@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
package/dist/core/index.mjs
CHANGED
|
@@ -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
|
|
6905
|
+
* How far the local mirror can be trusted, RIGHT NOW. See
|
|
6906
|
+
* {@link UserHydrationStatus}.
|
|
6904
6907
|
*
|
|
6905
|
-
*
|
|
6906
|
-
*
|
|
6907
|
-
*
|
|
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
|
-
|
|
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}`);
|