@wardic/solid 3.0.0-next.0 → 3.0.0-next.2

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.
Files changed (163) hide show
  1. package/README.md +17 -0
  2. package/dist/browser/animation-frame.js +1 -1
  3. package/dist/browser/animation-frame.js.map +1 -1
  4. package/dist/browser/config-view.js +2 -1
  5. package/dist/browser/config-view.js.map +1 -1
  6. package/dist/browser/diagnostic-codes.js +236 -0
  7. package/dist/browser/diagnostic-codes.js.map +1 -0
  8. package/dist/browser/diagnostics.js +79 -0
  9. package/dist/browser/diagnostics.js.map +1 -0
  10. package/dist/browser/element.js +7 -6
  11. package/dist/browser/element.js.map +1 -1
  12. package/dist/browser/frame-effect.js +1 -1
  13. package/dist/browser/frame-effect.js.map +1 -1
  14. package/dist/browser/gesture-callbacks.js +1 -1
  15. package/dist/browser/gesture-callbacks.js.map +1 -1
  16. package/dist/browser/hooks/drag.js +4 -3
  17. package/dist/browser/hooks/drag.js.map +1 -1
  18. package/dist/browser/hooks/presence-scope.js +2 -1
  19. package/dist/browser/hooks/presence-scope.js.map +1 -1
  20. package/dist/browser/hooks/reorder-elements.js +5 -4
  21. package/dist/browser/hooks/reorder-elements.js.map +1 -1
  22. package/dist/browser/hooks/rune.js +4 -3
  23. package/dist/browser/hooks/rune.js.map +1 -1
  24. package/dist/browser/hooks/ward.js +75 -18
  25. package/dist/browser/hooks/ward.js.map +1 -1
  26. package/dist/browser/hooks/wards.js +3 -2
  27. package/dist/browser/hooks/wards.js.map +1 -1
  28. package/dist/browser/provider.js +40 -21
  29. package/dist/browser/provider.js.map +1 -1
  30. package/dist/browser/reorder.js +5 -4
  31. package/dist/browser/reorder.js.map +1 -1
  32. package/dist/browser/runtime.js +26 -15
  33. package/dist/browser/runtime.js.map +1 -1
  34. package/dist/browser/spans-check.js +8 -3
  35. package/dist/browser/spans-check.js.map +1 -1
  36. package/dist/browser/v1/index.js +1 -1
  37. package/dist/browser/ward.js +25 -19
  38. package/dist/browser/ward.js.map +1 -1
  39. package/dist/server/animation-frame.js +1 -1
  40. package/dist/server/animation-frame.js.map +1 -1
  41. package/dist/server/config-view.js +2 -1
  42. package/dist/server/config-view.js.map +1 -1
  43. package/dist/server/diagnostic-codes.js +236 -0
  44. package/dist/server/diagnostic-codes.js.map +1 -0
  45. package/dist/server/diagnostics.js +79 -0
  46. package/dist/server/diagnostics.js.map +1 -0
  47. package/dist/server/element.js +7 -6
  48. package/dist/server/element.js.map +1 -1
  49. package/dist/server/frame-effect.js +1 -1
  50. package/dist/server/frame-effect.js.map +1 -1
  51. package/dist/server/gesture-callbacks.js +1 -1
  52. package/dist/server/gesture-callbacks.js.map +1 -1
  53. package/dist/server/hooks/drag.js +4 -3
  54. package/dist/server/hooks/drag.js.map +1 -1
  55. package/dist/server/hooks/presence-scope.js +2 -1
  56. package/dist/server/hooks/presence-scope.js.map +1 -1
  57. package/dist/server/hooks/reorder-elements.js +5 -4
  58. package/dist/server/hooks/reorder-elements.js.map +1 -1
  59. package/dist/server/hooks/rune.js +4 -3
  60. package/dist/server/hooks/rune.js.map +1 -1
  61. package/dist/server/hooks/ward.js +75 -18
  62. package/dist/server/hooks/ward.js.map +1 -1
  63. package/dist/server/hooks/wards.js +3 -2
  64. package/dist/server/hooks/wards.js.map +1 -1
  65. package/dist/server/provider.js +40 -21
  66. package/dist/server/provider.js.map +1 -1
  67. package/dist/server/reorder.js +5 -4
  68. package/dist/server/reorder.js.map +1 -1
  69. package/dist/server/runtime.js +26 -15
  70. package/dist/server/runtime.js.map +1 -1
  71. package/dist/server/spans-check.js +8 -3
  72. package/dist/server/spans-check.js.map +1 -1
  73. package/dist/server/v1/index.js +1 -1
  74. package/dist/server/ward.js +25 -19
  75. package/dist/server/ward.js.map +1 -1
  76. package/dist/solid/animation-frame.js +1 -1
  77. package/dist/solid/animation-frame.js.map +1 -1
  78. package/dist/solid/config-view.d.ts.map +1 -1
  79. package/dist/solid/config-view.js +2 -1
  80. package/dist/solid/config-view.js.map +1 -1
  81. package/dist/solid/diagnostic-codes.d.ts +10 -0
  82. package/dist/solid/diagnostic-codes.d.ts.map +1 -0
  83. package/dist/solid/diagnostic-codes.js +268 -0
  84. package/dist/solid/diagnostic-codes.js.map +1 -0
  85. package/dist/solid/diagnostics.d.ts +33 -0
  86. package/dist/solid/diagnostics.d.ts.map +1 -0
  87. package/dist/solid/diagnostics.js +76 -0
  88. package/dist/solid/diagnostics.js.map +1 -0
  89. package/dist/solid/element.d.ts.map +1 -1
  90. package/dist/solid/element.jsx +8 -8
  91. package/dist/solid/element.jsx.map +1 -1
  92. package/dist/solid/frame-effect.jsx +1 -1
  93. package/dist/solid/frame-effect.jsx.map +1 -1
  94. package/dist/solid/gesture-callbacks.js +1 -1
  95. package/dist/solid/gesture-callbacks.js.map +1 -1
  96. package/dist/solid/hooks/drag.d.ts.map +1 -1
  97. package/dist/solid/hooks/drag.js +4 -3
  98. package/dist/solid/hooks/drag.js.map +1 -1
  99. package/dist/solid/hooks/presence-scope.d.ts +4 -3
  100. package/dist/solid/hooks/presence-scope.d.ts.map +1 -1
  101. package/dist/solid/hooks/presence-scope.jsx +2 -1
  102. package/dist/solid/hooks/presence-scope.jsx.map +1 -1
  103. package/dist/solid/hooks/reorder-elements.d.ts.map +1 -1
  104. package/dist/solid/hooks/reorder-elements.jsx +5 -4
  105. package/dist/solid/hooks/reorder-elements.jsx.map +1 -1
  106. package/dist/solid/hooks/rune.d.ts.map +1 -1
  107. package/dist/solid/hooks/rune.js +4 -3
  108. package/dist/solid/hooks/rune.js.map +1 -1
  109. package/dist/solid/hooks/ward.d.ts +5 -3
  110. package/dist/solid/hooks/ward.d.ts.map +1 -1
  111. package/dist/solid/hooks/ward.js +85 -20
  112. package/dist/solid/hooks/ward.js.map +1 -1
  113. package/dist/solid/hooks/wards.d.ts.map +1 -1
  114. package/dist/solid/hooks/wards.js +3 -2
  115. package/dist/solid/hooks/wards.js.map +1 -1
  116. package/dist/solid/provider.d.ts.map +1 -1
  117. package/dist/solid/provider.jsx +41 -21
  118. package/dist/solid/provider.jsx.map +1 -1
  119. package/dist/solid/reorder.d.ts.map +1 -1
  120. package/dist/solid/reorder.jsx +5 -4
  121. package/dist/solid/reorder.jsx.map +1 -1
  122. package/dist/solid/runtime.d.ts +20 -7
  123. package/dist/solid/runtime.d.ts.map +1 -1
  124. package/dist/solid/runtime.js +25 -14
  125. package/dist/solid/runtime.js.map +1 -1
  126. package/dist/solid/spans-check.d.ts +5 -1
  127. package/dist/solid/spans-check.d.ts.map +1 -1
  128. package/dist/solid/spans-check.js +8 -3
  129. package/dist/solid/spans-check.js.map +1 -1
  130. package/dist/solid/v1/index.d.ts +1 -1
  131. package/dist/solid/v1/index.jsx +1 -1
  132. package/dist/solid/ward.d.ts.map +1 -1
  133. package/dist/solid/ward.jsx +25 -19
  134. package/dist/solid/ward.jsx.map +1 -1
  135. package/package.json +8 -6
  136. package/skills/wardic-diagnostics/SKILL.md +553 -0
  137. package/skills/wardic-migrate/SKILL.md +252 -0
  138. package/skills/wardic-solid/SKILL.md +60 -0
  139. package/skills/wardic-solid/events.md +70 -0
  140. package/skills/wardic-solid/from-motion.md +59 -0
  141. package/skills/wardic-solid/lists-and-presence.md +112 -0
  142. package/skills/wardic-solid/reorder-and-grips.md +88 -0
  143. package/skills/wardic-solid/runes.md +151 -0
  144. package/skills/wardic-solid/scopes-and-settings.md +75 -0
  145. package/src/animation-frame.ts +1 -1
  146. package/src/config-view.ts +5 -1
  147. package/src/diagnostic-codes.ts +280 -0
  148. package/src/diagnostics.ts +88 -0
  149. package/src/element.tsx +13 -10
  150. package/src/frame-effect.tsx +1 -1
  151. package/src/gesture-callbacks.ts +1 -1
  152. package/src/hooks/drag.ts +4 -3
  153. package/src/hooks/presence-scope.tsx +6 -4
  154. package/src/hooks/reorder-elements.tsx +6 -4
  155. package/src/hooks/rune.ts +4 -3
  156. package/src/hooks/ward.ts +90 -21
  157. package/src/hooks/wards.ts +4 -2
  158. package/src/provider.tsx +43 -20
  159. package/src/reorder.tsx +5 -4
  160. package/src/runtime.ts +43 -13
  161. package/src/spans-check.ts +12 -3
  162. package/src/v1/index.tsx +1 -1
  163. package/src/ward.tsx +27 -19
@@ -0,0 +1,553 @@
1
+ ---
2
+ name: wardic-diagnostics
3
+ description: Map a Wardic diagnostic code to its repair. Use when a console warning, a thrown error, a test failure or a captured Solid artifact names a `[WARDIC_…]` code.
4
+ ---
5
+
6
+ <!-- Generated from the packages' registries by scripts/diagnostics.ts (`bun run diagnostics`): edit the registry, not this file. -->
7
+
8
+ # Repairing Wardic code from its diagnostic codes
9
+
10
+ In development, Wardic reports a broken rule as Solid reports its own: a code, `[WARDIC_…]`, then what happened and how to fix it. Each section below is one code: what it means, why it matters, and the repair. Fix the cause. A code a test makes on purpose is named to its test's gate, never hidden.
11
+
12
+ ## Reading a report
13
+
14
+ ```
15
+ [WARDIC_GRIP_ROW_DOESNT_DRAG] createGrip(row): row doesn't drag; give it `drag`, or a behaviour that does.
16
+ in <App> › <Wishlist> › <Row>
17
+ at src/Row.tsx:18:3
18
+ ```
19
+
20
+ - **The first line:** the code, then what happened and the fix.
21
+ - **`in`:** the components it happened under, root first. A finding from Wardic's frame loop has none.
22
+ - **`at`:** where, when the build wrote source locations.
23
+ - **A misuse that throws** has the same lines as its error's message.
24
+ - **On Solid's diagnostics channel** it's an event with the code, at `warn`, so `@solidjs/diagnostics`' `captureArtifact` records it and a test's `expectDiagnostic` can name it.
25
+
26
+ ## Features
27
+
28
+ ### WARDIC_COMPLETE_UNDER_STRICT
29
+
30
+ A Complete element (`wardic.*`, `wardic.create`, `ward()`) was rendered where `strict` is on.
31
+
32
+ **Why:** A Complete element brings every Feature's code with it, whatever it uses. `strict` says the page ships only the Features its elements ask for, so a Complete element under it would undo that.
33
+
34
+ **Fix:** Use the hooks (`createWard`), which bring only the Features a ward's config uses, or a Slim element (`w.*`, `w.create`, `w.ward()`). Or leave `strict` off.
35
+
36
+ ### WARDIC_FEATURE_MISSING
37
+
38
+ An element uses something that needs a Feature its provider wasn't given: a layout prop, a gesture, or a wide-gamut colour.
39
+
40
+ **Why:** A Slim element (`w.*`, `w.create`) or a `makeWard` instance brings only the Features it's given, so the page ships only their code. A key that needs one it wasn't given does nothing: the layout doesn't animate, the gesture isn't heard, the colour isn't read as one.
41
+
42
+ **Fix:** Import the Feature the message names and give it to the provider (`<WardicProvider features={[layout]}>`) or to `makeWard({ features })`.
43
+
44
+ ## Presence
45
+
46
+ ### WARDIC_EXIT_FORM_MIXED
47
+
48
+ A ward a hook shows has an `exit` and an `animate` in different forms, a variant name and a values map, so its exit can't be laid over its `animate` as it leaves.
49
+
50
+ **Why:** A ward a hook shows (its `show`, a `createWards` row, a `createPresence`'s) leaves by its exit laid over the target it was shown at, so a key the exit doesn't name keeps that target. Names lay over names, and a values map over a values map, but a name and a values map can't be laid over each other without resolving the name. Such a ward leaves by its exit alone: a key the exit doesn't name falls back to its `initial`, and its followers, which follow names, are handed none.
51
+
52
+ **Fix:** Write the exit in its `animate`'s form: a variant name under a name (`exit: "gone"`, with `gone: { opacity: 0 }` among its variants), or a values map under a values map.
53
+
54
+ **Before:**
55
+
56
+ ```tsx before
57
+ import { createRune, createWards } from "@wardic/solid/hooks"
58
+
59
+ const comesIn = createRune({
60
+ variants: { away: { opacity: 0, x: -12 }, here: { opacity: 1, x: 0 } },
61
+ initial: "away",
62
+ animate: "here",
63
+ exit: { opacity: 0 },
64
+ })
65
+
66
+ const rows = createWards(items, comesIn)
67
+ ```
68
+
69
+ **After:**
70
+
71
+ ```tsx solid2
72
+ import { createRune, createWards } from "@wardic/solid/hooks"
73
+
74
+ const comesIn = createRune({
75
+ variants: { away: { opacity: 0, x: -12 }, here: { opacity: 1, x: 0 }, gone: { opacity: 0 } },
76
+ initial: "away",
77
+ animate: "here",
78
+ exit: "gone",
79
+ })
80
+
81
+ const rows = createWards(items, comesIn)
82
+ ```
83
+
84
+ ### WARDIC_EXIT_WHEN_UNDER_PRESENCE
85
+
86
+ `when` of an exit was asked of a ward made under a `<Presence>`, so an effect over it never runs.
87
+
88
+ **Why:** What a `<Presence>` takes away, a router's page or a slot, is ended by its owner first: Solid ends the component as its exit starts, and the boundary learns it left after. An effect made in that component, over its ward's `when("exitStart")`, is ended with it, before the leave is told. The ward still hears its leave: a promise from `next`, or an `each` loop, isn't owned by the component.
89
+
90
+ **Fix:** Listen with `next("exitStart")` or `each("exitStart")`, made in the component, and take `hold()` there for work that ends later. Give `next` a rejection handler: it rejects with an `AbortError` when the ward goes without leaving, its boundary unmounted with it. A ward your own state shows (its `show`, a `createWards` row, a `createPresence`'s) keeps its component while it leaves, so an effect over its `when` runs.
91
+
92
+ **Before:**
93
+
94
+ ```tsx before
95
+ import { createEffect } from "solid-js"
96
+ import { createWard } from "@wardic/solid/hooks"
97
+
98
+ export const Lesson = () => {
99
+ const page = createWard({ exit: { opacity: 0 } })
100
+ createEffect(page.when("exitStart"), () => {
101
+ const release = page.hold()
102
+ void saveDraft().finally(release)
103
+ })
104
+ return <article {...page} />
105
+ }
106
+ ```
107
+
108
+ **After:**
109
+
110
+ ```tsx solid2
111
+ import { createWard } from "@wardic/solid/hooks"
112
+
113
+ export const Lesson = () => {
114
+ const page = createWard({ exit: { opacity: 0 } })
115
+ page.next("exitStart").then(
116
+ () => {
117
+ const release = page.hold()
118
+ void saveDraft().finally(release)
119
+ },
120
+ // It went without leaving: nothing to hold.
121
+ () => {},
122
+ )
123
+ return <article {...page} />
124
+ }
125
+ ```
126
+
127
+ ### WARDIC_PRESENCE_SCOPE_REUSED
128
+
129
+ A presence scope's `within` was used round a second boundary while the first is still on the page.
130
+
131
+ **Why:** A presence scope is one boundary: its `exiting()`, `next` and `when` tell of what leaves inside it. Used round two at once, it tells of both as one, so a wait on one ends when the other's exit does.
132
+
133
+ **Fix:** Make a scope for each boundary, with `createPresenceScope` where each is drawn.
134
+
135
+ ### WARDIC_PRESENCE_WARD_HAS_SHOW
136
+
137
+ `createPresence(ward, value)` was given a ward that has a `show` of its own, or is a list's row.
138
+
139
+ **Why:** A presence decides when its ward is on the page and when it leaves. A ward with its own `show`, or a row that its list shows, already has something deciding that, and the two would fight.
140
+
141
+ **Fix:** Make a ward for the presence alone, with no `show`, and let the presence show it. A list's rows leave by their list: use `createWards` for a list.
142
+
143
+ ### WARDIC_PRESENCE_WARD_TAKEN
144
+
145
+ A ward given to `createPresence` already has a presence.
146
+
147
+ **Why:** A presence drives its ward's coming and going. Two presences on one ward would each try to show and remove it.
148
+
149
+ **Fix:** Make a ward for each presence.
150
+
151
+ **Before:**
152
+
153
+ ```tsx before
154
+ import { createPresence, createWard } from "@wardic/solid/hooks"
155
+
156
+ const panel = createWard(fadesIn)
157
+ const a = createPresence(panel, open)
158
+ const b = createPresence(panel, other)
159
+ ```
160
+
161
+ **After:**
162
+
163
+ ```tsx solid2
164
+ import { createPresence, createWard } from "@wardic/solid/hooks"
165
+
166
+ const a = createPresence(createWard(fadesIn), open)
167
+ const b = createPresence(createWard(fadesIn), other)
168
+ ```
169
+
170
+ ## Refs and spread
171
+
172
+ ### WARDIC_HOOK_WARD_IN_WARDREF
173
+
174
+ A ward `createWard` made was given to a component's `wardRef`.
175
+
176
+ **Why:** `wardRef` drives a ward made with `ward(config)`, or calls a function with the component's own ward. A hooks ward finds its Subject by its spread, so given to `wardRef` it never would, and nothing it says would move.
177
+
178
+ **Fix:** Spread the ward on the element (`{...ward}`), or on a component that forwards its `ref`.
179
+
180
+ ### WARDIC_REF_NOT_CALLED
181
+
182
+ A ward was spread on a component that never called its `ref`, so no element is its Subject.
183
+
184
+ **Why:** A ward finds its Subject through the `ref` in its spread. A component that takes the spread but doesn't pass `ref` on to the element it renders leaves the ward with nothing to move: nothing it says moves anything.
185
+
186
+ **Fix:** In the component, pass `props.ref` to the element it renders (`<div ref={props.ref}>`), or spread its props on that element whole. Or spread the ward on an element of your own.
187
+
188
+ **Before:**
189
+
190
+ ```tsx before
191
+ function Card(props) {
192
+ return <div class="card">{props.children}</div>
193
+ }
194
+ <Card {...card} />
195
+ ```
196
+
197
+ **After:**
198
+
199
+ ```tsx solid2
200
+ function Card(props: { ref?: (el: HTMLElement) => void; children?: unknown }) {
201
+ return <div class="card" ref={props.ref}>{props.children as never}</div>
202
+ }
203
+ ```
204
+
205
+ ### WARDIC_REF_NOT_FORWARDED
206
+
207
+ A component wrapped by `w.create` or `wardic.create` didn't forward its `ref`.
208
+
209
+ **Why:** The wrapper reaches the element it animates through the component's `ref`. A component that doesn't pass `ref` on to the element it renders gives it nothing to animate.
210
+
211
+ **Fix:** Pass `props.ref` to the element the component renders, or spread its props on that element whole.
212
+
213
+ ### WARDIC_RUNE_READ_TOO_EARLY
214
+
215
+ A function rune used a member of its ward in the rune's body, before the ward was made.
216
+
217
+ **Why:** A ward is made from all its runes, so it doesn't exist while one of them is still running. A member of it read there has nothing to read yet.
218
+
219
+ **Fix:** Use the member where the ward is rendered, or in an effect or a callback the rune sets up, which run once the ward is made.
220
+
221
+ ### WARDIC_STYLE_BESIDE_SPREAD
222
+
223
+ A ward was handed an element that never read its `style`: a `style` beside its spread replaced it, a component didn't pass `props.style` on, or the ward was called with the element and not spread.
224
+
225
+ **Why:** A ward's spread gives its Subject a `style` too: its initial values, and the styles it keeps. A `style` written after the spread replaces it, as any later prop does, so those never reach the Subject. A ward called with an element (`ward(el)`), as 2.x's could be, hands it the element with no spread at all; the check can't tell that from a replaced style.
226
+
227
+ **Fix:** Give the style through the ward, `{...ward.with({ style })}`, or as its own `style`. A component the ward is spread on passes `props.style` to the element it renders with `props.ref`. An element the app doesn't render, the page's root or a portal's host, is given with a rune's `subject`: `createWard({ subject: () => document.documentElement })`.
228
+
229
+ **Before:**
230
+
231
+ ```tsx before
232
+ import { createWard } from "@wardic/solid/hooks"
233
+
234
+ export const Card = () => {
235
+ const card = createWard({ initial: { opacity: 0 }, animate: { opacity: 1 } })
236
+ return <div {...card} style={{ width: "40px" }} />
237
+ }
238
+ ```
239
+
240
+ **After:**
241
+
242
+ ```tsx solid2
243
+ import { createWard } from "@wardic/solid/hooks"
244
+
245
+ export const Card = () => {
246
+ const card = createWard({ initial: { opacity: 0 }, animate: { opacity: 1 } })
247
+ return <div {...card.with({ style: { width: "40px" } })} />
248
+ }
249
+ ```
250
+
251
+ ### WARDIC_SUBJECT_NOT_ONE_ELEMENT
252
+
253
+ A rune's `subject` didn't resolve to one element.
254
+
255
+ **Why:** A ward moves one Subject. A `subject` that resolves to nothing, to text, or to several elements leaves it nothing it can drive.
256
+
257
+ **Fix:** Give `subject` the one element the ward should move, or an accessor of it, or leave `subject` out and spread the ward on that element.
258
+
259
+ ### WARDIC_WARD_MADE_IN_SPREAD
260
+
261
+ `ward(config)` was called inside a spread, so a new ward was made each time the element's props ran.
262
+
263
+ **Why:** Solid 2 runs a spread's expression again on every run of the element's props. A ward made there is a new ward each time, and the one before it is lost mid-animation.
264
+
265
+ **Fix:** Make the ward once, in the component's body, and spread that: `const card = ward(config)`, then `<div {...card} />`.
266
+
267
+ ### WARDIC_WARD_ON_TWO_SUBJECTS
268
+
269
+ One ward was spread on, or given to, a second element while the first is still on the page.
270
+
271
+ **Why:** A ward drives one Subject at a time: its values, its gestures and its exits are that Subject's. Two elements on one ward would fight over them, so Wardic refuses the second.
272
+
273
+ **Fix:** Make one ward for each element, where each is drawn: in the `<For>` callback, or in a component of its own. A ward that moves from one element to the next, the first gone before the second arrives, is fine.
274
+
275
+ **Before:**
276
+
277
+ ```tsx before
278
+ import { createWard } from "@wardic/solid/hooks"
279
+
280
+ const card = createWard(fadesIn)
281
+ <div {...card} />
282
+ <div {...card} />
283
+ ```
284
+
285
+ **After:**
286
+
287
+ ```tsx solid2
288
+ import { createWard } from "@wardic/solid/hooks"
289
+
290
+ function Card() {
291
+ const card = createWard(fadesIn)
292
+ return <div {...card} />
293
+ }
294
+ ```
295
+
296
+ ### WARDIC_WARD_WITHOUT_OWNER
297
+
298
+ `createWard` was called with no owner: outside a component or a root, at a module's top or in an event handler.
299
+
300
+ **Why:** A ward lives as long as the component it's made in, and ends with it. Made with no owner, nothing would end it, and it couldn't find the provider or the page around it.
301
+
302
+ **Fix:** Make the ward in the component that draws its Subject, and spread it there. A hook that holds state gives runes, which the component makes its ward of.
303
+
304
+ **Before:**
305
+
306
+ ```tsx before
307
+ import { createWard } from "@wardic/solid/hooks"
308
+
309
+ const card = createWard({ animate: { opacity: 1 } })
310
+
311
+ export const Card = () => <div {...card} />
312
+ ```
313
+
314
+ **After:**
315
+
316
+ ```tsx solid2
317
+ import { createWard } from "@wardic/solid/hooks"
318
+
319
+ export const Card = () => {
320
+ const card = createWard({ animate: { opacity: 1 } })
321
+ return <div {...card} />
322
+ }
323
+ ```
324
+
325
+ ### WARDIC_WARDREF_CONFLICT
326
+
327
+ A ward given to `wardRef` and its element disagree: a key set on both, variants on the ward with its keys on the element, or the ward made outside the element's variant parent.
328
+
329
+ **Why:** A ward given to `wardRef` and the element it's on make one config. A key set in both places, or a ward's variants split from the keys that read them, leaves it unclear which wins.
330
+
331
+ **Fix:** Set each key in one place: in `ward({ … })`, or on the element. A ward with variants takes its variant keys too. A ward made outside its element's variant parent names it with `ward(config, { parent })`, or stands alone with `inherit: false`.
332
+
333
+ ## Follow, variants and config
334
+
335
+ ### WARDIC_ACCESSOR_RETURNED_PROMISE
336
+
337
+ A key's accessor returned a promise.
338
+
339
+ **Why:** An accessor is called at every read of its key, so one that fetches would fetch at each read. A ward can't animate to a promise either.
340
+
341
+ **Fix:** Give the key an async memo, `key: createMemo(() => …)`, which fetches once and holds the value it resolves to.
342
+
343
+ ### WARDIC_CONFIG_AS_ACCESSOR
344
+
345
+ A whole config was given as one accessor (`ward(() => ({ … }))`).
346
+
347
+ **Why:** A config is read key by key, so each key follows its own source. One accessor for all of it would make every key rerun whenever any of them changed.
348
+
349
+ **Fix:** Give the config as an object and make the keys that change reactive one at a time: `ward({ animate: () => ({ x: x() }) })`, a getter, a store or a component's props.
350
+
351
+ ### WARDIC_FOLLOW_LEADER_UNNAMED
352
+
353
+ A ward follows a leader that names no states.
354
+
355
+ **Why:** A follower takes its leader's variant names for the values it doesn't set. A leader whose `animate` and `initial` are values, not names, has no names to give, so the follower's own `variants` never play.
356
+
357
+ **Fix:** Give the leader `variants` and name its states in `animate` (`animate: "open"`), or give the follower values of its own instead of following.
358
+
359
+ **Before:**
360
+
361
+ ```tsx before
362
+ import { createWard } from "@wardic/solid/hooks"
363
+
364
+ const panel = createWard({ animate: { opacity: 1 } })
365
+ const chevron = createWard({ follow: panel, variants: { open: { rotate: 180 } } })
366
+ ```
367
+
368
+ **After:**
369
+
370
+ ```tsx solid2
371
+ import { createWard } from "@wardic/solid/hooks"
372
+
373
+ const panel = createWard({ variants: { open: { opacity: 1 } }, animate: "open" })
374
+ const chevron = createWard({ follow: panel, variants: { open: { rotate: 180 } } })
375
+ ```
376
+
377
+ ### WARDIC_KEY_LOADING_AT_SETUP
378
+
379
+ A key was still loading when its ward was made.
380
+
381
+ **Why:** A ward reads some keys once, as it's made: where it starts, and what it's set up with. A key whose async source hasn't resolved has nothing to read then.
382
+
383
+ **Fix:** Give the key a value to start from, such as an `initial`, or make the ward once its data is in, inside the `<Loading>` that waits for it.
384
+
385
+ ### WARDIC_PARENT_WITHOUT_VARIANTS
386
+
387
+ `ward(config, { parent })` named a parent that carries no variants.
388
+
389
+ **Why:** A child joins its parent's variants through the parent's variant node. A parent with no `variants` or `inherit` in its config only listens: its element's props hold its variants, so there's nothing for the child to join by `{ parent }`.
390
+
391
+ **Fix:** Render the child inside that ward's element, where it joins through the tree, or put the variants in the parent's `ward({ … })`.
392
+
393
+ ### WARDIC_RUNE_WITH_INVALID
394
+
395
+ `createRuneWith(rune, api)` was given something it can't carry: a rune that already carries an API, a bare function, or an API member named like one of the rune's keys.
396
+
397
+ **Why:** `createRuneWith` joins one rune and one API into a value that's both. A second API would hide the first, a bare function isn't a rune a ward can read, and an API member named like a rune key would hide that key from the ward.
398
+
399
+ **Fix:** Give it the rune as written, with one API that has every member. Write a behaviour as `createRune((ward) => …)`. Give an API member that clashes another name.
400
+
401
+ ## Grips and reorder
402
+
403
+ ### WARDIC_DRAG_CONTAINER_MISSING
404
+
405
+ `dragConstraints` names a container that isn't on the page when a drag starts.
406
+
407
+ **Why:** A drag is held inside its container's box, measured as the drag starts. With no container there's no box, so that drag runs unconstrained. It's said once for the element; each drag measures again.
408
+
409
+ **Fix:** Render the container before the element can be dragged, and keep it on the page while it can be. Or give `dragConstraints` a box of numbers, `{ top, left, right, bottom }`.
410
+
411
+ ### WARDIC_DRAG_NOT_GIVEN
412
+
413
+ A rune listens to `ward.drag`, but nothing gives the ward a `drag`.
414
+
415
+ **Why:** `ward.drag`'s samples, keys and measured box are a dragging ward's. With no `drag` key, the ward never drags, so the behaviour listening to it never hears a sample.
416
+
417
+ **Fix:** Give the ward `drag` (`createRune({ drag: "x" })`), or have the behaviour return `drag` in the rune it makes.
418
+
419
+ ### WARDIC_GRIP_OUTSIDE_ROW
420
+
421
+ A grip was rendered outside its row's Subject.
422
+
423
+ **Why:** A press on a grip reaches its row's drag through the row's Subject. A grip outside it can't start the drag, and while it's on the page the row drags from its grips alone, so the row can't be dragged at all.
424
+
425
+ **Fix:** Render the grip inside its row's Subject, as one of its children.
426
+
427
+ ### WARDIC_GRIP_ROW_DOESNT_DRAG
428
+
429
+ A grip was made for a ward that doesn't drag.
430
+
431
+ **Why:** A grip starts its row's drag: a press on it is one the row's drag hears. A row with no `drag` has no drag to start, so the grip does nothing, and the row can't be moved by it.
432
+
433
+ **Fix:** Give the row `drag` (`createRune({ drag: "y" })`), or a behaviour rune whose ward drags, such as a `createReorder` list's `list.item(value)`. If the row isn't meant to move, give it no grip.
434
+
435
+ **Before:**
436
+
437
+ ```tsx before
438
+ import { createGrip, createWard } from "@wardic/solid/hooks"
439
+
440
+ const row = createWard(fadesIn)
441
+ const grip = createWard(createGrip(row as never))
442
+ ```
443
+
444
+ **After:**
445
+
446
+ ```tsx solid2
447
+ import { createGrip, createWard } from "@wardic/solid/hooks"
448
+
449
+ const row = createWard(fadesIn, list.item(value))
450
+ const grip = createWard(createGrip(row))
451
+ ```
452
+
453
+ ### WARDIC_REORDER_ITEM_OUTSIDE_GROUP
454
+
455
+ A `<Reorder.Item>` was rendered outside a `<Reorder.Group>`, or a `<Reorder.Grip>` outside a `<Reorder.Item>`.
456
+
457
+ **Why:** An item finds its list through its group, and a grip its row through its item. Outside them there's no list to reorder in, or no row to drag.
458
+
459
+ **Fix:** Render each item among its group's children, and each grip among its item's.
460
+
461
+ ### WARDIC_REORDER_ITEM_REMOUNTED
462
+
463
+ A Reorder item was unmounted and mounted again with the same value in one task.
464
+
465
+ **Why:** That's what a list keyed by index does when its order changes: each row's element is made again for whichever value lands on it. An element made again starts over, so the item's move doesn't animate from where it was, and a drag on it ends.
466
+
467
+ **Fix:** Key the items by their value, as the message says: in Solid, a keyed `<For each={items}>`, not `<For keyed={false}>` or `.map`.
468
+
469
+ ### WARDIC_REORDER_REF_NOT_FUNCTION
470
+
471
+ `<Reorder.Group>`'s `groupRef` or `<Reorder.Item>`'s `wardRef` was given a group or ward made beforehand.
472
+
473
+ **Why:** These take a function the component calls with the group or ward it makes. A group or ward made beforehand isn't one the component can drive.
474
+
475
+ **Fix:** Give the config as the component's props, and a function to `groupRef` or `wardRef` to be handed what it makes: `wardRef={(row) => …}`.
476
+
477
+ ## Style
478
+
479
+ ### WARDIC_CANT_BLEND
480
+
481
+ Two values an animation moves between can't be blended, so the value switches to the target at the first frame instead of moving.
482
+
483
+ **Why:** An animation moves through the values between its two ends. `10px` and `2em`, or two lists of different lengths, are read by the same interpolator but have no values between them, so Wardic switches at the first frame, as Motion does for values too different to mix.
484
+
485
+ **Fix:** Give both ends the same unit (`10px` to `20px`) and the same shape: as many numbers, in the same order.
486
+
487
+ ### WARDIC_TRANSFORM_STRING_DROPPED
488
+
489
+ A `transform` string in `style` was dropped, because the same `style` sets a transform key.
490
+
491
+ **Why:** Wardic draws `x`, `scale`, `rotate` and the other transform keys as one `transform`, as Motion does. A `transform` string beside them can't join it, so the keys win and the string is ignored, which can move or turn the element in a way its author didn't write.
492
+
493
+ **Fix:** Give the whole transform as keys (`{ x: 10, scale: 2 }`), or keep the string and leave the keys out of that `style`.
494
+
495
+ **Before:**
496
+
497
+ ```tsx before
498
+ import { createWard } from "@wardic/solid/hooks"
499
+
500
+ const box = createWard({ style: { transform: "scale(2)", x: 10 } })
501
+ ```
502
+
503
+ **After:**
504
+
505
+ ```tsx solid2
506
+ import { createWard } from "@wardic/solid/hooks"
507
+
508
+ const box = createWard({ style: { scale: 2, x: 10 } })
509
+ ```
510
+
511
+ ## Runtime and page
512
+
513
+ ### WARDIC_ENV_ASYNC
514
+
515
+ The `env` given to a `<WardicProvider>` waits as it builds.
516
+
517
+ **Why:** A provider builds its `env` at once, as its first element renders. A Layer that waits as it builds, such as `DevTools.layer()` waiting for its connection, can't be built there.
518
+
519
+ **Fix:** Build the Layer that waits before the app renders, and give its services in the `env`: `Layer.succeedContext(await Effect.runPromise(Layer.buildWithScope(layer, scope)))`.
520
+
521
+ ### WARDIC_NO_PROVIDER
522
+
523
+ Something that reads Wardic's runtime (`useWardicRuntime`, `useAnimateLayout`, …) was called with no `<WardicProvider>` above it and no page set up.
524
+
525
+ **Why:** It reads what a provider makes, or the page the hooks set up: its Effect runtime, its Features, its layout system. The hooks set the page up as they're imported, so an app that never imports them, on the 2.x components alone, has neither until it renders a provider.
526
+
527
+ **Fix:** Set the page up with no provider: importing `@wardic/solid/hooks` does, with `DomLive`, and `setupWard({ env })` from it gives it your own. Or render the component inside a `<WardicProvider env={DomLive}>`; `createWardicScope({ env }).within(…)` gives part of the page its own.
528
+
529
+ ### WARDIC_TRACER_WITHOUT_SPANS
530
+
531
+ The `env` installs a tracer, but gives no `WardicSpans`, so Wardic opens no spans.
532
+
533
+ **Why:** Wardic's spans are the app's to give: `WardicSpans` opens them under the tracer installed. Without it, the tracer sees none of Wardic's animations.
534
+
535
+ **Fix:** Merge `WardicSpans` beside the Environment, `Layer.mergeAll(DomLive, WardicSpans, …)`, or leave the tracer out if Wardic's spans aren't wanted.
536
+
537
+ ## App callbacks
538
+
539
+ ### WARDIC_CALLBACK_THREW
540
+
541
+ A function the app gave Wardic threw: a callback (`onComplete`, `onExitComplete`, a gesture's), a function variant or delay, a Live value's mixer or dependent, an easing, or an effect run for the app.
542
+
543
+ **Why:** Wardic catches it so the animation, and everything else, goes on. It logs it at Error with its cause and hands the cause to the app's `ErrorReporter`s. The label after the code names the function that threw; the cause under it is the app's own error. A function that throws on each call is reported once for the run of throws, and again after a call that returns.
544
+
545
+ **Fix:** Fix the function the label names: the cause's stack points into the app's code.
546
+
547
+ ### WARDIC_LAYOUT_CALLBACK_PROMISE
548
+
549
+ The function given to `animateLayout` returned a promise.
550
+
551
+ **Why:** `animateLayout(fn)` measures the layout before `fn` runs and again at the end of that task, and animates the difference. An async `fn` stops at its first `await`, so a change it makes after that lands in a later task, unmeasured, and jumps.
552
+
553
+ **Fix:** Await what you need before calling `animateLayout`, and give it a function that makes the layout change at once.