@molecule/app-angular 3.7.1 → 3.8.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.
Files changed (50) hide show
  1. package/README.md +354 -113
  2. package/dist/hooks/use-ai-models.d.ts +4 -1
  3. package/dist/hooks/use-ai-models.d.ts.map +1 -1
  4. package/dist/hooks/use-ai-models.js +7 -1
  5. package/dist/hooks/use-ai-models.js.map +1 -1
  6. package/dist/hooks/use-async.d.ts +3 -1
  7. package/dist/hooks/use-async.d.ts.map +1 -1
  8. package/dist/hooks/use-async.js +2 -0
  9. package/dist/hooks/use-async.js.map +1 -1
  10. package/dist/hooks/use-auth.d.ts +5 -2
  11. package/dist/hooks/use-auth.d.ts.map +1 -1
  12. package/dist/hooks/use-auth.js +5 -2
  13. package/dist/hooks/use-auth.js.map +1 -1
  14. package/dist/hooks/use-forms.d.ts +12 -6
  15. package/dist/hooks/use-forms.d.ts.map +1 -1
  16. package/dist/hooks/use-forms.js +68 -21
  17. package/dist/hooks/use-forms.js.map +1 -1
  18. package/dist/hooks/use-store.d.ts +18 -1
  19. package/dist/hooks/use-store.d.ts.map +1 -1
  20. package/dist/hooks/use-store.js +4 -15
  21. package/dist/hooks/use-store.js.map +1 -1
  22. package/dist/hooks/use-theme.d.ts.map +1 -1
  23. package/dist/hooks/use-theme.js +43 -10
  24. package/dist/hooks/use-theme.js.map +1 -1
  25. package/dist/hooks/use-translation.d.ts +5 -0
  26. package/dist/hooks/use-translation.d.ts.map +1 -1
  27. package/dist/hooks/use-translation.js +31 -4
  28. package/dist/hooks/use-translation.js.map +1 -1
  29. package/dist/index.d.ts +38 -15
  30. package/dist/index.d.ts.map +1 -1
  31. package/dist/index.js +38 -15
  32. package/dist/index.js.map +1 -1
  33. package/dist/link.d.ts +6 -1
  34. package/dist/link.d.ts.map +1 -1
  35. package/dist/link.js +11 -4
  36. package/dist/link.js.map +1 -1
  37. package/dist/services/forms.service.d.ts.map +1 -1
  38. package/dist/services/forms.service.js +0 -3
  39. package/dist/services/forms.service.js.map +1 -1
  40. package/dist/services/promise.service.d.ts +8 -4
  41. package/dist/services/promise.service.d.ts.map +1 -1
  42. package/dist/services/promise.service.js +2 -1
  43. package/dist/services/promise.service.js.map +1 -1
  44. package/dist/session-ready.d.ts +4 -3
  45. package/dist/session-ready.d.ts.map +1 -1
  46. package/dist/session-ready.js +5 -4
  47. package/dist/session-ready.js.map +1 -1
  48. package/dist/types.d.ts +4 -5
  49. package/dist/types.d.ts.map +1 -1
  50. package/package.json +3 -3
package/README.md CHANGED
@@ -3,7 +3,7 @@ AUTO-GENERATED — DO NOT EDIT THIS FILE.
3
3
  Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
4
4
  Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
5
5
  To change this document, edit the module-level JSDoc in src/index.ts.
6
- Generated: 2026-11-16T14:06:29.917Z
6
+ Generated: 2026-11-20T06:32:15.073Z
7
7
  -->
8
8
 
9
9
  # @molecule/app-angular
@@ -22,28 +22,21 @@ interfaces with Angular's idioms (services, DI, RxJS observables, etc.).
22
22
 
23
23
  ```typescript
24
24
  // main.ts — wire concrete providers into Angular DI:
25
+ import { Component, inject } from '@angular/core'
25
26
  import { bootstrapApplication } from '@angular/platform-browser'
26
- import { provideMolecule } from '@molecule/app-angular'
27
+ import {
28
+ MoleculeAuthService,
29
+ MoleculeThemeService,
30
+ provideMolecule,
31
+ t,
32
+ } from '@molecule/app-angular'
27
33
  import { createJWTAuthClient } from '@molecule/app-auth'
28
34
  import { provider as stateProvider } from '@molecule/app-state-zustand'
29
35
  import { provider as themeProvider } from '@molecule/app-theme-css-variables'
30
36
 
31
37
  const authClient = createJWTAuthClient({ baseURL: '/api' })
32
38
 
33
- bootstrapApplication(AppComponent, {
34
- providers: [
35
- provideMolecule({
36
- state: stateProvider,
37
- auth: authClient,
38
- theme: themeProvider,
39
- }),
40
- ],
41
- })
42
-
43
39
  // dashboard.component.ts — inject the Molecule services:
44
- import { Component, inject } from '@angular/core'
45
- import { MoleculeAuthService, MoleculeThemeService, t } from '@molecule/app-angular'
46
-
47
40
  @Component({
48
41
  selector: 'app-dashboard',
49
42
  template: `
@@ -56,7 +49,7 @@ import { MoleculeAuthService, MoleculeThemeService, t } from '@molecule/app-angu
56
49
  </div>
57
50
  `,
58
51
  })
59
- class DashboardComponent {
52
+ export class DashboardComponent {
60
53
  // Expose the reactive t() so template bindings re-evaluate on locale change.
61
54
  protected readonly t = t
62
55
 
@@ -70,8 +63,38 @@ class DashboardComponent {
70
63
  void this.authService.logout()
71
64
  }
72
65
  }
66
+
67
+ // app.component.ts — the root that mounts the dashboard:
68
+ @Component({
69
+ selector: 'app-root',
70
+ imports: [DashboardComponent],
71
+ template: '<app-dashboard />',
72
+ })
73
+ export class AppComponent {}
74
+
75
+ bootstrapApplication(AppComponent, {
76
+ providers: [
77
+ provideMolecule({
78
+ state: stateProvider,
79
+ auth: authClient,
80
+ theme: themeProvider,
81
+ }),
82
+ ],
83
+ })
73
84
  ```
74
85
 
86
+ **Session restore:** `useAuth().status === 'loading'` is undecided: wait for
87
+ it and redirect only on `status === 'unauthenticated'`. `'unavailable'` keeps
88
+ the session candidate for retry, but `isAuthenticated` can be false and
89
+ `user` can be null. A restore failure other than 401/403 never signs out.
90
+ `provideMolecule({ auth })` starts the bundled client's restore when a
91
+ consumer first reads the session, so the app entry can mount its root without
92
+ calling `initialize()`. A cached token and user render signed-in content
93
+ immediately, and a visitor without a session candidate renders signed-out
94
+ content immediately. Set `awaitSession: true` to hold bootstrap — and so
95
+ every page's first render — while a token-only or cookie-only restore is
96
+ undecided.
97
+
75
98
  ## Type
76
99
 
77
100
  `framework`
@@ -142,55 +165,143 @@ interface AuthClient<
142
165
  T = UserProfile,
143
166
  TRegister extends RegisterExtraShape<TRegister> = Record<never, never>,
144
167
  > {
145
- /** Returns the current authentication state snapshot. */
168
+ /**
169
+ * Returns the current authentication state snapshot.
170
+ *
171
+ * READING the state starts the client's one session restore when nobody has called
172
+ * {@link initialize} yet — lazily and exactly once, sharing the promise an explicit
173
+ * `initialize()` returns. A hook (`useAuth()`), a subscriber, `isAuthenticated()` and
174
+ * `getUser()` are reads too, so a client whose entry file dropped the template's
175
+ * `authClient.initialize()` line still restores instead of reporting `'loading'`
176
+ * forever.
177
+ */
146
178
  getState(): AuthState<T>
147
179
 
148
- /** Returns whether the user is currently authenticated. */
180
+ /**
181
+ * Returns whether the user is currently authenticated.
182
+ */
149
183
  isAuthenticated(): boolean
150
184
 
151
- /** Gets the current user. */
185
+ /**
186
+ * Gets the current user.
187
+ */
152
188
  getUser(): T | null
153
189
 
154
- /** Optional ownership marker for the current session. */
190
+ /**
191
+ * Optional ownership marker for the current session. Compare values only within
192
+ * this client: replacing or ending a session changes it, including re-adopting
193
+ * the same token and user. Profile updates and same-session refreshes keep it.
194
+ * Consumers can use it to discard stale async work without treating editable
195
+ * user fields as an immutable account identifier. Providers without this
196
+ * capability require the consumer's own stable identity check.
197
+ */
155
198
  getSessionRevision?(): number
156
199
 
157
200
  /** Updates the cached user object (state + persistent storage) without hitting the network. */
158
201
  setUser(user: T | null): void
159
202
 
160
- /** Gets the current access token. */
203
+ /**
204
+ * Gets the current access token.
205
+ */
161
206
  getAccessToken(): string | null
162
207
 
163
- /** Stores the access token in the configured token storage adapter (in a browser, Web Storage; `'memory'` where no browser store exists). */
208
+ /**
209
+ * Stores the access token in the configured token storage adapter (in a
210
+ * browser, Web Storage; `'memory'` where no browser store exists). Use this
211
+ * to seed the token after an out-of-band exchange (e.g. the OAuth
212
+ * code→token redirect) instead of writing to `localStorage` directly,
213
+ * which would violate the storage contract and make a stored bearer token
214
+ * JS-readable (XSS-exfiltratable). Pass `null` to clear it.
215
+ *
216
+ * Passing `null` does not by itself sign a signed-in client out: use
217
+ * {@link logout} to end a session, or {@link setUser} with `null` for
218
+ * local-only sign-out. A non-null token on a client that is not signed in is
219
+ * the first or second half of the app's own sign-in pair: together with
220
+ * {@link setUser} it adopts the session (see there). Prefer {@link setSession}
221
+ * with the token and user, or {@link login} / {@link register} for a
222
+ * credential exchange.
223
+ */
164
224
  setAccessToken(token: string | null): void
165
225
 
166
- /** Adopts a session an out-of-band exchange already established: stores the access token (and the refresh token when given), caches the user, and sets the COMPLET… */
226
+ /**
227
+ * Adopts a session an out-of-band exchange already established: stores the
228
+ * access token (and the refresh token when given), caches the user, and
229
+ * sets the COMPLETE state — `initialized`, `authenticated`, `status:
230
+ * 'authenticated'`, no error — in one update, with one subscriber
231
+ * notification. Every hook reading the shared client sees the user as
232
+ * signed in immediately.
233
+ *
234
+ * This is the way to seed an OAuth/custom sign-in. The field-setter pair
235
+ * ({@link setAccessToken} then {@link setUser}, or the reverse) on a client
236
+ * that is not signed in adopts the session the same way.
237
+ */
167
238
  setSession(session: AuthSessionSeed<T>): void
168
239
 
169
- /** Gets the refresh token. */
240
+ /**
241
+ * Gets the refresh token.
242
+ */
170
243
  getRefreshToken(): string | null
171
244
 
172
- /** Logs in with credentials. */
245
+ /**
246
+ * Logs in with credentials.
247
+ */
173
248
  login(credentials: LoginCredentials): Promise<AuthResult<T>>
174
249
 
175
- /** Logs out the current user. */
250
+ /**
251
+ * Logs out the current user. The server request is best-effort: a missing
252
+ * logout route (404), any other HTTP failure, or a network error never makes
253
+ * this method reject. It always clears the access token, refresh token and
254
+ * cached user, stops automatic refresh, and publishes one settled
255
+ * `authenticated: false`, `status: 'unauthenticated'` transition. Every pending
256
+ * session operation loses ownership; a persistent marker prevents reload from
257
+ * restoring an older session, and late credentials are revoked best-effort.
258
+ *
259
+ * When the API has no logout route, set {@link AuthClientConfigOptions.logoutEndpoint}
260
+ * to `null` (or `''`) to skip the request. Local sign-out still happens.
261
+ */
176
262
  logout(): Promise<void>
177
263
 
178
- /** Registers a new user. */
264
+ /**
265
+ * Registers a new user. Accepts the base fields plus the app's own fields
266
+ * (`TRegister`) at the top level — see {@link RegisterData}.
267
+ */
179
268
  register(data: RegisterData<TRegister>): Promise<AuthResult<T>>
180
269
 
181
- /** Exchanges a stored refresh token, or re-reads `currentUserEndpoint` with the existing access token/session cookie when the API has no refresh credential. */
270
+ /**
271
+ * Exchanges a stored refresh token, or re-reads `currentUserEndpoint` with the
272
+ * existing access token/session cookie when the API has no refresh credential.
273
+ * That fallback maps, stores and publishes the server user without renewing
274
+ * the access token. Failures reject. A 401/403 ends the session, as does an
275
+ * additional {@link AuthClientConfigOptions.currentUserRejectionStatuses}
276
+ * code from the fallback. Transient failures retain it as unavailable. Use {@link updateProfile} for a profile
277
+ * save, or {@link setUser} with the canonical row from an app-owned mutation.
278
+ */
182
279
  refresh(): Promise<AuthResult<T>>
183
280
 
184
- /** Requests a password reset. */
281
+ /**
282
+ * Requests a password reset.
283
+ */
185
284
  requestPasswordReset(data: PasswordResetRequest): Promise<void>
186
285
 
187
- /** Confirms a password reset. */
286
+ /**
287
+ * Confirms a password reset.
288
+ */
188
289
  confirmPasswordReset(data: PasswordResetConfirm): Promise<void>
189
290
 
190
- /** Updates the current user's profile. */
291
+ /**
292
+ * Updates the current user's profile.
293
+ * Returns the saved profile: the answer applied onto the signed-in user field
294
+ * by field, with or without an `id` — a field it carries replaces the value
295
+ * (`null` clears it), one it omits or leaves `undefined` is kept, so a field
296
+ * cleared by omission must arrive as `null`. A non-object answer is returned
297
+ * as it came. An answer for a replaced or ended session leaves the current one
298
+ * untouched.
299
+ */
191
300
  updateProfile(data: Partial<T>): Promise<T>
192
301
 
193
- /** Changes the current user's password. */
302
+ /**
303
+ * Changes the current user's password.
304
+ */
194
305
  changePassword(oldPassword: string, newPassword: string): Promise<void>
195
306
 
196
307
  /** Initializes auth state (e.g., from stored tokens). */
@@ -202,24 +313,48 @@ interface AuthClient<
202
313
  /** Resolves when the session restore started by `initialize()` has settled — the point after which the client knows whether this visitor is signed in. */
203
314
  whenRestored?(): Promise<void>
204
315
 
205
- /** Subscribes to auth state changes. */
316
+ /**
317
+ * Subscribes to auth state changes.
318
+ */
206
319
  subscribe(callback: (state: AuthState<T>) => void): () => void
207
320
 
208
- /** Subscribes to auth state changes (alias for subscribe). */
321
+ /**
322
+ * Subscribes to auth state changes (alias for subscribe).
323
+ */
209
324
  onAuthChange(callback: (state: AuthState<T>) => void): () => void
210
325
 
211
- /** Gets the current access token (alias for getAccessToken). */
326
+ /**
327
+ * Gets the current access token (alias for getAccessToken).
328
+ */
212
329
  getToken?(): string | null
213
330
 
214
- /** Adds an auth event listener. */
331
+ /**
332
+ * Adds an auth event listener.
333
+ *
334
+ * The listener is typed by this client's profile: one signature,
335
+ * `AuthEventListener<T>`, so an inline arrow is contextually typed and `event`
336
+ * is never implicitly `any`. A client whose profile extends
337
+ * {@link UserProfile} also accepts a default {@link AuthEventListener}: when
338
+ * `T` extends `UserProfile`, `AuthEvent<T>` is assignable to
339
+ * `AuthEvent<UserProfile>`, so a listener that takes the wider default event
340
+ * accepts every event this client emits and keeps compiling. (`UserProfile`
341
+ * is the wider type here — it has fewer required fields — and the assignable
342
+ * direction runs from the client's `AuthEvent<T>` to the listener's
343
+ * `AuthEvent<UserProfile>`.) A profile that does not extend `UserProfile`
344
+ * (no `id`) rejects the default listener: an `AuthEvent<UserProfile>` would
345
+ * promise an `id` the runtime user does not have, and the narrower-typed
346
+ * event is not assignable to it.
347
+ */
215
348
  addEventListener(listener: AuthEventListener<T>): () => void
216
349
 
217
- /** Destroys the auth client. */
350
+ /**
351
+ * Destroys the auth client.
352
+ */
218
353
  destroy(): void
219
354
  }
220
355
  ```
221
356
 
222
- _(Member comments are shortened to their first sentence to fit; the full declaration is in `node_modules/@molecule/app-auth/dist/types.d.ts`.)_
357
+ _(The 4 longest member comments are shortened to their first sentence to fit; the full declaration is in `node_modules/@molecule/app-auth/dist/types.d.ts`.)_
223
358
 
224
359
  #### `EditorProvider`
225
360
 
@@ -460,6 +595,15 @@ interface FormOptions<T extends FormValuesConstraint<T>> {
460
595
  HTTP client interface.
461
596
 
462
597
  All HTTP providers must implement this interface.
598
+ An explicit text, blob or arraybuffer parser determines the data type even when
599
+ a JSON generic is supplied. Keep JSON as the default for mutations returning a
600
+ record. A successful DELETE with no body already resolves with null data.
601
+
602
+ Every verb also takes a URL alone, through a signature with the same three parameters on every
603
+ verb, so a verb chosen at runtime (`client[verb](url)`) type-checks and a wrapper can implement
604
+ a verb with an arrow (`get: (url, config) => inner.get(url, config)`). With a body or a config,
605
+ choose the verb through `request({ method, url, data })` instead: the second argument is the
606
+ body for post/put/patch but the config for get/delete, so one call cannot serve both.
463
607
 
464
608
  ```typescript
465
609
  interface HttpClient {
@@ -477,11 +621,33 @@ interface HttpClient {
477
621
  * Makes a generic HTTP request. `data` is a field of THIS config object — the same body
478
622
  * `post(url, data, config)` takes as its second argument.
479
623
  */
624
+ request<T = unknown>(
625
+ config: FullRequestConfig & { responseType: 'text' },
626
+ ): Promise<HttpResponse<string>>
627
+ request<T = unknown>(
628
+ config: FullRequestConfig & { responseType: 'blob' },
629
+ ): Promise<HttpResponse<Blob>>
630
+ request<T = unknown>(
631
+ config: FullRequestConfig & { responseType: 'arraybuffer' },
632
+ ): Promise<HttpResponse<ArrayBuffer>>
480
633
  request<T = unknown>(config: FullRequestConfig): Promise<HttpResponse<T>>
481
634
 
482
635
  /**
483
636
  * Makes a GET request.
484
637
  */
638
+ get<T = unknown>(
639
+ url: string,
640
+ config: RequestConfig & { responseType: 'text' },
641
+ ): Promise<HttpResponse<string>>
642
+ get<T = unknown>(
643
+ url: string,
644
+ config: RequestConfig & { responseType: 'blob' },
645
+ ): Promise<HttpResponse<Blob>>
646
+ get<T = unknown>(
647
+ url: string,
648
+ config: RequestConfig & { responseType: 'arraybuffer' },
649
+ ): Promise<HttpResponse<ArrayBuffer>>
650
+ get<T = unknown>(url: string, config?: undefined, unused?: undefined): Promise<HttpResponse<T>>
485
651
  get<T = unknown>(url: string, config?: RequestConfig): Promise<HttpResponse<T>>
486
652
 
487
653
  /**
@@ -489,23 +655,84 @@ interface HttpClient {
489
655
  * `data` itself, so `post(url, { data: body })` sends `{"data":body}` — pass `body` directly.
490
656
  * A config (headers, params) is the THIRD argument.
491
657
  */
658
+ post<T = unknown>(
659
+ url: string,
660
+ data: unknown,
661
+ config: RequestConfig & { responseType: 'text' },
662
+ ): Promise<HttpResponse<string>>
663
+ post<T = unknown>(
664
+ url: string,
665
+ data: unknown,
666
+ config: RequestConfig & { responseType: 'blob' },
667
+ ): Promise<HttpResponse<Blob>>
668
+ post<T = unknown>(
669
+ url: string,
670
+ data: unknown,
671
+ config: RequestConfig & { responseType: 'arraybuffer' },
672
+ ): Promise<HttpResponse<ArrayBuffer>>
673
+ post<T = unknown>(url: string, data?: undefined, config?: undefined): Promise<HttpResponse<T>>
492
674
  post<T = unknown>(url: string, data?: unknown, config?: RequestConfig): Promise<HttpResponse<T>>
493
675
 
494
676
  /**
495
677
  * Makes a PUT request. `data` is the request BODY (second argument) — never `{ data: body }`,
496
678
  * which sends `{"data":body}`; a config is the THIRD argument.
497
679
  */
680
+ put<T = unknown>(
681
+ url: string,
682
+ data: unknown,
683
+ config: RequestConfig & { responseType: 'text' },
684
+ ): Promise<HttpResponse<string>>
685
+ put<T = unknown>(
686
+ url: string,
687
+ data: unknown,
688
+ config: RequestConfig & { responseType: 'blob' },
689
+ ): Promise<HttpResponse<Blob>>
690
+ put<T = unknown>(
691
+ url: string,
692
+ data: unknown,
693
+ config: RequestConfig & { responseType: 'arraybuffer' },
694
+ ): Promise<HttpResponse<ArrayBuffer>>
695
+ put<T = unknown>(url: string, data?: undefined, config?: undefined): Promise<HttpResponse<T>>
498
696
  put<T = unknown>(url: string, data?: unknown, config?: RequestConfig): Promise<HttpResponse<T>>
499
697
 
500
698
  /**
501
699
  * Makes a PATCH request. `data` is the request BODY (second argument) — never `{ data: body }`,
502
700
  * which sends `{"data":body}`; a config is the THIRD argument.
503
701
  */
702
+ patch<T = unknown>(
703
+ url: string,
704
+ data: unknown,
705
+ config: RequestConfig & { responseType: 'text' },
706
+ ): Promise<HttpResponse<string>>
707
+ patch<T = unknown>(
708
+ url: string,
709
+ data: unknown,
710
+ config: RequestConfig & { responseType: 'blob' },
711
+ ): Promise<HttpResponse<Blob>>
712
+ patch<T = unknown>(
713
+ url: string,
714
+ data: unknown,
715
+ config: RequestConfig & { responseType: 'arraybuffer' },
716
+ ): Promise<HttpResponse<ArrayBuffer>>
717
+ patch<T = unknown>(url: string, data?: undefined, config?: undefined): Promise<HttpResponse<T>>
504
718
  patch<T = unknown>(url: string, data?: unknown, config?: RequestConfig): Promise<HttpResponse<T>>
505
719
 
506
720
  /**
507
721
  * Makes a DELETE request.
508
722
  */
723
+ delete<T = unknown>(
724
+ url: string,
725
+ config: RequestConfig & { responseType: 'text' },
726
+ ): Promise<HttpResponse<string>>
727
+ delete<T = unknown>(
728
+ url: string,
729
+ config: RequestConfig & { responseType: 'blob' },
730
+ ): Promise<HttpResponse<Blob>>
731
+ delete<T = unknown>(
732
+ url: string,
733
+ config: RequestConfig & { responseType: 'arraybuffer' },
734
+ ): Promise<HttpResponse<ArrayBuffer>>
735
+ delete<T = unknown>(url: string, config?: undefined, unused?: undefined): Promise<HttpResponse<T>>
509
736
  delete<T = unknown>(url: string, config?: RequestConfig): Promise<HttpResponse<T>>
510
737
 
511
738
  /**
@@ -544,46 +771,21 @@ interface HttpClient {
544
771
  */
545
772
  getAuthToken(): string | null
546
773
 
547
- /**
548
- * Registers the LIVE token resolver every request of this client reads, or clears it with
549
- * `null`.
550
- *
551
- * `@molecule/app-http`'s `setAuthTokenSource()` calls this on every client it bonds, and the
552
- * client MUST consult the resolver again each time it assembles a request (and report it from
553
- * `getAuthToken()`). A session can change with no auth event and no observable state change —
554
- * `authClient.setSession()` with the same profile data, or the OAuth callback's
555
- * `setAccessToken()` — so a token pushed only at bond time or on `login`/`logout` events
556
- * leaves every later request carrying the PREVIOUS session's bearer while the UI shows the
557
- * new one.
558
- *
559
- * The resolved token takes the static token's place, with the same precedence: an
560
- * `Authorization` header passed per request or in the client's default headers wins over it
561
- * exactly where it won over a static token in this transport.
562
- *
563
- * A resolver that returns `null` (or `undefined`) means "this session has no body token": the
564
- * request carries no `Authorization` header of the client's own. A cookie-session API issues
565
- * no bearer, and the server prefers the header over the fresh cookie, so a kept bearer
566
- * authenticates as the prior — possibly deleted — session.
567
- *
568
- * Optional, so an implementation written against the previous interface still conforms.
569
- * `setAuthTokenSource()` follows such a client through a request interceptor instead, pushing
570
- * the source with `setAuthToken` before each request: that request carries the change only
571
- * when the transport applies its token after running its interceptors, so a transport that
572
- * applies it earlier sends a session adopted mid-page from the following request on.
573
- *
574
- * @param resolver - Returns the current access token (or null/undefined), or `null` to clear.
575
- */
774
+ /** Registers the LIVE token resolver every request of this client reads, or clears it with `null`. */
576
775
  setAuthTokenResolver?(resolver: AuthTokenResolver | null): void
577
776
 
578
777
  /**
579
- * Registers a handler for authentication errors (401).
778
+ * Registers a handler for authentication errors (401), with the rejected request's metadata.
580
779
  *
780
+ * @param handler - Receives the method, URL and credential state of the rejected request.
581
781
  * @returns An unsubscribe function.
582
782
  */
583
- onAuthError(handler: () => void): () => void
783
+ onAuthError(handler: (event: HttpAuthErrorEvent) => void): () => void
584
784
  }
585
785
  ```
586
786
 
787
+ _(The longest member comment is shortened to its first sentence to fit; the full declaration is in `node_modules/@molecule/app-http/dist/client.d.ts`.)_
788
+
587
789
  #### `I18nProvider`
588
790
 
589
791
  i18n provider interface.
@@ -1123,6 +1325,16 @@ interface Router {
1123
1325
  */
1124
1326
  generatePath(name: string, params?: RouteParams, query?: QueryParams): string
1125
1327
 
1328
+ /**
1329
+ * The `href` an anchor to the in-app `path` carries, as the native router's own link
1330
+ * writes it (its base path prefixed, or `#/…` under a hash history), so a middle-click,
1331
+ * a new tab or a copied link opens the same page a click does.
1332
+ *
1333
+ * @param path - Pathname with optional query string and hash, as passed to `navigate`.
1334
+ * @returns The `href`.
1335
+ */
1336
+ createHref(path: string): string
1337
+
1126
1338
  /**
1127
1339
  * Subscribes to route changes.
1128
1340
  */
@@ -1371,7 +1583,10 @@ Result returned by {@link useAIModels}: every field as a signal.
1371
1583
 
1372
1584
  ```typescript
1373
1585
  interface UseAIModelsResult {
1374
- /** Available models, or an empty array while loading. */
1586
+ /**
1587
+ * Available models, or an empty array while loading or after a failed fetch. The list keeps its identity
1588
+ * until the catalog changes, the empty one included, so it can key a computed or an effect.
1589
+ */
1375
1590
  readonly models: Signal<AppModelDefinition[]>
1376
1591
  /**
1377
1592
  * Per-mode server default model ids for the requester's tier, or `undefined`
@@ -2497,6 +2712,18 @@ interface UseStoreOptions<T, S = T> {
2497
2712
  }
2498
2713
  ```
2499
2714
 
2715
+ #### `SelectingStoreOptions`
2716
+
2717
+ Options for {@link useStore} that pick part of the store: a selector is
2718
+ required, so the selected type `S` always comes from it.
2719
+
2720
+ ```typescript
2721
+ interface SelectingStoreOptions<T, S> extends UseStoreOptions<T, S> {
2722
+ /** Picks the value the hook returns from the store's state. */
2723
+ selector: (state: T) => S
2724
+ }
2725
+ ```
2726
+
2500
2727
  #### `UseThemeResult`
2501
2728
 
2502
2729
  What {@link useTheme} returns: the current theme, its name and mode as
@@ -2528,6 +2755,11 @@ interface UseTranslationResult {
2528
2755
  * method itself) that reads the provider on every call AND the locale
2529
2756
  * notifications signal, so a template, `computed` or `effect` that calls it
2530
2757
  * re-runs on a locale switch the way React re-renders on one.
2758
+ *
2759
+ * Its identity follows the active locale, like React's `useTranslation().t`:
2760
+ * a value memoized on it (a `computed`, a child bound `t` as an input)
2761
+ * refreshes after a switch, while an `addTranslations` for the same locale
2762
+ * keeps it. `useT()` is the one-identity form.
2531
2763
  */
2532
2764
  readonly t: I18nProvider['t']
2533
2765
  /** The active locale code. */
@@ -2838,18 +3070,16 @@ interface PlatformService {
2838
3070
  Promise state manager.
2839
3071
 
2840
3072
  ```typescript
2841
- interface PromiseStateManager<T> {
3073
+ interface PromiseStateManager<T, Args extends unknown[] = unknown[]> {
2842
3074
  state$: Observable<PromiseState<T>>
2843
3075
  getState: () => PromiseState<T>
2844
- call: (...args: any[]) => Promise<T>
3076
+ call: (...args: Args) => Promise<T>
2845
3077
  cancel: (message?: string) => void
2846
3078
  reset: () => void
2847
3079
  destroy: () => void
2848
3080
  }
2849
3081
  ```
2850
3082
 
2851
- **Returns:** The result.
2852
-
2853
3083
  #### `PushService`
2854
3084
 
2855
3085
  Push service interface.
@@ -2930,13 +3160,12 @@ interface MoleculeModuleConfig {
2930
3160
  auth?: AuthClient<unknown>
2931
3161
  /**
2932
3162
  * Hold bootstrap (and so every page's first render) until `auth` has decided the
2933
- * session. After a full page load a returning visitor's session is restored by one
2934
- * request, and until it answers `MoleculeAuthService.user` is `null` everywhere — a
2935
- * public page's signed-in action (`if (!user) return`, a redirect to `/login`) then
2936
- * treats a signed-in visitor as signed out. With this set, Angular's app initializer
3163
+ * session. A token-only or cookie-only restore makes a current-user request.
3164
+ * Until it answers, a public page's signed-in action (`if (!user) return`, a
3165
+ * redirect to `/login`) can treat a signed-in visitor as signed out. Angular's app initializer
2937
3166
  * waits only while status is `'loading'`, so a cached session can render while its
2938
3167
  * verification continues in the background. `'unavailable'` also renders and may have a
2939
- * null user. Without a session hint, an anonymous visitor settles in microtasks without
3168
+ * null user. A visitor with no session candidate settles synchronously without
2940
3169
  * a request. Ignored without `auth`.
2941
3170
  */
2942
3171
  awaitSession?: boolean
@@ -3108,10 +3337,13 @@ that calls `navigate()`. Needs the router from `provideMolecule({ router })`.
3108
3337
  selector: 'a[molLink]',
3109
3338
  standalone: true,
3110
3339
  inputs: ['molLink', 'replace', 'state'],
3111
- host: { '[attr.href]': 'molLink' },
3340
+ host: { '[attr.href]': 'href' },
3112
3341
  })
3113
3342
  export class Link implements OnInit {
3114
- /** The destination: an app path (`/settings?tab=billing#plan`) or a URL. */
3343
+ /**
3344
+ * The destination: an app path (`/settings?tab=billing#plan`) or a URL. An app path's `href` is
3345
+ * the one the router writes for it (`routerLinkHref`), base path included.
3346
+ */
3115
3347
  molLink = ''
3116
3348
  /** Replace the current history entry instead of pushing one. */
3117
3349
  replace?: boolean
@@ -3119,6 +3351,11 @@ export class Link implements OnInit {
3119
3351
  state?: unknown
3120
3352
 
3121
3353
  private readonly router = useRouterInstance()
3354
+
3355
+ /** The anchor's `href`: the one the router writes for an app path, base path included. */
3356
+ get href(): string {
3357
+ return routerLinkHref(this.molLink, this.router)
3358
+ }
3122
3359
  private readonly element = inject<ElementRef<HTMLAnchorElement>>(ElementRef)
3123
3360
  private readonly renderer = inject(Renderer2)
3124
3361
  private readonly destroyRef = inject(DestroyRef)
@@ -3397,8 +3634,7 @@ class MoleculeFormInstance<T extends FormValuesConstraint<T>> {
3397
3634
  * @param value - The new value to set for the field.
3398
3635
  */
3399
3636
  setValue<K extends keyof T>(name: K, value: T[K]): void {
3400
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
3401
- this.controller.setValue(name as any, value as any)
3637
+ this.controller.setValue(name as string, value)
3402
3638
  }
3403
3639
 
3404
3640
  /**
@@ -3408,8 +3644,7 @@ class MoleculeFormInstance<T extends FormValuesConstraint<T>> {
3408
3644
  * @returns The error message for the field, or `undefined` if the field has no error.
3409
3645
  */
3410
3646
  getError(name: keyof T): string | undefined {
3411
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
3412
- return this.controller.getError(name as any)
3647
+ return this.controller.getError(name as string)
3413
3648
  }
3414
3649
 
3415
3650
  /**
@@ -3420,8 +3655,7 @@ class MoleculeFormInstance<T extends FormValuesConstraint<T>> {
3420
3655
  */
3421
3656
  setError(name: keyof T, error: string | undefined): void {
3422
3657
  if (error !== undefined) {
3423
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
3424
- this.controller.setError(name as any, error)
3658
+ this.controller.setError(name as string, error)
3425
3659
  } else {
3426
3660
  this.controller.clearError(name)
3427
3661
  }
@@ -4359,8 +4593,9 @@ signed out, or `'unavailable'`), and the `[slot=fallback]` content until
4359
4593
  then. It never redirects. An unavailable session is unconfirmed and may
4360
4594
  still have `user === null`; handle that status separately from sign-out.
4361
4595
 
4362
- After a full page load a returning visitor's session is restored by one
4363
- request. Until it answers, `useAuth().user` is `null` everywhere, so a
4596
+ With the bundled JWT client, a stored token and cached user restore synchronously.
4597
+ Token-only and cookie-only sessions need an asynchronous current-user request.
4598
+ Until it answers, `useAuth().user` is `null` everywhere, so a
4364
4599
  public page that renders a signed-in action at once lets that action run
4365
4600
  against "signed out": a Follow button whose handler starts with
4366
4601
  `if (!user) return` ignores the click, one that redirects to `/login` signs
@@ -4368,7 +4603,7 @@ the visitor out of the flow. Wrapping the routes (or passing `awaitSession`
4368
4603
  to `provideMolecule`) makes every page's first render read the restored user
4369
4604
  when restoration succeeds.
4370
4605
 
4371
- A visitor with no session to restore settles in microtasks without a
4606
+ A visitor with no session candidate settles synchronously without a
4372
4607
  request. Must render inside the auth registration (`provideMolecule` with
4373
4608
  `auth`). A client that nobody initialized starts its restore on this first
4374
4609
  read. The bundled JWT client bounds each auth request (default 10 seconds)
@@ -4488,12 +4723,9 @@ state, so it is not proof that an outstanding request has stopped. Use an
4488
4723
  app-owned queue when every click must be accepted in order.
4489
4724
 
4490
4725
  ```typescript
4491
- function usePromise<T extends (...args: never[]) => Promise<unknown>>(
4492
- asyncFn: T,
4493
- ): [
4494
- UsePromiseState<Awaited<ReturnType<T>>>,
4495
- (...args: Parameters<T>) => Promise<Awaited<ReturnType<T>>>,
4496
- ]
4726
+ function usePromise<V, A extends unknown[]>(
4727
+ asyncFn: (...args: A) => Promise<V>,
4728
+ ): [UsePromiseState<V>, (...args: A) => Promise<V>]
4497
4729
  ```
4498
4730
 
4499
4731
  - `asyncFn` — The async function to wrap.
@@ -4642,8 +4874,11 @@ function useAuthClient<
4642
4874
  Authentication state and actions. Call it in an injection context (a
4643
4875
  component field initializer or constructor).
4644
4876
 
4645
- `status === 'loading'` is undecided; `'unavailable'` keeps the candidate
4646
- session for retry; a restore failure never signs out.
4877
+ `status === 'loading'` is undecided: wait for it and redirect only on
4878
+ `status === 'unauthenticated'`. `'unavailable'` keeps the session candidate
4879
+ for retry, but `isAuthenticated` can be false and `user` can be null while a
4880
+ token/cookie-only restore has no cached profile. A restore failure other than
4881
+ 401/403 never signs out.
4647
4882
 
4648
4883
  The options may be a signal: `autoRefresh` turning on through it probes once
4649
4884
  (when the visitor is signed out and decided), the way React re-renders
@@ -4709,15 +4944,18 @@ function useForm<T extends FormValuesConstraint<T> = Record<string, unknown>>(
4709
4944
 
4710
4945
  Watches one field's value. Call it in an injection context.
4711
4946
 
4947
+ The controller and name may be signals, so a new controller or field is
4948
+ followed the way React re-renders `useWatch` with new arguments.
4949
+
4712
4950
  ```typescript
4713
4951
  function useWatch<T extends FormValuesConstraint<T>, K extends keyof T>(
4714
- form: FormController<T>,
4715
- name: K,
4952
+ form: MaybeSignal<FormController<T>>,
4953
+ name: MaybeSignal<K>,
4716
4954
  ): Signal<T[K]>
4717
4955
  ```
4718
4956
 
4719
- - `form` — Form controller.
4720
- - `name` — Field name to watch.
4957
+ - `form` — Form controller (or a signal of it).
4958
+ - `name` — Field name to watch (or a signal of it).
4721
4959
 
4722
4960
  **Returns:** The current field value as a signal.
4723
4961
 
@@ -4725,15 +4963,18 @@ function useWatch<T extends FormValuesConstraint<T>, K extends keyof T>(
4725
4963
 
4726
4964
  Reads one field's state. Call it in an injection context.
4727
4965
 
4966
+ The controller and name may be signals, so a new controller or field is
4967
+ followed the way React re-renders `useFieldState` with new arguments.
4968
+
4728
4969
  ```typescript
4729
4970
  function useFieldState<T extends FormValuesConstraint<T>>(
4730
- form: FormController<T>,
4731
- name: keyof T,
4971
+ form: MaybeSignal<FormController<T>>,
4972
+ name: MaybeSignal<keyof T>,
4732
4973
  ): Signal<FieldState<T[keyof T]>>
4733
4974
  ```
4734
4975
 
4735
- - `form` — Form controller.
4736
- - `name` — Field name.
4976
+ - `form` — Form controller (or a signal of it).
4977
+ - `name` — Field name (or a signal of it).
4737
4978
 
4738
4979
  **Returns:** The field state as a signal.
4739
4980
 
@@ -5374,10 +5615,10 @@ previous selected value the equality function compares survives the change,
5374
5615
  as React's ref does.
5375
5616
 
5376
5617
  ```typescript
5377
- function useStore<T, S = T>(
5618
+ function useStore<T>(
5378
5619
  store: MaybeSignal<Store<T>>,
5379
- options?: MaybeSignal<UseStoreOptions<T, S>>,
5380
- ): Signal<S>
5620
+ options?: MaybeSignal<UseStoreOptions<T, T>>,
5621
+ ): Signal<T>
5381
5622
  ```
5382
5623
 
5383
5624
  - `store` — The store to subscribe to (or a signal of it).
@@ -5919,9 +6160,9 @@ function createPlatformService(): PlatformService
5919
6160
  Creates a promise state manager for tracking async function state.
5920
6161
 
5921
6162
  ```typescript
5922
- function createPromiseState<T extends (...args: any[]) => Promise<any>>(
5923
- asyncFn: T,
5924
- ): PromiseStateManager<Awaited<ReturnType<T>>>
6163
+ function createPromiseState<Args extends unknown[], T>(
6164
+ asyncFn: (...args: Args) => Promise<T>,
6165
+ ): PromiseStateManager<T, Args>
5925
6166
  ```
5926
6167
 
5927
6168
  - `asyncFn` — The async function to track
@@ -6141,7 +6382,7 @@ Peer dependencies:
6141
6382
  - `@molecule/app-logger` ^1.0.1
6142
6383
  - `@molecule/app-platform` ^1.0.1
6143
6384
  - `@molecule/app-push` ^1.0.1
6144
- - `@molecule/app-routing` ^1.3.0
6385
+ - `@molecule/app-routing` ^1.4.0
6145
6386
  - `@molecule/app-state` ^1.2.0
6146
6387
  - `@molecule/app-storage` ^1.1.1
6147
6388
  - `@molecule/app-theme` ^1.0.1