@rowsncolumns/y-spreadsheet 16.0.0 → 16.1.0-beta.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.
- package/Readme.md +1 -1
- package/dist/cjs/helpers-v5.d.ts +64 -0
- package/dist/cjs/helpers-v5.d.ts.map +1 -0
- package/dist/cjs/helpers-v5.js +970 -0
- package/dist/cjs/helpers.d.ts +3 -2
- package/dist/cjs/helpers.d.ts.map +1 -1
- package/dist/cjs/helpers.js +8 -2
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/cjs/use-yspreadsheet-v2.d.ts +4 -2
- package/dist/cjs/use-yspreadsheet-v2.d.ts.map +1 -1
- package/dist/cjs/use-yspreadsheet-v2.js +125 -34
- package/dist/esm/helpers-v5.d.ts +64 -0
- package/dist/esm/helpers-v5.d.ts.map +1 -0
- package/dist/esm/helpers-v5.js +733 -0
- package/dist/esm/helpers.d.ts +3 -2
- package/dist/esm/helpers.d.ts.map +1 -1
- package/dist/esm/helpers.js +8 -2
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/esm/use-yspreadsheet-v2.d.ts +4 -2
- package/dist/esm/use-yspreadsheet-v2.d.ts.map +1 -1
- package/dist/esm/use-yspreadsheet-v2.js +86 -11
- package/package.json +2 -1
package/Readme.md
CHANGED
|
@@ -24,7 +24,7 @@ import { useYSpreadsheet } from "@rowsncolumns/spreadsheet-yjs";
|
|
|
24
24
|
import * as Y from "yjs";
|
|
25
25
|
import { WebsocketProvider } from "y-websocket";
|
|
26
26
|
|
|
27
|
-
const version = "
|
|
27
|
+
const version = "v5";
|
|
28
28
|
const yDoc = new Y.Doc();
|
|
29
29
|
const yWebsocketProvider = new WebsocketProvider(
|
|
30
30
|
"ws://localhost:1234",
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { CellData, CellFormat } from "@rowsncolumns/spreadsheet";
|
|
2
|
+
import type { SheetData } from "@rowsncolumns/spreadsheet-state";
|
|
3
|
+
import type { Patch } from "immer";
|
|
4
|
+
import type * as Y from "yjs";
|
|
5
|
+
/** A parsed v5 cell key; line ids as decimal strings (an id can exceed 2^53). */
|
|
6
|
+
export type ParsedCellKeyV5 = {
|
|
7
|
+
sheetId: number;
|
|
8
|
+
rowId: string;
|
|
9
|
+
colId: string;
|
|
10
|
+
};
|
|
11
|
+
/** The composed style plane: cell key → format (`StyleOverlay`). */
|
|
12
|
+
export type StyleOverlayV5 = Map<string, CellFormat>;
|
|
13
|
+
/**
|
|
14
|
+
* A sheet's line ids in grid order (position = index + 1), as decimal strings.
|
|
15
|
+
* Later duplicates and non-id values are skipped, as the engine's index does.
|
|
16
|
+
*/
|
|
17
|
+
export declare const readLineIds: (doc: Y.Doc, sheetId: number, axis: "row" | "column") => string[];
|
|
18
|
+
/** The `rncCells` / `rncNotes` key of a cell by its line ids. */
|
|
19
|
+
export declare const createCellKeyV5: (sheetId: number, rowId: string, colId: string) => string;
|
|
20
|
+
/** Parse a v5 key `"{sheetId}:{rowId}:{colId}"`; null when malformed. */
|
|
21
|
+
export declare const parseCellKeyV5: (key: string) => ParsedCellKeyV5 | null;
|
|
22
|
+
/**
|
|
23
|
+
* The composed style plane of a v5 doc (`refold_style_overlay`): the legacy
|
|
24
|
+
* `rncCellStyles` seed (`"{sheetId}!{A1}"`, the client-0 ids of that position)
|
|
25
|
+
* with every `rncCellStylesLog` buffer folded on in array order. Walks the log.
|
|
26
|
+
*/
|
|
27
|
+
export declare const readStyleOverlayV5: (doc: Y.Doc) => StyleOverlayV5;
|
|
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).
|
|
32
|
+
*/
|
|
33
|
+
export declare const sheetDataV5ToV2: <T extends CellData>(doc: Y.Doc, styles?: ReadonlyMap<string, CellFormat>) => SheetData<T>;
|
|
34
|
+
/**
|
|
35
|
+
* A reader of the cell at a 1-based position (`composeCell`), line ids read once
|
|
36
|
+
* per sheet. Undefined when nothing is there or the line is unnamed.
|
|
37
|
+
*/
|
|
38
|
+
export declare const createCellReaderV5: <T extends CellData = CellData>(doc: Y.Doc, styles?: ReadonlyMap<string, CellFormat>) => (sheetId: number, rowIndex: number, columnIndex: number) => T | undefined;
|
|
39
|
+
/** `createCellReaderV5` for one cell (reads both id arrays: O(lines)). */
|
|
40
|
+
export declare const getCellV5: <T extends CellData = CellData>(doc: Y.Doc, sheetId: number, rowIndex: number, columnIndex: number, styles?: ReadonlyMap<string, CellFormat>) => T | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* 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.
|
|
45
|
+
*/
|
|
46
|
+
export declare const processSheetDataChangesV5: <T extends CellData>(changedKeys: Iterable<string>, currentSheetData: SheetData<T>, doc: Y.Doc, styles?: ReadonlyMap<string, CellFormat>) => SheetData<T> | null;
|
|
47
|
+
/**
|
|
48
|
+
* Apply immer `SheetData` patches to a v5 doc in one transaction (`origin`, the
|
|
49
|
+
* caller's; nested in an open transaction it joins that one). Positional, like
|
|
50
|
+
* the v3 path: a row insert/delete arrives as rewritten rows and is applied as
|
|
51
|
+
* cell writes/removals at each position's line ids; no line is inserted or
|
|
52
|
+
* deleted. Writes past an axis name lines (client-0 padding, `ensure_lines`).
|
|
53
|
+
* `uf` changes append ONE `STYLE_LOG_V2` buffer to `rncCellStylesLog` and stay
|
|
54
|
+
* inline on the cell. `styles`, when given, is the caller's composed style plane
|
|
55
|
+
* (`readStyleOverlayV5`), used instead of folding the log and updated in place.
|
|
56
|
+
*/
|
|
57
|
+
export declare const addSheetDataPatchesV5: (doc: Y.Doc, patches: Patch[] | undefined, origin?: unknown, styles?: StyleOverlayV5) => void;
|
|
58
|
+
/** Set one cell of a v5 doc (see `addSheetDataPatchesV5`). */
|
|
59
|
+
export declare const setCellV5: (doc: Y.Doc, sheetId: number, rowIndex: number, columnIndex: number, value: CellData) => void;
|
|
60
|
+
/** Remove one cell of a v5 doc (see `addSheetDataPatchesV5`). */
|
|
61
|
+
export declare const deleteCellV5: (doc: Y.Doc, sheetId: number, rowIndex: number, columnIndex: number) => void;
|
|
62
|
+
/** Remove every cell of a sheet of a v5 doc; its line ids and dimensions stay. */
|
|
63
|
+
export declare const deleteSheetV5: (doc: Y.Doc, sheetId: number) => void;
|
|
64
|
+
//# sourceMappingURL=helpers-v5.d.ts.map
|
|
@@ -0,0 +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,KAAK,CAAC,MAAM,KAAK,CAAC;AAE9B,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;AAsDrD;;;GAGG;AACH,eAAO,MAAM,WAAW,GACtB,KAAK,CAAC,CAAC,GAAG,EACV,SAAS,MAAM,EACf,MAAM,KAAK,GAAG,QAAQ,KACrB,MAAM,EAYR,CAAC;AAEF,iEAAiE;AACjE,eAAO,MAAM,eAAe,GAC1B,SAAS,MAAM,EACf,OAAO,MAAM,EACb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