API reference

createEngine()

Create an engine. An ESM export of @kymoscope/sdk and Kymoscope.createEngine in the script build.

Signature

TypeScript
function createEngine(options?: EngineOptions): KymoscopeEngine

Options

NameTypeDescription
licenseKeystringLicense key for this domain. Without a valid one, every mounted chart shows a small attribution badge. See Licensing.
license{ get: () => Promise<string> }Fetches license keys from your backend, which calls license-renew. Called at creation and again 7 days before the held key expires; a rejection, an invalid key or no answer within 30 s keeps the current key and retries every hour. With licenseKey too, that key is used until the first successful get. See Automatic renewal.
limitsPartial<KymoscopeLimits>
Default: unlimited
Quantity limits. See Limits and errors.
mathChannelsMathChannelStoreAdapter
Default: in memory
Where math-channel changes are persisted. See Math channels.
live.relayLiveRelayConfigRelay URL and credential provider for encrypted streams. Without it, only local streams work.
beforeImport() => boolean | void | Promise<boolean | void>Runs before every datasets.importFiles call; return false to cancel it (rejects with import_vetoed).
palettestring[]Colors given to plotted datasets in order (the first plotted gets the first color, cycling); a color set with datasets.setColor still wins. Hex colors; defaults to DATASET_PALETTE.

Engine members

NameTypeDescription
getState()() => EngineStateThe current immutable state snapshot.
subscribe(listener)(listener: () => void) => () => voidCalled once per effective state change. Returns the unsubscribe function.
on(event, listener)(event: keyof EngineEvents, listener) => () => voidEngine events: change, limit, error, import. See Events.
licensedPromise<boolean>Whether this page holds a valid license, after the first check: of licenseKey, or of the first license.get when given. Never rejects. Later renewals update isLicensed() and state.licensed, not this promise.
isLicensed()() => boolean | nullThe current license state: null until the first check finishes, then true or false (it changes when a renewal succeeds or the held key stops verifying).
setOptions(options)(options: Partial<Omit<EngineOptions, 'licenseKey' | 'license'>>) => voidUpdate limits (merged into the current ones), the math-channel store, the relay, beforeImport or the palette at runtime.
dispose()() => voidDestroy every chart view, close live connections and free datasets. Later calls throw disposed.
history{ undo(): void; redo(): void; clear(): void }Undo/redo of the analysis; getState().history.canUndo / canRedo say whether there is a step. Cleared by io.openWorkbook, importWorkspace, restore and reset. See Undo and redo.
datasets, folders, worksheets, charts, view, mathChannels, live, io, datanamespacesSee Engine namespaces.