motionary 10.9.0 → 11.0.0

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 (406) hide show
  1. package/AGENTS.md +1 -1
  2. package/CHANGELOG.md +32 -0
  3. package/README.md +119 -74
  4. package/README_ja.md +4 -4
  5. package/README_zh.md +4 -4
  6. package/dist/chunks/{anim-image-CnZDYmtv.js → anim-image-Btw3j5Qb.js} +2 -2
  7. package/dist/chunks/{anim-image-CnZDYmtv.js.map → anim-image-Btw3j5Qb.js.map} +1 -1
  8. package/dist/chunks/{anim-image-D1JZ7wOU.cjs → anim-image-DVv_vtbG.cjs} +2 -2
  9. package/dist/chunks/{anim-image-D1JZ7wOU.cjs.map → anim-image-DVv_vtbG.cjs.map} +1 -1
  10. package/dist/chunks/{three-scene-DibsZUID.js → gl-scene-BDA6FlGQ.js} +5 -11
  11. package/dist/chunks/gl-scene-BDA6FlGQ.js.map +1 -0
  12. package/dist/chunks/{three-scene-BFZnZuqp.cjs → gl-scene-SO5UU93S.cjs} +3 -10
  13. package/dist/chunks/gl-scene-SO5UU93S.cjs.map +1 -0
  14. package/dist/chunks/{keyframes-uYSI-do7.cjs → keyframes-4rb2WShh.cjs} +2 -2
  15. package/dist/chunks/{keyframes-uYSI-do7.cjs.map → keyframes-4rb2WShh.cjs.map} +1 -1
  16. package/dist/chunks/{keyframes-CLoYRGjR.js → keyframes-C9poRyzF.js} +2 -2
  17. package/dist/chunks/{keyframes-CLoYRGjR.js.map → keyframes-C9poRyzF.js.map} +1 -1
  18. package/dist/chunks/{lottie-player-UJHOl-8L.js → lottie-player-CPdwHhqe.js} +2 -2
  19. package/dist/chunks/{lottie-player-UJHOl-8L.js.map → lottie-player-CPdwHhqe.js.map} +1 -1
  20. package/dist/chunks/{lottie-player-Mcpt1H5w.cjs → lottie-player-DD1pnLN2.cjs} +2 -2
  21. package/dist/chunks/{lottie-player-Mcpt1H5w.cjs.map → lottie-player-DD1pnLN2.cjs.map} +1 -1
  22. package/dist/chunks/{physics-playground-BxnQyZ_V.cjs → physics-playground-B00t13Nz.cjs} +2 -2
  23. package/dist/chunks/{physics-playground-BxnQyZ_V.cjs.map → physics-playground-B00t13Nz.cjs.map} +1 -1
  24. package/dist/chunks/{physics-playground-B19qANJs.js → physics-playground-CluT_Nj9.js} +2 -2
  25. package/dist/chunks/{physics-playground-B19qANJs.js.map → physics-playground-CluT_Nj9.js.map} +1 -1
  26. package/dist/chunks/{registry-RJYrdUTF.js → registry-W7pXOwju.js} +3 -3
  27. package/dist/chunks/{registry-RJYrdUTF.js.map → registry-W7pXOwju.js.map} +1 -1
  28. package/dist/chunks/{registry-xGDPpmX2.cjs → registry-uaO8pDKn.cjs} +3 -3
  29. package/dist/chunks/{registry-xGDPpmX2.cjs.map → registry-uaO8pDKn.cjs.map} +1 -1
  30. package/dist/chunks/{runtime-link-GD9ayzxH.cjs → runtime-link-Bz3rGMsh.cjs} +2 -2
  31. package/dist/chunks/{runtime-link-GD9ayzxH.cjs.map → runtime-link-Bz3rGMsh.cjs.map} +1 -1
  32. package/dist/chunks/{runtime-link-CQyKFwE1.js → runtime-link-CP3qaRja.js} +2 -2
  33. package/dist/chunks/{runtime-link-CQyKFwE1.js.map → runtime-link-CP3qaRja.js.map} +1 -1
  34. package/dist/chunks/{scroll-scene-C-6sdMtR.cjs → scroll-scene-CeIosbEs.cjs} +3 -3
  35. package/dist/chunks/{scroll-scene-C-6sdMtR.cjs.map → scroll-scene-CeIosbEs.cjs.map} +1 -1
  36. package/dist/chunks/{scroll-scene-DtAaP0Aa.js → scroll-scene-eHhGcoDQ.js} +3 -3
  37. package/dist/chunks/{scroll-scene-DtAaP0Aa.js.map → scroll-scene-eHhGcoDQ.js.map} +1 -1
  38. package/dist/chunks/{ticker-C4VkAL4Y.js → ticker-D0qF_rV_.js} +2 -2
  39. package/dist/chunks/{ticker-C4VkAL4Y.js.map → ticker-D0qF_rV_.js.map} +1 -1
  40. package/dist/chunks/{ticker-DJuzcy1_.cjs → ticker-nshSbZ-Q.cjs} +2 -2
  41. package/dist/chunks/{ticker-DJuzcy1_.cjs.map → ticker-nshSbZ-Q.cjs.map} +1 -1
  42. package/dist/chunks/{tween-BHbiOBWO.cjs → tween-Df87h-1G.cjs} +2 -2
  43. package/dist/chunks/{tween-BHbiOBWO.cjs.map → tween-Df87h-1G.cjs.map} +1 -1
  44. package/dist/chunks/{tween-CrnzMeOU.js → tween-WepVA7id.js} +2 -2
  45. package/dist/chunks/{tween-CrnzMeOU.js.map → tween-WepVA7id.js.map} +1 -1
  46. package/dist/chunks/{worker-canvas-Bkwd1euX.js → worker-canvas-BZNHRLcu.js} +50 -3
  47. package/dist/chunks/worker-canvas-BZNHRLcu.js.map +1 -0
  48. package/dist/chunks/{worker-canvas-Ckc3R2Ye.cjs → worker-canvas-DW3VgtxO.cjs} +50 -2
  49. package/dist/chunks/worker-canvas-DW3VgtxO.cjs.map +1 -0
  50. package/dist/components/dotlottie.cjs +3 -3
  51. package/dist/components/dotlottie.d.cts +2 -1
  52. package/dist/components/dotlottie.d.ts +2 -1
  53. package/dist/components/dotlottie.js +3 -3
  54. package/dist/components/fx-perf.cjs +10 -5
  55. package/dist/components/fx-perf.cjs.map +1 -1
  56. package/dist/components/fx-perf.d.cts +6 -1
  57. package/dist/components/fx-perf.d.ts +6 -1
  58. package/dist/components/fx-perf.js +11 -6
  59. package/dist/components/fx-perf.js.map +1 -1
  60. package/dist/components/fx2.d.cts +6 -1
  61. package/dist/components/fx2.d.ts +6 -1
  62. package/dist/components/gl-model.cjs +3 -3
  63. package/dist/components/gl-model.d.cts +1 -1
  64. package/dist/components/gl-model.d.ts +1 -1
  65. package/dist/components/gl-model.js +3 -3
  66. package/dist/components/snap-carousel.cjs +2 -2
  67. package/dist/components/snap-carousel.js +2 -2
  68. package/dist/components/widgets.cjs +9 -9
  69. package/dist/components/widgets.cjs.map +1 -1
  70. package/dist/components/widgets.d.cts +10 -9
  71. package/dist/components/widgets.d.ts +10 -9
  72. package/dist/components/widgets.js +12 -12
  73. package/dist/components/widgets.js.map +1 -1
  74. package/dist/llms-full.txt +301 -312
  75. package/dist/llms.txt +3 -4
  76. package/dist/manifest.json +271 -299
  77. package/dist/runtime/drag-snap.cjs +1 -1
  78. package/dist/runtime/drag-snap.js +1 -1
  79. package/dist/runtime/format-apng.cjs +4 -4
  80. package/dist/runtime/format-apng.js +4 -4
  81. package/dist/runtime/format-css.cjs +4 -4
  82. package/dist/runtime/format-css.js +4 -4
  83. package/dist/runtime/format-gif.cjs +4 -4
  84. package/dist/runtime/format-gif.js +4 -4
  85. package/dist/runtime/format-gltf.cjs +1 -1
  86. package/dist/runtime/format-gltf.js +1 -1
  87. package/dist/runtime/format-motion.cjs +4 -4
  88. package/dist/runtime/format-motion.js +4 -4
  89. package/dist/runtime/format-obj.cjs +1 -1
  90. package/dist/runtime/format-obj.js +1 -1
  91. package/dist/runtime/format-scene.cjs +1 -1
  92. package/dist/runtime/format-scene.js +1 -1
  93. package/dist/runtime/format-sprite.cjs +3 -3
  94. package/dist/runtime/format-sprite.js +3 -3
  95. package/dist/runtime/format-svg.cjs +3 -3
  96. package/dist/runtime/format-svg.js +3 -3
  97. package/dist/runtime/format-webp.cjs +4 -4
  98. package/dist/runtime/format-webp.js +4 -4
  99. package/dist/runtime/gl.cjs +1 -1
  100. package/dist/runtime/gl.js +1 -1
  101. package/dist/runtime/gltf-anim.cjs +1 -1
  102. package/dist/runtime/gltf-anim.js +1 -1
  103. package/dist/runtime/gltf-decoders.cjs +1 -1
  104. package/dist/runtime/gltf-decoders.js +1 -1
  105. package/dist/runtime/lottie-state.cjs +1 -1
  106. package/dist/runtime/lottie-state.js +1 -1
  107. package/dist/runtime/physics.cjs +1 -1
  108. package/dist/runtime/physics.js +1 -1
  109. package/dist/runtime/scroll.cjs +2 -2
  110. package/dist/runtime/scroll.js +2 -2
  111. package/dist/runtime/smooth.cjs +1 -1
  112. package/dist/runtime/smooth.js +1 -1
  113. package/dist/runtime/text.cjs +1 -1
  114. package/dist/runtime/text.js +1 -1
  115. package/dist/runtime/vector.cjs +66 -17
  116. package/dist/runtime/vector.cjs.map +1 -1
  117. package/dist/runtime/vector.d.cts +30 -6
  118. package/dist/runtime/vector.d.ts +30 -6
  119. package/dist/runtime/vector.iife.js +1 -1
  120. package/dist/runtime/vector.iife.js.map +1 -1
  121. package/dist/runtime/vector.js +65 -18
  122. package/dist/runtime/vector.js.map +1 -1
  123. package/dist/runtime.cjs +3 -3
  124. package/dist/runtime.d.cts +2 -2
  125. package/dist/runtime.d.ts +2 -2
  126. package/dist/runtime.iife.js +1 -1
  127. package/dist/runtime.iife.js.map +1 -1
  128. package/dist/runtime.js +5 -5
  129. package/dist/widgets/dotlottie.cjs +3 -3
  130. package/dist/widgets/dotlottie.js +3 -3
  131. package/dist/widgets/gl-model.cjs +3 -3
  132. package/dist/widgets/gl-model.js +3 -3
  133. package/dist/widgets/gl-scene.cjs +3 -3
  134. package/dist/widgets/gl-scene.js +3 -3
  135. package/dist/widgets/install-button.cjs.map +1 -1
  136. package/dist/widgets/install-button.js.map +1 -1
  137. package/dist/widgets/lottie-player.cjs +3 -3
  138. package/dist/widgets/lottie-player.js +3 -3
  139. package/dist/widgets/motion-inspector.cjs +1 -1
  140. package/dist/widgets/motion-inspector.js +1 -1
  141. package/dist/widgets/physics-playground.cjs +3 -3
  142. package/dist/widgets/physics-playground.js +3 -3
  143. package/dist/widgets/plugin-card.cjs +2 -2
  144. package/dist/widgets/plugin-card.js +2 -2
  145. package/dist/widgets/scroll-scene.cjs +3 -3
  146. package/dist/widgets/scroll-scene.js +3 -3
  147. package/dist/widgets/smooth-scroll.cjs +2 -2
  148. package/dist/widgets/smooth-scroll.js +2 -2
  149. package/dist/widgets/snap-carousel.cjs +2 -2
  150. package/dist/widgets/snap-carousel.js +2 -2
  151. package/dist/widgets/text-splitter.cjs +2 -2
  152. package/dist/widgets/text-splitter.js +2 -2
  153. package/dist/widgets/worker-canvas.cjs +1 -1
  154. package/dist/widgets/worker-canvas.js +1 -1
  155. package/dist/widgets.umd.js +1 -1
  156. package/dist/widgets.umd.js.map +1 -1
  157. package/docs/ROADMAP.md +44 -4
  158. package/docs/architecture.md +78 -0
  159. package/docs/compat-matrix.md +340 -0
  160. package/docs/components/README.md +1 -5
  161. package/docs/components/usa-accordion.md +1 -1
  162. package/docs/components/usa-acrylic.md +1 -1
  163. package/docs/components/usa-add-to-cart.md +1 -1
  164. package/docs/components/usa-ambient.md +1 -1
  165. package/docs/components/usa-anim-icon.md +1 -1
  166. package/docs/components/usa-audio.md +1 -1
  167. package/docs/components/usa-aurora.md +1 -1
  168. package/docs/components/usa-auto-animate.md +1 -1
  169. package/docs/components/usa-auto-skeleton.md +1 -1
  170. package/docs/components/usa-avatar-stack.md +1 -1
  171. package/docs/components/usa-back-to-top.md +1 -1
  172. package/docs/components/usa-badge-wall.md +1 -1
  173. package/docs/components/usa-badge.md +1 -1
  174. package/docs/components/usa-bar-chart.md +1 -1
  175. package/docs/components/usa-bg-generator.md +1 -1
  176. package/docs/components/usa-blobs.md +1 -1
  177. package/docs/components/usa-bottom-sheet.md +1 -1
  178. package/docs/components/usa-button.md +1 -1
  179. package/docs/components/usa-card-stack.md +1 -1
  180. package/docs/components/usa-card.md +1 -1
  181. package/docs/components/usa-carousel-3d.md +1 -1
  182. package/docs/components/usa-carousel.md +1 -1
  183. package/docs/components/usa-cart-drawer.md +1 -1
  184. package/docs/components/usa-chapter-nav.md +1 -1
  185. package/docs/components/usa-chat-composer.md +1 -1
  186. package/docs/components/usa-check.md +1 -1
  187. package/docs/components/usa-checkbox.md +1 -1
  188. package/docs/components/usa-click.md +1 -1
  189. package/docs/components/usa-clock-control.md +1 -1
  190. package/docs/components/usa-code-export.md +1 -1
  191. package/docs/components/usa-color-picker.md +1 -1
  192. package/docs/components/usa-command-palette.md +1 -1
  193. package/docs/components/usa-compare.md +1 -1
  194. package/docs/components/usa-countdown.md +1 -1
  195. package/docs/components/usa-counter.md +1 -1
  196. package/docs/components/usa-cube-gallery.md +1 -1
  197. package/docs/components/usa-cube.md +1 -1
  198. package/docs/components/usa-cursor.md +1 -1
  199. package/docs/components/usa-date-picker.md +1 -1
  200. package/docs/components/usa-depth.md +1 -1
  201. package/docs/components/usa-dialog.md +1 -1
  202. package/docs/components/usa-disclosure.md +1 -1
  203. package/docs/components/usa-distort.md +1 -1
  204. package/docs/components/usa-dock.md +1 -1
  205. package/docs/components/usa-dot-network.md +1 -1
  206. package/docs/components/usa-dotlottie.md +6 -6
  207. package/docs/components/usa-double-tap.md +1 -1
  208. package/docs/components/usa-draggable.md +1 -1
  209. package/docs/components/usa-draw.md +1 -1
  210. package/docs/components/usa-drawer.md +1 -1
  211. package/docs/components/usa-equalizer.md +1 -1
  212. package/docs/components/usa-fab.md +1 -1
  213. package/docs/components/usa-festival-banner.md +1 -1
  214. package/docs/components/usa-field.md +1 -1
  215. package/docs/components/usa-file-drop.md +1 -1
  216. package/docs/components/usa-fullpage.md +1 -1
  217. package/docs/components/usa-fx.md +1 -1
  218. package/docs/components/usa-gauge.md +1 -1
  219. package/docs/components/usa-gen-art.md +1 -1
  220. package/docs/components/usa-gesture-fx.md +1 -1
  221. package/docs/components/usa-gesture-sticker.md +1 -1
  222. package/docs/components/usa-gl-model.md +7 -7
  223. package/docs/components/usa-gl-scene.md +10 -10
  224. package/docs/components/usa-glitch.md +1 -1
  225. package/docs/components/usa-globe.md +1 -1
  226. package/docs/components/usa-gpu-particles.md +1 -1
  227. package/docs/components/usa-gradient-text.md +1 -1
  228. package/docs/components/usa-grain.md +1 -1
  229. package/docs/components/usa-grid-glow.md +1 -1
  230. package/docs/components/usa-gyro-card.md +1 -1
  231. package/docs/components/usa-handwriting.md +1 -1
  232. package/docs/components/usa-hero-video.md +1 -1
  233. package/docs/components/usa-hold.md +1 -1
  234. package/docs/components/usa-hud-panel.md +1 -1
  235. package/docs/components/usa-hydrate.md +1 -1
  236. package/docs/components/usa-icon-morph.md +1 -1
  237. package/docs/components/usa-install-button.md +3 -3
  238. package/docs/components/usa-kanban.md +1 -1
  239. package/docs/components/usa-keyframe-editor.md +1 -1
  240. package/docs/components/usa-kpi.md +1 -1
  241. package/docs/components/usa-leaderboard.md +1 -1
  242. package/docs/components/usa-like.md +1 -1
  243. package/docs/components/usa-liquid-nav.md +1 -1
  244. package/docs/components/usa-liquid.md +1 -1
  245. package/docs/components/usa-loading-bar.md +1 -1
  246. package/docs/components/usa-location-card.md +1 -1
  247. package/docs/components/usa-lottie-icon.md +1 -1
  248. package/docs/components/usa-lottie-player.md +5 -5
  249. package/docs/components/usa-lottie.md +1 -1
  250. package/docs/components/usa-lyrics.md +1 -1
  251. package/docs/components/usa-magnetic.md +1 -1
  252. package/docs/components/usa-marquee.md +1 -1
  253. package/docs/components/usa-mask-reveal.md +1 -1
  254. package/docs/components/usa-masonry-flow.md +1 -1
  255. package/docs/components/usa-masonry.md +1 -1
  256. package/docs/components/usa-menu-toggle.md +1 -1
  257. package/docs/components/usa-menu.md +1 -1
  258. package/docs/components/usa-message-list.md +1 -1
  259. package/docs/components/usa-milestones.md +1 -1
  260. package/docs/components/usa-modal.md +1 -1
  261. package/docs/components/usa-morph.md +1 -1
  262. package/docs/components/usa-motion-inspector.md +1 -1
  263. package/docs/components/usa-motion-prefs.md +1 -1
  264. package/docs/components/usa-motion-prompt.md +1 -1
  265. package/docs/components/usa-motion-spec.md +1 -1
  266. package/docs/components/usa-motion-switch.md +1 -1
  267. package/docs/components/usa-motion-theme.md +1 -1
  268. package/docs/components/usa-motion.md +1 -1
  269. package/docs/components/usa-music-player.md +1 -1
  270. package/docs/components/usa-native-preview.md +1 -1
  271. package/docs/components/usa-nav-morph.md +1 -1
  272. package/docs/components/usa-navbar.md +1 -1
  273. package/docs/components/usa-notification-bell.md +1 -1
  274. package/docs/components/usa-odometer.md +1 -1
  275. package/docs/components/usa-organic-card.md +1 -1
  276. package/docs/components/usa-otp.md +1 -1
  277. package/docs/components/usa-overscroll.md +1 -1
  278. package/docs/components/usa-pack.md +1 -1
  279. package/docs/components/usa-pagination.md +1 -1
  280. package/docs/components/usa-panorama.md +1 -1
  281. package/docs/components/usa-parallax-layers.md +1 -1
  282. package/docs/components/usa-particles.md +1 -1
  283. package/docs/components/usa-pause-all.md +1 -1
  284. package/docs/components/usa-perf-monitor.md +1 -1
  285. package/docs/components/usa-physics-playground.md +6 -6
  286. package/docs/components/usa-pinch-zoom.md +1 -1
  287. package/docs/components/usa-player.md +1 -1
  288. package/docs/components/usa-plugin-card.md +4 -4
  289. package/docs/components/usa-plugin-store.md +1 -1
  290. package/docs/components/usa-popover.md +1 -1
  291. package/docs/components/usa-post-fx.md +1 -1
  292. package/docs/components/usa-presence.md +1 -1
  293. package/docs/components/usa-press.md +1 -1
  294. package/docs/components/usa-prize-wheel.md +1 -1
  295. package/docs/components/usa-product-gallery.md +1 -1
  296. package/docs/components/usa-progress-ring.md +1 -1
  297. package/docs/components/usa-progress.md +1 -1
  298. package/docs/components/usa-prop-panel.md +1 -1
  299. package/docs/components/usa-pull-cord.md +1 -1
  300. package/docs/components/usa-pull-refresh.md +1 -1
  301. package/docs/components/usa-radar.md +1 -1
  302. package/docs/components/usa-reactions.md +1 -1
  303. package/docs/components/usa-red-envelope.md +1 -1
  304. package/docs/components/usa-retro-button.md +1 -1
  305. package/docs/components/usa-reveal.md +1 -1
  306. package/docs/components/usa-ripple.md +1 -1
  307. package/docs/components/usa-rive.md +3 -3
  308. package/docs/components/usa-route-transition.md +1 -1
  309. package/docs/components/usa-scene.md +1 -1
  310. package/docs/components/usa-scramble.md +1 -1
  311. package/docs/components/usa-scroll-highlight.md +1 -1
  312. package/docs/components/usa-scroll-progress.md +1 -1
  313. package/docs/components/usa-scroll-ring.md +1 -1
  314. package/docs/components/usa-scroll-scene.md +5 -5
  315. package/docs/components/usa-scrolly.md +1 -1
  316. package/docs/components/usa-segmented.md +1 -1
  317. package/docs/components/usa-shader-backdrop.md +1 -1
  318. package/docs/components/usa-shader.md +1 -1
  319. package/docs/components/usa-sheet.md +1 -1
  320. package/docs/components/usa-shimmer-text.md +1 -1
  321. package/docs/components/usa-shortcut.md +1 -1
  322. package/docs/components/usa-skeleton-reveal.md +1 -1
  323. package/docs/components/usa-skeleton.md +1 -1
  324. package/docs/components/usa-sketch-chart.md +1 -1
  325. package/docs/components/usa-slider.md +1 -1
  326. package/docs/components/usa-smooth-scroll.md +5 -5
  327. package/docs/components/usa-snap-carousel.md +5 -5
  328. package/docs/components/usa-sparkline.md +1 -1
  329. package/docs/components/usa-spatial-card.md +1 -1
  330. package/docs/components/usa-spinner.md +1 -1
  331. package/docs/components/usa-splash.md +1 -1
  332. package/docs/components/usa-split-text.md +1 -1
  333. package/docs/components/usa-spotlight.md +1 -1
  334. package/docs/components/usa-spring.md +1 -1
  335. package/docs/components/usa-stagger.md +1 -1
  336. package/docs/components/usa-star-rating.md +1 -1
  337. package/docs/components/usa-stepper.md +1 -1
  338. package/docs/components/usa-sticky-stack.md +1 -1
  339. package/docs/components/usa-sticky-wall.md +1 -1
  340. package/docs/components/usa-stories.md +1 -1
  341. package/docs/components/usa-story.md +1 -1
  342. package/docs/components/usa-suggestion-chips.md +1 -1
  343. package/docs/components/usa-swipe-deck.md +1 -1
  344. package/docs/components/usa-swipeable.md +1 -1
  345. package/docs/components/usa-switch.md +1 -1
  346. package/docs/components/usa-tab-bar.md +1 -1
  347. package/docs/components/usa-tabs.md +1 -1
  348. package/docs/components/usa-terminal.md +1 -1
  349. package/docs/components/usa-text-rotate.md +1 -1
  350. package/docs/components/usa-text-splitter.md +5 -5
  351. package/docs/components/usa-theme-surface.md +1 -1
  352. package/docs/components/usa-theme-switcher.md +1 -1
  353. package/docs/components/usa-tilt.md +1 -1
  354. package/docs/components/usa-timeline.md +1 -1
  355. package/docs/components/usa-tip.md +1 -1
  356. package/docs/components/usa-toast-stack.md +1 -1
  357. package/docs/components/usa-toaster.md +1 -1
  358. package/docs/components/usa-token-editor.md +1 -1
  359. package/docs/components/usa-typewriter.md +1 -1
  360. package/docs/components/usa-upload-progress.md +1 -1
  361. package/docs/components/usa-video-card.md +1 -1
  362. package/docs/components/usa-view-switch.md +1 -1
  363. package/docs/components/usa-voice-button.md +1 -1
  364. package/docs/components/usa-volume-knob.md +1 -1
  365. package/docs/components/usa-water-ripple.md +1 -1
  366. package/docs/components/usa-wave-text.md +1 -1
  367. package/docs/components/usa-weather-card.md +1 -1
  368. package/docs/components/usa-worker-canvas.md +1 -1
  369. package/docs/components/usa-xp-bar.md +1 -1
  370. package/docs/components.md +49 -49
  371. package/docs/deprecations.md +2 -0
  372. package/docs/entry-points.md +1 -2
  373. package/docs/runtime/core.md +2 -2
  374. package/docs/runtime/drag-snap.md +3 -3
  375. package/docs/runtime/format-apng.md +3 -3
  376. package/docs/runtime/format-css.md +3 -3
  377. package/docs/runtime/format-gif.md +3 -3
  378. package/docs/runtime/format-gltf.md +3 -3
  379. package/docs/runtime/format-motion.md +3 -3
  380. package/docs/runtime/format-obj.md +3 -3
  381. package/docs/runtime/format-scene.md +3 -3
  382. package/docs/runtime/format-sprite.md +3 -3
  383. package/docs/runtime/format-svg.md +3 -3
  384. package/docs/runtime/format-webp.md +3 -3
  385. package/docs/runtime/gl.md +3 -3
  386. package/docs/runtime/gltf-anim.md +3 -3
  387. package/docs/runtime/gltf-decoders.md +3 -3
  388. package/docs/runtime/lottie-state.md +3 -3
  389. package/docs/runtime/physics.md +3 -3
  390. package/docs/runtime/scroll.md +3 -3
  391. package/docs/runtime/smooth.md +3 -3
  392. package/docs/runtime/text.md +3 -3
  393. package/docs/runtime/vector.md +3 -3
  394. package/docs/upgrading-11.md +2 -2
  395. package/package.json +1 -11
  396. package/dist/chunks/three-scene-BFZnZuqp.cjs.map +0 -1
  397. package/dist/chunks/three-scene-DibsZUID.js.map +0 -1
  398. package/dist/chunks/worker-canvas-Bkwd1euX.js.map +0 -1
  399. package/dist/chunks/worker-canvas-Ckc3R2Ye.cjs.map +0 -1
  400. package/dist/widgets/three-scene.cjs +0 -11
  401. package/dist/widgets/three-scene.cjs.map +0 -1
  402. package/dist/widgets/three-scene.d.cts +0 -2
  403. package/dist/widgets/three-scene.d.ts +0 -2
  404. package/dist/widgets/three-scene.js +0 -5
  405. package/dist/widgets/three-scene.js.map +0 -1
  406. package/docs/components/usa-three-scene.md +0 -20
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worker-canvas-BZNHRLcu.js","sources":["../../src/components/widgets/worker-canvas.ts"],"sourcesContent":["import { defineElement, type UsaElement } from '../base';\nimport { offscreenRender, type DrawProgram } from '../fx2/perf3';\nimport css from './worker-canvas.css?raw';\n\n/**\n * `<usa-worker-canvas scene=\"particles\">` (9.6) — a canvas animation that\n * renders in a Web Worker on an OffscreenCanvas (main thread stays free;\n * falls back to the shared frame loop): built-in `scene` = `particles` ·\n * `orbits` · `starfield`, or your own `program` (a function\n * `(ctx, t, w, h, state) => {…}`; 11.0: a source string only runs in a worker). Only runs while on screen.\n * `data-usa-backend` shows `worker` or `main`; `backend` property;\n * `usa:backend` { backend }. An `img` with `label`; reduced motion: one\n * still frame.\n */\nexport interface UsaWorkerCanvasElement extends UsaElement {\n program: DrawProgram | null;\n readonly backend: string;\n}\n\nexport const WORKER_SCENES: Record<string, string> = {\n particles: `function (ctx, t, w, h, s) { if (!s.p) { s.p = Array.from({ length: 90 }, (_, i) => ({ x: (i * 97) % w, y: (i * 53) % h, vx: Math.cos(i) * 0.6, vy: Math.sin(i * 1.3) * 0.6, r: 1 + (i % 3) })); } ctx.fillStyle = 'rgba(15,23,42,0.25)'; ctx.fillRect(0, 0, w, h); for (const q of s.p) { q.x = (q.x + q.vx + w) % w; q.y = (q.y + q.vy + h) % h; ctx.beginPath(); ctx.arc(q.x, q.y, q.r, 0, 6.283); ctx.fillStyle = 'hsl(' + ((q.x / w) * 120 + 200) + ',90%,65%)'; ctx.fill(); } }`,\n orbits: `function (ctx, t, w, h) { ctx.fillStyle = '#0f172a'; ctx.fillRect(0, 0, w, h); for (let i = 1; i <= 6; i++) { const a = t / (400 + i * 180); const r = i * Math.min(w, h) / 14; ctx.strokeStyle = 'rgba(148,163,184,0.25)'; ctx.beginPath(); ctx.arc(w / 2, h / 2, r, 0, 6.283); ctx.stroke(); ctx.beginPath(); ctx.arc(w / 2 + Math.cos(a) * r, h / 2 + Math.sin(a) * r, 3 + i / 2, 0, 6.283); ctx.fillStyle = 'hsl(' + i * 50 + ',85%,65%)'; ctx.fill(); } }`,\n starfield: `function (ctx, t, w, h, s) { if (!s.st) { s.st = Array.from({ length: 140 }, (_, i) => ({ x: ((i * 7919) % 1000) / 500 - 1, y: ((i * 104729) % 1000) / 500 - 1, z: (i % 100) / 100 + 0.01 })); } ctx.fillStyle = '#020617'; ctx.fillRect(0, 0, w, h); for (const q of s.st) { q.z -= 0.004; if (q.z <= 0.01) q.z = 1; const x = w / 2 + (q.x / q.z) * w / 4, y = h / 2 + (q.y / q.z) * h / 4; ctx.fillStyle = 'rgba(255,255,255,' + (1 - q.z) + ')'; ctx.fillRect(x, y, 2 - q.z, 2 - q.z); } }`,\n};\n\ntype SceneFn = (ctx: CanvasRenderingContext2D, t: number, w: number, h: number, s: any) => void;\n/** The built-in scenes as functions — the main-thread fallback when no worker / OffscreenCanvas is available (11.0: strings are never evaluated on the main thread). Same drawing as `WORKER_SCENES`. */\nexport const WORKER_SCENE_FNS: Record<string, SceneFn> = {\n particles(ctx, _t, w, h, s) {\n if (!s.p) s.p = Array.from({ length: 90 }, (_, i) => ({ x: (i * 97) % w, y: (i * 53) % h, vx: Math.cos(i) * 0.6, vy: Math.sin(i * 1.3) * 0.6, r: 1 + (i % 3) }));\n ctx.fillStyle = 'rgba(15,23,42,0.25)';\n ctx.fillRect(0, 0, w, h);\n for (const q of s.p) {\n q.x = (q.x + q.vx + w) % w;\n q.y = (q.y + q.vy + h) % h;\n ctx.beginPath();\n ctx.arc(q.x, q.y, q.r, 0, 6.283);\n ctx.fillStyle = 'hsl(' + ((q.x / w) * 120 + 200) + ',90%,65%)';\n ctx.fill();\n }\n },\n orbits(ctx, t, w, h) {\n ctx.fillStyle = '#0f172a';\n ctx.fillRect(0, 0, w, h);\n for (let i = 1; i <= 6; i++) {\n const a = t / (400 + i * 180);\n const r = (i * Math.min(w, h)) / 14;\n ctx.strokeStyle = 'rgba(148,163,184,0.25)';\n ctx.beginPath();\n ctx.arc(w / 2, h / 2, r, 0, 6.283);\n ctx.stroke();\n ctx.beginPath();\n ctx.arc(w / 2 + Math.cos(a) * r, h / 2 + Math.sin(a) * r, 3 + i / 2, 0, 6.283);\n ctx.fillStyle = 'hsl(' + i * 50 + ',85%,65%)';\n ctx.fill();\n }\n },\n starfield(ctx, _t, w, h, s) {\n if (!s.st) s.st = Array.from({ length: 140 }, (_, i) => ({ x: ((i * 7919) % 1000) / 500 - 1, y: ((i * 104729) % 1000) / 500 - 1, z: (i % 100) / 100 + 0.01 }));\n ctx.fillStyle = '#020617';\n ctx.fillRect(0, 0, w, h);\n for (const q of s.st) {\n q.z -= 0.004;\n if (q.z <= 0.01) q.z = 1;\n const x = w / 2 + ((q.x / q.z) * w) / 4,\n y = h / 2 + ((q.y / q.z) * h) / 4;\n ctx.fillStyle = 'rgba(255,255,255,' + (1 - q.z) + ')';\n ctx.fillRect(x, y, 2 - q.z, 2 - q.z);\n }\n },\n};\n\nexport function defineWorkerCanvas(tag = 'usa-worker-canvas'): CustomElementConstructor | undefined {\n return defineElement(\n tag,\n (Base) => {\n class UsaWorkerCanvas extends Base {\n static get observedAttributes(): string[] {\n return ['scene', 'label'];\n }\n private _prog: DrawProgram | null = null;\n private _backend = 'none';\n get program(): DrawProgram | null {\n return this._prog;\n }\n set program(p: DrawProgram | null) {\n this._prog = p;\n if (this.isConnected) this.changed('program');\n }\n get backend(): string {\n return this._backend;\n }\n mount(): void {\n this.querySelectorAll(':scope > canvas[data-usa-part]').forEach((n) => n.remove());\n const scene = WORKER_SCENES[this.str('scene')] ? this.str('scene') : 'particles';\n this.setAttribute('role', 'img');\n this.setAttribute('aria-label', this.str('label', `Animated ${scene}`));\n const c = document.createElement('canvas');\n c.setAttribute('data-usa-part', '');\n c.width = Math.max(60, Math.round(this.clientWidth || 300));\n c.height = Math.max(40, Math.round(this.clientHeight || 160));\n this.prepend(c);\n const r = offscreenRender(c, this._prog || WORKER_SCENES[scene], { paused: this.reduced, fallback: this._prog ? undefined : WORKER_SCENE_FNS[scene] });\n this._backend = r.backend;\n this.setAttribute('data-usa-backend', r.backend);\n this.emit('backend', { backend: r.backend });\n this.onCleanup(() => r.stop());\n }\n }\n return UsaWorkerCanvas as unknown as CustomElementConstructor;\n },\n { id: 'worker-canvas', text: css }\n );\n}\n"],"names":[],"mappings":";;;;;AAmBO,MAAM,aAAa,GAA2B;AACnD,IAAA,SAAS,EAAE,CAAA,qdAAA,CAAud;AACle,IAAA,MAAM,EAAE,CAAA,8bAAA,CAAgc;AACxc,IAAA,SAAS,EAAE,CAAA,8dAAA,CAAge;;AAI7e;AACO,MAAM,gBAAgB,GAA4B;IACvD,SAAS,CAAC,GAAG,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAA;QACxB,IAAI,CAAC,CAAC,CAAC,CAAC;AAAE,YAAA,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE,EAAE,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,EAAE,EAAE,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC;AAChK,QAAA,GAAG,CAAC,SAAS,GAAG,qBAAqB;QACrC,GAAG,CAAC,QAAQ,CAAC,CAAC,EAAE,C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AAY,CAAC,kBAAkB,EAAE,CAAC,CAAC,OAAO,CAAC;AAChD,gBAAA,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC;gBAC5C,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC;YAChC;AACD;AACD,QAAA,OAAO,eAAsD;IAC/D,CAAC,EACD,EAAE,EAAE,EAAE,eAAe,EAAE,IAAI,EAAE,GAAG,EAAE,CACnC;AACH;;"}
@@ -10,6 +10,53 @@ const WORKER_SCENES = {
10
10
  orbits: `function (ctx, t, w, h) { ctx.fillStyle = '#0f172a'; ctx.fillRect(0, 0, w, h); for (let i = 1; i <= 6; i++) { const a = t / (400 + i * 180); const r = i * Math.min(w, h) / 14; ctx.strokeStyle = 'rgba(148,163,184,0.25)'; ctx.beginPath(); ctx.arc(w / 2, h / 2, r, 0, 6.283); ctx.stroke(); ctx.beginPath(); ctx.arc(w / 2 + Math.cos(a) * r, h / 2 + Math.sin(a) * r, 3 + i / 2, 0, 6.283); ctx.fillStyle = 'hsl(' + i * 50 + ',85%,65%)'; ctx.fill(); } }`,
11
11
  starfield: `function (ctx, t, w, h, s) { if (!s.st) { s.st = Array.from({ length: 140 }, (_, i) => ({ x: ((i * 7919) % 1000) / 500 - 1, y: ((i * 104729) % 1000) / 500 - 1, z: (i % 100) / 100 + 0.01 })); } ctx.fillStyle = '#020617'; ctx.fillRect(0, 0, w, h); for (const q of s.st) { q.z -= 0.004; if (q.z <= 0.01) q.z = 1; const x = w / 2 + (q.x / q.z) * w / 4, y = h / 2 + (q.y / q.z) * h / 4; ctx.fillStyle = 'rgba(255,255,255,' + (1 - q.z) + ')'; ctx.fillRect(x, y, 2 - q.z, 2 - q.z); } }`,
12
12
  };
13
+ /** The built-in scenes as functions — the main-thread fallback when no worker / OffscreenCanvas is available (11.0: strings are never evaluated on the main thread). Same drawing as `WORKER_SCENES`. */
14
+ const WORKER_SCENE_FNS = {
15
+ particles(ctx, _t, w, h, s) {
16
+ if (!s.p)
17
+ s.p = Array.from({ length: 90 }, (_, i) => ({ x: (i * 97) % w, y: (i * 53) % h, vx: Math.cos(i) * 0.6, vy: Math.sin(i * 1.3) * 0.6, r: 1 + (i % 3) }));
18
+ ctx.fillStyle = 'rgba(15,23,42,0.25)';
19
+ ctx.fillRect(0, 0, w, h);
20
+ for (const q of s.p) {
21
+ q.x = (q.x + q.vx + w) % w;
22
+ q.y = (q.y + q.vy + h) % h;
23
+ ctx.beginPath();
24
+ ctx.arc(q.x, q.y, q.r, 0, 6.283);
25
+ ctx.fillStyle = 'hsl(' + ((q.x / w) * 120 + 200) + ',90%,65%)';
26
+ ctx.fill();
27
+ }
28
+ },
29
+ orbits(ctx, t, w, h) {
30
+ ctx.fillStyle = '#0f172a';
31
+ ctx.fillRect(0, 0, w, h);
32
+ for (let i = 1; i <= 6; i++) {
33
+ const a = t / (400 + i * 180);
34
+ const r = (i * Math.min(w, h)) / 14;
35
+ ctx.strokeStyle = 'rgba(148,163,184,0.25)';
36
+ ctx.beginPath();
37
+ ctx.arc(w / 2, h / 2, r, 0, 6.283);
38
+ ctx.stroke();
39
+ ctx.beginPath();
40
+ ctx.arc(w / 2 + Math.cos(a) * r, h / 2 + Math.sin(a) * r, 3 + i / 2, 0, 6.283);
41
+ ctx.fillStyle = 'hsl(' + i * 50 + ',85%,65%)';
42
+ ctx.fill();
43
+ }
44
+ },
45
+ starfield(ctx, _t, w, h, s) {
46
+ if (!s.st)
47
+ s.st = Array.from({ length: 140 }, (_, i) => ({ x: ((i * 7919) % 1000) / 500 - 1, y: ((i * 104729) % 1000) / 500 - 1, z: (i % 100) / 100 + 0.01 }));
48
+ ctx.fillStyle = '#020617';
49
+ ctx.fillRect(0, 0, w, h);
50
+ for (const q of s.st) {
51
+ q.z -= 0.004;
52
+ if (q.z <= 0.01)
53
+ q.z = 1;
54
+ const x = w / 2 + ((q.x / q.z) * w) / 4, y = h / 2 + ((q.y / q.z) * h) / 4;
55
+ ctx.fillStyle = 'rgba(255,255,255,' + (1 - q.z) + ')';
56
+ ctx.fillRect(x, y, 2 - q.z, 2 - q.z);
57
+ }
58
+ },
59
+ };
13
60
  function defineWorkerCanvas(tag = 'usa-worker-canvas') {
14
61
  return base.defineElement(tag, (Base) => {
15
62
  class UsaWorkerCanvas extends Base {
@@ -42,7 +89,7 @@ function defineWorkerCanvas(tag = 'usa-worker-canvas') {
42
89
  c.width = Math.max(60, Math.round(this.clientWidth || 300));
43
90
  c.height = Math.max(40, Math.round(this.clientHeight || 160));
44
91
  this.prepend(c);
45
- const r = components_fxPerf.offscreenRender(c, this._prog || WORKER_SCENES[scene], { paused: this.reduced });
92
+ const r = components_fxPerf.offscreenRender(c, this._prog || WORKER_SCENES[scene], { paused: this.reduced, fallback: this._prog ? undefined : WORKER_SCENE_FNS[scene] });
46
93
  this._backend = r.backend;
47
94
  this.setAttribute('data-usa-backend', r.backend);
48
95
  this.emit('backend', { backend: r.backend });
@@ -54,5 +101,6 @@ function defineWorkerCanvas(tag = 'usa-worker-canvas') {
54
101
  }
55
102
 
56
103
  exports.WORKER_SCENES = WORKER_SCENES;
104
+ exports.WORKER_SCENE_FNS = WORKER_SCENE_FNS;
57
105
  exports.defineWorkerCanvas = defineWorkerCanvas;
58
- //# sourceMappingURL=worker-canvas-Ckc3R2Ye.cjs.map
106
+ //# sourceMappingURL=worker-canvas-DW3VgtxO.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worker-canvas-DW3VgtxO.cjs","sources":["../../src/components/widgets/worker-canvas.ts"],"sourcesContent":["import { defineElement, type UsaElement } from '../base';\nimport { offscreenRender, type DrawProgram } from '../fx2/perf3';\nimport css from './worker-canvas.css?raw';\n\n/**\n * `<usa-worker-canvas scene=\"particles\">` (9.6) — a canvas animation that\n * renders in a Web Worker on an OffscreenCanvas (main thread stays free;\n * falls back to the shared frame loop): built-in `scene` = `particles` ·\n * `orbits` · `starfield`, or your own `program` (a function\n * `(ctx, t, w, h, state) => {…}`; 11.0: a source string only runs in a worker). Only runs while on screen.\n * `data-usa-backend` shows `worker` or `main`; `backend` property;\n * `usa:backend` { backend }. An `img` with `label`; reduced motion: one\n * still frame.\n */\nexport interface UsaWorkerCanvasElement extends UsaElement {\n program: DrawProgram | null;\n readonly backend: string;\n}\n\nexport const WORKER_SCENES: Record<string, string> = {\n particles: `function (ctx, t, w, h, s) { if (!s.p) { s.p = Array.from({ length: 90 }, (_, i) => ({ x: (i * 97) % w, y: (i * 53) % h, vx: Math.cos(i) * 0.6, vy: Math.sin(i * 1.3) * 0.6, r: 1 + (i % 3) })); } ctx.fillStyle = 'rgba(15,23,42,0.25)'; ctx.fillRect(0, 0, w, h); for (const q of s.p) { q.x = (q.x + q.vx + w) % w; q.y = (q.y + q.vy + h) % h; ctx.beginPath(); ctx.arc(q.x, q.y, q.r, 0, 6.283); ctx.fillStyle = 'hsl(' + ((q.x / w) * 120 + 200) + ',90%,65%)'; ctx.fill(); } }`,\n orbits: `function (ctx, t, w, h) { ctx.fillStyle = '#0f172a'; ctx.fillRect(0, 0, w, h); for (let i = 1; i <= 6; i++) { const a = t / (400 + i * 180); const r = i * Math.min(w, h) / 14; ctx.strokeStyle = 'rgba(148,163,184,0.25)'; ctx.beginPath(); ctx.arc(w / 2, h / 2, r, 0, 6.283); ctx.stroke(); ctx.beginPath(); ctx.arc(w / 2 + Math.cos(a) * r, h / 2 + Math.sin(a) * r, 3 + i / 2, 0, 6.283); ctx.fillStyle = 'hsl(' + i * 50 + ',85%,65%)'; ctx.fill(); } }`,\n starfield: `function (ctx, t, w, h, s) { if (!s.st) { s.st = Array.from({ length: 140 }, (_, i) => ({ x: ((i * 7919) % 1000) / 500 - 1, y: ((i * 104729) % 1000) / 500 - 1, z: (i % 100) / 100 + 0.01 })); } ctx.fillStyle = '#020617'; ctx.fillRect(0, 0, w, h); for (const q of s.st) { q.z -= 0.004; if (q.z <= 0.01) q.z = 1; const x = w / 2 + (q.x / q.z) * w / 4, y = h / 2 + (q.y / q.z) * h / 4; ctx.fillStyle = 'rgba(255,255,255,' + (1 - q.z) + ')'; ctx.fillRect(x, y, 2 - q.z, 2 - q.z); } }`,\n};\n\ntype SceneFn = (ctx: CanvasRenderingContext2D, t: number, w: number, h: number, s: any) => void;\n/** The built-in scenes as functions — the main-thread fallback when no worker / OffscreenCanvas is available (11.0: strings are never evaluated on the main thread). Same drawing as `WORKER_SCENES`. */\nexport const WORKER_SCENE_FNS: Record<string, SceneFn> = {\n particles(ctx, _t, w, h, s) {\n if (!s.p) s.p = Array.from({ length: 90 }, (_, i) => ({ x: (i * 97) % w, y: (i * 53) % h, vx: Math.cos(i) * 0.6, vy: Math.sin(i * 1.3) * 0.6, r: 1 + (i % 3) }));\n ctx.fillStyle = 'rgba(15,23,42,0.25)';\n ctx.fillRect(0, 0, w, h);\n for (const q of s.p) {\n q.x = (q.x + q.vx + w) % w;\n q.y = (q.y + q.vy + h) % h;\n ctx.beginPath();\n ctx.arc(q.x, q.y, q.r, 0, 6.283);\n ctx.fillStyle = 'hsl(' + ((q.x / w) * 120 + 200) + ',90%,65%)';\n ctx.fill();\n }\n },\n orbits(ctx, t, w, h) {\n ctx.fillStyle = '#0f172a';\n ctx.fillRect(0, 0, w, h);\n for (let i = 1; i <= 6; i++) {\n const a = t / (400 + i * 180);\n const r = (i * Math.min(w, h)) / 14;\n ctx.strokeStyle = 'rgba(148,163,184,0.25)';\n ctx.beginPath();\n ctx.arc(w / 2, h / 2, r, 0, 6.283);\n ctx.stroke();\n ctx.beginPath();\n ctx.arc(w / 2 + Math.cos(a) * r, h / 2 + Math.sin(a) * r, 3 + i / 2, 0, 6.283);\n ctx.fillStyle = 'hsl(' + i * 50 + ',85%,65%)';\n ctx.fill();\n }\n },\n starfield(ctx, _t, w, h, s) {\n if (!s.st) s.st = Array.from({ length: 140 }, (_, i) => ({ x: ((i * 7919) % 1000) / 500 - 1, y: ((i * 104729) % 1000) / 500 - 1, z: (i % 100) / 100 + 0.01 }));\n ctx.fillStyle = '#020617';\n ctx.fillRect(0, 0, w, h);\n for (const q of s.st) {\n q.z -= 0.004;\n if (q.z <= 0.01) q.z = 1;\n const x = w / 2 + ((q.x / q.z) * w) / 4,\n y = h / 2 + ((q.y / q.z) * h) / 4;\n ctx.fillStyle = 'rgba(255,255,255,' + (1 - q.z) + ')';\n ctx.fillRect(x, y, 2 - q.z, 2 - q.z);\n }\n },\n};\n\nexport function defineWorkerCanvas(tag = 'usa-worker-canvas'): CustomElementConstructor | undefined {\n return defineElement(\n tag,\n (Base) => {\n class UsaWorkerCanvas extends Base {\n static get observedAttributes(): string[] {\n return ['scene', 'label'];\n }\n private _prog: DrawProgram | null = null;\n private _backend = 'none';\n get program(): DrawProgram | null {\n return this._prog;\n }\n set program(p: DrawProgram | null) {\n this._prog = p;\n if (this.isConnected) this.changed('program');\n }\n get backend(): string {\n return this._backend;\n }\n mount(): void {\n this.querySelectorAll(':scope > canvas[data-usa-part]').forEach((n) => n.remove());\n const scene = WORKER_SCENES[this.str('scene')] ? this.str('scene') : 'particles';\n this.setAttribute('role', 'img');\n this.setAttribute('aria-label', this.str('label', `Animated ${scene}`));\n const c = document.createElement('canvas');\n c.setAttribute('data-usa-part', '');\n c.width = Math.max(60, Math.round(this.clientWidth || 300));\n c.height = Math.max(40, Math.round(this.clientHeight || 160));\n this.prepend(c);\n const r = offscreenRender(c, this._prog || WORKER_SCENES[scene], { paused: this.reduced, fallback: this._prog ? undefined : WORKER_SCENE_FNS[scene] });\n this._backend = r.backend;\n this.setAttribute('data-usa-backend', r.backend);\n this.emit('backend', { backend: r.backend });\n this.onCleanup(() => r.stop());\n }\n }\n return UsaWorkerCanvas as unknown as CustomElementConstructor;\n },\n { id: 'worker-canvas', text: css }\n );\n}\n"],"names":["defineElement","offscreenRender"],"mappings":";;;;;;;AAmBO,MAAM,aAAa,GAA2B;AACnD,IAAA,SAAS,EAAE,CAAA,qdAAA,CAAud;AACle,IAAA,MAAM,EAAE,CAAA,8b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('../chunks/lottie-player-Mcpt1H5w.cjs');
6
- require('../chunks/registry-xGDPpmX2.cjs');
4
+ var runtimeLink = require('../chunks/runtime-link-Bz3rGMsh.cjs');
5
+ var widgets_lottiePlayer = require('../chunks/lottie-player-DD1pnLN2.cjs');
6
+ require('../chunks/registry-uaO8pDKn.cjs');
7
7
 
8
8
  function defineDotLottie(tag = 'usa-dotlottie') {
9
9
  return base.defineElement(tag, () => {
@@ -128,7 +128,8 @@ declare class Timeline extends Playable {
128
128
  * - keyframes: bezier easing per dimension, hold keyframes, v4 (`e`) and v5+
129
129
  * (`s` only) files;
130
130
  * - **dotLottie** (`.lottie`): zip (stored + deflate via the native
131
- * `DecompressionStream`), `manifest.json` v1 / v2, several animations,
131
+ * `DecompressionStream`; 11.0: entry-count / size / ratio limits enforced
132
+ * while inflating — `ZipLimits`, `ZIP_LIMITS`), `manifest.json` v1 / v2, several animations,
132
133
  * embedded images.
133
134
  *
134
135
  * 10.8: **text layers** (system / web fonts by family + style, justification,
@@ -128,7 +128,8 @@ declare class Timeline extends Playable {
128
128
  * - keyframes: bezier easing per dimension, hold keyframes, v4 (`e`) and v5+
129
129
  * (`s` only) files;
130
130
  * - **dotLottie** (`.lottie`): zip (stored + deflate via the native
131
- * `DecompressionStream`), `manifest.json` v1 / v2, several animations,
131
+ * `DecompressionStream`; 11.0: entry-count / size / ratio limits enforced
132
+ * while inflating — `ZipLimits`, `ZIP_LIMITS`), `manifest.json` v1 / v2, several animations,
132
133
  * embedded images.
133
134
  *
134
135
  * 10.8: **text layers** (system / web fonts by family + style, justification,
@@ -1,7 +1,7 @@
1
1
  import { f as defineElement } from '../chunks/base-BTev8qxg.js';
2
- import { r as runtimeModule } from '../chunks/runtime-link-CQyKFwE1.js';
3
- import { c as css, d as defineLottiePlayer } from '../chunks/lottie-player-UJHOl-8L.js';
4
- import '../chunks/registry-RJYrdUTF.js';
2
+ import { r as runtimeModule } from '../chunks/runtime-link-CP3qaRja.js';
3
+ import { c as css, d as defineLottiePlayer } from '../chunks/lottie-player-CPdwHhqe.js';
4
+ import '../chunks/registry-W7pXOwju.js';
5
5
 
6
6
  function defineDotLottie(tag = 'usa-dotlottie') {
7
7
  return defineElement(tag, () => {
@@ -36,7 +36,11 @@ function runInWorker(fn, ...args) {
36
36
  w.postMessage(args);
37
37
  });
38
38
  }
39
- /** Animate `canvas` with `program` in a worker (OffscreenCanvas) when possible, else on the main thread (9.6). */
39
+ /**
40
+ * Animate `canvas` with `program` in a worker (OffscreenCanvas) when possible, else on the main thread (9.6).
41
+ * 11.0: a **string** program only runs in a worker. Without a worker it needs `opts.fallback` (a function);
42
+ * otherwise it is refused (`backend: 'none'`, console error) — strings are never evaluated on the main thread.
43
+ */
40
44
  function offscreenRender(canvas, program, opts = {}) {
41
45
  const code = typeof program === 'string' ? program : program.toString();
42
46
  const canWorker = opts.worker !== false && typeof Worker !== 'undefined' && typeof canvas.transferControlToOffscreen === 'function' && typeof Blob !== 'undefined' && !!URL.createObjectURL;
@@ -66,10 +70,11 @@ function offscreenRender(canvas, program, opts = {}) {
66
70
  const ctx = canvas.getContext?.('2d');
67
71
  if (!ctx)
68
72
  return { backend: 'none', stop: () => undefined, resize: () => undefined };
69
- if (typeof program === 'string')
70
- base.deprecate('worker-canvas-string', 'offscreenRender() / <usa-worker-canvas> with a string program fell back to the main thread, where it is evaluated with new Function (blocked by a strict CSP). Deprecated in 10.9; 11.0 refuses string programs on the main thread — pass a function. See docs/upgrading-11.md.');
71
- // eslint-disable-next-line no-new-func
72
- const draw = typeof program === 'function' ? program : new Function(`return (${code})`)();
73
+ if (typeof program === 'string' && !opts.fallback) {
74
+ console.error('[motionary] offscreenRender() / <usa-worker-canvas>: a string program can only run in a worker (OffscreenCanvas); 11.0 no longer evaluates it on the main thread (new Function) — pass a function. See docs/upgrading-11.md.');
75
+ return { backend: 'none', stop: () => undefined, resize: () => undefined };
76
+ }
77
+ const draw = typeof program === 'function' ? program : opts.fallback;
73
78
  const st = {};
74
79
  let t = 0;
75
80
  const stop = opts.paused
@@ -1 +1 @@
1
- {"version":3,"file":"fx-perf.cjs","sources":["../../src/components/fx2/perf3.ts"],"sourcesContent":["/**\n * 9.6 — Performance 3.0 (`motionary/fx/perf`, also `motionary/components/fx-perf`):\n *\n * - `runInWorker(fn, ...args)` — run a pure function in a throw-away Web\n * Worker (built from its source) and get a promise of its result; runs\n * inline when Workers are unavailable.\n * - `offscreenRender(canvas, program, options)` — move a canvas animation\n * off the main thread: `program` is the source of\n * `function (ctx, t, w, h, state) {…}`; with OffscreenCanvas + Worker it\n * runs in a worker (`backend: 'worker'`), otherwise on the main thread via\n * the shared frame loop (`'main'`). Returns { backend, stop, resize }.\n * - `fpsMeter()` — a rolling frames-per-second meter on the shared loop.\n *\n * Effects: `idle-reveal` (enter) waits for an idle moment before fading in\n * (keeps first paint / input snappy); `gpu-lift` (hover) a compositor-only\n * lift (transform + opacity only). Reduced motion: idle-reveal just shows,\n * gpu-lift does nothing.\n */\nimport type { EffectContext, EffectDefinition } from '../fx/registry';\nimport { registerEffects } from '../fx/registry';\nimport { onFrame } from '../base';\nimport { deprecate } from '../base';\n\n/** Run a pure function in a Web Worker; resolves with its (structured-cloneable) result (9.6). */\nexport function runInWorker<A extends unknown[], R>(fn: (...args: A) => R | Promise<R>, ...args: A): Promise<R> {\n if (typeof Worker === 'undefined' || typeof Blob === 'undefined' || typeof URL === 'undefined' || !URL.createObjectURL) return Promise.resolve().then(() => fn(...args));\n const src = `self.onmessage=async(e)=>{try{const r=await (${fn.toString()})(...e.data);self.postMessage({ok:true,r})}catch(err){self.postMessage({ok:false,e:String(err&&err.message||err)})}}`;\n const url = URL.createObjectURL(new Blob([src], { type: 'text/javascript' }));\n return new Promise<R>((resolve, reject) => {\n let w: Worker;\n try {\n w = new Worker(url);\n } catch (e) {\n URL.revokeObjectURL(url);\n return resolve(Promise.resolve().then(() => fn(...args)));\n }\n const done = () => {\n w.terminate();\n URL.revokeObjectURL(url);\n };\n w.onmessage = (e) => {\n done();\n if (e.data?.ok) resolve(e.data.r as R);\n else reject(new Error(e.data?.e || 'worker failed'));\n };\n w.onerror = (e) => {\n done();\n reject(new Error(e.message || 'worker error'));\n };\n w.postMessage(args);\n });\n}\n\nexport type DrawProgram = string | ((ctx: CanvasRenderingContext2D, t: number, w: number, h: number, state: Record<string, unknown>) => void);\n/** Animate `canvas` with `program` in a worker (OffscreenCanvas) when possible, else on the main thread (9.6). */\nexport function offscreenRender(canvas: HTMLCanvasElement, program: DrawProgram, opts: { worker?: boolean; paused?: boolean } = {}): { backend: 'worker' | 'main' | 'none'; stop(): void; resize(w: number, h: number): void } {\n const code = typeof program === 'string' ? program : program.toString();\n const canWorker = opts.worker !== false && typeof Worker !== 'undefined' && typeof (canvas as any).transferControlToOffscreen === 'function' && typeof Blob !== 'undefined' && !!URL.createObjectURL;\n if (canWorker) {\n try {\n const off = (canvas as any).transferControlToOffscreen();\n const src = `let c,ctx,w,h,st={},run=true,t0=0;const draw=(${code});self.onmessage=(e)=>{const d=e.data;if(d.canvas){c=d.canvas;ctx=c.getContext('2d');w=c.width;h=c.height;const loop=(t)=>{if(run){if(!t0)t0=t;draw(ctx,t-t0,w,h,st)}requestAnimationFrame(loop)};requestAnimationFrame(loop)}if(d.size){w=c.width=d.size[0];h=c.height=d.size[1]}if('run' in d)run=d.run;if(d.stop)close()}`;\n const url = URL.createObjectURL(new Blob([src], { type: 'text/javascript' }));\n const w = new Worker(url);\n w.postMessage({ canvas: off }, [off]);\n if (opts.paused) w.postMessage({ run: false });\n return {\n backend: 'worker',\n stop: () => {\n w.postMessage({ stop: true });\n w.terminate();\n URL.revokeObjectURL(url);\n },\n resize: (a, b) => w.postMessage({ size: [a, b] }),\n };\n } catch {\n /* fall back to the main thread */\n }\n }\n const ctx = canvas.getContext?.('2d');\n if (!ctx) return { backend: 'none', stop: () => undefined, resize: () => undefined };\n if (typeof program === 'string') deprecate('worker-canvas-string', 'offscreenRender() / <usa-worker-canvas> with a string program fell back to the main thread, where it is evaluated with new Function (blocked by a strict CSP). Deprecated in 10.9; 11.0 refuses string programs on the main thread — pass a function. See docs/upgrading-11.md.');\n // eslint-disable-next-line no-new-func\n const draw = typeof program === 'function' ? program : (new Function(`return (${code})`)() as Exclude<DrawProgram, string>);\n const st: Record<string, unknown> = {};\n let t = 0;\n const stop = opts.paused\n ? () => undefined\n : onFrame((_now, dt) => {\n t += dt;\n draw(ctx, t, canvas.width, canvas.height, st);\n });\n if (opts.paused) draw(ctx, 0, canvas.width, canvas.height, st);\n return {\n backend: 'main',\n stop,\n resize: (a, b) => {\n canvas.width = a;\n canvas.height = b;\n },\n };\n}\n\n/** A rolling FPS meter on the shared frame loop: { fps, stop } (fps updates every frame) (9.6). */\nexport function fpsMeter(window = 30): { readonly fps: number; readonly samples: number[]; stop(): void } {\n const samples: number[] = [];\n let fps = 0;\n const stop = onFrame((_t, dt) => {\n if (dt <= 0) return;\n samples.push(1000 / dt);\n if (samples.length > window) samples.shift();\n fps = Math.round(samples.reduce((a, b) => a + b, 0) / samples.length);\n });\n return {\n get fps() {\n return fps;\n },\n samples,\n stop,\n };\n}\n\nexport const PERF3_FX: EffectDefinition[] = [\n {\n name: 'idle-reveal',\n kind: 'enter',\n description: 'Waits for an idle moment (requestIdleCallback, ≤ `timeout` ms) before fading in, keeping first paint and input snappy.',\n defaults: { duration: 400, timeout: 600 },\n run: (el: HTMLElement, o: any, ctx: EffectContext) => {\n if (ctx.reduced) return;\n const prev = el.style.opacity;\n el.style.opacity = '0';\n ctx.onCleanup(() => (el.style.opacity = prev));\n return new Promise<void>((resolve) => {\n const go = () => {\n el.style.opacity = prev;\n const a = ctx.animate(el, [{ opacity: 0 }, { opacity: 1 }], { duration: o.duration, easing: 'ease-out' });\n if (a) a.finished.then(() => resolve(), () => resolve());\n else resolve();\n };\n const ric = (globalThis as any).requestIdleCallback as ((cb: () => void, o?: { timeout: number }) => number) | undefined;\n if (ric) ric(go, { timeout: Number(o.timeout) || 600 });\n else setTimeout(go, 1);\n });\n },\n },\n {\n name: 'gpu-lift',\n kind: 'hover',\n description: 'A compositor-only hover lift — only transform and opacity change, so it never triggers layout or paint.',\n defaults: { duration: 250, lift: 6 },\n run: (el: HTMLElement, o: any, ctx: EffectContext) => {\n if (ctx.reduced) return;\n return ctx.animate(el, [{ transform: 'translateY(0) scale(1)' }, { transform: `translateY(${-Math.abs(Number(o.lift) || 6)}px) scale(1.02)` }], { duration: o.duration, easing: 'ease-out', fill: 'forwards' })?.finished.catch(() => undefined);\n },\n },\n];\n\n/** Register idle-reveal and gpu-lift (9.6). */\nexport function registerPerf3Pack(): void {\n registerEffects(PERF3_FX);\n}\n"],"names":["deprecate","onFrame","registerEffects"],"mappings":";;;;;AAuBA;SACgB,WAAW,CAAyB,EAAkC,EAAE,GAAG,IAAO,EAAA;AAChG,IAAA,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,IAAI,KAAK,WAAW,IAAI,OAAO,GAAG,KAAK,WAAW,IAAI,CAAC,GAAG,CAAC,eAAe;AAAE,QAAA,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC;IACxK,MAAM,GAAG,GAAG,CAAA,6CAAA,EAAgD,EAAE,CAAC,QAAQ,EAAE,sHAAsH;IAC/L,MAAM,GAAG,GAAG,GAAG,CAAC,eAAe,CAAC,IAAI,IAAI,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,EAAE,iBAAiB,EAAE,CAAC,CAAC;IAC7E,OAAO,IAAI,OAAO,CAAI,CAAC,OAAO,EAAE,MAAM,KAAI;AACxC,QAAA,IAAI,CAAS;AACb,QAAA,IAAI;AACF,YAAA,CAAC,GAAG,IAAI,MAAM,CAAC,GAAG,CAAC;QACrB;QAAE,OAAO,CAAC,EAAE;AACV,YAAA,GAAG,CAAC,eAAe,CAAC,GAAG,CAAC;AACxB,YAAA,OAAO,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,IAAI,CA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AI,GAAG;AAAE,oBAAA,GAAG,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,GAAG,EAAE,CAAC;;AAClD,oBAAA,UAAU,CAAC,EAAE,EAAE,CAAC,CAAC;AACxB,YAAA,CAAC,CAAC;QACJ,CAAC;AACF,KAAA;AACD,IAAA;AACE,QAAA,IAAI,EAAE,UAAU;AAChB,QAAA,IAAI,EAAE,OAAO;AACb,QAAA,WAAW,EAAE,yGAAyG;QACtH,QAAQ,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,EAAE;QACpC,GAAG,EAAE,CAAC,EAAe,EAAE,CAAM,EAAE,GAAkB,KAAI;YACnD,IAAI,GAAG,CAAC,OAAO;gBAAE;AACjB,YAAA,OAAO,GAAG,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC,EAAE,SAAS,EAAE,wBAAwB,EAAE,EAAE,EAAE,SAAS,EAAE,CAAA,WAAA,EAAc,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA,eAAA,CAAiB,EAAE,CAAC,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,EAAE,QAAQ,CAAC,KAAK,CAAC,MAAM,SAAS,CAAC;QAClP,CAAC;AACF,KAAA;;AAGH;SACgB,iBAAiB,GAAA;IAC/BC,wBAAe,CAAC,QAAQ,CAAC;AAC3B;;;;;;"}
1
+ {"version":3,"file":"fx-perf.cjs","sources":["../../src/components/fx2/perf3.ts"],"sourcesContent":["/**\n * 9.6 — Performance 3.0 (`motionary/fx/perf`, also `motionary/components/fx-perf`):\n *\n * - `runInWorker(fn, ...args)` — run a pure function in a throw-away Web\n * Worker (built from its source) and get a promise of its result; runs\n * inline when Workers are unavailable.\n * - `offscreenRender(canvas, program, options)` — move a canvas animation\n * off the main thread: `program` is the source of\n * `function (ctx, t, w, h, state) {…}`; with OffscreenCanvas + Worker it\n * runs in a worker (`backend: 'worker'`), otherwise on the main thread via\n * the shared frame loop (`'main'`). Returns { backend, stop, resize }.\n * - `fpsMeter()` — a rolling frames-per-second meter on the shared loop.\n *\n * Effects: `idle-reveal` (enter) waits for an idle moment before fading in\n * (keeps first paint / input snappy); `gpu-lift` (hover) a compositor-only\n * lift (transform + opacity only). Reduced motion: idle-reveal just shows,\n * gpu-lift does nothing.\n */\nimport type { EffectContext, EffectDefinition } from '../fx/registry';\nimport { registerEffects } from '../fx/registry';\nimport { onFrame } from '../base';\n\n/** Run a pure function in a Web Worker; resolves with its (structured-cloneable) result (9.6). */\nexport function runInWorker<A extends unknown[], R>(fn: (...args: A) => R | Promise<R>, ...args: A): Promise<R> {\n if (typeof Worker === 'undefined' || typeof Blob === 'undefined' || typeof URL === 'undefined' || !URL.createObjectURL) return Promise.resolve().then(() => fn(...args));\n const src = `self.onmessage=async(e)=>{try{const r=await (${fn.toString()})(...e.data);self.postMessage({ok:true,r})}catch(err){self.postMessage({ok:false,e:String(err&&err.message||err)})}}`;\n const url = URL.createObjectURL(new Blob([src], { type: 'text/javascript' }));\n return new Promise<R>((resolve, reject) => {\n let w: Worker;\n try {\n w = new Worker(url);\n } catch (e) {\n URL.revokeObjectURL(url);\n return resolve(Promise.resolve().then(() => fn(...args)));\n }\n const done = () => {\n w.terminate();\n URL.revokeObjectURL(url);\n };\n w.onmessage = (e) => {\n done();\n if (e.data?.ok) resolve(e.data.r as R);\n else reject(new Error(e.data?.e || 'worker failed'));\n };\n w.onerror = (e) => {\n done();\n reject(new Error(e.message || 'worker error'));\n };\n w.postMessage(args);\n });\n}\n\nexport type DrawProgram = string | ((ctx: CanvasRenderingContext2D, t: number, w: number, h: number, state: Record<string, unknown>) => void);\n/**\n * Animate `canvas` with `program` in a worker (OffscreenCanvas) when possible, else on the main thread (9.6).\n * 11.0: a **string** program only runs in a worker. Without a worker it needs `opts.fallback` (a function);\n * otherwise it is refused (`backend: 'none'`, console error) — strings are never evaluated on the main thread.\n */\nexport function offscreenRender(canvas: HTMLCanvasElement, program: DrawProgram, opts: { worker?: boolean; paused?: boolean; fallback?: Exclude<DrawProgram, string> } = {}): { backend: 'worker' | 'main' | 'none'; stop(): void; resize(w: number, h: number): void } {\n const code = typeof program === 'string' ? program : program.toString();\n const canWorker = opts.worker !== false && typeof Worker !== 'undefined' && typeof (canvas as any).transferControlToOffscreen === 'function' && typeof Blob !== 'undefined' && !!URL.createObjectURL;\n if (canWorker) {\n try {\n const off = (canvas as any).transferControlToOffscreen();\n const src = `let c,ctx,w,h,st={},run=true,t0=0;const draw=(${code});self.onmessage=(e)=>{const d=e.data;if(d.canvas){c=d.canvas;ctx=c.getContext('2d');w=c.width;h=c.height;const loop=(t)=>{if(run){if(!t0)t0=t;draw(ctx,t-t0,w,h,st)}requestAnimationFrame(loop)};requestAnimationFrame(loop)}if(d.size){w=c.width=d.size[0];h=c.height=d.size[1]}if('run' in d)run=d.run;if(d.stop)close()}`;\n const url = URL.createObjectURL(new Blob([src], { type: 'text/javascript' }));\n const w = new Worker(url);\n w.postMessage({ canvas: off }, [off]);\n if (opts.paused) w.postMessage({ run: false });\n return {\n backend: 'worker',\n stop: () => {\n w.postMessage({ stop: true });\n w.terminate();\n URL.revokeObjectURL(url);\n },\n resize: (a, b) => w.postMessage({ size: [a, b] }),\n };\n } catch {\n /* fall back to the main thread */\n }\n }\n const ctx = canvas.getContext?.('2d');\n if (!ctx) return { backend: 'none', stop: () => undefined, resize: () => undefined };\n if (typeof program === 'string' && !opts.fallback) {\n console.error('[motionary] offscreenRender() / <usa-worker-canvas>: a string program can only run in a worker (OffscreenCanvas); 11.0 no longer evaluates it on the main thread (new Function) — pass a function. See docs/upgrading-11.md.');\n return { backend: 'none', stop: () => undefined, resize: () => undefined };\n }\n const draw = typeof program === 'function' ? program : (opts.fallback as Exclude<DrawProgram, string>);\n const st: Record<string, unknown> = {};\n let t = 0;\n const stop = opts.paused\n ? () => undefined\n : onFrame((_now, dt) => {\n t += dt;\n draw(ctx, t, canvas.width, canvas.height, st);\n });\n if (opts.paused) draw(ctx, 0, canvas.width, canvas.height, st);\n return {\n backend: 'main',\n stop,\n resize: (a, b) => {\n canvas.width = a;\n canvas.height = b;\n },\n };\n}\n\n/** A rolling FPS meter on the shared frame loop: { fps, stop } (fps updates every frame) (9.6). */\nexport function fpsMeter(window = 30): { readonly fps: number; readonly samples: number[]; stop(): void } {\n const samples: number[] = [];\n let fps = 0;\n const stop = onFrame((_t, dt) => {\n if (dt <= 0) return;\n samples.push(1000 / dt);\n if (samples.length > window) samples.shift();\n fps = Math.round(samples.reduce((a, b) => a + b, 0) / samples.length);\n });\n return {\n get fps() {\n return fps;\n },\n samples,\n stop,\n };\n}\n\nexport const PERF3_FX: EffectDefinition[] = [\n {\n name: 'idle-reveal',\n kind: 'enter',\n description: 'Waits for an idle moment (requestIdleCallback, ≤ `timeout` ms) before fading in, keeping first paint and input snappy.',\n defaults: { duration: 400, timeout: 600 },\n run: (el: HTMLElement, o: any, ctx: EffectContext) => {\n if (ctx.reduced) return;\n const prev = el.style.opacity;\n el.style.opacity = '0';\n ctx.onCleanup(() => (el.style.opacity = prev));\n return new Promise<void>((resolve) => {\n const go = () => {\n el.style.opacity = prev;\n const a = ctx.animate(el, [{ opacity: 0 }, { opacity: 1 }], { duration: o.duration, easing: 'ease-out' });\n if (a) a.finished.then(() => resolve(), () => resolve());\n else resolve();\n };\n const ric = (globalThis as any).requestIdleCallback as ((cb: () => void, o?: { timeout: number }) => number) | undefined;\n if (ric) ric(go, { timeout: Number(o.timeout) || 600 });\n else setTimeout(go, 1);\n });\n },\n },\n {\n name: 'gpu-lift',\n kind: 'hover',\n description: 'A compositor-only hover lift — only transform and opacity change, so it never triggers layout or paint.',\n defaults: { duration: 250, lift: 6 },\n run: (el: HTMLElement, o: any, ctx: EffectContext) => {\n if (ctx.reduced) return;\n return ctx.animate(el, [{ transform: 'translateY(0) scale(1)' }, { transform: `translateY(${-Math.abs(Number(o.lift) || 6)}px) scale(1.02)` }], { duration: o.duration, easing: 'ease-out', fill: 'forwards' })?.finished.catch(() => undefined);\n },\n },\n];\n\n/** Register idle-reveal and gpu-lift (9.6). */\nexport function registerPerf3Pack(): void {\n registerEffects(PERF3_FX);\n}\n"],"names":["onFrame","registerEffects"],"mappings":";;;;;AAsBA;SACgB,WAAW,CAAyB,EAAkC,EAAE,GAAG,IAAO,EAAA;AAChG,IAAA,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,IAAI,KAAK,WAAW,IAAI,OAAO,GAAG,KAAK,WAAW,IAAI,CAAC,GAAG,CAAC,eAAe;AAAE,QAAA,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC;IACxK,MAAM,GAAG,GAAG,CAAA,6CAAA,EAAgD,EAAE,CAAC,QAAQ,EAAE,sHAAsH;IAC/L,MAAM,GAAG,GAAG,GAAG,CAAC,eAAe,CAAC,IAAI,IAAI,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,EAAE,iBAAiB,EAAE,CAAC,CAAC;IAC7E,OAAO,IAAI,OAAO,CAAI,CAAC,OAAO,EAAE,MAAM,KAAI;AACxC,QAAA,IAAI,CAAS;AACb,QAAA,IAAI;AACF,YAAA,CAAC,GAAG,IAAI,MAAM,CAAC,GAAG,CAAC;QACrB;QAAE,OAAO,CAAC,EAAE;AACV,YAAA,GAAG,CAAC,eAAe,CAAC,GAAG,CAAC;AACxB,YAAA,OAAO,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;QAC3D;QACA,MAAM,IAAI,GAAG,MAAK;YAChB,CAAC,CAAC,SAAS,EAAE;AACb,YAAA,GAAG,CAAC,eAAe,CAAC,GAAG,CA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AAE,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,GAAG,EAAE,CAAC;;AAClD,oBAAA,UAAU,CAAC,EAAE,EAAE,CAAC,CAAC;AACxB,YAAA,CAAC,CAAC;QACJ,CAAC;AACF,KAAA;AACD,IAAA;AACE,QAAA,IAAI,EAAE,UAAU;AAChB,QAAA,IAAI,EAAE,OAAO;AACb,QAAA,WAAW,EAAE,yGAAyG;QACtH,QAAQ,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,EAAE;QACpC,GAAG,EAAE,CAAC,EAAe,EAAE,CAAM,EAAE,GAAkB,KAAI;YACnD,IAAI,GAAG,CAAC,OAAO;gBAAE;AACjB,YAAA,OAAO,GAAG,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC,EAAE,SAAS,EAAE,wBAAwB,EAAE,EAAE,EAAE,SAAS,EAAE,CAAA,WAAA,EAAc,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA,eAAA,CAAiB,EAAE,CAAC,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,EAAE,QAAQ,CAAC,KAAK,CAAC,MAAM,SAAS,CAAC;QAClP,CAAC;AACF,KAAA;;AAGH;SACgB,iBAAiB,GAAA;IAC/BC,wBAAe,CAAC,QAAQ,CAAC;AAC3B;;;;;;"}
@@ -63,10 +63,15 @@ interface EffectDefinition<O extends Record<string, unknown> = Record<string, an
63
63
  /** Run a pure function in a Web Worker; resolves with its (structured-cloneable) result (9.6). */
64
64
  declare function runInWorker<A extends unknown[], R>(fn: (...args: A) => R | Promise<R>, ...args: A): Promise<R>;
65
65
  type DrawProgram = string | ((ctx: CanvasRenderingContext2D, t: number, w: number, h: number, state: Record<string, unknown>) => void);
66
- /** Animate `canvas` with `program` in a worker (OffscreenCanvas) when possible, else on the main thread (9.6). */
66
+ /**
67
+ * Animate `canvas` with `program` in a worker (OffscreenCanvas) when possible, else on the main thread (9.6).
68
+ * 11.0: a **string** program only runs in a worker. Without a worker it needs `opts.fallback` (a function);
69
+ * otherwise it is refused (`backend: 'none'`, console error) — strings are never evaluated on the main thread.
70
+ */
67
71
  declare function offscreenRender(canvas: HTMLCanvasElement, program: DrawProgram, opts?: {
68
72
  worker?: boolean;
69
73
  paused?: boolean;
74
+ fallback?: Exclude<DrawProgram, string>;
70
75
  }): {
71
76
  backend: 'worker' | 'main' | 'none';
72
77
  stop(): void;
@@ -63,10 +63,15 @@ interface EffectDefinition<O extends Record<string, unknown> = Record<string, an
63
63
  /** Run a pure function in a Web Worker; resolves with its (structured-cloneable) result (9.6). */
64
64
  declare function runInWorker<A extends unknown[], R>(fn: (...args: A) => R | Promise<R>, ...args: A): Promise<R>;
65
65
  type DrawProgram = string | ((ctx: CanvasRenderingContext2D, t: number, w: number, h: number, state: Record<string, unknown>) => void);
66
- /** Animate `canvas` with `program` in a worker (OffscreenCanvas) when possible, else on the main thread (9.6). */
66
+ /**
67
+ * Animate `canvas` with `program` in a worker (OffscreenCanvas) when possible, else on the main thread (9.6).
68
+ * 11.0: a **string** program only runs in a worker. Without a worker it needs `opts.fallback` (a function);
69
+ * otherwise it is refused (`backend: 'none'`, console error) — strings are never evaluated on the main thread.
70
+ */
67
71
  declare function offscreenRender(canvas: HTMLCanvasElement, program: DrawProgram, opts?: {
68
72
  worker?: boolean;
69
73
  paused?: boolean;
74
+ fallback?: Exclude<DrawProgram, string>;
70
75
  }): {
71
76
  backend: 'worker' | 'main' | 'none';
72
77
  stop(): void;
@@ -1,5 +1,5 @@
1
1
  import { registerEffects } from '../chunks/registry-BKzyg1JV.js';
2
- import { v as onFrame, B as deprecate } from '../chunks/base-BTev8qxg.js';
2
+ import { v as onFrame } from '../chunks/base-BTev8qxg.js';
3
3
 
4
4
  /** Run a pure function in a Web Worker; resolves with its (structured-cloneable) result (9.6). */
5
5
  function runInWorker(fn, ...args) {
@@ -34,7 +34,11 @@ function runInWorker(fn, ...args) {
34
34
  w.postMessage(args);
35
35
  });
36
36
  }
37
- /** Animate `canvas` with `program` in a worker (OffscreenCanvas) when possible, else on the main thread (9.6). */
37
+ /**
38
+ * Animate `canvas` with `program` in a worker (OffscreenCanvas) when possible, else on the main thread (9.6).
39
+ * 11.0: a **string** program only runs in a worker. Without a worker it needs `opts.fallback` (a function);
40
+ * otherwise it is refused (`backend: 'none'`, console error) — strings are never evaluated on the main thread.
41
+ */
38
42
  function offscreenRender(canvas, program, opts = {}) {
39
43
  const code = typeof program === 'string' ? program : program.toString();
40
44
  const canWorker = opts.worker !== false && typeof Worker !== 'undefined' && typeof canvas.transferControlToOffscreen === 'function' && typeof Blob !== 'undefined' && !!URL.createObjectURL;
@@ -64,10 +68,11 @@ function offscreenRender(canvas, program, opts = {}) {
64
68
  const ctx = canvas.getContext?.('2d');
65
69
  if (!ctx)
66
70
  return { backend: 'none', stop: () => undefined, resize: () => undefined };
67
- if (typeof program === 'string')
68
- deprecate('worker-canvas-string', 'offscreenRender() / <usa-worker-canvas> with a string program fell back to the main thread, where it is evaluated with new Function (blocked by a strict CSP). Deprecated in 10.9; 11.0 refuses string programs on the main thread — pass a function. See docs/upgrading-11.md.');
69
- // eslint-disable-next-line no-new-func
70
- const draw = typeof program === 'function' ? program : new Function(`return (${code})`)();
71
+ if (typeof program === 'string' && !opts.fallback) {
72
+ console.error('[motionary] offscreenRender() / <usa-worker-canvas>: a string program can only run in a worker (OffscreenCanvas); 11.0 no longer evaluates it on the main thread (new Function) — pass a function. See docs/upgrading-11.md.');
73
+ return { backend: 'none', stop: () => undefined, resize: () => undefined };
74
+ }
75
+ const draw = typeof program === 'function' ? program : opts.fallback;
71
76
  const st = {};
72
77
  let t = 0;
73
78
  const stop = opts.paused
@@ -1 +1 @@
1
- {"version":3,"file":"fx-perf.js","sources":["../../src/components/fx2/perf3.ts"],"sourcesContent":["/**\n * 9.6 — Performance 3.0 (`motionary/fx/perf`, also `motionary/components/fx-perf`):\n *\n * - `runInWorker(fn, ...args)` — run a pure function in a throw-away Web\n * Worker (built from its source) and get a promise of its result; runs\n * inline when Workers are unavailable.\n * - `offscreenRender(canvas, program, options)` — move a canvas animation\n * off the main thread: `program` is the source of\n * `function (ctx, t, w, h, state) {…}`; with OffscreenCanvas + Worker it\n * runs in a worker (`backend: 'worker'`), otherwise on the main thread via\n * the shared frame loop (`'main'`). Returns { backend, stop, resize }.\n * - `fpsMeter()` — a rolling frames-per-second meter on the shared loop.\n *\n * Effects: `idle-reveal` (enter) waits for an idle moment before fading in\n * (keeps first paint / input snappy); `gpu-lift` (hover) a compositor-only\n * lift (transform + opacity only). Reduced motion: idle-reveal just shows,\n * gpu-lift does nothing.\n */\nimport type { EffectContext, EffectDefinition } from '../fx/registry';\nimport { registerEffects } from '../fx/registry';\nimport { onFrame } from '../base';\nimport { deprecate } from '../base';\n\n/** Run a pure function in a Web Worker; resolves with its (structured-cloneable) result (9.6). */\nexport function runInWorker<A extends unknown[], R>(fn: (...args: A) => R | Promise<R>, ...args: A): Promise<R> {\n if (typeof Worker === 'undefined' || typeof Blob === 'undefined' || typeof URL === 'undefined' || !URL.createObjectURL) return Promise.resolve().then(() => fn(...args));\n const src = `self.onmessage=async(e)=>{try{const r=await (${fn.toString()})(...e.data);self.postMessage({ok:true,r})}catch(err){self.postMessage({ok:false,e:String(err&&err.message||err)})}}`;\n const url = URL.createObjectURL(new Blob([src], { type: 'text/javascript' }));\n return new Promise<R>((resolve, reject) => {\n let w: Worker;\n try {\n w = new Worker(url);\n } catch (e) {\n URL.revokeObjectURL(url);\n return resolve(Promise.resolve().then(() => fn(...args)));\n }\n const done = () => {\n w.terminate();\n URL.revokeObjectURL(url);\n };\n w.onmessage = (e) => {\n done();\n if (e.data?.ok) resolve(e.data.r as R);\n else reject(new Error(e.data?.e || 'worker failed'));\n };\n w.onerror = (e) => {\n done();\n reject(new Error(e.message || 'worker error'));\n };\n w.postMessage(args);\n });\n}\n\nexport type DrawProgram = string | ((ctx: CanvasRenderingContext2D, t: number, w: number, h: number, state: Record<string, unknown>) => void);\n/** Animate `canvas` with `program` in a worker (OffscreenCanvas) when possible, else on the main thread (9.6). */\nexport function offscreenRender(canvas: HTMLCanvasElement, program: DrawProgram, opts: { worker?: boolean; paused?: boolean } = {}): { backend: 'worker' | 'main' | 'none'; stop(): void; resize(w: number, h: number): void } {\n const code = typeof program === 'string' ? program : program.toString();\n const canWorker = opts.worker !== false && typeof Worker !== 'undefined' && typeof (canvas as any).transferControlToOffscreen === 'function' && typeof Blob !== 'undefined' && !!URL.createObjectURL;\n if (canWorker) {\n try {\n const off = (canvas as any).transferControlToOffscreen();\n const src = `let c,ctx,w,h,st={},run=true,t0=0;const draw=(${code});self.onmessage=(e)=>{const d=e.data;if(d.canvas){c=d.canvas;ctx=c.getContext('2d');w=c.width;h=c.height;const loop=(t)=>{if(run){if(!t0)t0=t;draw(ctx,t-t0,w,h,st)}requestAnimationFrame(loop)};requestAnimationFrame(loop)}if(d.size){w=c.width=d.size[0];h=c.height=d.size[1]}if('run' in d)run=d.run;if(d.stop)close()}`;\n const url = URL.createObjectURL(new Blob([src], { type: 'text/javascript' }));\n const w = new Worker(url);\n w.postMessage({ canvas: off }, [off]);\n if (opts.paused) w.postMessage({ run: false });\n return {\n backend: 'worker',\n stop: () => {\n w.postMessage({ stop: true });\n w.terminate();\n URL.revokeObjectURL(url);\n },\n resize: (a, b) => w.postMessage({ size: [a, b] }),\n };\n } catch {\n /* fall back to the main thread */\n }\n }\n const ctx = canvas.getContext?.('2d');\n if (!ctx) return { backend: 'none', stop: () => undefined, resize: () => undefined };\n if (typeof program === 'string') deprecate('worker-canvas-string', 'offscreenRender() / <usa-worker-canvas> with a string program fell back to the main thread, where it is evaluated with new Function (blocked by a strict CSP). Deprecated in 10.9; 11.0 refuses string programs on the main thread — pass a function. See docs/upgrading-11.md.');\n // eslint-disable-next-line no-new-func\n const draw = typeof program === 'function' ? program : (new Function(`return (${code})`)() as Exclude<DrawProgram, string>);\n const st: Record<string, unknown> = {};\n let t = 0;\n const stop = opts.paused\n ? () => undefined\n : onFrame((_now, dt) => {\n t += dt;\n draw(ctx, t, canvas.width, canvas.height, st);\n });\n if (opts.paused) draw(ctx, 0, canvas.width, canvas.height, st);\n return {\n backend: 'main',\n stop,\n resize: (a, b) => {\n canvas.width = a;\n canvas.height = b;\n },\n };\n}\n\n/** A rolling FPS meter on the shared frame loop: { fps, stop } (fps updates every frame) (9.6). */\nexport function fpsMeter(window = 30): { readonly fps: number; readonly samples: number[]; stop(): void } {\n const samples: number[] = [];\n let fps = 0;\n const stop = onFrame((_t, dt) => {\n if (dt <= 0) return;\n samples.push(1000 / dt);\n if (samples.length > window) samples.shift();\n fps = Math.round(samples.reduce((a, b) => a + b, 0) / samples.length);\n });\n return {\n get fps() {\n return fps;\n },\n samples,\n stop,\n };\n}\n\nexport const PERF3_FX: EffectDefinition[] = [\n {\n name: 'idle-reveal',\n kind: 'enter',\n description: 'Waits for an idle moment (requestIdleCallback, ≤ `timeout` ms) before fading in, keeping first paint and input snappy.',\n defaults: { duration: 400, timeout: 600 },\n run: (el: HTMLElement, o: any, ctx: EffectContext) => {\n if (ctx.reduced) return;\n const prev = el.style.opacity;\n el.style.opacity = '0';\n ctx.onCleanup(() => (el.style.opacity = prev));\n return new Promise<void>((resolve) => {\n const go = () => {\n el.style.opacity = prev;\n const a = ctx.animate(el, [{ opacity: 0 }, { opacity: 1 }], { duration: o.duration, easing: 'ease-out' });\n if (a) a.finished.then(() => resolve(), () => resolve());\n else resolve();\n };\n const ric = (globalThis as any).requestIdleCallback as ((cb: () => void, o?: { timeout: number }) => number) | undefined;\n if (ric) ric(go, { timeout: Number(o.timeout) || 600 });\n else setTimeout(go, 1);\n });\n },\n },\n {\n name: 'gpu-lift',\n kind: 'hover',\n description: 'A compositor-only hover lift — only transform and opacity change, so it never triggers layout or paint.',\n defaults: { duration: 250, lift: 6 },\n run: (el: HTMLElement, o: any, ctx: EffectContext) => {\n if (ctx.reduced) return;\n return ctx.animate(el, [{ transform: 'translateY(0) scale(1)' }, { transform: `translateY(${-Math.abs(Number(o.lift) || 6)}px) scale(1.02)` }], { duration: o.duration, easing: 'ease-out', fill: 'forwards' })?.finished.catch(() => undefined);\n },\n },\n];\n\n/** Register idle-reveal and gpu-lift (9.6). */\nexport function registerPerf3Pack(): void {\n registerEffects(PERF3_FX);\n}\n"],"names":[],"mappings":";;;AAuBA;SACgB,WAAW,CAAyB,EAAkC,EAAE,GAAG,IAAO,EAAA;AAChG,IAAA,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,IAAI,KAAK,WAAW,IAAI,OAAO,GAAG,KAAK,WAAW,IAAI,CAAC,GAAG,CAAC,eAAe;AAAE,QAAA,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC;IACxK,MAAM,GAAG,GAAG,CAAA,6CAAA,EAAgD,EAAE,CAAC,QAAQ,EAAE,sHAAsH;IAC/L,MAAM,GAAG,GAAG,GAAG,CAAC,eAAe,CAAC,IAAI,IAAI,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,EAAE,iBAAiB,EAAE,CAAC,CAAC;IAC7E,OAAO,IAAI,OAAO,CAAI,CAAC,OAAO,EAAE,MAAM,KAAI;AACxC,QAAA,IAAI,CAAS;AACb,QAAA,IAAI;AACF,YAAA,CAAC,GAAG,IAAI,MAAM,CAAC,GAAG,CAAC;QACrB;QAAE,OAAO,CAAC,EAAE;AACV,YAAA,GAAG,CAAC,eAAe,CAAC,GAAG,CAAC;AACxB,YAAA,OAAO,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;QAC3D;QACA,MAAM,IAAI,GAAG,MAAK;YAChB,CAAC,CAAC,S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G,EAAE,CAAC;;AAClD,oBAAA,UAAU,CAAC,EAAE,EAAE,CAAC,CAAC;AACxB,YAAA,CAAC,CAAC;QACJ,CAAC;AACF,KAAA;AACD,IAAA;AACE,QAAA,IAAI,EAAE,UAAU;AAChB,QAAA,IAAI,EAAE,OAAO;AACb,QAAA,WAAW,EAAE,yGAAyG;QACtH,QAAQ,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,EAAE;QACpC,GAAG,EAAE,CAAC,EAAe,EAAE,CAAM,EAAE,GAAkB,KAAI;YACnD,IAAI,GAAG,CAAC,OAAO;gBAAE;AACjB,YAAA,OAAO,GAAG,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC,EAAE,SAAS,EAAE,wBAAwB,EAAE,EAAE,EAAE,SAAS,EAAE,CAAA,WAAA,EAAc,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA,eAAA,CAAiB,EAAE,CAAC,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,EAAE,QAAQ,CAAC,KAAK,CAAC,MAAM,SAAS,CAAC;QAClP,CAAC;AACF,KAAA;;AAGH;SACgB,iBAAiB,GAAA;IAC/B,eAAe,CAAC,QAAQ,CAAC;AAC3B;;"}
1
+ {"version":3,"file":"fx-perf.js","sources":["../../src/components/fx2/perf3.ts"],"sourcesContent":["/**\n * 9.6 — Performance 3.0 (`motionary/fx/perf`, also `motionary/components/fx-perf`):\n *\n * - `runInWorker(fn, ...args)` — run a pure function in a throw-away Web\n * Worker (built from its source) and get a promise of its result; runs\n * inline when Workers are unavailable.\n * - `offscreenRender(canvas, program, options)` — move a canvas animation\n * off the main thread: `program` is the source of\n * `function (ctx, t, w, h, state) {…}`; with OffscreenCanvas + Worker it\n * runs in a worker (`backend: 'worker'`), otherwise on the main thread via\n * the shared frame loop (`'main'`). Returns { backend, stop, resize }.\n * - `fpsMeter()` — a rolling frames-per-second meter on the shared loop.\n *\n * Effects: `idle-reveal` (enter) waits for an idle moment before fading in\n * (keeps first paint / input snappy); `gpu-lift` (hover) a compositor-only\n * lift (transform + opacity only). Reduced motion: idle-reveal just shows,\n * gpu-lift does nothing.\n */\nimport type { EffectContext, EffectDefinition } from '../fx/registry';\nimport { registerEffects } from '../fx/registry';\nimport { onFrame } from '../base';\n\n/** Run a pure function in a Web Worker; resolves with its (structured-cloneable) result (9.6). */\nexport function runInWorker<A extends unknown[], R>(fn: (...args: A) => R | Promise<R>, ...args: A): Promise<R> {\n if (typeof Worker === 'undefined' || typeof Blob === 'undefined' || typeof URL === 'undefined' || !URL.createObjectURL) return Promise.resolve().then(() => fn(...args));\n const src = `self.onmessage=async(e)=>{try{const r=await (${fn.toString()})(...e.data);self.postMessage({ok:true,r})}catch(err){self.postMessage({ok:false,e:String(err&&err.message||err)})}}`;\n const url = URL.createObjectURL(new Blob([src], { type: 'text/javascript' }));\n return new Promise<R>((resolve, reject) => {\n let w: Worker;\n try {\n w = new Worker(url);\n } catch (e) {\n URL.revokeObjectURL(url);\n return resolve(Promise.resolve().then(() => fn(...args)));\n }\n const done = () => {\n w.terminate();\n URL.revokeObjectURL(url);\n };\n w.onmessage = (e) => {\n done();\n if (e.data?.ok) resolve(e.data.r as R);\n else reject(new Error(e.data?.e || 'worker failed'));\n };\n w.onerror = (e) => {\n done();\n reject(new Error(e.message || 'worker error'));\n };\n w.postMessage(args);\n });\n}\n\nexport type DrawProgram = string | ((ctx: CanvasRenderingContext2D, t: number, w: number, h: number, state: Record<string, unknown>) => void);\n/**\n * Animate `canvas` with `program` in a worker (OffscreenCanvas) when possible, else on the main thread (9.6).\n * 11.0: a **string** program only runs in a worker. Without a worker it needs `opts.fallback` (a function);\n * otherwise it is refused (`backend: 'none'`, console error) — strings are never evaluated on the main thread.\n */\nexport function offscreenRender(canvas: HTMLCanvasElement, program: DrawProgram, opts: { worker?: boolean; paused?: boolean; fallback?: Exclude<DrawProgram, string> } = {}): { backend: 'worker' | 'main' | 'none'; stop(): void; resize(w: number, h: number): void } {\n const code = typeof program === 'string' ? program : program.toString();\n const canWorker = opts.worker !== false && typeof Worker !== 'undefined' && typeof (canvas as any).transferControlToOffscreen === 'function' && typeof Blob !== 'undefined' && !!URL.createObjectURL;\n if (canWorker) {\n try {\n const off = (canvas as any).transferControlToOffscreen();\n const src = `let c,ctx,w,h,st={},run=true,t0=0;const draw=(${code});self.onmessage=(e)=>{const d=e.data;if(d.canvas){c=d.canvas;ctx=c.getContext('2d');w=c.width;h=c.height;const loop=(t)=>{if(run){if(!t0)t0=t;draw(ctx,t-t0,w,h,st)}requestAnimationFrame(loop)};requestAnimationFrame(loop)}if(d.size){w=c.width=d.size[0];h=c.height=d.size[1]}if('run' in d)run=d.run;if(d.stop)close()}`;\n const url = URL.createObjectURL(new Blob([src], { type: 'text/javascript' }));\n const w = new Worker(url);\n w.postMessage({ canvas: off }, [off]);\n if (opts.paused) w.postMessage({ run: false });\n return {\n backend: 'worker',\n stop: () => {\n w.postMessage({ stop: true });\n w.terminate();\n URL.revokeObjectURL(url);\n },\n resize: (a, b) => w.postMessage({ size: [a, b] }),\n };\n } catch {\n /* fall back to the main thread */\n }\n }\n const ctx = canvas.getContext?.('2d');\n if (!ctx) return { backend: 'none', stop: () => undefined, resize: () => undefined };\n if (typeof program === 'string' && !opts.fallback) {\n console.error('[motionary] offscreenRender() / <usa-worker-canvas>: a string program can only run in a worker (OffscreenCanvas); 11.0 no longer evaluates it on the main thread (new Function) — pass a function. See docs/upgrading-11.md.');\n return { backend: 'none', stop: () => undefined, resize: () => undefined };\n }\n const draw = typeof program === 'function' ? program : (opts.fallback as Exclude<DrawProgram, string>);\n const st: Record<string, unknown> = {};\n let t = 0;\n const stop = opts.paused\n ? () => undefined\n : onFrame((_now, dt) => {\n t += dt;\n draw(ctx, t, canvas.width, canvas.height, st);\n });\n if (opts.paused) draw(ctx, 0, canvas.width, canvas.height, st);\n return {\n backend: 'main',\n stop,\n resize: (a, b) => {\n canvas.width = a;\n canvas.height = b;\n },\n };\n}\n\n/** A rolling FPS meter on the shared frame loop: { fps, stop } (fps updates every frame) (9.6). */\nexport function fpsMeter(window = 30): { readonly fps: number; readonly samples: number[]; stop(): void } {\n const samples: number[] = [];\n let fps = 0;\n const stop = onFrame((_t, dt) => {\n if (dt <= 0) return;\n samples.push(1000 / dt);\n if (samples.length > window) samples.shift();\n fps = Math.round(samples.reduce((a, b) => a + b, 0) / samples.length);\n });\n return {\n get fps() {\n return fps;\n },\n samples,\n stop,\n };\n}\n\nexport const PERF3_FX: EffectDefinition[] = [\n {\n name: 'idle-reveal',\n kind: 'enter',\n description: 'Waits for an idle moment (requestIdleCallback, ≤ `timeout` ms) before fading in, keeping first paint and input snappy.',\n defaults: { duration: 400, timeout: 600 },\n run: (el: HTMLElement, o: any, ctx: EffectContext) => {\n if (ctx.reduced) return;\n const prev = el.style.opacity;\n el.style.opacity = '0';\n ctx.onCleanup(() => (el.style.opacity = prev));\n return new Promise<void>((resolve) => {\n const go = () => {\n el.style.opacity = prev;\n const a = ctx.animate(el, [{ opacity: 0 }, { opacity: 1 }], { duration: o.duration, easing: 'ease-out' });\n if (a) a.finished.then(() => resolve(), () => resolve());\n else resolve();\n };\n const ric = (globalThis as any).requestIdleCallback as ((cb: () => void, o?: { timeout: number }) => number) | undefined;\n if (ric) ric(go, { timeout: Number(o.timeout) || 600 });\n else setTimeout(go, 1);\n });\n },\n },\n {\n name: 'gpu-lift',\n kind: 'hover',\n description: 'A compositor-only hover lift — only transform and opacity change, so it never triggers layout or paint.',\n defaults: { duration: 250, lift: 6 },\n run: (el: HTMLElement, o: any, ctx: EffectContext) => {\n if (ctx.reduced) return;\n return ctx.animate(el, [{ transform: 'translateY(0) scale(1)' }, { transform: `translateY(${-Math.abs(Number(o.lift) || 6)}px) scale(1.02)` }], { duration: o.duration, easing: 'ease-out', fill: 'forwards' })?.finished.catch(() => undefined);\n },\n },\n];\n\n/** Register idle-reveal and gpu-lift (9.6). */\nexport function registerPerf3Pack(): void {\n registerEffects(PERF3_FX);\n}\n"],"names":[],"mappings":";;;AAsBA;SACgB,WAAW,CAAyB,EAAkC,EAAE,GAAG,IAAO,EAAA;AAChG,IAAA,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,IAAI,KAAK,WAAW,IAAI,OAAO,GAAG,KAAK,WAAW,IAAI,CAAC,GAAG,CAAC,eAAe;AAAE,QAAA,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC;IACxK,MAAM,GAAG,GAAG,CAAA,6CAAA,EAAgD,EAAE,CAAC,QAAQ,EAAE,sHAAsH;IAC/L,MAAM,GAAG,GAAG,GAAG,CAAC,eAAe,CAAC,IAAI,IAAI,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,EAAE,iBAAiB,EAAE,CAAC,CAAC;IAC7E,OAAO,IAAI,OAAO,CAAI,CAAC,OAAO,EAAE,MAAM,KAAI;AACxC,QAAA,IAAI,CAAS;AACb,QAAA,IAAI;AACF,YAAA,CAAC,GAAG,IAAI,MAAM,CAAC,GAAG,CAAC;QACrB;QAAE,OAAO,CAAC,EAAE;AACV,YAAA,GAAG,CAAC,eAAe,CAAC,GAAG,CAAC;AACxB,YAAA,OAAO,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;QAC3D;QACA,MAAM,IAAI,GAAG,MAAK;YAChB,CAAC,CAAC,SAAS,EAAE;AACb,YAAA,GAAG,CAAC,eAAe,CAAC,GAAG,CAAC;AAC1B,QAAA,CAAC;AACD,QAAA,CAAC,CAAC,SAAS,GAAG,CAAC,CAAC,KAAI;AAClB,YAAA,IAAI,EAAE;AACN,YAAA,IAAI,CAAC,CAAC,IAAI,E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,YAAA,CAAC,CAAC;QACJ,CAAC;AACF,KAAA;AACD,IAAA;AACE,QAAA,IAAI,EAAE,UAAU;AAChB,QAAA,IAAI,EAAE,OAAO;AACb,QAAA,WAAW,EAAE,yGAAyG;QACtH,QAAQ,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,EAAE;QACpC,GAAG,EAAE,CAAC,EAAe,EAAE,CAAM,EAAE,GAAkB,KAAI;YACnD,IAAI,GAAG,CAAC,OAAO;gBAAE;AACjB,YAAA,OAAO,GAAG,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC,EAAE,SAAS,EAAE,wBAAwB,EAAE,EAAE,EAAE,SAAS,EAAE,CAAA,WAAA,EAAc,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA,eAAA,CAAiB,EAAE,CAAC,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,EAAE,QAAQ,CAAC,KAAK,CAAC,MAAM,SAAS,CAAC;QAClP,CAAC;AACF,KAAA;;AAGH;SACgB,iBAAiB,GAAA;IAC/B,eAAe,CAAC,QAAQ,CAAC;AAC3B;;"}
@@ -969,10 +969,15 @@ declare function registerSafePack(): void;
969
969
  /** Run a pure function in a Web Worker; resolves with its (structured-cloneable) result (9.6). */
970
970
  declare function runInWorker<A extends unknown[], R>(fn: (...args: A) => R | Promise<R>, ...args: A): Promise<R>;
971
971
  type DrawProgram = string | ((ctx: CanvasRenderingContext2D, t: number, w: number, h: number, state: Record<string, unknown>) => void);
972
- /** Animate `canvas` with `program` in a worker (OffscreenCanvas) when possible, else on the main thread (9.6). */
972
+ /**
973
+ * Animate `canvas` with `program` in a worker (OffscreenCanvas) when possible, else on the main thread (9.6).
974
+ * 11.0: a **string** program only runs in a worker. Without a worker it needs `opts.fallback` (a function);
975
+ * otherwise it is refused (`backend: 'none'`, console error) — strings are never evaluated on the main thread.
976
+ */
973
977
  declare function offscreenRender(canvas: HTMLCanvasElement, program: DrawProgram, opts?: {
974
978
  worker?: boolean;
975
979
  paused?: boolean;
980
+ fallback?: Exclude<DrawProgram, string>;
976
981
  }): {
977
982
  backend: 'worker' | 'main' | 'none';
978
983
  stop(): void;
@@ -969,10 +969,15 @@ declare function registerSafePack(): void;
969
969
  /** Run a pure function in a Web Worker; resolves with its (structured-cloneable) result (9.6). */
970
970
  declare function runInWorker<A extends unknown[], R>(fn: (...args: A) => R | Promise<R>, ...args: A): Promise<R>;
971
971
  type DrawProgram = string | ((ctx: CanvasRenderingContext2D, t: number, w: number, h: number, state: Record<string, unknown>) => void);
972
- /** Animate `canvas` with `program` in a worker (OffscreenCanvas) when possible, else on the main thread (9.6). */
972
+ /**
973
+ * Animate `canvas` with `program` in a worker (OffscreenCanvas) when possible, else on the main thread (9.6).
974
+ * 11.0: a **string** program only runs in a worker. Without a worker it needs `opts.fallback` (a function);
975
+ * otherwise it is refused (`backend: 'none'`, console error) — strings are never evaluated on the main thread.
976
+ */
973
977
  declare function offscreenRender(canvas: HTMLCanvasElement, program: DrawProgram, opts?: {
974
978
  worker?: boolean;
975
979
  paused?: boolean;
980
+ fallback?: Exclude<DrawProgram, string>;
976
981
  }): {
977
982
  backend: 'worker' | 'main' | 'none';
978
983
  stop(): void;
@@ -1,9 +1,9 @@
1
1
  'use strict';
2
2
 
3
3
  var base = require('../chunks/base-DBheNxJu.cjs');
4
- var runtimeLink = require('../chunks/runtime-link-GD9ayzxH.cjs');
5
- var widgets_glScene = require('../chunks/three-scene-BFZnZuqp.cjs');
6
- require('../chunks/registry-xGDPpmX2.cjs');
4
+ var runtimeLink = require('../chunks/runtime-link-Bz3rGMsh.cjs');
5
+ var widgets_glScene = require('../chunks/gl-scene-SO5UU93S.cjs');
6
+ require('../chunks/registry-uaO8pDKn.cjs');
7
7
 
8
8
  function defineGlModel(tag = 'usa-gl-model') {
9
9
  return base.defineElement(tag, () => {
@@ -210,7 +210,7 @@ interface GltfAnimator {
210
210
  * `motionary/runtime/gltf-anim`), `animation-speed`; reduced motion shows
211
211
  * the first pose. Renders only while visible. `scene`, `camera`, `root`,
212
212
  * `animator`, `reload()`; `usa:load` { meshes, animations }, `usa:error`.
213
- * `<usa-three-scene>` is an alias with the same API.
213
+ * (The 10.5 alias `<usa-three-scene>` was removed in 11.0.)
214
214
  */
215
215
  interface UsaGlSceneElement extends UsaElement {
216
216
  readonly scene: Scene | null;
@@ -210,7 +210,7 @@ interface GltfAnimator {
210
210
  * `motionary/runtime/gltf-anim`), `animation-speed`; reduced motion shows
211
211
  * the first pose. Renders only while visible. `scene`, `camera`, `root`,
212
212
  * `animator`, `reload()`; `usa:load` { meshes, animations }, `usa:error`.
213
- * `<usa-three-scene>` is an alias with the same API.
213
+ * (The 10.5 alias `<usa-three-scene>` was removed in 11.0.)
214
214
  */
215
215
  interface UsaGlSceneElement extends UsaElement {
216
216
  readonly scene: Scene | null;
@@ -1,7 +1,7 @@
1
1
  import { f as defineElement } from '../chunks/base-BTev8qxg.js';
2
- import { r as runtimeModule } from '../chunks/runtime-link-CQyKFwE1.js';
3
- import { c as css, a as defineGlScene } from '../chunks/three-scene-DibsZUID.js';
4
- import '../chunks/registry-RJYrdUTF.js';
2
+ import { r as runtimeModule } from '../chunks/runtime-link-CP3qaRja.js';
3
+ import { c as css, d as defineGlScene } from '../chunks/gl-scene-BDA6FlGQ.js';
4
+ import '../chunks/registry-W7pXOwju.js';
5
5
 
6
6
  function defineGlModel(tag = 'usa-gl-model') {
7
7
  return defineElement(tag, () => {
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
3
  var base = require('../chunks/base-DBheNxJu.cjs');
4
- var runtimeLink = require('../chunks/runtime-link-GD9ayzxH.cjs');
5
- require('../chunks/registry-xGDPpmX2.cjs');
4
+ var runtimeLink = require('../chunks/runtime-link-Bz3rGMsh.cjs');
5
+ require('../chunks/registry-uaO8pDKn.cjs');
6
6
 
7
7
  var css = "usa-snap-carousel{display:block;position:relative;--usa-sc-size:80%;--usa-sc-gap:16px;--usa-sc-accent:#7c5cff}.usa-sc-viewport{overflow:hidden;border-radius:var(--usa-radius,14px);outline:none;cursor:grab}.usa-sc-viewport:focus-visible{box-shadow:0 0 0 2px var(--usa-sc-accent)}usa-snap-carousel[data-dragging] .usa-sc-viewport{cursor:grabbing}.usa-sc-track{display:flex;gap:var(--usa-sc-gap);will-change:transform;user-select:none;-webkit-user-select:none}.usa-sc-track>*{flex:0 0 var(--usa-sc-size);min-width:0;box-sizing:border-box;transition:opacity .3s,transform .3s}.usa-sc-track img{pointer-events:none;-webkit-user-drag:none}usa-snap-carousel:not([data-ready]) .usa-sc-viewport{overflow-x:auto;scroll-snap-type:x mandatory;scrollbar-width:thin}usa-snap-carousel:not([data-ready]) .usa-sc-track>*{scroll-snap-align:center}usa-snap-carousel[data-ready] .usa-sc-track>:not([data-active]){opacity:.55;transform:scale(.94)}.usa-sc-nav{position:absolute;top:calc(50% - 18px);z-index:2;width:36px;height:36px;border-radius:50%;border:0;background:rgba(255,255,255,.9);color:#111;font:600 20px/1 system-ui;cursor:pointer;display:grid;place-items:center;box-shadow:0 4px 14px rgba(0,0,0,.18)}.usa-sc-nav:disabled{opacity:.35;cursor:default}.usa-sc-nav:focus-visible,.usa-sc-dot:focus-visible{outline:2px solid var(--usa-sc-accent);outline-offset:2px}.usa-sc-prev{left:8px}.usa-sc-next{right:8px}.usa-sc-dots{display:flex;justify-content:center;gap:6px;padding-top:10px}.usa-sc-dot{width:8px;height:8px;padding:0;border:0;border-radius:99px;background:color-mix(in srgb,currentColor 30%,transparent);cursor:pointer;transition:width .3s,background .3s}.usa-sc-dot[aria-current=\"true\"]{width:22px;background:var(--usa-sc-accent)}.usa-sc-live{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;margin:0}@media (prefers-reduced-motion:reduce){.usa-sc-track>*,.usa-sc-dot{transition:none}}";
8
8
 
@@ -1,6 +1,6 @@
1
1
  import { f as defineElement } from '../chunks/base-BTev8qxg.js';
2
- import { r as runtimeModule } from '../chunks/runtime-link-CQyKFwE1.js';
3
- import '../chunks/registry-RJYrdUTF.js';
2
+ import { r as runtimeModule } from '../chunks/runtime-link-CP3qaRja.js';
3
+ import '../chunks/registry-W7pXOwju.js';
4
4
 
5
5
  var css = "usa-snap-carousel{display:block;position:relative;--usa-sc-size:80%;--usa-sc-gap:16px;--usa-sc-accent:#7c5cff}.usa-sc-viewport{overflow:hidden;border-radius:var(--usa-radius,14px);outline:none;cursor:grab}.usa-sc-viewport:focus-visible{box-shadow:0 0 0 2px var(--usa-sc-accent)}usa-snap-carousel[data-dragging] .usa-sc-viewport{cursor:grabbing}.usa-sc-track{display:flex;gap:var(--usa-sc-gap);will-change:transform;user-select:none;-webkit-user-select:none}.usa-sc-track>*{flex:0 0 var(--usa-sc-size);min-width:0;box-sizing:border-box;transition:opacity .3s,transform .3s}.usa-sc-track img{pointer-events:none;-webkit-user-drag:none}usa-snap-carousel:not([data-ready]) .usa-sc-viewport{overflow-x:auto;scroll-snap-type:x mandatory;scrollbar-width:thin}usa-snap-carousel:not([data-ready]) .usa-sc-track>*{scroll-snap-align:center}usa-snap-carousel[data-ready] .usa-sc-track>:not([data-active]){opacity:.55;transform:scale(.94)}.usa-sc-nav{position:absolute;top:calc(50% - 18px);z-index:2;width:36px;height:36px;border-radius:50%;border:0;background:rgba(255,255,255,.9);color:#111;font:600 20px/1 system-ui;cursor:pointer;display:grid;place-items:center;box-shadow:0 4px 14px rgba(0,0,0,.18)}.usa-sc-nav:disabled{opacity:.35;cursor:default}.usa-sc-nav:focus-visible,.usa-sc-dot:focus-visible{outline:2px solid var(--usa-sc-accent);outline-offset:2px}.usa-sc-prev{left:8px}.usa-sc-next{right:8px}.usa-sc-dots{display:flex;justify-content:center;gap:6px;padding-top:10px}.usa-sc-dot{width:8px;height:8px;padding:0;border:0;border-radius:99px;background:color-mix(in srgb,currentColor 30%,transparent);cursor:pointer;transition:width .3s,background .3s}.usa-sc-dot[aria-current=\"true\"]{width:22px;background:var(--usa-sc-accent)}.usa-sc-live{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;margin:0}@media (prefers-reduced-motion:reduce){.usa-sc-track>*,.usa-sc-dot{transition:none}}";
6
6