@molecule/app-react 1.10.2 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +108 -16
- package/dist/hooks/useTranslation.d.ts +25 -3
- package/dist/hooks/useTranslation.d.ts.map +1 -1
- package/dist/hooks/useTranslation.js +89 -18
- package/dist/hooks/useTranslation.js.map +1 -1
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +21 -2
- package/dist/types.d.ts.map +1 -1
- package/package.json +7 -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-10-
|
|
6
|
+
Generated: 2026-10-25T20:03:36.228Z
|
|
7
7
|
-->
|
|
8
8
|
|
|
9
9
|
# @molecule/app-react
|
|
@@ -250,9 +250,12 @@ interface AuthClient<T = UserProfile, TRegister extends RegisterExtraShape<TRegi
|
|
|
250
250
|
confirmPasswordReset(data: PasswordResetConfirm): Promise<void>;
|
|
251
251
|
/**
|
|
252
252
|
* Updates the current user's profile.
|
|
253
|
-
* Returns the saved
|
|
254
|
-
*
|
|
255
|
-
*
|
|
253
|
+
* Returns the saved profile: the answer applied onto the signed-in user field
|
|
254
|
+
* by field, with or without an `id` — a field it carries replaces the value
|
|
255
|
+
* (`null` clears it), one it omits or leaves `undefined` is kept, so a field
|
|
256
|
+
* cleared by omission must arrive as `null`. A non-object answer is returned
|
|
257
|
+
* as it came. An answer for a replaced or ended session leaves the current one
|
|
258
|
+
* untouched.
|
|
256
259
|
*/
|
|
257
260
|
updateProfile(data: Partial<T>): Promise<T>;
|
|
258
261
|
/**
|
|
@@ -308,9 +311,6 @@ interface AuthClient<T = UserProfile, TRegister extends RegisterExtraShape<TRegi
|
|
|
308
311
|
* Resolves when the session restore started by `initialize()` has settled — the point
|
|
309
312
|
* after which the client knows whether this visitor is signed in.
|
|
310
313
|
*
|
|
311
|
-
* Resolves IMMEDIATELY when no restore is in flight: before `initialize()` is ever
|
|
312
|
-
* called, and after it has finished. A restore that failed resolves too (it settled the
|
|
313
|
-
* question), so an HTTP client can await this before every request without risking one
|
|
314
314
|
// … truncated — the full declaration is in node_modules/@molecule/app-react/dist
|
|
315
315
|
```
|
|
316
316
|
|
|
@@ -518,12 +518,50 @@ interface HttpClient {
|
|
|
518
518
|
addErrorInterceptor(interceptor: ErrorInterceptor): () => void
|
|
519
519
|
/**
|
|
520
520
|
* Sets the authorization token.
|
|
521
|
+
*
|
|
522
|
+
* A static token: every request carries it until the next `setAuthToken` call. A client
|
|
523
|
+
* that has a {@link HttpClient.setAuthTokenResolver | resolver} (registered through
|
|
524
|
+
* `@molecule/app-http`'s `setAuthTokenSource`) ignores this value when it assembles a
|
|
525
|
+
* request — the resolver IS the session, and reading it per request is what keeps a
|
|
526
|
+
* session adopted without an auth event from sending the previous account's bearer. Once
|
|
527
|
+
* the resolver is removed, the static token is sent again.
|
|
521
528
|
*/
|
|
522
529
|
setAuthToken(token: string | null): void
|
|
523
530
|
/**
|
|
524
|
-
* Returns the
|
|
531
|
+
* Returns the token the client applies to its next request: the resolver's answer when one
|
|
532
|
+
* is registered, else the static token from `setAuthToken`.
|
|
525
533
|
*/
|
|
526
534
|
getAuthToken(): string | null
|
|
535
|
+
/**
|
|
536
|
+
* Registers the LIVE token resolver every request of this client reads, or clears it with
|
|
537
|
+
* `null`.
|
|
538
|
+
*
|
|
539
|
+
* `@molecule/app-http`'s `setAuthTokenSource()` calls this on every client it bonds, and the
|
|
540
|
+
* client MUST consult the resolver again each time it assembles a request (and report it from
|
|
541
|
+
* `getAuthToken()`). A session can change with no auth event and no observable state change —
|
|
542
|
+
* `authClient.setSession()` with the same profile data, or the OAuth callback's
|
|
543
|
+
* `setAccessToken()` — so a token pushed only at bond time or on `login`/`logout` events
|
|
544
|
+
* leaves every later request carrying the PREVIOUS session's bearer while the UI shows the
|
|
545
|
+
* new one.
|
|
546
|
+
*
|
|
547
|
+
* The resolved token takes the static token's place, with the same precedence: an
|
|
548
|
+
* `Authorization` header passed per request or in the client's default headers wins over it
|
|
549
|
+
* exactly where it won over a static token in this transport.
|
|
550
|
+
*
|
|
551
|
+
* A resolver that returns `null` (or `undefined`) means "this session has no body token": the
|
|
552
|
+
* request carries no `Authorization` header of the client's own. A cookie-session API issues
|
|
553
|
+
* no bearer, and the server prefers the header over the fresh cookie, so a kept bearer
|
|
554
|
+
* authenticates as the prior — possibly deleted — session.
|
|
555
|
+
*
|
|
556
|
+
* Optional, so an implementation written against the previous interface still conforms.
|
|
557
|
+
* `setAuthTokenSource()` follows such a client through a request interceptor instead, pushing
|
|
558
|
+
* the source with `setAuthToken` before each request: that request carries the change only
|
|
559
|
+
* when the transport applies its token after running its interceptors, so a transport that
|
|
560
|
+
* applies it earlier sends a session adopted mid-page from the following request on.
|
|
561
|
+
*
|
|
562
|
+
* @param resolver - Returns the current access token (or null/undefined), or `null` to clear.
|
|
563
|
+
*/
|
|
564
|
+
setAuthTokenResolver?(resolver: AuthTokenResolver | null): void
|
|
527
565
|
/**
|
|
528
566
|
* Registers a handler for authentication errors (401).
|
|
529
567
|
*
|
|
@@ -1418,7 +1456,7 @@ interface UseAuthResult<
|
|
|
1418
1456
|
*
|
|
1419
1457
|
* `setUser` alone does NOT sign the client in, and `setAccessToken` changes
|
|
1420
1458
|
* storage only — using those two for a caller-issued session leaves every
|
|
1421
|
-
* `authenticated` read signed out
|
|
1459
|
+
* `authenticated` read signed out.
|
|
1422
1460
|
*/
|
|
1423
1461
|
setSession: AuthClient<T>['setSession']
|
|
1424
1462
|
isAuthenticated: boolean
|
|
@@ -1816,6 +1854,34 @@ How far the return-page verification has got.
|
|
|
1816
1854
|
type VerifyPaymentReturnStatus = 'idle' | 'verifying' | 'verified' | 'failed'
|
|
1817
1855
|
```
|
|
1818
1856
|
|
|
1857
|
+
#### `UseTShorthandOptions`
|
|
1858
|
+
|
|
1859
|
+
Options for the shorthand form of {@link UseTFunction}: the fallback text is
|
|
1860
|
+
passed positionally, so only `count` remains here.
|
|
1861
|
+
|
|
1862
|
+
```typescript
|
|
1863
|
+
type UseTShorthandOptions = Omit<TranslateOptions, 'defaultValue'>
|
|
1864
|
+
```
|
|
1865
|
+
|
|
1866
|
+
#### `UseTFunction`
|
|
1867
|
+
|
|
1868
|
+
Translation function returned by `useT()`.
|
|
1869
|
+
|
|
1870
|
+
Two compatible call forms:
|
|
1871
|
+
|
|
1872
|
+
- `t(key, values?, options?)` — the {@link I18nProvider.t} signature.
|
|
1873
|
+
- `t(key, fallback, options?)` — a string second argument is the inline
|
|
1874
|
+
English `defaultValue`, with optional `count` for pluralization.
|
|
1875
|
+
|
|
1876
|
+
Its identity is stable while the i18n provider instance is unchanged, so it
|
|
1877
|
+
can be used directly as an effect dependency.
|
|
1878
|
+
|
|
1879
|
+
```typescript
|
|
1880
|
+
type UseTFunction = I18nProvider['t'] & {
|
|
1881
|
+
(key: string, fallback: string, options?: UseTShorthandOptions): string
|
|
1882
|
+
}
|
|
1883
|
+
```
|
|
1884
|
+
|
|
1819
1885
|
### Functions
|
|
1820
1886
|
|
|
1821
1887
|
#### `resetAIModelsCache()`
|
|
@@ -2651,15 +2717,32 @@ function useTranslation(): UseTranslationResult
|
|
|
2651
2717
|
|
|
2652
2718
|
Hook to get just the translation function.
|
|
2653
2719
|
|
|
2720
|
+
The returned function keeps ONE identity for as long as the provider
|
|
2721
|
+
instance is unchanged, so it is safe as an effect dependency: an effect
|
|
2722
|
+
written as `useEffect(..., [t])` does not re-run on ordinary re-renders or on
|
|
2723
|
+
a locale change. The hook still re-renders the calling component on every
|
|
2724
|
+
locale notification (including `addTranslations` for the active locale), so
|
|
2725
|
+
text it reads while rendering is current. A value memoized on `[t]` alone
|
|
2726
|
+
keeps the old text after a locale switch: `useMemo(() => t(...), [t])`, or a
|
|
2727
|
+
`React.memo` child that receives `t` as a prop. Call `useT()` inside that
|
|
2728
|
+
child, or add `useLocale()` to the dependencies.
|
|
2729
|
+
|
|
2730
|
+
Call it in either of two compatible forms:
|
|
2731
|
+
|
|
2732
|
+
- `t(key, values?, options?)` — the provider signature from
|
|
2733
|
+
`@molecule/app-i18n`, e.g. `t('cart.total', { total })`.
|
|
2734
|
+
- `t(key, fallback, options?)` — a shorthand for the common inline-English
|
|
2735
|
+
call: a string second argument is the `defaultValue`, so
|
|
2736
|
+
`t('cart.empty', 'Your cart is empty')` equals
|
|
2737
|
+
`t('cart.empty', undefined, { defaultValue: 'Your cart is empty' })`.
|
|
2738
|
+
Interpolation and pluralization still work:
|
|
2739
|
+
`t('cart.items', '{{count}} items', { count: 3 })`.
|
|
2740
|
+
|
|
2654
2741
|
```typescript
|
|
2655
|
-
function useT():
|
|
2656
|
-
key: string,
|
|
2657
|
-
values?: InterpolationValues,
|
|
2658
|
-
options?: { defaultValue?: string; count?: number },
|
|
2659
|
-
) => string
|
|
2742
|
+
function useT(): UseTFunction
|
|
2660
2743
|
```
|
|
2661
2744
|
|
|
2662
|
-
**Returns:** The translation function
|
|
2745
|
+
**Returns:** The translation function (stable identity while the provider is unchanged).
|
|
2663
2746
|
|
|
2664
2747
|
#### `useLocale()`
|
|
2665
2748
|
|
|
@@ -3103,7 +3186,7 @@ const PreviewContext: Context<PreviewProvider | null>
|
|
|
3103
3186
|
|
|
3104
3187
|
Peer dependencies:
|
|
3105
3188
|
|
|
3106
|
-
- `@molecule/app-auth` ^
|
|
3189
|
+
- `@molecule/app-auth` ^3.0.0
|
|
3107
3190
|
- `@molecule/app-ai-models` ^1.0.1
|
|
3108
3191
|
- `@molecule/app-forms` ^1.0.1
|
|
3109
3192
|
- `@molecule/app-utilities` ^1.0.1
|
|
@@ -3188,6 +3271,15 @@ Peer dependencies:
|
|
|
3188
3271
|
`useTranslation()` (or `useT()`); it re-renders on `onLocaleChange` — even when
|
|
3189
3272
|
`addTranslations()` only adds keys for the current locale. Calling the raw `t()` import from
|
|
3190
3273
|
`@molecule/app-i18n` in render works once but leaves stale text after a locale switch.
|
|
3274
|
+
`useT()` returns a function with a STABLE identity (safe as an effect dependency) that also
|
|
3275
|
+
takes an inline fallback as its second argument: `t('cart.empty', 'Your cart is empty')` is
|
|
3276
|
+
shorthand for `t('cart.empty', undefined, { defaultValue: 'Your cart is empty' })`.
|
|
3277
|
+
Prefer it over a hand-written local wrapper (`const t = (key, fallback) => …`), whose new
|
|
3278
|
+
identity every render re-runs any effect that depends on `t`. The identity also survives a
|
|
3279
|
+
locale switch, so text memoized on `[t]` alone (`useMemo`, or a `React.memo` child given `t`)
|
|
3280
|
+
keeps the old language — add `useLocale()` to those dependencies. Register translations at
|
|
3281
|
+
module scope or in a `useEffect`, never while rendering: the notification would update
|
|
3282
|
+
other components mid-render.
|
|
3191
3283
|
- **Load a page's data with `useQuery` from `@molecule/app-query-react`, never with `fetch` in a
|
|
3192
3284
|
`useEffect`.** A hand-written load effect that cancels on cleanup (a `cancelled` flag or an
|
|
3193
3285
|
`AbortController`) cancels its own request on every re-render when a dependency is rebuilt each
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
6
|
import type { I18nProvider } from '@molecule/app-i18n';
|
|
7
|
-
import type { UseTranslationResult } from '../types.js';
|
|
7
|
+
import type { UseTFunction, UseTranslationResult } from '../types.js';
|
|
8
8
|
/**
|
|
9
9
|
* Hook to access the i18n provider from context.
|
|
10
10
|
*
|
|
@@ -37,9 +37,31 @@ export declare function useTranslation(): UseTranslationResult;
|
|
|
37
37
|
/**
|
|
38
38
|
* Hook to get just the translation function.
|
|
39
39
|
*
|
|
40
|
-
*
|
|
40
|
+
* The returned function keeps ONE identity for as long as the provider
|
|
41
|
+
* instance is unchanged, so it is safe as an effect dependency: an effect
|
|
42
|
+
* written as `useEffect(..., [t])` does not re-run on ordinary re-renders or on
|
|
43
|
+
* a locale change. The hook still re-renders the calling component on every
|
|
44
|
+
* locale notification (including `addTranslations` for the active locale), so
|
|
45
|
+
* text it reads while rendering is current. A value memoized on `[t]` alone
|
|
46
|
+
* keeps the old text after a locale switch: `useMemo(() => t(...), [t])`, or a
|
|
47
|
+
* `React.memo` child that receives `t` as a prop. Call `useT()` inside that
|
|
48
|
+
* child, or add `useLocale()` to the dependencies.
|
|
49
|
+
*
|
|
50
|
+
* Call it in either of two compatible forms:
|
|
51
|
+
*
|
|
52
|
+
* - `t(key, values?, options?)` — the provider signature from
|
|
53
|
+
* `@molecule/app-i18n`, e.g. `t('cart.total', { total })`.
|
|
54
|
+
* - `t(key, fallback, options?)` — a shorthand for the common inline-English
|
|
55
|
+
* call: a string second argument is the `defaultValue`, so
|
|
56
|
+
* `t('cart.empty', 'Your cart is empty')` equals
|
|
57
|
+
* `t('cart.empty', undefined, { defaultValue: 'Your cart is empty' })`.
|
|
58
|
+
* Interpolation and pluralization still work:
|
|
59
|
+
* `t('cart.items', '{{count}} items', { count: 3 })`.
|
|
60
|
+
*
|
|
61
|
+
* @returns The translation function (stable identity while the provider is
|
|
62
|
+
* unchanged).
|
|
41
63
|
*/
|
|
42
|
-
export declare function useT():
|
|
64
|
+
export declare function useT(): UseTFunction;
|
|
43
65
|
/**
|
|
44
66
|
* Hook to get the current locale.
|
|
45
67
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTranslation.d.ts","sourceRoot":"","sources":["../../src/hooks/useTranslation.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAEV,YAAY,
|
|
1
|
+
{"version":3,"file":"useTranslation.d.ts","sourceRoot":"","sources":["../../src/hooks/useTranslation.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAEV,YAAY,EAIb,MAAM,oBAAoB,CAAA;AAI3B,OAAO,KAAK,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAErE;;;;;GAKG;AACH,wBAAgB,eAAe,IAAI,YAAY,CAU9C;AAwDD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,cAAc,IAAI,oBAAoB,CA8CrD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,IAAI,IAAI,YAAY,CAcnC;AAED;;;;GAIG;AACH,wBAAgB,SAAS,IAAI,MAAM,CAGlC;AAED;;;;GAIG;AACH,wBAAgB,YAAY,IAAI,KAAK,GAAG,KAAK,CAG5C;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAW3E"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
|
-
import { useCallback, useContext,
|
|
6
|
+
import { useCallback, useContext, useLayoutEffect, useMemo, useSyncExternalStore } from 'react';
|
|
7
7
|
import { I18nError, t } from '@molecule/app-i18n';
|
|
8
8
|
import { I18nContext } from '../contexts.js';
|
|
9
9
|
/**
|
|
@@ -21,6 +21,58 @@ export function useI18nProvider() {
|
|
|
21
21
|
}
|
|
22
22
|
return provider;
|
|
23
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* Subscribes the calling component to the provider's locale notifications
|
|
26
|
+
* through `useSyncExternalStore`, like the package's other store hooks.
|
|
27
|
+
*
|
|
28
|
+
* The snapshot counts this hook's notifications, carries the active locale,
|
|
29
|
+
* and includes the provider's `getRevision()` when it exposes one. A
|
|
30
|
+
* notification, a locale switch, or a revision bump re-renders the component.
|
|
31
|
+
*
|
|
32
|
+
* The one provider listener is attached in a layout effect, and
|
|
33
|
+
* `useSyncExternalStore` subscribes to it later, in the passive phase, then
|
|
34
|
+
* reads the snapshot again. Every layout effect of a commit runs before any
|
|
35
|
+
* mount effect, so a notification fired in a child's or an earlier sibling's
|
|
36
|
+
* `useEffect` is still counted and re-renders this component.
|
|
37
|
+
*
|
|
38
|
+
* The revision covers what the listener cannot: a change announced BEFORE the
|
|
39
|
+
* listener exists — from a child's or an earlier sibling's layout effect, or
|
|
40
|
+
* while React keeps the tree hidden (`<Activity mode="hidden">`) with effects
|
|
41
|
+
* unmounted. The snapshot re-read after subscribing sees the new revision and
|
|
42
|
+
* re-renders with the current text. `createSimpleI18nProvider` implements
|
|
43
|
+
* `getRevision`; a provider written before it existed falls back to the
|
|
44
|
+
* listener count, and a locale switch is still caught for it through the
|
|
45
|
+
* locale in the snapshot. Only a notification fired during the render, before
|
|
46
|
+
* this hook runs, remains unobservable — register translations at module scope
|
|
47
|
+
* or in an effect, never while rendering.
|
|
48
|
+
*
|
|
49
|
+
* No hook-returned function is rebuilt, so an effect that depends on one stays
|
|
50
|
+
* stable.
|
|
51
|
+
*
|
|
52
|
+
* @param provider - The i18n provider from context.
|
|
53
|
+
* @returns A value that changes on every notification, revision and locale switch.
|
|
54
|
+
*/
|
|
55
|
+
function useLocaleSnapshot(provider) {
|
|
56
|
+
const store = useMemo(() => {
|
|
57
|
+
let notifications = 0;
|
|
58
|
+
const onChanges = new Set();
|
|
59
|
+
return {
|
|
60
|
+
listener: () => {
|
|
61
|
+
notifications += 1;
|
|
62
|
+
onChanges.forEach((onChange) => onChange());
|
|
63
|
+
},
|
|
64
|
+
subscribe: (onChange) => {
|
|
65
|
+
onChanges.add(onChange);
|
|
66
|
+
return () => {
|
|
67
|
+
onChanges.delete(onChange);
|
|
68
|
+
};
|
|
69
|
+
},
|
|
70
|
+
getSnapshot: () => `${notifications}:${provider.getRevision?.() ?? 0}:${provider.getLocale()}`,
|
|
71
|
+
};
|
|
72
|
+
}, [provider]);
|
|
73
|
+
useLayoutEffect(() => provider.onLocaleChange(store.listener), [provider, store]);
|
|
74
|
+
return useSyncExternalStore(store.subscribe, store.getSnapshot, store.getSnapshot);
|
|
75
|
+
}
|
|
24
76
|
/**
|
|
25
77
|
* Hook for internationalization.
|
|
26
78
|
*
|
|
@@ -44,21 +96,15 @@ export function useI18nProvider() {
|
|
|
44
96
|
*/
|
|
45
97
|
export function useTranslation() {
|
|
46
98
|
const provider = useI18nProvider();
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
// Force re-render even when locale string is unchanged (e.g. when
|
|
57
|
-
// addTranslations adds new keys for the current locale).
|
|
58
|
-
forceUpdate({});
|
|
59
|
-
});
|
|
60
|
-
return unsubscribe;
|
|
61
|
-
}, [provider]);
|
|
99
|
+
const snapshot = useLocaleSnapshot(provider);
|
|
100
|
+
// Read from the provider on every render, never copied into state: a
|
|
101
|
+
// replaced provider, or a switch that landed before the subscription, shows
|
|
102
|
+
// its own values on the first render instead of the previous ones.
|
|
103
|
+
const locale = provider.getLocale();
|
|
104
|
+
const direction = provider.getDirection();
|
|
105
|
+
// `snapshot` is the recompute key: a new list once per notification, the same
|
|
106
|
+
// list otherwise, so an effect that depends on `locales` stays stable.
|
|
107
|
+
const locales = useMemo(() => provider.getLocales(), [provider, snapshot]);
|
|
62
108
|
// Memoized translation function
|
|
63
109
|
const t = useCallback((key, values, options) => provider.t(key, values, options), [provider, locale]);
|
|
64
110
|
// Memoized action wrappers
|
|
@@ -78,11 +124,36 @@ export function useTranslation() {
|
|
|
78
124
|
/**
|
|
79
125
|
* Hook to get just the translation function.
|
|
80
126
|
*
|
|
81
|
-
*
|
|
127
|
+
* The returned function keeps ONE identity for as long as the provider
|
|
128
|
+
* instance is unchanged, so it is safe as an effect dependency: an effect
|
|
129
|
+
* written as `useEffect(..., [t])` does not re-run on ordinary re-renders or on
|
|
130
|
+
* a locale change. The hook still re-renders the calling component on every
|
|
131
|
+
* locale notification (including `addTranslations` for the active locale), so
|
|
132
|
+
* text it reads while rendering is current. A value memoized on `[t]` alone
|
|
133
|
+
* keeps the old text after a locale switch: `useMemo(() => t(...), [t])`, or a
|
|
134
|
+
* `React.memo` child that receives `t` as a prop. Call `useT()` inside that
|
|
135
|
+
* child, or add `useLocale()` to the dependencies.
|
|
136
|
+
*
|
|
137
|
+
* Call it in either of two compatible forms:
|
|
138
|
+
*
|
|
139
|
+
* - `t(key, values?, options?)` — the provider signature from
|
|
140
|
+
* `@molecule/app-i18n`, e.g. `t('cart.total', { total })`.
|
|
141
|
+
* - `t(key, fallback, options?)` — a shorthand for the common inline-English
|
|
142
|
+
* call: a string second argument is the `defaultValue`, so
|
|
143
|
+
* `t('cart.empty', 'Your cart is empty')` equals
|
|
144
|
+
* `t('cart.empty', undefined, { defaultValue: 'Your cart is empty' })`.
|
|
145
|
+
* Interpolation and pluralization still work:
|
|
146
|
+
* `t('cart.items', '{{count}} items', { count: 3 })`.
|
|
147
|
+
*
|
|
148
|
+
* @returns The translation function (stable identity while the provider is
|
|
149
|
+
* unchanged).
|
|
82
150
|
*/
|
|
83
151
|
export function useT() {
|
|
84
152
|
const provider = useI18nProvider();
|
|
85
|
-
|
|
153
|
+
useLocaleSnapshot(provider);
|
|
154
|
+
return useCallback((key, valuesOrDefault, options) => typeof valuesOrDefault === 'string'
|
|
155
|
+
? provider.t(key, undefined, { ...options, defaultValue: valuesOrDefault })
|
|
156
|
+
: provider.t(key, valuesOrDefault, options), [provider]);
|
|
86
157
|
}
|
|
87
158
|
/**
|
|
88
159
|
* Hook to get the current locale.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTranslation.js","sourceRoot":"","sources":["../../src/hooks/useTranslation.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"useTranslation.js","sourceRoot":"","sources":["../../src/hooks/useTranslation.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,WAAW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B,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAA;IACvB,4EAA4E;IAC5E,qEAAqE;IACrE,4EAA4E;IAC5E,uEAAuE;IACvE,IAAI,KAAK,YAAY,SAAS,EAAE,CAAC;QAC/B,OAAO,CAAC,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,UAAU,EAAE,EAAE,YAAY,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,CAAA;IAC5E,CAAC;IACD,OAAO,KAAK,CAAC,OAAO,CAAA;AACtB,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -114,6 +114,15 @@
|
|
|
114
114
|
* `useTranslation()` (or `useT()`); it re-renders on `onLocaleChange` — even when
|
|
115
115
|
* `addTranslations()` only adds keys for the current locale. Calling the raw `t()` import from
|
|
116
116
|
* `@molecule/app-i18n` in render works once but leaves stale text after a locale switch.
|
|
117
|
+
* `useT()` returns a function with a STABLE identity (safe as an effect dependency) that also
|
|
118
|
+
* takes an inline fallback as its second argument: `t('cart.empty', 'Your cart is empty')` is
|
|
119
|
+
* shorthand for `t('cart.empty', undefined, { defaultValue: 'Your cart is empty' })`.
|
|
120
|
+
* Prefer it over a hand-written local wrapper (`const t = (key, fallback) => …`), whose new
|
|
121
|
+
* identity every render re-runs any effect that depends on `t`. The identity also survives a
|
|
122
|
+
* locale switch, so text memoized on `[t]` alone (`useMemo`, or a `React.memo` child given `t`)
|
|
123
|
+
* keeps the old language — add `useLocale()` to those dependencies. Register translations at
|
|
124
|
+
* module scope or in a `useEffect`, never while rendering: the notification would update
|
|
125
|
+
* other components mid-render.
|
|
117
126
|
* - **Load a page's data with `useQuery` from `@molecule/app-query-react`, never with `fetch` in a
|
|
118
127
|
* `useEffect`.** A hand-written load effect that cancels on cleanup (a `cancelled` flag or an
|
|
119
128
|
* `AbortController`) cancels its own request on every re-render when a dependency is rebuilt each
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8JG;AAEH,cAAc,qBAAqB,CAAA;AACnC,cAAc,eAAe,CAAA;AAC7B,cAAc,kBAAkB,CAAA;AAChC,cAAc,2BAA2B,CAAA;AACzC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,YAAY,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -114,6 +114,15 @@
|
|
|
114
114
|
* `useTranslation()` (or `useT()`); it re-renders on `onLocaleChange` — even when
|
|
115
115
|
* `addTranslations()` only adds keys for the current locale. Calling the raw `t()` import from
|
|
116
116
|
* `@molecule/app-i18n` in render works once but leaves stale text after a locale switch.
|
|
117
|
+
* `useT()` returns a function with a STABLE identity (safe as an effect dependency) that also
|
|
118
|
+
* takes an inline fallback as its second argument: `t('cart.empty', 'Your cart is empty')` is
|
|
119
|
+
* shorthand for `t('cart.empty', undefined, { defaultValue: 'Your cart is empty' })`.
|
|
120
|
+
* Prefer it over a hand-written local wrapper (`const t = (key, fallback) => …`), whose new
|
|
121
|
+
* identity every render re-runs any effect that depends on `t`. The identity also survives a
|
|
122
|
+
* locale switch, so text memoized on `[t]` alone (`useMemo`, or a `React.memo` child given `t`)
|
|
123
|
+
* keeps the old language — add `useLocale()` to those dependencies. Register translations at
|
|
124
|
+
* module scope or in a `useEffect`, never while rendering: the notification would update
|
|
125
|
+
* other components mid-render.
|
|
117
126
|
* - **Load a page's data with `useQuery` from `@molecule/app-query-react`, never with `fetch` in a
|
|
118
127
|
* `useEffect`.** A hand-written load effect that cancels on cleanup (a `cancelled` flag or an
|
|
119
128
|
* `AbortController`) cancels its own request on every re-render when a dependency is rebuilt each
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8JG;AAEH,cAAc,qBAAqB,CAAA;AACnC,cAAc,eAAe,CAAA;AAC7B,cAAc,kBAAkB,CAAA;AAChC,cAAc,2BAA2B,CAAA;AACzC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,YAAY,CAAA"}
|
package/dist/types.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ import type { AuthClient, AuthState, RegisterExtraShape } from '@molecule/app-au
|
|
|
9
9
|
import type { DiffFile, EditorFile, EditorProvider, EditorTab, FixWithAIRequest } from '@molecule/app-code-editor';
|
|
10
10
|
import type { FormController, FormOptions } from '@molecule/app-forms';
|
|
11
11
|
import type { HttpClient } from '@molecule/app-http';
|
|
12
|
-
import type { I18nProvider } from '@molecule/app-i18n';
|
|
12
|
+
import type { I18nProvider, TranslateOptions } from '@molecule/app-i18n';
|
|
13
13
|
import type { PanelId, WorkspaceLayout, WorkspaceProvider } from '@molecule/app-ide';
|
|
14
14
|
import type { DeviceFrame, PreviewProvider, PreviewState } from '@molecule/app-live-preview';
|
|
15
15
|
import type { LoggerProvider } from '@molecule/app-logger';
|
|
@@ -161,7 +161,7 @@ export interface UseAuthResult<T = unknown, TRegister extends RegisterExtraShape
|
|
|
161
161
|
*
|
|
162
162
|
* `setUser` alone does NOT sign the client in, and `setAccessToken` changes
|
|
163
163
|
* storage only — using those two for a caller-issued session leaves every
|
|
164
|
-
* `authenticated` read signed out
|
|
164
|
+
* `authenticated` read signed out.
|
|
165
165
|
*/
|
|
166
166
|
setSession: AuthClient<T>['setSession'];
|
|
167
167
|
isAuthenticated: boolean;
|
|
@@ -203,6 +203,25 @@ export interface UseTranslationResult {
|
|
|
203
203
|
formatDate: I18nProvider['formatDate'];
|
|
204
204
|
direction: 'ltr' | 'rtl';
|
|
205
205
|
}
|
|
206
|
+
/**
|
|
207
|
+
* Options for the shorthand form of {@link UseTFunction}: the fallback text is
|
|
208
|
+
* passed positionally, so only `count` remains here.
|
|
209
|
+
*/
|
|
210
|
+
export type UseTShorthandOptions = Omit<TranslateOptions, 'defaultValue'>;
|
|
211
|
+
/**
|
|
212
|
+
* Translation function returned by `useT()`.
|
|
213
|
+
*
|
|
214
|
+
* Two compatible call forms:
|
|
215
|
+
* - `t(key, values?, options?)` — the {@link I18nProvider.t} signature.
|
|
216
|
+
* - `t(key, fallback, options?)` — a string second argument is the inline
|
|
217
|
+
* English `defaultValue`, with optional `count` for pluralization.
|
|
218
|
+
*
|
|
219
|
+
* Its identity is stable while the i18n provider instance is unchanged, so it
|
|
220
|
+
* can be used directly as an effect dependency.
|
|
221
|
+
*/
|
|
222
|
+
export type UseTFunction = I18nProvider['t'] & {
|
|
223
|
+
(key: string, fallback: string, options?: UseTShorthandOptions): string;
|
|
224
|
+
};
|
|
206
225
|
/**
|
|
207
226
|
* Hook options for useChat.
|
|
208
227
|
*/
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEtC,OAAO,KAAK,EACV,mBAAmB,EACnB,cAAc,EACd,WAAW,EACX,YAAY,EACZ,eAAe,EAChB,MAAM,uBAAu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,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IAC9B,WAAW,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAA;IACxD,WAAW,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,EAAE,gBAAgB,KAAK,IAAI,KAAK,MAAM,IAAI,CAAA;CAC3E;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,YAAY,CAAA;IACnB,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAA;IAC7B,OAAO,EAAE,MAAM,IAAI,CAAA;IACnB,SAAS,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,IAAI,CAAA;IACxC,YAAY,EAAE,MAAM,IAAI,CAAA;IACxB;;;;;;OAMG;IACH,gBAAgB,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,OAAO,KAAK,IAAI,CAAA;IAC5D,6EAA6E;IAC7E,IAAI,EAAE,MAAM,IAAI,CAAA;IAChB,4EAA4E;IAC5E,OAAO,EAAE,MAAM,IAAI,CAAA;CACpB;AAMD,YAAY,EACV,UAAU,EACV,SAAS,EACT,cAAc,EACd,WAAW,EACX,UAAU,EACV,MAAM,EACN,YAAY,EACZ,KAAK,EACL,WAAW,EACX,KAAK,GACN,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@molecule/app-react",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "React framework bindings for molecule.dev",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -12,8 +12,10 @@
|
|
|
12
12
|
"scripts": {
|
|
13
13
|
"build": "tsc",
|
|
14
14
|
"dev": "tsc --watch",
|
|
15
|
+
"pretest": "npm run typecheck:tests",
|
|
15
16
|
"test": "vitest run",
|
|
16
|
-
"test:watch": "vitest"
|
|
17
|
+
"test:watch": "vitest",
|
|
18
|
+
"typecheck:tests": "tsc -p tsconfig.tests.json"
|
|
17
19
|
},
|
|
18
20
|
"author": "Molecule Dev, Inc. (https://molecule.dev)",
|
|
19
21
|
"license": "Apache-2.0",
|
|
@@ -21,7 +23,7 @@
|
|
|
21
23
|
"node": ">=20"
|
|
22
24
|
},
|
|
23
25
|
"peerDependencies": {
|
|
24
|
-
"@molecule/app-auth": "^
|
|
26
|
+
"@molecule/app-auth": "^3.0.0",
|
|
25
27
|
"@molecule/app-ai-models": "^1.0.1",
|
|
26
28
|
"@molecule/app-forms": "^1.0.1",
|
|
27
29
|
"@molecule/app-utilities": "^1.0.1",
|
|
@@ -59,8 +61,8 @@
|
|
|
59
61
|
},
|
|
60
62
|
"devDependencies": {
|
|
61
63
|
"@molecule/app-ai-models": "1.4.3",
|
|
62
|
-
"@molecule/app-bonds-default-react": "
|
|
63
|
-
"@molecule/app-i18n": "1.0
|
|
64
|
+
"@molecule/app-bonds-default-react": "3.0.0",
|
|
65
|
+
"@molecule/app-i18n": "1.1.0",
|
|
64
66
|
"@testing-library/dom": "10.4.2",
|
|
65
67
|
"@testing-library/react": "16.3.3",
|
|
66
68
|
"@types/node": "26.6.5",
|