@interncom/diplomatic 0.0.52 → 0.0.54
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/index.mjs +38 -25
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -2831,6 +2831,17 @@ function openDB(name, version, { blocked, upgrade, blocking, terminated } = {})
|
|
|
2831
2831
|
});
|
|
2832
2832
|
return openPromise;
|
|
2833
2833
|
}
|
|
2834
|
+
function deleteDB(name, { blocked } = {}) {
|
|
2835
|
+
const request = indexedDB.deleteDatabase(name);
|
|
2836
|
+
if (blocked) {
|
|
2837
|
+
request.addEventListener("blocked", (event) => blocked(
|
|
2838
|
+
// Casting due to https://github.com/microsoft/TypeScript-DOM-lib-generator/pull/1405
|
|
2839
|
+
event.oldVersion,
|
|
2840
|
+
event
|
|
2841
|
+
));
|
|
2842
|
+
}
|
|
2843
|
+
return wrap(request).then(() => void 0);
|
|
2844
|
+
}
|
|
2834
2845
|
var readMethods = ["get", "getKey", "getAll", "getAllKeys", "count"];
|
|
2835
2846
|
var writeMethods = ["put", "add", "delete", "clear"];
|
|
2836
2847
|
var cachedMethods = /* @__PURE__ */ new Map();
|
|
@@ -2917,38 +2928,39 @@ replaceTraps((oldTraps) => ({
|
|
|
2917
2928
|
}));
|
|
2918
2929
|
|
|
2919
2930
|
// src/idbStore.ts
|
|
2920
|
-
var
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
db3.
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
db3.
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
db3.
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
db3.
|
|
2937
|
-
|
|
2938
|
-
|
|
2931
|
+
var initDB = async () => {
|
|
2932
|
+
return await openDB("client-store-db", 6, {
|
|
2933
|
+
upgrade(db3) {
|
|
2934
|
+
if (!db3.objectStoreNames.contains("metaKV")) {
|
|
2935
|
+
db3.createObjectStore("metaKV");
|
|
2936
|
+
}
|
|
2937
|
+
if (!db3.objectStoreNames.contains("ops")) {
|
|
2938
|
+
db3.createObjectStore("ops", {
|
|
2939
|
+
keyPath: "sha256"
|
|
2940
|
+
});
|
|
2941
|
+
}
|
|
2942
|
+
if (!db3.objectStoreNames.contains("uploadQueue")) {
|
|
2943
|
+
db3.createObjectStore("uploadQueue", {
|
|
2944
|
+
keyPath: "sha256"
|
|
2945
|
+
});
|
|
2946
|
+
}
|
|
2947
|
+
if (!db3.objectStoreNames.contains("downloadQueue")) {
|
|
2948
|
+
db3.createObjectStore("downloadQueue", {
|
|
2949
|
+
keyPath: "sha256"
|
|
2950
|
+
});
|
|
2951
|
+
}
|
|
2939
2952
|
}
|
|
2940
|
-
}
|
|
2941
|
-
}
|
|
2953
|
+
});
|
|
2954
|
+
};
|
|
2955
|
+
var db = await initDB();
|
|
2942
2956
|
var IDBStore = class {
|
|
2943
2957
|
seed;
|
|
2944
2958
|
hostURL;
|
|
2945
2959
|
hostID;
|
|
2946
2960
|
lastFetchedAt;
|
|
2947
2961
|
async wipe() {
|
|
2948
|
-
await
|
|
2949
|
-
await
|
|
2950
|
-
await db.clear("downloadQueue");
|
|
2951
|
-
await db.clear("ops");
|
|
2962
|
+
await deleteDB("client-store-db");
|
|
2963
|
+
db = await initDB();
|
|
2952
2964
|
}
|
|
2953
2965
|
async getSeed() {
|
|
2954
2966
|
const hex = await db.get("metaKV", "seed");
|
|
@@ -11775,6 +11787,7 @@ var applier = async (op) => {
|
|
|
11775
11787
|
if (new Date(op.ts) > (curr?.updatedAt ?? "")) {
|
|
11776
11788
|
await db2.put("entities", {
|
|
11777
11789
|
eid: op.eid,
|
|
11790
|
+
gid: op.gid,
|
|
11778
11791
|
type: op.type,
|
|
11779
11792
|
createdAt: curr?.createdAt ?? /* @__PURE__ */ new Date(),
|
|
11780
11793
|
updatedAt: new Date(op.ts),
|