@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
|
@@ -5601,16 +5601,36 @@ var init_BaseUserDB = __esm({
|
|
|
5601
5601
|
// Database to use for write operations (local-first approach)
|
|
5602
5602
|
updateQueue;
|
|
5603
5603
|
_hydration = { state: "not-required" };
|
|
5604
|
+
/** In-flight hydration, so concurrent callers can wait for a real answer. */
|
|
5605
|
+
_hydrationPromise = null;
|
|
5604
5606
|
/**
|
|
5605
|
-
* How far the local mirror can be trusted. See
|
|
5607
|
+
* How far the local mirror can be trusted, RIGHT NOW. See
|
|
5608
|
+
* {@link UserHydrationStatus}.
|
|
5606
5609
|
*
|
|
5607
|
-
*
|
|
5608
|
-
*
|
|
5609
|
-
*
|
|
5610
|
+
* This is a snapshot, and during login it can legitimately read
|
|
5611
|
+
* `hydrating` — prefer awaitHydration() anywhere a decision hangs on the
|
|
5612
|
+
* answer.
|
|
5610
5613
|
*/
|
|
5611
5614
|
hydrationStatus() {
|
|
5612
5615
|
return { ...this._hydration };
|
|
5613
5616
|
}
|
|
5617
|
+
/**
|
|
5618
|
+
* The hydration status once it has settled — never `hydrating`.
|
|
5619
|
+
*
|
|
5620
|
+
* Resolves immediately unless a pull is in flight. Exists for callers that
|
|
5621
|
+
* must decide something (a route guard, a first-run branch) and would
|
|
5622
|
+
* otherwise sample `hydrating` and guess. Since init() is awaited by both
|
|
5623
|
+
* app startup and login(), that only happens when something navigates
|
|
5624
|
+
* concurrently with a login still in progress — a window that stretches to
|
|
5625
|
+
* HYDRATION_TIMEOUT_MS on a slow connection.
|
|
5626
|
+
*/
|
|
5627
|
+
async awaitHydration() {
|
|
5628
|
+
try {
|
|
5629
|
+
await this._hydrationPromise;
|
|
5630
|
+
} catch {
|
|
5631
|
+
}
|
|
5632
|
+
return this.hydrationStatus();
|
|
5633
|
+
}
|
|
5614
5634
|
/**
|
|
5615
5635
|
* Whether a missing document may be treated as genuinely absent, allowing
|
|
5616
5636
|
* callers to create it with defaults.
|
|
@@ -6067,7 +6087,8 @@ Currently logged-in as ${this._username}.`
|
|
|
6067
6087
|
}
|
|
6068
6088
|
this.syncStrategy.stopSync?.();
|
|
6069
6089
|
this.setDBandQ();
|
|
6070
|
-
|
|
6090
|
+
this._hydrationPromise = this.hydrateLocalMirror();
|
|
6091
|
+
await this._hydrationPromise;
|
|
6071
6092
|
this.syncStrategy.startSync(this.localDB, this.remoteDB);
|
|
6072
6093
|
this.applyDesignDocs().catch((error) => {
|
|
6073
6094
|
log3(`Error in applyDesignDocs background task: ${error}`);
|