Use the public exporters for event output. EventExporterGPX writes activities with positional data as GPX; activities without positional data do not contribute tracks to the result.
import { EventExporterGPX, SportsLib } from '@sports-alliance/sports-lib';
const event = await SportsLib.importFromFit(fitArrayBuffer);
const exporter = new EventExporterGPX();
const gpxText = await exporter.getAsString(event);
const file = new Blob([gpxText], { type: exporter.fileType });
Native JSON is the lossless persistence format for the Sports Lib model. Call toJSON() to obtain the typed contract and restore it with the corresponding SportsLib method.
import { EventExporterJSON, SportsLib } from '@sports-alliance/sports-lib';
const eventJson = event.toJSON();
const restoredEvent = SportsLib.importFromJSON(eventJson);
const jsonText = await EventExporterJSON.getAsString(event);
const restoredFromText = SportsLib.importFromJSON(JSON.parse(jsonText));
const routeJson = routeFile.toJSON();
const restoredRouteFile = SportsLib.importRoutesFromJSON(routeJson);
The EventJSONInterface and RouteFileJSONInterface API pages describe the JSON shapes. Use native route JSON when route metadata must be retained beyond FIT Course capabilities.