@fileverse-dev/dsheet 4.1.23-stabilise-package-1 → 4.1.23-stabilise-package-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.
Files changed (29) hide show
  1. package/README.md +10 -0
  2. package/dist/editor/contexts/editor-context.d.ts +2 -0
  3. package/dist/editor/hooks/use-editor-data.d.ts +1 -0
  4. package/dist/editor/types.d.ts +14 -3
  5. package/dist/editor/utils/after-update-cell.d.ts +4 -0
  6. package/dist/editor/utils/format-gate.d.ts +8 -4
  7. package/dist/editor/utils/legacy-on-change.d.ts +20 -0
  8. package/dist/editor/utils/legacy-on-change.test.d.ts +1 -0
  9. package/dist/editor/utils/rebuild-indexeddb-store.d.ts +8 -1
  10. package/dist/editor/utils/remote-apply-guard.d.ts +25 -3
  11. package/dist/editor/utils/wait-for-sync.d.ts +35 -0
  12. package/dist/editor/utils/wait-for-sync.test.d.ts +1 -0
  13. package/dist/{executeStringFunction-DKA5MuP0.js → executeStringFunction-D5BTPrXL.js} +9414 -9324
  14. package/dist/formula.js +1 -1
  15. package/dist/{index-ypRdpDnX.js → index-BXNWi7s5.js} +12266 -12081
  16. package/dist/index.es.js +29 -29
  17. package/dist/sheet-engine/core/api/sheet-flowdata-lifecycle.d.ts +1 -0
  18. package/dist/sheet-engine/core/api/sheet-flowdata-lifecycle.test.d.ts +1 -0
  19. package/dist/sheet-engine/core/modules/formula.d.ts +9 -0
  20. package/dist/sheet-engine/core/modules/history-calc-chain.d.ts +6 -0
  21. package/dist/sheet-engine/core/modules/history-grid-size.d.ts +16 -0
  22. package/dist/sheet-engine/core/modules/history-grid-size.test.d.ts +1 -0
  23. package/dist/sheet-engine/core/settings.d.ts +9 -1
  24. package/dist/sheet-engine/core/utils/ydoc-celldata-changes.d.ts +14 -3
  25. package/dist/{use-xlsx-import-impl-DQ3tpIAe.js → use-xlsx-import-impl-gsG9w9qV.js} +4 -4
  26. package/dist/{xlsx-defined-names-CVVLxbe-.js → xlsx-defined-names-dZveijsB.js} +2 -2
  27. package/dist/{xlsx-export-impl-ghSoFZBz.js → xlsx-export-impl-B10lK_L2.js} +4 -4
  28. package/dist/{xlsx-hyperlink-inline-DXj7AkSf.js → xlsx-hyperlink-inline-BFbPe75M.js} +2 -2
  29. package/package.json +1 -1
package/dist/index.es.js CHANGED
@@ -1,5 +1,5 @@
1
- import { C as s, f as o, g as t, S as r, h as l, j as n, k as d, T as S, l as c, n as i, o as m, p as h, q as p, t as C, u, v as E, w as F, x as g, z as x, A as R, B as L, D as f, E as A, F as I, G as T, H as w, I as y, J as D, K as v, L as M, M as b, N as k, O as z, P as O, Q as P } from "./index-ypRdpDnX.js";
2
- import { cD as B, cE as K, cF as U, cL as X, bx as _, e as G, f as H, l as J, a as j, dr as N, ds as Q, bg as q, dt as Y, du as Z, dy as W, dz as $, dB as ee, J as ae, dQ as se, eo as oe, b9 as te } from "./executeStringFunction-DKA5MuP0.js";
1
+ import { C as s, f as o, g as t, S as r, h as l, j as n, k as d, T as S, l as c, n as i, o as h, p as m, q as p, t as C, u, v as E, w as F, x, z as g, A as R, B as f, D as A, E as I, F as L, G as w, H as T, I as v, J as y, K as D, L as M, M as O, N as b, O as k, P, Q as V } from "./index-BXNWi7s5.js";
2
+ import { cG as B, cH as G, cI as H, cO as K, by as U, e as X, f as _, l as J, a as j, du as q, dv as N, bh as Q, dw as Y, dx as Z, dB as W, dC as $, dE as ee, J as ae, dS as se, eq as oe, ba as te } from "./executeStringFunction-D5BTPrXL.js";
3
3
  import { FLVURL as le } from "@fileverse-dev/formulajs";
4
4
  import { E as de, S as Se } from "./constants-8Ij49Lxv.js";
5
5
  export {
@@ -17,49 +17,49 @@ export {
17
17
  c as api,
18
18
  B as clearColumnsCellsFormat,
19
19
  i as clearFilter,
20
- K as clearRowsCellsFormat,
21
- U as clearSelectedCellFormat,
22
- m as createFilter,
23
- h as decryptForRoomKey,
24
- X as deleteRowCol,
25
- _ as deleteSelectedCellText,
20
+ G as clearRowsCellsFormat,
21
+ H as clearSelectedCellFormat,
22
+ h as createFilter,
23
+ m as decryptForRoomKey,
24
+ K as deleteRowCol,
25
+ U as deleteSelectedCellText,
26
26
  p as describeMatchedShortcut,
27
27
  C as encryptForRoomKey,
28
- G as executeStringFunction,
28
+ X as executeStringFunction,
29
29
  u as fetchSessionState,
30
- H as formulaResponseUiSync,
30
+ _ as formulaResponseUiSync,
31
31
  J as getFlowdata,
32
32
  E as getRemoveDuplicatesErrorMessage,
33
33
  F as getRemoveDuplicatesPreview,
34
34
  j as getSheetIndex,
35
- g as handleCSVUpload,
36
- x as handleCopy,
35
+ x as handleCSVUpload,
36
+ g as handleCopy,
37
37
  R as handleExportToCSV,
38
- L as handleExportToJSON,
39
- f as handleExportToODS,
40
- A as handleExportToXLSX,
41
- N as handleFreeze,
42
- Q as handleHorizontalAlign,
43
- q as handleLink,
38
+ f as handleExportToJSON,
39
+ A as handleExportToODS,
40
+ I as handleExportToXLSX,
41
+ q as handleFreeze,
42
+ N as handleHorizontalAlign,
43
+ Q as handleLink,
44
44
  Y as handleMerge,
45
- I as handlePasteByClick,
45
+ L as handlePasteByClick,
46
46
  Z as handleSort,
47
47
  W as handleTextSize,
48
48
  $ as handleVerticalAlign,
49
- T as importSpreadsheetFile,
49
+ w as importSpreadsheetFile,
50
50
  ee as insertRowCol,
51
- w as isBrowserZoomShortcut,
52
- y as isFormulaListShortcut,
53
- D as isOpenShortcutsModalShortcut,
51
+ T as isBrowserZoomShortcut,
52
+ v as isFormulaListShortcut,
53
+ y as isOpenShortcutsModalShortcut,
54
54
  ae as jfrefreshgrid,
55
55
  se as loadLocale,
56
- v as remapCommentAnchors,
56
+ D as remapCommentAnchors,
57
57
  M as removeActiveImage,
58
- b as removeDuplicates,
59
- k as seedSession,
60
- z as showImgChooser,
58
+ O as removeDuplicates,
59
+ b as seedSession,
60
+ k as showImgChooser,
61
61
  oe as toolbarItemClickHandler,
62
62
  te as updateFormat,
63
- O as useEnsStatus,
64
- P as useXLSXImport
63
+ P as useEnsStatus,
64
+ V as useXLSXImport
65
65
  };
@@ -1,5 +1,6 @@
1
1
  import { Context } from '../context';
2
2
 
3
+ export declare function collectSheetIdsFromFormulaText(ctx: Context, formula: string): Set<string>;
3
4
  /** Drop cached dense-sheet set (e.g. after structural workbook changes). */
4
5
  export declare function invalidateSheetsRequiredDenseCache(): void;
5
6
  /**
@@ -110,6 +110,15 @@ export declare class FormulaCache {
110
110
  export declare function iscelldata(txt: string): boolean;
111
111
  export declare function getcellrange(ctx: Context, txt: string, formulaId?: string): any;
112
112
  export declare function getAllFunctionGroup(ctx: Context): any[];
113
+ /**
114
+ * delFunctionGroup for many cells of one sheet: the chain and the dynamic
115
+ * array list are filtered once, not scanned and copied per cell. Same result
116
+ * as calling delFunctionGroup for each cell.
117
+ */
118
+ export declare function delFunctionGroupBatch(ctx: Context, id: string, cells: {
119
+ r: number;
120
+ c: number;
121
+ }[]): void;
113
122
  export declare function delFunctionGroup(ctx: Context, r: number, c: number, id?: string): void;
114
123
  export declare function insertUpdateFunctionGroup(ctx: Context, r: number, c: number, id?: string, calcChainSet?: Set<string>): void;
115
124
  /**
@@ -29,5 +29,11 @@ export declare function planHistoryPatches(patches: Patch[]): {
29
29
  * Register the restored cells that hold a formula and drop the ones that no
30
30
  * longer do. Run on a draft after the patches were applied. The graph is left
31
31
  * incomplete: restored formulas are not evaluated.
32
+ *
33
+ * A row-level patch lists every cell of the row, so most restored cells are
34
+ * unchanged. The chain is read once into a set; only a formula missing from it
35
+ * is added and only an entry whose cell lost its formula is removed (in one
36
+ * batch). Calling insertUpdateFunctionGroup / delFunctionGroup per cell
37
+ * scanned the chain each time: 6.8 s for 1,000 formulas on 1,000 rows.
32
38
  */
33
39
  export declare function reregisterRestoredFormulas(ctx: Context, restored: RestoredCell[]): void;
@@ -0,0 +1,16 @@
1
+ import { Patch } from 'immer';
2
+ import { Context } from '../context';
3
+
4
+ export type GridSizeChange = {
5
+ sheetId: string;
6
+ path: ['row'] | ['column'];
7
+ value: number;
8
+ type: 'update';
9
+ };
10
+ /**
11
+ * Undo and redo of a row/column insert or delete change a sheet's `row` /
12
+ * `column`. The forward edit writes them to Yjs (`emitGridSizeToYdoc`); history
13
+ * wrote the restored cells only, so a peer kept the grown grid until a later
14
+ * effect fixed it, and only for the current sheet.
15
+ */
16
+ export declare function gridSizeChangesFromPatches(ctxAfter: Context, patches: Patch[]): GridSizeChange[];
@@ -31,7 +31,15 @@ export type Hooks = {
31
31
  onLocalCellEdit?: () => void;
32
32
  afterUpdateCell?: (row: number, column: number, oldValue: any, newValue: any,
33
33
  /** Sheet that held the cell when it was committed (updateCell only). */
34
- sheetId?: string) => void;
34
+ sheetId?: string,
35
+ /**
36
+ * `skipPersist`: the caller writes this cell to Yjs in its own batch (paste
37
+ * and fill), after the cell is final. Persisting here too wrote the
38
+ * pre-format value first, so every formula was written twice.
39
+ */
40
+ options?: {
41
+ skipPersist?: boolean;
42
+ }) => void;
35
43
  afterSelectionChange?: (sheetId: string, selection: Selection) => void;
36
44
  beforeRenderRowHeaderCell?: (rowNumber: string, rowIndex: number, top: number, width: number, height: number, ctx: CanvasRenderingContext2D) => boolean;
37
45
  afterRenderRowHeaderCell?: (rowNumber: string, rowIndex: number, top: number, width: number, height: number, ctx: CanvasRenderingContext2D) => void;
@@ -1,6 +1,17 @@
1
1
  import { Context } from '../context';
2
2
  import { Cell, CellWithRowAndCol } from '../types';
3
3
 
4
+ /** Receives changes instead of the updateCellYdoc hook (see createYdocBatch). */
5
+ export type YdocChangeSink = (changes: any[]) => void;
6
+ /**
7
+ * Collect the Yjs changes of one structural edit and send them in a single
8
+ * updateCellYdoc call, so the edit is one transaction and one update for peers
9
+ * (an insert used to send four and a delete five).
10
+ */
11
+ export declare function createYdocBatch(ctx: Context): {
12
+ sink: YdocChangeSink;
13
+ flush: () => void;
14
+ };
4
15
  export type CelldataYdocChange = {
5
16
  sheetId: string;
6
17
  path: string[];
@@ -17,7 +28,7 @@ export declare function cellsEqualForYdocPersist(before: unknown, after: unknown
17
28
  export declare function snapshotPersistedCelldataInRange(data: unknown[][] | null | undefined, r1: number, r2: number, c1: number, c2: number, celldata?: CellWithRowAndCol[] | null): Map<string, Cell | string | number | boolean>;
18
29
  export declare function appendCelldataDiffChange(changes: CelldataYdocChange[], sheetId: string, r: number, c: number, cell: unknown, beforePersisted?: Map<string, Cell | string | number | boolean>): void;
19
30
  export declare function buildCelldataChangesForRange(sheetId: string, data: unknown[][], r1: number, r2: number, c1: number, c2: number, beforePersisted?: Map<string, Cell | string | number | boolean>): CelldataYdocChange[];
20
- export declare function emitCelldataRangeDiffToYdoc(ctx: Context, sheetId: string, data: unknown[][], r1: number, r2: number, c1: number, c2: number, beforePersisted?: Map<string, Cell | string | number | boolean>): void;
31
+ export declare function emitCelldataRangeDiffToYdoc(ctx: Context, sheetId: string, data: unknown[][], r1: number, r2: number, c1: number, c2: number, beforePersisted?: Map<string, Cell | string | number | boolean>, sink?: YdocChangeSink): void;
21
32
  /** Formula text per tab and cell key, taken before a structural edit rewrites it. */
22
33
  export type FormulaTextSnapshot = Map<string, Map<string, string>>;
23
34
  /**
@@ -33,13 +44,13 @@ export declare function snapshotFormulaTexts(ctx: Context): FormulaTextSnapshot;
33
44
  * pre-edit coordinates, which equal post-edit ones for every cell outside
34
45
  * that range.
35
46
  */
36
- export declare function emitRewrittenFormulasToYdoc(ctx: Context, before: FormulaTextSnapshot, editedSheetId: string, editedFromR: number, editedFromC: number): void;
47
+ export declare function emitRewrittenFormulasToYdoc(ctx: Context, before: FormulaTextSnapshot, editedSheetId: string, editedFromR: number, editedFromC: number, sink?: YdocChangeSink): void;
37
48
  /**
38
49
  * After delete row/col, emit deletes for persisted keys that now sit past the
39
50
  * shrunken grid. Range diffs only visit coordinates still inside `data`, so
40
51
  * tail keys would otherwise resurrect on peers/reload.
41
52
  */
42
- export declare function emitCelldataDeletesBeyondGrid(ctx: Context, sheetId: string, beforePersisted: Map<string, Cell | string | number | boolean> | undefined, rowCount: number, colCount: number): void;
53
+ export declare function emitCelldataDeletesBeyondGrid(ctx: Context, sheetId: string, beforePersisted: Map<string, Cell | string | number | boolean> | undefined, rowCount: number, colCount: number, sink?: YdocChangeSink): void;
43
54
  export type MergeBounds = {
44
55
  minR: number;
45
56
  minC: number;
@@ -1,10 +1,10 @@
1
1
  import * as BZ from "yjs";
2
- import { i as Yl, a as hl, b as ul, s as eZ, r as Il, y as pl, d as Rl, m as sl } from "./index-ypRdpDnX.js";
3
- import { g as al } from "./executeStringFunction-DKA5MuP0.js";
2
+ import { i as Yl, a as hl, b as ul, s as eZ, r as Il, y as pl, d as Rl, m as sl } from "./index-BXNWi7s5.js";
3
+ import { g as al } from "./executeStringFunction-D5BTPrXL.js";
4
4
  import { Workbook as Kl } from "exceljs";
5
5
  import Jl from "luckyexcel";
6
- import { e as xl, b as Ml, n as Sl } from "./xlsx-hyperlink-inline-DXj7AkSf.js";
7
- import { parseDefinedNamesFromXlsxBuffer as Nl, excelEntriesToDefinedNames as OZ } from "./xlsx-defined-names-CVVLxbe-.js";
6
+ import { e as xl, b as Ml, n as Sl } from "./xlsx-hyperlink-inline-BFbPe75M.js";
7
+ import { parseDefinedNamesFromXlsxBuffer as Nl, excelEntriesToDefinedNames as OZ } from "./xlsx-defined-names-dZveijsB.js";
8
8
  import { toast as fZ } from "@fileverse/ui";
9
9
  var Zl = { exports: {} };
10
10
  (function(m) {
@@ -1,5 +1,5 @@
1
- import { i as w } from "./executeStringFunction-DKA5MuP0.js";
2
- import { J as x } from "./xlsx-hyperlink-inline-DXj7AkSf.js";
1
+ import { i as w } from "./executeStringFunction-D5BTPrXL.js";
2
+ import { J as x } from "./xlsx-hyperlink-inline-BFbPe75M.js";
3
3
  function g(o) {
4
4
  return o.startsWith("_xlnm.");
5
5
  }
@@ -1,9 +1,9 @@
1
1
  import { utils as S, write as nt } from "xlsx-js-style";
2
2
  import { Workbook as pt } from "exceljs";
3
3
  import { toast as rt } from "@fileverse/ui";
4
- import { J as dt, c as X, g as ht, a as mt } from "./xlsx-hyperlink-inline-DXj7AkSf.js";
5
- import { b as gt } from "./executeStringFunction-DKA5MuP0.js";
6
- import { e as bt } from "./index-ypRdpDnX.js";
4
+ import { J as dt, c as X, g as ht, a as mt } from "./xlsx-hyperlink-inline-BFbPe75M.js";
5
+ import { b as gt } from "./executeStringFunction-D5BTPrXL.js";
6
+ import { e as bt } from "./index-BXNWi7s5.js";
7
7
  const xt = {
8
8
  1: "thin",
9
9
  2: "hair",
@@ -854,7 +854,7 @@ const Z = (t) => {
854
854
  O
855
855
  );
856
856
  });
857
- const { applyDefinedNamesToExcelWorkbook: ct } = await import("./xlsx-defined-names-CVVLxbe-.js");
857
+ const { applyDefinedNamesToExcelWorkbook: ct } = await import("./xlsx-defined-names-dZveijsB.js");
858
858
  ct(
859
859
  B,
860
860
  (k = (C = (s = t.current).getWorkbookContext) == null ? void 0 : C.call(s)) == null ? void 0 : k.definedNames,
@@ -1,5 +1,5 @@
1
- import { g as Rt, c as yt } from "./executeStringFunction-DKA5MuP0.js";
2
- import { c as wt } from "./index-ypRdpDnX.js";
1
+ import { g as Rt, c as yt } from "./executeStringFunction-D5BTPrXL.js";
2
+ import { c as wt } from "./index-BXNWi7s5.js";
3
3
  function jt(J, nt) {
4
4
  const g = J.getImages();
5
5
  if (!g.length) return [];
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@fileverse-dev/dsheet",
3
3
  "private": false,
4
4
  "description": "DSheet",
5
- "version": "4.1.23-stabilise-package-1",
5
+ "version": "4.1.23-stabilise-package-3",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "git+https://github.com/fileverse/fileverse-dsheets.git"