@fileverse-dev/ddoc 2.3.0-patch-13-customisation-4 → 2.3.0-rtc-patch-2
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/{ccip-iE3tr7jb.mjs → ccip-CBrV9CCB.mjs} +1 -1
- package/dist/{index-DnFRu9cp.mjs → index-CjlFbMdx.mjs} +45257 -37243
- package/dist/index.es.js +1 -1
- package/dist/package/extensions/mardown-paste-handler/index.d.ts +1 -0
- package/dist/package/extensions/sync-cursor.d.ts +28 -0
- package/dist/package/hooks/use-headless-editor.d.ts +4 -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 -0
- 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
@@ -18,6 +18,7 @@ declare const MarkdownPasteHandler: (ipfsImageUploadFn?: (file: File) => Promise
|
|
18
18
|
url: string;
|
19
19
|
file: File;
|
20
20
|
}>) => Extension<any, any>;
|
21
|
+
export declare function handleMarkdownContent(view: any, content: string, ipfsImageUploadFn?: (file: File) => Promise<IpfsImageUploadResponse>): Promise<void>;
|
21
22
|
export default MarkdownPasteHandler;
|
22
23
|
export declare function searchForSecureImageNodeAndEmbedImageContent(originalDoc: PMNode, ipfsImageFetchFn?: (_data: IpfsImageFetchPayload) => Promise<{
|
23
24
|
url: string;
|
@@ -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 {};
|
@@ -1,4 +1,6 @@
|
|
1
1
|
import { Editor, JSONContent } from '@tiptap/react';
|
2
|
+
import { handleMarkdownContent } from '../extensions/mardown-paste-handler';
|
3
|
+
import { IpfsImageUploadResponse } from '../types';
|
2
4
|
|
3
5
|
import * as Y from 'yjs';
|
4
6
|
export declare const useHeadlessEditor: () => {
|
@@ -13,4 +15,6 @@ export declare const useHeadlessEditor: () => {
|
|
13
15
|
};
|
14
16
|
downloadContentAsMd: (content: string | string[] | JSONContent, title: string) => Promise<void>;
|
15
17
|
mergeYjsUpdates: (contents: string[]) => string;
|
18
|
+
handleMarkdownContent: typeof handleMarkdownContent;
|
19
|
+
getYjsContentFromMarkdown: (file: File, ipfsImageUploadFn: (file: File) => Promise<IpfsImageUploadResponse>) => Promise<string | null>;
|
16
20
|
};
|
@@ -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
@@ -142,6 +142,20 @@ export interface DdocProps extends CommentAccountProps {
|
|
142
142
|
activeModel?: CustomModel;
|
143
143
|
maxTokens?: number;
|
144
144
|
isAIAgentEnabled?: boolean;
|
145
|
+
collaborationKey?: CryptoKey | null;
|
146
|
+
collaborationKeyPair?: {
|
147
|
+
publicKey: string;
|
148
|
+
privateKey: string;
|
149
|
+
};
|
150
|
+
collabConfig?: {
|
151
|
+
roomKey: string;
|
152
|
+
collaborationId: string;
|
153
|
+
username: string;
|
154
|
+
isOwner: boolean;
|
155
|
+
ownerEdSecret?: string;
|
156
|
+
contractAddress?: string;
|
157
|
+
ownerAddress?: string;
|
158
|
+
};
|
145
159
|
/**
|
146
160
|
* Document styling configuration
|
147
161
|
* @description Customize the appearance of the document editor
|
@@ -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
|
};
|