@abraca/dabra 0.1.4 → 0.1.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.
@@ -2272,17 +2272,27 @@ var AbracadabraProvider = class AbracadabraProvider extends HocuspocusProvider {
2272
2272
  }
2273
2273
  /**
2274
2274
  * Create (or return cached) a child AbracadabraProvider for a given
2275
- * child document id. The child shares the parent's WebSocket connection.
2275
+ * child document id. Each child opens its own WebSocket connection because
2276
+ * the server is document-scoped (one WebSocket ↔ one document).
2276
2277
  */
2277
2278
  async loadChild(childId) {
2278
2279
  if (this.childProviders.has(childId)) return this.childProviders.get(childId);
2279
2280
  const childDoc = new yjs.Doc({ guid: childId });
2280
- const parentWsp = this.configuration.websocketProvider;
2281
+ await new Promise((resolve) => {
2282
+ const onRegistered = ({ childId: cid }) => {
2283
+ if (cid === childId) {
2284
+ this.off("subdocRegistered", onRegistered);
2285
+ resolve();
2286
+ }
2287
+ };
2288
+ this.on("subdocRegistered", onRegistered);
2289
+ this.registerSubdoc(childDoc);
2290
+ setTimeout(resolve, 3e3);
2291
+ });
2281
2292
  const childProvider = new AbracadabraProvider({
2282
2293
  name: childId,
2283
2294
  document: childDoc,
2284
- url: parentWsp.configuration.url,
2285
- WebSocketPolyfill: parentWsp.configuration.WebSocketPolyfill,
2295
+ url: this.abracadabraConfig.url,
2286
2296
  token: this.configuration.token,
2287
2297
  subdocLoading: this.subdocLoading,
2288
2298
  disableOfflineStore: this.abracadabraConfig.disableOfflineStore,