@pibbl/core 0.0.2 → 0.0.3-alpha.109.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 (549) hide show
  1. package/THIRD_PARTY_NOTICES.txt +81 -0
  2. package/dist/features/physics/2d-testing.d.ts +1 -1
  3. package/dist/features/physics/2d-testing.js +2 -2
  4. package/dist/features/physics/2d-testing.js.map +2 -2
  5. package/dist/features/physics/lib/2d/canvas/components.js +25 -21
  6. package/dist/features/physics/lib/2d/canvas/components.js.map +2 -2
  7. package/dist/features/physics/lib/2d/canvas/presentation.js +1 -2
  8. package/dist/features/physics/lib/2d/canvas/presentation.js.map +2 -2
  9. package/dist/features/physics/lib/2d/collision/casts.js +4 -2
  10. package/dist/features/physics/lib/2d/collision/casts.js.map +2 -2
  11. package/dist/features/physics/lib/2d/runtime/controller.js +1 -1
  12. package/dist/features/physics/lib/2d/runtime/controller.js.map +2 -2
  13. package/dist/features/physics/lib/2d/runtime/obstacles.js +9 -11
  14. package/dist/features/physics/lib/2d/runtime/obstacles.js.map +2 -2
  15. package/dist/features/physics/lib/2d/shapes.js +8 -9
  16. package/dist/features/physics/lib/2d/shapes.js.map +2 -2
  17. package/dist/features/physics/lib/2d/world/rapier.js +22 -26
  18. package/dist/features/physics/lib/2d/world/rapier.js.map +2 -2
  19. package/dist/features/sprites/loader.js +6 -3
  20. package/dist/features/sprites/loader.js.map +2 -2
  21. package/dist/features/textures/index.d.ts +12 -2
  22. package/dist/features/textures/index.js +33 -1
  23. package/dist/features/textures/index.js.map +2 -2
  24. package/dist/features/textures/lib/chemical-field.d.ts +56 -0
  25. package/dist/features/textures/lib/chemical-field.js +154 -0
  26. package/dist/features/textures/lib/chemical-field.js.map +7 -0
  27. package/dist/features/textures/lib/chemical-recipes.d.ts +119 -0
  28. package/dist/features/textures/lib/chemical-recipes.js +275 -0
  29. package/dist/features/textures/lib/chemical-recipes.js.map +7 -0
  30. package/dist/features/textures/lib/definitions.d.ts +3 -18
  31. package/dist/features/textures/lib/definitions.js +17 -24
  32. package/dist/features/textures/lib/definitions.js.map +2 -2
  33. package/dist/features/textures/lib/geometric-patterns.d.ts +149 -0
  34. package/dist/features/textures/lib/geometric-patterns.js +305 -0
  35. package/dist/features/textures/lib/geometric-patterns.js.map +7 -0
  36. package/dist/features/textures/lib/gray-scott.d.ts +55 -0
  37. package/dist/features/textures/lib/gray-scott.js +37 -0
  38. package/dist/features/textures/lib/gray-scott.js.map +7 -0
  39. package/dist/features/textures/lib/palette.js +1 -3
  40. package/dist/features/textures/lib/palette.js.map +2 -2
  41. package/dist/features/textures/lib/patterns.d.ts +123 -0
  42. package/dist/features/textures/lib/patterns.js +344 -0
  43. package/dist/features/textures/lib/patterns.js.map +7 -0
  44. package/dist/features/textures/lib/rain-drops.js +2 -1
  45. package/dist/features/textures/lib/rain-drops.js.map +2 -2
  46. package/dist/features/textures/lib/reaction-diffusion.d.ts +3 -2
  47. package/dist/features/textures/lib/reaction-diffusion.js +9 -20
  48. package/dist/features/textures/lib/reaction-diffusion.js.map +2 -2
  49. package/dist/features/textures/lib/simulation.d.ts +10 -4
  50. package/dist/features/textures/lib/simulation.js +23 -13
  51. package/dist/features/textures/lib/simulation.js.map +2 -2
  52. package/dist/features/textures/lib/wasm/electric.js +8 -1
  53. package/dist/features/textures/lib/wasm/electric.js.map +2 -2
  54. package/dist/features/textures/lib/water-surface.js +1 -3
  55. package/dist/features/textures/lib/water-surface.js.map +2 -2
  56. package/dist/features/viz/index.d.ts +68 -6
  57. package/dist/features/viz/index.js +164 -2
  58. package/dist/features/viz/index.js.map +2 -2
  59. package/dist/features/viz/inspection/bar.d.ts +79 -0
  60. package/dist/features/viz/inspection/bar.js +49 -0
  61. package/dist/features/viz/inspection/bar.js.map +7 -0
  62. package/dist/features/viz/inspection/candle.d.ts +156 -0
  63. package/dist/features/viz/inspection/candle.js +120 -0
  64. package/dist/features/viz/inspection/candle.js.map +7 -0
  65. package/dist/features/viz/inspection/capture-types.d.ts +65 -0
  66. package/dist/features/viz/inspection/capture.d.ts +16 -0
  67. package/dist/features/viz/inspection/capture.js +49 -0
  68. package/dist/features/viz/inspection/capture.js.map +7 -0
  69. package/dist/features/viz/inspection/handler.d.ts +36 -0
  70. package/dist/features/viz/inspection/handler.js +91 -0
  71. package/dist/features/viz/inspection/handler.js.map +7 -0
  72. package/dist/features/viz/inspection/ohlc-bar.d.ts +132 -0
  73. package/dist/features/viz/inspection/ohlc-bar.js +118 -0
  74. package/dist/features/viz/inspection/ohlc-bar.js.map +7 -0
  75. package/dist/features/viz/inspection/owned-ref.d.ts +16 -0
  76. package/dist/features/viz/inspection/owned-ref.js +99 -0
  77. package/dist/features/viz/inspection/owned-ref.js.map +7 -0
  78. package/dist/features/viz/inspection/painted-point.d.ts +22 -0
  79. package/dist/features/viz/inspection/painted-point.js +29 -0
  80. package/dist/features/viz/inspection/painted-point.js.map +7 -0
  81. package/dist/features/viz/inspection/queries.d.ts +100 -0
  82. package/dist/features/viz/inspection/queries.js +192 -0
  83. package/dist/features/viz/inspection/queries.js.map +7 -0
  84. package/dist/features/viz/inspection/query-types.d.ts +177 -0
  85. package/dist/features/viz/inspection/volume.d.ts +104 -0
  86. package/dist/features/viz/inspection/volume.js +95 -0
  87. package/dist/features/viz/inspection/volume.js.map +7 -0
  88. package/dist/features/viz/inspection.d.ts +19 -0
  89. package/dist/features/viz/inspection.js +54 -0
  90. package/dist/features/viz/inspection.js.map +7 -0
  91. package/dist/features/viz/inspection.mjs +1 -0
  92. package/dist/features/viz/lib/area-series.d.ts +62 -0
  93. package/dist/features/viz/lib/area-series.js +120 -0
  94. package/dist/features/viz/lib/area-series.js.map +7 -0
  95. package/dist/features/viz/lib/axis-title.js +2 -1
  96. package/dist/features/viz/lib/axis-title.js.map +2 -2
  97. package/dist/features/viz/lib/axis.js +1 -1
  98. package/dist/features/viz/lib/axis.js.map +2 -2
  99. package/dist/features/viz/lib/bar-series.d.ts +3 -1
  100. package/dist/features/viz/lib/bar-series.js +16 -1
  101. package/dist/features/viz/lib/bar-series.js.map +2 -2
  102. package/dist/features/viz/lib/baseline-series.d.ts +55 -0
  103. package/dist/features/viz/lib/baseline-series.js +136 -0
  104. package/dist/features/viz/lib/baseline-series.js.map +7 -0
  105. package/dist/features/viz/lib/candlestick-series.d.ts +62 -0
  106. package/dist/features/viz/lib/candlestick-series.js +150 -0
  107. package/dist/features/viz/lib/candlestick-series.js.map +7 -0
  108. package/dist/features/viz/lib/censored-point-series.d.ts +71 -0
  109. package/dist/features/viz/lib/censored-point-series.js +129 -0
  110. package/dist/features/viz/lib/censored-point-series.js.map +7 -0
  111. package/dist/features/viz/lib/color-context.d.ts +4 -0
  112. package/dist/features/viz/lib/color-context.js +41 -0
  113. package/dist/features/viz/lib/color-context.js.map +7 -0
  114. package/dist/features/viz/lib/color-math.d.ts +4 -0
  115. package/dist/features/viz/lib/color-math.js +31 -0
  116. package/dist/features/viz/lib/color-math.js.map +7 -0
  117. package/dist/features/viz/lib/color-types.d.ts +53 -0
  118. package/dist/features/viz/lib/curve-definition.d.ts +49 -0
  119. package/dist/features/viz/lib/curve-definition.js +142 -0
  120. package/dist/features/viz/lib/curve-definition.js.map +7 -0
  121. package/dist/features/viz/lib/diverging-color-scale.d.ts +11 -0
  122. package/dist/features/viz/lib/diverging-color-scale.js +51 -0
  123. package/dist/features/viz/lib/diverging-color-scale.js.map +7 -0
  124. package/dist/features/viz/lib/domain-navigation.d.ts +40 -0
  125. package/dist/features/viz/lib/domain-navigation.js +77 -0
  126. package/dist/features/viz/lib/domain-navigation.js.map +7 -0
  127. package/dist/features/viz/lib/editable-chart-elements.d.ts +178 -0
  128. package/dist/features/viz/lib/editable-chart-elements.js +733 -0
  129. package/dist/features/viz/lib/editable-chart-elements.js.map +7 -0
  130. package/dist/features/viz/lib/financial-aggregation.d.ts +127 -0
  131. package/dist/features/viz/lib/financial-aggregation.js +116 -0
  132. package/dist/features/viz/lib/financial-aggregation.js.map +7 -0
  133. package/dist/features/viz/lib/financial-autoscale.d.ts +64 -0
  134. package/dist/features/viz/lib/financial-autoscale.js +61 -0
  135. package/dist/features/viz/lib/financial-autoscale.js.map +7 -0
  136. package/dist/features/viz/lib/financial-comparison.d.ts +62 -0
  137. package/dist/features/viz/lib/financial-comparison.js +98 -0
  138. package/dist/features/viz/lib/financial-comparison.js.map +7 -0
  139. package/dist/features/viz/lib/financial-geometry.d.ts +77 -0
  140. package/dist/features/viz/lib/financial-geometry.js +67 -0
  141. package/dist/features/viz/lib/financial-geometry.js.map +7 -0
  142. package/dist/features/viz/lib/financial-indicators.d.ts +114 -0
  143. package/dist/features/viz/lib/financial-indicators.js +135 -0
  144. package/dist/features/viz/lib/financial-indicators.js.map +7 -0
  145. package/dist/features/viz/lib/financial-oscillators.d.ts +171 -0
  146. package/dist/features/viz/lib/financial-oscillators.js +265 -0
  147. package/dist/features/viz/lib/financial-oscillators.js.map +7 -0
  148. package/dist/features/viz/lib/graph/bipartite.d.ts +14 -0
  149. package/dist/features/viz/lib/graph/bipartite.js +250 -0
  150. package/dist/features/viz/lib/graph/bipartite.js.map +7 -0
  151. package/dist/features/viz/lib/graph/chord.d.ts +44 -0
  152. package/dist/features/viz/lib/graph/chord.js +348 -0
  153. package/dist/features/viz/lib/graph/chord.js.map +7 -0
  154. package/dist/features/viz/lib/graph/dependency.d.ts +26 -0
  155. package/dist/features/viz/lib/graph/dependency.js +140 -0
  156. package/dist/features/viz/lib/graph/dependency.js.map +7 -0
  157. package/dist/features/viz/lib/graph/force.d.ts +28 -0
  158. package/dist/features/viz/lib/graph/force.js +580 -0
  159. package/dist/features/viz/lib/graph/force.js.map +7 -0
  160. package/dist/features/viz/lib/graph/hierarchy.d.ts +21 -0
  161. package/dist/features/viz/lib/graph/hierarchy.js +112 -0
  162. package/dist/features/viz/lib/graph/hierarchy.js.map +7 -0
  163. package/dist/features/viz/lib/graph/icicle.d.ts +16 -0
  164. package/dist/features/viz/lib/graph/icicle.js +153 -0
  165. package/dist/features/viz/lib/graph/icicle.js.map +7 -0
  166. package/dist/features/viz/lib/graph/matrix.d.ts +30 -0
  167. package/dist/features/viz/lib/graph/matrix.js +243 -0
  168. package/dist/features/viz/lib/graph/matrix.js.map +7 -0
  169. package/dist/features/viz/lib/graph/neighborhood.d.ts +11 -0
  170. package/dist/features/viz/lib/graph/neighborhood.js +281 -0
  171. package/dist/features/viz/lib/graph/neighborhood.js.map +7 -0
  172. package/dist/features/viz/lib/graph/routes.d.ts +35 -0
  173. package/dist/features/viz/lib/graph/routes.js +101 -0
  174. package/dist/features/viz/lib/graph/routes.js.map +7 -0
  175. package/dist/features/viz/lib/graph/sankey.d.ts +44 -0
  176. package/dist/features/viz/lib/graph/sankey.js +341 -0
  177. package/dist/features/viz/lib/graph/sankey.js.map +7 -0
  178. package/dist/features/viz/lib/graph/shared.d.ts +59 -0
  179. package/dist/features/viz/lib/graph/shared.js +301 -0
  180. package/dist/features/viz/lib/graph/shared.js.map +7 -0
  181. package/dist/features/viz/lib/graph/tree.d.ts +11 -0
  182. package/dist/features/viz/lib/graph/tree.js +232 -0
  183. package/dist/features/viz/lib/graph/tree.js.map +7 -0
  184. package/dist/features/viz/lib/graph/treemap.d.ts +20 -0
  185. package/dist/features/viz/lib/graph/treemap.js +227 -0
  186. package/dist/features/viz/lib/graph/treemap.js.map +7 -0
  187. package/dist/features/viz/lib/graph/types.d.ts +1097 -0
  188. package/dist/features/viz/lib/hover-card.js +8 -9
  189. package/dist/features/viz/lib/hover-card.js.map +2 -2
  190. package/dist/features/viz/lib/hover-data.d.ts +1 -1
  191. package/dist/features/viz/lib/hover-data.js +5 -2
  192. package/dist/features/viz/lib/hover-data.js.map +2 -2
  193. package/dist/features/viz/lib/interval-band-series.d.ts +49 -0
  194. package/dist/features/viz/lib/interval-band-series.js +136 -0
  195. package/dist/features/viz/lib/interval-band-series.js.map +7 -0
  196. package/dist/features/viz/lib/interval-diamond-series.d.ts +43 -0
  197. package/dist/features/viz/lib/interval-diamond-series.js +122 -0
  198. package/dist/features/viz/lib/interval-diamond-series.js.map +7 -0
  199. package/dist/features/viz/lib/interval-series.d.ts +79 -0
  200. package/dist/features/viz/lib/interval-series.js +158 -0
  201. package/dist/features/viz/lib/interval-series.js.map +7 -0
  202. package/dist/features/viz/lib/layout-pie.js +9 -13
  203. package/dist/features/viz/lib/layout-pie.js.map +2 -2
  204. package/dist/features/viz/lib/line-series.d.ts +1 -1
  205. package/dist/features/viz/lib/line-series.js +47 -28
  206. package/dist/features/viz/lib/line-series.js.map +2 -2
  207. package/dist/features/viz/lib/linear-scale.js +1 -1
  208. package/dist/features/viz/lib/linear-scale.js.map +2 -2
  209. package/dist/features/viz/lib/monotone-curve.d.ts +11 -0
  210. package/dist/features/viz/lib/monotone-curve.js +63 -0
  211. package/dist/features/viz/lib/monotone-curve.js.map +7 -0
  212. package/dist/features/viz/lib/numeric-range-interpolation.d.ts +15 -0
  213. package/dist/features/viz/lib/numeric-range-interpolation.js +36 -0
  214. package/dist/features/viz/lib/numeric-range-interpolation.js.map +7 -0
  215. package/dist/features/viz/lib/ohlc-bar-series.d.ts +55 -0
  216. package/dist/features/viz/lib/ohlc-bar-series.js +168 -0
  217. package/dist/features/viz/lib/ohlc-bar-series.js.map +7 -0
  218. package/dist/features/viz/lib/paired-series.d.ts +44 -0
  219. package/dist/features/viz/lib/paired-series.js +93 -0
  220. package/dist/features/viz/lib/paired-series.js.map +7 -0
  221. package/dist/features/viz/lib/pie-layout.js +2 -1
  222. package/dist/features/viz/lib/pie-layout.js.map +2 -2
  223. package/dist/features/viz/lib/plot-series.js +11 -6
  224. package/dist/features/viz/lib/plot-series.js.map +2 -2
  225. package/dist/features/viz/lib/plot-types.d.ts +4 -3
  226. package/dist/features/viz/lib/point-series.d.ts +1 -1
  227. package/dist/features/viz/lib/point-series.js +36 -9
  228. package/dist/features/viz/lib/point-series.js.map +2 -2
  229. package/dist/features/viz/lib/point-types.d.ts +5 -2
  230. package/dist/features/viz/lib/reference-band.js +4 -1
  231. package/dist/features/viz/lib/reference-band.js.map +2 -2
  232. package/dist/features/viz/lib/scale-context.d.ts +1 -1
  233. package/dist/features/viz/lib/scale-ticks.js +21 -6
  234. package/dist/features/viz/lib/scale-ticks.js.map +2 -2
  235. package/dist/features/viz/lib/sequential-color-scale.d.ts +11 -0
  236. package/dist/features/viz/lib/sequential-color-scale.js +49 -0
  237. package/dist/features/viz/lib/sequential-color-scale.js.map +7 -0
  238. package/dist/features/viz/lib/series-position.d.ts +12 -0
  239. package/dist/features/viz/lib/series-position.js +44 -0
  240. package/dist/features/viz/lib/series-position.js.map +7 -0
  241. package/dist/features/viz/lib/step-curves.d.ts +19 -0
  242. package/dist/features/viz/lib/step-curves.js +53 -0
  243. package/dist/features/viz/lib/step-curves.js.map +7 -0
  244. package/dist/features/viz/lib/threshold-color-scale.d.ts +43 -0
  245. package/dist/features/viz/lib/threshold-color-scale.js +59 -0
  246. package/dist/features/viz/lib/threshold-color-scale.js.map +7 -0
  247. package/dist/features/viz/lib/trading-time-mapping.d.ts +32 -0
  248. package/dist/features/viz/lib/trading-time-mapping.js +89 -0
  249. package/dist/features/viz/lib/trading-time-mapping.js.map +7 -0
  250. package/dist/features/viz/lib/trading-time-scale.d.ts +83 -0
  251. package/dist/features/viz/lib/trading-time-scale.js +96 -0
  252. package/dist/features/viz/lib/trading-time-scale.js.map +7 -0
  253. package/dist/features/viz/lib/trajectory-series.d.ts +71 -0
  254. package/dist/features/viz/lib/trajectory-series.js +111 -0
  255. package/dist/features/viz/lib/trajectory-series.js.map +7 -0
  256. package/dist/features/viz/lib/types.d.ts +20 -4
  257. package/dist/features/viz/lib/use-continuous-scale.js +6 -1
  258. package/dist/features/viz/lib/use-continuous-scale.js.map +2 -2
  259. package/dist/features/viz/lib/utc-scale.js +11 -10
  260. package/dist/features/viz/lib/utc-scale.js.map +2 -2
  261. package/dist/features/viz/lib/volume-series.d.ts +59 -0
  262. package/dist/features/viz/lib/volume-series.js +117 -0
  263. package/dist/features/viz/lib/volume-series.js.map +7 -0
  264. package/dist/features/viz/lib/weighted-point-series.d.ts +71 -0
  265. package/dist/features/viz/lib/weighted-point-series.js +169 -0
  266. package/dist/features/viz/lib/weighted-point-series.js.map +7 -0
  267. package/dist/filters/backdrop-contrast-gpu.d.ts +5 -0
  268. package/dist/filters/backdrop-contrast-gpu.js +33 -0
  269. package/dist/filters/backdrop-contrast-gpu.js.map +7 -0
  270. package/dist/filters/backdrop-contrast.d.ts +21 -0
  271. package/dist/filters/backdrop-contrast.js +61 -0
  272. package/dist/filters/backdrop-contrast.js.map +7 -0
  273. package/dist/filters/displacement.js +1 -1
  274. package/dist/filters/displacement.js.map +2 -2
  275. package/dist/filters/emboss-gpu.d.ts +4 -0
  276. package/dist/filters/emboss-gpu.js +39 -0
  277. package/dist/filters/emboss-gpu.js.map +7 -0
  278. package/dist/filters/emboss.d.ts +32 -0
  279. package/dist/filters/emboss.js +104 -0
  280. package/dist/filters/emboss.js.map +7 -0
  281. package/dist/filters/filter-executor.d.ts +11 -4
  282. package/dist/filters/filter-executor.js +104 -49
  283. package/dist/filters/filter-executor.js.map +2 -2
  284. package/dist/filters/reflected-light.js +1 -1
  285. package/dist/filters/reflected-light.js.map +2 -2
  286. package/dist/filters/reflection-gpu.d.ts +3 -1
  287. package/dist/filters/reflection-gpu.js +5 -2
  288. package/dist/filters/reflection-gpu.js.map +2 -2
  289. package/dist/filters/render-backdrop-contrast-boundary.d.ts +31 -0
  290. package/dist/filters/render-backdrop-contrast-boundary.js +116 -0
  291. package/dist/filters/render-backdrop-contrast-boundary.js.map +7 -0
  292. package/dist/filters/render-emboss-boundary.d.ts +13 -0
  293. package/dist/filters/render-emboss-boundary.js +131 -0
  294. package/dist/filters/render-emboss-boundary.js.map +7 -0
  295. package/dist/filters.d.ts +9 -5
  296. package/dist/filters.js +4 -0
  297. package/dist/filters.js.map +2 -2
  298. package/dist/index.d.ts +9 -5
  299. package/dist/index.js +18 -2
  300. package/dist/index.js.map +2 -2
  301. package/dist/internal.d.ts +4 -0
  302. package/dist/internal.js +6 -0
  303. package/dist/internal.js.map +2 -2
  304. package/dist/layout-kernel.d.ts +12 -0
  305. package/dist/layout-kernel.js +11 -0
  306. package/dist/layout-kernel.js.map +7 -0
  307. package/dist/layout-kernel.mjs +1 -0
  308. package/dist/lib/backend/types.d.ts +13 -1
  309. package/dist/lib/backend/types.js.map +2 -2
  310. package/dist/lib/components/arc-geometry.js +2 -1
  311. package/dist/lib/components/arc-geometry.js.map +2 -2
  312. package/dist/lib/components/g.js +2 -0
  313. package/dist/lib/components/g.js.map +2 -2
  314. package/dist/lib/components/html-box.js +2 -1
  315. package/dist/lib/components/html-box.js.map +2 -2
  316. package/dist/lib/components/img.js +3 -3
  317. package/dist/lib/components/img.js.map +2 -2
  318. package/dist/lib/components/layer.js +98 -16
  319. package/dist/lib/components/layer.js.map +3 -3
  320. package/dist/lib/components/text.d.ts +16 -0
  321. package/dist/lib/components/text.js +131 -24
  322. package/dist/lib/components/text.js.map +2 -2
  323. package/dist/lib/define-primitive.d.ts +4 -2
  324. package/dist/lib/define-primitive.js +3 -1
  325. package/dist/lib/define-primitive.js.map +2 -2
  326. package/dist/lib/element/metadata.d.ts +9 -0
  327. package/dist/lib/element/metadata.js +19 -0
  328. package/dist/lib/element/metadata.js.map +2 -2
  329. package/dist/lib/element/resolve-primitive-inputs.d.ts +2 -0
  330. package/dist/lib/element/resolve-primitive-inputs.js +17 -4
  331. package/dist/lib/element/resolve-primitive-inputs.js.map +2 -2
  332. package/dist/lib/events/event-facade.d.ts +18 -0
  333. package/dist/lib/events/event-facade.js +28 -2
  334. package/dist/lib/events/event-facade.js.map +2 -2
  335. package/dist/lib/events/hit-test.js +2 -1
  336. package/dist/lib/events/hit-test.js.map +2 -2
  337. package/dist/lib/events/propagation.d.ts +2 -1
  338. package/dist/lib/events/propagation.js +22 -16
  339. package/dist/lib/events/propagation.js.map +2 -2
  340. package/dist/lib/events/registrations.d.ts +10 -0
  341. package/dist/lib/events/registrations.js +160 -5
  342. package/dist/lib/events/registrations.js.map +2 -2
  343. package/dist/lib/execute-render.js +25 -1
  344. package/dist/lib/execute-render.js.map +2 -2
  345. package/dist/lib/filter/filter-region.js +3 -10
  346. package/dist/lib/filter/filter-region.js.map +2 -2
  347. package/dist/lib/focus/focus-manager.d.ts +8 -1
  348. package/dist/lib/focus/focus-manager.js +87 -43
  349. package/dist/lib/focus/focus-manager.js.map +2 -2
  350. package/dist/lib/focus/geometry.d.ts +2 -0
  351. package/dist/lib/focus/geometry.js +6 -0
  352. package/dist/lib/focus/geometry.js.map +2 -2
  353. package/dist/lib/geometry/path-bend-guide.js +1 -1
  354. package/dist/lib/geometry/path-bend-guide.js.map +2 -2
  355. package/dist/lib/geometry/path-geometry.js +12 -11
  356. package/dist/lib/geometry/path-geometry.js.map +2 -2
  357. package/dist/lib/geometry/path-transforms.js +17 -21
  358. package/dist/lib/geometry/path-transforms.js.map +2 -2
  359. package/dist/lib/geometry/path-warp-bezier.js +3 -1
  360. package/dist/lib/geometry/path-warp-bezier.js.map +2 -2
  361. package/dist/lib/geometry/path-warp.js +1 -1
  362. package/dist/lib/geometry/path-warp.js.map +2 -2
  363. package/dist/lib/global-state.js +2 -0
  364. package/dist/lib/global-state.js.map +2 -2
  365. package/dist/lib/html/html-events.d.ts +32 -0
  366. package/dist/lib/html/html-events.js +179 -0
  367. package/dist/lib/html/html-events.js.map +7 -0
  368. package/dist/lib/html/html-service.d.ts +8 -2
  369. package/dist/lib/html/html-service.js +198 -65
  370. package/dist/lib/html/html-service.js.map +2 -2
  371. package/dist/lib/html/overlay-config.js +7 -6
  372. package/dist/lib/html/overlay-config.js.map +2 -2
  373. package/dist/lib/html/types.d.ts +29 -2
  374. package/dist/lib/layout/absolute.d.ts +11 -5
  375. package/dist/lib/layout/absolute.js +329 -55
  376. package/dist/lib/layout/absolute.js.map +3 -3
  377. package/dist/lib/layout/allocation-checkpoint-owner.d.ts +11 -0
  378. package/dist/lib/layout/allocation-checkpoint-owner.js +86 -0
  379. package/dist/lib/layout/allocation-checkpoint-owner.js.map +7 -0
  380. package/dist/lib/layout/allocation-checkpoint.d.ts +53 -0
  381. package/dist/lib/layout/allocation-checkpoint.js +463 -0
  382. package/dist/lib/layout/allocation-checkpoint.js.map +7 -0
  383. package/dist/lib/layout/allocation-dependencies.d.ts +30 -0
  384. package/dist/lib/layout/allocation-dependencies.js +90 -0
  385. package/dist/lib/layout/allocation-dependencies.js.map +7 -0
  386. package/dist/lib/layout/allocation-revision.d.ts +13 -0
  387. package/dist/lib/layout/allocation-revision.js +67 -0
  388. package/dist/lib/layout/allocation-revision.js.map +7 -0
  389. package/dist/lib/layout/box-insets.d.ts +17 -0
  390. package/dist/lib/layout/box-insets.js +138 -0
  391. package/dist/lib/layout/box-insets.js.map +7 -0
  392. package/dist/lib/layout/box-sizing.d.ts +16 -0
  393. package/dist/lib/layout/box-sizing.js +77 -0
  394. package/dist/lib/layout/box-sizing.js.map +7 -0
  395. package/dist/lib/layout/box.js +42 -12
  396. package/dist/lib/layout/box.js.map +2 -2
  397. package/dist/lib/layout/canvas-measurement.d.ts +13 -0
  398. package/dist/lib/layout/canvas-measurement.js +57 -0
  399. package/dist/lib/layout/canvas-measurement.js.map +7 -0
  400. package/dist/lib/layout/context.d.ts +35 -6
  401. package/dist/lib/layout/context.js +72 -3
  402. package/dist/lib/layout/context.js.map +2 -2
  403. package/dist/lib/layout/define-layout-component.d.ts +23 -0
  404. package/dist/lib/layout/define-layout-component.js +84 -0
  405. package/dist/lib/layout/define-layout-component.js.map +7 -0
  406. package/dist/lib/layout/flex-allocation-cache.d.ts +42 -0
  407. package/dist/lib/layout/flex-baseline-mode.d.ts +2 -0
  408. package/dist/lib/layout/flex-baseline-mode.js +7 -0
  409. package/dist/lib/layout/flex-baseline-mode.js.map +7 -0
  410. package/dist/lib/layout/flex.d.ts +50 -15
  411. package/dist/lib/layout/flex.js +2124 -195
  412. package/dist/lib/layout/flex.js.map +3 -3
  413. package/dist/lib/layout/flow.js +225 -49
  414. package/dist/lib/layout/flow.js.map +2 -2
  415. package/dist/lib/layout/geometry-publication.d.ts +53 -0
  416. package/dist/lib/layout/geometry-publication.js +244 -0
  417. package/dist/lib/layout/geometry-publication.js.map +7 -0
  418. package/dist/lib/layout/grid-kernel.d.ts +63 -0
  419. package/dist/lib/layout/grid-kernel.js +168 -0
  420. package/dist/lib/layout/grid-kernel.js.map +7 -0
  421. package/dist/lib/layout/grid.d.ts +63 -4
  422. package/dist/lib/layout/grid.js +767 -171
  423. package/dist/lib/layout/grid.js.map +3 -3
  424. package/dist/lib/layout/measure.d.ts +55 -3
  425. package/dist/lib/layout/measure.js +448 -15
  426. package/dist/lib/layout/measure.js.map +2 -2
  427. package/dist/lib/layout/overlay.js +81 -23
  428. package/dist/lib/layout/overlay.js.map +2 -2
  429. package/dist/lib/layout/participation.d.ts +27 -0
  430. package/dist/lib/layout/participation.js +188 -0
  431. package/dist/lib/layout/participation.js.map +7 -0
  432. package/dist/lib/layout/place-child.js +1 -1
  433. package/dist/lib/layout/place-child.js.map +2 -2
  434. package/dist/lib/layout/positioning-diagnostics.d.ts +1 -1
  435. package/dist/lib/layout/positioning-diagnostics.js +13 -2
  436. package/dist/lib/layout/positioning-diagnostics.js.map +2 -2
  437. package/dist/lib/layout/prepared-root.d.ts +121 -0
  438. package/dist/lib/layout/prepared-root.js +360 -0
  439. package/dist/lib/layout/prepared-root.js.map +7 -0
  440. package/dist/lib/layout/standalone-kernel.d.ts +60 -0
  441. package/dist/lib/layout/standalone-kernel.js +722 -0
  442. package/dist/lib/layout/standalone-kernel.js.map +7 -0
  443. package/dist/lib/layout/topology.d.ts +21 -0
  444. package/dist/lib/layout/topology.js +113 -0
  445. package/dist/lib/layout/topology.js.map +7 -0
  446. package/dist/lib/layout/types.d.ts +5 -0
  447. package/dist/lib/layout/wasm/artifact.d.ts +1 -0
  448. package/dist/lib/layout/wasm/artifact.js +5 -0
  449. package/dist/lib/layout/wasm/artifact.js.map +7 -0
  450. package/dist/lib/layout/wasm/bytes.d.ts +1 -0
  451. package/dist/lib/layout/wasm/bytes.js +5 -0
  452. package/dist/lib/layout/wasm/bytes.js.map +7 -0
  453. package/dist/lib/layout/wasm/embedded.d.ts +2 -0
  454. package/dist/lib/layout/wasm/embedded.js +12 -0
  455. package/dist/lib/layout/wasm/embedded.js.map +7 -0
  456. package/dist/lib/layout/wasm/layout.wasm +0 -0
  457. package/dist/lib/layout/wasm/module.d.ts +8 -0
  458. package/dist/lib/layout/wasm/module.js +70 -0
  459. package/dist/lib/layout/wasm/module.js.map +7 -0
  460. package/dist/lib/layout/wasm/region.d.ts +267 -0
  461. package/dist/lib/layout/wasm/region.js +1018 -0
  462. package/dist/lib/layout/wasm/region.js.map +7 -0
  463. package/dist/lib/manipulation/controller.js +4 -7
  464. package/dist/lib/manipulation/controller.js.map +2 -2
  465. package/dist/lib/manipulation/frame.js +1 -1
  466. package/dist/lib/manipulation/frame.js.map +2 -2
  467. package/dist/lib/manipulation/handles.js +32 -33
  468. package/dist/lib/manipulation/handles.js.map +2 -2
  469. package/dist/lib/manipulation/solve.js +12 -10
  470. package/dist/lib/manipulation/solve.js.map +2 -2
  471. package/dist/lib/mount-pibbl.js +1 -0
  472. package/dist/lib/mount-pibbl.js.map +2 -2
  473. package/dist/lib/mount-prepared-pibbl.d.ts +5 -0
  474. package/dist/lib/mount-prepared-pibbl.js +29 -0
  475. package/dist/lib/mount-prepared-pibbl.js.map +7 -0
  476. package/dist/lib/mount-request.d.ts +8 -0
  477. package/dist/lib/mount-request.js +41 -0
  478. package/dist/lib/mount-request.js.map +7 -0
  479. package/dist/lib/pibbl.d.ts +21 -13
  480. package/dist/lib/pibbl.js +18 -16
  481. package/dist/lib/pibbl.js.map +2 -2
  482. package/dist/lib/recording/recording.d.ts +43 -0
  483. package/dist/lib/recording/recording.js +555 -0
  484. package/dist/lib/recording/recording.js.map +7 -0
  485. package/dist/lib/recording/types.d.ts +118 -0
  486. package/dist/lib/recording/wasm-bytes.d.ts +1 -0
  487. package/dist/lib/recording/wasm-bytes.js +5 -0
  488. package/dist/lib/recording/wasm-bytes.js.map +7 -0
  489. package/dist/lib/recording/worker-source.d.ts +1 -0
  490. package/dist/lib/recording/worker-source.js +5 -0
  491. package/dist/lib/recording/worker-source.js.map +7 -0
  492. package/dist/lib/render-layer/controller.d.ts +9 -3
  493. package/dist/lib/render-layer/controller.js +259 -110
  494. package/dist/lib/render-layer/controller.js.map +2 -2
  495. package/dist/lib/render-transaction.d.ts +12 -2
  496. package/dist/lib/render-transaction.js +69 -1
  497. package/dist/lib/render-transaction.js.map +2 -2
  498. package/dist/lib/render.js +32 -8
  499. package/dist/lib/render.js.map +2 -2
  500. package/dist/lib/scheduler/realm-scheduler.d.ts +2 -0
  501. package/dist/lib/scheduler/realm-scheduler.js +55 -26
  502. package/dist/lib/scheduler/realm-scheduler.js.map +2 -2
  503. package/dist/lib/scheduler/renderer-participant.js +1 -0
  504. package/dist/lib/scheduler/renderer-participant.js.map +2 -2
  505. package/dist/lib/series-inspection-frame.d.ts +18 -0
  506. package/dist/lib/series-inspection-frame.js +70 -0
  507. package/dist/lib/series-inspection-frame.js.map +7 -0
  508. package/dist/lib/signals/edge.d.ts +7 -4
  509. package/dist/lib/signals/edge.js +25 -3
  510. package/dist/lib/signals/edge.js.map +2 -2
  511. package/dist/lib/signals/graph.d.ts +16 -2
  512. package/dist/lib/signals/graph.js +54 -12
  513. package/dist/lib/signals/graph.js.map +2 -2
  514. package/dist/lib/signals/input-provision.d.ts +15 -0
  515. package/dist/lib/signals/input-provision.js +53 -3
  516. package/dist/lib/signals/input-provision.js.map +2 -2
  517. package/dist/lib/signals/render-consumer.d.ts +3 -0
  518. package/dist/lib/signals/render-consumer.js +22 -14
  519. package/dist/lib/signals/render-consumer.js.map +2 -2
  520. package/dist/lib/style/positioning.d.ts +50 -2
  521. package/dist/lib/style/positioning.js +28 -4
  522. package/dist/lib/style/positioning.js.map +2 -2
  523. package/dist/lib/style/resolve-built-in.d.ts +4 -3
  524. package/dist/lib/style/resolve-built-in.js +17 -3
  525. package/dist/lib/style/resolve-built-in.js.map +2 -2
  526. package/dist/lib/style/resolve-dispatch.d.ts +3 -0
  527. package/dist/lib/style/resolve-dispatch.js +77 -4
  528. package/dist/lib/style/resolve-dispatch.js.map +2 -2
  529. package/dist/lib/style/resolve-length.d.ts +2 -0
  530. package/dist/lib/style/resolve-length.js +13 -9
  531. package/dist/lib/style/resolve-length.js.map +2 -2
  532. package/dist/lib/style/sizing-length.d.ts +51 -0
  533. package/dist/lib/style/sizing-length.js +77 -0
  534. package/dist/lib/style/sizing-length.js.map +7 -0
  535. package/dist/lib/style/types.d.ts +63 -25
  536. package/dist/lib/surface/root-surface.js +10 -6
  537. package/dist/lib/surface/root-surface.js.map +2 -2
  538. package/dist/lib/textures/texture.js +10 -8
  539. package/dist/lib/textures/texture.js.map +2 -2
  540. package/dist/lib/transitions/capture.js +4 -1
  541. package/dist/lib/transitions/capture.js.map +2 -2
  542. package/dist/lib/transitions/embers-physics.js +17 -10
  543. package/dist/lib/transitions/embers-physics.js.map +2 -2
  544. package/dist/lib/types.d.ts +110 -1
  545. package/dist/sync.d.ts +16 -0
  546. package/dist/sync.js +13 -0
  547. package/dist/sync.js.map +7 -0
  548. package/dist/sync.mjs +1 -0
  549. package/package.json +26 -3
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/lib/components/img.ts"],
4
- "sourcesContent": ["import { resolveTexturePaint } from '../textures/texture-protocol.js';\nimport { definePrimitive } from '../define-primitive.js';\nimport type {\n PibblEventFocusOptions,\n PibblEventHandlers,\n PibblEventParticipationOptions,\n} from '../events/types.js';\nimport { useRectPath } from '../hooks/use-rect-path.js';\nimport { useReaction } from '../hooks/use-reaction.js';\nimport { useSignal } from '../hooks/use-signal.js';\nimport type {\n PibblPhysics2DPropExtension,\n MeasureInput,\n MeasureResult,\n RenderingContext2D,\n StyleResolutionContext,\n} from '../types.js';\nimport { resolveLength } from '../style/resolve-length.js';\nimport {\n resolveOptionalLength,\n stripLayoutParticipation,\n} from '../style/resolve-built-in.js';\nimport { registerOpaqueStyleProperties } from '../style/resolve-dispatch.js';\nimport type { ImgStyle, ResolvedImgStyle } from '../style/types.js';\nimport { adjustRectangleToPixelGrid } from '../util/pixel-grid-adjustments.js';\nimport { wireCommonEvents } from '../util/wire-common-events.js';\n\n/**\n * Authored inputs for Image, including the declared data and presentation options.\n *\n * @see {@link PibblEventHandlers}\n * @see {@link PibblEventParticipationOptions}\n * @see {@link PibblPhysics2DPropExtension}\n * @see {@link Image}\n */\nexport interface ImageProps extends PibblEventHandlers, PibblEventFocusOptions, PibblEventParticipationOptions, PibblPhysics2DPropExtension {}\n\ninterface LoadedImage {\n src: string;\n element: HTMLImageElement;\n}\n\nfunction renderImage(\n props: ImageProps,\n style: Readonly<ResolvedImgStyle>,\n ctx: RenderingContext2D,\n) {\n let {\n src,\n x = 0,\n y = 0,\n width,\n height,\n stroke,\n strokeWidth,\n opacity,\n cursor,\n alignToPixelGrid,\n } = style;\n\n if (opacity !== undefined) {\n ctx.globalAlpha = ctx.globalAlpha * opacity;\n }\n\n const loadedImage = useSignal<LoadedImage | null>(null);\n const loadedImageValue = loadedImage.get();\n const image =\n loadedImageValue && loadedImageValue.src === src ?\n loadedImageValue.element : null;\n\n useReaction(() => {\n let active = true;\n const BrowserImage = globalThis.Image;\n const element = new BrowserImage();\n const settle = () => {\n active = false;\n element.onload = null;\n element.onerror = null;\n };\n\n element.onload = () => {\n if (!active) return;\n settle();\n loadedImage.set({ src, element });\n };\n element.onerror = () => {\n if (!active) return;\n settle();\n loadedImage.set(null);\n };\n element.src = src;\n\n return () => {\n active = false;\n element.onload = null;\n element.onerror = null;\n element.removeAttribute('src');\n };\n }, [src]);\n\n width = width ?? image?.naturalWidth ?? image?.width ?? 0;\n height = height ?? image?.naturalHeight ?? image?.height ?? 0;\n\n if (alignToPixelGrid) {\n ({ x, y, width, height } = adjustRectangleToPixelGrid(\n strokeWidth ?? 0,\n x,\n y,\n width,\n height,\n alignToPixelGrid,\n ));\n }\n\n const imagePath = useRectPath(x, y, width, height);\n\n if (image) {\n ctx.drawImage(image, x, y, width, height);\n }\n\n if (stroke && strokeWidth) {\n ctx.strokeStyle = resolveTexturePaint(stroke, ctx, { x, y, width, height });\n ctx.lineWidth = strokeWidth;\n ctx.stroke(imagePath);\n }\n\n wireCommonEvents(\n props,\n imagePath,\n true,\n strokeWidth ?? 0,\n cursor,\n { x, y, width, height },\n );\n}\n\n/**\n * Describes a Canvas image primitive for JSX or createElement authoring.\n *\n * @param props - Authored component inputs, supplied through JSX or createElement. See the linked\n * props and style types.\n * @throws When called directly; Pibbl mounts this component through JSX or createElement.\n *\n * @see {@link ImageProps}\n * @see {@link ImgStyle}\n */\nexport const Image = definePrimitive<\n ImageProps,\n ImgStyle,\n ImgStyle,\n ResolvedImgStyle\n>(renderImage, {\n resolveStyle: resolveImageStyle,\n measure: measureImage,\n});\nregisterOpaqueStyleProperties(Image, ['src', 'stroke', 'cursor']);\n\nfunction resolveImageStyle(\n style: Readonly<ImgStyle>,\n context: Readonly<StyleResolutionContext>,\n): ResolvedImgStyle {\n return {\n ...stripLayoutParticipation(style),\n x: 0,\n y: 0,\n width: resolveOptionalLength(\n style.width,\n context.percentageBasis.width,\n 'width',\n context,\n ),\n height: resolveOptionalLength(\n style.height,\n context.percentageBasis.height,\n 'height',\n context,\n ),\n } as ResolvedImgStyle;\n}\n\nfunction measureImage({\n style,\n constraints,\n}: MeasureInput<ImageProps, ImgStyle>): MeasureResult {\n if (\n style.width === undefined || style.width === 'auto' ||\n style.height === undefined || style.height === 'auto'\n ) {\n return {\n status: 'unsupported',\n reason: 'Image natural dimensions are unavailable during pure measurement',\n };\n }\n const context = {\n component: 'Image',\n algorithm: 'measurement' as const,\n constraints,\n };\n return {\n status: 'measured',\n size: {\n width: resolveLength(\n style.width,\n constraints.maxWidth,\n 'width',\n context,\n )!,\n height: resolveLength(\n style.height,\n constraints.maxHeight,\n 'height',\n context,\n )!,\n },\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Q;AAAA,IACV;AAAA,EACF;AACA,QAAM,UAAU;AAAA,IACd,WAAW;AAAA,IACX,WAAW;AAAA,IACX;AAAA,EACF;AACA,SAAO;AAAA,IACL,QAAQ;AAAA,IACR,MAAM;AAAA,MACJ,OAAO;AAAA,QACL,MAAM;AAAA,QACN,YAAY;AAAA,QACZ;AAAA,QACA;AAAA,MACF;AAAA,MACA,QAAQ;AAAA,QACN,MAAM;AAAA,QACN,YAAY;AAAA,QACZ;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;",
4
+ "sourcesContent": ["import { resolveTexturePaint } from '../textures/texture-protocol.js';\nimport { definePrimitive } from '../define-primitive.js';\nimport type {\n PibblEventFocusOptions,\n PibblEventHandlers,\n PibblEventParticipationOptions,\n} from '../events/types.js';\nimport { useRectPath } from '../hooks/use-rect-path.js';\nimport { useReaction } from '../hooks/use-reaction.js';\nimport { useSignal } from '../hooks/use-signal.js';\nimport type {\n PibblPhysics2DPropExtension,\n MeasureInput,\n MeasureResult,\n RenderingContext2D,\n StyleResolutionContext,\n} from '../types.js';\nimport { resolveScalarSizingLength } from '../style/sizing-length.js';\nimport {\n resolveOptionalLength,\n stripLayoutParticipation,\n} from '../style/resolve-built-in.js';\nimport { registerOpaqueStyleProperties } from '../style/resolve-dispatch.js';\nimport type { ImgStyle, ResolvedImgStyle } from '../style/types.js';\nimport { adjustRectangleToPixelGrid } from '../util/pixel-grid-adjustments.js';\nimport { wireCommonEvents } from '../util/wire-common-events.js';\n\n/**\n * Authored inputs for Image, including the declared data and presentation options.\n *\n * @see {@link PibblEventHandlers}\n * @see {@link PibblEventParticipationOptions}\n * @see {@link PibblPhysics2DPropExtension}\n * @see {@link Image}\n */\nexport interface ImageProps extends PibblEventHandlers, PibblEventFocusOptions, PibblEventParticipationOptions, PibblPhysics2DPropExtension {}\n\ninterface LoadedImage {\n src: string;\n element: HTMLImageElement;\n}\n\nfunction renderImage(\n props: ImageProps,\n style: Readonly<ResolvedImgStyle>,\n ctx: RenderingContext2D,\n) {\n let {\n src,\n x = 0,\n y = 0,\n width,\n height,\n stroke,\n strokeWidth,\n opacity,\n cursor,\n alignToPixelGrid,\n } = style;\n\n if (opacity !== undefined) {\n ctx.globalAlpha = ctx.globalAlpha * opacity;\n }\n\n const loadedImage = useSignal<LoadedImage | null>(null);\n const loadedImageValue = loadedImage.get();\n const image =\n loadedImageValue && loadedImageValue.src === src ?\n loadedImageValue.element : null;\n\n useReaction(() => {\n let active = true;\n const BrowserImage = globalThis.Image;\n const element = new BrowserImage();\n const settle = () => {\n active = false;\n element.onload = null;\n element.onerror = null;\n };\n\n element.onload = () => {\n if (!active) return;\n settle();\n loadedImage.set({ src, element });\n };\n element.onerror = () => {\n if (!active) return;\n settle();\n loadedImage.set(null);\n };\n element.src = src;\n\n return () => {\n active = false;\n element.onload = null;\n element.onerror = null;\n element.removeAttribute('src');\n };\n }, [src]);\n\n width = width ?? image?.naturalWidth ?? image?.width ?? 0;\n height = height ?? image?.naturalHeight ?? image?.height ?? 0;\n\n if (alignToPixelGrid) {\n ({ x, y, width, height } = adjustRectangleToPixelGrid(\n strokeWidth ?? 0,\n x,\n y,\n width,\n height,\n alignToPixelGrid,\n ));\n }\n\n const imagePath = useRectPath(x, y, width, height);\n\n if (image) {\n ctx.drawImage(image, x, y, width, height);\n }\n\n if (stroke && strokeWidth) {\n ctx.strokeStyle = resolveTexturePaint(stroke, ctx, { x, y, width, height });\n ctx.lineWidth = strokeWidth;\n ctx.stroke(imagePath);\n }\n\n wireCommonEvents(\n props,\n imagePath,\n true,\n strokeWidth ?? 0,\n cursor,\n { x, y, width, height },\n );\n}\n\n/**\n * Describes a Canvas image primitive for JSX or createElement authoring.\n *\n * @param props - Authored component inputs, supplied through JSX or createElement. See the linked\n * props and style types.\n * @throws When called directly; Pibbl mounts this component through JSX or createElement.\n *\n * @see {@link ImageProps}\n * @see {@link ImgStyle}\n */\nexport const Image = definePrimitive<\n ImageProps,\n ImgStyle,\n ImgStyle,\n ResolvedImgStyle\n>(renderImage, {\n resolveStyle: resolveImageStyle,\n measure: measureImage,\n});\nregisterOpaqueStyleProperties(Image, ['src', 'stroke', 'cursor']);\n\nfunction resolveImageStyle(\n style: Readonly<ImgStyle>,\n context: Readonly<StyleResolutionContext>,\n): ResolvedImgStyle {\n return {\n ...stripLayoutParticipation(style),\n x: 0,\n y: 0,\n width: resolveOptionalLength(\n style.width,\n context.percentageBasis.width,\n 'width',\n context,\n ),\n height: resolveOptionalLength(\n style.height,\n context.percentageBasis.height,\n 'height',\n context,\n ),\n } as ResolvedImgStyle;\n}\n\nfunction measureImage({\n style,\n constraints,\n}: MeasureInput<ImageProps, ImgStyle>): MeasureResult {\n if (\n style.width === undefined || style.width === 'auto' ||\n style.height === undefined || style.height === 'auto'\n ) {\n return {\n status: 'unsupported',\n reason: 'Image natural dimensions are unavailable during pure measurement',\n };\n }\n const context = {\n component: 'Image',\n algorithm: 'measurement' as const,\n constraints,\n };\n return {\n status: 'measured',\n size: {\n width: resolveScalarSizingLength(\n style.width,\n constraints.maxWidth,\n 'width',\n context,\n )!,\n height: resolveScalarSizingLength(\n style.height,\n constraints.maxHeight,\n 'height',\n context,\n )!,\n },\n };\n}\n"],
5
+ "mappings": "AAAA,SAAS,2BAA2B;AACpC,SAAS,uBAAuB;AAMhC,SAAS,mBAAmB;AAC5B,SAAS,mBAAmB;AAC5B,SAAS,iBAAiB;AAQ1B,SAAS,iCAAiC;AAC1C;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,qCAAqC;AAE9C,SAAS,kCAAkC;AAC3C,SAAS,wBAAwB;AAiBjC,SAAS,YACP,OACA,OACA,KACA;AACA,MAAI;AAAA,IACF;AAAA,IACA,IAAI;AAAA,IACJ,IAAI;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI;AAEJ,MAAI,YAAY,QAAW;AACzB,QAAI,cAAc,IAAI,cAAc;AA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,IACE;AAAA,IACA;AAAA,IACA;AAAA,IACA,eAAe;AAAA,IACf;AAAA,IACA,EAAE,GAAG,GAAG,OAAO,OAAO;AAAA,EACxB;AACF;AAYO,MAAM,QAAQ,gBAKnB,aAAa;AAAA,EACb,cAAc;AAAA,EACd,SAAS;AACX,CAAC;AACD,8BAA8B,OAAO,CAAC,OAAO,UAAU,QAAQ,CAAC;AAEhE,SAAS,kBACP,OACA,SACkB;AAClB,SAAO;AAAA,IACL,GAAG,yBAAyB,KAAK;AAAA,IACjC,GAAG;AAAA,IACH,GAAG;AAAA,IACH,OAAO;AAAA,MACL,MAAM;AAAA,MACN,QAAQ,gBAAgB;AAAA,MACxB;AAAA,MACA;AAAA,IACF;AAAA,IACA,QAAQ;AAAA,MACN,MAAM;AAAA,MACN,QAAQ,gBAAgB;AAAA,MACxB;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;AAEA,SAAS,aAAa;AAAA,EACpB;AAAA,EACA;AACF,GAAsD;AACpD,MACE,MAAM,UAAU,UAAa,MAAM,UAAU,UAC7C,MAAM,WAAW,UAAa,MAAM,WAAW,QAC/C;AACA,WAAO;AAAA,MACL,QAAQ;AAAA,MACR,QAAQ;AAAA,IACV;AAAA,EACF;AACA,QAAM,UAAU;AAAA,IACd,WAAW;AAAA,IACX,WAAW;AAAA,IACX;AAAA,EACF;AACA,SAAO;AAAA,IACL,QAAQ;AAAA,IACR,MAAM;AAAA,MACJ,OAAO;AAAA,QACL,MAAM;AAAA,QACN,YAAY;AAAA,QACZ;AAAA,QACA;AAAA,MACF;AAAA,MACA,QAAQ;AAAA,QACN,MAAM;AAAA,QACN,YAAY;AAAA,QACZ;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;",
6
6
  "names": []
7
7
  }
@@ -1,6 +1,15 @@
1
+ import { getLayoutDirection, hasParentLayoutAllocation } from "../layout/context.js";
2
+ import { registerLayoutSuspensionResource, unregisterLayoutSuspensionResource } from "../layout/participation.js";
3
+ import { isLayoutComponent, prepareLayoutComponent } from "../layout/define-layout-component.js";
4
+ import { isKnownLayoutType, registerKnownLayoutPreflight, preflightKnownLayout, attachPreparedLayoutSlot, stagePreparedBoundaryChildren, takePreparedBoundaryChildren, preparedBoundaryNeedsAllocationParent, retainPreparedBoundarySubtree } from "../layout/prepared-root.js";
5
+ import { prepareLayoutChildren, prepareDirectChildStyle, resolveContainerBox } from "../layout/absolute.js";
6
+ import { setPreNormalizedStyle } from "../style/resolve-dispatch.js";
7
+ import { getChildPrimitiveReceiverToken } from "../element/metadata.js";
8
+ import { preparedStyleValue, preparedStyleQuery } from "../style/responsive.js";
9
+ import { nativeLayout } from "../layout/wasm/region.js";
1
10
  import { definePrimitive } from "../define-primitive.js";
2
11
  import { materializeContainerChildren } from "../element/children.js";
3
- import { createElement } from "../element/create-element.js";
12
+ import { clonePibblElement, createElement } from "../element/create-element.js";
4
13
  import { Fragment } from "../element/fragment.js";
5
14
  import { executeRender } from "../execute-render.js";
6
15
  import {
@@ -21,7 +30,8 @@ import { getCurrentWorldTransform } from "../render-target.js";
21
30
  import { createLayerSurface } from "../surface/resolve-surface.js";
22
31
  import {
23
32
  completeInstanceRenderRevision,
24
- hasPendingInstanceRender
33
+ hasPendingInstanceRender,
34
+ setInstanceAllocationParent
25
35
  } from "../scheduler/realm-scheduler.js";
26
36
  import {
27
37
  haveSameLayerNodeTree,
@@ -32,14 +42,20 @@ import {
32
42
  } from "./structural-events.js";
33
43
  function renderLayer(props, style, ctx) {
34
44
  wireStructuralEvents(props);
35
- const materializedChildren = materializeContainerChildren(
36
- props.children,
37
- "Layer"
38
- );
39
- const nextRoot = createPrivateLayerRoot(materializedChildren);
40
45
  const canvas = GLOBAL_STATE.canvas;
41
46
  const { width = canvas.width, height = canvas.height } = style;
42
47
  const componentRefs = GLOBAL_STATE.componentRefs;
48
+ let preparedBoundary = componentRefs.element;
49
+ let preparedChildren = nativeLayout ? takePreparedBoundaryChildren(preparedBoundary) : void 0;
50
+ if (nativeLayout && !preparedChildren) {
51
+ const slot2 = preflightKnownLayout(preparedBoundary, style, { x: 0, y: 0, width, height }, GLOBAL_STATE.primitiveReceiverToken);
52
+ preparedBoundary = clonePibblElement(preparedBoundary);
53
+ attachPreparedLayoutSlot(preparedBoundary, slot2);
54
+ preparedChildren = takePreparedBoundaryChildren(preparedBoundary);
55
+ }
56
+ const materializedChildren = preparedChildren ?? materializeContainerChildren(props.children, "Layer");
57
+ const needsPreparedAllocationParent = nativeLayout && preparedBoundaryNeedsAllocationParent(preparedBoundary);
58
+ const nextRoot = createPrivateLayerRoot(materializedChildren);
43
59
  const parentInstance = getCurrentPibblInstance();
44
60
  const parentSurface = getSurfaceSnapshot(parentInstance);
45
61
  const layerSurface = createLayerSurface(
@@ -72,10 +88,17 @@ function renderLayer(props, style, ctx) {
72
88
  interactionLayer: interactionLayer2,
73
89
  logicalWidth: width,
74
90
  logicalHeight: height,
91
+ layoutDirection: void 0,
75
92
  focusRenderRevision: void 0,
76
93
  retainedTree: void 0
77
94
  };
95
+ const suspensionResource = {
96
+ suspendLayout: () => parentInstance.paintEntries.delete(interactionLayer2)
97
+ };
98
+ registerLayoutSuspensionResource(componentRefs, suspensionResource);
78
99
  componentRefs.teardowns.add(() => {
100
+ unregisterLayoutSuspensionResource(componentRefs, suspensionResource);
101
+ setInstanceAllocationParent(childInstance);
79
102
  childInstance.eventParent = void 0;
80
103
  parentInstance.paintEntries.delete(interactionLayer2);
81
104
  controller.dispose();
@@ -84,6 +107,12 @@ function renderLayer(props, style, ctx) {
84
107
  const slot = componentRefs.refs[0];
85
108
  const offscreenCanvas = slot.canvas;
86
109
  const layerPibbl = getPibblInstance(offscreenCanvas);
110
+ if (nativeLayout) setInstanceAllocationParent(
111
+ layerPibbl,
112
+ hasParentLayoutAllocation() || needsPreparedAllocationParent ? parentInstance : void 0
113
+ );
114
+ const layoutDirection = getLayoutDirection();
115
+ const directionChanged = slot.layoutDirection !== layoutDirection;
87
116
  const dimensionsChanged = slot.logicalWidth !== width || slot.logicalHeight !== height;
88
117
  const surfaceChanged = offscreenCanvas.width !== layerSurface.backingWidth || offscreenCanvas.height !== layerSurface.backingHeight;
89
118
  const { interactionLayer } = slot;
@@ -96,7 +125,7 @@ function renderLayer(props, style, ctx) {
96
125
  parentInstance.paintEntries.add(interactionLayer);
97
126
  const focusPolicy = parentInstance.eventRoot.focusPolicy;
98
127
  const focusRenderRevision = focusPolicy?.layerFocusRenderRevision?.(layerPibbl);
99
- const shouldRender = GLOBAL_STATE.componentIsMounting || dimensionsChanged || surfaceChanged || !haveSameLayerNodeTree(slot.retainedTree, nextRoot) || slot.focusRenderRevision !== focusRenderRevision || hasPendingInstanceRender(layerPibbl);
128
+ const shouldRender = GLOBAL_STATE.componentIsMounting || dimensionsChanged || directionChanged || surfaceChanged || !haveSameLayerNodeTree(slot.retainedTree, nextRoot) || slot.focusRenderRevision !== focusRenderRevision || hasPendingInstanceRender(layerPibbl);
100
129
  if (shouldRender) {
101
130
  if (layerPibbl.surface.kind !== "layer") {
102
131
  throw new Error("Pibbl layer mounted without a derived surface.");
@@ -108,15 +137,24 @@ function renderLayer(props, style, ctx) {
108
137
  slot.logicalWidth = width;
109
138
  slot.logicalHeight = height;
110
139
  const renderedRevision = layerPibbl.requestedRenderRevision;
111
- executeRender(
112
- offscreenCanvas,
113
- getCurrentPibblInstance().renderTimestamp,
114
- nextRoot,
115
- false
116
- );
117
- completeInstanceRenderRevision(layerPibbl, renderedRevision);
118
- slot.retainedTree = snapshotLayerNodeTree(nextRoot);
140
+ const previousRootLayoutDirection = layerPibbl.rootLayoutDirection;
141
+ layerPibbl.rootLayoutDirection = layoutDirection;
142
+ try {
143
+ executeRender(
144
+ offscreenCanvas,
145
+ getCurrentPibblInstance().renderTimestamp,
146
+ nextRoot,
147
+ false
148
+ );
149
+ completeInstanceRenderRevision(layerPibbl, renderedRevision);
150
+ slot.retainedTree = snapshotLayerNodeTree(nextRoot);
151
+ slot.layoutDirection = layoutDirection;
152
+ } catch (error) {
153
+ layerPibbl.rootLayoutDirection = previousRootLayoutDirection;
154
+ throw error;
155
+ }
119
156
  } else {
157
+ if (nativeLayout) retainPreparedBoundarySubtree(preparedBoundary);
120
158
  parentInstance.eventRoot.focusPolicy?.replayRetainedSubtree(layerPibbl);
121
159
  }
122
160
  const renderedFocusPolicy = parentInstance.eventRoot.focusPolicy;
@@ -138,6 +176,50 @@ const Layer = definePrimitive(renderLayer, {
138
176
  childInput: "structural",
139
177
  resolveStyle: resolveLayerStyle
140
178
  });
179
+ if (nativeLayout) registerKnownLayoutPreflight(Layer, (element, _style, content, receiver, slot) => {
180
+ const previous = GLOBAL_STATE.primitiveReceiverToken;
181
+ GLOBAL_STATE.primitiveReceiverToken = receiver;
182
+ try {
183
+ const children = prepareLayoutChildren(element.props.children, "Layer");
184
+ const placed = children.slice();
185
+ let occurrences;
186
+ for (let index = 0; index < children.length; index++) {
187
+ const child = children[index];
188
+ if (!isKnownLayoutType(child.type) && !isLayoutComponent(child.type)) continue;
189
+ let occurrence = 0;
190
+ if (child.key === void 0) {
191
+ occurrences ??= /* @__PURE__ */ new Map();
192
+ occurrence = occurrences.get(child.type) ?? 0;
193
+ occurrences.set(child.type, occurrence + 1);
194
+ }
195
+ const token = getChildPrimitiveReceiverToken(GLOBAL_STATE.renderTransaction, receiver, index);
196
+ const root = isLayoutComponent(child.type) ? prepareLayoutComponent(child, { receiverToken: token }) : child;
197
+ if (!isKnownLayoutType(root.type)) continue;
198
+ const component = root.type.name || "Layout";
199
+ const prepared = prepareDirectChildStyle(child, token, content, true);
200
+ const style = preparedStyleValue(prepared);
201
+ const context = { component, algorithm: "render-dispatch", allocation: content, percentageBasis: content, constraints: { minWidth: 0, maxWidth: content.width, minHeight: 0, maxHeight: content.height } };
202
+ let width, height;
203
+ if (root.type === Layer) {
204
+ const layerStyle = resolveLayerStyle(style, context);
205
+ width = layerStyle.width;
206
+ height = layerStyle.height;
207
+ } else {
208
+ const box = resolveContainerBox(style, context, component, "render-dispatch");
209
+ width = box.contentBox.width;
210
+ height = box.contentBox.height;
211
+ }
212
+ const nested = preflightKnownLayout(child, style, { x: 0, y: 0, width, height }, token, occurrence, slot);
213
+ const clone = clonePibblElement(child);
214
+ setPreNormalizedStyle(clone, style, child, token, preparedStyleQuery(prepared));
215
+ attachPreparedLayoutSlot(clone, nested);
216
+ placed[index] = clone;
217
+ }
218
+ stagePreparedBoundaryChildren(slot, placed);
219
+ } finally {
220
+ GLOBAL_STATE.primitiveReceiverToken = previous;
221
+ }
222
+ });
141
223
  function resolveLayerStyle(style, context) {
142
224
  return {
143
225
  ...stripLayoutParticipation(style),
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/lib/components/layer.ts"],
4
- "sourcesContent": ["import { definePrimitive } from '../define-primitive.js';\nimport { materializeContainerChildren } from '../element/children.js';\nimport { createElement } from '../element/create-element.js';\nimport { Fragment, type FragmentProps } from '../element/fragment.js';\nimport { executeRender } from '../execute-render.js';\nimport {\n getPibblInstance,\n getCurrentPibblInstance,\n GLOBAL_STATE,\n} from '../global-state.js';\nimport { mountPibbl } from '../mount-pibbl.js';\nimport {\n PibblNodeInput,\n PibblInteractionLayer,\n RenderingContext2D,\n SystemStyle,\n} from '../types.js';\nimport { PibblPaintEntryKind } from '../events/paint-entry.js';\nimport {\n resolveRequiredLength,\n stripLayoutParticipation,\n} from '../style/resolve-built-in.js';\nimport type {\n BoxStyle,\n LayoutItemStyle,\n ResolvedDrawingStyle,\n} from '../style/types.js';\nimport {\n getSurfaceSnapshot,\n} from '../surface/transform.js';\nimport { getCurrentWorldTransform } from '../render-target.js';\nimport { createLayerSurface } from '../surface/resolve-surface.js';\nimport {\n completeInstanceRenderRevision,\n hasPendingInstanceRender,\n} from '../scheduler/realm-scheduler.js';\nimport type { PibblElement } from '../element/types.js';\nimport {\n haveSameLayerNodeTree,\n snapshotLayerNodeTree,\n type LayerNodeSnapshot,\n} from './layer-node-equality.js';\nimport {\n type PibblStructuralEventProps,\n wireStructuralEvents,\n} from './structural-events.js';\n\n/**\n * Authored inputs for Layer, including the declared data and presentation options.\n *\n * @see {@link PibblNodeInput}\n * @see {@link Layer}\n */\nexport interface LayerProps extends PibblStructuralEventProps {\n /** Descendant content or the callback that supplies it. See {@link PibblNodeInput}. */\n children: PibblNodeInput;\n}\n\n/**\n * Supported geometry and presentation properties for Layer.\n *\n * @see {@link SystemStyle}\n * @see {@link BoxStyle}\n * @see {@link LayoutItemStyle}\n * @see {@link Layer}\n */\nexport interface LayerStyle extends SystemStyle, BoxStyle, LayoutItemStyle {}\n\ntype ResolvedLayerStyle = ResolvedDrawingStyle<LayerStyle> & {\n width: number;\n height: number;\n};\n\ninterface LayerSlot {\n canvas: OffscreenCanvas;\n interactionLayer: PibblInteractionLayer;\n logicalWidth: number;\n logicalHeight: number;\n focusRenderRevision: number | undefined;\n retainedTree: LayerNodeSnapshot | undefined;\n}\n\nfunction renderLayer(\n props: LayerProps,\n style: Readonly<ResolvedLayerStyle>,\n ctx: RenderingContext2D,\n) {\n wireStructuralEvents(props);\n const materializedChildren = materializeContainerChildren(\n props.children,\n 'Layer',\n );\n const nextRoot = createPrivateLayerRoot(materializedChildren);\n const canvas = GLOBAL_STATE.canvas!;\n const { width = canvas.width, height = canvas.height } = style;\n const componentRefs = GLOBAL_STATE.componentRefs!;\n const parentInstance = getCurrentPibblInstance();\n const parentSurface = getSurfaceSnapshot(parentInstance);\n const layerSurface = createLayerSurface(\n width,\n height,\n parentSurface.backingPixelsPerLogicalUnitX,\n parentSurface.backingPixelsPerLogicalUnitY,\n );\n if (GLOBAL_STATE.componentIsMounting) {\n const offscreenCanvas = new OffscreenCanvas(\n layerSurface.backingWidth,\n layerSurface.backingHeight,\n );\n const controller = mountPibbl(offscreenCanvas, nextRoot, {\n parent: canvas,\n surface: layerSurface,\n });\n const childInstance = getPibblInstance(offscreenCanvas);\n childInstance.eventParent = componentRefs;\n const interactionLayer: PibblInteractionLayer = {\n paintKind: PibblPaintEntryKind.NestedInstance,\n instance: childInstance,\n transform: new DOMMatrix(),\n clippingStack: [],\n bounds: createBounds(width, height),\n resolveLocal: undefined,\n };\n componentRefs.refs[0] = {\n canvas: offscreenCanvas,\n interactionLayer,\n logicalWidth: width,\n logicalHeight: height,\n focusRenderRevision: undefined,\n retainedTree: undefined,\n } satisfies LayerSlot;\n componentRefs.teardowns.add(() => {\n childInstance.eventParent = undefined;\n parentInstance.paintEntries.delete(interactionLayer);\n controller.dispose();\n });\n }\n\n const slot = componentRefs.refs[0] as LayerSlot;\n const offscreenCanvas = slot.canvas;\n const layerPibbl = getPibblInstance(offscreenCanvas);\n const dimensionsChanged = slot.logicalWidth !== width ||\n slot.logicalHeight !== height;\n const surfaceChanged =\n offscreenCanvas.width !== layerSurface.backingWidth ||\n offscreenCanvas.height !== layerSurface.backingHeight;\n\n const { interactionLayer } = slot;\n parentInstance.paintEntries.delete(interactionLayer);\n interactionLayer.transform = getCurrentWorldTransform();\n interactionLayer.clippingStack = Array.from(GLOBAL_STATE.clippingStack);\n if (dimensionsChanged) {\n interactionLayer.bounds = createBounds(width, height);\n }\n // Install the current bridge before entering the child render. Focus bounds\n // collected by the child must never see the previous frame's transform.\n parentInstance.paintEntries.add(interactionLayer);\n\n const focusPolicy = parentInstance.eventRoot.focusPolicy;\n const focusRenderRevision = focusPolicy?.layerFocusRenderRevision?.(layerPibbl);\n\n const shouldRender =\n GLOBAL_STATE.componentIsMounting ||\n dimensionsChanged ||\n surfaceChanged ||\n !haveSameLayerNodeTree(slot.retainedTree, nextRoot) ||\n slot.focusRenderRevision !== focusRenderRevision ||\n hasPendingInstanceRender(layerPibbl);\n if (shouldRender) {\n if (layerPibbl.surface.kind !== 'layer') {\n throw new Error('Pibbl layer mounted without a derived surface.');\n }\n layerPibbl.surface.snapshot = layerSurface;\n layerPibbl.surface.managed = true;\n offscreenCanvas.width = layerSurface.backingWidth;\n offscreenCanvas.height = layerSurface.backingHeight;\n slot.logicalWidth = width;\n slot.logicalHeight = height;\n\n const renderedRevision = layerPibbl.requestedRenderRevision;\n executeRender(\n offscreenCanvas,\n getCurrentPibblInstance().renderTimestamp,\n nextRoot,\n false,\n );\n completeInstanceRenderRevision(layerPibbl, renderedRevision);\n slot.retainedTree = snapshotLayerNodeTree(nextRoot);\n } else {\n parentInstance.eventRoot.focusPolicy?.replayRetainedSubtree(layerPibbl);\n }\n const renderedFocusPolicy = parentInstance.eventRoot.focusPolicy;\n slot.focusRenderRevision =\n renderedFocusPolicy?.layerFocusRenderRevision?.(layerPibbl);\n\n parentInstance.eventRoot.html?.recordLayer(parentInstance, layerPibbl, interactionLayer, ctx.globalAlpha, ctx.globalCompositeOperation);\n\n ctx.drawImage(\n offscreenCanvas,\n 0,\n 0,\n offscreenCanvas.width,\n offscreenCanvas.height,\n 0,\n 0,\n width,\n height,\n );\n\n}\n\n/**\n * Describes a retained offscreen composition layer.\n *\n * @param props - Authored component inputs, supplied through JSX or createElement. See the linked\n * props and style types.\n * @throws When called directly; Pibbl mounts this component through JSX or createElement.\n *\n * @see {@link LayerProps}\n * @see {@link LayerStyle}\n */\nexport const Layer = definePrimitive<\n LayerProps,\n LayerStyle,\n LayerStyle,\n ResolvedLayerStyle\n>(renderLayer, {\n childInput: 'structural',\n resolveStyle: resolveLayerStyle,\n});\n\nfunction resolveLayerStyle(\n style: Readonly<LayerStyle>,\n context: Parameters<NonNullable<\n import('../types.js').PrimitiveCapabilities<\n LayerProps,\n LayerStyle,\n LayerStyle,\n ResolvedLayerStyle\n >['resolveStyle']\n >>[1],\n): ResolvedLayerStyle {\n return {\n ...stripLayoutParticipation(style),\n width: resolveRequiredLength(\n style.width ?? context.allocation.width,\n context.percentageBasis.width,\n 'width',\n context,\n ),\n height: resolveRequiredLength(\n style.height ?? context.allocation.height,\n context.percentageBasis.height,\n 'height',\n context,\n ),\n } as ResolvedLayerStyle;\n}\n\nfunction createPrivateLayerRoot(\n children: readonly PibblElement<any>[],\n): PibblElement<FragmentProps> {\n return createElement(Fragment, {\n key: 'pibbl-layer-root',\n children,\n });\n}\n\nfunction createBounds(width: number, height: number): Path2D {\n const bounds = new Path2D();\n bounds.rect(0, 0, width, height);\n return bounds;\n}\n"],
5
- "mappings": "AAAA,SAAS,uBAAuB;AAChC,SAAS,oCAAoC;AAC7C,SAAS,qBAAqB;AAC9B,SAAS,gBAAoC;AAC7C,SAAS,qBAAqB;AAC9B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,kBAAkB;AAO3B,SAAS,2BAA2B;AACpC;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAMP;AAAA,EACE;AAAA,OACK;AACP,SAAS,gCAAgC;AACzC,SAAS,0BAA0B;AACnC;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAEP;AAAA,EACE;AAAA,EACA;AAAA,OAEK;AACP;AAAA,EAEE;AAAA,OACK;AAqCP,SAAS,YACP,OACA,OACA,KACA;AACA,uBAAqB,KAAK;AAC1B,QAAM,uBAAuB;AAAA,IAC3B,MAAM;AAAA,IACN;AAAA,EACF;AACA,QAAM,WAAW,uBAAuB,oBAAoB;AAC5D,QAAM,SAAS,aAAa;AAC5B,QAAM,EAAE,QAAQ,OAAO,OAAO,SAAS,OAAO,OAAO,IAAI;AACzD,QAAM,gBAAgB,aAAa;AACnC,QAAM,iBAAiB,wBAAwB;AAC/C,QAAM,gBAAgB,mBAAmB,cAAc;AACvD,QAAM,eAAe;AAAA,IACnB;AAAA,IACA;AAAA,IACA,cAAc;AAAA,IACd,cAAc;AAAA,EAChB;AACA,MAAI,aAAa,qBAAqB;AACpC,UAAMA,mBAAkB,IAAI;AAAA,MAC1B,aAAa;AAAA,MACb,aAAa;AAAA,IACf;AACA,UAAM,aAAa,WAAWA,kBAAiB,UAAU;AAAA,MACvD,QAAQ;AAAA,MACR,SAAS;AAAA,IACX,CAAC;AACD,UAAM,gBAAgB,iBAAiBA,gBAAe;AACtD,kBAAc,cAAc;AAC5B,UAAMC,oBAA0C;AAAA,MAC9C,WAAW,oBA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AAG,OAAO,MAAM;AAC/B,SAAO;AACT;",
6
- "names": ["offscreenCanvas", "interactionLayer"]
4
+ "sourcesContent": ["import { getLayoutDirection, hasParentLayoutAllocation } from '../layout/context.js';\nimport { registerLayoutSuspensionResource, unregisterLayoutSuspensionResource } from '../layout/participation.js';\nimport { isLayoutComponent, prepareLayoutComponent } from '../layout/define-layout-component.js';\nimport { isKnownLayoutType, registerKnownLayoutPreflight, preflightKnownLayout, attachPreparedLayoutSlot, stagePreparedBoundaryChildren, takePreparedBoundaryChildren, preparedBoundaryNeedsAllocationParent, retainPreparedBoundarySubtree } from '../layout/prepared-root.js';\nimport { prepareLayoutChildren, prepareDirectChildStyle, resolveContainerBox } from '../layout/absolute.js';\nimport { setPreNormalizedStyle } from '../style/resolve-dispatch.js';\nimport { getChildPrimitiveReceiverToken } from '../element/metadata.js';\nimport { preparedStyleValue, preparedStyleQuery } from '../style/responsive.js';\nimport { nativeLayout } from '../layout/wasm/region.js';\nimport { definePrimitive } from '../define-primitive.js';\nimport { materializeContainerChildren } from '../element/children.js';\nimport { clonePibblElement, createElement } from '../element/create-element.js';\nimport { Fragment, type FragmentProps } from '../element/fragment.js';\nimport { executeRender } from '../execute-render.js';\nimport {\n getPibblInstance,\n getCurrentPibblInstance,\n GLOBAL_STATE,\n} from '../global-state.js';\nimport { mountPibbl } from '../mount-pibbl.js';\nimport {\n PibblNodeInput,\n PibblInteractionLayer,\n RenderingContext2D,\n SystemStyle,\n} from '../types.js';\nimport { PibblPaintEntryKind } from '../events/paint-entry.js';\nimport {\n resolveRequiredLength,\n stripLayoutParticipation,\n} from '../style/resolve-built-in.js';\nimport type {\n BoxStyle,\n LayoutItemStyle,\n ResolvedDrawingStyle,\n} from '../style/types.js';\nimport {\n getSurfaceSnapshot,\n} from '../surface/transform.js';\nimport { getCurrentWorldTransform } from '../render-target.js';\nimport { createLayerSurface } from '../surface/resolve-surface.js';\nimport {\n completeInstanceRenderRevision,\n hasPendingInstanceRender,\n setInstanceAllocationParent,\n} from '../scheduler/realm-scheduler.js';\nimport type { PibblElement } from '../element/types.js';\nimport {\n haveSameLayerNodeTree,\n snapshotLayerNodeTree,\n type LayerNodeSnapshot,\n} from './layer-node-equality.js';\nimport {\n type PibblStructuralEventProps,\n wireStructuralEvents,\n} from './structural-events.js';\n\n/**\n * Authored inputs for Layer, including the declared data and presentation options.\n *\n * @see {@link PibblNodeInput}\n * @see {@link Layer}\n */\nexport interface LayerProps extends PibblStructuralEventProps {\n /** Descendant content or the callback that supplies it. See {@link PibblNodeInput}. */\n children: PibblNodeInput;\n}\n\n/**\n * Supported geometry and presentation properties for Layer.\n *\n * @see {@link SystemStyle}\n * @see {@link BoxStyle}\n * @see {@link LayoutItemStyle}\n * @see {@link Layer}\n */\nexport interface LayerStyle extends SystemStyle, BoxStyle, LayoutItemStyle {}\n\ntype ResolvedLayerStyle = ResolvedDrawingStyle<LayerStyle> & {\n width: number;\n height: number;\n};\n\ninterface LayerSlot {\n canvas: OffscreenCanvas;\n interactionLayer: PibblInteractionLayer;\n logicalWidth: number;\n logicalHeight: number;\n /** Direction used for the currently retained child bitmap. */\n layoutDirection: 'ltr' | 'rtl' | undefined;\n focusRenderRevision: number | undefined;\n retainedTree: LayerNodeSnapshot | undefined;\n}\n\nfunction renderLayer(\n props: LayerProps,\n style: Readonly<ResolvedLayerStyle>,\n ctx: RenderingContext2D,\n) {\n wireStructuralEvents(props);\n const canvas = GLOBAL_STATE.canvas!;\n const { width = canvas.width, height = canvas.height } = style;\n const componentRefs = GLOBAL_STATE.componentRefs!;\n let preparedBoundary = componentRefs.element;\n let preparedChildren = nativeLayout ? takePreparedBoundaryChildren(preparedBoundary) : undefined;\n if (nativeLayout && !preparedChildren) {\n const slot = preflightKnownLayout(preparedBoundary, style, { x: 0, y: 0, width, height }, GLOBAL_STATE.primitiveReceiverToken);\n // Keep transaction metadata off the application-owned reusable descriptor.\n preparedBoundary = clonePibblElement(preparedBoundary);\n attachPreparedLayoutSlot(preparedBoundary, slot);\n preparedChildren = takePreparedBoundaryChildren(preparedBoundary);\n }\n const materializedChildren = preparedChildren ?? materializeContainerChildren(props.children, 'Layer');\n const needsPreparedAllocationParent = nativeLayout && preparedBoundaryNeedsAllocationParent(preparedBoundary);\n const nextRoot = createPrivateLayerRoot(materializedChildren);\n const parentInstance = getCurrentPibblInstance();\n const parentSurface = getSurfaceSnapshot(parentInstance);\n const layerSurface = createLayerSurface(\n width,\n height,\n parentSurface.backingPixelsPerLogicalUnitX,\n parentSurface.backingPixelsPerLogicalUnitY,\n );\n if (GLOBAL_STATE.componentIsMounting) {\n const offscreenCanvas = new OffscreenCanvas(\n layerSurface.backingWidth,\n layerSurface.backingHeight,\n );\n const controller = mountPibbl(offscreenCanvas, nextRoot, {\n parent: canvas,\n surface: layerSurface,\n });\n const childInstance = getPibblInstance(offscreenCanvas);\n childInstance.eventParent = componentRefs;\n const interactionLayer: PibblInteractionLayer = {\n paintKind: PibblPaintEntryKind.NestedInstance,\n instance: childInstance,\n transform: new DOMMatrix(),\n clippingStack: [],\n bounds: createBounds(width, height),\n resolveLocal: undefined,\n };\n componentRefs.refs[0] = {\n canvas: offscreenCanvas,\n interactionLayer,\n logicalWidth: width,\n logicalHeight: height,\n layoutDirection: undefined,\n focusRenderRevision: undefined,\n retainedTree: undefined,\n } satisfies LayerSlot;\n const suspensionResource = {\n suspendLayout: () => parentInstance.paintEntries.delete(interactionLayer),\n };\n registerLayoutSuspensionResource(componentRefs, suspensionResource);\n componentRefs.teardowns.add(() => {\n unregisterLayoutSuspensionResource(componentRefs, suspensionResource);\n setInstanceAllocationParent(childInstance);\n childInstance.eventParent = undefined;\n parentInstance.paintEntries.delete(interactionLayer);\n controller.dispose();\n });\n }\n\n const slot = componentRefs.refs[0] as LayerSlot;\n const offscreenCanvas = slot.canvas;\n const layerPibbl = getPibblInstance(offscreenCanvas);\n if (nativeLayout) setInstanceAllocationParent(layerPibbl,\n hasParentLayoutAllocation() || needsPreparedAllocationParent ? parentInstance : undefined);\n const layoutDirection = getLayoutDirection();\n const directionChanged = slot.layoutDirection !== layoutDirection;\n const dimensionsChanged = slot.logicalWidth !== width ||\n slot.logicalHeight !== height;\n const surfaceChanged =\n offscreenCanvas.width !== layerSurface.backingWidth ||\n offscreenCanvas.height !== layerSurface.backingHeight;\n\n const { interactionLayer } = slot;\n parentInstance.paintEntries.delete(interactionLayer);\n interactionLayer.transform = getCurrentWorldTransform();\n interactionLayer.clippingStack = Array.from(GLOBAL_STATE.clippingStack);\n if (dimensionsChanged) {\n interactionLayer.bounds = createBounds(width, height);\n }\n // Install the current bridge before entering the child render. Focus bounds\n // collected by the child must never see the previous frame's transform.\n parentInstance.paintEntries.add(interactionLayer);\n\n const focusPolicy = parentInstance.eventRoot.focusPolicy;\n const focusRenderRevision = focusPolicy?.layerFocusRenderRevision?.(layerPibbl);\n\n const shouldRender =\n GLOBAL_STATE.componentIsMounting ||\n dimensionsChanged ||\n directionChanged ||\n surfaceChanged ||\n !haveSameLayerNodeTree(slot.retainedTree, nextRoot) ||\n slot.focusRenderRevision !== focusRenderRevision ||\n hasPendingInstanceRender(layerPibbl);\n if (shouldRender) {\n if (layerPibbl.surface.kind !== 'layer') {\n throw new Error('Pibbl layer mounted without a derived surface.');\n }\n layerPibbl.surface.snapshot = layerSurface;\n layerPibbl.surface.managed = true;\n offscreenCanvas.width = layerSurface.backingWidth;\n offscreenCanvas.height = layerSurface.backingHeight;\n slot.logicalWidth = width;\n slot.logicalHeight = height;\n\n const renderedRevision = layerPibbl.requestedRenderRevision;\n const previousRootLayoutDirection = layerPibbl.rootLayoutDirection;\n layerPibbl.rootLayoutDirection = layoutDirection;\n try {\n executeRender(\n offscreenCanvas,\n getCurrentPibblInstance().renderTimestamp,\n nextRoot,\n false,\n );\n completeInstanceRenderRevision(layerPibbl, renderedRevision);\n slot.retainedTree = snapshotLayerNodeTree(nextRoot);\n slot.layoutDirection = layoutDirection;\n } catch (error) {\n layerPibbl.rootLayoutDirection = previousRootLayoutDirection;\n throw error;\n }\n } else {\n if (nativeLayout) retainPreparedBoundarySubtree(preparedBoundary);\n parentInstance.eventRoot.focusPolicy?.replayRetainedSubtree(layerPibbl);\n }\n const renderedFocusPolicy = parentInstance.eventRoot.focusPolicy;\n slot.focusRenderRevision =\n renderedFocusPolicy?.layerFocusRenderRevision?.(layerPibbl);\n\n parentInstance.eventRoot.html?.recordLayer(parentInstance, layerPibbl, interactionLayer, ctx.globalAlpha, ctx.globalCompositeOperation);\n\n ctx.drawImage(\n offscreenCanvas,\n 0,\n 0,\n offscreenCanvas.width,\n offscreenCanvas.height,\n 0,\n 0,\n width,\n height,\n );\n\n}\n\n/**\n * Describes a retained offscreen composition layer.\n *\n * @param props - Authored component inputs, supplied through JSX or createElement. See the linked\n * props and style types.\n * @throws When called directly; Pibbl mounts this component through JSX or createElement.\n *\n * @see {@link LayerProps}\n * @see {@link LayerStyle}\n */\nexport const Layer = definePrimitive<\n LayerProps,\n LayerStyle,\n LayerStyle,\n ResolvedLayerStyle\n>(renderLayer, {\n childInput: 'structural',\n resolveStyle: resolveLayerStyle,\n});\n\nif (nativeLayout) registerKnownLayoutPreflight(Layer, (element, _style, content, receiver, slot) => {\n const previous = GLOBAL_STATE.primitiveReceiverToken;\n GLOBAL_STATE.primitiveReceiverToken = receiver;\n try {\n const children = prepareLayoutChildren(element.props.children, 'Layer');\n const placed = children.slice();\n let occurrences: Map<Function, number> | undefined;\n for (let index = 0; index < children.length; index++) {\n const child = children[index];\n // Layer is a raster boundary, not a layout algorithm for arbitrary children.\n if (!isKnownLayoutType(child.type) && !isLayoutComponent(child.type)) continue;\n let occurrence = 0;\n if (child.key === undefined) {\n occurrences ??= new Map(); occurrence = occurrences.get(child.type) ?? 0;\n occurrences.set(child.type, occurrence + 1);\n }\n const token = getChildPrimitiveReceiverToken(GLOBAL_STATE.renderTransaction, receiver, index);\n const root = isLayoutComponent(child.type) ? prepareLayoutComponent(child, { receiverToken: token }) : child;\n if (!isKnownLayoutType(root.type)) continue;\n const component = root.type.name || 'Layout';\n const prepared = prepareDirectChildStyle(child, token, content, true);\n const style = preparedStyleValue(prepared);\n const context = { component, algorithm: 'render-dispatch' as const, allocation: content, percentageBasis: content, constraints: { minWidth: 0, maxWidth: content.width, minHeight: 0, maxHeight: content.height } };\n // A nested raster boundary uses Layer's actual dimensions, not box layout.\n let width: number, height: number;\n if (root.type === Layer) {\n const layerStyle = resolveLayerStyle(style, context);\n width = layerStyle.width!; height = layerStyle.height!;\n } else {\n const box = resolveContainerBox(style, context, component, 'render-dispatch');\n width = box.contentBox.width; height = box.contentBox.height;\n }\n const nested = preflightKnownLayout(child, style, { x: 0, y: 0, width, height }, token, occurrence, slot);\n const clone = clonePibblElement(child);\n setPreNormalizedStyle(clone, style, child, token, preparedStyleQuery(prepared));\n attachPreparedLayoutSlot(clone, nested); placed[index] = clone;\n }\n stagePreparedBoundaryChildren(slot, placed);\n } finally { GLOBAL_STATE.primitiveReceiverToken = previous; }\n});\n\nfunction resolveLayerStyle(\n style: Readonly<LayerStyle>,\n context: Parameters<NonNullable<\n import('../types.js').PrimitiveCapabilities<\n LayerProps,\n LayerStyle,\n LayerStyle,\n ResolvedLayerStyle\n >['resolveStyle']\n >>[1],\n): ResolvedLayerStyle {\n return {\n ...stripLayoutParticipation(style),\n width: resolveRequiredLength(\n style.width ?? context.allocation.width,\n context.percentageBasis.width,\n 'width',\n context,\n ),\n height: resolveRequiredLength(\n style.height ?? context.allocation.height,\n context.percentageBasis.height,\n 'height',\n context,\n ),\n } as ResolvedLayerStyle;\n}\n\nfunction createPrivateLayerRoot(\n children: readonly PibblElement<any>[],\n): PibblElement<FragmentProps> {\n return createElement(Fragment, {\n key: 'pibbl-layer-root',\n children,\n });\n}\n\nfunction createBounds(width: number, height: number): Path2D {\n const bounds = new Path2D();\n bounds.rect(0, 0, width, height);\n return bounds;\n}\n"],
5
+ "mappings": "AAAA,SAAS,oBAAoB,iCAAiC;AAC9D,SAAS,kCAAkC,0CAA0C;AACrF,SAAS,mBAAmB,8BAA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P,UAC6B;AAC7B,SAAO,cAAc,UAAU;AAAA,IAC7B,KAAK;AAAA,IACL;AAAA,EACF,CAAC;AACH;AAEA,SAAS,aAAa,OAAe,QAAwB;AAC3D,QAAM,SAAS,IAAI,OAAO;AAC1B,SAAO,KAAK,GAAG,GAAG,OAAO,MAAM;AAC/B,SAAO;AACT;",
6
+ "names": ["slot", "offscreenCanvas", "interactionLayer"]
7
7
  }
@@ -1,5 +1,6 @@
1
1
  import type { PibblEventFocusOptions, PibblEventHandlers, PibblEventParticipationOptions } from '../events/types.js';
2
2
  import type { TextStyle } from '../style/types.js';
3
+ import { CanvasMeasurementService } from '../types.js';
3
4
  import type { PibblTextInput } from '../types.js';
4
5
  import type { PibblPhysics2DPropExtension } from '../types.js';
5
6
  /**
@@ -27,3 +28,18 @@ export interface TextProps extends PibblEventHandlers, PibblEventFocusOptions, P
27
28
  * @see {@link TextStyle}
28
29
  */
29
30
  export declare const Text: import("@pibbl/core").PibblPrimitiveComponent<TextProps, import("@pibbl/core").PrimitiveInput<TextProps, TextStyle>>;
31
+ /** @internal Measure a materialized value without bypassing receiver reads. */
32
+ export declare function measureLayoutTextNaturalRun(text: string, options: {
33
+ font: string;
34
+ service: CanvasMeasurementService;
35
+ }): number;
36
+ /** @internal Longest run under Text's existing ASCII-space wrapping contract. */
37
+ export declare function measureLayoutTextMinimumWidth(props: Readonly<TextProps>, options: {
38
+ font: string;
39
+ service: CanvasMeasurementService;
40
+ receiverToken?: object;
41
+ }): number;
42
+ /** @internal Prepare measured Text through its existing transaction/receiver ownership. */
43
+ export declare function prepareLayoutTextContent(props: Readonly<TextProps>, options: {
44
+ receiverToken?: object;
45
+ }): string;
@@ -7,11 +7,14 @@ import {
7
7
  stripLayoutParticipation
8
8
  } from "../style/resolve-built-in.js";
9
9
  import { registerOpaqueStyleProperties } from "../style/resolve-dispatch.js";
10
- import { resolveLength } from "../style/resolve-length.js";
10
+ import { resolveScalarSizingLength } from "../style/sizing-length.js";
11
+ import { normalizeBoxInsets } from "../layout/box-insets.js";
11
12
  import { wireCommonEvents } from "../util/wire-common-events.js";
12
13
  import { pushClippingPath } from "../util/push-clipping-path.js";
13
14
  import { resolveTextClipBounds, resolveTextLayout } from "./text-layout.js";
14
15
  import { withReceiverInputProvision } from "../signals/input-provision.js";
16
+ import { withSignalDependencyRole, withSignalWriteForbidden } from "../signals/graph.js";
17
+ import { withHooksForbidden } from "../hooks/hook-slot.js";
15
18
  const materializedTextTransactions = /* @__PURE__ */ new WeakMap();
16
19
  function renderText(props, style, ctx) {
17
20
  const text = materializeTextContent(props);
@@ -85,28 +88,43 @@ function renderText(props, style, ctx) {
85
88
  }
86
89
  const Text = definePrimitive(renderText, {
87
90
  childInput: "text",
88
- resolveStyle: (style, context) => ({
89
- ...stripLayoutParticipation(style),
90
- x: 0,
91
- y: 0,
92
- width: resolveOptionalLength(
93
- style.width,
94
- context.percentageBasis.width,
95
- "width",
96
- context
97
- ),
98
- height: resolveOptionalLength(
99
- style.height,
100
- context.percentageBasis.height,
101
- "height",
102
- context
103
- )
104
- }),
91
+ resolveStyle: (style, context) => {
92
+ let x = 0, y = 0;
93
+ if (style.padding !== void 0 || style.paddingStart !== void 0 || style.paddingEnd !== void 0 || style.borderWidth !== void 0 || style.borderStartWidth !== void 0 || style.borderEndWidth !== void 0) {
94
+ const insets = normalizeBoxInsets(style, context);
95
+ x = insets.left;
96
+ y = insets.top;
97
+ }
98
+ return {
99
+ ...stripLayoutParticipation(style),
100
+ x,
101
+ y,
102
+ width: resolveOptionalLength(
103
+ style.width,
104
+ context.percentageBasis.width,
105
+ "width",
106
+ context
107
+ ),
108
+ height: resolveOptionalLength(
109
+ style.height,
110
+ context.percentageBasis.height,
111
+ "height",
112
+ context
113
+ )
114
+ };
115
+ },
105
116
  measure: ({ props, style, constraints, service }) => measureTextStyle(
106
117
  materializeTextContent(props),
107
118
  style,
108
119
  constraints,
109
120
  service
121
+ ),
122
+ measureIntrinsic: ({ props, style, service }) => measureTextIntrinsic(props, style, service),
123
+ measureBaselines: ({ props, style, allocation, service }) => measureTextBaselines(
124
+ materializeTextContent(props),
125
+ style,
126
+ allocation,
127
+ service
110
128
  )
111
129
  });
112
130
  registerOpaqueStyleProperties(Text, [
@@ -118,14 +136,62 @@ registerOpaqueStyleProperties(Text, [
118
136
  "textBaseline",
119
137
  "textAlign"
120
138
  ]);
139
+ function measureTextBaselines(text, style, allocation, service) {
140
+ if (text.length === 0) return { status: "unsupported", reason: "Text baseline measurement requires nonempty text" };
141
+ const measureAtBaseline = service.measureTextAtBaseline;
142
+ if (!measureAtBaseline) {
143
+ return {
144
+ status: "unsupported",
145
+ reason: "Text baseline measurement requires CanvasMeasurementService.measureTextAtBaseline"
146
+ };
147
+ }
148
+ const font = style.font ?? "13px sans-serif";
149
+ const textBaseline = style.textBaseline ?? "top";
150
+ const layout = resolveTextLayout(
151
+ (value) => measureAtBaseline.call(service, value, { font, textBaseline }),
152
+ text,
153
+ { ...style, x: 0, y: 0, width: allocation.width, height: allocation.height }
154
+ );
155
+ const firstLine = layout.lines[0];
156
+ const lastLine = layout.lines[layout.lines.length - 1];
157
+ if (!firstLine || !lastLine || firstLine.text.length === 0 || lastLine.text.length === 0) {
158
+ return { status: "unsupported", reason: "Text does not resolve a line for baseline measurement: requires a nonempty rendered baseline line" };
159
+ }
160
+ const firstMetrics = measureAtBaseline.call(service, firstLine.text, { font, textBaseline });
161
+ const first = firstLine.y - firstMetrics.alphabeticBaseline;
162
+ let last = first;
163
+ if (lastLine !== firstLine) {
164
+ const lastMetrics = measureAtBaseline.call(service, lastLine.text, { font, textBaseline });
165
+ last = lastLine.y - lastMetrics.alphabeticBaseline;
166
+ }
167
+ if (!Number.isFinite(first) || !Number.isFinite(last)) {
168
+ return {
169
+ status: "unsupported",
170
+ reason: "Canvas text metrics do not provide a finite alphabeticBaseline for Text baseline measurement"
171
+ };
172
+ }
173
+ return { status: "measured", first, last };
174
+ }
175
+ function measureTextIntrinsic(props, style, service) {
176
+ const text = prepareLayoutTextContent(props, {});
177
+ const font = style.font ?? "13px sans-serif";
178
+ const maximum = style.wrap ? measureLayoutTextNaturalRun(text, { font, service }) : service.measureText(text, font).width;
179
+ const minimum = style.wrap ? measureLayoutTextMinimumWidth(props, { font, service }) : maximum;
180
+ const intrinsicStyle = { ...style, width: void 0, height: void 0, fit: "visible" };
181
+ const minResult = measureTextStyle(text, intrinsicStyle, { minWidth: 0, maxWidth: minimum, minHeight: 0, maxHeight: Infinity }, service);
182
+ const maxResult = measureTextStyle(text, intrinsicStyle, { minWidth: 0, maxWidth: maximum, minHeight: 0, maxHeight: Infinity }, service);
183
+ if (minResult.status !== "measured") return minResult;
184
+ if (maxResult.status !== "measured") return maxResult;
185
+ return { status: "measured", minContent: { width: minimum, height: minResult.size.height }, maxContent: { width: maximum, height: maxResult.size.height } };
186
+ }
121
187
  function measureTextStyle(text, style, constraints, service) {
122
188
  const context = {
123
189
  component: "Text",
124
190
  algorithm: "measurement",
125
191
  constraints
126
192
  };
127
- const specifiedWidth = style.width === void 0 ? void 0 : resolveLength(style.width, constraints.maxWidth, "width", context);
128
- const specifiedHeight = style.height === void 0 ? void 0 : resolveLength(style.height, constraints.maxHeight, "height", context);
193
+ const specifiedWidth = style.width === void 0 ? void 0 : resolveScalarSizingLength(style.width, constraints.maxWidth, "width", context);
194
+ const specifiedHeight = style.height === void 0 ? void 0 : resolveScalarSizingLength(style.height, constraints.maxHeight, "height", context);
129
195
  const layoutWidth = specifiedWidth ?? (style.wrap && Number.isFinite(constraints.maxWidth) ? constraints.maxWidth : void 0);
130
196
  const font = style.font ?? "13px sans-serif";
131
197
  const layout = resolveTextLayout(
@@ -147,9 +213,44 @@ function measureTextStyle(text, style, constraints, service) {
147
213
  }
148
214
  };
149
215
  }
150
- function materializeTextContent(props) {
216
+ function measureLayoutTextNaturalRun(text, options) {
217
+ let start = 0;
218
+ while (text.charCodeAt(start) === 32) start++;
219
+ if (start === text.length) return 0;
220
+ const width = options.service.measureText(text.slice(start), options.font).width;
221
+ if (!Number.isFinite(width) || width < 0) {
222
+ throw new Error("Text intrinsic measurement requires a finite nonnegative natural width.");
223
+ }
224
+ return width;
225
+ }
226
+ function measureLayoutTextMinimumWidth(props, options) {
227
+ const text = prepareLayoutTextContent(props, { receiverToken: options.receiverToken });
228
+ let longest = 0;
229
+ let start = 0;
230
+ for (let index = 0; index <= text.length; index++) {
231
+ if (index !== text.length && text.charCodeAt(index) !== 32) continue;
232
+ if (index > start) {
233
+ const width = options.service.measureText(text.slice(start, index), options.font).width;
234
+ if (!Number.isFinite(width) || width < 0) {
235
+ throw new Error("Text intrinsic measurement requires finite nonnegative word widths.");
236
+ }
237
+ if (width > longest) longest = width;
238
+ }
239
+ start = index + 1;
240
+ }
241
+ return longest;
242
+ }
243
+ function prepareLayoutTextContent(props, options) {
244
+ return withSignalWriteForbidden(
245
+ "Signal writes are forbidden during Pibbl measurement",
246
+ () => withHooksForbidden(
247
+ "Pibbl hooks cannot be called while preparing measured Text content.",
248
+ () => materializeTextContent(props, options.receiverToken)
249
+ )
250
+ );
251
+ }
252
+ function materializeTextContent(props, receiver = GLOBAL_STATE.primitiveReceiverToken) {
151
253
  const transaction = GLOBAL_STATE.renderTransaction;
152
- const receiver = GLOBAL_STATE.primitiveReceiverToken;
153
254
  if (!transaction || !receiver) {
154
255
  return materializeTextChildren(props.children, "Text");
155
256
  }
@@ -163,12 +264,18 @@ function materializeTextContent(props) {
163
264
  const materialized = withReceiverInputProvision(
164
265
  transaction,
165
266
  receiver,
166
- () => materializeTextChildren(props.children, "Text")
267
+ () => withSignalDependencyRole(
268
+ "measurement",
269
+ () => materializeTextChildren(props.children, "Text")
270
+ )
167
271
  );
168
272
  receivers.set(receiver, materialized);
169
273
  return materialized;
170
274
  }
171
275
  export {
172
- Text
276
+ Text,
277
+ measureLayoutTextMinimumWidth,
278
+ measureLayoutTextNaturalRun,
279
+ prepareLayoutTextContent
173
280
  };
174
281
  //# sourceMappingURL=text.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/lib/components/text.ts"],
4
- "sourcesContent": ["import { resolveTexturePaint } from '../textures/texture-protocol.js';\nimport { definePrimitive } from '../define-primitive.js';\nimport { materializeTextChildren } from '../element/children.js';\nimport { GLOBAL_STATE } from '../global-state.js';\nimport type {\n PibblEventFocusOptions,\n PibblEventHandlers,\n PibblEventParticipationOptions,\n} from '../events/types.js';\nimport {\n resolveOptionalLength,\n stripLayoutParticipation,\n} from '../style/resolve-built-in.js';\nimport { registerOpaqueStyleProperties } from '../style/resolve-dispatch.js';\nimport type { ResolvedTextStyle, TextStyle } from '../style/types.js';\nimport {\n CanvasMeasurementService,\n MeasureResult,\n RenderingContext2D,\n} from '../types.js';\nimport type { Constraints } from '../layout/types.js';\nimport type { PibblRenderTransaction, PibblTextInput } from '../types.js';\nimport type { PibblPhysics2DPropExtension } from '../types.js';\nimport { resolveLength } from '../style/resolve-length.js';\nimport { wireCommonEvents } from '../util/wire-common-events.js';\nimport { pushClippingPath } from '../util/push-clipping-path.js';\nimport { resolveTextClipBounds, resolveTextLayout } from './text-layout.js';\nimport { withReceiverInputProvision } from '../signals/input-provision.js';\n\n/**\n * Authored inputs for Text, including the declared data and presentation options.\n *\n * @see {@link PibblEventHandlers}\n * @see {@link PibblEventParticipationOptions}\n * @see {@link PibblPhysics2DPropExtension}\n * @see {@link PibblTextInput}\n * @see {@link Text}\n */\nexport interface TextProps\n extends\n PibblEventHandlers,\n PibblEventFocusOptions,\n PibblEventParticipationOptions,\n PibblPhysics2DPropExtension {\n /** Descendant content or the callback that supplies it. See {@link PibblTextInput}. */\n children?: PibblTextInput;\n}\n\nconst materializedTextTransactions = new WeakMap<\n PibblRenderTransaction,\n WeakMap<object, string>\n>();\n\nfunction renderText(\n props: TextProps,\n style: Readonly<ResolvedTextStyle>,\n ctx: RenderingContext2D,\n) {\n const text = materializeTextContent(props);\n const {\n font = '13px sans-serif',\n textBaseline = 'top',\n textAlign = 'left',\n fill,\n stroke,\n strokeWidth = 0,\n opacity,\n cursor,\n } = style;\n\n if (opacity !== undefined) {\n ctx.globalAlpha = ctx.globalAlpha * opacity;\n }\n\n ctx.font = font;\n ctx.textBaseline = textBaseline;\n ctx.textAlign = textAlign;\n\n const layout = resolveTextLayout(\n value => ctx.measureText(value),\n text,\n style,\n );\n const clipBounds =\n layout.clipBounds ?? resolveTextClipBounds(style, ctx.canvas.height);\n\n let releaseClip: (() => void) | undefined;\n if (clipBounds) {\n const clipPath = new Path2D();\n clipPath.rect(\n clipBounds.x,\n clipBounds.y,\n clipBounds.width,\n clipBounds.height,\n );\n releaseClip = pushClippingPath(ctx, clipPath);\n }\n\n try {\n const textBounds = props.pointerEvents === 'none' ? undefined : new Path2D();\n\n for (const line of layout.lines) {\n if (stroke && strokeWidth) {\n ctx.strokeStyle = resolveTexturePaint(stroke, ctx, layout.bounds ?? line.bounds);\n ctx.lineWidth = strokeWidth;\n ctx.strokeText(line.text, line.x, line.y, line.squishWidth);\n }\n\n if (fill) {\n ctx.fillStyle = resolveTexturePaint(fill, ctx, layout.bounds ?? line.bounds);\n ctx.fillText(line.text, line.x, line.y, line.squishWidth);\n }\n\n if (textBounds) {\n textBounds.moveTo(line.bounds.x, line.bounds.y);\n textBounds.lineTo(line.bounds.x + line.bounds.width, line.bounds.y);\n textBounds.lineTo(\n line.bounds.x + line.bounds.width,\n line.bounds.y + line.bounds.height,\n );\n textBounds.lineTo(line.bounds.x, line.bounds.y + line.bounds.height);\n textBounds.closePath();\n }\n }\n\n wireCommonEvents(\n props,\n textBounds,\n true,\n strokeWidth,\n cursor,\n layout.bounds,\n );\n } finally {\n releaseClip?.();\n }\n}\n\n/**\n * Draws Canvas text from textual children using the resolved font, wrapping, fitting, and paint\n * style.\n *\n * @param props - Authored component inputs, supplied through JSX or createElement. See the linked\n * props and style types.\n * @throws When called directly; Pibbl mounts this component through JSX or createElement.\n *\n * @see {@link TextProps}\n * @see {@link TextStyle}\n */\nexport const Text = definePrimitive<\n TextProps,\n TextStyle,\n TextStyle,\n ResolvedTextStyle\n>(renderText, {\n childInput: 'text',\n resolveStyle: (style, context) => ({\n ...stripLayoutParticipation(style),\n x: 0,\n y: 0,\n width: resolveOptionalLength(\n style.width,\n context.percentageBasis.width,\n 'width',\n context,\n ),\n height: resolveOptionalLength(\n style.height,\n context.percentageBasis.height,\n 'height',\n context,\n ),\n }) as ResolvedTextStyle,\n measure: ({ props, style, constraints, service }) =>\n measureTextStyle(\n materializeTextContent(props),\n style,\n constraints,\n service,\n ),\n});\nregisterOpaqueStyleProperties(Text, [\n 'font',\n 'fill',\n 'stroke',\n 'cursor',\n 'fit',\n 'textBaseline',\n 'textAlign',\n]);\n\nfunction measureTextStyle(\n text: string,\n style: Readonly<TextStyle>,\n constraints: Readonly<Constraints>,\n service: CanvasMeasurementService,\n): MeasureResult {\n const context = {\n component: 'Text',\n algorithm: 'measurement',\n constraints,\n };\n const specifiedWidth = style.width === undefined ? undefined :\n resolveLength(style.width, constraints.maxWidth, 'width', context);\n const specifiedHeight = style.height === undefined ? undefined :\n resolveLength(style.height, constraints.maxHeight, 'height', context);\n const layoutWidth = specifiedWidth ?? (\n style.wrap && Number.isFinite(constraints.maxWidth) ?\n constraints.maxWidth :\n undefined\n );\n const font = style.font ?? '13px sans-serif';\n const layout = resolveTextLayout(\n value => service.measureText(value, font),\n text,\n {\n ...style,\n x: 0,\n y: 0,\n width: layoutWidth,\n height: specifiedHeight,\n },\n );\n return {\n status: 'measured',\n size: {\n width: specifiedWidth ?? (style.wrap && layoutWidth !== undefined ?\n layoutWidth :\n layout.bounds?.width ?? 0),\n height: specifiedHeight ?? (style.wrap ?\n layout.lines.length * (style.lineHeight ?? 13) :\n layout.bounds?.height ?? 0),\n },\n };\n}\n\nfunction materializeTextContent(props: Readonly<TextProps>): string {\n const transaction = GLOBAL_STATE.renderTransaction;\n const receiver = GLOBAL_STATE.primitiveReceiverToken;\n if (!transaction || !receiver) {\n return materializeTextChildren(props.children, 'Text');\n }\n\n let receivers = materializedTextTransactions.get(transaction);\n if (!receivers) {\n receivers = new WeakMap();\n materializedTextTransactions.set(transaction, receivers);\n }\n const cached = receivers.get(receiver);\n if (cached !== undefined) return cached;\n const materialized = withReceiverInputProvision(\n transaction,\n receiver,\n () => materializeTextChildren(props.children, 'Text'),\n );\n receivers.set(receiver, materialized);\n return materialized;\n}\n"],
5
- "mappings": "AAAA,SAAS,2BAA2B;AACpC,SAAS,uBAAuB;AAChC,SAAS,+BAA+B;AACxC,SAAS,oBAAoB;AAM7B;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,qCAAqC;AAU9C,SAAS,qBAAqB;AAC9B,SAAS,wBAAwB;AACjC,SAAS,wBAAwB;AACjC,SAAS,uBAAuB,yBAAyB;AACzD,SAAS,kCAAkC;AAqB3C,MAAM,+BAA+B,oBAAI,QAGvC;AAEF,SAAS,WACP,OACA,OACA,KACA;AACA,QAAM,OAAO,uBAAuB,KAAK;AACzC,QAAM;AAAA,IACJ,OAAO;AAAA,IACP,eAAe;AAAA,IACf,YAAY;AAAA,IACZ;AAAA,IACA;AAAA,IACA,cAAc;AAAA,IACd;AAAA,IACA;AAAA,EACF,IAAI;AAEJ,MAAI,YAAY,QAAW;AACzB,QAAI,cAAc,IAAI,cAAc;AAAA,EACtC;AAEA,MAAI,OAAO;AACX,MAAI,eAAe;AACnB,MAAI,YAAY;AAEhB,QAAM,SAAS;AAAA,IACb,WAAS,IAAI,YAAY,KAAK;AAAA,IAC9B;AAAA,IACA;AAAA,EACF;AACA,QAAM,aACJ,OAAO,cAAc,sBAAsB,OAAO,IAAI,OAAO,MAAM;AAErE,MAAI;AACJ,MAAI,YAAY;AACd,UAAM,WAAW,IAAI,OAAO;AAC5B,aAAS;AAAA,MACP,WAAW;AAAA,MACX,WAAW;AAAA,MACX,WAAW;AAAA,MACX,WAAW;AAAA,IACb;AACA,kBAAc,iBAAiB,KAAK,QAAQ;AAAA,EAC9C;AAEA,MAAI;AACF,UAAM,aAAa,MAAM,kBAAk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AU;AAC7B,WAAO,wBAAwB,MAAM,UAAU,MAAM;AAAA,EACvD;AAEA,MAAI,YAAY,6BAA6B,IAAI,WAAW;AAC5D,MAAI,CAAC,WAAW;AACd,gBAAY,oBAAI,QAAQ;AACxB,iCAA6B,IAAI,aAAa,SAAS;AAAA,EACzD;AACA,QAAM,SAAS,UAAU,IAAI,QAAQ;AACrC,MAAI,WAAW,OAAW,QAAO;AACjC,QAAM,eAAe;AAAA,IACnB;AAAA,IACA;AAAA,IACA,MAAM,wBAAwB,MAAM,UAAU,MAAM;AAAA,EACtD;AACA,YAAU,IAAI,UAAU,YAAY;AACpC,SAAO;AACT;",
4
+ "sourcesContent": ["import { resolveTexturePaint } from '../textures/texture-protocol.js';\nimport { definePrimitive } from '../define-primitive.js';\nimport { materializeTextChildren } from '../element/children.js';\nimport { GLOBAL_STATE } from '../global-state.js';\nimport type {\n PibblEventFocusOptions,\n PibblEventHandlers,\n PibblEventParticipationOptions,\n} from '../events/types.js';\nimport {\n resolveOptionalLength,\n stripLayoutParticipation,\n} from '../style/resolve-built-in.js';\nimport { registerOpaqueStyleProperties } from '../style/resolve-dispatch.js';\nimport type { ResolvedTextStyle, TextStyle } from '../style/types.js';\nimport {\n CanvasMeasurementService,\n MeasureResult,\n IntrinsicSizesResult,\n RenderingContext2D,\n} from '../types.js';\nimport type { Constraints } from '../layout/types.js';\nimport type { PibblRenderTransaction, PibblTextInput } from '../types.js';\nimport type { PibblPhysics2DPropExtension } from '../types.js';\nimport { resolveScalarSizingLength } from '../style/sizing-length.js';\nimport { normalizeBoxInsets } from '../layout/box-insets.js';\nimport { wireCommonEvents } from '../util/wire-common-events.js';\nimport { pushClippingPath } from '../util/push-clipping-path.js';\nimport { resolveTextClipBounds, resolveTextLayout } from './text-layout.js';\nimport { withReceiverInputProvision } from '../signals/input-provision.js';\nimport { withSignalDependencyRole, withSignalWriteForbidden } from '../signals/graph.js';\nimport { withHooksForbidden } from '../hooks/hook-slot.js';\n\n/**\n * Authored inputs for Text, including the declared data and presentation options.\n *\n * @see {@link PibblEventHandlers}\n * @see {@link PibblEventParticipationOptions}\n * @see {@link PibblPhysics2DPropExtension}\n * @see {@link PibblTextInput}\n * @see {@link Text}\n */\nexport interface TextProps\n extends\n PibblEventHandlers,\n PibblEventFocusOptions,\n PibblEventParticipationOptions,\n PibblPhysics2DPropExtension {\n /** Descendant content or the callback that supplies it. See {@link PibblTextInput}. */\n children?: PibblTextInput;\n}\n\nconst materializedTextTransactions = new WeakMap<\n PibblRenderTransaction,\n WeakMap<object, string>\n>();\n\nfunction renderText(\n props: TextProps,\n style: Readonly<ResolvedTextStyle>,\n ctx: RenderingContext2D,\n) {\n const text = materializeTextContent(props);\n const {\n font = '13px sans-serif',\n textBaseline = 'top',\n textAlign = 'left',\n fill,\n stroke,\n strokeWidth = 0,\n opacity,\n cursor,\n } = style;\n\n if (opacity !== undefined) {\n ctx.globalAlpha = ctx.globalAlpha * opacity;\n }\n\n ctx.font = font;\n ctx.textBaseline = textBaseline;\n ctx.textAlign = textAlign;\n\n const layout = resolveTextLayout(\n value => ctx.measureText(value),\n text,\n style,\n );\n const clipBounds =\n layout.clipBounds ?? resolveTextClipBounds(style, ctx.canvas.height);\n\n let releaseClip: (() => void) | undefined;\n if (clipBounds) {\n const clipPath = new Path2D();\n clipPath.rect(\n clipBounds.x,\n clipBounds.y,\n clipBounds.width,\n clipBounds.height,\n );\n releaseClip = pushClippingPath(ctx, clipPath);\n }\n\n try {\n const textBounds = props.pointerEvents === 'none' ? undefined : new Path2D();\n\n for (const line of layout.lines) {\n if (stroke && strokeWidth) {\n ctx.strokeStyle = resolveTexturePaint(stroke, ctx, layout.bounds ?? line.bounds);\n ctx.lineWidth = strokeWidth;\n ctx.strokeText(line.text, line.x, line.y, line.squishWidth);\n }\n\n if (fill) {\n ctx.fillStyle = resolveTexturePaint(fill, ctx, layout.bounds ?? line.bounds);\n ctx.fillText(line.text, line.x, line.y, line.squishWidth);\n }\n\n if (textBounds) {\n textBounds.moveTo(line.bounds.x, line.bounds.y);\n textBounds.lineTo(line.bounds.x + line.bounds.width, line.bounds.y);\n textBounds.lineTo(\n line.bounds.x + line.bounds.width,\n line.bounds.y + line.bounds.height,\n );\n textBounds.lineTo(line.bounds.x, line.bounds.y + line.bounds.height);\n textBounds.closePath();\n }\n }\n\n wireCommonEvents(\n props,\n textBounds,\n true,\n strokeWidth,\n cursor,\n layout.bounds,\n );\n } finally {\n releaseClip?.();\n }\n}\n\n/**\n * Draws Canvas text from textual children using the resolved font, wrapping, fitting, and paint\n * style.\n *\n * @param props - Authored component inputs, supplied through JSX or createElement. See the linked\n * props and style types.\n * @throws When called directly; Pibbl mounts this component through JSX or createElement.\n *\n * @see {@link TextProps}\n * @see {@link TextStyle}\n */\nexport const Text = definePrimitive<\n TextProps,\n TextStyle,\n TextStyle,\n ResolvedTextStyle\n>(renderText, {\n childInput: 'text',\n resolveStyle: (style, context) => {\n let x = 0, y = 0;\n if (style.padding !== undefined || style.paddingStart !== undefined || style.paddingEnd !== undefined ||\n style.borderWidth !== undefined || style.borderStartWidth !== undefined || style.borderEndWidth !== undefined) {\n const insets = normalizeBoxInsets(style, context);\n x = insets.left; y = insets.top;\n }\n return {\n ...stripLayoutParticipation(style),\n x,\n y,\n width: resolveOptionalLength(\n style.width,\n context.percentageBasis.width,\n 'width',\n context,\n ),\n height: resolveOptionalLength(\n style.height,\n context.percentageBasis.height,\n 'height',\n context,\n ),\n } as ResolvedTextStyle;\n },\n measure: ({ props, style, constraints, service }) =>\n measureTextStyle(\n materializeTextContent(props),\n style,\n constraints,\n service,\n ),\n measureIntrinsic: ({ props, style, service }) => measureTextIntrinsic(props, style, service),\n measureBaselines: ({ props, style, allocation, service }) =>\n measureTextBaselines(\n materializeTextContent(props),\n style,\n allocation,\n service,\n ),\n});\nregisterOpaqueStyleProperties(Text, [\n 'font',\n 'fill',\n 'stroke',\n 'cursor',\n 'fit',\n 'textBaseline',\n 'textAlign',\n]);\n\n\nfunction measureTextBaselines(\n text: string,\n style: Readonly<TextStyle>,\n allocation: Readonly<{ width: number; height: number }>,\n service: CanvasMeasurementService,\n) {\n if (text.length === 0) return { status: 'unsupported' as const, reason: 'Text baseline measurement requires nonempty text' };\n const measureAtBaseline = service.measureTextAtBaseline;\n if (!measureAtBaseline) {\n return {\n status: 'unsupported' as const,\n reason: 'Text baseline measurement requires CanvasMeasurementService.measureTextAtBaseline',\n };\n }\n const font = style.font ?? '13px sans-serif';\n const textBaseline = style.textBaseline ?? 'top';\n const layout = resolveTextLayout(\n value => measureAtBaseline.call(service, value, { font, textBaseline }),\n text,\n { ...style, x: 0, y: 0, width: allocation.width, height: allocation.height },\n );\n const firstLine = layout.lines[0];\n const lastLine = layout.lines[layout.lines.length - 1];\n if (!firstLine || !lastLine || firstLine.text.length === 0 || lastLine.text.length === 0) {\n return { status: 'unsupported' as const, reason: 'Text does not resolve a line for baseline measurement: requires a nonempty rendered baseline line' };\n }\n const firstMetrics = measureAtBaseline.call(service, firstLine.text, { font, textBaseline });\n const first = firstLine.y - firstMetrics.alphabeticBaseline;\n let last = first;\n if (lastLine !== firstLine) {\n const lastMetrics = measureAtBaseline.call(service, lastLine.text, { font, textBaseline });\n last = lastLine.y - lastMetrics.alphabeticBaseline;\n }\n if (!Number.isFinite(first) || !Number.isFinite(last)) {\n return {\n status: 'unsupported' as const,\n reason: 'Canvas text metrics do not provide a finite alphabeticBaseline for Text baseline measurement',\n };\n }\n return { status: 'measured' as const, first, last };\n}\n\n/** Width contributions and their respective natural heights share Text's existing wrap policy. */\nfunction measureTextIntrinsic(props: Readonly<TextProps>, style: Readonly<TextStyle>, service: CanvasMeasurementService): IntrinsicSizesResult {\n const text = prepareLayoutTextContent(props, {});\n const font = style.font ?? '13px sans-serif';\n const maximum = style.wrap ? measureLayoutTextNaturalRun(text, { font, service }) : service.measureText(text, font).width;\n const minimum = style.wrap ? measureLayoutTextMinimumWidth(props, { font, service }) : maximum;\n const intrinsicStyle = { ...style, width: undefined, height: undefined, fit: 'visible' as const };\n const minResult = measureTextStyle(text, intrinsicStyle, { minWidth: 0, maxWidth: minimum, minHeight: 0, maxHeight: Infinity }, service);\n const maxResult = measureTextStyle(text, intrinsicStyle, { minWidth: 0, maxWidth: maximum, minHeight: 0, maxHeight: Infinity }, service);\n if (minResult.status !== 'measured') return minResult;\n if (maxResult.status !== 'measured') return maxResult;\n return { status: 'measured', minContent: { width: minimum, height: minResult.size.height }, maxContent: { width: maximum, height: maxResult.size.height } };\n}\n\nfunction measureTextStyle(\n text: string,\n style: Readonly<TextStyle>,\n constraints: Readonly<Constraints>,\n service: CanvasMeasurementService,\n): MeasureResult {\n const context = {\n component: 'Text',\n algorithm: 'measurement',\n constraints,\n };\n const specifiedWidth = style.width === undefined ? undefined :\n resolveScalarSizingLength(style.width, constraints.maxWidth, 'width', context);\n const specifiedHeight = style.height === undefined ? undefined :\n resolveScalarSizingLength(style.height, constraints.maxHeight, 'height', context);\n const layoutWidth = specifiedWidth ?? (\n style.wrap && Number.isFinite(constraints.maxWidth) ?\n constraints.maxWidth :\n undefined\n );\n const font = style.font ?? '13px sans-serif';\n const layout = resolveTextLayout(\n value => service.measureText(value, font),\n text,\n {\n ...style,\n x: 0,\n y: 0,\n width: layoutWidth,\n height: specifiedHeight,\n },\n );\n return {\n status: 'measured',\n size: {\n width: specifiedWidth ?? (style.wrap && layoutWidth !== undefined ?\n layoutWidth :\n layout.bounds?.width ?? 0),\n height: specifiedHeight ?? (style.wrap ?\n layout.lines.length * (style.lineHeight ?? 13) :\n layout.bounds?.height ?? 0),\n },\n };\n}\n\n/** @internal Measure a materialized value without bypassing receiver reads. */\nexport function measureLayoutTextNaturalRun(\n text: string, options: { font: string; service: CanvasMeasurementService },\n): number {\n // wrapText discards leading empty words but preserves later spaces. Use the\n // same boundary rather than adding a CSS whitespace-normalization policy.\n let start = 0;\n while (text.charCodeAt(start) === 32) start++;\n if (start === text.length) return 0;\n const width = options.service.measureText(text.slice(start), options.font).width;\n if (!Number.isFinite(width) || width < 0) {\n throw new Error('Text intrinsic measurement requires a finite nonnegative natural width.');\n }\n return width;\n}\n\n/** @internal Longest run under Text's existing ASCII-space wrapping contract. */\nexport function measureLayoutTextMinimumWidth(\n props: Readonly<TextProps>,\n options: { font: string; service: CanvasMeasurementService; receiverToken?: object },\n): number {\n const text = prepareLayoutTextContent(props, { receiverToken: options.receiverToken });\n let longest = 0;\n let start = 0;\n for (let index = 0; index <= text.length; index++) {\n if (index !== text.length && text.charCodeAt(index) !== 32) continue;\n if (index > start) {\n const width = options.service.measureText(text.slice(start, index), options.font).width;\n if (!Number.isFinite(width) || width < 0) {\n throw new Error('Text intrinsic measurement requires finite nonnegative word widths.');\n }\n if (width > longest) longest = width;\n }\n start = index + 1;\n }\n return longest;\n}\n\n/** @internal Prepare measured Text through its existing transaction/receiver ownership. */\nexport function prepareLayoutTextContent(\n props: Readonly<TextProps>, options: { receiverToken?: object },\n): string {\n return withSignalWriteForbidden('Signal writes are forbidden during Pibbl measurement', () =>\n withHooksForbidden('Pibbl hooks cannot be called while preparing measured Text content.', () =>\n materializeTextContent(props, options.receiverToken),\n ),\n );\n}\n\nfunction materializeTextContent(\n props: Readonly<TextProps>, receiver = GLOBAL_STATE.primitiveReceiverToken,\n): string {\n const transaction = GLOBAL_STATE.renderTransaction;\n if (!transaction || !receiver) {\n return materializeTextChildren(props.children, 'Text');\n }\n\n let receivers = materializedTextTransactions.get(transaction);\n if (!receivers) {\n receivers = new WeakMap();\n materializedTextTransactions.set(transaction, receivers);\n }\n const cached = receivers.get(receiver);\n if (cached !== undefined) return cached;\n const materialized = withReceiverInputProvision(\n transaction,\n receiver,\n () => withSignalDependencyRole(\n 'measurement',\n () => materializeTextChildren(props.children, 'Text'),\n ),\n );\n receivers.set(receiver, materialized);\n return materialized;\n}\n"],
5
+ "mappings": "AAAA,SAAS,2BAA2B;AACpC,SAAS,uBAAuB;AAChC,SAAS,+BAA+B;AACxC,SAAS,oBAAoB;AAM7B;AAAA,EACE;AAAA,EACA;AAAA,OACK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