@fileverse-dev/dsheet 4.1.23-stabilise-package-8 → 4.1.24

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 (123) hide show
  1. package/README.md +0 -10
  2. package/dist/editor/contexts/editor-context.d.ts +0 -9
  3. package/dist/editor/hooks/use-celldata-compaction.d.ts +2 -44
  4. package/dist/editor/hooks/use-editor-data.d.ts +0 -1
  5. package/dist/editor/hooks/use-editor-sync.d.ts +1 -5
  6. package/dist/editor/types.d.ts +1 -41
  7. package/dist/editor/utils/after-update-cell.d.ts +0 -6
  8. package/dist/editor/utils/apply-comment-markers.d.ts +1 -3
  9. package/dist/editor/utils/editor-handle.d.ts +1 -1
  10. package/dist/editor/utils/remote-apply-guard.d.ts +0 -45
  11. package/dist/editor/utils/sheet-ydoc-sync-utils.d.ts +4 -13
  12. package/dist/editor/utils/update-ydoc.d.ts +1 -9
  13. package/dist/{executeStringFunction-CN6ZZqZM.js → executeStringFunction-B3Tw7e1U.js} +13166 -13690
  14. package/dist/formula.js +1 -1
  15. package/dist/{index-Dbl7Dh2_.js → index-DvpQioe4.js} +22321 -23599
  16. package/dist/index.d.ts +1 -1
  17. package/dist/index.es.js +21 -21
  18. package/dist/persistence-utils-BXFajzvq.js +98 -0
  19. package/dist/persistence-utils.d.ts +0 -2
  20. package/dist/persistence.d.ts +0 -13
  21. package/dist/persistence.js +74 -122
  22. package/dist/sheet-engine/core/api/cell.d.ts +1 -25
  23. package/dist/sheet-engine/core/api/sheet-flowdata-lifecycle.d.ts +0 -1
  24. package/dist/sheet-engine/core/index.d.ts +1 -1
  25. package/dist/sheet-engine/core/modules/border.d.ts +0 -9
  26. package/dist/sheet-engine/core/modules/dataVerification.d.ts +0 -15
  27. package/dist/sheet-engine/core/modules/formula-arrow-mode.d.ts +81 -0
  28. package/dist/sheet-engine/core/modules/formula-async-eval.d.ts +0 -5
  29. package/dist/sheet-engine/core/modules/formula-snapshot-eval.d.ts +0 -2
  30. package/dist/sheet-engine/core/modules/formula-transitive-deps.d.ts +1 -26
  31. package/dist/sheet-engine/core/modules/formula.d.ts +33 -88
  32. package/dist/sheet-engine/core/modules/index.d.ts +3 -4
  33. package/dist/sheet-engine/core/modules/rowcol.d.ts +0 -8
  34. package/dist/sheet-engine/core/paste-helpers/calculate-range-cell-size.d.ts +0 -14
  35. package/dist/sheet-engine/core/settings.d.ts +1 -11
  36. package/dist/sheet-engine/core/utils/ydoc-celldata-changes.d.ts +2 -29
  37. package/dist/sheet-engine/react/components/ContextMenu/FilterMenu.d.ts +2 -2
  38. package/dist/sheet-engine/react/components/ContextMenu/SheetTab.d.ts +2 -2
  39. package/dist/sheet-engine/react/components/ContextMenu/index.d.ts +2 -2
  40. package/dist/sheet-engine/react/components/SVGDefines.d.ts +2 -2
  41. package/dist/sheet-engine/react/components/SheetTab/index.d.ts +2 -2
  42. package/dist/sheet-engine/react/components/Toolbar/index.d.ts +2 -2
  43. package/dist/sheet-engine/react/components/Workbook/api.d.ts +0 -4
  44. package/dist/sheet-engine/react/components/Workbook/index.d.ts +0 -2
  45. package/dist/sheet-engine/react/context/index.d.ts +0 -15
  46. package/dist/style.css +1 -1
  47. package/dist/sync-local/SyncManager.d.ts +2 -2
  48. package/dist/sync-local/types/index.d.ts +1 -2
  49. package/dist/{use-xlsx-import-impl-sGRvmOlI.js → use-xlsx-import-impl-DWkIjd5v.js} +119 -120
  50. package/dist/{xlsx-defined-names-C6c8LJn5.js → xlsx-defined-names-776Vg9GT.js} +2 -2
  51. package/dist/{xlsx-export-impl-Dno93LqB.js → xlsx-export-impl-C60SB8Ve.js} +4 -4
  52. package/dist/{xlsx-hyperlink-inline-DjtQMKIL.js → xlsx-hyperlink-inline-DaxgypSu.js} +2 -2
  53. package/package.json +1 -1
  54. package/dist/editor/utils/active-sheet-keeper.test.d.ts +0 -1
  55. package/dist/editor/utils/after-update-cell.test.d.ts +0 -1
  56. package/dist/editor/utils/apply-comment-markers.test.d.ts +0 -1
  57. package/dist/editor/utils/calc-chain-ydoc-update.test.d.ts +0 -1
  58. package/dist/editor/utils/content-change.d.ts +0 -48
  59. package/dist/editor/utils/content-change.test.d.ts +0 -1
  60. package/dist/editor/utils/content-fingerprint.d.ts +0 -37
  61. package/dist/editor/utils/content-fingerprint.test.d.ts +0 -1
  62. package/dist/editor/utils/format-gate.d.ts +0 -27
  63. package/dist/editor/utils/format-gate.test.d.ts +0 -1
  64. package/dist/editor/utils/legacy-on-change.d.ts +0 -20
  65. package/dist/editor/utils/legacy-on-change.test.d.ts +0 -1
  66. package/dist/editor/utils/patch-plain-celldata.d.ts +0 -19
  67. package/dist/editor/utils/patch-plain-celldata.test.d.ts +0 -1
  68. package/dist/editor/utils/rebuild-indexeddb-store.d.ts +0 -19
  69. package/dist/editor/utils/rebuild-indexeddb-store.failure.test.d.ts +0 -1
  70. package/dist/editor/utils/rebuild-indexeddb-store.test.d.ts +0 -1
  71. package/dist/editor/utils/remote-apply-guard.test.d.ts +0 -1
  72. package/dist/editor/utils/sheet-ydoc-sync-utils.test.d.ts +0 -1
  73. package/dist/editor/utils/structural-edit-formula-sync.test.d.ts +0 -1
  74. package/dist/editor/utils/structural-edit-other-tabs.test.d.ts +0 -1
  75. package/dist/editor/utils/wait-for-sync.d.ts +0 -35
  76. package/dist/editor/utils/wait-for-sync.test.d.ts +0 -1
  77. package/dist/persistence-utils-CSKBobX8.js +0 -151
  78. package/dist/persistence.append.test.d.ts +0 -1
  79. package/dist/persistence.fingerprint.test.d.ts +0 -1
  80. package/dist/sheet-engine/core/api/remote-apply.test.d.ts +0 -1
  81. package/dist/sheet-engine/core/api/sheet-flowdata-lifecycle.test.d.ts +0 -1
  82. package/dist/sheet-engine/core/modules/b6-ydoc-writes.test.d.ts +0 -1
  83. package/dist/sheet-engine/core/modules/cell-shift.d.ts +0 -11
  84. package/dist/sheet-engine/core/modules/cell.commit-ydoc.test.d.ts +0 -1
  85. package/dist/sheet-engine/core/modules/engine-hot-spots.test.d.ts +0 -1
  86. package/dist/sheet-engine/core/modules/formula-dep-text.d.ts +0 -23
  87. package/dist/sheet-engine/core/modules/formula-dep-text.test.d.ts +0 -1
  88. package/dist/sheet-engine/core/modules/formula-edge-update.d.ts +0 -13
  89. package/dist/sheet-engine/core/modules/formula-narrowing.test.d.ts +0 -1
  90. package/dist/sheet-engine/core/modules/formula-tab-load.test.d.ts +0 -1
  91. package/dist/sheet-engine/core/modules/formula-warmup.d.ts +0 -33
  92. package/dist/sheet-engine/core/modules/formula-warmup.test.d.ts +0 -1
  93. package/dist/sheet-engine/core/modules/formula.dep-graph.test.d.ts +0 -1
  94. package/dist/sheet-engine/core/modules/formula.str-change.test.d.ts +0 -1
  95. package/dist/sheet-engine/core/modules/formula.wide-seed.test.d.ts +0 -1
  96. package/dist/sheet-engine/core/modules/history-calc-chain.d.ts +0 -39
  97. package/dist/sheet-engine/core/modules/history-calc-chain.test.d.ts +0 -1
  98. package/dist/sheet-engine/core/modules/history-celldata.d.ts +0 -25
  99. package/dist/sheet-engine/core/modules/history-grid-size.d.ts +0 -16
  100. package/dist/sheet-engine/core/modules/history-grid-size.test.d.ts +0 -1
  101. package/dist/sheet-engine/core/modules/rowcol-refused-edit.test.d.ts +0 -1
  102. package/dist/sheet-engine/core/modules/rowcol-unloaded-history.test.d.ts +0 -1
  103. package/dist/sheet-engine/core/modules/structural-edit-prep.d.ts +0 -36
  104. package/dist/sheet-engine/core/modules/structural-edit-prep.test.d.ts +0 -1
  105. package/dist/sheet-engine/core/paste/paste-dep-graph.test.d.ts +0 -1
  106. package/dist/sheet-engine/core/paste-helpers/calculate-range-cell-size.test.d.ts +0 -1
  107. package/dist/sheet-engine/react/components/NotationBoxes/shown-comments.d.ts +0 -20
  108. package/dist/sheet-engine/react/components/NotationBoxes/shown-comments.test.d.ts +0 -1
  109. package/dist/sheet-engine/react/components/SheetOverlay/editing-as-formula.d.ts +0 -7
  110. package/dist/sheet-engine/react/components/SheetOverlay/editing-as-formula.test.d.ts +0 -1
  111. package/dist/sheet-engine/react/components/SheetOverlay/hover-tracker.d.ts +0 -44
  112. package/dist/sheet-engine/react/components/SheetOverlay/hover-tracker.test.d.ts +0 -1
  113. package/dist/sheet-engine/react/components/Toolbar/FunctionList/group-functions.d.ts +0 -9
  114. package/dist/sheet-engine/react/components/Toolbar/FunctionList/group-functions.test.d.ts +0 -1
  115. package/dist/sheet-engine/react/components/Workbook/denomination-scan.d.ts +0 -16
  116. package/dist/sheet-engine/react/components/Workbook/denomination-scan.test.d.ts +0 -1
  117. package/dist/sheet-engine/react/components/Workbook/stable-handle.d.ts +0 -8
  118. package/dist/sheet-engine/react/components/Workbook/stable-handle.test.d.ts +0 -1
  119. package/dist/sheet-engine/react/context/use-workbook-store.d.ts +0 -30
  120. package/dist/sheet-engine/react/context/workbook-store.d.ts +0 -30
  121. package/dist/sheet-engine/react/context/workbook-store.test.d.ts +0 -1
  122. package/dist/sync-local/SyncManager.remote-apply.test.d.ts +0 -1
  123. /package/dist/{editor/hooks/use-celldata-compaction.test.d.ts → sheet-engine/core/modules/formula-arrow-mode.test.d.ts} +0 -0
@@ -1,5 +1,5 @@
1
- import { i as w } from "./executeStringFunction-CN6ZZqZM.js";
2
- import { J as x } from "./xlsx-hyperlink-inline-DjtQMKIL.js";
1
+ import { i as w } from "./executeStringFunction-B3Tw7e1U.js";
2
+ import { J as x } from "./xlsx-hyperlink-inline-DaxgypSu.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-DjtQMKIL.js";
5
- import { b as gt } from "./executeStringFunction-CN6ZZqZM.js";
6
- import { e as bt } from "./index-Dbl7Dh2_.js";
4
+ import { J as dt, c as X, g as ht, a as mt } from "./xlsx-hyperlink-inline-DaxgypSu.js";
5
+ import { b as gt } from "./executeStringFunction-B3Tw7e1U.js";
6
+ import { e as bt } from "./index-DvpQioe4.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-C6c8LJn5.js");
857
+ const { applyDefinedNamesToExcelWorkbook: ct } = await import("./xlsx-defined-names-776Vg9GT.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-CN6ZZqZM.js";
2
- import { c as wt } from "./index-Dbl7Dh2_.js";
1
+ import { g as Rt, c as yt } from "./executeStringFunction-B3Tw7e1U.js";
2
+ import { c as wt } from "./index-DvpQioe4.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-8",
5
+ "version": "4.1.24",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "git+https://github.com/fileverse/fileverse-dsheets.git"
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,48 +0,0 @@
1
- import * as Y from 'yjs';
2
- /**
3
- * Cheap change signal for hosts (Stabilize A1). Built from the live Y.Doc
4
- * without encoding it; full state stays available through
5
- * editorStateRef.getContentSnapshot().
6
- */
7
- export type DSheetContentChange = {
8
- /** Same meaning as dsheets.new `isEmptySheet(...) === false`. */
9
- hasContent: boolean;
10
- /** A local user edit has happened since this editor mounted. */
11
- userEdited: boolean;
12
- /**
13
- * base64 state vector + ":" + deleted count. Changes on every change,
14
- * deletes included; compare with === only. null until y-indexeddb is
15
- * attached and synced.
16
- */
17
- fingerprint: string | null;
18
- };
19
- /** Default-workbook seed and legacy migration: content, but not a user edit. */
20
- export declare const INIT_ORIGIN = "init";
21
- /** Idle celldata compaction: rewrites storage, not a user edit. */
22
- export declare const COMPACTION_ORIGIN = "compaction";
23
- /**
24
- * Mirrors dsheets.new `isEmptySheet` (components/dsheet-editor/editor-utils.ts):
25
- * no sheets → empty; more than one sheet → content; otherwise content when
26
- * sheet 0 has any config key or any celldata entry. Stops at the first live
27
- * entry, so it does not walk the sheet.
28
- */
29
- export declare function computeHasContent(doc: Y.Doc, dsheetId: string): boolean;
30
- export type UserEditTracker = {
31
- userEdited(): boolean;
32
- dispose(): void;
33
- };
34
- /**
35
- * Turns on at the first transaction that changes the document and whose
36
- * origin is not a known non-user origin or the IndexedDB provider.
37
- */
38
- export declare function attachUserEditTracker(doc: Y.Doc, getIndexeddbOrigin: () => unknown): UserEditTracker;
39
- export declare const CONTENT_CHANGE_WAIT_MS = 1000;
40
- /**
41
- * At most one host call per second (trailing only); local and remote changes
42
- * share the throttle. The change is built when the call fires, never per edit.
43
- */
44
- export declare function createContentChangeNotifier(getChange: () => DSheetContentChange, getHandler: () => ((change: DSheetContentChange) => void) | undefined, waitMs?: number): {
45
- notify: () => void;
46
- flush: () => void;
47
- cancel: () => any;
48
- };
@@ -1 +0,0 @@
1
- export {};
@@ -1,37 +0,0 @@
1
- import * as Y from 'yjs';
2
- /**
3
- * Cheap "did the document change" signal (Stabilize A1 / D6).
4
- *
5
- * fingerprint = base64(state vector) + ":" + deletedCount
6
- *
7
- * A state vector alone misses delete-only transactions (clearing a filter,
8
- * dropdown, conditional format, sub-sheet or named range; undo of a typed
9
- * value), because a Yjs delete adds no item. deletedCount is the total length
10
- * of all deleted ranges in the document, kept as a running count so no full
11
- * scan is needed per check. Compare fingerprints with === only.
12
- */
13
- export type ContentFingerprintTracker = {
14
- getFingerprint(): string;
15
- getDeletedCount(): number;
16
- dispose(): void;
17
- };
18
- /**
19
- * Attach when the Y.Doc is created, before any provider writes to it, so the
20
- * count is built from transactions. Attaching later costs one full scan.
21
- */
22
- export declare function attachContentFingerprint(doc: Y.Doc): ContentFingerprintTracker;
23
- /**
24
- * Same value as a live tracker, for a stored body or a merge of raw rows.
25
- * Builds a temporary document and scans its delete set, as getDsheetStateVector
26
- * builds one. Reading the delete ranges from the encoded update instead
27
- * (Y.decodeUpdate) misses GC structs that arrive without a delete range, e.g.
28
- * a row written when the document received a compacted body.
29
- */
30
- export declare function fingerprintFromUpdate(update: Uint8Array): string;
31
- /**
32
- * Same value as a live tracker, computed from a document by one scan of its
33
- * delete set (under 1.5 ms at 100k cells). Used by the body reads, which
34
- * already build a document from every IndexedDB row, so GC structs that
35
- * arrived without a delete range are counted.
36
- */
37
- export declare function fingerprintFromDocument(doc: Y.Doc): string;
@@ -1,27 +0,0 @@
1
- import * as Y from 'yjs';
2
- /** Highest `meta.format` this client can write. */
3
- export declare const SUPPORTED_FORMAT = 1;
4
- /** Shown to the user once the sheet is locked. */
5
- export declare const FORMAT_LOCKED_MESSAGE = "This sheet was updated. Reload to continue.";
6
- /**
7
- * Format of the sheet in `doc`. A missing map or key means 1, and so does a
8
- * value that is not a number. Does not create the map when it is absent.
9
- */
10
- export declare function readFormatVersion(doc: Y.Doc, dsheetId: string): number;
11
- /**
12
- * True once a watched sheet of `doc` has shown a format above SUPPORTED_FORMAT.
13
- * With `dsheetId` it answers for that sheet only, and also reads the doc, so
14
- * it holds before the watch starts. Without it, true if any sheet is locked.
15
- */
16
- export declare function isFormatLocked(doc: Y.Doc | null | undefined, dsheetId?: string): boolean;
17
- /**
18
- * Make the grid read-only in the same tick the lock is seen. The Yjs writers
19
- * stop at once (isFormatLocked), but the grid became read-only only after the
20
- * workbook data changed identity and the Workbook init effect ran: a commit in
21
- * between showed in the grid, never reached Yjs, and was gone on reload.
22
- * The Workbook init effect sets the same flag from the prop afterwards.
23
- */
24
- export declare function lockWorkbookReadOnly(workbook: {
25
- getWorkbookSetContext?: () => unknown;
26
- } | null | undefined): boolean;
27
- export declare function watchFormatGate(doc: Y.Doc, dsheetId: string, onLocked: (format: number) => void): () => void;
@@ -1 +0,0 @@
1
- export {};
@@ -1,20 +0,0 @@
1
- /** The legacy `onChange` argument pair: plain sheet data and the encoded doc. */
2
- export type LegacyOnChangeArgs = {
3
- data: unknown;
4
- update: string;
5
- };
6
- export declare const LEGACY_ON_CHANGE_WAIT_MS = 1000;
7
- /**
8
- * Trailing-only throttle for the host's legacy `onChange`.
9
- *
10
- * The host's handler is read when the throttle fires, not when it is created.
11
- * A host that passes a new inline `onChange` on every render must not rebuild
12
- * this throttle: rebuilding cancels the pending call, so an edit followed
13
- * within the wait by a re-render never reached the host's save.
14
- * `buildArgs` runs only when there is a handler, because it encodes the whole
15
- * document.
16
- */
17
- export declare function createLegacyOnChangeThrottle<TData>(getOnChange: () => ((data: TData, update: string) => void) | undefined, buildArgs: () => {
18
- data: TData;
19
- update: string;
20
- } | null, waitMs?: number): any;
@@ -1 +0,0 @@
1
- export {};
@@ -1,19 +0,0 @@
1
- export type PlainCelldataEntry = {
2
- r: number;
3
- c: number;
4
- v: unknown;
5
- };
6
- export type CelldataPatch = {
7
- key: string;
8
- action: 'delete' | 'update';
9
- v?: unknown;
10
- };
11
- /**
12
- * Apply a remote batch of cell changes to a sheet's plain celldata array in
13
- * place. Keys are `r_c` and unique within a batch.
14
- *
15
- * One pass over celldata finds every patched cell (A5): O(entries + changes)
16
- * instead of a findIndex per changed key. The lookup is by row then column
17
- * number, so the pass allocates nothing per entry.
18
- */
19
- export declare function patchPlainCelldata(celldata: PlainCelldataEntry[], patches: Iterable<CelldataPatch>): void;
@@ -1 +0,0 @@
1
- export {};
@@ -1,19 +0,0 @@
1
- import { IndexeddbPersistence } from 'y-indexeddb';
2
- import type * as Y from 'yjs';
3
- /**
4
- * D3: rebuild the local IndexedDB store from the live document.
5
- *
6
- * Destroys `current`, deletes the database, then attaches a new provider to
7
- * the SAME live Y.Doc, so y-indexeddb writes the full current state as one
8
- * fresh row. `onCreated` runs right after the new provider is constructed,
9
- * before it has synced, so the caller can track it and attach listeners. The Y.Doc is never replaced or cleared. Unlike delete-and-reopen
10
- * (heal), edits that exist only in the live doc are kept.
11
- *
12
- * The wait for the new provider is bounded: `whenSynced` never rejects, and a
13
- * provider destroyed before its first read (a bootstrap restarting meanwhile)
14
- * never syncs. It rejects on `timeoutMs` or once `isCurrent()` is false.
15
- */
16
- export declare function rebuildIndexedDbStore(dsheetId: string, doc: Y.Doc, current: IndexeddbPersistence | null, onCreated?: (provider: IndexeddbPersistence) => void, syncOptions?: {
17
- timeoutMs?: number;
18
- isCurrent?: () => boolean;
19
- }): Promise<IndexeddbPersistence>;
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,35 +0,0 @@
1
- /**
2
- * Waits for a y-indexeddb provider without trusting it to finish.
3
- *
4
- * In y-indexeddb 9.0.12 `whenSynced` resolves only on 'synced'. It has no
5
- * reject path, and a provider that is destroyed before its first read, or whose
6
- * first read never completes, never syncs. Awaiting it directly hangs the
7
- * bootstrap, and a rebuild that waits for the bootstrap hangs with it.
8
- */
9
- export declare const INDEXEDDB_SYNC_TIMEOUT_MS = 15000;
10
- /** How long a rebuild waits for a running bootstrap before it abandons it. */
11
- export declare const REBUILD_BOOTSTRAP_WAIT_MS = 3000;
12
- export declare class PersistenceSyncTimeoutError extends Error {
13
- constructor(ms: number);
14
- }
15
- export declare class PersistenceSupersededError extends Error {
16
- constructor();
17
- }
18
- /**
19
- * Resolves when `whenSynced` does. Rejects with PersistenceSyncTimeoutError
20
- * after `timeoutMs`, or with PersistenceSupersededError as soon as
21
- * `isCurrent()` turns false (checked every 100 ms): a newer bootstrap or an
22
- * unmount owns the provider then, and it may already be destroyed.
23
- */
24
- export declare function waitForPersistenceSynced(persistence: {
25
- whenSynced: Promise<unknown>;
26
- }, options?: {
27
- timeoutMs?: number;
28
- isCurrent?: () => boolean;
29
- }): Promise<void>;
30
- /**
31
- * Waits for a running bootstrap for at most `ms`. 'stuck' means it has not
32
- * settled; the caller then abandons it (bumps the generation) instead of
33
- * waiting for a provider that may never sync.
34
- */
35
- export declare function waitForBootstrapOrAbandon(bootstrap: Promise<unknown>, ms?: number): Promise<'settled' | 'stuck'>;
@@ -1 +0,0 @@
1
- export {};
@@ -1,151 +0,0 @@
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
- };
@@ -1 +0,0 @@
1
-
@@ -1 +0,0 @@
1
- export {};
@@ -1,11 +0,0 @@
1
- import { Context } from '../context';
2
-
3
- /** A selection rectangle: `row` and `column` are [start, end]. */
4
- export type CellShiftRange = {
5
- row: number[];
6
- column: number[];
7
- };
8
- /** Delete the selected cells and shift the rest left or up. */
9
- export declare function deleteCellsShift(ctx: Context, direction: 'left' | 'up', range: CellShiftRange): void;
10
- /** Insert empty cells at the selection and shift the rest right or down. */
11
- export declare function insertCellsShift(ctx: Context, direction: 'right' | 'down', range: CellShiftRange): void;
@@ -1,23 +0,0 @@
1
- import { Context } from '../context';
2
- import { WideRange } from './formula-transitive-deps';
3
-
4
- /** Same cap as `execfunction` (MAX_RANGE_DEPS in formula.ts). */
5
- export declare const MAX_TEXT_RANGE_DEPS = 10000;
6
- export type FormulaTextDeps = {
7
- /** `${sheetId}:${r}:${c}` of every cell the formula reads. */
8
- deps: Set<string>;
9
- /** Too wide or unresolvable to list. */
10
- wide: boolean;
11
- /**
12
- * The ranges that made it wide, as `execfunction` records them. `null` when
13
- * the formula is wide but its ranges can't be read from its text (an
14
- * unresolved tab, INDIRECT, OFFSET, a whole row or column of a tab with no
15
- * grid): it joins every commit's walk. `[]` when it is not wide.
16
- */
17
- wideRanges: WideRange[] | null;
18
- };
19
- /**
20
- * Collect the references of formula text `f` (with its leading `=`) written
21
- * in cell (`r`, `c`) of tab `sheetId`.
22
- */
23
- export declare function collectFormulaTextDeps(ctx: Context, f: string, sheetId: string, r: number, c: number): FormulaTextDeps;
@@ -1,13 +0,0 @@
1
- import { Context } from '../context';
2
-
3
- /**
4
- * Set the edges of the formula `f` written in (`r`, `c`) of tab `sheetId`, or
5
- * drop them when `f` is null (the value is no longer a formula).
6
- */
7
- export declare function setFormulaEdgesFromText(ctx: Context, r: number, c: number, sheetId: string, f: string | null): void;
8
- /**
9
- * A chain entry whose cell isn't here yet (a peer's chain can arrive before
10
- * its cells): it can't be read, so it runs on every commit until the cell
11
- * arrives and replaces this.
12
- */
13
- export declare function markFormulaEdgesUnknown(ctx: Context, r: number, c: number, sheetId: string): void;
@@ -1,33 +0,0 @@
1
- import { Context } from '../context';
2
-
3
- export declare const FORMULA_WARMUP_BUDGET_MS = 8;
4
- export declare const FORMULA_WARMUP_DEBOUNCE_MS = 2000;
5
- export declare const FORMULA_WARMUP_IDLE_TIMEOUT_MS = 1000;
6
- export type FormulaWarmupResult = 'complete' | 'aborted';
7
- export type FormulaWarmupOptions = {
8
- /** Longest a slice keeps reading formulas before it yields (default 8). */
9
- budgetMs: number;
10
- /** Runs the next slice later (idle callback in the app). */
11
- schedule: (cb: () => void) => void;
12
- isCancelled?: () => boolean;
13
- };
14
- /**
15
- * Walk the calc chain in slices and read every formula's references, then
16
- * mark the graph complete (C8). Resolves 'aborted' if the graph is cleared
17
- * while it runs or `isCancelled` says so. A tab with no grid is read from its
18
- * `celldata`.
19
- *
20
- * Pass a getter to read the latest context in each slice (the Workbook does);
21
- * a plain context is used as is.
22
- */
23
- export declare function warmFormulaDependencyGraph(ctxOrGetter: Context | (() => Context), opts: FormulaWarmupOptions): Promise<FormulaWarmupResult>;
24
- /**
25
- * Run the warm-up in the app: on `trigger()` (data ready after mount) and
26
- * again `FORMULA_WARMUP_DEBOUNCE_MS` after each `markDepGraphIncomplete()`.
27
- * Slices run in idle callbacks (setTimeout without requestIdleCallback) and
28
- * only while the page is visible.
29
- */
30
- export declare function scheduleFormulaWarmup(getCtx: () => Context): {
31
- trigger(): void;
32
- dispose(): void;
33
- };
@@ -1,39 +0,0 @@
1
- import { Patch } from 'immer';
2
- import { Context } from '../context';
3
-
4
- /**
5
- * Undo and redo apply Immer patches that address `calcChain` by array index.
6
- * After a collaborator's formula list has replaced the sheet's chain (A4),
7
- * those indexes point into a different array, so replaying them can truncate
8
- * it and drop the collaborator's formulas; the calcChain hook would then
9
- * delete those entries from Yjs for everyone.
10
- *
11
- * So history never restores `calcChain` from patches. The cells it restores
12
- * are re-registered from their own `f` instead (`reregisterRestoredFormulas`).
13
- */
14
- export type RestoredCell = {
15
- sheetIndex: number;
16
- r: number;
17
- c: number | null;
18
- };
19
- /**
20
- * `patches` without the calcChain ones, and the cells whose formulas must be
21
- * re-registered afterwards. When a patch replaces a whole sheet or grid the
22
- * cells can't be listed, so history is left as it was (`restored` is null).
23
- */
24
- export declare function planHistoryPatches(patches: Patch[]): {
25
- patches: Patch[];
26
- restored: RestoredCell[] | null;
27
- };
28
- /**
29
- * Register the restored cells that hold a formula and drop the ones that no
30
- * longer do. Run on a draft after the patches were applied. The graph is left
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.
38
- */
39
- export declare function reregisterRestoredFormulas(ctx: Context, restored: RestoredCell[]): void;