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.
- package/AGENTS.md +1 -1
- package/CHANGELOG.md +32 -0
- package/README.md +119 -74
- package/README_ja.md +4 -4
- package/README_zh.md +4 -4
- package/dist/chunks/{anim-image-CnZDYmtv.js → anim-image-Btw3j5Qb.js} +2 -2
- package/dist/chunks/{anim-image-CnZDYmtv.js.map → anim-image-Btw3j5Qb.js.map} +1 -1
- package/dist/chunks/{anim-image-D1JZ7wOU.cjs → anim-image-DVv_vtbG.cjs} +2 -2
- package/dist/chunks/{anim-image-D1JZ7wOU.cjs.map → anim-image-DVv_vtbG.cjs.map} +1 -1
- package/dist/chunks/{three-scene-DibsZUID.js → gl-scene-BDA6FlGQ.js} +5 -11
- package/dist/chunks/gl-scene-BDA6FlGQ.js.map +1 -0
- package/dist/chunks/{three-scene-BFZnZuqp.cjs → gl-scene-SO5UU93S.cjs} +3 -10
- package/dist/chunks/gl-scene-SO5UU93S.cjs.map +1 -0
- package/dist/chunks/{keyframes-uYSI-do7.cjs → keyframes-4rb2WShh.cjs} +2 -2
- package/dist/chunks/{keyframes-uYSI-do7.cjs.map → keyframes-4rb2WShh.cjs.map} +1 -1
- package/dist/chunks/{keyframes-CLoYRGjR.js → keyframes-C9poRyzF.js} +2 -2
- package/dist/chunks/{keyframes-CLoYRGjR.js.map → keyframes-C9poRyzF.js.map} +1 -1
- package/dist/chunks/{lottie-player-UJHOl-8L.js → lottie-player-CPdwHhqe.js} +2 -2
- package/dist/chunks/{lottie-player-UJHOl-8L.js.map → lottie-player-CPdwHhqe.js.map} +1 -1
- package/dist/chunks/{lottie-player-Mcpt1H5w.cjs → lottie-player-DD1pnLN2.cjs} +2 -2
- package/dist/chunks/{lottie-player-Mcpt1H5w.cjs.map → lottie-player-DD1pnLN2.cjs.map} +1 -1
- package/dist/chunks/{physics-playground-BxnQyZ_V.cjs → physics-playground-B00t13Nz.cjs} +2 -2
- package/dist/chunks/{physics-playground-BxnQyZ_V.cjs.map → physics-playground-B00t13Nz.cjs.map} +1 -1
- package/dist/chunks/{physics-playground-B19qANJs.js → physics-playground-CluT_Nj9.js} +2 -2
- package/dist/chunks/{physics-playground-B19qANJs.js.map → physics-playground-CluT_Nj9.js.map} +1 -1
- package/dist/chunks/{registry-RJYrdUTF.js → registry-W7pXOwju.js} +3 -3
- package/dist/chunks/{registry-RJYrdUTF.js.map → registry-W7pXOwju.js.map} +1 -1
- package/dist/chunks/{registry-xGDPpmX2.cjs → registry-uaO8pDKn.cjs} +3 -3
- package/dist/chunks/{registry-xGDPpmX2.cjs.map → registry-uaO8pDKn.cjs.map} +1 -1
- package/dist/chunks/{runtime-link-GD9ayzxH.cjs → runtime-link-Bz3rGMsh.cjs} +2 -2
- package/dist/chunks/{runtime-link-GD9ayzxH.cjs.map → runtime-link-Bz3rGMsh.cjs.map} +1 -1
- package/dist/chunks/{runtime-link-CQyKFwE1.js → runtime-link-CP3qaRja.js} +2 -2
- package/dist/chunks/{runtime-link-CQyKFwE1.js.map → runtime-link-CP3qaRja.js.map} +1 -1
- package/dist/chunks/{scroll-scene-C-6sdMtR.cjs → scroll-scene-CeIosbEs.cjs} +3 -3
- package/dist/chunks/{scroll-scene-C-6sdMtR.cjs.map → scroll-scene-CeIosbEs.cjs.map} +1 -1
- package/dist/chunks/{scroll-scene-DtAaP0Aa.js → scroll-scene-eHhGcoDQ.js} +3 -3
- package/dist/chunks/{scroll-scene-DtAaP0Aa.js.map → scroll-scene-eHhGcoDQ.js.map} +1 -1
- package/dist/chunks/{ticker-C4VkAL4Y.js → ticker-D0qF_rV_.js} +2 -2
- package/dist/chunks/{ticker-C4VkAL4Y.js.map → ticker-D0qF_rV_.js.map} +1 -1
- package/dist/chunks/{ticker-DJuzcy1_.cjs → ticker-nshSbZ-Q.cjs} +2 -2
- package/dist/chunks/{ticker-DJuzcy1_.cjs.map → ticker-nshSbZ-Q.cjs.map} +1 -1
- package/dist/chunks/{tween-BHbiOBWO.cjs → tween-Df87h-1G.cjs} +2 -2
- package/dist/chunks/{tween-BHbiOBWO.cjs.map → tween-Df87h-1G.cjs.map} +1 -1
- package/dist/chunks/{tween-CrnzMeOU.js → tween-WepVA7id.js} +2 -2
- package/dist/chunks/{tween-CrnzMeOU.js.map → tween-WepVA7id.js.map} +1 -1
- package/dist/chunks/{worker-canvas-Bkwd1euX.js → worker-canvas-BZNHRLcu.js} +50 -3
- package/dist/chunks/worker-canvas-BZNHRLcu.js.map +1 -0
- package/dist/chunks/{worker-canvas-Ckc3R2Ye.cjs → worker-canvas-DW3VgtxO.cjs} +50 -2
- package/dist/chunks/worker-canvas-DW3VgtxO.cjs.map +1 -0
- package/dist/components/dotlottie.cjs +3 -3
- package/dist/components/dotlottie.d.cts +2 -1
- package/dist/components/dotlottie.d.ts +2 -1
- package/dist/components/dotlottie.js +3 -3
- package/dist/components/fx-perf.cjs +10 -5
- package/dist/components/fx-perf.cjs.map +1 -1
- package/dist/components/fx-perf.d.cts +6 -1
- package/dist/components/fx-perf.d.ts +6 -1
- package/dist/components/fx-perf.js +11 -6
- package/dist/components/fx-perf.js.map +1 -1
- package/dist/components/fx2.d.cts +6 -1
- package/dist/components/fx2.d.ts +6 -1
- package/dist/components/gl-model.cjs +3 -3
- package/dist/components/gl-model.d.cts +1 -1
- package/dist/components/gl-model.d.ts +1 -1
- package/dist/components/gl-model.js +3 -3
- package/dist/components/snap-carousel.cjs +2 -2
- package/dist/components/snap-carousel.js +2 -2
- package/dist/components/widgets.cjs +9 -9
- package/dist/components/widgets.cjs.map +1 -1
- package/dist/components/widgets.d.cts +10 -9
- package/dist/components/widgets.d.ts +10 -9
- package/dist/components/widgets.js +12 -12
- package/dist/components/widgets.js.map +1 -1
- package/dist/llms-full.txt +301 -312
- package/dist/llms.txt +3 -4
- package/dist/manifest.json +271 -299
- package/dist/runtime/drag-snap.cjs +1 -1
- package/dist/runtime/drag-snap.js +1 -1
- package/dist/runtime/format-apng.cjs +4 -4
- package/dist/runtime/format-apng.js +4 -4
- package/dist/runtime/format-css.cjs +4 -4
- package/dist/runtime/format-css.js +4 -4
- package/dist/runtime/format-gif.cjs +4 -4
- package/dist/runtime/format-gif.js +4 -4
- package/dist/runtime/format-gltf.cjs +1 -1
- package/dist/runtime/format-gltf.js +1 -1
- package/dist/runtime/format-motion.cjs +4 -4
- package/dist/runtime/format-motion.js +4 -4
- package/dist/runtime/format-obj.cjs +1 -1
- package/dist/runtime/format-obj.js +1 -1
- package/dist/runtime/format-scene.cjs +1 -1
- package/dist/runtime/format-scene.js +1 -1
- package/dist/runtime/format-sprite.cjs +3 -3
- package/dist/runtime/format-sprite.js +3 -3
- package/dist/runtime/format-svg.cjs +3 -3
- package/dist/runtime/format-svg.js +3 -3
- package/dist/runtime/format-webp.cjs +4 -4
- package/dist/runtime/format-webp.js +4 -4
- package/dist/runtime/gl.cjs +1 -1
- package/dist/runtime/gl.js +1 -1
- package/dist/runtime/gltf-anim.cjs +1 -1
- package/dist/runtime/gltf-anim.js +1 -1
- package/dist/runtime/gltf-decoders.cjs +1 -1
- package/dist/runtime/gltf-decoders.js +1 -1
- package/dist/runtime/lottie-state.cjs +1 -1
- package/dist/runtime/lottie-state.js +1 -1
- package/dist/runtime/physics.cjs +1 -1
- package/dist/runtime/physics.js +1 -1
- package/dist/runtime/scroll.cjs +2 -2
- package/dist/runtime/scroll.js +2 -2
- package/dist/runtime/smooth.cjs +1 -1
- package/dist/runtime/smooth.js +1 -1
- package/dist/runtime/text.cjs +1 -1
- package/dist/runtime/text.js +1 -1
- package/dist/runtime/vector.cjs +66 -17
- package/dist/runtime/vector.cjs.map +1 -1
- package/dist/runtime/vector.d.cts +30 -6
- package/dist/runtime/vector.d.ts +30 -6
- package/dist/runtime/vector.iife.js +1 -1
- package/dist/runtime/vector.iife.js.map +1 -1
- package/dist/runtime/vector.js +65 -18
- package/dist/runtime/vector.js.map +1 -1
- package/dist/runtime.cjs +3 -3
- package/dist/runtime.d.cts +2 -2
- package/dist/runtime.d.ts +2 -2
- package/dist/runtime.iife.js +1 -1
- package/dist/runtime.iife.js.map +1 -1
- package/dist/runtime.js +5 -5
- package/dist/widgets/dotlottie.cjs +3 -3
- package/dist/widgets/dotlottie.js +3 -3
- package/dist/widgets/gl-model.cjs +3 -3
- package/dist/widgets/gl-model.js +3 -3
- package/dist/widgets/gl-scene.cjs +3 -3
- package/dist/widgets/gl-scene.js +3 -3
- package/dist/widgets/install-button.cjs.map +1 -1
- package/dist/widgets/install-button.js.map +1 -1
- package/dist/widgets/lottie-player.cjs +3 -3
- package/dist/widgets/lottie-player.js +3 -3
- package/dist/widgets/motion-inspector.cjs +1 -1
- package/dist/widgets/motion-inspector.js +1 -1
- package/dist/widgets/physics-playground.cjs +3 -3
- package/dist/widgets/physics-playground.js +3 -3
- package/dist/widgets/plugin-card.cjs +2 -2
- package/dist/widgets/plugin-card.js +2 -2
- package/dist/widgets/scroll-scene.cjs +3 -3
- package/dist/widgets/scroll-scene.js +3 -3
- package/dist/widgets/smooth-scroll.cjs +2 -2
- package/dist/widgets/smooth-scroll.js +2 -2
- package/dist/widgets/snap-carousel.cjs +2 -2
- package/dist/widgets/snap-carousel.js +2 -2
- package/dist/widgets/text-splitter.cjs +2 -2
- package/dist/widgets/text-splitter.js +2 -2
- package/dist/widgets/worker-canvas.cjs +1 -1
- package/dist/widgets/worker-canvas.js +1 -1
- package/dist/widgets.umd.js +1 -1
- package/dist/widgets.umd.js.map +1 -1
- package/docs/ROADMAP.md +44 -4
- package/docs/architecture.md +78 -0
- package/docs/compat-matrix.md +340 -0
- package/docs/components/README.md +1 -5
- package/docs/components/usa-accordion.md +1 -1
- package/docs/components/usa-acrylic.md +1 -1
- package/docs/components/usa-add-to-cart.md +1 -1
- package/docs/components/usa-ambient.md +1 -1
- package/docs/components/usa-anim-icon.md +1 -1
- package/docs/components/usa-audio.md +1 -1
- package/docs/components/usa-aurora.md +1 -1
- package/docs/components/usa-auto-animate.md +1 -1
- package/docs/components/usa-auto-skeleton.md +1 -1
- package/docs/components/usa-avatar-stack.md +1 -1
- package/docs/components/usa-back-to-top.md +1 -1
- package/docs/components/usa-badge-wall.md +1 -1
- package/docs/components/usa-badge.md +1 -1
- package/docs/components/usa-bar-chart.md +1 -1
- package/docs/components/usa-bg-generator.md +1 -1
- package/docs/components/usa-blobs.md +1 -1
- package/docs/components/usa-bottom-sheet.md +1 -1
- package/docs/components/usa-button.md +1 -1
- package/docs/components/usa-card-stack.md +1 -1
- package/docs/components/usa-card.md +1 -1
- package/docs/components/usa-carousel-3d.md +1 -1
- package/docs/components/usa-carousel.md +1 -1
- package/docs/components/usa-cart-drawer.md +1 -1
- package/docs/components/usa-chapter-nav.md +1 -1
- package/docs/components/usa-chat-composer.md +1 -1
- package/docs/components/usa-check.md +1 -1
- package/docs/components/usa-checkbox.md +1 -1
- package/docs/components/usa-click.md +1 -1
- package/docs/components/usa-clock-control.md +1 -1
- package/docs/components/usa-code-export.md +1 -1
- package/docs/components/usa-color-picker.md +1 -1
- package/docs/components/usa-command-palette.md +1 -1
- package/docs/components/usa-compare.md +1 -1
- package/docs/components/usa-countdown.md +1 -1
- package/docs/components/usa-counter.md +1 -1
- package/docs/components/usa-cube-gallery.md +1 -1
- package/docs/components/usa-cube.md +1 -1
- package/docs/components/usa-cursor.md +1 -1
- package/docs/components/usa-date-picker.md +1 -1
- package/docs/components/usa-depth.md +1 -1
- package/docs/components/usa-dialog.md +1 -1
- package/docs/components/usa-disclosure.md +1 -1
- package/docs/components/usa-distort.md +1 -1
- package/docs/components/usa-dock.md +1 -1
- package/docs/components/usa-dot-network.md +1 -1
- package/docs/components/usa-dotlottie.md +6 -6
- package/docs/components/usa-double-tap.md +1 -1
- package/docs/components/usa-draggable.md +1 -1
- package/docs/components/usa-draw.md +1 -1
- package/docs/components/usa-drawer.md +1 -1
- package/docs/components/usa-equalizer.md +1 -1
- package/docs/components/usa-fab.md +1 -1
- package/docs/components/usa-festival-banner.md +1 -1
- package/docs/components/usa-field.md +1 -1
- package/docs/components/usa-file-drop.md +1 -1
- package/docs/components/usa-fullpage.md +1 -1
- package/docs/components/usa-fx.md +1 -1
- package/docs/components/usa-gauge.md +1 -1
- package/docs/components/usa-gen-art.md +1 -1
- package/docs/components/usa-gesture-fx.md +1 -1
- package/docs/components/usa-gesture-sticker.md +1 -1
- package/docs/components/usa-gl-model.md +7 -7
- package/docs/components/usa-gl-scene.md +10 -10
- package/docs/components/usa-glitch.md +1 -1
- package/docs/components/usa-globe.md +1 -1
- package/docs/components/usa-gpu-particles.md +1 -1
- package/docs/components/usa-gradient-text.md +1 -1
- package/docs/components/usa-grain.md +1 -1
- package/docs/components/usa-grid-glow.md +1 -1
- package/docs/components/usa-gyro-card.md +1 -1
- package/docs/components/usa-handwriting.md +1 -1
- package/docs/components/usa-hero-video.md +1 -1
- package/docs/components/usa-hold.md +1 -1
- package/docs/components/usa-hud-panel.md +1 -1
- package/docs/components/usa-hydrate.md +1 -1
- package/docs/components/usa-icon-morph.md +1 -1
- package/docs/components/usa-install-button.md +3 -3
- package/docs/components/usa-kanban.md +1 -1
- package/docs/components/usa-keyframe-editor.md +1 -1
- package/docs/components/usa-kpi.md +1 -1
- package/docs/components/usa-leaderboard.md +1 -1
- package/docs/components/usa-like.md +1 -1
- package/docs/components/usa-liquid-nav.md +1 -1
- package/docs/components/usa-liquid.md +1 -1
- package/docs/components/usa-loading-bar.md +1 -1
- package/docs/components/usa-location-card.md +1 -1
- package/docs/components/usa-lottie-icon.md +1 -1
- package/docs/components/usa-lottie-player.md +5 -5
- package/docs/components/usa-lottie.md +1 -1
- package/docs/components/usa-lyrics.md +1 -1
- package/docs/components/usa-magnetic.md +1 -1
- package/docs/components/usa-marquee.md +1 -1
- package/docs/components/usa-mask-reveal.md +1 -1
- package/docs/components/usa-masonry-flow.md +1 -1
- package/docs/components/usa-masonry.md +1 -1
- package/docs/components/usa-menu-toggle.md +1 -1
- package/docs/components/usa-menu.md +1 -1
- package/docs/components/usa-message-list.md +1 -1
- package/docs/components/usa-milestones.md +1 -1
- package/docs/components/usa-modal.md +1 -1
- package/docs/components/usa-morph.md +1 -1
- package/docs/components/usa-motion-inspector.md +1 -1
- package/docs/components/usa-motion-prefs.md +1 -1
- package/docs/components/usa-motion-prompt.md +1 -1
- package/docs/components/usa-motion-spec.md +1 -1
- package/docs/components/usa-motion-switch.md +1 -1
- package/docs/components/usa-motion-theme.md +1 -1
- package/docs/components/usa-motion.md +1 -1
- package/docs/components/usa-music-player.md +1 -1
- package/docs/components/usa-native-preview.md +1 -1
- package/docs/components/usa-nav-morph.md +1 -1
- package/docs/components/usa-navbar.md +1 -1
- package/docs/components/usa-notification-bell.md +1 -1
- package/docs/components/usa-odometer.md +1 -1
- package/docs/components/usa-organic-card.md +1 -1
- package/docs/components/usa-otp.md +1 -1
- package/docs/components/usa-overscroll.md +1 -1
- package/docs/components/usa-pack.md +1 -1
- package/docs/components/usa-pagination.md +1 -1
- package/docs/components/usa-panorama.md +1 -1
- package/docs/components/usa-parallax-layers.md +1 -1
- package/docs/components/usa-particles.md +1 -1
- package/docs/components/usa-pause-all.md +1 -1
- package/docs/components/usa-perf-monitor.md +1 -1
- package/docs/components/usa-physics-playground.md +6 -6
- package/docs/components/usa-pinch-zoom.md +1 -1
- package/docs/components/usa-player.md +1 -1
- package/docs/components/usa-plugin-card.md +4 -4
- package/docs/components/usa-plugin-store.md +1 -1
- package/docs/components/usa-popover.md +1 -1
- package/docs/components/usa-post-fx.md +1 -1
- package/docs/components/usa-presence.md +1 -1
- package/docs/components/usa-press.md +1 -1
- package/docs/components/usa-prize-wheel.md +1 -1
- package/docs/components/usa-product-gallery.md +1 -1
- package/docs/components/usa-progress-ring.md +1 -1
- package/docs/components/usa-progress.md +1 -1
- package/docs/components/usa-prop-panel.md +1 -1
- package/docs/components/usa-pull-cord.md +1 -1
- package/docs/components/usa-pull-refresh.md +1 -1
- package/docs/components/usa-radar.md +1 -1
- package/docs/components/usa-reactions.md +1 -1
- package/docs/components/usa-red-envelope.md +1 -1
- package/docs/components/usa-retro-button.md +1 -1
- package/docs/components/usa-reveal.md +1 -1
- package/docs/components/usa-ripple.md +1 -1
- package/docs/components/usa-rive.md +3 -3
- package/docs/components/usa-route-transition.md +1 -1
- package/docs/components/usa-scene.md +1 -1
- package/docs/components/usa-scramble.md +1 -1
- package/docs/components/usa-scroll-highlight.md +1 -1
- package/docs/components/usa-scroll-progress.md +1 -1
- package/docs/components/usa-scroll-ring.md +1 -1
- package/docs/components/usa-scroll-scene.md +5 -5
- package/docs/components/usa-scrolly.md +1 -1
- package/docs/components/usa-segmented.md +1 -1
- package/docs/components/usa-shader-backdrop.md +1 -1
- package/docs/components/usa-shader.md +1 -1
- package/docs/components/usa-sheet.md +1 -1
- package/docs/components/usa-shimmer-text.md +1 -1
- package/docs/components/usa-shortcut.md +1 -1
- package/docs/components/usa-skeleton-reveal.md +1 -1
- package/docs/components/usa-skeleton.md +1 -1
- package/docs/components/usa-sketch-chart.md +1 -1
- package/docs/components/usa-slider.md +1 -1
- package/docs/components/usa-smooth-scroll.md +5 -5
- package/docs/components/usa-snap-carousel.md +5 -5
- package/docs/components/usa-sparkline.md +1 -1
- package/docs/components/usa-spatial-card.md +1 -1
- package/docs/components/usa-spinner.md +1 -1
- package/docs/components/usa-splash.md +1 -1
- package/docs/components/usa-split-text.md +1 -1
- package/docs/components/usa-spotlight.md +1 -1
- package/docs/components/usa-spring.md +1 -1
- package/docs/components/usa-stagger.md +1 -1
- package/docs/components/usa-star-rating.md +1 -1
- package/docs/components/usa-stepper.md +1 -1
- package/docs/components/usa-sticky-stack.md +1 -1
- package/docs/components/usa-sticky-wall.md +1 -1
- package/docs/components/usa-stories.md +1 -1
- package/docs/components/usa-story.md +1 -1
- package/docs/components/usa-suggestion-chips.md +1 -1
- package/docs/components/usa-swipe-deck.md +1 -1
- package/docs/components/usa-swipeable.md +1 -1
- package/docs/components/usa-switch.md +1 -1
- package/docs/components/usa-tab-bar.md +1 -1
- package/docs/components/usa-tabs.md +1 -1
- package/docs/components/usa-terminal.md +1 -1
- package/docs/components/usa-text-rotate.md +1 -1
- package/docs/components/usa-text-splitter.md +5 -5
- package/docs/components/usa-theme-surface.md +1 -1
- package/docs/components/usa-theme-switcher.md +1 -1
- package/docs/components/usa-tilt.md +1 -1
- package/docs/components/usa-timeline.md +1 -1
- package/docs/components/usa-tip.md +1 -1
- package/docs/components/usa-toast-stack.md +1 -1
- package/docs/components/usa-toaster.md +1 -1
- package/docs/components/usa-token-editor.md +1 -1
- package/docs/components/usa-typewriter.md +1 -1
- package/docs/components/usa-upload-progress.md +1 -1
- package/docs/components/usa-video-card.md +1 -1
- package/docs/components/usa-view-switch.md +1 -1
- package/docs/components/usa-voice-button.md +1 -1
- package/docs/components/usa-volume-knob.md +1 -1
- package/docs/components/usa-water-ripple.md +1 -1
- package/docs/components/usa-wave-text.md +1 -1
- package/docs/components/usa-weather-card.md +1 -1
- package/docs/components/usa-worker-canvas.md +1 -1
- package/docs/components/usa-xp-bar.md +1 -1
- package/docs/components.md +49 -49
- package/docs/deprecations.md +2 -0
- package/docs/entry-points.md +1 -2
- package/docs/runtime/core.md +2 -2
- package/docs/runtime/drag-snap.md +3 -3
- package/docs/runtime/format-apng.md +3 -3
- package/docs/runtime/format-css.md +3 -3
- package/docs/runtime/format-gif.md +3 -3
- package/docs/runtime/format-gltf.md +3 -3
- package/docs/runtime/format-motion.md +3 -3
- package/docs/runtime/format-obj.md +3 -3
- package/docs/runtime/format-scene.md +3 -3
- package/docs/runtime/format-sprite.md +3 -3
- package/docs/runtime/format-svg.md +3 -3
- package/docs/runtime/format-webp.md +3 -3
- package/docs/runtime/gl.md +3 -3
- package/docs/runtime/gltf-anim.md +3 -3
- package/docs/runtime/gltf-decoders.md +3 -3
- package/docs/runtime/lottie-state.md +3 -3
- package/docs/runtime/physics.md +3 -3
- package/docs/runtime/scroll.md +3 -3
- package/docs/runtime/smooth.md +3 -3
- package/docs/runtime/text.md +3 -3
- package/docs/runtime/vector.md +3 -3
- package/docs/upgrading-11.md +2 -2
- package/package.json +1 -11
- package/dist/chunks/three-scene-BFZnZuqp.cjs.map +0 -1
- package/dist/chunks/three-scene-DibsZUID.js.map +0 -1
- package/dist/chunks/worker-canvas-Bkwd1euX.js.map +0 -1
- package/dist/chunks/worker-canvas-Ckc3R2Ye.cjs.map +0 -1
- package/dist/widgets/three-scene.cjs +0 -11
- package/dist/widgets/three-scene.cjs.map +0 -1
- package/dist/widgets/three-scene.d.cts +0 -2
- package/dist/widgets/three-scene.d.ts +0 -2
- package/dist/widgets/three-scene.js +0 -5
- package/dist/widgets/three-scene.js.map +0 -1
- package/docs/components/usa-three-scene.md +0 -20
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"anim-image-D1JZ7wOU.cjs","sources":["../../src/runtime/anim-image.ts"],"sourcesContent":["/**\n * Shared internals of the animated-image loaders (`format-gif`, `format-apng`,\n * `format-webp`, 10.4): the decoded-animation shape, frame compositing in\n * plain RGBA arrays (no DOM — works in workers and on the server), the\n * browser image decoder used for APNG / WebP frames, and the canvas player\n * (a runtime `Playable`, so it can be paused, reversed, scrubbed and driven\n * by a scroll scene). Bundled into each loader; not a public module.\n */\nimport { Playable } from './tween';\n\n/** An RGBA bitmap (the shape of `ImageData`, without needing the DOM). */\nexport interface Rgba {\n width: number;\n height: number;\n data: Uint8ClampedArray;\n}\n\n/** One frame of an animation, already composited to the full canvas size. */\nexport interface AnimFrame {\n /** Display time, ms. */\n delay: number;\n image: Rgba;\n}\n\nexport interface AnimatedImage {\n format: 'gif' | 'apng' | 'webp';\n width: number;\n height: number;\n /** Number of plays: 0 = forever, 1 = once, … */\n plays: number;\n frames: AnimFrame[];\n}\n\n/** A frame region before compositing (APNG fcTL / WebP ANMF / GIF descriptor). */\nexport interface FramePart {\n x: number;\n y: number;\n image: Rgba;\n delay: number;\n /** 'over' alpha-blends onto the canvas, 'source' replaces the region. */\n blend: 'over' | 'source';\n /** What happens to the region after the frame is shown. */\n dispose: 'none' | 'background' | 'previous';\n}\n\n/** Browsers clamp tiny delays (0–10 ms) to 100 ms; we do the same. */\nexport const fixDelay = (ms: number): number => (ms <= 10 ? 100 : ms);\n\n/** Composite frame parts onto a `width × height` canvas (pure; RGBA in, RGBA out). */\nexport function composeFrames(width: number, height: number, parts: FramePart[], background?: [number, number, number, number]): AnimFrame[] {\n const canvas = new Uint8ClampedArray(width * height * 4);\n const out: AnimFrame[] = [];\n for (const p of parts) {\n const before = p.dispose === 'previous' ? canvas.slice() : null;\n const { width: w, height: h, data } = p.image;\n for (let y = 0; y < h; y++) {\n const cy = p.y + y;\n if (cy < 0 || cy >= height) continue;\n for (let x = 0; x < w; x++) {\n const cx = p.x + x;\n if (cx < 0 || cx >= width) continue;\n const s = (y * w + x) * 4, d = (cy * width + cx) * 4;\n const a = data[s + 3];\n if (p.blend === 'source' || a === 255) {\n canvas[d] = data[s]; canvas[d + 1] = data[s + 1]; canvas[d + 2] = data[s + 2]; canvas[d + 3] = a;\n } else if (a) {\n // straight-alpha \"over\"\n const da = canvas[d + 3] / 255, sa = a / 255, oa = sa + da * (1 - sa);\n for (let c = 0; c < 3; c++) canvas[d + c] = (data[s + c] * sa + canvas[d + c] * da * (1 - sa)) / oa;\n canvas[d + 3] = oa * 255;\n }\n }\n }\n out.push({ delay: p.delay, image: { width, height, data: canvas.slice() } });\n if (p.dispose === 'background') {\n for (let y = Math.max(0, p.y); y < Math.min(height, p.y + h); y++)\n for (let x = Math.max(0, p.x); x < Math.min(width, p.x + w); x++) canvas.set(background || [0, 0, 0, 0], (y * width + x) * 4);\n } else if (before) canvas.set(before);\n }\n return out;\n}\n\n/** Image decoder for one frame file (PNG / WebP bytes) → RGBA. Replaceable (workers, tests, servers). */\nexport type FrameDecoder = (bytes: Uint8Array, mime: string) => Promise<Rgba>;\n\n/** Default decoder: the browser's own (`createImageBitmap` + a 2D canvas; OffscreenCanvas in workers). */\nexport const browserDecode: FrameDecoder = async (bytes, mime) => {\n const g = globalThis as any;\n if (typeof g.createImageBitmap !== 'function') throw new Error('[motionary] no image decoder here (createImageBitmap is missing) — pass { decode } to the loader');\n const bmp = await g.createImageBitmap(new Blob([bytes as BlobPart], { type: mime }));\n const w = bmp.width, h = bmp.height; // read before close(): a closed ImageBitmap reports 0 × 0\n const c = typeof g.OffscreenCanvas === 'function' ? new g.OffscreenCanvas(w, h) : Object.assign(document.createElement('canvas'), { width: w, height: h });\n const ctx = c.getContext('2d', { willReadFrequently: true });\n ctx.drawImage(bmp, 0, 0);\n bmp.close?.();\n const id = ctx.getImageData(0, 0, w, h);\n return { width: id.width, height: id.height, data: id.data };\n};\n\n/** Read a `src` (URL, ArrayBuffer, typed array or Blob) into bytes. */\nexport async function bytesOf(src: string | ArrayBuffer | ArrayBufferView | Blob): Promise<Uint8Array> {\n if (typeof src === 'string') {\n const r = await fetch(src);\n if (!r.ok) throw new Error(`[motionary] could not load ${src} (${r.status})`);\n return new Uint8Array(await r.arrayBuffer());\n }\n if (src instanceof ArrayBuffer) return new Uint8Array(src);\n if (ArrayBuffer.isView(src)) return new Uint8Array(src.buffer, src.byteOffset, src.byteLength);\n return new Uint8Array(await (src as Blob).arrayBuffer());\n}\n\nexport interface AnimPlayerOptions {\n /** Extra repeats; default from the file (`plays`: 0 → forever). */\n repeat?: number;\n yoyo?: boolean;\n paused?: boolean;\n /** Playback speed (default 1). */\n speed?: number;\n}\n\nexport type AnimPlayer = Playable & { readonly frame: number; readonly frameCount: number };\n\nclass AnimImagePlayer extends Playable {\n private times: number[] = [0];\n private cur = -1;\n private ctx: CanvasRenderingContext2D | null;\n private datas: (ImageData | null)[];\n constructor(private canvas: HTMLCanvasElement | OffscreenCanvas, private anim: AnimatedImage, o: AnimPlayerOptions) {\n super({ repeat: o.repeat ?? (anim.plays === 0 ? -1 : Math.max(0, anim.plays - 1)), yoyo: o.yoyo });\n this.timeScale = o.speed || 1;\n for (const f of anim.frames) this.times.push(this.times[this.times.length - 1] + f.delay);\n if (canvas.width !== anim.width) canvas.width = anim.width;\n if (canvas.height !== anim.height) canvas.height = anim.height;\n this.ctx = canvas.getContext('2d') as CanvasRenderingContext2D | null;\n this.datas = anim.frames.map(() => null);\n this.show(0);\n if (!o.paused) this.play();\n }\n get duration(): number {\n return this.times[this.times.length - 1];\n }\n get frame(): number {\n return this.cur;\n }\n get frameCount(): number {\n return this.anim.frames.length;\n }\n protected renderLocal(ms: number): void {\n const t = Math.min(ms, this.duration - 0.001);\n let lo = 0, hi = this.anim.frames.length - 1;\n while (lo < hi) {\n const mid = (lo + hi + 1) >> 1;\n if (this.times[mid] <= t) lo = mid;\n else hi = mid - 1;\n }\n this.show(lo);\n }\n private show(i: number): void {\n if (i === this.cur || !this.ctx) return;\n this.cur = i;\n const f = this.anim.frames[i];\n if (!f) return;\n let d = this.datas[i];\n if (!d && typeof ImageData === 'function') d = this.datas[i] = new ImageData(new Uint8ClampedArray(f.image.data), f.image.width, f.image.height);\n if (d) this.ctx.putImageData(d, 0, 0);\n }\n}\n\n/** Play a decoded animation on a canvas as a runtime timeline (seek / reverse / `progress` scrub). */\nexport function animatedImagePlayer(canvas: HTMLCanvasElement | OffscreenCanvas, anim: AnimatedImage, o: AnimPlayerOptions = {}): AnimPlayer {\n if (!anim.frames.length) throw new Error('[motionary] animatedImagePlayer: the animation has no frames');\n return new AnimImagePlayer(canvas, anim, o);\n}\n\n/** A plain Uint8Array view (Node Buffers' `slice()` shares memory — normalise them away). */\nexport const u8 = (x: Uint8Array | ArrayBuffer): Uint8Array => (x instanceof ArrayBuffer ? new Uint8Array(x) : new Uint8Array(x.buffer, x.byteOffset, x.byteLength));\n\n/** CRC-32 (PNG chunks). */\nlet CRC: Uint32Array | null = null;\nexport function crc32(bytes: Uint8Array, start = 0, end = bytes.length): number {\n if (!CRC) {\n CRC = new Uint32Array(256);\n for (let n = 0; n < 256; n++) {\n let c = n;\n for (let k = 0; k < 8; k++) c = c & 1 ? 0xedb88320 ^ (c >>> 1) : c >>> 1;\n CRC[n] = c >>> 0;\n }\n }\n let c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AAG,EAAE,CAAC,EAAE,EAAE;YAC5B,IAAI,CAAC,GAAG,CAAC;YACT,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE;gBAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,UAAU,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC;AACxE,YAAA,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC;QAClB;IACF;IACA,IAAI,CAAC,GAAG,UAAU;IAClB,KAAK,IAAI,CAAC,GAAG,KAAK,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE;QAAE,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC5E,IAAA,OAAO,CAAC,CAAC,GAAG,UAAU,MAAM,CAAC;AAC/B;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"anim-image-DVv_vtbG.cjs","sources":["../../src/runtime/anim-image.ts"],"sourcesContent":["/**\n * Shared internals of the animated-image loaders (`format-gif`, `format-apng`,\n * `format-webp`, 10.4): the decoded-animation shape, frame compositing in\n * plain RGBA arrays (no DOM — works in workers and on the server), the\n * browser image decoder used for APNG / WebP frames, and the canvas player\n * (a runtime `Playable`, so it can be paused, reversed, scrubbed and driven\n * by a scroll scene). Bundled into each loader; not a public module.\n */\nimport { Playable } from './tween';\n\n/** An RGBA bitmap (the shape of `ImageData`, without needing the DOM). */\nexport interface Rgba {\n width: number;\n height: number;\n data: Uint8ClampedArray;\n}\n\n/** One frame of an animation, already composited to the full canvas size. */\nexport interface AnimFrame {\n /** Display time, ms. */\n delay: number;\n image: Rgba;\n}\n\nexport interface AnimatedImage {\n format: 'gif' | 'apng' | 'webp';\n width: number;\n height: number;\n /** Number of plays: 0 = forever, 1 = once, … */\n plays: number;\n frames: AnimFrame[];\n}\n\n/** A frame region before compositing (APNG fcTL / WebP ANMF / GIF descriptor). */\nexport interface FramePart {\n x: number;\n y: number;\n image: Rgba;\n delay: number;\n /** 'over' alpha-blends onto the canvas, 'source' replaces the region. */\n blend: 'over' | 'source';\n /** What happens to the region after the frame is shown. */\n dispose: 'none' | 'background' | 'previous';\n}\n\n/** Browsers clamp tiny delays (0–10 ms) to 100 ms; we do the same. */\nexport const fixDelay = (ms: number): number => (ms <= 10 ? 100 : ms);\n\n/** Composite frame parts onto a `width × height` canvas (pure; RGBA in, RGBA out). */\nexport function composeFrames(width: number, height: number, parts: FramePart[], background?: [number, number, number, number]): AnimFrame[] {\n const canvas = new Uint8ClampedArray(width * height * 4);\n const out: AnimFrame[] = [];\n for (const p of parts) {\n const before = p.dispose === 'previous' ? canvas.slice() : null;\n const { width: w, height: h, data } = p.image;\n for (let y = 0; y < h; y++) {\n const cy = p.y + y;\n if (cy < 0 || cy >= height) continue;\n for (let x = 0; x < w; x++) {\n const cx = p.x + x;\n if (cx < 0 || cx >= width) continue;\n const s = (y * w + x) * 4, d = (cy * width + cx) * 4;\n const a = data[s + 3];\n if (p.blend === 'source' || a === 255) {\n canvas[d] = data[s]; canvas[d + 1] = data[s + 1]; canvas[d + 2] = data[s + 2]; canvas[d + 3] = a;\n } else if (a) {\n // straight-alpha \"over\"\n const da = canvas[d + 3] / 255, sa = a / 255, oa = sa + da * (1 - sa);\n for (let c = 0; c < 3; c++) canvas[d + c] = (data[s + c] * sa + canvas[d + c] * da * (1 - sa)) / oa;\n canvas[d + 3] = oa * 255;\n }\n }\n }\n out.push({ delay: p.delay, image: { width, height, data: canvas.slice() } });\n if (p.dispose === 'background') {\n for (let y = Math.max(0, p.y); y < Math.min(height, p.y + h); y++)\n for (let x = Math.max(0, p.x); x < Math.min(width, p.x + w); x++) canvas.set(background || [0, 0, 0, 0], (y * width + x) * 4);\n } else if (before) canvas.set(before);\n }\n return out;\n}\n\n/** Image decoder for one frame file (PNG / WebP bytes) → RGBA. Replaceable (workers, tests, servers). */\nexport type FrameDecoder = (bytes: Uint8Array, mime: string) => Promise<Rgba>;\n\n/** Default decoder: the browser's own (`createImageBitmap` + a 2D canvas; OffscreenCanvas in workers). */\nexport const browserDecode: FrameDecoder = async (bytes, mime) => {\n const g = globalThis as any;\n if (typeof g.createImageBitmap !== 'function') throw new Error('[motionary] no image decoder here (createImageBitmap is missing) — pass { decode } to the loader');\n const bmp = await g.createImageBitmap(new Blob([bytes as BlobPart], { type: mime }));\n const w = bmp.width, h = bmp.height; // read before close(): a closed ImageBitmap reports 0 × 0\n const c = typeof g.OffscreenCanvas === 'function' ? new g.OffscreenCanvas(w, h) : Object.assign(document.createElement('canvas'), { width: w, height: h });\n const ctx = c.getContext('2d', { willReadFrequently: true });\n ctx.drawImage(bmp, 0, 0);\n bmp.close?.();\n const id = ctx.getImageData(0, 0, w, h);\n return { width: id.width, height: id.height, data: id.data };\n};\n\n/** Read a `src` (URL, ArrayBuffer, typed array or Blob) into bytes. */\nexport async function bytesOf(src: string | ArrayBuffer | ArrayBufferView | Blob): Promise<Uint8Array> {\n if (typeof src === 'string') {\n const r = await fetch(src);\n if (!r.ok) throw new Error(`[motionary] could not load ${src} (${r.status})`);\n return new Uint8Array(await r.arrayBuffer());\n }\n if (src instanceof ArrayBuffer) return new Uint8Array(src);\n if (ArrayBuffer.isView(src)) return new Uint8Array(src.buffer, src.byteOffset, src.byteLength);\n return new Uint8Array(await (src as Blob).arrayBuffer());\n}\n\nexport interface AnimPlayerOptions {\n /** Extra repeats; default from the file (`plays`: 0 → forever). */\n repeat?: number;\n yoyo?: boolean;\n paused?: boolean;\n /** Playback speed (default 1). */\n speed?: number;\n}\n\nexport type AnimPlayer = Playable & { readonly frame: number; readonly frameCount: number };\n\nclass AnimImagePlayer extends Playable {\n private times: number[] = [0];\n private cur = -1;\n private ctx: CanvasRenderingContext2D | null;\n private datas: (ImageData | null)[];\n constructor(private canvas: HTMLCanvasElement | OffscreenCanvas, private anim: AnimatedImage, o: AnimPlayerOptions) {\n super({ repeat: o.repeat ?? (anim.plays === 0 ? -1 : Math.max(0, anim.plays - 1)), yoyo: o.yoyo });\n this.timeScale = o.speed || 1;\n for (const f of anim.frames) this.times.push(this.times[this.times.length - 1] + f.delay);\n if (canvas.width !== anim.width) canvas.width = anim.width;\n if (canvas.height !== anim.height) canvas.height = anim.height;\n this.ctx = canvas.getContext('2d') as CanvasRenderingContext2D | null;\n this.datas = anim.frames.map(() => null);\n this.show(0);\n if (!o.paused) this.play();\n }\n get duration(): number {\n return this.times[this.times.length - 1];\n }\n get frame(): number {\n return this.cur;\n }\n get frameCount(): number {\n return this.anim.frames.length;\n }\n protected renderLocal(ms: number): void {\n const t = Math.min(ms, this.duration - 0.001);\n let lo = 0, hi = this.anim.frames.length - 1;\n while (lo < hi) {\n const mid = (lo + hi + 1) >> 1;\n if (this.times[mid] <= t) lo = mid;\n else hi = mid - 1;\n }\n this.show(lo);\n }\n private show(i: number): void {\n if (i === this.cur || !this.ctx) return;\n this.cur = i;\n const f = this.anim.frames[i];\n if (!f) return;\n let d = this.datas[i];\n if (!d && typeof ImageData === 'function') d = this.datas[i] = new ImageData(new Uint8ClampedArray(f.image.data), f.image.width, f.image.height);\n if (d) this.ctx.putImageData(d, 0, 0);\n }\n}\n\n/** Play a decoded animation on a canvas as a runtime timeline (seek / reverse / `progress` scrub). */\nexport function animatedImagePlayer(canvas: HTMLCanvasElement | OffscreenCanvas, anim: AnimatedImage, o: AnimPlayerOptions = {}): AnimPlayer {\n if (!anim.frames.length) throw new Error('[motionary] animatedImagePlayer: the animation has no frames');\n return new AnimImagePlayer(canvas, anim, o);\n}\n\n/** A plain Uint8Array view (Node Buffers' `slice()` shares memory — normalise them away). */\nexport const u8 = (x: Uint8Array | ArrayBuffer): Uint8Array => (x instanceof ArrayBuffer ? new Uint8Array(x) : new Uint8Array(x.buffer, x.byteOffset, x.byteLength));\n\n/** CRC-32 (PNG chunks). */\nlet CRC: Uint32Array | null = null;\nexport function crc32(bytes: Uint8Array, start = 0, end = bytes.length): number {\n if (!CRC) {\n CRC = new Uint32Array(256);\n for (let n = 0; n < 256; n++) {\n let c = n;\n for (let k = 0; k < 8; k++) c = c & 1 ? 0xedb88320 ^ (c >>> 1) : c >>> 1;\n CRC[n] = c >>> 0;\n }\n }\n let c = 0xffffffff;\n for (let i = start; i < end; i++) c = CRC[(c ^ bytes[i]) & 0xff] ^ (c >>> 8);\n return (c ^ 0xffffffff) >>> 0;\n}\n"],"names":["Playable"],"mappings":";;;;AAAA;;;;;;;AAOG;AAsCH;MACa,QAAQ,GAAG,CAAC,EAAU,MAAc,EAAE,IAAI,EAAE,GAAG,GAAG,GAAG,EAAE;AAEpE;AACM,SAAU,aAAa,CAAC,KAAa,EAAE,MAAc,EAAE,KAAkB,EAAE,UAA6C,EAAA;IAC5H,MAAM,MAAM,GAAG,IAAI,iBAAiB,CAAC,KAAK,GAAG,MAAM,GAAG,CAAC,CAAC;IACxD,MAAM,GAAG,GAAgB,EAAE;AAC3B,IAAA,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE;AACrB,QAAA,MAAM,MAAM,GAAG,CAAC,CAAC,OAAO,KAAK,UAAU,GAAG,MAAM,CAAC,KAAK,EAAE,GAAG,IAAI;AAC/D,QAAA,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC,KAAK;AAC7C,QAAA,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;AAC1B,YAAA,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;AAClB,YAAA,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,IAAI,MAAM;gBAAE;AAC5B,YAAA,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;AAC1B,gBAAA,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,GA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AG,GAAG,KAAK,CAAC,MAAM,EAAA;IACpE,IAAI,CAAC,GAAG,EAAE;AACR,QAAA,GAAG,GAAG,IAAI,WAAW,CAAC,GAAG,CAAC;AAC1B,QAAA,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE;YAC5B,IAAI,CAAC,GAAG,CAAC;YACT,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE;gBAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,UAAU,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC;AACxE,YAAA,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC;QAClB;IACF;IACA,IAAI,CAAC,GAAG,UAAU;IAClB,KAAK,IAAI,CAAC,GAAG,KAAK,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE;QAAE,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC5E,IAAA,OAAO,CAAC,CAAC,GAAG,UAAU,MAAM,CAAC;AAC/B;;;;;;;;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { f as defineElement
|
|
2
|
-
import { r as runtimeModule } from './runtime-link-
|
|
1
|
+
import { f as defineElement } from './base-BTev8qxg.js';
|
|
2
|
+
import { r as runtimeModule } from './runtime-link-CP3qaRja.js';
|
|
3
3
|
|
|
4
|
-
var css = "usa-gl-scene
|
|
4
|
+
var css = "usa-gl-scene{position:relative;display:block;aspect-ratio:16/10;min-height:120px}usa-gl-scene>canvas{display:block;width:100%;height:100%;border-radius:inherit;touch-action:none;outline:none}usa-gl-scene>canvas:focus-visible{box-shadow:0 0 0 2px #6366f1}usa-gl-scene .usa-rt-missing{position:absolute;inset:0;margin:0;padding:8px;border-radius:8px;background:#fef2f2;color:#991b1b;font:11px/1.4 ui-monospace,monospace;overflow:auto;overflow-wrap:anywhere}";
|
|
5
5
|
|
|
6
6
|
function defineGlScene(tag = 'usa-gl-scene') {
|
|
7
7
|
return defineElement(tag, (Base) => {
|
|
@@ -37,8 +37,6 @@ function defineGlScene(tag = 'usa-gl-scene') {
|
|
|
37
37
|
const G = runtimeModule(this, 'gl');
|
|
38
38
|
if (!G)
|
|
39
39
|
return;
|
|
40
|
-
if (this.localName === 'usa-three-scene')
|
|
41
|
-
deprecate('three-scene', '<usa-three-scene> / defineThreeScene() are deprecated (10.9) and removed in 11.0 — use <usa-gl-scene> / defineGlScene() (same API). Run npx usa-codemod-11 --write src.');
|
|
42
40
|
const canvas = document.createElement('canvas');
|
|
43
41
|
canvas.setAttribute('role', 'img');
|
|
44
42
|
canvas.setAttribute('aria-label', this.str('label', '3D scene'));
|
|
@@ -174,10 +172,6 @@ function defineGlScene(tag = 'usa-gl-scene') {
|
|
|
174
172
|
return UsaGlScene;
|
|
175
173
|
}, { id: 'gl-scene', text: css });
|
|
176
174
|
}
|
|
177
|
-
/** `<usa-three-scene>` — alias of `<usa-gl-scene>`. @deprecated 10.9, removed in 11.0: use `<usa-gl-scene>` / `defineGlScene()`. */
|
|
178
|
-
function defineThreeScene(tag = 'usa-three-scene') {
|
|
179
|
-
return defineGlScene(tag);
|
|
180
|
-
}
|
|
181
175
|
|
|
182
|
-
export {
|
|
183
|
-
//# sourceMappingURL=
|
|
176
|
+
export { css as c, defineGlScene as d };
|
|
177
|
+
//# sourceMappingURL=gl-scene-BDA6FlGQ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gl-scene-BDA6FlGQ.js","sources":["../../src/components/widgets/gl-scene.ts"],"sourcesContent":["import { defineElement, type UsaElement } from '../base';\nimport { runtimeModule } from './runtime-link';\nimport type { GlApi, Scene, Camera, Renderer, GlNode } from '../../runtime/gl';\nimport type { FormatGltfApi } from '../../runtime/format-gltf';\nimport type { FormatObjApi } from '../../runtime/format-obj';\nimport type { GltfAnimApi, GltfAnimator } from '../../runtime/gltf-anim';\nimport css from './gl-scene.css?raw';\n\n/**\n * `<usa-gl-scene src=\"model.glb\" controls auto-rotate></usa-gl-scene>` (10.5)\n * — a WebGL2 3D viewer on **`motionary/runtime/gl`** (requires `use(gl)`;\n * `.gltf` / `.glb` models also need `motionary/runtime/format-gltf`, `.obj`\n * needs `motionary/runtime/format-obj`). Without `src` it shows a built-in\n * `shape` (torus · box · sphere · plane). `color`, `metallic`, `roughness`,\n * `background`, `exposure`, `controls` (drag / wheel / pinch / arrow keys),\n * `auto-rotate` (deg/s; off under reduced motion), `video` (a video URL\n * mapped onto the shape as a texture; `video-scrub` ties its time to the\n * element's scroll position instead of playing), `label` (accessible name).\n * 10.8: `animation` (clip name or index; empty = the first) plays a glTF\n * animation with skinning and morph targets (requires\n * `motionary/runtime/gltf-anim`), `animation-speed`; reduced motion shows\n * the first pose. Renders only while visible. `scene`, `camera`, `root`,\n * `animator`, `reload()`; `usa:load` { meshes, animations }, `usa:error`.\n * (The 10.5 alias `<usa-three-scene>` was removed in 11.0.)\n */\nexport interface UsaGlSceneElement extends UsaElement {\n readonly scene: Scene | null;\n readonly camera: Camera | null;\n readonly root: GlNode | null;\n readonly animator: GltfAnimator | null;\n reload(): Promise<void>;\n}\n\nexport function defineGlScene(tag = 'usa-gl-scene'): CustomElementConstructor | undefined {\n return defineElement(\n tag,\n (Base) => {\n class UsaGlScene extends Base {\n static get observedAttributes(): string[] {\n return ['src', 'shape', 'color', 'metallic', 'roughness', 'background', 'exposure', 'controls', 'auto-rotate', 'video', 'video-scrub', 'label', 'animation', 'animation-speed'];\n }\n private s: Scene | null = null;\n private cam: Camera | null = null;\n private node: GlNode | null = null;\n private r: Renderer | null = null;\n private an: GltfAnimator | null = null;\n get animator(): GltfAnimator | null {\n return this.an;\n }\n get scene(): Scene | null {\n return this.s;\n }\n get camera(): Camera | null {\n return this.cam;\n }\n get root(): GlNode | null {\n return this.node;\n }\n reload(): Promise<void> {\n this.changed('src');\n return Promise.resolve();\n }\n mount(): void {\n const G = runtimeModule<GlApi>(this, 'gl');\n if (!G) return;\n const canvas = document.createElement('canvas');\n canvas.setAttribute('role', 'img');\n canvas.setAttribute('aria-label', this.str('label', '3D scene'));\n if (this.flag('controls')) canvas.tabIndex = 0;\n this.querySelector(':scope > canvas')?.remove();\n this.prepend(canvas);\n this.onCleanup(() => canvas.remove());\n let r: Renderer;\n try {\n r = G.createRenderer(canvas, { alpha: true });\n } catch (e) {\n this.dataset.usaBackend = 'none';\n this.emit('error', { error: String((e as Error).message) });\n return;\n }\n this.r = r;\n this.dataset.usaBackend = 'webgl2';\n const scene = (this.s = new G.Scene());\n const bg = this.str('background');\n if (bg) scene.background = G.color(bg);\n scene.exposure = this.num('exposure', 1);\n scene.lights.push({ type: 'directional', vector: [0.8, -0.2, 0.5], color: [0.55, 0.65, 1], intensity: 0.8 });\n const cam = (this.cam = new G.Camera({ position: [1.6, 1.1, 2.6], fov: 40 }));\n let video: HTMLVideoElement | null = null;\n const vsrc = this.str('video');\n if (vsrc) {\n video = document.createElement('video');\n Object.assign(video, { src: vsrc, muted: true, loop: true, playsInline: true, crossOrigin: 'anonymous', preload: 'auto' });\n video.setAttribute('aria-hidden', 'true');\n this.onCleanup(() => {\n video!.pause();\n video!.removeAttribute('src');\n video!.load();\n });\n }\n const fallback = () => {\n const shapes: Record<string, () => any> = { box: () => G.box(1.2, 1.2, 1.2), sphere: () => G.sphere(0.8, 48, 24), plane: () => G.plane(1.8, 1.0125), torus: () => G.torus(0.62, 0.24, 64, 24) };\n const geo = (shapes[this.str('shape', video ? 'plane' : 'torus')] || shapes.torus)();\n const mat = G.standardMaterial({ color: G.color(this.str('color', '#818cf8')), metallic: this.num('metallic', 0.3), roughness: this.num('roughness', 0.35), doubleSided: true });\n if (video) {\n mat.map = G.texture(video, { repeat: false });\n mat.color = [1, 1, 1, 1];\n mat.type = 'unlit';\n }\n return new G.GlNode('shape', { geometry: geo, material: mat });\n };\n const done = (n: GlNode) => {\n this.node = n;\n scene.add(n);\n G.frameNode(cam, n, 1.15);\n let meshes = 0;\n n.traverse((x) => (meshes += x.mesh ? (Array.isArray(x.mesh) ? x.mesh.length : 1) : 0));\n const clip = this.getAttribute('animation');\n if (clip !== null && clip !== 'none' && (n.extras as any).gltf) {\n const A = runtimeModule<GltfAnimApi>(this, 'gltf-anim');\n if (A) {\n const an = (this.an = A.gltfAnimator(n, { clip: clip === '' ? 0 : /^\\d+$/.test(clip) ? +clip : clip, speed: this.num('animation-speed', 1) }));\n if (!an.clip && an.clips.length) this.emit('error', { error: `no animation \"${clip}\" (have: ${an.clips.map((c) => c.name).join(', ')})` });\n }\n }\n this.emit('load', { meshes, animations: this.an ? this.an.clips.map((c) => c.name) : [] });\n this.dataset.loaded = '';\n };\n const src = this.str('src');\n if (src) {\n const isObj = /\\.obj(\\?|#|$)/i.test(src);\n const loader = isObj ? runtimeModule<FormatObjApi>(this, 'format-obj') : runtimeModule<FormatGltfApi>(this, 'format-gltf');\n if (!loader) return;\n (isObj ? (loader as FormatObjApi).loadObj(new URL(src, location.href).href) : (loader as FormatGltfApi).loadGltf(new URL(src, location.href).href, ((this as any).gltfOptions?.() ?? {}) as any))\n .then((n) => this.isConnected && done(n))\n .catch((e) => {\n this.emit('error', { error: String(e.message || e) });\n done(fallback());\n });\n } else done(fallback());\n const ctl = this.flag('controls') ? G.orbitControls(cam, canvas, { autoRotate: this.reduced ? 0 : (this.num('auto-rotate', 0) * Math.PI) / 180 }) : null;\n const spin = !ctl && this.hasAttribute('auto-rotate') && !this.reduced ? (this.num('auto-rotate', 20) * Math.PI) / 180 : 0;\n this.onCleanup(() => {\n ctl?.dispose();\n r.dispose();\n this.r = null;\n this.an = null;\n });\n let visible = false, raf = 0, last = 0, t = 0;\n const frame = (now: number) => {\n raf = 0;\n const dt = last ? Math.min(50, now - last) : 16;\n last = now;\n t += dt;\n r.resize();\n ctl?.update(dt);\n if (spin && this.node) this.node.rotation = G.quatFromEuler(0, (t / 1000) * spin, 0);\n if (video && this.flag('video-scrub')) {\n const rc = this.getBoundingClientRect();\n G.scrubVideo(video, Math.min(1, Math.max(0, (innerHeight - rc.top) / (innerHeight + rc.height))));\n }\n const play = !!this.an?.clip && !this.reduced;\n if (play) this.an!.update(dt / 1000);\n r.render(scene, cam, t);\n if (visible && (spin || ctl || video || play || !this.dataset.loaded)) raf = requestAnimationFrame(frame);\n };\n const kick = () => {\n if (!raf) raf = requestAnimationFrame(frame);\n };\n this.listen(canvas, 'pointerdown', kick);\n this.listen(canvas, 'wheel', kick, { passive: true });\n this.listen(canvas, 'keydown', kick);\n this.listen(this, 'usa:load', kick);\n this.listen(window, 'resize', kick, { passive: true });\n this.inView((v) => {\n visible = v;\n if (video && !this.flag('video-scrub')) v && !this.reduced ? video.play().catch(() => undefined) : video.pause();\n if (v) {\n last = 0;\n kick();\n }\n });\n this.onCleanup(() => raf && cancelAnimationFrame(raf));\n }\n }\n return UsaGlScene as unknown as CustomElementConstructor;\n },\n { id: 'gl-scene', text: css }\n );\n}\n"],"names":[],"mappings":";;;;;AAiCM,SAAU,aAAa,CAAC,GAAG,GAAG,cAAc,EAAA;AAChD,IAAA,OAAO,aAAa,CAClB,GAAG,EACH,CAAC,IAAI,KAAI;QACP,MAAM,UAAW,SAAQ,IAAI,CAAA;AAA7B,YAAA,WAAA,GAAA;;gBAIU,IAAA,CAAA,CAAC,GAAiB,IAAI;gBACtB,IAAA,CAAA,GAAG,GAAkB,IAAI;gBACzB,IAAA,CAAA,IAAI,GAAkB,IAAI;gBAC1B,IAAA,CAAA,CAAC,GAAoB,IAAI;gBACzB,IAAA,CAAA,EAAE,GAAwB,IAAI;YA2IxC;AAlJE,YAAA,WAAW,kBAAkB,GAAA;AAC3B,gBAAA,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,aAAa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BACR;AACF,gBAAA,CAAC,CAAC;AACF,gBAAA,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,IAAI,oBAAoB,CAAC,GAAG,CAAC,CAAC;YACxD;AACD;AACD,QAAA,OAAO,UAAiD;IAC1D,CAAC,EACD,EAAE,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,CAC9B;AACH;;"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var base = require('./base-DBheNxJu.cjs');
|
|
4
|
-
var runtimeLink = require('./runtime-link-
|
|
4
|
+
var runtimeLink = require('./runtime-link-Bz3rGMsh.cjs');
|
|
5
5
|
|
|
6
|
-
var css = "usa-gl-scene
|
|
6
|
+
var css = "usa-gl-scene{position:relative;display:block;aspect-ratio:16/10;min-height:120px}usa-gl-scene>canvas{display:block;width:100%;height:100%;border-radius:inherit;touch-action:none;outline:none}usa-gl-scene>canvas:focus-visible{box-shadow:0 0 0 2px #6366f1}usa-gl-scene .usa-rt-missing{position:absolute;inset:0;margin:0;padding:8px;border-radius:8px;background:#fef2f2;color:#991b1b;font:11px/1.4 ui-monospace,monospace;overflow:auto;overflow-wrap:anywhere}";
|
|
7
7
|
|
|
8
8
|
function defineGlScene(tag = 'usa-gl-scene') {
|
|
9
9
|
return base.defineElement(tag, (Base) => {
|
|
@@ -39,8 +39,6 @@ function defineGlScene(tag = 'usa-gl-scene') {
|
|
|
39
39
|
const G = runtimeLink.runtimeModule(this, 'gl');
|
|
40
40
|
if (!G)
|
|
41
41
|
return;
|
|
42
|
-
if (this.localName === 'usa-three-scene')
|
|
43
|
-
base.deprecate('three-scene', '<usa-three-scene> / defineThreeScene() are deprecated (10.9) and removed in 11.0 — use <usa-gl-scene> / defineGlScene() (same API). Run npx usa-codemod-11 --write src.');
|
|
44
42
|
const canvas = document.createElement('canvas');
|
|
45
43
|
canvas.setAttribute('role', 'img');
|
|
46
44
|
canvas.setAttribute('aria-label', this.str('label', '3D scene'));
|
|
@@ -176,12 +174,7 @@ function defineGlScene(tag = 'usa-gl-scene') {
|
|
|
176
174
|
return UsaGlScene;
|
|
177
175
|
}, { id: 'gl-scene', text: css });
|
|
178
176
|
}
|
|
179
|
-
/** `<usa-three-scene>` — alias of `<usa-gl-scene>`. @deprecated 10.9, removed in 11.0: use `<usa-gl-scene>` / `defineGlScene()`. */
|
|
180
|
-
function defineThreeScene(tag = 'usa-three-scene') {
|
|
181
|
-
return defineGlScene(tag);
|
|
182
|
-
}
|
|
183
177
|
|
|
184
178
|
exports.css = css;
|
|
185
179
|
exports.defineGlScene = defineGlScene;
|
|
186
|
-
|
|
187
|
-
//# sourceMappingURL=three-scene-BFZnZuqp.cjs.map
|
|
180
|
+
//# sourceMappingURL=gl-scene-SO5UU93S.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gl-scene-SO5UU93S.cjs","sources":["../../src/components/widgets/gl-scene.ts"],"sourcesContent":["import { defineElement, type UsaElement } from '../base';\nimport { runtimeModule } from './runtime-link';\nimport type { GlApi, Scene, Camera, Renderer, GlNode } from '../../runtime/gl';\nimport type { FormatGltfApi } from '../../runtime/format-gltf';\nimport type { FormatObjApi } from '../../runtime/format-obj';\nimport type { GltfAnimApi, GltfAnimator } from '../../runtime/gltf-anim';\nimport css from './gl-scene.css?raw';\n\n/**\n * `<usa-gl-scene src=\"model.glb\" controls auto-rotate></usa-gl-scene>` (10.5)\n * — a WebGL2 3D viewer on **`motionary/runtime/gl`** (requires `use(gl)`;\n * `.gltf` / `.glb` models also need `motionary/runtime/format-gltf`, `.obj`\n * needs `motionary/runtime/format-obj`). Without `src` it shows a built-in\n * `shape` (torus · box · sphere · plane). `color`, `metallic`, `roughness`,\n * `background`, `exposure`, `controls` (drag / wheel / pinch / arrow keys),\n * `auto-rotate` (deg/s; off under reduced motion), `video` (a video URL\n * mapped onto the shape as a texture; `video-scrub` ties its time to the\n * element's scroll position instead of playing), `label` (accessible name).\n * 10.8: `animation` (clip name or index; empty = the first) plays a glTF\n * animation with skinning and morph targets (requires\n * `motionary/runtime/gltf-anim`), `animation-speed`; reduced motion shows\n * the first pose. Renders only while visible. `scene`, `camera`, `root`,\n * `animator`, `reload()`; `usa:load` { meshes, animations }, `usa:error`.\n * (The 10.5 alias `<usa-three-scene>` was removed in 11.0.)\n */\nexport interface UsaGlSceneElement extends UsaElement {\n readonly scene: Scene | null;\n readonly camera: Camera | null;\n readonly root: GlNode | null;\n readonly animator: GltfAnimator | null;\n reload(): Promise<void>;\n}\n\nexport function defineGlScene(tag = 'usa-gl-scene'): CustomElementConstructor | undefined {\n return defineElement(\n tag,\n (Base) => {\n class UsaGlScene extends Base {\n static get observedAttributes(): string[] {\n return ['src', 'shape', 'color', 'metallic', 'roughness', 'background', 'exposure', 'controls', 'auto-rotate', 'video', 'video-scrub', 'label', 'animation', 'animation-speed'];\n }\n private s: Scene | null = null;\n private cam: Camera | null = null;\n private node: GlNode | null = null;\n private r: Renderer | null = null;\n private an: GltfAnimator | null = null;\n get animator(): GltfAnimator | null {\n return this.an;\n }\n get scene(): Scene | null {\n return this.s;\n }\n get camera(): Camera | null {\n return this.cam;\n }\n get root(): GlNode | null {\n return this.node;\n }\n reload(): Promise<void> {\n this.changed('src');\n return Promise.resolve();\n }\n mount(): void {\n const G = runtimeModule<GlApi>(this, 'gl');\n if (!G) return;\n const canvas = document.createElement('canvas');\n canvas.setAttribute('role', 'img');\n canvas.setAttribute('aria-label', this.str('label', '3D scene'));\n if (this.flag('controls')) canvas.tabIndex = 0;\n this.querySelector(':scope > canvas')?.remove();\n this.prepend(canvas);\n this.onCleanup(() => canvas.remove());\n let r: Renderer;\n try {\n r = G.createRenderer(canvas, { alpha: true });\n } catch (e) {\n this.dataset.usaBackend = 'none';\n this.emit('error', { error: String((e as Error).message) });\n return;\n }\n this.r = r;\n this.dataset.usaBackend = 'webgl2';\n const scene = (this.s = new G.Scene());\n const bg = this.str('background');\n if (bg) scene.background = G.color(bg);\n scene.exposure = this.num('exposure', 1);\n scene.lights.push({ type: 'directional', vector: [0.8, -0.2, 0.5], color: [0.55, 0.65, 1], intensity: 0.8 });\n const cam = (this.cam = new G.Camera({ position: [1.6, 1.1, 2.6], fov: 40 }));\n let video: HTMLVideoElement | null = null;\n const vsrc = this.str('video');\n if (vsrc) {\n video = document.createElement('video');\n Object.assign(video, { src: vsrc, muted: true, loop: true, playsInline: true, crossOrigin: 'anonymous', preload: 'auto' });\n video.setAttribute('aria-hidden', 'true');\n this.onCleanup(() => {\n video!.pause();\n video!.removeAttribute('src');\n video!.load();\n });\n }\n const fallback = () => {\n const shapes: Record<string, () => any> = { box: () => G.box(1.2, 1.2, 1.2), sphere: () => G.sphere(0.8, 48, 24), plane: () => G.plane(1.8, 1.0125), torus: () => G.torus(0.62, 0.24, 64, 24) };\n const geo = (shapes[this.str('shape', video ? 'plane' : 'torus')] || shapes.torus)();\n const mat = G.standardMaterial({ color: G.color(this.str('color', '#818cf8')), metallic: this.num('metallic', 0.3), roughness: this.num('roughness', 0.35), doubleSided: true });\n if (video) {\n mat.map = G.texture(video, { repeat: false });\n mat.color = [1, 1, 1, 1];\n mat.type = 'unlit';\n }\n return new G.GlNode('shape', { geometry: geo, material: mat });\n };\n const done = (n: GlNode) => {\n this.node = n;\n scene.add(n);\n G.frameNode(cam, n, 1.15);\n let meshes = 0;\n n.traverse((x) => (meshes += x.mesh ? (Array.isArray(x.mesh) ? x.mesh.length : 1) : 0));\n const clip = this.getAttribute('animation');\n if (clip !== null && clip !== 'none' && (n.extras as any).gltf) {\n const A = runtimeModule<GltfAnimApi>(this, 'gltf-anim');\n if (A) {\n const an = (this.an = A.gltfAnimator(n, { clip: clip === '' ? 0 : /^\\d+$/.test(clip) ? +clip : clip, speed: this.num('animation-speed', 1) }));\n if (!an.clip && an.clips.length) this.emit('error', { error: `no animation \"${clip}\" (have: ${an.clips.map((c) => c.name).join(', ')})` });\n }\n }\n this.emit('load', { meshes, animations: this.an ? this.an.clips.map((c) => c.name) : [] });\n this.dataset.loaded = '';\n };\n const src = this.str('src');\n if (src) {\n const isObj = /\\.obj(\\?|#|$)/i.test(src);\n const loader = isObj ? runtimeModule<FormatObjApi>(this, 'format-obj') : runtimeModule<FormatGltfApi>(this, 'format-gltf');\n if (!loader) return;\n (isObj ? (loader as FormatObjApi).loadObj(new URL(src, location.href).href) : (loader as FormatGltfApi).loadGltf(new URL(src, location.href).href, ((this as any).gltfOptions?.() ?? {}) as any))\n .then((n) => this.isConnected && done(n))\n .catch((e) => {\n this.emit('error', { error: String(e.message || e) });\n done(fallback());\n });\n } else done(fallback());\n const ctl = this.flag('controls') ? G.orbitControls(cam, canvas, { autoRotate: this.reduced ? 0 : (this.num('auto-rotate', 0) * Math.PI) / 180 }) : null;\n const spin = !ctl && this.hasAttribute('auto-rotate') && !this.reduced ? (this.num('auto-rotate', 20) * Math.PI) / 180 : 0;\n this.onCleanup(() => {\n ctl?.dispose();\n r.dispose();\n this.r = null;\n this.an = null;\n });\n let visible = false, raf = 0, last = 0, t = 0;\n const frame = (now: number) => {\n raf = 0;\n const dt = last ? Math.min(50, now - last) : 16;\n last = now;\n t += dt;\n r.resize();\n ctl?.update(dt);\n if (spin && this.node) this.node.rotation = G.quatFromEuler(0, (t / 1000) * spin, 0);\n if (video && this.flag('video-scrub')) {\n const rc = this.getBoundingClientRect();\n G.scrubVideo(video, Math.min(1, Math.max(0, (innerHeight - rc.top) / (innerHeight + rc.height))));\n }\n const play = !!this.an?.clip && !this.reduced;\n if (play) this.an!.update(dt / 1000);\n r.render(scene, cam, t);\n if (visible && (spin || ctl || video || play || !this.dataset.loaded)) raf = requestAnimationFrame(frame);\n };\n const kick = () => {\n if (!raf) raf = requestAnimationFrame(frame);\n };\n this.listen(canvas, 'pointerdown', kick);\n this.listen(canvas, 'wheel', kick, { passive: true });\n this.listen(canvas, 'keydown', kick);\n this.listen(this, 'usa:load', kick);\n this.listen(window, 'resize', kick, { passive: true });\n this.inView((v) => {\n visible = v;\n if (video && !this.flag('video-scrub')) v && !this.reduced ? video.play().catch(() => undefined) : video.pause();\n if (v) {\n last = 0;\n kick();\n }\n });\n this.onCleanup(() => raf && cancelAnimationFrame(raf));\n }\n }\n return UsaGlScene as unknown as CustomElementConstructor;\n },\n { id: 'gl-scene', text: css }\n );\n}\n"],"names":["defineElement","runtimeModule"],"mappings":";;;;;;;AAiCM,SAAU,aAAa,CAAC,GAAG,GAAG,cAAc,EAAA;AAChD,IAAA,OAAOA,kBAAa,CAClB,GAAG,EACH,CAAC,IAAI,KAAI;QACP,MAAM,UAAW,SAAQ,IAAI,CAAA;AAA7B,YAAA,WAAA,GAAA;;gBAIU,IAAA,CAAA,CAAC,GAAiB,IAAI;gBACtB,IAAA,CAAA,GAAG,GAAkB,IAAI;gBACzB,IAAA,CAAA,IAAI,GAAkB,IAAI;gBAC1B,IAAA,CAAA,CAAC,GAAoB,IAAI;gBACzB,IAAA,CAAA,EAAE,GAAwB,IAAI;YA2IxC;AAlJE,YAAA,WAAW,kBAAkB,GAAA;AAC3B,gBAAA,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,aAAa,EAAE,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,WAAW,EAAE,iBAAiB,CAAC;YACjL;AAMA,YAAA,IAAI,QAAQ,GAAA;gBACV,OAAO,IAAI,CAAC,EAAE;YAChB;AACA,YAAA,IAAI,KAAK,GAAA;gBACP,OAAO,IAAI,CAAC,CAAC;YACf;AACA,YAAA,IAAI,MAAM,GAAA;gBACR,OAAO,IAAI,CAAC,GAAG;YACjB;AACA,YAAA,IAAI,IAAI,GAAA;gBACN,OAAO,IAAI,CAAC,IAAI;YAClB;YACA,MAAM,GAAA;AACJ,gBAAA,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;AACnB,gBAAA,OAAO,OAAO,CAAC,OAAO,EAAE;YAC1B;YACA,KAAK,GAAA;gB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AAC,MAAM,CAAC,MAAM,EAAE,aAAa,EAAE,IAAI,CAAC;AACxC,gBAAA,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;gBACrD,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,EAAE,IAAI,CAAC;gBACpC,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,CAAC;AACnC,gBAAA,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AACtD,gBAAA,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,KAAI;oBAChB,OAAO,GAAG,CAAC;oBACX,IAAI,KAAK,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC;wBAAE,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,MAAM,SAAS,CAAC,GAAG,KAAK,CAAC,KAAK,EAAE;oBAChH,IAAI,CAAC,EAAE;wBACL,IAAI,GAAG,CAAC;AACR,wBAAA,IAAI,EAAE;oBACR;AACF,gBAAA,CAAC,CAAC;AACF,gBAAA,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,IAAI,oBAAoB,CAAC,GAAG,CAAC,CAAC;YACxD;AACD;AACD,QAAA,OAAO,UAAiD;IAC1D,CAAC,EACD,EAAE,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,CAC9B;AACH;;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var tween = require('./tween-
|
|
3
|
+
var tween = require('./tween-Df87h-1G.cjs');
|
|
4
4
|
var ease = require('./ease-HwYZnZat.cjs');
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -185,4 +185,4 @@ function framesToTimeline(target, frames, o = {}) {
|
|
|
185
185
|
exports.camelProp = camelProp;
|
|
186
186
|
exports.distributeOffsets = distributeOffsets;
|
|
187
187
|
exports.framesToTimeline = framesToTimeline;
|
|
188
|
-
//# sourceMappingURL=keyframes-
|
|
188
|
+
//# sourceMappingURL=keyframes-4rb2WShh.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keyframes-uYSI-do7.cjs","sources":["../../src/runtime/keyframes.ts"],"sourcesContent":["/**\n * Normalised keyframes shared by the format loaders: a list of frames with\n * offsets in [0, 1], camelCase props and an optional per-segment easing,\n * played as a runtime `Timeline` (one tween per segment).\n */\nimport { Timeline, Tween, parseValue, type Target, type PlayOptions } from './tween';\nimport { parseEase, type Ease } from './ease';\n\nexport interface Frame {\n offset: number;\n props: Record<string, string | number>;\n /** Easing from this frame to the next. */\n easing?: string;\n}\n\nexport interface KeyframesPlayOptions extends PlayOptions {\n /** ms (default 1000). */\n duration?: number;\n /** Default easing for segments without their own (default 'linear', as in CSS / WAAPI keyframes). */\n ease?: string | Ease;\n}\n\nexport const camelProp = (k: string): string => (k.startsWith('--') ? k : k.trim().replace(/-([a-z])/g, (_, c: string) => c.toUpperCase()));\n\n/** Fill in missing offsets (spaced evenly between known ones, first 0 / last 1), as the WAAPI does. */\nexport function distributeOffsets<T extends { offset?: number | null }>(frames: T[]): (T & { offset: number })[] {\n const out = frames.map((f) => ({ ...f })) as (T & { offset: number })[];\n if (!out.length) return out;\n if (out[0].offset == null) out[0].offset = out.length === 1 ? 1 : 0;\n if (out[out.length - 1].offset == null) out[out.length - 1].offset = 1;\n let i = 0;\n while (i < out.length) {\n if (out[i].offset != null) { i++; continue; }\n const a = i - 1;\n let b = i;\n while (out[b].offset == null) b++;\n const from = out[a].offset, to = out[b].offset;\n for (let k = i; k < b; k++) out[k].offset = from + ((to - from) * (k - a)) / (b - a);\n i = b;\n }\n return out;\n}\n\n/** CSS transform functions → runtime transform shorthands (translate/rotate/scale/skew); null when not representable (matrix, 3D, …). */\nexport function transformToProps(t: string): Record<string, string | number> | null {\n if (!t || t === 'none') return { x: 0, y: 0, rotate: 0, scale: 1 };\n const out: Record<string, string | number> = {};\n const re = /([a-zA-Z][a-zA-Z0-9]*)\\(([^)]*)\\)/g;\n let m: RegExpExecArray | null;\n let rest = t;\n while ((m = re.exec(t))) {\n rest = rest.replace(m[0], '');\n const args = m[2].split(/[\\s,]+/).filter(Boolean);\n switch (m[1]) {\n case 'translate': out.x = args[0]; out.y = args[1] ?? 0; break;\n case 'translateX': out.x = args[0]; break;\n case 'translateY': out.y = args[0]; break;\n case 'translate3d': if (parseFloat(args[2] || '0') !== 0) return null; out.x = args[0]; out.y = args[1] ?? 0; break;\n case 'scale3d': if (parseFloat(args[2] ?? '1') !== 1) return null; if (args[1] !== undefined && args[1] !== args[0]) { out.scaleX = +args[0]; out.scaleY = +args[1]; } else out.scale = +args[0]; break;\n case 'rotate': case 'rotateZ': out.rotate = args[0]; break;\n case 'scale': if (args[1] !== undefined && args[1] !== args[0]) { out.scaleX = +args[0]; out.scaleY = +args[1]; } else out.scale = +args[0]; break;\n case 'scaleX': out.scaleX = +args[0]; break;\n case 'scaleY': out.scaleY = +args[0]; break;\n case 'skewX': out.skewX = args[0]; break;\n case 'skewY': out.skewY = args[0]; break;\n default: return null;\n }\n }\n return rest.trim() ? null : out;\n}\n\n/** Expand `transform` into shorthands where possible (kept as a discrete prop otherwise). */\nexport function expandProps(props: Record<string, string | number>): Record<string, string | number> {\n const out: Record<string, string | number> = {};\n for (const [k, v] of Object.entries(props)) {\n if (k === 'transform' && typeof v === 'string') {\n const t = transformToProps(v);\n if (t) { Object.assign(out, t); continue; }\n }\n out[k] = v;\n }\n return out;\n}\n\nconst tweenable = (v: string | number): boolean => {\n try { parseValue(v); return true; } catch { return false; }\n};\n\n/**\n * Play frames on a target as a `Timeline` (paused unless `paused: false`).\n * Props missing from a frame hold their previous value; non-numeric values\n * (e.g. `display`, `matrix(...)`) switch discretely at the segment midpoint.\n */\nexport function framesToTimeline(target: Target, frames: Frame[], o: KeyframesPlayOptions = {}): Timeline {\n const dur = o.duration ?? 1000;\n const fs = [...frames].sort((a, b) => a.offset - b.offset).map((f) => ({ ...f, props: expandProps(f.props) }));\n const tl = new Timeline({ repeat: o.repeat, yoyo: o.yoyo, delay: o.delay, onUpdate: o.onUpdate, onComplete: o.onComplete });\n const keys = Array.from(new Set(fs.flatMap((f) => Object.keys(f.props))));\n // carry values forward / backward so every frame has every key\n const filled = fs.map((f) => ({ ...f, props: { ...f.props } }));\n for (const k of keys) {\n let last: string | number | undefined;\n for (const f of filled) { if (k in f.props) last = f.props[k]; else if (last !== undefined) f.props[k] = last; }\n let next: string | number | undefined;\n for (let i = filled.length - 1; i >= 0; i--) { if (k in filled[i].props) next = filled[i].props[k]; else if (next !== undefined) filled[i].props[k] = next; }\n }\n const def = o.ease ?? 'linear';\n if (filled.length === 1) filled.unshift({ ...filled[0], offset: 0 });\n for (let i = 0; i < filled.length - 1; i++) {\n const a = filled[i], b = filled[i + 1];\n const segDur = Math.max(0, (b.offset - a.offset) * dur);\n const from: Record<string, string | number> = {}, to: Record<string, string | number> = {};\n const discrete: [string, string | number][] = [];\n for (const k of keys) {\n if (tweenable(a.props[k]) && tweenable(b.props[k])) { from[k] = a.props[k]; to[k] = b.props[k]; }\n else discrete.push([k, b.props[k]]);\n }\n tl.add(new Tween(target, { from, to, duration: segDur, ease: a.easing ? parseEase(a.easing) : def, paused: true }), a.offset * dur);\n for (const [k, v] of discrete) tl.call(() => { if ((target as any).style) (target as HTMLElement).style.setProperty(k.replace(/[A-Z]/g, (c) => '-' + c.toLowerCase()), String(v)); else (target as any)[k] = v; }, a.offset * dur + segDur / 2);\n }\n if (o.paused === false) tl.play();\n return tl;\n}\n"],"names":["parseValue","Timeline","Tween","parseEase"],"mappings":";;;;;AAAA;;;;AAIG;MAkBU,SAAS,GAAG,CAAC,CAAS,MAAc,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG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GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;gBAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;YAAE;;AAC3F,gBAAA,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QACrC;QACA,EAAE,CAAC,GAAG,CAAC,IAAIC,WAAK,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,GAAGC,cAAS,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,MAAM,GAAG,GAAG,CAAC;AACnI,QAAA,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,QAAQ;YAAE,EAAE,CAAC,IAAI,CAAC,MAAK,EAAG,IAAK,MAAc,CAAC,KAAK;AAAG,gBAAA,MAAsB,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC,KAAK,GAAG,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;;AAAQ,gBAAA,MAAc,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,GAAG,GAAG,GAAG,MAAM,GAAG,CAAC,CAAC;IACjP;AACA,IAAA,IAAI,CAAC,CAAC,MAAM,KAAK,KAAK;QAAE,EAAE,CAAC,IAAI,EAAE;AACjC,IAAA,OAAO,EAAE;AACX;;;;"}
|
|
1
|
+
{"version":3,"file":"keyframes-4rb2WShh.cjs","sources":["../../src/runtime/keyframes.ts"],"sourcesContent":["/**\n * Normalised keyframes shared by the format loaders: a list of frames with\n * offsets in [0, 1], camelCase props and an optional per-segment easing,\n * played as a runtime `Timeline` (one tween per segment).\n */\nimport { Timeline, Tween, parseValue, type Target, type PlayOptions } from './tween';\nimport { parseEase, type Ease } from './ease';\n\nexport interface Frame {\n offset: number;\n props: Record<string, string | number>;\n /** Easing from this frame to the next. */\n easing?: string;\n}\n\nexport interface KeyframesPlayOptions extends PlayOptions {\n /** ms (default 1000). */\n duration?: number;\n /** Default easing for segments without their own (default 'linear', as in CSS / WAAPI keyframes). */\n ease?: string | Ease;\n}\n\nexport const camelProp = (k: string): string => (k.startsWith('--') ? k : k.trim().replace(/-([a-z])/g, (_, c: string) => c.toUpperCase()));\n\n/** Fill in missing offsets (spaced evenly between known ones, first 0 / last 1), as the WAAPI does. */\nexport function distributeOffsets<T extends { offset?: number | null }>(frames: T[]): (T & { offset: number })[] {\n const out = frames.map((f) => ({ ...f })) as (T & { offset: number })[];\n if (!out.length) return out;\n if (out[0].offset == null) out[0].offset = out.length === 1 ? 1 : 0;\n if (out[out.length - 1].offset == null) out[out.length - 1].offset = 1;\n let i = 0;\n while (i < out.length) {\n if (out[i].offset != null) { i++; continue; }\n const a = i - 1;\n let b = i;\n while (out[b].offset == null) b++;\n const from = out[a].offset, to = out[b].offset;\n for (let k = i; k < b; k++) out[k].offset = from + ((to - from) * (k - a)) / (b - a);\n i = b;\n }\n return out;\n}\n\n/** CSS transform functions → runtime transform shorthands (translate/rotate/scale/skew); null when not representable (matrix, 3D, …). */\nexport function transformToProps(t: string): Record<string, string | number> | null {\n if (!t || t === 'none') return { x: 0, y: 0, rotate: 0, scale: 1 };\n const out: Record<string, string | number> = {};\n const re = /([a-zA-Z][a-zA-Z0-9]*)\\(([^)]*)\\)/g;\n let m: RegExpExecArray | null;\n let rest = t;\n while ((m = re.exec(t))) {\n rest = rest.replace(m[0], '');\n const args = m[2].split(/[\\s,]+/).filter(Boolean);\n switch (m[1]) {\n case 'translate': out.x = args[0]; out.y = args[1] ?? 0; break;\n case 'translateX': out.x = args[0]; break;\n case 'translateY': out.y = args[0]; break;\n case 'translate3d': if (parseFloat(args[2] || '0') !== 0) return null; out.x = args[0]; out.y = args[1] ?? 0; break;\n case 'scale3d': if (parseFloat(args[2] ?? '1') !== 1) return null; if (args[1] !== undefined && args[1] !== args[0]) { out.scaleX = +args[0]; out.scaleY = +args[1]; } else out.scale = +args[0]; break;\n case 'rotate': case 'rotateZ': out.rotate = args[0]; break;\n case 'scale': if (args[1] !== undefined && args[1] !== args[0]) { out.scaleX = +args[0]; out.scaleY = +args[1]; } else out.scale = +args[0]; break;\n case 'scaleX': out.scaleX = +args[0]; break;\n case 'scaleY': out.scaleY = +args[0]; break;\n case 'skewX': out.skewX = args[0]; break;\n case 'skewY': out.skewY = args[0]; break;\n default: return null;\n }\n }\n return rest.trim() ? null : out;\n}\n\n/** Expand `transform` into shorthands where possible (kept as a discrete prop otherwise). */\nexport function expandProps(props: Record<string, string | number>): Record<string, string | number> {\n const out: Record<string, string | number> = {};\n for (const [k, v] of Object.entries(props)) {\n if (k === 'transform' && typeof v === 'string') {\n const t = transformToProps(v);\n if (t) { Object.assign(out, t); continue; }\n }\n out[k] = v;\n }\n return out;\n}\n\nconst tweenable = (v: string | number): boolean => {\n try { parseValue(v); return true; } catch { return false; }\n};\n\n/**\n * Play frames on a target as a `Timeline` (paused unless `paused: false`).\n * Props missing from a frame hold their previous value; non-numeric values\n * (e.g. `display`, `matrix(...)`) switch discretely at the segment midpoint.\n */\nexport function framesToTimeline(target: Target, frames: Frame[], o: KeyframesPlayOptions = {}): Timeline {\n const dur = o.duration ?? 1000;\n const fs = [...frames].sort((a, b) => a.offset - b.offset).map((f) => ({ ...f, props: expandProps(f.props) }));\n const tl = new Timeline({ repeat: o.repeat, yoyo: o.yoyo, delay: o.delay, onUpdate: o.onUpdate, onComplete: o.onComplete });\n const keys = Array.from(new Set(fs.flatMap((f) => Object.keys(f.props))));\n // carry values forward / backward so every frame has every key\n const filled = fs.map((f) => ({ ...f, props: { ...f.props } }));\n for (const k of keys) {\n let last: string | number | undefined;\n for (const f of filled) { if (k in f.props) last = f.props[k]; else if (last !== undefined) f.props[k] = last; }\n let next: string | number | undefined;\n for (let i = filled.length - 1; i >= 0; i--) { if (k in filled[i].props) next = filled[i].props[k]; else if (next !== undefined) filled[i].props[k] = next; }\n }\n const def = o.ease ?? 'linear';\n if (filled.length === 1) filled.unshift({ ...filled[0], offset: 0 });\n for (let i = 0; i < filled.length - 1; i++) {\n const a = filled[i], b = filled[i + 1];\n const segDur = Math.max(0, (b.offset - a.offset) * dur);\n const from: Record<string, string | number> = {}, to: Record<string, string | number> = {};\n const discrete: [string, string | number][] = [];\n for (const k of keys) {\n if (tweenable(a.props[k]) && tweenable(b.props[k])) { from[k] = a.props[k]; to[k] = b.props[k]; }\n else discrete.push([k, b.props[k]]);\n }\n tl.add(new Tween(target, { from, to, duration: segDur, ease: a.easing ? parseEase(a.easing) : def, paused: true }), a.offset * dur);\n for (const [k, v] of discrete) tl.call(() => { if ((target as any).style) (target as HTMLElement).style.setProperty(k.replace(/[A-Z]/g, (c) => '-' + c.toLowerCase()), String(v)); else (target as any)[k] = v; }, a.offset * dur + segDur / 2);\n }\n if (o.paused === false) tl.play();\n return tl;\n}\n"],"names":["parseValue","Timeline","Tween","parseEase"],"mappings":";;;;;AAAA;;;;AAIG;MAkBU,SAAS,GAAG,CAAC,CAAS,MAAc,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC,EAAE,CAAS,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;AAE1I;AACM,SAAU,iBAAiB,CAAuC,MAAW,EAAA;AACjF,IAAA,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC,CAA+B;IACvE,IAAI,CAAC,GAAG,CAAC,MAAM;AAAE,QAAA,OAAO,GAAG;AAC3B,IAAA,IAAI,GAAG,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CAAC,MAAM,GAAGC,cAAS,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,MAAM,GAAG,GAAG,CAAC;AACnI,QAAA,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,QAAQ;YAAE,EAAE,CAAC,IAAI,CAAC,MAAK,EAAG,IAAK,MAAc,CAAC,KAAK;AAAG,gBAAA,MAAsB,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC,KAAK,GAAG,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;;AAAQ,gBAAA,MAAc,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,GAAG,GAAG,GAAG,MAAM,GAAG,CAAC,CAAC;IACjP;AACA,IAAA,IAAI,CAAC,CAAC,MAAM,KAAK,KAAK;QAAE,EAAE,CAAC,IAAI,EAAE;AACjC,IAAA,OAAO,EAAE;AACX;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { T as Timeline, a as Tween, p as parseValue } from './tween-
|
|
1
|
+
import { T as Timeline, a as Tween, p as parseValue } from './tween-WepVA7id.js';
|
|
2
2
|
import { p as parseEase } from './ease-XN8_0sXu.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -181,4 +181,4 @@ function framesToTimeline(target, frames, o = {}) {
|
|
|
181
181
|
}
|
|
182
182
|
|
|
183
183
|
export { camelProp as c, distributeOffsets as d, framesToTimeline as f };
|
|
184
|
-
//# sourceMappingURL=keyframes-
|
|
184
|
+
//# sourceMappingURL=keyframes-C9poRyzF.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keyframes-CLoYRGjR.js","sources":["../../src/runtime/keyframes.ts"],"sourcesContent":["/**\n * Normalised keyframes shared by the format loaders: a list of frames with\n * offsets in [0, 1], camelCase props and an optional per-segment easing,\n * played as a runtime `Timeline` (one tween per segment).\n */\nimport { Timeline, Tween, parseValue, type Target, type PlayOptions } from './tween';\nimport { parseEase, type Ease } from './ease';\n\nexport interface Frame {\n offset: number;\n props: Record<string, string | number>;\n /** Easing from this frame to the next. */\n easing?: string;\n}\n\nexport interface KeyframesPlayOptions extends PlayOptions {\n /** ms (default 1000). */\n duration?: number;\n /** Default easing for segments without their own (default 'linear', as in CSS / WAAPI keyframes). */\n ease?: string | Ease;\n}\n\nexport const camelProp = (k: string): string => (k.startsWith('--') ? k : k.trim().replace(/-([a-z])/g, (_, c: string) => c.toUpperCase()));\n\n/** Fill in missing offsets (spaced evenly between known ones, first 0 / last 1), as the WAAPI does. */\nexport function distributeOffsets<T extends { offset?: number | null }>(frames: T[]): (T & { offset: number })[] {\n const out = frames.map((f) => ({ ...f })) as (T & { offset: number })[];\n if (!out.length) return out;\n if (out[0].offset == null) out[0].offset = out.length === 1 ? 1 : 0;\n if (out[out.length - 1].offset == null) out[out.length - 1].offset = 1;\n let i = 0;\n while (i < out.length) {\n if (out[i].offset != null) { i++; continue; }\n const a = i - 1;\n let b = i;\n while (out[b].offset == null) b++;\n const from = out[a].offset, to = out[b].offset;\n for (let k = i; k < b; k++) out[k].offset = from + ((to - from) * (k - a)) / (b - a);\n i = b;\n }\n return out;\n}\n\n/** CSS transform functions → runtime transform shorthands (translate/rotate/scale/skew); null when not representable (matrix, 3D, …). */\nexport function transformToProps(t: string): Record<string, string | number> | null {\n if (!t || t === 'none') return { x: 0, y: 0, rotate: 0, scale: 1 };\n const out: Record<string, string | number> = {};\n const re = /([a-zA-Z][a-zA-Z0-9]*)\\(([^)]*)\\)/g;\n let m: RegExpExecArray | null;\n let rest = t;\n while ((m = re.exec(t))) {\n rest = rest.replace(m[0], '');\n const args = m[2].split(/[\\s,]+/).filter(Boolean);\n switch (m[1]) {\n case 'translate': out.x = args[0]; out.y = args[1] ?? 0; break;\n case 'translateX': out.x = args[0]; break;\n case 'translateY': out.y = args[0]; break;\n case 'translate3d': if (parseFloat(args[2] || '0') !== 0) return null; out.x = args[0]; out.y = args[1] ?? 0; break;\n case 'scale3d': if (parseFloat(args[2] ?? '1') !== 1) return null; if (args[1] !== undefined && args[1] !== args[0]) { out.scaleX = +args[0]; out.scaleY = +args[1]; } else out.scale = +args[0]; break;\n case 'rotate': case 'rotateZ': out.rotate = args[0]; break;\n case 'scale': if (args[1] !== undefined && args[1] !== args[0]) { out.scaleX = +args[0]; out.scaleY = +args[1]; } else out.scale = +args[0]; break;\n case 'scaleX': out.scaleX = +args[0]; break;\n case 'scaleY': out.scaleY = +args[0]; break;\n case 'skewX': out.skewX = args[0]; break;\n case 'skewY': out.skewY = args[0]; break;\n default: return null;\n }\n }\n return rest.trim() ? null : out;\n}\n\n/** Expand `transform` into shorthands where possible (kept as a discrete prop otherwise). */\nexport function expandProps(props: Record<string, string | number>): Record<string, string | number> {\n const out: Record<string, string | number> = {};\n for (const [k, v] of Object.entries(props)) {\n if (k === 'transform' && typeof v === 'string') {\n const t = transformToProps(v);\n if (t) { Object.assign(out, t); continue; }\n }\n out[k] = v;\n }\n return out;\n}\n\nconst tweenable = (v: string | number): boolean => {\n try { parseValue(v); return true; } catch { return false; }\n};\n\n/**\n * Play frames on a target as a `Timeline` (paused unless `paused: false`).\n * Props missing from a frame hold their previous value; non-numeric values\n * (e.g. `display`, `matrix(...)`) switch discretely at the segment midpoint.\n */\nexport function framesToTimeline(target: Target, frames: Frame[], o: KeyframesPlayOptions = {}): Timeline {\n const dur = o.duration ?? 1000;\n const fs = [...frames].sort((a, b) => a.offset - b.offset).map((f) => ({ ...f, props: expandProps(f.props) }));\n const tl = new Timeline({ repeat: o.repeat, yoyo: o.yoyo, delay: o.delay, onUpdate: o.onUpdate, onComplete: o.onComplete });\n const keys = Array.from(new Set(fs.flatMap((f) => Object.keys(f.props))));\n // carry values forward / backward so every frame has every key\n const filled = fs.map((f) => ({ ...f, props: { ...f.props } }));\n for (const k of keys) {\n let last: string | number | undefined;\n for (const f of filled) { if (k in f.props) last = f.props[k]; else if (last !== undefined) f.props[k] = last; }\n let next: string | number | undefined;\n for (let i = filled.length - 1; i >= 0; i--) { if (k in filled[i].props) next = filled[i].props[k]; else if (next !== undefined) filled[i].props[k] = next; }\n }\n const def = o.ease ?? 'linear';\n if (filled.length === 1) filled.unshift({ ...filled[0], offset: 0 });\n for (let i = 0; i < filled.length - 1; i++) {\n const a = filled[i], b = filled[i + 1];\n const segDur = Math.max(0, (b.offset - a.offset) * dur);\n const from: Record<string, string | number> = {}, to: Record<string, string | number> = {};\n const discrete: [string, string | number][] = [];\n for (const k of keys) {\n if (tweenable(a.props[k]) && tweenable(b.props[k])) { from[k] = a.props[k]; to[k] = b.props[k]; }\n else discrete.push([k, b.props[k]]);\n }\n tl.add(new Tween(target, { from, to, duration: segDur, ease: a.easing ? parseEase(a.easing) : def, paused: true }), a.offset * dur);\n for (const [k, v] of discrete) tl.call(() => { if ((target as any).style) (target as HTMLElement).style.setProperty(k.replace(/[A-Z]/g, (c) => '-' + c.toLowerCase()), String(v)); else (target as any)[k] = v; }, a.offset * dur + segDur / 2);\n }\n if (o.paused === false) tl.play();\n return tl;\n}\n"],"names":[],"mappings":";;;AAAA;;;;AAIG;MAkBU,SAAS,GAAG,CAAC,CAAS,MAAc,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC,EAAE,CAAS,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;AAE1I;AACM,SAAU,iBAAiB,CAAuC,MAAW,EAAA;AACjF,IAAA,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC,CAA+B;IACvE,IAAI,CAAC,GAAG,CAAC,MAAM;AAAE,QAAA,OAAO,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M,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,MAAM,GAAG,GAAG,CAAC;AACnI,QAAA,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,QAAQ;YAAE,EAAE,CAAC,IAAI,CAAC,MAAK,EAAG,IAAK,MAAc,CAAC,KAAK;AAAG,gBAAA,MAAsB,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC,KAAK,GAAG,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;;AAAQ,gBAAA,MAAc,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,GAAG,GAAG,GAAG,MAAM,GAAG,CAAC,CAAC;IACjP;AACA,IAAA,IAAI,CAAC,CAAC,MAAM,KAAK,KAAK;QAAE,EAAE,CAAC,IAAI,EAAE;AACjC,IAAA,OAAO,EAAE;AACX;;"}
|
|
1
|
+
{"version":3,"file":"keyframes-C9poRyzF.js","sources":["../../src/runtime/keyframes.ts"],"sourcesContent":["/**\n * Normalised keyframes shared by the format loaders: a list of frames with\n * offsets in [0, 1], camelCase props and an optional per-segment easing,\n * played as a runtime `Timeline` (one tween per segment).\n */\nimport { Timeline, Tween, parseValue, type Target, type PlayOptions } from './tween';\nimport { parseEase, type Ease } from './ease';\n\nexport interface Frame {\n offset: number;\n props: Record<string, string | number>;\n /** Easing from this frame to the next. */\n easing?: string;\n}\n\nexport interface KeyframesPlayOptions extends PlayOptions {\n /** ms (default 1000). */\n duration?: number;\n /** Default easing for segments without their own (default 'linear', as in CSS / WAAPI keyframes). */\n ease?: string | Ease;\n}\n\nexport const camelProp = (k: string): string => (k.startsWith('--') ? k : k.trim().replace(/-([a-z])/g, (_, c: string) => c.toUpperCase()));\n\n/** Fill in missing offsets (spaced evenly between known ones, first 0 / last 1), as the WAAPI does. */\nexport function distributeOffsets<T extends { offset?: number | null }>(frames: T[]): (T & { offset: number })[] {\n const out = frames.map((f) => ({ ...f })) as (T & { offset: number })[];\n if (!out.length) return out;\n if (out[0].offset == null) out[0].offset = out.length === 1 ? 1 : 0;\n if (out[out.length - 1].offset == null) out[out.length - 1].offset = 1;\n let i = 0;\n while (i < out.length) {\n if (out[i].offset != null) { i++; continue; }\n const a = i - 1;\n let b = i;\n while (out[b].offset == null) b++;\n const from = out[a].offset, to = out[b].offset;\n for (let k = i; k < b; k++) out[k].offset = from + ((to - from) * (k - a)) / (b - a);\n i = b;\n }\n return out;\n}\n\n/** CSS transform functions → runtime transform shorthands (translate/rotate/scale/skew); null when not representable (matrix, 3D, …). */\nexport function transformToProps(t: string): Record<string, string | number> | null {\n if (!t || t === 'none') return { x: 0, y: 0, rotate: 0, scale: 1 };\n const out: Record<string, string | number> = {};\n const re = /([a-zA-Z][a-zA-Z0-9]*)\\(([^)]*)\\)/g;\n let m: RegExpExecArray | null;\n let rest = t;\n while ((m = re.exec(t))) {\n rest = rest.replace(m[0], '');\n const args = m[2].split(/[\\s,]+/).filter(Boolean);\n switch (m[1]) {\n case 'translate': out.x = args[0]; out.y = args[1] ?? 0; break;\n case 'translateX': out.x = args[0]; break;\n case 'translateY': out.y = args[0]; break;\n case 'translate3d': if (parseFloat(args[2] || '0') !== 0) return null; out.x = args[0]; out.y = args[1] ?? 0; break;\n case 'scale3d': if (parseFloat(args[2] ?? '1') !== 1) return null; if (args[1] !== undefined && args[1] !== args[0]) { out.scaleX = +args[0]; out.scaleY = +args[1]; } else out.scale = +args[0]; break;\n case 'rotate': case 'rotateZ': out.rotate = args[0]; break;\n case 'scale': if (args[1] !== undefined && args[1] !== args[0]) { out.scaleX = +args[0]; out.scaleY = +args[1]; } else out.scale = +args[0]; break;\n case 'scaleX': out.scaleX = +args[0]; break;\n case 'scaleY': out.scaleY = +args[0]; break;\n case 'skewX': out.skewX = args[0]; break;\n case 'skewY': out.skewY = args[0]; break;\n default: return null;\n }\n }\n return rest.trim() ? null : out;\n}\n\n/** Expand `transform` into shorthands where possible (kept as a discrete prop otherwise). */\nexport function expandProps(props: Record<string, string | number>): Record<string, string | number> {\n const out: Record<string, string | number> = {};\n for (const [k, v] of Object.entries(props)) {\n if (k === 'transform' && typeof v === 'string') {\n const t = transformToProps(v);\n if (t) { Object.assign(out, t); continue; }\n }\n out[k] = v;\n }\n return out;\n}\n\nconst tweenable = (v: string | number): boolean => {\n try { parseValue(v); return true; } catch { return false; }\n};\n\n/**\n * Play frames on a target as a `Timeline` (paused unless `paused: false`).\n * Props missing from a frame hold their previous value; non-numeric values\n * (e.g. `display`, `matrix(...)`) switch discretely at the segment midpoint.\n */\nexport function framesToTimeline(target: Target, frames: Frame[], o: KeyframesPlayOptions = {}): Timeline {\n const dur = o.duration ?? 1000;\n const fs = [...frames].sort((a, b) => a.offset - b.offset).map((f) => ({ ...f, props: expandProps(f.props) }));\n const tl = new Timeline({ repeat: o.repeat, yoyo: o.yoyo, delay: o.delay, onUpdate: o.onUpdate, onComplete: o.onComplete });\n const keys = Array.from(new Set(fs.flatMap((f) => Object.keys(f.props))));\n // carry values forward / backward so every frame has every key\n const filled = fs.map((f) => ({ ...f, props: { ...f.props } }));\n for (const k of keys) {\n let last: string | number | undefined;\n for (const f of filled) { if (k in f.props) last = f.props[k]; else if (last !== undefined) f.props[k] = last; }\n let next: string | number | undefined;\n for (let i = filled.length - 1; i >= 0; i--) { if (k in filled[i].props) next = filled[i].props[k]; else if (next !== undefined) filled[i].props[k] = next; }\n }\n const def = o.ease ?? 'linear';\n if (filled.length === 1) filled.unshift({ ...filled[0], offset: 0 });\n for (let i = 0; i < filled.length - 1; i++) {\n const a = filled[i], b = filled[i + 1];\n const segDur = Math.max(0, (b.offset - a.offset) * dur);\n const from: Record<string, string | number> = {}, to: Record<string, string | number> = {};\n const discrete: [string, string | number][] = [];\n for (const k of keys) {\n if (tweenable(a.props[k]) && tweenable(b.props[k])) { from[k] = a.props[k]; to[k] = b.props[k]; }\n else discrete.push([k, b.props[k]]);\n }\n tl.add(new Tween(target, { from, to, duration: segDur, ease: a.easing ? parseEase(a.easing) : def, paused: true }), a.offset * dur);\n for (const [k, v] of discrete) tl.call(() => { if ((target as any).style) (target as HTMLElement).style.setProperty(k.replace(/[A-Z]/g, (c) => '-' + c.toLowerCase()), String(v)); else (target as any)[k] = v; }, a.offset * dur + segDur / 2);\n }\n if (o.paused === false) tl.play();\n return tl;\n}\n"],"names":[],"mappings":";;;AAAA;;;;AAIG;MAkBU,SAAS,GAAG,CAAC,CAAS,MAAc,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC,EAAE,CAAS,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;AAE1I;AACM,SAAU,iBAAiB,CAAuC,MAAW,EAAA;AACjF,IAAA,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC,CAA+B;IACvE,IAAI,CAAC,GAAG,CAAC,MAAM;AAAE,QAAA,OAAO,GAAG;AAC3B,IAAA,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,IAAI,IAAI;AAAE,QAAA,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,GAAG,CAAC,MAAM,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC;IACnE,IAAI,GAAG,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,MAAM,IAAI,IAAI;QAAE,GAAG,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC;IACtE,IAAI,CAAC,GAAG,CAAC;AACT,IAAA,OAAO,CAAC,GAAG,G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KAAK,GAAG,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;;AAAQ,gBAAA,MAAc,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,GAAG,GAAG,GAAG,MAAM,GAAG,CAAC,CAAC;IACjP;AACA,IAAA,IAAI,CAAC,CAAC,MAAM,KAAK,KAAK;QAAE,EAAE,CAAC,IAAI,EAAE;AACjC,IAAA,OAAO,EAAE;AACX;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { f as defineElement } from './base-BTev8qxg.js';
|
|
2
|
-
import { r as runtimeModule } from './runtime-link-
|
|
2
|
+
import { r as runtimeModule } from './runtime-link-CP3qaRja.js';
|
|
3
3
|
|
|
4
4
|
var css = "usa-lottie-player{display:inline-block;width:240px;max-width:100%;vertical-align:middle}usa-lottie-player>canvas{display:block;width:100%;height:auto}usa-lottie-player .usa-rt-missing{margin:0 0 8px;padding:8px;border-radius:8px;background:#fef2f2;color:#991b1b;font:11px/1.4 ui-monospace,monospace;overflow-wrap:anywhere}";
|
|
5
5
|
|
|
@@ -124,4 +124,4 @@ function defineLottiePlayer(tag = 'usa-lottie-player') {
|
|
|
124
124
|
}
|
|
125
125
|
|
|
126
126
|
export { css as c, defineLottiePlayer as d };
|
|
127
|
-
//# sourceMappingURL=lottie-player-
|
|
127
|
+
//# sourceMappingURL=lottie-player-CPdwHhqe.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lottie-player-UJHOl-8L.js","sources":["../../src/components/widgets/lottie-player.ts"],"sourcesContent":["import { defineElement, type UsaElement } from '../base';\nimport { runtimeModule } from './runtime-link';\nimport type { VectorApi, LottiePlayer, LottieAnimation } from '../../runtime/vector';\nimport css from './lottie-player.css?raw';\n\n/**\n * `<usa-lottie-player src=\"hero.lottie\" autoplay loop></usa-lottie-player>`\n * (10.6) — plays Lottie JSON and dotLottie (`.lottie`) files with\n * **`motionary/runtime/vector`** (requires `use(vector)`): Motionary's own\n * Canvas 2D renderer for the documented subset (shapes, gradients, trim\n * paths, masks, track mattes, precomps, images). `animation` (id inside a\n * dotLottie), `autoplay`, `loop` (or a count), `speed`, `mode` (normal ·\n * bounce), `segment` (\"0,30\" or a marker name), `hover` (play on hover),\n * `scrub` (progress follows the element's scroll position), `fit` (contain ·\n * cover · fill), `background`, `label`. Methods `play()`, `pause()`,\n * `stop()`, `seek(frame)`, `player`, `animationData`, `unsupported`\n * (features in the file this renderer skips); `usa:load`, `usa:complete`,\n * `usa:error`. Reduced motion: first frame, no autoplay. Renders only while\n * visible.\n */\nexport interface UsaLottiePlayerElement extends UsaElement {\n play(): void;\n pause(): void;\n stop(): void;\n seek(frame: number): void;\n readonly player: LottiePlayer | null;\n readonly animationData: LottieAnimation | null;\n readonly unsupported: string[];\n}\n\nexport function defineLottiePlayer(tag = 'usa-lottie-player'): CustomElementConstructor | undefined {\n return defineElement(\n tag,\n (Base) => {\n class UsaLottiePlayer extends Base {\n static get observedAttributes(): string[] {\n return ['src', 'animation', 'autoplay', 'loop', 'speed', 'mode', 'segment', 'hover', 'scrub', 'fit', 'background', 'label'];\n }\n private p: LottiePlayer | null = null;\n private data: LottieAnimation | null = null;\n private skipped: string[] = [];\n get player(): LottiePlayer | null {\n return this.p;\n }\n get animationData(): LottieAnimation | null {\n return this.data;\n }\n get unsupported(): string[] {\n return this.skipped.slice();\n }\n play(): void {\n this.p?.play();\n }\n pause(): void {\n this.p?.pause();\n }\n stop(): void {\n this.p?.pause();\n this.p?.seek(0);\n }\n seek(frame: number): void {\n if (!this.p || !this.data) return;\n this.p.pause();\n this.p.seek((frame / this.data.fr) * 1000);\n }\n mount(): void {\n const V = runtimeModule<VectorApi>(this, 'vector');\n if (!V) return;\n const canvas = document.createElement('canvas');\n canvas.setAttribute('role', 'img');\n canvas.setAttribute('aria-label', this.str('label', 'Animation'));\n this.querySelector(':scope > canvas')?.remove();\n this.prepend(canvas);\n this.onCleanup(() => canvas.remove());\n const src = this.str('src');\n if (!src) return;\n let alive = true;\n this.onCleanup(() => {\n alive = false;\n this.p?.kill();\n this.p = null;\n });\n V.loadLottie(new URL(src, location.href).href, { animation: this.str('animation') || undefined })\n .then(({ animation: source, images, dotLottie }) => {\n if (!alive) return;\n const animationId = this.str('animation') || dotLottie?.manifest?.activeAnimationId || dotLottie?.manifest?.animations?.[0]?.id;\n // 10.9: subclasses (<usa-dotlottie>) may theme the animation before it plays\n const animation = (this as any).prepareAnimation ? (this as any).prepareAnimation(source, dotLottie, animationId) : source;\n this.data = animation;\n this.skipped = V.inspectLottie(animation).unsupported;\n const dpr = Math.min(2, devicePixelRatio || 1);\n const w = Math.max(1, Math.round((canvas.clientWidth || animation.w) * dpr));\n canvas.width = w;\n canvas.height = Math.round((w * animation.h) / animation.w);\n const seg = this.str('segment');\n const loopAttr = this.getAttribute('loop');\n const opts = {\n images,\n autoplay: false,\n loop: loopAttr === null ? false : loopAttr === '' || loopAttr === 'true' ? true : Math.max(0, Number(loopAttr) - 1) || true,\n bounce: this.str('mode') === 'bounce',\n speed: this.num('speed', 1),\n fit: (this.str('fit', 'contain') as any) || 'contain',\n background: this.str('background') || undefined,\n segment: seg ? (/^\\d/.test(seg) ? (seg.split(/[\\s,]+/).map(Number) as [number, number]) : seg) : undefined,\n };\n const build = (a: LottieAnimation): LottiePlayer => {\n this.p?.kill();\n const np = V.lottiePlayer(canvas, a, opts);\n np.onComplete = () => {\n this.emit('complete');\n (this as any).completed?.();\n };\n this.p = np;\n this.data = a;\n return np;\n };\n const p = build(animation);\n this.emit('load', { frames: animation.op - animation.ip, fr: animation.fr, w: animation.w, h: animation.h, unsupported: this.skipped });\n if ((this as any).playerReady?.({ player: p, animation, dotLottie, canvas, rebuild: build, source, animationId })) return;\n if (this.reduced) return;\n if (this.flag('scrub')) {\n const upd = () => {\n const r = this.getBoundingClientRect();\n p.progress = Math.min(1, Math.max(0, (innerHeight - r.top) / (innerHeight + r.height)));\n };\n this.listen(window, 'scroll', upd, { passive: true });\n upd();\n } else if (this.flag('hover')) {\n this.listen(this, 'pointerenter', () => p.play());\n this.listen(this, 'pointerleave', () => p.pause());\n } else if (this.flag('autoplay')) this.inView((v) => (v ? p.play() : p.pause()));\n })\n .catch((e) => alive && this.emit('error', { error: String(e?.message || e) }));\n }\n }\n return UsaLottiePlayer as unknown as CustomElementConstructor;\n },\n { id: 'lottie-player', text: css }\n );\n}\n"],"names":[],"mappings":";;;;;AA8BM,SAAU,kBAAkB,CAAC,GAAG,GAAG,mBAAmB,EAAA;AAC1D,IAAA,OAAO,aAAa,CAClB,GAAG,EACH,CAAC,IAAI,KAAI;QACP,MAAM,eAAgB,SAAQ,IAAI,CAAA;AAAlC,YAAA,WAAA,GAAA;;gBAIU,IAAA,CAAA,CAAC,GAAwB,IAAI;gBAC7B,IAAA,CAAA,IAAI,GAA2B,IAAI;gBACnC,IAAA,CAAA,OAAO,GAAa,EAAE;YA+FhC;AApGE,YAAA,WAAW,kBAAkB,GAAA;gBAC3B,OAAO,CAAC,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,OAAO,CAAC;YAC7H;AAIA,YAAA,IAAI,MAAM,GAAA;gBACR,OAAO,IAAI,CAAC,CAAC;YACf;AACA,YAAA,IAAI,aAAa,GAAA;gBACf,OAAO,IAAI,CAAC,IAAI;YAClB;AACA,YAAA,IAAI,WAAW,GAAA;AACb,gBAAA,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE;YAC7B;YACA,IAAI,GAAA;AACF,gBAAA,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE;YAChB;YACA,KAAK,GAAA;AACH,gBAAA,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE;YACjB;YACA,IAAI,GAAA;AACF,gBAAA,IAAI,CAAC,CAAC,EAAE,KA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,CAAC,IAAI,EAAE,cAAc,EAAE,MAAM,CAAC,CAAC,KAAK,EAAE,CAAC;oBACpD;AAAO,yBAAA,IAAI,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC;wBAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC;AAClF,gBAAA,CAAC;AACA,qBAAA,KAAK,CAAC,CAAC,CAAC,KAAK,KAAK,IAAI,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,EAAE,OAAO,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC;YAClF;AACD;AACD,QAAA,OAAO,eAAsD;IAC/D,CAAC,EACD,EAAE,EAAE,EAAE,eAAe,EAAE,IAAI,EAAE,GAAG,EAAE,CACnC;AACH;;"}
|
|
1
|
+
{"version":3,"file":"lottie-player-CPdwHhqe.js","sources":["../../src/components/widgets/lottie-player.ts"],"sourcesContent":["import { defineElement, type UsaElement } from '../base';\nimport { runtimeModule } from './runtime-link';\nimport type { VectorApi, LottiePlayer, LottieAnimation } from '../../runtime/vector';\nimport css from './lottie-player.css?raw';\n\n/**\n * `<usa-lottie-player src=\"hero.lottie\" autoplay loop></usa-lottie-player>`\n * (10.6) — plays Lottie JSON and dotLottie (`.lottie`) files with\n * **`motionary/runtime/vector`** (requires `use(vector)`): Motionary's own\n * Canvas 2D renderer for the documented subset (shapes, gradients, trim\n * paths, masks, track mattes, precomps, images). `animation` (id inside a\n * dotLottie), `autoplay`, `loop` (or a count), `speed`, `mode` (normal ·\n * bounce), `segment` (\"0,30\" or a marker name), `hover` (play on hover),\n * `scrub` (progress follows the element's scroll position), `fit` (contain ·\n * cover · fill), `background`, `label`. Methods `play()`, `pause()`,\n * `stop()`, `seek(frame)`, `player`, `animationData`, `unsupported`\n * (features in the file this renderer skips); `usa:load`, `usa:complete`,\n * `usa:error`. Reduced motion: first frame, no autoplay. Renders only while\n * visible.\n */\nexport interface UsaLottiePlayerElement extends UsaElement {\n play(): void;\n pause(): void;\n stop(): void;\n seek(frame: number): void;\n readonly player: LottiePlayer | null;\n readonly animationData: LottieAnimation | null;\n readonly unsupported: string[];\n}\n\nexport function defineLottiePlayer(tag = 'usa-lottie-player'): CustomElementConstructor | undefined {\n return defineElement(\n tag,\n (Base) => {\n class UsaLottiePlayer extends Base {\n static get observedAttributes(): string[] {\n return ['src', 'animation', 'autoplay', 'loop', 'speed', 'mode', 'segment', 'hover', 'scrub', 'fit', 'background', 'label'];\n }\n private p: LottiePlayer | null = null;\n private data: LottieAnimation | null = null;\n private skipped: string[] = [];\n get player(): LottiePlayer | null {\n return this.p;\n }\n get animationData(): LottieAnimation | null {\n return this.data;\n }\n get unsupported(): string[] {\n return this.skipped.slice();\n }\n play(): void {\n this.p?.play();\n }\n pause(): void {\n this.p?.pause();\n }\n stop(): void {\n this.p?.pause();\n this.p?.seek(0);\n }\n seek(frame: number): void {\n if (!this.p || !this.data) return;\n this.p.pause();\n this.p.seek((frame / this.data.fr) * 1000);\n }\n mount(): void {\n const V = runtimeModule<VectorApi>(this, 'vector');\n if (!V) return;\n const canvas = document.createElement('canvas');\n canvas.setAttribute('role', 'img');\n canvas.setAttribute('aria-label', this.str('label', 'Animation'));\n this.querySelector(':scope > canvas')?.remove();\n this.prepend(canvas);\n this.onCleanup(() => canvas.remove());\n const src = this.str('src');\n if (!src) return;\n let alive = true;\n this.onCleanup(() => {\n alive = false;\n this.p?.kill();\n this.p = null;\n });\n V.loadLottie(new URL(src, location.href).href, { animation: this.str('animation') || undefined })\n .then(({ animation: source, images, dotLottie }) => {\n if (!alive) return;\n const animationId = this.str('animation') || dotLottie?.manifest?.activeAnimationId || dotLottie?.manifest?.animations?.[0]?.id;\n // 10.9: subclasses (<usa-dotlottie>) may theme the animation before it plays\n const animation = (this as any).prepareAnimation ? (this as any).prepareAnimation(source, dotLottie, animationId) : source;\n this.data = animation;\n this.skipped = V.inspectLottie(animation).unsupported;\n const dpr = Math.min(2, devicePixelRatio || 1);\n const w = Math.max(1, Math.round((canvas.clientWidth || animation.w) * dpr));\n canvas.width = w;\n canvas.height = Math.round((w * animation.h) / animation.w);\n const seg = this.str('segment');\n const loopAttr = this.getAttribute('loop');\n const opts = {\n images,\n autoplay: false,\n loop: loopAttr === null ? false : loopAttr === '' || loopAttr === 'true' ? true : Math.max(0, Number(loopAttr) - 1) || true,\n bounce: this.str('mode') === 'bounce',\n speed: this.num('speed', 1),\n fit: (this.str('fit', 'contain') as any) || 'contain',\n background: this.str('background') || undefined,\n segment: seg ? (/^\\d/.test(seg) ? (seg.split(/[\\s,]+/).map(Number) as [number, number]) : seg) : undefined,\n };\n const build = (a: LottieAnimation): LottiePlayer => {\n this.p?.kill();\n const np = V.lottiePlayer(canvas, a, opts);\n np.onComplete = () => {\n this.emit('complete');\n (this as any).completed?.();\n };\n this.p = np;\n this.data = a;\n return np;\n };\n const p = build(animation);\n this.emit('load', { frames: animation.op - animation.ip, fr: animation.fr, w: animation.w, h: animation.h, unsupported: this.skipped });\n if ((this as any).playerReady?.({ player: p, animation, dotLottie, canvas, rebuild: build, source, animationId })) return;\n if (this.reduced) return;\n if (this.flag('scrub')) {\n const upd = () => {\n const r = this.getBoundingClientRect();\n p.progress = Math.min(1, Math.max(0, (innerHeight - r.top) / (innerHeight + r.height)));\n };\n this.listen(window, 'scroll', upd, { passive: true });\n upd();\n } else if (this.flag('hover')) {\n this.listen(this, 'pointerenter', () => p.play());\n this.listen(this, 'pointerleave', () => p.pause());\n } else if (this.flag('autoplay')) this.inView((v) => (v ? p.play() : p.pause()));\n })\n .catch((e) => alive && this.emit('error', { error: String(e?.message || e) }));\n }\n }\n return UsaLottiePlayer as unknown as CustomElementConstructor;\n },\n { id: 'lottie-player', text: css }\n );\n}\n"],"names":[],"mappings":";;;;;AA8BM,SAAU,kBAAkB,CAAC,GAAG,GAAG,mBAAmB,EAAA;AAC1D,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AE,KAAK,EAAE,MAAM,CAAC,CAAC,EAAE,OAAO,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC;YAClF;AACD;AACD,QAAA,OAAO,eAAsD;IAC/D,CAAC,EACD,EAAE,EAAE,EAAE,eAAe,EAAE,IAAI,EAAE,GAAG,EAAE,CACnC;AACH;;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var base = require('./base-DBheNxJu.cjs');
|
|
4
|
-
var runtimeLink = require('./runtime-link-
|
|
4
|
+
var runtimeLink = require('./runtime-link-Bz3rGMsh.cjs');
|
|
5
5
|
|
|
6
6
|
var css = "usa-lottie-player{display:inline-block;width:240px;max-width:100%;vertical-align:middle}usa-lottie-player>canvas{display:block;width:100%;height:auto}usa-lottie-player .usa-rt-missing{margin:0 0 8px;padding:8px;border-radius:8px;background:#fef2f2;color:#991b1b;font:11px/1.4 ui-monospace,monospace;overflow-wrap:anywhere}";
|
|
7
7
|
|
|
@@ -127,4 +127,4 @@ function defineLottiePlayer(tag = 'usa-lottie-player') {
|
|
|
127
127
|
|
|
128
128
|
exports.css = css;
|
|
129
129
|
exports.defineLottiePlayer = defineLottiePlayer;
|
|
130
|
-
//# sourceMappingURL=lottie-player-
|
|
130
|
+
//# sourceMappingURL=lottie-player-DD1pnLN2.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lottie-player-Mcpt1H5w.cjs","sources":["../../src/components/widgets/lottie-player.ts"],"sourcesContent":["import { defineElement, type UsaElement } from '../base';\nimport { runtimeModule } from './runtime-link';\nimport type { VectorApi, LottiePlayer, LottieAnimation } from '../../runtime/vector';\nimport css from './lottie-player.css?raw';\n\n/**\n * `<usa-lottie-player src=\"hero.lottie\" autoplay loop></usa-lottie-player>`\n * (10.6) — plays Lottie JSON and dotLottie (`.lottie`) files with\n * **`motionary/runtime/vector`** (requires `use(vector)`): Motionary's own\n * Canvas 2D renderer for the documented subset (shapes, gradients, trim\n * paths, masks, track mattes, precomps, images). `animation` (id inside a\n * dotLottie), `autoplay`, `loop` (or a count), `speed`, `mode` (normal ·\n * bounce), `segment` (\"0,30\" or a marker name), `hover` (play on hover),\n * `scrub` (progress follows the element's scroll position), `fit` (contain ·\n * cover · fill), `background`, `label`. Methods `play()`, `pause()`,\n * `stop()`, `seek(frame)`, `player`, `animationData`, `unsupported`\n * (features in the file this renderer skips); `usa:load`, `usa:complete`,\n * `usa:error`. Reduced motion: first frame, no autoplay. Renders only while\n * visible.\n */\nexport interface UsaLottiePlayerElement extends UsaElement {\n play(): void;\n pause(): void;\n stop(): void;\n seek(frame: number): void;\n readonly player: LottiePlayer | null;\n readonly animationData: LottieAnimation | null;\n readonly unsupported: string[];\n}\n\nexport function defineLottiePlayer(tag = 'usa-lottie-player'): CustomElementConstructor | undefined {\n return defineElement(\n tag,\n (Base) => {\n class UsaLottiePlayer extends Base {\n static get observedAttributes(): string[] {\n return ['src', 'animation', 'autoplay', 'loop', 'speed', 'mode', 'segment', 'hover', 'scrub', 'fit', 'background', 'label'];\n }\n private p: LottiePlayer | null = null;\n private data: LottieAnimation | null = null;\n private skipped: string[] = [];\n get player(): LottiePlayer | null {\n return this.p;\n }\n get animationData(): LottieAnimation | null {\n return this.data;\n }\n get unsupported(): string[] {\n return this.skipped.slice();\n }\n play(): void {\n this.p?.play();\n }\n pause(): void {\n this.p?.pause();\n }\n stop(): void {\n this.p?.pause();\n this.p?.seek(0);\n }\n seek(frame: number): void {\n if (!this.p || !this.data) return;\n this.p.pause();\n this.p.seek((frame / this.data.fr) * 1000);\n }\n mount(): void {\n const V = runtimeModule<VectorApi>(this, 'vector');\n if (!V) return;\n const canvas = document.createElement('canvas');\n canvas.setAttribute('role', 'img');\n canvas.setAttribute('aria-label', this.str('label', 'Animation'));\n this.querySelector(':scope > canvas')?.remove();\n this.prepend(canvas);\n this.onCleanup(() => canvas.remove());\n const src = this.str('src');\n if (!src) return;\n let alive = true;\n this.onCleanup(() => {\n alive = false;\n this.p?.kill();\n this.p = null;\n });\n V.loadLottie(new URL(src, location.href).href, { animation: this.str('animation') || undefined })\n .then(({ animation: source, images, dotLottie }) => {\n if (!alive) return;\n const animationId = this.str('animation') || dotLottie?.manifest?.activeAnimationId || dotLottie?.manifest?.animations?.[0]?.id;\n // 10.9: subclasses (<usa-dotlottie>) may theme the animation before it plays\n const animation = (this as any).prepareAnimation ? (this as any).prepareAnimation(source, dotLottie, animationId) : source;\n this.data = animation;\n this.skipped = V.inspectLottie(animation).unsupported;\n const dpr = Math.min(2, devicePixelRatio || 1);\n const w = Math.max(1, Math.round((canvas.clientWidth || animation.w) * dpr));\n canvas.width = w;\n canvas.height = Math.round((w * animation.h) / animation.w);\n const seg = this.str('segment');\n const loopAttr = this.getAttribute('loop');\n const opts = {\n images,\n autoplay: false,\n loop: loopAttr === null ? false : loopAttr === '' || loopAttr === 'true' ? true : Math.max(0, Number(loopAttr) - 1) || true,\n bounce: this.str('mode') === 'bounce',\n speed: this.num('speed', 1),\n fit: (this.str('fit', 'contain') as any) || 'contain',\n background: this.str('background') || undefined,\n segment: seg ? (/^\\d/.test(seg) ? (seg.split(/[\\s,]+/).map(Number) as [number, number]) : seg) : undefined,\n };\n const build = (a: LottieAnimation): LottiePlayer => {\n this.p?.kill();\n const np = V.lottiePlayer(canvas, a, opts);\n np.onComplete = () => {\n this.emit('complete');\n (this as any).completed?.();\n };\n this.p = np;\n this.data = a;\n return np;\n };\n const p = build(animation);\n this.emit('load', { frames: animation.op - animation.ip, fr: animation.fr, w: animation.w, h: animation.h, unsupported: this.skipped });\n if ((this as any).playerReady?.({ player: p, animation, dotLottie, canvas, rebuild: build, source, animationId })) return;\n if (this.reduced) return;\n if (this.flag('scrub')) {\n const upd = () => {\n const r = this.getBoundingClientRect();\n p.progress = Math.min(1, Math.max(0, (innerHeight - r.top) / (innerHeight + r.height)));\n };\n this.listen(window, 'scroll', upd, { passive: true });\n upd();\n } else if (this.flag('hover')) {\n this.listen(this, 'pointerenter', () => p.play());\n this.listen(this, 'pointerleave', () => p.pause());\n } else if (this.flag('autoplay')) this.inView((v) => (v ? p.play() : p.pause()));\n })\n .catch((e) => alive && this.emit('error', { error: String(e?.message || e) }));\n }\n }\n return UsaLottiePlayer as unknown as CustomElementConstructor;\n },\n { id: 'lottie-player', text: css }\n );\n}\n"],"names":["defineElement","runtimeModule"],"mappings":";;;;;;;AA8BM,SAAU,kBAAkB,CAAC,GAAG,GAAG,mBAAmB,EAAA;AAC1D,IAAA,OAAOA,kBAAa,CAClB,GAAG,EACH,CAAC,IAAI,KAAI;QACP,MAAM,eAAgB,SAAQ,IAAI,CAAA;AAAlC,YAAA,WAAA,GAAA;;gBAIU,IAAA,CAAA,CAAC,GAAwB,IAAI;gBAC7B,IAAA,CAAA,IAAI,GAA2B,IAAI;gBACnC,IAAA,CAAA,OAAO,GAAa,EAAE;YA+FhC;AApGE,YAAA,WAAW,kBAAkB,GAAA;gBAC3B,OAAO,CAAC,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,OAAO,CAAC;YAC7H;AAIA,YAAA,IAAI,MAAM,GAAA;gBACR,OAAO,IAAI,CAAC,CAAC;YACf;AACA,YAAA,IAAI,aAAa,GAAA;gBACf,OAAO,IAAI,CAAC,IAAI;YAClB;AACA,YAAA,IAAI,WAAW,GAAA;AACb,gBAAA,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE;YAC7B;YACA,IAAI,GAAA;AACF,gBAAA,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE;YAChB;YACA,KAAK,GAAA;AACH,gBAAA,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE;YACjB;YACA,IAAI,GAAA;AACF,gBAAA,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE;AACf,gBAAA,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CA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AC;oBACpD;AAAO,yBAAA,IAAI,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC;wBAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC;AAClF,gBAAA,CAAC;AACA,qBAAA,KAAK,CAAC,CAAC,CAAC,KAAK,KAAK,IAAI,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,EAAE,OAAO,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC;YAClF;AACD;AACD,QAAA,OAAO,eAAsD;IAC/D,CAAC,EACD,EAAE,EAAE,EAAE,eAAe,EAAE,IAAI,EAAE,GAAG,EAAE,CACnC;AACH;;;"}
|
|
1
|
+
{"version":3,"file":"lottie-player-DD1pnLN2.cjs","sources":["../../src/components/widgets/lottie-player.ts"],"sourcesContent":["import { defineElement, type UsaElement } from '../base';\nimport { runtimeModule } from './runtime-link';\nimport type { VectorApi, LottiePlayer, LottieAnimation } from '../../runtime/vector';\nimport css from './lottie-player.css?raw';\n\n/**\n * `<usa-lottie-player src=\"hero.lottie\" autoplay loop></usa-lottie-player>`\n * (10.6) — plays Lottie JSON and dotLottie (`.lottie`) files with\n * **`motionary/runtime/vector`** (requires `use(vector)`): Motionary's own\n * Canvas 2D renderer for the documented subset (shapes, gradients, trim\n * paths, masks, track mattes, precomps, images). `animation` (id inside a\n * dotLottie), `autoplay`, `loop` (or a count), `speed`, `mode` (normal ·\n * bounce), `segment` (\"0,30\" or a marker name), `hover` (play on hover),\n * `scrub` (progress follows the element's scroll position), `fit` (contain ·\n * cover · fill), `background`, `label`. Methods `play()`, `pause()`,\n * `stop()`, `seek(frame)`, `player`, `animationData`, `unsupported`\n * (features in the file this renderer skips); `usa:load`, `usa:complete`,\n * `usa:error`. Reduced motion: first frame, no autoplay. Renders only while\n * visible.\n */\nexport interface UsaLottiePlayerElement extends UsaElement {\n play(): void;\n pause(): void;\n stop(): void;\n seek(frame: number): void;\n readonly player: LottiePlayer | null;\n readonly animationData: LottieAnimation | null;\n readonly unsupported: string[];\n}\n\nexport function defineLottiePlayer(tag = 'usa-lottie-player'): CustomElementConstructor | undefined {\n return defineElement(\n tag,\n (Base) => {\n class UsaLottiePlayer extends Base {\n static get observedAttributes(): string[] {\n return ['src', 'animation', 'autoplay', 'loop', 'speed', 'mode', 'segment', 'hover', 'scrub', 'fit', 'background', 'label'];\n }\n private p: LottiePlayer | null = null;\n private data: LottieAnimation | null = null;\n private skipped: string[] = [];\n get player(): LottiePlayer | null {\n return this.p;\n }\n get animationData(): LottieAnimation | null {\n return this.data;\n }\n get unsupported(): string[] {\n return this.skipped.slice();\n }\n play(): void {\n this.p?.play();\n }\n pause(): void {\n this.p?.pause();\n }\n stop(): void {\n this.p?.pause();\n this.p?.seek(0);\n }\n seek(frame: number): void {\n if (!this.p || !this.data) return;\n this.p.pause();\n this.p.seek((frame / this.data.fr) * 1000);\n }\n mount(): void {\n const V = runtimeModule<VectorApi>(this, 'vector');\n if (!V) return;\n const canvas = document.createElement('canvas');\n canvas.setAttribute('role', 'img');\n canvas.setAttribute('aria-label', this.str('label', 'Animation'));\n this.querySelector(':scope > canvas')?.remove();\n this.prepend(canvas);\n this.onCleanup(() => canvas.remove());\n const src = this.str('src');\n if (!src) return;\n let alive = true;\n this.onCleanup(() => {\n alive = false;\n this.p?.kill();\n this.p = null;\n });\n V.loadLottie(new URL(src, location.href).href, { animation: this.str('animation') || undefined })\n .then(({ animation: source, images, dotLottie }) => {\n if (!alive) return;\n const animationId = this.str('animation') || dotLottie?.manifest?.activeAnimationId || dotLottie?.manifest?.animations?.[0]?.id;\n // 10.9: subclasses (<usa-dotlottie>) may theme the animation before it plays\n const animation = (this as any).prepareAnimation ? (this as any).prepareAnimation(source, dotLottie, animationId) : source;\n this.data = animation;\n this.skipped = V.inspectLottie(animation).unsupported;\n const dpr = Math.min(2, devicePixelRatio || 1);\n const w = Math.max(1, Math.round((canvas.clientWidth || animation.w) * dpr));\n canvas.width = w;\n canvas.height = Math.round((w * animation.h) / animation.w);\n const seg = this.str('segment');\n const loopAttr = this.getAttribute('loop');\n const opts = {\n images,\n autoplay: false,\n loop: loopAttr === null ? false : loopAttr === '' || loopAttr === 'true' ? true : Math.max(0, Number(loopAttr) - 1) || true,\n bounce: this.str('mode') === 'bounce',\n speed: this.num('speed', 1),\n fit: (this.str('fit', 'contain') as any) || 'contain',\n background: this.str('background') || undefined,\n segment: seg ? (/^\\d/.test(seg) ? (seg.split(/[\\s,]+/).map(Number) as [number, number]) : seg) : undefined,\n };\n const build = (a: LottieAnimation): LottiePlayer => {\n this.p?.kill();\n const np = V.lottiePlayer(canvas, a, opts);\n np.onComplete = () => {\n this.emit('complete');\n (this as any).completed?.();\n };\n this.p = np;\n this.data = a;\n return np;\n };\n const p = build(animation);\n this.emit('load', { frames: animation.op - animation.ip, fr: animation.fr, w: animation.w, h: animation.h, unsupported: this.skipped });\n if ((this as any).playerReady?.({ player: p, animation, dotLottie, canvas, rebuild: build, source, animationId })) return;\n if (this.reduced) return;\n if (this.flag('scrub')) {\n const upd = () => {\n const r = this.getBoundingClientRect();\n p.progress = Math.min(1, Math.max(0, (innerHeight - r.top) / (innerHeight + r.height)));\n };\n this.listen(window, 'scroll', upd, { passive: true });\n upd();\n } else if (this.flag('hover')) {\n this.listen(this, 'pointerenter', () => p.play());\n this.listen(this, 'pointerleave', () => p.pause());\n } else if (this.flag('autoplay')) this.inView((v) => (v ? p.play() : p.pause()));\n })\n .catch((e) => alive && this.emit('error', { error: String(e?.message || e) }));\n }\n }\n return UsaLottiePlayer as unknown as CustomElementConstructor;\n },\n { id: 'lottie-player', text: css }\n );\n}\n"],"names":["defineElement","runtimeModule"],"mappings":";;;;;;;AA8BM,SAAU,kBAAkB,CAAC,GAAG,GAAG,mBAAmB,EAAA;AAC1D,IAAA,OAAOA,kBAAa,CAClB,GAAG,EACH,CAAC,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,OAAO,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC;YAClF;AACD;AACD,QAAA,OAAO,eAAsD;IAC/D,CAAC,EACD,EAAE,EAAE,EAAE,eAAe,EAAE,IAAI,EAAE,GAAG,EAAE,CACnC;AACH;;;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var base = require('./base-DBheNxJu.cjs');
|
|
4
|
-
var runtimeLink = require('./runtime-link-
|
|
4
|
+
var runtimeLink = require('./runtime-link-Bz3rGMsh.cjs');
|
|
5
5
|
|
|
6
6
|
var css = "usa-physics-playground{position:relative;display:block;aspect-ratio:5/3;min-height:140px;background:radial-gradient(circle at 50% 0,#1e293b,#0f172a);border-radius:12px;overflow:hidden;touch-action:none}usa-physics-playground>canvas{display:block;width:100%;height:100%;cursor:grab;outline:none}usa-physics-playground>canvas:active{cursor:grabbing}usa-physics-playground>canvas:focus-visible{box-shadow:inset 0 0 0 2px #818cf8}usa-physics-playground>script{display:none}";
|
|
7
7
|
|
|
@@ -275,4 +275,4 @@ function definePhysicsPlayground(tag = 'usa-physics-playground') {
|
|
|
275
275
|
|
|
276
276
|
exports.PHYSICS_PRESETS = PHYSICS_PRESETS;
|
|
277
277
|
exports.definePhysicsPlayground = definePhysicsPlayground;
|
|
278
|
-
//# sourceMappingURL=physics-playground-
|
|
278
|
+
//# sourceMappingURL=physics-playground-B00t13Nz.cjs.map
|