@hocuspocus/common 2.1.0-alpha.0 → 2.2.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 +85 -84
- package/dist/hocuspocus-common.cjs.map +1 -1
- package/dist/hocuspocus-common.esm.js +85 -84
- package/dist/hocuspocus-common.esm.js.map +1 -1
- package/dist/packages/common/src/CloseEvents.d.ts +29 -29
- package/dist/packages/common/src/auth.d.ts +6 -6
- package/dist/packages/common/src/awarenessStatesToArray.d.ts +3 -3
- package/dist/packages/common/src/index.d.ts +4 -4
- package/dist/packages/common/src/types.d.ts +10 -10
- package/dist/packages/extension-database/src/Database.d.ts +30 -30
- package/dist/packages/extension-database/src/index.d.ts +1 -1
- package/dist/packages/extension-logger/src/Logger.d.ts +67 -67
- package/dist/packages/extension-logger/src/index.d.ts +1 -1
- package/dist/packages/extension-redis/src/Redis.d.ts +116 -95
- package/dist/packages/extension-redis/src/index.d.ts +1 -1
- package/dist/packages/extension-sqlite/src/SQLite.d.ts +26 -26
- package/dist/packages/extension-sqlite/src/index.d.ts +1 -1
- package/dist/packages/extension-throttle/src/index.d.ts +31 -31
- package/dist/packages/extension-webhook/src/index.d.ts +57 -57
- package/dist/packages/provider/src/EventEmitter.d.ts +9 -9
- package/dist/packages/provider/src/HocuspocusProvider.d.ts +110 -110
- package/dist/packages/provider/src/HocuspocusProviderWebsocket.d.ts +115 -115
- package/dist/packages/provider/src/IncomingMessage.d.ts +16 -16
- package/dist/packages/provider/src/MessageReceiver.d.ts +13 -13
- package/dist/packages/provider/src/MessageSender.d.ts +10 -10
- package/dist/packages/provider/src/OutgoingMessage.d.ts +9 -9
- package/dist/packages/provider/src/OutgoingMessages/AuthenticationMessage.d.ts +7 -7
- package/dist/packages/provider/src/OutgoingMessages/AwarenessMessage.d.ts +8 -8
- package/dist/packages/provider/src/OutgoingMessages/CloseMessage.d.ts +8 -8
- package/dist/packages/provider/src/OutgoingMessages/QueryAwarenessMessage.d.ts +8 -8
- package/dist/packages/provider/src/OutgoingMessages/StatelessMessage.d.ts +7 -7
- package/dist/packages/provider/src/OutgoingMessages/SyncStepOneMessage.d.ts +8 -8
- package/dist/packages/provider/src/OutgoingMessages/SyncStepTwoMessage.d.ts +8 -8
- package/dist/packages/provider/src/OutgoingMessages/UpdateMessage.d.ts +7 -7
- package/dist/packages/provider/src/TiptapCollabProvider.d.ts +11 -11
- package/dist/packages/provider/src/TiptapCollabProviderWebsocket.d.ts +11 -11
- package/dist/packages/provider/src/index.d.ts +5 -5
- package/dist/packages/provider/src/types.d.ts +84 -84
- package/dist/packages/server/src/ClientConnection.d.ts +56 -0
- package/dist/packages/server/src/Connection.d.ts +71 -71
- package/dist/packages/server/src/Debugger.d.ts +14 -14
- package/dist/packages/server/src/DirectConnection.d.ts +14 -0
- package/dist/packages/server/src/Document.d.ts +91 -88
- package/dist/packages/server/src/Hocuspocus.d.ts +103 -108
- package/dist/packages/server/src/IncomingMessage.d.ts +21 -21
- package/dist/packages/server/src/MessageReceiver.d.ts +12 -12
- package/dist/packages/server/src/OutgoingMessage.d.ts +20 -20
- package/dist/packages/server/src/index.d.ts +8 -8
- package/dist/packages/server/src/types.d.ts +270 -264
- package/dist/packages/server/src/util/getParameters.d.ts +8 -0
- package/dist/packages/transformer/src/Prosemirror.d.ts +11 -11
- package/dist/packages/transformer/src/Tiptap.d.ts +10 -10
- package/dist/packages/transformer/src/index.d.ts +3 -3
- package/dist/packages/transformer/src/types.d.ts +5 -5
- package/dist/playground/backend/src/default.d.ts +1 -1
- package/dist/playground/backend/src/express.d.ts +1 -1
- package/dist/playground/backend/src/koa.d.ts +1 -1
- package/dist/playground/backend/src/load-document.d.ts +1 -1
- package/dist/playground/backend/src/redis.d.ts +1 -1
- package/dist/playground/backend/src/slow.d.ts +1 -1
- package/dist/playground/backend/src/tiptapcollab.d.ts +1 -1
- package/dist/playground/backend/src/webhook.d.ts +1 -1
- package/dist/playground/frontend/src/main.d.ts +1 -1
- package/dist/playground/frontend/vite.config.d.ts +2 -2
- package/dist/tests/extension-database/fetch.d.ts +1 -1
- package/dist/tests/extension-logger/onListen.d.ts +1 -1
- package/dist/tests/extension-redis/closeConnections.d.ts +1 -1
- package/dist/tests/extension-redis/getConnectionCount.d.ts +1 -1
- package/dist/tests/extension-redis/getDocumentsCount.d.ts +1 -1
- package/dist/tests/extension-redis/onAwarenessChange.d.ts +1 -1
- package/dist/tests/extension-redis/onChange.d.ts +1 -1
- package/dist/tests/extension-redis/onStateless.d.ts +1 -1
- package/dist/tests/extension-redis/onStoreDocument.d.ts +1 -1
- package/dist/tests/extension-throttle/banning.d.ts +1 -1
- package/dist/tests/extension-throttle/configuration.d.ts +1 -1
- package/dist/tests/provider/observe.d.ts +1 -1
- package/dist/tests/provider/observeDeep.d.ts +1 -1
- package/dist/tests/provider/onAuthenticated.d.ts +1 -1
- package/dist/tests/provider/onAuthenticationFailed.d.ts +1 -1
- package/dist/tests/provider/onAwarenessChange.d.ts +1 -1
- package/dist/tests/provider/onAwarenessUpdate.d.ts +1 -1
- package/dist/tests/provider/onClose.d.ts +1 -1
- package/dist/tests/provider/onConnect.d.ts +1 -1
- package/dist/tests/provider/onDisconnect.d.ts +1 -1
- package/dist/tests/provider/onMessage.d.ts +1 -1
- package/dist/tests/provider/onOpen.d.ts +1 -1
- package/dist/tests/provider/onStateless.d.ts +1 -1
- package/dist/tests/provider/onSynced.d.ts +1 -1
- package/dist/tests/providerwebsocket/configuration.d.ts +1 -1
- package/dist/tests/server/address.d.ts +1 -1
- package/dist/tests/server/afterStoreDocument.d.ts +1 -1
- package/dist/tests/server/beforeBroadcastStateless.d.ts +1 -1
- package/dist/tests/server/beforeHandleMessage.d.ts +1 -1
- package/dist/tests/server/closeConnections.d.ts +1 -1
- package/dist/tests/server/getConnectionsCount.d.ts +1 -1
- package/dist/tests/server/getDocumentsCount.d.ts +1 -1
- package/dist/tests/server/getMessageLogs.d.ts +1 -1
- package/dist/tests/server/listen.d.ts +1 -1
- package/dist/tests/server/onAuthenticate.d.ts +1 -1
- package/dist/tests/server/onAwarenessUpdate.d.ts +1 -1
- package/dist/tests/server/onChange.d.ts +1 -1
- package/dist/tests/server/onClose.d.ts +1 -1
- package/dist/tests/server/onConfigure.d.ts +1 -1
- package/dist/tests/server/onConnect.d.ts +1 -1
- package/dist/tests/server/onDestroy.d.ts +1 -1
- package/dist/tests/server/onDisconnect.d.ts +1 -1
- package/dist/tests/server/onListen.d.ts +1 -1
- package/dist/tests/server/onLoadDocument.d.ts +1 -1
- package/dist/tests/server/onRequest.d.ts +1 -1
- package/dist/tests/server/onStateless.d.ts +1 -1
- package/dist/tests/server/onStoreDocument.d.ts +1 -1
- package/dist/tests/server/onUpgrade.d.ts +1 -1
- package/dist/tests/server/openDirectConnection.d.ts +1 -0
- package/dist/tests/server/requiresAuthentication.d.ts +1 -1
- package/dist/tests/server/websocketError.d.ts +1 -1
- package/dist/tests/transformer/TiptapTransformer.d.ts +1 -1
- package/dist/tests/utils/createDirectory.d.ts +1 -1
- package/dist/tests/utils/flushRedis.d.ts +1 -1
- package/dist/tests/utils/index.d.ts +9 -9
- package/dist/tests/utils/newHocuspocus.d.ts +2 -2
- package/dist/tests/utils/newHocuspocusProvider.d.ts +3 -3
- package/dist/tests/utils/newHocuspocusProviderWebsocket.d.ts +3 -3
- package/dist/tests/utils/randomInteger.d.ts +1 -1
- package/dist/tests/utils/redisConnectionSettings.d.ts +4 -4
- package/dist/tests/utils/removeDirectory.d.ts +1 -1
- package/dist/tests/utils/retryableAssertion.d.ts +2 -2
- package/dist/tests/utils/sleep.d.ts +1 -1
- package/package.json +3 -2
- package/src/auth.ts +4 -3
- package/src/index.ts +4 -4
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
export interface CloseEvent {
|
|
2
|
-
code: number;
|
|
3
|
-
reason: string;
|
|
4
|
-
}
|
|
5
|
-
/**
|
|
6
|
-
* The server is terminating the connection because a data frame was received
|
|
7
|
-
* that is too large.
|
|
8
|
-
* See: https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent/code
|
|
9
|
-
*/
|
|
10
|
-
export declare const MessageTooBig: CloseEvent;
|
|
11
|
-
/**
|
|
12
|
-
* The server successfully processed the request, asks that the requester reset
|
|
13
|
-
* its document view, and is not returning any content.
|
|
14
|
-
*/
|
|
15
|
-
export declare const ResetConnection: CloseEvent;
|
|
16
|
-
/**
|
|
17
|
-
* Similar to Forbidden, but specifically for use when authentication is required and has
|
|
18
|
-
* failed or has not yet been provided.
|
|
19
|
-
*/
|
|
20
|
-
export declare const Unauthorized: CloseEvent;
|
|
21
|
-
/**
|
|
22
|
-
* The request contained valid data and was understood by the server, but the server
|
|
23
|
-
* is refusing action.
|
|
24
|
-
*/
|
|
25
|
-
export declare const Forbidden: CloseEvent;
|
|
26
|
-
/**
|
|
27
|
-
* The server timed out waiting for the request.
|
|
28
|
-
*/
|
|
29
|
-
export declare const ConnectionTimeout: CloseEvent;
|
|
1
|
+
export interface CloseEvent {
|
|
2
|
+
code: number;
|
|
3
|
+
reason: string;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* The server is terminating the connection because a data frame was received
|
|
7
|
+
* that is too large.
|
|
8
|
+
* See: https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent/code
|
|
9
|
+
*/
|
|
10
|
+
export declare const MessageTooBig: CloseEvent;
|
|
11
|
+
/**
|
|
12
|
+
* The server successfully processed the request, asks that the requester reset
|
|
13
|
+
* its document view, and is not returning any content.
|
|
14
|
+
*/
|
|
15
|
+
export declare const ResetConnection: CloseEvent;
|
|
16
|
+
/**
|
|
17
|
+
* Similar to Forbidden, but specifically for use when authentication is required and has
|
|
18
|
+
* failed or has not yet been provided.
|
|
19
|
+
*/
|
|
20
|
+
export declare const Unauthorized: CloseEvent;
|
|
21
|
+
/**
|
|
22
|
+
* The request contained valid data and was understood by the server, but the server
|
|
23
|
+
* is refusing action.
|
|
24
|
+
*/
|
|
25
|
+
export declare const Forbidden: CloseEvent;
|
|
26
|
+
/**
|
|
27
|
+
* The server timed out waiting for the request.
|
|
28
|
+
*/
|
|
29
|
+
export declare const ConnectionTimeout: CloseEvent;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as encoding from 'lib0/encoding';
|
|
2
|
-
import * as decoding from 'lib0/decoding';
|
|
3
|
-
export declare const writeAuthentication: (encoder: encoding.Encoder, auth: string) => void;
|
|
4
|
-
export declare const writePermissionDenied: (encoder: encoding.Encoder, reason: string) => void;
|
|
5
|
-
export declare const writeAuthenticated: (encoder: encoding.Encoder) => void;
|
|
6
|
-
export declare const readAuthMessage: (decoder: decoding.Decoder, permissionDeniedHandler: (reason: string) => void, authenticatedHandler: () => void) => void;
|
|
1
|
+
import * as encoding from 'lib0/encoding';
|
|
2
|
+
import * as decoding from 'lib0/decoding';
|
|
3
|
+
export declare const writeAuthentication: (encoder: encoding.Encoder, auth: string) => void;
|
|
4
|
+
export declare const writePermissionDenied: (encoder: encoding.Encoder, reason: string) => void;
|
|
5
|
+
export declare const writeAuthenticated: (encoder: encoding.Encoder, scope: 'readonly' | 'read-write') => void;
|
|
6
|
+
export declare const readAuthMessage: (decoder: decoding.Decoder, permissionDeniedHandler: (reason: string) => void, authenticatedHandler: (scope: string) => void) => void;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare const awarenessStatesToArray: (states: Map<number, Record<string, any>>) => {
|
|
2
|
-
clientId: number;
|
|
3
|
-
}[];
|
|
1
|
+
export declare const awarenessStatesToArray: (states: Map<number, Record<string, any>>) => {
|
|
2
|
+
clientId: number;
|
|
3
|
+
}[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './auth';
|
|
2
|
-
export * from './CloseEvents';
|
|
3
|
-
export * from './awarenessStatesToArray';
|
|
4
|
-
export * from './types';
|
|
1
|
+
export * from './auth.js';
|
|
2
|
+
export * from './CloseEvents.js';
|
|
3
|
+
export * from './awarenessStatesToArray.js';
|
|
4
|
+
export * from './types.js';
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* State of the WebSocket connection.
|
|
3
|
-
* https://developer.mozilla.org/de/docs/Web/API/WebSocket/readyState
|
|
4
|
-
*/
|
|
5
|
-
export declare enum WsReadyStates {
|
|
6
|
-
Connecting = 0,
|
|
7
|
-
Open = 1,
|
|
8
|
-
Closing = 2,
|
|
9
|
-
Closed = 3
|
|
10
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* State of the WebSocket connection.
|
|
3
|
+
* https://developer.mozilla.org/de/docs/Web/API/WebSocket/readyState
|
|
4
|
+
*/
|
|
5
|
+
export declare enum WsReadyStates {
|
|
6
|
+
Connecting = 0,
|
|
7
|
+
Open = 1,
|
|
8
|
+
Closing = 2,
|
|
9
|
+
Closed = 3
|
|
10
|
+
}
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import { Extension, onChangePayload, onLoadDocumentPayload, storePayload, fetchPayload } from '@hocuspocus/server';
|
|
2
|
-
export interface DatabaseConfiguration {
|
|
3
|
-
/**
|
|
4
|
-
* Pass a Promise to retrieve updates from your database. The Promise should resolve to
|
|
5
|
-
* an array of items with Y.js-compatible binary data.
|
|
6
|
-
*/
|
|
7
|
-
fetch: (data: fetchPayload) => Promise<Uint8Array | null>;
|
|
8
|
-
/**
|
|
9
|
-
* Pass a function to store updates in your database.
|
|
10
|
-
*/
|
|
11
|
-
store: (data: storePayload) => void;
|
|
12
|
-
}
|
|
13
|
-
export declare class Database implements Extension {
|
|
14
|
-
/**
|
|
15
|
-
* Default configuration
|
|
16
|
-
*/
|
|
17
|
-
configuration: DatabaseConfiguration;
|
|
18
|
-
/**
|
|
19
|
-
* Constructor
|
|
20
|
-
*/
|
|
21
|
-
constructor(configuration: Partial<DatabaseConfiguration>);
|
|
22
|
-
/**
|
|
23
|
-
* Get stored data from the database.
|
|
24
|
-
*/
|
|
25
|
-
onLoadDocument(data: onLoadDocumentPayload): Promise<any>;
|
|
26
|
-
/**
|
|
27
|
-
* Store new updates in the database.
|
|
28
|
-
*/
|
|
29
|
-
onStoreDocument(data: onChangePayload): Promise<void>;
|
|
30
|
-
}
|
|
1
|
+
import { Extension, onChangePayload, onLoadDocumentPayload, storePayload, fetchPayload } from '@hocuspocus/server';
|
|
2
|
+
export interface DatabaseConfiguration {
|
|
3
|
+
/**
|
|
4
|
+
* Pass a Promise to retrieve updates from your database. The Promise should resolve to
|
|
5
|
+
* an array of items with Y.js-compatible binary data.
|
|
6
|
+
*/
|
|
7
|
+
fetch: (data: fetchPayload) => Promise<Uint8Array | null>;
|
|
8
|
+
/**
|
|
9
|
+
* Pass a function to store updates in your database.
|
|
10
|
+
*/
|
|
11
|
+
store: (data: storePayload) => void;
|
|
12
|
+
}
|
|
13
|
+
export declare class Database implements Extension {
|
|
14
|
+
/**
|
|
15
|
+
* Default configuration
|
|
16
|
+
*/
|
|
17
|
+
configuration: DatabaseConfiguration;
|
|
18
|
+
/**
|
|
19
|
+
* Constructor
|
|
20
|
+
*/
|
|
21
|
+
constructor(configuration: Partial<DatabaseConfiguration>);
|
|
22
|
+
/**
|
|
23
|
+
* Get stored data from the database.
|
|
24
|
+
*/
|
|
25
|
+
onLoadDocument(data: onLoadDocumentPayload): Promise<any>;
|
|
26
|
+
/**
|
|
27
|
+
* Store new updates in the database.
|
|
28
|
+
*/
|
|
29
|
+
onStoreDocument(data: onChangePayload): Promise<void>;
|
|
30
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './Database';
|
|
1
|
+
export * from './Database.js';
|
|
@@ -1,67 +1,67 @@
|
|
|
1
|
-
import { Extension, onChangePayload, onConfigurePayload, onConnectPayload, onLoadDocumentPayload, onDestroyPayload, onDisconnectPayload, onRequestPayload, onUpgradePayload } from '@hocuspocus/server';
|
|
2
|
-
export interface LoggerConfiguration {
|
|
3
|
-
/**
|
|
4
|
-
* Prepend all logging message with a string.
|
|
5
|
-
*
|
|
6
|
-
* @deprecated
|
|
7
|
-
*/
|
|
8
|
-
prefix: null | string;
|
|
9
|
-
/**
|
|
10
|
-
* Whether to log something for the `onLoadDocument` hook.
|
|
11
|
-
*/
|
|
12
|
-
onLoadDocument: boolean;
|
|
13
|
-
/**
|
|
14
|
-
* Whether to log something for the `onChange` hook.
|
|
15
|
-
*/
|
|
16
|
-
onChange: boolean;
|
|
17
|
-
/**
|
|
18
|
-
* Whether to log something for the `onStoreDocument` hook.
|
|
19
|
-
*/
|
|
20
|
-
onStoreDocument: boolean;
|
|
21
|
-
/**
|
|
22
|
-
* Whether to log something for the `onConnect` hook.
|
|
23
|
-
*/
|
|
24
|
-
onConnect: boolean;
|
|
25
|
-
/**
|
|
26
|
-
* Whether to log something for the `onDisconnect` hook.
|
|
27
|
-
*/
|
|
28
|
-
onDisconnect: boolean;
|
|
29
|
-
/**
|
|
30
|
-
* Whether to log something for the `onUpgrade` hook.
|
|
31
|
-
*/
|
|
32
|
-
onUpgrade: boolean;
|
|
33
|
-
/**
|
|
34
|
-
* Whether to log something for the `onRequest` hook.
|
|
35
|
-
*/
|
|
36
|
-
onRequest: boolean;
|
|
37
|
-
/**
|
|
38
|
-
* Whether to log something for the `onDestroy` hook.
|
|
39
|
-
*/
|
|
40
|
-
onDestroy: boolean;
|
|
41
|
-
/**
|
|
42
|
-
* Whether to log something for the `onConfigure` hook.
|
|
43
|
-
*/
|
|
44
|
-
onConfigure: boolean;
|
|
45
|
-
/**
|
|
46
|
-
* A log function, if none is provided output will go to console
|
|
47
|
-
*/
|
|
48
|
-
log: (...args: any[]) => void;
|
|
49
|
-
}
|
|
50
|
-
export declare class Logger implements Extension {
|
|
51
|
-
name: string | null;
|
|
52
|
-
configuration: LoggerConfiguration;
|
|
53
|
-
/**
|
|
54
|
-
* Constructor
|
|
55
|
-
*/
|
|
56
|
-
constructor(configuration?: Partial<LoggerConfiguration>);
|
|
57
|
-
onConfigure(data: onConfigurePayload): Promise<void>;
|
|
58
|
-
onLoadDocument(data: onLoadDocumentPayload): Promise<void>;
|
|
59
|
-
onChange(data: onChangePayload): Promise<void>;
|
|
60
|
-
onStoreDocument(data: onDisconnectPayload): Promise<void>;
|
|
61
|
-
onConnect(data: onConnectPayload): Promise<void>;
|
|
62
|
-
onDisconnect(data: onDisconnectPayload): Promise<void>;
|
|
63
|
-
onUpgrade(data: onUpgradePayload): Promise<void>;
|
|
64
|
-
onRequest(data: onRequestPayload): Promise<void>;
|
|
65
|
-
onDestroy(data: onDestroyPayload): Promise<void>;
|
|
66
|
-
private log;
|
|
67
|
-
}
|
|
1
|
+
import { Extension, onChangePayload, onConfigurePayload, onConnectPayload, onLoadDocumentPayload, onDestroyPayload, onDisconnectPayload, onRequestPayload, onUpgradePayload } from '@hocuspocus/server';
|
|
2
|
+
export interface LoggerConfiguration {
|
|
3
|
+
/**
|
|
4
|
+
* Prepend all logging message with a string.
|
|
5
|
+
*
|
|
6
|
+
* @deprecated
|
|
7
|
+
*/
|
|
8
|
+
prefix: null | string;
|
|
9
|
+
/**
|
|
10
|
+
* Whether to log something for the `onLoadDocument` hook.
|
|
11
|
+
*/
|
|
12
|
+
onLoadDocument: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Whether to log something for the `onChange` hook.
|
|
15
|
+
*/
|
|
16
|
+
onChange: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Whether to log something for the `onStoreDocument` hook.
|
|
19
|
+
*/
|
|
20
|
+
onStoreDocument: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Whether to log something for the `onConnect` hook.
|
|
23
|
+
*/
|
|
24
|
+
onConnect: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Whether to log something for the `onDisconnect` hook.
|
|
27
|
+
*/
|
|
28
|
+
onDisconnect: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Whether to log something for the `onUpgrade` hook.
|
|
31
|
+
*/
|
|
32
|
+
onUpgrade: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Whether to log something for the `onRequest` hook.
|
|
35
|
+
*/
|
|
36
|
+
onRequest: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Whether to log something for the `onDestroy` hook.
|
|
39
|
+
*/
|
|
40
|
+
onDestroy: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Whether to log something for the `onConfigure` hook.
|
|
43
|
+
*/
|
|
44
|
+
onConfigure: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* A log function, if none is provided output will go to console
|
|
47
|
+
*/
|
|
48
|
+
log: (...args: any[]) => void;
|
|
49
|
+
}
|
|
50
|
+
export declare class Logger implements Extension {
|
|
51
|
+
name: string | null;
|
|
52
|
+
configuration: LoggerConfiguration;
|
|
53
|
+
/**
|
|
54
|
+
* Constructor
|
|
55
|
+
*/
|
|
56
|
+
constructor(configuration?: Partial<LoggerConfiguration>);
|
|
57
|
+
onConfigure(data: onConfigurePayload): Promise<void>;
|
|
58
|
+
onLoadDocument(data: onLoadDocumentPayload): Promise<void>;
|
|
59
|
+
onChange(data: onChangePayload): Promise<void>;
|
|
60
|
+
onStoreDocument(data: onDisconnectPayload): Promise<void>;
|
|
61
|
+
onConnect(data: onConnectPayload): Promise<void>;
|
|
62
|
+
onDisconnect(data: onDisconnectPayload): Promise<void>;
|
|
63
|
+
onUpgrade(data: onUpgradePayload): Promise<void>;
|
|
64
|
+
onRequest(data: onRequestPayload): Promise<void>;
|
|
65
|
+
onDestroy(data: onDestroyPayload): Promise<void>;
|
|
66
|
+
private log;
|
|
67
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './Logger';
|
|
1
|
+
export * from './Logger.js';
|
|
@@ -1,95 +1,116 @@
|
|
|
1
|
-
import RedisClient, { ClusterNode, ClusterOptions, RedisOptions
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
*
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
*
|
|
43
|
-
*/
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
private
|
|
71
|
-
/**
|
|
72
|
-
*
|
|
73
|
-
*/
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
*
|
|
77
|
-
*/
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
*
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}
|
|
1
|
+
import RedisClient, { ClusterNode, ClusterOptions, RedisOptions } from 'ioredis';
|
|
2
|
+
import Redlock from 'redlock';
|
|
3
|
+
import { Extension, afterLoadDocumentPayload, afterStoreDocumentPayload, onDisconnectPayload, onStoreDocumentPayload, onAwarenessUpdatePayload, onChangePayload, Debugger, onConfigurePayload, beforeBroadcastStatelessPayload, Hocuspocus } from '@hocuspocus/server';
|
|
4
|
+
export type RedisInstance = RedisClient.Cluster | RedisClient.Redis;
|
|
5
|
+
export interface Configuration {
|
|
6
|
+
/**
|
|
7
|
+
* Redis port
|
|
8
|
+
*/
|
|
9
|
+
port: number;
|
|
10
|
+
/**
|
|
11
|
+
* Redis host
|
|
12
|
+
*/
|
|
13
|
+
host: string;
|
|
14
|
+
/**
|
|
15
|
+
* Redis Cluster
|
|
16
|
+
*/
|
|
17
|
+
nodes?: ClusterNode[];
|
|
18
|
+
/**
|
|
19
|
+
* Duplicate from an existed Redis instance
|
|
20
|
+
*/
|
|
21
|
+
redis?: RedisInstance;
|
|
22
|
+
/**
|
|
23
|
+
* Redis instance creator
|
|
24
|
+
*/
|
|
25
|
+
createClient?: () => RedisInstance;
|
|
26
|
+
/**
|
|
27
|
+
* Options passed directly to Redis constructor
|
|
28
|
+
*
|
|
29
|
+
* https://github.com/luin/ioredis/blob/master/API.md#new-redisport-host-options
|
|
30
|
+
*/
|
|
31
|
+
options?: ClusterOptions | RedisOptions;
|
|
32
|
+
/**
|
|
33
|
+
* An unique instance name, required to filter messages in Redis.
|
|
34
|
+
* If none is provided an unique id is generated.
|
|
35
|
+
*/
|
|
36
|
+
identifier: string;
|
|
37
|
+
/**
|
|
38
|
+
* Namespace for Redis keys, if none is provided 'hocuspocus' is used
|
|
39
|
+
*/
|
|
40
|
+
prefix: string;
|
|
41
|
+
/**
|
|
42
|
+
* The maximum time for the Redis lock in ms (in case it can’t be released).
|
|
43
|
+
*/
|
|
44
|
+
lockTimeout: number;
|
|
45
|
+
/**
|
|
46
|
+
* A delay before onDisconnect is executed. This allows last minute updates'
|
|
47
|
+
* sync messages to be received by the subscription before it's closed.
|
|
48
|
+
*/
|
|
49
|
+
disconnectDelay: number;
|
|
50
|
+
}
|
|
51
|
+
export declare class Redis implements Extension {
|
|
52
|
+
/**
|
|
53
|
+
* Make sure to give that extension a higher priority, so
|
|
54
|
+
* the `onStoreDocument` hook is able to intercept the chain,
|
|
55
|
+
* before documents are stored to the database.
|
|
56
|
+
*/
|
|
57
|
+
priority: number;
|
|
58
|
+
configuration: Configuration;
|
|
59
|
+
pub: RedisInstance;
|
|
60
|
+
sub: RedisInstance;
|
|
61
|
+
instance: Hocuspocus;
|
|
62
|
+
redlock: Redlock;
|
|
63
|
+
locks: Map<string, Redlock.Lock>;
|
|
64
|
+
logger: Debugger;
|
|
65
|
+
constructor(configuration: Partial<Configuration>);
|
|
66
|
+
onConfigure({ instance }: onConfigurePayload): Promise<void>;
|
|
67
|
+
private getKey;
|
|
68
|
+
private pubKey;
|
|
69
|
+
private subKey;
|
|
70
|
+
private lockKey;
|
|
71
|
+
/**
|
|
72
|
+
* Once a document is laoded, subscribe to the channel in Redis.
|
|
73
|
+
*/
|
|
74
|
+
afterLoadDocument({ documentName, document }: afterLoadDocumentPayload): Promise<unknown>;
|
|
75
|
+
/**
|
|
76
|
+
* Publish the first sync step through Redis.
|
|
77
|
+
*/
|
|
78
|
+
private publishFirstSyncStep;
|
|
79
|
+
/**
|
|
80
|
+
* Let’s ask Redis who is connected already.
|
|
81
|
+
*/
|
|
82
|
+
private requestAwarenessFromOtherInstances;
|
|
83
|
+
/**
|
|
84
|
+
* Before the document is stored, make sure to set a lock in Redis.
|
|
85
|
+
* That’s meant to avoid conflicts with other instances trying to store the document.
|
|
86
|
+
*/
|
|
87
|
+
onStoreDocument({ documentName }: onStoreDocumentPayload): Promise<unknown>;
|
|
88
|
+
/**
|
|
89
|
+
* Release the Redis lock, so other instances can store documents.
|
|
90
|
+
*/
|
|
91
|
+
afterStoreDocument({ documentName }: afterStoreDocumentPayload): Promise<void>;
|
|
92
|
+
/**
|
|
93
|
+
* Handle awareness update messages received directly by this Hocuspocus instance.
|
|
94
|
+
*/
|
|
95
|
+
onAwarenessUpdate({ documentName, awareness, added, updated, removed, }: onAwarenessUpdatePayload): Promise<number>;
|
|
96
|
+
/**
|
|
97
|
+
* Handle incoming messages published on all subscribed document channels.
|
|
98
|
+
* Note that this will also include messages from ourselves as it is not possible
|
|
99
|
+
* in Redis to filter these.
|
|
100
|
+
*/
|
|
101
|
+
private handleIncomingMessage;
|
|
102
|
+
/**
|
|
103
|
+
* if the ydoc changed, we'll need to inform other Hocuspocus servers about it.
|
|
104
|
+
*/
|
|
105
|
+
onChange(data: onChangePayload): Promise<any>;
|
|
106
|
+
/**
|
|
107
|
+
* Make sure to *not* listen for further changes, when there’s
|
|
108
|
+
* noone connected anymore.
|
|
109
|
+
*/
|
|
110
|
+
onDisconnect: ({ documentName }: onDisconnectPayload) => Promise<void>;
|
|
111
|
+
beforeBroadcastStateless(data: beforeBroadcastStatelessPayload): Promise<number>;
|
|
112
|
+
/**
|
|
113
|
+
* Kill the Redlock connection immediately.
|
|
114
|
+
*/
|
|
115
|
+
onDestroy(): Promise<void>;
|
|
116
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './Redis';
|
|
1
|
+
export * from './Redis.js';
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import { Database, DatabaseConfiguration } from '@hocuspocus/extension-database';
|
|
2
|
-
import sqlite3 from 'sqlite3';
|
|
3
|
-
export declare const schema = "CREATE TABLE IF NOT EXISTS \"documents\" (\n \"name\" varchar(255) NOT NULL,\n \"data\" blob NOT NULL,\n UNIQUE(name)\n)";
|
|
4
|
-
export declare const selectQuery = "\n SELECT data FROM \"documents\" WHERE name = $name ORDER BY rowid DESC\n";
|
|
5
|
-
export declare const upsertQuery = "\n INSERT INTO \"documents\" (\"name\", \"data\") VALUES ($name, $data)\n ON CONFLICT(name) DO UPDATE SET data = $data\n";
|
|
6
|
-
export interface SQLiteConfiguration extends DatabaseConfiguration {
|
|
7
|
-
/**
|
|
8
|
-
* Valid values are filenames, ":memory:" for an anonymous in-memory database and an empty
|
|
9
|
-
* string for an anonymous disk-based database. Anonymous databases are not persisted and
|
|
10
|
-
* when closing the database handle, their contents are lost.
|
|
11
|
-
*
|
|
12
|
-
* https://github.com/mapbox/node-sqlite3/wiki/API#new-sqlite3databasefilename-mode-callback
|
|
13
|
-
*/
|
|
14
|
-
database: string;
|
|
15
|
-
/**
|
|
16
|
-
* The database schema to create.
|
|
17
|
-
*/
|
|
18
|
-
schema: string;
|
|
19
|
-
}
|
|
20
|
-
export declare class SQLite extends Database {
|
|
21
|
-
db?: sqlite3.Database;
|
|
22
|
-
configuration: SQLiteConfiguration;
|
|
23
|
-
constructor(configuration?: Partial<SQLiteConfiguration>);
|
|
24
|
-
onConfigure(): Promise<void>;
|
|
25
|
-
onListen(): Promise<void>;
|
|
26
|
-
}
|
|
1
|
+
import { Database, DatabaseConfiguration } from '@hocuspocus/extension-database';
|
|
2
|
+
import sqlite3 from 'sqlite3';
|
|
3
|
+
export declare const schema = "CREATE TABLE IF NOT EXISTS \"documents\" (\n \"name\" varchar(255) NOT NULL,\n \"data\" blob NOT NULL,\n UNIQUE(name)\n)";
|
|
4
|
+
export declare const selectQuery = "\n SELECT data FROM \"documents\" WHERE name = $name ORDER BY rowid DESC\n";
|
|
5
|
+
export declare const upsertQuery = "\n INSERT INTO \"documents\" (\"name\", \"data\") VALUES ($name, $data)\n ON CONFLICT(name) DO UPDATE SET data = $data\n";
|
|
6
|
+
export interface SQLiteConfiguration extends DatabaseConfiguration {
|
|
7
|
+
/**
|
|
8
|
+
* Valid values are filenames, ":memory:" for an anonymous in-memory database and an empty
|
|
9
|
+
* string for an anonymous disk-based database. Anonymous databases are not persisted and
|
|
10
|
+
* when closing the database handle, their contents are lost.
|
|
11
|
+
*
|
|
12
|
+
* https://github.com/mapbox/node-sqlite3/wiki/API#new-sqlite3databasefilename-mode-callback
|
|
13
|
+
*/
|
|
14
|
+
database: string;
|
|
15
|
+
/**
|
|
16
|
+
* The database schema to create.
|
|
17
|
+
*/
|
|
18
|
+
schema: string;
|
|
19
|
+
}
|
|
20
|
+
export declare class SQLite extends Database {
|
|
21
|
+
db?: sqlite3.Database;
|
|
22
|
+
configuration: SQLiteConfiguration;
|
|
23
|
+
constructor(configuration?: Partial<SQLiteConfiguration>);
|
|
24
|
+
onConfigure(): Promise<void>;
|
|
25
|
+
onListen(): Promise<void>;
|
|
26
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './SQLite';
|
|
1
|
+
export * from './SQLite.js';
|