motionary 10.1.0 → 10.3.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 +61 -0
- package/CHANGELOG.md +36 -0
- package/README.md +69 -0
- package/dist/chunks/{keyframes-CyH_abhI.js → keyframes-DVAC5sQI.js} +2 -2
- package/dist/chunks/{keyframes-CyH_abhI.js.map → keyframes-DVAC5sQI.js.map} +1 -1
- package/dist/chunks/{keyframes-cUdsXSXQ.cjs → keyframes-Dw9zwVQa.cjs} +2 -2
- package/dist/chunks/{keyframes-cUdsXSXQ.cjs.map → keyframes-Dw9zwVQa.cjs.map} +1 -1
- package/dist/chunks/{registry-jF8VIA_9.js → registry-46AAzyeC.js} +2 -2
- package/dist/chunks/{registry-jF8VIA_9.js.map → registry-46AAzyeC.js.map} +1 -1
- package/dist/chunks/{registry-C0xLNq3-.cjs → registry-CSVil2qJ.cjs} +2 -2
- package/dist/chunks/{registry-C0xLNq3-.cjs.map → registry-CSVil2qJ.cjs.map} +1 -1
- package/dist/chunks/ticker-COOYAyQy.js +70 -0
- package/dist/chunks/ticker-COOYAyQy.js.map +1 -0
- package/dist/chunks/ticker-gHv6pNfx.cjs +72 -0
- package/dist/chunks/ticker-gHv6pNfx.cjs.map +1 -0
- package/dist/chunks/{tween-JEthWrjo.cjs → tween-CFN0WcOb.cjs} +16 -73
- package/dist/chunks/tween-CFN0WcOb.cjs.map +1 -0
- package/dist/chunks/{tween-DDObu9iA.js → tween-CGyolmzB.js} +16 -72
- package/dist/chunks/tween-CGyolmzB.js.map +1 -0
- package/dist/components/core.cjs +106 -0
- package/dist/components/core.cjs.map +1 -1
- package/dist/components/core.d.cts +44 -2
- package/dist/components/core.d.ts +44 -2
- package/dist/components/core.js +105 -1
- package/dist/components/core.js.map +1 -1
- package/dist/components/widgets.cjs +602 -198
- package/dist/components/widgets.cjs.map +1 -1
- package/dist/components/widgets.d.cts +186 -2
- package/dist/components/widgets.d.ts +186 -2
- package/dist/components/widgets.js +598 -199
- package/dist/components/widgets.js.map +1 -1
- package/dist/llms-full.txt +194 -1
- package/dist/llms.txt +10 -2
- package/dist/manifest.json +492 -1
- package/dist/runtime/format-css.cjs +4 -3
- package/dist/runtime/format-css.cjs.map +1 -1
- package/dist/runtime/format-css.js +4 -3
- package/dist/runtime/format-css.js.map +1 -1
- package/dist/runtime/format-motion.cjs +4 -3
- package/dist/runtime/format-motion.cjs.map +1 -1
- package/dist/runtime/format-motion.js +4 -3
- package/dist/runtime/format-motion.js.map +1 -1
- package/dist/runtime/format-sprite.cjs +225 -0
- package/dist/runtime/format-sprite.cjs.map +1 -0
- package/dist/runtime/format-sprite.d.cts +224 -0
- package/dist/runtime/format-sprite.d.ts +224 -0
- package/dist/runtime/format-sprite.iife.js +2 -0
- package/dist/runtime/format-sprite.iife.js.map +1 -0
- package/dist/runtime/format-sprite.js +215 -0
- package/dist/runtime/format-sprite.js.map +1 -0
- package/dist/runtime/format-svg.cjs +457 -0
- package/dist/runtime/format-svg.cjs.map +1 -0
- package/dist/runtime/format-svg.d.cts +214 -0
- package/dist/runtime/format-svg.d.ts +214 -0
- package/dist/runtime/format-svg.iife.js +2 -0
- package/dist/runtime/format-svg.iife.js.map +1 -0
- package/dist/runtime/format-svg.js +446 -0
- package/dist/runtime/format-svg.js.map +1 -0
- package/dist/runtime/scroll.cjs +301 -0
- package/dist/runtime/scroll.cjs.map +1 -0
- package/dist/runtime/scroll.d.cts +236 -0
- package/dist/runtime/scroll.d.ts +236 -0
- package/dist/runtime/scroll.iife.js +2 -0
- package/dist/runtime/scroll.iife.js.map +1 -0
- package/dist/runtime/scroll.js +292 -0
- package/dist/runtime/scroll.js.map +1 -0
- package/dist/runtime/text.cjs +147 -0
- package/dist/runtime/text.cjs.map +1 -0
- package/dist/runtime/text.d.cts +65 -0
- package/dist/runtime/text.d.ts +65 -0
- package/dist/runtime/text.iife.js +2 -0
- package/dist/runtime/text.iife.js.map +1 -0
- package/dist/runtime/text.js +143 -0
- package/dist/runtime/text.js.map +1 -0
- package/dist/runtime.cjs +5 -4
- package/dist/runtime.cjs.map +1 -1
- package/dist/runtime.d.cts +9 -2
- package/dist/runtime.d.ts +9 -2
- package/dist/runtime.iife.js +1 -1
- package/dist/runtime.iife.js.map +1 -1
- package/dist/runtime.js +5 -4
- package/dist/runtime.js.map +1 -1
- package/dist/widgets.umd.js +1 -1
- package/dist/widgets.umd.js.map +1 -1
- package/docs/ROADMAP.md +2 -2
- package/docs/ai-prompt-guide.md +54 -0
- package/docs/components/README.md +255 -0
- package/docs/components/usa-accordion.md +38 -0
- package/docs/components/usa-acrylic.md +38 -0
- package/docs/components/usa-add-to-cart.md +40 -0
- package/docs/components/usa-ambient.md +32 -0
- package/docs/components/usa-anim-icon.md +34 -0
- package/docs/components/usa-audio.md +38 -0
- package/docs/components/usa-aurora.md +36 -0
- package/docs/components/usa-auto-animate.md +44 -0
- package/docs/components/usa-auto-skeleton.md +38 -0
- package/docs/components/usa-avatar-stack.md +38 -0
- package/docs/components/usa-back-to-top.md +32 -0
- package/docs/components/usa-badge-wall.md +39 -0
- package/docs/components/usa-badge.md +36 -0
- package/docs/components/usa-bar-chart.md +33 -0
- package/docs/components/usa-bg-generator.md +32 -0
- package/docs/components/usa-blobs.md +32 -0
- package/docs/components/usa-bottom-sheet.md +32 -0
- package/docs/components/usa-button.md +78 -0
- package/docs/components/usa-card-stack.md +40 -0
- package/docs/components/usa-card.md +94 -0
- package/docs/components/usa-carousel-3d.md +40 -0
- package/docs/components/usa-carousel.md +40 -0
- package/docs/components/usa-cart-drawer.md +33 -0
- package/docs/components/usa-chapter-nav.md +40 -0
- package/docs/components/usa-chat-composer.md +33 -0
- package/docs/components/usa-check.md +32 -0
- package/docs/components/usa-checkbox.md +32 -0
- package/docs/components/usa-click.md +36 -0
- package/docs/components/usa-clock-control.md +37 -0
- package/docs/components/usa-code-export.md +36 -0
- package/docs/components/usa-color-picker.md +32 -0
- package/docs/components/usa-command-palette.md +39 -0
- package/docs/components/usa-compare.md +38 -0
- package/docs/components/usa-countdown.md +32 -0
- package/docs/components/usa-counter.md +32 -0
- package/docs/components/usa-cube-gallery.md +40 -0
- package/docs/components/usa-cube.md +36 -0
- package/docs/components/usa-cursor.md +32 -0
- package/docs/components/usa-date-picker.md +32 -0
- package/docs/components/usa-depth.md +44 -0
- package/docs/components/usa-dialog.md +40 -0
- package/docs/components/usa-disclosure.md +38 -0
- package/docs/components/usa-distort.md +36 -0
- package/docs/components/usa-dock.md +40 -0
- package/docs/components/usa-dot-network.md +32 -0
- package/docs/components/usa-double-tap.md +36 -0
- package/docs/components/usa-draggable.md +38 -0
- package/docs/components/usa-draw.md +36 -0
- package/docs/components/usa-drawer.md +34 -0
- package/docs/components/usa-equalizer.md +33 -0
- package/docs/components/usa-fab.md +40 -0
- package/docs/components/usa-festival-banner.md +32 -0
- package/docs/components/usa-field.md +34 -0
- package/docs/components/usa-file-drop.md +35 -0
- package/docs/components/usa-fullpage.md +38 -0
- package/docs/components/usa-fx.md +851 -0
- package/docs/components/usa-gauge.md +32 -0
- package/docs/components/usa-gen-art.md +32 -0
- package/docs/components/usa-gesture-fx.md +36 -0
- package/docs/components/usa-gesture-sticker.md +36 -0
- package/docs/components/usa-glitch.md +32 -0
- package/docs/components/usa-globe.md +33 -0
- package/docs/components/usa-gradient-text.md +32 -0
- package/docs/components/usa-grain.md +36 -0
- package/docs/components/usa-grid-glow.md +36 -0
- package/docs/components/usa-gyro-card.md +38 -0
- package/docs/components/usa-handwriting.md +32 -0
- package/docs/components/usa-hero-video.md +38 -0
- package/docs/components/usa-hold.md +32 -0
- package/docs/components/usa-hud-panel.md +38 -0
- package/docs/components/usa-hydrate.md +42 -0
- package/docs/components/usa-icon-morph.md +34 -0
- package/docs/components/usa-install-button.md +32 -0
- package/docs/components/usa-kanban.md +46 -0
- package/docs/components/usa-keyframe-editor.md +37 -0
- package/docs/components/usa-kpi.md +32 -0
- package/docs/components/usa-leaderboard.md +41 -0
- package/docs/components/usa-like.md +32 -0
- package/docs/components/usa-liquid-nav.md +36 -0
- package/docs/components/usa-liquid.md +36 -0
- package/docs/components/usa-loading-bar.md +35 -0
- package/docs/components/usa-location-card.md +34 -0
- package/docs/components/usa-lottie-icon.md +34 -0
- package/docs/components/usa-lottie.md +32 -0
- package/docs/components/usa-lyrics.md +38 -0
- package/docs/components/usa-magnetic.md +32 -0
- package/docs/components/usa-marquee.md +38 -0
- package/docs/components/usa-mask-reveal.md +36 -0
- package/docs/components/usa-masonry-flow.md +42 -0
- package/docs/components/usa-masonry.md +38 -0
- package/docs/components/usa-menu-toggle.md +34 -0
- package/docs/components/usa-menu.md +44 -0
- package/docs/components/usa-message-list.md +39 -0
- package/docs/components/usa-milestones.md +40 -0
- package/docs/components/usa-modal.md +42 -0
- package/docs/components/usa-morph.md +34 -0
- package/docs/components/usa-motion-inspector.md +32 -0
- package/docs/components/usa-motion-prefs.md +32 -0
- package/docs/components/usa-motion-spec.md +32 -0
- package/docs/components/usa-motion-switch.md +34 -0
- package/docs/components/usa-motion-theme.md +40 -0
- package/docs/components/usa-motion.md +42 -0
- package/docs/components/usa-music-player.md +36 -0
- package/docs/components/usa-native-preview.md +36 -0
- package/docs/components/usa-nav-morph.md +40 -0
- package/docs/components/usa-navbar.md +36 -0
- package/docs/components/usa-notification-bell.md +37 -0
- package/docs/components/usa-odometer.md +34 -0
- package/docs/components/usa-organic-card.md +36 -0
- package/docs/components/usa-otp.md +33 -0
- package/docs/components/usa-overscroll.md +36 -0
- package/docs/components/usa-pack.md +111 -0
- package/docs/components/usa-pagination.md +32 -0
- package/docs/components/usa-panorama.md +32 -0
- package/docs/components/usa-particles.md +32 -0
- package/docs/components/usa-pause-all.md +32 -0
- package/docs/components/usa-perf-monitor.md +32 -0
- package/docs/components/usa-pinch-zoom.md +36 -0
- package/docs/components/usa-player.md +38 -0
- package/docs/components/usa-plugin-card.md +61 -0
- package/docs/components/usa-plugin-store.md +36 -0
- package/docs/components/usa-popover.md +38 -0
- package/docs/components/usa-post-fx.md +36 -0
- package/docs/components/usa-presence.md +36 -0
- package/docs/components/usa-press.md +32 -0
- package/docs/components/usa-prize-wheel.md +32 -0
- package/docs/components/usa-product-gallery.md +40 -0
- package/docs/components/usa-progress-ring.md +38 -0
- package/docs/components/usa-progress.md +34 -0
- package/docs/components/usa-prop-panel.md +34 -0
- package/docs/components/usa-pull-cord.md +32 -0
- package/docs/components/usa-pull-refresh.md +37 -0
- package/docs/components/usa-radar.md +32 -0
- package/docs/components/usa-reactions.md +32 -0
- package/docs/components/usa-red-envelope.md +32 -0
- package/docs/components/usa-retro-button.md +34 -0
- package/docs/components/usa-reveal.md +36 -0
- package/docs/components/usa-ripple.md +32 -0
- package/docs/components/usa-route-transition.md +38 -0
- package/docs/components/usa-scene.md +38 -0
- package/docs/components/usa-scramble.md +32 -0
- package/docs/components/usa-scroll-highlight.md +34 -0
- package/docs/components/usa-scroll-progress.md +36 -0
- package/docs/components/usa-scroll-scene.md +66 -0
- package/docs/components/usa-scrolly.md +40 -0
- package/docs/components/usa-segmented.md +40 -0
- package/docs/components/usa-shader.md +74 -0
- package/docs/components/usa-sheet.md +42 -0
- package/docs/components/usa-shimmer-text.md +32 -0
- package/docs/components/usa-shortcut.md +34 -0
- package/docs/components/usa-skeleton-reveal.md +42 -0
- package/docs/components/usa-skeleton.md +36 -0
- package/docs/components/usa-sketch-chart.md +32 -0
- package/docs/components/usa-slider.md +32 -0
- package/docs/components/usa-sparkline.md +32 -0
- package/docs/components/usa-spatial-card.md +40 -0
- package/docs/components/usa-spinner.md +34 -0
- package/docs/components/usa-splash.md +36 -0
- package/docs/components/usa-split-text.md +32 -0
- package/docs/components/usa-spotlight.md +40 -0
- package/docs/components/usa-spring.md +42 -0
- package/docs/components/usa-stagger.md +40 -0
- package/docs/components/usa-star-rating.md +34 -0
- package/docs/components/usa-stepper.md +42 -0
- package/docs/components/usa-sticky-stack.md +40 -0
- package/docs/components/usa-sticky-wall.md +40 -0
- package/docs/components/usa-stories.md +38 -0
- package/docs/components/usa-story.md +80 -0
- package/docs/components/usa-suggestion-chips.md +32 -0
- package/docs/components/usa-swipe-deck.md +40 -0
- package/docs/components/usa-swipeable.md +36 -0
- package/docs/components/usa-switch.md +32 -0
- package/docs/components/usa-tab-bar.md +46 -0
- package/docs/components/usa-tabs.md +40 -0
- package/docs/components/usa-terminal.md +38 -0
- package/docs/components/usa-text-rotate.md +32 -0
- package/docs/components/usa-text-splitter.md +60 -0
- package/docs/components/usa-theme-surface.md +36 -0
- package/docs/components/usa-theme-switcher.md +32 -0
- package/docs/components/usa-tilt.md +36 -0
- package/docs/components/usa-timeline.md +40 -0
- package/docs/components/usa-tip.md +44 -0
- package/docs/components/usa-toast-stack.md +36 -0
- package/docs/components/usa-toaster.md +36 -0
- package/docs/components/usa-typewriter.md +32 -0
- package/docs/components/usa-upload-progress.md +33 -0
- package/docs/components/usa-video-card.md +40 -0
- package/docs/components/usa-view-switch.md +38 -0
- package/docs/components/usa-voice-button.md +33 -0
- package/docs/components/usa-volume-knob.md +32 -0
- package/docs/components/usa-water-ripple.md +36 -0
- package/docs/components/usa-wave-text.md +32 -0
- package/docs/components/usa-weather-card.md +32 -0
- package/docs/components/usa-worker-canvas.md +32 -0
- package/docs/components/usa-xp-bar.md +33 -0
- package/docs/components.md +95 -0
- package/docs/runtime/format-sprite.md +60 -0
- package/docs/runtime/format-svg.md +62 -0
- package/docs/runtime/scroll.md +61 -0
- package/docs/runtime/text.md +59 -0
- package/package.json +45 -3
- package/dist/chunks/tween-DDObu9iA.js.map +0 -1
- package/dist/chunks/tween-JEthWrjo.cjs.map +0 -1
package/AGENTS.md
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# AGENTS.md — using Motionary from an AI assistant
|
|
2
|
+
|
|
3
|
+
This file tells AI coding agents (and the people prompting them) how to pick and use Motionary components correctly. It applies to code that *uses* Motionary; contributors should also read [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
4
|
+
|
|
5
|
+
## Sources of truth (read these, do not guess)
|
|
6
|
+
|
|
7
|
+
| What | Where |
|
|
8
|
+
|---|---|
|
|
9
|
+
| Every component: tag, attributes, events, slots, methods, import path, define function, CDN URL, minimal example, prerequisites | `motionary/manifest.json` in the npm package · `https://harrisoncn.github.io/Motionary/components.json` (JSON Schema: `components.schema.json`) |
|
|
10
|
+
| Short index for LLMs | `https://harrisoncn.github.io/Motionary/llms.txt` |
|
|
11
|
+
| Full reference in one file | `https://harrisoncn.github.io/Motionary/llms-full.txt` |
|
|
12
|
+
| One Markdown page per component | [`docs/components/<tag>.md`](docs/components/README.md) |
|
|
13
|
+
| Runtime modules (`motionary/runtime/*`) and their compatibility tables | [`docs/runtime/`](docs/runtime/) |
|
|
14
|
+
| Prompting tips and common mistakes | [`docs/ai-prompt-guide.md`](docs/ai-prompt-guide.md) |
|
|
15
|
+
|
|
16
|
+
All of these are generated from the source at build time, so they match the installed version. If a tag or attribute is not in the manifest, it does not exist — do not invent it.
|
|
17
|
+
|
|
18
|
+
## Rules
|
|
19
|
+
|
|
20
|
+
1. **Install once:** `npm i motionary` (the old name `use-scroll-animate` is a compatibility alias). No other packages are needed except the few components whose manifest entry lists an official third-party runtime under `requires` (e.g. `<usa-rive>` from 10.6 needs `@rive-app/canvas`).
|
|
21
|
+
2. **Register before use.** Each component has a define function: `import { defineX } from '<import.path>'; defineX();` — or load the CDN bundle (`components.umd.js`, plus `widgets.umd.js` for 6.x+ widgets), which registers everything.
|
|
22
|
+
3. **Prerequisites first.** If a component's `requires` is non-empty, register those modules *before* the component mounts:
|
|
23
|
+
```js
|
|
24
|
+
import { use } from 'motionary/runtime';
|
|
25
|
+
import { scroll } from 'motionary/runtime/scroll';
|
|
26
|
+
use(scroll); // also registers the runtime core
|
|
27
|
+
import { defineScrollScene } from 'motionary/components/widgets';
|
|
28
|
+
defineScrollScene();
|
|
29
|
+
```
|
|
30
|
+
On a plain HTML page load `runtime.iife.js` first, then each `runtime/<module>.iife.js`, then the component bundles. A missing module shows a visible error that names the exact install / import / CDN fix.
|
|
31
|
+
4. **Use only documented attributes, events (`usa:*`) and methods.** Attribute values are strings; boolean attributes are present/absent.
|
|
32
|
+
5. **Accessibility is built in.** Every component honours `prefers-reduced-motion`; do not add your own motion overrides unless asked. Keep real text in the light DOM (components split / animate it accessibly).
|
|
33
|
+
6. **Frameworks:** Web Components work everywhere. React: `motionary/components/react` (`createUsaComponents`); Vue: mark `usa-*` as custom elements; Svelte / Solid / Angular helpers live in `motionary/components/<framework>`.
|
|
34
|
+
7. **SSR:** importing any entry is safe on the server (nothing touches `window` at import); call define functions / `use()` on the client.
|
|
35
|
+
8. **Prefer the smallest import:** a single category (`motionary/components/cards`), a single runtime module, or `motionary/core` for presets only.
|
|
36
|
+
|
|
37
|
+
## Minimal templates
|
|
38
|
+
|
|
39
|
+
Plain HTML:
|
|
40
|
+
|
|
41
|
+
```html
|
|
42
|
+
<script src="https://unpkg.com/motionary@10/dist/components.umd.js"></script>
|
|
43
|
+
<usa-reveal effect="fade-up"><h2>Hello</h2></usa-reveal>
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Bundler:
|
|
47
|
+
|
|
48
|
+
```js
|
|
49
|
+
import { defineReveal } from 'motionary/components/reveal';
|
|
50
|
+
defineReveal();
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Declarative motion without components (10.2):
|
|
54
|
+
|
|
55
|
+
```html
|
|
56
|
+
<ul data-motion="enter: fade-up 500ms stagger 80ms"><li>One</li><li>Two</li></ul>
|
|
57
|
+
<script type="module">
|
|
58
|
+
import { createMotion, applyMotionAttributes } from 'motionary/core';
|
|
59
|
+
applyMotionAttributes(createMotion());
|
|
60
|
+
</script>
|
|
61
|
+
```
|
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,42 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [10.3.0] - 2026-10-09
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
- **View Transitions 2.0** — `<usa-route-transition>`: a route container that swaps its content on same-origin link clicks (fetched pages, using the element that matches `selector` / its id) or inline `<template data-route>` routes; animated with the View Transitions API when available (`engine="auto"`) or the Web Animations fallback (`engine="waapi"`, effects `fade` / `slide` / `zoom`); `data-shared="name"` elements morph between routes (`view-transition-name`); `cross-document` opts the site into native cross-document (MPA) view transitions (`@view-transition { navigation: auto }`); history push / replace / off with `popstate`; `navigate(url)`, `current`; `usa:navigate` (cancelable), `usa:navigated`.
|
|
14
|
+
- **`motionary/runtime/text`** — `splitText(el, { type: 'chars,words,lines' })`: grapheme-aware characters (`Intl.Segmenter`: emoji, combining marks, CJK), words, lines grouped by rendered position; nested inline markup kept; accessible (`aria-label` with the full text, pieces `aria-hidden`); `--i` index custom property; `revert()` / `resplit()`; pure `segment()` for SSR / workers. CDN `dist/runtime/text.iife.js`; fixed gzip budget.
|
|
15
|
+
- **`motionary/runtime/format-sprite`** — sprite sheets and image sequences: `parseSpriteSheet()` (TexturePacker JSON hash + array with trimmed / rotated frames; Aseprite JSON hash + array with per-frame `duration` and `frameTags` forward / reverse / pingpong / pingpong_reverse), `gridSheet()`, `frameOrder()`, `drawFrame()`, `spritePlayer()` (canvas or element background), `imageSequence('frame_{0001}.webp', …)`, `preloadImages()`, `sequencePlayer()` (cover-fit, scrub with `progress`). All players are runtime timelines (seek, reverse, scroll-scrub). Test fixtures in the real export formats; `test/fixtures/formats/CREDITS.md` lists sample licences.
|
|
16
|
+
- **Runtime tween**: numbers inside any CSS string are interpolated when both ends share the same text (`filter: blur(8px) saturate(0%)`, `box-shadow`, `clip-path`, `matrix(…)`), and values that cannot be interpolated (keywords such as `display`) switch at 50 % like CSS — previously they threw.
|
|
17
|
+
- **New components (10.3)** in `motionary/components/widgets`: `<usa-route-transition>` and `<usa-text-splitter>` — splits into chars / words / lines and staggers them in (`rise`, `fade`, `blur`, `flip`, `wave`) on view, load or hover, optional `loop` (**Requires: motionary/runtime/text**). The 4.x `<usa-split-text>` keeps its name and API; the runtime-powered element is a new tag.
|
|
18
|
+
- Showcase: new gallery cards with copyable code, live demos and live Store thumbnails.
|
|
19
|
+
|
|
20
|
+
### Accessibility
|
|
21
|
+
- `<usa-text-splitter>` keeps the full sentence as the element's accessible name and hides the animated pieces from screen readers; under reduced motion the text is shown at once. `<usa-route-transition>` swaps instantly under reduced motion and keeps native link semantics (modifier-clicks, `target`, downloads and cross-origin links are left alone).
|
|
22
|
+
|
|
23
|
+
### Fixed
|
|
24
|
+
- `<usa-route-transition>` (Web Animations fallback) no longer hangs when the exit animation's `finished` promise never settles (background tabs, DOMs without animation timing): the swap waits at most the exit duration.
|
|
25
|
+
- `format-svg`: value interpolation narrows the runtime's new string values correctly (TypeScript build error after the 10.3 tween change; behaviour unchanged).
|
|
26
|
+
|
|
27
|
+
## [10.2.0] - 2026-10-09
|
|
28
|
+
|
|
29
|
+
### Added
|
|
30
|
+
- **`motionary/runtime/scroll`** — scroll-linked scenes (original implementation, own API): `scrollScene({ trigger, start, end, scrub, pin, markers, actions, toggleClass, once, horizontal, scroller, onEnter, onLeave, onEnterBack, onLeaveBack, onUpdate, onToggle, animation })`. Rules like `"top 80%"`, `"center center+=100"`, end `"+=600"`; scrub direct (`true`) or smoothed (ms) on the shared ticker; pinning with a layout-preserving spacer (fixed in the window, transform inside scroll containers); start / end / viewport markers; per-edge actions (`play pause resume reverse restart reset complete none`); `refreshScenes()`, `killScenes()`, `allScenes()`, `parseEdge()`, `resolveRule()`. CDN `dist/runtime/scroll.iife.js`; fixed gzip budget.
|
|
31
|
+
- **`motionary/runtime/format-svg`** — SVG loader: SMIL playback on the runtime timeline (`<animate>` from / to / by / values, `keyTimes`, `calcMode` linear / discrete / spline + `keySplines`; `<set>`; `<animateTransform>` translate / scale / rotate / skewX / skewY; `<animateMotion>` path / `<mpath>`, `rotate="auto"`; `dur`, numeric `begin`, `repeatCount` incl. `indefinite`, `repeatDur`, `fill="freeze"`), `playSmil()` (seek / scrub / reverse / timeScale, `restore()`), `readSmil()`; path geometry without the DOM — `parsePath()` (all commands incl. arcs and S/T reflections), `flattenPath()`, `pathLength()`, `pointAtLength()`, `samplePath()` — and **path morphing** between any two paths (`morphPath()`, also used for `attributeName="d"`). Compatibility table in `docs/runtime/format-svg.md`.
|
|
32
|
+
- **`data-motion` in `motionary/core`** — `applyMotionAttributes(motion, root?, { observe })` wires `data-motion="enter: fade-up 600ms stagger 80ms; click: pop"` (triggers `enter`, `load`, `click`, `hover`, `loop`; duration, `delay`, `stagger`, `ease`, `once`) without the DSL package; `parseMotionAttr()`. Core stays far under its 10 KB budget.
|
|
33
|
+
- **Per-component Markdown docs** — `docs/components/<tag>.md` for every element (attributes, events, slots, methods, import, CDN, prerequisites, minimal example, variants) + index, generated from the same data as `components.json` / `llms-full.txt` (`npm run docs:components`; `check:peer-docs` fails when they are stale).
|
|
34
|
+
- **`AGENTS.md`** (repo root, also in the npm package) and **`docs/ai-prompt-guide.md`** — how AI assistants should pick components, start from the manifest example, and handle prerequisites; review checklist and common misuses.
|
|
35
|
+
- **New components (10.2)** in `motionary/components/widgets`: `<usa-scroll-scene>` — scroll-scrubbed scene for `[data-scrub="prop: from -> to"]` children with `scrub`, `pin`, `markers`, `stagger`, `toggle-class`, `preview` (**Requires: motionary/runtime/scroll**); `<usa-motion-inspector>` — live list of running animations (CSS, WAAPI, components) with pause / play all, 0.25× slow motion, per-row scrub and the runtime ticker's fps.
|
|
36
|
+
- Showcase: new gallery cards with copyable code (prerequisites first), live demos and live Store thumbnails.
|
|
37
|
+
|
|
38
|
+
### Accessibility
|
|
39
|
+
- `<usa-scroll-scene>` is user-driven (it only moves when the reader scrolls); under reduced motion the scrub is linear and the preview loop does not run. `<usa-motion-inspector>` controls are a labelled `toolbar`, rows have labelled scrub sliders, and its slow-motion switch helps people check motion for vestibular safety.
|
|
40
|
+
|
|
41
|
+
### Fixed
|
|
42
|
+
- Runtime timeline: a timeline holding an infinitely repeating child no longer seeks to `NaN` (`0 × Infinity`) — infinite-duration timelines seek on the raw time.
|
|
43
|
+
- `format-svg`: SMIL `<set>` without `dur` is applied and holds its value (duration 0, freeze) instead of being dropped with a `NaN` duration.
|
|
44
|
+
- Tests: the 10.1 manifest test no longer pins the exact runtime module list, so releases that add modules keep it green.
|
|
45
|
+
|
|
10
46
|
## [10.1.0] - 2026-10-09
|
|
11
47
|
|
|
12
48
|
### Added
|
package/README.md
CHANGED
|
@@ -176,6 +176,10 @@ Motionary ships its own zero-dependency animation runtime — shared ticker, twe
|
|
|
176
176
|
| [Runtime core](docs/runtime/core.md) | `motionary/runtime` | `https://cdn.jsdelivr.net/npm/motionary@10/dist/runtime.iife.js` | `use();` | 5.5 KB |
|
|
177
177
|
| [CSS @keyframes & WAAPI keyframes loader](docs/runtime/format-css.md) | `motionary/runtime/format-css` | `https://cdn.jsdelivr.net/npm/motionary@10/dist/runtime/format-css.iife.js` | `use(formatCss);` | 2.5 KB |
|
|
178
178
|
| [Motion / Framer keyframe JSON loader](docs/runtime/format-motion.md) | `motionary/runtime/format-motion` | `https://cdn.jsdelivr.net/npm/motionary@10/dist/runtime/format-motion.iife.js` | `use(formatMotion);` | 2.5 KB |
|
|
179
|
+
| [Scroll scenes](docs/runtime/scroll.md) | `motionary/runtime/scroll` | `https://cdn.jsdelivr.net/npm/motionary@10/dist/runtime/scroll.iife.js` | `use(scroll);` | 4.5 KB |
|
|
180
|
+
| [SVG loader: SMIL playback + path morphing](docs/runtime/format-svg.md) | `motionary/runtime/format-svg` | `https://cdn.jsdelivr.net/npm/motionary@10/dist/runtime/format-svg.iife.js` | `use(formatSvg);` | 5.0 KB |
|
|
181
|
+
| [Text splitting](docs/runtime/text.md) | `motionary/runtime/text` | `https://cdn.jsdelivr.net/npm/motionary@10/dist/runtime/text.iife.js` | `use(text);` | 2.5 KB |
|
|
182
|
+
| [Sprite sheets & image sequences](docs/runtime/format-sprite.md) | `motionary/runtime/format-sprite` | `https://cdn.jsdelivr.net/npm/motionary@10/dist/runtime/format-sprite.iife.js` | `use(formatSprite);` | 3.0 KB |
|
|
179
183
|
|
|
180
184
|
Install once: `npm i motionary`. Plain HTML: load `runtime.iife.js` first, then the module files (each registers itself).
|
|
181
185
|
|
|
@@ -209,6 +213,69 @@ definePluginCard(); // registers <usa-plugin-card> — after the prerequisites
|
|
|
209
213
|
</usa-plugin-card>
|
|
210
214
|
```
|
|
211
215
|
|
|
216
|
+
#### `<usa-scroll-scene>` — Requires: motionary/runtime/scroll
|
|
217
|
+
|
|
218
|
+
- **Install:** `npm i motionary`
|
|
219
|
+
- **Import order & registration:** Register the core first, then the module: use(scroll) also registers the core. CDN: load runtime.iife.js, then runtime/scroll.iife.js (it registers itself).
|
|
220
|
+
|
|
221
|
+
```js
|
|
222
|
+
import { use } from 'motionary/runtime';
|
|
223
|
+
import { scroll } from 'motionary/runtime/scroll';
|
|
224
|
+
import { defineScrollScene } from 'motionary/components/widgets';
|
|
225
|
+
|
|
226
|
+
use(scroll);
|
|
227
|
+
defineScrollScene(); // registers <usa-scroll-scene> — after the prerequisites
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
- **CDN:**
|
|
231
|
+
|
|
232
|
+
```html
|
|
233
|
+
<script src="https://cdn.jsdelivr.net/npm/motionary@10/dist/runtime.iife.js"></script>
|
|
234
|
+
<script src="https://cdn.jsdelivr.net/npm/motionary@10/dist/runtime/scroll.iife.js"></script>
|
|
235
|
+
<!-- then the component bundles -->
|
|
236
|
+
<script src="https://unpkg.com/motionary@10/dist/components.umd.js"></script>
|
|
237
|
+
<script src="https://unpkg.com/motionary@10/dist/widgets.umd.js"></script>
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
- **Minimal example:**
|
|
241
|
+
|
|
242
|
+
```html
|
|
243
|
+
<usa-scroll-scene start="top 80%" end="bottom 20%" scrub="120" stagger="120">
|
|
244
|
+
<h2 data-scrub="x: -80 -> 0; opacity: 0 -> 1">Scroll</h2>
|
|
245
|
+
<p data-scrub="y: 40 -> 0; opacity: 0 -> 1">and it follows.</p>
|
|
246
|
+
</usa-scroll-scene>
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
#### `<usa-text-splitter>` — Requires: motionary/runtime/text
|
|
250
|
+
|
|
251
|
+
- **Install:** `npm i motionary`
|
|
252
|
+
- **Import order & registration:** Register the core first, then the module: use(text) also registers the core. CDN: load runtime.iife.js, then runtime/text.iife.js (it registers itself).
|
|
253
|
+
|
|
254
|
+
```js
|
|
255
|
+
import { use } from 'motionary/runtime';
|
|
256
|
+
import { text } from 'motionary/runtime/text';
|
|
257
|
+
import { defineTextSplitter } from 'motionary/components/widgets';
|
|
258
|
+
|
|
259
|
+
use(text);
|
|
260
|
+
defineTextSplitter(); // registers <usa-text-splitter> — after the prerequisites
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
- **CDN:**
|
|
264
|
+
|
|
265
|
+
```html
|
|
266
|
+
<script src="https://cdn.jsdelivr.net/npm/motionary@10/dist/runtime.iife.js"></script>
|
|
267
|
+
<script src="https://cdn.jsdelivr.net/npm/motionary@10/dist/runtime/text.iife.js"></script>
|
|
268
|
+
<!-- then the component bundles -->
|
|
269
|
+
<script src="https://unpkg.com/motionary@10/dist/components.umd.js"></script>
|
|
270
|
+
<script src="https://unpkg.com/motionary@10/dist/widgets.umd.js"></script>
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
- **Minimal example:**
|
|
274
|
+
|
|
275
|
+
```html
|
|
276
|
+
<usa-text-splitter split="chars" effect="rise" stagger="30">Motion, made simple.</usa-text-splitter>
|
|
277
|
+
```
|
|
278
|
+
|
|
212
279
|
<!-- runtime:end -->
|
|
213
280
|
|
|
214
281
|
## Accessibility & reduced motion
|
|
@@ -242,6 +309,8 @@ Evergreen browsers since 2023: Chrome / Edge ≥ 111, Safari ≥ 16.4, Firefox
|
|
|
242
309
|
|
|
243
310
|
## Documentation
|
|
244
311
|
|
|
312
|
+
- **AI assistants:** [AGENTS.md](AGENTS.md) · [prompt guide](docs/ai-prompt-guide.md) · one page per component in [docs/components/](docs/components/README.md) · `components.json` / `llms.txt` / `llms-full.txt` on the site root.
|
|
313
|
+
|
|
245
314
|
- [API reference](./docs/API.md) — every export, option and `data-sa-*` attribute
|
|
246
315
|
- [Presets](./docs/presets.md) — all 214 by category
|
|
247
316
|
- [Components](./docs/components.md) — every `<usa-*>` element, attribute and event
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { T as Timeline, a as Tween, p as parseEase, d as parseValue } from './tween-
|
|
1
|
+
import { T as Timeline, a as Tween, p as parseEase, d as parseValue } from './tween-CGyolmzB.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Normalised keyframes shared by the format loaders: a list of frames with
|
|
@@ -180,4 +180,4 @@ function framesToTimeline(target, frames, o = {}) {
|
|
|
180
180
|
}
|
|
181
181
|
|
|
182
182
|
export { camelProp as c, distributeOffsets as d, framesToTimeline as f };
|
|
183
|
-
//# sourceMappingURL=keyframes-
|
|
183
|
+
//# sourceMappingURL=keyframes-DVAC5sQI.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keyframes-CyH_abhI.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,GAAG,CAAC,MAAM,EAAE;QACrB,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,IA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AAC,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-DVAC5sQI.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,I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|
|
5
5
|
/**
|
|
6
6
|
* Normalised keyframes shared by the format loaders: a list of frames with
|
|
@@ -184,4 +184,4 @@ function framesToTimeline(target, frames, o = {}) {
|
|
|
184
184
|
exports.camelProp = camelProp;
|
|
185
185
|
exports.distributeOffsets = distributeOffsets;
|
|
186
186
|
exports.framesToTimeline = framesToTimeline;
|
|
187
|
-
//# sourceMappingURL=keyframes-
|
|
187
|
+
//# sourceMappingURL=keyframes-Dw9zwVQa.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keyframes-cUdsXSXQ.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":";;;;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":["../../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,C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WAAK,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,GAAGC,eAAS,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;;;;;;"}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* inside Web Workers.
|
|
8
8
|
*/
|
|
9
9
|
/** Runtime version (kept in sync with the package version by the release script). */
|
|
10
|
-
const RUNTIME_VERSION = '10.
|
|
10
|
+
const RUNTIME_VERSION = '10.3.0';
|
|
11
11
|
/** Where the CDN builds live (major-pinned). */
|
|
12
12
|
const RUNTIME_CDN = 'https://cdn.jsdelivr.net/npm/motionary@10/dist/';
|
|
13
13
|
const KEY = Symbol.for('motionary.runtime');
|
|
@@ -66,4 +66,4 @@ function requireModule(id, who) {
|
|
|
66
66
|
const registeredModules = () => Array.from(registry().modules.keys());
|
|
67
67
|
|
|
68
68
|
export { RUNTIME_VERSION as R, RUNTIME_CDN as a, RuntimeModuleError as b, moduleCdn as c, modulePath as d, registeredModules as e, registry as f, requireModule as g, hasModule as h, missingMessage as m, register as r };
|
|
69
|
-
//# sourceMappingURL=registry-
|
|
69
|
+
//# sourceMappingURL=registry-46AAzyeC.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry-
|
|
1
|
+
{"version":3,"file":"registry-46AAzyeC.js","sources":["../../src/runtime/registry.ts"],"sourcesContent":["/**\n * Module registry shared by every copy of `motionary/runtime` on the page\n * (ESM, CJS and the CDN IIFE builds all read the same `globalThis` slot),\n * so a component never needs to import the runtime itself — it asks for a\n * module with `requireModule()` and gets a clear error when it is missing.\n * Nothing here touches `window` / `document`: safe to import during SSR and\n * inside Web Workers.\n */\n\n/** Runtime version (kept in sync with the package version by the release script). */\nexport const RUNTIME_VERSION = '10.3.0';\n\n/** Where the CDN builds live (major-pinned). */\nexport const RUNTIME_CDN = 'https://cdn.jsdelivr.net/npm/motionary@10/dist/';\n\n/** A runtime module: `{ id, version, api }`, registered with `use()`. */\nexport interface RuntimeModule<A = unknown> {\n /** Module id: 'core', 'format-css', 'scroll', … (import path `motionary/runtime/<id>`). */\n id: string;\n version: string;\n /** Other modules this one needs (registered first by `use()` callers). */\n requires?: string[];\n /** The module's public API (what `requireModule(id)` returns). */\n api: A;\n /** Optional one-time setup, called on first registration. */\n setup?(registry: RuntimeRegistry): void;\n}\n\nexport interface RuntimeRegistry {\n version: string;\n modules: Map<string, RuntimeModule>;\n /** Shared per-page state slots (the ticker lives here). */\n slots: Record<string, unknown>;\n}\n\nconst KEY = Symbol.for('motionary.runtime');\n\n/** The page-wide registry (created on first use). */\nexport function registry(): RuntimeRegistry {\n const g = globalThis as unknown as Record<symbol, RuntimeRegistry | undefined>;\n return (g[KEY] ||= { version: RUNTIME_VERSION, modules: new Map(), slots: {} });\n}\n\n/** The import path of a module id. */\nexport const modulePath = (id: string): string => (id === 'core' ? 'motionary/runtime' : `motionary/runtime/${id}`);\n\n/** The CDN IIFE file of a module id. */\nexport const moduleCdn = (id: string): string => RUNTIME_CDN + (id === 'core' ? 'runtime.iife.js' : `runtime/${id}.iife.js`);\n\n/** The text of the \"module missing\" error (shared with the components). */\nexport function missingMessage(id: string, who = 'This feature'): string {\n const path = modulePath(id);\n const reg = id === 'core' ? `import { use } from 'motionary/runtime'; use();` : `import { use } from 'motionary/runtime'; import { ${camel(id)} } from '${path}'; use(${camel(id)});`;\n const cdn = id === 'core' ? `<script src=\"${moduleCdn('core')}\"></script>` : `<script src=\"${moduleCdn('core')}\"></script><script src=\"${moduleCdn(id)}\"></script>`;\n return `[motionary] ${who} requires ${path}. Install once: npm i motionary — then register it before the component mounts: ${reg} Or from a CDN (core first): ${cdn} Docs: https://github.com/HarrisonCN/Motionary/blob/main/docs/runtime/${id}.md`;\n}\n\n/** 'format-css' → 'formatCss' (the module object's export name). */\nexport const camel = (id: string): string => id.replace(/-(\\w)/g, (_, c: string) => c.toUpperCase());\n\n/** Thrown by `requireModule()` when a module is not registered. */\nexport class RuntimeModuleError extends Error {\n readonly module: string;\n constructor(id: string, who?: string) {\n super(missingMessage(id, who));\n this.name = 'RuntimeModuleError';\n this.module = id;\n }\n}\n\n/** Register modules (each once; re-registering the same id keeps the first). Returns the registry. */\nexport function register(...mods: RuntimeModule[]): RuntimeRegistry {\n const r = registry();\n for (const m of mods) {\n if (!m || typeof m.id !== 'string') throw new TypeError('[motionary] use(): not a runtime module — pass the object exported by motionary/runtime/<module>');\n if (r.modules.has(m.id)) continue;\n for (const dep of m.requires || []) if (!r.modules.has(dep)) throw new RuntimeModuleError(dep, `motionary/runtime/${m.id}`);\n r.modules.set(m.id, m as RuntimeModule);\n m.setup?.(r);\n }\n return r;\n}\n\n/** Is a module registered? */\nexport const hasModule = (id: string): boolean => registry().modules.has(id);\n\n/** The API of a registered module, or a `RuntimeModuleError` with install / import / CDN instructions. */\nexport function requireModule<A = unknown>(id: string, who?: string): A {\n const m = registry().modules.get(id);\n if (!m) throw new RuntimeModuleError(id, who);\n return m.api as A;\n}\n\n/** Ids of the registered modules. */\nexport const registeredModules = (): string[] => Array.from(registry().modules.keys());\n"],"names":[],"mappings":"AAAA;;;;;;;AAOG;AAEH;AACO,MAAM,eAAe,GAAG;AAE/B;AACO,MAAM,WAAW,GAAG;AAsB3B,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,mBAAmB,CAAC;AAE3C;SACgB,QAAQ,GAAA;IACtB,MAAM,CAAC,GAAG,UAAoE;IAC9E,QAAQ,CAAC,CAAC,GAAG,CAAA,KAAL,CAAC,CAAC,GAAG,CAAA,GAAM,EAAE,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,IAAI,GAAG,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,CAAA;AAChF;AAEA;AACO,MAAM,UAAU,GAAG,CAAC,EAAU,MAAc,EAAE,KAAK,MAAM,GAAG,mBAAmB,GAAG,CAAA,kBAAA,EAAqB,EAAE,CAAA,CAAE;AAElH;AACO,MAAM,SAAS,GAAG,CAAC,EAAU,KAAa,WAAW,IAAI,EAAE,KAAK,MAAM,GAAG,iBAAiB,GAAG,CAAA,QAAA,EAAW,EAAE,CAAA,QAAA,CAAU;AAE3H;SACgB,cAAc,CAAC,EAAU,EAAE,GAAG,GAAG,cAAc,EAAA;AAC7D,IAAA,MAAM,IAAI,GAAG,UAAU,CAAC,EAAE,CAAC;IAC3B,MAAM,GAAG,GAAG,EAAE,KAAK,MAAM,GAAG,CAAA,+CAAA,CAAiD,GAAG,qDAAqD,KAAK,CAAC,EAAE,CAAC,CAAA,SAAA,EAAY,IAAI,CAAA,OAAA,EAAU,KAAK,CAAC,EAAE,CAAC,CAAA,EAAA,CAAI;AACrL,IAAA,MAAM,GAAG,GAAG,EAAE,KAAK,MAAM,GAAG,CAAA,aAAA,EAAgB,SAAS,CAAC,MAAM,CAAC,CAAA,WAAA,CAAa,GAAG,CAAA,aAAA,EAAgB,S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C,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAkB,CAAC;AACvC,QAAA,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC;IACd;AACA,IAAA,OAAO,CAAC;AACV;AAEA;AACO,MAAM,SAAS,GAAG,CAAC,EAAU,KAAc,QAAQ,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;AAE3E;AACM,SAAU,aAAa,CAAc,EAAU,EAAE,GAAY,EAAA;IACjE,MAAM,CAAC,GAAG,QAAQ,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;AACpC,IAAA,IAAI,CAAC,CAAC;AAAE,QAAA,MAAM,IAAI,kBAAkB,CAAC,EAAE,EAAE,GAAG,CAAC;IAC7C,OAAO,CAAC,CAAC,GAAQ;AACnB;AAEA;AACO,MAAM,iBAAiB,GAAG,MAAgB,KAAK,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE;;;;"}
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* inside Web Workers.
|
|
10
10
|
*/
|
|
11
11
|
/** Runtime version (kept in sync with the package version by the release script). */
|
|
12
|
-
const RUNTIME_VERSION = '10.
|
|
12
|
+
const RUNTIME_VERSION = '10.3.0';
|
|
13
13
|
/** Where the CDN builds live (major-pinned). */
|
|
14
14
|
const RUNTIME_CDN = 'https://cdn.jsdelivr.net/npm/motionary@10/dist/';
|
|
15
15
|
const KEY = Symbol.for('motionary.runtime');
|
|
@@ -78,4 +78,4 @@ exports.register = register;
|
|
|
78
78
|
exports.registeredModules = registeredModules;
|
|
79
79
|
exports.registry = registry;
|
|
80
80
|
exports.requireModule = requireModule;
|
|
81
|
-
//# sourceMappingURL=registry-
|
|
81
|
+
//# sourceMappingURL=registry-CSVil2qJ.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry-
|
|
1
|
+
{"version":3,"file":"registry-CSVil2qJ.cjs","sources":["../../src/runtime/registry.ts"],"sourcesContent":["/**\n * Module registry shared by every copy of `motionary/runtime` on the page\n * (ESM, CJS and the CDN IIFE builds all read the same `globalThis` slot),\n * so a component never needs to import the runtime itself — it asks for a\n * module with `requireModule()` and gets a clear error when it is missing.\n * Nothing here touches `window` / `document`: safe to import during SSR and\n * inside Web Workers.\n */\n\n/** Runtime version (kept in sync with the package version by the release script). */\nexport const RUNTIME_VERSION = '10.3.0';\n\n/** Where the CDN builds live (major-pinned). */\nexport const RUNTIME_CDN = 'https://cdn.jsdelivr.net/npm/motionary@10/dist/';\n\n/** A runtime module: `{ id, version, api }`, registered with `use()`. */\nexport interface RuntimeModule<A = unknown> {\n /** Module id: 'core', 'format-css', 'scroll', … (import path `motionary/runtime/<id>`). */\n id: string;\n version: string;\n /** Other modules this one needs (registered first by `use()` callers). */\n requires?: string[];\n /** The module's public API (what `requireModule(id)` returns). */\n api: A;\n /** Optional one-time setup, called on first registration. */\n setup?(registry: RuntimeRegistry): void;\n}\n\nexport interface RuntimeRegistry {\n version: string;\n modules: Map<string, RuntimeModule>;\n /** Shared per-page state slots (the ticker lives here). */\n slots: Record<string, unknown>;\n}\n\nconst KEY = Symbol.for('motionary.runtime');\n\n/** The page-wide registry (created on first use). */\nexport function registry(): RuntimeRegistry {\n const g = globalThis as unknown as Record<symbol, RuntimeRegistry | undefined>;\n return (g[KEY] ||= { version: RUNTIME_VERSION, modules: new Map(), slots: {} });\n}\n\n/** The import path of a module id. */\nexport const modulePath = (id: string): string => (id === 'core' ? 'motionary/runtime' : `motionary/runtime/${id}`);\n\n/** The CDN IIFE file of a module id. */\nexport const moduleCdn = (id: string): string => RUNTIME_CDN + (id === 'core' ? 'runtime.iife.js' : `runtime/${id}.iife.js`);\n\n/** The text of the \"module missing\" error (shared with the components). */\nexport function missingMessage(id: string, who = 'This feature'): string {\n const path = modulePath(id);\n const reg = id === 'core' ? `import { use } from 'motionary/runtime'; use();` : `import { use } from 'motionary/runtime'; import { ${camel(id)} } from '${path}'; use(${camel(id)});`;\n const cdn = id === 'core' ? `<script src=\"${moduleCdn('core')}\"></script>` : `<script src=\"${moduleCdn('core')}\"></script><script src=\"${moduleCdn(id)}\"></script>`;\n return `[motionary] ${who} requires ${path}. Install once: npm i motionary — then register it before the component mounts: ${reg} Or from a CDN (core first): ${cdn} Docs: https://github.com/HarrisonCN/Motionary/blob/main/docs/runtime/${id}.md`;\n}\n\n/** 'format-css' → 'formatCss' (the module object's export name). */\nexport const camel = (id: string): string => id.replace(/-(\\w)/g, (_, c: string) => c.toUpperCase());\n\n/** Thrown by `requireModule()` when a module is not registered. */\nexport class RuntimeModuleError extends Error {\n readonly module: string;\n constructor(id: string, who?: string) {\n super(missingMessage(id, who));\n this.name = 'RuntimeModuleError';\n this.module = id;\n }\n}\n\n/** Register modules (each once; re-registering the same id keeps the first). Returns the registry. */\nexport function register(...mods: RuntimeModule[]): RuntimeRegistry {\n const r = registry();\n for (const m of mods) {\n if (!m || typeof m.id !== 'string') throw new TypeError('[motionary] use(): not a runtime module — pass the object exported by motionary/runtime/<module>');\n if (r.modules.has(m.id)) continue;\n for (const dep of m.requires || []) if (!r.modules.has(dep)) throw new RuntimeModuleError(dep, `motionary/runtime/${m.id}`);\n r.modules.set(m.id, m as RuntimeModule);\n m.setup?.(r);\n }\n return r;\n}\n\n/** Is a module registered? */\nexport const hasModule = (id: string): boolean => registry().modules.has(id);\n\n/** The API of a registered module, or a `RuntimeModuleError` with install / import / CDN instructions. */\nexport function requireModule<A = unknown>(id: string, who?: string): A {\n const m = registry().modules.get(id);\n if (!m) throw new RuntimeModuleError(id, who);\n return m.api as A;\n}\n\n/** Ids of the registered modules. */\nexport const registeredModules = (): string[] => Array.from(registry().modules.keys());\n"],"names":[],"mappings":";;AAAA;;;;;;;AAOG;AAEH;AACO,MAAM,eAAe,GAAG;AAE/B;AACO,MAAM,WAAW,GAAG;AAsB3B,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,mBAAmB,CAAC;AAE3C;SACg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;IACjE,MAAM,CAAC,GAAG,QAAQ,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;AACpC,IAAA,IAAI,CAAC,CAAC;AAAE,QAAA,MAAM,IAAI,kBAAkB,CAAC,EAAE,EAAE,GAAG,CAAC;IAC7C,OAAO,CAAC,CAAC,GAAQ;AACnB;AAEA;AACO,MAAM,iBAAiB,GAAG,MAAgB,KAAK,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { f as registry } from './registry-46AAzyeC.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The shared ticker: one requestAnimationFrame loop per page (or worker) for
|
|
5
|
+
* every runtime animation, with lag smoothing and a frame budget readout.
|
|
6
|
+
* Falls back to a 16 ms timer where rAF is missing (Node, some workers).
|
|
7
|
+
* Nothing runs until the first listener is added (SSR-safe).
|
|
8
|
+
*/
|
|
9
|
+
function createTicker() {
|
|
10
|
+
const fns = new Set();
|
|
11
|
+
let time = 0, last = -1, fps = 60, maxDelta = 100, handle = null;
|
|
12
|
+
const g = globalThis;
|
|
13
|
+
const now = () => (g.performance?.now ? g.performance.now() : Date.now());
|
|
14
|
+
const raf = (cb) => (typeof g.requestAnimationFrame === 'function' ? g.requestAnimationFrame(cb) : setTimeout(() => cb(now()), 16));
|
|
15
|
+
const caf = (h) => (typeof g.cancelAnimationFrame === 'function' ? g.cancelAnimationFrame(h) : clearTimeout(h));
|
|
16
|
+
const run = (dt, cap = true) => {
|
|
17
|
+
const d = (cap ? Math.min(dt, maxDelta) : dt) * t.timeScale;
|
|
18
|
+
time += d;
|
|
19
|
+
for (const fn of Array.from(fns))
|
|
20
|
+
fn(time, d);
|
|
21
|
+
};
|
|
22
|
+
const frame = (ts) => {
|
|
23
|
+
handle = null;
|
|
24
|
+
if (!fns.size)
|
|
25
|
+
return;
|
|
26
|
+
const n = typeof ts === 'number' && ts > 0 ? ts : now();
|
|
27
|
+
const dt = last < 0 ? 0 : n - last;
|
|
28
|
+
last = n;
|
|
29
|
+
if (dt > 0)
|
|
30
|
+
fps = fps * 0.9 + (1000 / dt) * 0.1;
|
|
31
|
+
run(dt);
|
|
32
|
+
if (fns.size)
|
|
33
|
+
handle = raf(frame);
|
|
34
|
+
};
|
|
35
|
+
const wake = () => {
|
|
36
|
+
if (handle === null && fns.size) {
|
|
37
|
+
last = -1;
|
|
38
|
+
handle = raf(frame);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
const t = {
|
|
42
|
+
add(fn) {
|
|
43
|
+
fns.add(fn);
|
|
44
|
+
wake();
|
|
45
|
+
return () => t.remove(fn);
|
|
46
|
+
},
|
|
47
|
+
remove(fn) {
|
|
48
|
+
fns.delete(fn);
|
|
49
|
+
if (!fns.size && handle !== null) {
|
|
50
|
+
caf(handle);
|
|
51
|
+
handle = null;
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
get time() { return time; },
|
|
55
|
+
get fps() { return Math.round(fps); },
|
|
56
|
+
get size() { return fns.size; },
|
|
57
|
+
lagSmoothing(ms) { maxDelta = ms > 0 ? ms : Infinity; },
|
|
58
|
+
timeScale: 1,
|
|
59
|
+
step(ms) { run(ms, false); },
|
|
60
|
+
};
|
|
61
|
+
return t;
|
|
62
|
+
}
|
|
63
|
+
/** The page-wide ticker (shared across every copy of the runtime). */
|
|
64
|
+
function getTicker() {
|
|
65
|
+
const s = registry().slots;
|
|
66
|
+
return (s.ticker || (s.ticker = createTicker()));
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export { getTicker as g };
|
|
70
|
+
//# sourceMappingURL=ticker-COOYAyQy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ticker-COOYAyQy.js","sources":["../../src/runtime/ticker.ts"],"sourcesContent":["/**\n * The shared ticker: one requestAnimationFrame loop per page (or worker) for\n * every runtime animation, with lag smoothing and a frame budget readout.\n * Falls back to a 16 ms timer where rAF is missing (Node, some workers).\n * Nothing runs until the first listener is added (SSR-safe).\n */\nimport { registry } from './registry';\n\nexport type TickFn = (time: number, delta: number) => void;\n\nexport interface Ticker {\n /** Add a listener; returns a remover. */\n add(fn: TickFn): () => void;\n remove(fn: TickFn): void;\n /** ms since the ticker started (frozen while sleeping). */\n readonly time: number;\n /** Smoothed frames per second. */\n readonly fps: number;\n /** Listener count (0 = asleep). */\n readonly size: number;\n /** Cap a single frame's delta (default 100 ms) so a background tab does not jump animations. */\n lagSmoothing(maxDelta: number): void;\n /** Global time scale (1 = normal, 0.5 = half speed, 0 = frozen). */\n timeScale: number;\n /** Advance by `ms` synchronously (tests, offline rendering, worker loops). */\n step(ms: number): void;\n}\n\nfunction createTicker(): Ticker {\n const fns = new Set<TickFn>();\n let time = 0, last = -1, fps = 60, maxDelta = 100, handle: unknown = null;\n const g = globalThis as any;\n const now = (): number => (g.performance?.now ? g.performance.now() : Date.now());\n const raf = (cb: (t: number) => void): unknown => (typeof g.requestAnimationFrame === 'function' ? g.requestAnimationFrame(cb) : setTimeout(() => cb(now()), 16));\n const caf = (h: unknown): void => (typeof g.cancelAnimationFrame === 'function' ? g.cancelAnimationFrame(h) : clearTimeout(h as any));\n const run = (dt: number, cap = true): void => {\n const d = (cap ? Math.min(dt, maxDelta) : dt) * t.timeScale;\n time += d;\n for (const fn of Array.from(fns)) fn(time, d);\n };\n const frame = (ts: number): void => {\n handle = null;\n if (!fns.size) return;\n const n = typeof ts === 'number' && ts > 0 ? ts : now();\n const dt = last < 0 ? 0 : n - last;\n last = n;\n if (dt > 0) fps = fps * 0.9 + (1000 / dt) * 0.1;\n run(dt);\n if (fns.size) handle = raf(frame);\n };\n const wake = (): void => {\n if (handle === null && fns.size) {\n last = -1;\n handle = raf(frame);\n }\n };\n const t: Ticker = {\n add(fn) {\n fns.add(fn);\n wake();\n return () => t.remove(fn);\n },\n remove(fn) {\n fns.delete(fn);\n if (!fns.size && handle !== null) {\n caf(handle);\n handle = null;\n }\n },\n get time() { return time; },\n get fps() { return Math.round(fps); },\n get size() { return fns.size; },\n lagSmoothing(ms) { maxDelta = ms > 0 ? ms : Infinity; },\n timeScale: 1,\n step(ms) { run(ms, false); },\n };\n return t;\n}\n\n/** The page-wide ticker (shared across every copy of the runtime). */\nexport function getTicker(): Ticker {\n const s = registry().slots;\n return (s.ticker ||= createTicker()) as Ticker;\n}\n"],"names":[],"mappings":";;AAAA;;;;;AAKG;AAuBH,SAAS,YAAY,GAAA;AACnB,IAAA,MAAM,GAAG,GAAG,IAAI,GAAG,EAAU;IAC7B,IAAI,IAAI,GAAG,CAAC,EAAE,IAAI,GAAG,EAAE,EAAE,GAAG,GAAG,EAAE,EAAE,QAAQ,GAAG,GAAG,EAAE,MAAM,GAAY,IAAI;IACzE,MAAM,CAAC,GAAG,UAAiB;AAC3B,IAAA,MAAM,GAAG,GAAG,OAAe,CAAC,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,CAAC,WAAW,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;AACjF,IAAA,MAAM,GAAG,GAAG,CAAC,EAAuB,MAAe,OAAO,CAAC,CAAC,qBAAqB,KAAK,UAAU,GAAG,CAAC,CAAC,qBAAqB,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;AACjK,IAAA,MAAM,GAAG,GAAG,CAAC,CAAU,MAAY,OAAO,CAAC,CAAC,oBAAoB,KAAK,UAAU,GAAG,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,CAAQ,CAAC,CAAC;IACrI,MAAM,GAAG,GAAG,CAAC,EAAU,EAAE,GAAG,GAAG,IAAI,KAAU;QAC3C,MAAM,CAAC,GAAG,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,QAAQ,CAAC,GAAG,EAAE,IAA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