Skip to main content

export=

FitFileViewer - API Documentation v29.4.0


FitFileViewer - API Documentation / main / export=

Variable: export=

const export=: { CONSTANTS: Readonly<{ DEFAULT_THEME: "dark"; DIALOG_FILTERS: Readonly<{ ALL_FILES: readonly (Readonly<{ extensions: string[]; name: "FIT Files"; }> | Readonly<{ extensions: string[]; name: "All Files"; }>)[]; EXPORT_FILES: readonly (Readonly<{ extensions: string[]; name: "CSV (Summary Table)"; }> | Readonly<{ extensions: string[]; name: "GPX (Track)"; }> | Readonly<{ extensions: string[]; name: "All Files"; }>)[]; FIT_FILES: readonly Readonly<{ extensions: string[]; name: "FIT Files"; }>[]; }>; LOG_LEVELS: Readonly<{ ERROR: "error"; INFO: "info"; WARN: "warn"; }>; PLATFORMS: Readonly<{ DARWIN: "darwin"; LINUX: "linux"; WIN32: "win32"; }>; SETTINGS_CONFIG_NAME: "settings"; THEME_STORAGE_KEY: "ffv-theme"; UPDATE_EVENTS: Readonly<{ AVAILABLE: "update-available"; CHECKING: "update-checking"; DOWNLOAD_PROGRESS: "update-download-progress"; DOWNLOADED: "update-downloaded"; ERROR: "update-error"; NOT_AVAILABLE: "update-not-available"; }>; }>; ensureFitParserStateIntegration: () => Promise<void>; exposeDevHelpers: () => void; getAppState: (statePath: string) => any; getThemeFromRenderer: (win: any) => Promise<string>; initializeApplication: () => Promise<any>; isWindowUsable: (win: any) => boolean; logWithContext: (level: string, message: string, context?: Record<string, unknown>) => void; resolveAutoUpdaterAsync: () => Promise<any>; resolveAutoUpdaterSync: () => any; sendToRenderer: (win: any, channel: string, ...args: any[]) => void; setAppState: (statePath: string, value: any, options?: Record<string, any>) => void; setupApplicationEventHandlers: () => void; setupAutoUpdater: (mainWindow: any, providedAutoUpdater?: any) => void; setupIPCHandlers: (mainWindow: any) => void; setupMainLifecycle: (deps: LifecycleDependencies) => void; setupMenuAndEventHandlers: () => void; startGyazoOAuthServer: (port?: number) => Promise<{ success: boolean; message: string; port?: number; }>; stopGyazoOAuthServer: () => Promise<{ success: boolean; message: string; }>; validateWindow: (win: any, context?: string) => boolean; }

Defined in: main.js:41

Type Declaration​

CONSTANTS​

CONSTANTS: Readonly<{ DEFAULT_THEME: "dark"; DIALOG_FILTERS: Readonly<{ ALL_FILES: readonly (Readonly<{ extensions: string[]; name: "FIT Files"; }> | Readonly<{ extensions: string[]; name: "All Files"; }>)[]; EXPORT_FILES: readonly (Readonly<{ extensions: string[]; name: "CSV (Summary Table)"; }> | Readonly<{ extensions: string[]; name: "GPX (Track)"; }> | Readonly<{ extensions: string[]; name: "All Files"; }>)[]; FIT_FILES: readonly Readonly<{ extensions: string[]; name: "FIT Files"; }>[]; }>; LOG_LEVELS: Readonly<{ ERROR: "error"; INFO: "info"; WARN: "warn"; }>; PLATFORMS: Readonly<{ DARWIN: "darwin"; LINUX: "linux"; WIN32: "win32"; }>; SETTINGS_CONFIG_NAME: "settings"; THEME_STORAGE_KEY: "ffv-theme"; UPDATE_EVENTS: Readonly<{ AVAILABLE: "update-available"; CHECKING: "update-checking"; DOWNLOAD_PROGRESS: "update-download-progress"; DOWNLOADED: "update-downloaded"; ERROR: "update-error"; NOT_AVAILABLE: "update-not-available"; }>; }>

Shared constants for the Electron main process. Extracted from the legacy monolithic main.js to help other modules consume configuration without re-defining values.

ensureFitParserStateIntegration()​

ensureFitParserStateIntegration: () => Promise<void>

Ensures that fit parser state integration has executed once. Subsequent calls reuse the same promise to avoid re-registering identical adapters.

Returns​

Promise<void>

Initialization guard promise.

exposeDevHelpers()​

exposeDevHelpers: () => void

Attaches debugging helpers to the global object for development builds. Mirroring the legacy behaviour keeps the devtools workflow untouched while allowing the logic to live outside main.js.

Returns​

void

getAppState()​

getAppState: (statePath: string) => any

Returns the current value for a state key from the main process state manager.

Parameters​

statePath​

string

Dot-notation state path (e.g. "fitFile.lastResult").

Returns​

any

Stored state value.

getThemeFromRenderer()​

getThemeFromRenderer: (win: any) => Promise<string>

Fetches the persisted theme from the renderer by reading localStorage. The helper is resilient to missing BrowserWindow instances so Jasmine/Vitest environments without a DOM do not crash.

Parameters​

win​

any

BrowserWindow whose webContents will be queried.

Returns​

Promise<string>

Resolved theme name falling back to the default theme.

initializeApplication()​

initializeApplication: () => Promise<any>

Bootstraps the main application window and wires up auto-updater integration. Extracted from the monolithic main.js to make the orchestration easier to comprehend.

Returns​

Promise<any>

Resolves with the created BrowserWindow instance.

isWindowUsable()​

isWindowUsable: (win: any) => boolean

Determines whether the provided BrowserWindow is still usable.

Parameters​

win​

any

Candidate BrowserWindow instance.

Returns​

boolean

True when the window and its webContents remain alive.

logWithContext()​

logWithContext: (level: string, message: string, context?: Record<string, unknown>) => void

Logs a message from the main process with optional structured context for easier debugging. The implementation mirrors the behaviour that previously lived in main.js so existing log expectations in tests remain unchanged.

Parameters​

level​

string

Console method to invoke.

message​

string

Message to log.

context?​

Record<string, unknown> = {}

Optional context payload serialized to JSON.

Returns​

void

resolveAutoUpdaterAsync()​

resolveAutoUpdaterAsync: () => Promise<any>

Returns​

Promise<any>

resolveAutoUpdaterSync()​

resolveAutoUpdaterSync: () => any

Resolves electron-updater synchronously supporting both CJS and ESM default exports.

Returns​

any

autoUpdater instance or null when unavailable.

sendToRenderer()​

sendToRenderer: (win: any, channel: string, ...args: any[]) => void

Sends an IPC message to the renderer only when the target window is still usable.

Parameters​

win​

any

BrowserWindow instance.

channel​

string

IPC channel.

args​

...any[]

Payload forwarded to webContents.send.

Returns​

void

setAppState()​

setAppState: (statePath: string, value: any, options?: Record<string, any>) => void

Persists a value into main process state.

Parameters​

statePath​

string

Dot-notation path to update.

value​

any

Value to persist.

options?​

Record<string, any> = {}

Additional metadata forwarded to the state manager.

Returns​

void

setupApplicationEventHandlers()​

setupApplicationEventHandlers: () => void

Registers core application-level Electron event handlers (activate, window-all-closed, etc.).

Returns​

void

setupAutoUpdater()​

setupAutoUpdater: (mainWindow: any, providedAutoUpdater?: any) => void

Configures electron-updater for the application, wiring all event handlers to relay progress to the renderer. The logic matches the historic main.js implementation so behaviour and logging stay consistent.

Parameters​

mainWindow​

any

BrowserWindow receiving updater events.

providedAutoUpdater?​

any

Optional pre-resolved autoUpdater (used by tests).

Returns​

void

setupIPCHandlers()​

setupIPCHandlers: (mainWindow: any) => void

Registers all IPC handlers for the main process. The structure mirrors the legacy implementation but lives in a dedicated module to keep main.js lean.

Parameters​

mainWindow​

any

Primary BrowserWindow instance (may be undefined in some test scenarios).

Returns​

void

setupMainLifecycle()​

setupMainLifecycle: (deps: LifecycleDependencies) => void

Registers the full main-process lifecycle, including test fallbacks that eagerly initialize the window and IPC wiring.

Parameters​

deps​

LifecycleDependencies

Returns​

void

setupMenuAndEventHandlers()​

setupMenuAndEventHandlers: () => void

Registers menu-related IPC handlers and listeners.

Returns​

void

startGyazoOAuthServer()​

startGyazoOAuthServer: (port?: number) => Promise<{ success: boolean; message: string; port?: number; }>

Starts the local OAuth callback server used for Gyazo integrations. The implementation mirrors the previous main.js logic, including informative logging and defensive error handling for tests.

Parameters​

port?​

number = 3000

Desired port for the callback server.

Returns​

Promise<{ success: boolean; message: string; port?: number; }>

Server status payload.

stopGyazoOAuthServer()​

stopGyazoOAuthServer: () => Promise<{ success: boolean; message: string; }>

Stops the Gyazo OAuth callback server if it is currently running.

Returns​

Promise<{ success: boolean; message: string; }>

Server shutdown payload.

validateWindow()​

validateWindow: (win: any, context?: string) => boolean

Validates that a BrowserWindow is usable and logs a structured warning when it is not.

Parameters​

win​

any

Target BrowserWindow instance.

context?​

string = "unknown operation"

Description of the operation requiring the window.

Returns​

boolean

True when the window can be used.