tabulark 0.0.4 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +81 -0
- package/README.md +316 -128
- package/THIRD_PARTY_NOTICES.md +37 -0
- package/dist/adapters.d.ts +62 -0
- package/dist/arrow.d.ts +3 -0
- package/dist/arrow.js +2 -0
- package/dist/arrow.js.map +7 -0
- package/dist/client.d.ts +145 -0
- package/dist/errors.d.ts +25 -0
- package/dist/excel.d.ts +3 -0
- package/dist/excel.js +2 -0
- package/dist/excel.js.map +7 -0
- package/dist/experimental.d.ts +13 -0
- package/dist/experimental.js +2 -0
- package/dist/experimental.js.map +7 -0
- package/dist/http.d.ts +65 -0
- package/dist/http.js +2 -0
- package/dist/http.js.map +7 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +7 -0
- package/dist/model.d.ts +392 -0
- package/dist/official-adapter-manifest.d.ts +31 -0
- package/dist/parquet.d.ts +3 -0
- package/dist/parquet.js +2 -0
- package/dist/parquet.js.map +7 -0
- package/dist/protocol.d.ts +54 -0
- package/dist/range-cache.d.ts +47 -0
- package/dist/range-source.d.ts +64 -0
- package/dist/rpc-client.d.ts +31 -0
- package/dist/source.d.ts +13 -0
- package/dist/view/accessible-grid.d.ts +36 -0
- package/dist/view/canvas-painter.d.ts +91 -0
- package/dist/view/canvas-table-view-public.d.ts +64 -0
- package/dist/view/canvas-table-view.d.ts +40 -0
- package/dist/view/controller.d.ts +34 -0
- package/dist/view/layout.d.ts +34 -0
- package/dist/view/selection.d.ts +7 -0
- package/dist/view/types.d.ts +184 -0
- package/dist/wasm/arrow/tabulark_arrow.d.ts +153 -0
- package/dist/wasm/arrow/tabulark_arrow.js +883 -0
- package/dist/wasm/arrow/tabulark_arrow_bg.wasm +0 -0
- package/dist/wasm/arrow/tabulark_arrow_bg.wasm.d.ts +30 -0
- package/dist/wasm/delimited/tabulark_delimited.d.ts +157 -0
- package/dist/wasm/delimited/tabulark_delimited.js +952 -0
- package/dist/wasm/delimited/tabulark_delimited_bg.wasm +0 -0
- package/dist/wasm/delimited/tabulark_delimited_bg.wasm.d.ts +31 -0
- package/dist/wasm/excel/tabulark_excel.d.ts +146 -0
- package/dist/wasm/excel/tabulark_excel.js +876 -0
- package/dist/wasm/excel/tabulark_excel_bg.wasm +0 -0
- package/dist/wasm/excel/tabulark_excel_bg.wasm.d.ts +30 -0
- package/dist/wasm/parquet/tabulark_parquet.d.ts +146 -0
- package/dist/wasm/parquet/tabulark_parquet.js +872 -0
- package/dist/wasm/parquet/tabulark_parquet_bg.wasm +0 -0
- package/dist/wasm/parquet/tabulark_parquet_bg.wasm.d.ts +30 -0
- package/dist/worker/blob-source-accessor.d.ts +10 -0
- package/dist/worker/source-accessor.d.ts +76 -0
- package/dist/worker/wasm-adapter.d.ts +58 -0
- package/dist/worker/worker-errors.d.ts +9 -0
- package/dist/worker-range-source.d.ts +1 -0
- package/dist/worker-range-source.js +2 -0
- package/dist/worker-range-source.js.map +7 -0
- package/dist/worker.d.ts +1 -0
- package/dist/worker.js +2 -0
- package/dist/worker.js.map +7 -0
- package/package.json +62 -12
- package/js/index.d.ts +0 -18
- package/js/index.js +0 -26
package/dist/model.d.ts
ADDED
|
@@ -0,0 +1,392 @@
|
|
|
1
|
+
import { BATCH_LAYOUT_VERSION } from "./protocol.js";
|
|
2
|
+
export declare const DEFAULT_MEMORY_BUDGET_BYTES: number;
|
|
3
|
+
export declare const MAX_ARRAY_BUFFER_BYTES: number;
|
|
4
|
+
export declare const MAX_RANGE_CELLS = 250000;
|
|
5
|
+
export declare const DEFAULT_TO_ROWS_CELL_LIMIT = 10000;
|
|
6
|
+
export declare const MAX_NESTING_DEPTH = 64;
|
|
7
|
+
export declare const MAX_SOURCES = 2;
|
|
8
|
+
export declare const MAX_ACTIVE_RANGES = 2;
|
|
9
|
+
export declare const MAX_RANGE_WAITERS = 8;
|
|
10
|
+
export interface MemoryBudgetLimits {
|
|
11
|
+
readonly memoryBudgetBytes: number;
|
|
12
|
+
/** Cross-thread accounting slices used by RangeSource brokers. */
|
|
13
|
+
readonly workerBudgetBytes: number;
|
|
14
|
+
readonly mainThreadSourceBytes: number;
|
|
15
|
+
readonly mainThreadRetainedBytes: number;
|
|
16
|
+
readonly sourceRangeCacheBytes: number;
|
|
17
|
+
/** Shared retained capacity allocated among the adapters actually registered. */
|
|
18
|
+
readonly adapterRuntimePoolBytes: number;
|
|
19
|
+
/** Maximum transient/decoded budget retained by one active adapter operation. */
|
|
20
|
+
readonly operationBudgetBytes: number;
|
|
21
|
+
readonly indexBudgetBytes: number;
|
|
22
|
+
readonly adapterTileCacheBudgetBytes: number;
|
|
23
|
+
readonly mainThreadRangeCacheBytes: number;
|
|
24
|
+
readonly maxFieldBytes: number;
|
|
25
|
+
readonly maxBatchBytes: number;
|
|
26
|
+
readonly maxArrayBufferBytes: number;
|
|
27
|
+
readonly maxSources: number;
|
|
28
|
+
readonly maxActiveRanges: number;
|
|
29
|
+
readonly maxRangeWaiters: number;
|
|
30
|
+
}
|
|
31
|
+
/** Derives every bounded runtime allocation from one engine-wide budget. */
|
|
32
|
+
export declare function deriveMemoryBudgetLimits(memoryBudgetBytes: number): MemoryBudgetLimits;
|
|
33
|
+
export type MemoryResourceKind = "adapter-runtime" | "source-staging" | "compressed-page" | "decompression" | "batch";
|
|
34
|
+
export interface MemoryReservation {
|
|
35
|
+
readonly resource: MemoryResourceKind;
|
|
36
|
+
readonly bytes: number;
|
|
37
|
+
release(): void;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Single-accounting ledger for Worker-owned bounded allocations.
|
|
41
|
+
*
|
|
42
|
+
* A reservation is deliberately idempotent so cancellation, close and failure
|
|
43
|
+
* races can all execute their normal cleanup paths without double accounting.
|
|
44
|
+
*/
|
|
45
|
+
export declare class MemoryReservationLedger {
|
|
46
|
+
#private;
|
|
47
|
+
constructor(capacityBytes: number);
|
|
48
|
+
get capacityBytes(): number;
|
|
49
|
+
get usedBytes(): number;
|
|
50
|
+
get availableBytes(): number;
|
|
51
|
+
reserve(resource: MemoryResourceKind, bytes: number): MemoryReservation;
|
|
52
|
+
}
|
|
53
|
+
export type AxisExtent = Readonly<{
|
|
54
|
+
kind: "exact";
|
|
55
|
+
value: number;
|
|
56
|
+
}> | Readonly<{
|
|
57
|
+
kind: "at-least";
|
|
58
|
+
value: number;
|
|
59
|
+
}> | Readonly<{
|
|
60
|
+
kind: "unknown";
|
|
61
|
+
}>;
|
|
62
|
+
export interface TableExtent {
|
|
63
|
+
readonly rows: AxisExtent;
|
|
64
|
+
readonly columns: AxisExtent;
|
|
65
|
+
}
|
|
66
|
+
export type TimeUnit = "second" | "millisecond" | "microsecond" | "nanosecond";
|
|
67
|
+
export type IntervalUnit = "year-month" | "day-time" | "month-day-nano";
|
|
68
|
+
export interface ArrowField {
|
|
69
|
+
readonly name: string;
|
|
70
|
+
readonly nullable: boolean;
|
|
71
|
+
readonly dataType: ArrowDataType;
|
|
72
|
+
readonly metadata?: Readonly<Record<string, string>>;
|
|
73
|
+
}
|
|
74
|
+
interface SimpleDataType<Type extends string> {
|
|
75
|
+
readonly type: Type;
|
|
76
|
+
}
|
|
77
|
+
/** A recursive representation of every arrow-schema 59.1.0 built-in DataType. */
|
|
78
|
+
export type ArrowDataType = SimpleDataType<"null" | "unknown" | "boolean" | "int8" | "int16" | "int32" | "int64" | "uint8" | "uint16" | "uint32" | "uint64" | "float16" | "float32" | "float64" | "date32" | "date64" | "binary" | "large-binary" | "binary-view" | "utf8" | "large-utf8" | "utf8-view"> | Readonly<{
|
|
79
|
+
type: "timestamp";
|
|
80
|
+
unit: TimeUnit;
|
|
81
|
+
timezone?: string;
|
|
82
|
+
}> | Readonly<{
|
|
83
|
+
type: "time32" | "time64" | "duration";
|
|
84
|
+
unit: TimeUnit;
|
|
85
|
+
}> | Readonly<{
|
|
86
|
+
type: "interval";
|
|
87
|
+
unit: IntervalUnit;
|
|
88
|
+
}> | Readonly<{
|
|
89
|
+
type: "fixed-size-binary";
|
|
90
|
+
byteWidth: number;
|
|
91
|
+
}> | Readonly<{
|
|
92
|
+
type: "decimal32" | "decimal64" | "decimal128" | "decimal256";
|
|
93
|
+
precision: number;
|
|
94
|
+
scale: number;
|
|
95
|
+
}> | Readonly<{
|
|
96
|
+
type: "list" | "large-list" | "list-view" | "large-list-view";
|
|
97
|
+
field: ArrowField;
|
|
98
|
+
}> | Readonly<{
|
|
99
|
+
type: "fixed-size-list";
|
|
100
|
+
field: ArrowField;
|
|
101
|
+
listSize: number;
|
|
102
|
+
}> | Readonly<{
|
|
103
|
+
type: "struct";
|
|
104
|
+
fields: readonly ArrowField[];
|
|
105
|
+
}> | Readonly<{
|
|
106
|
+
type: "union";
|
|
107
|
+
mode: "sparse" | "dense";
|
|
108
|
+
fields: readonly Readonly<{
|
|
109
|
+
typeId: number;
|
|
110
|
+
field: ArrowField;
|
|
111
|
+
}>[];
|
|
112
|
+
}> | Readonly<{
|
|
113
|
+
type: "dictionary";
|
|
114
|
+
indexType: ArrowDataType;
|
|
115
|
+
valueType: ArrowDataType;
|
|
116
|
+
ordered?: boolean;
|
|
117
|
+
}> | Readonly<{
|
|
118
|
+
type: "map";
|
|
119
|
+
entries: ArrowField;
|
|
120
|
+
keysSorted: boolean;
|
|
121
|
+
}> | Readonly<{
|
|
122
|
+
type: "run-end-encoded";
|
|
123
|
+
runEnds: ArrowField;
|
|
124
|
+
values: ArrowField;
|
|
125
|
+
}> | Readonly<{
|
|
126
|
+
type: "extension";
|
|
127
|
+
name: string;
|
|
128
|
+
metadata?: string;
|
|
129
|
+
storageType: ArrowDataType;
|
|
130
|
+
}>;
|
|
131
|
+
export interface ColumnSchema {
|
|
132
|
+
readonly id: string;
|
|
133
|
+
readonly name: string;
|
|
134
|
+
readonly index: number;
|
|
135
|
+
readonly dataType: ArrowDataType;
|
|
136
|
+
readonly nullable: boolean;
|
|
137
|
+
readonly metadata?: Readonly<Record<string, string>>;
|
|
138
|
+
}
|
|
139
|
+
export interface TableCapabilities {
|
|
140
|
+
readonly randomAccess: "indexed-prefix" | "full";
|
|
141
|
+
readonly typedValues: boolean;
|
|
142
|
+
readonly search: boolean;
|
|
143
|
+
readonly sort: boolean;
|
|
144
|
+
readonly filter: boolean;
|
|
145
|
+
readonly multiTable: boolean;
|
|
146
|
+
readonly [name: string]: unknown;
|
|
147
|
+
}
|
|
148
|
+
export interface TableMetadata {
|
|
149
|
+
readonly tableId: string;
|
|
150
|
+
readonly name: string;
|
|
151
|
+
readonly revision: number;
|
|
152
|
+
readonly extent: Readonly<TableExtent>;
|
|
153
|
+
readonly schema: Readonly<{
|
|
154
|
+
readonly version: number;
|
|
155
|
+
readonly columns: readonly Readonly<ColumnSchema>[];
|
|
156
|
+
}>;
|
|
157
|
+
readonly capabilities: Readonly<TableCapabilities>;
|
|
158
|
+
}
|
|
159
|
+
export type WorksheetVisibility = "visible" | "hidden" | "very-hidden";
|
|
160
|
+
/** One sparse row or column override supplied by a spreadsheet presentation. */
|
|
161
|
+
export interface PresentationAxisEntry {
|
|
162
|
+
readonly index: number;
|
|
163
|
+
/** CSS pixel extent when the source supplies an explicit dimension. */
|
|
164
|
+
readonly size?: number;
|
|
165
|
+
readonly hidden?: boolean;
|
|
166
|
+
}
|
|
167
|
+
export interface PresentationColor {
|
|
168
|
+
/** CSS-compatible resolved color, when the workbook supplied one. */
|
|
169
|
+
readonly css?: string;
|
|
170
|
+
}
|
|
171
|
+
export interface PresentationFont {
|
|
172
|
+
readonly family?: string;
|
|
173
|
+
readonly size?: number;
|
|
174
|
+
readonly bold?: boolean;
|
|
175
|
+
readonly italic?: boolean;
|
|
176
|
+
readonly underline?: boolean;
|
|
177
|
+
readonly color?: PresentationColor;
|
|
178
|
+
}
|
|
179
|
+
export interface PresentationBorderSide {
|
|
180
|
+
readonly style?: "none" | "thin" | "medium" | "thick" | "dashed" | "dotted" | "double";
|
|
181
|
+
readonly color?: PresentationColor;
|
|
182
|
+
}
|
|
183
|
+
/** Static cell styling that 0.1 preserves from spreadsheet input. */
|
|
184
|
+
export interface PresentationStyle {
|
|
185
|
+
readonly numberFormat?: string;
|
|
186
|
+
readonly font?: PresentationFont;
|
|
187
|
+
readonly foregroundColor?: PresentationColor;
|
|
188
|
+
readonly backgroundColor?: PresentationColor;
|
|
189
|
+
readonly fillColor?: PresentationColor;
|
|
190
|
+
readonly borders?: Readonly<{
|
|
191
|
+
readonly top?: PresentationBorderSide;
|
|
192
|
+
readonly right?: PresentationBorderSide;
|
|
193
|
+
readonly bottom?: PresentationBorderSide;
|
|
194
|
+
readonly left?: PresentationBorderSide;
|
|
195
|
+
}>;
|
|
196
|
+
readonly horizontalAlignment?: "general" | "left" | "center" | "right" | "justify";
|
|
197
|
+
readonly verticalAlignment?: "top" | "center" | "bottom" | "justify";
|
|
198
|
+
readonly wrapText?: boolean;
|
|
199
|
+
}
|
|
200
|
+
export interface MergedCellRegion {
|
|
201
|
+
readonly rowStart: number;
|
|
202
|
+
readonly rowEnd: number;
|
|
203
|
+
readonly columnStart: number;
|
|
204
|
+
readonly columnEnd: number;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Presentation metadata for a worksheet. It is intentionally static: formula
|
|
208
|
+
* calculation and document round-tripping are outside the 0.1 contract.
|
|
209
|
+
*/
|
|
210
|
+
export interface SpreadsheetPresentation {
|
|
211
|
+
readonly kind: "spreadsheet-v1";
|
|
212
|
+
readonly tableId: string;
|
|
213
|
+
readonly revision: number;
|
|
214
|
+
readonly visibility: WorksheetVisibility;
|
|
215
|
+
readonly frozenRows: number;
|
|
216
|
+
readonly frozenColumns: number;
|
|
217
|
+
readonly rows: readonly PresentationAxisEntry[];
|
|
218
|
+
readonly columns: readonly PresentationAxisEntry[];
|
|
219
|
+
/** Deduplicated styles addressed by `SpreadsheetPresentationRange.styleIds`. */
|
|
220
|
+
readonly styles: readonly PresentationStyle[];
|
|
221
|
+
}
|
|
222
|
+
export type TablePresentation = SpreadsheetPresentation;
|
|
223
|
+
export interface SpreadsheetPresentationRange {
|
|
224
|
+
readonly kind: "spreadsheet-v1";
|
|
225
|
+
readonly tableId: string;
|
|
226
|
+
readonly revision: number;
|
|
227
|
+
readonly range: Readonly<ReturnedRange>;
|
|
228
|
+
/** Rows and columns are exactly aligned with `range`; null means no style. */
|
|
229
|
+
readonly styleIds: readonly (readonly (number | null)[])[];
|
|
230
|
+
readonly mergedCells: readonly MergedCellRegion[];
|
|
231
|
+
/** Sparse layout entries that intersect this requested range. */
|
|
232
|
+
readonly rows: readonly PresentationAxisEntry[];
|
|
233
|
+
readonly columns: readonly PresentationAxisEntry[];
|
|
234
|
+
}
|
|
235
|
+
export type PresentationRange = SpreadsheetPresentationRange;
|
|
236
|
+
export interface TableDescriptor {
|
|
237
|
+
readonly id: string;
|
|
238
|
+
readonly name: string;
|
|
239
|
+
}
|
|
240
|
+
export interface RangeRequest {
|
|
241
|
+
readonly rowStart: number;
|
|
242
|
+
readonly rowCount: number;
|
|
243
|
+
readonly columnStart: number;
|
|
244
|
+
readonly columnCount: number;
|
|
245
|
+
}
|
|
246
|
+
export interface ReturnedRange extends RangeRequest {
|
|
247
|
+
}
|
|
248
|
+
/** A byte region in the batch's deduplicated buffer pool. */
|
|
249
|
+
export interface BatchBufferRegion {
|
|
250
|
+
readonly buffer: number;
|
|
251
|
+
readonly byteOffset?: number;
|
|
252
|
+
readonly byteLength?: number;
|
|
253
|
+
/** First bit for bitmap regions; ignored for byte-oriented regions. */
|
|
254
|
+
readonly bitOffset?: number;
|
|
255
|
+
}
|
|
256
|
+
/** UTF-8 text generated by Rust for rendering, ARIA, width measurement and copy. */
|
|
257
|
+
export interface DisplayColumnDescriptor {
|
|
258
|
+
readonly encoding: "utf8";
|
|
259
|
+
readonly data: BatchBufferRegion;
|
|
260
|
+
readonly offsets: BatchBufferRegion;
|
|
261
|
+
readonly validity?: BatchBufferRegion;
|
|
262
|
+
/** Logical offset into the display arrays, for sliced batches. */
|
|
263
|
+
readonly offset?: number;
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Recursive Arrow ArrayData layout. Buffer regions always point into the
|
|
267
|
+
* enclosing TableBatch buffer pool; encoded dictionaries and run ends remain
|
|
268
|
+
* visible in this descriptor even though `toRows()` returns logical values.
|
|
269
|
+
*/
|
|
270
|
+
export interface NativeColumnDescriptor {
|
|
271
|
+
/** Rust ArrayData layout encoding (for example `dictionary` or `run-end-encoded`). */
|
|
272
|
+
readonly encoding?: string;
|
|
273
|
+
readonly dataType: ArrowDataType;
|
|
274
|
+
readonly length: number;
|
|
275
|
+
readonly offset?: number;
|
|
276
|
+
readonly validity?: BatchBufferRegion;
|
|
277
|
+
readonly values?: BatchBufferRegion;
|
|
278
|
+
readonly offsets?: BatchBufferRegion;
|
|
279
|
+
readonly sizes?: BatchBufferRegion;
|
|
280
|
+
readonly data?: BatchBufferRegion;
|
|
281
|
+
readonly typeIds?: BatchBufferRegion;
|
|
282
|
+
readonly unionOffsets?: BatchBufferRegion;
|
|
283
|
+
readonly variadicBuffers?: readonly BatchBufferRegion[];
|
|
284
|
+
readonly children?: readonly NativeColumnDescriptor[];
|
|
285
|
+
readonly dictionary?: NativeColumnDescriptor;
|
|
286
|
+
readonly runEnds?: NativeColumnDescriptor;
|
|
287
|
+
readonly typeId?: number;
|
|
288
|
+
}
|
|
289
|
+
/** @internal Layout-v1 column descriptor received from an official WASM runtime. */
|
|
290
|
+
export interface WireTableBatchColumn {
|
|
291
|
+
readonly columnId: string;
|
|
292
|
+
readonly native: NativeColumnDescriptor;
|
|
293
|
+
readonly display: DisplayColumnDescriptor;
|
|
294
|
+
}
|
|
295
|
+
export interface DecimalValue {
|
|
296
|
+
readonly kind: "decimal";
|
|
297
|
+
readonly unscaled: bigint;
|
|
298
|
+
readonly precision: number;
|
|
299
|
+
readonly scale: number;
|
|
300
|
+
}
|
|
301
|
+
export interface TemporalValue {
|
|
302
|
+
readonly kind: "date32" | "date64" | "time32" | "time64" | "timestamp" | "duration";
|
|
303
|
+
readonly value: number | bigint;
|
|
304
|
+
readonly unit?: TimeUnit;
|
|
305
|
+
readonly timezone?: string;
|
|
306
|
+
}
|
|
307
|
+
export interface IntervalValue {
|
|
308
|
+
readonly kind: "interval";
|
|
309
|
+
readonly unit: IntervalUnit;
|
|
310
|
+
readonly months?: number;
|
|
311
|
+
readonly days?: number;
|
|
312
|
+
readonly milliseconds?: number;
|
|
313
|
+
readonly nanoseconds?: bigint;
|
|
314
|
+
}
|
|
315
|
+
export interface UnionValue {
|
|
316
|
+
readonly kind: "union";
|
|
317
|
+
readonly typeId: number;
|
|
318
|
+
readonly value: NativeValue | null;
|
|
319
|
+
}
|
|
320
|
+
export interface MapEntryValue {
|
|
321
|
+
readonly key: NativeValue | null;
|
|
322
|
+
readonly value: NativeValue | null;
|
|
323
|
+
}
|
|
324
|
+
export interface NativeListValue extends ReadonlyArray<NativeValue | null> {
|
|
325
|
+
}
|
|
326
|
+
export interface NativeStructValue {
|
|
327
|
+
readonly [name: string]: NativeValue | null;
|
|
328
|
+
}
|
|
329
|
+
export interface NativeMapValue extends ReadonlyArray<Readonly<MapEntryValue>> {
|
|
330
|
+
}
|
|
331
|
+
export type NativeValue = boolean | number | bigint | string | Uint8Array | DecimalValue | TemporalValue | IntervalValue | UnionValue | NativeListValue | NativeStructValue | NativeMapValue;
|
|
332
|
+
export interface ToRowsOptions {
|
|
333
|
+
/** Maximum decoded cells. Defaults to 10,000. */
|
|
334
|
+
readonly maxCells?: number;
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Logical, column-oriented access to one returned batch column.
|
|
338
|
+
*
|
|
339
|
+
* Values are indexed relative to `TableBatch.range.rowStart`; physical buffer
|
|
340
|
+
* regions and adapter transport details intentionally remain private.
|
|
341
|
+
*/
|
|
342
|
+
export interface TableBatchColumn {
|
|
343
|
+
readonly columnId: string;
|
|
344
|
+
readonly columnIndex: number;
|
|
345
|
+
readonly rowCount: number;
|
|
346
|
+
getValue(rowOffset: number): NativeValue | null;
|
|
347
|
+
getDisplayValue(rowOffset: number): string | null;
|
|
348
|
+
toValues(options?: ToRowsOptions): (NativeValue | null)[];
|
|
349
|
+
toDisplayValues(options?: ToRowsOptions): (string | null)[];
|
|
350
|
+
}
|
|
351
|
+
/** Stable logical batch contract. Wire buffers and ABI layout stay private. */
|
|
352
|
+
export interface TableBatch {
|
|
353
|
+
readonly tableId: string;
|
|
354
|
+
readonly revision: number;
|
|
355
|
+
readonly schemaVersion: number;
|
|
356
|
+
readonly range: Readonly<ReturnedRange>;
|
|
357
|
+
readonly columns: readonly TableBatchColumn[];
|
|
358
|
+
readonly complete: boolean;
|
|
359
|
+
toRows(options?: ToRowsOptions): (NativeValue | null)[][];
|
|
360
|
+
toDisplayRows(options?: ToRowsOptions): (string | null)[][];
|
|
361
|
+
}
|
|
362
|
+
export type WireBatchBuffer = ArrayBuffer | ArrayBufferView;
|
|
363
|
+
export interface WireTableBatch {
|
|
364
|
+
readonly layoutVersion: typeof BATCH_LAYOUT_VERSION;
|
|
365
|
+
readonly tableId: string;
|
|
366
|
+
readonly revision: number;
|
|
367
|
+
readonly schemaVersion: number;
|
|
368
|
+
readonly range: ReturnedRange;
|
|
369
|
+
readonly buffers: readonly WireBatchBuffer[];
|
|
370
|
+
readonly columns: readonly WireTableBatchColumn[];
|
|
371
|
+
readonly complete: boolean;
|
|
372
|
+
}
|
|
373
|
+
/** Owns and validates one generic layout-v1 batch received from the Worker. */
|
|
374
|
+
export declare class ColumnarTableBatch implements TableBatch {
|
|
375
|
+
#private;
|
|
376
|
+
readonly tableId: string;
|
|
377
|
+
readonly revision: number;
|
|
378
|
+
readonly schemaVersion: number;
|
|
379
|
+
readonly range: Readonly<ReturnedRange>;
|
|
380
|
+
readonly columns: readonly TableBatchColumn[];
|
|
381
|
+
readonly complete: boolean;
|
|
382
|
+
constructor(value: WireTableBatch);
|
|
383
|
+
toRows(options?: ToRowsOptions): (NativeValue | null)[][];
|
|
384
|
+
toDisplayRows(options?: ToRowsOptions): (string | null)[][];
|
|
385
|
+
}
|
|
386
|
+
export declare function validateRange(request: RangeRequest): RangeRequest;
|
|
387
|
+
export declare function normalizeMetadata(value: TableMetadata): Readonly<TableMetadata>;
|
|
388
|
+
/** Normalizes a protocol DataType and rejects cycles or excessive nesting. */
|
|
389
|
+
export declare function normalizeDataType(value: unknown, depth?: number): ArrowDataType;
|
|
390
|
+
export declare function assertNonNegativeSafeInteger(value: unknown, name: string): asserts value is number;
|
|
391
|
+
export declare function assertPositiveSafeInteger(value: unknown, name: string): asserts value is number;
|
|
392
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export type OfficialAdapterId = "tabulark:delimited" | "tabulark:arrow-ipc" | "tabulark:parquet" | "tabulark:excel";
|
|
2
|
+
export type OfficialSourceAccess = "streaming" | "range" | "staged";
|
|
3
|
+
export interface OfficialAdapterManifestEntry {
|
|
4
|
+
readonly id: OfficialAdapterId;
|
|
5
|
+
readonly entrypoint: "." | "./arrow" | "./parquet" | "./excel";
|
|
6
|
+
readonly exportName: string;
|
|
7
|
+
readonly wasm: Readonly<{
|
|
8
|
+
readonly packageName: string;
|
|
9
|
+
readonly crateArtifact: string;
|
|
10
|
+
readonly outputName: string;
|
|
11
|
+
readonly outputDirectory: string;
|
|
12
|
+
readonly modulePath: string;
|
|
13
|
+
readonly runtimeExport: "WasmRuntime";
|
|
14
|
+
}>;
|
|
15
|
+
readonly options: Readonly<{
|
|
16
|
+
readonly allowedKeys: readonly string[];
|
|
17
|
+
}>;
|
|
18
|
+
readonly resources: Readonly<{
|
|
19
|
+
readonly sourceAccess: OfficialSourceAccess;
|
|
20
|
+
readonly supportsPresentation: boolean;
|
|
21
|
+
readonly runtimeWeight: number;
|
|
22
|
+
}>;
|
|
23
|
+
}
|
|
24
|
+
/** Runtime IDs are derived from the manifest rather than repeated in code. */
|
|
25
|
+
export declare const OFFICIAL_ADAPTER_IDS: readonly OfficialAdapterId[];
|
|
26
|
+
/** The sole internal source of truth for built-in IDs, artifacts and host policy. */
|
|
27
|
+
export declare const OFFICIAL_ADAPTER_MANIFEST: readonly OfficialAdapterManifestEntry[];
|
|
28
|
+
export declare function isOfficialAdapterId(value: unknown): value is OfficialAdapterId;
|
|
29
|
+
export declare function officialAdapterManifestEntry(id: OfficialAdapterId): OfficialAdapterManifestEntry;
|
|
30
|
+
/** Resolves an official wrapper relative to the bundle that hosts this code. */
|
|
31
|
+
export declare function officialAdapterModuleUrl(id: OfficialAdapterId): string;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { type ParquetAdapterOptions } from "./adapters.js";
|
|
2
|
+
/** Opens Apache Parquet input through the lazy official Parquet WASM artifact. */
|
|
3
|
+
export declare const parquetAdapter: import("./adapters.js").AdapterDescriptor<"tabulark:parquet", import("./adapters.js").ParquetAdapterOptions>;
|
package/dist/parquet.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var OFFICIAL_ADAPTER=Symbol.for("tabulark.official-adapter.v2");function createOfficialAdapter(id){const marker=Object.freeze({id});return Object.freeze({id,kind:"official",[OFFICIAL_ADAPTER]:marker})}var delimitedAdapter=createOfficialAdapter("tabulark:delimited");function createParquetAdapter(){return createOfficialAdapter("tabulark:parquet")}var parquetAdapter=createParquetAdapter();export{parquetAdapter};
|
|
2
|
+
//# sourceMappingURL=parquet.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../js/adapters.ts", "../js/parquet.ts"],
|
|
4
|
+
"sourcesContent": ["import {\n isOfficialAdapterId,\n officialAdapterManifestEntry,\n type OfficialAdapterId,\n} from \"./official-adapter-manifest.js\";\n\nexport type { OfficialAdapterId } from \"./official-adapter-manifest.js\";\n\nexport type DelimitedDialect = \"csv\" | \"tsv\";\nexport type HeaderMode = \"first-row\" | \"none\";\nexport type ParseMode = \"lenient\" | \"strict\";\n\n/** Options understood by the built-in delimited adapter. */\nexport interface DelimitedAdapterOptions {\n /** Defaults to `csv`. No filename-based selection is performed. */\n readonly dialect?: DelimitedDialect;\n readonly header?: HeaderMode;\n readonly mode?: ParseMode;\n /** One ASCII delimiter byte. Overrides the dialect default when supplied. */\n readonly delimiter?: string;\n /** Optional display name for the source. */\n readonly sourceName?: string;\n}\n\nexport type ArrowIpcContainer = \"auto\" | \"file\" | \"stream\";\n\n/** Options understood by the built-in Arrow IPC adapter. */\nexport interface ArrowIpcAdapterOptions {\n /** Defaults to `auto`; format detection belongs to the Arrow adapter. */\n readonly container?: ArrowIpcContainer;\n /** Optional display name for the source. */\n readonly sourceName?: string;\n}\n\n/** Options understood by the built-in Parquet adapter. */\nexport interface ParquetAdapterOptions {\n /** Optional display name for the source. */\n readonly sourceName?: string;\n}\n\nexport type ExcelFormat = \"auto\" | \"xls\" | \"xlsx\";\n\n/** Options understood by the built-in Excel adapter. */\nexport interface ExcelAdapterOptions {\n /** Defaults to `auto`; the adapter identifies the file from its signature. */\n readonly format?: ExcelFormat;\n /** Optional display name for the source. */\n readonly sourceName?: string;\n}\n\n/**\n * A frozen descriptor for one built-in adapter.\n *\n * Descriptors select a named official artifact only. They are deliberately not\n * factories and cannot carry a module URL or a third-party implementation.\n */\nexport interface AdapterDescriptor<\n Id extends OfficialAdapterId = OfficialAdapterId,\n Options = unknown,\n> {\n readonly id: Id;\n readonly kind: \"official\";\n /** Carries the option type without exposing a runtime extension point. */\n readonly __options?: Options;\n}\n\ninterface InternalAdapterDescriptor<\n Id extends OfficialAdapterId = OfficialAdapterId,\n Options = unknown,\n> extends AdapterDescriptor<Id, Options> {\n readonly [OFFICIAL_ADAPTER]: Readonly<{ readonly id: Id }>;\n}\n\n/**\n * A process-global symbol permits descriptors from separately bundled stable\n * entrypoints to be recognized. It conveys no capability: the manifest below\n * still owns the selected module URL and resource policy.\n */\nconst OFFICIAL_ADAPTER = Symbol.for(\"tabulark.official-adapter.v2\");\n\nexport interface AdapterRegistration {\n readonly id: OfficialAdapterId;\n}\n\nfunction createOfficialAdapter<Id extends OfficialAdapterId, Options>(\n id: Id,\n): AdapterDescriptor<Id, Options> {\n const marker = Object.freeze({ id });\n return Object.freeze({\n id,\n kind: \"official\" as const,\n [OFFICIAL_ADAPTER]: marker,\n }) as InternalAdapterDescriptor<Id, Options>;\n}\n\n/** The built-in RFC-style delimited text adapter. */\nexport const delimitedAdapter = createOfficialAdapter<\n \"tabulark:delimited\",\n DelimitedAdapterOptions\n>(\"tabulark:delimited\");\n\n/** @internal Used by the stable `/arrow` entrypoint. */\nexport function createArrowIpcAdapter(): AdapterDescriptor<\"tabulark:arrow-ipc\", ArrowIpcAdapterOptions> {\n return createOfficialAdapter<\"tabulark:arrow-ipc\", ArrowIpcAdapterOptions>(\"tabulark:arrow-ipc\");\n}\n\n/** @internal Used by the stable `/parquet` entrypoint. */\nexport function createParquetAdapter(): AdapterDescriptor<\"tabulark:parquet\", ParquetAdapterOptions> {\n return createOfficialAdapter<\"tabulark:parquet\", ParquetAdapterOptions>(\"tabulark:parquet\");\n}\n\n/** @internal Used by the stable `/excel` entrypoint. */\nexport function createExcelAdapter(): AdapterDescriptor<\"tabulark:excel\", ExcelAdapterOptions> {\n return createOfficialAdapter<\"tabulark:excel\", ExcelAdapterOptions>(\"tabulark:excel\");\n}\n\n/** @internal Validates and extracts the non-public Worker registration. */\nexport function resolveOfficialAdapter(value: unknown): AdapterRegistration | undefined {\n if (!isRecord(value) || !Object.isFrozen(value) || !isOfficialAdapterId(value.id) || value.kind !== \"official\") {\n return undefined;\n }\n const marker = value[OFFICIAL_ADAPTER];\n if (!isRecord(marker) || marker.id !== value.id) {\n return undefined;\n }\n // A marker may be recreated by another bundle, but it conveys no URL or\n // implementation capability: it can select only a manifest-owned ID.\n officialAdapterManifestEntry(value.id);\n return Object.freeze({ id: value.id });\n}\n\nfunction isRecord(value: unknown): value is Record<PropertyKey, unknown> {\n return typeof value === \"object\" && value !== null;\n}\n", "export { type ParquetAdapterOptions } from \"./adapters.js\";\n\nimport { createParquetAdapter } from \"./adapters.js\";\n\n/** Opens Apache Parquet input through the lazy official Parquet WASM artifact. */\nexport const parquetAdapter = createParquetAdapter();\n"],
|
|
5
|
+
"mappings": "AA8EA,IAAM,iBAAmB,OAAO,IAAI,8BAA8B,EAMlE,SAAS,sBACP,GACgC,CAChC,MAAM,OAAS,OAAO,OAAO,CAAE,EAAG,CAAC,EACnC,OAAO,OAAO,OAAO,CACnB,GACA,KAAM,WACN,CAAC,gBAAgB,EAAG,MACtB,CAAC,CACH,CAGO,IAAM,iBAAmB,sBAG9B,oBAAoB,EAQf,SAAS,sBAAqF,CACnG,OAAO,sBAAiE,kBAAkB,CAC5F,CCxGO,IAAM,eAAiB,qBAAqB",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/** Version 4 introduces resumable, revisioned operations and main-thread batch ownership. */
|
|
2
|
+
export declare const PROTOCOL_VERSION: 4;
|
|
3
|
+
/** Version of the private, built-in Rust adapter contract. */
|
|
4
|
+
export declare const ADAPTER_API_VERSION: 3;
|
|
5
|
+
/** Version of the descriptor + deduplicated-buffer batch transport. */
|
|
6
|
+
export declare const BATCH_LAYOUT_VERSION: 1;
|
|
7
|
+
export type ProtocolVersion = typeof PROTOCOL_VERSION;
|
|
8
|
+
export type Operation = "hello" | "openSource" | "listTables" | "openTable" | "getMetadata" | "getPresentation" | "readPresentationRange" | "readRange" | "cancel" | "closeTable" | "closeSource" | "shutdown";
|
|
9
|
+
export interface ProtocolRequest<T = unknown> {
|
|
10
|
+
readonly protocolVersion: ProtocolVersion;
|
|
11
|
+
readonly requestId: string;
|
|
12
|
+
readonly op: Operation;
|
|
13
|
+
readonly payload: T;
|
|
14
|
+
}
|
|
15
|
+
export type ResponseKind = "hello" | "dataset" | "tables" | "table" | "metadata" | "presentation" | "presentationRange" | "batch" | "acknowledged";
|
|
16
|
+
export interface ProtocolResult<T = unknown> {
|
|
17
|
+
readonly kind: ResponseKind;
|
|
18
|
+
readonly data?: T;
|
|
19
|
+
}
|
|
20
|
+
export interface ProtocolSuccess<T = unknown> {
|
|
21
|
+
readonly protocolVersion: ProtocolVersion;
|
|
22
|
+
readonly requestId: string;
|
|
23
|
+
readonly status: "success";
|
|
24
|
+
readonly result: ProtocolResult<T>;
|
|
25
|
+
}
|
|
26
|
+
export interface SerializedError {
|
|
27
|
+
readonly code: string;
|
|
28
|
+
readonly message: string;
|
|
29
|
+
readonly retryable: boolean;
|
|
30
|
+
readonly details?: unknown;
|
|
31
|
+
}
|
|
32
|
+
export interface ProtocolFailure {
|
|
33
|
+
readonly protocolVersion: ProtocolVersion;
|
|
34
|
+
readonly requestId: string;
|
|
35
|
+
readonly status: "failure";
|
|
36
|
+
readonly error: SerializedError;
|
|
37
|
+
}
|
|
38
|
+
export type ProtocolResponse<T = unknown> = ProtocolSuccess<T> | ProtocolFailure;
|
|
39
|
+
export type RuntimeEventName = "progress" | "metadata" | "warning" | "closed" | "runtimeError";
|
|
40
|
+
export interface ProtocolEvent<T = unknown> {
|
|
41
|
+
readonly protocolVersion: ProtocolVersion;
|
|
42
|
+
readonly requestId?: string;
|
|
43
|
+
readonly event: RuntimeEventName;
|
|
44
|
+
/** Required for dataset/table events; omitted only by a process-wide runtimeError. */
|
|
45
|
+
readonly datasetHandle?: string;
|
|
46
|
+
readonly tableHandle?: string;
|
|
47
|
+
readonly tableId?: string;
|
|
48
|
+
/** Revision associated with a table-scoped event, when known. */
|
|
49
|
+
readonly revision?: number;
|
|
50
|
+
readonly payload: T;
|
|
51
|
+
}
|
|
52
|
+
export declare function isProtocolResponse(value: unknown): value is ProtocolResponse;
|
|
53
|
+
export declare function isProtocolEvent(value: unknown): value is ProtocolEvent;
|
|
54
|
+
export declare function isRecord(value: unknown): value is Record<string, unknown>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { RangeRequest, WireTableBatch, WireTableBatchColumn } from "./model.js";
|
|
2
|
+
export declare class PermitQueueFullError extends Error {
|
|
3
|
+
readonly maxWaiters: number;
|
|
4
|
+
constructor(maxWaiters: number);
|
|
5
|
+
}
|
|
6
|
+
/** A small FIFO permit queue whose pending acquisitions can be cancelled by key. */
|
|
7
|
+
export declare class AsyncPermitQueue {
|
|
8
|
+
#private;
|
|
9
|
+
constructor(maxActive: number, maxWaiters: number);
|
|
10
|
+
acquire(key: string): Promise<() => void>;
|
|
11
|
+
cancel(key: string, reason: unknown): boolean;
|
|
12
|
+
}
|
|
13
|
+
/** A byte-bounded least-recently-used cache. */
|
|
14
|
+
export declare class ByteLruCache<T> {
|
|
15
|
+
#private;
|
|
16
|
+
constructor(maxBytes: number, options?: Readonly<{
|
|
17
|
+
maxEntries?: number;
|
|
18
|
+
minimumEntryBytes?: number;
|
|
19
|
+
onRemove?: (key: string, value: T, byteLength: number) => void;
|
|
20
|
+
}>);
|
|
21
|
+
get maxBytes(): number;
|
|
22
|
+
get maxEntries(): number;
|
|
23
|
+
get(key: string): T | undefined;
|
|
24
|
+
set(key: string, value: T, byteLength: number, maxBytes?: number): void;
|
|
25
|
+
/** Evicts least-recently-used entries until the requested live cap is met. */
|
|
26
|
+
trimTo(maxBytes: number): void;
|
|
27
|
+
deleteWhere(predicate: (key: string, value: T) => boolean): void;
|
|
28
|
+
clear(): void;
|
|
29
|
+
}
|
|
30
|
+
export declare function rangeCacheKey(datasetHandle: string, tableId: string, revision: number, schemaVersion: number, range: RangeRequest): string;
|
|
31
|
+
export declare function rangeCacheKeyBelongsToDataset(key: string, datasetHandle: string): boolean;
|
|
32
|
+
export declare function rangeCacheKeyBelongsToTable(key: string, datasetHandle: string, tableId: string): boolean;
|
|
33
|
+
export declare function rangeCacheKeyMatchesVersion(key: string, revision: number, schemaVersion: number): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Main-thread-owned immutable backing for a logical batch.
|
|
36
|
+
*
|
|
37
|
+
* The ArrayBuffers arrive as independently transferable Worker output and are
|
|
38
|
+
* intentionally not cloned here. They remain unreachable through the public
|
|
39
|
+
* batch facade; binary getters perform their own defensive copy.
|
|
40
|
+
*/
|
|
41
|
+
export type BatchBacking = Omit<WireTableBatch, "buffers" | "columns" | "range"> & Readonly<{
|
|
42
|
+
range: Readonly<WireTableBatch["range"]>;
|
|
43
|
+
buffers: readonly ArrayBuffer[];
|
|
44
|
+
columns: readonly WireTableBatchColumn[];
|
|
45
|
+
}>;
|
|
46
|
+
export declare function createBatchBacking(batch: WireTableBatch): BatchBacking;
|
|
47
|
+
export declare function wireBatchByteLength(batch: WireTableBatch): number;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bounded, repeatable byte-range sources.
|
|
3
|
+
*
|
|
4
|
+
* A RangeSource is intentionally a very small host-side capability. The
|
|
5
|
+
* worker never receives the implementation (or a URL); it is given an opaque
|
|
6
|
+
* reader handle by the client and asks the host for bounded byte ranges.
|
|
7
|
+
*/
|
|
8
|
+
/** The largest addressable source (2^32 - 1 bytes). */
|
|
9
|
+
export declare const MAX_RANGE_SOURCE_BYTES = 4294967295;
|
|
10
|
+
/** A half-open byte interval [offset, offset + length). */
|
|
11
|
+
export interface ByteRange {
|
|
12
|
+
readonly offset: number;
|
|
13
|
+
readonly length: number;
|
|
14
|
+
}
|
|
15
|
+
/** A stable identity for one opened view of a source. */
|
|
16
|
+
export interface RangeSourceSnapshot {
|
|
17
|
+
readonly id: string;
|
|
18
|
+
readonly strength: "strong" | "weak";
|
|
19
|
+
}
|
|
20
|
+
/** Options supplied to every reader operation. */
|
|
21
|
+
export interface RangeSourceReadOptions {
|
|
22
|
+
readonly signal: AbortSignal;
|
|
23
|
+
}
|
|
24
|
+
/** A reader returned by a RangeSource.open() call. */
|
|
25
|
+
export interface RangeSourceReader {
|
|
26
|
+
/** Exact source size in bytes. */
|
|
27
|
+
readonly size: number;
|
|
28
|
+
/** Validator captured while opening the source. */
|
|
29
|
+
readonly snapshot: RangeSourceSnapshot;
|
|
30
|
+
/** Maximum number of provider reads that may run concurrently. Defaults to 1. */
|
|
31
|
+
readonly maxConcurrency?: number;
|
|
32
|
+
/** Reads exactly range.length bytes, or rejects. */
|
|
33
|
+
read(range: ByteRange, options: RangeSourceReadOptions): Promise<ArrayBuffer | ArrayBufferView>;
|
|
34
|
+
/** Releases all resources. Calling close more than once is harmless. */
|
|
35
|
+
close(): Promise<void> | void;
|
|
36
|
+
}
|
|
37
|
+
/** Open-time limits owned by the engine. */
|
|
38
|
+
export interface RangeSourceOpenOptions {
|
|
39
|
+
readonly signal: AbortSignal;
|
|
40
|
+
readonly maxSourceBytes: number;
|
|
41
|
+
readonly maxStagingBytes: number;
|
|
42
|
+
}
|
|
43
|
+
/** A repeatably openable source addressed by bounded byte ranges. */
|
|
44
|
+
export interface RangeSource {
|
|
45
|
+
readonly kind: "range";
|
|
46
|
+
readonly name?: string;
|
|
47
|
+
open(options: RangeSourceOpenOptions): Promise<RangeSourceReader>;
|
|
48
|
+
}
|
|
49
|
+
/** Runtime check used at the public engine boundary. */
|
|
50
|
+
export declare function isRangeSource(value: unknown): value is RangeSource;
|
|
51
|
+
/**
|
|
52
|
+
* Validates a byte range without coercing values. Keeping this check in one
|
|
53
|
+
* place prevents unsafe floating-point arithmetic at both HTTP and Worker
|
|
54
|
+
* boundaries.
|
|
55
|
+
*/
|
|
56
|
+
export declare function validateByteRange(range: unknown, size: number): asserts range is ByteRange;
|
|
57
|
+
/** Validates and freezes a reader snapshot. */
|
|
58
|
+
export declare function normalizeRangeSourceSnapshot(value: unknown): RangeSourceSnapshot;
|
|
59
|
+
/** Validates a reader object returned by an adapter/broker. */
|
|
60
|
+
export declare function validateRangeSourceReader(value: unknown): value is RangeSourceReader;
|
|
61
|
+
/** Converts an ArrayBuffer or view to a fresh, exact-length ArrayBuffer. */
|
|
62
|
+
export declare function copyRangeBytes(value: ArrayBuffer | ArrayBufferView): ArrayBuffer;
|
|
63
|
+
/** Returns whether a value is a safe non-negative integer. */
|
|
64
|
+
export declare function isSafeNonNegativeInteger(value: unknown): value is number;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { TabularkError } from "./errors.js";
|
|
2
|
+
import { type Operation, type ProtocolEvent, type ResponseKind } from "./protocol.js";
|
|
3
|
+
type EventListener = (event: ProtocolEvent) => void;
|
|
4
|
+
type FailureListener = (error: TabularkError) => void;
|
|
5
|
+
/** Private messages exchanged by the Worker source-byte broker. */
|
|
6
|
+
export type SourceBrokerListener = (value: unknown) => void;
|
|
7
|
+
interface RequestOptions {
|
|
8
|
+
readonly transfer?: Transferable[];
|
|
9
|
+
readonly signal?: AbortSignal;
|
|
10
|
+
readonly timeoutMs?: number;
|
|
11
|
+
/** Private opt-in operation telemetry callback. */
|
|
12
|
+
readonly measure?: boolean;
|
|
13
|
+
readonly onTelemetry?: (telemetry: OperationTelemetry | undefined) => void;
|
|
14
|
+
}
|
|
15
|
+
export interface OperationTelemetry {
|
|
16
|
+
readonly bytesRead: number;
|
|
17
|
+
readonly peakReservationBytes: number;
|
|
18
|
+
readonly sourceReads: number;
|
|
19
|
+
readonly sourceCacheHitBytes: number;
|
|
20
|
+
}
|
|
21
|
+
/** Main-thread request multiplexer for one dedicated Worker. */
|
|
22
|
+
export declare class WorkerRpcClient {
|
|
23
|
+
#private;
|
|
24
|
+
constructor(worker: Worker, onEvent: EventListener, onFailure?: FailureListener, onSourceMessage?: SourceBrokerListener);
|
|
25
|
+
/** Sends one private broker response without exposing the Worker object. */
|
|
26
|
+
postMessage(value: unknown, transfer?: Transferable[]): void;
|
|
27
|
+
request<T>(op: Operation, payload: unknown, expectedKind: ResponseKind, options?: RequestOptions): Promise<T>;
|
|
28
|
+
shutdown(timeoutMs?: number, options?: Pick<RequestOptions, "measure" | "onTelemetry">): Promise<void>;
|
|
29
|
+
terminate(error?: TabularkError, notifyFailure?: boolean): void;
|
|
30
|
+
}
|
|
31
|
+
export {};
|
package/dist/source.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Host-side source policy shared by the stable client and its Worker.
|
|
3
|
+
*
|
|
4
|
+
* This is deliberately a binary constant (rather than a decimal "2G" value):
|
|
5
|
+
* the large-source contract is exactly 2 * 1024^3 bytes. Keeping the value
|
|
6
|
+
* in one module prevents the client and Worker from drifting at the boundary.
|
|
7
|
+
*/
|
|
8
|
+
export declare const MAX_LARGE_SOURCE_BYTES: number;
|
|
9
|
+
export { MAX_RANGE_SOURCE_BYTES, isRangeSource, validateByteRange, validateRangeSourceReader, copyRangeBytes, } from "./range-source.js";
|
|
10
|
+
export type { ByteRange, RangeSource, RangeSourceOpenOptions, RangeSourceReader, RangeSourceReadOptions, RangeSourceSnapshot, } from "./range-source.js";
|
|
11
|
+
/** Selects the bounded default path or the large local-Blob path. */
|
|
12
|
+
export type SourceMode = "auto" | "large";
|
|
13
|
+
export declare function isSourceMode(value: unknown): value is SourceMode;
|