@wardic/solid 2.0.1 → 2.1.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 (222) hide show
  1. package/dist/browser/batch-reorder-group.js +3 -2
  2. package/dist/browser/batch-reorder-group.js.map +1 -1
  3. package/dist/browser/complete.js +3 -8
  4. package/dist/browser/complete.js.map +1 -1
  5. package/dist/browser/create-batch.js +13 -3
  6. package/dist/browser/create-batch.js.map +1 -1
  7. package/dist/browser/drag-sensor.js +44 -6
  8. package/dist/browser/drag-sensor.js.map +1 -1
  9. package/dist/browser/element.js +3 -1
  10. package/dist/browser/element.js.map +1 -1
  11. package/dist/browser/focus-sensor.js +21 -4
  12. package/dist/browser/focus-sensor.js.map +1 -1
  13. package/dist/browser/frame-effect.js +108 -0
  14. package/dist/browser/frame-effect.js.map +1 -0
  15. package/dist/browser/hover-sensor.js +21 -7
  16. package/dist/browser/hover-sensor.js.map +1 -1
  17. package/dist/browser/index.js +7 -0
  18. package/dist/browser/index.js.map +1 -1
  19. package/dist/browser/lifecycle.js +12 -0
  20. package/dist/browser/lifecycle.js.map +1 -1
  21. package/dist/browser/presence-hooks.js +5 -3
  22. package/dist/browser/presence-hooks.js.map +1 -1
  23. package/dist/browser/press-sensor.js +21 -7
  24. package/dist/browser/press-sensor.js.map +1 -1
  25. package/dist/browser/provider.js +7 -4
  26. package/dist/browser/provider.js.map +1 -1
  27. package/dist/browser/sensors.js +54 -3
  28. package/dist/browser/sensors.js.map +1 -1
  29. package/dist/browser/solid-reactivity.js +7 -0
  30. package/dist/browser/solid-reactivity.js.map +1 -1
  31. package/dist/browser/stage-batch.js +85 -0
  32. package/dist/browser/stage-batch.js.map +1 -0
  33. package/dist/browser/stage-graph.js +264 -0
  34. package/dist/browser/stage-graph.js.map +1 -0
  35. package/dist/browser/stage-hooks.js +61 -0
  36. package/dist/browser/stage-hooks.js.map +1 -0
  37. package/dist/browser/stage-ward.js +687 -0
  38. package/dist/browser/stage-ward.js.map +1 -0
  39. package/dist/browser/stage.js +8 -0
  40. package/dist/browser/stage.js.map +1 -0
  41. package/dist/browser/unstable/v2/index.js +9 -0
  42. package/dist/browser/unstable/v2/index.js.map +1 -1
  43. package/dist/browser/v1/index.js +1 -1
  44. package/dist/browser/w.js +3 -3
  45. package/dist/browser/w.js.map +1 -1
  46. package/dist/browser/ward-first.js +45 -0
  47. package/dist/browser/ward-first.js.map +1 -0
  48. package/dist/browser/ward.js +35 -6
  49. package/dist/browser/ward.js.map +1 -1
  50. package/dist/server/batch-reorder-group.js +3 -2
  51. package/dist/server/batch-reorder-group.js.map +1 -1
  52. package/dist/server/complete.js +3 -8
  53. package/dist/server/complete.js.map +1 -1
  54. package/dist/server/create-batch.js +13 -3
  55. package/dist/server/create-batch.js.map +1 -1
  56. package/dist/server/drag-sensor.js +44 -6
  57. package/dist/server/drag-sensor.js.map +1 -1
  58. package/dist/server/element.js +3 -1
  59. package/dist/server/element.js.map +1 -1
  60. package/dist/server/focus-sensor.js +21 -4
  61. package/dist/server/focus-sensor.js.map +1 -1
  62. package/dist/server/frame-effect.js +108 -0
  63. package/dist/server/frame-effect.js.map +1 -0
  64. package/dist/server/hover-sensor.js +21 -7
  65. package/dist/server/hover-sensor.js.map +1 -1
  66. package/dist/server/index.js +7 -0
  67. package/dist/server/index.js.map +1 -1
  68. package/dist/server/lifecycle.js +12 -0
  69. package/dist/server/lifecycle.js.map +1 -1
  70. package/dist/server/presence-hooks.js +5 -3
  71. package/dist/server/presence-hooks.js.map +1 -1
  72. package/dist/server/press-sensor.js +21 -7
  73. package/dist/server/press-sensor.js.map +1 -1
  74. package/dist/server/provider.js +7 -4
  75. package/dist/server/provider.js.map +1 -1
  76. package/dist/server/sensors.js +54 -3
  77. package/dist/server/sensors.js.map +1 -1
  78. package/dist/server/solid-reactivity.js +7 -0
  79. package/dist/server/solid-reactivity.js.map +1 -1
  80. package/dist/server/stage-batch.js +85 -0
  81. package/dist/server/stage-batch.js.map +1 -0
  82. package/dist/server/stage-graph.js +264 -0
  83. package/dist/server/stage-graph.js.map +1 -0
  84. package/dist/server/stage-hooks.js +61 -0
  85. package/dist/server/stage-hooks.js.map +1 -0
  86. package/dist/server/stage-ward.js +687 -0
  87. package/dist/server/stage-ward.js.map +1 -0
  88. package/dist/server/stage.js +8 -0
  89. package/dist/server/stage.js.map +1 -0
  90. package/dist/server/unstable/v2/index.js +9 -0
  91. package/dist/server/unstable/v2/index.js.map +1 -1
  92. package/dist/server/v1/index.js +1 -1
  93. package/dist/server/w.js +3 -3
  94. package/dist/server/w.js.map +1 -1
  95. package/dist/server/ward-first.js +45 -0
  96. package/dist/server/ward-first.js.map +1 -0
  97. package/dist/server/ward.js +35 -6
  98. package/dist/server/ward.js.map +1 -1
  99. package/dist/solid/batch-reorder-group.d.ts.map +1 -1
  100. package/dist/solid/batch-reorder-group.jsx +3 -2
  101. package/dist/solid/batch-reorder-group.jsx.map +1 -1
  102. package/dist/solid/complete.d.ts +8 -1
  103. package/dist/solid/complete.d.ts.map +1 -1
  104. package/dist/solid/complete.jsx +3 -9
  105. package/dist/solid/complete.jsx.map +1 -1
  106. package/dist/solid/create-batch.d.ts +5 -0
  107. package/dist/solid/create-batch.d.ts.map +1 -1
  108. package/dist/solid/create-batch.jsx +14 -3
  109. package/dist/solid/create-batch.jsx.map +1 -1
  110. package/dist/solid/drag-sensor.d.ts +18 -2
  111. package/dist/solid/drag-sensor.d.ts.map +1 -1
  112. package/dist/solid/drag-sensor.jsx +41 -6
  113. package/dist/solid/drag-sensor.jsx.map +1 -1
  114. package/dist/solid/element.d.ts.map +1 -1
  115. package/dist/solid/element.jsx +3 -1
  116. package/dist/solid/element.jsx.map +1 -1
  117. package/dist/solid/focus-sensor.d.ts +10 -3
  118. package/dist/solid/focus-sensor.d.ts.map +1 -1
  119. package/dist/solid/focus-sensor.jsx +25 -5
  120. package/dist/solid/focus-sensor.jsx.map +1 -1
  121. package/dist/solid/frame-effect.d.ts +3 -0
  122. package/dist/solid/frame-effect.d.ts.map +1 -0
  123. package/dist/solid/frame-effect.jsx +112 -0
  124. package/dist/solid/frame-effect.jsx.map +1 -0
  125. package/dist/solid/hover-sensor.d.ts +14 -3
  126. package/dist/solid/hover-sensor.d.ts.map +1 -1
  127. package/dist/solid/hover-sensor.jsx +20 -6
  128. package/dist/solid/hover-sensor.jsx.map +1 -1
  129. package/dist/solid/index.d.ts +8 -0
  130. package/dist/solid/index.d.ts.map +1 -1
  131. package/dist/solid/index.jsx +7 -0
  132. package/dist/solid/index.jsx.map +1 -1
  133. package/dist/solid/lifecycle.d.ts +3 -0
  134. package/dist/solid/lifecycle.d.ts.map +1 -1
  135. package/dist/solid/lifecycle.js +13 -0
  136. package/dist/solid/lifecycle.js.map +1 -1
  137. package/dist/solid/presence-hooks.d.ts +5 -3
  138. package/dist/solid/presence-hooks.d.ts.map +1 -1
  139. package/dist/solid/presence-hooks.jsx +5 -3
  140. package/dist/solid/presence-hooks.jsx.map +1 -1
  141. package/dist/solid/press-sensor.d.ts +11 -3
  142. package/dist/solid/press-sensor.d.ts.map +1 -1
  143. package/dist/solid/press-sensor.jsx +24 -6
  144. package/dist/solid/press-sensor.jsx.map +1 -1
  145. package/dist/solid/provider.d.ts.map +1 -1
  146. package/dist/solid/provider.jsx +7 -4
  147. package/dist/solid/provider.jsx.map +1 -1
  148. package/dist/solid/sensors.d.ts +25 -1
  149. package/dist/solid/sensors.d.ts.map +1 -1
  150. package/dist/solid/sensors.jsx +53 -3
  151. package/dist/solid/sensors.jsx.map +1 -1
  152. package/dist/solid/solid-reactivity.d.ts +7 -0
  153. package/dist/solid/solid-reactivity.d.ts.map +1 -1
  154. package/dist/solid/solid-reactivity.js +7 -0
  155. package/dist/solid/solid-reactivity.js.map +1 -1
  156. package/dist/solid/stage-batch.d.ts +6 -0
  157. package/dist/solid/stage-batch.d.ts.map +1 -0
  158. package/dist/solid/stage-batch.js +86 -0
  159. package/dist/solid/stage-batch.js.map +1 -0
  160. package/dist/solid/stage-graph.d.ts +79 -0
  161. package/dist/solid/stage-graph.d.ts.map +1 -0
  162. package/dist/solid/stage-graph.js +224 -0
  163. package/dist/solid/stage-graph.js.map +1 -0
  164. package/dist/solid/stage-hooks.d.ts +52 -0
  165. package/dist/solid/stage-hooks.d.ts.map +1 -0
  166. package/dist/solid/stage-hooks.js +44 -0
  167. package/dist/solid/stage-hooks.js.map +1 -0
  168. package/dist/solid/stage-ward.d.ts +52 -0
  169. package/dist/solid/stage-ward.d.ts.map +1 -0
  170. package/dist/solid/stage-ward.jsx +609 -0
  171. package/dist/solid/stage-ward.jsx.map +1 -0
  172. package/dist/solid/stage.d.ts +309 -0
  173. package/dist/solid/stage.d.ts.map +1 -0
  174. package/dist/solid/stage.js +8 -0
  175. package/dist/solid/stage.js.map +1 -0
  176. package/dist/solid/unstable/v2/index.d.ts +96 -0
  177. package/dist/solid/unstable/v2/index.d.ts.map +1 -1
  178. package/dist/solid/unstable/v2/index.jsx +18 -0
  179. package/dist/solid/unstable/v2/index.jsx.map +1 -1
  180. package/dist/solid/v1/index.d.ts +1 -1
  181. package/dist/solid/v1/index.jsx +1 -1
  182. package/dist/solid/w.d.ts +11 -0
  183. package/dist/solid/w.d.ts.map +1 -1
  184. package/dist/solid/w.jsx +3 -3
  185. package/dist/solid/w.jsx.map +1 -1
  186. package/dist/solid/ward-first.d.ts +21 -0
  187. package/dist/solid/ward-first.d.ts.map +1 -0
  188. package/dist/solid/ward-first.js +50 -0
  189. package/dist/solid/ward-first.js.map +1 -0
  190. package/dist/solid/ward-keys.d.ts +13 -12
  191. package/dist/solid/ward-keys.d.ts.map +1 -1
  192. package/dist/solid/ward.d.ts +49 -0
  193. package/dist/solid/ward.d.ts.map +1 -1
  194. package/dist/solid/ward.jsx +31 -6
  195. package/dist/solid/ward.jsx.map +1 -1
  196. package/package.json +5 -4
  197. package/src/batch-reorder-group.tsx +3 -2
  198. package/src/complete.tsx +16 -9
  199. package/src/create-batch.tsx +19 -3
  200. package/src/drag-sensor.tsx +54 -6
  201. package/src/element.tsx +3 -1
  202. package/src/focus-sensor.tsx +33 -6
  203. package/src/frame-effect.tsx +122 -0
  204. package/src/hover-sensor.tsx +25 -6
  205. package/src/index.tsx +46 -0
  206. package/src/lifecycle.ts +13 -0
  207. package/src/presence-hooks.tsx +5 -3
  208. package/src/press-sensor.tsx +30 -6
  209. package/src/provider.tsx +7 -4
  210. package/src/sensors.tsx +67 -2
  211. package/src/solid-reactivity.ts +8 -0
  212. package/src/stage-batch.ts +89 -0
  213. package/src/stage-graph.ts +264 -0
  214. package/src/stage-hooks.ts +100 -0
  215. package/src/stage-ward.tsx +795 -0
  216. package/src/stage.ts +337 -0
  217. package/src/unstable/v2/index.tsx +96 -0
  218. package/src/v1/index.tsx +1 -1
  219. package/src/w.tsx +22 -5
  220. package/src/ward-first.ts +67 -0
  221. package/src/ward-keys.ts +14 -13
  222. package/src/ward.tsx +42 -6
@@ -0,0 +1,122 @@
1
+ /**
2
+ * `createFrameEffect(compute, apply)`: an app's own code in Wardic's frame (a **Frame effect**), after
3
+ * Wardic's writes for it and before the frame is drawn. On the DOM, after the Flush gate's commit and
4
+ * before paint.
5
+ *
6
+ * - **compute** reads Live values and signals, tracked. It runs again once something it read changes:
7
+ * a Live value that moved in the frame, or a signal written since the last.
8
+ * - **apply** runs at the end of the frame after each run of compute, given its value, untracked. What it
9
+ * returns runs before its next apply, and when its owner is disposed.
10
+ *
11
+ * Frame effects run in the order they were made. Every frame needs no hook of its own: `createTime()` read
12
+ * in compute. Solid's own effect runs on Solid's schedule instead, after the frame is drawn. Under a
13
+ * `<WardicStage>`, it runs in the Stage's Host loop, before the scene renders.
14
+ *
15
+ * @example
16
+ * createFrameEffect(() => target.read("x")(), (x) => {
17
+ * label.style.transform = `translateX(${x}px)`
18
+ * })
19
+ * @see https://wardic.dev/reference/solid/live-values/create-frame-effect
20
+ */
21
+ // #884's PR 1 (ADR-0073 decision 19, *Amendment (#882)*'s Q3): the DOM's slot is core's
22
+ // `FrameEffects.onFrameLoop`, one a runtime, open while a Frame effect lives. A Live value reaches Solid as
23
+ // a signal set from its Atom, which Solid holds until a microtask (`followAtom`): each effect calls
24
+ // `flush()` first, so what the frame moved reaches its compute in the frame, not the next.
25
+ import { isServer } from "@solidjs/web"
26
+ import * as FrameEffects from "@wardic/core/unstable/FrameEffects"
27
+ import * as Report from "@wardic/dom/Report"
28
+ import * as OwnerScope from "@wardic/dom/unstable/OwnerScope"
29
+ import * as Cause from "effect/Cause"
30
+ import * as Predicate from "effect/Predicate"
31
+ import * as Scope from "effect/Scope"
32
+ import { createEffect, flush, onCleanup, untrack, useContext } from "solid-js"
33
+ import { useWardicRuntime } from "./provider.tsx"
34
+ import { CLIENT_ONLY } from "./solid-reactivity.ts"
35
+ import { WardicStage } from "./stage.ts"
36
+ import type { WardicRuntime } from "./runtime.ts"
37
+
38
+ const CLOSE_FAILED = "wardic.createFrameEffect: a finalizer failed"
39
+
40
+ /** A runtime's Frame effects, while one lives: core's slot, and the Scope it's on. */
41
+ interface Slot {
42
+ readonly effects: FrameEffects.FrameEffects
43
+ readonly scope: Scope.Closeable
44
+ live: number
45
+ }
46
+
47
+ /** Each runtime's slot, made at its first Frame effect and closed after its last. */
48
+ // Module state (#460, Q7): held weakly by the runtime.
49
+ const SLOTS = new WeakMap<WardicRuntime, Slot>()
50
+
51
+ /** `runtime`'s slot, made now if it has none. */
52
+ const slotOf = (runtime: WardicRuntime): Slot => {
53
+ const known = SLOTS.get(runtime)
54
+ if (Predicate.isNotUndefined(known)) return known
55
+ const scope = OwnerScope.open(runtime)
56
+ const report = (defect: unknown): void => void runtime.runFork(Report.failure("wardic.createFrameEffect: an apply failed", Cause.die(defect)))
57
+ const effects = runtime.runSync(FrameEffects.onFrameLoop(report).pipe(Scope.provide(scope)))
58
+ const made: Slot = { effects, scope, live: 0 }
59
+ SLOTS.set(runtime, made)
60
+ return made
61
+ }
62
+
63
+ /** `slot` let go of one Frame effect: closed with the last. */
64
+ const release = (runtime: WardicRuntime, slot: Slot): void => {
65
+ slot.live--
66
+ if (slot.live > 0) return
67
+ SLOTS.delete(runtime)
68
+ OwnerScope.close(runtime, slot.scope, CLOSE_FAILED)
69
+ }
70
+
71
+ /** The DOM provider's slot for one Frame effect: held until its owner is disposed. */
72
+ const domEffects = (): Pick<FrameEffects.FrameEffects, "add" | "request"> => {
73
+ const runtime = useWardicRuntime()
74
+ const slot = slotOf(runtime)
75
+ slot.live++
76
+ onCleanup(() => release(runtime, slot))
77
+ return slot.effects
78
+ }
79
+
80
+ /** The Frame effects a Frame effect made here joins: its Stage's, else the DOM provider's. */
81
+ const effectsHere = (): Pick<FrameEffects.FrameEffects, "add" | "request"> => {
82
+ const stage = useContext(WardicStage)
83
+ if (Predicate.isNotNull(stage)) return stage.frameEffects
84
+ return domEffects()
85
+ }
86
+
87
+ /** Runs `apply` in Wardic's frame, after its writes and before the frame is drawn, each time `compute`'s value is new. */
88
+ export const createFrameEffect = <T,>(compute: () => T, apply: (value: T) => void | (() => void)): void => {
89
+ if (isServer) return
90
+ // Under a Stage, its Host loop's (#884's PR 3); else the DOM provider's.
91
+ const effects = effectsHere()
92
+ let due = false
93
+ let value: T
94
+ let cleanup: (() => void) | undefined
95
+ // compute, tracked on Solid's own schedule: it only marks the effect due, and asks for a frame.
96
+ createEffect(
97
+ compute,
98
+ (next) => {
99
+ value = next
100
+ due = true
101
+ effects.request()
102
+ },
103
+ CLIENT_ONLY,
104
+ )
105
+ const remove = effects.add(() => {
106
+ // What this frame moved, a Live value's signal among it, given to Solid now (see the header).
107
+ flush()
108
+ if (!due) return
109
+ due = false
110
+ const ending = cleanup
111
+ cleanup = undefined
112
+ if (Predicate.isNotUndefined(ending)) ending()
113
+ const returned = untrack(() => apply(value))
114
+ if (Predicate.isFunction(returned)) cleanup = returned
115
+ })
116
+ onCleanup(() => {
117
+ remove()
118
+ const ending = cleanup
119
+ cleanup = undefined
120
+ if (Predicate.isNotUndefined(ending)) ending()
121
+ })
122
+ }
@@ -8,23 +8,42 @@ import type * as Feature from "@wardic/dom/unstable/Feature"
8
8
  import * as Hover from "@wardic/dom/unstable/features/Hover"
9
9
  import * as Keys from "@wardic/dom/unstable/features/Keys"
10
10
  import * as GestureFeatures from "@wardic/dom/unstable/GestureFeatures"
11
+ import * as Predicate from "effect/Predicate"
12
+ import type { Accessor } from "solid-js"
11
13
  import { useBrought } from "./provider.tsx"
12
- import { type Sensor, watchSensorOf } from "./sensors.tsx"
14
+ import { type Sensor, type SensorTarget, stageSensorOf, told, wardSensorOf, watchSensorOf } from "./sensors.tsx"
15
+ import { watchHoverOnStage } from "./stage-hooks.ts"
16
+ import { isWard } from "./ward.tsx"
13
17
 
14
18
  /** What it brings (ADR-0067 decision 12): its gesture's Feature, whatever its section has (#511). */
15
19
  const HOVER: ReadonlyArray<Feature.Feature> = [Hover.hover]
16
20
 
21
+ /** `createHover`'s forms: a sensor to give to a `ref`; or, given its element or a ward first, its reading. */
22
+ export interface CreateHover {
23
+ (): Sensor<boolean>
24
+ (target: SensorTarget): Accessor<boolean>
25
+ }
26
+
17
27
  /**
18
28
  * `true` while the pointer is over the element it's given to as a `ref`, `false` once it leaves: a
19
- * hover as state, for what isn't an animation, where `whileHover` would do. A touch never hovers.
29
+ * hover as state, for what isn't an animation, where `whileHover` would do. A touch never hovers. Given
30
+ * its element first, it reads that one; given a ward, the ward's own hover; under a `<WardicStage>`, given
31
+ * one of its Subjects, the pointer over it in the scene.
20
32
  *
21
33
  * @example
22
34
  * const hovered = createHover()
23
35
  * <article ref={hovered}>{hovered() ? "Over" : "Away"}</article>
36
+ *
37
+ * const card = ward({ whileHover: { scale: 1.05 } })
38
+ * const over = createHover(card)
24
39
  * @see https://wardic.dev/reference/solid/gestures/create-hover
25
40
  */
26
- // The core hover watch.
27
- export const createHover = (): Sensor<boolean> => {
41
+ // The core hover watch; given a ward, its `hoverStart` and `hoverEnd` (#884); given a Stage's Subject, on
42
+ // the Stage's input (#884's PR 4), before the page's Feature is brought: a scene needs none.
43
+ export const createHover: CreateHover = ((target?: SensorTarget): Sensor<boolean> | Accessor<boolean> => {
44
+ const onStage = stageSensorOf("createHover", target, false, watchHoverOnStage)
45
+ if (Predicate.isNotUndefined(onStage)) return onStage
28
46
  const services = useBrought(HOVER)
29
- return watchSensorOf<boolean>((target, { on, onDefect }) => GestureFeatures.serviceOf(services(), Keys.HoverGesture).watch(target, { on: (transition) => on(transition.active), onDefect }), false)
30
- }
47
+ if (isWard(target)) return wardSensorOf(target, false, ({ lifecycle }, set) => [lifecycle.listen("hoverStart", told(() => set(true))), lifecycle.listen("hoverEnd", told(() => set(false)))])
48
+ return watchSensorOf<boolean>((element, { on, onDefect }) => GestureFeatures.serviceOf(services(), Keys.HoverGesture).watch(element, { on: (transition) => on(transition.active), onDefect }), false, target as Element | undefined)
49
+ }) as CreateHover
package/src/index.tsx CHANGED
@@ -76,6 +76,50 @@ export {
76
76
  type WardWithProps,
77
77
  } from "./ward.tsx"
78
78
  export { ward } from "./complete.tsx"
79
+ export type { HeldWard } from "./ward-first.ts"
80
+ /** A Stage (#884, ADR-0073 decisions 12 and 20): what runs a scene, found through its own Solid context. */
81
+ export {
82
+ type SceneObjectEvent,
83
+ type SceneObjectEvents,
84
+ type SceneObjectExit,
85
+ type SceneWard,
86
+ type Stage,
87
+ type StageBatch,
88
+ type StageBatchBinding,
89
+ type StageBatchEvents,
90
+ type StageBatchHooks,
91
+ type StageBatchMemberInfo,
92
+ type StageBatchMembers,
93
+ type StageBatchTarget,
94
+ type StageBatchValues,
95
+ type StageCountBatchConfig,
96
+ type StageDrag,
97
+ type StageDragConfig,
98
+ type StageDragHandlers,
99
+ type StageDragRange,
100
+ type StageDragTransition,
101
+ type StageEvent,
102
+ type StageEvents,
103
+ type StageKeyedBatchConfig,
104
+ type StageRead,
105
+ type StageReadKey,
106
+ type StageReads,
107
+ type StageSubject,
108
+ type StageSubjectOf,
109
+ type StageSubjects,
110
+ type StageValueKey,
111
+ type StageValueOf,
112
+ type StageValues,
113
+ type StageWard,
114
+ type StageWardChecked,
115
+ type StageWardConfig,
116
+ type StageWardConfigValues,
117
+ WardicStage,
118
+ } from "./stage.ts"
119
+ export { stageSceneObject, type StageMembership, stageWard, type StageWardEnvironment } from "./stage-ward.tsx"
120
+ // A Stage's hooks alone (#927), for an Environment's binding to re-export under the hooks' own names.
121
+ export { createBatchOnStage, createDragOnStage, createHoverOnStage, createPressOnStage, wardOnStage } from "./stage-hooks.ts"
122
+ export type { StageGraph } from "./stage-graph.ts"
79
123
  export type { WardDragInfo, WardElement, WardEvent, WardEvents, WardGestures, WardPoint, WardPointInfo, WardPressInfo, WardSettled } from "./lifecycle.ts"
80
124
  export type { WardicAnimationDefinition } from "@wardic/dom/unstable/WardConfig"
81
125
  export type { AnimatedKey, WardKey, WardValueOf } from "./ward-keys.ts"
@@ -244,6 +288,8 @@ export {
244
288
  createWillChange,
245
289
  } from "./live-value.tsx"
246
290
  export { createScroll, type ElementSource, type ScrollOptions, type ScrollValues } from "./live-scroll.tsx"
291
+ /** Frame effects (#884, ADR-0073 decision 19): an app's own code in Wardic's frame, after its writes and before paint. */
292
+ export { createFrameEffect } from "./frame-effect.tsx"
247
293
  export type { FollowAccessor, FollowValueOptions, Live, LiveSource, SpringAccessor, WillChange } from "@wardic/dom/unstable/LiveStyle"
248
294
 
249
295
  /**
package/src/lifecycle.ts CHANGED
@@ -26,6 +26,7 @@
26
26
  * @module
27
27
  */
28
28
  import * as Bool from "effect/Boolean"
29
+ import * as Iter from "effect/Iterable"
29
30
  import * as Predicate from "effect/Predicate"
30
31
  import { constUndefined, identity } from "effect/Function"
31
32
  import * as UndefinedOr from "effect/UndefinedOr"
@@ -298,6 +299,8 @@ export class Lifecycle implements Spine.AnimationHooks {
298
299
  private tapWaiting: ((tap: WardPressInfo | undefined) => void) | undefined = undefined
299
300
  // The `next(name)` calls waiting, made at the first; and whether the ward is gone.
300
301
  private events: Waiters<WardEvents> | undefined = undefined
302
+ // The drag sensors given the ward (#884), made at the first.
303
+ private samples: Set<(sample: Drag.Sample) => void> | undefined = undefined
301
304
  private disposed = false
302
305
  // The gestures a `next` has asked for, whose recognizers the ward runs from then on.
303
306
  private hover = false
@@ -415,6 +418,8 @@ export class Lifecycle implements Spine.AnimationHooks {
415
418
  * (#431) isn't, as Motion's `cancel` tells no `onDragEnd`.
416
419
  */
417
420
  dragged(sample: Drag.Sample, locked: boolean, element: WardElement): void {
421
+ // A sensor given the ward reads every sample, as one on its element would (#884).
422
+ UndefinedOr.map(this.samples, (heard) => Iter.forEach(heard, (listener) => listener(sample)))
418
423
  if (sample.cancelled === true) return
419
424
  if (Bool.and(locked, sample.phase === "start")) this.tell("directionLock", () => sample.axis as "x" | "y")
420
425
  this.moved(DRAG_EVENT[sample.phase], "drag", sample, element)
@@ -565,6 +570,14 @@ export class Lifecycle implements Spine.AnimationHooks {
565
570
  return stop
566
571
  }
567
572
 
573
+ /** Every drag sample from the call on, as a drag sensor given the ward reads them (#884): until the returned stop. */
574
+ readonly listenSamples = (listener: (sample: Drag.Sample) => void): (() => void) => {
575
+ if (Predicate.isUndefined(this.samples)) this.samples = new Set()
576
+ const heard = this.samples
577
+ heard.add(listener)
578
+ return () => void heard.delete(listener)
579
+ }
580
+
568
581
  /** `when(name)` (#355): every `name`, as a memo for an effect: see `whenOf`. */
569
582
  when<E extends WardEvent>(name: E): Accessor<WardEvents[E]> {
570
583
  return whenOf<WardEvents, E>(this, name)
@@ -120,12 +120,14 @@ export const usePresence = (): PresenceExit => {
120
120
 
121
121
  /**
122
122
  * Whether a child of `<AnimatePresence>` is still present: `false` from its leave on, while its exit
123
- * plays. Give it to `ref` on an element in the child, and call it to read. Outside a presence, always
124
- * `true`. Motion's `useIsPresent`.
123
+ * plays. Give it to `ref` on an element in the child, and call it to read. The child's own bindings and
124
+ * effects are disposed by its leave, so one that reads it never sees `false`: read it where code still
125
+ * runs on the retained element, an event handler or a timer. To act as the child leaves, use
126
+ * `usePresence()`'s `next("leave")`. Outside a presence, always `true`. Motion's `useIsPresent`.
125
127
  *
126
128
  * @example
127
129
  * const present = useIsPresent()
128
- * <button ref={present} disabled={!present()}>Save</button>
130
+ * <button ref={present} onClick={() => present() && save()}>Save</button>
129
131
  * @see https://wardic.dev/reference/solid/presence/use-is-present
130
132
  */
131
133
  export const useIsPresent = (): IsPresent => {
@@ -8,24 +8,48 @@ import type * as Feature from "@wardic/dom/unstable/Feature"
8
8
  import * as Press from "@wardic/dom/unstable/features/Press"
9
9
  import * as Keys from "@wardic/dom/unstable/features/Keys"
10
10
  import * as GestureFeatures from "@wardic/dom/unstable/GestureFeatures"
11
+ import * as Predicate from "effect/Predicate"
12
+ import type { Accessor } from "solid-js"
11
13
  import { useBrought } from "./provider.tsx"
12
- import { type Sensor, watchSensorOf } from "./sensors.tsx"
14
+ import { type Sensor, type SensorTarget, stageSensorOf, told, wardSensorOf, watchSensorOf } from "./sensors.tsx"
15
+ import { watchPressOnStage } from "./stage-hooks.ts"
16
+ import { isWard } from "./ward.tsx"
13
17
 
14
18
  /** What it brings (ADR-0067 decision 12): its gesture's Feature, whatever its section has (#511). */
15
19
  const PRESS: ReadonlyArray<Feature.Feature> = [Press.press]
16
20
 
21
+ /** `createPress`'s forms: a sensor to give to a `ref`; or, given its element or a ward first, its reading. */
22
+ export interface CreatePress {
23
+ (): Sensor<boolean>
24
+ (target: SensorTarget): Accessor<boolean>
25
+ }
26
+
17
27
  /**
18
28
  * `true` while the element it's given to as a `ref` is pressed, by a pointer held down on it or by
19
29
  * Enter or Space while it has focus, `false` once it's released or the press is cancelled. An element
20
- * that takes no focus of itself is given `tabindex="0"`, so a keyboard can press it.
30
+ * that takes no focus of itself is given `tabindex="0"`, so a keyboard can press it. Given its element
31
+ * first, it reads that one; given a ward, the ward's own press, which a drag ends; under a `<WardicStage>`,
32
+ * given one of its Subjects, a pointer pressed on it in the scene.
21
33
  *
22
34
  * @example
23
35
  * const pressed = createPress()
24
36
  * <button ref={pressed}>{pressed() ? "Holding" : "Press and hold"}</button>
25
37
  * @see https://wardic.dev/reference/solid/gestures/create-press
26
38
  */
27
- // The core press watch; a Keyboard press (#427).
28
- export const createPress = (): Sensor<boolean> => {
39
+ // The core press watch; a Keyboard press (#427). Given a ward, its `pressStart`, `tap` and `tapCancel`
40
+ // (#884), and its `dragStart`: a press a drag takes over tells neither of the others. Given a Stage's
41
+ // Subject, on the Stage's input, a pointer's alone (#884's PR 4): a scene's object takes no focus.
42
+ export const createPress: CreatePress = ((target?: SensorTarget): Sensor<boolean> | Accessor<boolean> => {
43
+ const onStage = stageSensorOf("createPress", target, false, watchPressOnStage)
44
+ if (Predicate.isNotUndefined(onStage)) return onStage
29
45
  const services = useBrought(PRESS)
30
- return watchSensorOf<boolean>((target, { on, onDefect }) => GestureFeatures.serviceOf(services(), Keys.PressGesture).watch(target, { on: (press) => on(press.phase === "start"), onDefect }), false)
31
- }
46
+ if (isWard(target)) {
47
+ return wardSensorOf(target, false, ({ lifecycle }, set) => [
48
+ lifecycle.listen("pressStart", told(() => set(true))),
49
+ lifecycle.listen("tap", told(() => set(false))),
50
+ lifecycle.listen("tapCancel", told(() => set(false))),
51
+ lifecycle.listen("dragStart", told(() => set(false))),
52
+ ])
53
+ }
54
+ return watchSensorOf<boolean>((element, { on, onDefect }) => GestureFeatures.serviceOf(services(), Keys.PressGesture).watch(element, { on: (press) => on(press.phase === "start"), onDefect }), false, target as Element | undefined)
55
+ }) as CreatePress
package/src/provider.tsx CHANGED
@@ -59,7 +59,7 @@ import {
59
59
  import type * as ElementSetup from "@wardic/dom/unstable/ElementSetup"
60
60
  import { WAITING_ENV_FIX, WAITING_ENV_LINE } from "./messages.ts"
61
61
  import { warnWithoutSpans } from "./spans-check.ts"
62
- import { onSettledClientOnly, reactivityIn } from "./solid-reactivity.ts"
62
+ import { onSettledClientOnly, reactivityIn, untracked } from "./solid-reactivity.ts"
63
63
  import { useWardicConfig } from "./wardic-config.tsx"
64
64
  import * as WardicConfigValue from "@wardic/core/unstable/WardicConfigValue"
65
65
  import * as Instant from "@wardic/dom/unstable/Instant"
@@ -406,9 +406,11 @@ export function useWardicDefaultTransition(): DefaultTransition.DefaultTransitio
406
406
  * Whether reduced motion applies now (ADR-0029): the nearest `WardicConfig`'s `reducedMotion` (#434),
407
407
  * else the provider's, and the user's preference; always `false` during a server render. Internal.
408
408
  */
409
+ // Untracked: read as each animation starts, an exit's in its presence's effect apply among them, where
410
+ // a config's `reducedMotion={signal()}` was Solid 2's STRICT_READ_UNTRACKED.
409
411
  export function useWardicReducedMotion(): () => boolean {
410
412
  const config = useWardicConfig()
411
- return fromContext(contextValue(), "useWardicReducedMotion", (value) => reducedMotionWith(value, config))
413
+ return fromContext(contextValue(), "useWardicReducedMotion", (value) => untracked(reducedMotionWith(value, config)))
412
414
  }
413
415
 
414
416
  /**
@@ -416,12 +418,13 @@ export function useWardicReducedMotion(): () => boolean {
416
418
  * `skipAnimations`, or the provider's Instant change while one runs (#443). Read when each starts.
417
419
  * Internal.
418
420
  */
421
+ // Untracked, as `useWardicReducedMotion`: a config's `skipAnimations={signal()}` is read as each starts.
419
422
  export function useWardicSkipAnimations(): () => boolean {
420
423
  const config = WardicConfigValue.skipAnimationsOf(useWardicConfig())
421
424
  const value = contextValue()
422
- if (Predicate.isUndefined(value)) return config
425
+ if (Predicate.isUndefined(value)) return untracked(config)
423
426
  const instant = value.instant
424
- return () => Bool.or(instant.active(), config())
427
+ return untracked(() => Bool.or(instant.active(), config()))
425
428
  }
426
429
 
427
430
  /**
package/src/sensors.tsx CHANGED
@@ -8,6 +8,10 @@
8
8
  * <div ref={hovered}>{hovered() ? "in" : "out"}</div>
9
9
  * ```
10
10
  *
11
+ * Or give it its element, or a ward, first: `createHover(el)` reads `el`, and `createHover(card)` reads the
12
+ * ward's own recognizer, which `card`'s `when` would start, so nothing listens to its element twice
13
+ * (#884). Then it's an accessor alone.
14
+ *
11
15
  * Each wraps a core recognizer (ADR-0006): attached, it runs on the provider's runtime until the
12
16
  * sensor's owner is disposed or it's given another element. Each is a watch (#318, #379, ADR-0055),
13
17
  * in a Scope of its own with no fiber. Its value starts at its rest (`false`,
@@ -18,19 +22,27 @@
18
22
  * @module
19
23
  */
20
24
  import type * as InputFeed from "@wardic/core/InputFeed"
25
+ import * as InputSource from "@wardic/core/InputSource"
21
26
  import * as Probe from "@wardic/core/Probe"
22
27
  import * as Recognizer from "@wardic/core/Recognizer"
23
28
  import * as ReducedMotion from "@wardic/core/ReducedMotion"
24
29
  import * as Report from "@wardic/dom/Report"
25
30
  import type * as Cause from "effect/Cause"
31
+ import * as Arr from "effect/Array"
32
+ import * as Bool from "effect/Boolean"
26
33
  import * as Effect from "effect/Effect"
34
+ import * as Exit from "effect/Exit"
35
+ import { constVoid } from "effect/Function"
27
36
  import * as Scope from "effect/Scope"
28
37
  import * as Predicate from "effect/Predicate"
29
38
  import * as UndefinedOr from "effect/UndefinedOr"
30
39
  import { isServer } from "@solidjs/web"
31
- import { type Accessor, createSignal, onCleanup } from "solid-js"
40
+ import { type Accessor, createSignal, DEV, onCleanup, useContext } from "solid-js"
32
41
  import type * as WardConfig from "@wardic/dom/unstable/WardConfig"
33
42
  import { inViewOptionsOf } from "./gesture-callbacks.ts"
43
+ import type { Listener } from "./waiters.ts"
44
+ import { type StageSubject, WardicStage } from "./stage.ts"
45
+ import { type AnyWard, isWard, type Sensed, sensedOf } from "./ward.tsx"
34
46
  import * as OwnerScope from "@wardic/dom/unstable/OwnerScope"
35
47
  import type { WardicServices } from "./runtime.ts"
36
48
  import { fromAtom } from "./bridge.tsx"
@@ -50,7 +62,57 @@ export interface Sensor<A> {
50
62
  }
51
63
 
52
64
  /** Whether a sensor's call is Solid applying it as a ref. */
53
- const isElement = (value: unknown): value is Element => Predicate.hasProperty(value, "nodeType")
65
+ export const isElement = (value: unknown): value is Element => Predicate.hasProperty(value, "nodeType")
66
+
67
+ /** What a sensor of the page takes first, when it isn't its call form: an element, or a ward whose own recognizer it reads (#884). */
68
+ export type PageTarget = Element | AnyWard
69
+
70
+ /** What `createHover` and `createPress` take first: what {@link PageTarget} is, or, under a `<WardicStage>`, one of its Subjects (#884). */
71
+ export type SensorTarget = PageTarget | StageSubject
72
+
73
+ /**
74
+ * A sensor of a Stage's Subject (#884's PR 4): `watchOf` on the Stage's input from the call on, ended with
75
+ * its owner. `undefined` for an element or a ward, which are the page's; anything else no `<WardicStage>`
76
+ * above takes is an error in development, naming it.
77
+ */
78
+ export const stageSensorOf = <A,>(
79
+ name: string,
80
+ target: unknown,
81
+ initial: A,
82
+ watchOf: (subject: unknown, handlers: InputFeed.Handlers<A>) => Effect.Effect<void, never, Scope.Scope | InputSource.InputSource>,
83
+ ): Accessor<A> | undefined => {
84
+ if (Bool.some([isServer, Predicate.isUndefined(target), isElement(target), isWard(target)])) return undefined
85
+ const stage = useContext(WardicStage)
86
+ if (Bool.or(Predicate.isNull(stage), Bool.not(Predicate.isNotNull(stage) && stage.isSubject(target)))) {
87
+ if (DEV) throw new Error(`${name}(subject): it was given neither an element nor a ward, and no <WardicStage> above it takes it as one of its Subjects.`)
88
+ return undefined
89
+ }
90
+ const [value, setValue] = createSignal<A>(initial as Exclude<A, Function>)
91
+ const scope = Scope.makeUnsafe()
92
+ onCleanup(() => Effect.runSync(Scope.close(scope, Exit.void)))
93
+ const onDefect = (cause: Cause.Cause<never>): void => {
94
+ Effect.runFork(Report.failure(`wardic.${name}: a gesture handler failed`, cause))
95
+ }
96
+ const watch = watchOf(target, { on: (next) => setValue(() => next as Exclude<A, Function>), onDefect })
97
+ Effect.runSync(watch.pipe(Effect.provideService(InputSource.InputSource, (stage as NonNullable<typeof stage>).input), Scope.provide(scope)))
98
+ return value
99
+ }
100
+
101
+ /** A sensor of a ward: its reading, set by `listen` from the ward's own events (#884's PR 2). */
102
+ // `listen` subscribes to the ward's lifecycle, which starts the gesture's recognizer as `when` would: the
103
+ // ward's own, so nothing listens to its element twice. A server ward has no lifecycle: it rests there.
104
+ export const wardSensorOf = <A,>(ward: AnyWard, initial: A, listen: (sensed: Sensed, set: (next: A) => void) => ReadonlyArray<() => void>): Accessor<A> => {
105
+ if (isServer) return () => initial
106
+ const sensed = sensedOf(ward)
107
+ if (Predicate.isUndefined(sensed)) return () => initial
108
+ const [value, setValue] = createSignal<A>(initial as Exclude<A, Function>)
109
+ const stops = listen(sensed, (next) => setValue(() => next as Exclude<A, Function>))
110
+ onCleanup(() => Arr.forEach(stops, (stop) => stop()))
111
+ return value
112
+ }
113
+
114
+ /** A ward event's listener for a sensor: each told as `on` maps it, the ward's end ending nothing more. */
115
+ export const told = <E,>(on: (event: E) => void): Listener<E> => ({ next: on, error: constVoid })
54
116
 
55
117
 
56
118
  /**
@@ -61,6 +123,7 @@ const isElement = (value: unknown): value is Element => Predicate.hasProperty(va
61
123
  export const watchSensorOf = <A,>(
62
124
  watchOf: (target: Element, handlers: InputFeed.Handlers<A>) => Effect.Effect<void, never, Scope.Scope | WardicServices>,
63
125
  initial: A,
126
+ target?: Element,
64
127
  ): Sensor<A> => {
65
128
  // A server never calls a ref: the sensor rests where it starts.
66
129
  if (isServer) return ((): A => initial) as Sensor<A>
@@ -84,6 +147,8 @@ export const watchSensorOf = <A,>(
84
147
  attached = { element, scope }
85
148
  runtime.runSync(watchOf(element, { on: (next) => setValue(() => next as Exclude<A, Function>), onDefect }).pipe(Scope.provide(scope)))
86
149
  }
150
+ // Given its element first (#884): attached now.
151
+ if (Predicate.isNotUndefined(target)) attach(target)
87
152
  // eslint-disable-next-line solid/reactivity -- the sensor: a ref Solid calls with its element, and an accessor its caller reads where it tracks
88
153
  return ((element?: unknown): A | undefined => {
89
154
  if (isElement(element)) {
@@ -62,6 +62,14 @@ const SETTLED = { name: "onSettled", ...CLIENT_ONLY }
62
62
  */
63
63
  export const onSettledClientOnly = (callback: () => void | (() => void)): void => createTrackedEffect(() => untrack(callback), SETTLED)
64
64
 
65
+ /**
66
+ * `read`, read untracked at each call: for a setting read as each animation starts (ADR-0029, #468),
67
+ * often in an effect's apply, where Solid 2 reports a reactive read (STRICT_READ_UNTRACKED). A
68
+ * `WardicConfig` prop from a signal is such a read: a one-time read, which this says. Allocates
69
+ * nothing per call.
70
+ */
71
+ export const untracked = <A>(read: () => A): (() => A) => () => untrack(read)
72
+
65
73
  /** Solid 2's reactive primitives, a watch made under `owner`. */
66
74
  export const reactivityIn = (owner: Owner | null): Reactivity.Reactivity => ({
67
75
  untrack,
@@ -0,0 +1,89 @@
1
+ /**
2
+ * `createBatch` in a scene (#885's PR 5; ADR-0073 decision 16, *Amendment (#885)* Q9): a config with
3
+ * `object` or `instances` goes to the Stage in context, whose `batch` adds, moves and removes its members.
4
+ * Its landings and its members' gestures are told here, as a page's Batch's are, and its targets are read
5
+ * by an effect's compute and handed over in its apply (ADR-0070 decision 11, Shape B).
6
+ *
7
+ * @module
8
+ */
9
+ // #885's PR 5: the DOM's `createBatch` carries only the check that comes here.
10
+ import { isServer } from "@solidjs/web"
11
+ import * as Option from "effect/Option"
12
+ import * as Predicate from "effect/Predicate"
13
+ import * as UndefinedOr from "effect/UndefinedOr"
14
+ import { createEffect, DEV, onCleanup, untrack, useContext } from "solid-js"
15
+ import { flightsOf } from "./flights.ts"
16
+ import { CLIENT_ONLY } from "./solid-reactivity.ts"
17
+ import { type StageBatch, type StageBatchEvents, type StageCountBatchConfig, type StageKeyedBatchConfig, WardicStage } from "./stage.ts"
18
+ import { neverLands, serverWhen, Waiters, whenOf } from "./waiters.ts"
19
+
20
+ /** Whether a Batch's config is a scene's: its members `object`s or `instances`. */
21
+ export const isStageBatch = (config: object): boolean => Predicate.hasProperty(config, "object") || Predicate.hasProperty(config, "instances")
22
+
23
+ /** No Stage above that makes Batches. */
24
+ const NO_STAGE_BATCH =
25
+ "createBatch({ object | instances }): no Stage above it makes a scene's Batches: put it under a <WardicStage value={stage}> whose Stage has `batch`. With `@wardic/three/solid`, give `createStage` the feature: `createStage({ …, features: [stageBatches] })`."
26
+
27
+ /** The gesture each event is: what asking for one watches. */
28
+ const GESTURE_OF: Readonly<Record<keyof StageBatchEvents, "hover" | "press" | undefined>> = {
29
+ settled: undefined,
30
+ hoverStart: "hover",
31
+ hoverEnd: "hover",
32
+ pressStart: "press",
33
+ tap: "press",
34
+ tapCancel: "press",
35
+ }
36
+
37
+ /** A Batch that moves nothing: a server's, where a scene draws nothing. */
38
+ const INERT: StageBatch = {
39
+ settled: () => undefined,
40
+ next: () => neverLands(),
41
+ when: <E extends keyof StageBatchEvents>() => serverWhen<StageBatchEvents[E]>(),
42
+ }
43
+
44
+ /** A scene's Batch, made by the Stage in context. */
45
+ export const stageBatchOf = (config: StageKeyedBatchConfig<unknown> | StageCountBatchConfig): StageBatch => {
46
+ if (isServer) return INERT
47
+ const stage = useContext(WardicStage)
48
+ const batch = UndefinedOr.match(Option.getOrUndefined(Option.fromNullishOr(stage)), { onUndefined: () => undefined, onDefined: (given) => given.batch })
49
+ if (Predicate.isUndefined(batch)) {
50
+ if (DEV) throw new Error(NO_STAGE_BATCH)
51
+ return INERT
52
+ }
53
+ const flights = flightsOf<StageBatchEvents["settled"]>()
54
+ const events = new Waiters<StageBatchEvents>("The Batch was disposed before its next event.")
55
+ // Its first targets read untracked, wherever it's called: what tracks them is its own effect.
56
+ const binding = untrack(() =>
57
+ batch(config, {
58
+ started: () => flights.started(),
59
+ landed: (landing) => {
60
+ flights.ended(landing)
61
+ events.tell("settled", () => landing)
62
+ },
63
+ gesture: (name, info) => events.tell(name, () => info as never),
64
+ }),
65
+ )
66
+ if (Predicate.isNotUndefined(config.whileHover)) binding.listen("hover")
67
+ if (Predicate.isNotUndefined(config.whileTap)) binding.listen("press")
68
+ /** Asking for `name`: its gesture watched from now on, if it's one. */
69
+ const asked = (name: keyof StageBatchEvents): void => {
70
+ UndefinedOr.map(GESTURE_OF[name], binding.listen)
71
+ }
72
+ // Applied from its first run, at mount: its members are its own to make, as a Scene object joins then.
73
+ createEffect(binding.targetsOf, binding.apply, CLIENT_ONLY)
74
+ onCleanup(() => {
75
+ binding.dispose()
76
+ events.dispose()
77
+ })
78
+ return {
79
+ settled: flights.read,
80
+ next: (name) => {
81
+ asked(name)
82
+ return events.wait(name)
83
+ },
84
+ when: (name) => {
85
+ asked(name)
86
+ return whenOf(events, name)
87
+ },
88
+ }
89
+ }