@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,257 @@
1
+ import * as Bool from "effect/Boolean";
2
+ import * as Option from "effect/Option";
3
+ import * as Predicate from "effect/Predicate";
4
+ /**
5
+ * Keys that remain CSS `style` on an svg-inner element; everything else routes
6
+ * to an attribute. `transform` is applied as a CSS transform (with `transform-box`
7
+ * below); the motion-path props are CSS-only on SVG too (Motion parity).
8
+ */
9
+ const SVG_STYLE_KEYS = new Set([
10
+ "transform",
11
+ "transformOrigin",
12
+ "transform-origin",
13
+ "transformBox",
14
+ "transform-box",
15
+ "offsetDistance",
16
+ "offsetPath",
17
+ "offsetRotate",
18
+ "offsetAnchor",
19
+ ]);
20
+ /**
21
+ * SVG attribute names always written camelCase (never dash-cased) — Motion's
22
+ * `camelCaseAttributes`. Everything else is dash-cased (`strokeWidth` →
23
+ * `stroke-width`).
24
+ */
25
+ const CAMEL_CASE_ATTRS = new Set([
26
+ "baseFrequency",
27
+ "diffuseConstant",
28
+ "kernelMatrix",
29
+ "kernelUnitLength",
30
+ "keySplines",
31
+ "keyTimes",
32
+ "limitingConeAngle",
33
+ "markerHeight",
34
+ "markerWidth",
35
+ "numOctaves",
36
+ "targetX",
37
+ "targetY",
38
+ "surfaceScale",
39
+ "specularConstant",
40
+ "specularExponent",
41
+ "stdDeviation",
42
+ "tableValues",
43
+ "viewBox",
44
+ "gradientTransform",
45
+ "pathLength",
46
+ "startOffset",
47
+ "textLength",
48
+ "lengthAdjust",
49
+ ]);
50
+ /**
51
+ * Escape hatches: `x`/`y` are transform shorthands in Wardic (translateX/Y), so
52
+ * the SVG geometry ATTRIBUTE form is the explicit `attr*` key (Motion's
53
+ * `attrX`/`attrY`/`attrScale`). Maps to the bare attribute name.
54
+ */
55
+ const ATTR_ALIASES = { attrX: "x", attrY: "y", attrScale: "scale" };
56
+ /**
57
+ * Each key's dash-cased name, computed once (ADR-0034): the commit dash-cases every key of
58
+ * every patch, each frame. Keys come from animation configs, so the set stays small.
59
+ */
60
+ // Module state (#460, Q7): a cache keyed by what it caches: a bounded set of names.
61
+ const DASHED = new Map();
62
+ /**
63
+ * Whether `key` is a CSS custom property (`--brandColor`): it keeps its name, which is
64
+ * case-sensitive, and is always a style property, on SVG too (ADR-0014, *Amendment (#151)*;
65
+ * Motion's `isCSSVariableName`).
66
+ */
67
+ const isCustomProperty = (key) => key.startsWith("--");
68
+ /**
69
+ * camelCase → dash-case for a CSS/attribute name (`transformBox` → `transform-box`); a
70
+ * custom property keeps its name (`--brandColor`).
71
+ */
72
+ export const dashCase = (key) => {
73
+ const cached = DASHED.get(key);
74
+ if (Predicate.isNotUndefined(cached))
75
+ return cached;
76
+ const dashed = Bool.match(isCustomProperty(key), {
77
+ onTrue: () => key,
78
+ onFalse: () => key.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`),
79
+ });
80
+ DASHED.set(key, dashed);
81
+ return dashed;
82
+ };
83
+ /** The attribute name for an engine key: dash-cased unless it's a known camelCase attr. */
84
+ const attrName = (key) => {
85
+ if (CAMEL_CASE_ATTRS.has(key))
86
+ return key;
87
+ return dashCase(key);
88
+ };
89
+ /** Whether a key collapses into the stroke dash: `pathLength`, `pathSpacing` or `pathOffset`. */
90
+ export const isPathKey = (key) => key === "pathLength" || key === "pathSpacing" || key === "pathOffset";
91
+ /**
92
+ * The attribute an svg-inner element's `key` is written as (the routing below), or
93
+ * `None` for a key that stays style ({@link SVG_STYLE_KEYS}, a custom property) or collapses into the
94
+ * stroke dash (`pathLength` / `pathSpacing` / `pathOffset`). Internal: the Own-value read
95
+ * reads the attribute a key is written as (ADR-0022).
96
+ */
97
+ export const svgAttrNameOf = (key) => Bool.match(isPathKey(key) || isCustomProperty(key), {
98
+ onTrue: () => Option.none(),
99
+ onFalse: () => Option.orElse(Option.fromUndefinedOr(ATTR_ALIASES[key]), () => Option.map(Option.liftPredicate(key, (k) => Bool.not(SVG_STYLE_KEYS.has(k))), attrName)),
100
+ });
101
+ /** Whether `el` is an `<svg>` root, which is styled as HTML is: it has a CSS box. */
102
+ export const isSvgRoot = (el) => {
103
+ // No SVG classes on a server. Per frame (a flush's split): plain checks.
104
+ const SvgRoot = globalThis.SVGSVGElement;
105
+ return Predicate.isNotUndefined(SvgRoot) && el instanceof SvgRoot;
106
+ };
107
+ /** Whether `el` is an SVG element inside an `<svg>`: any SVG element but the root. */
108
+ export const isSvgInner = (el) => {
109
+ const Svg = globalThis.SVGElement;
110
+ return Predicate.isNotUndefined(Svg) && el instanceof Svg && !isSvgRoot(el);
111
+ };
112
+ /** An HTML element's attributes from a patch: none, one shared frozen record (#618: one a split). */
113
+ const NO_ATTRS = Object.freeze({});
114
+ /**
115
+ * A style patch split for `el`: an HTML element's, or an `<svg>` root's, is all style. An SVG element
116
+ * inside one takes every key as an attribute but the keys CSS styles and a custom property; `attrX`,
117
+ * `attrY` and `attrScale` as its `x`, `y` and `scale` attributes; a `transform` with `transform-box:
118
+ * fill-box` and `transform-origin: 50% 50%`, unless the values set them, so it turns about its own centre
119
+ * as an HTML element does; and `pathLength`, `pathSpacing` and `pathOffset` as a normalised
120
+ * `stroke-dasharray` and `stroke-dashoffset`, with `pathLength="1"`.
121
+ */
122
+ // The CSS keys: `SVG_STYLE_KEYS`.
123
+ export const splitPatch = (el, patch) => {
124
+ if (isSvgInner(el))
125
+ return routeSvgInner(patch);
126
+ return { style: patch, attrs: NO_ATTRS };
127
+ };
128
+ /**
129
+ * SVG's element names that HTML doesn't share, lowercase (Motion's list,
130
+ * framer-motion/src/render/svg/lowercase-elements.ts @ 16c6122, without the `svg` root).
131
+ * A name with a capital letter (`clipPath`, `linearGradient`, `feGaussianBlur` …) is SVG
132
+ * too, as Motion's `isSVGComponent` decides; `a`, `script`, `style` and `title` count as
133
+ * HTML, since a server has no namespace to tell them apart.
134
+ */
135
+ const SVG_INNER_TAGS = new Set([
136
+ "animate",
137
+ "circle",
138
+ "defs",
139
+ "desc",
140
+ "ellipse",
141
+ "g",
142
+ "image",
143
+ "line",
144
+ "filter",
145
+ "marker",
146
+ "mask",
147
+ "metadata",
148
+ "path",
149
+ "pattern",
150
+ "polygon",
151
+ "polyline",
152
+ "rect",
153
+ "stop",
154
+ "switch",
155
+ "symbol",
156
+ "text",
157
+ "tspan",
158
+ "use",
159
+ "view",
160
+ ]);
161
+ /** Whether `tag` names an SVG element inside an `<svg>`, by its name alone. */
162
+ export const isSvgInnerTag = (tag) => !tag.includes("-") && (SVG_INNER_TAGS.has(tag) || /[A-Z]/.test(tag));
163
+ /** `splitPatch` by tag name, for where there's no element yet: a server render, a starting style. `undefined` is an HTML element. */
164
+ // ADR-0021.
165
+ export const splitPatchForTag = (tag, patch) => Bool.match(Predicate.isNotUndefined(tag) && isSvgInnerTag(tag), {
166
+ onTrue: () => routeSvgInner(patch),
167
+ onFalse: () => ({ style: patch, attrs: NO_ATTRS }),
168
+ });
169
+ /** The svg-inner routing {@link splitPatch} and {@link splitPatchForTag} share. */
170
+ const routeSvgInner = (patch) => {
171
+ const style = {};
172
+ const attrs = {};
173
+ let hasTransform = false;
174
+ let pathLength;
175
+ let pathSpacing;
176
+ let pathOffset;
177
+ for (const key in patch) {
178
+ const value = patch[key];
179
+ if (Predicate.isUndefined(value))
180
+ continue;
181
+ if (key === "pathLength") {
182
+ pathLength = value;
183
+ continue;
184
+ }
185
+ if (key === "pathSpacing") {
186
+ pathSpacing = value;
187
+ continue;
188
+ }
189
+ if (key === "pathOffset") {
190
+ pathOffset = value;
191
+ continue;
192
+ }
193
+ const alias = ATTR_ALIASES[key];
194
+ if (Predicate.isNotUndefined(alias)) {
195
+ attrs[alias] = String(value);
196
+ continue;
197
+ }
198
+ if (SVG_STYLE_KEYS.has(key)) {
199
+ style[key] = value;
200
+ if (key === "transform")
201
+ hasTransform = true;
202
+ continue;
203
+ }
204
+ // A custom property is a style property (ADR-0014, *Amendment (#151)*).
205
+ if (isCustomProperty(key)) {
206
+ style[key] = value;
207
+ continue;
208
+ }
209
+ attrs[attrName(key)] = String(value);
210
+ }
211
+ // SVG's transform-origin defaults to the document origin (0 0), not the element
212
+ // centre — so a CSS transform on SVG reads differently from HTML. `fill-box` +
213
+ // a centred origin restore HTML-like semantics (Motion). User-set wins.
214
+ if (hasTransform) {
215
+ if (Predicate.isUndefined(style["transformBox"]) && Predicate.isUndefined(style["transform-box"])) {
216
+ style["transform-box"] = "fill-box";
217
+ }
218
+ if (Predicate.isUndefined(style["transformOrigin"]) && Predicate.isUndefined(style["transform-origin"])) {
219
+ style["transform-origin"] = "50% 50%";
220
+ }
221
+ }
222
+ // pathLength → normalised stroke dash (Motion's buildSVGPath). Unitless: Safari
223
+ // mis-scales px dash values when the page is zoomed.
224
+ if (Predicate.isNotUndefined(pathLength)) {
225
+ attrs["pathLength"] = "1";
226
+ attrs["stroke-dasharray"] = `${pathLength} ${spacingOf(pathSpacing)}`;
227
+ attrs["stroke-dashoffset"] = String(dashOffsetOf(offsetOf(pathOffset)));
228
+ }
229
+ return { style, attrs };
230
+ };
231
+ // The stroke dash's parts, per frame: early returns.
232
+ /** `pathSpacing`, 1 when none is given. */
233
+ const spacingOf = (spacing) => {
234
+ if (Predicate.isNullish(spacing))
235
+ return 1;
236
+ return spacing;
237
+ };
238
+ /** `pathOffset` as a number, 0 when none is given. */
239
+ const offsetOf = (offset) => {
240
+ if (Predicate.isNumber(offset))
241
+ return offset;
242
+ if (Predicate.isNullish(offset))
243
+ return 0;
244
+ return Number(offset);
245
+ };
246
+ /** The dash offset an offset draws: its negation, 0 for one that isn't finite. */
247
+ const dashOffsetOf = (offset) => {
248
+ if (Number.isFinite(offset))
249
+ return -offset;
250
+ return 0;
251
+ };
252
+ /** Writes each attribute onto `el` with `setAttribute`; nothing for an empty map. */
253
+ export const setSvgAttrs = (el, attrs) => {
254
+ for (const name in attrs)
255
+ el.setAttribute(name, attrs[name]);
256
+ };
257
+ //# sourceMappingURL=svg.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"svg.js","sourceRoot":"","sources":["../../src/internal/svg.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAA;AACtC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,SAAS,MAAM,kBAAkB,CAAA;AAE7C;;;;GAIG;AACH,MAAM,cAAc,GAAwB,IAAI,GAAG,CAAC;IAClD,WAAW;IACX,iBAAiB;IACjB,kBAAkB;IAClB,cAAc;IACd,eAAe;IACf,gBAAgB;IAChB,YAAY;IACZ,cAAc;IACd,cAAc;CACf,CAAC,CAAA;AAEF;;;;GAIG;AACH,MAAM,gBAAgB,GAAwB,IAAI,GAAG,CAAC;IACpD,eAAe;IACf,iBAAiB;IACjB,cAAc;IACd,kBAAkB;IAClB,YAAY;IACZ,UAAU;IACV,mBAAmB;IACnB,cAAc;IACd,aAAa;IACb,YAAY;IACZ,SAAS;IACT,SAAS;IACT,cAAc;IACd,kBAAkB;IAClB,kBAAkB;IAClB,cAAc;IACd,aAAa;IACb,SAAS;IACT,mBAAmB;IACnB,YAAY;IACZ,aAAa;IACb,YAAY;IACZ,cAAc;CACf,CAAC,CAAA;AAEF;;;;GAIG;AACH,MAA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AAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,MAAM,CAAA;IAC7C,IAAI,SAAS,CAAC,SAAS,CAAC,MAAM,CAAC;QAAE,OAAO,CAAC,CAAA;IACzC,OAAO,MAAM,CAAC,MAAM,CAAC,CAAA;AACvB,CAAC,CAAA;AACD,kFAAkF;AAClF,MAAM,YAAY,GAAG,CAAC,MAAc,EAAU,EAAE;IAC9C,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,OAAO,CAAC,MAAM,CAAA;IAC3C,OAAO,CAAC,CAAA;AACV,CAAC,CAAA;AAED,qFAAqF;AACrF,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,EAAW,EAAE,KAAuC,EAAQ,EAAE;IACxF,KAAK,MAAM,IAAI,IAAI,KAAK;QAAE,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAA;AAC9D,CAAC,CAAA"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Variable values in the DOM (#55, ADR-0035 *Amendment (#55)*; CONTEXT.md): a value that is wholly a
3
+ * `var(--name)`, with or without a fallback, stands for that custom property's value on the element.
4
+ * `variableValues(element)` is a Key rule bound to one element, which a binding adds to each leg it
5
+ * builds (`InterpolatorRegistry.withKeyRules`). Motion's rule (`getVariableValue`,
6
+ * css-variables-conversion.ts:18-53, and `DOMKeyframesResolver.readKeyframes` at 16c6122):
7
+ *
8
+ * - Either end that is a Variable value is resolved against the element, once, when the leg is
9
+ * built: the custom property's computed value, else its fallback, following a fallback that is
10
+ * itself a Variable value up to 4 deep. A numeric result is a number.
11
+ * - The resolved pair goes on through `next`, so the rules after this one still apply (`"none"` →
12
+ * `var(--shadow)` grows from its Animatable none), then blends by value.
13
+ * - The leg's last frame writes the target as written, so at rest the element follows the custom
14
+ * property again; a change mid-leg is followed from there.
15
+ * - A Variable value that doesn't resolve leaves the pair as written: the rule declines, and it
16
+ * switches as a Discrete pair, as Motion's does. A `var()` inside a larger value is text (#158).
17
+ *
18
+ * Client-only: it reads the element's computed style, after mount (ADR-0021).
19
+ *
20
+ * @module
21
+ */
22
+ import type * as InterpolatorRegistry from "@wardic/core/InterpolatorRegistry";
23
+ import * as Option from "effect/Option";
24
+ /** A value a key blends: a number or a string. */
25
+ /** What a Variable value resolves to: a number or a string. */
26
+ type Value = number | string;
27
+ /** Whether `value` is a Variable value: a string that's wholly a `var()`. */
28
+ export declare const isVariableValue: (value: unknown) => value is string;
29
+ /**
30
+ * What a Variable value stands for on `element`: its custom property's computed value, else its
31
+ * fallback, a fallback that is itself a Variable value followed up to 4 deep. `None` when nothing
32
+ * resolves. Reads the element's computed style.
33
+ */
34
+ export declare const resolveVariable: (element: Element, value: string) => Option.Option<Value>;
35
+ /**
36
+ * The Key rule for `element`'s Variable values: a pair with one at either end blends what they resolve
37
+ * to on `element`, through the rules after it and then by value, and lands on its target as written. It
38
+ * declines a pair with none, and one that doesn't resolve.
39
+ *
40
+ * @example
41
+ * yield* buildLegs.pipe(InterpolatorRegistry.withKeyRules([Variables.values(element)]))
42
+ */
43
+ export declare const variableValues: (element: Element) => InterpolatorRegistry.KeyRule;
44
+ export {};
45
+ //# sourceMappingURL=variables.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"variables.d.ts","sourceRoot":"","sources":["../../src/internal/variables.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,KAAK,KAAK,oBAAoB,MAAM,mCAAmC,CAAA;AAK9E,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAIvC,kDAAkD;AAClD,+DAA+D;AAC/D,KAAK,KAAK,GAAG,MAAM,GAAG,MAAM,CAAA;AA4C5B,6EAA6E;AAE7E,eAAO,MAAM,eAAe,UAAW,OAAO,KAAG,KAAK,IAAI,MAAoE,CAAA;AAK9H;;;;GAIG;AACH,eAAO,MAAM,eAAe,YAAa,OAAO,SAAS,MAAM,KAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAiC,CAAA;AAuCtH;;;;;;;GAOG;AAEH,eAAO,MAAM,cAAc,YAAa,OAAO,KAAG,oBAAoB,CAAC,OAQrE,CAAA"}
@@ -0,0 +1,92 @@
1
+ import * as Arr from "effect/Array";
2
+ import * as Bool from "effect/Boolean";
3
+ import * as Effect from "effect/Effect";
4
+ import { pipe } from "effect/Function";
5
+ import * as Option from "effect/Option";
6
+ import * as Predicate from "effect/Predicate";
7
+ import * as Str from "effect/String";
8
+ /** A Variable value's custom property, and its fallback when it has one (Motion's `parseCSSVariable`). */
9
+ const PARTS_RE = /^var\(\s*(--[\w-]+)\s*(?:,\s*([\s\S]*?))?\s*\)$/;
10
+ /** The cheap first check: a string that starts as a `var()` does. */
11
+ const VAR_START_RE = /^\s*var\(/;
12
+ /** How a character moves the bracket depth. */
13
+ const depthStep = (ch) => Bool.match(ch === "(", { onTrue: () => 1, onFalse: () => Bool.match(ch === ")", { onTrue: () => -1, onFalse: () => 0 }) });
14
+ /** Brackets that close as they open: a fallback that is one value, not the rest of a longer string. */
15
+ const isBalanced = (text) => {
16
+ const end = Arr.reduce(Str.split(text, ""), 0, (depth, ch) => Bool.match(depth < 0, { onTrue: () => depth, onFalse: () => depth + depthStep(ch) }));
17
+ return end === 0;
18
+ };
19
+ /**
20
+ * A Variable value's parts, or `None` for any other value: `var(--name)` or `var(--name, fallback)`,
21
+ * the fallback's brackets balanced, at any depth of nested `var()`s (a pattern alone stops at one).
22
+ * So `var(--a, 1px) var(--b)` isn't one: two values side by side.
23
+ */
24
+ const partsOf = (value) => {
25
+ // Asked of a string end of every key, each leg (#460): one that doesn't start as one builds nothing.
26
+ if (!VAR_START_RE.test(value))
27
+ return Option.none();
28
+ return pipe(Option.fromNullishOr(PARTS_RE.exec(Str.trim(value))), Option.map(([, name, fallback]) => ({ name, fallback: Option.map(Option.fromUndefinedOr(fallback), Str.trim) })), Option.filter((parts) => Option.match(parts.fallback, { onNone: () => true, onSome: isBalanced })));
29
+ };
30
+ /** How deep a fallback that is itself a Variable value is followed (Motion's `maxDepth`). */
31
+ const MAX_DEPTH = 4;
32
+ /** A numeric string, which a resolved value becomes a number from (Motion's `isNumericalString`). */
33
+ const NUMERIC_RE = /^-?\d*\.?\d+(?:e[-+]?\d+)?$/i;
34
+ /** Whether `value` is a Variable value: a string that's wholly a `var()`. */
35
+ // CONTEXT.md's Variable value.
36
+ export const isVariableValue = (value) => Predicate.isString(value) && Option.isSome(partsOf(value));
37
+ /** A resolved value as a key blends it: a number when it reads as one, else the string. */
38
+ const valueOf = (raw) => Bool.match(NUMERIC_RE.test(raw), { onTrue: () => Number.parseFloat(raw), onFalse: () => raw });
39
+ /**
40
+ * What a Variable value stands for on `element`: its custom property's computed value, else its
41
+ * fallback, a fallback that is itself a Variable value followed up to 4 deep. `None` when nothing
42
+ * resolves. Reads the element's computed style.
43
+ */
44
+ export const resolveVariable = (element, value) => resolveAt(element, value, 1);
45
+ /** {@link resolveVariable} at `depth`, following a fallback that's itself a Variable value. */
46
+ // #618 (F7): the depth counter was the public function's third parameter.
47
+ const resolveAt = (element, value, depth) => {
48
+ if (depth > MAX_DEPTH)
49
+ return Option.none();
50
+ return Option.flatMap(partsOf(value), ({ name, fallback }) => {
51
+ const own = Str.trim(getComputedStyle(element).getPropertyValue(name));
52
+ if (Str.isNonEmpty(own))
53
+ return Option.some(valueOf(own));
54
+ return pipe(fallback, Option.filter(Str.isNonEmpty), Option.flatMap((rest) => Bool.match(isVariableValue(rest), {
55
+ onTrue: () => resolveAt(element, rest, depth + 1),
56
+ onFalse: () => Option.some(valueOf(rest)),
57
+ })));
58
+ });
59
+ };
60
+ /** An end as the leg blends it: a Variable value resolved on `element`, any other value as it is. */
61
+ const endOf = (element, value) => Bool.match(isVariableValue(value), {
62
+ onTrue: () => resolveVariable(element, value),
63
+ onFalse: () => Option.some(value),
64
+ });
65
+ /**
66
+ * A blend that writes its target as written on the run's last Frame: a Variable value rests as the
67
+ * `var()` itself, so the element follows its custom property again. Per frame: a statement `if`.
68
+ */
69
+ const landOn = (blend, to) => (t, done) => {
70
+ if (done)
71
+ return to;
72
+ return blend(t, done);
73
+ };
74
+ /**
75
+ * The Key rule for `element`'s Variable values: a pair with one at either end blends what they resolve
76
+ * to on `element`, through the rules after it and then by value, and lands on its target as written. It
77
+ * declines a pair with none, and one that doesn't resolve.
78
+ *
79
+ * @example
80
+ * yield* buildLegs.pipe(InterpolatorRegistry.withKeyRules([Variables.values(element)]))
81
+ */
82
+ // #55.
83
+ export const variableValues = (element) => ({
84
+ name: "variable values",
85
+ blend: (key, from, to, _resolve, next) => {
86
+ // Per key, each leg (#460): a statement.
87
+ if (!isVariableValue(from) && !isVariableValue(to))
88
+ return Option.none();
89
+ return Option.map(Option.all([endOf(element, from), endOf(element, to)]), ([a, b]) => Effect.map(next(key, a, b), (blend) => landOn(blend, to)));
90
+ },
91
+ });
92
+ //# sourceMappingURL=variables.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"variables.js","sourceRoot":"","sources":["../../src/internal/variables.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAA;AACnC,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAA;AACtC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAA;AACtC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,SAAS,MAAM,kBAAkB,CAAA;AAC7C,OAAO,KAAK,GAAG,MAAM,eAAe,CAAA;AAMpC,0GAA0G;AAC1G,MAAM,QAAQ,GAAG,iDAAiD,CAAA;AAElE,qEAAqE;AACrE,MAAM,YAAY,GAAG,WAAW,CAAA;AAEhC,+CAA+C;AAC/C,MAAM,SAAS,GAAG,CAAC,EAAU,EAAU,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,KAAK,GAAG,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,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,OAAO;AACP,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,OAAgB,EAAgC,EAAE,CAAC,CAAC;IACjF,IAAI,EAAE,iBAAiB;IACvB,KAAK,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE;QACvC,yCAAyC;QACzC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,EAAE,CAAC;YAAE,OAAO,MAAM,CAAC,IAAI,EAAE,CAAA;QACxE,OAAO,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE,KAAK,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CACnF,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,CAAA;IAC9D,CAAC;CACF,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,67 @@
1
1
  {
2
2
  "name": "@wardic/dom",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.0.0-rc.10",
4
+ "description": "The browser environment for Wardic: its clock, renderer, input, probe and projection system, as Effect Layers.",
5
+ "keywords": [
6
+ "animation",
7
+ "motion",
8
+ "dom",
9
+ "effect"
10
+ ],
11
+ "homepage": "https://wardic.dev",
12
+ "bugs": "https://github.com/wardiclabs/wardic/issues",
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "git+https://github.com/wardiclabs/wardic.git",
16
+ "directory": "packages/dom"
17
+ },
18
+ "license": "MIT",
19
+ "author": {
20
+ "name": "The Wardic contributors",
21
+ "email": "hello@wardic.dev",
22
+ "url": "https://wardic.dev"
23
+ },
24
+ "files": [
25
+ "dist/**/*.js",
26
+ "dist/**/*.d.ts",
27
+ "dist/**/*.map",
28
+ "src",
29
+ "README.md",
30
+ "LICENSE",
31
+ "THIRD_PARTY_NOTICES.md"
32
+ ],
33
+ "type": "module",
34
+ "sideEffects": false,
35
+ "publishConfig": {
36
+ "access": "public"
37
+ },
38
+ "exports": {
39
+ "./package.json": "./package.json",
40
+ ".": {
41
+ "@wardic/source": "./src/index.ts",
42
+ "types": "./dist/index.d.ts",
43
+ "default": "./dist/index.js"
44
+ },
45
+ "./*": {
46
+ "@wardic/source": "./src/*.ts",
47
+ "types": "./dist/*.d.ts",
48
+ "default": "./dist/*.js"
49
+ },
50
+ "./internal/*": null
51
+ },
52
+ "scripts": {
53
+ "build": "../../node_modules/typescript-7/bin/tsc --build",
54
+ "typecheck": "../../node_modules/typescript-7/bin/tsc --build",
55
+ "typecheck:tests": "../../node_modules/typescript-7/bin/tsc -p tsconfig.test.json"
56
+ },
57
+ "dependencies": {
58
+ "@wardic/core": "1.0.0-rc.10",
59
+ "culori": "^4.0.2"
60
+ },
61
+ "peerDependencies": {
62
+ "effect": "^4.1.1"
63
+ },
64
+ "devDependencies": {
65
+ "@wardic/test": "1.0.0-rc.10"
66
+ }
67
+ }
package/src/Appear.ts ADDED
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Appear animations: a mount animation a server renders as CSS, played from the first paint, before any
3
+ * code runs, which the engine takes over at mount from where it has got to. The DOM's half, for any
4
+ * binding:
5
+ * - **On a server:** `keyframes` samples an element's spec, its mount animation built with core's
6
+ * machines, into one `@keyframes` rule, cached across requests. A render's `sheet` gives each element a
7
+ * slot, whose `animation` goes in its inline style, and writes the head's `<style>` once every slot's
8
+ * timing is defined.
9
+ * - **At mount:** `find` the element's animation, check it `matches` the client's own spec, start the run
10
+ * `elapsedOf` it in (`Machine.startAt`), and `release` the element in the task that writes the engine's
11
+ * first frame.
12
+ * - **A Batch's members** (#706): `batchKeyframes` samples one rule for every member on one set of
13
+ * transitions, each member's own values read from custom properties; a sheet's `batch` gives them one
14
+ * slot, and each member its style. At the Handoff, `findAll` reads every member's animation in one call,
15
+ * each `matchesBatch` the client's key, and its change starts `elapsedOf` it in (`Batch.retarget`'s
16
+ * `startAt`).
17
+ *
18
+ * @example
19
+ * import * as Appear from "@wardic/dom/Appear"
20
+ *
21
+ * // On a server, a sheet a render:
22
+ * const render = Appear.sheet()
23
+ * const slot = render.slot()
24
+ * slot.define({ spec, delay: 0 }) // `slot.animation` goes in the element's style, `render.css()` in the head
25
+ * // At mount:
26
+ * const elapsed = Option.map(Appear.find(element), Appear.elapsedOf)
27
+ */
28
+ // #48, ADR-0044: the **Handoff**. `@wardic/dom/Appear` (ADR-0041).
29
+ export {
30
+ adoptChunks,
31
+ animationOf,
32
+ batchKeyframes,
33
+ type BatchKeyframes,
34
+ type BatchSlot,
35
+ type BatchSpec,
36
+ CHUNK_ATTRIBUTE,
37
+ chunkStyle,
38
+ delayOf,
39
+ elapsedOf,
40
+ find,
41
+ findAll,
42
+ keyframes,
43
+ type Keyframes,
44
+ matches,
45
+ matchesBatch,
46
+ MAX_SECONDS,
47
+ nameOf,
48
+ type Play,
49
+ sheet,
50
+ type Sheet,
51
+ type Slot,
52
+ type Spec,
53
+ } from "./internal/appear.ts"
54
+ export { pending, PREFIX, release } from "./internal/appear-slot.ts"
package/src/Color.ts ADDED
@@ -0,0 +1,24 @@
1
+ /**
2
+ * CSS colours: `parse` reads a colour string, `format` writes one, `interpolator` blends two in a colour
3
+ * space, and `TOKEN` finds a colour inside a longer value, a shadow's say. A hex, `rgb()`, `hsl()` and the
4
+ * named colours are colours from the start; `registerSpaces` adds every other CSS colour space, so
5
+ * `oklch()` and `lab()` are colours too, and `interpolator("oklch")` can blend in it.
6
+ *
7
+ * @example
8
+ * import * as Color from "@wardic/dom/Color"
9
+ *
10
+ * Color.parse("#bf616a") // Some({ mode: "rgb", r: 0.749, g: 0.38, b: 0.416 })
11
+ * Color.format({ mode: "rgb", r: 1, g: 0.5, b: 0 }) // "rgb(255, 128, 0)"
12
+ */
13
+ // `@wardic/dom/Color` (#132, ADR-0041): a colour Interpolator in a culori mode, the DOM's own (`css`,
14
+ // sRGB), its `parse` and `format`, and its token (ADR-0024, ADR-0026); `registerSpaces` (#511).
15
+ export {
16
+ color as interpolator,
17
+ cssColor as css,
18
+ type Color,
19
+ formatColor as format,
20
+ parseColor as parse,
21
+ COLOR_TOKEN as TOKEN,
22
+ registerSpaces,
23
+ spacesRegistered,
24
+ } from "./internal/colors.ts"
@@ -0,0 +1,22 @@
1
+ /**
2
+ * The DOM's Announcer: a shared live region, an element a screen reader watches and reads out as its
3
+ * text changes, and the helpers a binding uses to describe a Reorder group's items to one. `layer` is
4
+ * what `DomLive` provides; `prepare` and `announceIn` work on any document.
5
+ *
6
+ * @example
7
+ * import * as DomAnnouncer from "@wardic/dom/DomAnnouncer"
8
+ *
9
+ * DomAnnouncer.prepare(document) // its live region, before the first announcement
10
+ * DomAnnouncer.announceIn(document, "Picked up Milk, position 2 of 5.")
11
+ */
12
+ // `@wardic/dom/DomAnnouncer` (#132, ADR-0041): a shared assertive live region (ADR-0037).
13
+ export {
14
+ AnnouncerDomLive as layer,
15
+ ANNOUNCER_ATTRIBUTE as ATTRIBUTE,
16
+ documentOf,
17
+ instructionsId,
18
+ instructionsIdOf,
19
+ showInstructions,
20
+ prepareAnnouncer as prepare,
21
+ announceIn,
22
+ } from "./internal/announcer.ts"
@@ -0,0 +1,22 @@
1
+ /**
2
+ * The DOM's writer for a Batch: each moving member's `transform` and `opacity`, written onto its
3
+ * element's style as Wardic's renderer draws the same values. A Batch's keys on the DOM are the
4
+ * transform keys (`x`, `y`, `z`, `translateX/Y/Z`, `scale`, `scaleX/Y`, `rotate`, `rotateX/Y/Z`,
5
+ * `skewX/Y`) and `opacity`, as numbers. A server renders a member's start with `styleOf`, the strings
6
+ * the writer draws it with.
7
+ *
8
+ * @example
9
+ * import * as Batch from "@wardic/core/Batch"
10
+ * import * as DomBatch from "@wardic/dom/DomBatch"
11
+ *
12
+ * const grid = Batch.make({ keys: ["x", "y", "opacity"], writer: DomBatch.writer, transition: { type: "spring" } })
13
+ *
14
+ * @example
15
+ * import * as DomBatch from "@wardic/dom/DomBatch"
16
+ *
17
+ * DomBatch.styleOf({ x: 10, opacity: 0 }) // { transform: "translateX(10px)", opacity: "0" }
18
+ */
19
+ // `@wardic/dom/DomBatch` (#665, ADR-0070 *Amendment (#665)*): the DOM's implementation of core's
20
+ // `Batch.Writer`, Dom-prefixed as `DomRenderer` is, its member without the module's noun (ADR-0041).
21
+ // Not in `DomLive`: a binding's `createBatch` imports it, so an app that never makes a Batch ships none.
22
+ export { styleOf, writer } from "./internal/batch-writer.ts"
@@ -0,0 +1,13 @@
1
+ /**
2
+ * The DOM's Clock: core's Clock and its Refresh frame source over the browser's `requestAnimationFrame`,
3
+ * as one Layer that needs nothing. `DomLive` provides it.
4
+ *
5
+ * @example
6
+ * import * as DomClock from "@wardic/dom/DomClock"
7
+ *
8
+ * const now = Effect.map(Clock.Clock, (clock) => clock.now()).pipe(Effect.provide(DomClock.layer))
9
+ */
10
+ // `@wardic/dom/DomClock` (#132, ADR-0041): rAF-driven (ADR-0031).
11
+ export {
12
+ ClockDomLive as layer,
13
+ } from "./internal/clock.ts"
@@ -0,0 +1,16 @@
1
+ /**
2
+ * The DOM's Default transition, Motion's by value: a spring for the transforms, a 0.3 s ease for the
3
+ * rest, and a 0.8 s tween through more than two keyframes. `layer` is what `DomLive` provides.
4
+ *
5
+ * @example
6
+ * import * as DomDefaultTransition from "@wardic/dom/DomDefaultTransition"
7
+ *
8
+ * DomDefaultTransition.transitionFor("x", 100) // { type: "spring", stiffness: 500, damping: 25, restSpeed: 10 }
9
+ * DomDefaultTransition.transitionFor("opacity", 1) // a 0.3 s tween
10
+ */
11
+ // `@wardic/dom/DomDefaultTransition` (#132, ADR-0041): ADR-0051, #357; keyframes #429.
12
+ export {
13
+ DefaultTransitionDomLive as layer,
14
+ keyframes,
15
+ transitionFor,
16
+ } from "./internal/default-transition.ts"