@molecule/app-svelte 3.5.1 → 3.7.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 (62) hide show
  1. package/README.md +287 -76
  2. package/dist/hooks/index.d.ts +2 -0
  3. package/dist/hooks/index.d.ts.map +1 -1
  4. package/dist/hooks/index.js +2 -0
  5. package/dist/hooks/live-store.d.ts +0 -8
  6. package/dist/hooks/live-store.d.ts.map +1 -1
  7. package/dist/hooks/live-store.js +0 -13
  8. package/dist/hooks/maybe-readable.d.ts +36 -0
  9. package/dist/hooks/maybe-readable.d.ts.map +1 -0
  10. package/dist/hooks/maybe-readable.js +36 -0
  11. package/dist/hooks/useAIModels.d.ts +8 -2
  12. package/dist/hooks/useAIModels.d.ts.map +1 -1
  13. package/dist/hooks/useAIModels.js +44 -17
  14. package/dist/hooks/useAuth.d.ts +10 -4
  15. package/dist/hooks/useAuth.d.ts.map +1 -1
  16. package/dist/hooks/useAuth.js +39 -13
  17. package/dist/hooks/useForm.d.ts +13 -5
  18. package/dist/hooks/useForm.d.ts.map +1 -1
  19. package/dist/hooks/useForm.js +90 -58
  20. package/dist/hooks/useHttp.d.ts +28 -22
  21. package/dist/hooks/useHttp.d.ts.map +1 -1
  22. package/dist/hooks/useHttp.js +67 -96
  23. package/dist/hooks/useOAuth.d.ts +23 -7
  24. package/dist/hooks/useOAuth.d.ts.map +1 -1
  25. package/dist/hooks/useOAuth.js +51 -18
  26. package/dist/hooks/useOptimisticToggle.d.ts +67 -0
  27. package/dist/hooks/useOptimisticToggle.d.ts.map +1 -0
  28. package/dist/hooks/useOptimisticToggle.js +52 -0
  29. package/dist/hooks/useOptimisticValue.d.ts +11 -4
  30. package/dist/hooks/useOptimisticValue.d.ts.map +1 -1
  31. package/dist/hooks/useOptimisticValue.js +40 -49
  32. package/dist/hooks/usePush.d.ts +7 -3
  33. package/dist/hooks/usePush.d.ts.map +1 -1
  34. package/dist/hooks/usePush.js +26 -6
  35. package/dist/hooks/useRouter.d.ts +13 -7
  36. package/dist/hooks/useRouter.d.ts.map +1 -1
  37. package/dist/hooks/useRouter.js +39 -18
  38. package/dist/hooks/useStorage.d.ts +22 -9
  39. package/dist/hooks/useStorage.d.ts.map +1 -1
  40. package/dist/hooks/useStorage.js +146 -69
  41. package/dist/hooks/useStore.d.ts +14 -7
  42. package/dist/hooks/useStore.d.ts.map +1 -1
  43. package/dist/hooks/useStore.js +46 -9
  44. package/dist/hooks/useTranslation.d.ts +6 -2
  45. package/dist/hooks/useTranslation.d.ts.map +1 -1
  46. package/dist/hooks/useTranslation.js +11 -6
  47. package/dist/index.d.ts +4 -0
  48. package/dist/index.d.ts.map +1 -1
  49. package/dist/index.js +4 -0
  50. package/dist/link/Link.svelte +33 -0
  51. package/dist/link/Link.svelte.d.ts +12 -0
  52. package/dist/link/Link.svelte.d.ts.map +1 -0
  53. package/dist/link/index.d.ts +23 -0
  54. package/dist/link/index.d.ts.map +1 -0
  55. package/dist/link/index.js +22 -0
  56. package/dist/link/types.d.ts +26 -0
  57. package/dist/link/types.d.ts.map +1 -0
  58. package/dist/link/types.js +6 -0
  59. package/dist/stores/chat.d.ts +4 -3
  60. package/dist/stores/chat.d.ts.map +1 -1
  61. package/dist/stores/chat.js +14 -15
  62. package/package.json +5 -5
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-14T12:22:38.195Z
6
+ Generated: 2026-11-16T14:06:38.893Z
7
7
  -->
8
8
 
9
9
  # @molecule/app-svelte
@@ -343,9 +343,10 @@ interface FormController<T extends FormValuesConstraint<T> = Record<string, unkn
343
343
  * record, never a merge of earlier records. With `keepDirtyValues`, edited
344
344
  * fields retain their values while pristine fields take the loaded values.
345
345
  * A changed non-null `id` still replaces the record and cancels a pending
346
- * submit. Equal-content baselines cause no update.
346
+ * submit. Equal-content baselines cause no update. `keepOmittedValues` opts
347
+ * into incremental top-level field fills using the current clean baseline.
347
348
  */
348
- updateValues(values: Partial<T>, resetOptions?: FormResetOptions): void
349
+ updateValues(values: Partial<T>, resetOptions?: FormUpdateOptions): void
349
350
 
350
351
  /**
351
352
  * Handles form submission.
@@ -1245,7 +1246,10 @@ Options for {@link useAuth}.
1245
1246
 
1246
1247
  ```typescript
1247
1248
  interface UseAuthOptions {
1248
- /** Whether to automatically refresh the token on mount. */
1249
+ /**
1250
+ * Whether to automatically refresh the session on mount, and again whenever
1251
+ * the flag turns on or the session decision changes while it is on.
1252
+ */
1249
1253
  autoRefresh?: boolean
1250
1254
  }
1251
1255
  ```
@@ -1441,7 +1445,7 @@ interface UseFormResult<T extends FormValuesConstraint<T>> {
1441
1445
  /** Restores the baseline (optionally a new one) and clears touched, errors and submit state. */
1442
1446
  reset: (values?: Partial<T>) => void
1443
1447
  /** Applies externally loaded values without clearing submission state. */
1444
- updateValues: (values: Partial<T>, resetOptions?: FormResetOptions) => void
1448
+ updateValues: (values: Partial<T>, resetOptions?: FormUpdateOptions) => void
1445
1449
  /** Whole-form state tuple: edits mark only changed fields dirty; fills preserve them. */
1446
1450
  asState(): readonly [
1447
1451
  T,
@@ -1547,8 +1551,14 @@ Return type for useOAuth hook.
1547
1551
 
1548
1552
  ```typescript
1549
1553
  interface UseOAuthReturn {
1550
- /** The configured provider names. */
1551
- providers: string[]
1554
+ /**
1555
+ * The configured provider names (React's `string[]`), read live: each read
1556
+ * returns the list the current config holds, and a read in markup or
1557
+ * `$derived` re-runs when a config store changes. Read it off the result
1558
+ * (`oauth.providers`); a destructured copy keeps the list of the moment it
1559
+ * was taken.
1560
+ */
1561
+ readonly providers: string[]
1552
1562
  /** Builds the provider's initiation URL (provider encoded as one path segment). */
1553
1563
  getOAuthUrl: (provider: string) => string
1554
1564
  /** Full-page redirect to the provider (default). The opener page navigates away. */
@@ -1591,6 +1601,39 @@ interface UseOAuthConfig {
1591
1601
  }
1592
1602
  ```
1593
1603
 
1604
+ #### `UseOptimisticToggleOptions`
1605
+
1606
+ Options for {@link useOptimisticToggle}.
1607
+
1608
+ ```typescript
1609
+ interface UseOptimisticToggleOptions {
1610
+ /** The loaded server value. Mount the control only after its record exists. */
1611
+ value: boolean
1612
+ /** Saves the DESIRED value and returns the server-confirmed value; reject on failure. */
1613
+ commit: (desired: boolean) => Promise<boolean>
1614
+ /** Receives the newest failed save and the confirmed value restored by the controller. */
1615
+ onError?: (error: unknown, value: boolean) => void
1616
+ }
1617
+ ```
1618
+
1619
+ #### `UseOptimisticToggleResult`
1620
+
1621
+ What {@link useOptimisticToggle} returns: the boolean to render as readable stores and
1622
+ an argument-free action (the same names React returns).
1623
+
1624
+ ```typescript
1625
+ interface UseOptimisticToggleResult {
1626
+ /** The value to render. */
1627
+ value: Readable<boolean>
1628
+ /** Whether a save is running or waiting. */
1629
+ pending: Readable<boolean>
1630
+ /** The failure of the newest change. */
1631
+ error: Readable<unknown>
1632
+ /** Flips the value shown now and saves it; the same function for the component's life. */
1633
+ toggle: () => void
1634
+ }
1635
+ ```
1636
+
1594
1637
  #### `UseOptimisticValueResult`
1595
1638
 
1596
1639
  What {@link useOptimisticValue} returns: the state to render as readable
@@ -1816,7 +1859,8 @@ Options for the usePush hook (e.g. check permission on mount).
1816
1859
  ```typescript
1817
1860
  interface UsePushOptions {
1818
1861
  /**
1819
- * Whether to check permission status on mount.
1862
+ * Whether to check permission status on mount, and again when the flag turns
1863
+ * on later on the same component.
1820
1864
  */
1821
1865
  checkOnMount?: boolean
1822
1866
  }
@@ -2153,6 +2197,28 @@ interface UseWorkspaceResult {
2153
2197
  }
2154
2198
  ```
2155
2199
 
2200
+ #### `LinkProps`
2201
+
2202
+ Props for `Link`. Every other anchor attribute (`class`, `target`, `rel`,
2203
+ `aria-*`, `data-*`, `onclick`) goes on the anchor.
2204
+
2205
+ ```typescript
2206
+ interface LinkProps extends Omit<HTMLAnchorAttributes, 'href' | 'children'> {
2207
+ /** Destination: an app path (`/settings?tab=billing#plan`) or a URL. Rendered as the anchor's `href`. */
2208
+ to: string
2209
+ /**
2210
+ * Replace the current history entry instead of pushing one. When omitted, a
2211
+ * link to the location already shown replaces it and any other link pushes,
2212
+ * as with react-router's `<Link>`.
2213
+ */
2214
+ replace?: boolean
2215
+ /** State stored with the new history entry (read back with `useLocation()`). */
2216
+ state?: unknown
2217
+ /** The link's content. */
2218
+ children?: Snippet
2219
+ }
2220
+ ```
2221
+
2156
2222
  #### `AsyncStateStore`
2157
2223
 
2158
2224
  Async state store.
@@ -2342,6 +2408,16 @@ shared packages fall back to {@link DEFAULT_AGENT_IDENTITY} when it does not.
2342
2408
  type AgentIdentity = ChatAgentIdentity
2343
2409
  ```
2344
2410
 
2411
+ #### `MaybeReadable`
2412
+
2413
+ A plain value or a readable store of one (a store of `undefined` stands for
2414
+ an omitted argument). Hooks read the current value when they use it and
2415
+ follow changes for as long as the component lives.
2416
+
2417
+ ```typescript
2418
+ type MaybeReadable<T> = T | Readable<T>
2419
+ ```
2420
+
2345
2421
  #### `AsyncSetState`
2346
2422
 
2347
2423
  Async-capable setState function.
@@ -2861,6 +2937,33 @@ function useStateProvider(): StateProvider
2861
2937
 
2862
2938
  **Returns:** The state provider instance.
2863
2939
 
2940
+ #### `isReadable(value)`
2941
+
2942
+ Whether a value is a readable store. A molecule store (`@molecule/app-state`'s
2943
+ `Store`: it has `getState` AND `subscribe`) is a VALUE, never a source —
2944
+ `useStore` takes the store itself as its argument.
2945
+
2946
+ ```typescript
2947
+ function isReadable(value: unknown): value is Readable<unknown>
2948
+ ```
2949
+
2950
+ - `value` — A hook argument: a plain value or a store.
2951
+
2952
+ **Returns:** True for a Svelte readable store.
2953
+
2954
+ #### `toReadable(value)`
2955
+
2956
+ The readable-store view of a hook argument: the store itself when it is one,
2957
+ a constant store of the plain value otherwise.
2958
+
2959
+ ```typescript
2960
+ function toReadable<T>(value: MaybeReadable<T>): Readable<T>
2961
+ ```
2962
+
2963
+ - `value` — A plain value or a store of one.
2964
+
2965
+ **Returns:** A readable store of the value.
2966
+
2864
2967
  #### `resetAIModelsCache()`
2865
2968
 
2866
2969
  Test-only: drops every cached model list so the next `useAIModels` call
@@ -2878,11 +2981,16 @@ The first mount of a scope triggers a single `GET /ai/models` fetch;
2878
2981
  subsequent mounts return the cached result, and a scope whose fetch failed
2879
2982
  does not refetch on a later mount.
2880
2983
 
2984
+ The project id may be a plain value or a readable store of one (a store
2985
+ holding `undefined` means the unscoped catalog): setting it resubscribes to
2986
+ the new scope's cache and fetches it if nobody has yet, on the same
2987
+ component, the way React's re-render does.
2988
+
2881
2989
  ```typescript
2882
- function useAIModels(projectId?: string): UseAIModelsResult
2990
+ function useAIModels(projectId?: MaybeReadable<string | undefined>): UseAIModelsResult
2883
2991
  ```
2884
2992
 
2885
- - `projectId` — Optional project scope: includes that project's custom ("bring your own AI") models on servers that support them.
2993
+ - `projectId` — Optional project scope: includes that project's custom ("bring your own AI") models on servers that support them (or a store of it).
2886
2994
 
2887
2995
  **Returns:** Models, free-tier model, loading flag, and error, as stores.
2888
2996
 
@@ -2921,10 +3029,10 @@ a sign-in the app itself runs, call `setSession({ accessToken, user })`.
2921
3029
  function useAuth<
2922
3030
  T = unknown,
2923
3031
  TRegister extends RegisterExtraShape<TRegister> = Record<never, never>,
2924
- >(options?: UseAuthOptions): UseAuthResult<T, TRegister>
3032
+ >(options?: MaybeReadable<UseAuthOptions | undefined>): UseAuthResult<T, TRegister>
2925
3033
  ```
2926
3034
 
2927
- - `options` — Hook options (`autoRefresh`).
3035
+ - `options` — Hook options (`autoRefresh`), or a store of them: setting `autoRefresh` later probes on the same component, the way React's re-render re-runs its effect.
2928
3036
 
2929
3037
  **Returns:** Auth state as stores and the actions as functions.
2930
3038
 
@@ -3033,13 +3141,20 @@ picks it up. Passing `createForm` overrides that for one form. When the
3033
3141
  take the loaded values. A changed `resetKey` starts a fresh form; fresh
3034
3142
  `defaultValues` without one leave the drafts alone.
3035
3143
 
3144
+ The options may be a plain value or a readable store of one (a store holding
3145
+ `undefined` means the options were omitted): setting the store re-runs the
3146
+ work React's re-render does, on the same controller — a changed `values`
3147
+ object is applied (dirty fields kept by default) and a changed `resetKey`
3148
+ replaces the controller with a fresh one. Edits, touched fields and pending
3149
+ submits survive every other change.
3150
+
3036
3151
  ```typescript
3037
3152
  function useForm<T extends FormValuesConstraint<T> = Record<string, unknown>>(
3038
- options?: UseFormOptions<T>,
3153
+ options?: MaybeReadable<UseFormOptions<T> | undefined>,
3039
3154
  ): UseFormResult<T>
3040
3155
  ```
3041
3156
 
3042
- - `options` — Form options. `defaultValues`, `mode` and the form-level `validate` are forwarded to the provider.
3157
+ - `options` — Form options (or a store of them). `defaultValues`, `mode` and the form-level `validate` are forwarded to the provider.
3043
3158
 
3044
3159
  **Returns:** Form state stores and methods
3045
3160
 
@@ -3082,25 +3197,30 @@ function useFieldState<T extends FormValuesConstraint<T>>(
3082
3197
  HTTP requests with state management, React's `useHttp` in Svelte's idiom:
3083
3198
  call it during component init under `setMoleculeContext({ http })`.
3084
3199
 
3200
+ Every argument may be a plain value or a readable store of one (a store
3201
+ holding `undefined` means the argument was omitted): `method`, `url` and the
3202
+ request options are read at the moment `execute` runs, so setting the `url`
3203
+ store retargets the next `execute` on the same component, the way React's
3204
+ re-render does. `immediate` is read on mount only — its request runs once per
3205
+ component even when the arguments change later.
3206
+
3085
3207
  The newest request owns the displayed state: an older response answering
3086
3208
  after a newer `execute` or `reset` cannot touch it (callbacks still report
3087
3209
  every request's own outcome). A failure resolves `null` — it never rejects
3088
3210
  to the caller. `reset` takes ownership too, so a request it superseded
3089
- cannot repopulate the state. `execute` keeps one identity per mount, and its
3090
- options are read at call time. `immediate` runs its request once per host,
3091
- on mount only, even when the host re-mounts the hook with new arguments.
3211
+ cannot repopulate the state.
3092
3212
 
3093
3213
  ```typescript
3094
3214
  function useHttp<T>(
3095
- method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE',
3096
- url: string,
3097
- options?: UseHttpOptions<T>,
3215
+ method: MaybeReadable<'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE'>,
3216
+ url: MaybeReadable<string>,
3217
+ options?: MaybeReadable<UseHttpOptions<T> | undefined>,
3098
3218
  ): UseHttpResult<T>
3099
3219
  ```
3100
3220
 
3101
- - `method` — HTTP method.
3102
- - `url` — Request URL.
3103
- - `options` — Request options, read at call time.
3221
+ - `method` — HTTP method (or a store of it).
3222
+ - `url` — Request URL (or a store of it).
3223
+ - `options` — Request options, read at call time (or a store of them).
3104
3224
 
3105
3225
  **Returns:** Request state as stores and the controls.
3106
3226
 
@@ -3109,11 +3229,14 @@ function useHttp<T>(
3109
3229
  GET requests, React's `useGet` in Svelte's idiom.
3110
3230
 
3111
3231
  ```typescript
3112
- function useGet<T>(url: string, options?: UseHttpOptions<T>): UseHttpResult<T>
3232
+ function useGet<T>(
3233
+ url: MaybeReadable<string>,
3234
+ options?: MaybeReadable<UseHttpOptions<T> | undefined>,
3235
+ ): UseHttpResult<T>
3113
3236
  ```
3114
3237
 
3115
- - `url` — Request URL to fetch from.
3116
- - `options` — HTTP request options including callbacks and request config.
3238
+ - `url` — Request URL to fetch from (or a store of it).
3239
+ - `options` — HTTP request options including callbacks and request config (or a store of them).
3117
3240
 
3118
3241
  **Returns:** Request state as stores and the controls.
3119
3242
 
@@ -3122,11 +3245,14 @@ function useGet<T>(url: string, options?: UseHttpOptions<T>): UseHttpResult<T>
3122
3245
  POST requests, React's `usePost` in Svelte's idiom.
3123
3246
 
3124
3247
  ```typescript
3125
- function usePost<T>(url: string, options?: UseHttpOptions<T>): UseHttpResult<T>
3248
+ function usePost<T>(
3249
+ url: MaybeReadable<string>,
3250
+ options?: MaybeReadable<UseHttpOptions<T> | undefined>,
3251
+ ): UseHttpResult<T>
3126
3252
  ```
3127
3253
 
3128
- - `url` — Request URL to post to.
3129
- - `options` — HTTP request options including body data and callbacks.
3254
+ - `url` — Request URL to post to (or a store of it).
3255
+ - `options` — HTTP request options including body data and callbacks (or a store of them).
3130
3256
 
3131
3257
  **Returns:** Request state as stores and the controls.
3132
3258
 
@@ -3135,11 +3261,14 @@ function usePost<T>(url: string, options?: UseHttpOptions<T>): UseHttpResult<T>
3135
3261
  PUT requests, React's `usePut` in Svelte's idiom.
3136
3262
 
3137
3263
  ```typescript
3138
- function usePut<T>(url: string, options?: UseHttpOptions<T>): UseHttpResult<T>
3264
+ function usePut<T>(
3265
+ url: MaybeReadable<string>,
3266
+ options?: MaybeReadable<UseHttpOptions<T> | undefined>,
3267
+ ): UseHttpResult<T>
3139
3268
  ```
3140
3269
 
3141
- - `url` — Request URL to send the PUT request to.
3142
- - `options` — HTTP request options including body data and callbacks.
3270
+ - `url` — Request URL to send the PUT request to (or a store of it).
3271
+ - `options` — HTTP request options including the replacement body (or a store of them).
3143
3272
 
3144
3273
  **Returns:** Request state as stores and the controls.
3145
3274
 
@@ -3148,11 +3277,14 @@ function usePut<T>(url: string, options?: UseHttpOptions<T>): UseHttpResult<T>
3148
3277
  PATCH requests, React's `usePatch` in Svelte's idiom.
3149
3278
 
3150
3279
  ```typescript
3151
- function usePatch<T>(url: string, options?: UseHttpOptions<T>): UseHttpResult<T>
3280
+ function usePatch<T>(
3281
+ url: MaybeReadable<string>,
3282
+ options?: MaybeReadable<UseHttpOptions<T> | undefined>,
3283
+ ): UseHttpResult<T>
3152
3284
  ```
3153
3285
 
3154
- - `url` — Request URL to send the PATCH request to.
3155
- - `options` — HTTP request options including partial body data and callbacks.
3286
+ - `url` — Request URL to send the partial body to (or a store of it).
3287
+ - `options` — HTTP request options including the partial body (or a store of them).
3156
3288
 
3157
3289
  **Returns:** Request state as stores and the controls.
3158
3290
 
@@ -3161,11 +3293,14 @@ function usePatch<T>(url: string, options?: UseHttpOptions<T>): UseHttpResult<T>
3161
3293
  DELETE requests, React's `useDelete` in Svelte's idiom.
3162
3294
 
3163
3295
  ```typescript
3164
- function useDelete<T>(url: string, options?: UseHttpOptions<T>): UseHttpResult<T>
3296
+ function useDelete<T>(
3297
+ url: MaybeReadable<string>,
3298
+ options?: MaybeReadable<UseHttpOptions<T> | undefined>,
3299
+ ): UseHttpResult<T>
3165
3300
  ```
3166
3301
 
3167
- - `url` — Request URL of the resource to delete.
3168
- - `options` — HTTP request options including callbacks.
3302
+ - `url` — Request URL of the resource to delete (or a store of it).
3303
+ - `options` — HTTP request options including callbacks (or a store of them).
3169
3304
 
3170
3305
  **Returns:** Request state as stores and the controls.
3171
3306
 
@@ -3237,14 +3372,46 @@ configuration and provides helpers to build OAuth URLs and start a login
3237
3372
  when the callback is running inside a popup we opened, relaying the result
3238
3373
  to the opener instead.
3239
3374
 
3375
+ The config may be a plain value or a readable store of one (a store holding
3376
+ `undefined` means no config): every field — the provider list, the URL
3377
+ pieces, the callbacks, the `navigate` option — is read at the moment it is
3378
+ used, so setting the store retargets the next `getOAuthUrl`/`redirect`/popup
3379
+ flow on the same component, the way React's re-render does. `providers` is
3380
+ React's `string[]`, read live (see {@link UseOAuthReturn.providers}). The
3381
+ callback exchange, when it finds a `code` in the URL, runs once with the
3382
+ config the hook was called with.
3383
+
3240
3384
  ```typescript
3241
- function useOAuth(config?: UseOAuthConfig): UseOAuthReturn
3385
+ function useOAuth(config?: MaybeReadable<UseOAuthConfig | undefined>): UseOAuthReturn
3242
3386
  ```
3243
3387
 
3244
- - `config` — Optional OAuth configuration override.
3388
+ - `config` — Optional OAuth configuration override (or a store of it).
3245
3389
 
3246
3390
  **Returns:** OAuth helpers: providers, getOAuthUrl, redirect, and loginViaPopup.
3247
3391
 
3392
+ #### `useOptimisticToggle(options)`
3393
+
3394
+ Owns the state and save ordering of a follow, favorite, star or subscription control
3395
+ while all markup stays in the app. Pass `toggle` straight to the click handler: it takes
3396
+ no argument and flips the value shown now. `commit(desired)` receives the value to SAVE,
3397
+ never the old one, and returns the server's boolean answer. Only the newest failure
3398
+ rolls the shown value back.
3399
+
3400
+ Saves run one at a time; clicks during a save coalesce to the newest desired value. Use
3401
+ `pending` for feedback, not to disable the control or drop a click. Mount it only after
3402
+ the record loads, key it by record identity, and keep it mounted through refetches. For
3403
+ a flag with a related count, use `useOptimisticValue` with both fields in one value.
3404
+
3405
+ ```typescript
3406
+ function useOptimisticToggle(
3407
+ options: MaybeReadable<UseOptimisticToggleOptions>,
3408
+ ): UseOptimisticToggleResult
3409
+ ```
3410
+
3411
+ - `options` — The server value, the save and an optional error callback (or a readable store of them: a new `value` syncs in while nothing is saving).
3412
+
3413
+ **Returns:** The value, pending and error state as readable stores, and the stable `toggle`.
3414
+
3248
3415
  #### `useOptimisticValue(options)`
3249
3416
 
3250
3417
  A server-backed value — a favorite, follow, like or bookmark button, a
@@ -3260,11 +3427,18 @@ record's pending change never shows on another. Keep related fields, such as
3260
3427
  a favorite flag and its count, in the SAME value. Let commit reject on
3261
3428
  failure: a catch that returns old data hides the failure.
3262
3429
 
3430
+ The options may be a plain value or a readable store of one: setting the
3431
+ store applies the new server value (and the new `commit`, `equals` and
3432
+ `onError`) on the same component, the way React's re-render does — the
3433
+ controller, and any save it is running, survive the change.
3434
+
3263
3435
  ```typescript
3264
- function useOptimisticValue<T>(options: OptimisticValueOptions<T>): UseOptimisticValueResult<T>
3436
+ function useOptimisticValue<T>(
3437
+ options: MaybeReadable<OptimisticValueOptions<T>>,
3438
+ ): UseOptimisticValueResult<T>
3265
3439
  ```
3266
3440
 
3267
- - `options` — The server's current value and how to save a change.
3441
+ - `options` — The server's current value and how to save a change (or a store of them).
3268
3442
 
3269
3443
  **Returns:** The value to render, whether a save is pending, the newest failure, and `set`/`update`.
3270
3444
 
@@ -3379,10 +3553,10 @@ context-provided. The provider's listeners are caller-managed: the returned
3379
3553
  `on*` unsubscribes are the caller's to call, like React's.
3380
3554
 
3381
3555
  ```typescript
3382
- function usePush(options?: UsePushOptions): UsePushResult
3556
+ function usePush(options?: MaybeReadable<UsePushOptions | undefined>): UsePushResult
3383
3557
  ```
3384
3558
 
3385
- - `options` — Hook options
3559
+ - `options` — Hook options (or a store of them): setting `checkOnMount` later runs its check on the same component, the way React's re-render re-runs its effect.
3386
3560
 
3387
3561
  **Returns:** Push notification state and action methods
3388
3562
 
@@ -3446,12 +3620,16 @@ function useNavigate(): (path: string, options?: NavigateOptions) => void
3446
3620
  Whether a path is active, React's `useIsActive` in Svelte's idiom: a
3447
3621
  readable store that re-evaluates on every route change.
3448
3622
 
3623
+ Both arguments may be a plain value or a readable store of one: the store
3624
+ re-evaluates when one changes (the way React's re-render re-reads its
3625
+ snapshot), so a navigation-driven nav link can take its path from a store.
3626
+
3449
3627
  ```typescript
3450
- function useIsActive(path: string, exact?: boolean): Readable<boolean>
3628
+ function useIsActive(path: MaybeReadable<string>, exact?: MaybeReadable<boolean>): Readable<boolean>
3451
3629
  ```
3452
3630
 
3453
- - `path` — The path to check.
3454
- - `exact` — Whether to match exactly (default: false).
3631
+ - `path` — The path to check (or a store of it).
3632
+ - `exact` — Whether to match exactly (default: false; or a store of it).
3455
3633
 
3456
3634
  **Returns:** A readable store of whether the path is active.
3457
3635
 
@@ -3469,13 +3647,14 @@ A signed-out visit to a view with `requiresAuth` replaces the entry with
3469
3647
  `options.auth.redirectTo`, carrying `state.returnTo`; until auth is confirmed
3470
3648
  `canLoad` is `false`.
3471
3649
 
3472
- The options may be a readable store: an auth status moving from `loading` to
3473
- `unauthenticated` re-resolves the list — and performs the sign-in redirect —
3474
- on the same component, the way React re-renders `useListRoute`.
3650
+ The options may be a plain value or a readable store of one (a store holding
3651
+ `undefined` means the default options): an auth status moving from `loading`
3652
+ to `unauthenticated` re-resolves the list — and performs the sign-in
3653
+ redirect — on the same component, the way React re-renders `useListRoute`.
3475
3654
 
3476
3655
  ```typescript
3477
3656
  function useListRoute<Filter extends string = string, Selection extends string = string>(
3478
- options?: ListRouteOptions<Filter, Selection> | Readable<ListRouteOptions<Filter, Selection>>,
3657
+ options?: MaybeReadable<ListRouteOptions<Filter, Selection> | undefined>,
3479
3658
  ): UseListRouteResult<Filter, Selection>
3480
3659
  ```
3481
3660
 
@@ -3525,6 +3704,13 @@ function useSignup<
3525
3704
  One storage key as Svelte stores, React's `useStorageValue` in Svelte's
3526
3705
  idiom: call it during component init under `setMoleculeContext({ storage })`.
3527
3706
 
3707
+ Both arguments may be a plain value or a readable store of one (a store
3708
+ holding `undefined` means the argument was omitted): setting the `key` store
3709
+ starts the new key over — its value is unknown until its read lands, so the
3710
+ default shows and `loading` is true, exactly as a fresh mount — while writes
3711
+ go to the key the hook holds at the moment they run. The latest
3712
+ `defaultValue` and `sync` always apply.
3713
+
3528
3714
  A read that started before a newer local write keeps that write's value (it
3529
3715
  still ends `loading`), and with `sync` an outside write reaches the hook
3530
3716
  through the provider's own subscription — so a non-browser backend
@@ -3533,13 +3719,13 @@ through the provider's own subscription — so a non-browser backend
3533
3719
 
3534
3720
  ```typescript
3535
3721
  function useStorageValue<T>(
3536
- key: string,
3537
- options?: UseStorageValueOptions<T>,
3722
+ key: MaybeReadable<string>,
3723
+ options?: MaybeReadable<UseStorageValueOptions<T> | undefined>,
3538
3724
  ): UseStorageValueResult<T>
3539
3725
  ```
3540
3726
 
3541
- - `key` — Storage key
3542
- - `options` — Hook options
3727
+ - `key` — Storage key (or a store of it).
3728
+ - `options` — Hook options (or a store of them).
3543
3729
 
3544
3730
  **Returns:** Storage value state (value, loading, error) and mutators (setValue, removeValue).
3545
3731
 
@@ -3555,19 +3741,22 @@ same component without a remount. Ordering is the store's: a read that
3555
3741
  started before a newer write, remove or external change is discarded, so a
3556
3742
  slow hydration never overwrites an edit the user already made.
3557
3743
 
3558
- Pass `null` for `key` while the real key is unknown (no project selected
3559
- yet): the hook then behaves as local state around `defaultValue` and
3560
- persists nothing.
3744
+ Both arguments may be a plain value or a readable store of one (a store
3745
+ holding `undefined` means the argument was omitted): setting the `key` store
3746
+ re-reads, re-subscribes and re-hydrates the new key on the same component
3747
+ (a `null`/`undefined` key is local state around the default and persists
3748
+ nothing), and writes go to the key the hook holds at the moment they run.
3749
+ The latest `defaultValue` always applies.
3561
3750
 
3562
3751
  ```typescript
3563
3752
  function useStoragePreference<T = unknown>(
3564
- key: string | null | undefined,
3565
- options?: UseStoragePreferenceOptions<T>,
3753
+ key: MaybeReadable<string | null | undefined>,
3754
+ options?: MaybeReadable<UseStoragePreferenceOptions<T> | undefined>,
3566
3755
  ): UseStoragePreferenceResult<T>
3567
3756
  ```
3568
3757
 
3569
- - `key` — The storage key, or `null` when there is nothing to persist.
3570
- - `options` — `defaultValue`, reported until the provider supplies one.
3758
+ - `key` — The storage key, or `null` when there is nothing to persist (or a store of either).
3759
+ - `options` — `defaultValue`, reported until the provider supplies one (or a store of them).
3571
3760
 
3572
3761
  **Returns:** The current value, its mutators, and whether it is definite yet.
3573
3762
 
@@ -3593,21 +3782,30 @@ function useStorage(): {
3593
3782
  Subscribes a store with an optional selector and equality function, React's
3594
3783
  `useStore` in Svelte's idiom: a readable store of the selected value.
3595
3784
 
3785
+ The store argument may be the store itself (a molecule store has `getState`
3786
+ AND `subscribe`, and is always a VALUE, never a source) or a readable store
3787
+ OF a store: setting it re-subscribes to the new store and re-reads its
3788
+ snapshot on the same component, the way React's re-render does. The options
3789
+ (or a store of them) are read whenever the snapshot is.
3790
+
3596
3791
  The store is the argument, so this hook needs NO state provider: it reads
3597
- `store.getState()` and subscribes with `store.subscribe()`. When
3598
- `equalityFn` says a new selected value equals the previous one, the previous
3599
- result is kept (the same value, not a fresh object).
3792
+ `store.getState()` and subscribes with `store.subscribe()`. When `equalityFn`
3793
+ says a new selected value equals the previous one, the previous result is
3794
+ kept (the same value, not a fresh object).
3600
3795
 
3601
3796
  The selector and equality function run with the same cadence as React's
3602
3797
  `useSyncExternalStore` binding, because React re-reads its snapshot around
3603
3798
  every render; {@link useSyncExternalStore} documents the cadence.
3604
3799
 
3605
3800
  ```typescript
3606
- function useStore<T, S = T>(store: Store<T>, options?: UseStoreOptions<T, S>): Readable<S>
3801
+ function useStore<T, S = T>(
3802
+ store: MaybeReadable<Store<T>>,
3803
+ options?: MaybeReadable<UseStoreOptions<T, S> | undefined>,
3804
+ ): Readable<S>
3607
3805
  ```
3608
3806
 
3609
- - `store` — The store to subscribe to.
3610
- - `options` — Hook options (selector, equalityFn).
3807
+ - `store` — The store to subscribe to (or a readable store of it).
3808
+ - `options` — Hook options (selector, equalityFn), or a store of them.
3611
3809
 
3612
3810
  **Returns:** A readable store of the selected state.
3613
3811
 
@@ -3739,11 +3937,14 @@ directly leaves stale text after a locale switch. If `error` is an
3739
3937
  using the current locale. For plain `Error` instances, `error.message` is
3740
3938
  returned unchanged.
3741
3939
 
3940
+ The error may be a plain value or a readable store of one: setting the store
3941
+ replaces the message on the same component, the way React's re-render does.
3942
+
3742
3943
  ```typescript
3743
- function useI18nError(error: Error | null | undefined): Readable<string | null>
3944
+ function useI18nError(error: MaybeReadable<Error | null | undefined>): Readable<string | null>
3744
3945
  ```
3745
3946
 
3746
- - `error` — The error to translate, or `null`/`undefined`.
3947
+ - `error` — The error to translate, or `null`/`undefined` (or a store of either).
3747
3948
 
3748
3949
  **Returns:** A readable store of the translated error string, or null.
3749
3950
 
@@ -3891,9 +4092,10 @@ AI chat with streaming: the transcript, loading and error state, mode, and
3891
4092
  the controls (send, abort, queue edits, history). Call it during component
3892
4093
  init.
3893
4094
 
3894
- The options may be a readable store: a new `endpoint` switches conversation
3895
- and a new `projectId` moves to that project's transcript, on the same
3896
- component, the way React re-renders `useChat`.
4095
+ The options may be a plain value or a readable store of one (a store holding
4096
+ `undefined` means no options): a new `endpoint` switches conversation and a
4097
+ new `projectId` moves to that project's transcript, on the same component,
4098
+ the way React re-renders `useChat`.
3897
4099
 
3898
4100
  ```typescript
3899
4101
  function useChat(options: UseChatOptions | Readable<UseChatOptions>): UseChatResult
@@ -4467,6 +4669,12 @@ function createVersionStores(): {
4467
4669
 
4468
4670
  ### Constants
4469
4671
 
4672
+ #### `Link`
4673
+
4674
+ ```typescript
4675
+ const Link: LegacyComponentType
4676
+ ```
4677
+
4470
4678
  #### `SessionReady`
4471
4679
 
4472
4680
  ```typescript
@@ -4547,7 +4755,7 @@ Peer dependencies:
4547
4755
  - `@molecule/app-auth` ^3.0.0
4548
4756
  - `@molecule/app-code-editor` ^1.0.1
4549
4757
  - `@molecule/app-device` ^1.0.1
4550
- - `@molecule/app-forms` ^2.3.1
4758
+ - `@molecule/app-forms` ^2.4.0
4551
4759
  - `@molecule/app-http` ^1.0.1
4552
4760
  - `@molecule/app-i18n` ^1.0.1
4553
4761
  - `@molecule/app-ide` ^1.0.1
@@ -4555,14 +4763,14 @@ Peer dependencies:
4555
4763
  - `@molecule/app-logger` ^1.0.1
4556
4764
  - `@molecule/app-platform` ^1.0.1
4557
4765
  - `@molecule/app-push` ^1.0.1
4558
- - `@molecule/app-routing` ^1.1.0
4766
+ - `@molecule/app-routing` ^1.3.0
4559
4767
  - `@molecule/app-state` ^1.2.0
4560
4768
  - `@molecule/app-storage` ^1.1.1
4561
4769
  - `@molecule/app-theme` ^1.0.1
4562
4770
  - `@molecule/app-ui` ^1.0.1
4563
4771
  - `@molecule/app-utilities` ^1.0.1
4564
4772
  - `@molecule/app-version` ^1.0.1
4565
- - `svelte` ^5.0.0
4773
+ - `svelte` ^5.7.0
4566
4774
 
4567
4775
  ### Runtime Dependencies
4568
4776
 
@@ -4597,6 +4805,9 @@ Peer dependencies:
4597
4805
  config; don't wrap in try/catch.
4598
4806
  - Results are Svelte stores — read them with the `$` prefix (`$isAuthenticated`, `$theme`);
4599
4807
  actions (`logout`, `toggleTheme`, `setTheme`) are plain functions.
4808
+ - In-app links are `Link` (`<Link to="/settings">`): it navigates through the router with
4809
+ react-router `<Link>`'s click rules. A hand-written click handler that calls `navigate()`
4810
+ breaks ctrl/cmd-click (new tab) unless it repeats those rules.
4600
4811
 
4601
4812
  ## Translations
4602
4813