@rowsncolumns/rnc-engine 0.10.132

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 (37) hide show
  1. package/LICENSE.md +100 -0
  2. package/README.md +83 -0
  3. package/dist/esm/command-handlers.d.ts +169 -0
  4. package/dist/esm/command-handlers.d.ts.map +1 -0
  5. package/dist/esm/command-handlers.js +404 -0
  6. package/dist/esm/fold.d.ts +140 -0
  7. package/dist/esm/fold.d.ts.map +1 -0
  8. package/dist/esm/fold.js +539 -0
  9. package/dist/esm/index.d.ts +620 -0
  10. package/dist/esm/index.d.ts.map +1 -0
  11. package/dist/esm/index.js +425 -0
  12. package/dist/esm/io.d.ts +119 -0
  13. package/dist/esm/io.d.ts.map +1 -0
  14. package/dist/esm/io.js +318 -0
  15. package/dist/esm/keys.d.ts +20 -0
  16. package/dist/esm/keys.d.ts.map +1 -0
  17. package/dist/esm/keys.js +41 -0
  18. package/dist/esm/move-rescope.d.ts +18 -0
  19. package/dist/esm/move-rescope.d.ts.map +1 -0
  20. package/dist/esm/move-rescope.js +38 -0
  21. package/dist/esm/use-engine-core.d.ts +293 -0
  22. package/dist/esm/use-engine-core.d.ts.map +1 -0
  23. package/dist/esm/use-engine-core.js +2279 -0
  24. package/dist/esm/use-engine-pivot-editor.d.ts +78 -0
  25. package/dist/esm/use-engine-pivot-editor.d.ts.map +1 -0
  26. package/dist/esm/use-engine-pivot-editor.js +252 -0
  27. package/dist/esm/use-spreadsheet-engine.d.ts +7 -0
  28. package/dist/esm/use-spreadsheet-engine.d.ts.map +1 -0
  29. package/dist/esm/use-spreadsheet-engine.js +23 -0
  30. package/dist/esm/use-spreadsheet-ui.d.ts +39 -0
  31. package/dist/esm/use-spreadsheet-ui.d.ts.map +1 -0
  32. package/dist/esm/use-spreadsheet-ui.js +78 -0
  33. package/dist/esm/wasm/rnc_wasm.d.ts +394 -0
  34. package/dist/esm/wasm/rnc_wasm.js +1455 -0
  35. package/dist/esm/wasm/rnc_wasm_bg.wasm +0 -0
  36. package/dist/esm/wasm/rnc_wasm_bg.wasm.d.ts +81 -0
  37. package/package.json +51 -0
@@ -0,0 +1,620 @@
1
+ /**
2
+ * `@rowsncolumns/rnc-engine` — typed JS/TS interop for the Rust→WASM spreadsheet calc engine.
3
+ *
4
+ * Wraps the wasm-bindgen-generated `rnc-wasm` surface (JSON strings in/out) with ergonomic, typed
5
+ * methods that speak the exact `rnc-model` / `commands.ts` shapes:
6
+ *
7
+ * - `applyCommand(command)` → `CommitResult` (a `commands.ts` command → value/style change-set)
8
+ * - `readWindow(...)` → `WindowSnapshot` (windowed render data + consolidated styles)
9
+ * - `RncEngine.toStyleMap(styles)` → `Map<"sheetId!A1", CellFormat>`
10
+ *
11
+ * The interop layer itself is GENERATED by wasm-bindgen (no hand-written FFI) — this package is the
12
+ * thin idiomatic layer on top. The prebuilt wasm is VENDORED in `./wasm` (shipped in `dist/esm/wasm`),
13
+ * so consumers need no Rust/wasm toolchain. Rebuild it after Rust changes with `yarn build:wasm`
14
+ * (nightly Rust — the `--features collab` engine pulls yrs 0.27).
15
+ */
16
+ import type { CellData, CellFormat, CellInterface, Citation, DataValidationRule, ExtendedValue, SheetCoordinate, SheetRange } from "@rowsncolumns/common-types";
17
+ import type { BandedRange, ConditionalFormatRule, DataValidationRuleRecord, EmbeddedChart, EmbeddedObject, FilterView, NamedRange, PivotTable, ProtectedRange, Sheet, Slicer, TableView } from "@rowsncolumns/spreadsheet";
18
+ import type { Command, CommandOf, CommandType } from "@rowsncolumns/spreadsheet-state";
19
+ import { CollabSpreadsheetEngine } from "./wasm/rnc_wasm.js";
20
+ export type { Command, CommandOf, CommandType };
21
+ /**
22
+ * The wire types reuse the EXACT canonical contract types — no reinvented coordinate shapes.
23
+ * On the Rust side these are `#[serde(flatten)]`-embedded `CellInterface` / `SheetCoordinate` /
24
+ * `SheetRange`, so the JSON carries `rowIndex` / `columnIndex` / `sheetId` / `startRowIndex` / …
25
+ */
26
+ /** One cell in a window — the value side the UI renders. Mirrors rnc-store `WindowCell`. */
27
+ export type WindowCell = CellInterface & {
28
+ formatted: string;
29
+ number: number | null;
30
+ isFormula: boolean;
31
+ /** The formula SOURCE (`=SUM(A1:A2)`) for a formula cell, so the lean-window reconstruction can put
32
+ * it on `ue.fv` (formula bar / editor). Absent for literals. */
33
+ formula?: string;
34
+ /** The cell VERBATIM (`ue`/formula source, `ev`, hyperlink, note, …) — present when the engine
35
+ * exposes the lossless `readWindowCommit`. The windowed render uses it AS-IS instead of
36
+ * reconstructing a lossy `CellData` from the lean fields above (which drops `ue.fv` etc.). */
37
+ cell?: CellData;
38
+ };
39
+ /** One consolidated style for a cell — the UI folds these into `Map<"sheetId!A1", CellFormat>`.
40
+ * `format: null` means the cell's style was **cleared** (drop it from the map). */
41
+ export type StyleEntry = SheetCoordinate & {
42
+ format: CellFormat | null;
43
+ };
44
+ /** A rectangular window streamed to the UI. Mirrors rnc-store `WindowSnapshot`. */
45
+ export type WindowSnapshot = SheetRange & {
46
+ cells: WindowCell[];
47
+ styles: StyleEntry[];
48
+ /** Render-only DERIVED number formats for the window's formula cells (`=SUM($a,$b)` → currency),
49
+ * layered UNDER the user's style in `getEffectiveFormat`. Absent when none — see `CommitResult`. */
50
+ derivedFormats?: StyleEntry[];
51
+ };
52
+ /** Selection statistics over a range — what the status bar shows. Mirrors rnc-store `RangeStats`,
53
+ * which mirrors the legacy `SELECTION_STATUS` formula. Computed in Rust over the stored cells (no
54
+ * value round-trip to JS), so it's cheap even on a million-cell selection — the bug this fixes: the
55
+ * JS status-bar path refused selections over ~200k cells.
56
+ *
57
+ * - `count` — non-empty cells (COUNTA): any cell with a value, numeric OR text.
58
+ * - `numericalCount` — cells holding a NUMBER (COUNT); `sum`/`average`/`min`/`max` are over these.
59
+ * - `sum`/`average`/`min`/`max` — `null` when the range holds no numbers (so the UI hides them). */
60
+ export interface RangeStats {
61
+ sum: number | null;
62
+ count: number;
63
+ average: number | null;
64
+ min: number | null;
65
+ max: number | null;
66
+ numericalCount: number;
67
+ }
68
+ /** One changed (or `removed`) cell — the delta streamed after a command. Mirrors `CellChange`. */
69
+ export type CellChange = SheetCoordinate & {
70
+ /** The cell VERBATIM — its `ue` (input / formula source), `ev` (computed value incl. `ev.ev` =
71
+ * errorValue), `fv` (formatted), hyperlink, … — assigned straight into `sheetData`. `null` = the
72
+ * cell was cleared. JS is view-only: it never reconstructs values, classifies inputs, or detects
73
+ * errors. (Styles ride the separate `styleChanges` channel, so they're NOT on this cell.) */
74
+ cell: CellData | null;
75
+ };
76
+ /** One row's / column's metadata delta — mirrors rnc-store `DimensionChange`. A resize/hide doesn't
77
+ * change any cell VALUE, so it streams here (not in `changes`). The UI assigns the props into
78
+ * `rowMetadata[index]` (from `rowChanges`) or `columnMetadata[index]` (from `columnChanges`). */
79
+ export interface DimensionChange {
80
+ sheetId: number;
81
+ index: number;
82
+ size?: number;
83
+ resizedByUser?: boolean;
84
+ customHeight?: boolean;
85
+ hiddenByUser?: boolean;
86
+ hiddenByFilter?: boolean;
87
+ hiddenByGroup?: boolean;
88
+ outlineLevel?: number;
89
+ collapsed?: boolean;
90
+ }
91
+ /** One merge-region delta — mirrors rnc-store `MergeChange`. `removed:true` = the region was
92
+ * unmerged (drop it from `sheet.merges`); otherwise it was merged (add it). The keep-upper-left cell
93
+ * clearing rides the `changes` channel, so the UI applies that automatically. */
94
+ export interface MergeChange {
95
+ sheetId: number;
96
+ startRowIndex: number;
97
+ endRowIndex: number;
98
+ startColumnIndex: number;
99
+ endColumnIndex: number;
100
+ removed: boolean;
101
+ }
102
+ /** What `applyCommand` returns. Mirrors rnc-store `CommitResult` — one typed channel per document
103
+ * facet: cell values (`changes`, incl. cross-sheet formula dependents), cell styles
104
+ * (`styleChanges`), row/column metadata (`rowChanges`/`columnChanges`), and merge regions
105
+ * (`merges`). The engine owns structural results; the UI applies these channels. */
106
+ export interface CommitResult {
107
+ changes: CellChange[];
108
+ styleChanges: StyleEntry[];
109
+ /** Render-only DERIVED number-format deltas: a formula cell's INHERITED format (`=SUM($a,$b)` →
110
+ * currency), layered UNDER the user's own style in `getEffectiveFormat` (`format: null` clears a
111
+ * prior one). NEVER persisted — distinct from `styleChanges`. Absent when no formula cell changed. */
112
+ derivedFormatChanges?: StyleEntry[];
113
+ rowChanges: DimensionChange[];
114
+ columnChanges: DimensionChange[];
115
+ merges: MergeChange[];
116
+ /** Data-validation results — folded ONTO each cell's `dataValidationResult` (`valid:false` = the
117
+ * value violates a rule). There is NO conditional-style channel: conditional formatting is rendered
118
+ * by CanvasGrid from the rules (`useConditionalFormatting`); the engine doesn't derive CF styles. */
119
+ validations: ValidationStatus[];
120
+ /** Per-cell note (annotation) deltas — `note: null` = the note was cleared. */
121
+ noteChanges: NoteEntry[];
122
+ /** Chart spec deltas — `chart: null` = deleted. UI → `onChangeCharts`. */
123
+ chartChanges: ChartChange[];
124
+ /** Pivot spec deltas — `pivotTable: null` = deleted. UI → `onChangePivotTables`. (Aggregation is
125
+ * deferred to `rnc-pivot`; the engine stores the spec + streams spec changes.) */
126
+ pivotChanges: PivotChange[];
127
+ /** HOST custom-function eval requests captured this recalc — a `=AOP(A1,…)` cell (a JS-registered
128
+ * function) records its cell + resolved args here. The hook runs the registered JS impl and answers
129
+ * via `setEffectiveValue`. See {@link useEngineCore}'s `registerCustomFunction`. */
130
+ customEvals: CustomEval[];
131
+ /** HOST custom-function calls whose cell no longer holds the formula after this commit — cleared,
132
+ * overwritten, filled/pasted over, undone, or removed with its row/column. The hook drops the
133
+ * matching in-flight eval's answer; hosts can additionally observe these via the
134
+ * `onCustomEvalCancel` option to abort whatever the call started (e.g. a backend run). Absent
135
+ * when nothing was cancelled. */
136
+ customCancels?: CustomCancel[];
137
+ fullResyncSheets: number[];
138
+ /** Conditional-format RULE set after a CF command (create/update/delete) — the full current list, so
139
+ * an `onChanges` / collaboration consumer observes rule changes here. Per-cell CF RESULTS still ride
140
+ * `changes` on the cell (`conditionalFormattingResultById`). Empty `[]` when no CF command ran this
141
+ * commit; also emitted on `load`. */
142
+ conditionalFormats: ConditionalFormatRule[];
143
+ /** Data-validation RULE set after a DV command — the full current list (per-cell validity still rides
144
+ * the `validations` channel). Empty `[]` when no DV command ran this commit; emitted on `load`. */
145
+ dataValidations: DataValidationEntry[];
146
+ /** Citation collection after a citation command (create/update/delete/remove-from-cell) — the full
147
+ * current list (a cell's `citationId` link still rides `changes`). Empty `[]` when no citation command
148
+ * ran this commit; emitted on `load`. */
149
+ citations: Citation[];
150
+ }
151
+ /** A pending host custom-function evaluation — the cell, the function name, and the RESOLVED argument
152
+ * values (e.g. `A1`'s value). Mirrors rnc-store `CustomEval`. */
153
+ export type CustomEval = SheetCoordinate & {
154
+ name: string;
155
+ args: unknown[];
156
+ };
157
+ /** A cancelled host custom-function call — the cell that held `=NAME(…)` and the (upper-cased)
158
+ * function name. Mirrors rnc-store `CustomCancel`. */
159
+ export type CustomCancel = SheetCoordinate & {
160
+ name: string;
161
+ };
162
+ /** One cell's data-validation result — mirrors rnc-store `ValidationStatus`. */
163
+ export type ValidationStatus = SheetCoordinate & {
164
+ valid: boolean;
165
+ };
166
+ /** One cell's note delta — mirrors rnc-store `NoteEntry`. `note: null` = cleared. */
167
+ export type NoteEntry = SheetCoordinate & {
168
+ note: string | null;
169
+ };
170
+ /** One chart's spec delta — mirrors rnc-store `ChartChange`. `chart: null` = deleted. The engine
171
+ * round-trips the canonical `EmbeddedChart` spec losslessly. */
172
+ export interface ChartChange {
173
+ chartId: EmbeddedChart["chartId"];
174
+ chart: EmbeddedChart | null;
175
+ }
176
+ /** One pivot table's spec delta — mirrors rnc-store `PivotChange`. `pivotTable: null` = deleted.
177
+ * (Aggregation is deferred to `rnc-pivot`; this carries the canonical `PivotTable` spec for sync.) */
178
+ export interface PivotChange {
179
+ pivotId: PivotTable["pivotId"];
180
+ pivotTable: PivotTable | null;
181
+ }
182
+ /** A sheet to register up-front (`id` → display name). */
183
+ export interface SheetInit {
184
+ sheetId: number;
185
+ title: string;
186
+ }
187
+ /** One sheet's authoritative identity/order as the engine reports it from {@link RncEngine.sheets} —
188
+ * the lifecycle facets (id / title / tab order, plus hidden / tab color) the engine owns. Dimension /
189
+ * merge metadata is NOT here (it rides the per-commit channels); this is the tab-list source of truth. */
190
+ export interface EngineSheet {
191
+ sheetId: number;
192
+ title: string;
193
+ /** 0-based tab order. */
194
+ index: number;
195
+ hidden?: boolean;
196
+ tabColor?: Sheet["tabColor"];
197
+ /** Sheet-view toggles + zoom (from the imported `<sheetView>`); absent = renderer default. */
198
+ showGridLines?: boolean;
199
+ showRowColHeaders?: boolean;
200
+ showZeros?: boolean;
201
+ zoomScale?: number;
202
+ /** `<sheetView rightToLeft>` — the sheet displays right-to-left. Round-tripped and queryable;
203
+ * the grid does NOT mirror yet (rendering is a follow-up). Absent = LTR. */
204
+ rightToLeft?: boolean;
205
+ /** Sheet default row height in px (from the imported `<sheetFormatPr defaultRowHeight>`): what a
206
+ * row with no `rowMetadata` entry renders at. Absent = renderer default. */
207
+ defaultRowHeight?: number;
208
+ }
209
+ /** Initial document to hydrate the engine from (e.g. an API response / saved snapshot). */
210
+ export interface LoadDocument {
211
+ sheets?: Array<{
212
+ sheetId: number;
213
+ title?: string;
214
+ }>;
215
+ /** `rnc-model` SheetData: `Record<sheetId, (RowData | null)[]>`. Short OR long cell keys both load
216
+ * (`ue`/`userEnteredValue`, `uf`/`userEnteredFormat`, …); a numeric `ss` is coerced to its string. */
217
+ sheetData?: Record<string | number, unknown>;
218
+ /** Optional explicit consolidated styles (alternative to per-cell `uf`). */
219
+ styles?: Array<SheetCoordinate & {
220
+ format: CellFormat;
221
+ }>;
222
+ /** Document facets to hydrate alongside the cells (evaluated/streamed on load). */
223
+ conditionalFormats?: ConditionalFormatRule[];
224
+ /** Input rules (`{ id, ranges, condition }`); the engine resolves a cell's rule by range membership.
225
+ * `id` may be a number at the type level — the engine coerces it to a string key. */
226
+ dataValidations?: DataValidationRuleRecord[];
227
+ charts?: EmbeddedChart[];
228
+ pivotTables?: PivotTable[];
229
+ tables?: TableView[];
230
+ namedRanges?: NamedRange[];
231
+ embeds?: EmbeddedObject[];
232
+ slicers?: Slicer[];
233
+ bandedRanges?: BandedRange[];
234
+ citations?: Citation[];
235
+ }
236
+ /** One stored data-validation rule + the ranges it covers — the hook resolves a cell's rule by
237
+ * testing membership in `ranges` (`getDataValidation(sheetId,row,col)`). Mirrors rnc-store `DvDef`. */
238
+ export interface DataValidationEntry {
239
+ id: string;
240
+ ranges: SheetRange[];
241
+ condition?: DataValidationRule["condition"];
242
+ /** `"plain"` suppresses the in-cell dropdown arrow (imported from OOXML `showDropDown="1"`,
243
+ * whose polarity is inverted); absent/`"arrow"` renders the default arrow. */
244
+ displayStyle?: DataValidationRule["displayStyle"];
245
+ allowBlank?: DataValidationRule["allowBlank"];
246
+ }
247
+ /** The document-level facets the renderer draws — the CanvasGrid props that aren't cells or styles.
248
+ * Read in one shot from the engine via {@link RncEngine.documentFacets} after each commit (small +
249
+ * change rarely, so they ride a getter, not a per-facet diff). Conditional-format rules and the
250
+ * lossless object facets (embeds / slicers / banded / protected ranges) are verbatim; named ranges
251
+ * and tables are reconstructed canonically from the engine's stored definitions. */
252
+ export interface DocumentFacets {
253
+ conditionalFormats: ConditionalFormatRule[];
254
+ dataValidations: DataValidationEntry[];
255
+ namedRanges: NamedRange[];
256
+ tables: TableView[];
257
+ embeds: EmbeddedObject[];
258
+ slicers: Slicer[];
259
+ bandedRanges: BandedRange[];
260
+ protectedRanges: ProtectedRange[];
261
+ basicFilters: Array<{
262
+ sheetId: number;
263
+ filter: FilterView;
264
+ }>;
265
+ citations: Citation[];
266
+ /**
267
+ * Body rows hidden by any active filter (basic OR table-column), keyed by sheetId, as compact
268
+ * `[start, end]` 1-based inclusive ranges. The host derives `visibleRowRanges` from these.
269
+ */
270
+ hiddenRowRanges?: Record<string, [number, number][]>;
271
+ }
272
+ /** A subscriber notified with each change-set the engine produces. */
273
+ export type ChangeListener = (commit: CommitResult) => void;
274
+ /**
275
+ * The minimal wasm-engine surface {@link RncEngine} drives — the JS side of the port plan's storage
276
+ * seam. The built-in single-user {@link SpreadsheetEngine} and the collaborative
277
+ * {@link CollabSpreadsheetEngine} both satisfy it, and so can a THIRD-PARTY Rust store compiled to
278
+ * wasm. Switching backends = passing a different one to {@link RncEngine.create}
279
+ * (`createEngine` on the hook options).
280
+ *
281
+ * `initGrid` / `stream*` are optional capabilities: only positional/CRDT stores need `initGrid`
282
+ * (pre-sizing); only the huge-workbook NDJSON path needs `stream*`. A store may omit either.
283
+ */
284
+ export interface SpreadsheetEngineLike {
285
+ addSheet(sheetId: number, name: string): void;
286
+ /** Pre-size a sheet's grid. Required by positional/CRDT stores (e.g. the collab engine) before
287
+ * cells are written; absent on stores that grow on demand. */
288
+ initGrid?(sheetId: number, rows: number, cols: number): void;
289
+ loadDocument(documentJson: string): string;
290
+ applyCommand(commandJson: string): string;
291
+ /** Declare WINDOWED rendering. When on, every commit this engine serializes (`applyCommand` /
292
+ * `undo` / `redo` / `loadDocument`) omits the O(cells) channels (`changes`, `styleChanges`,
293
+ * `derivedFormatChanges`, `validations`, `noteChanges`) — the windowed host re-reads visible cells
294
+ * via `readWindow` and discards those channels anyway, so on a 1M-row sheet this avoids building,
295
+ * shipping, and `JSON.parse`ing a multi-MB string the host throws away. Optional: a store may omit
296
+ * it (the host then receives full commits, which the windowed fold still correctly ignores — just
297
+ * without the transfer saving). See {@link useEngineCore}'s `windowed` option. */
298
+ setWindowed?(on: boolean): void;
299
+ readWindow(sheetId: number, startRow: number, startCol: number, endRow: number, endCol: number): string;
300
+ /** Lossless full-cell window read — each cell VERBATIM as a `CommitResult` JSON (`changes` carry the
301
+ * whole `CellData`: `ue`/formula source, `ev`, hyperlink, note). Preferred over the lean `readWindow`
302
+ * so the windowed render doesn't drop those fields. Absent on engines that only ship the lean read. */
303
+ readWindowCommit?(sheetId: number, startRow: number, startCol: number, endRow: number, endCol: number): string;
304
+ /** Selection statistics over a 1-indexed inclusive range as `RangeStats` JSON. Optional: a store
305
+ * may omit it (the host then falls back to its own — necessarily capped — JS computation). */
306
+ rangeStats?(sheetId: number, startRow: number, startCol: number, endRow: number, endCol: number): string;
307
+ /** Off-window search: JSON `SheetCoordinate[]` (row-major) of every cell on `sheetId` whose display
308
+ * text matches `find`. `rangesJson` is a JSON `SheetRange[]` (`""` = whole sheet). The windowed UI
309
+ * can only scan the loaded viewport in JS, so finding matches OUTSIDE it must go through the engine
310
+ * (which holds the whole document). Matching honors match-case / whole-word (`\b`) / regex, mirroring
311
+ * the JS `buildSearchRegex`. Optional: a store may omit it (the host then falls back to JS search,
312
+ * which only finds within loaded data). */
313
+ findAll?(sheetId: number, rangesJson: string, find: string, matchCase: boolean, wholeWord: boolean, useRegex: boolean): string;
314
+ /** Scratch-evaluate a formula at a cell — `ExtendedValue` JSON or `"null"`. Read-only (no
315
+ * install / commit / dirty marks); powers the cell editor's live result preview
316
+ * (`onRequestCalculate`). Optional: a store may omit it (the host then shows no preview). */
317
+ evalFormula?(sheetId: number, row: number, col: number, formula: string): string;
318
+ /** Distinct fill/font colors + CF icons in one column's body rows — JSON
319
+ * `{cellColors, fontColors, icons: [{iconSet, iconId}]}`. Powers the FilterBox
320
+ * "Filter by color" picker on windowed hosts (the JS per-row scan is disabled there).
321
+ * Optional: a store may omit it (the picker then stays hidden). */
322
+ filterColors?(sheetId: number, col: number, startRow: number, endRow: number): string;
323
+ sheetIds(): Int32Array | number[];
324
+ /** Remove the host-seeded default `Sheet1` (sheetId 1) when a collab merge showed the workbook's
325
+ * real sheets live under other ids. Call right after merging the collab doc, and ONLY when the
326
+ * persisted doc's sheet registry is non-empty and contains no sheetId 1 — the one fact the store
327
+ * cannot know. The store guards the rest (exact seed title, zero populated cells, ≥1 other
328
+ * sheet). Optional: only CRDT stores carry a construction seed that can dangle. Returns whether
329
+ * the seed was pruned. */
330
+ pruneDanglingDefaultSeed?(): boolean;
331
+ /** Per-sheet 1-based data extent as JSON `[[sheetId, rowCount, colCount], …]`. A windowed renderer
332
+ * sizes the grid's scroll extent to this so it can hold only the visible viewport in JS yet scroll
333
+ * the full sheet. Optional: present on the single-user + collab engines; a store may omit it (the
334
+ * windowed hook then falls back to the seeded sheet counts). */
335
+ sheetExtents?(): string;
336
+ /** Export a sheet's display values as RFC-4180 CSV. Optional capability. */
337
+ exportCsv?(sheetId: number): string;
338
+ /** Export the whole workbook to in-memory XLSX bytes (the engine reads the full document — values,
339
+ * formats, merges, frozen panes, tables, named ranges — and writes via the Rust exporter). Optional
340
+ * capability: only engines built with export support expose it. */
341
+ exportXlsx?(): Uint8Array;
342
+ /** Import an `.xlsx` workbook with the native Rust reader (`rnc-import`) and hydrate the engine from
343
+ * it, returning the full `CommitResult` JSON (same shape as `loadDocument`). Optional capability:
344
+ * only engines built with import support expose it (the yrs-store engine returns a sheet-summary
345
+ * instead; the {@link RncEngine.importXlsx} wrapper handles the single-engine commit shape). */
346
+ importXlsx?(bytes: Uint8Array): string;
347
+ documentFacets(): string;
348
+ /** The workbook's sheets in tab order as JSON `[{sheetId, title, index, hidden?, tabColor?}]` —
349
+ * the engine's authoritative sheet identity/order/titles. A thin UI reconciles its tab list from
350
+ * this after each commit. Optional: a store may omit it (the hook then keeps its seeded sheets). */
351
+ sheets?(): string;
352
+ registerCustomFunction(name: string): void;
353
+ precedents(sheetId: number, row: number, col: number): string;
354
+ dependents(sheetId: number, row: number, col: number): string;
355
+ clearHistory(): void;
356
+ undo(): string;
357
+ redo(): string;
358
+ canUndo(): boolean;
359
+ canRedo(): boolean;
360
+ undoDepth(): number;
361
+ redoDepth(): number;
362
+ /** Streaming hydration for 100 MB+ workbooks (NDJSON). Optional — collab docs hydrate from the
363
+ * CRDT update stream (`applyUpdate`) instead. */
364
+ streamBegin?(): void;
365
+ streamWrite?(chunk: Uint8Array): void;
366
+ streamEnd?(): void;
367
+ free(): void;
368
+ }
369
+ /**
370
+ * The extra Yjs sync surface a COLLABORATIVE engine implements so the host can bridge it to a
371
+ * `Y.Doc` (Keryx / yhub). {@link CollabSpreadsheetEngine} implements this; the single-user
372
+ * {@link SpreadsheetEngine} does not. {@link RncEngine} exposes these through
373
+ * {@link RncEngine.applyRemoteUpdate} / {@link RncEngine.encodeStateAsUpdate} / … when the injected
374
+ * engine is collaborative.
375
+ */
376
+ export interface CollabSync {
377
+ /** Merge a remote Yjs v1 update into the CRDT doc. Follow with `syncRemote()` to fold the result. */
378
+ applyUpdate(update: Uint8Array): void;
379
+ /** Rebuild the calc engine after `applyUpdate` and return a `CommitResult` JSON for the UI. */
380
+ syncRemote(): string;
381
+ /** Full document state as a Yjs v1 update (initial sync / persistence). */
382
+ encodeStateAsUpdate(): Uint8Array;
383
+ /** This peer's Yjs state vector (what it has seen). */
384
+ encodeStateVector(): Uint8Array;
385
+ /** The diff the remote (by its state vector) is missing — send via the transport's `applyUpdate`. */
386
+ encodeDiffV1(remoteStateVector: Uint8Array): Uint8Array;
387
+ }
388
+ /** Options for {@link RncEngine.create}. */
389
+ export interface CreateEngineOptions {
390
+ /** Inject the backing wasm engine instead of the default single-user {@link SpreadsheetEngine}.
391
+ * Pass `() => new CollabSpreadsheetEngine()` for yhub/collab, or your own store. */
392
+ engine?: SpreadsheetEngineLike;
393
+ /** Initial grid size for stores that implement `initGrid` (collab/positional). Ignored otherwise. */
394
+ gridRows?: number;
395
+ gridCols?: number;
396
+ }
397
+ /** Initialize the wasm module (idempotent). Called by {@link RncEngine.create}; exported for control. */
398
+ export declare function initEngine(): Promise<unknown>;
399
+ /**
400
+ * Ergonomic, typed handle to a standalone in-memory spreadsheet engine.
401
+ * Commands go in; value/style change-sets and windowed reads come out — all using the exact
402
+ * `rnc-model` shapes the rest of the app already speaks.
403
+ */
404
+ export declare class RncEngine {
405
+ private readonly inner;
406
+ private readonly listeners;
407
+ private constructor();
408
+ /**
409
+ * Initialize wasm (idempotent) and create an engine with the given sheets registered.
410
+ *
411
+ * By default the backend is the single-user {@link SpreadsheetEngine}. Pass `options.engine` to
412
+ * inject a different store — e.g. `new CollabSpreadsheetEngine()` (yhub/collab) or your own wasm
413
+ * store implementing {@link SpreadsheetEngineLike}. When the store implements `initGrid`
414
+ * (positional/CRDT), each registered sheet is pre-sized to `gridRows`×`gridCols`.
415
+ */
416
+ static create(sheets?: SheetInit[], options?: CreateEngineOptions): Promise<RncEngine>;
417
+ /**
418
+ * Wrap an ALREADY-INITIALIZED backing engine — skips {@link initEngine} (the caller owns wasm
419
+ * init). Use this when the wasm module is loaded by a different path than the vendored
420
+ * `--target web` build: a `--target nodejs` engine in tests/SSR, a `CollabSpreadsheetEngine` you
421
+ * constructed yourself, or any custom {@link SpreadsheetEngineLike} store. Registers `sheets` (and
422
+ * pre-sizes the grid via `initGrid` when the store supports it) exactly like {@link create}.
423
+ */
424
+ static fromEngine(inner: SpreadsheetEngineLike, sheets?: SheetInit[], options?: Pick<CreateEngineOptions, "gridRows" | "gridCols">): RncEngine;
425
+ /** Whether the backing engine is collaborative (implements the Yjs {@link CollabSync} surface). */
426
+ get isCollab(): boolean;
427
+ private collab;
428
+ /** Pre-size a sheet's grid on a positional/CRDT store. No-op for stores without `initGrid`. */
429
+ initGrid(sheetId: number, rows: number, cols: number): void;
430
+ /** Register a sheet (`id` → display name). */
431
+ addSheet(sheetId: number, name: string): void;
432
+ /** Begin a streaming hydration. Feed NDJSON byte chunks with {@link streamWrite}, then {@link streamEnd}. */
433
+ streamBegin(): void;
434
+ /** Ingest one NDJSON byte chunk (boundaries may fall anywhere — partial lines are buffered). */
435
+ streamWrite(chunk: Uint8Array): void;
436
+ /** Finish hydration: ingest the trailing line and recompute once. Read the viewport via `readWindow`. */
437
+ streamEnd(): void;
438
+ /**
439
+ * Hydrate from a byte stream of NDJSON records — e.g. `(await fetch(url)).body`. The 100 MB+
440
+ * workbook flows network → wasm in chunks and is never held whole in JS. Records are
441
+ * `{"t":"sheet"|"cell"|"style", …}` (see the Rust `StreamRecord`). Nothing is returned; call
442
+ * `readWindow` for the visible area once this resolves.
443
+ */
444
+ hydrateFromStream(stream: ReadableStream<Uint8Array>): Promise<void>;
445
+ /**
446
+ * Hydrate the engine from an initial document (sheets + cells + styles, the shape your API
447
+ * returns). Recomputes formulas and delivers the full change-set to {@link onChanges} subscribers
448
+ * — so initial load uses the exact same path as every other change. Returns it inline too.
449
+ */
450
+ load(document: LoadDocument): CommitResult;
451
+ /**
452
+ * Apply a `commands.ts` command. The resulting change-set is delivered to every
453
+ * {@link onChanges} subscriber; it's also returned for callers that want it inline.
454
+ */
455
+ applyCommand(command: Command): CommitResult;
456
+ /**
457
+ * Declare whether the host renders WINDOWED, so the backing engine can omit the per-cell commit
458
+ * channels the windowed render discards (it re-reads the viewport via {@link readWindow}). Forwarded
459
+ * to the injected engine's `setWindowed` when it implements it; a no-op otherwise (the windowed fold
460
+ * still ignores those channels correctly — it just pays to transfer them). Called once by the
461
+ * windowed hook after engine creation. See {@link SpreadsheetEngineLike.setWindowed}.
462
+ */
463
+ setWindowed(on: boolean): void;
464
+ /**
465
+ * Subscribe to the change-sets the engine produces. Returns an unsubscribe function.
466
+ *
467
+ * Today this fires synchronously after each {@link applyCommand}. The same API is the seam for
468
+ * out-of-band changes later — volatile recalc ticks, or Worker `postMessage` when calc moves off
469
+ * the main thread — without the UI's subscribe code changing.
470
+ */
471
+ onChanges(listener: ChangeListener): () => void;
472
+ /**
473
+ * Undo / redo the last document mutation in the engine. The resulting change-set (reverted input
474
+ * AND recomputed values, across any sheets touched) is delivered to {@link onChanges} subscribers.
475
+ */
476
+ undo(): CommitResult;
477
+ redo(): CommitResult;
478
+ /** Whether an undo / redo is currently available (for enabling toolbar buttons). */
479
+ canUndo(): boolean;
480
+ canRedo(): boolean;
481
+ /** Drop the entire undo/redo history (the document is unchanged). Backs `onClearHistory`. */
482
+ clearHistory(): void;
483
+ /** Undo / redo stack depth. A UI that keeps parallel per-edit state (cursor, selection, active
484
+ * sheet) watches these to push/pop its own snapshots in lockstep — a command that recorded an undo
485
+ * entry bumps `undoDepth`, so the UI knows whether to snapshot (and skips no-op-inverse commands). */
486
+ undoDepth(): number;
487
+ redoDepth(): number;
488
+ /** Read a 1-indexed, inclusive window of cells + consolidated styles. Prefers the LOSSLESS full-cell
489
+ * read (`readWindowCommit`): each cell is carried VERBATIM (`ue`/formula source, hyperlink, note, full
490
+ * `ev`) under `cell`, so the windowed render uses it as-is rather than reconstructing a lossy cell
491
+ * from a lean formatted/number/isFormula projection (which dropped `ue.fv` — the formula bar then
492
+ * showed the computed value, not `=SUM(4,4)`). Falls back to the lean `readWindow` for engines without
493
+ * it. The window is only viewport-sized, so carrying whole cells costs nothing. */
494
+ readWindow(sheetId: number, startRow: number, startCol: number, endRow: number, endCol: number): WindowSnapshot;
495
+ /**
496
+ * Selection statistics (sum / count / numericalCount / average / min / max) over a 1-indexed
497
+ * inclusive {@link SheetRange} — what the status bar shows for a selection. Computed in Rust over
498
+ * the stored cells, so it stays cheap even on a million-cell selection (no value round-trip to JS,
499
+ * no main-thread iteration — the reason the old JS path refused selections over ~200k cells).
500
+ *
501
+ * Returns `null` if the backing engine doesn't expose `rangeStats` (the host then falls back to
502
+ * its own JS computation). Numeric fields are `null` when the range holds no numbers.
503
+ */
504
+ rangeStats(range: SheetRange): RangeStats | null;
505
+ /** Off-window search: every cell on `sheetId` whose display text matches `find`, returned row-major
506
+ * (the order next/prev navigation walks). The windowed UI's JS search only sees the loaded viewport,
507
+ * so matches OUTSIDE it must come from the engine, which holds the whole document. `ranges` restricts
508
+ * the scope (whole sheet when omitted). Match-case / whole-word (`\b`) / regex mirror the JS search.
509
+ * Returns `[]` if the find is empty or the backing engine can't search. */
510
+ findAll(sheetId: number, find: string, options?: {
511
+ matchCase?: boolean;
512
+ wholeWord?: boolean;
513
+ useRegex?: boolean;
514
+ }, ranges?: SheetRange[]): SheetCoordinate[];
515
+ /** Scratch-evaluate `formula` at `(rowIndex, columnIndex)` on `sheetId` — the cell editor's live
516
+ * result preview. Read-only: nothing is installed or committed, no dirty marks; a host
517
+ * custom-function call (`=AOP(...)`) evaluates to `#NAME?` with NO `customEvals` request (host
518
+ * calls are recognised at set-value time only), so previewing can never fire one. Returns the
519
+ * result as an `ExtendedValue`, or `undefined` when the backing engine can't evaluate it (no
520
+ * capability, parse failure, unknown sheet, unpopulated engine). */
521
+ evalFormula(sheetId: number, rowIndex: number, columnIndex: number, formula: string): ExtendedValue | undefined;
522
+ /** Distinct fill/font colors + CF icons present in one column's body rows — the FilterBox
523
+ * "Filter by color" swatches, computed engine-side in ONE column scan (the windowed
524
+ * alternative to the JS per-row `getEffectiveFormat` scan). `undefined` when the backing
525
+ * engine doesn't expose it. */
526
+ filterColors(sheetId: number, columnIndex: number, startRow: number, endRow: number): {
527
+ cellColors: string[];
528
+ fontColors: string[];
529
+ icons: {
530
+ iconSet: string;
531
+ iconId: number;
532
+ }[];
533
+ } | undefined;
534
+ /** Sheet ids, in order. */
535
+ sheetIds(): number[];
536
+ /**
537
+ * Remove the host-seeded default `Sheet1` (sheetId 1) once a collab merge showed the workbook's
538
+ * real sheets live under other ids — without it, the seed's live structs ship with every outbound
539
+ * flush, materializing an empty ghost `Sheet1` tab for every collaborator (and re-materializing
540
+ * it after a peer's explicit delete-sheet). Call right after merging the collab doc, and ONLY
541
+ * when the persisted doc's sheet registry is non-empty and contains no sheetId 1; the store
542
+ * guards the rest (exact seed title, zero populated cells, ≥1 other sheet) and removes the seed
543
+ * WITHOUT a commit fan-out — the tombstones ride the next flushed update. No-op (returns false)
544
+ * on stores without a construction seed.
545
+ */
546
+ pruneDanglingDefaultSeed(): boolean;
547
+ /** The workbook's sheets in tab order — the engine's AUTHORITATIVE identity/order/titles (it
548
+ * generates ids for `create-sheet`, rewrites titles on rename, reorders on move). A thin UI
549
+ * reconciles its tab list from this after each commit. Returns `[]` if the backing engine doesn't
550
+ * expose it (the hook then keeps its seeded sheet list). */
551
+ sheets(): EngineSheet[];
552
+ /** Per-sheet 1-based data extent: `[sheetId, rowCount, columnCount][]`. A windowed renderer sizes
553
+ * the grid's scroll extent to this (so it holds only the visible viewport in JS yet scrolls the
554
+ * full sheet). Returns `[]` if the backing engine doesn't expose extents. */
555
+ sheetExtents(): Array<[number, number, number]>;
556
+ /** A sheet's display values as RFC-4180 CSV. Empty string if the backing engine can't export. */
557
+ exportCsv(sheetId: number): string;
558
+ /** The whole workbook as in-memory XLSX bytes (a `Uint8Array`), or `undefined` if the backing
559
+ * engine wasn't built with export support. Reads the full document inside the engine (works even in
560
+ * windowed mode, where the JS side holds only the viewport). */
561
+ exportXlsx(): Uint8Array | undefined;
562
+ /**
563
+ * Import an `.xlsx` workbook with the native Rust reader (`rnc-import`), REPLACING the engine's
564
+ * document, and return the full {@link CommitResult} (every cell + style + structural change — the
565
+ * same shape as {@link load}). Returns `undefined` if the backend has no import capability.
566
+ *
567
+ * NOTE: unlike {@link load}, this does NOT notify {@link onChanges} subscribers — because import is a
568
+ * full replace, the caller must reset its render state and fold this commit onto sheets seeded from
569
+ * {@link sheets} (merges/dimensions fold only onto pre-existing sheet objects). The windowed hook's
570
+ * `importXlsx` does exactly that. Only backends whose commit shape matches {@link CommitResult}
571
+ * (rnc-engine's built-in engine) are driven here; the collab (yrs-store) engine imports via its delta.
572
+ */
573
+ importXlsx(bytes: Uint8Array): CommitResult | undefined;
574
+ /** Raw JSON of {@link documentFacets} — the hook diffs this string against the previous commit's to
575
+ * skip a no-op facet update (so a pure cell edit doesn't churn the facet props and re-render the grid). */
576
+ documentFacetsJson(): string;
577
+ /** The document-level facets the renderer draws (CF rules, tables, named/protected ranges, embeds,
578
+ * slicers, banded ranges, basic filters, DV rules) in their canonical shapes. Cheap and re-read by
579
+ * the thin hook once per commit — they're small and change rarely, so they ride this getter rather
580
+ * than a per-facet `CommitResult` channel. */
581
+ documentFacets(): DocumentFacets;
582
+ /** Register a host (JS) custom-function NAME so `=NAME(…)` resolves (deps tracked) instead of
583
+ * `#NAME?`. On recalc the engine emits a `customEvals` request the host answers via
584
+ * `setEffectiveValue`. (The function body itself lives in JS — see the hook's
585
+ * `registerCustomFunction`, which pairs this with the resolve loop.) */
586
+ registerCustomFunction(name: string): void;
587
+ /** The PRECEDENTS of a cell — the cells + ranges its formula references (engine-parsed, exact). The
588
+ * engine owns the dependency data, so `getPrecedents` is backed by real graph data, not a stub. */
589
+ precedents(sheetId: number, rowIndex: number, columnIndex: number): {
590
+ cells: SheetCoordinate[];
591
+ ranges: SheetRange[];
592
+ };
593
+ /** The DEPENDENTS of a cell — every formula cell that references it (directly or within a range). */
594
+ dependents(sheetId: number, rowIndex: number, columnIndex: number): SheetCoordinate[];
595
+ /** Apply a remote Yjs v1 update (a peer's / yhub's delta) into the CRDT doc, rebuild, and fold the
596
+ * resulting change-set to {@link onChanges} subscribers. Returns it inline too. Throws if the
597
+ * backing engine isn't collaborative ({@link isCollab}). */
598
+ applyRemoteUpdate(update: Uint8Array): CommitResult;
599
+ /** Encode the full document state as a Yjs v1 update (initial sync to a peer / persistence). */
600
+ encodeStateAsUpdate(): Uint8Array;
601
+ /** Encode this peer's Yjs state vector (a compact summary of what it has seen). */
602
+ encodeStateVector(): Uint8Array;
603
+ /** Encode the diff a remote peer (identified by its state vector) is missing — apply the result to
604
+ * the transport doc (`Y.applyUpdate`) to propagate local edits. */
605
+ encodeDiffV1(remoteStateVector: Uint8Array): Uint8Array;
606
+ /** Release the underlying wasm memory. */
607
+ free(): void;
608
+ /** Fold `StyleEntry[]` into the consolidated `Map<"sheetId!A1", CellFormat>` the UI consumes.
609
+ * A `null` format clears the entry. */
610
+ static toStyleMap(styles: StyleEntry[]): Map<string, CellFormat>;
611
+ }
612
+ export { CollabSpreadsheetEngine };
613
+ export { cellKey, columnLabel, parseCellKey } from "./keys";
614
+ export * from "./fold";
615
+ export { useEngineCore, type CustomFunctionContext, type CustomFunctionImpl, type EngineSpreadsheet, type UseEngineSpreadsheetOptions, } from "./use-engine-core";
616
+ export { useSpreadsheetUI, type SpreadsheetUI, type DialogName, } from "./use-spreadsheet-ui";
617
+ export { useSpreadsheetEngine, type SpreadsheetEngine, } from "./use-spreadsheet-engine";
618
+ export { useEnginePivotEditor, VALUES_PIVOT_FIELD, type EnginePivotField, type UseEnginePivotEditorParams, } from "./use-engine-pivot-editor";
619
+ export { parseWorkbook, importXlsx, importOds, importCsv, streamWorkbookInto, exportXlsx, exportOds, exportCsv, type ParsedWorkbook, type ImportOptions, } from "./io";
620
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,KAAK,EACV,QAAQ,EACR,UAAU,EACV,aAAa,EACb,QAAQ,EACR,kBAAkB,EAClB,aAAa,EACb,eAAe,EACf,UAAU,EACX,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EACV,WAAW,EACX,qBAAqB,EACrB,wBAAwB,EACxB,aAAa,EACb,cAAc,EACd,UAAU,EACV,UAAU,EACV,UAAU,EACV,cAAc,EACd,KAAK,EACL,MAAM,EACN,SAAS,EACV,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EACV,OAAO,EACP,SAAS,EACT,WAAW,EACZ,MAAM,iCAAiC,CAAC;AAGzC,OAAa,EACX,uBAAuB,EAExB,MAAM,oBAAoB,CAAC;AAE5B,YAAY,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,CAAC;AAEhD;;;;GAIG;AAEH,4FAA4F;AAC5F,MAAM,MAAM,UAAU,GAAG,aAAa,GAAG;IACvC,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,SAAS,EAAE,OAAO,CAAC;IACnB;oEACgE;IAChE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;kGAE8F;IAC9F,IAAI,CAAC,EAAE,QAAQ,CAAC;CACjB,CAAC;AAEF;mFACmF;AACnF,MAAM,MAAM,UAAU,GAAG,eAAe,GAAG;IACzC,MAAM,EAAE,UAAU,GAAG,IAAI,CAAC;CAC3B,CAAC;AAE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