@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
@@ -7,7 +7,7 @@
7
7
  * Unstable, for Wardic's own packages: public, with no semver promise. `@wardic/dom/Style` re-exports
8
8
  * it for binding authors.
9
9
  *
10
- * Observability: pure and per element, so quiet (no span, no log).
10
+ * Observability: pure and per Subject, so quiet (no span, no log).
11
11
  *
12
12
  * @module
13
13
  */
@@ -87,7 +87,7 @@ const keepAnimatable = (value: unknown, key: string): boolean => {
87
87
 
88
88
  /** A values map's numbers and strings, its Keyframes set aside (#452, {@link keepAnimatable}): {@link toValues}' one pass. */
89
89
  const filtered = (v: object | undefined): Values.Values => {
90
- // Per element at mount (#540): statements and a loop.
90
+ // Per Subject at mount (#540): statements and a loop.
91
91
  setAside = undefined
92
92
  const out: Record<string, number | string> = {}
93
93
  if (Predicate.isUndefined(v)) return out
@@ -164,7 +164,7 @@ export const valuesAt = (v: object | undefined, at: StopAt): Values.Values => {
164
164
  export const keyframesOf = (v: object | undefined): Option.Option<Readonly<Record<string, Stops>>> => splitValues(v, "last").keyframes
165
165
 
166
166
  /**
167
- * What of an element's config its starting style is read from. Its values are typed `object`, so a
167
+ * What of a Subject's config its starting style is read from. Its values are typed `object`, so a
168
168
  * binding's own value types fit as they are.
169
169
  */
170
170
  export interface InitialConfig {
@@ -192,7 +192,7 @@ const isList = (entry: unknown): entry is ReadonlyArray<string> => Arr.isArray(e
192
192
 
193
193
  /**
194
194
  * A values map, or the `variants` entry a name names (an unknown name is empty), or nothing.
195
- * Built once, at module load: every element reads its own at setup (#69).
195
+ * Built once, at module load: every Subject reads its own at setup (#69).
196
196
  */
197
197
  const entryOf: (entry: Entry) => Values.Values = Match.type<Entry>().pipe(
198
198
  Match.when({ entry: Match.undefined }, (): Values.Values => ({})),
@@ -204,7 +204,7 @@ const entryOf: (entry: Entry) => Values.Values = Match.type<Entry>().pipe(
204
204
  )
205
205
 
206
206
  /**
207
- * The values an element starts from: its `initial` values, or the `variants` entries its `initial` names,
207
+ * The values a Subject starts from: its `initial` values, or the `variants` entries its `initial` names,
208
208
  * an unknown name empty, or nothing. With `initial: false`, its `animate`, resolved the same way, so it
209
209
  * starts at its target and nothing animates at mount, as Motion's. A keyframes value starts at its first
210
210
  * stop, or, with `initial: false`, at `animate`'s last, where the animation it skips would end. Read once,
@@ -215,7 +215,7 @@ const entryOf: (entry: Entry) => Values.Values = Match.type<Entry>().pipe(
215
215
  */
216
216
  // #134, Motion's `initial={false}`; **Keyframes** (#429, Motion's `use-visual-state.ts`).
217
217
  export const resolveInitial = (config: InitialConfig): Values.Values => {
218
- // Per element at mount (#540): statements.
218
+ // Per Subject at mount (#540): statements.
219
219
  if (config.initial === false) return entryOf({ entry: config.animate, variants: config.variants, at: "last" })
220
220
  return entryOf({ entry: config.initial as object | string | ReadonlyArray<string> | undefined, variants: config.variants, at: "first" })
221
221
  }
@@ -1,6 +1,6 @@
1
1
  /**
2
- * What an Environment draws and a Ward binds (**Subject**): opaque to core. An element in `@wardic/dom`, an
3
- * object in a scene; an Environment decides what its Subjects are.
2
+ * What an Environment draws and a Ward binds (**Subject**): opaque to core. `@wardic/dom`'s are its own kind,
3
+ * a scene's its objects; an Environment decides what its Subjects are.
4
4
  *
5
5
  * Unstable, for Wardic's own packages: public, with no semver promise.
6
6
  *
@@ -1,7 +1,7 @@
1
1
  /**
2
- * **Timeline values** (#240, ADR-0043 *Amendment (#240)*): what an element's spine tells of its keys,
2
+ * **Timeline values** (#240, ADR-0043 *Amendment (#240)*): what a Subject's spine tells of its keys,
3
3
  * and the service that runs their Timeline values, which a binding's `scroll` Feature gives. Only the
4
- * type and the key are here, on every element's path: the code is the Feature's, so an app that reads
4
+ * type and the key are here, on every Subject's path: the code is the Feature's, so an app that reads
5
5
  * no scroll ships none of it.
6
6
  *
7
7
  * Unstable, for Wardic's own packages: public, with no semver promise.
@@ -9,34 +9,34 @@
9
9
  * @module
10
10
  */
11
11
  // Unstable: ADR-0071, decision 5. #672 (Q15): solid's `timelines.ts`, moved for the spine to tell its keys'
12
- // Timeline values in core; its options' element a Subject, its runtime a Runner.
12
+ // Timeline values in core; its options' `subject` a Subject, its runtime a Runner.
13
13
  import type * as FlushGate from "./FlushGate.ts"
14
14
  import * as Context from "effect/Context"
15
15
  import type * as Atom from "effect/reactivity/Atom"
16
16
  import type * as Subject from "./Subject.ts"
17
17
  import type * as WardicServices from "./WardicServices.ts"
18
18
 
19
- /** An element's keys' Timeline values, as its spine tells of them. */
19
+ /** A Subject's keys' Timeline values, as its spine tells of them. */
20
20
  export interface TimelineKeys {
21
- /** The element shows `key`'s Live value: its Timeline value runs, when it has one. */
21
+ /** The Subject shows `key`'s Live value: its Timeline value runs, when it has one. */
22
22
  readonly shown: (key: string) => void
23
23
  /** Something else draws `key` now (an entry, a drag, an Imperative animation), or it left the `style`: its Timeline value stops. */
24
24
  readonly taken: (key: string) => void
25
- /** The element's unmounted: it's no longer told of a value described. */
25
+ /** The Subject's unmounted: it's no longer told of a value described. */
26
26
  readonly dispose: () => void
27
27
  }
28
28
 
29
- /** What an element's {@link TimelineKeys} are made with. */
29
+ /** What a Subject's {@link TimelineKeys} are made with. */
30
30
  export interface TimelineKeysOptions {
31
31
  readonly runtime: WardicServices.Runner<WardicServices.WardicServices>
32
32
  readonly gate: FlushGate.Shape
33
33
  readonly id: string
34
- readonly element: Subject.Subject
34
+ readonly subject: Subject.Subject
35
35
  /** Its routed `style` keys: each key's Atom, which describes its derivation. */
36
36
  readonly live: LiveAtoms
37
37
  }
38
38
 
39
- /** What an element's Timeline values read of its Live values: a routed key's Atom, `undefined` for one not routed. */
39
+ /** What a Subject's Timeline values read of its Live values: a routed key's Atom, `undefined` for one not routed. */
40
40
  // #672: the one member the Timelines' keys call of the spine's LiveRoutes, which meets it; named here, so
41
41
  // this module, which the spine imports, imports nothing of the spine's.
42
42
  export interface LiveAtoms {
@@ -44,10 +44,10 @@ export interface LiveAtoms {
44
44
  }
45
45
 
46
46
  /**
47
- * The `scroll` Feature's Timeline values (#240), one per provider: an element's {@link TimelineKeys},
47
+ * The `scroll` Feature's Timeline values (#240), one per provider: a Subject's {@link TimelineKeys},
48
48
  * made at its first write of a Live value; and `described`, told by a `createScroll` that has described
49
- * its values (`LiveValue.derivesAs`), after the elements following them may have shown them, so each
50
- * key an element shows finds its Timeline value then, its value unchanged.
49
+ * its values (`LiveValue.derivesAs`), after the Subjects following them may have shown them, so each
50
+ * key a Subject shows finds its Timeline value then, its value unchanged.
51
51
  */
52
52
  export class Timelines extends /*#__PURE__*/ Context.Service<
53
53
  Timelines,
@@ -1,5 +1,5 @@
1
1
  /**
2
- * A target resolved (#277, ADR-0048): a values map, or a variant name against an element's
2
+ * A target resolved (#277, ADR-0048): a values map, or a variant name against a Subject's
3
3
  * `variants`, each a target with its own transition or a dynamic variant, a function of `custom`.
4
4
  * Motion's `resolveVariantFromProps` and `resolveTransition`. Shared by every binding's spine, its
5
5
  * variant nodes and its Starting style.
@@ -22,7 +22,7 @@ import type * as Config from "./Config.ts"
22
22
 
23
23
  /**
24
24
  * What a dynamic variant reads besides `custom` (#277, Motion's `current` and `velocity`): the
25
- * element's values now and their velocities, its Snapshot's. Copied only when a resolver is called.
25
+ * Subject's values now and their velocities, its Snapshot's. Copied only when a resolver is called.
26
26
  */
27
27
  export interface VariantState {
28
28
  readonly values: Readonly<Record<string, number | string>>
@@ -48,6 +48,11 @@ export interface Target {
48
48
  * none.
49
49
  */
50
50
  readonly keyframes: Keyframes | undefined
51
+ /**
52
+ * A resolver it called that threw, and its variant's name (#979): it resolved to nothing in its place.
53
+ * None when every resolver it called returned.
54
+ */
55
+ readonly failure: Option.Option<VariantFailure>
51
56
  }
52
57
 
53
58
  /** A target's **Keyframes** (#429): each such key's stops. */
@@ -99,14 +104,34 @@ type Definition = Config.WardicVariant | Config.WardicVariantResolver | string |
99
104
  const velocitiesOf = (state: VariantState): Readonly<Record<string, number>> =>
100
105
  UndefinedOr.match(state.velocitiesNow, { onUndefined: () => state.velocities, onDefined: (now) => now(state) })
101
106
 
102
- /** A resolver called with what it reads, as Motion calls it; anything else as it is. */
103
- const calledOf = (definition: Definition, custom: unknown, state: VariantState): Definition => {
104
- if (Predicate.isFunction(definition)) return definition(custom, { ...state.values }, { ...velocitiesOf(state) })
107
+ /** A resolver's throw, handed on in place of a definition: the one value, its throw in {@link thrown}. */
108
+ // #979 (ADR-0074): every resolver runs in `calledOf`, so its throw is caught once, for every binding.
109
+ // One value, told apart by identity: every target passes the check, and a property check (`in`, a
110
+ // symbol a values map never has) cost a resolution 4–5% in Maglev (bench:solid's mount).
111
+ const FAILED: { readonly failed: true } = { failed: true }
112
+ type Failed = typeof FAILED
113
+
114
+ /** What the resolver behind the last {@link FAILED} threw: set by `calledOf` and read by `resolveOne` at once, with no app code between. */
115
+ // Module state (#979, bench:solid's mount): one throw at a time, handed from `calledOf` to `resolveOne` in one
116
+ // synchronous step and cleared there, so `FAILED` stays one value told apart by identity.
117
+ let thrown: unknown = undefined
118
+
119
+ /** A resolver called with what it reads, as Motion calls it, its throw handed on as {@link FAILED}; anything else as it is. */
120
+ // #979, Q4: a bare `try`, measured within 2% of the call alone; `Result.try` cost 21–35% more a call.
121
+ const calledOf = (definition: Definition | Failed, custom: unknown, state: VariantState): Definition | Failed => {
122
+ if (Predicate.isFunction(definition)) {
123
+ try {
124
+ return definition(custom, { ...state.values }, { ...velocitiesOf(state) })
125
+ } catch (defect) {
126
+ thrown = defect
127
+ return FAILED
128
+ }
129
+ }
105
130
  return definition
106
131
  }
107
132
 
108
133
  /** A name looked up in `variants`; anything else as it is. */
109
- const namedOf = (definition: Definition, variants: Config.WardicVariants | undefined): Definition => {
134
+ const namedOf = (definition: Definition | Failed, variants: Config.WardicVariants | undefined): Definition | Failed => {
110
135
  if (Bool.not(Predicate.isString(definition))) return definition
111
136
  if (Predicate.isUndefined(variants)) return undefined
112
137
  return variants[definition as string]
@@ -115,7 +140,7 @@ const namedOf = (definition: Definition, variants: Config.WardicVariants | undef
115
140
  /**
116
141
  * Resolve a target (#277): a values map, or a variant name, against `variants`, Motion's
117
142
  * `resolveVariantFromProps`. A name's entry is looked up, a resolver is called with `custom` and the
118
- * element's `state`, and a resolver that returns a name is followed once more. Its values go through
143
+ * Subject's `state`, and a resolver that returns a name is followed once more. Its values go through
119
144
  * `Stops.valuesAt`, so `Override.resolve` and `Values.split` never see an `undefined` value, nor an
120
145
  * array: a key's Keyframes (#429) are split off, its value their last stop; its `transition` is split
121
146
  * off too.
@@ -134,7 +159,20 @@ export const resolveTargets = (entry: Entry, variants: Config.WardicVariants | u
134
159
  return Arr.map(entry as ReadonlyArray<string>, (name): NamedTarget => ({ ...resolveOne(name, variants, custom, state), name }))
135
160
  }
136
161
  const one = entry as Config.WardicVariant | string | undefined
137
- return [{ ...resolveOne(one, variants, custom, state), name: Bool.match(Predicate.isString(one), { onTrue: () => one as string, onFalse: () => undefined }) }]
162
+ return [{ ...resolveOne(one, variants, custom, state), name: nameOfEntry(one) }]
163
+ }
164
+
165
+ /** An entry's name: the entry itself, when it's one. */
166
+ // Per Retarget, per Subject (#460, compose once): statements.
167
+ const nameOfEntry = (entry: Config.WardicVariant | string | undefined): string | undefined => {
168
+ if (Predicate.isString(entry)) return entry
169
+ return undefined
170
+ }
171
+
172
+ /** The first of two failures: what a merge keeps. */
173
+ const firstFailure = (before: Option.Option<VariantFailure>, after: Option.Option<VariantFailure>): Option.Option<VariantFailure> => {
174
+ if (Option.isSome(before)) return before
175
+ return after
138
176
  }
139
177
 
140
178
  /**
@@ -155,6 +193,8 @@ export const mergedOf = (targets: ReadonlyArray<Target>): Target =>
155
193
  onUndefined: () => merged.transitionEnd,
156
194
  onDefined: (own) => UndefinedOr.match(merged.transitionEnd, { onUndefined: () => own, onDefined: (before) => ({ ...before, ...own }) }),
157
195
  }),
196
+ // The first name's whose resolver threw (#979).
197
+ failure: firstFailure(merged.failure, target.failure),
158
198
  }))
159
199
 
160
200
  /**
@@ -168,12 +208,21 @@ const keyframesOver = (target: Target, before: Keyframes | undefined): Keyframes
168
208
  return Bool.match(Rec.isEmptyRecord(over), { onTrue: () => undefined, onFalse: () => over })
169
209
  }
170
210
 
211
+ /** No failure: one value, as every target that resolves carries it (#979, bench:solid's mount). */
212
+ export const NO_FAILURE: Option.Option<VariantFailure> = Option.none()
213
+
171
214
  /** Nothing resolved. */
172
- export const NO_TARGET: Target = { values: {}, transition: undefined, transitionEnd: undefined, keyframes: undefined }
215
+ export const NO_TARGET: Target = { values: {}, transition: undefined, transitionEnd: undefined, keyframes: undefined, failure: NO_FAILURE }
173
216
 
174
217
  /** One name or values map resolved ({@link resolveTarget}). */
175
218
  const resolveOne = (entry: Config.WardicVariant | string | undefined, variants: Config.WardicVariants | undefined, custom: unknown, state: VariantState): Target => {
176
219
  const definition = calledOf(namedOf(calledOf(namedOf(entry, variants), custom, state), variants), custom, state)
220
+ // A resolver that threw resolves to nothing, carrying what it threw and the name it was reached by (#979).
221
+ if (definition === FAILED) {
222
+ const defect = thrown
223
+ thrown = undefined
224
+ return { ...NO_TARGET, failure: Option.some({ defect, name: nameOfEntry(entry) }) }
225
+ }
177
226
  if (Bool.or(Predicate.isUndefined(definition), Bool.or(Predicate.isString(definition), Predicate.isFunction(definition)))) {
178
227
  return NO_TARGET
179
228
  }
@@ -185,11 +234,11 @@ const resolveOne = (entry: Config.WardicVariant | string | undefined, variants:
185
234
  // pass over its keys (#452).
186
235
  if (Bool.not(Predicate.isObject(target.transition))) {
187
236
  const split = Stops.splitValues(target, "last")
188
- return { values: split.values, transition: undefined, transitionEnd, keyframes: Option.getOrUndefined(split.keyframes) }
237
+ return { values: split.values, transition: undefined, transitionEnd, keyframes: Option.getOrUndefined(split.keyframes), failure: NO_FAILURE }
189
238
  }
190
239
  const { transition, ...values } = target
191
240
  const split = Stops.splitValues(values, "last")
192
- return { values: split.values, transition: transition as Config.WardicVariantTransition, transitionEnd, keyframes: Option.getOrUndefined(split.keyframes) }
241
+ return { values: split.values, transition: transition as Config.WardicVariantTransition, transitionEnd, keyframes: Option.getOrUndefined(split.keyframes), failure: NO_FAILURE }
193
242
  }
194
243
 
195
244
  /** A target's Transition end (#428), clean for core: none for anything but a values map, or an empty one. */
@@ -202,45 +251,75 @@ const transitionEndOf = (given: unknown): Values.Values | undefined => {
202
251
 
203
252
  /**
204
253
  * The transition an animation to a target runs on (#277, Motion's `resolveTransition`): the target's
205
- * own in place of the element's, or laid over it with `inherit: true` (a shallow merge, its own keys
206
- * winning); the element's when it has none. An own transition with no `inherit` is handed back as it
254
+ * own in place of the Subject's, or laid over it with `inherit: true` (a shallow merge, its own keys
255
+ * winning); the Subject's when it has none. An own transition with no `inherit` is handed back as it
207
256
  * is, the same object each call, so a memo of it holds (#460: a copy per call made Solid 2's variant
208
257
  * node re-run its orchestration's readers at every gesture, `UNSTABLE_MEMO_OUTPUT`).
209
258
  */
210
- export const transitionOfTarget = (own: Config.WardicVariantTransition | undefined, element: Config.WardicTransition | undefined): Config.WardicTransition | undefined => {
211
- if (Predicate.isUndefined(own)) return element
259
+ export const transitionOfTarget = (own: Config.WardicVariantTransition | undefined, wardTransition: Config.WardicTransition | undefined): Config.WardicTransition | undefined => {
260
+ if (Predicate.isUndefined(own)) return wardTransition
212
261
  if (!("inherit" in own)) return own as Config.WardicTransition
213
262
  const { inherit, ...rest } = own
214
- if (inherit === true) return { ...element, ...rest } as Config.WardicTransition
263
+ if (inherit === true) return { ...wardTransition, ...rest } as Config.WardicTransition
215
264
  return rest as Config.WardicTransition
216
265
  }
217
266
 
267
+ /** A target's values, and its failure: what {@link startingVariantsOf} reads of each. */
268
+ const valuesOfTarget = (target: Target): Values.Values => target.values
269
+ const failureOfTarget = (target: Target): Option.Option<VariantFailure> => target.failure
270
+
271
+ /** A variant's resolver that threw (#979): what it threw, and the variant's name where it has one. */
272
+ export interface VariantFailure {
273
+ readonly defect: unknown
274
+ readonly name: string | undefined
275
+ }
276
+
277
+ /** `variants` as the Starting style reads them, and the first of them whose resolver threw. */
278
+ export interface StartingVariants {
279
+ readonly variants: object | undefined
280
+ readonly failure: Option.Option<VariantFailure>
281
+ }
282
+
283
+ /** No variants: one value, as most Subjects have none (#979, bench:solid's mount). */
284
+ const NO_STARTING_VARIANTS: StartingVariants = { variants: undefined, failure: NO_FAILURE }
285
+
218
286
  /**
219
287
  * `variants` with each entry resolved to its values, a dynamic one with `custom` and no values yet
220
288
  * (#277): what dom's Starting style reads, which takes values maps only. As they are when none is a
221
- * function.
289
+ * function. A resolver that throws gives its entry no values, and its throw is the failure.
222
290
  */
223
- export const startingVariantsOf = (variants: object | undefined, custom: unknown): object | undefined => {
224
- if (Predicate.isUndefined(variants)) return undefined
291
+ export const startingVariantsOf = (variants: object | undefined, custom: unknown): StartingVariants => {
292
+ if (Predicate.isUndefined(variants)) return NO_STARTING_VARIANTS
225
293
  const entries = variants as Config.WardicVariants
226
- if (Bool.not(Arr.some(Rec.values(entries), Predicate.isFunction))) return variants
227
- return Rec.map(entries, (_, name) => resolveTarget(name, entries, custom, NO_VARIANT_STATE).values)
294
+ if (Bool.not(Arr.some(Rec.values(entries), Predicate.isFunction))) return { variants, failure: NO_FAILURE }
295
+ // Once a Subject's setup (#979): each entry resolved, a throwing resolver's left with no values.
296
+ const targets = Rec.map(entries, (_, name) => resolveTarget(name, entries, custom, NO_VARIANT_STATE))
297
+ return { variants: Rec.map(targets, valuesOfTarget), failure: Option.firstSomeOf(Arr.map(Rec.values(targets), failureOfTarget)) }
228
298
  }
229
299
 
300
+ /** What orchestration's resolution of a variant name, `entry`, came to: its failure, or none once it resolves. */
301
+ export type Orchestrated = (entry: Config.WardicVariantLabels, failure: Option.Option<VariantFailure>) => void
302
+
230
303
  /**
231
- * The own transition of an element's target now (#277): its `animate` map's, else the variant it
304
+ * The own transition of a Subject's target now (#277): its `animate` map's, else the variant it
232
305
  * names or inherits (`name`), resolved with `custom` and no values. What its orchestration reads.
306
+ * `orchestrated` is told what a name's resolution came to: a resolver that throws gives no own
307
+ * transition.
233
308
  */
234
309
  export const ownTransitionOf = (
235
310
  animate: object | Config.WardicVariantLabels | undefined,
236
311
  name: Config.WardicVariantLabels | undefined,
237
312
  variants: object | undefined,
238
313
  custom: unknown,
314
+ orchestrated?: Orchestrated,
239
315
  ): Config.WardicVariantTransition | undefined => {
240
316
  const byName = variants as Config.WardicVariants | undefined
241
317
  if (Bool.and(Predicate.isNotUndefined(animate), Bool.not(isLabels(animate)))) {
242
318
  return resolveTarget(animate as Config.WardicVariant, byName, custom, NO_VARIANT_STATE).transition
243
319
  }
244
320
  if (Predicate.isUndefined(name)) return undefined
245
- return resolveTarget(name, byName, custom, NO_VARIANT_STATE).transition
321
+ const target = resolveTarget(name, byName, custom, NO_VARIANT_STATE)
322
+ // #979 (Q6): a throw here is reported through the Subject's own once, its resolution's apart.
323
+ if (Predicate.isNotUndefined(orchestrated)) orchestrated(name, target.failure)
324
+ return target.transition
246
325
  }