@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.
@@ -1,5 +1,5 @@
1
- import { U as UserDBInterface, C as CourseDBInterface, b as CoursesDBInterface, c as ClassroomDBInterface, A as AdminDBInterface, a as UserDBReader, d as CourseInfo, S as StudySessionItem, D as DataLayerResult, e as ContentNavigationStrategyData, f as ContentNavigator, R as ReplanHints, G as GeneratorResult } from '../../contentSource-CBqZCoGU.cjs';
2
- import { D as DataLayerProvider } from '../../dataLayerProvider-BBA8tJNx.cjs';
1
+ import { U as UserDBInterface, C as CourseDBInterface, b as CoursesDBInterface, c as ClassroomDBInterface, A as AdminDBInterface, a as UserDBReader, d as CourseInfo, S as StudySessionItem, D as DataLayerResult, e as ContentNavigationStrategyData, f as ContentNavigator, R as ReplanHints, G as GeneratorResult } from '../../contentSource-D-LQYFyx.cjs';
2
+ import { D as DataLayerProvider } from '../../dataLayerProvider-Dd2UcCif.cjs';
3
3
  import { S as StaticCourseManifest } from '../../types-BFUa1pa3.cjs';
4
4
  import { CourseConfig, CourseElo, DataShape } from '@vue-skuilder/common';
5
5
  import { S as SkuilderCourseData, Q as QualifiedCardID, T as TagStub, a as Tag } from '../../types-legacy-4tlwHnXo.cjs';
@@ -1,5 +1,5 @@
1
- import { U as UserDBInterface, C as CourseDBInterface, b as CoursesDBInterface, c as ClassroomDBInterface, A as AdminDBInterface, a as UserDBReader, d as CourseInfo, S as StudySessionItem, D as DataLayerResult, e as ContentNavigationStrategyData, f as ContentNavigator, R as ReplanHints, G as GeneratorResult } from '../../contentSource-CudEz5Tm.js';
2
- import { D as DataLayerProvider } from '../../dataLayerProvider-C9WgkBzR.js';
1
+ import { U as UserDBInterface, C as CourseDBInterface, b as CoursesDBInterface, c as ClassroomDBInterface, A as AdminDBInterface, a as UserDBReader, d as CourseInfo, S as StudySessionItem, D as DataLayerResult, e as ContentNavigationStrategyData, f as ContentNavigator, R as ReplanHints, G as GeneratorResult } from '../../contentSource-BDRX_YYJ.js';
2
+ import { D as DataLayerProvider } from '../../dataLayerProvider-Dpshuql4.js';
3
3
  import { S as StaticCourseManifest } from '../../types-CHgpWQAY.js';
4
4
  import { CourseConfig, CourseElo, DataShape } from '@vue-skuilder/common';
5
5
  import { S as SkuilderCourseData, Q as QualifiedCardID, T as TagStub, a as Tag } from '../../types-legacy-4tlwHnXo.js';
@@ -5624,16 +5624,36 @@ var init_BaseUserDB = __esm({
5624
5624
  // Database to use for write operations (local-first approach)
5625
5625
  updateQueue;
5626
5626
  _hydration = { state: "not-required" };
5627
+ /** In-flight hydration, so concurrent callers can wait for a real answer. */
5628
+ _hydrationPromise = null;
5627
5629
  /**
5628
- * How far the local mirror can be trusted. See {@link UserHydrationStatus}.
5630
+ * How far the local mirror can be trusted, RIGHT NOW. See
5631
+ * {@link UserHydrationStatus}.
5629
5632
  *
5630
- * Consumers that would otherwise read a 404 as "new user" — onboarding
5631
- * gates, first-run experiences, progress dashboards should check for
5632
- * `failed` and present a retry affordance rather than an empty state.
5633
+ * This is a snapshot, and during login it can legitimately read
5634
+ * `hydrating` prefer awaitHydration() anywhere a decision hangs on the
5635
+ * answer.
5633
5636
  */
5634
5637
  hydrationStatus() {
5635
5638
  return { ...this._hydration };
5636
5639
  }
5640
+ /**
5641
+ * The hydration status once it has settled — never `hydrating`.
5642
+ *
5643
+ * Resolves immediately unless a pull is in flight. Exists for callers that
5644
+ * must decide something (a route guard, a first-run branch) and would
5645
+ * otherwise sample `hydrating` and guess. Since init() is awaited by both
5646
+ * app startup and login(), that only happens when something navigates
5647
+ * concurrently with a login still in progress — a window that stretches to
5648
+ * HYDRATION_TIMEOUT_MS on a slow connection.
5649
+ */
5650
+ async awaitHydration() {
5651
+ try {
5652
+ await this._hydrationPromise;
5653
+ } catch {
5654
+ }
5655
+ return this.hydrationStatus();
5656
+ }
5637
5657
  /**
5638
5658
  * Whether a missing document may be treated as genuinely absent, allowing
5639
5659
  * callers to create it with defaults.
@@ -6090,7 +6110,8 @@ Currently logged-in as ${this._username}.`
6090
6110
  }
6091
6111
  this.syncStrategy.stopSync?.();
6092
6112
  this.setDBandQ();
6093
- await this.hydrateLocalMirror();
6113
+ this._hydrationPromise = this.hydrateLocalMirror();
6114
+ await this._hydrationPromise;
6094
6115
  this.syncStrategy.startSync(this.localDB, this.remoteDB);
6095
6116
  this.applyDesignDocs().catch((error) => {
6096
6117
  log3(`Error in applyDesignDocs background task: ${error}`);