@liqweed/motion-kit 0.4.0 → 0.5.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/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/README.md +13 -5
- package/adapters/element/README.md +5 -0
- package/adapters/page/README.md +5 -0
- package/cli/motion-kit.mjs +9 -3
- package/docs/spec/technique.md +93 -30
- package/examples/custom-pulse.scene.mjs +3 -0
- package/examples/incident.json +18 -0
- package/examples/web-stack.json +17 -0
- package/lib/build.mjs +1 -1
- package/lib/check.mjs +207 -16
- package/lib/export.mjs +104 -7
- package/lib/gate.mjs +5 -3
- package/package.json +6 -3
- package/runtime/kit.mjs +2 -2
- package/runtime/links.mjs +314 -0
- package/runtime/parts.mjs +15 -0
- package/runtime/patch.mjs +297 -0
- package/runtime/player.mjs +5 -1
- package/runtime/scene.mjs +3 -1
- package/runtime/style.mjs +62 -16
- package/runtime/types/hub-spoke.mjs +2 -2
- package/runtime/types/index.mjs +4 -0
- package/runtime/types/sequence.mjs +2 -2
- package/runtime/types/stack.mjs +227 -0
- package/runtime/types/timeline.mjs +405 -0
- package/skills/animated-diagram/SKILL.md +27 -6
- package/skills/animated-diagram/references/custom-scenes.md +6 -1
- package/skills/animated-diagram/references/interactivity.md +111 -6
- package/skills/animated-diagram/references/qc.md +3 -0
- package/skills/animated-diagram/references/scene-types.md +45 -2
- package/skills/animated-diagram/references/styles.md +45 -5
- package/skills/animated-diagram/references/technique.md +9 -4
- package/skills/motion-render/SKILL.md +24 -6
- package/skills/motion-render/references/formats.md +8 -8
- package/skills/project-logo/SKILL.md +15 -4
- package/styles/neutral.json +2 -2
|
@@ -38,6 +38,51 @@ time draws (carrying an emphasis dot) and the spoke fills. Steps = hub, then
|
|
|
38
38
|
each spoke. Layouts: radial ellipse (wide/square), tree with an outside trunk
|
|
39
39
|
(9:16, tall). Throws when boxes would overlap: fewer spokes or a larger format.
|
|
40
40
|
|
|
41
|
+
### `timeline`: events in time
|
|
42
|
+
|
|
43
|
+
```json
|
|
44
|
+
{ "type": "timeline", "id": "incident",
|
|
45
|
+
"title": "…", "description": "…",
|
|
46
|
+
"events": [ { "when": "09:02", "label": "Alert fires", "detail": "…" },
|
|
47
|
+
…,
|
|
48
|
+
{ "when": "Thursday", "label": "Review", "planned": true } ],
|
|
49
|
+
"now": { "label": "Now", "detail": "…" }, // optional
|
|
50
|
+
"fontSize": 18 } // optional max; auto-fit otherwise
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
2–8 events in time order, each with a short `when` (one line: "09:02",
|
|
54
|
+
"Q3 2026") and a `label`. `planned: true` marks an event still to come;
|
|
55
|
+
planned events go last and need a `now`. Events and `now` may carry an `id`
|
|
56
|
+
for their step. Storyboard: the axis draws on → milestones drop onto it in
|
|
57
|
+
order; an event that has happened fills accent and the axis behind it turns
|
|
58
|
+
accent, a planned one stays pending → the "now" marker (the emphasis element)
|
|
59
|
+
settles on the axis after the last past event. Steps = one per event, then
|
|
60
|
+
`now`. Events are spaced evenly, not to scale. Layouts: horizontal axis with
|
|
61
|
+
labels below, or alternating above and below when that saves lines (wide
|
|
62
|
+
aspects, 1:1); vertical axis with labels on the right (9:16, tall). Throws when
|
|
63
|
+
a label or the now marker does not fit: fewer events, shorter labels or a
|
|
64
|
+
larger format.
|
|
65
|
+
|
|
66
|
+
### `stack`: layers that build on each other
|
|
67
|
+
|
|
68
|
+
```json
|
|
69
|
+
{ "type": "stack", "id": "web-stack",
|
|
70
|
+
"title": "…", "description": "…",
|
|
71
|
+
"layers": [ { "label": "Browser", "detail": "…" }, …,
|
|
72
|
+
{ "label": "Database", "detail": "…" } ],
|
|
73
|
+
"direction": "down", // or "up": the packet enters at the bottom
|
|
74
|
+
"fontSize": 18 } // optional max; auto-fit otherwise
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
2–8 layers, listed top to bottom as drawn; a layer may carry an `id` for its
|
|
78
|
+
step. Storyboard: the layers rise into place bottom-up → a packet (the emphasis
|
|
79
|
+
dot) enters on a rail beside the stack and hops layer to layer; the layer it
|
|
80
|
+
reaches fills accent, a layer it has left keeps an accent outline, and the rail
|
|
81
|
+
behind it turns accent. Steps = one per layer, in travel order (top → bottom
|
|
82
|
+
for `down`, bottom → top for `up`). Layout: one column of layers with the rail
|
|
83
|
+
on the right in every format; labels take one line, two when needed. Throws
|
|
84
|
+
when the layers do not fit: fewer layers, shorter labels or a larger format.
|
|
85
|
+
|
|
41
86
|
## Storyboards for types not built yet
|
|
42
87
|
|
|
43
88
|
Build these as custom scenes (`custom-scenes.md`) first. Promote one to a type
|
|
@@ -45,9 +90,7 @@ once it has been used twice.
|
|
|
45
90
|
|
|
46
91
|
| Type | Helps the viewer understand | Storyboard |
|
|
47
92
|
|---|---|---|
|
|
48
|
-
| `stack` | layers build on each other (architecture, security layers) | layers rise bottom-up; then a request/data packet travels down/up, each layer lighting as it passes |
|
|
49
93
|
| `before-after` | what changes | left state fully shown → a divider sweeps → right state builds; differences highlighted with the emphasis colour |
|
|
50
|
-
| `timeline` | events in time | axis draws on → milestones drop in order → "now" marker settles |
|
|
51
94
|
| `comparison` | option A vs B on criteria | two columns appear → criteria rows fill one at a time → the deciding row emphasised |
|
|
52
95
|
| `state-machine` | states and transitions | all states (pending) → a token walks a path of transitions, the current state accent |
|
|
53
96
|
| `request-journey` | a request crossing system components | components in regions/boundaries → a dot travels the path, each hop lights, async edges dashed |
|
|
@@ -27,15 +27,55 @@ properties (light + dark); standalone exports resolve them to literals.
|
|
|
27
27
|
"font": "Inter, ui-sans-serif, system-ui, sans-serif",
|
|
28
28
|
"radius": 10,
|
|
29
29
|
"stroke": 2,
|
|
30
|
-
"light": { "accent": "#
|
|
31
|
-
"dark": { "accent": "#
|
|
30
|
+
"light": { "accent": "#0a2a8a", "emphasis": "#05966a" },
|
|
31
|
+
"dark": { "accent": "#2563eb", "emphasis": "#a7f3d0" }
|
|
32
32
|
}
|
|
33
33
|
```
|
|
34
34
|
|
|
35
35
|
Missing tokens fall back to neutral. Colours must be `#rrggbb`. Unknown tokens
|
|
36
|
-
throw.
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
throw.
|
|
37
|
+
|
|
38
|
+
## Contrast
|
|
39
|
+
|
|
40
|
+
`motion-kit check --style acme.json …` checks every token pair the scene types
|
|
41
|
+
draw where the pair carries meaning in a step frame (`CONTRAST_PAIRS` in
|
|
42
|
+
`runtime/style.mjs`), in both themes, at WCAG thresholds: 4.5:1 for text,
|
|
43
|
+
3:1 for shapes and strokes.
|
|
44
|
+
|
|
45
|
+
| Pair | Needs | Where it is drawn |
|
|
46
|
+
|---|---|---|
|
|
47
|
+
| ink on bg | 4.5 | labels of reached nodes, on the canvas |
|
|
48
|
+
| ink on surface | 4.5 | labels inside pending boxes |
|
|
49
|
+
| muted on bg | 4.5 | labels of pending nodes, on the canvas |
|
|
50
|
+
| muted on surface | 4.5 | glyphs and icons inside pending circles |
|
|
51
|
+
| onAccent on accent | 4.5 | labels, glyphs and icons inside reached nodes |
|
|
52
|
+
| line on bg | 3 | connectors, outlines of pending nodes |
|
|
53
|
+
| accent on bg | 3 | reached nodes, drawn connectors |
|
|
54
|
+
| emphasis on bg | 3 | the emphasis ring and dot on the canvas |
|
|
55
|
+
| emphasis on accent | 3 | the ring around the reached node it marks: "here" told from "reached" without relying on hue |
|
|
56
|
+
|
|
57
|
+
Exempt (`CONTRAST_EXEMPT`), each for a reason:
|
|
58
|
+
|
|
59
|
+
| Pair | Why it is not checked |
|
|
60
|
+
|---|---|
|
|
61
|
+
| line on surface | a pending node's outline is its edge, told from the canvas outside it (line on bg), not from its own fill |
|
|
62
|
+
| accent on surface | the reached layer covers the pending one only while a node fills; a scene that draws accent on surface (a bar on a track) declares the pair |
|
|
63
|
+
| emphasis on surface | the ring crosses pending nodes only mid-hop, never in a step frame |
|
|
64
|
+
| accent on line | the accent draw-on covers the pending line; they meet only at the moving tip |
|
|
65
|
+
| onAccent on emphasis | no scene type draws it; the motion-kit logo does, and logos are exempt from WCAG 1.4.11 |
|
|
66
|
+
|
|
67
|
+
Emphasis on accent is the pair most palettes miss: two saturated colours of
|
|
68
|
+
the same lightness (blue and orange, teal and rust) are about 1:1 apart once
|
|
69
|
+
hue is gone. On a white canvas it usually means a dark accent (neutral light
|
|
70
|
+
uses `#1d36a8`) with a mid-tone emphasis; on a dark canvas, a light emphasis
|
|
71
|
+
(neutral dark uses `#fbbf24`).
|
|
72
|
+
|
|
73
|
+
A custom scene that draws another pair declares it, and the gate checks the
|
|
74
|
+
style against it for that scene:
|
|
75
|
+
|
|
76
|
+
```js
|
|
77
|
+
return { …, contrastPairs: [{ fg: "accent", bg: "surface", min: 3, use: "progress bar on its track" }] };
|
|
78
|
+
```
|
|
39
79
|
|
|
40
80
|
## Where style files live
|
|
41
81
|
|
|
@@ -31,7 +31,9 @@ Video maps frame `f` at `fps` to `t = f / fps` (30 fps × 25 s = 750 frames).
|
|
|
31
31
|
7. Round every number. `el()` rounds numeric attributes; numbers you put in a
|
|
32
32
|
template string (`transform`, `points`, path `d`) must go through `num()`.
|
|
33
33
|
The gate rejects any number with 5+ decimals.
|
|
34
|
-
8. No `Date`, `Math.random()`, `performance.now()` inside a scene
|
|
34
|
+
8. No `Date`, `Math.random()`, `performance.now()` inside a scene, nor in the
|
|
35
|
+
helpers it calls: the gate renders every sample under two stubbed clocks
|
|
36
|
+
and refuses a frame whose bytes change.
|
|
35
37
|
9. **Step frames are settled** (§4).
|
|
36
38
|
10. Markup is balanced and escaped: labels cannot inject markup.
|
|
37
39
|
11. Visibility decisions use rounded values: an element whose opacity rounds to
|
|
@@ -82,9 +84,12 @@ Patterns:
|
|
|
82
84
|
|
|
83
85
|
`steps[i].at` is when build step *i* is fully shown, and its frame is what a
|
|
84
86
|
slide shows. It must look intentional on its own: nothing mid-motion, no
|
|
85
|
-
half-drawn line pointing at nothing, no fading dot. Rule: **the
|
|
86
|
-
|
|
87
|
-
|
|
87
|
+
half-drawn line pointing at nothing, no fading dot. Rule: **the step's own
|
|
88
|
+
motion comes to rest by `at`, and the next motion starts no earlier than
|
|
89
|
+
50 ms after it.** The gate asserts `frame(at − 1 ms) === frame(at)` and that
|
|
90
|
+
the frames 1, 15, 30 and 45 ms after `at` equal it too, so a slow fade passing
|
|
91
|
+
through `at` fails even when rounding hides it over 1 ms. Anything that fades
|
|
92
|
+
out by a step (a travelling dot) must reach 0 by `at`.
|
|
88
93
|
|
|
89
94
|
## 5. Layouts are computed per format
|
|
90
95
|
|
|
@@ -6,12 +6,22 @@ description: "Render motion-kit scenes (animated diagrams) to deliverables: slid
|
|
|
6
6
|
# Motion render
|
|
7
7
|
|
|
8
8
|
All outputs come from the same pure scene, so they always agree. Locate the
|
|
9
|
-
toolkit as in the animated-diagram skill
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
toolkit as in the animated-diagram skill's "Locate the toolkit": first
|
|
10
|
+
`MOTION_KIT_HOME`, then the npm package through `npx` (at the version of these
|
|
11
|
+
skills), then the plugin copy two levels above this skill. PNG and video need
|
|
12
|
+
`@resvg/resvg-js`, which the `npx` route installs; video also needs `ffmpeg`.
|
|
13
|
+
The plugin copy alone has neither, so prefer `npx` there.
|
|
12
14
|
|
|
13
15
|
```bash
|
|
14
|
-
|
|
16
|
+
PLUGIN="$(cd -P "<this skill's base directory>" && cd ../.. && pwd -P)" # -P: the base may be a symlink to a clone
|
|
17
|
+
V="$(node -p "require(process.argv[1] + '/package.json').version" "$PLUGIN")"
|
|
18
|
+
if [ -n "${MOTION_KIT_HOME:-}" ]; then
|
|
19
|
+
MK="$MOTION_KIT_HOME"; mk() { node "$MK/cli/motion-kit.mjs" "$@"; }
|
|
20
|
+
elif npx -y "@liqweed/motion-kit@$V" --help >/dev/null 2>&1; then
|
|
21
|
+
MK="$PLUGIN"; mk() { npx -y "@liqweed/motion-kit@$V" "$@"; }
|
|
22
|
+
else
|
|
23
|
+
MK="$PLUGIN"; mk() { node "$MK/cli/motion-kit.mjs" "$@"; }
|
|
24
|
+
fi
|
|
15
25
|
```
|
|
16
26
|
|
|
17
27
|
**Always run `mk check <scene>` first.** Exporters refuse scenes that fail the gate.
|
|
@@ -80,5 +90,13 @@ errors, and cleans up on disconnect. Full usage: `adapters/element/README.md`.
|
|
|
80
90
|
REVIEW.md review report with human approval line
|
|
81
91
|
```
|
|
82
92
|
`manifest.json` records scene, type, format, locale, size, duration, style,
|
|
83
|
-
theme, an input hash
|
|
84
|
-
|
|
93
|
+
theme, an input hash, the source commit and `sourceDirty` (`true` when the
|
|
94
|
+
source file has uncommitted changes, so the frames match no commit; `null`
|
|
95
|
+
outside git), with no timestamps, so a re-render from the same inputs is
|
|
96
|
+
byte-identical and a stale export is easy to spot. Deliver from a clean
|
|
97
|
+
source (`sourceDirty: false`).
|
|
98
|
+
|
|
99
|
+
Re-exporting into the same folder replaces the previous export: files its
|
|
100
|
+
`manifest.json` listed that the new export does not write are deleted, so the
|
|
101
|
+
folder holds exactly what the new manifest lists. Files no export wrote are
|
|
102
|
+
left alone and named in a warning; keep notes and review files elsewhere.
|
|
@@ -2,17 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
| Name | viewBox | Typical use | Layout behaviour |
|
|
4
4
|
|---|---|---|---|
|
|
5
|
-
| `16:9` | 960×540 | slides, YouTube, web hero | sequence row (or 2-row snake when crowded); hub-spoke radial |
|
|
6
|
-
| `4:3` | 960×720 | older decks, docs | snake grid; radial |
|
|
7
|
-
| `1:1` | 720×720 | LinkedIn/Instagram feed | snake grid; radial |
|
|
8
|
-
| `9:16` | 540×960 | Reels/Shorts/TikTok, phone | column with labels right; hub-spoke tree |
|
|
9
|
-
| `wide` | 960×auto | web strip inside a page | row; height computed |
|
|
10
|
-
| `tall` | 360×auto | phone column on a page | column / tree; height computed |
|
|
5
|
+
| `16:9` | 960×540 | slides, YouTube, web hero | sequence row (or 2-row snake when crowded); hub-spoke radial; timeline horizontal axis |
|
|
6
|
+
| `4:3` | 960×720 | older decks, docs | snake grid; radial; horizontal axis |
|
|
7
|
+
| `1:1` | 720×720 | LinkedIn/Instagram feed | snake grid; radial; horizontal axis |
|
|
8
|
+
| `9:16` | 540×960 | Reels/Shorts/TikTok, phone | column with labels right; hub-spoke tree; timeline vertical axis |
|
|
9
|
+
| `wide` | 960×auto | web strip inside a page | row; horizontal axis; height computed |
|
|
10
|
+
| `tall` | 360×auto | phone column on a page | column / tree / vertical axis; height computed |
|
|
11
11
|
|
|
12
|
-
Fixed formats auto-fit text up to 22 px (sequence) / 20 px (hub-spoke) and
|
|
12
|
+
Fixed formats auto-fit text up to 22 px (sequence, timeline, stack) / 20 px (hub-spoke) and
|
|
13
13
|
step down to 14 px; strips max 16 px. A spec that cannot fit fails `check`
|
|
14
14
|
with a reason. Fix it with shorter labels, fewer nodes, or another format.
|
|
15
|
-
Never by cropping.
|
|
15
|
+
Never by cropping. A `stack` is one column of layers in every format.
|
|
16
16
|
|
|
17
17
|
Web pages: mount `wide` + `tall` and switch at the width where the wide
|
|
18
18
|
layout's text would fall below ~14 px on screen.
|
|
@@ -12,12 +12,23 @@ Same gate, same determinism as any diagram.
|
|
|
12
12
|
|
|
13
13
|
## Locate the toolkit
|
|
14
14
|
|
|
15
|
+
As in the animated-diagram skill: first `MOTION_KIT_HOME`, then the npm
|
|
16
|
+
package through `npx` (at the version of these skills), then the plugin copy.
|
|
17
|
+
`$MK` holds the template files (`brand/`, `styles/`); `mk` runs the CLI.
|
|
18
|
+
|
|
15
19
|
```bash
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
20
|
+
PLUGIN="$(cd -P "<this skill's base directory>" && cd ../.. && pwd -P)" # -P: the base may be a symlink to a clone
|
|
21
|
+
V="$(node -p "require(process.argv[1] + '/package.json').version" "$PLUGIN")"
|
|
22
|
+
if [ -n "${MOTION_KIT_HOME:-}" ]; then
|
|
23
|
+
MK="$MOTION_KIT_HOME"; mk() { node "$MK/cli/motion-kit.mjs" "$@"; }
|
|
24
|
+
elif npx -y "@liqweed/motion-kit@$V" --help >/dev/null 2>&1; then
|
|
25
|
+
MK="$PLUGIN"; mk() { npx -y "@liqweed/motion-kit@$V" "$@"; }
|
|
26
|
+
else
|
|
27
|
+
MK="$PLUGIN"; mk() { node "$MK/cli/motion-kit.mjs" "$@"; }
|
|
28
|
+
fi
|
|
19
29
|
```
|
|
20
|
-
Node ≥ 22. PNG needs `@resvg/resvg-js
|
|
30
|
+
Node ≥ 22. PNG needs `@resvg/resvg-js`: the `npx` route installs it; in
|
|
31
|
+
`$MOTION_KIT_HOME`, run `npm install`. The plugin copy alone renders SVG only.
|
|
21
32
|
|
|
22
33
|
## Workflow
|
|
23
34
|
|
package/styles/neutral.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"ink": "#111827",
|
|
10
10
|
"muted": "#4b5563",
|
|
11
11
|
"line": "#8b929c",
|
|
12
|
-
"accent": "#
|
|
12
|
+
"accent": "#1d36a8",
|
|
13
13
|
"onAccent": "#ffffff",
|
|
14
14
|
"emphasis": "#d97706"
|
|
15
15
|
},
|
|
@@ -21,6 +21,6 @@
|
|
|
21
21
|
"line": "#6b7280",
|
|
22
22
|
"accent": "#2563eb",
|
|
23
23
|
"onAccent": "#ffffff",
|
|
24
|
-
"emphasis": "#
|
|
24
|
+
"emphasis": "#fbbf24"
|
|
25
25
|
}
|
|
26
26
|
}
|