what-core 0.13.11 → 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,548 @@
|
|
|
1
|
+
// src/errors.js
|
|
2
|
+
var a = {
|
|
3
|
+
INFINITE_EFFECT: {
|
|
4
|
+
code: "ERR_INFINITE_EFFECT",
|
|
5
|
+
severity: "error",
|
|
6
|
+
template: 'Effect "{{effectName}}" was stopped after {{rounds}} re-runs in one flush: it keeps re-triggering itself, likely an infinite loop.'
|
|
7
|
+
},
|
|
8
|
+
COMPUTED_CYCLE: {
|
|
9
|
+
code: "ERR_COMPUTED_CYCLE",
|
|
10
|
+
severity: "error",
|
|
11
|
+
template: 'Computed "{{name}}" reads its own value, directly or through computeds that read it.'
|
|
12
|
+
},
|
|
13
|
+
SIGNAL_WRITE_IN_COMPUTED: {
|
|
14
|
+
code: "ERR_SIGNAL_WRITE_IN_COMPUTED",
|
|
15
|
+
severity: "warning",
|
|
16
|
+
template: 'Computed "{{computedName}}" wrote signal "{{signalName}}". A computed only derives a value; a write from it runs again on every recomputation and can loop.'
|
|
17
|
+
},
|
|
18
|
+
NESTED_FLUSH_SYNC: {
|
|
19
|
+
code: "ERR_NESTED_FLUSH_SYNC",
|
|
20
|
+
severity: "warning",
|
|
21
|
+
template: "flushSync() was called while {{context}} was running, so it did nothing: the effects it would run already run when the current flush reaches them."
|
|
22
|
+
},
|
|
23
|
+
MISSING_SIGNAL_READ: {
|
|
24
|
+
code: "ERR_MISSING_SIGNAL_READ",
|
|
25
|
+
severity: "warning",
|
|
26
|
+
template: 'Signal "{{signalName}}" was used as a value without being called (in a template literal, `+`, arithmetic, a comparison or as a property key), so the function\'s source text stood in for its value.'
|
|
27
|
+
},
|
|
28
|
+
HYDRATION_MISMATCH: {
|
|
29
|
+
code: "ERR_HYDRATION_MISMATCH",
|
|
30
|
+
severity: "error",
|
|
31
|
+
template: "Hydration mismatch ({{kind}}) in <{{component}}> at {{path}}: the server rendered {{found}} where the client renders {{expected}}. Recovery: {{recovery}}."
|
|
32
|
+
},
|
|
33
|
+
HYDRATION_OWNER_MISMATCH: {
|
|
34
|
+
code: "ERR_HYDRATION_OWNER_MISMATCH",
|
|
35
|
+
severity: "warning",
|
|
36
|
+
template: "A keyless resource or async value at owner path {{path}} was rendered by <{{server}}> on the server and <{{client}}> on the client, so it fetches instead of adopting the server value."
|
|
37
|
+
},
|
|
38
|
+
ORPHAN_EFFECT: {
|
|
39
|
+
code: "ERR_ORPHAN_EFFECT",
|
|
40
|
+
severity: "warning",
|
|
41
|
+
template: 'Effect "{{effectName}}" was created after an await, where no owner is current: nothing will dispose it when the component that started the async work goes away.'
|
|
42
|
+
},
|
|
43
|
+
REBUILT_COMPONENT: {
|
|
44
|
+
code: "ERR_REBUILT_COMPONENT",
|
|
45
|
+
severity: "warning",
|
|
46
|
+
template: 'A reactive region rebuilt <{{component}}> when it ran again, and the state <{{component}}> held is gone: "{{region}}" builds everything it returns anew on every run.'
|
|
47
|
+
},
|
|
48
|
+
ASYNC_EFFECT: {
|
|
49
|
+
code: "ERR_ASYNC_EFFECT",
|
|
50
|
+
severity: "warning",
|
|
51
|
+
template: 'Effect "{{effectName}}" is an async function. Only what it reads before its first await is tracked, the promise it returns is not a cleanup, and an older run can finish after a newer one and overwrite it.'
|
|
52
|
+
},
|
|
53
|
+
PENDING_READ_UNTRACKED: {
|
|
54
|
+
code: "ERR_PENDING_READ_UNTRACKED",
|
|
55
|
+
severity: "warning",
|
|
56
|
+
template: "{{call}} was read in a component body. The body runs once, so this reads the pending state once and it never changes on screen."
|
|
57
|
+
},
|
|
58
|
+
WRITE_AFTER_AWAIT: {
|
|
59
|
+
code: "ERR_WRITE_AFTER_AWAIT",
|
|
60
|
+
severity: "warning",
|
|
61
|
+
template: 'Signal "{{signalName}}" was written outside a transition while the async function of a transition that also wrote it was still running: a write after an await is not part of the transition, so it shows before the transition commits.'
|
|
62
|
+
},
|
|
63
|
+
ASYNC_WITHOUT_SUSPENSE: {
|
|
64
|
+
code: "ERR_ASYNC_WITHOUT_SUSPENSE",
|
|
65
|
+
severity: "warning",
|
|
66
|
+
template: 'Component "{{component}}" suspended (lazy(), use() or a value that had not landed, read in its body) with no <Suspense> above it: it renders nothing until the promise settles.'
|
|
67
|
+
},
|
|
68
|
+
ASYNC_READ_IN_BODY: {
|
|
69
|
+
code: "ERR_ASYNC_READ_IN_BODY",
|
|
70
|
+
severity: "error",
|
|
71
|
+
template: 'Component "{{component}}" read an async value it made in its own body before the value landed: suspending would run it again, make the value again and fetch again, forever.'
|
|
72
|
+
},
|
|
73
|
+
USE_UNCACHED_PROMISE: {
|
|
74
|
+
code: "ERR_USE_UNCACHED_PROMISE",
|
|
75
|
+
severity: "error",
|
|
76
|
+
template: 'Component "{{component}}" keeps suspending on a new promise: use() received a promise made in the component body, which is new on every attempt, so it never finishes.'
|
|
77
|
+
},
|
|
78
|
+
OPTIMISTIC_OUTSIDE_TRANSITION: {
|
|
79
|
+
code: "ERR_OPTIMISTIC_OUTSIDE_TRANSITION",
|
|
80
|
+
severity: "warning",
|
|
81
|
+
template: "addOptimistic() was called outside a transition, so the optimistic value drops at once instead of lasting until the action finishes."
|
|
82
|
+
},
|
|
83
|
+
ASYNC_COMPONENT: {
|
|
84
|
+
code: "ERR_ASYNC_COMPONENT",
|
|
85
|
+
severity: "warning",
|
|
86
|
+
template: 'Component "{{component}}" returned a promise: an async component renders as text.'
|
|
87
|
+
},
|
|
88
|
+
ASYNC_MEMO: {
|
|
89
|
+
code: "ERR_ASYNC_MEMO",
|
|
90
|
+
severity: "warning",
|
|
91
|
+
template: "useMemo() returned a promise; useMemo keeps it, so its readers get the promise."
|
|
92
|
+
},
|
|
93
|
+
SUSPEND_IN_TRANSITION: {
|
|
94
|
+
code: "ERR_SUSPEND_IN_TRANSITION",
|
|
95
|
+
severity: "warning",
|
|
96
|
+
template: 'Component "{{component}}" suspended while a transition committed: its fallback shows.'
|
|
97
|
+
},
|
|
98
|
+
SIGNAL_WRITE_IN_RENDER: {
|
|
99
|
+
code: "ERR_SIGNAL_WRITE_IN_RENDER",
|
|
100
|
+
severity: "error",
|
|
101
|
+
template: 'Signal "{{signalName}}" written during render of component "{{component}}". This triggers re-execution.'
|
|
102
|
+
},
|
|
103
|
+
MISSING_CLEANUP: {
|
|
104
|
+
code: "ERR_MISSING_CLEANUP",
|
|
105
|
+
severity: "warning",
|
|
106
|
+
template: 'Effect sets up "{{resource}}" but does not return a cleanup function.'
|
|
107
|
+
},
|
|
108
|
+
UNSAFE_INNERHTML: {
|
|
109
|
+
code: "ERR_UNSAFE_INNERHTML",
|
|
110
|
+
severity: "warning",
|
|
111
|
+
template: "innerHTML set on element without using the __html safety marker."
|
|
112
|
+
},
|
|
113
|
+
MISSING_KEY: {
|
|
114
|
+
code: "ERR_MISSING_KEY",
|
|
115
|
+
severity: "warning",
|
|
116
|
+
template: "A .map() returns JSX without a key prop."
|
|
117
|
+
},
|
|
118
|
+
PROP_READ_ONCE: {
|
|
119
|
+
code: "ERR_PROP_READ_ONCE",
|
|
120
|
+
severity: "warning",
|
|
121
|
+
template: "Prop `{{name}}` is read once, when <{{component}}> runs: {{reason}}."
|
|
122
|
+
},
|
|
123
|
+
STATE_READ_ONCE: {
|
|
124
|
+
code: "ERR_STATE_READ_ONCE",
|
|
125
|
+
severity: "warning",
|
|
126
|
+
template: "State `{{name}}` is read once in <{{component}}>: {{reason}}."
|
|
127
|
+
},
|
|
128
|
+
CLEANUP_READS_LIVE: {
|
|
129
|
+
code: "ERR_CLEANUP_READS_LIVE",
|
|
130
|
+
severity: "warning",
|
|
131
|
+
template: "The {{hook}} cleanup in <{{component}}> reads `{{name}}` when it runs, not the value its run used."
|
|
132
|
+
},
|
|
133
|
+
DUPLICATE_KEY: {
|
|
134
|
+
code: "ERR_DUPLICATE_KEY",
|
|
135
|
+
severity: "warning",
|
|
136
|
+
template: "A keyed list has more than one item with the key {{key}}."
|
|
137
|
+
},
|
|
138
|
+
SYMBOL_CHILD: {
|
|
139
|
+
code: "ERR_SYMBOL_CHILD",
|
|
140
|
+
severity: "warning",
|
|
141
|
+
template: "A Symbol ({{symbol}}) is a child of <{{component}}>, which renders nothing for it ({{path}})."
|
|
142
|
+
},
|
|
143
|
+
ASYNC_MIDDLEWARE: {
|
|
144
|
+
code: "ERR_ASYNC_MIDDLEWARE",
|
|
145
|
+
severity: "error",
|
|
146
|
+
template: "Route middleware must be synchronous; received a promise or thenable."
|
|
147
|
+
},
|
|
148
|
+
UNSAFE_REDIRECT: {
|
|
149
|
+
code: "ERR_UNSAFE_REDIRECT",
|
|
150
|
+
severity: "error",
|
|
151
|
+
template: "redirect() refused an unsafe target: {{target}}"
|
|
152
|
+
},
|
|
153
|
+
REDIRECT_NOT_CAUGHT: {
|
|
154
|
+
code: "ERR_REDIRECT_NOT_CAUGHT",
|
|
155
|
+
severity: "error",
|
|
156
|
+
template: "[what-router] redirect to {{target}}"
|
|
157
|
+
},
|
|
158
|
+
REDIRECT_CYCLE: {
|
|
159
|
+
code: "ERR_REDIRECT_CYCLE",
|
|
160
|
+
severity: "error",
|
|
161
|
+
template: "[what-router] Redirect loop ({{kind}}): {{cycle}}. Guards of: {{guards}}."
|
|
162
|
+
},
|
|
163
|
+
HOOK_OUTSIDE_COMPONENT: {
|
|
164
|
+
code: "ERR_HOOK_OUTSIDE_COMPONENT",
|
|
165
|
+
severity: "error",
|
|
166
|
+
template: "{{hookName}}() can only be called inside a component function. Did you call it outside of a component or in an async callback? If you need reactive state outside a component, use signal() directly."
|
|
167
|
+
},
|
|
168
|
+
EFFECT_DEP_NOT_FUNCTION: {
|
|
169
|
+
code: "ERR_EFFECT_DEP_NOT_FUNCTION",
|
|
170
|
+
severity: "warning",
|
|
171
|
+
template: "useEffect dependency at index {{index}} is a plain value, so the effect cannot re-run when it changes."
|
|
172
|
+
},
|
|
173
|
+
EFFECT_DEP_NOT_SIGNAL: {
|
|
174
|
+
code: "ERR_EFFECT_DEP_NOT_SIGNAL",
|
|
175
|
+
severity: "warning",
|
|
176
|
+
template: "useEffect dependency {{index}} is a function, never read."
|
|
177
|
+
},
|
|
178
|
+
CONTEXT_NOT_PROVIDED: {
|
|
179
|
+
code: "ERR_CONTEXT_NOT_PROVIDED",
|
|
180
|
+
severity: "warning",
|
|
181
|
+
template: "{{context}} was read with no provider above the component and has no default value, so useContext returned undefined."
|
|
182
|
+
},
|
|
183
|
+
CLEANUP_WITHOUT_OWNER: {
|
|
184
|
+
code: "ERR_CLEANUP_WITHOUT_OWNER",
|
|
185
|
+
severity: "warning",
|
|
186
|
+
template: "onCleanup() was called outside a component and outside any reactive owner, so the cleanup never runs."
|
|
187
|
+
},
|
|
188
|
+
DERIVED_WITHOUT_STATE: {
|
|
189
|
+
code: "ERR_DERIVED_WITHOUT_STATE",
|
|
190
|
+
severity: "warning",
|
|
191
|
+
template: 'derived() for "{{key}}" takes no parameter, so it cannot read the store state.'
|
|
192
|
+
},
|
|
193
|
+
FORM_HANDLER_WITHOUT_EVENT: {
|
|
194
|
+
code: "ERR_FORM_HANDLER_WITHOUT_EVENT",
|
|
195
|
+
severity: "warning",
|
|
196
|
+
template: 'register("{{name}}") change handler was called without an event; the field was left unchanged.'
|
|
197
|
+
},
|
|
198
|
+
FORM_RADIO_WITHOUT_VALUE: {
|
|
199
|
+
code: "ERR_FORM_RADIO_WITHOUT_VALUE",
|
|
200
|
+
severity: "warning",
|
|
201
|
+
template: 'Radio for field "{{name}}" has no value, so it cannot record a choice.'
|
|
202
|
+
},
|
|
203
|
+
FORM_RADIO_UNTYPED: {
|
|
204
|
+
code: "ERR_FORM_RADIO_UNTYPED",
|
|
205
|
+
severity: "warning",
|
|
206
|
+
template: `register("{{name}}") was spread onto a radio without { type: 'radio' }, which overwrote the radio's value.`
|
|
207
|
+
},
|
|
208
|
+
STORAGE_FAILED: {
|
|
209
|
+
code: "ERR_STORAGE_FAILED",
|
|
210
|
+
severity: "warning",
|
|
211
|
+
template: 'useLocalStorage("{{key}}") could not {{operation}} localStorage: {{reason}}.'
|
|
212
|
+
},
|
|
213
|
+
PORTAL_TARGET_MISSING: {
|
|
214
|
+
code: "ERR_PORTAL_TARGET_MISSING",
|
|
215
|
+
severity: "warning",
|
|
216
|
+
template: '<Portal target="{{selector}}"> matched no element, so its children render nowhere.'
|
|
217
|
+
},
|
|
218
|
+
MOUNT_TARGET_MISSING: {
|
|
219
|
+
code: "ERR_MOUNT_TARGET_MISSING",
|
|
220
|
+
severity: "error",
|
|
221
|
+
template: "{{fn}}() got no container element."
|
|
222
|
+
},
|
|
223
|
+
NO_SECURE_RANDOM: {
|
|
224
|
+
code: "ERR_NO_SECURE_RANDOM",
|
|
225
|
+
severity: "error",
|
|
226
|
+
template: "No secure random source available for CSRF token generation."
|
|
227
|
+
},
|
|
228
|
+
PAYLOAD_TOO_LARGE: {
|
|
229
|
+
code: "ERR_PAYLOAD_TOO_LARGE",
|
|
230
|
+
severity: "error",
|
|
231
|
+
template: "A call over the {{limit}}-byte bodyLimit was refused."
|
|
232
|
+
},
|
|
233
|
+
ACTION_FAILED: {
|
|
234
|
+
code: "ERR_ACTION_FAILED",
|
|
235
|
+
severity: "error",
|
|
236
|
+
template: "{{message}}"
|
|
237
|
+
},
|
|
238
|
+
STATIC_WRITE_ESCAPE: {
|
|
239
|
+
code: "ERR_STATIC_WRITE_ESCAPE",
|
|
240
|
+
severity: "error",
|
|
241
|
+
template: "[what-server] Refusing to write outside outDir: {{path}}"
|
|
242
|
+
},
|
|
243
|
+
INVALID_HTML_NESTING: {
|
|
244
|
+
code: "ERR_INVALID_HTML_NESTING",
|
|
245
|
+
severity: "error",
|
|
246
|
+
template: "<{{parent}}> cannot contain <{{child}}>: the HTML parser closed the outer tag early, so the rendered tree does not match your JSX."
|
|
247
|
+
},
|
|
248
|
+
TEMPLATE_NAMESPACE: {
|
|
249
|
+
code: "ERR_TEMPLATE_NAMESPACE",
|
|
250
|
+
severity: "error",
|
|
251
|
+
template: "The compiled template for <{{tag}}> has no namespace flag, so its root would render as an unknown HTML element instead of SVG or MathML."
|
|
252
|
+
},
|
|
253
|
+
COMPILER_RUNTIME_MISMATCH: {
|
|
254
|
+
code: "ERR_COMPILER_RUNTIME_MISMATCH",
|
|
255
|
+
severity: "error",
|
|
256
|
+
template: "what-compiler {{compiler}} cannot build for {{name}} {{version}} ({{file}})."
|
|
257
|
+
},
|
|
258
|
+
HOT_UPDATE_FAILED: {
|
|
259
|
+
code: "ERR_HOT_UPDATE_FAILED",
|
|
260
|
+
severity: "error",
|
|
261
|
+
template: 'The edit to {{file}} was not applied: {{phase}} threw "{{message}}". The page keeps running the code it had before the edit.'
|
|
262
|
+
},
|
|
263
|
+
NO_VNODE_RENDERER: {
|
|
264
|
+
code: "ERR_NO_VNODE_RENDERER",
|
|
265
|
+
severity: "error",
|
|
266
|
+
template: "{{what}} reached the compiled-JSX runtime, but no vnode renderer is installed."
|
|
267
|
+
},
|
|
268
|
+
INVALID_SSR_TAG: {
|
|
269
|
+
code: "ERR_INVALID_SSR_TAG",
|
|
270
|
+
severity: "error",
|
|
271
|
+
template: 'Invalid tag name in SSR: "{{tag}}"'
|
|
272
|
+
},
|
|
273
|
+
COMPILED_JSX_IN_SSR: {
|
|
274
|
+
code: "ERR_COMPILED_JSX_IN_SSR",
|
|
275
|
+
severity: "error",
|
|
276
|
+
template: "what-compiler client output cannot be server-rendered: {{file}}."
|
|
277
|
+
},
|
|
278
|
+
FOREIGN_ENGINE_IN_SSR: {
|
|
279
|
+
code: "ERR_FOREIGN_ENGINE_IN_SSR",
|
|
280
|
+
severity: "error",
|
|
281
|
+
template: "An async value was made by a second copy of what-core during a server render."
|
|
282
|
+
},
|
|
283
|
+
SECOND_CORE_COPY: {
|
|
284
|
+
code: "ERR_SECOND_CORE_COPY",
|
|
285
|
+
severity: "warning",
|
|
286
|
+
template: "A second copy of what-core is running on this page."
|
|
287
|
+
},
|
|
288
|
+
UNSAFE_STATIC_MARKUP: {
|
|
289
|
+
code: "ERR_UNSAFE_STATIC_MARKUP",
|
|
290
|
+
severity: "error",
|
|
291
|
+
template: "Refused unsafe static markup: {{message}}"
|
|
292
|
+
},
|
|
293
|
+
JSX_ISLAND_PROP: {
|
|
294
|
+
code: "ERR_JSX_ISLAND_PROP",
|
|
295
|
+
severity: "error",
|
|
296
|
+
template: "An island prop holds JSX: {{message}}"
|
|
297
|
+
},
|
|
298
|
+
SSR_SUSPENSE_TIMEOUT: {
|
|
299
|
+
code: "ERR_SSR_SUSPENSE_TIMEOUT",
|
|
300
|
+
severity: "error",
|
|
301
|
+
template: "[what-server] A resource was still pending after 12 attempts during streaming SSR."
|
|
302
|
+
},
|
|
303
|
+
LATE_REDIRECT: {
|
|
304
|
+
code: "ERR_LATE_REDIRECT",
|
|
305
|
+
severity: "error",
|
|
306
|
+
template: "[what-server] redirect({{location}}) after the shell was sent needs an inline script, and this stream has noScripts."
|
|
307
|
+
},
|
|
308
|
+
SSR_UNSAFE_REDIRECT: {
|
|
309
|
+
code: "ERR_SSR_UNSAFE_REDIRECT",
|
|
310
|
+
severity: "warning",
|
|
311
|
+
template: "[what-server] {{method}}: refusing unsafe redirect target {{target}}; redirecting to {{root}} instead. (ERR_SSR_UNSAFE_REDIRECT)"
|
|
312
|
+
},
|
|
313
|
+
SSR_INVALID_ID_PREFIX: {
|
|
314
|
+
code: "ERR_SSR_INVALID_ID_PREFIX",
|
|
315
|
+
severity: "error",
|
|
316
|
+
template: 'idPrefix {{idPrefix}} is not a letter followed by letters, digits, "_" or "-".'
|
|
317
|
+
},
|
|
318
|
+
SSR_LATE_HEAD: {
|
|
319
|
+
code: "ERR_SSR_LATE_HEAD",
|
|
320
|
+
severity: "warning",
|
|
321
|
+
template: "[what-server] <Head> inside a streamed <Suspense> (boundary {{boundaryId}}) set head tags after the shell was sent."
|
|
322
|
+
},
|
|
323
|
+
FORM_ACTION_MISSING: {
|
|
324
|
+
code: "ERR_FORM_ACTION_MISSING",
|
|
325
|
+
severity: "error",
|
|
326
|
+
template: "<Form> requires an `action` prop: a server action, its id, or a function."
|
|
327
|
+
},
|
|
328
|
+
ISLAND_WITHOUT_NAME: {
|
|
329
|
+
code: "ERR_ISLAND_WITHOUT_NAME",
|
|
330
|
+
severity: "warning",
|
|
331
|
+
template: "Island <{{component}}> has no `name`: a minified build renames its function, so the server and the browser name the island differently."
|
|
332
|
+
},
|
|
333
|
+
ISLAND_STORE_OUTSIDE_RENDER: {
|
|
334
|
+
code: "ERR_ISLAND_STORE_OUTSIDE_RENDER",
|
|
335
|
+
severity: "error",
|
|
336
|
+
template: 'Island store "{{name}}" was accessed outside an active server render.'
|
|
337
|
+
},
|
|
338
|
+
QUERY_OUTSIDE_RENDER: {
|
|
339
|
+
code: "ERR_QUERY_OUTSIDE_RENDER",
|
|
340
|
+
severity: "warning",
|
|
341
|
+
template: "[what] Server query cache used outside a render, loader or action."
|
|
342
|
+
},
|
|
343
|
+
ISR_MISSING_CLIENT: {
|
|
344
|
+
code: "ERR_ISR_MISSING_CLIENT",
|
|
345
|
+
severity: "error",
|
|
346
|
+
template: "[what-isr] createRedisStore requires { client }"
|
|
347
|
+
},
|
|
348
|
+
ISR_VARY_UNRESOLVED: {
|
|
349
|
+
code: "ERR_ISR_VARY_UNRESOLVED",
|
|
350
|
+
severity: "error",
|
|
351
|
+
template: "[what-isr] cannot build a cache key: `vary` is declared but could not be resolved against the request."
|
|
352
|
+
},
|
|
353
|
+
ISR_VARY_NO_HEADERS: {
|
|
354
|
+
code: "ERR_ISR_VARY_NO_HEADERS",
|
|
355
|
+
severity: "error",
|
|
356
|
+
template: "[what-isr] route declares `vary` but the adapter supplied no request headers; refusing to cache."
|
|
357
|
+
},
|
|
358
|
+
DUPLICATE_ACTION_ID: {
|
|
359
|
+
code: "ERR_DUPLICATE_ACTION_ID",
|
|
360
|
+
severity: "error",
|
|
361
|
+
template: 'Duplicate server action ID "{{id}}".'
|
|
362
|
+
},
|
|
363
|
+
PAGE_NO_DEFAULT_EXPORT: {
|
|
364
|
+
code: "ERR_PAGE_NO_DEFAULT_EXPORT",
|
|
365
|
+
severity: "error",
|
|
366
|
+
template: "Page module has no default-exported component."
|
|
367
|
+
},
|
|
368
|
+
HOOK_OUTSIDE_RENDER: {
|
|
369
|
+
code: "ERR_HOOK_OUTSIDE_RENDER",
|
|
370
|
+
severity: "error",
|
|
371
|
+
template: "[what-react] {{hookName}}() called outside of a component render."
|
|
372
|
+
},
|
|
373
|
+
NOT_TRANSLATED: {
|
|
374
|
+
code: "ERR_NOT_TRANSLATED",
|
|
375
|
+
severity: "warning",
|
|
376
|
+
template: "[what-react] <{{component}}> stays a React component on what-react: {{reason}}."
|
|
377
|
+
},
|
|
378
|
+
CLASS_COMPONENT_NOT_INSTALLED: {
|
|
379
|
+
code: "ERR_CLASS_COMPONENT_NOT_INSTALLED",
|
|
380
|
+
severity: "error",
|
|
381
|
+
template: "[what-react] {{name}} is a class component, which this bundle cannot render: use what-react's Vite plugin, import 'what-react/class', or extend Component."
|
|
382
|
+
},
|
|
383
|
+
CHILDREN_ONLY: {
|
|
384
|
+
code: "ERR_CHILDREN_ONLY",
|
|
385
|
+
severity: "error",
|
|
386
|
+
template: "React.Children.only expected to receive a single React element child."
|
|
387
|
+
},
|
|
388
|
+
RECONCILER_CHILD: {
|
|
389
|
+
code: "ERR_RECONCILER_CHILD",
|
|
390
|
+
severity: "error",
|
|
391
|
+
template: "[what-react] A custom renderer's tree cannot render {{what}}."
|
|
392
|
+
},
|
|
393
|
+
RECONCILER_PERSISTENCE: {
|
|
394
|
+
code: "ERR_RECONCILER_PERSISTENCE",
|
|
395
|
+
severity: "error",
|
|
396
|
+
template: "[what-react] This renderer uses persistence mode (supportsMutation: false), which what-react's react-reconciler does not support."
|
|
397
|
+
},
|
|
398
|
+
USE_INVALID_ARG: {
|
|
399
|
+
code: "ERR_USE_INVALID_ARG",
|
|
400
|
+
severity: "error",
|
|
401
|
+
template: "[what-react] use() expects a promise or a context."
|
|
402
|
+
},
|
|
403
|
+
PRETEXT_NOT_INSTALLED: {
|
|
404
|
+
code: "ERR_PRETEXT_NOT_INSTALLED",
|
|
405
|
+
severity: "error",
|
|
406
|
+
template: "[what-text] Failed to load @chenglou/pretext: {{message}}."
|
|
407
|
+
},
|
|
408
|
+
DEPENDENCY_JSX: {
|
|
409
|
+
code: "ERR_DEPENDENCY_JSX",
|
|
410
|
+
severity: "error",
|
|
411
|
+
template: "[what-compiler] {{package}} ships JSX in {{file}} without declaring What."
|
|
412
|
+
},
|
|
413
|
+
MOVED_IMPORT: {
|
|
414
|
+
code: "ERR_MOVED_IMPORT",
|
|
415
|
+
severity: "error",
|
|
416
|
+
template: '"{{name}}" is not exported by {{source}}. {{answer}}'
|
|
417
|
+
},
|
|
418
|
+
RUNTIME: {
|
|
419
|
+
code: "ERR_RUNTIME",
|
|
420
|
+
severity: "error",
|
|
421
|
+
template: "{{message}}"
|
|
422
|
+
},
|
|
423
|
+
UNKNOWN: {
|
|
424
|
+
code: "ERR_UNKNOWN",
|
|
425
|
+
severity: "error",
|
|
426
|
+
template: "Unknown error: {{errorCode}}"
|
|
427
|
+
},
|
|
428
|
+
UNKNOWN_TOOL: {
|
|
429
|
+
code: "ERR_UNKNOWN_TOOL",
|
|
430
|
+
severity: "error",
|
|
431
|
+
template: "Unknown tool: {{name}}."
|
|
432
|
+
}
|
|
433
|
+
}, E = null;
|
|
434
|
+
function N(t) {
|
|
435
|
+
return E === null && (E = new Map(Object.values(a).map((e) => [e.code, e]))), E.get(t);
|
|
436
|
+
}
|
|
437
|
+
var o = class extends Error {
|
|
438
|
+
// codeExample carries the bad/good pair from the error's ERROR_CODES entry.
|
|
439
|
+
// Every entry above already had one; the class simply dropped it on the
|
|
440
|
+
// floor, so the field the docs promise on the serialized error was never
|
|
441
|
+
// there and `suggestion` had to carry the whole fix in prose. It matters more
|
|
442
|
+
// here than in a framework aimed at humans: the audience reading toJSON() is
|
|
443
|
+
// usually an agent, and a diff-shaped example is the part it can copy.
|
|
444
|
+
//
|
|
445
|
+
// The class never reads the catalogue: it is a root export that apps import
|
|
446
|
+
// for `instanceof`, and a lookup here kept all of ERROR_CODES (about 14 KB
|
|
447
|
+
// gzipped) in those bundles. createWhatError() and classifyError() fill
|
|
448
|
+
// severity, suggestion and codeExample from the entry.
|
|
449
|
+
/**
|
|
450
|
+
* @param {object} init
|
|
451
|
+
* @param {string} init.code
|
|
452
|
+
* @param {'error' | 'warning'} [init.severity]
|
|
453
|
+
* @param {string} [init.message]
|
|
454
|
+
* @param {string} [init.suggestion]
|
|
455
|
+
* @param {{ bad?: string, good?: string } | string} [init.codeExample]
|
|
456
|
+
* @param {string} [init.file]
|
|
457
|
+
* @param {number} [init.line]
|
|
458
|
+
* @param {string} [init.component]
|
|
459
|
+
* @param {string} [init.signal]
|
|
460
|
+
* @param {string} [init.effect]
|
|
461
|
+
*/
|
|
462
|
+
constructor({ code: e, severity: n, message: r, suggestion: i, codeExample: s, file: _, line: R, component: c, signal: d, effect: l }) {
|
|
463
|
+
super(r), this.name = "WhatError", this.code = e, this.severity = n || "error", this.suggestion = i, this.codeExample = s, this.file = _, this.line = R, this.component = c, this.signal = d, this.effect = l;
|
|
464
|
+
}
|
|
465
|
+
toJSON() {
|
|
466
|
+
return {
|
|
467
|
+
code: this.code,
|
|
468
|
+
severity: this.severity,
|
|
469
|
+
message: this.message,
|
|
470
|
+
suggestion: this.suggestion,
|
|
471
|
+
codeExample: this.codeExample,
|
|
472
|
+
file: this.file,
|
|
473
|
+
line: this.line,
|
|
474
|
+
component: this.component,
|
|
475
|
+
signal: this.signal,
|
|
476
|
+
effect: this.effect
|
|
477
|
+
};
|
|
478
|
+
}
|
|
479
|
+
};
|
|
480
|
+
function p(t, e = {}) {
|
|
481
|
+
let n = typeof t == "string" ? a[t] : t;
|
|
482
|
+
if (!n)
|
|
483
|
+
return new o({
|
|
484
|
+
code: "ERR_UNKNOWN",
|
|
485
|
+
severity: (
|
|
486
|
+
/** @type {'error' | 'warning'} */
|
|
487
|
+
a.UNKNOWN.severity
|
|
488
|
+
),
|
|
489
|
+
message: `Unknown error: ${t}`,
|
|
490
|
+
suggestion: a.UNKNOWN.suggestion,
|
|
491
|
+
codeExample: a.UNKNOWN.codeExample
|
|
492
|
+
});
|
|
493
|
+
let r = n.template;
|
|
494
|
+
for (let [i, s] of Object.entries(e))
|
|
495
|
+
r = r.replace(new RegExp(`\\{\\{${i}\\}\\}`, "g"), String(s));
|
|
496
|
+
return r = r.replace(/\{\{[^}]+\}\}/g, "(unknown)"), new o({
|
|
497
|
+
code: n.code,
|
|
498
|
+
severity: n.severity,
|
|
499
|
+
message: r,
|
|
500
|
+
suggestion: n.suggestion,
|
|
501
|
+
// Verbatim from the definition: codeExample is a worked bad/good pair, not
|
|
502
|
+
// a template, so there is nothing in it to interpolate.
|
|
503
|
+
codeExample: n.codeExample,
|
|
504
|
+
file: e.file,
|
|
505
|
+
line: e.line,
|
|
506
|
+
component: e.component,
|
|
507
|
+
signal: e.signal || e.signalName,
|
|
508
|
+
effect: e.effect || e.effectName
|
|
509
|
+
});
|
|
510
|
+
}
|
|
511
|
+
function m(t, e = {}) {
|
|
512
|
+
let n = t?.message || String(t);
|
|
513
|
+
if (t && typeof t.code == "string") {
|
|
514
|
+
let r = N(t.code);
|
|
515
|
+
if (r)
|
|
516
|
+
return new o({
|
|
517
|
+
code: r.code,
|
|
518
|
+
severity: r.severity,
|
|
519
|
+
// The thrown message is the specific one; the template is generic.
|
|
520
|
+
message: n,
|
|
521
|
+
suggestion: r.suggestion,
|
|
522
|
+
codeExample: r.codeExample,
|
|
523
|
+
file: e.file,
|
|
524
|
+
line: e.line,
|
|
525
|
+
component: e.component,
|
|
526
|
+
signal: e.signal || e.signalName,
|
|
527
|
+
effect: e.effect || e.effectName
|
|
528
|
+
});
|
|
529
|
+
}
|
|
530
|
+
return new o({
|
|
531
|
+
code: "ERR_RUNTIME",
|
|
532
|
+
severity: (
|
|
533
|
+
/** @type {'error' | 'warning'} */
|
|
534
|
+
a.RUNTIME.severity
|
|
535
|
+
),
|
|
536
|
+
message: n,
|
|
537
|
+
suggestion: a.RUNTIME.suggestion,
|
|
538
|
+
codeExample: a.RUNTIME.codeExample,
|
|
539
|
+
...e
|
|
540
|
+
});
|
|
541
|
+
}
|
|
542
|
+
export {
|
|
543
|
+
a as ERROR_CODES,
|
|
544
|
+
o as WhatError,
|
|
545
|
+
m as classifyError,
|
|
546
|
+
p as createWhatError,
|
|
547
|
+
N as getErrorDefinition
|
|
548
|
+
};
|