motionary 10.5.0 → 10.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/AGENTS.md +2 -0
- package/CHANGELOG.md +28 -0
- package/README.md +95 -1
- package/bin/motionary-mcp.mjs +160 -11
- package/dist/chunks/{anim-image-DuxvYhq6.cjs → anim-image-CFGpUX7t.cjs} +2 -2
- package/dist/chunks/{anim-image-DuxvYhq6.cjs.map → anim-image-CFGpUX7t.cjs.map} +1 -1
- package/dist/chunks/{anim-image-BlNPv4JG.js → anim-image-CXDD19FH.js} +2 -2
- package/dist/chunks/{anim-image-BlNPv4JG.js.map → anim-image-CXDD19FH.js.map} +1 -1
- package/dist/chunks/{keyframes-Ce1s05n3.cjs → keyframes-DdwGY1gr.cjs} +2 -2
- package/dist/chunks/{keyframes-Ce1s05n3.cjs.map → keyframes-DdwGY1gr.cjs.map} +1 -1
- package/dist/chunks/{keyframes-B8ITIAVa.js → keyframes-DwR6GPej.js} +2 -2
- package/dist/chunks/{keyframes-B8ITIAVa.js.map → keyframes-DwR6GPej.js.map} +1 -1
- package/dist/chunks/{registry-DXdFb2fJ.js → registry-D87dP_aR.js} +3 -3
- package/dist/chunks/{registry-DXdFb2fJ.js.map → registry-D87dP_aR.js.map} +1 -1
- package/dist/chunks/{registry-VhfPSI0v.cjs → registry-DhKZCitb.cjs} +2 -2
- package/dist/chunks/{registry-VhfPSI0v.cjs.map → registry-DhKZCitb.cjs.map} +1 -1
- package/dist/chunks/{ticker-C5RMHMW7.js → ticker-CJYI5Pxc.js} +2 -2
- package/dist/chunks/{ticker-C5RMHMW7.js.map → ticker-CJYI5Pxc.js.map} +1 -1
- package/dist/chunks/{ticker-DvmC6WLS.cjs → ticker-jD9_A9Rh.cjs} +2 -2
- package/dist/chunks/{ticker-DvmC6WLS.cjs.map → ticker-jD9_A9Rh.cjs.map} +1 -1
- package/dist/chunks/{tween-_BGIl6hK.cjs → tween-Dk0QmNe9.cjs} +2 -2
- package/dist/chunks/{tween-_BGIl6hK.cjs.map → tween-Dk0QmNe9.cjs.map} +1 -1
- package/dist/chunks/{tween-CPtm-EdT.js → tween-_Lld1MsF.js} +2 -2
- package/dist/chunks/{tween-CPtm-EdT.js.map → tween-_Lld1MsF.js.map} +1 -1
- package/dist/components/ai.cjs +314 -0
- package/dist/components/ai.cjs.map +1 -0
- package/dist/components/ai.d.cts +58 -0
- package/dist/components/ai.d.ts +58 -0
- package/dist/components/ai.js +311 -0
- package/dist/components/ai.js.map +1 -0
- package/dist/components/lite.cjs +179 -0
- package/dist/components/lite.cjs.map +1 -1
- package/dist/components/lite.js +176 -1
- package/dist/components/lite.js.map +1 -1
- package/dist/components/tokens.cjs +179 -0
- package/dist/components/tokens.cjs.map +1 -1
- package/dist/components/tokens.d.cts +36 -1
- package/dist/components/tokens.d.ts +36 -1
- package/dist/components/tokens.js +176 -1
- package/dist/components/tokens.js.map +1 -1
- package/dist/components/widgets.cjs +985 -221
- package/dist/components/widgets.cjs.map +1 -1
- package/dist/components/widgets.d.cts +606 -4
- package/dist/components/widgets.d.ts +606 -4
- package/dist/components/widgets.js +976 -222
- package/dist/components/widgets.js.map +1 -1
- package/dist/components.cjs +4 -0
- package/dist/components.cjs.map +1 -1
- package/dist/components.d.cts +36 -1
- package/dist/components.d.ts +36 -1
- package/dist/components.js +1 -1
- package/dist/components.umd.js +2 -2
- package/dist/components.umd.js.map +1 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/llms-full.txt +221 -1
- package/dist/llms.txt +11 -2
- package/dist/manifest.json +580 -1
- package/dist/runtime/format-apng.cjs +4 -4
- package/dist/runtime/format-apng.js +4 -4
- package/dist/runtime/format-css.cjs +4 -4
- package/dist/runtime/format-css.js +4 -4
- package/dist/runtime/format-gif.cjs +4 -4
- package/dist/runtime/format-gif.js +4 -4
- package/dist/runtime/format-gltf.cjs +1 -1
- package/dist/runtime/format-gltf.js +1 -1
- package/dist/runtime/format-motion.cjs +4 -4
- package/dist/runtime/format-motion.js +4 -4
- package/dist/runtime/format-obj.cjs +1 -1
- package/dist/runtime/format-obj.js +1 -1
- package/dist/runtime/format-scene.cjs +241 -0
- package/dist/runtime/format-scene.cjs.map +1 -0
- package/dist/runtime/format-scene.d.cts +349 -0
- package/dist/runtime/format-scene.d.ts +349 -0
- package/dist/runtime/format-scene.iife.js +2 -0
- package/dist/runtime/format-scene.iife.js.map +1 -0
- package/dist/runtime/format-scene.js +233 -0
- package/dist/runtime/format-scene.js.map +1 -0
- package/dist/runtime/format-sprite.cjs +3 -3
- package/dist/runtime/format-sprite.js +3 -3
- package/dist/runtime/format-svg.cjs +3 -3
- package/dist/runtime/format-svg.js +3 -3
- package/dist/runtime/format-webp.cjs +4 -4
- package/dist/runtime/format-webp.js +4 -4
- package/dist/runtime/gl.cjs +1 -1
- package/dist/runtime/gl.js +1 -1
- package/dist/runtime/physics.cjs +739 -0
- package/dist/runtime/physics.cjs.map +1 -0
- package/dist/runtime/physics.d.cts +250 -0
- package/dist/runtime/physics.d.ts +250 -0
- package/dist/runtime/physics.iife.js +2 -0
- package/dist/runtime/physics.iife.js.map +1 -0
- package/dist/runtime/physics.js +731 -0
- package/dist/runtime/physics.js.map +1 -0
- package/dist/runtime/scroll.cjs +2 -2
- package/dist/runtime/scroll.js +2 -2
- package/dist/runtime/smooth.cjs +1 -1
- package/dist/runtime/smooth.js +1 -1
- package/dist/runtime/text.cjs +1 -1
- package/dist/runtime/text.js +1 -1
- package/dist/runtime/vector.cjs +704 -0
- package/dist/runtime/vector.cjs.map +1 -0
- package/dist/runtime/vector.d.cts +306 -0
- package/dist/runtime/vector.d.ts +306 -0
- package/dist/runtime/vector.iife.js +2 -0
- package/dist/runtime/vector.iife.js.map +1 -0
- package/dist/runtime/vector.js +692 -0
- package/dist/runtime/vector.js.map +1 -0
- package/dist/runtime.cjs +3 -3
- package/dist/runtime.d.cts +1 -1
- package/dist/runtime.d.ts +1 -1
- package/dist/runtime.iife.js +1 -1
- package/dist/runtime.iife.js.map +1 -1
- package/dist/runtime.js +5 -5
- package/dist/widgets.umd.js +1 -1
- package/dist/widgets.umd.js.map +1 -1
- package/docs/ROADMAP.md +2 -2
- package/docs/components/README.md +6 -1
- package/docs/components/usa-lottie-player.md +60 -0
- package/docs/components/usa-motion-prompt.md +32 -0
- package/docs/components/usa-physics-playground.md +63 -0
- package/docs/components/usa-rive.md +57 -0
- package/docs/components/usa-token-editor.md +32 -0
- package/docs/components.md +116 -0
- package/docs/runtime/format-scene.md +59 -0
- package/docs/runtime/physics.md +61 -0
- package/docs/runtime/rive.md +55 -0
- package/docs/runtime/vector.md +67 -0
- package/package.json +46 -2
package/AGENTS.md
CHANGED
|
@@ -63,3 +63,5 @@ Declarative motion without components (10.2):
|
|
|
63
63
|
## MCP server
|
|
64
64
|
|
|
65
65
|
If your client speaks MCP, add `motionary-mcp` (read-only, ships with the package): `{ "command": "npx", "args": ["-y", "-p", "motionary", "motionary-mcp"] }`. Use `search_components` → `get_component` → `scaffold_snippet` (prerequisites are already in the snippet, in order). See docs/mcp.md.
|
|
66
|
+
|
|
67
|
+
motionary-mcp 2.0 (10.7): `suggest_motion` turns a description (English or Chinese) into motion code and component suggestions; run `validate_snippet` on any code you write with `<usa-*>` components before handing it over — it catches unknown tags / attributes and missing or mis-ordered prerequisites.
|
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.7.0] - 2026-10-09
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
- **AI-assisted motion — `motionary/components/ai`**: `describeMotion(text)` turns a short description in English or Chinese ("fade the cards up slowly when they scroll into view, one after another" / "卡片从下往上依次淡入") into a motion spec — effect, direction, distance, duration, delay, easing, trigger, repeat, stagger, Web Animations keyframes + options, a CSS rule with a `prefers-reduced-motion` guard, and the Motionary components that implement it; `motionSnippet(intent, 'waapi' | 'css' | 'component')` gives ready code. A small deterministic parser — **no model, no network**, pure (SSR / workers). Pinned by an **evaluation set** of 30 English + Chinese prompts (`test/fixtures/ai-eval.json`) that CI runs (≥ 90 % must be fully right; 30 / 30 at release).
|
|
14
|
+
- **`motionary-mcp` 2.0** (`npx -y -p motionary motionary-mcp`): new read-only tools **`suggest_motion`** (the parser above, with prerequisite-aware component suggestions) and **`validate_snippet`** (static analysis of HTML / ESM / JSX / Vue / Svelte: unknown components with "did you mean" suggestions, unknown attributes, missing or mis-ordered prerequisites, a runtime module imported but never `use()`d, components never defined, hand-written animation without a reduced-motion path). Verified with the official MCP SDK client over stdio.
|
|
15
|
+
- **`motionary/runtime/physics`** — a 2D rigid-body engine written for Motionary (own implementation and API; no Matter.js / Box2D code): circles, boxes and convex polygons; static / dynamic / kinematic bodies; mass from density, restitution, Coulomb friction, sensors, collision categories / masks, sleeping; sort-and-sweep broad phase + SAT narrow phase with clipped 2-point manifolds and warm-started accumulated impulses; distance / spring / pin constraints and a pointer-drag constraint; fixed time step with an accumulator (same result at any frame rate), `world.run()` on the shared ticker. CDN `dist/runtime/physics.iife.js`; fixed gzip budget.
|
|
16
|
+
- **`motionary/runtime/format-scene`** — the versioned **`motionary-scene@1`** JSON format (world, named materials, bodies, constraints, per-body style): `validateScene()` (lists every problem, never throws), `migrateScene()` (unversioned / `@0` drafts → `@1`, with a change list), `parseScene()`, `sceneToWorld()`, `worldToScene()`. Fixed gzip budget.
|
|
17
|
+
- **New components (10.7)** in `motionary/components/widgets`: `<usa-physics-playground>` — presets (balls, pyramid, pendulum, dominoes), `src` or an inline `<script type="application/json">` scene, `gravity`, `spawn`, `paused`; drag bodies, tap to spawn, arrow keys nudge; `world`, `bodies`, `toScene()`, `reset()`, `play()` / `pause()`, `usa:collision` (**Requires: motionary/runtime/physics + motionary/runtime/format-scene**); `<usa-motion-prompt>` — type a description, get a live preview and WAAPI / CSS / component code with a copy button (`value`, `format`, `placeholder`, `label`; `usa:suggest`, `usa:copy`).
|
|
18
|
+
- Prerequisites for both runtime modules appear in all five places (gallery card, Store detail with the **Requires:** badge, `docs/runtime/physics.md` + `docs/runtime/format-scene.md` with compatibility tables, README, AI manifest).
|
|
19
|
+
|
|
20
|
+
### Fixed
|
|
21
|
+
- `motionary-mcp` listed `<usa-rive>`'s prerequisite (10.6, an official runtime) as `motionary/runtime/rive` and `scaffold_snippet` emitted an import of that non-existent module. Prerequisites are now peer-aware: `@rive-app/canvas`, its install command and the `provideRiveRuntime(() => import('@rive-app/canvas'))` line.
|
|
22
|
+
|
|
23
|
+
### Accessibility
|
|
24
|
+
- `<usa-physics-playground>` is a labelled, focusable canvas (arrow keys nudge the last body touched); under reduced motion the scene is settled off-screen and drawn once, and dragging advances it only while you move. `<usa-motion-prompt>` uses a labelled input, announces suggestions in a polite live region, shows the end state instead of animating under reduced motion, and every code sample it generates carries a `prefers-reduced-motion` guard.
|
|
25
|
+
|
|
26
|
+
## [10.6.0] - 2026-10-09
|
|
27
|
+
|
|
28
|
+
### Added
|
|
29
|
+
- **Motion design tokens 2.0 — W3C Design Tokens (DTCG 2025.10)** in `motionary/components/tokens`: `importDesignTokens()` (resolves `{group.token}` aliases, also inside composite values; `$type` inherited from groups; springs from `$extensions["org.motionary"]`), `exportDesignTokens()` (stable `2025.10` shape — durations as `{ value, unit: "ms" }` — or the earlier draft `"150ms"`; optional `transition` composites), `validateDesignTokens()` (unknown `$type`, malformed durations / cubic béziers, broken or circular aliases — listed, not thrown) and `resolveTokenAliases()`.
|
|
30
|
+
- **`motionary/runtime/vector`** — a Lottie (bodymovin JSON) + **dotLottie** player written for Motionary (own Canvas 2D renderer, no lottie-web code): shape / solid / null / image / precomp layers (time stretch + time remap), parenting, transforms incl. split and spatial-bezier positions, paths / rectangles / ellipses / stars, fills and strokes (dashes), linear + radial gradients, **trim paths**, **masks** (add / subtract / intersect / inverted / opacity), **track mattes** (alpha, alpha inverted; luma approximated), per-dimension bezier and hold keyframes; `.lottie` zip archives (stored + deflate via the native `DecompressionStream`, manifest v1 / v2, several animations, embedded images); `lottiePlayer()` is a runtime timeline (seek, reverse, scrub, markers → segments); `inspectLottie()` lists what a file uses that the renderer skips (text, expressions, effects, 3D, merge paths, repeaters — text layers and an expression subset follow in 10.8). CDN `dist/runtime/vector.iife.js`; fixed gzip budget.
|
|
31
|
+
- **Official Rive runtime as an optional peer dependency.** `.riv` is Rive's proprietary binary format, so Motionary does not reimplement it: `<usa-rive>` plays `.riv` files through the official MIT-licensed `@rive-app/canvas` (declared in `peerDependencies` with `peerDependenciesMeta.optional`, never bundled). It is lazy-loaded when the first `<usa-rive>` mounts — from `provideRiveRuntime(() => import('@rive-app/canvas'))` (bundlers), `window.rive` (the official CDN script), an import map, or a `runtime-src` URL — and a missing runtime gives a clear message in place (install command, the `provideRiveRuntime()` line, the pinned CDN URL) plus `usa:runtime-missing`. Its prerequisites appear in all five places (gallery card, Store detail with a **Requires: @rive-app/canvas** badge, `docs/runtime/rive.md`, README, AI manifest); prerequisite entries now have a `kind: 'peer'` for official runtimes.
|
|
32
|
+
- **New components (10.6)** in `motionary/components/widgets`: `<usa-lottie-player>` — `src` (.json / .lottie), `animation`, `autoplay`, `loop`, `speed`, `mode` (normal · bounce), `segment` (frames or a marker), `hover`, `scrub`, `fit`, `background` (**Requires: motionary/runtime/vector**); `<usa-rive>` — `src`, `artboard`, `animation`, `state-machine`, `autoplay`, `fit`, `runtime-src`, `input(name)` (**Requires: @rive-app/canvas**, optional peer); `<usa-token-editor>` — edit duration / easing tokens with live previews, export / import DTCG (`format`, `groups`, `apply`).
|
|
33
|
+
- Test fixtures: a self-made Lottie + dotLottie that exercise one supported feature per region (MIT), and Rive's own `message_icon.riv` sample (MIT, © Rive) — sources and licences in `test/fixtures/formats/CREDITS.md`.
|
|
34
|
+
|
|
35
|
+
### Accessibility
|
|
36
|
+
- `<usa-lottie-player>` and `<usa-rive>` draw into a labelled `img` canvas (`label`); under reduced motion they show the first frame and do not autoplay; Lottie renders only while on screen. `<usa-token-editor>` uses labelled inputs and announces import problems in a polite live region; its previews are decorative.
|
|
37
|
+
|
|
10
38
|
## [10.5.0] - 2026-10-09
|
|
11
39
|
|
|
12
40
|
### Added
|
package/README.md
CHANGED
|
@@ -187,6 +187,10 @@ Motionary ships its own zero-dependency animation runtime — shared ticker, twe
|
|
|
187
187
|
| [WebGL2 scene renderer](docs/runtime/gl.md) | `motionary/runtime/gl` | `https://cdn.jsdelivr.net/npm/motionary@10/dist/runtime/gl.iife.js` | `use(gl);` | 9.0 KB |
|
|
188
188
|
| [glTF 2.0 / GLB loader](docs/runtime/format-gltf.md) | `motionary/runtime/format-gltf` | `https://cdn.jsdelivr.net/npm/motionary@10/dist/runtime/format-gltf.iife.js` | `use(formatGltf);` | 6.0 KB |
|
|
189
189
|
| [OBJ / MTL loader](docs/runtime/format-obj.md) | `motionary/runtime/format-obj` | `https://cdn.jsdelivr.net/npm/motionary@10/dist/runtime/format-obj.iife.js` | `use(formatObj);` | 3.0 KB |
|
|
190
|
+
| [Lottie + dotLottie player](docs/runtime/vector.md) | `motionary/runtime/vector` | `https://cdn.jsdelivr.net/npm/motionary@10/dist/runtime/vector.iife.js` | `use(vector);` | 12.0 KB |
|
|
191
|
+
| [Official Rive runtime](docs/runtime/rive.md) | `@rive-app/canvas` | `https://unpkg.com/@rive-app/canvas@2.44.1/rive.js` | `provideRiveRuntime(() => import('@rive-app/canvas')); // lazy: fetched when the first <usa-rive> mounts` | official runtime (not bundled) |
|
|
192
|
+
| [2D rigid-body physics](docs/runtime/physics.md) | `motionary/runtime/physics` | `https://cdn.jsdelivr.net/npm/motionary@10/dist/runtime/physics.iife.js` | `use(physics);` | 10.0 KB |
|
|
193
|
+
| [Scene JSON (motionary-scene@1)](docs/runtime/format-scene.md) | `motionary/runtime/format-scene` | `https://cdn.jsdelivr.net/npm/motionary@10/dist/runtime/format-scene.iife.js` | `use(formatScene);` | 3.0 KB |
|
|
190
194
|
|
|
191
195
|
Install once: `npm i motionary`. Plain HTML: load `runtime.iife.js` first, then the module files (each registers itself).
|
|
192
196
|
|
|
@@ -347,6 +351,96 @@ defineGlScene(); // registers <usa-gl-scene> — after the prerequisites
|
|
|
347
351
|
<usa-gl-scene src="/models/chair.glb" controls auto-rotate="20" label="Chair"></usa-gl-scene>
|
|
348
352
|
```
|
|
349
353
|
|
|
354
|
+
#### `<usa-lottie-player>` — Requires: motionary/runtime/vector
|
|
355
|
+
|
|
356
|
+
- **Install:** `npm i motionary`
|
|
357
|
+
- **Import order & registration:** Register the core first, then the module: use(vector) also registers the core. CDN: load runtime.iife.js, then runtime/vector.iife.js (it registers itself).
|
|
358
|
+
|
|
359
|
+
```js
|
|
360
|
+
import { use } from 'motionary/runtime';
|
|
361
|
+
import { vector } from 'motionary/runtime/vector';
|
|
362
|
+
import { defineLottiePlayer } from 'motionary/components/widgets';
|
|
363
|
+
|
|
364
|
+
use(vector);
|
|
365
|
+
defineLottiePlayer(); // registers <usa-lottie-player> — after the prerequisites
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
- **CDN:**
|
|
369
|
+
|
|
370
|
+
```html
|
|
371
|
+
<script src="https://cdn.jsdelivr.net/npm/motionary@10/dist/runtime.iife.js"></script>
|
|
372
|
+
<script src="https://cdn.jsdelivr.net/npm/motionary@10/dist/runtime/vector.iife.js"></script>
|
|
373
|
+
<!-- then the component bundles -->
|
|
374
|
+
<script src="https://unpkg.com/motionary@10/dist/components.umd.js"></script>
|
|
375
|
+
<script src="https://unpkg.com/motionary@10/dist/widgets.umd.js"></script>
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
- **Minimal example:**
|
|
379
|
+
|
|
380
|
+
```html
|
|
381
|
+
<usa-lottie-player src="/anim/hero.lottie" autoplay loop label="Hero animation"></usa-lottie-player>
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
#### `<usa-rive>` — Requires: @rive-app/canvas
|
|
385
|
+
|
|
386
|
+
- **Install:** `npm i @rive-app/canvas`
|
|
387
|
+
- **Import order & registration:** Install the official runtime next to motionary, then hand <usa-rive> a lazy loader with provideRiveRuntime(() => import('@rive-app/canvas')) before the element mounts — your bundler splits the runtime into its own chunk, fetched only when the first <usa-rive> appears. Without a bundler: load the official rive.js from a CDN before the component bundles (window.rive), use an import map, or set runtime-src on the element. Missing → a clear message in place + usa:runtime-missing.
|
|
388
|
+
|
|
389
|
+
```js
|
|
390
|
+
import { provideRiveRuntime } from 'motionary/components/widgets';
|
|
391
|
+
import { defineRive } from 'motionary/components/widgets';
|
|
392
|
+
|
|
393
|
+
provideRiveRuntime(() => import('@rive-app/canvas')); // lazy: fetched when the first <usa-rive> mounts
|
|
394
|
+
defineRive(); // registers <usa-rive> — after the prerequisites
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
- **CDN:**
|
|
398
|
+
|
|
399
|
+
```html
|
|
400
|
+
<script src="https://unpkg.com/@rive-app/canvas@2.44.1/rive.js"></script>
|
|
401
|
+
<!-- then the component bundles -->
|
|
402
|
+
<script src="https://unpkg.com/motionary@10/dist/components.umd.js"></script>
|
|
403
|
+
<script src="https://unpkg.com/motionary@10/dist/widgets.umd.js"></script>
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
- **Minimal example:**
|
|
407
|
+
|
|
408
|
+
```html
|
|
409
|
+
<usa-rive src="/anim/icon.riv" state-machine="State Machine 1" autoplay label="Icon"></usa-rive>
|
|
410
|
+
```
|
|
411
|
+
|
|
412
|
+
#### `<usa-physics-playground>` — Requires: motionary/runtime/physics + motionary/runtime/format-scene
|
|
413
|
+
|
|
414
|
+
- **Install:** `npm i motionary`
|
|
415
|
+
- **Import order & registration:** Register the core first, then the module: use(physics) also registers the core. CDN: load runtime.iife.js, then runtime/physics.iife.js (it registers itself). Register the core first, then the module: use(formatScene) also registers the core. CDN: load runtime.iife.js, then runtime/format-scene.iife.js (it registers itself).
|
|
416
|
+
|
|
417
|
+
```js
|
|
418
|
+
import { use } from 'motionary/runtime';
|
|
419
|
+
import { physics } from 'motionary/runtime/physics';
|
|
420
|
+
import { formatScene } from 'motionary/runtime/format-scene';
|
|
421
|
+
import { definePhysicsPlayground } from 'motionary/components/widgets';
|
|
422
|
+
|
|
423
|
+
use(physics, formatScene);
|
|
424
|
+
definePhysicsPlayground(); // registers <usa-physics-playground> — after the prerequisites
|
|
425
|
+
```
|
|
426
|
+
|
|
427
|
+
- **CDN:**
|
|
428
|
+
|
|
429
|
+
```html
|
|
430
|
+
<script src="https://cdn.jsdelivr.net/npm/motionary@10/dist/runtime.iife.js"></script>
|
|
431
|
+
<script src="https://cdn.jsdelivr.net/npm/motionary@10/dist/runtime/physics.iife.js"></script>
|
|
432
|
+
<script src="https://cdn.jsdelivr.net/npm/motionary@10/dist/runtime/format-scene.iife.js"></script>
|
|
433
|
+
<!-- then the component bundles -->
|
|
434
|
+
<script src="https://unpkg.com/motionary@10/dist/components.umd.js"></script>
|
|
435
|
+
<script src="https://unpkg.com/motionary@10/dist/widgets.umd.js"></script>
|
|
436
|
+
```
|
|
437
|
+
|
|
438
|
+
- **Minimal example:**
|
|
439
|
+
|
|
440
|
+
```html
|
|
441
|
+
<usa-physics-playground preset="pyramid" spawn label="Knock the pyramid over"></usa-physics-playground>
|
|
442
|
+
```
|
|
443
|
+
|
|
350
444
|
<!-- runtime:end -->
|
|
351
445
|
|
|
352
446
|
## Accessibility & reduced motion
|
|
@@ -380,7 +474,7 @@ Evergreen browsers since 2023: Chrome / Edge ≥ 111, Safari ≥ 16.4, Firefox
|
|
|
380
474
|
|
|
381
475
|
## Documentation
|
|
382
476
|
|
|
383
|
-
- **MCP server:** `npx -y -p motionary motionary-mcp` — read-only component catalog for MCP clients (search, API, prerequisite-aware snippets): [docs/mcp.md](docs/mcp.md).
|
|
477
|
+
- **MCP server:** `npx -y -p motionary motionary-mcp` — read-only component catalog for MCP clients (search, API, prerequisite-aware snippets; 2.0 adds `suggest_motion` and `validate_snippet`): [docs/mcp.md](docs/mcp.md).
|
|
384
478
|
- **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.
|
|
385
479
|
|
|
386
480
|
- [API reference](./docs/API.md) — every export, option and `data-sa-*` attribute
|
package/bin/motionary-mcp.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// motionary-mcp (10.4) — a read-only Model Context Protocol server for the
|
|
2
|
+
// motionary-mcp 2.0 (10.7; 1.0 in 10.4) — a read-only Model Context Protocol server for the
|
|
3
3
|
// Motionary component catalog. Zero dependencies: speaks MCP (JSON-RPC 2.0,
|
|
4
4
|
// newline-delimited) over stdio and answers from the AI manifest that ships
|
|
5
5
|
// in the package (dist/manifest.json, the same data as components.json /
|
|
@@ -9,15 +9,20 @@
|
|
|
9
9
|
// MOTIONARY_MANIFEST=/path/manifest.json motionary-mcp (use another manifest)
|
|
10
10
|
//
|
|
11
11
|
// Tools: list_components, search_components, get_component, get_example,
|
|
12
|
-
// scaffold_snippet (prerequisites included automatically).
|
|
12
|
+
// scaffold_snippet (prerequisites included automatically); 2.0 (10.7) adds
|
|
13
|
+
// suggest_motion (natural language → motion spec + code, the deterministic
|
|
14
|
+
// parser from motionary/components/ai — no model, no network) and
|
|
15
|
+
// validate_snippet (unknown tags / attributes, missing or mis-ordered
|
|
16
|
+
// prerequisites, unregistered components, reduced-motion handling).
|
|
13
17
|
// Resources: motionary://manifest, motionary://llms.txt, motionary://component/<tag>.
|
|
14
18
|
import { readFileSync, existsSync } from 'node:fs';
|
|
15
19
|
import { fileURLToPath } from 'node:url';
|
|
16
20
|
import { dirname, join } from 'node:path';
|
|
17
21
|
import { createInterface } from 'node:readline';
|
|
22
|
+
import { pathToFileURL } from 'node:url';
|
|
18
23
|
|
|
19
24
|
const HERE = dirname(fileURLToPath(import.meta.url));
|
|
20
|
-
const SERVER = { name: 'motionary-mcp', version: '0.
|
|
25
|
+
const SERVER = { name: 'motionary-mcp', version: '2.0.0' };
|
|
21
26
|
const PROTOCOLS = ['2025-06-18', '2025-03-26', '2024-11-05'];
|
|
22
27
|
|
|
23
28
|
export function loadManifest(path = process.env.MOTIONARY_MANIFEST || join(HERE, '../dist/manifest.json')) {
|
|
@@ -31,15 +36,24 @@ const tagOf = (s) => {
|
|
|
31
36
|
const t = norm(s).trim().replace(/^<|\/?>$/g, '');
|
|
32
37
|
return t.startsWith('usa-') ? t : `usa-${t}`;
|
|
33
38
|
};
|
|
34
|
-
|
|
39
|
+
// 2.0: a requirement id is a motionary/runtime module or (10.6+) an official runtime (kind 'peer', e.g. rive → @rive-app/canvas)
|
|
40
|
+
let MOD = new Map();
|
|
41
|
+
const indexModules = (m) => {
|
|
42
|
+
if (MOD.m !== m) (MOD = new Map((m.runtimeModules || []).map((x) => [x.id, x]))), (MOD.m = m);
|
|
43
|
+
};
|
|
44
|
+
const isPeer = (r) => r.startsWith('@') || MOD.get(r)?.kind === 'peer';
|
|
45
|
+
const reqLabel = (r) => (r === 'core' ? 'motionary/runtime' : MOD.get(r)?.kind === 'peer' ? MOD.get(r).label : r.includes('/') || r.startsWith('@') ? r : `motionary/runtime/${r}`);
|
|
46
|
+
const brief = (c) => ({ tag: c.tag, title: c.title, category: c.category, import: c.import.path, requires: c.requires.map(reqLabel), since: c.since, description: c.description.slice(0, 200) });
|
|
35
47
|
|
|
36
48
|
export function findComponent(m, tag) {
|
|
49
|
+
indexModules(m);
|
|
37
50
|
const t = tagOf(tag);
|
|
38
51
|
return m.components.find((c) => c.tag === t) || m.components.find((c) => c.id === norm(tag));
|
|
39
52
|
}
|
|
40
53
|
|
|
41
54
|
/** Rank components for a free-text query (tag, title, keywords, description, category). */
|
|
42
55
|
export function searchComponents(m, query, limit = 10) {
|
|
56
|
+
indexModules(m);
|
|
43
57
|
const words = norm(query).split(/[^a-z0-9\u00c0-\uffff-]+/).filter(Boolean);
|
|
44
58
|
if (!words.length) return [];
|
|
45
59
|
const scored = m.components.map((c) => {
|
|
@@ -72,14 +86,17 @@ const runtimeImports = (ids) => {
|
|
|
72
86
|
|
|
73
87
|
/** A ready-to-paste snippet for one or more components, prerequisites first. */
|
|
74
88
|
export function scaffold(m, tags, framework = 'esm') {
|
|
89
|
+
indexModules(m);
|
|
75
90
|
if (!FRAMEWORKS.includes(framework)) throw new Error(`framework must be one of ${FRAMEWORKS.join(', ')}`);
|
|
76
91
|
const comps = tags.map((t) => {
|
|
77
92
|
const c = findComponent(m, t);
|
|
78
93
|
if (!c) throw new Error(`unknown component ${t} — use search_components first`);
|
|
79
94
|
return c;
|
|
80
95
|
});
|
|
81
|
-
const req = [...new Set(comps.flatMap((c) => c.requires))].filter((r) => !r
|
|
82
|
-
const
|
|
96
|
+
const req = [...new Set(comps.flatMap((c) => c.requires))].filter((r) => !isPeer(r));
|
|
97
|
+
const peerIds = [...new Set(comps.flatMap((c) => c.requires))].filter(isPeer);
|
|
98
|
+
const peers = peerIds.map(reqLabel);
|
|
99
|
+
const peerSetup = peerIds.map((r) => MOD.get(r)).filter(Boolean);
|
|
83
100
|
const needsWidgets = comps.some((c) => /widgets\.umd/.test(c.cdn));
|
|
84
101
|
const markup = comps.map((c) => c.example).join('\n');
|
|
85
102
|
const byPath = new Map();
|
|
@@ -88,25 +105,147 @@ export function scaffold(m, tags, framework = 'esm') {
|
|
|
88
105
|
const defCalls = [...new Set(comps.map((c) => c.import.register))];
|
|
89
106
|
const install = ['npm i motionary', ...peers.map((p) => `npm i ${p}`)].join(' && ');
|
|
90
107
|
const rt = req.length ? runtimeImports(req) : null;
|
|
91
|
-
const prereqNote = req.length ? `Prerequisites: ${req.map(
|
|
108
|
+
const prereqNote = req.length || peers.length ? `Prerequisites: ${[...req.map(reqLabel), ...peers].join(', ')} — register them before the components mount.` : 'No prerequisites.';
|
|
92
109
|
let code;
|
|
93
110
|
if (framework === 'html') {
|
|
94
111
|
code = [
|
|
95
112
|
'<!-- ' + prereqNote + ' -->',
|
|
96
113
|
...(req.length ? runtimeCdn(m, req) : []),
|
|
114
|
+
...peerSetup.map((p) => `<!-- ${p.label} (official runtime, lazy): -->\n${p.cdn}`),
|
|
97
115
|
`<script src="${m.cdn.components}"></script>`,
|
|
98
116
|
...(needsWidgets ? [`<script src="${m.cdn.widgets}"></script>`] : []),
|
|
99
117
|
'',
|
|
100
118
|
markup,
|
|
101
119
|
].join('\n');
|
|
102
120
|
} else {
|
|
103
|
-
const setup = [...(rt ? [...rt.lines] : []), ...defImports, '', ...(rt ? [rt.register + ' // prerequisites first'] : []), ...defCalls].join('\n');
|
|
121
|
+
const setup = [...(rt ? [...rt.lines] : []), ...peerSetup.map((p) => p.import).filter((l) => !defImports.includes(l)), ...defImports, '', ...(rt ? [rt.register + ' // prerequisites first'] : []), ...peerSetup.map((p) => p.register), ...defCalls].join('\n');
|
|
104
122
|
if (framework === 'esm') code = `// ${install}\n${setup}\n\n/* HTML:\n${markup}\n*/`;
|
|
105
123
|
else if (framework === 'react') code = `// ${install}\n${setup}\n\nexport function Demo() {\n return (\n <>\n${markup.split('\n').map((l) => ' ' + l.replace(/\bclass=/g, 'className=')).join('\n')}\n </>\n );\n}`;
|
|
106
124
|
else if (framework === 'vue') code = `<!-- ${install} -->\n<script setup>\n${setup}\n</script>\n\n<template>\n${markup.split('\n').map((l) => ' ' + l).join('\n')}\n</template>\n<!-- vite.config: vue({ template: { compilerOptions: { isCustomElement: (t) => t.startsWith('usa-') } } }) -->`;
|
|
107
125
|
else code = `<!-- ${install} -->\n<script>\n${setup}\n</script>\n\n${markup}`;
|
|
108
126
|
}
|
|
109
|
-
return { framework, components: comps.map((c) => c.tag), install, prerequisites: req.map(
|
|
127
|
+
return { framework, components: comps.map((c) => c.tag), install, prerequisites: req.map(reqLabel).concat(peers), code };
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// ---------------------------------------------------------------- 2.0: suggest_motion + validate_snippet
|
|
131
|
+
let AI = null;
|
|
132
|
+
/** Load the natural-language parser (motionary/components/ai) — from the package build, or MOTIONARY_AI. */
|
|
133
|
+
export async function loadAi(path = process.env.MOTIONARY_AI || join(HERE, '../dist/components/ai.js')) {
|
|
134
|
+
// a Function-wrapped import keeps bundlers / vite from rewriting this optional, path-based import
|
|
135
|
+
if (!AI && existsSync(path)) AI = await new Function('u', 'return import(u)')(pathToFileURL(path).href);
|
|
136
|
+
return AI;
|
|
137
|
+
}
|
|
138
|
+
export function setAi(mod) {
|
|
139
|
+
AI = mod;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/** Natural language → motion spec, code in three styles, and the catalog components that implement it. */
|
|
143
|
+
export function suggestMotion(m, text, format = 'waapi') {
|
|
144
|
+
if (!AI) throw new Error('suggest_motion needs motionary/components/ai (dist/components/ai.js) — run from an installed motionary package or set MOTIONARY_AI');
|
|
145
|
+
const i = AI.describeMotion(String(text || ''));
|
|
146
|
+
const comps = i.components.map((c) => {
|
|
147
|
+
const k = findComponent(m, c.tag);
|
|
148
|
+
return { ...c, requires: k ? brief(k).requires : [], import: k?.import?.path };
|
|
149
|
+
});
|
|
150
|
+
const code = { waapi: AI.motionSnippet(i, 'waapi'), css: AI.motionSnippet(i, 'css'), component: AI.motionSnippet(i, 'component') };
|
|
151
|
+
return {
|
|
152
|
+
text: i.text,
|
|
153
|
+
effect: i.effect,
|
|
154
|
+
also: i.also,
|
|
155
|
+
direction: i.direction,
|
|
156
|
+
amount: i.amount,
|
|
157
|
+
duration: i.duration,
|
|
158
|
+
delay: i.delay,
|
|
159
|
+
easing: i.easing,
|
|
160
|
+
easingName: i.easingName,
|
|
161
|
+
trigger: i.trigger,
|
|
162
|
+
iterations: i.iterations === Infinity ? 'infinite' : i.iterations,
|
|
163
|
+
alternate: i.alternate,
|
|
164
|
+
stagger: i.stagger,
|
|
165
|
+
reducedMotion: i.reducedMotion,
|
|
166
|
+
keyframes: i.keyframes,
|
|
167
|
+
options: { ...i.options, iterations: i.options.iterations === Infinity ? 'infinite' : i.options.iterations },
|
|
168
|
+
confidence: i.confidence,
|
|
169
|
+
matched: i.matched,
|
|
170
|
+
components: comps,
|
|
171
|
+
code: code[format] ? code[format] : code.waapi,
|
|
172
|
+
allCode: code,
|
|
173
|
+
note: i.confidence < 0.5 ? 'Low confidence: describe the motion with an effect (fade, slide, zoom …), a direction and a trigger (on scroll, on hover …).' : undefined,
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
const GLOBAL_ATTRS = new Set(['class', 'id', 'style', 'role', 'slot', 'hidden', 'tabindex', 'title', 'lang', 'dir', 'part', 'is', 'inert', 'nonce', 'popover', 'translate', 'draggable', 'contenteditable', 'autofocus', 'enterkeyhint', 'inputmode', 'key', 'ref', 'classname', 'v-if', 'v-for', 'v-show']);
|
|
178
|
+
const dist = (a, b) => {
|
|
179
|
+
const d = Array.from({ length: b.length + 1 }, (_, j) => j);
|
|
180
|
+
for (let i = 1; i <= a.length; i++) {
|
|
181
|
+
let prev = d[0];
|
|
182
|
+
d[0] = i;
|
|
183
|
+
for (let j = 1; j <= b.length; j++) {
|
|
184
|
+
const t = d[j];
|
|
185
|
+
d[j] = Math.min(d[j] + 1, d[j - 1] + 1, prev + (a[i - 1] === b[j - 1] ? 0 : 1));
|
|
186
|
+
prev = t;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
return d[b.length];
|
|
190
|
+
};
|
|
191
|
+
const camelId = (id) => id.replace(/-(\w)/g, (_, c) => c.toUpperCase());
|
|
192
|
+
|
|
193
|
+
/** Check a snippet (HTML, ESM, JSX, Vue or Svelte) against the catalog. Never runs it. */
|
|
194
|
+
export function validateSnippet(m, code) {
|
|
195
|
+
indexModules(m);
|
|
196
|
+
const src = String(code || '');
|
|
197
|
+
const errors = [], warnings = [];
|
|
198
|
+
const tags = [...src.matchAll(/<(usa-[a-z0-9-]+)([^>]*)>/gi)];
|
|
199
|
+
const used = new Map();
|
|
200
|
+
for (const [, rawTag, rawAttrs] of tags) {
|
|
201
|
+
const tag = rawTag.toLowerCase();
|
|
202
|
+
const c = findComponent(m, tag);
|
|
203
|
+
if (!c) {
|
|
204
|
+
const close = m.components.map((k) => [k.tag, dist(tag, k.tag)]).filter(([, d]) => d <= 3).sort((a, b) => a[1] - b[1]).map(([t]) => t);
|
|
205
|
+
const near = [...new Set([...close, ...searchComponents(m, tag.replace(/^usa-/, '').replace(/-/g, ' '), 3).map((x) => x.tag)])].slice(0, 3);
|
|
206
|
+
if (!used.has(tag)) errors.push(`unknown component <${tag}>${near.length ? ` — did you mean ${near.map((t) => `<${t}>`).join(', ')}?` : ''}`);
|
|
207
|
+
used.set(tag, null);
|
|
208
|
+
continue;
|
|
209
|
+
}
|
|
210
|
+
used.set(tag, c);
|
|
211
|
+
if (!(c.attributes || []).length) continue;
|
|
212
|
+
const attrs = [...rawAttrs.matchAll(/(?:^|\s)([:@]?[a-zA-Z_][\w:.-]*)(?=\s*=|\s|\/?$)/g)].map((x) => x[1].replace(/^[:@]/, '').replace(/^(?:v-bind|bind):/, '').toLowerCase());
|
|
213
|
+
for (const a of attrs) {
|
|
214
|
+
if (GLOBAL_ATTRS.has(a) || a.startsWith('data-') || a.startsWith('aria-') || a.startsWith('on') || a.startsWith('v-') || a.includes(':')) continue;
|
|
215
|
+
if (!c.attributes.includes(a)) warnings.push(`<${tag}> has no attribute "${a}" (attributes: ${c.attributes.join(', ')})`);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
const comps = [...used.values()].filter(Boolean);
|
|
219
|
+
const hasScript = /<script\b|\bimport\s|\brequire\(/.test(src);
|
|
220
|
+
// prerequisites (runtime modules + official runtimes) and their order
|
|
221
|
+
const modules = [...new Set(comps.flatMap((c) => c.requires))];
|
|
222
|
+
const firstDefine = Math.min(...comps.map((c) => { const i = src.indexOf(c.import.define + '('); return i < 0 ? Infinity : i; }), ...['components.umd.js', 'widgets.umd.js', 'motionary/components'].map((k) => { const i = src.indexOf(k); return i < 0 ? Infinity : i; }));
|
|
223
|
+
for (const r of modules) {
|
|
224
|
+
const who = comps.filter((c) => c.requires.includes(r)).map((c) => `<${c.tag}>`).join(', ');
|
|
225
|
+
if (isPeer(r)) {
|
|
226
|
+
const pk = reqLabel(r);
|
|
227
|
+
const has = src.includes(pk) || /runtime-src=/.test(src) || /provideRiveRuntime\(/.test(src);
|
|
228
|
+
if (!has) (hasScript ? errors : warnings).push(`${who} needs the official runtime ${pk} (optional peer): npm i ${pk}, or a runtime-src / provideRiveRuntime() — it is lazy-loaded on mount`);
|
|
229
|
+
continue;
|
|
230
|
+
}
|
|
231
|
+
const names = r === 'core' ? ["motionary/runtime'", 'motionary/runtime"', 'runtime.iife.js'] : [`motionary/runtime/${r}`, `runtime/${r}.iife.js`];
|
|
232
|
+
const at = Math.min(...names.map((n) => { const i = src.indexOf(n); return i < 0 ? Infinity : i; }));
|
|
233
|
+
const path = r === 'core' ? 'motionary/runtime' : `motionary/runtime/${r}`;
|
|
234
|
+
if (at === Infinity) {
|
|
235
|
+
(hasScript ? errors : warnings).push(`${who} requires ${path}: ${r === 'core' ? "import { use } from 'motionary/runtime'" : `import { ${camelId(r)} } from '${path}'; use(${camelId(r)});`} before the component mounts (CDN: runtime.iife.js${r === 'core' ? '' : `, then runtime/${r}.iife.js`}, before the component bundles)`);
|
|
236
|
+
continue;
|
|
237
|
+
}
|
|
238
|
+
if (r !== 'core' && /\bimport\s/.test(src) && !new RegExp(`use\\([^)]*\\b${camelId(r)}\\b`).test(src)) errors.push(`${path} is imported but never registered: call use(${camelId(r)}) before the components mount`);
|
|
239
|
+
if (at > firstDefine) errors.push(`${path} is loaded after the components — register prerequisites first`);
|
|
240
|
+
const useAt = src.search(new RegExp(`use\\([^)]*\\b${camelId(r)}\\b`));
|
|
241
|
+
const defAt = Math.min(...comps.filter((c) => c.requires.includes(r)).map((c) => { const i = src.indexOf(c.import.define + '('); return i < 0 ? Infinity : i; }));
|
|
242
|
+
if (useAt > -1 && defAt !== Infinity && useAt > defAt) errors.push(`use(${camelId(r)}) runs after ${who} are defined — call it first`);
|
|
243
|
+
}
|
|
244
|
+
// components imported in ESM but never defined
|
|
245
|
+
if (/\bimport\s/.test(src)) for (const c of comps) if (!src.includes(c.import.define + '(') && !/defineAll\w*\(|defineWidgets\(|auto(?:\.js)?['"]/.test(src)) warnings.push(`<${c.tag}> is used but ${c.import.define}() is never called (import it from '${c.import.path}')`);
|
|
246
|
+
// hand-written animations without a reduced-motion path
|
|
247
|
+
if (/\.animate\(|@keyframes|animation\s*:/.test(src) && !/prefers-reduced-motion|reducedMotion|prefersReducedMotion/.test(src)) warnings.push('hand-written animation without a prefers-reduced-motion check — guard it (Motionary components already respect reduced motion)');
|
|
248
|
+
return { valid: errors.length === 0, errors, warnings, components: comps.map((c) => c.tag), prerequisites: modules.map(reqLabel) };
|
|
110
249
|
}
|
|
111
250
|
|
|
112
251
|
// ---------------------------------------------------------------- MCP surface
|
|
@@ -117,11 +256,14 @@ export const TOOLS = [
|
|
|
117
256
|
{ name: 'get_component', title: 'Get a component', description: 'Everything about one component: attributes, events, slots, methods, import / define, CDN, prerequisites (install, import + register order, CDN script order), minimal example, variants.', inputSchema: { type: 'object', properties: { tag: { type: 'string', description: "'usa-tilt', 'tilt' or '<usa-tilt>'" } }, required: ['tag'], additionalProperties: false }, annotations: { title: 'Get component', ...RO } },
|
|
118
257
|
{ name: 'get_example', title: 'Get an example', description: "A working example for one component in the requested style ('html' = CDN, 'esm' = npm + bundler, or a variant id).", inputSchema: { type: 'object', properties: { tag: { type: 'string' }, variant: { type: 'string', description: "'html' (default), 'esm', or a variant id from get_component" } }, required: ['tag'], additionalProperties: false }, annotations: { title: 'Get example', ...RO } },
|
|
119
258
|
{ name: 'scaffold_snippet', title: 'Scaffold a snippet', description: 'A ready-to-paste snippet using one or more components, with every prerequisite installed, imported and registered in the right order before the components mount.', inputSchema: { type: 'object', properties: { tags: { type: 'array', items: { type: 'string' }, minItems: 1 }, framework: { type: 'string', enum: FRAMEWORKS, default: 'esm' } }, required: ['tags'], additionalProperties: false }, annotations: { title: 'Scaffold snippet', ...RO } },
|
|
259
|
+
{ name: 'suggest_motion', title: 'Suggest a motion', description: 'Natural language (English or Chinese) → a motion spec: effect, direction, duration, easing, trigger, stagger, Web Animations keyframes + options, CSS, and the Motionary components that implement it, with prerequisite-aware code. Deterministic parser, no model, no network.', inputSchema: { type: 'object', properties: { text: { type: 'string', description: "e.g. 'fade the cards up slowly when they scroll into view, one after another'" }, format: { type: 'string', enum: ['waapi', 'css', 'component'], default: 'waapi' } }, required: ['text'], additionalProperties: false }, annotations: { title: 'Suggest motion', ...RO } },
|
|
260
|
+
{ name: 'validate_snippet', title: 'Validate a snippet', description: 'Check HTML / ESM / JSX / Vue / Svelte code that uses <usa-*> components: unknown tags (with suggestions) and attributes, missing or mis-ordered prerequisites (motionary/runtime modules, official runtimes), components never defined, hand-written animation without a reduced-motion path. Static analysis only — never runs the code.', inputSchema: { type: 'object', properties: { code: { type: 'string' } }, required: ['code'], additionalProperties: false }, annotations: { title: 'Validate snippet', ...RO } },
|
|
120
261
|
];
|
|
121
262
|
|
|
122
263
|
const text = (obj) => ({ content: [{ type: 'text', text: typeof obj === 'string' ? obj : JSON.stringify(obj, null, 2) }], ...(typeof obj === 'object' ? { structuredContent: Array.isArray(obj) ? { items: obj } : obj } : {}) });
|
|
123
264
|
|
|
124
265
|
export function callTool(m, name, a = {}) {
|
|
266
|
+
indexModules(m);
|
|
125
267
|
switch (name) {
|
|
126
268
|
case 'list_components': {
|
|
127
269
|
let list = m.components;
|
|
@@ -159,6 +301,12 @@ export function callTool(m, name, a = {}) {
|
|
|
159
301
|
case 'scaffold_snippet':
|
|
160
302
|
if (!Array.isArray(a.tags) || !a.tags.length) throw new Error('tags must be a non-empty array');
|
|
161
303
|
return text(scaffold(m, a.tags, a.framework || 'esm'));
|
|
304
|
+
case 'suggest_motion':
|
|
305
|
+
if (!a.text) throw new Error('text is required');
|
|
306
|
+
return text(suggestMotion(m, a.text, a.format || 'waapi'));
|
|
307
|
+
case 'validate_snippet':
|
|
308
|
+
if (typeof a.code !== 'string') throw new Error('code is required');
|
|
309
|
+
return text(validateSnippet(m, a.code));
|
|
162
310
|
default:
|
|
163
311
|
throw Object.assign(new Error(`unknown tool ${name}`), { code: -32602 });
|
|
164
312
|
}
|
|
@@ -198,7 +346,7 @@ export function handle(m, msg, state = {}) {
|
|
|
198
346
|
case 'initialize': {
|
|
199
347
|
const v = PROTOCOLS.includes(params.protocolVersion) ? params.protocolVersion : PROTOCOLS[0];
|
|
200
348
|
state.initialized = true;
|
|
201
|
-
return ok({ protocolVersion: v, capabilities: { tools: { listChanged: false }, resources: { listChanged: false, subscribe: false }, prompts: { listChanged: false }, logging: {} }, serverInfo: { ...SERVER, title: 'Motionary component catalog' }, instructions: `Read-only catalog of Motionary ${m.version} (${m.components.length} <usa-*> Web Components + motionary/runtime modules). Search or list to pick a component, get_component for its API, scaffold_snippet for code that already registers every prerequisite in the right order.` });
|
|
349
|
+
return ok({ protocolVersion: v, capabilities: { tools: { listChanged: false }, resources: { listChanged: false, subscribe: false }, prompts: { listChanged: false }, logging: {} }, serverInfo: { ...SERVER, title: 'Motionary component catalog' }, instructions: `Read-only catalog of Motionary ${m.version} (${m.components.length} <usa-*> Web Components + motionary/runtime modules). Search or list to pick a component, get_component for its API, scaffold_snippet for code that already registers every prerequisite in the right order, suggest_motion to turn a description into motion code, validate_snippet to check code before you hand it over.` });
|
|
202
350
|
}
|
|
203
351
|
case 'ping':
|
|
204
352
|
return ok({});
|
|
@@ -252,10 +400,11 @@ export function serve(input = process.stdin, output = process.stdout, manifest)
|
|
|
252
400
|
const invoked = process.argv[1] && fileURLToPath(import.meta.url) === (await import('node:fs')).realpathSync(process.argv[1]);
|
|
253
401
|
if (invoked) {
|
|
254
402
|
if (process.argv.includes('--help') || process.argv.includes('-h')) {
|
|
255
|
-
console.log('motionary-mcp — read-only MCP server (stdio) for the Motionary component catalog.\nConfigure your MCP client with: { "command": "npx", "args": ["-y", "-p", "motionary", "motionary-mcp"] }\nTools: ' + TOOLS.map((t) => t.name).join(', '));
|
|
403
|
+
console.log('motionary-mcp 2.0 — read-only MCP server (stdio) for the Motionary component catalog.\nConfigure your MCP client with: { "command": "npx", "args": ["-y", "-p", "motionary", "motionary-mcp"] }\nTools: ' + TOOLS.map((t) => t.name).join(', '));
|
|
256
404
|
} else if (process.argv.includes('--version')) console.log(SERVER.version);
|
|
257
405
|
else {
|
|
258
406
|
try {
|
|
407
|
+
await loadAi();
|
|
259
408
|
serve();
|
|
260
409
|
} catch (e) {
|
|
261
410
|
console.error(String(e.message || e));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var tween = require('./tween-
|
|
3
|
+
var tween = require('./tween-Dk0QmNe9.cjs');
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Shared internals of the animated-image loaders (`format-gif`, `format-apng`,
|
|
@@ -171,4 +171,4 @@ exports.composeFrames = composeFrames;
|
|
|
171
171
|
exports.crc32 = crc32;
|
|
172
172
|
exports.fixDelay = fixDelay;
|
|
173
173
|
exports.u8 = u8;
|
|
174
|
-
//# sourceMappingURL=anim-image-
|
|
174
|
+
//# sourceMappingURL=anim-image-CFGpUX7t.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"anim-image-DuxvYhq6.cjs","sources":["../../src/runtime/anim-image.ts"],"sourcesContent":["/**\n * Shared internals of the animated-image loaders (`format-gif`, `format-apng`,\n * `format-webp`, 10.4): the decoded-animation shape, frame compositing in\n * plain RGBA arrays (no DOM — works in workers and on the server), the\n * browser image decoder used for APNG / WebP frames, and the canvas player\n * (a runtime `Playable`, so it can be paused, reversed, scrubbed and driven\n * by a scroll scene). Bundled into each loader; not a public module.\n */\nimport { Playable } from './tween';\n\n/** An RGBA bitmap (the shape of `ImageData`, without needing the DOM). */\nexport interface Rgba {\n width: number;\n height: number;\n data: Uint8ClampedArray;\n}\n\n/** One frame of an animation, already composited to the full canvas size. */\nexport interface AnimFrame {\n /** Display time, ms. */\n delay: number;\n image: Rgba;\n}\n\nexport interface AnimatedImage {\n format: 'gif' | 'apng' | 'webp';\n width: number;\n height: number;\n /** Number of plays: 0 = forever, 1 = once, … */\n plays: number;\n frames: AnimFrame[];\n}\n\n/** A frame region before compositing (APNG fcTL / WebP ANMF / GIF descriptor). */\nexport interface FramePart {\n x: number;\n y: number;\n image: Rgba;\n delay: number;\n /** 'over' alpha-blends onto the canvas, 'source' replaces the region. */\n blend: 'over' | 'source';\n /** What happens to the region after the frame is shown. */\n dispose: 'none' | 'background' | 'previous';\n}\n\n/** Browsers clamp tiny delays (0–10 ms) to 100 ms; we do the same. */\nexport const fixDelay = (ms: number): number => (ms <= 10 ? 100 : ms);\n\n/** Composite frame parts onto a `width × height` canvas (pure; RGBA in, RGBA out). */\nexport function composeFrames(width: number, height: number, parts: FramePart[], background?: [number, number, number, number]): AnimFrame[] {\n const canvas = new Uint8ClampedArray(width * height * 4);\n const out: AnimFrame[] = [];\n for (const p of parts) {\n const before = p.dispose === 'previous' ? canvas.slice() : null;\n const { width: w, height: h, data } = p.image;\n for (let y = 0; y < h; y++) {\n const cy = p.y + y;\n if (cy < 0 || cy >= height) continue;\n for (let x = 0; x < w; x++) {\n const cx = p.x + x;\n if (cx < 0 || cx >= width) continue;\n const s = (y * w + x) * 4, d = (cy * width + cx) * 4;\n const a = data[s + 3];\n if (p.blend === 'source' || a === 255) {\n canvas[d] = data[s]; canvas[d + 1] = data[s + 1]; canvas[d + 2] = data[s + 2]; canvas[d + 3] = a;\n } else if (a) {\n // straight-alpha \"over\"\n const da = canvas[d + 3] / 255, sa = a / 255, oa = sa + da * (1 - sa);\n for (let c = 0; c < 3; c++) canvas[d + c] = (data[s + c] * sa + canvas[d + c] * da * (1 - sa)) / oa;\n canvas[d + 3] = oa * 255;\n }\n }\n }\n out.push({ delay: p.delay, image: { width, height, data: canvas.slice() } });\n if (p.dispose === 'background') {\n for (let y = Math.max(0, p.y); y < Math.min(height, p.y + h); y++)\n for (let x = Math.max(0, p.x); x < Math.min(width, p.x + w); x++) canvas.set(background || [0, 0, 0, 0], (y * width + x) * 4);\n } else if (before) canvas.set(before);\n }\n return out;\n}\n\n/** Image decoder for one frame file (PNG / WebP bytes) → RGBA. Replaceable (workers, tests, servers). */\nexport type FrameDecoder = (bytes: Uint8Array, mime: string) => Promise<Rgba>;\n\n/** Default decoder: the browser's own (`createImageBitmap` + a 2D canvas; OffscreenCanvas in workers). */\nexport const browserDecode: FrameDecoder = async (bytes, mime) => {\n const g = globalThis as any;\n if (typeof g.createImageBitmap !== 'function') throw new Error('[motionary] no image decoder here (createImageBitmap is missing) — pass { decode } to the loader');\n const bmp = await g.createImageBitmap(new Blob([bytes as BlobPart], { type: mime }));\n const w = bmp.width, h = bmp.height; // read before close(): a closed ImageBitmap reports 0 × 0\n const c = typeof g.OffscreenCanvas === 'function' ? new g.OffscreenCanvas(w, h) : Object.assign(document.createElement('canvas'), { width: w, height: h });\n const ctx = c.getContext('2d', { willReadFrequently: true });\n ctx.drawImage(bmp, 0, 0);\n bmp.close?.();\n const id = ctx.getImageData(0, 0, w, h);\n return { width: id.width, height: id.height, data: id.data };\n};\n\n/** Read a `src` (URL, ArrayBuffer, typed array or Blob) into bytes. */\nexport async function bytesOf(src: string | ArrayBuffer | ArrayBufferView | Blob): Promise<Uint8Array> {\n if (typeof src === 'string') {\n const r = await fetch(src);\n if (!r.ok) throw new Error(`[motionary] could not load ${src} (${r.status})`);\n return new Uint8Array(await r.arrayBuffer());\n }\n if (src instanceof ArrayBuffer) return new Uint8Array(src);\n if (ArrayBuffer.isView(src)) return new Uint8Array(src.buffer, src.byteOffset, src.byteLength);\n return new Uint8Array(await (src as Blob).arrayBuffer());\n}\n\nexport interface AnimPlayerOptions {\n /** Extra repeats; default from the file (`plays`: 0 → forever). */\n repeat?: number;\n yoyo?: boolean;\n paused?: boolean;\n /** Playback speed (default 1). */\n speed?: number;\n}\n\nexport type AnimPlayer = Playable & { readonly frame: number; readonly frameCount: number };\n\nclass AnimImagePlayer extends Playable {\n private times: number[] = [0];\n private cur = -1;\n private ctx: CanvasRenderingContext2D | null;\n private datas: (ImageData | null)[];\n constructor(private canvas: HTMLCanvasElement | OffscreenCanvas, private anim: AnimatedImage, o: AnimPlayerOptions) {\n super({ repeat: o.repeat ?? (anim.plays === 0 ? -1 : Math.max(0, anim.plays - 1)), yoyo: o.yoyo });\n this.timeScale = o.speed || 1;\n for (const f of anim.frames) this.times.push(this.times[this.times.length - 1] + f.delay);\n if (canvas.width !== anim.width) canvas.width = anim.width;\n if (canvas.height !== anim.height) canvas.height = anim.height;\n this.ctx = canvas.getContext('2d') as CanvasRenderingContext2D | null;\n this.datas = anim.frames.map(() => null);\n this.show(0);\n if (!o.paused) this.play();\n }\n get duration(): number {\n return this.times[this.times.length - 1];\n }\n get frame(): number {\n return this.cur;\n }\n get frameCount(): number {\n return this.anim.frames.length;\n }\n protected renderLocal(ms: number): void {\n const t = Math.min(ms, this.duration - 0.001);\n let lo = 0, hi = this.anim.frames.length - 1;\n while (lo < hi) {\n const mid = (lo + hi + 1) >> 1;\n if (this.times[mid] <= t) lo = mid;\n else hi = mid - 1;\n }\n this.show(lo);\n }\n private show(i: number): void {\n if (i === this.cur || !this.ctx) return;\n this.cur = i;\n const f = this.anim.frames[i];\n if (!f) return;\n let d = this.datas[i];\n if (!d && typeof ImageData === 'function') d = this.datas[i] = new ImageData(new Uint8ClampedArray(f.image.data), f.image.width, f.image.height);\n if (d) this.ctx.putImageData(d, 0, 0);\n }\n}\n\n/** Play a decoded animation on a canvas as a runtime timeline (seek / reverse / `progress` scrub). */\nexport function animatedImagePlayer(canvas: HTMLCanvasElement | OffscreenCanvas, anim: AnimatedImage, o: AnimPlayerOptions = {}): AnimPlayer {\n if (!anim.frames.length) throw new Error('[motionary] animatedImagePlayer: the animation has no frames');\n return new AnimImagePlayer(canvas, anim, o);\n}\n\n/** A plain Uint8Array view (Node Buffers' `slice()` shares memory — normalise them away). */\nexport const u8 = (x: Uint8Array | ArrayBuffer): Uint8Array => (x instanceof ArrayBuffer ? new Uint8Array(x) : new Uint8Array(x.buffer, x.byteOffset, x.byteLength));\n\n/** CRC-32 (PNG chunks). */\nlet CRC: Uint32Array | null = null;\nexport function crc32(bytes: Uint8Array, start = 0, end = bytes.length): number {\n if (!CRC) {\n CRC = new Uint32Array(256);\n for (let n = 0; n < 256; n++) {\n let c = n;\n for (let k = 0; k < 8; k++) c = c & 1 ? 0xedb88320 ^ (c >>> 1) : c >>> 1;\n CRC[n] = c >>> 0;\n }\n }\n let c = 0xffffffff;\n for (let i = start; i < end; i++) c = CRC[(c ^ bytes[i]) & 0xff] ^ (c >>> 8);\n return (c ^ 0xffffffff) >>> 0;\n}\n"],"names":["Playable"],"mappings":";;;;AAAA;;;;;;;AAOG;AAsCH;MACa,QAAQ,GAAG,CAAC,EAAU,MAAc,EAAE,IAAI,EAAE,GAAG,GAAG,GAAG,EAAE;AAEpE;AACM,SAAU,aAAa,CAAC,KAAa,EAAE,MAAc,EAAE,KAAkB,EAAE,UAA6C,EAAA;IAC5H,MAAM,MAAM,GAAG,IAAI,iBAAiB,CAAC,KAAK,GAAG,MAAM,GAAG,CAAC,CAAC;IACxD,MAAM,GAAG,GAAgB,EAAE;AAC3B,IAAA,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE;AACrB,QAAA,MAAM,MAAM,GAAG,CAAC,CAAC,OAAO,KAAK,UAAU,GAAG,MAAM,CAAC,KAAK,EAAE,GAAG,IAAI;AAC/D,QAAA,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC,KAAK;AAC7C,QAAA,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;AAC1B,YAAA,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;AAClB,YAAA,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,IAAI,MAAM;gBAAE;AAC5B,YAAA,KAAK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CAAC,CAAC,UAAU,CAAC;AAEnK;AACA,IAAI,GAAG,GAAuB,IAAI;AAC5B,SAAU,KAAK,CAAC,KAAiB,EAAE,KAAK,GAAG,CAAC,EAAE,GAAG,GAAG,KAAK,CAAC,MAAM,EAAA;IACpE,IAAI,CAAC,GAAG,EAAE;AACR,QAAA,GAAG,GAAG,IAAI,WAAW,CAAC,GAAG,CAAC;AAC1B,QAAA,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE;YAC5B,IAAI,CAAC,GAAG,CAAC;YACT,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE;gBAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,UAAU,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC;AACxE,YAAA,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC;QAClB;IACF;IACA,IAAI,CAAC,GAAG,UAAU;IAClB,KAAK,IAAI,CAAC,GAAG,KAAK,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE;QAAE,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC5E,IAAA,OAAO,CAAC,CAAC,GAAG,UAAU,MAAM,CAAC;AAC/B;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"anim-image-CFGpUX7t.cjs","sources":["../../src/runtime/anim-image.ts"],"sourcesContent":["/**\n * Shared internals of the animated-image loaders (`format-gif`, `format-apng`,\n * `format-webp`, 10.4): the decoded-animation shape, frame compositing in\n * plain RGBA arrays (no DOM — works in workers and on the server), the\n * browser image decoder used for APNG / WebP frames, and the canvas player\n * (a runtime `Playable`, so it can be paused, reversed, scrubbed and driven\n * by a scroll scene). Bundled into each loader; not a public module.\n */\nimport { Playable } from './tween';\n\n/** An RGBA bitmap (the shape of `ImageData`, without needing the DOM). */\nexport interface Rgba {\n width: number;\n height: number;\n data: Uint8ClampedArray;\n}\n\n/** One frame of an animation, already composited to the full canvas size. */\nexport interface AnimFrame {\n /** Display time, ms. */\n delay: number;\n image: Rgba;\n}\n\nexport interface AnimatedImage {\n format: 'gif' | 'apng' | 'webp';\n width: number;\n height: number;\n /** Number of plays: 0 = forever, 1 = once, … */\n plays: number;\n frames: AnimFrame[];\n}\n\n/** A frame region before compositing (APNG fcTL / WebP ANMF / GIF descriptor). */\nexport interface FramePart {\n x: number;\n y: number;\n image: Rgba;\n delay: number;\n /** 'over' alpha-blends onto the canvas, 'source' replaces the region. */\n blend: 'over' | 'source';\n /** What happens to the region after the frame is shown. */\n dispose: 'none' | 'background' | 'previous';\n}\n\n/** Browsers clamp tiny delays (0–10 ms) to 100 ms; we do the same. */\nexport const fixDelay = (ms: number): number => (ms <= 10 ? 100 : ms);\n\n/** Composite frame parts onto a `width × height` canvas (pure; RGBA in, RGBA out). */\nexport function composeFrames(width: number, height: number, parts: FramePart[], background?: [number, number, number, number]): AnimFrame[] {\n const canvas = new Uint8ClampedArray(width * height * 4);\n const out: AnimFrame[] = [];\n for (const p of parts) {\n const before = p.dispose === 'previous' ? canvas.slice() : null;\n const { width: w, height: h, data } = p.image;\n for (let y = 0; y < h; y++) {\n const cy = p.y + y;\n if (cy < 0 || cy >= height) continue;\n for (let x = 0; x < w; x++) {\n const cx = p.x + x;\n if (cx < 0 || cx >= width) continue;\n const s = (y * w + x) * 4, d = (cy * width + cx) * 4;\n const a = data[s + 3];\n if (p.blend === 'source' || a === 255) {\n canvas[d] = data[s]; canvas[d + 1] = data[s + 1]; canvas[d + 2] = data[s + 2]; canvas[d + 3] = a;\n } else if (a) {\n // straight-alpha \"over\"\n const da = canvas[d + 3] / 255, sa = a / 255, oa = sa + da * (1 - sa);\n for (let c = 0; c < 3; c++) canvas[d + c] = (data[s + c] * sa + canvas[d + c] * da * (1 - sa)) / oa;\n canvas[d + 3] = oa * 255;\n }\n }\n }\n out.push({ delay: p.delay, image: { width, height, data: canvas.slice() } });\n if (p.dispose === 'background') {\n for (let y = Math.max(0, p.y); y < Math.min(height, p.y + h); y++)\n for (let x = Math.max(0, p.x); x < Math.min(width, p.x + w); x++) canvas.set(background || [0, 0, 0, 0], (y * width + x) * 4);\n } else if (before) canvas.set(before);\n }\n return out;\n}\n\n/** Image decoder for one frame file (PNG / WebP bytes) → RGBA. Replaceable (workers, tests, servers). */\nexport type FrameDecoder = (bytes: Uint8Array, mime: string) => Promise<Rgba>;\n\n/** Default decoder: the browser's own (`createImageBitmap` + a 2D canvas; OffscreenCanvas in workers). */\nexport const browserDecode: FrameDecoder = async (bytes, mime) => {\n const g = globalThis as any;\n if (typeof g.createImageBitmap !== 'function') throw new Error('[motionary] no image decoder here (createImageBitmap is missing) — pass { decode } to the loader');\n const bmp = await g.createImageBitmap(new Blob([bytes as BlobPart], { type: mime }));\n const w = bmp.width, h = bmp.height; // read before close(): a closed ImageBitmap reports 0 × 0\n const c = typeof g.OffscreenCanvas === 'function' ? new g.OffscreenCanvas(w, h) : Object.assign(document.createElement('canvas'), { width: w, height: h });\n const ctx = c.getContext('2d', { willReadFrequently: true });\n ctx.drawImage(bmp, 0, 0);\n bmp.close?.();\n const id = ctx.getImageData(0, 0, w, h);\n return { width: id.width, height: id.height, data: id.data };\n};\n\n/** Read a `src` (URL, ArrayBuffer, typed array or Blob) into bytes. */\nexport async function bytesOf(src: string | ArrayBuffer | ArrayBufferView | Blob): Promise<Uint8Array> {\n if (typeof src === 'string') {\n const r = await fetch(src);\n if (!r.ok) throw new Error(`[motionary] could not load ${src} (${r.status})`);\n return new Uint8Array(await r.arrayBuffer());\n }\n if (src instanceof ArrayBuffer) return new Uint8Array(src);\n if (ArrayBuffer.isView(src)) return new Uint8Array(src.buffer, src.byteOffset, src.byteLength);\n return new Uint8Array(await (src as Blob).arrayBuffer());\n}\n\nexport interface AnimPlayerOptions {\n /** Extra repeats; default from the file (`plays`: 0 → forever). */\n repeat?: number;\n yoyo?: boolean;\n paused?: boolean;\n /** Playback speed (default 1). */\n speed?: number;\n}\n\nexport type AnimPlayer = Playable & { readonly frame: number; readonly frameCount: number };\n\nclass AnimImagePlayer extends Playable {\n private times: number[] = [0];\n private cur = -1;\n private ctx: CanvasRenderingContext2D | null;\n private datas: (ImageData | null)[];\n constructor(private canvas: HTMLCanvasElement | OffscreenCanvas, private anim: AnimatedImage, o: AnimPlayerOptions) {\n super({ repeat: o.repeat ?? (anim.plays === 0 ? -1 : Math.max(0, anim.plays - 1)), yoyo: o.yoyo });\n this.timeScale = o.speed || 1;\n for (const f of anim.frames) this.times.push(this.times[this.times.length - 1] + f.delay);\n if (canvas.width !== anim.width) canvas.width = anim.width;\n if (canvas.height !== anim.height) canvas.height = anim.height;\n this.ctx = canvas.getContext('2d') as CanvasRenderingContext2D | null;\n this.datas = anim.frames.map(() => null);\n this.show(0);\n if (!o.paused) this.play();\n }\n get duration(): number {\n return this.times[this.times.length - 1];\n }\n get frame(): number {\n return this.cur;\n }\n get frameCount(): number {\n return this.anim.frames.length;\n }\n protected renderLocal(ms: number): void {\n const t = Math.min(ms, this.duration - 0.001);\n let lo = 0, hi = this.anim.frames.length - 1;\n while (lo < hi) {\n const mid = (lo + hi + 1) >> 1;\n if (this.times[mid] <= t) lo = mid;\n else hi = mid - 1;\n }\n this.show(lo);\n }\n private show(i: number): void {\n if (i === this.cur || !this.ctx) return;\n this.cur = i;\n const f = this.anim.frames[i];\n if (!f) return;\n let d = this.datas[i];\n if (!d && typeof ImageData === 'function') d = this.datas[i] = new ImageData(new Uint8ClampedArray(f.image.data), f.image.width, f.image.height);\n if (d) this.ctx.putImageData(d, 0, 0);\n }\n}\n\n/** Play a decoded animation on a canvas as a runtime timeline (seek / reverse / `progress` scrub). */\nexport function animatedImagePlayer(canvas: HTMLCanvasElement | OffscreenCanvas, anim: AnimatedImage, o: AnimPlayerOptions = {}): AnimPlayer {\n if (!anim.frames.length) throw new Error('[motionary] animatedImagePlayer: the animation has no frames');\n return new AnimImagePlayer(canvas, anim, o);\n}\n\n/** A plain Uint8Array view (Node Buffers' `slice()` shares memory — normalise them away). */\nexport const u8 = (x: Uint8Array | ArrayBuffer): Uint8Array => (x instanceof ArrayBuffer ? new Uint8Array(x) : new Uint8Array(x.buffer, x.byteOffset, x.byteLength));\n\n/** CRC-32 (PNG chunks). */\nlet CRC: Uint32Array | null = null;\nexport function crc32(bytes: Uint8Array, start = 0, end = bytes.length): number {\n if (!CRC) {\n CRC = new Uint32Array(256);\n for (let n = 0; n < 256; n++) {\n let c = n;\n for (let k = 0; k < 8; k++) c = c & 1 ? 0xedb88320 ^ (c >>> 1) : c >>> 1;\n CRC[n] = c >>> 0;\n }\n }\n let c = 0xffffffff;\n for (let i = start; i < end; i++) c = CRC[(c ^ bytes[i]) & 0xff] ^ (c >>> 8);\n return (c ^ 0xffffffff) >>> 0;\n}\n"],"names":["Playable"],"mappings":";;;;AAAA;;;;;;;AAOG;AAsCH;MACa,QAAQ,GAAG,CAAC,EAAU,MAAc,EAAE,IAAI,EAAE,GAAG,GAAG,GAAG,EAAE;AAEpE;AACM,SAAU,aAAa,CAAC,KAAa,EAAE,MAAc,EAAE,KAAkB,EAAE,UAA6C,EAAA;IAC5H,MAAM,MAAM,GAAG,IAAI,iBAAiB,CAAC,KAAK,GAAG,MAAM,GAAG,CAAC,CAAC;IACxD,MAAM,GAAG,GAAgB,EAAE;AAC3B,IAAA,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE;AACrB,QAAA,MAAM,MAAM,GAAG,CAAC,CAAC,OAAO,KAAK,UAAU,GAAG,MAAM,CAAC,KAAK,EAAE,GAAG,IAAI;AAC/D,QAAA,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC,KAAK;AAC7C,QAAA,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAA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
|
* Shared internals of the animated-image loaders (`format-gif`, `format-apng`,
|
|
@@ -163,4 +163,4 @@ function crc32(bytes, start = 0, end = bytes.length) {
|
|
|
163
163
|
}
|
|
164
164
|
|
|
165
165
|
export { animatedImagePlayer as a, browserDecode as b, composeFrames as c, bytesOf as d, crc32 as e, fixDelay as f, u8 as u };
|
|
166
|
-
//# sourceMappingURL=anim-image-
|
|
166
|
+
//# sourceMappingURL=anim-image-CXDD19FH.js.map
|