motionary 9.8.0 → 10.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/CHANGELOG.md +28 -0
- package/bin/usa-codemod-10.mjs +57 -0
- package/dist/components/core.cjs +219 -0
- package/dist/components/core.cjs.map +1 -0
- package/dist/components/core.d.cts +81 -0
- package/dist/components/core.d.ts +81 -0
- package/dist/components/core.js +214 -0
- package/dist/components/core.js.map +1 -0
- package/dist/components/fx2.cjs +33 -5
- package/dist/components/fx2.cjs.map +1 -1
- package/dist/components/fx2.d.cts +17 -5
- package/dist/components/fx2.d.ts +17 -5
- package/dist/components/fx2.js +30 -5
- package/dist/components/fx2.js.map +1 -1
- package/dist/components/plugins.cjs +138 -0
- package/dist/components/plugins.cjs.map +1 -0
- package/dist/components/plugins.d.cts +120 -0
- package/dist/components/plugins.d.ts +120 -0
- package/dist/components/plugins.js +105 -0
- package/dist/components/plugins.js.map +1 -0
- package/dist/widgets.umd.js +1 -1
- package/dist/widgets.umd.js.map +1 -1
- package/docs/ROADMAP.md +54 -14
- package/docs/components.md +20 -0
- package/docs/core.md +47 -0
- package/docs/deprecations.md +4 -0
- package/docs/upgrading-10.md +21 -0
- package/package.json +43 -2
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,34 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [10.0.0] - 2026-10-09
|
|
11
|
+
|
|
12
|
+
### ⚠️ Breaking
|
|
13
|
+
- **`registerEffectPacks()` removed** from `motionary/fx2` (deprecated in 9.9) → `registerAllPlugins()` (same behaviour) or only the plugins you use. `npx usa-codemod-10 --write src` rewrites it. See [docs/upgrading-10.md](./docs/upgrading-10.md).
|
|
14
|
+
|
|
15
|
+
### Added
|
|
16
|
+
- **New architecture — zero-dependency core `motionary/core`** (= `motionary/components/core`), **under 10 KB gzip** (≈ 2 KB; fixed size budget + test): `createMotion({ reducedMotion, rate })` → `use(...plugins)`, `play()`, `bind(el, effect, { trigger })`, `reveal(targets, preset, { stagger, once, threshold })`, `animate()`, `pause()` / `resume()` / `setRate()`, `has()`, `effects()`, `destroy()`; `PRESETS` (10 entrance presets), `preferredBackend()` (`webgpu` → `webgl2` → `canvas`), `VERSION`. See [docs/core.md](./docs/core.md).
|
|
17
|
+
- **Every effect as a plugin — `motionary/plugins`** (= `motionary/components/plugins`): every built-in effect pack as an `{ name, effects }` plugin (`retro`, `cinema`, `paper`, `cyber`, `weather`, …, `ALL_PLUGINS`) for `createMotion().use(…)` or `usePlugins(…)`; each import pulls in only its own pack.
|
|
18
|
+
- **WebGPU by default**: GPU effects and backgrounds keep `backend: 'auto'` = WebGPU → WebGL2 → Canvas, and plugins built on the core use the same order via `preferredBackend()`.
|
|
19
|
+
- Chinese roadmap v10.1 → v11.0 in [docs/ROADMAP.md](./docs/ROADMAP.md), with two new tracks across the minors: **AI-readable components** (components manifest + `llms.txt` in 10.1, per-component Markdown docs + `AGENTS.md` in 10.2, the `motionary-mcp` MCP server in 10.4) and **components that need peer plugins** (GSAP/ScrollTrigger, SplitType, Lenis, Three.js, lottie-web/Rive, Matter.js, Embla — optional peerDependencies, lazy-loaded with a clear error, prerequisites stated on every card / Store detail / docs page / README / manifest, and a "Requires: X" Store badge).
|
|
20
|
+
- npm: `motionary` and the `use-scroll-animate` alias are published with the `latest` tag.
|
|
21
|
+
|
|
22
|
+
### Accessibility
|
|
23
|
+
- The core honours reduced motion everywhere (OS setting or `reducedMotion: 'reduce'`): entrance presets fade instead of moving, loop / background / cursor effects are skipped, effects get `ctx.reduced`. `pause()` stops everything an instance started (WCAG 2.2.2).
|
|
24
|
+
|
|
25
|
+
### Fixed
|
|
26
|
+
|
|
27
|
+
- Tests: running `usa-codemod-10 --write` over the test suite also rewrote assertions about historical artifacts — the `usa-codemod-7` output and `docs/upgrading-7.md`, which still (correctly) name `registerEffectPacks` — and the new "`registerEffectPacks` is gone" check itself; those assertions are restored.
|
|
28
|
+
|
|
29
|
+
## [9.9.0] - 2026-10-09
|
|
30
|
+
|
|
31
|
+
### Added
|
|
32
|
+
- **Plugins API (9.9)** in `motionary/fx2` — every effect pack is a plugin: `definePlugin(name, effects, install?)`, `usePlugins(...plugins)` (registers each plugin once, returns its effect names), `effectPlugins()` (all built-in packs as `{ name: '<pack>', effects }`), `registerAllPlugins()`.
|
|
33
|
+
- `usa-codemod-10` (`npx usa-codemod-10 --write src`) and [docs/upgrading-10.md](docs/upgrading-10.md) — the 10.0 plan: zero-dependency core under 10 KB, effects only as plugins, WebGPU by default.
|
|
34
|
+
|
|
35
|
+
### Deprecated (removed in 10.0)
|
|
36
|
+
- `registerEffectPacks()` → `registerAllPlugins()` (same behaviour; warns once) — the codemod rewrites it. The showcase, `motionary/components/widgets/auto` and the internals already use the new names.
|
|
37
|
+
|
|
10
38
|
## [9.8.0] - 2026-10-09
|
|
11
39
|
|
|
12
40
|
### Added
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// motionary 9.x → 10.0 codemod.
|
|
3
|
+
// npx usa-codemod-10 [--write] [paths…] (default: ./src; dry run without --write)
|
|
4
|
+
// Rewrites (9.9 deprecations, removed in 10.0):
|
|
5
|
+
// 1. registerEffectPacks → registerAllPlugins (every effect pack is a plugin in 10.0).
|
|
6
|
+
import { readFileSync, writeFileSync, readdirSync, statSync } from 'node:fs';
|
|
7
|
+
import { join, extname } from 'node:path';
|
|
8
|
+
import { pathToFileURL } from 'node:url';
|
|
9
|
+
|
|
10
|
+
const EXT = new Set(['.js', '.mjs', '.cjs', '.jsx', '.ts', '.tsx', '.mts', '.cts', '.vue', '.svelte', '.html', '.astro', '.md', '.mdx']);
|
|
11
|
+
export const RENAMES = { registerEffectPacks: 'registerAllPlugins' };
|
|
12
|
+
|
|
13
|
+
/** Apply every rewrite to one file's source. Returns { code, changes, manual }. */
|
|
14
|
+
export function transform(source) {
|
|
15
|
+
const changes = [];
|
|
16
|
+
const manual = [];
|
|
17
|
+
let code = source;
|
|
18
|
+
for (const [from, to] of Object.entries(RENAMES)) {
|
|
19
|
+
const re = new RegExp(`(?<![\\w$])${from}(?![\\w$])`, 'g');
|
|
20
|
+
const n = (code.match(re) || []).length;
|
|
21
|
+
if (n) {
|
|
22
|
+
code = code.replace(re, to);
|
|
23
|
+
changes.push(`${from} → ${to} (${n}×)`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return { code, changes, manual };
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function* walk(p) {
|
|
30
|
+
const st = statSync(p);
|
|
31
|
+
if (st.isDirectory()) {
|
|
32
|
+
for (const f of readdirSync(p)) if (!['node_modules', 'dist', '.git'].includes(f)) yield* walk(join(p, f));
|
|
33
|
+
} else if (EXT.has(extname(p))) yield p;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function run(args) {
|
|
37
|
+
const write = args.includes('--write');
|
|
38
|
+
const paths = args.filter((a) => !a.startsWith('--'));
|
|
39
|
+
let files = 0;
|
|
40
|
+
let edits = 0;
|
|
41
|
+
let todo = 0;
|
|
42
|
+
for (const root of paths.length ? paths : ['src'])
|
|
43
|
+
for (const f of walk(root)) {
|
|
44
|
+
const src = readFileSync(f, 'utf8');
|
|
45
|
+
const { code, changes, manual } = transform(src);
|
|
46
|
+
if (!changes.length && !manual.length) continue;
|
|
47
|
+
files++;
|
|
48
|
+
edits += changes.length;
|
|
49
|
+
todo += manual.length;
|
|
50
|
+
console.log(`${f}${changes.map((c) => `\n - ${c}`).join('')}${manual.map((c) => `\n ! manual: ${c}`).join('')}`);
|
|
51
|
+
if (write && changes.length) writeFileSync(f, code);
|
|
52
|
+
}
|
|
53
|
+
console.log(`\n${files} file(s), ${edits} rewrite(s)${write ? ' applied' : ' (dry run — pass --write to apply)'}, ${todo} manual change(s).`);
|
|
54
|
+
return { files, edits, todo };
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (import.meta.url === pathToFileURL(process.argv[1] || '').href) run(process.argv.slice(2));
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* `motionary/core` (10.0) — the zero-dependency core, under 10 KB gzip.
|
|
5
|
+
*
|
|
6
|
+
* Everything else is a plugin: `createMotion().use(retro, cinema)` with the
|
|
7
|
+
* packs from `motionary/plugins` (or your own `{ name, effects }`).
|
|
8
|
+
*
|
|
9
|
+
* - `createMotion({ reducedMotion, rate })` → an instance with `use()`,
|
|
10
|
+
* `play(el, effect, options)`, `bind(el, effect, { trigger })`,
|
|
11
|
+
* `reveal(targets, preset, { stagger, once, threshold })`, `animate()`,
|
|
12
|
+
* `pause()` / `resume()` / `setRate()` for everything it started,
|
|
13
|
+
* `effects()` and `destroy()`.
|
|
14
|
+
* - `PRESETS` — entrance keyframes (fade, fade-up/down/left/right, scale,
|
|
15
|
+
* zoom-in/out, blur-in, flip-up), registered as `enter` effects.
|
|
16
|
+
* - `preferredBackend()` — `webgpu` (default when available) → `webgl2` →
|
|
17
|
+
* `canvas`, the order GPU plugins use.
|
|
18
|
+
*
|
|
19
|
+
* Reduced motion is honoured everywhere (OS setting or `reducedMotion:
|
|
20
|
+
* 'reduce'`): entrances fade, loops / backgrounds / cursors are skipped.
|
|
21
|
+
*/
|
|
22
|
+
const VERSION = '10.0.0';
|
|
23
|
+
const T = (x, y, s = 1) => `translate(${x}px,${y}px) scale(${s})`;
|
|
24
|
+
/** Entrance keyframes (10.0). */
|
|
25
|
+
const PRESETS = {
|
|
26
|
+
fade: [{ opacity: 0 }, { opacity: 1 }],
|
|
27
|
+
'fade-up': [{ opacity: 0, transform: T(0, 24) }, { opacity: 1, transform: 'none' }],
|
|
28
|
+
'fade-down': [{ opacity: 0, transform: T(0, -24) }, { opacity: 1, transform: 'none' }],
|
|
29
|
+
'fade-left': [{ opacity: 0, transform: T(24, 0) }, { opacity: 1, transform: 'none' }],
|
|
30
|
+
'fade-right': [{ opacity: 0, transform: T(-24, 0) }, { opacity: 1, transform: 'none' }],
|
|
31
|
+
scale: [{ opacity: 0, transform: 'scale(.85)' }, { opacity: 1, transform: 'none' }],
|
|
32
|
+
'zoom-in': [{ opacity: 0, transform: 'scale(.6)' }, { opacity: 1, transform: 'none' }],
|
|
33
|
+
'zoom-out': [{ opacity: 0, transform: 'scale(1.2)' }, { opacity: 1, transform: 'none' }],
|
|
34
|
+
'blur-in': [{ opacity: 0, filter: 'blur(10px)' }, { opacity: 1, filter: 'none' }],
|
|
35
|
+
'flip-up': [{ opacity: 0, transform: 'perspective(600px) rotateX(-60deg)' }, { opacity: 1, transform: 'none' }],
|
|
36
|
+
};
|
|
37
|
+
const EASE = 'cubic-bezier(0.22, 1, 0.36, 1)';
|
|
38
|
+
const SKIP = ['loop', 'background', 'cursor'];
|
|
39
|
+
/** GPU backend order used by GPU plugins: WebGPU by default (10.0). */
|
|
40
|
+
function preferredBackend() {
|
|
41
|
+
if (typeof navigator !== 'undefined' && navigator.gpu)
|
|
42
|
+
return 'webgpu';
|
|
43
|
+
try {
|
|
44
|
+
if (typeof document !== 'undefined' && document.createElement('canvas').getContext?.('webgl2'))
|
|
45
|
+
return 'webgl2';
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
/* no GL */
|
|
49
|
+
}
|
|
50
|
+
return 'canvas';
|
|
51
|
+
}
|
|
52
|
+
const list = (t) => typeof t === 'string' ? (typeof document === 'undefined' ? [] : Array.from(document.querySelectorAll(t))) : 'length' in t && !(t instanceof Element) ? Array.from(t) : [t];
|
|
53
|
+
/** Create a Motionary core instance (10.0). */
|
|
54
|
+
function createMotion(config = {}) {
|
|
55
|
+
const reg = new Map();
|
|
56
|
+
const plugins = new Set();
|
|
57
|
+
const live = new Set();
|
|
58
|
+
const offs = new Set();
|
|
59
|
+
let paused = false;
|
|
60
|
+
let rate = config.rate && config.rate > 0 ? config.rate : 1;
|
|
61
|
+
const reduced = () => config.reducedMotion === 'reduce' || (typeof matchMedia === 'function' && matchMedia('(prefers-reduced-motion: reduce)').matches);
|
|
62
|
+
const animate = (el, kf, o) => {
|
|
63
|
+
if (typeof el.animate !== 'function')
|
|
64
|
+
return null;
|
|
65
|
+
const a = el.animate(kf, o);
|
|
66
|
+
if (!a)
|
|
67
|
+
return null;
|
|
68
|
+
live.add(a);
|
|
69
|
+
if (rate !== 1)
|
|
70
|
+
a.playbackRate = rate;
|
|
71
|
+
if (paused)
|
|
72
|
+
a.pause();
|
|
73
|
+
const done = () => live.delete(a);
|
|
74
|
+
a.finished?.then(done, done);
|
|
75
|
+
return a;
|
|
76
|
+
};
|
|
77
|
+
const ctx = (event, cleanups = []) => ({ reduced: reduced(), sensitivity: reduced() ? 'minimal' : 'full', event, animate, onCleanup: (f) => cleanups.push(f) });
|
|
78
|
+
const skip = (d) => reduced() && (d.reduced ?? (SKIP.includes(d.kind) ? 'skip' : 'run')) === 'skip';
|
|
79
|
+
const m = {
|
|
80
|
+
get paused() {
|
|
81
|
+
return paused;
|
|
82
|
+
},
|
|
83
|
+
get rate() {
|
|
84
|
+
return rate;
|
|
85
|
+
},
|
|
86
|
+
use(...ps) {
|
|
87
|
+
for (const p of ps) {
|
|
88
|
+
if (!p || plugins.has(p.name))
|
|
89
|
+
continue;
|
|
90
|
+
plugins.add(p.name);
|
|
91
|
+
for (const e of p.effects || [])
|
|
92
|
+
if (!reg.has(e.name))
|
|
93
|
+
reg.set(e.name, e);
|
|
94
|
+
p.install?.(m);
|
|
95
|
+
}
|
|
96
|
+
return m;
|
|
97
|
+
},
|
|
98
|
+
has: (n) => reg.has(n),
|
|
99
|
+
effects: () => Array.from(reg.keys()).sort(),
|
|
100
|
+
reduced,
|
|
101
|
+
animate,
|
|
102
|
+
async play(el, name, options = {}, event) {
|
|
103
|
+
const d = reg.get(name);
|
|
104
|
+
if (!d)
|
|
105
|
+
throw new Error(`[motionary] unknown effect "${name}" — add its plugin with use()`);
|
|
106
|
+
if (skip(d))
|
|
107
|
+
return;
|
|
108
|
+
const out = d.run(el, { ...(d.defaults || {}), ...options }, ctx(event));
|
|
109
|
+
if (out?.finished?.then)
|
|
110
|
+
await out.finished.catch(() => undefined);
|
|
111
|
+
else if (out?.then)
|
|
112
|
+
await out;
|
|
113
|
+
},
|
|
114
|
+
bind(el, name, options = {}) {
|
|
115
|
+
const { trigger = 'click', once, ...o } = options;
|
|
116
|
+
const d = reg.get(name);
|
|
117
|
+
if (!d)
|
|
118
|
+
throw new Error(`[motionary] unknown effect "${name}"`);
|
|
119
|
+
const stops = [];
|
|
120
|
+
let current = [];
|
|
121
|
+
const fire = (e) => {
|
|
122
|
+
if (skip(d))
|
|
123
|
+
return;
|
|
124
|
+
current.splice(0).forEach((f) => f());
|
|
125
|
+
const out = d.run(el, { ...(d.defaults || {}), ...o }, ctx(e, current));
|
|
126
|
+
if (typeof out === 'function')
|
|
127
|
+
current.push(out);
|
|
128
|
+
};
|
|
129
|
+
const on = (type) => {
|
|
130
|
+
const h = (e) => fire(e);
|
|
131
|
+
el.addEventListener(type, h, { once: !!once });
|
|
132
|
+
stops.push(() => el.removeEventListener(type, h));
|
|
133
|
+
};
|
|
134
|
+
if (trigger === 'click')
|
|
135
|
+
on('click');
|
|
136
|
+
else if (trigger === 'hover')
|
|
137
|
+
(on('pointerenter'), on('focusin'));
|
|
138
|
+
else if (trigger === 'load' || trigger === 'loop')
|
|
139
|
+
fire();
|
|
140
|
+
else if (trigger === 'enter' && typeof IntersectionObserver !== 'undefined') {
|
|
141
|
+
const io = new IntersectionObserver((es) => es.forEach((en) => {
|
|
142
|
+
if (!en.isIntersecting)
|
|
143
|
+
return;
|
|
144
|
+
fire();
|
|
145
|
+
if (once !== false)
|
|
146
|
+
io.disconnect();
|
|
147
|
+
}));
|
|
148
|
+
io.observe(el);
|
|
149
|
+
stops.push(() => io.disconnect());
|
|
150
|
+
}
|
|
151
|
+
const off = () => {
|
|
152
|
+
stops.splice(0).forEach((f) => f());
|
|
153
|
+
current.splice(0).forEach((f) => f());
|
|
154
|
+
offs.delete(off);
|
|
155
|
+
};
|
|
156
|
+
offs.add(off);
|
|
157
|
+
return off;
|
|
158
|
+
},
|
|
159
|
+
reveal(targets, preset = 'fade-up', o = {}) {
|
|
160
|
+
const els = list(targets);
|
|
161
|
+
const kf = PRESETS[preset] || PRESETS.fade;
|
|
162
|
+
const show = (el, i) => {
|
|
163
|
+
el.style.removeProperty('opacity');
|
|
164
|
+
animate(el, reduced() ? PRESETS.fade : kf, { duration: o.duration ?? 600, delay: (o.delay ?? 0) + (o.stagger ?? 0) * i, easing: o.easing || EASE, fill: 'backwards' });
|
|
165
|
+
};
|
|
166
|
+
if (typeof IntersectionObserver === 'undefined') {
|
|
167
|
+
els.forEach(show);
|
|
168
|
+
return () => undefined;
|
|
169
|
+
}
|
|
170
|
+
els.forEach((el) => (el.style.opacity = '0'));
|
|
171
|
+
let batch = 0;
|
|
172
|
+
const io = new IntersectionObserver((es) => {
|
|
173
|
+
batch = 0;
|
|
174
|
+
for (const en of es) {
|
|
175
|
+
if (!en.isIntersecting)
|
|
176
|
+
continue;
|
|
177
|
+
show(en.target, batch++);
|
|
178
|
+
if (o.once !== false)
|
|
179
|
+
io.unobserve(en.target);
|
|
180
|
+
}
|
|
181
|
+
}, { threshold: o.threshold ?? 0.15 });
|
|
182
|
+
els.forEach((el) => io.observe(el));
|
|
183
|
+
const off = () => {
|
|
184
|
+
io.disconnect();
|
|
185
|
+
els.forEach((el) => el.style.removeProperty('opacity'));
|
|
186
|
+
offs.delete(off);
|
|
187
|
+
};
|
|
188
|
+
offs.add(off);
|
|
189
|
+
return off;
|
|
190
|
+
},
|
|
191
|
+
pause() {
|
|
192
|
+
paused = true;
|
|
193
|
+
live.forEach((a) => a.pause());
|
|
194
|
+
},
|
|
195
|
+
resume() {
|
|
196
|
+
paused = false;
|
|
197
|
+
live.forEach((a) => a.play());
|
|
198
|
+
},
|
|
199
|
+
setRate(r) {
|
|
200
|
+
if (!(r > 0))
|
|
201
|
+
return;
|
|
202
|
+
rate = r;
|
|
203
|
+
live.forEach((a) => (a.playbackRate = r));
|
|
204
|
+
},
|
|
205
|
+
destroy() {
|
|
206
|
+
Array.from(offs).forEach((f) => f());
|
|
207
|
+
live.forEach((a) => a.cancel());
|
|
208
|
+
live.clear();
|
|
209
|
+
},
|
|
210
|
+
};
|
|
211
|
+
m.use({ name: 'core/presets', effects: Object.entries(PRESETS).map(([name, frames]) => ({ name, kind: 'enter', defaults: { duration: 600, delay: 0, easing: EASE }, run: (el, o, c) => c.animate(el, c.reduced ? PRESETS.fade : frames, { duration: o.duration, delay: o.delay, easing: o.easing, fill: 'backwards' }) })) });
|
|
212
|
+
return m;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
exports.PRESETS = PRESETS;
|
|
216
|
+
exports.VERSION = VERSION;
|
|
217
|
+
exports.createMotion = createMotion;
|
|
218
|
+
exports.preferredBackend = preferredBackend;
|
|
219
|
+
//# sourceMappingURL=core.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.cjs","sources":["../../src/components/core/index.ts"],"sourcesContent":["/**\n * `motionary/core` (10.0) — the zero-dependency core, under 10 KB gzip.\n *\n * Everything else is a plugin: `createMotion().use(retro, cinema)` with the\n * packs from `motionary/plugins` (or your own `{ name, effects }`).\n *\n * - `createMotion({ reducedMotion, rate })` → an instance with `use()`,\n * `play(el, effect, options)`, `bind(el, effect, { trigger })`,\n * `reveal(targets, preset, { stagger, once, threshold })`, `animate()`,\n * `pause()` / `resume()` / `setRate()` for everything it started,\n * `effects()` and `destroy()`.\n * - `PRESETS` — entrance keyframes (fade, fade-up/down/left/right, scale,\n * zoom-in/out, blur-in, flip-up), registered as `enter` effects.\n * - `preferredBackend()` — `webgpu` (default when available) → `webgl2` →\n * `canvas`, the order GPU plugins use.\n *\n * Reduced motion is honoured everywhere (OS setting or `reducedMotion:\n * 'reduce'`): entrances fade, loops / backgrounds / cursors are skipped.\n */\nexport const VERSION = '10.0.0';\n\nexport type CoreEffectKind = 'enter' | 'exit' | 'attention' | 'hover' | 'click' | 'loop' | 'background' | 'cursor' | 'text' | 'scroll' | (string & {});\nexport interface CoreEffectContext {\n reduced: boolean;\n sensitivity: 'full' | 'gentle' | 'minimal' | 'static';\n event?: Event;\n animate(el: Element, keyframes: Keyframe[] | PropertyIndexedKeyframes, options?: number | KeyframeAnimationOptions): Animation | null;\n onCleanup(fn: () => void): void;\n}\nexport interface CoreEffect {\n name: string;\n kind: CoreEffectKind;\n description?: string;\n defaults?: Record<string, unknown>;\n reduced?: 'skip' | 'run';\n run(el: HTMLElement, options: any, ctx: CoreEffectContext): unknown;\n}\nexport interface CorePlugin {\n name: string;\n effects?: CoreEffect[];\n install?(m: MotionInstance): void;\n}\nexport type Trigger = 'click' | 'hover' | 'enter' | 'load' | 'loop' | 'manual';\nexport interface RevealOptions {\n stagger?: number;\n delay?: number;\n duration?: number;\n easing?: string;\n once?: boolean;\n threshold?: number;\n}\nexport interface MotionInstance {\n readonly paused: boolean;\n readonly rate: number;\n use(...plugins: CorePlugin[]): MotionInstance;\n has(effect: string): boolean;\n effects(): string[];\n reduced(): boolean;\n animate(el: Element, keyframes: Keyframe[] | PropertyIndexedKeyframes, options?: number | KeyframeAnimationOptions): Animation | null;\n play(el: HTMLElement, effect: string, options?: Record<string, unknown>, event?: Event): Promise<void>;\n bind(el: HTMLElement, effect: string, options?: Record<string, unknown> & { trigger?: Trigger; once?: boolean }): () => void;\n reveal(targets: string | Element | ArrayLike<Element>, preset?: string, options?: RevealOptions): () => void;\n pause(): void;\n resume(): void;\n setRate(rate: number): void;\n destroy(): void;\n}\n\nconst T = (x: number, y: number, s = 1) => `translate(${x}px,${y}px) scale(${s})`;\n/** Entrance keyframes (10.0). */\nexport const PRESETS: Record<string, Keyframe[]> = {\n fade: [{ opacity: 0 }, { opacity: 1 }],\n 'fade-up': [{ opacity: 0, transform: T(0, 24) }, { opacity: 1, transform: 'none' }],\n 'fade-down': [{ opacity: 0, transform: T(0, -24) }, { opacity: 1, transform: 'none' }],\n 'fade-left': [{ opacity: 0, transform: T(24, 0) }, { opacity: 1, transform: 'none' }],\n 'fade-right': [{ opacity: 0, transform: T(-24, 0) }, { opacity: 1, transform: 'none' }],\n scale: [{ opacity: 0, transform: 'scale(.85)' }, { opacity: 1, transform: 'none' }],\n 'zoom-in': [{ opacity: 0, transform: 'scale(.6)' }, { opacity: 1, transform: 'none' }],\n 'zoom-out': [{ opacity: 0, transform: 'scale(1.2)' }, { opacity: 1, transform: 'none' }],\n 'blur-in': [{ opacity: 0, filter: 'blur(10px)' }, { opacity: 1, filter: 'none' }],\n 'flip-up': [{ opacity: 0, transform: 'perspective(600px) rotateX(-60deg)' }, { opacity: 1, transform: 'none' }],\n};\nconst EASE = 'cubic-bezier(0.22, 1, 0.36, 1)';\nconst SKIP: string[] = ['loop', 'background', 'cursor'];\n\n/** GPU backend order used by GPU plugins: WebGPU by default (10.0). */\nexport function preferredBackend(): 'webgpu' | 'webgl2' | 'canvas' {\n if (typeof navigator !== 'undefined' && (navigator as any).gpu) return 'webgpu';\n try {\n if (typeof document !== 'undefined' && document.createElement('canvas').getContext?.('webgl2')) return 'webgl2';\n } catch {\n /* no GL */\n }\n return 'canvas';\n}\n\nconst list = (t: string | Element | ArrayLike<Element>): HTMLElement[] =>\n typeof t === 'string' ? (typeof document === 'undefined' ? [] : Array.from(document.querySelectorAll<HTMLElement>(t))) : 'length' in (t as ArrayLike<Element>) && !(t instanceof Element) ? (Array.from(t as ArrayLike<Element>) as HTMLElement[]) : [t as HTMLElement];\n\n/** Create a Motionary core instance (10.0). */\nexport function createMotion(config: { reducedMotion?: 'user' | 'reduce'; rate?: number } = {}): MotionInstance {\n const reg = new Map<string, CoreEffect>();\n const plugins = new Set<string>();\n const live = new Set<Animation>();\n const offs = new Set<() => void>();\n let paused = false;\n let rate = config.rate && config.rate > 0 ? config.rate : 1;\n const reduced = () => config.reducedMotion === 'reduce' || (typeof matchMedia === 'function' && matchMedia('(prefers-reduced-motion: reduce)').matches);\n const animate: MotionInstance['animate'] = (el, kf, o) => {\n if (typeof (el as any).animate !== 'function') return null;\n const a = el.animate(kf, o);\n if (!a) return null;\n live.add(a);\n if (rate !== 1) a.playbackRate = rate;\n if (paused) a.pause();\n const done = () => live.delete(a);\n a.finished?.then(done, done);\n return a;\n };\n const ctx = (event?: Event, cleanups: (() => void)[] = []): CoreEffectContext => ({ reduced: reduced(), sensitivity: reduced() ? 'minimal' : 'full', event, animate, onCleanup: (f) => cleanups.push(f) });\n const skip = (d: CoreEffect) => reduced() && (d.reduced ?? (SKIP.includes(d.kind) ? 'skip' : 'run')) === 'skip';\n const m: MotionInstance = {\n get paused() {\n return paused;\n },\n get rate() {\n return rate;\n },\n use(...ps) {\n for (const p of ps) {\n if (!p || plugins.has(p.name)) continue;\n plugins.add(p.name);\n for (const e of p.effects || []) if (!reg.has(e.name)) reg.set(e.name, e);\n p.install?.(m);\n }\n return m;\n },\n has: (n) => reg.has(n),\n effects: () => Array.from(reg.keys()).sort(),\n reduced,\n animate,\n async play(el, name, options = {}, event) {\n const d = reg.get(name);\n if (!d) throw new Error(`[motionary] unknown effect \"${name}\" — add its plugin with use()`);\n if (skip(d)) return;\n const out = d.run(el, { ...(d.defaults || {}), ...options }, ctx(event)) as any;\n if (out?.finished?.then) await out.finished.catch(() => undefined);\n else if (out?.then) await out;\n },\n bind(el, name, options = {}) {\n const { trigger = 'click', once, ...o } = options;\n const d = reg.get(name);\n if (!d) throw new Error(`[motionary] unknown effect \"${name}\"`);\n const stops: (() => void)[] = [];\n let current: (() => void)[] = [];\n const fire = (e?: Event) => {\n if (skip(d)) return;\n current.splice(0).forEach((f) => f());\n const out = d.run(el, { ...(d.defaults || {}), ...o }, ctx(e, current));\n if (typeof out === 'function') current.push(out as () => void);\n };\n const on = (type: string) => {\n const h = (e: Event) => fire(e);\n el.addEventListener(type, h, { once: !!once });\n stops.push(() => el.removeEventListener(type, h));\n };\n if (trigger === 'click') on('click');\n else if (trigger === 'hover') (on('pointerenter'), on('focusin'));\n else if (trigger === 'load' || trigger === 'loop') fire();\n else if (trigger === 'enter' && typeof IntersectionObserver !== 'undefined') {\n const io = new IntersectionObserver((es) =>\n es.forEach((en) => {\n if (!en.isIntersecting) return;\n fire();\n if (once !== false) io.disconnect();\n })\n );\n io.observe(el);\n stops.push(() => io.disconnect());\n }\n const off = () => {\n stops.splice(0).forEach((f) => f());\n current.splice(0).forEach((f) => f());\n offs.delete(off);\n };\n offs.add(off);\n return off;\n },\n reveal(targets, preset = 'fade-up', o = {}) {\n const els = list(targets);\n const kf = PRESETS[preset] || PRESETS.fade;\n const show = (el: HTMLElement, i: number) => {\n el.style.removeProperty('opacity');\n animate(el, reduced() ? PRESETS.fade : kf, { duration: o.duration ?? 600, delay: (o.delay ?? 0) + (o.stagger ?? 0) * i, easing: o.easing || EASE, fill: 'backwards' });\n };\n if (typeof IntersectionObserver === 'undefined') {\n els.forEach(show);\n return () => undefined;\n }\n els.forEach((el) => (el.style.opacity = '0'));\n let batch = 0;\n const io = new IntersectionObserver(\n (es) => {\n batch = 0;\n for (const en of es) {\n if (!en.isIntersecting) continue;\n show(en.target as HTMLElement, batch++);\n if (o.once !== false) io.unobserve(en.target);\n }\n },\n { threshold: o.threshold ?? 0.15 }\n );\n els.forEach((el) => io.observe(el));\n const off = () => {\n io.disconnect();\n els.forEach((el) => el.style.removeProperty('opacity'));\n offs.delete(off);\n };\n offs.add(off);\n return off;\n },\n pause() {\n paused = true;\n live.forEach((a) => a.pause());\n },\n resume() {\n paused = false;\n live.forEach((a) => a.play());\n },\n setRate(r) {\n if (!(r > 0)) return;\n rate = r;\n live.forEach((a) => (a.playbackRate = r));\n },\n destroy() {\n Array.from(offs).forEach((f) => f());\n live.forEach((a) => a.cancel());\n live.clear();\n },\n };\n m.use({ name: 'core/presets', effects: Object.entries(PRESETS).map(([name, frames]) => ({ name, kind: 'enter', defaults: { duration: 600, delay: 0, easing: EASE }, run: (el: HTMLElement, o: any, c: CoreEffectContext) => c.animate(el, c.reduced ? PRESETS.fade : frames, { duration: o.duration, delay: o.delay, easing: o.easing, fill: 'backwards' }) })) });\n return m;\n}\n"],"names":[],"mappings":";;AAAA;;;;;;;;;;;;;;;;;;AAkBG;AACI,MAAM,OAAO,GAAG;AAiDvB,MAAM,CAAC,GAAG,CAAC,CAAS,EAAE,CAAS,EAAE,CAAC,GAAG,CAAC,KAAK,aAAa,CAAC,CAAA,GAAA,EAAM,CAAC,CAAA,UAAA,EAAa,CAAC,GAAG;AACjF;AACO,MAAM,OAAO,GAA+B;AACjD,IAAA,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;IACtC,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC;IACnF,WAAW,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC;IACtF,WAAW,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC;IACrF,YAAY,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC;IACvF,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,SAAS,EAAE,YAAY,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CAAC,IAAI,GAAG,MAAM,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;AAClW,IAAA,OAAO,CAAC;AACV;;;;;;;"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `motionary/core` (10.0) — the zero-dependency core, under 10 KB gzip.
|
|
3
|
+
*
|
|
4
|
+
* Everything else is a plugin: `createMotion().use(retro, cinema)` with the
|
|
5
|
+
* packs from `motionary/plugins` (or your own `{ name, effects }`).
|
|
6
|
+
*
|
|
7
|
+
* - `createMotion({ reducedMotion, rate })` → an instance with `use()`,
|
|
8
|
+
* `play(el, effect, options)`, `bind(el, effect, { trigger })`,
|
|
9
|
+
* `reveal(targets, preset, { stagger, once, threshold })`, `animate()`,
|
|
10
|
+
* `pause()` / `resume()` / `setRate()` for everything it started,
|
|
11
|
+
* `effects()` and `destroy()`.
|
|
12
|
+
* - `PRESETS` — entrance keyframes (fade, fade-up/down/left/right, scale,
|
|
13
|
+
* zoom-in/out, blur-in, flip-up), registered as `enter` effects.
|
|
14
|
+
* - `preferredBackend()` — `webgpu` (default when available) → `webgl2` →
|
|
15
|
+
* `canvas`, the order GPU plugins use.
|
|
16
|
+
*
|
|
17
|
+
* Reduced motion is honoured everywhere (OS setting or `reducedMotion:
|
|
18
|
+
* 'reduce'`): entrances fade, loops / backgrounds / cursors are skipped.
|
|
19
|
+
*/
|
|
20
|
+
declare const VERSION = "10.0.0";
|
|
21
|
+
type CoreEffectKind = 'enter' | 'exit' | 'attention' | 'hover' | 'click' | 'loop' | 'background' | 'cursor' | 'text' | 'scroll' | (string & {});
|
|
22
|
+
interface CoreEffectContext {
|
|
23
|
+
reduced: boolean;
|
|
24
|
+
sensitivity: 'full' | 'gentle' | 'minimal' | 'static';
|
|
25
|
+
event?: Event;
|
|
26
|
+
animate(el: Element, keyframes: Keyframe[] | PropertyIndexedKeyframes, options?: number | KeyframeAnimationOptions): Animation | null;
|
|
27
|
+
onCleanup(fn: () => void): void;
|
|
28
|
+
}
|
|
29
|
+
interface CoreEffect {
|
|
30
|
+
name: string;
|
|
31
|
+
kind: CoreEffectKind;
|
|
32
|
+
description?: string;
|
|
33
|
+
defaults?: Record<string, unknown>;
|
|
34
|
+
reduced?: 'skip' | 'run';
|
|
35
|
+
run(el: HTMLElement, options: any, ctx: CoreEffectContext): unknown;
|
|
36
|
+
}
|
|
37
|
+
interface CorePlugin {
|
|
38
|
+
name: string;
|
|
39
|
+
effects?: CoreEffect[];
|
|
40
|
+
install?(m: MotionInstance): void;
|
|
41
|
+
}
|
|
42
|
+
type Trigger = 'click' | 'hover' | 'enter' | 'load' | 'loop' | 'manual';
|
|
43
|
+
interface RevealOptions {
|
|
44
|
+
stagger?: number;
|
|
45
|
+
delay?: number;
|
|
46
|
+
duration?: number;
|
|
47
|
+
easing?: string;
|
|
48
|
+
once?: boolean;
|
|
49
|
+
threshold?: number;
|
|
50
|
+
}
|
|
51
|
+
interface MotionInstance {
|
|
52
|
+
readonly paused: boolean;
|
|
53
|
+
readonly rate: number;
|
|
54
|
+
use(...plugins: CorePlugin[]): MotionInstance;
|
|
55
|
+
has(effect: string): boolean;
|
|
56
|
+
effects(): string[];
|
|
57
|
+
reduced(): boolean;
|
|
58
|
+
animate(el: Element, keyframes: Keyframe[] | PropertyIndexedKeyframes, options?: number | KeyframeAnimationOptions): Animation | null;
|
|
59
|
+
play(el: HTMLElement, effect: string, options?: Record<string, unknown>, event?: Event): Promise<void>;
|
|
60
|
+
bind(el: HTMLElement, effect: string, options?: Record<string, unknown> & {
|
|
61
|
+
trigger?: Trigger;
|
|
62
|
+
once?: boolean;
|
|
63
|
+
}): () => void;
|
|
64
|
+
reveal(targets: string | Element | ArrayLike<Element>, preset?: string, options?: RevealOptions): () => void;
|
|
65
|
+
pause(): void;
|
|
66
|
+
resume(): void;
|
|
67
|
+
setRate(rate: number): void;
|
|
68
|
+
destroy(): void;
|
|
69
|
+
}
|
|
70
|
+
/** Entrance keyframes (10.0). */
|
|
71
|
+
declare const PRESETS: Record<string, Keyframe[]>;
|
|
72
|
+
/** GPU backend order used by GPU plugins: WebGPU by default (10.0). */
|
|
73
|
+
declare function preferredBackend(): 'webgpu' | 'webgl2' | 'canvas';
|
|
74
|
+
/** Create a Motionary core instance (10.0). */
|
|
75
|
+
declare function createMotion(config?: {
|
|
76
|
+
reducedMotion?: 'user' | 'reduce';
|
|
77
|
+
rate?: number;
|
|
78
|
+
}): MotionInstance;
|
|
79
|
+
|
|
80
|
+
export { PRESETS, VERSION, createMotion, preferredBackend };
|
|
81
|
+
export type { CoreEffect, CoreEffectContext, CoreEffectKind, CorePlugin, MotionInstance, RevealOptions, Trigger };
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `motionary/core` (10.0) — the zero-dependency core, under 10 KB gzip.
|
|
3
|
+
*
|
|
4
|
+
* Everything else is a plugin: `createMotion().use(retro, cinema)` with the
|
|
5
|
+
* packs from `motionary/plugins` (or your own `{ name, effects }`).
|
|
6
|
+
*
|
|
7
|
+
* - `createMotion({ reducedMotion, rate })` → an instance with `use()`,
|
|
8
|
+
* `play(el, effect, options)`, `bind(el, effect, { trigger })`,
|
|
9
|
+
* `reveal(targets, preset, { stagger, once, threshold })`, `animate()`,
|
|
10
|
+
* `pause()` / `resume()` / `setRate()` for everything it started,
|
|
11
|
+
* `effects()` and `destroy()`.
|
|
12
|
+
* - `PRESETS` — entrance keyframes (fade, fade-up/down/left/right, scale,
|
|
13
|
+
* zoom-in/out, blur-in, flip-up), registered as `enter` effects.
|
|
14
|
+
* - `preferredBackend()` — `webgpu` (default when available) → `webgl2` →
|
|
15
|
+
* `canvas`, the order GPU plugins use.
|
|
16
|
+
*
|
|
17
|
+
* Reduced motion is honoured everywhere (OS setting or `reducedMotion:
|
|
18
|
+
* 'reduce'`): entrances fade, loops / backgrounds / cursors are skipped.
|
|
19
|
+
*/
|
|
20
|
+
declare const VERSION = "10.0.0";
|
|
21
|
+
type CoreEffectKind = 'enter' | 'exit' | 'attention' | 'hover' | 'click' | 'loop' | 'background' | 'cursor' | 'text' | 'scroll' | (string & {});
|
|
22
|
+
interface CoreEffectContext {
|
|
23
|
+
reduced: boolean;
|
|
24
|
+
sensitivity: 'full' | 'gentle' | 'minimal' | 'static';
|
|
25
|
+
event?: Event;
|
|
26
|
+
animate(el: Element, keyframes: Keyframe[] | PropertyIndexedKeyframes, options?: number | KeyframeAnimationOptions): Animation | null;
|
|
27
|
+
onCleanup(fn: () => void): void;
|
|
28
|
+
}
|
|
29
|
+
interface CoreEffect {
|
|
30
|
+
name: string;
|
|
31
|
+
kind: CoreEffectKind;
|
|
32
|
+
description?: string;
|
|
33
|
+
defaults?: Record<string, unknown>;
|
|
34
|
+
reduced?: 'skip' | 'run';
|
|
35
|
+
run(el: HTMLElement, options: any, ctx: CoreEffectContext): unknown;
|
|
36
|
+
}
|
|
37
|
+
interface CorePlugin {
|
|
38
|
+
name: string;
|
|
39
|
+
effects?: CoreEffect[];
|
|
40
|
+
install?(m: MotionInstance): void;
|
|
41
|
+
}
|
|
42
|
+
type Trigger = 'click' | 'hover' | 'enter' | 'load' | 'loop' | 'manual';
|
|
43
|
+
interface RevealOptions {
|
|
44
|
+
stagger?: number;
|
|
45
|
+
delay?: number;
|
|
46
|
+
duration?: number;
|
|
47
|
+
easing?: string;
|
|
48
|
+
once?: boolean;
|
|
49
|
+
threshold?: number;
|
|
50
|
+
}
|
|
51
|
+
interface MotionInstance {
|
|
52
|
+
readonly paused: boolean;
|
|
53
|
+
readonly rate: number;
|
|
54
|
+
use(...plugins: CorePlugin[]): MotionInstance;
|
|
55
|
+
has(effect: string): boolean;
|
|
56
|
+
effects(): string[];
|
|
57
|
+
reduced(): boolean;
|
|
58
|
+
animate(el: Element, keyframes: Keyframe[] | PropertyIndexedKeyframes, options?: number | KeyframeAnimationOptions): Animation | null;
|
|
59
|
+
play(el: HTMLElement, effect: string, options?: Record<string, unknown>, event?: Event): Promise<void>;
|
|
60
|
+
bind(el: HTMLElement, effect: string, options?: Record<string, unknown> & {
|
|
61
|
+
trigger?: Trigger;
|
|
62
|
+
once?: boolean;
|
|
63
|
+
}): () => void;
|
|
64
|
+
reveal(targets: string | Element | ArrayLike<Element>, preset?: string, options?: RevealOptions): () => void;
|
|
65
|
+
pause(): void;
|
|
66
|
+
resume(): void;
|
|
67
|
+
setRate(rate: number): void;
|
|
68
|
+
destroy(): void;
|
|
69
|
+
}
|
|
70
|
+
/** Entrance keyframes (10.0). */
|
|
71
|
+
declare const PRESETS: Record<string, Keyframe[]>;
|
|
72
|
+
/** GPU backend order used by GPU plugins: WebGPU by default (10.0). */
|
|
73
|
+
declare function preferredBackend(): 'webgpu' | 'webgl2' | 'canvas';
|
|
74
|
+
/** Create a Motionary core instance (10.0). */
|
|
75
|
+
declare function createMotion(config?: {
|
|
76
|
+
reducedMotion?: 'user' | 'reduce';
|
|
77
|
+
rate?: number;
|
|
78
|
+
}): MotionInstance;
|
|
79
|
+
|
|
80
|
+
export { PRESETS, VERSION, createMotion, preferredBackend };
|
|
81
|
+
export type { CoreEffect, CoreEffectContext, CoreEffectKind, CorePlugin, MotionInstance, RevealOptions, Trigger };
|