@molecule/app-angular 3.5.0 → 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.
- package/README.md +323 -88
- package/dist/chat.d.ts.map +1 -1
- package/dist/chat.js +3 -2
- package/dist/chat.js.map +1 -1
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +1 -0
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/use-ai-models.d.ts +10 -3
- package/dist/hooks/use-ai-models.d.ts.map +1 -1
- package/dist/hooks/use-ai-models.js +40 -15
- package/dist/hooks/use-ai-models.js.map +1 -1
- package/dist/hooks/use-async.d.ts +10 -6
- package/dist/hooks/use-async.d.ts.map +1 -1
- package/dist/hooks/use-async.js +38 -33
- package/dist/hooks/use-async.js.map +1 -1
- package/dist/hooks/use-auth-flows.d.ts +40 -21
- package/dist/hooks/use-auth-flows.d.ts.map +1 -1
- package/dist/hooks/use-auth-flows.js +59 -38
- package/dist/hooks/use-auth-flows.js.map +1 -1
- package/dist/hooks/use-auth.d.ts +7 -2
- package/dist/hooks/use-auth.d.ts.map +1 -1
- package/dist/hooks/use-auth.js +25 -10
- package/dist/hooks/use-auth.js.map +1 -1
- package/dist/hooks/use-forms.d.ts +10 -13
- package/dist/hooks/use-forms.d.ts.map +1 -1
- package/dist/hooks/use-forms.js +90 -54
- package/dist/hooks/use-forms.js.map +1 -1
- package/dist/hooks/use-http.d.ts +40 -32
- package/dist/hooks/use-http.d.ts.map +1 -1
- package/dist/hooks/use-http.js +80 -94
- package/dist/hooks/use-http.js.map +1 -1
- package/dist/hooks/use-ide.d.ts.map +1 -1
- package/dist/hooks/use-ide.js +3 -3
- package/dist/hooks/use-ide.js.map +1 -1
- package/dist/hooks/use-logger.d.ts.map +1 -1
- package/dist/hooks/use-logger.js +1 -1
- package/dist/hooks/use-logger.js.map +1 -1
- package/dist/hooks/use-native.d.ts +7 -2
- package/dist/hooks/use-native.d.ts.map +1 -1
- package/dist/hooks/use-native.js +27 -12
- package/dist/hooks/use-native.js.map +1 -1
- package/dist/hooks/use-optimistic-toggle.d.ts +65 -0
- package/dist/hooks/use-optimistic-toggle.d.ts.map +1 -0
- package/dist/hooks/use-optimistic-toggle.js +51 -0
- package/dist/hooks/use-optimistic-toggle.js.map +1 -0
- package/dist/hooks/use-router.d.ts +11 -4
- package/dist/hooks/use-router.d.ts.map +1 -1
- package/dist/hooks/use-router.js +22 -7
- package/dist/hooks/use-router.js.map +1 -1
- package/dist/hooks/use-storage.d.ts +20 -6
- package/dist/hooks/use-storage.d.ts.map +1 -1
- package/dist/hooks/use-storage.js +148 -66
- package/dist/hooks/use-storage.js.map +1 -1
- package/dist/hooks/use-store.d.ts +10 -3
- package/dist/hooks/use-store.d.ts.map +1 -1
- package/dist/hooks/use-store.js +49 -9
- package/dist/hooks/use-store.js.map +1 -1
- package/dist/hooks/use-theme.d.ts.map +1 -1
- package/dist/hooks/use-theme.js +1 -1
- package/dist/hooks/use-theme.js.map +1 -1
- package/dist/hooks/use-translation.d.ts +7 -2
- package/dist/hooks/use-translation.d.ts.map +1 -1
- package/dist/hooks/use-translation.js +11 -5
- package/dist/hooks/use-translation.js.map +1 -1
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/inject.d.ts +7 -2
- package/dist/inject.d.ts.map +1 -1
- package/dist/inject.js +51 -5
- package/dist/inject.js.map +1 -1
- package/dist/link.d.ts +63 -0
- package/dist/link.d.ts.map +1 -0
- package/dist/link.js +82 -0
- package/dist/link.js.map +1 -0
- package/dist/maybe-signal.d.ts +26 -0
- package/dist/maybe-signal.d.ts.map +1 -0
- package/dist/maybe-signal.js +20 -0
- package/dist/maybe-signal.js.map +1 -0
- package/package.json +4 -4
- package/dist/site.d.ts +0 -51
- package/dist/site.d.ts.map +0 -1
- package/dist/site.js +0 -69
- package/dist/site.js.map +0 -1
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-
|
|
6
|
+
Generated: 2026-11-16T14:06:29.917Z
|
|
7
7
|
-->
|
|
8
8
|
|
|
9
9
|
# @molecule/app-angular
|
|
@@ -379,9 +379,10 @@ interface FormController<T extends FormValuesConstraint<T> = Record<string, unkn
|
|
|
379
379
|
* record, never a merge of earlier records. With `keepDirtyValues`, edited
|
|
380
380
|
* fields retain their values while pristine fields take the loaded values.
|
|
381
381
|
* A changed non-null `id` still replaces the record and cancels a pending
|
|
382
|
-
* submit. Equal-content baselines cause no update.
|
|
382
|
+
* submit. Equal-content baselines cause no update. `keepOmittedValues` opts
|
|
383
|
+
* into incremental top-level field fills using the current clean baseline.
|
|
383
384
|
*/
|
|
384
|
-
updateValues(values: Partial<T>, resetOptions?:
|
|
385
|
+
updateValues(values: Partial<T>, resetOptions?: FormUpdateOptions): void
|
|
385
386
|
|
|
386
387
|
/**
|
|
387
388
|
* Handles form submission.
|
|
@@ -1550,7 +1551,11 @@ Return type for {@link useOAuth}.
|
|
|
1550
1551
|
|
|
1551
1552
|
```typescript
|
|
1552
1553
|
interface UseOAuthReturn {
|
|
1553
|
-
/**
|
|
1554
|
+
/**
|
|
1555
|
+
* The supported provider names. A live getter: it reads the config the hook
|
|
1556
|
+
* currently holds, so it follows a config passed as a signal the way React's
|
|
1557
|
+
* re-rendered `providers` list does.
|
|
1558
|
+
*/
|
|
1554
1559
|
providers: string[]
|
|
1555
1560
|
/**
|
|
1556
1561
|
* Builds the initiation URL for one provider.
|
|
@@ -1578,6 +1583,35 @@ interface UseOAuthReturn {
|
|
|
1578
1583
|
}
|
|
1579
1584
|
```
|
|
1580
1585
|
|
|
1586
|
+
#### `UseOAuthConfig`
|
|
1587
|
+
|
|
1588
|
+
OAuth configuration for {@link useOAuth}: the app's `oauthConfig` (from its `config.ts`),
|
|
1589
|
+
the same type under the same name in every framework binding.
|
|
1590
|
+
|
|
1591
|
+
```typescript
|
|
1592
|
+
interface UseOAuthConfig {
|
|
1593
|
+
/** Base URL for the API server (e.g. "https://api.example.com"). */
|
|
1594
|
+
baseURL?: string
|
|
1595
|
+
/** List of supported OAuth provider names (e.g. ["google", "github"]). */
|
|
1596
|
+
oauthProviders?: string[]
|
|
1597
|
+
/** Path prefix for OAuth routes (defaults to "/oauth"). */
|
|
1598
|
+
oauthEndpoint?: string
|
|
1599
|
+
/** Path for the OAuth login POST endpoint (defaults to "/users/log-in/oauth"). */
|
|
1600
|
+
loginEndpoint?: string
|
|
1601
|
+
/** Callback after successful OAuth login. */
|
|
1602
|
+
onSuccess?: () => void
|
|
1603
|
+
/** Callback on OAuth login failure. */
|
|
1604
|
+
onError?: (error: string) => void
|
|
1605
|
+
/**
|
|
1606
|
+
* How the page leaves for the provider: {@link UseOAuthReturn.redirect} and the
|
|
1607
|
+
* blocked-popup fallback call it with the provider URL. Defaults to a full-page
|
|
1608
|
+
* navigation (`window.location.href = url`); pass an in-app browser opener on
|
|
1609
|
+
* native, or a router's external navigation.
|
|
1610
|
+
*/
|
|
1611
|
+
navigate?: (url: string) => void
|
|
1612
|
+
}
|
|
1613
|
+
```
|
|
1614
|
+
|
|
1581
1615
|
#### `UseAuthOptions`
|
|
1582
1616
|
|
|
1583
1617
|
Options for {@link useAuth}.
|
|
@@ -1738,7 +1772,7 @@ interface UseFormResult<T extends FormValuesConstraint<T>> {
|
|
|
1738
1772
|
* @param values - The values to apply.
|
|
1739
1773
|
* @param resetOptions - Whether edits survive.
|
|
1740
1774
|
*/
|
|
1741
|
-
updateValues: (values: Partial<T>, resetOptions?:
|
|
1775
|
+
updateValues: (values: Partial<T>, resetOptions?: FormUpdateOptions) => void
|
|
1742
1776
|
/**
|
|
1743
1777
|
* Whole-form state tuple: edits mark only changed fields dirty; fills
|
|
1744
1778
|
* preserve them.
|
|
@@ -1796,9 +1830,11 @@ interface UseHttpResult<T> {
|
|
|
1796
1830
|
* Runs the request and resolves with its own data, or `null` on failure,
|
|
1797
1831
|
* even when a newer request or `reset` has superseded its displayed state.
|
|
1798
1832
|
*
|
|
1799
|
-
* This function is IDENTITY-STABLE for
|
|
1800
|
-
*
|
|
1801
|
-
*
|
|
1833
|
+
* This function is IDENTITY-STABLE for the component's lifetime — the
|
|
1834
|
+
* request it performs is the one the `method`, `url` and `options` sources
|
|
1835
|
+
* hold when it is CALLED, as React reads the latest committed render's
|
|
1836
|
+
* arguments when its `execute` runs. Its request options are read when it
|
|
1837
|
+
* is CALLED.
|
|
1802
1838
|
*
|
|
1803
1839
|
* @returns The response data, or `null` on failure.
|
|
1804
1840
|
*/
|
|
@@ -2145,6 +2181,39 @@ interface UsePushResult {
|
|
|
2145
2181
|
}
|
|
2146
2182
|
```
|
|
2147
2183
|
|
|
2184
|
+
#### `UseOptimisticToggleOptions`
|
|
2185
|
+
|
|
2186
|
+
Options for {@link useOptimisticToggle}.
|
|
2187
|
+
|
|
2188
|
+
```typescript
|
|
2189
|
+
interface UseOptimisticToggleOptions {
|
|
2190
|
+
/** The loaded server value. Mount the control only after its record exists. */
|
|
2191
|
+
value: boolean
|
|
2192
|
+
/** Saves the DESIRED value and returns the server-confirmed value; reject on failure. */
|
|
2193
|
+
commit: (desired: boolean) => Promise<boolean>
|
|
2194
|
+
/** Receives the newest failed save and the confirmed value restored by the controller. */
|
|
2195
|
+
onError?: (error: unknown, value: boolean) => void
|
|
2196
|
+
}
|
|
2197
|
+
```
|
|
2198
|
+
|
|
2199
|
+
#### `UseOptimisticToggleResult`
|
|
2200
|
+
|
|
2201
|
+
What {@link useOptimisticToggle} returns: the boolean to render (as signals, the same
|
|
2202
|
+
fields React's result carries as plain values) and an argument-free action.
|
|
2203
|
+
|
|
2204
|
+
```typescript
|
|
2205
|
+
interface UseOptimisticToggleResult {
|
|
2206
|
+
/** The newest chosen value, or the server's value when nothing is saving. */
|
|
2207
|
+
readonly value: Signal<boolean>
|
|
2208
|
+
/** Whether a save is running or waiting to run. */
|
|
2209
|
+
readonly pending: Signal<boolean>
|
|
2210
|
+
/** The failure of the newest change, after the value went back; `null` otherwise. */
|
|
2211
|
+
readonly error: Signal<unknown>
|
|
2212
|
+
/** Flips the value shown now and saves it; the same function for the component's life. */
|
|
2213
|
+
toggle: () => void
|
|
2214
|
+
}
|
|
2215
|
+
```
|
|
2216
|
+
|
|
2148
2217
|
#### `UseProfileFormOptions`
|
|
2149
2218
|
|
|
2150
2219
|
Configuration for a profile form; transport stays in the auth bond.
|
|
@@ -3004,8 +3073,73 @@ How far the return-page verification has got.
|
|
|
3004
3073
|
type VerifyPaymentReturnStatus = 'idle' | 'verifying' | 'verified' | 'failed'
|
|
3005
3074
|
```
|
|
3006
3075
|
|
|
3076
|
+
#### `MaybeSignal`
|
|
3077
|
+
|
|
3078
|
+
A hook argument: the plain value, or a signal holding the value the hook
|
|
3079
|
+
should currently use. A signal holding `undefined` means the argument was
|
|
3080
|
+
omitted, exactly like a missing plain argument: the default applies.
|
|
3081
|
+
|
|
3082
|
+
```typescript
|
|
3083
|
+
type MaybeSignal<T> = T | Signal<T>
|
|
3084
|
+
```
|
|
3085
|
+
|
|
3007
3086
|
### Classes
|
|
3008
3087
|
|
|
3088
|
+
#### `Link`
|
|
3089
|
+
|
|
3090
|
+
`<a molLink="/settings">`: sets the anchor's `href` and navigates in-app
|
|
3091
|
+
through the molecule router, with react-router `<Link>`'s rules
|
|
3092
|
+
(`followRouterLink` from `@molecule/app-routing`): a plain primary click
|
|
3093
|
+
navigates without a page load; a ctrl/cmd, shift or alt click, a `target`
|
|
3094
|
+
other than `_self`, a click the template's own `(click)` handler prevented,
|
|
3095
|
+
and a URL on another origin are left to the browser.
|
|
3096
|
+
|
|
3097
|
+
Inputs: `molLink` (the destination: an app path or a URL), `replace` (replace
|
|
3098
|
+
the current history entry; when unset, a link to the location already shown
|
|
3099
|
+
replaces it and any other link pushes, as with react-router's `<Link>`), and
|
|
3100
|
+
`state` (stored with the new entry). Every other attribute (`class`,
|
|
3101
|
+
`target`, `rel`) is written on the anchor as usual.
|
|
3102
|
+
|
|
3103
|
+
Use it for every internal link instead of an anchor with a `(click)` handler
|
|
3104
|
+
that calls `navigate()`. Needs the router from `provideMolecule({ router })`.
|
|
3105
|
+
|
|
3106
|
+
```typescript
|
|
3107
|
+
@Directive({
|
|
3108
|
+
selector: 'a[molLink]',
|
|
3109
|
+
standalone: true,
|
|
3110
|
+
inputs: ['molLink', 'replace', 'state'],
|
|
3111
|
+
host: { '[attr.href]': 'molLink' },
|
|
3112
|
+
})
|
|
3113
|
+
export class Link implements OnInit {
|
|
3114
|
+
/** The destination: an app path (`/settings?tab=billing#plan`) or a URL. */
|
|
3115
|
+
molLink = ''
|
|
3116
|
+
/** Replace the current history entry instead of pushing one. */
|
|
3117
|
+
replace?: boolean
|
|
3118
|
+
/** State stored with the new history entry. */
|
|
3119
|
+
state?: unknown
|
|
3120
|
+
|
|
3121
|
+
private readonly router = useRouterInstance()
|
|
3122
|
+
private readonly element = inject<ElementRef<HTMLAnchorElement>>(ElementRef)
|
|
3123
|
+
private readonly renderer = inject(Renderer2)
|
|
3124
|
+
private readonly destroyRef = inject(DestroyRef)
|
|
3125
|
+
|
|
3126
|
+
/**
|
|
3127
|
+
* Starts handling clicks. The listener is added here, after the template
|
|
3128
|
+
* created this anchor's own `(click)` listeners, so those run first and can
|
|
3129
|
+
* prevent the navigation (react-router calls `onClick` first too).
|
|
3130
|
+
*/
|
|
3131
|
+
ngOnInit(): void {
|
|
3132
|
+
const stop = this.renderer.listen(this.element.nativeElement, 'click', (event: MouseEvent) => {
|
|
3133
|
+
followRouterLink(event, this.molLink, this.router, {
|
|
3134
|
+
replace: this.replace,
|
|
3135
|
+
state: this.state,
|
|
3136
|
+
})
|
|
3137
|
+
})
|
|
3138
|
+
this.destroyRef.onDestroy(stop)
|
|
3139
|
+
}
|
|
3140
|
+
}
|
|
3141
|
+
```
|
|
3142
|
+
|
|
3009
3143
|
#### `MoleculeAuthService`
|
|
3010
3144
|
|
|
3011
3145
|
Angular service for authentication.
|
|
@@ -4325,11 +4459,16 @@ Subscribes to the cached AI model catalog. The first mount of a scope
|
|
|
4325
4459
|
triggers a single `GET /ai/models` fetch; subsequent mounts return the
|
|
4326
4460
|
cached result. Call it in an injection context.
|
|
4327
4461
|
|
|
4462
|
+
The project id may be a signal: the hook then switches to that project's
|
|
4463
|
+
scope on the same component — resubscribing, resyncing from the new scope's
|
|
4464
|
+
cache and fetching it when it is not cached — the way React re-renders
|
|
4465
|
+
`useAIModels` with a new `projectId`.
|
|
4466
|
+
|
|
4328
4467
|
```typescript
|
|
4329
|
-
function useAIModels(projectId?: string): UseAIModelsResult
|
|
4468
|
+
function useAIModels(projectId?: MaybeSignal<string | undefined>): UseAIModelsResult
|
|
4330
4469
|
```
|
|
4331
4470
|
|
|
4332
|
-
- `projectId` — Optional project scope: includes that project's custom ("bring your own AI") models on servers that support them.
|
|
4471
|
+
- `projectId` — Optional project scope: includes that project's custom ("bring your own AI") models on servers that support them (or a signal of it).
|
|
4333
4472
|
|
|
4334
4473
|
**Returns:** Models, free-tier model, loading flag, and error as signals.
|
|
4335
4474
|
|
|
@@ -4388,16 +4527,20 @@ Only a failure of the newest change puts the server value back. A new server
|
|
|
4388
4527
|
`value` is taken only while nothing is being saved, so a parent re-render or
|
|
4389
4528
|
a refetch of older data never flips the control mid-save.
|
|
4390
4529
|
|
|
4391
|
-
|
|
4392
|
-
|
|
4393
|
-
the
|
|
4394
|
-
|
|
4530
|
+
The options may be a signal, and the controller follows them the way React's
|
|
4531
|
+
re-render does: `commit`, `equals` and `onError` are read from the options
|
|
4532
|
+
the signal holds at the moment they run, and a server `value` that differs
|
|
4533
|
+
(by `equals`) from the last one received is synced in — kept as the fallback
|
|
4534
|
+
while a save runs — with the controller and any pending save kept on the same
|
|
4535
|
+
component.
|
|
4395
4536
|
|
|
4396
4537
|
```typescript
|
|
4397
|
-
function useOptimisticValue<T>(
|
|
4538
|
+
function useOptimisticValue<T>(
|
|
4539
|
+
options: MaybeSignal<OptimisticValueOptions<T>>,
|
|
4540
|
+
): UseOptimisticValueResult<T>
|
|
4398
4541
|
```
|
|
4399
4542
|
|
|
4400
|
-
- `options` — The server's current value and how to save a change.
|
|
4543
|
+
- `options` — The server's current value and how to save a change (or a signal of them).
|
|
4401
4544
|
|
|
4402
4545
|
**Returns:** The value to render, whether a save is pending, the newest failure, and `set`/`update`.
|
|
4403
4546
|
|
|
@@ -4461,31 +4604,22 @@ handles OAuth callbacks by detecting `code` and `state` URL parameters and
|
|
|
4461
4604
|
exchanging them for a session — and, when the callback is running inside a
|
|
4462
4605
|
popup we opened, relaying the result to the opener instead.
|
|
4463
4606
|
|
|
4607
|
+
The config may be a signal, and the result follows it the way React's
|
|
4608
|
+
re-render does: `providers` reads the config at the moment it is read,
|
|
4609
|
+
`getOAuthUrl` builds from the config at call time, and a flow (`redirect`,
|
|
4610
|
+
`loginViaPopup`, a callback exchange) uses the config it was started with,
|
|
4611
|
+
like the render closure React started it from.
|
|
4612
|
+
|
|
4464
4613
|
Unmounting does not cancel a flow that has started. A popup result or a
|
|
4465
4614
|
callback exchange that settles afterwards still establishes the session on
|
|
4466
4615
|
the shared auth client, because the user did sign in. `onSuccess` and
|
|
4467
4616
|
`onError` are not called after unmount: they belong to the unmounted view.
|
|
4468
4617
|
|
|
4469
4618
|
```typescript
|
|
4470
|
-
function useOAuth(config?:
|
|
4471
|
-
baseURL?: string
|
|
4472
|
-
oauthProviders?: string[]
|
|
4473
|
-
oauthEndpoint?: string
|
|
4474
|
-
loginEndpoint?: string
|
|
4475
|
-
onSuccess?: () => void
|
|
4476
|
-
onError?: (error: string) => void
|
|
4477
|
-
navigate?: (url: string) => void
|
|
4478
|
-
}): UseOAuthReturn
|
|
4619
|
+
function useOAuth(config?: MaybeSignal<UseOAuthConfig>): UseOAuthReturn
|
|
4479
4620
|
```
|
|
4480
4621
|
|
|
4481
|
-
- `config` — Optional OAuth configuration override.
|
|
4482
|
-
- `config.baseURL` — Base URL for the API server (e.g. "https://api.example.com").
|
|
4483
|
-
- `config.oauthProviders` — List of supported OAuth provider names (e.g. ["google", "github"]).
|
|
4484
|
-
- `config.oauthEndpoint` — Path prefix for OAuth routes (defaults to "/oauth").
|
|
4485
|
-
- `config.loginEndpoint` — Path for the OAuth login POST endpoint (defaults to "/users/log-in/oauth").
|
|
4486
|
-
- `config.onSuccess` — Callback after successful OAuth login.
|
|
4487
|
-
- `config.onError` — Callback on OAuth login failure.
|
|
4488
|
-
- `config.navigate` — How the page leaves for the provider: {@link UseOAuthReturn.redirect} and the blocked-popup fallback call it with the provider URL. Defaults to a full-page navigation (`window.location.href = url`); pass an in-app browser opener on native, or a router's external navigation.
|
|
4622
|
+
- `config` — Optional OAuth configuration override (see {@link UseOAuthConfig}), or a signal of it.
|
|
4489
4623
|
|
|
4490
4624
|
**Returns:** OAuth helpers: providers, getOAuthUrl, redirect, and loginViaPopup.
|
|
4491
4625
|
|
|
@@ -4511,14 +4645,18 @@ component field initializer or constructor).
|
|
|
4511
4645
|
`status === 'loading'` is undecided; `'unavailable'` keeps the candidate
|
|
4512
4646
|
session for retry; a restore failure never signs out.
|
|
4513
4647
|
|
|
4648
|
+
The options may be a signal: `autoRefresh` turning on through it probes once
|
|
4649
|
+
(when the visitor is signed out and decided), the way React re-renders
|
|
4650
|
+
`useAuth` with the new option.
|
|
4651
|
+
|
|
4514
4652
|
```typescript
|
|
4515
4653
|
function useAuth<
|
|
4516
4654
|
T = unknown,
|
|
4517
4655
|
TRegister extends RegisterExtraShape<TRegister> = Record<never, never>,
|
|
4518
|
-
>(options?: UseAuthOptions): UseAuthResult<T, TRegister>
|
|
4656
|
+
>(options?: MaybeSignal<UseAuthOptions>): UseAuthResult<T, TRegister>
|
|
4519
4657
|
```
|
|
4520
4658
|
|
|
4521
|
-
- `options` — Hook options (`autoRefresh`).
|
|
4659
|
+
- `options` — Hook options (`autoRefresh`), or a signal of them.
|
|
4522
4660
|
|
|
4523
4661
|
**Returns:** Auth state as signals and the auth actions.
|
|
4524
4662
|
|
|
@@ -4551,18 +4689,19 @@ Creates its controller through the bonded forms provider, so an app wires a
|
|
|
4551
4689
|
form library once (`setProvider` from `@molecule/app-forms`) and every form
|
|
4552
4690
|
picks it up. Passing `createForm` overrides that for one form.
|
|
4553
4691
|
|
|
4554
|
-
|
|
4555
|
-
`
|
|
4556
|
-
|
|
4557
|
-
|
|
4692
|
+
The options may be a signal, and the hook follows them the way React's
|
|
4693
|
+
re-render does: when `values` changes by content, it becomes the new
|
|
4694
|
+
baseline; `resetOptions.keepDirtyValues` retains edited fields while
|
|
4695
|
+
pristine fields take the loaded values. A changed `resetKey` starts a fresh
|
|
4696
|
+
form; new `defaultValues` without one leave the form (and its drafts) alone.
|
|
4558
4697
|
|
|
4559
4698
|
```typescript
|
|
4560
4699
|
function useForm<T extends FormValuesConstraint<T> = Record<string, unknown>>(
|
|
4561
|
-
options?: UseFormOptions<T
|
|
4700
|
+
options?: MaybeSignal<UseFormOptions<T>>,
|
|
4562
4701
|
): UseFormResult<T>
|
|
4563
4702
|
```
|
|
4564
4703
|
|
|
4565
|
-
- `options` — Form options.
|
|
4704
|
+
- `options` — Form options (or a signal of them).
|
|
4566
4705
|
|
|
4567
4706
|
**Returns:** Form state as signals and the form methods.
|
|
4568
4707
|
|
|
@@ -4614,11 +4753,16 @@ function useHttpClient(): HttpClient
|
|
|
4614
4753
|
HTTP requests with state management. Call it in an injection context (a
|
|
4615
4754
|
component field initializer or constructor).
|
|
4616
4755
|
|
|
4617
|
-
`execute` keeps one identity
|
|
4618
|
-
|
|
4619
|
-
|
|
4620
|
-
`execute` is called
|
|
4621
|
-
|
|
4756
|
+
`execute` keeps one identity for the component's lifetime; the request it
|
|
4757
|
+
performs is the one the `method`, `url` and `options` sources hold when it
|
|
4758
|
+
is called. The current headers, body, `signal` and callbacks are read when
|
|
4759
|
+
`execute` is called, so an inline options object or callback needs no
|
|
4760
|
+
memoizing.
|
|
4761
|
+
|
|
4762
|
+
The arguments may be signals: `execute` then sends to the url the signal
|
|
4763
|
+
holds at the moment it is called, the way React's re-rendered `useHttp`
|
|
4764
|
+
sends to the latest url. The hook's state (an in-flight request, loaded
|
|
4765
|
+
data) survives an argument change, as React's survives a re-render.
|
|
4622
4766
|
|
|
4623
4767
|
The newest request owns the state: an older request that answers after a
|
|
4624
4768
|
newer one (or after `reset`) cannot repopulate the displayed state, though
|
|
@@ -4626,15 +4770,15 @@ its own callbacks still report its outcome.
|
|
|
4626
4770
|
|
|
4627
4771
|
```typescript
|
|
4628
4772
|
function useHttp<T>(
|
|
4629
|
-
method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE'
|
|
4630
|
-
url: string
|
|
4631
|
-
options?: UseHttpOptions<T
|
|
4773
|
+
method: MaybeSignal<'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE'>,
|
|
4774
|
+
url: MaybeSignal<string>,
|
|
4775
|
+
options?: MaybeSignal<UseHttpOptions<T>>,
|
|
4632
4776
|
): UseHttpResult<T>
|
|
4633
4777
|
```
|
|
4634
4778
|
|
|
4635
|
-
- `method` — HTTP method.
|
|
4636
|
-
- `url` — Request URL.
|
|
4637
|
-
- `options` — Request options, read at call time.
|
|
4779
|
+
- `method` — HTTP method (or a signal of it).
|
|
4780
|
+
- `url` — Request URL (or a signal of it).
|
|
4781
|
+
- `options` — Request options, read at call time (or a signal of them).
|
|
4638
4782
|
|
|
4639
4783
|
**Returns:** The request state as signals and the execute/reset functions.
|
|
4640
4784
|
|
|
@@ -4643,11 +4787,14 @@ function useHttp<T>(
|
|
|
4643
4787
|
GET requests.
|
|
4644
4788
|
|
|
4645
4789
|
```typescript
|
|
4646
|
-
function useGet<T>(
|
|
4790
|
+
function useGet<T>(
|
|
4791
|
+
url: MaybeSignal<string>,
|
|
4792
|
+
options?: MaybeSignal<UseHttpOptions<T>>,
|
|
4793
|
+
): UseHttpResult<T>
|
|
4647
4794
|
```
|
|
4648
4795
|
|
|
4649
|
-
- `url` — Request URL to fetch from.
|
|
4650
|
-
- `options` — HTTP request options including callbacks and request config.
|
|
4796
|
+
- `url` — Request URL to fetch from (or a signal of it).
|
|
4797
|
+
- `options` — HTTP request options including callbacks and request config (or a signal of them).
|
|
4651
4798
|
|
|
4652
4799
|
**Returns:** Request state (data, loading, error) and controls (execute, reset).
|
|
4653
4800
|
|
|
@@ -4656,11 +4803,14 @@ function useGet<T>(url: string, options?: UseHttpOptions<T>): UseHttpResult<T>
|
|
|
4656
4803
|
POST requests, with the body in `options.data`.
|
|
4657
4804
|
|
|
4658
4805
|
```typescript
|
|
4659
|
-
function usePost<T>(
|
|
4806
|
+
function usePost<T>(
|
|
4807
|
+
url: MaybeSignal<string>,
|
|
4808
|
+
options?: MaybeSignal<UseHttpOptions<T>>,
|
|
4809
|
+
): UseHttpResult<T>
|
|
4660
4810
|
```
|
|
4661
4811
|
|
|
4662
|
-
- `url` — Request URL to post to.
|
|
4663
|
-
- `options` — HTTP request options including body data and callbacks.
|
|
4812
|
+
- `url` — Request URL to post to (or a signal of it).
|
|
4813
|
+
- `options` — HTTP request options including body data and callbacks (or a signal of them).
|
|
4664
4814
|
|
|
4665
4815
|
**Returns:** Request state (data, loading, error) and controls (execute, reset).
|
|
4666
4816
|
|
|
@@ -4669,11 +4819,14 @@ function usePost<T>(url: string, options?: UseHttpOptions<T>): UseHttpResult<T>
|
|
|
4669
4819
|
PUT requests, with the replacement body.
|
|
4670
4820
|
|
|
4671
4821
|
```typescript
|
|
4672
|
-
function usePut<T>(
|
|
4822
|
+
function usePut<T>(
|
|
4823
|
+
url: MaybeSignal<string>,
|
|
4824
|
+
options?: MaybeSignal<UseHttpOptions<T>>,
|
|
4825
|
+
): UseHttpResult<T>
|
|
4673
4826
|
```
|
|
4674
4827
|
|
|
4675
|
-
- `url` — Request URL to send the PUT request to.
|
|
4676
|
-
- `options` — HTTP request options including body data and callbacks.
|
|
4828
|
+
- `url` — Request URL to send the PUT request to (or a signal of it).
|
|
4829
|
+
- `options` — HTTP request options including body data and callbacks (or a signal of them).
|
|
4677
4830
|
|
|
4678
4831
|
**Returns:** Request state (data, loading, error) and controls (execute, reset).
|
|
4679
4832
|
|
|
@@ -4682,11 +4835,14 @@ function usePut<T>(url: string, options?: UseHttpOptions<T>): UseHttpResult<T>
|
|
|
4682
4835
|
PATCH requests, with the partial body.
|
|
4683
4836
|
|
|
4684
4837
|
```typescript
|
|
4685
|
-
function usePatch<T>(
|
|
4838
|
+
function usePatch<T>(
|
|
4839
|
+
url: MaybeSignal<string>,
|
|
4840
|
+
options?: MaybeSignal<UseHttpOptions<T>>,
|
|
4841
|
+
): UseHttpResult<T>
|
|
4686
4842
|
```
|
|
4687
4843
|
|
|
4688
|
-
- `url` — Request URL to send the PATCH request to.
|
|
4689
|
-
- `options` — HTTP request options including partial body data and callbacks.
|
|
4844
|
+
- `url` — Request URL to send the PATCH request to (or a signal of it).
|
|
4845
|
+
- `options` — HTTP request options including partial body data and callbacks (or a signal of them).
|
|
4690
4846
|
|
|
4691
4847
|
**Returns:** Request state (data, loading, error) and controls (execute, reset).
|
|
4692
4848
|
|
|
@@ -4695,11 +4851,14 @@ function usePatch<T>(url: string, options?: UseHttpOptions<T>): UseHttpResult<T>
|
|
|
4695
4851
|
DELETE requests; a body travels in `options.data`.
|
|
4696
4852
|
|
|
4697
4853
|
```typescript
|
|
4698
|
-
function useDelete<T>(
|
|
4854
|
+
function useDelete<T>(
|
|
4855
|
+
url: MaybeSignal<string>,
|
|
4856
|
+
options?: MaybeSignal<UseHttpOptions<T>>,
|
|
4857
|
+
): UseHttpResult<T>
|
|
4699
4858
|
```
|
|
4700
4859
|
|
|
4701
|
-
- `url` — Request URL of the resource to delete.
|
|
4702
|
-
- `options` — HTTP request options including callbacks.
|
|
4860
|
+
- `url` — Request URL of the resource to delete (or a signal of it).
|
|
4861
|
+
- `options` — HTTP request options including callbacks (or a signal of them).
|
|
4703
4862
|
|
|
4704
4863
|
**Returns:** Request state (data, loading, error) and controls (execute, reset).
|
|
4705
4864
|
|
|
@@ -4904,14 +5063,41 @@ Push notification state and actions. Call it in an injection context.
|
|
|
4904
5063
|
Uses module-level `getProvider()` — push is a singleton, not
|
|
4905
5064
|
registration-provided.
|
|
4906
5065
|
|
|
5066
|
+
The options may be a signal: `checkOnMount` turning on through it checks the
|
|
5067
|
+
permission once more (when it was off before), the way React re-renders
|
|
5068
|
+
`usePush` with the new option.
|
|
5069
|
+
|
|
4907
5070
|
```typescript
|
|
4908
|
-
function usePush(options?: UsePushOptions): UsePushResult
|
|
5071
|
+
function usePush(options?: MaybeSignal<UsePushOptions>): UsePushResult
|
|
4909
5072
|
```
|
|
4910
5073
|
|
|
4911
|
-
- `options` — Hook options.
|
|
5074
|
+
- `options` — Hook options (or a signal of them).
|
|
4912
5075
|
|
|
4913
5076
|
**Returns:** The permission and token as signals and the action functions.
|
|
4914
5077
|
|
|
5078
|
+
#### `useOptimisticToggle(options)`
|
|
5079
|
+
|
|
5080
|
+
Owns the state and save ordering of a follow, favorite, star or subscription control
|
|
5081
|
+
while all markup stays in the component's template. Bind `toggle` straight to the click
|
|
5082
|
+
handler: it takes no argument and flips the value shown now. `commit(desired)` receives
|
|
5083
|
+
the value to SAVE, never the old one, and returns the server's boolean answer. Only the
|
|
5084
|
+
newest failure rolls the shown value back. Call it in an injection context.
|
|
5085
|
+
|
|
5086
|
+
Saves run one at a time; clicks during a save coalesce to the newest desired value. Use
|
|
5087
|
+
`pending` for feedback, not to disable the control or drop a click. Create it only after
|
|
5088
|
+
the record loads, one per record, and keep it through refetches. For a flag with a
|
|
5089
|
+
related count, use `useOptimisticValue` with both fields in one value.
|
|
5090
|
+
|
|
5091
|
+
```typescript
|
|
5092
|
+
function useOptimisticToggle(
|
|
5093
|
+
options: MaybeSignal<UseOptimisticToggleOptions>,
|
|
5094
|
+
): UseOptimisticToggleResult
|
|
5095
|
+
```
|
|
5096
|
+
|
|
5097
|
+
- `options` — The server value, the save and an optional error callback (or a signal of them: a new `value` syncs in while nothing is saving).
|
|
5098
|
+
|
|
5099
|
+
**Returns:** The value, pending and error state as signals, and the stable `toggle`.
|
|
5100
|
+
|
|
4915
5101
|
#### `useProfileForm(options)`
|
|
4916
5102
|
|
|
4917
5103
|
Owns load → edit → submit → publish for the signed-in user's profile. Call
|
|
@@ -5004,12 +5190,20 @@ function useNavigate(): (path: string, options?: NavigateOptions) => void
|
|
|
5004
5190
|
Whether a path is active, re-evaluated on every route change. Call it in an
|
|
5005
5191
|
injection context.
|
|
5006
5192
|
|
|
5193
|
+
The arguments may be signals: the active flag then follows a changed path or
|
|
5194
|
+
`exact` on the same component, the way React re-renders `useIsActive` with
|
|
5195
|
+
new arguments. A signal holding `undefined` for `exact` matches an omitted
|
|
5196
|
+
argument (`false`).
|
|
5197
|
+
|
|
5007
5198
|
```typescript
|
|
5008
|
-
function useIsActive(
|
|
5199
|
+
function useIsActive(
|
|
5200
|
+
path: MaybeSignal<string>,
|
|
5201
|
+
exact?: MaybeSignal<boolean | undefined>,
|
|
5202
|
+
): Signal<boolean>
|
|
5009
5203
|
```
|
|
5010
5204
|
|
|
5011
|
-
- `path` — The path to check.
|
|
5012
|
-
- `exact` — Whether to match exactly (default: `false
|
|
5205
|
+
- `path` — The path to check (or a signal of it).
|
|
5206
|
+
- `exact` — Whether to match exactly (default: `false`, or a signal of it).
|
|
5013
5207
|
|
|
5014
5208
|
**Returns:** A signal of whether the path is active.
|
|
5015
5209
|
|
|
@@ -5032,7 +5226,7 @@ A signed-out visit to a view with `requiresAuth` replaces the entry with
|
|
|
5032
5226
|
|
|
5033
5227
|
```typescript
|
|
5034
5228
|
function useListRoute<Filter extends string = string, Selection extends string = string>(
|
|
5035
|
-
options?:
|
|
5229
|
+
options?: MaybeSignal<ListRouteOptions<Filter, Selection>>,
|
|
5036
5230
|
): UseListRouteResult<Filter, Selection>
|
|
5037
5231
|
```
|
|
5038
5232
|
|
|
@@ -5080,15 +5274,21 @@ loading. `sync` subscribes through the PROVIDER's own change subscription, so
|
|
|
5080
5274
|
a non-browser backend propagates the same way instead of being limited to
|
|
5081
5275
|
the browser `storage` event.
|
|
5082
5276
|
|
|
5277
|
+
The arguments may be signals: a new key then starts over on the same
|
|
5278
|
+
component (the value falls back to the default, loading turns true and the
|
|
5279
|
+
new key is read and subscribed), the way React re-renders `useStorageValue`
|
|
5280
|
+
with a new key. The value, its pending write and any error survive the
|
|
5281
|
+
change, as React's state does.
|
|
5282
|
+
|
|
5083
5283
|
```typescript
|
|
5084
5284
|
function useStorageValue<T>(
|
|
5085
|
-
key: string
|
|
5086
|
-
options?: UseStorageValueOptions<T
|
|
5285
|
+
key: MaybeSignal<string>,
|
|
5286
|
+
options?: MaybeSignal<UseStorageValueOptions<T>>,
|
|
5087
5287
|
): UseStorageValueResult<T>
|
|
5088
5288
|
```
|
|
5089
5289
|
|
|
5090
|
-
- `key` — Storage key.
|
|
5091
|
-
- `options` — Hook options (`defaultValue`, `sync`).
|
|
5290
|
+
- `key` — Storage key (or a signal of it).
|
|
5291
|
+
- `options` — Hook options (`defaultValue`, `sync`), or a signal of them.
|
|
5092
5292
|
|
|
5093
5293
|
**Returns:** The value, its mutators, and the loading/error state as signals.
|
|
5094
5294
|
|
|
@@ -5108,15 +5308,20 @@ Pass `null` for `key` while the real key is unknown (no project selected
|
|
|
5108
5308
|
yet): the hook then behaves as local state around `defaultValue` and
|
|
5109
5309
|
persists nothing.
|
|
5110
5310
|
|
|
5311
|
+
The arguments may be signals: a new key then re-reads and re-subscribes that
|
|
5312
|
+
key on the same component (its old subscription is dropped, hydration
|
|
5313
|
+
converges it), the way React re-renders `useStoragePreference` with a new
|
|
5314
|
+
key. The shown value survives the change, as React's state does.
|
|
5315
|
+
|
|
5111
5316
|
```typescript
|
|
5112
5317
|
function useStoragePreference<T = unknown>(
|
|
5113
|
-
key: string | null | undefined
|
|
5114
|
-
options?: UseStoragePreferenceOptions<T
|
|
5318
|
+
key: MaybeSignal<string | null | undefined>,
|
|
5319
|
+
options?: MaybeSignal<UseStoragePreferenceOptions<T>>,
|
|
5115
5320
|
): UseStoragePreferenceResult<T>
|
|
5116
5321
|
```
|
|
5117
5322
|
|
|
5118
|
-
- `key` — The storage key, or `null` when there is nothing to persist.
|
|
5119
|
-
- `options` — `defaultValue`, reported until the provider supplies one.
|
|
5323
|
+
- `key` — The storage key, or `null` when there is nothing to persist (or a signal of it).
|
|
5324
|
+
- `options` — `defaultValue`, reported until the provider supplies one (or a signal of them).
|
|
5120
5325
|
|
|
5121
5326
|
**Returns:** The current value, its mutators, and whether it is definite yet.
|
|
5122
5327
|
|
|
@@ -5162,12 +5367,21 @@ the state registration. A store minted outside the `state` bond — the direct
|
|
|
5162
5367
|
`createStoreWithActions()` / `createStore()` a provider package exports — is
|
|
5163
5368
|
therefore as valid here as one `@molecule/app-state`'s `createStore()` made.
|
|
5164
5369
|
|
|
5370
|
+
The arguments may be signals: a new store is subscribed in place of the old
|
|
5371
|
+
one (the old subscription is dropped first) and new options are applied on
|
|
5372
|
+
the next read, the way React re-renders `useStore` with new arguments. The
|
|
5373
|
+
previous selected value the equality function compares survives the change,
|
|
5374
|
+
as React's ref does.
|
|
5375
|
+
|
|
5165
5376
|
```typescript
|
|
5166
|
-
function useStore<T, S = T>(
|
|
5377
|
+
function useStore<T, S = T>(
|
|
5378
|
+
store: MaybeSignal<Store<T>>,
|
|
5379
|
+
options?: MaybeSignal<UseStoreOptions<T, S>>,
|
|
5380
|
+
): Signal<S>
|
|
5167
5381
|
```
|
|
5168
5382
|
|
|
5169
|
-
- `store` — The store to subscribe to.
|
|
5170
|
-
- `options` — Hook options (`selector`, `equalityFn`).
|
|
5383
|
+
- `store` — The store to subscribe to (or a signal of it).
|
|
5384
|
+
- `options` — Hook options (`selector`, `equalityFn`), or a signal of them.
|
|
5171
5385
|
|
|
5172
5386
|
**Returns:** A signal of the selected state.
|
|
5173
5387
|
|
|
@@ -5330,11 +5544,14 @@ changes. An `I18nError` is translated through its key (its own message as
|
|
|
5330
5544
|
the default value); a plain `Error` returns its message unchanged; no error
|
|
5331
5545
|
returns `null`. Call it in an injection context.
|
|
5332
5546
|
|
|
5547
|
+
The error may be a signal: the message then follows a changed error on the
|
|
5548
|
+
same component, the way React re-renders `useI18nError` with a new argument.
|
|
5549
|
+
|
|
5333
5550
|
```typescript
|
|
5334
|
-
function useI18nError(error: Error | null | undefined): Signal<string | null>
|
|
5551
|
+
function useI18nError(error: MaybeSignal<Error | null | undefined>): Signal<string | null>
|
|
5335
5552
|
```
|
|
5336
5553
|
|
|
5337
|
-
- `error` — The error to translate, or `null`/`undefined
|
|
5554
|
+
- `error` — The error to translate, or `null`/`undefined` (or a signal of it).
|
|
5338
5555
|
|
|
5339
5556
|
**Returns:** A signal of the error's display text, or `null`.
|
|
5340
5557
|
|
|
@@ -5422,6 +5639,20 @@ function t(key: string, values?: InterpolationValues, options?: TranslateOptions
|
|
|
5422
5639
|
|
|
5423
5640
|
**Returns:** Translated string
|
|
5424
5641
|
|
|
5642
|
+
#### `readMaybeSignal(value)`
|
|
5643
|
+
|
|
5644
|
+
Reads a hook argument's current value. Inside a `computed` or `effect` this
|
|
5645
|
+
TRACKS a signal argument, so the reader re-runs when the argument changes;
|
|
5646
|
+
outside one it is a plain read.
|
|
5647
|
+
|
|
5648
|
+
```typescript
|
|
5649
|
+
function readMaybeSignal<T>(value: MaybeSignal<T>): T
|
|
5650
|
+
```
|
|
5651
|
+
|
|
5652
|
+
- `value` — The argument as the hook received it.
|
|
5653
|
+
|
|
5654
|
+
**Returns:** The argument's current value.
|
|
5655
|
+
|
|
5425
5656
|
#### `provideState(provider)`
|
|
5426
5657
|
|
|
5427
5658
|
Provide state management.
|
|
@@ -5902,7 +6133,7 @@ Peer dependencies:
|
|
|
5902
6133
|
- `@molecule/app-auth` ^3.0.0
|
|
5903
6134
|
- `@molecule/app-code-editor` ^1.0.1
|
|
5904
6135
|
- `@molecule/app-device` ^1.0.1
|
|
5905
|
-
- `@molecule/app-forms` ^2.
|
|
6136
|
+
- `@molecule/app-forms` ^2.4.0
|
|
5906
6137
|
- `@molecule/app-http` ^1.0.1
|
|
5907
6138
|
- `@molecule/app-i18n` ^1.0.1
|
|
5908
6139
|
- `@molecule/app-ide` ^1.0.1
|
|
@@ -5910,7 +6141,7 @@ Peer dependencies:
|
|
|
5910
6141
|
- `@molecule/app-logger` ^1.0.1
|
|
5911
6142
|
- `@molecule/app-platform` ^1.0.1
|
|
5912
6143
|
- `@molecule/app-push` ^1.0.1
|
|
5913
|
-
- `@molecule/app-routing` ^1.
|
|
6144
|
+
- `@molecule/app-routing` ^1.3.0
|
|
5914
6145
|
- `@molecule/app-state` ^1.2.0
|
|
5915
6146
|
- `@molecule/app-storage` ^1.1.1
|
|
5916
6147
|
- `@molecule/app-theme` ^1.0.1
|
|
@@ -5958,6 +6189,10 @@ Peer dependencies:
|
|
|
5958
6189
|
Molecule service whose token was never provided fails at DI time.
|
|
5959
6190
|
Per-concern helpers (`provideAuth`, `provideTheme`, ...) exist for
|
|
5960
6191
|
piecemeal setup.
|
|
6192
|
+
- In-app links use the `Link` directive (`<a molLink="/settings">`, `imports: [Link]`): it
|
|
6193
|
+
navigates through the molecule router with react-router `<Link>`'s click rules. A bare
|
|
6194
|
+
`<a href>` reloads the page; a hand-written `(click)` handler that calls `navigate()`
|
|
6195
|
+
breaks ctrl/cmd-click (new tab) unless it repeats those rules.
|
|
5961
6196
|
|
|
5962
6197
|
## Translations
|
|
5963
6198
|
|