@fileverse-dev/ddoc 3.0.69-rtc-patch-3 → 3.0.70

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 (28) hide show
  1. package/dist/index.d.ts +4 -1
  2. package/dist/index.es.js +30693 -28795
  3. package/dist/package/components/export-modal.d.ts +4 -5
  4. package/dist/package/hooks/use-ddoc-export.d.ts +6 -1
  5. package/dist/package/hooks/use-export-headless-editor-content.d.ts +33 -0
  6. package/dist/package/hooks/use-headless-editor.d.ts +3 -2
  7. package/dist/package/hooks/use-rtc-websocket-disconnector.d.ts +1 -0
  8. package/dist/package/hooks/use-tab-editor.d.ts +5 -4
  9. package/dist/package/hooks/use-tab-manager.d.ts +1 -1
  10. package/dist/package/hooks/use-yjs-setup.d.ts +11 -6
  11. package/dist/package/sync-local/actions/index.d.ts +137 -0
  12. package/dist/package/sync-local/actions/syncMachineActions.d.ts +1 -0
  13. package/dist/package/sync-local/constants/config.d.ts +7 -0
  14. package/dist/package/sync-local/constants/index.d.ts +5 -0
  15. package/dist/package/sync-local/guards/syncMachineGuards.d.ts +10 -0
  16. package/dist/package/sync-local/index.d.ts +6 -3
  17. package/dist/package/sync-local/services/syncMachineServices.d.ts +19 -0
  18. package/dist/package/sync-local/socketClient.d.ts +29 -22
  19. package/dist/package/sync-local/syncMachine.d.ts +13 -0
  20. package/dist/package/sync-local/types/index.d.ts +123 -156
  21. package/dist/package/sync-local/useSyncMachine.d.ts +38 -0
  22. package/dist/package/sync-local/utils/createAwarenessUpdateHandler.d.ts +3 -3
  23. package/dist/package/types.d.ts +31 -3
  24. package/dist/package/use-ddoc-editor.d.ts +3 -4
  25. package/package.json +7 -3
  26. package/dist/package/sync-local/SyncManager.d.ts +0 -55
  27. package/dist/package/sync-local/collabStateMachine.d.ts +0 -23
  28. package/dist/package/sync-local/useSyncManager.d.ts +0 -11
@@ -1,176 +1,130 @@
1
- import { Data, IDocCollabUsers } from '../../types';
1
+ import { Data } from '../../types';
2
+ import { SocketClient } from '../socketClient';
2
3
 
3
4
  import * as Y from 'yjs';
4
- /** Connection identity — changes to these trigger reconnect */
5
- export interface CollabConnectionConfig {
6
- roomKey: string;
7
- roomId: string;
8
- wsUrl: string;
9
- isOwner: boolean;
10
- ownerEdSecret?: string;
11
- contractAddress?: string;
12
- ownerAddress?: string;
13
- roomInfo?: {
14
- documentTitle: string;
15
- portalAddress: string;
16
- commentKey: string;
17
- };
18
- }
19
- /** Session metadata — changes to these update awareness, NOT reconnect */
20
- export interface CollabSessionMeta {
5
+ export interface IRoomMember {
6
+ userId: string;
21
7
  username: string;
22
- isEns?: boolean;
23
- }
24
- /** Storage integrations the sync engine depends on */
25
- export interface CollabServices {
26
- commitToStorage?: (file: File) => Promise<string>;
27
- fetchFromStorage?: (cid: string) => Promise<any>;
8
+ role: 'owner' | 'editor';
28
9
  }
29
- export type CollabErrorCode = 'CONNECTION_FAILED' | 'AUTH_FAILED' | 'SYNC_FAILED' | 'TIMEOUT' | 'UNKNOWN';
30
- export type CollabError = {
31
- code: CollabErrorCode;
32
- message: string;
33
- recoverable: boolean;
34
- };
35
- export type CollabStatus = 'idle' | 'connecting' | 'syncing' | 'ready' | 'reconnecting' | 'error' | 'terminated';
36
- export type CollabState = {
37
- status: 'idle';
38
- } | {
39
- status: 'connecting';
40
- } | {
41
- status: 'syncing';
42
- hasUnmergedPeerUpdates: boolean;
43
- } | {
44
- status: 'ready';
45
- } | {
46
- status: 'reconnecting';
47
- attempt: number;
48
- maxAttempts: number;
49
- } | {
50
- status: 'error';
51
- error: CollabError;
52
- } | {
53
- status: 'terminated';
54
- reason?: string;
55
- };
56
- export type CollabEvent = {
57
- type: 'CONNECT';
58
- } | {
59
- type: 'AUTH_SUCCESS';
60
- } | {
61
- type: 'SYNC_COMPLETE';
62
- } | {
63
- type: 'SET_UNMERGED_UPDATES';
64
- hasUpdates: boolean;
65
- } | {
66
- type: 'SOCKET_DROPPED';
67
- } | {
68
- type: 'RECONNECTED';
69
- } | {
70
- type: 'RETRY_EXHAUSTED';
71
- } | {
72
- type: 'ERROR';
73
- error: CollabError;
74
- } | {
75
- type: 'SESSION_TERMINATED';
76
- reason?: string;
77
- } | {
78
- type: 'RESET';
79
- };
80
- export interface CollabContext {
81
- hasUnmergedPeerUpdates: boolean;
82
- reconnectAttempt: number;
83
- maxReconnectAttempts: number;
84
- error: CollabError | null;
85
- terminationReason?: string;
10
+ export interface SendUpdateResponse {
11
+ data: {
12
+ agent_id: string;
13
+ commitCid: string | null;
14
+ created_at: number;
15
+ data: string;
16
+ documentId: string;
17
+ id: string;
18
+ update_snapshot_ref: string | null;
19
+ updateType: string;
20
+ };
21
+ is_handshake_response: boolean;
22
+ status: boolean;
23
+ statusCode: number;
86
24
  }
87
- /** Event callbacks the consumer reacts to */
88
- export interface CollabCallbacks {
89
- onStateChange?: (state: CollabState) => void;
90
- onError?: (error: CollabError) => void;
91
- onCollaboratorsChange?: (collaborators: IDocCollabUsers[]) => void;
92
- onHandshakeData?: (data: {
93
- data: AckResponse;
94
- roomKey: string;
95
- }) => void;
25
+ export interface CommitResponse {
26
+ data: {
27
+ agent_id: string;
28
+ cid: string;
29
+ created_at: number;
30
+ data: any | null;
31
+ documentId: string;
32
+ updates: string[];
33
+ };
34
+ is_handshake_response: boolean;
35
+ status: boolean;
36
+ statusCode: number;
96
37
  }
97
- /** Discriminated union — TypeScript enforces config+services only when enabled */
98
- export type CollaborationProps = {
99
- enabled: false;
100
- } | {
101
- enabled: true;
102
- connection: CollabConnectionConfig;
103
- session: CollabSessionMeta;
104
- services: CollabServices;
105
- on?: CollabCallbacks;
106
- };
107
- export interface SyncManagerConfig {
38
+ export interface SyncMachineContext {
108
39
  ydoc: Y.Doc;
109
- services?: CollabServices;
110
- callbacks?: CollabCallbacks;
40
+ socketClient: SocketClient | null;
41
+ roomId: string;
42
+ username: string;
43
+ roomMembers: IRoomMember[];
44
+ isConnected: boolean;
45
+ awareness: any;
46
+ _awarenessUpdateHandler: (({ added, updated, removed, }: {
47
+ added: number[];
48
+ updated: number[];
49
+ removed: number[];
50
+ }) => void) | null;
51
+ onError: ((e: Error) => void) | null;
52
+ roomKey: string;
53
+ wsUrl: string;
54
+ uncommittedUpdatesIdList: string[];
55
+ isOwner: boolean;
56
+ updateQueue: Uint8Array[];
57
+ isReady: boolean;
58
+ isNewDoc: boolean;
59
+ contentTobeAppliedQueue: string[];
60
+ initialUpdate: string | null;
61
+ errorCount: number;
62
+ errorMaxRetryCount: number;
63
+ errorMessage: string;
64
+ initalDocumentDecryptionState: 'done' | 'pending';
65
+ onCollaborationConnectCallback: (response: any) => void;
66
+ onCollaborationCommit: (file: File) => Promise<string>;
67
+ onFetchCommitContent: (cid: string) => Promise<any>;
68
+ onSessionTerminated: () => void;
69
+ onUnMergedUpdates: (state: boolean) => void;
111
70
  onLocalUpdate?: (updatedDocContent: Data['editorJSONData'], updateChunk: string) => void;
112
71
  }
113
- export declare enum ServerErrorCode {
114
- AUTH_TOKEN_MISSING = "AUTH_TOKEN_MISSING",
115
- AUTH_TOKEN_INVALID = "AUTH_TOKEN_INVALID",
116
- SESSION_NOT_FOUND = "SESSION_NOT_FOUND",
117
- SESSION_TERMINATED = "SESSION_TERMINATED",
118
- SESSION_DID_MISSING = "SESSION_DID_MISSING",
119
- DOCUMENT_ID_MISSING = "DOCUMENT_ID_MISSING",
120
- UPDATE_DATA_MISSING = "UPDATE_DATA_MISSING",
121
- COMMIT_UNAUTHORIZED = "COMMIT_UNAUTHORIZED",
122
- COMMIT_MISSING_DATA = "COMMIT_MISSING_DATA",
123
- INVALID_ADDRESS = "INVALID_ADDRESS",
124
- NOT_AUTHENTICATED = "NOT_AUTHENTICATED",
125
- DB_ERROR = "DB_ERROR",
126
- INTERNAL_ERROR = "INTERNAL_ERROR"
72
+ export interface ErrorResponseMessage {
73
+ status: boolean;
74
+ statusCode: number;
75
+ seqId: string | null;
76
+ is_handshake_response: boolean;
77
+ err: string;
78
+ err_detail: {
79
+ [key: string]: any;
80
+ } | null;
127
81
  }
128
- export interface AckResponse<T = Record<string, any>> {
82
+ export interface SuccessResponseMessage {
129
83
  status: boolean;
130
84
  statusCode: number;
131
- data?: T;
132
- error?: string;
133
- errorCode?: ServerErrorCode;
85
+ seqId: string | null;
86
+ is_handshake_response: boolean;
87
+ data: {
88
+ [key: string]: any;
89
+ };
134
90
  }
135
- export interface SendUpdateResponse extends AckResponse<{
136
- id: string;
137
- documentId: string;
138
- data: string;
139
- updateType: string;
140
- commitCid: string | null;
141
- createdAt: number;
142
- }> {
91
+ export interface EventMessage {
92
+ type: string;
93
+ event_type: string;
94
+ event: {
95
+ data: any;
96
+ roomId: string;
97
+ };
143
98
  }
144
- export interface CommitResponse extends AckResponse<{
145
- cid: string;
146
- createdAt: number;
147
- documentId: string;
148
- updates: string[];
149
- }> {
99
+ export type RequestResponse = ErrorResponseMessage | SuccessResponseMessage;
100
+ export type OnMessagePayloadType = RequestResponse | EventMessage;
101
+ export type EventHandler = (message: EventMessage) => void;
102
+ export type DisconnectHandler = (e: CloseEvent | ErrorEvent) => void;
103
+ export type ConnectHandler = () => void;
104
+ export interface PartialRequest {
105
+ cmd: string;
106
+ args: {
107
+ [key: string]: any;
108
+ };
150
109
  }
110
+ export interface RequestPayload extends PartialRequest {
111
+ seqId: string;
112
+ }
113
+ export type SequenceResponseCB = (data: RequestResponse) => void;
114
+ export interface SequenceToRequestMapValue {
115
+ callback: SequenceResponseCB;
116
+ }
117
+ export type SequenceToRequestMap = {
118
+ [key: string]: SequenceToRequestMapValue;
119
+ };
120
+ export type Update = Uint8Array;
151
121
  export interface ISocketInitConfig {
152
- onHandshakeSuccess: () => void;
153
- onDisconnect: () => void;
154
- onSocketDropped: () => void;
122
+ onConnect: ConnectHandler;
123
+ onDisconnect: DisconnectHandler;
155
124
  onError: (err: Error) => void;
156
- onHandShakeError: (err: Error, statusCode?: number) => void;
157
- onContentUpdate: (data: {
158
- id: string;
159
- data: string;
160
- createdAt: number;
161
- roomId: string;
162
- }) => void;
163
- onMembershipChange: (data: {
164
- action: string;
165
- user: {
166
- role: string;
167
- };
168
- roomId: string;
169
- }) => void;
170
- onSessionTerminated: (data: {
171
- roomId: string;
172
- }) => void;
173
- onReconnectFailed: () => void;
125
+ onWsEvent: EventHandler;
126
+ onHandShakeError: (err: Error) => void;
127
+ roomId: string;
174
128
  }
175
129
  export declare enum SocketStatusEnum {
176
130
  CLOSED = "CLOSED",
@@ -184,6 +138,19 @@ export interface RoomMember {
184
138
  userId: string;
185
139
  role: 'owner' | 'editor';
186
140
  }
141
+ export type IAesKey = string;
142
+ export type SyncMachinEvent = {
143
+ type: string;
144
+ data: any;
145
+ };
146
+ export interface IpfsUploadResponse {
147
+ ipfsUrl: string;
148
+ ipfsHash: string;
149
+ ipfsStorage: string;
150
+ cachedUrl: string;
151
+ fileSize: number;
152
+ mimetype: string;
153
+ }
187
154
  export interface IAuthArgs {
188
155
  collaborationToken: string;
189
156
  documentId: string;
@@ -0,0 +1,38 @@
1
+ import { SyncMachineContext } from '.';
2
+
3
+ export interface IConnectConf {
4
+ username?: string;
5
+ roomKey: string;
6
+ roomId: string;
7
+ isOwner: boolean;
8
+ ownerEdSecret?: string;
9
+ contractAddress?: string;
10
+ ownerAddress?: string;
11
+ isEns?: boolean;
12
+ wsUrl: string;
13
+ roomInfo?: {
14
+ documentTitle: string;
15
+ portalAddress: string;
16
+ commentKey: string;
17
+ };
18
+ }
19
+ export declare const useSyncMachine: (config: Partial<SyncMachineContext>) => {
20
+ connect: (connectConfig: IConnectConf) => void;
21
+ disconnect: () => void;
22
+ isConnected: any;
23
+ isReady: boolean;
24
+ error: any;
25
+ terminateSession: () => void;
26
+ awareness: any;
27
+ hasCollabContentInitialised: boolean;
28
+ state: import('xstate').State<SyncMachineContext, {
29
+ type: string;
30
+ data: any;
31
+ }, any, {
32
+ value: any;
33
+ context: SyncMachineContext;
34
+ }, import('xstate').ResolveTypegenMeta<import('xstate').TypegenDisabled, {
35
+ type: string;
36
+ data: any;
37
+ }, import('xstate').BaseActionObject, import('xstate').ServiceMap>>;
38
+ };
@@ -1,8 +1,8 @@
1
1
  import { Awareness } from 'y-protocols/awareness';
2
- import { SocketClient } from '../socketClient';
2
+ import { SyncMachineContext } from '../types';
3
3
 
4
- export declare const createAwarenessUpdateHandler: (awareness: Awareness, socketClient: SocketClient, roomKey: string) => ({ added, updated, removed, }: {
4
+ export declare const createAwarenessUpdateHandler: (awareness: Awareness, context: SyncMachineContext) => ({ added, updated, removed, }: {
5
5
  added: number[];
6
6
  updated: number[];
7
7
  removed: number[];
8
- }, origin: any) => void;
8
+ }) => void;
@@ -4,9 +4,7 @@ import { EditorProps } from '@tiptap/pm/view';
4
4
  import { Editor } from '@tiptap/react';
5
5
  import { default as React, SetStateAction } from 'react';
6
6
  import { IComment } from './extensions/comment';
7
- import { CollaborationProps } from './sync-local/types';
8
7
 
9
- export type { CollaborationProps, CollabConnectionConfig, CollabSessionMeta, CollabServices, CollabCallbacks, CollabState, CollabError, CollabErrorCode, CollabStatus, } from './sync-local/types';
10
8
  export declare const DdocEditorProps: EditorProps;
11
9
  export interface IDocCollabUsers {
12
10
  clientId: number;
@@ -115,7 +113,7 @@ export interface DdocProps extends CommentAccountProps {
115
113
  extensions?: Record<string, Extension | any>;
116
114
  selectedTags?: TagType[];
117
115
  setSelectedTags?: React.Dispatch<SetStateAction<TagType[]>>;
118
- collaboration?: CollaborationProps;
116
+ enableCollaboration?: boolean | undefined;
119
117
  setIsCommentSectionOpen?: React.Dispatch<SetStateAction<boolean>>;
120
118
  inlineCommentData?: InlineCommentData;
121
119
  setInlineCommentData?: React.Dispatch<React.SetStateAction<InlineCommentData>>;
@@ -126,6 +124,7 @@ export interface DdocProps extends CommentAccountProps {
126
124
  setIsNavbarVisible: React.Dispatch<SetStateAction<boolean>>;
127
125
  editorCanvasClassNames?: string;
128
126
  isCommentSectionOpen?: boolean;
127
+ collaborationId?: string;
129
128
  isPreviewMode: boolean;
130
129
  ensResolutionUrl?: string;
131
130
  ipfsImageUploadFn?: (file: File) => Promise<IpfsImageUploadResponse>;
@@ -176,11 +175,24 @@ export interface DdocProps extends CommentAccountProps {
176
175
  activeModel?: CustomModel;
177
176
  maxTokens?: number;
178
177
  isAIAgentEnabled?: boolean;
178
+ collaborationKey?: CryptoKey | null;
179
+ collaborationKeyPair?: {
180
+ publicKey: string;
181
+ privateKey: string;
182
+ };
183
+ collabConfig?: ICollaborationConfig;
179
184
  /**
180
185
  * Document styling configuration
181
186
  * @description Customize the appearance of the document editor
182
187
  */
183
188
  documentStyling?: DocumentStyling;
189
+ onCollaborationConnectCallback?: (response: any) => void;
190
+ onCollaborationCommit?: (file: File) => Promise<string>;
191
+ onFetchCommitContent?: (cid: string) => Promise<any>;
192
+ onCollabSessionTermination?: () => void;
193
+ onUnMergedUpdates?: (state: boolean) => void;
194
+ onCollabError?: (error: any) => void;
195
+ isExistingCollabSession?: boolean;
184
196
  /**
185
197
  * Callback when IndexedDB initialization fails
186
198
  * @description Called when the IndexedDB persistence provider fails to initialize (e.g., private browsing, quota exceeded, corrupted DB). The editor will continue to function without local persistence.
@@ -217,3 +229,19 @@ export interface IpfsImageFetchPayload {
217
229
  mimeType: string;
218
230
  authTag: string;
219
231
  }
232
+ export interface ICollaborationConfig {
233
+ roomKey: string;
234
+ collaborationId: string;
235
+ username: string;
236
+ isOwner: boolean;
237
+ ownerEdSecret?: string;
238
+ contractAddress?: string;
239
+ ownerAddress?: string;
240
+ wsUrl: string;
241
+ isEns?: boolean;
242
+ roomInfo?: {
243
+ documentTitle: string;
244
+ portalAddress: string;
245
+ commentKey: string;
246
+ };
247
+ }
@@ -1,9 +1,9 @@
1
1
  import { DdocProps } from './types';
2
2
  import { Editor } from '@tiptap/react';
3
3
 
4
- export declare const useDdocEditor: ({ isPreviewMode, initialContent, versionHistoryState, collaboration, onChange, onCollaboratorChange, onCommentInteraction, onError, setCharacterCount, setWordCount, ipfsImageUploadFn, ddocId, enableIndexeddbSync, unFocused, theme, zoomLevel, onInvalidContentError, ignoreCorruptedData, isPresentationMode, metadataProxyUrl, extensions: externalExtensions, onCopyHeadingLink, ipfsImageFetchFn, fetchV1ImageFn, isConnected, activeModel, maxTokens, isAIAgentEnabled, onIndexedDbError, disableInlineComment, ...rest }: Partial<DdocProps>) => {
4
+ export declare const useDdocEditor: ({ isPreviewMode, initialContent, versionHistoryState, enableCollaboration, onChange, onCollaboratorChange, onCommentInteraction, onError, setCharacterCount, setWordCount, ipfsImageUploadFn, ddocId, enableIndexeddbSync, unFocused, theme, zoomLevel, onInvalidContentError, ignoreCorruptedData, isPresentationMode, metadataProxyUrl, extensions: externalExtensions, onCopyHeadingLink, ipfsImageFetchFn, fetchV1ImageFn, isConnected, activeModel, maxTokens, isAIAgentEnabled, collabConfig, onIndexedDbError, disableInlineComment, ...rest }: Partial<DdocProps>) => {
5
5
  ydoc: import('yjs').Doc;
6
- awareness: import('y-protocols/awareness.js').Awareness | null;
6
+ awareness: any;
7
7
  refreshYjsIndexedDbProvider: () => Promise<void>;
8
8
  terminateSession: () => void;
9
9
  isContentLoading: boolean;
@@ -21,11 +21,10 @@ export declare const useDdocEditor: ({ isPreviewMode, initialContent, versionHis
21
21
  }) => void;
22
22
  duplicateTab: (tabId: string) => string | undefined;
23
23
  orderTab: (destinationTabId: string, movedTabId: string) => void;
24
- onConnect: (connectConfig: import('./types').CollabConnectionConfig) => void;
24
+ onConnect: (connectConfig: import('./sync-local/useSyncMachine').IConnectConf) => void;
25
25
  isReady: boolean;
26
26
  hasCollabContentInitialised: boolean;
27
27
  initialiseYjsIndexedDbProvider: () => Promise<void>;
28
- collabState: import('./types').CollabState;
29
28
  editor: Editor | null;
30
29
  ref: import('react').RefObject<HTMLDivElement>;
31
30
  slides: string[];
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@fileverse-dev/ddoc",
3
3
  "private": false,
4
4
  "description": "DDoc",
5
- "version": "3.0.69-rtc-patch-3",
5
+ "version": "3.0.70",
6
6
  "main": "dist/index.es.js",
7
7
  "module": "dist/index.es.js",
8
8
  "exports": {
@@ -76,6 +76,8 @@
76
76
  "@tiptap/suggestion": "^3.11.0",
77
77
  "@types/uuid": "^10.0.0",
78
78
  "@ucans/ucans": "^0.12.0",
79
+ "@xstate-ninja/react": "^1.1.3",
80
+ "@xstate/react": "^3.2.2",
79
81
  "base64-js": "^1.5.1",
80
82
  "classnames": "^2.5.1",
81
83
  "color": "^5.0.3",
@@ -93,7 +95,7 @@
93
95
  "mammoth": "^1.10.0",
94
96
  "markdown-it-footnote": "^4.0.0",
95
97
  "ollama": "^0.5.14",
96
- "socket.io-client": "^4.7.5",
98
+ "partysocket": "^1.0.2",
97
99
  "platform": "^1.3.6",
98
100
  "prosemirror-model": "^1.21.0",
99
101
  "prosemirror-state": "^1.4.3",
@@ -109,6 +111,8 @@
109
111
  "vaul": "^0.9.1",
110
112
  "vite-plugin-dts": "^3.6.3",
111
113
  "ws": "^8.18.0",
114
+ "xstate": "^4.38.2",
115
+ "xstate-ninja": "^1.3.10",
112
116
  "y-indexeddb": "^9.0.12",
113
117
  "y-prosemirror": "^1.2.5",
114
118
  "y-protocols": "^1.0.6",
@@ -152,4 +156,4 @@
152
156
  "typescript": "^5.2.2",
153
157
  "vite": "^5.0.0"
154
158
  }
155
- }
159
+ }
@@ -1,55 +0,0 @@
1
- import { Awareness } from 'y-protocols/awareness.js';
2
- import { SyncManagerConfig, CollabConnectionConfig, CollabServices, CollabCallbacks, CollabStatus, CollabState } from './types';
3
-
4
- export declare class SyncManager {
5
- private onCollabStateChange;
6
- private _status;
7
- private _context;
8
- private _awareness;
9
- private socketClient;
10
- private roomKey;
11
- private roomKeyBytes;
12
- private isOwner;
13
- private updateQueue;
14
- private uncommittedUpdatesIdList;
15
- private contentTobeAppliedQueue;
16
- private isProcessing;
17
- private _awarenessUpdateHandler;
18
- private ydoc;
19
- private servicesRef;
20
- private callbacksRef;
21
- private onLocalUpdate?;
22
- constructor(config: SyncManagerConfig, onCollabStateChange: (state: CollabState) => void);
23
- /** Called by useSyncManager on every render to keep refs fresh */
24
- updateRefs(services: CollabServices | undefined, callbacks: CollabCallbacks | undefined, onLocalUpdate?: (updatedDocContent: string, updateChunk: string) => void): void;
25
- get isConnected(): boolean;
26
- get isReady(): boolean;
27
- get awareness(): Awareness | null;
28
- get status(): CollabStatus;
29
- get collabState(): CollabState;
30
- private send;
31
- private runExitActions;
32
- private runEntryActions;
33
- connect(config: CollabConnectionConfig): Promise<void>;
34
- disconnect(): Promise<void>;
35
- terminateSession(): Promise<void>;
36
- enqueueLocalUpdate(update: Uint8Array): void;
37
- forceCleanup(): void;
38
- private handleConnectionError;
39
- private handleReconnection;
40
- private connectSocket;
41
- private syncLatestCommit;
42
- private initializeAwareness;
43
- private cleanupAwareness;
44
- private commitLocalContents;
45
- private broadcastLocalContents;
46
- private processUpdateQueue;
47
- private processNextUpdate;
48
- private processCommit;
49
- private handleRemoteContentUpdate;
50
- private applyRemoteYjsUpdate;
51
- private applyQueuedRemoteContents;
52
- private withRetry;
53
- private disconnectInternal;
54
- private resetInternalState;
55
- }
@@ -1,23 +0,0 @@
1
- import { CollabStatus, CollabEvent, CollabContext, CollabState, CollabErrorCode } from './types';
2
-
3
- export declare const INITIAL_CONTEXT: CollabContext;
4
- type TransitionResult = {
5
- status: CollabStatus;
6
- context: Partial<CollabContext>;
7
- } | null;
8
- /**
9
- * Transition map: (currentStatus, eventType) → nextStatus + context mutations.
10
- * Returns null if the transition is invalid.
11
- */
12
- export declare function transition(currentStatus: CollabStatus, event: CollabEvent, context: CollabContext): TransitionResult;
13
- /**
14
- * Derives the consumer-facing CollabState from internal status + context.
15
- */
16
- export declare function deriveCollabState(status: CollabStatus, context: CollabContext): CollabState;
17
- /** Helper to create a CollabError */
18
- export declare function createCollabError(code: CollabErrorCode, message: string, recoverable?: boolean): {
19
- code: CollabErrorCode;
20
- message: string;
21
- recoverable: boolean;
22
- };
23
- export {};
@@ -1,11 +0,0 @@
1
- import { SyncManagerConfig, CollabConnectionConfig, CollabState } from './types';
2
-
3
- export declare const useSyncManager: (config: SyncManagerConfig) => {
4
- state: CollabState;
5
- connect: (connectConfig: CollabConnectionConfig) => void;
6
- disconnect: () => void;
7
- terminateSession: () => void;
8
- isReady: boolean;
9
- awareness: import('y-protocols/awareness.js').Awareness | null;
10
- hasCollabContentInitialised: boolean;
11
- };