@hocuspocus/provider 2.12.2 → 2.13.0

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.
@@ -26,6 +26,7 @@ export declare const defaultConfiguration: {
26
26
  */
27
27
  export declare class Hocuspocus {
28
28
  configuration: Configuration;
29
+ loadingDocuments: Map<string, Promise<Document>>;
29
30
  documents: Map<string, Document>;
30
31
  server?: HocuspocusServer;
31
32
  debugger: Debugger;
@@ -87,6 +88,7 @@ export declare class Hocuspocus {
87
88
  * Create a new document by the given request
88
89
  */
89
90
  createDocument(documentName: string, request: Partial<Pick<IncomingMessage, 'headers' | 'url'>>, socketId: string, connection: ConnectionConfiguration, context?: any): Promise<Document>;
91
+ loadDocument(documentName: string, request: Partial<Pick<IncomingMessage, 'headers' | 'url'>>, socketId: string, connection: ConnectionConfiguration, context?: any): Promise<Document>;
90
92
  storeDocumentHooks(document: Document, hookPayload: onStoreDocumentPayload): Promise<void>;
91
93
  /**
92
94
  * Run the given hook on all configured extensions.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hocuspocus/provider",
3
- "version": "2.12.2",
3
+ "version": "2.13.0",
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": "^2.12.2",
32
+ "@hocuspocus/common": "^2.13.0",
33
33
  "@lifeomic/attempt": "^3.0.2",
34
34
  "lib0": "^0.2.87",
35
35
  "ws": "^8.14.2"
@@ -216,7 +216,10 @@ export class HocuspocusProvider extends EventEmitter {
216
216
  this.awareness?.on('update', this.awarenessUpdateHandler.bind(this))
217
217
  this.registerEventListeners()
218
218
 
219
- if (this.configuration.forceSyncInterval) {
219
+ if (
220
+ this.configuration.forceSyncInterval
221
+ && typeof this.configuration.forceSyncInterval === 'number'
222
+ ) {
220
223
  this.intervals.forceSync = setInterval(
221
224
  this.forceSync.bind(this),
222
225
  this.configuration.forceSyncInterval,
@@ -303,7 +306,7 @@ export class HocuspocusProvider extends EventEmitter {
303
306
  }
304
307
 
305
308
  registerEventListeners() {
306
- if (typeof window === 'undefined') {
309
+ if (typeof window === 'undefined' || !('addEventListener' in window)) {
307
310
  return
308
311
  }
309
312
 
@@ -503,7 +506,7 @@ export class HocuspocusProvider extends EventEmitter {
503
506
  this.send(CloseMessage, { documentName: this.configuration.name })
504
507
  this.disconnect()
505
508
 
506
- if (typeof window === 'undefined') {
509
+ if (typeof window === 'undefined' || !('removeEventListener' in window)) {
507
510
  return
508
511
  }
509
512