motionary 9.6.0 → 9.7.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/docs/ROADMAP.md CHANGED
@@ -8,7 +8,7 @@
8
8
  - ✅ **v9.4** — 视频动效:滚动驱动视频、帧序列;新组件 视频卡片、英雄视频。
9
9
  - ✅ **v9.5** — 无障碍动效 2.0:更细的动效偏好分级;新组件 动效偏好面板。
10
10
  - ✅ **v9.6** — 性能 3.0:OffscreenCanvas、Worker 渲染;新组件 性能监视器。
11
- - **v9.7** — 设计工具集成:Figma 插件脚手架、Framer 导出。
11
+ - ✅ **v9.7** — 设计工具集成:Figma 插件脚手架、Framer 导出。
12
12
  - **v9.8** — 原生 2.0:React Native / Flutter 组件示例。
13
13
  - **v9.9** — 10.0 预备:10.0 弃用警告、`upgrading-10.md` 与 `usa-codemod-10`。
14
14
  - **v10.0** — 全新架构:零依赖核心 < 10 KB、所有特效插件化、默认 WebGPU;npm `latest`。
@@ -1272,6 +1272,20 @@ const primes = await runInWorker((n) => { /* heavy */ return n * 2; }, 21);
1272
1272
  - `<usa-worker-canvas scene label>`: `program`, `backend`; `usa:backend`.
1273
1273
  - Perf: `offscreenRender`, `runInWorker`, `fpsMeter`; effects `idle-reveal` (`timeout`), `gpu-lift` (`lift`).
1274
1274
 
1275
+ ### v9.7 Design tool integration (`motionary/design`) + `<usa-motion-spec>`
1276
+
1277
+ ```html
1278
+ <usa-motion-spec label="Card entrance" rules="enter: fade-up 600ms ease-out stagger 80ms; hover: pop 300ms spring"></usa-motion-spec>
1279
+ ```
1280
+ ```js
1281
+ import { figmaToMotion, framerComponent, motionToCss } from 'motionary/design';
1282
+ el.dataset.motion = figmaToMotion(figmaNode.reactions); // "click: fade 300ms ease-out"
1283
+ const tsx = framerComponent(describeComponent(card), { name: 'PricingCard' });
1284
+ const css = motionToCss('enter: fade-up 600ms stagger 80ms', '.cards');
1285
+ ```
1286
+ - Figma: import `figma-plugin/manifest.json` (Plugins → Development) and run **Motionary export** on layers with prototype interactions.
1287
+ - `<usa-motion-spec rules label>`: `parsed`, `css`, `play()`; `usa:copy` { ok }.
1288
+
1275
1289
  ## Frameworks
1276
1290
 
1277
1291
  Custom elements work in every framework. Register once (e.g. in your entry file), then use the tags.
@@ -0,0 +1,9 @@
1
+ # Motionary — Figma plugin scaffold (9.7)
2
+
3
+ Turns Figma prototype interactions into Motionary `data-motion` strings.
4
+
5
+ 1. Figma → Plugins → Development → Import plugin from manifest… → pick `figma-plugin/manifest.json`.
6
+ 2. Select frames / components that have prototype interactions and run **Motionary export**.
7
+ 3. Copy the `data-motion="…"` strings into your markup and call `applyMotion()` from `motionary/dsl`.
8
+
9
+ The mapping (DISSOLVE → `fade`, SMART_ANIMATE → `scale`, MOVE_IN / SLIDE_IN / PUSH → `fade-<direction>`, durations, easings, AFTER_TIMEOUT → `load` + `delay`) is the same as `figmaToMotion()` in `motionary/design`; Framer users can generate a code component with `framerComponent()`.
@@ -0,0 +1,26 @@
1
+ // Motionary export — Figma plugin scaffold (9.7).
2
+ // Select frames / components with prototype interactions and run the plugin:
3
+ // it turns each node's reactions into a Motionary `data-motion` string
4
+ // (the same mapping as figmaToMotion() in motionary/design) and shows them
5
+ // in the UI for copying.
6
+ const EASE = { LINEAR: 'linear', EASE_IN: 'ease-in', EASE_OUT: 'ease-out', EASE_IN_AND_OUT: 'ease-in-out', EASE_OUT_BACK: 'cubic-bezier(0.34, 1.56, 0.64, 1)', GENTLE: 'cubic-bezier(0.22, 1, 0.36, 1)' };
7
+ const TRIG = { ON_CLICK: 'click', ON_PRESS: 'click', ON_HOVER: 'hover', MOUSE_ENTER: 'hover', AFTER_TIMEOUT: 'load' };
8
+ const DIR = { LEFT: 'left', RIGHT: 'right', TOP: 'down', BOTTOM: 'up' };
9
+ function toMotion(reactions) {
10
+ return (reactions || [])
11
+ .map((r) => {
12
+ const t = TRIG[r.trigger && r.trigger.type];
13
+ const tr = (r.action && r.action.transition) || (r.actions && r.actions[0] && r.actions[0].transition);
14
+ if (!t || !tr) return null;
15
+ const fx = tr.type === 'DISSOLVE' ? 'fade' : tr.type === 'SMART_ANIMATE' ? 'scale' : 'fade-' + (DIR[tr.direction] || 'up');
16
+ const parts = [t + ': ' + fx, Math.round((tr.duration || 0.3) * 1000) + 'ms'];
17
+ if (tr.easing && EASE[tr.easing.type]) parts.push(EASE[tr.easing.type]);
18
+ return parts.join(' ');
19
+ })
20
+ .filter(Boolean)
21
+ .join('; ');
22
+ }
23
+ figma.showUI(__html__, { width: 360, height: 420 });
24
+ const rows = figma.currentPage.selection.map((n) => ({ name: n.name, motion: 'reactions' in n ? toMotion(n.reactions) : '' }));
25
+ figma.ui.postMessage({ rows });
26
+ figma.ui.onmessage = (m) => m === 'close' && figma.closePlugin();
@@ -0,0 +1,9 @@
1
+ {
2
+ "name": "Motionary export",
3
+ "id": "motionary-export",
4
+ "api": "1.0.0",
5
+ "main": "code.js",
6
+ "ui": "ui.html",
7
+ "editorType": ["figma"],
8
+ "networkAccess": { "allowedDomains": ["none"] }
9
+ }
@@ -0,0 +1,10 @@
1
+ <style>body{font:12px system-ui;margin:12px}code{display:block;padding:6px;margin:4px 0 10px;background:#f1f5f9;border-radius:6px;white-space:pre-wrap}</style>
2
+ <h3>Motionary export</h3>
3
+ <div id="out">Select layers with prototype interactions…</div>
4
+ <button onclick="parent.postMessage({ pluginMessage: 'close' }, '*')">Close</button>
5
+ <script>
6
+ onmessage = (e) => {
7
+ const rows = (e.data.pluginMessage || {}).rows || [];
8
+ document.getElementById('out').innerHTML = rows.length ? rows.map((r) => `<b>${r.name}</b><code>data-motion="${r.motion || '—'}"</code>`).join('') : 'Nothing selected.';
9
+ };
10
+ </script>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "motionary",
3
- "version": "9.6.0",
3
+ "version": "9.7.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",
@@ -118,6 +118,16 @@
118
118
  "default": "./dist/components/marketplace.cjs"
119
119
  }
120
120
  },
121
+ "./design": {
122
+ "import": {
123
+ "types": "./dist/components/design.d.ts",
124
+ "default": "./dist/components/design.js"
125
+ },
126
+ "require": {
127
+ "types": "./dist/components/design.d.cts",
128
+ "default": "./dist/components/design.cjs"
129
+ }
130
+ },
121
131
  "./fx": {
122
132
  "import": {
123
133
  "types": "./dist/components/fx2.d.ts",
@@ -1118,6 +1128,16 @@
1118
1128
  "default": "./dist/components/fx-perf.cjs"
1119
1129
  }
1120
1130
  },
1131
+ "./components/design": {
1132
+ "import": {
1133
+ "types": "./dist/components/design.d.ts",
1134
+ "default": "./dist/components/design.js"
1135
+ },
1136
+ "require": {
1137
+ "types": "./dist/components/design.d.cts",
1138
+ "default": "./dist/components/design.cjs"
1139
+ }
1140
+ },
1121
1141
  "./components/lite": {
1122
1142
  "import": {
1123
1143
  "types": "./dist/components/lite.d.ts",
@@ -1158,7 +1178,8 @@
1158
1178
  "README_zh.md",
1159
1179
  "README_ja.md",
1160
1180
  "LICENSE",
1161
- "CHANGELOG.md"
1181
+ "CHANGELOG.md",
1182
+ "figma-plugin"
1162
1183
  ],
1163
1184
  "sideEffects": [
1164
1185
  "*.css",