@wardic/core 1.3.1 → 1.4.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 (245) 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 +12 -6
  8. package/dist/Batch.d.ts.map +1 -1
  9. package/dist/Batch.js +374 -30
  10. package/dist/Batch.js.map +1 -1
  11. package/dist/Clock.d.ts +16 -0
  12. package/dist/Clock.d.ts.map +1 -1
  13. package/dist/Clock.js +22 -8
  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 +14 -8
  25. package/dist/DragRecognizer.d.ts.map +1 -1
  26. package/dist/DragRecognizer.js +93 -34
  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 +11 -8
  34. package/dist/InputFeed.d.ts.map +1 -1
  35. package/dist/InputFeed.js +18 -37
  36. package/dist/InputFeed.js.map +1 -1
  37. package/dist/InputSource.d.ts +3 -3
  38. package/dist/InputSource.js +2 -2
  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 +16 -9
  46. package/dist/LiveValue.d.ts.map +1 -1
  47. package/dist/LiveValue.js +204 -27
  48. package/dist/LiveValue.js.map +1 -1
  49. package/dist/Machine.d.ts +21 -8
  50. package/dist/Machine.d.ts.map +1 -1
  51. package/dist/Machine.js +184 -60
  52. package/dist/Machine.js.map +1 -1
  53. package/dist/Playback.d.ts.map +1 -1
  54. package/dist/Playback.js +16 -9
  55. package/dist/Playback.js.map +1 -1
  56. package/dist/Projection.d.ts +9 -9
  57. package/dist/Projection.js +2 -2
  58. package/dist/Recognizer.d.ts +2 -2
  59. package/dist/Recognizer.d.ts.map +1 -1
  60. package/dist/Recognizer.js +15 -10
  61. package/dist/Recognizer.js.map +1 -1
  62. package/dist/ReducedMotion.d.ts +4 -4
  63. package/dist/ReducedMotion.js +6 -6
  64. package/dist/Renderer.d.ts +5 -5
  65. package/dist/Renderer.js +6 -6
  66. package/dist/Renderer.js.map +1 -1
  67. package/dist/Reorder.d.ts +1 -1
  68. package/dist/Reorder.d.ts.map +1 -1
  69. package/dist/Reorder.js +2 -1
  70. package/dist/Reorder.js.map +1 -1
  71. package/dist/ScrollSource.d.ts +1 -1
  72. package/dist/ScrollSource.d.ts.map +1 -1
  73. package/dist/Sequence.d.ts +1 -1
  74. package/dist/SharedSource.d.ts +3 -3
  75. package/dist/SharedSource.js +5 -5
  76. package/dist/SharedSource.js.map +1 -1
  77. package/dist/Spring.d.ts.map +1 -1
  78. package/dist/Spring.js +2 -1
  79. package/dist/Spring.js.map +1 -1
  80. package/dist/Values.d.ts +2 -2
  81. package/dist/Values.js +1 -1
  82. package/dist/index.d.ts +1 -1
  83. package/dist/index.js +1 -1
  84. package/dist/internal/carried.d.ts +13 -0
  85. package/dist/internal/carried.d.ts.map +1 -0
  86. package/dist/internal/carried.js +23 -0
  87. package/dist/internal/carried.js.map +1 -0
  88. package/dist/internal/firstSteps.d.ts +66 -0
  89. package/dist/internal/firstSteps.d.ts.map +1 -0
  90. package/dist/internal/firstSteps.js +107 -0
  91. package/dist/internal/firstSteps.js.map +1 -0
  92. package/dist/internal/frameLoop.d.ts +11 -3
  93. package/dist/internal/frameLoop.d.ts.map +1 -1
  94. package/dist/internal/frameLoop.js +190 -39
  95. package/dist/internal/frameLoop.js.map +1 -1
  96. package/dist/internal/guarded.d.ts +16 -0
  97. package/dist/internal/guarded.d.ts.map +1 -0
  98. package/dist/internal/guarded.js +68 -0
  99. package/dist/internal/guarded.js.map +1 -0
  100. package/dist/internal/lerpsNumbers.d.ts +11 -0
  101. package/dist/internal/lerpsNumbers.d.ts.map +1 -0
  102. package/dist/internal/lerpsNumbers.js +38 -0
  103. package/dist/internal/lerpsNumbers.js.map +1 -0
  104. package/dist/internal/options.d.ts +7 -7
  105. package/dist/internal/options.d.ts.map +1 -1
  106. package/dist/internal/options.js +10 -10
  107. package/dist/internal/options.js.map +1 -1
  108. package/dist/internal/stepper.d.ts +21 -4
  109. package/dist/internal/stepper.d.ts.map +1 -1
  110. package/dist/internal/stepper.js +21 -5
  111. package/dist/internal/stepper.js.map +1 -1
  112. package/dist/internal/tracing.d.ts +1 -1
  113. package/dist/internal/tracing.js +1 -1
  114. package/dist/unstable/AnimationControls.d.ts +45 -39
  115. package/dist/unstable/AnimationControls.d.ts.map +1 -1
  116. package/dist/unstable/AnimationControls.js +59 -35
  117. package/dist/unstable/AnimationControls.js.map +1 -1
  118. package/dist/unstable/AppearHandoff.d.ts +11 -5
  119. package/dist/unstable/AppearHandoff.d.ts.map +1 -1
  120. package/dist/unstable/AppearHandoff.js.map +1 -1
  121. package/dist/unstable/BatchCalls.d.ts +2 -2
  122. package/dist/unstable/BatchCalls.js +5 -5
  123. package/dist/unstable/Config.d.ts +21 -17
  124. package/dist/unstable/Config.d.ts.map +1 -1
  125. package/dist/unstable/Config.js.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 +54 -50
  131. package/dist/unstable/FlushGate.d.ts.map +1 -1
  132. package/dist/unstable/FlushGate.js +201 -77
  133. package/dist/unstable/FlushGate.js.map +1 -1
  134. package/dist/unstable/FrameEffects.d.ts +6 -3
  135. package/dist/unstable/FrameEffects.d.ts.map +1 -1
  136. package/dist/unstable/FrameEffects.js +14 -3
  137. package/dist/unstable/FrameEffects.js.map +1 -1
  138. package/dist/unstable/FrameTime.d.ts +1 -1
  139. package/dist/unstable/FrameTime.js +1 -1
  140. package/dist/unstable/Imperative.d.ts +42 -13
  141. package/dist/unstable/Imperative.d.ts.map +1 -1
  142. package/dist/unstable/Imperative.js +279 -88
  143. package/dist/unstable/Imperative.js.map +1 -1
  144. package/dist/unstable/MeasuredPairs.d.ts +6 -2
  145. package/dist/unstable/MeasuredPairs.d.ts.map +1 -1
  146. package/dist/unstable/MeasuredPairs.js.map +1 -1
  147. package/dist/unstable/OwnValues.js +1 -1
  148. package/dist/unstable/PresenceRecord.d.ts +30 -26
  149. package/dist/unstable/PresenceRecord.d.ts.map +1 -1
  150. package/dist/unstable/PresenceRecord.js +8 -8
  151. package/dist/unstable/PresenceRecord.js.map +1 -1
  152. package/dist/unstable/Projector.d.ts +34 -0
  153. package/dist/unstable/Projector.d.ts.map +1 -0
  154. package/dist/unstable/Projector.js +9 -0
  155. package/dist/unstable/Projector.js.map +1 -0
  156. package/dist/unstable/Report.d.ts +8 -1
  157. package/dist/unstable/Report.d.ts.map +1 -1
  158. package/dist/unstable/Report.js +18 -2
  159. package/dist/unstable/Report.js.map +1 -1
  160. package/dist/unstable/RetargetLegs.d.ts +7 -1
  161. package/dist/unstable/RetargetLegs.d.ts.map +1 -1
  162. package/dist/unstable/RetargetLegs.js +24 -8
  163. package/dist/unstable/RetargetLegs.js.map +1 -1
  164. package/dist/unstable/Spine.d.ts +123 -68
  165. package/dist/unstable/Spine.d.ts.map +1 -1
  166. package/dist/unstable/Spine.js +319 -167
  167. package/dist/unstable/Spine.js.map +1 -1
  168. package/dist/unstable/Stops.d.ts +3 -3
  169. package/dist/unstable/Stops.js +4 -4
  170. package/dist/unstable/Subject.d.ts +2 -2
  171. package/dist/unstable/Subject.js +2 -2
  172. package/dist/unstable/Timelines.d.ts +11 -11
  173. package/dist/unstable/Timelines.d.ts.map +1 -1
  174. package/dist/unstable/Timelines.js +3 -3
  175. package/dist/unstable/VariantTarget.d.ts +32 -10
  176. package/dist/unstable/VariantTarget.d.ts.map +1 -1
  177. package/dist/unstable/VariantTarget.js +73 -20
  178. package/dist/unstable/VariantTarget.js.map +1 -1
  179. package/dist/unstable/VariantTree.d.ts +68 -34
  180. package/dist/unstable/VariantTree.d.ts.map +1 -1
  181. package/dist/unstable/VariantTree.js +83 -36
  182. package/dist/unstable/VariantTree.js.map +1 -1
  183. package/dist/unstable/WardicConfigValue.d.ts +13 -13
  184. package/dist/unstable/WardicConfigValue.d.ts.map +1 -1
  185. package/dist/unstable/WardicConfigValue.js +4 -4
  186. package/dist/unstable/WardicConfigValue.js.map +1 -1
  187. package/package.json +1 -1
  188. package/src/Arc.ts +3 -3
  189. package/src/BaseValue.ts +18 -21
  190. package/src/Batch.ts +391 -27
  191. package/src/Clock.ts +29 -8
  192. package/src/DefaultTransition.ts +5 -3
  193. package/src/Drag.ts +32 -14
  194. package/src/DragActivity.ts +3 -3
  195. package/src/DragRecognizer.ts +118 -41
  196. package/src/Easing.ts +1 -1
  197. package/src/Frame.ts +5 -3
  198. package/src/InputFeed.ts +39 -42
  199. package/src/InputSource.ts +5 -5
  200. package/src/Interpolator.ts +3 -3
  201. package/src/InterpolatorRegistry.ts +22 -13
  202. package/src/LiveValue.ts +186 -30
  203. package/src/Machine.ts +252 -81
  204. package/src/Playback.ts +15 -9
  205. package/src/Projection.ts +9 -9
  206. package/src/Recognizer.ts +16 -10
  207. package/src/ReducedMotion.ts +6 -6
  208. package/src/Renderer.ts +6 -6
  209. package/src/Reorder.ts +3 -2
  210. package/src/ScrollSource.ts +1 -1
  211. package/src/Sequence.ts +1 -1
  212. package/src/SharedSource.ts +5 -5
  213. package/src/Spring.ts +2 -1
  214. package/src/Values.ts +2 -2
  215. package/src/index.ts +1 -1
  216. package/src/internal/carried.ts +22 -0
  217. package/src/internal/firstSteps.ts +139 -0
  218. package/src/internal/frameLoop.ts +203 -41
  219. package/src/internal/guarded.ts +69 -0
  220. package/src/internal/lerpsNumbers.ts +53 -0
  221. package/src/internal/options.ts +10 -10
  222. package/src/internal/stepper.ts +33 -6
  223. package/src/internal/tracing.ts +1 -1
  224. package/src/unstable/AnimationControls.ts +88 -57
  225. package/src/unstable/AppearHandoff.ts +13 -6
  226. package/src/unstable/BatchCalls.ts +5 -5
  227. package/src/unstable/Config.ts +23 -17
  228. package/src/unstable/FirstSteps.ts +26 -0
  229. package/src/unstable/FlushGate.ts +250 -108
  230. package/src/unstable/FrameEffects.ts +17 -4
  231. package/src/unstable/FrameTime.ts +1 -1
  232. package/src/unstable/Imperative.ts +342 -101
  233. package/src/unstable/MeasuredPairs.ts +7 -1
  234. package/src/unstable/OwnValues.ts +1 -1
  235. package/src/unstable/PresenceRecord.ts +33 -29
  236. package/src/unstable/Projector.ts +45 -0
  237. package/src/unstable/Report.ts +20 -2
  238. package/src/unstable/RetargetLegs.ts +24 -9
  239. package/src/unstable/Spine.ts +399 -202
  240. package/src/unstable/Stops.ts +6 -6
  241. package/src/unstable/Subject.ts +2 -2
  242. package/src/unstable/Timelines.ts +12 -12
  243. package/src/unstable/VariantTarget.ts +102 -23
  244. package/src/unstable/VariantTree.ts +123 -42
  245. package/src/unstable/WardicConfigValue.ts +13 -13
@@ -44,11 +44,17 @@ export interface Measured extends Pair {
44
44
  export interface Shape {
45
45
  /** Whether `key` from `from` to `to` needs its pair measured: its ends in units that don't blend. */
46
46
  readonly needs: (key: string, from: number | string, to: number | string) => boolean
47
- /** Asks `pairs` measured on `subject`, at `values`: each key's pair, whose result it reads once it's done. */
47
+ /**
48
+ * Asks `pairs` measured on `subject`, at `values`: each key's pair, whose result it reads once it's
49
+ * done. One the measure can't take (its write throws) is never measured, and `failed` is told, its
50
+ * Subject's alone.
51
+ */
52
+ // #979, row 8 (ADR-0074): `failed`, the asker's, which reports through its own runtime.
48
53
  readonly measure: (
49
54
  subject: object,
50
55
  pairs: Readonly<Record<string, { readonly from: number | string; readonly to: number | string }>>,
51
56
  values: Values.Values,
57
+ failed: (defect: unknown) => void,
52
58
  ) => Readonly<Record<string, Requested>>
53
59
  }
54
60
 
@@ -13,7 +13,7 @@
13
13
  // Unstable: ADR-0071, decision 5. #672 (PR2-Q1, PR2-Q2; ADR-0071's *Amendment (#672)*): a port, so the
14
14
  // spine and `live-style` read their Environment's values through it, not through dom. A provider
15
15
  // resolves it once into its record when its Environment gives one, else its DOM binding gives the
16
- // DOM's (PR2-Q4: so `DomLive` ships none of it to an app that never reads it); each element's spine gets it in its options. Each member is a plain
16
+ // DOM's (PR2-Q4: so `DomLive` ships none of it to an app that never reads it); each Subject's spine gets it in its options. Each member is a plain
17
17
  // function: `valueLike` runs on a Follow leg's every step.
18
18
  import * as Context from "effect/Context"
19
19
  import type * as Option from "effect/Option"
@@ -15,6 +15,8 @@ import type * as Subject from "./Subject.ts"
15
15
  import type * as Stops from "./Stops.ts"
16
16
  import type * as Config from "./Config.ts"
17
17
  import { constFalse } from "effect/Function"
18
+ import type * as Option from "effect/Option"
19
+ import type * as VariantTarget from "./VariantTarget.ts"
18
20
  import * as Predicate from "effect/Predicate"
19
21
  import * as UndefinedOr from "effect/UndefinedOr"
20
22
 
@@ -24,8 +26,8 @@ import * as UndefinedOr from "effect/UndefinedOr"
24
26
  * the child's owner so the parent-driven exit reads them after the child leaves.
25
27
  */
26
28
  export interface PresenceRecord<E extends Subject.Subject = Subject.Subject> {
27
- /** The child's root Subject (the same `el` the spine wires). */
28
- readonly element: E
29
+ /** The child's root Subject (the same `subject` the spine wires). */
30
+ readonly subject: E
29
31
  /** The latest emitted value-map, updated by the spine each frame. */
30
32
  readonly snapshot: { current: Values.Values }
31
33
  /**
@@ -36,13 +38,13 @@ export interface PresenceRecord<E extends Subject.Subject = Subject.Subject> {
36
38
  readonly exitOf: (custom: unknown, inherited: Config.WardicVariantLabels | undefined) => PresenceExit
37
39
  /**
38
40
  * Where it sits in the variant tree, decided at setup as the tree is: whether it joins the
39
- * nearest element that provides a context (a **Variant child**, which then exits on that one's
41
+ * nearest Subject that provides a context (a **Variant child**, which then exits on that one's
40
42
  * exit name, in its stagger), whether its own Variant children join it, and whether it's a twin
41
43
  * (a `layoutId`, whose crossfade replaces its exit). Left out: none of them.
42
44
  */
43
45
  readonly tree?: PresenceTree
44
46
  /**
45
- * Where an exit key with no value in `snapshot` starts: its value as the element was given it (in
47
+ * Where an exit key with no value in `snapshot` starts: its value as the Subject was given it (in
46
48
  * `@wardic/dom`, its `style`), else its Own value, read from the Subject kept at the exit, in the
47
49
  * shape of `like` (the key's exit target). `undefined` starts it at its target. Optional: a record
48
50
  * without it starts such a key at its target.
@@ -65,11 +67,11 @@ export interface PresenceRecord<E extends Subject.Subject = Subject.Subject> {
65
67
  readonly skipAnimations?: (() => boolean) | undefined
66
68
  }
67
69
 
68
- /** Where a Wardic element starts when its child takes over from a leaver (#286, ADR-0048): the values and velocities it's drawn at. */
70
+ /** Where a Ward's Subject starts when its child takes over from a leaver (#286, ADR-0048): the values and velocities it's drawn at. */
69
71
  export interface PresenceSeed {
70
72
  readonly values: Values.Values
71
73
  readonly velocities: Readonly<Record<string, number>>
72
- /** Where the element it takes over from painted, in the Root frame: a layout node moves from there. */
74
+ /** Where the Subject it takes over from was drawn, in the Root frame: a layout node moves from there. */
73
75
  readonly box?: Box.Box | undefined
74
76
  /** The crossfade factor a twin it takes over from had faded out to: its handover's fade goes on from there. */
75
77
  readonly fade?: number | undefined
@@ -86,12 +88,14 @@ export interface PresenceExit {
86
88
  readonly name: Config.WardicVariantLabels | undefined
87
89
  /**
88
90
  * A list's exit by name (#297): each name's keys (those it's the last to set) on its own transition,
89
- * else the element's, and its orchestration for its Variant children's keys of that name. Every
91
+ * else the Subject's, and its orchestration for its Variant children's keys of that name. Every
90
92
  * name has one, keys or none. Left out for a single name or a values map: the whole exit is one.
91
93
  */
92
94
  readonly groups?: ReadonlyArray<ExitGroup> | undefined
93
95
  /** Its Keyframes (#429): each such key's stops, its value in `values` their last. Left out with none. */
94
96
  readonly keyframes?: Readonly<Record<string, Stops.Stops>> | undefined
97
+ /** Its exit's resolver that threw, and its variant's name (#979): it has none of that exit's values. None when it returned. */
98
+ readonly failure: Option.Option<VariantTarget.VariantFailure>
95
99
  }
96
100
 
97
101
  /** One name of a list's exit (#297): its keys, and the transition they and its orchestration run on. */
@@ -117,17 +121,17 @@ export interface PresenceContextValue<E extends Subject.Subject = Subject.Subjec
117
121
  */
118
122
  readonly register: (rec: PresenceRecord<E>) => () => void
119
123
  /**
120
- * Whether an element setting up now starts at its `animate`, with nothing animating at mount:
124
+ * Whether a Subject setting up now starts at its `animate`, with nothing animating at mount:
121
125
  * `<AnimatePresence initial={false}>`, during its first render (Motion's
122
126
  * `presenceContext.initial`). A child that enters later animates in. Optional: left out, never.
123
127
  */
124
128
  readonly blocksInitial?: () => boolean
125
129
  /**
126
- * Whether an element setting up now is inside a child `mode="wait"` holds back: `undefined`
130
+ * Whether a Subject setting up now is inside a child `mode="wait"` holds back: `undefined`
127
131
  * when it isn't, and it starts now. Else `start` is called once the child is shown, and the
128
- * call returned cancels that (the element gone first). Optional: left out, never.
132
+ * call returned cancels that (the Subject gone first). Optional: left out, never.
129
133
  */
130
- readonly hold?: (el: E, start: () => void) => (() => void) | undefined
134
+ readonly hold?: (subject: E, start: () => void) => (() => void) | undefined
131
135
  /**
132
136
  * A presence hook's registration: `usePresence`'s and `useIsPresent`'s.
133
137
  * Optional: left out, nothing is watched.
@@ -136,39 +140,39 @@ export interface PresenceContextValue<E extends Subject.Subject = Subject.Subjec
136
140
  /** The presence's `custom`, reactive: `usePresenceData`'s. Left out, `undefined`. */
137
141
  readonly data?: () => unknown
138
142
  /**
139
- * A Wardic element made: its `key` and whether it's a twin, told as its element is
143
+ * A Ward's Subject made: its `key` and whether it's a twin, told as the Subject is
140
144
  * made, before the presence decides what it shows (so `mode="wait"` doesn't hold a child
141
- * back under its key), and before any of its child's wards mount (so the elements inside pair).
145
+ * back under its key), and before any of its child's wards mount (so the Subjects inside pair).
142
146
  * Optional: left out, no child is keyed.
143
147
  */
144
- readonly made?: (el: E, key: string | number | undefined, twin: boolean) => void
148
+ readonly made?: (subject: E, key: string | number | undefined, twin: boolean) => void
145
149
  /**
146
- * Where an element mounting now starts, when its child takes over from a leaver: asked once,
150
+ * Where a Subject mounting now starts, when its child takes over from a leaver: asked once,
147
151
  * before its first Retarget. `undefined`: as it would. Optional: left out, never.
148
152
  */
149
- readonly takeOverOf?: (el: E) => PresenceSeed | undefined
153
+ readonly takeOverOf?: (subject: E) => PresenceSeed | undefined
150
154
  }
151
155
 
152
- /** Tell `presence` a Wardic element was made ({@link PresenceContextValue.made}): nothing without one. */
153
- export const presenceMade = <E extends Subject.Subject>(presence: PresenceContextValue<E> | undefined, el: E, key: string | number | undefined, twin: boolean): void => {
156
+ /** Tell `presence` a Ward's Subject was made ({@link PresenceContextValue.made}): nothing without one. */
157
+ export const presenceMade = <E extends Subject.Subject>(presence: PresenceContextValue<E> | undefined, subject: E, key: string | number | undefined, twin: boolean): void => {
154
158
  if (Predicate.isUndefined(presence)) return
155
- UndefinedOr.map(presence.made, (tell) => tell(el, key, twin))
159
+ UndefinedOr.map(presence.made, (tell) => tell(subject, key, twin))
156
160
  }
157
161
 
158
- /** Where `el` starts as it mounts, taking over from a leaver ({@link PresenceContextValue.takeOverOf}): `undefined` as it would. */
159
- export const presenceSeedOf = <E extends Subject.Subject>(presence: PresenceContextValue<E> | undefined, el: E): PresenceSeed | undefined => {
162
+ /** Where `subject` starts as it mounts, taking over from a leaver ({@link PresenceContextValue.takeOverOf}): `undefined` as it would. */
163
+ export const presenceSeedOf = <E extends Subject.Subject>(presence: PresenceContextValue<E> | undefined, subject: E): PresenceSeed | undefined => {
160
164
  if (Predicate.isUndefined(presence)) return undefined
161
- return UndefinedOr.map(presence.takeOverOf, (of) => of(el))
165
+ return UndefinedOr.map(presence.takeOverOf, (of) => of(subject))
162
166
  }
163
167
 
164
168
  /**
165
- * What a presence hook registers (#277's PR 5b, ADR-0048): its element, whose leaving child it
166
- * belongs to, and what it's told. Kept until that child goes, the presence goes, or its element
169
+ * What a presence hook registers (#277's PR 5b, ADR-0048): its Subject, whose leaving child it
170
+ * belongs to, and what it's told. Kept until that child goes, the presence goes, or its Subject
167
171
  * goes some other way.
168
172
  */
169
173
  export interface PresenceWatch<E extends Subject.Subject = Subject.Subject> {
170
- /** Its element, once it has one: the child that holds it is the one it belongs to. */
171
- readonly element: () => E | undefined
174
+ /** Its Subject, once it has one: the child that holds it is the one it belongs to. */
175
+ readonly subject: () => E | undefined
172
176
  /** Whether it holds its child as it leaves, until `release` is called (`usePresence`). */
173
177
  readonly holds: boolean
174
178
  /**
@@ -187,7 +191,7 @@ export interface PresenceWatch<E extends Subject.Subject = Subject.Subject> {
187
191
  readonly interrupted?: () => void
188
192
  }
189
193
 
190
- /** Whether `presence` holds an element setting up now at its `animate` ({@link PresenceContextValue.blocksInitial}). */
194
+ /** Whether `presence` holds a Subject setting up now at its `animate` ({@link PresenceContextValue.blocksInitial}). */
191
195
  export const presenceBlocksInitial = <E extends Subject.Subject>(presence: PresenceContextValue<E> | undefined): boolean =>
192
196
  UndefinedOr.match(presence, {
193
197
  onUndefined: constFalse,
@@ -198,5 +202,5 @@ export const presenceBlocksInitial = <E extends Subject.Subject>(presence: Prese
198
202
  * Whether `el` waits for its child to be shown ({@link PresenceContextValue.hold}): the call
199
203
  * that cancels `start`, or `undefined` when it starts now.
200
204
  */
201
- export const presenceHold = <E extends Subject.Subject>(presence: PresenceContextValue<E> | undefined, el: E, start: () => void): (() => void) | undefined =>
202
- UndefinedOr.map(presence, (p) => UndefinedOr.map(p.hold, (hold) => hold(el, start)))
205
+ export const presenceHold = <E extends Subject.Subject>(presence: PresenceContextValue<E> | undefined, subject: E, start: () => void): (() => void) | undefined =>
206
+ UndefinedOr.map(presence, (p) => UndefinedOr.map(p.hold, (hold) => hold(subject, start)))
@@ -0,0 +1,45 @@
1
+ /**
2
+ * A Renderer's **projector**: one target's own `project`. It projects a target's values as its Renderer's
3
+ * `project` does, into a patch it keeps and rewrites in place at its next call, so a target that moves every
4
+ * frame is given no new patch each frame. The Flush gate makes one for each target it registers, from its
5
+ * Renderer, and commits each patch before the next call. A Renderer without one is projected with its
6
+ * `project`.
7
+ *
8
+ * A projector rides on its Renderer's value, so a Renderer given in place of an Environment's own has none,
9
+ * and its own `project` is the one used.
10
+ *
11
+ * Unstable, for Wardic's own packages: public, with no semver promise.
12
+ *
13
+ * @example
14
+ * import * as Projector from "@wardic/core/unstable/Projector"
15
+ *
16
+ * const renderer = Projector.attach({ project, commit }, makeProjector)
17
+ * Projector.makerOf(renderer) // Option.some(makeProjector)
18
+ *
19
+ * @module
20
+ */
21
+ // #1030 (ADR-0034, *Amendment (#1030)*): on the Renderer's value, under this module's key, so the stable
22
+ // `Renderer` keeps its shape and a Renderer provided over an Environment's (a test's, one that adds a key)
23
+ // is projected with its own `project`.
24
+ import type * as Renderer from "../Renderer.ts"
25
+ import type * as Option from "effect/Option"
26
+ import * as Predicate from "effect/Predicate"
27
+ import { carriedOf, carry } from "../internal/carried.ts"
28
+
29
+ /** One target's projector: its values' patch, which it may rewrite at its next call. */
30
+ export type Projector = (values: Record<string, unknown>) => Renderer.Patch
31
+
32
+ /** Makes one target's projector. */
33
+ export type Make = () => Projector
34
+
35
+ /** A Renderer: its `project` and its `commit`. */
36
+ type Service = Renderer.Renderer["Service"]
37
+
38
+ /** Where a Renderer's value carries its projector's maker. */
39
+ const KEY: unique symbol = Symbol.for("@wardic/core/unstable/Projector")
40
+
41
+ /** `renderer`, carrying `make`, which makes a projector for each of its targets. */
42
+ export const attach = (renderer: Service, make: Make): Service => carry(renderer, KEY, make)
43
+
44
+ /** What makes `renderer`'s projectors: `None` for a Renderer that carries none. */
45
+ export const makerOf = (renderer: Service): Option.Option<Make> => carriedOf(renderer, KEY, Predicate.isFunction) as Option.Option<Make>
@@ -3,7 +3,8 @@
3
3
  * `ErrorReporter`s. Core's engine doesn't report: the Frame loop hands each run's failure to its
4
4
  * caller, and a Tier 2 caller may recover. A binding boundary that ends a fiber nobody observes calls
5
5
  * this, so a failure there reaches the console and an app's reporters instead of stopping its feature
6
- * with nothing said.
6
+ * with nothing said. So does what outlives one Subject's failure, so the others go on: the Flush gate's
7
+ * flush, a Batch's run, on the services it runs with.
7
8
  *
8
9
  * An app installs its reporters on the Environment it hands the provider,
9
10
  * `ErrorReporter.layer([…])` merged into `env`; Wardic ships none. With none installed, a report
@@ -21,11 +22,13 @@
21
22
  // reports from core once it's lifted there.
22
23
  import * as Bool from "effect/Boolean"
23
24
  import * as Cause from "effect/Cause"
25
+ import type * as Context from "effect/Context"
24
26
  import * as Effect from "effect/Effect"
25
27
  import * as ErrorReporter from "effect/ErrorReporter"
26
28
  import * as LogLevel from "effect/LogLevel"
27
29
  import * as Predicate from "effect/Predicate"
28
30
  import * as References from "effect/References"
31
+ import * as UndefinedOr from "effect/UndefinedOr"
29
32
 
30
33
  /**
31
34
  * `cause` logged at Error as `message`, with the cause, and handed to the Environment's
@@ -38,6 +41,21 @@ export const failure = (message: string, cause: Cause.Cause<unknown>): Effect.Ef
38
41
  onFalse: () => Effect.logError(message, cause).pipe(Effect.andThen(ErrorReporter.report(cause))),
39
42
  })
40
43
 
44
+ /**
45
+ * {@link failure}, run where no fiber of a binding's is there to see it: on `context`, what the failing
46
+ * code was built or started in, so an app's logger and reporters hear it, else on Effect's default
47
+ * runtime. Forked, off the path that failed, with `annotations` on its log when given.
48
+ */
49
+ // #979 (ADR-0030, *Amendment (#979, groups D and G)*): a Live value's run, a scroll's reader, a pointer's
50
+ // value and a watch with no onDefect, each captured its context once and calls this only at a failure.
51
+ export const failureOn = (context: Context.Context<never> | undefined, message: string, cause: Cause.Cause<unknown>, annotations?: Readonly<Record<string, unknown>>): void => {
52
+ const report = UndefinedOr.match(annotations, { onUndefined: () => failure(message, cause), onDefined: (given) => Effect.annotateLogs(failure(message, cause), given) })
53
+ UndefinedOr.match(context, {
54
+ onUndefined: () => void Effect.runFork(report),
55
+ onDefined: (given) => void Effect.runForkWith(given)(report),
56
+ })
57
+ }
58
+
41
59
  /**
42
60
  * Whether a Debug log would be kept, as Effect's `MinimumLogLevel` says. Run it once (a runtime, a
43
61
  * build) and keep the answer, not once a log.
@@ -49,7 +67,7 @@ export const debugKept: Effect.Effect<boolean> = /*#__PURE__*/ Effect.map(Refere
49
67
  * A lifecycle debug log for `scope` (`wardic.projection`, say): `log(event, annotations?)` logs
50
68
  * `scope: event` at Debug, forked on `runner`, with the annotations. Whether a Debug log would be kept
51
69
  * is read once, here ({@link debugKept}): when it wouldn't, `on` is `false` and `log` returns at once,
52
- * forking nothing. A site that builds its annotations per element checks `on` first.
70
+ * forking nothing. A site that builds its annotations per Subject checks `on` first.
53
71
  */
54
72
  // #618 (M4): each call forked a fiber whatever the level, 0.3-0.5 µs to log nothing (one per layout
55
73
  // node's mount and unmount); core's Frame loop reads the level once as this does (frameLoop.ts).
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * A Retarget's legs as one pure builder (#48, ADR-0044 decision 8): which machines a Retarget
3
- * runs, each from where and on which transition, with nothing of the element's (its gate, its
3
+ * runs, each from where and on which transition, with nothing of the Subject's (its gate, its
4
4
  * Snapshot, its fibers). The spine runs each leg into its sinks; a server render samples a mount's
5
5
  * legs into an Appear animation, so the two can't drift.
6
6
  *
@@ -181,7 +181,7 @@ const isEntry = (value: unknown): boolean => Predicate.isObject(value)
181
181
 
182
182
  /**
183
183
  * A transition's entries (#301), or `undefined` for one with none: worked out once per transition
184
- * object, so an element whose transitions have none pays a lookup per Retarget.
184
+ * object, so a Subject whose transitions have none pays a lookup per Retarget.
185
185
  */
186
186
  export const entriesOf = (given: Config.WardicTransition | undefined): Entries | undefined => {
187
187
  if (Predicate.isUndefined(given)) return undefined
@@ -249,6 +249,20 @@ export const transitionForKey = (given: Config.WardicTransition | undefined, key
249
249
  return forKey(entries, key)
250
250
  }
251
251
 
252
+ /**
253
+ * Whether `given` gives `key` a velocity of its own, a number other than 0, on the transition it runs on:
254
+ * it kicks the key, so the key animates though it's already at its target, out and back on a spring or
255
+ * gliding on an inertia, as Motion's `valueTransition.velocity` does.
256
+ */
257
+ // #448 (ADR-0005, *Amendment (#448)*): the spine's, here for a server's Appear rule to read too (#1018, ADR-0044).
258
+ export const givesVelocity = (given: Config.WardicTransition | undefined, key: string): boolean => {
259
+ // Per key, per Retarget (the spine's): statements.
260
+ const own = transitionForKey(given, key) as { readonly velocity?: unknown } | undefined
261
+ if (Predicate.isUndefined(own)) return false
262
+ if (Bool.not(Predicate.isNumber(own.velocity))) return false
263
+ return own.velocity !== 0
264
+ }
265
+
252
266
  /**
253
267
  * `given` held back by `extra` more seconds (ADR-0007's stagger, #290's exit delays): its own `delay`,
254
268
  * and each entry's (#301), so a key on its entry waits as the rest do. An `inherit` entry with no
@@ -380,9 +394,10 @@ const TIME_FIELDS = ["duration", "bounce", "visualDuration"] as const
380
394
 
381
395
  /**
382
396
  * The fields that don't define a transition, beside the orchestration's ({@link motionOf}): Motion's
383
- * `isTransitionDefined` (at 16c6122) skips `delay`; Wardic's reduced-motion opt-out, `skipAnimations`
397
+ * `isTransitionDefined` skips `delay`; Wardic's reduced-motion opt-out, `skipAnimations`
384
398
  * (#468) and a target's `inherit` aren't a transition's either. `repeat` and its fields do define one, a tween (ADR-0051).
385
399
  */
400
+ // `isTransitionDefined` at 16c6122.
386
401
  const NOT_DEFINING: ReadonlySet<string> = new Set(["delay", "respectReducedMotion", "skipAnimations", "inherit"])
387
402
 
388
403
  /** Motion's spring defaults (`springDefaults`): what a spring transition leaves out (ADR-0051). */
@@ -469,7 +484,7 @@ const hasKeys: Predicate.Predicate<Values.Values> = Predicate.not(Rec.isEmptyRec
469
484
 
470
485
  /**
471
486
  * A Retarget's legs, in the order the spine starts them. Positional, as the spine calls it once a
472
- * Retarget per element (#69's PR 2: what a Retarget allocates shows in `bench:solid`'s bytes).
487
+ * Retarget per Subject (#69's PR 2: what a Retarget allocates shows in `bench:solid`'s bytes).
473
488
  *
474
489
  * @param from each key's start
475
490
  * @param to each key's target
@@ -578,7 +593,7 @@ const pathOf = (
578
593
  current: Values.Values | undefined,
579
594
  rests: Values.Values | undefined,
580
595
  ): { readonly leg: Blend; readonly rest: Values.Values } | undefined => {
581
- // Every element's Retarget asks, nearly always with no `path` (#460): guards, nothing built.
596
+ // Every Subject's Retarget asks, nearly always with no `path` (#460): guards, nothing built.
582
597
  if (Predicate.isUndefined(given)) return undefined
583
598
  const path = given.path
584
599
  if (Predicate.isUndefined(path)) return undefined
@@ -601,7 +616,7 @@ const pathOf = (
601
616
  const endY = axisOf("y", to, resting)
602
617
  if (Predicate.isUndefined(endY)) return undefined
603
618
  const at = path({ x: startX, y: startY }, { x: endX, y: endY })
604
- // A path that turns the element says so at its start, as Motion's `interpolate(0).rotate`.
619
+ // A path that turns the Subject says so at its start, as Motion's `interpolate(0).rotate`.
605
620
  const end: Values.Values = Bool.match(Predicate.isUndefined(at(0).rotate), {
606
621
  onTrue: () => ({ x: endX, y: endY }),
607
622
  onFalse: () => ({ x: endX, y: endY, pathRotation: 0 }),
@@ -800,7 +815,7 @@ const defaultFor = (
800
815
  /**
801
816
  * A Default transition with what the transition that defines none still says: its `delay` (a
802
817
  * stagger's among it, ADR-0007), its reduced-motion opt-out and its `skipAnimations` (#468). The
803
- * Default transition itself when it says none, as nearly every element's (it has no transition).
818
+ * Default transition itself when it says none, as nearly every Subject's (it has no transition).
804
819
  */
805
820
  const carried = (runsOn: DefaultTransition.Transition | DefaultTransition.KeyframesTransition, given: Config.WardicTransition | undefined): Run => {
806
821
  if (Predicate.isUndefined(given)) return runsOn
@@ -851,7 +866,7 @@ const legsWith = (
851
866
  const following = followingKeys.length > 0
852
867
  let fixed = rest
853
868
  if (following) fixed = Rec.filter(rest, (_, key) => !Arr.contains(followingKeys, key))
854
- // Built a leg at a time, once a Retarget (#69's PR 2: a Retarget is per element, so no spreads).
869
+ // Built a leg at a time, once a Retarget (#69's PR 2: a Retarget is per Subject, so no spreads).
855
870
  const legs: Array<Leg> = []
856
871
  // Measured pairs (#430): a leg of their own, between their ends in px, on this transition.
857
872
  const measuring = anyMeasured(fixed, measured)
@@ -944,7 +959,7 @@ export type MachineMap = <F extends Frame.Frame<unknown>>(machine: Machine.Machi
944
959
  */
945
960
  export const mapMachine = (leg: Leg, f: MachineMap): Leg => mapMachineMatch({ leg, f })
946
961
 
947
- /** {@link mapMachine}'s cases, built once at module load: it runs per element at hydration (#69's PR 2). */
962
+ /** {@link mapMachine}'s cases, built once at module load: it runs per Subject at hydration (#69's PR 2). */
948
963
  const mapMachineMatch: (input: { readonly leg: Leg; readonly f: MachineMap }) => Leg = Match.type<{ readonly leg: Leg; readonly f: MachineMap }>().pipe(
949
964
  Match.when({ leg: { _tag: "Blend" } }, ({ leg, f }): Leg => ({ ...leg, machine: () => Effect.map(leg.machine(), f) })),
950
965
  Match.orElse(({ leg, f }): Leg => {