@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
|
@@ -7541,16 +7541,36 @@ var init_BaseUserDB = __esm({
|
|
|
7541
7541
|
// Database to use for write operations (local-first approach)
|
|
7542
7542
|
updateQueue;
|
|
7543
7543
|
_hydration = { state: "not-required" };
|
|
7544
|
+
/** In-flight hydration, so concurrent callers can wait for a real answer. */
|
|
7545
|
+
_hydrationPromise = null;
|
|
7544
7546
|
/**
|
|
7545
|
-
* How far the local mirror can be trusted. See
|
|
7547
|
+
* How far the local mirror can be trusted, RIGHT NOW. See
|
|
7548
|
+
* {@link UserHydrationStatus}.
|
|
7546
7549
|
*
|
|
7547
|
-
*
|
|
7548
|
-
*
|
|
7549
|
-
*
|
|
7550
|
+
* This is a snapshot, and during login it can legitimately read
|
|
7551
|
+
* `hydrating` — prefer awaitHydration() anywhere a decision hangs on the
|
|
7552
|
+
* answer.
|
|
7550
7553
|
*/
|
|
7551
7554
|
hydrationStatus() {
|
|
7552
7555
|
return { ...this._hydration };
|
|
7553
7556
|
}
|
|
7557
|
+
/**
|
|
7558
|
+
* The hydration status once it has settled — never `hydrating`.
|
|
7559
|
+
*
|
|
7560
|
+
* Resolves immediately unless a pull is in flight. Exists for callers that
|
|
7561
|
+
* must decide something (a route guard, a first-run branch) and would
|
|
7562
|
+
* otherwise sample `hydrating` and guess. Since init() is awaited by both
|
|
7563
|
+
* app startup and login(), that only happens when something navigates
|
|
7564
|
+
* concurrently with a login still in progress — a window that stretches to
|
|
7565
|
+
* HYDRATION_TIMEOUT_MS on a slow connection.
|
|
7566
|
+
*/
|
|
7567
|
+
async awaitHydration() {
|
|
7568
|
+
try {
|
|
7569
|
+
await this._hydrationPromise;
|
|
7570
|
+
} catch {
|
|
7571
|
+
}
|
|
7572
|
+
return this.hydrationStatus();
|
|
7573
|
+
}
|
|
7554
7574
|
/**
|
|
7555
7575
|
* Whether a missing document may be treated as genuinely absent, allowing
|
|
7556
7576
|
* callers to create it with defaults.
|
|
@@ -8007,7 +8027,8 @@ Currently logged-in as ${this._username}.`
|
|
|
8007
8027
|
}
|
|
8008
8028
|
this.syncStrategy.stopSync?.();
|
|
8009
8029
|
this.setDBandQ();
|
|
8010
|
-
|
|
8030
|
+
this._hydrationPromise = this.hydrateLocalMirror();
|
|
8031
|
+
await this._hydrationPromise;
|
|
8011
8032
|
this.syncStrategy.startSync(this.localDB, this.remoteDB);
|
|
8012
8033
|
this.applyDesignDocs().catch((error) => {
|
|
8013
8034
|
log3(`Error in applyDesignDocs background task: ${error}`);
|