what-core 0.14.0 → 0.15.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/LICENSE +21 -0
- package/README.md +64 -38
- package/a11y.d.ts +128 -0
- package/data.d.ts +294 -0
- package/dist/a11y.js +510 -0
- package/dist/a11y.min.js +413 -0
- package/dist/actions.js +158 -0
- package/dist/actions.min.js +112 -0
- package/dist/animation.js +481 -0
- package/dist/animation.min.js +295 -0
- package/dist/async.js +180 -0
- package/dist/async.min.js +134 -0
- package/dist/components.js +577 -0
- package/dist/components.min.js +413 -0
- package/dist/data.js +1212 -0
- package/dist/data.min.js +918 -0
- package/dist/diagnostics.js +187 -0
- package/dist/diagnostics.min.js +134 -0
- package/dist/dom.js +796 -0
- package/dist/dom.min.js +603 -0
- package/dist/entries/a11y.js +43 -0
- package/dist/entries/a11y.min.js +43 -0
- package/dist/entries/data.js +29 -0
- package/dist/entries/data.min.js +29 -0
- package/dist/entries/dom.js +45 -0
- package/dist/entries/dom.min.js +45 -0
- package/dist/entries/form.js +31 -0
- package/dist/entries/form.min.js +31 -0
- package/dist/entries/internal.js +123 -0
- package/dist/entries/internal.min.js +123 -0
- package/dist/entries/motion.js +23 -0
- package/dist/entries/motion.min.js +23 -0
- package/dist/entries/ui.js +25 -0
- package/dist/entries/ui.min.js +25 -0
- package/dist/env.js +5 -0
- package/dist/env.min.js +5 -0
- package/dist/errors.js +1518 -0
- package/dist/errors.min.js +548 -0
- package/dist/form.js +936 -0
- package/dist/form.min.js +703 -0
- package/dist/guardrails.js +84 -0
- package/dist/guardrails.min.js +55 -0
- package/dist/h.js +232 -0
- package/dist/h.min.js +171 -0
- package/dist/head.js +241 -0
- package/dist/head.min.js +207 -0
- package/dist/helpers.js +126 -0
- package/dist/helpers.min.js +98 -0
- package/dist/hooks.js +255 -0
- package/dist/hooks.min.js +153 -0
- package/dist/hot.js +215 -0
- package/dist/hot.min.js +24 -0
- package/dist/hydration-data.js +495 -0
- package/dist/hydration-data.min.js +371 -0
- package/dist/import-changes.js +273 -0
- package/dist/import-changes.min.js +272 -0
- package/dist/index.js +95 -0
- package/dist/index.min.js +95 -227
- package/dist/jsx-dev-runtime.js +10 -0
- package/dist/jsx-dev-runtime.min.js +10 -1
- package/dist/jsx-runtime.js +27 -0
- package/dist/jsx-runtime.min.js +15 -1
- package/dist/live.js +54 -0
- package/dist/live.min.js +49 -0
- package/dist/markup-rules.js +250 -0
- package/dist/markup-rules.min.js +213 -0
- package/dist/reactive.js +3334 -0
- package/dist/reactive.min.js +2033 -0
- package/dist/render.js +4746 -0
- package/dist/render.min.js +2797 -1
- package/dist/scheduler.js +225 -0
- package/dist/scheduler.min.js +162 -0
- package/dist/selector.js +11 -0
- package/dist/selector.min.js +10 -0
- package/dist/server-context.js +148 -0
- package/dist/server-context.min.js +121 -0
- package/dist/skeleton.js +342 -0
- package/dist/skeleton.min.js +310 -0
- package/dist/store.js +72 -0
- package/dist/store.min.js +50 -0
- package/dist/testing.js +720 -0
- package/dist/testing.min.js +458 -1
- package/dist/vnode-adoption.js +19 -0
- package/dist/vnode-adoption.min.js +19 -0
- package/dist/vnode-renderer.js +61 -0
- package/dist/vnode-renderer.min.js +47 -0
- package/dom.d.ts +44 -0
- package/form.d.ts +218 -0
- package/hot.d.ts +35 -0
- package/index.d.ts +421 -736
- package/internal.d.ts +284 -0
- package/jsx-runtime.d.ts +160 -137
- package/markup-rules.d.ts +83 -0
- package/motion.d.ts +156 -0
- package/package.json +117 -3
- package/render.d.ts +278 -29
- package/src/a11y.js +64 -59
- package/src/actions.js +226 -0
- package/src/animation.js +105 -57
- package/src/async.js +259 -0
- package/src/components.js +495 -144
- package/src/data.js +1410 -1159
- package/src/diagnostics.js +263 -0
- package/src/dom.js +1159 -872
- package/src/entries/a11y.js +24 -0
- package/src/entries/data.js +17 -0
- package/src/entries/dom.js +29 -0
- package/src/entries/form.js +16 -0
- package/src/entries/internal.js +63 -0
- package/src/entries/motion.js +13 -0
- package/src/entries/ui.js +13 -0
- package/src/env-development.js +12 -0
- package/src/env.js +33 -0
- package/src/errors.js +1144 -168
- package/src/form.js +723 -225
- package/src/guardrails.js +38 -126
- package/src/h.js +227 -152
- package/src/head.js +189 -19
- package/src/helpers.js +47 -75
- package/src/hooks.js +233 -248
- package/src/hot.js +316 -0
- package/src/hydration-data.js +859 -16
- package/src/import-changes.js +156 -0
- package/src/index.js +38 -188
- package/src/jsx-dev-runtime.js +7 -14
- package/src/jsx-runtime.js +25 -9
- package/src/live.js +80 -0
- package/src/markup-rules.js +387 -0
- package/src/reactive.js +4400 -862
- package/src/render.js +6502 -2570
- package/src/scheduler.js +56 -21
- package/src/selector.js +31 -0
- package/src/server-context.js +252 -22
- package/src/skeleton.js +22 -12
- package/src/store.js +17 -31
- package/src/testing.js +389 -63
- package/src/vnode-adoption.js +48 -0
- package/src/vnode-renderer.js +114 -0
- package/testing.d.ts +81 -1
- package/ui.d.ts +20 -0
- package/dist/chunk-6YOUZ6T4.min.js +0 -1
- package/dist/chunk-FN6HXME3.min.js +0 -11
- package/dist/chunk-VKZY7JPN.min.js +0 -1
- package/src/agent-context.js +0 -127
- package/src/warnings.js +0 -193
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
// What Framework - Import changes
|
|
2
|
+
//
|
|
3
|
+
// Every name the root entry (`what-framework`, and `what-core` alike) stopped
|
|
4
|
+
// exporting in 0.15.0, and where it went, the names it exports with React's
|
|
5
|
+
// meaning instead of What's, then the internal interfaces new in 0.15 that the
|
|
6
|
+
// root entry never exported. This table is the one list: the docs
|
|
7
|
+
// (docs/UPGRADING.md, generated by scripts/generate-import-changes.mjs),
|
|
8
|
+
// what-compiler's Vite plugin, eslint-plugin-what's no-moved-imports rule,
|
|
9
|
+
// validateImports() and tools reading what-core/internal all take it from
|
|
10
|
+
// here, so agents and people see the same answer.
|
|
11
|
+
//
|
|
12
|
+
// A record is { name, to, as?, note, answer, onRoot?, neverOnRoot? }:
|
|
13
|
+
// name the name as it is imported
|
|
14
|
+
// to the module that exports it now, or null when it is gone
|
|
15
|
+
// as its new name, when it was renamed
|
|
16
|
+
// note why, ending with what to write instead
|
|
17
|
+
// answer what an import of the name from the root entry is told: the
|
|
18
|
+
// note, then the import to write (built from the fields above)
|
|
19
|
+
// onRoot true for a name the root entry exports again, with React's
|
|
20
|
+
// meaning: the record says where What's export of that name
|
|
21
|
+
// went, and only an import of its new name (`as`) from the root
|
|
22
|
+
// entry is answered
|
|
23
|
+
// neverOnRoot true for an internal interface new in 0.15 that the root
|
|
24
|
+
// entry never exported, listed so an import of it is answered
|
|
25
|
+
// A what-framework/<kit> path has a what-core/<kit> twin with the same exports.
|
|
26
|
+
// A row with `names` stands for one record per name.
|
|
27
|
+
|
|
28
|
+
export const IMPORT_CHANGES = /* @__PURE__ */ table([
|
|
29
|
+
// Names that meant something else in React.
|
|
30
|
+
{ name: 'useTransition', to: 'what-framework/motion', as: 'useTween', onRoot: true, note: 'The animation helper formerly named useTransition is useTween. useTransition and startTransition on the root entry are React\'s transition API: const [isPending, start] = useTransition(), where isPending is an accessor, read as isPending().' },
|
|
31
|
+
{ name: 'transition', to: 'what-framework/motion', as: 'transitionClass', note: 'The enter/leave class helper is transitionClass(name, active).' },
|
|
32
|
+
{ name: 'on', to: 'what-framework/render', note: 'on(el, event, handler) is a fine-grained rendering primitive; in components write onClick={...} in JSX.' },
|
|
33
|
+
|
|
34
|
+
// Deleted: duplicates of names that stay.
|
|
35
|
+
{ name: 'each', to: null, note: 'Render lists with .map() and a key prop, or <For>.' },
|
|
36
|
+
{ name: 'atom', to: null, note: 'Use signal(initial).' },
|
|
37
|
+
{ name: 'storeComputed', to: null, note: 'Use derived(fn) in the store definition.' },
|
|
38
|
+
{ name: 'onRootCleanup', to: null, note: 'Use onCleanup(fn): it attaches to the component being rendered, or else to the reactive owner (createRoot, a list row).' },
|
|
39
|
+
{ name: 'signalMemo', to: null, note: 'Use computed(fn), which recomputes only when read and skips readers when the value is unchanged.' },
|
|
40
|
+
{ name: 'getLoaderData', to: null, note: 'Use useLoaderData(), which reads the same payload on the client and the render context on the server.' },
|
|
41
|
+
{ name: '_template', to: null, note: 'Use template() from what-framework/render; compiled output imports _$template from there.' },
|
|
42
|
+
{ name: 'getResource', to: null, note: 'Use createResource(fetcher, { key }), which reads the hydrated value for its key.' },
|
|
43
|
+
|
|
44
|
+
// One island component: the server's. What the compiler lowers client:*
|
|
45
|
+
// directives to is a compiler target.
|
|
46
|
+
{ name: 'Island', to: 'what-framework/server', note: 'The island component is what-framework/server\'s Island({ name, props, mode }), which the client hydrates through the island registry (island(), hydrateIslands()). A JSX client:* directive (<Counter client:idle />) compiles to _$Island from what-framework/render, an island that hydrates itself; code written with h() calls that the same way: h(_$Island, { component: Counter, mode: \'idle\' }).' },
|
|
47
|
+
|
|
48
|
+
// The error collector: the diagnostics channel replaced it.
|
|
49
|
+
{ name: 'collectError', to: null, note: 'Nothing collects errors by hand: the runtime reports its coded diagnostics on one channel (getDiagnostics(), subscribeDiagnostics()), and what-devtools records thrown errors (getErrors()). Both are development-only: a production build reports nothing.' },
|
|
50
|
+
{ name: 'getCollectedErrors', to: null, note: 'Use getDiagnostics({ since }) for the coded diagnostics (since is the seq the previous call returned, not a timestamp), or getErrors() from what-devtools for thrown errors; both are development-only.' },
|
|
51
|
+
{ name: 'clearCollectedErrors', to: null, note: 'Use clearDiagnostics().' },
|
|
52
|
+
|
|
53
|
+
// The agent context (window.__WHAT_AGENT__): what-devtools and
|
|
54
|
+
// what-devtools-mcp replaced it.
|
|
55
|
+
{ name: 'installAgentContext', to: null, note: 'Use installDevTools() from what-devtools, which what-devtools-mcp\'s Vite plugin calls in development: it exposes the app\'s state as window.__WHAT_DEVTOOLS__, which the what_* MCP tools read.' },
|
|
56
|
+
{ to: null, names: ['registerComponent', 'unregisterComponent'], note: 'Delete the call: with what-devtools installed, every component is registered as it mounts and dropped as it unmounts.' },
|
|
57
|
+
{ to: null, names: ['registerSignal', 'unregisterSignal'], note: 'Delete the call: with what-devtools installed, every signal is registered as it is created, and nothing has to unregister it.' },
|
|
58
|
+
{ name: 'getMountedComponents', to: null, note: 'Use getSnapshot().components from what-devtools (development only), or the what_components MCP tool.' },
|
|
59
|
+
{ name: 'getActiveSignals', to: null, note: 'Use getSnapshot().signals from what-devtools (development only), or the what_signals MCP tool.' },
|
|
60
|
+
{ name: 'getHealth', to: null, note: 'Use the what_diagnose MCP tool (diagnostic codes, errors, hot effects, unread signals), or getDiagnostics() for the coded diagnostics alone.' },
|
|
61
|
+
|
|
62
|
+
// Domain kits on subpaths.
|
|
63
|
+
{ to: 'what-framework/a11y', names: [
|
|
64
|
+
'useFocus', 'useFocusRestore', 'useFocusTrap', 'FocusTrap', 'announce', 'announceAssertive',
|
|
65
|
+
'SkipLink', 'useAriaExpanded', 'useAriaSelected', 'useAriaChecked', 'useRovingTabIndex',
|
|
66
|
+
'VisuallyHidden', 'LiveRegion', 'useIds', 'useDescribedBy', 'useLabelledBy', 'Keys', 'onKey', 'onKeys',
|
|
67
|
+
], note: 'Accessibility helpers live in what-framework/a11y.' },
|
|
68
|
+
{ to: 'what-framework/ui', names: [
|
|
69
|
+
'Skeleton', 'SkeletonText', 'SkeletonAvatar', 'SkeletonCard', 'SkeletonTable', 'IslandSkeleton',
|
|
70
|
+
'useSkeleton', 'Placeholder', 'LoadingDots', 'Spinner',
|
|
71
|
+
], note: 'Skeletons and loading placeholders live in what-framework/ui.' },
|
|
72
|
+
{ to: 'what-framework/motion', names: [
|
|
73
|
+
'spring', 'tween', 'easings', 'useGesture', 'useAnimatedValue', 'createTransitionClasses', 'cssTransition',
|
|
74
|
+
], note: 'Animation lives in what-framework/motion.' },
|
|
75
|
+
{ to: 'what-framework/dom', names: [
|
|
76
|
+
'scheduleRead', 'scheduleWrite', 'flushScheduler', 'measure', 'mutate', 'useScheduledEffect',
|
|
77
|
+
'nextFrame', 'raf', 'onResize', 'onIntersect', 'smoothScrollTo',
|
|
78
|
+
], note: 'The DOM read/write scheduler lives in what-framework/dom.' },
|
|
79
|
+
{ to: 'what-framework/dom', names: [
|
|
80
|
+
'cls', 'style', 'debounce', 'throttle', 'useMediaQuery', 'useLocalStorage', 'useClickOutside', 'clearHead',
|
|
81
|
+
], note: 'DOM utilities live in what-framework/dom.' },
|
|
82
|
+
{ to: 'what-framework/form', names: [
|
|
83
|
+
'useForm', 'useField', 'rules', 'simpleResolver', 'zodResolver', 'yupResolver',
|
|
84
|
+
'Input', 'Textarea', 'Select', 'Checkbox', 'Radio', 'ErrorMessage',
|
|
85
|
+
], note: 'Forms live in what-framework/form.' },
|
|
86
|
+
{ to: 'what-framework/data', names: [
|
|
87
|
+
'useFetch', 'useSWR', 'useQuery', 'useInfiniteQuery', 'invalidateQueries', 'prefetchQuery',
|
|
88
|
+
'setQueryData', 'getQueryData', 'clearCache',
|
|
89
|
+
], note: 'The query, SWR and fetch hooks live in what-framework/data.' },
|
|
90
|
+
|
|
91
|
+
// Fine-grained rendering primitives: the compiler's runtime, for code
|
|
92
|
+
// written without JSX.
|
|
93
|
+
{ to: 'what-framework/render', names: [
|
|
94
|
+
'template', 'svgTemplate', 'insert', 'mapArray', 'spread', 'setProp', 'delegateEvents',
|
|
95
|
+
'classList', 'isHydrating', '_$template', '_$createComponent',
|
|
96
|
+
], note: 'Fine-grained rendering primitives live in what-framework/render, beside the rest of the compiled-JSX runtime.' },
|
|
97
|
+
{ name: '_setTextInsertHook', to: 'what-core/render', note: 'Text engines register their insert hook through what-core/render.' },
|
|
98
|
+
|
|
99
|
+
// The contract between what-core and its sibling packages and tools.
|
|
100
|
+
{ to: 'what-core/internal', names: [
|
|
101
|
+
'__setDevToolsHooks', '__drainPreinstallBuffer', '__getCacheSnapshot', 'configureGuardrails', 'getGuardrailConfig',
|
|
102
|
+
'validateImports', 'ERROR_CODES', 'createWhatError', 'classifyError',
|
|
103
|
+
], note: 'Devtools hooks, guardrails and the error catalogue are tool interfaces in what-core/internal.' },
|
|
104
|
+
{ name: 'checkComponentName', to: null, note: 'Removed: a function that reaches the runtime is already being called as a component, so its name cannot reveal the lowercase JSX tag (rendered as an unknown element) the check was meant to catch. Name components in PascalCase.' },
|
|
105
|
+
{ name: 'installSignalReadGuardrail', to: null, note: 'Nothing to install: in development every signal and computed reports ERR_MISSING_SIGNAL_READ when it is converted to a string or a number, with or without what-devtools.' },
|
|
106
|
+
{ to: 'what-core/internal', names: [
|
|
107
|
+
'getServerContext', 'setServerContext', 'runWithServerContext', '__installServerContextStorage',
|
|
108
|
+
'beginHeadCollection', 'endHeadCollection', '_isAriaAttr', '_beginComponentSSR', '_endComponentSSR',
|
|
109
|
+
'_mapArrayToArray', '__readHydrationData', '__resetHydrationData',
|
|
110
|
+
], note: 'Server-rendering internals are what-server\'s interface in what-core/internal; apps use getResponse() and useLoaderData().' },
|
|
111
|
+
|
|
112
|
+
// New in 0.15, never on the root entry.
|
|
113
|
+
{ to: 'what-core/internal', neverOnRoot: true, names: [
|
|
114
|
+
'__depsOf', '__subsOf', '__currentEffect', '__ownerOf', '__ownerPath', 'reportDiagnostic', '_thrownMessage', 'IMPORT_CHANGES', 'SUBPATH_ONLY',
|
|
115
|
+
], note: 'Devtools hooks, guardrails and the error catalogue are tool interfaces in what-core/internal.' },
|
|
116
|
+
{ to: 'what-core/internal', neverOnRoot: true, names: [
|
|
117
|
+
'_escapeHtml', '_runInComponentSSR', '_assignOwnerPath', '_ownerCounter', '_currentOwnerPath', '_actionStateKey', '_actionKeySalt', '_currentRowPath', '_enterRow', '_installRowKeys', '_leaveRow', '_renderSalt', '_tracksRows', '__flushOutsideServerContext', '__outsideServerContext', '__markServerProcess',
|
|
118
|
+
'_rowKeyDigest', '_engine', '_runComponentAsync', '_runComponentSync', '_symbolChild', '_loadedQueries',
|
|
119
|
+
], note: 'Server-rendering internals are what-server\'s interface in what-core/internal; apps use getResponse() and useLoaderData().' },
|
|
120
|
+
{ to: 'what-core/internal', neverOnRoot: true, names: [
|
|
121
|
+
'__invalidateFromDevtools', '_tagQueries', '_formStatus', '_formStatusContext', '_resetForm', '_formMember', '_devAction', '__DEV__', '_urgent', '_currentTransition', '_onCommit', '_pathLoaded',
|
|
122
|
+
'_contextOf', '_provide', '_isServerProcess', '_devNewContent', '_devDropped', '_hotKeep',
|
|
123
|
+
], note: 'The query cache\'s devtools and router hooks, the status <Form> provides and its reset, the engine hooks a navigation uses and the development flag are what-devtools\', what-router\'s and what-server\'s interface in what-core/internal; apps use what-framework/data, useFormStatus(), <Form> and useTransition().' },
|
|
124
|
+
{ name: 'isVNode', to: 'what-core/internal', neverOnRoot: true, note: 'Whether a value is a vnode, by the brand only what-core\'s producers (h(), the JSX runtime, the boundaries) give: for libraries that make or inspect elements, such as what-react. Apps make elements with h() or JSX.' },
|
|
125
|
+
{ name: '_signalKeyed', to: 'what-core/internal', neverOnRoot: true, note: 'A vnode whose key is a signal, as the reactive child that builds it again when the key\'s value changes: what-server renders it with it. Apps write the key (`h(Editor, { key: id })`).' },
|
|
126
|
+
{ to: 'what-core/internal', neverOnRoot: true, names: ['_claimRegion', '_afterWalk', '_devHoldsState'], note: 'Hooks for what-react\'s islands: an island takes the server\'s HTML for it whole and renders after the walk, and in development says it holds state (ERR_REBUILT_COMPONENT). Apps use hydrate().' },
|
|
127
|
+
{ to: 'what-core/internal', neverOnRoot: true, names: ['_errorSource', '_errorFromRecord'], note: 'Whether an error is what a read of a failed async value threw, and the Error a hydrating client makes of a server error record: what-server shows an <ErrorBoundary>\'s fallback for a value that failed as the client does. Apps use <ErrorBoundary>.' },
|
|
128
|
+
{ name: '_mountPortal', to: 'what-core/internal', neverOnRoot: true, note: 'The client renderer a portal\'s vnode carries: what-react\'s createPortal attaches it, so its portal also renders where it reaches a native What tree. Apps use <Portal>.' },
|
|
129
|
+
{ to: 'what-core/internal', neverOnRoot: true, names: ['_placedNamespace', '_svgOnlyTag'], note: 'What a React tree native code places is created in, for what-react\'s mixed mode: the namespace compiled JSX placed the native code in, and the tags only SVG has. Apps write the <svg>.' },
|
|
130
|
+
]);
|
|
131
|
+
|
|
132
|
+
// Names a subpath exports that the root entry never did, imported from the
|
|
133
|
+
// root entry by someone who guessed (`import { Router, Link } from
|
|
134
|
+
// 'what-framework'`, the way react-router's names are swapped for React's).
|
|
135
|
+
// They are not changes, so the upgrade guide does not list them; what-compiler's
|
|
136
|
+
// Vite plugin and eslint-plugin-what's no-moved-imports rule answer such an
|
|
137
|
+
// import with where the name lives, as they answer a moved one. Records have
|
|
138
|
+
// the shape of IMPORT_CHANGES' ({ name, to, note, answer }).
|
|
139
|
+
export const SUBPATH_ONLY = /* @__PURE__ */ table([
|
|
140
|
+
{ to: 'what-framework/router', names: [
|
|
141
|
+
'Router', 'FileRouter', 'Link', 'NavLink', 'Outlet', 'Redirect', 'navigate', 'redirect', 'route',
|
|
142
|
+
'useRoute', 'useParams', 'useSearch', 'useNavigate', 'defineRoutes', 'nestedRoutes', 'routeGroup',
|
|
143
|
+
'matchRoute', 'compilePath', 'parseQuery', 'isSafeUrl', 'setBase', 'guard', 'asyncGuard',
|
|
144
|
+
'beforeNavigate', 'afterNavigate', 'prefetch', 'prefetchRoute', 'enableScrollRestoration',
|
|
145
|
+
'setViewTransition', 'viewTransitionName',
|
|
146
|
+
], note: 'The router lives in what-framework/router.' },
|
|
147
|
+
]);
|
|
148
|
+
|
|
149
|
+
function table(rows) {
|
|
150
|
+
const records = rows.flatMap(({ names, ...row }) => (names ? names.map((name) => ({ name, ...row })) : [row]));
|
|
151
|
+
return Object.freeze(records.map((change) => Object.freeze({ ...change, answer: answerFor(change) })));
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function answerFor({ name, to, as, note }) {
|
|
155
|
+
return to ? `${note} Import it with: import { ${as || name} } from '${to}'.` : `It was removed in 0.15. ${note}`;
|
|
156
|
+
}
|
package/src/index.js
CHANGED
|
@@ -1,30 +1,32 @@
|
|
|
1
1
|
// What Framework - Core
|
|
2
|
-
//
|
|
3
|
-
|
|
4
|
-
//
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
//
|
|
8
|
-
|
|
9
|
-
//
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
//
|
|
14
|
-
//
|
|
15
|
-
|
|
2
|
+
//
|
|
3
|
+
// The root entry: what an app needs to write components, from React's names
|
|
4
|
+
// (which mean what they mean in React) and What's signals. Domain kits are
|
|
5
|
+
// subpaths (what-framework/a11y, /ui, /motion, /dom, /form, /data), the
|
|
6
|
+
// compiled-JSX runtime is what-framework/render, and what sibling packages
|
|
7
|
+
// share with what-core is what-core/internal. test/exports.test.js pins this
|
|
8
|
+
// list, so growth is a decision. Names that left this entry, and where they
|
|
9
|
+
// went, are in import-changes.js.
|
|
10
|
+
|
|
11
|
+
// Reactivity
|
|
12
|
+
export { signal, effect, batch, untrack, flushSync, createRoot, getOwner, runWithOwner } from './reactive.js';
|
|
13
|
+
// Async values in the graph: computed() may return a promise; transitions,
|
|
14
|
+
// optimistic overlays and React 19's use() are built on it (docs/ASYNC.md).
|
|
15
|
+
export { computed, refresh, isPending, startTransition, useTransition, useOptimistic, use, settled } from './async.js';
|
|
16
|
+
// React 19's action hooks, on those transitions.
|
|
17
|
+
export { useActionState, useFormStatus } from './actions.js';
|
|
18
|
+
// O(1) keyed selection: isSelected(key) re-runs only the readers of the keys a change involves.
|
|
19
|
+
export { createSelector } from './selector.js';
|
|
20
|
+
// A live view of the value an accessor returns, for render functions handed a row.
|
|
21
|
+
export { live } from './live.js';
|
|
22
|
+
|
|
23
|
+
// Rendering. h is also a compiler target: compiled JSX imports it from here.
|
|
16
24
|
export { h, Fragment, html } from './h.js';
|
|
17
|
-
|
|
18
|
-
// DOM mounting & rendering (fine-grained, no VDOM reconciler)
|
|
19
25
|
export { mount } from './dom.js';
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
export { _isAriaAttr } from './dom.js';
|
|
23
|
-
// Internal, underscore-prefixed: the component stack lives here, so SSR has to
|
|
24
|
-
// borrow it rather than build a second one that hooks cannot see.
|
|
25
|
-
export { _beginComponentSSR, _endComponentSSR } from './dom.js';
|
|
26
|
+
export { hydrate } from './render.js';
|
|
27
|
+
export { applyStreamedBoundaries } from './hydration-data.js';
|
|
26
28
|
|
|
27
|
-
// Hooks
|
|
29
|
+
// Hooks
|
|
28
30
|
export {
|
|
29
31
|
useState,
|
|
30
32
|
useSignal,
|
|
@@ -33,179 +35,27 @@ export {
|
|
|
33
35
|
useMemo,
|
|
34
36
|
useCallback,
|
|
35
37
|
useRef,
|
|
36
|
-
useContext,
|
|
37
38
|
useReducer,
|
|
38
39
|
createContext,
|
|
40
|
+
useContext,
|
|
39
41
|
onMount,
|
|
40
42
|
onCleanup,
|
|
41
43
|
createResource,
|
|
42
44
|
useLoaderData,
|
|
43
45
|
} from './hooks.js';
|
|
46
|
+
export { useId } from './a11y.js';
|
|
44
47
|
|
|
45
|
-
//
|
|
46
|
-
export { memo, lazy, Suspense, ErrorBoundary, Show, For, Switch, Match
|
|
47
|
-
|
|
48
|
-
// Store
|
|
49
|
-
export { createStore, derived, storeComputed, atom } from './store.js';
|
|
50
|
-
|
|
51
|
-
// Head management
|
|
52
|
-
export { Head, clearHead, beginHeadCollection, endHeadCollection } from './head.js';
|
|
53
|
-
|
|
54
|
-
// SSR render-scoped context (keystone for head collection, loaders, resources)
|
|
55
|
-
export {
|
|
56
|
-
getServerContext,
|
|
57
|
-
setServerContext,
|
|
58
|
-
runWithServerContext,
|
|
59
|
-
__installServerContextStorage,
|
|
60
|
-
} from './server-context.js';
|
|
61
|
-
|
|
62
|
-
// Client hydration payload reader (loader data + resources)
|
|
63
|
-
export { __readHydrationData, __resetHydrationData, getLoaderData, getResource } from './hydration-data.js';
|
|
64
|
-
|
|
65
|
-
// Utilities
|
|
66
|
-
export {
|
|
67
|
-
each,
|
|
68
|
-
cls,
|
|
69
|
-
style,
|
|
70
|
-
debounce,
|
|
71
|
-
throttle,
|
|
72
|
-
useMediaQuery,
|
|
73
|
-
useLocalStorage,
|
|
74
|
-
useClickOutside,
|
|
75
|
-
Portal,
|
|
76
|
-
transition,
|
|
77
|
-
} from './helpers.js';
|
|
78
|
-
|
|
79
|
-
// DOM Scheduler (prevents layout thrashing)
|
|
80
|
-
export {
|
|
81
|
-
scheduleRead,
|
|
82
|
-
scheduleWrite,
|
|
83
|
-
flushScheduler,
|
|
84
|
-
measure,
|
|
85
|
-
mutate,
|
|
86
|
-
useScheduledEffect,
|
|
87
|
-
nextFrame,
|
|
88
|
-
raf,
|
|
89
|
-
onResize,
|
|
90
|
-
onIntersect,
|
|
91
|
-
smoothScrollTo,
|
|
92
|
-
} from './scheduler.js';
|
|
93
|
-
|
|
94
|
-
// Testing utilities (import separately: 'what/testing')
|
|
95
|
-
// export * from './testing.js';
|
|
96
|
-
|
|
97
|
-
// Animation primitives
|
|
98
|
-
export {
|
|
99
|
-
spring,
|
|
100
|
-
tween,
|
|
101
|
-
easings,
|
|
102
|
-
useTransition,
|
|
103
|
-
useGesture,
|
|
104
|
-
useAnimatedValue,
|
|
105
|
-
createTransitionClasses,
|
|
106
|
-
cssTransition,
|
|
107
|
-
} from './animation.js';
|
|
108
|
-
|
|
109
|
-
// Accessibility utilities
|
|
110
|
-
export {
|
|
111
|
-
useFocus,
|
|
112
|
-
useFocusRestore,
|
|
113
|
-
useFocusTrap,
|
|
114
|
-
FocusTrap,
|
|
115
|
-
announce,
|
|
116
|
-
announceAssertive,
|
|
117
|
-
SkipLink,
|
|
118
|
-
useAriaExpanded,
|
|
119
|
-
useAriaSelected,
|
|
120
|
-
useAriaChecked,
|
|
121
|
-
useRovingTabIndex,
|
|
122
|
-
VisuallyHidden,
|
|
123
|
-
LiveRegion,
|
|
124
|
-
useId,
|
|
125
|
-
useIds,
|
|
126
|
-
useDescribedBy,
|
|
127
|
-
useLabelledBy,
|
|
128
|
-
Keys,
|
|
129
|
-
onKey,
|
|
130
|
-
onKeys,
|
|
131
|
-
} from './a11y.js';
|
|
48
|
+
// Components and boundaries
|
|
49
|
+
export { memo, lazy, Suspense, ErrorBoundary, Show, For, Switch, Match } from './components.js';
|
|
50
|
+
export { Portal } from './helpers.js';
|
|
132
51
|
|
|
133
|
-
//
|
|
134
|
-
export {
|
|
135
|
-
Skeleton,
|
|
136
|
-
SkeletonText,
|
|
137
|
-
SkeletonAvatar,
|
|
138
|
-
SkeletonCard,
|
|
139
|
-
SkeletonTable,
|
|
140
|
-
IslandSkeleton,
|
|
141
|
-
useSkeleton,
|
|
142
|
-
Placeholder,
|
|
143
|
-
LoadingDots,
|
|
144
|
-
Spinner,
|
|
145
|
-
} from './skeleton.js';
|
|
52
|
+
// Stores
|
|
53
|
+
export { createStore, derived } from './store.js';
|
|
146
54
|
|
|
147
|
-
//
|
|
148
|
-
export {
|
|
149
|
-
|
|
150
|
-
useSWR,
|
|
151
|
-
useQuery,
|
|
152
|
-
useInfiniteQuery,
|
|
153
|
-
invalidateQueries,
|
|
154
|
-
prefetchQuery,
|
|
155
|
-
setQueryData,
|
|
156
|
-
getQueryData,
|
|
157
|
-
clearCache,
|
|
158
|
-
__getCacheSnapshot,
|
|
159
|
-
} from './data.js';
|
|
55
|
+
// Document head and the server response
|
|
56
|
+
export { Head } from './head.js';
|
|
57
|
+
export { getResponse } from './server-context.js';
|
|
160
58
|
|
|
161
|
-
//
|
|
162
|
-
export {
|
|
163
|
-
|
|
164
|
-
useField,
|
|
165
|
-
rules,
|
|
166
|
-
simpleResolver,
|
|
167
|
-
zodResolver,
|
|
168
|
-
yupResolver,
|
|
169
|
-
Input,
|
|
170
|
-
Textarea,
|
|
171
|
-
Select,
|
|
172
|
-
Checkbox,
|
|
173
|
-
Radio,
|
|
174
|
-
ErrorMessage,
|
|
175
|
-
} from './form.js';
|
|
176
|
-
|
|
177
|
-
// Structured error system (agent-first)
|
|
178
|
-
export {
|
|
179
|
-
WhatError,
|
|
180
|
-
ERROR_CODES,
|
|
181
|
-
getErrorDefinition,
|
|
182
|
-
createWhatError,
|
|
183
|
-
classifyError,
|
|
184
|
-
collectError,
|
|
185
|
-
getCollectedErrors,
|
|
186
|
-
clearCollectedErrors,
|
|
187
|
-
} from './errors.js';
|
|
188
|
-
|
|
189
|
-
// Agent guardrails (dev-mode runtime checks)
|
|
190
|
-
export {
|
|
191
|
-
configureGuardrails,
|
|
192
|
-
getGuardrailConfig,
|
|
193
|
-
installSignalReadGuardrail,
|
|
194
|
-
checkComponentName,
|
|
195
|
-
validateImports,
|
|
196
|
-
} from './guardrails.js';
|
|
197
|
-
|
|
198
|
-
// Generic text insertion hook (used by external text engines like what-text)
|
|
199
|
-
export { _setTextInsertHook } from './render.js';
|
|
200
|
-
|
|
201
|
-
// Agent context (global inspection API)
|
|
202
|
-
export {
|
|
203
|
-
installAgentContext,
|
|
204
|
-
registerComponent,
|
|
205
|
-
unregisterComponent,
|
|
206
|
-
getMountedComponents,
|
|
207
|
-
registerSignal,
|
|
208
|
-
unregisterSignal,
|
|
209
|
-
getActiveSignals,
|
|
210
|
-
getHealth,
|
|
211
|
-
} from './agent-context.js';
|
|
59
|
+
// Diagnostics: what development checks reported, and what a code means
|
|
60
|
+
export { getDiagnostics, subscribe as subscribeDiagnostics, clearDiagnostics } from './diagnostics.js';
|
|
61
|
+
export { getErrorDefinition, WhatError } from './errors.js';
|
package/src/jsx-dev-runtime.js
CHANGED
|
@@ -1,19 +1,12 @@
|
|
|
1
1
|
// What Framework — JSX Dev Runtime
|
|
2
|
-
// Same as jsx-runtime but used in development mode by Vite.
|
|
2
|
+
// Same as jsx-runtime but used in development mode by Vite. jsxDEV's extra
|
|
3
|
+
// arguments (static-children flag, source, self) are not used.
|
|
3
4
|
|
|
4
|
-
import {
|
|
5
|
+
import { Fragment } from './h.js';
|
|
6
|
+
import { jsx } from './jsx-runtime.js';
|
|
5
7
|
|
|
6
8
|
export { Fragment };
|
|
7
9
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
if (key !== undefined) rest.key = key;
|
|
12
|
-
if (children === undefined) return h(type, rest);
|
|
13
|
-
if (Array.isArray(children)) return h(type, rest, ...children);
|
|
14
|
-
return h(type, rest, children);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
// Also export jsx/jsxs for compatibility — some bundlers use these even in dev
|
|
18
|
-
export const jsx = jsxDEV;
|
|
19
|
-
export const jsxs = jsxDEV;
|
|
10
|
+
// jsx/jsxs too: some bundlers use them even in dev.
|
|
11
|
+
export { jsx, jsx as jsxDEV };
|
|
12
|
+
export const jsxs = jsx;
|
package/src/jsx-runtime.js
CHANGED
|
@@ -2,19 +2,35 @@
|
|
|
2
2
|
// Used by: jsxImportSource: "what-framework" (or "what-core")
|
|
3
3
|
// Vite/esbuild import this automatically when using the "react-jsx" transform.
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { Fragment, _jsxVNode } from './h.js';
|
|
6
6
|
|
|
7
7
|
export { Fragment };
|
|
8
8
|
|
|
9
|
-
// Automatic JSX transform signature: jsx(type, { children, ...props }, key)
|
|
10
|
-
//
|
|
9
|
+
// Automatic JSX transform signature: jsx(type, { children, ...props }, key).
|
|
10
|
+
// One pass over the own properties builds the props object the vnode keeps,
|
|
11
|
+
// without `children` or `key`, so h()'s own copy is not needed on top of it
|
|
12
|
+
// (a for-in with an own-property test, not Object.keys: no array per
|
|
13
|
+
// element). The key argument wins over a `key` carried in by a spread.
|
|
11
14
|
export function jsx(type, props, key) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
if (
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
const rest = {};
|
|
16
|
+
let children;
|
|
17
|
+
let k = key;
|
|
18
|
+
if (props != null) {
|
|
19
|
+
for (const name in props) {
|
|
20
|
+
if (!Object.hasOwn(props, name)) continue;
|
|
21
|
+
if (name === 'children') children = props[name];
|
|
22
|
+
else if (name === 'key') { if (k === undefined) k = props[name]; }
|
|
23
|
+
else rest[name] = props[name];
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
// A function that takes an argument is not the vnode's key but a prop,
|
|
27
|
+
// as h() treats it: <For key={(item) => item.id}>. A signal or a getter
|
|
28
|
+
// (`() => doc().id`) is the key.
|
|
29
|
+
if (typeof k === 'function' && k._signal !== true && k.length > 0) {
|
|
30
|
+
rest.key = k;
|
|
31
|
+
k = undefined;
|
|
32
|
+
}
|
|
33
|
+
return _jsxVNode(type, rest, children, k === undefined ? null : k);
|
|
18
34
|
}
|
|
19
35
|
|
|
20
36
|
// jsxs = jsx for static children (multiple). Same behavior for What.
|
package/src/live.js
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// --- live ---
|
|
2
|
+
// A live view of the object an accessor returns: `view.name` reads the
|
|
3
|
+
// accessor's CURRENT value and returns its `name`. JSX built once from the
|
|
4
|
+
// view follows a value replaced under the accessor (a keyed row's item after a
|
|
5
|
+
// refetch, a query's data after it revalidates) instead of being built again.
|
|
6
|
+
//
|
|
7
|
+
// The view is what What reads as live props (dom.js _isLiveProp): an object
|
|
8
|
+
// with no prototype whose properties are getters. `{view.name}` placed in JSX
|
|
9
|
+
// is a reactive child, `class={view.on ? 'a' : 'b'}` a reactive attribute,
|
|
10
|
+
// and `<Cell row={view} />` hands the view on. A getter is defined the first
|
|
11
|
+
// time its key is read on a value that has it as its own property (a Proxy:
|
|
12
|
+
// the keys of the value can change), so making the view reads nothing.
|
|
13
|
+
//
|
|
14
|
+
// A keyed row whose building code reads `view.id` records the field `id`, not
|
|
15
|
+
// the whole item (reactive.js _readKey, _rowItem): a replacement whose `id` is
|
|
16
|
+
// the same keeps the row and the state in it. Listing the view's keys (a
|
|
17
|
+
// spread, Object.keys, JSON.stringify) reads the whole value.
|
|
18
|
+
|
|
19
|
+
import { _readKey, untrack } from './reactive.js';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @template {object} T
|
|
23
|
+
* @param {() => T | null | undefined} source
|
|
24
|
+
* @returns {T}
|
|
25
|
+
*/
|
|
26
|
+
export function live(source) {
|
|
27
|
+
if (typeof source !== 'function') throw new TypeError('live(source): source must be a function that returns the current value');
|
|
28
|
+
const target = Object.create(null);
|
|
29
|
+
const current = (key) => _readKey(key, source);
|
|
30
|
+
// Whether the value has a field is a question, not a read of it: a keyed row
|
|
31
|
+
// checking a prop's liveness (_isLiveProp) records nothing, and the region
|
|
32
|
+
// or binding asking (render.js _place, where it checks a live prop) does not
|
|
33
|
+
// come to depend on the whole value, which would build it again whenever
|
|
34
|
+
// any field changed.
|
|
35
|
+
const peek = () => untrack(() => _readKey(null, source));
|
|
36
|
+
const define = (key) => {
|
|
37
|
+
if (!Object.hasOwn(target, key) && Object.isExtensible(target)) {
|
|
38
|
+
Object.defineProperty(target, key, {
|
|
39
|
+
get: () => {
|
|
40
|
+
const value = current(key);
|
|
41
|
+
return value == null ? undefined : value[key];
|
|
42
|
+
},
|
|
43
|
+
enumerable: true,
|
|
44
|
+
configurable: true,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
return new Proxy(target, {
|
|
49
|
+
get(t, key) {
|
|
50
|
+
if (typeof key !== 'string') return undefined;
|
|
51
|
+
const value = current(key);
|
|
52
|
+
if (value == null) return undefined;
|
|
53
|
+
if (Object.hasOwn(value, key)) define(key);
|
|
54
|
+
return value[key];
|
|
55
|
+
},
|
|
56
|
+
getOwnPropertyDescriptor(t, key) {
|
|
57
|
+
if (typeof key !== 'string') return undefined;
|
|
58
|
+
// A key defined once stays reported: a frozen view may not lose one.
|
|
59
|
+
if (!Object.hasOwn(t, key)) {
|
|
60
|
+
const value = peek();
|
|
61
|
+
if (value == null || !Object.hasOwn(value, key)) return undefined;
|
|
62
|
+
define(key);
|
|
63
|
+
}
|
|
64
|
+
return Reflect.getOwnPropertyDescriptor(t, key);
|
|
65
|
+
},
|
|
66
|
+
has(t, key) {
|
|
67
|
+
if (typeof key !== 'string') return false;
|
|
68
|
+
const value = peek();
|
|
69
|
+
return (value != null && key in Object(value)) || Object.hasOwn(t, key);
|
|
70
|
+
},
|
|
71
|
+
ownKeys(t) {
|
|
72
|
+
const value = source();
|
|
73
|
+
if (value != null) for (const key of Object.keys(value)) define(key);
|
|
74
|
+
return Reflect.ownKeys(t);
|
|
75
|
+
},
|
|
76
|
+
set() {
|
|
77
|
+
return false;
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
}
|