@rowsncolumns/y-spreadsheet 17.0.1 → 17.0.3
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.
- package/dist/cjs/helpers-v5.d.ts +69 -5
- package/dist/cjs/helpers-v5.d.ts.map +1 -1
- package/dist/cjs/helpers-v5.js +305 -33
- package/dist/cjs/use-yspreadsheet-v2.d.ts +1 -1
- package/dist/cjs/use-yspreadsheet-v2.d.ts.map +1 -1
- package/dist/cjs/use-yspreadsheet-v2.js +4 -3
- package/dist/esm/helpers-v5.d.ts +69 -5
- package/dist/esm/helpers-v5.d.ts.map +1 -1
- package/dist/esm/helpers-v5.js +300 -32
- package/dist/esm/use-yspreadsheet-v2.d.ts +1 -1
- package/dist/esm/use-yspreadsheet-v2.d.ts.map +1 -1
- package/dist/esm/use-yspreadsheet-v2.js +4 -3
- package/package.json +10 -9
package/dist/cjs/helpers-v5.d.ts
CHANGED
|
@@ -26,9 +26,15 @@ export declare const parseCellKeyV5: (key: string) => ParsedCellKeyV5 | null;
|
|
|
26
26
|
*/
|
|
27
27
|
export declare const readStyleOverlayV5: (doc: YDoc) => StyleOverlayV5;
|
|
28
28
|
/**
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
|
|
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
|
+
* A v5 doc as V2 `SheetData` (same shape as `sheetDataV3ToV2`): every key of
|
|
35
|
+
* `rncCells`, `rncNotes`, the composed style plane and every cold block entry,
|
|
36
|
+
* composed as `composeCell` does (hot shadows cold; tombstones and orphans
|
|
37
|
+
* skipped). Inflates every cold block once.
|
|
32
38
|
*/
|
|
33
39
|
export declare const sheetDataV5ToV2: <T extends CellData>(doc: YDoc, styles?: ReadonlyMap<string, CellFormat>) => SheetData<T>;
|
|
34
40
|
/**
|
|
@@ -40,10 +46,68 @@ export declare const createCellReaderV5: <T extends CellData = CellData>(doc: YD
|
|
|
40
46
|
export declare const getCellV5: <T extends CellData = CellData>(doc: YDoc, sheetId: number, rowIndex: number, columnIndex: number, styles?: ReadonlyMap<string, CellFormat>) => T | undefined;
|
|
41
47
|
/**
|
|
42
48
|
* Apply changed `rncCells` / `rncNotes` keys to `currentSheetData` (copy-on-write,
|
|
43
|
-
* like `processSheetDataEventsV3`), `uf` from `styles
|
|
44
|
-
*
|
|
49
|
+
* like `processSheetDataEventsV3`), `uf` from `styles`; a removed hot entry
|
|
50
|
+
* reveals the cold cell under it. Only valid while no id array, no style and no
|
|
51
|
+
* cold block changed (those need `sheetDataV5ToV2`). Null when nothing changed.
|
|
45
52
|
*/
|
|
46
53
|
export declare const processSheetDataChangesV5: <T extends CellData>(changedKeys: Iterable<string>, currentSheetData: SheetData<T>, doc: YDoc, styles?: ReadonlyMap<string, CellFormat>) => SheetData<T> | null;
|
|
54
|
+
/** A decoded `Addr`; line ids as decimal strings, `null` = an open side (`B:B`, `1:1`). */
|
|
55
|
+
export type FacetAddrV5 = {
|
|
56
|
+
kind: "range";
|
|
57
|
+
sheetId: number;
|
|
58
|
+
r0: string | null;
|
|
59
|
+
r1: string | null;
|
|
60
|
+
c0: string | null;
|
|
61
|
+
c1: string | null;
|
|
62
|
+
} | {
|
|
63
|
+
kind: "cell" | "point";
|
|
64
|
+
sheetId: number;
|
|
65
|
+
row: string;
|
|
66
|
+
col: string;
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* How one anchored map of a facet value reads:
|
|
70
|
+
* - `positional`: no usable anchor (none, undecodable, its recorded fields no
|
|
71
|
+
* longer equal the stored ones, or it names another sheet's lines): the
|
|
72
|
+
* stored positional fields are the truth.
|
|
73
|
+
* - `resolved`: the positional fields now (`fields`; an open side's field is
|
|
74
|
+
* absent and keeps its stored value).
|
|
75
|
+
* - `engine`: a corner line is not in this doc's axis (deleted, or not synced
|
|
76
|
+
* yet). The engine repairs or falls back from what its session saw; a native
|
|
77
|
+
* reader cannot, so read the facet through the engine (or treat it as stale).
|
|
78
|
+
*/
|
|
79
|
+
export type ResolvedFacetAnchorV5 = {
|
|
80
|
+
status: "positional";
|
|
81
|
+
} | {
|
|
82
|
+
status: "resolved";
|
|
83
|
+
fields: Record<string, number>;
|
|
84
|
+
} | {
|
|
85
|
+
status: "engine";
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Decode a facet `anchor` buffer (`decode_anchor`): `u8 n`, the `n` positional
|
|
89
|
+
* fields as written (zigzag varints), then one `Addr` filling the rest.
|
|
90
|
+
*/
|
|
91
|
+
export declare const decodeFacetAnchorV5: (buf: Uint8Array) => {
|
|
92
|
+
frame: number[];
|
|
93
|
+
addr: FacetAddrV5;
|
|
94
|
+
} | null;
|
|
95
|
+
/**
|
|
96
|
+
* Resolve the `anchor` of one anchored map inside a facet value (`site_now`):
|
|
97
|
+
* `site` `"range"` = a map with `startRowIndex`…`endColumnIndex` (a named
|
|
98
|
+
* range, merge, CF / DV range, table, chart range, …), `"cell"` = a one-cell
|
|
99
|
+
* map (`rowIndex` / `columnIndex`) that goes with its lines (data-table input,
|
|
100
|
+
* scenario cells), `"point"` = a floating object's anchor cell. `sheetId` is
|
|
101
|
+
* the sheet the facet lives on.
|
|
102
|
+
*
|
|
103
|
+
* Only live corner lines are resolved here; anything the engine would repair
|
|
104
|
+
* (a deleted line) or fall back on (a line this replica never saw) answers
|
|
105
|
+
* `engine`. Which maps of which facet carry an anchor (and the derived ones:
|
|
106
|
+
* table filter column offsets, print breaks, print titles) is the engine's
|
|
107
|
+
* walk (`facet_anchor.rs`); for those, and whenever the exact answer matters,
|
|
108
|
+
* read facets through the engine.
|
|
109
|
+
*/
|
|
110
|
+
export declare const resolveFacetAnchorV5: (doc: YDoc, sheetId: number, value: Record<string, unknown>, site: "range" | "cell" | "point") => ResolvedFacetAnchorV5;
|
|
47
111
|
/**
|
|
48
112
|
* Apply immer `SheetData` patches to a v5 doc in one transaction (`origin`, the
|
|
49
113
|
* 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":"
|
|
1
|
+
{"version":3,"file":"helpers-v5.d.ts","sourceRoot":"","sources":["../../helpers-v5.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAGjE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAQnC,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;AAwDrD;;;GAGG;AACH,eAAO,MAAM,WAAW,GACtB,KAAK,IAAI,EACT,SAAS,MAAM,EACf,MAAM,KAAK,GAAG,QAAQ,KACrB,MAAM,EAYR,CAAC;AAEF,iEAAiE;AACjE,eAAO,MAAM,eAAe,GAC1B,SAAS,MAAM,EACf,OAAO,MAAM,EACb,OAAO,MAAM,KACZ,MAAwC,CAAC;AAE5C,yEAAyE;AACzE,eAAO,MAAM,cAAc,GAAI,KAAK,MAAM,KAAG,eAAe,GAAG,IAc9D,CAAC;AAyHF;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,GAAI,KAAK,IAAI,KAAG,cAoB9C,CAAC;AA+DF;;;GAGG;AACH,eAAO,MAAM,mBAAmB,GA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KAAK,IAAI,EAAE,SAAS,MAAM,KAAG,IACM,CAAC"}
|
package/dist/cjs/helpers-v5.js
CHANGED
|
@@ -6,18 +6,26 @@
|
|
|
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
|
|
10
|
-
// `
|
|
11
|
-
// `
|
|
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
|
|
16
|
-
//
|
|
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).
|
|
17
24
|
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;
|
|
25
|
+
exports.deleteSheetV5 = exports.deleteCellV5 = exports.setCellV5 = exports.addSheetDataPatchesV5 = exports.resolveFacetAnchorV5 = exports.decodeFacetAnchorV5 = exports.processSheetDataChangesV5 = exports.getCellV5 = exports.createCellReaderV5 = exports.sheetDataV5ToV2 = exports.decodeColumnBlockV5 = exports.readStyleOverlayV5 = exports.parseCellKeyV5 = exports.createCellKeyV5 = exports.readLineIds = void 0;
|
|
19
26
|
var tslib_1 = require("tslib");
|
|
20
27
|
var utils_1 = require("@rowsncolumns/utils");
|
|
28
|
+
var fflate_1 = require("fflate");
|
|
21
29
|
var decoding = tslib_1.__importStar(require("lib0/decoding"));
|
|
22
30
|
var encoding = tslib_1.__importStar(require("lib0/encoding"));
|
|
23
31
|
var cloneDeep_1 = tslib_1.__importDefault(require("lodash/cloneDeep"));
|
|
@@ -34,6 +42,7 @@ var BLOCKS_V5 = "rncColumnBlocks"; // RNC_COLUMN_BLOCKS
|
|
|
34
42
|
var BLOCK_ROWS = 32768; // BLOCK_ROWS
|
|
35
43
|
var BLOCK_V2_MAGIC = 0x80000000; // BLOCK_V2_MAGIC
|
|
36
44
|
var BLOCK_V2_DENSE = 0x40000000; // BLOCK_V2_DENSE
|
|
45
|
+
var MAX_BLOCK_RAW_BYTES = 512 * 1024 * 1024; // MAX_BLOCK_RAW_BYTES
|
|
37
46
|
var STYLE_LOG_V1 = 1; // STYLE_LOG_V1
|
|
38
47
|
var STYLE_LOG_V2 = 2; // STYLE_LOG_V2
|
|
39
48
|
var CELL_KEY_V5 = /^(-?\d+):(-?\d+):(-?\d+)$/; // cell_key
|
|
@@ -352,16 +361,108 @@ var coldCellExists = function (doc, cache, sheetId, rowId, colId) {
|
|
|
352
361
|
}
|
|
353
362
|
return offsets.has((counter - 1) % BLOCK_ROWS);
|
|
354
363
|
};
|
|
364
|
+
/**
|
|
365
|
+
* Cell bodies of a block by row offset (`decode_cell_block_bodies`, v1 too).
|
|
366
|
+
* A malformed block reads as the entries decoded before the damage.
|
|
367
|
+
*/
|
|
368
|
+
var decodeColumnBlockV5 = function (buf) {
|
|
369
|
+
var out = new Map();
|
|
370
|
+
if (buf.length < 4)
|
|
371
|
+
return out;
|
|
372
|
+
var view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
373
|
+
var text = new TextDecoder();
|
|
374
|
+
var body = function (bytes, pos, len) {
|
|
375
|
+
if (pos + len > bytes.length)
|
|
376
|
+
return null;
|
|
377
|
+
var value = JSON.parse(text.decode(bytes.subarray(pos, pos + len)));
|
|
378
|
+
return isPlainObject(value) ? value : null;
|
|
379
|
+
};
|
|
380
|
+
try {
|
|
381
|
+
var first = view.getUint32(0, true);
|
|
382
|
+
if (first & BLOCK_V2_MAGIC) {
|
|
383
|
+
var offsets = blockRowOffsets(buf);
|
|
384
|
+
var pos = 8 + (first & BLOCK_V2_DENSE ? 0 : offsets.length * 4);
|
|
385
|
+
if (pos + 4 > buf.length)
|
|
386
|
+
return out;
|
|
387
|
+
var rawLen = view.getUint32(pos, true);
|
|
388
|
+
if (rawLen > MAX_BLOCK_RAW_BYTES)
|
|
389
|
+
return out;
|
|
390
|
+
var bodies = (0, fflate_1.inflateSync)(buf.subarray(pos + 4), { out: new Uint8Array(rawLen) });
|
|
391
|
+
var bodyView = new DataView(bodies.buffer, bodies.byteOffset, bodies.byteLength);
|
|
392
|
+
for (var i = 0, at = 0; i < offsets.length && at + 4 <= bodies.length; i++) {
|
|
393
|
+
var len = bodyView.getUint32(at, true);
|
|
394
|
+
var cell = body(bodies, at + 4, len);
|
|
395
|
+
if (cell)
|
|
396
|
+
out.set(offsets[i], cell);
|
|
397
|
+
at += 4 + len;
|
|
398
|
+
}
|
|
399
|
+
return out;
|
|
400
|
+
}
|
|
401
|
+
for (var i = 0, pos = 4; i < first && pos + 8 <= buf.length; i++) {
|
|
402
|
+
var offset = view.getUint32(pos, true);
|
|
403
|
+
var len = view.getUint32(pos + 4, true);
|
|
404
|
+
var cell = body(buf, pos + 8, len);
|
|
405
|
+
if (cell)
|
|
406
|
+
out.set(offset, cell);
|
|
407
|
+
pos += 8 + len;
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
catch (_e) {
|
|
411
|
+
// Truncated deflate stream or a body that is not JSON: keep what decoded.
|
|
412
|
+
}
|
|
413
|
+
return out;
|
|
414
|
+
};
|
|
415
|
+
exports.decodeColumnBlockV5 = decodeColumnBlockV5;
|
|
416
|
+
/** Whether `rncColumnBlocks` key `key` is a v5 block (its column part a line id, not `< 2^32`). */
|
|
417
|
+
var parseBlockKeyV5 = function (key) {
|
|
418
|
+
var match = BLOCK_KEY_V5.exec(key);
|
|
419
|
+
if (!match)
|
|
420
|
+
return null;
|
|
421
|
+
var colId = BigInt(match[2]);
|
|
422
|
+
if (BigInt.asIntN(64, colId) !== colId || idCounter(colId) === 0)
|
|
423
|
+
return null;
|
|
424
|
+
return { sheetId: Number(match[1]), colId: colId.toString(), block: Number(match[3]) };
|
|
425
|
+
};
|
|
426
|
+
/**
|
|
427
|
+
* The cold body of the cell at `rowId` × `colId`: entry `(counter - 1) % BLOCK_ROWS`
|
|
428
|
+
* of block `(counter - 1) / BLOCK_ROWS` of the column, for a client-0 row id only.
|
|
429
|
+
*/
|
|
430
|
+
var coldCellV5 = function (doc, cache, sheetId, rowId, colId) {
|
|
431
|
+
var _a;
|
|
432
|
+
var counter = c0Counter(rowId);
|
|
433
|
+
if (!counter || !doc.share.has(BLOCKS_V5))
|
|
434
|
+
return null;
|
|
435
|
+
var key = "".concat(sheetId, ":").concat(colId, ":").concat(Math.floor((counter - 1) / BLOCK_ROWS));
|
|
436
|
+
var cells = cache.get(key);
|
|
437
|
+
if (!cells) {
|
|
438
|
+
var buf = doc.get(BLOCKS_V5).getAttr(key);
|
|
439
|
+
cells = buf instanceof Uint8Array ? (0, exports.decodeColumnBlockV5)(buf) : new Map();
|
|
440
|
+
cache.set(key, cells);
|
|
441
|
+
}
|
|
442
|
+
return (_a = cells.get((counter - 1) % BLOCK_ROWS)) !== null && _a !== void 0 ? _a : null;
|
|
443
|
+
};
|
|
355
444
|
// ── readers ─────────────────────────────────────────────────────────────────
|
|
356
445
|
/**
|
|
357
|
-
* The
|
|
358
|
-
* `
|
|
359
|
-
|
|
446
|
+
* The stored value of the cell under `key`: its hot entry (`ft` stripped; a
|
|
447
|
+
* `null` or any non-map is a tombstone and reads null), else its cold body.
|
|
448
|
+
*/
|
|
449
|
+
var storedCellV5 = function (doc, key, cold) {
|
|
450
|
+
var hot = doc.share.has(CELLS_V5) ? doc.get(CELLS_V5) : null;
|
|
451
|
+
if (hot === null || hot === void 0 ? void 0 : hot.hasAttr(key))
|
|
452
|
+
return cellDataV5(hot.getAttr(key));
|
|
453
|
+
var parsed = (0, exports.parseCellKeyV5)(key);
|
|
454
|
+
if (!parsed)
|
|
455
|
+
return null;
|
|
456
|
+
var body = coldCellV5(doc, cold, parsed.sheetId, parsed.rowId, parsed.colId);
|
|
457
|
+
return body ? cellDataV5(body) : null;
|
|
458
|
+
};
|
|
459
|
+
/**
|
|
460
|
+
* The cell under `key` as the readers show it: the stored value
|
|
461
|
+
* (`storedCellV5`), `uf` from `styles` where it has an entry, `note` from
|
|
462
|
+
* `rncNotes` where it has one. Null when none of the three holds anything.
|
|
360
463
|
*/
|
|
361
|
-
var composeCell = function (doc, key, styles) {
|
|
362
|
-
var cell = doc
|
|
363
|
-
? cellDataV5(doc.get(CELLS_V5).getAttr(key))
|
|
364
|
-
: null;
|
|
464
|
+
var composeCell = function (doc, key, styles, cold) {
|
|
465
|
+
var cell = storedCellV5(doc, key, cold);
|
|
365
466
|
var uf = styles.get(key);
|
|
366
467
|
if (uf)
|
|
367
468
|
cell = tslib_1.__assign(tslib_1.__assign({}, cell), { uf: uf });
|
|
@@ -371,9 +472,10 @@ var composeCell = function (doc, key, styles) {
|
|
|
371
472
|
return cell;
|
|
372
473
|
};
|
|
373
474
|
/**
|
|
374
|
-
* A v5 doc as V2 `SheetData` (same shape as `sheetDataV3ToV2`)
|
|
375
|
-
*
|
|
376
|
-
* `composeCell` does (tombstones and orphans
|
|
475
|
+
* A v5 doc as V2 `SheetData` (same shape as `sheetDataV3ToV2`): every key of
|
|
476
|
+
* `rncCells`, `rncNotes`, the composed style plane and every cold block entry,
|
|
477
|
+
* composed as `composeCell` does (hot shadows cold; tombstones and orphans
|
|
478
|
+
* skipped). Inflates every cold block once.
|
|
377
479
|
*/
|
|
378
480
|
var sheetDataV5ToV2 = function (doc, styles) {
|
|
379
481
|
var e_6, _a, e_7, _b, e_8, _c;
|
|
@@ -382,6 +484,7 @@ var sheetDataV5ToV2 = function (doc, styles) {
|
|
|
382
484
|
if (styles === void 0) { styles = (0, exports.readStyleOverlayV5)(doc); }
|
|
383
485
|
var sheetData = {};
|
|
384
486
|
var cache = new Map();
|
|
487
|
+
var cold = new Map();
|
|
385
488
|
var keys = new Set(styles.keys());
|
|
386
489
|
try {
|
|
387
490
|
for (var _h = tslib_1.__values([CELLS_V5, NOTES_V5]), _j = _h.next(); !_j.done; _j = _h.next()) {
|
|
@@ -410,12 +513,28 @@ var sheetDataV5ToV2 = function (doc, styles) {
|
|
|
410
513
|
}
|
|
411
514
|
finally { if (e_6) throw e_6.error; }
|
|
412
515
|
}
|
|
516
|
+
if (doc.share.has(BLOCKS_V5)) {
|
|
517
|
+
(0, ynodes_1.forEachEntry)(doc.get(BLOCKS_V5), function (value, blockKey) {
|
|
518
|
+
var parsed = parseBlockKeyV5(blockKey);
|
|
519
|
+
if (!parsed || !(value instanceof Uint8Array))
|
|
520
|
+
return;
|
|
521
|
+
var cells = (0, exports.decodeColumnBlockV5)(value);
|
|
522
|
+
cold.set(blockKey, cells);
|
|
523
|
+
var rows = sheetLinesV5(doc, cache, parsed.sheetId).rows;
|
|
524
|
+
cells.forEach(function (_cell, offset) {
|
|
525
|
+
var rowId = c0Id(parsed.block * BLOCK_ROWS + offset + 1);
|
|
526
|
+
// A row not in the axis is deleted: its block cells are orphans.
|
|
527
|
+
if (rows.has(rowId))
|
|
528
|
+
keys.add((0, exports.createCellKeyV5)(parsed.sheetId, rowId, parsed.colId));
|
|
529
|
+
});
|
|
530
|
+
});
|
|
531
|
+
}
|
|
413
532
|
try {
|
|
414
533
|
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
534
|
var key = keys_1_1.value;
|
|
416
535
|
var parsed = (0, exports.parseCellKeyV5)(key);
|
|
417
536
|
var pos = parsed && positionV5(doc, cache, parsed);
|
|
418
|
-
var cell = pos && composeCell(doc, key, styles);
|
|
537
|
+
var cell = pos && composeCell(doc, key, styles, cold);
|
|
419
538
|
if (!parsed || !pos || !cell)
|
|
420
539
|
continue;
|
|
421
540
|
var _m = tslib_1.__read(pos, 2), rowIdx = _m[0], colIdx = _m[1];
|
|
@@ -447,6 +566,7 @@ exports.sheetDataV5ToV2 = sheetDataV5ToV2;
|
|
|
447
566
|
var createCellReaderV5 = function (doc, styles) {
|
|
448
567
|
if (styles === void 0) { styles = (0, exports.readStyleOverlayV5)(doc); }
|
|
449
568
|
var lines = new Map();
|
|
569
|
+
var cold = new Map();
|
|
450
570
|
return function (sheetId, rowIndex, columnIndex) {
|
|
451
571
|
var _a;
|
|
452
572
|
var ids = lines.get(sheetId);
|
|
@@ -458,7 +578,7 @@ var createCellReaderV5 = function (doc, styles) {
|
|
|
458
578
|
var colId = ids[1][columnIndex - 1];
|
|
459
579
|
if (rowId === undefined || colId === undefined)
|
|
460
580
|
return undefined;
|
|
461
|
-
return (_a = composeCell(doc, (0, exports.createCellKeyV5)(sheetId, rowId, colId), styles)) !== null && _a !== void 0 ? _a : undefined;
|
|
581
|
+
return ((_a = composeCell(doc, (0, exports.createCellKeyV5)(sheetId, rowId, colId), styles, cold)) !== null && _a !== void 0 ? _a : undefined);
|
|
462
582
|
};
|
|
463
583
|
};
|
|
464
584
|
exports.createCellReaderV5 = createCellReaderV5;
|
|
@@ -467,14 +587,16 @@ var getCellV5 = function (doc, sheetId, rowIndex, columnIndex, styles) { return
|
|
|
467
587
|
exports.getCellV5 = getCellV5;
|
|
468
588
|
/**
|
|
469
589
|
* Apply changed `rncCells` / `rncNotes` keys to `currentSheetData` (copy-on-write,
|
|
470
|
-
* like `processSheetDataEventsV3`), `uf` from `styles
|
|
471
|
-
*
|
|
590
|
+
* like `processSheetDataEventsV3`), `uf` from `styles`; a removed hot entry
|
|
591
|
+
* reveals the cold cell under it. Only valid while no id array, no style and no
|
|
592
|
+
* cold block changed (those need `sheetDataV5ToV2`). Null when nothing changed.
|
|
472
593
|
*/
|
|
473
594
|
var processSheetDataChangesV5 = function (changedKeys, currentSheetData, doc, styles) {
|
|
474
595
|
var e_9, _a;
|
|
475
596
|
var _b, _c, _d;
|
|
476
597
|
if (styles === void 0) { styles = (0, exports.readStyleOverlayV5)(doc); }
|
|
477
598
|
var cache = new Map();
|
|
599
|
+
var cold = new Map();
|
|
478
600
|
var next = tslib_1.__assign({}, currentSheetData);
|
|
479
601
|
var clonedSheets = new Set();
|
|
480
602
|
var clonedRows = new Set();
|
|
@@ -488,7 +610,7 @@ var processSheetDataChangesV5 = function (changedKeys, currentSheetData, doc, st
|
|
|
488
610
|
continue;
|
|
489
611
|
var _h = tslib_1.__read(pos, 2), rowIdx = _h[0], colIdx = _h[1];
|
|
490
612
|
var sheetId = parsed.sheetId;
|
|
491
|
-
var cell = composeCell(doc, key, styles);
|
|
613
|
+
var cell = composeCell(doc, key, styles, cold);
|
|
492
614
|
var row = (_b = next[sheetId]) === null || _b === void 0 ? void 0 : _b[rowIdx];
|
|
493
615
|
if (!cell && !((_c = row === null || row === void 0 ? void 0 : row.values) === null || _c === void 0 ? void 0 : _c[colIdx]))
|
|
494
616
|
continue;
|
|
@@ -522,6 +644,161 @@ var processSheetDataChangesV5 = function (changedKeys, currentSheetData, doc, st
|
|
|
522
644
|
return hasChanges ? next : null;
|
|
523
645
|
};
|
|
524
646
|
exports.processSheetDataChangesV5 = processSheetDataChangesV5;
|
|
647
|
+
// ── facet anchors (facet_anchor.rs, addr.rs) ────────────────────────────────
|
|
648
|
+
var MAX_ROW = 1048576; // MAX_ROW
|
|
649
|
+
var MAX_COL = 16384; // MAX_COL
|
|
650
|
+
var TAG_RANGE = 1; // TAG_RANGE
|
|
651
|
+
var TAG_CELL = 2; // TAG_CELL
|
|
652
|
+
var TAG_POINT = 3; // TAG_POINT
|
|
653
|
+
var RANGE_KEYS = ["startRowIndex", "endRowIndex", "startColumnIndex", "endColumnIndex"];
|
|
654
|
+
var CELL_KEYS = ["rowIndex", "columnIndex"];
|
|
655
|
+
/** Zigzag LEB128 `i64` (`get_var`). */
|
|
656
|
+
var readVar = function (buf, at) {
|
|
657
|
+
var z = BigInt(0);
|
|
658
|
+
for (var shift = BigInt(0); shift < BigInt(64); shift += BigInt(7)) {
|
|
659
|
+
if (at.pos >= buf.length)
|
|
660
|
+
return null;
|
|
661
|
+
var b = buf[at.pos++];
|
|
662
|
+
z |= BigInt(b & 0x7f) << shift;
|
|
663
|
+
if ((b & 0x80) === 0) {
|
|
664
|
+
return BigInt.asIntN(64, (z >> BigInt(1)) ^ -(z & BigInt(1)));
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
return null;
|
|
668
|
+
};
|
|
669
|
+
/**
|
|
670
|
+
* Decode a facet `anchor` buffer (`decode_anchor`): `u8 n`, the `n` positional
|
|
671
|
+
* fields as written (zigzag varints), then one `Addr` filling the rest.
|
|
672
|
+
*/
|
|
673
|
+
var decodeFacetAnchorV5 = function (buf) {
|
|
674
|
+
var at = { pos: 0 };
|
|
675
|
+
if (!buf.length)
|
|
676
|
+
return null;
|
|
677
|
+
var n = buf[at.pos++];
|
|
678
|
+
var frame = [];
|
|
679
|
+
for (var i = 0; i < n; i++) {
|
|
680
|
+
var v = readVar(buf, at);
|
|
681
|
+
if (v === null)
|
|
682
|
+
return null;
|
|
683
|
+
frame.push(Number(v));
|
|
684
|
+
}
|
|
685
|
+
if (at.pos >= buf.length)
|
|
686
|
+
return null;
|
|
687
|
+
var tag = buf[at.pos++];
|
|
688
|
+
var sheet = readVar(buf, at);
|
|
689
|
+
if (sheet === null)
|
|
690
|
+
return null;
|
|
691
|
+
var sheetId = Number(sheet);
|
|
692
|
+
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; };
|
|
693
|
+
var addr;
|
|
694
|
+
if (tag === TAG_RANGE) {
|
|
695
|
+
if (at.pos + 2 > buf.length)
|
|
696
|
+
return null;
|
|
697
|
+
at.pos++; // abs
|
|
698
|
+
var bits = buf[at.pos++];
|
|
699
|
+
var corners = [];
|
|
700
|
+
for (var i = 0; i < 4; i++) {
|
|
701
|
+
if (bits & (1 << i)) {
|
|
702
|
+
var c = id();
|
|
703
|
+
if (c === null)
|
|
704
|
+
return null;
|
|
705
|
+
corners.push(c);
|
|
706
|
+
}
|
|
707
|
+
else {
|
|
708
|
+
corners.push(null);
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
var _a = tslib_1.__read(corners, 4), r0 = _a[0], r1 = _a[1], c0 = _a[2], c1 = _a[3];
|
|
712
|
+
addr = { kind: "range", sheetId: sheetId, r0: r0, r1: r1, c0: c0, c1: c1 };
|
|
713
|
+
}
|
|
714
|
+
else if (tag === TAG_CELL || tag === TAG_POINT) {
|
|
715
|
+
if (tag === TAG_CELL) {
|
|
716
|
+
if (at.pos >= buf.length)
|
|
717
|
+
return null;
|
|
718
|
+
at.pos++; // abs
|
|
719
|
+
}
|
|
720
|
+
var row = id();
|
|
721
|
+
var col = id();
|
|
722
|
+
if (row === null || col === null)
|
|
723
|
+
return null;
|
|
724
|
+
addr = { kind: tag === TAG_CELL ? "cell" : "point", sheetId: sheetId, row: row, col: col };
|
|
725
|
+
}
|
|
726
|
+
else {
|
|
727
|
+
return null;
|
|
728
|
+
}
|
|
729
|
+
return at.pos === buf.length ? { frame: frame, addr: addr } : null;
|
|
730
|
+
};
|
|
731
|
+
exports.decodeFacetAnchorV5 = decodeFacetAnchorV5;
|
|
732
|
+
/**
|
|
733
|
+
* Resolve the `anchor` of one anchored map inside a facet value (`site_now`):
|
|
734
|
+
* `site` `"range"` = a map with `startRowIndex`…`endColumnIndex` (a named
|
|
735
|
+
* range, merge, CF / DV range, table, chart range, …), `"cell"` = a one-cell
|
|
736
|
+
* map (`rowIndex` / `columnIndex`) that goes with its lines (data-table input,
|
|
737
|
+
* scenario cells), `"point"` = a floating object's anchor cell. `sheetId` is
|
|
738
|
+
* the sheet the facet lives on.
|
|
739
|
+
*
|
|
740
|
+
* Only live corner lines are resolved here; anything the engine would repair
|
|
741
|
+
* (a deleted line) or fall back on (a line this replica never saw) answers
|
|
742
|
+
* `engine`. Which maps of which facet carry an anchor (and the derived ones:
|
|
743
|
+
* table filter column offsets, print breaks, print titles) is the engine's
|
|
744
|
+
* walk (`facet_anchor.rs`); for those, and whenever the exact answer matters,
|
|
745
|
+
* read facets through the engine.
|
|
746
|
+
*/
|
|
747
|
+
var resolveFacetAnchorV5 = function (doc, sheetId, value, site) {
|
|
748
|
+
var positional = { status: "positional" };
|
|
749
|
+
var buf = value.anchor;
|
|
750
|
+
if (!(buf instanceof Uint8Array))
|
|
751
|
+
return positional;
|
|
752
|
+
var decoded = (0, exports.decodeFacetAnchorV5)(buf);
|
|
753
|
+
if (!decoded)
|
|
754
|
+
return positional;
|
|
755
|
+
var frame = decoded.frame, addr = decoded.addr;
|
|
756
|
+
var keys = site === "range" ? RANGE_KEYS : CELL_KEYS;
|
|
757
|
+
var stored = keys.map(function (k) { return value[k]; });
|
|
758
|
+
if (stored.length !== frame.length ||
|
|
759
|
+
stored.some(function (v, i) { return typeof v !== "number" || v !== frame[i]; })) {
|
|
760
|
+
return positional;
|
|
761
|
+
}
|
|
762
|
+
// A value copied onto another sheet with its anchors names the source's lines.
|
|
763
|
+
if (addr.sheetId !== sheetId)
|
|
764
|
+
return positional;
|
|
765
|
+
var lines = sheetLinesV5(doc, new Map(), sheetId);
|
|
766
|
+
if (site === "point") {
|
|
767
|
+
if (addr.kind !== "point")
|
|
768
|
+
return positional;
|
|
769
|
+
var row = lines.rows.get(addr.row);
|
|
770
|
+
var col = lines.cols.get(addr.col);
|
|
771
|
+
if (row === undefined || col === undefined)
|
|
772
|
+
return { status: "engine" };
|
|
773
|
+
return { status: "resolved", fields: { rowIndex: row, columnIndex: col } };
|
|
774
|
+
}
|
|
775
|
+
if (addr.kind !== "range")
|
|
776
|
+
return positional;
|
|
777
|
+
var axis = function (index, c0, c1, max) {
|
|
778
|
+
var s = c0 === null ? 1 : index.get(c0);
|
|
779
|
+
var e = c1 === null ? max : index.get(c1);
|
|
780
|
+
if (s === undefined || e === undefined)
|
|
781
|
+
return null;
|
|
782
|
+
// Both lines live in the other order (a move): the box of both.
|
|
783
|
+
return s <= e ? [s, e] : [e, s];
|
|
784
|
+
};
|
|
785
|
+
var rows = axis(lines.rows, addr.r0, addr.r1, MAX_ROW);
|
|
786
|
+
var cols = axis(lines.cols, addr.c0, addr.c1, MAX_COL);
|
|
787
|
+
if (!rows || !cols)
|
|
788
|
+
return { status: "engine" };
|
|
789
|
+
if (site === "cell") {
|
|
790
|
+
return { status: "resolved", fields: { rowIndex: rows[0], columnIndex: cols[0] } };
|
|
791
|
+
}
|
|
792
|
+
var now = [rows[0], rows[1], cols[0], cols[1]];
|
|
793
|
+
var open = [addr.r0, addr.r1, addr.c0, addr.c1].map(function (c) { return c === null; });
|
|
794
|
+
var fields = {};
|
|
795
|
+
RANGE_KEYS.forEach(function (k, i) {
|
|
796
|
+
if (!open[i])
|
|
797
|
+
fields[k] = now[i];
|
|
798
|
+
});
|
|
799
|
+
return { status: "resolved", fields: fields };
|
|
800
|
+
};
|
|
801
|
+
exports.resolveFacetAnchorV5 = resolveFacetAnchorV5;
|
|
525
802
|
var axisKey = function (sheetId, isRow) {
|
|
526
803
|
return "".concat(sheetId, ":").concat(isRow ? "R" : "C");
|
|
527
804
|
};
|
|
@@ -653,7 +930,8 @@ var queueStyle = function (w, sheetId, rowId, colId, format) {
|
|
|
653
930
|
* composed plane's entry, else the inline `uf`) is logged as a replace (a
|
|
654
931
|
* clear, then the format; a style reference only clears: the engine cannot
|
|
655
932
|
* resolve it). A note lives in `rncNotes` when the key has an entry there,
|
|
656
|
-
* inline otherwise. An unchanged cell
|
|
933
|
+
* inline otherwise. An unchanged cell (hot, or cold with no hot entry) is not
|
|
934
|
+
* rewritten (its `ft` survives; a cold cell gets no hot copy).
|
|
657
935
|
*/
|
|
658
936
|
var writeCell = function (w, sheetId, row, col, cell) {
|
|
659
937
|
var _a;
|
|
@@ -662,7 +940,7 @@ var writeCell = function (w, sheetId, row, col, cell) {
|
|
|
662
940
|
var rowId = ensureLine(w, sheetId, true, row);
|
|
663
941
|
var colId = ensureLine(w, sheetId, false, col);
|
|
664
942
|
var key = (0, exports.createCellKeyV5)(sheetId, rowId, colId);
|
|
665
|
-
var stored =
|
|
943
|
+
var stored = storedCellV5(w.doc, key, w.cold);
|
|
666
944
|
var format = normalizedFormat((0, utils_1.getCellUserEnteredFormat)(cell));
|
|
667
945
|
var storedFormat = normalizedFormat((_a = writerStyles(w).get(key)) !== null && _a !== void 0 ? _a : (0, utils_1.getCellUserEnteredFormat)(stored));
|
|
668
946
|
if (!(0, isEqual_1.default)(format, storedFormat)) {
|
|
@@ -803,6 +1081,7 @@ var clearSheets = function (w, match) {
|
|
|
803
1081
|
drop(BLOCKS_V5);
|
|
804
1082
|
drop(NOTES_V5);
|
|
805
1083
|
drop(STYLES_SEED_V5);
|
|
1084
|
+
w.cold.clear();
|
|
806
1085
|
try {
|
|
807
1086
|
for (var _b = tslib_1.__values(Array.from(writerStyles(w).keys())), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
808
1087
|
var key = _c.value;
|
|
@@ -821,7 +1100,7 @@ var clearSheets = function (w, match) {
|
|
|
821
1100
|
}
|
|
822
1101
|
w.offsets.clear();
|
|
823
1102
|
};
|
|
824
|
-
/** The cell a nested patch edits: the stored cell as the readers show it. */
|
|
1103
|
+
/** The cell a nested patch edits: the stored cell (hot, else cold) as the readers show it. */
|
|
825
1104
|
var nestedBase = function (w, sheetId, row, col) {
|
|
826
1105
|
var _a;
|
|
827
1106
|
var rowId = writerAxis(w, sheetId, true).ids[row - 1];
|
|
@@ -829,10 +1108,7 @@ var nestedBase = function (w, sheetId, row, col) {
|
|
|
829
1108
|
if (rowId === undefined || colId === undefined)
|
|
830
1109
|
return {};
|
|
831
1110
|
var key = (0, exports.createCellKeyV5)(sheetId, rowId, colId);
|
|
832
|
-
|
|
833
|
-
return null;
|
|
834
|
-
}
|
|
835
|
-
return (_a = composeCell(w.doc, key, writerStyles(w))) !== null && _a !== void 0 ? _a : {};
|
|
1111
|
+
return (_a = composeCell(w.doc, key, writerStyles(w), w.cold)) !== null && _a !== void 0 ? _a : {};
|
|
836
1112
|
};
|
|
837
1113
|
var applyPatchV5 = function (w, _a) {
|
|
838
1114
|
var e_15, _b;
|
|
@@ -864,11 +1140,6 @@ var applyPatchV5 = function (w, _a) {
|
|
|
864
1140
|
if (!validPosition(row, col))
|
|
865
1141
|
return;
|
|
866
1142
|
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
1143
|
var cell = (0, cloneDeep_1.default)(base);
|
|
873
1144
|
var nested = path.slice(4);
|
|
874
1145
|
if (op === "remove") {
|
|
@@ -918,6 +1189,7 @@ var addSheetDataPatchesV5 = function (doc, patches, origin, styles) {
|
|
|
918
1189
|
styles: styles !== null && styles !== void 0 ? styles : null,
|
|
919
1190
|
ops: [],
|
|
920
1191
|
offsets: new Map(),
|
|
1192
|
+
cold: new Map(),
|
|
921
1193
|
};
|
|
922
1194
|
// Consecutive cell patches are consolidated (the later one wins) but never
|
|
923
1195
|
// 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` (
|
|
80
|
+
* from `rncCells` and the cold `rncColumnBlocks`, written to `rncCells` (see `helpers-v5.ts`)
|
|
81
81
|
*/
|
|
82
82
|
sheetDataVersion?: "v2" | "v3" | "v5";
|
|
83
83
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-yspreadsheet-v2.d.ts","sourceRoot":"","sources":["../../use-yspreadsheet-v2.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACvE,OAAO,EAEL,UAAU,EACV,KAAK,QAAQ,EAEb,KAAK,YAAY,EACjB,KAAK,qBAAqB,EAC1B,KAAK,wBAAwB,EAC7B,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,UAAU,EACf,KAAK,cAAc,EACnB,KAAK,KAAK,EACV,KAAK,SAAS,EACf,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,KAAK,OAAO,EACZ,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACtB,MAAM,iCAAiC,CAAC;AASzC,OAAO,KAAK,EAAE,KAAK,EAAE,MA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AgxBtB,CACP,KAAK,EAAE,gBAAgB,CAAC,KAAK,CAAC,EAC9B,IAAI,CAAC,EAAE,WAAW,GAAG,SAAS,GAAG,IAAI,CACtC,EAAE;;;CA6SR,CAAC"}
|
|
@@ -635,9 +635,9 @@ var useYSpreadsheetV2 = function (_a) {
|
|
|
635
635
|
ySheetDataV3.unobserve(callback);
|
|
636
636
|
};
|
|
637
637
|
}, [onChangeSheetData, ySheetDataV3, useV3, yjs, observesLocal]);
|
|
638
|
-
// Only for sheet Data (V5 docs): `rncCells`, `rncNotes`, the style planes
|
|
639
|
-
// every sheet's id arrays. A change of an id array, a
|
|
640
|
-
// `docMeta`): full re-read; a cell or note change alone is applied
|
|
638
|
+
// Only for sheet Data (V5 docs): `rncCells`, `rncNotes`, the style planes,
|
|
639
|
+
// the cold blocks and every sheet's id arrays. A change of an id array, a
|
|
640
|
+
// style plane, a cold block (or of `docMeta`): full re-read; a cell or note change alone is applied
|
|
641
641
|
// incrementally. Roots are matched by name in `doc.share`, so a root a peer
|
|
642
642
|
// created after this effect ran is seen too.
|
|
643
643
|
(0, ui_1.useIsomorphicLayoutEffect)(function () {
|
|
@@ -658,6 +658,7 @@ var useYSpreadsheetV2 = function (_a) {
|
|
|
658
658
|
changed.forEach(function (key) { return key !== null && cellKeys.push(key); });
|
|
659
659
|
}
|
|
660
660
|
else if (name_1 === "docMeta" ||
|
|
661
|
+
name_1 === "rncColumnBlocks" ||
|
|
661
662
|
name_1 === "rncCellStylesLog" ||
|
|
662
663
|
name_1 === "rncCellStyles" ||
|
|
663
664
|
name_1.startsWith("rncRowIds:") ||
|
package/dist/esm/helpers-v5.d.ts
CHANGED
|
@@ -26,9 +26,15 @@ export declare const parseCellKeyV5: (key: string) => ParsedCellKeyV5 | null;
|
|
|
26
26
|
*/
|
|
27
27
|
export declare const readStyleOverlayV5: (doc: YDoc) => StyleOverlayV5;
|
|
28
28
|
/**
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
|
|
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
|
+
* A v5 doc as V2 `SheetData` (same shape as `sheetDataV3ToV2`): every key of
|
|
35
|
+
* `rncCells`, `rncNotes`, the composed style plane and every cold block entry,
|
|
36
|
+
* composed as `composeCell` does (hot shadows cold; tombstones and orphans
|
|
37
|
+
* skipped). Inflates every cold block once.
|
|
32
38
|
*/
|
|
33
39
|
export declare const sheetDataV5ToV2: <T extends CellData>(doc: YDoc, styles?: ReadonlyMap<string, CellFormat>) => SheetData<T>;
|
|
34
40
|
/**
|
|
@@ -40,10 +46,68 @@ export declare const createCellReaderV5: <T extends CellData = CellData>(doc: YD
|
|
|
40
46
|
export declare const getCellV5: <T extends CellData = CellData>(doc: YDoc, sheetId: number, rowIndex: number, columnIndex: number, styles?: ReadonlyMap<string, CellFormat>) => T | undefined;
|
|
41
47
|
/**
|
|
42
48
|
* Apply changed `rncCells` / `rncNotes` keys to `currentSheetData` (copy-on-write,
|
|
43
|
-
* like `processSheetDataEventsV3`), `uf` from `styles
|
|
44
|
-
*
|
|
49
|
+
* like `processSheetDataEventsV3`), `uf` from `styles`; a removed hot entry
|
|
50
|
+
* reveals the cold cell under it. Only valid while no id array, no style and no
|
|
51
|
+
* cold block changed (those need `sheetDataV5ToV2`). Null when nothing changed.
|
|
45
52
|
*/
|
|
46
53
|
export declare const processSheetDataChangesV5: <T extends CellData>(changedKeys: Iterable<string>, currentSheetData: SheetData<T>, doc: YDoc, styles?: ReadonlyMap<string, CellFormat>) => SheetData<T> | null;
|
|
54
|
+
/** A decoded `Addr`; line ids as decimal strings, `null` = an open side (`B:B`, `1:1`). */
|
|
55
|
+
export type FacetAddrV5 = {
|
|
56
|
+
kind: "range";
|
|
57
|
+
sheetId: number;
|
|
58
|
+
r0: string | null;
|
|
59
|
+
r1: string | null;
|
|
60
|
+
c0: string | null;
|
|
61
|
+
c1: string | null;
|
|
62
|
+
} | {
|
|
63
|
+
kind: "cell" | "point";
|
|
64
|
+
sheetId: number;
|
|
65
|
+
row: string;
|
|
66
|
+
col: string;
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* How one anchored map of a facet value reads:
|
|
70
|
+
* - `positional`: no usable anchor (none, undecodable, its recorded fields no
|
|
71
|
+
* longer equal the stored ones, or it names another sheet's lines): the
|
|
72
|
+
* stored positional fields are the truth.
|
|
73
|
+
* - `resolved`: the positional fields now (`fields`; an open side's field is
|
|
74
|
+
* absent and keeps its stored value).
|
|
75
|
+
* - `engine`: a corner line is not in this doc's axis (deleted, or not synced
|
|
76
|
+
* yet). The engine repairs or falls back from what its session saw; a native
|
|
77
|
+
* reader cannot, so read the facet through the engine (or treat it as stale).
|
|
78
|
+
*/
|
|
79
|
+
export type ResolvedFacetAnchorV5 = {
|
|
80
|
+
status: "positional";
|
|
81
|
+
} | {
|
|
82
|
+
status: "resolved";
|
|
83
|
+
fields: Record<string, number>;
|
|
84
|
+
} | {
|
|
85
|
+
status: "engine";
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Decode a facet `anchor` buffer (`decode_anchor`): `u8 n`, the `n` positional
|
|
89
|
+
* fields as written (zigzag varints), then one `Addr` filling the rest.
|
|
90
|
+
*/
|
|
91
|
+
export declare const decodeFacetAnchorV5: (buf: Uint8Array) => {
|
|
92
|
+
frame: number[];
|
|
93
|
+
addr: FacetAddrV5;
|
|
94
|
+
} | null;
|
|
95
|
+
/**
|
|
96
|
+
* Resolve the `anchor` of one anchored map inside a facet value (`site_now`):
|
|
97
|
+
* `site` `"range"` = a map with `startRowIndex`…`endColumnIndex` (a named
|
|
98
|
+
* range, merge, CF / DV range, table, chart range, …), `"cell"` = a one-cell
|
|
99
|
+
* map (`rowIndex` / `columnIndex`) that goes with its lines (data-table input,
|
|
100
|
+
* scenario cells), `"point"` = a floating object's anchor cell. `sheetId` is
|
|
101
|
+
* the sheet the facet lives on.
|
|
102
|
+
*
|
|
103
|
+
* Only live corner lines are resolved here; anything the engine would repair
|
|
104
|
+
* (a deleted line) or fall back on (a line this replica never saw) answers
|
|
105
|
+
* `engine`. Which maps of which facet carry an anchor (and the derived ones:
|
|
106
|
+
* table filter column offsets, print breaks, print titles) is the engine's
|
|
107
|
+
* walk (`facet_anchor.rs`); for those, and whenever the exact answer matters,
|
|
108
|
+
* read facets through the engine.
|
|
109
|
+
*/
|
|
110
|
+
export declare const resolveFacetAnchorV5: (doc: YDoc, sheetId: number, value: Record<string, unknown>, site: "range" | "cell" | "point") => ResolvedFacetAnchorV5;
|
|
47
111
|
/**
|
|
48
112
|
* Apply immer `SheetData` patches to a v5 doc in one transaction (`origin`, the
|
|
49
113
|
* 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":"
|
|
1
|
+
{"version":3,"file":"helpers-v5.d.ts","sourceRoot":"","sources":["../../helpers-v5.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAGjE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAQnC,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;AAwDrD;;;GAGG;A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AM,qBAAqB,GAChC,KAAK,IAAI,EACT,SAAS,KAAK,EAAE,GAAG,SAAS,EAC5B,SAAQ,OAAc,EACtB,SAAS,cAAc,SA8CxB,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"}
|
package/dist/esm/helpers-v5.js
CHANGED
|
@@ -5,15 +5,23 @@
|
|
|
5
5
|
// (`RNC_CELLS`, `c0_floor`, …) are the Rust ones in rust/crates/rnc-yrs-store/src
|
|
6
6
|
// (lib.rs unless a module is named); they win over this module.
|
|
7
7
|
//
|
|
8
|
-
// Readers
|
|
9
|
-
// `
|
|
10
|
-
// `
|
|
8
|
+
// Readers: `sheetDataV5ToV2`, `getCellV5`, `createCellReaderV5`,
|
|
9
|
+
// `processSheetDataChangesV5`. A cell is its hot `rncCells` entry, else its cold
|
|
10
|
+
// `rncColumnBlocks` body (a hot `null` hides the cold cell; orphans of deleted
|
|
11
|
+
// lines are skipped); `uf` from the composed style plane, `note` from
|
|
12
|
+
// `rncNotes`, so a cell read here can be written back unchanged.
|
|
13
|
+
// Facets: `resolveFacetAnchorV5` resolves one stored `anchor` from live line
|
|
14
|
+
// ids; a deleted or unsynced corner line needs the engine's repair.
|
|
11
15
|
// Writer: `addSheetDataPatchesV5` applies immer `SheetData` patches positionally
|
|
12
16
|
// (a structural edit arrives as rewritten rows, v3 parity); it names lines past
|
|
13
17
|
// an axis with client-0 ids exactly as `YrsStore::ensure_lines` does and logs
|
|
14
|
-
// `uf` changes as `STYLE_LOG_V2` ops. It never writes `ft
|
|
15
|
-
//
|
|
18
|
+
// `uf` changes as `STYLE_LOG_V2` ops. It never writes `ft` (engine-owned: the
|
|
19
|
+
// engine derives it on its next write of the cell; until then the formula is
|
|
20
|
+
// positional in its write frame, `ue.fv` being the truth) and never writes a
|
|
21
|
+
// facet `anchor` (a facet written here is positional and gains one on its next
|
|
22
|
+
// engine write).
|
|
16
23
|
import { getCellUserEnteredFormat } from "@rowsncolumns/utils";
|
|
24
|
+
import { inflateSync } from "fflate";
|
|
17
25
|
import * as decoding from "lib0/decoding";
|
|
18
26
|
import * as encoding from "lib0/encoding";
|
|
19
27
|
import cloneDeep from "lodash/cloneDeep";
|
|
@@ -30,6 +38,7 @@ const BLOCKS_V5 = "rncColumnBlocks"; // RNC_COLUMN_BLOCKS
|
|
|
30
38
|
const BLOCK_ROWS = 32768; // BLOCK_ROWS
|
|
31
39
|
const BLOCK_V2_MAGIC = 0x80000000; // BLOCK_V2_MAGIC
|
|
32
40
|
const BLOCK_V2_DENSE = 0x40000000; // BLOCK_V2_DENSE
|
|
41
|
+
const MAX_BLOCK_RAW_BYTES = 512 * 1024 * 1024; // MAX_BLOCK_RAW_BYTES
|
|
33
42
|
const STYLE_LOG_V1 = 1; // STYLE_LOG_V1
|
|
34
43
|
const STYLE_LOG_V2 = 2; // STYLE_LOG_V2
|
|
35
44
|
const CELL_KEY_V5 = /^(-?\d+):(-?\d+):(-?\d+)$/; // cell_key
|
|
@@ -275,16 +284,106 @@ const coldCellExists = (doc, cache, sheetId, rowId, colId) => {
|
|
|
275
284
|
}
|
|
276
285
|
return offsets.has((counter - 1) % BLOCK_ROWS);
|
|
277
286
|
};
|
|
287
|
+
/**
|
|
288
|
+
* Cell bodies of a block by row offset (`decode_cell_block_bodies`, v1 too).
|
|
289
|
+
* A malformed block reads as the entries decoded before the damage.
|
|
290
|
+
*/
|
|
291
|
+
export const decodeColumnBlockV5 = (buf) => {
|
|
292
|
+
const out = new Map();
|
|
293
|
+
if (buf.length < 4)
|
|
294
|
+
return out;
|
|
295
|
+
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
296
|
+
const text = new TextDecoder();
|
|
297
|
+
const body = (bytes, pos, len) => {
|
|
298
|
+
if (pos + len > bytes.length)
|
|
299
|
+
return null;
|
|
300
|
+
const value = JSON.parse(text.decode(bytes.subarray(pos, pos + len)));
|
|
301
|
+
return isPlainObject(value) ? value : null;
|
|
302
|
+
};
|
|
303
|
+
try {
|
|
304
|
+
const first = view.getUint32(0, true);
|
|
305
|
+
if (first & BLOCK_V2_MAGIC) {
|
|
306
|
+
const offsets = blockRowOffsets(buf);
|
|
307
|
+
const pos = 8 + (first & BLOCK_V2_DENSE ? 0 : offsets.length * 4);
|
|
308
|
+
if (pos + 4 > buf.length)
|
|
309
|
+
return out;
|
|
310
|
+
const rawLen = view.getUint32(pos, true);
|
|
311
|
+
if (rawLen > MAX_BLOCK_RAW_BYTES)
|
|
312
|
+
return out;
|
|
313
|
+
const bodies = inflateSync(buf.subarray(pos + 4), { out: new Uint8Array(rawLen) });
|
|
314
|
+
const bodyView = new DataView(bodies.buffer, bodies.byteOffset, bodies.byteLength);
|
|
315
|
+
for (let i = 0, at = 0; i < offsets.length && at + 4 <= bodies.length; i++) {
|
|
316
|
+
const len = bodyView.getUint32(at, true);
|
|
317
|
+
const cell = body(bodies, at + 4, len);
|
|
318
|
+
if (cell)
|
|
319
|
+
out.set(offsets[i], cell);
|
|
320
|
+
at += 4 + len;
|
|
321
|
+
}
|
|
322
|
+
return out;
|
|
323
|
+
}
|
|
324
|
+
for (let i = 0, pos = 4; i < first && pos + 8 <= buf.length; i++) {
|
|
325
|
+
const offset = view.getUint32(pos, true);
|
|
326
|
+
const len = view.getUint32(pos + 4, true);
|
|
327
|
+
const cell = body(buf, pos + 8, len);
|
|
328
|
+
if (cell)
|
|
329
|
+
out.set(offset, cell);
|
|
330
|
+
pos += 8 + len;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
catch (_e) {
|
|
334
|
+
// Truncated deflate stream or a body that is not JSON: keep what decoded.
|
|
335
|
+
}
|
|
336
|
+
return out;
|
|
337
|
+
};
|
|
338
|
+
/** Whether `rncColumnBlocks` key `key` is a v5 block (its column part a line id, not `< 2^32`). */
|
|
339
|
+
const parseBlockKeyV5 = (key) => {
|
|
340
|
+
const match = BLOCK_KEY_V5.exec(key);
|
|
341
|
+
if (!match)
|
|
342
|
+
return null;
|
|
343
|
+
const colId = BigInt(match[2]);
|
|
344
|
+
if (BigInt.asIntN(64, colId) !== colId || idCounter(colId) === 0)
|
|
345
|
+
return null;
|
|
346
|
+
return { sheetId: Number(match[1]), colId: colId.toString(), block: Number(match[3]) };
|
|
347
|
+
};
|
|
348
|
+
/**
|
|
349
|
+
* The cold body of the cell at `rowId` × `colId`: entry `(counter - 1) % BLOCK_ROWS`
|
|
350
|
+
* of block `(counter - 1) / BLOCK_ROWS` of the column, for a client-0 row id only.
|
|
351
|
+
*/
|
|
352
|
+
const coldCellV5 = (doc, cache, sheetId, rowId, colId) => {
|
|
353
|
+
const counter = c0Counter(rowId);
|
|
354
|
+
if (!counter || !doc.share.has(BLOCKS_V5))
|
|
355
|
+
return null;
|
|
356
|
+
const key = `${sheetId}:${colId}:${Math.floor((counter - 1) / BLOCK_ROWS)}`;
|
|
357
|
+
let cells = cache.get(key);
|
|
358
|
+
if (!cells) {
|
|
359
|
+
const buf = doc.get(BLOCKS_V5).getAttr(key);
|
|
360
|
+
cells = buf instanceof Uint8Array ? decodeColumnBlockV5(buf) : new Map();
|
|
361
|
+
cache.set(key, cells);
|
|
362
|
+
}
|
|
363
|
+
return cells.get((counter - 1) % BLOCK_ROWS) ?? null;
|
|
364
|
+
};
|
|
278
365
|
// ── readers ─────────────────────────────────────────────────────────────────
|
|
279
366
|
/**
|
|
280
|
-
* The
|
|
281
|
-
* `
|
|
282
|
-
|
|
367
|
+
* The stored value of the cell under `key`: its hot entry (`ft` stripped; a
|
|
368
|
+
* `null` or any non-map is a tombstone and reads null), else its cold body.
|
|
369
|
+
*/
|
|
370
|
+
const storedCellV5 = (doc, key, cold) => {
|
|
371
|
+
const hot = doc.share.has(CELLS_V5) ? doc.get(CELLS_V5) : null;
|
|
372
|
+
if (hot?.hasAttr(key))
|
|
373
|
+
return cellDataV5(hot.getAttr(key));
|
|
374
|
+
const parsed = parseCellKeyV5(key);
|
|
375
|
+
if (!parsed)
|
|
376
|
+
return null;
|
|
377
|
+
const body = coldCellV5(doc, cold, parsed.sheetId, parsed.rowId, parsed.colId);
|
|
378
|
+
return body ? cellDataV5(body) : null;
|
|
379
|
+
};
|
|
380
|
+
/**
|
|
381
|
+
* The cell under `key` as the readers show it: the stored value
|
|
382
|
+
* (`storedCellV5`), `uf` from `styles` where it has an entry, `note` from
|
|
383
|
+
* `rncNotes` where it has one. Null when none of the three holds anything.
|
|
283
384
|
*/
|
|
284
|
-
const composeCell = (doc, key, styles) => {
|
|
285
|
-
let cell = doc
|
|
286
|
-
? cellDataV5(doc.get(CELLS_V5).getAttr(key))
|
|
287
|
-
: null;
|
|
385
|
+
const composeCell = (doc, key, styles, cold) => {
|
|
386
|
+
let cell = storedCellV5(doc, key, cold);
|
|
288
387
|
const uf = styles.get(key);
|
|
289
388
|
if (uf)
|
|
290
389
|
cell = { ...cell, uf };
|
|
@@ -294,13 +393,15 @@ const composeCell = (doc, key, styles) => {
|
|
|
294
393
|
return cell;
|
|
295
394
|
};
|
|
296
395
|
/**
|
|
297
|
-
* A v5 doc as V2 `SheetData` (same shape as `sheetDataV3ToV2`)
|
|
298
|
-
*
|
|
299
|
-
* `composeCell` does (tombstones and orphans
|
|
396
|
+
* A v5 doc as V2 `SheetData` (same shape as `sheetDataV3ToV2`): every key of
|
|
397
|
+
* `rncCells`, `rncNotes`, the composed style plane and every cold block entry,
|
|
398
|
+
* composed as `composeCell` does (hot shadows cold; tombstones and orphans
|
|
399
|
+
* skipped). Inflates every cold block once.
|
|
300
400
|
*/
|
|
301
401
|
export const sheetDataV5ToV2 = (doc, styles = readStyleOverlayV5(doc)) => {
|
|
302
402
|
const sheetData = {};
|
|
303
403
|
const cache = new Map();
|
|
404
|
+
const cold = new Map();
|
|
304
405
|
const keys = new Set(styles.keys());
|
|
305
406
|
for (const name of [CELLS_V5, NOTES_V5]) {
|
|
306
407
|
if (doc.share.has(name)) {
|
|
@@ -308,10 +409,26 @@ export const sheetDataV5ToV2 = (doc, styles = readStyleOverlayV5(doc)) => {
|
|
|
308
409
|
keys.add(key);
|
|
309
410
|
}
|
|
310
411
|
}
|
|
412
|
+
if (doc.share.has(BLOCKS_V5)) {
|
|
413
|
+
forEachEntry(doc.get(BLOCKS_V5), (value, blockKey) => {
|
|
414
|
+
const parsed = parseBlockKeyV5(blockKey);
|
|
415
|
+
if (!parsed || !(value instanceof Uint8Array))
|
|
416
|
+
return;
|
|
417
|
+
const cells = decodeColumnBlockV5(value);
|
|
418
|
+
cold.set(blockKey, cells);
|
|
419
|
+
const { rows } = sheetLinesV5(doc, cache, parsed.sheetId);
|
|
420
|
+
cells.forEach((_cell, offset) => {
|
|
421
|
+
const rowId = c0Id(parsed.block * BLOCK_ROWS + offset + 1);
|
|
422
|
+
// A row not in the axis is deleted: its block cells are orphans.
|
|
423
|
+
if (rows.has(rowId))
|
|
424
|
+
keys.add(createCellKeyV5(parsed.sheetId, rowId, parsed.colId));
|
|
425
|
+
});
|
|
426
|
+
});
|
|
427
|
+
}
|
|
311
428
|
for (const key of keys) {
|
|
312
429
|
const parsed = parseCellKeyV5(key);
|
|
313
430
|
const pos = parsed && positionV5(doc, cache, parsed);
|
|
314
|
-
const cell = pos && composeCell(doc, key, styles);
|
|
431
|
+
const cell = pos && composeCell(doc, key, styles, cold);
|
|
315
432
|
if (!parsed || !pos || !cell)
|
|
316
433
|
continue;
|
|
317
434
|
const [rowIdx, colIdx] = pos;
|
|
@@ -333,6 +450,7 @@ export const sheetDataV5ToV2 = (doc, styles = readStyleOverlayV5(doc)) => {
|
|
|
333
450
|
*/
|
|
334
451
|
export const createCellReaderV5 = (doc, styles = readStyleOverlayV5(doc)) => {
|
|
335
452
|
const lines = new Map();
|
|
453
|
+
const cold = new Map();
|
|
336
454
|
return (sheetId, rowIndex, columnIndex) => {
|
|
337
455
|
let ids = lines.get(sheetId);
|
|
338
456
|
if (!ids) {
|
|
@@ -343,18 +461,20 @@ export const createCellReaderV5 = (doc, styles = readStyleOverlayV5(doc)) => {
|
|
|
343
461
|
const colId = ids[1][columnIndex - 1];
|
|
344
462
|
if (rowId === undefined || colId === undefined)
|
|
345
463
|
return undefined;
|
|
346
|
-
return composeCell(doc, createCellKeyV5(sheetId, rowId, colId), styles) ?? undefined;
|
|
464
|
+
return (composeCell(doc, createCellKeyV5(sheetId, rowId, colId), styles, cold) ?? undefined);
|
|
347
465
|
};
|
|
348
466
|
};
|
|
349
467
|
/** `createCellReaderV5` for one cell (reads both id arrays: O(lines)). */
|
|
350
468
|
export const getCellV5 = (doc, sheetId, rowIndex, columnIndex, styles) => createCellReaderV5(doc, styles)(sheetId, rowIndex, columnIndex);
|
|
351
469
|
/**
|
|
352
470
|
* Apply changed `rncCells` / `rncNotes` keys to `currentSheetData` (copy-on-write,
|
|
353
|
-
* like `processSheetDataEventsV3`), `uf` from `styles
|
|
354
|
-
*
|
|
471
|
+
* like `processSheetDataEventsV3`), `uf` from `styles`; a removed hot entry
|
|
472
|
+
* reveals the cold cell under it. Only valid while no id array, no style and no
|
|
473
|
+
* cold block changed (those need `sheetDataV5ToV2`). Null when nothing changed.
|
|
355
474
|
*/
|
|
356
475
|
export const processSheetDataChangesV5 = (changedKeys, currentSheetData, doc, styles = readStyleOverlayV5(doc)) => {
|
|
357
476
|
const cache = new Map();
|
|
477
|
+
const cold = new Map();
|
|
358
478
|
const next = { ...currentSheetData };
|
|
359
479
|
const clonedSheets = new Set();
|
|
360
480
|
const clonedRows = new Set();
|
|
@@ -366,7 +486,7 @@ export const processSheetDataChangesV5 = (changedKeys, currentSheetData, doc, st
|
|
|
366
486
|
continue;
|
|
367
487
|
const [rowIdx, colIdx] = pos;
|
|
368
488
|
const { sheetId } = parsed;
|
|
369
|
-
const cell = composeCell(doc, key, styles);
|
|
489
|
+
const cell = composeCell(doc, key, styles, cold);
|
|
370
490
|
const row = next[sheetId]?.[rowIdx];
|
|
371
491
|
if (!cell && !row?.values?.[colIdx])
|
|
372
492
|
continue;
|
|
@@ -391,6 +511,159 @@ export const processSheetDataChangesV5 = (changedKeys, currentSheetData, doc, st
|
|
|
391
511
|
}
|
|
392
512
|
return hasChanges ? next : null;
|
|
393
513
|
};
|
|
514
|
+
// ── facet anchors (facet_anchor.rs, addr.rs) ────────────────────────────────
|
|
515
|
+
const MAX_ROW = 1048576; // MAX_ROW
|
|
516
|
+
const MAX_COL = 16384; // MAX_COL
|
|
517
|
+
const TAG_RANGE = 1; // TAG_RANGE
|
|
518
|
+
const TAG_CELL = 2; // TAG_CELL
|
|
519
|
+
const TAG_POINT = 3; // TAG_POINT
|
|
520
|
+
const RANGE_KEYS = ["startRowIndex", "endRowIndex", "startColumnIndex", "endColumnIndex"];
|
|
521
|
+
const CELL_KEYS = ["rowIndex", "columnIndex"];
|
|
522
|
+
/** Zigzag LEB128 `i64` (`get_var`). */
|
|
523
|
+
const readVar = (buf, at) => {
|
|
524
|
+
let z = BigInt(0);
|
|
525
|
+
for (let shift = BigInt(0); shift < BigInt(64); shift += BigInt(7)) {
|
|
526
|
+
if (at.pos >= buf.length)
|
|
527
|
+
return null;
|
|
528
|
+
const b = buf[at.pos++];
|
|
529
|
+
z |= BigInt(b & 0x7f) << shift;
|
|
530
|
+
if ((b & 0x80) === 0) {
|
|
531
|
+
return BigInt.asIntN(64, (z >> BigInt(1)) ^ -(z & BigInt(1)));
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
return null;
|
|
535
|
+
};
|
|
536
|
+
/**
|
|
537
|
+
* Decode a facet `anchor` buffer (`decode_anchor`): `u8 n`, the `n` positional
|
|
538
|
+
* fields as written (zigzag varints), then one `Addr` filling the rest.
|
|
539
|
+
*/
|
|
540
|
+
export const decodeFacetAnchorV5 = (buf) => {
|
|
541
|
+
const at = { pos: 0 };
|
|
542
|
+
if (!buf.length)
|
|
543
|
+
return null;
|
|
544
|
+
const n = buf[at.pos++];
|
|
545
|
+
const frame = [];
|
|
546
|
+
for (let i = 0; i < n; i++) {
|
|
547
|
+
const v = readVar(buf, at);
|
|
548
|
+
if (v === null)
|
|
549
|
+
return null;
|
|
550
|
+
frame.push(Number(v));
|
|
551
|
+
}
|
|
552
|
+
if (at.pos >= buf.length)
|
|
553
|
+
return null;
|
|
554
|
+
const tag = buf[at.pos++];
|
|
555
|
+
const sheet = readVar(buf, at);
|
|
556
|
+
if (sheet === null)
|
|
557
|
+
return null;
|
|
558
|
+
const sheetId = Number(sheet);
|
|
559
|
+
const id = () => readVar(buf, at)?.toString() ?? null;
|
|
560
|
+
let addr;
|
|
561
|
+
if (tag === TAG_RANGE) {
|
|
562
|
+
if (at.pos + 2 > buf.length)
|
|
563
|
+
return null;
|
|
564
|
+
at.pos++; // abs
|
|
565
|
+
const bits = buf[at.pos++];
|
|
566
|
+
const corners = [];
|
|
567
|
+
for (let i = 0; i < 4; i++) {
|
|
568
|
+
if (bits & (1 << i)) {
|
|
569
|
+
const c = id();
|
|
570
|
+
if (c === null)
|
|
571
|
+
return null;
|
|
572
|
+
corners.push(c);
|
|
573
|
+
}
|
|
574
|
+
else {
|
|
575
|
+
corners.push(null);
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
const [r0, r1, c0, c1] = corners;
|
|
579
|
+
addr = { kind: "range", sheetId, r0, r1, c0, c1 };
|
|
580
|
+
}
|
|
581
|
+
else if (tag === TAG_CELL || tag === TAG_POINT) {
|
|
582
|
+
if (tag === TAG_CELL) {
|
|
583
|
+
if (at.pos >= buf.length)
|
|
584
|
+
return null;
|
|
585
|
+
at.pos++; // abs
|
|
586
|
+
}
|
|
587
|
+
const row = id();
|
|
588
|
+
const col = id();
|
|
589
|
+
if (row === null || col === null)
|
|
590
|
+
return null;
|
|
591
|
+
addr = { kind: tag === TAG_CELL ? "cell" : "point", sheetId, row, col };
|
|
592
|
+
}
|
|
593
|
+
else {
|
|
594
|
+
return null;
|
|
595
|
+
}
|
|
596
|
+
return at.pos === buf.length ? { frame, addr } : null;
|
|
597
|
+
};
|
|
598
|
+
/**
|
|
599
|
+
* Resolve the `anchor` of one anchored map inside a facet value (`site_now`):
|
|
600
|
+
* `site` `"range"` = a map with `startRowIndex`…`endColumnIndex` (a named
|
|
601
|
+
* range, merge, CF / DV range, table, chart range, …), `"cell"` = a one-cell
|
|
602
|
+
* map (`rowIndex` / `columnIndex`) that goes with its lines (data-table input,
|
|
603
|
+
* scenario cells), `"point"` = a floating object's anchor cell. `sheetId` is
|
|
604
|
+
* the sheet the facet lives on.
|
|
605
|
+
*
|
|
606
|
+
* Only live corner lines are resolved here; anything the engine would repair
|
|
607
|
+
* (a deleted line) or fall back on (a line this replica never saw) answers
|
|
608
|
+
* `engine`. Which maps of which facet carry an anchor (and the derived ones:
|
|
609
|
+
* table filter column offsets, print breaks, print titles) is the engine's
|
|
610
|
+
* walk (`facet_anchor.rs`); for those, and whenever the exact answer matters,
|
|
611
|
+
* read facets through the engine.
|
|
612
|
+
*/
|
|
613
|
+
export const resolveFacetAnchorV5 = (doc, sheetId, value, site) => {
|
|
614
|
+
const positional = { status: "positional" };
|
|
615
|
+
const buf = value.anchor;
|
|
616
|
+
if (!(buf instanceof Uint8Array))
|
|
617
|
+
return positional;
|
|
618
|
+
const decoded = decodeFacetAnchorV5(buf);
|
|
619
|
+
if (!decoded)
|
|
620
|
+
return positional;
|
|
621
|
+
const { frame, addr } = decoded;
|
|
622
|
+
const keys = site === "range" ? RANGE_KEYS : CELL_KEYS;
|
|
623
|
+
const stored = keys.map((k) => value[k]);
|
|
624
|
+
if (stored.length !== frame.length ||
|
|
625
|
+
stored.some((v, i) => typeof v !== "number" || v !== frame[i])) {
|
|
626
|
+
return positional;
|
|
627
|
+
}
|
|
628
|
+
// A value copied onto another sheet with its anchors names the source's lines.
|
|
629
|
+
if (addr.sheetId !== sheetId)
|
|
630
|
+
return positional;
|
|
631
|
+
const lines = sheetLinesV5(doc, new Map(), sheetId);
|
|
632
|
+
if (site === "point") {
|
|
633
|
+
if (addr.kind !== "point")
|
|
634
|
+
return positional;
|
|
635
|
+
const row = lines.rows.get(addr.row);
|
|
636
|
+
const col = lines.cols.get(addr.col);
|
|
637
|
+
if (row === undefined || col === undefined)
|
|
638
|
+
return { status: "engine" };
|
|
639
|
+
return { status: "resolved", fields: { rowIndex: row, columnIndex: col } };
|
|
640
|
+
}
|
|
641
|
+
if (addr.kind !== "range")
|
|
642
|
+
return positional;
|
|
643
|
+
const axis = (index, c0, c1, max) => {
|
|
644
|
+
const s = c0 === null ? 1 : index.get(c0);
|
|
645
|
+
const e = c1 === null ? max : index.get(c1);
|
|
646
|
+
if (s === undefined || e === undefined)
|
|
647
|
+
return null;
|
|
648
|
+
// Both lines live in the other order (a move): the box of both.
|
|
649
|
+
return s <= e ? [s, e] : [e, s];
|
|
650
|
+
};
|
|
651
|
+
const rows = axis(lines.rows, addr.r0, addr.r1, MAX_ROW);
|
|
652
|
+
const cols = axis(lines.cols, addr.c0, addr.c1, MAX_COL);
|
|
653
|
+
if (!rows || !cols)
|
|
654
|
+
return { status: "engine" };
|
|
655
|
+
if (site === "cell") {
|
|
656
|
+
return { status: "resolved", fields: { rowIndex: rows[0], columnIndex: cols[0] } };
|
|
657
|
+
}
|
|
658
|
+
const now = [rows[0], rows[1], cols[0], cols[1]];
|
|
659
|
+
const open = [addr.r0, addr.r1, addr.c0, addr.c1].map((c) => c === null);
|
|
660
|
+
const fields = {};
|
|
661
|
+
RANGE_KEYS.forEach((k, i) => {
|
|
662
|
+
if (!open[i])
|
|
663
|
+
fields[k] = now[i];
|
|
664
|
+
});
|
|
665
|
+
return { status: "resolved", fields };
|
|
666
|
+
};
|
|
394
667
|
const axisKey = (sheetId, isRow) => `${sheetId}:${isRow ? "R" : "C"}`;
|
|
395
668
|
const writerStyles = (w) => (w.styles ??= readStyleOverlayV5(w.doc));
|
|
396
669
|
const writerAxis = (w, sheetId, isRow) => {
|
|
@@ -502,7 +775,8 @@ const queueStyle = (w, sheetId, rowId, colId, format) => {
|
|
|
502
775
|
* composed plane's entry, else the inline `uf`) is logged as a replace (a
|
|
503
776
|
* clear, then the format; a style reference only clears: the engine cannot
|
|
504
777
|
* resolve it). A note lives in `rncNotes` when the key has an entry there,
|
|
505
|
-
* inline otherwise. An unchanged cell
|
|
778
|
+
* inline otherwise. An unchanged cell (hot, or cold with no hot entry) is not
|
|
779
|
+
* rewritten (its `ft` survives; a cold cell gets no hot copy).
|
|
506
780
|
*/
|
|
507
781
|
const writeCell = (w, sheetId, row, col, cell) => {
|
|
508
782
|
if (!validPosition(row, col))
|
|
@@ -510,7 +784,7 @@ const writeCell = (w, sheetId, row, col, cell) => {
|
|
|
510
784
|
const rowId = ensureLine(w, sheetId, true, row);
|
|
511
785
|
const colId = ensureLine(w, sheetId, false, col);
|
|
512
786
|
const key = createCellKeyV5(sheetId, rowId, colId);
|
|
513
|
-
const stored =
|
|
787
|
+
const stored = storedCellV5(w.doc, key, w.cold);
|
|
514
788
|
const format = normalizedFormat(getCellUserEnteredFormat(cell));
|
|
515
789
|
const storedFormat = normalizedFormat(writerStyles(w).get(key) ?? getCellUserEnteredFormat(stored));
|
|
516
790
|
if (!isEqual(format, storedFormat)) {
|
|
@@ -614,6 +888,7 @@ const clearSheets = (w, match) => {
|
|
|
614
888
|
drop(BLOCKS_V5);
|
|
615
889
|
drop(NOTES_V5);
|
|
616
890
|
drop(STYLES_SEED_V5);
|
|
891
|
+
w.cold.clear();
|
|
617
892
|
for (const key of Array.from(writerStyles(w).keys())) {
|
|
618
893
|
const parsed = parseCellKeyV5(key);
|
|
619
894
|
if (parsed && match(parsed.sheetId)) {
|
|
@@ -622,17 +897,14 @@ const clearSheets = (w, match) => {
|
|
|
622
897
|
}
|
|
623
898
|
w.offsets.clear();
|
|
624
899
|
};
|
|
625
|
-
/** The cell a nested patch edits: the stored cell as the readers show it. */
|
|
900
|
+
/** The cell a nested patch edits: the stored cell (hot, else cold) as the readers show it. */
|
|
626
901
|
const nestedBase = (w, sheetId, row, col) => {
|
|
627
902
|
const rowId = writerAxis(w, sheetId, true).ids[row - 1];
|
|
628
903
|
const colId = writerAxis(w, sheetId, false).ids[col - 1];
|
|
629
904
|
if (rowId === undefined || colId === undefined)
|
|
630
905
|
return {};
|
|
631
906
|
const key = createCellKeyV5(sheetId, rowId, colId);
|
|
632
|
-
|
|
633
|
-
return null;
|
|
634
|
-
}
|
|
635
|
-
return composeCell(w.doc, key, writerStyles(w)) ?? {};
|
|
907
|
+
return composeCell(w.doc, key, writerStyles(w), w.cold) ?? {};
|
|
636
908
|
};
|
|
637
909
|
const applyPatchV5 = (w, { op, path, value }) => {
|
|
638
910
|
if (path.length === 0) {
|
|
@@ -652,11 +924,6 @@ const applyPatchV5 = (w, { op, path, value }) => {
|
|
|
652
924
|
if (!validPosition(row, col))
|
|
653
925
|
return;
|
|
654
926
|
const base = nestedBase(w, sheetId, row, col);
|
|
655
|
-
if (base === null) {
|
|
656
|
-
// Cold-only cell: its body needs an async inflate, a sync writer cannot merge into it.
|
|
657
|
-
console.warn(`y-spreadsheet v5: nested patch on cold cell ${sheetId}!R${row}C${col} skipped`);
|
|
658
|
-
return;
|
|
659
|
-
}
|
|
660
927
|
const cell = cloneDeep(base);
|
|
661
928
|
const nested = path.slice(4);
|
|
662
929
|
if (op === "remove") {
|
|
@@ -704,6 +971,7 @@ export const addSheetDataPatchesV5 = (doc, patches, origin = null, styles) => {
|
|
|
704
971
|
styles: styles ?? null,
|
|
705
972
|
ops: [],
|
|
706
973
|
offsets: new Map(),
|
|
974
|
+
cold: new Map(),
|
|
707
975
|
};
|
|
708
976
|
// Consecutive cell patches are consolidated (the later one wins) but never
|
|
709
977
|
// 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` (
|
|
80
|
+
* from `rncCells` and the cold `rncColumnBlocks`, written to `rncCells` (see `helpers-v5.ts`)
|
|
81
81
|
*/
|
|
82
82
|
sheetDataVersion?: "v2" | "v3" | "v5";
|
|
83
83
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-yspreadsheet-v2.d.ts","sourceRoot":"","sources":["../../use-yspreadsheet-v2.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACvE,OAAO,EAEL,UAAU,EACV,KAAK,QAAQ,EAEb,KAAK,YAAY,EACjB,KAAK,qBAAqB,EAC1B,KAAK,wBAAwB,EAC7B,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,UAAU,EACf,KAAK,cAAc,EACnB,KAAK,KAAK,EACV,KAAK,SAAS,EACf,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,KAAK,OAAO,EACZ,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACtB,MAAM,iCAAiC,CAAC;AASzC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AA6BnC,OAAO,KAAK,EAEV,kBAAkB,EAClB,IAAI,EAEJ,UAAU,EACV,KAAK,EAEN,MAAM,SAAS,CAAC;AAgFjB,MAAM,M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R,CAAC"}
|
|
@@ -549,9 +549,9 @@ export const useYSpreadsheetV2 = ({ onChangeSheetData, onChangeSheets, onChangeT
|
|
|
549
549
|
ySheetDataV3.unobserve(callback);
|
|
550
550
|
};
|
|
551
551
|
}, [onChangeSheetData, ySheetDataV3, useV3, yjs, observesLocal]);
|
|
552
|
-
// Only for sheet Data (V5 docs): `rncCells`, `rncNotes`, the style planes
|
|
553
|
-
// every sheet's id arrays. A change of an id array, a
|
|
554
|
-
// `docMeta`): full re-read; a cell or note change alone is applied
|
|
552
|
+
// Only for sheet Data (V5 docs): `rncCells`, `rncNotes`, the style planes,
|
|
553
|
+
// the cold blocks and every sheet's id arrays. A change of an id array, a
|
|
554
|
+
// style plane, a cold block (or of `docMeta`): full re-read; a cell or note change alone is applied
|
|
555
555
|
// incrementally. Roots are matched by name in `doc.share`, so a root a peer
|
|
556
556
|
// created after this effect ran is seen too.
|
|
557
557
|
useIsomorphicLayoutEffect(() => {
|
|
@@ -569,6 +569,7 @@ export const useYSpreadsheetV2 = ({ onChangeSheetData, onChangeSheets, onChangeT
|
|
|
569
569
|
changed.forEach((key) => key !== null && cellKeys.push(key));
|
|
570
570
|
}
|
|
571
571
|
else if (name === "docMeta" ||
|
|
572
|
+
name === "rncColumnBlocks" ||
|
|
572
573
|
name === "rncCellStylesLog" ||
|
|
573
574
|
name === "rncCellStyles" ||
|
|
574
575
|
name.startsWith("rncRowIds:") ||
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rowsncolumns/y-spreadsheet",
|
|
3
|
-
"version": "17.0.
|
|
3
|
+
"version": "17.0.3",
|
|
4
4
|
"main": "./dist/cjs/index.js",
|
|
5
5
|
"module": "./dist/esm/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -34,16 +34,16 @@
|
|
|
34
34
|
"sideEffects": false,
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@hocuspocus/provider": "^3.1.1",
|
|
37
|
-
"@rowsncolumns/common-types": ">=5.
|
|
38
|
-
"@rowsncolumns/fast-formula-parser": ">=6.2.
|
|
39
|
-
"@rowsncolumns/grid": ">=13.
|
|
40
|
-
"@rowsncolumns/spreadsheet": ">=10.
|
|
41
|
-
"@rowsncolumns/spreadsheet-state": ">=29.
|
|
42
|
-
"@rowsncolumns/ui": ">=16.2.
|
|
43
|
-
"@rowsncolumns/utils": ">=9.8.
|
|
37
|
+
"@rowsncolumns/common-types": ">=5.5.1",
|
|
38
|
+
"@rowsncolumns/fast-formula-parser": ">=6.2.49",
|
|
39
|
+
"@rowsncolumns/grid": ">=13.6.1",
|
|
40
|
+
"@rowsncolumns/spreadsheet": ">=10.10.3",
|
|
41
|
+
"@rowsncolumns/spreadsheet-state": ">=29.5.6",
|
|
42
|
+
"@rowsncolumns/ui": ">=16.2.3",
|
|
43
|
+
"@rowsncolumns/utils": ">=9.8.1",
|
|
44
44
|
"@types/lodash": "^4.17.17",
|
|
45
45
|
"@y/y": "14.0.0-rc.29",
|
|
46
|
-
"immer": "^
|
|
46
|
+
"immer": "^11.2.8",
|
|
47
47
|
"react": "^19.1.0",
|
|
48
48
|
"react-dom": "^19.1.0",
|
|
49
49
|
"y-websocket": "^3.0.0",
|
|
@@ -67,6 +67,7 @@
|
|
|
67
67
|
}
|
|
68
68
|
},
|
|
69
69
|
"dependencies": {
|
|
70
|
+
"fflate": "^0.8.2",
|
|
70
71
|
"lib0": "^0.2.87",
|
|
71
72
|
"lodash": "^4.17.21",
|
|
72
73
|
"rxjs": "^7.8.2"
|