@kymoscope/sdk 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +69 -0
- package/README.md +138 -2
- package/dist/assets/duckdb-browser-eh.worker--3HUwN9R.js +14 -0
- package/dist/assets/duckdb-eh-D-nnNw7L.wasm.gz +0 -0
- package/dist/assets/h5wasmModule-BCQWU2Gw.js +24295 -0
- package/dist/assets/importer.worker-D4is7BLf.js +6 -0
- package/dist/assets/offscreenLineWorker-mShhnyXX.js +79 -0
- package/dist/assets/parseDataset.worker-PynRsPD8.js +5 -0
- package/dist/importers-DivmF3tx.js +5 -0
- package/dist/krc-CbE28CjD.js +9 -0
- package/dist/kymoscope-embed.js +633 -0
- package/dist/kymoscope-sdk.js +616 -0
- package/dist/react.js +2 -0
- package/dist/styles/charts.css +207 -0
- package/dist/styles/fonts/OFL.txt +93 -0
- package/dist/styles/fonts/plus-jakarta-sans-italic-latin-ext.woff2 +0 -0
- package/dist/styles/fonts/plus-jakarta-sans-italic-latin.woff2 +0 -0
- package/dist/styles/fonts/plus-jakarta-sans-latin-ext.woff2 +0 -0
- package/dist/styles/fonts/plus-jakarta-sans-latin.woff2 +0 -0
- package/dist/styles/tokens.css +218 -0
- package/dist/types/charts/AlarmOverlay.d.ts +11 -0
- package/dist/types/charts/AnnotationLayer.d.ts +29 -0
- package/dist/types/charts/ChartBody.d.ts +52 -0
- package/dist/types/charts/PerfHud.d.ts +20 -0
- package/dist/types/charts/beacon.d.ts +27 -0
- package/dist/types/charts/chartWindow.d.ts +31 -0
- package/dist/types/charts/liveOverlay.d.ts +16 -0
- package/dist/types/charts/runtime.d.ts +63 -0
- package/dist/types/charts/useWorksheetData.d.ts +159 -0
- package/dist/types/components/AreaChart.d.ts +21 -0
- package/dist/types/components/BarChart.d.ts +30 -0
- package/dist/types/components/BoxPlotChart.d.ts +16 -0
- package/dist/types/components/BubbleChart.d.ts +24 -0
- package/dist/types/components/CalibrationChart.d.ts +15 -0
- package/dist/types/components/CdfChart.d.ts +15 -0
- package/dist/types/components/ConfusionChart.d.ts +11 -0
- package/dist/types/components/ControlChart.d.ts +17 -0
- package/dist/types/components/DuckDbMultiBandPanel.d.ts +35 -0
- package/dist/types/components/EmbeddingChart.d.ts +25 -0
- package/dist/types/components/FlameGraphChart.d.ts +15 -0
- package/dist/types/components/GanttChart.d.ts +15 -0
- package/dist/types/components/GaugeChart.d.ts +27 -0
- package/dist/types/components/HeatmapChart.d.ts +41 -0
- package/dist/types/components/HistogramChart.d.ts +15 -0
- package/dist/types/components/LossCurveChart.d.ts +17 -0
- package/dist/types/components/MultiBandCanvasChart.d.ts +156 -0
- package/dist/types/components/ParallelCoordsChart.d.ts +21 -0
- package/dist/types/components/PolarChart.d.ts +17 -0
- package/dist/types/components/QQPlotChart.d.ts +16 -0
- package/dist/types/components/RadarChart.d.ts +17 -0
- package/dist/types/components/RocChart.d.ts +12 -0
- package/dist/types/components/SankeyChart.d.ts +15 -0
- package/dist/types/components/SpectrogramChart.d.ts +16 -0
- package/dist/types/components/SpectrogramWaterfall.d.ts +14 -0
- package/dist/types/components/SpectrumChart.d.ts +17 -0
- package/dist/types/components/TreemapChart.d.ts +14 -0
- package/dist/types/components/ViolinChart.d.ts +17 -0
- package/dist/types/components/XYScatterChart.d.ts +47 -0
- package/dist/types/components/XYZMeshChart.d.ts +68 -0
- package/dist/types/components/dashboardGridLayout.d.ts +50 -0
- package/dist/types/components/liveFollowEase.d.ts +10 -0
- package/dist/types/components/liveWindow.d.ts +63 -0
- package/dist/types/components/multiBandHover.d.ts +44 -0
- package/dist/types/embed/Attribution.d.ts +5 -0
- package/dist/types/embed/license.d.ts +29 -0
- package/dist/types/embed/standalone.d.ts +5 -0
- package/dist/types/engine/columns.d.ts +44 -0
- package/dist/types/engine/createEngine.d.ts +394 -0
- package/dist/types/engine/derive.d.ts +27 -0
- package/dist/types/engine/emitter.d.ts +6 -0
- package/dist/types/engine/errors.d.ts +7 -0
- package/dist/types/engine/history.d.ts +29 -0
- package/dist/types/engine/kinds.d.ts +9 -0
- package/dist/types/engine/liveController.d.ts +27 -0
- package/dist/types/engine/store.d.ts +8 -0
- package/dist/types/engine/types.d.ts +194 -0
- package/dist/types/index.d.ts +69 -0
- package/dist/types/lib/annotations.d.ts +37 -0
- package/dist/types/lib/beacon.d.ts +62 -0
- package/dist/types/lib/colorScheme.d.ts +5 -0
- package/dist/types/lib/colormap.d.ts +9 -0
- package/dist/types/lib/columnTable.d.ts +37 -0
- package/dist/types/lib/data/arrowDecimation.d.ts +11 -0
- package/dist/types/lib/data/binnedHeatmap.d.ts +27 -0
- package/dist/types/lib/data/columnCaches.d.ts +6 -0
- package/dist/types/lib/data/columnarDataSource.d.ts +34 -0
- package/dist/types/lib/data/createDataSource.d.ts +23 -0
- package/dist/types/lib/data/dataSource.d.ts +75 -0
- package/dist/types/lib/data/decimate.d.ts +25 -0
- package/dist/types/lib/data/duckDbDataSource.d.ts +42 -0
- package/dist/types/lib/data/envelope.d.ts +16 -0
- package/dist/types/lib/data/inMemoryDataSource.d.ts +25 -0
- package/dist/types/lib/data/liveDataSource.d.ts +77 -0
- package/dist/types/lib/data/lruCache.d.ts +11 -0
- package/dist/types/lib/data/openDataset.d.ts +24 -0
- package/dist/types/lib/data/opfsParquet.d.ts +4 -0
- package/dist/types/lib/data/pointColumns.d.ts +59 -0
- package/dist/types/lib/data/schemaColumns.d.ts +5 -0
- package/dist/types/lib/data/useSeriesPoints.d.ts +48 -0
- package/dist/types/lib/data/xyColumns.d.ts +77 -0
- package/dist/types/lib/dataBounds.d.ts +10 -0
- package/dist/types/lib/datasetColors.d.ts +19 -0
- package/dist/types/lib/datasetColumns.d.ts +3 -0
- package/dist/types/lib/datasetMerge.d.ts +8 -0
- package/dist/types/lib/duckdb/duckdbInstance.d.ts +7 -0
- package/dist/types/lib/duckdb/fileIdentity.d.ts +9 -0
- package/dist/types/lib/duckdb/sql.d.ts +124 -0
- package/dist/types/lib/fft.d.ts +15 -0
- package/dist/types/lib/folderTree.d.ts +29 -0
- package/dist/types/lib/gaugeColors.d.ts +32 -0
- package/dist/types/lib/importers/arrowSink.d.ts +35 -0
- package/dist/types/lib/importers/blobReader.d.ts +22 -0
- package/dist/types/lib/importers/bytes.d.ts +11 -0
- package/dist/types/lib/importers/combine.d.ts +30 -0
- package/dist/types/lib/importers/comtrade/format.d.ts +2 -0
- package/dist/types/lib/importers/comtrade/importer.d.ts +25 -0
- package/dist/types/lib/importers/dbc.d.ts +45 -0
- package/dist/types/lib/importers/edf/format.d.ts +2 -0
- package/dist/types/lib/importers/edf/importer.d.ts +7 -0
- package/dist/types/lib/importers/expr.d.ts +10 -0
- package/dist/types/lib/importers/formats.d.ts +23 -0
- package/dist/types/lib/importers/hdf5/format.d.ts +4 -0
- package/dist/types/lib/importers/hdf5/h5.d.ts +76 -0
- package/dist/types/lib/importers/hdf5/h5wasmModule.d.ts +1 -0
- package/dist/types/lib/importers/hdf5/importer.d.ts +2 -0
- package/dist/types/lib/importers/importer.worker.d.ts +5 -0
- package/dist/types/lib/importers/importers.d.ts +4 -0
- package/dist/types/lib/importers/limits.d.ts +28 -0
- package/dist/types/lib/importers/mat/format.d.ts +2 -0
- package/dist/types/lib/importers/mat/group.d.ts +19 -0
- package/dist/types/lib/importers/mat/importer.d.ts +2 -0
- package/dist/types/lib/importers/mat/v5.d.ts +24 -0
- package/dist/types/lib/importers/mat/v73.d.ts +13 -0
- package/dist/types/lib/importers/mdf/blocks3.d.ts +3 -0
- package/dist/types/lib/importers/mdf/blocks4.d.ts +7 -0
- package/dist/types/lib/importers/mdf/bus.d.ts +59 -0
- package/dist/types/lib/importers/mdf/conversion.d.ts +48 -0
- package/dist/types/lib/importers/mdf/decode.d.ts +15 -0
- package/dist/types/lib/importers/mdf/format.d.ts +2 -0
- package/dist/types/lib/importers/mdf/importer.d.ts +19 -0
- package/dist/types/lib/importers/mdf/model.d.ts +75 -0
- package/dist/types/lib/importers/mdf/records.d.ts +31 -0
- package/dist/types/lib/importers/mdf/stream.d.ts +42 -0
- package/dist/types/lib/importers/memorySink.d.ts +11 -0
- package/dist/types/lib/importers/names.d.ts +2 -0
- package/dist/types/lib/importers/openImport.d.ts +33 -0
- package/dist/types/lib/importers/registry.d.ts +24 -0
- package/dist/types/lib/importers/run.d.ts +35 -0
- package/dist/types/lib/importers/session.d.ts +28 -0
- package/dist/types/lib/importers/tdms/format.d.ts +2 -0
- package/dist/types/lib/importers/tdms/importer.d.ts +10 -0
- package/dist/types/lib/importers/types.d.ts +172 -0
- package/dist/types/lib/importers/workerCore.d.ts +44 -0
- package/dist/types/lib/importers/xdf/format.d.ts +2 -0
- package/dist/types/lib/importers/xdf/importer.d.ts +2 -0
- package/dist/types/lib/importers/zlib.d.ts +13 -0
- package/dist/types/lib/kde.d.ts +2 -0
- package/dist/types/lib/live/buffer.d.ts +265 -0
- package/dist/types/lib/live/columnsWire.d.ts +24 -0
- package/dist/types/lib/live/crypto.d.ts +157 -0
- package/dist/types/lib/live/liveMathChannels.d.ts +11 -0
- package/dist/types/lib/live/recorder.d.ts +32 -0
- package/dist/types/lib/live/stream.d.ts +33 -0
- package/dist/types/lib/live/timeBuckets.d.ts +71 -0
- package/dist/types/lib/live/types.d.ts +72 -0
- package/dist/types/lib/live/wire.d.ts +25 -0
- package/dist/types/lib/mathChannels/compile.d.ts +22 -0
- package/dist/types/lib/mathChannels/evaluator.d.ts +40 -0
- package/dist/types/lib/mathChannels/functions/conditional.d.ts +2 -0
- package/dist/types/lib/mathChannels/functions/filters.d.ts +7 -0
- package/dist/types/lib/mathChannels/functions/index.d.ts +3 -0
- package/dist/types/lib/mathChannels/functions/reference.d.ts +7 -0
- package/dist/types/lib/mathChannels/functions/windowOps.d.ts +11 -0
- package/dist/types/lib/mathChannels/index.d.ts +13 -0
- package/dist/types/lib/mathChannels/io.d.ts +18 -0
- package/dist/types/lib/mathChannels/mathjsSetup.d.ts +7 -0
- package/dist/types/lib/mathChannels/parseMath.d.ts +12 -0
- package/dist/types/lib/mathChannels/parser.d.ts +22 -0
- package/dist/types/lib/mathChannels/types.d.ts +34 -0
- package/dist/types/lib/mathChannels/usedChannels.d.ts +14 -0
- package/dist/types/lib/moduleWorker.d.ts +7 -0
- package/dist/types/lib/panelChartSettings.d.ts +438 -0
- package/dist/types/lib/parseDataset.d.ts +74 -0
- package/dist/types/lib/parseDataset.worker.d.ts +1 -0
- package/dist/types/lib/parseDatasetWorkerClient.d.ts +32 -0
- package/dist/types/lib/perfLog.d.ts +4 -0
- package/dist/types/lib/quantiles.d.ts +10 -0
- package/dist/types/lib/recordings/csvWriter.d.ts +10 -0
- package/dist/types/lib/recordings/export.d.ts +26 -0
- package/dist/types/lib/recordings/importer.d.ts +2 -0
- package/dist/types/lib/recordings/keys.d.ts +23 -0
- package/dist/types/lib/recordings/krc.d.ts +38 -0
- package/dist/types/lib/recordings/mf4Writer.d.ts +20 -0
- package/dist/types/lib/render/chartFonts.d.ts +10 -0
- package/dist/types/lib/render/colorBucket.d.ts +6 -0
- package/dist/types/lib/render/contours.d.ts +16 -0
- package/dist/types/lib/render/cssColor.d.ts +2 -0
- package/dist/types/lib/render/frames.d.ts +46 -0
- package/dist/types/lib/render/gl3d.d.ts +63 -0
- package/dist/types/lib/render/glLines.d.ts +62 -0
- package/dist/types/lib/render/glPlot.d.ts +36 -0
- package/dist/types/lib/render/glPoints.d.ts +37 -0
- package/dist/types/lib/render/glSeries.d.ts +67 -0
- package/dist/types/lib/render/heatGrid.d.ts +9 -0
- package/dist/types/lib/render/hitGrid.d.ts +16 -0
- package/dist/types/lib/render/liveZoomBus.d.ts +18 -0
- package/dist/types/lib/render/margins.d.ts +14 -0
- package/dist/types/lib/render/offscreenLineRenderer.d.ts +53 -0
- package/dist/types/lib/render/offscreenLineWorker.d.ts +1 -0
- package/dist/types/lib/render/plotFrame.d.ts +36 -0
- package/dist/types/lib/render/resample.d.ts +18 -0
- package/dist/types/lib/render/sharedGl.d.ts +38 -0
- package/dist/types/lib/render/useGlPlot.d.ts +7 -0
- package/dist/types/lib/savedLayout.d.ts +45 -0
- package/dist/types/lib/stft.d.ts +37 -0
- package/dist/types/lib/workspaces/encrypted.d.ts +50 -0
- package/dist/types/lib/workspaces/io.d.ts +120 -0
- package/dist/types/lib/xyFit.d.ts +14 -0
- package/dist/types/lib/yAxisTicks.d.ts +28 -0
- package/dist/types/react/index.d.ts +32 -0
- package/dist/types/types/loadedDataset.d.ts +42 -0
- package/dist/types/types/plotSeries.d.ts +27 -0
- package/package.json +63 -4
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/** Live-stream types shared by the engine and charts. */
|
|
2
|
+
import type { EncryptedEnvelope } from './crypto';
|
|
3
|
+
import type { LiveColumnsBlock, LiveMessage } from './buffer';
|
|
4
|
+
import type { LiveDataSource } from '../data/liveDataSource';
|
|
5
|
+
import type { Dataset } from '../parseDataset';
|
|
6
|
+
/** What a viewer needs to join an encrypted relay stream (from the stream registry). */
|
|
7
|
+
export interface LiveStreamDescriptor {
|
|
8
|
+
id: string;
|
|
9
|
+
name: string;
|
|
10
|
+
/** PBKDF2 salt chosen by the publisher. */
|
|
11
|
+
salt: string;
|
|
12
|
+
/** Encrypted marker proving the password is right before any frame arrives. */
|
|
13
|
+
key_check: EncryptedEnvelope;
|
|
14
|
+
owner_name?: string;
|
|
15
|
+
visibility?: 'private' | 'public' | 'org' | 'project';
|
|
16
|
+
org_name?: string | null;
|
|
17
|
+
/** Null when the viewer can't see the project's name. */
|
|
18
|
+
project_name?: string | null;
|
|
19
|
+
/**
|
|
20
|
+
* The relay the stream goes through when it isn't the engine's (a relay its
|
|
21
|
+
* owner hosts). The engine's `getToken` is still asked for the credential.
|
|
22
|
+
*/
|
|
23
|
+
relay_url?: string | null;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The keys of a stream in an end-to-end encrypted project: frames name their key id
|
|
27
|
+
* (the project key epoch & 0xff); `keyFor` resolves it (null: not available yet, the
|
|
28
|
+
* frame is dropped). The host (e.g. Kymoscope's key steward) unwraps them.
|
|
29
|
+
*/
|
|
30
|
+
export interface StreamKeyProvider {
|
|
31
|
+
keyFor(keyId: number | null): Promise<CryptoKey | null>;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* How much of a stream a viewer keeps. Memory grows with the samples received,
|
|
35
|
+
* up to whichever limit comes first; past it the oldest samples are dropped.
|
|
36
|
+
*/
|
|
37
|
+
export interface LiveStreamOptions {
|
|
38
|
+
/** Samples kept per stream. Default 10,000,000. */
|
|
39
|
+
capacity?: number;
|
|
40
|
+
/** Memory a stream's samples may take, in MB (8 bytes per sample per channel,
|
|
41
|
+
* time included). Default 512. */
|
|
42
|
+
maxMemoryMB?: number;
|
|
43
|
+
}
|
|
44
|
+
/** A host-fed stream: frames pushed from the page itself — no network, no crypto. */
|
|
45
|
+
export interface LocalLiveStream {
|
|
46
|
+
id: string;
|
|
47
|
+
push: (frames: LiveMessage | LiveMessage[]) => void;
|
|
48
|
+
/**
|
|
49
|
+
* A block of samples by column: `t` and each signal the same length (typed
|
|
50
|
+
* arrays are copied in bulk). The way to feed high sample rates: no object
|
|
51
|
+
* per sample.
|
|
52
|
+
*/
|
|
53
|
+
pushColumns: (block: LiveColumnsBlock) => void;
|
|
54
|
+
close: () => void;
|
|
55
|
+
}
|
|
56
|
+
export interface LiveConnection {
|
|
57
|
+
id: string;
|
|
58
|
+
name: string;
|
|
59
|
+
ownerName: string;
|
|
60
|
+
visibility: 'private' | 'public' | 'org' | 'project';
|
|
61
|
+
orgName: string | null;
|
|
62
|
+
projectName?: string | null;
|
|
63
|
+
/** Slow (~1 Hz) snapshot for column discovery / count / non-multiband charts. */
|
|
64
|
+
dataset: Dataset;
|
|
65
|
+
/** Live decimation source read by the multiband chart every frame (no React). */
|
|
66
|
+
source: LiveDataSource;
|
|
67
|
+
rowCount: number;
|
|
68
|
+
status: 'connecting' | 'live' | 'stale' | 'error';
|
|
69
|
+
error: string | null;
|
|
70
|
+
/** When a recording is running: its start time (ms since epoch). */
|
|
71
|
+
recordingSince: number | null;
|
|
72
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export declare const KIND_SCHEMA = 1;
|
|
2
|
+
export declare const KIND_FRAMES = 2;
|
|
3
|
+
/** A block of samples by column (see columnsWire.ts): what high-rate publishers send. */
|
|
4
|
+
export declare const KIND_COLUMNS = 3;
|
|
5
|
+
export declare const KEY_ID_FLAG = 128;
|
|
6
|
+
export interface SealedMessage {
|
|
7
|
+
kind: number;
|
|
8
|
+
/** The project key epoch & 0xff; null for password streams. */
|
|
9
|
+
keyId: number | null;
|
|
10
|
+
iv: Uint8Array;
|
|
11
|
+
ciphertext: Uint8Array;
|
|
12
|
+
aad: Uint8Array;
|
|
13
|
+
}
|
|
14
|
+
export declare function parseMessage(buf: ArrayBuffer): SealedMessage | null;
|
|
15
|
+
/** The key of a message: one key, or per key id (project streams; null = not available). */
|
|
16
|
+
export type MessageKey = CryptoKey | ((keyId: number | null) => Promise<CryptoKey | null>);
|
|
17
|
+
/** Parse + decrypt. Null if malformed or its key isn't available; throws if authentication fails. */
|
|
18
|
+
export declare function openMessage(key: MessageKey, buf: ArrayBuffer): Promise<{
|
|
19
|
+
kind: number;
|
|
20
|
+
plaintext: Uint8Array;
|
|
21
|
+
} | null>;
|
|
22
|
+
/** Seal a relay message (`keyId` given: the project-stream header). For tests and local publishers. */
|
|
23
|
+
export declare function sealMessage(key: CryptoKey, kind: number, plaintext: Uint8Array, keyId?: number): Promise<ArrayBuffer>;
|
|
24
|
+
/** @internal sealMessage with a fixed IV: pinned test vectors only (not in index.ts). */
|
|
25
|
+
export declare function sealMessageWith(key: CryptoKey, kind: number, plaintext: Uint8Array, keyId?: number, _iv?: Uint8Array): Promise<ArrayBuffer>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { MathJsInstance, MathNode } from 'mathjs';
|
|
2
|
+
/**
|
|
3
|
+
* A formula compiled to one JS loop over typed columns: writes row i's result
|
|
4
|
+
* to out[i] (NaN = null), reading input k from cols[k][i]. Throws what mathjs
|
|
5
|
+
* would throw on the first row it would throw on.
|
|
6
|
+
*/
|
|
7
|
+
export type Kernel = (out: Float64Array, cols: Float64Array[], n: number) => void;
|
|
8
|
+
/**
|
|
9
|
+
* Compile `node` (inputs named by `inputs`, input k = cols[k]) or null when it
|
|
10
|
+
* holds anything not handled here, so the caller evaluates it with mathjs.
|
|
11
|
+
*
|
|
12
|
+
* Exact by construction rather than by reimplementing mathjs: values stay the
|
|
13
|
+
* JS values mathjs would see (numbers, booleans, null, Complex), every
|
|
14
|
+
* operator and function is the very function mathjs would call, and only the
|
|
15
|
+
* dispatch is skipped: when all arguments are numbers the call goes straight
|
|
16
|
+
* to the implementation typed-function would pick for them (typed.find),
|
|
17
|
+
* otherwise to the typed function itself (conversions, errors and all).
|
|
18
|
+
*
|
|
19
|
+
* A row with any non-finite input (a column, or a window op's result) is a
|
|
20
|
+
* gap (NaN) without evaluating.
|
|
21
|
+
*/
|
|
22
|
+
export declare function compileKernel(math: MathJsInstance, node: MathNode, inputs: string[]): Kernel | null;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { Dataset } from '../parseDataset';
|
|
2
|
+
import type { EvalResult, MathChannel } from './types';
|
|
3
|
+
/** evalChannelColumns' result: values with NaN for null; `compiled` when a compiled kernel produced them. */
|
|
4
|
+
export interface ColumnsResult extends Omit<EvalResult, 'values'> {
|
|
5
|
+
values: Float64Array;
|
|
6
|
+
compiled?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare function evalChannel(channel: MathChannel, dataset: Dataset, xKey: string, otherChannels: MathChannel[]): EvalResult;
|
|
9
|
+
/** Test-only: evaluate with mathjs alone (the reference the kernels must match). */
|
|
10
|
+
export declare function _setCompiledKernels(on: boolean): void;
|
|
11
|
+
/**
|
|
12
|
+
* evalChannel over columns: `column(name)` is that column's values (NaN or any
|
|
13
|
+
* non-finite value = empty), undefined when the dataset has no such column.
|
|
14
|
+
* Formulas run as compiled kernels when compileKernel handles them, else
|
|
15
|
+
* through mathjs row by row; both give the same values and statuses.
|
|
16
|
+
*/
|
|
17
|
+
export declare function evalChannelColumns(channel: MathChannel, column: (name: string) => Float64Array | undefined, xKey: string, length: number, otherChannels: MathChannel[], carry?: IntegralCarry): ColumnsResult;
|
|
18
|
+
/**
|
|
19
|
+
* Running integrals across evaluations of a growing series (live channels are
|
|
20
|
+
* evaluated over the newest samples only): the k-th integral() call of a formula
|
|
21
|
+
* starts from `start(k)` instead of 0, and `done(k, values)` hands back what it
|
|
22
|
+
* computed, for the next evaluation to continue from.
|
|
23
|
+
*/
|
|
24
|
+
export interface IntegralCarry {
|
|
25
|
+
start(k: number): number;
|
|
26
|
+
done(k: number, values: ArrayLike<number | null>): void;
|
|
27
|
+
}
|
|
28
|
+
export declare function evalAllChannels(channels: MathChannel[], dataset: Dataset, xKey: string): Record<string, EvalResult>;
|
|
29
|
+
type Materialized = {
|
|
30
|
+
rows: Dataset['rows'];
|
|
31
|
+
ok: MathChannel[];
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* `part`'s rows extended with the `ok` channels' values, evaluated on this part
|
|
35
|
+
* alone (window ops never mix samples across datasets). Cached per rows array
|
|
36
|
+
* and channels-array identity, so showing/hiding one dataset reuses the others'
|
|
37
|
+
* materialized rows instead of re-evaluating and re-cloning everything.
|
|
38
|
+
*/
|
|
39
|
+
export declare function materializeChannels(part: Dataset, channels: MathChannel[], xKey: string): Materialized;
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Numlike } from './windowOps';
|
|
2
|
+
/** Median of finite values, used to infer sample rate from a time column (null or NaN = empty). */
|
|
3
|
+
export declare function inferSampleRate(x: ArrayLike<Numlike>): number;
|
|
4
|
+
export declare function lowpass(y: Numlike[], fc: number, fs: number): Numlike[];
|
|
5
|
+
export declare function highpass(y: Numlike[], fc: number, fs: number): Numlike[];
|
|
6
|
+
export declare function lowpassCol(y: Float64Array, fc: number, fs: number): Float64Array | null;
|
|
7
|
+
export declare function highpassCol(y: Float64Array, fc: number, fs: number): Float64Array | null;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type Numlike = number | null;
|
|
2
|
+
export declare function derivative(y: Numlike[], x: Numlike[]): Numlike[];
|
|
3
|
+
export declare function integral(y: Numlike[], x: Numlike[]): Numlike[];
|
|
4
|
+
export declare function movavg(y: Numlike[], n: number): Numlike[];
|
|
5
|
+
export declare function lag(y: Numlike[], n: number): Numlike[];
|
|
6
|
+
export declare function lead(y: Numlike[], n: number): Numlike[];
|
|
7
|
+
export declare function derivativeCol(y: Float64Array, x: Float64Array): Float64Array | null;
|
|
8
|
+
export declare function integralCol(y: Float64Array, x: Float64Array): Float64Array | null;
|
|
9
|
+
export declare function movavgCol(y: Float64Array, n: number): Float64Array | null;
|
|
10
|
+
export declare function lagCol(y: Float64Array, n: number): Float64Array;
|
|
11
|
+
export declare function leadCol(y: Float64Array, n: number): Float64Array;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type { MathChannel, MathChannelPatch, EvalResult, EvalStatus, MathChannelsBundle, } from './types';
|
|
2
|
+
export { newMathChannel } from './types';
|
|
3
|
+
export { evalChannel, evalAllChannels, materializeChannels } from './evaluator';
|
|
4
|
+
export { pickUsedChannels } from './usedChannels';
|
|
5
|
+
export { parseFormula, extractFreeIdentifiers, WINDOW_FN_NAMES } from './parser';
|
|
6
|
+
export { FUNCTION_REFERENCE } from './functions/reference';
|
|
7
|
+
export type { FunctionDoc } from './functions/reference';
|
|
8
|
+
export declare function isMathChannelName(name: string, channels: {
|
|
9
|
+
name: string;
|
|
10
|
+
}[]): boolean;
|
|
11
|
+
export declare function decorateColumnLabel(name: string, channels: {
|
|
12
|
+
name: string;
|
|
13
|
+
}[]): string;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { MathChannel } from './types';
|
|
2
|
+
export interface ExportEnvelope {
|
|
3
|
+
version: 1;
|
|
4
|
+
exportedAt: string;
|
|
5
|
+
channels: Array<{
|
|
6
|
+
name: string;
|
|
7
|
+
units: string;
|
|
8
|
+
formula: string;
|
|
9
|
+
enabled: boolean;
|
|
10
|
+
description?: string;
|
|
11
|
+
}>;
|
|
12
|
+
}
|
|
13
|
+
export interface ImportResult {
|
|
14
|
+
channels: MathChannel[];
|
|
15
|
+
errors: string[];
|
|
16
|
+
}
|
|
17
|
+
export declare function buildExportBlob(channels: MathChannel[]): Blob;
|
|
18
|
+
export declare function parseImportFile(file: File): Promise<ImportResult>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type MathJsInstance } from 'mathjs';
|
|
2
|
+
export type SetupFn = (m: MathJsInstance) => void;
|
|
3
|
+
export declare function createMathInstance(setup?: SetupFn): MathJsInstance;
|
|
4
|
+
/** Parses a formula with an instance made by createMathInstance. */
|
|
5
|
+
export declare function hostParse(m: MathJsInstance, formula: string): import("mathjs").MathNode;
|
|
6
|
+
/** Evaluates a formula with an instance made by createMathInstance. */
|
|
7
|
+
export declare function hostEvaluate(m: MathJsInstance, formula: string, scope?: Record<string, unknown>): unknown;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { MathNode } from 'mathjs';
|
|
2
|
+
/** parseFormula with the node typed as mathjs's MathNode, for the evaluator. */
|
|
3
|
+
export type MathParseResult = {
|
|
4
|
+
ok: true;
|
|
5
|
+
node: MathNode;
|
|
6
|
+
} | {
|
|
7
|
+
ok: false;
|
|
8
|
+
message: string;
|
|
9
|
+
};
|
|
10
|
+
export declare function parseMathFormula(formula: string): MathParseResult;
|
|
11
|
+
/** Test-only: clear the AST cache between tests if needed. */
|
|
12
|
+
export declare function _resetParserCache(): void;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export declare const WINDOW_FN_NAMES: readonly ["derivative", "integral", "movavg", "lag", "lead", "lowpass", "highpass"];
|
|
2
|
+
/**
|
|
3
|
+
* A parsed formula: a mathjs expression tree, typed locally so the published declarations do not need
|
|
4
|
+
* mathjs. Pass it to {@link extractFreeIdentifiers}; anything deeper is a mathjs `MathNode`.
|
|
5
|
+
*/
|
|
6
|
+
export interface FormulaNode {
|
|
7
|
+
readonly type: string;
|
|
8
|
+
toString(): string;
|
|
9
|
+
}
|
|
10
|
+
export type ParseResult = {
|
|
11
|
+
ok: true;
|
|
12
|
+
node: FormulaNode;
|
|
13
|
+
} | {
|
|
14
|
+
ok: false;
|
|
15
|
+
message: string;
|
|
16
|
+
};
|
|
17
|
+
export declare function parseFormula(formula: string): ParseResult;
|
|
18
|
+
export interface FreeIdentifiers {
|
|
19
|
+
identifiers: string[];
|
|
20
|
+
functions: string[];
|
|
21
|
+
}
|
|
22
|
+
export declare function extractFreeIdentifiers(formula: FormulaNode): FreeIdentifiers;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export type MathChannelSource = 'personal' | 'subscribed' | 'workbook';
|
|
2
|
+
export interface MathChannel {
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
units: string;
|
|
6
|
+
formula: string;
|
|
7
|
+
enabled: boolean;
|
|
8
|
+
description?: string;
|
|
9
|
+
createdAt: number;
|
|
10
|
+
updatedAt: number;
|
|
11
|
+
source: MathChannelSource;
|
|
12
|
+
/** @deprecated use projectId */
|
|
13
|
+
sharedWithOrgId: string | null;
|
|
14
|
+
/** The project the channel belongs to (null: its owner's personal space). */
|
|
15
|
+
projectId: string | null;
|
|
16
|
+
projectName?: string | null;
|
|
17
|
+
ownerUserId: string;
|
|
18
|
+
ownerDisplayName: string | null;
|
|
19
|
+
ownerLastName: string | null;
|
|
20
|
+
}
|
|
21
|
+
export type MathChannelPatch = Partial<Pick<MathChannel, 'name' | 'units' | 'formula' | 'enabled' | 'description'>>;
|
|
22
|
+
export type EvalStatus = 'ok' | 'missing-inputs' | 'parse-error' | 'runtime-error' | 'disabled' | 'references-channel';
|
|
23
|
+
export interface EvalResult {
|
|
24
|
+
channelId: string;
|
|
25
|
+
status: EvalStatus;
|
|
26
|
+
values: (number | null)[];
|
|
27
|
+
message?: string;
|
|
28
|
+
missingCols?: string[];
|
|
29
|
+
}
|
|
30
|
+
export interface MathChannelsBundle {
|
|
31
|
+
version: 1;
|
|
32
|
+
channels: MathChannel[];
|
|
33
|
+
}
|
|
34
|
+
export declare function newMathChannel(partial?: Partial<MathChannel>): MathChannel;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Math channels that are actually plotted — referenced by a panel (as a series,
|
|
3
|
+
* axis, color, heatmap column, ...) or used as the X key.
|
|
4
|
+
*
|
|
5
|
+
* Detection scans the serialized panel settings so it catches every reference
|
|
6
|
+
* shape without coupling to each chart type. Channels NOT returned can be skipped
|
|
7
|
+
* during materialization — a big per-frame win for live data, where materializing
|
|
8
|
+
* an unused channel spreads the whole dataset into new rows on every tick. The
|
|
9
|
+
* skipped channels stay available to add to a chart (the picker sources their
|
|
10
|
+
* names separately).
|
|
11
|
+
*/
|
|
12
|
+
export declare function pickUsedChannels<T extends {
|
|
13
|
+
name: string;
|
|
14
|
+
}>(channels: T[], panelSettings: unknown, xKey: string): T[];
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Starts a module worker from a bundled worker URL (`import url from './x.worker.ts?worker&url'`).
|
|
3
|
+
* Browsers refuse `new Worker(url)` across origins, which is the case when the SDK script is served
|
|
4
|
+
* from a CDN; a same-origin blob module that imports the real worker is allowed (the import is an
|
|
5
|
+
* ordinary CORS fetch, and the worker's own relative imports resolve against its real URL).
|
|
6
|
+
*/
|
|
7
|
+
export declare function moduleWorker(url: string): Worker;
|