@molecule/app-svelte 1.0.4 → 2.0.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 (2) hide show
  1. package/README.md +68 -9
  2. package/package.json +2 -2
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-23T21:29:58.335Z
6
+ Generated: 2026-10-25T19:22:15.681Z
7
7
  -->
8
8
 
9
9
  # @molecule/app-svelte
@@ -248,9 +248,12 @@ interface AuthClient<T = UserProfile, TRegister extends RegisterExtraShape<TRegi
248
248
  confirmPasswordReset(data: PasswordResetConfirm): Promise<void>;
249
249
  /**
250
250
  * Updates the current user's profile.
251
- * Returns the saved response. If the session is explicitly replaced or ended
252
- * while the request is pending, that response does not replace the current
253
- * session's user or persisted cache.
251
+ * Returns the saved profile: the answer applied onto the signed-in user field
252
+ * by field, with or without an `id` — a field it carries replaces the value
253
+ * (`null` clears it), one it omits or leaves `undefined` is kept, so a field
254
+ * cleared by omission must arrive as `null`. A non-object answer is returned
255
+ * as it came. An answer for a replaced or ended session leaves the current one
256
+ * untouched.
254
257
  */
255
258
  updateProfile(data: Partial<T>): Promise<T>;
256
259
  /**
@@ -306,9 +309,6 @@ interface AuthClient<T = UserProfile, TRegister extends RegisterExtraShape<TRegi
306
309
  * Resolves when the session restore started by `initialize()` has settled — the point
307
310
  * after which the client knows whether this visitor is signed in.
308
311
  *
309
- * Resolves IMMEDIATELY when no restore is in flight: before `initialize()` is ever
310
- * called, and after it has finished. A restore that failed resolves too (it settled the
311
- * question), so an HTTP client can await this before every request without risking one
312
312
  // … truncated — the full declaration is in node_modules/@molecule/app-svelte/dist
313
313
  ```
314
314
 
@@ -516,12 +516,50 @@ interface HttpClient {
516
516
  addErrorInterceptor(interceptor: ErrorInterceptor): () => void
517
517
  /**
518
518
  * Sets the authorization token.
519
+ *
520
+ * A static token: every request carries it until the next `setAuthToken` call. A client
521
+ * that has a {@link HttpClient.setAuthTokenResolver | resolver} (registered through
522
+ * `@molecule/app-http`'s `setAuthTokenSource`) ignores this value when it assembles a
523
+ * request — the resolver IS the session, and reading it per request is what keeps a
524
+ * session adopted without an auth event from sending the previous account's bearer. Once
525
+ * the resolver is removed, the static token is sent again.
519
526
  */
520
527
  setAuthToken(token: string | null): void
521
528
  /**
522
- * Returns the current authorization token, or `null` if not set.
529
+ * Returns the token the client applies to its next request: the resolver's answer when one
530
+ * is registered, else the static token from `setAuthToken`.
523
531
  */
524
532
  getAuthToken(): string | null
533
+ /**
534
+ * Registers the LIVE token resolver every request of this client reads, or clears it with
535
+ * `null`.
536
+ *
537
+ * `@molecule/app-http`'s `setAuthTokenSource()` calls this on every client it bonds, and the
538
+ * client MUST consult the resolver again each time it assembles a request (and report it from
539
+ * `getAuthToken()`). A session can change with no auth event and no observable state change —
540
+ * `authClient.setSession()` with the same profile data, or the OAuth callback's
541
+ * `setAccessToken()` — so a token pushed only at bond time or on `login`/`logout` events
542
+ * leaves every later request carrying the PREVIOUS session's bearer while the UI shows the
543
+ * new one.
544
+ *
545
+ * The resolved token takes the static token's place, with the same precedence: an
546
+ * `Authorization` header passed per request or in the client's default headers wins over it
547
+ * exactly where it won over a static token in this transport.
548
+ *
549
+ * A resolver that returns `null` (or `undefined`) means "this session has no body token": the
550
+ * request carries no `Authorization` header of the client's own. A cookie-session API issues
551
+ * no bearer, and the server prefers the header over the fresh cookie, so a kept bearer
552
+ * authenticates as the prior — possibly deleted — session.
553
+ *
554
+ * Optional, so an implementation written against the previous interface still conforms.
555
+ * `setAuthTokenSource()` follows such a client through a request interceptor instead, pushing
556
+ * the source with `setAuthToken` before each request: that request carries the change only
557
+ * when the transport applies its token after running its interceptors, so a transport that
558
+ * applies it earlier sends a session adopted mid-page from the following request on.
559
+ *
560
+ * @param resolver - Returns the current access token (or null/undefined), or `null` to clear.
561
+ */
562
+ setAuthTokenResolver?(resolver: AuthTokenResolver | null): void
525
563
  /**
526
564
  * Registers a handler for authentication errors (401).
527
565
  *
@@ -662,6 +700,27 @@ interface I18nProvider {
662
700
  * @returns An unsubscribe function.
663
701
  */
664
702
  onLocaleChange(listener: (locale: string) => void): () => void
703
+ /**
704
+ * Gets a counter that advances for every change `onLocaleChange` announces:
705
+ * a locale switch, a locale-list change, or translations added for a locale
706
+ * `t()` reads (the active locale and the locales it falls back to — English
707
+ * for `createSimpleI18nProvider`). It does NOT advance for a re-registration
708
+ * that leaves every rendered string identical.
709
+ *
710
+ * **Optional — read it only when present.** A consumer that observes the
711
+ * provider through `useSyncExternalStore` (the React hooks do) compares this
712
+ * value across renders, so it also sees a change that happened before its
713
+ * listener existed: a notification fired from a child's or an earlier
714
+ * sibling's layout effect, or while React kept the tree hidden with its
715
+ * effects unmounted. Providers written before this method existed keep the
716
+ * listener-only behaviour; consumers must fall back to counting
717
+ * notifications.
718
+ *
719
+ * Reads must be side-effect free, and the value must never decrease.
720
+ *
721
+ * @returns The provider's current revision.
722
+ */
723
+ getRevision?(): number
665
724
  /**
666
725
  * Gets the text direction for the current locale.
667
726
  *
@@ -2079,7 +2138,7 @@ function createVersionStores(): {
2079
2138
 
2080
2139
  Peer dependencies:
2081
2140
 
2082
- - `@molecule/app-auth` ^1.0.1
2141
+ - `@molecule/app-auth` ^3.0.0
2083
2142
  - `@molecule/app-device` ^1.0.1
2084
2143
  - `@molecule/app-forms` ^1.0.1
2085
2144
  - `@molecule/app-http` ^1.0.1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@molecule/app-svelte",
3
- "version": "1.0.4",
3
+ "version": "2.0.0",
4
4
  "description": "Svelte framework bindings for molecule.dev",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -22,7 +22,7 @@
22
22
  "node": ">=20"
23
23
  },
24
24
  "peerDependencies": {
25
- "@molecule/app-auth": "^1.0.1",
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",