@fileverse-dev/dsheet 4.0.5-edit-mode-12 → 4.0.6
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/api-key-modal/api-key-input.d.ts +1 -1
- package/dist/editor/components/api-key-modal/api-key-modal.d.ts +1 -3
- package/dist/editor/components/api-key-modal/rate-limit-info.d.ts +1 -1
- package/dist/editor/components/comments/comment-sidebar-empty.d.ts +1 -1
- package/dist/editor/components/editor-workbook.d.ts +1 -5
- package/dist/editor/components/export-menu-section.d.ts +1 -1
- package/dist/editor/components/import-button-ui.d.ts +1 -1
- package/dist/editor/components/permission-chip.d.ts +1 -5
- package/dist/editor/components/read-only-export-button.d.ts +1 -1
- package/dist/editor/components/sidebar/editor-right-sidebar.d.ts +1 -1
- package/dist/editor/components/sidebar/right-sidebar.d.ts +2 -2
- package/dist/editor/components/sidebar/sidebar-context.d.ts +1 -1
- package/dist/editor/components/sidebar/sidebar-portal-registry.d.ts +2 -2
- package/dist/editor/components/sidebars/conditional-format.d.ts +1 -1
- package/dist/editor/components/sidebars/data-verification.d.ts +1 -1
- package/dist/editor/components/sidebars/function/function-categories.d.ts +1 -3
- package/dist/editor/components/sidebars/function/function-metadata.d.ts +1 -1
- package/dist/editor/components/sidebars/function/functionList.d.ts +1 -2
- package/dist/editor/components/sidebars/function-content.d.ts +1 -1
- package/dist/editor/components/sidebars/named-ranges.d.ts +1 -1
- package/dist/editor/components/sidebars/template-ui.d.ts +2 -4
- package/dist/editor/components/sidebars/templates.d.ts +1 -1
- package/dist/editor/components/skeleton-loader.d.ts +4 -4
- package/dist/editor/components/smart-contract/error-toast.d.ts +1 -1
- package/dist/editor/components/smart-contract/smart-contract-list-item.d.ts +1 -2
- package/dist/editor/components/smart-contract/smart-contract-reading-intro.d.ts +1 -1
- package/dist/editor/components/smart-contract.d.ts +1 -1
- package/dist/editor/components/transition-wrapper.d.ts +1 -1
- package/dist/editor/contexts/editor-context.d.ts +2 -11
- package/dist/editor/dsheet-editor.d.ts +2 -3
- package/dist/editor/hooks/use-collab-awareness.d.ts +6 -3
- package/dist/editor/hooks/use-editor-data.d.ts +2 -2
- package/dist/editor/hooks/use-editor-sync.d.ts +2 -6
- package/dist/editor/types.d.ts +3 -29
- package/dist/editor/utils/custom-toolbar-item.d.ts +3 -3
- package/dist/editor/utils/smart-contract/constants.d.ts +1 -7
- package/dist/{executeStringFunction-B6fhDKyN.js → executeStringFunction-CxsiamWG.js} +6421 -6339
- package/dist/formula.js +1 -1
- package/dist/{index-D7psIU8B.js → index-CQUhZB3J.js} +19505 -20459
- package/dist/index.d.ts +1 -3
- package/dist/index.es.js +48 -52
- package/dist/persistence-utils-DsM_MOB1.js +89 -0
- package/dist/persistence-utils.d.ts +0 -6
- package/dist/persistence.js +1 -1
- package/dist/sheet-engine/core/modules/format.d.ts +5 -1
- package/dist/sheet-engine/react/components/DataVerification/ColorPicker.d.ts +1 -3
- package/dist/sheet-engine/react/components/DataVerification/DropdownOption.d.ts +1 -1
- package/dist/sheet-engine/react/components/DuneChartsInputModal/DuneChartsInputModal.d.ts +1 -2
- package/dist/sheet-engine/react/components/SheetOverlay/FormulaHint/dragable-div.d.ts +1 -1
- package/dist/sheet-engine/react/components/SheetOverlay/FormulaHint/index.d.ts +1 -2
- package/dist/sheet-engine/react/components/SheetOverlay/Icon.d.ts +19 -19
- package/dist/sheet-engine/react/components/SheetOverlay/LucideIcon.d.ts +19 -19
- package/dist/sheet-engine/react/components/Toolbar/FunctionList/FunctionListButton.d.ts +1 -1
- package/dist/sheet-engine/react/components/Toolbar/FunctionList/HoverMenuItem.d.ts +1 -1
- package/dist/sheet-engine/react/components/Toolbar/index.d.ts +1 -2
- package/dist/sheet-engine/react/components/Workbook/index.d.ts +0 -1
- package/dist/style.css +1 -1
- package/dist/sync-local/SyncManager.d.ts +9 -54
- package/dist/sync-local/index.d.ts +1 -1
- package/dist/sync-local/socketClient.d.ts +8 -74
- package/dist/sync-local/types/index.d.ts +15 -111
- package/dist/sync-local/useSyncManager.d.ts +0 -4
- package/dist/sync-local/utils/objectToFile.d.ts +1 -0
- package/dist/{use-xlsx-import-impl-B73ILpg3.js → use-xlsx-import-impl-DNTnmzDN.js} +53 -53
- package/dist/{xlsx-defined-names-Bl8Y-KEV.js → xlsx-defined-names-BHxDk83p.js} +2 -2
- package/dist/{xlsx-export-impl-FuZcrQ2a.js → xlsx-export-impl-r3bDoVjv.js} +4 -4
- package/dist/{xlsx-hyperlink-inline-Cdizm_s4.js → xlsx-hyperlink-inline-B5IR_SOR.js} +2 -2
- package/package.json +2 -2
- package/dist/editor/components/editor-workbook-controls.d.ts +0 -11
- package/dist/editor/components/editor-workbook-controls.test.d.ts +0 -1
- package/dist/editor/components/permission-chip-model.d.ts +0 -34
- package/dist/editor/components/permission-chip.test.d.ts +0 -1
- package/dist/editor/hooks/collaboration-lifecycle.d.ts +0 -35
- package/dist/editor/hooks/collaboration-lifecycle.test.d.ts +0 -1
- package/dist/editor/utils/detach-workbook-data.d.ts +0 -8
- package/dist/editor/utils/detach-workbook-data.test.d.ts +0 -1
- package/dist/editor/utils/editor-handle.d.ts +0 -11
- package/dist/editor/utils/editor-handle.test.d.ts +0 -1
- package/dist/persistence-utils-BBTuIssZ.js +0 -97
- package/dist/persistence-utils.test.d.ts +0 -1
- package/dist/sync-local/crypto/room-key.d.ts +0 -2
- package/dist/sync-local/crypto/room-key.test.d.ts +0 -1
- package/dist/sync-local/floor.d.ts +0 -8
- package/dist/sync-local/floor.test.d.ts +0 -1
- package/dist/sync-local/presence.d.ts +0 -11
- package/dist/sync-local/presence.test.d.ts +0 -1
- package/dist/sync-local/session-tools.d.ts +0 -31
- package/dist/sync-local/session-tools.test.d.ts +0 -1
|
@@ -9,66 +9,35 @@ export declare class SyncManager {
|
|
|
9
9
|
private socketClient;
|
|
10
10
|
private roomKey;
|
|
11
11
|
private roomKeyBytes;
|
|
12
|
-
private rotating;
|
|
13
|
-
private roomKeyBytesPrev;
|
|
14
|
-
private pendingRotationKey;
|
|
15
|
-
private healingPromise;
|
|
16
|
-
private healBackoffUntil;
|
|
17
|
-
private staleAckRetries;
|
|
18
|
-
private encryptMirror;
|
|
19
|
-
private fileKeyEpoch;
|
|
20
|
-
private mirrorIdleTimer;
|
|
21
|
-
private readonly MIRROR_IDLE_MS;
|
|
22
12
|
private isOwner;
|
|
23
|
-
private joinOnly;
|
|
24
13
|
private updateQueue;
|
|
14
|
+
private uncommittedUpdatesIdList;
|
|
25
15
|
private contentTobeAppliedQueue;
|
|
26
16
|
private isProcessing;
|
|
27
|
-
|
|
28
|
-
private
|
|
29
|
-
private updatesSinceSnapshot;
|
|
30
|
-
private isAuthoringSnapshot;
|
|
31
|
-
private readonly SNAPSHOT_THRESHOLD;
|
|
32
|
-
private tailCompactTimer;
|
|
33
|
-
private gapCatchUpTimer;
|
|
34
|
-
private gapCatchUpInFlight;
|
|
35
|
-
private gapCatchUpCooldownUntil;
|
|
36
|
-
private readonly TAIL_COMPACT_PAGES;
|
|
37
|
-
private readonly TAIL_COMPACT_ROWS;
|
|
17
|
+
/** Prevents parallel terminateSession calls (UI + effect cleanup). */
|
|
18
|
+
private _terminating;
|
|
38
19
|
private flushTimer;
|
|
39
20
|
private readonly FLUSH_INTERVAL_MS;
|
|
40
21
|
private readonly MAX_QUEUE_SIZE;
|
|
41
22
|
private _awarenessUpdateHandler;
|
|
42
23
|
private ydoc;
|
|
24
|
+
private servicesRef;
|
|
43
25
|
private callbacksRef;
|
|
44
26
|
private onLocalUpdate?;
|
|
45
27
|
constructor(config: SyncManagerConfig, onCollabStateChange: (state: CollabState) => void);
|
|
46
28
|
/** Called by useSyncManager on every render to keep refs fresh */
|
|
47
|
-
updateRefs(
|
|
29
|
+
updateRefs(services: CollabServices | undefined, callbacks: CollabCallbacks | undefined, onLocalUpdate?: (updatedDocContent: string, updateChunk: string) => void): void;
|
|
48
30
|
get isConnected(): boolean;
|
|
49
31
|
get isReady(): boolean;
|
|
50
32
|
get awareness(): Awareness | null;
|
|
51
33
|
get status(): CollabStatus;
|
|
52
34
|
get collabState(): CollabState;
|
|
53
|
-
private beginSyncAttempt;
|
|
54
|
-
private isCurrentSyncAttempt;
|
|
55
35
|
private send;
|
|
56
36
|
private runExitActions;
|
|
57
37
|
private runEntryActions;
|
|
58
38
|
connect(config: CollabConnectionConfig): Promise<void>;
|
|
59
39
|
disconnect(): Promise<void>;
|
|
60
|
-
/** Owner rename mid-session — see SocketClient.updateDocumentMeta. */
|
|
61
|
-
updateTitle(args: {
|
|
62
|
-
encryptedTitle: string;
|
|
63
|
-
documentTitle: string;
|
|
64
|
-
}): Promise<void>;
|
|
65
40
|
terminateSession(): Promise<void>;
|
|
66
|
-
/** In-place roomKey migration on CUTOVER: pause dispatch, swap the key, re-auth the same
|
|
67
|
-
* socket, re-broadcast awareness, then flush. See SocketClient.rekey for the wire side. */
|
|
68
|
-
rekey(newRoomKey: string, newAppLock?: string, newEditUcan?: string): Promise<void>;
|
|
69
|
-
private onDecryptMiss;
|
|
70
|
-
private runGapCatchUp;
|
|
71
|
-
private scheduleGapCatchUp;
|
|
72
41
|
enqueueLocalUpdate(update: Uint8Array): void;
|
|
73
42
|
private flushUpdates;
|
|
74
43
|
private awaitFlush;
|
|
@@ -76,35 +45,21 @@ export declare class SyncManager {
|
|
|
76
45
|
* Fire-and-forget: merge all queued updates, encrypt, and emit via Socket.IO
|
|
77
46
|
* without awaiting the server ACK. The server broadcasts to peers immediately
|
|
78
47
|
* (before MongoDB write), so content reaches observers in near-real-time.
|
|
48
|
+
* ACK callback handles updateId tracking and auto-commit asynchronously.
|
|
79
49
|
*/
|
|
80
50
|
private sendUpdateBatch;
|
|
81
|
-
private sendUpdateBatchAttempt;
|
|
82
|
-
private isRevocationResponse;
|
|
83
|
-
private isSessionTerminatedResponse;
|
|
84
|
-
private isSessionNotFoundResponse;
|
|
85
|
-
private classifyRevocation;
|
|
86
|
-
private handleWriteRevocation;
|
|
87
|
-
private surfaceSessionTerminated;
|
|
88
|
-
private maybeAuthorSnapshotAfterSend;
|
|
89
|
-
private scheduleMirror;
|
|
90
|
-
private authorMirror;
|
|
91
|
-
buildPendingBeaconPayload(): string | null;
|
|
92
|
-
fireBeacon(): void;
|
|
93
51
|
forceCleanup(): void;
|
|
94
52
|
private handleConnectionError;
|
|
95
53
|
private handleReconnection;
|
|
96
54
|
private connectSocket;
|
|
97
|
-
private
|
|
98
|
-
private decodeInto;
|
|
99
|
-
private catchUpFloor;
|
|
100
|
-
private authorSnapshot;
|
|
101
|
-
private hydrate;
|
|
102
|
-
private maybeCompactTail;
|
|
55
|
+
private syncLatestCommit;
|
|
103
56
|
private initializeAwareness;
|
|
104
57
|
private cleanupAwareness;
|
|
58
|
+
private commitLocalContents;
|
|
105
59
|
private broadcastLocalContents;
|
|
106
60
|
private processUpdateQueue;
|
|
107
61
|
private processNextUpdate;
|
|
62
|
+
private processCommit;
|
|
108
63
|
private handleRemoteContentUpdate;
|
|
109
64
|
private applyRemoteYjsUpdate;
|
|
110
65
|
private applyQueuedRemoteContents;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { useSyncManager } from './useSyncManager';
|
|
2
2
|
export { SyncManager } from './SyncManager';
|
|
3
|
-
export type { SyncManagerConfig, CollabConnectionConfig, CollabServices, CollabCallbacks, CollaborationProps, CollabSessionMeta, CollabStatus, CollabState, CollabError, CollabErrorCode, CollabEvent, CollabContext, } from './types';
|
|
3
|
+
export type { SyncManagerConfig, CollabConnectionConfig, CollabServices, CollabCallbacks, CollaborationProps, CollabSessionMeta, CollabStatus, CollabState, CollabError, CollabErrorCode, CollabEvent, CollabContext, CollabUser, } from './types';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ISocketInitConfig, SocketStatusEnum, SendUpdateResponse,
|
|
1
|
+
import { ISocketInitConfig, RoomMember, SocketStatusEnum, SendUpdateResponse, CommitResponse, AckResponse } from './types';
|
|
2
2
|
import { Awareness } from 'y-protocols/awareness.js';
|
|
3
3
|
|
|
4
4
|
interface ISocketClientConfig {
|
|
@@ -8,37 +8,6 @@ interface ISocketClientConfig {
|
|
|
8
8
|
ownerEdSecret?: string;
|
|
9
9
|
contractAddress?: string;
|
|
10
10
|
ownerAddress?: string;
|
|
11
|
-
editLock?: string;
|
|
12
|
-
encryptedTitle?: string;
|
|
13
|
-
identityToken?: string;
|
|
14
|
-
editUcan?: string;
|
|
15
|
-
refreshEditClaim?: () => Promise<{
|
|
16
|
-
status: 'ok';
|
|
17
|
-
token: string;
|
|
18
|
-
} | {
|
|
19
|
-
status: 'demoted';
|
|
20
|
-
} | {
|
|
21
|
-
status: 'unavailable';
|
|
22
|
-
}>;
|
|
23
|
-
onRotationPrepare?: (inner: {
|
|
24
|
-
epoch: number;
|
|
25
|
-
gp: string;
|
|
26
|
-
appLock?: string;
|
|
27
|
-
}) => Promise<string | {
|
|
28
|
-
roomKey: string;
|
|
29
|
-
editUcan?: string;
|
|
30
|
-
} | null>;
|
|
31
|
-
onEpochAvailable?: (data: {
|
|
32
|
-
roomId: string;
|
|
33
|
-
epoch: number;
|
|
34
|
-
payload: string;
|
|
35
|
-
}) => void | Promise<void>;
|
|
36
|
-
onCutover?: (data: {
|
|
37
|
-
roomId: string;
|
|
38
|
-
epoch: number;
|
|
39
|
-
}) => void | Promise<void>;
|
|
40
|
-
actorHandle?: string;
|
|
41
|
-
joinOnly?: boolean;
|
|
42
11
|
onHandshakeData?: (response: {
|
|
43
12
|
data: AckResponse;
|
|
44
13
|
roomKey: string;
|
|
@@ -51,8 +20,6 @@ interface ISocketClientConfig {
|
|
|
51
20
|
}
|
|
52
21
|
export declare class SocketClient {
|
|
53
22
|
private _socketUrl;
|
|
54
|
-
private _restBase;
|
|
55
|
-
private _lastSessionToken;
|
|
56
23
|
private _socket;
|
|
57
24
|
private _webSocketStatus;
|
|
58
25
|
private _isIntentionalDisconnect;
|
|
@@ -60,71 +27,38 @@ export declare class SocketClient {
|
|
|
60
27
|
get status(): SocketStatusEnum;
|
|
61
28
|
private _websocketServiceDid;
|
|
62
29
|
private roomId;
|
|
63
|
-
roomMembers:
|
|
64
|
-
private _lastPresenceSignature;
|
|
65
|
-
private _onPresenceChange?;
|
|
66
|
-
private _pendingAwarenessUpdates;
|
|
30
|
+
roomMembers: RoomMember[];
|
|
67
31
|
private collaborationKeyPair;
|
|
68
32
|
private ownerKeyPair?;
|
|
69
33
|
private contractAddress?;
|
|
70
34
|
private ownerUcan?;
|
|
71
35
|
private collaborationUcan?;
|
|
72
36
|
private ownerAddress?;
|
|
73
|
-
private editLock?;
|
|
74
|
-
private encryptedTitle?;
|
|
75
|
-
private identityToken?;
|
|
76
|
-
private editUcan?;
|
|
77
|
-
private refreshEditClaim?;
|
|
78
|
-
private lastGoodEditUcan?;
|
|
79
|
-
private actorHandle?;
|
|
80
|
-
private joinOnly?;
|
|
81
37
|
private roomKey;
|
|
82
38
|
private roomInfo?;
|
|
83
39
|
private awareness;
|
|
84
40
|
private connectionAttemptErrorCount;
|
|
85
41
|
private _onHandshakeData;
|
|
86
|
-
private _onEpochAvailable;
|
|
87
|
-
private _onCutover;
|
|
88
|
-
private _rotating;
|
|
89
42
|
constructor(config: ISocketClientConfig);
|
|
90
43
|
registerAwareness(awareness: Awareness): void;
|
|
91
|
-
private _stampSocketId;
|
|
92
44
|
private _emitWithAck;
|
|
93
45
|
private _fetchRoomMembers;
|
|
94
|
-
private _recomputePresence;
|
|
95
46
|
sendUpdate({ update }: {
|
|
96
47
|
update: string;
|
|
97
48
|
}): Promise<SendUpdateResponse>;
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
sendMirrorSnapshot({ data, fileKeyEpoch, }: {
|
|
105
|
-
data: string;
|
|
106
|
-
fileKeyEpoch: number;
|
|
107
|
-
}): Promise<AckResponse<any>>;
|
|
108
|
-
setDocumentMeta(): Promise<void>;
|
|
109
|
-
/** Owner rename mid-session: refresh the connect-frozen title artifacts (so
|
|
110
|
-
* every later /auth re-sends current values), persist server-side, and let
|
|
111
|
-
* the server broadcast /document/meta_update to room peers. */
|
|
112
|
-
updateDocumentMeta(args: {
|
|
113
|
-
encryptedTitle: string;
|
|
114
|
-
documentTitle: string;
|
|
115
|
-
}): Promise<void>;
|
|
49
|
+
commitUpdates({ updates, cid }: {
|
|
50
|
+
updates: string[];
|
|
51
|
+
cid: string;
|
|
52
|
+
}): Promise<CommitResponse>;
|
|
53
|
+
fetchLatestCommit(): Promise<AckResponse<any>>;
|
|
54
|
+
getUncommittedChanges(): Promise<AckResponse<any>>;
|
|
116
55
|
broadcastAwareness(awarenessUpdate: string): Promise<void>;
|
|
117
56
|
disconnect: () => void;
|
|
118
|
-
reauth: () => void;
|
|
119
|
-
rekey(newRoomKey: string, newAppLock?: string, newEditUcan?: string): Promise<void>;
|
|
120
|
-
ackEpochLoaded(documentId: string, epoch: number): Promise<void>;
|
|
121
57
|
terminateSession: () => Promise<void>;
|
|
122
|
-
flushBeacon(mergedUpdate: string): void;
|
|
123
58
|
private getCollaborationKeyPair;
|
|
124
59
|
private isUcanValid;
|
|
125
60
|
private getOwnerToken;
|
|
126
61
|
private buildSessionToken;
|
|
127
|
-
private _authenticate;
|
|
128
62
|
private _handleHandShake;
|
|
129
63
|
private _handleAwarenessUpdate;
|
|
130
64
|
connectSocket(config: ISocketInitConfig): Promise<void>;
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import * as Y from 'yjs';
|
|
2
|
-
/** dSheet presence identity. Cell coordinates stay in Yjs awareness and are
|
|
3
|
-
* intentionally excluded from the authoritative socket roster signature. */
|
|
4
2
|
export interface CollabUser {
|
|
5
|
-
clientId:
|
|
3
|
+
clientId: number;
|
|
6
4
|
name: string;
|
|
7
5
|
color: string;
|
|
8
|
-
isEns:
|
|
9
|
-
isPlaceholder?: boolean;
|
|
6
|
+
isEns: boolean;
|
|
10
7
|
cell?: {
|
|
11
8
|
r: number;
|
|
12
9
|
c: number;
|
|
@@ -19,60 +16,6 @@ export interface CollabConnectionConfig {
|
|
|
19
16
|
roomId: string;
|
|
20
17
|
wsUrl: string;
|
|
21
18
|
isOwner: boolean;
|
|
22
|
-
/** Host signal: doc is in an active live-collaboration context (shared / peers present). Keeps the socket connected. */
|
|
23
|
-
livePresence?: boolean;
|
|
24
|
-
/** Host signal: connect once on open to initialise durability even without an edit. */
|
|
25
|
-
connectOnOpen?: boolean;
|
|
26
|
-
/** Host signal (owner-only): wrapped roomKey bytes (owner-lock construction), uploaded as the server editLock recovery artifact. Opaque to the package. */
|
|
27
|
-
editLock?: string;
|
|
28
|
-
/** Host signal (owner-only): the document title encrypted with the roomKey, uploaded as the server title recovery artifact. Opaque to the package. */
|
|
29
|
-
encryptedTitle?: string;
|
|
30
|
-
/** Host signal (owner-only): Ed25519 UCAN proving the owner identity, sent on /auth so the server binds the CRYPTOGRAPHICALLY PROVEN owner DID (not a bare asserted string). Opaque to the package. */
|
|
31
|
-
identityToken?: string;
|
|
32
|
-
/** Host signal (non-owner editor): the gate-minted edit-admission UCAN, forwarded on /auth so the
|
|
33
|
-
* server admits this connection as a GP-rail editor. Opaque to the package. */
|
|
34
|
-
editUcan?: string;
|
|
35
|
-
/** Host signal (non-owner editor): re-mints a CURRENT-epoch editUcan. Called at every /auth
|
|
36
|
-
* (incl. reconnect after a force-drop). Tri-state: `ok` (fresh token; overrides the static
|
|
37
|
-
* `editUcan`), `demoted` (no longer an editor → terminal, drop to viewer), or `unavailable`
|
|
38
|
-
* (transient/network → retry on the last-good claim). Opaque to the package. */
|
|
39
|
-
refreshEditClaim?: () => Promise<{
|
|
40
|
-
status: 'ok';
|
|
41
|
-
token: string;
|
|
42
|
-
} | {
|
|
43
|
-
status: 'demoted';
|
|
44
|
-
} | {
|
|
45
|
-
status: 'unavailable';
|
|
46
|
-
}>;
|
|
47
|
-
/** Host signal: resolves the rotated roomKey for the given epoch payload (GP: gate release
|
|
48
|
-
* unwrap of `gp`; workspace: app-key unwrap of `appLock`). Returns the new base64 roomKey —
|
|
49
|
-
* or, for a gate-admitted editor, `{ roomKey, editUcan }`: the same gate release that unwraps
|
|
50
|
-
* the relay also mints the new-epoch editUcan, and the cutover re-auth must present THAT token
|
|
51
|
-
* (a re-mint through the host's fresh-open flow can race the deferred publish and hand back a
|
|
52
|
-
* stale-epoch claim). `null` if this actor can't resolve it (falls back to the decrypt-miss
|
|
53
|
-
* self-heal path). Opaque to the package. */
|
|
54
|
-
onRotationPrepare?: (inner: {
|
|
55
|
-
epoch: number;
|
|
56
|
-
gp: string;
|
|
57
|
-
appLock?: string;
|
|
58
|
-
}) => Promise<string | {
|
|
59
|
-
roomKey: string;
|
|
60
|
-
editUcan?: string;
|
|
61
|
-
} | null>;
|
|
62
|
-
/** Host signal: an anonymous per-connection actor handle (public rail). Record-only; opaque. */
|
|
63
|
-
actorHandle?: string;
|
|
64
|
-
/** Host signal (non-creator workspace member): join-only. The server never creates or
|
|
65
|
-
* binds a session for this connection and caps the role at editor; every handshake
|
|
66
|
-
* rejection resolves to a quiet terminated state ('ROOM_NOT_ESTABLISHED' when the room
|
|
67
|
-
* was never established, 'JOIN_REJECTED' otherwise) instead of an error. */
|
|
68
|
-
joinOnly?: boolean;
|
|
69
|
-
/** Host signal (editor): produces the view-plane mirror ciphertext from the live Yjs state. The app
|
|
70
|
-
* AES-GCM-encrypts `{ file: base64(yjsUpdate), source }` under the fileKey in the publish wire
|
|
71
|
-
* format. Absent ⇒ the mirror is not written. The package never sees the fileKey or the crypto. */
|
|
72
|
-
encryptMirror?: (yjsUpdate: Uint8Array) => Promise<string>;
|
|
73
|
-
/** Host signal: the fileKey's rotation epoch (the gate `currentEpoch` / fileKey version — NOT
|
|
74
|
-
* `editGrantEpoch`; default 0 for non-rotating plain-public docs). */
|
|
75
|
-
fileKeyEpoch?: number;
|
|
76
19
|
ownerEdSecret?: string;
|
|
77
20
|
contractAddress?: string;
|
|
78
21
|
ownerAddress?: string;
|
|
@@ -85,18 +28,21 @@ export interface CollabConnectionConfig {
|
|
|
85
28
|
/** Session metadata — changes to these update awareness, NOT reconnect */
|
|
86
29
|
export interface CollabSessionMeta {
|
|
87
30
|
username: string;
|
|
88
|
-
/** Spreadsheet-only awareness color used by Fortune cell cursors. */
|
|
89
31
|
color?: string;
|
|
90
32
|
isEns?: boolean;
|
|
91
33
|
}
|
|
92
|
-
|
|
93
|
-
export
|
|
34
|
+
/** Storage integrations the sync engine depends on */
|
|
35
|
+
export interface CollabServices {
|
|
36
|
+
commitToStorage?: (file: File) => Promise<string>;
|
|
37
|
+
fetchFromStorage?: (cid: string) => Promise<any>;
|
|
38
|
+
}
|
|
39
|
+
export type CollabErrorCode = 'CONNECTION_FAILED' | 'AUTH_FAILED' | 'SYNC_FAILED' | 'TIMEOUT' | 'POISONED_ROOM' | 'UNKNOWN';
|
|
94
40
|
export type CollabError = {
|
|
95
41
|
code: CollabErrorCode;
|
|
96
42
|
message: string;
|
|
97
43
|
recoverable: boolean;
|
|
98
44
|
};
|
|
99
|
-
export type CollabStatus = 'idle' | 'connecting' | 'syncing' | 'ready' | 'reconnecting' | '
|
|
45
|
+
export type CollabStatus = 'idle' | 'connecting' | 'syncing' | 'ready' | 'reconnecting' | 'error' | 'terminated';
|
|
100
46
|
export type CollabState = {
|
|
101
47
|
status: 'idle';
|
|
102
48
|
} | {
|
|
@@ -110,10 +56,6 @@ export type CollabState = {
|
|
|
110
56
|
status: 'reconnecting';
|
|
111
57
|
attempt: number;
|
|
112
58
|
maxAttempts: number;
|
|
113
|
-
}
|
|
114
|
-
/** roomKey migration in flight — distinct from `terminated` so consumers don't mistake it for a kick. */
|
|
115
|
-
| {
|
|
116
|
-
status: 'rotating';
|
|
117
59
|
} | {
|
|
118
60
|
status: 'error';
|
|
119
61
|
error: CollabError;
|
|
@@ -142,10 +84,6 @@ export type CollabEvent = {
|
|
|
142
84
|
} | {
|
|
143
85
|
type: 'SESSION_TERMINATED';
|
|
144
86
|
reason?: string;
|
|
145
|
-
}
|
|
146
|
-
/** roomKey cutover in progress; no-op on status — lets the manager gate re-entrancy itself. */
|
|
147
|
-
| {
|
|
148
|
-
type: 'CUTOVER';
|
|
149
87
|
} | {
|
|
150
88
|
type: 'RESET';
|
|
151
89
|
};
|
|
@@ -165,13 +103,6 @@ export interface CollabCallbacks {
|
|
|
165
103
|
data: AckResponse;
|
|
166
104
|
roomKey: string;
|
|
167
105
|
}) => void;
|
|
168
|
-
/** Live rename from the room owner; title is roomKey-encrypted. */
|
|
169
|
-
onTitleUpdate?: (encryptedTitle: string | null) => void;
|
|
170
|
-
/** Decrypt-miss self-heal: resolves the CURRENT-epoch roomKey (same resolution the host
|
|
171
|
-
* uses for `onRotationPrepare`, minus the relay payload — re-read the blob's
|
|
172
|
-
* `wrappedRoomKey` / appLock). Returns the new base64 roomKey, or `null` if this actor
|
|
173
|
-
* can't resolve one (the miss is then a real revocation, not a rotation lag). */
|
|
174
|
-
onRotationSelfHeal?: () => Promise<string | null>;
|
|
175
106
|
}
|
|
176
107
|
/** Discriminated union — TypeScript enforces config+services only when enabled */
|
|
177
108
|
export type CollaborationProps = {
|
|
@@ -207,9 +138,7 @@ export declare enum ServerErrorCode {
|
|
|
207
138
|
NOT_AUTHENTICATED = "NOT_AUTHENTICATED",
|
|
208
139
|
DB_ERROR = "DB_ERROR",
|
|
209
140
|
INTERNAL_ERROR = "INTERNAL_ERROR",
|
|
210
|
-
|
|
211
|
-
EDIT_REVOKED = "EDIT_REVOKED",
|
|
212
|
-
ROOM_NOT_ESTABLISHED = "ROOM_NOT_ESTABLISHED"
|
|
141
|
+
APP_MISMATCH = "APP_MISMATCH"
|
|
213
142
|
}
|
|
214
143
|
export interface AckResponse<T = Record<string, any>> {
|
|
215
144
|
status: boolean;
|
|
@@ -227,30 +156,11 @@ export interface SendUpdateResponse extends AckResponse<{
|
|
|
227
156
|
createdAt: number;
|
|
228
157
|
}> {
|
|
229
158
|
}
|
|
230
|
-
export interface
|
|
231
|
-
|
|
159
|
+
export interface CommitResponse extends AckResponse<{
|
|
160
|
+
cid: string;
|
|
161
|
+
createdAt: number;
|
|
232
162
|
documentId: string;
|
|
233
|
-
|
|
234
|
-
data: string;
|
|
235
|
-
updateType: string;
|
|
236
|
-
committed?: boolean;
|
|
237
|
-
commitCid?: string | null;
|
|
238
|
-
createdAt?: number;
|
|
239
|
-
sessionDid?: string;
|
|
240
|
-
publishedMarker?: string | null;
|
|
241
|
-
floorSeq?: number | null;
|
|
242
|
-
}
|
|
243
|
-
export interface HydrationResponse extends AckResponse<{
|
|
244
|
-
history: HydrationRow[];
|
|
245
|
-
total: number;
|
|
246
|
-
snapshot: HydrationRow | null;
|
|
247
|
-
nextSeq: number | null;
|
|
248
|
-
hasMore: boolean;
|
|
249
|
-
}> {
|
|
250
|
-
}
|
|
251
|
-
export interface SnapshotResponse extends AckResponse<{
|
|
252
|
-
id: string;
|
|
253
|
-
seq: number;
|
|
163
|
+
updates: string[];
|
|
254
164
|
}> {
|
|
255
165
|
}
|
|
256
166
|
export interface ISocketInitConfig {
|
|
@@ -258,7 +168,7 @@ export interface ISocketInitConfig {
|
|
|
258
168
|
onDisconnect: () => void;
|
|
259
169
|
onSocketDropped: () => void;
|
|
260
170
|
onError: (err: Error) => void;
|
|
261
|
-
onHandShakeError: (err: Error, statusCode?: number
|
|
171
|
+
onHandShakeError: (err: Error, statusCode?: number) => void;
|
|
262
172
|
onContentUpdate: (data: {
|
|
263
173
|
id: string;
|
|
264
174
|
data: string;
|
|
@@ -272,8 +182,6 @@ export interface ISocketInitConfig {
|
|
|
272
182
|
};
|
|
273
183
|
roomId: string;
|
|
274
184
|
}) => void;
|
|
275
|
-
onPresenceChange?: (collaborators: CollabUser[]) => void;
|
|
276
|
-
onTitleUpdate?: (encryptedTitle: string | null) => void;
|
|
277
185
|
onSessionTerminated: (data: {
|
|
278
186
|
roomId: string;
|
|
279
187
|
}) => void;
|
|
@@ -300,9 +208,5 @@ export interface IAuthArgs {
|
|
|
300
208
|
contractAddress?: string;
|
|
301
209
|
sessionDid?: string;
|
|
302
210
|
roomInfo?: string;
|
|
303
|
-
identityToken?: string;
|
|
304
|
-
editUcan?: string;
|
|
305
|
-
actorHandle?: string;
|
|
306
|
-
joinOnly?: boolean;
|
|
307
211
|
appType?: AppType;
|
|
308
212
|
}
|
|
@@ -5,10 +5,6 @@ export declare const useSyncManager: (config: SyncManagerConfig) => {
|
|
|
5
5
|
connect: (connectConfig: CollabConnectionConfig) => void;
|
|
6
6
|
disconnect: () => void;
|
|
7
7
|
terminateSession: () => void;
|
|
8
|
-
updateTitle: (args: {
|
|
9
|
-
encryptedTitle: string;
|
|
10
|
-
documentTitle: string;
|
|
11
|
-
}) => void;
|
|
12
8
|
isReady: boolean;
|
|
13
9
|
isSyncing: boolean;
|
|
14
10
|
awareness: import('y-protocols/awareness.js').Awareness | null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const objectToFile: (data: Record<string, unknown>, fileName: string) => File;
|