@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.
@@ -1745,7 +1745,7 @@ var AbracadabraWS = class extends EventEmitter {
1745
1745
  }
1746
1746
  attach(provider) {
1747
1747
  const existing = this.configuration.providerMap.get(provider.configuration.name);
1748
- if (existing && existing !== provider) console.warn(`[AbracadabraWS] attach: overwriting provider for "${provider.configuration.name}". This may indicate a duplicate loadChild for the same document.`);
1748
+ if (existing && existing !== provider) console.debug(`[AbracadabraWS] attach: replacing provider for "${provider.configuration.name}".`);
1749
1749
  this.configuration.providerMap.set(provider.configuration.name, provider);
1750
1750
  if (this.status === WebSocketStatus.Disconnected && this.shouldConnect) this.connect();
1751
1751
  if (this.receivedOnOpenPayload && this.status === WebSocketStatus.Connected) provider.onOpen(this.receivedOnOpenPayload);
@@ -2744,8 +2744,10 @@ var OfflineStore = class {
2744
2744
  }
2745
2745
  destroy() {
2746
2746
  this._destroyed = true;
2747
+ const db = this.db;
2747
2748
  this.db = null;
2748
2749
  this.dbPromise = null;
2750
+ if (db) Promise.resolve().then(() => db.close());
2749
2751
  }
2750
2752
  };
2751
2753
 
@@ -8626,10 +8628,20 @@ var BackgroundSyncManager = class extends EventEmitter {
8626
8628
  }
8627
8629
  }
8628
8630
  async _syncNonE2EDoc(docId) {
8631
+ const alreadyCached = this.rootProvider.children.has(docId);
8632
+ if (!alreadyCached) {
8633
+ if ((this.rootProvider.configuration?.websocketProvider?.configuration?.providerMap)?.has(docId)) return {
8634
+ docId,
8635
+ status: "synced",
8636
+ lastSynced: Date.now(),
8637
+ isE2E: false
8638
+ };
8639
+ }
8629
8640
  const childProvider = await this.rootProvider.loadChild(docId);
8630
8641
  await childProvider.ready;
8631
8642
  await this._waitForSynced(childProvider);
8632
8643
  if (this.opts.prefetchFiles && this.fileBlobStore) this._prefetchDocFiles(docId, childProvider.document).catch(() => null);
8644
+ if (!alreadyCached) this.rootProvider.unloadChild(docId);
8633
8645
  return {
8634
8646
  docId,
8635
8647
  status: "synced",