@fileverse-dev/dsheet 4.1.26 → 4.1.27-stabilise-package-1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (133) hide show
  1. package/README.md +10 -0
  2. package/dist/editor/components/skeleton-loader.d.ts +2 -1
  3. package/dist/editor/contexts/editor-context.d.ts +10 -0
  4. package/dist/editor/hooks/use-celldata-compaction.d.ts +44 -2
  5. package/dist/editor/hooks/use-celldata-compaction.test.d.ts +1 -0
  6. package/dist/editor/hooks/use-editor-data.d.ts +1 -0
  7. package/dist/editor/hooks/use-editor-sync.d.ts +5 -1
  8. package/dist/editor/hooks/use-editor-sync.test.d.ts +1 -0
  9. package/dist/editor/types.d.ts +44 -1
  10. package/dist/editor/utils/active-sheet-keeper.test.d.ts +1 -0
  11. package/dist/editor/utils/after-update-cell.d.ts +6 -0
  12. package/dist/editor/utils/after-update-cell.test.d.ts +1 -0
  13. package/dist/editor/utils/apply-comment-markers.d.ts +3 -1
  14. package/dist/editor/utils/apply-comment-markers.test.d.ts +1 -0
  15. package/dist/editor/utils/calc-chain-ydoc-update.test.d.ts +1 -0
  16. package/dist/editor/utils/content-change.d.ts +48 -0
  17. package/dist/editor/utils/content-change.test.d.ts +1 -0
  18. package/dist/editor/utils/content-fingerprint.d.ts +37 -0
  19. package/dist/editor/utils/content-fingerprint.test.d.ts +1 -0
  20. package/dist/editor/utils/editor-handle.d.ts +1 -1
  21. package/dist/editor/utils/format-gate.d.ts +27 -0
  22. package/dist/editor/utils/format-gate.test.d.ts +1 -0
  23. package/dist/editor/utils/legacy-on-change.d.ts +20 -0
  24. package/dist/editor/utils/legacy-on-change.test.d.ts +1 -0
  25. package/dist/editor/utils/patch-plain-celldata.d.ts +19 -0
  26. package/dist/editor/utils/patch-plain-celldata.test.d.ts +1 -0
  27. package/dist/editor/utils/rebuild-indexeddb-store.d.ts +19 -0
  28. package/dist/editor/utils/rebuild-indexeddb-store.failure.test.d.ts +1 -0
  29. package/dist/editor/utils/rebuild-indexeddb-store.test.d.ts +1 -0
  30. package/dist/editor/utils/remote-apply-guard.d.ts +45 -0
  31. package/dist/editor/utils/remote-apply-guard.test.d.ts +1 -0
  32. package/dist/editor/utils/sheet-ydoc-sync-utils.d.ts +13 -4
  33. package/dist/editor/utils/sheet-ydoc-sync-utils.test.d.ts +1 -0
  34. package/dist/editor/utils/structural-edit-formula-sync.test.d.ts +1 -0
  35. package/dist/editor/utils/structural-edit-other-tabs.test.d.ts +1 -0
  36. package/dist/editor/utils/update-ydoc.d.ts +9 -1
  37. package/dist/editor/utils/wait-for-sync.d.ts +35 -0
  38. package/dist/editor/utils/wait-for-sync.test.d.ts +1 -0
  39. package/dist/editor/utils/xlsx-export-impl.d.ts +1 -0
  40. package/dist/editor/utils/xlsx-export.d.ts +1 -0
  41. package/dist/{executeStringFunction-KWYZ3QNg.js → executeStringFunction-D1SB3Bwm.js} +14018 -13280
  42. package/dist/formula.js +1 -1
  43. package/dist/{index-BDSumZYk.js → index-Dp7tGJO0.js} +23688 -22379
  44. package/dist/index.d.ts +2 -2
  45. package/dist/index.es.js +46 -45
  46. package/dist/persistence-utils-CSKBobX8.js +151 -0
  47. package/dist/persistence-utils.d.ts +2 -0
  48. package/dist/persistence.append.test.d.ts +1 -0
  49. package/dist/persistence.d.ts +13 -0
  50. package/dist/persistence.fingerprint.test.d.ts +1 -0
  51. package/dist/persistence.js +122 -74
  52. package/dist/sheet-engine/core/api/cell.d.ts +25 -1
  53. package/dist/sheet-engine/core/api/remote-apply.test.d.ts +1 -0
  54. package/dist/sheet-engine/core/api/sheet-flowdata-lifecycle.d.ts +1 -0
  55. package/dist/sheet-engine/core/api/sheet-flowdata-lifecycle.test.d.ts +1 -0
  56. package/dist/sheet-engine/core/index.d.ts +1 -1
  57. package/dist/sheet-engine/core/modules/b6-ydoc-writes.test.d.ts +1 -0
  58. package/dist/sheet-engine/core/modules/border.d.ts +9 -0
  59. package/dist/sheet-engine/core/modules/cell-shift-dep-graph.test.d.ts +1 -0
  60. package/dist/sheet-engine/core/modules/cell-shift.d.ts +11 -0
  61. package/dist/sheet-engine/core/modules/cell.commit-ydoc.test.d.ts +1 -0
  62. package/dist/sheet-engine/core/modules/dataVerification.d.ts +15 -0
  63. package/dist/sheet-engine/core/modules/engine-hot-spots.test.d.ts +1 -0
  64. package/dist/sheet-engine/core/modules/formula-async-eval.d.ts +5 -0
  65. package/dist/sheet-engine/core/modules/formula-dep-text.d.ts +23 -0
  66. package/dist/sheet-engine/core/modules/formula-dep-text.test.d.ts +1 -0
  67. package/dist/sheet-engine/core/modules/formula-edge-update.d.ts +13 -0
  68. package/dist/sheet-engine/core/modules/formula-narrowing.test.d.ts +1 -0
  69. package/dist/sheet-engine/core/modules/formula-snapshot-eval.d.ts +2 -0
  70. package/dist/sheet-engine/core/modules/formula-tab-load.test.d.ts +1 -0
  71. package/dist/sheet-engine/core/modules/formula-transitive-deps.d.ts +26 -1
  72. package/dist/sheet-engine/core/modules/formula-warmup.d.ts +33 -0
  73. package/dist/sheet-engine/core/modules/formula-warmup.test.d.ts +1 -0
  74. package/dist/sheet-engine/core/modules/formula-wide-grid-growth.test.d.ts +1 -0
  75. package/dist/sheet-engine/core/modules/formula.d.ts +87 -1
  76. package/dist/sheet-engine/core/modules/formula.dep-graph.test.d.ts +1 -0
  77. package/dist/sheet-engine/core/modules/formula.str-change.test.d.ts +1 -0
  78. package/dist/sheet-engine/core/modules/formula.wide-seed.test.d.ts +1 -0
  79. package/dist/sheet-engine/core/modules/history-calc-chain.d.ts +39 -0
  80. package/dist/sheet-engine/core/modules/history-calc-chain.test.d.ts +1 -0
  81. package/dist/sheet-engine/core/modules/history-celldata.d.ts +25 -0
  82. package/dist/sheet-engine/core/modules/history-grid-size.d.ts +16 -0
  83. package/dist/sheet-engine/core/modules/history-grid-size.test.d.ts +1 -0
  84. package/dist/sheet-engine/core/modules/index.d.ts +3 -2
  85. package/dist/sheet-engine/core/modules/rowcol-dep-graph.test.d.ts +1 -0
  86. package/dist/sheet-engine/core/modules/rowcol-refused-edit.test.d.ts +1 -0
  87. package/dist/sheet-engine/core/modules/rowcol-unloaded-history.test.d.ts +1 -0
  88. package/dist/sheet-engine/core/modules/rowcol.d.ts +8 -0
  89. package/dist/sheet-engine/core/modules/structural-edit-prep.d.ts +36 -0
  90. package/dist/sheet-engine/core/modules/structural-edit-prep.test.d.ts +1 -0
  91. package/dist/sheet-engine/core/paste/paste-dep-graph.test.d.ts +1 -0
  92. package/dist/sheet-engine/core/paste-helpers/calculate-range-cell-size.d.ts +14 -0
  93. package/dist/sheet-engine/core/paste-helpers/calculate-range-cell-size.test.d.ts +1 -0
  94. package/dist/sheet-engine/core/settings.d.ts +11 -1
  95. package/dist/sheet-engine/core/utils/ydoc-celldata-changes.d.ts +29 -2
  96. package/dist/sheet-engine/react/components/ContextMenu/FilterMenu.d.ts +2 -2
  97. package/dist/sheet-engine/react/components/ContextMenu/SheetTab.d.ts +2 -2
  98. package/dist/sheet-engine/react/components/ContextMenu/index.d.ts +2 -2
  99. package/dist/sheet-engine/react/components/NotationBoxes/shown-comments.d.ts +20 -0
  100. package/dist/sheet-engine/react/components/NotationBoxes/shown-comments.test.d.ts +1 -0
  101. package/dist/sheet-engine/react/components/SVGDefines.d.ts +2 -2
  102. package/dist/sheet-engine/react/components/SheetOverlay/editing-as-formula.d.ts +7 -0
  103. package/dist/sheet-engine/react/components/SheetOverlay/editing-as-formula.test.d.ts +1 -0
  104. package/dist/sheet-engine/react/components/SheetOverlay/hover-tracker.d.ts +44 -0
  105. package/dist/sheet-engine/react/components/SheetOverlay/hover-tracker.test.d.ts +1 -0
  106. package/dist/sheet-engine/react/components/SheetTab/index.d.ts +2 -2
  107. package/dist/sheet-engine/react/components/Toolbar/FunctionList/group-functions.d.ts +9 -0
  108. package/dist/sheet-engine/react/components/Toolbar/FunctionList/group-functions.test.d.ts +1 -0
  109. package/dist/sheet-engine/react/components/Toolbar/index.d.ts +2 -2
  110. package/dist/sheet-engine/react/components/Workbook/api.d.ts +4 -0
  111. package/dist/sheet-engine/react/components/Workbook/denomination-scan.d.ts +16 -0
  112. package/dist/sheet-engine/react/components/Workbook/denomination-scan.test.d.ts +1 -0
  113. package/dist/sheet-engine/react/components/Workbook/index.d.ts +2 -0
  114. package/dist/sheet-engine/react/components/Workbook/stable-handle.d.ts +8 -0
  115. package/dist/sheet-engine/react/components/Workbook/stable-handle.test.d.ts +1 -0
  116. package/dist/sheet-engine/react/context/index.d.ts +15 -0
  117. package/dist/sheet-engine/react/context/use-workbook-store.d.ts +30 -0
  118. package/dist/sheet-engine/react/context/workbook-store.d.ts +30 -0
  119. package/dist/sheet-engine/react/context/workbook-store.test.d.ts +1 -0
  120. package/dist/style.css +1 -1
  121. package/dist/sync-local/SyncManager.d.ts +2 -2
  122. package/dist/sync-local/SyncManager.remote-apply.test.d.ts +1 -0
  123. package/dist/sync-local/SyncManager.test.d.ts +1 -0
  124. package/dist/sync-local/socketClient.d.ts +2 -0
  125. package/dist/sync-local/socketClient.test.d.ts +1 -0
  126. package/dist/sync-local/types/index.d.ts +5 -1
  127. package/dist/{use-xlsx-import-impl-DN63dMYx.js → use-xlsx-import-impl-DdbvcXEd.js} +120 -119
  128. package/dist/{xlsx-defined-names-DoOdrbDR.js → xlsx-defined-names-BbP8Yh6X.js} +2 -2
  129. package/dist/xlsx-export-impl-BWKY9xjL.js +903 -0
  130. package/dist/{xlsx-hyperlink-inline-CJfom4ax.js → xlsx-hyperlink-inline-C3KG35Vc.js} +2 -2
  131. package/package.json +1 -1
  132. package/dist/persistence-utils-BXFajzvq.js +0 -98
  133. package/dist/xlsx-export-impl-l3bwAIHT.js +0 -880
package/dist/index.d.ts CHANGED
@@ -5,7 +5,7 @@ export { executeStringFunction } from './editor/utils/executeStringFunction';
5
5
  export { FLVURL } from '@fileverse-dev/formulajs';
6
6
  export { loadLocale } from './sheet-engine/core';
7
7
  export type { ErrorMessageHandlerReturnType, DataBlockEvent, DataBlockEventType, ApiKeyStorage, DSheetEditorHandle, DSheetPermissionMode, } from './editor/types';
8
- export type { PanelConfig, PanelId, BuiltInPanelType } from './editor/types';
8
+ export type { PanelConfig, PanelId, BuiltInPanelType, DSheetContentChange, } from './editor/types';
9
9
  export type { CommentThread, CommentReply, CommentActionParams, CommentsConfig, CommentAnchorMove, } from './editor/types/comments';
10
10
  export { CommentAction } from './editor/types/comments';
11
11
  export { remapCommentAnchors } from './editor/utils/remap-comment-anchors';
@@ -23,7 +23,7 @@ export { ERROR_MESSAGES_FLAG, SERVICES_API_KEY, } from './editor/constants/share
23
23
  export { TEMPLATES } from '@fileverse-dev/dsheets-templates/template-metadata-list';
24
24
  export { handleCSVUpload } from './editor/utils/csv-import';
25
25
  export { importSpreadsheetFile, type ImportSpreadsheetFileOptions, type ImportSpreadsheetFileResult, type SpreadsheetImportFileType, } from './editor/utils/spreadsheet-import';
26
- export { handleExportToXLSX, handleExportToODS } from './editor/utils/xlsx-export';
26
+ export { handleExportToXLSX, handleExportToODS, exportToXLSXBytes, } from './editor/utils/xlsx-export';
27
27
  export { handleExportToCSV } from './editor/utils/csv-export';
28
28
  export { handleExportToJSON } from './editor/utils/json-export';
29
29
  export { useXLSXImport } from './editor/hooks/use-xlsx-import';
package/dist/index.es.js CHANGED
@@ -1,65 +1,66 @@
1
- import { C as s, d as o, f as t, S as r, g as l, h as n, j as d, T as S, k as c, l as i, n as m, o as h, p, q as C, t as u, u as E, v as F, w as x, x as g, z as R, A as f, B as A, D as I, E as L, F as w, G as T, H as v, I as y, J as D, K as M, L as b, M as O, N as k, O as P, P as V } from "./index-BDSumZYk.js";
2
- import { cB as B, cC as K, cD as U, cJ as X, bx as _, e as G, f as H, l as J, a as j, dn as q, dp as N, bb as Y, dq as Z, dr as Q, dv as W, dw as $, dy as ee, I as ae, dO as se, el as oe, b4 as te } from "./executeStringFunction-KWYZ3QNg.js";
3
- import { FLVURL as le } from "@fileverse-dev/formulajs";
4
- import { E as de, S as Se } from "./constants-8Ij49Lxv.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 R, A as g, B as L, D as A, E as T, F as f, G as I, H as v, I as w, J as y, K as D, L as M, M as X, N as b, O as k, P as z, Q as B, R as O } from "./index-Dp7tGJO0.js";
2
+ import { cL as V, cM as G, cN as H, cT as J, bD as K, e as U, f as _, l as N, a as j, dz as q, dA as Q, bh as Y, dB as Z, dC as W, dG as $, dH as ee, dJ as ae, J as se, dX as oe, ev as te, ba as re } from "./executeStringFunction-D1SB3Bwm.js";
3
+ import { FLVURL as ne } from "@fileverse-dev/formulajs";
4
+ import { E as Se, S as ce } from "./constants-8Ij49Lxv.js";
5
5
  export {
6
6
  s as CommentAction,
7
7
  o as CommentCellUI,
8
8
  t as CommentsContent,
9
9
  r as DSheetEditor,
10
10
  l as DSheetSkeleton,
11
- de as ERROR_MESSAGES_FLAG,
12
- le as FLVURL,
11
+ Se as ERROR_MESSAGES_FLAG,
12
+ ne as FLVURL,
13
13
  n as FortuneCore,
14
- Se as SERVICES_API_KEY,
14
+ ce as SERVICES_API_KEY,
15
15
  d as SupportedChain,
16
16
  S as TEMPLATES,
17
17
  c as api,
18
- B as clearColumnsCellsFormat,
18
+ V 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
+ J as deleteRowCol,
25
+ K as deleteSelectedCellText,
26
26
  p as describeMatchedShortcut,
27
27
  C as encryptForRoomKey,
28
- G as executeStringFunction,
29
- u as fetchSessionState,
30
- H as formulaResponseUiSync,
31
- J as getFlowdata,
32
- E as getRemoveDuplicatesErrorMessage,
33
- F as getRemoveDuplicatesPreview,
28
+ U as executeStringFunction,
29
+ u as exportToXLSXBytes,
30
+ E as fetchSessionState,
31
+ _ as formulaResponseUiSync,
32
+ N as getFlowdata,
33
+ F as getRemoveDuplicatesErrorMessage,
34
+ x as getRemoveDuplicatesPreview,
34
35
  j as getSheetIndex,
35
- x as handleCSVUpload,
36
+ R as handleCSVUpload,
36
37
  g as handleCopy,
37
- R as handleExportToCSV,
38
- f as handleExportToJSON,
39
- A as handleExportToODS,
40
- I as handleExportToXLSX,
38
+ L as handleExportToCSV,
39
+ A as handleExportToJSON,
40
+ T as handleExportToODS,
41
+ f as handleExportToXLSX,
41
42
  q as handleFreeze,
42
- N as handleHorizontalAlign,
43
+ Q as handleHorizontalAlign,
43
44
  Y as handleLink,
44
45
  Z as handleMerge,
45
- L as handlePasteByClick,
46
- Q as handleSort,
47
- W as handleTextSize,
48
- $ as handleVerticalAlign,
49
- w as importSpreadsheetFile,
50
- ee as insertRowCol,
51
- T as isBrowserZoomShortcut,
52
- v as isFormulaListShortcut,
53
- y as isOpenShortcutsModalShortcut,
54
- ae as jfrefreshgrid,
55
- se as loadLocale,
56
- D as remapCommentAnchors,
57
- M as removeActiveImage,
46
+ I as handlePasteByClick,
47
+ W as handleSort,
48
+ $ as handleTextSize,
49
+ ee as handleVerticalAlign,
50
+ v as importSpreadsheetFile,
51
+ ae as insertRowCol,
52
+ w as isBrowserZoomShortcut,
53
+ y as isFormulaListShortcut,
54
+ D as isOpenShortcutsModalShortcut,
55
+ se as jfrefreshgrid,
56
+ oe as loadLocale,
57
+ M as remapCommentAnchors,
58
+ X as removeActiveImage,
58
59
  b as removeDuplicates,
59
- O as seedSession,
60
- k as showImgChooser,
61
- oe as toolbarItemClickHandler,
62
- te as updateFormat,
63
- P as useEnsStatus,
64
- V as useXLSXImport
60
+ k as seedSession,
61
+ z as showImgChooser,
62
+ te as toolbarItemClickHandler,
63
+ re as updateFormat,
64
+ B as useEnsStatus,
65
+ O as useXLSXImport
65
66
  };
@@ -0,0 +1,151 @@
1
+ import * as c from "yjs";
2
+ const p = typeof Buffer == "function";
3
+ typeof TextDecoder == "function" && new TextDecoder();
4
+ typeof TextEncoder == "function" && new TextEncoder();
5
+ const E = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", l = Array.prototype.slice.call(E), f = ((t) => {
6
+ let e = {};
7
+ return t.forEach((r, n) => e[r] = n), e;
8
+ })(l), U = /^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/, u = String.fromCharCode.bind(String), h = typeof Uint8Array.from == "function" ? Uint8Array.from.bind(Uint8Array) : (t) => new Uint8Array(Array.prototype.slice.call(t, 0)), T = (t) => t.replace(/=/g, "").replace(/[+\/]/g, (e) => e == "+" ? "-" : "_"), m = (t) => t.replace(/[^A-Za-z0-9\+\/]/g, ""), w = (t) => {
9
+ let e, r, n, a, o = "";
10
+ const s = t.length % 3;
11
+ for (let i = 0; i < t.length; ) {
12
+ if ((r = t.charCodeAt(i++)) > 255 || (n = t.charCodeAt(i++)) > 255 || (a = t.charCodeAt(i++)) > 255)
13
+ throw new TypeError("invalid character found");
14
+ e = r << 16 | n << 8 | a, o += l[e >> 18 & 63] + l[e >> 12 & 63] + l[e >> 6 & 63] + l[e & 63];
15
+ }
16
+ return s ? o.slice(0, s - 3) + "===".substring(s) : o;
17
+ }, _ = typeof btoa == "function" ? (t) => btoa(t) : p ? (t) => Buffer.from(t, "binary").toString("base64") : w, y = p ? (t) => Buffer.from(t).toString("base64") : (t) => {
18
+ let r = [];
19
+ for (let n = 0, a = t.length; n < a; n += 4096)
20
+ r.push(u.apply(null, t.subarray(n, n + 4096)));
21
+ return _(r.join(""));
22
+ }, d = (t, e = !1) => e ? T(y(t)) : y(t), C = (t) => {
23
+ if (t = t.replace(/\s+/g, ""), !U.test(t))
24
+ throw new TypeError("malformed base64.");
25
+ t += "==".slice(2 - (t.length & 3));
26
+ let e, r, n, a = [];
27
+ for (let o = 0; o < t.length; )
28
+ e = f[t.charAt(o++)] << 18 | f[t.charAt(o++)] << 12 | (r = f[t.charAt(o++)]) << 6 | (n = f[t.charAt(o++)]), r === 64 ? a.push(u(e >> 16 & 255)) : n === 64 ? a.push(u(e >> 16 & 255, e >> 8 & 255)) : a.push(u(e >> 16 & 255, e >> 8 & 255, e & 255));
29
+ return a.join("");
30
+ }, x = typeof atob == "function" ? (t) => atob(m(t)) : p ? (t) => Buffer.from(t, "base64").toString("binary") : C, B = p ? (t) => h(Buffer.from(t, "base64")) : (t) => h(x(t).split("").map((e) => e.charCodeAt(0))), k = (t) => B(F(t)), F = (t) => m(t.replace(/[-_]/g, (e) => e == "-" ? "+" : "/")), S = (t) => {
31
+ let e = 0;
32
+ return t.clients.forEach((r) => {
33
+ for (let n = 0; n < r.length; n += 1) e += r[n].len;
34
+ }), e;
35
+ }, z = (t) => {
36
+ let e = 0;
37
+ return t.deleteSet.clients.forEach((r, n) => {
38
+ const a = t.beforeState.get(n) ?? 0;
39
+ for (let o = 0; o < r.length; o += 1) {
40
+ const { clock: s, len: i } = r[o];
41
+ s < a && (e += Math.min(s + i, a) - s);
42
+ }
43
+ }), t.afterState.forEach((r, n) => {
44
+ const a = t.beforeState.get(n) ?? 0;
45
+ if (r <= a) return;
46
+ const o = t.doc.store.clients.get(n);
47
+ if (o)
48
+ for (let s = c.findIndexSS(o, a); s < o.length && o[s].id.clock < r; s += 1) {
49
+ const i = o[s];
50
+ if (!i.deleted) continue;
51
+ const A = Math.max(i.id.clock, a), D = Math.min(i.id.clock + i.length, r);
52
+ e += D - A;
53
+ }
54
+ }), e;
55
+ };
56
+ function V(t) {
57
+ let e = t.store.clients.size === 0 ? 0 : S(c.createDeleteSetFromStructStore(t.store));
58
+ const r = (n) => {
59
+ e += z(n);
60
+ };
61
+ return t.on("afterTransaction", r), {
62
+ getFingerprint: () => `${d(c.encodeStateVector(t))}:${e}`,
63
+ getDeletedCount: () => e,
64
+ dispose: () => t.off("afterTransaction", r)
65
+ };
66
+ }
67
+ function I(t) {
68
+ const e = new c.Doc();
69
+ try {
70
+ return c.applyUpdate(e, t), b(e);
71
+ } finally {
72
+ e.destroy();
73
+ }
74
+ }
75
+ function b(t) {
76
+ const e = t.store.clients.size === 0 ? 0 : S(c.createDeleteSetFromStructStore(t.store));
77
+ return `${d(c.encodeStateVector(t))}:${e}`;
78
+ }
79
+ const Z = 8e3, P = (t) => t instanceof Error ? t : new Error(String(t)), v = (t, e, r = "dsheet-package-ingress") => {
80
+ const n = k(e), a = new c.Doc();
81
+ try {
82
+ c.applyUpdate(a, n);
83
+ } finally {
84
+ a.destroy();
85
+ }
86
+ let o = !1;
87
+ const s = () => {
88
+ o = !0;
89
+ };
90
+ t.on("update", s);
91
+ try {
92
+ return c.applyUpdate(t, n, r), o;
93
+ } finally {
94
+ t.off("update", s);
95
+ }
96
+ }, $ = async (t, e) => {
97
+ let r;
98
+ try {
99
+ return await Promise.race([
100
+ t,
101
+ new Promise((n, a) => {
102
+ r = setTimeout(
103
+ () => a(new Error("dSheet IndexedDB operation timed out")),
104
+ e
105
+ );
106
+ })
107
+ ]);
108
+ } finally {
109
+ r && clearTimeout(r);
110
+ }
111
+ }, g = (t, e, r) => ({
112
+ dsheetId: t,
113
+ status: e,
114
+ encodedState: null,
115
+ stateVector: null,
116
+ fingerprint: null,
117
+ ...r ? { error: P(r) } : {}
118
+ }), M = (t, e) => {
119
+ const r = c.encodeStateAsUpdate(e);
120
+ return {
121
+ dsheetId: t,
122
+ status: r.length <= 2 ? "empty" : "available",
123
+ encodedState: d(r),
124
+ stateVector: d(c.encodeStateVector(e)),
125
+ fingerprint: b(e)
126
+ };
127
+ }, j = (t, e, r) => {
128
+ if (!r)
129
+ return g(
130
+ t,
131
+ "unavailable",
132
+ new Error("dSheet document is not ready")
133
+ );
134
+ try {
135
+ return v(r, e, "dsheet-package-ingress"), M(t, r);
136
+ } catch (n) {
137
+ return g(t, "corrupt", n);
138
+ }
139
+ };
140
+ export {
141
+ Z as D,
142
+ I as a,
143
+ V as b,
144
+ j as c,
145
+ d as f,
146
+ v as m,
147
+ M as s,
148
+ k as t,
149
+ g as u,
150
+ $ as w
151
+ };
@@ -6,6 +6,8 @@ export type DSheetContentSnapshot = {
6
6
  status: DSheetContentStatus;
7
7
  encodedState: string | null;
8
8
  stateVector: string | null;
9
+ /** A1 content fingerprint of the document read; null when unavailable. */
10
+ fingerprint: string | null;
9
11
  error?: Error;
10
12
  };
11
13
  export type DSheetContentReadOptions = {
@@ -0,0 +1 @@
1
+
@@ -1,6 +1,7 @@
1
1
  import { DSheetContentReadOptions, DSheetContentSnapshot } from './persistence-utils';
2
2
 
3
3
  export type { DSheetContentReadOptions, DSheetContentSnapshot, DSheetContentStatus, } from './persistence-utils';
4
+ export { fingerprintFromUpdate } from './editor/utils/content-fingerprint';
4
5
  export declare const getDsheetStateVector: (encodedState: string | Uint8Array) => string;
5
6
  /**
6
7
  * Read the package-owned Y-IndexedDB database without attaching another
@@ -10,3 +11,15 @@ export declare const readDsheetContent: (dsheetId: string, options?: DSheetConte
10
11
  /** Merge content into the package-owned Y-IndexedDB document. */
11
12
  export declare const mergeDsheetContent: (dsheetId: string, encodedState: string, options?: DSheetContentReadOptions) => Promise<DSheetContentSnapshot>;
12
13
  export declare const deleteDsheetContent: (dsheetId: string) => Promise<void>;
14
+ /**
15
+ * Append one Yjs update as a single row of the package-owned y-indexeddb
16
+ * `updates` store. Unlike mergeDsheetContent it never builds a Y.Doc and never
17
+ * writes a full copy of the document: the caller passes only what is missing
18
+ * (for example Y.diffUpdate(remote, localStateVector)).
19
+ *
20
+ * If the database does not exist yet it is created with the same schema
21
+ * y-indexeddb uses (`updates` autoIncrement, `custom`). Rejects with
22
+ * "IndexedDB is unavailable" when there is no indexedDB, and with the
23
+ * underlying error if the transaction fails or aborts.
24
+ */
25
+ export declare const appendDsheetUpdate: (dsheetId: string, update: Uint8Array, options?: DSheetContentReadOptions) => Promise<void>;
@@ -1,118 +1,166 @@
1
- import { t as D, f as h, D as b, u as p, w as S, s as w } from "./persistence-utils-BXFajzvq.js";
2
- import * as u from "yjs";
3
- import { clearDocument as v, IndexeddbPersistence as E } from "y-indexeddb";
4
- const f = /* @__PURE__ */ new Map(), M = (e) => {
5
- const o = new u.Doc();
1
+ import { w, D, t as h, f as g, u as m, s as S } from "./persistence-utils-CSKBobX8.js";
2
+ import { a as F } from "./persistence-utils-CSKBobX8.js";
3
+ import * as p from "yjs";
4
+ import { clearDocument as x, IndexeddbPersistence as E } from "y-indexeddb";
5
+ const y = /* @__PURE__ */ new Map(), A = (e) => {
6
+ const i = new p.Doc();
6
7
  try {
7
- return u.applyUpdate(
8
- o,
9
- typeof e == "string" ? D(e) : e
10
- ), h(u.encodeStateVector(o));
8
+ return p.applyUpdate(
9
+ i,
10
+ typeof e == "string" ? h(e) : e
11
+ ), g(p.encodeStateVector(i));
11
12
  } finally {
12
- o.destroy();
13
+ i.destroy();
13
14
  }
14
- }, x = (e, o) => new Promise((s) => {
15
- const a = new u.Doc();
16
- let r = null, t = null, i = !1, m = !1;
17
- const y = (n) => {
18
- i || (i = !0, clearTimeout(g), r == null || r.close(), a.destroy(), s(n));
19
- }, c = (n, d) => y(p(e, n, d)), g = setTimeout(() => {
15
+ }, v = (e, i) => new Promise((c) => {
16
+ const r = new p.Doc();
17
+ let n = null, t = null, u = !1, b = !1;
18
+ const l = (s) => {
19
+ u || (u = !0, clearTimeout(a), n == null || n.close(), r.destroy(), c(s));
20
+ }, o = (s, f) => l(m(e, s, f)), a = setTimeout(() => {
20
21
  try {
21
22
  t == null || t.abort();
22
23
  } catch {
23
24
  }
24
- c("timed-out", new Error("dSheet IndexedDB read timed out"));
25
- }, o);
26
- let l;
25
+ o("timed-out", new Error("dSheet IndexedDB read timed out"));
26
+ }, i);
27
+ let d;
27
28
  try {
28
- l = indexedDB.open(e);
29
- } catch (n) {
30
- c("unavailable", n);
29
+ d = indexedDB.open(e);
30
+ } catch (s) {
31
+ o("unavailable", s);
31
32
  return;
32
33
  }
33
- l.onupgradeneeded = () => {
34
- var n;
35
- m = !0, (n = l.transaction) == null || n.abort();
36
- }, l.onerror = () => {
37
- m ? y(p(e, "missing")) : c("unavailable", l.error);
38
- }, l.onsuccess = () => {
39
- if (r = l.result, !r.objectStoreNames.contains("updates") || !r.objectStoreNames.contains("custom")) {
40
- c("corrupt", new Error("dSheet IndexedDB schema is invalid"));
34
+ d.onupgradeneeded = () => {
35
+ var s;
36
+ b = !0, (s = d.transaction) == null || s.abort();
37
+ }, d.onerror = () => {
38
+ b ? l(m(e, "missing")) : o("unavailable", d.error);
39
+ }, d.onsuccess = () => {
40
+ if (n = d.result, !n.objectStoreNames.contains("updates") || !n.objectStoreNames.contains("custom")) {
41
+ o("corrupt", new Error("dSheet IndexedDB schema is invalid"));
41
42
  return;
42
43
  }
43
44
  try {
44
- t = r.transaction("updates", "readonly");
45
- const n = t.objectStore("updates").getAll();
46
- n.onerror = () => c("unavailable", n.error), n.onsuccess = () => {
45
+ t = n.transaction("updates", "readonly");
46
+ const s = t.objectStore("updates").getAll();
47
+ s.onerror = () => o("unavailable", s.error), s.onsuccess = () => {
47
48
  try {
48
- for (const d of n.result ?? []) {
49
- if (!(d instanceof Uint8Array))
49
+ for (const f of s.result ?? []) {
50
+ if (!(f instanceof Uint8Array))
50
51
  throw new Error("dSheet IndexedDB contains a non-Yjs update");
51
- u.applyUpdate(a, d);
52
+ p.applyUpdate(r, f);
52
53
  }
53
- } catch (d) {
54
- c("corrupt", d);
54
+ } catch (f) {
55
+ o("corrupt", f);
55
56
  }
56
- }, t.oncomplete = () => y(w(e, a)), t.onabort = () => {
57
- i || c("unavailable", t == null ? void 0 : t.error);
57
+ }, t.oncomplete = () => l(S(e, r)), t.onabort = () => {
58
+ u || o("unavailable", t == null ? void 0 : t.error);
58
59
  }, t.onerror = () => {
59
- i || c("unavailable", t == null ? void 0 : t.error);
60
+ u || o("unavailable", t == null ? void 0 : t.error);
60
61
  };
61
- } catch (n) {
62
- c("unavailable", n);
62
+ } catch (s) {
63
+ o("unavailable", s);
63
64
  }
64
65
  };
65
- }), B = async (e, o) => {
66
+ }), B = async (e, i) => {
66
67
  if (typeof indexedDB > "u")
67
- return p(
68
+ return m(
68
69
  e,
69
70
  "unavailable",
70
71
  new Error("IndexedDB is unavailable")
71
72
  );
72
- const s = indexedDB;
73
- if (s.databases)
73
+ const c = indexedDB;
74
+ if (c.databases)
74
75
  try {
75
- if (!(await s.databases()).some((r) => r.name === e))
76
- return p(e, "missing");
76
+ if (!(await c.databases()).some((n) => n.name === e))
77
+ return m(e, "missing");
77
78
  } catch {
78
79
  }
79
- return x(e, o);
80
- }, A = (e, o = {}) => {
81
- const s = f.get(e);
82
- if (s) return s;
83
- const a = B(
80
+ return v(e, i);
81
+ }, M = (e, i = {}) => {
82
+ const c = y.get(e);
83
+ if (c) return c;
84
+ const r = B(
84
85
  e,
85
- o.timeoutMs ?? b
86
+ i.timeoutMs ?? D
86
87
  ).finally(() => {
87
- f.get(e) === a && f.delete(e);
88
+ y.get(e) === r && y.delete(e);
88
89
  });
89
- return f.set(e, a), a;
90
- }, C = async (e, o, s = {}) => {
91
- const a = s.timeoutMs ?? b, r = new u.Doc();
90
+ return y.set(e, r), r;
91
+ }, j = async (e, i, c = {}) => {
92
+ const r = c.timeoutMs ?? D, n = new p.Doc();
92
93
  try {
93
- u.applyUpdate(r, D(o), "dsheet-package-ingress");
94
- } catch (i) {
95
- return r.destroy(), p(e, "corrupt", i);
94
+ p.applyUpdate(n, h(i), "dsheet-package-ingress");
95
+ } catch (u) {
96
+ return n.destroy(), m(e, "corrupt", u);
96
97
  }
97
98
  let t = null;
98
99
  try {
99
- return t = new E(e, r), await S(t.whenSynced, a), w(e, r);
100
- } catch (i) {
101
- return p(
100
+ return t = new E(e, n), await w(t.whenSynced, r), S(e, n);
101
+ } catch (u) {
102
+ return m(
102
103
  e,
103
- /timed out/i.test(String(i)) ? "timed-out" : "unavailable",
104
- i
104
+ /timed out/i.test(String(u)) ? "timed-out" : "unavailable",
105
+ u
105
106
  );
106
107
  } finally {
107
108
  await (t == null ? void 0 : t.destroy().catch(() => {
108
- })), r.destroy();
109
+ })), n.destroy();
110
+ }
111
+ }, N = async (e) => {
112
+ y.delete(e), typeof indexedDB < "u" && await x(e);
113
+ }, C = async (e, i, c = {}) => {
114
+ if (!(i instanceof Uint8Array))
115
+ throw new TypeError("appendDsheetUpdate expects a Uint8Array update");
116
+ if (typeof indexedDB > "u")
117
+ throw new Error("IndexedDB is unavailable");
118
+ let r = null, n = !1;
119
+ const t = () => {
120
+ try {
121
+ r == null || r.close();
122
+ } catch {
123
+ }
124
+ }, u = new Promise((b, l) => {
125
+ let o;
126
+ try {
127
+ o = indexedDB.open(e);
128
+ } catch (a) {
129
+ l(a);
130
+ return;
131
+ }
132
+ o.onupgradeneeded = () => {
133
+ const a = o.result;
134
+ a.objectStoreNames.contains("updates") || a.createObjectStore("updates", { autoIncrement: !0 }), a.objectStoreNames.contains("custom") || a.createObjectStore("custom");
135
+ }, o.onerror = () => l(o.error), o.onsuccess = () => {
136
+ if (r = o.result, r.onversionchange = () => t(), n) {
137
+ t();
138
+ return;
139
+ }
140
+ try {
141
+ if (!r.objectStoreNames.contains("updates"))
142
+ throw new Error("dSheet IndexedDB schema is invalid");
143
+ const a = r.transaction("updates", "readwrite");
144
+ a.objectStore("updates").add(i), a.oncomplete = () => b(), a.onerror = () => l(a.error), a.onabort = () => l(a.error ?? new Error("dSheet IndexedDB write aborted"));
145
+ } catch (a) {
146
+ l(a);
147
+ }
148
+ };
149
+ });
150
+ try {
151
+ await w(
152
+ u,
153
+ c.timeoutMs ?? D
154
+ );
155
+ } finally {
156
+ n = !0, t();
109
157
  }
110
- }, j = async (e) => {
111
- f.delete(e), typeof indexedDB < "u" && await v(e);
112
158
  };
113
159
  export {
114
- j as deleteDsheetContent,
115
- M as getDsheetStateVector,
116
- C as mergeDsheetContent,
117
- A as readDsheetContent
160
+ C as appendDsheetUpdate,
161
+ N as deleteDsheetContent,
162
+ F as fingerprintFromUpdate,
163
+ A as getDsheetStateVector,
164
+ j as mergeDsheetContent,
165
+ M as readDsheetContent
118
166
  };
@@ -1,5 +1,5 @@
1
1
  import { Context } from '../context';
2
- import { Cell, SingleRange } from '../types';
2
+ import { Cell, SingleRange, Sheet } from '../types';
3
3
  import { CommonOptions } from './common';
4
4
 
5
5
  export declare function getCellValue(ctx: Context, row: number, column: number, options?: CommonOptions & {
@@ -7,6 +7,30 @@ export declare function getCellValue(ctx: Context, row: number, column: number,
7
7
  }): any;
8
8
  export declare function setCellValue(ctx: Context, row: number, column: number, value: any, cellInput: HTMLDivElement | null, options?: CommonOptions, callAfterUpdate?: boolean): void;
9
9
  export declare function applyRemoteCellValue(ctx: Context, row: number, column: number, value: any, options?: CommonOptions): void;
10
+ /**
11
+ * Replace a sheet's formula list with the collaborator's value from Yjs (A4).
12
+ * This is what the grid rebuild it replaces produced, without the rebuild. The
13
+ * caller runs it with noHistory.
14
+ *
15
+ * The dependency edges follow the change (C8): an entry that left the chain
16
+ * loses its edges, one that joined gets the edges its cell's text names (or
17
+ * runs on every commit until its cell arrives), and the rest are left alone, so
18
+ * `depGraphComplete` stays on. When the two chains can't be compared the
19
+ * indexes reset to a fresh mount's state.
20
+ */
21
+ export declare function setSheetCalcChain(ctx: Context, calcChain: Sheet['calcChain'], options?: CommonOptions): void;
22
+ export type RemoteCellChange = {
23
+ r: number;
24
+ c: number;
25
+ v: unknown;
26
+ };
27
+ /**
28
+ * Apply a remote batch of cells inside one draft (A5). The caller runs it in
29
+ * one setContext with noHistory, so a batch is one Immer pass and never
30
+ * lands on the local undo stack. A cell that fails is reported through
31
+ * onSkip and the rest still apply.
32
+ */
33
+ export declare function applyRemoteCells(ctx: Context, cells: RemoteCellChange[], options?: CommonOptions, onSkip?: (cell: RemoteCellChange, error: unknown) => void): void;
10
34
  export declare function clearCell(ctx: Context, row: number, column: number, options?: CommonOptions): void;
11
35
  export declare function setCellFormat(ctx: Context, row: number, column: number, attr: keyof Cell, value: any, options?: CommonOptions): void;
12
36
  export declare function autoFillCell(ctx: Context, copyRange: SingleRange, applyRange: SingleRange, direction: 'up' | 'down' | 'left' | 'right'): void;
@@ -0,0 +1 @@
1
+ export {};
@@ -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
  /**