@rowsncolumns/rnc-yrs-store 0.28.1 → 0.29.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -311,6 +311,10 @@ export class SpreadsheetEngine {
311
311
  * sheet registry is non-empty and contains no `sheetId: 1`. Returns `true` when pruned.
312
312
  */
313
313
  pruneDanglingDefaultSeed(): boolean;
314
+ /**
315
+ * Whether read-only mode is on (`setReadOnly`).
316
+ */
317
+ readOnly(): boolean;
314
318
  readWindow(sheet_id: number, start_row: number, start_col: number, end_row: number, end_col: number): string;
315
319
  /**
316
320
  * A window's cells + effective styles as COMPACT JSON —
@@ -357,6 +361,16 @@ export class SpreadsheetEngine {
357
361
  * clears them (commits whole again). Takes effect from the next commit.
358
362
  */
359
363
  setCommitWindows(windows_json: string): void;
364
+ /**
365
+ * Read-only mode, which the host sets from the room's grant: while on, the engine writes
366
+ * nothing to the document. Recalculations still run and show what they compute (a volatile
367
+ * `NOW()` included), held in the engine; no write-back, display refresh, link, computed
368
+ * value or merge repair reaches `takePendingUpdates` or `encodeDiffV1`, and every command but
369
+ * a calculation (`recalculate`, `calculate-sheet`, `calculate-full`) is refused (rejection
370
+ * code `read-only-mode`). Off again, the held results are dropped and the document's values
371
+ * show. Off by default.
372
+ */
373
+ setReadOnly(on: boolean): void;
360
374
  /**
361
375
  * Create stable-ids (v5) documents with this engine; off by default. On, the document this
362
376
  * engine itself creates starts as v5: the first edit or import of an engine that was never
@@ -540,31 +554,32 @@ export class YrsSheetDoc {
540
554
  * `positional_state` is the document's whole state as one v1 update (what `encodeStateAsUpdate`
541
555
  * gives). The result is the converted document's whole state as one v1 update. It loads in a
542
556
  * fresh engine as an ordinary v5 document and reads, cell for cell and facet for facet, what the
543
- * input read on the positional store. The positional entries the conversion read are not in the
544
- * result; an entry of a shape this engine does not know stays where it is and reads `#UNKNOWN!`,
545
- * as it does on both stores.
557
+ * input read on the positional store. The result is a document of its own: read its content and
558
+ * copy it into a room, never merge its bytes into one. Two conversions of the same input read the
559
+ * same; their bytes are not the same.
546
560
  *
547
- * The result is a document of its own: read its content and copy it into a room, never merge
548
- * its bytes into one (the room was converted by another run, under other ids). Two conversions
549
- * of the same input read the same; their bytes are not the same.
561
+ * Without `line_ids_json` (`undefined` or `null`) each line takes the client-0 id of its position,
562
+ * as a room's own conversion names them ([`convert_to_stable_ids`]). With it, each line takes the
563
+ * id the map gives its position and a fresh id `make_id(freshClient, n)` where it gives none
564
+ * ([`convert_to_stable_ids_with_line_ids`]): `{"freshClient": <1..=2^32-1>, "sheets":
565
+ * {"<sheetId>": {"rowIds": [<id> | null, …], "columnIds": [<id> | null, …]}}}`, an id as its
566
+ * decimal string (as `rowIds` / `columnIds` give them). A host restoring a version saved before its
567
+ * room was converted gives the room's ids to the lines the room still has, so a reference the room
568
+ * keeps on a line stays on that line, and fresh ids to the rest (a `freshClient` the room never
569
+ * used), so a reference never lands on another line.
550
570
  *
551
- * Refuses with no result (wasm: throws the message; Rust: `Err`). The message starts with:
552
- * * `already-stable-ids` ([`CONVERT_ALREADY_STABLE_IDS`]): the input is already v5;
553
- * * `newer-format` ([`CONVERT_NEWER_FORMAT`]): the input is stamped with a data format after v5;
554
- * * `migration-refused` ([`crate::MIGRATION_REFUSED`]): a `sheet-format.cells` the migration of
555
- * this engine does not convert;
556
- * * `invalid-document` ([`CONVERT_INVALID_DOCUMENT`]): bytes that are not a v1 update, an update
557
- * that is not a whole state, a document that holds no sheet and no cell, or a positional
558
- * entry outside the grid (row 0, or past row 1,048,576 or column 16,384);
559
- * * `convert-failed` ([`CONVERT_FAILED`]): the migration would leave a positional entry out of
560
- * the converted document (two entries for one cell, for one), or the engine failed.
561
- *
562
- * It runs the migration a load into the v5 store runs ([`YrsStore::migrate_to_v5`]) on a store
563
- * of its own, twice: once keeping the positional plane, to check that the v5 document holds
564
- * every positional entry, then once deleting what it read, for the result. No engine session,
565
- * no calc engine. An engine still never converts a document it is handed (`dual.rs`).
571
+ * Throws, with no result, a message that starts with:
572
+ * * `already-stable-ids`: the input is already v5;
573
+ * * `newer-format`: the input is stamped with a data format after v5;
574
+ * * `migration-refused`: a `sheet-format.cells` the migration of this engine does not convert;
575
+ * * `invalid-document`: bytes that are not a v1 update, an update that is not a whole state, a
576
+ * document that holds no sheet and no cell, or a positional entry outside the grid;
577
+ * * `convert-failed`: the migration would leave a positional entry out, or the engine failed;
578
+ * * `invalid-line-ids`: a map that is not the shape above, a fresh client of 0 or past 32 bits, an
579
+ * id that is no line id, an id of the fresh client, one id named twice on an axis, a sheet the
580
+ * document does not hold, or a sheet whose lines are already named.
566
581
  */
567
- export function convertToStableIds(positional_state: Uint8Array): Uint8Array;
582
+ export function convertToStableIds(positional_state: Uint8Array, line_ids_json?: string | null): Uint8Array;
568
583
 
569
584
  /**
570
585
  * Engine-less resolution of a `GridRange` on `sheet_id` through an op list in application order
@@ -634,6 +649,7 @@ export interface InitOutput {
634
649
  readonly spreadsheetengine_parseCsv: (a: number, b: number, c: number) => [number, number, number, number];
635
650
  readonly spreadsheetengine_precedents: (a: number, b: number, c: number, d: number) => [number, number];
636
651
  readonly spreadsheetengine_pruneDanglingDefaultSeed: (a: number) => number;
652
+ readonly spreadsheetengine_readOnly: (a: number) => number;
637
653
  readonly spreadsheetengine_readWindow: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];
638
654
  readonly spreadsheetengine_readWindowCells: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];
639
655
  readonly spreadsheetengine_readWindowCommit: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];
@@ -643,6 +659,7 @@ export interface InitOutput {
643
659
  readonly spreadsheetengine_registerCustomFunction: (a: number, b: number, c: number) => void;
644
660
  readonly spreadsheetengine_scenarios: (a: number) => [number, number];
645
661
  readonly spreadsheetengine_setCommitWindows: (a: number, b: number, c: number) => [number, number];
662
+ readonly spreadsheetengine_setReadOnly: (a: number, b: number) => void;
646
663
  readonly spreadsheetengine_setStableIds: (a: number, b: number) => [number, number, number];
647
664
  readonly spreadsheetengine_setTimezoneOffsetMinutes: (a: number, b: number) => number;
648
665
  readonly spreadsheetengine_setWindowed: (a: number, b: number) => void;
@@ -672,16 +689,16 @@ export interface InitOutput {
672
689
  readonly yrssheetdoc_new: () => number;
673
690
  readonly yrssheetdoc_setCell: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];
674
691
  readonly spreadsheetengine_stateAsUpdate: (a: number) => [number, number];
692
+ readonly convertToStableIds: (a: number, b: number, c: number, d: number) => [number, number, number, number];
675
693
  readonly spreadsheetengine_anchorRange: (a: number, b: number, c: number, d: number) => [number, number, number, number];
676
- readonly spreadsheetengine_resolveAnchor: (a: number, b: number, c: number) => [number, number, number, number];
677
- readonly spreadsheetengine_shiftLogFrontier: (a: number) => [number, number];
678
- readonly spreadsheetengine_transformRange: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number, number];
679
- readonly transformRangeThroughOps: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
680
- readonly convertToStableIds: (a: number, b: number) => [number, number, number, number];
681
694
  readonly spreadsheetengine_columnIds: (a: number, b: number) => [number, number];
682
695
  readonly spreadsheetengine_parseStableCellKey: (a: number, b: number, c: number) => [number, number];
696
+ readonly spreadsheetengine_resolveAnchor: (a: number, b: number, c: number) => [number, number, number, number];
683
697
  readonly spreadsheetengine_rowIds: (a: number, b: number) => [number, number];
698
+ readonly spreadsheetengine_shiftLogFrontier: (a: number) => [number, number];
684
699
  readonly spreadsheetengine_stableCellKey: (a: number, b: number, c: number, d: number) => [number, number];
700
+ readonly spreadsheetengine_transformRange: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number, number];
701
+ readonly transformRangeThroughOps: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
685
702
  readonly __wbindgen_malloc: (a: number, b: number) => number;
686
703
  readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
687
704
  readonly __wbindgen_free: (a: number, b: number, c: number) => void;
@@ -1049,6 +1049,14 @@ export class SpreadsheetEngine {
1049
1049
  const ret = wasm.spreadsheetengine_pruneDanglingDefaultSeed(this.__wbg_ptr);
1050
1050
  return ret !== 0;
1051
1051
  }
1052
+ /**
1053
+ * Whether read-only mode is on (`setReadOnly`).
1054
+ * @returns {boolean}
1055
+ */
1056
+ readOnly() {
1057
+ const ret = wasm.spreadsheetengine_readOnly(this.__wbg_ptr);
1058
+ return ret !== 0;
1059
+ }
1052
1060
  /**
1053
1061
  * @param {number} sheet_id
1054
1062
  * @param {number} start_row
@@ -1229,6 +1237,19 @@ export class SpreadsheetEngine {
1229
1237
  throw takeFromExternrefTable0(ret[0]);
1230
1238
  }
1231
1239
  }
1240
+ /**
1241
+ * Read-only mode, which the host sets from the room's grant: while on, the engine writes
1242
+ * nothing to the document. Recalculations still run and show what they compute (a volatile
1243
+ * `NOW()` included), held in the engine; no write-back, display refresh, link, computed
1244
+ * value or merge repair reaches `takePendingUpdates` or `encodeDiffV1`, and every command but
1245
+ * a calculation (`recalculate`, `calculate-sheet`, `calculate-full`) is refused (rejection
1246
+ * code `read-only-mode`). Off again, the held results are dropped and the document's values
1247
+ * show. Off by default.
1248
+ * @param {boolean} on
1249
+ */
1250
+ setReadOnly(on) {
1251
+ wasm.spreadsheetengine_setReadOnly(this.__wbg_ptr, on);
1252
+ }
1232
1253
  /**
1233
1254
  * Create stable-ids (v5) documents with this engine; off by default. On, the document this
1234
1255
  * engine itself creates starts as v5: the first edit or import of an engine that was never
@@ -1758,42 +1779,46 @@ if (Symbol.dispose) YrsSheetDoc.prototype[Symbol.dispose] = YrsSheetDoc.prototyp
1758
1779
  * `positional_state` is the document's whole state as one v1 update (what `encodeStateAsUpdate`
1759
1780
  * gives). The result is the converted document's whole state as one v1 update. It loads in a
1760
1781
  * fresh engine as an ordinary v5 document and reads, cell for cell and facet for facet, what the
1761
- * input read on the positional store. The positional entries the conversion read are not in the
1762
- * result; an entry of a shape this engine does not know stays where it is and reads `#UNKNOWN!`,
1763
- * as it does on both stores.
1764
- *
1765
- * The result is a document of its own: read its content and copy it into a room, never merge
1766
- * its bytes into one (the room was converted by another run, under other ids). Two conversions
1767
- * of the same input read the same; their bytes are not the same.
1782
+ * input read on the positional store. The result is a document of its own: read its content and
1783
+ * copy it into a room, never merge its bytes into one. Two conversions of the same input read the
1784
+ * same; their bytes are not the same.
1768
1785
  *
1769
- * Refuses with no result (wasm: throws the message; Rust: `Err`). The message starts with:
1770
- * * `already-stable-ids` ([`CONVERT_ALREADY_STABLE_IDS`]): the input is already v5;
1771
- * * `newer-format` ([`CONVERT_NEWER_FORMAT`]): the input is stamped with a data format after v5;
1772
- * * `migration-refused` ([`crate::MIGRATION_REFUSED`]): a `sheet-format.cells` the migration of
1773
- * this engine does not convert;
1774
- * * `invalid-document` ([`CONVERT_INVALID_DOCUMENT`]): bytes that are not a v1 update, an update
1775
- * that is not a whole state, a document that holds no sheet and no cell, or a positional
1776
- * entry outside the grid (row 0, or past row 1,048,576 or column 16,384);
1777
- * * `convert-failed` ([`CONVERT_FAILED`]): the migration would leave a positional entry out of
1778
- * the converted document (two entries for one cell, for one), or the engine failed.
1786
+ * Without `line_ids_json` (`undefined` or `null`) each line takes the client-0 id of its position,
1787
+ * as a room's own conversion names them ([`convert_to_stable_ids`]). With it, each line takes the
1788
+ * id the map gives its position and a fresh id `make_id(freshClient, n)` where it gives none
1789
+ * ([`convert_to_stable_ids_with_line_ids`]): `{"freshClient": <1..=2^32-1>, "sheets":
1790
+ * {"<sheetId>": {"rowIds": [<id> | null, …], "columnIds": [<id> | null, …]}}}`, an id as its
1791
+ * decimal string (as `rowIds` / `columnIds` give them). A host restoring a version saved before its
1792
+ * room was converted gives the room's ids to the lines the room still has, so a reference the room
1793
+ * keeps on a line stays on that line, and fresh ids to the rest (a `freshClient` the room never
1794
+ * used), so a reference never lands on another line.
1779
1795
  *
1780
- * It runs the migration a load into the v5 store runs ([`YrsStore::migrate_to_v5`]) on a store
1781
- * of its own, twice: once keeping the positional plane, to check that the v5 document holds
1782
- * every positional entry, then once deleting what it read, for the result. No engine session,
1783
- * no calc engine. An engine still never converts a document it is handed (`dual.rs`).
1796
+ * Throws, with no result, a message that starts with:
1797
+ * * `already-stable-ids`: the input is already v5;
1798
+ * * `newer-format`: the input is stamped with a data format after v5;
1799
+ * * `migration-refused`: a `sheet-format.cells` the migration of this engine does not convert;
1800
+ * * `invalid-document`: bytes that are not a v1 update, an update that is not a whole state, a
1801
+ * document that holds no sheet and no cell, or a positional entry outside the grid;
1802
+ * * `convert-failed`: the migration would leave a positional entry out, or the engine failed;
1803
+ * * `invalid-line-ids`: a map that is not the shape above, a fresh client of 0 or past 32 bits, an
1804
+ * id that is no line id, an id of the fresh client, one id named twice on an axis, a sheet the
1805
+ * document does not hold, or a sheet whose lines are already named.
1784
1806
  * @param {Uint8Array} positional_state
1807
+ * @param {string | null} [line_ids_json]
1785
1808
  * @returns {Uint8Array}
1786
1809
  */
1787
- export function convertToStableIds(positional_state) {
1810
+ export function convertToStableIds(positional_state, line_ids_json) {
1788
1811
  const ptr0 = passArray8ToWasm0(positional_state, wasm.__wbindgen_malloc);
1789
1812
  const len0 = WASM_VECTOR_LEN;
1790
- const ret = wasm.convertToStableIds(ptr0, len0);
1813
+ var ptr1 = isLikeNone(line_ids_json) ? 0 : passStringToWasm0(line_ids_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1814
+ var len1 = WASM_VECTOR_LEN;
1815
+ const ret = wasm.convertToStableIds(ptr0, len0, ptr1, len1);
1791
1816
  if (ret[3]) {
1792
1817
  throw takeFromExternrefTable0(ret[2]);
1793
1818
  }
1794
- var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1819
+ var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1795
1820
  wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1796
- return v2;
1821
+ return v3;
1797
1822
  }
1798
1823
 
1799
1824
  /**
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rowsncolumns/rnc-yrs-store",
3
- "version": "0.28.1",
3
+ "version": "0.29.1",
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).",