@abraca/dabra 1.0.18 → 1.0.20

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.
@@ -1715,7 +1715,7 @@ var AbracadabraWS = class extends EventEmitter {
1715
1715
  }
1716
1716
  attach(provider) {
1717
1717
  const existing = this.configuration.providerMap.get(provider.configuration.name);
1718
- if (existing && existing !== provider) console.warn(`[AbracadabraWS] attach: overwriting provider for "${provider.configuration.name}". This may indicate a duplicate loadChild for the same document.`);
1718
+ if (existing && existing !== provider) console.debug(`[AbracadabraWS] attach: replacing provider for "${provider.configuration.name}".`);
1719
1719
  this.configuration.providerMap.set(provider.configuration.name, provider);
1720
1720
  if (this.status === WebSocketStatus.Disconnected && this.shouldConnect) this.connect();
1721
1721
  if (this.receivedOnOpenPayload && this.status === WebSocketStatus.Connected) provider.onOpen(this.receivedOnOpenPayload);
@@ -2714,8 +2714,10 @@ var OfflineStore = class {
2714
2714
  }
2715
2715
  destroy() {
2716
2716
  this._destroyed = true;
2717
+ const db = this.db;
2717
2718
  this.db = null;
2718
2719
  this.dbPromise = null;
2720
+ if (db) Promise.resolve().then(() => db.close());
2719
2721
  }
2720
2722
  };
2721
2723
 
@@ -8574,10 +8576,20 @@ var BackgroundSyncManager = class extends EventEmitter {
8574
8576
  }
8575
8577
  }
8576
8578
  async _syncNonE2EDoc(docId) {
8579
+ const alreadyCached = this.rootProvider.children.has(docId);
8580
+ if (!alreadyCached) {
8581
+ if ((this.rootProvider.configuration?.websocketProvider?.configuration?.providerMap)?.has(docId)) return {
8582
+ docId,
8583
+ status: "synced",
8584
+ lastSynced: Date.now(),
8585
+ isE2E: false
8586
+ };
8587
+ }
8577
8588
  const childProvider = await this.rootProvider.loadChild(docId);
8578
8589
  await childProvider.ready;
8579
8590
  await this._waitForSynced(childProvider);
8580
8591
  if (this.opts.prefetchFiles && this.fileBlobStore) this._prefetchDocFiles(docId, childProvider.document).catch(() => null);
8592
+ if (!alreadyCached) this.rootProvider.unloadChild(docId);
8581
8593
  return {
8582
8594
  docId,
8583
8595
  status: "synced",