@brendanbank/atrium-host-bundle-utils 0.17.0 → 0.19.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/README.md CHANGED
@@ -87,9 +87,9 @@ function App() {
87
87
  }
88
88
  ```
89
89
 
90
- The hooks fetch atrium's fixed same-origin `/users/me/context`
91
- endpoint — no path is configurable, since a host bundle loads inside
92
- atrium's SPA and hits the same origin. `<AtriumProvider>` reads from
90
+ The hooks fetch atrium's fixed same-origin `/api/users/me/context`
91
+ endpoint (atrium >= 0.19) — no path is configurable, since a host
92
+ bundle loads inside atrium's SPA and hits the same origin. `<AtriumProvider>` reads from
93
93
  your existing `<QueryClientProvider>` by default — no second
94
94
  QueryClient. Pass `client={hostQueryClient}` to wrap one inline; pass
95
95
  `fetchUserContext={...}` to inject a custom fetcher (useful for tests
@@ -97,8 +97,8 @@ or hosts that want axios-shaped retry).
97
97
 
98
98
  ## Versioning
99
99
 
100
- The package version tracks atrium's image version. Pin `^0.17` for
101
- "compatible with atrium 0.17.x"; bump together with the atrium image
100
+ The package version tracks atrium's image version. Pin `^0.19` for
101
+ "compatible with atrium 0.19.x"; bump together with the atrium image
102
102
  to pick up new registry slots and SDK helpers.
103
103
 
104
104
  ## See also
@@ -2,27 +2,29 @@
2
2
  * React hooks + provider for atrium host bundles.
3
3
  *
4
4
  * One TanStack Query subscription serves the whole host tree:
5
- * `useMe()` fetches `/users/me/context` once and shares the result
6
- * with every `usePerm()`, `useRole()`, and `useUserContext()` caller.
7
- *
8
- * The endpoint path is fixed by atrium — it's mounted at the SPA root
9
- * by `app.include_router(me_context_router)` and served from the same
10
- * origin as the bundle. There's no `apiBase` prop because there's
11
- * nothing for the host to configure: a host bundle that loads inside
12
- * atrium's SPA fetches a same-origin relative path. Hosts that want
13
- * to layer their own retry / headers / mock can pass `fetchUserContext`.
14
- *
15
- * The hooks reuse the host's enclosing `<QueryClientProvider>` if one
16
- * is already mounted; pass `client={hostQueryClient}` to
5
+ * `useMe()` fetches `/api/users/me/context` once and shares the
6
+ * result with every `usePerm()`, `useRole()`, and `useUserContext()`
7
+ * caller.
8
+ *
9
+ * The endpoint path is fixed by atrium — it's mounted under
10
+ * `/api/...` (atrium >= 0.19) and served from the same origin as the
11
+ * bundle. There's no `apiBase` prop because there's nothing for the
12
+ * host to configure: a host bundle that loads inside atrium's SPA
13
+ * fetches a same-origin relative path. Hosts that want to layer
14
+ * their own retry / headers / mock can pass `fetchUserContext`.
15
+ *
16
+ * The hooks reuse the host's enclosing `<QueryClientProvider>` if
17
+ * one is already mounted; pass `client={hostQueryClient}` to
17
18
  * `<AtriumProvider>` only if you want this provider to wrap the
18
19
  * QueryClient too. Two QueryClients (atrium's + the host's) is the
19
- * intended state — atrium clears its cache on logout via `qc.clear()`,
20
- * and a shared client would lose host queries the user still wants.
20
+ * intended state — atrium clears its cache on logout via
21
+ * `qc.clear()`, and a shared client would lose host queries the user
22
+ * still wants.
21
23
  */
22
24
  import { type ReactNode } from 'react';
23
25
  import { type QueryClient, type UseQueryResult } from '@tanstack/react-query';
24
- import type { UserContext } from '@brendanbank/atrium-host-types';
25
- export type { UserContext } from '@brendanbank/atrium-host-types';
26
+ import type { AtriumUserChangeDetail, UserContext } from '@brendanbank/atrium-host-types';
27
+ export type { AtriumUserChangeDetail, UserContext, } from '@brendanbank/atrium-host-types';
26
28
  export { __atrium_t__ } from '../i18n';
27
29
  interface AtriumContextValue {
28
30
  fetchUserContext: () => Promise<UserContext | null>;
@@ -33,10 +35,10 @@ export interface AtriumProviderProps {
33
35
  * inherit the caller's enclosing one. Use this only when the host
34
36
  * hasn't already set up its own provider. */
35
37
  client?: QueryClient;
36
- /** Override the fetcher for `/users/me/context`. Useful for tests
37
- * and for hosts that want to layer an axios interceptor or extra
38
- * headers on top. The default uses `fetch` with `credentials:
39
- * 'include'`. */
38
+ /** Override the fetcher for `/api/users/me/context`. Useful for
39
+ * tests and for hosts that want to layer an axios interceptor or
40
+ * extra headers on top. The default uses `fetch` with
41
+ * `credentials: 'include'`. */
40
42
  fetchUserContext?: () => Promise<UserContext | null>;
41
43
  children: ReactNode;
42
44
  }
@@ -198,4 +200,47 @@ export declare function useAtriumNavigate(): (href: string, opts?: {
198
200
  * `window.location` fresh. Production code never calls this — the
199
201
  * cache is updated by the event subscription. */
200
202
  export declare function __resetAtriumLocationCacheForTests(): void;
203
+ /** Subscribe to atrium's identity transitions from inside a host
204
+ * bundle's React tree. Returns the most recent `atrium:userchange`
205
+ * detail — `{previous, current, nonce}` — or a zeroed sentinel
206
+ * (`{previous: null, current: null, nonce: 0}`) before any event has
207
+ * fired. The hook does NOT report the initial signed-in state on
208
+ * mount; use `useUserContext()` for that.
209
+ *
210
+ * Bridges the `atrium:userchange` CustomEvent atrium dispatches on
211
+ * `window` through `useSyncExternalStore`, so multiple subscribers in
212
+ * the same tree share one event listener and the snapshot is
213
+ * referentially stable when nothing has changed.
214
+ *
215
+ * The canonical use is wiping a host's own QueryClient when the user
216
+ * swaps — without it, user A's host cache renders for user B until
217
+ * staleness forces a refetch:
218
+ *
219
+ * ```tsx
220
+ * function HostCacheGuard({ client }: { client: QueryClient }) {
221
+ * const { nonce } = useAtriumUser();
222
+ * useEffect(() => {
223
+ * // nonce > 0 means at least one transition has fired; on the
224
+ * // first paint we skip (the host already loaded against the
225
+ * // current user).
226
+ * if (nonce > 0) client.clear();
227
+ * }, [nonce, client]);
228
+ * return null;
229
+ * }
230
+ * ```
231
+ *
232
+ * Hosts that don't use React (or want to clear the cache from outside
233
+ * any component) can subscribe directly:
234
+ * `window.addEventListener('atrium:userchange', () => client.clear())`.
235
+ *
236
+ * Available on atrium 0.18+. On older atrium images the event is
237
+ * never dispatched, so the hook stays at the zeroed sentinel — host
238
+ * bundles that need to support pre-0.18 atrium can read
239
+ * `window.__ATRIUM_VERSION__` and fall back to the in-component
240
+ * watch-`useUserContext` workaround. */
241
+ export declare function useAtriumUser(): AtriumUserChangeDetail;
242
+ /** Test-only: drop the cached snapshot so the next `getSnapshot`
243
+ * returns the zeroed sentinel. Production code never calls this — the
244
+ * cache is updated by the event subscription. */
245
+ export declare function __resetAtriumUserCacheForTests(): void;
201
246
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,EAOL,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AACf,OAAO,EAGL,KAAK,WAAW,EAChB,KAAK,cAAc,EACpB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAElE,YAAY,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,UAAU,kBAAkB;IAC1B,gBAAgB,EAAE,MAAM,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;CACrD;AAmBD,MAAM,WAAW,mBAAmB;IAClC;;;kDAG8C;IAC9C,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB;;;sBAGkB;IAClB,gBAAgB,CAAC,EAAE,MAAM,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IACrD,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED;;;qCAGqC;AACrC,wBAAgB,cAAc,CAAC,EAC7B,MAAM,EACN,gBAAgB,EAChB,QAAQ,GACT,EAAE,mBAAmB,2MAYrB;AAED;;iEAEiE;AACjE,eAAO,MAAM,YAAY,2BAA4B,CAAC;AAmBtD;;;;;;;;8BAQ8B;AAC9B,wBAAgB,KAAK,IAAI,cAAc,CAAC,WAAW,GAAG,IAAI,CAAC,CAQ1D;AAED;;iBAEiB;AACjB,wBAAgB,cAAc,IAAI,cAAc,CAAC,WAAW,GAAG,IAAI,CAAC,CAEnE;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,OAAO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wBAAgB,kCAAkC,IAAI,IAAI,CAEzD;AAkDD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yCAqCyC;AACzC,wBAAgB,aAAa,IAAI,sBAAsB,CAMtD;AAED;;kDAEkD;AAClD,wBAAgB,8BAA8B,IAAI,IAAI,CAErD"}
@@ -4,27 +4,29 @@
4
4
  * React hooks + provider for atrium host bundles.
5
5
  *
6
6
  * One TanStack Query subscription serves the whole host tree:
7
- * `useMe()` fetches `/users/me/context` once and shares the result
8
- * with every `usePerm()`, `useRole()`, and `useUserContext()` caller.
7
+ * `useMe()` fetches `/api/users/me/context` once and shares the
8
+ * result with every `usePerm()`, `useRole()`, and `useUserContext()`
9
+ * caller.
9
10
  *
10
- * The endpoint path is fixed by atrium — it's mounted at the SPA root
11
- * by `app.include_router(me_context_router)` and served from the same
12
- * origin as the bundle. There's no `apiBase` prop because there's
13
- * nothing for the host to configure: a host bundle that loads inside
14
- * atrium's SPA fetches a same-origin relative path. Hosts that want
15
- * to layer their own retry / headers / mock can pass `fetchUserContext`.
11
+ * The endpoint path is fixed by atrium — it's mounted under
12
+ * `/api/...` (atrium >= 0.19) and served from the same origin as the
13
+ * bundle. There's no `apiBase` prop because there's nothing for the
14
+ * host to configure: a host bundle that loads inside atrium's SPA
15
+ * fetches a same-origin relative path. Hosts that want to layer
16
+ * their own retry / headers / mock can pass `fetchUserContext`.
16
17
  *
17
- * The hooks reuse the host's enclosing `<QueryClientProvider>` if one
18
- * is already mounted; pass `client={hostQueryClient}` to
18
+ * The hooks reuse the host's enclosing `<QueryClientProvider>` if
19
+ * one is already mounted; pass `client={hostQueryClient}` to
19
20
  * `<AtriumProvider>` only if you want this provider to wrap the
20
21
  * QueryClient too. Two QueryClients (atrium's + the host's) is the
21
- * intended state — atrium clears its cache on logout via `qc.clear()`,
22
- * and a shared client would lose host queries the user still wants.
22
+ * intended state — atrium clears its cache on logout via
23
+ * `qc.clear()`, and a shared client would lose host queries the user
24
+ * still wants.
23
25
  */
24
26
  import { createContext, createElement, useCallback, useContext, useMemo, useSyncExternalStore, } from 'react';
25
27
  import { QueryClientProvider, useQuery, } from '@tanstack/react-query';
26
28
  export { __atrium_t__ } from '../i18n';
27
- const ME_CONTEXT_PATH = '/users/me/context';
29
+ const ME_CONTEXT_PATH = '/api/users/me/context';
28
30
  async function defaultFetchUserContext() {
29
31
  const res = await fetch(ME_CONTEXT_PATH, {
30
32
  credentials: 'include',
@@ -296,4 +298,89 @@ export function useAtriumNavigate() {
296
298
  export function __resetAtriumLocationCacheForTests() {
297
299
  cachedLocation = null;
298
300
  }
301
+ // ---------------------------------------------------------------------------
302
+ // Identity transitions — `atrium:userchange`
303
+ // ---------------------------------------------------------------------------
304
+ const ATRIUM_USERCHANGE_EVENT = 'atrium:userchange';
305
+ const NO_USERCHANGE = {
306
+ previous: null,
307
+ current: null,
308
+ nonce: 0,
309
+ };
310
+ // Module-level cache so `useSyncExternalStore.getSnapshot` returns a
311
+ // referentially-stable object across renders. Updated only when an
312
+ // `atrium:userchange` event lands; `null` until the first event.
313
+ let cachedUserChange = null;
314
+ function getUserChangeSnapshot() {
315
+ return cachedUserChange ?? NO_USERCHANGE;
316
+ }
317
+ function getServerUserChangeSnapshot() {
318
+ return NO_USERCHANGE;
319
+ }
320
+ function subscribeUserChange(onChange) {
321
+ if (typeof window === 'undefined')
322
+ return () => { };
323
+ const handler = (e) => {
324
+ const detail = e.detail;
325
+ if (detail &&
326
+ (detail.previous === null || typeof detail.previous === 'number') &&
327
+ (detail.current === null || typeof detail.current === 'number')) {
328
+ cachedUserChange = {
329
+ previous: detail.previous,
330
+ current: detail.current,
331
+ nonce: typeof detail.nonce === 'number' ? detail.nonce : 0,
332
+ };
333
+ onChange();
334
+ }
335
+ };
336
+ window.addEventListener(ATRIUM_USERCHANGE_EVENT, handler);
337
+ return () => window.removeEventListener(ATRIUM_USERCHANGE_EVENT, handler);
338
+ }
339
+ /** Subscribe to atrium's identity transitions from inside a host
340
+ * bundle's React tree. Returns the most recent `atrium:userchange`
341
+ * detail — `{previous, current, nonce}` — or a zeroed sentinel
342
+ * (`{previous: null, current: null, nonce: 0}`) before any event has
343
+ * fired. The hook does NOT report the initial signed-in state on
344
+ * mount; use `useUserContext()` for that.
345
+ *
346
+ * Bridges the `atrium:userchange` CustomEvent atrium dispatches on
347
+ * `window` through `useSyncExternalStore`, so multiple subscribers in
348
+ * the same tree share one event listener and the snapshot is
349
+ * referentially stable when nothing has changed.
350
+ *
351
+ * The canonical use is wiping a host's own QueryClient when the user
352
+ * swaps — without it, user A's host cache renders for user B until
353
+ * staleness forces a refetch:
354
+ *
355
+ * ```tsx
356
+ * function HostCacheGuard({ client }: { client: QueryClient }) {
357
+ * const { nonce } = useAtriumUser();
358
+ * useEffect(() => {
359
+ * // nonce > 0 means at least one transition has fired; on the
360
+ * // first paint we skip (the host already loaded against the
361
+ * // current user).
362
+ * if (nonce > 0) client.clear();
363
+ * }, [nonce, client]);
364
+ * return null;
365
+ * }
366
+ * ```
367
+ *
368
+ * Hosts that don't use React (or want to clear the cache from outside
369
+ * any component) can subscribe directly:
370
+ * `window.addEventListener('atrium:userchange', () => client.clear())`.
371
+ *
372
+ * Available on atrium 0.18+. On older atrium images the event is
373
+ * never dispatched, so the hook stays at the zeroed sentinel — host
374
+ * bundles that need to support pre-0.18 atrium can read
375
+ * `window.__ATRIUM_VERSION__` and fall back to the in-component
376
+ * watch-`useUserContext` workaround. */
377
+ export function useAtriumUser() {
378
+ return useSyncExternalStore(subscribeUserChange, getUserChangeSnapshot, getServerUserChangeSnapshot);
379
+ }
380
+ /** Test-only: drop the cached snapshot so the next `getSnapshot`
381
+ * returns the zeroed sentinel. Production code never calls this — the
382
+ * cache is updated by the event subscription. */
383
+ export function __resetAtriumUserCacheForTests() {
384
+ cachedUserChange = null;
385
+ }
299
386
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA,kC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uB,EAAE,OAAO,CAAC,CAAC;IAC1D,OAAO,GAAG,EAAE,CAAC,MAAM,CAAC,mBAAmB,CAAC,uBAAuB,EAAE,OAAO,CAAC,CAAC;AAC5E,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yCAqCyC;AACzC,MAAM,UAAU,aAAa;IAC3B,OAAO,oBAAoB,CACzB,mBAAmB,EACnB,qBAAqB,EACrB,2BAA2B,CAC5B,CAAC;AACJ,CAAC;AAED;;kDAEkD;AAClD,MAAM,UAAU,8BAA8B;IAC5C,gBAAgB,GAAG,IAAI,CAAC;AAC1B,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@brendanbank/atrium-host-bundle-utils",
3
- "version": "0.17.0",
4
- "description": "Runtime helpers, Vite preset, and React hooks for atrium host bundles. Wraps the dual-tree mount pattern, the host-bundle Vite library config, and the /users/me/context hook so a host's main.tsx is ~10 lines of registration calls.",
3
+ "version": "0.19.0",
4
+ "description": "Runtime helpers, Vite preset, and React hooks for atrium host bundles. Wraps the dual-tree mount pattern, the host-bundle Vite library config, and the /api/users/me/context hook so a host's main.tsx is ~10 lines of registration calls.",
5
5
  "license": "BSD-2-Clause",
6
6
  "type": "module",
7
7
  "files": [
@@ -25,7 +25,7 @@
25
25
  }
26
26
  },
27
27
  "dependencies": {
28
- "@brendanbank/atrium-host-types": "0.17.0"
28
+ "@brendanbank/atrium-host-types": "0.19.0"
29
29
  },
30
30
  "peerDependencies": {
31
31
  "@tanstack/react-query": "^5.0.0",