@motionscript/core 0.1.0-alpha.7 → 0.1.0-alpha.8

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 (498) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/NOTICE +15 -14
  3. package/README.md +4 -4
  4. package/dist/assets/manager.d.ts.map +1 -1
  5. package/dist/assets/manager.js +7 -5
  6. package/dist/assets/manager.js.map +1 -1
  7. package/dist/attributes/audio/effects/chain.d.ts +73 -0
  8. package/dist/attributes/audio/effects/chain.d.ts.map +1 -0
  9. package/dist/attributes/audio/effects/chain.js +67 -0
  10. package/dist/attributes/audio/effects/chain.js.map +1 -0
  11. package/dist/attributes/audio/effects/implementations/echo.d.ts +14 -0
  12. package/dist/attributes/audio/effects/implementations/echo.d.ts.map +1 -0
  13. package/dist/attributes/audio/effects/implementations/echo.js +11 -0
  14. package/dist/attributes/audio/effects/implementations/echo.js.map +1 -0
  15. package/dist/attributes/audio/effects/implementations/gain.d.ts +10 -0
  16. package/dist/attributes/audio/effects/implementations/gain.d.ts.map +1 -0
  17. package/dist/attributes/audio/effects/implementations/gain.js +6 -0
  18. package/dist/attributes/audio/effects/implementations/gain.js.map +1 -0
  19. package/dist/attributes/audio/effects/implementations/highpass.d.ts +12 -0
  20. package/dist/attributes/audio/effects/implementations/highpass.d.ts.map +1 -0
  21. package/dist/attributes/audio/effects/implementations/highpass.js +10 -0
  22. package/dist/attributes/audio/effects/implementations/highpass.js.map +1 -0
  23. package/dist/attributes/audio/effects/implementations/lowpass.d.ts +12 -0
  24. package/dist/attributes/audio/effects/implementations/lowpass.d.ts.map +1 -0
  25. package/dist/attributes/audio/effects/implementations/lowpass.js +10 -0
  26. package/dist/attributes/audio/effects/implementations/lowpass.js.map +1 -0
  27. package/dist/attributes/audio/effects/implementations/tremolo.d.ts +12 -0
  28. package/dist/attributes/audio/effects/implementations/tremolo.d.ts.map +1 -0
  29. package/dist/attributes/audio/effects/implementations/tremolo.js +10 -0
  30. package/dist/attributes/audio/effects/implementations/tremolo.js.map +1 -0
  31. package/dist/attributes/audio/effects/index.d.ts +12 -0
  32. package/dist/attributes/audio/effects/index.d.ts.map +1 -0
  33. package/dist/attributes/audio/effects/index.js +4 -0
  34. package/dist/attributes/audio/effects/index.js.map +1 -0
  35. package/dist/attributes/audio/effects/registry.d.ts +36 -0
  36. package/dist/attributes/audio/effects/registry.d.ts.map +1 -0
  37. package/dist/attributes/audio/effects/registry.js +80 -0
  38. package/dist/attributes/audio/effects/registry.js.map +1 -0
  39. package/dist/attributes/audio/effects/union.d.ts +14 -0
  40. package/dist/attributes/audio/effects/union.d.ts.map +1 -0
  41. package/dist/attributes/audio/effects/union.js +24 -0
  42. package/dist/attributes/audio/effects/union.js.map +1 -0
  43. package/dist/attributes/audio/ramp.d.ts +103 -0
  44. package/dist/attributes/audio/ramp.d.ts.map +1 -0
  45. package/dist/attributes/audio/ramp.js +246 -0
  46. package/dist/attributes/audio/ramp.js.map +1 -0
  47. package/dist/attributes/audio/request.d.ts +24 -13
  48. package/dist/attributes/audio/request.d.ts.map +1 -1
  49. package/dist/attributes/audio/request.js +4 -3
  50. package/dist/attributes/audio/request.js.map +1 -1
  51. package/dist/attributes/audio/schedule.d.ts +21 -13
  52. package/dist/attributes/audio/schedule.d.ts.map +1 -1
  53. package/dist/attributes/audio/schedule.js +42 -28
  54. package/dist/attributes/audio/schedule.js.map +1 -1
  55. package/dist/attributes/audio/sound.d.ts +15 -12
  56. package/dist/attributes/audio/sound.d.ts.map +1 -1
  57. package/dist/attributes/audio/sound.js +8 -10
  58. package/dist/attributes/audio/sound.js.map +1 -1
  59. package/dist/attributes/audio/transition.d.ts +33 -0
  60. package/dist/attributes/audio/transition.d.ts.map +1 -0
  61. package/dist/attributes/audio/transition.js +48 -0
  62. package/dist/attributes/audio/transition.js.map +1 -0
  63. package/dist/attributes/index.d.ts +4 -3
  64. package/dist/attributes/index.d.ts.map +1 -1
  65. package/dist/attributes/index.js +4 -7
  66. package/dist/attributes/index.js.map +1 -1
  67. package/dist/attributes/layout/matrix2d.d.ts +2 -2
  68. package/dist/attributes/layout/matrix2d.js.map +1 -1
  69. package/dist/attributes/layout/space3d.js +1 -1
  70. package/dist/attributes/layout/space3d.js.map +1 -1
  71. package/dist/attributes/properties/typed.d.ts +7 -7
  72. package/dist/attributes/properties/typed.d.ts.map +1 -1
  73. package/dist/attributes/properties/typed.js +6 -6
  74. package/dist/attributes/properties/typed.js.map +1 -1
  75. package/dist/attributes/shape/corners/corner-radius.d.ts +1 -2
  76. package/dist/attributes/shape/corners/corner-radius.d.ts.map +1 -1
  77. package/dist/attributes/shape/corners/corner-radius.js +1 -2
  78. package/dist/attributes/shape/corners/corner-radius.js.map +1 -1
  79. package/dist/attributes/shape/effects/chain.d.ts +96 -409
  80. package/dist/attributes/shape/effects/chain.d.ts.map +1 -1
  81. package/dist/attributes/shape/effects/chain.js +93 -283
  82. package/dist/attributes/shape/effects/chain.js.map +1 -1
  83. package/dist/attributes/shape/effects/effect-data.d.ts +1 -1
  84. package/dist/attributes/shape/effects/effect-data.js.map +1 -1
  85. package/dist/attributes/shape/effects/implementations/ascii.d.ts +45 -13
  86. package/dist/attributes/shape/effects/implementations/ascii.d.ts.map +1 -1
  87. package/dist/attributes/shape/effects/implementations/ascii.js +29 -23
  88. package/dist/attributes/shape/effects/implementations/ascii.js.map +1 -1
  89. package/dist/attributes/shape/effects/implementations/bit-crush.d.ts +32 -7
  90. package/dist/attributes/shape/effects/implementations/bit-crush.d.ts.map +1 -1
  91. package/dist/attributes/shape/effects/implementations/bit-crush.js +17 -15
  92. package/dist/attributes/shape/effects/implementations/bit-crush.js.map +1 -1
  93. package/dist/attributes/shape/effects/implementations/block-displace.d.ts +46 -10
  94. package/dist/attributes/shape/effects/implementations/block-displace.d.ts.map +1 -1
  95. package/dist/attributes/shape/effects/implementations/block-displace.js +21 -19
  96. package/dist/attributes/shape/effects/implementations/block-displace.js.map +1 -1
  97. package/dist/attributes/shape/effects/implementations/bloom.d.ts +32 -7
  98. package/dist/attributes/shape/effects/implementations/bloom.d.ts.map +1 -1
  99. package/dist/attributes/shape/effects/implementations/bloom.js +17 -11
  100. package/dist/attributes/shape/effects/implementations/bloom.js.map +1 -1
  101. package/dist/attributes/shape/effects/implementations/blur.d.ts +16 -3
  102. package/dist/attributes/shape/effects/implementations/blur.d.ts.map +1 -1
  103. package/dist/attributes/shape/effects/implementations/blur.js +13 -5
  104. package/dist/attributes/shape/effects/implementations/blur.js.map +1 -1
  105. package/dist/attributes/shape/effects/implementations/bulge.d.ts +28 -9
  106. package/dist/attributes/shape/effects/implementations/bulge.d.ts.map +1 -1
  107. package/dist/attributes/shape/effects/implementations/bulge.js +15 -14
  108. package/dist/attributes/shape/effects/implementations/bulge.js.map +1 -1
  109. package/dist/attributes/shape/effects/implementations/chromatic-aberration.d.ts +21 -5
  110. package/dist/attributes/shape/effects/implementations/chromatic-aberration.d.ts.map +1 -1
  111. package/dist/attributes/shape/effects/implementations/chromatic-aberration.js +15 -10
  112. package/dist/attributes/shape/effects/implementations/chromatic-aberration.js.map +1 -1
  113. package/dist/attributes/shape/effects/implementations/color-adjustment.d.ts +96 -26
  114. package/dist/attributes/shape/effects/implementations/color-adjustment.d.ts.map +1 -1
  115. package/dist/attributes/shape/effects/implementations/color-adjustment.js +29 -26
  116. package/dist/attributes/shape/effects/implementations/color-adjustment.js.map +1 -1
  117. package/dist/attributes/shape/effects/implementations/curves.d.ts +20 -6
  118. package/dist/attributes/shape/effects/implementations/curves.d.ts.map +1 -1
  119. package/dist/attributes/shape/effects/implementations/curves.js +26 -23
  120. package/dist/attributes/shape/effects/implementations/curves.js.map +1 -1
  121. package/dist/attributes/shape/effects/implementations/directional-blur.d.ts +26 -5
  122. package/dist/attributes/shape/effects/implementations/directional-blur.d.ts.map +1 -1
  123. package/dist/attributes/shape/effects/implementations/directional-blur.js +15 -10
  124. package/dist/attributes/shape/effects/implementations/directional-blur.js.map +1 -1
  125. package/dist/attributes/shape/effects/implementations/dither.d.ts +58 -11
  126. package/dist/attributes/shape/effects/implementations/dither.d.ts.map +1 -1
  127. package/dist/attributes/shape/effects/implementations/dither.js +26 -20
  128. package/dist/attributes/shape/effects/implementations/dither.js.map +1 -1
  129. package/dist/attributes/shape/effects/implementations/drop-shadow.d.ts +46 -14
  130. package/dist/attributes/shape/effects/implementations/drop-shadow.d.ts.map +1 -1
  131. package/dist/attributes/shape/effects/implementations/drop-shadow.js +24 -29
  132. package/dist/attributes/shape/effects/implementations/drop-shadow.js.map +1 -1
  133. package/dist/attributes/shape/effects/implementations/duotone.d.ts +26 -7
  134. package/dist/attributes/shape/effects/implementations/duotone.d.ts.map +1 -1
  135. package/dist/attributes/shape/effects/implementations/duotone.js +17 -16
  136. package/dist/attributes/shape/effects/implementations/duotone.js.map +1 -1
  137. package/dist/attributes/shape/effects/implementations/edges.d.ts +29 -7
  138. package/dist/attributes/shape/effects/implementations/edges.d.ts.map +1 -1
  139. package/dist/attributes/shape/effects/implementations/edges.js +17 -14
  140. package/dist/attributes/shape/effects/implementations/edges.js.map +1 -1
  141. package/dist/attributes/shape/effects/implementations/glass.d.ts +76 -19
  142. package/dist/attributes/shape/effects/implementations/glass.d.ts.map +1 -1
  143. package/dist/attributes/shape/effects/implementations/glass.js +28 -22
  144. package/dist/attributes/shape/effects/implementations/glass.js.map +1 -1
  145. package/dist/attributes/shape/effects/implementations/glow.d.ts +149 -42
  146. package/dist/attributes/shape/effects/implementations/glow.d.ts.map +1 -1
  147. package/dist/attributes/shape/effects/implementations/glow.js +74 -72
  148. package/dist/attributes/shape/effects/implementations/glow.js.map +1 -1
  149. package/dist/attributes/shape/effects/implementations/grain.d.ts +43 -11
  150. package/dist/attributes/shape/effects/implementations/grain.d.ts.map +1 -1
  151. package/dist/attributes/shape/effects/implementations/grain.js +21 -18
  152. package/dist/attributes/shape/effects/implementations/grain.js.map +1 -1
  153. package/dist/attributes/shape/effects/implementations/grayscale.d.ts +17 -3
  154. package/dist/attributes/shape/effects/implementations/grayscale.d.ts.map +1 -1
  155. package/dist/attributes/shape/effects/implementations/grayscale.js +13 -5
  156. package/dist/attributes/shape/effects/implementations/grayscale.js.map +1 -1
  157. package/dist/attributes/shape/effects/implementations/halftone.d.ts +40 -9
  158. package/dist/attributes/shape/effects/implementations/halftone.d.ts.map +1 -1
  159. package/dist/attributes/shape/effects/implementations/halftone.js +20 -16
  160. package/dist/attributes/shape/effects/implementations/halftone.js.map +1 -1
  161. package/dist/attributes/shape/effects/implementations/invert.d.ts +23 -5
  162. package/dist/attributes/shape/effects/implementations/invert.d.ts.map +1 -1
  163. package/dist/attributes/shape/effects/implementations/invert.js +15 -10
  164. package/dist/attributes/shape/effects/implementations/invert.js.map +1 -1
  165. package/dist/attributes/shape/effects/implementations/kaleidoscope.d.ts +57 -18
  166. package/dist/attributes/shape/effects/implementations/kaleidoscope.d.ts.map +1 -1
  167. package/dist/attributes/shape/effects/implementations/kaleidoscope.js +25 -22
  168. package/dist/attributes/shape/effects/implementations/kaleidoscope.js.map +1 -1
  169. package/dist/attributes/shape/effects/implementations/lut.d.ts +34 -7
  170. package/dist/attributes/shape/effects/implementations/lut.d.ts.map +1 -1
  171. package/dist/attributes/shape/effects/implementations/lut.js +20 -16
  172. package/dist/attributes/shape/effects/implementations/lut.js.map +1 -1
  173. package/dist/attributes/shape/effects/implementations/magnify.d.ts +27 -9
  174. package/dist/attributes/shape/effects/implementations/magnify.d.ts.map +1 -1
  175. package/dist/attributes/shape/effects/implementations/magnify.js +17 -14
  176. package/dist/attributes/shape/effects/implementations/magnify.js.map +1 -1
  177. package/dist/attributes/shape/effects/implementations/motion-blur.d.ts +54 -19
  178. package/dist/attributes/shape/effects/implementations/motion-blur.d.ts.map +1 -1
  179. package/dist/attributes/shape/effects/implementations/motion-blur.js +42 -20
  180. package/dist/attributes/shape/effects/implementations/motion-blur.js.map +1 -1
  181. package/dist/attributes/shape/effects/implementations/oil-paint.d.ts +17 -3
  182. package/dist/attributes/shape/effects/implementations/oil-paint.d.ts.map +1 -1
  183. package/dist/attributes/shape/effects/implementations/oil-paint.js +13 -9
  184. package/dist/attributes/shape/effects/implementations/oil-paint.js.map +1 -1
  185. package/dist/attributes/shape/effects/implementations/outline.d.ts +28 -8
  186. package/dist/attributes/shape/effects/implementations/outline.d.ts.map +1 -1
  187. package/dist/attributes/shape/effects/implementations/outline.js +18 -17
  188. package/dist/attributes/shape/effects/implementations/outline.js.map +1 -1
  189. package/dist/attributes/shape/effects/implementations/pixelate.d.ts +25 -6
  190. package/dist/attributes/shape/effects/implementations/pixelate.d.ts.map +1 -1
  191. package/dist/attributes/shape/effects/implementations/pixelate.js +16 -14
  192. package/dist/attributes/shape/effects/implementations/pixelate.js.map +1 -1
  193. package/dist/attributes/shape/effects/implementations/posterize.d.ts +14 -3
  194. package/dist/attributes/shape/effects/implementations/posterize.d.ts.map +1 -1
  195. package/dist/attributes/shape/effects/implementations/posterize.js +13 -9
  196. package/dist/attributes/shape/effects/implementations/posterize.js.map +1 -1
  197. package/dist/attributes/shape/effects/implementations/progressive-blur.d.ts +91 -26
  198. package/dist/attributes/shape/effects/implementations/progressive-blur.d.ts.map +1 -1
  199. package/dist/attributes/shape/effects/implementations/progressive-blur.js +27 -28
  200. package/dist/attributes/shape/effects/implementations/progressive-blur.js.map +1 -1
  201. package/dist/attributes/shape/effects/implementations/radial-blur.d.ts +49 -10
  202. package/dist/attributes/shape/effects/implementations/radial-blur.d.ts.map +1 -1
  203. package/dist/attributes/shape/effects/implementations/radial-blur.js +19 -20
  204. package/dist/attributes/shape/effects/implementations/radial-blur.js.map +1 -1
  205. package/dist/attributes/shape/effects/implementations/rgb-shift.d.ts +36 -6
  206. package/dist/attributes/shape/effects/implementations/rgb-shift.d.ts.map +1 -1
  207. package/dist/attributes/shape/effects/implementations/rgb-shift.js +16 -15
  208. package/dist/attributes/shape/effects/implementations/rgb-shift.js.map +1 -1
  209. package/dist/attributes/shape/effects/implementations/scanlines.d.ts +52 -11
  210. package/dist/attributes/shape/effects/implementations/scanlines.d.ts.map +1 -1
  211. package/dist/attributes/shape/effects/implementations/scanlines.js +21 -18
  212. package/dist/attributes/shape/effects/implementations/scanlines.js.map +1 -1
  213. package/dist/attributes/shape/effects/implementations/scatter.d.ts +23 -9
  214. package/dist/attributes/shape/effects/implementations/scatter.d.ts.map +1 -1
  215. package/dist/attributes/shape/effects/implementations/scatter.js +15 -12
  216. package/dist/attributes/shape/effects/implementations/scatter.js.map +1 -1
  217. package/dist/attributes/shape/effects/implementations/shader.d.ts +90 -34
  218. package/dist/attributes/shape/effects/implementations/shader.d.ts.map +1 -1
  219. package/dist/attributes/shape/effects/implementations/shader.js +42 -26
  220. package/dist/attributes/shape/effects/implementations/shader.js.map +1 -1
  221. package/dist/attributes/shape/effects/implementations/sharpen.d.ts +23 -5
  222. package/dist/attributes/shape/effects/implementations/sharpen.d.ts.map +1 -1
  223. package/dist/attributes/shape/effects/implementations/sharpen.js +16 -11
  224. package/dist/attributes/shape/effects/implementations/sharpen.js.map +1 -1
  225. package/dist/attributes/shape/effects/implementations/streak.d.ts +40 -9
  226. package/dist/attributes/shape/effects/implementations/streak.d.ts.map +1 -1
  227. package/dist/attributes/shape/effects/implementations/streak.js +19 -16
  228. package/dist/attributes/shape/effects/implementations/streak.js.map +1 -1
  229. package/dist/attributes/shape/effects/implementations/threshold.d.ts +24 -5
  230. package/dist/attributes/shape/effects/implementations/threshold.d.ts.map +1 -1
  231. package/dist/attributes/shape/effects/implementations/threshold.js +17 -11
  232. package/dist/attributes/shape/effects/implementations/threshold.js.map +1 -1
  233. package/dist/attributes/shape/effects/implementations/twirl.d.ts +35 -8
  234. package/dist/attributes/shape/effects/implementations/twirl.d.ts.map +1 -1
  235. package/dist/attributes/shape/effects/implementations/twirl.js +17 -16
  236. package/dist/attributes/shape/effects/implementations/twirl.js.map +1 -1
  237. package/dist/attributes/shape/effects/implementations/vignette.d.ts +37 -7
  238. package/dist/attributes/shape/effects/implementations/vignette.d.ts.map +1 -1
  239. package/dist/attributes/shape/effects/implementations/vignette.js +19 -18
  240. package/dist/attributes/shape/effects/implementations/vignette.js.map +1 -1
  241. package/dist/attributes/shape/effects/implementations/vintage.d.ts +24 -5
  242. package/dist/attributes/shape/effects/implementations/vintage.d.ts.map +1 -1
  243. package/dist/attributes/shape/effects/implementations/vintage.js +15 -10
  244. package/dist/attributes/shape/effects/implementations/vintage.js.map +1 -1
  245. package/dist/attributes/shape/effects/implementations/wave.d.ts +61 -14
  246. package/dist/attributes/shape/effects/implementations/wave.d.ts.map +1 -1
  247. package/dist/attributes/shape/effects/implementations/wave.js +26 -23
  248. package/dist/attributes/shape/effects/implementations/wave.js.map +1 -1
  249. package/dist/attributes/shape/effects/index.d.ts +4 -2
  250. package/dist/attributes/shape/effects/index.d.ts.map +1 -1
  251. package/dist/attributes/shape/effects/index.js +1 -1
  252. package/dist/attributes/shape/effects/index.js.map +1 -1
  253. package/dist/attributes/shape/effects/registry.d.ts +11 -0
  254. package/dist/attributes/shape/effects/registry.d.ts.map +1 -1
  255. package/dist/attributes/shape/effects/registry.js +113 -102
  256. package/dist/attributes/shape/effects/registry.js.map +1 -1
  257. package/dist/attributes/shape/effects/spec.d.ts +229 -0
  258. package/dist/attributes/shape/effects/spec.d.ts.map +1 -0
  259. package/dist/attributes/shape/effects/spec.js +178 -0
  260. package/dist/attributes/shape/effects/spec.js.map +1 -0
  261. package/dist/attributes/shape/fill/chain.d.ts +7 -9
  262. package/dist/attributes/shape/fill/chain.d.ts.map +1 -1
  263. package/dist/attributes/shape/fill/chain.js +9 -11
  264. package/dist/attributes/shape/fill/chain.js.map +1 -1
  265. package/dist/attributes/shape/fill/implementations/shader.d.ts +27 -26
  266. package/dist/attributes/shape/fill/implementations/shader.d.ts.map +1 -1
  267. package/dist/attributes/shape/fill/implementations/shader.js +20 -14
  268. package/dist/attributes/shape/fill/implementations/shader.js.map +1 -1
  269. package/dist/attributes/shape/fill/index.d.ts +1 -1
  270. package/dist/attributes/shape/fill/index.d.ts.map +1 -1
  271. package/dist/attributes/shape/fill/index.js.map +1 -1
  272. package/dist/attributes/shape/fill/registry.d.ts +1 -2
  273. package/dist/attributes/shape/fill/registry.d.ts.map +1 -1
  274. package/dist/attributes/shape/fill/registry.js +1 -2
  275. package/dist/attributes/shape/fill/registry.js.map +1 -1
  276. package/dist/attributes/shape/filters/chain.d.ts +2 -6
  277. package/dist/attributes/shape/filters/chain.d.ts.map +1 -1
  278. package/dist/attributes/shape/filters/chain.js +1 -5
  279. package/dist/attributes/shape/filters/chain.js.map +1 -1
  280. package/dist/attributes/shape/filters/implementations/color-matrix.d.ts +2 -2
  281. package/dist/attributes/shape/filters/implementations/color-matrix.d.ts.map +1 -1
  282. package/dist/attributes/shape/filters/implementations/color-matrix.js.map +1 -1
  283. package/dist/attributes/shape/filters/registry.d.ts +1 -1
  284. package/dist/attributes/shape/filters/registry.d.ts.map +1 -1
  285. package/dist/attributes/shape/filters/registry.js +3 -3
  286. package/dist/attributes/shape/filters/registry.js.map +1 -1
  287. package/dist/attributes/shape/filters/union.d.ts +2 -3
  288. package/dist/attributes/shape/filters/union.d.ts.map +1 -1
  289. package/dist/attributes/shape/filters/union.js.map +1 -1
  290. package/dist/attributes/shape/shaders/index.d.ts +2 -0
  291. package/dist/attributes/shape/shaders/index.d.ts.map +1 -1
  292. package/dist/attributes/shape/shaders/index.js +2 -0
  293. package/dist/attributes/shape/shaders/index.js.map +1 -1
  294. package/dist/attributes/shape/shaders/language.d.ts +26 -0
  295. package/dist/attributes/shape/shaders/language.d.ts.map +1 -0
  296. package/dist/attributes/shape/shaders/language.js +20 -0
  297. package/dist/attributes/shape/shaders/language.js.map +1 -0
  298. package/dist/attributes/shape/shaders/pack.d.ts +25 -11
  299. package/dist/attributes/shape/shaders/pack.d.ts.map +1 -1
  300. package/dist/attributes/shape/shaders/pack.js +9 -4
  301. package/dist/attributes/shape/shaders/pack.js.map +1 -1
  302. package/dist/attributes/shape/shaders/resolve.d.ts +4 -5
  303. package/dist/attributes/shape/shaders/resolve.d.ts.map +1 -1
  304. package/dist/attributes/shape/shaders/resolve.js +3 -6
  305. package/dist/attributes/shape/shaders/resolve.js.map +1 -1
  306. package/dist/attributes/shape/shaders/uniforms.d.ts +41 -0
  307. package/dist/attributes/shape/shaders/uniforms.d.ts.map +1 -0
  308. package/dist/attributes/shape/shaders/uniforms.js +0 -0
  309. package/dist/attributes/shape/shaders/uniforms.js.map +1 -0
  310. package/dist/browser/chunks/chunk-AOT33LMS.js +13 -0
  311. package/dist/browser/chunks/chunk-AOT33LMS.js.map +7 -0
  312. package/dist/browser/chunks/chunk-GKM6UZJR.js +6 -0
  313. package/dist/browser/chunks/chunk-GKM6UZJR.js.map +7 -0
  314. package/dist/browser/experimental.js +1 -1
  315. package/dist/browser/experimental.js.map +4 -4
  316. package/dist/browser/index.js +1 -1
  317. package/dist/browser/index.js.map +2 -2
  318. package/dist/browser/manifest.json +1 -1
  319. package/dist/browser/sdk.js +1 -1
  320. package/dist/components/builtins/audio/audio.d.ts +14 -5
  321. package/dist/components/builtins/audio/audio.d.ts.map +1 -1
  322. package/dist/components/builtins/audio/audio.js +10 -13
  323. package/dist/components/builtins/audio/audio.js.map +1 -1
  324. package/dist/components/builtins/geometry/composite.d.ts +3 -3
  325. package/dist/components/builtins/media/media.d.ts +7 -7
  326. package/dist/components/builtins/media/media.d.ts.map +1 -1
  327. package/dist/components/builtins/media/media.js +4 -10
  328. package/dist/components/builtins/media/media.js.map +1 -1
  329. package/dist/components/builtins/text/text.d.ts +12 -12
  330. package/dist/components/builtins/text/text.d.ts.map +1 -1
  331. package/dist/components/builtins/text/text.js +3 -0
  332. package/dist/components/builtins/text/text.js.map +1 -1
  333. package/dist/components/factory/api.d.ts +38 -11
  334. package/dist/components/factory/api.d.ts.map +1 -1
  335. package/dist/components/factory/api.js.map +1 -1
  336. package/dist/components/factory/component3d.d.ts.map +1 -1
  337. package/dist/components/factory/component3d.js +11 -3
  338. package/dist/components/factory/component3d.js.map +1 -1
  339. package/dist/components/factory/factory.d.ts +3 -0
  340. package/dist/components/factory/factory.d.ts.map +1 -1
  341. package/dist/components/factory/factory.js +39 -5
  342. package/dist/components/factory/factory.js.map +1 -1
  343. package/dist/components/modules/text-style.d.ts +1 -1
  344. package/dist/components/trees/2d/node-render.d.ts +1 -1
  345. package/dist/components/trees/2d/node-render.js +1 -1
  346. package/dist/components/trees/2d/node-render.js.map +1 -1
  347. package/dist/components/trees/2d/node2d.d.ts +1 -1
  348. package/dist/components/trees/2d/node2d.js +1 -1
  349. package/dist/components/trees/2d/node2d.js.map +1 -1
  350. package/dist/components/trees/audio/node-audio.d.ts +16 -9
  351. package/dist/components/trees/audio/node-audio.d.ts.map +1 -1
  352. package/dist/components/trees/audio/node-audio.js +15 -11
  353. package/dist/components/trees/audio/node-audio.js.map +1 -1
  354. package/dist/document/command-traits.d.ts +12 -2
  355. package/dist/document/command-traits.d.ts.map +1 -1
  356. package/dist/document/command-traits.js +34 -6
  357. package/dist/document/command-traits.js.map +1 -1
  358. package/dist/document/index.d.ts +8 -0
  359. package/dist/document/index.d.ts.map +1 -1
  360. package/dist/document/index.js +4 -0
  361. package/dist/document/index.js.map +1 -1
  362. package/dist/document/migrate.d.ts +70 -0
  363. package/dist/document/migrate.d.ts.map +1 -0
  364. package/dist/document/migrate.js +202 -0
  365. package/dist/document/migrate.js.map +1 -0
  366. package/dist/document/missing-node.d.ts +27 -0
  367. package/dist/document/missing-node.d.ts.map +1 -0
  368. package/dist/document/missing-node.js +48 -0
  369. package/dist/document/missing-node.js.map +1 -0
  370. package/dist/document/node-descriptor.d.ts +4 -0
  371. package/dist/document/node-descriptor.d.ts.map +1 -1
  372. package/dist/document/node-descriptor.js.map +1 -1
  373. package/dist/document/placement.d.ts +2 -1
  374. package/dist/document/placement.d.ts.map +1 -1
  375. package/dist/document/placement.js.map +1 -1
  376. package/dist/document/project.d.ts +2 -0
  377. package/dist/document/project.d.ts.map +1 -1
  378. package/dist/document/project.js +1 -0
  379. package/dist/document/project.js.map +1 -1
  380. package/dist/document/prop-evolution.d.ts +51 -0
  381. package/dist/document/prop-evolution.d.ts.map +1 -0
  382. package/dist/document/prop-evolution.js +83 -0
  383. package/dist/document/prop-evolution.js.map +1 -0
  384. package/dist/document/registry.d.ts +16 -0
  385. package/dist/document/registry.d.ts.map +1 -1
  386. package/dist/document/registry.js +30 -4
  387. package/dist/document/registry.js.map +1 -1
  388. package/dist/document/settled-index.d.ts +2 -0
  389. package/dist/document/settled-index.d.ts.map +1 -1
  390. package/dist/document/settled-index.js +5 -5
  391. package/dist/document/settled-index.js.map +1 -1
  392. package/dist/document/timeline-patch.d.ts +4 -0
  393. package/dist/document/timeline-patch.d.ts.map +1 -1
  394. package/dist/document/timeline-patch.js +28 -3
  395. package/dist/document/timeline-patch.js.map +1 -1
  396. package/dist/document/timeline.d.ts +45 -1
  397. package/dist/document/timeline.d.ts.map +1 -1
  398. package/dist/document/timeline.js +172 -42
  399. package/dist/document/timeline.js.map +1 -1
  400. package/dist/document/types.d.ts +14 -28
  401. package/dist/document/types.d.ts.map +1 -1
  402. package/dist/document/types.js.map +1 -1
  403. package/dist/document/validate.d.ts +17 -5
  404. package/dist/document/validate.d.ts.map +1 -1
  405. package/dist/document/validate.js +158 -21
  406. package/dist/document/validate.js.map +1 -1
  407. package/dist/document/vocabulary.d.ts +28 -0
  408. package/dist/document/vocabulary.d.ts.map +1 -0
  409. package/dist/document/vocabulary.js +42 -0
  410. package/dist/document/vocabulary.js.map +1 -0
  411. package/dist/experimental.d.ts +68 -8
  412. package/dist/experimental.d.ts.map +1 -1
  413. package/dist/experimental.js +22 -8
  414. package/dist/experimental.js.map +1 -1
  415. package/dist/platform/exporter.d.ts +13 -0
  416. package/dist/platform/exporter.d.ts.map +1 -1
  417. package/dist/platform/exporter.js.map +1 -1
  418. package/dist/renamed-scene-names.d.ts +1 -1
  419. package/dist/renamed-scene-names.d.ts.map +1 -1
  420. package/dist/renamed-scene-names.js +1 -1
  421. package/dist/renamed-scene-names.js.map +1 -1
  422. package/dist/render/canvas-render-context2d.d.ts +9 -0
  423. package/dist/render/canvas-render-context2d.d.ts.map +1 -1
  424. package/dist/render/canvas-render-context2d.js +10 -0
  425. package/dist/render/canvas-render-context2d.js.map +1 -1
  426. package/dist/render/clip-contains.js +1 -1
  427. package/dist/render/clip-contains.js.map +1 -1
  428. package/dist/render/descriptors/text.d.ts +2 -2
  429. package/dist/render/descriptors/text.js +2 -2
  430. package/dist/render/descriptors/text.js.map +1 -1
  431. package/dist/render/index.d.ts +2 -0
  432. package/dist/render/index.d.ts.map +1 -1
  433. package/dist/render/index.js +1 -0
  434. package/dist/render/index.js.map +1 -1
  435. package/dist/render/render-context2d.d.ts +1 -1
  436. package/dist/render/render-context2d.js.map +1 -1
  437. package/dist/render/render-issue.d.ts +39 -0
  438. package/dist/render/render-issue.d.ts.map +1 -0
  439. package/dist/render/render-issue.js +29 -0
  440. package/dist/render/render-issue.js.map +1 -0
  441. package/dist/render/surface.d.ts +2 -2
  442. package/dist/render/surface.js.map +1 -1
  443. package/dist/render3d/graphics3d.d.ts.map +1 -1
  444. package/dist/render3d/graphics3d.js +54 -5
  445. package/dist/render3d/graphics3d.js.map +1 -1
  446. package/dist/runtime/asset-refine.js +2 -1
  447. package/dist/runtime/asset-refine.js.map +1 -1
  448. package/dist/runtime/asset-timeline.d.ts +10 -0
  449. package/dist/runtime/asset-timeline.d.ts.map +1 -1
  450. package/dist/runtime/asset-timeline.js.map +1 -1
  451. package/dist/runtime/asset-update.d.ts.map +1 -1
  452. package/dist/runtime/asset-update.js +7 -0
  453. package/dist/runtime/asset-update.js.map +1 -1
  454. package/dist/runtime/clip-instance.d.ts +3 -1
  455. package/dist/runtime/clip-instance.d.ts.map +1 -1
  456. package/dist/runtime/clip-instance.js +4 -0
  457. package/dist/runtime/clip-instance.js.map +1 -1
  458. package/dist/runtime/clip-store.d.ts.map +1 -1
  459. package/dist/runtime/clip-store.js +17 -2
  460. package/dist/runtime/clip-store.js.map +1 -1
  461. package/dist/runtime/engine.d.ts +5 -3
  462. package/dist/runtime/engine.d.ts.map +1 -1
  463. package/dist/runtime/engine.js +2 -1
  464. package/dist/runtime/engine.js.map +1 -1
  465. package/dist/runtime/playback-controller.d.ts.map +1 -1
  466. package/dist/runtime/playback-controller.js +14 -4
  467. package/dist/runtime/playback-controller.js.map +1 -1
  468. package/dist/runtime/session.d.ts +7 -3
  469. package/dist/runtime/session.d.ts.map +1 -1
  470. package/dist/runtime/session.js +11 -4
  471. package/dist/runtime/session.js.map +1 -1
  472. package/dist/runtime/text-geometry.d.ts +1 -1
  473. package/dist/runtime/text-geometry.js.map +1 -1
  474. package/dist/sdk/index.d.ts +8 -6
  475. package/dist/sdk/index.d.ts.map +1 -1
  476. package/dist/sdk/index.js +10 -3
  477. package/dist/sdk/index.js.map +1 -1
  478. package/dist/tween/command-decorator.d.ts +7 -0
  479. package/dist/tween/command-decorator.d.ts.map +1 -1
  480. package/dist/tween/command-decorator.js +1 -0
  481. package/dist/tween/command-decorator.js.map +1 -1
  482. package/dist/tween/ease/describe.d.ts +2 -0
  483. package/dist/tween/ease/describe.d.ts.map +1 -1
  484. package/dist/tween/ease/describe.js +4 -0
  485. package/dist/tween/ease/describe.js.map +1 -1
  486. package/dist/tween/ease/spec.d.ts +31 -0
  487. package/dist/tween/ease/spec.d.ts.map +1 -0
  488. package/dist/tween/ease/spec.js +51 -0
  489. package/dist/tween/ease/spec.js.map +1 -0
  490. package/dist/tween/index.d.ts +1 -0
  491. package/dist/tween/index.d.ts.map +1 -1
  492. package/dist/tween/index.js +1 -0
  493. package/dist/tween/index.js.map +1 -1
  494. package/package.json +2 -2
  495. package/dist/browser/chunks/chunk-D4FSTPML.js +0 -14
  496. package/dist/browser/chunks/chunk-D4FSTPML.js.map +0 -7
  497. package/dist/browser/chunks/chunk-RTNATFWX.js +0 -5
  498. package/dist/browser/chunks/chunk-RTNATFWX.js.map +0 -7
@@ -1 +1 @@
1
- {"version":3,"file":"registry.js","sourceRoot":"","sources":["../../../../src/attributes/shape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M;QAAE,OAAO,SAAS,CAAC;IACnD,OAAO,eAAe,CAAC,IAAI,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,CAAC,CAAQ,CAAC;AAC3D,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,IAAiB,EAAE,EAAe,EAAE,CAAS;IACzE,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC;IAChD,MAAM,MAAM,GAAgB,EAAE,CAAC;IAC/B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAC9B,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;QAChB,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YACT,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QACrC,CAAC;aAAM,IAAI,CAAC,EAAE,CAAC;YACX,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACnB,CAAC;aAAM,IAAI,CAAC,EAAE,CAAC;YACX,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACnB,CAAC;IACL,CAAC;IACD,OAAO,MAAM,CAAC;AAClB,CAAC","sourcesContent":["import { MediaAdjustment, VideoOnlyAdjustment } from \"./union\";\r\nimport { declareEffect, effectSurface, hasEffect, lerpEffect } from \"../effects/registry\";\r\nimport type { NodeEffect } from \"../effects/union\";\r\nimport type { AssetScope } from \"@/assets/scope\";\r\n\r\nimport { exposureFilter } from \"./implementations/exposure\";\r\nimport { blurFilter } from \"./implementations/blur\";\r\nimport { grayscaleFilter } from \"./implementations/grayscale\";\r\nimport { alphaFilter } from \"./implementations/alpha\";\r\nimport { colorMatrixFilter } from \"./implementations/color-matrix\";\r\nimport { curvesFilter } from \"./implementations/curves\";\r\nimport { colorAdjustmentFilter } from \"./implementations/color-adjustment\";\r\nimport { posterizeTimeFilter } from \"./implementations/posterize-time\";\r\nimport { echoFilter } from \"./implementations/echo\";\r\n\r\n/** Any concrete filter object accepted on a media fill — pixel or video-only. */\r\nexport type AnyFilter = MediaAdjustment | VideoOnlyAdjustment;\r\n\r\n/** Interpolation and equality contract every filter implementation must implement. */\r\nexport interface FilterData<T extends AnyFilter> {\r\n /** Return a new filter linearly interpolated between `from` and `to` at progress `t` (0–1). */\r\n lerp(from: T, to: T, t: number): T;\r\n /** Return true when both filters are visually identical (used to skip redundant redraws). */\r\n equals(a: T, b: T): boolean;\r\n}\r\n\r\n/**\r\n * Maps each filter `type` to its `FilterData` handler. Statically imported\r\n * constants (no runtime registration step), mirroring the `FILLS` map in the\r\n * fill registry — so the table is always populated and there is no side-effect\r\n * import to forget.\r\n *\r\n * It holds only the filters that exist *solely* as filters. Most of the roster\r\n * is {@link EffectAdjustment} — a node effect applied to a fill's own pixels — and\r\n * those are looked up in the effects registry rather than duplicated here, so\r\n * `dither` interpolates the same way whether it is on a node or on an image.\r\n */\r\nconst FILTERS = new Map<string, FilterData<AnyFilter>>([\r\n [\"exposure\", exposureFilter as FilterData<AnyFilter>],\r\n [\"blur\", blurFilter as FilterData<AnyFilter>],\r\n [\"grayscale\", grayscaleFilter as FilterData<AnyFilter>],\r\n [\"alpha\", alphaFilter as FilterData<AnyFilter>],\r\n [\"colorMatrix\", colorMatrixFilter as FilterData<AnyFilter>],\r\n [\"curves\", curvesFilter as FilterData<AnyFilter>],\r\n [\"colorAdjustment\", colorAdjustmentFilter as FilterData<AnyFilter>],\r\n [\"posterizeTime\", posterizeTimeFilter as FilterData<AnyFilter>],\r\n [\"echo\", echoFilter as FilterData<AnyFilter>],\r\n]);\r\n\r\n/**\r\n * Video-only filter types. These are consumed by the video fill's per-frame\r\n * `update()` (`posterizeTime`) or a dedicated multi-pass renderer (`echo`),\r\n * NOT the pixel `setImageFilter` chain. `isPixelFilter` lets the web layer skip\r\n * them when composing the CanvasKit image filter.\r\n */\r\nconst VIDEO_ONLY = new Set<string>([\"posterizeTime\", \"echo\"]);\r\n\r\n/** True when `type` is a pixel filter that composes into a CanvasKit image filter. */\r\nexport function isPixelFilter(type: string): boolean {\r\n return !VIDEO_ONLY.has(type);\r\n}\r\n\r\n/** True when `type` has a registered `FilterData` handler, here or in the effects registry. */\r\nexport function hasFilter(type: string): boolean {\r\n return FILTERS.has(type) || hasEffect(type);\r\n}\r\n\r\n/**\r\n * Interpolate between two individual filters at progress `t`.\r\n * Falls back to a hard cut at t = 0.5 when the types differ or are unregistered.\r\n *\r\n * A type with no dedicated `FilterData` is an {@link EffectAdjustment}, so it is\r\n * handed to `lerpEffect` — one interpolation per effect, whether it is animated\r\n * on a node or inside a fill.\r\n */\r\nexport function lerpFilter(from: AnyFilter, to: AnyFilter, t: number): AnyFilter {\r\n if (from.type !== to.type) return t < 0.5 ? from : to;\r\n const data = FILTERS.get(from.type);\r\n if (data) return data.lerp(from, to, t);\r\n return lerpEffect(from as NodeEffect, to as NodeEffect, t) as AnyFilter;\r\n}\r\n\r\n/**\r\n * The filters defined here reference nothing, but an {@link EffectAdjustment} can —\r\n * `lut` samples an image — and an undeclared one is a lookup the effect can only\r\n * read as \"no lookup table\".\r\n */\r\nexport function declareFilter(filter: AnyFilter, assets: AssetScope): void {\r\n if (FILTERS.has(filter.type)) return;\r\n declareEffect(filter as NodeEffect, assets);\r\n}\r\n\r\n/**\r\n * How a backend must realise `filter` — `\"shader\"` when it resamples pixel\r\n * positions and therefore has to wrap the fill's shader rather than compose\r\n * into its `ImageFilter` chain. The filters defined here are all `\"filter\"`;\r\n * an {@link EffectAdjustment} answers with its effect's own declaration.\r\n */\r\nexport function filterSurface(filter: AnyFilter): \"filter\" | \"shader\" {\r\n if (FILTERS.has(filter.type)) return \"filter\";\r\n // A filter is applied to the fill's own pixels, so it is never a backdrop\r\n // effect however the underlying effect's `mode` predicate reads.\r\n return effectSurface({ ...filter, mode: \"foreground\" } as NodeEffect);\r\n}\r\n\r\n/**\r\n * {@link lerpFilterArray} over two *optional* arrays, answering `undefined`\r\n * when neither side has a filter.\r\n *\r\n * A media fill's `lerp` is spread over the whole fill (`{...a, ...lerp(a,b,t)}`),\r\n * so returning `[]` for the overwhelmingly common no-filter case would allocate\r\n * a fresh array per fill per frame and turn an absent field into a present one.\r\n */\r\nexport function lerpOptionalFilters<T extends AnyFilter>(\r\n from: T[] | undefined,\r\n to: T[] | undefined,\r\n t: number,\r\n): T[] | undefined {\r\n if (!from?.length && !to?.length) return undefined;\r\n return lerpFilterArray(from ?? [], to ?? [], t) as T[];\r\n}\r\n\r\n/**\r\n * Interpolate between two filter arrays of potentially different lengths.\r\n * Indices present in only one array are kept as-is; matched indices are lerped pairwise.\r\n */\r\nexport function lerpFilterArray(from: AnyFilter[], to: AnyFilter[], t: number): AnyFilter[] {\r\n const maxLen = Math.max(from.length, to.length);\r\n const result: AnyFilter[] = [];\r\n for (let i = 0; i < maxLen; i++) {\r\n const a = from[i];\r\n const b = to[i];\r\n if (a && b) {\r\n result.push(lerpFilter(a, b, t));\r\n } else if (a) {\r\n result.push(a);\r\n } else if (b) {\r\n result.push(b);\r\n }\r\n }\r\n return result;\r\n}\r\n"]}
1
+ {"version":3,"file":"registry.js","sourceRoot":"","sources":["../../../../src/attributes/shape/filters/registry.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAI1F,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAA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AK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAC9B,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;QAChB,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YACT,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QACrC,CAAC;aAAM,IAAI,CAAC,EAAE,CAAC;YACX,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACnB,CAAC;aAAM,IAAI,CAAC,EAAE,CAAC;YACX,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACnB,CAAC;IACL,CAAC;IACD,OAAO,MAAM,CAAC;AAClB,CAAC","sourcesContent":["import { MediaAdjustment, VideoOnlyAdjustment } from \"./union\";\r\nimport { declareEffect, effectSurface, hasEffect, lerpEffect } from \"../effects/registry\";\r\nimport type { NodeEffect } from \"../effects/union\";\r\nimport type { AssetScope } from \"@/assets/scope\";\r\n\r\nimport { exposureFilter } from \"./implementations/exposure\";\r\nimport { blurFilter } from \"./implementations/blur\";\r\nimport { grayscaleFilter } from \"./implementations/grayscale\";\r\nimport { alphaFilter } from \"./implementations/alpha\";\r\nimport { colorMatrixFilter } from \"./implementations/color-matrix\";\r\nimport { curvesFilter } from \"./implementations/curves\";\r\nimport { colorAdjustmentFilter } from \"./implementations/color-adjustment\";\r\nimport { posterizeTimeFilter } from \"./implementations/posterize-time\";\r\nimport { echoFilter } from \"./implementations/echo\";\r\n\r\n/** Any concrete filter object accepted on a media fill — pixel or video-only. */\r\nexport type AnyFilter = MediaAdjustment | VideoOnlyAdjustment;\r\n\r\n/** Interpolation and equality contract every filter implementation must implement. */\r\nexport interface FilterData<T extends AnyFilter> {\r\n /** Return a new filter linearly interpolated between `from` and `to` at progress `t` (0–1). */\r\n lerp(from: T, to: T, t: number): T;\r\n /** Return true when both filters are visually identical (used to skip redundant redraws). */\r\n equals(a: T, b: T): boolean;\r\n}\r\n\r\n/**\r\n * Maps each filter `type` to its `FilterData` handler. Statically imported\r\n * constants (no runtime registration step), mirroring the `FILLS` map in the\r\n * fill registry — so the table is always populated and there is no side-effect\r\n * import to forget.\r\n *\r\n * It holds only the filters that exist *solely* as filters. Most of the roster\r\n * is {@link EffectAdjustment} — a node effect applied to a fill's own pixels — and\r\n * those are looked up in the effects registry rather than duplicated here, so\r\n * `dither` interpolates the same way whether it is on a node or on an image.\r\n */\r\nconst FILTERS = new Map<string, FilterData<AnyFilter>>([\r\n [\"exposure\", exposureFilter as FilterData<AnyFilter>],\r\n [\"blur\", blurFilter as FilterData<AnyFilter>],\r\n [\"grayscale\", grayscaleFilter as FilterData<AnyFilter>],\r\n [\"alpha\", alphaFilter as FilterData<AnyFilter>],\r\n [\"colorMatrix\", colorMatrixFilter as FilterData<AnyFilter>],\r\n [\"curves\", curvesFilter as FilterData<AnyFilter>],\r\n [\"colorAdjustment\", colorAdjustmentFilter as FilterData<AnyFilter>],\r\n [\"posterizeTime\", posterizeTimeFilter as FilterData<AnyFilter>],\r\n [\"echo\", echoFilter as FilterData<AnyFilter>],\r\n]);\r\n\r\n/**\r\n * Video-only filter types. These are consumed by the video fill's per-frame\r\n * `update()` (`posterizeTime`) or a dedicated multi-pass renderer (`echo`),\r\n * not the pixel filter chain. `isPixelFilter` lets a renderer skip them when\r\n * composing that chain.\r\n */\r\nconst VIDEO_ONLY = new Set<string>([\"posterizeTime\", \"echo\"]);\r\n\r\n/** True when `type` is a pixel filter that composes into a media fill's filter chain. */\r\nexport function isPixelFilter(type: string): boolean {\r\n return !VIDEO_ONLY.has(type);\r\n}\r\n\r\n/** True when `type` has a registered `FilterData` handler, here or in the effects registry. */\r\nexport function hasFilter(type: string): boolean {\r\n return FILTERS.has(type) || hasEffect(type);\r\n}\r\n\r\n/**\r\n * Interpolate between two individual filters at progress `t`.\r\n * Falls back to a hard cut at t = 0.5 when the types differ or are unregistered.\r\n *\r\n * A type with no dedicated `FilterData` is an {@link EffectAdjustment}, so it is\r\n * handed to `lerpEffect` — one interpolation per effect, whether it is animated\r\n * on a node or inside a fill.\r\n */\r\nexport function lerpFilter(from: AnyFilter, to: AnyFilter, t: number): AnyFilter {\r\n if (from.type !== to.type) return t < 0.5 ? from : to;\r\n const data = FILTERS.get(from.type);\r\n if (data) return data.lerp(from, to, t);\r\n return lerpEffect(from as NodeEffect, to as NodeEffect, t) as AnyFilter;\r\n}\r\n\r\n/**\r\n * The filters defined here reference nothing, but an {@link EffectAdjustment} can —\r\n * `lut` samples an image — and an undeclared one is a lookup the effect can only\r\n * read as \"no lookup table\".\r\n */\r\nexport function declareFilter(filter: AnyFilter, assets: AssetScope): void {\r\n if (FILTERS.has(filter.type)) return;\r\n declareEffect(filter as NodeEffect, assets);\r\n}\r\n\r\n/**\r\n * How a backend must realise `filter` — `\"shader\"` when it resamples pixel\r\n * positions and therefore has to wrap the fill's shader rather than compose\r\n * into its `ImageFilter` chain. The filters defined here are all `\"filter\"`;\r\n * an {@link EffectAdjustment} answers with its effect's own declaration.\r\n */\r\nexport function filterSurface(filter: AnyFilter): \"filter\" | \"shader\" {\r\n if (FILTERS.has(filter.type)) return \"filter\";\r\n // A filter is applied to the fill's own pixels, so it is never a backdrop\r\n // effect however the underlying effect's `mode` predicate reads.\r\n return effectSurface({ ...filter, mode: \"foreground\" } as NodeEffect);\r\n}\r\n\r\n/**\r\n * {@link lerpFilterArray} over two *optional* arrays, answering `undefined`\r\n * when neither side has a filter.\r\n *\r\n * A media fill's `lerp` is spread over the whole fill (`{...a, ...lerp(a,b,t)}`),\r\n * so returning `[]` for the overwhelmingly common no-filter case would allocate\r\n * a fresh array per fill per frame and turn an absent field into a present one.\r\n */\r\nexport function lerpOptionalFilters<T extends AnyFilter>(\r\n from: T[] | undefined,\r\n to: T[] | undefined,\r\n t: number,\r\n): T[] | undefined {\r\n if (!from?.length && !to?.length) return undefined;\r\n return lerpFilterArray(from ?? [], to ?? [], t) as T[];\r\n}\r\n\r\n/**\r\n * Interpolate between two filter arrays of potentially different lengths.\r\n * Indices present in only one array are kept as-is; matched indices are lerped pairwise.\r\n */\r\nexport function lerpFilterArray(from: AnyFilter[], to: AnyFilter[], t: number): AnyFilter[] {\r\n const maxLen = Math.max(from.length, to.length);\r\n const result: AnyFilter[] = [];\r\n for (let i = 0; i < maxLen; i++) {\r\n const a = from[i];\r\n const b = to[i];\r\n if (a && b) {\r\n result.push(lerpFilter(a, b, t));\r\n } else if (a) {\r\n result.push(a);\r\n } else if (b) {\r\n result.push(b);\r\n }\r\n }\r\n return result;\r\n}\r\n"]}
@@ -65,9 +65,8 @@ type NonFilterEffect = MagnifyEffect | GlassEffect | MotionBlurEffect | OutlineE
65
65
  export type EffectAdjustment = Exclude<NodeEffect, NonFilterEffect>;
66
66
  /**
67
67
  * Discriminated union of pixel filters — the filters valid on both image and
68
- * video fills. Each is realised either as a single CanvasKit image filter
69
- * applied via `paint.setImageFilter`, or — for the ones that resample pixel
70
- * *positions* — as a lens shader wrapping the fill's own shader.
68
+ * video fills. Each is realised either as a per-pixel colour filter, or — for
69
+ * the ones that resample pixel *positions* — as a lens pass over the fill.
71
70
  */
72
71
  export type MediaAdjustment = ExposureFilter | BlurFilter | GrayscaleFilter | AlphaFilter | ColorMatrixFilter | CurvesFilter | ColorAdjustmentFilter | EffectAdjustment;
73
72
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"union.d.ts","sourceRoot":"","sources":["../../../../src/attributes/shape/filters/union.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAChF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,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,KAAK,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wDAAwD,CAAC;AAC/F,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAEpE;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,KAAK,eAAe,GACd,aAAa,GACb,WAAW,GACX,gBAAgB,GAChB,aAAa,GACb,gBAAgB,GAChB,UAAU,GACV,UAAU,GACV,eAAe,GACf,YAAY,GACZ,qBAAqB,CAAC;AAE5B;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,gBAAgB,GAAG,OAAO,CAAC,UAAU,EAAE,eAAe,CAAC,CAAC;AAEpE;;;;GAIG;AACH,MAAM,MAAM,eAAe,GACrB,cAAc,GACd,UAAU,GACV,eAAe,GACf,WAAW,GACX,iBAAiB,GACjB,YAAY,GACZ,qBAAqB,GACrB,gBAAgB,CAAC;AAEvB;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,GACzB,mBAAmB,GACnB,eAAe,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"union.js","sourceRoot":"","sources":["../../../../src/attributes/shape/filters/union.ts"],"names":[],"mappings":"","sourcesContent":["import type { AlphaFilter } from \"./implementations/alpha\";\r\nimport type { BlurFilter } from \"./implementations/blur\";\r\nimport type { ColorAdjustmentFilter } from \"./implementations/color-adjustment\";\r\nimport type { ColorMatrixFilter } from \"./implementations/color-matrix\";\r\nimport type { CurvesFilter } from \"./implementations/curves\";\r\nimport type { ExposureFilter } from \"./implementations/exposure\";\r\nimport type { GrayscaleFilter } from \"./implementations/grayscale\";\r\nimport type { PosterizeTimeFilter } from \"./implementations/posterize-time\";\r\nimport type { VideoEchoFilter } from \"./implementations/echo\";\r\n\r\nimport type { NodeEffect } from \"../effects/union\";\r\nimport type { BlurEffect } from \"../effects/implementations/blur\";\r\nimport type { GrayscaleEffect } from \"../effects/implementations/grayscale\";\r\nimport type { CurvesEffect } from \"../effects/implementations/curves\";\r\nimport type { ColorAdjustmentEffect } from \"../effects/implementations/color-adjustment\";\r\nimport type { MagnifyEffect } from \"../effects/implementations/magnify\";\r\nimport type { MotionBlurEffect } from \"../effects/implementations/motion-blur\";\r\nimport type { OutlineEffect } from \"../effects/implementations/outline\";\r\nimport type { DropShadowEffect } from \"@/attributes/shape/effects/implementations/drop-shadow\";\r\nimport type { GlowEffect } from \"../effects/implementations/glow\";\r\nimport type { GlassEffect } from \"../effects/implementations/glass\";\r\n\r\n/**\r\n * The node effects that are **not** media filters, and why.\r\n *\r\n * Everything else in {@link NodeEffect} is a function of the pixels it is\r\n * given, so it means exactly the same thing applied to a node's rendered\r\n * content or to one fill layer's own pixels — and the renderer already runs\r\n * both through a single handler registry. This is the exception list, so a new\r\n * effect becomes a filter by default rather than by remembering to add it.\r\n *\r\n * Two reasons land here:\r\n *\r\n * - **Needs something a fill layer doesn't have.** `magnify` and `glass` sample\r\n * the backdrop beneath the node — glass is a slab you see *through*, and a\r\n * node's own paint is not something there is anything behind; `motionBlur` and\r\n * `trails` are derived from the node's sampled velocity. A fill has no\r\n * backdrop and no motion of its own.\r\n * - **Draws outside the silhouette.** `outline` paints a ring around the\r\n * content, which the shape path a fill is clipped to would cut away, and\r\n * `glow` bleeds past it in every direction — a glow clipped to the thing that\r\n * cast it is not a dimmer glow, it is no glow at all. (`bloom` stays: it is\r\n * the contained version of the same idea, which is what makes it the right\r\n * one to reach for on a fill.)\r\n *\r\n * `blur`, `grayscale`, `curves` and `colorAdjustment` are excluded for a third,\r\n * bookkeeping reason: they already have a dedicated filter type below, sharing\r\n * the same fields and the same renderer handler.\r\n */\r\ntype NonFilterEffect =\r\n | MagnifyEffect\r\n | GlassEffect\r\n | MotionBlurEffect\r\n | OutlineEffect\r\n | DropShadowEffect\r\n | GlowEffect\r\n | BlurEffect\r\n | GrayscaleEffect\r\n | CurvesEffect\r\n | ColorAdjustmentEffect;\r\n\r\n/**\r\n * Node effects usable as a media filter — i.e. applied to one image/video\r\n * fill's own pixels rather than to a node and everything under it.\r\n *\r\n * This is what lets a background image be oil-painted, dithered or posterized\r\n * without wrapping it in a node whose effect would also hit its children:\r\n *\r\n * Rect({\r\n * fill: Fills.image('bg.jpg', { filters: Adjustments.oilPaint(4) }),\r\n * children: [Text({ text: \"still sharp\" })],\r\n * })\r\n *\r\n * The effects carry a `mode` field that means nothing here (a fill has no\r\n * backdrop); the {@link VideoAdjustmentChain} builders drop it, and the renderer ignores\r\n * it on this path.\r\n */\r\nexport type EffectAdjustment = Exclude<NodeEffect, NonFilterEffect>;\r\n\r\n/**\r\n * Discriminated union of pixel filters — the filters valid on both image and\r\n * video fills. Each is realised either as a single CanvasKit image filter\r\n * applied via `paint.setImageFilter`, or — for the ones that resample pixel\r\n * *positions* — as a lens shader wrapping the fill's own shader.\r\n */\r\nexport type MediaAdjustment =\r\n | ExposureFilter\r\n | BlurFilter\r\n | GrayscaleFilter\r\n | AlphaFilter\r\n | ColorMatrixFilter\r\n | CurvesFilter\r\n | ColorAdjustmentFilter\r\n | EffectAdjustment;\r\n\r\n/**\r\n * Discriminated union of video-only filters — temporal/multi-frame effects that\r\n * are meaningless on a still image (a single frame has no time axis and no\r\n * previous frames). Consumed outside the pixel `setImageFilter` path.\r\n */\r\nexport type VideoOnlyAdjustment =\r\n | PosterizeTimeFilter\r\n | VideoEchoFilter;\r\n"]}
1
+ {"version":3,"file":"union.js","sourceRoot":"","sources":["../../../../src/attributes/shape/filters/union.ts"],"names":[],"mappings":"","sourcesContent":["import type { AlphaFilter } from \"./implementations/alpha\";\r\nimport type { BlurFilter } from \"./implementations/blur\";\r\nimport type { ColorAdjustmentFilter } from \"./implementations/color-adjustment\";\r\nimport type { ColorMatrixFilter } from \"./implementations/color-matrix\";\r\nimport type { CurvesFilter } from \"./implementations/curves\";\r\nimport type { ExposureFilter } from \"./implementations/exposure\";\r\nimport type { GrayscaleFilter } from \"./implementations/grayscale\";\r\nimport type { PosterizeTimeFilter } from \"./implementations/posterize-time\";\r\nimport type { VideoEchoFilter } from \"./implementations/echo\";\r\n\r\nimport type { NodeEffect } from \"../effects/union\";\r\nimport type { BlurEffect } from \"../effects/implementations/blur\";\r\nimport type { GrayscaleEffect } from \"../effects/implementations/grayscale\";\r\nimport type { CurvesEffect } from \"../effects/implementations/curves\";\r\nimport type { ColorAdjustmentEffect } from \"../effects/implementations/color-adjustment\";\r\nimport type { MagnifyEffect } from \"../effects/implementations/magnify\";\r\nimport type { MotionBlurEffect } from \"../effects/implementations/motion-blur\";\r\nimport type { OutlineEffect } from \"../effects/implementations/outline\";\r\nimport type { DropShadowEffect } from \"@/attributes/shape/effects/implementations/drop-shadow\";\r\nimport type { GlowEffect } from \"../effects/implementations/glow\";\r\nimport type { GlassEffect } from \"../effects/implementations/glass\";\r\n\r\n/**\r\n * The node effects that are **not** media filters, and why.\r\n *\r\n * Everything else in {@link NodeEffect} is a function of the pixels it is\r\n * given, so it means exactly the same thing applied to a node's rendered\r\n * content or to one fill layer's own pixels — and the renderer already runs\r\n * both through a single handler registry. This is the exception list, so a new\r\n * effect becomes a filter by default rather than by remembering to add it.\r\n *\r\n * Two reasons land here:\r\n *\r\n * - **Needs something a fill layer doesn't have.** `magnify` and `glass` sample\r\n * the backdrop beneath the node — glass is a slab you see *through*, and a\r\n * node's own paint is not something there is anything behind; `motionBlur` and\r\n * `trails` are derived from the node's sampled velocity. A fill has no\r\n * backdrop and no motion of its own.\r\n * - **Draws outside the silhouette.** `outline` paints a ring around the\r\n * content, which the shape path a fill is clipped to would cut away, and\r\n * `glow` bleeds past it in every direction — a glow clipped to the thing that\r\n * cast it is not a dimmer glow, it is no glow at all. (`bloom` stays: it is\r\n * the contained version of the same idea, which is what makes it the right\r\n * one to reach for on a fill.)\r\n *\r\n * `blur`, `grayscale`, `curves` and `colorAdjustment` are excluded for a third,\r\n * bookkeeping reason: they already have a dedicated filter type below, sharing\r\n * the same fields and the same renderer handler.\r\n */\r\ntype NonFilterEffect =\r\n | MagnifyEffect\r\n | GlassEffect\r\n | MotionBlurEffect\r\n | OutlineEffect\r\n | DropShadowEffect\r\n | GlowEffect\r\n | BlurEffect\r\n | GrayscaleEffect\r\n | CurvesEffect\r\n | ColorAdjustmentEffect;\r\n\r\n/**\r\n * Node effects usable as a media filter — i.e. applied to one image/video\r\n * fill's own pixels rather than to a node and everything under it.\r\n *\r\n * This is what lets a background image be oil-painted, dithered or posterized\r\n * without wrapping it in a node whose effect would also hit its children:\r\n *\r\n * Rect({\r\n * fill: Fills.image('bg.jpg', { filters: Adjustments.oilPaint(4) }),\r\n * children: [Text({ text: \"still sharp\" })],\r\n * })\r\n *\r\n * The effects carry a `mode` field that means nothing here (a fill has no\r\n * backdrop); the {@link VideoAdjustmentChain} builders drop it, and the renderer ignores\r\n * it on this path.\r\n */\r\nexport type EffectAdjustment = Exclude<NodeEffect, NonFilterEffect>;\r\n\r\n/**\r\n * Discriminated union of pixel filters — the filters valid on both image and\r\n * video fills. Each is realised either as a per-pixel colour filter, or — for\r\n * the ones that resample pixel *positions* — as a lens pass over the fill.\r\n */\r\nexport type MediaAdjustment =\r\n | ExposureFilter\r\n | BlurFilter\r\n | GrayscaleFilter\r\n | AlphaFilter\r\n | ColorMatrixFilter\r\n | CurvesFilter\r\n | ColorAdjustmentFilter\r\n | EffectAdjustment;\r\n\r\n/**\r\n * Discriminated union of video-only filters — temporal/multi-frame effects that\r\n * are meaningless on a still image (a single frame has no time axis and no\r\n * previous frames). Consumed outside the pixel `setImageFilter` path.\r\n */\r\nexport type VideoOnlyAdjustment =\r\n | PosterizeTimeFilter\r\n | VideoEchoFilter;\r\n"]}
@@ -1,3 +1,5 @@
1
+ export * from "./language.js";
1
2
  export * from "./pack.js";
2
3
  export * from "./resolve.js";
4
+ export * from "./uniforms.js";
3
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/attributes/shape/shaders/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/attributes/shape/shaders/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC"}
@@ -1,3 +1,5 @@
1
+ export * from "./language.js";
1
2
  export * from "./pack.js";
2
3
  export * from "./resolve.js";
4
+ export * from "./uniforms.js";
3
5
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/attributes/shape/shaders/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC","sourcesContent":["export * from \"./pack\";\r\nexport * from \"./resolve\";\r\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/attributes/shape/shaders/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC","sourcesContent":["export * from \"./language\";\r\nexport * from \"./pack\";\r\nexport * from \"./resolve\";\r\nexport * from \"./uniforms\";\r\n"]}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * The language a custom shader is written in: WGSL, the only one the renderer
3
+ * runs. A fill defines `fn fill(in: FillIn) -> vec4f`, an effect
4
+ * `fn effect(in: EffectIn) -> vec4f`; uniforms are the members of
5
+ * `struct Params`, read as `u.<name>`.
6
+ */
7
+ export type ShaderLanguage = "wgsl";
8
+ /** Whether a shader fill, shader effect or shader pack is WGSL: its `language` is absent or `"wgsl"`. */
9
+ export declare function isWgslShader(shader: {
10
+ language?: string;
11
+ }): boolean;
12
+ /**
13
+ * The version of the WGSL contract a shader is written against: `FillIn` /
14
+ * `EffectIn`, the helpers, and uniforms bound to `struct Params` by name
15
+ * (packages/renderer/DESIGN.md §6.3). Bumped only by a change that would draw
16
+ * an existing shader differently. A WGSL fill or effect resolves with
17
+ * `contract` set (stamped with this when absent), so a stored document says
18
+ * what it was written for and a renderer can tell a newer one apart.
19
+ */
20
+ export declare const WGSL_CONTRACT = 1;
21
+ /** The contract a shader states, or the current one for a WGSL shader that states none; `undefined` for any other language. */
22
+ export declare function shaderContractOf(shader: {
23
+ language?: string;
24
+ contract?: number;
25
+ }): number | undefined;
26
+ //# sourceMappingURL=language.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"language.d.ts","sourceRoot":"","sources":["../../../../src/attributes/shape/shaders/language.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC;AAEpC,yGAAyG;AACzG,wBAAgB,YAAY,CAAC,MAAM,EAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAEnE;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,IAAI,CAAC;AAE/B,+HAA+H;AAC/H,wBAAgB,gBAAgB,CAAC,MAAM,EAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,GAAG,SAAS,CAGrG"}
@@ -0,0 +1,20 @@
1
+ /** Whether a shader fill, shader effect or shader pack is WGSL: its `language` is absent or `"wgsl"`. */
2
+ export function isWgslShader(shader) {
3
+ return shader.language === undefined || shader.language === "wgsl";
4
+ }
5
+ /**
6
+ * The version of the WGSL contract a shader is written against: `FillIn` /
7
+ * `EffectIn`, the helpers, and uniforms bound to `struct Params` by name
8
+ * (packages/renderer/DESIGN.md §6.3). Bumped only by a change that would draw
9
+ * an existing shader differently. A WGSL fill or effect resolves with
10
+ * `contract` set (stamped with this when absent), so a stored document says
11
+ * what it was written for and a renderer can tell a newer one apart.
12
+ */
13
+ export const WGSL_CONTRACT = 1;
14
+ /** The contract a shader states, or the current one for a WGSL shader that states none; `undefined` for any other language. */
15
+ export function shaderContractOf(shader) {
16
+ if (!isWgslShader(shader))
17
+ return undefined;
18
+ return shader.contract ?? WGSL_CONTRACT;
19
+ }
20
+ //# sourceMappingURL=language.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"language.js","sourceRoot":"","sources":["../../../../src/attributes/shape/shaders/language.ts"],"names":[],"mappings":"AAQA,yGAAyG;AACzG,MAAM,UAAU,YAAY,CAAC,MAA6B;IACtD,OAAO,MAAM,CAAC,QAAQ,KAAK,SAAS,IAAI,MAAM,CAAC,QAAQ,KAAK,MAAM,CAAC;AACvE,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC;AAE/B,+HAA+H;AAC/H,MAAM,UAAU,gBAAgB,CAAC,MAAgD;IAC7E,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC;QAAE,OAAO,SAAS,CAAC;IAC5C,OAAO,MAAM,CAAC,QAAQ,IAAI,aAAa,CAAC;AAC5C,CAAC","sourcesContent":["/**\r\n * The language a custom shader is written in: WGSL, the only one the renderer\r\n * runs. A fill defines `fn fill(in: FillIn) -> vec4f`, an effect\r\n * `fn effect(in: EffectIn) -> vec4f`; uniforms are the members of\r\n * `struct Params`, read as `u.<name>`.\r\n */\r\nexport type ShaderLanguage = \"wgsl\";\r\n\r\n/** Whether a shader fill, shader effect or shader pack is WGSL: its `language` is absent or `\"wgsl\"`. */\r\nexport function isWgslShader(shader: { language?: string }): boolean {\r\n return shader.language === undefined || shader.language === \"wgsl\";\r\n}\r\n\r\n/**\r\n * The version of the WGSL contract a shader is written against: `FillIn` /\r\n * `EffectIn`, the helpers, and uniforms bound to `struct Params` by name\r\n * (packages/renderer/DESIGN.md §6.3). Bumped only by a change that would draw\r\n * an existing shader differently. A WGSL fill or effect resolves with\r\n * `contract` set (stamped with this when absent), so a stored document says\r\n * what it was written for and a renderer can tell a newer one apart.\r\n */\r\nexport const WGSL_CONTRACT = 1;\r\n\r\n/** The contract a shader states, or the current one for a WGSL shader that states none; `undefined` for any other language. */\r\nexport function shaderContractOf(shader: { language?: string; contract?: number }): number | undefined {\r\n if (!isWgslShader(shader)) return undefined;\r\n return shader.contract ?? WGSL_CONTRACT;\r\n}\r\n"]}
@@ -1,4 +1,5 @@
1
- import type { ShaderFillCoords, SkSLUniformRecord } from "../sksl-uniforms.js";
1
+ import type { ShaderUniformRecord } from "./uniforms.js";
2
+ import type { ShaderLanguage } from "./language.js";
2
3
  /**
3
4
  * A **shader pack**: a program, plus what a host may edit about it.
4
5
  *
@@ -9,9 +10,9 @@ import type { ShaderFillCoords, SkSLUniformRecord } from "../sksl-uniforms.js";
9
10
  * to offer a slider had to keep that table itself, beside a program it did not
10
11
  * own.
11
12
  *
12
- * **Two scopes, one shape.** A fill paints inside a shape's path and takes a
13
- * `coords` matrix; an effect paints over a layer and may sample what is beneath
14
- * it. Those are the only two differences, and making them arms of a union rather
13
+ * **Two scopes, one shape.** A fill paints inside a shape's path and may sample
14
+ * textures; an effect paints over a layer and may sample what is beneath it.
15
+ * Those are the only two differences, and making them arms of a union rather
15
16
  * than optional fields on one type is what makes `Fills.shader(anEffectShader)`
16
17
  * a compile error instead of a program that fails at the first frame.
17
18
  */
@@ -32,25 +33,38 @@ export interface ShaderBase {
32
33
  id?: string;
33
34
  name: string;
34
35
  description?: string;
35
- /** SkSL source. */
36
+ /** The language `source` is written in; normalising a pack stamps WGSL when absent. */
37
+ language?: ShaderLanguage;
38
+ /**
39
+ * The program. In WGSL, a fill defines `fn fill(in: FillIn) -> vec4f` and an
40
+ * effect `fn effect(in: EffectIn) -> vec4f`, and the uniforms are the
41
+ * members of `struct Params` (types, layout and all); `properties` name
42
+ * those members in their `inputs`.
43
+ */
36
44
  source: string;
37
45
  /** Uniform values the properties do not cover, by name. */
38
- uniforms?: SkSLUniformRecord;
46
+ uniforms?: ShaderUniformRecord;
39
47
  /** The editable values, by property id. */
40
48
  properties: Record<string, ShaderProperty>;
41
49
  }
42
50
  /** A shader that paints inside a shape's path. */
43
51
  export interface FillShader extends ShaderBase {
44
52
  scope: "fill";
45
- /** How the shape's box maps onto the coordinates `main` receives. */
46
- coords?: ShaderFillCoords;
53
+ /**
54
+ * The images the program samples, by name. In WGSL, `sample_texture(uv)`
55
+ * samples the first; the fill that applies the pack supplies each `src`.
56
+ */
57
+ textures?: readonly {
58
+ name: string;
59
+ description?: string;
60
+ }[];
47
61
  }
48
62
  /** A shader that paints over a layer. */
49
63
  export interface EffectShader extends ShaderBase {
50
64
  scope: "effect";
51
65
  /**
52
- * Whether the source declares `uniform shader u_backdrop` and so has to run
53
- * on the backdrop path.
66
+ * Whether the program is meant to run on the backdrop path, where
67
+ * `sample_src` reads what is beneath the node rather than its own layer.
54
68
  *
55
69
  * A fact about the **program**, which is why it lives here rather than on
56
70
  * the effect instance: the instance keeps `mode`, the cross-cutting field
@@ -102,7 +116,7 @@ export interface HueProperty extends ShaderPropertyBase {
102
116
  kind: "hue";
103
117
  default: number;
104
118
  }
105
- /** Written to its uniform as 1 or 0 — SkSL has no bool uniform worth relying on. */
119
+ /** Written to its uniform as 1 or 0, since a `bool` cannot be a uniform member in WGSL. */
106
120
  export interface BooleanProperty extends ShaderPropertyBase {
107
121
  kind: "boolean";
108
122
  default: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"pack.d.ts","sourceRoot":"","sources":["../../../../src/attributes/shape/shaders/pack.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAE5E;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,MAAM,GAAG,UAAU,GAAG,YAAY,CAAC;AAE/C,8BAA8B;AAC9B,MAAM,WAAW,UAAU;IACvB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;;OAKG;IACH,EAAE,C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Ac,SAAQ,kBAAkB;IACrD,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAAC;CACvC;AAED,mCAAmC;AACnC,MAAM,WAAW,cAAe,SAAQ,kBAAkB;IACtD,IAAI,EAAE,QAAQ,CAAC;IACf,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;CAC9B;AAED,mEAAmE;AACnE,MAAM,WAAW,aAAc,SAAQ,kBAAkB;IACrD,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,SAAS,MAAM,EAAE,GAAG;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CACzD;AAED;;;;;;;;;;GAUG;AACH,MAAM,WAAW,qBAAsB,SAAQ,kBAAkB;IAC7D,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;CAC7B;AAMD,gEAAgE;AAChE,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,cAAc,GAAG,QAAQ,IAAI,mBAAmB,CAE/F;AAED,sFAAsF;AACtF,eAAO,MAAM,qBAAqB,KAAK,CAAC;AAExC,mFAAmF;AACnF,eAAO,MAAM,iBAAiB,QAAS,CAAC;AAExC;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAsD1D"}
@@ -37,23 +37,28 @@ export function normalizeShaderPack(input) {
37
37
  throw new Error(`Shader pack "${String(raw.name ?? "?")}" source is ${source.length} characters, ` +
38
38
  `over the ${MAX_SHADER_SOURCE} ceiling.`);
39
39
  }
40
+ if (raw.language !== undefined && raw.language !== "wgsl") {
41
+ throw new Error(`Shader pack "${String(raw.name ?? "?")}" is written in ${JSON.stringify(raw.language)}; ` +
42
+ `only WGSL is supported. Port it to WGSL.`);
43
+ }
40
44
  const base = {
41
45
  ...(typeof raw.$kind === "string" ? { $kind: raw.$kind } : {}),
42
46
  ...(typeof raw.id === "string" ? { id: raw.id } : {}),
43
47
  name: typeof raw.name === "string" && raw.name !== "" ? raw.name : "Shader",
44
48
  ...(typeof raw.description === "string" ? { description: raw.description } : {}),
49
+ language: "wgsl",
45
50
  source,
46
51
  ...(isRecord(raw.uniforms) ? { uniforms: raw.uniforms } : {}),
47
52
  properties: normalizeProperties(raw.properties, String(raw.name ?? "?")),
48
53
  };
49
54
  if (scope === "fill") {
50
- const coords = raw.coords;
55
+ const textures = Array.isArray(raw.textures)
56
+ ? raw.textures.filter((t) => isRecord(t) && typeof t.name === "string").map((t) => ({ name: t.name, ...(typeof t.description === "string" ? { description: t.description } : {}) }))
57
+ : [];
51
58
  return {
52
59
  ...base,
53
60
  scope: "fill",
54
- ...(coords === "normalized" || coords === "centered" || coords === "local"
55
- ? { coords }
56
- : {}),
61
+ ...(textures.length ? { textures } : {}),
57
62
  };
58
63
  }
59
64
  return { ...base, scope: "effect", ...(raw.backdrop === true ? { backdrop: true } : {}) };
@@ -1 +1 @@
1
- {"version":3,"file":"pack.js","sourceRoot":"","sources":["../../../../src/attributes/shape/shaders/pack.ts"],"names":[],"mappings":"AAqKA,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC;IACxB,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO;CAC5E,CAAC,CAAC;AAEH,gEAAgE;AAChE,MAAM,UAAU,qBAAqB,CAAC,QAAwB;IAC1D,OAAO,WAAW,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AAC1C,CAAC;AAED,sFAAsF;AACtF,MAAM,CAAC,MAAM,qBAAqB,GAAG,EAAE,CAAC;AAExC,mFAAmF;AACnF,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC;AAExC;;;;;;;;;GASG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAAc;IA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gBACpE,IAAI,CAAC,WAAW,KAAK,iBAAiB,KAAK,UAAU,EAAE,yBAAyB,OAAO,OAAO,EAAE,YAAY,CAAC,CAAC;gBAC9G,QAAQ,GAAG,IAAI,CAAC;gBAChB,MAAM;YACV,CAAC;YACD,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;QAC7B,CAAC;QACD,IAAI,QAAQ;YAAE,SAAS;QAEvB,GAAG,CAAC,EAAE,CAAC,GAAG,KAAkC,CAAC;IACjD,CAAC;IACD,OAAO,GAAG,CAAC;AACf,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC5B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAChF,CAAC;AAED,MAAM,MAAM,GAAG,IAAI,GAAG,EAAU,CAAC;AAEjC,6EAA6E;AAC7E,SAAS,IAAI,CAAC,OAAe;IACzB,IAAI,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC;QAAE,OAAO;IAChC,IAAI,MAAM,CAAC,IAAI,GAAG,GAAG;QAAE,MAAM,CAAC,KAAK,EAAE,CAAC;IACtC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACpB,OAAO,CAAC,IAAI,CAAC,YAAY,OAAO,EAAE,CAAC,CAAC;AACxC,CAAC","sourcesContent":["import type { ShaderFillCoords, SkSLUniformRecord } from \"../sksl-uniforms\";\r\n\r\n/**\r\n * A **shader pack**: a program, plus what a host may edit about it.\r\n *\r\n * The interchange format for a shader — authored as JSON, imported as a value,\r\n * handed to `Fills.shader` or `Effects.shader`. It exists because a bare source\r\n * string says nothing about which of its uniforms are meant to be touched, what\r\n * they are called in a panel, or what range they take, so every host that wanted\r\n * to offer a slider had to keep that table itself, beside a program it did not\r\n * own.\r\n *\r\n * **Two scopes, one shape.** A fill paints inside a shape's path and takes a\r\n * `coords` matrix; an effect paints over a layer and may sample what is beneath\r\n * it. Those are the only two differences, and making them arms of a union rather\r\n * than optional fields on one type is what makes `Fills.shader(anEffectShader)`\r\n * a compile error instead of a program that fails at the first frame.\r\n */\r\nexport type Shader = FillShader | EffectShader;\r\n\r\n/** What both scopes carry. */\r\nexport interface ShaderBase {\r\n /**\r\n * Format tag, so a file that is not one of these can be told apart from one\r\n * that is merely from a newer version.\r\n */\r\n $kind?: string;\r\n /**\r\n * Provenance, when the pack came from a library row. **Not** how it is\r\n * registered — `Registry.addShader` takes the key separately, exactly as\r\n * `Registry.addNode` does, so the same file can be registered under whatever\r\n * name a project wants and the file itself stays portable.\r\n */\r\n id?: string;\r\n name: string;\r\n description?: string;\r\n /** SkSL source. */\r\n source: string;\r\n /** Uniform values the properties do not cover, by name. */\r\n uniforms?: SkSLUniformRecord;\r\n /** The editable values, by property id. */\r\n properties: Record<string, ShaderProperty>;\r\n}\r\n\r\n/** A shader that paints inside a shape's path. */\r\nexport interface FillShader extends ShaderBase {\r\n scope: \"fill\";\r\n /** How the shape's box maps onto the coordinates `main` receives. */\r\n coords?: ShaderFillCoords;\r\n}\r\n\r\n/** A shader that paints over a layer. */\r\nexport interface EffectShader extends ShaderBase {\r\n scope: \"effect\";\r\n /**\r\n * Whether the source declares `uniform shader u_backdrop` and so has to run\r\n * on the backdrop path.\r\n *\r\n * A fact about the **program**, which is why it lives here rather than on\r\n * the effect instance: the instance keeps `mode`, the cross-cutting field\r\n * five generic consumers read without knowing what type they hold. The\r\n * builder maps this to `mode: \"backdrop\"` as the default and a caller may\r\n * still override it.\r\n */\r\n backdrop?: boolean;\r\n}\r\n\r\n/** One editable value. */\r\nexport type ShaderProperty = KnownShaderProperty | UnknownShaderProperty;\r\n\r\nexport type KnownShaderProperty =\r\n | NumberProperty\r\n | SliderProperty\r\n | AngleProperty\r\n | HueProperty\r\n | BooleanProperty\r\n | ColorProperty\r\n | VectorProperty\r\n | PointProperty;\r\n\r\ninterface ShaderPropertyBase {\r\n /** What a panel calls it. Falls back to the property id. */\r\n name?: string;\r\n /**\r\n * The uniform each of this property's components writes.\r\n *\r\n * The composite mechanism, and the reason a property is not just a uniform\r\n * under another name: one editable value may span several uniforms. A\r\n * scalar names one component, `value`; a point may name `value` for a\r\n * `float2`, or `x` and `y` for two separate floats.\r\n */\r\n inputs: Record<string, string>;\r\n}\r\n\r\n/** A scalar, drawn as a number input. */\r\nexport interface NumberProperty extends ShaderPropertyBase {\r\n kind: \"number\";\r\n default: number;\r\n min?: number;\r\n max?: number;\r\n step?: number;\r\n}\r\n\r\n/** A scalar with a bounded range, drawn as a slider. */\r\nexport interface SliderProperty extends ShaderPropertyBase {\r\n kind: \"slider\";\r\n default: number;\r\n min: number;\r\n max: number;\r\n step?: number;\r\n}\r\n\r\n/** Degrees, matching every other angle in the library. */\r\nexport interface AngleProperty extends ShaderPropertyBase {\r\n kind: \"angle\";\r\n default: number;\r\n}\r\n\r\n/** Degrees around the colour wheel. */\r\nexport interface HueProperty extends ShaderPropertyBase {\r\n kind: \"hue\";\r\n default: number;\r\n}\r\n\r\n/** Written to its uniform as 1 or 0 — SkSL has no bool uniform worth relying on. */\r\nexport interface BooleanProperty extends ShaderPropertyBase {\r\n kind: \"boolean\";\r\n default: boolean;\r\n}\r\n\r\n/** RGBA in 0–1. A CSS string is accepted and parsed, so theme tokens work. */\r\nexport interface ColorProperty extends ShaderPropertyBase {\r\n kind: \"color\";\r\n default: string | readonly number[];\r\n}\r\n\r\n/** A fixed-width run of floats. */\r\nexport interface VectorProperty extends ShaderPropertyBase {\r\n kind: \"vector\";\r\n default: readonly number[];\r\n}\r\n\r\n/** Two floats, as one `float2` or as separate `x`/`y` uniforms. */\r\nexport interface PointProperty extends ShaderPropertyBase {\r\n kind: \"point\";\r\n default: readonly number[] | { x: number; y: number };\r\n}\r\n\r\n/**\r\n * A property whose kind this version of the vocabulary does not name.\r\n *\r\n * Open at the edges on purpose: a pack written against a newer version should\r\n * draw the controls a host knows and say so about the rest, instead of\r\n * failing to load at all.\r\n *\r\n * An unknown property is still *resolved* — its `default` is written to its\r\n * `inputs` unchanged — so a shader whose panel a host cannot fully draw still\r\n * renders correctly.\r\n */\r\nexport interface UnknownShaderProperty extends ShaderPropertyBase {\r\n kind: string;\r\n default?: unknown;\r\n [option: string]: unknown;\r\n}\r\n\r\nconst KNOWN_KINDS = new Set([\r\n \"number\", \"slider\", \"angle\", \"hue\", \"boolean\", \"color\", \"vector\", \"point\",\r\n]);\r\n\r\n/** Whether `property` is one this version knows how to draw. */\r\nexport function isKnownShaderProperty(property: ShaderProperty): property is KnownShaderProperty {\r\n return KNOWN_KINDS.has(property.kind);\r\n}\r\n\r\n/** Ceiling on properties in one pack, so a malformed import cannot exhaust a host. */\r\nexport const MAX_SHADER_PROPERTIES = 64;\r\n\r\n/** Ceiling on source length, matching what a compile cache can reasonably hold. */\r\nexport const MAX_SHADER_SOURCE = 64_000;\r\n\r\n/**\r\n * Validate and normalise an authored pack.\r\n *\r\n * **Throws** when the pack is structurally not one — no source, no usable\r\n * scope — because there is nothing to render and a silent empty shader is a\r\n * blank frame with no explanation. **Warns and drops** an individual malformed\r\n * property, because the rest of the shader still works and a panel missing one\r\n * control is a better answer than a scene that will not build. That split is the\r\n * same one `normalizeUniforms` makes.\r\n */\r\nexport function normalizeShaderPack(input: unknown): Shader {\r\n if (typeof input !== \"object\" || input === null) {\r\n throw new Error(\"A shader pack must be an object.\");\r\n }\r\n const raw = input as Record<string, unknown>;\r\n\r\n const scope = raw.scope;\r\n if (scope !== \"fill\" && scope !== \"effect\") {\r\n throw new Error(\r\n `A shader pack needs scope \"fill\" or \"effect\", got ${JSON.stringify(scope)}. ` +\r\n `The two are written against different contracts — a fill has no backdrop to ` +\r\n `sample and an effect has no shape box to map coordinates onto.`,\r\n );\r\n }\r\n\r\n const source = typeof raw.source === \"string\" ? raw.source.trim() : \"\";\r\n if (source === \"\") throw new Error(`Shader pack \"${String(raw.name ?? \"?\")}\" has no source.`);\r\n if (source.length > MAX_SHADER_SOURCE) {\r\n throw new Error(\r\n `Shader pack \"${String(raw.name ?? \"?\")}\" source is ${source.length} characters, ` +\r\n `over the ${MAX_SHADER_SOURCE} ceiling.`,\r\n );\r\n }\r\n\r\n const base: ShaderBase = {\r\n ...(typeof raw.$kind === \"string\" ? { $kind: raw.$kind } : {}),\r\n ...(typeof raw.id === \"string\" ? { id: raw.id } : {}),\r\n name: typeof raw.name === \"string\" && raw.name !== \"\" ? raw.name : \"Shader\",\r\n ...(typeof raw.description === \"string\" ? { description: raw.description } : {}),\r\n source,\r\n ...(isRecord(raw.uniforms) ? { uniforms: raw.uniforms as SkSLUniformRecord } : {}),\r\n properties: normalizeProperties(raw.properties, String(raw.name ?? \"?\")),\r\n };\r\n\r\n if (scope === \"fill\") {\r\n const coords = raw.coords;\r\n return {\r\n ...base,\r\n scope: \"fill\",\r\n ...(coords === \"normalized\" || coords === \"centered\" || coords === \"local\"\r\n ? { coords }\r\n : {}),\r\n };\r\n }\r\n return { ...base, scope: \"effect\", ...(raw.backdrop === true ? { backdrop: true } : {}) };\r\n}\r\n\r\nfunction normalizeProperties(input: unknown, where: string): Record<string, ShaderProperty> {\r\n if (!isRecord(input)) return {};\r\n const out: Record<string, ShaderProperty> = {};\r\n const claimed = new Map<string, string>();\r\n\r\n for (const [id, value] of Object.entries(input)) {\r\n if (Object.keys(out).length >= MAX_SHADER_PROPERTIES) {\r\n warn(`shader \"${where}\" declares more than ${MAX_SHADER_PROPERTIES} properties; the rest are ignored.`);\r\n break;\r\n }\r\n if (!isRecord(value) || typeof value.kind !== \"string\") {\r\n warn(`shader \"${where}\" property \"${id}\" has no kind; ignored.`);\r\n continue;\r\n }\r\n const inputs = value.inputs;\r\n if (!isRecord(inputs) || Object.keys(inputs).length === 0) {\r\n warn(`shader \"${where}\" property \"${id}\" names no uniform in \"inputs\"; ignored.`);\r\n continue;\r\n }\r\n let conflict = false;\r\n for (const uniform of Object.values(inputs)) {\r\n if (typeof uniform !== \"string\") {\r\n warn(`shader \"${where}\" property \"${id}\" has a non-string uniform name; ignored.`);\r\n conflict = true;\r\n break;\r\n }\r\n const prior = claimed.get(uniform);\r\n if (prior !== undefined) {\r\n // Two properties writing one uniform means the panel has two\r\n // controls for one value and whichever resolves last silently wins.\r\n warn(`shader \"${where}\" properties \"${prior}\" and \"${id}\" both write uniform \"${uniform}\"; \"${id}\" ignored.`);\r\n conflict = true;\r\n break;\r\n }\r\n claimed.set(uniform, id);\r\n }\r\n if (conflict) continue;\r\n\r\n out[id] = value as unknown as ShaderProperty;\r\n }\r\n return out;\r\n}\r\n\r\nfunction isRecord(value: unknown): value is Record<string, unknown> {\r\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\r\n}\r\n\r\nconst warned = new Set<string>();\r\n\r\n/** Warn once per message — a pack may be normalised on every scene build. */\r\nfunction warn(message: string): void {\r\n if (warned.has(message)) return;\r\n if (warned.size > 256) warned.clear();\r\n warned.add(message);\r\n console.warn(`[shader] ${message}`);\r\n}\r\n"]}
1
+ {"version":3,"file":"pack.js","sourceRoot":"","sources":["../../../../src/attributes/shape/shaders/pack.ts"],"names":[],"mappings":"AAgLA,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC;IACxB,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO;CAC5E,CAAC,CAAC;AAEH,gEAAgE;AAChE,MAAM,UAAU,qBAAqB,CAAC,QAAwB;IAC1D,OAAO,WAAW,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AAC1C,CAAC;AAED,sFAAsF;AACtF,MAAM,CAAC,MAAM,qBAAqB,GAAG,EAAE,CAAC;AAExC,mFAAmF;AACnF,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC;AAExC;;;;;;;;;GASG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAAc;IAC9C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CA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6EAA6E;AAC7E,SAAS,IAAI,CAAC,OAAe;IACzB,IAAI,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC;QAAE,OAAO;IAChC,IAAI,MAAM,CAAC,IAAI,GAAG,GAAG;QAAE,MAAM,CAAC,KAAK,EAAE,CAAC;IACtC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACpB,OAAO,CAAC,IAAI,CAAC,YAAY,OAAO,EAAE,CAAC,CAAC;AACxC,CAAC","sourcesContent":["import type { ShaderUniformRecord } from \"./uniforms\";\r\nimport type { ShaderLanguage } from \"./language\";\r\n\r\n/**\r\n * A **shader pack**: a program, plus what a host may edit about it.\r\n *\r\n * The interchange format for a shader — authored as JSON, imported as a value,\r\n * handed to `Fills.shader` or `Effects.shader`. It exists because a bare source\r\n * string says nothing about which of its uniforms are meant to be touched, what\r\n * they are called in a panel, or what range they take, so every host that wanted\r\n * to offer a slider had to keep that table itself, beside a program it did not\r\n * own.\r\n *\r\n * **Two scopes, one shape.** A fill paints inside a shape's path and may sample\r\n * textures; an effect paints over a layer and may sample what is beneath it.\r\n * Those are the only two differences, and making them arms of a union rather\r\n * than optional fields on one type is what makes `Fills.shader(anEffectShader)`\r\n * a compile error instead of a program that fails at the first frame.\r\n */\r\nexport type Shader = FillShader | EffectShader;\r\n\r\n/** What both scopes carry. */\r\nexport interface ShaderBase {\r\n /**\r\n * Format tag, so a file that is not one of these can be told apart from one\r\n * that is merely from a newer version.\r\n */\r\n $kind?: string;\r\n /**\r\n * Provenance, when the pack came from a library row. **Not** how it is\r\n * registered — `Registry.addShader` takes the key separately, exactly as\r\n * `Registry.addNode` does, so the same file can be registered under whatever\r\n * name a project wants and the file itself stays portable.\r\n */\r\n id?: string;\r\n name: string;\r\n description?: string;\r\n /** The language `source` is written in; normalising a pack stamps WGSL when absent. */\r\n language?: ShaderLanguage;\r\n /**\r\n * The program. In WGSL, a fill defines `fn fill(in: FillIn) -> vec4f` and an\r\n * effect `fn effect(in: EffectIn) -> vec4f`, and the uniforms are the\r\n * members of `struct Params` (types, layout and all); `properties` name\r\n * those members in their `inputs`.\r\n */\r\n source: string;\r\n /** Uniform values the properties do not cover, by name. */\r\n uniforms?: ShaderUniformRecord;\r\n /** The editable values, by property id. */\r\n properties: Record<string, ShaderProperty>;\r\n}\r\n\r\n/** A shader that paints inside a shape's path. */\r\nexport interface FillShader extends ShaderBase {\r\n scope: \"fill\";\r\n /**\r\n * The images the program samples, by name. In WGSL, `sample_texture(uv)`\r\n * samples the first; the fill that applies the pack supplies each `src`.\r\n */\r\n textures?: readonly { name: string; description?: string }[];\r\n}\r\n\r\n/** A shader that paints over a layer. */\r\nexport interface EffectShader extends ShaderBase {\r\n scope: \"effect\";\r\n /**\r\n * Whether the program is meant to run on the backdrop path, where\r\n * `sample_src` reads what is beneath the node rather than its own layer.\r\n *\r\n * A fact about the **program**, which is why it lives here rather than on\r\n * the effect instance: the instance keeps `mode`, the cross-cutting field\r\n * five generic consumers read without knowing what type they hold. The\r\n * builder maps this to `mode: \"backdrop\"` as the default and a caller may\r\n * still override it.\r\n */\r\n backdrop?: boolean;\r\n}\r\n\r\n/** One editable value. */\r\nexport type ShaderProperty = KnownShaderProperty | UnknownShaderProperty;\r\n\r\nexport type KnownShaderProperty =\r\n | NumberProperty\r\n | SliderProperty\r\n | AngleProperty\r\n | HueProperty\r\n | BooleanProperty\r\n | ColorProperty\r\n | VectorProperty\r\n | PointProperty;\r\n\r\ninterface ShaderPropertyBase {\r\n /** What a panel calls it. Falls back to the property id. */\r\n name?: string;\r\n /**\r\n * The uniform each of this property's components writes.\r\n *\r\n * The composite mechanism, and the reason a property is not just a uniform\r\n * under another name: one editable value may span several uniforms. A\r\n * scalar names one component, `value`; a point may name `value` for a\r\n * `float2`, or `x` and `y` for two separate floats.\r\n */\r\n inputs: Record<string, string>;\r\n}\r\n\r\n/** A scalar, drawn as a number input. */\r\nexport interface NumberProperty extends ShaderPropertyBase {\r\n kind: \"number\";\r\n default: number;\r\n min?: number;\r\n max?: number;\r\n step?: number;\r\n}\r\n\r\n/** A scalar with a bounded range, drawn as a slider. */\r\nexport interface SliderProperty extends ShaderPropertyBase {\r\n kind: \"slider\";\r\n default: number;\r\n min: number;\r\n max: number;\r\n step?: number;\r\n}\r\n\r\n/** Degrees, matching every other angle in the library. */\r\nexport interface AngleProperty extends ShaderPropertyBase {\r\n kind: \"angle\";\r\n default: number;\r\n}\r\n\r\n/** Degrees around the colour wheel. */\r\nexport interface HueProperty extends ShaderPropertyBase {\r\n kind: \"hue\";\r\n default: number;\r\n}\r\n\r\n/** Written to its uniform as 1 or 0, since a `bool` cannot be a uniform member in WGSL. */\r\nexport interface BooleanProperty extends ShaderPropertyBase {\r\n kind: \"boolean\";\r\n default: boolean;\r\n}\r\n\r\n/** RGBA in 0–1. A CSS string is accepted and parsed, so theme tokens work. */\r\nexport interface ColorProperty extends ShaderPropertyBase {\r\n kind: \"color\";\r\n default: string | readonly number[];\r\n}\r\n\r\n/** A fixed-width run of floats. */\r\nexport interface VectorProperty extends ShaderPropertyBase {\r\n kind: \"vector\";\r\n default: readonly number[];\r\n}\r\n\r\n/** Two floats, as one `float2` or as separate `x`/`y` uniforms. */\r\nexport interface PointProperty extends ShaderPropertyBase {\r\n kind: \"point\";\r\n default: readonly number[] | { x: number; y: number };\r\n}\r\n\r\n/**\r\n * A property whose kind this version of the vocabulary does not name.\r\n *\r\n * Open at the edges on purpose: a pack written against a newer version should\r\n * draw the controls a host knows and say so about the rest, instead of\r\n * failing to load at all.\r\n *\r\n * An unknown property is still *resolved* — its `default` is written to its\r\n * `inputs` unchanged — so a shader whose panel a host cannot fully draw still\r\n * renders correctly.\r\n */\r\nexport interface UnknownShaderProperty extends ShaderPropertyBase {\r\n kind: string;\r\n default?: unknown;\r\n [option: string]: unknown;\r\n}\r\n\r\nconst KNOWN_KINDS = new Set([\r\n \"number\", \"slider\", \"angle\", \"hue\", \"boolean\", \"color\", \"vector\", \"point\",\r\n]);\r\n\r\n/** Whether `property` is one this version knows how to draw. */\r\nexport function isKnownShaderProperty(property: ShaderProperty): property is KnownShaderProperty {\r\n return KNOWN_KINDS.has(property.kind);\r\n}\r\n\r\n/** Ceiling on properties in one pack, so a malformed import cannot exhaust a host. */\r\nexport const MAX_SHADER_PROPERTIES = 64;\r\n\r\n/** Ceiling on source length, matching what a compile cache can reasonably hold. */\r\nexport const MAX_SHADER_SOURCE = 64_000;\r\n\r\n/**\r\n * Validate and normalise an authored pack.\r\n *\r\n * **Throws** when the pack is structurally not one — no source, no usable\r\n * scope — because there is nothing to render and a silent empty shader is a\r\n * blank frame with no explanation. **Warns and drops** an individual malformed\r\n * property, because the rest of the shader still works and a panel missing one\r\n * control is a better answer than a scene that will not build. That split is the\r\n * same one `normalizeUniforms` makes.\r\n */\r\nexport function normalizeShaderPack(input: unknown): Shader {\r\n if (typeof input !== \"object\" || input === null) {\r\n throw new Error(\"A shader pack must be an object.\");\r\n }\r\n const raw = input as Record<string, unknown>;\r\n\r\n const scope = raw.scope;\r\n if (scope !== \"fill\" && scope !== \"effect\") {\r\n throw new Error(\r\n `A shader pack needs scope \"fill\" or \"effect\", got ${JSON.stringify(scope)}. ` +\r\n `The two are written against different contracts — a fill has no backdrop to ` +\r\n `sample and an effect has no shape box to map coordinates onto.`,\r\n );\r\n }\r\n\r\n const source = typeof raw.source === \"string\" ? raw.source.trim() : \"\";\r\n if (source === \"\") throw new Error(`Shader pack \"${String(raw.name ?? \"?\")}\" has no source.`);\r\n if (source.length > MAX_SHADER_SOURCE) {\r\n throw new Error(\r\n `Shader pack \"${String(raw.name ?? \"?\")}\" source is ${source.length} characters, ` +\r\n `over the ${MAX_SHADER_SOURCE} ceiling.`,\r\n );\r\n }\r\n\r\n if (raw.language !== undefined && raw.language !== \"wgsl\") {\r\n throw new Error(\r\n `Shader pack \"${String(raw.name ?? \"?\")}\" is written in ${JSON.stringify(raw.language)}; ` +\r\n `only WGSL is supported. Port it to WGSL.`,\r\n );\r\n }\r\n\r\n const base: ShaderBase = {\r\n ...(typeof raw.$kind === \"string\" ? { $kind: raw.$kind } : {}),\r\n ...(typeof raw.id === \"string\" ? { id: raw.id } : {}),\r\n name: typeof raw.name === \"string\" && raw.name !== \"\" ? raw.name : \"Shader\",\r\n ...(typeof raw.description === \"string\" ? { description: raw.description } : {}),\r\n language: \"wgsl\",\r\n source,\r\n ...(isRecord(raw.uniforms) ? { uniforms: raw.uniforms as ShaderUniformRecord } : {}),\r\n properties: normalizeProperties(raw.properties, String(raw.name ?? \"?\")),\r\n };\r\n\r\n if (scope === \"fill\") {\r\n const textures = Array.isArray(raw.textures)\r\n ? (raw.textures as unknown[]).filter((t): t is { name: string; description?: string } =>\r\n isRecord(t) && typeof t.name === \"string\").map((t) => ({ name: t.name, ...(typeof t.description === \"string\" ? { description: t.description } : {}) }))\r\n : [];\r\n return {\r\n ...base,\r\n scope: \"fill\",\r\n ...(textures.length ? { textures } : {}),\r\n };\r\n }\r\n return { ...base, scope: \"effect\", ...(raw.backdrop === true ? { backdrop: true } : {}) };\r\n}\r\n\r\nfunction normalizeProperties(input: unknown, where: string): Record<string, ShaderProperty> {\r\n if (!isRecord(input)) return {};\r\n const out: Record<string, ShaderProperty> = {};\r\n const claimed = new Map<string, string>();\r\n\r\n for (const [id, value] of Object.entries(input)) {\r\n if (Object.keys(out).length >= MAX_SHADER_PROPERTIES) {\r\n warn(`shader \"${where}\" declares more than ${MAX_SHADER_PROPERTIES} properties; the rest are ignored.`);\r\n break;\r\n }\r\n if (!isRecord(value) || typeof value.kind !== \"string\") {\r\n warn(`shader \"${where}\" property \"${id}\" has no kind; ignored.`);\r\n continue;\r\n }\r\n const inputs = value.inputs;\r\n if (!isRecord(inputs) || Object.keys(inputs).length === 0) {\r\n warn(`shader \"${where}\" property \"${id}\" names no uniform in \"inputs\"; ignored.`);\r\n continue;\r\n }\r\n let conflict = false;\r\n for (const uniform of Object.values(inputs)) {\r\n if (typeof uniform !== \"string\") {\r\n warn(`shader \"${where}\" property \"${id}\" has a non-string uniform name; ignored.`);\r\n conflict = true;\r\n break;\r\n }\r\n const prior = claimed.get(uniform);\r\n if (prior !== undefined) {\r\n // Two properties writing one uniform means the panel has two\r\n // controls for one value and whichever resolves last silently wins.\r\n warn(`shader \"${where}\" properties \"${prior}\" and \"${id}\" both write uniform \"${uniform}\"; \"${id}\" ignored.`);\r\n conflict = true;\r\n break;\r\n }\r\n claimed.set(uniform, id);\r\n }\r\n if (conflict) continue;\r\n\r\n out[id] = value as unknown as ShaderProperty;\r\n }\r\n return out;\r\n}\r\n\r\nfunction isRecord(value: unknown): value is Record<string, unknown> {\r\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\r\n}\r\n\r\nconst warned = new Set<string>();\r\n\r\n/** Warn once per message — a pack may be normalised on every scene build. */\r\nfunction warn(message: string): void {\r\n if (warned.has(message)) return;\r\n if (warned.size > 256) warned.clear();\r\n warned.add(message);\r\n console.warn(`[shader] ${message}`);\r\n}\r\n"]}
@@ -1,4 +1,4 @@
1
- import type { SkSLUniformRecord } from "../sksl-uniforms.js";
1
+ import type { ShaderUniformRecord } from "./uniforms.js";
2
2
  import type { Shader } from "./pack.js";
3
3
  /** Overrides for a pack's properties, by property id. */
4
4
  export type ShaderPropertyValues = Record<string, unknown>;
@@ -10,9 +10,8 @@ export type ShaderPropertyValues = Record<string, unknown>;
10
10
  * is where that value has to end up. One property may feed several uniforms —
11
11
  * see `ShaderPropertyBase.inputs` — which is why this cannot be a rename.
12
12
  *
13
- * The pack's own `uniforms` are merged in first and the properties win, matching
14
- * the precedence `writeUniforms` already uses for an author value over a
15
- * built-in: the more specific statement of the same value takes it.
13
+ * The pack's own `uniforms` are merged in first and the properties win: the
14
+ * more specific statement of the same value takes it.
16
15
  */
17
- export declare function resolveShaderProperties(pack: Shader, overrides?: ShaderPropertyValues): SkSLUniformRecord;
16
+ export declare function resolveShaderProperties(pack: Shader, overrides?: ShaderPropertyValues): ShaderUniformRecord;
18
17
  //# sourceMappingURL=resolve.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../../../src/attributes/shape/shaders/resolve.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAoB,MAAM,kBAAkB,CAAC;AAC5E,OAAO,KAAK,EAAE,MAAM,EAAkB,MAAM,QAAQ,CAAC;AAErD,yDAAyD;AACzD,MAAM,MAAM,oBAAoB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAM3D;;;;;;;;;;;GAWG;AACH,wBAAgB,uBAAuB,CACnC,IAAI,EAAE,MAAM,EACZ,SAAS,CAAC,EAAE,oBAAoB,GACjC,iBAAiB,CAyBnB"}
1
+ {"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../../../src/attributes/shape/shaders/resolve.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAsB,MAAM,YAAY,CAAC;AAC1E,OAAO,KAAK,EAAE,MAAM,EAAkB,MAAM,QAAQ,CAAC;AAErD,yDAAyD;AACzD,MAAM,MAAM,oBAAoB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAM3D;;;;;;;;;;GAUG;AACH,wBAAgB,uBAAuB,CACnC,IAAI,EAAE,MAAM,EACZ,SAAS,CAAC,EAAE,oBAAoB,GACjC,mBAAmB,CAyBrB"}
@@ -10,9 +10,8 @@ const COLOR_COMPONENTS = ["r", "g", "b", "a"];
10
10
  * is where that value has to end up. One property may feed several uniforms —
11
11
  * see `ShaderPropertyBase.inputs` — which is why this cannot be a rename.
12
12
  *
13
- * The pack's own `uniforms` are merged in first and the properties win, matching
14
- * the precedence `writeUniforms` already uses for an author value over a
15
- * built-in: the more specific statement of the same value takes it.
13
+ * The pack's own `uniforms` are merged in first and the properties win: the
14
+ * more specific statement of the same value takes it.
16
15
  */
17
16
  export function resolveShaderProperties(pack, overrides) {
18
17
  const out = { ...(pack.uniforms ?? {}) };
@@ -74,9 +73,7 @@ function toUniformValue(property, value, id, where) {
74
73
  case "angle":
75
74
  case "hue":
76
75
  return asFinite(value, id, where);
77
- // SkSL's `bool` uniform is not worth relying on across backends, and an
78
- // int uniform does not survive CanvasKit at all — see `writeUniforms`.
79
- // A float of 1 or 0 is what a shader can actually branch on.
76
+ // A `bool` cannot be a uniform member in WGSL; a float of 1 or 0 is what a shader can branch on.
80
77
  case "boolean":
81
78
  return value ? 1 : 0;
82
79
  case "color":
@@ -1 +1 @@
1
- {"version":3,"file":"resolve.js","sourceRoot":"","sources":["../../../../src/attributes/shape/shaders/resolve.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAOlD,8EAA8E;AAC9E,MAAM,UAAU,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAU,CAAC;AACjD,MAAM,gBAAgB,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAU,CAAC;AAEvD;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,uBAAuB,CACnC,IAAY,EACZ,SAAgC;IAEhC,MAAM,GAAG,GAAsB,EAAE,GAAG,CAAC,IAAI,CAAC,QAAQ,IAAI,EAAE,CAAC,EAAE,CAAC;IAE5D,KAAK,MAAM,CAAC,EAAE,EAAE,QAAQ,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;QAC3D,MAAM,QAAQ,GAAG,SAAS,IAAI,EAAE,IAAI,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC;QACjF,MAAM,KAAK,GAAG,YAAY,CAAC,QAAQ,EAAE,QAAQ,EAAE,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;QAC9D,IAAI,CAAC,KAAK;YAAE,SAAS;QACrB,KAAK,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,IAAI,MAAM,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,CAAC,KAAK,QAAQ;YAAE,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;IAC9F,CAAC;IACD,IAAI,CAAC,WAAW,KAAK,eAAe,EAAE,0BAA0B,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC1F,OAAO,SAAS,CAAC;AACrB,CAAC;AAED,MAAM,MAAM,GAAG,IAAI,GAAG,EAAU,CAAC;AAEjC,SAAS,IAAI,CAAC,OAAe;IACzB,IAAI,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC;QAAE,OAAO;IAChC,IAAI,MAAM,CAAC,IAAI,GAAG,GAAG;QAAE,MAAM,CAAC,KAAK,EAAE,CAAC;IACtC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACpB,OAAO,CAAC,IAAI,CAAC,YAAY,OAAO,EAAE,CAAC,CAAC;AACxC,CAAC","sourcesContent":["import { parseColor } from \"../fill/color/parser\";\r\nimport type { SkSLUniformRecord, SkSLUniformValue } from \"../sksl-uniforms\";\r\nimport type { Shader, ShaderProperty } from \"./pack\";\r\n\r\n/** Overrides for a pack's properties, by property id. */\r\nexport type ShaderPropertyValues = Record<string, unknown>;\r\n\r\n/** Component names a multi-part property may map, in the order they index. */\r\nconst COMPONENTS = [\"x\", \"y\", \"z\", \"w\"] as const;\r\nconst COLOR_COMPONENTS = [\"r\", \"g\", \"b\", \"a\"] as const;\r\n\r\n/**\r\n * Turn a pack's properties, plus any overrides, into the uniform record the\r\n * renderer writes.\r\n *\r\n * This is the whole job of a property: it is an *editable* value, and a uniform\r\n * is where that value has to end up. One property may feed several uniforms —\r\n * see `ShaderPropertyBase.inputs` — which is why this cannot be a rename.\r\n *\r\n * The pack's own `uniforms` are merged in first and the properties win, matching\r\n * the precedence `writeUniforms` already uses for an author value over a\r\n * built-in: the more specific statement of the same value takes it.\r\n */\r\nexport function resolveShaderProperties(\r\n pack: Shader,\r\n overrides?: ShaderPropertyValues,\r\n): SkSLUniformRecord {\r\n const out: SkSLUniformRecord = { ...(pack.uniforms ?? {}) };\r\n\r\n for (const [id, property] of Object.entries(pack.properties)) {\r\n const supplied = overrides && id in overrides ? overrides[id] : property.default;\r\n const parts = componentsOf(property, supplied, id, pack.name);\r\n if (!parts) continue;\r\n for (const [component, uniform] of Object.entries(property.inputs)) {\r\n const value = parts[component];\r\n if (value === undefined) {\r\n warn(`shader \"${pack.name}\" property \"${id}\" has no \"${component}\" to write to \"${uniform}\".`);\r\n continue;\r\n }\r\n out[uniform] = value;\r\n }\r\n }\r\n\r\n if (overrides) {\r\n for (const id of Object.keys(overrides)) {\r\n if (id in pack.properties) continue;\r\n warn(`shader \"${pack.name}\" has no property \"${id}\"; the override is ignored.`);\r\n }\r\n }\r\n\r\n return out;\r\n}\r\n\r\n/**\r\n * Split one property's value across the components its `inputs` name.\r\n *\r\n * A property naming only `value` passes its whole value through, which is the\r\n * common case and the reason a scalar needs no ceremony. One naming `x`/`y` (or\r\n * `r`/`g`/`b`/`a`) indexes into the value, which is what lets a `point` drive two\r\n * separate `float` uniforms in a source that never declared a `float2`.\r\n */\r\nfunction componentsOf(\r\n property: ShaderProperty,\r\n value: unknown,\r\n id: string,\r\n where: string,\r\n): Record<string, SkSLUniformValue> | undefined {\r\n const flat = toUniformValue(property, value, id, where);\r\n if (flat === undefined) return undefined;\r\n\r\n const names = Object.keys(property.inputs);\r\n if (names.length === 1 && names[0] === \"value\") return { value: flat };\r\n\r\n const parts = typeof flat === \"number\" ? [flat] : flat;\r\n const out: Record<string, SkSLUniformValue> = { value: flat };\r\n for (const [index, name] of COMPONENTS.entries()) {\r\n if (parts[index] !== undefined) out[name] = parts[index];\r\n }\r\n for (const [index, name] of COLOR_COMPONENTS.entries()) {\r\n if (parts[index] !== undefined) out[name] = parts[index];\r\n }\r\n return out;\r\n}\r\n\r\n/** One property's value as floats, by its kind. */\r\nfunction toUniformValue(\r\n property: ShaderProperty,\r\n value: unknown,\r\n id: string,\r\n where: string,\r\n): SkSLUniformValue | undefined {\r\n switch (property.kind) {\r\n case \"number\":\r\n case \"slider\":\r\n case \"angle\":\r\n case \"hue\":\r\n return asFinite(value, id, where);\r\n\r\n // SkSL's `bool` uniform is not worth relying on across backends, and an\r\n // int uniform does not survive CanvasKit at all — see `writeUniforms`.\r\n // A float of 1 or 0 is what a shader can actually branch on.\r\n case \"boolean\":\r\n return value ? 1 : 0;\r\n\r\n case \"color\":\r\n return asColor(value, id, where);\r\n\r\n case \"vector\":\r\n case \"point\":\r\n return asFloats(value, id, where);\r\n\r\n // An unknown kind still resolves: its value reaches its uniforms\r\n // untouched, so a shader a host cannot fully draw still renders.\r\n default:\r\n return typeof value === \"number\" || Array.isArray(value)\r\n ? (value as SkSLUniformValue)\r\n : undefined;\r\n }\r\n}\r\n\r\nfunction asFinite(value: unknown, id: string, where: string): number | undefined {\r\n if (typeof value === \"number\" && Number.isFinite(value)) return value;\r\n warn(`shader \"${where}\" property \"${id}\" expects a number, got ${JSON.stringify(value)}.`);\r\n return undefined;\r\n}\r\n\r\n/**\r\n * A colour as four floats in 0–1.\r\n *\r\n * A CSS string is parsed rather than refused, so a theme token, an `oklch()` and\r\n * the `\"white/10\"` opacity suffix all reach a shader — `parseColor` is the one\r\n * place any of those are understood, and a shader pack has no reason to be the\r\n * exception.\r\n */\r\nfunction asColor(value: unknown, id: string, where: string): number[] | undefined {\r\n if (typeof value === \"string\") {\r\n const [r, g, b, a] = parseColor(value);\r\n return [r, g, b, a];\r\n }\r\n return asFloats(value, id, where);\r\n}\r\n\r\nfunction asFloats(value: unknown, id: string, where: string): number[] | undefined {\r\n if (Array.isArray(value) && value.every((v) => typeof v === \"number\" && Number.isFinite(v))) {\r\n return value as number[];\r\n }\r\n if (typeof value === \"object\" && value !== null) {\r\n const point = value as { x?: unknown; y?: unknown };\r\n if (typeof point.x === \"number\" && typeof point.y === \"number\") return [point.x, point.y];\r\n }\r\n warn(`shader \"${where}\" property \"${id}\" expects numbers, got ${JSON.stringify(value)}.`);\r\n return undefined;\r\n}\r\n\r\nconst warned = new Set<string>();\r\n\r\nfunction warn(message: string): void {\r\n if (warned.has(message)) return;\r\n if (warned.size > 256) warned.clear();\r\n warned.add(message);\r\n console.warn(`[shader] ${message}`);\r\n}\r\n"]}
1
+ {"version":3,"file":"resolve.js","sourceRoot":"","sources":["../../../../src/attributes/shape/shaders/resolve.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAOlD,8EAA8E;AAC9E,MAAM,UAAU,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAU,CAAC;AACjD,MAAM,gBAAgB,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAU,CAAC;AAEvD;;;;;;;;;;GAUG;AACH,MAAM,UAAU,uBAAuB,CACnC,IAAY,EACZ,SAAgC;IAEhC,MAAM,GAAG,GAAwB,EAAE,GAAG,CAAC,IAAI,CAAC,QAAQ,IAAI,EAAE,CAAC,EAAE,CAAC;IAE9D,KAAK,MAAM,CAAC,EAAE,EAAE,QAAQ,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;QAC3D,MAAM,QAAQ,GAAG,SAAS,IAAI,EAAE,IAAI,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC;QACjF,MAAM,KAAK,GAAG,YAAY,CAAC,QAAQ,EAAE,QAAQ,EAAE,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;QAC9D,IAAI,CAAC,KAAK;YAAE,SAAS;QACrB,KAAK,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;YACjE,MAAM,KAAK,GAAG,KAAK,CAAC,SAAS,CAAC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,eAAe,EAAE,0BAA0B,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC1F,OAAO,SAAS,CAAC;AACrB,CAAC;AAED,MAAM,MAAM,GAAG,IAAI,GAAG,EAAU,CAAC;AAEjC,SAAS,IAAI,CAAC,OAAe;IACzB,IAAI,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC;QAAE,OAAO;IAChC,IAAI,MAAM,CAAC,IAAI,GAAG,GAAG;QAAE,MAAM,CAAC,KAAK,EAAE,CAAC;IACtC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACpB,OAAO,CAAC,IAAI,CAAC,YAAY,OAAO,EAAE,CAAC,CAAC;AACxC,CAAC","sourcesContent":["import { parseColor } from \"../fill/color/parser\";\r\nimport type { ShaderUniformRecord, ShaderUniformValue } from \"./uniforms\";\r\nimport type { Shader, ShaderProperty } from \"./pack\";\r\n\r\n/** Overrides for a pack's properties, by property id. */\r\nexport type ShaderPropertyValues = Record<string, unknown>;\r\n\r\n/** Component names a multi-part property may map, in the order they index. */\r\nconst COMPONENTS = [\"x\", \"y\", \"z\", \"w\"] as const;\r\nconst COLOR_COMPONENTS = [\"r\", \"g\", \"b\", \"a\"] as const;\r\n\r\n/**\r\n * Turn a pack's properties, plus any overrides, into the uniform record the\r\n * renderer writes.\r\n *\r\n * This is the whole job of a property: it is an *editable* value, and a uniform\r\n * is where that value has to end up. One property may feed several uniforms —\r\n * see `ShaderPropertyBase.inputs` — which is why this cannot be a rename.\r\n *\r\n * The pack's own `uniforms` are merged in first and the properties win: the\r\n * more specific statement of the same value takes it.\r\n */\r\nexport function resolveShaderProperties(\r\n pack: Shader,\r\n overrides?: ShaderPropertyValues,\r\n): ShaderUniformRecord {\r\n const out: ShaderUniformRecord = { ...(pack.uniforms ?? {}) };\r\n\r\n for (const [id, property] of Object.entries(pack.properties)) {\r\n const supplied = overrides && id in overrides ? overrides[id] : property.default;\r\n const parts = componentsOf(property, supplied, id, pack.name);\r\n if (!parts) continue;\r\n for (const [component, uniform] of Object.entries(property.inputs)) {\r\n const value = parts[component];\r\n if (value === undefined) {\r\n warn(`shader \"${pack.name}\" property \"${id}\" has no \"${component}\" to write to \"${uniform}\".`);\r\n continue;\r\n }\r\n out[uniform] = value;\r\n }\r\n }\r\n\r\n if (overrides) {\r\n for (const id of Object.keys(overrides)) {\r\n if (id in pack.properties) continue;\r\n warn(`shader \"${pack.name}\" has no property \"${id}\"; the override is ignored.`);\r\n }\r\n }\r\n\r\n return out;\r\n}\r\n\r\n/**\r\n * Split one property's value across the components its `inputs` name.\r\n *\r\n * A property naming only `value` passes its whole value through, which is the\r\n * common case and the reason a scalar needs no ceremony. One naming `x`/`y` (or\r\n * `r`/`g`/`b`/`a`) indexes into the value, which is what lets a `point` drive two\r\n * separate `float` uniforms in a source that never declared a `float2`.\r\n */\r\nfunction componentsOf(\r\n property: ShaderProperty,\r\n value: unknown,\r\n id: string,\r\n where: string,\r\n): Record<string, ShaderUniformValue> | undefined {\r\n const flat = toUniformValue(property, value, id, where);\r\n if (flat === undefined) return undefined;\r\n\r\n const names = Object.keys(property.inputs);\r\n if (names.length === 1 && names[0] === \"value\") return { value: flat };\r\n\r\n const parts = typeof flat === \"number\" ? [flat] : flat;\r\n const out: Record<string, ShaderUniformValue> = { value: flat };\r\n for (const [index, name] of COMPONENTS.entries()) {\r\n if (parts[index] !== undefined) out[name] = parts[index];\r\n }\r\n for (const [index, name] of COLOR_COMPONENTS.entries()) {\r\n if (parts[index] !== undefined) out[name] = parts[index];\r\n }\r\n return out;\r\n}\r\n\r\n/** One property's value as floats, by its kind. */\r\nfunction toUniformValue(\r\n property: ShaderProperty,\r\n value: unknown,\r\n id: string,\r\n where: string,\r\n): ShaderUniformValue | undefined {\r\n switch (property.kind) {\r\n case \"number\":\r\n case \"slider\":\r\n case \"angle\":\r\n case \"hue\":\r\n return asFinite(value, id, where);\r\n\r\n // A `bool` cannot be a uniform member in WGSL; a float of 1 or 0 is what a shader can branch on.\r\n case \"boolean\":\r\n return value ? 1 : 0;\r\n\r\n case \"color\":\r\n return asColor(value, id, where);\r\n\r\n case \"vector\":\r\n case \"point\":\r\n return asFloats(value, id, where);\r\n\r\n // An unknown kind still resolves: its value reaches its uniforms\r\n // untouched, so a shader a host cannot fully draw still renders.\r\n default:\r\n return typeof value === \"number\" || Array.isArray(value)\r\n ? (value as ShaderUniformValue)\r\n : undefined;\r\n }\r\n}\r\n\r\nfunction asFinite(value: unknown, id: string, where: string): number | undefined {\r\n if (typeof value === \"number\" && Number.isFinite(value)) return value;\r\n warn(`shader \"${where}\" property \"${id}\" expects a number, got ${JSON.stringify(value)}.`);\r\n return undefined;\r\n}\r\n\r\n/**\r\n * A colour as four floats in 0–1.\r\n *\r\n * A CSS string is parsed rather than refused, so a theme token, an `oklch()` and\r\n * the `\"white/10\"` opacity suffix all reach a shader — `parseColor` is the one\r\n * place any of those are understood, and a shader pack has no reason to be the\r\n * exception.\r\n */\r\nfunction asColor(value: unknown, id: string, where: string): number[] | undefined {\r\n if (typeof value === \"string\") {\r\n const [r, g, b, a] = parseColor(value);\r\n return [r, g, b, a];\r\n }\r\n return asFloats(value, id, where);\r\n}\r\n\r\nfunction asFloats(value: unknown, id: string, where: string): number[] | undefined {\r\n if (Array.isArray(value) && value.every((v) => typeof v === \"number\" && Number.isFinite(v))) {\r\n return value as number[];\r\n }\r\n if (typeof value === \"object\" && value !== null) {\r\n const point = value as { x?: unknown; y?: unknown };\r\n if (typeof point.x === \"number\" && typeof point.y === \"number\") return [point.x, point.y];\r\n }\r\n warn(`shader \"${where}\" property \"${id}\" expects numbers, got ${JSON.stringify(value)}.`);\r\n return undefined;\r\n}\r\n\r\nconst warned = new Set<string>();\r\n\r\nfunction warn(message: string): void {\r\n if (warned.has(message)) return;\r\n if (warned.size > 256) warned.clear();\r\n warned.add(message);\r\n console.warn(`[shader] ${message}`);\r\n}\r\n"]}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Uniform values shared by the `shader` fill and the `shader` effect: the
3
+ * authoring shapes, their canonical record, and how two records interpolate
4
+ * and compare. The renderer binds the record to the program's `struct Params`
5
+ * by name.
6
+ */
7
+ /** A single uniform value: a float, or a flat array for a vector/matrix/array uniform. */
8
+ export type ShaderUniformValue = number | number[];
9
+ /** A named uniform, in the positional `[{name, value}]` form older shader effects were written with. */
10
+ export interface ShaderUniform {
11
+ name: string;
12
+ value: ShaderUniformValue;
13
+ }
14
+ /** Uniform values keyed by the name they are declared under in the shader. */
15
+ export type ShaderUniformRecord = Record<string, ShaderUniformValue>;
16
+ /**
17
+ * Normalise either authoring shape to a canonical record.
18
+ *
19
+ * Accepts the record form and the positional `[{name, value}]` array older
20
+ * shader effects were written with. Keys are **sorted**, which makes the resolved fill canonical: two
21
+ * authors writing the same uniforms in a different order produce the same object,
22
+ * so `equals` and any structural diff agree with the renderer (which reads by
23
+ * name and never sees the order at all).
24
+ */
25
+ export declare function normalizeUniforms(input: ShaderUniformRecord | readonly ShaderUniform[] | undefined): ShaderUniformRecord;
26
+ /** Component-wise lerp. Mismatched shapes snap, since there is no in-between arity. */
27
+ export declare function lerpUniformValue(a: ShaderUniformValue, b: ShaderUniformValue, t: number): ShaderUniformValue;
28
+ export declare function uniformValuesEqual(a: ShaderUniformValue, b: ShaderUniformValue): boolean;
29
+ /**
30
+ * Interpolate two uniform records over the **union** of their keys.
31
+ *
32
+ * A key present on one side only holds at the value it has rather than
33
+ * interpolating from zero: the shader still declares it, so dropping it would
34
+ * write zeros mid-tween and read as the uniform snapping to black/none. This is
35
+ * also what makes the self-pair `lerpFillArray` builds for an unmatched fill
36
+ * layer a no-op on the uniforms.
37
+ */
38
+ export declare function lerpUniformRecord(a: ShaderUniformRecord, b: ShaderUniformRecord, t: number): ShaderUniformRecord;
39
+ /** Compare by key *set*, not insertion order. */
40
+ export declare function uniformRecordsEqual(a: ShaderUniformRecord, b: ShaderUniformRecord): boolean;
41
+ //# sourceMappingURL=uniforms.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uniforms.d.ts","sourceRoot":"","sources":["../../../../src/attributes/shape/shaders/uniforms.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,0FAA0F;AAC1F,MAAM,MAAM,kBAAkB,GAAG,MAAM,GAAG,MAAM,EAAE,CAAC;AAEnD,wGAAwG;AACxG,MAAM,WAAW,aAAa;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,kBAAkB,CAAC;CAC7B;AAED,8EAA8E;AAC9E,MAAM,MAAM,mBAAmB,GAAG,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;AAsDrE;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAC7B,KAAK,EAAE,mBAAmB,GAAG,SAAS,aAAa,EAAE,GAAG,SAAS,GAClE,mBAAmB,CAYrB;AAMD,uFAAuF;AACvF,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,kBAAkB,EAAE,CAAC,EAAE,kBAAkB,EAAE,CAAC,EAAE,MAAM,GAAG,kBAAkB,CAO5G;AAED,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,kBAAkB,EAAE,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAMxF;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAC7B,CAAC,EAAE,mBAAmB,EACtB,CAAC,EAAE,mBAAmB,EACtB,CAAC,EAAE,MAAM,GACV,mBAAmB,CAWrB;AAED,iDAAiD;AACjD,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,mBAAmB,EAAE,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAO3F"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uniforms.js","sourceRoot":"","sources":["../../../../src/attributes/shape/shaders/uniforms.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAc1C,8EAA8E;AAC9E,cAAc;AACd,8EAA8E;AAE9E;;;;;;GAMG;AACH,MAAM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,GAAG,GAAwB,EAAE,CAAC;IACpC,KAAK,MAAM,IAAI,IAAI,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;QAC/D,IAAI,IAAI,IAAI,GAAG;YAAE,SAAS;QAC1B,MAAM,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC;QACrB,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC;QACnB,IAAI,IAAI,KAAK,SAAS;YAAE,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;aAClC,IAAI,EAAE,KAAK,SAAS;YAAE,GAAG,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;;YACvC,GAAG,CAAC,IAAI,CAAC,GAAG,gBAAgB,CAAC,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;IACnD,CAAC;IACD,OAAO,GAAG,CAAC;AACf,CAAC;AAED,iDAAiD;AACjD,MAAM,UAAU,mBAAmB,CAAC,CAAsB,EAAE,CAAsB;IAC9E,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC7B,IAAI,KAAK,CAAC,MAAM,KAAK,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM;QAAE,OAAO,KAAK,CAAC;IACzD,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE;QACxB,MAAM,KAAK,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC;QACtB,OAAO,KAAK,KAAK,SAAS,IAAI,kBAAkB,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,CAAC;IACrE,CAAC,CAAC,CAAC;AACP,CAAC","sourcesContent":["/**\n * Uniform values shared by the `shader` fill and the `shader` effect: the\n * authoring shapes, their canonical record, and how two records interpolate\n * and compare. The renderer binds the record to the program's `struct Params`\n * by name.\n */\n\nimport { lerpNumber } from '@/tween/lerp';\n\n/** A single uniform value: a float, or a flat array for a vector/matrix/array uniform. */\nexport type ShaderUniformValue = number | number[];\n\n/** A named uniform, in the positional `[{name, value}]` form older shader effects were written with. */\nexport interface ShaderUniform {\n name: string;\n value: ShaderUniformValue;\n}\n\n/** Uniform values keyed by the name they are declared under in the shader. */\nexport type ShaderUniformRecord = Record<string, ShaderUniformValue>;\n\n// ---------------------------------------------------------------------------\n// Diagnostics\n// ---------------------------------------------------------------------------\n\n/**\n * Warnings already emitted, keyed by scope + message.\n *\n * Normalising runs on every resolve, so an unguarded warn is thousands of\n * identical lines in an export. Cleared past a ceiling so a pathological scene\n * can't grow this without bound.\n */\nconst warned = new Set<string>();\n\nfunction warnOnce(scope: string, message: string): void {\n const key = `${scope}\u0000${message}`;\n if (warned.has(key)) return;\n if (warned.size > 512) warned.clear();\n warned.add(key);\n console.warn(`[shader] ${message}`);\n}\n\n// ---------------------------------------------------------------------------\n// Authoring shapes → canonical record\n// ---------------------------------------------------------------------------\n\n/** Flatten a value to the float list it contributes, or null if it isn't numeric. */\nfunction flattenValue(name: string, value: unknown): ShaderUniformValue | null {\n if (typeof value === 'number') {\n if (!Number.isFinite(value)) {\n warnOnce('normalize', `uniform \"${name}\" is ${value}; ignoring it.`);\n return null;\n }\n return value;\n }\n if (!Array.isArray(value)) {\n warnOnce('normalize', `uniform \"${name}\" is not a number or number array; ignoring it.`);\n return null;\n }\n // `[[r,g,b,a], …]` is how an author naturally writes a colour array uniform,\n // and the renderer takes the whole thing as one flat float run either way.\n const flat = (value as unknown[]).flat(Infinity) as unknown[];\n const out: number[] = [];\n for (const entry of flat) {\n if (typeof entry !== 'number' || !Number.isFinite(entry)) {\n warnOnce('normalize', `uniform \"${name}\" contains a non-finite entry; ignoring it.`);\n return null;\n }\n out.push(entry);\n }\n return out;\n}\n\n/**\n * Normalise either authoring shape to a canonical record.\n *\n * Accepts the record form and the positional `[{name, value}]` array older\n * shader effects were written with. Keys are **sorted**, which makes the resolved fill canonical: two\n * authors writing the same uniforms in a different order produce the same object,\n * so `equals` and any structural diff agree with the renderer (which reads by\n * name and never sees the order at all).\n */\nexport function normalizeUniforms(\n input: ShaderUniformRecord | readonly ShaderUniform[] | undefined,\n): ShaderUniformRecord {\n if (!input) return {};\n const pairs: Array<[string, unknown]> = Array.isArray(input)\n ? (input as readonly ShaderUniform[]).map((u) => [u.name, u.value])\n : Object.entries(input as ShaderUniformRecord);\n\n const out: ShaderUniformRecord = {};\n for (const [name, value] of pairs.sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))) {\n const flat = flattenValue(name, value);\n if (flat !== null) out[name] = flat;\n }\n return out;\n}\n\n// ---------------------------------------------------------------------------\n// Interpolation and equality\n// ---------------------------------------------------------------------------\n\n/** Component-wise lerp. Mismatched shapes snap, since there is no in-between arity. */\nexport function lerpUniformValue(a: ShaderUniformValue, b: ShaderUniformValue, t: number): ShaderUniformValue {\n if (typeof a === 'number' && typeof b === 'number') return lerpNumber(a, b, t);\n if (Array.isArray(a) && Array.isArray(b)) {\n const len = Math.max(a.length, b.length);\n return Array.from({ length: len }, (_, i) => lerpNumber(a[i] ?? 0, b[i] ?? 0, t));\n }\n return t < 0.5 ? a : b;\n}\n\nexport function uniformValuesEqual(a: ShaderUniformValue, b: ShaderUniformValue): boolean {\n if (typeof a === 'number' && typeof b === 'number') return a === b;\n if (Array.isArray(a) && Array.isArray(b)) {\n return a.length === b.length && a.every((v, i) => v === b[i]);\n }\n return false;\n}\n\n/**\n * Interpolate two uniform records over the **union** of their keys.\n *\n * A key present on one side only holds at the value it has rather than\n * interpolating from zero: the shader still declares it, so dropping it would\n * write zeros mid-tween and read as the uniform snapping to black/none. This is\n * also what makes the self-pair `lerpFillArray` builds for an unmatched fill\n * layer a no-op on the uniforms.\n */\nexport function lerpUniformRecord(\n a: ShaderUniformRecord,\n b: ShaderUniformRecord,\n t: number,\n): ShaderUniformRecord {\n const out: ShaderUniformRecord = {};\n for (const name of [...Object.keys(a), ...Object.keys(b)].sort()) {\n if (name in out) continue;\n const from = a[name];\n const to = b[name];\n if (from === undefined) out[name] = to;\n else if (to === undefined) out[name] = from;\n else out[name] = lerpUniformValue(from, to, t);\n }\n return out;\n}\n\n/** Compare by key *set*, not insertion order. */\nexport function uniformRecordsEqual(a: ShaderUniformRecord, b: ShaderUniformRecord): boolean {\n const aKeys = Object.keys(a);\n if (aKeys.length !== Object.keys(b).length) return false;\n return aKeys.every((name) => {\n const other = b[name];\n return other !== undefined && uniformValuesEqual(a[name], other);\n });\n}\n"]}