@hocuspocus/provider 2.4.0 → 2.5.0-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.
@@ -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
  }
@@ -19,6 +19,7 @@ export declare const defaultConfiguration: {
19
19
  gc: boolean;
20
20
  gcFilter: () => boolean;
21
21
  };
22
+ unloadImmediately: boolean;
22
23
  };
23
24
  /**
24
25
  * Hocuspocus Server
@@ -72,6 +73,9 @@ 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
81
  timers: Map<string, {
@@ -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
  */
@@ -190,6 +198,7 @@ export interface onChangePayload {
190
198
  requestParameters: URLSearchParams;
191
199
  update: Uint8Array;
192
200
  socketId: string;
201
+ transactionOrigin: any;
193
202
  }
194
203
  export interface beforeHandleMessagePayload {
195
204
  clientsCount: number;
@@ -217,6 +226,7 @@ export interface onStoreDocumentPayload {
217
226
  requestHeaders: IncomingHttpHeaders;
218
227
  requestParameters: URLSearchParams;
219
228
  socketId: string;
229
+ transactionOrigin?: any;
220
230
  }
221
231
  export interface afterStoreDocumentPayload extends onStoreDocumentPayload {
222
232
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hocuspocus/provider",
3
- "version": "2.4.0",
3
+ "version": "2.5.0-rc.0",
4
4
  "description": "hocuspocus provider",
5
5
  "homepage": "https://hocuspocus.dev",
6
6
  "keywords": [
@@ -29,7 +29,7 @@
29
29
  "dist"
30
30
  ],
31
31
  "dependencies": {
32
- "@hocuspocus/common": "^2.4.0",
32
+ "@hocuspocus/common": "^2.5.0-rc.0",
33
33
  "@lifeomic/attempt": "^3.0.2",
34
34
  "lib0": "^0.2.47",
35
35
  "ws": "^7.5.9"