@hocuspocus/common 3.0.0-rc.0 → 3.0.6-rc.0
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/hocuspocus-common.cjs.map +1 -1
- package/dist/hocuspocus-common.esm.js.map +1 -1
- package/dist/packages/common/src/index.d.ts +4 -4
- package/dist/packages/extension-database/src/index.d.ts +1 -1
- package/dist/packages/extension-logger/src/index.d.ts +1 -1
- package/dist/packages/extension-redis/src/Redis.d.ts +6 -2
- package/dist/packages/extension-redis/src/index.d.ts +1 -1
- package/dist/packages/extension-sqlite/src/index.d.ts +1 -1
- package/dist/packages/provider/src/HocuspocusProvider.d.ts +14 -36
- package/dist/packages/provider/src/HocuspocusProviderWebsocket.d.ts +4 -8
- package/dist/packages/provider/src/IncomingMessage.d.ts +2 -2
- package/dist/packages/provider/src/MessageReceiver.d.ts +2 -4
- package/dist/packages/provider/src/MessageSender.d.ts +2 -2
- package/dist/packages/provider/src/OutgoingMessage.d.ts +2 -2
- package/dist/packages/provider/src/OutgoingMessages/AuthenticationMessage.d.ts +3 -3
- package/dist/packages/provider/src/OutgoingMessages/AwarenessMessage.d.ts +3 -3
- package/dist/packages/provider/src/OutgoingMessages/CloseMessage.d.ts +3 -3
- package/dist/packages/provider/src/OutgoingMessages/QueryAwarenessMessage.d.ts +3 -3
- package/dist/packages/provider/src/OutgoingMessages/StatelessMessage.d.ts +3 -3
- package/dist/packages/provider/src/OutgoingMessages/SyncStepOneMessage.d.ts +3 -3
- package/dist/packages/provider/src/OutgoingMessages/SyncStepTwoMessage.d.ts +3 -3
- package/dist/packages/provider/src/OutgoingMessages/UpdateMessage.d.ts +3 -3
- package/dist/packages/provider/src/index.d.ts +3 -5
- package/dist/packages/provider/src/types.d.ts +50 -10
- package/dist/packages/server/src/ClientConnection.d.ts +16 -8
- package/dist/packages/server/src/Connection.d.ts +14 -20
- package/dist/packages/server/src/DirectConnection.d.ts +4 -4
- package/dist/packages/server/src/Document.d.ts +2 -6
- package/dist/packages/server/src/Hocuspocus.d.ts +6 -15
- package/dist/packages/server/src/IncomingMessage.d.ts +4 -3
- package/dist/packages/server/src/MessageReceiver.d.ts +6 -8
- package/dist/packages/server/src/OutgoingMessage.d.ts +2 -1
- package/dist/packages/server/src/Server.d.ts +3 -3
- package/dist/packages/server/src/index.d.ts +9 -10
- package/dist/packages/server/src/types.d.ts +41 -13
- package/dist/packages/transformer/src/Prosemirror.d.ts +1 -1
- package/dist/packages/transformer/src/Tiptap.d.ts +1 -1
- package/dist/packages/transformer/src/index.d.ts +3 -3
- package/dist/playground/frontend/app/SocketContext.d.ts +2 -0
- package/dist/playground/frontend/next.config.d.ts +3 -0
- package/dist/tests/utils/index.d.ts +9 -9
- package/dist/tests/utils/newHocuspocusProvider.d.ts +2 -2
- package/package.json +2 -2
- package/src/index.ts +4 -4
- package/dist/packages/provider/src/TiptapCollabProvider.d.ts +0 -64
- package/dist/packages/provider/src/TiptapCollabProviderWebsocket.d.ts +0 -20
- package/dist/packages/server/src/Debugger.d.ts +0 -14
- package/dist/playground/frontend/vite.config.d.ts +0 -2
- package/dist/tests/server/getMessageLogs.d.ts +0 -1
- package/dist/tests/server/requiresAuthentication.d.ts +0 -1
- /package/dist/{playground/frontend/src/main.d.ts → tests/server/beforeSync.d.ts} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as encoding from 'lib0/encoding';
|
|
2
|
-
import type { OutgoingMessageArguments } from '../types.
|
|
3
|
-
import { MessageType } from '../types.
|
|
4
|
-
import { OutgoingMessage } from '../OutgoingMessage.
|
|
2
|
+
import type { OutgoingMessageArguments } from '../types.ts';
|
|
3
|
+
import { MessageType } from '../types.ts';
|
|
4
|
+
import { OutgoingMessage } from '../OutgoingMessage.ts';
|
|
5
5
|
export declare class QueryAwarenessMessage extends OutgoingMessage {
|
|
6
6
|
type: MessageType;
|
|
7
7
|
description: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { OutgoingMessageArguments } from '../types.
|
|
2
|
-
import { MessageType } from '../types.
|
|
3
|
-
import { OutgoingMessage } from '../OutgoingMessage.
|
|
1
|
+
import type { OutgoingMessageArguments } from '../types.ts';
|
|
2
|
+
import { MessageType } from '../types.ts';
|
|
3
|
+
import { OutgoingMessage } from '../OutgoingMessage.ts';
|
|
4
4
|
export declare class StatelessMessage extends OutgoingMessage {
|
|
5
5
|
type: MessageType;
|
|
6
6
|
description: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as encoding from 'lib0/encoding';
|
|
2
|
-
import type { OutgoingMessageArguments } from '../types.
|
|
3
|
-
import { MessageType } from '../types.
|
|
4
|
-
import { OutgoingMessage } from '../OutgoingMessage.
|
|
2
|
+
import type { OutgoingMessageArguments } from '../types.ts';
|
|
3
|
+
import { MessageType } from '../types.ts';
|
|
4
|
+
import { OutgoingMessage } from '../OutgoingMessage.ts';
|
|
5
5
|
export declare class SyncStepOneMessage extends OutgoingMessage {
|
|
6
6
|
type: MessageType;
|
|
7
7
|
description: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as encoding from 'lib0/encoding';
|
|
2
|
-
import type { OutgoingMessageArguments } from '../types.
|
|
3
|
-
import { MessageType } from '../types.
|
|
4
|
-
import { OutgoingMessage } from '../OutgoingMessage.
|
|
2
|
+
import type { OutgoingMessageArguments } from '../types.ts';
|
|
3
|
+
import { MessageType } from '../types.ts';
|
|
4
|
+
import { OutgoingMessage } from '../OutgoingMessage.ts';
|
|
5
5
|
export declare class SyncStepTwoMessage extends OutgoingMessage {
|
|
6
6
|
type: MessageType;
|
|
7
7
|
description: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { OutgoingMessageArguments } from '../types.
|
|
2
|
-
import { MessageType } from '../types.
|
|
3
|
-
import { OutgoingMessage } from '../OutgoingMessage.
|
|
1
|
+
import type { OutgoingMessageArguments } from '../types.ts';
|
|
2
|
+
import { MessageType } from '../types.ts';
|
|
3
|
+
import { OutgoingMessage } from '../OutgoingMessage.ts';
|
|
4
4
|
export declare class UpdateMessage extends OutgoingMessage {
|
|
5
5
|
type: MessageType;
|
|
6
6
|
description: string;
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
export * from './HocuspocusProvider.
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './
|
|
4
|
-
export * from './HocuspocusProviderWebsocket.js';
|
|
5
|
-
export * from './types.js';
|
|
1
|
+
export * from './HocuspocusProvider.ts';
|
|
2
|
+
export * from './HocuspocusProviderWebsocket.ts';
|
|
3
|
+
export * from './types.ts';
|
|
@@ -3,14 +3,14 @@ import type { Event, MessageEvent } from 'ws';
|
|
|
3
3
|
import type { Awareness } from 'y-protocols/awareness';
|
|
4
4
|
import type * as Y from 'yjs';
|
|
5
5
|
import type { CloseEvent } from '@hocuspocus/common';
|
|
6
|
-
import type { IncomingMessage } from './IncomingMessage.
|
|
7
|
-
import type { OutgoingMessage } from './OutgoingMessage.
|
|
8
|
-
import type { AuthenticationMessage } from './OutgoingMessages/AuthenticationMessage.
|
|
9
|
-
import type { AwarenessMessage } from './OutgoingMessages/AwarenessMessage.
|
|
10
|
-
import type { QueryAwarenessMessage } from './OutgoingMessages/QueryAwarenessMessage.
|
|
11
|
-
import type { SyncStepOneMessage } from './OutgoingMessages/SyncStepOneMessage.
|
|
12
|
-
import type { SyncStepTwoMessage } from './OutgoingMessages/SyncStepTwoMessage.
|
|
13
|
-
import type { UpdateMessage } from './OutgoingMessages/UpdateMessage.
|
|
6
|
+
import type { IncomingMessage } from './IncomingMessage.ts';
|
|
7
|
+
import type { OutgoingMessage } from './OutgoingMessage.ts';
|
|
8
|
+
import type { AuthenticationMessage } from './OutgoingMessages/AuthenticationMessage.ts';
|
|
9
|
+
import type { AwarenessMessage } from './OutgoingMessages/AwarenessMessage.ts';
|
|
10
|
+
import type { QueryAwarenessMessage } from './OutgoingMessages/QueryAwarenessMessage.ts';
|
|
11
|
+
import type { SyncStepOneMessage } from './OutgoingMessages/SyncStepOneMessage.ts';
|
|
12
|
+
import type { SyncStepTwoMessage } from './OutgoingMessages/SyncStepTwoMessage.ts';
|
|
13
|
+
import type { UpdateMessage } from './OutgoingMessages/UpdateMessage.ts';
|
|
14
14
|
export declare enum MessageType {
|
|
15
15
|
Sync = 0,
|
|
16
16
|
Awareness = 1,
|
|
@@ -88,14 +88,17 @@ export type TCollabThread<Data = any, CommentData = any> = {
|
|
|
88
88
|
id: string;
|
|
89
89
|
createdAt: number;
|
|
90
90
|
updatedAt: number;
|
|
91
|
+
deletedAt: number | null;
|
|
91
92
|
resolvedAt?: string;
|
|
92
93
|
comments: TCollabComment<CommentData>[];
|
|
94
|
+
deletedComments: TCollabComment<CommentData>[];
|
|
93
95
|
data: Data;
|
|
94
96
|
};
|
|
95
97
|
export type TCollabComment<Data = any> = {
|
|
96
98
|
id: string;
|
|
97
|
-
createdAt:
|
|
98
|
-
updatedAt:
|
|
99
|
+
createdAt: string;
|
|
100
|
+
updatedAt: string;
|
|
101
|
+
deletedAt?: string;
|
|
99
102
|
data: Data;
|
|
100
103
|
content: any;
|
|
101
104
|
};
|
|
@@ -144,3 +147,40 @@ export type THistoryDocumentRevertedEvent = {
|
|
|
144
147
|
event: 'document.reverted';
|
|
145
148
|
version: number;
|
|
146
149
|
};
|
|
150
|
+
export type DeleteCommentOptions = {
|
|
151
|
+
/**
|
|
152
|
+
* If `true`, the thread will also be deleted if the deleted comment was the first comment in the thread.
|
|
153
|
+
*/
|
|
154
|
+
deleteThread?: boolean;
|
|
155
|
+
/**
|
|
156
|
+
* If `true`, will remove the content of the deleted comment
|
|
157
|
+
*/
|
|
158
|
+
deleteContent?: boolean;
|
|
159
|
+
};
|
|
160
|
+
export type DeleteThreadOptions = {
|
|
161
|
+
/**
|
|
162
|
+
* If `true`, will remove the comments on the thread,
|
|
163
|
+
* otherwise will only mark the thread as deleted
|
|
164
|
+
* and keep the comments
|
|
165
|
+
* @default false
|
|
166
|
+
*/
|
|
167
|
+
deleteComments?: boolean;
|
|
168
|
+
/**
|
|
169
|
+
* If `true`, will forcefully remove the thread and all comments,
|
|
170
|
+
* otherwise will only mark the thread as deleted
|
|
171
|
+
* and keep the comments
|
|
172
|
+
* @default false
|
|
173
|
+
*/
|
|
174
|
+
force?: boolean;
|
|
175
|
+
};
|
|
176
|
+
/**
|
|
177
|
+
* The type of thread
|
|
178
|
+
*/
|
|
179
|
+
export type ThreadType = 'archived' | 'unarchived';
|
|
180
|
+
export type GetThreadsOptions = {
|
|
181
|
+
/**
|
|
182
|
+
* The types of threads to get
|
|
183
|
+
* @default ['unarchived']
|
|
184
|
+
*/
|
|
185
|
+
types?: Array<ThreadType>;
|
|
186
|
+
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { IncomingMessage } from 'http';
|
|
2
|
+
import { type CloseEvent } from '@hocuspocus/common';
|
|
2
3
|
import type WebSocket from 'ws';
|
|
3
|
-
import type
|
|
4
|
-
import type
|
|
5
|
-
import type {
|
|
6
|
-
import type { onDisconnectPayload } from './types.js';
|
|
4
|
+
import type Document from './Document.ts';
|
|
5
|
+
import type { Hocuspocus } from './Hocuspocus.ts';
|
|
6
|
+
import type { onDisconnectPayload } from './types.ts';
|
|
7
7
|
/**
|
|
8
8
|
* The `ClientConnection` class is responsible for handling an incoming WebSocket
|
|
9
9
|
*
|
|
@@ -15,7 +15,6 @@ export declare class ClientConnection {
|
|
|
15
15
|
private readonly request;
|
|
16
16
|
private readonly documentProvider;
|
|
17
17
|
private readonly hooks;
|
|
18
|
-
private readonly debuggerTool;
|
|
19
18
|
private readonly opts;
|
|
20
19
|
private readonly defaultContext;
|
|
21
20
|
private readonly documentConnections;
|
|
@@ -23,8 +22,10 @@ export declare class ClientConnection {
|
|
|
23
22
|
private readonly documentConnectionsEstablished;
|
|
24
23
|
private readonly hookPayloads;
|
|
25
24
|
private readonly callbacks;
|
|
26
|
-
private readonly closeIdleConnectionTimeout;
|
|
27
25
|
private readonly socketId;
|
|
26
|
+
timeout: number;
|
|
27
|
+
pingInterval: NodeJS.Timeout;
|
|
28
|
+
pongReceived: boolean;
|
|
28
29
|
/**
|
|
29
30
|
* The `ClientConnection` class receives incoming WebSocket connections,
|
|
30
31
|
* runs all hooks:
|
|
@@ -37,10 +38,17 @@ export declare class ClientConnection {
|
|
|
37
38
|
*/
|
|
38
39
|
constructor(websocket: WebSocket, request: IncomingMessage, documentProvider: {
|
|
39
40
|
createDocument: Hocuspocus['createDocument'];
|
|
40
|
-
}, hooks: Hocuspocus['hooks'],
|
|
41
|
-
requiresAuthentication: boolean;
|
|
41
|
+
}, hooks: Hocuspocus['hooks'], opts: {
|
|
42
42
|
timeout: number;
|
|
43
43
|
}, defaultContext?: any);
|
|
44
|
+
private handleWebsocketClose;
|
|
45
|
+
close(event?: CloseEvent): void;
|
|
46
|
+
handlePong: () => void;
|
|
47
|
+
/**
|
|
48
|
+
* Check if pong was received and close the connection otherwise
|
|
49
|
+
* @private
|
|
50
|
+
*/
|
|
51
|
+
private check;
|
|
44
52
|
/**
|
|
45
53
|
* Set a callback that will be triggered when the connection is closed
|
|
46
54
|
*/
|
|
@@ -1,30 +1,25 @@
|
|
|
1
1
|
import type { IncomingMessage as HTTPIncomingMessage } from 'http';
|
|
2
|
-
import
|
|
2
|
+
import { type CloseEvent } from '@hocuspocus/common';
|
|
3
3
|
import type WebSocket from 'ws';
|
|
4
|
-
import type
|
|
5
|
-
import type
|
|
6
|
-
import type { Debugger } from './Debugger.js';
|
|
7
|
-
import type { onStatelessPayload } from './types.js';
|
|
4
|
+
import type Document from './Document.ts';
|
|
5
|
+
import type { beforeSyncPayload, onStatelessPayload } from './types.ts';
|
|
8
6
|
export declare class Connection {
|
|
9
7
|
webSocket: WebSocket;
|
|
10
8
|
context: any;
|
|
11
9
|
document: Document;
|
|
12
|
-
pingInterval: NodeJS.Timeout;
|
|
13
|
-
pongReceived: boolean;
|
|
14
10
|
request: HTTPIncomingMessage;
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
callbacks: {
|
|
12
|
+
onClose: ((document: Document, event?: CloseEvent) => void)[];
|
|
13
|
+
beforeHandleMessage: (connection: Connection, update: Uint8Array) => Promise<void>;
|
|
14
|
+
beforeSync: (connection: Connection, payload: Pick<beforeSyncPayload, "type" | "payload">) => Promise<void>;
|
|
15
|
+
statelessCallback: (payload: onStatelessPayload) => Promise<void>;
|
|
16
|
+
};
|
|
17
17
|
socketId: string;
|
|
18
|
-
lock: AsyncLock;
|
|
19
18
|
readOnly: boolean;
|
|
20
|
-
logger: Debugger;
|
|
21
19
|
/**
|
|
22
20
|
* Constructor.
|
|
23
21
|
*/
|
|
24
|
-
constructor(connection: WebSocket, request: HTTPIncomingMessage, document: Document,
|
|
25
|
-
boundClose: (event?: CloseEvent) => void;
|
|
26
|
-
boundHandlePong: () => void;
|
|
27
|
-
handlePong(): void;
|
|
22
|
+
constructor(connection: WebSocket, request: HTTPIncomingMessage, document: Document, socketId: string, context: any, readOnly?: boolean);
|
|
28
23
|
/**
|
|
29
24
|
* Set a callback that will be triggered when the connection is closed
|
|
30
25
|
*/
|
|
@@ -37,6 +32,10 @@ export declare class Connection {
|
|
|
37
32
|
* Set a callback that will be triggered before an message is handled
|
|
38
33
|
*/
|
|
39
34
|
beforeHandleMessage(callback: (connection: Connection, update: Uint8Array) => Promise<any>): Connection;
|
|
35
|
+
/**
|
|
36
|
+
* Set a callback that will be triggered before a sync message is handled
|
|
37
|
+
*/
|
|
38
|
+
beforeSync(callback: (connection: Connection, payload: Pick<beforeSyncPayload, 'type' | 'payload'>) => Promise<any>): Connection;
|
|
40
39
|
/**
|
|
41
40
|
* Send the given message
|
|
42
41
|
*/
|
|
@@ -49,11 +48,6 @@ export declare class Connection {
|
|
|
49
48
|
* Graceful wrapper around the WebSocket close method.
|
|
50
49
|
*/
|
|
51
50
|
close(event?: CloseEvent): void;
|
|
52
|
-
/**
|
|
53
|
-
* Check if pong was received and close the connection otherwise
|
|
54
|
-
* @private
|
|
55
|
-
*/
|
|
56
|
-
private check;
|
|
57
51
|
/**
|
|
58
52
|
* Send the current document awareness to the client, if any
|
|
59
53
|
* @private
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type Document from './Document.
|
|
2
|
-
import type { Hocuspocus } from './Hocuspocus.
|
|
3
|
-
import type { DirectConnection as DirectConnectionInterface } from './types.
|
|
1
|
+
import type Document from './Document.ts';
|
|
2
|
+
import type { Hocuspocus } from './Hocuspocus.ts';
|
|
3
|
+
import type { DirectConnection as DirectConnectionInterface } from './types.ts';
|
|
4
4
|
export declare class DirectConnection implements DirectConnectionInterface {
|
|
5
5
|
document: Document | null;
|
|
6
6
|
instance: Hocuspocus;
|
|
@@ -9,6 +9,6 @@ export declare class DirectConnection implements DirectConnectionInterface {
|
|
|
9
9
|
* Constructor.
|
|
10
10
|
*/
|
|
11
11
|
constructor(document: Document, instance: Hocuspocus, context?: any);
|
|
12
|
-
transact(transaction: (document: Document) => void
|
|
12
|
+
transact(transaction: (document: Document) => void): Promise<void>;
|
|
13
13
|
disconnect(): Promise<void>;
|
|
14
14
|
}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import type WebSocket from 'ws';
|
|
2
2
|
import { Awareness } from 'y-protocols/awareness';
|
|
3
3
|
import { Doc } from 'yjs';
|
|
4
|
-
import type
|
|
5
|
-
import type Connection from './Connection.js';
|
|
6
|
-
import type { Debugger } from './Debugger.js';
|
|
4
|
+
import type Connection from './Connection.ts';
|
|
7
5
|
export declare class Document extends Doc {
|
|
8
6
|
awareness: Awareness;
|
|
9
7
|
callbacks: {
|
|
@@ -16,14 +14,12 @@ export declare class Document extends Doc {
|
|
|
16
14
|
}>;
|
|
17
15
|
directConnectionsCount: number;
|
|
18
16
|
name: string;
|
|
19
|
-
mux: mutex;
|
|
20
|
-
logger?: Debugger;
|
|
21
17
|
isLoading: boolean;
|
|
22
18
|
isDestroyed: boolean;
|
|
23
19
|
/**
|
|
24
20
|
* Constructor.
|
|
25
21
|
*/
|
|
26
|
-
constructor(name: string,
|
|
22
|
+
constructor(name: string, yDocOptions?: object);
|
|
27
23
|
/**
|
|
28
24
|
* Check if the Document (XMLFragment or Map) is empty
|
|
29
25
|
*/
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import type { IncomingMessage } from 'http';
|
|
2
2
|
import type WebSocket from 'ws';
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import type { Configuration, ConnectionConfiguration, HookName, HookPayloadByName, onStoreDocumentPayload } from './types.js';
|
|
3
|
+
import { DirectConnection } from './DirectConnection.ts';
|
|
4
|
+
import Document from './Document.ts';
|
|
5
|
+
import type { Server } from './Server.ts';
|
|
6
|
+
import type { Configuration, ConnectionConfiguration, HookName, HookPayloadByName, onStoreDocumentPayload } from './types.ts';
|
|
8
7
|
export declare const defaultConfiguration: {
|
|
9
8
|
name: null;
|
|
10
9
|
timeout: number;
|
|
@@ -22,7 +21,6 @@ export declare class Hocuspocus {
|
|
|
22
21
|
loadingDocuments: Map<string, Promise<Document>>;
|
|
23
22
|
documents: Map<string, Document>;
|
|
24
23
|
server?: Server;
|
|
25
|
-
debugger: Debugger;
|
|
26
24
|
debouncer: {
|
|
27
25
|
debounce: (id: string, func: Function, debounce: number, maxDebounce: number) => any;
|
|
28
26
|
isDebounced: (id: string) => boolean;
|
|
@@ -33,7 +31,6 @@ export declare class Hocuspocus {
|
|
|
33
31
|
* Configure Hocuspocus
|
|
34
32
|
*/
|
|
35
33
|
configure(configuration: Partial<Configuration>): Hocuspocus;
|
|
36
|
-
get requiresAuthentication(): boolean;
|
|
37
34
|
/**
|
|
38
35
|
* Get the total number of active documents
|
|
39
36
|
*/
|
|
@@ -68,19 +65,13 @@ export declare class Hocuspocus {
|
|
|
68
65
|
* Create a new document by the given request
|
|
69
66
|
*/
|
|
70
67
|
createDocument(documentName: string, request: Partial<Pick<IncomingMessage, 'headers' | 'url'>>, socketId: string, connection: ConnectionConfiguration, context?: any): Promise<Document>;
|
|
71
|
-
loadDocument(documentName: string, request: Partial<Pick<IncomingMessage, 'headers' | 'url'>>, socketId: string,
|
|
68
|
+
loadDocument(documentName: string, request: Partial<Pick<IncomingMessage, 'headers' | 'url'>>, socketId: string, connectionConfig: ConnectionConfiguration, context?: any): Promise<Document>;
|
|
72
69
|
storeDocumentHooks(document: Document, hookPayload: onStoreDocumentPayload, immediately?: boolean): any;
|
|
73
70
|
/**
|
|
74
71
|
* Run the given hook on all configured extensions.
|
|
75
72
|
* Runs the given callback after each hook.
|
|
76
73
|
*/
|
|
77
74
|
hooks<T extends HookName>(name: T, payload: HookPayloadByName[T], callback?: Function | null): Promise<any>;
|
|
78
|
-
unloadDocument(document: Document):
|
|
79
|
-
enableDebugging(): void;
|
|
80
|
-
enableMessageLogging(): void;
|
|
81
|
-
disableLogging(): void;
|
|
82
|
-
disableDebugging(): void;
|
|
83
|
-
flushMessageLogs(): this;
|
|
84
|
-
getMessageLogs(): any[];
|
|
75
|
+
unloadDocument(document: Document): Promise<any>;
|
|
85
76
|
openDirectConnection(documentName: string, context?: any): Promise<DirectConnection>;
|
|
86
77
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Decoder } from 'lib0/decoding';
|
|
2
2
|
import type { Encoder } from 'lib0/encoding';
|
|
3
|
-
import type { MessageType } from './types.
|
|
3
|
+
import type { MessageType } from './types.ts';
|
|
4
4
|
export declare class IncomingMessage {
|
|
5
5
|
/**
|
|
6
6
|
* Access to the received message.
|
|
@@ -14,10 +14,11 @@ export declare class IncomingMessage {
|
|
|
14
14
|
private encoderInternal?;
|
|
15
15
|
constructor(input: any);
|
|
16
16
|
get encoder(): Encoder;
|
|
17
|
-
readVarUint8Array(): Uint8Array
|
|
17
|
+
readVarUint8Array(): Uint8Array<ArrayBufferLike>;
|
|
18
|
+
peekVarUint8Array(): Uint8Array<ArrayBufferLike>;
|
|
18
19
|
readVarUint(): number;
|
|
19
20
|
readVarString(): string;
|
|
20
|
-
toUint8Array(): Uint8Array
|
|
21
|
+
toUint8Array(): Uint8Array<ArrayBufferLike>;
|
|
21
22
|
writeVarUint(type: MessageType): void;
|
|
22
23
|
writeVarString(string: string): void;
|
|
23
24
|
get length(): number;
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import type Connection from './Connection.
|
|
2
|
-
import type
|
|
3
|
-
import type
|
|
4
|
-
import type { IncomingMessage } from './IncomingMessage.js';
|
|
1
|
+
import type Connection from './Connection.ts';
|
|
2
|
+
import type Document from './Document.ts';
|
|
3
|
+
import type { IncomingMessage } from './IncomingMessage.ts';
|
|
5
4
|
export declare class MessageReceiver {
|
|
6
5
|
message: IncomingMessage;
|
|
7
|
-
logger: Debugger;
|
|
8
6
|
defaultTransactionOrigin?: string;
|
|
9
|
-
constructor(message: IncomingMessage,
|
|
10
|
-
apply(document: Document, connection?: Connection, reply?: (message: Uint8Array) => void): void
|
|
11
|
-
readSyncMessage(message: IncomingMessage, document: Document, connection?: Connection, reply?: (message: Uint8Array) => void, requestFirstSync?: boolean): 0 | 1 | 2
|
|
7
|
+
constructor(message: IncomingMessage, defaultTransactionOrigin?: string);
|
|
8
|
+
apply(document: Document, connection?: Connection, reply?: (message: Uint8Array) => void): Promise<void>;
|
|
9
|
+
readSyncMessage(message: IncomingMessage, document: Document, connection?: Connection, reply?: (message: Uint8Array) => void, requestFirstSync?: boolean): Promise<0 | 1 | 2>;
|
|
12
10
|
applyQueryAwarenessMessage(document: Document, reply?: (message: Uint8Array) => void): void;
|
|
13
11
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Encoder } from 'lib0/encoding';
|
|
2
2
|
import type { Awareness } from 'y-protocols/awareness';
|
|
3
|
-
import type Document from './Document.
|
|
3
|
+
import type Document from './Document.ts';
|
|
4
4
|
export declare class OutgoingMessage {
|
|
5
5
|
encoder: Encoder;
|
|
6
6
|
type?: number;
|
|
@@ -17,5 +17,6 @@ export declare class OutgoingMessage {
|
|
|
17
17
|
writeStateless(payload: string): OutgoingMessage;
|
|
18
18
|
writeBroadcastStateless(payload: string): OutgoingMessage;
|
|
19
19
|
writeSyncStatus(updateSaved: boolean): OutgoingMessage;
|
|
20
|
+
writeCloseMessage(reason: string): OutgoingMessage;
|
|
20
21
|
toUint8Array(): Uint8Array;
|
|
21
22
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { IncomingMessage, Server as HTTPServer, ServerResponse } from 'http';
|
|
2
|
-
import type { AddressInfo } from 'ws';
|
|
3
2
|
import { WebSocketServer } from 'ws';
|
|
4
|
-
import {
|
|
3
|
+
import type { AddressInfo, ServerOptions } from 'ws';
|
|
4
|
+
import { Hocuspocus } from './Hocuspocus.ts';
|
|
5
5
|
import type { Configuration } from './types';
|
|
6
6
|
export interface ServerConfiguration extends Configuration {
|
|
7
7
|
port?: number;
|
|
@@ -18,7 +18,7 @@ export declare class Server {
|
|
|
18
18
|
webSocketServer: WebSocketServer;
|
|
19
19
|
hocuspocus: Hocuspocus;
|
|
20
20
|
configuration: ServerConfiguration;
|
|
21
|
-
constructor(configuration?: Partial<ServerConfiguration
|
|
21
|
+
constructor(configuration?: Partial<ServerConfiguration>, websocketOptions?: ServerOptions);
|
|
22
22
|
setupWebsocketConnection: () => void;
|
|
23
23
|
setupHttpUpgrade: () => void;
|
|
24
24
|
requestHandler: (request: IncomingMessage, response: ServerResponse) => Promise<void>;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
export * from './Connection.
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './
|
|
4
|
-
export * from './
|
|
5
|
-
export * from './
|
|
6
|
-
export * from './
|
|
7
|
-
export * from './
|
|
8
|
-
export * from './
|
|
9
|
-
export * from './
|
|
10
|
-
export * from './util/debounce.js';
|
|
1
|
+
export * from './Connection.ts';
|
|
2
|
+
export * from './Document.ts';
|
|
3
|
+
export * from './Hocuspocus.ts';
|
|
4
|
+
export * from './IncomingMessage.ts';
|
|
5
|
+
export * from './MessageReceiver.ts';
|
|
6
|
+
export * from './OutgoingMessage.ts';
|
|
7
|
+
export * from './Server.ts';
|
|
8
|
+
export * from './types.ts';
|
|
9
|
+
export * from './util/debounce.ts';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { IncomingHttpHeaders, IncomingMessage, ServerResponse } from 'http';
|
|
2
2
|
import type { URLSearchParams } from 'url';
|
|
3
3
|
import type { Awareness } from 'y-protocols/awareness';
|
|
4
|
-
import type Connection from './Connection.
|
|
5
|
-
import type Document from './Document.
|
|
6
|
-
import type { Hocuspocus } from './Hocuspocus.
|
|
4
|
+
import type Connection from './Connection.ts';
|
|
5
|
+
import type Document from './Document.ts';
|
|
6
|
+
import type { Hocuspocus } from './Hocuspocus.ts';
|
|
7
7
|
export declare enum MessageType {
|
|
8
8
|
Unknown = -1,
|
|
9
9
|
Sync = 0,
|
|
@@ -23,7 +23,6 @@ export interface AwarenessUpdate {
|
|
|
23
23
|
}
|
|
24
24
|
export interface ConnectionConfiguration {
|
|
25
25
|
readOnly: boolean;
|
|
26
|
-
requiresAuthentication: boolean;
|
|
27
26
|
isAuthenticated: boolean;
|
|
28
27
|
}
|
|
29
28
|
export interface Extension {
|
|
@@ -39,6 +38,7 @@ export interface Extension {
|
|
|
39
38
|
onLoadDocument?(data: onLoadDocumentPayload): Promise<any>;
|
|
40
39
|
afterLoadDocument?(data: afterLoadDocumentPayload): Promise<any>;
|
|
41
40
|
beforeHandleMessage?(data: beforeHandleMessagePayload): Promise<any>;
|
|
41
|
+
beforeSync?(data: beforeSyncPayload): Promise<any>;
|
|
42
42
|
beforeBroadcastStateless?(data: beforeBroadcastStatelessPayload): Promise<any>;
|
|
43
43
|
onStateless?(payload: onStatelessPayload): Promise<any>;
|
|
44
44
|
onChange?(data: onChangePayload): Promise<any>;
|
|
@@ -47,10 +47,11 @@ export interface Extension {
|
|
|
47
47
|
onAwarenessUpdate?(data: onAwarenessUpdatePayload): Promise<any>;
|
|
48
48
|
onRequest?(data: onRequestPayload): Promise<any>;
|
|
49
49
|
onDisconnect?(data: onDisconnectPayload): Promise<any>;
|
|
50
|
+
beforeUnloadDocument?(data: beforeUnloadDocumentPayload): Promise<any>;
|
|
50
51
|
afterUnloadDocument?(data: afterUnloadDocumentPayload): Promise<any>;
|
|
51
52
|
onDestroy?(data: onDestroyPayload): Promise<any>;
|
|
52
53
|
}
|
|
53
|
-
export type HookName = 'onConfigure' | 'onListen' | 'onUpgrade' | 'onConnect' | 'connected' | 'onAuthenticate' | 'onCreateDocument' | 'onLoadDocument' | 'afterLoadDocument' | 'beforeHandleMessage' | 'beforeBroadcastStateless' | 'onStateless' | 'onChange' | 'onStoreDocument' | 'afterStoreDocument' | 'onAwarenessUpdate' | 'onRequest' | 'onDisconnect' | 'afterUnloadDocument' | 'onDestroy';
|
|
54
|
+
export type HookName = 'onConfigure' | 'onListen' | 'onUpgrade' | 'onConnect' | 'connected' | 'onAuthenticate' | 'onCreateDocument' | 'onLoadDocument' | 'afterLoadDocument' | 'beforeHandleMessage' | 'beforeBroadcastStateless' | 'beforeSync' | 'onStateless' | 'onChange' | 'onStoreDocument' | 'afterStoreDocument' | 'onAwarenessUpdate' | 'onRequest' | 'onDisconnect' | 'beforeUnloadDocument' | 'afterUnloadDocument' | 'onDestroy';
|
|
54
55
|
export type HookPayloadByName = {
|
|
55
56
|
onConfigure: onConfigurePayload;
|
|
56
57
|
onListen: onListenPayload;
|
|
@@ -63,6 +64,7 @@ export type HookPayloadByName = {
|
|
|
63
64
|
afterLoadDocument: afterLoadDocumentPayload;
|
|
64
65
|
beforeHandleMessage: beforeHandleMessagePayload;
|
|
65
66
|
beforeBroadcastStateless: beforeBroadcastStatelessPayload;
|
|
67
|
+
beforeSync: beforeSyncPayload;
|
|
66
68
|
onStateless: onStatelessPayload;
|
|
67
69
|
onChange: onChangePayload;
|
|
68
70
|
onStoreDocument: onStoreDocumentPayload;
|
|
@@ -71,6 +73,7 @@ export type HookPayloadByName = {
|
|
|
71
73
|
onRequest: onRequestPayload;
|
|
72
74
|
onDisconnect: onDisconnectPayload;
|
|
73
75
|
afterUnloadDocument: afterUnloadDocumentPayload;
|
|
76
|
+
beforeUnloadDocument: beforeUnloadDocumentPayload;
|
|
74
77
|
onDestroy: onDestroyPayload;
|
|
75
78
|
};
|
|
76
79
|
export interface Configuration extends Extension {
|
|
@@ -130,7 +133,7 @@ export interface onAuthenticatePayload {
|
|
|
130
133
|
request: IncomingMessage;
|
|
131
134
|
socketId: string;
|
|
132
135
|
token: string;
|
|
133
|
-
|
|
136
|
+
connectionConfig: ConnectionConfiguration;
|
|
134
137
|
}
|
|
135
138
|
export interface onCreateDocumentPayload {
|
|
136
139
|
context: any;
|
|
@@ -139,7 +142,7 @@ export interface onCreateDocumentPayload {
|
|
|
139
142
|
requestHeaders: IncomingHttpHeaders;
|
|
140
143
|
requestParameters: URLSearchParams;
|
|
141
144
|
socketId: string;
|
|
142
|
-
|
|
145
|
+
connectionConfig: ConnectionConfiguration;
|
|
143
146
|
}
|
|
144
147
|
export interface onConnectPayload {
|
|
145
148
|
context: any;
|
|
@@ -149,7 +152,7 @@ export interface onConnectPayload {
|
|
|
149
152
|
requestHeaders: IncomingHttpHeaders;
|
|
150
153
|
requestParameters: URLSearchParams;
|
|
151
154
|
socketId: string;
|
|
152
|
-
|
|
155
|
+
connectionConfig: ConnectionConfiguration;
|
|
153
156
|
}
|
|
154
157
|
export interface connectedPayload {
|
|
155
158
|
context: any;
|
|
@@ -159,8 +162,8 @@ export interface connectedPayload {
|
|
|
159
162
|
requestHeaders: IncomingHttpHeaders;
|
|
160
163
|
requestParameters: URLSearchParams;
|
|
161
164
|
socketId: string;
|
|
162
|
-
|
|
163
|
-
|
|
165
|
+
connectionConfig: ConnectionConfiguration;
|
|
166
|
+
connection: Connection;
|
|
164
167
|
}
|
|
165
168
|
export interface onLoadDocumentPayload {
|
|
166
169
|
context: any;
|
|
@@ -170,7 +173,7 @@ export interface onLoadDocumentPayload {
|
|
|
170
173
|
requestHeaders: IncomingHttpHeaders;
|
|
171
174
|
requestParameters: URLSearchParams;
|
|
172
175
|
socketId: string;
|
|
173
|
-
|
|
176
|
+
connectionConfig: ConnectionConfiguration;
|
|
174
177
|
}
|
|
175
178
|
export interface afterLoadDocumentPayload {
|
|
176
179
|
context: any;
|
|
@@ -180,7 +183,7 @@ export interface afterLoadDocumentPayload {
|
|
|
180
183
|
requestHeaders: IncomingHttpHeaders;
|
|
181
184
|
requestParameters: URLSearchParams;
|
|
182
185
|
socketId: string;
|
|
183
|
-
|
|
186
|
+
connectionConfig: ConnectionConfiguration;
|
|
184
187
|
}
|
|
185
188
|
export interface onChangePayload {
|
|
186
189
|
clientsCount: number;
|
|
@@ -206,6 +209,27 @@ export interface beforeHandleMessagePayload {
|
|
|
206
209
|
socketId: string;
|
|
207
210
|
connection: Connection;
|
|
208
211
|
}
|
|
212
|
+
export interface beforeSyncPayload {
|
|
213
|
+
clientsCount: number;
|
|
214
|
+
context: any;
|
|
215
|
+
document: Document;
|
|
216
|
+
documentName: string;
|
|
217
|
+
connection: Connection;
|
|
218
|
+
/**
|
|
219
|
+
* The y-protocols/sync message type
|
|
220
|
+
* @example
|
|
221
|
+
* 0: SyncStep1
|
|
222
|
+
* 1: SyncStep2
|
|
223
|
+
* 2: YjsUpdate
|
|
224
|
+
*
|
|
225
|
+
* @see https://github.com/yjs/y-protocols/blob/master/sync.js#L13-L40
|
|
226
|
+
*/
|
|
227
|
+
type: number;
|
|
228
|
+
/**
|
|
229
|
+
* The payload of the y-sync message.
|
|
230
|
+
*/
|
|
231
|
+
payload: Uint8Array;
|
|
232
|
+
}
|
|
209
233
|
export interface beforeBroadcastStatelessPayload {
|
|
210
234
|
document: Document;
|
|
211
235
|
documentName: string;
|
|
@@ -250,7 +274,7 @@ export interface fetchPayload {
|
|
|
250
274
|
requestHeaders: IncomingHttpHeaders;
|
|
251
275
|
requestParameters: URLSearchParams;
|
|
252
276
|
socketId: string;
|
|
253
|
-
|
|
277
|
+
connectionConfig: ConnectionConfiguration;
|
|
254
278
|
}
|
|
255
279
|
export interface storePayload extends onStoreDocumentPayload {
|
|
256
280
|
state: Buffer;
|
|
@@ -293,6 +317,10 @@ export interface afterUnloadDocumentPayload {
|
|
|
293
317
|
instance: Hocuspocus;
|
|
294
318
|
documentName: string;
|
|
295
319
|
}
|
|
320
|
+
export interface beforeUnloadDocumentPayload {
|
|
321
|
+
instance: Hocuspocus;
|
|
322
|
+
documentName: string;
|
|
323
|
+
}
|
|
296
324
|
export interface DirectConnection {
|
|
297
325
|
transact(transaction: (document: Document) => void): Promise<void>;
|
|
298
326
|
disconnect(): void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Doc } from 'yjs';
|
|
2
2
|
import { Schema } from '@tiptap/pm/model';
|
|
3
|
-
import type { Transformer } from './types.
|
|
3
|
+
import type { Transformer } from './types.ts';
|
|
4
4
|
declare class Prosemirror implements Transformer {
|
|
5
5
|
defaultSchema: Schema;
|
|
6
6
|
schema(schema: Schema): Prosemirror;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Doc } from 'yjs';
|
|
2
2
|
import type { Extensions } from '@tiptap/core';
|
|
3
|
-
import type { Transformer } from './types.
|
|
3
|
+
import type { Transformer } from './types.ts';
|
|
4
4
|
export declare class Tiptap implements Transformer {
|
|
5
5
|
defaultExtensions: Extensions;
|
|
6
6
|
extensions(extensions: Extensions): Tiptap;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './Prosemirror.
|
|
2
|
-
export * from './Tiptap.
|
|
3
|
-
export * from './types.
|
|
1
|
+
export * from './Prosemirror.ts';
|
|
2
|
+
export * from './Tiptap.ts';
|
|
3
|
+
export * from './types.ts';
|