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

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 (161) 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 +216 -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 +31 -12
  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 +216 -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 +31 -12
  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 +246 -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.map +1 -1
  100. package/dist/solid/hooks/presence-scope.jsx +2 -1
  101. package/dist/solid/hooks/presence-scope.jsx.map +1 -1
  102. package/dist/solid/hooks/reorder-elements.d.ts.map +1 -1
  103. package/dist/solid/hooks/reorder-elements.jsx +5 -4
  104. package/dist/solid/hooks/reorder-elements.jsx.map +1 -1
  105. package/dist/solid/hooks/rune.d.ts.map +1 -1
  106. package/dist/solid/hooks/rune.js +4 -3
  107. package/dist/solid/hooks/rune.js.map +1 -1
  108. package/dist/solid/hooks/ward.d.ts.map +1 -1
  109. package/dist/solid/hooks/ward.js +35 -14
  110. package/dist/solid/hooks/ward.js.map +1 -1
  111. package/dist/solid/hooks/wards.d.ts.map +1 -1
  112. package/dist/solid/hooks/wards.js +3 -2
  113. package/dist/solid/hooks/wards.js.map +1 -1
  114. package/dist/solid/provider.d.ts.map +1 -1
  115. package/dist/solid/provider.jsx +41 -21
  116. package/dist/solid/provider.jsx.map +1 -1
  117. package/dist/solid/reorder.d.ts.map +1 -1
  118. package/dist/solid/reorder.jsx +5 -4
  119. package/dist/solid/reorder.jsx.map +1 -1
  120. package/dist/solid/runtime.d.ts +20 -7
  121. package/dist/solid/runtime.d.ts.map +1 -1
  122. package/dist/solid/runtime.js +25 -14
  123. package/dist/solid/runtime.js.map +1 -1
  124. package/dist/solid/spans-check.d.ts +5 -1
  125. package/dist/solid/spans-check.d.ts.map +1 -1
  126. package/dist/solid/spans-check.js +8 -3
  127. package/dist/solid/spans-check.js.map +1 -1
  128. package/dist/solid/v1/index.d.ts +1 -1
  129. package/dist/solid/v1/index.jsx +1 -1
  130. package/dist/solid/ward.d.ts.map +1 -1
  131. package/dist/solid/ward.jsx +25 -19
  132. package/dist/solid/ward.jsx.map +1 -1
  133. package/package.json +8 -6
  134. package/skills/wardic-diagnostics/SKILL.md +472 -0
  135. package/skills/wardic-migrate/SKILL.md +204 -0
  136. package/skills/wardic-solid/SKILL.md +60 -0
  137. package/skills/wardic-solid/events.md +70 -0
  138. package/skills/wardic-solid/from-motion.md +59 -0
  139. package/skills/wardic-solid/lists-and-presence.md +110 -0
  140. package/skills/wardic-solid/reorder-and-grips.md +88 -0
  141. package/skills/wardic-solid/runes.md +151 -0
  142. package/skills/wardic-solid/scopes-and-settings.md +75 -0
  143. package/src/animation-frame.ts +1 -1
  144. package/src/config-view.ts +5 -1
  145. package/src/diagnostic-codes.ts +254 -0
  146. package/src/diagnostics.ts +88 -0
  147. package/src/element.tsx +13 -10
  148. package/src/frame-effect.tsx +1 -1
  149. package/src/gesture-callbacks.ts +1 -1
  150. package/src/hooks/drag.ts +4 -3
  151. package/src/hooks/presence-scope.tsx +2 -1
  152. package/src/hooks/reorder-elements.tsx +6 -4
  153. package/src/hooks/rune.ts +4 -3
  154. package/src/hooks/ward.ts +36 -12
  155. package/src/hooks/wards.ts +4 -2
  156. package/src/provider.tsx +43 -20
  157. package/src/reorder.tsx +5 -4
  158. package/src/runtime.ts +43 -13
  159. package/src/spans-check.ts +12 -3
  160. package/src/v1/index.tsx +1 -1
  161. package/src/ward.tsx +27 -19
@@ -0,0 +1,60 @@
1
+ ---
2
+ name: wardic-solid
3
+ description: Write motion with Wardic's hooks on Solid 2 (`@wardic/solid/hooks`). Use when writing, reviewing or porting animation in a Solid 2 app (a ward, a rune, a list's rows, something leaving, a drag or a reorder, a layout animation), or moving code over from Motion (`motion.div`, `AnimatePresence`).
4
+ ---
5
+
6
+ # Motion with Wardic's hooks on Solid 2
7
+
8
+ Wardic's hooks are `@wardic/solid/hooks`, in `@wardic/solid@next`, a prerelease. Solid 2 is not Solid 1 and not React: read the `solid-2.0` skill (`node_modules/solid-js/skills/solid-2.0/SKILL.md`) before writing Solid code.
9
+
10
+ ## The words
11
+
12
+ - **Subject:** what a ward moves. On the page, an element.
13
+ - **Ward:** one Subject's motion, `createWard(...runes)`, spread on its Subject.
14
+ - **Rune:** one job a ward is made of. A config (`{ whileHover: { y: -4 } }`), or `createRune(config)` kept in a constant.
15
+ - **Function rune:** `createRune((ward) => config)`, a rune that reads or listens to the ward it's given to. A **behaviour** is a function rune that drives its ward's drag, as a reorder's `list.item(value)` does.
16
+ - **Grip:** what a row is dragged by, `createGrip(row)`, a rune of the grip's own ward.
17
+ - **Scope:** a value with `within(build)`, which puts everything built inside it in the scope: `createConfigScope`, `createLayoutGroup`, `createWardicScope`, `createPresenceScope`.
18
+
19
+ ## The rule
20
+
21
+ Ward and rune are the language. Solve a motion problem with a ward or a rune; what's shared or reused is a rune, never a ward. How runes are written, joined and named: [runes.md](runes.md).
22
+
23
+ ## Solid's ward rules
24
+
25
+ Each rule's tier says what catches it: **type** (the compiler), **code** (a `[WARDIC_…]` diagnostic in development), **review** (no tool does: you hold it).
26
+
27
+ 1. **A ward is made where its Subject is drawn:** in a component's body, or a row's callback, beside the markup it's spread on. Review; a ward made with no owner at all is code, `WARDIC_WARD_WITHOUT_OWNER`.
28
+ 2. **An app's hooks hold state and give runes:** accessors, actions, runes that close over the state, rune factories (`card(index)`), `createRuneWith` values. The ward stays in the component. Review.
29
+ 3. **A ward is one-job runes, each named for what it does:** `fadesIn`, `lifts`, `springy`. An inline config is fine for a one-job ward used once. Review.
30
+ 4. **A rune is made once, for what it describes:** in a module when it depends on nothing, once in a hook when it depends on the hook's state, by a function for each Subject when it depends on which Subject. Never in JSX or in a spread. Review.
31
+ 5. **A follower is written out beside its leader:** `createWard({ follow: panel }, turns)`. Review.
32
+ 6. **A ward is spread on its one Subject,** `<li {...row} />`. A style goes through the ward, `{...row.with({ style })}` or its own `style`, and a component a ward is spread on passes `props.ref` and `props.style` to its element. Code: `WARDIC_WARD_ON_TWO_SUBJECTS`, `WARDIC_STYLE_BESIDE_SPREAD`, `WARDIC_REF_NOT_CALLED`.
33
+ 7. **A ward's keys are checked where they're written:** a misspelt or foreign key is an error at the call. A style value goes by its CSS name, `"box-shadow"` and `"background-color"` as Solid's `style` takes them, not Motion's camelCase `boxShadow`, which is "isn't a value a ward on the page animates". Type.
34
+ 8. **A rune listens in its `ref`,** and a ward's reads are read where they're followed: in JSX, a memo or an effect. Type for a handler in a rune's `props`; code for a read too early, `WARDIC_RUNE_READ_TOO_EARLY`.
35
+ 9. **Nothing is set up:** importing the hooks gives the page the DOM's Environment, and each ward brings the Features its own config uses. A provider is for a test or a second Environment; the whole page's settings are `setupWard` or `makeWard`. Review.
36
+
37
+ ## Writing a ward
38
+
39
+ 1. **Name the Subjects:** what moves, and where each is drawn: a component, a list's row, an element another component renders (a rune's `subject`).
40
+ 2. **Write the runes:** one job each, named for it, made where rule 4 says. Give each key in one rune: a key several runes give is merged at every retarget.
41
+ 3. **Hold state in a hook, if there's any:** `createX()` returns the state and the runes that read it.
42
+ 4. **Make each ward where its Subject is drawn,** from the runes: `createWard`; `createWards` for a list; `createPresence(ward, value)` for one value at a time; `<Presence>` round what someone else removes. Followers beside their leaders.
43
+ 5. **Spread each ward on its Subject.**
44
+ 6. **Check.** The ward is done when:
45
+ - the app typechecks;
46
+ - a development run of the change, or its tests, reports no `[WARDIC_…]` code;
47
+ - every `createWard`, `createWards` and `createPresence` call is in a component's body or a row's callback;
48
+ - no hook of the app's returns a ward.
49
+
50
+ ## Where to look
51
+
52
+ - **A `[WARDIC_…]` code** in a warning, an error or a test: the `wardic-diagnostics` skill, one section per code (`node_modules/@wardic/solid/skills/wardic-diagnostics/SKILL.md`).
53
+ - **Writing or naming a rune,** joining runes, a function rune, a rune's `ref` or `props`: [runes.md](runes.md).
54
+ - **Porting from Motion:** [from-motion.md](from-motion.md).
55
+ - **Porting Wardic 2.x's own** (`w.*`, `wardic.*`, `ward(config)`, `<AnimatePresence>`): the `wardic-migrate` skill (`node_modules/@wardic/solid/skills/wardic-migrate/SKILL.md`).
56
+ - **A list's rows, something leaving,** one value at a time, a router's pages: [lists-and-presence.md](lists-and-presence.md).
57
+ - **Drag to reorder,** a grip, a behaviour of your own: [reorder-and-grips.md](reorder-and-grips.md).
58
+ - **Settings,** a default transition, reduced motion, `layoutId` groups, Features at once, a page of its own: [scopes-and-settings.md](scopes-and-settings.md).
59
+ - **Gestures as state, a ward's events,** its exits, when it's ready: [events.md](events.md).
60
+ - **The API in full:** https://next.wardic.dev/reference/solid/hooks/create-ward and the pages beside it.
@@ -0,0 +1,70 @@
1
+ # A ward's state and events
2
+
3
+ A ward says what happens to its Subject through reads and events on the ward itself, never through callback props. API: https://next.wardic.dev/reference/solid/hooks/create-ward#members and https://next.wardic.dev/reference/solid/elements/ward-events
4
+
5
+ ## Gestures and motion as state
6
+
7
+ | Read | `true` while |
8
+ | --- | --- |
9
+ | `hovering()` | The pointer is over its Subject. |
10
+ | `pressing()` | A press is held on it. |
11
+ | `dragging()` | A drag is under way. |
12
+ | `viewing()` | It's in view, by its `viewport`. |
13
+ | `focusing()` | It has the focus. |
14
+ | `animating()` | An animation of its own is on its way. |
15
+ | `shown()`, `mounted()`, `exiting()` | It's shown; it belongs on the page (until its exit has landed); it's leaving. |
16
+
17
+ Read them where they're followed: in JSX, a memo, an effect, a target's accessor. A read asks for its gesture's Feature as it's first read, so a ward reads `hovering()` with no `whileHover`.
18
+
19
+ ```tsx solid2
20
+ import { createWard } from "@wardic/solid/hooks"
21
+
22
+ function Card() {
23
+ const card = createWard({ whileHover: { y: -4 } })
24
+ return <article {...card}>{card.hovering() ? "Over" : "Away"}</article>
25
+ }
26
+ ```
27
+
28
+ ## Events
29
+
30
+ Each event has three forms:
31
+
32
+ - **`next(name)`:** a promise of the next one, from the call on: `await card.next("settled")`.
33
+ - **`each(name)`:** every one from the call on, for a `for await`.
34
+ - **`when(name)`:** a memo of the latest, for an effect: pending until the first, so the effect runs at each one. Read it in an effect, not in JSX, and write the effect's apply as a block (Solid 2 keeps what an apply returns as its cleanup). Anything reactive the apply needs (a row's `item`, a signal) is read in the compute and handed to the apply: read in the apply, it's `STRICT_READ_UNTRACKED`.
35
+
36
+ ```tsx solid2
37
+ import { createEffect, createSignal } from "solid-js"
38
+ import { createWard } from "@wardic/solid/hooks"
39
+
40
+ function Thumb() {
41
+ const [taps, setTaps] = createSignal(0)
42
+ const thumb = createWard({ whileTap: { scale: 0.95 } })
43
+ createEffect(thumb.when("tap"), () => {
44
+ setTaps((count) => count + 1)
45
+ })
46
+ return <button {...thumb}>Tapped {taps()} times</button>
47
+ }
48
+ ```
49
+
50
+ | Event | When |
51
+ | --- | --- |
52
+ | `settled` | An animation lands. |
53
+ | `hoverStart`, `hover`, `hoverEnd` | The pointer comes over, moves on, and leaves. |
54
+ | `pressStart`, `tap`, `tapCancel` | A press begins, ends on the Subject, or ends elsewhere. |
55
+ | `dragStart`, `drag`, `dragEnd` | A drag starts, moves, and ends. |
56
+ | `dragTransitionEnd` | It comes to rest after it's let go. |
57
+ | `panSessionStart`, `panStart`, `pan`, `panEnd` | A pan's pointer goes down, it starts, moves, and ends. |
58
+ | `viewportEnter`, `viewportLeave` | It comes into view, and leaves it. |
59
+ | `layoutStart`, `layoutComplete` | A layout animation starts, and lands. |
60
+ | `exitStart`, `exitComplete` | A ward a hook shows starts to leave, and has gone. |
61
+ | `ready` | Every Feature its config uses is on the page: once, and kept. |
62
+
63
+ `isPending(() => card.settled())` is "animating"; `ward.read(key)` is a value it draws.
64
+
65
+ ## Who listens where
66
+
67
+ - **The component, for the page's own business:** an effect over the ward's `when`, beside where the ward is made.
68
+ - **A rune, for what it does to its Subject:** its `ref` ([runes.md](runes.md)).
69
+ - **A rune that reads or listens to its own ward:** a function rune, whose ward's events are the finished ward's.
70
+ - **A list's or a presence's exits:** on what `createWards` returns, or the presence scope or ref ([lists-and-presence.md](lists-and-presence.md)).
@@ -0,0 +1,59 @@
1
+ # From Motion
2
+
3
+ Porting Wardic 2.x's own components (`w.*`, `wardic.*`, `ward(config)`, `<AnimatePresence>`) is the `wardic-migrate` skill's, beside this one: `node_modules/@wardic/solid/skills/wardic-migrate/SKILL.md`.
4
+
5
+ The keys keep Motion's names and meanings: `initial`, `animate`, `exit`, `variants`, `custom`, `transition`, the `while*` targets, `viewport`, `layout`, `layoutId`, `drag` and its options. What changes is where they're written: in runes, made into a ward where the Subject is drawn. The full map: https://next.wardic.dev/motion
6
+
7
+ ## The same card
8
+
9
+ Motion:
10
+
11
+ ```tsx before
12
+ <motion.div initial={{ opacity: 0 }} animate={{ opacity: 1 }} whileHover={{ y: -4 }} />
13
+ ```
14
+
15
+ Wardic's hooks:
16
+
17
+ ```tsx solid2
18
+ import { createRune, createWard } from "@wardic/solid/hooks"
19
+
20
+ const fadesIn = createRune({ initial: { opacity: 0 }, animate: { opacity: 1 } })
21
+ const lifts = createRune({ whileHover: { y: -4 } })
22
+
23
+ function Card() {
24
+ const card = createWard(fadesIn, lifts)
25
+ return <div {...card} />
26
+ }
27
+ ```
28
+
29
+ ## What replaces what
30
+
31
+ | Motion | The hooks |
32
+ | --- | --- |
33
+ | `<motion.div …>` | `createWard(...runes)`, spread on the element: `<div {...card} />` |
34
+ | `motion.create(Component)` | Spread the ward on the component, which passes `props.ref` and `props.style` to its element; or give the ward its Subject with a rune's `subject` |
35
+ | Children taking a parent's variants | Each child's ward follows its leader, written beside it: `createWard({ follow: parent }, ...runes)` |
36
+ | `staggerChildren`, `delayChildren`, `when` | The leader's `followers: { stagger, delay, order }` |
37
+ | `<AnimatePresence>` round one element that comes and goes | The ward's own `show: open`, and `<Show when={ward.mounted()}>` where it must leave the page |
38
+ | `<AnimatePresence>` round a list | `createWards(list, ...runes)`: a ward for each item, kept until its exit has landed |
39
+ | `<AnimatePresence mode="wait">` round one value | `createPresence(ward, value)` |
40
+ | `<AnimatePresence>` round children someone else removes (a router's page) | `<Presence>`: `wait` or `pop` for `mode`, `enter={false}` for `initial={false}` |
41
+ | `onExitComplete` | `when("exitComplete")` in an effect: on the ward, the list `createWards` returns, or a presence scope |
42
+ | `usePresence`'s `safeToRemove`, `useIsPresent` | `ward.hold()`, `ward.exiting()` |
43
+ | `<LayoutGroup id>` | `createLayoutGroup(id)`: a rune for a ward, and `within` for what it builds |
44
+ | `<MotionConfig transition reducedMotion>` | `createConfigScope({ transition, reducedMotion })`, a rune and `within`; for the whole page, `setupWard` |
45
+ | `<LazyMotion features>`, `m.div` | Nothing: each ward loads the Features its config uses. For Features at once, `makeWard({ features })` |
46
+ | `<Reorder.Group values onReorder>`, `<Reorder.Item value>` | `createReorder({ each, onReorder })` on the list, `list.item(value)` on each row |
47
+ | `useDragControls`, `dragListener={false}` | `createGrip(row)`, the grip's own ward |
48
+ | `onHoverStart`, `onTap`, `onAnimationComplete`, … | The ward's events: an effect over `ward.when("hoverStart")`, or `await ward.next("settled")`. See [events.md](events.md) |
49
+ | Hover or press state kept by hand | `ward.hovering()`, `ward.pressing()` |
50
+ | A style value's camelCase name, `boxShadow`, `backgroundColor` | Its CSS name, `"box-shadow"`, `"background-color"`, in a target as in `style` (`x`, `y`, `scale`, `rotate` and `opacity` keep their names) |
51
+ | `useMotionValue`, `useTransform`, `useSpring`, `useScroll`, `useAnimate` | The main entry's `create*` (`createTransform`, `createSpring`, `createScroll`, `createAnimate`): https://next.wardic.dev/motion#hooks |
52
+
53
+ ## Porting a component
54
+
55
+ 1. **Find each Subject** the component moves, and the motion props on it.
56
+ 2. **Split the props into one-job runes,** each named for what it does ([runes.md](runes.md)), made once.
57
+ 3. **Make the ward in the component's body** from the runes, and spread it in place of `motion.*`'s props.
58
+ 4. **Turn each callback prop into an event** of the ward's, heard in an effect, and each `AnimatePresence` into the hook the table names.
59
+ 5. **Check** as SKILL.md's sequence ends: types, no `[WARDIC_…]` code in a development run, every ward in a component's body or a row's callback.
@@ -0,0 +1,110 @@
1
+ # Lists, and what leaves
2
+
3
+ Choose by who decides that the Subject comes and goes. API: https://next.wardic.dev/reference/solid/hooks/presence and https://next.wardic.dev/reference/solid/hooks/create-wards
4
+
5
+ | What leaves | Its hook |
6
+ | --- | --- |
7
+ | One Subject, shown or hidden by your state | A ward's own `show` |
8
+ | A list's items | `createWards(list, ...runes)` |
9
+ | One value at a time, the old one gone before the new one comes | `createPresence(ward, value)` |
10
+ | The value now beside the one it replaced | `createWards({ value }, ...runes)` |
11
+ | Children someone else removes: a router's page, a slot | `<Presence>`, or `createPresenceScope` |
12
+
13
+ Each leaves by its ward's `exit` (its `initial` with none; `exit: false` leaves at once).
14
+
15
+ ## One Subject: `show`
16
+
17
+ ```tsx solid2
18
+ import { createSignal, Show } from "solid-js"
19
+ import { createRune, createWard } from "@wardic/solid/hooks"
20
+
21
+ const risesIn = createRune({ initial: { opacity: 0, y: 12 }, animate: { opacity: 1, y: 0 }, exit: { opacity: 0 } })
22
+
23
+ function Notice() {
24
+ const [open, setOpen] = createSignal(true)
25
+ const notice = createWard({ show: open }, risesIn)
26
+ return (
27
+ <Show when={notice.mounted()}>
28
+ <p {...notice} onClick={() => setOpen(false)}>
29
+ Saved
30
+ </p>
31
+ </Show>
32
+ )
33
+ }
34
+ ```
35
+
36
+ - Hidden, a `show` ward animates to its `exit`, then sets `display: none`. `mounted()` stays true until its exit has landed, for a `<Show>` that takes the Subject off the page instead.
37
+ - **A `show` ward is never a `layout` ward too:** hidden, it measures as an empty box and travels in from the page's corner. Something that comes and goes inside a layout container leaves the page: `createPresence`, or `createWards({ value })`.
38
+ - `pop` takes a leaving `show` ward out of the flow where it is, so what's after it moves up at once.
39
+
40
+ ## A list: `createWards`
41
+
42
+ ```tsx solid2
43
+ import { For } from "solid-js"
44
+ import { createRune, createWards } from "@wardic/solid/hooks"
45
+
46
+ const fades = createRune({ initial: { opacity: 0 }, animate: { opacity: 1 }, exit: { opacity: 0 } })
47
+
48
+ function Toasts(props: { toasts: ReadonlyArray<{ id: string; text: string }> }) {
49
+ const rows = createWards({ each: () => props.toasts, key: (toast) => toast.id }, fades, { pop: "bottom-right" }, (row) => ({ transition: { delay: row.index() * 0.05 } }))
50
+ return <For each={rows()}>{(row) => <li {...row}>{row.item.text}</li>}</For>
51
+ }
52
+ ```
53
+
54
+ - **The hook makes the rows' wards,** so an item that leaves the list stays in `rows()` until its exit has landed. Render `rows()`, not the list.
55
+ - **A function among the runes** is called for each row, with its `item` and `index()`, and gives that row's rune.
56
+ - **A row's `item` is reactive,** the latest under its key: read it in JSX, a memo, or an effect's compute, never in an effect's apply. An effect over the row's events reads the item in its compute and hands it on: `createEffect(() => [row.when("settled")(), row.item.id] as const, ([, id]) => { log(id) })`.
57
+ - **`key`** matches items when the list is made again (a refetch); **`initial: false`** gives the first rows no entrance; **`wait: true`** has new items wait until the leaving ones have gone.
58
+ - Made where the list is drawn, as a ward is.
59
+
60
+ ## One value at a time: `createPresence`
61
+
62
+ ```tsx solid2
63
+ import { Show } from "solid-js"
64
+ import { createPresence, createWard } from "@wardic/solid/hooks"
65
+
66
+ function Tabs(props: { tab: string }) {
67
+ const panel = createWard({ initial: { opacity: 0 }, animate: { opacity: 1 }, exit: { opacity: 0 } })
68
+ const shown = createPresence(panel, () => props.tab)
69
+ return <Show when={shown()} keyed>{(tab) => <div {...panel}>{tab}</div>}</Show>
70
+ }
71
+ ```
72
+
73
+ The ward is one `createWard` made, with no `show` of its own and not a list's row. `shown()` is the value on the page: the old value's Subject leaves, and only then does the new value's enter, from its `initial`. `undefined`, `null` and `false` show nothing.
74
+
75
+ ## What someone else removes: `<Presence>`
76
+
77
+ A router's page, or children handed in, are ended by their owner, and every ward inside with them, so what keeps them on the page while they leave sits above them:
78
+
79
+ ```tsx solid2
80
+ import type { JSX } from "@solidjs/web"
81
+ import { Presence } from "@wardic/solid/hooks"
82
+
83
+ function Layout(props: { children: JSX.Element }) {
84
+ return <Presence pop>{props.children}</Presence>
85
+ }
86
+ ```
87
+
88
+ - Each page's motion is its own: a ward on its own root, leaving by its `exit`.
89
+ - **A ward made inside what a `<Presence>` takes away never hears its own exit:** it ends as its exit starts. The boundary tells it: `ref={presence}`, a `createPresenceRef()`, or a `createPresenceScope` made in a module, with `when("exitComplete")`.
90
+ - `wait` (one at a time) or `pop` (out of the flow at once), not both; `enter={false}` for no entrance on the first page.
91
+
92
+ ## Leaving, heard
93
+
94
+ - A ward that a hook shows (`show`, a row, a `createPresence`'s) hears `"exitStart"` and `"exitComplete"`; a list hears its own on what `createWards` returns.
95
+ - `ward.hold()` keeps a leaving Subject on the page until the release it returns is called: for a save, a CSS transition, another library's exit.
96
+
97
+ ```tsx solid2
98
+ import { createEffect, createSignal } from "solid-js"
99
+ import { createWard } from "@wardic/solid/hooks"
100
+
101
+ function Draft() {
102
+ const [open, setOpen] = createSignal(true)
103
+ const card = createWard({ show: open, exit: { opacity: 0 } })
104
+ createEffect(card.when("exitStart"), () => {
105
+ const release = card.hold()
106
+ void saveDraft().then(release)
107
+ })
108
+ return <article {...card} onClick={() => setOpen(false)} />
109
+ }
110
+ ```
@@ -0,0 +1,88 @@
1
+ # Drag to reorder, grips, and behaviours
2
+
3
+ A reorder is a ward's drag driven by a behaviour, a function rune: `list.item(value)` is Wardic's, and an app can write its own on `ward.drag`. API: https://next.wardic.dev/reference/solid/hooks/reorder
4
+
5
+ ## A reordered list
6
+
7
+ ```tsx solid2
8
+ import { createSignal, For } from "solid-js"
9
+ import { createReorder, createRune, createWards } from "@wardic/solid/hooks"
10
+
11
+ const heldUp = createRune({ whileDrag: { scale: 1.03 } })
12
+
13
+ function Shelf() {
14
+ const [items, setItems] = createSignal([{ name: "Linen" }, { name: "Wool" }, { name: "Silk" }])
15
+ const list = createReorder({ each: items, onReorder: setItems })
16
+ const rows = createWards(items, (row) => list.item(row.item), heldUp)
17
+ return (
18
+ <ul {...list}>
19
+ <For each={rows()}>{(row) => <li {...row}>{row.item.name}</li>}</For>
20
+ </ul>
21
+ )
22
+ }
23
+ ```
24
+
25
+ - **The list is the app's:** `each` is its order, and `onReorder` is handed the new order as an item passes another, or moves by the keys. Set the list from it.
26
+ - **`list.item(value)` is each row's behaviour:** it gives the row `layout`, a drag along the list's axis, the keyboard reorder's tab stop, and its lift.
27
+ - **Spread the list on the list's Subject** as it is. Its own style goes in `createReorder({ style })`, never beside the spread, where it would replace the list's. To move the list itself too, give a ward of its own the list as a rune, `createWard(fadesIn, list)`, and spread that ward in its place.
28
+ - **Save once, at a reorder's end:** an effect over `list.when("reorderEnd")`, handed `values`.
29
+ - **`key`** keeps an item's place and drag when the app makes its list again (a store's copy, a refetch); give the rows' `createWards` the same `key`.
30
+ - `createReorder` may be made in the app's hook (its list is a rune with an API); the rows' wards are made in the component.
31
+
32
+ ## A grip: `createGrip(row)`
33
+
34
+ What the visitor drags a row by. A press on the grip's Subject starts the row's drag; while one of the row's grips is on the page, the row drags from its grips alone. The grip has a ward of its own:
35
+
36
+ ```tsx solid2
37
+ import { createSignal, For } from "solid-js"
38
+ import { createGrip, createReorder, createRune, createWard } from "@wardic/solid/hooks"
39
+
40
+ const gripLook = createRune({ whileHover: { opacity: 1 }, style: { opacity: 0.6, cursor: "grab" } })
41
+
42
+ function Tasks() {
43
+ const [tasks, setTasks] = createSignal(["Glaze", "Fire", "Pack"])
44
+ const list = createReorder({ each: tasks, onReorder: setTasks })
45
+ return (
46
+ <ul {...list}>
47
+ <For each={tasks()}>
48
+ {(task) => {
49
+ // Made in the row's callback, where the row is drawn.
50
+ const row = createWard(list.item(task))
51
+ const grip = createWard(createGrip(row), gripLook)
52
+ return (
53
+ <li {...row}>
54
+ <button {...grip} aria-label="Move">
55
+ ⋮⋮
56
+ </button>
57
+ {task}
58
+ </li>
59
+ )
60
+ }}
61
+ </For>
62
+ </ul>
63
+ )
64
+ }
65
+ ```
66
+
67
+ - **The row is one that drags:** one of its runes gives `drag` (a behaviour does). A grip of a row that doesn't drag is `WARDIC_GRIP_ROW_DOESNT_DRAG`.
68
+ - **The grip goes inside its row's Subject.** Outside it, `WARDIC_GRIP_OUTSIDE_ROW`.
69
+ - It writes the `touch-action` for the row's axis; its cursor, `role` and label are the app's.
70
+
71
+ ## A behaviour of your own: `ward.drag`
72
+
73
+ A behaviour is a function rune that listens on `ward.drag` and gives the keys that respond, `drag`, `layout` and `lifted`:
74
+
75
+ ```tsx solid2
76
+ import { createRune } from "@wardic/solid/hooks"
77
+
78
+ const swipes = (onSwipe: (dx: number) => void) =>
79
+ createRune((ward) => {
80
+ ward.drag.onSample((sample) => {
81
+ if (sample.phase === "end") onSwipe(sample.offset.x)
82
+ })
83
+ return { drag: "x", dragSnapToOrigin: true }
84
+ })
85
+ ```
86
+
87
+ - `onSample` (each sample: `phase`, `point`, `offset`, `delta`, `velocity`), `onKey` (its keys, which make its Subject a tab stop), `onBlur`, `onPress`, and `measured()`, its box.
88
+ - `drag` is on a function rune's ward alone. A rune that listens on a ward nothing gives a `drag` is `WARDIC_DRAG_NOT_GIVEN`.
@@ -0,0 +1,151 @@
1
+ # Runes
2
+
3
+ A ward is made of runes, each one job: a fade, a lift, a spring, a list's place. These rules hold for a rune in any Wardic binding; the examples are Solid's hooks. API: https://next.wardic.dev/reference/solid/hooks/runes
4
+
5
+ ## The rules
6
+
7
+ Each rule's tier says what catches it, as in SKILL.md: **type**, **code**, **runtime** (an error with no Wardic code), or **review**.
8
+
9
+ 1. **A rune says one thing, and has a name for it.** A behaviour's name is a verb (`fadesIn`, `risesIn`, `lifts`, `gives`, `travels`), a transition's an adjective (`springy`, `soft`, `slow`), a factory's what it gives (`card(index)`). No `Rune` suffix. Review.
10
+ 2. **A rune is a value; a setting makes it a function.** A rune that depends on nothing is a constant. One that takes a setting is a function that returns a rune: `spring(stiffness)`, `dragToClose(close)`. Review.
11
+ 3. **A rune is fixed once made.** Its keys are the ones it has as it's made, and a plain value in it (a target, a transition, its variants) is meant to stay as it is: the rune is frozen, so setting, adding or deleting a key throws, and in development the data inside it is frozen too. What changes is an accessor, a function or a getter, read where the ward reads it (`animate: () => ({ x: x() })`), or a store. To change a rune, make another, or give the key an accessor. Runtime: a `TypeError`, with no Wardic code.
12
+ 4. **A behaviour is a rune:** a function rune for what reads or listens to its ward, a `ref` for what it does to its Subject. Never a ward, and never a handler prop. Type, for a handler in a rune's `props`; review otherwise.
13
+ 5. **Wardic's words fit any host; an Environment's words are its own.** `initial`, `animate`, `exit`, `variants`, `transition`, the `while*` targets, `show`, `follow` and `followers` say motion whatever moves. A page's rune adds the page's (`style`, `layout`, `drag`, `ref`, `props`, `subject`, `tag`, `pop`): such a rune fits a page's ward only. Type: a key a ward doesn't take is an error at its `createWard`.
14
+
15
+ ## Writing one
16
+
17
+ ```tsx solid2
18
+ import { createRune, createWard } from "@wardic/solid/hooks"
19
+
20
+ const fadesIn = createRune({ initial: { opacity: 0 }, animate: { opacity: 1 } })
21
+ const lifts = createRune({ whileHover: { y: -4 } })
22
+ const springy = createRune({ transition: { type: "spring", stiffness: 400, damping: 28 } })
23
+
24
+ function Card() {
25
+ const card = createWard(fadesIn, lifts, springy)
26
+ return <article {...card} />
27
+ }
28
+ ```
29
+
30
+ - **`createRune(config)`** checks a config where it's written, so a rune kept in a constant is checked there. A config written in a ward's own call is checked by that call; a plain object is a rune too.
31
+ - **Where it's made** (SKILL.md's rule 4): a module for a constant; once in a hook for one over the hook's state; a function for each Subject for one over which Subject it's on.
32
+
33
+ ```tsx solid2
34
+ import { createSignal } from "solid-js"
35
+ import { createRune } from "@wardic/solid/hooks"
36
+
37
+ export function createDisclosure() {
38
+ const [open, setOpen] = createSignal(false)
39
+ // Made once, over the hook's state: every ward given it follows `open`.
40
+ const opens = createRune({ initial: "closed", animate: () => (open() ? "open" : "closed"), variants: { open: { opacity: 1, y: 0 }, closed: { opacity: 0, y: -8 } } })
41
+ return { open, toggle: () => setOpen((was) => !was), opens }
42
+ }
43
+ ```
44
+
45
+ ## How runes join
46
+
47
+ A ward's runes join key by key, a later rune winning:
48
+
49
+ - `initial`, `animate`, `exit`, the `while*` targets, `transition` and `style` merge their keys when both are objects.
50
+ - `variants` merge by name, then key by key.
51
+ - Anything else is the later rune's.
52
+ - Every rune's `ref` runs; none wins.
53
+ - `props` join name by name, a later rune's winning a name.
54
+
55
+ Give each key in one rune: a key several runes give is merged each time it changes.
56
+
57
+ ## Function runes
58
+
59
+ `createRune((ward) => config)` is a hook's body for each ward it's given to: called once for that ward, as it's made and under its owner, and returning that ward's config.
60
+
61
+ ```tsx solid2
62
+ import { createEffect } from "solid-js"
63
+ import { createRune } from "@wardic/solid/hooks"
64
+
65
+ const dragToClose = (close: () => void) =>
66
+ createRune((sheet) => {
67
+ createEffect(sheet.when("dragEnd"), (release) => {
68
+ if (release.offset.y > 120) close()
69
+ })
70
+ return { drag: "y", dragSnapToOrigin: true }
71
+ })
72
+ ```
73
+
74
+ - **Its ward's reads and events are the finished ward's:** `ward.hovering()`, `ward.exiting()`, `ward.when("exitComplete")`.
75
+ - **Read them where they're followed:** in a target's accessor, a `props` value, a memo, an effect. Read bare in the body, a read is read once, and too early is `WARDIC_RUNE_READ_TOO_EARLY`.
76
+ - **Its ward alone has `drag`,** what it hears of its drag: see [reorder-and-grips.md](reorder-and-grips.md).
77
+
78
+ ## `ref`: what a rune does to its Subject
79
+
80
+ ```tsx solid2
81
+ import { createRune } from "@wardic/solid/hooks"
82
+
83
+ const closesOnEscape = (close: () => void) =>
84
+ createRune({
85
+ ref: (subject) => {
86
+ const onKey = (event: KeyboardEvent) => {
87
+ if (event.key === "Escape") close()
88
+ }
89
+ subject.addEventListener("keydown", onKey)
90
+ return () => subject.removeEventListener("keydown", onKey)
91
+ },
92
+ })
93
+ ```
94
+
95
+ - **Handed its Subject alone,** once it's on the page. What it returns undoes it, once the Subject is off show.
96
+ - **Untracked, as Solid's `ref` is:** to follow a signal, make an effect in a function rune.
97
+ - **Its listener hears an event before the page's own handlers.** Take an event with `preventDefault()`, which they then see, never `stopPropagation()`; leave an event that began in a child alone (`event.target !== subject`).
98
+
99
+ ## `props`: what a rune sets on its Subject
100
+
101
+ ```tsx solid2
102
+ import { createRune } from "@wardic/solid/hooks"
103
+
104
+ const toggles = (on: () => boolean) => createRune({ props: { role: "switch", tabindex: 0, "data-on": on } })
105
+ ```
106
+
107
+ Attributes alone: a `role`, a `tabindex`, an `aria-` state, a `data-` mark, each a value or an accessor. A handler is a `ref`'s job; `style` and `ref` are a rune's own keys; a state is a `data-` attribute a stylesheet reads, not a `class`.
108
+
109
+ ## A rune with an API: `createRuneWith`
110
+
111
+ A utility of the app's own hands back one value that's a rune where a ward is given it, and an API where the app calls it:
112
+
113
+ ```tsx solid2
114
+ import { createSignal } from "solid-js"
115
+ import { createRuneWith } from "@wardic/solid/hooks"
116
+
117
+ export const createCarousel = (count: number) => {
118
+ const [index, setIndex] = createSignal(0)
119
+ return createRuneWith(
120
+ { get animate() { return { x: `${-index() * 100}%` } }, transition: { type: "spring", bounce: 0 } },
121
+ { index, next: () => setIndex((i) => Math.min(i + 1, count - 1)), prev: () => setIndex((i) => Math.max(i - 1, 0)) },
122
+ )
123
+ }
124
+ ```
125
+
126
+ The component makes the ward, `createWard({ drag: "x" }, carousel)`, and calls `carousel.next()` from its buttons. An API member named like one of the rune's keys is refused.
127
+
128
+ ## Followers
129
+
130
+ A ward takes another's variant names with `follow`, written where it's made, beside its leader. The leader times its followers with `followers`:
131
+
132
+ ```tsx solid2
133
+ import { createSignal } from "solid-js"
134
+ import { createRune, createWard } from "@wardic/solid/hooks"
135
+
136
+ const turns = createRune({ variants: { open: { rotate: 180 }, closed: { rotate: 0 } } })
137
+ const staggered = createRune({ followers: { stagger: 0.05 } })
138
+
139
+ function Disclosure() {
140
+ const [state, setState] = createSignal<"open" | "closed">("closed")
141
+ const panel = createWard({ initial: "closed", animate: state }, staggered)
142
+ const chevron = createWard({ follow: panel }, turns)
143
+ return (
144
+ <section {...panel}>
145
+ <button onClick={() => setState((was) => (was === "open" ? "closed" : "open"))}>
146
+ <span {...chevron}>⌄</span>
147
+ </button>
148
+ </section>
149
+ )
150
+ }
151
+ ```
@@ -0,0 +1,75 @@
1
+ # Scopes and settings
2
+
3
+ API: https://next.wardic.dev/reference/solid/hooks/scopes and https://next.wardic.dev/reference/solid/hooks/make-ward
4
+
5
+ ## Nothing is set up
6
+
7
+ Importing `@wardic/solid/hooks` gives the page the DOM's Environment, `DomLive`, and every setting at its default. Each ward brings the Features its own config uses (hover, press, focus, inView, pan, drag, layout, colors), each a module fetched the first time a ward asks for it. No provider and no list of Features. A ward's `when("ready")` says when its Features are all there.
8
+
9
+ | Need | Reach for |
10
+ | --- | --- |
11
+ | Settings for the whole page: a default `transition`, `reducedMotion`, `appear`, `nonce`, `strict` | `setupWard({ … })`, once, in a module that loads before anything renders |
12
+ | Features at once, in the page's own bundle, with nothing loaded later | `makeWard({ features, … })`, once, in a module of its own; its `createWard` and `createWards` bring them |
13
+ | Settings for some wards: a default `transition`, `reducedMotion`, `skipAnimations` | `createConfigScope({ … })` |
14
+ | `layoutId`s that two copies of a component keep apart | `createLayoutGroup(id)` |
15
+ | A page of its own inside the page: a test's Environment, an embedded widget | `createWardicScope({ env, features })` |
16
+
17
+ `<WardicProvider>`, `<WardicConfig>` and `<LayoutGroup>` are utilities over these, for code written that way; new code uses the hooks.
18
+
19
+ ## `make*` once, in a module; `create*` in a component
20
+
21
+ ```tsx solid2
22
+ // src/lib/wardic.ts
23
+ import { domAnimation } from "@wardic/solid"
24
+ import { makeWard } from "@wardic/solid/hooks"
25
+
26
+ export const wardic = makeWard({ features: domAnimation, strict: true })
27
+ export const { createWard, createWards } = wardic
28
+ ```
29
+
30
+ Components then import `createWard` from that module. `wardic.with(layout)` makes the same hooks with more Features, for a module only some pages import. A page with settings and no Features calls `setupWard` instead.
31
+
32
+ ## A scope builds what's inside it: `within`
33
+
34
+ A Solid 2 component has no owner of its own, so a context set from its body would land on the owner around it and on every sibling after it. A scope is a value with `within(build)`, Solid's own provider round what it builds: every ward made in `build`, at any depth, is in the scope.
35
+
36
+ A config scope and a layout group are runes too, for a ward made beside them in the same body, which isn't inside their `within`:
37
+
38
+ ```tsx solid2
39
+ import { createConfigScope, createRune, createWard } from "@wardic/solid/hooks"
40
+
41
+ const calm = createConfigScope({ transition: { type: "tween", duration: 0.6 } })
42
+ const lifts = createRune({ whileHover: { y: -4 } })
43
+
44
+ function Shelf() {
45
+ // This ward, by the scope as a rune; every ward made in `within`, by the scope around it.
46
+ const title = createWard(calm, lifts)
47
+ return (
48
+ <section>
49
+ <h2 {...title}>New in</h2>
50
+ {calm.within(() => <Cards />)}
51
+ </section>
52
+ )
53
+ }
54
+ ```
55
+
56
+ - **Given as a rune, write the scope first:** a later rune's key wins, so `createWard(calm, { transition: fast })` keeps `fast`.
57
+ - **A ward's own key beats every scope it's inside.**
58
+ - **A layout group puts a ward's `layoutId` in its namespace:** `createWard(tabs, { layoutId: "underline" })`.
59
+
60
+ ```tsx solid2
61
+ import { createLayoutGroup, createWard } from "@wardic/solid/hooks"
62
+
63
+ function TabBar() {
64
+ const tabs = createLayoutGroup("tabs")
65
+ const underline = createWard(tabs, { layoutId: "underline" })
66
+ return (
67
+ <nav>
68
+ {tabs.within(() => <Tabs />)}
69
+ <span {...underline} />
70
+ </nav>
71
+ )
72
+ }
73
+ ```
74
+
75
+ - **A Wardic scope is no rune:** a ward is made in it, not given it. Nothing from around it reaches its wards: neither the page's settings nor a config scope's.
@@ -26,7 +26,7 @@ export const eachFrameOf = (runtime: WardicRuntime, callback: (time: number, del
26
26
  } catch (defect) {
27
27
  if (failing) return
28
28
  failing = true
29
- runtime.runFork(Report.failure("wardic.createAnimationFrame: the callback failed", Cause.die(defect)))
29
+ runtime.runFork(Report.callbackFailed("wardic.createAnimationFrame: the callback failed", Cause.die(defect)))
30
30
  }
31
31
  })
32
32
  }
@@ -27,6 +27,7 @@ import * as Predicate from "effect/Predicate"
27
27
  import * as UndefinedOr from "effect/UndefinedOr"
28
28
  import { latest, NotReadyError, runWithOwner, untrack } from "solid-js"
29
29
  import type { Accessor } from "solid-js"
30
+ import { misuse } from "./diagnostics.ts"
30
31
 
31
32
  /**
32
33
  * A config whose keys may each be an accessor (#259): a key's value, or a function returning it,
@@ -119,7 +120,10 @@ const NONE_PENDING: ReadonlyArray<never> = []
119
120
 
120
121
  /** The error for an accessor that returned a promise (#257 item 1, Q3). */
121
122
  const promiseError = (key: string): Error =>
122
- new Error(`\`${key}\`'s accessor returned a promise: give it an async memo instead, \`${key}: createMemo(() => …)\`. An accessor is called at every read of its key, so it would fetch at each.`)
123
+ misuse(
124
+ "WARDIC_ACCESSOR_RETURNED_PROMISE",
125
+ `\`${key}\`'s accessor returned a promise: give it an async memo instead, \`${key}: createMemo(() => …)\`. An accessor is called at every read of its key, so it would fetch at each.`,
126
+ )
123
127
 
124
128
 
125
129
  /**