@hocuspocus/common 3.0.0-rc.0 → 3.0.4-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/auth.d.ts +1 -1
- package/dist/packages/extension-redis/src/Redis.d.ts +8 -2
- package/dist/packages/extension-throttle/src/index.d.ts +1 -0
- package/dist/packages/extension-webhook/src/index.d.ts +1 -0
- package/dist/packages/provider/src/HocuspocusProvider.d.ts +11 -33
- package/dist/packages/provider/src/HocuspocusProviderWebsocket.d.ts +0 -4
- package/dist/packages/provider/src/MessageReceiver.d.ts +0 -2
- package/dist/packages/provider/src/index.d.ts +0 -2
- package/dist/packages/provider/src/types.d.ts +42 -2
- package/dist/packages/server/src/ClientConnection.d.ts +15 -5
- package/dist/packages/server/src/Connection.d.ts +3 -17
- package/dist/packages/server/src/DirectConnection.d.ts +1 -1
- package/dist/packages/server/src/Document.d.ts +1 -5
- package/dist/packages/server/src/Hocuspocus.d.ts +3 -11
- package/dist/packages/server/src/MessageReceiver.d.ts +1 -3
- package/dist/packages/server/src/OutgoingMessage.d.ts +1 -0
- package/dist/packages/server/src/Server.d.ts +3 -2
- package/dist/packages/server/src/index.d.ts +0 -1
- package/dist/packages/server/src/types.d.ts +20 -11
- package/dist/packages/server/src/util/getParameters.d.ts +2 -0
- package/dist/tests/utils/newHocuspocusProvider.d.ts +2 -2
- package/dist/tests/utils/newHocuspocusProviderWebsocket.d.ts +1 -1
- package/package.json +1 -1
- 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/tests/server/getMessageLogs.d.ts +0 -1
- package/dist/tests/server/requiresAuthentication.d.ts +0 -1
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
1
3
|
import type { IncomingMessage } from 'http';
|
|
4
|
+
import { type CloseEvent } from '@hocuspocus/common';
|
|
2
5
|
import type WebSocket from 'ws';
|
|
3
|
-
import type { Debugger } from './Debugger.js';
|
|
4
6
|
import type Document from './Document.js';
|
|
5
7
|
import type { Hocuspocus } from './Hocuspocus.js';
|
|
6
8
|
import type { onDisconnectPayload } from './types.js';
|
|
@@ -15,7 +17,6 @@ export declare class ClientConnection {
|
|
|
15
17
|
private readonly request;
|
|
16
18
|
private readonly documentProvider;
|
|
17
19
|
private readonly hooks;
|
|
18
|
-
private readonly debuggerTool;
|
|
19
20
|
private readonly opts;
|
|
20
21
|
private readonly defaultContext;
|
|
21
22
|
private readonly documentConnections;
|
|
@@ -23,8 +24,10 @@ export declare class ClientConnection {
|
|
|
23
24
|
private readonly documentConnectionsEstablished;
|
|
24
25
|
private readonly hookPayloads;
|
|
25
26
|
private readonly callbacks;
|
|
26
|
-
private readonly closeIdleConnectionTimeout;
|
|
27
27
|
private readonly socketId;
|
|
28
|
+
timeout: number;
|
|
29
|
+
pingInterval: NodeJS.Timeout;
|
|
30
|
+
pongReceived: boolean;
|
|
28
31
|
/**
|
|
29
32
|
* The `ClientConnection` class receives incoming WebSocket connections,
|
|
30
33
|
* runs all hooks:
|
|
@@ -37,10 +40,17 @@ export declare class ClientConnection {
|
|
|
37
40
|
*/
|
|
38
41
|
constructor(websocket: WebSocket, request: IncomingMessage, documentProvider: {
|
|
39
42
|
createDocument: Hocuspocus['createDocument'];
|
|
40
|
-
}, hooks: Hocuspocus['hooks'],
|
|
41
|
-
requiresAuthentication: boolean;
|
|
43
|
+
}, hooks: Hocuspocus['hooks'], opts: {
|
|
42
44
|
timeout: number;
|
|
43
45
|
}, defaultContext?: any);
|
|
46
|
+
private handleWebsocketClose;
|
|
47
|
+
close(event?: CloseEvent): void;
|
|
48
|
+
handlePong: () => void;
|
|
49
|
+
/**
|
|
50
|
+
* Check if pong was received and close the connection otherwise
|
|
51
|
+
* @private
|
|
52
|
+
*/
|
|
53
|
+
private check;
|
|
44
54
|
/**
|
|
45
55
|
* Set a callback that will be triggered when the connection is closed
|
|
46
56
|
*/
|
|
@@ -1,30 +1,21 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
1
2
|
import type { IncomingMessage as HTTPIncomingMessage } from 'http';
|
|
2
|
-
import AsyncLock from 'async-lock';
|
|
3
3
|
import type WebSocket from 'ws';
|
|
4
|
-
import type
|
|
4
|
+
import { type CloseEvent } from '@hocuspocus/common';
|
|
5
5
|
import type Document from './Document.js';
|
|
6
|
-
import type { Debugger } from './Debugger.js';
|
|
7
6
|
import type { onStatelessPayload } from './types.js';
|
|
8
7
|
export declare class Connection {
|
|
9
8
|
webSocket: WebSocket;
|
|
10
9
|
context: any;
|
|
11
10
|
document: Document;
|
|
12
|
-
pingInterval: NodeJS.Timeout;
|
|
13
|
-
pongReceived: boolean;
|
|
14
11
|
request: HTTPIncomingMessage;
|
|
15
|
-
timeout: number;
|
|
16
12
|
callbacks: any;
|
|
17
13
|
socketId: string;
|
|
18
|
-
lock: AsyncLock;
|
|
19
14
|
readOnly: boolean;
|
|
20
|
-
logger: Debugger;
|
|
21
15
|
/**
|
|
22
16
|
* Constructor.
|
|
23
17
|
*/
|
|
24
|
-
constructor(connection: WebSocket, request: HTTPIncomingMessage, document: Document,
|
|
25
|
-
boundClose: (event?: CloseEvent) => void;
|
|
26
|
-
boundHandlePong: () => void;
|
|
27
|
-
handlePong(): void;
|
|
18
|
+
constructor(connection: WebSocket, request: HTTPIncomingMessage, document: Document, socketId: string, context: any, readOnly?: boolean);
|
|
28
19
|
/**
|
|
29
20
|
* Set a callback that will be triggered when the connection is closed
|
|
30
21
|
*/
|
|
@@ -49,11 +40,6 @@ export declare class Connection {
|
|
|
49
40
|
* Graceful wrapper around the WebSocket close method.
|
|
50
41
|
*/
|
|
51
42
|
close(event?: CloseEvent): void;
|
|
52
|
-
/**
|
|
53
|
-
* Check if pong was received and close the connection otherwise
|
|
54
|
-
* @private
|
|
55
|
-
*/
|
|
56
|
-
private check;
|
|
57
43
|
/**
|
|
58
44
|
* Send the current document awareness to the client, if any
|
|
59
45
|
* @private
|
|
@@ -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 { mutex } from 'lib0/mutex.js';
|
|
5
4
|
import type Connection from './Connection.js';
|
|
6
|
-
import type { Debugger } from './Debugger.js';
|
|
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,7 +1,7 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
1
2
|
import type { IncomingMessage } from 'http';
|
|
2
3
|
import type WebSocket from 'ws';
|
|
3
4
|
import type { Server } from './Server.js';
|
|
4
|
-
import { Debugger } from './Debugger.js';
|
|
5
5
|
import { DirectConnection } from './DirectConnection.js';
|
|
6
6
|
import Document from './Document.js';
|
|
7
7
|
import type { Configuration, ConnectionConfiguration, HookName, HookPayloadByName, onStoreDocumentPayload } from './types.js';
|
|
@@ -22,7 +22,6 @@ export declare class Hocuspocus {
|
|
|
22
22
|
loadingDocuments: Map<string, Promise<Document>>;
|
|
23
23
|
documents: Map<string, Document>;
|
|
24
24
|
server?: Server;
|
|
25
|
-
debugger: Debugger;
|
|
26
25
|
debouncer: {
|
|
27
26
|
debounce: (id: string, func: Function, debounce: number, maxDebounce: number) => any;
|
|
28
27
|
isDebounced: (id: string) => boolean;
|
|
@@ -33,7 +32,6 @@ export declare class Hocuspocus {
|
|
|
33
32
|
* Configure Hocuspocus
|
|
34
33
|
*/
|
|
35
34
|
configure(configuration: Partial<Configuration>): Hocuspocus;
|
|
36
|
-
get requiresAuthentication(): boolean;
|
|
37
35
|
/**
|
|
38
36
|
* Get the total number of active documents
|
|
39
37
|
*/
|
|
@@ -68,19 +66,13 @@ export declare class Hocuspocus {
|
|
|
68
66
|
* Create a new document by the given request
|
|
69
67
|
*/
|
|
70
68
|
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,
|
|
69
|
+
loadDocument(documentName: string, request: Partial<Pick<IncomingMessage, 'headers' | 'url'>>, socketId: string, connectionConfig: ConnectionConfiguration, context?: any): Promise<Document>;
|
|
72
70
|
storeDocumentHooks(document: Document, hookPayload: onStoreDocumentPayload, immediately?: boolean): any;
|
|
73
71
|
/**
|
|
74
72
|
* Run the given hook on all configured extensions.
|
|
75
73
|
* Runs the given callback after each hook.
|
|
76
74
|
*/
|
|
77
75
|
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[];
|
|
76
|
+
unloadDocument(document: Document): Promise<any>;
|
|
85
77
|
openDirectConnection(documentName: string, context?: any): Promise<DirectConnection>;
|
|
86
78
|
}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import type Connection from './Connection.js';
|
|
2
|
-
import type { Debugger } from './Debugger.js';
|
|
3
2
|
import type Document from './Document.js';
|
|
4
3
|
import type { IncomingMessage } from './IncomingMessage.js';
|
|
5
4
|
export declare class MessageReceiver {
|
|
6
5
|
message: IncomingMessage;
|
|
7
|
-
logger: Debugger;
|
|
8
6
|
defaultTransactionOrigin?: string;
|
|
9
|
-
constructor(message: IncomingMessage,
|
|
7
|
+
constructor(message: IncomingMessage, defaultTransactionOrigin?: string);
|
|
10
8
|
apply(document: Document, connection?: Connection, reply?: (message: Uint8Array) => void): void;
|
|
11
9
|
readSyncMessage(message: IncomingMessage, document: Document, connection?: Connection, reply?: (message: Uint8Array) => void, requestFirstSync?: boolean): 0 | 1 | 2;
|
|
12
10
|
applyQueryAwarenessMessage(document: Document, reply?: (message: Uint8Array) => void): void;
|
|
@@ -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,6 +1,7 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
1
2
|
import type { IncomingMessage, Server as HTTPServer, ServerResponse } from 'http';
|
|
2
|
-
import type { AddressInfo } from 'ws';
|
|
3
3
|
import { WebSocketServer } from 'ws';
|
|
4
|
+
import type { AddressInfo, ServerOptions } from 'ws';
|
|
4
5
|
import { Hocuspocus } from './Hocuspocus.js';
|
|
5
6
|
import type { Configuration } from './types';
|
|
6
7
|
export interface ServerConfiguration extends Configuration {
|
|
@@ -18,7 +19,7 @@ export declare class Server {
|
|
|
18
19
|
webSocketServer: WebSocketServer;
|
|
19
20
|
hocuspocus: Hocuspocus;
|
|
20
21
|
configuration: ServerConfiguration;
|
|
21
|
-
constructor(configuration?: Partial<ServerConfiguration
|
|
22
|
+
constructor(configuration?: Partial<ServerConfiguration>, websocketOptions?: ServerOptions);
|
|
22
23
|
setupWebsocketConnection: () => void;
|
|
23
24
|
setupHttpUpgrade: () => void;
|
|
24
25
|
requestHandler: (request: IncomingMessage, response: ServerResponse) => Promise<void>;
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
/// <reference types="node" />
|
|
4
|
+
/// <reference types="node" />
|
|
1
5
|
import type { IncomingHttpHeaders, IncomingMessage, ServerResponse } from 'http';
|
|
2
6
|
import type { URLSearchParams } from 'url';
|
|
3
7
|
import type { Awareness } from 'y-protocols/awareness';
|
|
@@ -10,7 +14,7 @@ export declare enum MessageType {
|
|
|
10
14
|
Awareness = 1,
|
|
11
15
|
Auth = 2,
|
|
12
16
|
QueryAwareness = 3,
|
|
13
|
-
SyncReply = 4
|
|
17
|
+
SyncReply = 4,
|
|
14
18
|
Stateless = 5,
|
|
15
19
|
BroadcastStateless = 6,
|
|
16
20
|
CLOSE = 7,
|
|
@@ -23,7 +27,6 @@ export interface AwarenessUpdate {
|
|
|
23
27
|
}
|
|
24
28
|
export interface ConnectionConfiguration {
|
|
25
29
|
readOnly: boolean;
|
|
26
|
-
requiresAuthentication: boolean;
|
|
27
30
|
isAuthenticated: boolean;
|
|
28
31
|
}
|
|
29
32
|
export interface Extension {
|
|
@@ -47,10 +50,11 @@ export interface Extension {
|
|
|
47
50
|
onAwarenessUpdate?(data: onAwarenessUpdatePayload): Promise<any>;
|
|
48
51
|
onRequest?(data: onRequestPayload): Promise<any>;
|
|
49
52
|
onDisconnect?(data: onDisconnectPayload): Promise<any>;
|
|
53
|
+
beforeUnloadDocument?(data: beforeUnloadDocumentPayload): Promise<any>;
|
|
50
54
|
afterUnloadDocument?(data: afterUnloadDocumentPayload): Promise<any>;
|
|
51
55
|
onDestroy?(data: onDestroyPayload): Promise<any>;
|
|
52
56
|
}
|
|
53
|
-
export type HookName = 'onConfigure' | 'onListen' | 'onUpgrade' | 'onConnect' | 'connected' | 'onAuthenticate' | 'onCreateDocument' | 'onLoadDocument' | 'afterLoadDocument' | 'beforeHandleMessage' | 'beforeBroadcastStateless' | 'onStateless' | 'onChange' | 'onStoreDocument' | 'afterStoreDocument' | 'onAwarenessUpdate' | 'onRequest' | 'onDisconnect' | 'afterUnloadDocument' | 'onDestroy';
|
|
57
|
+
export type HookName = 'onConfigure' | 'onListen' | 'onUpgrade' | 'onConnect' | 'connected' | 'onAuthenticate' | 'onCreateDocument' | 'onLoadDocument' | 'afterLoadDocument' | 'beforeHandleMessage' | 'beforeBroadcastStateless' | 'onStateless' | 'onChange' | 'onStoreDocument' | 'afterStoreDocument' | 'onAwarenessUpdate' | 'onRequest' | 'onDisconnect' | 'beforeUnloadDocument' | 'afterUnloadDocument' | 'onDestroy';
|
|
54
58
|
export type HookPayloadByName = {
|
|
55
59
|
onConfigure: onConfigurePayload;
|
|
56
60
|
onListen: onListenPayload;
|
|
@@ -71,6 +75,7 @@ export type HookPayloadByName = {
|
|
|
71
75
|
onRequest: onRequestPayload;
|
|
72
76
|
onDisconnect: onDisconnectPayload;
|
|
73
77
|
afterUnloadDocument: afterUnloadDocumentPayload;
|
|
78
|
+
beforeUnloadDocument: beforeUnloadDocumentPayload;
|
|
74
79
|
onDestroy: onDestroyPayload;
|
|
75
80
|
};
|
|
76
81
|
export interface Configuration extends Extension {
|
|
@@ -130,7 +135,7 @@ export interface onAuthenticatePayload {
|
|
|
130
135
|
request: IncomingMessage;
|
|
131
136
|
socketId: string;
|
|
132
137
|
token: string;
|
|
133
|
-
|
|
138
|
+
connectionConfig: ConnectionConfiguration;
|
|
134
139
|
}
|
|
135
140
|
export interface onCreateDocumentPayload {
|
|
136
141
|
context: any;
|
|
@@ -139,7 +144,7 @@ export interface onCreateDocumentPayload {
|
|
|
139
144
|
requestHeaders: IncomingHttpHeaders;
|
|
140
145
|
requestParameters: URLSearchParams;
|
|
141
146
|
socketId: string;
|
|
142
|
-
|
|
147
|
+
connectionConfig: ConnectionConfiguration;
|
|
143
148
|
}
|
|
144
149
|
export interface onConnectPayload {
|
|
145
150
|
context: any;
|
|
@@ -149,7 +154,7 @@ export interface onConnectPayload {
|
|
|
149
154
|
requestHeaders: IncomingHttpHeaders;
|
|
150
155
|
requestParameters: URLSearchParams;
|
|
151
156
|
socketId: string;
|
|
152
|
-
|
|
157
|
+
connectionConfig: ConnectionConfiguration;
|
|
153
158
|
}
|
|
154
159
|
export interface connectedPayload {
|
|
155
160
|
context: any;
|
|
@@ -159,8 +164,8 @@ export interface connectedPayload {
|
|
|
159
164
|
requestHeaders: IncomingHttpHeaders;
|
|
160
165
|
requestParameters: URLSearchParams;
|
|
161
166
|
socketId: string;
|
|
162
|
-
|
|
163
|
-
|
|
167
|
+
connectionConfig: ConnectionConfiguration;
|
|
168
|
+
connection: Connection;
|
|
164
169
|
}
|
|
165
170
|
export interface onLoadDocumentPayload {
|
|
166
171
|
context: any;
|
|
@@ -170,7 +175,7 @@ export interface onLoadDocumentPayload {
|
|
|
170
175
|
requestHeaders: IncomingHttpHeaders;
|
|
171
176
|
requestParameters: URLSearchParams;
|
|
172
177
|
socketId: string;
|
|
173
|
-
|
|
178
|
+
connectionConfig: ConnectionConfiguration;
|
|
174
179
|
}
|
|
175
180
|
export interface afterLoadDocumentPayload {
|
|
176
181
|
context: any;
|
|
@@ -180,7 +185,7 @@ export interface afterLoadDocumentPayload {
|
|
|
180
185
|
requestHeaders: IncomingHttpHeaders;
|
|
181
186
|
requestParameters: URLSearchParams;
|
|
182
187
|
socketId: string;
|
|
183
|
-
|
|
188
|
+
connectionConfig: ConnectionConfiguration;
|
|
184
189
|
}
|
|
185
190
|
export interface onChangePayload {
|
|
186
191
|
clientsCount: number;
|
|
@@ -250,7 +255,7 @@ export interface fetchPayload {
|
|
|
250
255
|
requestHeaders: IncomingHttpHeaders;
|
|
251
256
|
requestParameters: URLSearchParams;
|
|
252
257
|
socketId: string;
|
|
253
|
-
|
|
258
|
+
connectionConfig: ConnectionConfiguration;
|
|
254
259
|
}
|
|
255
260
|
export interface storePayload extends onStoreDocumentPayload {
|
|
256
261
|
state: Buffer;
|
|
@@ -293,6 +298,10 @@ export interface afterUnloadDocumentPayload {
|
|
|
293
298
|
instance: Hocuspocus;
|
|
294
299
|
documentName: string;
|
|
295
300
|
}
|
|
301
|
+
export interface beforeUnloadDocumentPayload {
|
|
302
|
+
instance: Hocuspocus;
|
|
303
|
+
documentName: string;
|
|
304
|
+
}
|
|
296
305
|
export interface DirectConnection {
|
|
297
306
|
transact(transaction: (document: Document) => void): Promise<void>;
|
|
298
307
|
disconnect(): void;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { HocuspocusProvider, type HocuspocusProviderConfiguration, type HocuspocusProviderWebsocketConfiguration } from '@hocuspocus/provider';
|
|
1
|
+
import { HocuspocusProvider, type HocuspocusProviderConfiguration, type HocuspocusProviderWebsocket, type HocuspocusProviderWebsocketConfiguration } from '@hocuspocus/provider';
|
|
2
2
|
import type { Hocuspocus } from '@hocuspocus/server';
|
|
3
|
-
export declare const newHocuspocusProvider: (server: Hocuspocus, options?: Partial<HocuspocusProviderConfiguration>, websocketOptions?: Partial<HocuspocusProviderWebsocketConfiguration
|
|
3
|
+
export declare const newHocuspocusProvider: (server: Hocuspocus, options?: Partial<HocuspocusProviderConfiguration>, websocketOptions?: Partial<HocuspocusProviderWebsocketConfiguration>, websocketProvider?: HocuspocusProviderWebsocket) => HocuspocusProvider;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { HocuspocusProviderWebsocketConfiguration } from '@hocuspocus/provider';
|
|
2
2
|
import { HocuspocusProviderWebsocket } from '@hocuspocus/provider';
|
|
3
3
|
import type { Hocuspocus } from '@hocuspocus/server';
|
|
4
|
-
export declare const newHocuspocusProviderWebsocket: (hocuspocus: Hocuspocus, options?: Partial<Omit<HocuspocusProviderWebsocketConfiguration,
|
|
4
|
+
export declare const newHocuspocusProviderWebsocket: (hocuspocus: Hocuspocus, options?: Partial<Omit<HocuspocusProviderWebsocketConfiguration, 'url'>>) => HocuspocusProviderWebsocket;
|
package/package.json
CHANGED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import type { AbstractType, YArrayEvent } from 'yjs';
|
|
2
|
-
import * as Y from 'yjs';
|
|
3
|
-
import type { HocuspocusProviderConfiguration } from './HocuspocusProvider.js';
|
|
4
|
-
import { HocuspocusProvider } from './HocuspocusProvider.js';
|
|
5
|
-
import { TiptapCollabProviderWebsocket } from './TiptapCollabProviderWebsocket.js';
|
|
6
|
-
import type { TCollabComment, TCollabThread, THistoryVersion } from './types.js';
|
|
7
|
-
export type TiptapCollabProviderConfiguration = Required<Pick<HocuspocusProviderConfiguration, 'name'>> & Partial<HocuspocusProviderConfiguration> & (Required<Pick<AdditionalTiptapCollabProviderConfiguration, 'websocketProvider'>> | Required<Pick<AdditionalTiptapCollabProviderConfiguration, 'appId'>> | Required<Pick<AdditionalTiptapCollabProviderConfiguration, 'baseUrl'>>) & Pick<AdditionalTiptapCollabProviderConfiguration, 'user'>;
|
|
8
|
-
export interface AdditionalTiptapCollabProviderConfiguration {
|
|
9
|
-
/**
|
|
10
|
-
* A Hocuspocus Cloud App ID, get one here: https://cloud.tiptap.dev
|
|
11
|
-
*/
|
|
12
|
-
appId?: string;
|
|
13
|
-
/**
|
|
14
|
-
* If you are using the on-premise version of TiptapCollab, put your baseUrl here (e.g. https://collab.yourdomain.com)
|
|
15
|
-
*/
|
|
16
|
-
baseUrl?: string;
|
|
17
|
-
websocketProvider?: TiptapCollabProviderWebsocket;
|
|
18
|
-
user?: string;
|
|
19
|
-
}
|
|
20
|
-
export declare class TiptapCollabProvider extends HocuspocusProvider {
|
|
21
|
-
tiptapCollabConfigurationPrefix: string;
|
|
22
|
-
userData?: Y.PermanentUserData;
|
|
23
|
-
constructor(configuration: TiptapCollabProviderConfiguration);
|
|
24
|
-
/**
|
|
25
|
-
* note: this will only work if your server loaded @hocuspocus-pro/extension-history, or if you are on a Tiptap business plan.
|
|
26
|
-
*/
|
|
27
|
-
createVersion(name?: string): void;
|
|
28
|
-
/**
|
|
29
|
-
* note: this will only work if your server loaded @hocuspocus-pro/extension-history, or if you are on a Tiptap business plan.
|
|
30
|
-
*/
|
|
31
|
-
revertToVersion(targetVersion: number): void;
|
|
32
|
-
/**
|
|
33
|
-
* note: this will only work if your server loaded @hocuspocus-pro/extension-history, or if you are on a Tiptap business plan.
|
|
34
|
-
*
|
|
35
|
-
* The server will reply with a stateless message (THistoryVersionPreviewEvent)
|
|
36
|
-
*/
|
|
37
|
-
previewVersion(targetVersion: number): void;
|
|
38
|
-
/**
|
|
39
|
-
* note: this will only work if your server loaded @hocuspocus-pro/extension-history, or if you are on a Tiptap business plan.
|
|
40
|
-
*/
|
|
41
|
-
getVersions(): THistoryVersion[];
|
|
42
|
-
watchVersions(callback: Parameters<AbstractType<YArrayEvent<THistoryVersion>>['observe']>[0]): void;
|
|
43
|
-
unwatchVersions(callback: Parameters<AbstractType<YArrayEvent<THistoryVersion>>['unobserve']>[0]): void;
|
|
44
|
-
isAutoVersioning(): boolean;
|
|
45
|
-
enableAutoVersioning(): 1;
|
|
46
|
-
disableAutoVersioning(): 0;
|
|
47
|
-
private getYThreads;
|
|
48
|
-
getThreads<Data, CommentData>(): TCollabThread<Data, CommentData>[];
|
|
49
|
-
private getThreadIndex;
|
|
50
|
-
getThread<Data, CommentData>(id: string): TCollabThread<Data, CommentData> | null;
|
|
51
|
-
private getYThread;
|
|
52
|
-
createThread(data: Omit<TCollabThread, 'id' | 'createdAt' | 'updatedAt' | 'comments'>): TCollabThread;
|
|
53
|
-
updateThread(id: TCollabThread['id'], data: Partial<Pick<TCollabThread, 'data'> & {
|
|
54
|
-
resolvedAt: TCollabThread['resolvedAt'] | null;
|
|
55
|
-
}>): TCollabThread;
|
|
56
|
-
deleteThread(id: TCollabThread['id']): void;
|
|
57
|
-
getThreadComments(threadId: TCollabThread['id']): TCollabComment[] | null;
|
|
58
|
-
getThreadComment(threadId: TCollabThread['id'], commentId: TCollabComment['id']): TCollabComment | null;
|
|
59
|
-
addComment(threadId: TCollabThread['id'], data: Omit<TCollabComment, 'id' | 'updatedAt' | 'createdAt'>): TCollabThread;
|
|
60
|
-
updateComment(threadId: TCollabThread['id'], commentId: TCollabComment['id'], data: Partial<Pick<TCollabComment, 'data' | 'content'>>): TCollabThread;
|
|
61
|
-
deleteComment(threadId: TCollabThread['id'], commentId: TCollabComment['id']): TCollabThread | null | undefined;
|
|
62
|
-
watchThreads(callback: () => void): void;
|
|
63
|
-
unwatchThreads(callback: () => void): void;
|
|
64
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { CompleteHocuspocusProviderWebsocketConfiguration } from './HocuspocusProviderWebsocket.js';
|
|
2
|
-
import { HocuspocusProviderWebsocket } from './HocuspocusProviderWebsocket.js';
|
|
3
|
-
export type TiptapCollabProviderWebsocketConfiguration = Partial<CompleteHocuspocusProviderWebsocketConfiguration> & AdditionalTiptapCollabProviderWebsocketConfiguration;
|
|
4
|
-
export interface AdditionalTiptapCollabProviderWebsocketConfiguration {
|
|
5
|
-
/**
|
|
6
|
-
* A Hocuspocus Cloud App ID, get one here: https://cloud.tiptap.dev
|
|
7
|
-
*/
|
|
8
|
-
appId?: string;
|
|
9
|
-
/**
|
|
10
|
-
* If you are using the on-premise version of TiptapCollab, put your baseUrl here (e.g. https://collab.yourdomain.com)
|
|
11
|
-
*/
|
|
12
|
-
baseUrl?: string;
|
|
13
|
-
/**
|
|
14
|
-
* Only fill this if you are using Tiptap Collab HA.
|
|
15
|
-
*/
|
|
16
|
-
shardKey?: string;
|
|
17
|
-
}
|
|
18
|
-
export declare class TiptapCollabProviderWebsocket extends HocuspocusProviderWebsocket {
|
|
19
|
-
constructor(configuration: TiptapCollabProviderWebsocketConfiguration);
|
|
20
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|