@hocuspocus/provider 1.0.0-alpha.27 → 1.0.0-alpha.28
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 +7 -2
- package/dist/hocuspocus-provider.cjs.map +1 -1
- package/dist/hocuspocus-provider.esm.js +7 -2
- package/dist/hocuspocus-provider.esm.js.map +1 -1
- package/dist/packages/extension-database/src/Database.d.ts +36 -0
- package/dist/packages/extension-database/src/index.d.ts +1 -0
- package/dist/packages/extension-sqlite/src/SQLite.d.ts +26 -0
- package/dist/packages/extension-sqlite/src/index.d.ts +1 -0
- package/dist/packages/extension-webhook/src/index.d.ts +1 -1
- package/dist/packages/provider/src/HocuspocusProvider.d.ts +1 -1
- package/dist/{demos/backend/src/express.d.ts → playground/backend/src/default.d.ts} +0 -0
- package/dist/{demos/backend/src/koa.d.ts → playground/backend/src/express.d.ts} +0 -0
- package/dist/{demos/backend/src/load-document.d.ts → playground/backend/src/koa.d.ts} +0 -0
- package/dist/{demos/backend/src/minimal.d.ts → playground/backend/src/load-document.d.ts} +0 -0
- package/dist/{demos → playground}/backend/src/monitor.d.ts +0 -0
- package/dist/{demos → playground}/backend/src/redis.d.ts +0 -0
- package/dist/{demos → playground}/backend/src/slow.d.ts +0 -0
- package/dist/{demos → playground}/backend/src/webhook.d.ts +0 -0
- package/package.json +5 -5
- package/src/HocuspocusProvider.ts +9 -2
|
@@ -2081,7 +2081,7 @@ class HocuspocusProvider extends EventEmitter {
|
|
|
2081
2081
|
});
|
|
2082
2082
|
this.document.on('update', this.documentUpdateHandler.bind(this));
|
|
2083
2083
|
this.awareness.on('update', this.awarenessUpdateHandler.bind(this));
|
|
2084
|
-
this.
|
|
2084
|
+
this.registerEventListeners();
|
|
2085
2085
|
this.intervals.connectionChecker = setInterval(this.checkConnection.bind(this), this.options.messageReconnectTimeout / 10);
|
|
2086
2086
|
if (this.options.forceSyncInterval) {
|
|
2087
2087
|
this.intervals.forceSync = setInterval(this.forceSync.bind(this), this.options.forceSyncInterval);
|
|
@@ -2191,10 +2191,11 @@ class HocuspocusProvider extends EventEmitter {
|
|
|
2191
2191
|
}
|
|
2192
2192
|
this.send(SyncStepOneMessage, { document: this.document });
|
|
2193
2193
|
}
|
|
2194
|
-
|
|
2194
|
+
registerEventListeners() {
|
|
2195
2195
|
if (typeof window === 'undefined') {
|
|
2196
2196
|
return;
|
|
2197
2197
|
}
|
|
2198
|
+
window.addEventListener('online', this.connect.bind(this));
|
|
2198
2199
|
window.addEventListener('beforeunload', () => {
|
|
2199
2200
|
removeAwarenessStates(this.awareness, [this.document.clientID], 'window unload');
|
|
2200
2201
|
});
|
|
@@ -2359,6 +2360,10 @@ class HocuspocusProvider extends EventEmitter {
|
|
|
2359
2360
|
this.awareness.off('update', this.awarenessUpdateHandler);
|
|
2360
2361
|
this.document.off('update', this.documentUpdateHandler);
|
|
2361
2362
|
this.removeAllListeners();
|
|
2363
|
+
if (typeof window === 'undefined') {
|
|
2364
|
+
return;
|
|
2365
|
+
}
|
|
2366
|
+
window.removeEventListener('online', this.connect.bind(this));
|
|
2362
2367
|
}
|
|
2363
2368
|
get broadcastChannel() {
|
|
2364
2369
|
return `${this.serverUrl}/${this.options.name}`;
|