@wardic/core 1.3.2 → 1.5.0-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (237) hide show
  1. package/dist/Arc.d.ts +2 -2
  2. package/dist/Arc.js +1 -1
  3. package/dist/BaseValue.d.ts +11 -10
  4. package/dist/BaseValue.d.ts.map +1 -1
  5. package/dist/BaseValue.js +12 -15
  6. package/dist/BaseValue.js.map +1 -1
  7. package/dist/Batch.d.ts +15 -5
  8. package/dist/Batch.d.ts.map +1 -1
  9. package/dist/Batch.js +218 -20
  10. package/dist/Batch.js.map +1 -1
  11. package/dist/Clock.d.ts +7 -7
  12. package/dist/Clock.d.ts.map +1 -1
  13. package/dist/Clock.js +17 -16
  14. package/dist/Clock.js.map +1 -1
  15. package/dist/DefaultTransition.d.ts +3 -2
  16. package/dist/DefaultTransition.d.ts.map +1 -1
  17. package/dist/DefaultTransition.js +5 -3
  18. package/dist/DefaultTransition.js.map +1 -1
  19. package/dist/Drag.d.ts +24 -9
  20. package/dist/Drag.d.ts.map +1 -1
  21. package/dist/Drag.js +10 -10
  22. package/dist/Drag.js.map +1 -1
  23. package/dist/DragActivity.js +3 -3
  24. package/dist/DragRecognizer.d.ts +8 -6
  25. package/dist/DragRecognizer.d.ts.map +1 -1
  26. package/dist/DragRecognizer.js +51 -16
  27. package/dist/DragRecognizer.js.map +1 -1
  28. package/dist/Easing.d.ts +1 -1
  29. package/dist/Easing.js +1 -1
  30. package/dist/Frame.d.ts.map +1 -1
  31. package/dist/Frame.js +5 -3
  32. package/dist/Frame.js.map +1 -1
  33. package/dist/InputFeed.d.ts +1 -1
  34. package/dist/InputFeed.js +2 -2
  35. package/dist/InputSource.d.ts +9 -3
  36. package/dist/InputSource.d.ts.map +1 -1
  37. package/dist/InputSource.js +2 -2
  38. package/dist/InputSource.js.map +1 -1
  39. package/dist/Interpolator.d.ts +2 -2
  40. package/dist/Interpolator.js +2 -2
  41. package/dist/InterpolatorRegistry.d.ts +29 -15
  42. package/dist/InterpolatorRegistry.d.ts.map +1 -1
  43. package/dist/InterpolatorRegistry.js +17 -8
  44. package/dist/InterpolatorRegistry.js.map +1 -1
  45. package/dist/LiveValue.d.ts +7 -6
  46. package/dist/LiveValue.d.ts.map +1 -1
  47. package/dist/LiveValue.js +45 -14
  48. package/dist/LiveValue.js.map +1 -1
  49. package/dist/Machine.d.ts +7 -4
  50. package/dist/Machine.d.ts.map +1 -1
  51. package/dist/Machine.js +146 -45
  52. package/dist/Machine.js.map +1 -1
  53. package/dist/Playback.d.ts.map +1 -1
  54. package/dist/Playback.js +6 -1
  55. package/dist/Playback.js.map +1 -1
  56. package/dist/Projection.d.ts +8 -19
  57. package/dist/Projection.d.ts.map +1 -1
  58. package/dist/Projection.js +3 -19
  59. package/dist/Projection.js.map +1 -1
  60. package/dist/Recognizer.d.ts +1 -1
  61. package/dist/Recognizer.d.ts.map +1 -1
  62. package/dist/Recognizer.js +22 -7
  63. package/dist/Recognizer.js.map +1 -1
  64. package/dist/ReducedMotion.d.ts +4 -4
  65. package/dist/ReducedMotion.js +6 -6
  66. package/dist/Renderer.d.ts +5 -5
  67. package/dist/Renderer.js +6 -6
  68. package/dist/Renderer.js.map +1 -1
  69. package/dist/Reorder.d.ts +12 -2
  70. package/dist/Reorder.d.ts.map +1 -1
  71. package/dist/Reorder.js +65 -37
  72. package/dist/Reorder.js.map +1 -1
  73. package/dist/ScrollSource.d.ts +1 -1
  74. package/dist/ScrollSource.d.ts.map +1 -1
  75. package/dist/Sequence.d.ts +1 -1
  76. package/dist/SharedSource.d.ts +3 -3
  77. package/dist/SharedSource.js +5 -5
  78. package/dist/SharedSource.js.map +1 -1
  79. package/dist/Spring.d.ts.map +1 -1
  80. package/dist/Spring.js +2 -1
  81. package/dist/Spring.js.map +1 -1
  82. package/dist/Values.d.ts +2 -2
  83. package/dist/Values.js +1 -1
  84. package/dist/index.d.ts +1 -1
  85. package/dist/index.js +1 -1
  86. package/dist/internal/carried.d.ts +13 -0
  87. package/dist/internal/carried.d.ts.map +1 -0
  88. package/dist/internal/carried.js +23 -0
  89. package/dist/internal/carried.js.map +1 -0
  90. package/dist/internal/firstSteps.d.ts +66 -0
  91. package/dist/internal/firstSteps.d.ts.map +1 -0
  92. package/dist/internal/firstSteps.js +107 -0
  93. package/dist/internal/firstSteps.js.map +1 -0
  94. package/dist/internal/frameLoop.d.ts +1 -1
  95. package/dist/internal/frameLoop.d.ts.map +1 -1
  96. package/dist/internal/frameLoop.js +102 -81
  97. package/dist/internal/frameLoop.js.map +1 -1
  98. package/dist/internal/lerpsNumbers.d.ts +11 -0
  99. package/dist/internal/lerpsNumbers.d.ts.map +1 -0
  100. package/dist/internal/lerpsNumbers.js +38 -0
  101. package/dist/internal/lerpsNumbers.js.map +1 -0
  102. package/dist/internal/options.d.ts +7 -7
  103. package/dist/internal/options.d.ts.map +1 -1
  104. package/dist/internal/options.js +10 -10
  105. package/dist/internal/options.js.map +1 -1
  106. package/dist/internal/projectionRest.d.ts +22 -0
  107. package/dist/internal/projectionRest.d.ts.map +1 -0
  108. package/dist/internal/projectionRest.js +20 -0
  109. package/dist/internal/projectionRest.js.map +1 -0
  110. package/dist/internal/stepper.d.ts +13 -2
  111. package/dist/internal/stepper.d.ts.map +1 -1
  112. package/dist/internal/stepper.js +16 -1
  113. package/dist/internal/stepper.js.map +1 -1
  114. package/dist/internal/tracing.d.ts +1 -1
  115. package/dist/internal/tracing.js +1 -1
  116. package/dist/unstable/AnimationControls.d.ts +37 -38
  117. package/dist/unstable/AnimationControls.d.ts.map +1 -1
  118. package/dist/unstable/AnimationControls.js +39 -36
  119. package/dist/unstable/AnimationControls.js.map +1 -1
  120. package/dist/unstable/AppearHandoff.d.ts +5 -5
  121. package/dist/unstable/AppearHandoff.d.ts.map +1 -1
  122. package/dist/unstable/BatchCalls.d.ts +2 -2
  123. package/dist/unstable/BatchCalls.js +5 -5
  124. package/dist/unstable/Config.d.ts +19 -19
  125. package/dist/unstable/Config.d.ts.map +1 -1
  126. package/dist/unstable/FirstSteps.d.ts +25 -0
  127. package/dist/unstable/FirstSteps.d.ts.map +1 -0
  128. package/dist/unstable/FirstSteps.js +2 -0
  129. package/dist/unstable/FirstSteps.js.map +1 -0
  130. package/dist/unstable/FlushGate.d.ts +53 -51
  131. package/dist/unstable/FlushGate.d.ts.map +1 -1
  132. package/dist/unstable/FlushGate.js +56 -49
  133. package/dist/unstable/FlushGate.js.map +1 -1
  134. package/dist/unstable/FrameEffects.d.ts +2 -2
  135. package/dist/unstable/FrameEffects.js +2 -2
  136. package/dist/unstable/FrameTime.d.ts +1 -1
  137. package/dist/unstable/FrameTime.js +1 -1
  138. package/dist/unstable/Imperative.d.ts +29 -9
  139. package/dist/unstable/Imperative.d.ts.map +1 -1
  140. package/dist/unstable/Imperative.js +79 -47
  141. package/dist/unstable/Imperative.js.map +1 -1
  142. package/dist/unstable/OwnValues.js +1 -1
  143. package/dist/unstable/PresenceRecord.d.ts +31 -27
  144. package/dist/unstable/PresenceRecord.d.ts.map +1 -1
  145. package/dist/unstable/PresenceRecord.js +8 -8
  146. package/dist/unstable/PresenceRecord.js.map +1 -1
  147. package/dist/unstable/Projector.d.ts +34 -0
  148. package/dist/unstable/Projector.d.ts.map +1 -0
  149. package/dist/unstable/Projector.js +9 -0
  150. package/dist/unstable/Projector.js.map +1 -0
  151. package/dist/unstable/Report.d.ts +1 -1
  152. package/dist/unstable/Report.js +1 -1
  153. package/dist/unstable/RetargetLegs.d.ts +1 -1
  154. package/dist/unstable/RetargetLegs.d.ts.map +1 -1
  155. package/dist/unstable/RetargetLegs.js +9 -8
  156. package/dist/unstable/RetargetLegs.js.map +1 -1
  157. package/dist/unstable/Spine.d.ts +81 -72
  158. package/dist/unstable/Spine.d.ts.map +1 -1
  159. package/dist/unstable/Spine.js +171 -164
  160. package/dist/unstable/Spine.js.map +1 -1
  161. package/dist/unstable/Stops.d.ts +3 -3
  162. package/dist/unstable/Stops.js +4 -4
  163. package/dist/unstable/Subject.d.ts +2 -2
  164. package/dist/unstable/Subject.js +2 -2
  165. package/dist/unstable/Timelines.d.ts +11 -11
  166. package/dist/unstable/Timelines.d.ts.map +1 -1
  167. package/dist/unstable/Timelines.js +3 -3
  168. package/dist/unstable/VariantTarget.d.ts +7 -7
  169. package/dist/unstable/VariantTarget.d.ts.map +1 -1
  170. package/dist/unstable/VariantTarget.js +11 -11
  171. package/dist/unstable/VariantTarget.js.map +1 -1
  172. package/dist/unstable/VariantTree.d.ts +43 -36
  173. package/dist/unstable/VariantTree.d.ts.map +1 -1
  174. package/dist/unstable/VariantTree.js +34 -34
  175. package/dist/unstable/VariantTree.js.map +1 -1
  176. package/dist/unstable/WardicConfigValue.d.ts +13 -13
  177. package/dist/unstable/WardicConfigValue.d.ts.map +1 -1
  178. package/dist/unstable/WardicConfigValue.js +4 -4
  179. package/dist/unstable/WardicConfigValue.js.map +1 -1
  180. package/package.json +1 -1
  181. package/src/Arc.ts +3 -3
  182. package/src/BaseValue.ts +18 -21
  183. package/src/Batch.ts +236 -22
  184. package/src/Clock.ts +18 -17
  185. package/src/DefaultTransition.ts +5 -3
  186. package/src/Drag.ts +32 -14
  187. package/src/DragActivity.ts +3 -3
  188. package/src/DragRecognizer.ts +65 -23
  189. package/src/Easing.ts +1 -1
  190. package/src/Frame.ts +5 -3
  191. package/src/InputFeed.ts +2 -2
  192. package/src/InputSource.ts +12 -5
  193. package/src/Interpolator.ts +3 -3
  194. package/src/InterpolatorRegistry.ts +22 -13
  195. package/src/LiveValue.ts +47 -17
  196. package/src/Machine.ts +199 -61
  197. package/src/Playback.ts +5 -1
  198. package/src/Projection.ts +10 -28
  199. package/src/Recognizer.ts +24 -8
  200. package/src/ReducedMotion.ts +6 -6
  201. package/src/Renderer.ts +6 -6
  202. package/src/Reorder.ts +84 -38
  203. package/src/ScrollSource.ts +1 -1
  204. package/src/Sequence.ts +1 -1
  205. package/src/SharedSource.ts +5 -5
  206. package/src/Spring.ts +2 -1
  207. package/src/Values.ts +2 -2
  208. package/src/index.ts +1 -1
  209. package/src/internal/carried.ts +22 -0
  210. package/src/internal/firstSteps.ts +139 -0
  211. package/src/internal/frameLoop.ts +103 -87
  212. package/src/internal/lerpsNumbers.ts +53 -0
  213. package/src/internal/options.ts +10 -10
  214. package/src/internal/projectionRest.ts +31 -0
  215. package/src/internal/stepper.ts +20 -2
  216. package/src/internal/tracing.ts +1 -1
  217. package/src/unstable/AnimationControls.ts +59 -56
  218. package/src/unstable/AppearHandoff.ts +6 -6
  219. package/src/unstable/BatchCalls.ts +5 -5
  220. package/src/unstable/Config.ts +19 -19
  221. package/src/unstable/FirstSteps.ts +26 -0
  222. package/src/unstable/FlushGate.ts +92 -82
  223. package/src/unstable/FrameEffects.ts +2 -2
  224. package/src/unstable/FrameTime.ts +1 -1
  225. package/src/unstable/Imperative.ts +126 -56
  226. package/src/unstable/OwnValues.ts +1 -1
  227. package/src/unstable/PresenceRecord.ts +34 -30
  228. package/src/unstable/Projector.ts +45 -0
  229. package/src/unstable/Report.ts +1 -1
  230. package/src/unstable/RetargetLegs.ts +10 -9
  231. package/src/unstable/Spine.ts +210 -201
  232. package/src/unstable/Stops.ts +6 -6
  233. package/src/unstable/Subject.ts +2 -2
  234. package/src/unstable/Timelines.ts +12 -12
  235. package/src/unstable/VariantTarget.ts +13 -13
  236. package/src/unstable/VariantTree.ts +50 -43
  237. package/src/unstable/WardicConfigValue.ts +13 -13
@@ -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.
@@ -71,32 +72,32 @@ import * as Scope from "effect/Scope";
71
72
  * at flush time.
72
73
  */
73
74
  export interface FlushSink {
74
- /** The element the patch is committed onto. */
75
+ /** The Subject the patch is committed onto. */
75
76
  readonly target: unknown;
76
77
  /**
77
- * Called once, just before the element's first commit in a frame flush (not a Measure
78
- * pass's `flushPass`), inside the binding's `batch` with every other element's switch that
78
+ * Called once, just before the Subject's first commit in a frame flush (not a Measure
79
+ * pass's `flushPass`), inside the binding's `batch` with every other Subject's switch that
79
80
  * flush: a binding drops its Starting style from its `style` here,
80
81
  * so its framework removes those keys and the commit writes the first frame in the same
81
- * Refresh frame, with no paint in between.
82
+ * Refresh frame, with nothing drawn in between.
82
83
  */
83
84
  readonly beforeFirstCommit?: (() => void) | undefined;
84
85
  /**
85
- * Called with every key the gate now holds on the element, each time that set changes: after the
86
+ * Called with every key the gate now holds on the Subject, each time that set changes: after the
86
87
  * gate restores a key it dropped, and before the commit that first
87
- * writes a key. A binding whose `style` reaches the element leaves these keys out of it,
88
+ * writes a key. A binding whose `style` reaches the Subject leaves these keys out of it,
88
89
  * so its framework never writes over Wardic's value (`style` is a key's fallback). Called in
89
- * the binding's `batch`, with every other element's whose keys changed that flush, so what the
90
- * binding changes reaches the element before the commit, a framework that applies an update later
90
+ * the binding's `batch`, with every other Subject's whose keys changed that flush, so what the
91
+ * binding changes reaches the Subject before the commit, a framework that applies an update later
91
92
  * (Solid 2) included.
92
93
  */
93
94
  readonly onHeld?: ((keys: ReadonlyArray<string>) => void) | undefined;
94
95
  /**
95
- * Called once per frame in which the element's values were committed, after every commit of that
96
+ * Called once per frame in which the Subject's values were committed, after every commit of that
96
97
  * frame (Motion's `onUpdate`), with its values before
97
- * projection (`x` as a number). The object is the element's own, reused each call: valid during
98
+ * projection (`x` as a number). The object is the Subject's own, reused each call: valid during
98
99
  * the call, copied to keep. A Measure pass's commits are told at the frame flush after them, so
99
- * a frame tells each element once. A write it makes is the next frame's. A throw is reported,
100
+ * a frame tells each Subject once. A write it makes is the next frame's. A throw is reported,
100
101
  * and the others are still told.
101
102
  */
102
103
  readonly onCommit?: ((values: Readonly<Record<string, unknown>>) => void) | undefined;
@@ -109,24 +110,24 @@ export interface GateTimeline {
109
110
  /**
110
111
  * What the gate reads of its Environment's targets, and what it keeps from a sink: a target's value
111
112
  * for a key before the gate first writes it there (`""` for none), which it gives back at the key's
112
- * release, and the key its Renderer reserves for an element's Transform template, which `onCommit`
113
+ * release, and the key its Renderer reserves for a Subject's Transform template, which `onCommit`
113
114
  * never sees.
114
115
  */
115
116
  export interface GateEnvironment {
116
117
  readonly valueBeforeOf: (target: unknown, key: string) => string;
117
118
  readonly templateKey: string;
118
119
  }
119
- /** A Flush gate: what a binding registers its elements with and writes their values into, one per provider. */
120
+ /** A Flush gate: what a binding registers its Subjects with and writes their values into, one per provider. */
120
121
  export interface FlushGate {
121
122
  /**
122
- * Register an element under `id` with its `sink`. Returns an unregister fn
123
- * that removes the element from the accumulator (a subsequent `write` is a
123
+ * Register a Subject under `id` with its `sink`. Returns an unregister fn
124
+ * that removes the Subject from the accumulator (a subsequent `write` is a
124
125
  * no-op). `values` start its value-map, unflushed: drawn with its first `write`, so they never
125
126
  * commit alone.
126
127
  */
127
128
  readonly register: (id: string, sink: FlushSink, values?: Readonly<Record<string, unknown>>) => () => void;
128
129
  /**
129
- * Merge `partial` into the element's value-map by key, mark it dirty, and
130
+ * Merge `partial` into the Subject's value-map by key, mark it dirty, and
130
131
  * schedule a flush: the end of the Frame loop's tick, for a write made in one, or else the
131
132
  * next Refresh frame. A `write` for an unregistered (or unregistered-since) id
132
133
  * is a no-op.
@@ -138,41 +139,41 @@ export interface FlushGate {
138
139
  * `pass()` runs are recorded; each recorded entry is `project`ed and committed once, and
139
140
  * marked clean. Everything else stays dirty for its flush. A write made by an effect a sink's
140
141
  * hook runs (a Solid effect) takes the ordinary path. The Projection system calls it at the
141
- * end of a task, so a new layout never paints without its projection.
142
+ * end of a task, so a new layout is never drawn without its projection.
142
143
  */
143
144
  readonly flushPass: (pass: () => void) => void;
144
145
  /**
145
- * Hand `keys` back to the element's own style: drop each from the element's
146
+ * Hand `keys` back to the Subject's own style: drop each from the Subject's
146
147
  * value-map and schedule a flush, which writes `restore[key]` (its Environment's text form) for a key it had
147
- * written, or else the element's own value it overwrote, and tells the sink (`onHeld`). A key the
148
+ * written, or else the Subject's own value it overwrote, and tells the sink (`onHeld`). A key the
148
149
  * entry doesn't hold, or an unknown id, is a no-op. A binding releases a key back at its `style`
149
150
  * value, so a later `style` change shows at rest. A later `write` brings the key back. A property in
150
151
  * `keep` (`transform` for its keys) is left as it's drawn when it drops out: another writer draws it next.
151
152
  */
152
153
  readonly release: (id: string, keys: ReadonlyArray<string>, restore?: Readonly<Record<string, string>>, keep?: ReadonlyArray<string>) => void;
153
154
  /**
154
- * The element's value for `id`'s `key`, live: an `Atom` set as each write that
155
+ * The Subject's value for `id`'s `key`, live: an `Atom` set as each write that
155
156
  * changes it lands, so it's the value the next commit draws, before the Renderer projects it
156
157
  * (`x` as a number, not a `transform`). Set at the write, not the commit, so a value derived
157
158
  * from it (another key following it through a binding) is written in the same frame and
158
159
  * commits with it. `undefined` before the key's first write, and once it's released or the
159
- * element unregisters. One Atom for an id and a key, made on first ask, so per frame only the
160
+ * Subject unregisters. One Atom for an id and a key, made on first ask, so per frame only the
160
161
  * keys asked for cost anything.
161
162
  */
162
163
  readonly valueOf: (id: string, key: string) => Atom.Atom<unknown>;
163
164
  /**
164
- * Run `key`'s Timeline value on `id`'s element (#240), or stop it (`undefined`): a binding sets one
165
+ * Run `key`'s Timeline value on `id`'s Subject (#240), or stop it (`undefined`): a binding sets one
165
166
  * while the key shows its Live value, and clears it when an entry of the Override stack takes the
166
- * key. The gate goes on writing the key: at each flush that commits the element, before the commit,
167
+ * key. The gate goes on writing the key: at each flush that commits the Subject, before the commit,
167
168
  * it starts the value's animation over it, or cancels it while something else adds to its property
168
169
  * (a projection, a Transform template, another transform key off its identity), so a frame shows one
169
170
  * or the other. A cleared or replaced one is cancelled at the next flush; a released key's, an
170
- * unregistered element's and a disposed gate's, at once. Setting one schedules a flush.
171
+ * unregistered Subject's and a disposed gate's, at once. Setting one schedules a flush.
171
172
  */
172
173
  readonly timeline: (id: string, key: string, timeline: GateTimeline | undefined) => void;
173
174
  /**
174
175
  * Call `fn` once, after the gate's next flush: the end of the Frame loop's tick, for a call
175
- * made in one, else the next Refresh frame's, so what was written before it is on the elements.
176
+ * made in one, else the next Refresh frame's, so what was written before it is on the Subjects.
176
177
  * It schedules that flush if none is pending. A binding tells an animation's end here, as Motion's
177
178
  * `onAnimationComplete` comes with the final value set. One that throws is reported, and the rest
178
179
  * still run.
@@ -183,7 +184,7 @@ export interface FlushGate {
183
184
  }
184
185
  /** The gate as its spine and its binding use it: all but its `dispose`, which its Scope runs. */
185
186
  export type Shape = Omit<FlushGate, "dispose">;
186
- /** An element's commit target and hooks, given to `register`. */
187
+ /** A Subject's commit target and hooks, given to `register`. */
187
188
  export type Sink = FlushSink;
188
189
  /** 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`. */
189
190
  export type FlushGateServices = Renderer.Renderer | RefreshFrameSource.RefreshFrameSource | FrameLoop.FrameLoop | AtomRegistry.AtomRegistry;
@@ -201,11 +202,11 @@ export interface FlushGateRuntime {
201
202
  export interface FlushGateOptions {
202
203
  /**
203
204
  * Runs a flush's hooks together: calls `apply`, and returns once every update inside it has reached
204
- * the elements, before the gate commits. Solid 1 passes its `batch`, Solid 2 runs `apply` then
205
+ * the Subjects, before the gate commits. Solid 1 passes its `batch`, Solid 2 runs `apply` then
205
206
  * `flush()`, and React would pass `flushSync`, untried; a binding with nothing to batch passes
206
207
  * `(apply) => apply()`. Called at most twice a flush: once for the starting-style switches
207
- * (`beforeFirstCommit`) of the elements committing for the first time, before anything is read off the
208
- * elements; and once for the held keys (`onHeld`) of the elements whose held keys changed.
208
+ * (`beforeFirstCommit`) of the Subjects committing for the first time, before anything is read off the
209
+ * Subjects; and once for the held keys (`onHeld`) of the Subjects whose held keys changed.
209
210
  */
210
211
  readonly batch: (apply: () => void) => void;
211
212
  }
@@ -214,7 +215,8 @@ export interface FlushGateOptions {
214
215
  * switches through the binding's `batch`.
215
216
  *
216
217
  * Resolves both ONCE here: `project` is pure and `commit` a plain call (both called directly at
217
- * flush, ADR-0034), `requestFrame` /
218
+ * flush, ADR-0034), and a Renderer's projector maker makes each Subject's projector as it registers;
219
+ * `requestFrame` /
218
220
  * `cancelFrame` schedule and cancel the flush of a write made outside a tick, and the Frame
219
221
  * loop's `afterTick` takes the gate's hook for its lifetime. All come from whichever env the
220
222
  * provider was given (`DomLive` / `TestLive`), so the gate inherits that environment's
@@ -1 +1 @@
1
- {"version":3,"file":"FlushGate.d.ts","sourceRoot":"","sources":["../../src/unstable/FlushGate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2DG;AAIH,OAAO,KAAK,SAAS,MAAM,iBAAiB,CAAA;AAC5C,OAAO,KAAK,kBAAkB,MAAM,0BAA0B,CAAA;AAC9D,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAA;AAE1C,OAAO,KAAK,IAAI,MAAM,wBAAwB,CAAA;AAC9C,OAAO,KAAK,YAAY,MAAM,gCAAgC,CAAA;AAC9D,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAEvC,OAAO,KAAK,KAAK,KAAK,MAAM,cAAc,CAAA;AAG1C,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AAGrC;;;GAGG;AACH,MAAM,WAAW,SAAS;IACxB,+CAA+C;IAC/C,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAA;IACxB;;;;;;OAMG;IACH,QAAQ,CAAC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AAE,CAAC,EAAE,iBAAiB,CAAC,KAAK,CAAC,CAAA;IAC7E,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,iBAAiB,CAAC,KAAK,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;IAC7F,uFAAuF;IACvF,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC,KAAK,CAAA;CAC5B;AAED,2CAA2C;AAC3C,MAAM,WAAW,gBAAgB;IAC/B;;;;;;;OAOG;IAEH,QAAQ,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,MAAM,IAAI,KAAK,IAAI,CAAA;CAC5C;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,aAAa,YAAa,gBAAgB,WAAW,gBAAgB,eAAe,eAAe,KAAG,SAuhBlH,CAAA"}
@@ -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.js";
65
66
  import * as RefreshFrameSource from "../RefreshFrameSource.js";
66
67
  import * as Renderer from "../Renderer.js";
68
+ import * as Projector from "./Projector.js";
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 * as Predicate from "effect/Predicate";
73
76
  import * as UndefinedOr from "effect/UndefinedOr";
74
77
  import * as Scope from "effect/Scope";
@@ -95,7 +98,8 @@ const cancelEach = (values) => {
95
98
  * switches through the binding's `batch`.
96
99
  *
97
100
  * Resolves both ONCE here: `project` is pure and `commit` a plain call (both called directly at
98
- * flush, ADR-0034), `requestFrame` /
101
+ * flush, ADR-0034), and a Renderer's projector maker makes each Subject's projector as it registers;
102
+ * `requestFrame` /
99
103
  * `cancelFrame` schedule and cancel the flush of a write made outside a tick, and the Frame
100
104
  * loop's `afterTick` takes the gate's hook for its lifetime. All come from whichever env the
101
105
  * provider was given (`DomLive` / `TestLive`), so the gate inherits that environment's
@@ -108,12 +112,14 @@ export const makeFlushGate = (runtime, options, environment) => {
108
112
  // `requestFrame` and `cancelFrame` are called detached, never as `frames.requestFrame(cb)`: a
109
113
  // browser throws "Illegal invocation" when `requestAnimationFrame` runs with `this` bound to
110
114
  // anything but the window (ADR-0031, decision 7).
111
- const { commit, project, requestFrame, cancelFrame, afterTick } = runtime.runSync(Effect.gen(function* () {
112
- const { commit, project } = yield* Renderer.Renderer;
115
+ const { commit, project, maker, requestFrame, cancelFrame, afterTick } = runtime.runSync(Effect.gen(function* () {
116
+ const renderer = yield* Renderer.Renderer;
113
117
  const { requestFrame, cancelFrame } = yield* RefreshFrameSource.RefreshFrameSource;
114
118
  const { afterTick } = yield* FrameLoop.FrameLoop;
115
- return { commit, project, requestFrame, cancelFrame, afterTick };
119
+ return { commit: renderer.commit, project: renderer.project, maker: Projector.makerOf(renderer), requestFrame, cancelFrame, afterTick };
116
120
  }));
121
+ // What makes a new Subject's projector, at its register: its Renderer's maker, or the Renderer's `project` for all.
122
+ const projectorOf = Option.getOrElse(maker, () => () => project);
117
123
  const accumulator = new Map();
118
124
  // Every live output asked for (`valueOf`), by id: an entry registered later picks its map up.
119
125
  const outputsById = new Map();
@@ -129,8 +135,8 @@ export const makeFlushGate = (runtime, options, environment) => {
129
135
  let recording;
130
136
  // The entries committed since the last frame flush whose sink has an `onCommit` (#233).
131
137
  const committedSince = new Set();
132
- // Each element's Timeline values by key (#240), and those let go of since its last flush, cancelled at
133
- // its next: only the elements that have one, so the per-frame path checks their sizes alone.
138
+ // Each Subject's Timeline values by key (#240), and those let go of since its last flush, cancelled at
139
+ // its next: only the Subjects that have one, so the per-frame path checks their sizes alone.
134
140
  const timelines = new Map();
135
141
  const endings = new Map();
136
142
  // A frame flush's entries, in order, prepared and waiting for their commit; and those whose
@@ -138,13 +144,13 @@ export const makeFlushGate = (runtime, options, environment) => {
138
144
  const prepared = entryListOf();
139
145
  const heldChanged = entryListOf();
140
146
  /**
141
- * Project one dirty entry's patch and restore the keys it dropped (once per element per flush),
147
+ * Project one dirty entry's patch and restore the keys it dropped (once per Subject per flush),
142
148
  * marking it clean: into `into`, and into `held` when the keys it holds change and its sink
143
149
  * hears them. Its commit waits for the binding's `batch` of those (ADR-0034, *Amendment
144
150
  * (#209)*). Plain calls only: this is the per-frame path.
145
151
  */
146
152
  const prepare = (entry, into, held) => {
147
- const patch = project(entry.values);
153
+ const patch = entry.projector(entry.values);
148
154
  entry.dirty = false;
149
155
  entry.patch = patch;
150
156
  addTo(into, entry);
@@ -162,7 +168,7 @@ export const makeFlushGate = (runtime, options, environment) => {
162
168
  committed.set(key, valueBeforeOf(target, key));
163
169
  added = true;
164
170
  }
165
- // A key the last patch wrote and this one doesn't: the element gets its own value
171
+ // A key the last patch wrote and this one doesn't: the Subject gets its own value
166
172
  // back. Only looked for when one dropped out (the usual frame keeps every key).
167
173
  let restore;
168
174
  if (kept < before) {
@@ -186,10 +192,10 @@ export const makeFlushGate = (runtime, options, environment) => {
186
192
  addTo(held, entry);
187
193
  };
188
194
  /**
189
- * Before a flush's commits (#240): cancel the Timeline values each element committing now let go of,
195
+ * Before a flush's commits (#240): cancel the Timeline values each Subject committing now let go of,
190
196
  * and sync the rest with its values, so each starts or stops as nothing else adds to its property.
191
197
  * An entry is committing while it holds a prepared patch. Kept beside the entries, not on them, so an
192
- * element with none pays nothing per frame: the flush checks two sizes. Per flush: plain loops.
198
+ * Subject with none pays nothing per frame: the flush checks two sizes. Per flush: plain loops.
193
199
  */
194
200
  const syncTimelines = () => {
195
201
  for (const [entry, ended] of endings) {
@@ -218,7 +224,7 @@ export const makeFlushGate = (runtime, options, environment) => {
218
224
  }
219
225
  }
220
226
  };
221
- /** Every Timeline value of `entry`, cancelled at once: its element is gone, or the gate is. */
227
+ /** Every Timeline value of `entry`, cancelled at once: its Subject is gone, or the gate is. */
222
228
  const cancelTimelines = (entry) => {
223
229
  const ended = endings.get(entry);
224
230
  endings.delete(entry);
@@ -229,7 +235,7 @@ export const makeFlushGate = (runtime, options, environment) => {
229
235
  if (Predicate.isNotUndefined(byKey))
230
236
  cancelEach(byKey.values());
231
237
  };
232
- /** Commit a prepared entry's patch onto its element. */
238
+ /** Commit a prepared entry's patch onto its Subject. */
233
239
  const commitPrepared = (entry) => {
234
240
  const patch = entry.patch;
235
241
  if (Predicate.isUndefined(patch))
@@ -243,13 +249,13 @@ export const makeFlushGate = (runtime, options, environment) => {
243
249
  };
244
250
  /**
245
251
  * One of `entry`'s steps threw this flush (#969): its later steps skipped this frame, its patch with
246
- * them, and the other elements' going on. A run of them is reported at its first, `step` naming it.
252
+ * them, and the other Subjects' going on. A run of them is reported at its first, `step` naming it.
247
253
  */
248
254
  // A failure's path, never the frame's: one place each loop's catch calls.
249
255
  const failedAt = (entry, step, defect) => {
250
256
  entry.patch = undefined;
251
257
  // Tried again at the gate's next flush, which it doesn't ask for itself: a Subject frozen for good would
252
- // keep the host's frames running. A later write, its own or another element's, brings that flush.
258
+ // keep the host's frames running. A later write, its own or another Subject's, brings that flush.
253
259
  entry.dirty = true;
254
260
  // Its sink's `onCommit` hears nothing of a frame it didn't commit in.
255
261
  committedSince.delete(entry);
@@ -265,7 +271,7 @@ export const makeFlushGate = (runtime, options, environment) => {
265
271
  const commitAll = (entries, held) => {
266
272
  if (held.count > 0)
267
273
  batch(() => tellHeld(held));
268
- // A try for each element, its call direct (#969): a shared helper taking the step measured +20% a frame.
274
+ // A try for each Subject, its call direct (#969): a shared helper taking the step measured +20% a frame.
269
275
  for (let i = 0; i < entries.count; i++) {
270
276
  const entry = entries.entries[i];
271
277
  try {
@@ -278,7 +284,7 @@ export const makeFlushGate = (runtime, options, environment) => {
278
284
  clear(entries);
279
285
  clear(held);
280
286
  };
281
- /** Each entry's `onHeld`, with every key the gate holds on its element now. */
287
+ /** Each entry's `onHeld`, with every key the gate holds on its Subject now. */
282
288
  const tellHeld = (held) => {
283
289
  for (let i = 0; i < held.count; i++) {
284
290
  const entry = held.entries[i];
@@ -338,7 +344,7 @@ export const makeFlushGate = (runtime, options, environment) => {
338
344
  */
339
345
  // #979, group D (ADR-0074): an output's dependent that throws (an app's Atom over a ward's `read(key)`)
340
346
  // is its own. The registry has set the output and told its other listeners before the throw comes back,
341
- // so the write goes on, the element's other outputs with it: before, it came out of the ward's own leg.
347
+ // so the write goes on, the Subject's other outputs with it: before, it came out of the ward's own leg.
342
348
  const setOutputs = (entry) => {
343
349
  const outputs = entry.outputs;
344
350
  if (Predicate.isUndefined(outputs))
@@ -353,7 +359,7 @@ export const makeFlushGate = (runtime, options, environment) => {
353
359
  };
354
360
  /** `output` set to `value`, its dependent's throw its own: reported once a run of throws, until a clean set. */
355
361
  // The try is here, out of the loops that call it (`setOutputs`', `endOutputs`'): in the body of
356
- // `setOutputs`' loop over the element's outputs Map, it measured +5–8% on Node's write.
362
+ // `setOutputs`' loop over the Subject's outputs Map, it measured +5–8% on Node's write.
357
363
  const setOutput = (id, key, output, value) => {
358
364
  try {
359
365
  registry.set(output.atom, value);
@@ -393,10 +399,10 @@ export const makeFlushGate = (runtime, options, environment) => {
393
399
  const flush = () => {
394
400
  scheduled = false;
395
401
  try {
396
- // The switches first: an element's own values are read once its Starting style is gone.
402
+ // The switches first: a Subject's own values are read once its Starting style is gone.
397
403
  if (firstCommits.size > 0)
398
404
  batch(runFirstCommits);
399
- // Every dirty element, once. No auto-reschedule — the next write() does. A write()
405
+ // Every dirty Subject, once. No auto-reschedule — the next write() does. A write()
400
406
  // from an effect a sink's hook runs requests the next frame (it isn't stranded).
401
407
  for (const entry of accumulator.values()) {
402
408
  if (!entry.dirty)
@@ -467,6 +473,7 @@ export const makeFlushGate = (runtime, options, environment) => {
467
473
  committed: new Map(),
468
474
  outputs: outputsById.get(id),
469
475
  id,
476
+ projector: projectorOf(),
470
477
  latest: undefined,
471
478
  onCommitFailing: false,
472
479
  stepFailing: false,
@@ -488,8 +495,8 @@ export const makeFlushGate = (runtime, options, environment) => {
488
495
  endOutputs(id);
489
496
  };
490
497
  };
491
- /** `id`'s live outputs, each set to `undefined` and forgotten: its element is gone. */
492
- // #979, row 42 (ADR-0074): set through `setOutput`, so a dependent that throws as its element leaves is
498
+ /** `id`'s live outputs, each set to `undefined` and forgotten: its Subject is gone. */
499
+ // #979, row 42 (ADR-0074): set through `setOutput`, so a dependent that throws as its Subject leaves is
493
500
  // reported, and every output still ends: before, its throw came out of the unregister, a binding's
494
501
  // cleanup, and left that output and the later ones mounted.
495
502
  const endOutputs = (id) => {
@@ -521,7 +528,7 @@ export const makeFlushGate = (runtime, options, environment) => {
521
528
  const known = outputs.get(key);
522
529
  if (Predicate.isNotUndefined(known))
523
530
  return known.atom;
524
- // Made `undefined` and mounted until its element unregisters, not kept alive: a kept-alive
531
+ // Made `undefined` and mounted until its Subject unregisters, not kept alive: a kept-alive
525
532
  // Atom's node never leaves the registry, and one left behind reads `undefined` afresh.
526
533
  const atom = Atom.make(undefined);
527
534
  const output = { atom, last: undefined, unmount: registry.mount(atom), failing: false };
@@ -557,7 +564,7 @@ export const makeFlushGate = (runtime, options, environment) => {
557
564
  return;
558
565
  // No `beforeFirstCommit` here: a Measure pass may write only a node's projection, and
559
566
  // dropping the Starting style then would leave its animated keys unset until the frame
560
- // flush (a frame later for an element mounted inside a frame). The frame flush switches.
567
+ // flush (a frame later for a Subject mounted inside a frame). The frame flush switches.
561
568
  // A commit here is told at the frame flush (#233): the write that made it scheduled that flush.
562
569
  // Its own lists: a pass may run from a hook the frame flush's `batch` runs.
563
570
  const entries = entryListOf();
@@ -605,13 +612,13 @@ export const makeFlushGate = (runtime, options, environment) => {
605
612
  }
606
613
  byKey.set(key, value);
607
614
  }
608
- // An element left with none leaves the map, so the flush skips it.
615
+ // A Subject left with none leaves the map, so the flush skips it.
609
616
  if (Predicate.isNotUndefined(byKey) && byKey.size === 0)
610
617
  timelines.delete(entry);
611
618
  entry.dirty = true;
612
619
  scheduleFlush();
613
620
  };
614
- /** `entry`'s Timeline values for `keys`, cancelled at once: those keys go back to the element's own style. */
621
+ /** `entry`'s Timeline values for `keys`, cancelled at once: those keys go back to the Subject's own style. */
615
622
  const releaseTimelines = (entry, keys) => {
616
623
  const byKey = timelines.get(entry);
617
624
  if (Predicate.isUndefined(byKey))