@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
|
@@ -2057,7 +2057,7 @@ class HocuspocusProvider extends EventEmitter {
|
|
|
2057
2057
|
});
|
|
2058
2058
|
this.document.on('update', this.documentUpdateHandler.bind(this));
|
|
2059
2059
|
this.awareness.on('update', this.awarenessUpdateHandler.bind(this));
|
|
2060
|
-
this.
|
|
2060
|
+
this.registerEventListeners();
|
|
2061
2061
|
this.intervals.connectionChecker = setInterval(this.checkConnection.bind(this), this.options.messageReconnectTimeout / 10);
|
|
2062
2062
|
if (this.options.forceSyncInterval) {
|
|
2063
2063
|
this.intervals.forceSync = setInterval(this.forceSync.bind(this), this.options.forceSyncInterval);
|
|
@@ -2167,10 +2167,11 @@ class HocuspocusProvider extends EventEmitter {
|
|
|
2167
2167
|
}
|
|
2168
2168
|
this.send(SyncStepOneMessage, { document: this.document });
|
|
2169
2169
|
}
|
|
2170
|
-
|
|
2170
|
+
registerEventListeners() {
|
|
2171
2171
|
if (typeof window === 'undefined') {
|
|
2172
2172
|
return;
|
|
2173
2173
|
}
|
|
2174
|
+
window.addEventListener('online', this.connect.bind(this));
|
|
2174
2175
|
window.addEventListener('beforeunload', () => {
|
|
2175
2176
|
removeAwarenessStates(this.awareness, [this.document.clientID], 'window unload');
|
|
2176
2177
|
});
|
|
@@ -2335,6 +2336,10 @@ class HocuspocusProvider extends EventEmitter {
|
|
|
2335
2336
|
this.awareness.off('update', this.awarenessUpdateHandler);
|
|
2336
2337
|
this.document.off('update', this.documentUpdateHandler);
|
|
2337
2338
|
this.removeAllListeners();
|
|
2339
|
+
if (typeof window === 'undefined') {
|
|
2340
|
+
return;
|
|
2341
|
+
}
|
|
2342
|
+
window.removeEventListener('online', this.connect.bind(this));
|
|
2338
2343
|
}
|
|
2339
2344
|
get broadcastChannel() {
|
|
2340
2345
|
return `${this.serverUrl}/${this.options.name}`;
|