tabulark 0.0.4 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +215 -110
  3. package/THIRD_PARTY_NOTICES.md +37 -0
  4. package/dist/adapters.d.ts +62 -0
  5. package/dist/arrow.d.ts +3 -0
  6. package/dist/arrow.js +2 -0
  7. package/dist/arrow.js.map +7 -0
  8. package/dist/client.d.ts +76 -0
  9. package/dist/errors.d.ts +19 -0
  10. package/dist/excel.d.ts +3 -0
  11. package/dist/excel.js +2 -0
  12. package/dist/excel.js.map +7 -0
  13. package/dist/experimental.d.ts +13 -0
  14. package/dist/experimental.js +2 -0
  15. package/dist/experimental.js.map +7 -0
  16. package/dist/index.d.ts +10 -0
  17. package/dist/index.js +2 -0
  18. package/dist/index.js.map +7 -0
  19. package/dist/model.d.ts +389 -0
  20. package/dist/official-adapter-manifest.d.ts +31 -0
  21. package/dist/parquet.d.ts +3 -0
  22. package/dist/parquet.js +2 -0
  23. package/dist/parquet.js.map +7 -0
  24. package/dist/protocol.d.ts +54 -0
  25. package/dist/range-cache.d.ts +28 -0
  26. package/dist/rpc-client.d.ts +18 -0
  27. package/dist/view/accessible-grid.d.ts +36 -0
  28. package/dist/view/canvas-painter.d.ts +91 -0
  29. package/dist/view/canvas-table-view-public.d.ts +58 -0
  30. package/dist/view/canvas-table-view.d.ts +32 -0
  31. package/dist/view/controller.d.ts +34 -0
  32. package/dist/view/layout.d.ts +34 -0
  33. package/dist/view/selection.d.ts +7 -0
  34. package/dist/view/types.d.ts +184 -0
  35. package/dist/wasm/arrow/tabulark_arrow.d.ts +126 -0
  36. package/dist/wasm/arrow/tabulark_arrow.js +771 -0
  37. package/dist/wasm/arrow/tabulark_arrow_bg.wasm +0 -0
  38. package/dist/wasm/arrow/tabulark_arrow_bg.wasm.d.ts +25 -0
  39. package/dist/wasm/delimited/tabulark_delimited.d.ts +131 -0
  40. package/dist/wasm/delimited/tabulark_delimited.js +845 -0
  41. package/dist/wasm/delimited/tabulark_delimited_bg.wasm +0 -0
  42. package/dist/wasm/delimited/tabulark_delimited_bg.wasm.d.ts +26 -0
  43. package/dist/wasm/excel/tabulark_excel.d.ts +121 -0
  44. package/dist/wasm/excel/tabulark_excel.js +766 -0
  45. package/dist/wasm/excel/tabulark_excel_bg.wasm +0 -0
  46. package/dist/wasm/excel/tabulark_excel_bg.wasm.d.ts +25 -0
  47. package/dist/wasm/parquet/tabulark_parquet.d.ts +121 -0
  48. package/dist/wasm/parquet/tabulark_parquet.js +754 -0
  49. package/dist/wasm/parquet/tabulark_parquet_bg.wasm +0 -0
  50. package/dist/wasm/parquet/tabulark_parquet_bg.wasm.d.ts +25 -0
  51. package/dist/worker/wasm-adapter.d.ts +57 -0
  52. package/dist/worker/worker-errors.d.ts +9 -0
  53. package/dist/worker.d.ts +1 -0
  54. package/dist/worker.js +2 -0
  55. package/dist/worker.js.map +7 -0
  56. package/package.json +55 -12
  57. package/js/index.d.ts +0 -18
  58. package/js/index.js +0 -26
package/CHANGELOG.md ADDED
@@ -0,0 +1,16 @@
1
+ # Changelog
2
+
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.
6
+
7
+ ## 0.1.0
8
+
9
+ - Establish the stable browser-facing API and the official local-format adapter
10
+ host.
11
+ - Add local Apache Parquet and Excel (BIFF8/XLSX) preview adapters.
12
+ - Add spreadsheet presentation metadata for the Canvas view.
13
+
14
+ ## 0.0.4
15
+
16
+ Published before the 0.1.0 release train.
package/README.md CHANGED
@@ -1,157 +1,262 @@
1
1
  # Tabulark
2
2
 
3
- > A WebAssembly-first engine for fast, format-agnostic tabular data preview in the browser.
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).
4
8
 
5
- **One table model for every tabular source.**
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.
6
13
 
7
- **Status: pre-alpha design and prototyping.**
14
+ [Try the playground](https://ronbb.github.io/tabulark/) · [Architecture](docs/architecture.md) · [API stability](docs/api-stability.md) · [Testing](docs/testing.md)
8
15
 
9
- > [!IMPORTANT]
10
- > Tabulark is currently in the design and prototyping stage. There is no stable
11
- > public API or production-ready release yet. The architecture, formats, and
12
- > performance characteristics described below are goals, not shipped features.
16
+ ## Supported local formats
13
17
 
14
- ## Why Tabulark?
18
+ The 0.1.0 source tree contains four immutable official adapters. Each adapter
19
+ is a separate, lazily loaded WebAssembly artifact; creating an engine loads no
20
+ WASM and opening one format does not fetch unused artifacts.
15
21
 
16
- Tabular data reaches web applications through many formats, but preview
17
- interfaces repeatedly reimplement parsing, data transfer, caching, and
18
- rendering for each one.
22
+ | Format | Official ID | Stable entry point | 0.1 contract |
23
+ | --- | --- | --- | --- |
24
+ | CSV/TSV | `tabulark:delimited` | `tabulark` | Explicit delimiter, header, and strict/lenient modes |
25
+ | Arrow IPC | `tabulark:arrow-ipc` | `tabulark/arrow` | File/Stream; none, LZ4, and Zstd IPC compression |
26
+ | Parquet | `tabulark:parquet` | `tabulark/parquet` | Range-driven row-group/column projection and the documented codec set |
27
+ | Excel | `tabulark:excel` | `tabulark/excel` | Excel 97–2003 BIFF8 XLS and OOXML XLSX, including static presentation |
19
28
 
20
- Tabulark is being designed as composable browser infrastructure that presents
21
- those sources through one format-agnostic `Table` model. It is a preview engine,
22
- not a spreadsheet application.
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.
23
32
 
24
- ## Design principles
33
+ ## Install and build
25
34
 
26
- - One `Table` abstraction for every supported data source.
27
- - Independently loadable source adapters, including format-specific parsers.
28
- - Parsing and data ownership outside the browser main thread, with WebAssembly
29
- as the primary runtime for performance-sensitive components.
30
- - Demand-driven access instead of copying an entire dataset into JavaScript.
31
- - Viewport-oriented rendering, with Canvas as the first planned renderer.
32
- - Framework-neutral, composable building blocks.
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.
33
38
 
34
- ## Target architecture
39
+ ```sh
40
+ npm ci
41
+ npm run build
42
+ npm run check
43
+ npm run test:browser
44
+ ```
35
45
 
36
- ```text
37
- Data source
38
- -> source adapter
39
- -> Worker / WebAssembly runtime
40
- -> unified Table model and cache
41
- -> viewport query API
42
- -> renderer
43
- -> application UI
46
+ `npm run build` creates five public JavaScript entry points, a generic Worker,
47
+ and independent Delimited, Arrow, Parquet, and Excel WASM artifacts under
48
+ `dist/wasm/`.
49
+
50
+ ## Stable JavaScript API
51
+
52
+ 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`.
55
+
56
+ ```ts
57
+ import { createEngine, delimitedAdapter } from "tabulark";
58
+ import { arrowIpcAdapter } from "tabulark/arrow";
59
+ import { parquetAdapter } from "tabulark/parquet";
60
+ import { excelAdapter } from "tabulark/excel";
61
+
62
+ const engine = await createEngine({
63
+ adapters: [delimitedAdapter, arrowIpcAdapter, parquetAdapter, excelAdapter],
64
+ });
65
+
66
+ const csv = await engine.open(csvFile, {
67
+ adapter: delimitedAdapter,
68
+ adapterOptions: {
69
+ dialect: "csv",
70
+ header: "first-row",
71
+ mode: "lenient",
72
+ },
73
+ });
74
+
75
+ const parquet = await engine.open(parquetFile, {
76
+ adapter: parquetAdapter,
77
+ adapterOptions: { sourceName: parquetFile.name },
78
+ });
79
+
80
+ const workbook = await engine.open(excelFile, {
81
+ adapter: excelAdapter,
82
+ adapterOptions: { format: "auto", sourceName: excelFile.name },
83
+ });
44
84
  ```
45
85
 
46
- This architecture is intentionally provisional while the first end-to-end
47
- prototype is being developed.
86
+ Adapter selection is explicit. Excel's `format: "auto"` and Arrow's
87
+ `container: "auto"` inspect source bytes; filename extensions never select or
88
+ authenticate a format.
89
+
90
+ `ArrayBuffer` ownership is retained by default. Set `transferInput: true` only
91
+ when intentionally detaching an `ArrayBuffer`; using it with a `Blob` or
92
+ `File` returns `INVALID_ARGUMENT`.
93
+
94
+ ### Tables, logical batches, and presentation
95
+
96
+ ```ts
97
+ const table = await workbook.openTable(workbook.tables[0].id);
98
+ const batch = await table.readRange({
99
+ rowStart: 0,
100
+ rowCount: 100,
101
+ columnStart: 0,
102
+ columnCount: table.metadata.schema.columns.length,
103
+ });
104
+
105
+ const nativeRows = batch.toRows();
106
+ const displayRows = batch.toDisplayRows();
107
+ const presentation = await table.getPresentation();
108
+ const visiblePresentation = await table.readPresentationRange(batch.range);
109
+ ```
48
110
 
49
- ## Current scaffold
111
+ The stable `TableBatch` exposes logical data, its returned range, columns, and
112
+ logical accessors. WASM buffer regions, wire descriptors, protocol versions,
113
+ adapter ABI versions, and physical batch layout are private implementation
114
+ details.
115
+
116
+ `toRows()` preserves native values such as `bigint`, `Uint8Array`, decimals,
117
+ temporal values, lists, structs, maps, and unions. `toDisplayRows()` returns
118
+ only `(string | null)[][]` for rendering, accessibility, sizing, and copy.
119
+
120
+ Excel tables can return a `spreadsheet-v1` presentation. It includes sheet
121
+ visibility, frozen rows/columns, sparse row and column sizes/hidden state, a
122
+ deduplicated static style table, range-aligned style IDs, and intersecting
123
+ merged cells. Styles cover number formats, fonts, colors, fills, borders, and
124
+ alignment. The high-level Canvas view uses presentation automatically:
125
+
126
+ ```ts
127
+ const view = createCanvasTableView({
128
+ container,
129
+ table,
130
+ presentation: "auto", // default; use "ignore" for logical data only
131
+ });
132
+ ```
50
133
 
51
- The repository currently contains:
134
+ Forced-colors mode overrides workbook colors while retaining dimensions,
135
+ merges, alignment, and font emphasis.
52
136
 
53
- - A minimal Rust crate with an experimental `TableShape` value type.
54
- - A minimal ESM npm entry point with matching shape metadata.
55
- - Version synchronization and package dry-run checks.
56
- - GitHub Actions prepared for OIDC-based publication to crates.io and npm after
57
- the initial registry bootstrap and Trusted Publisher configuration.
137
+ Low-level painter, controller, layout, hit-testing, and selection primitives
138
+ live under `tabulark/experimental` and carry no compatibility promise.
58
139
 
59
- No parser, Worker runtime, WebAssembly bridge, cache, or renderer has been
60
- implemented yet.
140
+ ## Format behavior
61
141
 
62
- ## Planned data sources
142
+ ### Parquet
63
143
 
64
- CSV and TSV are intended to be the first reference adapters. Longer-term
65
- candidates include XLSX, XLS, Parquet, Apache Arrow, Feather, SQLite query
66
- results, DuckDB query results, and third-party data sources.
144
+ Each file exposes one table. The adapter reads the footer and metadata first,
145
+ then only row groups and top-level projected columns intersecting a request; it
146
+ does not stage the full file. Supported compression is uncompressed, Snappy,
147
+ Gzip, Brotli, LZ4, LZ4_RAW, and Zstd. INT96 becomes a timezone-free nanosecond
148
+ timestamp. LZO, encrypted Parquet, and experimental Variant/Geo types return
149
+ `UNSUPPORTED_FEATURE`.
67
150
 
68
- A format should not be considered supported until a released adapter is backed
69
- by compatibility tests.
151
+ All promised Parquet codecs in the official WebAssembly adapter use Rust
152
+ implementations. Arrow/Parquet 59.1.0 calls the narrow `zstd` 0.13 bulk API
153
+ directly, so the workspace supplies a Rust 1.85-compatible implementation of
154
+ that API backed by pinned `ruzstd` 0.8.1. The release gate proves the official
155
+ Arrow and Parquet WASM graphs contain neither `zstd-sys` nor `zstd-safe`.
70
156
 
71
- ## Non-goals
157
+ Cargo removes workspace patches when it publishes a crate. Therefore the
158
+ experimental crates.io Rust features deliberately do not enable upstream's
159
+ Zstd feature; Zstd is part of the stable JavaScript/WASM format contract, not
160
+ the experimental Rust API contract. This prevents a crates.io consumer from
161
+ silently receiving a C-backed implementation.
72
162
 
73
- Tabulark is not intended to be:
163
+ ### Excel
74
164
 
75
- - A spreadsheet editor or Excel replacement.
76
- - A formula calculation or workbook recalculation engine.
77
- - A VBA, macro, or arbitrary workbook-code runtime.
78
- - A pixel-perfect implementation of every Office document feature.
79
- - A pivot table, chart authoring, BI, or database product.
80
- - A mandatory all-formats bundle or complete application framework.
165
+ Each worksheet becomes a table in workbook order with an ID such as
166
+ `sheet-0`. Hidden and very-hidden worksheets remain addressable and preserve
167
+ visibility. Chart, dialog, and macro sheets are skipped with a warning.
81
168
 
82
- Editing, analysis, and application-specific UI may be built on top of Tabulark,
83
- but they are outside the core project's scope.
169
+ Columns are named A, B, …; the first row is always data; empty cells are null.
170
+ Excel values are display strings (`typedValues=false`). Formula cells use only
171
+ their cached result—Tabulark never executes formulas—and missing cached values
172
+ become null with a warning. Merged cells use the top-left value as their anchor.
84
173
 
85
- ## Development
174
+ XLS support is deliberately limited to BIFF8. Earlier BIFF, XLSM, XLSB, ODS,
175
+ and encrypted workbooks return `UNSUPPORTED_FEATURE`. XLS and XLSX share the
176
+ same bounded static-presentation subset.
86
177
 
87
- Requirements:
178
+ ## Memory and lifecycle
88
179
 
89
- - Rust 1.85 or later.
90
- - Node.js 20 or later.
91
- - npm 10 or later.
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.
92
186
 
93
- Run the local checks:
187
+ Handles are nested and cleanup cascades downward:
94
188
 
95
- ```bash
96
- cargo fmt --all --check
97
- cargo clippy --workspace --all-targets --all-features -- -D warnings
98
- cargo test --workspace --all-features
99
- cargo package --allow-dirty --locked
100
- npm ci
101
- npm run check
189
+ ```text
190
+ Engine
191
+ └─ DatasetSession
192
+ └─ TableHandle
193
+ └─ TableBatch
102
194
  ```
103
195
 
104
- After the first registry release, consumers will be able to install the base
105
- packages with:
196
+ Close operations are idempotent. Closing a dataset closes its tables; closing
197
+ an engine closes every dataset. Cancellation and close races settle once, and
198
+ reservations are released on success, failure, cancellation, and close.
106
199
 
107
- ```bash
108
- cargo add tabulark
109
- npm install tabulark
200
+ ```ts
201
+ view.destroy();
202
+ await table.close();
203
+ await workbook.close();
204
+ await engine.close();
110
205
  ```
111
206
 
112
- ## Repository layout
207
+ ## Verification
113
208
 
114
- ```text
115
- tabulark/
116
- ├── src/ # Rust crate
117
- ├── js/ # Browser-facing ESM package entry point
118
- ├── test/ # JavaScript tests
119
- ├── scripts/ # Repository validation scripts
120
- ├── docs/ # Vision and release documentation
121
- └── .github/workflows/ # CI and registry publication
122
- ```
209
+ ```sh
210
+ # Rust 1.85/stable, Clippy, all features, lifecycle, fixtures, fuzz seeds
211
+ cargo fmt --all --check
212
+ cargo clippy --workspace --all-targets --all-features -- -D warnings
213
+ cargo test --workspace --all-features --locked
123
214
 
124
- See the [project vision](docs/vision.md) for the long-term design intent and
125
- [release guide](docs/releasing.md) for registry setup and publishing.
215
+ # Stable exports/declarations, clean package consumers, and Pages assembly
216
+ npm run check
126
217
 
127
- ## Project status
218
+ # Real module Worker/WASM, Canvas, ARIA, keyboard, copy, forced-colors, visuals
219
+ npm run test:browser
128
220
 
129
- - [ ] Validate the unified `Table` model.
130
- - [ ] Define the parser and Worker protocol.
131
- - [ ] Implement a reference CSV/TSV parser.
132
- - [ ] Prototype viewport-driven Canvas rendering.
133
- - [ ] Publish the first crates.io and npm packages.
134
- - [ ] Stabilize extension APIs.
221
+ # Independent core, Arrow, Parquet, Excel, npm, and Pages delivery budgets
222
+ npm run benchmark:size
135
223
 
136
- ## Contributing
224
+ # Parquet/XLS/XLSX cold-open, range-read, and Chromium memory evidence
225
+ npm run benchmark:formats
226
+ ```
137
227
 
138
- Tabulark is not yet ready for broad feature contributions. Design discussion,
139
- representative datasets, and concrete browser-preview use cases are welcome in
140
- [GitHub Issues](https://github.com/Ronbb/tabulark/issues).
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.
141
231
 
142
- ## AI-assisted development
232
+ ## Stability and release
143
233
 
144
- Tabulark makes extensive use of generative AI throughout project design,
145
- implementation, testing, documentation, and code review. AI-generated output is
146
- treated as a draft rather than trusted work: maintainers remain responsible for
147
- every change, and the same review, testing, security, and licensing standards
148
- apply regardless of how a contribution was produced.
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
237
+ `/experimental` remain experimental/private.
149
238
 
150
- ## License
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
242
+ [docs/releasing.md](docs/releasing.md) for the immutable-release and patch
243
+ recovery policy.
151
244
 
152
- Licensed under either of:
245
+ ## Repository map
153
246
 
154
- - Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE))
155
- - MIT License ([LICENSE-MIT](LICENSE-MIT))
247
+ ```text
248
+ src/ shared Rust model, protocol, and native adapters
249
+ crates/tabulark-*-wasm/ four independently built WASM entry crates
250
+ js/ stable API, private Worker host, batches, and view
251
+ examples/csv-preview/ static six-format Playground
252
+ test/fixtures/ pinned format fixtures and provenance
253
+ test/browser/ Chromium, accessibility, visual, and Pages smoke
254
+ test/performance/ performance and per-artifact delivery budgets
255
+ docs/ architecture, testing, stability, and release policy
256
+ ```
257
+
258
+ ## License
156
259
 
157
- at your option.
260
+ Dual-licensed under [MIT](LICENSE-MIT) or [Apache-2.0](LICENSE-APACHE).
261
+ Shipped third-party material is listed in
262
+ [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md).
@@ -0,0 +1,37 @@
1
+ # Third-party notices
2
+
3
+ The optional `tabulark/arrow` and `tabulark/parquet` WebAssembly artifacts use
4
+ Apache Arrow Rust 59.1.0. This includes the `arrow-*` crates used for logical
5
+ arrays and IPC plus the `parquet` crate. Apache Arrow Rust is distributed under
6
+ Apache-2.0, with some Arrow component crates additionally carrying MIT terms.
7
+
8
+ Arrow IPC and Parquet compression support uses `brotli` (BSD-3-Clause AND MIT),
9
+ `flate2` (MIT OR Apache-2.0), `lz4_flex` (MIT), `snap` (BSD-3-Clause), and
10
+ `ruzstd` 0.8.1 (MIT). A narrow in-tree compatibility crate exposes
11
+ the `zstd` 0.13 bulk API required by Arrow/Parquet while remaining Rust-only;
12
+ its hashing dependency is `twox-hash` (MIT). `zstd-sys` and `zstd-safe` are not
13
+ part of the official production WebAssembly dependency graph.
14
+
15
+ The optional `tabulark/excel` artifact uses `calamine` 0.35.0 (MIT) for
16
+ workbook values, formulas, and worksheet discovery. Its bounded container and
17
+ static-presentation readers also use `cfb` (MIT), `zip` (MIT), and `quick-xml`
18
+ (MIT).
19
+
20
+ The Arrow IPC integration fixture under `test/fixtures/arrow/v1` is copied
21
+ byte-for-byte from `apache/arrow-testing` at the revision recorded in its
22
+ `provenance.json`. The exact upstream Apache-2.0 license is stored next to the
23
+ fixture.
24
+
25
+ The independent Parquet fixture under `test/fixtures/parquet/v1` is copied
26
+ byte-for-byte from `apache/parquet-testing` at the pinned revision recorded in
27
+ its `provenance.json`. Its Apache-2.0 license is stored next to the fixture.
28
+
29
+ The independent XLSX fixture under `test/fixtures/excel/v1` is copied
30
+ byte-for-byte from the XlsxWriter comparison corpus at the pinned revision
31
+ recorded in its `provenance.json`. XlsxWriter is distributed under BSD-2-Clause;
32
+ the upstream license is stored next to the fixture.
33
+
34
+ The complete dependency versions and checksums are locked in `Cargo.lock`.
35
+ `cargo deny check advisories licenses` is a release gate, and the release workflow emits
36
+ an SPDX SBOM. Nothing in this notice changes the license terms supplied by an
37
+ upstream project.
@@ -0,0 +1,62 @@
1
+ import { type OfficialAdapterId } from "./official-adapter-manifest.js";
2
+ export type { OfficialAdapterId } from "./official-adapter-manifest.js";
3
+ export type DelimitedDialect = "csv" | "tsv";
4
+ export type HeaderMode = "first-row" | "none";
5
+ export type ParseMode = "lenient" | "strict";
6
+ /** Options understood by the built-in delimited adapter. */
7
+ export interface DelimitedAdapterOptions {
8
+ /** Defaults to `csv`. No filename-based selection is performed. */
9
+ readonly dialect?: DelimitedDialect;
10
+ readonly header?: HeaderMode;
11
+ readonly mode?: ParseMode;
12
+ /** One ASCII delimiter byte. Overrides the dialect default when supplied. */
13
+ readonly delimiter?: string;
14
+ /** Optional display name for the source. */
15
+ readonly sourceName?: string;
16
+ }
17
+ export type ArrowIpcContainer = "auto" | "file" | "stream";
18
+ /** Options understood by the built-in Arrow IPC adapter. */
19
+ export interface ArrowIpcAdapterOptions {
20
+ /** Defaults to `auto`; format detection belongs to the Arrow adapter. */
21
+ readonly container?: ArrowIpcContainer;
22
+ /** Optional display name for the source. */
23
+ readonly sourceName?: string;
24
+ }
25
+ /** Options understood by the built-in Parquet adapter. */
26
+ export interface ParquetAdapterOptions {
27
+ /** Optional display name for the source. */
28
+ readonly sourceName?: string;
29
+ }
30
+ export type ExcelFormat = "auto" | "xls" | "xlsx";
31
+ /** Options understood by the built-in Excel adapter. */
32
+ export interface ExcelAdapterOptions {
33
+ /** Defaults to `auto`; the adapter identifies the file from its signature. */
34
+ readonly format?: ExcelFormat;
35
+ /** Optional display name for the source. */
36
+ readonly sourceName?: string;
37
+ }
38
+ /**
39
+ * A frozen descriptor for one built-in adapter.
40
+ *
41
+ * Descriptors select a named official artifact only. They are deliberately not
42
+ * factories and cannot carry a module URL or a third-party implementation.
43
+ */
44
+ export interface AdapterDescriptor<Id extends OfficialAdapterId = OfficialAdapterId, Options = unknown> {
45
+ readonly id: Id;
46
+ readonly kind: "official";
47
+ /** Carries the option type without exposing a runtime extension point. */
48
+ readonly __options?: Options;
49
+ }
50
+ export interface AdapterRegistration {
51
+ readonly id: OfficialAdapterId;
52
+ }
53
+ /** The built-in RFC-style delimited text adapter. */
54
+ export declare const delimitedAdapter: AdapterDescriptor<"tabulark:delimited", DelimitedAdapterOptions>;
55
+ /** @internal Used by the stable `/arrow` entrypoint. */
56
+ export declare function createArrowIpcAdapter(): AdapterDescriptor<"tabulark:arrow-ipc", ArrowIpcAdapterOptions>;
57
+ /** @internal Used by the stable `/parquet` entrypoint. */
58
+ export declare function createParquetAdapter(): AdapterDescriptor<"tabulark:parquet", ParquetAdapterOptions>;
59
+ /** @internal Used by the stable `/excel` entrypoint. */
60
+ export declare function createExcelAdapter(): AdapterDescriptor<"tabulark:excel", ExcelAdapterOptions>;
61
+ /** @internal Validates and extracts the non-public Worker registration. */
62
+ export declare function resolveOfficialAdapter(value: unknown): AdapterRegistration | undefined;
@@ -0,0 +1,3 @@
1
+ export { type ArrowIpcAdapterOptions, type ArrowIpcContainer } from "./adapters.js";
2
+ /** Opens Apache Arrow IPC File or Stream input through the lazy official Arrow artifact. */
3
+ export declare const arrowIpcAdapter: import("./adapters.js").AdapterDescriptor<"tabulark:arrow-ipc", import("./adapters.js").ArrowIpcAdapterOptions>;
package/dist/arrow.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 createArrowIpcAdapter(){return createOfficialAdapter("tabulark:arrow-ipc")}var arrowIpcAdapter=createArrowIpcAdapter();export{arrowIpcAdapter};
2
+ //# sourceMappingURL=arrow.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../js/adapters.ts", "../js/arrow.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 ArrowIpcAdapterOptions, type ArrowIpcContainer } from \"./adapters.js\";\n\nimport { createArrowIpcAdapter } from \"./adapters.js\";\n\n/** Opens Apache Arrow IPC File or Stream input through the lazy official Arrow artifact. */\nexport const arrowIpcAdapter = createArrowIpcAdapter();\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,EAGf,SAAS,uBAAyF,CACvG,OAAO,sBAAoE,oBAAoB,CACjG,CCnGO,IAAM,gBAAkB,sBAAsB",
6
+ "names": []
7
+ }
@@ -0,0 +1,76 @@
1
+ import { TabularkError } from "./errors.js";
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";
4
+ export interface OpenSourceOptions<Options = unknown> {
5
+ /** One of the official descriptors registered when the engine was created. */
6
+ readonly adapter: AdapterDescriptor<OfficialAdapterId, Options>;
7
+ readonly adapterOptions?: Options;
8
+ /** Detaches an ArrayBuffer input. Defaults to false; Blob input cannot be transferred. */
9
+ readonly transferInput?: boolean;
10
+ /** Cancels opening and releases any Worker-side source created by the request. */
11
+ readonly signal?: AbortSignal;
12
+ }
13
+ export interface EngineOptions {
14
+ /** The engine's immutable allow-list. At least one official adapter is required. */
15
+ readonly adapters: readonly AdapterDescriptor[];
16
+ readonly memoryBudgetBytes?: number;
17
+ readonly workerName?: string;
18
+ }
19
+ export interface ReadRangeOptions {
20
+ readonly signal?: AbortSignal;
21
+ }
22
+ export interface RuntimeProgress {
23
+ readonly sourceHandle: string;
24
+ readonly tableId?: string;
25
+ readonly revision?: number;
26
+ readonly bytesScanned: number;
27
+ readonly rowsDiscovered: number;
28
+ readonly done: boolean;
29
+ }
30
+ export interface SourceWarning {
31
+ readonly handle: string;
32
+ readonly kind: string;
33
+ readonly message: string;
34
+ readonly byteOffset?: number;
35
+ readonly row?: number;
36
+ }
37
+ export type DatasetEvent = Readonly<{
38
+ type: "progress";
39
+ progress: RuntimeProgress;
40
+ }> | Readonly<{
41
+ type: "metadata";
42
+ metadata: Readonly<TableMetadata>;
43
+ }> | Readonly<{
44
+ type: "warning";
45
+ warning: SourceWarning;
46
+ }> | Readonly<{
47
+ type: "closed";
48
+ }> | Readonly<{
49
+ type: "runtimeError";
50
+ error: TabularkError;
51
+ }>;
52
+ export type TableEvent = Exclude<DatasetEvent, Readonly<{
53
+ type: "progress";
54
+ }>>;
55
+ export type Unsubscribe = () => void;
56
+ export interface DatasetSession {
57
+ readonly tables: readonly Readonly<TableDescriptor>[];
58
+ openTable(tableId: string): Promise<TableHandle>;
59
+ subscribe(listener: (event: DatasetEvent) => void): Unsubscribe;
60
+ close(): Promise<void>;
61
+ }
62
+ export interface TableHandle {
63
+ readonly metadata: Readonly<TableMetadata>;
64
+ getPresentation(): Promise<TablePresentation | null>;
65
+ readPresentationRange(request: RangeRequest, options?: ReadRangeOptions): Promise<PresentationRange | null>;
66
+ readRange(request: RangeRequest, options?: ReadRangeOptions): Promise<TableBatch>;
67
+ subscribe(listener: (event: TableEvent) => void): Unsubscribe;
68
+ close(): Promise<void>;
69
+ }
70
+ export interface TabularkEngine {
71
+ open<Options>(source: Blob | ArrayBuffer, options: OpenSourceOptions<Options>): Promise<DatasetSession>;
72
+ close(): Promise<void>;
73
+ dispose(): Promise<void>;
74
+ }
75
+ /** Creates one dedicated Worker-backed Tabulark engine. */
76
+ export declare function createEngine(options: EngineOptions): Promise<TabularkEngine>;
@@ -0,0 +1,19 @@
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 & {});
3
+ /** A stable, serializable error returned by Tabulark. */
4
+ export declare class TabularkError extends Error {
5
+ readonly code: TabularkErrorCode;
6
+ readonly retryable: boolean;
7
+ readonly details?: unknown;
8
+ constructor(code: TabularkErrorCode, message: string, options?: {
9
+ retryable?: boolean;
10
+ details?: unknown;
11
+ cause?: unknown;
12
+ });
13
+ static fromSerialized(error: SerializedError): TabularkError;
14
+ }
15
+ /** @internal Ensures every resource-limit error has a stable capacity shape. */
16
+ export declare function normalizeResourceLimitDetails(details: unknown): Readonly<Record<string, unknown>>;
17
+ export declare function cancelledError(): TabularkError;
18
+ export declare function closedError(resource: string): TabularkError;
19
+ export declare function invalidArgument(message: string, details?: unknown): TabularkError;
@@ -0,0 +1,3 @@
1
+ export { type ExcelAdapterOptions, type ExcelFormat } from "./adapters.js";
2
+ /** Opens BIFF8 XLS or OOXML XLSX input through the lazy official Excel artifact. */
3
+ export declare const excelAdapter: import("./adapters.js").AdapterDescriptor<"tabulark:excel", import("./adapters.js").ExcelAdapterOptions>;
package/dist/excel.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 createExcelAdapter(){return createOfficialAdapter("tabulark:excel")}var excelAdapter=createExcelAdapter();export{excelAdapter};
2
+ //# sourceMappingURL=excel.js.map