@rowsncolumns/y-spreadsheet 17.0.2 → 17.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.
@@ -26,9 +26,25 @@ export declare const parseCellKeyV5: (key: string) => ParsedCellKeyV5 | null;
26
26
  */
27
27
  export declare const readStyleOverlayV5: (doc: YDoc) => StyleOverlayV5;
28
28
  /**
29
- * A v5 doc as V2 `SheetData` (same shape as `sheetDataV3ToV2`), hot plane only:
30
- * every key of `rncCells`, `rncNotes` and the composed style plane composed as
31
- * `composeCell` does (tombstones and orphans skipped).
29
+ * Cell bodies of a block by row offset (`decode_cell_block_bodies`, v1 too).
30
+ * A malformed block reads as the entries decoded before the damage.
31
+ */
32
+ export declare const decodeColumnBlockV5: (buf: Uint8Array) => Map<number, CellData>;
33
+ /**
34
+ * Whether the doc's format marker says `sheet-format.cells >= 2`
35
+ * (`stage2_cell_format` in rnc-yrs-store-v3): on a v5 doc past it, formula text
36
+ * is rendered from `ft` on read and a stored `ue.fv` may be stale.
37
+ */
38
+ export declare const v5RendersFormulaTextOnRead: (doc: YDoc) => boolean;
39
+ /** What every reader and writer here throws on a doc past the marker. */
40
+ export declare class V5FormulaTextOnReadError extends Error {
41
+ constructor();
42
+ }
43
+ /**
44
+ * A v5 doc as V2 `SheetData` (same shape as `sheetDataV3ToV2`): every key of
45
+ * `rncCells`, `rncNotes`, the composed style plane and every cold block entry,
46
+ * composed as `composeCell` does (hot shadows cold; tombstones and orphans
47
+ * skipped). Inflates every cold block once.
32
48
  */
33
49
  export declare const sheetDataV5ToV2: <T extends CellData>(doc: YDoc, styles?: ReadonlyMap<string, CellFormat>) => SheetData<T>;
34
50
  /**
@@ -40,10 +56,68 @@ export declare const createCellReaderV5: <T extends CellData = CellData>(doc: YD
40
56
  export declare const getCellV5: <T extends CellData = CellData>(doc: YDoc, sheetId: number, rowIndex: number, columnIndex: number, styles?: ReadonlyMap<string, CellFormat>) => T | undefined;
41
57
  /**
42
58
  * Apply changed `rncCells` / `rncNotes` keys to `currentSheetData` (copy-on-write,
43
- * like `processSheetDataEventsV3`), `uf` from `styles`. Only valid while no id
44
- * array and no style changed (those need `sheetDataV5ToV2`). Null when nothing changed.
59
+ * like `processSheetDataEventsV3`), `uf` from `styles`; a removed hot entry
60
+ * reveals the cold cell under it. Only valid while no id array, no style and no
61
+ * cold block changed (those need `sheetDataV5ToV2`). Null when nothing changed.
45
62
  */
46
63
  export declare const processSheetDataChangesV5: <T extends CellData>(changedKeys: Iterable<string>, currentSheetData: SheetData<T>, doc: YDoc, styles?: ReadonlyMap<string, CellFormat>) => SheetData<T> | null;
64
+ /** A decoded `Addr`; line ids as decimal strings, `null` = an open side (`B:B`, `1:1`). */
65
+ export type FacetAddrV5 = {
66
+ kind: "range";
67
+ sheetId: number;
68
+ r0: string | null;
69
+ r1: string | null;
70
+ c0: string | null;
71
+ c1: string | null;
72
+ } | {
73
+ kind: "cell" | "point";
74
+ sheetId: number;
75
+ row: string;
76
+ col: string;
77
+ };
78
+ /**
79
+ * How one anchored map of a facet value reads:
80
+ * - `positional`: no usable anchor (none, undecodable, its recorded fields no
81
+ * longer equal the stored ones, or it names another sheet's lines): the
82
+ * stored positional fields are the truth.
83
+ * - `resolved`: the positional fields now (`fields`; an open side's field is
84
+ * absent and keeps its stored value).
85
+ * - `engine`: a corner line is not in this doc's axis (deleted, or not synced
86
+ * yet). The engine repairs or falls back from what its session saw; a native
87
+ * reader cannot, so read the facet through the engine (or treat it as stale).
88
+ */
89
+ export type ResolvedFacetAnchorV5 = {
90
+ status: "positional";
91
+ } | {
92
+ status: "resolved";
93
+ fields: Record<string, number>;
94
+ } | {
95
+ status: "engine";
96
+ };
97
+ /**
98
+ * Decode a facet `anchor` buffer (`decode_anchor`): `u8 n`, the `n` positional
99
+ * fields as written (zigzag varints), then one `Addr` filling the rest.
100
+ */
101
+ export declare const decodeFacetAnchorV5: (buf: Uint8Array) => {
102
+ frame: number[];
103
+ addr: FacetAddrV5;
104
+ } | null;
105
+ /**
106
+ * Resolve the `anchor` of one anchored map inside a facet value (`site_now`):
107
+ * `site` `"range"` = a map with `startRowIndex`…`endColumnIndex` (a named
108
+ * range, merge, CF / DV range, table, chart range, …), `"cell"` = a one-cell
109
+ * map (`rowIndex` / `columnIndex`) that goes with its lines (data-table input,
110
+ * scenario cells), `"point"` = a floating object's anchor cell. `sheetId` is
111
+ * the sheet the facet lives on.
112
+ *
113
+ * Only live corner lines are resolved here; anything the engine would repair
114
+ * (a deleted line) or fall back on (a line this replica never saw) answers
115
+ * `engine`. Which maps of which facet carry an anchor (and the derived ones:
116
+ * table filter column offsets, print breaks, print titles) is the engine's
117
+ * walk (`facet_anchor.rs`); for those, and whenever the exact answer matters,
118
+ * read facets through the engine.
119
+ */
120
+ export declare const resolveFacetAnchorV5: (doc: YDoc, sheetId: number, value: Record<string, unknown>, site: "range" | "cell" | "point") => ResolvedFacetAnchorV5;
47
121
  /**
48
122
  * Apply immer `SheetData` patches to a v5 doc in one transaction (`origin`, the
49
123
  * caller's; nested in an open transaction it joins that one). Positional, like
@@ -1 +1 @@
1
- {"version":3,"file":"helpers-v5.d.ts","sourceRoot":"","sources":["../../helpers-v5.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAEjE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAOnC,OAAO,KAAK,EAAE,IAAI,EAAS,MAAM,SAAS,CAAC;AAG3C,iFAAiF;AACjF,MAAM,MAAM,eAAe,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAEhF,oEAAoE;AACpE,MAAM,MAAM,cAAc,GAAG,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;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OAAO,KAC/B,qBAmDF,CAAC;AA0SF;;;;;;;;;GASG;AACH,eAAO,MAAM,qBAAqB,GAChC,KAAK,IAAI,EACT,SAAS,KAAK,EAAE,GAAG,SAAS,EAC5B,SAAQ,OAAc,EACtB,SAAS,cAAc,SA+CxB,CAAC;AAEF,8DAA8D;AAC9D,eAAO,MAAM,SAAS,GACpB,KAAK,IAAI,EACT,SAAS,MAAM,EACf,UAAU,MAAM,EAChB,aAAa,MAAM,EACnB,OAAO,QAAQ,KACd,IAGC,CAAC;AAEL,iEAAiE;AACjE,eAAO,MAAM,YAAY,GACvB,KAAK,IAAI,EACT,SAAS,MAAM,EACf,UAAU,MAAM,EAChB,aAAa,MAAM,KAClB,IAGC,CAAC;AAEL,kFAAkF;AAClF,eAAO,MAAM,aAAa,GAAI,KAAK,IAAI,EAAE,SAAS,MAAM,KAAG,IACM,CAAC"}
@@ -6,18 +6,31 @@
6
6
  // (`RNC_CELLS`, `c0_floor`, …) are the Rust ones in rust/crates/rnc-yrs-store/src
7
7
  // (lib.rs unless a module is named); they win over this module.
8
8
  //
9
- // Readers (hot plane only; cold-block cells are not decoded): `sheetDataV5ToV2`,
10
- // `getCellV5`, `processSheetDataChangesV5`; `uf` from the composed style plane,
11
- // `note` from `rncNotes`, so a cell read here can be written back unchanged.
9
+ // Readers: `sheetDataV5ToV2`, `getCellV5`, `createCellReaderV5`,
10
+ // `processSheetDataChangesV5`. A cell is its hot `rncCells` entry, else its cold
11
+ // `rncColumnBlocks` body (a hot `null` hides the cold cell; orphans of deleted
12
+ // lines are skipped); `uf` from the composed style plane, `note` from
13
+ // `rncNotes`, so a cell read here can be written back unchanged.
14
+ // Facets: `resolveFacetAnchorV5` resolves one stored `anchor` from live line
15
+ // ids; a deleted or unsynced corner line needs the engine's repair.
12
16
  // Writer: `addSheetDataPatchesV5` applies immer `SheetData` patches positionally
13
17
  // (a structural edit arrives as rewritten rows, v3 parity); it names lines past
14
18
  // an axis with client-0 ids exactly as `YrsStore::ensure_lines` does and logs
15
- // `uf` changes as `STYLE_LOG_V2` ops. It never writes `ft`: a JS formula is
16
- // positional in its write frame.
19
+ // `uf` changes as `STYLE_LOG_V2` ops. It never writes `ft` (engine-owned: the
20
+ // engine derives it on its next write of the cell; until then the formula is
21
+ // positional in its write frame, `ue.fv` being the truth) and never writes a
22
+ // facet `anchor` (a facet written here is positional and gains one on its next
23
+ // engine write).
24
+ // Past the Stage 2 format marker (`sheet-format.cells >= 2`) a structural edit
25
+ // leaves `ue.fv` as written and the engine renders formula text from `ft` on
26
+ // read, so a stored `ue.fv` may name cells the formula no longer reads. This
27
+ // module reads `ue.fv` as stored: every reader and writer here refuses such a
28
+ // doc (`V5FormulaTextOnReadError`); read it through the engine.
17
29
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.deleteSheetV5 = exports.deleteCellV5 = exports.setCellV5 = exports.addSheetDataPatchesV5 = exports.processSheetDataChangesV5 = exports.getCellV5 = exports.createCellReaderV5 = exports.sheetDataV5ToV2 = exports.readStyleOverlayV5 = exports.parseCellKeyV5 = exports.createCellKeyV5 = exports.readLineIds = void 0;
30
+ exports.deleteSheetV5 = exports.deleteCellV5 = exports.setCellV5 = exports.addSheetDataPatchesV5 = exports.resolveFacetAnchorV5 = exports.decodeFacetAnchorV5 = exports.processSheetDataChangesV5 = exports.getCellV5 = exports.createCellReaderV5 = exports.sheetDataV5ToV2 = exports.V5FormulaTextOnReadError = exports.v5RendersFormulaTextOnRead = exports.decodeColumnBlockV5 = exports.readStyleOverlayV5 = exports.parseCellKeyV5 = exports.createCellKeyV5 = exports.readLineIds = void 0;
19
31
  var tslib_1 = require("tslib");
20
32
  var utils_1 = require("@rowsncolumns/utils");
33
+ var fflate_1 = require("fflate");
21
34
  var decoding = tslib_1.__importStar(require("lib0/decoding"));
22
35
  var encoding = tslib_1.__importStar(require("lib0/encoding"));
23
36
  var cloneDeep_1 = tslib_1.__importDefault(require("lodash/cloneDeep"));
@@ -34,7 +47,10 @@ var BLOCKS_V5 = "rncColumnBlocks"; // RNC_COLUMN_BLOCKS
34
47
  var BLOCK_ROWS = 32768; // BLOCK_ROWS
35
48
  var BLOCK_V2_MAGIC = 0x80000000; // BLOCK_V2_MAGIC
36
49
  var BLOCK_V2_DENSE = 0x40000000; // BLOCK_V2_DENSE
50
+ var MAX_BLOCK_RAW_BYTES = 512 * 1024 * 1024; // MAX_BLOCK_RAW_BYTES
37
51
  var STYLE_LOG_V1 = 1; // STYLE_LOG_V1
52
+ var FORMAT_ROOT = "sheet-format"; // rnc-yrs-store-v3 node_cell::FORMAT_ROOT
53
+ var NODE_CELL_FORMAT = 2; // rnc-yrs-store-v3 node_cell::NODE_CELL_FORMAT
38
54
  var STYLE_LOG_V2 = 2; // STYLE_LOG_V2
39
55
  var CELL_KEY_V5 = /^(-?\d+):(-?\d+):(-?\d+)$/; // cell_key
40
56
  var BLOCK_KEY_V5 = /^(-?\d+):(-?\d+):(\d+)$/; // block_key
@@ -352,16 +368,135 @@ var coldCellExists = function (doc, cache, sheetId, rowId, colId) {
352
368
  }
353
369
  return offsets.has((counter - 1) % BLOCK_ROWS);
354
370
  };
371
+ /**
372
+ * Cell bodies of a block by row offset (`decode_cell_block_bodies`, v1 too).
373
+ * A malformed block reads as the entries decoded before the damage.
374
+ */
375
+ var decodeColumnBlockV5 = function (buf) {
376
+ var out = new Map();
377
+ if (buf.length < 4)
378
+ return out;
379
+ var view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
380
+ var text = new TextDecoder();
381
+ var body = function (bytes, pos, len) {
382
+ if (pos + len > bytes.length)
383
+ return null;
384
+ var value = JSON.parse(text.decode(bytes.subarray(pos, pos + len)));
385
+ return isPlainObject(value) ? value : null;
386
+ };
387
+ try {
388
+ var first = view.getUint32(0, true);
389
+ if (first & BLOCK_V2_MAGIC) {
390
+ var offsets = blockRowOffsets(buf);
391
+ var pos = 8 + (first & BLOCK_V2_DENSE ? 0 : offsets.length * 4);
392
+ if (pos + 4 > buf.length)
393
+ return out;
394
+ var rawLen = view.getUint32(pos, true);
395
+ if (rawLen > MAX_BLOCK_RAW_BYTES)
396
+ return out;
397
+ var bodies = (0, fflate_1.inflateSync)(buf.subarray(pos + 4), { out: new Uint8Array(rawLen) });
398
+ var bodyView = new DataView(bodies.buffer, bodies.byteOffset, bodies.byteLength);
399
+ for (var i = 0, at = 0; i < offsets.length && at + 4 <= bodies.length; i++) {
400
+ var len = bodyView.getUint32(at, true);
401
+ var cell = body(bodies, at + 4, len);
402
+ if (cell)
403
+ out.set(offsets[i], cell);
404
+ at += 4 + len;
405
+ }
406
+ return out;
407
+ }
408
+ for (var i = 0, pos = 4; i < first && pos + 8 <= buf.length; i++) {
409
+ var offset = view.getUint32(pos, true);
410
+ var len = view.getUint32(pos + 4, true);
411
+ var cell = body(buf, pos + 8, len);
412
+ if (cell)
413
+ out.set(offset, cell);
414
+ pos += 8 + len;
415
+ }
416
+ }
417
+ catch (_e) {
418
+ // Truncated deflate stream or a body that is not JSON: keep what decoded.
419
+ }
420
+ return out;
421
+ };
422
+ exports.decodeColumnBlockV5 = decodeColumnBlockV5;
423
+ /** Whether `rncColumnBlocks` key `key` is a v5 block (its column part a line id, not `< 2^32`). */
424
+ var parseBlockKeyV5 = function (key) {
425
+ var match = BLOCK_KEY_V5.exec(key);
426
+ if (!match)
427
+ return null;
428
+ var colId = BigInt(match[2]);
429
+ if (BigInt.asIntN(64, colId) !== colId || idCounter(colId) === 0)
430
+ return null;
431
+ return { sheetId: Number(match[1]), colId: colId.toString(), block: Number(match[3]) };
432
+ };
433
+ /**
434
+ * The cold body of the cell at `rowId` × `colId`: entry `(counter - 1) % BLOCK_ROWS`
435
+ * of block `(counter - 1) / BLOCK_ROWS` of the column, for a client-0 row id only.
436
+ */
437
+ var coldCellV5 = function (doc, cache, sheetId, rowId, colId) {
438
+ var _a;
439
+ var counter = c0Counter(rowId);
440
+ if (!counter || !doc.share.has(BLOCKS_V5))
441
+ return null;
442
+ var key = "".concat(sheetId, ":").concat(colId, ":").concat(Math.floor((counter - 1) / BLOCK_ROWS));
443
+ var cells = cache.get(key);
444
+ if (!cells) {
445
+ var buf = doc.get(BLOCKS_V5).getAttr(key);
446
+ cells = buf instanceof Uint8Array ? (0, exports.decodeColumnBlockV5)(buf) : new Map();
447
+ cache.set(key, cells);
448
+ }
449
+ return (_a = cells.get((counter - 1) % BLOCK_ROWS)) !== null && _a !== void 0 ? _a : null;
450
+ };
355
451
  // ── readers ─────────────────────────────────────────────────────────────────
356
452
  /**
357
- * The cell under `key` as the readers show it: the hot value (`ft` stripped),
358
- * `uf` from `styles` where it has an entry, `note` from `rncNotes` where it has
359
- * one. Null when none of the three holds anything.
453
+ * Whether the doc's format marker says `sheet-format.cells >= 2`
454
+ * (`stage2_cell_format` in rnc-yrs-store-v3): on a v5 doc past it, formula text
455
+ * is rendered from `ft` on read and a stored `ue.fv` may be stale.
456
+ */
457
+ var v5RendersFormulaTextOnRead = function (doc) {
458
+ if (!doc.share.has(FORMAT_ROOT))
459
+ return false;
460
+ var cells = doc.get(FORMAT_ROOT).getAttr("cells");
461
+ return typeof cells === "number" && cells >= NODE_CELL_FORMAT;
462
+ };
463
+ exports.v5RendersFormulaTextOnRead = v5RendersFormulaTextOnRead;
464
+ /** What every reader and writer here throws on a doc past the marker. */
465
+ var V5FormulaTextOnReadError = /** @class */ (function (_super) {
466
+ tslib_1.__extends(V5FormulaTextOnReadError, _super);
467
+ function V5FormulaTextOnReadError() {
468
+ var _this = _super.call(this, "This sheet renders formula text on read (sheet-format.cells >= 2): read and write it through the engine") || this;
469
+ _this.name = "V5FormulaTextOnReadError";
470
+ return _this;
471
+ }
472
+ return V5FormulaTextOnReadError;
473
+ }(Error));
474
+ exports.V5FormulaTextOnReadError = V5FormulaTextOnReadError;
475
+ var refuseRenderedText = function (doc) {
476
+ if ((0, exports.v5RendersFormulaTextOnRead)(doc))
477
+ throw new V5FormulaTextOnReadError();
478
+ };
479
+ /**
480
+ * The stored value of the cell under `key`: its hot entry (`ft` stripped; a
481
+ * `null` or any non-map is a tombstone and reads null), else its cold body.
482
+ */
483
+ var storedCellV5 = function (doc, key, cold) {
484
+ var hot = doc.share.has(CELLS_V5) ? doc.get(CELLS_V5) : null;
485
+ if (hot === null || hot === void 0 ? void 0 : hot.hasAttr(key))
486
+ return cellDataV5(hot.getAttr(key));
487
+ var parsed = (0, exports.parseCellKeyV5)(key);
488
+ if (!parsed)
489
+ return null;
490
+ var body = coldCellV5(doc, cold, parsed.sheetId, parsed.rowId, parsed.colId);
491
+ return body ? cellDataV5(body) : null;
492
+ };
493
+ /**
494
+ * The cell under `key` as the readers show it: the stored value
495
+ * (`storedCellV5`), `uf` from `styles` where it has an entry, `note` from
496
+ * `rncNotes` where it has one. Null when none of the three holds anything.
360
497
  */
361
- var composeCell = function (doc, key, styles) {
362
- var cell = doc.share.has(CELLS_V5)
363
- ? cellDataV5(doc.get(CELLS_V5).getAttr(key))
364
- : null;
498
+ var composeCell = function (doc, key, styles, cold) {
499
+ var cell = storedCellV5(doc, key, cold);
365
500
  var uf = styles.get(key);
366
501
  if (uf)
367
502
  cell = tslib_1.__assign(tslib_1.__assign({}, cell), { uf: uf });
@@ -371,17 +506,20 @@ var composeCell = function (doc, key, styles) {
371
506
  return cell;
372
507
  };
373
508
  /**
374
- * A v5 doc as V2 `SheetData` (same shape as `sheetDataV3ToV2`), hot plane only:
375
- * every key of `rncCells`, `rncNotes` and the composed style plane composed as
376
- * `composeCell` does (tombstones and orphans skipped).
509
+ * A v5 doc as V2 `SheetData` (same shape as `sheetDataV3ToV2`): every key of
510
+ * `rncCells`, `rncNotes`, the composed style plane and every cold block entry,
511
+ * composed as `composeCell` does (hot shadows cold; tombstones and orphans
512
+ * skipped). Inflates every cold block once.
377
513
  */
378
514
  var sheetDataV5ToV2 = function (doc, styles) {
379
515
  var e_6, _a, e_7, _b, e_8, _c;
380
516
  var _d, _f;
381
517
  var _g;
382
518
  if (styles === void 0) { styles = (0, exports.readStyleOverlayV5)(doc); }
519
+ refuseRenderedText(doc);
383
520
  var sheetData = {};
384
521
  var cache = new Map();
522
+ var cold = new Map();
385
523
  var keys = new Set(styles.keys());
386
524
  try {
387
525
  for (var _h = tslib_1.__values([CELLS_V5, NOTES_V5]), _j = _h.next(); !_j.done; _j = _h.next()) {
@@ -410,12 +548,28 @@ var sheetDataV5ToV2 = function (doc, styles) {
410
548
  }
411
549
  finally { if (e_6) throw e_6.error; }
412
550
  }
551
+ if (doc.share.has(BLOCKS_V5)) {
552
+ (0, ynodes_1.forEachEntry)(doc.get(BLOCKS_V5), function (value, blockKey) {
553
+ var parsed = parseBlockKeyV5(blockKey);
554
+ if (!parsed || !(value instanceof Uint8Array))
555
+ return;
556
+ var cells = (0, exports.decodeColumnBlockV5)(value);
557
+ cold.set(blockKey, cells);
558
+ var rows = sheetLinesV5(doc, cache, parsed.sheetId).rows;
559
+ cells.forEach(function (_cell, offset) {
560
+ var rowId = c0Id(parsed.block * BLOCK_ROWS + offset + 1);
561
+ // A row not in the axis is deleted: its block cells are orphans.
562
+ if (rows.has(rowId))
563
+ keys.add((0, exports.createCellKeyV5)(parsed.sheetId, rowId, parsed.colId));
564
+ });
565
+ });
566
+ }
413
567
  try {
414
568
  for (var keys_1 = tslib_1.__values(keys), keys_1_1 = keys_1.next(); !keys_1_1.done; keys_1_1 = keys_1.next()) {
415
569
  var key = keys_1_1.value;
416
570
  var parsed = (0, exports.parseCellKeyV5)(key);
417
571
  var pos = parsed && positionV5(doc, cache, parsed);
418
- var cell = pos && composeCell(doc, key, styles);
572
+ var cell = pos && composeCell(doc, key, styles, cold);
419
573
  if (!parsed || !pos || !cell)
420
574
  continue;
421
575
  var _m = tslib_1.__read(pos, 2), rowIdx = _m[0], colIdx = _m[1];
@@ -446,9 +600,13 @@ exports.sheetDataV5ToV2 = sheetDataV5ToV2;
446
600
  */
447
601
  var createCellReaderV5 = function (doc, styles) {
448
602
  if (styles === void 0) { styles = (0, exports.readStyleOverlayV5)(doc); }
603
+ refuseRenderedText(doc);
449
604
  var lines = new Map();
605
+ var cold = new Map();
450
606
  return function (sheetId, rowIndex, columnIndex) {
451
607
  var _a;
608
+ // The marker can arrive with a sync after the reader was made.
609
+ refuseRenderedText(doc);
452
610
  var ids = lines.get(sheetId);
453
611
  if (!ids) {
454
612
  ids = [(0, exports.readLineIds)(doc, sheetId, "row"), (0, exports.readLineIds)(doc, sheetId, "column")];
@@ -458,7 +616,7 @@ var createCellReaderV5 = function (doc, styles) {
458
616
  var colId = ids[1][columnIndex - 1];
459
617
  if (rowId === undefined || colId === undefined)
460
618
  return undefined;
461
- return (_a = composeCell(doc, (0, exports.createCellKeyV5)(sheetId, rowId, colId), styles)) !== null && _a !== void 0 ? _a : undefined;
619
+ return ((_a = composeCell(doc, (0, exports.createCellKeyV5)(sheetId, rowId, colId), styles, cold)) !== null && _a !== void 0 ? _a : undefined);
462
620
  };
463
621
  };
464
622
  exports.createCellReaderV5 = createCellReaderV5;
@@ -467,14 +625,17 @@ var getCellV5 = function (doc, sheetId, rowIndex, columnIndex, styles) { return
467
625
  exports.getCellV5 = getCellV5;
468
626
  /**
469
627
  * Apply changed `rncCells` / `rncNotes` keys to `currentSheetData` (copy-on-write,
470
- * like `processSheetDataEventsV3`), `uf` from `styles`. Only valid while no id
471
- * array and no style changed (those need `sheetDataV5ToV2`). Null when nothing changed.
628
+ * like `processSheetDataEventsV3`), `uf` from `styles`; a removed hot entry
629
+ * reveals the cold cell under it. Only valid while no id array, no style and no
630
+ * cold block changed (those need `sheetDataV5ToV2`). Null when nothing changed.
472
631
  */
473
632
  var processSheetDataChangesV5 = function (changedKeys, currentSheetData, doc, styles) {
474
633
  var e_9, _a;
475
634
  var _b, _c, _d;
476
635
  if (styles === void 0) { styles = (0, exports.readStyleOverlayV5)(doc); }
636
+ refuseRenderedText(doc);
477
637
  var cache = new Map();
638
+ var cold = new Map();
478
639
  var next = tslib_1.__assign({}, currentSheetData);
479
640
  var clonedSheets = new Set();
480
641
  var clonedRows = new Set();
@@ -488,7 +649,7 @@ var processSheetDataChangesV5 = function (changedKeys, currentSheetData, doc, st
488
649
  continue;
489
650
  var _h = tslib_1.__read(pos, 2), rowIdx = _h[0], colIdx = _h[1];
490
651
  var sheetId = parsed.sheetId;
491
- var cell = composeCell(doc, key, styles);
652
+ var cell = composeCell(doc, key, styles, cold);
492
653
  var row = (_b = next[sheetId]) === null || _b === void 0 ? void 0 : _b[rowIdx];
493
654
  if (!cell && !((_c = row === null || row === void 0 ? void 0 : row.values) === null || _c === void 0 ? void 0 : _c[colIdx]))
494
655
  continue;
@@ -522,6 +683,161 @@ var processSheetDataChangesV5 = function (changedKeys, currentSheetData, doc, st
522
683
  return hasChanges ? next : null;
523
684
  };
524
685
  exports.processSheetDataChangesV5 = processSheetDataChangesV5;
686
+ // ── facet anchors (facet_anchor.rs, addr.rs) ────────────────────────────────
687
+ var MAX_ROW = 1048576; // MAX_ROW
688
+ var MAX_COL = 16384; // MAX_COL
689
+ var TAG_RANGE = 1; // TAG_RANGE
690
+ var TAG_CELL = 2; // TAG_CELL
691
+ var TAG_POINT = 3; // TAG_POINT
692
+ var RANGE_KEYS = ["startRowIndex", "endRowIndex", "startColumnIndex", "endColumnIndex"];
693
+ var CELL_KEYS = ["rowIndex", "columnIndex"];
694
+ /** Zigzag LEB128 `i64` (`get_var`). */
695
+ var readVar = function (buf, at) {
696
+ var z = BigInt(0);
697
+ for (var shift = BigInt(0); shift < BigInt(64); shift += BigInt(7)) {
698
+ if (at.pos >= buf.length)
699
+ return null;
700
+ var b = buf[at.pos++];
701
+ z |= BigInt(b & 0x7f) << shift;
702
+ if ((b & 0x80) === 0) {
703
+ return BigInt.asIntN(64, (z >> BigInt(1)) ^ -(z & BigInt(1)));
704
+ }
705
+ }
706
+ return null;
707
+ };
708
+ /**
709
+ * Decode a facet `anchor` buffer (`decode_anchor`): `u8 n`, the `n` positional
710
+ * fields as written (zigzag varints), then one `Addr` filling the rest.
711
+ */
712
+ var decodeFacetAnchorV5 = function (buf) {
713
+ var at = { pos: 0 };
714
+ if (!buf.length)
715
+ return null;
716
+ var n = buf[at.pos++];
717
+ var frame = [];
718
+ for (var i = 0; i < n; i++) {
719
+ var v = readVar(buf, at);
720
+ if (v === null)
721
+ return null;
722
+ frame.push(Number(v));
723
+ }
724
+ if (at.pos >= buf.length)
725
+ return null;
726
+ var tag = buf[at.pos++];
727
+ var sheet = readVar(buf, at);
728
+ if (sheet === null)
729
+ return null;
730
+ var sheetId = Number(sheet);
731
+ var id = function () { var _a, _b; return (_b = (_a = readVar(buf, at)) === null || _a === void 0 ? void 0 : _a.toString()) !== null && _b !== void 0 ? _b : null; };
732
+ var addr;
733
+ if (tag === TAG_RANGE) {
734
+ if (at.pos + 2 > buf.length)
735
+ return null;
736
+ at.pos++; // abs
737
+ var bits = buf[at.pos++];
738
+ var corners = [];
739
+ for (var i = 0; i < 4; i++) {
740
+ if (bits & (1 << i)) {
741
+ var c = id();
742
+ if (c === null)
743
+ return null;
744
+ corners.push(c);
745
+ }
746
+ else {
747
+ corners.push(null);
748
+ }
749
+ }
750
+ var _a = tslib_1.__read(corners, 4), r0 = _a[0], r1 = _a[1], c0 = _a[2], c1 = _a[3];
751
+ addr = { kind: "range", sheetId: sheetId, r0: r0, r1: r1, c0: c0, c1: c1 };
752
+ }
753
+ else if (tag === TAG_CELL || tag === TAG_POINT) {
754
+ if (tag === TAG_CELL) {
755
+ if (at.pos >= buf.length)
756
+ return null;
757
+ at.pos++; // abs
758
+ }
759
+ var row = id();
760
+ var col = id();
761
+ if (row === null || col === null)
762
+ return null;
763
+ addr = { kind: tag === TAG_CELL ? "cell" : "point", sheetId: sheetId, row: row, col: col };
764
+ }
765
+ else {
766
+ return null;
767
+ }
768
+ return at.pos === buf.length ? { frame: frame, addr: addr } : null;
769
+ };
770
+ exports.decodeFacetAnchorV5 = decodeFacetAnchorV5;
771
+ /**
772
+ * Resolve the `anchor` of one anchored map inside a facet value (`site_now`):
773
+ * `site` `"range"` = a map with `startRowIndex`…`endColumnIndex` (a named
774
+ * range, merge, CF / DV range, table, chart range, …), `"cell"` = a one-cell
775
+ * map (`rowIndex` / `columnIndex`) that goes with its lines (data-table input,
776
+ * scenario cells), `"point"` = a floating object's anchor cell. `sheetId` is
777
+ * the sheet the facet lives on.
778
+ *
779
+ * Only live corner lines are resolved here; anything the engine would repair
780
+ * (a deleted line) or fall back on (a line this replica never saw) answers
781
+ * `engine`. Which maps of which facet carry an anchor (and the derived ones:
782
+ * table filter column offsets, print breaks, print titles) is the engine's
783
+ * walk (`facet_anchor.rs`); for those, and whenever the exact answer matters,
784
+ * read facets through the engine.
785
+ */
786
+ var resolveFacetAnchorV5 = function (doc, sheetId, value, site) {
787
+ var positional = { status: "positional" };
788
+ var buf = value.anchor;
789
+ if (!(buf instanceof Uint8Array))
790
+ return positional;
791
+ var decoded = (0, exports.decodeFacetAnchorV5)(buf);
792
+ if (!decoded)
793
+ return positional;
794
+ var frame = decoded.frame, addr = decoded.addr;
795
+ var keys = site === "range" ? RANGE_KEYS : CELL_KEYS;
796
+ var stored = keys.map(function (k) { return value[k]; });
797
+ if (stored.length !== frame.length ||
798
+ stored.some(function (v, i) { return typeof v !== "number" || v !== frame[i]; })) {
799
+ return positional;
800
+ }
801
+ // A value copied onto another sheet with its anchors names the source's lines.
802
+ if (addr.sheetId !== sheetId)
803
+ return positional;
804
+ var lines = sheetLinesV5(doc, new Map(), sheetId);
805
+ if (site === "point") {
806
+ if (addr.kind !== "point")
807
+ return positional;
808
+ var row = lines.rows.get(addr.row);
809
+ var col = lines.cols.get(addr.col);
810
+ if (row === undefined || col === undefined)
811
+ return { status: "engine" };
812
+ return { status: "resolved", fields: { rowIndex: row, columnIndex: col } };
813
+ }
814
+ if (addr.kind !== "range")
815
+ return positional;
816
+ var axis = function (index, c0, c1, max) {
817
+ var s = c0 === null ? 1 : index.get(c0);
818
+ var e = c1 === null ? max : index.get(c1);
819
+ if (s === undefined || e === undefined)
820
+ return null;
821
+ // Both lines live in the other order (a move): the box of both.
822
+ return s <= e ? [s, e] : [e, s];
823
+ };
824
+ var rows = axis(lines.rows, addr.r0, addr.r1, MAX_ROW);
825
+ var cols = axis(lines.cols, addr.c0, addr.c1, MAX_COL);
826
+ if (!rows || !cols)
827
+ return { status: "engine" };
828
+ if (site === "cell") {
829
+ return { status: "resolved", fields: { rowIndex: rows[0], columnIndex: cols[0] } };
830
+ }
831
+ var now = [rows[0], rows[1], cols[0], cols[1]];
832
+ var open = [addr.r0, addr.r1, addr.c0, addr.c1].map(function (c) { return c === null; });
833
+ var fields = {};
834
+ RANGE_KEYS.forEach(function (k, i) {
835
+ if (!open[i])
836
+ fields[k] = now[i];
837
+ });
838
+ return { status: "resolved", fields: fields };
839
+ };
840
+ exports.resolveFacetAnchorV5 = resolveFacetAnchorV5;
525
841
  var axisKey = function (sheetId, isRow) {
526
842
  return "".concat(sheetId, ":").concat(isRow ? "R" : "C");
527
843
  };
@@ -653,7 +969,8 @@ var queueStyle = function (w, sheetId, rowId, colId, format) {
653
969
  * composed plane's entry, else the inline `uf`) is logged as a replace (a
654
970
  * clear, then the format; a style reference only clears: the engine cannot
655
971
  * resolve it). A note lives in `rncNotes` when the key has an entry there,
656
- * inline otherwise. An unchanged cell is not rewritten (its `ft` survives).
972
+ * inline otherwise. An unchanged cell (hot, or cold with no hot entry) is not
973
+ * rewritten (its `ft` survives; a cold cell gets no hot copy).
657
974
  */
658
975
  var writeCell = function (w, sheetId, row, col, cell) {
659
976
  var _a;
@@ -662,7 +979,7 @@ var writeCell = function (w, sheetId, row, col, cell) {
662
979
  var rowId = ensureLine(w, sheetId, true, row);
663
980
  var colId = ensureLine(w, sheetId, false, col);
664
981
  var key = (0, exports.createCellKeyV5)(sheetId, rowId, colId);
665
- var stored = cellDataV5(w.cells.getAttr(key));
982
+ var stored = storedCellV5(w.doc, key, w.cold);
666
983
  var format = normalizedFormat((0, utils_1.getCellUserEnteredFormat)(cell));
667
984
  var storedFormat = normalizedFormat((_a = writerStyles(w).get(key)) !== null && _a !== void 0 ? _a : (0, utils_1.getCellUserEnteredFormat)(stored));
668
985
  if (!(0, isEqual_1.default)(format, storedFormat)) {
@@ -803,6 +1120,7 @@ var clearSheets = function (w, match) {
803
1120
  drop(BLOCKS_V5);
804
1121
  drop(NOTES_V5);
805
1122
  drop(STYLES_SEED_V5);
1123
+ w.cold.clear();
806
1124
  try {
807
1125
  for (var _b = tslib_1.__values(Array.from(writerStyles(w).keys())), _c = _b.next(); !_c.done; _c = _b.next()) {
808
1126
  var key = _c.value;
@@ -821,7 +1139,7 @@ var clearSheets = function (w, match) {
821
1139
  }
822
1140
  w.offsets.clear();
823
1141
  };
824
- /** The cell a nested patch edits: the stored cell as the readers show it. */
1142
+ /** The cell a nested patch edits: the stored cell (hot, else cold) as the readers show it. */
825
1143
  var nestedBase = function (w, sheetId, row, col) {
826
1144
  var _a;
827
1145
  var rowId = writerAxis(w, sheetId, true).ids[row - 1];
@@ -829,10 +1147,7 @@ var nestedBase = function (w, sheetId, row, col) {
829
1147
  if (rowId === undefined || colId === undefined)
830
1148
  return {};
831
1149
  var key = (0, exports.createCellKeyV5)(sheetId, rowId, colId);
832
- if (!w.cells.hasAttr(key) && coldCellExists(w.doc, w.offsets, sheetId, rowId, colId)) {
833
- return null;
834
- }
835
- return (_a = composeCell(w.doc, key, writerStyles(w))) !== null && _a !== void 0 ? _a : {};
1150
+ return (_a = composeCell(w.doc, key, writerStyles(w), w.cold)) !== null && _a !== void 0 ? _a : {};
836
1151
  };
837
1152
  var applyPatchV5 = function (w, _a) {
838
1153
  var e_15, _b;
@@ -864,11 +1179,6 @@ var applyPatchV5 = function (w, _a) {
864
1179
  if (!validPosition(row, col))
865
1180
  return;
866
1181
  var base = nestedBase(w, sheetId, row, col);
867
- if (base === null) {
868
- // Cold-only cell: its body needs an async inflate, a sync writer cannot merge into it.
869
- console.warn("y-spreadsheet v5: nested patch on cold cell ".concat(sheetId, "!R").concat(row, "C").concat(col, " skipped"));
870
- return;
871
- }
872
1182
  var cell = (0, cloneDeep_1.default)(base);
873
1183
  var nested = path.slice(4);
874
1184
  if (op === "remove") {
@@ -908,6 +1218,7 @@ var addSheetDataPatchesV5 = function (doc, patches, origin, styles) {
908
1218
  if (origin === void 0) { origin = null; }
909
1219
  if (!(patches === null || patches === void 0 ? void 0 : patches.length))
910
1220
  return;
1221
+ refuseRenderedText(doc);
911
1222
  doc.transact(function () {
912
1223
  var e_16, _a;
913
1224
  var w = {
@@ -918,6 +1229,7 @@ var addSheetDataPatchesV5 = function (doc, patches, origin, styles) {
918
1229
  styles: styles !== null && styles !== void 0 ? styles : null,
919
1230
  ops: [],
920
1231
  offsets: new Map(),
1232
+ cold: new Map(),
921
1233
  };
922
1234
  // Consecutive cell patches are consolidated (the later one wins) but never
923
1235
  // reordered across a row-, sheet- or document-level patch (v3 parity).
@@ -77,7 +77,7 @@ export type UseYSpreadsheetPropsV2<T extends CellData, S extends Sheet, C extend
77
77
  * If using V3 but version is "v2" or undefined, migration will occur
78
78
  * This should be provided by the backend/server
79
79
  * "v5" (also when `docMeta.sheetDataVersion` says so): stable line ids, read
80
- * from and written to `rncCells` (hot plane only, see `helpers-v5.ts`)
80
+ * from `rncCells` and the cold `rncColumnBlocks`, written to `rncCells` (see `helpers-v5.ts`)
81
81
  */
82
82
  sheetDataVersion?: "v2" | "v3" | "v5";
83
83
  /**