@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.
Files changed (223) hide show
  1. package/LICENSE.md +69 -0
  2. package/README.md +138 -2
  3. package/dist/assets/duckdb-browser-eh.worker--3HUwN9R.js +14 -0
  4. package/dist/assets/duckdb-eh-D-nnNw7L.wasm.gz +0 -0
  5. package/dist/assets/h5wasmModule-BCQWU2Gw.js +24295 -0
  6. package/dist/assets/importer.worker-D4is7BLf.js +6 -0
  7. package/dist/assets/offscreenLineWorker-mShhnyXX.js +79 -0
  8. package/dist/assets/parseDataset.worker-PynRsPD8.js +5 -0
  9. package/dist/importers-DivmF3tx.js +5 -0
  10. package/dist/krc-CbE28CjD.js +9 -0
  11. package/dist/kymoscope-embed.js +633 -0
  12. package/dist/kymoscope-sdk.js +616 -0
  13. package/dist/react.js +2 -0
  14. package/dist/styles/charts.css +207 -0
  15. package/dist/styles/fonts/OFL.txt +93 -0
  16. package/dist/styles/fonts/plus-jakarta-sans-italic-latin-ext.woff2 +0 -0
  17. package/dist/styles/fonts/plus-jakarta-sans-italic-latin.woff2 +0 -0
  18. package/dist/styles/fonts/plus-jakarta-sans-latin-ext.woff2 +0 -0
  19. package/dist/styles/fonts/plus-jakarta-sans-latin.woff2 +0 -0
  20. package/dist/styles/tokens.css +218 -0
  21. package/dist/types/charts/AlarmOverlay.d.ts +11 -0
  22. package/dist/types/charts/AnnotationLayer.d.ts +29 -0
  23. package/dist/types/charts/ChartBody.d.ts +52 -0
  24. package/dist/types/charts/PerfHud.d.ts +20 -0
  25. package/dist/types/charts/beacon.d.ts +27 -0
  26. package/dist/types/charts/chartWindow.d.ts +31 -0
  27. package/dist/types/charts/liveOverlay.d.ts +16 -0
  28. package/dist/types/charts/runtime.d.ts +63 -0
  29. package/dist/types/charts/useWorksheetData.d.ts +159 -0
  30. package/dist/types/components/AreaChart.d.ts +21 -0
  31. package/dist/types/components/BarChart.d.ts +30 -0
  32. package/dist/types/components/BoxPlotChart.d.ts +16 -0
  33. package/dist/types/components/BubbleChart.d.ts +24 -0
  34. package/dist/types/components/CalibrationChart.d.ts +15 -0
  35. package/dist/types/components/CdfChart.d.ts +15 -0
  36. package/dist/types/components/ConfusionChart.d.ts +11 -0
  37. package/dist/types/components/ControlChart.d.ts +17 -0
  38. package/dist/types/components/DuckDbMultiBandPanel.d.ts +35 -0
  39. package/dist/types/components/EmbeddingChart.d.ts +25 -0
  40. package/dist/types/components/FlameGraphChart.d.ts +15 -0
  41. package/dist/types/components/GanttChart.d.ts +15 -0
  42. package/dist/types/components/GaugeChart.d.ts +27 -0
  43. package/dist/types/components/HeatmapChart.d.ts +41 -0
  44. package/dist/types/components/HistogramChart.d.ts +15 -0
  45. package/dist/types/components/LossCurveChart.d.ts +17 -0
  46. package/dist/types/components/MultiBandCanvasChart.d.ts +156 -0
  47. package/dist/types/components/ParallelCoordsChart.d.ts +21 -0
  48. package/dist/types/components/PolarChart.d.ts +17 -0
  49. package/dist/types/components/QQPlotChart.d.ts +16 -0
  50. package/dist/types/components/RadarChart.d.ts +17 -0
  51. package/dist/types/components/RocChart.d.ts +12 -0
  52. package/dist/types/components/SankeyChart.d.ts +15 -0
  53. package/dist/types/components/SpectrogramChart.d.ts +16 -0
  54. package/dist/types/components/SpectrogramWaterfall.d.ts +14 -0
  55. package/dist/types/components/SpectrumChart.d.ts +17 -0
  56. package/dist/types/components/TreemapChart.d.ts +14 -0
  57. package/dist/types/components/ViolinChart.d.ts +17 -0
  58. package/dist/types/components/XYScatterChart.d.ts +47 -0
  59. package/dist/types/components/XYZMeshChart.d.ts +68 -0
  60. package/dist/types/components/dashboardGridLayout.d.ts +50 -0
  61. package/dist/types/components/liveFollowEase.d.ts +10 -0
  62. package/dist/types/components/liveWindow.d.ts +63 -0
  63. package/dist/types/components/multiBandHover.d.ts +44 -0
  64. package/dist/types/embed/Attribution.d.ts +5 -0
  65. package/dist/types/embed/license.d.ts +29 -0
  66. package/dist/types/embed/standalone.d.ts +5 -0
  67. package/dist/types/engine/columns.d.ts +44 -0
  68. package/dist/types/engine/createEngine.d.ts +394 -0
  69. package/dist/types/engine/derive.d.ts +27 -0
  70. package/dist/types/engine/emitter.d.ts +6 -0
  71. package/dist/types/engine/errors.d.ts +7 -0
  72. package/dist/types/engine/history.d.ts +29 -0
  73. package/dist/types/engine/kinds.d.ts +9 -0
  74. package/dist/types/engine/liveController.d.ts +27 -0
  75. package/dist/types/engine/store.d.ts +8 -0
  76. package/dist/types/engine/types.d.ts +194 -0
  77. package/dist/types/index.d.ts +69 -0
  78. package/dist/types/lib/annotations.d.ts +37 -0
  79. package/dist/types/lib/beacon.d.ts +62 -0
  80. package/dist/types/lib/colorScheme.d.ts +5 -0
  81. package/dist/types/lib/colormap.d.ts +9 -0
  82. package/dist/types/lib/columnTable.d.ts +37 -0
  83. package/dist/types/lib/data/arrowDecimation.d.ts +11 -0
  84. package/dist/types/lib/data/binnedHeatmap.d.ts +27 -0
  85. package/dist/types/lib/data/columnCaches.d.ts +6 -0
  86. package/dist/types/lib/data/columnarDataSource.d.ts +34 -0
  87. package/dist/types/lib/data/createDataSource.d.ts +23 -0
  88. package/dist/types/lib/data/dataSource.d.ts +75 -0
  89. package/dist/types/lib/data/decimate.d.ts +25 -0
  90. package/dist/types/lib/data/duckDbDataSource.d.ts +42 -0
  91. package/dist/types/lib/data/envelope.d.ts +16 -0
  92. package/dist/types/lib/data/inMemoryDataSource.d.ts +25 -0
  93. package/dist/types/lib/data/liveDataSource.d.ts +77 -0
  94. package/dist/types/lib/data/lruCache.d.ts +11 -0
  95. package/dist/types/lib/data/openDataset.d.ts +24 -0
  96. package/dist/types/lib/data/opfsParquet.d.ts +4 -0
  97. package/dist/types/lib/data/pointColumns.d.ts +59 -0
  98. package/dist/types/lib/data/schemaColumns.d.ts +5 -0
  99. package/dist/types/lib/data/useSeriesPoints.d.ts +48 -0
  100. package/dist/types/lib/data/xyColumns.d.ts +77 -0
  101. package/dist/types/lib/dataBounds.d.ts +10 -0
  102. package/dist/types/lib/datasetColors.d.ts +19 -0
  103. package/dist/types/lib/datasetColumns.d.ts +3 -0
  104. package/dist/types/lib/datasetMerge.d.ts +8 -0
  105. package/dist/types/lib/duckdb/duckdbInstance.d.ts +7 -0
  106. package/dist/types/lib/duckdb/fileIdentity.d.ts +9 -0
  107. package/dist/types/lib/duckdb/sql.d.ts +124 -0
  108. package/dist/types/lib/fft.d.ts +15 -0
  109. package/dist/types/lib/folderTree.d.ts +29 -0
  110. package/dist/types/lib/gaugeColors.d.ts +32 -0
  111. package/dist/types/lib/importers/arrowSink.d.ts +35 -0
  112. package/dist/types/lib/importers/blobReader.d.ts +22 -0
  113. package/dist/types/lib/importers/bytes.d.ts +11 -0
  114. package/dist/types/lib/importers/combine.d.ts +30 -0
  115. package/dist/types/lib/importers/comtrade/format.d.ts +2 -0
  116. package/dist/types/lib/importers/comtrade/importer.d.ts +25 -0
  117. package/dist/types/lib/importers/dbc.d.ts +45 -0
  118. package/dist/types/lib/importers/edf/format.d.ts +2 -0
  119. package/dist/types/lib/importers/edf/importer.d.ts +7 -0
  120. package/dist/types/lib/importers/expr.d.ts +10 -0
  121. package/dist/types/lib/importers/formats.d.ts +23 -0
  122. package/dist/types/lib/importers/hdf5/format.d.ts +4 -0
  123. package/dist/types/lib/importers/hdf5/h5.d.ts +76 -0
  124. package/dist/types/lib/importers/hdf5/h5wasmModule.d.ts +1 -0
  125. package/dist/types/lib/importers/hdf5/importer.d.ts +2 -0
  126. package/dist/types/lib/importers/importer.worker.d.ts +5 -0
  127. package/dist/types/lib/importers/importers.d.ts +4 -0
  128. package/dist/types/lib/importers/limits.d.ts +28 -0
  129. package/dist/types/lib/importers/mat/format.d.ts +2 -0
  130. package/dist/types/lib/importers/mat/group.d.ts +19 -0
  131. package/dist/types/lib/importers/mat/importer.d.ts +2 -0
  132. package/dist/types/lib/importers/mat/v5.d.ts +24 -0
  133. package/dist/types/lib/importers/mat/v73.d.ts +13 -0
  134. package/dist/types/lib/importers/mdf/blocks3.d.ts +3 -0
  135. package/dist/types/lib/importers/mdf/blocks4.d.ts +7 -0
  136. package/dist/types/lib/importers/mdf/bus.d.ts +59 -0
  137. package/dist/types/lib/importers/mdf/conversion.d.ts +48 -0
  138. package/dist/types/lib/importers/mdf/decode.d.ts +15 -0
  139. package/dist/types/lib/importers/mdf/format.d.ts +2 -0
  140. package/dist/types/lib/importers/mdf/importer.d.ts +19 -0
  141. package/dist/types/lib/importers/mdf/model.d.ts +75 -0
  142. package/dist/types/lib/importers/mdf/records.d.ts +31 -0
  143. package/dist/types/lib/importers/mdf/stream.d.ts +42 -0
  144. package/dist/types/lib/importers/memorySink.d.ts +11 -0
  145. package/dist/types/lib/importers/names.d.ts +2 -0
  146. package/dist/types/lib/importers/openImport.d.ts +33 -0
  147. package/dist/types/lib/importers/registry.d.ts +24 -0
  148. package/dist/types/lib/importers/run.d.ts +35 -0
  149. package/dist/types/lib/importers/session.d.ts +28 -0
  150. package/dist/types/lib/importers/tdms/format.d.ts +2 -0
  151. package/dist/types/lib/importers/tdms/importer.d.ts +10 -0
  152. package/dist/types/lib/importers/types.d.ts +172 -0
  153. package/dist/types/lib/importers/workerCore.d.ts +44 -0
  154. package/dist/types/lib/importers/xdf/format.d.ts +2 -0
  155. package/dist/types/lib/importers/xdf/importer.d.ts +2 -0
  156. package/dist/types/lib/importers/zlib.d.ts +13 -0
  157. package/dist/types/lib/kde.d.ts +2 -0
  158. package/dist/types/lib/live/buffer.d.ts +265 -0
  159. package/dist/types/lib/live/columnsWire.d.ts +24 -0
  160. package/dist/types/lib/live/crypto.d.ts +157 -0
  161. package/dist/types/lib/live/liveMathChannels.d.ts +11 -0
  162. package/dist/types/lib/live/recorder.d.ts +32 -0
  163. package/dist/types/lib/live/stream.d.ts +33 -0
  164. package/dist/types/lib/live/timeBuckets.d.ts +71 -0
  165. package/dist/types/lib/live/types.d.ts +72 -0
  166. package/dist/types/lib/live/wire.d.ts +25 -0
  167. package/dist/types/lib/mathChannels/compile.d.ts +22 -0
  168. package/dist/types/lib/mathChannels/evaluator.d.ts +40 -0
  169. package/dist/types/lib/mathChannels/functions/conditional.d.ts +2 -0
  170. package/dist/types/lib/mathChannels/functions/filters.d.ts +7 -0
  171. package/dist/types/lib/mathChannels/functions/index.d.ts +3 -0
  172. package/dist/types/lib/mathChannels/functions/reference.d.ts +7 -0
  173. package/dist/types/lib/mathChannels/functions/windowOps.d.ts +11 -0
  174. package/dist/types/lib/mathChannels/index.d.ts +13 -0
  175. package/dist/types/lib/mathChannels/io.d.ts +18 -0
  176. package/dist/types/lib/mathChannels/mathjsSetup.d.ts +7 -0
  177. package/dist/types/lib/mathChannels/parseMath.d.ts +12 -0
  178. package/dist/types/lib/mathChannels/parser.d.ts +22 -0
  179. package/dist/types/lib/mathChannels/types.d.ts +34 -0
  180. package/dist/types/lib/mathChannels/usedChannels.d.ts +14 -0
  181. package/dist/types/lib/moduleWorker.d.ts +7 -0
  182. package/dist/types/lib/panelChartSettings.d.ts +438 -0
  183. package/dist/types/lib/parseDataset.d.ts +74 -0
  184. package/dist/types/lib/parseDataset.worker.d.ts +1 -0
  185. package/dist/types/lib/parseDatasetWorkerClient.d.ts +32 -0
  186. package/dist/types/lib/perfLog.d.ts +4 -0
  187. package/dist/types/lib/quantiles.d.ts +10 -0
  188. package/dist/types/lib/recordings/csvWriter.d.ts +10 -0
  189. package/dist/types/lib/recordings/export.d.ts +26 -0
  190. package/dist/types/lib/recordings/importer.d.ts +2 -0
  191. package/dist/types/lib/recordings/keys.d.ts +23 -0
  192. package/dist/types/lib/recordings/krc.d.ts +38 -0
  193. package/dist/types/lib/recordings/mf4Writer.d.ts +20 -0
  194. package/dist/types/lib/render/chartFonts.d.ts +10 -0
  195. package/dist/types/lib/render/colorBucket.d.ts +6 -0
  196. package/dist/types/lib/render/contours.d.ts +16 -0
  197. package/dist/types/lib/render/cssColor.d.ts +2 -0
  198. package/dist/types/lib/render/frames.d.ts +46 -0
  199. package/dist/types/lib/render/gl3d.d.ts +63 -0
  200. package/dist/types/lib/render/glLines.d.ts +62 -0
  201. package/dist/types/lib/render/glPlot.d.ts +36 -0
  202. package/dist/types/lib/render/glPoints.d.ts +37 -0
  203. package/dist/types/lib/render/glSeries.d.ts +67 -0
  204. package/dist/types/lib/render/heatGrid.d.ts +9 -0
  205. package/dist/types/lib/render/hitGrid.d.ts +16 -0
  206. package/dist/types/lib/render/liveZoomBus.d.ts +18 -0
  207. package/dist/types/lib/render/margins.d.ts +14 -0
  208. package/dist/types/lib/render/offscreenLineRenderer.d.ts +53 -0
  209. package/dist/types/lib/render/offscreenLineWorker.d.ts +1 -0
  210. package/dist/types/lib/render/plotFrame.d.ts +36 -0
  211. package/dist/types/lib/render/resample.d.ts +18 -0
  212. package/dist/types/lib/render/sharedGl.d.ts +38 -0
  213. package/dist/types/lib/render/useGlPlot.d.ts +7 -0
  214. package/dist/types/lib/savedLayout.d.ts +45 -0
  215. package/dist/types/lib/stft.d.ts +37 -0
  216. package/dist/types/lib/workspaces/encrypted.d.ts +50 -0
  217. package/dist/types/lib/workspaces/io.d.ts +120 -0
  218. package/dist/types/lib/xyFit.d.ts +14 -0
  219. package/dist/types/lib/yAxisTicks.d.ts +28 -0
  220. package/dist/types/react/index.d.ts +32 -0
  221. package/dist/types/types/loadedDataset.d.ts +42 -0
  222. package/dist/types/types/plotSeries.d.ts +27 -0
  223. package/package.json +63 -4
@@ -0,0 +1,37 @@
1
+ export declare function fmtHz(hz: number): string;
2
+ /**
3
+ * Short-time Fourier transform: the amplitude of every frequency bin of every
4
+ * window, `frames` × `bins` row by row (row = bin), plus the largest.
5
+ */
6
+ export declare function computeSTFT(signal: ArrayLike<number>, winSz: number, step: number, useHann: boolean): {
7
+ amps: Float32Array;
8
+ frames: number;
9
+ bins: number;
10
+ max: number;
11
+ };
12
+ /**
13
+ * A spectrogram as a grid of cells, `bins` rows × `frames` columns (row r,
14
+ * frame f at values[r * frames + f]): each cell the bin's amplitude, or its
15
+ * level in dB (20·log10, not yet relative to the loudest: the caller applies
16
+ * that through the colour range, so a louder new frame rewrites no cell).
17
+ * Row r shows bin `rowBin[r]` (a warped frequency axis) or bin r.
18
+ *
19
+ * Given the previous result, windows whose samples are unchanged are not
20
+ * transformed again: a signal that dropped its oldest samples and gained new
21
+ * ones (a live stream) by a multiple of the hop reuses every window still in
22
+ * it, so each refresh transforms only the new windows.
23
+ */
24
+ export interface SpectrogramGrid {
25
+ values: Float32Array;
26
+ frames: number;
27
+ bins: number;
28
+ /** The largest amplitude. */
29
+ max: number;
30
+ /** Windows transformed by this call (the rest were reused). */
31
+ computed: number;
32
+ /** For the next call: the signal (a copy) and each frame's largest amplitude. */
33
+ readonly sig: Float64Array;
34
+ readonly frameMax: Float32Array;
35
+ readonly key: string;
36
+ }
37
+ export declare function spectrogramGrid(signal: ArrayLike<number>, winSz: number, step: number, useHann: boolean, db: boolean, rowBin: Int32Array | null, prev?: SpectrogramGrid | null): SpectrogramGrid;
@@ -0,0 +1,50 @@
1
+ import { type PasswordSealed } from '../live/crypto';
2
+ import type { WorkbookBody } from './io';
3
+ /** A `.kymo` file (spec "Export / import files"). v3: AES-256-GCM under the key of the scope it was exported for
4
+ * ('user': only me, 'org': my organization, 'any': anyone with Kymoscope; the host holds the keys), of the envelope
5
+ * v2 JSON or, with `inner: 'password'`, of a v2 file. v2: the envelope sealed under a password only. */
6
+ export type WorkbookFileScope = 'user' | 'org' | 'any';
7
+ export interface PasswordWorkbookFile extends PasswordSealed {
8
+ format: 'kymoscope-workbook';
9
+ v: 2;
10
+ }
11
+ export interface ScopedWorkbookFile {
12
+ format: 'kymoscope-workbook';
13
+ v: 3;
14
+ scope: WorkbookFileScope;
15
+ scope_id: string | null;
16
+ alg: 'AES-256-GCM';
17
+ iv: string;
18
+ ct: string;
19
+ inner?: 'password';
20
+ }
21
+ export type EncryptedWorkbookFile = PasswordWorkbookFile | ScopedWorkbookFile;
22
+ export interface WorkbookFileOptions {
23
+ scope: WorkbookFileScope;
24
+ /** The user's or organization's id; null for 'any'. */
25
+ scopeId: string | null;
26
+ /** The scope's 32-byte key. */
27
+ key: Uint8Array;
28
+ /** Optional: a password layer inside (the only layer the key holder can't open). */
29
+ password?: string;
30
+ }
31
+ export interface WorkbookFileInfo {
32
+ v: 2 | 3;
33
+ scope: WorkbookFileScope | null;
34
+ scopeId: string | null;
35
+ password: boolean;
36
+ }
37
+ /** Binds the scope and the file's v and inner too: a file whose inner was stripped or added doesn't open. */
38
+ export declare const workbookExportAad: (scope: WorkbookFileScope, scopeId: string | null, inner?: "password") => string;
39
+ /** A password-only file (v2): for embedders without scope keys; v3 files carry it inside as their password layer. */
40
+ export declare function encryptPasswordWorkbookFile(body: WorkbookBody, password: string): Promise<PasswordWorkbookFile>;
41
+ export declare function encryptWorkbookFile(body: WorkbookBody, o: WorkbookFileOptions): Promise<ScopedWorkbookFile>;
42
+ export declare function isEncryptedWorkbookFile(x: unknown): x is EncryptedWorkbookFile;
43
+ /** What opening a file needs (null: not a file this SDK reads). */
44
+ export declare function workbookFileInfo(x: unknown): WorkbookFileInfo | null;
45
+ /** The envelope inside (still to be parsed). scope_key_required / password_required: what's missing; another
46
+ * scope's key or a damaged file: bad_file; a wrong password: wrong_password. */
47
+ export declare function decryptWorkbookFile(file: EncryptedWorkbookFile, o: {
48
+ key?: Uint8Array;
49
+ password?: string;
50
+ }): Promise<unknown>;
@@ -0,0 +1,120 @@
1
+ import type { Worksheet } from '../savedLayout';
2
+ import { type WorkbookFileInfo } from './encrypted';
3
+ import type { PanelChartSettings } from '../panelChartSettings';
4
+ import type { DashboardPanel, DashboardPanelKind } from '../../components/dashboardGridLayout';
5
+ import type { BeaconConfig } from '../beacon';
6
+ import type { MathChannel } from '../mathChannels/types';
7
+ type ExportedWorksheet = {
8
+ name: string;
9
+ xKey: string;
10
+ panels: Worksheet['panels'];
11
+ panelChartSettings: Worksheet['panelChartSettings'];
12
+ panelChartBackgrounds: Worksheet['panelChartBackgrounds'];
13
+ };
14
+ /** Legacy plain export (still imported). */
15
+ export interface WorkspaceExportEnvelopeV1 {
16
+ version: 1;
17
+ exportedAt: string;
18
+ worksheets: ExportedWorksheet[];
19
+ }
20
+ /** A math channel copied into a workbook, by value. */
21
+ export type WorkbookChannel = Pick<MathChannel, 'name' | 'formula' | 'units' | 'enabled'> & {
22
+ description?: string;
23
+ };
24
+ /** Envelope v2 — a cloud workbook's body and a `.kymo` file's content. The analysis only, never data: no files,
25
+ * streams, selection, dataset colours or offsets (spec "Workbook body"). */
26
+ export interface WorkbookBody {
27
+ version: 2;
28
+ worksheets: ExportedWorksheet[];
29
+ /** Index into `worksheets`. */
30
+ activeWorksheet: number;
31
+ mathChannels: WorkbookChannel[];
32
+ liveWindowSeconds: number | null;
33
+ /** Lap / cycle split, without the dataset it came from. */
34
+ laps: BeaconConfig | null;
35
+ }
36
+ /** What `exportWorkspace()` returns (envelope v2 since cloud workbooks). */
37
+ export type WorkspaceExportEnvelope = WorkbookBody;
38
+ export interface WorksheetExportEnvelope {
39
+ version: 1;
40
+ kind: 'worksheet';
41
+ exportedAt: string;
42
+ worksheet: {
43
+ name: string;
44
+ xKey: string;
45
+ panels: Worksheet['panels'];
46
+ panelChartSettings: Worksheet['panelChartSettings'];
47
+ panelChartBackgrounds: Worksheet['panelChartBackgrounds'];
48
+ };
49
+ }
50
+ export interface ImportedChart {
51
+ kind: DashboardPanelKind;
52
+ title?: string;
53
+ settings: PanelChartSettings;
54
+ background: string | null;
55
+ }
56
+ export interface ChartExportEnvelope {
57
+ version: 1;
58
+ kind: 'chart';
59
+ exportedAt: string;
60
+ chart: {
61
+ kind: DashboardPanelKind;
62
+ title?: string;
63
+ settings: PanelChartSettings;
64
+ background: string | null;
65
+ };
66
+ }
67
+ export interface ImportResult {
68
+ worksheets: Worksheet[];
69
+ errors: string[];
70
+ }
71
+ /** A parsed v1 or v2 envelope. `liveWindowSeconds` / `laps` undefined: a v1 file (keep the current ones). */
72
+ export interface ParsedWorkbook extends ImportResult {
73
+ activeIndex: number;
74
+ mathChannels: WorkbookChannel[];
75
+ liveWindowSeconds: number | null | undefined;
76
+ laps: BeaconConfig | null | undefined;
77
+ }
78
+ export type ParsedKymoscopeFile = {
79
+ type: 'workspace';
80
+ worksheets: Worksheet[];
81
+ errors: string[];
82
+ } | {
83
+ type: 'worksheet';
84
+ worksheet: Worksheet;
85
+ } | {
86
+ type: 'chart';
87
+ chart: ImportedChart;
88
+ } | ({
89
+ type: 'encrypted';
90
+ } & WorkbookFileInfo) | {
91
+ type: 'error';
92
+ errors: string[];
93
+ };
94
+ export declare function buildWorkspaceEnvelope(worksheets: Worksheet[]): WorkspaceExportEnvelopeV1;
95
+ export declare function buildWorkbookBody(s: {
96
+ worksheets: Worksheet[];
97
+ activeWorksheetId: string;
98
+ channels: Array<Pick<MathChannel, 'name' | 'formula' | 'units' | 'enabled'> & {
99
+ description?: string;
100
+ }>;
101
+ liveWindowSeconds: number | null;
102
+ laps: BeaconConfig | null;
103
+ }): WorkbookBody;
104
+ export declare function buildWorkspaceExportBlob(worksheets: Worksheet[]): Blob;
105
+ export declare function buildWorksheetEnvelope(worksheet: Worksheet): WorksheetExportEnvelope;
106
+ export declare function buildWorksheetExportBlob(worksheet: Worksheet): Blob;
107
+ export declare function buildChartEnvelope(panel: DashboardPanel, settings: PanelChartSettings, background: string | null): ChartExportEnvelope;
108
+ export declare function buildChartExportBlob(panel: DashboardPanel, settings: PanelChartSettings, background: string | null): Blob;
109
+ export declare function parseWorkspaceImportFile(file: File): Promise<ImportResult>;
110
+ export declare function isCssColor(v: unknown): v is string;
111
+ /** Parse an already-decoded v1 or v2 envelope. */
112
+ export declare function parseWorkspaceEnvelope(parsed: unknown): ParsedWorkbook;
113
+ /**
114
+ * True when the given worksheets contain real work worth warning about before
115
+ * a destructive replace — i.e. at least one worksheet has a panel. A single
116
+ * empty default worksheet does not count.
117
+ */
118
+ export declare function workspaceHasWork(worksheets: Worksheet[]): boolean;
119
+ export declare function parseKymoscopeFile(file: File): Promise<ParsedKymoscopeFile>;
120
+ export {};
@@ -0,0 +1,14 @@
1
+ /** Least-squares polynomial fits for X-Y scatter trend lines. */
2
+ import type { XYPoint } from '../components/XYScatterChart';
3
+ import { type XYColumns } from './data/xyColumns';
4
+ /** Only the points inside this window take part (the chart's visible area). */
5
+ export interface FitWindow {
6
+ xmin: number;
7
+ xmax: number;
8
+ ymin: number;
9
+ ymax: number;
10
+ }
11
+ /** Least-squares polynomial of `degree` through the points (those in `win` only, when given). */
12
+ export declare function computePolyFit(pts: XYPoint[] | XYColumns, degree: number, win?: FitWindow): number[] | null;
13
+ export declare function computeR2(pts: XYPoint[] | XYColumns, coeffs: number[]): number;
14
+ export declare function buildEquation(coeffs: number[], xLabel: string, yLabel: string): string;
@@ -0,0 +1,28 @@
1
+ /** “Nice” step for roughly `maxTicks` divisions across a span. */
2
+ export declare function niceMajorStep(span: number, maxTicks?: number): number;
3
+ /** X-axis tick budget for a plot width: up to 6, fewer on narrow plots so labels don't collide. */
4
+ export declare function xTickCount(plotWidthPx: number): number;
5
+ export declare function effectiveMajorMinor(scaleMin: number, scaleMax: number, yMajorStep: number | undefined, yMinorStep: number | undefined): {
6
+ majorStep: number;
7
+ minorStep: number;
8
+ };
9
+ export declare function majorTickValues(lo: number, hi: number, step: number): number[];
10
+ export declare function minorTickValues(lo: number, hi: number, minorStep: number, majorVals: number[]): number[];
11
+ /**
12
+ * Decimals that write `step` exactly (0.05 → 2, 0.25 → 2, 2.5 → 1, 20 → 0),
13
+ * at most two past its leading digit; a step that never ends (1/3, an axis cut
14
+ * in sixths) gets one past it, so 0.17 0.33 0.50 don't pass for round values.
15
+ */
16
+ export declare function stepDecimals(step: number): number;
17
+ /**
18
+ * An axis tick label: decimals from the tick `step` (not the value), so
19
+ * adjacent ticks always differ (0.60 0.65 0.70, never 1 1 1). Steps of 1000
20
+ * and up read k/M/G, steps under 0.001 m/µ/n, chosen from the step so a whole
21
+ * axis shares one prefix; zero is always "0".
22
+ */
23
+ export declare function formatTick(v: number, step: number): string;
24
+ /**
25
+ * A single value for tooltips, legends and readouts: four significant digits
26
+ * at any scale (0.6523, 3.142, 12035), SI prefixes outside 0.001..1e6.
27
+ */
28
+ export declare function formatValue(v: number): string;
@@ -0,0 +1,32 @@
1
+ /**
2
+ * React bindings for the Kymoscope engine. Optional: the engine and charts work
3
+ * without React; these only save the wiring in React hosts.
4
+ */
5
+ import { type CSSProperties, type ReactNode } from 'react';
6
+ import type { KymoscopeEngine } from '../engine/createEngine';
7
+ import type { EngineState } from '../engine/types';
8
+ import type { ChartView, ChartViewEvents, MountOptions } from '../charts/runtime';
9
+ export declare function KymoscopeProvider({ engine, children }: {
10
+ engine: KymoscopeEngine;
11
+ children?: ReactNode;
12
+ }): import("react/jsx-runtime").JSX.Element;
13
+ export declare function useEngine(): KymoscopeEngine;
14
+ /**
15
+ * Subscribe to a slice of the engine state. Re-renders only when the selected
16
+ * value changes (by `isEqual`, default `Object.is`).
17
+ */
18
+ export declare function useEngineState<T>(selector: (s: EngineState) => T, isEqual?: (a: T, b: T) => boolean): T;
19
+ export interface ChartProps {
20
+ /** Chart id (from `engine.charts.add`). */
21
+ id: string;
22
+ className?: string;
23
+ style?: CSSProperties;
24
+ options?: MountOptions;
25
+ onStatus?: (status: ChartViewEvents['status']) => void;
26
+ onContextMenu?: (e: ChartViewEvents['contextmenu']) => void;
27
+ onViewChange?: (range: ChartViewEvents['viewchange']) => void;
28
+ /** Receives the ChartView (export, shift mode, autoscale) once mounted. */
29
+ viewRef?: (view: ChartView | null) => void;
30
+ }
31
+ /** A mounted chart. Size it with `className`/`style`; the plot fills it. */
32
+ export declare function Chart({ id, className, style, options, onStatus, onContextMenu, onViewChange, viewRef }: ChartProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,42 @@
1
+ import type { Dataset, DatasetParseConfig } from '../lib/parseDataset';
2
+ import type { DataSource, ColumnSchema } from '../lib/data/dataSource';
3
+ import type { BeaconConfig } from '../lib/beacon';
4
+ import type { DatasetFileInfo } from '../lib/importers/types';
5
+ export interface LoadedDataset {
6
+ id: string;
7
+ name: string;
8
+ /** 'memory' = fully parsed into rows; 'duckdb' = large file, out-of-core; 'columnar' = large host columns (typed arrays). The last two are read through `source`. */
9
+ kind: 'memory' | 'duckdb' | 'columnar';
10
+ /** Read interface (InMemoryDataSource or DuckDbDataSource). */
11
+ source: DataSource;
12
+ /** Column schema (numeric/string + units), from the source. */
13
+ schema: ColumnSchema[];
14
+ /**
15
+ * Always present so the existing row-based pipeline keeps working. For
16
+ * 'duckdb' it is HEADER-ONLY: columnNames + units populated, `rows` empty (the
17
+ * real data lives in the DuckDB table, queried via `source`).
18
+ */
19
+ data: Dataset;
20
+ /**
21
+ * The dataset's text: all of it for text handed over directly, only the start
22
+ * (up to 256 KB, for previews) for an imported file, which `file` keeps instead.
23
+ * Absent for binary files (see `info`).
24
+ */
25
+ rawText?: string;
26
+ /** The imported file, read again to re-parse or re-import (absent: `rawText` is the whole text). */
27
+ file?: Blob;
28
+ /** Files read together with `file` (an MF4's .dbc, a COMTRADE .dat). */
29
+ companions?: File[];
30
+ /** Delimited text only. */
31
+ parseConfig?: DatasetParseConfig;
32
+ /** Binary files: format, start time, groups, events. */
33
+ info?: DatasetFileInfo;
34
+ /** Built from host columns (`datasets.addColumns`): its data can be swapped with `datasets.replaceColumns`. */
35
+ fromColumns?: boolean;
36
+ /** Arrays a column was replaced from, reused by the next writeColumns (engine internal). */
37
+ columnSpares?: Map<string, Float64Array>;
38
+ /** Beacon lap split; when set, the dataset is shown/selected as its laps. */
39
+ beacon?: BeaconConfig;
40
+ }
41
+ /** True when the dataset's rows are materialized in memory (small files). */
42
+ export declare function isInMemory(ld: LoadedDataset): boolean;
@@ -0,0 +1,27 @@
1
+ export type AlarmStyle = 'solid' | 'dashed' | 'dotted';
2
+ export interface AlarmLine {
3
+ value: number;
4
+ style: AlarmStyle;
5
+ width: number;
6
+ color: string;
7
+ }
8
+ /** One Y layer: vertical fraction of the plot area and physical scale. */
9
+ export interface PlotSeries {
10
+ id: string;
11
+ column: string;
12
+ color: string;
13
+ /** % from the bottom of the plot area (0 = bottom of the chart). */
14
+ bandFromPct: number;
15
+ /** % from the bottom to the top of the band (100 = top of the plot area). */
16
+ bandToPct: number;
17
+ scaleMin: number;
18
+ scaleMax: number;
19
+ /** Major tick interval (labels + grid). 0 = automatic. */
20
+ yMajorStep: number;
21
+ /** Minor tick interval (marks only). 0 = automatic (~one fifth of major). */
22
+ yMinorStep: number;
23
+ /** Optional horizontal alarm line drawn across the band at this value. */
24
+ alarm?: AlarmLine | null;
25
+ }
26
+ export declare function clampPct(n: number): number;
27
+ export declare function newSeriesId(): string;
package/package.json CHANGED
@@ -1,6 +1,65 @@
1
1
  {
2
2
  "name": "@kymoscope/sdk",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.1",
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
+ "license": "SEE LICENSE IN LICENSE.md",
6
+ "homepage": "https://kymoscope.com/docs/introduction",
7
+ "keywords": [
8
+ "telemetry",
9
+ "charts",
10
+ "data-visualization",
11
+ "duckdb",
12
+ "time-series",
13
+ "mdf",
14
+ "react"
15
+ ],
16
+ "type": "module",
17
+ "sideEffects": [
18
+ "**/*.css"
19
+ ],
20
+ "exports": {
21
+ ".": {
22
+ "types": "./dist/types/index.d.ts",
23
+ "default": "./dist/kymoscope-sdk.js"
24
+ },
25
+ "./react": {
26
+ "types": "./dist/types/react/index.d.ts",
27
+ "default": "./dist/react.js"
28
+ },
29
+ "./embed": "./dist/kymoscope-embed.js",
30
+ "./styles/*": "./dist/styles/*",
31
+ "./package.json": "./package.json"
32
+ },
33
+ "peerDependencies": {
34
+ "react": "^19",
35
+ "react-dom": "^19"
36
+ },
37
+ "devDependencies": {
38
+ "@duckdb/duckdb-wasm": "^1.33.1-dev45.0",
39
+ "@msgpack/msgpack": "^3.1.3",
40
+ "apache-arrow": "17.0.0",
41
+ "delaunator": "^5.1.0",
42
+ "fflate": "^0.8.3",
43
+ "h5wasm": "0.10.3",
44
+ "mathjs": "^15.2.0"
45
+ },
46
+ "scripts": {
47
+ "test": "vitest run",
48
+ "build": "vite build && vite build -c vite.embed.config.ts && tsc -p tsconfig.build.json && node -e \"require('fs').cpSync('src/styles','dist/styles',{recursive:true})\"",
49
+ "license": "node scripts/license.mjs",
50
+ "prepack": "node scripts/pack-manifest.mjs dist",
51
+ "postpack": "node scripts/pack-manifest.mjs restore",
52
+ "prepublishOnly": "node scripts/pack-manifest.mjs guard"
53
+ },
54
+ "files": [
55
+ "dist",
56
+ "LICENSE.md",
57
+ "README.md"
58
+ ],
59
+ "publishConfig": {
60
+ "access": "public"
61
+ },
62
+ "main": "./dist/kymoscope-sdk.js",
63
+ "module": "./dist/kymoscope-sdk.js",
64
+ "types": "./dist/types/index.d.ts"
65
+ }