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/docs/ROADMAP.md
CHANGED
|
@@ -1,14 +1,54 @@
|
|
|
1
|
-
# Motionary 路线图(
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
# Motionary 路线图(10.0 之后)
|
|
2
|
+
|
|
3
|
+
10.0 已发布:全新架构 —— 零依赖核心 `motionary/core`(gzip 后不到 10 KB,实测约 2 KB:`createMotion()`、入场预设、`play` / `bind` / `reveal`、统一暂停与倍速)、所有特效插件化(`motionary/plugins`,按需 `createMotion().use(retro, cinema)`,每个插件只引入自己的特效包)、GPU 特效默认使用 WebGPU(不支持时回退 WebGL2 → Canvas);移除 9.9 弃用的 `registerEffectPacks()`(改用 `registerAllPlugins()`,`npx usa-codemod-10 --write src` 自动改写);`motionary` 与 `use-scroll-animate` 同时成为 npm `latest`。
|
|
4
|
+
|
|
5
|
+
下面是 10.1 → 11.0 的计划。每个版本一个主题 + 一组新组件,另外贯穿两条长期主线:
|
|
6
|
+
|
|
7
|
+
- **主线 A · AI 可读组件**:让 AI 模型能自己发现、理解并正确使用每一个组件 —— 机器可读的组件清单、`llms.txt`、逐组件 Markdown 文档、`AGENTS.md` 提示指南,以及 `motionary-mcp` MCP 服务器。
|
|
8
|
+
- **主线 B · 依赖第三方插件的组件**:基于 GSAP / ScrollTrigger、SplitType、Lenis、Three.js、lottie-web、Rive、Matter.js、Embla Carousel 等成熟库的组件与特效。这些库一律声明为**可选** `peerDependencies`(`peerDependenciesMeta.optional: true`),核心与其他组件不受影响;组件在首次使用时懒加载对应库,缺失时抛出清晰的错误(例如 `[motionary] <usa-three-scene> 需要 three:npm i three,或通过 CDN 引入后再注册`),而不是静默失败。
|
|
9
|
+
|
|
10
|
+
## 主线 B 的统一规则(从 10.1 起对每个依赖插件的组件强制执行)
|
|
11
|
+
|
|
12
|
+
每个依赖第三方库的组件,在以下 **5 处** 都必须写明前置条件:画廊卡片、Store 详情、文档页、README 对应章节、AI 组件清单(manifest)。前置条件固定包含 4 项:
|
|
13
|
+
|
|
14
|
+
1. **安装命令**:如 `npm i gsap`(多个库写在一条命令里);
|
|
15
|
+
2. **CDN 替代方案**:可直接复制的 `<script>` / `import` URL(固定版本号);
|
|
16
|
+
3. **引入顺序与注册代码**:先引入哪个库、是否需要 `gsap.registerPlugin(ScrollTrigger)` 之类的注册、再如何注册 Motionary 组件;
|
|
17
|
+
4. **最小用法示例**:能直接运行的一段 HTML / JS。
|
|
18
|
+
|
|
19
|
+
Store 卡片显示 **「Requires: X」** 徽章(如 `Requires: GSAP + ScrollTrigger`),点开详情即可看到上面 4 项。从 10.1 起 CI 增加 `check:peer-docs`,任何一处缺失都会让构建失败。
|
|
20
|
+
|
|
21
|
+
## 各版本计划
|
|
22
|
+
|
|
23
|
+
- **v10.1** — 插件生态 + AI 清单 + 第三方插件基础设施:插件开发脚手架(`npm create motionary-plugin`)、插件签名校验与版本兼容检查。
|
|
24
|
+
- 主线 A:发布机器可读组件清单 `components.json`(Pages 根目录 + npm 包内 `motionary/manifest.json`,带 JSON Schema),每个组件包含:标签名、属性 / attributes、事件、插槽、导入路径、CDN URL、最小示例、peer 依赖;Pages 根目录提供 `llms.txt`(索引)与 `llms-full.txt`(全部组件的完整说明),均在构建时由源码生成,保证不过期。
|
|
25
|
+
- 主线 B:`requirePeer()` 懒加载器与统一错误提示、`peerDependenciesMeta` 规范、Store 「Requires: X」徽章、前置条件区块模板与 `check:peer-docs`(本版先用于新组件)。
|
|
26
|
+
- 新组件:插件详情卡、安装按钮(一键复制 npm 命令或 CDN 代码)。
|
|
27
|
+
- **v10.2** — 核心 DSL 化:`motionary/core` 直接支持 `data-motion` 声明式语法(无需整个 DSL 包)。
|
|
28
|
+
- 主线 A:逐组件 Markdown 文档(`/docs/components/<tag>.md`,由清单生成,与 `llms-full.txt` 同源);仓库根目录新增 `AGENTS.md` 与提示指南(如何让 AI 选组件、写最小示例、避免常见误用)。
|
|
29
|
+
- 主线 B:首个依赖插件的组件 —— GSAP + ScrollTrigger 桥接(`motionary/peer/gsap`,把 Motionary 特效挂到 GSAP 时间线上)。
|
|
30
|
+
- 新组件:动效检查器面板、`<usa-scroll-scene>`(Requires: GSAP + ScrollTrigger)。
|
|
31
|
+
- **v10.3** — View Transitions 2.0:跨文档页面转场、共享元素动画插件。
|
|
32
|
+
- 主线 B:文字拆分组件 `<usa-split-text>`(Requires: SplitType),逐字 / 逐词 / 逐行入场。
|
|
33
|
+
- 新组件:路由转场容器、`<usa-split-text>`。
|
|
34
|
+
- **v10.4** — 滚动驱动 3.0:原生 `animation-timeline` 优先、JS 回退插件化。
|
|
35
|
+
- 主线 A:发布 `motionary-mcp` MCP 服务器(`npx motionary-mcp`,stdio),工具:`list_components`、`search_components`、`get_component`、`get_example`、`scaffold_snippet`(按框架 / CDN / npm 生成可运行片段,自动带上 peer 前置条件);数据直接读取清单。
|
|
36
|
+
- 主线 B:平滑滚动组件(Requires: Lenis)。
|
|
37
|
+
- 新组件:滚动进度环、视差分层容器、`<usa-smooth-scroll>`。
|
|
38
|
+
- **v10.5** — WebGPU 特效 2.0:计算着色器粒子、后处理链(辉光、色差、景深)。
|
|
39
|
+
- 主线 B:Three.js 场景组件(Requires: three;加载 glTF 时另需 `three/addons` 的 GLTFLoader,文档写明引入路径)。
|
|
40
|
+
- 新组件:粒子画布、着色器背景、`<usa-three-scene>`。
|
|
41
|
+
- **v10.6** — 动效设计令牌 2.0:W3C Design Tokens 格式导入导出、主题级动效曲线。
|
|
42
|
+
- 主线 B:完整保真的 Lottie / Rive 播放器(Requires: lottie-web / @rive-app/canvas),与 9.2 的内置 `lottieToKeyframes()` 轻量转换并存,文档说明何时选哪个。
|
|
43
|
+
- 新组件:令牌编辑器、`<usa-lottie-player>`、`<usa-rive>`。
|
|
44
|
+
- **v10.7** — AI 辅助动效:自然语言 → 动效描述(本地规则引擎,可选接入模型)、动效建议。
|
|
45
|
+
- 主线 A:MCP 服务器 2.0 —— 新增 `suggest_motion`、`validate_snippet`(检查标签、属性与 peer 前置条件是否齐全);清单覆盖全部特效;加入 AI 使用评测集(给模型一组任务,检验生成代码能否直接运行)。
|
|
46
|
+
- 主线 B:物理组件(Requires: matter-js)。
|
|
47
|
+
- 新组件:动效提示输入框、`<usa-physics-playground>`。
|
|
48
|
+
- **v10.8** — 跨端 3.0:小程序(微信 / 支付宝)适配插件、鸿蒙 ArkTS 示例。
|
|
49
|
+
- 主线 B:轮播组件(Requires: embla-carousel),类 Swiper 的手势、循环、自动播放,暂停遵循减少动态效果偏好。
|
|
50
|
+
- 新组件:跨端预览器、`<usa-carousel>`。
|
|
51
|
+
- **v10.9** — 11.0 预备:11.0 弃用警告、`upgrading-11.md` 与 `usa-codemod-11`。
|
|
52
|
+
- 主线 A:清单 Schema v2 定稿(11.0 起冻结),`llms.txt` / 文档 / MCP 全量对齐。
|
|
53
|
+
- 主线 B:对全部依赖插件的组件做一次审计 —— `check:peer-docs` 扩展到所有历史组件,peer 版本范围与 CDN 链接统一更新。
|
|
54
|
+
- **v11.0** — 下一代:核心继续瘦身(目标 < 5 KB)、插件按需懒加载、移除 10.9 弃用项;组件清单 Schema v2 与 `motionary-mcp` 1.0 稳定版;`motionary/peer/*` 入口转为稳定 API;npm `latest`。
|
package/docs/components.md
CHANGED
|
@@ -1301,6 +1301,26 @@ fs.writeFileSync('motion-tokens.json', JSON.stringify(nativeTokens(), null, 2));
|
|
|
1301
1301
|
```
|
|
1302
1302
|
- `<usa-native-preview rules platform name>`: `replay()`, `code('react-native' | 'flutter')`; `usa:replay`.
|
|
1303
1303
|
|
|
1304
|
+
### v9.9 Plugins API (`motionary/fx2`) — 10.0 preparation
|
|
1305
|
+
|
|
1306
|
+
```js
|
|
1307
|
+
import { usePlugins, effectPlugins, definePlugin, registerAllPlugins } from 'motionary/fx2';
|
|
1308
|
+
usePlugins(...effectPlugins().filter((p) => /retro|cinema/.test(p.name))); // only what you use
|
|
1309
|
+
usePlugins(definePlugin('acme/sparkle', [sparkleEffect]));
|
|
1310
|
+
```
|
|
1311
|
+
- `registerEffectPacks()` is deprecated (removed in 10.0) → `registerAllPlugins()`; `npx usa-codemod-10 --write src`. See docs/upgrading-10.md.
|
|
1312
|
+
|
|
1313
|
+
### v10.0 New architecture — `motionary/core` (< 10 KB gzip) + `motionary/plugins`
|
|
1314
|
+
|
|
1315
|
+
```js
|
|
1316
|
+
import { createMotion } from 'motionary/core';
|
|
1317
|
+
import { retro, cinema } from 'motionary/plugins';
|
|
1318
|
+
const motion = createMotion().use(retro, cinema);
|
|
1319
|
+
motion.reveal('.card', 'fade-up', { stagger: 80 });
|
|
1320
|
+
motion.bind(button, 'vhs-glitch', { trigger: 'click' });
|
|
1321
|
+
```
|
|
1322
|
+
- Zero dependencies, ≈ 2 KB gzip; every effect pack is a plugin; WebGPU is the default GPU backend. `registerEffectPacks()` is removed → `registerAllPlugins()` (`npx usa-codemod-10 --write src`). See docs/core.md and docs/upgrading-10.md.
|
|
1323
|
+
|
|
1304
1324
|
## Frameworks
|
|
1305
1325
|
|
|
1306
1326
|
Custom elements work in every framework. Register once (e.g. in your entry file), then use the tags.
|
package/docs/core.md
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# `motionary/core` — the 10.0 zero-dependency core
|
|
2
|
+
|
|
3
|
+
`motionary/core` is the whole runtime of Motionary 10: no dependencies, no side effects, **under 10 KB gzip** (about 2 KB today; a size budget and a test keep it there). Everything else — every effect pack, every GPU background — is a plugin you add with `use()`.
|
|
4
|
+
|
|
5
|
+
```js
|
|
6
|
+
import { createMotion } from 'motionary/core';
|
|
7
|
+
import { retro, cinema } from 'motionary/plugins';
|
|
8
|
+
|
|
9
|
+
const motion = createMotion().use(retro, cinema);
|
|
10
|
+
|
|
11
|
+
motion.reveal('.card', 'fade-up', { stagger: 80 }); // scroll-in entrances
|
|
12
|
+
motion.bind(button, 'vhs-glitch', { trigger: 'click' }); // effect on a trigger
|
|
13
|
+
await motion.play(hero, 'dolly-in', { duration: 900 }); // play once, await it
|
|
14
|
+
motion.pause(); motion.setRate(0.5); motion.resume(); // one control for everything it started
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## API
|
|
18
|
+
|
|
19
|
+
- `createMotion({ reducedMotion?: 'user' | 'reduce', rate?: number })` → instance:
|
|
20
|
+
- `use(...plugins)` — add plugins (`{ name, effects?, install?(motion) }`); a plugin is installed once, the first effect with a name wins.
|
|
21
|
+
- `play(el, effect, options?, event?)` — run an effect, resolves when it finishes; unknown effects throw ("add its plugin with use()").
|
|
22
|
+
- `bind(el, effect, { trigger: 'click' | 'hover' | 'enter' | 'load' | 'loop' | 'manual', once?, ...options })` → `off()`.
|
|
23
|
+
- `reveal(targets, preset = 'fade-up', { stagger, delay, duration, easing, once, threshold })` → `off()`; elements are hidden until they enter the viewport.
|
|
24
|
+
- `animate(el, keyframes, options)` — `el.animate()` tracked by the instance.
|
|
25
|
+
- `pause()`, `resume()`, `setRate(rate)`, `paused`, `rate`, `has(name)`, `effects()`, `reduced()`, `destroy()`.
|
|
26
|
+
- `PRESETS` — `fade`, `fade-up`, `fade-down`, `fade-left`, `fade-right`, `scale`, `zoom-in`, `zoom-out`, `blur-in`, `flip-up` (registered as `enter` effects on every instance).
|
|
27
|
+
- `preferredBackend()` — `'webgpu'` when `navigator.gpu` exists (the 10.0 default), else `'webgl2'`, else `'canvas'`.
|
|
28
|
+
- `VERSION` — `'10.0.0'`.
|
|
29
|
+
|
|
30
|
+
## Plugins
|
|
31
|
+
|
|
32
|
+
`motionary/plugins` exports every built-in effect pack as a plugin (`retro`, `cinema`, `paper`, `cyber`, `weather`, … and `ALL_PLUGINS`). Each import pulls in only its own pack. The same plugins work with `usePlugins()` from `motionary/fx2` for the `<usa-*>` elements and `data-usa-fx` attributes.
|
|
33
|
+
|
|
34
|
+
Your own plugin:
|
|
35
|
+
|
|
36
|
+
```js
|
|
37
|
+
const sparkle = { name: 'acme/sparkle', effects: [{ name: 'sparkle', kind: 'attention', run: (el, o, ctx) => ctx.animate(el, [{ filter: 'brightness(1)' }, { filter: 'brightness(1.8)' }, { filter: 'brightness(1)' }], 400) }] };
|
|
38
|
+
createMotion().use(sparkle);
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Reduced motion
|
|
42
|
+
|
|
43
|
+
Honoured everywhere (the OS setting, or `reducedMotion: 'reduce'`): entrance presets fade instead of moving; `loop`, `background` and `cursor` effects are skipped unless the effect says `reduced: 'run'`; effects receive `ctx.reduced` to degrade themselves.
|
|
44
|
+
|
|
45
|
+
## Upgrading
|
|
46
|
+
|
|
47
|
+
`registerEffectPacks()` (deprecated in 9.9) is removed — use `registerAllPlugins()` or, better, only the plugins you need. `npx usa-codemod-10 --write src` rewrites it. The full `motionary` package, `motionary/components` and every `<usa-*>` element keep working unchanged. See [upgrading-10.md](./upgrading-10.md).
|
package/docs/deprecations.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Deprecations
|
|
2
2
|
|
|
3
|
+
## Deprecated in 9.9, removed in 10.0 (released)
|
|
4
|
+
|
|
5
|
+
See [upgrading-10.md](./upgrading-10.md) — `registerEffectPacks()` (use `registerAllPlugins()` or `usePlugins(...)`). Run `npx usa-codemod-10 --write src`.
|
|
6
|
+
|
|
3
7
|
## Deprecated in 8.9, removed in 9.0 (released)
|
|
4
8
|
|
|
5
9
|
See [upgrading-9.md](./upgrading-9.md) — the 5.8 motion-theme names `applyTheme()`, `THEMES`, `THEME_NAMES`, `<usa-theme>` / `defineTheme()` (use `applyMotionTheme()`, `MOTION_THEMES`, `MOTION_THEME_NAMES`, `<usa-motion-theme>` / `defineMotionTheme()`; same behaviour). Run `npx usa-codemod-9 --write src`.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Upgrading to 10.0
|
|
2
|
+
|
|
3
|
+
10.0.0 is released — a new architecture: a zero-dependency core under 10 KB (`motionary/core`), every effect pack delivered as a plugin, and WebGPU as the default backend for GPU effects. 9.9 warned once in the console for everything that went away, and a codemod rewrites it:
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
npx usa-codemod-10 src # dry run: lists every change (and what needs a manual edit)
|
|
7
|
+
npx usa-codemod-10 --write src # apply
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## Removed in 10.0 (deprecated in 9.9)
|
|
11
|
+
|
|
12
|
+
| 9.x | 10.0 | Codemod |
|
|
13
|
+
|---|---|---|
|
|
14
|
+
| `registerEffectPacks()` (`motionary/fx2`) | `registerAllPlugins()` — or register only the plugins you use: `usePlugins(retro, cinema)` | ✅ |
|
|
15
|
+
`EFFECT_PACKS` (packs by key) stays; `effectPlugins()` gives the same packs as plugin objects (`[{ name: 'retro', effects }, …]`).
|
|
16
|
+
|
|
17
|
+
## New in 9.9 (before the break)
|
|
18
|
+
|
|
19
|
+
- **Plugins.** `definePlugin(name, effects, install?)`, `usePlugins(...plugins)` (registers each plugin once, returns the effect names), `effectPlugins()` (every built-in pack as a plugin) and `registerAllPlugins()` in `motionary/fx2`. `installPlugin()` from `motionary/marketplace` accepts these plugin objects too.
|
|
20
|
+
|
|
21
|
+
See the [CHANGELOG](../CHANGELOG.md) for the full list.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "motionary",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "10.0.0",
|
|
4
4
|
"description": "Motionary (formerly use-scroll-animate): dependency-free scroll animations + 94 animated Web Components — 214 scroll-reveal presets, card/click/button morphs, physics, page transitions, generative & sound-reactive backgrounds, cursor/gesture effects, themes, micro-interactions, <usa-player>, WebGL. React, Vue, Svelte, Solid, Angular or plain HTML.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -138,6 +138,26 @@
|
|
|
138
138
|
"default": "./dist/components/native.cjs"
|
|
139
139
|
}
|
|
140
140
|
},
|
|
141
|
+
"./core": {
|
|
142
|
+
"import": {
|
|
143
|
+
"types": "./dist/components/core.d.ts",
|
|
144
|
+
"default": "./dist/components/core.js"
|
|
145
|
+
},
|
|
146
|
+
"require": {
|
|
147
|
+
"types": "./dist/components/core.d.cts",
|
|
148
|
+
"default": "./dist/components/core.cjs"
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
"./plugins": {
|
|
152
|
+
"import": {
|
|
153
|
+
"types": "./dist/components/plugins.d.ts",
|
|
154
|
+
"default": "./dist/components/plugins.js"
|
|
155
|
+
},
|
|
156
|
+
"require": {
|
|
157
|
+
"types": "./dist/components/plugins.d.cts",
|
|
158
|
+
"default": "./dist/components/plugins.cjs"
|
|
159
|
+
}
|
|
160
|
+
},
|
|
141
161
|
"./fx": {
|
|
142
162
|
"import": {
|
|
143
163
|
"types": "./dist/components/fx2.d.ts",
|
|
@@ -1158,6 +1178,26 @@
|
|
|
1158
1178
|
"default": "./dist/components/native.cjs"
|
|
1159
1179
|
}
|
|
1160
1180
|
},
|
|
1181
|
+
"./components/core": {
|
|
1182
|
+
"import": {
|
|
1183
|
+
"types": "./dist/components/core.d.ts",
|
|
1184
|
+
"default": "./dist/components/core.js"
|
|
1185
|
+
},
|
|
1186
|
+
"require": {
|
|
1187
|
+
"types": "./dist/components/core.d.cts",
|
|
1188
|
+
"default": "./dist/components/core.cjs"
|
|
1189
|
+
}
|
|
1190
|
+
},
|
|
1191
|
+
"./components/plugins": {
|
|
1192
|
+
"import": {
|
|
1193
|
+
"types": "./dist/components/plugins.d.ts",
|
|
1194
|
+
"default": "./dist/components/plugins.js"
|
|
1195
|
+
},
|
|
1196
|
+
"require": {
|
|
1197
|
+
"types": "./dist/components/plugins.d.cts",
|
|
1198
|
+
"default": "./dist/components/plugins.cjs"
|
|
1199
|
+
}
|
|
1200
|
+
},
|
|
1161
1201
|
"./components/lite": {
|
|
1162
1202
|
"import": {
|
|
1163
1203
|
"types": "./dist/components/lite.d.ts",
|
|
@@ -1293,6 +1333,7 @@
|
|
|
1293
1333
|
"usa-codemod-6": "./bin/usa-codemod-6.mjs",
|
|
1294
1334
|
"usa-codemod-7": "./bin/usa-codemod-7.mjs",
|
|
1295
1335
|
"usa-codemod-8": "./bin/usa-codemod-8.mjs",
|
|
1296
|
-
"usa-codemod-9": "./bin/usa-codemod-9.mjs"
|
|
1336
|
+
"usa-codemod-9": "./bin/usa-codemod-9.mjs",
|
|
1337
|
+
"usa-codemod-10": "./bin/usa-codemod-10.mjs"
|
|
1297
1338
|
}
|
|
1298
1339
|
}
|