@fileverse-dev/ddoc 3.0.64-rtc-patch-1 → 3.0.65-export-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.
Files changed (28) hide show
  1. package/dist/index.d.ts +3 -0
  2. package/dist/index.es.js +27782 -25648
  3. package/dist/package/components/export-modal.d.ts +4 -5
  4. package/dist/package/extensions/font-family-persistence.d.ts +11 -0
  5. package/dist/package/extensions/typography-persistence.d.ts +22 -0
  6. package/dist/package/hooks/use-ddoc-export.d.ts +6 -1
  7. package/dist/package/hooks/use-export-headless-editor-content.d.ts +31 -0
  8. package/dist/package/hooks/use-headless-editor.d.ts +3 -2
  9. package/dist/package/hooks/use-rtc-websocket-disconnector.d.ts +1 -0
  10. package/dist/package/hooks/use-tab-editor.d.ts +2 -2
  11. package/dist/package/hooks/use-yjs-setup.d.ts +3 -3
  12. package/dist/package/sync-local/actions/index.d.ts +137 -0
  13. package/dist/package/sync-local/actions/syncMachineActions.d.ts +1 -0
  14. package/dist/package/sync-local/constants/config.d.ts +7 -0
  15. package/dist/package/sync-local/constants/index.d.ts +5 -0
  16. package/dist/package/sync-local/guards/syncMachineGuards.d.ts +10 -0
  17. package/dist/package/sync-local/index.d.ts +6 -3
  18. package/dist/package/sync-local/services/syncMachineServices.d.ts +19 -0
  19. package/dist/package/sync-local/socketClient.d.ts +26 -17
  20. package/dist/package/sync-local/syncMachine.d.ts +13 -0
  21. package/dist/package/sync-local/types/index.d.ts +120 -85
  22. package/dist/package/sync-local/useSyncMachine.d.ts +38 -0
  23. package/dist/package/sync-local/utils/createAwarenessUpdateHandler.d.ts +3 -3
  24. package/dist/package/use-ddoc-editor.d.ts +2 -2
  25. package/dist/style.css +1 -1
  26. package/package.json +7 -3
  27. package/dist/package/sync-local/SyncManager.d.ts +0 -52
  28. package/dist/package/sync-local/useSyncManager.d.ts +0 -13
@@ -1,108 +1,130 @@
1
1
  import { Data } from '../../types';
2
- import { Awareness } from 'y-protocols/awareness';
2
+ import { SocketClient } from '../socketClient';
3
3
 
4
4
  import * as Y from 'yjs';
5
- export declare enum SyncStatus {
6
- DISCONNECTED = "disconnected",
7
- CONNECTING = "connecting",
8
- SYNCING = "syncing",
9
- CONNECTED = "connected",
10
- PROCESSING = "processing",
11
- DISCONNECTING = "disconnecting"
5
+ export interface IRoomMember {
6
+ userId: string;
7
+ username: string;
8
+ role: 'owner' | 'editor';
12
9
  }
13
- export interface SyncManagerConfig {
14
- ydoc: Y.Doc;
15
- onError?: (e: Error) => void;
16
- onCollaborationConnectCallback?: (response: any) => void;
17
- onCollaborationCommit?: (file: File) => Promise<string>;
18
- onFetchCommitContent?: (cid: string) => Promise<any>;
19
- onSessionTerminated?: () => void;
20
- onUnMergedUpdates?: (state: boolean) => void;
21
- onLocalUpdate?: (updatedDocContent: Data['editorJSONData'], updateChunk: string) => void;
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;
22
24
  }
23
- export interface ConnectConfig {
24
- username?: string;
25
- roomKey: string;
26
- roomId: string;
27
- isOwner: boolean;
28
- ownerEdSecret?: string;
29
- contractAddress?: string;
30
- ownerAddress?: string;
31
- isEns?: boolean;
32
- wsUrl: string;
33
- roomInfo?: {
34
- documentTitle: string;
35
- portalAddress: string;
36
- commentKey: string;
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[];
37
33
  };
34
+ is_handshake_response: boolean;
35
+ status: boolean;
36
+ statusCode: number;
38
37
  }
39
- export interface SyncManagerSnapshot {
40
- status: SyncStatus;
38
+ export interface SyncMachineContext {
39
+ ydoc: Y.Doc;
40
+ socketClient: SocketClient | null;
41
+ roomId: string;
42
+ username: string;
43
+ roomMembers: IRoomMember[];
41
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[];
42
57
  isReady: boolean;
58
+ isNewDoc: boolean;
59
+ contentTobeAppliedQueue: string[];
60
+ initialUpdate: string | null;
61
+ errorCount: number;
62
+ errorMaxRetryCount: number;
43
63
  errorMessage: string;
44
- awareness: Awareness | null;
45
- initialDocumentDecryptionState: 'done' | 'pending';
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;
70
+ onLocalUpdate?: (updatedDocContent: Data['editorJSONData'], updateChunk: string) => void;
46
71
  }
47
- export declare enum ServerErrorCode {
48
- AUTH_TOKEN_MISSING = "AUTH_TOKEN_MISSING",
49
- AUTH_TOKEN_INVALID = "AUTH_TOKEN_INVALID",
50
- SESSION_NOT_FOUND = "SESSION_NOT_FOUND",
51
- SESSION_TERMINATED = "SESSION_TERMINATED",
52
- SESSION_DID_MISSING = "SESSION_DID_MISSING",
53
- DOCUMENT_ID_MISSING = "DOCUMENT_ID_MISSING",
54
- UPDATE_DATA_MISSING = "UPDATE_DATA_MISSING",
55
- COMMIT_UNAUTHORIZED = "COMMIT_UNAUTHORIZED",
56
- COMMIT_MISSING_DATA = "COMMIT_MISSING_DATA",
57
- INVALID_ADDRESS = "INVALID_ADDRESS",
58
- NOT_AUTHENTICATED = "NOT_AUTHENTICATED",
59
- DB_ERROR = "DB_ERROR",
60
- 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;
61
81
  }
62
- export interface AckResponse<T = Record<string, any>> {
82
+ export interface SuccessResponseMessage {
63
83
  status: boolean;
64
84
  statusCode: number;
65
- data?: T;
66
- error?: string;
67
- errorCode?: ServerErrorCode;
85
+ seqId: string | null;
86
+ is_handshake_response: boolean;
87
+ data: {
88
+ [key: string]: any;
89
+ };
68
90
  }
69
- export interface SendUpdateResponse extends AckResponse<{
70
- id: string;
71
- documentId: string;
72
- data: string;
73
- updateType: string;
74
- commitCid: string | null;
75
- createdAt: number;
76
- }> {
91
+ export interface EventMessage {
92
+ type: string;
93
+ event_type: string;
94
+ event: {
95
+ data: any;
96
+ roomId: string;
97
+ };
77
98
  }
78
- export interface CommitResponse extends AckResponse<{
79
- cid: string;
80
- createdAt: number;
81
- documentId: string;
82
- updates: string[];
83
- }> {
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
+ };
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;
84
116
  }
117
+ export type SequenceToRequestMap = {
118
+ [key: string]: SequenceToRequestMapValue;
119
+ };
120
+ export type Update = Uint8Array;
85
121
  export interface ISocketInitConfig {
86
- onConnect: () => void;
87
- onDisconnect: () => void;
122
+ onConnect: ConnectHandler;
123
+ onDisconnect: DisconnectHandler;
88
124
  onError: (err: Error) => void;
125
+ onWsEvent: EventHandler;
89
126
  onHandShakeError: (err: Error) => void;
90
- onContentUpdate: (data: {
91
- id: string;
92
- data: string;
93
- createdAt: number;
94
- roomId: string;
95
- }) => void;
96
- onMembershipChange: (data: {
97
- action: string;
98
- user: {
99
- role: string;
100
- };
101
- roomId: string;
102
- }) => void;
103
- onSessionTerminated: (data: {
104
- roomId: string;
105
- }) => void;
127
+ roomId: string;
106
128
  }
107
129
  export declare enum SocketStatusEnum {
108
130
  CLOSED = "CLOSED",
@@ -116,6 +138,19 @@ export interface RoomMember {
116
138
  userId: string;
117
139
  role: 'owner' | 'editor';
118
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
+ }
119
154
  export interface IAuthArgs {
120
155
  collaborationToken: string;
121
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;
@@ -3,7 +3,7 @@ import { Editor } from '@tiptap/react';
3
3
 
4
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,7 +21,7 @@ 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('./sync-local').ConnectConfig) => void;
24
+ onConnect: (connectConfig: import('./sync-local/useSyncMachine').IConnectConf) => void;
25
25
  isReady: boolean;
26
26
  hasCollabContentInitialised: boolean;
27
27
  initialiseYjsIndexedDbProvider: () => Promise<void>;