@pibbl/core 0.0.1 → 0.0.3-alpha.85.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (374) hide show
  1. package/README.md +1 -1
  2. package/THIRD_PARTY_NOTICES.txt +81 -0
  3. package/dist/features/machines/animation.d.ts +64 -0
  4. package/dist/features/machines/animation.js +55 -0
  5. package/dist/features/machines/animation.js.map +7 -0
  6. package/dist/features/machines/animation.mjs +1 -0
  7. package/dist/features/machines/assign.d.ts +16 -0
  8. package/dist/features/machines/assign.js +15 -0
  9. package/dist/features/machines/assign.js.map +7 -0
  10. package/dist/features/machines/callback.d.ts +9 -0
  11. package/dist/features/machines/callback.js +7 -0
  12. package/dist/features/machines/callback.js.map +7 -0
  13. package/dist/features/machines/hook.d.ts +30 -0
  14. package/dist/features/machines/hook.js +37 -0
  15. package/dist/features/machines/hook.js.map +7 -0
  16. package/dist/features/machines/index.d.ts +6 -0
  17. package/dist/features/machines/index.js +12 -0
  18. package/dist/features/machines/index.js.map +7 -0
  19. package/dist/features/machines/index.mjs +1 -0
  20. package/dist/features/machines/runtime.d.ts +18 -0
  21. package/dist/features/machines/runtime.js +363 -0
  22. package/dist/features/machines/runtime.js.map +7 -0
  23. package/dist/features/machines/types.d.ts +164 -0
  24. package/dist/features/physics/2d-geometry.d.ts +3 -3
  25. package/dist/features/physics/2d-geometry.js.map +1 -1
  26. package/dist/features/physics/2d.d.ts +115 -62
  27. package/dist/features/physics/2d.js +59 -28
  28. package/dist/features/physics/2d.js.map +2 -2
  29. package/dist/features/physics/lib/2d/query-types.d.ts +6 -0
  30. package/dist/features/physics/lib/2d/runtime/controller.d.ts +7 -6
  31. package/dist/features/physics/lib/2d/runtime/controller.js.map +2 -2
  32. package/dist/features/physics/lib/2d/types.d.ts +8 -30
  33. package/dist/features/physics/lib/2d/world/queries.d.ts +7 -6
  34. package/dist/features/physics/lib/2d/world/queries.js.map +2 -2
  35. package/dist/features/sprites/formats/aseprite.d.ts +5 -0
  36. package/dist/features/sprites/formats/texture-packer.d.ts +5 -0
  37. package/dist/features/sprites/index.d.ts +6 -0
  38. package/dist/features/sprites/loader.d.ts +25 -0
  39. package/dist/features/sprites/model.d.ts +75 -0
  40. package/dist/features/sprites/sprite.d.ts +22 -0
  41. package/dist/features/textures/index.d.ts +12 -2
  42. package/dist/features/textures/index.js +33 -1
  43. package/dist/features/textures/index.js.map +2 -2
  44. package/dist/features/textures/lib/chemical-field.d.ts +56 -0
  45. package/dist/features/textures/lib/chemical-field.js +154 -0
  46. package/dist/features/textures/lib/chemical-field.js.map +7 -0
  47. package/dist/features/textures/lib/chemical-recipes.d.ts +119 -0
  48. package/dist/features/textures/lib/chemical-recipes.js +275 -0
  49. package/dist/features/textures/lib/chemical-recipes.js.map +7 -0
  50. package/dist/features/textures/lib/definitions.d.ts +3 -18
  51. package/dist/features/textures/lib/definitions.js +15 -20
  52. package/dist/features/textures/lib/definitions.js.map +2 -2
  53. package/dist/features/textures/lib/geometric-patterns.d.ts +149 -0
  54. package/dist/features/textures/lib/geometric-patterns.js +305 -0
  55. package/dist/features/textures/lib/geometric-patterns.js.map +7 -0
  56. package/dist/features/textures/lib/gray-scott.d.ts +55 -0
  57. package/dist/features/textures/lib/gray-scott.js +39 -0
  58. package/dist/features/textures/lib/gray-scott.js.map +7 -0
  59. package/dist/features/textures/lib/patterns.d.ts +123 -0
  60. package/dist/features/textures/lib/patterns.js +344 -0
  61. package/dist/features/textures/lib/patterns.js.map +7 -0
  62. package/dist/features/textures/lib/reaction-diffusion.d.ts +3 -2
  63. package/dist/features/textures/lib/reaction-diffusion.js +9 -20
  64. package/dist/features/textures/lib/reaction-diffusion.js.map +2 -2
  65. package/dist/features/textures/lib/simulation.d.ts +10 -4
  66. package/dist/features/textures/lib/simulation.js +23 -13
  67. package/dist/features/textures/lib/simulation.js.map +2 -2
  68. package/dist/features/viz/index.d.ts +79 -5
  69. package/dist/features/viz/index.js +145 -4
  70. package/dist/features/viz/index.js.map +2 -2
  71. package/dist/features/viz/inspection/bar.d.ts +79 -0
  72. package/dist/features/viz/inspection/bar.js +49 -0
  73. package/dist/features/viz/inspection/bar.js.map +7 -0
  74. package/dist/features/viz/inspection/candle.d.ts +156 -0
  75. package/dist/features/viz/inspection/candle.js +120 -0
  76. package/dist/features/viz/inspection/candle.js.map +7 -0
  77. package/dist/features/viz/inspection/capture-types.d.ts +65 -0
  78. package/dist/features/viz/inspection/capture.d.ts +16 -0
  79. package/dist/features/viz/inspection/capture.js +49 -0
  80. package/dist/features/viz/inspection/capture.js.map +7 -0
  81. package/dist/features/viz/inspection/handler.d.ts +36 -0
  82. package/dist/features/viz/inspection/handler.js +91 -0
  83. package/dist/features/viz/inspection/handler.js.map +7 -0
  84. package/dist/features/viz/inspection/ohlc-bar.d.ts +132 -0
  85. package/dist/features/viz/inspection/ohlc-bar.js +118 -0
  86. package/dist/features/viz/inspection/ohlc-bar.js.map +7 -0
  87. package/dist/features/viz/inspection/owned-ref.d.ts +16 -0
  88. package/dist/features/viz/inspection/owned-ref.js +99 -0
  89. package/dist/features/viz/inspection/owned-ref.js.map +7 -0
  90. package/dist/features/viz/inspection/painted-point.d.ts +22 -0
  91. package/dist/features/viz/inspection/painted-point.js +29 -0
  92. package/dist/features/viz/inspection/painted-point.js.map +7 -0
  93. package/dist/features/viz/inspection/queries.d.ts +100 -0
  94. package/dist/features/viz/inspection/queries.js +192 -0
  95. package/dist/features/viz/inspection/queries.js.map +7 -0
  96. package/dist/features/viz/inspection/query-types.d.ts +177 -0
  97. package/dist/features/viz/inspection/volume.d.ts +104 -0
  98. package/dist/features/viz/inspection/volume.js +95 -0
  99. package/dist/features/viz/inspection/volume.js.map +7 -0
  100. package/dist/features/viz/inspection.d.ts +19 -0
  101. package/dist/features/viz/inspection.js +54 -0
  102. package/dist/features/viz/inspection.js.map +7 -0
  103. package/dist/features/viz/inspection.mjs +1 -0
  104. package/dist/features/viz/lib/area-series.d.ts +62 -0
  105. package/dist/features/viz/lib/area-series.js +120 -0
  106. package/dist/features/viz/lib/area-series.js.map +7 -0
  107. package/dist/features/viz/lib/axis-labels.d.ts +2 -0
  108. package/dist/features/viz/lib/axis-labels.js +41 -0
  109. package/dist/features/viz/lib/axis-labels.js.map +7 -0
  110. package/dist/features/viz/lib/axis-title.d.ts +23 -0
  111. package/dist/features/viz/lib/axis-title.js +23 -0
  112. package/dist/features/viz/lib/axis-title.js.map +7 -0
  113. package/dist/features/viz/lib/axis.d.ts +1 -1
  114. package/dist/features/viz/lib/axis.js +50 -50
  115. package/dist/features/viz/lib/axis.js.map +2 -2
  116. package/dist/features/viz/lib/bar-scale.d.ts +7 -0
  117. package/dist/features/viz/lib/bar-scale.js +34 -0
  118. package/dist/features/viz/lib/bar-scale.js.map +7 -0
  119. package/dist/features/viz/lib/bar-series.d.ts +3 -1
  120. package/dist/features/viz/lib/bar-series.js +21 -5
  121. package/dist/features/viz/lib/bar-series.js.map +2 -2
  122. package/dist/features/viz/lib/baseline-series.d.ts +55 -0
  123. package/dist/features/viz/lib/baseline-series.js +136 -0
  124. package/dist/features/viz/lib/baseline-series.js.map +7 -0
  125. package/dist/features/viz/lib/candlestick-series.d.ts +62 -0
  126. package/dist/features/viz/lib/candlestick-series.js +150 -0
  127. package/dist/features/viz/lib/candlestick-series.js.map +7 -0
  128. package/dist/features/viz/lib/censored-point-series.d.ts +71 -0
  129. package/dist/features/viz/lib/censored-point-series.js +129 -0
  130. package/dist/features/viz/lib/censored-point-series.js.map +7 -0
  131. package/dist/features/viz/lib/chart-lines.d.ts +41 -0
  132. package/dist/features/viz/lib/chart-lines.js +32 -0
  133. package/dist/features/viz/lib/chart-lines.js.map +7 -0
  134. package/dist/features/viz/lib/color-context.d.ts +4 -0
  135. package/dist/features/viz/lib/color-context.js +41 -0
  136. package/dist/features/viz/lib/color-context.js.map +7 -0
  137. package/dist/features/viz/lib/color-math.d.ts +4 -0
  138. package/dist/features/viz/lib/color-math.js +31 -0
  139. package/dist/features/viz/lib/color-math.js.map +7 -0
  140. package/dist/features/viz/lib/color-types.d.ts +53 -0
  141. package/dist/features/viz/lib/curve-definition.d.ts +49 -0
  142. package/dist/features/viz/lib/curve-definition.js +148 -0
  143. package/dist/features/viz/lib/curve-definition.js.map +7 -0
  144. package/dist/features/viz/lib/diverging-color-scale.d.ts +11 -0
  145. package/dist/features/viz/lib/diverging-color-scale.js +51 -0
  146. package/dist/features/viz/lib/diverging-color-scale.js.map +7 -0
  147. package/dist/features/viz/lib/domain-navigation.d.ts +40 -0
  148. package/dist/features/viz/lib/domain-navigation.js +77 -0
  149. package/dist/features/viz/lib/domain-navigation.js.map +7 -0
  150. package/dist/features/viz/lib/editable-chart-elements.d.ts +178 -0
  151. package/dist/features/viz/lib/editable-chart-elements.js +733 -0
  152. package/dist/features/viz/lib/editable-chart-elements.js.map +7 -0
  153. package/dist/features/viz/lib/financial-aggregation.d.ts +127 -0
  154. package/dist/features/viz/lib/financial-aggregation.js +116 -0
  155. package/dist/features/viz/lib/financial-aggregation.js.map +7 -0
  156. package/dist/features/viz/lib/financial-autoscale.d.ts +64 -0
  157. package/dist/features/viz/lib/financial-autoscale.js +61 -0
  158. package/dist/features/viz/lib/financial-autoscale.js.map +7 -0
  159. package/dist/features/viz/lib/financial-comparison.d.ts +62 -0
  160. package/dist/features/viz/lib/financial-comparison.js +98 -0
  161. package/dist/features/viz/lib/financial-comparison.js.map +7 -0
  162. package/dist/features/viz/lib/financial-geometry.d.ts +77 -0
  163. package/dist/features/viz/lib/financial-geometry.js +67 -0
  164. package/dist/features/viz/lib/financial-geometry.js.map +7 -0
  165. package/dist/features/viz/lib/financial-indicators.d.ts +114 -0
  166. package/dist/features/viz/lib/financial-indicators.js +135 -0
  167. package/dist/features/viz/lib/financial-indicators.js.map +7 -0
  168. package/dist/features/viz/lib/financial-oscillators.d.ts +171 -0
  169. package/dist/features/viz/lib/financial-oscillators.js +265 -0
  170. package/dist/features/viz/lib/financial-oscillators.js.map +7 -0
  171. package/dist/features/viz/lib/hover-data.d.ts +1 -1
  172. package/dist/features/viz/lib/hover-data.js +6 -3
  173. package/dist/features/viz/lib/hover-data.js.map +2 -2
  174. package/dist/features/viz/lib/hover-types.d.ts +5 -5
  175. package/dist/features/viz/lib/interval-band-series.d.ts +49 -0
  176. package/dist/features/viz/lib/interval-band-series.js +136 -0
  177. package/dist/features/viz/lib/interval-band-series.js.map +7 -0
  178. package/dist/features/viz/lib/interval-diamond-series.d.ts +43 -0
  179. package/dist/features/viz/lib/interval-diamond-series.js +124 -0
  180. package/dist/features/viz/lib/interval-diamond-series.js.map +7 -0
  181. package/dist/features/viz/lib/interval-series.d.ts +79 -0
  182. package/dist/features/viz/lib/interval-series.js +158 -0
  183. package/dist/features/viz/lib/interval-series.js.map +7 -0
  184. package/dist/features/viz/lib/line-series.d.ts +1 -1
  185. package/dist/features/viz/lib/line-series.js +47 -28
  186. package/dist/features/viz/lib/line-series.js.map +2 -2
  187. package/dist/features/viz/lib/linear-scale-component.d.ts +7 -0
  188. package/dist/features/viz/lib/linear-scale-component.js +18 -0
  189. package/dist/features/viz/lib/linear-scale-component.js.map +7 -0
  190. package/dist/features/viz/lib/linear-scale.js +1 -1
  191. package/dist/features/viz/lib/linear-scale.js.map +2 -2
  192. package/dist/features/viz/lib/log-scale-component.d.ts +7 -0
  193. package/dist/features/viz/lib/log-scale-component.js +19 -0
  194. package/dist/features/viz/lib/log-scale-component.js.map +7 -0
  195. package/dist/features/viz/lib/log-scale.d.ts +2 -0
  196. package/dist/features/viz/lib/log-scale.js +53 -0
  197. package/dist/features/viz/lib/log-scale.js.map +7 -0
  198. package/dist/features/viz/lib/monotone-curve.d.ts +11 -0
  199. package/dist/features/viz/lib/monotone-curve.js +63 -0
  200. package/dist/features/viz/lib/monotone-curve.js.map +7 -0
  201. package/dist/features/viz/lib/nearest.d.ts +9 -9
  202. package/dist/features/viz/lib/nearest.js.map +1 -1
  203. package/dist/features/viz/lib/numeric-range-interpolation.d.ts +15 -0
  204. package/dist/features/viz/lib/numeric-range-interpolation.js +36 -0
  205. package/dist/features/viz/lib/numeric-range-interpolation.js.map +7 -0
  206. package/dist/features/viz/lib/numeric-ticks.d.ts +38 -0
  207. package/dist/features/viz/lib/numeric-ticks.js +54 -0
  208. package/dist/features/viz/lib/numeric-ticks.js.map +7 -0
  209. package/dist/features/viz/lib/ohlc-bar-series.d.ts +55 -0
  210. package/dist/features/viz/lib/ohlc-bar-series.js +168 -0
  211. package/dist/features/viz/lib/ohlc-bar-series.js.map +7 -0
  212. package/dist/features/viz/lib/paired-series.d.ts +44 -0
  213. package/dist/features/viz/lib/paired-series.js +93 -0
  214. package/dist/features/viz/lib/paired-series.js.map +7 -0
  215. package/dist/features/viz/lib/plot-series.js +11 -6
  216. package/dist/features/viz/lib/plot-series.js.map +2 -2
  217. package/dist/features/viz/lib/plot-types.d.ts +4 -3
  218. package/dist/features/viz/lib/point-scale-component.d.ts +7 -0
  219. package/dist/features/viz/lib/point-scale-component.js +19 -0
  220. package/dist/features/viz/lib/point-scale-component.js.map +7 -0
  221. package/dist/features/viz/lib/point-scale.d.ts +2 -0
  222. package/dist/features/viz/lib/point-scale.js +45 -0
  223. package/dist/features/viz/lib/point-scale.js.map +7 -0
  224. package/dist/features/viz/lib/point-series.d.ts +1 -1
  225. package/dist/features/viz/lib/point-series.js +36 -9
  226. package/dist/features/viz/lib/point-series.js.map +2 -2
  227. package/dist/features/viz/lib/point-types.d.ts +5 -2
  228. package/dist/features/viz/lib/reference-band.d.ts +16 -0
  229. package/dist/features/viz/lib/reference-band.js +27 -0
  230. package/dist/features/viz/lib/reference-band.js.map +7 -0
  231. package/dist/features/viz/lib/scale-adjust.js +9 -4
  232. package/dist/features/viz/lib/scale-adjust.js.map +2 -2
  233. package/dist/features/viz/lib/scale-context.d.ts +5 -4
  234. package/dist/features/viz/lib/scale-context.js +15 -11
  235. package/dist/features/viz/lib/scale-context.js.map +2 -2
  236. package/dist/features/viz/lib/scale-provider.d.ts +2 -0
  237. package/dist/features/viz/lib/scale-provider.js +13 -0
  238. package/dist/features/viz/lib/scale-provider.js.map +7 -0
  239. package/dist/features/viz/lib/scale-ticks.d.ts +5 -0
  240. package/dist/features/viz/lib/scale-ticks.js +64 -0
  241. package/dist/features/viz/lib/scale-ticks.js.map +7 -0
  242. package/dist/features/viz/lib/scale-view.d.ts +4 -0
  243. package/dist/features/viz/lib/scale-view.js +21 -0
  244. package/dist/features/viz/lib/scale-view.js.map +7 -0
  245. package/dist/features/viz/lib/sequential-color-scale.d.ts +11 -0
  246. package/dist/features/viz/lib/sequential-color-scale.js +49 -0
  247. package/dist/features/viz/lib/sequential-color-scale.js.map +7 -0
  248. package/dist/features/viz/lib/series-position.d.ts +12 -0
  249. package/dist/features/viz/lib/series-position.js +44 -0
  250. package/dist/features/viz/lib/series-position.js.map +7 -0
  251. package/dist/features/viz/lib/step-curves.d.ts +19 -0
  252. package/dist/features/viz/lib/step-curves.js +53 -0
  253. package/dist/features/viz/lib/step-curves.js.map +7 -0
  254. package/dist/features/viz/lib/symlog-scale-component.d.ts +7 -0
  255. package/dist/features/viz/lib/symlog-scale-component.js +19 -0
  256. package/dist/features/viz/lib/symlog-scale-component.js.map +7 -0
  257. package/dist/features/viz/lib/symlog-scale.d.ts +2 -0
  258. package/dist/features/viz/lib/symlog-scale.js +38 -0
  259. package/dist/features/viz/lib/symlog-scale.js.map +7 -0
  260. package/dist/features/viz/lib/threshold-color-scale.d.ts +43 -0
  261. package/dist/features/viz/lib/threshold-color-scale.js +59 -0
  262. package/dist/features/viz/lib/threshold-color-scale.js.map +7 -0
  263. package/dist/features/viz/lib/trading-time-mapping.d.ts +32 -0
  264. package/dist/features/viz/lib/trading-time-mapping.js +89 -0
  265. package/dist/features/viz/lib/trading-time-mapping.js.map +7 -0
  266. package/dist/features/viz/lib/trading-time-scale.d.ts +83 -0
  267. package/dist/features/viz/lib/trading-time-scale.js +96 -0
  268. package/dist/features/viz/lib/trading-time-scale.js.map +7 -0
  269. package/dist/features/viz/lib/trajectory-series.d.ts +71 -0
  270. package/dist/features/viz/lib/trajectory-series.js +111 -0
  271. package/dist/features/viz/lib/trajectory-series.js.map +7 -0
  272. package/dist/features/viz/lib/types.d.ts +114 -21
  273. package/dist/features/viz/lib/use-bar-scale.d.ts +8 -0
  274. package/dist/features/viz/lib/use-bar-scale.js +9 -0
  275. package/dist/features/viz/lib/use-bar-scale.js.map +7 -0
  276. package/dist/features/viz/lib/use-continuous-scale.d.ts +8 -0
  277. package/dist/features/viz/lib/use-continuous-scale.js +14 -0
  278. package/dist/features/viz/lib/use-continuous-scale.js.map +7 -0
  279. package/dist/features/viz/lib/use-linear-scale.d.ts +8 -0
  280. package/dist/features/viz/lib/use-linear-scale.js +9 -0
  281. package/dist/features/viz/lib/use-linear-scale.js.map +7 -0
  282. package/dist/features/viz/lib/use-log-scale.d.ts +8 -0
  283. package/dist/features/viz/lib/use-log-scale.js +9 -0
  284. package/dist/features/viz/lib/use-log-scale.js.map +7 -0
  285. package/dist/features/viz/lib/use-point-scale.d.ts +8 -0
  286. package/dist/features/viz/lib/use-point-scale.js +9 -0
  287. package/dist/features/viz/lib/use-point-scale.js.map +7 -0
  288. package/dist/features/viz/lib/use-symlog-scale.d.ts +8 -0
  289. package/dist/features/viz/lib/use-symlog-scale.js +9 -0
  290. package/dist/features/viz/lib/use-symlog-scale.js.map +7 -0
  291. package/dist/features/viz/lib/use-utc-scale.d.ts +8 -0
  292. package/dist/features/viz/lib/use-utc-scale.js +9 -0
  293. package/dist/features/viz/lib/use-utc-scale.js.map +7 -0
  294. package/dist/features/viz/lib/utc-labels.d.ts +12 -0
  295. package/dist/features/viz/lib/utc-labels.js +27 -0
  296. package/dist/features/viz/lib/utc-labels.js.map +7 -0
  297. package/dist/features/viz/lib/utc-scale-component.d.ts +7 -0
  298. package/dist/features/viz/lib/utc-scale-component.js +18 -0
  299. package/dist/features/viz/lib/utc-scale-component.js.map +7 -0
  300. package/dist/features/viz/lib/utc-scale.d.ts +21 -0
  301. package/dist/features/viz/lib/utc-scale.js +123 -0
  302. package/dist/features/viz/lib/utc-scale.js.map +7 -0
  303. package/dist/features/viz/lib/volume-series.d.ts +59 -0
  304. package/dist/features/viz/lib/volume-series.js +117 -0
  305. package/dist/features/viz/lib/volume-series.js.map +7 -0
  306. package/dist/features/viz/lib/weighted-point-series.d.ts +71 -0
  307. package/dist/features/viz/lib/weighted-point-series.js +169 -0
  308. package/dist/features/viz/lib/weighted-point-series.js.map +7 -0
  309. package/dist/filters/emboss-gpu.d.ts +4 -0
  310. package/dist/filters/emboss-gpu.js +39 -0
  311. package/dist/filters/emboss-gpu.js.map +7 -0
  312. package/dist/filters/emboss.d.ts +32 -0
  313. package/dist/filters/emboss.js +106 -0
  314. package/dist/filters/emboss.js.map +7 -0
  315. package/dist/filters/reflection-gpu.d.ts +3 -1
  316. package/dist/filters/reflection-gpu.js +5 -2
  317. package/dist/filters/reflection-gpu.js.map +2 -2
  318. package/dist/filters/render-emboss-boundary.d.ts +13 -0
  319. package/dist/filters/render-emboss-boundary.js +131 -0
  320. package/dist/filters/render-emboss-boundary.js.map +7 -0
  321. package/dist/filters.d.ts +2 -0
  322. package/dist/filters.js +2 -0
  323. package/dist/filters.js.map +2 -2
  324. package/dist/index.d.ts +3 -1
  325. package/dist/index.js +3 -0
  326. package/dist/index.js.map +2 -2
  327. package/dist/internal.d.ts +2 -0
  328. package/dist/internal.js +4 -0
  329. package/dist/internal.js.map +2 -2
  330. package/dist/lib/animation/definition.d.ts +5 -3
  331. package/dist/lib/animation/definition.js +29 -4
  332. package/dist/lib/animation/definition.js.map +2 -2
  333. package/dist/lib/animation/playback.d.ts +8 -0
  334. package/dist/lib/animation/playback.js +33 -11
  335. package/dist/lib/animation/playback.js.map +2 -2
  336. package/dist/lib/animation/spring.d.ts +3 -1
  337. package/dist/lib/animation/spring.js.map +2 -2
  338. package/dist/lib/animation/types.d.ts +29 -73
  339. package/dist/lib/events/event-facade.d.ts +13 -0
  340. package/dist/lib/events/event-facade.js +23 -0
  341. package/dist/lib/events/event-facade.js.map +2 -2
  342. package/dist/lib/events/propagation.js +19 -14
  343. package/dist/lib/events/propagation.js.map +2 -2
  344. package/dist/lib/execute-render.js +13 -0
  345. package/dist/lib/execute-render.js.map +2 -2
  346. package/dist/lib/hooks/use-animated-value.d.ts +11 -21
  347. package/dist/lib/hooks/use-animated-value.js +23 -70
  348. package/dist/lib/hooks/use-animated-value.js.map +3 -3
  349. package/dist/lib/hooks/use-playback.js +1 -0
  350. package/dist/lib/hooks/use-playback.js.map +2 -2
  351. package/dist/lib/recording/recording.d.ts +43 -0
  352. package/dist/lib/recording/recording.js +555 -0
  353. package/dist/lib/recording/recording.js.map +7 -0
  354. package/dist/lib/recording/types.d.ts +118 -0
  355. package/dist/lib/recording/wasm-bytes.d.ts +1 -0
  356. package/dist/lib/recording/wasm-bytes.js +5 -0
  357. package/dist/lib/recording/wasm-bytes.js.map +7 -0
  358. package/dist/lib/recording/worker-source.d.ts +1 -0
  359. package/dist/lib/recording/worker-source.js +5 -0
  360. package/dist/lib/recording/worker-source.js.map +7 -0
  361. package/dist/lib/render-transaction.d.ts +5 -2
  362. package/dist/lib/render-transaction.js +23 -1
  363. package/dist/lib/render-transaction.js.map +2 -2
  364. package/dist/lib/series-inspection-frame.d.ts +18 -0
  365. package/dist/lib/series-inspection-frame.js +70 -0
  366. package/dist/lib/series-inspection-frame.js.map +7 -0
  367. package/dist/lib/types.d.ts +6 -0
  368. package/package.json +27 -5
  369. package/dist/features/viz/lib/scale.d.ts +0 -11
  370. package/dist/features/viz/lib/scale.js +0 -80
  371. package/dist/features/viz/lib/scale.js.map +0 -7
  372. package/dist/features/viz/lib/use-scale.d.ts +0 -20
  373. package/dist/features/viz/lib/use-scale.js +0 -10
  374. package/dist/features/viz/lib/use-scale.js.map +0 -7
@@ -1,11 +1,17 @@
1
1
  import { jsx } from "@pibbl/core/jsx-runtime";
2
2
  import { Path, resolveSignalValue } from "@pibbl/core";
3
3
  import { useInternalValueMemoSlot } from "@pibbl/core/internal";
4
- import { useScale } from "./use-scale.js";
4
+ import {
5
+ appendCurveForward,
6
+ curveGeometry,
7
+ resolveSeriesCurve
8
+ } from "./curve-definition.js";
9
+ import {
10
+ useSeriesPosition,
11
+ seriesAccessor,
12
+ mapSeriesPosition
13
+ } from "./series-position.js";
5
14
  import { width, opacity } from "./paint.js";
6
- function accessor(input) {
7
- return typeof input === "function" ? input : (datum) => datum[input];
8
- }
9
15
  function LineSeries({
10
16
  data: dataInput,
11
17
  x: xInput,
@@ -13,20 +19,24 @@ function LineSeries({
13
19
  xScale: xId,
14
20
  yScale: yId,
15
21
  defined,
22
+ inspection,
16
23
  curve,
17
24
  style: styleInput,
18
25
  ...eventProps
19
26
  }) {
20
- const xScale = useScale(xId).get();
21
- const yScale = useScale(yId).get();
22
- const x = useInternalValueMemoSlot("vizXAccessor", () => accessor(xInput), [
23
- xInput
24
- ]);
25
- const y = useInternalValueMemoSlot("vizYAccessor", () => accessor(yInput), [
26
- yInput
27
- ]);
28
- if (curve !== void 0 && curve !== "linear")
29
- throw new TypeError('LineSeries supports curve="linear" only.');
27
+ const xScale = useSeriesPosition(xId);
28
+ const yScale = useSeriesPosition(yId);
29
+ const x = useInternalValueMemoSlot(
30
+ "vizXAccessor",
31
+ () => seriesAccessor(xInput),
32
+ [xInput]
33
+ );
34
+ const y = useInternalValueMemoSlot(
35
+ "vizYAccessor",
36
+ () => seriesAccessor(yInput),
37
+ [yInput]
38
+ );
39
+ const curveDefinition = resolveSeriesCurve(curve);
30
40
  const data = resolveSignalValue(dataInput);
31
41
  if (!Array.isArray(data))
32
42
  throw new TypeError(
@@ -45,29 +55,38 @@ function LineSeries({
45
55
  "LineSeries"
46
56
  );
47
57
  const path = new Path2D();
48
- let previous;
49
- let inRun = false;
58
+ const captured = inspection ? [] : void 0;
59
+ let runId = 0;
60
+ if (inspection && (xScale.type === "point" || yScale.type === "point")) throw new TypeError("Numeric line inspection requires numeric continuous scales.");
61
+ let run = [];
62
+ const flushRun = () => {
63
+ if (run.length >= 2) {
64
+ const geometry = curveGeometry(curveDefinition, run);
65
+ path.moveTo(geometry.start[0], geometry.start[1]);
66
+ appendCurveForward(path, geometry);
67
+ }
68
+ run = [];
69
+ };
50
70
  for (let i = 0; i < data.length; i++) {
51
71
  const datum = data[i];
52
72
  if (defined && !defined(datum, i, data)) {
53
- previous = void 0;
54
- inRun = false;
73
+ flushRun();
74
+ runId++;
55
75
  continue;
56
76
  }
57
77
  const xv = x(datum, i, data), yv = y(datum, i, data);
58
- if (typeof xv !== "number" || typeof yv !== "number" || !Number.isFinite(xv) || !Number.isFinite(yv)) {
59
- previous = void 0;
60
- inRun = false;
78
+ const px = mapSeriesPosition(xScale, xv), py = mapSeriesPosition(yScale, yv);
79
+ if (px === void 0 || py === void 0) {
80
+ flushRun();
81
+ runId++;
61
82
  continue;
62
83
  }
63
- const point = [xScale.map(xv), yScale.map(yv)];
64
- if (previous) {
65
- if (!inRun) path.moveTo(previous[0], previous[1]);
66
- path.lineTo(point[0], point[1]);
67
- inRun = true;
68
- }
69
- previous = point;
84
+ captured?.push(Object.freeze({ datum, sourceIndex: i, domainX: xv, domainY: yv, anchorLocal: Object.freeze({ x: px, y: py }), run: runId }));
85
+ const point = [px, py];
86
+ run.push(point);
70
87
  }
88
+ flushRun();
89
+ if (inspection && xScale.type !== "point" && yScale.type !== "point") inspection.capture({ observations: captured, xScale, yScale });
71
90
  return /* @__PURE__ */ jsx(
72
91
  Path,
73
92
  {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/features/viz/lib/line-series.tsx"],
4
- "sourcesContent": ["import { Path, resolveSignalValue } from \"@pibbl/core\";\nimport { useInternalValueMemoSlot } from \"@pibbl/core/internal\";\nimport type { LineAccessor, LineCoordinate, LineSeriesProps } from \"./types.js\";\nimport { useScale } from \"./use-scale.js\";\nimport { width, opacity } from \"./paint.js\";\nfunction accessor<D>(\n input: LineAccessor<D>,\n): (datum: D, index: number, data: readonly D[]) => LineCoordinate {\n return typeof input === \"function\"\n ? input\n : (datum) => datum[input] as LineCoordinate;\n}\n/**\n * Draws a scaled line through defined data values, leaving gaps for undefined values.\n *\n * @param props - Data, coordinate accessors, scales, and line styling. See {@link LineSeriesProps}\n * .\n * @returns Pibbl nodes drawing the data as a line series.\n *\n * @see {@link LineSeriesProps}\n */\nexport function LineSeries<D>({\n data: dataInput,\n x: xInput,\n y: yInput,\n xScale: xId,\n yScale: yId,\n defined,\n curve,\n style: styleInput,\n ...eventProps\n}: LineSeriesProps<D>) {\n const xScale = useScale(xId).get();\n const yScale = useScale(yId).get();\n const x = useInternalValueMemoSlot(\"vizXAccessor\", () => accessor(xInput), [\n xInput,\n ]);\n const y = useInternalValueMemoSlot(\"vizYAccessor\", () => accessor(yInput), [\n yInput,\n ]);\n if (curve !== undefined && curve !== \"linear\")\n throw new TypeError('LineSeries supports curve=\"linear\" only.');\n const data = resolveSignalValue(dataInput);\n if (!Array.isArray(data))\n throw new TypeError(\n \"LineSeries data must be an array or a signal containing an array.\",\n );\n const style = resolveSignalValue(styleInput) ?? {};\n const stroke = resolveSignalValue(style.stroke) ?? \"#2563eb\";\n const strokeWidth = width(\n resolveSignalValue(style.strokeWidth) ?? 2,\n \"LineSeries\",\n );\n const alpha = opacity(resolveSignalValue(style.opacity) ?? 1, \"LineSeries\");\n const cursor = resolveSignalValue(style.cursor);\n const lineInteractionWidth = width(\n resolveSignalValue(style.lineInteractionWidth) ?? strokeWidth,\n \"LineSeries\",\n );\n const path = new Path2D();\n let previous: readonly [number, number] | undefined;\n let inRun = false;\n for (let i = 0; i < data.length; i++) {\n const datum = data[i];\n if (defined && !defined(datum, i, data)) {\n previous = undefined;\n inRun = false;\n continue;\n }\n const xv = x(datum, i, data),\n yv = y(datum, i, data);\n if (\n typeof xv !== \"number\" ||\n typeof yv !== \"number\" ||\n !Number.isFinite(xv) ||\n !Number.isFinite(yv)\n ) {\n previous = undefined;\n inRun = false;\n continue;\n }\n const point = [xScale.map(xv), yScale.map(yv)] as const;\n if (previous) {\n if (!inRun) path.moveTo(previous[0], previous[1]);\n path.lineTo(point[0], point[1]);\n inRun = true;\n }\n previous = point;\n }\n return (\n <Path\n {...eventProps}\n style={{\n d: path,\n stroke,\n strokeWidth,\n opacity: alpha,\n cursor,\n lineInteractionWidth,\n }}\n />\n );\n}\n"],
5
- "mappings": "AA0FI;AA1FJ,SAAS,MAAM,0BAA0B;AACzC,SAAS,gCAAgC;AAEzC,SAAS,gBAAgB;AACzB,SAAS,OAAO,eAAe;AAC/B,SAAS,SACP,OACiE;AACjE,SAAO,OAAO,UAAU,aACpB,QACA,CAAC,UAAU,MAAM,KAAK;AAC5B;AAUO,SAAS,WAAc;AAAA,EAC5B,MAAM;AAAA,EACN,GAAG;AAAA,EACH,GAAG;AAAA,EACH,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR;AAAA,EACA;AAAA,EACA,OAAO;AAAA,EACP,GAAG;AACL,GAAuB;AACrB,QAAM,SAAS,SAAS,GAAG,EAAE,IAAI;AACjC,QAAM,SAAS,SAAS,GAAG,EAAE,IAAI;AACjC,QAAM,IAAI,yBAAyB,gBAAgB,MAAM,SAAS,MAAM,GAAG;AAAA,IACzE;AAAA,EACF,CAAC;AACD,QAAM,IAAI,yBAAyB,gBAAgB,MAAM,SAAS,MAAM,GAAG;AAAA,IACzE;AAAA,EACF,CAAC;AACD,MAAI,UAAU,UAAa,UAAU;AACnC,UAAM,IAAI,UAAU,0CAA0C;AAChE,QAAM,OAAO,mBAAmB,SAAS;AACzC,MAAI,CAAC,MAAM,QAAQ,IAAI;AACrB,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AACF,QAAM,QAAQ,mBAAmB,UAAU,KAAK,CAAC;AACjD,QAAM,SAAS,mBAAmB,MAAM,MAAM,KAAK;AACnD,QAAM,cAAc;AAAA,IAClB,mBAAmB,MAAM,WAAW,KAAK;AAAA,IACzC;AAAA,EACF;AACA,QAAM,QAAQ,QAAQ,mBAAmB,MAAM,OAAO,KAAK,GAAG,YAAY;AAC1E,QAAM,SAAS,mBAAmB,MAAM,MAAM;AAC9C,QAAM,uBAAuB;AAAA,IAC3B,mBAAmB,MAAM,oBAAoB,KAAK;AAAA,IAClD;AAAA,EACF;AACA,QAAM,OAAO,IAAI,OAAO;AACxB,MAAI;AACJ,MAAI,QAAQ;AACZ,WAAS,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;AACpC,UAAM,QAAQ,KAAK,CAAC;AACpB,QAAI,WAAW,CAAC,QAAQ,OAAO,GAAG,IAAI,GAAG;AACvC,iBAAW;AACX,cAAQ;AACR;AAAA,IACF;AACA,UAAM,KAAK,EAAE,OAAO,GAAG,IAAI,GACzB,KAAK,EAAE,OAAO,GAAG,IAAI;AACvB,QACE,OAAO,OAAO,YACd,OAAO,OAAO,YACd,CAAC,OAAO,SAAS,EAAE,KACnB,CAAC,OAAO,SAAS,EAAE,GACnB;AACA,iBAAW;AACX,cAAQ;AACR;AAAA,IACF;AACA,UAAM,QAAQ,CAAC,OAAO,IAAI,EAAE,GAAG,OAAO,IAAI,EAAE,CAAC;AAC7C,QAAI,UAAU;AACZ,UAAI,CAAC,MAAO,MAAK,OAAO,SAAS,CAAC,GAAG,SAAS,CAAC,CAAC;AAChD,WAAK,OAAO,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC;AAC9B,cAAQ;AAAA,IACV;AACA,eAAW;AAAA,EACb;AACA,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,OAAO;AAAA,QACL,GAAG;AAAA,QACH;AAAA,QACA;AAAA,QACA,SAAS;AAAA,QACT;AAAA,QACA;AAAA,MACF;AAAA;AAAA,EACF;AAEJ;",
4
+ "sourcesContent": ["import { Path, resolveSignalValue } from \"@pibbl/core\";\nimport { useInternalValueMemoSlot } from \"@pibbl/core/internal\";\nimport type { LineSeriesProps } from \"./types.js\";\nimport {\n appendCurveForward,\n curveGeometry,\n resolveSeriesCurve,\n} from \"./curve-definition.js\";\nimport {\n useSeriesPosition,\n seriesAccessor,\n mapSeriesPosition,\n} from \"./series-position.js\";\nimport { width, opacity } from \"./paint.js\";\n/**\n * Draws a scaled line through defined data values, leaving gaps for undefined values.\n *\n * @param props - Data, coordinate accessors, scales, and line styling. See {@link LineSeriesProps}\n * .\n * @returns Pibbl nodes drawing the data as a line series.\n *\n * @see {@link LineSeriesProps}\n */\nexport function LineSeries<D>({\n data: dataInput,\n x: xInput,\n y: yInput,\n xScale: xId,\n yScale: yId,\n defined,\n inspection,\n curve,\n style: styleInput,\n ...eventProps\n}: LineSeriesProps<D>) {\n const xScale = useSeriesPosition(xId);\n const yScale = useSeriesPosition(yId);\n const x = useInternalValueMemoSlot(\n \"vizXAccessor\",\n () => seriesAccessor(xInput),\n [xInput],\n );\n const y = useInternalValueMemoSlot(\n \"vizYAccessor\",\n () => seriesAccessor(yInput),\n [yInput],\n );\n const curveDefinition = resolveSeriesCurve(curve);\n const data = resolveSignalValue(dataInput);\n if (!Array.isArray(data))\n throw new TypeError(\n \"LineSeries data must be an array or a signal containing an array.\",\n );\n const style = resolveSignalValue(styleInput) ?? {};\n const stroke = resolveSignalValue(style.stroke) ?? \"#2563eb\";\n const strokeWidth = width(\n resolveSignalValue(style.strokeWidth) ?? 2,\n \"LineSeries\",\n );\n const alpha = opacity(resolveSignalValue(style.opacity) ?? 1, \"LineSeries\");\n const cursor = resolveSignalValue(style.cursor);\n const lineInteractionWidth = width(\n resolveSignalValue(style.lineInteractionWidth) ?? strokeWidth,\n \"LineSeries\",\n );\n const path = new Path2D();\n const captured: import(\"../inspection/capture-types.js\").CapturedNumericObservation<D>[] | undefined = inspection ? [] : undefined;\n let runId = 0;\n if (inspection && (xScale.type === \"point\" || yScale.type === \"point\")) throw new TypeError(\"Numeric line inspection requires numeric continuous scales.\");\n let run: (readonly [number, number])[] = [];\n const flushRun = () => {\n if (run.length >= 2) {\n const geometry = curveGeometry(curveDefinition, run);\n path.moveTo(geometry.start[0], geometry.start[1]);\n appendCurveForward(path, geometry);\n }\n run = [];\n };\n for (let i = 0; i < data.length; i++) {\n const datum = data[i];\n if (defined && !defined(datum, i, data)) {\n flushRun();\n runId++;\n continue;\n }\n const xv = x(datum, i, data),\n yv = y(datum, i, data);\n const px = mapSeriesPosition(xScale, xv),\n py = mapSeriesPosition(yScale, yv);\n if (px === undefined || py === undefined) {\n flushRun();\n runId++;\n continue;\n }\n captured?.push(Object.freeze({datum,sourceIndex:i,domainX:xv as number,domainY:yv as number,anchorLocal:Object.freeze({x:px,y:py}),run:runId}));\n const point = [px, py] as const;\n run.push(point);\n }\n flushRun();\n if (inspection && xScale.type !== \"point\" && yScale.type !== \"point\") inspection.capture({observations:captured!,xScale,yScale});\n return (\n <Path\n {...eventProps}\n style={{\n d: path,\n stroke,\n strokeWidth,\n opacity: alpha,\n cursor,\n lineInteractionWidth,\n }}\n />\n );\n}\n"],
5
+ "mappings": "AAqGI;AArGJ,SAAS,MAAM,0BAA0B;AACzC,SAAS,gCAAgC;AAEzC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,OAAO,eAAe;AAUxB,SAAS,WAAc;AAAA,EAC5B,MAAM;AAAA,EACN,GAAG;AAAA,EACH,GAAG;AAAA,EACH,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR;AAAA,EACA;AAAA,EACA;AAAA,EACA,OAAO;AAAA,EACP,GAAG;AACL,GAAuB;AACrB,QAAM,SAAS,kBAAkB,GAAG;AACpC,QAAM,SAAS,kBAAkB,GAAG;AACpC,QAAM,IAAI;AAAA,IACR;AAAA,IACA,MAAM,eAAe,MAAM;AAAA,IAC3B,CAAC,MAAM;AAAA,EACT;AACA,QAAM,IAAI;AAAA,IACR;AAAA,IACA,MAAM,eAAe,MAAM;AAAA,IAC3B,CAAC,MAAM;AAAA,EACT;AACA,QAAM,kBAAkB,mBAAmB,KAAK;AAChD,QAAM,OAAO,mBAAmB,SAAS;AACzC,M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F;AACA,cAAU,KAAK,OAAO,OAAO,EAAC,OAAM,aAAY,GAAE,SAAQ,IAAa,SAAQ,IAAa,aAAY,OAAO,OAAO,EAAC,GAAE,IAAG,GAAE,GAAE,CAAC,GAAE,KAAI,MAAK,CAAC,CAAC;AAC9I,UAAM,QAAQ,CAAC,IAAI,EAAE;AACrB,QAAI,KAAK,KAAK;AAAA,EAChB;AACA,WAAS;AACT,MAAI,cAAc,OAAO,SAAS,WAAW,OAAO,SAAS,QAAS,YAAW,QAAQ,EAAC,cAAa,UAAU,QAAO,OAAM,CAAC;AAC/H,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,OAAO;AAAA,QACL,GAAG;AAAA,QACH;AAAA,QACA;AAAA,QACA,SAAS;AAAA,QACT;AAAA,QACA;AAAA,MACF;AAAA;AAAA,EACF;AAEJ;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,7 @@
1
+ import type { LinearScaleProps } from "./types.js";
2
+ /**
3
+ * Provides a named linear mapping to descendant visualization components.
4
+ * @param props - Identity, domain, range, and children. See {@link LinearScaleProps}.
5
+ * @returns Descendant content within the scale scope.
6
+ */
7
+ export declare function LinearScale(props: LinearScaleProps): import("@pibbl/core").PibblNode;
@@ -0,0 +1,18 @@
1
+ import { resolveSignalValue, useLayoutBox } from "@pibbl/core";
2
+ import { resolveLinearScale } from "./linear-scale.js";
3
+ import { useScaleProvider } from "./scale-provider.js";
4
+ function LinearScale(props) {
5
+ const { width, height } = useLayoutBox();
6
+ useScaleProvider(props.id, "linear", () => resolveLinearScale(
7
+ resolveSignalValue(props.domain),
8
+ resolveSignalValue(props.range),
9
+ resolveSignalValue(props.reverse ?? false),
10
+ width,
11
+ height
12
+ ), [props.domain, props.range, props.reverse, width, height]);
13
+ return props.children;
14
+ }
15
+ export {
16
+ LinearScale
17
+ };
18
+ //# sourceMappingURL=linear-scale-component.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/features/viz/lib/linear-scale-component.ts"],
4
+ "sourcesContent": ["import { resolveSignalValue, useLayoutBox } from \"@pibbl/core\";\nimport type { LinearScaleProps } from \"./types.js\";\nimport { resolveLinearScale } from \"./linear-scale.js\";\nimport { useScaleProvider } from \"./scale-provider.js\";\n/**\n * Provides a named linear mapping to descendant visualization components.\n * @param props - Identity, domain, range, and children. See {@link LinearScaleProps}.\n * @returns Descendant content within the scale scope.\n */\nexport function LinearScale(props: LinearScaleProps) {\n const { width, height } = useLayoutBox();\n useScaleProvider(props.id, \"linear\", () => resolveLinearScale(\n resolveSignalValue(props.domain), resolveSignalValue(props.range),\n resolveSignalValue(props.reverse ?? false), width, height,\n ), [props.domain, props.range, props.reverse, width, height]);\n return props.children;\n}\n"],
5
+ "mappings": "AAAA,SAAS,oBAAoB,oBAAoB;AAEjD,SAAS,0BAA0B;AACnC,SAAS,wBAAwB;AAM1B,SAAS,YAAY,OAAyB;AACnD,QAAM,EAAE,OAAO,OAAO,IAAI,aAAa;AACvC,mBAAiB,MAAM,IAAI,UAAU,MAAM;AAAA,IACzC,mBAAmB,MAAM,MAAM;AAAA,IAAG,mBAAmB,MAAM,KAAK;AAAA,IAChE,mBAAmB,MAAM,WAAW,KAAK;AAAA,IAAG;AAAA,IAAO;AAAA,EACrD,GAAG,CAAC,MAAM,QAAQ,MAAM,OAAO,MAAM,SAAS,OAAO,MAAM,CAAC;AAC5D,SAAO,MAAM;AACf;",
6
+ "names": []
7
+ }
@@ -61,7 +61,7 @@ function resolveLinearScale(domainInput, rangeInput, reverse, width, height) {
61
61
  });
62
62
  }
63
63
  function equalScale(a, b) {
64
- return a.type === b.type && a.domain.length === b.domain.length && a.domain.every((value, index) => Object.is(value, b.domain[index])) && (a.type !== "band" || b.type === "band" && a.bandwidth === b.bandwidth && a.step === b.step) && Object.is(a.range[0], b.range[0]) && Object.is(a.range[1], b.range[1]) && Object.is(a.frame.width, b.frame.width) && Object.is(a.frame.height, b.frame.height);
64
+ return a.type === b.type && (a.type !== "trading-time" || b.type === "trading-time" && a.logicalRange.every((v, i) => v === b.logicalRange[i])) && (a.type !== "symlog" || b.type === "symlog" && a.constant === b.constant) && (a.type !== "point" || b.type === "point" && a.padding === b.padding) && (a.type !== "log" || b.type === "log" && a.base === b.base) && a.domain.length === b.domain.length && a.domain.every((value, index) => Object.is(value, b.domain[index])) && (a.type !== "band" || b.type === "band" && a.bandwidth === b.bandwidth && a.step === b.step) && Object.is(a.range[0], b.range[0]) && Object.is(a.range[1], b.range[1]) && Object.is(a.frame.width, b.frame.width) && Object.is(a.frame.height, b.frame.height);
65
65
  }
66
66
  export {
67
67
  equalScale,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/features/viz/lib/linear-scale.ts"],
4
- "sourcesContent": ["import type {\n LinearDomain,\n ResolvedLinearScale,\n ResolvedScale,\n ScaleRange,\n} from \"./types.js\";\nfunction finite(value: number, field: string): number {\n if (typeof value !== \"number\" || !Number.isFinite(value))\n throw new RangeError(`Scale ${field} must be finite.`);\n return value;\n}\nfunction pair(\n value: readonly number[],\n field: string,\n): readonly [number, number] {\n if (!Array.isArray(value) || value.length !== 2)\n throw new RangeError(`Scale ${field} requires two finite endpoints.`);\n return Object.freeze([finite(value[0], field), finite(value[1], field)]);\n}\nexport function resolveLinearScale(\n domainInput: LinearDomain,\n rangeInput: ScaleRange,\n reverse: boolean,\n width: number,\n height: number,\n): ResolvedLinearScale {\n finite(width, \"frame.width\");\n finite(height, \"frame.height\");\n if (width < 0 || height < 0)\n throw new RangeError(\"Scale allocation must be nonnegative.\");\n if (typeof reverse !== \"boolean\")\n throw new TypeError(\"Scale reverse must be boolean.\");\n const domain = pair(domainInput, \"domain\");\n if (domain[0] === domain[1])\n throw new RangeError(\"Scale domain endpoints must differ.\");\n const original = pair(\n rangeInput === \"width\"\n ? [0, width]\n : rangeInput === \"height\"\n ? [0, height]\n : (rangeInput as readonly number[]),\n \"range\",\n );\n const range = reverse ? pair([original[1], original[0]], \"range\") : original;\n const domainSpan = finite(domain[1] - domain[0], \"domain span\");\n const rangeSpan = finite(range[1] - range[0], \"range span\");\n return Object.freeze({\n type: \"linear\",\n domain,\n range,\n frame: Object.freeze({ x: 0, y: 0, width, height }),\n map(value: number) {\n return finite(\n range[0] +\n ((finite(value, \"map input\") - domain[0]) / domainSpan) * rangeSpan,\n \"mapped output\",\n );\n },\n invert(pixel: number) {\n if (rangeSpan === 0)\n throw new RangeError(\n \"Scale cannot invert a collapsed range; supply a nonzero extent.\",\n );\n return finite(\n domain[0] +\n ((finite(pixel, \"invert input\") - range[0]) / rangeSpan) * domainSpan,\n \"inverted output\",\n );\n },\n ticks(count = 5) {\n if (!Number.isInteger(count) || count < 2 || count > 100)\n throw new RangeError(\n \"Scale ticks count must be an integer from 2 to 100.\",\n );\n return Object.freeze(\n Array.from({ length: count }, (_, i) =>\n i === count - 1\n ? domain[1]\n : finite(domain[0] + (domainSpan * i) / (count - 1), \"tick\"),\n ),\n );\n },\n });\n}\nexport function equalScale(a: ResolvedScale, b: ResolvedScale): boolean {\n return (\n a.type === b.type &&\n a.domain.length === b.domain.length &&\n a.domain.every((value, index) => Object.is(value, b.domain[index])) &&\n (a.type !== \"band\" ||\n (b.type === \"band\" &&\n a.bandwidth === b.bandwidth &&\n a.step === b.step)) &&\n Object.is(a.range[0], b.range[0]) &&\n Object.is(a.range[1], b.range[1]) &&\n Object.is(a.frame.width, b.frame.width) &&\n Object.is(a.frame.height, b.frame.height)\n );\n}\n"],
5
- "mappings": "AAMA,SAAS,OAAO,OAAe,OAAuB;AACpD,MAAI,OAAO,UAAU,YAAY,CAAC,OAAO,SAAS,KAAK;AACrD,UAAM,IAAI,WAAW,SAAS,KAAK,kBAAkB;AACvD,SAAO;AACT;AACA,SAAS,KACP,OACA,OAC2B;AAC3B,MAAI,CAAC,MAAM,QAAQ,KAAK,KAAK,MAAM,WAAW;AAC5C,UAAM,IAAI,WAAW,SAAS,KAAK,iCAAiC;AACtE,SAAO,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AA,QAC7D;AAAA,MACF;AAAA,IACF;AAAA,IACA,MAAM,QAAQ,GAAG;AACf,UAAI,CAAC,OAAO,UAAU,KAAK,KAAK,QAAQ,KAAK,QAAQ;AACnD,cAAM,IAAI;AAAA,UACR;AAAA,QACF;AACF,aAAO,OAAO;AAAA,QACZ,MAAM;AAAA,UAAK,EAAE,QAAQ,MAAM;AAAA,UAAG,CAAC,GAAG,MAChC,MAAM,QAAQ,IACV,OAAO,CAAC,IACR,OAAO,OAAO,CAAC,IAAK,aAAa,KAAM,QAAQ,IAAI,MAAM;AAAA,QAC/D;AAAA,MACF;AAAA,IACF;AAAA,EACF,CAAC;AACH;AACO,SAAS,WAAW,GAAkB,GAA2B;AACtE,SACE,EAAE,SAAS,EAAE,QACb,EAAE,OAAO,WAAW,EAAE,OAAO,UAC7B,EAAE,OAAO,MAAM,CAAC,OAAO,UAAU,OAAO,GAAG,OAAO,EAAE,OAAO,KAAK,CAAC,CAAC,MACjE,EAAE,SAAS,UACT,EAAE,SAAS,UACV,EAAE,cAAc,EAAE,aAClB,EAAE,SAAS,EAAE,SACjB,OAAO,GAAG,EAAE,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,KAChC,OAAO,GAAG,EAAE,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,KAChC,OAAO,GAAG,EAAE,MAAM,OAAO,EAAE,MAAM,KAAK,KACtC,OAAO,GAAG,EAAE,MAAM,QAAQ,EAAE,MAAM,MAAM;AAE5C;",
4
+ "sourcesContent": ["import type {\n LinearDomain,\n ResolvedLinearScale,\n ResolvedScale,\n ScaleRange,\n} from \"./types.js\";\nfunction finite(value: number, field: string): number {\n if (typeof value !== \"number\" || !Number.isFinite(value))\n throw new RangeError(`Scale ${field} must be finite.`);\n return value;\n}\nfunction pair(\n value: readonly number[],\n field: string,\n): readonly [number, number] {\n if (!Array.isArray(value) || value.length !== 2)\n throw new RangeError(`Scale ${field} requires two finite endpoints.`);\n return Object.freeze([finite(value[0], field), finite(value[1], field)]);\n}\nexport function resolveLinearScale(\n domainInput: LinearDomain,\n rangeInput: ScaleRange,\n reverse: boolean,\n width: number,\n height: number,\n): ResolvedLinearScale {\n finite(width, \"frame.width\");\n finite(height, \"frame.height\");\n if (width < 0 || height < 0)\n throw new RangeError(\"Scale allocation must be nonnegative.\");\n if (typeof reverse !== \"boolean\")\n throw new TypeError(\"Scale reverse must be boolean.\");\n const domain = pair(domainInput, \"domain\");\n if (domain[0] === domain[1])\n throw new RangeError(\"Scale domain endpoints must differ.\");\n const original = pair(\n rangeInput === \"width\"\n ? [0, width]\n : rangeInput === \"height\"\n ? [0, height]\n : (rangeInput as readonly number[]),\n \"range\",\n );\n const range = reverse ? pair([original[1], original[0]], \"range\") : original;\n const domainSpan = finite(domain[1] - domain[0], \"domain span\");\n const rangeSpan = finite(range[1] - range[0], \"range span\");\n return Object.freeze({\n type: \"linear\",\n domain,\n range,\n frame: Object.freeze({ x: 0, y: 0, width, height }),\n map(value: number) {\n return finite(\n range[0] +\n ((finite(value, \"map input\") - domain[0]) / domainSpan) * rangeSpan,\n \"mapped output\",\n );\n },\n invert(pixel: number) {\n if (rangeSpan === 0)\n throw new RangeError(\n \"Scale cannot invert a collapsed range; supply a nonzero extent.\",\n );\n return finite(\n domain[0] +\n ((finite(pixel, \"invert input\") - range[0]) / rangeSpan) * domainSpan,\n \"inverted output\",\n );\n },\n ticks(count = 5) {\n if (!Number.isInteger(count) || count < 2 || count > 100)\n throw new RangeError(\n \"Scale ticks count must be an integer from 2 to 100.\",\n );\n return Object.freeze(\n Array.from({ length: count }, (_, i) =>\n i === count - 1\n ? domain[1]\n : finite(domain[0] + (domainSpan * i) / (count - 1), \"tick\"),\n ),\n );\n },\n });\n}\nexport function equalScale(a: ResolvedScale, b: ResolvedScale): boolean {\n return (\n a.type === b.type &&\n (a.type !== \"trading-time\" ||\n (b.type === \"trading-time\" &&\n a.logicalRange.every((v, i) => v === b.logicalRange[i]))) &&\n (a.type !== \"symlog\" ||\n (b.type === \"symlog\" && a.constant === b.constant)) &&\n (a.type !== \"point\" || (b.type === \"point\" && a.padding === b.padding)) &&\n (a.type !== \"log\" || (b.type === \"log\" && a.base === b.base)) &&\n a.domain.length === b.domain.length &&\n a.domain.every((value, index) => Object.is(value, b.domain[index])) &&\n (a.type !== \"band\" ||\n (b.type === \"band\" &&\n a.bandwidth === b.bandwidth &&\n a.step === b.step)) &&\n Object.is(a.range[0], b.range[0]) &&\n Object.is(a.range[1], b.range[1]) &&\n Object.is(a.frame.width, b.frame.width) &&\n Object.is(a.frame.height, b.frame.height)\n );\n}\n"],
5
+ "mappings": "AAMA,SAAS,OAAO,OAAe,OAAuB;AACpD,MAAI,OAAO,UAAU,YAAY,CAAC,OAAO,SAAS,KAAK;AACrD,UAAM,IAAI,WAAW,SAAS,KAAK,kBAAkB;AACvD,SAAO;AACT;AACA,SAAS,KACP,OACA,OAC2B;AAC3B,MAAI,CAAC,MAAM,QAAQ,KAAK,KAAK,MAAM,WAAW;AAC5C,UAAM,IAAI,WAAW,SAAS,KAAK,iCAAiC;AACtE,SAAO,OAAO,OAAO,CAAC,OAAO,MAAM,CAAC,GAAG,KAAK,GAAG,OAAO,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC;AACzE;AACO,SAAS,mBACd,aACA,YACA,SACA,OACA,QACqB;AACrB,SAAO,OAAO,aAAa;AAC3B,SAAO,QAAQ,cAAc;AAC7B,MAAI,QAAQ,KAAK,SAAS;AACxB,UAAM,IAAI,WAAW,uCAAuC;AAC9D,MAAI,OAAO,YAAY;AACrB,UAAM,IAAI,UAAU,gCAAgC;AACtD,QAAM,SAAS,KAAK,aAAa,QAAQ;AACzC,MAAI,OAAO,CAAC,MAAM,OAAO,CAAC;AACxB,UAAM,IAAI,WAAW,qCAAqC;AAC5D,QAAM,WAAW;AAAA,IACf,eAAe,UACX,CAAC,GAAG,KAAK,IACT,eAAe,WACb,CAAC,GAAG,MAAM,IACT;AAAA,IACP;AAAA,EACF;AACA,QAAM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AAa,CAAC,CAAC,OACzD,EAAE,SAAS,YACT,EAAE,SAAS,YAAY,EAAE,aAAa,EAAE,cAC1C,EAAE,SAAS,WAAY,EAAE,SAAS,WAAW,EAAE,YAAY,EAAE,aAC7D,EAAE,SAAS,SAAU,EAAE,SAAS,SAAS,EAAE,SAAS,EAAE,SACvD,EAAE,OAAO,WAAW,EAAE,OAAO,UAC7B,EAAE,OAAO,MAAM,CAAC,OAAO,UAAU,OAAO,GAAG,OAAO,EAAE,OAAO,KAAK,CAAC,CAAC,MACjE,EAAE,SAAS,UACT,EAAE,SAAS,UACV,EAAE,cAAc,EAAE,aAClB,EAAE,SAAS,EAAE,SACjB,OAAO,GAAG,EAAE,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,KAChC,OAAO,GAAG,EAAE,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,KAChC,OAAO,GAAG,EAAE,MAAM,OAAO,EAAE,MAAM,KAAK,KACtC,OAAO,GAAG,EAAE,MAAM,QAAQ,EAAE,MAAM,MAAM;AAE5C;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,7 @@
1
+ import type { LogScaleProps } from "./types.js";
2
+ /**
3
+ * Provides a named positive logarithmic mapping to descendant marks and axes.
4
+ * @param props - Identity, positive domain, range, and optional tick base. See {@link LogScaleProps}.
5
+ * @returns Descendant content within the logarithmic scale scope.
6
+ */
7
+ export declare function LogScale(props: LogScaleProps): import("@pibbl/core").PibblNode;
@@ -0,0 +1,19 @@
1
+ import { resolveSignalValue, useLayoutBox } from "@pibbl/core";
2
+ import { resolveLogScale } from "./log-scale.js";
3
+ import { useScaleProvider } from "./scale-provider.js";
4
+ function LogScale(props) {
5
+ const { width, height } = useLayoutBox();
6
+ useScaleProvider(props.id, "log", () => resolveLogScale(
7
+ resolveSignalValue(props.domain),
8
+ resolveSignalValue(props.range),
9
+ resolveSignalValue(props.reverse ?? false),
10
+ width,
11
+ height,
12
+ resolveSignalValue(props.base ?? 10)
13
+ ), [props.domain, props.range, props.reverse, props.base, width, height]);
14
+ return props.children;
15
+ }
16
+ export {
17
+ LogScale
18
+ };
19
+ //# sourceMappingURL=log-scale-component.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/features/viz/lib/log-scale-component.ts"],
4
+ "sourcesContent": ["import { resolveSignalValue, useLayoutBox } from \"@pibbl/core\";\nimport type { LogScaleProps } from \"./types.js\";\nimport { resolveLogScale } from \"./log-scale.js\";\nimport { useScaleProvider } from \"./scale-provider.js\";\n/**\n * Provides a named positive logarithmic mapping to descendant marks and axes.\n * @param props - Identity, positive domain, range, and optional tick base. See {@link LogScaleProps}.\n * @returns Descendant content within the logarithmic scale scope.\n */\nexport function LogScale(props: LogScaleProps) {\n const { width, height } = useLayoutBox();\n useScaleProvider(props.id, \"log\", () => resolveLogScale(\n resolveSignalValue(props.domain), resolveSignalValue(props.range),\n resolveSignalValue(props.reverse ?? false), width, height, resolveSignalValue(props.base ?? 10),\n ), [props.domain, props.range, props.reverse, props.base, width, height]);\n return props.children;\n}\n"],
5
+ "mappings": "AAAA,SAAS,oBAAoB,oBAAoB;AAEjD,SAAS,uBAAuB;AAChC,SAAS,wBAAwB;AAM1B,SAAS,SAAS,OAAsB;AAC7C,QAAM,EAAE,OAAO,OAAO,IAAI,aAAa;AACvC,mBAAiB,MAAM,IAAI,OAAO,MAAM;AAAA,IACtC,mBAAmB,MAAM,MAAM;AAAA,IAAG,mBAAmB,MAAM,KAAK;AAAA,IAChE,mBAAmB,MAAM,WAAW,KAAK;AAAA,IAAG;AAAA,IAAO;AAAA,IAAQ,mBAAmB,MAAM,QAAQ,EAAE;AAAA,EAChG,GAAG,CAAC,MAAM,QAAQ,MAAM,OAAO,MAAM,SAAS,MAAM,MAAM,OAAO,MAAM,CAAC;AACxE,SAAO,MAAM;AACf;",
6
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ import type { LinearDomain, ResolvedLogScale, ScaleRange } from "./types.js";
2
+ export declare function resolveLogScale(domainInput: LinearDomain, range: ScaleRange, reverse: boolean, width: number, height: number, base: number): ResolvedLogScale;
@@ -0,0 +1,53 @@
1
+ import { resolveLinearScale } from "./linear-scale.js";
2
+ function positive(value, field) {
3
+ if (typeof value !== "number" || !Number.isFinite(value) || value <= 0)
4
+ throw new RangeError(`LogScale ${field} must be finite and positive.`);
5
+ return value;
6
+ }
7
+ function resolveLogScale(domainInput, range, reverse, width, height, base) {
8
+ if (typeof base !== "number" || !Number.isFinite(base) || base <= 1)
9
+ throw new RangeError("LogScale base must be finite and greater than one.");
10
+ if (!Array.isArray(domainInput) || domainInput.length !== 2)
11
+ throw new RangeError("LogScale domain requires two positive endpoints.");
12
+ const domain = Object.freeze([positive(domainInput[0], "domain"), positive(domainInput[1], "domain")]);
13
+ const logarithm = (value) => Math.log(positive(value, "map input"));
14
+ const mapping = resolveLinearScale([logarithm(domain[0]), logarithm(domain[1])], range, reverse, width, height);
15
+ return Object.freeze({
16
+ ...mapping,
17
+ type: "log",
18
+ domain,
19
+ base,
20
+ map(value) {
21
+ return mapping.map(logarithm(value));
22
+ },
23
+ invert(pixel) {
24
+ if (pixel === mapping.range[0] && mapping.range[0] !== mapping.range[1]) return domain[0];
25
+ if (pixel === mapping.range[1] && mapping.range[0] !== mapping.range[1]) return domain[1];
26
+ return positive(Math.exp(mapping.invert(pixel)), "inverted output");
27
+ },
28
+ ticks(count = 5) {
29
+ if (!Number.isInteger(count) || count < 2 || count > 100)
30
+ throw new RangeError("LogScale ticks count must be an integer from 2 to 100.");
31
+ if (count === 2) return Object.freeze([...domain]);
32
+ const lo = Math.min(...domain), hi = Math.max(...domain);
33
+ const first = Math.floor(Math.log(lo) / Math.log(base)) + 1;
34
+ const last = Math.ceil(Math.log(hi) / Math.log(base)) - 1;
35
+ if (!Number.isSafeInteger(first) || !Number.isSafeInteger(last))
36
+ throw new RangeError("LogScale tick exponents exceed numeric precision; choose a larger base.");
37
+ const stride = Math.max(1, Math.ceil((last - first + 1) / (count - 2)));
38
+ const ticks = [lo];
39
+ for (let i = 0; i < count - 2; i++) {
40
+ const exponent = first + i * stride;
41
+ if (exponent > last) break;
42
+ const value = base ** exponent;
43
+ if (Number.isFinite(value) && value > ticks[ticks.length - 1] && value < hi) ticks.push(value);
44
+ }
45
+ ticks.push(hi);
46
+ return Object.freeze(domain[0] > domain[1] ? ticks.reverse() : ticks);
47
+ }
48
+ });
49
+ }
50
+ export {
51
+ resolveLogScale
52
+ };
53
+ //# sourceMappingURL=log-scale.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/features/viz/lib/log-scale.ts"],
4
+ "sourcesContent": ["import type { LinearDomain, ResolvedLogScale, ScaleRange } from \"./types.js\";\nimport { resolveLinearScale } from \"./linear-scale.js\";\nfunction positive(value: number, field: string): number {\n if (typeof value !== \"number\" || !Number.isFinite(value) || value <= 0)\n throw new RangeError(`LogScale ${field} must be finite and positive.`);\n return value;\n}\nexport function resolveLogScale(domainInput: LinearDomain, range: ScaleRange, reverse: boolean, width: number, height: number, base: number): ResolvedLogScale {\n if (typeof base !== \"number\" || !Number.isFinite(base) || base <= 1)\n throw new RangeError(\"LogScale base must be finite and greater than one.\");\n if (!Array.isArray(domainInput) || domainInput.length !== 2)\n throw new RangeError(\"LogScale domain requires two positive endpoints.\");\n const domain = Object.freeze([positive(domainInput[0], \"domain\"), positive(domainInput[1], \"domain\")] as const);\n const logarithm = (value: number) => Math.log(positive(value, \"map input\"));\n const mapping = resolveLinearScale([logarithm(domain[0]), logarithm(domain[1])], range, reverse, width, height);\n return Object.freeze({\n ...mapping, type: \"log\", domain, base,\n map(value: number) { return mapping.map(logarithm(value)); },\n invert(pixel: number) {\n if (pixel === mapping.range[0] && mapping.range[0] !== mapping.range[1]) return domain[0];\n if (pixel === mapping.range[1] && mapping.range[0] !== mapping.range[1]) return domain[1];\n return positive(Math.exp(mapping.invert(pixel)), \"inverted output\");\n },\n ticks(count = 5) {\n if (!Number.isInteger(count) || count < 2 || count > 100)\n throw new RangeError(\"LogScale ticks count must be an integer from 2 to 100.\");\n if (count === 2) return Object.freeze([...domain]);\n const lo = Math.min(...domain), hi = Math.max(...domain);\n const first = Math.floor(Math.log(lo) / Math.log(base)) + 1;\n const last = Math.ceil(Math.log(hi) / Math.log(base)) - 1;\n if (!Number.isSafeInteger(first) || !Number.isSafeInteger(last))\n throw new RangeError(\"LogScale tick exponents exceed numeric precision; choose a larger base.\");\n const stride = Math.max(1, Math.ceil((last - first + 1) / (count - 2)));\n const ticks: number[] = [lo];\n for (let i = 0; i < count - 2; i++) {\n const exponent = first + i * stride;\n if (exponent > last) break;\n const value = base ** exponent;\n if (Number.isFinite(value) && value > ticks[ticks.length - 1] && value < hi) ticks.push(value);\n }\n ticks.push(hi);\n return Object.freeze(domain[0] > domain[1] ? ticks.reverse() : ticks);\n },\n });\n}\n"],
5
+ "mappings": "AACA,SAAS,0BAA0B;AACnC,SAAS,SAAS,OAAe,OAAuB;AACtD,MAAI,OAAO,UAAU,YAAY,CAAC,OAAO,SAAS,KAAK,KAAK,SAAS;AACnE,UAAM,IAAI,WAAW,YAAY,KAAK,+BAA+B;AACvE,SAAO;AACT;AACO,SAAS,gBAAgB,aAA2B,OAAmB,SAAkB,OAAe,QAAgB,MAAgC;AAC7J,MAAI,OAAO,SAAS,YAAY,CAAC,OAAO,SAAS,IAAI,KAAK,QAAQ;AAChE,UAAM,IAAI,WAAW,oDAAoD;AAC3E,MAAI,CAAC,MAAM,QAAQ,WAAW,KAAK,YAAY,WAAW;AACxD,UAAM,IAAI,WAAW,kDAAkD;AACzE,QAAM,SAAS,OAAO,OAAO,CAAC,SAAS,YAAY,CAAC,GAAG,QAAQ,GAAG,SAAS,YAAY,CAAC,GAAG,QAAQ,CAAC,CAAU;AAC9G,QAAM,YAAY,CAAC,UAAkB,KAAK,IAAI,SAAS,OAAO,WAAW,CAAC;AAC1E,QAAM,UAAU,mBAAmB,CAAC,UAAU,OAAO,CAAC,CAA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AAS,IAAI,GAAG,IAAI,QAAQ,GAAG,KAAK;AAClC,cAAM,WAAW,QAAQ,IAAI;AAC7B,YAAI,WAAW,KAAM;AACrB,cAAM,QAAQ,QAAQ;AACtB,YAAI,OAAO,SAAS,KAAK,KAAK,QAAQ,MAAM,MAAM,SAAS,CAAC,KAAK,QAAQ,GAAI,OAAM,KAAK,KAAK;AAAA,MAC/F;AACA,YAAM,KAAK,EAAE;AACb,aAAO,OAAO,OAAO,OAAO,CAAC,IAAI,OAAO,CAAC,IAAI,MAAM,QAAQ,IAAI,KAAK;AAAA,IACtE;AAAA,EACF,CAAC;AACH;",
6
+ "names": []
7
+ }
@@ -0,0 +1,11 @@
1
+ import { type SeriesCurve } from "./curve-definition.js";
2
+ /**
3
+ * Returns the immutable monotone-X cubic Hermite definition.
4
+ *
5
+ * It uses weighted harmonic interior slopes and limited one-sided endpoint slopes, preserving every observation,
6
+ * flat segment, and local extremum without sorting data. Each run must have strictly ascending
7
+ * or strictly descending x coordinates.
8
+ *
9
+ * @returns The named {@link SeriesCurve} definition.
10
+ */
11
+ export declare function monotoneX(): SeriesCurve;
@@ -0,0 +1,63 @@
1
+ import {
2
+ createSeriesCurve
3
+ } from "./curve-definition.js";
4
+ function endpointSlope(h0, h1, first, second) {
5
+ let slope = ((2 * h0 + h1) * first - h0 * second) / (h0 + h1);
6
+ if (Math.sign(slope) !== Math.sign(first)) return 0;
7
+ if (Math.sign(first) !== Math.sign(second) && Math.abs(slope) > Math.abs(3 * first))
8
+ slope = 3 * first;
9
+ return slope;
10
+ }
11
+ function monotoneSegments(points) {
12
+ if (points.length < 2) return [];
13
+ const direction = points[1][0] > points[0][0] ? 1 : -1;
14
+ const x = points.map((point) => direction * point[0]);
15
+ const h = [];
16
+ const delta = [];
17
+ for (let i = 0; i < points.length - 1; i++) {
18
+ const width = x[i + 1] - x[i];
19
+ if (!Number.isFinite(width) || width <= 0)
20
+ throw new RangeError(
21
+ "monotoneX requires strictly ascending or descending finite x coordinates."
22
+ );
23
+ h.push(width);
24
+ delta.push((points[i + 1][1] - points[i][1]) / width);
25
+ }
26
+ const slopes = new Array(points.length);
27
+ if (points.length === 2) slopes[0] = slopes[1] = delta[0];
28
+ else {
29
+ slopes[0] = endpointSlope(h[0], h[1], delta[0], delta[1]);
30
+ slopes[points.length - 1] = endpointSlope(
31
+ h.at(-1),
32
+ h.at(-2),
33
+ delta.at(-1),
34
+ delta.at(-2)
35
+ );
36
+ for (let i = 1; i < points.length - 1; i++) {
37
+ const previous = delta[i - 1], next = delta[i];
38
+ slopes[i] = previous === 0 || next === 0 || Math.sign(previous) !== Math.sign(next) ? 0 : 3 * (h[i - 1] + h[i]) / ((2 * h[i] + h[i - 1]) / previous + (h[i] + 2 * h[i - 1]) / next);
39
+ }
40
+ }
41
+ return points.slice(1).map((end, index) => {
42
+ const start = points[index], width = h[index];
43
+ const control1 = [
44
+ start[0] + (end[0] - start[0]) / 3,
45
+ start[1] + slopes[index] * width / 3
46
+ ];
47
+ const control2 = [
48
+ end[0] - (end[0] - start[0]) / 3,
49
+ end[1] - slopes[index + 1] * width / 3
50
+ ];
51
+ if (![...control1, ...control2, ...end].every(Number.isFinite))
52
+ throw new RangeError("monotoneX generated non-finite cubic controls.");
53
+ return Object.freeze({ end, control1, control2 });
54
+ });
55
+ }
56
+ const monotone = /* @__PURE__ */ createSeriesCurve(monotoneSegments);
57
+ function monotoneX() {
58
+ return monotone;
59
+ }
60
+ export {
61
+ monotoneX
62
+ };
63
+ //# sourceMappingURL=monotone-curve.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/features/viz/lib/monotone-curve.ts"],
4
+ "sourcesContent": ["import {\n createSeriesCurve,\n type SeriesCurve,\n type SeriesCurvePoint,\n} from \"./curve-definition.js\";\n\nfunction endpointSlope(\n h0: number,\n h1: number,\n first: number,\n second: number,\n): number {\n let slope = ((2 * h0 + h1) * first - h0 * second) / (h0 + h1);\n if (Math.sign(slope) !== Math.sign(first)) return 0;\n if (\n Math.sign(first) !== Math.sign(second) &&\n Math.abs(slope) > Math.abs(3 * first)\n )\n slope = 3 * first;\n return slope;\n}\n\nfunction monotoneSegments(points: readonly SeriesCurvePoint[]) {\n if (points.length < 2) return [];\n const direction = points[1][0] > points[0][0] ? 1 : -1;\n const x = points.map((point) => direction * point[0]);\n const h: number[] = [];\n const delta: number[] = [];\n for (let i = 0; i < points.length - 1; i++) {\n const width = x[i + 1] - x[i];\n if (!Number.isFinite(width) || width <= 0)\n throw new RangeError(\n \"monotoneX requires strictly ascending or descending finite x coordinates.\",\n );\n h.push(width);\n delta.push((points[i + 1][1] - points[i][1]) / width);\n }\n const slopes = new Array<number>(points.length);\n if (points.length === 2) slopes[0] = slopes[1] = delta[0];\n else {\n slopes[0] = endpointSlope(h[0], h[1], delta[0], delta[1]);\n slopes[points.length - 1] = endpointSlope(\n h.at(-1)!,\n h.at(-2)!,\n delta.at(-1)!,\n delta.at(-2)!,\n );\n for (let i = 1; i < points.length - 1; i++) {\n const previous = delta[i - 1],\n next = delta[i];\n slopes[i] =\n previous === 0 || next === 0 || Math.sign(previous) !== Math.sign(next)\n ? 0\n : (3 * (h[i - 1] + h[i])) /\n ((2 * h[i] + h[i - 1]) / previous + (h[i] + 2 * h[i - 1]) / next);\n }\n }\n return points.slice(1).map((end, index) => {\n const start = points[index],\n width = h[index];\n const control1: SeriesCurvePoint = [\n start[0] + (end[0] - start[0]) / 3,\n start[1] + (slopes[index] * width) / 3,\n ];\n const control2: SeriesCurvePoint = [\n end[0] - (end[0] - start[0]) / 3,\n end[1] - (slopes[index + 1] * width) / 3,\n ];\n if (![...control1, ...control2, ...end].every(Number.isFinite))\n throw new RangeError(\"monotoneX generated non-finite cubic controls.\");\n return Object.freeze({ end, control1, control2 });\n });\n}\n\nconst monotone = /* @__PURE__ */ createSeriesCurve(monotoneSegments);\n\n/**\n * Returns the immutable monotone-X cubic Hermite definition.\n *\n * It uses weighted harmonic interior slopes and limited one-sided endpoint slopes, preserving every observation,\n * flat segment, and local extremum without sorting data. Each run must have strictly ascending\n * or strictly descending x coordinates.\n *\n * @returns The named {@link SeriesCurve} definition.\n */\nexport function monotoneX(): SeriesCurve {\n return monotone;\n}\n"],
5
+ "mappings": "AAAA;AAAA,EACE;AAAA,OAGK;AAEP,SAAS,cACP,IACA,IACA,OACA,QACQ;AACR,MAAI,UAAU,IAAI,KAAK,MAAM,QAAQ,KAAK,WAAW,KAAK;AAC1D,MAAI,KAAK,KAAK,KAAK,MAAM,KAAK,KAAK,KAAK,EAAG,QAAO;AAClD,MACE,KAAK,KAAK,KAAK,MAAM,KAAK,KAAK,MAAM,KACrC,KAAK,IAAI,KAAK,IAAI,KAAK,IAAI,IAAI,KAAK;AAEpC,YAAQ,IAAI;AACd,SAAO;AACT;AAEA,SAAS,iBAAiB,QAAqC;AAC7D,MAAI,OAAO,SAAS,EAAG,QAAO,CAAC;AAC/B,QAAM,YAAY,OAAO,CAAC,EAAE,CAAC,IAAI,OAAO,CAAC,EAAE,CAAC,IAAI,IAAI;AACpD,QAAM,IAAI,OAAO,IAAI,CAAC,UAAU,YAAY,MAAM,CAAC,CAAC;AACpD,QAAM,IAAc,CAAC;AACrB,QAAM,QAAkB,CAAC;AACzB,WAAS,IAAI,GAAG,IAAI,OAAO,SAAS,GAAG,KAAK;AAC1C,UAAM,QAAQ,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC;AAC5B,QAAI,CAAC,OAAO,SAAS,KAAK,KAAK,SAAS;AACtC,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AACF,MAAE,KAAK,KAAK;AACZ,UAAM,MAAM,OAAO,IAAI,CAAC,EAAE,CAAC,IAAI,OAAO,CAAC,EAAE,CAAC,KAAK,KAAK;AAAA,EACtD;AACA,QAAM,SAAS,IAAI,MAAc,OAAO,MAAM;AAC9C,MAAI,OAAO,WAAW,EAAG,QAAO,CAAC,IAAI,OAAO,CAAC,IAAI,MAAM,CAAC;AAAA,OACnD;AACH,WAAO,CAAC,I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AC;AAAA,EAClD,CAAC;AACH;AAEA,MAAM,WAA2B,kCAAkB,gBAAgB;AAW5D,SAAS,YAAyB;AACvC,SAAO;AACT;",
6
+ "names": []
7
+ }
@@ -1,10 +1,10 @@
1
- import type { ResolvedLinearScale } from "./types.js";
1
+ import type { ResolvedContinuousScale } from "./types.js";
2
2
  import type { PointAccessor } from "./point-types.js";
3
3
  /**
4
4
  * Coordinate accessors, resolved scales, and candidate filtering for a nearest-point search.
5
5
  *
6
6
  * @see {@link PointAccessor}
7
- * @see {@link ResolvedLinearScale}
7
+ * @see {@link ResolvedContinuousScale}
8
8
  * @see {@link nearestPoint}
9
9
  */
10
10
  export interface NearestPointOptions<D> {
@@ -12,10 +12,10 @@ export interface NearestPointOptions<D> {
12
12
  readonly x: PointAccessor<D>;
13
13
  /** Property key or callback extracting the vertical domain coordinate. See {@link PointAccessor}. */
14
14
  readonly y: PointAccessor<D>;
15
- /** The scale used to map horizontal data coordinates. See {@link ResolvedLinearScale}. */
16
- readonly xScale: ResolvedLinearScale;
17
- /** The scale used to map vertical data coordinates. See {@link ResolvedLinearScale}. */
18
- readonly yScale: ResolvedLinearScale;
15
+ /** The scale used to map horizontal data coordinates. See {@link ResolvedContinuousScale}. */
16
+ readonly xScale: ResolvedContinuousScale;
17
+ /** The scale used to map vertical data coordinates. See {@link ResolvedContinuousScale}. */
18
+ readonly yScale: ResolvedContinuousScale;
19
19
  /**
20
20
  * Returns whether a datum contributes drawable or queryable coordinates. See
21
21
  * {@link NearestPointOptions}.
@@ -57,12 +57,12 @@ export interface NearestPoint<D> {
57
57
  *
58
58
  * @param values - Candidate domain values.
59
59
  * @param rangeValue - Pointer coordinate in the scale's range.
60
- * @param scale - Scale mapping candidates into range coordinates. See {@link ResolvedLinearScale}.
60
+ * @param scale - Scale mapping candidates into range coordinates. See {@link ResolvedContinuousScale}.
61
61
  * @returns The nearest domain value, or undefined when no candidate can be selected.
62
62
  *
63
- * @see {@link ResolvedLinearScale}
63
+ * @see {@link ResolvedContinuousScale}
64
64
  */
65
- export declare function nearestDomainValue(values: readonly number[], rangeValue: number, scale: ResolvedLinearScale): number | undefined;
65
+ export declare function nearestDomainValue(values: readonly number[], rangeValue: number, scale: ResolvedContinuousScale): number | undefined;
66
66
  /**
67
67
  * Finds the nearest defined datum in scaled coordinates, subject to an optional maximum distance.
68
68
  *
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/features/viz/lib/nearest.ts"],
4
- "sourcesContent": ["import type { ResolvedLinearScale } from \"./types.js\";\nimport type { PointAccessor } from \"./point-types.js\";\nimport { finiteCoordinate, pointAccessor, pointData } from \"./point-data.js\";\n/**\n * Coordinate accessors, resolved scales, and candidate filtering for a nearest-point search.\n *\n * @see {@link PointAccessor}\n * @see {@link ResolvedLinearScale}\n * @see {@link nearestPoint}\n */\nexport interface NearestPointOptions<D> {\n /** Property key or callback extracting the horizontal domain coordinate. See {@link PointAccessor}. */\n readonly x: PointAccessor<D>;\n /** Property key or callback extracting the vertical domain coordinate. See {@link PointAccessor}. */\n readonly y: PointAccessor<D>;\n /** The scale used to map horizontal data coordinates. See {@link ResolvedLinearScale}. */\n readonly xScale: ResolvedLinearScale;\n /** The scale used to map vertical data coordinates. See {@link ResolvedLinearScale}. */\n readonly yScale: ResolvedLinearScale;\n /**\n * Returns whether a datum contributes drawable or queryable coordinates. See\n * {@link NearestPointOptions}.\n * @param datum - Datum to test.\n * @param index - Zero-based index in the source data.\n * @param data - Complete source data array.\n * @returns Whether this datum should participate in the series or query.\n */\n readonly defined?: (datum: D, index: number, data: readonly D[]) => boolean;\n /** Maximum distance accepted by the query. See {@link NearestPointOptions}. */\n readonly maxDistance?: number;\n}\n/**\n * The selected datum, source index, mapped coordinates, and distance from the query point.\n *\n * @see {@link nearestPoint}\n */\nexport interface NearestPoint<D> {\n /** The original data item selected by this result. See {@link NearestPoint}. */\n readonly datum: D;\n /** Index of the selected datum in its source data. See {@link NearestPoint}. */\n readonly index: number;\n /**\n * Horizontal coordinate or displacement in the containing coordinate system. See\n * {@link NearestPoint}.\n */\n readonly x: number;\n /**\n * Vertical coordinate or displacement in the containing coordinate system. See\n * {@link NearestPoint}.\n */\n readonly y: number;\n /** Distance measured in this query or guide's coordinate system. See {@link NearestPoint}. */\n readonly distance: number;\n}\nfunction finite(value: unknown, name: string): asserts value is number {\n if (!finiteCoordinate(value)) throw new RangeError(`${name} must be finite.`);\n}\n/**\n * Finds the domain value nearest to a logical range coordinate; returns undefined for no\n * candidate.\n *\n * @param values - Candidate domain values.\n * @param rangeValue - Pointer coordinate in the scale's range.\n * @param scale - Scale mapping candidates into range coordinates. See {@link ResolvedLinearScale}.\n * @returns The nearest domain value, or undefined when no candidate can be selected.\n *\n * @see {@link ResolvedLinearScale}\n */\nexport function nearestDomainValue(\n values: readonly number[],\n rangeValue: number,\n scale: ResolvedLinearScale,\n): number | undefined {\n pointData(values, \"nearestDomainValue\");\n finite(rangeValue, \"nearestDomainValue rangeValue\");\n let best: number | undefined,\n distance = Infinity;\n for (const value of values) {\n if (!finiteCoordinate(value)) continue;\n const next = Math.abs(scale.map(value) - rangeValue);\n finite(next, \"nearestDomainValue distance\");\n if (next < distance) {\n best = value;\n distance = next;\n }\n }\n return best;\n}\n/**\n * Finds the nearest defined datum in scaled coordinates, subject to an optional maximum distance.\n *\n * @param data - Candidate data records.\n * @param point - Query point in plotted range coordinates.\n * @param options - Accessors, scales, eligibility, and distance settings. See\n * {@link NearestPointOptions} .\n * @returns The nearest matching point, or undefined when no candidate qualifies. See\n * {@link NearestPoint} .\n *\n * @see {@link NearestPointOptions}\n * @see {@link NearestPoint}\n */\nexport function nearestPoint<D>(\n data: readonly D[],\n point: Readonly<{ x: number; y: number }>,\n options: NearestPointOptions<D>,\n): NearestPoint<D> | undefined {\n pointData(data, \"nearestPoint\");\n finite(point.x, \"nearestPoint x\");\n finite(point.y, \"nearestPoint y\");\n const max = options.maxDistance;\n if (max !== undefined) {\n finite(max, \"nearestPoint maxDistance\");\n if (max < 0)\n throw new RangeError(\"nearestPoint maxDistance must be nonnegative.\");\n }\n const x = pointAccessor(options.x),\n y = pointAccessor(options.y);\n let best: NearestPoint<D> | undefined,\n distance = Infinity;\n for (let i = 0; i < data.length; i++) {\n const datum = data[i];\n if (options.defined && !options.defined(datum, i, data)) continue;\n const xv = x(datum, i, data),\n yv = y(datum, i, data);\n if (!finiteCoordinate(xv) || !finiteCoordinate(yv)) continue;\n const px = options.xScale.map(xv),\n py = options.yScale.map(yv);\n const next = Math.hypot(px - point.x, py - point.y);\n finite(next, \"nearestPoint distance\");\n if (next < distance && (max === undefined || next <= max)) {\n distance = next;\n best = { datum, index: i, x: px, y: py, distance: next };\n }\n }\n return best;\n}\n"],
4
+ "sourcesContent": ["import type { ResolvedContinuousScale } from \"./types.js\";\nimport type { PointAccessor } from \"./point-types.js\";\nimport { finiteCoordinate, pointAccessor, pointData } from \"./point-data.js\";\n/**\n * Coordinate accessors, resolved scales, and candidate filtering for a nearest-point search.\n *\n * @see {@link PointAccessor}\n * @see {@link ResolvedContinuousScale}\n * @see {@link nearestPoint}\n */\nexport interface NearestPointOptions<D> {\n /** Property key or callback extracting the horizontal domain coordinate. See {@link PointAccessor}. */\n readonly x: PointAccessor<D>;\n /** Property key or callback extracting the vertical domain coordinate. See {@link PointAccessor}. */\n readonly y: PointAccessor<D>;\n /** The scale used to map horizontal data coordinates. See {@link ResolvedContinuousScale}. */\n readonly xScale: ResolvedContinuousScale;\n /** The scale used to map vertical data coordinates. See {@link ResolvedContinuousScale}. */\n readonly yScale: ResolvedContinuousScale;\n /**\n * Returns whether a datum contributes drawable or queryable coordinates. See\n * {@link NearestPointOptions}.\n * @param datum - Datum to test.\n * @param index - Zero-based index in the source data.\n * @param data - Complete source data array.\n * @returns Whether this datum should participate in the series or query.\n */\n readonly defined?: (datum: D, index: number, data: readonly D[]) => boolean;\n /** Maximum distance accepted by the query. See {@link NearestPointOptions}. */\n readonly maxDistance?: number;\n}\n/**\n * The selected datum, source index, mapped coordinates, and distance from the query point.\n *\n * @see {@link nearestPoint}\n */\nexport interface NearestPoint<D> {\n /** The original data item selected by this result. See {@link NearestPoint}. */\n readonly datum: D;\n /** Index of the selected datum in its source data. See {@link NearestPoint}. */\n readonly index: number;\n /**\n * Horizontal coordinate or displacement in the containing coordinate system. See\n * {@link NearestPoint}.\n */\n readonly x: number;\n /**\n * Vertical coordinate or displacement in the containing coordinate system. See\n * {@link NearestPoint}.\n */\n readonly y: number;\n /** Distance measured in this query or guide's coordinate system. See {@link NearestPoint}. */\n readonly distance: number;\n}\nfunction finite(value: unknown, name: string): asserts value is number {\n if (!finiteCoordinate(value)) throw new RangeError(`${name} must be finite.`);\n}\n/**\n * Finds the domain value nearest to a logical range coordinate; returns undefined for no\n * candidate.\n *\n * @param values - Candidate domain values.\n * @param rangeValue - Pointer coordinate in the scale's range.\n * @param scale - Scale mapping candidates into range coordinates. See {@link ResolvedContinuousScale}.\n * @returns The nearest domain value, or undefined when no candidate can be selected.\n *\n * @see {@link ResolvedContinuousScale}\n */\nexport function nearestDomainValue(\n values: readonly number[],\n rangeValue: number,\n scale: ResolvedContinuousScale,\n): number | undefined {\n pointData(values, \"nearestDomainValue\");\n finite(rangeValue, \"nearestDomainValue rangeValue\");\n let best: number | undefined,\n distance = Infinity;\n for (const value of values) {\n if (!finiteCoordinate(value)) continue;\n const next = Math.abs(scale.map(value) - rangeValue);\n finite(next, \"nearestDomainValue distance\");\n if (next < distance) {\n best = value;\n distance = next;\n }\n }\n return best;\n}\n/**\n * Finds the nearest defined datum in scaled coordinates, subject to an optional maximum distance.\n *\n * @param data - Candidate data records.\n * @param point - Query point in plotted range coordinates.\n * @param options - Accessors, scales, eligibility, and distance settings. See\n * {@link NearestPointOptions} .\n * @returns The nearest matching point, or undefined when no candidate qualifies. See\n * {@link NearestPoint} .\n *\n * @see {@link NearestPointOptions}\n * @see {@link NearestPoint}\n */\nexport function nearestPoint<D>(\n data: readonly D[],\n point: Readonly<{ x: number; y: number }>,\n options: NearestPointOptions<D>,\n): NearestPoint<D> | undefined {\n pointData(data, \"nearestPoint\");\n finite(point.x, \"nearestPoint x\");\n finite(point.y, \"nearestPoint y\");\n const max = options.maxDistance;\n if (max !== undefined) {\n finite(max, \"nearestPoint maxDistance\");\n if (max < 0)\n throw new RangeError(\"nearestPoint maxDistance must be nonnegative.\");\n }\n const x = pointAccessor(options.x),\n y = pointAccessor(options.y);\n let best: NearestPoint<D> | undefined,\n distance = Infinity;\n for (let i = 0; i < data.length; i++) {\n const datum = data[i];\n if (options.defined && !options.defined(datum, i, data)) continue;\n const xv = x(datum, i, data),\n yv = y(datum, i, data);\n if (!finiteCoordinate(xv) || !finiteCoordinate(yv)) continue;\n const px = options.xScale.map(xv),\n py = options.yScale.map(yv);\n const next = Math.hypot(px - point.x, py - point.y);\n finite(next, \"nearestPoint distance\");\n if (next < distance && (max === undefined || next <= max)) {\n distance = next;\n best = { datum, index: i, x: px, y: py, distance: next };\n }\n }\n return best;\n}\n"],
5
5
  "mappings": "AAEA,SAAS,kBAAkB,eAAe,iBAAiB;AAoD3D,SAAS,OAAO,OAAgB,MAAuC;AACrE,MAAI,CAAC,iBAAiB,KAAK,EAAG,OAAM,IAAI,WAAW,GAAG,IAAI,kBAAkB;AAC9E;AAYO,SAAS,mBACd,QACA,YACA,OACoB;AACpB,YAAU,QAAQ,oBAAoB;AACtC,SAAO,YAAY,+BAA+B;AAClD,MAAI,MACF,WAAW;AACb,aAAW,SAAS,QAAQ;AAC1B,QAAI,CAAC,iBAAiB,KAAK,EAAG;AAC9B,UAAM,OAAO,KAAK,IAAI,MAAM,IAAI,KAAK,IAAI,UAAU;AACnD,WAAO,MAAM,6BAA6B;AAC1C,QAAI,OAAO,UAAU;AACnB,aAAO;AACP,iBAAW;AAAA,IACb;AAAA,EACF;AACA,SAAO;AACT;AAcO,SAAS,aACd,MACA,OACA,SAC6B;AAC7B,YAAU,MAAM,cAAc;AAC9B,SAAO,MAAM,GAAG,gBAAgB;AAChC,SAAO,MAAM,GAAG,gBAAgB;AAChC,QAAM,MAAM,QAAQ;AACpB,MAAI,QAAQ,QAAW;AACrB,WAAO,KAAK,0BAA0B;AACtC,QAAI,MAAM;AACR,YAAM,IAAI,WAAW,+CAA+C;AAAA,EACxE;AACA,QAAM,IAAI,cAAc,QAAQ,CAAC,GAC/B,IAAI,cAAc,QAAQ,CAAC;AAC7B,MAAI,MACF,WAAW;AACb,WAAS,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;AACpC,UAAM,QAAQ,KAAK,CAAC;AACpB,QAAI,QAAQ,WAAW,CAAC,QAAQ,QAAQ,OAAO,GAAG,IAAI,EAAG;AACzD,UAAM,KAAK,EAAE,OAAO,GAAG,IAAI,GACzB,KAAK,EAAE,OAAO,GAAG,IAAI;AACvB,QAAI,CAAC,iBAAiB,EAAE,KAAK,CAAC,iBAAiB,EAAE,EAAG;AACpD,UAAM,KAAK,QAAQ,OAAO,IAAI,EAAE,GAC9B,KAAK,QAAQ,OAAO,IAAI,EAAE;AAC5B,UAAM,OAAO,KAAK,MAAM,KAAK,MAAM,GAAG,KAAK,MAAM,CAAC;AAClD,WAAO,MAAM,uBAAuB;AACpC,QAAI,OAAO,aAAa,QAAQ,UAAa,QAAQ,MAAM;AACzD,iBAAW;AACX,aAAO,EAAE,OAAO,OAAO,GAAG,GAAG,IAAI,GAAG,IAAI,UAAU,KAAK;AAAA,IACzD;AAAA,EACF;AACA,SAAO;AACT;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,15 @@
1
+ import type { NumericDomain } from "./types.js";
2
+ /**
3
+ * Linearly interpolates both endpoints of a finite numeric range.
4
+ *
5
+ * The returned pair is frozen. It preserves ascending, descending, and flat
6
+ * endpoint order for progress within zero through one. Progress outside that
7
+ * interval deliberately extrapolates, matching Pibbl's numeric tween behavior.
8
+ *
9
+ * @param from - Starting finite endpoint pair.
10
+ * @param to - Ending finite endpoint pair.
11
+ * @param progress - Finite interpolation progress supplied by an animation definition.
12
+ * @returns A frozen finite endpoint pair.
13
+ * @see {@link NumericDomain}
14
+ */
15
+ export declare function interpolateNumericRange(from: NumericDomain, to: NumericDomain, progress: number): NumericDomain;
@@ -0,0 +1,36 @@
1
+ function endpoint(value, name) {
2
+ if (typeof value !== "number" || !Number.isFinite(value))
3
+ throw new RangeError(`Numeric range ${name} must be finite.`);
4
+ return value;
5
+ }
6
+ function range(value, name) {
7
+ if (!Array.isArray(value) || value.length !== 2)
8
+ throw new TypeError(`Numeric range ${name} requires two endpoints.`);
9
+ return [endpoint(value[0], `${name}[0]`), endpoint(value[1], `${name}[1]`)];
10
+ }
11
+ function interpolateEndpoint(from, to, progress) {
12
+ if (progress === 0 || from === to) return from;
13
+ if (progress === 1) return to;
14
+ const difference = to - from;
15
+ const direct = from + difference * progress;
16
+ if (Number.isFinite(direct)) return direct;
17
+ const scale = Math.max(Math.abs(from), Math.abs(to));
18
+ const scaled = (from / scale + (to / scale - from / scale) * progress) * scale;
19
+ if (!Number.isFinite(scaled))
20
+ throw new RangeError("Numeric range interpolation must produce finite endpoints.");
21
+ return scaled;
22
+ }
23
+ function interpolateNumericRange(from, to, progress) {
24
+ const start = range(from, "from");
25
+ const end = range(to, "to");
26
+ if (typeof progress !== "number" || !Number.isFinite(progress))
27
+ throw new RangeError("Numeric range interpolation progress must be finite.");
28
+ return Object.freeze([
29
+ interpolateEndpoint(start[0], end[0], progress),
30
+ interpolateEndpoint(start[1], end[1], progress)
31
+ ]);
32
+ }
33
+ export {
34
+ interpolateNumericRange
35
+ };
36
+ //# sourceMappingURL=numeric-range-interpolation.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/features/viz/lib/numeric-range-interpolation.ts"],
4
+ "sourcesContent": ["import type { NumericDomain } from \"./types.js\";\n\nfunction endpoint(value: unknown, name: string): number {\n if (typeof value !== \"number\" || !Number.isFinite(value))\n throw new RangeError(`Numeric range ${name} must be finite.`);\n return value;\n}\n\nfunction range(value: NumericDomain, name: string): readonly [number, number] {\n if (!Array.isArray(value) || value.length !== 2)\n throw new TypeError(`Numeric range ${name} requires two endpoints.`);\n return [endpoint(value[0], `${name}[0]`), endpoint(value[1], `${name}[1]`)];\n}\n\nfunction interpolateEndpoint(from: number, to: number, progress: number): number {\n if (progress === 0 || from === to) return from;\n if (progress === 1) return to;\n const difference = to - from;\n const direct = from + difference * progress;\n if (Number.isFinite(direct)) return direct;\n\n // Scaling avoids overflow in the subtraction for opposite, very large endpoints.\n const scale = Math.max(Math.abs(from), Math.abs(to));\n const scaled =\n (from / scale + (to / scale - from / scale) * progress) * scale;\n if (!Number.isFinite(scaled))\n throw new RangeError(\"Numeric range interpolation must produce finite endpoints.\");\n return scaled;\n}\n\n/**\n * Linearly interpolates both endpoints of a finite numeric range.\n *\n * The returned pair is frozen. It preserves ascending, descending, and flat\n * endpoint order for progress within zero through one. Progress outside that\n * interval deliberately extrapolates, matching Pibbl's numeric tween behavior.\n *\n * @param from - Starting finite endpoint pair.\n * @param to - Ending finite endpoint pair.\n * @param progress - Finite interpolation progress supplied by an animation definition.\n * @returns A frozen finite endpoint pair.\n * @see {@link NumericDomain}\n */\nexport function interpolateNumericRange(\n from: NumericDomain,\n to: NumericDomain,\n progress: number,\n): NumericDomain {\n const start = range(from, \"from\");\n const end = range(to, \"to\");\n if (typeof progress !== \"number\" || !Number.isFinite(progress))\n throw new RangeError(\"Numeric range interpolation progress must be finite.\");\n return Object.freeze([\n interpolateEndpoint(start[0], end[0], progress),\n interpolateEndpoint(start[1], end[1], progress),\n ]);\n}\n"],
5
+ "mappings": "AAEA,SAAS,SAAS,OAAgB,MAAsB;AACtD,MAAI,OAAO,UAAU,YAAY,CAAC,OAAO,SAAS,KAAK;AACrD,UAAM,IAAI,WAAW,iBAAiB,IAAI,kBAAkB;AAC9D,SAAO;AACT;AAEA,SAAS,MAAM,OAAsB,MAAyC;AAC5E,MAAI,CAAC,MAAM,QAAQ,KAAK,KAAK,MAAM,WAAW;AAC5C,UAAM,IAAI,U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