@molecule/app-angular 3.7.2 → 3.9.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.
- package/README.md +265 -126
- package/dist/hooks/use-async.d.ts +3 -1
- package/dist/hooks/use-async.d.ts.map +1 -1
- package/dist/hooks/use-async.js +2 -0
- package/dist/hooks/use-async.js.map +1 -1
- package/dist/hooks/use-auth.d.ts +5 -2
- package/dist/hooks/use-auth.d.ts.map +1 -1
- package/dist/hooks/use-auth.js +5 -2
- package/dist/hooks/use-auth.js.map +1 -1
- package/dist/hooks/use-forms.d.ts +12 -6
- package/dist/hooks/use-forms.d.ts.map +1 -1
- package/dist/hooks/use-forms.js +68 -21
- package/dist/hooks/use-forms.js.map +1 -1
- package/dist/hooks/use-ide.d.ts +10 -8
- package/dist/hooks/use-ide.d.ts.map +1 -1
- package/dist/hooks/use-ide.js.map +1 -1
- package/dist/hooks/use-store.d.ts +18 -1
- package/dist/hooks/use-store.d.ts.map +1 -1
- package/dist/hooks/use-store.js +4 -15
- 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 +43 -10
- package/dist/hooks/use-theme.js.map +1 -1
- package/dist/hooks/use-translation.d.ts +23 -2
- package/dist/hooks/use-translation.d.ts.map +1 -1
- package/dist/hooks/use-translation.js +31 -4
- package/dist/hooks/use-translation.js.map +1 -1
- package/dist/index.d.ts +37 -15
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +37 -15
- package/dist/index.js.map +1 -1
- package/dist/link.d.ts +21 -2
- package/dist/link.d.ts.map +1 -1
- package/dist/link.js +11 -4
- package/dist/link.js.map +1 -1
- package/dist/providers.d.ts.map +1 -1
- package/dist/providers.js +11 -2
- package/dist/providers.js.map +1 -1
- package/dist/services/forms.service.d.ts.map +1 -1
- package/dist/services/forms.service.js +0 -3
- package/dist/services/forms.service.js.map +1 -1
- package/dist/services/promise.service.d.ts +8 -4
- package/dist/services/promise.service.d.ts.map +1 -1
- package/dist/services/promise.service.js +2 -1
- package/dist/services/promise.service.js.map +1 -1
- package/dist/session-ready.d.ts +15 -2
- package/dist/session-ready.d.ts.map +1 -1
- package/dist/session-ready.js +4 -3
- package/dist/session-ready.js.map +1 -1
- package/dist/types.d.ts +12 -10
- package/dist/types.d.ts.map +1 -1
- package/package.json +13 -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-11-
|
|
6
|
+
Generated: 2026-11-21T12:46:14.101Z
|
|
7
7
|
-->
|
|
8
8
|
|
|
9
9
|
# @molecule/app-angular
|
|
@@ -22,28 +22,21 @@ interfaces with Angular's idioms (services, DI, RxJS observables, etc.).
|
|
|
22
22
|
|
|
23
23
|
```typescript
|
|
24
24
|
// main.ts — wire concrete providers into Angular DI:
|
|
25
|
+
import { Component, inject } from '@angular/core'
|
|
25
26
|
import { bootstrapApplication } from '@angular/platform-browser'
|
|
26
|
-
import {
|
|
27
|
+
import {
|
|
28
|
+
MoleculeAuthService,
|
|
29
|
+
MoleculeThemeService,
|
|
30
|
+
provideMolecule,
|
|
31
|
+
t,
|
|
32
|
+
} from '@molecule/app-angular'
|
|
27
33
|
import { createJWTAuthClient } from '@molecule/app-auth'
|
|
28
34
|
import { provider as stateProvider } from '@molecule/app-state-zustand'
|
|
29
35
|
import { provider as themeProvider } from '@molecule/app-theme-css-variables'
|
|
30
36
|
|
|
31
37
|
const authClient = createJWTAuthClient({ baseURL: '/api' })
|
|
32
38
|
|
|
33
|
-
bootstrapApplication(AppComponent, {
|
|
34
|
-
providers: [
|
|
35
|
-
provideMolecule({
|
|
36
|
-
state: stateProvider,
|
|
37
|
-
auth: authClient,
|
|
38
|
-
theme: themeProvider,
|
|
39
|
-
}),
|
|
40
|
-
],
|
|
41
|
-
})
|
|
42
|
-
|
|
43
39
|
// dashboard.component.ts — inject the Molecule services:
|
|
44
|
-
import { Component, inject } from '@angular/core'
|
|
45
|
-
import { MoleculeAuthService, MoleculeThemeService, t } from '@molecule/app-angular'
|
|
46
|
-
|
|
47
40
|
@Component({
|
|
48
41
|
selector: 'app-dashboard',
|
|
49
42
|
template: `
|
|
@@ -56,7 +49,7 @@ import { MoleculeAuthService, MoleculeThemeService, t } from '@molecule/app-angu
|
|
|
56
49
|
</div>
|
|
57
50
|
`,
|
|
58
51
|
})
|
|
59
|
-
class DashboardComponent {
|
|
52
|
+
export class DashboardComponent {
|
|
60
53
|
// Expose the reactive t() so template bindings re-evaluate on locale change.
|
|
61
54
|
protected readonly t = t
|
|
62
55
|
|
|
@@ -70,8 +63,37 @@ class DashboardComponent {
|
|
|
70
63
|
void this.authService.logout()
|
|
71
64
|
}
|
|
72
65
|
}
|
|
66
|
+
|
|
67
|
+
// app.component.ts — the root that mounts the dashboard:
|
|
68
|
+
@Component({
|
|
69
|
+
selector: 'app-root',
|
|
70
|
+
imports: [DashboardComponent],
|
|
71
|
+
template: '<app-dashboard />',
|
|
72
|
+
})
|
|
73
|
+
export class AppComponent {}
|
|
74
|
+
|
|
75
|
+
bootstrapApplication(AppComponent, {
|
|
76
|
+
providers: [
|
|
77
|
+
provideMolecule({
|
|
78
|
+
state: stateProvider,
|
|
79
|
+
auth: authClient,
|
|
80
|
+
theme: themeProvider,
|
|
81
|
+
}),
|
|
82
|
+
],
|
|
83
|
+
})
|
|
73
84
|
```
|
|
74
85
|
|
|
86
|
+
**Session restore:** `useAuth().status === 'loading'` is undecided: wait for
|
|
87
|
+
it and redirect only on `status === 'unauthenticated'`. `'unavailable'` keeps
|
|
88
|
+
the session candidate for retry, but `isAuthenticated` can be false and
|
|
89
|
+
`user` can be null. A restore failure other than 401/403 never signs out.
|
|
90
|
+
`provideMolecule({ auth })` starts the bundled client's restore when a
|
|
91
|
+
consumer first reads the session, so the app entry can mount its root without
|
|
92
|
+
calling `initialize()`. It holds bootstrap — and so every page's first
|
|
93
|
+
render — while a token-only or cookie-only restore is undecided; a cached
|
|
94
|
+
token and user, and a visitor without a session candidate, settle at once.
|
|
95
|
+
Pass `awaitSession: false` to render before the restore settles.
|
|
96
|
+
|
|
75
97
|
## Type
|
|
76
98
|
|
|
77
99
|
`framework`
|
|
@@ -521,6 +543,21 @@ interface FormController<T extends FormValuesConstraint<T> = Record<string, unkn
|
|
|
521
543
|
}
|
|
522
544
|
```
|
|
523
545
|
|
|
546
|
+
#### `FormResetOptions`
|
|
547
|
+
|
|
548
|
+
Options controlling how externally supplied values replace a form's baseline.
|
|
549
|
+
|
|
550
|
+
```typescript
|
|
551
|
+
interface FormResetOptions {
|
|
552
|
+
/**
|
|
553
|
+
* Keep fields whose current value differs from their baseline when `values`
|
|
554
|
+
* changes. Pristine fields still take the new values. False by default, so a
|
|
555
|
+
* new record can replace edits from the previous record.
|
|
556
|
+
*/
|
|
557
|
+
keepDirtyValues?: boolean
|
|
558
|
+
}
|
|
559
|
+
```
|
|
560
|
+
|
|
524
561
|
#### `FormOptions`
|
|
525
562
|
|
|
526
563
|
Form creation options.
|
|
@@ -748,46 +785,21 @@ interface HttpClient {
|
|
|
748
785
|
*/
|
|
749
786
|
getAuthToken(): string | null
|
|
750
787
|
|
|
751
|
-
/**
|
|
752
|
-
* Registers the LIVE token resolver every request of this client reads, or clears it with
|
|
753
|
-
* `null`.
|
|
754
|
-
*
|
|
755
|
-
* `@molecule/app-http`'s `setAuthTokenSource()` calls this on every client it bonds, and the
|
|
756
|
-
* client MUST consult the resolver again each time it assembles a request (and report it from
|
|
757
|
-
* `getAuthToken()`). A session can change with no auth event and no observable state change —
|
|
758
|
-
* `authClient.setSession()` with the same profile data, or the OAuth callback's
|
|
759
|
-
* `setAccessToken()` — so a token pushed only at bond time or on `login`/`logout` events
|
|
760
|
-
* leaves every later request carrying the PREVIOUS session's bearer while the UI shows the
|
|
761
|
-
* new one.
|
|
762
|
-
*
|
|
763
|
-
* The resolved token takes the static token's place, with the same precedence: an
|
|
764
|
-
* `Authorization` header passed per request or in the client's default headers wins over it
|
|
765
|
-
* exactly where it won over a static token in this transport.
|
|
766
|
-
*
|
|
767
|
-
* A resolver that returns `null` (or `undefined`) means "this session has no body token": the
|
|
768
|
-
* request carries no `Authorization` header of the client's own. A cookie-session API issues
|
|
769
|
-
* no bearer, and the server prefers the header over the fresh cookie, so a kept bearer
|
|
770
|
-
* authenticates as the prior — possibly deleted — session.
|
|
771
|
-
*
|
|
772
|
-
* Optional, so an implementation written against the previous interface still conforms.
|
|
773
|
-
* `setAuthTokenSource()` follows such a client through a request interceptor instead, pushing
|
|
774
|
-
* the source with `setAuthToken` before each request: that request carries the change only
|
|
775
|
-
* when the transport applies its token after running its interceptors, so a transport that
|
|
776
|
-
* applies it earlier sends a session adopted mid-page from the following request on.
|
|
777
|
-
*
|
|
778
|
-
* @param resolver - Returns the current access token (or null/undefined), or `null` to clear.
|
|
779
|
-
*/
|
|
788
|
+
/** Registers the LIVE token resolver every request of this client reads, or clears it with `null`. */
|
|
780
789
|
setAuthTokenResolver?(resolver: AuthTokenResolver | null): void
|
|
781
790
|
|
|
782
791
|
/**
|
|
783
|
-
* Registers a handler for authentication errors (401).
|
|
792
|
+
* Registers a handler for authentication errors (401), with the rejected request's metadata.
|
|
784
793
|
*
|
|
794
|
+
* @param handler - Receives the method, URL and credential state of the rejected request.
|
|
785
795
|
* @returns An unsubscribe function.
|
|
786
796
|
*/
|
|
787
|
-
onAuthError(handler: () => void): () => void
|
|
797
|
+
onAuthError(handler: (event: HttpAuthErrorEvent) => void): () => void
|
|
788
798
|
}
|
|
789
799
|
```
|
|
790
800
|
|
|
801
|
+
_(The longest member comment is shortened to its first sentence to fit; the full declaration is in `node_modules/@molecule/app-http/dist/client.d.ts`.)_
|
|
802
|
+
|
|
791
803
|
#### `I18nProvider`
|
|
792
804
|
|
|
793
805
|
i18n provider interface.
|
|
@@ -1327,6 +1339,16 @@ interface Router {
|
|
|
1327
1339
|
*/
|
|
1328
1340
|
generatePath(name: string, params?: RouteParams, query?: QueryParams): string
|
|
1329
1341
|
|
|
1342
|
+
/**
|
|
1343
|
+
* The `href` an anchor to the in-app `path` carries, as the native router's own link
|
|
1344
|
+
* writes it (its base path prefixed, or `#/…` under a hash history), so a middle-click,
|
|
1345
|
+
* a new tab or a copied link opens the same page a click does.
|
|
1346
|
+
*
|
|
1347
|
+
* @param path - Pathname with optional query string and hash, as passed to `navigate`.
|
|
1348
|
+
* @returns The `href`.
|
|
1349
|
+
*/
|
|
1350
|
+
createHref(path: string): string
|
|
1351
|
+
|
|
1330
1352
|
/**
|
|
1331
1353
|
* Subscribes to route changes.
|
|
1332
1354
|
*/
|
|
@@ -1354,6 +1376,31 @@ interface Router {
|
|
|
1354
1376
|
}
|
|
1355
1377
|
```
|
|
1356
1378
|
|
|
1379
|
+
#### `RouterConfig` _(deprecated)_
|
|
1380
|
+
|
|
1381
|
+
> **Deprecated:** Use `BrowserRouterConfig` (`createBrowserRouter`) or `MemoryRouterConfig` (`createMemoryRouter`): each takes only the options it acts on.
|
|
1382
|
+
|
|
1383
|
+
Configuration options for creating a router instance.
|
|
1384
|
+
|
|
1385
|
+
```typescript
|
|
1386
|
+
interface RouterConfig {
|
|
1387
|
+
/**
|
|
1388
|
+
* Router mode.
|
|
1389
|
+
*/
|
|
1390
|
+
mode?: 'history' | 'hash' | 'memory'
|
|
1391
|
+
|
|
1392
|
+
/**
|
|
1393
|
+
* Base path.
|
|
1394
|
+
*/
|
|
1395
|
+
basePath?: string
|
|
1396
|
+
|
|
1397
|
+
/**
|
|
1398
|
+
* Initial routes.
|
|
1399
|
+
*/
|
|
1400
|
+
routes?: RouteDefinition[]
|
|
1401
|
+
}
|
|
1402
|
+
```
|
|
1403
|
+
|
|
1357
1404
|
#### `StoreConfig`
|
|
1358
1405
|
|
|
1359
1406
|
Configuration for creating a store (initial state, optional name, and middleware chain).
|
|
@@ -2084,6 +2131,42 @@ interface UseHttpOptions<T> extends RequestConfig {
|
|
|
2084
2131
|
}
|
|
2085
2132
|
```
|
|
2086
2133
|
|
|
2134
|
+
#### `UseWorkspaceResult`
|
|
2135
|
+
|
|
2136
|
+
What {@link useWorkspace} returns: the workspace state as signals and the layout actions.
|
|
2137
|
+
|
|
2138
|
+
```typescript
|
|
2139
|
+
interface UseWorkspaceResult {
|
|
2140
|
+
/** The current panel layout. */
|
|
2141
|
+
readonly layout: Signal<WorkspaceState['layout']>
|
|
2142
|
+
/** The active panel id, or `null`. */
|
|
2143
|
+
readonly activePanel: Signal<WorkspaceState['activePanel']>
|
|
2144
|
+
/** The collapsed panel ids. */
|
|
2145
|
+
readonly collapsedPanels: Signal<WorkspaceState['collapsedPanels']>
|
|
2146
|
+
/**
|
|
2147
|
+
* Shows or hides one panel.
|
|
2148
|
+
*
|
|
2149
|
+
* @param panelId - The panel to toggle.
|
|
2150
|
+
*/
|
|
2151
|
+
togglePanel: (panelId: PanelId) => void
|
|
2152
|
+
/**
|
|
2153
|
+
* Rewrites one panel's size.
|
|
2154
|
+
*
|
|
2155
|
+
* @param panelId - The panel to resize.
|
|
2156
|
+
* @param size - The new size.
|
|
2157
|
+
*/
|
|
2158
|
+
resizePanel: (panelId: PanelId, size: number) => void
|
|
2159
|
+
/**
|
|
2160
|
+
* Sets the active panel.
|
|
2161
|
+
*
|
|
2162
|
+
* @param panelId - The panel to activate.
|
|
2163
|
+
*/
|
|
2164
|
+
setActivePanel: (panelId: PanelId) => void
|
|
2165
|
+
/** Restores the default layout. */
|
|
2166
|
+
resetLayout: () => void
|
|
2167
|
+
}
|
|
2168
|
+
```
|
|
2169
|
+
|
|
2087
2170
|
#### `UseEditorResult`
|
|
2088
2171
|
|
|
2089
2172
|
What {@link useEditor} returns: the tab list and active file as signals and
|
|
@@ -2704,6 +2787,18 @@ interface UseStoreOptions<T, S = T> {
|
|
|
2704
2787
|
}
|
|
2705
2788
|
```
|
|
2706
2789
|
|
|
2790
|
+
#### `SelectingStoreOptions`
|
|
2791
|
+
|
|
2792
|
+
Options for {@link useStore} that pick part of the store: a selector is
|
|
2793
|
+
required, so the selected type `S` always comes from it.
|
|
2794
|
+
|
|
2795
|
+
```typescript
|
|
2796
|
+
interface SelectingStoreOptions<T, S> extends UseStoreOptions<T, S> {
|
|
2797
|
+
/** Picks the value the hook returns from the store's state. */
|
|
2798
|
+
selector: (state: T) => S
|
|
2799
|
+
}
|
|
2800
|
+
```
|
|
2801
|
+
|
|
2707
2802
|
#### `UseThemeResult`
|
|
2708
2803
|
|
|
2709
2804
|
What {@link useTheme} returns: the current theme, its name and mode as
|
|
@@ -2735,6 +2830,11 @@ interface UseTranslationResult {
|
|
|
2735
2830
|
* method itself) that reads the provider on every call AND the locale
|
|
2736
2831
|
* notifications signal, so a template, `computed` or `effect` that calls it
|
|
2737
2832
|
* re-runs on a locale switch the way React re-renders on one.
|
|
2833
|
+
*
|
|
2834
|
+
* Its identity follows the active locale, like React's `useTranslation().t`:
|
|
2835
|
+
* a value memoized on it (a `computed`, a child bound `t` as an input)
|
|
2836
|
+
* refreshes after a switch, while an `addTranslations` for the same locale
|
|
2837
|
+
* keeps it. `useT()` is the one-identity form.
|
|
2738
2838
|
*/
|
|
2739
2839
|
readonly t: I18nProvider['t']
|
|
2740
2840
|
/** The active locale code. */
|
|
@@ -2849,6 +2949,24 @@ interface UseVersionResult {
|
|
|
2849
2949
|
}
|
|
2850
2950
|
```
|
|
2851
2951
|
|
|
2952
|
+
#### `LinkProps`
|
|
2953
|
+
|
|
2954
|
+
The inputs {@link Link} takes: `@molecule/app-react`'s `LinkProps` for an
|
|
2955
|
+
Angular directive. React's `to` is the directive's own attribute,
|
|
2956
|
+
`molLink`; every other anchor attribute (`class`, `target`, `rel`) is
|
|
2957
|
+
written on the `<a>` as usual.
|
|
2958
|
+
|
|
2959
|
+
```typescript
|
|
2960
|
+
interface LinkProps {
|
|
2961
|
+
/** The destination: an app path or a URL (React's `to`). */
|
|
2962
|
+
molLink: string
|
|
2963
|
+
/** Replace the current history entry instead of pushing one. */
|
|
2964
|
+
replace?: boolean
|
|
2965
|
+
/** State stored with the new history entry. */
|
|
2966
|
+
state?: unknown
|
|
2967
|
+
}
|
|
2968
|
+
```
|
|
2969
|
+
|
|
2852
2970
|
#### `AsyncStateManager`
|
|
2853
2971
|
|
|
2854
2972
|
Async state manager.
|
|
@@ -3045,18 +3163,16 @@ interface PlatformService {
|
|
|
3045
3163
|
Promise state manager.
|
|
3046
3164
|
|
|
3047
3165
|
```typescript
|
|
3048
|
-
interface PromiseStateManager<T> {
|
|
3166
|
+
interface PromiseStateManager<T, Args extends unknown[] = unknown[]> {
|
|
3049
3167
|
state$: Observable<PromiseState<T>>
|
|
3050
3168
|
getState: () => PromiseState<T>
|
|
3051
|
-
call: (...args:
|
|
3169
|
+
call: (...args: Args) => Promise<T>
|
|
3052
3170
|
cancel: (message?: string) => void
|
|
3053
3171
|
reset: () => void
|
|
3054
3172
|
destroy: () => void
|
|
3055
3173
|
}
|
|
3056
3174
|
```
|
|
3057
3175
|
|
|
3058
|
-
**Returns:** The result.
|
|
3059
|
-
|
|
3060
3176
|
#### `PushService`
|
|
3061
3177
|
|
|
3062
3178
|
Push service interface.
|
|
@@ -3127,6 +3243,22 @@ interface VersionService {
|
|
|
3127
3243
|
}
|
|
3128
3244
|
```
|
|
3129
3245
|
|
|
3246
|
+
#### `SessionReadyProps`
|
|
3247
|
+
|
|
3248
|
+
The content {@link SessionReady} takes. React passes these nodes as the
|
|
3249
|
+
`children` and `fallback` props; an Angular component takes nodes as
|
|
3250
|
+
projected content, so `children` is the content and `fallback` is the
|
|
3251
|
+
element marked `slot="fallback"`.
|
|
3252
|
+
|
|
3253
|
+
```typescript
|
|
3254
|
+
interface SessionReadyProps {
|
|
3255
|
+
/** What renders once the initial restore settles (projected content). */
|
|
3256
|
+
children?: unknown
|
|
3257
|
+
/** What renders while the session restore is still undecided (the `[slot=fallback]` element). */
|
|
3258
|
+
fallback?: unknown
|
|
3259
|
+
}
|
|
3260
|
+
```
|
|
3261
|
+
|
|
3130
3262
|
#### `MoleculeModuleConfig`
|
|
3131
3263
|
|
|
3132
3264
|
Configuration for molecule Angular module.
|
|
@@ -3137,13 +3269,15 @@ interface MoleculeModuleConfig {
|
|
|
3137
3269
|
auth?: AuthClient<unknown>
|
|
3138
3270
|
/**
|
|
3139
3271
|
* Hold bootstrap (and so every page's first render) until `auth` has decided the
|
|
3140
|
-
* session.
|
|
3141
|
-
* Until it answers, a public page's
|
|
3142
|
-
* redirect to `/login`)
|
|
3143
|
-
*
|
|
3144
|
-
*
|
|
3145
|
-
* null user. A visitor with no
|
|
3146
|
-
* a request.
|
|
3272
|
+
* session. Defaults to true, as React's `MoleculeProvider` does. A token-only or
|
|
3273
|
+
* cookie-only restore makes a current-user request. Until it answers, a public page's
|
|
3274
|
+
* signed-in action (`if (!user) return`, a redirect to `/login`) treats a signed-in
|
|
3275
|
+
* visitor as signed out. Angular's app initializer waits only while status is
|
|
3276
|
+
* `'loading'`, so a cached session renders while its verification continues in the
|
|
3277
|
+
* background. `'unavailable'` also renders and may have a null user. A visitor with no
|
|
3278
|
+
* session candidate settles synchronously without a request. While the initializer
|
|
3279
|
+
* waits, the page shows whatever the app root holds in `index.html` (Angular has no
|
|
3280
|
+
* `sessionFallback`). Set false to render at once. Ignored without `auth`.
|
|
3147
3281
|
*/
|
|
3148
3282
|
awaitSession?: boolean
|
|
3149
3283
|
theme?: ThemeProvider
|
|
@@ -3271,6 +3405,31 @@ previous value.
|
|
|
3271
3405
|
type FormSetState<T> = (value: T | ((previous: T) => T)) => void
|
|
3272
3406
|
```
|
|
3273
3407
|
|
|
3408
|
+
#### `UseTShorthandOptions`
|
|
3409
|
+
|
|
3410
|
+
Options for the shorthand form of {@link UseTFunction}: the fallback text is
|
|
3411
|
+
passed positionally, so only `count` remains here.
|
|
3412
|
+
|
|
3413
|
+
```typescript
|
|
3414
|
+
type UseTShorthandOptions = Omit<TranslateOptions, 'defaultValue'>
|
|
3415
|
+
```
|
|
3416
|
+
|
|
3417
|
+
#### `UseTFunction`
|
|
3418
|
+
|
|
3419
|
+
The translation function {@link useT} returns.
|
|
3420
|
+
|
|
3421
|
+
Two compatible call forms:
|
|
3422
|
+
|
|
3423
|
+
- `t(key, values?, options?)` — the {@link I18nProvider.t} signature.
|
|
3424
|
+
- `t(key, fallback, options?)` — a string second argument is the inline
|
|
3425
|
+
English `defaultValue`, with optional `count` for pluralization.
|
|
3426
|
+
|
|
3427
|
+
```typescript
|
|
3428
|
+
type UseTFunction = I18nProvider['t'] & {
|
|
3429
|
+
(key: string, fallback: string, options?: UseTShorthandOptions): string
|
|
3430
|
+
}
|
|
3431
|
+
```
|
|
3432
|
+
|
|
3274
3433
|
#### `VerifyPaymentReturnStatus`
|
|
3275
3434
|
|
|
3276
3435
|
How far the return-page verification has got.
|
|
@@ -3314,10 +3473,13 @@ that calls `navigate()`. Needs the router from `provideMolecule({ router })`.
|
|
|
3314
3473
|
selector: 'a[molLink]',
|
|
3315
3474
|
standalone: true,
|
|
3316
3475
|
inputs: ['molLink', 'replace', 'state'],
|
|
3317
|
-
host: { '[attr.href]': '
|
|
3476
|
+
host: { '[attr.href]': 'href' },
|
|
3318
3477
|
})
|
|
3319
|
-
export class Link implements OnInit {
|
|
3320
|
-
/**
|
|
3478
|
+
export class Link implements OnInit, LinkProps {
|
|
3479
|
+
/**
|
|
3480
|
+
* The destination: an app path (`/settings?tab=billing#plan`) or a URL. An app path's `href` is
|
|
3481
|
+
* the one the router writes for it (`routerLinkHref`), base path included.
|
|
3482
|
+
*/
|
|
3321
3483
|
molLink = ''
|
|
3322
3484
|
/** Replace the current history entry instead of pushing one. */
|
|
3323
3485
|
replace?: boolean
|
|
@@ -3325,6 +3487,11 @@ export class Link implements OnInit {
|
|
|
3325
3487
|
state?: unknown
|
|
3326
3488
|
|
|
3327
3489
|
private readonly router = useRouterInstance()
|
|
3490
|
+
|
|
3491
|
+
/** The anchor's `href`: the one the router writes for an app path, base path included. */
|
|
3492
|
+
get href(): string {
|
|
3493
|
+
return routerLinkHref(this.molLink, this.router)
|
|
3494
|
+
}
|
|
3328
3495
|
private readonly element = inject<ElementRef<HTMLAnchorElement>>(ElementRef)
|
|
3329
3496
|
private readonly renderer = inject(Renderer2)
|
|
3330
3497
|
private readonly destroyRef = inject(DestroyRef)
|
|
@@ -3603,8 +3770,7 @@ class MoleculeFormInstance<T extends FormValuesConstraint<T>> {
|
|
|
3603
3770
|
* @param value - The new value to set for the field.
|
|
3604
3771
|
*/
|
|
3605
3772
|
setValue<K extends keyof T>(name: K, value: T[K]): void {
|
|
3606
|
-
|
|
3607
|
-
this.controller.setValue(name as any, value as any)
|
|
3773
|
+
this.controller.setValue(name as string, value)
|
|
3608
3774
|
}
|
|
3609
3775
|
|
|
3610
3776
|
/**
|
|
@@ -3614,8 +3780,7 @@ class MoleculeFormInstance<T extends FormValuesConstraint<T>> {
|
|
|
3614
3780
|
* @returns The error message for the field, or `undefined` if the field has no error.
|
|
3615
3781
|
*/
|
|
3616
3782
|
getError(name: keyof T): string | undefined {
|
|
3617
|
-
|
|
3618
|
-
return this.controller.getError(name as any)
|
|
3783
|
+
return this.controller.getError(name as string)
|
|
3619
3784
|
}
|
|
3620
3785
|
|
|
3621
3786
|
/**
|
|
@@ -3626,8 +3791,7 @@ class MoleculeFormInstance<T extends FormValuesConstraint<T>> {
|
|
|
3626
3791
|
*/
|
|
3627
3792
|
setError(name: keyof T, error: string | undefined): void {
|
|
3628
3793
|
if (error !== undefined) {
|
|
3629
|
-
|
|
3630
|
-
this.controller.setError(name as any, error)
|
|
3794
|
+
this.controller.setError(name as string, error)
|
|
3631
3795
|
} else {
|
|
3632
3796
|
this.controller.clearError(name)
|
|
3633
3797
|
}
|
|
@@ -4571,8 +4735,9 @@ Until it answers, `useAuth().user` is `null` everywhere, so a
|
|
|
4571
4735
|
public page that renders a signed-in action at once lets that action run
|
|
4572
4736
|
against "signed out": a Follow button whose handler starts with
|
|
4573
4737
|
`if (!user) return` ignores the click, one that redirects to `/login` signs
|
|
4574
|
-
the visitor out of the flow.
|
|
4575
|
-
|
|
4738
|
+
the visitor out of the flow. `provideMolecule({ auth })` holds bootstrap for
|
|
4739
|
+
that by default; wrap the routes in this component where an app passes
|
|
4740
|
+
`awaitSession: false`, so every page's first render reads the restored user
|
|
4576
4741
|
when restoration succeeds.
|
|
4577
4742
|
|
|
4578
4743
|
A visitor with no session candidate settles synchronously without a
|
|
@@ -4695,12 +4860,9 @@ state, so it is not proof that an outstanding request has stopped. Use an
|
|
|
4695
4860
|
app-owned queue when every click must be accepted in order.
|
|
4696
4861
|
|
|
4697
4862
|
```typescript
|
|
4698
|
-
function usePromise<
|
|
4699
|
-
asyncFn:
|
|
4700
|
-
): [
|
|
4701
|
-
UsePromiseState<Awaited<ReturnType<T>>>,
|
|
4702
|
-
(...args: Parameters<T>) => Promise<Awaited<ReturnType<T>>>,
|
|
4703
|
-
]
|
|
4863
|
+
function usePromise<V, A extends unknown[]>(
|
|
4864
|
+
asyncFn: (...args: A) => Promise<V>,
|
|
4865
|
+
): [UsePromiseState<V>, (...args: A) => Promise<V>]
|
|
4704
4866
|
```
|
|
4705
4867
|
|
|
4706
4868
|
- `asyncFn` — The async function to wrap.
|
|
@@ -4849,8 +5011,11 @@ function useAuthClient<
|
|
|
4849
5011
|
Authentication state and actions. Call it in an injection context (a
|
|
4850
5012
|
component field initializer or constructor).
|
|
4851
5013
|
|
|
4852
|
-
`status === 'loading'` is undecided
|
|
4853
|
-
|
|
5014
|
+
`status === 'loading'` is undecided: wait for it and redirect only on
|
|
5015
|
+
`status === 'unauthenticated'`. `'unavailable'` keeps the session candidate
|
|
5016
|
+
for retry, but `isAuthenticated` can be false and `user` can be null while a
|
|
5017
|
+
token/cookie-only restore has no cached profile. A restore failure other than
|
|
5018
|
+
401/403 never signs out.
|
|
4854
5019
|
|
|
4855
5020
|
The options may be a signal: `autoRefresh` turning on through it probes once
|
|
4856
5021
|
(when the visitor is signed out and decided), the way React re-renders
|
|
@@ -4916,15 +5081,18 @@ function useForm<T extends FormValuesConstraint<T> = Record<string, unknown>>(
|
|
|
4916
5081
|
|
|
4917
5082
|
Watches one field's value. Call it in an injection context.
|
|
4918
5083
|
|
|
5084
|
+
The controller and name may be signals, so a new controller or field is
|
|
5085
|
+
followed the way React re-renders `useWatch` with new arguments.
|
|
5086
|
+
|
|
4919
5087
|
```typescript
|
|
4920
5088
|
function useWatch<T extends FormValuesConstraint<T>, K extends keyof T>(
|
|
4921
|
-
form: FormController<T
|
|
4922
|
-
name: K
|
|
5089
|
+
form: MaybeSignal<FormController<T>>,
|
|
5090
|
+
name: MaybeSignal<K>,
|
|
4923
5091
|
): Signal<T[K]>
|
|
4924
5092
|
```
|
|
4925
5093
|
|
|
4926
|
-
- `form` — Form controller.
|
|
4927
|
-
- `name` — Field name to watch.
|
|
5094
|
+
- `form` — Form controller (or a signal of it).
|
|
5095
|
+
- `name` — Field name to watch (or a signal of it).
|
|
4928
5096
|
|
|
4929
5097
|
**Returns:** The current field value as a signal.
|
|
4930
5098
|
|
|
@@ -4932,15 +5100,18 @@ function useWatch<T extends FormValuesConstraint<T>, K extends keyof T>(
|
|
|
4932
5100
|
|
|
4933
5101
|
Reads one field's state. Call it in an injection context.
|
|
4934
5102
|
|
|
5103
|
+
The controller and name may be signals, so a new controller or field is
|
|
5104
|
+
followed the way React re-renders `useFieldState` with new arguments.
|
|
5105
|
+
|
|
4935
5106
|
```typescript
|
|
4936
5107
|
function useFieldState<T extends FormValuesConstraint<T>>(
|
|
4937
|
-
form: FormController<T
|
|
4938
|
-
name: keyof T
|
|
5108
|
+
form: MaybeSignal<FormController<T>>,
|
|
5109
|
+
name: MaybeSignal<keyof T>,
|
|
4939
5110
|
): Signal<FieldState<T[keyof T]>>
|
|
4940
5111
|
```
|
|
4941
5112
|
|
|
4942
|
-
- `form` — Form controller.
|
|
4943
|
-
- `name` — Field name.
|
|
5113
|
+
- `form` — Form controller (or a signal of it).
|
|
5114
|
+
- `name` — Field name (or a signal of it).
|
|
4944
5115
|
|
|
4945
5116
|
**Returns:** The field state as a signal.
|
|
4946
5117
|
|
|
@@ -5086,35 +5257,7 @@ IDE workspace layout management. Call it in an injection context (a
|
|
|
5086
5257
|
component field initializer or constructor).
|
|
5087
5258
|
|
|
5088
5259
|
```typescript
|
|
5089
|
-
function useWorkspace():
|
|
5090
|
-
/** The current panel layout. */
|
|
5091
|
-
readonly layout: Signal<WorkspaceState['layout']>
|
|
5092
|
-
/** The active panel id, or `null`. */
|
|
5093
|
-
readonly activePanel: Signal<WorkspaceState['activePanel']>
|
|
5094
|
-
/** The collapsed panel ids. */
|
|
5095
|
-
readonly collapsedPanels: Signal<WorkspaceState['collapsedPanels']>
|
|
5096
|
-
/**
|
|
5097
|
-
* Shows or hides one panel.
|
|
5098
|
-
*
|
|
5099
|
-
* @param panelId - The panel to toggle.
|
|
5100
|
-
*/
|
|
5101
|
-
togglePanel: (panelId: PanelId) => void
|
|
5102
|
-
/**
|
|
5103
|
-
* Rewrites one panel's size.
|
|
5104
|
-
*
|
|
5105
|
-
* @param panelId - The panel to resize.
|
|
5106
|
-
* @param size - The new size.
|
|
5107
|
-
*/
|
|
5108
|
-
resizePanel: (panelId: PanelId, size: number) => void
|
|
5109
|
-
/**
|
|
5110
|
-
* Sets the active panel.
|
|
5111
|
-
*
|
|
5112
|
-
* @param panelId - The panel to activate.
|
|
5113
|
-
*/
|
|
5114
|
-
setActivePanel: (panelId: PanelId) => void
|
|
5115
|
-
/** Restores the default layout. */
|
|
5116
|
-
resetLayout: () => void
|
|
5117
|
-
}
|
|
5260
|
+
function useWorkspace(): UseWorkspaceResult
|
|
5118
5261
|
```
|
|
5119
5262
|
|
|
5120
5263
|
**Returns:** The workspace state as signals and the layout actions.
|
|
@@ -5581,10 +5724,10 @@ previous selected value the equality function compares survives the change,
|
|
|
5581
5724
|
as React's ref does.
|
|
5582
5725
|
|
|
5583
5726
|
```typescript
|
|
5584
|
-
function useStore<T
|
|
5727
|
+
function useStore<T>(
|
|
5585
5728
|
store: MaybeSignal<Store<T>>,
|
|
5586
|
-
options?: MaybeSignal<UseStoreOptions<T,
|
|
5587
|
-
): Signal<
|
|
5729
|
+
options?: MaybeSignal<UseStoreOptions<T, T>>,
|
|
5730
|
+
): Signal<T>
|
|
5588
5731
|
```
|
|
5589
5732
|
|
|
5590
5733
|
- `store` — The store to subscribe to (or a signal of it).
|
|
@@ -5715,11 +5858,7 @@ Call it in either of two compatible forms:
|
|
|
5715
5858
|
`defaultValue`.
|
|
5716
5859
|
|
|
5717
5860
|
```typescript
|
|
5718
|
-
function useT():
|
|
5719
|
-
key: string,
|
|
5720
|
-
valuesOrDefault?: InterpolationValues | string,
|
|
5721
|
-
options?: TranslateOptions,
|
|
5722
|
-
) => string
|
|
5861
|
+
function useT(): UseTFunction
|
|
5723
5862
|
```
|
|
5724
5863
|
|
|
5725
5864
|
**Returns:** The translation function.
|
|
@@ -6126,9 +6265,9 @@ function createPlatformService(): PlatformService
|
|
|
6126
6265
|
Creates a promise state manager for tracking async function state.
|
|
6127
6266
|
|
|
6128
6267
|
```typescript
|
|
6129
|
-
function createPromiseState<
|
|
6130
|
-
asyncFn: T
|
|
6131
|
-
): PromiseStateManager<
|
|
6268
|
+
function createPromiseState<Args extends unknown[], T>(
|
|
6269
|
+
asyncFn: (...args: Args) => Promise<T>,
|
|
6270
|
+
): PromiseStateManager<T, Args>
|
|
6132
6271
|
```
|
|
6133
6272
|
|
|
6134
6273
|
- `asyncFn` — The async function to track
|
|
@@ -6348,7 +6487,7 @@ Peer dependencies:
|
|
|
6348
6487
|
- `@molecule/app-logger` ^1.0.1
|
|
6349
6488
|
- `@molecule/app-platform` ^1.0.1
|
|
6350
6489
|
- `@molecule/app-push` ^1.0.1
|
|
6351
|
-
- `@molecule/app-routing` ^1.
|
|
6490
|
+
- `@molecule/app-routing` ^1.4.0
|
|
6352
6491
|
- `@molecule/app-state` ^1.2.0
|
|
6353
6492
|
- `@molecule/app-storage` ^1.1.1
|
|
6354
6493
|
- `@molecule/app-theme` ^1.0.1
|
|
@@ -45,11 +45,13 @@ export interface UsePromiseState<T> {
|
|
|
45
45
|
* state, so it is not proof that an outstanding request has stopped. Use an
|
|
46
46
|
* app-owned queue when every click must be accepted in order.
|
|
47
47
|
*
|
|
48
|
+
* @template V - What the async function resolves with.
|
|
49
|
+
* @template A - The async function's parameters.
|
|
48
50
|
* @param asyncFn - The async function to wrap.
|
|
49
51
|
* @returns A tuple of `[state, wrappedFunction]`; the state object is updated
|
|
50
52
|
* in place for this instance's lifetime.
|
|
51
53
|
*/
|
|
52
|
-
export declare const usePromise: <
|
|
54
|
+
export declare const usePromise: <V, A extends unknown[]>(asyncFn: (...args: A) => Promise<V>) => [UsePromiseState<V>, (...args: A) => Promise<V>];
|
|
53
55
|
/**
|
|
54
56
|
* An async-capable setState function: a value, an updater receiving the
|
|
55
57
|
* previous state, or a promise resolving to either. Errors from a resolved
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-async.d.ts","sourceRoot":"","sources":["../../src/hooks/use-async.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAwC,KAAK,MAAM,EAAa,MAAM,eAAe,CAAA;AAE5F,OAAO,KAAK,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAA;AAElF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AAE5D,OAAO,EAAE,KAAK,WAAW,EAAmB,MAAM,oBAAoB,CAAA;AAGtE;;;;GAIG;AACH,MAAM,WAAW,eAAe,CAAC,CAAC;IAChC,2DAA2D;IAC3D,MAAM,EAAE,aAAa,CAAA;IACrB,gFAAgF;IAChF,KAAK,EAAE,CAAC,GAAG,IAAI,CAAA;IACf,2EAA2E;IAC3E,KAAK,EAAE,KAAK,GAAG,IAAI,CAAA;IACnB,m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AAC,KAC9C,wBAAwB,CAAC,CAAC,CA6C5B,CAAA"}
|
package/dist/hooks/use-async.js
CHANGED
|
@@ -28,6 +28,8 @@ import { useExternalStore } from './external-store.js';
|
|
|
28
28
|
* state, so it is not proof that an outstanding request has stopped. Use an
|
|
29
29
|
* app-owned queue when every click must be accepted in order.
|
|
30
30
|
*
|
|
31
|
+
* @template V - What the async function resolves with.
|
|
32
|
+
* @template A - The async function's parameters.
|
|
31
33
|
* @param asyncFn - The async function to wrap.
|
|
32
34
|
* @returns A tuple of `[state, wrappedFunction]`; the state object is updated
|
|
33
35
|
* in place for this instance's lifetime.
|