@kymoscope/sdk 0.8.3 → 0.9.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/kymoscope-embed.js +71 -71
- package/dist/kymoscope-sdk.js +65 -65
- package/dist/styles/charts.css +3 -0
- package/dist/types/charts/CameraPanel.d.ts +1 -1
- package/dist/types/charts/ChartBody.d.ts +6 -2
- package/dist/types/charts/runtime.d.ts +1 -1
- package/dist/types/engine/types.d.ts +2 -0
- package/dist/types/index.d.ts +3 -2
- package/dist/types/lib/live/cameraSender.d.ts +9 -6
- package/dist/types/lib/live/publisher.d.ts +65 -2
- package/dist/types/lib/live/types.d.ts +7 -0
- package/dist/types/lib/live/videoTrack.d.ts +8 -0
- package/dist/types/lib/render/chartFonts.d.ts +2 -0
- package/package.json +1 -1
package/dist/styles/charts.css
CHANGED
|
@@ -315,6 +315,9 @@
|
|
|
315
315
|
|
|
316
316
|
.kymo-camera__empty p { margin: 0; }
|
|
317
317
|
|
|
318
|
+
/* Over the canvas: the last frame never shows through (No signal). */
|
|
319
|
+
.kymo-camera__empty--cover { background: var(--chart-bg); }
|
|
320
|
+
|
|
318
321
|
.kymo-camera__empty-icon {
|
|
319
322
|
width: 30px;
|
|
320
323
|
height: 30px;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type CameraPanelSettings } from '../lib/panelChartSettings';
|
|
2
|
-
import type
|
|
2
|
+
import { type LiveConnection } from '../lib/live/types';
|
|
3
3
|
import { type VideoSource } from '../lib/live/videoTrack';
|
|
4
4
|
import type { LoadedDataset } from '../types/loadedDataset';
|
|
5
5
|
/** The worksheet's shared chart cursor (engine.view.cursorX), in X data units. */
|
|
@@ -13,7 +13,8 @@ import type { LiveZoomBus } from '../lib/render/liveZoomBus';
|
|
|
13
13
|
import { type WorksheetData } from './useWorksheetData';
|
|
14
14
|
import type { LiveConnection } from '../lib/live/types';
|
|
15
15
|
import type { LoadedDataset } from '../types/loadedDataset';
|
|
16
|
-
|
|
16
|
+
/** 'no-data': nothing loaded; 'empty': nothing chosen or nothing to draw; 'missing': a chosen channel isn't in this data; 'ready'. */
|
|
17
|
+
export type ChartStatus = 'no-data' | 'empty' | 'missing' | 'ready';
|
|
17
18
|
export interface ContextMenuEvent {
|
|
18
19
|
clientX: number;
|
|
19
20
|
clientY: number;
|
|
@@ -56,7 +57,10 @@ export interface ChartBodyProps {
|
|
|
56
57
|
onContextMenu: (e: ContextMenuEvent) => void;
|
|
57
58
|
xyzRef?: Ref<XYZMeshChartHandle>;
|
|
58
59
|
}
|
|
59
|
-
/**
|
|
60
|
+
/** Every column a chart's settings pick (series, slots, lists); helper fields such as the multiband's add picker don't count. */
|
|
61
|
+
export declare function chosenColumns(settings: PanelChartSettings | undefined): string[];
|
|
62
|
+
/** Renders the chart and reports whether it had anything to draw: an empty chart whose chosen
|
|
63
|
+
* channels aren't all in this data says so ('missing'), the same for every kind. */
|
|
60
64
|
export declare function renderChart(p: ChartBodyProps): {
|
|
61
65
|
status: ChartStatus;
|
|
62
66
|
node: ReactNode;
|
|
@@ -33,7 +33,7 @@ export interface ChartViewEvents extends Record<string, unknown> {
|
|
|
33
33
|
}
|
|
34
34
|
export interface ChartView {
|
|
35
35
|
readonly chartId: string;
|
|
36
|
-
/** Current status: 'no-data' (nothing plotted), 'empty' (
|
|
36
|
+
/** Current status: 'no-data' (nothing plotted), 'empty' (nothing chosen or nothing to draw), 'missing' (a chosen channel isn't in this data), 'ready'. */
|
|
37
37
|
status(): ChartStatus | null;
|
|
38
38
|
on<K extends keyof ChartViewEvents>(event: K, cb: (payload: ChartViewEvents[K]) => void): () => void;
|
|
39
39
|
/**
|
|
@@ -175,6 +175,8 @@ export interface LiveConnectionInfo {
|
|
|
175
175
|
customColor: boolean;
|
|
176
176
|
/** When a recording is running: its start time (ms since epoch), else null. */
|
|
177
177
|
recordingSince: number | null;
|
|
178
|
+
/** The plan-limit banner it was opened with (e.g. "Video limit reached this month"), else null. */
|
|
179
|
+
limitNotice?: string | null;
|
|
178
180
|
/** Its columns as of the last structural change (the time column first). */
|
|
179
181
|
channels: string[];
|
|
180
182
|
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -59,14 +59,15 @@ export type { FunctionDoc } from './lib/mathChannels';
|
|
|
59
59
|
export { buildExportBlob as buildMathChannelsBlob, parseImportFile as parseMathChannelsFile } from './lib/mathChannels/io';
|
|
60
60
|
export type { LiveRelayConfig } from './lib/live/stream';
|
|
61
61
|
export type { LiveStreamDescriptor, LiveStreamOptions, LocalLiveStream, StreamKeyProvider } from './lib/live/types';
|
|
62
|
+
export { VIDEO_LIMIT_NOTICE } from './lib/live/types';
|
|
62
63
|
export type { LiveColumnsBlock, LiveMessage } from './lib/live/buffer';
|
|
63
64
|
export { LIVE_TIME_COLUMN } from './lib/live/buffer';
|
|
64
65
|
export { openMessage, sealMessage, KIND_VIDEO } from './lib/live/wire';
|
|
65
66
|
export { encodeVideo, decodeVideo, fragmentVideo, VIDEO_MAX_FRAGMENT, type VideoMessage } from './lib/live/videoWire';
|
|
66
67
|
export type { VideoSource, EncodedUnit, VideoTrackInfo } from './lib/live/videoTrack';
|
|
67
68
|
export { RecordedVideoSource, type RecordedVideoSourceOptions } from './lib/recordings/videoSource';
|
|
68
|
-
export { LivePublisher, type PublisherDeps, type PublisherOptions, type PublisherState, type PublisherStatus } from './lib/live/publisher';
|
|
69
|
-
export { CameraSender,
|
|
69
|
+
export { LivePublisher, fetchUsage, liveBytesPerSec, RegistryError, type CameraQuality, type LiveProfile, type LiveUsage, type PublisherDeps, type PublisherOptions, type PublisherState, type PublisherStatus } from './lib/live/publisher';
|
|
70
|
+
export { CameraSender, CAMERA_QUALITIES, LOW_PRESET, type CameraPreset, type CameraStats, type CameraLayerStats, type CameraSenderDeps } from './lib/live/cameraSender';
|
|
70
71
|
export type { RecordingKey } from './lib/recordings/keys';
|
|
71
72
|
export { recordingKeyAad, recordingKeySealAad } from './lib/recordings/keys';
|
|
72
73
|
export { parseKrc, parseKrcHeader, KRC_HEADER_BYTES } from './lib/recordings/krc';
|
|
@@ -1,11 +1,16 @@
|
|
|
1
|
-
import type { LivePublisher } from './publisher';
|
|
1
|
+
import type { CameraQuality, LivePublisher } from './publisher';
|
|
2
|
+
export type { CameraQuality };
|
|
2
3
|
export interface CameraPreset {
|
|
3
4
|
width: number;
|
|
4
5
|
height: number;
|
|
5
6
|
fps: number;
|
|
6
7
|
kbps: number;
|
|
7
8
|
}
|
|
8
|
-
|
|
9
|
+
/** The frame size of each declarable quality (the getUserMedia ideal and the encoder's size). */
|
|
10
|
+
export declare const CAMERA_QUALITIES: Record<CameraQuality, {
|
|
11
|
+
width: number;
|
|
12
|
+
height: number;
|
|
13
|
+
}>;
|
|
9
14
|
/** The low layer's default: what small panels and camera walls draw. */
|
|
10
15
|
export declare const LOW_PRESET: CameraPreset;
|
|
11
16
|
export interface CameraLayerStats {
|
|
@@ -31,7 +36,7 @@ export interface CameraSenderDeps {
|
|
|
31
36
|
/** The low layer's downscale (test seam); defaults to drawing onto an OffscreenCanvas. The caller closes the result. */
|
|
32
37
|
scale?: (frame: VideoFrame, width: number, height: number) => VideoFrame;
|
|
33
38
|
}
|
|
34
|
-
type Publisher = Pick<LivePublisher, 'send' | 'viewers' | 'onViewers' | '
|
|
39
|
+
type Publisher = Pick<LivePublisher, 'send' | 'viewers' | 'onViewers' | 'bitrateKbps' | 'profile'>;
|
|
35
40
|
export declare class CameraSender {
|
|
36
41
|
private readonly high;
|
|
37
42
|
private readonly lowOpt;
|
|
@@ -46,8 +51,7 @@ export declare class CameraSender {
|
|
|
46
51
|
private stopped;
|
|
47
52
|
private readonly statsFns;
|
|
48
53
|
private lastStats;
|
|
49
|
-
constructor(publisher: Publisher, opts
|
|
50
|
-
preset: CameraPreset;
|
|
54
|
+
constructor(publisher: Publisher, opts?: {
|
|
51
55
|
keyframeS?: number;
|
|
52
56
|
low?: {
|
|
53
57
|
publisher: Publisher;
|
|
@@ -67,4 +71,3 @@ export declare class CameraSender {
|
|
|
67
71
|
/** Stop encoding. The publishers and the track belong to the caller and keep running. */
|
|
68
72
|
stop(): void;
|
|
69
73
|
}
|
|
70
|
-
export {};
|
|
@@ -42,6 +42,29 @@ export interface PublisherDeps {
|
|
|
42
42
|
save(s: PublisherState): Promise<void>;
|
|
43
43
|
};
|
|
44
44
|
}
|
|
45
|
+
export type CameraQuality = '360p' | '480p' | '720p' | '1080p';
|
|
46
|
+
/** What the stream declares before it starts (spec 2026-11-07 declared streams); the server admits or refuses it
|
|
47
|
+
* against the plan. A data stream: `mode` plus `hz` and `channels` (or `sources`, one {hz, channels} per source) and
|
|
48
|
+
* `bytes_per_sec`, the bytes a second it really sends (see liveBytesPerSec): the server admits, and the relay limits
|
|
49
|
+
* the stream, at the larger of it and its own formula. A camera: `mode` plus `quality` and `fps` (1–60); a low layer
|
|
50
|
+
* declares its high camera's profile. */
|
|
51
|
+
export interface LiveProfile {
|
|
52
|
+
mode: 'live' | 'record';
|
|
53
|
+
hz?: number;
|
|
54
|
+
channels?: number;
|
|
55
|
+
sources?: {
|
|
56
|
+
hz: number;
|
|
57
|
+
channels: number;
|
|
58
|
+
}[];
|
|
59
|
+
/** A data stream's wire bytes a second (required for kind 'data'; finite, > 0). */
|
|
60
|
+
bytes_per_sec?: number;
|
|
61
|
+
quality?: CameraQuality;
|
|
62
|
+
fps?: number;
|
|
63
|
+
}
|
|
64
|
+
/** A data stream's `bytes_per_sec`: `messagesPerSec` messages a second of `plaintextBytes` each (one representative
|
|
65
|
+
* message's plaintext as handed to send(), with the samples one message carries), sealed and framed as the publisher
|
|
66
|
+
* sends them. */
|
|
67
|
+
export declare function liveBytesPerSec(plaintextBytes: number, messagesPerSec: number): number;
|
|
45
68
|
export interface PublisherOptions {
|
|
46
69
|
supabaseUrl: string;
|
|
47
70
|
apiKey: string;
|
|
@@ -58,6 +81,13 @@ export interface PublisherOptions {
|
|
|
58
81
|
* stream id (same parent). Both or neither. */
|
|
59
82
|
layer?: 'low';
|
|
60
83
|
lowOf?: string;
|
|
84
|
+
/** Required: what this stream sends (see LiveProfile). */
|
|
85
|
+
profile: LiveProfile;
|
|
86
|
+
/** A heartbeat's notice (a degradation or a quota warning), once per notice until a beat comes without it. */
|
|
87
|
+
onNotice?: (n: {
|
|
88
|
+
code: string;
|
|
89
|
+
message: string;
|
|
90
|
+
}) => void;
|
|
61
91
|
}
|
|
62
92
|
export type PublisherStatus = {
|
|
63
93
|
phase: 'registering';
|
|
@@ -73,6 +103,26 @@ export type PublisherStatus = {
|
|
|
73
103
|
code: string;
|
|
74
104
|
message: string;
|
|
75
105
|
};
|
|
106
|
+
/** A stream-token / stream-publisher call that failed: HTTP status (0: network) and the server's {error, message}. */
|
|
107
|
+
export declare class RegistryError extends Error {
|
|
108
|
+
status: number;
|
|
109
|
+
code: string;
|
|
110
|
+
detail: string;
|
|
111
|
+
constructor(status: number, code: string, message: string);
|
|
112
|
+
}
|
|
113
|
+
/** What the API key's account may still use: each limit (null: unlimited) and this month's usage. */
|
|
114
|
+
export interface LiveUsage {
|
|
115
|
+
limits: Record<string, number | null>;
|
|
116
|
+
usage: {
|
|
117
|
+
liveKbps: number;
|
|
118
|
+
cameraSeconds: number;
|
|
119
|
+
dataBytes: number;
|
|
120
|
+
videoBytes: number;
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
/** The plan's limits and what is used, before starting anything (stream-publisher `usage`). Rejects with the
|
|
124
|
+
* server's {status, code, detail} (status 0: network). */
|
|
125
|
+
export declare function fetchUsage(supabaseUrl: string, apiKey: string, f?: typeof fetch): Promise<LiveUsage>;
|
|
76
126
|
export declare class LivePublisher {
|
|
77
127
|
private readonly opts;
|
|
78
128
|
private readonly deps;
|
|
@@ -119,6 +169,10 @@ export declare class LivePublisher {
|
|
|
119
169
|
private readonly statusFns;
|
|
120
170
|
private readonly viewerFns;
|
|
121
171
|
private lastStatus;
|
|
172
|
+
private readonly wire;
|
|
173
|
+
private usage;
|
|
174
|
+
private bitrate;
|
|
175
|
+
private noticeCode;
|
|
122
176
|
constructor(opts: PublisherOptions, deps: PublisherDeps);
|
|
123
177
|
/** The registered stream id (null until start() registers). */
|
|
124
178
|
get streamId(): string | null;
|
|
@@ -129,6 +183,12 @@ export declare class LivePublisher {
|
|
|
129
183
|
maxBytesPerSec: number;
|
|
130
184
|
maxMessageBytes: number;
|
|
131
185
|
};
|
|
186
|
+
/** The register reply's usage line (what was admitted and what is left), for the sender to show; null before. */
|
|
187
|
+
get usageMessage(): string | null;
|
|
188
|
+
/** A camera's bitrate in kbit/s, chosen by the server for its declared quality and fps; null before register. */
|
|
189
|
+
get bitrateKbps(): number | null;
|
|
190
|
+
/** The declared profile as sent to the server (normalised, frozen). */
|
|
191
|
+
get profile(): Readonly<LiveProfile>;
|
|
132
192
|
onStatus(fn: (s: PublisherStatus) => void): () => void;
|
|
133
193
|
onViewers(fn: (n: number) => void): () => void;
|
|
134
194
|
/** Mint, register (reusing a persisted stream id and salt), open the socket, heartbeat. Rejects when
|
|
@@ -137,15 +197,18 @@ export declare class LivePublisher {
|
|
|
137
197
|
/** Seal with the current stream key (the key id of its epoch when e2ee) and send; false if not sent
|
|
138
198
|
* (no key yet, socket down, stopped). */
|
|
139
199
|
send(kind: number, plaintext: Uint8Array): Promise<boolean>;
|
|
140
|
-
/** Close the socket and stop the timers. The stream stays registered (never deleted here)
|
|
200
|
+
/** Close the socket and stop the timers. The stream stays registered (never deleted here), offline at once: what
|
|
201
|
+
* it declared stops counting against the live limits now, not when the live window runs out. */
|
|
141
202
|
stop(): void;
|
|
142
203
|
private post;
|
|
143
204
|
private mint;
|
|
144
205
|
private call;
|
|
145
206
|
private register;
|
|
207
|
+
private admitted;
|
|
208
|
+
private notice;
|
|
146
209
|
private senderDevice;
|
|
147
210
|
/** Token refresh, then the heartbeat (each new ticket also refreshes the socket). 401/403 stop the
|
|
148
|
-
* publisher (revoked key, plan, stale_epoch); anything else is retried on the next interval. */
|
|
211
|
+
* publisher (revoked key, plan, stale_epoch, a camera's video_hours_exhausted); anything else is retried on the next interval. */
|
|
149
212
|
private housekeeping;
|
|
150
213
|
/** Seal the stream key to the owner's browsers that lack it (password streams), at most 50 per call. */
|
|
151
214
|
private wrapFor;
|
|
@@ -5,6 +5,9 @@ import type { LiveDataSource } from '../data/liveDataSource';
|
|
|
5
5
|
import type { Dataset } from '../parseDataset';
|
|
6
6
|
import type { VideoTrack } from './videoTrack';
|
|
7
7
|
import type { ClockMap } from './clockMap';
|
|
8
|
+
/** A camera's limit_notice once this month's video hours are used up (stream-publisher degrade.ts VIDEO_BANNER): the
|
|
9
|
+
* camera stopped, so its panel shows this instead of video. Any other notice (storage full) leaves the video playing. */
|
|
10
|
+
export declare const VIDEO_LIMIT_NOTICE = "Video limit reached this month";
|
|
8
11
|
/** What a viewer needs to join an encrypted relay stream (from the stream registry). */
|
|
9
12
|
export interface LiveStreamDescriptor {
|
|
10
13
|
id: string;
|
|
@@ -29,6 +32,8 @@ export interface LiveStreamDescriptor {
|
|
|
29
32
|
parent_stream_id?: string | null;
|
|
30
33
|
/** A camera's low layer (360p, for small panels and walls): its high camera's id; null/absent otherwise. */
|
|
31
34
|
low_of_stream_id?: string | null;
|
|
35
|
+
/** Set while a plan limit holds the stream back (e.g. "Video limit reached this month"); null/absent otherwise. */
|
|
36
|
+
limit_notice?: string | null;
|
|
32
37
|
}
|
|
33
38
|
/**
|
|
34
39
|
* The keys of a stream in an end-to-end encrypted project: frames name their key id
|
|
@@ -88,4 +93,6 @@ export interface LiveConnection {
|
|
|
88
93
|
error: string | null;
|
|
89
94
|
/** When a recording is running: its start time (ms since epoch). */
|
|
90
95
|
recordingSince: number | null;
|
|
96
|
+
/** The plan-limit banner it was opened with (LiveStreamDescriptor.limit_notice); a Camera panel shows it. */
|
|
97
|
+
limitNotice?: string | null;
|
|
91
98
|
}
|
|
@@ -15,7 +15,15 @@ export interface VideoTrackInfo {
|
|
|
15
15
|
lagMs: number | null;
|
|
16
16
|
units: number;
|
|
17
17
|
bytes: number;
|
|
18
|
+
/** Live: when the newest unit arrived (local ms), null before the first. */
|
|
19
|
+
arrivedAt?: number | null;
|
|
20
|
+
/** Live: the usual time between arriving units (median of the recent ones, ms), null with fewer than two. */
|
|
21
|
+
gapMs?: number | null;
|
|
18
22
|
}
|
|
23
|
+
/** No unit for this long means the sender stopped (the game stopped, the camera went away): never less than 3 s,
|
|
24
|
+
* and four of the camera's usual gaps for a slow one. */
|
|
25
|
+
export declare const NO_SIGNAL_MIN_MS = 3000;
|
|
26
|
+
export declare function noSignalAfterMs(gapMs: number | null | undefined): number;
|
|
19
27
|
/**
|
|
20
28
|
* A camera's video as the Camera panel plays it: a live camera connection's ring (kind 'live'), or a camera
|
|
21
29
|
* recorded with a cloud recording (kind 'recorded', RecordedVideoSource). Listed by engine.video.sources().
|
|
@@ -8,3 +8,5 @@ export declare const chartFonts: {
|
|
|
8
8
|
sans: string;
|
|
9
9
|
mono: string;
|
|
10
10
|
};
|
|
11
|
+
/** The one text every chart draws when it has nothing to show in its view, centred on the canvas, in the current fill colour. */
|
|
12
|
+
export declare function drawNoData(ctx: CanvasRenderingContext2D): void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kymoscope/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.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",
|