@fileverse-dev/ddoc 3.0.57-patch-5 → 3.0.58-folder-sharing-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/index.d.ts +3 -0
- package/dist/index.es.js +28984 -26921
- package/dist/package/components/editor-utils.d.ts +1 -0
- package/dist/package/components/export-modal.d.ts +3 -4
- package/dist/package/components/inline-comment/context/comment-context.d.ts +1 -1
- package/dist/package/components/inline-comment/context/types.d.ts +7 -5
- package/dist/package/hooks/use-ddoc-export.d.ts +6 -1
- package/dist/package/hooks/use-export-headless-editor-content.d.ts +31 -0
- package/dist/package/hooks/use-headless-editor.d.ts +3 -2
- package/dist/package/hooks/use-rtc-websocket-disconnector.d.ts +1 -0
- package/dist/package/hooks/use-tab-editor.d.ts +2 -2
- package/dist/package/hooks/use-yjs-setup.d.ts +3 -3
- package/dist/package/sync-local/actions/index.d.ts +137 -0
- package/dist/package/sync-local/actions/syncMachineActions.d.ts +1 -0
- package/dist/package/sync-local/constants/config.d.ts +7 -0
- package/dist/package/sync-local/constants/index.d.ts +5 -0
- package/dist/package/sync-local/guards/syncMachineGuards.d.ts +10 -0
- package/dist/package/sync-local/index.d.ts +6 -3
- package/dist/package/sync-local/services/syncMachineServices.d.ts +19 -0
- package/dist/package/sync-local/socketClient.d.ts +26 -16
- package/dist/package/sync-local/syncMachine.d.ts +13 -0
- package/dist/package/sync-local/types/index.d.ts +120 -85
- package/dist/package/sync-local/useSyncMachine.d.ts +38 -0
- package/dist/package/sync-local/utils/createAwarenessUpdateHandler.d.ts +3 -3
- package/dist/package/types.d.ts +9 -4
- package/dist/package/use-ddoc-editor.d.ts +2 -2
- package/dist/style.css +1 -1
- package/package.json +6 -2
- package/dist/package/sync-local/SyncManager.d.ts +0 -54
- package/dist/package/sync-local/useSyncManager.d.ts +0 -13
|
@@ -1,108 +1,130 @@
|
|
|
1
1
|
import { Data } from '../../types';
|
|
2
|
-
import {
|
|
2
|
+
import { SocketClient } from '../socketClient';
|
|
3
3
|
|
|
4
4
|
import * as Y from 'yjs';
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
|
40
|
-
|
|
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
|
-
|
|
45
|
-
|
|
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
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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
|
|
82
|
+
export interface SuccessResponseMessage {
|
|
63
83
|
status: boolean;
|
|
64
84
|
statusCode: number;
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
85
|
+
seqId: string | null;
|
|
86
|
+
is_handshake_response: boolean;
|
|
87
|
+
data: {
|
|
88
|
+
[key: string]: any;
|
|
89
|
+
};
|
|
68
90
|
}
|
|
69
|
-
export interface
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
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:
|
|
87
|
-
onDisconnect:
|
|
122
|
+
onConnect: ConnectHandler;
|
|
123
|
+
onDisconnect: DisconnectHandler;
|
|
88
124
|
onError: (err: Error) => void;
|
|
125
|
+
onWsEvent: EventHandler;
|
|
89
126
|
onHandShakeError: (err: Error) => void;
|
|
90
|
-
|
|
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 {
|
|
2
|
+
import { SyncMachineContext } from '../types';
|
|
3
3
|
|
|
4
|
-
export declare const createAwarenessUpdateHandler: (awareness: Awareness,
|
|
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
|
-
}
|
|
8
|
+
}) => void;
|
package/dist/package/types.d.ts
CHANGED
|
@@ -17,6 +17,11 @@ export type InlineCommentData = {
|
|
|
17
17
|
highlightedTextContent: string;
|
|
18
18
|
handleClick: boolean;
|
|
19
19
|
};
|
|
20
|
+
export type CommentMutationType = 'create' | 'resolve' | 'unresolve' | 'delete';
|
|
21
|
+
export interface CommentMutationMeta {
|
|
22
|
+
type: CommentMutationType;
|
|
23
|
+
updateChunk: string;
|
|
24
|
+
}
|
|
20
25
|
export interface CommentAccountProps {
|
|
21
26
|
isConnected?: boolean;
|
|
22
27
|
connectViaWallet?: () => Promise<void>;
|
|
@@ -94,10 +99,10 @@ export interface DdocProps extends CommentAccountProps {
|
|
|
94
99
|
initialComments?: IComment[];
|
|
95
100
|
setInitialComments?: React.Dispatch<SetStateAction<IComment[]>>;
|
|
96
101
|
onCommentReply?: (activeCommentId: string, reply: IComment) => void;
|
|
97
|
-
onNewComment?: (newComment: IComment) => void;
|
|
98
|
-
onResolveComment?: (activeCommentId: string) => void;
|
|
99
|
-
onUnresolveComment?: (activeCommentId: string) => void;
|
|
100
|
-
onDeleteComment?: (activeCommentId: string) => void;
|
|
102
|
+
onNewComment?: (newComment: IComment, meta?: CommentMutationMeta) => void;
|
|
103
|
+
onResolveComment?: (activeCommentId: string, meta?: CommentMutationMeta) => void;
|
|
104
|
+
onUnresolveComment?: (activeCommentId: string, meta?: CommentMutationMeta) => void;
|
|
105
|
+
onDeleteComment?: (activeCommentId: string, meta?: CommentMutationMeta) => void;
|
|
101
106
|
showTOC?: boolean;
|
|
102
107
|
setShowTOC?: React.Dispatch<SetStateAction<boolean>>;
|
|
103
108
|
extensions?: Record<string, Extension | any>;
|
|
@@ -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:
|
|
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').
|
|
24
|
+
onConnect: (connectConfig: import('./sync-local/useSyncMachine').IConnectConf) => void;
|
|
25
25
|
isReady: boolean;
|
|
26
26
|
hasCollabContentInitialised: boolean;
|
|
27
27
|
initialiseYjsIndexedDbProvider: () => Promise<void>;
|