@wardic/dom 0.0.0-stage → 1.0.0-rc.10

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 (315) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +8 -2
  3. package/THIRD_PARTY_NOTICES.md +145 -0
  4. package/dist/Appear.d.ts +30 -0
  5. package/dist/Appear.d.ts.map +1 -0
  6. package/dist/Appear.js +31 -0
  7. package/dist/Appear.js.map +1 -0
  8. package/dist/Color.d.ts +14 -0
  9. package/dist/Color.d.ts.map +1 -0
  10. package/dist/Color.js +16 -0
  11. package/dist/Color.js.map +1 -0
  12. package/dist/DomAnnouncer.d.ts +13 -0
  13. package/dist/DomAnnouncer.d.ts.map +1 -0
  14. package/dist/DomAnnouncer.js +14 -0
  15. package/dist/DomAnnouncer.js.map +1 -0
  16. package/dist/DomBatch.d.ts +20 -0
  17. package/dist/DomBatch.d.ts.map +1 -0
  18. package/dist/DomBatch.js +23 -0
  19. package/dist/DomBatch.js.map +1 -0
  20. package/dist/DomClock.d.ts +11 -0
  21. package/dist/DomClock.d.ts.map +1 -0
  22. package/dist/DomClock.js +12 -0
  23. package/dist/DomClock.js.map +1 -0
  24. package/dist/DomDefaultTransition.d.ts +12 -0
  25. package/dist/DomDefaultTransition.d.ts.map +1 -0
  26. package/dist/DomDefaultTransition.js +13 -0
  27. package/dist/DomDefaultTransition.js.map +1 -0
  28. package/dist/DomInput.d.ts +14 -0
  29. package/dist/DomInput.d.ts.map +1 -0
  30. package/dist/DomInput.js +17 -0
  31. package/dist/DomInput.js.map +1 -0
  32. package/dist/DomInterpolators.d.ts +13 -0
  33. package/dist/DomInterpolators.d.ts.map +1 -0
  34. package/dist/DomInterpolators.js +14 -0
  35. package/dist/DomInterpolators.js.map +1 -0
  36. package/dist/DomKeyRules.d.ts +13 -0
  37. package/dist/DomKeyRules.d.ts.map +1 -0
  38. package/dist/DomKeyRules.js +14 -0
  39. package/dist/DomKeyRules.js.map +1 -0
  40. package/dist/DomPositionalKeys.d.ts +13 -0
  41. package/dist/DomPositionalKeys.d.ts.map +1 -0
  42. package/dist/DomPositionalKeys.js +14 -0
  43. package/dist/DomPositionalKeys.js.map +1 -0
  44. package/dist/DomProbe.d.ts +13 -0
  45. package/dist/DomProbe.d.ts.map +1 -0
  46. package/dist/DomProbe.js +14 -0
  47. package/dist/DomProbe.js.map +1 -0
  48. package/dist/DomProjectionSystem.d.ts +28 -0
  49. package/dist/DomProjectionSystem.d.ts.map +1 -0
  50. package/dist/DomProjectionSystem.js +41 -0
  51. package/dist/DomProjectionSystem.js.map +1 -0
  52. package/dist/DomRenderer.d.ts +13 -0
  53. package/dist/DomRenderer.d.ts.map +1 -0
  54. package/dist/DomRenderer.js +15 -0
  55. package/dist/DomRenderer.js.map +1 -0
  56. package/dist/DomScrollSource.d.ts +14 -0
  57. package/dist/DomScrollSource.d.ts.map +1 -0
  58. package/dist/DomScrollSource.js +15 -0
  59. package/dist/DomScrollSource.js.map +1 -0
  60. package/dist/FlushGate.d.ts +48 -0
  61. package/dist/FlushGate.d.ts.map +1 -0
  62. package/dist/FlushGate.js +62 -0
  63. package/dist/FlushGate.js.map +1 -0
  64. package/dist/KeyboardPress.d.ts +16 -0
  65. package/dist/KeyboardPress.d.ts.map +1 -0
  66. package/dist/KeyboardPress.js +17 -0
  67. package/dist/KeyboardPress.js.map +1 -0
  68. package/dist/MeasuredPair.d.ts +14 -0
  69. package/dist/MeasuredPair.d.ts.map +1 -0
  70. package/dist/MeasuredPair.js +16 -0
  71. package/dist/MeasuredPair.js.map +1 -0
  72. package/dist/OwnValues.d.ts +14 -0
  73. package/dist/OwnValues.d.ts.map +1 -0
  74. package/dist/OwnValues.js +15 -0
  75. package/dist/OwnValues.js.map +1 -0
  76. package/dist/ProjectionSystem.d.ts +34 -0
  77. package/dist/ProjectionSystem.d.ts.map +1 -0
  78. package/dist/ProjectionSystem.js +29 -0
  79. package/dist/ProjectionSystem.js.map +1 -0
  80. package/dist/ReorderController.d.ts +61 -0
  81. package/dist/ReorderController.d.ts.map +1 -0
  82. package/dist/ReorderController.js +78 -0
  83. package/dist/ReorderController.js.map +1 -0
  84. package/dist/Report.d.ts +12 -0
  85. package/dist/Report.d.ts.map +1 -0
  86. package/dist/Report.js +13 -0
  87. package/dist/Report.js.map +1 -0
  88. package/dist/ScrollOffset.d.ts +34 -0
  89. package/dist/ScrollOffset.d.ts.map +1 -0
  90. package/dist/ScrollOffset.js +42 -0
  91. package/dist/ScrollOffset.js.map +1 -0
  92. package/dist/Style.d.ts +15 -0
  93. package/dist/Style.d.ts.map +1 -0
  94. package/dist/Style.js +17 -0
  95. package/dist/Style.js.map +1 -0
  96. package/dist/Svg.d.ts +13 -0
  97. package/dist/Svg.d.ts.map +1 -0
  98. package/dist/Svg.js +14 -0
  99. package/dist/Svg.js.map +1 -0
  100. package/dist/Variables.d.ts +13 -0
  101. package/dist/Variables.d.ts.map +1 -0
  102. package/dist/Variables.js +14 -0
  103. package/dist/Variables.js.map +1 -0
  104. package/dist/index.d.ts +83 -0
  105. package/dist/index.d.ts.map +1 -0
  106. package/dist/index.js +71 -0
  107. package/dist/index.js.map +1 -0
  108. package/dist/internal/announcer.d.ts +50 -0
  109. package/dist/internal/announcer.d.ts.map +1 -0
  110. package/dist/internal/announcer.js +115 -0
  111. package/dist/internal/announcer.js.map +1 -0
  112. package/dist/internal/appear-slot.d.ts +23 -0
  113. package/dist/internal/appear-slot.d.ts.map +1 -0
  114. package/dist/internal/appear-slot.js +29 -0
  115. package/dist/internal/appear-slot.js.map +1 -0
  116. package/dist/internal/appear.d.ts +237 -0
  117. package/dist/internal/appear.d.ts.map +1 -0
  118. package/dist/internal/appear.js +740 -0
  119. package/dist/internal/appear.js.map +1 -0
  120. package/dist/internal/auto-scroll.d.ts +24 -0
  121. package/dist/internal/auto-scroll.d.ts.map +1 -0
  122. package/dist/internal/auto-scroll.js +124 -0
  123. package/dist/internal/auto-scroll.js.map +1 -0
  124. package/dist/internal/batch-writer.d.ts +16 -0
  125. package/dist/internal/batch-writer.d.ts.map +1 -0
  126. package/dist/internal/batch-writer.js +77 -0
  127. package/dist/internal/batch-writer.js.map +1 -0
  128. package/dist/internal/clock.d.ts +19 -0
  129. package/dist/internal/clock.d.ts.map +1 -0
  130. package/dist/internal/clock.js +39 -0
  131. package/dist/internal/clock.js.map +1 -0
  132. package/dist/internal/colors.d.ts +45 -0
  133. package/dist/internal/colors.d.ts.map +1 -0
  134. package/dist/internal/colors.js +193 -0
  135. package/dist/internal/colors.js.map +1 -0
  136. package/dist/internal/complex.d.ts +24 -0
  137. package/dist/internal/complex.d.ts.map +1 -0
  138. package/dist/internal/complex.js +28 -0
  139. package/dist/internal/complex.js.map +1 -0
  140. package/dist/internal/content-watch.d.ts +20 -0
  141. package/dist/internal/content-watch.d.ts.map +1 -0
  142. package/dist/internal/content-watch.js +76 -0
  143. package/dist/internal/content-watch.js.map +1 -0
  144. package/dist/internal/default-transition.d.ts +25 -0
  145. package/dist/internal/default-transition.d.ts.map +1 -0
  146. package/dist/internal/default-transition.js +41 -0
  147. package/dist/internal/default-transition.js.map +1 -0
  148. package/dist/internal/drag-defaults.d.ts +18 -0
  149. package/dist/internal/drag-defaults.d.ts.map +1 -0
  150. package/dist/internal/drag-defaults.js +38 -0
  151. package/dist/internal/drag-defaults.js.map +1 -0
  152. package/dist/internal/gate.d.ts +188 -0
  153. package/dist/internal/gate.d.ts.map +1 -0
  154. package/dist/internal/gate.js +458 -0
  155. package/dist/internal/gate.js.map +1 -0
  156. package/dist/internal/input.d.ts +35 -0
  157. package/dist/internal/input.d.ts.map +1 -0
  158. package/dist/internal/input.js +658 -0
  159. package/dist/internal/input.js.map +1 -0
  160. package/dist/internal/interpolators.d.ts +19 -0
  161. package/dist/internal/interpolators.d.ts.map +1 -0
  162. package/dist/internal/interpolators.js +30 -0
  163. package/dist/internal/interpolators.js.map +1 -0
  164. package/dist/internal/key-rules.d.ts +11 -0
  165. package/dist/internal/key-rules.d.ts.map +1 -0
  166. package/dist/internal/key-rules.js +244 -0
  167. package/dist/internal/key-rules.js.map +1 -0
  168. package/dist/internal/keyboard-press.d.ts +7 -0
  169. package/dist/internal/keyboard-press.d.ts.map +1 -0
  170. package/dist/internal/keyboard-press.js +45 -0
  171. package/dist/internal/keyboard-press.js.map +1 -0
  172. package/dist/internal/measure.d.ts +157 -0
  173. package/dist/internal/measure.d.ts.map +1 -0
  174. package/dist/internal/measure.js +296 -0
  175. package/dist/internal/measure.js.map +1 -0
  176. package/dist/internal/measured-pairs.d.ts +38 -0
  177. package/dist/internal/measured-pairs.d.ts.map +1 -0
  178. package/dist/internal/measured-pairs.js +251 -0
  179. package/dist/internal/measured-pairs.js.map +1 -0
  180. package/dist/internal/own-values.d.ts +35 -0
  181. package/dist/internal/own-values.d.ts.map +1 -0
  182. package/dist/internal/own-values.js +117 -0
  183. package/dist/internal/own-values.js.map +1 -0
  184. package/dist/internal/pass-ends.d.ts +21 -0
  185. package/dist/internal/pass-ends.d.ts.map +1 -0
  186. package/dist/internal/pass-ends.js +14 -0
  187. package/dist/internal/pass-ends.js.map +1 -0
  188. package/dist/internal/positional-keys.d.ts +16 -0
  189. package/dist/internal/positional-keys.d.ts.map +1 -0
  190. package/dist/internal/positional-keys.js +21 -0
  191. package/dist/internal/positional-keys.js.map +1 -0
  192. package/dist/internal/probe.d.ts +10 -0
  193. package/dist/internal/probe.d.ts.map +1 -0
  194. package/dist/internal/probe.js +116 -0
  195. package/dist/internal/probe.js.map +1 -0
  196. package/dist/internal/projection-defaults.d.ts +34 -0
  197. package/dist/internal/projection-defaults.d.ts.map +1 -0
  198. package/dist/internal/projection-defaults.js +21 -0
  199. package/dist/internal/projection-defaults.js.map +1 -0
  200. package/dist/internal/projection.d.ts +537 -0
  201. package/dist/internal/projection.d.ts.map +1 -0
  202. package/dist/internal/projection.js +5228 -0
  203. package/dist/internal/projection.js.map +1 -0
  204. package/dist/internal/renderer.d.ts +104 -0
  205. package/dist/internal/renderer.d.ts.map +1 -0
  206. package/dist/internal/renderer.js +618 -0
  207. package/dist/internal/renderer.js.map +1 -0
  208. package/dist/internal/reorder.d.ts +174 -0
  209. package/dist/internal/reorder.d.ts.map +1 -0
  210. package/dist/internal/reorder.js +466 -0
  211. package/dist/internal/reorder.js.map +1 -0
  212. package/dist/internal/report.d.ts +30 -0
  213. package/dist/internal/report.d.ts.map +1 -0
  214. package/dist/internal/report.js +60 -0
  215. package/dist/internal/report.js.map +1 -0
  216. package/dist/internal/require-global.d.ts +11 -0
  217. package/dist/internal/require-global.d.ts.map +1 -0
  218. package/dist/internal/require-global.js +31 -0
  219. package/dist/internal/require-global.js.map +1 -0
  220. package/dist/internal/reveal.d.ts +20 -0
  221. package/dist/internal/reveal.d.ts.map +1 -0
  222. package/dist/internal/reveal.js +71 -0
  223. package/dist/internal/reveal.js.map +1 -0
  224. package/dist/internal/runner.d.ts +21 -0
  225. package/dist/internal/runner.d.ts.map +1 -0
  226. package/dist/internal/runner.js +48 -0
  227. package/dist/internal/runner.js.map +1 -0
  228. package/dist/internal/scale-correction.d.ts +80 -0
  229. package/dist/internal/scale-correction.d.ts.map +1 -0
  230. package/dist/internal/scale-correction.js +227 -0
  231. package/dist/internal/scale-correction.js.map +1 -0
  232. package/dist/internal/scroll.d.ts +37 -0
  233. package/dist/internal/scroll.d.ts.map +1 -0
  234. package/dist/internal/scroll.js +279 -0
  235. package/dist/internal/scroll.js.map +1 -0
  236. package/dist/internal/scrollers.d.ts +35 -0
  237. package/dist/internal/scrollers.d.ts.map +1 -0
  238. package/dist/internal/scrollers.js +38 -0
  239. package/dist/internal/scrollers.js.map +1 -0
  240. package/dist/internal/starting-style.d.ts +141 -0
  241. package/dist/internal/starting-style.d.ts.map +1 -0
  242. package/dist/internal/starting-style.js +300 -0
  243. package/dist/internal/starting-style.js.map +1 -0
  244. package/dist/internal/svg.d.ts +60 -0
  245. package/dist/internal/svg.d.ts.map +1 -0
  246. package/dist/internal/svg.js +257 -0
  247. package/dist/internal/svg.js.map +1 -0
  248. package/dist/internal/variables.d.ts +45 -0
  249. package/dist/internal/variables.d.ts.map +1 -0
  250. package/dist/internal/variables.js +92 -0
  251. package/dist/internal/variables.js.map +1 -0
  252. package/package.json +65 -4
  253. package/src/Appear.ts +54 -0
  254. package/src/Color.ts +24 -0
  255. package/src/DomAnnouncer.ts +22 -0
  256. package/src/DomBatch.ts +22 -0
  257. package/src/DomClock.ts +13 -0
  258. package/src/DomDefaultTransition.ts +16 -0
  259. package/src/DomInput.ts +23 -0
  260. package/src/DomInterpolators.ts +16 -0
  261. package/src/DomKeyRules.ts +17 -0
  262. package/src/DomPositionalKeys.ts +16 -0
  263. package/src/DomProbe.ts +15 -0
  264. package/src/DomProjectionSystem.ts +44 -0
  265. package/src/DomRenderer.ts +26 -0
  266. package/src/DomScrollSource.ts +14 -0
  267. package/src/FlushGate.ts +81 -0
  268. package/src/KeyboardPress.ts +16 -0
  269. package/src/MeasuredPair.ts +15 -0
  270. package/src/OwnValues.ts +19 -0
  271. package/src/ProjectionSystem.ts +51 -0
  272. package/src/ReorderController.ts +122 -0
  273. package/src/Report.ts +17 -0
  274. package/src/ScrollOffset.ts +54 -0
  275. package/src/Style.ts +37 -0
  276. package/src/Svg.ts +21 -0
  277. package/src/Variables.ts +17 -0
  278. package/src/index.ts +120 -0
  279. package/src/internal/announcer.ts +132 -0
  280. package/src/internal/appear-slot.ts +32 -0
  281. package/src/internal/appear.ts +1134 -0
  282. package/src/internal/auto-scroll.ts +176 -0
  283. package/src/internal/batch-writer.ts +95 -0
  284. package/src/internal/clock.ts +45 -0
  285. package/src/internal/colors.ts +258 -0
  286. package/src/internal/complex.ts +29 -0
  287. package/src/internal/content-watch.ts +84 -0
  288. package/src/internal/culori.d.ts +58 -0
  289. package/src/internal/default-transition.ts +50 -0
  290. package/src/internal/drag-defaults.ts +54 -0
  291. package/src/internal/gate.ts +598 -0
  292. package/src/internal/input.ts +763 -0
  293. package/src/internal/interpolators.ts +33 -0
  294. package/src/internal/key-rules.ts +357 -0
  295. package/src/internal/keyboard-press.ts +45 -0
  296. package/src/internal/measure.ts +373 -0
  297. package/src/internal/measured-pairs.ts +297 -0
  298. package/src/internal/own-values.ts +166 -0
  299. package/src/internal/pass-ends.ts +23 -0
  300. package/src/internal/positional-keys.ts +24 -0
  301. package/src/internal/probe.ts +175 -0
  302. package/src/internal/projection-defaults.ts +45 -0
  303. package/src/internal/projection.ts +6233 -0
  304. package/src/internal/renderer.ts +648 -0
  305. package/src/internal/reorder.ts +650 -0
  306. package/src/internal/report.ts +69 -0
  307. package/src/internal/require-global.ts +46 -0
  308. package/src/internal/reveal.ts +75 -0
  309. package/src/internal/runner.ts +64 -0
  310. package/src/internal/scale-correction.ts +310 -0
  311. package/src/internal/scroll.ts +358 -0
  312. package/src/internal/scrollers.ts +51 -0
  313. package/src/internal/starting-style.ts +396 -0
  314. package/src/internal/svg.ts +300 -0
  315. package/src/internal/variables.ts +145 -0
@@ -0,0 +1,23 @@
1
+ /**
2
+ * The DOM's InputSource: pointer, keyboard and focus events as core's own, mapped from the DOM's names by
3
+ * `toPointer`, `keyOf`, `kindOf` and `buttonOf`. It isn't in `DomLive`: a binding builds `layer` with the
4
+ * first gesture an app uses, so an app with none ships no input code.
5
+ *
6
+ * @example
7
+ * import * as DomInput from "@wardic/dom/DomInput"
8
+ *
9
+ * DomInput.keyOf("ArrowLeft") // "left"
10
+ * DomInput.buttonOf(2) // "secondary"
11
+ */
12
+ // `@wardic/dom/DomInput` (#132, ADR-0041): ADR-0019, ADR-0036 *Amendment (#189)*, ADR-0037. Not in
13
+ // `DomLive`: #511, ADR-0067 decision 14.
14
+ export {
15
+ InputDomLive as layer,
16
+ keyOf,
17
+ kindOf,
18
+ buttonOf,
19
+ toPointer,
20
+ type Where,
21
+ } from "./internal/input.ts"
22
+ // The Keyboard press's own module's (#709): `KeyboardPress.makeFocusable`, the same function.
23
+ export { makeFocusable } from "./internal/keyboard-press.ts"
@@ -0,0 +1,16 @@
1
+ /**
2
+ * The DOM's InterpolatorRegistry: core's value kinds with the DOM's colours and complex values, and the
3
+ * DOM's Key rules. `layer` is what `DomLive` provides; `all` is its kinds, in the order they're tried.
4
+ *
5
+ * @example
6
+ * import * as DomInterpolators from "@wardic/dom/DomInterpolators"
7
+ *
8
+ * const registry = yield* InterpolatorRegistry.make(DomInterpolators.all, DomKeyRules.all)
9
+ * const blend = yield* registry.resolve("#bf616a", "#a3be8c")
10
+ * blend(0.5) // the colour halfway
11
+ */
12
+ // `@wardic/dom/DomInterpolators` (#132, ADR-0041): ADR-0024, ADR-0035, ADR-0036.
13
+ export {
14
+ InterpolatorRegistryDomLive as layer,
15
+ interpolators as all,
16
+ } from "./internal/interpolators.ts"
@@ -0,0 +1,17 @@
1
+ /**
2
+ * The DOM's Key rules, for the keys it blends by name. `visibility` keeps `display` and `visibility` at
3
+ * their start until an animation's last frame when they're hiding the element, and `animatableNone`
4
+ * grows a shadow, a filter or a fill from nothing when one end is empty. `all` is both, in the order
5
+ * they're asked.
6
+ *
7
+ * @example
8
+ * import * as DomKeyRules from "@wardic/dom/DomKeyRules"
9
+ *
10
+ * const registry = yield* InterpolatorRegistry.make(DomInterpolators.all, [DomKeyRules.visibility])
11
+ */
12
+ // `@wardic/dom/DomKeyRules` (#132, ADR-0041): ADR-0015, ADR-0035.
13
+ export {
14
+ keyRules as all,
15
+ visibility,
16
+ animatableNone,
17
+ } from "./internal/key-rules.ts"
@@ -0,0 +1,16 @@
1
+ /**
2
+ * The DOM's Positional keys, the keys reduced motion lands at once rather than animating: the
3
+ * transforms, and the keys that place and size an element's box, `top`, `width` and the rest. `layer`
4
+ * is what `DomLive` provides.
5
+ *
6
+ * @example
7
+ * import * as DomPositionalKeys from "@wardic/dom/DomPositionalKeys"
8
+ *
9
+ * DomPositionalKeys.isPositional("width") // true: it lands at once
10
+ * DomPositionalKeys.isPositional("opacity") // false: it still fades
11
+ */
12
+ // `@wardic/dom/DomPositionalKeys` (#132, ADR-0041): ADR-0029, ADR-0036.
13
+ export {
14
+ PositionalKeysDomLive as layer,
15
+ isPositional,
16
+ } from "./internal/positional-keys.ts"
@@ -0,0 +1,15 @@
1
+ /**
2
+ * The DOM's Probe: boxes from `getBoundingClientRect`, sizes and visibility from the observers, the
3
+ * viewport, the reduced-motion preference from `matchMedia`, and whether the page is shown. `layer` needs
4
+ * the Environment's `AtomRegistry`, which it writes its live values through; `DomLive` provides both. A
5
+ * container's scroll is `DomScrollSource`'s.
6
+ *
7
+ * @example
8
+ * import * as DomProbe from "@wardic/dom/DomProbe"
9
+ *
10
+ * const probe = DomProbe.layer.pipe(Layer.provide(AtomRegistry.layer))
11
+ */
12
+ // `@wardic/dom/DomProbe` (#132, ADR-0041).
13
+ export {
14
+ ProbeDomLive as layer,
15
+ } from "./internal/probe.ts"
@@ -0,0 +1,44 @@
1
+ /**
2
+ * The DOM's Projection system: `layer` builds it, writing through the Environment's
3
+ * `FlushGate`, and `make` builds it over any sink, for a binding that wires it itself. Only a binding's
4
+ * layout feature imports it, so a page that never lays out ships none of it. Closing its Scope stops the
5
+ * engine: its run, its observers and listeners, and what it forked. Built after the gate, it ends before
6
+ * it.
7
+ *
8
+ * @example
9
+ * import * as DomProjectionSystem from "@wardic/dom/DomProjectionSystem"
10
+ *
11
+ * const layout = DomProjectionSystem.layer().pipe(Layer.provide(FlushGate.layer({ batch: (apply) => apply() })))
12
+ */
13
+ // The DOM's **Projection system** engine (#548, ADR-0041's `Dom` implementations), apart from
14
+ // `ProjectionSystem`'s key and types (ADR-0067, *Amendment (#548)*). Its members are plain functions.
15
+ import * as Context from "effect/Context"
16
+ import * as Effect from "effect/Effect"
17
+ import * as Layer from "effect/Layer"
18
+ import type * as Scope from "effect/Scope"
19
+ import * as FlushGate from "./FlushGate.ts"
20
+ import { PassEnds } from "./internal/pass-ends.ts"
21
+ import * as internal from "./internal/projection.ts"
22
+ import { makeRunner } from "./internal/runner.ts"
23
+ import { ProjectionSystem, type Options, type Services, type Shape, type Sink } from "./ProjectionSystem.ts"
24
+
25
+ /**
26
+ * Build the engine over `sink`, the context's Frame loop and Renderer, in the current Scope: what
27
+ * it forks runs in that Scope, and closing it ends the engine. It's the `ProjectionSystem` in the
28
+ * context it gives, beside what a Reorder controller over it needs.
29
+ */
30
+ // The context holds the internal `PassEnds` too (internal/pass-ends.ts, #618), the engine's own, so a
31
+ // ProjectionSystem a binding wraps or replaces in its context still has its Reorder controller hear
32
+ // each Measure pass. Its runner forks on Effect's default scheduler, whatever call built the Layer
33
+ // (`internal/runner.ts`).
34
+ export const make: (sink: Sink, options?: Options) => Effect.Effect<Context.Context<ProjectionSystem | PassEnds>, never, Services | Scope.Scope> =
35
+ /*#__PURE__*/ Effect.fnUntraced(function* (sink: Sink, options: Options = {}) {
36
+ // Typed without `dispose` and `onPassEnd`: the Scope ends it, and `PassEnds` hands the other out.
37
+ const system = internal.makeProjectionSystem(yield* makeRunner<Services>(), sink, options)
38
+ yield* Effect.addFinalizer(() => Effect.sync(system.dispose))
39
+ return Context.make(ProjectionSystem, system as Shape).pipe(Context.add(PassEnds, { onPassEnd: system.onPassEnd }))
40
+ })
41
+
42
+ /** The engine as a Layer, writing through the Environment's `FlushGate`: built by `make`, ended by the Layer's Scope. */
43
+ export const layer = (options: Options = {}): Layer.Layer<ProjectionSystem | PassEnds, never, FlushGate.FlushGate | Services> =>
44
+ Layer.effectContext(Effect.flatMap(Effect.service(FlushGate.FlushGate), (gate) => make(gate, options)))
@@ -0,0 +1,26 @@
1
+ /**
2
+ * The DOM's Renderer: `project` turns a Frame's values into a style patch, grouping the transform keys
3
+ * into one `transform` and drawing a bare number on a length in `px`, and its `commit` writes the patch
4
+ * onto an element. The rest is for a binding's layout projection: an element's own move, scale, rotation
5
+ * and opacity, read from its values, and its transform template.
6
+ *
7
+ * @example
8
+ * import * as DomRenderer from "@wardic/dom/DomRenderer"
9
+ *
10
+ * DomRenderer.project({ x: 100, opacity: 0.5 }) // { transform: "translateX(100px)", opacity: 0.5 }
11
+ */
12
+ // `@wardic/dom/DomRenderer` (#132, ADR-0041): ADR-0006, ADR-0034; the **Transform template** (#443);
13
+ // `LENGTH_KEYS` (#522).
14
+ export {
15
+ RendererDomLive as layer,
16
+ project,
17
+ ownScaleOf,
18
+ ownTranslateOf,
19
+ ownRotateOf,
20
+ ownOpacityOf,
21
+ TEMPLATE_KEY,
22
+ type TransformTemplate,
23
+ heldTransformOf,
24
+ LENGTH_KEYS,
25
+ type LengthKey,
26
+ } from "./internal/renderer.ts"
@@ -0,0 +1,14 @@
1
+ /**
2
+ * The DOM's scroll, core's `ScrollSource`: a container's scroll as an Atom, set inside the container's
3
+ * `scroll` event, the window's `resize`, and a resize of the container or its content, so a value derived
4
+ * from a scroll is written in the frame that shows it. `layer` needs the Environment's `AtomRegistry`,
5
+ * which it writes through. A binding builds it where something reads a scroll: the Solid binding's
6
+ * `scroll` Feature does, beside `DomLive`.
7
+ *
8
+ * @example
9
+ * import * as DomScrollSource from "@wardic/dom/DomScrollSource"
10
+ *
11
+ * const scroll = DomScrollSource.layer.pipe(Layer.provide(AtomRegistry.layer))
12
+ */
13
+ // `@wardic/dom/DomScrollSource` (#518, ADR-0041's names): the DOM Probe's `scroll` until then.
14
+ export { layer } from "./internal/scroll.ts"
@@ -0,0 +1,81 @@
1
+ /**
2
+ * The Flush gate: where a binding writes each element's animated values, drawn onto the elements once a
3
+ * frame. A binding registers each element with its target, writes values as its animations step, and the
4
+ * gate draws them together, at the end of the frame's animation tick, through the Environment's renderer;
5
+ * a write made outside a tick, as a drag's move is, asks for a frame of its own. A server render gets
6
+ * `inert`, which does nothing.
7
+ *
8
+ * @example
9
+ * import * as FlushGate from "@wardic/dom/FlushGate"
10
+ *
11
+ * const gate = yield* FlushGate.FlushGate
12
+ * const unregister = gate.register("card", { target: card })
13
+ * gate.write("card", { opacity: 0.5 }) // drawn at the next frame
14
+ */
15
+ // The **Flush gate** (ADR-0006, ADR-0031, ADR-0033, ADR-0034). `@wardic/dom/FlushGate` (#132, ADR-0041). A
16
+ // service built by a Layer (`layer`) and ended by that Layer's Scope: closing it takes the gate's hook off
17
+ // the Frame loop, cancels a pending frame and clears what it held. Its members are plain functions, called
18
+ // per element and per frame. `make` is the scoped constructor, for a binding that wires it itself. `inert`
19
+ // (ADR-0021, decision 9): a value for a binding whose server builds no runtime, or `layerInert` for one
20
+ // whose server runs an Effect program.
21
+ import * as Context from "effect/Context"
22
+ import * as Effect from "effect/Effect"
23
+ import * as Layer from "effect/Layer"
24
+ import * as Atom from "effect/reactivity/Atom"
25
+ import type * as Scope from "effect/Scope"
26
+ import * as internal from "./internal/gate.ts"
27
+ import { makeRunner } from "./internal/runner.ts"
28
+
29
+ /** The gate: what a binding registers its elements with and writes their values into. */
30
+ export type Shape = Omit<internal.FlushGate, "dispose">
31
+
32
+ /** An element's commit target and hooks, given to `register`. */
33
+ export type Sink = internal.FlushSink
34
+
35
+ /** What a binding hands its gate: the `batch` a frame's Starting-style switches run in. */
36
+ export type Options = internal.FlushGateOptions
37
+
38
+ /** The services a gate needs from its Environment. */
39
+ export type Services = internal.FlushGateServices
40
+
41
+ /** The Environment's Flush gate. */
42
+ export class FlushGate extends Context.Service<FlushGate, Shape>()("@wardic/dom/FlushGate") {}
43
+
44
+ /**
45
+ * Build a gate over the context's Renderer, Frame loop and Refresh frame source, in the current
46
+ * Scope: what it forks runs in that Scope, and closing it ends the gate.
47
+ */
48
+ export const make: (options: Options) => Effect.Effect<Shape, never, Services | Scope.Scope> = Effect.fnUntraced(
49
+ function* (options: Options) {
50
+ // The gate itself, typed without `dispose`: the Scope ends it. Its runner forks on Effect's
51
+ // default scheduler, whatever call built the Layer (`internal/runner.ts`).
52
+ const gate = internal.makeFlushGate(yield* makeRunner<Services>(), options)
53
+ yield* Effect.addFinalizer(() => Effect.sync(gate.dispose))
54
+ return gate
55
+ })
56
+
57
+ /** The gate as a Layer: built by `make`, ended by the Layer's Scope. */
58
+ export const layer = (options: Options): Layer.Layer<FlushGate, never, Services> => Layer.effect(FlushGate)(make(options))
59
+
60
+ const noop = (): void => {}
61
+
62
+ /** What `inert`'s `valueOf` gives: an Atom that stays `undefined`, since nothing is committed on a server. */
63
+ const NO_VALUE: Atom.Atom<unknown> = Atom.make<unknown>(undefined)
64
+
65
+ /**
66
+ * The gate a server render gets: it flushes nothing, so `register` returns an unregister that does
67
+ * nothing, and the rest do nothing, `afterFlush` included, since no flush comes. Code that takes the gate
68
+ * at setup and uses it after mount keeps working on a server.
69
+ */
70
+ // ADR-0021, decision 9.
71
+ export const inert: Shape = Object.freeze({
72
+ register: () => noop,
73
+ write: noop,
74
+ flushPass: noop,
75
+ release: noop,
76
+ valueOf: () => NO_VALUE,
77
+ afterFlush: noop,
78
+ })
79
+
80
+ /** `inert` as a Layer, for a binding whose server render runs an Effect program. */
81
+ export const layerInert: Layer.Layer<FlushGate> = Layer.succeed(FlushGate, inert)
@@ -0,0 +1,16 @@
1
+ /**
2
+ * A Keyboard press's focusability: `makeFocusable` gives an HTML element that doesn't take the
3
+ * keyboard's focus of itself `tabindex="0"`, so Enter and Space can press it, as Motion's press does. A
4
+ * control, a link with its `href`, an editable region, an element given a `tabindex` and an SVG element
5
+ * are left as they are. `DomInput.makeFocusable` is the same function, here apart from the DOM's input,
6
+ * so a binding calls it as each pressable element mounts without loading the input.
7
+ *
8
+ * @example
9
+ * import * as KeyboardPress from "@wardic/dom/KeyboardPress"
10
+ *
11
+ * const tile = document.createElement("div")
12
+ * KeyboardPress.makeFocusable(tile)
13
+ * // tile.getAttribute("tabindex") === "0"
14
+ */
15
+ // `@wardic/dom/KeyboardPress` (#709, Q2; ADR-0056, *Amendment (#709)*): ADR-0041's module per concern.
16
+ export { makeFocusable } from "./internal/keyboard-press.ts"
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Measured pairs: a key that places or sizes the box, whose two ends are lengths of different types,
3
+ * `"auto"` against px, `"50%"` against a number, a `calc()`, can't blend as written. Both ends are
4
+ * measured in px at the end of the task that asks, as Motion's are, so the animation runs between them
5
+ * and lands on its target as given.
6
+ *
7
+ * @example
8
+ * import * as MeasuredPair from "@wardic/dom/MeasuredPair"
9
+ *
10
+ * MeasuredPair.needs("width", "auto", 200) // true
11
+ * MeasuredPair.needs("opacity", 0, 1) // false
12
+ */
13
+ // **Measured pairs** (#430, CONTEXT.md, Motion's `DOMKeyframesResolver`). `@wardic/dom/MeasuredPair`: for
14
+ // binding authors.
15
+ export { measure, measured, type Measured, needs, type Requested } from "./internal/measured-pairs.ts"
@@ -0,0 +1,19 @@
1
+ /**
2
+ * An element's own values: what its style or its computed style says for a key, read once, the value an
3
+ * animation starts from, and returns to when nothing else sets it. `valueLike` reads a raw value in the
4
+ * shape of the key's target.
5
+ *
6
+ * @example
7
+ * import * as OwnValues from "@wardic/dom/OwnValues"
8
+ *
9
+ * const own = OwnValues.of(element)
10
+ * own("opacity") // Some("1"), from its computed style
11
+ * OwnValues.valueLike("10px", 0) // Some(10)
12
+ */
13
+ // `@wardic/dom/OwnValues` (#132, ADR-0041): its Base values (ADR-0022).
14
+ export {
15
+ ownValues as of,
16
+ styleValueOf,
17
+ valueLike,
18
+ type OwnValue,
19
+ } from "./internal/own-values.ts"
@@ -0,0 +1,51 @@
1
+ /**
2
+ * The Projection system: what runs the DOM's layout animations, one per Environment a binding builds. A binding registers
3
+ * each layout element with it, and when a layout changes it measures their boxes, draws each where it was
4
+ * with a transform, and animates it to where it is now; elements that share a `layoutId` fly one into the
5
+ * other. This module is its key and its types, which every element's code reads: the engine itself is
6
+ * `DomProjectionSystem`'s, so a page that never lays out ships none of it. `toJSON()` gives its tree as
7
+ * plain data, for a diagnostic view. A server render builds none.
8
+ *
9
+ * @example
10
+ * import * as ProjectionSystem from "@wardic/dom/ProjectionSystem"
11
+ *
12
+ * const system = yield* ProjectionSystem.ProjectionSystem
13
+ * const node = system.register({ id: "card", element: card, transition: () => Option.none() })
14
+ * system.animateLayout(() => expand(card)) // measured before and after, and animated between
15
+ */
16
+ // The **Projection system**, the DOM's engine for the **Projection** (ADR-0009, ADR-0010, ADR-0018): it
17
+ // holds every Projection node, runs the Measure pass and the per-frame projection pass, and owns `layoutId`
18
+ // matching. `@wardic/dom/ProjectionSystem` (#132, ADR-0041). The key apart from the engine: #548, ADR-0067
19
+ // *Amendment (#548)*. An Effect `Inspectable` (#384): `console.log(system)` shows the tree, as `Tree`,
20
+ // each node with its parent, its `layoutId` twin's part and what it's doing; the layout lab draws it. A
21
+ // server render builds none (ADR-0021).
22
+ import * as Context from "effect/Context"
23
+ import type * as internal from "./internal/projection.ts"
24
+
25
+ export {
26
+ type RegisterNodeOptions,
27
+ type ProjectionNodeHandle as NodeHandle,
28
+ type DragProjectionHandle as DragHandle,
29
+ type AnimateLayoutOptions,
30
+ type Tree,
31
+ type TreeNode,
32
+ } from "./internal/projection.ts"
33
+ export { DEFAULT_DRAG_TRANSITION, DEFAULT_LAYOUT_TRANSITION, type DragTransition, type LayoutTransition } from "./internal/projection-defaults.ts"
34
+ export type { ScaleCorrectorEntry as ScaleCorrector, CorrectorInfo } from "./internal/scale-correction.ts"
35
+ export { dragBoundsWithin, measureLayoutBox } from "./internal/measure.ts"
36
+
37
+ /** The engine: what a binding registers its layout elements with. */
38
+ export type Shape = Omit<internal.ProjectionSystem, "dispose" | "onPassEnd">
39
+
40
+ /** What the engine writes each node's projection through: a `FlushGate`'s `write` and `flushPass`. */
41
+ export type Sink = internal.ProjectionSink
42
+
43
+ /** What a binding hands its engine: whether reduced motion applies now, and the app's scale correctors. */
44
+ // ADR-0029; #443.
45
+ export type Options = internal.ProjectionSystemOptions
46
+
47
+ /** The services the engine needs from its Environment. */
48
+ export type Services = internal.ProjectionServices
49
+
50
+ /** The Environment's Projection system. */
51
+ export class ProjectionSystem extends /*#__PURE__*/ Context.Service<ProjectionSystem, Shape>()("@wardic/dom/ProjectionSystem") {}
@@ -0,0 +1,122 @@
1
+ /**
2
+ * A Reorder group on the DOM: the group, its items' drags, its keyboard and its announcements, one
3
+ * controller a group. `make` builds one over the context's Projection system and `Announcer`, for items
4
+ * that are layout nodes; `makePlaced` one over the `Announcer` alone, for a Batch Reorder group's items,
5
+ * placed from their index and never measured. A binding attaches its group element, gets a driver for
6
+ * each item, and closing the Scope ends the controller. A server render gets `inert`.
7
+ *
8
+ * @example
9
+ * import * as ReorderController from "@wardic/dom/ReorderController"
10
+ *
11
+ * const controller = yield* ReorderController.make({ values: () => items, onReorder: (next) => (items = next) })
12
+ * controller.attach(list)
13
+ * const driver = controller.item(item, () => Option.some(element))
14
+ *
15
+ * // Items placed from their index: placed() once they're laid out in a new order.
16
+ * const placedGroup = yield* ReorderController.makePlaced({ values: () => items, onReorder: (next) => (items = next) })
17
+ * placedGroup.placed()
18
+ */
19
+ // A **Reorder group**'s controller (ADR-0019 *Amendment (Reorder)*, ADR-0037); a server render's `inert`
20
+ // (ADR-0021). `@wardic/dom/ReorderController` (#132, ADR-0041). A scoped constructor, one per group (#132's
21
+ // PR 3): `make` logs its `wardic.reorder:` events through the context's Logger, and ends with its Scope,
22
+ // which stops its listening to Measure passes, resets its Auto-scroll and clears a pending announcement.
23
+ // `makePlaced` (#712, ADR-0072) is the same controller wired to its binding's placing: no projection system,
24
+ // and `placed` where `make`'s hears a Measure pass's end.
25
+ // Its items' drivers stay plain, each with its own `dispose`, since one is made per element.
26
+ import * as Announcer from "@wardic/core/Announcer"
27
+ import * as Effect from "effect/Effect"
28
+ import { constVoid } from "effect/Function"
29
+ import type * as Scope from "effect/Scope"
30
+ import { PassEnds } from "./internal/pass-ends.ts"
31
+ import * as internal from "./internal/reorder.ts"
32
+ import { makeRunner } from "./internal/runner.ts"
33
+ import * as ProjectionSystem from "./ProjectionSystem.ts"
34
+
35
+ export {
36
+ type ReorderEnd as End,
37
+ type ReorderHoldEnd as HoldEnd,
38
+ type ReorderHoldHow as HoldHow,
39
+ type ReorderHoldStart as HoldStart,
40
+ type ReorderItemDriver as ItemDriver,
41
+ type ReorderItemHandle as ItemHandle,
42
+ DEFAULT_REORDER_INSTRUCTIONS as DEFAULT_INSTRUCTIONS,
43
+ REORDER_GROUP_STYLE as GROUP_STYLE,
44
+ } from "./internal/reorder.ts"
45
+
46
+ /** A **Reorder group** on the DOM: what a binding attaches its group element and items to. */
47
+ export type ReorderController<V> = Omit<internal.ReorderController<V>, "dispose">
48
+
49
+ /** What a binding hands its group: the app's values, its axis, its keyboard and its announcements. */
50
+ export type Options<V> = internal.ReorderControllerOptions<V>
51
+
52
+ /**
53
+ * The services a controller takes from its context: the projection system its items are nodes of,
54
+ * with what tells it each Measure pass's end (`DomProjectionSystem`'s Layer provides both), and the
55
+ * Environment's `Announcer`.
56
+ */
57
+ export type Services = ProjectionSystem.ProjectionSystem | PassEnds | Announcer.Announcer
58
+
59
+ /**
60
+ * Build a group's controller over the context's projection system, announcing through its
61
+ * `Announcer`, in the current Scope: closing it ends the controller.
62
+ */
63
+ export const make: <V>(options: Options<V>) => Effect.Effect<ReorderController<V>, never, Services | Scope.Scope> = Effect.fnUntraced(
64
+ function* <V>(options: Options<V>) {
65
+ const projection = yield* ProjectionSystem.ProjectionSystem
66
+ const passEnds = yield* PassEnds
67
+ const announcer = yield* Announcer.Announcer
68
+ const controller = internal.makeReorderController(
69
+ { runtime: yield* makeRunner<never>(), layOut: () => projection.notify(), announce: announcer.announce, onLaidOut: passEnds.onPassEnd },
70
+ options,
71
+ )
72
+ yield* Effect.addFinalizer(() => Effect.sync(controller.dispose))
73
+ return controller
74
+ })
75
+
76
+ /**
77
+ * A **Batch Reorder group**'s controller, whose items are placed from their index, never measured: `placed`
78
+ * tells it the binding has laid its items out in a new order, as a Measure pass's end tells `make`'s.
79
+ */
80
+ // #712, ADR-0072 decision 6.
81
+ export interface Placed<V> extends ReorderController<V> {
82
+ /** The binding has placed its items in the new order: their layout's turn, a stepped item revealed. */
83
+ readonly placed: () => void
84
+ }
85
+
86
+ /**
87
+ * Build a group's controller for items placed rather than measured, a Batch Reorder group's, announcing
88
+ * through the context's `Announcer`, in the current Scope: closing it ends the controller. It needs no
89
+ * projection system: each item registers a handle whose box is its place, raising its box's version as
90
+ * it's placed, and the binding calls `placed` once it has placed a new order.
91
+ */
92
+ // #712, ADR-0072 decision 6: the same controller, wired to its binding's placing.
93
+ export const makePlaced: <V>(options: Options<V>) => Effect.Effect<Placed<V>, never, Announcer.Announcer | Scope.Scope> = Effect.fnUntraced(
94
+ function* <V>(options: Options<V>) {
95
+ const announcer = yield* Announcer.Announcer
96
+ // What hears the binding's placing: the controller's own, once, until it's disposed.
97
+ let laidOut: () => void = constVoid
98
+ const controller = internal.makeReorderController(
99
+ {
100
+ runtime: yield* makeRunner<never>(),
101
+ // The binding places its items on a change of `values` itself.
102
+ layOut: constVoid,
103
+ announce: announcer.announce,
104
+ onLaidOut: (listener) => {
105
+ laidOut = listener
106
+ return () => {
107
+ laidOut = constVoid
108
+ }
109
+ },
110
+ },
111
+ options,
112
+ )
113
+ yield* Effect.addFinalizer(() => Effect.sync(controller.dispose))
114
+ return { ...controller, placed: () => laidOut() }
115
+ })
116
+
117
+ /**
118
+ * The controller a server render gets: its group has no values, so every operation on it does nothing,
119
+ * its axis is `"y"`, and an item's driver does nothing too.
120
+ */
121
+ // ADR-0021.
122
+ export const inert: ReorderController<never> = internal.INERT_REORDER_CONTROLLER
package/src/Report.ts ADDED
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Reporting a failure where a fiber stops: logged at Error and handed to the Environment's
3
+ * `ErrorReporter`s, so an app's error tracking sees it. An interruption is neither: it's how a run is
4
+ * removed.
5
+ *
6
+ * @example
7
+ * import * as Report from "@wardic/dom/Report"
8
+ *
9
+ * yield* Report.failure("wardic: an animation failed", cause)
10
+ */
11
+ // `@wardic/dom/Report` (#132, ADR-0041): ADR-0030, decision 4.
12
+ export {
13
+ reportFailure as failure,
14
+ debugKept,
15
+ debugOf,
16
+ type DebugLog,
17
+ } from "./internal/report.ts"
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Scroll offsets, the DOM's: Motion's syntax for where a target's progress through its scroll container
3
+ * runs, from 0 to 1, which the DOM's `ScrollSource` resolves. Core takes an offset as its Environment's
4
+ * own and passes it through, so its syntax, its names and its units are the DOM's.
5
+ *
6
+ * - **An edge** is a name (`start`, `center`, `end`), a fraction of a length (`0.5`), or a CSS length:
7
+ * `"100px"` a distance, `"50%"` a fraction, `"10vw"` or `"10vh"` a share of the viewport.
8
+ * - **A stop** is a pair of edges, `[target, container]`: the scroll position where the target's edge
9
+ * meets the container's. A string holds both (`"start end"`); one edge alone is both for a name or a
10
+ * number (`"end"`, `0.5`), else the target's against the container's start (`"100px"`).
11
+ * - **An offset** is two stops or more: progress runs from 0 at the first to 1 at the last, evenly
12
+ * between them, and holds past them.
13
+ *
14
+ * @example
15
+ * import * as ScrollOffset from "@wardic/dom/ScrollOffset"
16
+ *
17
+ * // From the target's top meeting the container's bottom, to its bottom meeting the container's top:
18
+ * const across: ScrollOffset.ScrollOffset = ["start end", "end start"]
19
+ */
20
+ // #234, ADR-0043 *Amendment (#233, #234)*; resolved in `internal/scroll.ts`. `@wardic/dom/ScrollOffset`
21
+ // (ADR-0041): the type a binding gives its `scroll` helper's `offset`.
22
+
23
+ /** One edge of a stop: a name, a fraction, or a CSS length (see the module's doc). */
24
+ export type Edge = string | number
25
+
26
+ /** One stop: `[target edge, container edge]`, a string of both, or one edge. */
27
+ export type Stop = Edge | readonly [Edge, Edge]
28
+
29
+ /** Where a target's progress runs: two stops or more. */
30
+ export type ScrollOffset = ReadonlyArray<Stop>
31
+
32
+ /** Motion's presets: while the target comes into the container. */
33
+ export const Enter: ScrollOffset = [
34
+ [0, 1],
35
+ [1, 1],
36
+ ]
37
+
38
+ /** While the target leaves the container. */
39
+ export const Exit: ScrollOffset = [
40
+ [0, 0],
41
+ [1, 0],
42
+ ]
43
+
44
+ /** While any of the target is in the container. */
45
+ export const Any: ScrollOffset = [
46
+ [1, 0],
47
+ [0, 1],
48
+ ]
49
+
50
+ /** While all of the target is in the container: the offset with a target and none given. */
51
+ export const All: ScrollOffset = [
52
+ [0, 0],
53
+ [1, 1],
54
+ ]
package/src/Style.ts ADDED
@@ -0,0 +1,37 @@
1
+ /**
2
+ * An element's style as a binding builds it: its starting style, what it's drawn with before any
3
+ * animation runs, from its `initial` (or its `animate`, with `initial: false`); how an app's own style and
4
+ * Wardic's are layered (`over`, `without`); and a drag element's default style. A server render draws the
5
+ * starting style, so an element is drawn where it starts before any code runs.
6
+ *
7
+ * @example
8
+ * import * as Style from "@wardic/dom/Style"
9
+ *
10
+ * const start = Style.resolveInitial({ initial: { opacity: 0, y: 8 }, animate: { opacity: 1, y: 0 } })
11
+ * Style.starting(undefined, start) // { style: { transform: "translateY(8px)", opacity: 0 }, attrs: {} }
12
+ */
13
+ // `@wardic/dom/Style` (#132, ADR-0041): the **Starting style**, the merges of an app's style with
14
+ // Wardic's, and a drag element's defaults (ADR-0019, ADR-0021, ADR-0034).
15
+ export {
16
+ startingStyle as starting,
17
+ resolveInitial,
18
+ type InitialConfig,
19
+ keyframesOf,
20
+ splitValues,
21
+ type SplitValues,
22
+ type StopAt,
23
+ type Stops,
24
+ toValues,
25
+ valuesAt,
26
+ type StyleInput as Input,
27
+ type StyleRecord as Style,
28
+ over,
29
+ without,
30
+ heldTouches,
31
+ } from "./internal/starting-style.ts"
32
+ export {
33
+ dragDefaultStyle as dragDefaults,
34
+ type DragDefaultStyle as DragDefaults,
35
+ DRAG_DEFAULT_ATTRIBUTES,
36
+ reorderTouchAction,
37
+ } from "./internal/drag-defaults.ts"
package/src/Svg.ts ADDED
@@ -0,0 +1,21 @@
1
+ /**
2
+ * SVG: which elements are SVG's, and a style patch split into the CSS an SVG element takes and the
3
+ * attributes it takes instead. An `<svg>` root is styled as HTML is; an element inside it takes most keys
4
+ * as attributes, and a transform about its own centre, as an HTML element's is.
5
+ *
6
+ * @example
7
+ * import * as Svg from "@wardic/dom/Svg"
8
+ *
9
+ * Svg.splitPatchForTag("circle", { r: 10, opacity: 0.5, transform: "scale(2)" })
10
+ * // style: transform, transform-box and transform-origin; attrs: { r: "10", opacity: "0.5" }
11
+ */
12
+ // `@wardic/dom/Svg` (#132, ADR-0041): ADR-0014.
13
+ export {
14
+ isSvgRoot as isRoot,
15
+ isSvgInner as isInner,
16
+ isSvgInnerTag as isInnerTag,
17
+ setSvgAttrs as setAttrs,
18
+ splitPatch,
19
+ splitPatchForTag,
20
+ type SplitPatch,
21
+ } from "./internal/svg.ts"
@@ -0,0 +1,17 @@
1
+ /**
2
+ * CSS variables in animated values: a value that's wholly a `var()` is resolved against an element, so
3
+ * `var(--accent)` animates from or to the colour it stands for. `values` is the Key rule a binding adds
4
+ * for an element's own animations.
5
+ *
6
+ * @example
7
+ * import * as Variables from "@wardic/dom/Variables"
8
+ *
9
+ * Variables.isValue("var(--gap)") // true
10
+ * Variables.resolve(element, "var(--gap)") // what `--gap` computes to on `element`
11
+ */
12
+ // `@wardic/dom/Variables` (#132, ADR-0041): #55, ADR-0035.
13
+ export {
14
+ isVariableValue as isValue,
15
+ resolveVariable as resolve,
16
+ variableValues as values,
17
+ } from "./internal/variables.ts"