@hocuspocus/provider 3.2.1 → 3.2.2

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.
@@ -1,7 +1,8 @@
1
1
  import type { Extension, Hocuspocus, afterLoadDocumentPayload, afterStoreDocumentPayload, beforeBroadcastStatelessPayload, onAwarenessUpdatePayload, onChangePayload, onConfigurePayload, onDisconnectPayload, onStoreDocumentPayload } from "@hocuspocus/server";
2
- import type { ClusterNode, ClusterOptions, RedisOptions } from "ioredis";
3
- import Redlock from "redlock";
4
- export type RedisInstance = RedisClient.Cluster | RedisClient.Redis;
2
+ import { Redlock, type ExecutionResult, type Lock } from '@sesamecare-oss/redlock';
3
+ import type { Cluster, ClusterNode, ClusterOptions, RedisOptions } from "ioredis";
4
+ import RedisClient from "ioredis";
5
+ export type RedisInstance = RedisClient | Cluster;
5
6
  export interface Configuration {
6
7
  /**
7
8
  * Redis port
@@ -61,7 +62,10 @@ export declare class Redis implements Extension {
61
62
  sub: RedisInstance;
62
63
  instance: Hocuspocus;
63
64
  redlock: Redlock;
64
- locks: Map<string, Redlock.Lock>;
65
+ locks: Map<string, {
66
+ lock: Lock;
67
+ release?: Promise<ExecutionResult>;
68
+ }>;
65
69
  messagePrefix: Buffer;
66
70
  /**
67
71
  * When we have a high frequency of updates to a document we don't need tons of setTimeouts
@@ -93,15 +97,15 @@ export declare class Redis implements Extension {
93
97
  * Before the document is stored, make sure to set a lock in Redis.
94
98
  * That’s meant to avoid conflicts with other instances trying to store the document.
95
99
  */
96
- onStoreDocument({ documentName }: onStoreDocumentPayload): Promise<unknown>;
100
+ onStoreDocument({ documentName }: onStoreDocumentPayload): Promise<void>;
97
101
  /**
98
102
  * Release the Redis lock, so other instances can store documents.
99
103
  */
100
- afterStoreDocument({ documentName, socketId, }: afterStoreDocumentPayload): Promise<void>;
104
+ afterStoreDocument({ documentName, socketId }: afterStoreDocumentPayload): Promise<void>;
101
105
  /**
102
106
  * Handle awareness update messages received directly by this Hocuspocus instance.
103
107
  */
104
- onAwarenessUpdate({ documentName, awareness, added, updated, removed, }: onAwarenessUpdatePayload): Promise<any>;
108
+ onAwarenessUpdate({ documentName, awareness, added, updated, removed, }: onAwarenessUpdatePayload): Promise<number>;
105
109
  /**
106
110
  * Handle incoming messages published on subscribed document channels.
107
111
  * Note that this will also include messages from ourselves as it is not possible
@@ -117,7 +121,7 @@ export declare class Redis implements Extension {
117
121
  * no one connected anymore.
118
122
  */
119
123
  onDisconnect: ({ documentName }: onDisconnectPayload) => Promise<void>;
120
- beforeBroadcastStateless(data: beforeBroadcastStatelessPayload): Promise<any>;
124
+ beforeBroadcastStateless(data: beforeBroadcastStatelessPayload): Promise<number>;
121
125
  /**
122
126
  * Kill the Redlock connection immediately.
123
127
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hocuspocus/provider",
3
- "version": "3.2.1",
3
+ "version": "3.2.2",
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": "^3.2.1",
32
+ "@hocuspocus/common": "^3.2.2",
33
33
  "@lifeomic/attempt": "^3.0.2",
34
34
  "lib0": "^0.2.87",
35
35
  "ws": "^8.17.1"