@kymoscope/sdk 0.24.0 → 0.26.0
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/dist/assets/{importer.worker-CiiLni0T.js → importer.worker-q_b4_xbW.js} +1 -1
- package/dist/importer-DXGqA1PR.js +12 -0
- package/dist/{importers-GN37e7wh.js → importers-HtqEQxrK.js} +2 -2
- package/dist/kymoscope-embed.js +124 -124
- package/dist/kymoscope-sdk.js +86 -86
- package/dist/types/components/MultiBandCanvasChart.d.ts +5 -1
- package/dist/types/engine/createEngine.d.ts +2 -0
- package/dist/types/engine/types.d.ts +6 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/lib/data/liveDataSource.d.ts +22 -1
- package/dist/types/lib/diagnostics/encode.d.ts +12 -0
- package/dist/types/lib/diagnostics/index.d.ts +2 -0
- package/dist/types/lib/diagnostics/registry.d.ts +23 -0
- package/dist/types/lib/diagnostics/sampler.d.ts +79 -0
- package/dist/types/lib/diagnostics/session.d.ts +22 -0
- package/dist/types/lib/exemptWorksheet.d.ts +6 -0
- package/dist/types/lib/live/buffer.d.ts +34 -2
- package/dist/types/lib/live/publisher.d.ts +1 -1
- package/dist/types/lib/live/wire.d.ts +2 -0
- package/package.json +1 -1
- package/dist/importer-CLYlv_9G.js +0 -12
|
@@ -21,7 +21,11 @@ export interface LiveChartSource {
|
|
|
21
21
|
* last time (datasets under a live overlay, a beacon's reference) is measured
|
|
22
22
|
* and handed to the line renderer once; the others every time the data changes.
|
|
23
23
|
*/
|
|
24
|
-
pull: (x0: number, x1: number, maxPoints: number, cutX?: number, clipsCut?: boolean) => PointColumns[];
|
|
24
|
+
pull: (x0: number, x1: number, maxPoints: number, cutX?: number, clipsCut?: boolean, window?: [number, number]) => PointColumns[];
|
|
25
|
+
/** With it, a live window on this X is in time (see the chart's tick): the X span of the samples whose time is in
|
|
26
|
+
* [t0, t1] (null: none), and `pull` is given that `window` (instead of cutX) to draw only those samples. For an X
|
|
27
|
+
* that is not time (lap distance). */
|
|
28
|
+
windowXBounds?: (t0: number, t1: number) => [number, number] | null;
|
|
25
29
|
/** With `clipsCut` (see pull), the points come back untrimmed and unchanged until the data changes, and the chart
|
|
26
30
|
* clips them at the display edge on the GPU: no copy of every point each frame. Set only when every layer is
|
|
27
31
|
* this live trace (a dataset or reference under it must not be clipped). */
|
|
@@ -59,6 +59,8 @@ export interface InternalState {
|
|
|
59
59
|
video: VideoSource[];
|
|
60
60
|
mathChannels: MathChannel[];
|
|
61
61
|
limits: KymoscopeLimits;
|
|
62
|
+
/** Worksheets outside the limits (worksheets.add with `exempt`). Never saved. */
|
|
63
|
+
exempt: string[];
|
|
62
64
|
palette: string[];
|
|
63
65
|
importing: number;
|
|
64
66
|
/** null until the licence check finishes. */
|
|
@@ -25,6 +25,9 @@ export interface KymoscopeLimits {
|
|
|
25
25
|
canImportExportWorkspaces: boolean;
|
|
26
26
|
}
|
|
27
27
|
export declare const UNLIMITED: KymoscopeLimits;
|
|
28
|
+
/** The worksheets a worksheet limit of `max` shows (at least one): every exempt one (lib/exemptWorksheet,
|
|
29
|
+
* host-only), plus the first `max` of the others. */
|
|
30
|
+
export declare function worksheetsWithinLimit<W>(list: W[], max: number | null, exempt: (w: W) => boolean): W[];
|
|
28
31
|
/**
|
|
29
32
|
* Where math channels are persisted. Without one they live in memory. With one,
|
|
30
33
|
* the engine calls these for every change and the host pushes its authoritative
|
|
@@ -161,6 +164,9 @@ export interface WorksheetState {
|
|
|
161
164
|
/** Live window of the worksheet's charts (seconds; null = all): each worksheet has its own. */
|
|
162
165
|
liveWindowSeconds: number | null;
|
|
163
166
|
charts: ChartModel[];
|
|
167
|
+
/** Outside the host's limits (lib/exemptWorksheet, host-only): its charts and channels are never limited, and
|
|
168
|
+
* it doesn't count toward the worksheet limit. Never saved: a loaded worksheet is limited. */
|
|
169
|
+
exempt?: boolean;
|
|
164
170
|
}
|
|
165
171
|
export interface LiveConnectionInfo {
|
|
166
172
|
id: string;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export { createEngine } from './engine/createEngine';
|
|
|
12
12
|
export type { KymoscopeEngine, Snapshot, ImportSource, ImportResult, ImportOptions, Exported, ParsedFile, ChartSettingsPatch, } from './engine/createEngine';
|
|
13
13
|
export { KymoscopeError } from './engine/errors';
|
|
14
14
|
export type { KymoscopeErrorCode } from './engine/errors';
|
|
15
|
-
export { UNLIMITED } from './engine/types';
|
|
15
|
+
export { UNLIMITED, worksheetsWithinLimit } from './engine/types';
|
|
16
16
|
export type { EngineOptions, EngineState, EngineEvents, KymoscopeLimits, LimitReason, MathChannelStoreAdapter, DatasetInfo, ColumnInfo, LapInfo, LapCycle, ChartKind, ChartModel, WorksheetState, LiveConnectionInfo, } from './engine/types';
|
|
17
17
|
export type { ChartMark, RuleStateInfo } from './engine/alerts';
|
|
18
18
|
export { CHART_KINDS, chartLabel } from './engine/kinds';
|
|
@@ -30,7 +30,10 @@ export declare class LiveDataSource implements DataSource {
|
|
|
30
30
|
* out of the ring when first asked for (incrementally, see
|
|
31
31
|
* LiveBuffer.mirrorColumn). A new map per call: the columns as they are now.
|
|
32
32
|
*/
|
|
33
|
-
columns(
|
|
33
|
+
columns(view?: {
|
|
34
|
+
max?: number;
|
|
35
|
+
tail?: number;
|
|
36
|
+
}): ReadonlyMap<string, Float64Array>;
|
|
34
37
|
/**
|
|
35
38
|
* Every buffered sample of `column`, oldest first (see LiveBuffer.mirrorColumn: a call copies only what arrived
|
|
36
39
|
* since the last), and how many samples the stream had before the first of them: an index that stays put while
|
|
@@ -58,6 +61,13 @@ export declare class LiveDataSource implements DataSource {
|
|
|
58
61
|
/** {@link getSeriesMultiSync} as chart points: on the live time axis with no
|
|
59
62
|
* row objects in between (see LiveBuffer.decimatePoints). */
|
|
60
63
|
getPointsSync(columns: string[], viewport: Viewport, maxPoints: number): PointColumns;
|
|
64
|
+
/** {@link getPointsSync} over only the samples whose time is in [t0, t1] (see LiveBuffer.decimateWindow). */
|
|
65
|
+
getWindowPointsSync(columns: string[], viewport: Viewport, maxPoints: number, t0: number, t1: number): PointColumns;
|
|
66
|
+
/** Min/max of `column` over the samples whose time is in [t0, t1] (see LiveBuffer.windowXBounds). */
|
|
67
|
+
windowXBoundsSync(column: string, t0: number, t1: number): {
|
|
68
|
+
x0: number;
|
|
69
|
+
x1: number;
|
|
70
|
+
} | null;
|
|
61
71
|
xBounds(column: string): Promise<{
|
|
62
72
|
x0: number;
|
|
63
73
|
x1: number;
|
|
@@ -110,3 +120,14 @@ export declare class LiveDataSource implements DataSource {
|
|
|
110
120
|
readColumns(columns: string[], offset: number, limit: number): Promise<Record<string, Float64Array>>;
|
|
111
121
|
dispose(): Promise<void>;
|
|
112
122
|
}
|
|
123
|
+
/** Columns read when first asked for (`has` answers without reading). */
|
|
124
|
+
/**
|
|
125
|
+
* A view of a buffered column for charts that can't use millions of samples a refresh: `tail`, the newest samples
|
|
126
|
+
* in a row (a signal for an FFT); `max`, at most that many spread over all of them, every stride-th on a grid
|
|
127
|
+
* counted from the stream's first sample (`first`, the absolute index of `all[0]`), so a point drawn stays drawn
|
|
128
|
+
* while the ring rolls.
|
|
129
|
+
*/
|
|
130
|
+
export declare function liveView(all: Float64Array, first: number, view: {
|
|
131
|
+
max?: number;
|
|
132
|
+
tail?: number;
|
|
133
|
+
}): Float64Array;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Batch } from './sampler';
|
|
2
|
+
export interface Plain {
|
|
3
|
+
kind: number;
|
|
4
|
+
plaintext: Uint8Array;
|
|
5
|
+
}
|
|
6
|
+
/** The relay keeps one schema for late viewers, so a batch is ONE block: it is re-sent when the channel set grows and at least every this many seconds. */
|
|
7
|
+
export declare const SCHEMA_RESEND_S = 10;
|
|
8
|
+
export declare function createEncoder(timeOrigin?: number, now?: () => number): {
|
|
9
|
+
encode(b: Batch): Promise<Plain[]>;
|
|
10
|
+
/** After a reconnect the viewer may have missed the schema: send it again with the next batch. */
|
|
11
|
+
reset(): void;
|
|
12
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Live Performance Support's seam between the app and the charts: the app turns a session on, every chart frame
|
|
3
|
+
* registers its PerfStats while one runs. Off: charts measure nothing (unless the debug overlay is on).
|
|
4
|
+
*/
|
|
5
|
+
import type { RefObject } from 'react';
|
|
6
|
+
import type { PerfStats } from '../../charts/PerfHud';
|
|
7
|
+
export interface ChartEntry {
|
|
8
|
+
kind: string;
|
|
9
|
+
stats: PerfStats;
|
|
10
|
+
host: RefObject<HTMLElement | null>;
|
|
11
|
+
}
|
|
12
|
+
export interface RegisteredChart extends ChartEntry {
|
|
13
|
+
index: number;
|
|
14
|
+
}
|
|
15
|
+
export declare const isActive: () => boolean;
|
|
16
|
+
export declare function setActive(on: boolean): void;
|
|
17
|
+
export declare function subscribe(l: () => void): () => void;
|
|
18
|
+
export declare function registerChart(e: ChartEntry): () => void;
|
|
19
|
+
export declare const charts: () => RegisteredChart[];
|
|
20
|
+
/** The running session's error sink (null when none runs). */
|
|
21
|
+
export declare function setDiagnosticReporter(fn: ((e: unknown) => void) | null): void;
|
|
22
|
+
/** An error the page can't see as a window error (an import worker crashing): recorded when a session runs, else nothing. */
|
|
23
|
+
export declare function reportDiagnosticError(e: unknown): void;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Diagnostics sampling (spec §5). Fast columns: one row per real frame (cheap reads only). Slow columns: once a second
|
|
3
|
+
* (DOM count, canvas size, heap, points: measuring them per frame would cause the spikes we look for). Marks: spikes
|
|
4
|
+
* with the last 10 s of frame times, and errors. No data values, file names, titles or channel names ever.
|
|
5
|
+
*/
|
|
6
|
+
import type { RegisteredChart } from './registry';
|
|
7
|
+
export declare const SPIKE_FRAME_MS = 100;
|
|
8
|
+
export declare const SPIKE_TASK_MS = 200;
|
|
9
|
+
export declare const SPIKE_LAG_JUMP_S = 1;
|
|
10
|
+
export interface Sources {
|
|
11
|
+
now: () => number;
|
|
12
|
+
charts: () => RegisteredChart[];
|
|
13
|
+
live: () => {
|
|
14
|
+
age: number;
|
|
15
|
+
lag: number;
|
|
16
|
+
wait: number;
|
|
17
|
+
} | null;
|
|
18
|
+
heapMb: () => number | null;
|
|
19
|
+
domNodes: () => number;
|
|
20
|
+
canvasMp: () => number;
|
|
21
|
+
/** document.visibilityState === 'hidden' */
|
|
22
|
+
hidden: () => boolean;
|
|
23
|
+
}
|
|
24
|
+
export interface Columns {
|
|
25
|
+
t: number[];
|
|
26
|
+
columns: Record<string, number[]>;
|
|
27
|
+
}
|
|
28
|
+
export interface Script {
|
|
29
|
+
url?: string;
|
|
30
|
+
fn?: string;
|
|
31
|
+
ms?: number;
|
|
32
|
+
invoker?: string;
|
|
33
|
+
}
|
|
34
|
+
export type Mark = {
|
|
35
|
+
type: 'spike';
|
|
36
|
+
at: number;
|
|
37
|
+
reason: 'frame' | 'task' | 'lag';
|
|
38
|
+
ms: number;
|
|
39
|
+
frames: number[];
|
|
40
|
+
scripts?: Script[];
|
|
41
|
+
suppressed?: number;
|
|
42
|
+
} | {
|
|
43
|
+
type: 'error';
|
|
44
|
+
at: number;
|
|
45
|
+
message: string;
|
|
46
|
+
stack: string;
|
|
47
|
+
repeats?: number;
|
|
48
|
+
}
|
|
49
|
+
/** The browser's environment, sent once at the start (see environment()). */
|
|
50
|
+
| {
|
|
51
|
+
type: 'env';
|
|
52
|
+
at: number;
|
|
53
|
+
[k: string]: unknown;
|
|
54
|
+
};
|
|
55
|
+
export interface Batch {
|
|
56
|
+
fast: Columns;
|
|
57
|
+
slow: Columns;
|
|
58
|
+
marks: Mark[];
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Removes anything that could name the customer's files, channels or machine from error text (spec §5). Input is cut
|
|
62
|
+
* to 4000 chars first and every pattern starts at a token boundary, so the cost is linear. Prefers over-scrubbing:
|
|
63
|
+
* `foo.bar` identifiers go too. Function names without a dot (`at foo`) survive.
|
|
64
|
+
*/
|
|
65
|
+
export declare function scrub(s: string): string;
|
|
66
|
+
export declare function createSampler(src: Sources): {
|
|
67
|
+
/** Call from the page's visibilitychange: the gap that follows is a hidden tab, not a freeze. */
|
|
68
|
+
visibilityChanged(): void;
|
|
69
|
+
/** Call once per animation frame. */
|
|
70
|
+
frame(): void;
|
|
71
|
+
/** Time the diagnostics themselves took (frame sampling, encoding, sealing); summed into the slow lane's diag.overhead_ms. */
|
|
72
|
+
overhead(ms: number): void;
|
|
73
|
+
/** A long task / long animation frame from PerformanceObserver. */
|
|
74
|
+
longTask(ms: number, scripts?: Script[]): void;
|
|
75
|
+
error(e: unknown): void;
|
|
76
|
+
drain(): Batch;
|
|
77
|
+
};
|
|
78
|
+
/** Environment, sent once (spec §5 metadata). */
|
|
79
|
+
export declare function environment(): Promise<Record<string, unknown>>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** The server ends a session after an hour; this browser stops then even when it can't hear the server. */
|
|
2
|
+
export declare const SESSION_MS = 3600000;
|
|
3
|
+
export type EndReason = 'stopped' | 'expired' | 'error';
|
|
4
|
+
export interface SessionOptions {
|
|
5
|
+
/** e.g. `${SUPABASE_URL}/functions/v1` */
|
|
6
|
+
functionsUrl: string;
|
|
7
|
+
jwt: () => string | Promise<string>;
|
|
8
|
+
subject: string;
|
|
9
|
+
body: string;
|
|
10
|
+
fetch?: typeof fetch;
|
|
11
|
+
WebSocket?: typeof WebSocket;
|
|
12
|
+
raf?: (cb: FrameRequestCallback) => number;
|
|
13
|
+
cancelRaf?: (id: number) => void;
|
|
14
|
+
onEnded?: (reason: EndReason) => void;
|
|
15
|
+
}
|
|
16
|
+
export interface Session {
|
|
17
|
+
streamId: string;
|
|
18
|
+
caseId: string;
|
|
19
|
+
caseNumber: string;
|
|
20
|
+
stop(): Promise<void>;
|
|
21
|
+
}
|
|
22
|
+
export declare function startSession(o: SessionOptions): Promise<Session>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { KymoscopeEngine } from '../engine/createEngine';
|
|
2
|
+
/** Host-only: the engine's way to add a worksheet outside the limits (a support session's). Kept off the public
|
|
3
|
+
* API: this file is reachable only inside the repo (`@kymoscope/sdk/lib/*`), never from the npm package. */
|
|
4
|
+
export declare const exemptAdders: WeakMap<object, (name: string) => string>;
|
|
5
|
+
/** Adds a worksheet outside the host's limits (its charts and channels too), not counted toward them, never saved. */
|
|
6
|
+
export declare function addExemptWorksheet(engine: KymoscopeEngine, name: string): string;
|
|
@@ -58,8 +58,13 @@ export declare class LiveBuffer {
|
|
|
58
58
|
/** Time never decreases across the buffered samples (see lastBackAbs). */
|
|
59
59
|
private get timeMonotonic();
|
|
60
60
|
private lastPushT;
|
|
61
|
-
/**
|
|
62
|
-
|
|
61
|
+
/** decimateColumns' bucket maps, one per X and column set (each chart on a stream keeps its own: with one shared,
|
|
62
|
+
* every chart's pull rebuilt the whole lap the previous chart had just built). Least recently built first. */
|
|
63
|
+
private decCaches;
|
|
64
|
+
/** decimateWindow's blocks, per X, column set and bucket width (see there). Least recently used first. */
|
|
65
|
+
private winBlocks;
|
|
66
|
+
/** windowXBounds' min/max of X per block, per X column. */
|
|
67
|
+
private winX;
|
|
63
68
|
/** Where the newest pass of a wrapping X starts (see {@link passStart}). */
|
|
64
69
|
private passTrack;
|
|
65
70
|
/** The previous cycle's points (see decimateCyclePoints). */
|
|
@@ -214,6 +219,12 @@ export declare class LiveBuffer {
|
|
|
214
219
|
* (RPM) channels. Absolute buckets keep a sample in the same bucket as the view
|
|
215
220
|
* scrolls, so shared buckets are identical between pulls. */
|
|
216
221
|
private accumulate;
|
|
222
|
+
/**
|
|
223
|
+
* {@link accumulate} for the samples at absolute indices [from, to), a run of samples in one bucket at a time: the
|
|
224
|
+
* min/max of a run are kept in locals and written to its row once (a lap-distance X stays in a bucket for many
|
|
225
|
+
* samples at a high rate). Same rows as accumulating one by one. Returns the lowest bucket (Infinity: none).
|
|
226
|
+
*/
|
|
227
|
+
private foldRuns;
|
|
217
228
|
/**
|
|
218
229
|
* Min/max-decimate several columns over [x0,x1] straight from the ring — no
|
|
219
230
|
* per-column copy, so the live pull allocates only the small bucket result.
|
|
@@ -239,6 +250,27 @@ export declare class LiveBuffer {
|
|
|
239
250
|
* candidates and re-checked against the range as it is now.
|
|
240
251
|
*/
|
|
241
252
|
private passStart;
|
|
253
|
+
/** Logical index of the first sample whose time is > `t` (time ascending). */
|
|
254
|
+
private timeIndexAfter;
|
|
255
|
+
/** Absolute indices [a0, a1) of the samples whose time is in [t0, t1] (time ascending). */
|
|
256
|
+
private windowRange;
|
|
257
|
+
/**
|
|
258
|
+
* {@link decimatePoints} on an X that is not time, over only the samples whose time is in [t0, t1]: a live window
|
|
259
|
+
* (the newest N seconds, or all of them) drawn against lap distance, as a time axis draws it. Buckets by X value,
|
|
260
|
+
* like decimateColumns. The ring is cut into blocks of WIN_BLOCK samples on the absolute index; a whole block's
|
|
261
|
+
* buckets are made once and kept, so a pull merges the blocks inside the window (about 1,500 at 50 kHz over 30 s)
|
|
262
|
+
* and folds only the samples of its two partial ends. A block a late message moved is made again. Time must ascend
|
|
263
|
+
* (else, and on the time axis: decimatePoints).
|
|
264
|
+
*/
|
|
265
|
+
decimateWindow(xKey: string, columns: string[], x0: number, x1: number, maxPoints: number, t0: number, t1: number): PointColumns;
|
|
266
|
+
/** Block `k` of decimateWindow (samples [k, k + 1) x WIN_BLOCK): its buckets on X, in the order first met. */
|
|
267
|
+
private winBlock;
|
|
268
|
+
/** Min/max of `xKey` over the samples whose time is in [t0, t1] (null: none): the X a live window spans. A block
|
|
269
|
+
* of WIN_BLOCK samples is read once (its min/max kept); the ends of the window sample by sample. */
|
|
270
|
+
windowXBounds(xKey: string, t0: number, t1: number): {
|
|
271
|
+
x0: number;
|
|
272
|
+
x1: number;
|
|
273
|
+
} | null;
|
|
242
274
|
/** Logical index (0 = oldest) of the first sample whose time is ≥ `t` (time ascending). */
|
|
243
275
|
private timeIndex;
|
|
244
276
|
/** Fold the samples at logical indices [from, to) into `store` (time ascending). */
|
|
@@ -126,7 +126,7 @@ export declare class RegistryError extends Error {
|
|
|
126
126
|
export interface LiveUsage {
|
|
127
127
|
limits: Record<string, number | null>;
|
|
128
128
|
usage: {
|
|
129
|
-
|
|
129
|
+
liveChannels: number;
|
|
130
130
|
cameraSeconds: number;
|
|
131
131
|
dataBytes: number;
|
|
132
132
|
videoBytes: number;
|
|
@@ -14,6 +14,8 @@ export declare const KIND_LAST_VALUES = 7;
|
|
|
14
14
|
export declare const KIND_CHAIN = 8;
|
|
15
15
|
/** Events of a stream over 1,000 channels, each one channel at its own time (see blockWire.ts decodeSparse). */
|
|
16
16
|
export declare const KIND_SPARSE = 9;
|
|
17
|
+
/** JSON marks (spikes, errors) of a Live Performance Support stream; viewers that do not know this kind skip it. */
|
|
18
|
+
export declare const KIND_EVENT = 10;
|
|
17
19
|
export declare const KEY_ID_FLAG = 128;
|
|
18
20
|
export interface SealedMessage {
|
|
19
21
|
kind: number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kymoscope/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.26.0",
|
|
4
4
|
"description": "The Kymoscope data engine and charts for the browser: import large measurement files, plot them, stream live data end-to-end encrypted.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
6
6
|
"homepage": "https://kymoscope.com/docs/introduction",
|