@abraca/dabra 1.0.12 → 1.0.13

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.
@@ -1816,6 +1816,7 @@ var AbracadabraWS = class extends EventEmitter {
1816
1816
  this.webSocket?.removeEventListener(name, handlers[name]);
1817
1817
  delete this.webSocketHandlers[identifier];
1818
1818
  });
1819
+ if (this.webSocket.readyState !== 3) this.webSocket.addEventListener("error", () => {});
1819
1820
  try {
1820
1821
  if (this.webSocket.readyState !== 0 && this.webSocket.readyState !== 3) this.webSocket.close();
1821
1822
  } catch (e) {}
@@ -1922,6 +1923,7 @@ var AbracadabraWS = class extends EventEmitter {
1922
1923
  }
1923
1924
  }
1924
1925
  destroy() {
1926
+ this.shouldConnect = false;
1925
1927
  this.emit("destroy");
1926
1928
  clearInterval(this.intervals.connectionChecker);
1927
1929
  this.stopConnectionAttempt();
@@ -2597,10 +2599,11 @@ var OfflineStore = class {
2597
2599
  constructor(docId, serverOrigin) {
2598
2600
  this.db = null;
2599
2601
  this.dbPromise = null;
2602
+ this._destroyed = false;
2600
2603
  this.storeKey = serverOrigin ? `${serverOrigin}/${docId}` : docId;
2601
2604
  }
2602
2605
  getDb() {
2603
- if (!idbAvailable$4()) return Promise.resolve(null);
2606
+ if (this._destroyed || !idbAvailable$4()) return Promise.resolve(null);
2604
2607
  if (!this.dbPromise) this.dbPromise = openDb$5(this.storeKey).catch(() => null).then((db) => {
2605
2608
  this.db = db;
2606
2609
  return db;
@@ -2696,17 +2699,18 @@ var OfflineStore = class {
2696
2699
  const db = await this.getDb();
2697
2700
  if (!db) return null;
2698
2701
  const tx = db.transaction("meta", "readonly");
2699
- return await txPromise$2(tx.objectStore("meta"), tx.objectStore("meta").get(key)) ?? null;
2702
+ return await txPromise$2(tx.objectStore("meta"), tx.objectStore("meta").get(`meta:${key}`)) ?? null;
2700
2703
  }
2701
2704
  async setMeta(key, value) {
2702
2705
  const db = await this.getDb();
2703
2706
  if (!db) return;
2704
2707
  const tx = db.transaction("meta", "readwrite");
2705
- await txPromise$2(tx.objectStore("meta"), tx.objectStore("meta").put(value, key));
2708
+ await txPromise$2(tx.objectStore("meta"), tx.objectStore("meta").put(value, `meta:${key}`));
2706
2709
  }
2707
2710
  destroy() {
2708
- this.db?.close();
2711
+ this._destroyed = true;
2709
2712
  this.db = null;
2713
+ this.dbPromise = null;
2710
2714
  }
2711
2715
  };
2712
2716
 
@@ -7593,6 +7597,18 @@ var FileBlobStore = class FileBlobStore extends EventEmitter {
7593
7597
  this.objectUrls.set(key, url);
7594
7598
  return url;
7595
7599
  }
7600
+ /**
7601
+ * Retrieve the raw Blob from IDB for a previously cached upload.
7602
+ * Returns null if the blob has been evicted or was never stored.
7603
+ * Use this to re-upload a file after a page reload.
7604
+ */
7605
+ async getBlob(docId, uploadId) {
7606
+ const db = await this.getDb();
7607
+ if (!db) return null;
7608
+ const key = this.blobKey(docId, uploadId);
7609
+ const tx = db.transaction("blobs", "readonly");
7610
+ return (await txPromise(tx.objectStore("blobs"), tx.objectStore("blobs").get(key)))?.blob ?? null;
7611
+ }
7596
7612
  /** Revoke the object URL and remove the blob from cache. */
7597
7613
  async evictBlob(docId, uploadId) {
7598
7614
  const key = this.blobKey(docId, uploadId);