tabulark 0.1.0 → 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.
Files changed (45) hide show
  1. package/CHANGELOG.md +67 -2
  2. package/README.md +125 -42
  3. package/dist/client.d.ts +71 -2
  4. package/dist/errors.d.ts +7 -1
  5. package/dist/experimental.js +1 -1
  6. package/dist/experimental.js.map +2 -2
  7. package/dist/http.d.ts +65 -0
  8. package/dist/http.js +2 -0
  9. package/dist/http.js.map +7 -0
  10. package/dist/index.d.ts +2 -1
  11. package/dist/index.js +2 -1
  12. package/dist/index.js.map +4 -4
  13. package/dist/model.d.ts +6 -3
  14. package/dist/protocol.d.ts +3 -3
  15. package/dist/range-cache.d.ts +24 -5
  16. package/dist/range-source.d.ts +64 -0
  17. package/dist/rpc-client.d.ts +15 -2
  18. package/dist/source.d.ts +13 -0
  19. package/dist/view/canvas-table-view-public.d.ts +6 -0
  20. package/dist/view/canvas-table-view.d.ts +8 -0
  21. package/dist/wasm/arrow/tabulark_arrow.d.ts +33 -6
  22. package/dist/wasm/arrow/tabulark_arrow.js +129 -17
  23. package/dist/wasm/arrow/tabulark_arrow_bg.wasm +0 -0
  24. package/dist/wasm/arrow/tabulark_arrow_bg.wasm.d.ts +6 -1
  25. package/dist/wasm/delimited/tabulark_delimited.d.ts +31 -5
  26. package/dist/wasm/delimited/tabulark_delimited.js +115 -8
  27. package/dist/wasm/delimited/tabulark_delimited_bg.wasm +0 -0
  28. package/dist/wasm/delimited/tabulark_delimited_bg.wasm.d.ts +6 -1
  29. package/dist/wasm/excel/tabulark_excel.d.ts +33 -8
  30. package/dist/wasm/excel/tabulark_excel.js +129 -19
  31. package/dist/wasm/excel/tabulark_excel_bg.wasm +0 -0
  32. package/dist/wasm/excel/tabulark_excel_bg.wasm.d.ts +6 -1
  33. package/dist/wasm/parquet/tabulark_parquet.d.ts +31 -6
  34. package/dist/wasm/parquet/tabulark_parquet.js +135 -17
  35. package/dist/wasm/parquet/tabulark_parquet_bg.wasm +0 -0
  36. package/dist/wasm/parquet/tabulark_parquet_bg.wasm.d.ts +6 -1
  37. package/dist/worker/blob-source-accessor.d.ts +10 -0
  38. package/dist/worker/source-accessor.d.ts +76 -0
  39. package/dist/worker/wasm-adapter.d.ts +39 -38
  40. package/dist/worker-range-source.d.ts +1 -0
  41. package/dist/worker-range-source.js +2 -0
  42. package/dist/worker-range-source.js.map +7 -0
  43. package/dist/worker.js +1 -1
  44. package/dist/worker.js.map +4 -4
  45. package/package.json +8 -1
package/CHANGELOG.md CHANGED
@@ -1,8 +1,73 @@
1
1
  # Changelog
2
2
 
3
3
  All notable changes to Tabulark are documented here. The project follows
4
- [Semantic Versioning](https://semver.org/); public JavaScript entry points are
5
- additive-only throughout the 0.1.x line.
4
+ [Semantic Versioning](https://semver.org/).
5
+
6
+ ## 0.2.1
7
+
8
+ - Read partial viewports from oversized Parquet row groups page by page instead
9
+ of staging every projected column chunk. Lazy reads enforce cumulative page
10
+ decompression, bounded page tracking and header parsing, compressed-cache
11
+ peak, and decoder-restart limits before returning data to parquet-rs.
12
+ - Bound nested Arrow display previews without changing their native values;
13
+ oversized list, struct, map, and union text ends with an explicit
14
+ `... [truncated]` marker.
15
+ - Add a separately built, experimental document-preview source package with a
16
+ Worker-isolated PDFium page pipeline, bounded RGBA page rendering, and an
17
+ accessible framework-free paged view. It is not part of the stable root npm
18
+ exports or official tabular-adapter manifest.
19
+
20
+ ## 0.2.0
21
+
22
+ - Add bounded structured diagnostics and independent diagnostic subscriptions.
23
+ - Add logical dataset/table capability snapshots and opt-in privacy-safe
24
+ performance samples.
25
+ - Add Canvas `colorScheme` support with dynamic dark mode and forced-colors
26
+ precedence.
27
+ - Add opt-in `sourceMode: "large"` for local Blob/File inputs through exactly
28
+ `2^31` bytes across CSV, Arrow File, Parquet, XLSX, and XLS; ArrayBuffer and
29
+ automatic-mode limits remain unchanged.
30
+ - Add the stable `RangeSource` capability to every official format. Readers
31
+ validate exact lengths and snapshots, support independent reopen/close
32
+ lifecycles, and address at most `4,294,967,295` bytes (`2^32 - 1`).
33
+ - Add `tabulark/http` with a `GET Range: bytes=0-0` capability probe, strict
34
+ `Content-Range` and validator checks, bounded transient retries, dynamic
35
+ headers/credentials, and an explicit bounded-download fallback. Network and
36
+ authentication remain on the main thread; no URL, headers, validator, or
37
+ snapshot ID is exposed in Worker messages, errors, or performance samples.
38
+ - Add source-range request coalescing, dataset singleflight, a byte-budgeted
39
+ range LRU, four-way maximum provider concurrency, exact reader cleanup, and
40
+ cross-thread memory slices (75% Worker, 12.5% source staging, 12.5%
41
+ retained batches/fallback).
42
+ - Add `SOURCE_UNAVAILABLE`, `SOURCE_CHANGED`, and `RANGE_UNSUPPORTED` source
43
+ errors. Extend `PerformanceSample` with `sourceReads` and
44
+ `sourceCacheHitBytes`; `cacheHit` remains the logical batch-cache metric.
45
+ - Move every official adapter to private Worker protocol v4 and adapter ABI v3
46
+ resumable operations with checked revisions, bounded multi-range actions,
47
+ cooperative no-I/O yields, and one-transfer batch output.
48
+ - Make the main thread the sole decoded-batch cache owner, with immutable
49
+ backings, logical-table keys, singleflight misses, and independent caller
50
+ cancellation. Remove the Worker decoded LRU.
51
+ - Add Rust/WASM resource ledgers and native cache admission/reclamation
52
+ evidence, including 100-cycle lifecycle and WebAssembly-memory high-water
53
+ gates.
54
+ - Add incremental Arrow File/Stream indexing, coalesced Parquet projection
55
+ reads, and Rust range-backed ZIP64/CFB Excel container indexing. Excel
56
+ compacts only required workbook content into its bounded compatibility
57
+ parser.
58
+ - Add release-blocking Chromium, Firefox, and WebKit functional projects.
59
+ Chromium additionally owns pixel, performance, real-clipboard, and exact
60
+ 2 GiB evidence.
61
+ - Add paired baseline performance gates, shipped-JavaScript shrinkage gates,
62
+ and a native five-container exact-size generator/workflow.
63
+ - Add HTTP contract, virtual/sparse 4 GiB−1, cancellation/lifecycle,
64
+ concurrency, cache, CORS, retry, validator-change, and explicit-fallback
65
+ release evidence in Chromium, Firefox, and WebKit. Keep a separate measured
66
+ raw/Brotli size budget for the new `/http` entry point.
67
+ - Remove the private TypeScript large-XLSX parser and its shipped artifact.
68
+
69
+ Version 0.1.1 was never tagged or published; its compatible work is included
70
+ in 0.2.0. The immutable `v0.1.0` tag is unchanged.
6
71
 
7
72
  ## 0.1.0
8
73
 
package/README.md CHANGED
@@ -1,40 +1,47 @@
1
1
  # Tabulark
2
2
 
3
- > **Status: M4 complete; 0.1.0 release candidate in progress.** The M4
4
- > CSV/TSV and Apache Arrow IPC milestone completed at `1d79837`, including CI,
5
- > GitHub Pages, and a deployed-URL smoke. The package has not yet been published
6
- > as 0.1.0; see the [M4 completion record](docs/m4-completion.md) and the
7
- > [release policy](docs/releasing.md).
8
-
9
- Tabulark is a WebAssembly-first browser primitive for previewing local tabular
10
- data without uploading it. A module Worker owns parsing, bounded byte access,
11
- adapter state, cancellation, and cleanup. A Canvas viewport renders visible
12
- cells while a bounded semantic grid supplies keyboard and screen-reader access.
3
+ > **Status: 0.2.1.** The immutable `v0.1.0` tag and its registry/Pages
4
+ > evidence remain recorded in
5
+ > [the release evidence](docs/release-0.1.0-evidence.md); that tag is never
6
+ > moved or reused. Version 0.2 adds bounded local and remote range sources,
7
+ > structured diagnostics and capabilities, performance observation, and
8
+ > synchronized Canvas themes without changing the documented 0.1.0 calling
9
+ > patterns. Local `sourceMode: "large"` remains capped at 2 GiB; a validated
10
+ > `RangeSource` may address at most `4,294,967,295` bytes (`2^32 - 1`).
11
+
12
+ Tabulark is a WebAssembly-first browser primitive for previewing tabular data
13
+ without uploading it. Local bytes stay local; an explicit `RangeSource` can
14
+ read a remote object through a main-thread broker without giving its URL,
15
+ credentials, or headers to the Worker. A module Worker owns parsing, bounded
16
+ byte access, adapter state, cancellation, and cleanup. A Canvas viewport
17
+ renders visible cells while a bounded semantic grid supplies keyboard and
18
+ screen-reader access.
13
19
 
14
20
  [Try the playground](https://ronbb.github.io/tabulark/) · [Architecture](docs/architecture.md) · [API stability](docs/api-stability.md) · [Testing](docs/testing.md)
15
21
 
16
22
  ## Supported local formats
17
23
 
18
- The 0.1.0 source tree contains four immutable official adapters. Each adapter
24
+ The 0.2.1 source tree contains four official adapters. Each adapter
19
25
  is a separate, lazily loaded WebAssembly artifact; creating an engine loads no
20
26
  WASM and opening one format does not fetch unused artifacts.
21
27
 
22
- | Format | Official ID | Stable entry point | 0.1 contract |
28
+ | Format | Official ID | Stable entry point | 0.2 contract |
23
29
  | --- | --- | --- | --- |
24
30
  | CSV/TSV | `tabulark:delimited` | `tabulark` | Explicit delimiter, header, and strict/lenient modes |
25
31
  | Arrow IPC | `tabulark:arrow-ipc` | `tabulark/arrow` | File/Stream; none, LZ4, and Zstd IPC compression |
26
32
  | Parquet | `tabulark:parquet` | `tabulark/parquet` | Range-driven row-group/column projection and the documented codec set |
27
33
  | Excel | `tabulark:excel` | `tabulark/excel` | Excel 97–2003 BIFF8 XLS and OOXML XLSX, including static presentation |
28
34
 
29
- Remote sources, arbitrary adapter/module URLs, public third-party adapters,
30
- persistent caches, formula calculation, editing, and document-level Excel
31
- round-tripping are outside 0.1.
35
+ Arbitrary adapter/module URLs, public third-party adapters, persistent caches,
36
+ ReadableStream sources, formula calculation, editing, and document-level Excel
37
+ round-tripping are outside 0.2. Remote input is available only through the
38
+ explicit `RangeSource` contract (or the opt-in `tabulark/http` helper).
32
39
 
33
40
  ## Install and build
34
41
 
35
- The npm package has no production JavaScript dependencies. It targets modern
36
- Chromium and requires Node 20 or newer to build from source. Rust 1.85 is the
37
- minimum supported Rust version.
42
+ The npm package has no production JavaScript dependencies. Its desktop release
43
+ gate covers Chromium, Firefox, and WebKit, and it requires Node 20 or newer to
44
+ build from source. Rust 1.85 is the minimum supported Rust version.
38
45
 
39
46
  ```sh
40
47
  npm ci
@@ -43,21 +50,23 @@ npm run check
43
50
  npm run test:browser
44
51
  ```
45
52
 
46
- `npm run build` creates five public JavaScript entry points, a generic Worker,
53
+ `npm run build` creates six public JavaScript entry points, a generic Worker,
47
54
  and independent Delimited, Arrow, Parquet, and Excel WASM artifacts under
48
55
  `dist/wasm/`.
49
56
 
50
57
  ## Stable JavaScript API
51
58
 
52
59
  Register only the adapters an engine may use. The allow-list is immutable for
53
- that engine's lifetime, and the only accepted source inputs are `File`, `Blob`,
54
- and `ArrayBuffer`.
60
+ that engine's lifetime. Local inputs are `File`, `Blob`, and `ArrayBuffer`; an
61
+ explicit `RangeSource` is the bounded remote (or application-owned) source
62
+ capability.
55
63
 
56
64
  ```ts
57
65
  import { createEngine, delimitedAdapter } from "tabulark";
58
66
  import { arrowIpcAdapter } from "tabulark/arrow";
59
67
  import { parquetAdapter } from "tabulark/parquet";
60
68
  import { excelAdapter } from "tabulark/excel";
69
+ import { httpRangeSource } from "tabulark/http";
61
70
 
62
71
  const engine = await createEngine({
63
72
  adapters: [delimitedAdapter, arrowIpcAdapter, parquetAdapter, excelAdapter],
@@ -65,6 +74,7 @@ const engine = await createEngine({
65
74
 
66
75
  const csv = await engine.open(csvFile, {
67
76
  adapter: delimitedAdapter,
77
+ sourceMode: "auto", // use "large" for a local File/Blob up to 2 GiB
68
78
  adapterOptions: {
69
79
  dialect: "csv",
70
80
  header: "first-row",
@@ -81,16 +91,65 @@ const workbook = await engine.open(excelFile, {
81
91
  adapter: excelAdapter,
82
92
  adapterOptions: { format: "auto", sourceName: excelFile.name },
83
93
  });
94
+
95
+ const remote = httpRangeSource("https://data.example.test/table.parquet", {
96
+ credentials: "include",
97
+ validation: "strong", // ETag, or Last-Modified + length when permitted
98
+ maxConcurrency: 2,
99
+ });
100
+ const remoteTable = await engine.open(remote, {
101
+ adapter: parquetAdapter,
102
+ });
84
103
  ```
85
104
 
86
- Adapter selection is explicit. Excel's `format: "auto"` and Arrow's
105
+ In the stable API, adapter selection is explicit. Excel's `format: "auto"` and Arrow's
87
106
  `container: "auto"` inspect source bytes; filename extensions never select or
88
107
  authenticate a format.
89
108
 
109
+ The bundled playground is a convenience layer: it uses the local file name,
110
+ MIME type, and (when needed) a bounded signature read to choose the explicit
111
+ adapter call for you. Applications using the stable API should continue to
112
+ select and register an adapter themselves.
113
+
90
114
  `ArrayBuffer` ownership is retained by default. Set `transferInput: true` only
91
115
  when intentionally detaching an `ArrayBuffer`; using it with a `Blob` or
92
116
  `File` returns `INVALID_ARGUMENT`.
93
117
 
118
+ `sourceMode: "auto"` keeps the conservative source policy. The opt-in
119
+ `sourceMode: "large"` path accepts only a local `File`/`Blob` no larger than
120
+ exactly `2,147,483,648` bytes (`2^31`, 2 GiB); it does not raise the existing
121
+ `ArrayBuffer` staging limit or allocate a work set proportional to the file. A
122
+ larger source fails before an open request is sent to the Worker, with
123
+ `RESOURCE_LIMIT` details containing `resource`, `requiredBytes`, and
124
+ `availableBytes`.
125
+
126
+ `RangeSource` readers report an exact size and snapshot validator and return
127
+ exactly the requested bytes. `TabularkEngine.open()` creates an independent
128
+ reader for each open and closes it exactly once on failure, cancellation, or
129
+ dataset/engine close. `sourceMode` and `transferInput` are rejected for a
130
+ `RangeSource`. The source ceiling is exactly `4,294,967,295` bytes; a 4 GiB
131
+ source is rejected before adapter startup. The Worker receives only an opaque
132
+ source handle, size, and bounded transferable byte buffers. Provider requests
133
+ are merged for overlap/adjacency, limited to four concurrent reads, and
134
+ covered by a dataset range-cache/singleflight layer.
135
+
136
+ The `tabulark/http` helper probes with `GET Range: bytes=0-0`, requires a
137
+ precise `Content-Range` and a trusted ETag (or an explicitly allowed weak
138
+ Last-Modified-plus-length validator), and revalidates every `206` response.
139
+ Retries are bounded and limited to transient network/status failures. A full
140
+ download is never implicit: `fallback: { mode: "bounded-download", maxBytes }`
141
+ must be supplied and must fit both that bound and the engine staging budget.
142
+ Error messages and performance samples omit URLs, query strings, headers,
143
+ validators, and snapshot identifiers.
144
+
145
+ The exact-boundary local-file release gate covers five real containers: CSV,
146
+ Arrow File, Parquet, XLSX, and XLS. Each fixture is exactly `2^31` bytes and
147
+ the test reads the final bounded window ending at byte `2^31 - 1`. Remote
148
+ RangeSource gates separately use a virtual/sparse source at
149
+ `4,294,967,295` bytes and exercise non-adjacent offsets above `2^31` without
150
+ allocating oversized browser fixtures. Overflow and 4 GiB rejection are
151
+ checked before adapter startup.
152
+
94
153
  ### Tables, logical batches, and presentation
95
154
 
96
155
  ```ts
@@ -175,14 +234,30 @@ XLS support is deliberately limited to BIFF8. Earlier BIFF, XLSM, XLSB, ODS,
175
234
  and encrypted workbooks return `UNSUPPORTED_FEATURE`. XLS and XLSX share the
176
235
  same bounded static-presentation subset.
177
236
 
178
- ## Memory and lifecycle
179
-
180
- One engine-wide reservation ledger accounts for adapter runtimes, source
181
- staging, compressed/decompressed pages, opened worksheets, batches, and caches.
182
- `RESOURCE_LIMIT` errors identify the resource category and the required and
183
- available amounts. Excel stages one bounded workbook; Parquet performs bounded
184
- range reads. ZIP/CFB entry counts, decompressed bytes, worksheet dimensions,
185
- cells, styles, layout entries, and merged regions are capped before allocation.
237
+ For large XLSX, Rust indexes ZIP/ZIP64 metadata and fetches the workbook,
238
+ relationships, shared resources, and selected worksheet ranges. For large XLS,
239
+ Rust indexes CFB/DIFAT/FAT/miniFAT/directory data and fetches the referenced
240
+ Workbook/Book stream ranges. In both cases it compacts only the needed content
241
+ into a bounded workbook for the existing Calamine compatibility parser. This
242
+ does not imply a custom XML/BIFF checkpoint engine or worksheet tile store.
243
+
244
+ ## Memory, cache, and lifecycle
245
+
246
+ The main thread owns the only decoded-batch cache. It stores immutable backing
247
+ objects keyed by dataset, logical table, revision, schema version, and
248
+ normalized range; each API call receives a fresh logical facade. Concurrent
249
+ identical misses are singleflight operations. Cancelling one caller does not
250
+ cancel work shared by others, while cancelling every waiter sends one Worker
251
+ cancel. A table handle may close without discarding its logical-table backing;
252
+ dataset close or a revision/schema change evicts it.
253
+
254
+ The Worker coordinates the engine-wide quota across adapters. Inside each
255
+ Rust/WASM runtime, a checked ledger distinguishes persistent state, active
256
+ operations, ingress/output, reclaimable native cache, and caller-owned
257
+ telemetry. Admission clears soft native cache and retries once before returning
258
+ `RESOURCE_LIMIT`, whose details identify required and available capacity.
259
+ ZIP/CFB entries, decompression, worksheet dimensions, cells, styles, layout,
260
+ merged regions, Parquet pages, and decoded batches remain bounded.
186
261
 
187
262
  Handles are nested and cleanup cascades downward:
188
263
 
@@ -215,7 +290,7 @@ cargo test --workspace --all-features --locked
215
290
  # Stable exports/declarations, clean package consumers, and Pages assembly
216
291
  npm run check
217
292
 
218
- # Real module Worker/WASM, Canvas, ARIA, keyboard, copy, forced-colors, visuals
293
+ # Real module Worker/WASM, Canvas, ARIA, keyboard, copy, and forced-colors
219
294
  npm run test:browser
220
295
 
221
296
  # Independent core, Arrow, Parquet, Excel, npm, and Pages delivery budgets
@@ -225,20 +300,27 @@ npm run benchmark:size
225
300
  npm run benchmark:formats
226
301
  ```
227
302
 
228
- Chromium is the sole formal 0.1.0 browser gate. CI records its exact version.
229
- The Pages post-deploy smoke opens CSV, Arrow IPC, Parquet, XLS, and XLSX and
230
- asserts that only used adapter artifacts were requested.
303
+ Chromium, Firefox, and WebKit are all release-blocking desktop functional gates.
304
+ Chromium additionally owns exact pixel snapshots, performance comparison, real
305
+ Clipboard API coverage, and the exact-2-GiB workflow. Firefox and WebKit cover
306
+ the four adapters, lifecycle, Blob ranges, themes, ARIA, input behavior, copy
307
+ through a deterministic clipboard seam, and Pages smoke. The Pages post-deploy
308
+ smoke opens CSV, Arrow IPC, Parquet, XLS, and XLSX and asserts that only used
309
+ adapter artifacts were requested.
231
310
 
232
311
  ## Stability and release
233
312
 
234
- The root, `/arrow`, `/parquet`, and `/excel` entry points are stable for 0.1.x:
235
- compatible additions are allowed, but removals and breaking changes wait for
236
- 0.2.0. Rust APIs, the Worker protocol, adapter ABI, wire DTOs, and
313
+ The root, `/arrow`, `/parquet`, `/excel`, and `/http` entry points are stable
314
+ for 0.2.x. (`/experimental` remains explicitly unstable.)
315
+ Version 0.2 preserves the documented 0.1.0 calls and adds diagnostics,
316
+ capability queries, performance observation, `SourceMode`, and Canvas themes.
317
+ Rust APIs, Worker protocol v4, adapter ABI v3, wire DTOs, batch layout v1, and
237
318
  `/experimental` remain experimental/private.
238
319
 
239
- No `v0.1.0` tag is created until every release gate and registry/OIDC
240
- precondition passes. npm and crates.io publishing is serialized behind protected
241
- GitHub Environments with required reviewer approval. See
320
+ The `v0.1.0` tag is immutable and must never be moved or reused. npm and
321
+ crates.io publishing is serialized behind protected GitHub Environments with
322
+ required reviewer approval; recovery finalizes artifacts without republishing.
323
+ See
242
324
  [docs/releasing.md](docs/releasing.md) for the immutable-release and patch
243
325
  recovery policy.
244
326
 
@@ -247,10 +329,11 @@ recovery policy.
247
329
  ```text
248
330
  src/ shared Rust model, protocol, and native adapters
249
331
  crates/tabulark-*-wasm/ four independently built WASM entry crates
250
- js/ stable API, private Worker host, batches, and view
332
+ js/ stable API, HTTP/range broker, private Worker host,
333
+ batches, and view
251
334
  examples/csv-preview/ static six-format Playground
252
335
  test/fixtures/ pinned format fixtures and provenance
253
- test/browser/ Chromium, accessibility, visual, and Pages smoke
336
+ test/browser/ three-browser behavior, Chromium visual/performance, and Pages smoke
254
337
  test/performance/ performance and per-artifact delivery budgets
255
338
  docs/ architecture, testing, stability, and release policy
256
339
  ```
package/dist/client.d.ts CHANGED
@@ -1,10 +1,23 @@
1
1
  import { TabularkError } from "./errors.js";
2
2
  import { type AdapterDescriptor, type OfficialAdapterId } from "./adapters.js";
3
- import { type RangeRequest, type PresentationRange, type TablePresentation, type TableBatch, type TableDescriptor, type TableMetadata } from "./model.js";
3
+ import { type RangeRequest, type PresentationRange, type TablePresentation, type TableBatch, type TableCapabilities, type TableDescriptor, type TableMetadata } from "./model.js";
4
+ import { type OfficialSourceAccess } from "./official-adapter-manifest.js";
5
+ import { type SourceMode } from "./source.js";
6
+ import { type RangeSource } from "./range-source.js";
7
+ export type { SourceMode } from "./source.js";
8
+ export type { ByteRange, RangeSource, RangeSourceReader, RangeSourceSnapshot, } from "./range-source.js";
4
9
  export interface OpenSourceOptions<Options = unknown> {
5
10
  /** One of the official descriptors registered when the engine was created. */
6
11
  readonly adapter: AdapterDescriptor<OfficialAdapterId, Options>;
7
12
  readonly adapterOptions?: Options;
13
+ /**
14
+ * Selects the bounded default source path or the local Blob path that may
15
+ * address files up to 2 GiB. Defaults to `auto`.
16
+ *
17
+ * Large mode is reserved for local `File`/`Blob` inputs and never changes
18
+ * ArrayBuffer staging limits.
19
+ */
20
+ readonly sourceMode?: SourceMode;
8
21
  /** Detaches an ArrayBuffer input. Defaults to false; Blob input cannot be transferred. */
9
22
  readonly transferInput?: boolean;
10
23
  /** Cancels opening and releases any Worker-side source created by the request. */
@@ -31,8 +44,57 @@ export interface SourceWarning {
31
44
  readonly handle: string;
32
45
  readonly kind: string;
33
46
  readonly message: string;
47
+ readonly tableId?: string;
48
+ readonly resource?: string;
49
+ readonly requiredBytes?: number;
50
+ readonly availableBytes?: number;
34
51
  readonly byteOffset?: number;
52
+ /** Compatible alias used by structured diagnostics. */
53
+ readonly sourceOffset?: number;
54
+ readonly row?: number;
55
+ readonly column?: number;
56
+ }
57
+ /** A safe, structured source or runtime diagnostic. */
58
+ export interface TabularkDiagnostic {
59
+ readonly code: string;
60
+ readonly severity: "warning" | "error";
61
+ readonly message: string;
62
+ readonly recoverable: boolean;
63
+ readonly resource?: string;
64
+ readonly requiredBytes?: number;
65
+ readonly availableBytes?: number;
66
+ readonly sourceOffset?: number;
67
+ readonly tableId?: string;
68
+ readonly revision?: number;
35
69
  readonly row?: number;
70
+ readonly column?: number;
71
+ }
72
+ /** Logical capabilities of an opened dataset. */
73
+ export interface DatasetCapabilities {
74
+ readonly adapterId: OfficialAdapterId;
75
+ readonly sourceAccess: OfficialSourceAccess;
76
+ readonly progressive: boolean;
77
+ readonly maxSourceBytes: number;
78
+ readonly multiTable: boolean;
79
+ readonly presentation: boolean;
80
+ readonly typedValues: boolean;
81
+ }
82
+ /** Optional, privacy-preserving operation timing sample. */
83
+ export interface PerformanceSample {
84
+ /** Logical operation stage; implementation and transport names are omitted. */
85
+ readonly stage: string;
86
+ /** Elapsed duration relative to the operation start, in milliseconds. */
87
+ readonly durationMs: number;
88
+ /** Bytes read from the source during this stage, when known. */
89
+ readonly bytesRead: number;
90
+ /** Whether the result came from a retained range cache. */
91
+ readonly cacheHit: boolean;
92
+ /** Peak reservation observed by the host, when known. */
93
+ readonly peakReservationBytes: number;
94
+ /** Number of provider range reads represented by this operation. */
95
+ readonly sourceReads: number;
96
+ /** Bytes served from the Worker source-range cache. */
97
+ readonly sourceCacheHitBytes: number;
36
98
  }
37
99
  export type DatasetEvent = Readonly<{
38
100
  type: "progress";
@@ -57,6 +119,9 @@ export interface DatasetSession {
57
119
  readonly tables: readonly Readonly<TableDescriptor>[];
58
120
  openTable(tableId: string): Promise<TableHandle>;
59
121
  subscribe(listener: (event: DatasetEvent) => void): Unsubscribe;
122
+ getDiagnostics(): readonly TabularkDiagnostic[];
123
+ subscribeDiagnostics(listener: (diagnostic: TabularkDiagnostic) => void): Unsubscribe;
124
+ getCapabilities(): Readonly<DatasetCapabilities>;
60
125
  close(): Promise<void>;
61
126
  }
62
127
  export interface TableHandle {
@@ -65,10 +130,14 @@ export interface TableHandle {
65
130
  readPresentationRange(request: RangeRequest, options?: ReadRangeOptions): Promise<PresentationRange | null>;
66
131
  readRange(request: RangeRequest, options?: ReadRangeOptions): Promise<TableBatch>;
67
132
  subscribe(listener: (event: TableEvent) => void): Unsubscribe;
133
+ getDiagnostics(): readonly TabularkDiagnostic[];
134
+ subscribeDiagnostics(listener: (diagnostic: TabularkDiagnostic) => void): Unsubscribe;
135
+ getCapabilities(): Readonly<TableCapabilities>;
68
136
  close(): Promise<void>;
69
137
  }
70
138
  export interface TabularkEngine {
71
- open<Options>(source: Blob | ArrayBuffer, options: OpenSourceOptions<Options>): Promise<DatasetSession>;
139
+ open<Options>(source: Blob | ArrayBuffer | RangeSource, options: OpenSourceOptions<Options>): Promise<DatasetSession>;
140
+ subscribePerformance(listener: (sample: PerformanceSample) => void): Unsubscribe;
72
141
  close(): Promise<void>;
73
142
  dispose(): Promise<void>;
74
143
  }
package/dist/errors.d.ts CHANGED
@@ -1,5 +1,11 @@
1
1
  import type { SerializedError } from "./protocol.js";
2
- export type TabularkErrorCode = "INVALID_ARGUMENT" | "INVALID_RANGE" | "RANGE_NOT_INDEXED" | "RESOURCE_LIMIT" | "CANCELLED" | "HANDLE_CLOSED" | "PROTOCOL_INCOMPATIBLE" | "PARSE_FAILED" | "UNSUPPORTED_FEATURE" | "UNSUPPORTED_RUNTIME" | "RUNTIME_FAILURE" | (string & {});
2
+ export type TabularkErrorCode = "INVALID_ARGUMENT" | "INVALID_RANGE" | "RANGE_NOT_INDEXED" | "RESOURCE_LIMIT" | "CANCELLED" | "HANDLE_CLOSED" | "PROTOCOL_INCOMPATIBLE" | "PARSE_FAILED" | "UNSUPPORTED_FEATURE" | "UNSUPPORTED_RUNTIME" | "RUNTIME_FAILURE"
3
+ /** A remote/source provider could not be reached or did not return bytes. */
4
+ | "SOURCE_UNAVAILABLE"
5
+ /** The provider validator or total length changed while a reader was open. */
6
+ | "SOURCE_CHANGED"
7
+ /** The provider did not honor the required single-range protocol. */
8
+ | "RANGE_UNSUPPORTED" | (string & {});
3
9
  /** A stable, serializable error returned by Tabulark. */
4
10
  export declare class TabularkError extends Error {
5
11
  readonly code: TabularkErrorCode;