@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
@@ -0,0 +1,178 @@
1
+ import { lerpNumber } from "../../../tween/lerp.js";
2
+ import { lerpVector2 } from "../../../attributes/layout/vector2.js";
3
+ import { lerpColor } from "../../../attributes/shape/fill/lerp.js";
4
+ import { resolveEffectColor, sameEffectAxis, sameEffectColor, scalarOptions, withEffectOptions } from "./effect-data.js";
5
+ /** Declares a built-in effect; see {@link EffectSpec}. */
6
+ export function defineEffect(spec) {
7
+ return spec;
8
+ }
9
+ /** The middle of the layer, every centre option's default. Shared, as it always was. */
10
+ export const CENTER = { x: 0.5, y: 0.5 };
11
+ /** Parameter constructors for {@link defineEffect}. */
12
+ export const param = {
13
+ number(o) {
14
+ return { kind: "number", ...o };
15
+ },
16
+ color(o) {
17
+ return { kind: "color", ...o };
18
+ },
19
+ /** A point or per-axis pair. `fromNumber` lets the builder take a bare number for it. */
20
+ vec2(o) {
21
+ const normalize = o.fromNumber === undefined
22
+ ? undefined
23
+ : o.fromNumber === "both"
24
+ ? (v) => (typeof v === "number" ? { x: v, y: v } : v)
25
+ : (v) => (typeof v === "number" ? { x: 0, y: v } : v);
26
+ return { kind: "vec2", ...(normalize ? { normalize } : {}), ...o };
27
+ },
28
+ choice(options, o) {
29
+ return { kind: "enum", options, lerp: "step", ...o };
30
+ },
31
+ boolean(o) {
32
+ return { kind: "boolean", lerp: "step", ...o };
33
+ },
34
+ axis(o) {
35
+ return { kind: "axis", lerp: "step", ...o };
36
+ },
37
+ text(o) {
38
+ return { kind: "text", lerp: "step", ...o };
39
+ },
40
+ /**
41
+ * A parameter of stored type `T` that no generic kind covers, curried so
42
+ * `T` is given and the options inferred: `param.of<Color[]>()({ kind: "colors", … })`.
43
+ * It steps and compares by `===` unless given `lerp`/`equals`.
44
+ */
45
+ of() {
46
+ return (o) => ({ lerp: "step", ...o });
47
+ },
48
+ };
49
+ const step = (a, b, t) => (t < 0.5 ? a : b);
50
+ const same = (a, b) => a === b;
51
+ const sameVector = (a, b) => a.x === b.x && a.y === b.y;
52
+ const KIND_LERP = {
53
+ number: lerpNumber,
54
+ color: (a, b, t) => lerpColor(resolveEffectColor(a), resolveEffectColor(b), t),
55
+ vec2: lerpVector2,
56
+ };
57
+ const KIND_EQUALS = {
58
+ color: sameEffectColor,
59
+ vec2: sameVector,
60
+ axis: sameEffectAxis,
61
+ };
62
+ function paramLerp(def) {
63
+ if (typeof def.lerp === "function")
64
+ return def.lerp;
65
+ const kind = def.lerp === "step" ? undefined : KIND_LERP[def.kind];
66
+ if (!kind)
67
+ return step;
68
+ // An absent optional field tweens from what it means when absent.
69
+ if (def.optional && def.default !== undefined) {
70
+ const fallback = def.default;
71
+ return (a, b, t, from, to) => kind(a ?? fallback, b ?? fallback, t, from, to);
72
+ }
73
+ return kind;
74
+ }
75
+ /** The derived `EffectData` of a spec: generic per-kind `lerp`/`equals` unless the spec gives its own. */
76
+ export function effectDataOf(spec) {
77
+ const entries = Object.entries(spec.params);
78
+ const lerps = entries.map(([name, def]) => [name, paramLerp(def)]);
79
+ const equals = entries.map(([name, def]) => [name, def.equals ?? KIND_EQUALS[def.kind] ?? same]);
80
+ const derived = (from, to, t) => {
81
+ const out = { type: spec.type };
82
+ const f = from;
83
+ const g = to;
84
+ for (const [name, lerp] of lerps)
85
+ out[name] = lerp(f[name], g[name], t, f, g);
86
+ return out;
87
+ };
88
+ const custom = spec.lerp;
89
+ const data = {
90
+ lerp: custom ? (from, to, t) => custom(from, to, t, derived) : derived,
91
+ equals: spec.equals ?? ((a, b) => {
92
+ const x = a;
93
+ const y = b;
94
+ return equals.every(([name, eq]) => eq(x[name], y[name]));
95
+ }),
96
+ };
97
+ if (spec.surface !== undefined)
98
+ data.surface = spec.surface;
99
+ if (spec.resolve)
100
+ data.resolve = spec.resolve;
101
+ if (spec.declare)
102
+ data.declare = spec.declare;
103
+ return data;
104
+ }
105
+ // Arrays are copied so editing one effect's list never reaches another's;
106
+ // objects (a centre point) are shared, as they always were.
107
+ const copyDefault = (value) => (Array.isArray(value) ? [...value] : value);
108
+ /**
109
+ * Builds an effect from builder input: the scalar shorthand, then each
110
+ * parameter's option or default (normalised), then `mode`/`clip`.
111
+ */
112
+ export function buildEffect(spec, arg) {
113
+ const o = (spec.scalar
114
+ ? scalarOptions(arg, spec.scalar)
115
+ : (arg ?? {}));
116
+ const out = { type: spec.type };
117
+ for (const [name, def] of Object.entries(spec.params)) {
118
+ const value = o[name] ?? copyDefault(def.default);
119
+ if (value === undefined)
120
+ continue;
121
+ out[name] = def.normalize ? def.normalize(value) : value;
122
+ }
123
+ const options = spec.defaultMode && o.mode === undefined ? { ...o, mode: spec.defaultMode } : o;
124
+ return withEffectOptions(out, options);
125
+ }
126
+ const json = (value) => value === undefined ? undefined : JSON.parse(JSON.stringify(value));
127
+ /** The serialisable {@link EffectDescriptor} of a spec. */
128
+ export function describeSpec(spec) {
129
+ const params = Object.entries(spec.params).map(([name, def], index) => {
130
+ const stored = def.default !== undefined && def.normalize ? def.normalize(def.default) : def.default;
131
+ const out = {
132
+ name,
133
+ kind: def.kind,
134
+ animatable: def.lerp !== "step",
135
+ label: def.label ?? name,
136
+ order: def.order ?? index,
137
+ };
138
+ const optional = {
139
+ default: json(stored),
140
+ required: def.required,
141
+ optional: def.optional,
142
+ min: def.min,
143
+ max: def.max,
144
+ step: def.step,
145
+ unit: def.unit,
146
+ options: def.options ? [...def.options] : undefined,
147
+ control: def.control,
148
+ inline: def.inline,
149
+ zero: def.zero,
150
+ optionsLabel: def.optionsLabel,
151
+ hidden: def.hidden,
152
+ initial: json(def.initial),
153
+ };
154
+ for (const [key, value] of Object.entries(optional)) {
155
+ if (value !== undefined)
156
+ out[key] = value;
157
+ }
158
+ return out;
159
+ });
160
+ const out = {
161
+ type: spec.type,
162
+ group: spec.group,
163
+ surface: typeof spec.surface === "function" ? "dynamic" : (spec.surface ?? "filter"),
164
+ neutral: spec.neutral === null ? null : json(Object.fromEntries(Object.entries(spec.neutral).map(([name, value]) => {
165
+ const normalize = spec.params[name]?.normalize;
166
+ return [name, normalize ? normalize(value) : value];
167
+ }))),
168
+ params,
169
+ };
170
+ if (spec.scalar)
171
+ out.scalar = spec.scalar;
172
+ if (spec.defaultMode)
173
+ out.defaultMode = spec.defaultMode;
174
+ if (spec.onlyOn)
175
+ out.onlyOn = spec.onlyOn;
176
+ return out;
177
+ }
178
+ //# sourceMappingURL=spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spec.js","sourceRoot":"","sources":["../../../../src/attributes/shape/effects/spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAgB,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAIzD,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,eAAe,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAoItH,0DAA0D;AAC1D,MAAM,UAAU,YAAY,CACxB,IAAsB;IAEtB,OAAO,IAAI,CAAC;AAChB,CAAC;AAED,wFAAwF;AACxF,MAAM,CAAC,MAAM,MAAM,GAAY,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC;AAMlD,uDAAuD;AACvD,MAAM,CAAC,MAAM,KAAK,GAAG;IACjB,MAAM,CAAkC,CAAoE;QACxG,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,CAAC,EAAE,CAAC;IACpC,CAAC;IACD,KAAK,CAAiC,CAAuB;QACzD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,CAAC,EAAE,CAAC;IACnC,CAAC;IACD,yFAAyF;IACzF,IAAI,CACA,CAAyB;QAEzB,MAAM,SAAS,GAAG,CAAC,CAAC,UAAU,KAAK,SAAS;YACxC,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,CAAC,CAAC,UAAU,KAAK,MAAM;gBACrB,CAAC,CAAC,CAAC,CAAmB,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,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;QAC1B,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,OAAO,EAAE,OAAO,IAAI,CAAC,OAAO,KAAK,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,IAAI,QAAQ,CAAC;QACpF,OAAO,EAAE,IAAI,CAAC,OAAO,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAE,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,EAAE;YAChH,MAAM,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,SAAS,CAAC;YAC/C,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QACxD,CAAC,CAAC,CAAC,CAAmC;QACtC,MAAM;KACT,CAAC;IACF,IAAI,IAAI,CAAC,MAAM;QAAE,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;IAC1C,IAAI,IAAI,CAAC,WAAW;QAAE,GAAG,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC;IACzD,IAAI,IAAI,CAAC,MAAM;QAAE,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;IAC1C,OAAO,GAAG,CAAC;AACf,CAAC","sourcesContent":["import { lerpNumber } from \"@/tween/lerp\";\r\nimport { lerpVector2, type Vector2 } from \"@/attributes/layout/vector2\";\r\nimport { lerpColor } from \"@/attributes/shape/fill/lerp\";\r\nimport type { Color } from \"@/attributes/shape/fill/color/parser\";\r\nimport type { AssetScope } from \"@/assets/scope\";\r\nimport type { EffectAxis, EffectData, EffectMode, EffectOptions, EffectSurface, ModedEffect } from \"./effect-data\";\r\nimport { resolveEffectColor, sameEffectAxis, sameEffectColor, scalarOptions, withEffectOptions } from \"./effect-data\";\r\n\r\n/**\r\n * How a parameter's value is shaped, which decides its default interpolation,\r\n * equality and how a renderer encodes it into a uniform.\r\n */\r\nexport type EffectParamKind =\r\n | \"number\"\r\n | \"color\"\r\n | \"vec2\"\r\n | \"enum\"\r\n | \"boolean\"\r\n | \"axis\"\r\n | \"text\"\r\n | \"colors\"\r\n | \"numbers\"\r\n | \"points\"\r\n | \"table\"\r\n | \"uniforms\";\r\n\r\n/** What a number measures, for a host's units and a renderer's scaling. */\r\nexport type EffectParamUnit = \"px\" | \"deg\" | \"percent\" | \"factor\" | \"normalized\";\r\n\r\n/** The picker family an effect is listed under. */\r\nexport type EffectGroup = \"blur\" | \"light\" | \"color\" | \"stylize\" | \"distort\" | \"glitch\";\r\n\r\n/** The control an inspector should draw for a parameter. */\r\nexport type EffectParamControl = \"number\" | \"slider\" | \"angle\" | \"hue\" | \"segmented\" | \"select\" | \"text\" | \"color\" | \"point\" | \"toggle\";\r\n\r\n/** Per-parameter inspector hints. None of them changes what the effect does. */\r\nexport interface EffectParamHints {\r\n /** i18n leaf for the field's label; defaults to the parameter name. */\r\n readonly label?: string;\r\n readonly control?: EffectParamControl;\r\n /** Shown on the effect's row beside its name (one per effect). */\r\n readonly inline?: boolean;\r\n /** Inspector position; defaults to the declaration order. */\r\n readonly order?: number;\r\n /** For an angle: where 0° points (the bearing turns clockwise). Defaults to `\"right\"`. */\r\n readonly zero?: \"right\" | \"top\";\r\n /** i18n group for an enum's option labels. */\r\n readonly optionsLabel?: string;\r\n /** Not offered as a field: the value a fresh effect carries is kept as is. */\r\n readonly hidden?: boolean;\r\n /** Where a freshly inserted effect starts, when the builder default would show nothing. */\r\n readonly initial?: unknown;\r\n}\r\n\r\n/** Interpolates one parameter. `from`/`to` are the whole effects, for parameters that depend on a sibling. */\r\nexport type EffectParamLerp<T> = (a: T, b: T, t: number, from: Record<string, unknown>, to: Record<string, unknown>) => T;\r\n\r\n/**\r\n * One parameter of a built-in effect: a stored field of the effect object.\r\n *\r\n * `T` is the stored type, `In` what a builder accepts for it (`normalize` maps\r\n * one to the other: a bare number for a per-axis count, say). Only the\r\n * serialisable fields reach {@link EffectDescriptor}.\r\n */\r\nexport interface EffectParamDef<T = unknown, In = T> extends EffectParamHints {\r\n readonly kind: EffectParamKind;\r\n /** What the builder writes when the option is omitted (an input, before `normalize`). */\r\n readonly default?: In;\r\n /** The stored field may be absent (`colorAdjustment`'s fields, `curves.channel`). */\r\n readonly optional?: boolean;\r\n /** The builder's options type requires it. */\r\n readonly required?: boolean;\r\n readonly min?: number;\r\n readonly max?: number;\r\n readonly step?: number;\r\n readonly unit?: EffectParamUnit;\r\n /** An enum's values, in the order a renderer indexes them. */\r\n readonly options?: readonly (string | number)[];\r\n readonly normalize?: (input: In) => T;\r\n /** `\"step\"` switches at the midpoint; omitted uses the kind's interpolation. */\r\n readonly lerp?: \"step\" | EffectParamLerp<T>;\r\n readonly equals?: (a: T, b: T) => boolean;\r\n /** Type carrier only; never set. */\r\n readonly __type?: [T, In];\r\n}\r\n\r\n/** An effect's parameters, by stored field name, in builder (and stored-key) order. */\r\nexport type EffectParamTable = Readonly<Record<string, EffectParamDef<any, any>>>;\r\n\r\n/**\r\n * The declarative definition of a built-in effect: its parameters (types,\r\n * defaults, ranges, inspector hints) plus the behaviour that has to stay code.\r\n * Core's types, builder defaults, `lerp`/`equals` and the host-facing\r\n * {@link EffectDescriptor} are derived from it, and the renderers bind their\r\n * shader uniforms to its parameter names.\r\n */\r\nexport interface EffectSpec<T extends string = string, P extends EffectParamTable = EffectParamTable> {\r\n readonly type: T;\r\n readonly params: P;\r\n readonly group: EffectGroup;\r\n /** The option a bare number passed to the builder sets. */\r\n readonly scalar?: string;\r\n /** The builder's `mode` when none is given. */\r\n readonly defaultMode?: EffectMode;\r\n /** The one layer the effect does anything on. */\r\n readonly onlyOn?: EffectMode;\r\n /** Builder options at which the effect draws nothing, or `null` when it has none. */\r\n readonly neutral: Readonly<Record<string, unknown>> | null;\r\n readonly surface?: EffectData<any>[\"surface\"];\r\n readonly resolve?: (effect: any) => any;\r\n readonly declare?: (effect: any, assets: AssetScope) => void;\r\n /** Wraps or replaces the derived interpolation, which it is handed as `derived`. */\r\n readonly lerp?: (from: any, to: any, t: number, derived: (from: any, to: any, t: number) => any) => any;\r\n readonly equals?: (a: any, b: any) => boolean;\r\n}\r\n\r\ntype ParamValue<D> = D extends { readonly __type?: [infer T, unknown] } ? T : never;\r\ntype ParamInput<D> = D extends { readonly __type?: [unknown, infer I] } ? I : never;\r\ntype IsOptional<D> = D extends { readonly optional: true } ? true : false;\r\ntype IsRequired<D> = D extends { readonly required: true } ? true : false;\r\n\r\n/** The stored fields an effect's parameters describe. */\r\nexport type EffectFields<P extends EffectParamTable> = {\r\n -readonly [K in keyof P as IsOptional<P[K]> extends true ? never : K]: ParamValue<P[K]>;\r\n} & {\r\n -readonly [K in keyof P as IsOptional<P[K]> extends true ? K : never]?: ParamValue<P[K]>;\r\n};\r\n\r\n/** A builder's options for an effect: every parameter as input, plus `mode`/`clip`. */\r\nexport type EffectOptionsOf<P extends EffectParamTable> = {\r\n -readonly [K in keyof P as IsRequired<P[K]> extends true ? K : never]: ParamInput<P[K]>;\r\n} & {\r\n -readonly [K in keyof P as IsRequired<P[K]> extends true ? never : K]?: ParamInput<P[K]>;\r\n} & EffectOptions;\r\n\r\n/** The effect object a spec describes. */\r\nexport type EffectOf<S extends EffectSpec> = { type: S[\"type\"] } & ModedEffect & EffectFields<S[\"params\"]>;\r\n\r\n/** Declares a built-in effect; see {@link EffectSpec}. */\r\nexport function defineEffect<const T extends string, const P extends EffectParamTable>(\r\n spec: EffectSpec<T, P>,\r\n): EffectSpec<T, P> {\r\n return spec;\r\n}\r\n\r\n/** The middle of the layer, every centre option's default. Shared, as it always was. */\r\nexport const CENTER: Vector2 = { x: 0.5, y: 0.5 };\r\n\r\ntype Options<T, In = T> = Omit<EffectParamDef<T, In>, \"kind\" | \"__type\" | \"options\" | \"normalize\" | \"lerp\" | \"equals\">;\r\n// Kept out of the inferred options so a lambda here is typed by its parameter.\r\ntype Behaviour<T> = Pick<EffectParamDef<T>, \"lerp\" | \"equals\">;\r\n\r\n/** Parameter constructors for {@link defineEffect}. */\r\nexport const param = {\r\n number<const O extends Options<number>>(o: O & Behaviour<number> & { normalize?: (input: number) => number }): EffectParamDef<number> & NoInfer<O> & { kind: \"number\" } {\r\n return { kind: \"number\", ...o };\r\n },\r\n color<const O extends Options<Color>>(o: O & Behaviour<Color>): EffectParamDef<Color> & NoInfer<O> & { kind: \"color\" } {\r\n return { kind: \"color\", ...o };\r\n },\r\n /** A point or per-axis pair. `fromNumber` lets the builder take a bare number for it. */\r\n vec2<const O extends Options<Vector2, number | Vector2> & { fromNumber?: \"both\" | \"y\" }>(\r\n o: O & Behaviour<Vector2>,\r\n ): EffectParamDef<Vector2, O extends { fromNumber: string } ? number | Vector2 : Vector2> & NoInfer<O> & { kind: \"vec2\" } {\r\n const normalize = o.fromNumber === undefined\r\n ? undefined\r\n : o.fromNumber === \"both\"\r\n ? (v: number | Vector2) => (typeof v === \"number\" ? { x: v, y: v } : v)\r\n : (v: number | Vector2) => (typeof v === \"number\" ? { x: 0, y: v } : v);\r\n return { kind: \"vec2\", ...(normalize ? { normalize } : {}), ...o } as never;\r\n },\r\n choice<const V extends string | number, const O extends Options<V>>(\r\n options: readonly V[],\r\n o: O & Behaviour<V>,\r\n ): EffectParamDef<V> & NoInfer<O> & { kind: \"enum\"; options: readonly V[] } {\r\n return { kind: \"enum\", options, lerp: \"step\", ...o };\r\n },\r\n boolean<const O extends Options<boolean>>(o: O & Behaviour<boolean>): EffectParamDef<boolean> & NoInfer<O> & { kind: \"boolean\" } {\r\n return { kind: \"boolean\", lerp: \"step\", ...o };\r\n },\r\n axis<const O extends Options<EffectAxis>>(o: O & Behaviour<EffectAxis>): EffectParamDef<EffectAxis> & NoInfer<O> & { kind: \"axis\" } {\r\n return { kind: \"axis\", lerp: \"step\", ...o };\r\n },\r\n text<V extends string = string, const O extends Options<V> = Options<V>>(o: O & Behaviour<V>): EffectParamDef<V> & NoInfer<O> & { kind: \"text\" } {\r\n return { kind: \"text\", lerp: \"step\", ...o };\r\n },\r\n /**\r\n * A parameter of stored type `T` that no generic kind covers, curried so\r\n * `T` is given and the options inferred: `param.of<Color[]>()({ kind: \"colors\", … })`.\r\n * It steps and compares by `===` unless given `lerp`/`equals`.\r\n */\r\n of<T>() {\r\n return <const O extends Options<T> & { kind: EffectParamKind }>(o: O & Behaviour<T>): EffectParamDef<T> & NoInfer<O> =>\r\n ({ lerp: \"step\", ...o }) as never;\r\n },\r\n};\r\n\r\nconst step = <T>(a: T, b: T, t: number): T => (t < 0.5 ? a : b);\r\nconst same = (a: unknown, b: unknown) => a === b;\r\nconst sameVector = (a: Vector2, b: Vector2) => a.x === b.x && a.y === b.y;\r\n\r\nconst KIND_LERP: Partial<Record<EffectParamKind, EffectParamLerp<any>>> = {\r\n number: lerpNumber,\r\n color: (a: Color, b: Color, t) => lerpColor(resolveEffectColor(a), resolveEffectColor(b), t),\r\n vec2: lerpVector2,\r\n};\r\n\r\nconst KIND_EQUALS: Partial<Record<EffectParamKind, (a: any, b: any) => boolean>> = {\r\n color: sameEffectColor,\r\n vec2: sameVector,\r\n axis: sameEffectAxis,\r\n};\r\n\r\nfunction paramLerp(def: EffectParamDef<any, any>): EffectParamLerp<unknown> {\r\n if (typeof def.lerp === \"function\") return def.lerp;\r\n const kind = def.lerp === \"step\" ? undefined : KIND_LERP[def.kind];\r\n if (!kind) return step;\r\n // An absent optional field tweens from what it means when absent.\r\n if (def.optional && def.default !== undefined) {\r\n const fallback = def.default;\r\n return (a, b, t, from, to) => kind(a ?? fallback, b ?? fallback, t, from, to);\r\n }\r\n return kind;\r\n}\r\n\r\n/** The derived `EffectData` of a spec: generic per-kind `lerp`/`equals` unless the spec gives its own. */\r\nexport function effectDataOf<S extends EffectSpec>(spec: S): EffectData<EffectOf<S>> {\r\n const entries = Object.entries(spec.params);\r\n const lerps = entries.map(([name, def]) => [name, paramLerp(def)] as const);\r\n const equals = entries.map(([name, def]) => [name, def.equals ?? KIND_EQUALS[def.kind] ?? same] as const);\r\n const derived = (from: EffectOf<S>, to: EffectOf<S>, t: number): EffectOf<S> => {\r\n const out: Record<string, unknown> = { type: spec.type };\r\n const f = from as unknown as Record<string, unknown>;\r\n const g = to as unknown as Record<string, unknown>;\r\n for (const [name, lerp] of lerps) out[name] = lerp(f[name], g[name], t, f, g);\r\n return out as EffectOf<S>;\r\n };\r\n const custom = spec.lerp;\r\n const data: EffectData<EffectOf<S>> = {\r\n lerp: custom ? (from, to, t) => custom(from, to, t, derived) : derived,\r\n equals: spec.equals ?? ((a, b) => {\r\n const x = a as unknown as Record<string, unknown>;\r\n const y = b as unknown as Record<string, unknown>;\r\n return equals.every(([name, eq]) => eq(x[name], y[name]));\r\n }),\r\n };\r\n if (spec.surface !== undefined) data.surface = spec.surface;\r\n if (spec.resolve) data.resolve = spec.resolve;\r\n if (spec.declare) data.declare = spec.declare;\r\n return data;\r\n}\r\n\r\n// Arrays are copied so editing one effect's list never reaches another's;\r\n// objects (a centre point) are shared, as they always were.\r\nconst copyDefault = (value: unknown) => (Array.isArray(value) ? [...value] : value);\r\n\r\n/**\r\n * Builds an effect from builder input: the scalar shorthand, then each\r\n * parameter's option or default (normalised), then `mode`/`clip`.\r\n */\r\nexport function buildEffect<S extends EffectSpec>(\r\n spec: S,\r\n arg: number | EffectOptionsOf<S[\"params\"]> | undefined,\r\n): EffectOf<S> {\r\n const o = (spec.scalar\r\n ? scalarOptions(arg as number | Record<string, unknown> | undefined, spec.scalar as never)\r\n : (arg ?? {})) as Record<string, unknown> & EffectOptions;\r\n const out: Record<string, unknown> = { type: spec.type };\r\n for (const [name, def] of Object.entries(spec.params)) {\r\n const value = o[name] ?? copyDefault(def.default);\r\n if (value === undefined) continue;\r\n out[name] = def.normalize ? def.normalize(value) : value;\r\n }\r\n const options = spec.defaultMode && o.mode === undefined ? { ...o, mode: spec.defaultMode } : o;\r\n return withEffectOptions(out, options) as unknown as EffectOf<S>;\r\n}\r\n\r\n/** A JSON value — what every field of an {@link EffectDescriptor} is made of. */\r\nexport type EffectJson = string | number | boolean | null | EffectJson[] | { [key: string]: EffectJson };\r\n\r\n/** One parameter of an {@link EffectDescriptor}. */\r\nexport interface EffectParamDescriptor {\r\n /** The stored field it writes. */\r\n name: string;\r\n kind: EffectParamKind;\r\n /** What the builder writes when it is omitted, as stored (colours as authored). */\r\n default?: EffectJson;\r\n /** The builder's options require it. */\r\n required?: boolean;\r\n /** The stored field may be absent. */\r\n optional?: boolean;\r\n min?: number;\r\n max?: number;\r\n step?: number;\r\n unit?: EffectParamUnit;\r\n options?: (string | number)[];\r\n /** Tweens continuously (false: switches at the midpoint). */\r\n animatable: boolean;\r\n /** i18n leaf for the label; the name unless the spec says otherwise. */\r\n label: string;\r\n control?: EffectParamControl;\r\n inline?: boolean;\r\n /** Inspector position. */\r\n order: number;\r\n zero?: \"right\" | \"top\";\r\n optionsLabel?: string;\r\n hidden?: boolean;\r\n initial?: EffectJson;\r\n}\r\n\r\n/**\r\n * A built-in effect, described for a host: what its fields are, their kinds,\r\n * defaults and ranges, and how an inspector should lay them out. Plain JSON, so\r\n * it can be shipped to a UI as is.\r\n */\r\nexport interface EffectDescriptor {\r\n type: string;\r\n group: EffectGroup;\r\n /** `\"dynamic\"`: depends on the effect's `mode` (the user shader). */\r\n surface: EffectSurface | \"dynamic\";\r\n scalar?: string;\r\n defaultMode?: EffectMode;\r\n onlyOn?: EffectMode;\r\n /** Stored fields at which it draws nothing (the rest at their defaults); `null` when it has none. */\r\n neutral: { [key: string]: EffectJson } | null;\r\n /** In stored-key order; sort by `order` for the inspector's. */\r\n params: EffectParamDescriptor[];\r\n}\r\n\r\nconst json = (value: unknown): EffectJson | undefined =>\r\n value === undefined ? undefined : (JSON.parse(JSON.stringify(value)) as EffectJson);\r\n\r\n/** The serialisable {@link EffectDescriptor} of a spec. */\r\nexport function describeSpec(spec: EffectSpec): EffectDescriptor {\r\n const params = Object.entries(spec.params).map(([name, def], index): EffectParamDescriptor => {\r\n const stored = def.default !== undefined && def.normalize ? def.normalize(def.default) : def.default;\r\n const out: EffectParamDescriptor = {\r\n name,\r\n kind: def.kind,\r\n animatable: def.lerp !== \"step\",\r\n label: def.label ?? name,\r\n order: def.order ?? index,\r\n };\r\n const optional = {\r\n default: json(stored),\r\n required: def.required,\r\n optional: def.optional,\r\n min: def.min,\r\n max: def.max,\r\n step: def.step,\r\n unit: def.unit,\r\n options: def.options ? [...def.options] : undefined,\r\n control: def.control,\r\n inline: def.inline,\r\n zero: def.zero,\r\n optionsLabel: def.optionsLabel,\r\n hidden: def.hidden,\r\n initial: json(def.initial),\r\n };\r\n for (const [key, value] of Object.entries(optional)) {\r\n if (value !== undefined) (out as unknown as Record<string, unknown>)[key] = value;\r\n }\r\n return out;\r\n });\r\n const out: EffectDescriptor = {\r\n type: spec.type,\r\n group: spec.group,\r\n surface: typeof spec.surface === \"function\" ? \"dynamic\" : (spec.surface ?? \"filter\"),\r\n neutral: spec.neutral === null ? null : (json(Object.fromEntries(Object.entries(spec.neutral).map(([name, value]) => {\r\n const normalize = spec.params[name]?.normalize;\r\n return [name, normalize ? normalize(value) : value];\r\n }))) as { [key: string]: EffectJson }),\r\n params,\r\n };\r\n if (spec.scalar) out.scalar = spec.scalar;\r\n if (spec.defaultMode) out.defaultMode = spec.defaultMode;\r\n if (spec.onlyOn) out.onlyOn = spec.onlyOn;\r\n return out;\r\n}\r\n"]}
@@ -128,25 +128,23 @@ export declare class FillChain {
128
128
  */
129
129
  fractalNoise(options?: FillOptions & Omit<FractalNoiseFillProp, 'type' | 'opacity' | 'blend'>): FillChain;
130
130
  /**
131
- * Append a custom SkSL shader fill — the escape hatch past {@link noise} and
131
+ * Append a custom shader fill — the escape hatch past {@link noise} and
132
132
  * {@link fractalNoise}, where the author writes the fragment function.
133
133
  *
134
- * `source` must declare `vec4 main(vec2 fragCoord)` and return
134
+ * The WGSL `source` defines `fn fill(in: FillIn) -> vec4f` and declares its
135
+ * uniforms as `struct Params`, read as `u.<name>`. It returns
135
136
  * **premultiplied** rgba, without folding `opacity` in (the layer's opacity is
136
- * already on the paint, so applying it twice squares it). Uniforms are keyed
137
- * by their declared name and bound by reflecting the compiled program, so
138
- * order is irrelevant; the renderer supplies `u_size`, `u_origin`,
139
- * `u_resolution`, `u_aspect`, `u_time` and `u_scale` to whichever of them the
140
- * source declares.
137
+ * already applied, so applying it twice squares it). Uniforms are keyed by
138
+ * their declared name, so order is irrelevant.
141
139
  *
142
140
  * Keep `source` constant — it is the compile-cache key, so it snaps at a
143
141
  * tween's midpoint and rebuilding it per frame compiles a program per frame.
144
142
  * Everything that changes belongs in a uniform, which is an in-place write.
145
143
  *
146
144
  * @example
147
- * Fills.shader(GLOW, { uniforms: { u_amount: 0.6 }, coords: 'centered' })
145
+ * Fills.shader(GLOW, { uniforms: { amount: 0.6 } })
148
146
  */
149
- shader(source: string | FillShader, options?: FillOptions & Omit<ShaderFillProp, 'type' | 'source' | 'opacity' | 'blend' | 'shaderId'> & {
147
+ shader(source: string | FillShader, options?: FillOptions & Omit<ShaderFillProp, 'type' | 'source' | 'language' | 'opacity' | 'blend' | 'shaderId'> & {
150
148
  values?: ShaderPropertyValues;
151
149
  }): FillChain;
152
150
  /** Append a stripe (hatch) fill. */
@@ -1 +1 @@
1
- {"version":3,"file":"chain.d.ts","sourceRoot":"","sources":["../../../../src/attributes/shape/fill/chain.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACz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CAAC,YAAY,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC;IAa7E;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG;QAAE,aAAa,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,OAAO,CAAA;KAAE;IAKhG,2EAA2E;IAC1E,CAAC,MAAM,CAAC,QAAQ,CAAC;IAIlB,2FAA2F;IAC3F,MAAM;CAGT;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,IAAI,GACV,QAAQ,GACR,YAAY,GACZ,SAAS,GACT,CAAC,QAAQ,GAAG,YAAY,GAAG,SAAS,CAAC,EAAE,CAAC;AAE9C;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,KAAK,WAAkB,CAAC;AAErC;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,IAAI,GAAG,SAAS,GAAG,QAAQ,EAAE,CAiBnE"}
@@ -1,4 +1,4 @@
1
- import { normalizeUniforms } from "../sksl-uniforms.js";
1
+ import { normalizeUniforms } from "../shaders/uniforms.js";
2
2
  import { resolveShaderProperties } from "../shaders/resolve.js";
3
3
  /** Strip `undefined` option keys so the produced props stay minimal/comparable. */
4
4
  function withOptions(base, options = {}) {
@@ -104,23 +104,21 @@ export class FillChain {
104
104
  }, common)]);
105
105
  }
106
106
  /**
107
- * Append a custom SkSL shader fill — the escape hatch past {@link noise} and
107
+ * Append a custom shader fill — the escape hatch past {@link noise} and
108
108
  * {@link fractalNoise}, where the author writes the fragment function.
109
109
  *
110
- * `source` must declare `vec4 main(vec2 fragCoord)` and return
110
+ * The WGSL `source` defines `fn fill(in: FillIn) -> vec4f` and declares its
111
+ * uniforms as `struct Params`, read as `u.<name>`. It returns
111
112
  * **premultiplied** rgba, without folding `opacity` in (the layer's opacity is
112
- * already on the paint, so applying it twice squares it). Uniforms are keyed
113
- * by their declared name and bound by reflecting the compiled program, so
114
- * order is irrelevant; the renderer supplies `u_size`, `u_origin`,
115
- * `u_resolution`, `u_aspect`, `u_time` and `u_scale` to whichever of them the
116
- * source declares.
113
+ * already applied, so applying it twice squares it). Uniforms are keyed by
114
+ * their declared name, so order is irrelevant.
117
115
  *
118
116
  * Keep `source` constant — it is the compile-cache key, so it snaps at a
119
117
  * tween's midpoint and rebuilding it per frame compiles a program per frame.
120
118
  * Everything that changes belongs in a uniform, which is an in-place write.
121
119
  *
122
120
  * @example
123
- * Fills.shader(GLOW, { uniforms: { u_amount: 0.6 }, coords: 'centered' })
121
+ * Fills.shader(GLOW, { uniforms: { amount: 0.6 } })
124
122
  */
125
123
  shader(source, options) {
126
124
  const pack = typeof source === 'string' ? undefined : source;
@@ -129,7 +127,7 @@ export class FillChain {
129
127
  `("${pack.name}"). An effect shader samples a backdrop a fill does not have; ` +
130
128
  `use Effects.shader.`);
131
129
  }
132
- const { uniforms, coords, textures, values, ...common } = options ?? {};
130
+ const { uniforms, textures, values, ...common } = options ?? {};
133
131
  // A pack resolves to plain uniforms here; anything passed as `uniforms`
134
132
  // still wins, matching how an author value overrides a built-in.
135
133
  const resolved = pack
@@ -138,8 +136,8 @@ export class FillChain {
138
136
  return new FillChain([...this.list, withOptions({
139
137
  type: 'shader',
140
138
  source: typeof source === 'string' ? source : source.source,
139
+ language: 'wgsl',
141
140
  uniforms: resolved,
142
- coords: coords ?? pack?.coords,
143
141
  textures,
144
142
  ...(pack?.id !== undefined ? { shaderId: pack.id } : {}),
145
143
  }, common)]);
@@ -1 +1 @@
1
- {"version":3,"file":"chain.js","sourceRoot":"","sources":["../../../../src/attributes/shape/fill/chain.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,uBAAuB,EAA6B,MAAM,oBAAoB,CAAC;AA0DxF,mFAAmF;AACnF,SAAS,WAAW,CAAmB,IAAO,EAAE,UAAuB,EAAE;IACrE,MAAM,GAAG,GA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E,GAAG,CAAC,IAAI,CAAC,GAAG,gBAAgB,CAAC,IAAY,CAAC,CAAC,CAAC;;gBACrE,GAAG,CAAC,IAAI,CAAC,IAAgB,CAAC,CAAC;QACpC,CAAC;QACD,OAAO,GAAG,CAAC;IACf,CAAC;IACD,OAAO,CAAC,IAAgB,CAAC,CAAC;AAC9B,CAAC","sourcesContent":["import type { Color } from \"./color/parser\";\r\nimport type { BlendMode } from \"./blend\";\r\nimport type { Vector2 } from \"@/attributes/layout/vector2\";\r\nimport type { ImageAdjustment, VideoAdjustment } from \"../filters/chain\";\r\nimport type { MediaPresetProp, VideoPresetProp } from \"./media-preset\";\r\nimport type { FillProp, FillResolved, FillSpace } from \"./union\";\r\nimport { normalizeUniforms } from \"../sksl-uniforms\";\r\nimport { resolveShaderProperties, type ShaderPropertyValues } from \"../shaders/resolve\";\r\nimport type { FillShader } from \"../shaders/pack\";\r\nimport type { ImageCrop, ImageFit, ImageMatrix } from \"./implementations/image\";\r\nimport type { Alignment } from \"@/attributes/layout/alignment\";\r\nimport type { FractalNoiseFillProp } from \"./implementations/fractal-noise\";\r\nimport type { DotGridFillProp } from \"./implementations/dot-grid\";\r\nimport type { GridFillProp } from \"./implementations/grid\";\r\nimport type { ShaderFillProp } from \"./implementations/shader\";\r\nimport type { Scene3D } from \"@/render3d/scene3d\";\r\n\r\n/** Placement options shared by the image and video fill builders. */\r\nexport interface MediaPlacementOptions {\r\n /** How the (cropped) source is scaled into the node's bounds. Default `'fill'`. */\r\n fit?: ImageFit;\r\n /** Window onto the source, in fractions of its own size, applied before `fit`. */\r\n crop?: ImageCrop;\r\n /** Magnification on top of the fitted scale. `1` is the fitted size. */\r\n zoom?: number;\r\n /** The point held fixed as `zoom` scales; also the alignment when it doesn't cover. */\r\n anchor?: Alignment;\r\n /** Raw source→shape matrix; bypasses `crop`/`fit`/`zoom`/`anchor` and the bounds. */\r\n matrix?: ImageMatrix;\r\n}\r\n\r\n/** Author-facing options for a {@link FillChain.video} layer. */\r\nexport interface VideoFillOptions extends FillOptions, MediaPlacementOptions {\r\n /** The grade laid over the footage — an adjustment chain plus a 0–1 mix. */\r\n preset?: VideoPresetProp;\r\n /** @deprecated Moved to `preset.adjustments`. Removed in the next major. */\r\n filters?: VideoAdjustment;\r\n /**\r\n * Explicit source time to paint, in seconds. Omit it and the clip plays by\r\n * itself, timed from the moment the node painting it appeared — set it only\r\n * to drive the playhead yourself (`null` hands the playhead back).\r\n */\r\n timestamp?: number | null;\r\n /** Whether playback advances with the node's clock. Defaults to `true`. */\r\n playing?: boolean;\r\n trimStart?: number;\r\n trimEnd?: number;\r\n /** Seconds after the painting node appears before playback begins. Default `0`. */\r\n playStart?: number;\r\n speed?: number;\r\n loop?: 'forward' | 'reverse' | 'none';\r\n duration?: number;\r\n}\r\n\r\n/**\r\n * Cross-cutting options shared by every fill layer. These map onto the\r\n * `opacity` / `blend` fields each fill prop already accepts, plus the\r\n * `space` directive carried generically by the registry.\r\n */\r\nexport interface FillOptions {\r\n opacity?: number;\r\n blend?: BlendMode;\r\n space?: FillSpace;\r\n}\r\n\r\n/** Strip `undefined` option keys so the produced props stay minimal/comparable. */\r\nfunction withOptions<T extends object>(base: T, options: FillOptions = {}): T & FillOptions {\r\n const out = { ...base } as T & FillOptions;\r\n if (options.opacity !== undefined) out.opacity = options.opacity;\r\n if (options.blend !== undefined) out.blend = options.blend;\r\n if (options.space !== undefined) out.space = options.space;\r\n return out;\r\n}\r\n\r\n/**\r\n * Immutable, chainable list of fill layers.\r\n *\r\n * Each builder method returns a new `FillChain` with the layer appended, so\r\n * chains are safe to share and branch — mirroring {@link EffectChain}.\r\n *\r\n * @example\r\n * const bg = Fills.image('./background.jpg', { blend: 'overlay', opacity: 0.2 })\r\n * .color('red', { opacity: 0.3 });\r\n * node.fill = bg; // assign directly\r\n * node.fill = [...bg, 'white']; // spread into an array\r\n */\r\nexport class FillChain {\r\n constructor(public list: FillProp[] = []) { }\r\n\r\n /** Append a solid color fill. A CSS string or normalized `[r,g,b,a]`. */\r\n color(color: Color, options?: FillOptions) {\r\n return new FillChain([...this.list, withOptions({ type: 'solid' as const, color }, options)]);\r\n }\r\n\r\n /**\r\n * Append an image fill from `src`.\r\n *\r\n * @example\r\n * Fills.image('./city.jpg', { zoom: 1.4, anchor: 'topCenter', crop: { bottom: 0.2 } })\r\n */\r\n image(\r\n src: string,\r\n options?: FillOptions & MediaPlacementOptions & {\r\n /** The grade laid over the picture — an adjustment chain plus a 0–1 mix. */\r\n preset?: MediaPresetProp;\r\n /** @deprecated Moved to `preset.adjustments`. Removed in the next major. */\r\n filters?: ImageAdjustment;\r\n },\r\n ) {\r\n const { fit, crop, zoom, anchor, matrix, preset, filters, ...common } = options ?? {};\r\n // Both are forwarded unresolved: `imageFill.resolve` is the one place\r\n // that flattens a chain and folds the deprecated prop into the preset,\r\n // so a fill built here and a fill written as a literal cannot disagree\r\n // about what a grade means.\r\n return new FillChain([...this.list, withOptions({\r\n type: 'image' as const,\r\n src,\r\n fit, crop, zoom, anchor, matrix,\r\n preset, filters,\r\n }, common)]);\r\n }\r\n\r\n /**\r\n * Append a video fill from `src`. Plays by default: its source timestamp is\r\n * derived as it paints, from how long the node carrying the fill has\r\n * existed — so the clip runs wherever the fill is used (fill, overlay,\r\n * stroke, shadow, a custom node's `Graphics2D`) with nothing to advance.\r\n */\r\n video(src: string, options?: VideoFillOptions) {\r\n const { fit, crop, zoom, anchor, matrix, preset, filters, timestamp, playing, trimStart, trimEnd, playStart, speed, loop, duration, ...common } = options ?? {};\r\n return new FillChain([...this.list, withOptions({\r\n type: 'video' as const,\r\n src,\r\n fit, crop, zoom, anchor, matrix, preset, filters,\r\n timestamp,\r\n playing: playing ?? true,\r\n trimStart, trimEnd, playStart, speed, loop, duration,\r\n }, common)]);\r\n }\r\n\r\n\r\n /** Append a linear gradient between `colors`. */\r\n linearGradient(colors: Color[], options?: FillOptions & { stops?: number[]; start?: Vector2; end?: Vector2 }) {\r\n const { stops, start, end, ...common } = options ?? {};\r\n return new FillChain([...this.list, withOptions({ type: 'linear-gradient' as const, colors, stops, start, end }, common)]);\r\n }\r\n\r\n /** Append a radial gradient between `colors`. */\r\n radialGradient(colors: Color[], options?: FillOptions & { stops?: number[]; center?: Vector2; radius?: number }) {\r\n const { stops, center, radius, ...common } = options ?? {};\r\n return new FillChain([...this.list, withOptions({ type: 'radial-gradient' as const, colors, stops, center, radius }, common)]);\r\n }\r\n\r\n /** Append a conic gradient between `colors`. */\r\n conicGradient(colors: Color[], options?: FillOptions & { stops?: number[]; center?: Vector2; startAngle?: number }) {\r\n const { stops, center, startAngle, ...common } = options ?? {};\r\n return new FillChain([...this.list, withOptions({ type: 'conic-gradient' as const, colors, stops, center, startAngle }, common)]);\r\n }\r\n\r\n /** Append a noise (speckle) fill. Tween `seed` to make the static crawl. */\r\n noise(options?: FillOptions & { size?: Vector2; density?: number; color?: Color; seed?: number }) {\r\n const { size, density, color, seed, ...common } = options ?? {};\r\n return new FillChain([...this.list, withOptions({ type: 'noise' as const, size, density, color, seed }, common)]);\r\n }\r\n\r\n /**\r\n * Append a fractal (fBm) noise fill — a continuous field rather than the\r\n * speckle {@link noise} paints. Cloud, marble, smoke, terrain, plasma.\r\n *\r\n * Tween `offset` to travel through the field (it flows); tween `seed` to\r\n * shift to a different field entirely (it churns).\r\n */\r\n fractalNoise(options?: FillOptions & Omit<FractalNoiseFillProp, 'type' | 'opacity' | 'blend'>) {\r\n const {\r\n basis, octaves, frequency, lacunarity, gain, seed, offset, angle,\r\n colors, stops, contrast, ...common\r\n } = options ?? {};\r\n return new FillChain([...this.list, withOptions(\r\n {\r\n type: 'fractalNoise' as const,\r\n basis, octaves, frequency, lacunarity, gain, seed, offset, angle,\r\n colors, stops, contrast,\r\n },\r\n common,\r\n )]);\r\n }\r\n\r\n /**\r\n * Append a custom SkSL shader fill — the escape hatch past {@link noise} and\r\n * {@link fractalNoise}, where the author writes the fragment function.\r\n *\r\n * `source` must declare `vec4 main(vec2 fragCoord)` and return\r\n * **premultiplied** rgba, without folding `opacity` in (the layer's opacity is\r\n * already on the paint, so applying it twice squares it). Uniforms are keyed\r\n * by their declared name and bound by reflecting the compiled program, so\r\n * order is irrelevant; the renderer supplies `u_size`, `u_origin`,\r\n * `u_resolution`, `u_aspect`, `u_time` and `u_scale` to whichever of them the\r\n * source declares.\r\n *\r\n * Keep `source` constant — it is the compile-cache key, so it snaps at a\r\n * tween's midpoint and rebuilding it per frame compiles a program per frame.\r\n * Everything that changes belongs in a uniform, which is an in-place write.\r\n *\r\n * @example\r\n * Fills.shader(GLOW, { uniforms: { u_amount: 0.6 }, coords: 'centered' })\r\n */\r\n shader(\r\n source: string | FillShader,\r\n options?: FillOptions\r\n & Omit<ShaderFillProp, 'type' | 'source' | 'opacity' | 'blend' | 'shaderId'>\r\n & { values?: ShaderPropertyValues },\r\n ) {\r\n const pack = typeof source === 'string' ? undefined : source;\r\n if (pack && pack.scope !== 'fill') {\r\n throw new Error(\r\n `Fills.shader was given a \"${(pack as { scope: string }).scope}\" shader ` +\r\n `(\"${pack.name}\"). An effect shader samples a backdrop a fill does not have; ` +\r\n `use Effects.shader.`,\r\n );\r\n }\r\n const { uniforms, coords, textures, values, ...common } = options ?? {};\r\n // A pack resolves to plain uniforms here; anything passed as `uniforms`\r\n // still wins, matching how an author value overrides a built-in.\r\n const resolved = pack\r\n ? { ...resolveShaderProperties(pack, values), ...normalizeUniforms(uniforms ?? {}) }\r\n : uniforms;\r\n return new FillChain([...this.list, withOptions(\r\n {\r\n type: 'shader' as const,\r\n source: typeof source === 'string' ? source : source.source,\r\n uniforms: resolved,\r\n coords: coords ?? pack?.coords,\r\n textures,\r\n ...(pack?.id !== undefined ? { shaderId: pack.id } : {}),\r\n },\r\n common,\r\n )]);\r\n }\r\n\r\n /** Append a stripe (hatch) fill. */\r\n stripe(options?: FillOptions & { gap?: number; strokeWidth?: number; angle?: number; color?: Color }) {\r\n const { gap, strokeWidth, angle, color, ...common } = options ?? {};\r\n return new FillChain([...this.list, withOptions({ type: 'stripe' as const, gap, strokeWidth, angle, color }, common)]);\r\n }\r\n\r\n /**\r\n * Append a dot-grid fill — a lattice of dots at a pixel pitch.\r\n *\r\n * Tween `offset` to drift the field under a shape that isn't moving; tween\r\n * `spacing` or `radius` to breathe it.\r\n *\r\n * @example\r\n * Fills.dotGrid({ radius: 1.5, spacing: 24, color: 'muted' })\r\n */\r\n dotGrid(options?: FillOptions & Omit<DotGridFillProp, 'type' | 'opacity' | 'blend'>) {\r\n const { radius, spacing, offset, color, ...common } = options ?? {};\r\n return new FillChain([...this.list, withOptions(\r\n { type: 'dotGrid' as const, radius, spacing, offset, color },\r\n common,\r\n )]);\r\n }\r\n\r\n /**\r\n * Append a grid fill — ruled lines dividing the shape into cells, with an\r\n * optional finer ruling nested inside each one.\r\n *\r\n * Sized in divisions of the shape rather than in px (unlike {@link dotGrid}),\r\n * so it holds its structure as the shape resizes.\r\n *\r\n * @example\r\n * Fills.grid({ divisions: 8, subdivisions: 4, color: 'border' })\r\n */\r\n grid(options?: FillOptions & Omit<GridFillProp, 'type' | 'opacity' | 'blend'>) {\r\n const {\r\n divisions, subdivisions, offset, strokeWidth, subdivisionWidth, color, ...common\r\n } = options ?? {};\r\n return new FillChain([...this.list, withOptions(\r\n {\r\n type: 'grid' as const,\r\n divisions, subdivisions, offset, strokeWidth, subdivisionWidth, color,\r\n },\r\n common,\r\n )]);\r\n }\r\n\r\n /**\r\n * Append a 3D scene, painted through the shape's own path.\r\n *\r\n * Takes a **built** {@link Scene3D}, never a builder — per-frame freshness\r\n * comes from where the value is produced (a `renderSelf`, or a `() => …`\r\n * reactive binding), like every other fill.\r\n *\r\n * Note two same-type 3D layers hard-cut rather than cross-fading, because a\r\n * command list has no meaningful in-between. To dissolve between two scenes,\r\n * stack them and tween their opacities in opposite directions.\r\n */\r\n canvas3D(scene: Scene3D, options?: FillOptions & { maxPixelRatio?: number; antialias?: boolean }) {\r\n const { maxPixelRatio, antialias, ...common } = options ?? {};\r\n return new FillChain([...this.list, withOptions({ type: 'canvas3D' as const, scene, maxPixelRatio, antialias }, common)]);\r\n }\r\n\r\n /** Allows spreading the chain into an array: `[...Fills.color('red')]`. */\r\n *[Symbol.iterator]() {\r\n yield* this.list;\r\n }\r\n\r\n /** Serializes to the raw fill array so frameworks that call `toJSON` get a plain value. */\r\n toJSON() {\r\n return this.list;\r\n }\r\n}\r\n\r\n/**\r\n * Accepted shapes for a node's `fill` prop.\r\n *\r\n * Can be a single fill, a `FillChain` builder result, an already-resolved\r\n * {@link FillResolved}, or an array mixing any of these (each chain contributes\r\n * all its layers in place):\r\n *\r\n * 'red' // plain CSS color\r\n * Fills.image('bg.jpg') // chain\r\n * ['#e8c584', Fills.image('bg.jpg')]\r\n * ['#e8c584', ...Fills.image('bg.jpg')]\r\n * resolvedFills // FillResolved[] passes through\r\n */\r\nexport type Fill =\r\n | FillProp\r\n | FillResolved\r\n | FillChain\r\n | (FillProp | FillResolved | FillChain)[];\r\n\r\n/**\r\n * Entry point for building fill chains fluently.\r\n *\r\n * An empty {@link FillChain}, so `Fills.image(src)` *is* `new FillChain().image(src)`\r\n * — every builder's signature and documentation has one definition, on the\r\n * class, which is what an editor shows when you hover `Fills.image`. The chain\r\n * is immutable (each builder returns a new one), so sharing one empty instance\r\n * as the entry point is safe.\r\n *\r\n * @example\r\n * node.fill = Fills.image('./bg.jpg', { opacity: 0.2 }).color('red', { opacity: 0.3 });\r\n */\r\nexport const Fills = new FillChain();\r\n\r\n/**\r\n * Normalises any {@link Fill} value to a plain `FillProp[]`.\r\n * Used by `resolveFillArray` before resolving to the renderer shape.\r\n *\r\n * Already-resolved fills (`FillResolved`) structurally satisfy `FillProp`, so\r\n * they pass straight through and `resolveFill` re-normalises them idempotently.\r\n */\r\nexport function resolveChainFill(fill: Fill | undefined): FillProp[] {\r\n if (fill == null) return [];\r\n if (fill instanceof FillChain) return fill.list;\r\n if (Array.isArray(fill)) {\r\n // Flatten any chains used as array elements so each contributes its\r\n // layers in place: `['#e8c584', Fills.image('bg.jpg')]` — and the plain\r\n // array a chain serializes to, which is how that value reads back out of\r\n // a stored document.\r\n const out: FillProp[] = [];\r\n for (const item of fill) {\r\n if (item instanceof FillChain) out.push(...item.list);\r\n else if (Array.isArray(item)) out.push(...resolveChainFill(item as Fill));\r\n else out.push(item as FillProp);\r\n }\r\n return out;\r\n }\r\n return [fill as FillProp];\r\n}\r\n"]}
1
+ {"version":3,"file":"chain.js","sourceRoot":"","sources":["../../../../src/attributes/shape/fill/chain.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,uBAAuB,EAA6B,MAAM,oBAAoB,CAAC;AA0DxF,mFAAmF;AACnF,SAAS,WAAW,CAAmB,IAAO,EAAE,UAAuB,EAAE;IACrE,MAAM,GAAG,GAAG,EAAE,GAAG,IAAI,EAAqB,CAAC;IAC3C,IAAI,OAAO,CAAC,OAAO,KAAK,SAAS;QAAE,GAAG,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IACjE,IAAI,OAAO,CAAC,KAAK,KAAK,SAAS;QAAE,GAAG,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;IAC3D,IAAI,OAAO,CAAC,KAAK,KAAK,SAAS;QAAE,GAAG,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;IAC3D,OAAO,GAAG,CAAC;AACf,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,SAAS;IACC;IAAnB,YAAmB,OAAmB,EAAE;QAArB,SAAI,GAAJ,IAAI,CAAiB;IAAI,CAAC;IAE7C,yEAAyE;IACzE,KAAK,CAAC,KAAY,EAAE,OAAqB;QACrC,OAAO,IAAI,SAAS,CAAC,CAAC,GAAG,IAAI,CAAC,IAAI,EAAE,WAAW,CAAC,EAAE,IAAI,EAAE,OAAgB,EAAE,KAAK,EAAE,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IAClG,CAAC;IAED;;;;;OAKG;IACH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I,IAAI,IAAI,IAAI;QAAE,OAAO,EAAE,CAAC;IAC5B,IAAI,IAAI,YAAY,SAAS;QAAE,OAAO,IAAI,CAAC,IAAI,CAAC;IAChD,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QACtB,oEAAoE;QACpE,wEAAwE;QACxE,yEAAyE;QACzE,qBAAqB;QACrB,MAAM,GAAG,GAAe,EAAE,CAAC;QAC3B,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE,CAAC;YACtB,IAAI,IAAI,YAAY,SAAS;gBAAE,GAAG,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC;iBACjD,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;gBAAE,GAAG,CAAC,IAAI,CAAC,GAAG,gBAAgB,CAAC,IAAY,CAAC,CAAC,CAAC;;gBACrE,GAAG,CAAC,IAAI,CAAC,IAAgB,CAAC,CAAC;QACpC,CAAC;QACD,OAAO,GAAG,CAAC;IACf,CAAC;IACD,OAAO,CAAC,IAAgB,CAAC,CAAC;AAC9B,CAAC","sourcesContent":["import type { Color } from \"./color/parser\";\r\nimport type { BlendMode } from \"./blend\";\r\nimport type { Vector2 } from \"@/attributes/layout/vector2\";\r\nimport type { ImageAdjustment, VideoAdjustment } from \"../filters/chain\";\r\nimport type { MediaPresetProp, VideoPresetProp } from \"./media-preset\";\r\nimport type { FillProp, FillResolved, FillSpace } from \"./union\";\r\nimport { normalizeUniforms } from \"../shaders/uniforms\";\r\nimport { resolveShaderProperties, type ShaderPropertyValues } from \"../shaders/resolve\";\r\nimport type { FillShader } from \"../shaders/pack\";\r\nimport type { ImageCrop, ImageFit, ImageMatrix } from \"./implementations/image\";\r\nimport type { Alignment } from \"@/attributes/layout/alignment\";\r\nimport type { FractalNoiseFillProp } from \"./implementations/fractal-noise\";\r\nimport type { DotGridFillProp } from \"./implementations/dot-grid\";\r\nimport type { GridFillProp } from \"./implementations/grid\";\r\nimport type { ShaderFillProp } from \"./implementations/shader\";\r\nimport type { Scene3D } from \"@/render3d/scene3d\";\r\n\r\n/** Placement options shared by the image and video fill builders. */\r\nexport interface MediaPlacementOptions {\r\n /** How the (cropped) source is scaled into the node's bounds. Default `'fill'`. */\r\n fit?: ImageFit;\r\n /** Window onto the source, in fractions of its own size, applied before `fit`. */\r\n crop?: ImageCrop;\r\n /** Magnification on top of the fitted scale. `1` is the fitted size. */\r\n zoom?: number;\r\n /** The point held fixed as `zoom` scales; also the alignment when it doesn't cover. */\r\n anchor?: Alignment;\r\n /** Raw source→shape matrix; bypasses `crop`/`fit`/`zoom`/`anchor` and the bounds. */\r\n matrix?: ImageMatrix;\r\n}\r\n\r\n/** Author-facing options for a {@link FillChain.video} layer. */\r\nexport interface VideoFillOptions extends FillOptions, MediaPlacementOptions {\r\n /** The grade laid over the footage — an adjustment chain plus a 0–1 mix. */\r\n preset?: VideoPresetProp;\r\n /** @deprecated Moved to `preset.adjustments`. Removed in the next major. */\r\n filters?: VideoAdjustment;\r\n /**\r\n * Explicit source time to paint, in seconds. Omit it and the clip plays by\r\n * itself, timed from the moment the node painting it appeared — set it only\r\n * to drive the playhead yourself (`null` hands the playhead back).\r\n */\r\n timestamp?: number | null;\r\n /** Whether playback advances with the node's clock. Defaults to `true`. */\r\n playing?: boolean;\r\n trimStart?: number;\r\n trimEnd?: number;\r\n /** Seconds after the painting node appears before playback begins. Default `0`. */\r\n playStart?: number;\r\n speed?: number;\r\n loop?: 'forward' | 'reverse' | 'none';\r\n duration?: number;\r\n}\r\n\r\n/**\r\n * Cross-cutting options shared by every fill layer. These map onto the\r\n * `opacity` / `blend` fields each fill prop already accepts, plus the\r\n * `space` directive carried generically by the registry.\r\n */\r\nexport interface FillOptions {\r\n opacity?: number;\r\n blend?: BlendMode;\r\n space?: FillSpace;\r\n}\r\n\r\n/** Strip `undefined` option keys so the produced props stay minimal/comparable. */\r\nfunction withOptions<T extends object>(base: T, options: FillOptions = {}): T & FillOptions {\r\n const out = { ...base } as T & FillOptions;\r\n if (options.opacity !== undefined) out.opacity = options.opacity;\r\n if (options.blend !== undefined) out.blend = options.blend;\r\n if (options.space !== undefined) out.space = options.space;\r\n return out;\r\n}\r\n\r\n/**\r\n * Immutable, chainable list of fill layers.\r\n *\r\n * Each builder method returns a new `FillChain` with the layer appended, so\r\n * chains are safe to share and branch — mirroring {@link EffectChain}.\r\n *\r\n * @example\r\n * const bg = Fills.image('./background.jpg', { blend: 'overlay', opacity: 0.2 })\r\n * .color('red', { opacity: 0.3 });\r\n * node.fill = bg; // assign directly\r\n * node.fill = [...bg, 'white']; // spread into an array\r\n */\r\nexport class FillChain {\r\n constructor(public list: FillProp[] = []) { }\r\n\r\n /** Append a solid color fill. A CSS string or normalized `[r,g,b,a]`. */\r\n color(color: Color, options?: FillOptions) {\r\n return new FillChain([...this.list, withOptions({ type: 'solid' as const, color }, options)]);\r\n }\r\n\r\n /**\r\n * Append an image fill from `src`.\r\n *\r\n * @example\r\n * Fills.image('./city.jpg', { zoom: 1.4, anchor: 'topCenter', crop: { bottom: 0.2 } })\r\n */\r\n image(\r\n src: string,\r\n options?: FillOptions & MediaPlacementOptions & {\r\n /** The grade laid over the picture — an adjustment chain plus a 0–1 mix. */\r\n preset?: MediaPresetProp;\r\n /** @deprecated Moved to `preset.adjustments`. Removed in the next major. */\r\n filters?: ImageAdjustment;\r\n },\r\n ) {\r\n const { fit, crop, zoom, anchor, matrix, preset, filters, ...common } = options ?? {};\r\n // Both are forwarded unresolved: `imageFill.resolve` is the one place\r\n // that flattens a chain and folds the deprecated prop into the preset,\r\n // so a fill built here and a fill written as a literal cannot disagree\r\n // about what a grade means.\r\n return new FillChain([...this.list, withOptions({\r\n type: 'image' as const,\r\n src,\r\n fit, crop, zoom, anchor, matrix,\r\n preset, filters,\r\n }, common)]);\r\n }\r\n\r\n /**\r\n * Append a video fill from `src`. Plays by default: its source timestamp is\r\n * derived as it paints, from how long the node carrying the fill has\r\n * existed — so the clip runs wherever the fill is used (fill, overlay,\r\n * stroke, shadow, a custom node's `Graphics2D`) with nothing to advance.\r\n */\r\n video(src: string, options?: VideoFillOptions) {\r\n const { fit, crop, zoom, anchor, matrix, preset, filters, timestamp, playing, trimStart, trimEnd, playStart, speed, loop, duration, ...common } = options ?? {};\r\n return new FillChain([...this.list, withOptions({\r\n type: 'video' as const,\r\n src,\r\n fit, crop, zoom, anchor, matrix, preset, filters,\r\n timestamp,\r\n playing: playing ?? true,\r\n trimStart, trimEnd, playStart, speed, loop, duration,\r\n }, common)]);\r\n }\r\n\r\n\r\n /** Append a linear gradient between `colors`. */\r\n linearGradient(colors: Color[], options?: FillOptions & { stops?: number[]; start?: Vector2; end?: Vector2 }) {\r\n const { stops, start, end, ...common } = options ?? {};\r\n return new FillChain([...this.list, withOptions({ type: 'linear-gradient' as const, colors, stops, start, end }, common)]);\r\n }\r\n\r\n /** Append a radial gradient between `colors`. */\r\n radialGradient(colors: Color[], options?: FillOptions & { stops?: number[]; center?: Vector2; radius?: number }) {\r\n const { stops, center, radius, ...common } = options ?? {};\r\n return new FillChain([...this.list, withOptions({ type: 'radial-gradient' as const, colors, stops, center, radius }, common)]);\r\n }\r\n\r\n /** Append a conic gradient between `colors`. */\r\n conicGradient(colors: Color[], options?: FillOptions & { stops?: number[]; center?: Vector2; startAngle?: number }) {\r\n const { stops, center, startAngle, ...common } = options ?? {};\r\n return new FillChain([...this.list, withOptions({ type: 'conic-gradient' as const, colors, stops, center, startAngle }, common)]);\r\n }\r\n\r\n /** Append a noise (speckle) fill. Tween `seed` to make the static crawl. */\r\n noise(options?: FillOptions & { size?: Vector2; density?: number; color?: Color; seed?: number }) {\r\n const { size, density, color, seed, ...common } = options ?? {};\r\n return new FillChain([...this.list, withOptions({ type: 'noise' as const, size, density, color, seed }, common)]);\r\n }\r\n\r\n /**\r\n * Append a fractal (fBm) noise fill — a continuous field rather than the\r\n * speckle {@link noise} paints. Cloud, marble, smoke, terrain, plasma.\r\n *\r\n * Tween `offset` to travel through the field (it flows); tween `seed` to\r\n * shift to a different field entirely (it churns).\r\n */\r\n fractalNoise(options?: FillOptions & Omit<FractalNoiseFillProp, 'type' | 'opacity' | 'blend'>) {\r\n const {\r\n basis, octaves, frequency, lacunarity, gain, seed, offset, angle,\r\n colors, stops, contrast, ...common\r\n } = options ?? {};\r\n return new FillChain([...this.list, withOptions(\r\n {\r\n type: 'fractalNoise' as const,\r\n basis, octaves, frequency, lacunarity, gain, seed, offset, angle,\r\n colors, stops, contrast,\r\n },\r\n common,\r\n )]);\r\n }\r\n\r\n /**\r\n * Append a custom shader fill — the escape hatch past {@link noise} and\r\n * {@link fractalNoise}, where the author writes the fragment function.\r\n *\r\n * The WGSL `source` defines `fn fill(in: FillIn) -> vec4f` and declares its\r\n * uniforms as `struct Params`, read as `u.<name>`. It returns\r\n * **premultiplied** rgba, without folding `opacity` in (the layer's opacity is\r\n * already applied, so applying it twice squares it). Uniforms are keyed by\r\n * their declared name, so order is irrelevant.\r\n *\r\n * Keep `source` constant — it is the compile-cache key, so it snaps at a\r\n * tween's midpoint and rebuilding it per frame compiles a program per frame.\r\n * Everything that changes belongs in a uniform, which is an in-place write.\r\n *\r\n * @example\r\n * Fills.shader(GLOW, { uniforms: { amount: 0.6 } })\r\n */\r\n shader(\r\n source: string | FillShader,\r\n options?: FillOptions\r\n & Omit<ShaderFillProp, 'type' | 'source' | 'language' | 'opacity' | 'blend' | 'shaderId'>\r\n & { values?: ShaderPropertyValues },\r\n ) {\r\n const pack = typeof source === 'string' ? undefined : source;\r\n if (pack && pack.scope !== 'fill') {\r\n throw new Error(\r\n `Fills.shader was given a \"${(pack as { scope: string }).scope}\" shader ` +\r\n `(\"${pack.name}\"). An effect shader samples a backdrop a fill does not have; ` +\r\n `use Effects.shader.`,\r\n );\r\n }\r\n const { uniforms, textures, values, ...common } = options ?? {};\r\n // A pack resolves to plain uniforms here; anything passed as `uniforms`\r\n // still wins, matching how an author value overrides a built-in.\r\n const resolved = pack\r\n ? { ...resolveShaderProperties(pack, values), ...normalizeUniforms(uniforms ?? {}) }\r\n : uniforms;\r\n return new FillChain([...this.list, withOptions(\r\n {\r\n type: 'shader' as const,\r\n source: typeof source === 'string' ? source : source.source,\r\n language: 'wgsl' as const,\r\n uniforms: resolved,\r\n textures,\r\n ...(pack?.id !== undefined ? { shaderId: pack.id } : {}),\r\n },\r\n common,\r\n )]);\r\n }\r\n\r\n /** Append a stripe (hatch) fill. */\r\n stripe(options?: FillOptions & { gap?: number; strokeWidth?: number; angle?: number; color?: Color }) {\r\n const { gap, strokeWidth, angle, color, ...common } = options ?? {};\r\n return new FillChain([...this.list, withOptions({ type: 'stripe' as const, gap, strokeWidth, angle, color }, common)]);\r\n }\r\n\r\n /**\r\n * Append a dot-grid fill — a lattice of dots at a pixel pitch.\r\n *\r\n * Tween `offset` to drift the field under a shape that isn't moving; tween\r\n * `spacing` or `radius` to breathe it.\r\n *\r\n * @example\r\n * Fills.dotGrid({ radius: 1.5, spacing: 24, color: 'muted' })\r\n */\r\n dotGrid(options?: FillOptions & Omit<DotGridFillProp, 'type' | 'opacity' | 'blend'>) {\r\n const { radius, spacing, offset, color, ...common } = options ?? {};\r\n return new FillChain([...this.list, withOptions(\r\n { type: 'dotGrid' as const, radius, spacing, offset, color },\r\n common,\r\n )]);\r\n }\r\n\r\n /**\r\n * Append a grid fill — ruled lines dividing the shape into cells, with an\r\n * optional finer ruling nested inside each one.\r\n *\r\n * Sized in divisions of the shape rather than in px (unlike {@link dotGrid}),\r\n * so it holds its structure as the shape resizes.\r\n *\r\n * @example\r\n * Fills.grid({ divisions: 8, subdivisions: 4, color: 'border' })\r\n */\r\n grid(options?: FillOptions & Omit<GridFillProp, 'type' | 'opacity' | 'blend'>) {\r\n const {\r\n divisions, subdivisions, offset, strokeWidth, subdivisionWidth, color, ...common\r\n } = options ?? {};\r\n return new FillChain([...this.list, withOptions(\r\n {\r\n type: 'grid' as const,\r\n divisions, subdivisions, offset, strokeWidth, subdivisionWidth, color,\r\n },\r\n common,\r\n )]);\r\n }\r\n\r\n /**\r\n * Append a 3D scene, painted through the shape's own path.\r\n *\r\n * Takes a **built** {@link Scene3D}, never a builder — per-frame freshness\r\n * comes from where the value is produced (a `renderSelf`, or a `() => …`\r\n * reactive binding), like every other fill.\r\n *\r\n * Note two same-type 3D layers hard-cut rather than cross-fading, because a\r\n * command list has no meaningful in-between. To dissolve between two scenes,\r\n * stack them and tween their opacities in opposite directions.\r\n */\r\n canvas3D(scene: Scene3D, options?: FillOptions & { maxPixelRatio?: number; antialias?: boolean }) {\r\n const { maxPixelRatio, antialias, ...common } = options ?? {};\r\n return new FillChain([...this.list, withOptions({ type: 'canvas3D' as const, scene, maxPixelRatio, antialias }, common)]);\r\n }\r\n\r\n /** Allows spreading the chain into an array: `[...Fills.color('red')]`. */\r\n *[Symbol.iterator]() {\r\n yield* this.list;\r\n }\r\n\r\n /** Serializes to the raw fill array so frameworks that call `toJSON` get a plain value. */\r\n toJSON() {\r\n return this.list;\r\n }\r\n}\r\n\r\n/**\r\n * Accepted shapes for a node's `fill` prop.\r\n *\r\n * Can be a single fill, a `FillChain` builder result, an already-resolved\r\n * {@link FillResolved}, or an array mixing any of these (each chain contributes\r\n * all its layers in place):\r\n *\r\n * 'red' // plain CSS color\r\n * Fills.image('bg.jpg') // chain\r\n * ['#e8c584', Fills.image('bg.jpg')]\r\n * ['#e8c584', ...Fills.image('bg.jpg')]\r\n * resolvedFills // FillResolved[] passes through\r\n */\r\nexport type Fill =\r\n | FillProp\r\n | FillResolved\r\n | FillChain\r\n | (FillProp | FillResolved | FillChain)[];\r\n\r\n/**\r\n * Entry point for building fill chains fluently.\r\n *\r\n * An empty {@link FillChain}, so `Fills.image(src)` *is* `new FillChain().image(src)`\r\n * — every builder's signature and documentation has one definition, on the\r\n * class, which is what an editor shows when you hover `Fills.image`. The chain\r\n * is immutable (each builder returns a new one), so sharing one empty instance\r\n * as the entry point is safe.\r\n *\r\n * @example\r\n * node.fill = Fills.image('./bg.jpg', { opacity: 0.2 }).color('red', { opacity: 0.3 });\r\n */\r\nexport const Fills = new FillChain();\r\n\r\n/**\r\n * Normalises any {@link Fill} value to a plain `FillProp[]`.\r\n * Used by `resolveFillArray` before resolving to the renderer shape.\r\n *\r\n * Already-resolved fills (`FillResolved`) structurally satisfy `FillProp`, so\r\n * they pass straight through and `resolveFill` re-normalises them idempotently.\r\n */\r\nexport function resolveChainFill(fill: Fill | undefined): FillProp[] {\r\n if (fill == null) return [];\r\n if (fill instanceof FillChain) return fill.list;\r\n if (Array.isArray(fill)) {\r\n // Flatten any chains used as array elements so each contributes its\r\n // layers in place: `['#e8c584', Fills.image('bg.jpg')]` — and the plain\r\n // array a chain serializes to, which is how that value reads back out of\r\n // a stored document.\r\n const out: FillProp[] = [];\r\n for (const item of fill) {\r\n if (item instanceof FillChain) out.push(...item.list);\r\n else if (Array.isArray(item)) out.push(...resolveChainFill(item as Fill));\r\n else out.push(item as FillProp);\r\n }\r\n return out;\r\n }\r\n return [fill as FillProp];\r\n}\r\n"]}
@@ -1,16 +1,22 @@
1
1
  import type { BlendMode } from '../blend.js';
2
2
  import type { FillData } from '../registry.js';
3
- import { type ShaderFillCoords, type SkSLUniform, type SkSLUniformRecord } from '../../sksl-uniforms.js';
4
- export type { ShaderFillCoords };
5
- /** An image bound to one of the shader's `uniform shader` declarations. */
3
+ import { type ShaderUniform, type ShaderUniformRecord } from '../../shaders/uniforms.js';
4
+ import { type ShaderLanguage } from '../../shaders/language.js';
5
+ /** An image the shader samples. */
6
6
  export interface ShaderTexture {
7
- /** The `uniform shader` name in the source this image binds to. */
7
+ /** The name the shader pack gives this texture. */
8
8
  name: string;
9
9
  /** Asset path, resolved like any other image fill's `src`. */
10
10
  src: string;
11
11
  }
12
12
  /**
13
- * A custom SkSL shader, painted as a fill.
13
+ * A custom WGSL shader, painted as a fill.
14
+ *
15
+ * The source defines `fn fill(in: FillIn) -> vec4f`, returning **premultiplied**
16
+ * rgba; `in` carries `uv` (0–1 across the box), `local` (px from the box's
17
+ * top-left), `size`, `time` and `scale` (device px per px), and the uniforms are
18
+ * `u`, a `struct Params` the source declares. The first of `textures` is what
19
+ * `sample_texture(uv)` reads.
14
20
  *
15
21
  * The escape hatch at the end of the procedural spectrum: where
16
22
  * {@link NoiseFillProp} and {@link FractalNoiseFillProp} expose a fixed set of
@@ -19,21 +25,12 @@ export interface ShaderTexture {
19
25
  * `Path`, a run of `Text` — stacks as one layer in the fill array, and inherits
20
26
  * the layer's `opacity`/`blend`/`space` like every other kind.
21
27
  *
22
- * Rect({ fill: Fills.shader(src, { uniforms: { u_amount: 0.4 } }) })
28
+ * Rect({ fill: Fills.shader(src, { uniforms: { amount: 0.4 } }) })
23
29
  * Text({ text: "DEPTH", fontSize: 320, fill: Fills.shader(src) })
24
30
  *
25
- * The contract on the source is `vec4 main(vec2 fragCoord)` returning
26
- * **premultiplied** rgba. It must *not* fold `opacity` in: the fill layer's
27
- * opacity is already on the paint as an alpha the shader's output is modulated
28
- * by, so a shader applying it again renders at the square of what was asked for.
29
- * That is also why no `u_alpha` built-in is offered.
30
- *
31
- * Uniforms are supplied **by name**, not by position, and marshalled by
32
- * reflecting the compiled program. So declaration order doesn't matter, a
33
- * declared-but-unsupplied uniform reads as zero with a warning instead of
34
- * silently refusing to paint, and the renderer can fill in built-ins
35
- * (`u_size`, `u_origin`, `u_resolution`, `u_aspect`, `u_time`, `u_scale`) for
36
- * whichever of them the source happens to declare.
31
+ * It must *not* fold `opacity` in: the fill layer's opacity is already applied
32
+ * to the output, so a shader applying it again renders at the square of what
33
+ * was asked for.
37
34
  *
38
35
  * `source` is the compile-cache key, so it **snaps** at a tween's midpoint rather
39
36
  * than interpolating — tweening it would compile a program per frame. Keep the
@@ -42,8 +39,12 @@ export interface ShaderTexture {
42
39
  */
43
40
  export interface ShaderFillProp {
44
41
  type: 'shader';
45
- /** SkSL source declaring `vec4 main(vec2 fragCoord)`. Hoist it; don't rebuild it per frame. */
42
+ /** The program. Hoist it; don't rebuild it per frame. */
46
43
  source: string;
44
+ /** The language `source` is written in; WGSL when absent. */
45
+ language?: ShaderLanguage;
46
+ /** WGSL only: the contract version it is written against (`WGSL_CONTRACT` when absent). */
47
+ contract?: number;
47
48
  /**
48
49
  * The shader pack this was built from, when it was built from one.
49
50
  *
@@ -61,14 +62,12 @@ export interface ShaderFillProp {
61
62
  */
62
63
  shaderId?: string;
63
64
  /**
64
- * Uniform values keyed by their declared name. The `sksl` effect's positional
65
+ * Uniform values keyed by their declared name. The positional
65
66
  * `[{name, value}]` array is accepted too, so a shader can move between an
66
67
  * effect and a fill unchanged.
67
68
  */
68
- uniforms?: SkSLUniformRecord | readonly SkSLUniform[];
69
- /** What `fragCoord` means. Default `'normalized'`. See {@link ShaderFillCoords}. */
70
- coords?: ShaderFillCoords;
71
- /** Images bound to the source's `uniform shader` declarations, matched by name. */
69
+ uniforms?: ShaderUniformRecord | readonly ShaderUniform[];
70
+ /** Images the shader samples. */
72
71
  textures?: readonly ShaderTexture[];
73
72
  opacity?: number;
74
73
  blend?: BlendMode;
@@ -76,10 +75,12 @@ export interface ShaderFillProp {
76
75
  export interface ShaderFillResolved {
77
76
  type: 'shader';
78
77
  source: string;
78
+ language: ShaderLanguage;
79
+ /** WGSL only. See {@link ShaderFillProp.contract}. */
80
+ contract?: number;
79
81
  /** See {@link ShaderFillProp.shaderId}. */
80
82
  shaderId?: string;
81
- uniforms: SkSLUniformRecord;
82
- coords: ShaderFillCoords;
83
+ uniforms: ShaderUniformRecord;
83
84
  textures?: ShaderTexture[];
84
85
  opacity?: number;
85
86
  blend?: BlendMode;
@@ -1 +1 @@
1
- {"version":3,"file":"shader.d.ts","sourceRoot":"","sources":["../../../../../src/attributes/shape/fill/implementations/shader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAIH,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,KA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