@wardic/core 1.3.2 → 1.5.0-next.0

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 (237) hide show
  1. package/dist/Arc.d.ts +2 -2
  2. package/dist/Arc.js +1 -1
  3. package/dist/BaseValue.d.ts +11 -10
  4. package/dist/BaseValue.d.ts.map +1 -1
  5. package/dist/BaseValue.js +12 -15
  6. package/dist/BaseValue.js.map +1 -1
  7. package/dist/Batch.d.ts +15 -5
  8. package/dist/Batch.d.ts.map +1 -1
  9. package/dist/Batch.js +218 -20
  10. package/dist/Batch.js.map +1 -1
  11. package/dist/Clock.d.ts +7 -7
  12. package/dist/Clock.d.ts.map +1 -1
  13. package/dist/Clock.js +17 -16
  14. package/dist/Clock.js.map +1 -1
  15. package/dist/DefaultTransition.d.ts +3 -2
  16. package/dist/DefaultTransition.d.ts.map +1 -1
  17. package/dist/DefaultTransition.js +5 -3
  18. package/dist/DefaultTransition.js.map +1 -1
  19. package/dist/Drag.d.ts +24 -9
  20. package/dist/Drag.d.ts.map +1 -1
  21. package/dist/Drag.js +10 -10
  22. package/dist/Drag.js.map +1 -1
  23. package/dist/DragActivity.js +3 -3
  24. package/dist/DragRecognizer.d.ts +8 -6
  25. package/dist/DragRecognizer.d.ts.map +1 -1
  26. package/dist/DragRecognizer.js +51 -16
  27. package/dist/DragRecognizer.js.map +1 -1
  28. package/dist/Easing.d.ts +1 -1
  29. package/dist/Easing.js +1 -1
  30. package/dist/Frame.d.ts.map +1 -1
  31. package/dist/Frame.js +5 -3
  32. package/dist/Frame.js.map +1 -1
  33. package/dist/InputFeed.d.ts +1 -1
  34. package/dist/InputFeed.js +2 -2
  35. package/dist/InputSource.d.ts +9 -3
  36. package/dist/InputSource.d.ts.map +1 -1
  37. package/dist/InputSource.js +2 -2
  38. package/dist/InputSource.js.map +1 -1
  39. package/dist/Interpolator.d.ts +2 -2
  40. package/dist/Interpolator.js +2 -2
  41. package/dist/InterpolatorRegistry.d.ts +29 -15
  42. package/dist/InterpolatorRegistry.d.ts.map +1 -1
  43. package/dist/InterpolatorRegistry.js +17 -8
  44. package/dist/InterpolatorRegistry.js.map +1 -1
  45. package/dist/LiveValue.d.ts +7 -6
  46. package/dist/LiveValue.d.ts.map +1 -1
  47. package/dist/LiveValue.js +45 -14
  48. package/dist/LiveValue.js.map +1 -1
  49. package/dist/Machine.d.ts +7 -4
  50. package/dist/Machine.d.ts.map +1 -1
  51. package/dist/Machine.js +146 -45
  52. package/dist/Machine.js.map +1 -1
  53. package/dist/Playback.d.ts.map +1 -1
  54. package/dist/Playback.js +6 -1
  55. package/dist/Playback.js.map +1 -1
  56. package/dist/Projection.d.ts +8 -19
  57. package/dist/Projection.d.ts.map +1 -1
  58. package/dist/Projection.js +3 -19
  59. package/dist/Projection.js.map +1 -1
  60. package/dist/Recognizer.d.ts +1 -1
  61. package/dist/Recognizer.d.ts.map +1 -1
  62. package/dist/Recognizer.js +22 -7
  63. package/dist/Recognizer.js.map +1 -1
  64. package/dist/ReducedMotion.d.ts +4 -4
  65. package/dist/ReducedMotion.js +6 -6
  66. package/dist/Renderer.d.ts +5 -5
  67. package/dist/Renderer.js +6 -6
  68. package/dist/Renderer.js.map +1 -1
  69. package/dist/Reorder.d.ts +12 -2
  70. package/dist/Reorder.d.ts.map +1 -1
  71. package/dist/Reorder.js +65 -37
  72. package/dist/Reorder.js.map +1 -1
  73. package/dist/ScrollSource.d.ts +1 -1
  74. package/dist/ScrollSource.d.ts.map +1 -1
  75. package/dist/Sequence.d.ts +1 -1
  76. package/dist/SharedSource.d.ts +3 -3
  77. package/dist/SharedSource.js +5 -5
  78. package/dist/SharedSource.js.map +1 -1
  79. package/dist/Spring.d.ts.map +1 -1
  80. package/dist/Spring.js +2 -1
  81. package/dist/Spring.js.map +1 -1
  82. package/dist/Values.d.ts +2 -2
  83. package/dist/Values.js +1 -1
  84. package/dist/index.d.ts +1 -1
  85. package/dist/index.js +1 -1
  86. package/dist/internal/carried.d.ts +13 -0
  87. package/dist/internal/carried.d.ts.map +1 -0
  88. package/dist/internal/carried.js +23 -0
  89. package/dist/internal/carried.js.map +1 -0
  90. package/dist/internal/firstSteps.d.ts +66 -0
  91. package/dist/internal/firstSteps.d.ts.map +1 -0
  92. package/dist/internal/firstSteps.js +107 -0
  93. package/dist/internal/firstSteps.js.map +1 -0
  94. package/dist/internal/frameLoop.d.ts +1 -1
  95. package/dist/internal/frameLoop.d.ts.map +1 -1
  96. package/dist/internal/frameLoop.js +102 -81
  97. package/dist/internal/frameLoop.js.map +1 -1
  98. package/dist/internal/lerpsNumbers.d.ts +11 -0
  99. package/dist/internal/lerpsNumbers.d.ts.map +1 -0
  100. package/dist/internal/lerpsNumbers.js +38 -0
  101. package/dist/internal/lerpsNumbers.js.map +1 -0
  102. package/dist/internal/options.d.ts +7 -7
  103. package/dist/internal/options.d.ts.map +1 -1
  104. package/dist/internal/options.js +10 -10
  105. package/dist/internal/options.js.map +1 -1
  106. package/dist/internal/projectionRest.d.ts +22 -0
  107. package/dist/internal/projectionRest.d.ts.map +1 -0
  108. package/dist/internal/projectionRest.js +20 -0
  109. package/dist/internal/projectionRest.js.map +1 -0
  110. package/dist/internal/stepper.d.ts +13 -2
  111. package/dist/internal/stepper.d.ts.map +1 -1
  112. package/dist/internal/stepper.js +16 -1
  113. package/dist/internal/stepper.js.map +1 -1
  114. package/dist/internal/tracing.d.ts +1 -1
  115. package/dist/internal/tracing.js +1 -1
  116. package/dist/unstable/AnimationControls.d.ts +37 -38
  117. package/dist/unstable/AnimationControls.d.ts.map +1 -1
  118. package/dist/unstable/AnimationControls.js +39 -36
  119. package/dist/unstable/AnimationControls.js.map +1 -1
  120. package/dist/unstable/AppearHandoff.d.ts +5 -5
  121. package/dist/unstable/AppearHandoff.d.ts.map +1 -1
  122. package/dist/unstable/BatchCalls.d.ts +2 -2
  123. package/dist/unstable/BatchCalls.js +5 -5
  124. package/dist/unstable/Config.d.ts +19 -19
  125. package/dist/unstable/Config.d.ts.map +1 -1
  126. package/dist/unstable/FirstSteps.d.ts +25 -0
  127. package/dist/unstable/FirstSteps.d.ts.map +1 -0
  128. package/dist/unstable/FirstSteps.js +2 -0
  129. package/dist/unstable/FirstSteps.js.map +1 -0
  130. package/dist/unstable/FlushGate.d.ts +53 -51
  131. package/dist/unstable/FlushGate.d.ts.map +1 -1
  132. package/dist/unstable/FlushGate.js +56 -49
  133. package/dist/unstable/FlushGate.js.map +1 -1
  134. package/dist/unstable/FrameEffects.d.ts +2 -2
  135. package/dist/unstable/FrameEffects.js +2 -2
  136. package/dist/unstable/FrameTime.d.ts +1 -1
  137. package/dist/unstable/FrameTime.js +1 -1
  138. package/dist/unstable/Imperative.d.ts +29 -9
  139. package/dist/unstable/Imperative.d.ts.map +1 -1
  140. package/dist/unstable/Imperative.js +79 -47
  141. package/dist/unstable/Imperative.js.map +1 -1
  142. package/dist/unstable/OwnValues.js +1 -1
  143. package/dist/unstable/PresenceRecord.d.ts +31 -27
  144. package/dist/unstable/PresenceRecord.d.ts.map +1 -1
  145. package/dist/unstable/PresenceRecord.js +8 -8
  146. package/dist/unstable/PresenceRecord.js.map +1 -1
  147. package/dist/unstable/Projector.d.ts +34 -0
  148. package/dist/unstable/Projector.d.ts.map +1 -0
  149. package/dist/unstable/Projector.js +9 -0
  150. package/dist/unstable/Projector.js.map +1 -0
  151. package/dist/unstable/Report.d.ts +1 -1
  152. package/dist/unstable/Report.js +1 -1
  153. package/dist/unstable/RetargetLegs.d.ts +1 -1
  154. package/dist/unstable/RetargetLegs.d.ts.map +1 -1
  155. package/dist/unstable/RetargetLegs.js +9 -8
  156. package/dist/unstable/RetargetLegs.js.map +1 -1
  157. package/dist/unstable/Spine.d.ts +81 -72
  158. package/dist/unstable/Spine.d.ts.map +1 -1
  159. package/dist/unstable/Spine.js +171 -164
  160. package/dist/unstable/Spine.js.map +1 -1
  161. package/dist/unstable/Stops.d.ts +3 -3
  162. package/dist/unstable/Stops.js +4 -4
  163. package/dist/unstable/Subject.d.ts +2 -2
  164. package/dist/unstable/Subject.js +2 -2
  165. package/dist/unstable/Timelines.d.ts +11 -11
  166. package/dist/unstable/Timelines.d.ts.map +1 -1
  167. package/dist/unstable/Timelines.js +3 -3
  168. package/dist/unstable/VariantTarget.d.ts +7 -7
  169. package/dist/unstable/VariantTarget.d.ts.map +1 -1
  170. package/dist/unstable/VariantTarget.js +11 -11
  171. package/dist/unstable/VariantTarget.js.map +1 -1
  172. package/dist/unstable/VariantTree.d.ts +43 -36
  173. package/dist/unstable/VariantTree.d.ts.map +1 -1
  174. package/dist/unstable/VariantTree.js +34 -34
  175. package/dist/unstable/VariantTree.js.map +1 -1
  176. package/dist/unstable/WardicConfigValue.d.ts +13 -13
  177. package/dist/unstable/WardicConfigValue.d.ts.map +1 -1
  178. package/dist/unstable/WardicConfigValue.js +4 -4
  179. package/dist/unstable/WardicConfigValue.js.map +1 -1
  180. package/package.json +1 -1
  181. package/src/Arc.ts +3 -3
  182. package/src/BaseValue.ts +18 -21
  183. package/src/Batch.ts +236 -22
  184. package/src/Clock.ts +18 -17
  185. package/src/DefaultTransition.ts +5 -3
  186. package/src/Drag.ts +32 -14
  187. package/src/DragActivity.ts +3 -3
  188. package/src/DragRecognizer.ts +65 -23
  189. package/src/Easing.ts +1 -1
  190. package/src/Frame.ts +5 -3
  191. package/src/InputFeed.ts +2 -2
  192. package/src/InputSource.ts +12 -5
  193. package/src/Interpolator.ts +3 -3
  194. package/src/InterpolatorRegistry.ts +22 -13
  195. package/src/LiveValue.ts +47 -17
  196. package/src/Machine.ts +199 -61
  197. package/src/Playback.ts +5 -1
  198. package/src/Projection.ts +10 -28
  199. package/src/Recognizer.ts +24 -8
  200. package/src/ReducedMotion.ts +6 -6
  201. package/src/Renderer.ts +6 -6
  202. package/src/Reorder.ts +84 -38
  203. package/src/ScrollSource.ts +1 -1
  204. package/src/Sequence.ts +1 -1
  205. package/src/SharedSource.ts +5 -5
  206. package/src/Spring.ts +2 -1
  207. package/src/Values.ts +2 -2
  208. package/src/index.ts +1 -1
  209. package/src/internal/carried.ts +22 -0
  210. package/src/internal/firstSteps.ts +139 -0
  211. package/src/internal/frameLoop.ts +103 -87
  212. package/src/internal/lerpsNumbers.ts +53 -0
  213. package/src/internal/options.ts +10 -10
  214. package/src/internal/projectionRest.ts +31 -0
  215. package/src/internal/stepper.ts +20 -2
  216. package/src/internal/tracing.ts +1 -1
  217. package/src/unstable/AnimationControls.ts +59 -56
  218. package/src/unstable/AppearHandoff.ts +6 -6
  219. package/src/unstable/BatchCalls.ts +5 -5
  220. package/src/unstable/Config.ts +19 -19
  221. package/src/unstable/FirstSteps.ts +26 -0
  222. package/src/unstable/FlushGate.ts +92 -82
  223. package/src/unstable/FrameEffects.ts +2 -2
  224. package/src/unstable/FrameTime.ts +1 -1
  225. package/src/unstable/Imperative.ts +126 -56
  226. package/src/unstable/OwnValues.ts +1 -1
  227. package/src/unstable/PresenceRecord.ts +34 -30
  228. package/src/unstable/Projector.ts +45 -0
  229. package/src/unstable/Report.ts +1 -1
  230. package/src/unstable/RetargetLegs.ts +10 -9
  231. package/src/unstable/Spine.ts +210 -201
  232. package/src/unstable/Stops.ts +6 -6
  233. package/src/unstable/Subject.ts +2 -2
  234. package/src/unstable/Timelines.ts +12 -12
  235. package/src/unstable/VariantTarget.ts +13 -13
  236. package/src/unstable/VariantTree.ts +50 -43
  237. package/src/unstable/WardicConfigValue.ts +13 -13
@@ -1,22 +1,22 @@
1
1
  /**
2
2
  * **Animation controls** (#433's PR 3, CONTEXT.md; Motion's `useAnimationControls`), on every binding:
3
- * one object made outside any component and given as `animate={controls}` to any number of Wardic
4
- * elements, which follow its calls.
3
+ * one object made outside any component and given as `animate={controls}` to any number of Wards'
4
+ * Subjects, which follow its calls.
5
5
  *
6
- * - **`start(definition, transitionOverride)`** sets each element's `animate` entry (a **Controls
6
+ * - **`start(definition, transitionOverride)`** sets each Subject's `animate` entry (a **Controls
7
7
  * change**), so it Retargets, staggers its Variant children and lands as a change of the prop would.
8
- * It resolves once each element and the Variant children it hands its names to have landed.
9
- * - The override is the transition of that change: it beats the definition's own on the element and
8
+ * It resolves once each Subject and the Variant children it hands its names to have landed.
9
+ * - The override is the transition of that change: it beats the definition's own on the Subject and
10
10
  * on each Variant child, and it is their orchestration (stagger, `when`), as Motion's
11
11
  * `transitionOverride` is.
12
12
  * - Their next Retarget, a gesture's, runs on their own transitions again.
13
- * - **`set(definition)`** is an **Instant change**: the elements and their Variant children
13
+ * - **`set(definition)`** is an **Instant change**: the Subjects and their Variant children
14
14
  * snap there, as Motion's `setValues` sets them.
15
- * - **`stop()`** ends each element's running legs where they are.
15
+ * - **`stop()`** ends each Ward's running legs where they are.
16
16
  *
17
- * A function definition is called once per element, with its `custom`, values and velocities, as
18
- * Motion's `controls.start((i) => …)`, every element's before any is set: one that throws for an element
19
- * refuses the call, taking nothing. An element hears the controls from its mount to its unmount.
17
+ * A function definition is called once per Subject, with its `custom`, values and velocities, as
18
+ * Motion's `controls.start((i) => …)`, every Subject's before any is set: one that throws for a Subject
19
+ * refuses the call, taking nothing. A Subject hears the controls from its mount to its unmount.
20
20
  *
21
21
  * Unstable, for Wardic's own packages: public, with no semver promise.
22
22
  *
@@ -40,26 +40,26 @@ declare const queueMicrotask: (callback: () => void) => void
40
40
  export type { WardicAnimationControls, WardicControlsDefinition } from "./Config.ts"
41
41
 
42
42
  /**
43
- * A **Controls change** (#433): what one `start` or `set` set one element's `animate` entry to, the
44
- * transition it runs on, and the landings it waits for. The element and each Variant child it reaches
43
+ * A **Controls change** (#433): what one `start` or `set` set one Subject's `animate` entry to, the
44
+ * transition it runs on, and the landings it waits for. The Subject and each Variant child it reaches
45
45
  * join it at the Retarget it makes them run, and leave at that one's landing (or the next's).
46
46
  */
47
47
  export interface ControlsChange {
48
48
  /** Its place among every change: a trigger key part, so a change is a trigger even to the same name. */
49
49
  readonly serial: number
50
- /** The element's `animate` entry: a target or a name, a resolver already called. */
50
+ /** The Subject's `animate` entry: a target or a name, a resolver already called. */
51
51
  readonly definition: Config.WardicVariant | Config.WardicVariantLabels
52
- /** The transition of the change (start's override, set's instant one), or none: the element's own. */
52
+ /** The transition of the change (start's override, set's instant one), or none: the Subject's own. */
53
53
  readonly override: Config.WardicTransition | undefined
54
- /** Elements in it that haven't landed. */
54
+ /** Subjects in it that haven't landed. */
55
55
  pending: number
56
- /** Whether every element it reaches has had its chance to join: its binding's flush has run. */
56
+ /** Whether every Subject it reaches has had its chance to join: its binding's flush has run. */
57
57
  armed: boolean
58
58
  /** Told once it has landed. */
59
59
  readonly landed: () => void
60
60
  }
61
61
 
62
- /** What a controlled element does at a change, as its binding wires it: its entry worked out, then set, and the change's landing promised. */
62
+ /** What a controlled Subject does at a change, as its binding wires it: its entry worked out, then set, and the change's landing promised. */
63
63
  export interface Controlled {
64
64
  /** Its entry for `definition`: a function definition called with its `custom`, values and velocities; anything else as it is. */
65
65
  readonly entryOf: (definition: Config.WardicControlsDefinition) => Config.WardicVariant | Config.WardicVariantLabels
@@ -67,7 +67,7 @@ export interface Controlled {
67
67
  readonly stop: () => void
68
68
  }
69
69
 
70
- /** The elements each controls reach, by the controls. */
70
+ /** The Subjects each controls reach, by the controls. */
71
71
  // Module state (#460, Q7): each controls object's subscribers, held weakly by it.
72
72
  const subscribers = new WeakMap<Config.WardicAnimationControls, Set<Controlled>>()
73
73
 
@@ -75,43 +75,43 @@ const subscribers = new WeakMap<Config.WardicAnimationControls, Set<Controlled>>
75
75
  export const INSTANT: Config.WardicTransition = { type: "tween", duration: 0 }
76
76
 
77
77
  /**
78
- * Each element's entry for `definition`, worked out before any is set: a function definition that throws
78
+ * Each Subject's entry for `definition`, worked out before any is set: a function definition that throws
79
79
  * for one refuses the call, taking nothing, as an `animate()` call refuses one.
80
80
  */
81
- // #979 (ADR-0074, row 35): `start` and `set` set each element's entry as they called its function, so one
82
- // that threw for a later element left the earlier ones changed and the rest unreached, as #986's row 20.
83
- const entriesOf = (elements: ReadonlyArray<Controlled>, definition: Config.WardicControlsDefinition): ReadonlyArray<Config.WardicVariant | Config.WardicVariantLabels> =>
84
- Arr.map(elements, (element) => element.entryOf(definition))
81
+ // #979 (ADR-0074, row 35): `start` and `set` set each Subject's entry as they called its function, so one
82
+ // that threw for a later Subject left the earlier ones changed and the rest unreached, as #986's row 20.
83
+ const entriesOf = (reachedNow: ReadonlyArray<Controlled>, definition: Config.WardicControlsDefinition): ReadonlyArray<Config.WardicVariant | Config.WardicVariantLabels> =>
84
+ Arr.map(reachedNow, (controlled) => controlled.entryOf(definition))
85
85
 
86
86
  /**
87
- * Makes animation controls, which animate elements from code by their variants or targets: give them
88
- * to each element as `animate={controls}`, on a `w.*` element, in a ward's config or on a
89
- * `Reorder.Item`, then `start`, `set` or `stop` them. Needs no owner. Motion's `useAnimationControls`.
87
+ * Makes animation controls, which animate Subjects from code by their variants or targets: a binding
88
+ * gives them to each Subject as its `animate`, then `start`, `set` or `stop` them. Needs no owner.
89
+ * Motion's `useAnimationControls`.
90
90
  *
91
91
  * @example
92
92
  * const controls = createAnimationControls()
93
- * <w.ul initial="hidden" animate={controls} variants={list}>…</w.ul>
93
+ * // A binding gives `controls` to each Subject as its `animate`.
94
94
  * await controls.start("visible")
95
- * @see https://wardic.dev/reference/solid/animation/create-animation-controls
96
95
  */
97
- // #433's PR 3: each `start` or `set` is a Controls change of each element's `animate` entry.
96
+ // #433's PR 3: each `start` or `set` is a Controls change of each Subject's `animate` entry. Solid's
97
+ // export declares its own doc, with its markup (#1053).
98
98
  export const createAnimationControls = (): Config.WardicAnimationControls => {
99
99
  const reached = new Set<Controlled>()
100
100
  const controls: Config.WardicAnimationControls = {
101
101
  [Config.CONTROLS]: true,
102
102
  start: (definition, transitionOverride) => {
103
- const elements = Arr.fromIterable(reached)
104
- const entries = entriesOf(elements, definition)
105
- return Promise.all(Arr.zipWith(elements, entries, (element, entry) => element.change(entry, transitionOverride))).then(() => undefined)
103
+ const reachedNow = Arr.fromIterable(reached)
104
+ const entries = entriesOf(reachedNow, definition)
105
+ return Promise.all(Arr.zipWith(reachedNow, entries, (controlled, entry) => controlled.change(entry, transitionOverride))).then(() => undefined)
106
106
  },
107
107
  set: (definition) => {
108
- const elements = Arr.fromIterable(reached)
109
- const entries = entriesOf(elements, definition)
110
- Arr.forEach(Arr.zip(elements, entries), ([element, entry]) => {
111
- void element.change(entry, INSTANT)
108
+ const reachedNow = Arr.fromIterable(reached)
109
+ const entries = entriesOf(reachedNow, definition)
110
+ Arr.forEach(Arr.zip(reachedNow, entries), ([controlled, entry]) => {
111
+ void controlled.change(entry, INSTANT)
112
112
  })
113
113
  },
114
- stop: () => reached.forEach((element) => element.stop()),
114
+ stop: () => reached.forEach((controlled) => controlled.stop()),
115
115
  }
116
116
  subscribers.set(controls, reached)
117
117
  return controls
@@ -120,17 +120,17 @@ export const createAnimationControls = (): Config.WardicAnimationControls => {
120
120
  /** Whether `u` is **Animation controls** (Motion's `isAnimationControls`). */
121
121
  export const isAnimationControls = (u: unknown): u is Config.WardicAnimationControls => Predicate.hasProperty(u, Config.CONTROLS)
122
122
 
123
- /** An element's `animate` as **Animation controls**, when it is them: what a binding reads once at its mount (#798); `undefined` for a target or a name. */
123
+ /** A Subject's `animate` as **Animation controls**, when it is them: what a binding reads once at its mount (#798); `undefined` for a target or a name. */
124
124
  export const controlsOf = (animate: unknown): Config.WardicAnimationControls | undefined =>
125
125
  Bool.match(isAnimationControls(animate), { onTrue: () => animate as Config.WardicAnimationControls, onFalse: constUndefined })
126
126
 
127
- /** Reach `element` from `controls`, until the returned function: its mount to its unmount. */
128
- export const subscribe = (controls: Config.WardicAnimationControls, element: Controlled): (() => void) => {
127
+ /** Reach `controlled` from `controls`, until the returned function: its mount to its unmount. */
128
+ export const subscribe = (controls: Config.WardicAnimationControls, controlled: Controlled): (() => void) => {
129
129
  const reached = subscribers.get(controls)
130
130
  if (Predicate.isUndefined(reached)) return () => undefined
131
- reached.add(element)
131
+ reached.add(controlled)
132
132
  return () => {
133
- reached.delete(element)
133
+ reached.delete(controlled)
134
134
  }
135
135
  }
136
136
 
@@ -139,10 +139,10 @@ export const subscribe = (controls: Config.WardicAnimationControls, element: Con
139
139
  let serials = 0
140
140
 
141
141
  /**
142
- * An element's entry for `definition`: a resolver called with its `custom`, values and velocities (once,
142
+ * A Subject's entry for `definition`: a resolver called with its `custom`, values and velocities (once,
143
143
  * as Motion's), anything else as it is.
144
144
  */
145
- // #433; #979 (row 35): worked out for every element before any is set.
145
+ // #433; #979 (row 35): worked out for every Subject before any is set.
146
146
  export const entryOf = (
147
147
  definition: Config.WardicControlsDefinition,
148
148
  custom: unknown,
@@ -155,15 +155,18 @@ export const entryOf = (
155
155
  })
156
156
 
157
157
  /**
158
- * A change of one element: its entry, on `override`, and its landing, promised. It lands once every
159
- * element it reaches has joined, at the end of the binding's flush (`armed`), and left. One that reaches
160
- * no element lands then.
158
+ * A change of one Subject: its entry, on `override`, and its landing, promised. It lands once every
159
+ * Subject it reaches has joined, at the end of the binding's flush (`armed`), and left. One that reaches
160
+ * no Subject lands then.
161
161
  */
162
162
  // #433.
163
163
  export const changeOf = (
164
164
  entry: Config.WardicVariant | Config.WardicVariantLabels,
165
165
  override: Config.WardicTransition | undefined,
166
166
  ): { readonly change: ControlsChange; readonly landing: Promise<void> } => {
167
+ // The landing's resolver, set as the promise is made: its executor runs at once, so it's set before it's read,
168
+ // never missing, and needs no Option. `Promise.withResolvers` would say so; it's ES2024, and core builds against
169
+ // ES2022 (#1053, Q18).
167
170
  let resolve!: () => void
168
171
  const landing = new Promise<void>((done) => {
169
172
  resolve = done
@@ -172,25 +175,25 @@ export const changeOf = (
172
175
  return { change, landing }
173
176
  }
174
177
 
175
- /** An element joins `change`: it runs a Retarget for it. */
178
+ /** A Subject joins `change`: it runs a Retarget for it. */
176
179
  export const join = (change: ControlsChange): void => {
177
180
  change.pending++
178
181
  }
179
182
 
180
- /** An element in `change` landed, or left it (a later change, its unmount): it lands once none is left and it's armed. */
183
+ /** A Subject in `change` landed, or left it (a later change, its unmount): it lands once none is left and it's armed. */
181
184
  export const leave = (change: ControlsChange): void => {
182
185
  change.pending--
183
186
  if (change.armed && change.pending <= 0) change.landed()
184
187
  }
185
188
 
186
- /** `change` armed, its binding's flush having run: it lands now if no element joined, or all have left. */
189
+ /** `change` armed, its binding's flush having run: it lands now if no Subject joined, or all have left. */
187
190
  export const arm = (change: ControlsChange): void => {
188
191
  change.armed = true
189
192
  if (change.pending <= 0) change.landed()
190
193
  }
191
194
 
192
195
  /**
193
- * An element's config with **Animation controls** for its `animate` (#433), as everything but its
196
+ * A Subject's config with **Animation controls** for its `animate` (#433), as everything but its
194
197
  * controls reads it: `change`'s entry (none before the first), and marked controlled, so it names its
195
198
  * own variants whatever the entry is (Motion's `isControllingVariants`).
196
199
  */
@@ -201,14 +204,14 @@ export const controlledConfigOf = <C extends Pick<Config.SpineConfig, "animate">
201
204
  export const uncontrolledOf = <C extends Pick<Config.SpineConfig, "animate">>(config: C): C =>
202
205
  Bool.match(isAnimationControls(config.animate), { onTrue: () => controlledConfigOf(config, undefined), onFalse: () => config })
203
206
 
204
- /** What a controlled element reads at a change: its `custom`, and its values and velocities now (its Snapshot). */
207
+ /** What a controlled Subject reads at a change: its `custom`, and its values and velocities now (its Snapshot). */
205
208
  export interface ControlledState {
206
209
  readonly custom: () => unknown
207
210
  /** Its Snapshot: its values, and its velocities now (#663), a spring leg's being on its Frame. */
208
211
  readonly snapshot: ControlledSnapshot
209
212
  }
210
213
 
211
- /** What Animation controls read of an element's Snapshot: its values, and its velocities now (#663). */
214
+ /** What Animation controls read of a Ward's Snapshot: its values, and its velocities now (#663). */
212
215
  // #672: the controls name what they read, so they import nothing of the spine, whose Snapshot meets it.
213
216
  export interface ControlledSnapshot {
214
217
  readonly values: Values.Values
@@ -216,11 +219,11 @@ export interface ControlledSnapshot {
216
219
  }
217
220
 
218
221
  /**
219
- * A mounted element as its controls reach it (#433): a change sets its entry through `setChange`, its
222
+ * A mounted Subject as its controls reach it (#433): a change sets its entry through `setChange`, its
220
223
  * binding's signal, and arms once the binding's flush has run (a microtask after, Solid 2's included),
221
- * every element it reaches joined by then; `stop` ends its legs.
224
+ * every Subject it reaches joined by then; `stop` ends its legs.
222
225
  */
223
- export const controlledElement = (setChange: (change: ControlsChange) => void, state: ControlledState, stop: () => void): Controlled => ({
226
+ export const controlledSubject = (setChange: (change: ControlsChange) => void, state: ControlledState, stop: () => void): Controlled => ({
224
227
  entryOf: (definition) => entryOf(definition, state.custom(), state.snapshot.values, state.snapshot.velocitiesNow(state.snapshot)),
225
228
  change: (entry, override) => {
226
229
  const made = changeOf(entry, override)
@@ -1,5 +1,5 @@
1
1
  /**
2
- * An element's mount animation as both sides describe it, and its **Handoff** as the spine reads it
2
+ * A Subject's mount animation as both sides describe it, and its **Handoff** as the spine reads it
3
3
  * (#48, ADR-0044): how far in its first legs start, from where its Appear animation has got. Its
4
4
  * binding samples a server's and finds a client's.
5
5
  *
@@ -16,15 +16,15 @@ import * as UndefinedOr from "effect/UndefinedOr"
16
16
  import type * as Config from "./Config.ts"
17
17
  import * as RetargetLegs from "./RetargetLegs.ts"
18
18
 
19
- /** An element's mount animation, described the same on the server and the client. */
19
+ /** A Subject's mount animation, described the same on the server and the client. */
20
20
  export interface MountAnimation {
21
- /** The element's tag, by which its Environment routes some keys; `undefined` for an element whose tag isn't known. */
21
+ /** The Subject's tag, by which its Environment routes some keys; `undefined` for a Subject whose tag isn't known. */
22
22
  readonly tag: string | undefined
23
23
  /** Each animated key's start. */
24
24
  readonly from: Values.Values
25
25
  /** Each animated key's target. */
26
26
  readonly to: Values.Values
27
- /** The element's own transition: its stagger isn't in it (ADR-0007). */
27
+ /** The Subject's own transition: its stagger isn't in it (ADR-0007). */
28
28
  readonly transition: Config.WardicTransition | undefined
29
29
  /** Whether reduced motion is on for it (ADR-0029). */
30
30
  readonly reduced: boolean
@@ -37,7 +37,7 @@ export interface MountAnimation {
37
37
  readonly stops?: RetargetLegs.StopsByKey | undefined
38
38
  /**
39
39
  * Whether it's a **Skipped animation** (#468): every key lands on its first frame, so its Appear
40
- * animation takes 0 s, holding its end from first paint. Part of its key; left out when it isn't.
40
+ * animation takes 0 s, holding its end from the first frame drawn. Part of its key; left out when it isn't.
41
41
  */
42
42
  readonly skipped?: boolean | undefined
43
43
  /** Its **Transform template** (#443): its stops drawn through it, as the client draws them. Left out with none. */
@@ -70,7 +70,7 @@ const heldInAppear = (transition: Config.WardicTransition | undefined): number =
70
70
  /** A mount animation's `skipped` (#468): left out when it isn't, so its key is as before. */
71
71
  export const skippedField = (skipped: boolean): { readonly skipped?: true } => Bool.match(skipped, { onTrue: () => ({ skipped: true }) as const, onFalse: () => ({}) })
72
72
 
73
- /** An element's Appear animation, found at mount: the spine starts its first legs as far in as it has got. */
73
+ /** A Subject's Appear animation, found at mount: the spine starts its first legs as far in as it has got. */
74
74
  export interface Handoff {
75
75
  /** How far its animation has run, in seconds (its delay included). */
76
76
  readonly elapsed: () => number
@@ -93,7 +93,7 @@ const snapAfter = (delay: number): Batch.Transition => {
93
93
  }
94
94
 
95
95
  /**
96
- * A Default transition held by a key's own `delay`, as a Wardic element's is when its transition gives
96
+ * A Default transition held by a key's own `delay`, as a Ward's Subject's is when its transition gives
97
97
  * only a delay (ADR-0051): one object for each transition and delay, so the members on it share it.
98
98
  */
99
99
  // Module state (#460, Q7): a cache held weakly by the object it's for, so it goes with it.
@@ -115,8 +115,8 @@ export const delayedBy = (transition: Batch.Transition, delay: number): Batch.Tr
115
115
 
116
116
  /**
117
117
  * A transition without a `stagger()` delay, which a change gives each member by its place: one object
118
- * each. A `delay` in seconds stays, held by the keys the transition's own fields reach, as a Wardic
119
- * element's top-level delay is.
118
+ * each. A `delay` in seconds stays, held by the keys the transition's own fields reach, as a Ward's
119
+ * Subject's top-level delay is.
120
120
  */
121
121
  // Module state (#460, Q7): a cache held weakly by the object it's for, so it goes with it.
122
122
  const UNSTAGGERED = new WeakMap<object, Config.WardicTransition>()
@@ -152,7 +152,7 @@ export interface KeyPlan {
152
152
  }
153
153
 
154
154
  /**
155
- * Each key's plan for a change, by its index, as a Wardic element's keys run (#301): its entry, else
155
+ * Each key's plan for a change, by its index, as a Ward's Subject's keys run (#301): its entry, else
156
156
  * `default`, else the transition's own fields; reduced motion's Snap for a positional key that doesn't
157
157
  * opt out; its Default transition, held by its own `delay`, for a key whose transition isn't defined.
158
158
  */
@@ -390,7 +390,7 @@ export const isMember: Predicate.Refinement<unknown, Imperative.BatchMember> = /
390
390
  /**
391
391
  * A compiled sequence's parts (Q40): each Batch's members as one part, in the order they first appear,
392
392
  * with their animations; every other subject as it is. `restOf` gives what of a member's animation its
393
- * Subject takes itself (the DOM's member element's keys the Batch doesn't draw), when it takes any.
393
+ * Subject takes itself (`@wardic/dom`'s member's own keys the Batch doesn't draw), when it takes any.
394
394
  */
395
395
  export const sequencePartsOf = <X, S>(
396
396
  compiled: ReadonlyArray<readonly [X | Imperative.BatchMember, Sequence.Animation]>,
@@ -1,5 +1,5 @@
1
1
  /**
2
- * The config types a binding's elements and the spine share, each built on {@link ValueKeys}: the keys
2
+ * The config types a binding's Subjects and the spine share, each built on {@link ValueKeys}: the keys
3
3
  * an Environment animates and the values each takes. Empty here, `ValueKeys` is filled by the
4
4
  * Environment's binding types (`@wardic/dom/unstable/WardConfig` fills it), so each type keeps its
5
5
  * name and its shape whatever fills it.
@@ -52,7 +52,7 @@ export type WardicStagger = (index: number, total: number) => number
52
52
 
53
53
  /**
54
54
  * A path for `x` and `y` to travel along together: from where they start to where they end, the point
55
- * at each progress, 0 to 1, with a turn (`rotate`, in degrees) for one that turns the element. `arc()`
55
+ * at each progress, 0 to 1, with a turn (`rotate`, in degrees) for one that turns the Subject. `arc()`
56
56
  * makes one; any function of this shape is one, a curve of your own.
57
57
  */
58
58
  // A Path (#438).
@@ -144,14 +144,14 @@ export interface WardicSkipAnimations {
144
144
  * An axis the target leaves out ends where it rests (#574): where a Path in flight was taking it, so
145
145
  * one caught mid-air curves back to its line, else where it is.
146
146
  * A layout animation reads it where Motion's does, on its layout transition: the `layout` entry when
147
- * there is one, else the element's transition. On any other value's entry it isn't read.
147
+ * there is one, else the Subject's transition. On any other value's entry it isn't read.
148
148
  */
149
149
  export interface WardicTransitionPath {
150
150
  readonly path?: WardicPath
151
151
  }
152
152
 
153
153
  /**
154
- * How an element gets to its target: a spring, a tween, or an inertia, with a value's own transition
154
+ * How a Subject gets to its target: a spring, a tween, or an inertia, with a value's own transition
155
155
  * under its name. With no `type`, a spring field (`stiffness`, `damping`, `mass`, `velocity`,
156
156
  * `restDelta`, `restSpeed`, `bounce`, `visualDuration`) makes it a spring, and anything else a tween, so
157
157
  * `{ duration: 0.5 }` is a 0.5 s tween. A spring's missing fields are Motion's 100 / 10 / 1, or set by
@@ -167,7 +167,7 @@ export interface WardicTransitionPath {
167
167
  export type WardicTransition = WardicTransitionWith<WardicTransitionEntries>
168
168
 
169
169
  /**
170
- * A transition with the entries `E` (#301): {@link WardicTransition}'s two arms. A Wardic element's
170
+ * A transition with the entries `E` (#301): {@link WardicTransition}'s two arms. A Ward's Subject's
171
171
  * config checks each transition in it against the entries its keys allow (`WardChecked`).
172
172
  */
173
173
  export type WardicTransitionWith<E> =
@@ -198,7 +198,7 @@ export type WardicValueKey = Exclude<keyof ValueKeys & string, "transition">
198
198
 
199
199
  /**
200
200
  * A transition's per-value entries: a value's own transition under its name, `default` for every value
201
- * without one, and `layout` for the element's layout animations. A value runs on its entry, else
201
+ * without one, and `layout` for the Subject's layout animations. A value runs on its entry, else
202
202
  * `default`, else the transition's own fields. Motion's `TransitionWithValueOverrides`.
203
203
  */
204
204
  // #301; `layout`, ADR-0009 *Amendment (#171)*: a layout animation on `layout`, else `default`, else the
@@ -227,7 +227,7 @@ export type WardicTransitionFor<K extends string> = WardicTransitionWith<WardicV
227
227
 
228
228
  /**
229
229
  * A variant's own transition, or a target's: it runs the animation that variant starts, in place of
230
- * the element's `transition`, unless `inherit: true` lays it over the element's, its own fields winning.
230
+ * the Subject's `transition`, unless `inherit: true` lays it over the Subject's, its own fields winning.
231
231
  * Motion's.
232
232
  */
233
233
  // #277, ADR-0048.
@@ -236,7 +236,7 @@ export type WardicVariantTransition = WardicTransition & WardicInherit
236
236
  /**
237
237
  * A target's **Transition end** (Motion's `transitionEnd`): values set at once, with no
238
238
  * animation, once the keys the target animates have landed. Its keys are the target's, so they return to their base when it's no longer active;
239
- * a target interrupted before it lands never sets them; the target an element renders first sets its
239
+ * a target interrupted before it lands never sets them; the target a Subject renders first sets its
240
240
  * own at once, on a server too.
241
241
  */
242
242
  export type WardicTransitionEnd = Omit<ValueKeys, "transition">
@@ -255,16 +255,16 @@ export type WardicVariant =
255
255
  * Variant names (Motion's `VariantLabels`): one name, or a list of them. A list merges its
256
256
  * names' values in order, a later name's winning a key both set. Each key animates on the own
257
257
  * transition of the last name that sets it, and each name orchestrates the keys it sets in the
258
- * element's Variant children. An empty list is no name.
258
+ * Subject's Variant children. An empty list is no name.
259
259
  */
260
260
  export type WardicVariantLabels = string | ReadonlyArray<string>
261
261
 
262
262
  /**
263
263
  * A dynamic variant (Motion's `TargetResolver`): called each time the variant is
264
- * resolved with the element's `custom` (or, for an exit, its `<AnimatePresence custom>`), its values
264
+ * resolved with the Subject's `custom` (or, for an exit, its `<AnimatePresence custom>`), its values
265
265
  * now and their velocities, and returns its target, or another variant's name.
266
266
  *
267
- * One that throws is reported, and only its element is affected: it keeps its last target until the
267
+ * One that throws is reported, and only its Subject is affected: it keeps its last target until the
268
268
  * variant resolves, leaves without that exit, or starts without that variant's values.
269
269
  */
270
270
  // #979 (group F; ADR-0074, ADR-0007's Amendment): core's one call site catches it, and the failure
@@ -279,29 +279,29 @@ export type WardicVariantResolver = (
279
279
  /** Named targets, each a target or a {@link WardicVariantResolver}. */
280
280
  export type WardicVariants = Readonly<Record<string, WardicVariant | WardicVariantResolver>>
281
281
 
282
- /** What controls start or set an element to: a target, a variant name or a list of them, or a function of each element's `custom`. Motion's `AnimationDefinition`. */
282
+ /** What controls start or set a Subject to: a target, a variant name or a list of them, or a function of each Subject's `custom`. Motion's `AnimationDefinition`. */
283
283
  export type WardicControlsDefinition = WardicVariant | WardicVariantLabels | WardicVariantResolver
284
284
 
285
285
  /** The mark that tells controls from a target. */
286
286
  export const CONTROLS: unique symbol = Symbol("wardic.animationControls")
287
287
 
288
288
  /**
289
- * `createAnimationControls()`'s controls: give them as `animate={controls}`, and every element given
289
+ * `createAnimationControls()`'s controls: give them as `animate={controls}`, and every Subject given
290
290
  * them follows `start`, `set` and `stop`. Motion's `LegacyAnimationControls`.
291
291
  */
292
292
  // #433.
293
293
  export interface WardicAnimationControls {
294
294
  readonly [CONTROLS]: true
295
295
  /**
296
- * Animates every element given these controls to `definition`, as a change of its `animate` would,
296
+ * Animates every Subject given these controls to `definition`, as a change of its `animate` would,
297
297
  * its variant children following. `transitionOverride`, when given, is the transition of this change,
298
- * over the definition's own, and its stagger. Resolves once each element and its children have landed.
299
- * A function definition that throws for one element refuses the call, throwing, with no element changed.
298
+ * over the definition's own, and its stagger. Resolves once each Subject and its children have landed.
299
+ * A function definition that throws for one Subject refuses the call, throwing, with no Subject changed.
300
300
  */
301
301
  readonly start: (definition: WardicControlsDefinition, transitionOverride?: WardicTransition) => Promise<void>
302
- /** Sets every element given these controls, and its variant children, at `definition` at once; refused, with none set, as `start` is. */
302
+ /** Sets every Subject given these controls, and its variant children, at `definition` at once; refused, with none set, as `start` is. */
303
303
  readonly set: (definition: WardicControlsDefinition) => void
304
- /** Ends every element's running animation where it is. */
304
+ /** Ends every Subject's running animation where it is. */
305
305
  readonly stop: () => void
306
306
  }
307
307
 
@@ -318,7 +318,7 @@ export type WardicAnimationDefinition = WardicVariantLabels | ValueKeys
318
318
  export type WardicTransformPoint = (point: { readonly x: number; readonly y: number }) => { readonly x: number; readonly y: number }
319
319
 
320
320
  /**
321
- * What the spine reads of an element's config: its start, its targets, variants and transitions, each
321
+ * What the spine reads of a Ward's config: its start, its targets, variants and transitions, each
322
322
  * gesture's target, its layout, and the callbacks it tells. Every binding's config extends it, with
323
323
  * its Environment's own props beside.
324
324
  */
@@ -0,0 +1,26 @@
1
+ /**
2
+ * The late-frame rule's reader of the Frame loop's ticks, for a run that keeps the rule for each thing it
3
+ * moves, each begun at its own time: a long task delays a frame, whose dt then holds the task's time, and a
4
+ * thing begun in that task, or in the late frame after its tick, takes none of it. The loop carries its
5
+ * `Reader`: what one made now owes, and the dt of each of its steps while it owes one. A loop that carries
6
+ * none (a test's own) is read with `owingNothing`, under which nothing owes.
7
+ *
8
+ * Unstable, for Wardic's own packages: public, with no semver promise.
9
+ *
10
+ * @example
11
+ * import * as FirstSteps from "@wardic/core/unstable/FirstSteps"
12
+ * import * as Option from "effect/Option"
13
+ *
14
+ * const ticks = Option.getOrElse(FirstSteps.readerOf(loop), () => FirstSteps.owingNothing)
15
+ * // A thing made now: what it owes.
16
+ * let owed = ticks.madeOwing()
17
+ * // A step of it at the tick's `dt`, while it owes: its own dt, and what it owes after.
18
+ * const own = ticks.owingDt(owed, dt)
19
+ * owed = ticks.owedAfter(owed)
20
+ *
21
+ * @module
22
+ */
23
+ // Unstable: ADR-0071, decision 5. #1028 (ADR-0027 *Amendment (#1028)*): core's `internal/firstSteps.ts`,
24
+ // for the projection's coordinator, whose nodes keep #1026's rule each as a Batch's members do.
25
+ export type { Reader } from "../internal/firstSteps.ts"
26
+ export { owingNothing, readerOf } from "../internal/firstSteps.ts"