@interncom/diplomatic 0.0.56 → 0.0.58

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.
Files changed (2) hide show
  1. package/dist/index.mjs +28 -38
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -2846,17 +2846,6 @@ function openDB(name, version, { blocked, upgrade, blocking, terminated } = {})
2846
2846
  });
2847
2847
  return openPromise;
2848
2848
  }
2849
- function deleteDB(name, { blocked } = {}) {
2850
- const request = indexedDB.deleteDatabase(name);
2851
- if (blocked) {
2852
- request.addEventListener("blocked", (event) => blocked(
2853
- // Casting due to https://github.com/microsoft/TypeScript-DOM-lib-generator/pull/1405
2854
- event.oldVersion,
2855
- event
2856
- ));
2857
- }
2858
- return wrap(request).then(() => void 0);
2859
- }
2860
2849
  var readMethods = ["get", "getKey", "getAll", "getAllKeys", "count"];
2861
2850
  var writeMethods = ["put", "add", "delete", "clear"];
2862
2851
  var cachedMethods = /* @__PURE__ */ new Map();
@@ -2943,39 +2932,38 @@ replaceTraps((oldTraps) => ({
2943
2932
  }));
2944
2933
 
2945
2934
  // src/idbStore.ts
2946
- var initDB = () => {
2947
- return openDB("client-store-db", 6, {
2948
- upgrade(db3) {
2949
- if (!db3.objectStoreNames.contains("metaKV")) {
2950
- db3.createObjectStore("metaKV");
2951
- }
2952
- if (!db3.objectStoreNames.contains("ops")) {
2953
- db3.createObjectStore("ops", {
2954
- keyPath: "sha256"
2955
- });
2956
- }
2957
- if (!db3.objectStoreNames.contains("uploadQueue")) {
2958
- db3.createObjectStore("uploadQueue", {
2959
- keyPath: "sha256"
2960
- });
2961
- }
2962
- if (!db3.objectStoreNames.contains("downloadQueue")) {
2963
- db3.createObjectStore("downloadQueue", {
2964
- keyPath: "sha256"
2965
- });
2966
- }
2935
+ var db = await openDB("client-store-db", 6, {
2936
+ upgrade(db3) {
2937
+ if (!db3.objectStoreNames.contains("metaKV")) {
2938
+ db3.createObjectStore("metaKV");
2967
2939
  }
2968
- });
2969
- };
2970
- var db = await initDB();
2940
+ if (!db3.objectStoreNames.contains("ops")) {
2941
+ db3.createObjectStore("ops", {
2942
+ keyPath: "sha256"
2943
+ });
2944
+ }
2945
+ if (!db3.objectStoreNames.contains("uploadQueue")) {
2946
+ db3.createObjectStore("uploadQueue", {
2947
+ keyPath: "sha256"
2948
+ });
2949
+ }
2950
+ if (!db3.objectStoreNames.contains("downloadQueue")) {
2951
+ db3.createObjectStore("downloadQueue", {
2952
+ keyPath: "sha256"
2953
+ });
2954
+ }
2955
+ }
2956
+ });
2971
2957
  var IDBStore = class {
2972
2958
  seed;
2973
2959
  hostURL;
2974
2960
  hostID;
2975
2961
  lastFetchedAt;
2976
2962
  async wipe() {
2977
- await deleteDB("client-store-db");
2978
- db = await initDB();
2963
+ await db.clear("metaKV");
2964
+ await db.clear("uploadQueue");
2965
+ await db.clear("downloadQueue");
2966
+ await db.clear("ops");
2979
2967
  }
2980
2968
  async getSeed() {
2981
2969
  const hex = await db.get("metaKV", "seed");
@@ -11439,6 +11427,7 @@ var DiplomaticClient = class {
11439
11427
  await this.store.setSeed(bytes);
11440
11428
  }
11441
11429
  await this.loadSeed();
11430
+ this.emitUpdate();
11442
11431
  if (params.hostID && params.hostURL) {
11443
11432
  await this.store.setHostID(params.hostID);
11444
11433
  await this.store.setHostURL(params.hostURL);
@@ -11447,11 +11436,12 @@ var DiplomaticClient = class {
11447
11436
  } else {
11448
11437
  await this.loadHost();
11449
11438
  }
11439
+ this.emitUpdate();
11450
11440
  if (this.hostURL) {
11451
11441
  await this.connect(this.hostURL);
11442
+ this.emitUpdate();
11452
11443
  }
11453
11444
  await this.sync();
11454
- this.emitUpdate();
11455
11445
  this.emitXferUpdate();
11456
11446
  }
11457
11447
  async loadSeed() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@interncom/diplomatic",
3
- "version": "0.0.56",
3
+ "version": "0.0.58",
4
4
  "type": "module",
5
5
  "description": "Secure sync layer",
6
6
  "main": "dist/index.mjs",