@wardic/core 1.3.2 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (228) 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 +5 -4
  25. package/dist/DragRecognizer.d.ts.map +1 -1
  26. package/dist/DragRecognizer.js +37 -14
  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 +3 -3
  36. package/dist/InputSource.js +2 -2
  37. package/dist/Interpolator.d.ts +2 -2
  38. package/dist/Interpolator.js +2 -2
  39. package/dist/InterpolatorRegistry.d.ts +29 -15
  40. package/dist/InterpolatorRegistry.d.ts.map +1 -1
  41. package/dist/InterpolatorRegistry.js +17 -8
  42. package/dist/InterpolatorRegistry.js.map +1 -1
  43. package/dist/LiveValue.d.ts +7 -6
  44. package/dist/LiveValue.d.ts.map +1 -1
  45. package/dist/LiveValue.js +45 -14
  46. package/dist/LiveValue.js.map +1 -1
  47. package/dist/Machine.d.ts +7 -4
  48. package/dist/Machine.d.ts.map +1 -1
  49. package/dist/Machine.js +146 -45
  50. package/dist/Machine.js.map +1 -1
  51. package/dist/Playback.d.ts.map +1 -1
  52. package/dist/Playback.js +6 -1
  53. package/dist/Playback.js.map +1 -1
  54. package/dist/Projection.d.ts +9 -9
  55. package/dist/Projection.js +2 -2
  56. package/dist/Recognizer.d.ts +4 -3
  57. package/dist/Recognizer.d.ts.map +1 -1
  58. package/dist/Recognizer.js +49 -20
  59. package/dist/Recognizer.js.map +1 -1
  60. package/dist/ReducedMotion.d.ts +4 -4
  61. package/dist/ReducedMotion.js +6 -6
  62. package/dist/Renderer.d.ts +5 -5
  63. package/dist/Renderer.js +6 -6
  64. package/dist/Renderer.js.map +1 -1
  65. package/dist/Reorder.d.ts +1 -1
  66. package/dist/Reorder.d.ts.map +1 -1
  67. package/dist/Reorder.js +2 -1
  68. package/dist/Reorder.js.map +1 -1
  69. package/dist/ScrollSource.d.ts +1 -1
  70. package/dist/ScrollSource.d.ts.map +1 -1
  71. package/dist/Sequence.d.ts +1 -1
  72. package/dist/SharedSource.d.ts +3 -3
  73. package/dist/SharedSource.js +5 -5
  74. package/dist/SharedSource.js.map +1 -1
  75. package/dist/Spring.d.ts.map +1 -1
  76. package/dist/Spring.js +2 -1
  77. package/dist/Spring.js.map +1 -1
  78. package/dist/Values.d.ts +2 -2
  79. package/dist/Values.js +1 -1
  80. package/dist/index.d.ts +1 -1
  81. package/dist/index.js +1 -1
  82. package/dist/internal/carried.d.ts +13 -0
  83. package/dist/internal/carried.d.ts.map +1 -0
  84. package/dist/internal/carried.js +23 -0
  85. package/dist/internal/carried.js.map +1 -0
  86. package/dist/internal/firstSteps.d.ts +66 -0
  87. package/dist/internal/firstSteps.d.ts.map +1 -0
  88. package/dist/internal/firstSteps.js +107 -0
  89. package/dist/internal/firstSteps.js.map +1 -0
  90. package/dist/internal/frameLoop.d.ts +1 -1
  91. package/dist/internal/frameLoop.d.ts.map +1 -1
  92. package/dist/internal/frameLoop.js +102 -81
  93. package/dist/internal/frameLoop.js.map +1 -1
  94. package/dist/internal/lerpsNumbers.d.ts +11 -0
  95. package/dist/internal/lerpsNumbers.d.ts.map +1 -0
  96. package/dist/internal/lerpsNumbers.js +38 -0
  97. package/dist/internal/lerpsNumbers.js.map +1 -0
  98. package/dist/internal/options.d.ts +7 -7
  99. package/dist/internal/options.d.ts.map +1 -1
  100. package/dist/internal/options.js +10 -10
  101. package/dist/internal/options.js.map +1 -1
  102. package/dist/internal/stepper.d.ts +13 -2
  103. package/dist/internal/stepper.d.ts.map +1 -1
  104. package/dist/internal/stepper.js +16 -1
  105. package/dist/internal/stepper.js.map +1 -1
  106. package/dist/internal/tracing.d.ts +1 -1
  107. package/dist/internal/tracing.js +1 -1
  108. package/dist/unstable/AnimationControls.d.ts +37 -38
  109. package/dist/unstable/AnimationControls.d.ts.map +1 -1
  110. package/dist/unstable/AnimationControls.js +39 -36
  111. package/dist/unstable/AnimationControls.js.map +1 -1
  112. package/dist/unstable/AppearHandoff.d.ts +5 -5
  113. package/dist/unstable/AppearHandoff.d.ts.map +1 -1
  114. package/dist/unstable/BatchCalls.d.ts +2 -2
  115. package/dist/unstable/BatchCalls.js +5 -5
  116. package/dist/unstable/Config.d.ts +19 -19
  117. package/dist/unstable/Config.d.ts.map +1 -1
  118. package/dist/unstable/FirstSteps.d.ts +25 -0
  119. package/dist/unstable/FirstSteps.d.ts.map +1 -0
  120. package/dist/unstable/FirstSteps.js +2 -0
  121. package/dist/unstable/FirstSteps.js.map +1 -0
  122. package/dist/unstable/FlushGate.d.ts +53 -51
  123. package/dist/unstable/FlushGate.d.ts.map +1 -1
  124. package/dist/unstable/FlushGate.js +56 -49
  125. package/dist/unstable/FlushGate.js.map +1 -1
  126. package/dist/unstable/FrameEffects.d.ts +2 -2
  127. package/dist/unstable/FrameEffects.js +2 -2
  128. package/dist/unstable/FrameTime.d.ts +1 -1
  129. package/dist/unstable/FrameTime.js +1 -1
  130. package/dist/unstable/Imperative.d.ts +29 -9
  131. package/dist/unstable/Imperative.d.ts.map +1 -1
  132. package/dist/unstable/Imperative.js +79 -47
  133. package/dist/unstable/Imperative.js.map +1 -1
  134. package/dist/unstable/OwnValues.js +1 -1
  135. package/dist/unstable/PresenceRecord.d.ts +26 -26
  136. package/dist/unstable/PresenceRecord.d.ts.map +1 -1
  137. package/dist/unstable/PresenceRecord.js +8 -8
  138. package/dist/unstable/PresenceRecord.js.map +1 -1
  139. package/dist/unstable/Projector.d.ts +34 -0
  140. package/dist/unstable/Projector.d.ts.map +1 -0
  141. package/dist/unstable/Projector.js +9 -0
  142. package/dist/unstable/Projector.js.map +1 -0
  143. package/dist/unstable/Report.d.ts +1 -1
  144. package/dist/unstable/Report.js +1 -1
  145. package/dist/unstable/RetargetLegs.d.ts +1 -1
  146. package/dist/unstable/RetargetLegs.d.ts.map +1 -1
  147. package/dist/unstable/RetargetLegs.js +9 -8
  148. package/dist/unstable/RetargetLegs.js.map +1 -1
  149. package/dist/unstable/Spine.d.ts +81 -72
  150. package/dist/unstable/Spine.d.ts.map +1 -1
  151. package/dist/unstable/Spine.js +152 -150
  152. package/dist/unstable/Spine.js.map +1 -1
  153. package/dist/unstable/Stops.d.ts +3 -3
  154. package/dist/unstable/Stops.js +4 -4
  155. package/dist/unstable/Subject.d.ts +2 -2
  156. package/dist/unstable/Subject.js +2 -2
  157. package/dist/unstable/Timelines.d.ts +11 -11
  158. package/dist/unstable/Timelines.d.ts.map +1 -1
  159. package/dist/unstable/Timelines.js +3 -3
  160. package/dist/unstable/VariantTarget.d.ts +7 -7
  161. package/dist/unstable/VariantTarget.d.ts.map +1 -1
  162. package/dist/unstable/VariantTarget.js +11 -11
  163. package/dist/unstable/VariantTarget.js.map +1 -1
  164. package/dist/unstable/VariantTree.d.ts +36 -36
  165. package/dist/unstable/VariantTree.d.ts.map +1 -1
  166. package/dist/unstable/VariantTree.js +33 -33
  167. package/dist/unstable/VariantTree.js.map +1 -1
  168. package/dist/unstable/WardicConfigValue.d.ts +13 -13
  169. package/dist/unstable/WardicConfigValue.d.ts.map +1 -1
  170. package/dist/unstable/WardicConfigValue.js +4 -4
  171. package/dist/unstable/WardicConfigValue.js.map +1 -1
  172. package/package.json +1 -1
  173. package/src/Arc.ts +3 -3
  174. package/src/BaseValue.ts +18 -21
  175. package/src/Batch.ts +236 -22
  176. package/src/Clock.ts +18 -17
  177. package/src/DefaultTransition.ts +5 -3
  178. package/src/Drag.ts +32 -14
  179. package/src/DragActivity.ts +3 -3
  180. package/src/DragRecognizer.ts +41 -16
  181. package/src/Easing.ts +1 -1
  182. package/src/Frame.ts +5 -3
  183. package/src/InputFeed.ts +2 -2
  184. package/src/InputSource.ts +5 -5
  185. package/src/Interpolator.ts +3 -3
  186. package/src/InterpolatorRegistry.ts +22 -13
  187. package/src/LiveValue.ts +47 -17
  188. package/src/Machine.ts +199 -61
  189. package/src/Playback.ts +5 -1
  190. package/src/Projection.ts +9 -9
  191. package/src/Recognizer.ts +69 -38
  192. package/src/ReducedMotion.ts +6 -6
  193. package/src/Renderer.ts +6 -6
  194. package/src/Reorder.ts +3 -2
  195. package/src/ScrollSource.ts +1 -1
  196. package/src/Sequence.ts +1 -1
  197. package/src/SharedSource.ts +5 -5
  198. package/src/Spring.ts +2 -1
  199. package/src/Values.ts +2 -2
  200. package/src/index.ts +1 -1
  201. package/src/internal/carried.ts +22 -0
  202. package/src/internal/firstSteps.ts +139 -0
  203. package/src/internal/frameLoop.ts +103 -87
  204. package/src/internal/lerpsNumbers.ts +53 -0
  205. package/src/internal/options.ts +10 -10
  206. package/src/internal/stepper.ts +20 -2
  207. package/src/internal/tracing.ts +1 -1
  208. package/src/unstable/AnimationControls.ts +59 -56
  209. package/src/unstable/AppearHandoff.ts +6 -6
  210. package/src/unstable/BatchCalls.ts +5 -5
  211. package/src/unstable/Config.ts +19 -19
  212. package/src/unstable/FirstSteps.ts +26 -0
  213. package/src/unstable/FlushGate.ts +92 -82
  214. package/src/unstable/FrameEffects.ts +2 -2
  215. package/src/unstable/FrameTime.ts +1 -1
  216. package/src/unstable/Imperative.ts +126 -56
  217. package/src/unstable/OwnValues.ts +1 -1
  218. package/src/unstable/PresenceRecord.ts +29 -29
  219. package/src/unstable/Projector.ts +45 -0
  220. package/src/unstable/Report.ts +1 -1
  221. package/src/unstable/RetargetLegs.ts +10 -9
  222. package/src/unstable/Spine.ts +190 -188
  223. package/src/unstable/Stops.ts +6 -6
  224. package/src/unstable/Subject.ts +2 -2
  225. package/src/unstable/Timelines.ts +12 -12
  226. package/src/unstable/VariantTarget.ts +13 -13
  227. package/src/unstable/VariantTree.ts +42 -42
  228. package/src/unstable/WardicConfigValue.ts +13 -13
@@ -4,8 +4,8 @@
4
4
  * An Environment says what its Subjects are and how a plain one starts ({@link Subjects}), and what
5
5
  * its Batches are ({@link Batches}); each binding's `createAnimate()` builds on it.
6
6
  *
7
- * - **A Wardic element** animates through its own spine, registered here while it's mounted: the
8
- * call takes the keys it animates, which stay where it leaves them until the element's own target
7
+ * - **A Ward's Subject** animates through its own spine, registered here while it's mounted: the
8
+ * call takes the keys it animates, which stay where it leaves them until the Subject's own target
9
9
  * for them changes (Motion's latest-wins).
10
10
  * - **A plain Subject** animates through a spine of its own (#433's Q4), with no config, presence or
11
11
  * layout node: it starts from the Subject's Own value (ADR-0022) and keeps its values for the next
@@ -58,21 +58,21 @@ import * as Predicate from "effect/Predicate"
58
58
  import * as Rec from "effect/Record"
59
59
  import * as UndefinedOr from "effect/UndefinedOr"
60
60
 
61
- /** What an Imperative animation animates a Wardic element through: what its spine hands over (`host`). */
62
- type Animatable = Pick<Spine.ElementSpine, "host">
61
+ /** What an Imperative animation animates a Ward's Subject through: what its spine hands over (`host`). */
62
+ type Animatable = Pick<Spine.SubjectSpine, "host">
63
63
 
64
- /** Each mounted Wardic element's spine (Motion's `visualElementStore`), by its Subject. */
65
- // Module state (#460, Q7): each Wardic element's animatable, held weakly by its Subject.
66
- const wardicElements = new WeakMap<object, Animatable>()
64
+ /** Each mounted Ward's Subject's spine (Motion's `visualElementStore`), by its Subject. */
65
+ // Module state (#460, Q7): each Ward's Subject's animatable, held weakly by the Subject.
66
+ const wardedSubjects = new WeakMap<object, Animatable>()
67
67
 
68
68
  /**
69
- * Register a mounted Wardic element's spine for the Imperative animations of its Subject (#433): until
69
+ * Register a mounted Ward's Subject's spine for the Imperative animations of its Subject (#433): until
70
70
  * the returned function, which its unmount calls.
71
71
  */
72
72
  export const registerAnimatable = (subject: object, spine: Animatable): (() => void) => {
73
- wardicElements.set(subject, spine)
73
+ wardedSubjects.set(subject, spine)
74
74
  return () => {
75
- if (wardicElements.get(subject) === spine) wardicElements.delete(subject)
75
+ if (wardedSubjects.get(subject) === spine) wardedSubjects.delete(subject)
76
76
  }
77
77
  }
78
78
 
@@ -98,13 +98,13 @@ export interface AnimateEnv {
98
98
 
99
99
  /**
100
100
  * An Environment's Subjects, for `animate`: what its first argument names, and where a plain one
101
- * starts. The DOM's are elements, selectors looked up in the scope and lists of them; a scene's, its
102
- * objects.
101
+ * starts. `@wardic/dom`'s are its own kind, the strings it looks up in the scope, and lists of them; a scene's,
102
+ * its objects.
103
103
  */
104
104
  export interface Subjects<S extends object> {
105
105
  /** The Subjects `given` names, inside `scope` (a binding's scope, or `undefined`): none when it names none. */
106
106
  readonly resolve: (given: unknown, scope: unknown) => ReadonlyArray<S>
107
- /** A plain Subject's Base-value links (ADR-0022): its Own values, and the DOM's Starting style. */
107
+ /** A plain Subject's Base-value links (ADR-0022): its Own values, and `@wardic/dom`'s Starting style. */
108
108
  readonly startLinksOf: (subject: S) => Spine.StartLinks
109
109
  }
110
110
 
@@ -209,7 +209,7 @@ export interface Ports<S extends object> {
209
209
 
210
210
  /** A plain Subject's spine (#433's Q4), its values, and how many of its animations run, which keep it in the gate. */
211
211
  interface Plain {
212
- readonly spine: Spine.ElementSpine
212
+ readonly spine: Spine.SubjectSpine
213
213
  readonly snapshot: Spine.Snapshot
214
214
  readonly id: string
215
215
  running: number
@@ -238,11 +238,11 @@ const plainOf = <S extends object>(env: AnimateEnv, subjects: Subjects<S>, subje
238
238
  if (Predicate.isNotUndefined(known)) return known
239
239
  const id = `wardic-animate-${plainIds++}`
240
240
  const snapshot: Spine.Snapshot = Spine.emptySnapshotOf({})
241
- const spine = Spine.makeElementSpine({
241
+ const spine = Spine.makeSubjectSpine({
242
242
  runtime: env.runtime,
243
243
  gate: env.gate,
244
244
  id,
245
- element: subject,
245
+ subject,
246
246
  tag: undefined,
247
247
  config: () => NO_CONFIG,
248
248
  parent: undefined,
@@ -273,7 +273,7 @@ const plainOf = <S extends object>(env: AnimateEnv, subjects: Subjects<S>, subje
273
273
 
274
274
  /**
275
275
  * `transition` with `skipAnimations` when its scope's animations are skipped (#468, Motion's
276
- * `useAnimate`, which hands its config's to each animation): a Wardic element's own config can skip it
276
+ * `useAnimate`, which hands its config's to each animation): a Ward's Subject's own config can skip it
277
277
  * too, and a plain Subject has none.
278
278
  */
279
279
  const skippedIn = (env: AnimateEnv, transition: Config.WardicTransition | undefined): Config.WardicTransition | undefined => {
@@ -352,7 +352,7 @@ const endFree = (owner: Spine.Running | undefined): boolean => {
352
352
  // #746 (ADR-0067, *Amendment (#746)*, decision 10): here, not in the spine, so an app that never animates
353
353
  // imperatively ships none of it; the spine hands over what it takes (`SpineHost`).
354
354
  const imperativeTrackOf = (host: Spine.SpineHost, target: VariantTarget.Target, given: Config.WardicTransition | undefined, head: Playback.Playhead, hooks: Spine.ImperativeHooks): Spine.ImperativeTrack => {
355
- const { snapshot, owners, keepTheRest, element, positionalKeys, defaultTransition, unitScale, readVelocity, gate, forget, endLeg, live, own, legProgram, legEnded, turnBack, id, recordFrame, runtime, elementRules, measuredPairs, variableValues } = host
355
+ const { snapshot, owners, keepTheRest, subject, positionalKeys, defaultTransition, unitScale, readVelocity, gate, forget, endLeg, live, own, legProgram, legEnded, turnBack, id, recordFrame, runtime, subjectRules, measuredPairs, variableValues } = host
356
356
  /** A leg of an Imperative animation, forked as a Retarget's are; it lands on its track. */
357
357
  // Data-first: a pipe's curried forms are two closures more for every leg (#618, H1).
358
358
  const runImperative = (running: Spine.Running, program: Effect.Effect<unknown, never, WardicServices.WardicServices>): void => {
@@ -391,7 +391,7 @@ const imperativeTrackOf = (host: Spine.SpineHost, target: VariantTarget.Target,
391
391
  const reduce = host.reducedMotion()
392
392
  const skipped = host.skipAnimations()
393
393
  let measured: RetargetLegs.MeasuredPairs | undefined
394
- if (Bool.and(Bool.not(Bool.or(reduce, skipped)), Predicate.isNotUndefined(measuring))) measured = Spine.measuredOf(measuredPairs, element, UndefinedOr.getOrThrow(measuring), from, to, snapshot.values, stops, runtime, id)
394
+ if (Bool.and(Bool.not(Bool.or(reduce, skipped)), Predicate.isNotUndefined(measuring))) measured = Spine.measuredOf(measuredPairs, subject, UndefinedOr.getOrThrow(measuring), from, to, snapshot.values, stops, runtime, id)
395
395
  // Built once: a seek or a replay runs the same legs, from the same start, with the same velocities.
396
396
  const built = RetargetLegs.legsOf(from, to, given, reduce, skipped, positionalKeys, defaultTransition, readVelocity, undefined, stops, measured, snapshot.values, rests, unitScale)
397
397
  const variables = Spine.holdsVariable(variableValues, from, to, stops)
@@ -449,7 +449,7 @@ const imperativeTrackOf = (host: Spine.SpineHost, target: VariantTarget.Target,
449
449
  }
450
450
  /**
451
451
  * Its Transition end's keys put back as they were before it was set (Q5): at a cancel, a seek or a
452
- * replay, each a key no leg has drawn since, a later call's or the element's own. The next landing
452
+ * replay, each a key no leg has drawn since, a later call's or the Subject's own. The next landing
453
453
  * sets them again.
454
454
  */
455
455
  const putBack = (): void => {
@@ -463,10 +463,10 @@ const imperativeTrackOf = (host: Spine.SpineHost, target: VariantTarget.Target,
463
463
  // frame, its keys landed from its start, so a take before then takes nothing in flight, as Motion's
464
464
  // skipped value makes no animation. Its machine read only for a leg that lost a key.
465
465
  const snaps = (i: number): boolean => Machine.durationOf(machineOf(UndefinedOr.getOrThrow(built[i]))) === 0
466
- // A leg the element's own Retarget carried on, toward the same target, as its own (Q7): the call has lost it.
466
+ // A leg the Subject's own Retarget carried on, toward the same target, as its own (Q7): the call has lost it.
467
467
  let carried = false
468
468
  // Taken (#896's Q3, #951): a key it animates taken from its leg mid-flight, by a later animation or the
469
- // element's own target, or a leg carried off whole. A leg that lost one has fewer than it started
469
+ // Subject's own target, or a leg carried off whole. A leg that lost one has fewer than it started
470
470
  // with; one taken after its leg landed doesn't count, as Motion's, nor one that snaps.
471
471
  const taken = (): boolean => {
472
472
  if (carried) return true
@@ -509,7 +509,7 @@ const imperativeTrackOf = (host: Spine.SpineHost, target: VariantTarget.Target,
509
509
  }
510
510
  /**
511
511
  * A leg of this run ended **Superseded** (#951), told at its end, as it settles nothing of this
512
- * track's: carried on by the element's own Retarget as its own, its landing the Retarget's now (Q7);
512
+ * track's: carried on by the Subject's own Retarget as its own, its landing the Retarget's now (Q7);
513
513
  * or with every key taken, a count of 0 (only a take lowers it), which `taken` reads. Either counts
514
514
  * toward the track's landing, which finds it taken.
515
515
  */
@@ -534,7 +534,7 @@ const imperativeTrackOf = (host: Spine.SpineHost, target: VariantTarget.Target,
534
534
  if (head.speed < 0) return false
535
535
  return head.time >= duration()
536
536
  }
537
- // A key another leg draws: a later animation's, or the element's own.
537
+ // A key another leg draws: a later animation's, or the Subject's own.
538
538
  const drawnByAnother = (key: string): boolean => Predicate.isNotUndefined(owners.get(key))
539
539
  const run = (): void => {
540
540
  runs++
@@ -568,7 +568,7 @@ const imperativeTrackOf = (host: Spine.SpineHost, target: VariantTarget.Target,
568
568
  const duration = (): number =>
569
569
  Arr.reduce(built, 0, (longest, leg) => Math.max(longest, Machine.durationOf(machineOf(leg))))
570
570
  const machineOf = (leg: RetargetLegs.Leg): Machine.Machine<Frame.Frame<unknown>> => {
571
- if (leg._tag === "Blend") return runtime.runSync(Effect.suspend(leg.machine).pipe(InterpolatorRegistry.withKeyRules(elementRules)))
571
+ if (leg._tag === "Blend") return runtime.runSync(Effect.suspend(leg.machine).pipe(InterpolatorRegistry.withKeyRules(subjectRules)))
572
572
  return leg.machine() as Machine.Machine<Frame.Frame<unknown>>
573
573
  }
574
574
  const stop = (): void => {
@@ -581,7 +581,7 @@ const imperativeTrackOf = (host: Spine.SpineHost, target: VariantTarget.Target,
581
581
 
582
582
  /**
583
583
  * A call's transition on its target's own (#896, ADR-0061 *Amendment (#896)*, Q1): the options' fields
584
- * laid over the target's, shallowly, as `inherit: true` lays a target's over its element's. Motion's
584
+ * laid over the target's, shallowly, as `inherit: true` lays a target's over its Subject's. Motion's
585
585
  * `animate` reads the options alone.
586
586
  */
587
587
  // Its own handed back as it is with no options, so the legs' decode cache (#66) holds for it. Its
@@ -597,7 +597,7 @@ interface Readied<S extends object> {
597
597
  readonly subject: S
598
598
  readonly target: VariantTarget.Target
599
599
  readonly host: Spine.SpineHost
600
- /** Its plain spine: `undefined` for a Wardic element's, which runs through the element's own. */
600
+ /** Its plain spine: `undefined` for a Ward's Subject's, which runs through the Subject's own. */
601
601
  readonly plain: Plain | undefined
602
602
  }
603
603
 
@@ -614,7 +614,7 @@ const readiedOf = <S extends object>(env: AnimateEnv, subjects: Subjects<S>, sub
614
614
  // A function given as the target (past the types) that throws is an error at the call, as a key it
615
615
  // can't take is: the call takes nothing (#979; ADR-0074 keeps a refusal at the call a throw).
616
616
  if (Option.isSome(target.failure)) throw target.failure.value.defect
617
- const own = wardicElements.get(subject)
617
+ const own = wardedSubjects.get(subject)
618
618
  if (Predicate.isNotUndefined(own)) return readOwnValues({ subject, target, host: own.host(), plain: undefined })
619
619
  const plain = plainOf(env, subjects, subject)
620
620
  return readOwnValues({ subject, target, host: plain.spine.host(), plain })
@@ -635,7 +635,7 @@ const readOwnValues = <S extends object>(readied: Readied<S>): Readied<S> => {
635
635
  }
636
636
 
637
637
  /**
638
- * A readied Subject's animation (`readiedOf`): through its spine when it's a Wardic element's, else through
638
+ * A readied Subject's animation (`readiedOf`): through its spine when it's a Ward's Subject's, else through
639
639
  * its plain spine, in the gate while any of its animations runs.
640
640
  */
641
641
  const trackOf = <S extends object>(env: AnimateEnv, readied: Readied<S>, given: Config.WardicTransition | undefined, head: Playback.Playhead, settled: (landed: boolean) => void): Spine.ImperativeTrack => {
@@ -761,6 +761,12 @@ const skipsBatchCall = (env: AnimateEnv, options: WardicAnimateOptions | undefin
761
761
  /** Where an animation is: `"idle"`, `"running"`, `"paused"` or `"finished"`. Motion's `AnimationPlayState`. */
762
762
  export type WardicPlayState = "idle" | "running" | "paused" | "finished"
763
763
 
764
+ /** How an animation ended: whether it landed. */
765
+ export interface WardicAnimationEnd {
766
+ /** It arrived: it landed at its end, or `complete()` took it there. False when it was stopped, cancelled or taken over. */
767
+ readonly landed: boolean
768
+ }
769
+
764
770
  /**
765
771
  * What `animate` returns: an animation's controls, and a promise of its landing, so it can be awaited.
766
772
  * Motion's `AnimationPlaybackControls`.
@@ -783,6 +789,22 @@ export interface WardicPlaybackControls extends PromiseLike<void> {
783
789
  * animation takes one of its keys, as Motion's.
784
790
  */
785
791
  readonly finished: Promise<void>
792
+ /**
793
+ * Resolves once it ends, however it ends, with whether it landed: `landed` at its landing or
794
+ * `complete()`, and not at `stop()`, `cancel()`, or once a later animation takes one of its keys.
795
+ * It never rejects. Each time it plays has its own: played again, sought or completed after it ended,
796
+ * it gives a new one.
797
+ *
798
+ * @example
799
+ * setBusy(true)
800
+ * try {
801
+ * await controls.ended
802
+ * } finally {
803
+ * setBusy(false)
804
+ * }
805
+ */
806
+ // #955 (ADR-0061, *Amendment (#955)*): Wardic's own, beside Motion's `finished`.
807
+ readonly ended: Promise<WardicAnimationEnd>
786
808
  /** Play it on: from where it's paused, or again from its start once it's finished or cancelled. Not after `stop()`. */
787
809
  readonly play: () => void
788
810
  /** Hold it where it is. */
@@ -802,6 +824,57 @@ export interface AnimationWatch {
802
824
  readonly ended: (controls: WardicPlaybackControls, landed: boolean) => void
803
825
  }
804
826
 
827
+ /**
828
+ * A run's outcome as a promise: made at its first read, resolved once, and renewed for the next run. A run
829
+ * is what the scope's watch hears of an animation, from a start to its end.
830
+ */
831
+ interface RunPromise<A> {
832
+ /** This run's promise, made as it's first read: resolved already when the run has its outcome. */
833
+ readonly get: () => Promise<A>
834
+ /** The run's outcome, `value`, read yet or not. */
835
+ readonly resolve: (value: A) => void
836
+ /** A new run: the next read makes a new promise. */
837
+ readonly renew: () => void
838
+ }
839
+
840
+ /** A promise of each run's outcome, nothing made until it's read (#955: `finished` and `ended`). */
841
+ const runPromiseOf = <A>(): RunPromise<A> => {
842
+ let promise: Promise<A> | undefined
843
+ let settle: ((value: A) => void) | undefined
844
+ let outcome: Option.Option<A> = Option.none()
845
+ return {
846
+ get: () => {
847
+ if (Predicate.isNotUndefined(promise)) return promise
848
+ promise = Option.match(outcome, {
849
+ onSome: (value) => Promise.resolve(value),
850
+ onNone: () =>
851
+ new Promise<A>((settleWith) => {
852
+ settle = settleWith
853
+ }),
854
+ })
855
+ return promise
856
+ },
857
+ resolve: (value) => {
858
+ outcome = Option.some(value)
859
+ if (Predicate.isNotUndefined(settle)) settle(value)
860
+ },
861
+ renew: () => {
862
+ promise = undefined
863
+ settle = undefined
864
+ outcome = Option.none()
865
+ },
866
+ }
867
+ }
868
+
869
+ /** A run that landed, as `ended` gives it. */
870
+ const LANDED: WardicAnimationEnd = Object.freeze({ landed: true })
871
+
872
+ /** A run that ended without landing: stopped, cancelled or taken over. */
873
+ const NOT_LANDED: WardicAnimationEnd = Object.freeze({ landed: false })
874
+
875
+ /** How a run ended, as `ended` gives it. */
876
+ const endOf: (landed: boolean) => WardicAnimationEnd = /*#__PURE__*/ Bool.match({ onTrue: () => LANDED, onFalse: () => NOT_LANDED })
877
+
805
878
  /** Playback controls over `tracks`, all run through `head`, started now: a throw from `onComplete` reported on `runtime`. */
806
879
  const controlsOf = (
807
880
  tracks: ReadonlyArray<Spine.ImperativeTrack>,
@@ -818,9 +891,9 @@ const controlsOf = (
818
891
  let landed = 0
819
892
  // Whether a Subject's part ended without landing, a key of it taken by a later animation (#951).
820
893
  let anyTaken = false
821
- let resolve: (() => void) | undefined
822
- let finished: Promise<void> | undefined
823
- let isResolved = false
894
+ const finished = runPromiseOf<void>()
895
+ // Each run's end, however it ended (#955): a run is what `watch` hears, from its start to its end.
896
+ const ended = runPromiseOf<WardicAnimationEnd>()
824
897
  let duration: number | undefined
825
898
  const durationNow = (): number => {
826
899
  if (Predicate.isUndefined(duration)) duration = Arr.reduce(tracks, 0, (longest, track) => Math.max(longest, track.duration()))
@@ -831,20 +904,23 @@ const controlsOf = (
831
904
  anyTaken = false
832
905
  Arr.forEach(tracks, (track) => track.run())
833
906
  }
834
- const fresh = (): void => {
835
- finished = undefined
836
- resolve = undefined
837
- isResolved = false
838
- }
839
907
  const end = (how: WardicPlayState, landedNow: boolean): void => {
840
908
  const was = state
841
909
  state = how
842
- if (Bool.or(was === "running", was === "paused")) watch.ended(controls, landedNow)
910
+ if (Bool.or(was === "running", was === "paused")) {
911
+ ended.resolve(endOf(landedNow))
912
+ watch.ended(controls, landedNow)
913
+ }
914
+ }
915
+ // A new run, from an end: its own `ended`, and the watch told it started.
916
+ const newRun = (): void => {
917
+ ended.renew()
918
+ watch.started(controls)
843
919
  }
844
920
  const restart = (): void => {
845
921
  const was = state
846
922
  state = "running"
847
- if (Bool.or(was === "finished", was === "idle")) watch.started(controls)
923
+ if (Bool.or(was === "finished", was === "idle")) newRun()
848
924
  }
849
925
  const controls: WardicPlaybackControls = {
850
926
  get time() {
@@ -856,8 +932,8 @@ const controlsOf = (
856
932
  if (state !== "running") {
857
933
  Playback.pause(head)
858
934
  if (Bool.or(state === "finished", state === "idle")) {
859
- fresh()
860
- watch.started(controls)
935
+ finished.renew()
936
+ newRun()
861
937
  }
862
938
  state = "paused"
863
939
  }
@@ -876,16 +952,10 @@ const controlsOf = (
876
952
  return state
877
953
  },
878
954
  get finished() {
879
- if (Predicate.isUndefined(finished)) {
880
- finished = Bool.match(isResolved, {
881
- onTrue: () => Promise.resolve(),
882
- onFalse: () =>
883
- new Promise<void>((done) => {
884
- resolve = done
885
- }),
886
- })
887
- }
888
- return finished
955
+ return finished.get()
956
+ },
957
+ get ended() {
958
+ return ended.get()
889
959
  },
890
960
  then: (onResolve, onReject) => controls.finished.then(onResolve, onReject),
891
961
  play: () => {
@@ -897,7 +967,7 @@ const controlsOf = (
897
967
  }
898
968
  if (state === "running") return
899
969
  // Again from its start: its end when it plays backwards.
900
- fresh()
970
+ finished.renew()
901
971
  Playback.play(head)
902
972
  Playback.seek(head, Bool.match(head.speed < 0, { onTrue: durationNow, onFalse: () => 0 }))
903
973
  restart()
@@ -936,8 +1006,7 @@ const controlsOf = (
936
1006
  stopped = true
937
1007
  return end("idle", false)
938
1008
  }
939
- isResolved = true
940
- UndefinedOr.map(resolve, (done) => done())
1009
+ finished.resolve(undefined)
941
1010
  // Finished before its onComplete runs, as Motion's `finish()`: a throw there leaves it finished, and
942
1011
  // is reported each time it lands (#977; ADR-0074, *Amendment (#979, group A)*).
943
1012
  end("finished", true)
@@ -961,6 +1030,7 @@ export const finishedControls = (): WardicPlaybackControls => {
961
1030
  duration: 0,
962
1031
  state: "finished",
963
1032
  finished: done,
1033
+ ended: Promise.resolve(LANDED),
964
1034
  then: (onResolve, onReject) => done.then(onResolve, onReject),
965
1035
  play: constVoid,
966
1036
  pause: constVoid,
@@ -1071,7 +1141,7 @@ const builtAtRun = (build: () => Spine.ImperativeTrack): Spine.ImperativeTrack =
1071
1141
  * An **Animation scope**'s `animate` (#433), over an Environment's {@link Ports}: `animate(subject,
1072
1142
  * target, options?)`, a Batch's `animate(batch, target, options?)` and `animate(sequence, options?)`,
1073
1143
  * each returning its Playback controls. `scope()` is handed to the Environment's {@link Subjects.resolve}
1074
- * (the DOM's selectors are looked up inside it); each animation is told to `watch` as it starts and
1144
+ * (`@wardic/dom` looks its strings up inside it); each animation is told to `watch` as it starts and
1075
1145
  * ends. Every Subject's legs start in the call, on the loop by the end of its task. An Environment
1076
1146
  * types its own overloads over it.
1077
1147
  *
@@ -1223,7 +1293,7 @@ const subjectsIn = <S extends object>(batches: Batches<S>, subjects: ReadonlyArr
1223
1293
 
1224
1294
  /**
1225
1295
  * A sequence's steps for core (#433): labels as they are; a Segment of Subjects' Subjects (a string
1226
- * the Environment resolves, a DOM selector, looked up once a sequence, inside `scope`), values and each
1296
+ * the Environment resolves, looked up once a sequence, inside `scope`), values and each
1227
1297
  * value's transition; a function Segment's own value, from 0 to 1 unless it gives its stops.
1228
1298
  */
1229
1299
  const stepsOf = <S extends object>(ports: Ports<S>, sequence: ReadonlyArray<unknown>, scope: unknown, defaults: Config.WardicTransition | undefined): ReadonlyArray<Sequence.Step<S | Callback | BatchMember>> => {
@@ -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"
@@ -26,8 +26,8 @@ import * as UndefinedOr from "effect/UndefinedOr"
26
26
  * the child's owner so the parent-driven exit reads them after the child leaves.
27
27
  */
28
28
  export interface PresenceRecord<E extends Subject.Subject = Subject.Subject> {
29
- /** The child's root Subject (the same `el` the spine wires). */
30
- readonly element: E
29
+ /** The child's root Subject (the same `subject` the spine wires). */
30
+ readonly subject: E
31
31
  /** The latest emitted value-map, updated by the spine each frame. */
32
32
  readonly snapshot: { current: Values.Values }
33
33
  /**
@@ -38,13 +38,13 @@ export interface PresenceRecord<E extends Subject.Subject = Subject.Subject> {
38
38
  readonly exitOf: (custom: unknown, inherited: Config.WardicVariantLabels | undefined) => PresenceExit
39
39
  /**
40
40
  * Where it sits in the variant tree, decided at setup as the tree is: whether it joins the
41
- * 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
42
42
  * exit name, in its stagger), whether its own Variant children join it, and whether it's a twin
43
43
  * (a `layoutId`, whose crossfade replaces its exit). Left out: none of them.
44
44
  */
45
45
  readonly tree?: PresenceTree
46
46
  /**
47
- * 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
48
48
  * `@wardic/dom`, its `style`), else its Own value, read from the Subject kept at the exit, in the
49
49
  * shape of `like` (the key's exit target). `undefined` starts it at its target. Optional: a record
50
50
  * without it starts such a key at its target.
@@ -67,11 +67,11 @@ export interface PresenceRecord<E extends Subject.Subject = Subject.Subject> {
67
67
  readonly skipAnimations?: (() => boolean) | undefined
68
68
  }
69
69
 
70
- /** 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. */
71
71
  export interface PresenceSeed {
72
72
  readonly values: Values.Values
73
73
  readonly velocities: Readonly<Record<string, number>>
74
- /** 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. */
75
75
  readonly box?: Box.Box | undefined
76
76
  /** The crossfade factor a twin it takes over from had faded out to: its handover's fade goes on from there. */
77
77
  readonly fade?: number | undefined
@@ -88,7 +88,7 @@ export interface PresenceExit {
88
88
  readonly name: Config.WardicVariantLabels | undefined
89
89
  /**
90
90
  * A list's exit by name (#297): each name's keys (those it's the last to set) on its own transition,
91
- * 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
92
92
  * name has one, keys or none. Left out for a single name or a values map: the whole exit is one.
93
93
  */
94
94
  readonly groups?: ReadonlyArray<ExitGroup> | undefined
@@ -121,17 +121,17 @@ export interface PresenceContextValue<E extends Subject.Subject = Subject.Subjec
121
121
  */
122
122
  readonly register: (rec: PresenceRecord<E>) => () => void
123
123
  /**
124
- * 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:
125
125
  * `<AnimatePresence initial={false}>`, during its first render (Motion's
126
126
  * `presenceContext.initial`). A child that enters later animates in. Optional: left out, never.
127
127
  */
128
128
  readonly blocksInitial?: () => boolean
129
129
  /**
130
- * 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`
131
131
  * when it isn't, and it starts now. Else `start` is called once the child is shown, and the
132
- * 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.
133
133
  */
134
- readonly hold?: (el: E, start: () => void) => (() => void) | undefined
134
+ readonly hold?: (subject: E, start: () => void) => (() => void) | undefined
135
135
  /**
136
136
  * A presence hook's registration: `usePresence`'s and `useIsPresent`'s.
137
137
  * Optional: left out, nothing is watched.
@@ -140,39 +140,39 @@ export interface PresenceContextValue<E extends Subject.Subject = Subject.Subjec
140
140
  /** The presence's `custom`, reactive: `usePresenceData`'s. Left out, `undefined`. */
141
141
  readonly data?: () => unknown
142
142
  /**
143
- * 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
144
144
  * made, before the presence decides what it shows (so `mode="wait"` doesn't hold a child
145
- * 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).
146
146
  * Optional: left out, no child is keyed.
147
147
  */
148
- readonly made?: (el: E, key: string | number | undefined, twin: boolean) => void
148
+ readonly made?: (subject: E, key: string | number | undefined, twin: boolean) => void
149
149
  /**
150
- * 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,
151
151
  * before its first Retarget. `undefined`: as it would. Optional: left out, never.
152
152
  */
153
- readonly takeOverOf?: (el: E) => PresenceSeed | undefined
153
+ readonly takeOverOf?: (subject: E) => PresenceSeed | undefined
154
154
  }
155
155
 
156
- /** Tell `presence` a Wardic element was made ({@link PresenceContextValue.made}): nothing without one. */
157
- 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 => {
158
158
  if (Predicate.isUndefined(presence)) return
159
- UndefinedOr.map(presence.made, (tell) => tell(el, key, twin))
159
+ UndefinedOr.map(presence.made, (tell) => tell(subject, key, twin))
160
160
  }
161
161
 
162
- /** Where `el` 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, 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 => {
164
164
  if (Predicate.isUndefined(presence)) return undefined
165
- return UndefinedOr.map(presence.takeOverOf, (of) => of(el))
165
+ return UndefinedOr.map(presence.takeOverOf, (of) => of(subject))
166
166
  }
167
167
 
168
168
  /**
169
- * What a presence hook registers (#277's PR 5b, ADR-0048): its element, whose leaving child it
170
- * 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
171
171
  * goes some other way.
172
172
  */
173
173
  export interface PresenceWatch<E extends Subject.Subject = Subject.Subject> {
174
- /** Its element, once it has one: the child that holds it is the one it belongs to. */
175
- 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
176
176
  /** Whether it holds its child as it leaves, until `release` is called (`usePresence`). */
177
177
  readonly holds: boolean
178
178
  /**
@@ -191,7 +191,7 @@ export interface PresenceWatch<E extends Subject.Subject = Subject.Subject> {
191
191
  readonly interrupted?: () => void
192
192
  }
193
193
 
194
- /** 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}). */
195
195
  export const presenceBlocksInitial = <E extends Subject.Subject>(presence: PresenceContextValue<E> | undefined): boolean =>
196
196
  UndefinedOr.match(presence, {
197
197
  onUndefined: constFalse,
@@ -202,5 +202,5 @@ export const presenceBlocksInitial = <E extends Subject.Subject>(presence: Prese
202
202
  * Whether `el` waits for its child to be shown ({@link PresenceContextValue.hold}): the call
203
203
  * that cancels `start`, or `undefined` when it starts now.
204
204
  */
205
- export const presenceHold = <E extends Subject.Subject>(presence: PresenceContextValue<E> | undefined, el: E, start: () => void): (() => void) | undefined =>
206
- 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>
@@ -67,7 +67,7 @@ export const debugKept: Effect.Effect<boolean> = /*#__PURE__*/ Effect.map(Refere
67
67
  * A lifecycle debug log for `scope` (`wardic.projection`, say): `log(event, annotations?)` logs
68
68
  * `scope: event` at Debug, forked on `runner`, with the annotations. Whether a Debug log would be kept
69
69
  * is read once, here ({@link debugKept}): when it wouldn't, `on` is `false` and `log` returns at once,
70
- * 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.
71
71
  */
72
72
  // #618 (M4): each call forked a fiber whatever the level, 0.3-0.5 µs to log nothing (one per layout
73
73
  // node's mount and unmount); core's Frame loop reads the level once as this does (frameLoop.ts).