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

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 (285) 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 +24 -0
  5. package/dist/Appear.d.ts.map +1 -0
  6. package/dist/Appear.js +25 -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/DomClock.d.ts +11 -0
  17. package/dist/DomClock.d.ts.map +1 -0
  18. package/dist/DomClock.js +12 -0
  19. package/dist/DomClock.js.map +1 -0
  20. package/dist/DomDefaultTransition.d.ts +12 -0
  21. package/dist/DomDefaultTransition.d.ts.map +1 -0
  22. package/dist/DomDefaultTransition.js +13 -0
  23. package/dist/DomDefaultTransition.js.map +1 -0
  24. package/dist/DomInput.d.ts +13 -0
  25. package/dist/DomInput.d.ts.map +1 -0
  26. package/dist/DomInput.js +15 -0
  27. package/dist/DomInput.js.map +1 -0
  28. package/dist/DomInterpolators.d.ts +13 -0
  29. package/dist/DomInterpolators.d.ts.map +1 -0
  30. package/dist/DomInterpolators.js +14 -0
  31. package/dist/DomInterpolators.js.map +1 -0
  32. package/dist/DomKeyRules.d.ts +13 -0
  33. package/dist/DomKeyRules.d.ts.map +1 -0
  34. package/dist/DomKeyRules.js +14 -0
  35. package/dist/DomKeyRules.js.map +1 -0
  36. package/dist/DomPositionalKeys.d.ts +13 -0
  37. package/dist/DomPositionalKeys.d.ts.map +1 -0
  38. package/dist/DomPositionalKeys.js +14 -0
  39. package/dist/DomPositionalKeys.js.map +1 -0
  40. package/dist/DomProbe.d.ts +13 -0
  41. package/dist/DomProbe.d.ts.map +1 -0
  42. package/dist/DomProbe.js +14 -0
  43. package/dist/DomProbe.js.map +1 -0
  44. package/dist/DomProjectionSystem.d.ts +28 -0
  45. package/dist/DomProjectionSystem.d.ts.map +1 -0
  46. package/dist/DomProjectionSystem.js +41 -0
  47. package/dist/DomProjectionSystem.js.map +1 -0
  48. package/dist/DomRenderer.d.ts +13 -0
  49. package/dist/DomRenderer.d.ts.map +1 -0
  50. package/dist/DomRenderer.js +15 -0
  51. package/dist/DomRenderer.js.map +1 -0
  52. package/dist/FlushGate.d.ts +48 -0
  53. package/dist/FlushGate.d.ts.map +1 -0
  54. package/dist/FlushGate.js +62 -0
  55. package/dist/FlushGate.js.map +1 -0
  56. package/dist/MeasuredPair.d.ts +14 -0
  57. package/dist/MeasuredPair.d.ts.map +1 -0
  58. package/dist/MeasuredPair.js +16 -0
  59. package/dist/MeasuredPair.js.map +1 -0
  60. package/dist/OwnValues.d.ts +14 -0
  61. package/dist/OwnValues.d.ts.map +1 -0
  62. package/dist/OwnValues.js +15 -0
  63. package/dist/OwnValues.js.map +1 -0
  64. package/dist/ProjectionSystem.d.ts +34 -0
  65. package/dist/ProjectionSystem.d.ts.map +1 -0
  66. package/dist/ProjectionSystem.js +29 -0
  67. package/dist/ProjectionSystem.js.map +1 -0
  68. package/dist/ReorderController.d.ts +41 -0
  69. package/dist/ReorderController.d.ts.map +1 -0
  70. package/dist/ReorderController.js +44 -0
  71. package/dist/ReorderController.js.map +1 -0
  72. package/dist/Report.d.ts +12 -0
  73. package/dist/Report.d.ts.map +1 -0
  74. package/dist/Report.js +13 -0
  75. package/dist/Report.js.map +1 -0
  76. package/dist/ScrollOffset.d.ts +34 -0
  77. package/dist/ScrollOffset.d.ts.map +1 -0
  78. package/dist/ScrollOffset.js +42 -0
  79. package/dist/ScrollOffset.js.map +1 -0
  80. package/dist/Style.d.ts +15 -0
  81. package/dist/Style.d.ts.map +1 -0
  82. package/dist/Style.js +17 -0
  83. package/dist/Style.js.map +1 -0
  84. package/dist/Svg.d.ts +13 -0
  85. package/dist/Svg.d.ts.map +1 -0
  86. package/dist/Svg.js +14 -0
  87. package/dist/Svg.js.map +1 -0
  88. package/dist/Variables.d.ts +13 -0
  89. package/dist/Variables.d.ts.map +1 -0
  90. package/dist/Variables.js +14 -0
  91. package/dist/Variables.js.map +1 -0
  92. package/dist/index.d.ts +72 -0
  93. package/dist/index.d.ts.map +1 -0
  94. package/dist/index.js +60 -0
  95. package/dist/index.js.map +1 -0
  96. package/dist/internal/announcer.d.ts +50 -0
  97. package/dist/internal/announcer.d.ts.map +1 -0
  98. package/dist/internal/announcer.js +115 -0
  99. package/dist/internal/announcer.js.map +1 -0
  100. package/dist/internal/appear.d.ts +169 -0
  101. package/dist/internal/appear.d.ts.map +1 -0
  102. package/dist/internal/appear.js +499 -0
  103. package/dist/internal/appear.js.map +1 -0
  104. package/dist/internal/auto-scroll.d.ts +24 -0
  105. package/dist/internal/auto-scroll.d.ts.map +1 -0
  106. package/dist/internal/auto-scroll.js +124 -0
  107. package/dist/internal/auto-scroll.js.map +1 -0
  108. package/dist/internal/clock.d.ts +19 -0
  109. package/dist/internal/clock.d.ts.map +1 -0
  110. package/dist/internal/clock.js +39 -0
  111. package/dist/internal/clock.js.map +1 -0
  112. package/dist/internal/colors.d.ts +45 -0
  113. package/dist/internal/colors.d.ts.map +1 -0
  114. package/dist/internal/colors.js +193 -0
  115. package/dist/internal/colors.js.map +1 -0
  116. package/dist/internal/complex.d.ts +24 -0
  117. package/dist/internal/complex.d.ts.map +1 -0
  118. package/dist/internal/complex.js +28 -0
  119. package/dist/internal/complex.js.map +1 -0
  120. package/dist/internal/content-watch.d.ts +20 -0
  121. package/dist/internal/content-watch.d.ts.map +1 -0
  122. package/dist/internal/content-watch.js +76 -0
  123. package/dist/internal/content-watch.js.map +1 -0
  124. package/dist/internal/default-transition.d.ts +25 -0
  125. package/dist/internal/default-transition.d.ts.map +1 -0
  126. package/dist/internal/default-transition.js +41 -0
  127. package/dist/internal/default-transition.js.map +1 -0
  128. package/dist/internal/drag-defaults.d.ts +18 -0
  129. package/dist/internal/drag-defaults.d.ts.map +1 -0
  130. package/dist/internal/drag-defaults.js +38 -0
  131. package/dist/internal/drag-defaults.js.map +1 -0
  132. package/dist/internal/gate.d.ts +186 -0
  133. package/dist/internal/gate.d.ts.map +1 -0
  134. package/dist/internal/gate.js +453 -0
  135. package/dist/internal/gate.js.map +1 -0
  136. package/dist/internal/input.d.ts +41 -0
  137. package/dist/internal/input.d.ts.map +1 -0
  138. package/dist/internal/input.js +476 -0
  139. package/dist/internal/input.js.map +1 -0
  140. package/dist/internal/interpolators.d.ts +19 -0
  141. package/dist/internal/interpolators.d.ts.map +1 -0
  142. package/dist/internal/interpolators.js +30 -0
  143. package/dist/internal/interpolators.js.map +1 -0
  144. package/dist/internal/key-rules.d.ts +11 -0
  145. package/dist/internal/key-rules.d.ts.map +1 -0
  146. package/dist/internal/key-rules.js +244 -0
  147. package/dist/internal/key-rules.js.map +1 -0
  148. package/dist/internal/measure.d.ts +150 -0
  149. package/dist/internal/measure.d.ts.map +1 -0
  150. package/dist/internal/measure.js +278 -0
  151. package/dist/internal/measure.js.map +1 -0
  152. package/dist/internal/measured-pairs.d.ts +38 -0
  153. package/dist/internal/measured-pairs.d.ts.map +1 -0
  154. package/dist/internal/measured-pairs.js +251 -0
  155. package/dist/internal/measured-pairs.js.map +1 -0
  156. package/dist/internal/own-values.d.ts +35 -0
  157. package/dist/internal/own-values.d.ts.map +1 -0
  158. package/dist/internal/own-values.js +117 -0
  159. package/dist/internal/own-values.js.map +1 -0
  160. package/dist/internal/pass-ends.d.ts +21 -0
  161. package/dist/internal/pass-ends.d.ts.map +1 -0
  162. package/dist/internal/pass-ends.js +14 -0
  163. package/dist/internal/pass-ends.js.map +1 -0
  164. package/dist/internal/positional-keys.d.ts +16 -0
  165. package/dist/internal/positional-keys.d.ts.map +1 -0
  166. package/dist/internal/positional-keys.js +21 -0
  167. package/dist/internal/positional-keys.js.map +1 -0
  168. package/dist/internal/probe.d.ts +10 -0
  169. package/dist/internal/probe.d.ts.map +1 -0
  170. package/dist/internal/probe.js +117 -0
  171. package/dist/internal/probe.js.map +1 -0
  172. package/dist/internal/projection-defaults.d.ts +34 -0
  173. package/dist/internal/projection-defaults.d.ts.map +1 -0
  174. package/dist/internal/projection-defaults.js +21 -0
  175. package/dist/internal/projection-defaults.js.map +1 -0
  176. package/dist/internal/projection.d.ts +529 -0
  177. package/dist/internal/projection.d.ts.map +1 -0
  178. package/dist/internal/projection.js +4990 -0
  179. package/dist/internal/projection.js.map +1 -0
  180. package/dist/internal/renderer.d.ts +86 -0
  181. package/dist/internal/renderer.d.ts.map +1 -0
  182. package/dist/internal/renderer.js +616 -0
  183. package/dist/internal/renderer.js.map +1 -0
  184. package/dist/internal/reorder.d.ts +159 -0
  185. package/dist/internal/reorder.d.ts.map +1 -0
  186. package/dist/internal/reorder.js +437 -0
  187. package/dist/internal/reorder.js.map +1 -0
  188. package/dist/internal/report.d.ts +30 -0
  189. package/dist/internal/report.d.ts.map +1 -0
  190. package/dist/internal/report.js +60 -0
  191. package/dist/internal/report.js.map +1 -0
  192. package/dist/internal/require-global.d.ts +11 -0
  193. package/dist/internal/require-global.d.ts.map +1 -0
  194. package/dist/internal/require-global.js +31 -0
  195. package/dist/internal/require-global.js.map +1 -0
  196. package/dist/internal/reveal.d.ts +16 -0
  197. package/dist/internal/reveal.d.ts.map +1 -0
  198. package/dist/internal/reveal.js +66 -0
  199. package/dist/internal/reveal.js.map +1 -0
  200. package/dist/internal/runner.d.ts +21 -0
  201. package/dist/internal/runner.d.ts.map +1 -0
  202. package/dist/internal/runner.js +48 -0
  203. package/dist/internal/runner.js.map +1 -0
  204. package/dist/internal/scale-correction.d.ts +80 -0
  205. package/dist/internal/scale-correction.d.ts.map +1 -0
  206. package/dist/internal/scale-correction.js +227 -0
  207. package/dist/internal/scale-correction.js.map +1 -0
  208. package/dist/internal/scroll.d.ts +35 -0
  209. package/dist/internal/scroll.d.ts.map +1 -0
  210. package/dist/internal/scroll.js +244 -0
  211. package/dist/internal/scroll.js.map +1 -0
  212. package/dist/internal/scrollers.d.ts +35 -0
  213. package/dist/internal/scrollers.d.ts.map +1 -0
  214. package/dist/internal/scrollers.js +38 -0
  215. package/dist/internal/scrollers.js.map +1 -0
  216. package/dist/internal/starting-style.d.ts +141 -0
  217. package/dist/internal/starting-style.d.ts.map +1 -0
  218. package/dist/internal/starting-style.js +300 -0
  219. package/dist/internal/starting-style.js.map +1 -0
  220. package/dist/internal/svg.d.ts +60 -0
  221. package/dist/internal/svg.d.ts.map +1 -0
  222. package/dist/internal/svg.js +257 -0
  223. package/dist/internal/svg.js.map +1 -0
  224. package/dist/internal/variables.d.ts +45 -0
  225. package/dist/internal/variables.d.ts.map +1 -0
  226. package/dist/internal/variables.js +92 -0
  227. package/dist/internal/variables.js.map +1 -0
  228. package/package.json +65 -4
  229. package/src/Appear.ts +45 -0
  230. package/src/Color.ts +24 -0
  231. package/src/DomAnnouncer.ts +22 -0
  232. package/src/DomClock.ts +13 -0
  233. package/src/DomDefaultTransition.ts +16 -0
  234. package/src/DomInput.ts +22 -0
  235. package/src/DomInterpolators.ts +16 -0
  236. package/src/DomKeyRules.ts +17 -0
  237. package/src/DomPositionalKeys.ts +16 -0
  238. package/src/DomProbe.ts +15 -0
  239. package/src/DomProjectionSystem.ts +44 -0
  240. package/src/DomRenderer.ts +26 -0
  241. package/src/FlushGate.ts +81 -0
  242. package/src/MeasuredPair.ts +15 -0
  243. package/src/OwnValues.ts +19 -0
  244. package/src/ProjectionSystem.ts +51 -0
  245. package/src/ReorderController.ts +72 -0
  246. package/src/Report.ts +17 -0
  247. package/src/ScrollOffset.ts +54 -0
  248. package/src/Style.ts +37 -0
  249. package/src/Svg.ts +21 -0
  250. package/src/Variables.ts +17 -0
  251. package/src/index.ts +106 -0
  252. package/src/internal/announcer.ts +132 -0
  253. package/src/internal/appear.ts +739 -0
  254. package/src/internal/auto-scroll.ts +176 -0
  255. package/src/internal/clock.ts +45 -0
  256. package/src/internal/colors.ts +258 -0
  257. package/src/internal/complex.ts +29 -0
  258. package/src/internal/content-watch.ts +84 -0
  259. package/src/internal/culori.d.ts +58 -0
  260. package/src/internal/default-transition.ts +50 -0
  261. package/src/internal/drag-defaults.ts +54 -0
  262. package/src/internal/gate.ts +593 -0
  263. package/src/internal/input.ts +579 -0
  264. package/src/internal/interpolators.ts +33 -0
  265. package/src/internal/key-rules.ts +357 -0
  266. package/src/internal/measure.ts +357 -0
  267. package/src/internal/measured-pairs.ts +297 -0
  268. package/src/internal/own-values.ts +166 -0
  269. package/src/internal/pass-ends.ts +23 -0
  270. package/src/internal/positional-keys.ts +24 -0
  271. package/src/internal/probe.ts +176 -0
  272. package/src/internal/projection-defaults.ts +45 -0
  273. package/src/internal/projection.ts +5999 -0
  274. package/src/internal/renderer.ts +646 -0
  275. package/src/internal/reorder.ts +604 -0
  276. package/src/internal/report.ts +69 -0
  277. package/src/internal/require-global.ts +46 -0
  278. package/src/internal/reveal.ts +69 -0
  279. package/src/internal/runner.ts +64 -0
  280. package/src/internal/scale-correction.ts +310 -0
  281. package/src/internal/scroll.ts +356 -0
  282. package/src/internal/scrollers.ts +51 -0
  283. package/src/internal/starting-style.ts +396 -0
  284. package/src/internal/svg.ts +300 -0
  285. package/src/internal/variables.ts +145 -0
@@ -0,0 +1,30 @@
1
+ import * as Cause from "effect/Cause";
2
+ import * as Effect from "effect/Effect";
3
+ /**
4
+ * `cause` logged at Error as `message`, with the cause, and handed to the Environment's
5
+ * `ErrorReporter`s. An interruption is neither: it's how a run is removed, by a retarget, an unmount or a
6
+ * dispose. Annotate the log by piping `Effect.annotateLogs` onto it.
7
+ */
8
+ export declare const reportFailure: (message: string, cause: Cause.Cause<unknown>) => Effect.Effect<void>;
9
+ /**
10
+ * Whether a Debug log would be kept, as Effect's `MinimumLogLevel` says. Run it once (a runtime, a
11
+ * build) and keep the answer, not once a log.
12
+ */
13
+ export declare const debugKept: Effect.Effect<boolean>;
14
+ /**
15
+ * A lifecycle debug log for `scope` (`wardic.projection`, say): `log(event, annotations?)` logs
16
+ * `scope: event` at Debug, forked on `runner`, with the annotations. Whether a Debug log would be kept
17
+ * is read once, here ({@link debugKept}): when it wouldn't, `on` is `false` and `log` returns at once,
18
+ * forking nothing. A site that builds its annotations per element checks `on` first.
19
+ */
20
+ export declare const debugOf: (runner: {
21
+ readonly runSync: <A>(effect: Effect.Effect<A>) => A;
22
+ readonly runFork: <A>(effect: Effect.Effect<A>) => unknown;
23
+ }, scope: string) => DebugLog;
24
+ /** {@link debugOf}'s log: called with an event and its annotations, and `on` when a Debug log is kept. */
25
+ export interface DebugLog {
26
+ (event: string, annotations?: Record<string, unknown>): void;
27
+ /** Whether a Debug log would be kept: when it's `false`, a call logs nothing. */
28
+ readonly on: boolean;
29
+ }
30
+ //# sourceMappingURL=report.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"report.d.ts","sourceRoot":"","sources":["../../src/internal/report.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAMvC;;;;GAIG;AACH,eAAO,MAAM,aAAa,YAAa,MAAM,SAAS,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,KAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAI3F,CAAA;AAEJ;;;GAGG;AAEH,eAAO,MAAM,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,OAAO,CAAqH,CAAA;AAElK;;;;;GAKG;AAGH,eAAO,MAAM,OAAO,WAAY;IAAE,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,OAAO,CAAA;CAAE,SAAS,MAAM,KAAG,QAYrK,CAAA;AAED,0GAA0G;AAC1G,MAAM,WAAW,QAAQ;IACvB,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAA;IAC5D,iFAAiF;IACjF,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAA;CACrB"}
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Where a binding's failure stops (ADR-0030, decision 4): `reportFailure` logs it at Error and
3
+ * reports it to the Environment's `ErrorReporter`s. Core doesn't report: the Frame loop hands each
4
+ * run's failure to its caller (ADR-0027, decision 7), and a Tier 2 caller may recover. A binding
5
+ * boundary that ends a fiber nobody observes calls this, so a failure there reaches the console
6
+ * and an app's reporters instead of stopping its feature with nothing said.
7
+ *
8
+ * An app installs its reporters on the Environment it hands the provider,
9
+ * `ErrorReporter.layer([…])` merged into `env`; Wardic ships none. With none installed, a report
10
+ * is one `getRef` and a size check, on the failure path only. A reporter built with
11
+ * `ErrorReporter.make` dedupes a cause and its original error, so a failure that crosses two
12
+ * boundaries reports once: pass the cause on as it came, never wrapped.
13
+ *
14
+ * Tier 2 (ADR-0008): for binding authors.
15
+ */
16
+ import * as Bool from "effect/Boolean";
17
+ import * as Cause from "effect/Cause";
18
+ import * as Effect from "effect/Effect";
19
+ import * as ErrorReporter from "effect/ErrorReporter";
20
+ import * as LogLevel from "effect/LogLevel";
21
+ import * as Predicate from "effect/Predicate";
22
+ import * as References from "effect/References";
23
+ /**
24
+ * `cause` logged at Error as `message`, with the cause, and handed to the Environment's
25
+ * `ErrorReporter`s. An interruption is neither: it's how a run is removed, by a retarget, an unmount or a
26
+ * dispose. Annotate the log by piping `Effect.annotateLogs` onto it.
27
+ */
28
+ export const reportFailure = (message, cause) => Bool.match(Cause.hasInterruptsOnly(cause), {
29
+ onTrue: () => Effect.void,
30
+ onFalse: () => Effect.logError(message, cause).pipe(Effect.andThen(ErrorReporter.report(cause))),
31
+ });
32
+ /**
33
+ * Whether a Debug log would be kept, as Effect's `MinimumLogLevel` says. Run it once (a runtime, a
34
+ * build) and keep the answer, not once a log.
35
+ */
36
+ // #618: the spine reads it alone, so an app that logs nothing else doesn't ship debugOf's log.
37
+ export const debugKept = /*#__PURE__*/ Effect.map(References.MinimumLogLevel, (level) => Bool.not(LogLevel.isGreaterThan(level, "Debug")));
38
+ /**
39
+ * A lifecycle debug log for `scope` (`wardic.projection`, say): `log(event, annotations?)` logs
40
+ * `scope: event` at Debug, forked on `runner`, with the annotations. Whether a Debug log would be kept
41
+ * is read once, here ({@link debugKept}): when it wouldn't, `on` is `false` and `log` returns at once,
42
+ * forking nothing. A site that builds its annotations per element checks `on` first.
43
+ */
44
+ // #618 (M4): each call forked a fiber whatever the level, 0.3-0.5 µs to log nothing (one per layout
45
+ // node's mount and unmount); core's Frame loop reads the level once as this does (frameLoop.ts).
46
+ export const debugOf = (runner, scope) => {
47
+ const on = runner.runSync(debugKept);
48
+ const log = (event, annotations) => {
49
+ if (!on)
50
+ return;
51
+ const logged = Effect.logDebug(`${scope}: ${event}`);
52
+ if (Predicate.isUndefined(annotations)) {
53
+ runner.runFork(logged);
54
+ return;
55
+ }
56
+ runner.runFork(Effect.annotateLogs(logged, annotations));
57
+ };
58
+ return Object.assign(log, { on });
59
+ };
60
+ //# sourceMappingURL=report.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"report.js","sourceRoot":"","sources":["../../src/internal/report.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAA;AACtC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,aAAa,MAAM,sBAAsB,CAAA;AACrD,OAAO,KAAK,QAAQ,MAAM,iBAAiB,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AC,CAAA;YACtB,OAAM;QACR,CAAC;QACD,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAAA;IAC1D,CAAC,CAAA;IACD,OAAO,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,EAAE,EAAE,EAAE,CAAC,CAAA;AACnC,CAAC,CAAA"}
@@ -0,0 +1,11 @@
1
+ import * as Effect from "effect/Effect";
2
+ /** The browser globals a DomLive Layer can need. */
3
+ export type BrowserGlobal = "requestAnimationFrame" | "document" | "window";
4
+ /** The DOM's Layers that need a browser global, by the names an app knows them by. */
5
+ export type ClientLayer = "DomClock.layer" | "DomInput.layer" | "DomProbe.layer" | "DomAnnouncer.layer";
6
+ /**
7
+ * Fail the build of `layer` with ADR-0021's client-only error when `global` doesn't exist.
8
+ * Make it the first step of the build: anything that reads the global must come after it.
9
+ */
10
+ export declare const requireGlobal: (layer: ClientLayer, global: BrowserGlobal) => Effect.Effect<void>;
11
+ //# sourceMappingURL=require-global.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"require-global.d.ts","sourceRoot":"","sources":["../../src/internal/require-global.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAGvC,oDAAoD;AACpD,MAAM,MAAM,aAAa,GAAG,uBAAuB,GAAG,UAAU,GAAG,QAAQ,CAAA;AAE3E,sFAAsF;AACtF,MAAM,MAAM,WAAW,GAAG,gBAAgB,GAAG,gBAAgB,GAAG,gBAAgB,GAAG,oBAAoB,CAAA;AAUvG;;;GAGG;AAGH,eAAO,MAAM,aAAa,UAAW,WAAW,UAAU,aAAa,KAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAWzF,CAAA"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * DomLive is client-only, and says so (ADR-0021, decision 7). A server render builds no
3
+ * runtime, so building a DomLive Layer on a server is always a mistake: each Layer that
4
+ * needs a browser global checks for it as its build starts, and fails with one message
5
+ * naming the Layer, the global and the rule, instead of a `ReferenceError` from deep
6
+ * inside the build.
7
+ *
8
+ * Read when the Layer builds, never when `@wardic/dom` is imported. Once per build, so
9
+ * no log or span (the cold path's message is the error itself).
10
+ */
11
+ import * as Bool from "effect/Boolean";
12
+ import * as Effect from "effect/Effect";
13
+ import * as Predicate from "effect/Predicate";
14
+ /** Where an app gets each: three are `DomLive`'s, and a gesture builds the input. */
15
+ const FROM = {
16
+ "DomClock.layer": "DomLive's",
17
+ "DomProbe.layer": "DomLive's",
18
+ "DomAnnouncer.layer": "DomLive's",
19
+ "DomInput.layer": "a gesture's",
20
+ };
21
+ /**
22
+ * Fail the build of `layer` with ADR-0021's client-only error when `global` doesn't exist.
23
+ * Make it the first step of the build: anything that reads the global must come after it.
24
+ */
25
+ // #618 (D7): the error named the Layers ADR-0041 renamed (`ClockDomLive`…), and an ADR; `layer` is a
26
+ // union of today's names, so a rename can't leave it behind. Short, as every app ships it.
27
+ export const requireGlobal = (layer, global) => Effect.suspend(() => Bool.match(Predicate.isUndefined(globalThis[global]), {
28
+ onTrue: () => Effect.die(new Error(`${layer} (${FROM[layer]}) needs ${global}: Wardic's runtime is client-only, never built during a server render.`)),
29
+ onFalse: () => Effect.void,
30
+ }));
31
+ //# sourceMappingURL=require-global.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"require-global.js","sourceRoot":"","sources":["../../src/internal/require-global.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAA;AACtC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,SAAS,MAAM,kBAAkB,CAAA;AAQ7C,qFAAqF;AACrF,MAAM,IAAI,GAA0C;IAClD,gBAAgB,EAAE,WAAW;IAC7B,gBAAgB,EAAE,WAAW;IAC7B,oBAAoB,EAAE,WAAW;IACjC,gBAAgB,EAAE,aAAa;CAChC,CAAA;AAED;;;GAGG;AACH,qGAAqG;AACrG,2FAA2F;AAC3F,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,KAAkB,EAAE,MAAqB,EAAuB,EAAE,CAC9F,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,CAClB,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,WAAW,CAAE,UAAsC,CAAC,MAAM,CAAC,CAAC,EAAE;IACjF,MAAM,EAAE,GAAG,EAAE,CACX,MAAM,CAAC,GAAG,CACR,IAAI,KAAK,CACP,GAAG,KAAK,KAAK,IAAI,CAAC,KAAK,CAAC,WAAW,MAAM,wEAAwE,CAClH,CACF;IACH,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI;CAC3B,CAAC,CACH,CAAA"}
@@ -0,0 +1,16 @@
1
+ /** A box on screen, in client coordinates. */
2
+ interface Rect {
3
+ readonly left: number;
4
+ readonly top: number;
5
+ readonly right: number;
6
+ readonly bottom: number;
7
+ }
8
+ /**
9
+ * `el`'s layout box on screen: its painted box with its own transform undone. A translate and a
10
+ * scale (the projection's) about its `transform-origin`; a box drawn with no transform is as painted.
11
+ */
12
+ export declare const layoutRectOf: (el: Element) => Rect;
13
+ /** Scroll `el`'s new place into view (see the module doc). */
14
+ export declare const revealLayoutOf: (el: Element) => void;
15
+ export {};
16
+ //# sourceMappingURL=reveal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reveal.d.ts","sourceRoot":"","sources":["../../src/internal/reveal.ts"],"names":[],"mappings":"AAaA,8CAA8C;AAC9C,UAAU,IAAI;IACZ,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CACxB;AAED;;;GAGG;AACH,eAAO,MAAM,YAAY,OAAQ,OAAO,KAAG,IAW1C,CAAA;AAYD,8DAA8D;AAC9D,eAAO,MAAM,cAAc,OAAQ,OAAO,KAAG,IAmB5C,CAAA"}
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Keep a **Keyboard reorder**'s item in view (ADR-0037, Q13): after a step, scroll its new place
3
+ * into view, as little as needed, in each scroller that moves it and then the page, as
4
+ * `scrollIntoView({ block: "nearest", inline: "nearest" })` would. Its new place, not where it's
5
+ * drawn: a step's layout animation starts it where it was, so the box is the element's painted one
6
+ * with its own transform (a translate and a scale about its origin) undone. Instant, so it never
7
+ * runs against the step's own animation, and with nothing for reduced motion to stop.
8
+ *
9
+ * @internal for the Reorder controller.
10
+ */
11
+ import { scrollersOf } from "./scrollers.js";
12
+ import * as Arr from "effect/Array";
13
+ /**
14
+ * `el`'s layout box on screen: its painted box with its own transform undone. A translate and a
15
+ * scale (the projection's) about its `transform-origin`; a box drawn with no transform is as painted.
16
+ */
17
+ export const layoutRectOf = (el) => {
18
+ const painted = el.getBoundingClientRect();
19
+ const style = getComputedStyle(el);
20
+ const m = new DOMMatrixReadOnly(style.transform);
21
+ if (m.isIdentity)
22
+ return painted;
23
+ if (m.a === 0)
24
+ return painted;
25
+ if (m.d === 0)
26
+ return painted;
27
+ const [ox = 0, oy = 0] = style.transformOrigin.split(" ").map((v) => Number.parseFloat(v));
28
+ const left = painted.left - m.e - ox * (1 - m.a);
29
+ const top = painted.top - m.f - oy * (1 - m.d);
30
+ return { left, top, right: left + painted.width / m.a, bottom: top + painted.height / m.d };
31
+ };
32
+ /**
33
+ * How far to scroll a view from `viewMin` to `viewMax` so `min` to `max` shows: 0 when it does, else
34
+ * the least that brings it in, its start first when it can't all fit.
35
+ */
36
+ const scrollToShow = (min, max, viewMin, viewMax) => {
37
+ if (min < viewMin)
38
+ return min - viewMin;
39
+ if (max > viewMax)
40
+ return Math.min(max - viewMax, min - viewMin);
41
+ return 0;
42
+ };
43
+ /** Scroll `el`'s new place into view (see the module doc). */
44
+ export const revealLayoutOf = (el) => {
45
+ const { ancestors, page } = scrollersOf(el);
46
+ // Each scroller in turn, nearest first: what it scrolls moves the element for the next.
47
+ const rect = Arr.reduce(ancestors, layoutRectOf(el), (rect, scroller) => {
48
+ const box = scroller.getBoundingClientRect();
49
+ const top = box.top + scroller.clientTop;
50
+ const left = box.left + scroller.clientLeft;
51
+ const dy = scrollToShow(rect.top, rect.bottom, top, top + scroller.clientHeight);
52
+ const dx = scrollToShow(rect.left, rect.right, left, left + scroller.clientWidth);
53
+ if (dx === 0 && dy === 0)
54
+ return rect;
55
+ scroller.scrollBy({ left: dx, top: dy, behavior: "instant" });
56
+ return { left: rect.left - dx, top: rect.top - dy, right: rect.right - dx, bottom: rect.bottom - dy };
57
+ });
58
+ const win = el.ownerDocument.defaultView;
59
+ if (page && win !== null) {
60
+ const dy = scrollToShow(rect.top, rect.bottom, 0, win.innerHeight);
61
+ const dx = scrollToShow(rect.left, rect.right, 0, win.innerWidth);
62
+ if (dx !== 0 || dy !== 0)
63
+ win.scrollBy({ left: dx, top: dy, behavior: "instant" });
64
+ }
65
+ };
66
+ //# sourceMappingURL=reveal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reveal.js","sourceRoot":"","sources":["../../src/internal/reveal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,KAAK,GAAG,MAAM,cAAc,CAAA;AAUnC;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,EAAW,EAAQ,EAAE;IAChD,MAAM,OAAO,GAAG,EAAE,CAAC,qBAAqB,EAAE,CAAA;IAC1C,MAAM,KAAK,GAAG,gBAAgB,CAAC,EAAE,CAAC,CAAA;IAClC,MAAM,CAAC,GAAG,IAAI,iBAAiB,CAAC,KAAK,CAAC,SAAS,CAAC,CAAA;IAChD,IAAI,CAAC,CAAC,UAAU;QAAE,OAAO,OAAO,CAAA;IAChC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;QAAE,OAAO,OAAO,CAAA;IAC7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I,CAAC,GAAG,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,GAAG,CAAC,WAAW,CAAC,CAAA;QAClE,MAAM,EAAE,GAAG,YAAY,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,EAAE,GAAG,CAAC,UAAU,CAAC,CAAA;QACjE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC;YAAE,GAAG,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,CAAA;IACpF,CAAC;AACH,CAAC,CAAA"}
@@ -0,0 +1,21 @@
1
+ import * as Effect from "effect/Effect";
2
+ import type * as Fiber from "effect/Fiber";
3
+ import * as Scope from "effect/Scope";
4
+ /** Runs Effects synchronously, and forked into the Scope it was made in. */
5
+ export interface Runner<R> {
6
+ readonly runSync: <A, E>(effect: Effect.Effect<A, E, R>) => A;
7
+ readonly runFork: <A, E>(effect: Effect.Effect<A, E, R>) => Fiber.Fiber<A, E>;
8
+ /**
9
+ * The Scope it was made in: what a service built with it keeps its own fibers in, so closing the
10
+ * Scope ends them, after the service's own cleanup, and awaits them.
11
+ */
12
+ readonly scope: Scope.Scope;
13
+ }
14
+ /**
15
+ * A runner over the current context, without a sync scheduler, forking into a `FiberSet` in the
16
+ * current Scope. It forks with that context itself (`Effect.runForkWith`), not through
17
+ * `FiberSet.runtime`, which reads the context again in the current fiber, where the building call's
18
+ * scheduler still is: `Effect.provideContext` merges into a fiber's context, it doesn't replace it.
19
+ */
20
+ export declare const makeRunner: <R>() => Effect.Effect<Runner<R>, never, R | Scope.Scope>;
21
+ //# sourceMappingURL=runner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../src/internal/runner.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,KAAK,KAAK,MAAM,cAAc,CAAA;AAG1C,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AAErC,4EAA4E;AAC5E,MAAM,WAAW,MAAM,CAAC,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAA;IAC7D,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,KAAK,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;IAC7E;;;OAGG;IAEH,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC,KAAK,CAAA;CAC5B;AAED;;;;;GAKG;AAGH,eAAO,MAAM,UAAU,GAAI,CAAC,OAAK,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,KAAK,CAAC,KAAK,CAW5E,CAAA"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * A Layer-built service's runner (#132, ADR-0041): how `FlushGate.make` and `DomProjectionSystem.make`
3
+ * run their Effects after they're built, synchronously and forked, on the context their Layer was
4
+ * built in, forking into its Scope.
5
+ *
6
+ * The context drops a sync scheduler, and keeps any other (ADR-0041, *Amendment (#208)*). A
7
+ * binding's first read builds the Layer inside a `ManagedRuntime.runSync`, whose fiber carries a sync
8
+ * `MixedScheduler`: kept, it would pin every later fork to that scheduler, which resumes a fork's
9
+ * yields on a microtask, where Effect's default resumes them on a macrotask. Without it, forks use
10
+ * the default, as a `ManagedRuntime`'s do. A host's own async scheduler, provided in the Layers it
11
+ * hands Wardic (Foldkit's microtask `MixedScheduler`), is the host's choice: forks keep it (ADR-0027,
12
+ * decision 6: a fork inherits the scheduler it's forked under). A host that provides a *sync* one is
13
+ * overridden too: a sync scheduler is for draining a `runSync`.
14
+ */
15
+ import * as Bool from "effect/Boolean";
16
+ import * as Context from "effect/Context";
17
+ import * as Effect from "effect/Effect";
18
+ import * as FiberSet from "effect/FiberSet";
19
+ import * as Scheduler from "effect/Scheduler";
20
+ import * as Scope from "effect/Scope";
21
+ /**
22
+ * A runner over the current context, without a sync scheduler, forking into a `FiberSet` in the
23
+ * current Scope. It forks with that context itself (`Effect.runForkWith`), not through
24
+ * `FiberSet.runtime`, which reads the context again in the current fiber, where the building call's
25
+ * scheduler still is: `Effect.provideContext` merges into a fiber's context, it doesn't replace it.
26
+ */
27
+ // Not `Effect.fnUntraced`, as effect-4's guide prefers: TypeScript can't carry `R` through it, and the
28
+ // runner's context would be `unknown` (#618, H1).
29
+ export const makeRunner = () => Effect.gen(function* () {
30
+ const context = withoutSyncScheduler(yield* Effect.context());
31
+ const fibers = yield* FiberSet.make();
32
+ const fork = Effect.runForkWith(context);
33
+ const runFork = (effect) => {
34
+ const fiber = fork(effect);
35
+ FiberSet.addUnsafe(fibers, fiber);
36
+ return fiber;
37
+ };
38
+ return { runSync: Effect.runSyncWith(context), runFork, scope: Context.get(context, Scope.Scope) };
39
+ });
40
+ /**
41
+ * `context` without its scheduler when that one is sync (`runSync`'s), else as it is: a host's
42
+ * async scheduler stays, and with none stored the context has Effect's default already.
43
+ */
44
+ const withoutSyncScheduler = (context) => Bool.match(Context.get(context, Scheduler.Scheduler).executionMode === "sync", {
45
+ onTrue: () => Context.omit(Scheduler.Scheduler)(context),
46
+ onFalse: () => context,
47
+ });
48
+ //# sourceMappingURL=runner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runner.js","sourceRoot":"","sources":["../../src/internal/runner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAA;AACtC,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AACzC,OAAO,KAAK,M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AO,EAAE,GAAG,EAAE,CAAC,OAAO;CACvB,CAAC,CAAA"}
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Scale-correction registry (ADR-0011) — the visual-correction half of the
3
+ * projection (ADR-0009). A scaling projection counter-scales an element's
4
+ * geometry via the transform, but non-geometric CSS — `border-radius`,
5
+ * `box-shadow` — is still distorted by that scale. Each {@link ScaleCorrector}
6
+ * reads the element's base value at measure time and, per frame, emits a CSS
7
+ * string that — once the transform scales it — renders as the AUTHORED value.
8
+ *
9
+ * The projection coordinator owns the pipeline (it has the element + the per-frame
10
+ * `delta`/`treeScale`); the corrected value is written into the node's gate entry
11
+ * as an ordinary style key, so the Renderer stays pure (ADR-0002/0006) — it just
12
+ * applies what the projection computed.
13
+ *
14
+ * Units: `getComputedStyle` resolves em/rem/etc. to px, leaving only **px**
15
+ * (corrected via `/scale`) and **`%`** (self-correcting — a percentage stays the
16
+ * same fraction of each scaled dimension, so it passes through). Reading resolved
17
+ * values therefore gives full-grammar parity.
18
+ */
19
+ import type * as Box from "@wardic/core/Box";
20
+ import type * as Point from "@wardic/core/Point";
21
+ import type * as Projection from "@wardic/core/Projection";
22
+ /**
23
+ * What an app's scale corrector is handed beside the value: the projection node's fields Motion's
24
+ * correctors read, as Motion names them. `target` is the box the node is drawn into this frame,
25
+ * `treeScale` its ancestors' scale, `projectionDelta` its delta.
26
+ */
27
+ export interface CorrectorInfo {
28
+ /** The box the node is drawn into this frame. */
29
+ readonly target: Box.Box;
30
+ /** Its ancestors' scale, multiplied together. */
31
+ readonly treeScale: Point.Point;
32
+ /** Its delta, from its layout box to `target`. */
33
+ readonly projectionDelta: Projection.Delta;
34
+ }
35
+ /**
36
+ * An app's scale corrector (Motion's `addScaleCorrector` entry), given to a provider by the value key it
37
+ * corrects (`borderRadius`, `--card-radius`): `correct` turns the element's value into the one to write
38
+ * while its projection scales it, written under `applyTo`'s keys when given, else its own.
39
+ */
40
+ export interface ScaleCorrectorEntry {
41
+ /** The value to write while the projection scales the element, from its own value, `latest`, and the node's fields. */
42
+ readonly correct: (latest: string | number, info: CorrectorInfo) => string | number;
43
+ /** The keys the corrected value is written under: its own key when left out. */
44
+ readonly applyTo?: ReadonlyArray<string> | undefined;
45
+ }
46
+ /** A registered scale corrector — owns reading its base + emitting the corrected value. */
47
+ export interface ScaleCorrector {
48
+ /** The gate value-map / CSS key the corrected value is written under. */
49
+ readonly key: string;
50
+ /**
51
+ * Read the element's base value(s) at measure time (read phase), or `undefined`
52
+ * if there is nothing to correct (e.g. radius all `0px`, shadow `none`).
53
+ */
54
+ readonly read: (el: HTMLElement) => unknown;
55
+ /** Emit the corrected CSS string for the per-axis visual scale `(sx, sy)`. */
56
+ readonly correct: (base: unknown, sx: number, sy: number) => string;
57
+ }
58
+ /** Whether a per-axis scale is ~identity (no correction needed). */
59
+ export declare const isUnitScale: (sx: number, sy: number) => boolean;
60
+ export declare const borderRadiusCorrector: ScaleCorrector;
61
+ export declare const ZERO_RADIUS: unknown;
62
+ /**
63
+ * A border radius between a twin's and a Lead's at `progress` (ADR-0010 *Amendment (#166)*): corner by
64
+ * corner and axis by axis, `undefined` standing for no radius. What {@link borderRadiusCorrector}
65
+ * corrects while a handover blends. Per frame.
66
+ */
67
+ export declare const blendRadius: (from: unknown, to: unknown, progress: number) => unknown;
68
+ /**
69
+ * `radius` as drawn under an own scale `(sx, sy)` (ADR-0010 *Amendment (#166)*): its px components
70
+ * scaled, its `%` ones as they are (a fraction of the scaled box already). Per frame.
71
+ */
72
+ export declare const scaleRadius: (radius: unknown, sx: number, sy: number) => unknown;
73
+ export declare const boxShadowCorrector: ScaleCorrector;
74
+ /**
75
+ * The default scale-corrector registry (ADR-0011). Ship `borderRadius` +
76
+ * `boxShadow`; a public `addScaleCorrector` API is a deferred follow-up (adding
77
+ * an entry here is the extension point until then).
78
+ */
79
+ export declare const SCALE_CORRECTORS: ReadonlyArray<ScaleCorrector>;
80
+ //# sourceMappingURL=scale-correction.d.ts.map
@@ -0,0 +1 @@
1
+ {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B,EAAE,cAkBnC,CAAA;AAID,eAAO,MAAM,WAAW,EAAE,OAA4E,CAAA;AAwBtG;;;;GAIG;AACH,eAAO,MAAM,WAAW,SAAU,OAAO,MAAM,OAAO,YAAY,MAAM,KAAG,OAG1E,CAAA;AAQD;;;GAGG;AACH,eAAO,MAAM,WAAW,WAAY,OAAO,MAAM,MAAM,MAAM,MAAM,KAAG,OAIrE,CAAA;AA8GD,eAAO,MAAM,kBAAkB,EAAE,cAYhC,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,EAAE,aAAa,CAAC,cAAc,CAA+C,CAAA"}
@@ -0,0 +1,227 @@
1
+ import * as Predicate from "effect/Predicate";
2
+ const EPS = 1e-3;
3
+ /** Whether a per-axis scale is ~identity (no correction needed). */
4
+ export const isUnitScale = (sx, sy) => Math.abs(sx - 1) < EPS && Math.abs(sy - 1) < EPS;
5
+ const CORNER_PROPS = [
6
+ "borderTopLeftRadius",
7
+ "borderTopRightRadius",
8
+ "borderBottomRightRadius",
9
+ "borderBottomLeftRadius",
10
+ ];
11
+ /** Parse a computed longhand (`"H V"` or `"H"`) into its H + V components. */
12
+ const parseCorner = (computed) => {
13
+ // `split` gives at least one part. A single value is circular (H === V).
14
+ const parts = computed.trim().split(/\s+/);
15
+ const h = parts[0];
16
+ if (parts.length < 2)
17
+ return { h, v: h };
18
+ return { h, v: parts[1] };
19
+ };
20
+ /** Whether every corner is zero (nothing to correct). */
21
+ const isZeroRadius = (base) => base.every((c) => (Number.parseFloat(c.h) || 0) === 0 && (Number.parseFloat(c.v) || 0) === 0);
22
+ /**
23
+ * Correct one radius component for `scale`. A `%` is self-correcting (a fraction
24
+ * of each scaled dimension) and passes through; a px value is divided by the
25
+ * scale so the transform renders it back to the authored px.
26
+ */
27
+ const correctRadiusComponent = (value, scale) => {
28
+ if (value.endsWith("%"))
29
+ return value;
30
+ const px = Number.parseFloat(value);
31
+ if (!Number.isFinite(px))
32
+ return value;
33
+ return `${px / scale}px`;
34
+ };
35
+ export const borderRadiusCorrector = {
36
+ // Kebab-case: corrected values flow through the gate's style object, which the
37
+ // binding applies via `el.style.setProperty` — that requires hyphenated names
38
+ // (a camelCase key is silently dropped). `transform`/`opacity` work either way.
39
+ key: "border-radius",
40
+ read: (el) => {
41
+ const cs = getComputedStyle(el);
42
+ const base = CORNER_PROPS.map((p) => parseCorner(cs[p] || "0px"));
43
+ if (isZeroRadius(base))
44
+ return undefined;
45
+ return base;
46
+ },
47
+ correct: (base, sx, sy) => {
48
+ const corners = base;
49
+ const h = corners.map((c) => correctRadiusComponent(c.h, sx)).join(" ");
50
+ const v = corners.map((c) => correctRadiusComponent(c.v, sy)).join(" ");
51
+ // Elliptical shorthand: horizontal radii / vertical radii.
52
+ return `${h} / ${v}`;
53
+ },
54
+ };
55
+ /** No corner rounded: what a twin with no radius blends from or to (ADR-0010 *Amendment (#166)*). */
56
+ const ZERO_CORNER = { h: "0px", v: "0px" };
57
+ export const ZERO_RADIUS = [ZERO_CORNER, ZERO_CORNER, ZERO_CORNER, ZERO_CORNER];
58
+ /** A radius, or {@link ZERO_RADIUS} for none. */
59
+ const orZero = (radius) => {
60
+ if (Predicate.isUndefined(radius))
61
+ return ZERO_RADIUS;
62
+ return radius;
63
+ };
64
+ /**
65
+ * One radius component between `from` and `to` at `progress` (ADR-0010 *Amendment (#166)*, Motion's
66
+ * `mixValues`): mixed when both are the same unit or either is 0, as a `%` when either is one, and
67
+ * never below 0; otherwise `to` as it is. Per frame.
68
+ */
69
+ const blendComponent = (from, to, progress) => {
70
+ const f = Number.parseFloat(from) || 0;
71
+ const t = Number.parseFloat(to) || 0;
72
+ const fromPercent = from.endsWith("%");
73
+ const toPercent = to.endsWith("%");
74
+ if (f !== 0 && t !== 0 && fromPercent !== toPercent)
75
+ return to;
76
+ const mixed = Math.max(f + (t - f) * progress, 0);
77
+ if (fromPercent || toPercent)
78
+ return `${mixed}%`;
79
+ return `${mixed}px`;
80
+ };
81
+ /**
82
+ * A border radius between a twin's and a Lead's at `progress` (ADR-0010 *Amendment (#166)*): corner by
83
+ * corner and axis by axis, `undefined` standing for no radius. What {@link borderRadiusCorrector}
84
+ * corrects while a handover blends. Per frame.
85
+ */
86
+ export const blendRadius = (from, to, progress) => {
87
+ const b = orZero(to);
88
+ return orZero(from).map((corner, i) => blendCorner(corner, b[i], progress));
89
+ };
90
+ /** One corner between `from` and `to` at `progress`, axis by axis. Per frame. */
91
+ const blendCorner = (from, to, progress) => {
92
+ if (Predicate.isUndefined(to))
93
+ return from;
94
+ return { h: blendComponent(from.h, to.h, progress), v: blendComponent(from.v, to.v, progress) };
95
+ };
96
+ /**
97
+ * `radius` as drawn under an own scale `(sx, sy)` (ADR-0010 *Amendment (#166)*): its px components
98
+ * scaled, its `%` ones as they are (a fraction of the scaled box already). Per frame.
99
+ */
100
+ export const scaleRadius = (radius, sx, sy) => {
101
+ if (Predicate.isUndefined(radius))
102
+ return undefined;
103
+ if (sx === 1 && sy === 1)
104
+ return radius;
105
+ return radius.map((corner) => ({ h: scaleComponent(corner.h, sx), v: scaleComponent(corner.v, sy) }));
106
+ };
107
+ /** One radius component under an own scale: px scaled, `%` as it is. */
108
+ const scaleComponent = (value, scale) => {
109
+ if (value.endsWith("%"))
110
+ return value;
111
+ return `${(Number.parseFloat(value) || 0) * scale}px`;
112
+ };
113
+ /** Split a `box-shadow` value into layers on TOP-LEVEL commas (ignoring `rgb(…)` commas). */
114
+ const splitLayers = (value) => {
115
+ const layers = [];
116
+ let depth = 0;
117
+ let start = 0;
118
+ for (let i = 0; i < value.length; i++) {
119
+ const ch = value[i];
120
+ if (ch === "(")
121
+ depth++;
122
+ if (ch === ")")
123
+ depth--;
124
+ if (ch === "," && depth === 0) {
125
+ layers.push(value.slice(start, i));
126
+ start = i + 1;
127
+ }
128
+ }
129
+ layers.push(value.slice(start));
130
+ return layers;
131
+ };
132
+ /** Tokenise a layer, keeping parenthesised groups (e.g. `rgb(0, 0, 0)`) intact. */
133
+ const tokenizeLayer = (layer) => {
134
+ const tokens = [];
135
+ let depth = 0;
136
+ let cur = "";
137
+ for (const ch of layer.trim()) {
138
+ if (ch === "(")
139
+ depth++;
140
+ if (ch === ")")
141
+ depth--;
142
+ if (/\s/.test(ch) && depth === 0) {
143
+ if (cur !== "")
144
+ tokens.push(cur);
145
+ cur = "";
146
+ continue;
147
+ }
148
+ cur += ch;
149
+ }
150
+ if (cur !== "")
151
+ tokens.push(cur);
152
+ return tokens;
153
+ };
154
+ const isLength = (t) => Number.isFinite(Number.parseFloat(t));
155
+ const parseLayer = (layer) => {
156
+ const tokens = tokenizeLayer(layer);
157
+ if (tokens.length === 0)
158
+ return undefined;
159
+ let inset = false;
160
+ const lengths = [];
161
+ let color = "";
162
+ for (const t of tokens) {
163
+ if (t === "inset") {
164
+ inset = true;
165
+ continue;
166
+ }
167
+ if (isLength(t)) {
168
+ lengths.push(Number.parseFloat(t));
169
+ continue;
170
+ }
171
+ color = t; // a non-length, non-inset token is the color (verbatim)
172
+ }
173
+ if (lengths.length < 2)
174
+ return undefined; // offsetX + offsetY are required
175
+ return {
176
+ color,
177
+ offsetX: lengths[0],
178
+ offsetY: lengths[1],
179
+ blur: lengthAt(lengths, 2),
180
+ spread: lengthAt(lengths, 3),
181
+ inset,
182
+ lengthCount: lengths.length,
183
+ };
184
+ };
185
+ /** A shadow's `i`th length, 0 when it wasn't authored. */
186
+ const lengthAt = (lengths, i) => {
187
+ if (i >= lengths.length)
188
+ return 0;
189
+ return lengths[i];
190
+ };
191
+ const formatLayer = (l, sx, sy) => {
192
+ const mean = (sx + sy) / 2;
193
+ // Per-axis offsets exact; blur + spread are scalar -> axis mean (no exact value
194
+ // under non-uniform scale).
195
+ const lens = [l.offsetX / sx, l.offsetY / sy, l.blur / mean, l.spread / mean]
196
+ .slice(0, l.lengthCount)
197
+ .map((n) => `${n}px`);
198
+ const parts = [];
199
+ if (l.inset)
200
+ parts.push("inset");
201
+ parts.push(...lens);
202
+ if (l.color !== "")
203
+ parts.push(l.color);
204
+ return parts.join(" ");
205
+ };
206
+ export const boxShadowCorrector = {
207
+ key: "box-shadow", // kebab-case (see borderRadiusCorrector.key)
208
+ read: (el) => {
209
+ const value = getComputedStyle(el).boxShadow;
210
+ if (value === "" || value === "none")
211
+ return undefined;
212
+ const layers = splitLayers(value)
213
+ .map(parseLayer)
214
+ .filter(Predicate.isNotUndefined);
215
+ if (layers.length === 0)
216
+ return undefined;
217
+ return layers;
218
+ },
219
+ correct: (base, sx, sy) => base.map((l) => formatLayer(l, sx, sy)).join(", "),
220
+ };
221
+ /**
222
+ * The default scale-corrector registry (ADR-0011). Ship `borderRadius` +
223
+ * `boxShadow`; a public `addScaleCorrector` API is a deferred follow-up (adding
224
+ * an entry here is the extension point until then).
225
+ */
226
+ export const SCALE_CORRECTORS = [borderRadiusCorrector, boxShadowCorrector];
227
+ //# sourceMappingURL=scale-correction.js.map