motionary 10.6.0 → 10.8.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.
Files changed (153) hide show
  1. package/AGENTS.md +2 -0
  2. package/CHANGELOG.md +36 -0
  3. package/README.md +77 -4
  4. package/bin/motionary-mcp.mjs +160 -11
  5. package/dist/chunks/{anim-image-DECLkPH4.cjs → anim-image-BzTQa2k3.cjs} +2 -2
  6. package/dist/chunks/{anim-image-DECLkPH4.cjs.map → anim-image-BzTQa2k3.cjs.map} +1 -1
  7. package/dist/chunks/{anim-image-DNghy017.js → anim-image-iD646Q7i.js} +2 -2
  8. package/dist/chunks/{anim-image-DNghy017.js.map → anim-image-iD646Q7i.js.map} +1 -1
  9. package/dist/chunks/{keyframes-F6vp6tZZ.js → keyframes-B4zefz0k.js} +2 -2
  10. package/dist/chunks/{keyframes-F6vp6tZZ.js.map → keyframes-B4zefz0k.js.map} +1 -1
  11. package/dist/chunks/{keyframes-CbUZjD_5.cjs → keyframes-BlOyB1PP.cjs} +2 -2
  12. package/dist/chunks/{keyframes-CbUZjD_5.cjs.map → keyframes-BlOyB1PP.cjs.map} +1 -1
  13. package/dist/chunks/{registry-dr1CPTk1.cjs → registry-BZxDVL3h.cjs} +2 -2
  14. package/dist/chunks/{registry-dr1CPTk1.cjs.map → registry-BZxDVL3h.cjs.map} +1 -1
  15. package/dist/chunks/{registry-D8LAoXI-.js → registry-Bkt3-3ET.js} +3 -3
  16. package/dist/chunks/{registry-D8LAoXI-.js.map → registry-Bkt3-3ET.js.map} +1 -1
  17. package/dist/chunks/runtime-link-CUiZ8lbE.cjs +38 -0
  18. package/dist/chunks/runtime-link-CUiZ8lbE.cjs.map +1 -0
  19. package/dist/chunks/runtime-link-c13gskBZ.js +36 -0
  20. package/dist/chunks/runtime-link-c13gskBZ.js.map +1 -0
  21. package/dist/chunks/{ticker-DaAlEyOd.cjs → ticker-BfxAECfO.cjs} +2 -2
  22. package/dist/chunks/{ticker-DaAlEyOd.cjs.map → ticker-BfxAECfO.cjs.map} +1 -1
  23. package/dist/chunks/{ticker-Do9bGsaV.js → ticker-ZtweD3U4.js} +2 -2
  24. package/dist/chunks/{ticker-Do9bGsaV.js.map → ticker-ZtweD3U4.js.map} +1 -1
  25. package/dist/chunks/{tween-CmkdSyaC.cjs → tween--MD-39y0.cjs} +2 -2
  26. package/dist/chunks/{tween-CmkdSyaC.cjs.map → tween--MD-39y0.cjs.map} +1 -1
  27. package/dist/chunks/{tween-BzCGq_Ba.js → tween-DACdkLyO.js} +2 -2
  28. package/dist/chunks/{tween-BzCGq_Ba.js.map → tween-DACdkLyO.js.map} +1 -1
  29. package/dist/components/ai.cjs +314 -0
  30. package/dist/components/ai.cjs.map +1 -0
  31. package/dist/components/ai.d.cts +58 -0
  32. package/dist/components/ai.d.ts +58 -0
  33. package/dist/components/ai.js +311 -0
  34. package/dist/components/ai.js.map +1 -0
  35. package/dist/components/snap-carousel.cjs +216 -0
  36. package/dist/components/snap-carousel.cjs.map +1 -0
  37. package/dist/components/snap-carousel.d.cts +80 -0
  38. package/dist/components/snap-carousel.d.ts +80 -0
  39. package/dist/components/snap-carousel.js +214 -0
  40. package/dist/components/snap-carousel.js.map +1 -0
  41. package/dist/components/widgets.cjs +626 -268
  42. package/dist/components/widgets.cjs.map +1 -1
  43. package/dist/components/widgets.d.cts +515 -39
  44. package/dist/components/widgets.d.ts +515 -39
  45. package/dist/components/widgets.js +617 -262
  46. package/dist/components/widgets.js.map +1 -1
  47. package/dist/llms-full.txt +191 -6
  48. package/dist/llms.txt +10 -3
  49. package/dist/manifest.json +497 -19
  50. package/dist/runtime/drag-snap.cjs +269 -0
  51. package/dist/runtime/drag-snap.cjs.map +1 -0
  52. package/dist/runtime/drag-snap.d.cts +109 -0
  53. package/dist/runtime/drag-snap.d.ts +109 -0
  54. package/dist/runtime/drag-snap.iife.js +2 -0
  55. package/dist/runtime/drag-snap.iife.js.map +1 -0
  56. package/dist/runtime/drag-snap.js +261 -0
  57. package/dist/runtime/drag-snap.js.map +1 -0
  58. package/dist/runtime/format-apng.cjs +4 -4
  59. package/dist/runtime/format-apng.js +4 -4
  60. package/dist/runtime/format-css.cjs +4 -4
  61. package/dist/runtime/format-css.js +4 -4
  62. package/dist/runtime/format-gif.cjs +4 -4
  63. package/dist/runtime/format-gif.js +4 -4
  64. package/dist/runtime/format-gltf.cjs +37 -18
  65. package/dist/runtime/format-gltf.cjs.map +1 -1
  66. package/dist/runtime/format-gltf.d.cts +18 -2
  67. package/dist/runtime/format-gltf.d.ts +18 -2
  68. package/dist/runtime/format-gltf.iife.js +1 -1
  69. package/dist/runtime/format-gltf.iife.js.map +1 -1
  70. package/dist/runtime/format-gltf.js +37 -18
  71. package/dist/runtime/format-gltf.js.map +1 -1
  72. package/dist/runtime/format-motion.cjs +4 -4
  73. package/dist/runtime/format-motion.js +4 -4
  74. package/dist/runtime/format-obj.cjs +1 -1
  75. package/dist/runtime/format-obj.d.cts +2 -0
  76. package/dist/runtime/format-obj.d.ts +2 -0
  77. package/dist/runtime/format-obj.iife.js.map +1 -1
  78. package/dist/runtime/format-obj.js +1 -1
  79. package/dist/runtime/format-scene.cjs +241 -0
  80. package/dist/runtime/format-scene.cjs.map +1 -0
  81. package/dist/runtime/format-scene.d.cts +349 -0
  82. package/dist/runtime/format-scene.d.ts +349 -0
  83. package/dist/runtime/format-scene.iife.js +2 -0
  84. package/dist/runtime/format-scene.iife.js.map +1 -0
  85. package/dist/runtime/format-scene.js +233 -0
  86. package/dist/runtime/format-scene.js.map +1 -0
  87. package/dist/runtime/format-sprite.cjs +3 -3
  88. package/dist/runtime/format-sprite.js +3 -3
  89. package/dist/runtime/format-svg.cjs +3 -3
  90. package/dist/runtime/format-svg.js +3 -3
  91. package/dist/runtime/format-webp.cjs +4 -4
  92. package/dist/runtime/format-webp.js +4 -4
  93. package/dist/runtime/gl.cjs +17 -4
  94. package/dist/runtime/gl.cjs.map +1 -1
  95. package/dist/runtime/gl.d.cts +2 -0
  96. package/dist/runtime/gl.d.ts +2 -0
  97. package/dist/runtime/gl.iife.js +1 -1
  98. package/dist/runtime/gl.iife.js.map +1 -1
  99. package/dist/runtime/gl.js +17 -4
  100. package/dist/runtime/gl.js.map +1 -1
  101. package/dist/runtime/gltf-anim.cjs +251 -0
  102. package/dist/runtime/gltf-anim.cjs.map +1 -0
  103. package/dist/runtime/gltf-anim.d.cts +216 -0
  104. package/dist/runtime/gltf-anim.d.ts +216 -0
  105. package/dist/runtime/gltf-anim.iife.js +2 -0
  106. package/dist/runtime/gltf-anim.iife.js.map +1 -0
  107. package/dist/runtime/gltf-anim.js +243 -0
  108. package/dist/runtime/gltf-anim.js.map +1 -0
  109. package/dist/runtime/physics.cjs +739 -0
  110. package/dist/runtime/physics.cjs.map +1 -0
  111. package/dist/runtime/physics.d.cts +250 -0
  112. package/dist/runtime/physics.d.ts +250 -0
  113. package/dist/runtime/physics.iife.js +2 -0
  114. package/dist/runtime/physics.iife.js.map +1 -0
  115. package/dist/runtime/physics.js +731 -0
  116. package/dist/runtime/physics.js.map +1 -0
  117. package/dist/runtime/scroll.cjs +2 -2
  118. package/dist/runtime/scroll.js +2 -2
  119. package/dist/runtime/smooth.cjs +1 -1
  120. package/dist/runtime/smooth.js +1 -1
  121. package/dist/runtime/text.cjs +1 -1
  122. package/dist/runtime/text.js +1 -1
  123. package/dist/runtime/vector.cjs +421 -11
  124. package/dist/runtime/vector.cjs.map +1 -1
  125. package/dist/runtime/vector.d.cts +20 -4
  126. package/dist/runtime/vector.d.ts +20 -4
  127. package/dist/runtime/vector.iife.js +1 -1
  128. package/dist/runtime/vector.iife.js.map +1 -1
  129. package/dist/runtime/vector.js +421 -12
  130. package/dist/runtime/vector.js.map +1 -1
  131. package/dist/runtime.cjs +3 -3
  132. package/dist/runtime.d.cts +1 -1
  133. package/dist/runtime.d.ts +1 -1
  134. package/dist/runtime.iife.js +1 -1
  135. package/dist/runtime.iife.js.map +1 -1
  136. package/dist/runtime.js +5 -5
  137. package/dist/widgets.umd.js +1 -1
  138. package/dist/widgets.umd.js.map +1 -1
  139. package/docs/ROADMAP.md +2 -2
  140. package/docs/components/README.md +5 -2
  141. package/docs/components/usa-gl-scene.md +27 -6
  142. package/docs/components/usa-lottie-player.md +18 -0
  143. package/docs/components/usa-motion-prompt.md +32 -0
  144. package/docs/components/usa-physics-playground.md +63 -0
  145. package/docs/components/usa-snap-carousel.md +68 -0
  146. package/docs/components.md +95 -3
  147. package/docs/runtime/drag-snap.md +60 -0
  148. package/docs/runtime/format-gltf.md +3 -2
  149. package/docs/runtime/format-scene.md +59 -0
  150. package/docs/runtime/gltf-anim.md +62 -0
  151. package/docs/runtime/physics.md +61 -0
  152. package/docs/runtime/vector.md +3 -2
  153. package/package.json +61 -1
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,42 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [10.8.0] - 2026-10-09
11
+
12
+ ### Added
13
+ - **`motionary/runtime/drag-snap`** — pointer drag along one axis with velocity tracking (last 100 ms), inertial throws (constant deceleration), snap points (nearest to the projected throw; a fast flick always moves one point), rubber-band edges and a critically damped spring on the shared ticker; the click that ends a drag is swallowed, clicks inside still work. `createDragSnap(el, { snap, onUpdate, onSnap, … })` → `snapTo()`, `setPosition()`, `setSnapPoints()`; pure helpers `projectThrow`, `nearestSnap`, `rubberband`, `springStep`, `velocityTracker`. Reduced motion: no inertia, no spring. CDN `dist/runtime/drag-snap.iife.js`; fixed gzip budget.
14
+ - **`<usa-snap-carousel>`** (**Requires: motionary/runtime/drag-snap**) — drag / swipe carousel with real inertia and snapping, slides that keep their own width (peek), `align` (center · start), `gap`, `index`, `autoplay` (pauses on hover, focus, off screen; never under reduced motion), prev / next buttons, dots, ←/→ / Home / End; `next()`, `prev()`, `goTo()`, `controller`, `usa:change`. Without the runtime module it stays a native CSS scroll-snap strip (plus the clear notice). **Shipped as its own entry point `motionary/components/snap-carousel`** — from 10.8 new components are not added to `motionary/components/widgets` or the all-components `motionary/components/lite` bundle, whose fixed 70 KB gzip budget stays as it is.
15
+ - **`motionary/runtime/gltf-anim`** — glTF 2.0 **animation** (translation / rotation / scale / weights channels; `LINEAR` with quaternion slerp, `STEP`, `CUBICSPLINE` Hermite with in / out tangents), **skinning** (joint hierarchy, inverse bind matrices, 4 influences per vertex) and **morph targets** (POSITION + NORMAL deltas; mesh, node and animated weights) for models loaded by `motionary/runtime/format-gltf`, deformed on the CPU so every runtime/gl material works. `gltfAnimator(model, { clip, loop, speed })` → `seek()`, `update(dt)`, `play()` on the shared ticker; `gltfClips`, `sampleChannel`, `applyClip`, `deformModel`, `deformGeometry` are pure. Fixed gzip budget.
16
+ - `motionary/runtime/format-gltf`: **sparse accessors**; skin and morph data are kept on each geometry (`geometry.deform`) and node (`extras.skin`, `extras.weights`). `motionary/runtime/gl`: `geometry.version` — bump it after changing positions / normals and the renderer re-uploads them.
17
+ - **`<usa-gl-scene animation>`** plays a clip (name or index; empty = the first) with `animation-speed`; reduced motion shows the first pose; `animator` property; `usa:load` lists the clips. Animation needs `motionary/runtime/gltf-anim` (all five prerequisite places list it for the new "3D animation" card).
18
+ - **Lottie text layers** in `motionary/runtime/vector`: fonts by family + style (weight / italic), justification, tracking, line height, fill + stroke (stroke over fill), box text with word wrapping, source-text keyframes and source-text expressions.
19
+ - **Lottie expression subset** with Motionary's own interpreter — **no `eval` / `new Function`** (works under a strict CSP; an expression can only call the listed helpers): `time`, `value`, `wiggle()`, `loopOut()` / `loopIn()` (cycle · pingpong · offset · continue, + `…Duration`), `linear()`, `ease()`, `easeIn()`, `easeOut()`, `clamp()`, `valueAtTime()`, `framesToTime()`, `timeToFrames()`, `degreesToRadians()`, `radiansToDegrees()`, `add` / `sub` / `mul` / `div` / `length`, `Math.*`, arithmetic on numbers and arrays, `var` / `$bm_rt =`, comparisons and `?:`. Anything else keeps the keyframed value and `inspectLottie()` lists "expressions outside the supported subset". `evalExpression(src, value, time, fr)` is exported.
20
+ - New gallery / Store cards: snap carousel, 3D animation (a self-made skinned tentacle with two clips), Lottie text + expressions. Self-made, MIT test fixtures: `sample-skin.gltf`, `sample-morph.gltf` (one sparse target), `motionary-tentacle.glb`, `sample-text.json` (credits in `test/fixtures/formats/CREDITS.md`).
21
+ - Prerequisites for both new runtime modules appear in all five places (gallery card, Store detail with the **Requires:** badge, `docs/runtime/drag-snap.md` + `docs/runtime/gltf-anim.md` with compatibility tables, README, AI manifest); the format-gltf and vector compatibility tables are updated.
22
+
23
+ ### Accessibility
24
+ - `<usa-snap-carousel>` is a labelled `region` (`aria-roledescription="carousel"`), slides are `group`s labelled "n of N", the viewport is focusable with ←/→ / Home / End, prev / next are real buttons (disabled at the ends), dots are labelled buttons with `aria-current`, slide changes made with keys or buttons are announced politely; autoplay pauses on hover / focus and is off under reduced motion, where moves are instant.
25
+ - `<usa-gl-scene animation>`: reduced motion shows the first pose instead of playing.
26
+
27
+ ### Deferred (from the 10.8 plan)
28
+ - Cross-platform 3.0 (mini-program / HarmonyOS ArkTS samples, cross-platform previewer) and "manifest covers all effects" are not in this release; they stay on the roadmap after 11.0.
29
+
30
+ ## [10.7.0] - 2026-10-09
31
+
32
+ ### Added
33
+ - **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).
34
+ - **`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.
35
+ - **`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.
36
+ - **`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.
37
+ - **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`).
38
+ - 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).
39
+
40
+ ### Fixed
41
+ - `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.
42
+
43
+ ### Accessibility
44
+ - `<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.
45
+
10
46
  ## [10.6.0] - 2026-10-09
11
47
 
12
48
  ### Added
package/README.md CHANGED
@@ -189,6 +189,10 @@ Motionary ships its own zero-dependency animation runtime — shared ticker, twe
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
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
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 |
194
+ | [Drag, inertia and snap points](docs/runtime/drag-snap.md) | `motionary/runtime/drag-snap` | `https://cdn.jsdelivr.net/npm/motionary@10/dist/runtime/drag-snap.iife.js` | `use(dragSnap);` | 4.0 KB |
195
+ | [glTF animation, skinning and morph targets](docs/runtime/gltf-anim.md) | `motionary/runtime/gltf-anim` | `https://cdn.jsdelivr.net/npm/motionary@10/dist/runtime/gltf-anim.iife.js` | `use(gltfAnim);` | 4.5 KB |
192
196
 
193
197
  Install once: `npm i motionary`. Plain HTML: load `runtime.iife.js` first, then the module files (each registers itself).
194
198
 
@@ -315,19 +319,20 @@ defineSmoothScroll(); // registers <usa-smooth-scroll> — after the prerequisit
315
319
  <usa-smooth-scroll lerp="0.1" offset="64"></usa-smooth-scroll>
316
320
  ```
317
321
 
318
- #### `<usa-gl-scene>` — Requires: motionary/runtime/gl + motionary/runtime/format-gltf + motionary/runtime/format-obj
322
+ #### `<usa-gl-scene>` — Requires: motionary/runtime/gl + motionary/runtime/format-gltf + motionary/runtime/format-obj + motionary/runtime/gltf-anim
319
323
 
320
324
  - **Install:** `npm i motionary`
321
- - **Import order & registration:** Register the core first, then the module: use(gl) also registers the core. CDN: load runtime.iife.js, then runtime/gl.iife.js (it registers itself). Register the core first, then the module: use(formatGltf) also registers the core. CDN: load runtime.iife.js, then runtime/format-gltf.iife.js (it registers itself). Register the core first, then the module: use(formatObj) also registers the core. CDN: load runtime.iife.js, then runtime/format-obj.iife.js (it registers itself).
325
+ - **Import order & registration:** Register the core first, then the module: use(gl) also registers the core. CDN: load runtime.iife.js, then runtime/gl.iife.js (it registers itself). Register the core first, then the module: use(formatGltf) also registers the core. CDN: load runtime.iife.js, then runtime/format-gltf.iife.js (it registers itself). Register the core first, then the module: use(formatObj) also registers the core. CDN: load runtime.iife.js, then runtime/format-obj.iife.js (it registers itself). Register the core first, then the module: use(gltfAnim) also registers the core. CDN: load runtime.iife.js, then runtime/gltf-anim.iife.js (it registers itself).
322
326
 
323
327
  ```js
324
328
  import { use } from 'motionary/runtime';
325
329
  import { gl } from 'motionary/runtime/gl';
326
330
  import { formatGltf } from 'motionary/runtime/format-gltf';
327
331
  import { formatObj } from 'motionary/runtime/format-obj';
332
+ import { gltfAnim } from 'motionary/runtime/gltf-anim';
328
333
  import { defineGlScene } from 'motionary/components/widgets';
329
334
 
330
- use(gl, formatGltf, formatObj);
335
+ use(gl, formatGltf, formatObj, gltfAnim);
331
336
  defineGlScene(); // registers <usa-gl-scene> — after the prerequisites
332
337
  ```
333
338
 
@@ -338,6 +343,7 @@ defineGlScene(); // registers <usa-gl-scene> — after the prerequisites
338
343
  <script src="https://cdn.jsdelivr.net/npm/motionary@10/dist/runtime/gl.iife.js"></script>
339
344
  <script src="https://cdn.jsdelivr.net/npm/motionary@10/dist/runtime/format-gltf.iife.js"></script>
340
345
  <script src="https://cdn.jsdelivr.net/npm/motionary@10/dist/runtime/format-obj.iife.js"></script>
346
+ <script src="https://cdn.jsdelivr.net/npm/motionary@10/dist/runtime/gltf-anim.iife.js"></script>
341
347
  <!-- then the component bundles -->
342
348
  <script src="https://unpkg.com/motionary@10/dist/components.umd.js"></script>
343
349
  <script src="https://unpkg.com/motionary@10/dist/widgets.umd.js"></script>
@@ -407,6 +413,72 @@ defineRive(); // registers <usa-rive> — after the prerequisites
407
413
  <usa-rive src="/anim/icon.riv" state-machine="State Machine 1" autoplay label="Icon"></usa-rive>
408
414
  ```
409
415
 
416
+ #### `<usa-physics-playground>` — Requires: motionary/runtime/physics + motionary/runtime/format-scene
417
+
418
+ - **Install:** `npm i motionary`
419
+ - **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).
420
+
421
+ ```js
422
+ import { use } from 'motionary/runtime';
423
+ import { physics } from 'motionary/runtime/physics';
424
+ import { formatScene } from 'motionary/runtime/format-scene';
425
+ import { definePhysicsPlayground } from 'motionary/components/widgets';
426
+
427
+ use(physics, formatScene);
428
+ definePhysicsPlayground(); // registers <usa-physics-playground> — after the prerequisites
429
+ ```
430
+
431
+ - **CDN:**
432
+
433
+ ```html
434
+ <script src="https://cdn.jsdelivr.net/npm/motionary@10/dist/runtime.iife.js"></script>
435
+ <script src="https://cdn.jsdelivr.net/npm/motionary@10/dist/runtime/physics.iife.js"></script>
436
+ <script src="https://cdn.jsdelivr.net/npm/motionary@10/dist/runtime/format-scene.iife.js"></script>
437
+ <!-- then the component bundles -->
438
+ <script src="https://unpkg.com/motionary@10/dist/components.umd.js"></script>
439
+ <script src="https://unpkg.com/motionary@10/dist/widgets.umd.js"></script>
440
+ ```
441
+
442
+ - **Minimal example:**
443
+
444
+ ```html
445
+ <usa-physics-playground preset="pyramid" spawn label="Knock the pyramid over"></usa-physics-playground>
446
+ ```
447
+
448
+ #### `<usa-snap-carousel>` — Requires: motionary/runtime/drag-snap
449
+
450
+ - **Install:** `npm i motionary`
451
+ - **Import order & registration:** Register the core first, then the module: use(dragSnap) also registers the core. CDN: load runtime.iife.js, then runtime/drag-snap.iife.js (it registers itself).
452
+
453
+ ```js
454
+ import { use } from 'motionary/runtime';
455
+ import { dragSnap } from 'motionary/runtime/drag-snap';
456
+ import { defineSnapCarousel } from 'motionary/components/snap-carousel';
457
+
458
+ use(dragSnap);
459
+ defineSnapCarousel(); // registers <usa-snap-carousel> — after the prerequisites
460
+ ```
461
+
462
+ - **CDN:**
463
+
464
+ ```html
465
+ <script src="https://cdn.jsdelivr.net/npm/motionary@10/dist/runtime.iife.js"></script>
466
+ <script src="https://cdn.jsdelivr.net/npm/motionary@10/dist/runtime/drag-snap.iife.js"></script>
467
+ <!-- then the component bundles -->
468
+ <script src="https://unpkg.com/motionary@10/dist/components.umd.js"></script>
469
+ <script src="https://unpkg.com/motionary@10/dist/widgets.umd.js"></script>
470
+ ```
471
+
472
+ - **Minimal example:**
473
+
474
+ ```html
475
+ <usa-snap-carousel align="center" gap="16" label="Featured">
476
+ <article>…</article>
477
+ <article>…</article>
478
+ <article>…</article>
479
+ </usa-snap-carousel>
480
+ ```
481
+
410
482
  <!-- runtime:end -->
411
483
 
412
484
  ## Accessibility & reduced motion
@@ -440,7 +512,8 @@ Evergreen browsers since 2023: Chrome / Edge ≥ 111, Safari ≥ 16.4, Firefox
440
512
 
441
513
  ## Documentation
442
514
 
443
- - **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).
515
+ - **Individual entry points (10.8+):** new components ship as their own entry (`motionary/components/snap-carousel`) and are not added to `motionary/components/widgets` or the all-components `motionary/components/lite` bundle (its 70 KB gzip budget is fixed).
516
+ - **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).
444
517
  - **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.
445
518
 
446
519
  - [API reference](./docs/API.md) — every export, option and `data-sa-*` attribute
@@ -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.1.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
- const brief = (c) => ({ tag: c.tag, title: c.title, category: c.category, import: c.import.path, requires: c.requires.map((r) => (r === 'core' ? 'motionary/runtime' : r.includes('/') || r.startsWith('@') ? r : `motionary/runtime/${r}`)), since: c.since, description: c.description.slice(0, 200) });
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.startsWith('@'));
82
- const peers = [...new Set(comps.flatMap((c) => c.requires))].filter((r) => r.startsWith('@'));
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((r) => (r === 'core' ? 'motionary/runtime' : `motionary/runtime/${r}`)).join(', ')} — register them before the components mount.` : 'No prerequisites.';
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((r) => (r === 'core' ? 'motionary/runtime' : `motionary/runtime/${r}`)).concat(peers), code };
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-CmkdSyaC.cjs');
3
+ var tween = require('./tween--MD-39y0.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-DECLkPH4.cjs.map
174
+ //# sourceMappingURL=anim-image-BzTQa2k3.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"anim-image-DECLkPH4.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,EAA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CAAC,GAAG,UAAU,MAAM,CAAC;AAC/B;;;;;;;;"}
1
+ {"version":3,"file":"anim-image-BzTQa2k3.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,CA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G,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,4 +1,4 @@
1
- import { P as Playable } from './tween-BzCGq_Ba.js';
1
+ import { P as Playable } from './tween-DACdkLyO.js';
2
2
 
3
3
  /**
4
4
  * 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-DNghy017.js.map
166
+ //# sourceMappingURL=anim-image-iD646Q7i.js.map