@fileverse-dev/ddoc 2.3.0-patch-13-customisation-3 → 2.3.0-rtc-patch-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/README.md +0 -51
- package/dist/{ccip-BJlDlP5S.mjs → ccip-C8cPDr9s.mjs} +1 -1
- package/dist/{index-CBXKsMdu.mjs → index-BYTPU5Y7.mjs} +45078 -37152
- package/dist/index.es.js +1 -1
- package/dist/package/components/presentation-mode/presentation-mode.d.ts +2 -3
- package/dist/package/components/presentation-mode/preview-panel.d.ts +1 -4
- package/dist/package/context/editor-context.d.ts +0 -3
- package/dist/package/extensions/sync-cursor.d.ts +28 -0
- package/dist/package/sync-local/actions/index.d.ts +127 -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/crypto/index.d.ts +6 -0
- package/dist/package/sync-local/guards/syncMachineGuards.d.ts +10 -0
- package/dist/package/sync-local/index.d.ts +6 -0
- package/dist/package/sync-local/services/syncMachineServices.d.ts +19 -0
- package/dist/package/sync-local/socketClient.d.ts +59 -0
- package/dist/package/sync-local/syncMachine.d.ts +13 -0
- package/dist/package/sync-local/types/index.d.ts +163 -0
- package/dist/package/sync-local/useSyncMachine.d.ts +51 -0
- package/dist/package/sync-local/utils/createAwarenessUpdateHandler.d.ts +8 -0
- package/dist/package/sync-local/utils/fetchIpfsJsonContent.d.ts +1 -0
- package/dist/package/sync-local/utils/objectToFile.d.ts +1 -0
- package/dist/package/sync-local/utils/uploadFileToIPFS.d.ts +3 -0
- package/dist/package/types.d.ts +14 -35
- package/dist/package/use-ddoc-editor.d.ts +2 -2
- package/dist/style.css +1 -1
- package/package.json +14 -1
package/dist/index.es.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { Editor } from '@tiptap/react';
|
2
|
-
import { IpfsImageFetchPayload
|
2
|
+
import { IpfsImageFetchPayload } from '../../types';
|
3
3
|
|
4
4
|
interface PresentationModeProps {
|
5
5
|
editor: Editor;
|
@@ -20,7 +20,6 @@ interface PresentationModeProps {
|
|
20
20
|
url: string;
|
21
21
|
file: File;
|
22
22
|
}>;
|
23
|
-
documentStyling?: DdocProps['documentStyling'];
|
24
23
|
}
|
25
|
-
export declare const PresentationMode: ({ editor, onClose, isFullscreen, setIsFullscreen, onError, setCommentDrawerOpen, sharedSlidesLink, isPreviewMode, documentName, onSlidesShare, slides, setSlides, renderThemeToggle, isContentLoading, ipfsImageFetchFn,
|
24
|
+
export declare const PresentationMode: ({ editor, onClose, isFullscreen, setIsFullscreen, onError, setCommentDrawerOpen, sharedSlidesLink, isPreviewMode, documentName, onSlidesShare, slides, setSlides, renderThemeToggle, isContentLoading, ipfsImageFetchFn, }: PresentationModeProps) => import("react/jsx-runtime").JSX.Element | null;
|
26
25
|
export {};
|
@@ -1,10 +1,7 @@
|
|
1
|
-
import { DdocProps } from '../../types';
|
2
|
-
|
3
1
|
interface PreviewPanelProps {
|
4
2
|
slides: string[];
|
5
3
|
currentSlide: number;
|
6
4
|
setCurrentSlide: (index: number) => void;
|
7
|
-
documentStyling?: DdocProps['documentStyling'];
|
8
5
|
}
|
9
|
-
export declare const PreviewPanel: ({ slides, currentSlide, setCurrentSlide,
|
6
|
+
export declare const PreviewPanel: ({ slides, currentSlide, setCurrentSlide, }: PreviewPanelProps) => import("react/jsx-runtime").JSX.Element;
|
10
7
|
export {};
|
@@ -1,17 +1,14 @@
|
|
1
1
|
import { default as React, ReactNode } from 'react';
|
2
|
-
import { DocumentStyling } from '../types';
|
3
2
|
|
4
3
|
interface EditorContextType {
|
5
4
|
collapsedHeadings: Set<string>;
|
6
5
|
setCollapsedHeadings: (updater: (prev: Set<string>) => Set<string>) => void;
|
7
6
|
isHeadingCollapsed: (id: string) => boolean;
|
8
7
|
expandMultipleHeadings: (ids: string[]) => void;
|
9
|
-
documentStyling?: DocumentStyling;
|
10
8
|
}
|
11
9
|
export declare const EditorContext: React.Context<EditorContextType | null>;
|
12
10
|
export declare const useEditorContext: () => EditorContextType;
|
13
11
|
export declare const EditorProvider: React.FC<{
|
14
12
|
children: ReactNode;
|
15
|
-
documentStyling?: DocumentStyling;
|
16
13
|
}>;
|
17
14
|
export {};
|
@@ -0,0 +1,28 @@
|
|
1
|
+
import { Extension } from '@tiptap/core';
|
2
|
+
|
3
|
+
type CollaborationCursorStorage = {
|
4
|
+
users: {
|
5
|
+
clientId: number;
|
6
|
+
[key: string]: any;
|
7
|
+
}[];
|
8
|
+
};
|
9
|
+
export interface CollaborationCursorOptions {
|
10
|
+
provider: any;
|
11
|
+
user: Record<string, any>;
|
12
|
+
render(user: Record<string, any>): HTMLElement;
|
13
|
+
selectionRender(user: Record<string, any>): any;
|
14
|
+
onUpdate: (users: {
|
15
|
+
clientId: number;
|
16
|
+
[key: string]: any;
|
17
|
+
}[]) => null;
|
18
|
+
}
|
19
|
+
declare module '@tiptap/core' {
|
20
|
+
interface Commands<ReturnType> {
|
21
|
+
collaborationCursor: {
|
22
|
+
updateUser: (attributes: Record<string, any>) => ReturnType;
|
23
|
+
user: (attributes: Record<string, any>) => ReturnType;
|
24
|
+
};
|
25
|
+
}
|
26
|
+
}
|
27
|
+
export declare const SyncCursor: Extension<CollaborationCursorOptions, CollaborationCursorStorage>;
|
28
|
+
export {};
|
@@ -0,0 +1,127 @@
|
|
1
|
+
import { SyncMachineContext, SyncMachinEvent } from '../types';
|
2
|
+
import { SocketClient } from '../socketClient';
|
3
|
+
|
4
|
+
import * as awarenessProtocol from 'y-protocols/awareness';
|
5
|
+
export declare const awarenessUpdateHandler: (context: SyncMachineContext, event: SyncMachinEvent) => {};
|
6
|
+
export declare const initAwarenessHandler: (context: SyncMachineContext) => {
|
7
|
+
awareness: awarenessProtocol.Awareness;
|
8
|
+
_awarenessUpdateHandler: ({ added, updated, removed, }: {
|
9
|
+
added: number[];
|
10
|
+
updated: number[];
|
11
|
+
removed: number[];
|
12
|
+
}) => void;
|
13
|
+
};
|
14
|
+
export declare const updateConnectionStateHandler: (context: SyncMachineContext) => {
|
15
|
+
isConnected: boolean;
|
16
|
+
};
|
17
|
+
export declare const websocketInitializer: (context: SyncMachineContext, event: SyncMachinEvent) => {
|
18
|
+
socketClient: SocketClient;
|
19
|
+
username: any;
|
20
|
+
initialUpdate: any;
|
21
|
+
roomKey: any;
|
22
|
+
roomId: any;
|
23
|
+
isOwner: any;
|
24
|
+
isEns: any;
|
25
|
+
};
|
26
|
+
export declare const yjsUpdateHandler: (context: SyncMachineContext, event: SyncMachinEvent) => {
|
27
|
+
uncommittedUpdatesIdList?: undefined;
|
28
|
+
} | {
|
29
|
+
uncommittedUpdatesIdList: any[];
|
30
|
+
};
|
31
|
+
export declare const roomMemberUpdateHandler: (context: SyncMachineContext) => {
|
32
|
+
roomMembers: import('../types').RoomMember[];
|
33
|
+
};
|
34
|
+
export declare const stateResetHandler: () => {
|
35
|
+
roomMembers: never[];
|
36
|
+
isConnected: boolean;
|
37
|
+
awareness: null;
|
38
|
+
_awarenessUpdateHandler: null;
|
39
|
+
socketClient: null;
|
40
|
+
};
|
41
|
+
export declare const registerUpdateHandler: (context: SyncMachineContext, event: SyncMachinEvent) => {
|
42
|
+
uncommittedUpdatesIdList?: undefined;
|
43
|
+
} | {
|
44
|
+
uncommittedUpdatesIdList: any[];
|
45
|
+
};
|
46
|
+
export declare const removeLastProcessedUpdate: (context: SyncMachineContext, event: SyncMachinEvent) => {
|
47
|
+
updateQueue: Uint8Array<ArrayBufferLike>[];
|
48
|
+
};
|
49
|
+
export declare const clearUncommitedUpdatesHandler: (_context: SyncMachineContext, event: SyncMachinEvent) => {
|
50
|
+
uncommittedUpdatesIdList: never[];
|
51
|
+
};
|
52
|
+
export declare const addUpdateToQueueHandler: (context: SyncMachineContext, event: SyncMachinEvent) => {
|
53
|
+
updateQueue: any[];
|
54
|
+
};
|
55
|
+
export declare const updateConnectionReadyStateHandler: (_context: SyncMachineContext, event: SyncMachinEvent) => {
|
56
|
+
isReady: any;
|
57
|
+
};
|
58
|
+
export declare const setNewDocFlagHandler: (_context: SyncMachineContext, event: SyncMachinEvent) => {
|
59
|
+
isNewDoc: any;
|
60
|
+
};
|
61
|
+
export declare const commitUncommittedIdsHandler: (_context: SyncMachineContext, event: SyncMachinEvent) => {
|
62
|
+
uncommittedUpdatesIdList: any;
|
63
|
+
};
|
64
|
+
export declare const setConnectionActiveStateHandler: (context: SyncMachineContext) => {
|
65
|
+
isConnected: boolean;
|
66
|
+
};
|
67
|
+
export declare const setMachineReadyStateHandler: () => {
|
68
|
+
isReady: boolean;
|
69
|
+
};
|
70
|
+
export declare const addRemoteContentToQueueHandler: (context: SyncMachineContext, event: SyncMachinEvent) => {
|
71
|
+
contentTobeAppliedQueue: any[];
|
72
|
+
};
|
73
|
+
export declare const applyContentsFromRemote: (context: SyncMachineContext) => {
|
74
|
+
contentTobeAppliedQueue?: undefined;
|
75
|
+
} | {
|
76
|
+
contentTobeAppliedQueue: never[];
|
77
|
+
};
|
78
|
+
export declare const clearErrorCountHandler: () => {
|
79
|
+
errorCount: number;
|
80
|
+
errorMessage: string;
|
81
|
+
};
|
82
|
+
export declare const updateErrorCountHandler: (context: SyncMachineContext) => {
|
83
|
+
errorCount: number;
|
84
|
+
};
|
85
|
+
export declare const setCommitMessageErrorHandler: (_context: SyncMachineContext, event: SyncMachinEvent) => {
|
86
|
+
errorMessage: string;
|
87
|
+
};
|
88
|
+
export declare const setUpdateErrorMessageHandler: (_context: SyncMachineContext, event: SyncMachinEvent) => {
|
89
|
+
errorMessage: string;
|
90
|
+
};
|
91
|
+
export declare const setConnectionErrorMessageHandler: (_context: SyncMachineContext, event: SyncMachinEvent) => {
|
92
|
+
errorMessage: string;
|
93
|
+
};
|
94
|
+
export declare const setIpfsQueryErrorMessageHandler: (_context: SyncMachineContext, event: SyncMachinEvent) => {
|
95
|
+
errorMessage: string;
|
96
|
+
};
|
97
|
+
export declare const setInitialCommitErrorMessageHandler: (_context: SyncMachineContext, event: SyncMachinEvent) => {
|
98
|
+
errorMessage: string;
|
99
|
+
};
|
100
|
+
export declare const setInitialUpdateErrorMessageHandler: (_context: SyncMachineContext, event: SyncMachinEvent) => {
|
101
|
+
errorMessage: string;
|
102
|
+
};
|
103
|
+
export declare const disconnectedStateHandler: () => {
|
104
|
+
socketClient: null;
|
105
|
+
roomMembers: never[];
|
106
|
+
isConnected: boolean;
|
107
|
+
awareness: null;
|
108
|
+
_awarenessUpdateHandler: null;
|
109
|
+
uncommittedUpdatesIdList: never[];
|
110
|
+
updateQueue: never[];
|
111
|
+
};
|
112
|
+
export declare const handleDisconnectionDueToError: (context: SyncMachineContext, event: SyncMachinEvent) => {
|
113
|
+
errorCount: number;
|
114
|
+
errorMessage: any;
|
115
|
+
} | {
|
116
|
+
errorCount?: undefined;
|
117
|
+
errorMessage?: undefined;
|
118
|
+
};
|
119
|
+
export declare const terminateSessionHandler: (context: SyncMachineContext) => {
|
120
|
+
socketClient: null;
|
121
|
+
roomMembers: never[];
|
122
|
+
isConnected: boolean;
|
123
|
+
awareness: null;
|
124
|
+
_awarenessUpdateHandler: null;
|
125
|
+
uncommittedUpdatesIdList: never[];
|
126
|
+
updateQueue: never[];
|
127
|
+
};
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const syncMachineActions: Record<any, any>;
|
@@ -0,0 +1,6 @@
|
|
1
|
+
export declare const crypto: {
|
2
|
+
generateKeyPair: () => import('@fileverse/crypto/ecies').EciesKeyPairBytes;
|
3
|
+
encryptData: (key: Uint8Array, message: Uint8Array) => string;
|
4
|
+
decryptData: (key: Uint8Array, message: string) => Uint8Array<ArrayBufferLike>;
|
5
|
+
generateRandomBytes: <E extends import('@fileverse/crypto/types').EncodingType = "bytes">(length?: number, encoding?: E) => import('@fileverse/crypto/types').EncodedReturnType<E>;
|
6
|
+
};
|
@@ -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
|
+
};
|
@@ -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) => () => 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
|
+
};
|
@@ -0,0 +1,59 @@
|
|
1
|
+
import { UrlProvider } from 'partysocket/ws';
|
2
|
+
import { ISocketInitConfig, RoomMember, SocketStatusEnum, SendUpdateResponse, CommitResponse } from './types';
|
3
|
+
|
4
|
+
interface ISocketClientConfig {
|
5
|
+
wsUrl: UrlProvider;
|
6
|
+
roomKey: string;
|
7
|
+
ownerEdSecret?: string;
|
8
|
+
contractAddress?: string;
|
9
|
+
ownerAddress?: string;
|
10
|
+
}
|
11
|
+
export declare class SocketClient {
|
12
|
+
private _websocketUrl;
|
13
|
+
private _machineEventHandler;
|
14
|
+
private _onConnect;
|
15
|
+
private _onDisconnection;
|
16
|
+
private _sequenceCallbackMap;
|
17
|
+
_webSocketStatus: SocketStatusEnum;
|
18
|
+
private _webSocket;
|
19
|
+
private _websocketServiceDid;
|
20
|
+
private roomId;
|
21
|
+
private clientUsername;
|
22
|
+
roomMembers: RoomMember[];
|
23
|
+
private collaborationKeyPair;
|
24
|
+
private ownerKeyPair?;
|
25
|
+
private contractAddress?;
|
26
|
+
private ownerUcan?;
|
27
|
+
private ownerAddress?;
|
28
|
+
_onError: ISocketInitConfig['onError'] | null;
|
29
|
+
constructor(config: ISocketClientConfig);
|
30
|
+
private _getSequenceIdCallback;
|
31
|
+
private _removeSequenceIdFromMap;
|
32
|
+
private _registerSequenceCallback;
|
33
|
+
private _sendNetworkRequest;
|
34
|
+
private _fetchRoomMembers;
|
35
|
+
sendUpdate({ update }: {
|
36
|
+
update: string;
|
37
|
+
}): Promise<SendUpdateResponse>;
|
38
|
+
commitUpdates({ updates, cid }: {
|
39
|
+
updates: string[];
|
40
|
+
cid: string;
|
41
|
+
}): Promise<CommitResponse>;
|
42
|
+
fetchLatestCommit(): Promise<any>;
|
43
|
+
getUncommittedChanges(): Promise<any>;
|
44
|
+
broadcastAwareness(awarenessUpdate: string): Promise<any>;
|
45
|
+
disconnect: () => void;
|
46
|
+
terminateSession: () => Promise<void>;
|
47
|
+
private _buildRequest;
|
48
|
+
private getCollaborationKeyPair;
|
49
|
+
private getOwnerToken;
|
50
|
+
private buildToken;
|
51
|
+
private _handleHandShake;
|
52
|
+
private _executeRequestCallback;
|
53
|
+
private _dispatchEventHandler;
|
54
|
+
private _processMessage;
|
55
|
+
private _clearSequenceCallbackMap;
|
56
|
+
connectSocket(): Promise<void> | undefined;
|
57
|
+
init(config: ISocketInitConfig): Promise<void>;
|
58
|
+
}
|
59
|
+
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;
|
@@ -0,0 +1,163 @@
|
|
1
|
+
import { SocketClient } from '../socketClient';
|
2
|
+
|
3
|
+
import * as Y from 'yjs';
|
4
|
+
export interface IRoomMember {
|
5
|
+
userId: string;
|
6
|
+
username: string;
|
7
|
+
role: 'owner' | 'editor';
|
8
|
+
}
|
9
|
+
export interface SendUpdateResponse {
|
10
|
+
data: {
|
11
|
+
agent_id: string;
|
12
|
+
commitCid: string | null;
|
13
|
+
created_at: number;
|
14
|
+
data: string;
|
15
|
+
documentId: string;
|
16
|
+
id: string;
|
17
|
+
update_snapshot_ref: string | null;
|
18
|
+
updateType: string;
|
19
|
+
};
|
20
|
+
is_handshake_response: boolean;
|
21
|
+
status: boolean;
|
22
|
+
statusCode: number;
|
23
|
+
}
|
24
|
+
export interface CommitResponse {
|
25
|
+
data: {
|
26
|
+
agent_id: string;
|
27
|
+
cid: string;
|
28
|
+
created_at: number;
|
29
|
+
data: any | null;
|
30
|
+
documentId: string;
|
31
|
+
updates: string[];
|
32
|
+
};
|
33
|
+
is_handshake_response: boolean;
|
34
|
+
status: boolean;
|
35
|
+
statusCode: number;
|
36
|
+
}
|
37
|
+
export interface SyncMachineContext {
|
38
|
+
ydoc: Y.Doc;
|
39
|
+
socketClient: SocketClient | null;
|
40
|
+
roomId: string;
|
41
|
+
username: string;
|
42
|
+
roomMembers: IRoomMember[];
|
43
|
+
isConnected: boolean;
|
44
|
+
awareness: any;
|
45
|
+
_awarenessUpdateHandler: (({ added, updated, removed, }: {
|
46
|
+
added: number[];
|
47
|
+
updated: number[];
|
48
|
+
removed: number[];
|
49
|
+
}) => void) | null;
|
50
|
+
onError: ((e: string) => void) | null;
|
51
|
+
roomKey: string;
|
52
|
+
wsUrl: string;
|
53
|
+
uncommittedUpdatesIdList: string[];
|
54
|
+
isOwner: boolean;
|
55
|
+
updateQueue: Uint8Array[];
|
56
|
+
isReady: boolean;
|
57
|
+
isNewDoc: boolean;
|
58
|
+
contentTobeAppliedQueue: string[];
|
59
|
+
initialUpdate: string | null;
|
60
|
+
errorCount: number;
|
61
|
+
errorMaxRetryCount: number;
|
62
|
+
errorMessage: string;
|
63
|
+
cryptoUtils: {
|
64
|
+
generateKeyPair: () => {
|
65
|
+
publicKey: Uint8Array;
|
66
|
+
privateKey: Uint8Array;
|
67
|
+
};
|
68
|
+
encryptData: (data: Uint8Array, key: Uint8Array) => Uint8Array;
|
69
|
+
decryptData: (data: Uint8Array, key: Uint8Array) => Uint8Array;
|
70
|
+
generateRandomBytes: (length: number) => Uint8Array;
|
71
|
+
};
|
72
|
+
}
|
73
|
+
export interface ErrorResponseMessage {
|
74
|
+
status: boolean;
|
75
|
+
statusCode: number;
|
76
|
+
seqId: string | null;
|
77
|
+
is_handshake_response: boolean;
|
78
|
+
err: string;
|
79
|
+
err_detail: {
|
80
|
+
[key: string]: any;
|
81
|
+
} | null;
|
82
|
+
}
|
83
|
+
export interface SuccessResponseMessage {
|
84
|
+
status: boolean;
|
85
|
+
statusCode: number;
|
86
|
+
seqId: string | null;
|
87
|
+
is_handshake_response: boolean;
|
88
|
+
data: {
|
89
|
+
[key: string]: any;
|
90
|
+
};
|
91
|
+
}
|
92
|
+
export interface EventMessage {
|
93
|
+
type: string;
|
94
|
+
event_type: string;
|
95
|
+
event: {
|
96
|
+
data: any;
|
97
|
+
roomId: string;
|
98
|
+
};
|
99
|
+
}
|
100
|
+
export type RequestResponse = ErrorResponseMessage | SuccessResponseMessage;
|
101
|
+
export type OnMessagePayloadType = RequestResponse | EventMessage;
|
102
|
+
export type EventHandler = (message: EventMessage) => void;
|
103
|
+
export type DisconnectHandler = (e: CloseEvent | ErrorEvent) => void;
|
104
|
+
export type ConnectHandler = () => void;
|
105
|
+
export interface PartialRequest {
|
106
|
+
cmd: string;
|
107
|
+
args: {
|
108
|
+
[key: string]: any;
|
109
|
+
};
|
110
|
+
}
|
111
|
+
export interface RequestPayload extends PartialRequest {
|
112
|
+
seqId: string;
|
113
|
+
}
|
114
|
+
export type SequenceResponseCB = (data: RequestResponse) => void;
|
115
|
+
export interface SequenceToRequestMapValue {
|
116
|
+
callback: SequenceResponseCB;
|
117
|
+
}
|
118
|
+
export type SequenceToRequestMap = {
|
119
|
+
[key: string]: SequenceToRequestMapValue;
|
120
|
+
};
|
121
|
+
export type Update = Uint8Array;
|
122
|
+
export interface ISocketInitConfig {
|
123
|
+
onConnect: ConnectHandler;
|
124
|
+
onDisconnect: DisconnectHandler;
|
125
|
+
onError: (err: string) => void;
|
126
|
+
onWsEvent: EventHandler;
|
127
|
+
roomId: string;
|
128
|
+
username: string;
|
129
|
+
}
|
130
|
+
export declare enum SocketStatusEnum {
|
131
|
+
CLOSED = "CLOSED",
|
132
|
+
CONNECTED = "CONNECTED",
|
133
|
+
CONNECTING = "CONNECTING",
|
134
|
+
DISCONNECTING = "DISCONNECTING",
|
135
|
+
DISCONNECTED = "DISCONNECTED"
|
136
|
+
}
|
137
|
+
export interface RoomMember {
|
138
|
+
username: string;
|
139
|
+
userId: string;
|
140
|
+
role: 'owner' | 'editor';
|
141
|
+
}
|
142
|
+
export type IAesKey = string;
|
143
|
+
export type SyncMachinEvent = {
|
144
|
+
type: string;
|
145
|
+
data: any;
|
146
|
+
};
|
147
|
+
export interface IpfsUploadResponse {
|
148
|
+
ipfsUrl: string;
|
149
|
+
ipfsHash: string;
|
150
|
+
ipfsStorage: string;
|
151
|
+
cachedUrl: string;
|
152
|
+
fileSize: number;
|
153
|
+
mimetype: string;
|
154
|
+
}
|
155
|
+
export interface IAuthArgs {
|
156
|
+
username: string;
|
157
|
+
collaborationToken: string;
|
158
|
+
documentId: string;
|
159
|
+
ownerToken?: string;
|
160
|
+
ownerAddress?: string;
|
161
|
+
contractAddress?: string;
|
162
|
+
collaborationDid?: string;
|
163
|
+
}
|
@@ -0,0 +1,51 @@
|
|
1
|
+
import { SyncMachineContext } from '.';
|
2
|
+
|
3
|
+
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
|
+
}
|
13
|
+
export declare const useSyncMachine: (config: Partial<SyncMachineContext>) => {
|
14
|
+
machine: (import('xstate').State<SyncMachineContext, {
|
15
|
+
type: string;
|
16
|
+
data: any;
|
17
|
+
}, any, {
|
18
|
+
value: any;
|
19
|
+
context: SyncMachineContext;
|
20
|
+
}, import('xstate').ResolveTypegenMeta<import('xstate').TypegenDisabled, {
|
21
|
+
type: string;
|
22
|
+
data: any;
|
23
|
+
}, import('xstate').BaseActionObject, import('xstate').ServiceMap>> | ((event: import("xstate").SCXML.Event<{
|
24
|
+
type: string;
|
25
|
+
data: any;
|
26
|
+
}> | import('xstate').SingleOrArray<import('xstate').Event<{
|
27
|
+
type: string;
|
28
|
+
data: any;
|
29
|
+
}>>, payload?: import('xstate').EventData) => import('xstate').State<SyncMachineContext, {
|
30
|
+
type: string;
|
31
|
+
data: any;
|
32
|
+
}, any, {
|
33
|
+
value: any;
|
34
|
+
context: SyncMachineContext;
|
35
|
+
}, import('xstate').ResolveTypegenMeta<import('xstate').TypegenDisabled, {
|
36
|
+
type: string;
|
37
|
+
data: any;
|
38
|
+
}, import('xstate').BaseActionObject, import('xstate').ServiceMap>>))[];
|
39
|
+
connect: (connectConfig: IConnectConf) => void;
|
40
|
+
disconnect: () => void;
|
41
|
+
isConnected: boolean;
|
42
|
+
isReady: boolean;
|
43
|
+
getYjsEncodedState: () => string;
|
44
|
+
applyYjsEncodedState: (update: string) => void;
|
45
|
+
error: {
|
46
|
+
message: string;
|
47
|
+
} | null;
|
48
|
+
context: any;
|
49
|
+
terminateSession: () => void;
|
50
|
+
};
|
51
|
+
export {};
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import { Awareness } from 'y-protocols/awareness';
|
2
|
+
import { SyncMachineContext } from '../types';
|
3
|
+
|
4
|
+
export declare const createAwarenessUpdateHandler: (awareness: Awareness, context: SyncMachineContext) => ({ added, updated, removed, }: {
|
5
|
+
added: number[];
|
6
|
+
updated: number[];
|
7
|
+
removed: number[];
|
8
|
+
}) => void;
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare function fetchIpfsJsonContent(cid: string): Promise<any>;
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const objectToFile: (data: Record<string, unknown>, fileName: string) => File;
|
package/dist/package/types.d.ts
CHANGED
@@ -32,36 +32,6 @@ export interface CustomModel {
|
|
32
32
|
apiKey: string;
|
33
33
|
systemPrompt: string;
|
34
34
|
}
|
35
|
-
/**
|
36
|
-
* Document styling configuration interface
|
37
|
-
* @description Defines the styling options available for customizing the document editor appearance
|
38
|
-
*/
|
39
|
-
export interface DocumentStyling {
|
40
|
-
/**
|
41
|
-
* Outer page/document background
|
42
|
-
* @description Controls the background of the entire editor area. Supports solid colors and CSS gradients.
|
43
|
-
* @example "#f8f9fa" | "linear-gradient(135deg, #667eea 0%, #764ba2 100%)"
|
44
|
-
*/
|
45
|
-
background?: string;
|
46
|
-
/**
|
47
|
-
* Editor content area background
|
48
|
-
* @description Controls the background color of the actual editor content where text is written. Should be solid colors for readability.
|
49
|
-
* @example "#ffffff" | "#f5f5f5"
|
50
|
-
*/
|
51
|
-
canvasBackground?: string;
|
52
|
-
/**
|
53
|
-
* Text color
|
54
|
-
* @description Controls the color of the text content in the editor.
|
55
|
-
* @example "#000000" | "#1a1a1a"
|
56
|
-
*/
|
57
|
-
textColor?: string;
|
58
|
-
/**
|
59
|
-
* Font family
|
60
|
-
* @description Controls the font family used for the editor content.
|
61
|
-
* @example "Inter" | "Arial" | "Georgia"
|
62
|
-
*/
|
63
|
-
fontFamily?: string;
|
64
|
-
}
|
65
35
|
export interface DdocProps extends CommentAccountProps {
|
66
36
|
isCollabDocumentPublished?: boolean;
|
67
37
|
ipfsImageFetchFn?: (_data: IpfsImageFetchPayload) => Promise<{
|
@@ -142,11 +112,20 @@ export interface DdocProps extends CommentAccountProps {
|
|
142
112
|
activeModel?: CustomModel;
|
143
113
|
maxTokens?: number;
|
144
114
|
isAIAgentEnabled?: boolean;
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
115
|
+
collaborationKey?: CryptoKey | null;
|
116
|
+
collaborationKeyPair?: {
|
117
|
+
publicKey: string;
|
118
|
+
privateKey: string;
|
119
|
+
};
|
120
|
+
collabConfig?: {
|
121
|
+
roomKey: string;
|
122
|
+
collaborationId: string;
|
123
|
+
username: string;
|
124
|
+
isOwner: boolean;
|
125
|
+
ownerEdSecret?: string;
|
126
|
+
contractAddress?: string;
|
127
|
+
ownerAddress?: string;
|
128
|
+
};
|
150
129
|
}
|
151
130
|
export interface IEditorSelectionData {
|
152
131
|
from: number;
|
@@ -1,11 +1,10 @@
|
|
1
1
|
import { DdocProps } from './types';
|
2
2
|
|
3
3
|
import * as Y from 'yjs';
|
4
|
-
export declare const useDdocEditor: ({ isPreviewMode, initialContent, enableCollaboration,
|
4
|
+
export declare const useDdocEditor: ({ isPreviewMode, initialContent, enableCollaboration, walletAddress, onChange, onCollaboratorChange, onCommentInteraction, ensResolutionUrl, onError, setCharacterCount, setWordCount, ipfsImageUploadFn, ddocId, enableIndexeddbSync, unFocused, zoomLevel, onInvalidContentError, ignoreCorruptedData, isPresentationMode, proExtensions, metadataProxyUrl, extensions: externalExtensions, onCopyHeadingLink, ipfsImageFetchFn, isConnected, activeModel, maxTokens, isAIAgentEnabled, collabConfig, }: Partial<DdocProps>) => {
|
5
5
|
editor: import('@tiptap/core').Editor | null;
|
6
6
|
isContentLoading: boolean;
|
7
7
|
ref: import('react').RefObject<HTMLDivElement>;
|
8
|
-
connect: (username: string | null | undefined, isEns?: boolean) => () => void;
|
9
8
|
ydoc: Y.Doc;
|
10
9
|
refreshYjsIndexedDbProvider: () => Promise<void>;
|
11
10
|
activeCommentId: string | null;
|
@@ -15,4 +14,5 @@ export declare const useDdocEditor: ({ isPreviewMode, initialContent, enableColl
|
|
15
14
|
setSlides: import('react').Dispatch<import('react').SetStateAction<string[]>>;
|
16
15
|
tocItems: any[];
|
17
16
|
setTocItems: import('react').Dispatch<import('react').SetStateAction<any[]>>;
|
17
|
+
terminateSession: () => void;
|
18
18
|
};
|