@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.
- package/dist/index.d.ts +3 -0
- package/dist/index.es.js +27782 -25648
- package/dist/package/components/export-modal.d.ts +4 -5
- package/dist/package/extensions/font-family-persistence.d.ts +11 -0
- package/dist/package/extensions/typography-persistence.d.ts +22 -0
- 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 -17
- 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/use-ddoc-editor.d.ts +2 -2
- package/dist/style.css +1 -1
- package/package.json +7 -3
- package/dist/package/sync-local/SyncManager.d.ts +0 -52
- 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
|
|
9
|
+
export interface DdocExportModalProps {
|
|
10
10
|
open: boolean;
|
|
11
11
|
onOpenChange: (open: boolean) => void;
|
|
12
12
|
onExport?: (data: {
|
|
@@ -18,5 +18,4 @@ interface ExportAsModalProps {
|
|
|
18
18
|
initialFormat?: string;
|
|
19
19
|
initialTab?: string;
|
|
20
20
|
}
|
|
21
|
-
export declare const
|
|
22
|
-
export {};
|
|
21
|
+
export declare const DdocExportModal: ({ open, onOpenChange, onExport, formatOptions, tabOptions, initialFormat, initialTab, }: DdocExportModalProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Extension } from '@tiptap/core';
|
|
2
|
+
|
|
3
|
+
declare module '@tiptap/core' {
|
|
4
|
+
interface Commands<ReturnType> {
|
|
5
|
+
fontFamilyPersistence: {
|
|
6
|
+
setFontFamily: (fontFamily: string) => ReturnType;
|
|
7
|
+
unsetFontFamily: () => ReturnType;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export declare const FontFamilyPersistence: Extension<any, any>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Extension } from '@tiptap/core';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* TypographyPersistence consolidates fontFamily and fontSize persistence logic
|
|
5
|
+
* into a single extension with 3 plugins, replacing the 6 individual plugins
|
|
6
|
+
* that were split across FontFamilyPersistence and FontSize.
|
|
7
|
+
*
|
|
8
|
+
* Plugins:
|
|
9
|
+
* 1. typographyInheritance — when a new paragraph is inserted next to a styled
|
|
10
|
+
* one, inherit fontFamily and fontSize in a single setNodeMarkup pass.
|
|
11
|
+
* Skips trailing-node paragraphs (they inherit from the previous sibling
|
|
12
|
+
* at creation time, but should not be overridden when the user clears them).
|
|
13
|
+
* 2. typographyStoredMarks — when selection moves into an empty styled
|
|
14
|
+
* paragraph, restore storedMarks for both fontFamily and fontSize at once.
|
|
15
|
+
* 3. typographySyncNodeAttr — when storedMarks change on an empty paragraph,
|
|
16
|
+
* update both node attributes in one setNodeMarkup call.
|
|
17
|
+
* Clearing only happens when the textStyle mark itself explicitly has a null
|
|
18
|
+
* value for the property — NOT when non-textStyle marks (bold, italic, etc.)
|
|
19
|
+
* are stored, which was previously causing font attrs to be wiped on
|
|
20
|
+
* bold/italic toggle.
|
|
21
|
+
*/
|
|
22
|
+
export declare const TypographyPersistence: Extension<any, any>;
|
|
@@ -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 { DdocExportModalProps } 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: DdocExportModalProps;
|
|
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,12 +16,14 @@ interface ISocketClientConfig {
|
|
|
17
16
|
};
|
|
18
17
|
}
|
|
19
18
|
export declare class SocketClient {
|
|
20
|
-
private
|
|
21
|
-
private
|
|
22
|
-
private
|
|
23
|
-
private
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
private _websocketUrl;
|
|
20
|
+
private _machineEventHandler;
|
|
21
|
+
private _onConnect;
|
|
22
|
+
private _onDisconnection;
|
|
23
|
+
private _onHandShakeError;
|
|
24
|
+
private _sequenceCallbackMap;
|
|
25
|
+
_webSocketStatus: SocketStatusEnum;
|
|
26
|
+
private _webSocket;
|
|
26
27
|
private _websocketServiceDid;
|
|
27
28
|
private roomId;
|
|
28
29
|
roomMembers: RoomMember[];
|
|
@@ -38,8 +39,11 @@ export declare class SocketClient {
|
|
|
38
39
|
_onError: ISocketInitConfig['onError'] | null;
|
|
39
40
|
_onCollaborationConnectCallback: ISocketClientConfig['onCollaborationConnectCallback'] | null;
|
|
40
41
|
constructor(config: ISocketClientConfig);
|
|
42
|
+
private _getSequenceIdCallback;
|
|
43
|
+
private _removeSequenceIdFromMap;
|
|
41
44
|
registerAwareness(awareness: Awareness): void;
|
|
42
|
-
private
|
|
45
|
+
private _registerSequenceCallback;
|
|
46
|
+
private _sendNetworkRequest;
|
|
43
47
|
private _fetchRoomMembers;
|
|
44
48
|
sendUpdate({ update }: {
|
|
45
49
|
update: string;
|
|
@@ -48,19 +52,24 @@ export declare class SocketClient {
|
|
|
48
52
|
updates: string[];
|
|
49
53
|
cid: string;
|
|
50
54
|
}): Promise<CommitResponse>;
|
|
51
|
-
fetchLatestCommit(): Promise<
|
|
52
|
-
getUncommittedChanges(): Promise<
|
|
53
|
-
broadcastAwareness(awarenessUpdate: string): Promise<
|
|
54
|
-
disconnect: () => void;
|
|
55
|
+
fetchLatestCommit(): Promise<any>;
|
|
56
|
+
getUncommittedChanges(): Promise<any>;
|
|
57
|
+
broadcastAwareness(awarenessUpdate: string): Promise<any>;
|
|
58
|
+
disconnect: (reason: string, code: number) => void;
|
|
55
59
|
terminateSession: () => Promise<void>;
|
|
60
|
+
private _buildRequest;
|
|
56
61
|
private getCollaborationKeyPair;
|
|
57
62
|
private isUcanValid;
|
|
58
63
|
private getOwnerToken;
|
|
59
64
|
private buildSessionToken;
|
|
60
65
|
private _handleHandShake;
|
|
61
|
-
private
|
|
62
|
-
|
|
66
|
+
private _executeRequestCallback;
|
|
67
|
+
private _dispatchEventHandler;
|
|
63
68
|
private _onSessionTerminated;
|
|
69
|
+
private _processMessage;
|
|
70
|
+
private _clearSequenceCallbackMap;
|
|
71
|
+
connectSocket(): Promise<void> | undefined;
|
|
72
|
+
init(config: ISocketInitConfig): Promise<void>;
|
|
64
73
|
private resetSocketClient;
|
|
65
74
|
}
|
|
66
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;
|