@hocuspocus/common 3.2.4 → 3.2.6

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,5 +1,5 @@
1
- import type { Extension, Hocuspocus, afterLoadDocumentPayload, afterStoreDocumentPayload, beforeBroadcastStatelessPayload, onAwarenessUpdatePayload, onChangePayload, onConfigurePayload, onDisconnectPayload, onStoreDocumentPayload } from "@hocuspocus/server";
2
- import { Redlock, type ExecutionResult, type Lock } from '@sesamecare-oss/redlock';
1
+ import type { Extension, Hocuspocus, afterLoadDocumentPayload, afterStoreDocumentPayload, afterUnloadDocumentPayload, beforeBroadcastStatelessPayload, beforeUnloadDocumentPayload, onAwarenessUpdatePayload, onChangePayload, onConfigurePayload, onStoreDocumentPayload } from "@hocuspocus/server";
2
+ import { type ExecutionResult, type Lock, Redlock } from "@sesamecare-oss/redlock";
3
3
  import type { Cluster, ClusterNode, ClusterOptions, RedisOptions } from "ioredis";
4
4
  import RedisClient from "ioredis";
5
5
  export type RedisInstance = RedisClient | Cluster;
@@ -67,11 +67,6 @@ export declare class Redis implements Extension {
67
67
  release?: Promise<ExecutionResult>;
68
68
  }>;
69
69
  messagePrefix: Buffer;
70
- /**
71
- * When we have a high frequency of updates to a document we don't need tons of setTimeouts
72
- * piling up, so we'll track them to keep it to the most recent per document.
73
- */
74
- private pendingDisconnects;
75
70
  private pendingAfterStoreDocumentResolves;
76
71
  constructor(configuration: Partial<Configuration>);
77
72
  onConfigure({ instance }: onConfigurePayload): Promise<void>;
@@ -101,7 +96,7 @@ export declare class Redis implements Extension {
101
96
  /**
102
97
  * Release the Redis lock, so other instances can store documents.
103
98
  */
104
- afterStoreDocument({ documentName, socketId }: afterStoreDocumentPayload): Promise<void>;
99
+ afterStoreDocument({ documentName, socketId, }: afterStoreDocumentPayload): Promise<void>;
105
100
  /**
106
101
  * Handle awareness update messages received directly by this Hocuspocus instance.
107
102
  */
@@ -117,10 +112,10 @@ export declare class Redis implements Extension {
117
112
  */
118
113
  onChange(data: onChangePayload): Promise<any>;
119
114
  /**
120
- * Make sure to *not* listen for further changes, when there’s
121
- * no one connected anymore.
115
+ * Delay unloading to allow syncs to finish
122
116
  */
123
- onDisconnect: ({ documentName }: onDisconnectPayload) => Promise<void>;
117
+ beforeUnloadDocument(data: beforeUnloadDocumentPayload): Promise<void>;
118
+ afterUnloadDocument(data: afterUnloadDocumentPayload): Promise<void>;
124
119
  beforeBroadcastStateless(data: beforeBroadcastStatelessPayload): Promise<number>;
125
120
  /**
126
121
  * Kill the Redlock connection immediately.
@@ -1,6 +1,6 @@
1
- import type { Extension, onChangePayload, onConnectPayload, onLoadDocumentPayload, onDisconnectPayload } from "@hocuspocus/server";
2
- import type { Doc } from "yjs";
1
+ import type { Extension, onChangePayload, onConnectPayload, onDisconnectPayload, onLoadDocumentPayload } from "@hocuspocus/server";
3
2
  import type { Transformer } from "@hocuspocus/transformer";
3
+ import type { Doc } from "yjs";
4
4
  export declare enum Events {
5
5
  onChange = "change",
6
6
  onConnect = "connect",
@@ -2,6 +2,7 @@ import type WebSocket from "ws";
2
2
  import { Awareness } from "y-protocols/awareness";
3
3
  import { Doc } from "yjs";
4
4
  import type Connection from "./Connection.ts";
5
+ import { Mutex } from "async-mutex";
5
6
  export declare class Document extends Doc {
6
7
  awareness: Awareness;
7
8
  callbacks: {
@@ -16,6 +17,7 @@ export declare class Document extends Doc {
16
17
  name: string;
17
18
  isLoading: boolean;
18
19
  isDestroyed: boolean;
20
+ saveMutex: Mutex;
19
21
  /**
20
22
  * Constructor.
21
23
  */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hocuspocus/common",
3
3
  "description": "shared code for multiple Hocuspocus packages",
4
- "version": "3.2.4",
4
+ "version": "3.2.6",
5
5
  "homepage": "https://hocuspocus.dev",
6
6
  "keywords": [
7
7
  "hocuspocus"