@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,75 @@
1
+ import type { Conv } from './conversion';
2
+ /** A piece of a logical data stream (DT/SD/RD data, or a DZ block to inflate). */
3
+ export interface Fragment {
4
+ offset: number;
5
+ length: number;
6
+ zip: {
7
+ type: number;
8
+ param: number;
9
+ orgLength: number;
10
+ } | null;
11
+ }
12
+ export interface ChannelModel {
13
+ name: string;
14
+ unit: string;
15
+ /** value: in the record; vlsd: an offset into signal data; master / vmaster: time. */
16
+ kind: 'value' | 'vlsd' | 'master' | 'vmaster';
17
+ type: 'uint' | 'int' | 'float' | 'string' | 'bytes';
18
+ encoding: 'latin1' | 'utf-8' | 'utf-16le' | 'utf-16be';
19
+ bigEndian: boolean;
20
+ byteOffset: number;
21
+ bitOffset: number;
22
+ bitCount: number;
23
+ invalBit: number | null;
24
+ allInvalid: boolean;
25
+ conv: Conv;
26
+ /** VLSD: its signal data (SD blocks)… */
27
+ sd: Fragment[] | null;
28
+ /** …or the record id of the VLSD channel group holding it. */
29
+ sdRecordId: number | null;
30
+ }
31
+ export interface GroupModel {
32
+ name: string;
33
+ dg: number;
34
+ recordId: number;
35
+ recordIdSize: number;
36
+ /** MDF3 with two record ids: one more id byte after each record. */
37
+ idTrailer: number;
38
+ dataBytes: number;
39
+ invalBytes: number;
40
+ cycles: number;
41
+ /** A VLSD channel group: holds another group's strings, not a group of its own. */
42
+ vlsdCg: boolean;
43
+ /** The only channel group of its data group: records back to back. */
44
+ sorted: boolean;
45
+ master: ChannelModel | null;
46
+ channels: ChannelModel[];
47
+ /** The data of its whole data group. */
48
+ stream: Fragment[];
49
+ /** Acquisition source bus type (2 = CAN) and the bus-event flag (bus logging, Task 4). */
50
+ busType: number;
51
+ busEvent: boolean;
52
+ }
53
+ export interface FileModel {
54
+ version: string;
55
+ startTime: string | null;
56
+ groups: GroupModel[];
57
+ notes: string[];
58
+ meta: Record<string, string>;
59
+ }
60
+ /** Bytes of one record: id, data bytes, invalidation bytes, MDF3 trailing id. */
61
+ export declare const recordSize: (g: GroupModel) => number;
62
+ /**
63
+ * The model as the decoders may trust it (a damaged or hostile file): record
64
+ * sizes bounded, record counts no more than the data holds, every channel's bits
65
+ * inside its record and its invalidation bit inside the invalidation bytes.
66
+ * Channels that are not are skipped with a note (a master that is not: samples
67
+ * are numbered).
68
+ */
69
+ export declare function checkModel(model: FileModel, fileSize: number): void;
70
+ /**
71
+ * Bytes at the start of each record that `channels` and the group's time are read
72
+ * from (a transposed DZ block inflates only those); all of it when invalidation
73
+ * bits are read.
74
+ */
75
+ export declare function bytesNeeded(g: GroupModel, channels: ChannelModel[]): number;
@@ -0,0 +1,31 @@
1
+ import type { BlobReader } from '../blobReader';
2
+ import { type ChannelModel, type FileModel, type GroupModel } from './model';
3
+ /** Records per batch: ~8 MB of record bytes, up to 64k rows (fewer than 1k only for records over 8 KB). */
4
+ export declare const rowsFor: (size: number) => number;
5
+ /** VLSD strings: SD streams read forward, or entries of VLSD channel groups collected while demultiplexing. */
6
+ export declare class Vlsd {
7
+ #private;
8
+ constructor(io: BlobReader, signal?: AbortSignal);
9
+ want(recordId: number): void;
10
+ wanted(recordId: number): boolean;
11
+ put(recordId: number, offset: number, bytes: Uint8Array): void;
12
+ bytes(ch: ChannelModel, offsets: Float64Array): Promise<(Uint8Array | null)[]>;
13
+ strings(ch: ChannelModel, offsets: Float64Array): Promise<(string | null)[]>;
14
+ }
15
+ /** Time of `n` records from `start` (master, virtual master), or null (no master: sample index). */
16
+ export declare function decodeTime(g: GroupModel, buf: Uint8Array, n: number, start: number, stride?: number, t?: Float64Array): Float64Array | null;
17
+ /**
18
+ * Raw records of the model groups `wanted` (all in one data group), in file
19
+ * order, `rows` at a time per group. Sorted: the records back to back.
20
+ * Unsorted: demultiplexed by record id; VLSD channel group entries go to `vlsd`.
21
+ * Each yielded buffer is reused once the consumer asks for more. `need`
22
+ * (sorted): the bytes of each record read (see `bytesNeeded`); `size` is the
23
+ * record stride of `buf` (shorter than the record when only those are inflated).
24
+ */
25
+ export declare function rawRecords(io: BlobReader, model: FileModel, wanted: number[], vlsd: Vlsd, signal?: AbortSignal, need?: number): AsyncGenerator<{
26
+ g: number;
27
+ buf: Uint8Array;
28
+ n: number;
29
+ start: number;
30
+ size: number;
31
+ }>;
@@ -0,0 +1,42 @@
1
+ import { type BlobReader } from '../blobReader';
2
+ import type { Fragment } from './model';
3
+ /**
4
+ * Undo the DZ transposition: `cols` = record size; the bytes past whole rows were
5
+ * not transposed. `use` < `cols`: only the first `use` bytes of each record, as
6
+ * records of `use` bytes (`b` then needs only those columns, `use` x rows bytes).
7
+ */
8
+ export declare function untranspose(b: Uint8Array, cols: number, orgLength: number, use?: number): Uint8Array;
9
+ /**
10
+ * Bytes per record read from `frags` when only the first `need` bytes of each
11
+ * `size`-byte record are used: `need` (rounded up to 4 bytes) when every block
12
+ * is a transposed DZ of whole records (only those columns are inflated), else `size`.
13
+ */
14
+ export declare function recordStride(frags: Fragment[], size: number, need: number): number;
15
+ /**
16
+ * The logical bytes of a DZ block, inflated once. `use` < record size (a
17
+ * transposed block of whole records, see `recordStride`): only the first `use`
18
+ * bytes of each record, as `use`-byte records. `limit`: a plain block stops once
19
+ * that many bytes are out (a prefix).
20
+ */
21
+ export declare function inflateFragment(io: BlobReader, f: Fragment, use?: number, limit?: number): Promise<Uint8Array>;
22
+ /** The logical bytes of a fragment list, window by window (DZ inflated; a large plain-deflate DZ streamed). `use`: see `recordStride`. */
23
+ export declare function logical(io: BlobReader, frags: Fragment[], signal?: AbortSignal, use?: number): AsyncGenerator<Uint8Array>;
24
+ /**
25
+ * Whole records out of a byte stream, `rows` at a time, at most `limit` records:
26
+ * views of the stream's own bytes where whole records lie in one piece, else
27
+ * copied into a buffer that is reused (decode a batch before asking for the next).
28
+ */
29
+ export declare function records(bytes: AsyncIterable<Uint8Array>, size: number, rows: number, limit: number): AsyncGenerator<{
30
+ buf: Uint8Array;
31
+ n: number;
32
+ }>;
33
+ /** Record `index` of an uncompressed fragment list, or null (past the end, or in a DZ block). */
34
+ export declare function recordAt(io: BlobReader, frags: Fragment[], index: number, size: number): Promise<Uint8Array | null>;
35
+ /** VLSD signal data ([u32 length][bytes] entries), read forward through a window. */
36
+ export declare class SdReader {
37
+ #private;
38
+ constructor(io: BlobReader, frags: Fragment[], signal?: AbortSignal);
39
+ /** The entry at `offset` when it is in the window already (no await on the common path). */
40
+ peek(offset: number): Uint8Array | null;
41
+ get(offset: number): Promise<Uint8Array>;
42
+ }
@@ -0,0 +1,11 @@
1
+ import type { ColumnTable } from '../columnTable';
2
+ import type { Chunk } from './combine';
3
+ /** Combined chunks into one Float64Array per column plus sparse text cells: what the CSV worker returns. */
4
+ export declare class MemorySink {
5
+ #private;
6
+ constructor(columns: {
7
+ name: string;
8
+ }[], rowsHint: number);
9
+ append(chunk: Chunk): void;
10
+ table(): ColumnTable;
11
+ }
@@ -0,0 +1,2 @@
1
+ /** Column names unique ignoring case (DuckDB folds case); `reserved` (the time column) is taken. */
2
+ export declare function uniqueNames(names: string[], reserved?: string[]): string[];
@@ -0,0 +1,33 @@
1
+ import type { LoadedDataset } from '../../types/loadedDataset';
2
+ import { type WorkerLike } from './session';
3
+ import type { ChannelChooser, GroupSelection, Importer } from './types';
4
+ /** Above this many channels the host's chooser (if any) is asked first. */
5
+ export declare const PICKER_CHANNELS = 2000;
6
+ export interface OpenImportOptions {
7
+ /** Values held by in-memory datasets already (shared budget). */
8
+ priorInMemoryValues: number;
9
+ signal?: AbortSignal;
10
+ onProgress?: (fraction: number) => void;
11
+ chooseChannels?: ChannelChooser;
12
+ /** Ask `chooseChannels` whatever the file. */
13
+ pickChannels?: boolean;
14
+ /** What the chooser starts from (choosing again for an earlier import). */
15
+ initial?: GroupSelection[];
16
+ /** Exactly these channels (split / combine of an earlier import): no chooser. */
17
+ selection?: GroupSelection[];
18
+ /** One dataset per group. */
19
+ split?: boolean;
20
+ createWorker?: () => WorkerLike;
21
+ find?: (id: string) => Promise<Importer>;
22
+ }
23
+ /**
24
+ * A binary file (with its companions) as one dataset, combined on one time
25
+ * base, or one per group (`split`, or groups without a common time base).
26
+ * Each output goes in memory while it fits the shared budget, else into DuckDB.
27
+ */
28
+ export declare function openImport(item: {
29
+ main: File;
30
+ companions: File[];
31
+ format: string;
32
+ keys?: import('../recordings/keys').RecordingKey[];
33
+ }, o: OpenImportOptions): Promise<LoadedDataset[]>;
@@ -0,0 +1,24 @@
1
+ import { type FormatInfo } from './formats';
2
+ export interface ImportItem {
3
+ main: File;
4
+ companions: File[];
5
+ /** null: delimited text (the CSV path). */
6
+ format: FormatInfo | null;
7
+ }
8
+ export declare const extOf: (name: string) => string;
9
+ /** The binary format of a file from its first bytes (formats claiming its extension are tried first), or null. */
10
+ export declare function detectFormat(file: File): Promise<FormatInfo | null>;
11
+ /**
12
+ * Files dropped or picked together, as imports: each binary main file with its
13
+ * companions (an MF4's .dbc, a COMTRADE .cfg's .dat), delimited text on its
14
+ * own, and an error for anything else. Order follows `files`.
15
+ */
16
+ export declare function groupImports(files: File[]): Promise<{
17
+ items: ImportItem[];
18
+ errors: {
19
+ file: string;
20
+ error: Error;
21
+ }[];
22
+ }>;
23
+ /** Extensions file pickers and folder trees offer: text, every binary format and their companions. */
24
+ export declare const IMPORTABLE_EXTENSIONS: string[];
@@ -0,0 +1,35 @@
1
+ import type { BlobReader } from './blobReader';
2
+ import { type Chunk } from './combine';
3
+ import type { ColumnTable } from '../columnTable';
4
+ import type { FileEvent, GroupSelection, ImportFiles, ImportPlan, Importer } from './types';
5
+ export interface OutColumn {
6
+ name: string;
7
+ unit: string;
8
+ text: boolean;
9
+ }
10
+ export interface ReadResult {
11
+ columns: OutColumn[];
12
+ rows: number;
13
+ /** Memory mode only. */
14
+ table?: ColumnTable;
15
+ events: FileEvent[];
16
+ }
17
+ export interface ReadCallbacks {
18
+ /** Stream mode: one combined chunk; resolve when it is stored (back-pressure). */
19
+ chunk?: (c: Chunk) => Promise<void>;
20
+ progress?: (fraction: number) => void;
21
+ signal?: AbortSignal;
22
+ }
23
+ /** A file's plan, checked (`checkPlan`): the worker and the inline session plan through this. */
24
+ export declare function planImport(importer: Importer, files: ImportFiles, io: BlobReader): Promise<ImportPlan>;
25
+ /** Time, then every selected channel; a name repeated across groups gets its group in brackets. */
26
+ export declare function outColumns(plan: ImportPlan, selection: GroupSelection[]): OutColumn[];
27
+ /** Rows of the combined output (the base group plus every irregular group); -1 when a group's count is unknown. */
28
+ export declare function estimateRows(plan: ImportPlan, selection: GroupSelection[]): number;
29
+ /** Values (rows × columns, Time included) the selection loads; unknown counts assume 4 bytes per value. */
30
+ export declare function estimateValues(plan: ImportPlan, selection: GroupSelection[], fileSize: number): number;
31
+ /**
32
+ * Read the selected groups of a planned file into one table (memory) or a
33
+ * stream of chunks (DuckDB), combined on one time base.
34
+ */
35
+ export declare function readImport(importer: Importer, files: ImportFiles, plan: ImportPlan, io: BlobReader, selection: GroupSelection[], mode: 'memory' | 'stream', on?: ReadCallbacks): Promise<ReadResult>;
@@ -0,0 +1,28 @@
1
+ import { type ReadResult } from './run';
2
+ import type { Chunk } from './combine';
3
+ import type { FromWorker, ToWorker } from './workerCore';
4
+ import type { GroupSelection, ImportFiles, ImportPlan, Importer } from './types';
5
+ export interface ReadHandlers {
6
+ chunk?: (c: Chunk) => Promise<void>;
7
+ progress?: (fraction: number) => void;
8
+ }
9
+ /** One file being imported: plan once, read one or more selections, then close. */
10
+ export interface ImportSession {
11
+ plan(): Promise<ImportPlan>;
12
+ read(selection: GroupSelection[], mode: 'memory' | 'stream', on?: ReadHandlers): Promise<ReadResult>;
13
+ close(): void;
14
+ }
15
+ /** The slice of the Worker API used here (a fake in tests). */
16
+ export interface WorkerLike {
17
+ postMessage(m: ToWorker): void;
18
+ terminate(): void;
19
+ onmessage: ((e: MessageEvent<FromWorker>) => void) | null;
20
+ onerror: ((e: unknown) => void) | null;
21
+ }
22
+ /**
23
+ * Start the next import's worker now; with `h5`, have it load and initialise h5wasm too
24
+ * (HDF5, MAT 7.3). No-op where imports run inline (no workers).
25
+ */
26
+ export declare function warmImport(h5: boolean, createWorker?: () => WorkerLike): void;
27
+ /** In a worker where there are workers (always in browsers), else in this thread (tests, server-side). */
28
+ export declare function openSession(importer: string, files: ImportFiles, signal?: AbortSignal, createWorker?: () => WorkerLike, find?: (id: string) => Promise<Importer>): ImportSession;
@@ -0,0 +1,2 @@
1
+ import type { FormatInfo } from '../formats';
2
+ export declare const TDMS_FORMAT: FormatInfo;
@@ -0,0 +1,10 @@
1
+ import { type Importer } from '../types';
2
+ type Scale = (x: number) => number;
3
+ /**
4
+ * The NI scale chain of a channel (from the channel, else its group, else the
5
+ * file, like npTDMS), or null. Linear and polynomial, input sources resolved; a
6
+ * scale without a type is the DAQmx scaler itself (its raw value).
7
+ */
8
+ export declare function scaling(chain: Map<string, unknown>[], notes: string[], name: string): Scale | null;
9
+ export declare const tdmsImporter: Importer;
10
+ export {};
@@ -0,0 +1,172 @@
1
+ /**
2
+ * Binary and scientific file importers (wave 1: MF4/MDF3 + DBC, EDF/BDF, XDF,
3
+ * TDMS, HDF5, MAT, COMTRADE). An importer plans a file from its headers, then
4
+ * yields batches of samples per group; `readImport` combines the groups onto
5
+ * one time base and fills a sink (memory or DuckDB).
6
+ */
7
+ import type { BlobReader } from './blobReader';
8
+ /** How a group's sample times are known. */
9
+ export type TimeBase =
10
+ /** t = start + i / rate (seconds). */
11
+ {
12
+ kind: 'rate';
13
+ rate: number;
14
+ start: number;
15
+ }
16
+ /** Every batch carries its timestamps (seconds from the start of the file). */
17
+ | {
18
+ kind: 'timestamps';
19
+ }
20
+ /** No time in the file: the sample index (such groups cannot be combined). */
21
+ | {
22
+ kind: 'index';
23
+ };
24
+ export interface PlanChannel {
25
+ name: string;
26
+ unit: string;
27
+ /** Text values; else numbers. */
28
+ text?: boolean;
29
+ /** Combined, it only has values at its own timestamps (markers); else it holds its last value. */
30
+ sparse?: boolean;
31
+ }
32
+ export interface PlanGroup {
33
+ name: string;
34
+ channels: PlanChannel[];
35
+ /** Samples in the group; -1 when the file does not say before it is read. */
36
+ samples: number;
37
+ time: TimeBase;
38
+ /** Nominal rate in Hz for the UI; null when irregular or unknown. */
39
+ rateHz: number | null;
40
+ /** Its timestamps join the combined time base as they are (irregular streams, markers). */
41
+ irregular?: boolean;
42
+ }
43
+ export interface FileEvent {
44
+ time: number;
45
+ text: string;
46
+ }
47
+ export interface ImportPlan {
48
+ /** Format and version, e.g. 'MF4 4.10', 'EDF+'. */
49
+ format: string;
50
+ /** ISO 8601 start of the recording, when the file has one. */
51
+ startTime: string | null;
52
+ groups: PlanGroup[];
53
+ meta: Record<string, string>;
54
+ events: FileEvent[];
55
+ /** What was skipped or approximated, in plain English. */
56
+ notes: string[];
57
+ /** The structure is ambiguous: ask the host which groups to read (HDF5). */
58
+ pick?: boolean;
59
+ /** Groups read when nobody chooses (default: all). */
60
+ defaultGroups?: number[];
61
+ /**
62
+ * The groups share one data stream (unsorted MF4, bus logging): read them in
63
+ * one pass with `stream`, even when the importer has `streamGroup`.
64
+ */
65
+ interleaved?: boolean;
66
+ /** Importer-private; never leaves the worker. */
67
+ state: unknown;
68
+ }
69
+ /** Channels to read from one group, in output order (indices into `PlanGroup.channels`). */
70
+ export interface GroupSelection {
71
+ group: number;
72
+ channels: number[];
73
+ }
74
+ export type ColumnValues = Float64Array | (string | null)[];
75
+ /**
76
+ * Samples of one group. Every Float64Array owns its whole buffer (it may be
77
+ * transferred to the page).
78
+ */
79
+ export interface Batch {
80
+ group: number;
81
+ /** Seconds from the start of the file; null for 'rate' and 'index' groups (made from `start`). */
82
+ time: Float64Array | null;
83
+ /** Index of the first row within its group. */
84
+ start: number;
85
+ length: number;
86
+ /** One per selected channel of this group, in selection order. */
87
+ columns: ColumnValues[];
88
+ /** Events found while reading (EDF+ annotations). */
89
+ events?: FileEvent[];
90
+ }
91
+ export interface ImportFiles {
92
+ main: File;
93
+ companions: File[];
94
+ /** A cloud recording's keys (the `krc` importer only): structured-cloned to the worker, never extracted. */
95
+ keys?: import('../recordings/keys').RecordingKey[];
96
+ }
97
+ export interface StreamArgs {
98
+ files: ImportFiles;
99
+ plan: ImportPlan;
100
+ io: BlobReader;
101
+ selection: GroupSelection[];
102
+ signal?: AbortSignal;
103
+ }
104
+ export interface Importer {
105
+ id: string;
106
+ label: string;
107
+ /** Lowercase, with the dot. A hint only: `sniff` decides. */
108
+ extensions: string[];
109
+ companions?: {
110
+ ext: string;
111
+ anyName?: boolean;
112
+ }[];
113
+ sniff(head: Uint8Array, name: string): boolean;
114
+ plan(files: ImportFiles, io: BlobReader): Promise<ImportPlan>;
115
+ /** Batches of every selected group, in file order (groups may interleave in time). */
116
+ stream(args: StreamArgs): AsyncIterable<Batch>;
117
+ /** One group's batches in time order, reading only that group (formats that store groups apart). */
118
+ streamGroup?(args: StreamArgs, group: number): AsyncIterable<Batch>;
119
+ }
120
+ /** The channels selected in group `g` (empty when the group is not selected). */
121
+ export declare function selectedChannels(args: StreamArgs, g: number): number[];
122
+ /** What a binary dataset knows about its file (`LoadedDataset.info`, `DatasetInfo.fileInfo`). */
123
+ export interface DatasetFileInfo {
124
+ format: string;
125
+ /** Importer id, used to read the file again (split / combine). */
126
+ importer: string;
127
+ startTime: string | null;
128
+ /** Every group in the file, also those not read. */
129
+ groups: {
130
+ name: string;
131
+ channels: number;
132
+ samples: number;
133
+ rateHz: number | null;
134
+ }[];
135
+ /** What this dataset holds. */
136
+ selection: GroupSelection[];
137
+ /** Several groups on one time base: how many, and the base rate. */
138
+ combined: {
139
+ groups: number;
140
+ rateHz: number | null;
141
+ } | null;
142
+ /** Datasets split from one file share this key. */
143
+ splitKey: string | null;
144
+ channels: number;
145
+ notes: string[];
146
+ meta: Record<string, string>;
147
+ events: FileEvent[];
148
+ }
149
+ /** What `chooseChannels` is asked before a large or ambiguous binary file is read. */
150
+ export interface ChannelRequest {
151
+ file: string;
152
+ format: string;
153
+ groups: {
154
+ name: string;
155
+ rateHz: number | null;
156
+ samples: number;
157
+ channels: {
158
+ name: string;
159
+ unit: string;
160
+ }[];
161
+ }[];
162
+ /** What would be read without a choice. */
163
+ selection: GroupSelection[];
164
+ /** Values (rows × columns) a selection would load. */
165
+ estimate(selection: GroupSelection[]): number;
166
+ /** In-memory budget and what open datasets already use (above it, the file goes out of core). */
167
+ budget: number;
168
+ used: number;
169
+ notes: string[];
170
+ }
171
+ /** Resolves with the channels to read, or null to cancel this file. */
172
+ export type ChannelChooser = (request: ChannelRequest) => Promise<GroupSelection[] | null>;
@@ -0,0 +1,44 @@
1
+ import { type ReadResult } from './run';
2
+ import type { Chunk } from './combine';
3
+ import type { GroupSelection, ImportFiles, ImportPlan, Importer } from './types';
4
+ export type ToWorker = {
5
+ type: 'plan';
6
+ importer: string;
7
+ files: ImportFiles;
8
+ } | {
9
+ type: 'read';
10
+ selection: GroupSelection[];
11
+ mode: 'memory' | 'stream';
12
+ } | {
13
+ type: 'ack';
14
+ }
15
+ /** Load h5wasm now (warm-up ahead of an HDF5 / MAT 7.3 import). */
16
+ | {
17
+ type: 'warm';
18
+ };
19
+ export type FromWorker = {
20
+ type: 'plan';
21
+ plan: ImportPlan;
22
+ } | {
23
+ type: 'progress';
24
+ fraction: number;
25
+ } | {
26
+ type: 'chunk';
27
+ chunk: Chunk;
28
+ } | {
29
+ type: 'done';
30
+ result: ReadResult;
31
+ } | {
32
+ type: 'error';
33
+ message: string;
34
+ }
35
+ /** Heartbeat while a request runs; `work` (bytes read) shows whether it is getting anywhere. */
36
+ | {
37
+ type: 'alive';
38
+ work: number;
39
+ };
40
+ export declare const HEARTBEAT_MS = 1000;
41
+ /** A chunk ready to post: arrays owning their buffer are transferred, views into a larger buffer copied. */
42
+ export declare function transferable(chunk: Chunk): [Chunk, ArrayBuffer[]];
43
+ /** The import worker: plan once, then any number of reads (a split reads each group). */
44
+ export declare function workerHandler(post: (m: FromWorker, transfer?: Transferable[]) => void, find?: (id: string) => Importer): (m: ToWorker) => Promise<void>;
@@ -0,0 +1,2 @@
1
+ import type { FormatInfo } from '../formats';
2
+ export declare const XDF_FORMAT: FormatInfo;
@@ -0,0 +1,2 @@
1
+ import { type Importer } from '../types';
2
+ export declare const xdfImporter: Importer;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * A zlib stream arriving in pieces, inflated as it comes (never the whole input
3
+ * or output at once): the platform's `DecompressionStream('deflate')` (browsers,
4
+ * workers, Node 18+), else fflate. Stopping early (break) cancels the inflate.
5
+ */
6
+ export declare function inflateStream(input: AsyncIterable<Uint8Array>): AsyncGenerator<Uint8Array>;
7
+ /**
8
+ * A whole zlib stream (MF4 DZ blocks, MAT miCOMPRESSED elements), by the
9
+ * platform's zlib when it has one. `size`: the inflated length when known (one
10
+ * output buffer, no concatenation). `limit`: stop once that many bytes are out;
11
+ * the result is then the first `limit` bytes.
12
+ */
13
+ export declare function inflate(b: Uint8Array, size?: number, limit?: number): Promise<Uint8Array>;
@@ -0,0 +1,2 @@
1
+ /** Gaussian KDE of `sorted` (any order) at `pts`; over many values, of their histogram on [lo, hi]. */
2
+ export declare function kde(sorted: ArrayLike<number>, h: number, pts: Float64Array, lo: number, hi: number): Float64Array;