use-scroll-animate 10.2.0 → 10.4.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.
- package/AGENTS.md +4 -0
- package/CHANGELOG.md +35 -0
- package/README.md +67 -0
- package/bin/motionary-mcp.mjs +265 -0
- package/dist/chunks/anim-image-DDdb9q3X.js +166 -0
- package/dist/chunks/anim-image-DDdb9q3X.js.map +1 -0
- package/dist/chunks/anim-image-blQgPFFS.cjs +174 -0
- package/dist/chunks/anim-image-blQgPFFS.cjs.map +1 -0
- package/dist/chunks/audio-BpU-A1m1.cjs.map +1 -1
- package/dist/chunks/{audio-D95jwlOh.js → audio-CWt1xdZB.js} +3 -3
- package/dist/chunks/{audio-D95jwlOh.js.map → audio-CWt1xdZB.js.map} +1 -1
- package/dist/chunks/{base-BnRyfuyM.js → base-BTev8qxg.js} +2 -2
- package/dist/chunks/{base-BnRyfuyM.js.map → base-BTev8qxg.js.map} +1 -1
- package/dist/chunks/base-DBheNxJu.cjs.map +1 -1
- package/dist/chunks/bind-B_CTL6Qn.js.map +1 -1
- package/dist/chunks/bind-Ui43-n2d.cjs.map +1 -1
- package/dist/chunks/builtins-CKKZNR95.cjs.map +1 -1
- package/dist/chunks/{builtins-CqIq1zBv.js → builtins-CPmS6aDB.js} +3 -3
- package/dist/chunks/{builtins-CqIq1zBv.js.map → builtins-CPmS6aDB.js.map} +1 -1
- package/dist/chunks/core-B5T0dhFH.cjs.map +1 -1
- package/dist/chunks/{core-DsGoL9EY.js → core-BviA7nFa.js} +2 -2
- package/dist/chunks/{core-DsGoL9EY.js.map → core-BviA7nFa.js.map} +1 -1
- package/dist/chunks/core-D74Fz-dL.cjs.map +1 -1
- package/dist/chunks/core-D7cVumUu.js.map +1 -1
- package/dist/chunks/{core-XA2yhn1b.js → core-KiM7MXjL.js} +2 -2
- package/dist/chunks/{core-XA2yhn1b.js.map → core-KiM7MXjL.js.map} +1 -1
- package/dist/chunks/core-MQlXZKUG.cjs.map +1 -1
- package/dist/chunks/ease-HwYZnZat.cjs +94 -0
- package/dist/chunks/ease-HwYZnZat.cjs.map +1 -0
- package/dist/chunks/ease-XN8_0sXu.js +89 -0
- package/dist/chunks/ease-XN8_0sXu.js.map +1 -0
- package/dist/chunks/fx-B_pbhpDp.cjs.map +1 -1
- package/dist/chunks/{fx-CtnrFEg9.js → fx-CgWKqVsn.js} +2 -2
- package/dist/chunks/{fx-CtnrFEg9.js.map → fx-CgWKqVsn.js.map} +1 -1
- package/dist/chunks/generative-2LhxG5BJ.js.map +1 -1
- package/dist/chunks/generative-BHIj-NU0.cjs.map +1 -1
- package/dist/chunks/{gpu-CDcXiNA8.js → gpu-BWfgYWMY.js} +2 -2
- package/dist/chunks/{gpu-CDcXiNA8.js.map → gpu-BWfgYWMY.js.map} +1 -1
- package/dist/chunks/gpu-cUixt7kT.cjs.map +1 -1
- package/dist/chunks/index-tags-B-JBecYg.js.map +1 -1
- package/dist/chunks/index-tags-hLIF2Clq.cjs.map +1 -1
- package/dist/chunks/{keyframes-W-474DMc.js → keyframes-B5PWe5bU.js} +3 -2
- package/dist/chunks/keyframes-B5PWe5bU.js.map +1 -0
- package/dist/chunks/{keyframes-ZheOkpt0.cjs → keyframes-tC3I7anQ.cjs} +4 -3
- package/dist/chunks/keyframes-tC3I7anQ.cjs.map +1 -0
- package/dist/chunks/{manifest-D58HXVY-.js → manifest-BHx5yPN6.js} +2 -2
- package/dist/chunks/{manifest-D58HXVY-.js.map → manifest-BHx5yPN6.js.map} +1 -1
- package/dist/chunks/manifest-PaF9B8Vt.cjs.map +1 -1
- package/dist/chunks/{player-48Zy_NBG.js → player-BfHMNtiM.js} +4 -4
- package/dist/chunks/{player-48Zy_NBG.js.map → player-BfHMNtiM.js.map} +1 -1
- package/dist/chunks/player-C4y4jXSv.cjs.map +1 -1
- package/dist/chunks/presets-BYBVJVeP.js.map +1 -1
- package/dist/chunks/presets-CUHys3sK.cjs.map +1 -1
- package/dist/chunks/{registry-gFJRpPES.js → registry-BKzyg1JV.js} +2 -2
- package/dist/chunks/{registry-gFJRpPES.js.map → registry-BKzyg1JV.js.map} +1 -1
- package/dist/chunks/{registry-BIEjKngP.js → registry-CT-TT_bx.js} +3 -3
- package/dist/chunks/{registry-BIEjKngP.js.map → registry-CT-TT_bx.js.map} +1 -1
- package/dist/chunks/{registry-eJgpFAzI.cjs → registry-tzwKkldE.cjs} +2 -2
- package/dist/chunks/{registry-eJgpFAzI.cjs.map → registry-tzwKkldE.cjs.map} +1 -1
- package/dist/chunks/registry-xQZnSqqV.cjs.map +1 -1
- package/dist/chunks/shared-CkKHWrtJ.js.map +1 -1
- package/dist/chunks/shared-jkgRH-Hx.cjs.map +1 -1
- package/dist/chunks/{spring-CZDNyqWp.js → spring-BHuP55DR.js} +2 -2
- package/dist/chunks/{spring-CZDNyqWp.js.map → spring-BHuP55DR.js.map} +1 -1
- package/dist/chunks/spring-BlTQD2AV.cjs.map +1 -1
- package/dist/chunks/stagger-CCFyhzSw.cjs.map +1 -1
- package/dist/chunks/stagger-DtMKo2SK.js.map +1 -1
- package/dist/chunks/{ticker-CM_56oVy.js → ticker-C8lSGml9.js} +2 -2
- package/dist/chunks/{ticker-CM_56oVy.js.map → ticker-C8lSGml9.js.map} +1 -1
- package/dist/chunks/{ticker-D4o6enH0.cjs → ticker-Un0bvTWR.cjs} +2 -2
- package/dist/chunks/{ticker-D4o6enH0.cjs.map → ticker-Un0bvTWR.cjs.map} +1 -1
- package/dist/chunks/{tween-CqX1JBuj.js → tween-BcejKpsx.js} +15 -91
- package/dist/chunks/tween-BcejKpsx.js.map +1 -0
- package/dist/chunks/{tween-CBuWYpI-.cjs → tween-CwLLC3Ko.cjs} +15 -95
- package/dist/chunks/tween-CwLLC3Ko.cjs.map +1 -0
- package/dist/chunks/variants-CrDDJoYK.cjs.map +1 -1
- package/dist/chunks/{variants-GU3yIL4F.js → variants-CsRGUIyA.js} +2 -2
- package/dist/chunks/{variants-GU3yIL4F.js.map → variants-CsRGUIyA.js.map} +1 -1
- package/dist/components/a11y.cjs.map +1 -1
- package/dist/components/a11y.js +2 -2
- package/dist/components/a11y.js.map +1 -1
- package/dist/components/angular.cjs.map +1 -1
- package/dist/components/angular.js +8 -8
- package/dist/components/angular.js.map +1 -1
- package/dist/components/background.cjs.map +1 -1
- package/dist/components/background.js +2 -2
- package/dist/components/background.js.map +1 -1
- package/dist/components/bridge.cjs.map +1 -1
- package/dist/components/bridge.js +1 -1
- package/dist/components/bridge.js.map +1 -1
- package/dist/components/cards.cjs.map +1 -1
- package/dist/components/cards.js +2 -2
- package/dist/components/cards.js.map +1 -1
- package/dist/components/click.cjs.map +1 -1
- package/dist/components/click.js +3 -3
- package/dist/components/click.js.map +1 -1
- package/dist/components/core.cjs.map +1 -1
- package/dist/components/core.js.map +1 -1
- package/dist/components/depth.cjs.map +1 -1
- package/dist/components/depth.js +3 -3
- package/dist/components/depth.js.map +1 -1
- package/dist/components/design.cjs.map +1 -1
- package/dist/components/design.js +3 -3
- package/dist/components/design.js.map +1 -1
- package/dist/components/dsl.cjs.map +1 -1
- package/dist/components/dsl.js +2 -2
- package/dist/components/dsl.js.map +1 -1
- package/dist/components/effects.cjs.map +1 -1
- package/dist/components/effects.js +9 -9
- package/dist/components/effects.js.map +1 -1
- package/dist/components/engine.cjs.map +1 -1
- package/dist/components/engine.js +2 -2
- package/dist/components/engine.js.map +1 -1
- package/dist/components/feedback.cjs.map +1 -1
- package/dist/components/feedback.js +1 -1
- package/dist/components/feedback.js.map +1 -1
- package/dist/components/fx-3d.cjs.map +1 -1
- package/dist/components/fx-3d.js +2 -2
- package/dist/components/fx-3d.js.map +1 -1
- package/dist/components/fx-ai.cjs.map +1 -1
- package/dist/components/fx-ai.js +2 -2
- package/dist/components/fx-ai.js.map +1 -1
- package/dist/components/fx-chart.cjs.map +1 -1
- package/dist/components/fx-chart.js +2 -2
- package/dist/components/fx-chart.js.map +1 -1
- package/dist/components/fx-cinema.cjs.map +1 -1
- package/dist/components/fx-cinema.js +2 -2
- package/dist/components/fx-cinema.js.map +1 -1
- package/dist/components/fx-cyber.cjs.map +1 -1
- package/dist/components/fx-cyber.js +2 -2
- package/dist/components/fx-cyber.js.map +1 -1
- package/dist/components/fx-festival.cjs.map +1 -1
- package/dist/components/fx-festival.js +2 -2
- package/dist/components/fx-festival.js.map +1 -1
- package/dist/components/fx-focus.cjs.map +1 -1
- package/dist/components/fx-focus.js +2 -2
- package/dist/components/fx-focus.js.map +1 -1
- package/dist/components/fx-form.cjs.map +1 -1
- package/dist/components/fx-form.js +2 -2
- package/dist/components/fx-form.js.map +1 -1
- package/dist/components/fx-game.cjs.map +1 -1
- package/dist/components/fx-game.js +2 -2
- package/dist/components/fx-game.js.map +1 -1
- package/dist/components/fx-genart.cjs.map +1 -1
- package/dist/components/fx-genart.js +2 -2
- package/dist/components/fx-genart.js.map +1 -1
- package/dist/components/fx-geo.cjs.map +1 -1
- package/dist/components/fx-geo.js +2 -2
- package/dist/components/fx-geo.js.map +1 -1
- package/dist/components/fx-gesture.cjs.map +1 -1
- package/dist/components/fx-gesture.js +2 -2
- package/dist/components/fx-gesture.js.map +1 -1
- package/dist/components/fx-gpu.js +3 -3
- package/dist/components/fx-light.cjs.map +1 -1
- package/dist/components/fx-light.js +2 -2
- package/dist/components/fx-light.js.map +1 -1
- package/dist/components/fx-lottie.cjs.map +1 -1
- package/dist/components/fx-lottie.js +2 -2
- package/dist/components/fx-lottie.js.map +1 -1
- package/dist/components/fx-morph.cjs.map +1 -1
- package/dist/components/fx-morph.js +2 -2
- package/dist/components/fx-morph.js.map +1 -1
- package/dist/components/fx-music.cjs.map +1 -1
- package/dist/components/fx-music.js +3 -3
- package/dist/components/fx-music.js.map +1 -1
- package/dist/components/fx-organic.cjs.map +1 -1
- package/dist/components/fx-organic.js +2 -2
- package/dist/components/fx-organic.js.map +1 -1
- package/dist/components/fx-paper.cjs.map +1 -1
- package/dist/components/fx-paper.js +2 -2
- package/dist/components/fx-paper.js.map +1 -1
- package/dist/components/fx-perf.cjs.map +1 -1
- package/dist/components/fx-perf.js +2 -2
- package/dist/components/fx-perf.js.map +1 -1
- package/dist/components/fx-physics.cjs.map +1 -1
- package/dist/components/fx-physics.js +2 -2
- package/dist/components/fx-physics.js.map +1 -1
- package/dist/components/fx-retro.cjs.map +1 -1
- package/dist/components/fx-retro.js +2 -2
- package/dist/components/fx-retro.js.map +1 -1
- package/dist/components/fx-safe.cjs.map +1 -1
- package/dist/components/fx-safe.js +2 -2
- package/dist/components/fx-safe.js.map +1 -1
- package/dist/components/fx-shop.cjs.map +1 -1
- package/dist/components/fx-shop.js +2 -2
- package/dist/components/fx-shop.js.map +1 -1
- package/dist/components/fx-social.cjs.map +1 -1
- package/dist/components/fx-social.js +2 -2
- package/dist/components/fx-social.js.map +1 -1
- package/dist/components/fx-spatial.cjs.map +1 -1
- package/dist/components/fx-spatial.js +2 -2
- package/dist/components/fx-spatial.js.map +1 -1
- package/dist/components/fx-surface.cjs.map +1 -1
- package/dist/components/fx-surface.js +2 -2
- package/dist/components/fx-surface.js.map +1 -1
- package/dist/components/fx-text.cjs.map +1 -1
- package/dist/components/fx-text.js +2 -2
- package/dist/components/fx-text.js.map +1 -1
- package/dist/components/fx-transitions.cjs.map +1 -1
- package/dist/components/fx-transitions.js +3 -3
- package/dist/components/fx-transitions.js.map +1 -1
- package/dist/components/fx-video.cjs.map +1 -1
- package/dist/components/fx-video.js +2 -2
- package/dist/components/fx-video.js.map +1 -1
- package/dist/components/fx-weather.cjs.map +1 -1
- package/dist/components/fx-weather.js +2 -2
- package/dist/components/fx-weather.js.map +1 -1
- package/dist/components/fx.cjs.map +1 -1
- package/dist/components/fx.js +6 -6
- package/dist/components/fx.js.map +1 -1
- package/dist/components/fx2.cjs.map +1 -1
- package/dist/components/fx2.js +6 -6
- package/dist/components/fx2.js.map +1 -1
- package/dist/components/gesture.cjs.map +1 -1
- package/dist/components/gesture.js +4 -4
- package/dist/components/gesture.js.map +1 -1
- package/dist/components/interaction.cjs.map +1 -1
- package/dist/components/interaction.js +1 -1
- package/dist/components/interaction.js.map +1 -1
- package/dist/components/layout.cjs.map +1 -1
- package/dist/components/layout.js +1 -1
- package/dist/components/layout.js.map +1 -1
- package/dist/components/lazy.cjs.map +1 -1
- package/dist/components/lazy.js.map +1 -1
- package/dist/components/lite.cjs.map +1 -1
- package/dist/components/lite.js.map +1 -1
- package/dist/components/marketplace.cjs.map +1 -1
- package/dist/components/marketplace.js +4 -4
- package/dist/components/marketplace.js.map +1 -1
- package/dist/components/native.cjs.map +1 -1
- package/dist/components/native.js +3 -3
- package/dist/components/native.js.map +1 -1
- package/dist/components/packs.cjs.map +1 -1
- package/dist/components/packs.js +1 -1
- package/dist/components/packs.js.map +1 -1
- package/dist/components/page.cjs.map +1 -1
- package/dist/components/page.js +3 -3
- package/dist/components/page.js.map +1 -1
- package/dist/components/perf.cjs.map +1 -1
- package/dist/components/perf.js +2 -2
- package/dist/components/perf.js.map +1 -1
- package/dist/components/physics.cjs.map +1 -1
- package/dist/components/physics.js +3 -3
- package/dist/components/physics.js.map +1 -1
- package/dist/components/plugins.cjs.map +1 -1
- package/dist/components/plugins.js +4 -4
- package/dist/components/plugins.js.map +1 -1
- package/dist/components/react.cjs.map +1 -1
- package/dist/components/react.js.map +1 -1
- package/dist/components/reveal.cjs.map +1 -1
- package/dist/components/reveal.js +1 -1
- package/dist/components/reveal.js.map +1 -1
- package/dist/components/solid.cjs.map +1 -1
- package/dist/components/solid.js +8 -8
- package/dist/components/solid.js.map +1 -1
- package/dist/components/svelte.cjs.map +1 -1
- package/dist/components/svelte.js +8 -8
- package/dist/components/svelte.js.map +1 -1
- package/dist/components/svg.cjs.map +1 -1
- package/dist/components/svg.js +1 -1
- package/dist/components/svg.js.map +1 -1
- package/dist/components/text.cjs.map +1 -1
- package/dist/components/text.js +2 -2
- package/dist/components/text.js.map +1 -1
- package/dist/components/timeline.cjs.map +1 -1
- package/dist/components/timeline.js +3 -3
- package/dist/components/timeline.js.map +1 -1
- package/dist/components/tokens.cjs.map +1 -1
- package/dist/components/tokens.js.map +1 -1
- package/dist/components/transitions.cjs.map +1 -1
- package/dist/components/transitions.js +1 -1
- package/dist/components/transitions.js.map +1 -1
- package/dist/components/ui.cjs.map +1 -1
- package/dist/components/ui.js +4 -4
- package/dist/components/ui.js.map +1 -1
- package/dist/components/vue.cjs.map +1 -1
- package/dist/components/vue.js +8 -8
- package/dist/components/vue.js.map +1 -1
- package/dist/components/webgl.cjs.map +1 -1
- package/dist/components/webgl.js +1 -1
- package/dist/components/webgl.js.map +1 -1
- package/dist/components/widgets.cjs +766 -212
- package/dist/components/widgets.cjs.map +1 -1
- package/dist/components/widgets.d.cts +207 -2
- package/dist/components/widgets.d.ts +207 -2
- package/dist/components/widgets.js +770 -221
- package/dist/components/widgets.js.map +1 -1
- package/dist/components.cjs.map +1 -1
- package/dist/components.js +10 -10
- package/dist/components.js.map +1 -1
- package/dist/element.cjs.map +1 -1
- package/dist/element.js.map +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/llms-full.txt +250 -1
- package/dist/llms.txt +13 -2
- package/dist/manifest.json +646 -1
- package/dist/presets/extended.cjs.map +1 -1
- package/dist/presets/extended.js.map +1 -1
- package/dist/react.cjs.map +1 -1
- package/dist/react.js.map +1 -1
- package/dist/runtime/format-apng.cjs +131 -0
- package/dist/runtime/format-apng.cjs.map +1 -0
- package/dist/runtime/format-apng.d.cts +250 -0
- package/dist/runtime/format-apng.d.ts +250 -0
- package/dist/runtime/format-apng.iife.js +2 -0
- package/dist/runtime/format-apng.iife.js.map +1 -0
- package/dist/runtime/format-apng.js +123 -0
- package/dist/runtime/format-apng.js.map +1 -0
- package/dist/runtime/format-css.cjs +5 -4
- package/dist/runtime/format-css.cjs.map +1 -1
- package/dist/runtime/format-css.js +5 -4
- package/dist/runtime/format-css.js.map +1 -1
- package/dist/runtime/format-gif.cjs +206 -0
- package/dist/runtime/format-gif.cjs.map +1 -0
- package/dist/runtime/format-gif.d.cts +223 -0
- package/dist/runtime/format-gif.d.ts +223 -0
- package/dist/runtime/format-gif.iife.js +2 -0
- package/dist/runtime/format-gif.iife.js.map +1 -0
- package/dist/runtime/format-gif.js +199 -0
- package/dist/runtime/format-gif.js.map +1 -0
- package/dist/runtime/format-motion.cjs +9 -8
- package/dist/runtime/format-motion.cjs.map +1 -1
- package/dist/runtime/format-motion.js +5 -4
- package/dist/runtime/format-motion.js.map +1 -1
- package/dist/runtime/format-sprite.cjs +226 -0
- package/dist/runtime/format-sprite.cjs.map +1 -0
- package/dist/runtime/format-sprite.d.cts +224 -0
- package/dist/runtime/format-sprite.d.ts +224 -0
- package/dist/runtime/format-sprite.iife.js +2 -0
- package/dist/runtime/format-sprite.iife.js.map +1 -0
- package/dist/runtime/format-sprite.js +216 -0
- package/dist/runtime/format-sprite.js.map +1 -0
- package/dist/runtime/format-svg.cjs +5 -4
- package/dist/runtime/format-svg.cjs.map +1 -1
- package/dist/runtime/format-svg.iife.js.map +1 -1
- package/dist/runtime/format-svg.js +4 -3
- package/dist/runtime/format-svg.js.map +1 -1
- package/dist/runtime/format-webp.cjs +123 -0
- package/dist/runtime/format-webp.cjs.map +1 -0
- package/dist/runtime/format-webp.d.cts +245 -0
- package/dist/runtime/format-webp.d.ts +245 -0
- package/dist/runtime/format-webp.iife.js +2 -0
- package/dist/runtime/format-webp.iife.js.map +1 -0
- package/dist/runtime/format-webp.js +115 -0
- package/dist/runtime/format-webp.js.map +1 -0
- package/dist/runtime/scroll.cjs +2 -2
- package/dist/runtime/scroll.cjs.map +1 -1
- package/dist/runtime/scroll.js +2 -2
- package/dist/runtime/scroll.js.map +1 -1
- package/dist/runtime/smooth.cjs +284 -0
- package/dist/runtime/smooth.cjs.map +1 -0
- package/dist/runtime/smooth.d.cts +137 -0
- package/dist/runtime/smooth.d.ts +137 -0
- package/dist/runtime/smooth.iife.js +2 -0
- package/dist/runtime/smooth.iife.js.map +1 -0
- package/dist/runtime/smooth.js +279 -0
- package/dist/runtime/smooth.js.map +1 -0
- package/dist/runtime/text.cjs +147 -0
- package/dist/runtime/text.cjs.map +1 -0
- package/dist/runtime/text.d.cts +65 -0
- package/dist/runtime/text.d.ts +65 -0
- package/dist/runtime/text.iife.js +2 -0
- package/dist/runtime/text.iife.js.map +1 -0
- package/dist/runtime/text.js +143 -0
- package/dist/runtime/text.js.map +1 -0
- package/dist/runtime.cjs +9 -8
- package/dist/runtime.cjs.map +1 -1
- package/dist/runtime.d.cts +9 -2
- package/dist/runtime.d.ts +9 -2
- package/dist/runtime.iife.js +1 -1
- package/dist/runtime.iife.js.map +1 -1
- package/dist/runtime.js +6 -5
- package/dist/runtime.js.map +1 -1
- package/dist/solid.cjs.map +1 -1
- package/dist/solid.js.map +1 -1
- package/dist/svelte.cjs.map +1 -1
- package/dist/svelte.js.map +1 -1
- package/dist/vue.cjs.map +1 -1
- package/dist/vue.js.map +1 -1
- package/dist/widgets.umd.js +1 -1
- package/dist/widgets.umd.js.map +1 -1
- package/docs/ROADMAP.md +2 -2
- package/docs/components/README.md +12 -7
- package/docs/components/usa-parallax-layers.md +38 -0
- package/docs/components/usa-route-transition.md +38 -0
- package/docs/components/usa-scroll-ring.md +32 -0
- package/docs/components/usa-smooth-scroll.md +60 -0
- package/docs/components/usa-text-splitter.md +60 -0
- package/docs/components.md +94 -0
- package/docs/mcp.md +50 -0
- package/docs/runtime/format-apng.md +59 -0
- package/docs/runtime/format-gif.md +60 -0
- package/docs/runtime/format-sprite.md +60 -0
- package/docs/runtime/format-webp.md +58 -0
- package/docs/runtime/smooth.md +60 -0
- package/docs/runtime/text.md +59 -0
- package/package.json +64 -2
- package/dist/chunks/keyframes-W-474DMc.js.map +0 -1
- package/dist/chunks/keyframes-ZheOkpt0.cjs.map +0 -1
- package/dist/chunks/tween-CBuWYpI-.cjs.map +0 -1
- package/dist/chunks/tween-CqX1JBuj.js.map +0 -1
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { R as RUNTIME_VERSION } from '../chunks/registry-CT-TT_bx.js';
|
|
2
|
+
import { a as animatedImagePlayer, b as browserDecode, c as composeFrames, d as bytesOf, u as u8, f as fixDelay, e as crc32 } from '../chunks/anim-image-DDdb9q3X.js';
|
|
3
|
+
import '../chunks/tween-BcejKpsx.js';
|
|
4
|
+
import '../chunks/ticker-C8lSGml9.js';
|
|
5
|
+
import '../chunks/ease-XN8_0sXu.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* `motionary/runtime/format-apng` (10.4) — animated PNG (APNG) loader written
|
|
9
|
+
* for Motionary: reads `acTL` / `fcTL` / `fdAT`, rebuilds every frame as a
|
|
10
|
+
* standalone PNG (header + palette / transparency chunks + its image data,
|
|
11
|
+
* with fresh CRCs) and lets the browser's own PNG decoder decode it, then
|
|
12
|
+
* composites the frames (`dispose_op` none / background / previous,
|
|
13
|
+
* `blend_op` source / over) into full-size RGBA. A plain (non-animated) PNG
|
|
14
|
+
* loads as a one-frame animation.
|
|
15
|
+
*
|
|
16
|
+
* `parseApng()` and `apngFramePngs()` are pure (no DOM); `decodeApng()` needs
|
|
17
|
+
* an image decoder — the browser's by default (also in workers), or your own
|
|
18
|
+
* via `{ decode }`.
|
|
19
|
+
*/
|
|
20
|
+
const SIG = [137, 80, 78, 71, 13, 10, 26, 10];
|
|
21
|
+
const u32 = (b, i) => ((b[i] << 24) | (b[i + 1] << 16) | (b[i + 2] << 8) | b[i + 3]) >>> 0;
|
|
22
|
+
const u16 = (b, i) => (b[i] << 8) | b[i + 1];
|
|
23
|
+
/** Read the chunk list of a PNG / APNG (pure). */
|
|
24
|
+
function pngChunks(b) {
|
|
25
|
+
for (let i = 0; i < 8; i++)
|
|
26
|
+
if (b[i] !== SIG[i])
|
|
27
|
+
throw new Error('[motionary] format-apng: not a PNG file');
|
|
28
|
+
const out = [];
|
|
29
|
+
let p = 8;
|
|
30
|
+
while (p + 8 <= b.length) {
|
|
31
|
+
const len = u32(b, p), type = String.fromCharCode(b[p + 4], b[p + 5], b[p + 6], b[p + 7]);
|
|
32
|
+
out.push({ type, data: b.subarray(p + 8, p + 8 + len) });
|
|
33
|
+
p += 12 + len;
|
|
34
|
+
if (type === 'IEND')
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
return out;
|
|
38
|
+
}
|
|
39
|
+
/** Parse the animation structure (pure; no pixels decoded). */
|
|
40
|
+
function parseApng(input) {
|
|
41
|
+
const b = u8(input);
|
|
42
|
+
const chunks = pngChunks(b);
|
|
43
|
+
const ihdr = chunks[0]?.type === 'IHDR' ? chunks[0].data : null;
|
|
44
|
+
if (!ihdr)
|
|
45
|
+
throw new Error('[motionary] format-apng: missing IHDR');
|
|
46
|
+
const width = u32(ihdr, 0), height = u32(ihdr, 4);
|
|
47
|
+
const shared = chunks.filter((c) => /^(PLTE|tRNS|gAMA|cHRM|sRGB|iCCP|sBIT)$/.test(c.type));
|
|
48
|
+
const actl = chunks.find((c) => c.type === 'acTL');
|
|
49
|
+
const frames = [];
|
|
50
|
+
let cur = null, sawIdat = false, idatHasFrame = false;
|
|
51
|
+
const idat = [];
|
|
52
|
+
for (const c of chunks) {
|
|
53
|
+
if (c.type === 'fcTL') {
|
|
54
|
+
const d = c.data;
|
|
55
|
+
const dn = u16(d, 20), dd = u16(d, 22) || 100;
|
|
56
|
+
cur = { width: u32(d, 4), height: u32(d, 8), x: u32(d, 12), y: u32(d, 16), delay: fixDelay((dn / dd) * 1000), dispose: ['none', 'background', 'previous'][d[24]] || 'none', blend: d[25] === 1 ? 'over' : 'source', data: [] };
|
|
57
|
+
frames.push(cur);
|
|
58
|
+
if (!sawIdat)
|
|
59
|
+
idatHasFrame = true;
|
|
60
|
+
}
|
|
61
|
+
else if (c.type === 'IDAT') {
|
|
62
|
+
sawIdat = true;
|
|
63
|
+
idat.push(c.data);
|
|
64
|
+
if (cur && idatHasFrame)
|
|
65
|
+
cur.data.push(c.data);
|
|
66
|
+
}
|
|
67
|
+
else if (c.type === 'fdAT' && cur)
|
|
68
|
+
cur.data.push(c.data.subarray(4)); // drop the sequence number
|
|
69
|
+
}
|
|
70
|
+
if (!actl || !frames.length) {
|
|
71
|
+
// a plain PNG: one frame, the whole image
|
|
72
|
+
return { width, height, plays: 1, animated: false, hiddenDefault: false, frames: [{ width, height, x: 0, y: 0, delay: 100, dispose: 'none', blend: 'source', data: idat }], shared, ihdr };
|
|
73
|
+
}
|
|
74
|
+
// the first frame's dispose "previous" acts like "background" (spec)
|
|
75
|
+
if (frames[0].dispose === 'previous')
|
|
76
|
+
frames[0].dispose = 'background';
|
|
77
|
+
return { width, height, plays: u32(actl.data, 4), animated: true, hiddenDefault: !idatHasFrame, frames, shared, ihdr };
|
|
78
|
+
}
|
|
79
|
+
function chunk(type, data) {
|
|
80
|
+
const out = new Uint8Array(12 + data.length);
|
|
81
|
+
const v = new DataView(out.buffer);
|
|
82
|
+
v.setUint32(0, data.length);
|
|
83
|
+
for (let i = 0; i < 4; i++)
|
|
84
|
+
out[4 + i] = type.charCodeAt(i);
|
|
85
|
+
out.set(data, 8);
|
|
86
|
+
v.setUint32(8 + data.length, crc32(out, 4, 8 + data.length));
|
|
87
|
+
return out;
|
|
88
|
+
}
|
|
89
|
+
/** Rebuild every animation frame as a standalone PNG file (pure). */
|
|
90
|
+
function apngFramePngs(info) {
|
|
91
|
+
return info.frames.map((f) => {
|
|
92
|
+
const ihdr = new Uint8Array(info.ihdr); // a copy (never a Node Buffer view)
|
|
93
|
+
const v = new DataView(ihdr.buffer);
|
|
94
|
+
v.setUint32(0, f.width);
|
|
95
|
+
v.setUint32(4, f.height);
|
|
96
|
+
const parts = [new Uint8Array(SIG), chunk('IHDR', ihdr), ...info.shared.map((c) => chunk(c.type, c.data)), ...f.data.map((d) => chunk('IDAT', d)), chunk('IEND', new Uint8Array(0))];
|
|
97
|
+
const out = new Uint8Array(parts.reduce((n, p) => n + p.length, 0));
|
|
98
|
+
let o = 0;
|
|
99
|
+
for (const p of parts) {
|
|
100
|
+
out.set(p, o);
|
|
101
|
+
o += p.length;
|
|
102
|
+
}
|
|
103
|
+
return out;
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
/** Decode an APNG (or PNG) into composited RGBA frames. */
|
|
107
|
+
async function decodeApng(input, o = {}) {
|
|
108
|
+
const info = parseApng(input);
|
|
109
|
+
const decode = o.decode || browserDecode;
|
|
110
|
+
const pngs = apngFramePngs(info);
|
|
111
|
+
const images = await Promise.all(pngs.map((p) => decode(p, 'image/png')));
|
|
112
|
+
const parts = info.frames.map((f, i) => ({ x: f.x, y: f.y, image: images[i], delay: f.delay, blend: f.blend, dispose: f.dispose }));
|
|
113
|
+
return { format: 'apng', width: info.width, height: info.height, plays: info.plays, frames: composeFrames(info.width, info.height, parts), info };
|
|
114
|
+
}
|
|
115
|
+
/** Fetch (URL) or read (ArrayBuffer / Blob / bytes) and decode an APNG. */
|
|
116
|
+
async function loadApng(src, o = {}) {
|
|
117
|
+
return decodeApng(await bytesOf(src), o);
|
|
118
|
+
}
|
|
119
|
+
/** The module object for `use(formatApng)`. */
|
|
120
|
+
const formatApng = { id: 'format-apng', version: RUNTIME_VERSION, requires: ['core'], api: { parseApng, apngFramePngs, decodeApng, loadApng, animatedImagePlayer } };
|
|
121
|
+
|
|
122
|
+
export { animatedImagePlayer, apngFramePngs, decodeApng, formatApng, loadApng, parseApng, pngChunks };
|
|
123
|
+
//# sourceMappingURL=format-apng.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-apng.js","sources":["../../src/runtime/format-apng.ts"],"sourcesContent":["/**\n * `motionary/runtime/format-apng` (10.4) — animated PNG (APNG) loader written\n * for Motionary: reads `acTL` / `fcTL` / `fdAT`, rebuilds every frame as a\n * standalone PNG (header + palette / transparency chunks + its image data,\n * with fresh CRCs) and lets the browser's own PNG decoder decode it, then\n * composites the frames (`dispose_op` none / background / previous,\n * `blend_op` source / over) into full-size RGBA. A plain (non-animated) PNG\n * loads as a one-frame animation.\n *\n * `parseApng()` and `apngFramePngs()` are pure (no DOM); `decodeApng()` needs\n * an image decoder — the browser's by default (also in workers), or your own\n * via `{ decode }`.\n */\nimport { RUNTIME_VERSION, type RuntimeModule } from './registry';\nimport { composeFrames, fixDelay, bytesOf, browserDecode, crc32, animatedImagePlayer, u8, type AnimatedImage, type FramePart, type FrameDecoder } from './anim-image';\n\nexport type { AnimatedImage, AnimFrame, Rgba, AnimPlayer, AnimPlayerOptions, FrameDecoder } from './anim-image';\nexport { animatedImagePlayer } from './anim-image';\n\nconst SIG = [137, 80, 78, 71, 13, 10, 26, 10];\n\nexport interface ApngChunk {\n type: string;\n data: Uint8Array;\n}\n\nexport interface ApngFrameInfo {\n width: number;\n height: number;\n x: number;\n y: number;\n /** ms */\n delay: number;\n dispose: FramePart['dispose'];\n blend: FramePart['blend'];\n /** Image data (zlib stream pieces) of this frame. */\n data: Uint8Array[];\n}\n\nexport interface ApngInfo {\n width: number;\n height: number;\n /** acTL num_plays (0 = forever); 1 for a plain PNG. */\n plays: number;\n animated: boolean;\n /** The default image (IDAT) is not part of the animation. */\n hiddenDefault: boolean;\n frames: ApngFrameInfo[];\n /** Chunks copied into every frame PNG (PLTE, tRNS, gAMA, cHRM, sRGB, iCCP, sBIT). */\n shared: ApngChunk[];\n ihdr: Uint8Array;\n}\n\nconst u32 = (b: Uint8Array, i: number) => ((b[i] << 24) | (b[i + 1] << 16) | (b[i + 2] << 8) | b[i + 3]) >>> 0;\nconst u16 = (b: Uint8Array, i: number) => (b[i] << 8) | b[i + 1];\n\n/** Read the chunk list of a PNG / APNG (pure). */\nexport function pngChunks(b: Uint8Array): ApngChunk[] {\n for (let i = 0; i < 8; i++) if (b[i] !== SIG[i]) throw new Error('[motionary] format-apng: not a PNG file');\n const out: ApngChunk[] = [];\n let p = 8;\n while (p + 8 <= b.length) {\n const len = u32(b, p), type = String.fromCharCode(b[p + 4], b[p + 5], b[p + 6], b[p + 7]);\n out.push({ type, data: b.subarray(p + 8, p + 8 + len) });\n p += 12 + len;\n if (type === 'IEND') break;\n }\n return out;\n}\n\n/** Parse the animation structure (pure; no pixels decoded). */\nexport function parseApng(input: Uint8Array | ArrayBuffer): ApngInfo {\n const b = u8(input);\n const chunks = pngChunks(b);\n const ihdr = chunks[0]?.type === 'IHDR' ? chunks[0].data : null;\n if (!ihdr) throw new Error('[motionary] format-apng: missing IHDR');\n const width = u32(ihdr, 0), height = u32(ihdr, 4);\n const shared = chunks.filter((c) => /^(PLTE|tRNS|gAMA|cHRM|sRGB|iCCP|sBIT)$/.test(c.type));\n const actl = chunks.find((c) => c.type === 'acTL');\n const frames: ApngFrameInfo[] = [];\n let cur: ApngFrameInfo | null = null, sawIdat = false, idatHasFrame = false;\n const idat: Uint8Array[] = [];\n for (const c of chunks) {\n if (c.type === 'fcTL') {\n const d = c.data;\n const dn = u16(d, 20), dd = u16(d, 22) || 100;\n cur = { width: u32(d, 4), height: u32(d, 8), x: u32(d, 12), y: u32(d, 16), delay: fixDelay((dn / dd) * 1000), dispose: (['none', 'background', 'previous'] as const)[d[24]] || 'none', blend: d[25] === 1 ? 'over' : 'source', data: [] };\n frames.push(cur);\n if (!sawIdat) idatHasFrame = true;\n } else if (c.type === 'IDAT') {\n sawIdat = true;\n idat.push(c.data);\n if (cur && idatHasFrame) cur.data.push(c.data);\n } else if (c.type === 'fdAT' && cur) cur.data.push(c.data.subarray(4)); // drop the sequence number\n }\n if (!actl || !frames.length) {\n // a plain PNG: one frame, the whole image\n return { width, height, plays: 1, animated: false, hiddenDefault: false, frames: [{ width, height, x: 0, y: 0, delay: 100, dispose: 'none', blend: 'source', data: idat }], shared, ihdr };\n }\n // the first frame's dispose \"previous\" acts like \"background\" (spec)\n if (frames[0].dispose === 'previous') frames[0].dispose = 'background';\n return { width, height, plays: u32(actl.data, 4), animated: true, hiddenDefault: !idatHasFrame, frames, shared, ihdr };\n}\n\nfunction chunk(type: string, data: Uint8Array): Uint8Array {\n const out = new Uint8Array(12 + data.length);\n const v = new DataView(out.buffer);\n v.setUint32(0, data.length);\n for (let i = 0; i < 4; i++) out[4 + i] = type.charCodeAt(i);\n out.set(data, 8);\n v.setUint32(8 + data.length, crc32(out, 4, 8 + data.length));\n return out;\n}\n\n/** Rebuild every animation frame as a standalone PNG file (pure). */\nexport function apngFramePngs(info: ApngInfo): Uint8Array[] {\n return info.frames.map((f) => {\n const ihdr = new Uint8Array(info.ihdr); // a copy (never a Node Buffer view)\n const v = new DataView(ihdr.buffer);\n v.setUint32(0, f.width);\n v.setUint32(4, f.height);\n const parts = [new Uint8Array(SIG), chunk('IHDR', ihdr), ...info.shared.map((c) => chunk(c.type, c.data)), ...f.data.map((d) => chunk('IDAT', d)), chunk('IEND', new Uint8Array(0))];\n const out = new Uint8Array(parts.reduce((n, p) => n + p.length, 0));\n let o = 0;\n for (const p of parts) {\n out.set(p, o);\n o += p.length;\n }\n return out;\n });\n}\n\n/** Decode an APNG (or PNG) into composited RGBA frames. */\nexport async function decodeApng(input: Uint8Array | ArrayBuffer, o: { decode?: FrameDecoder } = {}): Promise<AnimatedImage & { info: ApngInfo }> {\n const info = parseApng(input);\n const decode = o.decode || browserDecode;\n const pngs = apngFramePngs(info);\n const images = await Promise.all(pngs.map((p) => decode(p, 'image/png')));\n const parts: FramePart[] = info.frames.map((f, i) => ({ x: f.x, y: f.y, image: images[i], delay: f.delay, blend: f.blend, dispose: f.dispose }));\n return { format: 'apng', width: info.width, height: info.height, plays: info.plays, frames: composeFrames(info.width, info.height, parts), info };\n}\n\n/** Fetch (URL) or read (ArrayBuffer / Blob / bytes) and decode an APNG. */\nexport async function loadApng(src: string | ArrayBuffer | ArrayBufferView | Blob, o: { decode?: FrameDecoder } = {}): Promise<AnimatedImage & { info: ApngInfo }> {\n return decodeApng(await bytesOf(src), o);\n}\n\nexport interface FormatApngApi {\n parseApng: typeof parseApng;\n apngFramePngs: typeof apngFramePngs;\n decodeApng: typeof decodeApng;\n loadApng: typeof loadApng;\n animatedImagePlayer: typeof animatedImagePlayer;\n}\n\n/** The module object for `use(formatApng)`. */\nexport const formatApng: RuntimeModule<FormatApngApi> = { id: 'format-apng', version: RUNTIME_VERSION, requires: ['core'], api: { parseApng, apngFramePngs, decodeApng, loadApng, animatedImagePlayer } };\n"],"names":[],"mappings":";;;;;;AAAA;;;;;;;;;;;;AAYG;AAOH,MAAM,GAAG,GAAG,CAAC,GAAG,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC;AAkC7C,MAAM,GAAG,GAAG,CAAC,CAAa,EAAE,CAAS,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC;AAC9G,MAAM,GAAG,GAAG,CAAC,CAAa,EAAE,CAAS,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;AAEhE;AACM,SAAU,SAAS,CAAC,CAAa,EAAA;IACrC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE;QAAE,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;AAAE,YAAA,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC;IAC3G,MAAM,GAAG,GAAgB,EAAE;IAC3B,IAAI,CAAC,GAAG,CAAC;IACT,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE;AACxB,QAAA,MAAM,GAAG,GAAG,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,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E;AACnJ;AAEA;AACO,eAAe,QAAQ,CAAC,GAAkD,EAAE,IAA+B,EAAE,EAAA;IAClH,OAAO,UAAU,CAAC,MAAM,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;AAC1C;AAUA;AACO,MAAM,UAAU,GAAiC,EAAE,EAAE,EAAE,aAAa,EAAE,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,EAAE,SAAS,EAAE,aAAa,EAAE,UAAU,EAAE,QAAQ,EAAE,mBAAmB,EAAE;;"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var registry = require('../chunks/registry-
|
|
4
|
-
var keyframes = require('../chunks/keyframes-
|
|
5
|
-
require('../chunks/tween-
|
|
6
|
-
require('../chunks/ticker-
|
|
3
|
+
var registry = require('../chunks/registry-tzwKkldE.cjs');
|
|
4
|
+
var keyframes = require('../chunks/keyframes-tC3I7anQ.cjs');
|
|
5
|
+
require('../chunks/tween-CwLLC3Ko.cjs');
|
|
6
|
+
require('../chunks/ticker-Un0bvTWR.cjs');
|
|
7
|
+
require('../chunks/ease-HwYZnZat.cjs');
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* `motionary/runtime/format-css` (10.1) — import CSS `@keyframes` and Web
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format-css.cjs","sources":["../../src/runtime/format-css.ts"],"sourcesContent":["/**\n * `motionary/runtime/format-css` (10.1) — import CSS `@keyframes` and Web\n * Animations API keyframes into the runtime timeline.\n *\n * - `parseKeyframes(cssText)` — every `@keyframes` block of a stylesheet\n * (incl. `-webkit-`), percentages / `from` / `to` / lists (`0%, 100%`),\n * per-frame `animation-timing-function`, `!important` ignored as in CSS.\n * - `fromCssRule(rule)` — a live `CSSKeyframesRule`.\n * - `fromWaapi(keyframes)` — array form (`[{ opacity: 0 }, { opacity: 1, offset: .8 }]`)\n * and property-indexed form (`{ opacity: [0, 1], easing: 'ease-out' }`), with\n * offsets distributed like the WAAPI.\n * - `playKeyframes(target, frames, { duration, … })` — a runtime `Timeline`.\n *\n * Unsupported (documented in docs/runtime/format-css.md): `composite: add / accumulate`,\n * `@property` typed interpolation, 3D / matrix transforms (switch discretely).\n */\nimport { RUNTIME_VERSION, type RuntimeModule } from './registry';\nimport { camelProp, distributeOffsets, framesToTimeline, type Frame, type KeyframesPlayOptions } from './keyframes';\nimport type { Target } from './tween';\n\nexport type { Frame, KeyframesPlayOptions } from './keyframes';\n\nexport interface KeyframesDef {\n name: string;\n frames: Frame[];\n}\n\n/** Strip comments. */\nconst clean = (css: string) => css.replace(/\\/\\*[\\s\\S]*?\\*\\//g, '');\n\nfunction block(css: string, open: number): [string, number] {\n let depth = 0;\n for (let i = open; i < css.length; i++) {\n if (css[i] === '{') depth++;\n else if (css[i] === '}' && --depth === 0) return [css.slice(open + 1, i), i + 1];\n }\n throw new Error('[motionary] format-css: unbalanced braces in @keyframes');\n}\n\nfunction decls(body: string): { props: Record<string, string>; easing?: string } {\n const props: Record<string, string> = {};\n let easing: string | undefined;\n // split on ';' outside parentheses\n let depth = 0, cur = '';\n const parts: string[] = [];\n for (const ch of body) {\n if (ch === '(') depth++;\n if (ch === ')') depth--;\n if (ch === ';' && !depth) { parts.push(cur); cur = ''; } else cur += ch;\n }\n parts.push(cur);\n for (const p of parts) {\n const i = p.indexOf(':');\n if (i < 0) continue;\n const k = p.slice(0, i).trim();\n const v = p.slice(i + 1).replace(/!important/i, '').trim();\n if (!k || !v) continue;\n if (k === 'animation-timing-function' || k === '-webkit-animation-timing-function') easing = v;\n else props[camelProp(k)] = v;\n }\n return { props, easing };\n}\n\nconst offsetOf = (sel: string): number => {\n const s = sel.trim().toLowerCase();\n if (s === 'from') return 0;\n if (s === 'to') return 1;\n const n = parseFloat(s);\n if (!s.endsWith('%') || !Number.isFinite(n)) throw new Error(`[motionary] format-css: bad keyframe selector \"${sel}\"`);\n return n / 100;\n};\n\n/** Parse the body of one `@keyframes` block. */\nexport function parseKeyframesBody(body: string): Frame[] {\n const frames: Frame[] = [];\n let i = 0;\n while (i < body.length) {\n const open = body.indexOf('{', i);\n if (open < 0) break;\n const sel = body.slice(i, open);\n const [inner, end] = block(body, open);\n const d = decls(inner);\n for (const part of sel.split(',')) if (part.trim()) frames.push({ offset: offsetOf(part), props: { ...d.props }, ...(d.easing ? { easing: d.easing } : {}) });\n i = end;\n }\n // merge duplicate offsets (later declarations win, as in CSS)\n const by = new Map<number, Frame>();\n for (const f of frames.sort((a, b) => a.offset - b.offset)) {\n const prev = by.get(f.offset);\n by.set(f.offset, prev ? { offset: f.offset, props: { ...prev.props, ...f.props }, easing: f.easing ?? prev.easing } : f);\n }\n return Array.from(by.values());\n}\n\n/** Every `@keyframes` block in a stylesheet's text. */\nexport function parseKeyframes(cssText: string): KeyframesDef[] {\n const css = clean(cssText);\n const out: KeyframesDef[] = [];\n const re = /@(?:-webkit-|-moz-)?keyframes\\s+([\"']?)([\\w-]+)\\1\\s*\\{/g;\n let m: RegExpExecArray | null;\n while ((m = re.exec(css))) {\n const [body, end] = block(css, m.index + m[0].length - 1);\n out.push({ name: m[2], frames: parseKeyframesBody(body) });\n re.lastIndex = end;\n }\n return out;\n}\n\n/** A live `CSSKeyframesRule` (e.g. from `document.styleSheets`). */\nexport function fromCssRule(rule: { name: string; cssText: string }): KeyframesDef {\n const css = rule.cssText;\n const open = css.indexOf('{');\n return { name: rule.name, frames: parseKeyframesBody(block(css, open)[0]) };\n}\n\ntype WaapiFrame = Record<string, unknown> & { offset?: number | null; easing?: string };\n\n/** WAAPI keyframes (array or property-indexed form) → frames. */\nexport function fromWaapi(kf: WaapiFrame[] | Record<string, unknown>): Frame[] {\n let list: WaapiFrame[];\n if (Array.isArray(kf)) list = kf;\n else {\n const n = Math.max(...Object.entries(kf).filter(([k]) => k !== 'easing' && k !== 'offset' && k !== 'composite').map(([, v]) => (Array.isArray(v) ? v.length : 1)));\n list = Array.from({ length: n }, (_, i) => {\n const f: WaapiFrame = {};\n for (const [k, v] of Object.entries(kf)) {\n if (k === 'composite') continue;\n const arr = Array.isArray(v) ? v : [v];\n if (k === 'offset') { if (arr[i] !== undefined) f.offset = arr[i] as number; continue; }\n if (k === 'easing') { const e = arr[Math.min(i, arr.length - 1)]; if (e !== undefined) f.easing = e as string; continue; }\n if (arr.length === 1 && n > 1) { if (i === n - 1) f[k] = arr[0]; continue; }\n if (arr[i] !== undefined) f[k] = arr[i];\n }\n return f;\n });\n }\n return distributeOffsets(list).map((f) => {\n const props: Record<string, string | number> = {};\n for (const [k, v] of Object.entries(f)) if (k !== 'offset' && k !== 'easing' && k !== 'composite' && (typeof v === 'string' || typeof v === 'number')) props[camelProp(k === 'cssFloat' ? 'float' : k)] = v;\n return { offset: f.offset, props, ...(f.easing ? { easing: f.easing } : {}) };\n });\n}\n\n/** Frames in WAAPI array form (for `element.animate()`). */\nexport function toWaapi(frames: Frame[]): Keyframe[] {\n return frames.map((f) => ({ ...f.props, offset: f.offset, ...(f.easing ? { easing: f.easing } : {}) })) as Keyframe[];\n}\n\n/** Play frames (or a `KeyframesDef`) on a target. Returns the runtime timeline (playing unless `paused: true`). */\nexport function playKeyframes(target: Target, frames: Frame[] | KeyframesDef, o: KeyframesPlayOptions = {}) {\n return framesToTimeline(target, Array.isArray(frames) ? frames : frames.frames, { ...o, paused: o.paused ?? false });\n}\n\nexport interface FormatCssApi {\n parseKeyframes: typeof parseKeyframes;\n fromCssRule: typeof fromCssRule;\n fromWaapi: typeof fromWaapi;\n toWaapi: typeof toWaapi;\n playKeyframes: typeof playKeyframes;\n}\n\n/** The module object for `use(formatCss)`. */\nexport const formatCss: RuntimeModule<FormatCssApi> = { id: 'format-css', version: RUNTIME_VERSION, requires: ['core'], api: { parseKeyframes, fromCssRule, fromWaapi, toWaapi, playKeyframes } };\n"],"names":["camelProp","distributeOffsets","framesToTimeline","RUNTIME_VERSION"],"mappings":";;;;;;;AAAA;;;;;;;;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Ac,EAAE,MAA8B,EAAE,IAA0B,EAAE,EAAA;AACxG,IAAA,OAAOE,0BAAgB,CAAC,MAAM,EAAE,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,IAAI,KAAK,EAAE,CAAC;AACtH;AAUA;AACO,MAAM,SAAS,GAAgC,EAAE,EAAE,EAAE,YAAY,EAAE,OAAO,EAAEC,wBAAe,EAAE,QAAQ,EAAE,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,EAAE,cAAc,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,aAAa,EAAE;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"format-css.cjs","sources":["../../src/runtime/format-css.ts"],"sourcesContent":["/**\n * `motionary/runtime/format-css` (10.1) — import CSS `@keyframes` and Web\n * Animations API keyframes into the runtime timeline.\n *\n * - `parseKeyframes(cssText)` — every `@keyframes` block of a stylesheet\n * (incl. `-webkit-`), percentages / `from` / `to` / lists (`0%, 100%`),\n * per-frame `animation-timing-function`, `!important` ignored as in CSS.\n * - `fromCssRule(rule)` — a live `CSSKeyframesRule`.\n * - `fromWaapi(keyframes)` — array form (`[{ opacity: 0 }, { opacity: 1, offset: .8 }]`)\n * and property-indexed form (`{ opacity: [0, 1], easing: 'ease-out' }`), with\n * offsets distributed like the WAAPI.\n * - `playKeyframes(target, frames, { duration, … })` — a runtime `Timeline`.\n *\n * Unsupported (documented in docs/runtime/format-css.md): `composite: add / accumulate`,\n * `@property` typed interpolation, 3D / matrix transforms (switch discretely).\n */\nimport { RUNTIME_VERSION, type RuntimeModule } from './registry';\nimport { camelProp, distributeOffsets, framesToTimeline, type Frame, type KeyframesPlayOptions } from './keyframes';\nimport type { Target } from './tween';\n\nexport type { Frame, KeyframesPlayOptions } from './keyframes';\n\nexport interface KeyframesDef {\n name: string;\n frames: Frame[];\n}\n\n/** Strip comments. */\nconst clean = (css: string) => css.replace(/\\/\\*[\\s\\S]*?\\*\\//g, '');\n\nfunction block(css: string, open: number): [string, number] {\n let depth = 0;\n for (let i = open; i < css.length; i++) {\n if (css[i] === '{') depth++;\n else if (css[i] === '}' && --depth === 0) return [css.slice(open + 1, i), i + 1];\n }\n throw new Error('[motionary] format-css: unbalanced braces in @keyframes');\n}\n\nfunction decls(body: string): { props: Record<string, string>; easing?: string } {\n const props: Record<string, string> = {};\n let easing: string | undefined;\n // split on ';' outside parentheses\n let depth = 0, cur = '';\n const parts: string[] = [];\n for (const ch of body) {\n if (ch === '(') depth++;\n if (ch === ')') depth--;\n if (ch === ';' && !depth) { parts.push(cur); cur = ''; } else cur += ch;\n }\n parts.push(cur);\n for (const p of parts) {\n const i = p.indexOf(':');\n if (i < 0) continue;\n const k = p.slice(0, i).trim();\n const v = p.slice(i + 1).replace(/!important/i, '').trim();\n if (!k || !v) continue;\n if (k === 'animation-timing-function' || k === '-webkit-animation-timing-function') easing = v;\n else props[camelProp(k)] = v;\n }\n return { props, easing };\n}\n\nconst offsetOf = (sel: string): number => {\n const s = sel.trim().toLowerCase();\n if (s === 'from') return 0;\n if (s === 'to') return 1;\n const n = parseFloat(s);\n if (!s.endsWith('%') || !Number.isFinite(n)) throw new Error(`[motionary] format-css: bad keyframe selector \"${sel}\"`);\n return n / 100;\n};\n\n/** Parse the body of one `@keyframes` block. */\nexport function parseKeyframesBody(body: string): Frame[] {\n const frames: Frame[] = [];\n let i = 0;\n while (i < body.length) {\n const open = body.indexOf('{', i);\n if (open < 0) break;\n const sel = body.slice(i, open);\n const [inner, end] = block(body, open);\n const d = decls(inner);\n for (const part of sel.split(',')) if (part.trim()) frames.push({ offset: offsetOf(part), props: { ...d.props }, ...(d.easing ? { easing: d.easing } : {}) });\n i = end;\n }\n // merge duplicate offsets (later declarations win, as in CSS)\n const by = new Map<number, Frame>();\n for (const f of frames.sort((a, b) => a.offset - b.offset)) {\n const prev = by.get(f.offset);\n by.set(f.offset, prev ? { offset: f.offset, props: { ...prev.props, ...f.props }, easing: f.easing ?? prev.easing } : f);\n }\n return Array.from(by.values());\n}\n\n/** Every `@keyframes` block in a stylesheet's text. */\nexport function parseKeyframes(cssText: string): KeyframesDef[] {\n const css = clean(cssText);\n const out: KeyframesDef[] = [];\n const re = /@(?:-webkit-|-moz-)?keyframes\\s+([\"']?)([\\w-]+)\\1\\s*\\{/g;\n let m: RegExpExecArray | null;\n while ((m = re.exec(css))) {\n const [body, end] = block(css, m.index + m[0].length - 1);\n out.push({ name: m[2], frames: parseKeyframesBody(body) });\n re.lastIndex = end;\n }\n return out;\n}\n\n/** A live `CSSKeyframesRule` (e.g. from `document.styleSheets`). */\nexport function fromCssRule(rule: { name: string; cssText: string }): KeyframesDef {\n const css = rule.cssText;\n const open = css.indexOf('{');\n return { name: rule.name, frames: parseKeyframesBody(block(css, open)[0]) };\n}\n\ntype WaapiFrame = Record<string, unknown> & { offset?: number | null; easing?: string };\n\n/** WAAPI keyframes (array or property-indexed form) → frames. */\nexport function fromWaapi(kf: WaapiFrame[] | Record<string, unknown>): Frame[] {\n let list: WaapiFrame[];\n if (Array.isArray(kf)) list = kf;\n else {\n const n = Math.max(...Object.entries(kf).filter(([k]) => k !== 'easing' && k !== 'offset' && k !== 'composite').map(([, v]) => (Array.isArray(v) ? v.length : 1)));\n list = Array.from({ length: n }, (_, i) => {\n const f: WaapiFrame = {};\n for (const [k, v] of Object.entries(kf)) {\n if (k === 'composite') continue;\n const arr = Array.isArray(v) ? v : [v];\n if (k === 'offset') { if (arr[i] !== undefined) f.offset = arr[i] as number; continue; }\n if (k === 'easing') { const e = arr[Math.min(i, arr.length - 1)]; if (e !== undefined) f.easing = e as string; continue; }\n if (arr.length === 1 && n > 1) { if (i === n - 1) f[k] = arr[0]; continue; }\n if (arr[i] !== undefined) f[k] = arr[i];\n }\n return f;\n });\n }\n return distributeOffsets(list).map((f) => {\n const props: Record<string, string | number> = {};\n for (const [k, v] of Object.entries(f)) if (k !== 'offset' && k !== 'easing' && k !== 'composite' && (typeof v === 'string' || typeof v === 'number')) props[camelProp(k === 'cssFloat' ? 'float' : k)] = v;\n return { offset: f.offset, props, ...(f.easing ? { easing: f.easing } : {}) };\n });\n}\n\n/** Frames in WAAPI array form (for `element.animate()`). */\nexport function toWaapi(frames: Frame[]): Keyframe[] {\n return frames.map((f) => ({ ...f.props, offset: f.offset, ...(f.easing ? { easing: f.easing } : {}) })) as Keyframe[];\n}\n\n/** Play frames (or a `KeyframesDef`) on a target. Returns the runtime timeline (playing unless `paused: true`). */\nexport function playKeyframes(target: Target, frames: Frame[] | KeyframesDef, o: KeyframesPlayOptions = {}) {\n return framesToTimeline(target, Array.isArray(frames) ? frames : frames.frames, { ...o, paused: o.paused ?? false });\n}\n\nexport interface FormatCssApi {\n parseKeyframes: typeof parseKeyframes;\n fromCssRule: typeof fromCssRule;\n fromWaapi: typeof fromWaapi;\n toWaapi: typeof toWaapi;\n playKeyframes: typeof playKeyframes;\n}\n\n/** The module object for `use(formatCss)`. */\nexport const formatCss: RuntimeModule<FormatCssApi> = { id: 'format-css', version: RUNTIME_VERSION, requires: ['core'], api: { parseKeyframes, fromCssRule, fromWaapi, toWaapi, playKeyframes } };\n"],"names":["camelProp","distributeOffsets","framesToTimeline","RUNTIME_VERSION"],"mappings":";;;;;;;;AAAA;;;;;;;;;;;;;;;AAeG;AAYH;AACA,MAAM,KAAK,GAAG,CAAC,GAAW,KAAK,GAAG,CAAC,OAAO,CAAC,mBAAmB,EAAE,EAAE,CAAC;AAEnE,SAAS,KAAK,CAAC,GAAW,EAAE,IAAY,EAAA;IACtC,IAAI,KAAK,GAAG,CAAC;AACb,IAAA,KAAK,IAAI,CAAC,GAAG,IAAI,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;AACtC,QAAA,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG;AAAE,YAAA,KAAK,EAAE;aACtB,IAAI,GAAG,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AE,cAAc,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,aAAa,EAAE;;;;;;;;"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { R as RUNTIME_VERSION } from '../chunks/registry-
|
|
2
|
-
import { f as framesToTimeline, d as distributeOffsets, c as camelProp } from '../chunks/keyframes-
|
|
3
|
-
import '../chunks/tween-
|
|
4
|
-
import '../chunks/ticker-
|
|
1
|
+
import { R as RUNTIME_VERSION } from '../chunks/registry-CT-TT_bx.js';
|
|
2
|
+
import { f as framesToTimeline, d as distributeOffsets, c as camelProp } from '../chunks/keyframes-B5PWe5bU.js';
|
|
3
|
+
import '../chunks/tween-BcejKpsx.js';
|
|
4
|
+
import '../chunks/ticker-C8lSGml9.js';
|
|
5
|
+
import '../chunks/ease-XN8_0sXu.js';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* `motionary/runtime/format-css` (10.1) — import CSS `@keyframes` and Web
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format-css.js","sources":["../../src/runtime/format-css.ts"],"sourcesContent":["/**\n * `motionary/runtime/format-css` (10.1) — import CSS `@keyframes` and Web\n * Animations API keyframes into the runtime timeline.\n *\n * - `parseKeyframes(cssText)` — every `@keyframes` block of a stylesheet\n * (incl. `-webkit-`), percentages / `from` / `to` / lists (`0%, 100%`),\n * per-frame `animation-timing-function`, `!important` ignored as in CSS.\n * - `fromCssRule(rule)` — a live `CSSKeyframesRule`.\n * - `fromWaapi(keyframes)` — array form (`[{ opacity: 0 }, { opacity: 1, offset: .8 }]`)\n * and property-indexed form (`{ opacity: [0, 1], easing: 'ease-out' }`), with\n * offsets distributed like the WAAPI.\n * - `playKeyframes(target, frames, { duration, … })` — a runtime `Timeline`.\n *\n * Unsupported (documented in docs/runtime/format-css.md): `composite: add / accumulate`,\n * `@property` typed interpolation, 3D / matrix transforms (switch discretely).\n */\nimport { RUNTIME_VERSION, type RuntimeModule } from './registry';\nimport { camelProp, distributeOffsets, framesToTimeline, type Frame, type KeyframesPlayOptions } from './keyframes';\nimport type { Target } from './tween';\n\nexport type { Frame, KeyframesPlayOptions } from './keyframes';\n\nexport interface KeyframesDef {\n name: string;\n frames: Frame[];\n}\n\n/** Strip comments. */\nconst clean = (css: string) => css.replace(/\\/\\*[\\s\\S]*?\\*\\//g, '');\n\nfunction block(css: string, open: number): [string, number] {\n let depth = 0;\n for (let i = open; i < css.length; i++) {\n if (css[i] === '{') depth++;\n else if (css[i] === '}' && --depth === 0) return [css.slice(open + 1, i), i + 1];\n }\n throw new Error('[motionary] format-css: unbalanced braces in @keyframes');\n}\n\nfunction decls(body: string): { props: Record<string, string>; easing?: string } {\n const props: Record<string, string> = {};\n let easing: string | undefined;\n // split on ';' outside parentheses\n let depth = 0, cur = '';\n const parts: string[] = [];\n for (const ch of body) {\n if (ch === '(') depth++;\n if (ch === ')') depth--;\n if (ch === ';' && !depth) { parts.push(cur); cur = ''; } else cur += ch;\n }\n parts.push(cur);\n for (const p of parts) {\n const i = p.indexOf(':');\n if (i < 0) continue;\n const k = p.slice(0, i).trim();\n const v = p.slice(i + 1).replace(/!important/i, '').trim();\n if (!k || !v) continue;\n if (k === 'animation-timing-function' || k === '-webkit-animation-timing-function') easing = v;\n else props[camelProp(k)] = v;\n }\n return { props, easing };\n}\n\nconst offsetOf = (sel: string): number => {\n const s = sel.trim().toLowerCase();\n if (s === 'from') return 0;\n if (s === 'to') return 1;\n const n = parseFloat(s);\n if (!s.endsWith('%') || !Number.isFinite(n)) throw new Error(`[motionary] format-css: bad keyframe selector \"${sel}\"`);\n return n / 100;\n};\n\n/** Parse the body of one `@keyframes` block. */\nexport function parseKeyframesBody(body: string): Frame[] {\n const frames: Frame[] = [];\n let i = 0;\n while (i < body.length) {\n const open = body.indexOf('{', i);\n if (open < 0) break;\n const sel = body.slice(i, open);\n const [inner, end] = block(body, open);\n const d = decls(inner);\n for (const part of sel.split(',')) if (part.trim()) frames.push({ offset: offsetOf(part), props: { ...d.props }, ...(d.easing ? { easing: d.easing } : {}) });\n i = end;\n }\n // merge duplicate offsets (later declarations win, as in CSS)\n const by = new Map<number, Frame>();\n for (const f of frames.sort((a, b) => a.offset - b.offset)) {\n const prev = by.get(f.offset);\n by.set(f.offset, prev ? { offset: f.offset, props: { ...prev.props, ...f.props }, easing: f.easing ?? prev.easing } : f);\n }\n return Array.from(by.values());\n}\n\n/** Every `@keyframes` block in a stylesheet's text. */\nexport function parseKeyframes(cssText: string): KeyframesDef[] {\n const css = clean(cssText);\n const out: KeyframesDef[] = [];\n const re = /@(?:-webkit-|-moz-)?keyframes\\s+([\"']?)([\\w-]+)\\1\\s*\\{/g;\n let m: RegExpExecArray | null;\n while ((m = re.exec(css))) {\n const [body, end] = block(css, m.index + m[0].length - 1);\n out.push({ name: m[2], frames: parseKeyframesBody(body) });\n re.lastIndex = end;\n }\n return out;\n}\n\n/** A live `CSSKeyframesRule` (e.g. from `document.styleSheets`). */\nexport function fromCssRule(rule: { name: string; cssText: string }): KeyframesDef {\n const css = rule.cssText;\n const open = css.indexOf('{');\n return { name: rule.name, frames: parseKeyframesBody(block(css, open)[0]) };\n}\n\ntype WaapiFrame = Record<string, unknown> & { offset?: number | null; easing?: string };\n\n/** WAAPI keyframes (array or property-indexed form) → frames. */\nexport function fromWaapi(kf: WaapiFrame[] | Record<string, unknown>): Frame[] {\n let list: WaapiFrame[];\n if (Array.isArray(kf)) list = kf;\n else {\n const n = Math.max(...Object.entries(kf).filter(([k]) => k !== 'easing' && k !== 'offset' && k !== 'composite').map(([, v]) => (Array.isArray(v) ? v.length : 1)));\n list = Array.from({ length: n }, (_, i) => {\n const f: WaapiFrame = {};\n for (const [k, v] of Object.entries(kf)) {\n if (k === 'composite') continue;\n const arr = Array.isArray(v) ? v : [v];\n if (k === 'offset') { if (arr[i] !== undefined) f.offset = arr[i] as number; continue; }\n if (k === 'easing') { const e = arr[Math.min(i, arr.length - 1)]; if (e !== undefined) f.easing = e as string; continue; }\n if (arr.length === 1 && n > 1) { if (i === n - 1) f[k] = arr[0]; continue; }\n if (arr[i] !== undefined) f[k] = arr[i];\n }\n return f;\n });\n }\n return distributeOffsets(list).map((f) => {\n const props: Record<string, string | number> = {};\n for (const [k, v] of Object.entries(f)) if (k !== 'offset' && k !== 'easing' && k !== 'composite' && (typeof v === 'string' || typeof v === 'number')) props[camelProp(k === 'cssFloat' ? 'float' : k)] = v;\n return { offset: f.offset, props, ...(f.easing ? { easing: f.easing } : {}) };\n });\n}\n\n/** Frames in WAAPI array form (for `element.animate()`). */\nexport function toWaapi(frames: Frame[]): Keyframe[] {\n return frames.map((f) => ({ ...f.props, offset: f.offset, ...(f.easing ? { easing: f.easing } : {}) })) as Keyframe[];\n}\n\n/** Play frames (or a `KeyframesDef`) on a target. Returns the runtime timeline (playing unless `paused: true`). */\nexport function playKeyframes(target: Target, frames: Frame[] | KeyframesDef, o: KeyframesPlayOptions = {}) {\n return framesToTimeline(target, Array.isArray(frames) ? frames : frames.frames, { ...o, paused: o.paused ?? false });\n}\n\nexport interface FormatCssApi {\n parseKeyframes: typeof parseKeyframes;\n fromCssRule: typeof fromCssRule;\n fromWaapi: typeof fromWaapi;\n toWaapi: typeof toWaapi;\n playKeyframes: typeof playKeyframes;\n}\n\n/** The module object for `use(formatCss)`. */\nexport const formatCss: RuntimeModule<FormatCssApi> = { id: 'format-css', version: RUNTIME_VERSION, requires: ['core'], api: { parseKeyframes, fromCssRule, fromWaapi, toWaapi, playKeyframes } };\n"],"names":[],"mappings":";;;;;AAAA;;;;;;;;;;;;;;;AAeG;AAYH;AACA,MAAM,KAAK,GAAG,CAAC,GAAW,KAAK,GAAG,CAAC,OAAO,CAAC,mBAAmB,EAAE,EAAE,CAAC;AAEnE,SAAS,KAAK,CAAC,GAAW,EAAE,IAAY,EAAA;IACtC,IAAI,KAAK,GAAG,CAAC;AACb,IAAA,KAAK,IAAI,CAAC,GAAG,IAAI,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EA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AAE,YAAY,EAAE,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,EAAE,cAAc,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,aAAa,EAAE;;;;"}
|
|
1
|
+
{"version":3,"file":"format-css.js","sources":["../../src/runtime/format-css.ts"],"sourcesContent":["/**\n * `motionary/runtime/format-css` (10.1) — import CSS `@keyframes` and Web\n * Animations API keyframes into the runtime timeline.\n *\n * - `parseKeyframes(cssText)` — every `@keyframes` block of a stylesheet\n * (incl. `-webkit-`), percentages / `from` / `to` / lists (`0%, 100%`),\n * per-frame `animation-timing-function`, `!important` ignored as in CSS.\n * - `fromCssRule(rule)` — a live `CSSKeyframesRule`.\n * - `fromWaapi(keyframes)` — array form (`[{ opacity: 0 }, { opacity: 1, offset: .8 }]`)\n * and property-indexed form (`{ opacity: [0, 1], easing: 'ease-out' }`), with\n * offsets distributed like the WAAPI.\n * - `playKeyframes(target, frames, { duration, … })` — a runtime `Timeline`.\n *\n * Unsupported (documented in docs/runtime/format-css.md): `composite: add / accumulate`,\n * `@property` typed interpolation, 3D / matrix transforms (switch discretely).\n */\nimport { RUNTIME_VERSION, type RuntimeModule } from './registry';\nimport { camelProp, distributeOffsets, framesToTimeline, type Frame, type KeyframesPlayOptions } from './keyframes';\nimport type { Target } from './tween';\n\nexport type { Frame, KeyframesPlayOptions } from './keyframes';\n\nexport interface KeyframesDef {\n name: string;\n frames: Frame[];\n}\n\n/** Strip comments. */\nconst clean = (css: string) => css.replace(/\\/\\*[\\s\\S]*?\\*\\//g, '');\n\nfunction block(css: string, open: number): [string, number] {\n let depth = 0;\n for (let i = open; i < css.length; i++) {\n if (css[i] === '{') depth++;\n else if (css[i] === '}' && --depth === 0) return [css.slice(open + 1, i), i + 1];\n }\n throw new Error('[motionary] format-css: unbalanced braces in @keyframes');\n}\n\nfunction decls(body: string): { props: Record<string, string>; easing?: string } {\n const props: Record<string, string> = {};\n let easing: string | undefined;\n // split on ';' outside parentheses\n let depth = 0, cur = '';\n const parts: string[] = [];\n for (const ch of body) {\n if (ch === '(') depth++;\n if (ch === ')') depth--;\n if (ch === ';' && !depth) { parts.push(cur); cur = ''; } else cur += ch;\n }\n parts.push(cur);\n for (const p of parts) {\n const i = p.indexOf(':');\n if (i < 0) continue;\n const k = p.slice(0, i).trim();\n const v = p.slice(i + 1).replace(/!important/i, '').trim();\n if (!k || !v) continue;\n if (k === 'animation-timing-function' || k === '-webkit-animation-timing-function') easing = v;\n else props[camelProp(k)] = v;\n }\n return { props, easing };\n}\n\nconst offsetOf = (sel: string): number => {\n const s = sel.trim().toLowerCase();\n if (s === 'from') return 0;\n if (s === 'to') return 1;\n const n = parseFloat(s);\n if (!s.endsWith('%') || !Number.isFinite(n)) throw new Error(`[motionary] format-css: bad keyframe selector \"${sel}\"`);\n return n / 100;\n};\n\n/** Parse the body of one `@keyframes` block. */\nexport function parseKeyframesBody(body: string): Frame[] {\n const frames: Frame[] = [];\n let i = 0;\n while (i < body.length) {\n const open = body.indexOf('{', i);\n if (open < 0) break;\n const sel = body.slice(i, open);\n const [inner, end] = block(body, open);\n const d = decls(inner);\n for (const part of sel.split(',')) if (part.trim()) frames.push({ offset: offsetOf(part), props: { ...d.props }, ...(d.easing ? { easing: d.easing } : {}) });\n i = end;\n }\n // merge duplicate offsets (later declarations win, as in CSS)\n const by = new Map<number, Frame>();\n for (const f of frames.sort((a, b) => a.offset - b.offset)) {\n const prev = by.get(f.offset);\n by.set(f.offset, prev ? { offset: f.offset, props: { ...prev.props, ...f.props }, easing: f.easing ?? prev.easing } : f);\n }\n return Array.from(by.values());\n}\n\n/** Every `@keyframes` block in a stylesheet's text. */\nexport function parseKeyframes(cssText: string): KeyframesDef[] {\n const css = clean(cssText);\n const out: KeyframesDef[] = [];\n const re = /@(?:-webkit-|-moz-)?keyframes\\s+([\"']?)([\\w-]+)\\1\\s*\\{/g;\n let m: RegExpExecArray | null;\n while ((m = re.exec(css))) {\n const [body, end] = block(css, m.index + m[0].length - 1);\n out.push({ name: m[2], frames: parseKeyframesBody(body) });\n re.lastIndex = end;\n }\n return out;\n}\n\n/** A live `CSSKeyframesRule` (e.g. from `document.styleSheets`). */\nexport function fromCssRule(rule: { name: string; cssText: string }): KeyframesDef {\n const css = rule.cssText;\n const open = css.indexOf('{');\n return { name: rule.name, frames: parseKeyframesBody(block(css, open)[0]) };\n}\n\ntype WaapiFrame = Record<string, unknown> & { offset?: number | null; easing?: string };\n\n/** WAAPI keyframes (array or property-indexed form) → frames. */\nexport function fromWaapi(kf: WaapiFrame[] | Record<string, unknown>): Frame[] {\n let list: WaapiFrame[];\n if (Array.isArray(kf)) list = kf;\n else {\n const n = Math.max(...Object.entries(kf).filter(([k]) => k !== 'easing' && k !== 'offset' && k !== 'composite').map(([, v]) => (Array.isArray(v) ? v.length : 1)));\n list = Array.from({ length: n }, (_, i) => {\n const f: WaapiFrame = {};\n for (const [k, v] of Object.entries(kf)) {\n if (k === 'composite') continue;\n const arr = Array.isArray(v) ? v : [v];\n if (k === 'offset') { if (arr[i] !== undefined) f.offset = arr[i] as number; continue; }\n if (k === 'easing') { const e = arr[Math.min(i, arr.length - 1)]; if (e !== undefined) f.easing = e as string; continue; }\n if (arr.length === 1 && n > 1) { if (i === n - 1) f[k] = arr[0]; continue; }\n if (arr[i] !== undefined) f[k] = arr[i];\n }\n return f;\n });\n }\n return distributeOffsets(list).map((f) => {\n const props: Record<string, string | number> = {};\n for (const [k, v] of Object.entries(f)) if (k !== 'offset' && k !== 'easing' && k !== 'composite' && (typeof v === 'string' || typeof v === 'number')) props[camelProp(k === 'cssFloat' ? 'float' : k)] = v;\n return { offset: f.offset, props, ...(f.easing ? { easing: f.easing } : {}) };\n });\n}\n\n/** Frames in WAAPI array form (for `element.animate()`). */\nexport function toWaapi(frames: Frame[]): Keyframe[] {\n return frames.map((f) => ({ ...f.props, offset: f.offset, ...(f.easing ? { easing: f.easing } : {}) })) as Keyframe[];\n}\n\n/** Play frames (or a `KeyframesDef`) on a target. Returns the runtime timeline (playing unless `paused: true`). */\nexport function playKeyframes(target: Target, frames: Frame[] | KeyframesDef, o: KeyframesPlayOptions = {}) {\n return framesToTimeline(target, Array.isArray(frames) ? frames : frames.frames, { ...o, paused: o.paused ?? false });\n}\n\nexport interface FormatCssApi {\n parseKeyframes: typeof parseKeyframes;\n fromCssRule: typeof fromCssRule;\n fromWaapi: typeof fromWaapi;\n toWaapi: typeof toWaapi;\n playKeyframes: typeof playKeyframes;\n}\n\n/** The module object for `use(formatCss)`. */\nexport const formatCss: RuntimeModule<FormatCssApi> = { id: 'format-css', version: RUNTIME_VERSION, requires: ['core'], api: { parseKeyframes, fromCssRule, fromWaapi, toWaapi, playKeyframes } };\n"],"names":[],"mappings":";;;;;;AAAA;;;;;;;;;;;;;;;AAeG;AAYH;AACA,MAAM,KAAK,GAAG,CAAC,GAAW,KAAK,GAAG,CAAC,OAAO,CAAC,mBAAmB,EAAE,EAAE,CAAC;AAEnE,SAAS,KAAK,CAAC,GAAW,EAAE,IAAY,EAAA;IACtC,IAAI,KAAK,GAAG,CAAC;AACb,IAAA,KAAK,IAAI,CAAC,GAAG,IAAI,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;AACtC,QAAA,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG;AAAE,YAAA,KAAK,EAAE;aACtB,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,EAAE,KAAK,KAAK,CAAC;AAAE,YAAA,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;IAClF;AACA,IAAA,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC;AAC5E;AAEA,SAAS,KAAK,CAAC,IAAY,EAAA;IACzB,MAAM,KAAK,GAA2B,EAAE;AACxC,IAAA,IAAI,MAA0B;;AAE9B,IAAA,IAA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AE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,MAAM,GAAG,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE;AAC/E,IAAA,CAAC,CAAC;AACJ;AAEA;AACM,SAAU,OAAO,CAAC,MAAe,EAAA;IACrC,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,MAAM,GAAG,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,CAAe;AACvH;AAEA;AACM,SAAU,aAAa,CAAC,MAAc,EAAE,MAA8B,EAAE,IAA0B,EAAE,EAAA;AACxG,IAAA,OAAO,gBAAgB,CAAC,MAAM,EAAE,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,IAAI,KAAK,EAAE,CAAC;AACtH;AAUA;AACO,MAAM,SAAS,GAAgC,EAAE,EAAE,EAAE,YAAY,EAAE,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,EAAE,cAAc,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,aAAa,EAAE;;"}
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var registry = require('../chunks/registry-tzwKkldE.cjs');
|
|
4
|
+
var animImage = require('../chunks/anim-image-blQgPFFS.cjs');
|
|
5
|
+
require('../chunks/tween-CwLLC3Ko.cjs');
|
|
6
|
+
require('../chunks/ticker-Un0bvTWR.cjs');
|
|
7
|
+
require('../chunks/ease-HwYZnZat.cjs');
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* `motionary/runtime/format-gif` (10.4) — a complete GIF decoder written for
|
|
11
|
+
* Motionary (own LZW implementation, no dependencies, no DOM): GIF87a / GIF89a,
|
|
12
|
+
* global and local palettes, transparency, interlaced frames, disposal
|
|
13
|
+
* methods 0–3, per-frame delays and the NETSCAPE2.0 loop count. Frames are
|
|
14
|
+
* composited to full-size RGBA, so they can be drawn, scrubbed or reversed
|
|
15
|
+
* with `animatedImagePlayer()` (a runtime timeline).
|
|
16
|
+
*
|
|
17
|
+
* ```ts
|
|
18
|
+
* import { use } from 'motionary/runtime';
|
|
19
|
+
* import { formatGif, loadGif, animatedImagePlayer } from 'motionary/runtime/format-gif';
|
|
20
|
+
* use(formatGif);
|
|
21
|
+
* const gif = await loadGif('/loader.gif');
|
|
22
|
+
* const player = animatedImagePlayer(canvas, gif); // player.pause(); player.progress = 0.5
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
/** LZW-decode GIF image data into palette indices (exported for tests / tools). */
|
|
26
|
+
function lzwDecode(minCodeSize, data, pixelCount) {
|
|
27
|
+
const out = new Uint8Array(pixelCount);
|
|
28
|
+
const clear = 1 << minCodeSize, eoi = clear + 1;
|
|
29
|
+
const prefix = new Uint16Array(4096), suffix = new Uint8Array(4096), stack = new Uint8Array(4097);
|
|
30
|
+
let size = minCodeSize + 1, mask = (1 << size) - 1, next = eoi + 1;
|
|
31
|
+
let old = -1, first = 0, bits = 0, acc = 0, op = 0, pos = 0;
|
|
32
|
+
for (let i = 0; i < clear; i++)
|
|
33
|
+
suffix[i] = i;
|
|
34
|
+
while (op < pixelCount) {
|
|
35
|
+
while (bits < size) {
|
|
36
|
+
if (pos >= data.length)
|
|
37
|
+
return out; // truncated data: keep what we have
|
|
38
|
+
acc |= data[pos++] << bits;
|
|
39
|
+
bits += 8;
|
|
40
|
+
}
|
|
41
|
+
const code = acc & mask;
|
|
42
|
+
acc >>>= size;
|
|
43
|
+
bits -= size;
|
|
44
|
+
if (code === clear) {
|
|
45
|
+
size = minCodeSize + 1;
|
|
46
|
+
mask = (1 << size) - 1;
|
|
47
|
+
next = eoi + 1;
|
|
48
|
+
old = -1;
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
if (code === eoi)
|
|
52
|
+
break;
|
|
53
|
+
if (old === -1) {
|
|
54
|
+
out[op++] = suffix[code];
|
|
55
|
+
old = first = code;
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
let c = code, sp = 0;
|
|
59
|
+
if (code >= next) {
|
|
60
|
+
stack[sp++] = first;
|
|
61
|
+
c = old;
|
|
62
|
+
}
|
|
63
|
+
while (c >= clear) {
|
|
64
|
+
stack[sp++] = suffix[c];
|
|
65
|
+
c = prefix[c];
|
|
66
|
+
}
|
|
67
|
+
first = suffix[c];
|
|
68
|
+
stack[sp++] = first;
|
|
69
|
+
while (sp && op < pixelCount)
|
|
70
|
+
out[op++] = stack[--sp];
|
|
71
|
+
if (next < 4096) {
|
|
72
|
+
prefix[next] = old;
|
|
73
|
+
suffix[next] = first;
|
|
74
|
+
next++;
|
|
75
|
+
if (next > mask && size < 12) {
|
|
76
|
+
size++;
|
|
77
|
+
mask = (1 << size) - 1;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
old = code;
|
|
81
|
+
}
|
|
82
|
+
return out;
|
|
83
|
+
}
|
|
84
|
+
const DISPOSE = ['none', 'none', 'background', 'previous'];
|
|
85
|
+
/** Decode a GIF (bytes) into composited RGBA frames. Pure: no DOM, works in workers / Node. */
|
|
86
|
+
function decodeGif(input) {
|
|
87
|
+
const b = animImage.u8(input);
|
|
88
|
+
const sig = String.fromCharCode(...b.subarray(0, 6));
|
|
89
|
+
if (sig !== 'GIF87a' && sig !== 'GIF89a')
|
|
90
|
+
throw new Error('[motionary] format-gif: not a GIF file');
|
|
91
|
+
const width = b[6] | (b[7] << 8), height = b[8] | (b[9] << 8), flags = b[10];
|
|
92
|
+
let p = 13, gct = null;
|
|
93
|
+
if (flags & 0x80) {
|
|
94
|
+
const n = 3 << ((flags & 7) + 1);
|
|
95
|
+
gct = b.subarray(p, p + n);
|
|
96
|
+
p += n;
|
|
97
|
+
}
|
|
98
|
+
const parts = [];
|
|
99
|
+
let loopCount = null, delay = 0, transparent = -1, disposal = 0;
|
|
100
|
+
const blocks = () => {
|
|
101
|
+
const chunks = [];
|
|
102
|
+
let len = 0;
|
|
103
|
+
while (p < b.length) {
|
|
104
|
+
const n = b[p++];
|
|
105
|
+
if (!n)
|
|
106
|
+
break;
|
|
107
|
+
chunks.push(b.subarray(p, p + n));
|
|
108
|
+
len += n;
|
|
109
|
+
p += n;
|
|
110
|
+
}
|
|
111
|
+
const outB = new Uint8Array(len);
|
|
112
|
+
let o = 0;
|
|
113
|
+
for (const c of chunks) {
|
|
114
|
+
outB.set(c, o);
|
|
115
|
+
o += c.length;
|
|
116
|
+
}
|
|
117
|
+
return outB;
|
|
118
|
+
};
|
|
119
|
+
while (p < b.length) {
|
|
120
|
+
const t = b[p++];
|
|
121
|
+
if (t === 0x3b)
|
|
122
|
+
break; // trailer
|
|
123
|
+
if (t === 0x21) {
|
|
124
|
+
const label = b[p++];
|
|
125
|
+
if (label === 0xf9) {
|
|
126
|
+
const d = blocks();
|
|
127
|
+
disposal = (d[0] >> 2) & 7;
|
|
128
|
+
delay = (d[1] | (d[2] << 8)) * 10;
|
|
129
|
+
transparent = d[0] & 1 ? d[3] : -1;
|
|
130
|
+
}
|
|
131
|
+
else if (label === 0xff) {
|
|
132
|
+
const id = String.fromCharCode(...b.subarray(p + 1, p + 12));
|
|
133
|
+
const d = blocks();
|
|
134
|
+
if ((id === 'NETSCAPE2.0' || id === 'ANIMEXTS1.0') && d.length >= 14 && d[11] === 1)
|
|
135
|
+
loopCount = d[12] | (d[13] << 8);
|
|
136
|
+
}
|
|
137
|
+
else
|
|
138
|
+
blocks();
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
if (t !== 0x2c)
|
|
142
|
+
break; // unknown block: stop (corrupt tail)
|
|
143
|
+
const x = b[p] | (b[p + 1] << 8), y = b[p + 2] | (b[p + 3] << 8), w = b[p + 4] | (b[p + 5] << 8), h = b[p + 6] | (b[p + 7] << 8), f = b[p + 8];
|
|
144
|
+
p += 9;
|
|
145
|
+
let pal = gct;
|
|
146
|
+
if (f & 0x80) {
|
|
147
|
+
const n = 3 << ((f & 7) + 1);
|
|
148
|
+
pal = b.subarray(p, p + n);
|
|
149
|
+
p += n;
|
|
150
|
+
}
|
|
151
|
+
const minCode = b[p++];
|
|
152
|
+
const idx = lzwDecode(minCode, blocks(), w * h);
|
|
153
|
+
const rows = new Uint32Array(h);
|
|
154
|
+
if (f & 0x40) {
|
|
155
|
+
// interlaced: rows come in 4 passes (every 8th from 0, every 8th from 4, every 4th from 2, every 2nd from 1)
|
|
156
|
+
let r = 0;
|
|
157
|
+
for (const [start, step] of [[0, 8], [4, 8], [2, 4], [1, 2]])
|
|
158
|
+
for (let yy = start; yy < h; yy += step)
|
|
159
|
+
rows[r++] = yy;
|
|
160
|
+
}
|
|
161
|
+
else
|
|
162
|
+
for (let yy = 0; yy < h; yy++)
|
|
163
|
+
rows[yy] = yy;
|
|
164
|
+
const data = new Uint8ClampedArray(w * h * 4);
|
|
165
|
+
for (let r = 0; r < h; r++) {
|
|
166
|
+
const dy = rows[r];
|
|
167
|
+
for (let xx = 0; xx < w; xx++) {
|
|
168
|
+
const ci = idx[r * w + xx], o = (dy * w + xx) * 4;
|
|
169
|
+
if (ci === transparent || !pal || ci * 3 + 2 >= pal.length)
|
|
170
|
+
continue;
|
|
171
|
+
data[o] = pal[ci * 3];
|
|
172
|
+
data[o + 1] = pal[ci * 3 + 1];
|
|
173
|
+
data[o + 2] = pal[ci * 3 + 2];
|
|
174
|
+
data[o + 3] = 255;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
parts.push({ x, y, image: { width: w, height: h, data }, delay: animImage.fixDelay(delay), blend: 'over', dispose: DISPOSE[disposal] || 'none' });
|
|
178
|
+
delay = 0;
|
|
179
|
+
transparent = -1;
|
|
180
|
+
disposal = 0;
|
|
181
|
+
}
|
|
182
|
+
// like browsers, "restore to background" clears to transparent
|
|
183
|
+
const frames = animImage.composeFrames(width, height, parts);
|
|
184
|
+
return {
|
|
185
|
+
format: 'gif',
|
|
186
|
+
width,
|
|
187
|
+
height,
|
|
188
|
+
plays: loopCount === null ? 1 : loopCount === 0 ? 0 : loopCount + 1,
|
|
189
|
+
frames,
|
|
190
|
+
info: { version: sig.slice(3), width, height, loopCount, frameCount: frames.length },
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
/** Fetch (URL) or read (ArrayBuffer / Blob / bytes) and decode a GIF. */
|
|
194
|
+
async function loadGif(src) {
|
|
195
|
+
return decodeGif(await animImage.bytesOf(src));
|
|
196
|
+
}
|
|
197
|
+
/** The module object for `use(formatGif)`. */
|
|
198
|
+
const formatGif = { id: 'format-gif', version: registry.RUNTIME_VERSION, requires: ['core'], api: { decodeGif, loadGif, lzwDecode, animatedImagePlayer: animImage.animatedImagePlayer } };
|
|
199
|
+
|
|
200
|
+
exports.animatedImagePlayer = animImage.animatedImagePlayer;
|
|
201
|
+
exports.composeFrames = animImage.composeFrames;
|
|
202
|
+
exports.decodeGif = decodeGif;
|
|
203
|
+
exports.formatGif = formatGif;
|
|
204
|
+
exports.loadGif = loadGif;
|
|
205
|
+
exports.lzwDecode = lzwDecode;
|
|
206
|
+
//# sourceMappingURL=format-gif.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-gif.cjs","sources":["../../src/runtime/format-gif.ts"],"sourcesContent":["/**\n * `motionary/runtime/format-gif` (10.4) — a complete GIF decoder written for\n * Motionary (own LZW implementation, no dependencies, no DOM): GIF87a / GIF89a,\n * global and local palettes, transparency, interlaced frames, disposal\n * methods 0–3, per-frame delays and the NETSCAPE2.0 loop count. Frames are\n * composited to full-size RGBA, so they can be drawn, scrubbed or reversed\n * with `animatedImagePlayer()` (a runtime timeline).\n *\n * ```ts\n * import { use } from 'motionary/runtime';\n * import { formatGif, loadGif, animatedImagePlayer } from 'motionary/runtime/format-gif';\n * use(formatGif);\n * const gif = await loadGif('/loader.gif');\n * const player = animatedImagePlayer(canvas, gif); // player.pause(); player.progress = 0.5\n * ```\n */\nimport { RUNTIME_VERSION, type RuntimeModule } from './registry';\nimport { composeFrames, fixDelay, bytesOf, animatedImagePlayer, u8, type AnimatedImage, type FramePart } from './anim-image';\n\nexport type { AnimatedImage, AnimFrame, Rgba, AnimPlayer, AnimPlayerOptions } from './anim-image';\nexport { animatedImagePlayer, composeFrames } from './anim-image';\n\n/** LZW-decode GIF image data into palette indices (exported for tests / tools). */\nexport function lzwDecode(minCodeSize: number, data: Uint8Array, pixelCount: number): Uint8Array {\n const out = new Uint8Array(pixelCount);\n const clear = 1 << minCodeSize, eoi = clear + 1;\n const prefix = new Uint16Array(4096), suffix = new Uint8Array(4096), stack = new Uint8Array(4097);\n let size = minCodeSize + 1, mask = (1 << size) - 1, next = eoi + 1;\n let old = -1, first = 0, bits = 0, acc = 0, op = 0, pos = 0;\n for (let i = 0; i < clear; i++) suffix[i] = i;\n while (op < pixelCount) {\n while (bits < size) {\n if (pos >= data.length) return out; // truncated data: keep what we have\n acc |= data[pos++] << bits;\n bits += 8;\n }\n const code = acc & mask;\n acc >>>= size;\n bits -= size;\n if (code === clear) {\n size = minCodeSize + 1; mask = (1 << size) - 1; next = eoi + 1; old = -1;\n continue;\n }\n if (code === eoi) break;\n if (old === -1) {\n out[op++] = suffix[code];\n old = first = code;\n continue;\n }\n let c = code, sp = 0;\n if (code >= next) {\n stack[sp++] = first;\n c = old;\n }\n while (c >= clear) {\n stack[sp++] = suffix[c];\n c = prefix[c];\n }\n first = suffix[c];\n stack[sp++] = first;\n while (sp && op < pixelCount) out[op++] = stack[--sp];\n if (next < 4096) {\n prefix[next] = old;\n suffix[next] = first;\n next++;\n if (next > mask && size < 12) {\n size++;\n mask = (1 << size) - 1;\n }\n }\n old = code;\n }\n return out;\n}\n\nexport interface GifInfo {\n version: '87a' | '89a';\n width: number;\n height: number;\n /** NETSCAPE2.0 loop count (0 = forever), or null when the file has none (plays once). */\n loopCount: number | null;\n frameCount: number;\n}\n\nconst DISPOSE: FramePart['dispose'][] = ['none', 'none', 'background', 'previous'];\n\n/** Decode a GIF (bytes) into composited RGBA frames. Pure: no DOM, works in workers / Node. */\nexport function decodeGif(input: Uint8Array | ArrayBuffer): AnimatedImage & { info: GifInfo } {\n const b = u8(input);\n const sig = String.fromCharCode(...b.subarray(0, 6));\n if (sig !== 'GIF87a' && sig !== 'GIF89a') throw new Error('[motionary] format-gif: not a GIF file');\n const width = b[6] | (b[7] << 8), height = b[8] | (b[9] << 8), flags = b[10];\n let p = 13, gct: Uint8Array | null = null;\n if (flags & 0x80) {\n const n = 3 << ((flags & 7) + 1);\n gct = b.subarray(p, p + n);\n p += n;\n }\n const parts: FramePart[] = [];\n let loopCount: number | null = null, delay = 0, transparent = -1, disposal = 0;\n const blocks = (): Uint8Array => {\n const chunks: Uint8Array[] = [];\n let len = 0;\n while (p < b.length) {\n const n = b[p++];\n if (!n) break;\n chunks.push(b.subarray(p, p + n));\n len += n;\n p += n;\n }\n const outB = new Uint8Array(len);\n let o = 0;\n for (const c of chunks) {\n outB.set(c, o);\n o += c.length;\n }\n return outB;\n };\n while (p < b.length) {\n const t = b[p++];\n if (t === 0x3b) break; // trailer\n if (t === 0x21) {\n const label = b[p++];\n if (label === 0xf9) {\n const d = blocks();\n disposal = (d[0] >> 2) & 7;\n delay = (d[1] | (d[2] << 8)) * 10;\n transparent = d[0] & 1 ? d[3] : -1;\n } else if (label === 0xff) {\n const id = String.fromCharCode(...b.subarray(p + 1, p + 12));\n const d = blocks();\n if ((id === 'NETSCAPE2.0' || id === 'ANIMEXTS1.0') && d.length >= 14 && d[11] === 1) loopCount = d[12] | (d[13] << 8);\n } else blocks();\n continue;\n }\n if (t !== 0x2c) break; // unknown block: stop (corrupt tail)\n const x = b[p] | (b[p + 1] << 8), y = b[p + 2] | (b[p + 3] << 8), w = b[p + 4] | (b[p + 5] << 8), h = b[p + 6] | (b[p + 7] << 8), f = b[p + 8];\n p += 9;\n let pal = gct;\n if (f & 0x80) {\n const n = 3 << ((f & 7) + 1);\n pal = b.subarray(p, p + n);\n p += n;\n }\n const minCode = b[p++];\n const idx = lzwDecode(minCode, blocks(), w * h);\n const rows = new Uint32Array(h);\n if (f & 0x40) {\n // interlaced: rows come in 4 passes (every 8th from 0, every 8th from 4, every 4th from 2, every 2nd from 1)\n let r = 0;\n for (const [start, step] of [[0, 8], [4, 8], [2, 4], [1, 2]]) for (let yy = start; yy < h; yy += step) rows[r++] = yy;\n } else for (let yy = 0; yy < h; yy++) rows[yy] = yy;\n const data = new Uint8ClampedArray(w * h * 4);\n for (let r = 0; r < h; r++) {\n const dy = rows[r];\n for (let xx = 0; xx < w; xx++) {\n const ci = idx[r * w + xx], o = (dy * w + xx) * 4;\n if (ci === transparent || !pal || ci * 3 + 2 >= pal.length) continue;\n data[o] = pal[ci * 3]; data[o + 1] = pal[ci * 3 + 1]; data[o + 2] = pal[ci * 3 + 2]; data[o + 3] = 255;\n }\n }\n parts.push({ x, y, image: { width: w, height: h, data }, delay: fixDelay(delay), blend: 'over', dispose: DISPOSE[disposal] || 'none' });\n delay = 0; transparent = -1; disposal = 0;\n }\n // like browsers, \"restore to background\" clears to transparent\n const frames = composeFrames(width, height, parts);\n return {\n format: 'gif',\n width,\n height,\n plays: loopCount === null ? 1 : loopCount === 0 ? 0 : loopCount + 1,\n frames,\n info: { version: sig.slice(3) as '87a' | '89a', width, height, loopCount, frameCount: frames.length },\n };\n}\n\n/** Fetch (URL) or read (ArrayBuffer / Blob / bytes) and decode a GIF. */\nexport async function loadGif(src: string | ArrayBuffer | ArrayBufferView | Blob): Promise<AnimatedImage & { info: GifInfo }> {\n return decodeGif(await bytesOf(src));\n}\n\nexport interface FormatGifApi {\n decodeGif: typeof decodeGif;\n loadGif: typeof loadGif;\n lzwDecode: typeof lzwDecode;\n animatedImagePlayer: typeof animatedImagePlayer;\n}\n\n/** The module object for `use(formatGif)`. */\nexport const formatGif: RuntimeModule<FormatGifApi> = { id: 'format-gif', version: RUNTIME_VERSION, requires: ['core'], api: { decodeGif, loadGif, lzwDecode, animatedImagePlayer } };\n"],"names":["u8","fixDelay","composeFrames","bytesOf","RUNTIME_VERSION","animatedImagePlayer"],"mappings":";;;;;;;;AAAA;;;;;;;;;;;;;;;AAeG;AAOH;SACgB,SAAS,CAAC,WAAmB,EAAE,IAAgB,EAAE,UAAkB,EAAA;AACjF,IAAA,MAAM,GAAG,GAAG,IAAI,UAAU,CAAC,UAAU,CAAC;IACtC,MAAM,KAAK,GAAG,CAAC,IAAI,WAAW,EAAE,GAAG,GAAG,KAAK,GAAG,CAAC;IAC/C,MAAM,MAAM,GAAG,IAAI,WAAW,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,EAAE,KAAK,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC;IACjG,IAAI,IAAI,GAAG,WAAW,GAAG,CAAC,EAAE,IAAI,GAAG,CAAC,CAAC,IAAI,IAAI,IAAI,CAAC,EAAE,IAAI,GAAG,GAAG,GAAG,CAAC;IAClE,IAAI,GAAG,GAAG,EAAE,EAAE,KAAK,GAAG,CAAC,EAAE,IAAI,GAAG,CAAC,EAAE,GAAG,GAAG,CAAC,EAAE,EAAE,GAAG,CAAC,EAAE,GAAG,GAAG,CAAC;IAC3D,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,EAAE;AAAE,QAAA,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC;AAC7C,IAAA,OAAO,EAAE,GAAG,UAAU,EAAE;AACtB,QAAA,OAAO,IAAI,GAAG,IAAI,EAAE;AAClB,YAAA,IAAI,GAAG,IAAI,IAAI,CAAC,MAAM;gBAAE,OAAO,GAAG,CAAC;Y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