@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.
- package/dist/abracadabra-provider.cjs +20 -4
- package/dist/abracadabra-provider.cjs.map +1 -1
- package/dist/abracadabra-provider.esm.js +20 -4
- package/dist/abracadabra-provider.esm.js.map +1 -1
- package/dist/index.d.ts +9 -0
- package/package.json +1 -1
- package/src/AbracadabraClient.ts +1 -1
- package/src/AbracadabraWS.ts +16 -3
- package/src/FileBlobStore.ts +18 -0
- package/src/OfflineStore.ts +11 -4
|
@@ -1786,6 +1786,7 @@ var AbracadabraWS = class extends EventEmitter {
|
|
|
1786
1786
|
this.webSocket?.removeEventListener(name, handlers[name]);
|
|
1787
1787
|
delete this.webSocketHandlers[identifier];
|
|
1788
1788
|
});
|
|
1789
|
+
if (this.webSocket.readyState !== 3) this.webSocket.addEventListener("error", () => {});
|
|
1789
1790
|
try {
|
|
1790
1791
|
if (this.webSocket.readyState !== 0 && this.webSocket.readyState !== 3) this.webSocket.close();
|
|
1791
1792
|
} catch (e) {}
|
|
@@ -1892,6 +1893,7 @@ var AbracadabraWS = class extends EventEmitter {
|
|
|
1892
1893
|
}
|
|
1893
1894
|
}
|
|
1894
1895
|
destroy() {
|
|
1896
|
+
this.shouldConnect = false;
|
|
1895
1897
|
this.emit("destroy");
|
|
1896
1898
|
clearInterval(this.intervals.connectionChecker);
|
|
1897
1899
|
this.stopConnectionAttempt();
|
|
@@ -2567,10 +2569,11 @@ var OfflineStore = class {
|
|
|
2567
2569
|
constructor(docId, serverOrigin) {
|
|
2568
2570
|
this.db = null;
|
|
2569
2571
|
this.dbPromise = null;
|
|
2572
|
+
this._destroyed = false;
|
|
2570
2573
|
this.storeKey = serverOrigin ? `${serverOrigin}/${docId}` : docId;
|
|
2571
2574
|
}
|
|
2572
2575
|
getDb() {
|
|
2573
|
-
if (!idbAvailable$4()) return Promise.resolve(null);
|
|
2576
|
+
if (this._destroyed || !idbAvailable$4()) return Promise.resolve(null);
|
|
2574
2577
|
if (!this.dbPromise) this.dbPromise = openDb$5(this.storeKey).catch(() => null).then((db) => {
|
|
2575
2578
|
this.db = db;
|
|
2576
2579
|
return db;
|
|
@@ -2666,17 +2669,18 @@ var OfflineStore = class {
|
|
|
2666
2669
|
const db = await this.getDb();
|
|
2667
2670
|
if (!db) return null;
|
|
2668
2671
|
const tx = db.transaction("meta", "readonly");
|
|
2669
|
-
return await txPromise$2(tx.objectStore("meta"), tx.objectStore("meta").get(key)) ?? null;
|
|
2672
|
+
return await txPromise$2(tx.objectStore("meta"), tx.objectStore("meta").get(`meta:${key}`)) ?? null;
|
|
2670
2673
|
}
|
|
2671
2674
|
async setMeta(key, value) {
|
|
2672
2675
|
const db = await this.getDb();
|
|
2673
2676
|
if (!db) return;
|
|
2674
2677
|
const tx = db.transaction("meta", "readwrite");
|
|
2675
|
-
await txPromise$2(tx.objectStore("meta"), tx.objectStore("meta").put(value, key));
|
|
2678
|
+
await txPromise$2(tx.objectStore("meta"), tx.objectStore("meta").put(value, `meta:${key}`));
|
|
2676
2679
|
}
|
|
2677
2680
|
destroy() {
|
|
2678
|
-
this.
|
|
2681
|
+
this._destroyed = true;
|
|
2679
2682
|
this.db = null;
|
|
2683
|
+
this.dbPromise = null;
|
|
2680
2684
|
}
|
|
2681
2685
|
};
|
|
2682
2686
|
|
|
@@ -7563,6 +7567,18 @@ var FileBlobStore = class FileBlobStore extends EventEmitter {
|
|
|
7563
7567
|
this.objectUrls.set(key, url);
|
|
7564
7568
|
return url;
|
|
7565
7569
|
}
|
|
7570
|
+
/**
|
|
7571
|
+
* Retrieve the raw Blob from IDB for a previously cached upload.
|
|
7572
|
+
* Returns null if the blob has been evicted or was never stored.
|
|
7573
|
+
* Use this to re-upload a file after a page reload.
|
|
7574
|
+
*/
|
|
7575
|
+
async getBlob(docId, uploadId) {
|
|
7576
|
+
const db = await this.getDb();
|
|
7577
|
+
if (!db) return null;
|
|
7578
|
+
const key = this.blobKey(docId, uploadId);
|
|
7579
|
+
const tx = db.transaction("blobs", "readonly");
|
|
7580
|
+
return (await txPromise(tx.objectStore("blobs"), tx.objectStore("blobs").get(key)))?.blob ?? null;
|
|
7581
|
+
}
|
|
7566
7582
|
/** Revoke the object URL and remove the blob from cache. */
|
|
7567
7583
|
async evictBlob(docId, uploadId) {
|
|
7568
7584
|
const key = this.blobKey(docId, uploadId);
|