@fileverse-dev/dsheet 4.0.4 → 4.0.5-edit-mode-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.
- package/dist/editor/components/sidebar/use-right-panels.d.ts +1 -1
- package/dist/editor/components/sidebars/named-ranges.d.ts +2 -0
- package/dist/editor/contexts/editor-context.d.ts +13 -5
- package/dist/editor/dsheet-editor.d.ts +3 -2
- package/dist/editor/hooks/collaboration-lifecycle.d.ts +30 -0
- package/dist/editor/hooks/collaboration-lifecycle.test.d.ts +1 -0
- package/dist/editor/hooks/use-celldata-compaction.d.ts +2 -3
- package/dist/editor/hooks/use-collab-awareness.d.ts +3 -6
- package/dist/editor/hooks/use-editor-data.d.ts +2 -2
- package/dist/editor/hooks/use-editor-sync.d.ts +7 -3
- package/dist/editor/types.d.ts +17 -6
- package/dist/editor/utils/compact-committed-celldata.d.ts +11 -10
- package/dist/editor/utils/defined-names-ydoc.d.ts +31 -0
- package/dist/editor/utils/editor-handle.d.ts +11 -0
- package/dist/editor/utils/editor-handle.test.d.ts +1 -0
- package/dist/editor/utils/import-compaction.d.ts +25 -0
- package/dist/editor/utils/xlsx-defined-names.d.ts +41 -0
- package/dist/editor/utils/xlsx-import-pipeline.d.ts +28 -0
- package/dist/{executeStringFunction-CsLQk-dm.js → executeStringFunction-B6fhDKyN.js} +6985 -6477
- package/dist/formula.js +1 -1
- package/dist/{index-DvwJ-8x8.js → index-CXPCkzqN.js} +19697 -18260
- package/dist/index.d.ts +3 -1
- package/dist/index.es.js +51 -47
- package/dist/persistence-utils-BXFajzvq.js +98 -0
- package/dist/persistence-utils.d.ts +8 -2
- package/dist/persistence-utils.test.d.ts +1 -0
- package/dist/persistence.js +1 -1
- package/dist/sheet-engine/core/api/common.d.ts +1 -0
- package/dist/sheet-engine/core/context.d.ts +3 -1
- package/dist/sheet-engine/core/index.d.ts +2 -2
- package/dist/sheet-engine/core/modules/formula-snapshot-eval.d.ts +11 -0
- package/dist/sheet-engine/core/modules/formula.d.ts +27 -0
- package/dist/sheet-engine/core/modules/index.d.ts +3 -2
- package/dist/sheet-engine/core/modules/namedRanges.d.ts +53 -0
- package/dist/sheet-engine/core/paste/paste-border-utils.d.ts +2 -0
- package/dist/sheet-engine/core/settings.d.ts +2 -0
- package/dist/sheet-engine/core/types.d.ts +21 -0
- package/dist/sheet-engine/react/components/NamedRanges/index.d.ts +4 -0
- package/dist/sheet-engine/react/components/Workbook/api.d.ts +1 -0
- package/dist/sheet-engine/react/components/Workbook/index.d.ts +1 -0
- package/dist/style.css +1 -1
- package/dist/sync-local/SyncManager.d.ts +54 -9
- package/dist/sync-local/crypto/room-key.d.ts +2 -0
- package/dist/sync-local/crypto/room-key.test.d.ts +1 -0
- package/dist/sync-local/floor.d.ts +8 -0
- package/dist/sync-local/floor.test.d.ts +1 -0
- package/dist/sync-local/index.d.ts +1 -1
- package/dist/sync-local/presence.d.ts +11 -0
- package/dist/sync-local/presence.test.d.ts +1 -0
- package/dist/sync-local/session-tools.d.ts +31 -0
- package/dist/sync-local/session-tools.test.d.ts +1 -0
- package/dist/sync-local/socketClient.d.ts +74 -8
- package/dist/sync-local/types/index.d.ts +111 -15
- package/dist/sync-local/useSyncManager.d.ts +4 -0
- package/dist/use-xlsx-import-impl-BtFa-ngI.js +1898 -0
- package/dist/worker/dsheet-worker-client.d.ts +14 -0
- package/dist/worker/dsheet-worker.d.ts +14 -0
- package/dist/xlsx-defined-names-DIgNskJ5.js +117 -0
- package/dist/xlsx-export-impl-CfnWkjsY.js +831 -0
- package/dist/xlsx-hyperlink-inline-BkyQuqyy.js +2512 -0
- package/package.json +2 -1
- package/dist/persistence-utils-DsM_MOB1.js +0 -89
- package/dist/sync-local/utils/objectToFile.d.ts +0 -1
- package/dist/use-xlsx-import-impl-I69dMglI.js +0 -1549
- package/dist/xlsx-export-impl-Bg7Suzh-.js +0 -3138
- package/dist/xlsx-hyperlink-inline-DzewAypN.js +0 -71
- package/dist/xlsx-image-utils-Cvg0qxRA.js +0 -126
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type BuiltInPanelType = 'templates' | 'comments' | 'functions' | 'data-verification' | 'conditional-format';
|
|
1
|
+
export type BuiltInPanelType = 'templates' | 'comments' | 'functions' | 'data-verification' | 'conditional-format' | 'named-ranges';
|
|
2
2
|
export type PanelId = BuiltInPanelType | string;
|
|
3
3
|
interface UseRightPanelsReturn {
|
|
4
4
|
activePanel: PanelId | null;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
import { LiveQueryData, Sheet, WorkbookInstance } from '../../sheet-engine/react';
|
|
3
3
|
import { IndexeddbPersistence } from 'y-indexeddb';
|
|
4
|
-
import { SheetUpdateData, DataBlockEvent } from '../types';
|
|
4
|
+
import { SheetUpdateData, DataBlockEvent, DSheetEditorHandle } from '../types';
|
|
5
5
|
import { CommentsConfig } from '../types/comments';
|
|
6
6
|
import { ApiKeyStorage } from '../utils/api-key-storage';
|
|
7
7
|
import { OpenApiKeyModalFn } from '../utils/data-block-error-handler';
|
|
@@ -11,7 +11,7 @@ import { CollaborationProps, CollabState, CollabUser } from '../../sync-local/ty
|
|
|
11
11
|
import { Awareness } from 'y-protocols/awareness';
|
|
12
12
|
import { DSheetContentSnapshot } from '../../persistence';
|
|
13
13
|
|
|
14
|
-
import * as Y from
|
|
14
|
+
import * as Y from "yjs";
|
|
15
15
|
export interface EditorContextType {
|
|
16
16
|
setIsDataLoaded: React.Dispatch<React.SetStateAction<boolean>>;
|
|
17
17
|
handleOnChangePortalUpdate: () => void;
|
|
@@ -32,6 +32,7 @@ export interface EditorContextType {
|
|
|
32
32
|
}>>;
|
|
33
33
|
refreshIndexedDB: () => Promise<void>;
|
|
34
34
|
sheetEditorRef: React.MutableRefObject<WorkbookInstance | null>;
|
|
35
|
+
setSheetEditorRef: React.RefCallback<WorkbookInstance>;
|
|
35
36
|
ydocRef: React.MutableRefObject<Y.Doc | null>;
|
|
36
37
|
persistenceRef: React.MutableRefObject<IndexeddbPersistence | null>;
|
|
37
38
|
sheetData: Sheet[];
|
|
@@ -43,8 +44,9 @@ export interface EditorContextType {
|
|
|
43
44
|
loading: boolean;
|
|
44
45
|
forceSheetRender: number;
|
|
45
46
|
setForceSheetRender: React.Dispatch<React.SetStateAction<number>>;
|
|
46
|
-
syncStatus:
|
|
47
|
+
syncStatus: "initializing" | "syncing" | "synced" | "error";
|
|
47
48
|
collabEnabled?: boolean;
|
|
49
|
+
isLiveCollabSession: boolean;
|
|
48
50
|
collabIsOwner?: boolean;
|
|
49
51
|
collabState?: CollabState;
|
|
50
52
|
isCollabReady?: boolean;
|
|
@@ -79,7 +81,8 @@ interface EditorProviderProps {
|
|
|
79
81
|
onContentUpdate?: () => void;
|
|
80
82
|
onChange?: (data: SheetUpdateData, encodedUpdate?: string) => void;
|
|
81
83
|
collaboration?: CollaborationProps;
|
|
82
|
-
externalEditorRef?: React.
|
|
84
|
+
externalEditorRef?: React.Ref<DSheetEditorHandle>;
|
|
85
|
+
legacyEditorRef?: React.Ref<DSheetEditorHandle>;
|
|
83
86
|
commentsConfig?: CommentsConfig;
|
|
84
87
|
editorStateRef?: React.MutableRefObject<{
|
|
85
88
|
refreshIndexedDB: () => Promise<void>;
|
|
@@ -87,6 +90,10 @@ interface EditorProviderProps {
|
|
|
87
90
|
mergeContent: (encodedState: string) => DSheetContentSnapshot;
|
|
88
91
|
terminateSession?: () => void;
|
|
89
92
|
updateCollaboratorName?: (name: string) => void;
|
|
93
|
+
updateSessionTitle?: (args: {
|
|
94
|
+
encryptedTitle: string;
|
|
95
|
+
documentTitle: string;
|
|
96
|
+
}) => void;
|
|
90
97
|
rehydrateAfterCollabSync?: (reason?: string) => boolean;
|
|
91
98
|
} | null>;
|
|
92
99
|
enableLiveQuery?: boolean;
|
|
@@ -94,7 +101,8 @@ interface EditorProviderProps {
|
|
|
94
101
|
apiKeyStorage?: ApiKeyStorage;
|
|
95
102
|
onDataBlockEvent?: (event: DataBlockEvent) => void;
|
|
96
103
|
smartContracts?: SmartContractConfig;
|
|
97
|
-
onContentSyncStatusChange?: (status:
|
|
104
|
+
onContentSyncStatusChange?: (status: "initializing" | "syncing" | "synced" | "error") => void;
|
|
105
|
+
onIndexedDbError?: (error: Error) => void;
|
|
98
106
|
}
|
|
99
107
|
export declare const EditorProvider: React.FC<EditorProviderProps>;
|
|
100
108
|
export declare const useEditor: () => EditorContextType;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { DSheetEditorHandle, DsheetProps } from './types';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* SpreadsheetEditor component that provides a collaborative spreadsheet interface
|
|
@@ -7,5 +8,5 @@ import { DsheetProps } from './types';
|
|
|
7
8
|
* @param props - Component properties
|
|
8
9
|
* @returns The SpreadsheetEditor component
|
|
9
10
|
*/
|
|
10
|
-
declare const SpreadsheetEditor:
|
|
11
|
+
declare const SpreadsheetEditor: React.ForwardRefExoticComponent<DsheetProps & React.RefAttributes<DSheetEditorHandle>>;
|
|
11
12
|
export default SpreadsheetEditor;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { CollabConnectionConfig, CollaborationProps } from '../../sync-local/types';
|
|
2
|
+
|
|
3
|
+
export declare const COLLAB_WARM_MS = 30000;
|
|
4
|
+
export declare const shouldKeepCollaborationSocketAlive: (connection: CollabConnectionConfig) => boolean;
|
|
5
|
+
export declare const isLiveCollaborationSession: (collaboration?: CollaborationProps) => boolean;
|
|
6
|
+
export declare const isQualifyingCollaborationEdit: (origin: unknown, indexeddbOrigin: unknown, isBootstrapReady: boolean) => boolean;
|
|
7
|
+
export declare const shouldRenderBootstrappedWorkbook: (collabEnabled: boolean, sheetCount: number) => boolean;
|
|
8
|
+
export declare const shouldInitializeDefaultWorkbook: (syncStatus: string | undefined, collabEnabled: boolean, collabStatus: string | undefined) => boolean;
|
|
9
|
+
export declare const getWorkbookHydrationReason: (status: string | undefined, previousStatus: string | undefined, hasHydratedReadyState: boolean) => "initial" | "reconnect" | null;
|
|
10
|
+
export interface CollaborationConnectionController {
|
|
11
|
+
onYdocUpdate: (update: Uint8Array, origin: unknown) => void;
|
|
12
|
+
dispose: () => void;
|
|
13
|
+
}
|
|
14
|
+
export declare const createCollaborationConnectionController: (args: {
|
|
15
|
+
connection: CollabConnectionConfig;
|
|
16
|
+
isSocketConnectedRef: {
|
|
17
|
+
current: boolean;
|
|
18
|
+
};
|
|
19
|
+
getIndexeddbOrigin: () => unknown;
|
|
20
|
+
isBootstrapReady: boolean;
|
|
21
|
+
connect: (connection: CollabConnectionConfig) => void;
|
|
22
|
+
disconnect: () => void;
|
|
23
|
+
}) => CollaborationConnectionController;
|
|
24
|
+
/**
|
|
25
|
+
* Merge the published artifact into the editor's one durable Y.Doc before
|
|
26
|
+
* IndexedDB replay and collaboration hydration. The `self` origin prevents a
|
|
27
|
+
* late package listener from treating the host seed as a live user edit;
|
|
28
|
+
* SyncManager's state-vector diff still sees it when the room is hydrated.
|
|
29
|
+
*/
|
|
30
|
+
export declare const mergePublishedContentIntoYdoc: (ydoc: import('yjs').Doc, encodedContent?: string) => boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -15,9 +15,8 @@ type UseCelldataCompactionArgs = {
|
|
|
15
15
|
collabSyncing: boolean;
|
|
16
16
|
};
|
|
17
17
|
/**
|
|
18
|
-
* One-shot background compaction
|
|
19
|
-
*
|
|
20
|
-
* after the editor is synced and idle so it does not compete with load or edits.
|
|
18
|
+
* One-shot background compaction (celldata + borderInfo). Completion is stored
|
|
19
|
+
* on the anchor sheet's config in Yjs so it syncs across devices.
|
|
21
20
|
*/
|
|
22
21
|
export declare function useCelldataCompaction({ dsheetId, ydocRef, sheetEditorRef, currentDataRef, handleOnChangePortalUpdate, syncStatus, isDataLoaded, isReadOnly, remoteUpdateRef, collabSyncing, }: UseCelldataCompactionArgs): void;
|
|
23
22
|
export {};
|
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
import { Awareness } from 'y-protocols/awareness';
|
|
2
2
|
import { WorkbookInstance } from '../../sheet-engine/react';
|
|
3
|
-
import { CollabUser } from '../../sync-local/types';
|
|
4
3
|
|
|
5
4
|
/**
|
|
6
5
|
* Reads remote cursor positions from Yjs awareness and keeps Fortune sheet's
|
|
7
6
|
* native presence list in sync. Fortune renders colored cell borders + username
|
|
8
7
|
* labels automatically via context.presences[].
|
|
9
8
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* ddoc's editor-layer awareness handler, which maps awareness.states →
|
|
13
|
-
* `{ clientId, ...user }` and fires on every awareness update + once on mount.
|
|
9
|
+
* The host collaborator roster is emitted by SocketClient from the
|
|
10
|
+
* authoritative server room-members list. This hook owns only cell cursors.
|
|
14
11
|
*/
|
|
15
|
-
export declare const useCollabAwareness: (awareness: Awareness | null | undefined, sheetEditorRef: React.MutableRefObject<WorkbookInstance | null
|
|
12
|
+
export declare const useCollabAwareness: (awareness: Awareness | null | undefined, sheetEditorRef: React.MutableRefObject<WorkbookInstance | null>) => {
|
|
16
13
|
localColor: "#30bced" | "#6eeb83" | "#fa69d1" | "#ecd444" | "#ee6352" | "#db3041" | "#0ad7f2" | "#1bff39";
|
|
17
14
|
};
|
|
@@ -8,7 +8,7 @@ import * as Y from 'yjs';
|
|
|
8
8
|
* Hook for managing sheet data
|
|
9
9
|
* Handles initialization, updates, and persistence of sheet data
|
|
10
10
|
*/
|
|
11
|
-
export declare const useEditorData: (ydocRef: React.MutableRefObject<Y.Doc | null>, dsheetId: string, sheetEditorRef: React.MutableRefObject<WorkbookInstance | null>, setForceSheetRender?: React.Dispatch<React.SetStateAction<number>>,
|
|
11
|
+
export declare const useEditorData: (ydocRef: React.MutableRefObject<Y.Doc | null>, dsheetId: string, sheetEditorRef: React.MutableRefObject<WorkbookInstance | null>, setForceSheetRender?: React.Dispatch<React.SetStateAction<number>>, isReadOnly?: boolean, onChange?: (data: Sheet[]) => void, syncStatus?: "initializing" | "syncing" | "synced" | "error", isContentBootstrapReady?: boolean, commentData?: object, dataBlockCalcFunction?: {
|
|
12
12
|
[key: string]: {
|
|
13
13
|
[key: string]: any;
|
|
14
14
|
};
|
|
@@ -16,7 +16,7 @@ export declare const useEditorData: (ydocRef: React.MutableRefObject<Y.Doc | nul
|
|
|
16
16
|
[key: string]: {
|
|
17
17
|
[key: string]: any;
|
|
18
18
|
};
|
|
19
|
-
}>>, enableLiveQuery?: boolean, liveQueryRefreshRate?: number, apiKeyStorage?: ApiKeyStorage, openApiKeyModal?: OpenApiKeyModalFn, onDataBlockEvent?: (event: DataBlockEvent) => void, allowComments?: boolean,
|
|
19
|
+
}>>, enableLiveQuery?: boolean, liveQueryRefreshRate?: number, apiKeyStorage?: ApiKeyStorage, openApiKeyModal?: OpenApiKeyModalFn, onDataBlockEvent?: (event: DataBlockEvent) => void, allowComments?: boolean, collabEnabled?: boolean) => {
|
|
20
20
|
sheetData: Sheet[];
|
|
21
21
|
setSheetData: import('react').Dispatch<import('react').SetStateAction<Sheet[]>>;
|
|
22
22
|
currentDataRef: import('react').MutableRefObject<Sheet[]>;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { IndexeddbPersistence } from 'y-indexeddb';
|
|
2
2
|
import { CollaborationProps } from '../../sync-local/types';
|
|
3
|
-
import * as Y from
|
|
4
|
-
export declare const useEditorSync: (dsheetId: string, enableIndexeddbSync?: boolean, isReadOnly?: boolean, collaboration?: CollaborationProps, onCollabUpdate?: (fullState: string, updateChunk: string) => void) => {
|
|
3
|
+
import * as Y from "yjs";
|
|
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) => {
|
|
5
5
|
ydocRef: import('react').MutableRefObject<Y.Doc | null>;
|
|
6
6
|
persistenceRef: import('react').MutableRefObject<IndexeddbPersistence | null>;
|
|
7
7
|
syncStatus: "error" | "syncing" | "initializing" | "synced";
|
|
8
|
-
|
|
8
|
+
isContentBootstrapReady: boolean;
|
|
9
9
|
refreshIndexedDB: () => Promise<void>;
|
|
10
10
|
getContentSnapshot: () => import('../../persistence-utils').DSheetContentSnapshot;
|
|
11
11
|
mergeContent: (encodedState: string) => import('../../persistence-utils').DSheetContentSnapshot;
|
|
@@ -13,6 +13,10 @@ export declare const useEditorSync: (dsheetId: string, enableIndexeddbSync?: boo
|
|
|
13
13
|
isCollabReady: boolean;
|
|
14
14
|
isCollabSyncing: boolean;
|
|
15
15
|
terminateSession: () => void;
|
|
16
|
+
updateTitle: (args: {
|
|
17
|
+
encryptedTitle: string;
|
|
18
|
+
documentTitle: string;
|
|
19
|
+
}) => void;
|
|
16
20
|
awareness: import('y-protocols/awareness.js').Awareness | null;
|
|
17
21
|
hasCollabContentInitialised: boolean;
|
|
18
22
|
};
|
package/dist/editor/types.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { ApiKeyStorage } from './utils/api-key-storage';
|
|
|
8
8
|
import { ThemeKey } from '../sheet-engine/core/theme';
|
|
9
9
|
import { DSheetContentSnapshot } from '../persistence';
|
|
10
10
|
|
|
11
|
-
import * as Y from
|
|
11
|
+
import * as Y from "yjs";
|
|
12
12
|
export type { ThemeKey } from '../sheet-engine/core/theme';
|
|
13
13
|
export type { CommentThread, CommentReply, CommentActionParams, CommentsConfig, } from './types/comments';
|
|
14
14
|
export { CommentAction } from './types/comments';
|
|
@@ -22,6 +22,15 @@ export interface EditorValues {
|
|
|
22
22
|
openPanel: (panelId: string) => void;
|
|
23
23
|
closePanel: () => void;
|
|
24
24
|
}
|
|
25
|
+
export type DSheetEditorHandle = WorkbookInstance & {
|
|
26
|
+
refreshIndexedDB: () => Promise<void>;
|
|
27
|
+
terminateSession: () => void;
|
|
28
|
+
updateCollaboratorName: (name: string) => void;
|
|
29
|
+
updateSessionTitle: (args: {
|
|
30
|
+
encryptedTitle: string;
|
|
31
|
+
documentTitle: string;
|
|
32
|
+
}) => void;
|
|
33
|
+
};
|
|
25
34
|
export interface PanelConfig {
|
|
26
35
|
id: string;
|
|
27
36
|
header: {
|
|
@@ -40,7 +49,7 @@ export type OnboardingHandlerType = (params: {
|
|
|
40
49
|
row: number;
|
|
41
50
|
column: number;
|
|
42
51
|
};
|
|
43
|
-
export type DataBlockEventType =
|
|
52
|
+
export type DataBlockEventType = "success" | "error" | "api-key-required" | "api-key-saved" | "retry";
|
|
44
53
|
export interface DataBlockEvent {
|
|
45
54
|
type: DataBlockEventType;
|
|
46
55
|
functionName?: string;
|
|
@@ -67,6 +76,9 @@ export interface DsheetProps {
|
|
|
67
76
|
onContentUpdate?: () => void;
|
|
68
77
|
onChange?: (updateData: SheetUpdateData, encodedUpdate?: string) => void;
|
|
69
78
|
collaboration?: CollaborationProps;
|
|
79
|
+
/** Called when local IndexedDB persistence fails. The editor and durable
|
|
80
|
+
* collaboration continue using the in-memory Y.Doc, matching dDoc. */
|
|
81
|
+
onIndexedDbError?: (error: Error) => void;
|
|
70
82
|
username?: string;
|
|
71
83
|
portalContent?: string;
|
|
72
84
|
isReadOnly?: boolean;
|
|
@@ -80,9 +92,8 @@ export interface DsheetProps {
|
|
|
80
92
|
setForceSheetRender?: React.Dispatch<React.SetStateAction<number>>;
|
|
81
93
|
commentsConfig?: CommentsConfig;
|
|
82
94
|
toggleTemplateSidebar?: () => void;
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}>;
|
|
95
|
+
/** Legacy ref prop. Standard React refs are also supported. */
|
|
96
|
+
sheetEditorRef?: React.Ref<DSheetEditorHandle>;
|
|
86
97
|
/** Override where datablock API keys are stored (default: localStorage). */
|
|
87
98
|
apiKeyStorage?: ApiKeyStorage;
|
|
88
99
|
/** Optional lifecycle events for analytics / side-effects. */
|
|
@@ -92,7 +103,7 @@ export interface DsheetProps {
|
|
|
92
103
|
/** Fires whenever local content-sync status changes. Host apps should gate
|
|
93
104
|
* collab start/resume on 'synced' — starting before local content is fully
|
|
94
105
|
* synced is what let the RTC layer bind to a stale doc in the past. */
|
|
95
|
-
onContentSyncStatusChange?: (status:
|
|
106
|
+
onContentSyncStatusChange?: (status: "initializing" | "syncing" | "synced" | "error") => void;
|
|
96
107
|
editorStateRef?: React.MutableRefObject<{
|
|
97
108
|
refreshIndexedDB: () => Promise<void>;
|
|
98
109
|
getContentSnapshot: () => DSheetContentSnapshot;
|
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import { CellMatrix, CellWithRowAndCol, Sheet } from '../../sheet-engine/core/types';
|
|
2
2
|
import { SheetChangePath } from './update-ydoc';
|
|
3
3
|
import * as Y from 'yjs';
|
|
4
|
-
|
|
5
|
-
export
|
|
4
|
+
/** Celldata + borderInfo compaction; bump when rules change. */
|
|
5
|
+
export declare const SHEET_COMPACTION_REV = 2;
|
|
6
|
+
export declare const SHEET_COMPACTION_CONFIG_KEY = "sheetCompactionRev";
|
|
7
|
+
export type SheetCompactionResult = {
|
|
6
8
|
removedFromYdoc: number;
|
|
7
9
|
clearedInMemory: number;
|
|
8
10
|
changes: SheetChangePath[];
|
|
9
11
|
};
|
|
10
|
-
export declare function
|
|
11
|
-
export declare function
|
|
12
|
-
export declare function
|
|
12
|
+
export declare function readSheetCompactionRev(config: unknown): number;
|
|
13
|
+
export declare function getAnchorSheet(sheets: Sheet[] | null | undefined): Sheet | null;
|
|
14
|
+
export declare function hasSheetCompactionCompleted(ydoc: Y.Doc, dsheetId: string): boolean;
|
|
15
|
+
export declare function buildCompactionRevChange(ydoc: Y.Doc, dsheetId: string): SheetChangePath | null;
|
|
16
|
+
export declare function markCompactionRevInMemory(sheets: Sheet[] | null | undefined): void;
|
|
13
17
|
/** Collect Yjs celldata keys that should not be persisted (format-only / empty ghosts). */
|
|
14
18
|
export declare function collectStaleCelldataKeys(celldataMap: Y.Map<unknown> | Record<string, unknown> | null | undefined): string[];
|
|
15
19
|
export declare function buildCelldataDeleteChanges(sheetId: string, keys: string[]): SheetChangePath[];
|
|
@@ -21,8 +25,5 @@ export declare function compactSheetCelldataArray(celldata: CellWithRowAndCol[]
|
|
|
21
25
|
removed: number;
|
|
22
26
|
};
|
|
23
27
|
export declare function compactInMemorySheets(sheets: Sheet[] | null | undefined): number;
|
|
24
|
-
/**
|
|
25
|
-
|
|
26
|
-
* `changes` via `updateYdocSheetData`.
|
|
27
|
-
*/
|
|
28
|
-
export declare function planYdocCelldataCompaction(ydoc: Y.Doc, dsheetId: string): CelldataCompactionResult;
|
|
28
|
+
/** Scan Y.Doc for committed ghosts. Does not mutate — caller applies `changes`. */
|
|
29
|
+
export declare function planYdocCompaction(ydoc: Y.Doc, dsheetId: string): SheetCompactionResult;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { WorkbookInstance } from '../../sheet-engine/react';
|
|
2
|
+
import { DefinedName } from '../../sheet-engine/core/types';
|
|
3
|
+
import { RefObject } from 'react';
|
|
4
|
+
|
|
5
|
+
import * as Y from 'yjs';
|
|
6
|
+
/** Sibling share key on the same Y.Doc as the sheet array. */
|
|
7
|
+
export declare function getDefinedNamesMapKey(dsheetId: string): string;
|
|
8
|
+
export declare function getDefinedNamesYMap(ydoc: Y.Doc, dsheetId: string): Y.Map<DefinedName>;
|
|
9
|
+
/** Read workbook-level named ranges from Yjs (stable name order). */
|
|
10
|
+
export declare function readDefinedNamesFromYdoc(ydoc: Y.Doc, dsheetId: string): DefinedName[];
|
|
11
|
+
/**
|
|
12
|
+
* Prefer the sheet `Y.Array` share key when a doc has sibling maps
|
|
13
|
+
* (e.g. `${dsheetId}:definedNames`).
|
|
14
|
+
*/
|
|
15
|
+
export declare function resolveSheetArrayShareKey(doc: Y.Doc, preferredKey?: string): string | null;
|
|
16
|
+
/**
|
|
17
|
+
* Diff Context definedNames against the Y.Map and apply set/delete by id.
|
|
18
|
+
*/
|
|
19
|
+
export declare function syncDefinedNamesToYdoc({ ydoc, dsheetId, definedNames, handleContentPortal, }: {
|
|
20
|
+
ydoc: Y.Doc;
|
|
21
|
+
dsheetId: string;
|
|
22
|
+
definedNames: DefinedName[];
|
|
23
|
+
handleContentPortal?: () => void;
|
|
24
|
+
}): void;
|
|
25
|
+
/** Push current workbook definedNames into Yjs (editor hook target). */
|
|
26
|
+
export declare const definedNamesYdocUpdate: ({ sheetEditorRef, ydocRef, dsheetId, handleContentPortal, }: {
|
|
27
|
+
sheetEditorRef: RefObject<WorkbookInstance | null>;
|
|
28
|
+
ydocRef: RefObject<Y.Doc | null>;
|
|
29
|
+
dsheetId: string;
|
|
30
|
+
handleContentPortal?: () => void;
|
|
31
|
+
}) => void;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Ref } from 'react';
|
|
2
|
+
import { WorkbookInstance } from '../../sheet-engine/react';
|
|
3
|
+
import { DSheetEditorHandle } from '../types';
|
|
4
|
+
|
|
5
|
+
export type DSheetEditorMethods = Pick<DSheetEditorHandle, "refreshIndexedDB" | "terminateSession" | "updateCollaboratorName" | "updateSessionTitle">;
|
|
6
|
+
/**
|
|
7
|
+
* Compose Fortune's regenerated imperative handle with dSheet lifecycle methods.
|
|
8
|
+
* React callback refs invoke this again after every Workbook remount, so both
|
|
9
|
+
* standard forwarded refs and the legacy sheetEditorRef prop stay current.
|
|
10
|
+
*/
|
|
11
|
+
export declare const attachDSheetEditorHandle: (workbook: WorkbookInstance | null, methods: DSheetEditorMethods, refs: Array<Ref<DSheetEditorHandle> | undefined>) => DSheetEditorHandle | null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Sheet } from '../../sheet-engine/react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* XLSX imports (Google Sheets exports especially) materialize every
|
|
5
|
+
* styled-but-empty cell. Move those into config.cellFormatRanges — the same
|
|
6
|
+
* sparse representation the editor uses — so they never inflate celldata/Yjs.
|
|
7
|
+
* Cells with content, merges, hyperlinks, notes or masks are kept verbatim.
|
|
8
|
+
*/
|
|
9
|
+
export declare function compactImportedSheetFormatting(sheet: Sheet): void;
|
|
10
|
+
/**
|
|
11
|
+
* Imported validations repeat the full option list + per-option color string
|
|
12
|
+
* on every covered cell (whole-column dropdowns → thousands of copies). Store
|
|
13
|
+
* each unique entry once in dataVerificationDefs and keep numeric refs in the
|
|
14
|
+
* per-cell map; expandSheetDataVerification restores objects for the engine.
|
|
15
|
+
*/
|
|
16
|
+
export declare function internImportedDataVerification(sheet: Sheet): void;
|
|
17
|
+
/**
|
|
18
|
+
* Resolve interned dataVerification refs back to shared entry objects before
|
|
19
|
+
* the sheet reaches the engine or the XLSX exporter. No-op (and no mutation)
|
|
20
|
+
* when the map already holds objects, so live workbook sheets pass through.
|
|
21
|
+
*/
|
|
22
|
+
export declare function expandSheetDataVerification<T extends {
|
|
23
|
+
dataVerification?: unknown;
|
|
24
|
+
dataVerificationDefs?: unknown;
|
|
25
|
+
}>(sheet: T): T;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { DefinedName } from '../../sheet-engine/core/types';
|
|
2
|
+
|
|
3
|
+
export type ExcelDefinedNameEntry = {
|
|
4
|
+
name: string;
|
|
5
|
+
ranges: string[];
|
|
6
|
+
localSheetId?: number;
|
|
7
|
+
};
|
|
8
|
+
export declare function isExcelSystemDefinedName(name: string): boolean;
|
|
9
|
+
/** Build Excel loc string: `Sheet1!$A$1:$C$2` (or single cell). */
|
|
10
|
+
export declare function encodeDefinedNameExcelRef(sheetName: string, range: DefinedName['range']): string;
|
|
11
|
+
/**
|
|
12
|
+
* Parse `Sheet1!$A$1:$B$2` / `'My Sheet'!$A$1` into sheet name + 0-based range.
|
|
13
|
+
*/
|
|
14
|
+
export declare function parseExcelDefinedNameRef(ref: string): {
|
|
15
|
+
sheetName: string;
|
|
16
|
+
range: {
|
|
17
|
+
row: [number, number];
|
|
18
|
+
column: [number, number];
|
|
19
|
+
};
|
|
20
|
+
} | null;
|
|
21
|
+
/**
|
|
22
|
+
* Convert Excel defined-name entries into our DefinedName list.
|
|
23
|
+
* `sheets` must already have stable ids and names (Excel order).
|
|
24
|
+
*/
|
|
25
|
+
export declare function excelEntriesToDefinedNames(entries: ExcelDefinedNameEntry[], sheets: Array<{
|
|
26
|
+
id?: string;
|
|
27
|
+
name?: string;
|
|
28
|
+
}>): DefinedName[];
|
|
29
|
+
/** Write defined names onto an ExcelJS workbook (Pass 2). */
|
|
30
|
+
export declare function applyDefinedNamesToExcelWorkbook(excelWorkbook: {
|
|
31
|
+
definedNames: {
|
|
32
|
+
add: (loc: string, name: string) => void;
|
|
33
|
+
};
|
|
34
|
+
}, definedNames: DefinedName[] | undefined, sheets: Array<{
|
|
35
|
+
id?: string;
|
|
36
|
+
name?: string;
|
|
37
|
+
}>): void;
|
|
38
|
+
/**
|
|
39
|
+
* Parse `<definedNames>` from xl/workbook.xml (keeps localSheetId).
|
|
40
|
+
*/
|
|
41
|
+
export declare function parseDefinedNamesFromXlsxBuffer(arrayBuffer: ArrayBuffer): Promise<ExcelDefinedNameEntry[]>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Sheet } from '../../sheet-engine/react';
|
|
2
|
+
import { ExcelDefinedNameEntry } from './xlsx-defined-names';
|
|
3
|
+
|
|
4
|
+
export declare function generateImportSheetId(): string;
|
|
5
|
+
export type XlsxImportWarning = {
|
|
6
|
+
code: 'tables-unsupported';
|
|
7
|
+
} | {
|
|
8
|
+
code: 'filters-unsupported';
|
|
9
|
+
};
|
|
10
|
+
export type XlsxParseSettings = {
|
|
11
|
+
/** Workbook default column width in px (from the live workbook settings, if any). */
|
|
12
|
+
workbookDefaultColWidth?: number;
|
|
13
|
+
/** Workbook default row height in px (from the live workbook settings, if any). */
|
|
14
|
+
workbookDefaultRowHeight?: number;
|
|
15
|
+
};
|
|
16
|
+
export type XlsxParsedWorkbook = {
|
|
17
|
+
/** Decorated + compacted sheets, ready for the ydoc write. */
|
|
18
|
+
sheets: Sheet[];
|
|
19
|
+
/** Workbook name from luckyexcel info (extension not yet stripped). */
|
|
20
|
+
workbookName: string;
|
|
21
|
+
/** UI warnings to replay on the main thread (toasts/onWarning). */
|
|
22
|
+
warnings: XlsxImportWarning[];
|
|
23
|
+
/** Sheet ids this pipeline generated — the caller may remap them with a custom generator. */
|
|
24
|
+
generatedSheetIds: string[];
|
|
25
|
+
/** Named ranges from xl/workbook.xml — synced to Yjs on the main thread. */
|
|
26
|
+
definedNameEntries: ExcelDefinedNameEntry[];
|
|
27
|
+
};
|
|
28
|
+
export declare function parseXlsxWorkbook(file: File, settings?: XlsxParseSettings): Promise<XlsxParsedWorkbook>;
|