@wardic/solid 1.1.2 → 1.1.3

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 (144) hide show
  1. package/dist/browser/batch-reorder-group.js +2 -5
  2. package/dist/browser/batch-reorder-group.js.map +1 -1
  3. package/dist/browser/batch-reorder.js +4 -15
  4. package/dist/browser/batch-reorder.js.map +1 -1
  5. package/dist/browser/create-ward.js +6 -15
  6. package/dist/browser/create-ward.js.map +1 -1
  7. package/dist/browser/create-wardic.js +1 -1
  8. package/dist/browser/create-wardic.js.map +1 -1
  9. package/dist/browser/gesture-callbacks.js +11 -164
  10. package/dist/browser/gesture-callbacks.js.map +1 -1
  11. package/dist/browser/index.js +1 -1
  12. package/dist/browser/provider.js +1 -5
  13. package/dist/browser/provider.js.map +1 -1
  14. package/dist/browser/reorder.js +8 -22
  15. package/dist/browser/reorder.js.map +1 -1
  16. package/dist/browser/unstable/v2/batch-reorder-group.js +2 -5
  17. package/dist/browser/unstable/v2/batch-reorder-group.js.map +1 -1
  18. package/dist/browser/unstable/v2/bridge.js +5 -3
  19. package/dist/browser/unstable/v2/bridge.js.map +1 -1
  20. package/dist/browser/unstable/v2/create-wardic.js +1 -1
  21. package/dist/browser/unstable/v2/create-wardic.js.map +1 -1
  22. package/dist/browser/unstable/v2/flights.js +7 -4
  23. package/dist/browser/unstable/v2/flights.js.map +1 -1
  24. package/dist/browser/unstable/v2/provider.js +2 -6
  25. package/dist/browser/unstable/v2/provider.js.map +1 -1
  26. package/dist/browser/unstable/v2/reorder.js +3 -6
  27. package/dist/browser/unstable/v2/reorder.js.map +1 -1
  28. package/dist/browser/unstable/v2/solid-reactivity.js +10 -1
  29. package/dist/browser/unstable/v2/solid-reactivity.js.map +1 -1
  30. package/dist/browser/unstable/v2/ward.js +25 -10
  31. package/dist/browser/unstable/v2/ward.js.map +1 -1
  32. package/dist/server/batch-reorder-group.js +2 -5
  33. package/dist/server/batch-reorder-group.js.map +1 -1
  34. package/dist/server/batch-reorder.js +4 -15
  35. package/dist/server/batch-reorder.js.map +1 -1
  36. package/dist/server/create-ward.js +6 -15
  37. package/dist/server/create-ward.js.map +1 -1
  38. package/dist/server/create-wardic.js +1 -1
  39. package/dist/server/create-wardic.js.map +1 -1
  40. package/dist/server/gesture-callbacks.js +11 -164
  41. package/dist/server/gesture-callbacks.js.map +1 -1
  42. package/dist/server/index.js +1 -1
  43. package/dist/server/provider.js +1 -5
  44. package/dist/server/provider.js.map +1 -1
  45. package/dist/server/reorder.js +8 -22
  46. package/dist/server/reorder.js.map +1 -1
  47. package/dist/server/unstable/v2/batch-reorder-group.js +2 -5
  48. package/dist/server/unstable/v2/batch-reorder-group.js.map +1 -1
  49. package/dist/server/unstable/v2/bridge.js +5 -3
  50. package/dist/server/unstable/v2/bridge.js.map +1 -1
  51. package/dist/server/unstable/v2/create-wardic.js +1 -1
  52. package/dist/server/unstable/v2/create-wardic.js.map +1 -1
  53. package/dist/server/unstable/v2/flights.js +7 -4
  54. package/dist/server/unstable/v2/flights.js.map +1 -1
  55. package/dist/server/unstable/v2/provider.js +2 -6
  56. package/dist/server/unstable/v2/provider.js.map +1 -1
  57. package/dist/server/unstable/v2/reorder.js +3 -6
  58. package/dist/server/unstable/v2/reorder.js.map +1 -1
  59. package/dist/server/unstable/v2/solid-reactivity.js +10 -1
  60. package/dist/server/unstable/v2/solid-reactivity.js.map +1 -1
  61. package/dist/server/unstable/v2/ward.js +25 -10
  62. package/dist/server/unstable/v2/ward.js.map +1 -1
  63. package/dist/solid/batch-reorder-group.jsx +2 -2
  64. package/dist/solid/batch-reorder-group.jsx.map +1 -1
  65. package/dist/solid/batch-reorder.d.ts +1 -4
  66. package/dist/solid/batch-reorder.d.ts.map +1 -1
  67. package/dist/solid/batch-reorder.js +4 -9
  68. package/dist/solid/batch-reorder.js.map +1 -1
  69. package/dist/solid/create-ward.d.ts.map +1 -1
  70. package/dist/solid/create-ward.jsx +6 -15
  71. package/dist/solid/create-ward.jsx.map +1 -1
  72. package/dist/solid/create-wardic.jsx +1 -1
  73. package/dist/solid/create-wardic.jsx.map +1 -1
  74. package/dist/solid/gesture-callbacks.d.ts +10 -37
  75. package/dist/solid/gesture-callbacks.d.ts.map +1 -1
  76. package/dist/solid/gesture-callbacks.js +11 -178
  77. package/dist/solid/gesture-callbacks.js.map +1 -1
  78. package/dist/solid/index.d.ts +1 -1
  79. package/dist/solid/index.jsx +1 -1
  80. package/dist/solid/provider.d.ts.map +1 -1
  81. package/dist/solid/provider.jsx +1 -5
  82. package/dist/solid/provider.jsx.map +1 -1
  83. package/dist/solid/reorder.d.ts.map +1 -1
  84. package/dist/solid/reorder.jsx +7 -15
  85. package/dist/solid/reorder.jsx.map +1 -1
  86. package/dist/solid/unstable/v2/batch-reorder-group.jsx +2 -2
  87. package/dist/solid/unstable/v2/batch-reorder-group.jsx.map +1 -1
  88. package/dist/solid/unstable/v2/bridge.d.ts +4 -2
  89. package/dist/solid/unstable/v2/bridge.d.ts.map +1 -1
  90. package/dist/solid/unstable/v2/bridge.jsx +5 -3
  91. package/dist/solid/unstable/v2/bridge.jsx.map +1 -1
  92. package/dist/solid/unstable/v2/create-wardic.jsx +1 -1
  93. package/dist/solid/unstable/v2/create-wardic.jsx.map +1 -1
  94. package/dist/solid/unstable/v2/flights.d.ts +5 -2
  95. package/dist/solid/unstable/v2/flights.d.ts.map +1 -1
  96. package/dist/solid/unstable/v2/flights.js +7 -4
  97. package/dist/solid/unstable/v2/flights.js.map +1 -1
  98. package/dist/solid/unstable/v2/provider.d.ts.map +1 -1
  99. package/dist/solid/unstable/v2/provider.jsx +2 -4
  100. package/dist/solid/unstable/v2/provider.jsx.map +1 -1
  101. package/dist/solid/unstable/v2/reorder.jsx +3 -3
  102. package/dist/solid/unstable/v2/reorder.jsx.map +1 -1
  103. package/dist/solid/unstable/v2/solid-reactivity.d.ts +7 -0
  104. package/dist/solid/unstable/v2/solid-reactivity.d.ts.map +1 -1
  105. package/dist/solid/unstable/v2/solid-reactivity.js +10 -1
  106. package/dist/solid/unstable/v2/solid-reactivity.js.map +1 -1
  107. package/dist/solid/unstable/v2/ward.d.ts.map +1 -1
  108. package/dist/solid/unstable/v2/ward.jsx +26 -10
  109. package/dist/solid/unstable/v2/ward.jsx.map +1 -1
  110. package/package.json +11 -11
  111. package/src/batch-reorder-group.tsx +2 -2
  112. package/src/batch-reorder.ts +4 -10
  113. package/src/create-ward.tsx +6 -16
  114. package/src/create-wardic.tsx +1 -1
  115. package/src/gesture-callbacks.ts +21 -190
  116. package/src/index.tsx +1 -1
  117. package/src/provider.tsx +1 -5
  118. package/src/reorder.tsx +7 -19
  119. package/src/unstable/v2/batch-reorder-group.tsx +2 -2
  120. package/src/unstable/v2/bridge.tsx +5 -3
  121. package/src/unstable/v2/create-wardic.tsx +1 -1
  122. package/src/unstable/v2/flights.ts +8 -5
  123. package/src/unstable/v2/provider.tsx +2 -3
  124. package/src/unstable/v2/reorder.tsx +3 -3
  125. package/src/unstable/v2/solid-reactivity.ts +12 -1
  126. package/src/unstable/v2/ward.tsx +25 -10
  127. package/dist/browser/instance-features.js +0 -66
  128. package/dist/browser/instance-features.js.map +0 -1
  129. package/dist/browser/reorder-input.js +0 -117
  130. package/dist/browser/reorder-input.js.map +0 -1
  131. package/dist/server/instance-features.js +0 -66
  132. package/dist/server/instance-features.js.map +0 -1
  133. package/dist/server/reorder-input.js +0 -117
  134. package/dist/server/reorder-input.js.map +0 -1
  135. package/dist/solid/instance-features.d.ts +0 -7
  136. package/dist/solid/instance-features.d.ts.map +0 -1
  137. package/dist/solid/instance-features.js +0 -63
  138. package/dist/solid/instance-features.js.map +0 -1
  139. package/dist/solid/reorder-input.d.ts +0 -43
  140. package/dist/solid/reorder-input.d.ts.map +0 -1
  141. package/dist/solid/reorder-input.js +0 -113
  142. package/dist/solid/reorder-input.js.map +0 -1
  143. package/src/instance-features.ts +0 -76
  144. package/src/reorder-input.ts +0 -140
@@ -1,9 +1,10 @@
1
1
  /**
2
2
  * Solid 1's gesture callbacks (#273, ADR-0047): Motion's `onHoverStart`, `onTap`, `onDragEnd` and the
3
- * rest, told from the recognizers' events and the drag track's samples. Motion's `(event, info)`: the
4
- * platform's own event core carried through (`raw`), then the info (dom's `unstable/GestureInfo`), its point in
5
- * the viewport. Each is read from the config when it's called, at the event. One that throws is
6
- * reported (`wardic.gesture: onTap failed`), and the gesture goes on.
3
+ * rest, told from the recognizers' events and the drag track's samples by dom's gesture teller
4
+ * (`unstable/GestureFeatures`, #793): Motion's `(event, info)`, the platform's own event core carried
5
+ * through (`raw`), then the info, its point in the viewport. Each is read from the config when it's
6
+ * called, at the event, and called as the function it is. One that throws is reported
7
+ * (`wardic.gesture: onTap failed`), and the gesture goes on.
7
8
  *
8
9
  * Which gestures an element runs follows Motion's features (`definitions.ts:5-24` @ `16c6122`): the
9
10
  * hover recognizer once `whileHover`, `onHoverStart` or `onHoverEnd` is set, the press recognizer once
@@ -11,202 +12,32 @@
11
12
  *
12
13
  * @module
13
14
  */
14
- import type * as Drag from "@wardic/core/Drag"
15
- import type * as DragRecognizer from "@wardic/core/DragRecognizer"
16
15
  import type * as Recognizer from "@wardic/core/Recognizer"
17
16
  import * as Report from "@wardic/dom/Report"
18
- import * as Bool from "effect/Boolean"
19
17
  import * as Cause from "effect/Cause"
20
18
  import * as Effect from "effect/Effect"
21
- import * as Match from "effect/Match"
22
- import * as Predicate from "effect/Predicate"
23
- import * as UndefinedOr from "effect/UndefinedOr"
24
19
  import type * as WardConfig from "@wardic/dom/unstable/WardConfig"
25
- import * as GestureInfo from "@wardic/dom/unstable/GestureInfo"
20
+ import * as GestureFeatures from "@wardic/dom/unstable/GestureFeatures"
26
21
  import type { WardicRuntime } from "./runtime.ts"
27
22
 
28
- /**
29
- * Every key the `wants*` below read (#525): an element given none of them, its keys fixed, can never
30
- * want a gesture, so it starts no computation to watch for one. `gesture-keys.ssr.test.tsx` checks
31
- * each of them turns its gesture on.
32
- */
33
- export const GESTURE_KEYS = [
34
- "whileHover",
35
- "onHoverStart",
36
- "onHoverEnd",
37
- "whileTap",
38
- "onTap",
39
- "onTapStart",
40
- "onTapCancel",
41
- "onPan",
42
- "onPanStart",
43
- "onPanSessionStart",
44
- "onPanEnd",
45
- "whileInView",
46
- "onViewportEnter",
47
- "onViewportLeave",
48
- "whileFocus",
49
- ] as const satisfies ReadonlyArray<keyof WardConfig.WardConfig>
50
-
51
- /**
52
- * Whether `config` runs the hover recognizer (Motion's hover feature). Read at every config change of
53
- * an element that doesn't run it yet: statement `if`s, no array (ADR-0025).
54
- */
55
- export const wantsHover = (config: WardConfig.WardConfig): boolean => {
56
- if (Predicate.isNotUndefined(config.whileHover)) return true
57
- if (Predicate.isNotUndefined(config.onHoverStart)) return true
58
- return Predicate.isNotUndefined(config.onHoverEnd)
59
- }
23
+ // The wanted-gesture predicates and the keys they read are dom's (#793): every binding's gesture start reads them.
24
+ export { GESTURE_KEYS, wantsFocus, wantsHover, wantsInView, wantsPan, wantsPress } from "@wardic/dom/unstable/GestureFeatures"
60
25
 
61
- /** Whether `config` runs the press recognizer (Motion's tap feature): as {@link wantsHover}. */
62
- export const wantsPress = (config: WardConfig.WardConfig): boolean => {
63
- if (Predicate.isNotUndefined(config.whileTap)) return true
64
- if (Predicate.isNotUndefined(config.onTap)) return true
65
- if (Predicate.isNotUndefined(config.onTapStart)) return true
66
- return Predicate.isNotUndefined(config.onTapCancel)
67
- }
26
+ /** Motion's `viewport` as core's in-view options (#273): its root read now, when the recognizer starts. dom's, over Solid's accessor root. */
27
+ export const inViewOptionsOf = (viewport: WardConfig.WardicViewport | undefined): Recognizer.InViewOptions => GestureFeatures.inViewOptionsOf(viewport)
68
28
 
69
- /** Whether `config` runs the pan recognizer (Motion's pan feature, #273): as {@link wantsHover}. */
70
- export const wantsPan = (config: WardConfig.WardConfig): boolean => {
71
- if (Predicate.isNotUndefined(config.onPan)) return true
72
- if (Predicate.isNotUndefined(config.onPanStart)) return true
73
- if (Predicate.isNotUndefined(config.onPanSessionStart)) return true
74
- return Predicate.isNotUndefined(config.onPanEnd)
75
- }
76
-
77
- /** Whether `config` runs the in-view recognizer (Motion's inView feature, #273): `whileInView` or a viewport callback. */
78
- export const wantsInView = (config: WardConfig.WardConfig): boolean => {
79
- if (Predicate.isNotUndefined(config.whileInView)) return true
80
- if (Predicate.isNotUndefined(config.onViewportEnter)) return true
81
- return Predicate.isNotUndefined(config.onViewportLeave)
82
- }
83
-
84
- /** Whether `config` runs the focus recognizer (Motion's focus feature, #273): `whileFocus`. */
85
- export const wantsFocus = (config: WardConfig.WardConfig): boolean => Predicate.isNotUndefined(config.whileFocus)
86
-
87
- /** Motion's `amount` as a share of the element: `"some"` any of it, `"all"` all of it. */
88
- const amountOf = (amount: "some" | "all" | number | undefined): number | undefined =>
89
- Match.value(amount).pipe(
90
- Match.when("some", () => 0),
91
- Match.when("all", () => 1),
92
- Match.orElse((share) => share),
93
- )
94
-
95
- /** Motion's `viewport` as core's in-view options (#273): its root read now, when the recognizer starts. */
96
- export const inViewOptionsOf = (viewport: WardConfig.WardicViewport | undefined): Recognizer.InViewOptions =>
97
- UndefinedOr.match(viewport, {
98
- onUndefined: () => ({}),
99
- onDefined: (v) => ({
100
- once: v.once,
101
- margin: v.margin,
102
- amount: amountOf(v.amount),
103
- ...UndefinedOr.match(v.root, { onUndefined: () => ({}), onDefined: (root) => ({ root: root() }) }),
104
- }),
105
- })
29
+ /** What tells an element's gestures to its config's callbacks: dom's teller. */
30
+ export type GestureCallbacks = GestureFeatures.GestureTeller
106
31
 
107
- /** What tells an element's gestures to its config's callbacks. */
108
- export interface GestureCallbacks {
109
- readonly hovered: (edge: Recognizer.Edge) => void
110
- readonly pressed: (press: Recognizer.PressEvent, element: Element) => void
111
- readonly dragged: (sample: Drag.Sample) => void
112
- /** The drag's release came to rest on its own. */
113
- readonly released: () => void
114
- readonly panned: (sample: DragRecognizer.PanSample) => void
115
- /** An in-view edge: `onViewportEnter` or `onViewportLeave`, with the platform's entry. */
116
- readonly viewed: (edge: Recognizer.ViewEdge) => void
117
- }
118
-
119
- /** Each press phase's callback: a press a drag took over has none (Motion tells neither). */
120
- const PRESS_CALLBACK = { start: "onTapStart", tap: "onTap", cancel: "onTapCancel", dragged: undefined } as const
121
-
122
- /** Each drag phase's callback, `onDrag` aside. */
123
- const DRAG_CALLBACK = { start: "onDragStart", move: undefined, end: "onDragEnd" } as const
124
-
125
- /** Each pan phase's callback past its session's start, `onPan` aside. */
126
- const PAN_CALLBACK = { start: "onPanStart", move: undefined, end: "onPanEnd" } as const
127
-
128
- /** A drag's or a pan's start or end callback. */
129
- type MovementCallback = "onDragStart" | "onDragEnd" | "onPanStart" | "onPanEnd"
32
+ /** A callback of Solid 1's config: a function of the event and the info. */
33
+ type Called = (...args: ReadonlyArray<unknown>) => void
130
34
 
131
35
  /** An element's callers, reading `config` at each call; `id` names it in a report. */
132
- export const gestureCallbacksOf = (runtime: WardicRuntime, id: string, config: () => WardConfig.WardConfig): GestureCallbacks => {
133
- // The per-move callbacks whose last call threw (#257 item 4): a run of throws reports at its
134
- // first, so one that throws at every move logs once; a call that returns ends the run.
135
- let failing: Set<string> | undefined
136
- /** Report the app's `name` threw `defect`. */
137
- const report = (name: string, defect: unknown): void => {
138
- runtime.runFork(Report.failure(`wardic.gesture: ${name} failed`, Cause.die(defect)).pipe(Effect.annotateLogs({ id })))
139
- }
140
- /** Call the app's `name`, reported if it throws. */
141
- const call = <Args extends ReadonlyArray<unknown>>(name: string, callback: ((...args: Args) => void) | undefined, ...args: Args): void => {
142
- if (Predicate.isUndefined(callback)) return
143
- try {
144
- callback(...args)
145
- } catch (defect) {
146
- report(name, defect)
147
- }
148
- }
149
- /** Call `onDrag` or `onPan`, at every move: a run of throws is reported at its first. */
150
- const callPerMove = <Args extends ReadonlyArray<unknown>>(name: string, callback: ((...args: Args) => void) | undefined, ...args: Args): void => {
151
- if (Predicate.isUndefined(callback)) return
152
- try {
153
- callback(...args)
154
- UndefinedOr.map(failing, (names) => names.delete(name))
155
- } catch (defect) {
156
- if (Predicate.isUndefined(failing)) failing = new Set()
157
- if (failing.has(name)) return
158
- failing.add(name)
159
- report(name, defect)
160
- }
161
- }
162
- /**
163
- * A drag's or a pan's sample, past a pan's session's start: its start's or its end's callback
164
- * (`named`), then `every`, which hears its start and each move (Motion's pan session runs `onMove`
165
- * at the start too). The info is built once, for whichever is set.
166
- */
167
- const moved = (named: MovementCallback | undefined, every: "onDrag" | "onPan", sample: Drag.Sample): void => {
168
- const c = config()
169
- const own = UndefinedOr.map(named, (key) => c[key])
170
- const moving = sample.phase !== "end"
171
- const each = c[every]
172
- if (Bool.and(Predicate.isUndefined(own), Bool.or(Bool.not(moving), Predicate.isUndefined(each)))) return
173
- const raw = sample.raw as PointerEvent
174
- const info = GestureInfo.dragInfoOf(sample)
175
- if (Predicate.isNotUndefined(named)) call(named, own, raw, info)
176
- if (moving) callPerMove(every, each, raw, info)
177
- }
178
- return {
179
- hovered: (edge) => {
180
- const name = Bool.match(edge.active, { onTrue: () => "onHoverStart" as const, onFalse: () => "onHoverEnd" as const })
181
- call(name, config()[name], edge.event.raw as PointerEvent, GestureInfo.pointInfoOf(edge.event))
182
- },
183
- pressed: (press, element) => {
184
- const name = PRESS_CALLBACK[press.phase]
185
- if (Predicate.isUndefined(name)) return
186
- call(name, config()[name], press.event.raw as GestureInfo.WardicPressEvent, GestureInfo.pressInfoOf(press, element))
36
+ export const gestureCallbacksOf = (runtime: WardicRuntime, id: string, config: () => WardConfig.WardConfig): GestureCallbacks =>
37
+ GestureFeatures.gestureTellerOf({
38
+ config,
39
+ invoke: (handler, args) => (handler as Called)(...args),
40
+ report: (name, defect) => {
41
+ runtime.runFork(Report.failure(`wardic.gesture: ${name} failed`, Cause.die(defect)).pipe(Effect.annotateLogs({ id })))
187
42
  },
188
- dragged: (sample) => {
189
- // A drag its controls cancelled (#431) ends untold, as Motion's `cancel` tells no `onDragEnd`.
190
- if (sample.cancelled === true) return
191
- // A direction-locked drag's lock, at its start, before `onDragStart` (Motion's order).
192
- if (sample.phase === "start") {
193
- const c = config()
194
- if (c.dragDirectionLock === true) call("onDirectionLock", c.onDirectionLock, sample.axis as "x" | "y")
195
- }
196
- moved(DRAG_CALLBACK[sample.phase], "onDrag", sample)
197
- },
198
- released: () => call("onDragTransitionEnd", config().onDragTransitionEnd),
199
- panned: (sample) => {
200
- // Its session's start, at the down: Motion's `onPanSessionStart`, with the point only.
201
- if (sample.phase === "session") {
202
- call("onPanSessionStart", config().onPanSessionStart, sample.raw as PointerEvent, GestureInfo.pointOfSample(sample))
203
- return
204
- }
205
- moved(PAN_CALLBACK[sample.phase], "onPan", sample as Drag.Sample)
206
- },
207
- viewed: (edge) => {
208
- const name = Bool.match(edge.active, { onTrue: () => "onViewportEnter" as const, onFalse: () => "onViewportLeave" as const })
209
- call(name, config()[name], edge.raw as IntersectionObserverEntry)
210
- },
211
- }
212
- }
43
+ })
package/src/index.tsx CHANGED
@@ -11,7 +11,7 @@
11
11
  *
12
12
  * @see https://wardic.dev/reference/solid/utilities/version
13
13
  */
14
- export const VERSION = "1.1.2"
14
+ export const VERSION = "1.1.3"
15
15
 
16
16
  /**
17
17
  * `WardicProvider` (one Effect runtime + `AtomRegistry` per ADR-0006), the
package/src/provider.tsx CHANGED
@@ -22,7 +22,6 @@ import * as Scope from "effect/Scope"
22
22
  import * as Bool from "effect/Boolean"
23
23
  import { constFalse, constUndefined, identity } from "effect/Function"
24
24
  import * as Latch from "effect/Latch"
25
- import * as Option from "effect/Option"
26
25
  import * as Predicate from "effect/Predicate"
27
26
  import * as UndefinedOr from "effect/UndefinedOr"
28
27
  import { batch, createContext, DEV, onCleanup, onMount, untrack, useContext } from "solid-js"
@@ -147,10 +146,7 @@ export function WardicProvider(props: {
147
146
  // and once the render is done the head's `<style>` gets every rule and timing (`useAssets`,
148
147
  // injected before `</head>`). A render with no `</head>` drops it, and its elements keep their
149
148
  // Starting style, as they would without it.
150
- const appear = Bool.match(props.appear === false, {
151
- onTrue: constUndefined,
152
- onFalse: () => AppearAnimations.serverAppear(Option.getOrElse(Option.fromUndefinedOr(props.reducedMotion), () => "user" as const), AppearAnimations.explainerOf(props.appear), props.nonce),
153
- })
149
+ const appear = AppearAnimations.serverAppearUnder(props.appear, props.reducedMotion, props.nonce)
154
150
  if (Predicate.isNotUndefined(appear)) useAssets(() => appearStyle(appear))
155
151
  const value = serverContext(props.env, WAITING_ENV_FIX, appear, () => untrack(() => props.reducedMotion))
156
152
  onCleanup(() => void value.features.dispose())
package/src/reorder.tsx CHANGED
@@ -31,11 +31,9 @@ import * as DomAnnouncer from "@wardic/dom/DomAnnouncer"
31
31
  import * as ReorderController from "@wardic/dom/ReorderController"
32
32
  import * as Style from "@wardic/dom/Style"
33
33
  import { mergeRefs } from "@solid-primitives/refs"
34
- import * as Arr from "effect/Array"
35
34
  import * as Bool from "effect/Boolean"
36
35
  import * as Effect from "effect/Effect"
37
36
  import { constUndefined, identity, pipe } from "effect/Function"
38
- import * as Match from "effect/Match"
39
37
  import * as Option from "effect/Option"
40
38
  import * as Predicate from "effect/Predicate"
41
39
  import * as Scope from "effect/Scope"
@@ -61,7 +59,7 @@ import { Dynamic } from "solid-js/web"
61
59
  import * as OwnerScope from "@wardic/dom/unstable/OwnerScope"
62
60
  import { runWatch, useBrought, useWardicGate, useWardicRuntime } from "./provider.tsx"
63
61
  import { useLayoutServices } from "./layout-projection.tsx"
64
- import { watchItemInput } from "./reorder-input.ts"
62
+ import { watchItemInput } from "@wardic/dom/unstable/ReorderInput"
65
63
  import { plainOrder } from "./reorder-values.ts"
66
64
  import type * as Feature from "@wardic/dom/unstable/Feature"
67
65
  import * as Drag from "@wardic/dom/unstable/features/Drag"
@@ -229,7 +227,7 @@ export function createReorderGroup<V>(config: ReorderGroupConfig<V> | Accessor<R
229
227
  axis: () => Option.fromUndefinedOr(untrack(cfg).axis),
230
228
  onAxis: setDetected,
231
229
  keyedWith: "<For>",
232
- keyboard: () => untrack(cfg).keyboard !== false,
230
+ keyboard: () => ReorderController.keyboardOn(untrack(cfg).keyboard),
233
231
  announcements: () => Option.fromUndefinedOr(untrack(cfg).announcements),
234
232
  }).pipe(Effect.provide(useLayoutServices()), Scope.provide(scope)),
235
233
  )
@@ -263,8 +261,8 @@ export function createReorderGroup<V>(config: ReorderGroupConfig<V> | Accessor<R
263
261
 
264
262
  /** A group's keyboard reorder settings, as accessors (ADR-0037). */
265
263
  const keyboardOf = <V,>(cfg: Accessor<ReorderGroupConfig<V>>) => ({
266
- keyboard: (): boolean => cfg().keyboard !== false,
267
- instructions: (): string => UndefinedOr.match(cfg().instructions, { onUndefined: () => ReorderController.DEFAULT_INSTRUCTIONS, onDefined: (text: string) => text }),
264
+ keyboard: (): boolean => ReorderController.keyboardOn(cfg().keyboard),
265
+ instructions: (): string => ReorderController.instructionsOf(cfg().instructions),
268
266
  })
269
267
 
270
268
  /**
@@ -321,7 +319,7 @@ const itemInternals = <V,>(group: ItemGroup<V>, value: V, element: Accessor<HTML
321
319
  )
322
320
  return {
323
321
  brings: ITEM_BRINGS,
324
- dragAxis: () => dragAxisFor(driver.dragAxis()),
322
+ dragAxis: () => ReorderController.itemDragAxis(driver.dragAxis()),
325
323
  onDragSample: driver.onSample,
326
324
  onLayoutHandle: (handle) => onCleanup(driver.register(handle)),
327
325
  raiseWhileDragged: true,
@@ -348,14 +346,10 @@ const internalsOf = <V,>(group: ItemGroup<V>, value: V, element: Accessor<HTMLEl
348
346
  */
349
347
  const keyboardAttributes = (group: ItemGroup<never>, user: ReorderItemUserProps = NO_ITEM_PROPS, describedBy: Accessor<string | undefined>) => ({
350
348
  get tabindex() {
351
- return UndefinedOr.match(user.tabIndex, {
352
- onDefined: identity,
353
- onUndefined: () => Bool.match(group.keyboard(), { onTrue: () => 0, onFalse: constUndefined }),
354
- })
349
+ return UndefinedOr.match(user.tabIndex, { onDefined: identity, onUndefined: () => ReorderController.tabStopOf(group.keyboard(), false) })
355
350
  },
356
351
  get "aria-describedby"() {
357
- const ids = Arr.filter([user["aria-describedby"], Bool.match(group.keyboard(), { onTrue: describedBy, onFalse: constUndefined })], Predicate.isNotUndefined)
358
- return Bool.match(ids.length === 0, { onTrue: () => undefined, onFalse: () => ids.join(" ") })
352
+ return ReorderController.describedByOf(user["aria-describedby"], Bool.match(group.keyboard(), { onTrue: describedBy, onFalse: constUndefined }))
359
353
  },
360
354
  })
361
355
 
@@ -427,12 +421,6 @@ const noop = (): void => {}
427
421
  const NO_GROUP_PROPS: ReorderGroupUserProps = {}
428
422
  const NO_ITEM_PROPS: ReorderItemUserProps = {}
429
423
 
430
- /** A Reorder item's drag axis for its gesture's axis: a grid's `xy` is a free drag. Built once, at module load. */
431
- const dragAxisFor: (axis: CoreReorder.Axis) => true | "x" | "y" = Match.type<CoreReorder.Axis>().pipe(
432
- Match.when("xy", (): true => true),
433
- Match.orElse((axis) => axis as "x" | "y"),
434
- )
435
-
436
424
  /**
437
425
  * {@link createReorderGroup} during a server render (ADR-0021): the group's element style
438
426
  * (`overflow-anchor: none` under the user's) and the app's axis, else `"y"`; its `group`,
@@ -213,8 +213,8 @@ const BatchGroupContext = createContext<GroupForItems<unknown> | null>(null)
213
213
  // #712, ADR-0072.
214
214
  export function BatchGroup<V, Tag extends ReorderElementTag = "ul">(props: ReorderBatchGroupProps<V, Tag>): JSX.Element {
215
215
  const local = props as unknown as GroupLocal<V>
216
- const keyboard = (): boolean => local.keyboard !== false
217
- const instructions = (): string => UndefinedOr.match(local.instructions, { onUndefined: () => ReorderController.DEFAULT_INSTRUCTIONS, onDefined: identity })
216
+ const keyboard = (): boolean => ReorderController.keyboardOn(local.keyboard)
217
+ const instructions = (): string => ReorderController.instructionsOf(local.instructions)
218
218
  const Element = staticElementOf(UndefinedOr.match(untrack(() => local.as), { onUndefined: () => "ul", onDefined: identity }))
219
219
  const rest = omit(props as unknown as Record<string, unknown>, ...GROUP_OWN)
220
220
  // On a server (Q39): its items' starts, no runtime, and a group whose events never come, as
@@ -39,11 +39,13 @@ export const streamToSignal = <A,>(stream: Stream.Stream<A, never, WardicService
39
39
  /**
40
40
  * `atom` as an accessor carrying it: a signal set from `registry` at each change, unsubscribed when
41
41
  * the owner is disposed. Every Atom the binding hands to Solid goes through it (a ward's `read`, the
42
- * Live-value helpers, `fromAtom`). Call it where you'd make a signal.
42
+ * Live-value helpers, `fromAtom`). Call it where you'd make a signal. Its unsubscribe goes to
43
+ * `addCleanup`, the owner's `onCleanup` unless given: a ward's accessor first called in a ref, where
44
+ * Solid 2.0 refuses `onCleanup`, gives its own (#566).
43
45
  */
44
- export const followAtom = <A,>(registry: AtomRegistry.AtomRegistry, atom: Atom.Atom<A>): Accessor<A> => {
46
+ export const followAtom = <A,>(registry: AtomRegistry.AtomRegistry, atom: Atom.Atom<A>, addCleanup: (cleanup: () => void) => void = onCleanup): Accessor<A> => {
45
47
  const [value, setValue] = createSignal<A>(registry.get(atom) as Exclude<A, Function>)
46
- onCleanup(registry.subscribe(atom, (next) => setValue(() => next as Exclude<A, Function>)))
48
+ addCleanup(registry.subscribe(atom, (next) => setValue(() => next as Exclude<A, Function>)))
47
49
  // eslint-disable-next-line solid/reactivity -- the accessor itself is returned, for its caller to read where it tracks
48
50
  return LiveStyle.carry(value, atom)
49
51
  }
@@ -7,7 +7,7 @@
7
7
  * @module
8
8
  */
9
9
  import type * as Feature from "@wardic/dom/unstable/Feature"
10
- import { instanceFeaturesOf } from "../../instance-features.ts"
10
+ import { instanceFeaturesOf } from "@wardic/dom/unstable/InstanceFeatures"
11
11
  import { createInstantLayoutTransition, createResetProjection, useAnimateLayout, useInstanceBrought } from "./provider.tsx"
12
12
  import { wOf } from "./w.tsx"
13
13
  import type { WardicInstance } from "./wardic-instance.ts"
@@ -7,10 +7,10 @@
7
7
  */
8
8
  import * as Predicate from "effect/Predicate"
9
9
  import * as UndefinedOr from "effect/UndefinedOr"
10
- import { type Accessor, createMemo, createSignal, getOwner, runWithOwner } from "solid-js"
11
- import { CLIENT_ONLY } from "./solid-reactivity.ts"
10
+ import { type Accessor, createMemo, createSignal, runWithOwner } from "solid-js"
11
+ import { CLIENT_ONLY, firstCallOwnerHere } from "./solid-reactivity.ts"
12
12
 
13
- /** Flights counted: each one's start and end, and the async value they make, read under its maker's owner. */
13
+ /** Flights counted: each one's start and end, and the async value they make, made at its first read under an owner of its own. */
14
14
  export interface Flights<L> {
15
15
  readonly started: () => void
16
16
  /** One flight ended, with its landing, or `undefined` for one that ended without landing. */
@@ -18,9 +18,12 @@ export interface Flights<L> {
18
18
  readonly read: () => L | undefined
19
19
  }
20
20
 
21
- /** Flights made under the current owner: nothing Solid is made until the first read. */
21
+ /**
22
+ * Flights made under the current owner: nothing but their owner is made until the first read, which can
23
+ * be in a ref (#566).
24
+ */
22
25
  export const flightsOf = <L>(): Flights<L> => {
23
- const owner = getOwner()
26
+ const owner = firstCallOwnerHere()
24
27
  let flying = 0
25
28
  let last: L | undefined
26
29
  let setCount: ((count: number) => void) | undefined
@@ -319,9 +319,8 @@ const disposals = new WeakMap<WardicContextValue, Promise<never>>()
319
319
  * gets every rule and timing once the shell has rendered.
320
320
  */
321
321
  const serverAppearOf = (appear: boolean | "explain" | undefined, reducedMotion: ReducedMotion.Config | undefined, nonce: string | undefined): AppearAnimations.ServerAppear | undefined => {
322
- if (appear === false) return undefined
323
- const state = AppearAnimations.serverAppear(UndefinedOr.match(reducedMotion, { onUndefined: () => "user" as const, onDefined: identity }), AppearAnimations.explainerOf(appear), nonce)
324
- useHead(appearStyle(() => state.css(), nonce))
322
+ const state = AppearAnimations.serverAppearUnder(appear, reducedMotion, nonce)
323
+ UndefinedOr.map(state, (made) => useHead(appearStyle(() => made.css(), nonce)))
325
324
  return state
326
325
  }
327
326
 
@@ -64,7 +64,7 @@ import * as Pan from "@wardic/dom/unstable/features/Pan"
64
64
  import * as Press from "@wardic/dom/unstable/features/Press"
65
65
  import * as GestureFeatures from "@wardic/dom/unstable/GestureFeatures"
66
66
  import * as OwnerScope from "@wardic/dom/unstable/OwnerScope"
67
- import { watchItemInput } from "../../reorder-input.ts"
67
+ import { watchItemInput } from "@wardic/dom/unstable/ReorderInput"
68
68
  import { plainOrder } from "../../reorder-values.ts"
69
69
  import * as VariantTree from "@wardic/core/unstable/VariantTree"
70
70
  import { configView, type PerKey } from "./config-view.ts"
@@ -281,8 +281,8 @@ const isElement = (value: unknown): value is HTMLElement => Predicate.hasPropert
281
281
 
282
282
  /** The group's keyboard reorder settings, as accessors (ADR-0037). */
283
283
  const keyboardOf = <V,>(cfg: Accessor<ReorderGroupConfigValues<V>>) => ({
284
- keyboard: (): boolean => cfg().keyboard !== false,
285
- instructions: (): string => UndefinedOr.match(cfg().instructions, { onUndefined: () => ReorderController.DEFAULT_INSTRUCTIONS, onDefined: identity }),
284
+ keyboard: (): boolean => ReorderController.keyboardOn(cfg().keyboard),
285
+ instructions: (): string => ReorderController.instructionsOf(cfg().instructions),
286
286
  })
287
287
 
288
288
  /** The group element's style: the config's over `overflow-anchor: none`. */
@@ -15,7 +15,7 @@
15
15
  *
16
16
  * @module
17
17
  */
18
- import { createEffect, createRoot, createSignal, createTrackedEffect, type Owner, runWithOwner, untrack } from "solid-js"
18
+ import { createEffect, createRoot, createSignal, createTrackedEffect, getOwner, type Owner, runWithOwner, untrack } from "solid-js"
19
19
  import type * as Reactivity from "@wardic/core/unstable/Reactivity"
20
20
 
21
21
  /**
@@ -25,6 +25,17 @@ import type * as Reactivity from "@wardic/core/unstable/Reactivity"
25
25
  * ward is lean, ADR-0021), so the client's later ids would miss the server's markup.
26
26
  */
27
27
  export const CLIENT_ONLY = { transparent: true } as const
28
+
29
+ /** A root's own owner. */
30
+ const ownerOfRoot = (): Owner | null => getOwner()
31
+
32
+ /**
33
+ * An owner for what's made at a first call (#566), under the current one and disposed with it: made in a
34
+ * maker's body, so a first call in a ref makes under it. Solid 2.0 runs a ref in its creating pass's
35
+ * owner, the maker's own when its handle is given in the component that made it, and refuses a memo
36
+ * or an effect made under that owner there. Client-only: it takes no hydration id.
37
+ */
38
+ export const firstCallOwnerHere = (): Owner | null => createRoot(ownerOfRoot, CLIENT_ONLY)
28
39
  /** {@link CLIENT_ONLY}, deferred: an effect that skips its first run. */
29
40
  export const CLIENT_ONLY_DEFERRED = { transparent: true, defer: true } as const
30
41
 
@@ -127,7 +127,7 @@ import {
127
127
  } from "./provider.tsx"
128
128
  import * as Feature from "@wardic/dom/unstable/Feature"
129
129
  import type * as All from "@wardic/dom/unstable/features/All"
130
- import { CLIENT_ONLY, CLIENT_ONLY_DEFERRED, CLIENT_ONLY_SYNC, CLIENT_ONLY_SYNC_DEFERRED, reactivityIn } from "./solid-reactivity.ts"
130
+ import { CLIENT_ONLY, CLIENT_ONLY_DEFERRED, CLIENT_ONLY_SYNC, CLIENT_ONLY_SYNC_DEFERRED, firstCallOwnerHere, reactivityIn } from "./solid-reactivity.ts"
131
131
  import { useWardicConfig } from "./wardic-config.tsx"
132
132
  import { configView, type Fixed, type PerKey, type PerKeyApart } from "./config-view.ts"
133
133
  import { type EventNeeds, Lifecycle, type WardEvent, type WardEvents, type WardPressInfo, type WardSettled } from "./lifecycle.ts"
@@ -813,13 +813,14 @@ const NO_CHANGE: Accessor<AnimationControls.ControlsChange | undefined> = constU
813
813
  * they make its entry, over the rest of its keys as given, the view marked controlled; anything else, none.
814
814
  */
815
815
  const controlsOf = (given: WardConfigValues, animate: WardConfigValues["animate"]): Controls | undefined => {
816
- if (Bool.not(AnimationControls.isAnimationControls(animate))) return undefined
816
+ const controls = AnimationControls.controlsOf(animate)
817
+ if (Predicate.isUndefined(controls)) return undefined
817
818
  const [change, setChange] = createSignal<AnimationControls.ControlsChange | undefined>(undefined)
818
819
  const view = Object.create(given, {
819
820
  animate: { enumerable: true, get: () => UndefinedOr.map(change(), (made) => made.definition) },
820
821
  controlled: { enumerable: true, value: true },
821
822
  }) as WardConfigValues
822
- return { controls: animate as AnimationControls.WardicAnimationControls, view, change, set: (made) => setChange(() => made) }
823
+ return { controls, view, change, set: (made) => setChange(() => made) }
823
824
  }
824
825
 
825
826
  /**
@@ -850,6 +851,8 @@ const lifecycleFor = (share: WardShare | undefined, owner: Owner | null, want: (
850
851
  return new Lifecycle(owner, want)
851
852
  }
852
853
  const lifecycleOfShare = (share: WardShare): Lifecycle | undefined => share.lifecycle
854
+ /** Runs one cleanup an accessor added at its first call (#566). */
855
+ const runCleanup = (cleanup: () => void): void => cleanup()
853
856
  /** A mount's element. */
854
857
  const elementOfMount = (m: { readonly element: HTMLElement }): HTMLElement => m.element
855
858
 
@@ -936,6 +939,9 @@ export function wardWith(config: WardConfig, internal: WardInternals): Ward {
936
939
  // Its value reads (PR2-Q6): one context read.
937
940
  const { ownValues, measuredPairs, variableValues } = ElementSetup.valueReadsOf(useWardicValueReads())
938
941
  const owner = getOwner()
942
+ // What its accessors make at their first call goes under an owner of the ward's own, so a first
943
+ // call in a ref makes it as in the body (#566).
944
+ const firstCallOwner = firstCallOwnerHere()
939
945
  const reactivity = reactivityIn(owner)
940
946
  const registry = Spine.registryOf(runtime)
941
947
  // SSR/hydration-stable: the server ward makes the same one call.
@@ -1153,16 +1159,23 @@ export function wardWith(config: WardConfig, internal: WardInternals): Ward {
1153
1159
  // `next` follow that element. Followed through an Atom made at the first `read`, `atom` or drive.
1154
1160
  let driver: Driver | undefined
1155
1161
  let driven: Atom.Writable<Driver | undefined> | undefined
1162
+ // What an accessor mounts at its first call (#566), ended by the ward's one cleanup below: that
1163
+ // call can be in a ref, where Solid 2.0 refuses `onCleanup`.
1164
+ let cleanups: Array<() => void> | undefined
1165
+ const addCleanup = (cleanup: () => void): void => {
1166
+ if (Predicate.isUndefined(cleanups)) cleanups = []
1167
+ cleanups.push(cleanup)
1168
+ }
1156
1169
  const drivenAtom = (): Atom.Writable<Driver | undefined> => {
1157
1170
  if (Predicate.isNotUndefined(driven)) return driven
1158
1171
  const atom = Atom.make<Driver | undefined>(driver)
1159
- runWithOwner(owner, () => onCleanup(registry().mount(atom)))
1172
+ addCleanup(registry().mount(atom))
1160
1173
  driven = atom
1161
1174
  return atom
1162
1175
  }
1163
1176
 
1164
1177
  // A driving ward's are its given ward's (#349), whose `next` starts them on the element it drives.
1165
- const lifecycle = lifecycleFor(share, owner, () => {
1178
+ const lifecycle = lifecycleFor(share, firstCallOwner, () => {
1166
1179
  watchLateGestures()
1167
1180
  UndefinedOr.map(mounted, startRecognizers)
1168
1181
  UndefinedOr.map(driver, (d) => d.wanted())
@@ -1314,11 +1327,13 @@ export function wardWith(config: WardConfig, internal: WardInternals): Ward {
1314
1327
  if (justLeft.size === 0) queueMicrotask(forgetJustLeft)
1315
1328
  justLeft.add(left)
1316
1329
  }
1317
- // Its element's mount goes, and its lifecycle's waits are rejected (#257): one cleanup.
1330
+ // Its element's mount goes, and its lifecycle's waits are rejected (#257): one cleanup, which ends
1331
+ // what its accessors mounted at their first calls too (#566).
1318
1332
  // A driving ward's lifecycle is its given ward's, which outlives the element (#349).
1319
1333
  onCleanup(() => {
1320
1334
  unmount()
1321
1335
  if (Predicate.isUndefined(share)) lifecycle.dispose()
1336
+ UndefinedOr.map(cleanups, (all) => Arr.forEach(all, runCleanup))
1322
1337
  })
1323
1338
 
1324
1339
  const mount = (el: HTMLElement): Mounted => {
@@ -1725,13 +1740,13 @@ export function wardWith(config: WardConfig, internal: WardInternals): Ward {
1725
1740
  if (Predicate.isNotUndefined(known)) return known
1726
1741
  const output = gate.valueOf(id, key)
1727
1742
  const following = drivenAtom()
1728
- const entry = runWithOwner(owner, (): ReadEntry => {
1743
+ const entry = runWithOwner(firstCallOwner, (): ReadEntry => {
1729
1744
  const resting = createMemo(() => {
1730
1745
  withCallsOf()[0]()
1731
1746
  return ElementSetup.restingOf(key, start.initialValues, userStyle(), (raw) => live.read(raw))
1732
1747
  }, CLIENT_ONLY)
1733
1748
  const restingAtom = Atom.make<unknown>(untrack(resting))
1734
- onCleanup(registry().mount(restingAtom))
1749
+ addCleanup(registry().mount(restingAtom))
1735
1750
  createEffect(
1736
1751
  resting,
1737
1752
  (value) => {
@@ -1742,7 +1757,7 @@ export function wardWith(config: WardConfig, internal: WardInternals): Ward {
1742
1757
  const own = Atom.make((get) => UndefinedOr.match(get(output), { onUndefined: () => get(restingAtom), onDefined: identity }))
1743
1758
  // Given to a component (#349): what the element it drives shows, while it's there.
1744
1759
  const atom = Atom.make((get) => UndefinedOr.match(get(following), { onUndefined: () => get(own), onDefined: (d) => get(d.readAtom(key)) }))
1745
- return { accessor: followAtom(registry(), atom), atom }
1760
+ return { accessor: followAtom(registry(), atom, addCleanup), atom }
1746
1761
  })
1747
1762
  reads.set(key, entry)
1748
1763
  return entry
@@ -2018,7 +2033,7 @@ const serverWard = (config: WardConfig, internal: WardInternals): Ward => {
2018
2033
  // The element's style for its user style: the config's, or a `.with()` style over it (#264).
2019
2034
  const styleFor = (user: WardStyle | string | undefined): JSX.CSSProperties => {
2020
2035
  const parts = LiveStyle.split(user, ownValues)
2021
- if (AppearAnimations.setsAnimation(parts.css)) appear.veto("its own style sets an animation")
2036
+ if (AppearAnimations.setsAnimation(parts.css)) appear.veto(AppearAnimations.OWN_ANIMATION)
2022
2037
  return pipe(
2023
2038
  ElementSetup.serverStartingStyle(internal.tag, seed.style, initialValues, parts.routed, layoutNode, untrack, c.transformTemplate),
2024
2039
  Style.over(parts.css),