@hocuspocus/extension-database 1.0.0-alpha.2 → 1.0.0-alpha.20
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 +1 -1
- package/dist/hocuspocus-database.cjs +12 -12
- package/dist/hocuspocus-database.cjs.map +1 -1
- package/dist/hocuspocus-database.esm.js +12 -12
- package/dist/hocuspocus-database.esm.js.map +1 -1
- package/dist/packages/common/src/CloseEvents.d.ts +23 -0
- package/dist/packages/common/src/awarenessStatesToArray.d.ts +3 -0
- package/dist/packages/common/src/index.d.ts +3 -0
- package/dist/packages/common/src/types.d.ts +10 -0
- package/dist/packages/extension-database/src/Database.d.ts +5 -11
- package/dist/packages/extension-logger/src/Logger.d.ts +5 -0
- package/dist/packages/extension-monitor/src/Collector.d.ts +2 -3
- package/dist/packages/extension-monitor/src/index.d.ts +2 -2
- package/dist/packages/extension-redis/src/Redis.d.ts +91 -9
- package/dist/packages/extension-redis/src/index.d.ts +0 -1
- package/dist/packages/extension-sqlite/src/SQLite.d.ts +4 -4
- package/dist/packages/extension-throttle/src/index.d.ts +6 -2
- package/dist/packages/extension-webhook/src/index.d.ts +1 -2
- package/dist/packages/provider/src/EventEmitter.d.ts +1 -1
- package/dist/packages/provider/src/HocuspocusCloudProvider.d.ts +4 -3
- package/dist/packages/provider/src/HocuspocusProvider.d.ts +30 -26
- package/dist/packages/provider/src/index.d.ts +0 -1
- package/dist/packages/provider/src/types.d.ts +43 -0
- package/dist/packages/server/src/Connection.d.ts +12 -5
- package/dist/packages/server/src/Debugger.d.ts +1 -2
- package/dist/packages/server/src/Document.d.ts +9 -5
- package/dist/packages/server/src/Hocuspocus.d.ts +37 -15
- package/dist/packages/server/src/MessageReceiver.d.ts +8 -5
- package/dist/packages/server/src/OutgoingMessage.d.ts +2 -0
- package/dist/packages/server/src/index.d.ts +6 -0
- package/dist/packages/server/src/types.d.ts +115 -38
- package/dist/tests/extension-database/fetch.d.ts +1 -0
- package/dist/tests/extension-logger/onListen.d.ts +1 -0
- package/dist/tests/extension-redis/closeConnections.d.ts +1 -0
- package/dist/tests/extension-redis/getConnectionCount.d.ts +1 -0
- package/dist/tests/extension-redis/getDocumentsCount.d.ts +1 -0
- package/dist/tests/extension-redis/onAwarenessChange.d.ts +1 -0
- package/dist/tests/extension-redis/onChange.d.ts +1 -0
- package/dist/tests/extension-redis/onStoreDocument.d.ts +1 -0
- package/dist/tests/extension-throttle/configuration.d.ts +1 -0
- package/dist/tests/provider/configuration.d.ts +1 -0
- package/dist/tests/provider/observe.d.ts +1 -0
- package/dist/tests/provider/observeDeep.d.ts +1 -0
- package/dist/tests/provider/onAuthenticated.d.ts +1 -0
- package/dist/tests/provider/onAuthenticationFailed.d.ts +1 -0
- package/dist/tests/provider/onAwarenessChange.d.ts +1 -0
- package/dist/tests/provider/onAwarenessUpdate.d.ts +1 -0
- package/dist/tests/provider/onClose.d.ts +1 -0
- package/dist/tests/provider/onConnect.d.ts +1 -0
- package/dist/tests/provider/onDisconnect.d.ts +1 -0
- package/dist/tests/provider/onMessage.d.ts +1 -0
- package/dist/tests/provider/onOpen.d.ts +1 -0
- package/dist/tests/provider/onSynced.d.ts +1 -0
- package/dist/tests/server/address.d.ts +1 -0
- package/dist/tests/server/afterStoreDocument.d.ts +1 -0
- package/dist/tests/server/closeConnections.d.ts +1 -0
- package/dist/tests/server/getConnectionsCount.d.ts +1 -0
- package/dist/tests/server/getDocumentName.d.ts +1 -0
- package/dist/tests/server/getDocumentsCount.d.ts +1 -0
- package/dist/tests/server/getMessageLogs.d.ts +1 -0
- package/dist/tests/server/listen.d.ts +1 -0
- package/dist/tests/server/onAuthenticate.d.ts +1 -0
- package/dist/tests/server/onAwarenessUpdate.d.ts +1 -0
- package/dist/tests/server/onChange.d.ts +1 -0
- package/dist/tests/server/onConfigure.d.ts +1 -0
- package/dist/tests/server/onConnect.d.ts +1 -0
- package/dist/tests/server/onDestroy.d.ts +1 -0
- package/dist/tests/server/onDisconnect.d.ts +1 -0
- package/dist/tests/server/onListen.d.ts +1 -0
- package/dist/tests/server/onLoadDocument.d.ts +1 -0
- package/dist/tests/server/onRequest.d.ts +1 -0
- package/dist/tests/server/onStoreDocument.d.ts +1 -0
- package/dist/tests/server/onUpgrade.d.ts +1 -0
- package/dist/tests/server/requiresAuthentication.d.ts +1 -0
- package/dist/tests/server/websocketError.d.ts +1 -0
- package/dist/tests/transformer/TiptapTransformer.d.ts +1 -0
- package/dist/tests/utils/createDirectory.d.ts +1 -0
- package/dist/tests/utils/flushRedis.d.ts +1 -0
- package/dist/tests/utils/index.d.ts +8 -0
- package/dist/tests/utils/newHocuspocus.d.ts +2 -0
- package/dist/tests/utils/newHocuspocusProvider.d.ts +3 -0
- package/dist/tests/utils/randomInteger.d.ts +1 -0
- package/dist/tests/utils/redisConnectionSettings.d.ts +4 -0
- package/dist/tests/utils/removeDirectory.d.ts +1 -0
- package/dist/tests/utils/retryableAssertion.d.ts +2 -0
- package/dist/tests/utils/sleep.d.ts +1 -0
- package/package.json +5 -5
- package/src/Database.ts +23 -18
- package/dist/packages/extension-redis/src/RedisCluster.d.ts +0 -4
- package/dist/packages/extension-rocksdb/src/index.d.ts +0 -22
- package/dist/packages/provider/src/utils/awarenessStatesToArray.d.ts +0 -4
- package/dist/packages/provider/src/utils/index.d.ts +0 -1
- package/dist/packages/server/src/CloseEvents.d.ts +0 -4
|
@@ -1,18 +1,26 @@
|
|
|
1
1
|
import { Awareness } from 'y-protocols/awareness';
|
|
2
2
|
import * as Y from 'yjs';
|
|
3
3
|
import { Encoder } from 'lib0/encoding';
|
|
4
|
+
import type { Event, CloseEvent, MessageEvent } from 'ws';
|
|
4
5
|
import { AuthenticationMessage } from './OutgoingMessages/AuthenticationMessage';
|
|
5
6
|
import { AwarenessMessage } from './OutgoingMessages/AwarenessMessage';
|
|
6
7
|
import { QueryAwarenessMessage } from './OutgoingMessages/QueryAwarenessMessage';
|
|
7
8
|
import { SyncStepOneMessage } from './OutgoingMessages/SyncStepOneMessage';
|
|
8
9
|
import { SyncStepTwoMessage } from './OutgoingMessages/SyncStepTwoMessage';
|
|
9
10
|
import { UpdateMessage } from './OutgoingMessages/UpdateMessage';
|
|
11
|
+
import { IncomingMessage } from './IncomingMessage';
|
|
12
|
+
import { OutgoingMessage } from './OutgoingMessage';
|
|
10
13
|
export declare enum MessageType {
|
|
11
14
|
Sync = 0,
|
|
12
15
|
Awareness = 1,
|
|
13
16
|
Auth = 2,
|
|
14
17
|
QueryAwareness = 3
|
|
15
18
|
}
|
|
19
|
+
export declare enum WebSocketStatus {
|
|
20
|
+
Connecting = "connecting",
|
|
21
|
+
Connected = "connected",
|
|
22
|
+
Disconnected = "disconnected"
|
|
23
|
+
}
|
|
16
24
|
export interface OutgoingMessageInterface {
|
|
17
25
|
encoder: Encoder;
|
|
18
26
|
type?: MessageType;
|
|
@@ -32,3 +40,38 @@ export interface Constructable<T> {
|
|
|
32
40
|
new (...args: any): T;
|
|
33
41
|
}
|
|
34
42
|
export declare type ConstructableOutgoingMessage = Constructable<AuthenticationMessage> | Constructable<AwarenessMessage> | Constructable<QueryAwarenessMessage> | Constructable<SyncStepOneMessage> | Constructable<SyncStepTwoMessage> | Constructable<UpdateMessage>;
|
|
43
|
+
export declare type onAuthenticationFailedParameters = {
|
|
44
|
+
reason: string;
|
|
45
|
+
};
|
|
46
|
+
export declare type onOpenParameters = {
|
|
47
|
+
event: Event;
|
|
48
|
+
};
|
|
49
|
+
export declare type onMessageParameters = {
|
|
50
|
+
event: MessageEvent;
|
|
51
|
+
message: IncomingMessage;
|
|
52
|
+
};
|
|
53
|
+
export declare type onOutgoingMessageParameters = {
|
|
54
|
+
message: OutgoingMessage;
|
|
55
|
+
};
|
|
56
|
+
export declare type onStatusParameters = {
|
|
57
|
+
status: WebSocketStatus;
|
|
58
|
+
};
|
|
59
|
+
export declare type onSyncedParameters = {
|
|
60
|
+
state: boolean;
|
|
61
|
+
};
|
|
62
|
+
export declare type onDisconnectParameters = {
|
|
63
|
+
event: CloseEvent;
|
|
64
|
+
};
|
|
65
|
+
export declare type onCloseParameters = {
|
|
66
|
+
event: CloseEvent;
|
|
67
|
+
};
|
|
68
|
+
export declare type onAwarenessUpdateParameters = {
|
|
69
|
+
states: StatesArray;
|
|
70
|
+
};
|
|
71
|
+
export declare type onAwarenessChangeParameters = {
|
|
72
|
+
states: StatesArray;
|
|
73
|
+
};
|
|
74
|
+
export declare type StatesArray = {
|
|
75
|
+
clientId: number;
|
|
76
|
+
[key: string | number]: any;
|
|
77
|
+
}[];
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
import AsyncLock from 'async-lock';
|
|
3
3
|
import WebSocket from 'ws';
|
|
4
4
|
import { IncomingMessage as HTTPIncomingMessage } from 'http';
|
|
5
|
+
import { CloseEvent } from '@hocuspocus/common';
|
|
5
6
|
import Document from './Document';
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
declare class Connection {
|
|
7
|
+
import { Debugger } from './Debugger';
|
|
8
|
+
export declare class Connection {
|
|
9
9
|
webSocket: WebSocket;
|
|
10
10
|
context: any;
|
|
11
11
|
document: Document;
|
|
@@ -17,11 +17,11 @@ declare class Connection {
|
|
|
17
17
|
socketId: string;
|
|
18
18
|
lock: AsyncLock;
|
|
19
19
|
readOnly: Boolean;
|
|
20
|
-
|
|
20
|
+
logger: Debugger;
|
|
21
21
|
/**
|
|
22
22
|
* Constructor.
|
|
23
23
|
*/
|
|
24
|
-
constructor(connection: WebSocket, request: HTTPIncomingMessage, document: Document, timeout: number, socketId: string, context: any, readOnly
|
|
24
|
+
constructor(connection: WebSocket, request: HTTPIncomingMessage, document: Document, timeout: number, socketId: string, context: any, readOnly: boolean | undefined, logger: Debugger);
|
|
25
25
|
/**
|
|
26
26
|
* Set a callback that will be triggered when the connection is closed
|
|
27
27
|
*/
|
|
@@ -49,6 +49,13 @@ declare class Connection {
|
|
|
49
49
|
* @private
|
|
50
50
|
*/
|
|
51
51
|
private handleMessage;
|
|
52
|
+
/**
|
|
53
|
+
* Handle a ws instance error, which is required to prevent
|
|
54
|
+
* the server from crashing when one happens
|
|
55
|
+
* See https://github.com/websockets/ws/issues/1777#issuecomment-660803472
|
|
56
|
+
* @private
|
|
57
|
+
*/
|
|
58
|
+
private handleError;
|
|
52
59
|
/**
|
|
53
60
|
* Get the underlying connection instance
|
|
54
61
|
* @deprecated
|
|
@@ -3,20 +3,24 @@ import { Awareness } from 'y-protocols/awareness';
|
|
|
3
3
|
import { Doc } from 'yjs';
|
|
4
4
|
import { mutex } from 'lib0/mutex.js';
|
|
5
5
|
import Connection from './Connection';
|
|
6
|
-
import {
|
|
7
|
-
declare class Document extends Doc {
|
|
6
|
+
import { Debugger } from './Debugger';
|
|
7
|
+
export declare class Document extends Doc {
|
|
8
8
|
awareness: Awareness;
|
|
9
9
|
callbacks: {
|
|
10
10
|
onUpdate: (document: Document, connection: Connection, update: Uint8Array) => void;
|
|
11
11
|
};
|
|
12
|
-
connections: Map<
|
|
12
|
+
connections: Map<WebSocket, {
|
|
13
|
+
clients: Set<any>;
|
|
14
|
+
connection: Connection;
|
|
15
|
+
}>;
|
|
13
16
|
name: string;
|
|
14
17
|
mux: mutex;
|
|
15
|
-
|
|
18
|
+
logger: Debugger;
|
|
19
|
+
isLoading: boolean;
|
|
16
20
|
/**
|
|
17
21
|
* Constructor.
|
|
18
22
|
*/
|
|
19
|
-
constructor(name: string);
|
|
23
|
+
constructor(name: string, logger: Debugger, yDocOptions: {});
|
|
20
24
|
/**
|
|
21
25
|
* Check if the Document is empty
|
|
22
26
|
*/
|
|
@@ -1,24 +1,32 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import WebSocket, { WebSocketServer } from 'ws';
|
|
2
|
+
import WebSocket, { AddressInfo, WebSocketServer } from 'ws';
|
|
3
3
|
import { IncomingMessage, Server as HTTPServer } from 'http';
|
|
4
|
-
import { Configuration,
|
|
5
|
-
import
|
|
4
|
+
import { Configuration, HookName, HookPayload } from './types';
|
|
5
|
+
import Document from './Document';
|
|
6
|
+
import { Debugger } from './Debugger';
|
|
6
7
|
import { onListenPayload } from '.';
|
|
7
8
|
export declare const defaultConfiguration: {
|
|
8
9
|
name: null;
|
|
9
10
|
port: number;
|
|
10
11
|
timeout: number;
|
|
12
|
+
debounce: number;
|
|
13
|
+
maxDebounce: number;
|
|
11
14
|
quiet: boolean;
|
|
15
|
+
yDocOptions: {
|
|
16
|
+
gc: boolean;
|
|
17
|
+
gcFilter: () => boolean;
|
|
18
|
+
};
|
|
12
19
|
};
|
|
13
20
|
/**
|
|
14
21
|
* Hocuspocus Server
|
|
15
22
|
*/
|
|
16
23
|
export declare class Hocuspocus {
|
|
17
24
|
configuration: Configuration;
|
|
18
|
-
documents: Map<
|
|
25
|
+
documents: Map<string, Document>;
|
|
19
26
|
httpServer?: HTTPServer;
|
|
20
27
|
webSocketServer?: WebSocketServer;
|
|
21
|
-
debugger:
|
|
28
|
+
debugger: Debugger;
|
|
29
|
+
constructor(configuration?: Partial<Configuration>);
|
|
22
30
|
/**
|
|
23
31
|
* Configure the server
|
|
24
32
|
*/
|
|
@@ -27,7 +35,11 @@ export declare class Hocuspocus {
|
|
|
27
35
|
/**
|
|
28
36
|
* Start the server
|
|
29
37
|
*/
|
|
30
|
-
listen(portOrCallback?: number | ((data: onListenPayload) => Promise<any>) | null, callback?: any): Promise<
|
|
38
|
+
listen(portOrCallback?: number | ((data: onListenPayload) => Promise<any>) | null, callback?: any): Promise<Hocuspocus>;
|
|
39
|
+
get address(): AddressInfo;
|
|
40
|
+
get URL(): string;
|
|
41
|
+
get webSocketURL(): string;
|
|
42
|
+
get httpURL(): string;
|
|
31
43
|
private showStartScreen;
|
|
32
44
|
/**
|
|
33
45
|
* Get the total number of active documents
|
|
@@ -46,37 +58,47 @@ export declare class Hocuspocus {
|
|
|
46
58
|
*/
|
|
47
59
|
destroy(): Promise<any>;
|
|
48
60
|
/**
|
|
49
|
-
*
|
|
61
|
+
* The `handleConnection` method receives incoming WebSocket connections,
|
|
62
|
+
* runs all hooks:
|
|
63
|
+
*
|
|
64
|
+
* - onConnect for all connections
|
|
65
|
+
* - onAuthenticate only if required
|
|
66
|
+
*
|
|
67
|
+
* … and if nothings fails it’ll fully establish the connection and
|
|
68
|
+
* load the Document then.
|
|
50
69
|
*/
|
|
51
70
|
handleConnection(incoming: WebSocket, request: IncomingMessage, documentName: string, context?: any): void;
|
|
52
71
|
/**
|
|
53
72
|
* Handle update of the given document
|
|
54
|
-
* @private
|
|
55
73
|
*/
|
|
56
74
|
private handleDocumentUpdate;
|
|
75
|
+
timers: Map<string, {
|
|
76
|
+
timeout: NodeJS.Timeout;
|
|
77
|
+
start: number;
|
|
78
|
+
}>;
|
|
79
|
+
/**
|
|
80
|
+
* debounce the given function, using the given identifier
|
|
81
|
+
*/
|
|
82
|
+
debounce(id: string, func: Function, immediately?: boolean): void;
|
|
57
83
|
/**
|
|
58
84
|
* Create a new document by the given request
|
|
59
|
-
* @private
|
|
60
85
|
*/
|
|
61
86
|
private createDocument;
|
|
62
87
|
/**
|
|
63
88
|
* Create a new connection by the given request and document
|
|
64
|
-
* @private
|
|
65
89
|
*/
|
|
66
90
|
private createConnection;
|
|
67
91
|
/**
|
|
68
|
-
* Run the given hook on all configured extensions
|
|
69
|
-
* Runs the given callback after each hook
|
|
92
|
+
* Run the given hook on all configured extensions.
|
|
93
|
+
* Runs the given callback after each hook.
|
|
70
94
|
*/
|
|
71
|
-
hooks(name:
|
|
95
|
+
hooks(name: HookName, payload: HookPayload, callback?: Function | null): Promise<any>;
|
|
72
96
|
/**
|
|
73
97
|
* Get parameters by the given request
|
|
74
|
-
* @private
|
|
75
98
|
*/
|
|
76
99
|
private static getParameters;
|
|
77
100
|
/**
|
|
78
101
|
* Get document name by the given request
|
|
79
|
-
* @private
|
|
80
102
|
*/
|
|
81
103
|
private getDocumentNameFromRequest;
|
|
82
104
|
enableDebugging(): void;
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
import { Awareness } from 'y-protocols/awareness';
|
|
1
2
|
import Connection from './Connection';
|
|
2
3
|
import { IncomingMessage } from './IncomingMessage';
|
|
3
|
-
import {
|
|
4
|
+
import { Debugger } from './Debugger';
|
|
5
|
+
import Document from './Document';
|
|
4
6
|
export declare class MessageReceiver {
|
|
5
7
|
message: IncomingMessage;
|
|
6
|
-
|
|
7
|
-
constructor(message: IncomingMessage);
|
|
8
|
-
apply(connection:
|
|
9
|
-
readSyncMessage(message: IncomingMessage, connection:
|
|
8
|
+
logger: Debugger;
|
|
9
|
+
constructor(message: IncomingMessage, logger: Debugger);
|
|
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 | 2 | 1;
|
|
12
|
+
applyQueryAwarenessMessage(awareness: Awareness, reply?: (message: Uint8Array) => void): void;
|
|
10
13
|
}
|
|
@@ -7,7 +7,9 @@ export declare class OutgoingMessage {
|
|
|
7
7
|
category?: string;
|
|
8
8
|
constructor();
|
|
9
9
|
createSyncMessage(): OutgoingMessage;
|
|
10
|
+
createSyncReplyMessage(): OutgoingMessage;
|
|
10
11
|
createAwarenessUpdateMessage(awareness: Awareness, changedClients?: Array<any>): OutgoingMessage;
|
|
12
|
+
writeQueryAwareness(): OutgoingMessage;
|
|
11
13
|
writeAuthenticated(): OutgoingMessage;
|
|
12
14
|
writePermissionDenied(reason: string): OutgoingMessage;
|
|
13
15
|
writeFirstSyncStepFor(document: Document): OutgoingMessage;
|
|
@@ -1,56 +1,55 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { IncomingHttpHeaders, IncomingMessage, ServerResponse } from 'http';
|
|
3
3
|
import { URLSearchParams } from 'url';
|
|
4
|
-
import {
|
|
4
|
+
import { Awareness } from 'y-protocols/awareness';
|
|
5
5
|
import Document from './Document';
|
|
6
6
|
import { Hocuspocus } from './Hocuspocus';
|
|
7
7
|
export declare enum MessageType {
|
|
8
8
|
Unknown = -1,
|
|
9
9
|
Sync = 0,
|
|
10
10
|
Awareness = 1,
|
|
11
|
-
Auth = 2
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
* State of the WebSocket connection.
|
|
15
|
-
* https://developer.mozilla.org/de/docs/Web/API/WebSocket/readyState
|
|
16
|
-
*/
|
|
17
|
-
export declare enum WsReadyStates {
|
|
18
|
-
Connecting = 0,
|
|
19
|
-
Open = 1,
|
|
20
|
-
Closing = 2,
|
|
21
|
-
Closed = 3
|
|
11
|
+
Auth = 2,
|
|
12
|
+
QueryAwareness = 3,
|
|
13
|
+
SyncReply = 4
|
|
22
14
|
}
|
|
23
15
|
export interface AwarenessUpdate {
|
|
24
16
|
added: Array<any>;
|
|
25
17
|
updated: Array<any>;
|
|
26
18
|
removed: Array<any>;
|
|
27
19
|
}
|
|
28
|
-
export interface
|
|
20
|
+
export interface ConnectionConfiguration {
|
|
29
21
|
readOnly: boolean;
|
|
30
22
|
requiresAuthentication: boolean;
|
|
31
23
|
isAuthenticated: boolean;
|
|
32
24
|
}
|
|
33
25
|
export interface Extension {
|
|
34
|
-
|
|
35
|
-
onChange?(data: onChangePayload): Promise<any>;
|
|
36
|
-
onConnect?(data: onConnectPayload): Promise<any>;
|
|
26
|
+
priority?: number;
|
|
37
27
|
onConfigure?(data: onConfigurePayload): Promise<any>;
|
|
28
|
+
onListen?(data: onListenPayload): Promise<any>;
|
|
29
|
+
onUpgrade?(data: onUpgradePayload): Promise<any>;
|
|
30
|
+
onConnect?(data: onConnectPayload): Promise<any>;
|
|
31
|
+
connected?(data: connectedPayload): Promise<any>;
|
|
32
|
+
onAuthenticate?(data: onAuthenticatePayload): Promise<any>;
|
|
38
33
|
/**
|
|
39
34
|
* @deprecated onCreateDocument is deprecated, use onLoadDocument instead
|
|
40
35
|
*/
|
|
41
36
|
onCreateDocument?(data: onLoadDocumentPayload): Promise<any>;
|
|
42
37
|
onLoadDocument?(data: onLoadDocumentPayload): Promise<any>;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
38
|
+
afterLoadDocument?(data: onLoadDocumentPayload): Promise<any>;
|
|
39
|
+
onChange?(data: onChangePayload): Promise<any>;
|
|
40
|
+
onStoreDocument?(data: onStoreDocumentPayload): Promise<any>;
|
|
41
|
+
afterStoreDocument?(data: afterStoreDocumentPayload): Promise<any>;
|
|
42
|
+
onAwarenessUpdate?(data: onAwarenessUpdatePayload): Promise<any>;
|
|
46
43
|
onRequest?(data: onRequestPayload): Promise<any>;
|
|
47
|
-
|
|
44
|
+
onDisconnect?(data: onDisconnectPayload): Promise<any>;
|
|
45
|
+
onDestroy?(data: onDestroyPayload): Promise<any>;
|
|
48
46
|
}
|
|
49
|
-
export declare type
|
|
47
|
+
export declare type HookName = 'onConfigure' | 'onListen' | 'onUpgrade' | 'onConnect' | 'connected' | 'onAuthenticate' |
|
|
50
48
|
/**
|
|
51
49
|
* @deprecated onCreateDocument is deprecated, use onLoadDocument instead
|
|
52
50
|
*/
|
|
53
|
-
'onCreateDocument' | 'onLoadDocument' | '
|
|
51
|
+
'onCreateDocument' | 'onLoadDocument' | 'afterLoadDocument' | 'onChange' | 'onStoreDocument' | 'afterStoreDocument' | 'onAwarenessUpdate' | 'onRequest' | 'onDisconnect' | 'onDestroy';
|
|
52
|
+
export declare type HookPayload = onConfigurePayload | onListenPayload | onUpgradePayload | onConnectPayload | connectedPayload | onAuthenticatePayload | onLoadDocumentPayload | onChangePayload | onStoreDocumentPayload | afterStoreDocumentPayload | onAwarenessUpdatePayload | onRequestPayload | onDisconnectPayload | onDestroyPayload;
|
|
54
53
|
export interface Configuration extends Extension {
|
|
55
54
|
/**
|
|
56
55
|
* A name for the instance, used for logging.
|
|
@@ -68,18 +67,35 @@ export interface Configuration extends Extension {
|
|
|
68
67
|
* Defines in which interval the server sends a ping, and closes the connection when no pong is sent back.
|
|
69
68
|
*/
|
|
70
69
|
timeout: number;
|
|
70
|
+
/**
|
|
71
|
+
* Debounces the call of the `onStoreDocument` hook for the given amount of time in ms.
|
|
72
|
+
* Otherwise every single update would be persisted.
|
|
73
|
+
*/
|
|
74
|
+
debounce: number;
|
|
75
|
+
/**
|
|
76
|
+
* Makes sure to call `onStoreDocument` at least in the given amount of time (ms).
|
|
77
|
+
*/
|
|
78
|
+
maxDebounce: number;
|
|
71
79
|
/**
|
|
72
80
|
* By default, the servers show a start screen. If passed false, the server will start quietly.
|
|
73
81
|
*/
|
|
74
82
|
quiet: boolean;
|
|
83
|
+
/**
|
|
84
|
+
* options to pass to the ydoc document
|
|
85
|
+
*/
|
|
86
|
+
yDocOptions: {
|
|
87
|
+
gc: boolean;
|
|
88
|
+
gcFilter: () => boolean;
|
|
89
|
+
};
|
|
75
90
|
/**
|
|
76
91
|
* Function which returns the (customized) document name based on the request
|
|
77
92
|
*/
|
|
78
|
-
getDocumentName?(data:
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
93
|
+
getDocumentName?(data: getDocumentNamePayload): string | Promise<string>;
|
|
94
|
+
}
|
|
95
|
+
export interface getDocumentNamePayload {
|
|
96
|
+
documentName: string;
|
|
97
|
+
request: IncomingMessage;
|
|
98
|
+
requestParameters: URLSearchParams;
|
|
83
99
|
}
|
|
84
100
|
export interface onAuthenticatePayload {
|
|
85
101
|
documentName: string;
|
|
@@ -88,7 +104,7 @@ export interface onAuthenticatePayload {
|
|
|
88
104
|
requestParameters: URLSearchParams;
|
|
89
105
|
socketId: string;
|
|
90
106
|
token: string;
|
|
91
|
-
connection:
|
|
107
|
+
connection: ConnectionConfiguration;
|
|
92
108
|
}
|
|
93
109
|
export interface onConnectPayload {
|
|
94
110
|
documentName: string;
|
|
@@ -97,7 +113,16 @@ export interface onConnectPayload {
|
|
|
97
113
|
requestHeaders: IncomingHttpHeaders;
|
|
98
114
|
requestParameters: URLSearchParams;
|
|
99
115
|
socketId: string;
|
|
100
|
-
connection:
|
|
116
|
+
connection: ConnectionConfiguration;
|
|
117
|
+
}
|
|
118
|
+
export interface connectedPayload {
|
|
119
|
+
documentName: string;
|
|
120
|
+
instance: Hocuspocus;
|
|
121
|
+
request: IncomingMessage;
|
|
122
|
+
requestHeaders: IncomingHttpHeaders;
|
|
123
|
+
requestParameters: URLSearchParams;
|
|
124
|
+
socketId: string;
|
|
125
|
+
connection: ConnectionConfiguration;
|
|
101
126
|
}
|
|
102
127
|
export interface onLoadDocumentPayload {
|
|
103
128
|
context: any;
|
|
@@ -107,7 +132,17 @@ export interface onLoadDocumentPayload {
|
|
|
107
132
|
requestHeaders: IncomingHttpHeaders;
|
|
108
133
|
requestParameters: URLSearchParams;
|
|
109
134
|
socketId: string;
|
|
110
|
-
connection:
|
|
135
|
+
connection: ConnectionConfiguration;
|
|
136
|
+
}
|
|
137
|
+
export interface afterLoadDocumentPayload {
|
|
138
|
+
context: any;
|
|
139
|
+
document: Document;
|
|
140
|
+
documentName: string;
|
|
141
|
+
instance: Hocuspocus;
|
|
142
|
+
requestHeaders: IncomingHttpHeaders;
|
|
143
|
+
requestParameters: URLSearchParams;
|
|
144
|
+
socketId: string;
|
|
145
|
+
connection: ConnectionConfiguration;
|
|
111
146
|
}
|
|
112
147
|
export interface onChangePayload {
|
|
113
148
|
clientsCount: number;
|
|
@@ -120,6 +155,51 @@ export interface onChangePayload {
|
|
|
120
155
|
update: Uint8Array;
|
|
121
156
|
socketId: string;
|
|
122
157
|
}
|
|
158
|
+
export interface onStoreDocumentPayload {
|
|
159
|
+
clientsCount: number;
|
|
160
|
+
context: any;
|
|
161
|
+
document: Document;
|
|
162
|
+
documentName: string;
|
|
163
|
+
instance: Hocuspocus;
|
|
164
|
+
requestHeaders: IncomingHttpHeaders;
|
|
165
|
+
requestParameters: URLSearchParams;
|
|
166
|
+
socketId: string;
|
|
167
|
+
}
|
|
168
|
+
export interface afterStoreDocumentPayload extends onStoreDocumentPayload {
|
|
169
|
+
}
|
|
170
|
+
export interface onAwarenessUpdatePayload {
|
|
171
|
+
clientsCount: number;
|
|
172
|
+
context: any;
|
|
173
|
+
document: Document;
|
|
174
|
+
documentName: string;
|
|
175
|
+
instance: Hocuspocus;
|
|
176
|
+
requestHeaders: IncomingHttpHeaders;
|
|
177
|
+
requestParameters: URLSearchParams;
|
|
178
|
+
update: Uint8Array;
|
|
179
|
+
socketId: string;
|
|
180
|
+
added: number[];
|
|
181
|
+
updated: number[];
|
|
182
|
+
removed: number[];
|
|
183
|
+
awareness: Awareness;
|
|
184
|
+
states: StatesArray;
|
|
185
|
+
}
|
|
186
|
+
export declare type StatesArray = {
|
|
187
|
+
clientId: number;
|
|
188
|
+
[key: string | number]: any;
|
|
189
|
+
}[];
|
|
190
|
+
export interface fetchPayload {
|
|
191
|
+
context: any;
|
|
192
|
+
document: Document;
|
|
193
|
+
documentName: string;
|
|
194
|
+
instance: Hocuspocus;
|
|
195
|
+
requestHeaders: IncomingHttpHeaders;
|
|
196
|
+
requestParameters: URLSearchParams;
|
|
197
|
+
socketId: string;
|
|
198
|
+
connection: ConnectionConfiguration;
|
|
199
|
+
}
|
|
200
|
+
export interface storePayload extends onStoreDocumentPayload {
|
|
201
|
+
state: Buffer;
|
|
202
|
+
}
|
|
123
203
|
export interface onDisconnectPayload {
|
|
124
204
|
clientsCount: number;
|
|
125
205
|
context: any;
|
|
@@ -136,24 +216,21 @@ export interface onRequestPayload {
|
|
|
136
216
|
instance: Hocuspocus;
|
|
137
217
|
}
|
|
138
218
|
export interface onUpgradePayload {
|
|
139
|
-
head: any;
|
|
140
219
|
request: IncomingMessage;
|
|
141
|
-
socket:
|
|
220
|
+
socket: any;
|
|
221
|
+
head: any;
|
|
142
222
|
instance: Hocuspocus;
|
|
143
223
|
}
|
|
144
224
|
export interface onListenPayload {
|
|
225
|
+
instance: Hocuspocus;
|
|
226
|
+
configuration: Configuration;
|
|
145
227
|
port: number;
|
|
146
228
|
}
|
|
147
229
|
export interface onDestroyPayload {
|
|
148
230
|
instance: Hocuspocus;
|
|
149
231
|
}
|
|
150
232
|
export interface onConfigurePayload {
|
|
233
|
+
instance: Hocuspocus;
|
|
151
234
|
configuration: Configuration;
|
|
152
235
|
version: string;
|
|
153
|
-
yjsVersion: string;
|
|
154
|
-
instance: Hocuspocus;
|
|
155
|
-
}
|
|
156
|
-
export interface CloseEvent {
|
|
157
|
-
code: number;
|
|
158
|
-
reason: string;
|
|
159
236
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|