@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,12 +1,12 @@
|
|
|
1
|
-
interface ExportFormatOption {
|
|
1
|
+
export interface ExportFormatOption {
|
|
2
2
|
id: string;
|
|
3
3
|
label: string;
|
|
4
4
|
}
|
|
5
|
-
interface ExportTabOption {
|
|
5
|
+
export interface ExportTabOption {
|
|
6
6
|
id: string;
|
|
7
7
|
label: string;
|
|
8
8
|
}
|
|
9
|
-
interface ExportAsModalProps {
|
|
9
|
+
export interface ExportAsModalProps {
|
|
10
10
|
open: boolean;
|
|
11
11
|
onOpenChange: (open: boolean) => void;
|
|
12
12
|
onExport?: (data: {
|
|
@@ -19,4 +19,3 @@ interface ExportAsModalProps {
|
|
|
19
19
|
initialTab?: string;
|
|
20
20
|
}
|
|
21
21
|
export declare const ExportAsModal: ({ open, onOpenChange, onExport, formatOptions, tabOptions, initialFormat, initialTab, }: ExportAsModalProps) => import("react/jsx-runtime").JSX.Element;
|
|
22
|
-
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { CommentContextType, CommentProviderProps } from './types';
|
|
2
2
|
|
|
3
|
-
export declare const CommentProvider: ({ children, editor, initialComments, setInitialComments, username, setUsername, activeCommentId, setActiveCommentId, activeTabId, focusCommentWithActiveId, onNewComment, onCommentReply, ensResolutionUrl, onResolveComment, onUnresolveComment, onDeleteComment, isConnected, connectViaWallet, isLoading, connectViaUsername, isDDocOwner, onInlineComment, onComment, setCommentDrawerOpen, }: CommentProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
export declare const CommentProvider: ({ children, editor, ydoc, initialComments, setInitialComments, username, setUsername, activeCommentId, setActiveCommentId, activeTabId, focusCommentWithActiveId, onNewComment, onCommentReply, ensResolutionUrl, onResolveComment, onUnresolveComment, onDeleteComment, isConnected, connectViaWallet, isLoading, connectViaUsername, isDDocOwner, onInlineComment, onComment, setCommentDrawerOpen, }: CommentProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
4
4
|
export declare const useComments: () => CommentContextType;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { Editor } from '@tiptap/react';
|
|
2
2
|
import { IComment } from '../../../extensions/comment';
|
|
3
3
|
import { SetStateAction } from 'react';
|
|
4
|
-
import { CommentAccountProps } from '../../../types';
|
|
4
|
+
import { CommentAccountProps, CommentMutationMeta } from '../../../types';
|
|
5
5
|
import { EnsStatus } from '../types';
|
|
6
6
|
|
|
7
|
+
import * as Y from 'yjs';
|
|
7
8
|
export interface CommentContextType extends CommentAccountProps {
|
|
8
9
|
comments: IComment[];
|
|
9
10
|
setComments: React.Dispatch<SetStateAction<IComment[]>>;
|
|
@@ -68,13 +69,14 @@ export interface CommentContextType extends CommentAccountProps {
|
|
|
68
69
|
export interface CommentProviderProps extends CommentAccountProps {
|
|
69
70
|
children: React.ReactNode;
|
|
70
71
|
editor: Editor;
|
|
72
|
+
ydoc: Y.Doc;
|
|
71
73
|
initialComments?: IComment[];
|
|
72
74
|
setInitialComments?: React.Dispatch<SetStateAction<IComment[]>>;
|
|
73
75
|
onCommentReply?: (activeCommentId: string, reply: IComment) => void;
|
|
74
|
-
onNewComment?: (newComment: IComment) => void;
|
|
75
|
-
onResolveComment?: (activeCommentId: string) => void;
|
|
76
|
-
onUnresolveComment?: (activeCommentId: string) => void;
|
|
77
|
-
onDeleteComment?: (activeCommentId: string) => void;
|
|
76
|
+
onNewComment?: (newComment: IComment, meta?: CommentMutationMeta) => void;
|
|
77
|
+
onResolveComment?: (activeCommentId: string, meta?: CommentMutationMeta) => void;
|
|
78
|
+
onUnresolveComment?: (activeCommentId: string, meta?: CommentMutationMeta) => void;
|
|
79
|
+
onDeleteComment?: (activeCommentId: string, meta?: CommentMutationMeta) => void;
|
|
78
80
|
username: string | null;
|
|
79
81
|
setUsername?: React.Dispatch<SetStateAction<string>>;
|
|
80
82
|
activeCommentId: string | null;
|
|
@@ -6,7 +6,7 @@ import * as Y from 'yjs';
|
|
|
6
6
|
interface UseDdocExportArgs {
|
|
7
7
|
editor: Editor | null;
|
|
8
8
|
tabs: Tab[];
|
|
9
|
-
ydoc: Y.Doc;
|
|
9
|
+
ydoc: Y.Doc | null;
|
|
10
10
|
exportOptions: (IEditorToolElement | null)[];
|
|
11
11
|
}
|
|
12
12
|
declare const useDdocExport: ({ editor, tabs, ydoc, exportOptions, }: UseDdocExportArgs) => {
|
|
@@ -20,5 +20,10 @@ declare const useDdocExport: ({ editor, tabs, ydoc, exportOptions, }: UseDdocExp
|
|
|
20
20
|
tab: string;
|
|
21
21
|
name?: string;
|
|
22
22
|
}) => void;
|
|
23
|
+
handleExportAsync: ({ format, tab, name, }: {
|
|
24
|
+
format: string;
|
|
25
|
+
tab: string;
|
|
26
|
+
name?: string;
|
|
27
|
+
}) => Promise<void>;
|
|
23
28
|
};
|
|
24
29
|
export { useDdocExport };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Editor, JSONContent } from '@tiptap/react';
|
|
2
|
+
import { ExportAsModalProps } from '../components/export-modal';
|
|
3
|
+
import { UseHeadlessEditorProps } from './use-headless-editor';
|
|
4
|
+
|
|
5
|
+
import * as Y from 'yjs';
|
|
6
|
+
export type HeadlessEditorExportFormat = 'pdf' | 'md' | 'html' | 'txt';
|
|
7
|
+
export interface HeadlessEditorExportOption {
|
|
8
|
+
content: string;
|
|
9
|
+
fileName?: string;
|
|
10
|
+
initialFormat?: HeadlessEditorExportFormat;
|
|
11
|
+
}
|
|
12
|
+
export declare const useExportHeadlessEditorContent: (props?: UseHeadlessEditorProps) => {
|
|
13
|
+
exportContent: (option: HeadlessEditorExportOption) => void;
|
|
14
|
+
exportModalProps: ExportAsModalProps;
|
|
15
|
+
setContent: (initialContent: string | string[] | JSONContent, editor: Editor, ydoc: Y.Doc) => void;
|
|
16
|
+
getEditor: () => {
|
|
17
|
+
editor: Editor;
|
|
18
|
+
ydoc: Y.Doc;
|
|
19
|
+
};
|
|
20
|
+
getYjsConvertor: () => {
|
|
21
|
+
convertJSONContentToYjsEncodedString: (content: JSONContent) => string;
|
|
22
|
+
cleanup: () => void;
|
|
23
|
+
};
|
|
24
|
+
downloadContentAsMd: (content: string | string[] | JSONContent, title: string) => Promise<void>;
|
|
25
|
+
downloadContentAsHtml: (content: string | string[] | JSONContent, title: string) => Promise<void>;
|
|
26
|
+
downloadContentAsTxt: (content: string | string[] | JSONContent, title: string) => Promise<void>;
|
|
27
|
+
mergeYjsUpdates: (contents: string[]) => string;
|
|
28
|
+
handleMarkdownContent: typeof import('../extensions/mardown-paste-handler').handleMarkdownContent;
|
|
29
|
+
getYjsContentFromMarkdown: (file: File, ipfsImageUploadFn: (file: File) => Promise<import('../types').IpfsImageUploadResponse>) => Promise<string | null>;
|
|
30
|
+
getYjsContentFromDocx: (file: File, ipfsImageUploadFn: (file: File) => Promise<import('../types').IpfsImageUploadResponse>) => Promise<string | null>;
|
|
31
|
+
};
|
|
@@ -3,9 +3,10 @@ import { handleMarkdownContent } from '../extensions/mardown-paste-handler';
|
|
|
3
3
|
import { IpfsImageUploadResponse } from '../types';
|
|
4
4
|
|
|
5
5
|
import * as Y from 'yjs';
|
|
6
|
-
export
|
|
6
|
+
export interface UseHeadlessEditorProps {
|
|
7
7
|
optionalExtensions?: string[];
|
|
8
|
-
}
|
|
8
|
+
}
|
|
9
|
+
export declare const useHeadlessEditor: (props?: UseHeadlessEditorProps) => {
|
|
9
10
|
setContent: (initialContent: string | string[] | JSONContent, editor: Editor, ydoc: Y.Doc) => void;
|
|
10
11
|
getEditor: () => {
|
|
11
12
|
editor: Editor;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useRtcWebsocketDisconnector: (syncState: any, enableCollaboration: boolean | undefined) => void;
|
|
@@ -2,7 +2,7 @@ import { Dispatch, MutableRefObject, SetStateAction } from 'react';
|
|
|
2
2
|
import { DdocProps } from '../types';
|
|
3
3
|
import { AnyExtension, Editor } from '@tiptap/react';
|
|
4
4
|
import { ToCItemType } from '../components/toc/types';
|
|
5
|
-
import {
|
|
5
|
+
import { IConnectConf } from '../sync-local/useSyncMachine';
|
|
6
6
|
|
|
7
7
|
import * as Y from 'yjs';
|
|
8
8
|
interface UseTabEditorArgs {
|
|
@@ -38,7 +38,7 @@ interface UseTabEditorArgs {
|
|
|
38
38
|
onInvalidContentError?: DdocProps['onInvalidContentError'];
|
|
39
39
|
ignoreCorruptedData?: boolean;
|
|
40
40
|
onCollaboratorChange?: DdocProps['onCollaboratorChange'];
|
|
41
|
-
onConnect: (connectConfig:
|
|
41
|
+
onConnect: (connectConfig: IConnectConf) => void;
|
|
42
42
|
hasCollabContentInitialised?: boolean;
|
|
43
43
|
initialiseYjsIndexedDbProvider: () => Promise<void>;
|
|
44
44
|
externalExtensions?: Record<string, AnyExtension>;
|
|
@@ -14,12 +14,12 @@ interface UseYjsSetupArgs {
|
|
|
14
14
|
onCollabSessionTermination?: () => void;
|
|
15
15
|
onUnMergedUpdates?: (state: boolean) => void;
|
|
16
16
|
}
|
|
17
|
-
export declare const useYjsSetup: ({ onChange, enableIndexeddbSync, ddocId, onIndexedDbError, onCollabError, onCollaborationConnectCallback, onCollaborationCommit, onFetchCommitContent, onCollabSessionTermination, onUnMergedUpdates, }: UseYjsSetupArgs) => {
|
|
17
|
+
export declare const useYjsSetup: ({ onChange, enableIndexeddbSync, ddocId, enableCollaboration, onIndexedDbError, onCollabError, onCollaborationConnectCallback, onCollaborationCommit, onFetchCommitContent, onCollabSessionTermination, onUnMergedUpdates, }: UseYjsSetupArgs) => {
|
|
18
18
|
ydoc: Y.Doc;
|
|
19
|
-
onConnect: (connectConfig: import('../sync-local').
|
|
19
|
+
onConnect: (connectConfig: import('../sync-local/useSyncMachine').IConnectConf) => void;
|
|
20
20
|
isReady: boolean;
|
|
21
21
|
terminateSession: () => void;
|
|
22
|
-
awareness:
|
|
22
|
+
awareness: any;
|
|
23
23
|
hasCollabContentInitialised: boolean;
|
|
24
24
|
initialiseYjsIndexedDbProvider: () => Promise<void>;
|
|
25
25
|
refreshYjsIndexedDbProvider: () => Promise<void>;
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { SyncMachineContext, SyncMachinEvent } from '../types';
|
|
2
|
+
import { SocketClient } from '../socketClient';
|
|
3
|
+
|
|
4
|
+
import * as awarenessProtocol from 'y-protocols/awareness';
|
|
5
|
+
export declare const initAwarenessHandler: (context: SyncMachineContext) => {
|
|
6
|
+
awareness: awarenessProtocol.Awareness;
|
|
7
|
+
_awarenessUpdateHandler: ({ added, updated, removed, }: {
|
|
8
|
+
added: number[];
|
|
9
|
+
updated: number[];
|
|
10
|
+
removed: number[];
|
|
11
|
+
}) => void;
|
|
12
|
+
};
|
|
13
|
+
export declare const updateConnectionStateHandler: (context: SyncMachineContext) => {
|
|
14
|
+
isConnected: boolean;
|
|
15
|
+
};
|
|
16
|
+
export declare const websocketInitializer: (context: SyncMachineContext, event: SyncMachinEvent) => {
|
|
17
|
+
socketClient: SocketClient;
|
|
18
|
+
initialUpdate: any;
|
|
19
|
+
roomKey: any;
|
|
20
|
+
roomId: any;
|
|
21
|
+
isOwner: any;
|
|
22
|
+
isEns: any;
|
|
23
|
+
wsUrl: any;
|
|
24
|
+
onCollaborationCommit: (file: File) => Promise<string>;
|
|
25
|
+
onFetchCommitContent: (cid: string) => Promise<any>;
|
|
26
|
+
onSessionTerminated: () => void;
|
|
27
|
+
onUnMergedUpdates: (state: boolean) => void;
|
|
28
|
+
onLocalUpdate: ((updatedDocContent: import('../../types').Data["editorJSONData"], updateChunk: string) => void) | undefined;
|
|
29
|
+
};
|
|
30
|
+
export declare const yjsUpdateHandler: (context: SyncMachineContext, event: SyncMachinEvent) => {
|
|
31
|
+
uncommittedUpdatesIdList?: undefined;
|
|
32
|
+
} | {
|
|
33
|
+
uncommittedUpdatesIdList: any[];
|
|
34
|
+
};
|
|
35
|
+
export declare const roomMemberUpdateHandler: (context: SyncMachineContext) => {
|
|
36
|
+
roomMembers: import('../types').RoomMember[];
|
|
37
|
+
};
|
|
38
|
+
export declare const stateResetHandler: () => {
|
|
39
|
+
roomMembers: never[];
|
|
40
|
+
isConnected: boolean;
|
|
41
|
+
awareness: null;
|
|
42
|
+
_awarenessUpdateHandler: null;
|
|
43
|
+
socketClient: null;
|
|
44
|
+
};
|
|
45
|
+
export declare const registerUpdateHandler: (context: SyncMachineContext, event: SyncMachinEvent) => {
|
|
46
|
+
uncommittedUpdatesIdList?: undefined;
|
|
47
|
+
} | {
|
|
48
|
+
uncommittedUpdatesIdList: any[];
|
|
49
|
+
};
|
|
50
|
+
export declare const removeLastProcessedUpdate: (context: SyncMachineContext, event: SyncMachinEvent) => {
|
|
51
|
+
updateQueue: Uint8Array<ArrayBufferLike>[];
|
|
52
|
+
};
|
|
53
|
+
export declare const clearUncommitedUpdatesHandler: () => {
|
|
54
|
+
uncommittedUpdatesIdList: never[];
|
|
55
|
+
};
|
|
56
|
+
export declare const addUpdateToQueueHandler: (context: SyncMachineContext, event: SyncMachinEvent) => {
|
|
57
|
+
updateQueue: any[];
|
|
58
|
+
};
|
|
59
|
+
export declare const updateConnectionReadyStateHandler: (_context: SyncMachineContext, event: SyncMachinEvent) => {
|
|
60
|
+
isReady: any;
|
|
61
|
+
};
|
|
62
|
+
export declare const setNewDocFlagHandler: (_context: SyncMachineContext, event: SyncMachinEvent) => {
|
|
63
|
+
isNewDoc: any;
|
|
64
|
+
};
|
|
65
|
+
export declare const commitUncommittedIdsHandler: (_context: SyncMachineContext, event: SyncMachinEvent) => {
|
|
66
|
+
uncommittedUpdatesIdList: any;
|
|
67
|
+
};
|
|
68
|
+
export declare const setConnectionActiveStateHandler: (context: SyncMachineContext) => {
|
|
69
|
+
isConnected: boolean;
|
|
70
|
+
};
|
|
71
|
+
export declare const setMachineReadyStateHandler: () => {
|
|
72
|
+
isReady: boolean;
|
|
73
|
+
};
|
|
74
|
+
export declare const addRemoteContentToQueueHandler: (context: SyncMachineContext, event: SyncMachinEvent) => {
|
|
75
|
+
contentTobeAppliedQueue: any[];
|
|
76
|
+
};
|
|
77
|
+
export declare const applyContentsFromRemote: (context: SyncMachineContext) => {
|
|
78
|
+
contentTobeAppliedQueue?: undefined;
|
|
79
|
+
} | {
|
|
80
|
+
contentTobeAppliedQueue: never[];
|
|
81
|
+
};
|
|
82
|
+
export declare const clearErrorCountHandler: () => {
|
|
83
|
+
errorCount: number;
|
|
84
|
+
errorMessage: string;
|
|
85
|
+
};
|
|
86
|
+
export declare const updateErrorCountHandler: (context: SyncMachineContext) => {
|
|
87
|
+
errorCount: number;
|
|
88
|
+
};
|
|
89
|
+
export declare const setCommitMessageErrorHandler: (_context: SyncMachineContext, event: SyncMachinEvent) => {
|
|
90
|
+
errorMessage: string;
|
|
91
|
+
};
|
|
92
|
+
export declare const setUpdateErrorMessageHandler: (_context: SyncMachineContext, event: SyncMachinEvent) => {
|
|
93
|
+
errorMessage: string;
|
|
94
|
+
};
|
|
95
|
+
export declare const setConnectionErrorMessageHandler: (_context: SyncMachineContext, event: SyncMachinEvent) => {
|
|
96
|
+
errorMessage: string;
|
|
97
|
+
};
|
|
98
|
+
export declare const setIpfsQueryErrorMessageHandler: (_context: SyncMachineContext, event: SyncMachinEvent) => {
|
|
99
|
+
errorMessage: string;
|
|
100
|
+
};
|
|
101
|
+
export declare const setInitialCommitErrorMessageHandler: (_context: SyncMachineContext, event: SyncMachinEvent) => {
|
|
102
|
+
errorMessage: string;
|
|
103
|
+
};
|
|
104
|
+
export declare const setInitialUpdateErrorMessageHandler: (_context: SyncMachineContext, event: SyncMachinEvent) => {
|
|
105
|
+
errorMessage: string;
|
|
106
|
+
};
|
|
107
|
+
export declare const disconnectedStateHandler: () => {
|
|
108
|
+
socketClient: null;
|
|
109
|
+
roomMembers: never[];
|
|
110
|
+
isConnected: boolean;
|
|
111
|
+
awareness: null;
|
|
112
|
+
_awarenessUpdateHandler: null;
|
|
113
|
+
uncommittedUpdatesIdList: never[];
|
|
114
|
+
updateQueue: never[];
|
|
115
|
+
};
|
|
116
|
+
export declare const terminateSessionHandler: (context: SyncMachineContext) => {
|
|
117
|
+
socketClient: null;
|
|
118
|
+
roomId: string;
|
|
119
|
+
roomMembers: never[];
|
|
120
|
+
isConnected: boolean;
|
|
121
|
+
awareness: null;
|
|
122
|
+
_awarenessUpdateHandler: null;
|
|
123
|
+
roomKey: string;
|
|
124
|
+
wsUrl: string;
|
|
125
|
+
uncommittedUpdatesIdList: never[];
|
|
126
|
+
updateQueue: never[];
|
|
127
|
+
isOwner: boolean;
|
|
128
|
+
isReady: boolean;
|
|
129
|
+
isNewDoc: boolean;
|
|
130
|
+
contentTobeAppliedQueue: never[];
|
|
131
|
+
initialUpdate: null;
|
|
132
|
+
errorCount: number;
|
|
133
|
+
errorMessage: string;
|
|
134
|
+
};
|
|
135
|
+
export declare const setDocumentDecryptionStateHandler: (_: SyncMachineContext, event: SyncMachinEvent) => {
|
|
136
|
+
initalDocumentDecryptionState: any;
|
|
137
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const syncMachineActions: Record<any, any>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { SyncMachineContext } from '../types';
|
|
2
|
+
|
|
3
|
+
export declare const syncMachineGuards: {
|
|
4
|
+
isUserConnected: (context: SyncMachineContext) => boolean;
|
|
5
|
+
hasMoreUpdates: (context: SyncMachineContext) => boolean;
|
|
6
|
+
isOwner: (context: SyncMachineContext) => boolean;
|
|
7
|
+
errorIsLessThanRetryCount: (context: SyncMachineContext) => boolean;
|
|
8
|
+
shouldRetryConnection: (context: SyncMachineContext) => boolean;
|
|
9
|
+
shouldRefetchCommit: (context: SyncMachineContext) => boolean;
|
|
10
|
+
};
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { default as syncMachine } from './syncMachine';
|
|
2
|
+
import { SyncMachineContext } from './types';
|
|
3
|
+
|
|
4
|
+
export { useSyncMachine } from './useSyncMachine';
|
|
5
|
+
export { syncMachine };
|
|
6
|
+
export type { SyncMachineContext };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Sender } from 'xstate';
|
|
2
|
+
import { SyncMachineContext, SyncMachinEvent } from '../types';
|
|
3
|
+
|
|
4
|
+
export declare const syncMachineServices: {
|
|
5
|
+
connectSocket: (context: SyncMachineContext) => (send: Sender<SyncMachinEvent>) => Promise<void>;
|
|
6
|
+
disconnectSocket: (context: SyncMachineContext) => () => Promise<void>;
|
|
7
|
+
processNextUpdate: (context: SyncMachineContext) => () => Promise<{
|
|
8
|
+
updateId: string | undefined;
|
|
9
|
+
queueOffset: number;
|
|
10
|
+
} | undefined>;
|
|
11
|
+
processCommit: (context: SyncMachineContext) => (send: Sender<SyncMachinEvent>) => Promise<void>;
|
|
12
|
+
syncLatestCommitFromIpfs: (context: SyncMachineContext) => (send: Sender<SyncMachinEvent>) => Promise<{
|
|
13
|
+
ids: string[];
|
|
14
|
+
unbroadcastedUpdate: string | null;
|
|
15
|
+
}>;
|
|
16
|
+
broadcastLocalContents: (context: SyncMachineContext, event: SyncMachinEvent) => () => Promise<boolean>;
|
|
17
|
+
commitLocalContents: (context: SyncMachineContext, event: SyncMachinEvent) => (send: Sender<SyncMachinEvent>) => Promise<string | undefined>;
|
|
18
|
+
verifyConnectionState: (context: SyncMachineContext) => (send: Sender<SyncMachinEvent>) => Promise<void>;
|
|
19
|
+
};
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { UrlProvider } from 'partysocket/ws';
|
|
2
|
+
import { ISocketInitConfig, RoomMember, SocketStatusEnum, SendUpdateResponse, CommitResponse } from './types';
|
|
2
3
|
import { Awareness } from 'y-protocols/awareness.js';
|
|
3
4
|
|
|
4
5
|
interface ISocketClientConfig {
|
|
5
|
-
wsUrl:
|
|
6
|
+
wsUrl: UrlProvider;
|
|
6
7
|
roomKey: string;
|
|
7
|
-
roomId: string;
|
|
8
8
|
ownerEdSecret?: string;
|
|
9
9
|
contractAddress?: string;
|
|
10
10
|
ownerAddress?: string;
|
|
11
11
|
onCollaborationConnectCallback: (response: any) => void;
|
|
12
|
-
onError?: (e: Error) => void;
|
|
13
12
|
roomInfo?: {
|
|
14
13
|
documentTitle: string;
|
|
15
14
|
portalAddress: string;
|
|
@@ -17,11 +16,14 @@ interface ISocketClientConfig {
|
|
|
17
16
|
};
|
|
18
17
|
}
|
|
19
18
|
export declare class SocketClient {
|
|
20
|
-
private
|
|
21
|
-
private
|
|
22
|
-
private
|
|
23
|
-
|
|
24
|
-
|
|
19
|
+
private _websocketUrl;
|
|
20
|
+
private _machineEventHandler;
|
|
21
|
+
private _onConnect;
|
|
22
|
+
private _onDisconnection;
|
|
23
|
+
private _onHandShakeError;
|
|
24
|
+
private _sequenceCallbackMap;
|
|
25
|
+
_webSocketStatus: SocketStatusEnum;
|
|
26
|
+
private _webSocket;
|
|
25
27
|
private _websocketServiceDid;
|
|
26
28
|
private roomId;
|
|
27
29
|
roomMembers: RoomMember[];
|
|
@@ -37,8 +39,11 @@ export declare class SocketClient {
|
|
|
37
39
|
_onError: ISocketInitConfig['onError'] | null;
|
|
38
40
|
_onCollaborationConnectCallback: ISocketClientConfig['onCollaborationConnectCallback'] | null;
|
|
39
41
|
constructor(config: ISocketClientConfig);
|
|
42
|
+
private _getSequenceIdCallback;
|
|
43
|
+
private _removeSequenceIdFromMap;
|
|
40
44
|
registerAwareness(awareness: Awareness): void;
|
|
41
|
-
private
|
|
45
|
+
private _registerSequenceCallback;
|
|
46
|
+
private _sendNetworkRequest;
|
|
42
47
|
private _fetchRoomMembers;
|
|
43
48
|
sendUpdate({ update }: {
|
|
44
49
|
update: string;
|
|
@@ -47,19 +52,24 @@ export declare class SocketClient {
|
|
|
47
52
|
updates: string[];
|
|
48
53
|
cid: string;
|
|
49
54
|
}): Promise<CommitResponse>;
|
|
50
|
-
fetchLatestCommit(): Promise<
|
|
51
|
-
getUncommittedChanges(): Promise<
|
|
52
|
-
broadcastAwareness(awarenessUpdate: string): Promise<
|
|
53
|
-
disconnect: () => void;
|
|
55
|
+
fetchLatestCommit(): Promise<any>;
|
|
56
|
+
getUncommittedChanges(): Promise<any>;
|
|
57
|
+
broadcastAwareness(awarenessUpdate: string): Promise<any>;
|
|
58
|
+
disconnect: (reason: string, code: number) => void;
|
|
54
59
|
terminateSession: () => Promise<void>;
|
|
60
|
+
private _buildRequest;
|
|
55
61
|
private getCollaborationKeyPair;
|
|
56
62
|
private isUcanValid;
|
|
57
63
|
private getOwnerToken;
|
|
58
64
|
private buildSessionToken;
|
|
59
65
|
private _handleHandShake;
|
|
60
|
-
private
|
|
61
|
-
|
|
66
|
+
private _executeRequestCallback;
|
|
67
|
+
private _dispatchEventHandler;
|
|
62
68
|
private _onSessionTerminated;
|
|
69
|
+
private _processMessage;
|
|
70
|
+
private _clearSequenceCallbackMap;
|
|
71
|
+
connectSocket(): Promise<void> | undefined;
|
|
72
|
+
init(config: ISocketInitConfig): Promise<void>;
|
|
63
73
|
private resetSocketClient;
|
|
64
74
|
}
|
|
65
75
|
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { SyncMachineContext } from './types';
|
|
2
|
+
|
|
3
|
+
declare const syncMachine: import('xstate').StateMachine<SyncMachineContext, any, {
|
|
4
|
+
type: string;
|
|
5
|
+
data: any;
|
|
6
|
+
}, {
|
|
7
|
+
value: any;
|
|
8
|
+
context: SyncMachineContext;
|
|
9
|
+
}, import('xstate').BaseActionObject, import('xstate').ServiceMap, import('xstate').ResolveTypegenMeta<import('xstate').TypegenDisabled, {
|
|
10
|
+
type: string;
|
|
11
|
+
data: any;
|
|
12
|
+
}, import('xstate').BaseActionObject, import('xstate').ServiceMap>>;
|
|
13
|
+
export default syncMachine;
|