mirror of
https://github.com/badlogic/pi-mono.git
synced 2026-11-05 23:37:25 +00:00
defineMessages with typed t, t.message/t.render for messages as data, the Translations registry with fallbacks and conflicts, a locale preference per principal with the device as default and a live switch, useMessages and scope.messages, formatTime/formatNumber. The tutorial gains a chapter on languages. |
||
|---|---|---|
| .. | ||
| hooks.ts | ||
| index.ts | ||
| README.md | ||
| stores.ts | ||
react
React bindings (slice 11 §3, decision "Slice 11, P7"): @earendil-works/chord/react; optional (React is an optional
peer), non-React apps never load it. No components, no styling.
HostProvider({ host }),useHost().useHold(Type, params): a reference held while the component is mounted, released on unmount, held again when its params change (compared by value);undefinedon the first render.useWatch(watchable): its current value (undefinedwhile it has none), re-rendering on change (useSyncExternalStoreoverwatchStore).useRegistry(R): the registry's composed value;useRefState(ref): the reference's state.useMessages(t):{ t, locale }, a plugin's messages bound to the host's language (followed bystartPage), re-rendering when the locale or a translation changes; before a language is followed, the first catalog.usePageState(key, initial):useState's pair, the value kept by the page (its host's life) underkey(surfaces/page-state.ts, shared withTuiScope.pageState), so a component remounted by a plugin reload keeps it.- A component unmounted by a reload has not left (design §21): its releases are plain releases. A component of a
reloaded plugin is a new function and remounts, its
useStatestarting over: what must survive is page state.
Tests: test/node/react/ (stores.test.ts in Node, hooks.test.ts in a real browser); the page state alone in
test/surfaces/page-state.test.ts.