@hocuspocus/provider 2.0.2 → 2.0.3
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/hocuspocus-provider.cjs +9 -2
- package/dist/hocuspocus-provider.cjs.map +1 -1
- package/dist/hocuspocus-provider.esm.js +9 -2
- package/dist/hocuspocus-provider.esm.js.map +1 -1
- package/dist/packages/extension-redis/src/Redis.d.ts +6 -1
- package/dist/packages/provider/src/HocuspocusProvider.d.ts +1 -0
- package/package.json +2 -2
- package/src/HocuspocusProvider.ts +11 -2
- package/src/MessageReceiver.ts +1 -1
|
@@ -42,6 +42,11 @@ export interface Configuration {
|
|
|
42
42
|
* The maximum time for the Redis lock in ms (in case it can’t be released).
|
|
43
43
|
*/
|
|
44
44
|
lockTimeout: number;
|
|
45
|
+
/**
|
|
46
|
+
* A delay before onDisconnect is executed. This allows last minute updates'
|
|
47
|
+
* sync messages to be received by the subscription before it's closed.
|
|
48
|
+
*/
|
|
49
|
+
disconnectDelay: number;
|
|
45
50
|
}
|
|
46
51
|
export declare class Redis implements Extension {
|
|
47
52
|
/**
|
|
@@ -103,7 +108,7 @@ export declare class Redis implements Extension {
|
|
|
103
108
|
* Make sure to *not* listen for further changes, when there’s
|
|
104
109
|
* noone connected anymore.
|
|
105
110
|
*/
|
|
106
|
-
onDisconnect: ({
|
|
111
|
+
onDisconnect: ({ document, documentName }: onDisconnectPayload) => Promise<void>;
|
|
107
112
|
beforeBroadcastStateless(data: beforeBroadcastStatelessPayload): Promise<number>;
|
|
108
113
|
/**
|
|
109
114
|
* Kill the Redlock connection immediately.
|
|
@@ -77,6 +77,7 @@ export declare class HocuspocusProvider extends EventEmitter {
|
|
|
77
77
|
get document(): Y.Doc;
|
|
78
78
|
get awareness(): Awareness;
|
|
79
79
|
get hasUnsyncedChanges(): boolean;
|
|
80
|
+
updateUnsyncedChanges(unsyncedChanges?: number): void;
|
|
80
81
|
forceSync(): void;
|
|
81
82
|
boundBeforeUnload: () => void;
|
|
82
83
|
beforeUnload(): void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hocuspocus/provider",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.3",
|
|
4
4
|
"description": "hocuspocus provider",
|
|
5
5
|
"homepage": "https://hocuspocus.dev",
|
|
6
6
|
"keywords": [
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"dist"
|
|
29
29
|
],
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@hocuspocus/common": "^2.0.
|
|
31
|
+
"@hocuspocus/common": "^2.0.3",
|
|
32
32
|
"@lifeomic/attempt": "^3.0.2",
|
|
33
33
|
"lib0": "^0.2.47",
|
|
34
34
|
"ws": "^7.5.9"
|
|
@@ -232,10 +232,15 @@ export class HocuspocusProvider extends EventEmitter {
|
|
|
232
232
|
return this.configuration.awareness
|
|
233
233
|
}
|
|
234
234
|
|
|
235
|
-
get hasUnsyncedChanges() {
|
|
235
|
+
get hasUnsyncedChanges(): boolean {
|
|
236
236
|
return this.unsyncedChanges > 0
|
|
237
237
|
}
|
|
238
238
|
|
|
239
|
+
updateUnsyncedChanges(unsyncedChanges = 0) {
|
|
240
|
+
this.unsyncedChanges += unsyncedChanges
|
|
241
|
+
this.emit('unsyncedChanges', this.unsyncedChanges)
|
|
242
|
+
}
|
|
243
|
+
|
|
239
244
|
forceSync() {
|
|
240
245
|
this.send(SyncStepOneMessage, { document: this.document, documentName: this.configuration.name })
|
|
241
246
|
}
|
|
@@ -263,7 +268,7 @@ export class HocuspocusProvider extends EventEmitter {
|
|
|
263
268
|
return
|
|
264
269
|
}
|
|
265
270
|
|
|
266
|
-
this.
|
|
271
|
+
this.updateUnsyncedChanges(1)
|
|
267
272
|
this.send(UpdateMessage, { update, documentName: this.configuration.name }, true)
|
|
268
273
|
}
|
|
269
274
|
|
|
@@ -286,6 +291,10 @@ export class HocuspocusProvider extends EventEmitter {
|
|
|
286
291
|
return
|
|
287
292
|
}
|
|
288
293
|
|
|
294
|
+
if (state && this.unsyncedChanges > 0) {
|
|
295
|
+
this.updateUnsyncedChanges(-1 * this.unsyncedChanges)
|
|
296
|
+
}
|
|
297
|
+
|
|
289
298
|
this.isSynced = state
|
|
290
299
|
this.emit('synced', { state })
|
|
291
300
|
this.emit('sync', { state })
|
package/src/MessageReceiver.ts
CHANGED