@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.
- package/dist/{contentSource-CudEz5Tm.d.ts → contentSource-BDRX_YYJ.d.ts} +13 -1
- package/dist/{contentSource-CBqZCoGU.d.cts → contentSource-D-LQYFyx.d.cts} +13 -1
- package/dist/core/index.d.cts +3 -3
- package/dist/core/index.d.ts +3 -3
- package/dist/core/index.js +26 -5
- package/dist/core/index.js.map +1 -1
- package/dist/core/index.mjs +26 -5
- package/dist/core/index.mjs.map +1 -1
- package/dist/{dataLayerProvider-BBA8tJNx.d.cts → dataLayerProvider-Dd2UcCif.d.cts} +1 -1
- package/dist/{dataLayerProvider-C9WgkBzR.d.ts → dataLayerProvider-Dpshuql4.d.ts} +1 -1
- package/dist/impl/couch/index.d.cts +2 -2
- package/dist/impl/couch/index.d.ts +2 -2
- package/dist/impl/couch/index.js +26 -5
- package/dist/impl/couch/index.js.map +1 -1
- package/dist/impl/couch/index.mjs +26 -5
- package/dist/impl/couch/index.mjs.map +1 -1
- package/dist/impl/static/index.d.cts +2 -2
- package/dist/impl/static/index.d.ts +2 -2
- package/dist/impl/static/index.js +26 -5
- package/dist/impl/static/index.js.map +1 -1
- package/dist/impl/static/index.mjs +26 -5
- package/dist/impl/static/index.mjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +26 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +26 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/core/interfaces/userDB.ts +14 -1
- package/src/impl/common/BaseUserDB.ts +36 -5
- package/tests/impl/hydration.test.ts +49 -0
|
@@ -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-
|
|
2
|
-
import { D as DataLayerProvider } from '../../dataLayerProvider-
|
|
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-
|
|
2
|
-
import { D as DataLayerProvider } from '../../dataLayerProvider-
|
|
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
|
|
5630
|
+
* How far the local mirror can be trusted, RIGHT NOW. See
|
|
5631
|
+
* {@link UserHydrationStatus}.
|
|
5629
5632
|
*
|
|
5630
|
-
*
|
|
5631
|
-
*
|
|
5632
|
-
*
|
|
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
|
-
|
|
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}`);
|