@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.
- package/README.md +17 -0
- package/dist/browser/animation-frame.js +1 -1
- package/dist/browser/animation-frame.js.map +1 -1
- package/dist/browser/config-view.js +2 -1
- package/dist/browser/config-view.js.map +1 -1
- package/dist/browser/diagnostic-codes.js +216 -0
- package/dist/browser/diagnostic-codes.js.map +1 -0
- package/dist/browser/diagnostics.js +79 -0
- package/dist/browser/diagnostics.js.map +1 -0
- package/dist/browser/element.js +7 -6
- package/dist/browser/element.js.map +1 -1
- package/dist/browser/frame-effect.js +1 -1
- package/dist/browser/frame-effect.js.map +1 -1
- package/dist/browser/gesture-callbacks.js +1 -1
- package/dist/browser/gesture-callbacks.js.map +1 -1
- package/dist/browser/hooks/drag.js +4 -3
- package/dist/browser/hooks/drag.js.map +1 -1
- package/dist/browser/hooks/presence-scope.js +2 -1
- package/dist/browser/hooks/presence-scope.js.map +1 -1
- package/dist/browser/hooks/reorder-elements.js +5 -4
- package/dist/browser/hooks/reorder-elements.js.map +1 -1
- package/dist/browser/hooks/rune.js +4 -3
- package/dist/browser/hooks/rune.js.map +1 -1
- package/dist/browser/hooks/ward.js +31 -12
- package/dist/browser/hooks/ward.js.map +1 -1
- package/dist/browser/hooks/wards.js +3 -2
- package/dist/browser/hooks/wards.js.map +1 -1
- package/dist/browser/provider.js +40 -21
- package/dist/browser/provider.js.map +1 -1
- package/dist/browser/reorder.js +5 -4
- package/dist/browser/reorder.js.map +1 -1
- package/dist/browser/runtime.js +26 -15
- package/dist/browser/runtime.js.map +1 -1
- package/dist/browser/spans-check.js +8 -3
- package/dist/browser/spans-check.js.map +1 -1
- package/dist/browser/v1/index.js +1 -1
- package/dist/browser/ward.js +25 -19
- package/dist/browser/ward.js.map +1 -1
- package/dist/server/animation-frame.js +1 -1
- package/dist/server/animation-frame.js.map +1 -1
- package/dist/server/config-view.js +2 -1
- package/dist/server/config-view.js.map +1 -1
- package/dist/server/diagnostic-codes.js +216 -0
- package/dist/server/diagnostic-codes.js.map +1 -0
- package/dist/server/diagnostics.js +79 -0
- package/dist/server/diagnostics.js.map +1 -0
- package/dist/server/element.js +7 -6
- package/dist/server/element.js.map +1 -1
- package/dist/server/frame-effect.js +1 -1
- package/dist/server/frame-effect.js.map +1 -1
- package/dist/server/gesture-callbacks.js +1 -1
- package/dist/server/gesture-callbacks.js.map +1 -1
- package/dist/server/hooks/drag.js +4 -3
- package/dist/server/hooks/drag.js.map +1 -1
- package/dist/server/hooks/presence-scope.js +2 -1
- package/dist/server/hooks/presence-scope.js.map +1 -1
- package/dist/server/hooks/reorder-elements.js +5 -4
- package/dist/server/hooks/reorder-elements.js.map +1 -1
- package/dist/server/hooks/rune.js +4 -3
- package/dist/server/hooks/rune.js.map +1 -1
- package/dist/server/hooks/ward.js +31 -12
- package/dist/server/hooks/ward.js.map +1 -1
- package/dist/server/hooks/wards.js +3 -2
- package/dist/server/hooks/wards.js.map +1 -1
- package/dist/server/provider.js +40 -21
- package/dist/server/provider.js.map +1 -1
- package/dist/server/reorder.js +5 -4
- package/dist/server/reorder.js.map +1 -1
- package/dist/server/runtime.js +26 -15
- package/dist/server/runtime.js.map +1 -1
- package/dist/server/spans-check.js +8 -3
- package/dist/server/spans-check.js.map +1 -1
- package/dist/server/v1/index.js +1 -1
- package/dist/server/ward.js +25 -19
- package/dist/server/ward.js.map +1 -1
- package/dist/solid/animation-frame.js +1 -1
- package/dist/solid/animation-frame.js.map +1 -1
- package/dist/solid/config-view.d.ts.map +1 -1
- package/dist/solid/config-view.js +2 -1
- package/dist/solid/config-view.js.map +1 -1
- package/dist/solid/diagnostic-codes.d.ts +10 -0
- package/dist/solid/diagnostic-codes.d.ts.map +1 -0
- package/dist/solid/diagnostic-codes.js +246 -0
- package/dist/solid/diagnostic-codes.js.map +1 -0
- package/dist/solid/diagnostics.d.ts +33 -0
- package/dist/solid/diagnostics.d.ts.map +1 -0
- package/dist/solid/diagnostics.js +76 -0
- package/dist/solid/diagnostics.js.map +1 -0
- package/dist/solid/element.d.ts.map +1 -1
- package/dist/solid/element.jsx +8 -8
- package/dist/solid/element.jsx.map +1 -1
- package/dist/solid/frame-effect.jsx +1 -1
- package/dist/solid/frame-effect.jsx.map +1 -1
- package/dist/solid/gesture-callbacks.js +1 -1
- package/dist/solid/gesture-callbacks.js.map +1 -1
- package/dist/solid/hooks/drag.d.ts.map +1 -1
- package/dist/solid/hooks/drag.js +4 -3
- package/dist/solid/hooks/drag.js.map +1 -1
- package/dist/solid/hooks/presence-scope.d.ts.map +1 -1
- package/dist/solid/hooks/presence-scope.jsx +2 -1
- package/dist/solid/hooks/presence-scope.jsx.map +1 -1
- package/dist/solid/hooks/reorder-elements.d.ts.map +1 -1
- package/dist/solid/hooks/reorder-elements.jsx +5 -4
- package/dist/solid/hooks/reorder-elements.jsx.map +1 -1
- package/dist/solid/hooks/rune.d.ts.map +1 -1
- package/dist/solid/hooks/rune.js +4 -3
- package/dist/solid/hooks/rune.js.map +1 -1
- package/dist/solid/hooks/ward.d.ts.map +1 -1
- package/dist/solid/hooks/ward.js +35 -14
- package/dist/solid/hooks/ward.js.map +1 -1
- package/dist/solid/hooks/wards.d.ts.map +1 -1
- package/dist/solid/hooks/wards.js +3 -2
- package/dist/solid/hooks/wards.js.map +1 -1
- package/dist/solid/provider.d.ts.map +1 -1
- package/dist/solid/provider.jsx +41 -21
- package/dist/solid/provider.jsx.map +1 -1
- package/dist/solid/reorder.d.ts.map +1 -1
- package/dist/solid/reorder.jsx +5 -4
- package/dist/solid/reorder.jsx.map +1 -1
- package/dist/solid/runtime.d.ts +20 -7
- package/dist/solid/runtime.d.ts.map +1 -1
- package/dist/solid/runtime.js +25 -14
- package/dist/solid/runtime.js.map +1 -1
- package/dist/solid/spans-check.d.ts +5 -1
- package/dist/solid/spans-check.d.ts.map +1 -1
- package/dist/solid/spans-check.js +8 -3
- package/dist/solid/spans-check.js.map +1 -1
- package/dist/solid/v1/index.d.ts +1 -1
- package/dist/solid/v1/index.jsx +1 -1
- package/dist/solid/ward.d.ts.map +1 -1
- package/dist/solid/ward.jsx +25 -19
- package/dist/solid/ward.jsx.map +1 -1
- package/package.json +8 -6
- package/skills/wardic-diagnostics/SKILL.md +472 -0
- package/skills/wardic-migrate/SKILL.md +204 -0
- package/skills/wardic-solid/SKILL.md +60 -0
- package/skills/wardic-solid/events.md +70 -0
- package/skills/wardic-solid/from-motion.md +59 -0
- package/skills/wardic-solid/lists-and-presence.md +110 -0
- package/skills/wardic-solid/reorder-and-grips.md +88 -0
- package/skills/wardic-solid/runes.md +151 -0
- package/skills/wardic-solid/scopes-and-settings.md +75 -0
- package/src/animation-frame.ts +1 -1
- package/src/config-view.ts +5 -1
- package/src/diagnostic-codes.ts +254 -0
- package/src/diagnostics.ts +88 -0
- package/src/element.tsx +13 -10
- package/src/frame-effect.tsx +1 -1
- package/src/gesture-callbacks.ts +1 -1
- package/src/hooks/drag.ts +4 -3
- package/src/hooks/presence-scope.tsx +2 -1
- package/src/hooks/reorder-elements.tsx +6 -4
- package/src/hooks/rune.ts +4 -3
- package/src/hooks/ward.ts +36 -12
- package/src/hooks/wards.ts +4 -2
- package/src/provider.tsx +43 -20
- package/src/reorder.tsx +5 -4
- package/src/runtime.ts +43 -13
- package/src/spans-check.ts +12 -3
- package/src/v1/index.tsx +1 -1
- package/src/ward.tsx +27 -19
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Solid binding's coded diagnostics (solid-next, the skill grill's Q12, Q18): each code it reports
|
|
3
|
+
* (`report` and `misuse`, `./diagnostics.ts`), with what the docs and the `wardic-diagnostics` skill
|
|
4
|
+
* say of it, both generated from here by `scripts/diagnostics.ts`. Imported by nothing an app runs.
|
|
5
|
+
*
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
import type * as Diagnostic from "@wardic/core/unstable/Diagnostic"
|
|
9
|
+
|
|
10
|
+
export const CODES: ReadonlyArray<Diagnostic.Entry> = [
|
|
11
|
+
{
|
|
12
|
+
code: "WARDIC_GRIP_ROW_DOESNT_DRAG",
|
|
13
|
+
group: "Grips and reorder",
|
|
14
|
+
summary: "A grip was made for a ward that doesn't drag.",
|
|
15
|
+
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.",
|
|
16
|
+
repair: "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.",
|
|
17
|
+
example: {
|
|
18
|
+
before: 'import { createGrip, createWard } from "@wardic/solid/hooks"\n\nconst row = createWard(fadesIn)\nconst grip = createWard(createGrip(row as never))',
|
|
19
|
+
after: 'import { createGrip, createWard } from "@wardic/solid/hooks"\n\nconst row = createWard(fadesIn, list.item(value))\nconst grip = createWard(createGrip(row))',
|
|
20
|
+
},
|
|
21
|
+
notes: ["The behaviour-runes grill's Q14, Q20"],
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
code: "WARDIC_WARD_ON_TWO_SUBJECTS",
|
|
25
|
+
group: "Refs and spread",
|
|
26
|
+
summary: "One ward was spread on, or given to, a second element while the first is still on the page.",
|
|
27
|
+
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.",
|
|
28
|
+
repair: "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.",
|
|
29
|
+
example: {
|
|
30
|
+
before: 'import { createWard } from "@wardic/solid/hooks"\n\nconst card = createWard(fadesIn)\n<div {...card} />\n<div {...card} />',
|
|
31
|
+
after: 'import { createWard } from "@wardic/solid/hooks"\n\nfunction Card() {\n const card = createWard(fadesIn)\n return <div {...card} />\n}',
|
|
32
|
+
},
|
|
33
|
+
notes: ["#349's Q5"],
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
code: "WARDIC_REF_NOT_CALLED",
|
|
37
|
+
group: "Refs and spread",
|
|
38
|
+
summary: "A ward was spread on a component that never called its `ref`, so no element is its Subject.",
|
|
39
|
+
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.",
|
|
40
|
+
repair: "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.",
|
|
41
|
+
example: {
|
|
42
|
+
before: "function Card(props) {\n return <div class=\"card\">{props.children}</div>\n}\n<Card {...card} />",
|
|
43
|
+
after: "function Card(props: { ref?: (el: HTMLElement) => void; children?: unknown }) {\n return <div class=\"card\" ref={props.ref}>{props.children as never}</div>\n}",
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
code: "WARDIC_SUBJECT_NOT_ONE_ELEMENT",
|
|
48
|
+
group: "Refs and spread",
|
|
49
|
+
summary: "A rune's `subject` didn't resolve to one element.",
|
|
50
|
+
why: "A ward moves one Subject. A `subject` that resolves to nothing, to text, or to several elements leaves it nothing it can drive.",
|
|
51
|
+
repair: "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.",
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
code: "WARDIC_PRESENCE_WARD_HAS_SHOW",
|
|
55
|
+
group: "Presence",
|
|
56
|
+
summary: "`createPresence(ward, value)` was given a ward that has a `show` of its own, or is a list's row.",
|
|
57
|
+
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.",
|
|
58
|
+
repair: "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.",
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
code: "WARDIC_PRESENCE_WARD_TAKEN",
|
|
62
|
+
group: "Presence",
|
|
63
|
+
summary: "A ward given to `createPresence` already has a presence.",
|
|
64
|
+
why: "A presence drives its ward's coming and going. Two presences on one ward would each try to show and remove it.",
|
|
65
|
+
repair: "Make a ward for each presence.",
|
|
66
|
+
example: {
|
|
67
|
+
before: 'import { createPresence, createWard } from "@wardic/solid/hooks"\n\nconst panel = createWard(fadesIn)\nconst a = createPresence(panel, open)\nconst b = createPresence(panel, other)',
|
|
68
|
+
after: 'import { createPresence, createWard } from "@wardic/solid/hooks"\n\nconst a = createPresence(createWard(fadesIn), open)\nconst b = createPresence(createWard(fadesIn), other)',
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
code: "WARDIC_PRESENCE_SCOPE_REUSED",
|
|
73
|
+
group: "Presence",
|
|
74
|
+
summary: "A presence scope's `within` was used round a second boundary while the first is still on the page.",
|
|
75
|
+
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.",
|
|
76
|
+
repair: "Make a scope for each boundary, with `createPresenceScope` where each is drawn.",
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
code: "WARDIC_FOLLOW_LEADER_UNNAMED",
|
|
80
|
+
group: "Follow, variants and config",
|
|
81
|
+
summary: "A ward follows a leader that names no states.",
|
|
82
|
+
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.",
|
|
83
|
+
repair: "Give the leader `variants` and name its states in `animate` (`animate: \"open\"`), or give the follower values of its own instead of following.",
|
|
84
|
+
example: {
|
|
85
|
+
before: 'import { createWard } from "@wardic/solid/hooks"\n\nconst panel = createWard({ animate: { opacity: 1 } })\nconst chevron = createWard({ follow: panel, variants: { open: { rotate: 180 } } })',
|
|
86
|
+
after: 'import { createWard } from "@wardic/solid/hooks"\n\nconst panel = createWard({ variants: { open: { opacity: 1 } }, animate: "open" })\nconst chevron = createWard({ follow: panel, variants: { open: { rotate: 180 } } })',
|
|
87
|
+
},
|
|
88
|
+
notes: ["The follow grill's Q2, Q6"],
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
code: "WARDIC_GRIP_OUTSIDE_ROW",
|
|
92
|
+
group: "Grips and reorder",
|
|
93
|
+
summary: "A grip was rendered outside its row's Subject.",
|
|
94
|
+
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.",
|
|
95
|
+
repair: "Render the grip inside its row's Subject, as one of its children.",
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
code: "WARDIC_DRAG_NOT_GIVEN",
|
|
99
|
+
group: "Grips and reorder",
|
|
100
|
+
summary: "A rune listens to `ward.drag`, but nothing gives the ward a `drag`.",
|
|
101
|
+
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.",
|
|
102
|
+
repair: "Give the ward `drag` (`createRune({ drag: \"x\" })`), or have the behaviour return `drag` in the rune it makes.",
|
|
103
|
+
notes: ["The behaviour-runes grill's Q19"],
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
code: "WARDIC_COMPLETE_UNDER_STRICT",
|
|
107
|
+
group: "Features",
|
|
108
|
+
summary: "A Complete element (`wardic.*`, `wardic.create`, `ward()`) was rendered where `strict` is on.",
|
|
109
|
+
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.",
|
|
110
|
+
repair: "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.",
|
|
111
|
+
notes: ["#511, ADR-0067 decision 7"],
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
code: "WARDIC_FEATURE_MISSING",
|
|
115
|
+
group: "Features",
|
|
116
|
+
summary: "An element uses something that needs a Feature its provider wasn't given: a layout prop, a gesture, or a wide-gamut colour.",
|
|
117
|
+
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.",
|
|
118
|
+
repair: "Import the Feature the message names and give it to the provider (`<WardicProvider features={[layout]}>`) or to `makeWard({ features })`.",
|
|
119
|
+
notes: ["#511, ADR-0067 decision 7"],
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
code: "WARDIC_HOOK_WARD_IN_WARDREF",
|
|
123
|
+
group: "Refs and spread",
|
|
124
|
+
summary: "A ward `createWard` made was given to a component's `wardRef`.",
|
|
125
|
+
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.",
|
|
126
|
+
repair: "Spread the ward on the element (`{...ward}`), or on a component that forwards its `ref`.",
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
code: "WARDIC_REF_NOT_FORWARDED",
|
|
130
|
+
group: "Refs and spread",
|
|
131
|
+
summary: "A component wrapped by `w.create` or `wardic.create` didn't forward its `ref`.",
|
|
132
|
+
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.",
|
|
133
|
+
repair: "Pass `props.ref` to the element the component renders, or spread its props on that element whole.",
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
code: "WARDIC_WARDREF_CONFLICT",
|
|
137
|
+
group: "Refs and spread",
|
|
138
|
+
summary: "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.",
|
|
139
|
+
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.",
|
|
140
|
+
repair: "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`.",
|
|
141
|
+
notes: ["#349, #398"],
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
code: "WARDIC_WARD_MADE_IN_SPREAD",
|
|
145
|
+
group: "Refs and spread",
|
|
146
|
+
summary: "`ward(config)` was called inside a spread, so a new ward was made each time the element's props ran.",
|
|
147
|
+
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.",
|
|
148
|
+
repair: "Make the ward once, in the component's body, and spread that: `const card = ward(config)`, then `<div {...card} />`.",
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
code: "WARDIC_RUNE_READ_TOO_EARLY",
|
|
152
|
+
group: "Refs and spread",
|
|
153
|
+
summary: "A function rune used a member of its ward in the rune's body, before the ward was made.",
|
|
154
|
+
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.",
|
|
155
|
+
repair: "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.",
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
code: "WARDIC_PARENT_WITHOUT_VARIANTS",
|
|
159
|
+
group: "Follow, variants and config",
|
|
160
|
+
summary: "`ward(config, { parent })` named a parent that carries no variants.",
|
|
161
|
+
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 }`.",
|
|
162
|
+
repair: "Render the child inside that ward's element, where it joins through the tree, or put the variants in the parent's `ward({ … })`.",
|
|
163
|
+
notes: ["#398"],
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
code: "WARDIC_CONFIG_AS_ACCESSOR",
|
|
167
|
+
group: "Follow, variants and config",
|
|
168
|
+
summary: "A whole config was given as one accessor (`ward(() => ({ … }))`).",
|
|
169
|
+
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.",
|
|
170
|
+
repair: "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.",
|
|
171
|
+
notes: ["#259"],
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
code: "WARDIC_KEY_LOADING_AT_SETUP",
|
|
175
|
+
group: "Follow, variants and config",
|
|
176
|
+
summary: "A key was still loading when its ward was made.",
|
|
177
|
+
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.",
|
|
178
|
+
repair: "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.",
|
|
179
|
+
notes: ["#257 item 1"],
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
code: "WARDIC_ACCESSOR_RETURNED_PROMISE",
|
|
183
|
+
group: "Follow, variants and config",
|
|
184
|
+
summary: "A key's accessor returned a promise.",
|
|
185
|
+
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.",
|
|
186
|
+
repair: "Give the key an async memo, `key: createMemo(() => …)`, which fetches once and holds the value it resolves to.",
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
code: "WARDIC_RUNE_WITH_INVALID",
|
|
190
|
+
group: "Follow, variants and config",
|
|
191
|
+
summary: "`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.",
|
|
192
|
+
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.",
|
|
193
|
+
repair: "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.",
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
code: "WARDIC_REORDER_REF_NOT_FUNCTION",
|
|
197
|
+
group: "Grips and reorder",
|
|
198
|
+
summary: "`<Reorder.Group>`'s `groupRef` or `<Reorder.Item>`'s `wardRef` was given a group or ward made beforehand.",
|
|
199
|
+
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.",
|
|
200
|
+
repair: "Give the config as the component's props, and a function to `groupRef` or `wardRef` to be handed what it makes: `wardRef={(row) => …}`.",
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
code: "WARDIC_REORDER_ITEM_OUTSIDE_GROUP",
|
|
204
|
+
group: "Grips and reorder",
|
|
205
|
+
summary: "A `<Reorder.Item>` was rendered outside a `<Reorder.Group>`, or a `<Reorder.Grip>` outside a `<Reorder.Item>`.",
|
|
206
|
+
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.",
|
|
207
|
+
repair: "Render each item among its group's children, and each grip among its item's.",
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
code: "WARDIC_WARD_WITHOUT_OWNER",
|
|
211
|
+
group: "Refs and spread",
|
|
212
|
+
summary: "`createWard` was called with no owner: outside a component or a root, at a module's top or in an event handler.",
|
|
213
|
+
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.",
|
|
214
|
+
repair: "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.",
|
|
215
|
+
example: {
|
|
216
|
+
before: 'import { createWard } from "@wardic/solid/hooks"\n\nconst card = createWard({ animate: { opacity: 1 } })\n\nexport const Card = () => <div {...card} />',
|
|
217
|
+
after: 'import { createWard } from "@wardic/solid/hooks"\n\nexport const Card = () => {\n const card = createWard({ animate: { opacity: 1 } })\n return <div {...card} />\n}',
|
|
218
|
+
},
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
code: "WARDIC_STYLE_BESIDE_SPREAD",
|
|
222
|
+
group: "Refs and spread",
|
|
223
|
+
summary: "A ward's `style` was replaced: by a `style` beside its spread, or by a component that doesn't pass `props.style` on.",
|
|
224
|
+
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.",
|
|
225
|
+
repair: "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`.",
|
|
226
|
+
example: {
|
|
227
|
+
before: 'import { createWard } from "@wardic/solid/hooks"\n\nexport const Card = () => {\n const card = createWard({ initial: { opacity: 0 }, animate: { opacity: 1 } })\n return <div {...card} style={{ width: "40px" }} />\n}',
|
|
228
|
+
after: 'import { createWard } from "@wardic/solid/hooks"\n\nexport const Card = () => {\n const card = createWard({ initial: { opacity: 0 }, animate: { opacity: 1 } })\n return <div {...card.with({ style: { width: "40px" } })} />\n}',
|
|
229
|
+
},
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
code: "WARDIC_NO_PROVIDER",
|
|
233
|
+
group: "Runtime and page",
|
|
234
|
+
summary: "Something that reads Wardic's runtime (`useWardicRuntime`, `useAnimateLayout`, …) was called with no `<WardicProvider>` above it and no page set up.",
|
|
235
|
+
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.",
|
|
236
|
+
repair: "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.",
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
code: "WARDIC_ENV_ASYNC",
|
|
240
|
+
group: "Runtime and page",
|
|
241
|
+
summary: "The `env` given to a `<WardicProvider>` waits as it builds.",
|
|
242
|
+
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.",
|
|
243
|
+
repair: "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)))`.",
|
|
244
|
+
notes: ["#746"],
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
code: "WARDIC_TRACER_WITHOUT_SPANS",
|
|
248
|
+
group: "Runtime and page",
|
|
249
|
+
summary: "The `env` installs a tracer, but gives no `WardicSpans`, so Wardic opens no spans.",
|
|
250
|
+
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.",
|
|
251
|
+
repair: "Merge `WardicSpans` beside the Environment, `Layer.mergeAll(DomLive, WardicSpans, …)`, or leave the tracer out if Wardic's spans aren't wanted.",
|
|
252
|
+
notes: ["#746, ADR-0067 decision 8"],
|
|
253
|
+
},
|
|
254
|
+
]
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wardic's coded diagnostics on Solid 2 (solid-next, the skill grill's Q6, Q17 and Q21): a broken rule is
|
|
3
|
+
* reported as Solid reports its own. In development it goes on Solid's channel (`OBSERVE.diagnostics`),
|
|
4
|
+
* under the owner it happened in, where `@solidjs/diagnostics`' `captureArtifact` reads it, and it's
|
|
5
|
+
* printed: `[WARDIC_…]` and what happened with its fix, the owners it happened under, and on its code's
|
|
6
|
+
* first report a footer naming its page on next.wardic.dev and its section in the `wardic-diagnostics`
|
|
7
|
+
* skill. Solid's own printer isn't used: its footer names Solid's docs and Solid's skill. A production
|
|
8
|
+
* build has no channel, and reports nothing.
|
|
9
|
+
*
|
|
10
|
+
* @module
|
|
11
|
+
*/
|
|
12
|
+
import * as Diagnostic from "@wardic/core/unstable/Diagnostic"
|
|
13
|
+
import * as Effect from "effect/Effect"
|
|
14
|
+
import * as Layer from "effect/Layer"
|
|
15
|
+
import * as UndefinedOr from "effect/UndefinedOr"
|
|
16
|
+
import { DEV, type DiagnosticCode, type DiagnosticEvent, getOwner, OBSERVE } from "solid-js"
|
|
17
|
+
|
|
18
|
+
/** A Wardic diagnostic's code: `WARDIC_` and what happened, core's, dom's or the binding's own. */
|
|
19
|
+
export type Code = Diagnostic.Code
|
|
20
|
+
|
|
21
|
+
/** Where a code's page is, by the code in lowercase. */
|
|
22
|
+
const DOCS = "https://next.wardic.dev/diagnostics/"
|
|
23
|
+
|
|
24
|
+
/** Where a code's section is in the skill the package ships, by the code in lowercase. */
|
|
25
|
+
const SKILL = "node_modules/@wardic/solid/skills/wardic-diagnostics/SKILL.md#"
|
|
26
|
+
|
|
27
|
+
// Module state (#460, Q7): the codes whose first report has printed the footer, once a page, as Solid's footer
|
|
28
|
+
// is: development's alone, as `report` and `misuse` print nothing else, and a page's for its life.
|
|
29
|
+
const footered = new Set<string>()
|
|
30
|
+
|
|
31
|
+
/** A coded report's first line, what happened and its fix: what a thrown misuse says too. */
|
|
32
|
+
const coded = (code: Code, message: string): string => Diagnostic.line(code, message)
|
|
33
|
+
|
|
34
|
+
/** A code's footer, on its first report alone: its page, and its section in the skill. */
|
|
35
|
+
const footerOf = (code: Code): ReadonlyArray<string> => {
|
|
36
|
+
if (footered.has(code)) return []
|
|
37
|
+
footered.add(code)
|
|
38
|
+
const anchor = code.toLowerCase()
|
|
39
|
+
return [` What it means and how to fix it: ${DOCS}${anchor}`, ` For a coding agent: ${SKILL}${anchor}`]
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** What's printed for `event`: its line, its owners and where, and its code's footer the first time. */
|
|
43
|
+
const printedOf = (code: Code, event: DiagnosticEvent): string =>
|
|
44
|
+
[
|
|
45
|
+
event.message,
|
|
46
|
+
...UndefinedOr.match(event.ownerPath, { onUndefined: () => [], onDefined: (path) => [` in ${path.join(" › ")}`] }),
|
|
47
|
+
...UndefinedOr.match(event.loc, { onUndefined: () => [], onDefined: (loc) => [` at ${loc}`] }),
|
|
48
|
+
...footerOf(code),
|
|
49
|
+
].join("\n")
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* `code` on Solid's channel, under the current owner, at `warn` (Solid prints an `error` with its own
|
|
53
|
+
* footer, which names its docs and its skill), and what's printed for it. Development's alone.
|
|
54
|
+
*/
|
|
55
|
+
const emittedInDev = (code: Code, message: string): string =>
|
|
56
|
+
UndefinedOr.match(OBSERVE, {
|
|
57
|
+
onUndefined: () => coded(code, message),
|
|
58
|
+
// Solid's codes are a closed list: a Wardic one is carried as one of its own.
|
|
59
|
+
onDefined: (observe) =>
|
|
60
|
+
printedOf(code, observe.diagnostics.emit({ code: code as unknown as DiagnosticCode, kind: "render", severity: "warn", message: coded(code, message) }, getOwner())),
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Reports `code` in development, `message` saying what happened and its fix: on Solid's channel, under
|
|
65
|
+
* the current owner, and printed. Nothing in production: under `DEV`, which Solid's production build
|
|
66
|
+
* leaves undefined, so a bundle drops it, the footer's text with it.
|
|
67
|
+
*/
|
|
68
|
+
export const report = (code: Code, message: string): void => {
|
|
69
|
+
if (DEV) console.warn(emittedInDev(code, message))
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* The binding's reporter, for what core and dom report on the runtime it builds (`Diagnostic.report`):
|
|
74
|
+
* on Solid's channel and printed, as the binding's own are. Under no owner: it runs from a fiber.
|
|
75
|
+
*/
|
|
76
|
+
export const reporterLayer: Layer.Layer<never> = Layer.succeed(Diagnostic.Reporter, {
|
|
77
|
+
report: (code, message) => Effect.sync(() => report(code, message)),
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* A misuse that throws: on Solid's channel in development, as {@link report} puts one, and the error to
|
|
82
|
+
* throw, its message `code`'s line, with its owners and its code's footer the first time. In production,
|
|
83
|
+
* the line alone.
|
|
84
|
+
*/
|
|
85
|
+
export const misuse = (code: Code, message: string): Error => {
|
|
86
|
+
if (DEV) return new Error(emittedInDev(code, message))
|
|
87
|
+
return new Error(coded(code, message))
|
|
88
|
+
}
|
package/src/element.tsx
CHANGED
|
@@ -29,6 +29,7 @@ import { identity } from "effect/Function"
|
|
|
29
29
|
import * as UndefinedOr from "effect/UndefinedOr"
|
|
30
30
|
import { type ComponentProps, dynamic, isServer, type JSX, type ValidComponent } from "@solidjs/web"
|
|
31
31
|
import { $PROXY, children, type Component, createEffect, createMemo, createRoot, DEV, omit, runWithOwner, untrack } from "solid-js"
|
|
32
|
+
import { misuse } from "./diagnostics.ts"
|
|
32
33
|
import { unforwardedRefFix, unforwardedRefLine } from "./messages.ts"
|
|
33
34
|
import { MOTION_PROPS_V2 as MOTION_PROPS, type WardicMotionPropsV2 as WardicMotionProps } from "./motion-props.ts"
|
|
34
35
|
import * as VariantTree from "@wardic/core/unstable/VariantTree"
|
|
@@ -215,17 +216,18 @@ export const besideOf = (name: string, props: object, share: WardShare, keys: Re
|
|
|
215
216
|
if (beside.length === 0) return beside
|
|
216
217
|
const twice = setKeysOf(share.config, beside)
|
|
217
218
|
if (twice.length > 0) {
|
|
218
|
-
throw
|
|
219
|
-
|
|
220
|
-
|
|
219
|
+
throw misuse(
|
|
220
|
+
"WARDIC_WARDREF_CONFLICT",
|
|
221
|
+
`${name}: ${listOf(twice)} set both in the ward given to wardRef and on the element. ` + "Set each key in one place: in ward({ … }), or on the element.",
|
|
221
222
|
)
|
|
222
223
|
}
|
|
223
224
|
if (share.carries) {
|
|
224
225
|
const carried = Arr.filter(beside, (key) => NODE_KEYS.has(key))
|
|
225
226
|
if (carried.length > 0) {
|
|
226
|
-
throw
|
|
227
|
+
throw misuse(
|
|
228
|
+
"WARDIC_WARDREF_CONFLICT",
|
|
227
229
|
`${name}: the ward given to wardRef carries its variants (\`variants\` or \`inherit\` in its ward({ … })), so ${listOf(carried)} ` +
|
|
228
|
-
"go there too: its variant node, made where the ward is made, reads them
|
|
230
|
+
"go there too: its variant node, made where the ward is made, reads them. Or leave the variants to the element: " +
|
|
229
231
|
"a ward with neither only listens, and its element's props set its motion.",
|
|
230
232
|
)
|
|
231
233
|
}
|
|
@@ -261,8 +263,9 @@ const checkParent = (name: string, share: WardShare): void => {
|
|
|
261
263
|
const here = useVariantContext()
|
|
262
264
|
if (Bool.or(here === share.parent, Predicate.isUndefined(here))) return
|
|
263
265
|
if (Bool.not(VariantTree.isVariantChild(share.setup))) return
|
|
264
|
-
throw
|
|
265
|
-
|
|
266
|
+
throw misuse(
|
|
267
|
+
"WARDIC_WARDREF_CONFLICT",
|
|
268
|
+
`${name}: the ward in wardRef was made outside its element's variant parent, so it wouldn't inherit from it. ` +
|
|
266
269
|
"Make it with ward(config, { parent }), naming the ward whose element it renders in, or give it `inherit: false` to stand alone.",
|
|
267
270
|
)
|
|
268
271
|
}
|
|
@@ -483,7 +486,7 @@ const tagComponent = (tag: string, routing: string | undefined, forward: boolean
|
|
|
483
486
|
const wardRef = untrack(() => own.wardRef)
|
|
484
487
|
const given = shareOf(wardRef)
|
|
485
488
|
if (Predicate.isNotUndefined(given)) {
|
|
486
|
-
if (madeByTheHooks(given)) throw
|
|
489
|
+
if (madeByTheHooks(given)) throw misuse("WARDIC_HOOK_WARD_IN_WARDREF", hookWardGiven(name))
|
|
487
490
|
const { ward: driving, setup } = drivenWard(name, own, given, { ...kind, tag: routing }, MOTION_PROPS)
|
|
488
491
|
return withProvider(driving, setup, () => <Element {...rest} {...driving.with({ style: own.style })} ref={refsOf(own, [driving])} />)
|
|
489
492
|
}
|
|
@@ -533,7 +536,7 @@ const wrapComponent = (Wrapped: Component<Record<string, unknown>>, routing: str
|
|
|
533
536
|
(elements) => {
|
|
534
537
|
if (Arr.isArrayEmpty(elements)) return
|
|
535
538
|
if (Arr.some(elements, (inside) => Predicate.isNotUndefined(reached) && inside.contains(reached))) return
|
|
536
|
-
throw
|
|
539
|
+
throw misuse("WARDIC_REF_NOT_FORWARDED", unforwardedRefMessage(name))
|
|
537
540
|
},
|
|
538
541
|
CLIENT_ONLY,
|
|
539
542
|
)
|
|
@@ -543,7 +546,7 @@ const wrapComponent = (Wrapped: Component<Record<string, unknown>>, routing: str
|
|
|
543
546
|
const wardRef = untrack(() => own.wardRef)
|
|
544
547
|
const given = shareOf(wardRef)
|
|
545
548
|
if (Predicate.isNotUndefined(given)) {
|
|
546
|
-
if (madeByTheHooks(given)) throw
|
|
549
|
+
if (madeByTheHooks(given)) throw misuse("WARDIC_HOOK_WARD_IN_WARDREF", hookWardGiven(name))
|
|
547
550
|
const { ward: driving, setup } = drivenWard(name, own, given, { ...kind, defaultsOnElement: true, tag: routing }, MOTION_PROPS)
|
|
548
551
|
return withProvider(driving, setup, () => checked(() => <Element {...rest} {...driving.with({ style: own.style })} ref={refsOf(own, [driving, seen])} />))
|
|
549
552
|
}
|
package/src/frame-effect.tsx
CHANGED
|
@@ -53,7 +53,7 @@ const slotOf = (runtime: WardicRuntime): Slot => {
|
|
|
53
53
|
const known = SLOTS.get(runtime)
|
|
54
54
|
if (Predicate.isNotUndefined(known)) return known
|
|
55
55
|
const scope = OwnerScope.open(runtime)
|
|
56
|
-
const report = (defect: unknown): void => void runtime.runFork(Report.
|
|
56
|
+
const report = (defect: unknown): void => void runtime.runFork(Report.callbackFailed("wardic.createFrameEffect: an apply failed", Cause.die(defect)))
|
|
57
57
|
const effects = runtime.runSync(FrameEffects.onFrameLoop(report).pipe(Scope.provide(scope)))
|
|
58
58
|
const made: Slot = { effects, scope, live: 0 }
|
|
59
59
|
SLOTS.set(runtime, made)
|
package/src/gesture-callbacks.ts
CHANGED
|
@@ -38,7 +38,7 @@ export const gestureCallbacksOf = (runtime: WardicRuntime, id: string, config: (
|
|
|
38
38
|
config,
|
|
39
39
|
invoke: (handler, args) => (handler as Called)(...args),
|
|
40
40
|
report: (name, defect) => {
|
|
41
|
-
runtime.runFork(Report.
|
|
41
|
+
runtime.runFork(Report.callbackFailed(`wardic.gesture: ${name} failed`, Cause.die(defect)).pipe(Effect.annotateLogs({ id })))
|
|
42
42
|
},
|
|
43
43
|
// `onDragEnd` and `onPanEnd` told how each ended (#1042).
|
|
44
44
|
tellsEndedBy: true,
|
package/src/hooks/drag.ts
CHANGED
|
@@ -25,6 +25,7 @@ import * as InputSource from "@wardic/core/InputSource"
|
|
|
25
25
|
import type * as Point from "@wardic/core/Point"
|
|
26
26
|
import type * as ProjectionSystem from "@wardic/dom/ProjectionSystem"
|
|
27
27
|
import * as Style from "@wardic/dom/Style"
|
|
28
|
+
import { report } from "../diagnostics.ts"
|
|
28
29
|
import type { WardicServices } from "../runtime.ts"
|
|
29
30
|
import * as Bool from "effect/Boolean"
|
|
30
31
|
import * as Effect from "effect/Effect"
|
|
@@ -550,7 +551,7 @@ export const createGrip = (row: DraggingWard): RuneConfig => {
|
|
|
550
551
|
|
|
551
552
|
/** A grip of a ward that doesn't drag: development says so, and it drives nothing (Q14, Q20). */
|
|
552
553
|
const notDragging = (): RuneConfig => {
|
|
553
|
-
if (DEV)
|
|
554
|
+
if (DEV) report("WARDIC_GRIP_ROW_DOESNT_DRAG", NOT_DRAGGING)
|
|
554
555
|
return NO_GRIP
|
|
555
556
|
}
|
|
556
557
|
|
|
@@ -593,7 +594,7 @@ export const GRIP_OUTSIDE = "createGrip(row): this grip isn't inside its row's e
|
|
|
593
594
|
const warnIfOutside = (site: Site, subject: HTMLElement): void => {
|
|
594
595
|
if (DEV) {
|
|
595
596
|
UndefinedOr.map(site.at, (at) => {
|
|
596
|
-
if (Bool.not(at.element.contains(subject)))
|
|
597
|
+
if (Bool.not(at.element.contains(subject))) report("WARDIC_GRIP_OUTSIDE_ROW", GRIP_OUTSIDE)
|
|
597
598
|
})
|
|
598
599
|
}
|
|
599
600
|
}
|
|
@@ -656,7 +657,7 @@ export const NO_DRAG = "createWard(...runes): a rune listens to `ward.drag`, but
|
|
|
656
657
|
export const warnIfUndragged = (site: Site, drags: boolean): void => {
|
|
657
658
|
if (Bool.or(warned, Bool.or(drags, Bool.not(site.listened)))) return
|
|
658
659
|
warned = true
|
|
659
|
-
|
|
660
|
+
report("WARDIC_DRAG_NOT_GIVEN", NO_DRAG)
|
|
660
661
|
}
|
|
661
662
|
|
|
662
663
|
/** A `drag` value as a drag's axis: `"x"`, `"y"`, or whether it drags freely. */
|
|
@@ -29,6 +29,7 @@ import type { PopAnchors, PresenceMode } from "@wardic/dom/unstable/PresenceCont
|
|
|
29
29
|
import * as Predicate from "effect/Predicate"
|
|
30
30
|
import { DEV, getOwner, onCleanup } from "solid-js"
|
|
31
31
|
import { AnimatePresence } from "../presence.tsx"
|
|
32
|
+
import { report } from "../diagnostics.ts"
|
|
32
33
|
import { createPresence as makeRef, ownPresenceHandle, type Presence as Handle } from "../presence-handle.ts"
|
|
33
34
|
import type { PopCorner } from "./rune.ts"
|
|
34
35
|
import { popAnchorsOf } from "./ward.ts"
|
|
@@ -125,7 +126,7 @@ export const createPresenceScope = (options: PresenceScopeOptions = {}): Presenc
|
|
|
125
126
|
if (Predicate.isNotNull(getOwner())) onCleanup(() => void (live -= 1))
|
|
126
127
|
if (!DEV || warned || live < 2) return
|
|
127
128
|
warned = true
|
|
128
|
-
|
|
129
|
+
report("WARDIC_PRESENCE_SCOPE_REUSED", ONE_BOUNDARY)
|
|
129
130
|
}
|
|
130
131
|
// Read where the boundary reads each: `options` may be a component's props.
|
|
131
132
|
const within = (build: () => JSX.Element): JSX.Element => {
|
|
@@ -29,6 +29,7 @@ import { createGrip, type DraggingWard } from "./drag.ts"
|
|
|
29
29
|
import type { HookWardOf } from "./ward.ts"
|
|
30
30
|
import type { ReorderList, ReorderSource } from "./reorder.ts"
|
|
31
31
|
import type { Rune, RuneConfig } from "./rune.ts"
|
|
32
|
+
import { misuse } from "../diagnostics.ts"
|
|
32
33
|
|
|
33
34
|
/** What makes a group's list: `createReorder`, as an app has it. */
|
|
34
35
|
export type ListMaker = (source: ReorderSource<unknown>) => ListOf
|
|
@@ -255,7 +256,7 @@ export const reorderElementsOf = (elements: Readonly<Record<string, Component<Re
|
|
|
255
256
|
}
|
|
256
257
|
const list = listOf(source)
|
|
257
258
|
const groupRef = untrack(() => own.groupRef)
|
|
258
|
-
if (isGroup(groupRef)) throw
|
|
259
|
+
if (isGroup(groupRef)) throw misuse("WARDIC_REORDER_REF_NOT_FUNCTION", GIVEN_GROUP)
|
|
259
260
|
if (Predicate.isFunction(groupRef)) groupRef(list)
|
|
260
261
|
const Element = UndefinedOr.getOrThrow(elements[UndefinedOr.match(untrack(() => own.as), { onUndefined: () => "ul", onDefined: identity })])
|
|
261
262
|
const rest = omit(props, ...GROUP_KEPT)
|
|
@@ -268,14 +269,15 @@ export const reorderElementsOf = (elements: Readonly<Record<string, Component<Re
|
|
|
268
269
|
|
|
269
270
|
const Item = (props: Record<string, unknown>): JSX.Element => {
|
|
270
271
|
const list = useContext(ListContext)
|
|
271
|
-
if (Predicate.isNull(list))
|
|
272
|
+
if (Predicate.isNull(list))
|
|
273
|
+
throw misuse("WARDIC_REORDER_ITEM_OUTSIDE_GROUP", "Reorder.Item must be a child of Reorder.Group: render each item inside its group's children.")
|
|
272
274
|
const own = props as unknown as ItemProps
|
|
273
275
|
const Element = plainOf(UndefinedOr.match(untrack(() => own.as), { onUndefined: () => "li", onDefined: identity }))
|
|
274
276
|
// Its row a plain ward of its group's behaviour and its own props (probe: behaviour-runes, Q12): what
|
|
275
277
|
// an app writes, `createWard(list.item(value), ...)`.
|
|
276
278
|
const row = untrack(() => createWard(list.item(own.value), itemRuneOf(props) as RuneConfig)) as object
|
|
277
279
|
const wardRef = untrack(() => own.wardRef)
|
|
278
|
-
if (isWard(wardRef)) throw
|
|
280
|
+
if (isWard(wardRef)) throw misuse("WARDIC_REORDER_REF_NOT_FUNCTION", GIVEN_WARD)
|
|
279
281
|
if (Predicate.isFunction(wardRef)) wardRef(row)
|
|
280
282
|
// Its spread's props, as a spread of it reads them: called with nothing, as Solid's `merge` calls a
|
|
281
283
|
// ward it spreads (#495), for the keyboard attributes and the drag's style a row's binding gives
|
|
@@ -306,7 +308,7 @@ export const reorderElementsOf = (elements: Readonly<Record<string, Component<Re
|
|
|
306
308
|
*/
|
|
307
309
|
const Grip = (props: Record<string, unknown>): JSX.Element => {
|
|
308
310
|
const row = useContext(RowContext)
|
|
309
|
-
if (Predicate.isNull(row)) throw
|
|
311
|
+
if (Predicate.isNull(row)) throw misuse("WARDIC_REORDER_ITEM_OUTSIDE_GROUP", "Reorder.Grip must be inside a Reorder.Item: render it among its item's children.")
|
|
310
312
|
const own = props as unknown as { readonly as?: string | undefined; readonly ref?: unknown }
|
|
311
313
|
const tag = UndefinedOr.match(untrack(() => own.as), { onUndefined: () => "button", onDefined: identity })
|
|
312
314
|
const Element = plainOf(tag)
|
package/src/hooks/rune.ts
CHANGED
|
@@ -45,6 +45,7 @@ import * as UndefinedOr from "effect/UndefinedOr"
|
|
|
45
45
|
import { $PROXY, DEV, untrack } from "solid-js"
|
|
46
46
|
import type { Accessor } from "solid-js"
|
|
47
47
|
import type { AnyWard, WardConfig } from "../ward.tsx"
|
|
48
|
+
import { misuse } from "../diagnostics.ts"
|
|
48
49
|
import type { HookWard } from "./ward.ts"
|
|
49
50
|
import type { Drags, WardDrag } from "./drag.ts"
|
|
50
51
|
|
|
@@ -442,10 +443,10 @@ const isBareFunction = (rune: object): boolean => {
|
|
|
442
443
|
* or where the API would hide one of its keys.
|
|
443
444
|
*/
|
|
444
445
|
const refusedInDevelopment = (rune: object, api: object): void => {
|
|
445
|
-
if (RUNE_API in rune) throw
|
|
446
|
-
if (isBareFunction(rune)) throw
|
|
446
|
+
if (RUNE_API in rune) throw misuse("WARDIC_RUNE_WITH_INVALID", SECOND_API)
|
|
447
|
+
if (isBareFunction(rune)) throw misuse("WARDIC_RUNE_WITH_INVALID", BARE_FUNCTION)
|
|
447
448
|
const clash = Arr.findFirst(Object.keys(api), isOwnKeyOf(rune))
|
|
448
|
-
if (Option.isSome(clash)) throw
|
|
449
|
+
if (Option.isSome(clash)) throw misuse("WARDIC_RUNE_WITH_INVALID", clashOf(clash.value))
|
|
449
450
|
}
|
|
450
451
|
|
|
451
452
|
/**
|