@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/index.mjs
CHANGED
|
@@ -7896,16 +7896,36 @@ var init_BaseUserDB = __esm({
|
|
|
7896
7896
|
// Database to use for write operations (local-first approach)
|
|
7897
7897
|
updateQueue;
|
|
7898
7898
|
_hydration = { state: "not-required" };
|
|
7899
|
+
/** In-flight hydration, so concurrent callers can wait for a real answer. */
|
|
7900
|
+
_hydrationPromise = null;
|
|
7899
7901
|
/**
|
|
7900
|
-
* How far the local mirror can be trusted. See
|
|
7902
|
+
* How far the local mirror can be trusted, RIGHT NOW. See
|
|
7903
|
+
* {@link UserHydrationStatus}.
|
|
7901
7904
|
*
|
|
7902
|
-
*
|
|
7903
|
-
*
|
|
7904
|
-
*
|
|
7905
|
+
* This is a snapshot, and during login it can legitimately read
|
|
7906
|
+
* `hydrating` — prefer awaitHydration() anywhere a decision hangs on the
|
|
7907
|
+
* answer.
|
|
7905
7908
|
*/
|
|
7906
7909
|
hydrationStatus() {
|
|
7907
7910
|
return { ...this._hydration };
|
|
7908
7911
|
}
|
|
7912
|
+
/**
|
|
7913
|
+
* The hydration status once it has settled — never `hydrating`.
|
|
7914
|
+
*
|
|
7915
|
+
* Resolves immediately unless a pull is in flight. Exists for callers that
|
|
7916
|
+
* must decide something (a route guard, a first-run branch) and would
|
|
7917
|
+
* otherwise sample `hydrating` and guess. Since init() is awaited by both
|
|
7918
|
+
* app startup and login(), that only happens when something navigates
|
|
7919
|
+
* concurrently with a login still in progress — a window that stretches to
|
|
7920
|
+
* HYDRATION_TIMEOUT_MS on a slow connection.
|
|
7921
|
+
*/
|
|
7922
|
+
async awaitHydration() {
|
|
7923
|
+
try {
|
|
7924
|
+
await this._hydrationPromise;
|
|
7925
|
+
} catch {
|
|
7926
|
+
}
|
|
7927
|
+
return this.hydrationStatus();
|
|
7928
|
+
}
|
|
7909
7929
|
/**
|
|
7910
7930
|
* Whether a missing document may be treated as genuinely absent, allowing
|
|
7911
7931
|
* callers to create it with defaults.
|
|
@@ -8362,7 +8382,8 @@ Currently logged-in as ${this._username}.`
|
|
|
8362
8382
|
}
|
|
8363
8383
|
this.syncStrategy.stopSync?.();
|
|
8364
8384
|
this.setDBandQ();
|
|
8365
|
-
|
|
8385
|
+
this._hydrationPromise = this.hydrateLocalMirror();
|
|
8386
|
+
await this._hydrationPromise;
|
|
8366
8387
|
this.syncStrategy.startSync(this.localDB, this.remoteDB);
|
|
8367
8388
|
this.applyDesignDocs().catch((error) => {
|
|
8368
8389
|
log4(`Error in applyDesignDocs background task: ${error}`);
|