@rowsncolumns/rnc-yrs-store 0.29.7 → 0.30.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.
@@ -188,6 +188,25 @@ export class SpreadsheetEngine {
188
188
  * differs from the engine's is written.
189
189
  */
190
190
  flushRemoteDirty(): string;
191
+ /**
192
+ * Whether the document is waiting on an update it has not received: an inbound update is
193
+ * deferred on a causal gap, or the document holds content it cannot integrate yet. Read it
194
+ * after a load: a stored state that lacks the start of some session's writes is not loaded,
195
+ * and the workbook reads as empty (`sheets()` is `[]`) with this `true`. A host must not
196
+ * seed a first sheet or write into such a workbook (rowsncolumns/spreadsheet#1874).
197
+ */
198
+ hasMissingUpdates(): boolean;
199
+ /**
200
+ * Whether the workbook holds a volatile formula: a cell, or a defined name, whose formula
201
+ * calls `NOW`, `TODAY`, `RAND`, `RANDBETWEEN`, `RANDARRAY`, `OFFSET`, `INDIRECT`, `INFO` or
202
+ * `CELL`. A formula that only reads such a cell or name does not count on its own; the cell
203
+ * or name it reads does. Read from the calc engine's graph, so it follows this session's
204
+ * edits and every merged one (a collaborator's `=NOW()` turns it true once merged), and it
205
+ * is `false` while the engine holds no graph (a document past the populate caps). The cost
206
+ * is the volatile formulas and their readers, not the workbook. A host asks this before
207
+ * `recalculateVolatile`.
208
+ */
209
+ hasVolatileFormulas(): boolean;
191
210
  /**
192
211
  * Every HOST-OWNED formula cell on a sheet (registered custom-function calls + dot accessors)
193
212
  * as a `CellChange[]` JSON, row-major (`SpreadsheetEngineLike.hostOwnedCells`). The index-backed
@@ -335,6 +354,19 @@ export class SpreadsheetEngine {
335
354
  * they can discard on failure. See [`YDocEngine::rebuild_and_recalc`].
336
355
  */
337
356
  rebuildAndRecalc(): void;
357
+ /**
358
+ * Calculate the volatile formulas and what reads them, and nothing else that is up to date,
359
+ * returning the `CommitResult` JSON (the cells whose result changed, like
360
+ * `flushRemoteDirty`). For a session that only reads (a viewer, a reopen from a device
361
+ * copy, a server-side export): `NOW()` and `TODAY()` then show the present instead of what
362
+ * the last writer stored, at the cost of those formulas and their readers instead of a full
363
+ * `recalculate`. Accepted in read-only mode (`setReadOnly`), where what it computes shows
364
+ * and is held: nothing reaches the document, `takePendingUpdates` or `encodeDiffV1`. Off
365
+ * read-only mode the changed results are written back, as after any calculation. Does
366
+ * nothing when `hasVolatileFormulas()` is false, and nothing in Manual calculation, where
367
+ * volatile formulas wait for `recalculate` (F9) as in Excel.
368
+ */
369
+ recalculateVolatile(): string;
338
370
  redo(): string;
339
371
  redoDepth(): number;
340
372
  /**
@@ -374,8 +406,15 @@ export class SpreadsheetEngine {
374
406
  * and `declareExternalFunctions` (of a name the room does not declare yet) throw
375
407
  * (`read-only-mode: …`), `addSheet` adds nothing, and `anchorRange` and `compactStyleLog`
376
408
  * write nothing.
409
+ *
410
+ * Switched off after a merge in the mode, a positional room gets the repair a merge able to
411
+ * write would have made: a cell the room holds from before a row or column insert, delete
412
+ * or move its author had not heard of is moved to where that edit puts it, as a session
413
+ * that opens the room able to write moves it at open. When that moved anything the call
414
+ * returns its `CommitResult` JSON, to be painted as `syncRemote`'s is; otherwise
415
+ * `undefined`.
377
416
  */
378
- setReadOnly(on: boolean): void;
417
+ setReadOnly(on: boolean): string | undefined;
379
418
  /**
380
419
  * Create stable-ids (v5) documents with this engine; off by default. On, the document this
381
420
  * engine itself creates starts as v5: the first edit or import of an engine that was never
@@ -453,6 +492,35 @@ export class SpreadsheetEngine {
453
492
  * [`YrsStore::shift_log_frontier`]).
454
493
  */
455
494
  shiftLogFrontier(): string;
495
+ /**
496
+ * The commit a load returns, WITHOUT ITS CELLS: every channel of `loadFromUpdate`'s answer
497
+ * but `changes` (`styleChanges`: the formats cells hold of their own; `noteChanges`;
498
+ * `rowChanges` / `columnChanges`; `merges`; `chartChanges`; `pivotChanges`;
499
+ * `conditionalFormats`; `dataValidations`; `citations`), read from the document as it stands
500
+ * now. No cell is read to build it, so it costs what those channels hold, not what the room
501
+ * holds: load with `loadFromUpdateQuiet`, take this, and read the cells in bands
502
+ * (`readWindowCells`) or not at all. A windowed load followed by `takeOmittedCells` returns
503
+ * the same channels and every cell of the room with them.
504
+ *
505
+ * Two exceptions. On a sheet with a filter applied it lists one `rowChanges` entry per row
506
+ * of the filter and reads the filtered column to do so, as a load's commit does. In a room
507
+ * imported from xlsx the formats and the notes are on the cells and are not listed here:
508
+ * read them with the cells (`readWindowCells`).
509
+ *
510
+ * The per-cell channels are whole whatever `setCommitWindows` says. Taking this moves no
511
+ * value and takes nothing: `takeOmittedCells` still hands over what the last commit left
512
+ * out, and the load's capped formulas stay to be taken. It does derive the rows a filter
513
+ * hides if nothing had derived them yet, as `documentFacets` does: on a sheet with a filter
514
+ * and no formula, a later retype of a filtered cell can then hide other rows than it would
515
+ * have. And a session that goes on afterwards can list its answers and send its updates in
516
+ * another order. A session that loads quietly, reads and ends has nothing later to change.
517
+ *
518
+ * Formats, notes, charts and pivots are listed in a fixed order (by place, by id), where a
519
+ * load's commit lists them in the order its maps iterate. Like a load's commit it carries no
520
+ * `validations` and no `derivedFormatChanges`: a load reports no cell's validity, even for
521
+ * a cell that breaks its rule (the rules themselves are in `dataValidations`).
522
+ */
523
+ snapshotWithoutCells(): string;
456
524
  /**
457
525
  * The `rncCells` key (`"{sheetId}:{rowId}:{colId}"`) of 1-based `(row, col)`; `undefined`
458
526
  * while the row or column is unnamed (past the sheet's named extent). Never names lines.
@@ -636,6 +704,8 @@ export interface InitOutput {
636
704
  readonly spreadsheetengine_findAll: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => [number, number];
637
705
  readonly spreadsheetengine_findAllBounded: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => [number, number];
638
706
  readonly spreadsheetengine_flushRemoteDirty: (a: number) => [number, number];
707
+ readonly spreadsheetengine_hasMissingUpdates: (a: number) => number;
708
+ readonly spreadsheetengine_hasVolatileFormulas: (a: number) => number;
639
709
  readonly spreadsheetengine_hostOwnedCells: (a: number, b: number) => [number, number];
640
710
  readonly spreadsheetengine_importCsv: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
641
711
  readonly spreadsheetengine_importDelimited: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number, number];
@@ -660,12 +730,13 @@ export interface InitOutput {
660
730
  readonly spreadsheetengine_readWindowCells: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];
661
731
  readonly spreadsheetengine_readWindowCommit: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];
662
732
  readonly spreadsheetengine_rebuildAndRecalc: (a: number) => void;
733
+ readonly spreadsheetengine_recalculateVolatile: (a: number) => [number, number];
663
734
  readonly spreadsheetengine_redo: (a: number) => [number, number];
664
735
  readonly spreadsheetengine_redoDepth: (a: number) => number;
665
736
  readonly spreadsheetengine_registerCustomFunction: (a: number, b: number, c: number) => void;
666
737
  readonly spreadsheetengine_scenarios: (a: number) => [number, number];
667
738
  readonly spreadsheetengine_setCommitWindows: (a: number, b: number, c: number) => [number, number];
668
- readonly spreadsheetengine_setReadOnly: (a: number, b: number) => void;
739
+ readonly spreadsheetengine_setReadOnly: (a: number, b: number) => [number, number];
669
740
  readonly spreadsheetengine_setStableIds: (a: number, b: number) => [number, number, number];
670
741
  readonly spreadsheetengine_setTimezoneOffsetMinutes: (a: number, b: number) => number;
671
742
  readonly spreadsheetengine_setWindowed: (a: number, b: number) => void;
@@ -677,6 +748,7 @@ export interface InitOutput {
677
748
  readonly spreadsheetengine_sheetMetas: (a: number) => [number, number];
678
749
  readonly spreadsheetengine_sheetStats: (a: number) => [number, number];
679
750
  readonly spreadsheetengine_sheets: (a: number) => [number, number];
751
+ readonly spreadsheetengine_snapshotWithoutCells: (a: number) => [number, number, number, number];
680
752
  readonly spreadsheetengine_staleFormulaCells: (a: number, b: number) => [number, number];
681
753
  readonly spreadsheetengine_styleLogStats: (a: number) => [number, number];
682
754
  readonly spreadsheetengine_syncRemote: (a: number) => [number, number];
@@ -632,6 +632,33 @@ export class SpreadsheetEngine {
632
632
  wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
633
633
  }
634
634
  }
635
+ /**
636
+ * Whether the document is waiting on an update it has not received: an inbound update is
637
+ * deferred on a causal gap, or the document holds content it cannot integrate yet. Read it
638
+ * after a load: a stored state that lacks the start of some session's writes is not loaded,
639
+ * and the workbook reads as empty (`sheets()` is `[]`) with this `true`. A host must not
640
+ * seed a first sheet or write into such a workbook (rowsncolumns/spreadsheet#1874).
641
+ * @returns {boolean}
642
+ */
643
+ hasMissingUpdates() {
644
+ const ret = wasm.spreadsheetengine_hasMissingUpdates(this.__wbg_ptr);
645
+ return ret !== 0;
646
+ }
647
+ /**
648
+ * Whether the workbook holds a volatile formula: a cell, or a defined name, whose formula
649
+ * calls `NOW`, `TODAY`, `RAND`, `RANDBETWEEN`, `RANDARRAY`, `OFFSET`, `INDIRECT`, `INFO` or
650
+ * `CELL`. A formula that only reads such a cell or name does not count on its own; the cell
651
+ * or name it reads does. Read from the calc engine's graph, so it follows this session's
652
+ * edits and every merged one (a collaborator's `=NOW()` turns it true once merged), and it
653
+ * is `false` while the engine holds no graph (a document past the populate caps). The cost
654
+ * is the volatile formulas and their readers, not the workbook. A host asks this before
655
+ * `recalculateVolatile`.
656
+ * @returns {boolean}
657
+ */
658
+ hasVolatileFormulas() {
659
+ const ret = wasm.spreadsheetengine_hasVolatileFormulas(this.__wbg_ptr);
660
+ return ret !== 0;
661
+ }
635
662
  /**
636
663
  * Every HOST-OWNED formula cell on a sheet (registered custom-function calls + dot accessors)
637
664
  * as a `CellChange[]` JSON, row-major (`SpreadsheetEngineLike.hostOwnedCells`). The index-backed
@@ -1132,6 +1159,31 @@ export class SpreadsheetEngine {
1132
1159
  rebuildAndRecalc() {
1133
1160
  wasm.spreadsheetengine_rebuildAndRecalc(this.__wbg_ptr);
1134
1161
  }
1162
+ /**
1163
+ * Calculate the volatile formulas and what reads them, and nothing else that is up to date,
1164
+ * returning the `CommitResult` JSON (the cells whose result changed, like
1165
+ * `flushRemoteDirty`). For a session that only reads (a viewer, a reopen from a device
1166
+ * copy, a server-side export): `NOW()` and `TODAY()` then show the present instead of what
1167
+ * the last writer stored, at the cost of those formulas and their readers instead of a full
1168
+ * `recalculate`. Accepted in read-only mode (`setReadOnly`), where what it computes shows
1169
+ * and is held: nothing reaches the document, `takePendingUpdates` or `encodeDiffV1`. Off
1170
+ * read-only mode the changed results are written back, as after any calculation. Does
1171
+ * nothing when `hasVolatileFormulas()` is false, and nothing in Manual calculation, where
1172
+ * volatile formulas wait for `recalculate` (F9) as in Excel.
1173
+ * @returns {string}
1174
+ */
1175
+ recalculateVolatile() {
1176
+ let deferred1_0;
1177
+ let deferred1_1;
1178
+ try {
1179
+ const ret = wasm.spreadsheetengine_recalculateVolatile(this.__wbg_ptr);
1180
+ deferred1_0 = ret[0];
1181
+ deferred1_1 = ret[1];
1182
+ return getStringFromWasm0(ret[0], ret[1]);
1183
+ } finally {
1184
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1185
+ }
1186
+ }
1135
1187
  /**
1136
1188
  * @returns {string}
1137
1189
  */
@@ -1250,10 +1302,24 @@ export class SpreadsheetEngine {
1250
1302
  * and `declareExternalFunctions` (of a name the room does not declare yet) throw
1251
1303
  * (`read-only-mode: …`), `addSheet` adds nothing, and `anchorRange` and `compactStyleLog`
1252
1304
  * write nothing.
1305
+ *
1306
+ * Switched off after a merge in the mode, a positional room gets the repair a merge able to
1307
+ * write would have made: a cell the room holds from before a row or column insert, delete
1308
+ * or move its author had not heard of is moved to where that edit puts it, as a session
1309
+ * that opens the room able to write moves it at open. When that moved anything the call
1310
+ * returns its `CommitResult` JSON, to be painted as `syncRemote`'s is; otherwise
1311
+ * `undefined`.
1253
1312
  * @param {boolean} on
1313
+ * @returns {string | undefined}
1254
1314
  */
1255
1315
  setReadOnly(on) {
1256
- wasm.spreadsheetengine_setReadOnly(this.__wbg_ptr, on);
1316
+ const ret = wasm.spreadsheetengine_setReadOnly(this.__wbg_ptr, on);
1317
+ let v1;
1318
+ if (ret[0] !== 0) {
1319
+ v1 = getStringFromWasm0(ret[0], ret[1]).slice();
1320
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1321
+ }
1322
+ return v1;
1257
1323
  }
1258
1324
  /**
1259
1325
  * Create stable-ids (v5) documents with this engine; off by default. On, the document this
@@ -1444,6 +1510,53 @@ export class SpreadsheetEngine {
1444
1510
  wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1445
1511
  }
1446
1512
  }
1513
+ /**
1514
+ * The commit a load returns, WITHOUT ITS CELLS: every channel of `loadFromUpdate`'s answer
1515
+ * but `changes` (`styleChanges`: the formats cells hold of their own; `noteChanges`;
1516
+ * `rowChanges` / `columnChanges`; `merges`; `chartChanges`; `pivotChanges`;
1517
+ * `conditionalFormats`; `dataValidations`; `citations`), read from the document as it stands
1518
+ * now. No cell is read to build it, so it costs what those channels hold, not what the room
1519
+ * holds: load with `loadFromUpdateQuiet`, take this, and read the cells in bands
1520
+ * (`readWindowCells`) or not at all. A windowed load followed by `takeOmittedCells` returns
1521
+ * the same channels and every cell of the room with them.
1522
+ *
1523
+ * Two exceptions. On a sheet with a filter applied it lists one `rowChanges` entry per row
1524
+ * of the filter and reads the filtered column to do so, as a load's commit does. In a room
1525
+ * imported from xlsx the formats and the notes are on the cells and are not listed here:
1526
+ * read them with the cells (`readWindowCells`).
1527
+ *
1528
+ * The per-cell channels are whole whatever `setCommitWindows` says. Taking this moves no
1529
+ * value and takes nothing: `takeOmittedCells` still hands over what the last commit left
1530
+ * out, and the load's capped formulas stay to be taken. It does derive the rows a filter
1531
+ * hides if nothing had derived them yet, as `documentFacets` does: on a sheet with a filter
1532
+ * and no formula, a later retype of a filtered cell can then hide other rows than it would
1533
+ * have. And a session that goes on afterwards can list its answers and send its updates in
1534
+ * another order. A session that loads quietly, reads and ends has nothing later to change.
1535
+ *
1536
+ * Formats, notes, charts and pivots are listed in a fixed order (by place, by id), where a
1537
+ * load's commit lists them in the order its maps iterate. Like a load's commit it carries no
1538
+ * `validations` and no `derivedFormatChanges`: a load reports no cell's validity, even for
1539
+ * a cell that breaks its rule (the rules themselves are in `dataValidations`).
1540
+ * @returns {string}
1541
+ */
1542
+ snapshotWithoutCells() {
1543
+ let deferred2_0;
1544
+ let deferred2_1;
1545
+ try {
1546
+ const ret = wasm.spreadsheetengine_snapshotWithoutCells(this.__wbg_ptr);
1547
+ var ptr1 = ret[0];
1548
+ var len1 = ret[1];
1549
+ if (ret[3]) {
1550
+ ptr1 = 0; len1 = 0;
1551
+ throw takeFromExternrefTable0(ret[2]);
1552
+ }
1553
+ deferred2_0 = ptr1;
1554
+ deferred2_1 = len1;
1555
+ return getStringFromWasm0(ptr1, len1);
1556
+ } finally {
1557
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
1558
+ }
1559
+ }
1447
1560
  /**
1448
1561
  * The `rncCells` key (`"{sheetId}:{rowId}:{colId}"`) of 1-based `(row, col)`; `undefined`
1449
1562
  * while the row or column is unnamed (past the sheet's named extent). Never names lines.
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rowsncolumns/rnc-yrs-store",
3
- "version": "0.29.7",
3
+ "version": "0.30.0",
4
4
  "author": "Vinay M",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "description": "Document-backed Rust→WASM spreadsheet calc engine (yrs/CRDT, canonical sheetDataV3). Ships the `SpreadsheetEngine` (a `Store<YrsStore>`): applyCommand / undo / redo / canUndo + the Yjs collaboration surface (applyUpdate / takePendingUpdates / loadFromUpdate / stateAsUpdate) the Keryx update-pump binds to. This is the 1,000,000-row engine the demo-app ships today — previously vendored, now a versioned package. The PREBUILT wasm is included (consumers need NO Rust/wasm toolchain); the glue's default init REQUIRES an explicit `module_or_path` — pass the URL of the served `rnc_yrs_store_bg.wasm` (webpack/Turbopack statically resolve a bundled `new URL`, which would 404 from this package, so the inline-default branch is intentionally a throw).",