@hocuspocus/extension-logger 2.4.0 → 2.5.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/packages/extension-redis/src/Redis.d.ts +6 -1
- package/dist/packages/server/src/DirectConnection.d.ts +1 -1
- package/dist/packages/server/src/Hocuspocus.d.ts +5 -9
- package/dist/packages/server/src/MessageReceiver.d.ts +2 -1
- package/dist/packages/server/src/index.d.ts +1 -0
- package/dist/packages/server/src/types.d.ts +10 -9
- package/dist/packages/server/src/util/debounce.d.ts +1 -0
- package/package.json +2 -2
- package/dist/tests/extension-redis/closeConnections.d.ts +0 -1
- package/dist/tests/extension-redis/getConnectionCount.d.ts +0 -1
- package/dist/tests/extension-redis/getDocumentsCount.d.ts +0 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
1
2
|
import RedisClient, { ClusterNode, ClusterOptions, RedisOptions } from 'ioredis';
|
|
2
3
|
import Redlock from 'redlock';
|
|
3
4
|
import { Extension, afterLoadDocumentPayload, afterStoreDocumentPayload, onDisconnectPayload, onStoreDocumentPayload, onAwarenessUpdatePayload, onChangePayload, Debugger, onConfigurePayload, beforeBroadcastStatelessPayload, Hocuspocus } from '@hocuspocus/server';
|
|
@@ -56,18 +57,22 @@ export declare class Redis implements Extension {
|
|
|
56
57
|
*/
|
|
57
58
|
priority: number;
|
|
58
59
|
configuration: Configuration;
|
|
60
|
+
redisTransactionOrigin: string;
|
|
59
61
|
pub: RedisInstance;
|
|
60
62
|
sub: RedisInstance;
|
|
61
63
|
instance: Hocuspocus;
|
|
62
64
|
redlock: Redlock;
|
|
63
65
|
locks: Map<string, Redlock.Lock>;
|
|
64
66
|
logger: Debugger;
|
|
67
|
+
messagePrefix: Buffer;
|
|
65
68
|
constructor(configuration: Partial<Configuration>);
|
|
66
69
|
onConfigure({ instance }: onConfigurePayload): Promise<void>;
|
|
67
70
|
private getKey;
|
|
68
71
|
private pubKey;
|
|
69
72
|
private subKey;
|
|
70
73
|
private lockKey;
|
|
74
|
+
private encodeMessage;
|
|
75
|
+
private decodeMessage;
|
|
71
76
|
/**
|
|
72
77
|
* Once a document is loaded, subscribe to the channel in Redis.
|
|
73
78
|
*/
|
|
@@ -94,7 +99,7 @@ export declare class Redis implements Extension {
|
|
|
94
99
|
*/
|
|
95
100
|
onAwarenessUpdate({ documentName, awareness, added, updated, removed, }: onAwarenessUpdatePayload): Promise<number>;
|
|
96
101
|
/**
|
|
97
|
-
* Handle incoming messages published on
|
|
102
|
+
* Handle incoming messages published on subscribed document channels.
|
|
98
103
|
* Note that this will also include messages from ourselves as it is not possible
|
|
99
104
|
* in Redis to filter these.
|
|
100
105
|
*/
|
|
@@ -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): Promise<void>;
|
|
12
|
+
transact(transaction: (document: Document) => void, transactionOrigin?: any): Promise<void>;
|
|
13
13
|
disconnect(): void;
|
|
14
14
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
2
|
import { IncomingMessage } from 'http';
|
|
4
3
|
import WebSocket, { AddressInfo } from 'ws';
|
|
5
4
|
import { Server as HocuspocusServer } from './Server';
|
|
@@ -19,6 +18,7 @@ export declare const defaultConfiguration: {
|
|
|
19
18
|
gc: boolean;
|
|
20
19
|
gcFilter: () => boolean;
|
|
21
20
|
};
|
|
21
|
+
unloadImmediately: boolean;
|
|
22
22
|
};
|
|
23
23
|
/**
|
|
24
24
|
* Hocuspocus Server
|
|
@@ -28,6 +28,7 @@ export declare class Hocuspocus {
|
|
|
28
28
|
documents: Map<string, Document>;
|
|
29
29
|
server?: HocuspocusServer;
|
|
30
30
|
debugger: Debugger;
|
|
31
|
+
debounce: (id: string, func: Function, debounce: number, maxDebounce: number) => void;
|
|
31
32
|
constructor(configuration?: Partial<Configuration>);
|
|
32
33
|
/**
|
|
33
34
|
* Configure the server
|
|
@@ -72,16 +73,11 @@ export declare class Hocuspocus {
|
|
|
72
73
|
handleConnection(incoming: WebSocket, request: IncomingMessage, defaultContext?: any): void;
|
|
73
74
|
/**
|
|
74
75
|
* Handle update of the given document
|
|
76
|
+
*
|
|
77
|
+
* "connection" is not necessarily type "Connection", it's the Yjs "origin" (which is "Connection" if
|
|
78
|
+
* the update is incoming from the provider, but can be anything if the updates is originated from an extension.
|
|
75
79
|
*/
|
|
76
80
|
private handleDocumentUpdate;
|
|
77
|
-
timers: Map<string, {
|
|
78
|
-
timeout: NodeJS.Timeout;
|
|
79
|
-
start: number;
|
|
80
|
-
}>;
|
|
81
|
-
/**
|
|
82
|
-
* debounce the given function, using the given identifier
|
|
83
|
-
*/
|
|
84
|
-
debounce(id: string, func: Function, immediately?: boolean): void;
|
|
85
81
|
/**
|
|
86
82
|
* Create a new document by the given request
|
|
87
83
|
*/
|
|
@@ -5,7 +5,8 @@ import { IncomingMessage } from './IncomingMessage.js';
|
|
|
5
5
|
export declare class MessageReceiver {
|
|
6
6
|
message: IncomingMessage;
|
|
7
7
|
logger: Debugger;
|
|
8
|
-
|
|
8
|
+
defaultTransactionOrigin?: string;
|
|
9
|
+
constructor(message: IncomingMessage, logger: Debugger, defaultTransactionOrigin?: string);
|
|
9
10
|
apply(document: Document, connection?: Connection, reply?: (message: Uint8Array) => void): void;
|
|
10
11
|
readSyncMessage(message: IncomingMessage, document: Document, connection?: Connection, reply?: (message: Uint8Array) => void, requestFirstSync?: boolean): 0 | 1 | 2;
|
|
11
12
|
applyQueryAwarenessMessage(document: Document, reply?: (message: Uint8Array) => void): void;
|
|
@@ -108,6 +108,14 @@ export interface Configuration extends Extension {
|
|
|
108
108
|
* By default, the servers show a start screen. If passed false, the server will start quietly.
|
|
109
109
|
*/
|
|
110
110
|
quiet: boolean;
|
|
111
|
+
/**
|
|
112
|
+
* If set to false, respects the debounce time of `onStoreDocument` before unloading a document.
|
|
113
|
+
* Otherwise, the document will be unloaded immediately.
|
|
114
|
+
*
|
|
115
|
+
* This prevents a client from DOSing the server by repeatedly connecting and disconnecting when
|
|
116
|
+
* your onStoreDocument is rate-limited.
|
|
117
|
+
*/
|
|
118
|
+
unloadImmediately: boolean;
|
|
111
119
|
/**
|
|
112
120
|
* options to pass to the ydoc document
|
|
113
121
|
*/
|
|
@@ -115,15 +123,6 @@ export interface Configuration extends Extension {
|
|
|
115
123
|
gc: boolean;
|
|
116
124
|
gcFilter: () => boolean;
|
|
117
125
|
};
|
|
118
|
-
/**
|
|
119
|
-
* Function which returns the (customized) document name based on the request
|
|
120
|
-
*/
|
|
121
|
-
getDocumentName?(data: getDocumentNamePayload): string | Promise<string>;
|
|
122
|
-
}
|
|
123
|
-
export interface getDocumentNamePayload {
|
|
124
|
-
documentName: string;
|
|
125
|
-
request: IncomingMessage;
|
|
126
|
-
requestParameters: URLSearchParams;
|
|
127
126
|
}
|
|
128
127
|
export interface onStatelessPayload {
|
|
129
128
|
connection: Connection;
|
|
@@ -190,6 +189,7 @@ export interface onChangePayload {
|
|
|
190
189
|
requestParameters: URLSearchParams;
|
|
191
190
|
update: Uint8Array;
|
|
192
191
|
socketId: string;
|
|
192
|
+
transactionOrigin: any;
|
|
193
193
|
}
|
|
194
194
|
export interface beforeHandleMessagePayload {
|
|
195
195
|
clientsCount: number;
|
|
@@ -217,6 +217,7 @@ export interface onStoreDocumentPayload {
|
|
|
217
217
|
requestHeaders: IncomingHttpHeaders;
|
|
218
218
|
requestParameters: URLSearchParams;
|
|
219
219
|
socketId: string;
|
|
220
|
+
transactionOrigin?: any;
|
|
220
221
|
}
|
|
221
222
|
export interface afterStoreDocumentPayload extends onStoreDocumentPayload {
|
|
222
223
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useDebounce: () => (id: string, func: Function, debounce: number, maxDebounce: number) => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hocuspocus/extension-logger",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.0",
|
|
4
4
|
"description": "hocuspocus logging extension",
|
|
5
5
|
"homepage": "https://hocuspocus.dev",
|
|
6
6
|
"keywords": [
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"dist"
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@hocuspocus/server": "^2.
|
|
32
|
+
"@hocuspocus/server": "^2.5.0"
|
|
33
33
|
},
|
|
34
34
|
"gitHead": "b3454a4ca289a84ddfb7fa5607a2d4b8d5c37e9d"
|
|
35
35
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|