@hocuspocus/extension-redis 1.0.0-alpha.68 → 1.0.0-alpha.70

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.
@@ -26,6 +26,10 @@ export declare class Connection {
26
26
  * Set a callback that will be triggered when the connection is closed
27
27
  */
28
28
  onClose(callback: (document: Document) => void): Connection;
29
+ /**
30
+ * Set a callback that will be triggered before an message is handled
31
+ */
32
+ beforeHandleMessage(callback: (payload: Document, update: Uint8Array) => Promise<any>): Connection;
29
33
  /**
30
34
  * Send the given message
31
35
  */
@@ -49,6 +53,13 @@ export declare class Connection {
49
53
  * @private
50
54
  */
51
55
  private handleMessage;
56
+ /**
57
+ * Handle a ws instance error, which is required to prevent
58
+ * the server from crashing when one happens
59
+ * See https://github.com/websockets/ws/issues/1777#issuecomment-660803472
60
+ * @private
61
+ */
62
+ private handleError;
52
63
  /**
53
64
  * Get the underlying connection instance
54
65
  * @deprecated
@@ -36,6 +36,7 @@ export interface Extension {
36
36
  onCreateDocument?(data: onLoadDocumentPayload): Promise<any>;
37
37
  onLoadDocument?(data: onLoadDocumentPayload): Promise<any>;
38
38
  afterLoadDocument?(data: onLoadDocumentPayload): Promise<any>;
39
+ beforeHandleMessage?(data: beforeHandleMessagePayload): Promise<any>;
39
40
  onChange?(data: onChangePayload): Promise<any>;
40
41
  onStoreDocument?(data: onStoreDocumentPayload): Promise<any>;
41
42
  afterStoreDocument?(data: afterStoreDocumentPayload): Promise<any>;
@@ -48,7 +49,7 @@ export declare type HookName = 'onConfigure' | 'onListen' | 'onUpgrade' | 'onCon
48
49
  /**
49
50
  * @deprecated onCreateDocument is deprecated, use onLoadDocument instead
50
51
  */
51
- 'onCreateDocument' | 'onLoadDocument' | 'afterLoadDocument' | 'onChange' | 'onStoreDocument' | 'afterStoreDocument' | 'onAwarenessUpdate' | 'onRequest' | 'onDisconnect' | 'onDestroy';
52
+ 'onCreateDocument' | 'onLoadDocument' | 'afterLoadDocument' | 'beforeHandleMessage' | 'onChange' | 'onStoreDocument' | 'afterStoreDocument' | 'onAwarenessUpdate' | 'onRequest' | 'onDisconnect' | 'onDestroy';
52
53
  export declare type HookPayload = onConfigurePayload | onListenPayload | onUpgradePayload | onConnectPayload | connectedPayload | onAuthenticatePayload | onLoadDocumentPayload | onChangePayload | onStoreDocumentPayload | afterStoreDocumentPayload | onAwarenessUpdatePayload | onRequestPayload | onDisconnectPayload | onDestroyPayload;
53
54
  export interface Configuration extends Extension {
54
55
  /**
@@ -155,6 +156,17 @@ export interface onChangePayload {
155
156
  update: Uint8Array;
156
157
  socketId: string;
157
158
  }
159
+ export interface beforeHandleMessagePayload {
160
+ clientsCount: number;
161
+ context: any;
162
+ document: Document;
163
+ documentName: string;
164
+ instance: Hocuspocus;
165
+ requestHeaders: IncomingHttpHeaders;
166
+ requestParameters: URLSearchParams;
167
+ update: Uint8Array;
168
+ socketId: string;
169
+ }
158
170
  export interface onStoreDocumentPayload {
159
171
  clientsCount: number;
160
172
  context: any;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hocuspocus/extension-redis",
3
- "version": "1.0.0-alpha.68",
3
+ "version": "1.0.0-alpha.70",
4
4
  "description": "Scale Hocuspocus horizontally with Redis",
5
5
  "homepage": "https://hocuspocus.dev",
6
6
  "keywords": [
@@ -32,7 +32,7 @@
32
32
  "@types/redlock": "^4.0.3"
33
33
  },
34
34
  "dependencies": {
35
- "@hocuspocus/server": "^1.0.0-alpha.105",
35
+ "@hocuspocus/server": "^1.0.0-alpha.107",
36
36
  "ioredis": "^4.28.2",
37
37
  "kleur": "^4.1.4",
38
38
  "lodash.debounce": "^4.0.8",
@@ -41,5 +41,5 @@
41
41
  "y-protocols": "^1.0.5",
42
42
  "yjs": "^13.5.23"
43
43
  },
44
- "gitHead": "6865794352a68372a54c579040513e45aac422d1"
44
+ "gitHead": "3dc62aedd8d19d4a9c346188885657ea814271c0"
45
45
  }