@palbase/web 1.8.0 → 1.9.0
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/{analytics-facade-DfJ420F5.d.cts → analytics-facade-DFd5LB3_.d.cts} +17 -4
- package/dist/{analytics-facade-CgURkjpP.d.ts → analytics-facade-DsvKx5A5.d.ts} +17 -4
- package/dist/{chunk-AWVNDAMG.js → chunk-I3ZMB7XM.js} +33 -6
- package/dist/chunk-I3ZMB7XM.js.map +1 -0
- package/dist/index.cjs +31 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -1
- package/dist/internal.cjs +32 -5
- package/dist/internal.cjs.map +1 -1
- package/dist/internal.d.cts +3 -3
- package/dist/internal.d.ts +3 -3
- package/dist/internal.js +1 -1
- package/dist/next/client.cjs +32 -5
- package/dist/next/client.cjs.map +1 -1
- package/dist/next/client.js +1 -1
- package/dist/next/index.cjs +32 -5
- package/dist/next/index.cjs.map +1 -1
- package/dist/next/index.d.cts +2 -2
- package/dist/next/index.d.ts +2 -2
- package/dist/next/index.js +1 -1
- package/dist/{pb-C1v9ErPy.d.ts → pb-CDVMy1l1.d.ts} +1 -1
- package/dist/{pb-BwQwp411.d.cts → pb-D_fuhafL.d.cts} +1 -1
- package/dist/react/index.cjs +1 -1
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +1 -1
- package/dist/react/index.d.ts +1 -1
- package/dist/react/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-AWVNDAMG.js.map +0 -1
package/dist/next/client.js
CHANGED
package/dist/next/index.cjs
CHANGED
|
@@ -1527,6 +1527,8 @@ var PalbeAuth = class {
|
|
|
1527
1527
|
// suppresses AuthClient's TOKEN_REFRESHED during re-signIn
|
|
1528
1528
|
signedInState = false;
|
|
1529
1529
|
// dedupes AuthClient's repeated SIGNED_OUT events
|
|
1530
|
+
hydratingUser = false;
|
|
1531
|
+
// guards hydrateUser() to a single boot fetch
|
|
1530
1532
|
stateListeners = /* @__PURE__ */ new Set();
|
|
1531
1533
|
eventListeners = /* @__PURE__ */ new Set();
|
|
1532
1534
|
userListeners = /* @__PURE__ */ new Set();
|
|
@@ -1579,13 +1581,37 @@ var PalbeAuth = class {
|
|
|
1579
1581
|
if (changed) for (const cb of this.userListeners) this.safeInvoke(() => cb(user));
|
|
1580
1582
|
return user;
|
|
1581
1583
|
}
|
|
1584
|
+
/**
|
|
1585
|
+
* Restore the user after a session was rehydrated from storage (page reload).
|
|
1586
|
+
* Hydration in buildRuntime restores the TOKENS synchronously, but the access
|
|
1587
|
+
* token JWT does not carry emailVerified/createdAt, so the full AuthUser can't
|
|
1588
|
+
* be reconstructed offline — this fetches GET /auth/user once and announces
|
|
1589
|
+
* `signedIn`, so the app no longer has to `await pb.auth.refreshUser()` itself
|
|
1590
|
+
* on boot. Idempotent (runs once), browser-safe (no-op when not signed in or
|
|
1591
|
+
* a user is already cached), and never throws (a boot-time network failure
|
|
1592
|
+
* must not break app startup — isSignedIn stays true, the app can retry).
|
|
1593
|
+
*/
|
|
1594
|
+
hydrateUser() {
|
|
1595
|
+
if (this.hydratingUser || this.cachedUser || !this.isSignedIn) return;
|
|
1596
|
+
this.hydratingUser = true;
|
|
1597
|
+
void this.refreshUser().then((user) => {
|
|
1598
|
+
if (this.isSignedIn) {
|
|
1599
|
+
this.signedInState = true;
|
|
1600
|
+
this.emitState({ status: "signedIn", user });
|
|
1601
|
+
}
|
|
1602
|
+
}).catch(() => {
|
|
1603
|
+
}).finally(() => {
|
|
1604
|
+
this.hydratingUser = false;
|
|
1605
|
+
});
|
|
1606
|
+
}
|
|
1582
1607
|
// ── listeners ──────────────────────────────────────────
|
|
1583
1608
|
/**
|
|
1584
1609
|
* Subscribe to signed-in/signed-out state. Fires immediately with the
|
|
1585
|
-
* current snapshot (iOS parity).
|
|
1586
|
-
*
|
|
1587
|
-
*
|
|
1588
|
-
*
|
|
1610
|
+
* current snapshot (iOS parity). A restored session (page reload) hydrates
|
|
1611
|
+
* the user asynchronously via `hydrateUser()` (fired once at boot), so the
|
|
1612
|
+
* FIRST snapshot may report signedOut for a tick even when `isSignedIn` is
|
|
1613
|
+
* true; the listener then fires again with `signedIn` once the user lands.
|
|
1614
|
+
* Rely on `isSignedIn` for the session truth if you need it synchronously.
|
|
1589
1615
|
*/
|
|
1590
1616
|
onAuthStateChange(callback) {
|
|
1591
1617
|
this.stateListeners.add(callback);
|
|
@@ -8939,7 +8965,7 @@ function defaultSessionStorage(key) {
|
|
|
8939
8965
|
}
|
|
8940
8966
|
|
|
8941
8967
|
// src/version.ts
|
|
8942
|
-
var VERSION = "1.
|
|
8968
|
+
var VERSION = "1.9.0";
|
|
8943
8969
|
|
|
8944
8970
|
// src/runtime.ts
|
|
8945
8971
|
function buildRuntime(config) {
|
|
@@ -9057,6 +9083,7 @@ function buildRuntime(config) {
|
|
|
9057
9083
|
void rt.perf;
|
|
9058
9084
|
if (typeof document !== "undefined") {
|
|
9059
9085
|
void new PerfConfigClient().fetchConfig(rt, rt.perf);
|
|
9086
|
+
rt.auth.hydrateUser();
|
|
9060
9087
|
}
|
|
9061
9088
|
recordColdStart(rt);
|
|
9062
9089
|
observeWebVitals((item) => rt.perf.record(item));
|