@molecule/app-angular 1.0.5 → 2.0.1

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 (2) hide show
  1. package/README.md +77 -20
  2. 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-10-24T04:18:38.351Z
6
+ Generated: 2026-10-26T04:14:37.536Z
7
7
  -->
8
8
 
9
9
  # @molecule/app-angular
@@ -230,9 +230,12 @@ interface AuthClient<T = UserProfile, TRegister extends RegisterExtraShape<TRegi
230
230
  confirmPasswordReset(data: PasswordResetConfirm): Promise<void>;
231
231
  /**
232
232
  * Updates the current user's profile.
233
- * Returns the saved response. If the session is explicitly replaced or ended
234
- * while the request is pending, that response does not replace the current
235
- * session's user or persisted cache.
233
+ * Returns the saved profile: the answer applied onto the signed-in user field
234
+ * by field, with or without an `id` — a field it carries replaces the value
235
+ * (`null` clears it), one it omits or leaves `undefined` is kept, so a field
236
+ * cleared by omission must arrive as `null`. A non-object answer is returned
237
+ * as it came. An answer for a replaced or ended session leaves the current one
238
+ * untouched.
236
239
  */
237
240
  updateProfile(data: Partial<T>): Promise<T>;
238
241
  /**
@@ -288,9 +291,6 @@ interface AuthClient<T = UserProfile, TRegister extends RegisterExtraShape<TRegi
288
291
  * Resolves when the session restore started by `initialize()` has settled — the point
289
292
  * after which the client knows whether this visitor is signed in.
290
293
  *
291
- * Resolves IMMEDIATELY when no restore is in flight: before `initialize()` is ever
292
- * called, and after it has finished. A restore that failed resolves too (it settled the
293
- * question), so an HTTP client can await this before every request without risking one
294
294
  // … truncated — the full declaration is in node_modules/@molecule/app-angular/dist
295
295
  ```
296
296
 
@@ -498,12 +498,50 @@ interface HttpClient {
498
498
  addErrorInterceptor(interceptor: ErrorInterceptor): () => void
499
499
  /**
500
500
  * Sets the authorization token.
501
+ *
502
+ * A static token: every request carries it until the next `setAuthToken` call. A client
503
+ * that has a {@link HttpClient.setAuthTokenResolver | resolver} (registered through
504
+ * `@molecule/app-http`'s `setAuthTokenSource`) ignores this value when it assembles a
505
+ * request — the resolver IS the session, and reading it per request is what keeps a
506
+ * session adopted without an auth event from sending the previous account's bearer. Once
507
+ * the resolver is removed, the static token is sent again.
501
508
  */
502
509
  setAuthToken(token: string | null): void
503
510
  /**
504
- * Returns the current authorization token, or `null` if not set.
511
+ * Returns the token the client applies to its next request: the resolver's answer when one
512
+ * is registered, else the static token from `setAuthToken`.
505
513
  */
506
514
  getAuthToken(): string | null
515
+ /**
516
+ * Registers the LIVE token resolver every request of this client reads, or clears it with
517
+ * `null`.
518
+ *
519
+ * `@molecule/app-http`'s `setAuthTokenSource()` calls this on every client it bonds, and the
520
+ * client MUST consult the resolver again each time it assembles a request (and report it from
521
+ * `getAuthToken()`). A session can change with no auth event and no observable state change —
522
+ * `authClient.setSession()` with the same profile data, or the OAuth callback's
523
+ * `setAccessToken()` — so a token pushed only at bond time or on `login`/`logout` events
524
+ * leaves every later request carrying the PREVIOUS session's bearer while the UI shows the
525
+ * new one.
526
+ *
527
+ * The resolved token takes the static token's place, with the same precedence: an
528
+ * `Authorization` header passed per request or in the client's default headers wins over it
529
+ * exactly where it won over a static token in this transport.
530
+ *
531
+ * A resolver that returns `null` (or `undefined`) means "this session has no body token": the
532
+ * request carries no `Authorization` header of the client's own. A cookie-session API issues
533
+ * no bearer, and the server prefers the header over the fresh cookie, so a kept bearer
534
+ * authenticates as the prior — possibly deleted — session.
535
+ *
536
+ * Optional, so an implementation written against the previous interface still conforms.
537
+ * `setAuthTokenSource()` follows such a client through a request interceptor instead, pushing
538
+ * the source with `setAuthToken` before each request: that request carries the change only
539
+ * when the transport applies its token after running its interceptors, so a transport that
540
+ * applies it earlier sends a session adopted mid-page from the following request on.
541
+ *
542
+ * @param resolver - Returns the current access token (or null/undefined), or `null` to clear.
543
+ */
544
+ setAuthTokenResolver?(resolver: AuthTokenResolver | null): void
507
545
  /**
508
546
  * Registers a handler for authentication errors (401).
509
547
  *
@@ -644,6 +682,27 @@ interface I18nProvider {
644
682
  * @returns An unsubscribe function.
645
683
  */
646
684
  onLocaleChange(listener: (locale: string) => void): () => void
685
+ /**
686
+ * Gets a counter that advances for every change `onLocaleChange` announces:
687
+ * a locale switch, a locale-list change, or translations added for a locale
688
+ * `t()` reads (the active locale and the locales it falls back to — English
689
+ * for `createSimpleI18nProvider`). It does NOT advance for a re-registration
690
+ * that leaves every rendered string identical.
691
+ *
692
+ * **Optional — read it only when present.** A consumer that observes the
693
+ * provider through `useSyncExternalStore` (the React hooks do) compares this
694
+ * value across renders, so it also sees a change that happened before its
695
+ * listener existed: a notification fired from a child's or an earlier
696
+ * sibling's layout effect, or while React kept the tree hidden with its
697
+ * effects unmounted. Providers written before this method existed keep the
698
+ * listener-only behaviour; consumers must fall back to counting
699
+ * notifications.
700
+ *
701
+ * Reads must be side-effect free, and the value must never decrease.
702
+ *
703
+ * @returns The provider's current revision.
704
+ */
705
+ getRevision?(): number
647
706
  /**
648
707
  * Gets the text direction for the current locale.
649
708
  *
@@ -2662,7 +2721,7 @@ function provideState(provider: StateProvider): EnvironmentProviders
2662
2721
  Registers an AuthClient as an Angular environment provider for dependency injection.
2663
2722
 
2664
2723
  ```typescript
2665
- function provideAuth(client: AuthClient<T, Record<never, never>>): EnvironmentProviders
2724
+ function provideAuth<T>(client: AuthClient<T>): EnvironmentProviders
2666
2725
  ```
2667
2726
 
2668
2727
  - `client` — Auth client
@@ -2758,7 +2817,7 @@ function provideMolecule(config: MoleculeModuleConfig): EnvironmentProviders
2758
2817
  Creates an async-capable state manager.
2759
2818
 
2760
2819
  ```typescript
2761
- function createAsyncState(initialState: T): AsyncStateManager<T>
2820
+ function createAsyncState<T>(initialState: T): AsyncStateManager<T>
2762
2821
  ```
2763
2822
 
2764
2823
  - `initialState` — Initial state value
@@ -2785,9 +2844,7 @@ function createCapacitorAppState(options?: CapacitorAppOptions): CapacitorAppMan
2785
2844
  Creates a change password state manager with async state tracking.
2786
2845
 
2787
2846
  ```typescript
2788
- function createChangePasswordState(
2789
- client: AuthClient<UserProfile, Record<never, never>>,
2790
- ): ChangePasswordStateManager
2847
+ function createChangePasswordState(client: AuthClient): ChangePasswordStateManager
2791
2848
  ```
2792
2849
 
2793
2850
  - `client` — Auth client
@@ -2809,7 +2866,7 @@ function createDeviceService(): DeviceService
2809
2866
  Creates a login state manager with async state tracking.
2810
2867
 
2811
2868
  ```typescript
2812
- function createLoginState(client: AuthClient<T, Record<never, never>>): LoginStateManager<T>
2869
+ function createLoginState<T = unknown>(client: AuthClient<T>): LoginStateManager<T>
2813
2870
  ```
2814
2871
 
2815
2872
  - `client` — Auth client
@@ -2837,9 +2894,7 @@ function createOAuthState(options?: OAuthOptions): OAuthStateManager
2837
2894
  Creates a password reset state manager with async state tracking.
2838
2895
 
2839
2896
  ```typescript
2840
- function createPasswordResetState(
2841
- client: AuthClient<UserProfile, Record<never, never>>,
2842
- ): PasswordResetStateManager
2897
+ function createPasswordResetState(client: AuthClient): PasswordResetStateManager
2843
2898
  ```
2844
2899
 
2845
2900
  - `client` — Auth client
@@ -2861,7 +2916,9 @@ function createPlatformService(): PlatformService
2861
2916
  Creates a promise state manager for tracking async function state.
2862
2917
 
2863
2918
  ```typescript
2864
- function createPromiseState(asyncFn: T): PromiseStateManager<Awaited<ReturnType<T>>>
2919
+ function createPromiseState<T extends (...args: any[]) => Promise<any>>(
2920
+ asyncFn: T,
2921
+ ): PromiseStateManager<Awaited<ReturnType<T>>>
2865
2922
  ```
2866
2923
 
2867
2924
  - `asyncFn` — The async function to track
@@ -2883,7 +2940,7 @@ function createPushService(): PushService
2883
2940
  Creates a signup state manager with async state tracking.
2884
2941
 
2885
2942
  ```typescript
2886
- function createSignupState(client: AuthClient<T, Record<never, never>>): SignupStateManager<T>
2943
+ function createSignupState<T = unknown>(client: AuthClient<T>): SignupStateManager<T>
2887
2944
  ```
2888
2945
 
2889
2946
  - `client` — Auth client
@@ -2973,7 +3030,7 @@ const LOGGER_PROVIDER: InjectionToken<LoggerProvider>
2973
3030
  Peer dependencies:
2974
3031
 
2975
3032
  - `@angular/core` 22.0.0
2976
- - `@molecule/app-auth` ^1.0.1 || ^2.0.0
3033
+ - `@molecule/app-auth` ^3.0.0
2977
3034
  - `@molecule/app-device` ^1.0.1
2978
3035
  - `@molecule/app-forms` ^1.0.1
2979
3036
  - `@molecule/app-http` ^1.0.1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@molecule/app-angular",
3
- "version": "1.0.5",
3
+ "version": "2.0.1",
4
4
  "description": "Angular framework bindings for molecule.dev",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -22,7 +22,7 @@
22
22
  },
23
23
  "peerDependencies": {
24
24
  "@angular/core": "22.0.0",
25
- "@molecule/app-auth": "^1.0.1 || ^2.0.0",
25
+ "@molecule/app-auth": "^3.0.0",
26
26
  "@molecule/app-device": "^1.0.1",
27
27
  "@molecule/app-forms": "^1.0.1",
28
28
  "@molecule/app-http": "^1.0.1",
@@ -43,7 +43,7 @@
43
43
  "@angular/compiler": "22.2.3",
44
44
  "@angular/compiler-cli": "22.2.3",
45
45
  "@angular/core": "22.2.3",
46
- "@molecule/app-utilities": "1.0.5",
46
+ "@molecule/app-utilities": "1.0.6",
47
47
  "@types/node": "26.6.5",
48
48
  "rxjs": "7.8.2",
49
49
  "typescript": "6.0.3",