@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,54 +4,55 @@
4
4
  * sinks, and its Environment the edges it reads (`GateEnvironment`); the gate imports nothing from a
5
5
  * framework.
6
6
  *
7
- * Per ADR-0006, per-frame writes never reach their element directly. Each source
7
+ * Per ADR-0006, per-frame writes never reach their Subject directly. Each source
8
8
  * `write(id, partialValues)`s into a provider-owned gate that:
9
9
  *
10
- * 1. Accumulates *value-maps* (NOT already-projected Patches) per element,
11
- * merging partials by key — so multiple sources can feed one element
10
+ * 1. Accumulates *value-maps* (NOT already-projected Patches) per Subject,
11
+ * merging partials by key — so multiple sources can feed one Subject
12
12
  * (e.g. a drag setting `x`/`y` while a spring drives `scale`, all
13
13
  * collapsing into one grouped `transform`). Projecting per source would
14
14
  * clobber the grouped transform.
15
15
  * 2. Resolves the Renderer's PURE `project` ONCE at creation and uses it to
16
- * turn each dirty element's merged value-map into a `Patch` exactly once
17
- * per element per frame.
18
- * 3. Commits each resulting Patch onto its element with the Renderer's `commit`, a plain
19
- * call (ADR-0034) — one pass over the elements per frame, shared by every element: at the end of the
16
+ * turn each dirty Subject's merged value-map into a `Patch` exactly once
17
+ * per Subject per frame; or, for a Renderer with a projector (`unstable/Projector`),
18
+ * the Subject's own, made when it registers, whose patch it rewrites in place.
19
+ * 3. Commits each resulting Patch onto its Subject with the Renderer's `commit`, a plain
20
+ * call (ADR-0034) — one pass over the Subjects per frame, shared by every Subject: at the end of the
20
21
  * Frame loop's tick, in the Refresh frame that computed the values (ADR-0033). No
21
- * framework runs per frame: a binding's render carries an element's style only until its
22
+ * framework runs per frame: a binding's render carries a Subject's style only until its
22
23
  * first commit (ADR-0021, decision 6), and after it only the keys the gate doesn't hold.
23
24
  *
24
25
  * Three locked design decisions (this session's grills):
25
26
  * - FLUSHED at the end of the Frame loop's tick (ADR-0033): the gate registers a hook on
26
27
  * the Environment's loop (`afterTick`), so everything a tick writes is applied at the end
27
- * of that tick, inside the Clock's callback, and paints in that Refresh frame. A write
28
+ * of that tick, inside the Clock's callback, and drawn in that Refresh frame. A write
28
29
  * made outside a tick (a drag's move, a `release` from a task, an effect a sink's hook ran,
29
30
  * a Tier 2 `Stream` on `Clock.ticks` subscribed after the loop) still requests a
30
31
  * Refresh frame, only if one is not already pending, and the hook withdraws that request
31
32
  * when it flushes first. `flush` does NOT auto-reschedule, so an idle accumulator
32
33
  * requests no frames — the next `write` does. The frames come from the Environment's
33
34
  * `RefreshFrameSource` (ADR-0031): `@wardic/dom`'s is its runtime's frame callback. No binding
34
- * asks its runtime for frames itself. A Tier 2 `Stream` that writes here paints in
35
+ * asks its runtime for frames itself. A Tier 2 `Stream` that writes here is drawn in
35
36
  * the loop's frame or the next one, by its subscription order (ADR-0033): run it on the
36
- * loop (`Machine.run`) to paint with it.
37
- * - ONE flush per frame: all dirty elements flush together. The one exception
37
+ * loop (`Machine.run`) to be drawn with it.
38
+ * - ONE flush per frame: all dirty Subjects flush together. The one exception
38
39
  * is `flushPass` (ADR-0018): a projection Measure pass's own writes are applied
39
- * at the end of its task, so a new layout never paints without its projection.
40
- * - ONE sink shape (ADR-0034): a sink is the element its patch is committed onto. The gate
41
- * also removes a key its last patch had and this one doesn't (a dragged element's raise
42
- * once it's dropped, ADR-0016 *Amendment (Reorder)*), restoring the element's own
40
+ * at the end of its task, so a new layout is never drawn without its projection.
41
+ * - ONE sink shape (ADR-0034): a sink is the Subject its patch is committed onto. The gate
42
+ * also removes a key its last patch had and this one doesn't (a dragged Subject's raise
43
+ * once it's dropped, ADR-0016 *Amendment (Reorder)*), restoring the Subject's own
43
44
  * value, saved before the gate first wrote the key. Two hooks reach the binding,
44
45
  * outside the commits, each in the binding's `batch` (ADR-0034, *Amendment (#209)*): the
45
- * Starting-style switch before an element's first commit (`beforeFirstCommit`), and the keys
46
- * the gate holds on the element whenever they change (`onHeld`), so the binding's `style`
46
+ * Starting-style switch before a Subject's first commit (`beforeFirstCommit`), and the keys
47
+ * the gate holds on the Subject whenever they change (`onHeld`), so the binding's `style`
47
48
  * leaves them to Wardic.
48
49
  *
49
50
  * Observability (CONTEXT.md convention): the hot path (`write`/`flush`) is the
50
51
  * per-frame work, so — exactly like core's per-frame writes and the Clock's
51
- * `tick` — it stays quiet (no span, no per-call log, no metric). A throw in one element's step (its
52
- * binding's hook, the read of its own value, its Timeline values, its commit) is that element's: it
52
+ * `tick` — it stays quiet (no span, no per-call log, no metric). A throw in one Subject's step (its
53
+ * binding's hook, the read of its own value, its Timeline values, its commit) is that Subject's: it
53
54
  * commits nothing that frame, a run of them is reported once (`Report.failure`) until it commits again,
54
- * and every other element still commits. Anything else a flush throws is reported and the gate
55
+ * and every other Subject still commits. Anything else a flush throws is reported and the gate
55
56
  * goes on, so it can't fail the Frame loop's tick it runs in (ADR-0033).
56
57
  *
57
58
  * Unstable, for Wardic's own packages: public, with no semver promise.
@@ -60,15 +61,17 @@
60
61
  */
61
62
  // Unstable: ADR-0071, decision 5. #672: dom's `internal/gate.ts`, moved for the spine to write through
62
63
  // it in core; dom's `FlushGate` builds it with the DOM's edges (`DOM_GATE`) and gives it as a Layer.
63
- // #969 (ADR-0033, *Amendment (#969)*): one element's failure in a flush is its own.
64
+ // #969 (ADR-0033, *Amendment (#969)*): one Subject's failure in a flush is its own.
64
65
  import * as FrameLoop from "../FrameLoop.ts"
65
66
  import * as RefreshFrameSource from "../RefreshFrameSource.ts"
66
67
  import * as Renderer from "../Renderer.ts"
68
+ import * as Projector from "./Projector.ts"
67
69
  import * as Cause from "effect/Cause"
68
70
  import * as Atom from "effect/reactivity/Atom"
69
71
  import * as AtomRegistry from "effect/reactivity/AtomRegistry"
70
72
  import * as Effect from "effect/Effect"
71
73
  import * as Exit from "effect/Exit"
74
+ import * as Option from "effect/Option"
72
75
  import type * as Fiber from "effect/Fiber"
73
76
  import * as Predicate from "effect/Predicate"
74
77
  import * as UndefinedOr from "effect/UndefinedOr"
@@ -80,33 +83,33 @@ import * as Report from "./Report.ts"
80
83
  * at flush time.
81
84
  */
82
85
  export interface FlushSink {
83
- /** The element the patch is committed onto. */
86
+ /** The Subject the patch is committed onto. */
84
87
  readonly target: unknown
85
88
  /**
86
- * Called once, just before the element's first commit in a frame flush (not a Measure
87
- * pass's `flushPass`), inside the binding's `batch` with every other element's switch that
89
+ * Called once, just before the Subject's first commit in a frame flush (not a Measure
90
+ * pass's `flushPass`), inside the binding's `batch` with every other Subject's switch that
88
91
  * flush: a binding drops its Starting style from its `style` here,
89
92
  * so its framework removes those keys and the commit writes the first frame in the same
90
- * Refresh frame, with no paint in between.
93
+ * Refresh frame, with nothing drawn in between.
91
94
  */
92
95
  readonly beforeFirstCommit?: (() => void) | undefined
93
96
  /**
94
- * Called with every key the gate now holds on the element, each time that set changes: after the
97
+ * Called with every key the gate now holds on the Subject, each time that set changes: after the
95
98
  * gate restores a key it dropped, and before the commit that first
96
- * writes a key. A binding whose `style` reaches the element leaves these keys out of it,
99
+ * writes a key. A binding whose `style` reaches the Subject leaves these keys out of it,
97
100
  * so its framework never writes over Wardic's value (`style` is a key's fallback). Called in
98
- * the binding's `batch`, with every other element's whose keys changed that flush, so what the
99
- * binding changes reaches the element before the commit, a framework that applies an update later
101
+ * the binding's `batch`, with every other Subject's whose keys changed that flush, so what the
102
+ * binding changes reaches the Subject before the commit, a framework that applies an update later
100
103
  * (Solid 2) included.
101
104
  */
102
105
  // ADR-0034, *Amendment (#209)*.
103
106
  readonly onHeld?: ((keys: ReadonlyArray<string>) => void) | undefined
104
107
  /**
105
- * Called once per frame in which the element's values were committed, after every commit of that
108
+ * Called once per frame in which the Subject's values were committed, after every commit of that
106
109
  * frame (Motion's `onUpdate`), with its values before
107
- * projection (`x` as a number). The object is the element's own, reused each call: valid during
110
+ * projection (`x` as a number). The object is the Subject's own, reused each call: valid during
108
111
  * the call, copied to keep. A Measure pass's commits are told at the frame flush after them, so
109
- * a frame tells each element once. A write it makes is the next frame's. A throw is reported,
112
+ * a frame tells each Subject once. A write it makes is the next frame's. A throw is reported,
110
113
  * and the others are still told.
111
114
  */
112
115
  readonly onCommit?: ((values: Readonly<Record<string, unknown>>) => void) | undefined
@@ -136,18 +139,21 @@ const clear = (list: EntryList): void => {
136
139
  list.count = 0
137
140
  }
138
141
 
139
- /** Accumulated pre-`project` state for one registered element. */
142
+ /** Accumulated pre-`project` state for one registered Subject. */
140
143
  interface Entry {
141
144
  /** Its gate id: what a failure of its own is reported with (#969). */
142
145
  readonly id: string
146
+ /** What projects its values: its Renderer's projector, made for it, or else the Renderer's `project`. */
147
+ // #1030: its own, so a moving Subject's frames make no patch.
148
+ readonly projector: Projector.Projector
143
149
  /** Merged value-map (partials `Object.assign`ed in by key). */
144
150
  readonly values: Record<string, unknown>
145
- /** Where this element's projected Patch goes. */
151
+ /** Where this Subject's projected Patch goes. */
146
152
  readonly sink: FlushSink
147
153
  /** Whether a `write` has landed since the last flush. */
148
154
  dirty: boolean
149
155
  /**
150
- * The keys the gate holds on the element: its last patch's, each with the element's own
156
+ * The keys the gate holds on the Subject: its last patch's, each with the Subject's own
151
157
  * value from before the gate first wrote it (`""` for none), to restore when the
152
158
  * key drops out.
153
159
  */
@@ -191,7 +197,7 @@ export interface GateTimeline {
191
197
  /**
192
198
  * What the gate reads of its Environment's targets, and what it keeps from a sink: a target's value
193
199
  * for a key before the gate first writes it there (`""` for none), which it gives back at the key's
194
- * release, and the key its Renderer reserves for an element's Transform template, which `onCommit`
200
+ * release, and the key its Renderer reserves for a Subject's Transform template, which `onCommit`
195
201
  * never sees.
196
202
  */
197
203
  // #672 (PR2-Q1): the gate's two edges of its Environment, given by `FlushGate.make`, its only builder,
@@ -201,7 +207,7 @@ export interface GateEnvironment {
201
207
  readonly templateKey: string
202
208
  }
203
209
 
204
- /** A step of one element's flush, as its failure is reported (#969): `prepare`'s report as its commit. */
210
+ /** A step of one Subject's flush, as its failure is reported (#969): `prepare`'s report as its commit. */
205
211
  type Step = "a commit" | "a beforeFirstCommit" | "an onHeld" | "a Timeline sync"
206
212
 
207
213
  /** Each of `values` cancelled (#240). Per flush: a plain loop. */
@@ -209,18 +215,18 @@ const cancelEach = (values: Iterable<GateTimeline>): void => {
209
215
  for (const value of values) value.cancel()
210
216
  }
211
217
 
212
- /** A Flush gate: what a binding registers its elements with and writes their values into, one per provider. */
218
+ /** A Flush gate: what a binding registers its Subjects with and writes their values into, one per provider. */
213
219
  export interface FlushGate {
214
220
  /**
215
- * Register an element under `id` with its `sink`. Returns an unregister fn
216
- * that removes the element from the accumulator (a subsequent `write` is a
221
+ * Register a Subject under `id` with its `sink`. Returns an unregister fn
222
+ * that removes the Subject from the accumulator (a subsequent `write` is a
217
223
  * no-op). `values` start its value-map, unflushed: drawn with its first `write`, so they never
218
224
  * commit alone.
219
225
  */
220
226
  // #443: its Transform template, which mustn't take its Starting style off early.
221
227
  readonly register: (id: string, sink: FlushSink, values?: Readonly<Record<string, unknown>>) => () => void
222
228
  /**
223
- * Merge `partial` into the element's value-map by key, mark it dirty, and
229
+ * Merge `partial` into the Subject's value-map by key, mark it dirty, and
224
230
  * schedule a flush: the end of the Frame loop's tick, for a write made in one, or else the
225
231
  * next Refresh frame. A `write` for an unregistered (or unregistered-since) id
226
232
  * is a no-op.
@@ -232,13 +238,13 @@ export interface FlushGate {
232
238
  * `pass()` runs are recorded; each recorded entry is `project`ed and committed once, and
233
239
  * marked clean. Everything else stays dirty for its flush. A write made by an effect a sink's
234
240
  * hook runs (a Solid effect) takes the ordinary path. The Projection system calls it at the
235
- * end of a task, so a new layout never paints without its projection.
241
+ * end of a task, so a new layout is never drawn without its projection.
236
242
  */
237
243
  readonly flushPass: (pass: () => void) => void
238
244
  /**
239
- * Hand `keys` back to the element's own style: drop each from the element's
245
+ * Hand `keys` back to the Subject's own style: drop each from the Subject's
240
246
  * value-map and schedule a flush, which writes `restore[key]` (its Environment's text form) for a key it had
241
- * written, or else the element's own value it overwrote, and tells the sink (`onHeld`). A key the
247
+ * written, or else the Subject's own value it overwrote, and tells the sink (`onHeld`). A key the
242
248
  * entry doesn't hold, or an unknown id, is a no-op. A binding releases a key back at its `style`
243
249
  * value, so a later `style` change shows at rest. A later `write` brings the key back. A property in
244
250
  * `keep` (`transform` for its keys) is left as it's drawn when it drops out: another writer draws it next.
@@ -246,28 +252,28 @@ export interface FlushGate {
246
252
  // `keep`: #665's PR 4, a Batch member's group handed back to its Batch, whose writer draws it from then on.
247
253
  readonly release: (id: string, keys: ReadonlyArray<string>, restore?: Readonly<Record<string, string>>, keep?: ReadonlyArray<string>) => void
248
254
  /**
249
- * The element's value for `id`'s `key`, live: an `Atom` set as each write that
255
+ * The Subject's value for `id`'s `key`, live: an `Atom` set as each write that
250
256
  * changes it lands, so it's the value the next commit draws, before the Renderer projects it
251
257
  * (`x` as a number, not a `transform`). Set at the write, not the commit, so a value derived
252
258
  * from it (another key following it through a binding) is written in the same frame and
253
259
  * commits with it. `undefined` before the key's first write, and once it's released or the
254
- * element unregisters. One Atom for an id and a key, made on first ask, so per frame only the
260
+ * Subject unregisters. One Atom for an id and a key, made on first ask, so per frame only the
255
261
  * keys asked for cost anything.
256
262
  */
257
263
  readonly valueOf: (id: string, key: string) => Atom.Atom<unknown>
258
264
  /**
259
- * Run `key`'s Timeline value on `id`'s element (#240), or stop it (`undefined`): a binding sets one
265
+ * Run `key`'s Timeline value on `id`'s Subject (#240), or stop it (`undefined`): a binding sets one
260
266
  * while the key shows its Live value, and clears it when an entry of the Override stack takes the
261
- * key. The gate goes on writing the key: at each flush that commits the element, before the commit,
267
+ * key. The gate goes on writing the key: at each flush that commits the Subject, before the commit,
262
268
  * it starts the value's animation over it, or cancels it while something else adds to its property
263
269
  * (a projection, a Transform template, another transform key off its identity), so a frame shows one
264
270
  * or the other. A cleared or replaced one is cancelled at the next flush; a released key's, an
265
- * unregistered element's and a disposed gate's, at once. Setting one schedules a flush.
271
+ * unregistered Subject's and a disposed gate's, at once. Setting one schedules a flush.
266
272
  */
267
273
  readonly timeline: (id: string, key: string, timeline: GateTimeline | undefined) => void
268
274
  /**
269
275
  * Call `fn` once, after the gate's next flush: the end of the Frame loop's tick, for a call
270
- * made in one, else the next Refresh frame's, so what was written before it is on the elements.
276
+ * made in one, else the next Refresh frame's, so what was written before it is on the Subjects.
271
277
  * It schedules that flush if none is pending. A binding tells an animation's end here, as Motion's
272
278
  * `onAnimationComplete` comes with the final value set. One that throws is reported, and the rest
273
279
  * still run.
@@ -282,7 +288,7 @@ export interface FlushGate {
282
288
  // #672: named here, as dom's `FlushGate` names it, so the spine reads the gate's own types in core.
283
289
  export type Shape = Omit<FlushGate, "dispose">
284
290
 
285
- /** An element's commit target and hooks, given to `register`. */
291
+ /** A Subject's commit target and hooks, given to `register`. */
286
292
  export type Sink = FlushSink
287
293
 
288
294
  /** What a flush gate needs from its Environment: the `Renderer`, the Frame loop it flushes at the end of each tick of, and the `RefreshFrameSource`. */
@@ -304,11 +310,11 @@ export interface FlushGateRuntime {
304
310
  export interface FlushGateOptions {
305
311
  /**
306
312
  * Runs a flush's hooks together: calls `apply`, and returns once every update inside it has reached
307
- * the elements, before the gate commits. Solid 1 passes its `batch`, Solid 2 runs `apply` then
313
+ * the Subjects, before the gate commits. Solid 1 passes its `batch`, Solid 2 runs `apply` then
308
314
  * `flush()`, and React would pass `flushSync`, untried; a binding with nothing to batch passes
309
315
  * `(apply) => apply()`. Called at most twice a flush: once for the starting-style switches
310
- * (`beforeFirstCommit`) of the elements committing for the first time, before anything is read off the
311
- * elements; and once for the held keys (`onHeld`) of the elements whose held keys changed.
316
+ * (`beforeFirstCommit`) of the Subjects committing for the first time, before anything is read off the
317
+ * Subjects; and once for the held keys (`onHeld`) of the Subjects whose held keys changed.
312
318
  */
313
319
  // ADR-0031, decision 3, ADR-0034; *Amendment (#209)*.
314
320
  readonly batch: (apply: () => void) => void
@@ -319,7 +325,8 @@ export interface FlushGateOptions {
319
325
  * switches through the binding's `batch`.
320
326
  *
321
327
  * Resolves both ONCE here: `project` is pure and `commit` a plain call (both called directly at
322
- * flush, ADR-0034), `requestFrame` /
328
+ * flush, ADR-0034), and a Renderer's projector maker makes each Subject's projector as it registers;
329
+ * `requestFrame` /
323
330
  * `cancelFrame` schedule and cancel the flush of a write made outside a tick, and the Frame
324
331
  * loop's `afterTick` takes the gate's hook for its lifetime. All come from whichever env the
325
332
  * provider was given (`DomLive` / `TestLive`), so the gate inherits that environment's
@@ -332,14 +339,16 @@ export const makeFlushGate = (runtime: FlushGateRuntime, options: FlushGateOptio
332
339
  // `requestFrame` and `cancelFrame` are called detached, never as `frames.requestFrame(cb)`: a
333
340
  // browser throws "Illegal invocation" when `requestAnimationFrame` runs with `this` bound to
334
341
  // anything but the window (ADR-0031, decision 7).
335
- const { commit, project, requestFrame, cancelFrame, afterTick } = runtime.runSync(
342
+ const { commit, project, maker, requestFrame, cancelFrame, afterTick } = runtime.runSync(
336
343
  Effect.gen(function* () {
337
- const { commit, project } = yield* Renderer.Renderer
344
+ const renderer = yield* Renderer.Renderer
338
345
  const { requestFrame, cancelFrame } = yield* RefreshFrameSource.RefreshFrameSource
339
346
  const { afterTick } = yield* FrameLoop.FrameLoop
340
- return { commit, project, requestFrame, cancelFrame, afterTick }
347
+ return { commit: renderer.commit, project: renderer.project, maker: Projector.makerOf(renderer), requestFrame, cancelFrame, afterTick }
341
348
  }),
342
349
  )
350
+ // What makes a new Subject's projector, at its register: its Renderer's maker, or the Renderer's `project` for all.
351
+ const projectorOf: Projector.Make = Option.getOrElse(maker, () => () => project)
343
352
 
344
353
  const accumulator = new Map<string, Entry>()
345
354
  // Every live output asked for (`valueOf`), by id: an entry registered later picks its map up.
@@ -356,8 +365,8 @@ export const makeFlushGate = (runtime: FlushGateRuntime, options: FlushGateOptio
356
365
  let recording: Set<string> | undefined
357
366
  // The entries committed since the last frame flush whose sink has an `onCommit` (#233).
358
367
  const committedSince = new Set<Entry>()
359
- // Each element's Timeline values by key (#240), and those let go of since its last flush, cancelled at
360
- // its next: only the elements that have one, so the per-frame path checks their sizes alone.
368
+ // Each Subject's Timeline values by key (#240), and those let go of since its last flush, cancelled at
369
+ // its next: only the Subjects that have one, so the per-frame path checks their sizes alone.
361
370
  const timelines = new Map<Entry, Map<string, GateTimeline>>()
362
371
  const endings = new Map<Entry, Array<GateTimeline>>()
363
372
  // A frame flush's entries, in order, prepared and waiting for their commit; and those whose
@@ -366,13 +375,13 @@ export const makeFlushGate = (runtime: FlushGateRuntime, options: FlushGateOptio
366
375
  const heldChanged = entryListOf()
367
376
 
368
377
  /**
369
- * Project one dirty entry's patch and restore the keys it dropped (once per element per flush),
378
+ * Project one dirty entry's patch and restore the keys it dropped (once per Subject per flush),
370
379
  * marking it clean: into `into`, and into `held` when the keys it holds change and its sink
371
380
  * hears them. Its commit waits for the binding's `batch` of those (ADR-0034, *Amendment
372
381
  * (#209)*). Plain calls only: this is the per-frame path.
373
382
  */
374
383
  const prepare = (entry: Entry, into: EntryList, held: EntryList): void => {
375
- const patch = project(entry.values)
384
+ const patch = entry.projector(entry.values)
376
385
  entry.dirty = false
377
386
  entry.patch = patch
378
387
  addTo(into, entry)
@@ -390,7 +399,7 @@ export const makeFlushGate = (runtime: FlushGateRuntime, options: FlushGateOptio
390
399
  committed.set(key, valueBeforeOf(target, key))
391
400
  added = true
392
401
  }
393
- // A key the last patch wrote and this one doesn't: the element gets its own value
402
+ // A key the last patch wrote and this one doesn't: the Subject gets its own value
394
403
  // back. Only looked for when one dropped out (the usual frame keeps every key).
395
404
  let restore: Renderer.Patch | undefined
396
405
  if (kept < before) {
@@ -411,10 +420,10 @@ export const makeFlushGate = (runtime: FlushGateRuntime, options: FlushGateOptio
411
420
  }
412
421
 
413
422
  /**
414
- * Before a flush's commits (#240): cancel the Timeline values each element committing now let go of,
423
+ * Before a flush's commits (#240): cancel the Timeline values each Subject committing now let go of,
415
424
  * and sync the rest with its values, so each starts or stops as nothing else adds to its property.
416
425
  * An entry is committing while it holds a prepared patch. Kept beside the entries, not on them, so an
417
- * element with none pays nothing per frame: the flush checks two sizes. Per flush: plain loops.
426
+ * Subject with none pays nothing per frame: the flush checks two sizes. Per flush: plain loops.
418
427
  */
419
428
  const syncTimelines = (): void => {
420
429
  for (const [entry, ended] of endings) {
@@ -439,7 +448,7 @@ export const makeFlushGate = (runtime: FlushGateRuntime, options: FlushGateOptio
439
448
  }
440
449
  }
441
450
 
442
- /** Every Timeline value of `entry`, cancelled at once: its element is gone, or the gate is. */
451
+ /** Every Timeline value of `entry`, cancelled at once: its Subject is gone, or the gate is. */
443
452
  const cancelTimelines = (entry: Entry): void => {
444
453
  const ended = endings.get(entry)
445
454
  endings.delete(entry)
@@ -449,7 +458,7 @@ export const makeFlushGate = (runtime: FlushGateRuntime, options: FlushGateOptio
449
458
  if (Predicate.isNotUndefined(byKey)) cancelEach(byKey.values())
450
459
  }
451
460
 
452
- /** Commit a prepared entry's patch onto its element. */
461
+ /** Commit a prepared entry's patch onto its Subject. */
453
462
  const commitPrepared = (entry: Entry): void => {
454
463
  const patch = entry.patch
455
464
  if (Predicate.isUndefined(patch)) return
@@ -461,13 +470,13 @@ export const makeFlushGate = (runtime: FlushGateRuntime, options: FlushGateOptio
461
470
 
462
471
  /**
463
472
  * One of `entry`'s steps threw this flush (#969): its later steps skipped this frame, its patch with
464
- * them, and the other elements' going on. A run of them is reported at its first, `step` naming it.
473
+ * them, and the other Subjects' going on. A run of them is reported at its first, `step` naming it.
465
474
  */
466
475
  // A failure's path, never the frame's: one place each loop's catch calls.
467
476
  const failedAt = (entry: Entry, step: Step, defect: unknown): void => {
468
477
  entry.patch = undefined
469
478
  // Tried again at the gate's next flush, which it doesn't ask for itself: a Subject frozen for good would
470
- // keep the host's frames running. A later write, its own or another element's, brings that flush.
479
+ // keep the host's frames running. A later write, its own or another Subject's, brings that flush.
471
480
  entry.dirty = true
472
481
  // Its sink's `onCommit` hears nothing of a frame it didn't commit in.
473
482
  committedSince.delete(entry)
@@ -482,7 +491,7 @@ export const makeFlushGate = (runtime: FlushGateRuntime, options: FlushGateOptio
482
491
  */
483
492
  const commitAll = (entries: EntryList, held: EntryList): void => {
484
493
  if (held.count > 0) batch(() => tellHeld(held))
485
- // A try for each element, its call direct (#969): a shared helper taking the step measured +20% a frame.
494
+ // A try for each Subject, its call direct (#969): a shared helper taking the step measured +20% a frame.
486
495
  for (let i = 0; i < entries.count; i++) {
487
496
  const entry = entries.entries[i] as Entry
488
497
  try {
@@ -495,7 +504,7 @@ export const makeFlushGate = (runtime: FlushGateRuntime, options: FlushGateOptio
495
504
  clear(held)
496
505
  }
497
506
 
498
- /** Each entry's `onHeld`, with every key the gate holds on its element now. */
507
+ /** Each entry's `onHeld`, with every key the gate holds on its Subject now. */
499
508
  const tellHeld = (held: EntryList): void => {
500
509
  for (let i = 0; i < held.count; i++) {
501
510
  const entry = held.entries[i] as Entry
@@ -549,7 +558,7 @@ export const makeFlushGate = (runtime: FlushGateRuntime, options: FlushGateOptio
549
558
  */
550
559
  // #979, group D (ADR-0074): an output's dependent that throws (an app's Atom over a ward's `read(key)`)
551
560
  // is its own. The registry has set the output and told its other listeners before the throw comes back,
552
- // so the write goes on, the element's other outputs with it: before, it came out of the ward's own leg.
561
+ // so the write goes on, the Subject's other outputs with it: before, it came out of the ward's own leg.
553
562
  const setOutputs = (entry: Entry): void => {
554
563
  const outputs = entry.outputs
555
564
  if (Predicate.isUndefined(outputs)) return
@@ -563,7 +572,7 @@ export const makeFlushGate = (runtime: FlushGateRuntime, options: FlushGateOptio
563
572
 
564
573
  /** `output` set to `value`, its dependent's throw its own: reported once a run of throws, until a clean set. */
565
574
  // The try is here, out of the loops that call it (`setOutputs`', `endOutputs`'): in the body of
566
- // `setOutputs`' loop over the element's outputs Map, it measured +5–8% on Node's write.
575
+ // `setOutputs`' loop over the Subject's outputs Map, it measured +5–8% on Node's write.
567
576
  const setOutput = (id: string, key: string, output: Output, value: unknown): void => {
568
577
  try {
569
578
  registry.set(output.atom, value)
@@ -598,9 +607,9 @@ export const makeFlushGate = (runtime: FlushGateRuntime, options: FlushGateOptio
598
607
  const flush = (): void => {
599
608
  scheduled = false
600
609
  try {
601
- // The switches first: an element's own values are read once its Starting style is gone.
610
+ // The switches first: a Subject's own values are read once its Starting style is gone.
602
611
  if (firstCommits.size > 0) batch(runFirstCommits)
603
- // Every dirty element, once. No auto-reschedule — the next write() does. A write()
612
+ // Every dirty Subject, once. No auto-reschedule — the next write() does. A write()
604
613
  // from an effect a sink's hook runs requests the next frame (it isn't stranded).
605
614
  for (const entry of accumulator.values()) {
606
615
  if (!entry.dirty) continue
@@ -666,6 +675,7 @@ export const makeFlushGate = (runtime: FlushGateRuntime, options: FlushGateOptio
666
675
  committed: new Map(),
667
676
  outputs: outputsById.get(id),
668
677
  id,
678
+ projector: projectorOf(),
669
679
  latest: undefined,
670
680
  onCommitFailing: false,
671
681
  stepFailing: false,
@@ -686,8 +696,8 @@ export const makeFlushGate = (runtime: FlushGateRuntime, options: FlushGateOptio
686
696
  }
687
697
  }
688
698
 
689
- /** `id`'s live outputs, each set to `undefined` and forgotten: its element is gone. */
690
- // #979, row 42 (ADR-0074): set through `setOutput`, so a dependent that throws as its element leaves is
699
+ /** `id`'s live outputs, each set to `undefined` and forgotten: its Subject is gone. */
700
+ // #979, row 42 (ADR-0074): set through `setOutput`, so a dependent that throws as its Subject leaves is
691
701
  // reported, and every output still ends: before, its throw came out of the unregister, a binding's
692
702
  // cleanup, and left that output and the later ones mounted.
693
703
  const endOutputs = (id: string): void => {
@@ -717,7 +727,7 @@ export const makeFlushGate = (runtime: FlushGateRuntime, options: FlushGateOptio
717
727
  }
718
728
  const known = outputs.get(key)
719
729
  if (Predicate.isNotUndefined(known)) return known.atom
720
- // Made `undefined` and mounted until its element unregisters, not kept alive: a kept-alive
730
+ // Made `undefined` and mounted until its Subject unregisters, not kept alive: a kept-alive
721
731
  // Atom's node never leaves the registry, and one left behind reads `undefined` afresh.
722
732
  const atom = Atom.make<unknown>(undefined)
723
733
  const output: Output = { atom, last: undefined, unmount: registry.mount(atom), failing: false }
@@ -751,7 +761,7 @@ export const makeFlushGate = (runtime: FlushGateRuntime, options: FlushGateOptio
751
761
  if (written.size === 0) return
752
762
  // No `beforeFirstCommit` here: a Measure pass may write only a node's projection, and
753
763
  // dropping the Starting style then would leave its animated keys unset until the frame
754
- // flush (a frame later for an element mounted inside a frame). The frame flush switches.
764
+ // flush (a frame later for a Subject mounted inside a frame). The frame flush switches.
755
765
  // A commit here is told at the frame flush (#233): the write that made it scheduled that flush.
756
766
  // Its own lists: a pass may run from a hook the frame flush's `batch` runs.
757
767
  const entries = entryListOf()
@@ -791,13 +801,13 @@ export const makeFlushGate = (runtime: FlushGateRuntime, options: FlushGateOptio
791
801
  }
792
802
  byKey.set(key, value)
793
803
  }
794
- // An element left with none leaves the map, so the flush skips it.
804
+ // A Subject left with none leaves the map, so the flush skips it.
795
805
  if (Predicate.isNotUndefined(byKey) && byKey.size === 0) timelines.delete(entry)
796
806
  entry.dirty = true
797
807
  scheduleFlush()
798
808
  }
799
809
 
800
- /** `entry`'s Timeline values for `keys`, cancelled at once: those keys go back to the element's own style. */
810
+ /** `entry`'s Timeline values for `keys`, cancelled at once: those keys go back to the Subject's own style. */
801
811
  const releaseTimelines = (entry: Entry, keys: ReadonlyArray<string>): void => {
802
812
  const byKey = timelines.get(entry)
803
813
  if (Predicate.isUndefined(byKey)) return
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * An Environment's **Frame effects** (CONTEXT.md): an app's own code, run at the end of each frame the
3
3
  * Environment draws, after Wardic's writes for it, in the order the effects were added. A scene runs
4
- * them in its Host loop before it renders; the DOM before paint. The Environment calls {@link
4
+ * them in its Host loop before it renders; `@wardic/dom`, before its frame is drawn. The Environment calls {@link
5
5
  * FrameEffects.run} at its frame's end, and gives `make` its way to ask for a frame, so an effect whose
6
6
  * inputs changed is run on a frame nothing else asked for.
7
7
  *
@@ -136,7 +136,7 @@ export const make = (options: FrameEffectsOptions): FrameEffects => {
136
136
  }
137
137
 
138
138
  /**
139
- * Frame effects for an Environment on core's Frame loop and Refresh frames, the DOM's: run at the end
139
+ * Frame effects for an Environment on core's Frame loop and Refresh frames, as `@wardic/dom` is: run at the end
140
140
  * of each tick, after the tick's hooks added before them (the Flush gate's flush, so after Wardic's
141
141
  * writes for the frame), and, on a frame with no tick, on a Refresh frame of their own that `request()`
142
142
  * asks for, which a tick withdraws. For as long as the Scope is open.
@@ -36,7 +36,7 @@ export const frameNow: () => number = Clock.syncNow(() => performance.now())
36
36
  const clockNows = new WeakMap<WardicServices.Runner<WardicServices.WardicServices>, () => number>()
37
37
 
38
38
  /**
39
- * The time a provider's elements read their velocities against (#460, Q7): its Environment's Clock's
39
+ * The time a provider's Subjects read their velocities against (#460, Q7): its Environment's Clock's
40
40
  * `now` (#464's sync time, `@wardic/dom`'s or a test Environment's own), kept per runtime.
41
41
  */
42
42
  export const clockNowOf = (runtime: WardicServices.Runner<WardicServices.WardicServices>): (() => number) => {