@vue-skuilder/db 0.2.18 → 0.2.19

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.
@@ -6899,16 +6899,36 @@ var init_BaseUserDB = __esm({
6899
6899
  // Database to use for write operations (local-first approach)
6900
6900
  updateQueue;
6901
6901
  _hydration = { state: "not-required" };
6902
+ /** In-flight hydration, so concurrent callers can wait for a real answer. */
6903
+ _hydrationPromise = null;
6902
6904
  /**
6903
- * How far the local mirror can be trusted. See {@link UserHydrationStatus}.
6905
+ * How far the local mirror can be trusted, RIGHT NOW. See
6906
+ * {@link UserHydrationStatus}.
6904
6907
  *
6905
- * Consumers that would otherwise read a 404 as "new user" — onboarding
6906
- * gates, first-run experiences, progress dashboards should check for
6907
- * `failed` and present a retry affordance rather than an empty state.
6908
+ * This is a snapshot, and during login it can legitimately read
6909
+ * `hydrating` prefer awaitHydration() anywhere a decision hangs on the
6910
+ * answer.
6908
6911
  */
6909
6912
  hydrationStatus() {
6910
6913
  return { ...this._hydration };
6911
6914
  }
6915
+ /**
6916
+ * The hydration status once it has settled — never `hydrating`.
6917
+ *
6918
+ * Resolves immediately unless a pull is in flight. Exists for callers that
6919
+ * must decide something (a route guard, a first-run branch) and would
6920
+ * otherwise sample `hydrating` and guess. Since init() is awaited by both
6921
+ * app startup and login(), that only happens when something navigates
6922
+ * concurrently with a login still in progress — a window that stretches to
6923
+ * HYDRATION_TIMEOUT_MS on a slow connection.
6924
+ */
6925
+ async awaitHydration() {
6926
+ try {
6927
+ await this._hydrationPromise;
6928
+ } catch {
6929
+ }
6930
+ return this.hydrationStatus();
6931
+ }
6912
6932
  /**
6913
6933
  * Whether a missing document may be treated as genuinely absent, allowing
6914
6934
  * callers to create it with defaults.
@@ -7365,7 +7385,8 @@ Currently logged-in as ${this._username}.`
7365
7385
  }
7366
7386
  this.syncStrategy.stopSync?.();
7367
7387
  this.setDBandQ();
7368
- await this.hydrateLocalMirror();
7388
+ this._hydrationPromise = this.hydrateLocalMirror();
7389
+ await this._hydrationPromise;
7369
7390
  this.syncStrategy.startSync(this.localDB, this.remoteDB);
7370
7391
  this.applyDesignDocs().catch((error) => {
7371
7392
  log3(`Error in applyDesignDocs background task: ${error}`);