@vue-skuilder/standalone-ui 0.2.18 → 0.2.20

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.
@@ -29632,18 +29632,23 @@ ${t.stack}` : JSON.stringify(t);
29632
29632
  return t === GuestUsername || t.startsWith(GuestUsername) ? getLocalUserDB(t) : this.getUserDB(t);
29633
29633
  }
29634
29634
  async hydrate(t, c) {
29635
- let u = pouchdb_setup_default.replicate(c, t, {});
29636
- this.hydrationHandle = u;
29635
+ let u = (await t.info()).doc_count === 0, d = pouchdb_setup_default.replicate(c, t, u ? { selector: { _deleted: { $exists: !1 } } } : {});
29636
+ this.hydrationHandle = d;
29637
29637
  try {
29638
- return { docsWritten: (await u).docs_written };
29638
+ let t = await d;
29639
+ return {
29640
+ docsWritten: t.docs_written,
29641
+ lastSeq: u ? t.last_seq : void 0
29642
+ };
29639
29643
  } finally {
29640
29644
  this.hydrationHandle = void 0;
29641
29645
  }
29642
29646
  }
29643
- startSync(t, c) {
29647
+ startSync(t, c, u) {
29644
29648
  t.name !== c.name && (this.syncHandle = pouchdb_setup_default.sync(t, c, {
29645
29649
  live: !0,
29646
- retry: !0
29650
+ retry: !0,
29651
+ ...u === void 0 ? {} : { pull: { since: u } }
29647
29652
  }));
29648
29653
  }
29649
29654
  stopSync() {
@@ -29808,6 +29813,12 @@ ${t.stack}` : JSON.stringify(t);
29808
29813
  hydrationStatus() {
29809
29814
  return { ...this._hydration };
29810
29815
  }
29816
+ async awaitHydration() {
29817
+ try {
29818
+ await this._hydrationPromise;
29819
+ } catch {}
29820
+ return this.hydrationStatus();
29821
+ }
29811
29822
  canMaterializeDefaults() {
29812
29823
  return this._hydration.state !== "failed" && this._hydration.state !== "hydrating";
29813
29824
  }
@@ -30066,7 +30077,7 @@ Currently logged-in as ${this._username}.`);
30066
30077
  }) : (_BaseUser._instance = new _BaseUser(await t.getCurrentUsername(), t), await _BaseUser._instance.init(), _BaseUser._instance);
30067
30078
  }
30068
30079
  constructor(t, c) {
30069
- _defineProperty$2(this, "_username", void 0), _defineProperty$2(this, "syncStrategy", void 0), _defineProperty$2(this, "localDB", void 0), _defineProperty$2(this, "remoteDB", void 0), _defineProperty$2(this, "writeDB", void 0), _defineProperty$2(this, "updateQueue", void 0), _defineProperty$2(this, "_hydration", { state: "not-required" }), _BaseUser._initialized = !1, this._username = t, this.syncStrategy = c, this.setDBandQ();
30080
+ _defineProperty$2(this, "_username", void 0), _defineProperty$2(this, "syncStrategy", void 0), _defineProperty$2(this, "localDB", void 0), _defineProperty$2(this, "remoteDB", void 0), _defineProperty$2(this, "writeDB", void 0), _defineProperty$2(this, "updateQueue", void 0), _defineProperty$2(this, "_hydration", { state: "not-required" }), _defineProperty$2(this, "_hydrationPromise", null), _defineProperty$2(this, "_hydratedSeq", void 0), _BaseUser._initialized = !1, this._username = t, this.syncStrategy = c, this.setDBandQ();
30070
30081
  }
30071
30082
  setDBandQ() {
30072
30083
  this.localDB = getLocalUserDB(this._username), this.remoteDB = this.syncStrategy.setupRemoteDB(this._username), this.writeDB = this.syncStrategy.getWriteDB ? this.syncStrategy.getWriteDB(this._username) : this.localDB, this.updateQueue = new UpdateQueue(this.localDB, this.writeDB);
@@ -30076,14 +30087,14 @@ Currently logged-in as ${this._username}.`);
30076
30087
  _BaseUser._initialized = !0;
30077
30088
  return;
30078
30089
  }
30079
- this.syncStrategy.stopSync?.(), this.setDBandQ(), await this.hydrateLocalMirror(), this.syncStrategy.startSync(this.localDB, this.remoteDB), this.applyDesignDocs().catch((t) => {
30090
+ this.syncStrategy.stopSync?.(), this.setDBandQ(), this._hydrationPromise = this.hydrateLocalMirror(), await this._hydrationPromise, this.syncStrategy.startSync(this.localDB, this.remoteDB, this._hydratedSeq), this.applyDesignDocs().catch((t) => {
30080
30091
  log4(`Error in applyDesignDocs background task: ${t}`), t && typeof t == "object" && log4(`Full error details in applyDesignDocs: ${JSON.stringify(t)}`);
30081
30092
  }), this.deduplicateReviews().catch((t) => {
30082
30093
  log4(`Error in deduplicateReviews background task: ${t}`), t && typeof t == "object" && log4(`Full error details in background task: ${JSON.stringify(t)}`);
30083
30094
  }), _BaseUser._initialized = !0;
30084
30095
  }
30085
30096
  async hydrateLocalMirror() {
30086
- if (this.localDB.name === this.remoteDB.name || !this.syncStrategy.hydrate) {
30097
+ if (this._hydratedSeq = void 0, this.localDB.name === this.remoteDB.name || !this.syncStrategy.hydrate) {
30087
30098
  this._hydration = { state: "not-required" };
30088
30099
  return;
30089
30100
  }
@@ -30094,8 +30105,8 @@ Currently logged-in as ${this._username}.`);
30094
30105
  this._hydration = { state: "hydrating" };
30095
30106
  let t = Date.now();
30096
30107
  try {
30097
- let { docsWritten: c } = await withTimeout(this.syncStrategy.hydrate(this.localDB, this.remoteDB), HYDRATION_TIMEOUT_MS, `Hydration of local mirror for ${this._username}`);
30098
- await this.writeHydrationMarker(), this._hydration = {
30108
+ let { docsWritten: c, lastSeq: u } = await withTimeout(this.syncStrategy.hydrate(this.localDB, this.remoteDB), HYDRATION_TIMEOUT_MS, `Hydration of local mirror for ${this._username}`);
30109
+ this._hydratedSeq = u, await this.writeHydrationMarker(), this._hydration = {
30099
30110
  state: "hydrated",
30100
30111
  docsWritten: c,
30101
30112
  durationMs: Date.now() - t