@wardic/dom 1.1.0 → 1.1.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 (253) hide show
  1. package/dist/DomProjectionSystem.js +3 -3
  2. package/dist/DomProjectionSystem.js.map +1 -1
  3. package/dist/FlushGate.d.ts +6 -6
  4. package/dist/FlushGate.d.ts.map +1 -1
  5. package/dist/FlushGate.js +7 -5
  6. package/dist/FlushGate.js.map +1 -1
  7. package/dist/ReorderController.js +3 -3
  8. package/dist/ReorderController.js.map +1 -1
  9. package/dist/Report.d.ts +1 -1
  10. package/dist/Report.d.ts.map +1 -1
  11. package/dist/Report.js +3 -2
  12. package/dist/Report.js.map +1 -1
  13. package/dist/Style.d.ts +2 -1
  14. package/dist/Style.d.ts.map +1 -1
  15. package/dist/Style.js +3 -1
  16. package/dist/Style.js.map +1 -1
  17. package/dist/index.d.ts +1 -1
  18. package/dist/index.js +1 -1
  19. package/dist/internal/batch-handoff.d.ts +25 -0
  20. package/dist/internal/batch-handoff.d.ts.map +1 -0
  21. package/dist/internal/batch-handoff.js +64 -0
  22. package/dist/internal/batch-handoff.js.map +1 -0
  23. package/dist/internal/gate-environment.d.ts +4 -0
  24. package/dist/internal/gate-environment.d.ts.map +1 -0
  25. package/dist/internal/gate-environment.js +21 -0
  26. package/dist/internal/gate-environment.js.map +1 -0
  27. package/dist/internal/projection.js +14 -14
  28. package/dist/internal/projection.js.map +1 -1
  29. package/dist/internal/reorder.d.ts +2 -2
  30. package/dist/internal/reorder.d.ts.map +1 -1
  31. package/dist/internal/reorder.js +2 -2
  32. package/dist/internal/reorder.js.map +1 -1
  33. package/dist/internal/starting-style.d.ts +0 -83
  34. package/dist/internal/starting-style.d.ts.map +1 -1
  35. package/dist/internal/starting-style.js +16 -143
  36. package/dist/internal/starting-style.js.map +1 -1
  37. package/dist/unstable/AppearAnimations.d.ts +191 -0
  38. package/dist/unstable/AppearAnimations.d.ts.map +1 -0
  39. package/dist/unstable/AppearAnimations.js +561 -0
  40. package/dist/unstable/AppearAnimations.js.map +1 -0
  41. package/dist/unstable/BatchMembers.d.ts +513 -0
  42. package/dist/unstable/BatchMembers.d.ts.map +1 -0
  43. package/dist/unstable/BatchMembers.js +2490 -0
  44. package/dist/unstable/BatchMembers.js.map +1 -0
  45. package/dist/unstable/DomValues.d.ts +25 -0
  46. package/dist/unstable/DomValues.d.ts.map +1 -0
  47. package/dist/unstable/DomValues.js +45 -0
  48. package/dist/unstable/DomValues.js.map +1 -0
  49. package/dist/unstable/DragConstraints.d.ts +48 -0
  50. package/dist/unstable/DragConstraints.d.ts.map +1 -0
  51. package/dist/unstable/DragConstraints.js +49 -0
  52. package/dist/unstable/DragConstraints.js.map +1 -0
  53. package/dist/unstable/DragControls.d.ts +50 -0
  54. package/dist/unstable/DragControls.d.ts.map +1 -0
  55. package/dist/unstable/DragControls.js +55 -0
  56. package/dist/unstable/DragControls.js.map +1 -0
  57. package/dist/unstable/DragDefaults.d.ts +34 -0
  58. package/dist/unstable/DragDefaults.d.ts.map +1 -0
  59. package/dist/unstable/DragDefaults.js +47 -0
  60. package/dist/unstable/DragDefaults.js.map +1 -0
  61. package/dist/unstable/DragTrack.d.ts +236 -0
  62. package/dist/unstable/DragTrack.d.ts.map +1 -0
  63. package/dist/unstable/DragTrack.js +646 -0
  64. package/dist/unstable/DragTrack.js.map +1 -0
  65. package/dist/unstable/DragTransition.d.ts +22 -0
  66. package/dist/unstable/DragTransition.d.ts.map +1 -0
  67. package/dist/unstable/DragTransition.js +31 -0
  68. package/dist/unstable/DragTransition.js.map +1 -0
  69. package/dist/unstable/ElementSetup.d.ts +144 -0
  70. package/dist/unstable/ElementSetup.d.ts.map +1 -0
  71. package/dist/unstable/ElementSetup.js +297 -0
  72. package/dist/unstable/ElementSetup.js.map +1 -0
  73. package/dist/unstable/Feature.d.ts +221 -0
  74. package/dist/unstable/Feature.d.ts.map +1 -0
  75. package/dist/unstable/Feature.js +281 -0
  76. package/dist/unstable/Feature.js.map +1 -0
  77. package/dist/unstable/GestureFeatures.d.ts +30 -0
  78. package/dist/unstable/GestureFeatures.d.ts.map +1 -0
  79. package/dist/unstable/GestureFeatures.js +32 -0
  80. package/dist/unstable/GestureFeatures.js.map +1 -0
  81. package/dist/unstable/GestureInfo.d.ts +61 -0
  82. package/dist/unstable/GestureInfo.d.ts.map +1 -0
  83. package/dist/unstable/GestureInfo.js +23 -0
  84. package/dist/unstable/GestureInfo.js.map +1 -0
  85. package/dist/unstable/Imperative.d.ts +214 -0
  86. package/dist/unstable/Imperative.d.ts.map +1 -0
  87. package/dist/unstable/Imperative.js +768 -0
  88. package/dist/unstable/Imperative.js.map +1 -0
  89. package/dist/unstable/Instant.d.ts +46 -0
  90. package/dist/unstable/Instant.d.ts.map +1 -0
  91. package/dist/unstable/Instant.js +49 -0
  92. package/dist/unstable/Instant.js.map +1 -0
  93. package/dist/unstable/LayoutGroup.d.ts +14 -0
  94. package/dist/unstable/LayoutGroup.d.ts.map +1 -0
  95. package/dist/unstable/LayoutGroup.js +31 -0
  96. package/dist/unstable/LayoutGroup.js.map +1 -0
  97. package/dist/unstable/LayoutMember.d.ts +127 -0
  98. package/dist/unstable/LayoutMember.d.ts.map +1 -0
  99. package/dist/unstable/LayoutMember.js +176 -0
  100. package/dist/unstable/LayoutMember.js.map +1 -0
  101. package/dist/unstable/LiveStyle.d.ts +171 -0
  102. package/dist/unstable/LiveStyle.d.ts.map +1 -0
  103. package/dist/unstable/LiveStyle.js +329 -0
  104. package/dist/unstable/LiveStyle.js.map +1 -0
  105. package/dist/unstable/MemberHold.d.ts +3 -0
  106. package/dist/unstable/MemberHold.d.ts.map +1 -0
  107. package/dist/unstable/MemberHold.js +223 -0
  108. package/dist/unstable/MemberHold.js.map +1 -0
  109. package/dist/unstable/OwnerScope.d.ts +16 -0
  110. package/dist/unstable/OwnerScope.d.ts.map +1 -0
  111. package/dist/unstable/OwnerScope.js +35 -0
  112. package/dist/unstable/OwnerScope.js.map +1 -0
  113. package/dist/unstable/PresenceController.d.ts +128 -0
  114. package/dist/unstable/PresenceController.d.ts.map +1 -0
  115. package/dist/unstable/PresenceController.js +1427 -0
  116. package/dist/unstable/PresenceController.js.map +1 -0
  117. package/dist/unstable/Press.d.ts +26 -0
  118. package/dist/unstable/Press.d.ts.map +1 -0
  119. package/dist/unstable/Press.js +19 -0
  120. package/dist/unstable/Press.js.map +1 -0
  121. package/dist/unstable/ServerInterpolators.d.ts +17 -0
  122. package/dist/unstable/ServerInterpolators.d.ts.map +1 -0
  123. package/dist/unstable/ServerInterpolators.js +20 -0
  124. package/dist/unstable/ServerInterpolators.js.map +1 -0
  125. package/dist/unstable/WardConfig.d.ts +567 -0
  126. package/dist/unstable/WardConfig.d.ts.map +1 -0
  127. package/dist/unstable/WardConfig.js +2 -0
  128. package/dist/unstable/WardConfig.js.map +1 -0
  129. package/dist/unstable/features/All.d.ts +24 -0
  130. package/dist/unstable/features/All.d.ts.map +1 -0
  131. package/dist/unstable/features/All.js +20 -0
  132. package/dist/unstable/features/All.js.map +1 -0
  133. package/dist/unstable/features/Colors.d.ts +12 -0
  134. package/dist/unstable/features/Colors.d.ts.map +1 -0
  135. package/dist/unstable/features/Colors.js +38 -0
  136. package/dist/unstable/features/Colors.js.map +1 -0
  137. package/dist/unstable/features/DomAnimation.d.ts +16 -0
  138. package/dist/unstable/features/DomAnimation.d.ts.map +1 -0
  139. package/dist/unstable/features/DomAnimation.js +19 -0
  140. package/dist/unstable/features/DomAnimation.js.map +1 -0
  141. package/dist/unstable/features/DomMax.d.ts +12 -0
  142. package/dist/unstable/features/DomMax.d.ts.map +1 -0
  143. package/dist/unstable/features/DomMax.js +14 -0
  144. package/dist/unstable/features/DomMax.js.map +1 -0
  145. package/dist/unstable/features/Drag.d.ts +5 -0
  146. package/dist/unstable/features/Drag.d.ts.map +1 -0
  147. package/dist/unstable/features/Drag.js +32 -0
  148. package/dist/unstable/features/Drag.js.map +1 -0
  149. package/dist/unstable/features/Focus.d.ts +5 -0
  150. package/dist/unstable/features/Focus.d.ts.map +1 -0
  151. package/dist/unstable/features/Focus.js +20 -0
  152. package/dist/unstable/features/Focus.js.map +1 -0
  153. package/dist/unstable/features/Hover.d.ts +5 -0
  154. package/dist/unstable/features/Hover.d.ts.map +1 -0
  155. package/dist/unstable/features/Hover.js +20 -0
  156. package/dist/unstable/features/Hover.js.map +1 -0
  157. package/dist/unstable/features/InView.d.ts +5 -0
  158. package/dist/unstable/features/InView.d.ts.map +1 -0
  159. package/dist/unstable/features/InView.js +20 -0
  160. package/dist/unstable/features/InView.js.map +1 -0
  161. package/dist/unstable/features/Input.d.ts +28 -0
  162. package/dist/unstable/features/Input.d.ts.map +1 -0
  163. package/dist/unstable/features/Input.js +31 -0
  164. package/dist/unstable/features/Input.js.map +1 -0
  165. package/dist/unstable/features/Keys.d.ts +95 -0
  166. package/dist/unstable/features/Keys.d.ts.map +1 -0
  167. package/dist/unstable/features/Keys.js +44 -0
  168. package/dist/unstable/features/Keys.js.map +1 -0
  169. package/dist/unstable/features/Layout.d.ts +43 -0
  170. package/dist/unstable/features/Layout.d.ts.map +1 -0
  171. package/dist/unstable/features/Layout.js +44 -0
  172. package/dist/unstable/features/Layout.js.map +1 -0
  173. package/dist/unstable/features/Pan.d.ts +5 -0
  174. package/dist/unstable/features/Pan.d.ts.map +1 -0
  175. package/dist/unstable/features/Pan.js +20 -0
  176. package/dist/unstable/features/Pan.js.map +1 -0
  177. package/dist/unstable/features/Press.d.ts +13 -0
  178. package/dist/unstable/features/Press.d.ts.map +1 -0
  179. package/dist/unstable/features/Press.js +10 -0
  180. package/dist/unstable/features/Press.js.map +1 -0
  181. package/dist/unstable/features/Scroll.d.ts +20 -0
  182. package/dist/unstable/features/Scroll.d.ts.map +1 -0
  183. package/dist/unstable/features/Scroll.js +34 -0
  184. package/dist/unstable/features/Scroll.js.map +1 -0
  185. package/dist/unstable/features/TimelineKeys.d.ts +7 -0
  186. package/dist/unstable/features/TimelineKeys.d.ts.map +1 -0
  187. package/dist/unstable/features/TimelineKeys.js +103 -0
  188. package/dist/unstable/features/TimelineKeys.js.map +1 -0
  189. package/package.json +4 -3
  190. package/src/DomProjectionSystem.ts +3 -3
  191. package/src/FlushGate.ts +11 -9
  192. package/src/ReorderController.ts +3 -3
  193. package/src/Report.ts +3 -7
  194. package/src/Style.ts +4 -1
  195. package/src/index.ts +1 -1
  196. package/src/internal/batch-handoff.ts +75 -0
  197. package/src/internal/gate-environment.ts +21 -0
  198. package/src/internal/projection.ts +14 -14
  199. package/src/internal/reorder.ts +4 -4
  200. package/src/internal/starting-style.ts +5 -204
  201. package/src/unstable/AppearAnimations.ts +837 -0
  202. package/src/unstable/BatchMembers.ts +3085 -0
  203. package/src/unstable/DomValues.ts +53 -0
  204. package/src/unstable/DragConstraints.ts +107 -0
  205. package/src/unstable/DragControls.ts +98 -0
  206. package/src/unstable/DragDefaults.ts +57 -0
  207. package/src/unstable/DragTrack.ts +959 -0
  208. package/src/unstable/DragTransition.ts +46 -0
  209. package/src/unstable/ElementSetup.ts +411 -0
  210. package/src/unstable/Feature.ts +494 -0
  211. package/src/unstable/GestureFeatures.ts +38 -0
  212. package/src/unstable/GestureInfo.ts +85 -0
  213. package/src/unstable/Imperative.ts +1037 -0
  214. package/src/unstable/Instant.ts +93 -0
  215. package/src/unstable/LayoutGroup.ts +36 -0
  216. package/src/unstable/LayoutMember.ts +319 -0
  217. package/src/unstable/LiveStyle.ts +497 -0
  218. package/src/unstable/MemberHold.ts +211 -0
  219. package/src/unstable/OwnerScope.ts +35 -0
  220. package/src/unstable/PresenceController.ts +1747 -0
  221. package/src/unstable/Press.ts +43 -0
  222. package/src/unstable/ServerInterpolators.ts +39 -0
  223. package/src/unstable/WardConfig.ts +704 -0
  224. package/src/unstable/features/All.ts +39 -0
  225. package/src/unstable/features/Colors.ts +40 -0
  226. package/src/unstable/features/DomAnimation.ts +19 -0
  227. package/src/unstable/features/DomMax.ts +14 -0
  228. package/src/unstable/features/Drag.ts +34 -0
  229. package/src/unstable/features/Focus.ts +21 -0
  230. package/src/unstable/features/Hover.ts +21 -0
  231. package/src/unstable/features/InView.ts +21 -0
  232. package/src/unstable/features/Input.ts +37 -0
  233. package/src/unstable/features/Keys.ts +124 -0
  234. package/src/unstable/features/Layout.ts +75 -0
  235. package/src/unstable/features/Pan.ts +21 -0
  236. package/src/unstable/features/Press.ts +21 -0
  237. package/src/unstable/features/Scroll.ts +35 -0
  238. package/src/unstable/features/TimelineKeys.ts +115 -0
  239. package/dist/internal/gate.d.ts +0 -199
  240. package/dist/internal/gate.d.ts.map +0 -1
  241. package/dist/internal/gate.js +0 -570
  242. package/dist/internal/gate.js.map +0 -1
  243. package/dist/internal/report.d.ts +0 -30
  244. package/dist/internal/report.d.ts.map +0 -1
  245. package/dist/internal/report.js +0 -60
  246. package/dist/internal/report.js.map +0 -1
  247. package/dist/internal/runner.d.ts +0 -22
  248. package/dist/internal/runner.d.ts.map +0 -1
  249. package/dist/internal/runner.js +0 -62
  250. package/dist/internal/runner.js.map +0 -1
  251. package/src/internal/gate.ts +0 -706
  252. package/src/internal/report.ts +0 -69
  253. package/src/internal/runner.ts +0 -78
@@ -0,0 +1,211 @@
1
+ /**
2
+ * A Batch member's element's hold on the groups a Wardic element on it takes from its Batch (#665's
3
+ * PR 4, ADR-0069 decision 17, Q52–Q54): the latest driver. Its spine makes one as it first finds its
4
+ * element a member's, through what `createBatch` provides here: an app with no Batch ships none of it.
5
+ *
6
+ * Unstable, for Wardic's own packages: public, with no semver promise.
7
+ *
8
+ * @module
9
+ */
10
+ // Unstable: ADR-0071, decision 5. #672 (Q14): the filler half of solid's `member-hold.ts` (its slot is core's
11
+ // Spine's), moved to dom beside the Batch for every DOM binding's `createBatch`.
12
+ // ADR-0070, *Amendment (#665)*: only members pay. A spine reads one module slot a Retarget while no
13
+ // Batch has been made, and a WeakMap after; this module's code is reached through `provideBatchHolds`,
14
+ // which only `createBatch` calls.
15
+ import * as BaseValue from "@wardic/core/BaseValue"
16
+ import * as Arr from "effect/Array"
17
+ import { constFalse } from "effect/Function"
18
+ import * as Iter from "effect/Iterable"
19
+ import * as Predicate from "effect/Predicate"
20
+ import * as Rec from "effect/Record"
21
+ import * as BatchMembers from "./BatchMembers.ts"
22
+ import * as Spine from "@wardic/core/unstable/Spine"
23
+
24
+ // What a hold works its spine with (#746): here, not in the spine, so an app with no Batch ships none
25
+ // of it (ADR-0070's *Note (#746)*). Functions over the host, not closures: a hold makes none of its own.
26
+
27
+ /** Whether a leg still runs on a key `which` picks. */
28
+ // Per held group at a leg's end or a Batch change (#665): statements.
29
+ const anyRunning = (host: Spine.HoldHost, which: (key: string) => boolean): boolean => {
30
+ let runs = false
31
+ Iter.forEach(host.owners, ([key, running]) => {
32
+ if (Predicate.isUndefined(running)) return
33
+ if (running.done) return
34
+ if (which(key)) runs = true
35
+ })
36
+ return runs
37
+ }
38
+
39
+ /** The keys `which` picks given up by the legs drawing them, each leg drawing the rest from then on. */
40
+ // Setting a visited key is safe in a Map's iteration.
41
+ const giveUpKeys = (host: Spine.HoldHost, which: (key: string) => boolean): void => {
42
+ Iter.forEach(host.owners, ([key, running]) => {
43
+ if (Predicate.isUndefined(running)) return
44
+ if (which(key)) host.giveUp(key, running)
45
+ })
46
+ host.keepTheRest()
47
+ }
48
+
49
+ /** `key`'s speed at `now`, per second. */
50
+ const velocityOf = (host: Spine.HoldHost, key: string, now: number): number => Spine.velocityAt(host.snapshot, host.owners.get(key), key, now)
51
+
52
+ /** `key` the spine's no more: out of the keys it drove and those it returns. */
53
+ const forgetKey = (host: Spine.HoldHost, key: string): void => {
54
+ host.driven.delete(key)
55
+ host.returning().delete(key)
56
+ }
57
+
58
+ /** Holds made from now on (`createBatch`, as it's called): a Batch's members can be Wardic elements. */
59
+ // #672 (Q14): the slot is the spine's; this fills it with the Batch's holds.
60
+ export const provideBatchHolds = (): void => Spine.provideMemberHolds(BATCH_HOLDS)
61
+
62
+ /** A Batch member's element's {@link Spine.MemberHold}. */
63
+ const makeMemberHold = (host: Spine.HoldHost): Spine.MemberHold => {
64
+ const { element, gate, id, snapshot } = host
65
+ // The groups it holds now, each with the Batch's keys in it; the member it took them from; and whether
66
+ // a drag holds `x`/`y`, from its first read or write to its hand-back.
67
+ const held = new Map<BatchMembers.BatchGroup, ReadonlyArray<string>>()
68
+ let takenFrom: BatchMembers.BatchMemberEntry | undefined
69
+ let dragging = false
70
+
71
+ /** A transform key the Batch doesn't draw (`rotate` on an `{ x, y }` Batch): its `transform` would drop it. */
72
+ const undrawnBy = (batchKeys: ReadonlyArray<string>) => (key: string): boolean => {
73
+ if (BatchMembers.batchGroupOf(key) !== "transform") return false
74
+ return !Arr.contains(batchKeys, key)
75
+ }
76
+
77
+ /** Whether a transform key the Batch doesn't draw has a leg running, or is off its identity. */
78
+ // Per held transform at a leg's end or a Batch change (#665): statements.
79
+ const holdsUndrawn = (batchKeys: ReadonlyArray<string>): boolean => {
80
+ const undrawn = undrawnBy(batchKeys)
81
+ if (anyRunning(host, undrawn)) return true
82
+ return Arr.some(Rec.keys(snapshot.values), (key) => {
83
+ if (!undrawn(key)) return false
84
+ return snapshot.values[key] !== BaseValue.TRANSFORM_IDENTITY[key]
85
+ })
86
+ }
87
+
88
+ /** Whether it keeps the transform: a drag holds it, or a transform key the Batch doesn't draw. */
89
+ const keepsTransform = (batchKeys: ReadonlyArray<string>): boolean => {
90
+ if (dragging) return true
91
+ return holdsUndrawn(batchKeys)
92
+ }
93
+
94
+ /** `group` given back: its legs give its keys up, the gate draws it no more (what's drawn kept), and its Batch keys' values and speeds. */
95
+ const surrender = (group: BatchMembers.BatchGroup): BatchMembers.BatchHandover | undefined => {
96
+ const batchKeys = held.get(group)
97
+ if (Predicate.isUndefined(batchKeys)) return undefined
98
+ held.delete(group)
99
+ const now = snapshot.now()
100
+ const values: Record<string, number> = {}
101
+ const velocities: Record<string, number> = {}
102
+ Arr.forEach(batchKeys, (key) => {
103
+ values[key] = snapshot.values[key] as number
104
+ velocities[key] = velocityOf(host, key, now)
105
+ })
106
+ const inGroup = (key: string): boolean => BatchMembers.batchGroupOf(key) === group
107
+ giveUpKeys(host, inGroup)
108
+ const keys = Arr.filter(Rec.keys(snapshot.values), inGroup)
109
+ // Left as drawn as it drops out: the Batch's writer draws it from its next step. A group's name is its property's.
110
+ gate.release(id, keys, undefined, [group])
111
+ Arr.forEach(keys, (key) => {
112
+ delete snapshot.values[key]
113
+ forgetKey(host, key)
114
+ })
115
+ return { values, velocities }
116
+ }
117
+
118
+ const holder: BatchMembers.BatchHolder = {
119
+ surrender,
120
+ keepsThrough: (group) => {
121
+ if (group !== "transform") return false
122
+ const batchKeys = held.get(group)
123
+ if (Predicate.isUndefined(batchKeys)) return false
124
+ return keepsTransform(batchKeys)
125
+ },
126
+ }
127
+
128
+ /** `group` taken from the Batch of `entry`, its element's member (Q53): seeded at the member's values and speeds, drawn by the gate from now on. */
129
+ const claim = (entry: BatchMembers.BatchMemberEntry, group: BatchMembers.BatchGroup): void => {
130
+ if (held.has(group)) return
131
+ const given = entry.binding.yieldGroup(entry.member, group, holder)
132
+ if (Predicate.isUndefined(given)) return
133
+ held.set(group, given.keys)
134
+ snapshot.values = { ...snapshot.values, ...given.values }
135
+ snapshot.velocities = { ...snapshot.velocities, ...given.velocities }
136
+ const now = snapshot.now()
137
+ Arr.forEach(given.keys, (seeded) => {
138
+ snapshot.drawnAt[seeded] = now
139
+ })
140
+ gate.write(id, given.values)
141
+ }
142
+
143
+ /**
144
+ * Its element's member now, what it holds kept only if it's the one it took them from: an element
145
+ * another member's, or its Batch's no more, holds nothing of its old one.
146
+ */
147
+ const memberNow = (): BatchMembers.BatchMemberEntry | undefined => {
148
+ const entry = BatchMembers.memberEntryOf(element)
149
+ if (entry === takenFrom) return entry
150
+ held.clear()
151
+ takenFrom = entry
152
+ return entry
153
+ }
154
+
155
+ /** Each group it holds and `keeps` doesn't, back to the member's Batch, from where it is. Deleting the visited entry is safe in a Map's iteration. */
156
+ const giveBack = (keeps: (group: BatchMembers.BatchGroup, batchKeys: ReadonlyArray<string>) => boolean): void => {
157
+ if (held.size === 0) return
158
+ const entry = memberNow()
159
+ if (Predicate.isUndefined(entry)) return
160
+ Iter.forEach(held, ([group, batchKeys]) => {
161
+ if (keeps(group, batchKeys)) return
162
+ const back = surrender(group)
163
+ if (Predicate.isNotUndefined(back)) entry.binding.reclaim(entry.member, group, back)
164
+ })
165
+ }
166
+
167
+ /** Whether `group` stays its own at a leg's end: a leg runs on it, or it's the transform it keeps (Q54). */
168
+ const stays = (group: BatchMembers.BatchGroup, batchKeys: ReadonlyArray<string>): boolean => {
169
+ if (anyRunning(host, (key) => BatchMembers.batchGroupOf(key) === group)) return true
170
+ if (group !== "transform") return false
171
+ return keepsTransform(batchKeys)
172
+ }
173
+
174
+ return {
175
+ retarget: (t, dragged) => {
176
+ const entry = memberNow()
177
+ if (Predicate.isUndefined(entry)) return
178
+ if (dragged) claim(entry, "transform")
179
+ // Per key of a member's Retarget: statements.
180
+ Arr.forEach(Rec.keys(t), (key) => {
181
+ const group = BatchMembers.batchGroupOf(key)
182
+ if (Predicate.isUndefined(group)) return
183
+ if (held.has(group)) return
184
+ const drawn = entry.binding.drawnValueOf(entry.member, key)
185
+ if (Predicate.isUndefined(drawn)) return
186
+ if (t[key] === drawn) {
187
+ delete t[key]
188
+ return
189
+ }
190
+ claim(entry, group)
191
+ })
192
+ },
193
+ settle: () => giveBack(stays),
194
+ drag: (on) => {
195
+ if (on) {
196
+ dragging = true
197
+ if (held.has("transform")) return
198
+ const entry = memberNow()
199
+ if (Predicate.isNotUndefined(entry)) claim(entry, "transform")
200
+ return
201
+ }
202
+ if (!dragging) return
203
+ dragging = false
204
+ giveBack(stays)
205
+ },
206
+ dispose: () => giveBack(constFalse),
207
+ }
208
+ }
209
+
210
+ /** The Batch's holds, which `provideBatchHolds` gives the spine's slot: one record, made once. */
211
+ const BATCH_HOLDS: Spine.MemberHolds = { isMember: BatchMembers.isMemberElement, make: makeMemberHold }
@@ -0,0 +1,35 @@
1
+ /**
2
+ * The Scopes a binding opens on its provider's runtime, for an element's or a hook's work: each a child
3
+ * of the runtime's own, so one nothing closed ends with the runtime, and closed with its owner without
4
+ * throwing into the cleanup that closes it. Every binding's.
5
+ *
6
+ * Unstable, for Wardic's own packages: public, with no semver promise.
7
+ *
8
+ * @module
9
+ */
10
+ // Unstable: ADR-0071, decision 5. #672: solid's `owner-scope.ts`, moved to dom for every DOM binding's
11
+ // elements, hooks and Features, on a Runner (PR5-Q1).
12
+ import * as Report from "../Report.ts"
13
+ import * as Exit from "effect/Exit"
14
+ import * as Scope from "effect/Scope"
15
+ import type * as WardicServices from "@wardic/core/unstable/WardicServices"
16
+
17
+ /**
18
+ * A Scope for one owner's work on `runtime`: a child of the runtime's, so the runtime's disposal closes
19
+ * it if its owner hasn't. Its finalizers run in reverse order, as a Scope's do.
20
+ */
21
+ // #618 (L1): no detached `Scope.makeUnsafe()`. A child closed first takes itself off its parent.
22
+ export const open = (runtime: { readonly scope: Scope.Scope }): Scope.Closeable => Scope.forkUnsafe(runtime.scope, "sequential")
23
+
24
+ /**
25
+ * Closes `scope` now, synchronously, on `runtime`. A finalizer that fails is logged and reported as
26
+ * `label` (`Report.failure`), never thrown: the rest of the binding's cleanup that closes it still runs. A
27
+ * Scope the runtime's disposal already closed is left as it is.
28
+ */
29
+ // #618 (decision 5): `runtime.runSync(Scope.close(…))` threw a failed finalizer's cause into Solid's
30
+ // cleanup, which skipped the rest of it.
31
+ export const close = <R>(runtime: WardicServices.Runner<R>, scope: Scope.Closeable, label: string): void => {
32
+ if (scope.state._tag === "Closed") return
33
+ const exit = runtime.runSyncExit(Scope.close(scope, Exit.void))
34
+ if (Exit.isFailure(exit)) runtime.runFork(Report.failure(label, exit.cause))
35
+ }