@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.
- package/README.md +0 -10
- package/dist/editor/contexts/editor-context.d.ts +0 -9
- package/dist/editor/hooks/use-celldata-compaction.d.ts +2 -44
- package/dist/editor/hooks/use-editor-data.d.ts +0 -1
- package/dist/editor/hooks/use-editor-sync.d.ts +1 -5
- package/dist/editor/types.d.ts +1 -41
- package/dist/editor/utils/after-update-cell.d.ts +0 -6
- package/dist/editor/utils/apply-comment-markers.d.ts +1 -3
- package/dist/editor/utils/editor-handle.d.ts +1 -1
- package/dist/editor/utils/remote-apply-guard.d.ts +0 -45
- package/dist/editor/utils/sheet-ydoc-sync-utils.d.ts +4 -13
- package/dist/editor/utils/update-ydoc.d.ts +1 -9
- package/dist/{executeStringFunction-CN6ZZqZM.js → executeStringFunction-B3Tw7e1U.js} +13166 -13690
- package/dist/formula.js +1 -1
- package/dist/{index-Dbl7Dh2_.js → index-DvpQioe4.js} +22321 -23599
- package/dist/index.d.ts +1 -1
- package/dist/index.es.js +21 -21
- package/dist/persistence-utils-BXFajzvq.js +98 -0
- package/dist/persistence-utils.d.ts +0 -2
- package/dist/persistence.d.ts +0 -13
- package/dist/persistence.js +74 -122
- package/dist/sheet-engine/core/api/cell.d.ts +1 -25
- package/dist/sheet-engine/core/api/sheet-flowdata-lifecycle.d.ts +0 -1
- package/dist/sheet-engine/core/index.d.ts +1 -1
- package/dist/sheet-engine/core/modules/border.d.ts +0 -9
- package/dist/sheet-engine/core/modules/dataVerification.d.ts +0 -15
- package/dist/sheet-engine/core/modules/formula-arrow-mode.d.ts +81 -0
- package/dist/sheet-engine/core/modules/formula-async-eval.d.ts +0 -5
- package/dist/sheet-engine/core/modules/formula-snapshot-eval.d.ts +0 -2
- package/dist/sheet-engine/core/modules/formula-transitive-deps.d.ts +1 -26
- package/dist/sheet-engine/core/modules/formula.d.ts +33 -88
- package/dist/sheet-engine/core/modules/index.d.ts +3 -4
- package/dist/sheet-engine/core/modules/rowcol.d.ts +0 -8
- package/dist/sheet-engine/core/paste-helpers/calculate-range-cell-size.d.ts +0 -14
- package/dist/sheet-engine/core/settings.d.ts +1 -11
- package/dist/sheet-engine/core/utils/ydoc-celldata-changes.d.ts +2 -29
- package/dist/sheet-engine/react/components/ContextMenu/FilterMenu.d.ts +2 -2
- package/dist/sheet-engine/react/components/ContextMenu/SheetTab.d.ts +2 -2
- package/dist/sheet-engine/react/components/ContextMenu/index.d.ts +2 -2
- package/dist/sheet-engine/react/components/SVGDefines.d.ts +2 -2
- package/dist/sheet-engine/react/components/SheetTab/index.d.ts +2 -2
- package/dist/sheet-engine/react/components/Toolbar/index.d.ts +2 -2
- package/dist/sheet-engine/react/components/Workbook/api.d.ts +0 -4
- package/dist/sheet-engine/react/components/Workbook/index.d.ts +0 -2
- package/dist/sheet-engine/react/context/index.d.ts +0 -15
- package/dist/style.css +1 -1
- package/dist/sync-local/SyncManager.d.ts +2 -2
- package/dist/sync-local/types/index.d.ts +1 -2
- package/dist/{use-xlsx-import-impl-sGRvmOlI.js → use-xlsx-import-impl-DWkIjd5v.js} +119 -120
- package/dist/{xlsx-defined-names-C6c8LJn5.js → xlsx-defined-names-776Vg9GT.js} +2 -2
- package/dist/{xlsx-export-impl-Dno93LqB.js → xlsx-export-impl-C60SB8Ve.js} +4 -4
- package/dist/{xlsx-hyperlink-inline-DjtQMKIL.js → xlsx-hyperlink-inline-DaxgypSu.js} +2 -2
- package/package.json +1 -1
- package/dist/editor/utils/active-sheet-keeper.test.d.ts +0 -1
- package/dist/editor/utils/after-update-cell.test.d.ts +0 -1
- package/dist/editor/utils/apply-comment-markers.test.d.ts +0 -1
- package/dist/editor/utils/calc-chain-ydoc-update.test.d.ts +0 -1
- package/dist/editor/utils/content-change.d.ts +0 -48
- package/dist/editor/utils/content-change.test.d.ts +0 -1
- package/dist/editor/utils/content-fingerprint.d.ts +0 -37
- package/dist/editor/utils/content-fingerprint.test.d.ts +0 -1
- package/dist/editor/utils/format-gate.d.ts +0 -27
- package/dist/editor/utils/format-gate.test.d.ts +0 -1
- package/dist/editor/utils/legacy-on-change.d.ts +0 -20
- package/dist/editor/utils/legacy-on-change.test.d.ts +0 -1
- package/dist/editor/utils/patch-plain-celldata.d.ts +0 -19
- package/dist/editor/utils/patch-plain-celldata.test.d.ts +0 -1
- package/dist/editor/utils/rebuild-indexeddb-store.d.ts +0 -19
- package/dist/editor/utils/rebuild-indexeddb-store.failure.test.d.ts +0 -1
- package/dist/editor/utils/rebuild-indexeddb-store.test.d.ts +0 -1
- package/dist/editor/utils/remote-apply-guard.test.d.ts +0 -1
- package/dist/editor/utils/sheet-ydoc-sync-utils.test.d.ts +0 -1
- package/dist/editor/utils/structural-edit-formula-sync.test.d.ts +0 -1
- package/dist/editor/utils/structural-edit-other-tabs.test.d.ts +0 -1
- package/dist/editor/utils/wait-for-sync.d.ts +0 -35
- package/dist/editor/utils/wait-for-sync.test.d.ts +0 -1
- package/dist/persistence-utils-CSKBobX8.js +0 -151
- package/dist/persistence.append.test.d.ts +0 -1
- package/dist/persistence.fingerprint.test.d.ts +0 -1
- package/dist/sheet-engine/core/api/remote-apply.test.d.ts +0 -1
- package/dist/sheet-engine/core/api/sheet-flowdata-lifecycle.test.d.ts +0 -1
- package/dist/sheet-engine/core/modules/b6-ydoc-writes.test.d.ts +0 -1
- package/dist/sheet-engine/core/modules/cell-shift.d.ts +0 -11
- package/dist/sheet-engine/core/modules/cell.commit-ydoc.test.d.ts +0 -1
- package/dist/sheet-engine/core/modules/engine-hot-spots.test.d.ts +0 -1
- package/dist/sheet-engine/core/modules/formula-dep-text.d.ts +0 -23
- package/dist/sheet-engine/core/modules/formula-dep-text.test.d.ts +0 -1
- package/dist/sheet-engine/core/modules/formula-edge-update.d.ts +0 -13
- package/dist/sheet-engine/core/modules/formula-narrowing.test.d.ts +0 -1
- package/dist/sheet-engine/core/modules/formula-tab-load.test.d.ts +0 -1
- package/dist/sheet-engine/core/modules/formula-warmup.d.ts +0 -33
- package/dist/sheet-engine/core/modules/formula-warmup.test.d.ts +0 -1
- package/dist/sheet-engine/core/modules/formula.dep-graph.test.d.ts +0 -1
- package/dist/sheet-engine/core/modules/formula.str-change.test.d.ts +0 -1
- package/dist/sheet-engine/core/modules/formula.wide-seed.test.d.ts +0 -1
- package/dist/sheet-engine/core/modules/history-calc-chain.d.ts +0 -39
- package/dist/sheet-engine/core/modules/history-calc-chain.test.d.ts +0 -1
- package/dist/sheet-engine/core/modules/history-celldata.d.ts +0 -25
- package/dist/sheet-engine/core/modules/history-grid-size.d.ts +0 -16
- package/dist/sheet-engine/core/modules/history-grid-size.test.d.ts +0 -1
- package/dist/sheet-engine/core/modules/rowcol-refused-edit.test.d.ts +0 -1
- package/dist/sheet-engine/core/modules/rowcol-unloaded-history.test.d.ts +0 -1
- package/dist/sheet-engine/core/modules/structural-edit-prep.d.ts +0 -36
- package/dist/sheet-engine/core/modules/structural-edit-prep.test.d.ts +0 -1
- package/dist/sheet-engine/core/paste/paste-dep-graph.test.d.ts +0 -1
- package/dist/sheet-engine/core/paste-helpers/calculate-range-cell-size.test.d.ts +0 -1
- package/dist/sheet-engine/react/components/NotationBoxes/shown-comments.d.ts +0 -20
- package/dist/sheet-engine/react/components/NotationBoxes/shown-comments.test.d.ts +0 -1
- package/dist/sheet-engine/react/components/SheetOverlay/editing-as-formula.d.ts +0 -7
- package/dist/sheet-engine/react/components/SheetOverlay/editing-as-formula.test.d.ts +0 -1
- package/dist/sheet-engine/react/components/SheetOverlay/hover-tracker.d.ts +0 -44
- package/dist/sheet-engine/react/components/SheetOverlay/hover-tracker.test.d.ts +0 -1
- package/dist/sheet-engine/react/components/Toolbar/FunctionList/group-functions.d.ts +0 -9
- package/dist/sheet-engine/react/components/Toolbar/FunctionList/group-functions.test.d.ts +0 -1
- package/dist/sheet-engine/react/components/Workbook/denomination-scan.d.ts +0 -16
- package/dist/sheet-engine/react/components/Workbook/denomination-scan.test.d.ts +0 -1
- package/dist/sheet-engine/react/components/Workbook/stable-handle.d.ts +0 -8
- package/dist/sheet-engine/react/components/Workbook/stable-handle.test.d.ts +0 -1
- package/dist/sheet-engine/react/context/use-workbook-store.d.ts +0 -30
- package/dist/sheet-engine/react/context/workbook-store.d.ts +0 -30
- package/dist/sheet-engine/react/context/workbook-store.test.d.ts +0 -1
- package/dist/sync-local/SyncManager.remote-apply.test.d.ts +0 -1
- /package/dist/{editor/hooks/use-celldata-compaction.test.d.ts → sheet-engine/core/modules/formula-arrow-mode.test.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -86,7 +86,6 @@ function App() {
|
|
|
86
86
|
| `isCollaborative` | `boolean` | `false` | Enable collaborative features |
|
|
87
87
|
| `enableWebrtc` | `boolean` | `true` | Enable WebRTC for P2P collaboration |
|
|
88
88
|
| `enableIndexeddbSync` | `boolean` | `true` | Enable local IndexedDB persistence |
|
|
89
|
-
| `onIndexedDbError` | `(error: Error) => void` | - | Called when local persistence fails, or when the first read of the local store does not finish within 15 s. The editor continues with the in-memory document; call `rebuildLocalStore()` to recreate the store |
|
|
90
89
|
| `isTemplateOpen` | `boolean` | - | Template sidebar state |
|
|
91
90
|
| `selectedTemplate` | `string` | - | Selected template identifier |
|
|
92
91
|
| `onboardingComplete` | `boolean` | - | Onboarding completion status |
|
|
@@ -116,15 +115,6 @@ function App() {
|
|
|
116
115
|
| `setInputFetchURLDataBlock` | `Dispatch<SetStateAction<string>>` | URL input state setter |
|
|
117
116
|
| `setForceSheetRender` | `Dispatch<SetStateAction<number>>` | Force re-render trigger |
|
|
118
117
|
|
|
119
|
-
### Editor handle methods
|
|
120
|
-
|
|
121
|
-
`sheetEditorRef` is a `DSheetEditorHandle`: the workbook instance plus these methods.
|
|
122
|
-
|
|
123
|
-
| Method | Description |
|
|
124
|
-
|--------|-------------|
|
|
125
|
-
| `rebuildLocalStore()` | `Promise<void>`. Deletes this sheet's IndexedDB database and rewrites it from the live document, so local edits are kept. A no-op when read-only or when `enableIndexeddbSync` is off. Rejects if the rebuild fails, the new store does not sync within 15 s, or a refresh or unmount supersedes it. Concurrent calls share one rebuild. |
|
|
126
|
-
| `getContentFingerprint()` | `string \| null`. Changes on every document change, deletes included; compare with `===` only. `null` until local persistence has synced. |
|
|
127
|
-
|
|
128
118
|
## Examples
|
|
129
119
|
|
|
130
120
|
### Read-Only Viewer
|
|
@@ -10,7 +10,6 @@ import { UseSmartContractReturn } from '../hooks/use-smart-contract';
|
|
|
10
10
|
import { CollaborationProps, CollabState, CollabUser } from '../../sync-local/types';
|
|
11
11
|
import { Awareness } from 'y-protocols/awareness';
|
|
12
12
|
import { DSheetContentSnapshot } from '../../persistence';
|
|
13
|
-
import { DSheetContentChange } from '../utils/content-change';
|
|
14
13
|
|
|
15
14
|
import * as Y from 'yjs';
|
|
16
15
|
export interface EditorContextType {
|
|
@@ -21,8 +20,6 @@ export interface EditorContextType {
|
|
|
21
20
|
getDocumentTitle?: (dsheetId: string) => Promise<string>;
|
|
22
21
|
updateDocumentTitle?: (title: string) => void;
|
|
23
22
|
isAuthorized: boolean;
|
|
24
|
-
/** True once the sheet's meta.format is above what this client supports. */
|
|
25
|
-
formatLocked?: boolean;
|
|
26
23
|
dataBlockCalcFunction: {
|
|
27
24
|
[key: string]: {
|
|
28
25
|
[key: string]: any;
|
|
@@ -34,19 +31,14 @@ export interface EditorContextType {
|
|
|
34
31
|
};
|
|
35
32
|
}>>;
|
|
36
33
|
refreshIndexedDB: () => Promise<void>;
|
|
37
|
-
rebuildLocalStore: () => Promise<void>;
|
|
38
34
|
sheetEditorRef: React.MutableRefObject<WorkbookInstance | null>;
|
|
39
35
|
setSheetEditorRef: React.RefCallback<WorkbookInstance>;
|
|
40
|
-
/** Call when the active sheet changes or sheets appear; lets the keeper remember or restore it. */
|
|
41
|
-
notifyActiveSheetChange: () => void;
|
|
42
36
|
ydocRef: React.MutableRefObject<Y.Doc | null>;
|
|
43
37
|
persistenceRef: React.MutableRefObject<IndexeddbPersistence | null>;
|
|
44
38
|
sheetData: Sheet[];
|
|
45
39
|
setSheetData: React.Dispatch<React.SetStateAction<Sheet[]>>;
|
|
46
40
|
currentDataRef: React.MutableRefObject<Sheet[]>;
|
|
47
41
|
remoteUpdateRef: React.MutableRefObject<boolean>;
|
|
48
|
-
/** True while a peer's structural edit waits to remount the grid. */
|
|
49
|
-
structuralRemountPendingRef: React.MutableRefObject<boolean>;
|
|
50
42
|
handleChange: (data: Sheet[]) => void;
|
|
51
43
|
initialiseLiveQueryData: (data: Sheet[]) => void;
|
|
52
44
|
loading: boolean;
|
|
@@ -88,7 +80,6 @@ interface EditorProviderProps {
|
|
|
88
80
|
enableIndexeddbSync?: boolean;
|
|
89
81
|
isReadOnly?: boolean;
|
|
90
82
|
onContentUpdate?: () => void;
|
|
91
|
-
onContentChange?: (change: DSheetContentChange) => void;
|
|
92
83
|
onChange?: (data: SheetUpdateData, encodedUpdate?: string) => void;
|
|
93
84
|
collaboration?: CollaborationProps;
|
|
94
85
|
externalEditorRef?: React.Ref<DSheetEditorHandle>;
|
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
import { MutableRefObject, RefObject } from 'react';
|
|
2
2
|
import { WorkbookInstance, Sheet } from '../../sheet-engine/react';
|
|
3
|
-
import { planYdocCompaction } from '../utils/compact-committed-celldata';
|
|
4
3
|
|
|
5
|
-
import * as Y from 'yjs';
|
|
6
|
-
/** Wait before a refused or stopped run is tried again. */
|
|
7
|
-
export declare const COMPACTION_RETRY_MS = 30000;
|
|
8
|
-
/** Tries after the first run; the compaction is also retried on a later open. */
|
|
9
|
-
export declare const COMPACTION_MAX_RETRIES = 10;
|
|
4
|
+
import type * as Y from 'yjs';
|
|
10
5
|
type UseCelldataCompactionArgs = {
|
|
11
6
|
dsheetId: string;
|
|
12
7
|
ydocRef: RefObject<Y.Doc | null>;
|
|
@@ -17,48 +12,11 @@ type UseCelldataCompactionArgs = {
|
|
|
17
12
|
isDataLoaded: boolean;
|
|
18
13
|
isReadOnly: boolean;
|
|
19
14
|
remoteUpdateRef: MutableRefObject<boolean>;
|
|
20
|
-
/** True while a structural remote change waits to remount the Workbook. */
|
|
21
|
-
structuralRemountPendingRef?: MutableRefObject<boolean>;
|
|
22
15
|
collabSyncing: boolean;
|
|
23
16
|
};
|
|
24
|
-
/**
|
|
25
|
-
* False while a remote apply is running, while a structural remount is pending
|
|
26
|
-
* (the engine still has the old grid and the Yjs document has the new one) or
|
|
27
|
-
* while collaboration is still syncing.
|
|
28
|
-
*/
|
|
29
|
-
export declare function canRunCompaction(refs: {
|
|
30
|
-
remoteUpdateRef: MutableRefObject<boolean>;
|
|
31
|
-
structuralRemountPendingRef?: MutableRefObject<boolean>;
|
|
32
|
-
}, collabSyncing: boolean): boolean;
|
|
33
|
-
/**
|
|
34
|
-
* Runs `attempt` and, when it asks for a retry (the gate was closed, or a run
|
|
35
|
-
* stopped because the document changed), calls `retry` after `delayMs`, up to
|
|
36
|
-
* `maxRetries` times. Without it a refused run waited for the next open, so
|
|
37
|
-
* compaction made one chunk of progress per open (PR 466 N10).
|
|
38
|
-
*/
|
|
39
|
-
export declare function createCompactionRetrier({ attempt, retry, delayMs, maxRetries, setTimer, clearTimer, }: {
|
|
40
|
-
attempt: () => Promise<'done' | 'retry'>;
|
|
41
|
-
retry: () => void;
|
|
42
|
-
delayMs?: number;
|
|
43
|
-
maxRetries?: number;
|
|
44
|
-
setTimer?: (cb: () => void, ms: number) => ReturnType<typeof setTimeout>;
|
|
45
|
-
clearTimer?: (handle: ReturnType<typeof setTimeout>) => void;
|
|
46
|
-
}): {
|
|
47
|
-
run(): Promise<void>;
|
|
48
|
-
cancel(): void;
|
|
49
|
-
};
|
|
50
|
-
/**
|
|
51
|
-
* Applies the plan chunk by chunk, yielding between chunks. The plan was made
|
|
52
|
-
* from the document as it was, and one change in it, the whole-value
|
|
53
|
-
* borderInfo write, would overwrite a newer value. So the run stops, leaving
|
|
54
|
-
* the compaction unfinished (it is retried on a later open), as soon as the
|
|
55
|
-
* document differs from what the previous chunk left. Returns true when every
|
|
56
|
-
* chunk was applied.
|
|
57
|
-
*/
|
|
58
|
-
export declare function applyCompactionChangesInChunks(ydoc: Y.Doc, dsheetId: string, changes: ReturnType<typeof planYdocCompaction>['changes'], handleOnChangePortalUpdate: () => void, isCancelled: () => boolean, sheetEditorRef: RefObject<WorkbookInstance | null>, chunkSize?: number): Promise<boolean>;
|
|
59
17
|
/**
|
|
60
18
|
* One-shot background compaction (celldata + borderInfo). Completion is stored
|
|
61
19
|
* on the anchor sheet's config in Yjs so it syncs across devices.
|
|
62
20
|
*/
|
|
63
|
-
export declare function useCelldataCompaction({ dsheetId, ydocRef, sheetEditorRef, currentDataRef, handleOnChangePortalUpdate, syncStatus, isDataLoaded, isReadOnly, remoteUpdateRef,
|
|
21
|
+
export declare function useCelldataCompaction({ dsheetId, ydocRef, sheetEditorRef, currentDataRef, handleOnChangePortalUpdate, syncStatus, isDataLoaded, isReadOnly, remoteUpdateRef, collabSyncing, }: UseCelldataCompactionArgs): void;
|
|
64
22
|
export {};
|
|
@@ -21,7 +21,6 @@ export declare const useEditorData: (ydocRef: React.MutableRefObject<Y.Doc | nul
|
|
|
21
21
|
setSheetData: import('react').Dispatch<import('react').SetStateAction<Sheet[]>>;
|
|
22
22
|
currentDataRef: import('react').MutableRefObject<Sheet[]>;
|
|
23
23
|
remoteUpdateRef: import('react').MutableRefObject<boolean>;
|
|
24
|
-
structuralRemountPendingRef: import('react').MutableRefObject<boolean>;
|
|
25
24
|
isDataLoaded: boolean;
|
|
26
25
|
setIsDataLoaded: import('react').Dispatch<import('react').SetStateAction<boolean>>;
|
|
27
26
|
handleChange: (_data: Sheet[]) => void;
|
|
@@ -1,17 +1,13 @@
|
|
|
1
1
|
import { IndexeddbPersistence } from 'y-indexeddb';
|
|
2
2
|
import { CollaborationProps } from '../../sync-local/types';
|
|
3
|
-
import { DSheetContentChange } from '../utils/content-change';
|
|
4
3
|
import * as Y from 'yjs';
|
|
5
|
-
export declare const useEditorSync: (dsheetId: string, enableIndexeddbSync?: boolean, isReadOnly?: boolean, portalContent?: string, collaboration?: CollaborationProps,
|
|
4
|
+
export declare const useEditorSync: (dsheetId: string, enableIndexeddbSync?: boolean, isReadOnly?: boolean, portalContent?: string, collaboration?: CollaborationProps, onCollabUpdate?: (fullState: string, updateChunk: string) => void, onIndexedDbError?: (error: Error) => void) => {
|
|
6
5
|
ydocRef: import('react').MutableRefObject<Y.Doc | null>;
|
|
7
6
|
persistenceRef: import('react').MutableRefObject<IndexeddbPersistence | null>;
|
|
8
7
|
syncStatus: "error" | "syncing" | "initializing" | "synced";
|
|
9
8
|
isContentBootstrapReady: boolean;
|
|
10
9
|
refreshIndexedDB: () => Promise<void>;
|
|
11
|
-
rebuildLocalStore: () => Promise<void>;
|
|
12
10
|
getContentSnapshot: () => import('../../persistence-utils').DSheetContentSnapshot;
|
|
13
|
-
getContentFingerprint: () => string | null;
|
|
14
|
-
getContentChange: () => DSheetContentChange;
|
|
15
11
|
mergeContent: (encodedState: string) => import('../../persistence-utils').DSheetContentSnapshot;
|
|
16
12
|
collabState: import('../..').CollabState;
|
|
17
13
|
isCollabReady: boolean;
|
package/dist/editor/types.d.ts
CHANGED
|
@@ -5,13 +5,11 @@ import { CollaborationProps } from '../sync-local/types';
|
|
|
5
5
|
import { CommentsConfig } from './types/comments';
|
|
6
6
|
import { SmartContractConfig } from './types/smart-contract';
|
|
7
7
|
import { ApiKeyStorage } from './utils/api-key-storage';
|
|
8
|
-
import { DSheetContentChange } from './utils/content-change';
|
|
9
8
|
import { ThemeKey } from '../sheet-engine/core/theme';
|
|
10
9
|
import { DSheetContentSnapshot } from '../persistence';
|
|
11
10
|
import { NavigateToSheetOptions } from './utils/navigate-to-sheet';
|
|
12
11
|
|
|
13
12
|
import * as Y from 'yjs';
|
|
14
|
-
export type { DSheetContentChange } from './utils/content-change';
|
|
15
13
|
export type { ThemeKey } from '../sheet-engine/core/theme';
|
|
16
14
|
export type DSheetPermissionMode = 'view' | 'comment' | 'edit';
|
|
17
15
|
export type { CommentThread, CommentReply, CommentActionParams, CommentsConfig, CommentAnchorMove, } from './types/comments';
|
|
@@ -28,20 +26,6 @@ export interface EditorValues {
|
|
|
28
26
|
}
|
|
29
27
|
export type DSheetEditorHandle = WorkbookInstance & {
|
|
30
28
|
refreshIndexedDB: () => Promise<void>;
|
|
31
|
-
/**
|
|
32
|
-
* Delete this sheet's IndexedDB database and rewrite it from the live
|
|
33
|
-
* document (same Y.Doc, never replaced), so local edits are kept. Resolves
|
|
34
|
-
* once the new store has synced. Resolves as a no-op when the editor is
|
|
35
|
-
* read-only, local persistence is disabled or there is no sheet id. Rejects
|
|
36
|
-
* if the rebuild fails, if the new store does not sync within 15 s, or if a
|
|
37
|
-
* refresh/unmount supersedes it. Concurrent calls share one rebuild.
|
|
38
|
-
*
|
|
39
|
-
* A bootstrap that is still waiting on an unreadable store (the case this
|
|
40
|
-
* heals) is abandoned after 3 s: the rebuild then finishes the bootstrap
|
|
41
|
-
* itself, merging the published content into the document, so the editor
|
|
42
|
-
* leaves "syncing" once the rebuild resolves.
|
|
43
|
-
*/
|
|
44
|
-
rebuildLocalStore: () => Promise<void>;
|
|
45
29
|
terminateSession: () => void;
|
|
46
30
|
updateCollaboratorName: (name: string) => void;
|
|
47
31
|
updateSessionTitle: (args: {
|
|
@@ -49,13 +33,6 @@ export type DSheetEditorHandle = WorkbookInstance & {
|
|
|
49
33
|
documentTitle: string;
|
|
50
34
|
}) => void;
|
|
51
35
|
navigateToSheet: (sheetId: string, opts?: NavigateToSheetOptions) => Promise<boolean>;
|
|
52
|
-
/**
|
|
53
|
-
* Content fingerprint: base64 state vector + ":" + deleted count. Changes
|
|
54
|
-
* on every change, deletes included; compare with === only. null until
|
|
55
|
-
* y-indexeddb is attached and synced; use fingerprintFromUpdate of the
|
|
56
|
-
* IndexedDB body then.
|
|
57
|
-
*/
|
|
58
|
-
getContentFingerprint: () => string | null;
|
|
59
36
|
};
|
|
60
37
|
export interface PanelConfig {
|
|
61
38
|
id: string;
|
|
@@ -107,27 +84,10 @@ export interface DsheetProps {
|
|
|
107
84
|
* Unlike `onChange`, this does not build a plain sheet or encode the Y.Doc.
|
|
108
85
|
*/
|
|
109
86
|
onContentUpdate?: () => void;
|
|
110
|
-
/**
|
|
111
|
-
* Cheap change signal (Stabilize A1): `hasContent`, `userEdited` and the
|
|
112
|
-
* content `fingerprint`, computed without encoding the Y.Doc. At most one
|
|
113
|
-
* call per second (trailing), flushed on pagehide, beforeunload and unmount.
|
|
114
|
-
* Read full state on demand with `editorStateRef.getContentSnapshot()`.
|
|
115
|
-
*/
|
|
116
|
-
onContentChange?: (change: DSheetContentChange) => void;
|
|
117
|
-
/**
|
|
118
|
-
* @deprecated Encodes the whole Y.Doc and rebuilds a plain workbook per
|
|
119
|
-
* call. Use `onContentChange` and read full state on demand. Called at most
|
|
120
|
-
* once per second (trailing), flushed only on unload and unmount. The latest
|
|
121
|
-
* `onChange` you pass is the one called, so an inline function is safe: a new
|
|
122
|
-
* identity does not cancel a pending call.
|
|
123
|
-
*/
|
|
124
87
|
onChange?: (updateData: SheetUpdateData, encodedUpdate?: string) => void;
|
|
125
88
|
collaboration?: CollaborationProps;
|
|
126
89
|
/** Called when local IndexedDB persistence fails. The editor and durable
|
|
127
|
-
* collaboration continue using the in-memory Y.Doc, matching dDoc.
|
|
128
|
-
* called when the first read of the local store does not finish within 15 s
|
|
129
|
-
* (the editor then continues without local persistence, and
|
|
130
|
-
* `rebuildLocalStore()` can recreate the store). */
|
|
90
|
+
* collaboration continue using the in-memory Y.Doc, matching dDoc. */
|
|
131
91
|
onIndexedDbError?: (error: Error) => void;
|
|
132
92
|
username?: string;
|
|
133
93
|
portalContent?: string;
|
|
@@ -50,13 +50,7 @@ interface AfterUpdateCellParams {
|
|
|
50
50
|
collabEnabled?: boolean;
|
|
51
51
|
collabIsOwner?: boolean;
|
|
52
52
|
remoteUpdateRef?: React.MutableRefObject<boolean>;
|
|
53
|
-
/** True while a peer's structural edit waits to remount the grid. */
|
|
54
|
-
structuralRemountPendingRef?: React.MutableRefObject<boolean>;
|
|
55
53
|
localUserEditRef?: React.MutableRefObject<boolean>;
|
|
56
|
-
/** Sheet that held the cell at commit time; falls back to the current sheet. */
|
|
57
|
-
sheetId?: string;
|
|
58
|
-
/** The caller writes the cell to Yjs itself (paste and fill batch writes). */
|
|
59
|
-
skipPersist?: boolean;
|
|
60
54
|
}
|
|
61
55
|
/** True when data-block formulas (API / smart contract) should run for this edit. */
|
|
62
56
|
export declare const shouldExecuteDataBlocks: (params: {
|
|
@@ -8,9 +8,7 @@ type CommentData = object | null | undefined;
|
|
|
8
8
|
* `null`, so a tiny `{ ps }` object is created in the live view only so the
|
|
9
9
|
* triangle can render. Row/column drag still owns real cell data.
|
|
10
10
|
*
|
|
11
|
-
*
|
|
12
|
-
* are replaced with copies, never written into, because they may be Yjs
|
|
13
|
-
* content (see ySheetArrayToPlain).
|
|
11
|
+
* Mutates in place and returns the same array.
|
|
14
12
|
*/
|
|
15
13
|
export declare const applyCommentMarkers: <T>(sheets: T | null | undefined, commentData: CommentData, allowComments: boolean | undefined) => T | null | undefined;
|
|
16
14
|
export {};
|
|
@@ -2,7 +2,7 @@ import { Ref } from 'react';
|
|
|
2
2
|
import { WorkbookInstance } from '../../sheet-engine/react';
|
|
3
3
|
import { DSheetEditorHandle } from '../types';
|
|
4
4
|
|
|
5
|
-
export type DSheetEditorMethods = Pick<DSheetEditorHandle, "refreshIndexedDB" | "
|
|
5
|
+
export type DSheetEditorMethods = Pick<DSheetEditorHandle, "refreshIndexedDB" | "terminateSession" | "updateCollaboratorName" | "updateSessionTitle" | "navigateToSheet">;
|
|
6
6
|
/**
|
|
7
7
|
* Compose Fortune's regenerated imperative handle with dSheet lifecycle methods.
|
|
8
8
|
* React callback refs invoke this again after every Workbook remount, so both
|
|
@@ -11,54 +11,9 @@ export type RemoteApplyGuardRefs = {
|
|
|
11
11
|
remoteApplyDepthRef: MutableRefObject<number>;
|
|
12
12
|
remoteUpdateRef: MutableRefObject<boolean>;
|
|
13
13
|
};
|
|
14
|
-
/**
|
|
15
|
-
* True when an engine → Yjs echo hook (calcChain, conditional formats, ...)
|
|
16
|
-
* must stay quiet: a remote apply is running, or a structural remount is
|
|
17
|
-
* pending. While one is pending the engine still has the grid from before the
|
|
18
|
-
* peer's insert or delete, so a diff of its metadata against Yjs would write
|
|
19
|
-
* the old coordinates over the peer's (and delete the peer's calcChain
|
|
20
|
-
* entries). Cell commits are not echo hooks and are not held back by this.
|
|
21
|
-
*/
|
|
22
|
-
export declare function shouldSkipEchoWrite(refs: {
|
|
23
|
-
remoteUpdateRef: MutableRefObject<boolean>;
|
|
24
|
-
structuralRemountPendingRef?: MutableRefObject<boolean>;
|
|
25
|
-
}): boolean;
|
|
26
14
|
export declare function syncRemoteUpdateFlag(refs: RemoteApplyGuardRefs): void;
|
|
27
15
|
export declare function beginRemoteApply(refs: RemoteApplyGuardRefs): void;
|
|
28
16
|
export declare function endRemoteApply(refs: RemoteApplyGuardRefs): void;
|
|
29
17
|
export declare function runUnderRemoteApply(refs: RemoteApplyGuardRefs, fn: () => void): void;
|
|
30
|
-
export type StructuralRemountRefs = RemoteApplyGuardRefs & {
|
|
31
|
-
pendingRef: MutableRefObject<boolean>;
|
|
32
|
-
timerRef: MutableRefObject<number | null>;
|
|
33
|
-
};
|
|
34
|
-
/**
|
|
35
|
-
* Debounced structural remount under the remote-apply guard.
|
|
36
|
-
*
|
|
37
|
-
* Each pending remount owns exactly one begin and one end (B1): the guard is
|
|
38
|
-
* begun when the remount becomes pending (no remount was pending before),
|
|
39
|
-
* held while the timer is pending or deferred by a cell edit (B3), and ended
|
|
40
|
-
* after paint once `run` has finished. Events that land while one is pending
|
|
41
|
-
* only re-arm its timer.
|
|
42
|
-
*
|
|
43
|
-
* While `isEditing()` is true at fire time the timer re-arms (250 ms) and the
|
|
44
|
-
* pending flag and guard depth are kept; the remount runs once the edit ends.
|
|
45
|
-
* The typed cell itself is still written: the commit-time write and the cell
|
|
46
|
-
* write in afterUpdateCell do not check the guard.
|
|
47
|
-
*/
|
|
48
|
-
export declare function scheduleStructuralRemount(refs: StructuralRemountRefs, run: () => void, delayMs?: number, isEditing?: () => boolean): void;
|
|
49
|
-
/** Re-arm interval while a cell edit blocks the remount. */
|
|
50
|
-
export declare const STRUCTURAL_REMOUNT_EDIT_RETRY_MS = 250;
|
|
51
|
-
/**
|
|
52
|
-
* Drop a pending structural remount (observer teardown) and release the
|
|
53
|
-
* guard begun for it.
|
|
54
|
-
*/
|
|
55
|
-
export declare function cancelStructuralRemount(refs: StructuralRemountRefs): void;
|
|
56
|
-
/**
|
|
57
|
-
* Run `fn` under the guard and keep it until paint (a remount follows). If
|
|
58
|
-
* `fn` throws, the guard is ended at once and the error is rethrown: a begin
|
|
59
|
-
* with no matching end leaves the depth above zero, and `handleChange` then
|
|
60
|
-
* drops every local write until reload.
|
|
61
|
-
*/
|
|
62
|
-
export declare function runRemoteApplyUntilPaint<T>(refs: RemoteApplyGuardRefs, fn: () => T): T;
|
|
63
18
|
/** End after Workbook remount hooks have flushed (2 rAF ≈ one paint). */
|
|
64
19
|
export declare function endRemoteApplyAfterPaint(refs: RemoteApplyGuardRefs): void;
|
|
@@ -2,29 +2,19 @@ import { WorkbookInstance } from '../../sheet-engine/react';
|
|
|
2
2
|
import { SheetChangePath } from './update-ydoc';
|
|
3
3
|
|
|
4
4
|
import * as Y from 'yjs';
|
|
5
|
-
export { readYdocSheetField } from './update-ydoc';
|
|
6
|
-
/** Sheet fields the per-feature Yjs hooks sync. */
|
|
7
|
-
export declare const SYNCED_SHEET_FIELDS: readonly ["calcChain", "config", "dataVerification", "luckysheet_conditionformat_save", "hyperlink", "filter", "filter_select", "liveQueryList", "dataBlockCalcFunction"];
|
|
8
5
|
type SyncContext = {
|
|
9
6
|
currentSheetId: string;
|
|
10
|
-
/** Only `field` is populated: the value stored in Yjs. */
|
|
11
7
|
oldSheet: Record<string, any>;
|
|
12
|
-
/** The engine's current value of `field` for the active sheet. */
|
|
13
|
-
newValue: any;
|
|
14
|
-
/** The engine's active sheet, for checks against its cells. */
|
|
15
|
-
engineSheet: Record<string, any> | undefined;
|
|
16
8
|
ydoc: Y.Doc;
|
|
17
9
|
};
|
|
18
10
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* which rebuilds celldata from the dense grid.
|
|
11
|
+
* Build a stable sync context from current editor sheet and Yjs snapshot.
|
|
12
|
+
* This keeps all field-level sync handlers aligned on the same baseline.
|
|
22
13
|
*/
|
|
23
|
-
export declare const getSheetYdocSyncContext: ({ sheetEditorRef, ydocRef, dsheetId,
|
|
14
|
+
export declare const getSheetYdocSyncContext: ({ sheetEditorRef, ydocRef, dsheetId, }: {
|
|
24
15
|
sheetEditorRef: React.RefObject<WorkbookInstance | null>;
|
|
25
16
|
ydocRef: React.RefObject<Y.Doc | null>;
|
|
26
17
|
dsheetId: string;
|
|
27
|
-
field: string;
|
|
28
18
|
}) => SyncContext | null;
|
|
29
19
|
export declare const buildMapFieldChanges: ({ sheetId, fieldPath, oldData, newData, }: {
|
|
30
20
|
sheetId: string;
|
|
@@ -38,3 +28,4 @@ export declare const applyYdocSheetChanges: ({ ydoc, dsheetId, changes, handleCo
|
|
|
38
28
|
changes: SheetChangePath[];
|
|
39
29
|
handleContentPortal?: any;
|
|
40
30
|
}) => void;
|
|
31
|
+
export {};
|
|
@@ -17,13 +17,5 @@ export type SheetChangePath = {
|
|
|
17
17
|
export declare const updateYdocSheetData: (ydoc: Y.Doc | null, dsheetId: string, changes: SheetChangePath[], handleContentPortal: any, onCellFormatRangesCommitted?: (commits: Array<{
|
|
18
18
|
sheetId: string;
|
|
19
19
|
ranges: CellFormatRange[];
|
|
20
|
-
}>) => void
|
|
21
|
-
/** Transaction origin; omit for user edits. */
|
|
22
|
-
origin?: unknown) => void;
|
|
20
|
+
}>) => void) => void;
|
|
23
21
|
export declare function ySheetArrayToPlain(sheetArray: Y.Array<Y.Map>): Sheet[];
|
|
24
|
-
/**
|
|
25
|
-
* One field of one sheet, with the same value ySheetArrayToPlain gives for
|
|
26
|
-
* it, without converting the rest of the workbook (A3). Shared, read-only
|
|
27
|
-
* semantics as ySheetArrayToPlain.
|
|
28
|
-
*/
|
|
29
|
-
export declare function readYdocSheetField(ydoc: Y.Doc, dsheetId: string, sheetId: string, field: string): any;
|