@abraca/dabra 1.0.13 → 1.0.14

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.
@@ -7609,6 +7609,48 @@ var FileBlobStore = class FileBlobStore extends EventEmitter {
7609
7609
  const tx = db.transaction("blobs", "readonly");
7610
7610
  return (await txPromise(tx.objectStore("blobs"), tx.objectStore("blobs").get(key)))?.blob ?? null;
7611
7611
  }
7612
+ /** Return metadata for all cached blobs (for storage stats). */
7613
+ async getAllCachedEntries() {
7614
+ const db = await this.getDb();
7615
+ if (!db) return [];
7616
+ return new Promise((resolve, reject) => {
7617
+ const tx = db.transaction("blobs", "readonly");
7618
+ const store = tx.objectStore("blobs");
7619
+ const keysReq = store.getAllKeys();
7620
+ const valuesReq = store.getAll();
7621
+ tx.oncomplete = () => {
7622
+ const keys = keysReq.result;
7623
+ const values = valuesReq.result;
7624
+ resolve(keys.map((key, i) => {
7625
+ const slashIdx = key.indexOf("/");
7626
+ const docId = key.slice(0, slashIdx);
7627
+ const uploadId = key.slice(slashIdx + 1);
7628
+ const e = values[i];
7629
+ return {
7630
+ docId,
7631
+ uploadId,
7632
+ filename: e.filename,
7633
+ mimeType: e.mime_type,
7634
+ size: e.blob.size,
7635
+ cachedAt: e.cachedAt
7636
+ };
7637
+ }));
7638
+ };
7639
+ tx.onerror = () => reject(tx.error);
7640
+ });
7641
+ }
7642
+ /** Revoke all object URLs and clear the entire blob cache from IDB. */
7643
+ async clearAllBlobs() {
7644
+ for (const url of this.objectUrls.values()) URL.revokeObjectURL(url);
7645
+ this.objectUrls.clear();
7646
+ const db = await this.getDb();
7647
+ if (!db) return;
7648
+ return new Promise((resolve, reject) => {
7649
+ const req = db.transaction("blobs", "readwrite").objectStore("blobs").clear();
7650
+ req.onsuccess = () => resolve();
7651
+ req.onerror = () => reject(req.error);
7652
+ });
7653
+ }
7612
7654
  /** Revoke the object URL and remove the blob from cache. */
7613
7655
  async evictBlob(docId, uploadId) {
7614
7656
  const key = this.blobKey(docId, uploadId);