@whzxc/agent-design-gallery 0.15.0 → 0.16.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/README.md +5 -2
- package/package.json +2 -1
- package/public/app.js +602 -64
- package/public/assets.js +25 -10
- package/public/boards.js +8 -3
- package/public/frame-identity.js +25 -12
- package/public/icons.js +7 -0
- package/public/index.html +14 -2
- package/public/motion-flow.js +28 -0
- package/public/motion-identity.js +100 -0
- package/public/motion-paint.js +332 -0
- package/public/motion-scene.js +165 -0
- package/public/motion-specimens.js +335 -0
- package/public/player.css +270 -0
- package/public/player.js +753 -0
- package/public/recent-updates.js +535 -0
- package/public/style.css +17 -2
- package/public/tokens.css +6 -0
- package/public/view-boards.css +131 -0
- package/public/view-boards.js +350 -0
- package/public/view-route.js +1 -1
- package/src/boards/motion-board.mjs +202 -0
- package/src/boards/token-board.mjs +9 -5
- package/src/cli-output.mjs +3 -1
- package/src/cli.mjs +52 -18
- package/src/http.mjs +5 -2
- package/src/recent-frames.mjs +295 -0
- package/src/recent-history.mjs +100 -0
- package/src/recent-job.mjs +63 -0
- package/src/recent-worker.mjs +171 -0
- package/src/server.mjs +229 -18
- package/src/toolkit/arch-git.mjs +8 -14
- package/src/toolkit/browser.mjs +1 -13
- package/src/toolkit/build-store.mjs +9 -1
- package/src/toolkit/build-worker.mjs +6 -0
- package/src/toolkit/build.mjs +22 -16
- package/src/toolkit/commands.mjs +93 -2
- package/src/toolkit/compare.mjs +13 -11
- package/src/toolkit/config.mjs +2 -2
- package/src/toolkit/diff-inputs.mjs +35 -26
- package/src/toolkit/diff.mjs +24 -11
- package/src/toolkit/frame-declarations.mjs +36 -0
- package/src/toolkit/git-blobs.mjs +50 -0
- package/src/toolkit/impact-inputs.mjs +11 -19
- package/src/toolkit/impact-selection.mjs +2 -2
- package/src/toolkit/impact.mjs +17 -3
- package/src/toolkit/implementation-map.mjs +17 -6
- package/src/toolkit/input-generation.mjs +15 -0
- package/src/toolkit/inspect-output.mjs +1 -1
- package/src/toolkit/inspect.d.ts +9 -1
- package/src/toolkit/inspect.mjs +25 -1
- package/src/toolkit/motion-check.mjs +382 -0
- package/src/toolkit/motion-css.mjs +105 -0
- package/src/toolkit/motion-flows.mjs +95 -0
- package/src/toolkit/motion-impact.mjs +87 -0
- package/src/toolkit/motion-inventory.mjs +202 -0
- package/src/toolkit/motion-label.mjs +111 -0
- package/src/toolkit/motion-patterns.mjs +216 -0
- package/src/toolkit/motion-primitives.mjs +94 -0
- package/src/toolkit/motion-queries.mjs +169 -0
- package/src/toolkit/motion.mjs +300 -0
- package/src/toolkit/owner.mjs +19 -6
- package/src/toolkit/play-endpoint.mjs +66 -0
- package/src/toolkit/project-index.mjs +2 -2
- package/src/toolkit/recent-structure.mjs +201 -0
- package/src/toolkit/results.mjs +2 -2
- package/src/toolkit/review-document.mjs +9 -4
- package/src/toolkit/review-embed-document.mjs +671 -0
- package/src/toolkit/review-filmstrip.mjs +76 -0
- package/src/toolkit/review-motion-card.mjs +51 -0
- package/src/toolkit/review-motion.mjs +159 -0
- package/src/toolkit/review-playback.js +123 -0
- package/src/toolkit/review-sheet.mjs +36 -28
- package/src/toolkit/review.mjs +131 -31
- package/src/toolkit/runtime.mjs +7 -1
- package/src/viewer-cache.mjs +48 -12
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { escape } from '../toolkit/html.mjs';
|
|
2
|
+
import { patternParameters } from '../toolkit/motion-patterns.mjs';
|
|
3
|
+
import { milliseconds, tokenValue } from '../toolkit/motion-primitives.mjs';
|
|
4
|
+
|
|
5
|
+
export const motionBoardCss = `
|
|
6
|
+
[data-motion-patterns]{--motion-columns:3;display:grid;grid-template-columns:repeat(var(--motion-columns),minmax(0,1fr));gap:16px;align-items:start;margin-bottom:32px}
|
|
7
|
+
[data-motion-pattern],[data-motion-detail]{min-width:0;border:1px solid var(--adg-border);border-radius:var(--radius-card,12px);background:var(--adg-surface)}
|
|
8
|
+
[data-motion-pattern]{height:192px;display:grid;grid-template-rows:34px minmax(0,1fr) 18px 22px;gap:8px;padding:12px 14px;cursor:pointer;pointer-events:auto}
|
|
9
|
+
[data-motion-pattern]:is(:hover,:focus-within,[data-expanded]){border-color:var(--border-strong,var(--adg-text))}
|
|
10
|
+
[data-motion-pattern] h3,[data-motion-detail] h3,[data-motion-detail] h4,[data-motion-pattern] p,[data-motion-detail] p{margin:0}
|
|
11
|
+
[data-motion-pattern] h3{font-size:15px;line-height:19px}
|
|
12
|
+
[data-motion-pattern] [data-motion-toggle]{display:block;max-width:100%;padding:0;border:0;background:none;color:inherit;font:inherit;text-align:left;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;cursor:pointer}
|
|
13
|
+
[data-motion-pattern] p,[data-motion-detail] p,[data-motion-detail] dl{font:13px/1.45 var(--font-ui,system-ui);color:var(--adg-muted)}
|
|
14
|
+
[data-motion-pattern] header p{font-size:12px;line-height:15px}
|
|
15
|
+
[data-motion-summary]{font:12px/18px var(--font-mono,monospace);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
16
|
+
[data-motion-timing=dark]{display:none}
|
|
17
|
+
:where([data-theme="dark"]) [data-motion-timing=light]{display:none}
|
|
18
|
+
:where([data-theme="dark"]) [data-motion-timing=dark]{display:inline}
|
|
19
|
+
[data-motion-card-foot]{display:flex;align-items:center;justify-content:space-between;gap:8px;font-size:12px;color:var(--adg-muted)}
|
|
20
|
+
[data-motion-variant-count]{padding:3px 7px;border-radius:var(--radius-pill,999px);background:var(--adg-canvas);color:var(--adg-text);white-space:nowrap}
|
|
21
|
+
[data-motion-detail]{grid-column:1/-1;pointer-events:auto;padding:20px;display:grid;gap:20px}
|
|
22
|
+
[data-motion-detail-header],[data-motion-detail-actions]{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap}
|
|
23
|
+
[data-motion-detail-header] h3{font-size:20px}
|
|
24
|
+
[data-motion-detail-actions] a{color:inherit;font-size:13px;text-underline-offset:3px}
|
|
25
|
+
[data-motion-detail] button{padding:5px 9px;border:1px solid var(--adg-border);border-radius:var(--radius-row,6px);background:var(--adg-surface);color:inherit;cursor:pointer}
|
|
26
|
+
[data-motion-detail-main]{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:20px;align-items:start}
|
|
27
|
+
[data-motion-detail-specimen]{display:grid;gap:8px;justify-items:start}
|
|
28
|
+
[data-motion-detail-specimen] [data-motion-stage]{height:168px;width:100%}
|
|
29
|
+
[data-motion-detail] dl{display:grid;grid-template-columns:auto minmax(0,1fr);gap:4px 12px;margin:0}
|
|
30
|
+
[data-motion-detail] dd{margin:0;overflow-wrap:anywhere}
|
|
31
|
+
[data-motion-detail] code{font:12px/1.5 var(--font-mono,monospace)}
|
|
32
|
+
[data-motion-detail] h4{font-size:14px;line-height:1.4}
|
|
33
|
+
[data-motion-variants]{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(220px,100%),1fr));gap:12px}
|
|
34
|
+
[data-motion-variant]{display:grid;gap:6px;align-content:start;padding:12px;border:1px solid var(--adg-border);border-radius:8px}
|
|
35
|
+
[data-motion-page]{width:min(860px,calc(100vw - 32px));max-height:calc(100dvh - 48px);padding:0;border:0;border-radius:var(--radius-card,12px);background:var(--adg-surface);color:var(--adg-text);pointer-events:auto}
|
|
36
|
+
[data-motion-page] [data-motion-stage]{height:220px}
|
|
37
|
+
[data-motion-page] [data-motion-page-link]{display:none}
|
|
38
|
+
[data-motion-page]::backdrop{background:#0007}
|
|
39
|
+
@media(max-width:600px){[data-motion-page] [data-motion-detail-main]{grid-template-columns:minmax(0,1fr)}}
|
|
40
|
+
[data-motion-default]{font:11px/1.5 var(--font-ui,system-ui);white-space:nowrap;color:var(--adg-text)}
|
|
41
|
+
[data-motion-unadopted]{margin-top:24px;border-top:1px solid var(--adg-border)}
|
|
42
|
+
[data-motion-unadopted] summary{padding:16px 0;pointer-events:auto;cursor:pointer;font-size:14px;font-weight:600}
|
|
43
|
+
[data-motion-unadopted] summary span{margin-left:8px;color:var(--adg-muted);font-weight:400}
|
|
44
|
+
[data-motion-stage]{display:grid;place-items:center;position:relative;min-width:0;overflow:hidden;border-radius:8px;background:var(--adg-canvas);color:var(--action,var(--adg-text))}
|
|
45
|
+
[data-motion-stage][data-effect=follow]{touch-action:none;cursor:crosshair}
|
|
46
|
+
[data-motion-stage][data-effect=avoid]{display:flex;flex-direction:column;justify-content:center;gap:6px}
|
|
47
|
+
[data-motion-shape]{width:52px;height:34px;border-radius:8px;background:currentColor}
|
|
48
|
+
[data-effect=expand] [data-motion-shape]{height:58px;width:86px;transform-origin:top}
|
|
49
|
+
[data-effect=avoid] [data-motion-shape]{height:18px;width:54%}
|
|
50
|
+
[data-motion-sibling]{opacity:.38}
|
|
51
|
+
[data-motion-sibling][hidden]{display:none}
|
|
52
|
+
[data-effect=follow] [data-motion-shape]{width:20px;height:20px;border-radius:50%;pointer-events:none}
|
|
53
|
+
[data-effect=crossfade] [data-motion-shape]{position:absolute;display:grid;place-items:center;color:var(--on-action,var(--adg-surface));background:var(--action,var(--adg-text));font-size:13px}
|
|
54
|
+
[data-effect=crossfade] [data-motion-shape]:nth-child(2){opacity:0}
|
|
55
|
+
[data-effect=spin] [data-motion-shape]{width:32px;height:32px;border-radius:50%;background:none;border:3px solid var(--adg-border);border-top-color:currentColor}
|
|
56
|
+
[data-effect=stagger]{grid-auto-flow:column;justify-content:center;gap:8px}
|
|
57
|
+
[data-effect=stagger] [data-motion-shape]{width:22px;height:34px}
|
|
58
|
+
[data-effect=aurora] [data-motion-shape]{position:relative;overflow:hidden;width:104px;height:52px;background:var(--adg-surface);isolation:isolate}
|
|
59
|
+
[data-motion-aurora]{position:absolute;inset:-100%;z-index:-1;background:conic-gradient(#576de8,#71c9ad,#e8b279,#ac71ce,#576de8)}
|
|
60
|
+
[data-effect=aurora] [data-motion-shape]::after{content:"";position:absolute;inset:3px;border-radius:6px;background:var(--adg-surface)}
|
|
61
|
+
[data-effect=shimmer] [data-motion-shape]{width:100px;background:linear-gradient(105deg,currentColor 28%,var(--adg-surface) 50%,currentColor 72%);background-size:250% 100%}
|
|
62
|
+
[data-motion-reduced]{display:none!important}
|
|
63
|
+
[data-motion-stage]>[data-motion-reduced]{position:absolute;right:6px;bottom:4px;color:var(--adg-muted);font:11px/1.3 var(--font-ui,system-ui)}
|
|
64
|
+
@media(prefers-reduced-motion:reduce){[data-motion-reduced]{display:block!important}}
|
|
65
|
+
`;
|
|
66
|
+
|
|
67
|
+
const shape = '<span data-motion-shape></span>';
|
|
68
|
+
const stageShapes = {
|
|
69
|
+
crossfade: '<span data-motion-shape>A</span><span data-motion-shape>B</span>',
|
|
70
|
+
avoid: '<span data-motion-shape data-motion-sibling hidden></span>' + shape + shape,
|
|
71
|
+
stagger: shape.repeat(3),
|
|
72
|
+
aurora: '<span data-motion-shape><span data-motion-aurora></span></span>',
|
|
73
|
+
};
|
|
74
|
+
const title = id => id.replaceAll('-', ' ').replace(/^./, c => c.toUpperCase());
|
|
75
|
+
const json = value => escape(JSON.stringify(value));
|
|
76
|
+
const pair = (name, value) => '<dt>' + escape(name) + '</dt><dd>' + value + '</dd>';
|
|
77
|
+
|
|
78
|
+
export function motionCards(catalog, inventory, source, prefix) {
|
|
79
|
+
const asset = name => prefix && name.startsWith(prefix + '/') ? name.slice(prefix.length + 1) : name;
|
|
80
|
+
const frameLink = ref => '?' + new URLSearchParams({ asset: asset(ref.source), frame: ref.frame });
|
|
81
|
+
const codeLink = (file, line, label) =>
|
|
82
|
+
'<a data-motion-code href="' + escape('api/motion-code?' + new URLSearchParams({ source: file, line })) + '">' + escape(label) + '</a>';
|
|
83
|
+
const listConsumer = ref => {
|
|
84
|
+
if (ref.type === 'code') return codeLink(ref.source, ref.line, ref.source + ':' + ref.line);
|
|
85
|
+
const frame = '<a href="' + escape(frameLink(ref)) + '">' + escape(ref.frame + ' · ' + ref.source) + '</a>';
|
|
86
|
+
return ref.type === 'edge' ? codeLink(ref.sidecar, ref.line, ref.id) + ' · ' + frame : frame;
|
|
87
|
+
};
|
|
88
|
+
const countLabel = count => 'Used in ' + count + (count === 1 ? ' place' : ' places');
|
|
89
|
+
const uses = id => inventory.consumers.get(id) ?? [];
|
|
90
|
+
const usage = (id, refs, prefix = '') => refs.length
|
|
91
|
+
? '<button type="button" data-motion-consumers="' + escape(title(id)) + '" aria-label="' +
|
|
92
|
+
escape(title(id) + ' · ' + countLabel(refs.length)) + '">' + prefix + countLabel(refs.length) +
|
|
93
|
+
'</button><template><ul>' + refs.map(ref => '<li>' + listConsumer(ref) + '</li>').join('') + '</ul></template>'
|
|
94
|
+
: '<p>' + countLabel(0) + '</p>';
|
|
95
|
+
const isDefault = value => catalog.defaultTokens.has(value) ||
|
|
96
|
+
(Object.hasOwn(catalog.springs.light, value) && ['-duration','-bounce'].some(suffix => catalog.defaultTokens.has(value + suffix)));
|
|
97
|
+
const defaultLabel = ' <span data-motion-default>ADG default</span>';
|
|
98
|
+
const describe = params => Object.entries(params).map(([key,value]) => {
|
|
99
|
+
const spring = catalog.springs.light[value];
|
|
100
|
+
const light = tokenValue(catalog.tokens, 'light', value);
|
|
101
|
+
const dark = tokenValue(catalog.tokens, 'dark', value);
|
|
102
|
+
const label = spring ? spring.duration + ' ms / bounce ' + spring.bounce : light;
|
|
103
|
+
const darkSpring = catalog.springs.dark[value];
|
|
104
|
+
const themeLabel = darkSpring ? darkSpring.duration + ' ms / bounce ' + darkSpring.bounce : dark;
|
|
105
|
+
return escape(key) + ' <code>' + escape(value) + '</code>' +
|
|
106
|
+
(label === undefined ? '' : ' · ' + escape(label)) + (label === themeLabel ? '' : ' / dark ' + escape(themeLabel)) +
|
|
107
|
+
(isDefault(value) ? defaultLabel : '');
|
|
108
|
+
}).join('<br>');
|
|
109
|
+
const equal = (left, right) => Object.keys(left).length === Object.keys(right).length &&
|
|
110
|
+
Object.entries(left).every(([key, value]) => right[key] === value);
|
|
111
|
+
const deltas = (base, variant, phase) => {
|
|
112
|
+
const inherited = patternParameters(base, phase);
|
|
113
|
+
return Object.fromEntries(Object.entries(patternParameters(variant, phase)).filter(([key, value]) => inherited[key] !== value));
|
|
114
|
+
};
|
|
115
|
+
const variantRow = (base, id) => {
|
|
116
|
+
const variant = catalog.patterns.get(id);
|
|
117
|
+
const enter = deltas(base, variant, 'enter'), exit = deltas(base, variant, 'exit');
|
|
118
|
+
const overrides = equal(enter, exit)
|
|
119
|
+
? (Object.keys(enter).length ? pair('Overrides', describe(enter)) : '')
|
|
120
|
+
: (Object.keys(enter).length ? pair('Enter', describe(enter)) : '') +
|
|
121
|
+
(Object.keys(exit).length ? pair('Exit', describe(exit)) : '');
|
|
122
|
+
return '<div data-motion-variant="' + escape(id) + '"><h4>' + title(id) + '</h4>' +
|
|
123
|
+
(overrides ? '<dl>' + overrides + '</dl>' : '<p>Inherits base parameters</p>') +
|
|
124
|
+
'<div>' + usage(id, uses(id)) + '</div></div>';
|
|
125
|
+
};
|
|
126
|
+
const render = (id, pattern) => {
|
|
127
|
+
const directions = ['enter','exit'];
|
|
128
|
+
const themeValues = (theme, direction) => {
|
|
129
|
+
const params = patternParameters(pattern, direction);
|
|
130
|
+
const value = key => tokenValue(catalog.tokens, theme, params[key]);
|
|
131
|
+
const spring = catalog.springs[theme][params.spring];
|
|
132
|
+
return {
|
|
133
|
+
duration: spring?.duration ?? milliseconds(value('duration')), easing: spring?.easing ?? value('easing'),
|
|
134
|
+
distance: value('distance'), scale: Number(value('scale') ?? .85), stagger: milliseconds(value('stagger')) || 0,
|
|
135
|
+
opacity: params.fromOpacity ?? 0,
|
|
136
|
+
};
|
|
137
|
+
};
|
|
138
|
+
const preview = Object.fromEntries(['light','dark'].map(theme =>
|
|
139
|
+
[theme, Object.fromEntries(directions.map(direction => [direction, themeValues(theme, direction)]))]));
|
|
140
|
+
const primary = pattern.action === 'exit' ? 'exit' : 'enter';
|
|
141
|
+
const alternate = primary === 'enter' ? 'exit' : 'enter';
|
|
142
|
+
const main = patternParameters(pattern, primary), other = patternParameters(pattern, alternate);
|
|
143
|
+
const asymmetric = !equal(main, other);
|
|
144
|
+
const variants = catalog.variants.get(id) ?? [];
|
|
145
|
+
const direct = uses(id);
|
|
146
|
+
const total = new Set([id, ...variants].flatMap(uses).map(ref =>
|
|
147
|
+
JSON.stringify([ref.type, ref.source, ref.frame, ref.id, ref.line, ref.match]))).size;
|
|
148
|
+
const adoption = variants.length
|
|
149
|
+
? '<p data-motion-family-count>' + countLabel(total) + '</p>' +
|
|
150
|
+
(direct.length ? '<div>' + usage(id, direct, 'Base · ') + '</div>' : '') +
|
|
151
|
+
'<div data-motion-variants>' + variants.map(child => variantRow(pattern, child)).join('') + '</div>'
|
|
152
|
+
: usage(id, direct);
|
|
153
|
+
const name = title(id);
|
|
154
|
+
const reducedLabel = escape('Reduced motion · ' + pattern.reduced);
|
|
155
|
+
const kind = escape(pattern.kind + ' · ' + pattern.action);
|
|
156
|
+
const stage = compact => '<div data-motion-stage data-effect="' + escape(pattern.effect) + '" data-action="' +
|
|
157
|
+
escape(pattern.action) + '" data-preview="' + json(preview) + '"' +
|
|
158
|
+
(pattern.effect === 'follow' ? ' role="group" tabindex="0" aria-label="Follow specimen. Move the pointer or use the arrow keys."' : '') +
|
|
159
|
+
'>' + (stageShapes[pattern.effect] ?? shape).replaceAll('<span ', '<span aria-hidden="true" ') +
|
|
160
|
+
(compact ? '<span data-motion-reduced>' + reducedLabel + '</span>' : '') + '</div>';
|
|
161
|
+
const timing = theme => {
|
|
162
|
+
const spring = catalog.springs[theme][main.spring];
|
|
163
|
+
const summary = preview[theme][primary].duration + ' ms · ' +
|
|
164
|
+
(spring ? 'bounce ' + spring.bounce : main.easing.slice(2));
|
|
165
|
+
return escape(summary) + ([main.spring, main.duration, main.easing].some(isDefault) ? ' ·' + defaultLabel : '');
|
|
166
|
+
};
|
|
167
|
+
const link = '?' + new URLSearchParams({scope: 'tokens', section: 'motion', pattern: id});
|
|
168
|
+
const detailId = 'motion-detail-' + id;
|
|
169
|
+
const detail = '<section data-motion-detail id="' + detailId + '" aria-labelledby="' + detailId + '-heading">' +
|
|
170
|
+
'<header data-motion-detail-header><div><h3 id="' + detailId + '-heading">' + name + '</h3><p>' + kind + '</p></div>' +
|
|
171
|
+
'<div data-motion-detail-actions><a data-motion-page-link href="' + escape(link) + '">Open detail view</a>' +
|
|
172
|
+
'<button type="button" data-motion-close aria-label="Close ' + name + ' details">Close</button></div></header>' +
|
|
173
|
+
'<div data-motion-detail-main><div data-motion-detail-specimen>' + stage(false) +
|
|
174
|
+
'<div data-motion-detail-actions><button type="button" data-motion-replay>Replay</button>' +
|
|
175
|
+
(pattern.effect === 'avoid' ? '<button type="button" data-motion-avoid aria-pressed="false">Insert sibling</button>' : '') +
|
|
176
|
+
'</div><p data-motion-reduced>' + reducedLabel + '</p></div><dl>' +
|
|
177
|
+
pair('Properties', escape(pattern.properties.join(', '))) +
|
|
178
|
+
pair(asymmetric ? title(primary) : 'Parameters', describe(main)) +
|
|
179
|
+
(asymmetric ? pair(title(alternate), describe(other)) : '') +
|
|
180
|
+
pair('Interrupt', escape(pattern.interrupt)) + pair('Reduced motion', escape(pattern.reduced)) +
|
|
181
|
+
'</dl></div>' + adoption + '</section>';
|
|
182
|
+
return '<article data-motion-pattern="' + escape(id) + '" data-specimen="' + escape(source + '#' + id) + '">' +
|
|
183
|
+
'<header><h3><button type="button" data-motion-toggle aria-expanded="false">' + name + '</button></h3><p>' + kind + '</p></header>' +
|
|
184
|
+
stage(true) + '<div data-motion-summary><span data-motion-timing="light">' + timing('light') +
|
|
185
|
+
'</span><span data-motion-timing="dark">' + timing('dark') + '</span></div>' +
|
|
186
|
+
'<div data-motion-card-foot><span>' + countLabel(total) + '</span>' +
|
|
187
|
+
(variants.length ? '<span data-motion-variant-count>' + variants.length + (variants.length === 1 ? ' variant' : ' variants') + '</span>' : '') +
|
|
188
|
+
'</div><template data-motion-template>' + detail + '</template></article>';
|
|
189
|
+
};
|
|
190
|
+
const grid = cards => '<div data-motion-patterns>' + cards.join('') + '</div>';
|
|
191
|
+
const adopted = [], notAdopted = [];
|
|
192
|
+
for (const [id, pattern] of catalog.patterns) {
|
|
193
|
+
if (pattern.extends) continue;
|
|
194
|
+
const unused = catalog.variants.has(id) && ![id, ...catalog.variants.get(id)].some(key => uses(key).length);
|
|
195
|
+
(unused ? notAdopted : adopted).push(render(id, pattern));
|
|
196
|
+
}
|
|
197
|
+
return {
|
|
198
|
+
adopted: adopted.length ? grid(adopted) : '',
|
|
199
|
+
notAdopted: notAdopted.length ? '<details data-motion-unadopted><summary>Not adopted <span>' +
|
|
200
|
+
notAdopted.length + '</span></summary>' + grid(notAdopted) + '</details>' : '',
|
|
201
|
+
};
|
|
202
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { parseTokens, themeCss } from '../toolkit/tokens.mjs';
|
|
2
|
+
import { motionBoardCss, motionCards } from './motion-board.mjs';
|
|
2
3
|
import { escape } from '../toolkit/html.mjs';
|
|
3
4
|
import { boardCss, boardHeader, sectionMarkup, boardWidth, specimenWidth } from './board.mjs';
|
|
4
5
|
|
|
@@ -110,7 +111,7 @@ function easingCurve(value) {
|
|
|
110
111
|
return `<svg data-adg-easing viewBox="0 0 128 128" role="img" aria-label="${escape(value)}"><path d="M16 16 V112 H112" fill="none" stroke="currentColor" opacity=".18"/><path d="${curve}" fill="none" stroke="currentColor" stroke-width="2.5"/></svg>`;
|
|
111
112
|
}
|
|
112
113
|
|
|
113
|
-
export function tokenBoard(source, css, { projectName = 'Design library' } = {}) {
|
|
114
|
+
export function tokenBoard(source, css, { projectName = 'Design library', patterns, inventory, patternError, prefix = '', patternSource = source } = {}) {
|
|
114
115
|
const tokens = parseTokens(css);
|
|
115
116
|
const darkValues = new Map([...tokens.light, ...tokens.dark]);
|
|
116
117
|
const themes = themeCss(tokens);
|
|
@@ -173,15 +174,18 @@ export function tokenBoard(source, css, { projectName = 'Design library' } = {})
|
|
|
173
174
|
}).join('');
|
|
174
175
|
sections.push(section('Sizing', `<div data-adg-token-groups>${sizeGroups}</div>`));
|
|
175
176
|
}
|
|
176
|
-
|
|
177
|
+
const cards = patterns ? motionCards(patterns, inventory, patternSource, prefix) : {
|
|
178
|
+
adopted: patternError ? `<p role="status">${escape(patternError)}</p>` : '', notAdopted: '',
|
|
179
|
+
};
|
|
180
|
+
if (cards.adopted || cards.notAdopted || categories.has('easing') || categories.has('duration')) {
|
|
177
181
|
const milliseconds = name => parseFloat(light(name)) * (light(name).endsWith('ms') ? 1 : 1000);
|
|
178
182
|
const names = [...tokens.light.keys()].filter(name => categories.get('easing')?.includes(name) || categories.get('duration')?.includes(name));
|
|
179
|
-
sections.push(section('Motion', groups(names, group => {
|
|
183
|
+
sections.push(section('Motion', cards.adopted + groups(names, group => {
|
|
180
184
|
const maximum = Math.max(1, ...group.filter(name => categories.get('duration')?.includes(name)).map(milliseconds));
|
|
181
185
|
return `<div data-adg-motion-grid>${group.map(name => article(name, categories.get('easing')?.includes(name)
|
|
182
186
|
? easingCurve(light(name)) + label(name)
|
|
183
187
|
: `<div data-adg-duration-track><div data-adg-duration style="width:${milliseconds(name) / maximum * 100}%"></div></div>${label(name)}`)).join('')}</div>`;
|
|
184
|
-
})));
|
|
188
|
+
}) + cards.notAdopted));
|
|
185
189
|
}
|
|
186
190
|
const body = `<main data-adg-board>${boardHeader({ title: 'Tokens', projectName, layer: 'Tokens', number: 1, sourceCount: 1, frameCount: tokens.light.size, countLabel: 'tokens' })}${sections.join('')}</main>`;
|
|
187
191
|
// Scope project tokens to the board so a DOM overlay never changes viewer chrome.
|
|
@@ -191,6 +195,6 @@ export function tokenBoard(source, css, { projectName = 'Design library' } = {})
|
|
|
191
195
|
return {
|
|
192
196
|
key: source, source, name: 'Tokens', layer: 'Tokens', kind: 'board',
|
|
193
197
|
width: boardWidth, height: null, sourceCount: 1, frameCount: tokens.light.size,
|
|
194
|
-
body, css: `${scopedTokens}\n${boardCss}\n${tokenStyles}`,
|
|
198
|
+
body, css: `${scopedTokens}\n${boardCss}\n${tokenStyles}\n${motionBoardCss}`,
|
|
195
199
|
};
|
|
196
200
|
}
|
package/src/cli-output.mjs
CHANGED
|
@@ -67,6 +67,7 @@ export const errorCatalog = {
|
|
|
67
67
|
NETWORK_FAILED: [2, 'compare', 'Retry after restoring fixture connectivity.'],
|
|
68
68
|
AUTH_REQUIRED: [2, 'compare', 'Retry after providing fixture access.'],
|
|
69
69
|
IO_FAILED: [2, 'help', 'Repair access to the reported path before retrying.'],
|
|
70
|
+
MOTION_EDGE_NOT_FOUND: [2, 'motion-check', 'List motion edges with adg check --transitions --read-only --json.'],
|
|
70
71
|
INTERNAL_ERROR: [2, 'version', 'Record the runtime version with the diagnostic.'],
|
|
71
72
|
};
|
|
72
73
|
|
|
@@ -84,7 +85,7 @@ export class CliError extends Error {
|
|
|
84
85
|
}
|
|
85
86
|
|
|
86
87
|
const canonicalCommands = new Set([
|
|
87
|
-
'comments', 'open', 'link', 'serve', 'root', 'service', 'migrate', 'init', 'check', 'render', 'compare', 'diff', 'owner', 'impact', 'inspect',
|
|
88
|
+
'comments', 'open', 'link', 'serve', 'root', 'service', 'migrate', 'init', 'check', 'render', 'compare', 'diff', 'owner', 'impact', 'inspect', 'motion',
|
|
88
89
|
'comments list', 'comments read', 'comments reply', 'comments resolve',
|
|
89
90
|
'root add', 'root remove', 'root list', 'root scan',
|
|
90
91
|
'service install', 'service uninstall', 'service status', 'service logs', 'service migrate',
|
|
@@ -117,6 +118,7 @@ export function nextActions(code, context = {}) {
|
|
|
117
118
|
const state = context.stateDirectory ? ['--state-dir', context.stateDirectory] : [];
|
|
118
119
|
let argv;
|
|
119
120
|
switch (recovery) {
|
|
121
|
+
case 'motion-check': argv = ['adg','check','--transitions','--read-only','--json']; break;
|
|
120
122
|
case 'check': argv = ['adg', 'check', '--read-only', '--json', ...(context.positionals?.length && context.command === 'check' ? ['--', ...context.positionals] : [])]; break;
|
|
121
123
|
case 'install': argv = ['npm', 'install', '-g', '@whzxc/agent-design-gallery']; break;
|
|
122
124
|
case 'migrate': argv = context.project ? ['adg', 'migrate', context.project, '--json'] : helpArgv('migrate'); break;
|
package/src/cli.mjs
CHANGED
|
@@ -6,7 +6,7 @@ import { realpathSync } from 'node:fs';
|
|
|
6
6
|
import { VERSION, loadConfig } from './toolkit/config.mjs';
|
|
7
7
|
import { CliError, createOutput, withHumanOutput } from './cli-output.mjs';
|
|
8
8
|
|
|
9
|
-
export const commands = ['comments', 'open', 'link', 'serve', 'root', 'service', 'migrate', 'init', 'check', 'render', 'compare', 'diff', 'review', 'owner', 'impact', 'inspect'];
|
|
9
|
+
export const commands = ['comments', 'open', 'link', 'serve', 'root', 'service', 'migrate', 'init', 'check', 'render', 'compare', 'diff', 'review', 'owner', 'impact', 'inspect', 'motion'];
|
|
10
10
|
const targetOptions = '[--asset=<path> [--frame=<name>] | --group=<name> | --layer=<name> | --tokens] [--mode=query|path] [--base=<rev>]';
|
|
11
11
|
const usage = {
|
|
12
12
|
comments: '[[list] [--status=open|resolved|all] [--source=<path>] [--frame=<name>] | read <n> | reply <n> --author=<name> --message=<text> | resolve <n> --author=<name> [--message=<text>]] [--state-dir=<path>] [--json]',
|
|
@@ -15,15 +15,17 @@ const usage = {
|
|
|
15
15
|
serve: '[--port=4310] [--state-dir=<path>] [--print-key | --rotate-key]',
|
|
16
16
|
service: 'install|uninstall|status|logs|migrate [--state-dir=<path>] [--port=4310] [--public-origin=<origin>]',
|
|
17
17
|
root: 'add <dir> [--depth=2] | remove <dir> | list | scan [dir] [--state-dir=<path>]',
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
motion: '[--css | --json]',
|
|
19
|
+
migrate: '[project]', init: '', check: '[source...] [--transitions] [--read-only] [--motion-only] [--motion-details] [--impacted --base=<rev> [--frame=<name>] [--theme=both|light|dark] [--state-dir=<path>] [--explain]]', render: '[source...] [--frame=<name>] [--theme=both|light|dark|system] [--scale=2] [--out-dir=<path>] [--json] [--base=<rev>] [--impacted [--state-dir=<path>] [--explain]]',
|
|
20
|
+
compare: '<source> --frame=<name> [--fixture=<name>] [--region=<name> | --selector=<css> | --page] [--origin="<x> <y>"] [--click=<name>...] [--viewport=<w>x<h>] [--no-screenshots] | --all',
|
|
20
21
|
diff: '[source...] --base=<rev> [--frame=<name>] [--theme=both|light|dark|system] [--scale=2] [--out-dir=<path>] [--json] [--impacted [--state-dir=<path>] [--explain]]',
|
|
21
|
-
review: '--base=<rev> [--theme=system|light|dark] [--out=<file
|
|
22
|
-
owner: '(--file=<path|directory|glob> [--line=<n>] [--symbol=<name>] | --text=<text> [--contains] [--locale=<tag>] | --color=<css> | --token=<name> | --part=<source>[#<Export>]) [--theme=both|light|dark] [--state-dir=<path>] [--json]',
|
|
23
|
-
inspect: '[source] [--frame=<name>] [--theme=both|light|dark] [--part=<source>#<Export> | --element=<id> | --text=<text> [--contains]] [--depth=<n|all>] [--fields=<groups>] [--wrappers=semantic|all] [--expand] [--state-dir=<path>] [--json]',
|
|
24
|
-
impact: '(--source=<path>... [--part=<name>] | --token=<name>... | --file=<path|directory|glob> [--line=<n>] [--symbol=<name>] | --base=<rev> [--head=<rev>]) [--theme=both|light|dark] [--explain] [--state-dir=<path>] [--json]',
|
|
22
|
+
review: '--base=<rev> [--format=html|png|embed] [--theme=system|light|dark] [--out=<file>] [--viewer-url=<project-url>] [--exact] [--json]',
|
|
23
|
+
owner: '[--transitions] (--transition=<id> | --file=<path|directory|glob> [--line=<n>] [--symbol=<name>] | --text=<text> [--contains] [--locale=<tag>] | --color=<css> | --token=<name> | --part=<source>[#<Export>]) [--theme=both|light|dark] [--state-dir=<path>] [--json]',
|
|
24
|
+
inspect: '[--transition=<id> [--explain] | <source> --frame=<name> --transitions] [source] [--frame=<name>] [--theme=both|light|dark] [--part=<source>#<Export> | --element=<id> | --text=<text> [--contains]] [--depth=<n|all>] [--fields=<groups>] [--wrappers=semantic|all] [--expand] [--state-dir=<path>] [--json]',
|
|
25
|
+
impact: '[--transitions] (--source=<path>... [--part=<name>] | --token=<name>... | --file=<path|directory|glob> [--line=<n>] [--symbol=<name>] | --base=<rev> [--head=<rev>]) [--theme=both|light|dark] [--explain] [--state-dir=<path>] [--json]',
|
|
25
26
|
};
|
|
26
27
|
const details = {
|
|
28
|
+
motion: 'Export project motion tokens and raw spring parameters. --css emits a token stylesheet with generated linear() springs.',
|
|
27
29
|
comments: 'List open project comment threads by default, or read, reply to or resolve a thread by number, #number or ID. Run from the project directory.',
|
|
28
30
|
migrate: 'Rename a project configuration and runtime imports, update editor paths and ignore entries, remove old generated files and regenerate declarations. Refuses mixed config names; safe to run again.',
|
|
29
31
|
serve: 'Run the resident multi-project hub on 127.0.0.1. Projects build on viewer access and idle viewers stop after five minutes. --print-key prints the key and exits; --rotate-key rotates the running hub key and exits. Forwarded data requests require a header or query key; direct-local requests are exempt.',
|
|
@@ -33,8 +35,8 @@ const details = {
|
|
|
33
35
|
link: 'Print a clean ADG preview URL. --comment=<n> opens a comment thread. --base=<rev> enables Git overlays for architecture diagrams. Query mode isolates a target. Path mode locates it in the design hierarchy.',
|
|
34
36
|
check: 'Check import direction and every selected frame in both themes. --read-only skips generated types and build files. --impacted --base=<rev> evaluates scheduled current rows; proven rows remain not_checked with partial coverage.', render: 'Render selected frames as PNG. Defaults to both themes at 2×. --theme=system resolves the current macOS appearance, otherwise light, and reports the resolved themes. --impacted --base=<rev> captures scheduled plain current frames and reports deletions, with operation-local proofs for skipped rows. Ordinary architecture --base produces proposal overlays; --impacted never does. --json prints completed captures and impact coverage, including zero-job runs.',
|
|
35
37
|
compare: 'Compare fixture text positions. Flags override Frame fixture and capture. --all writes a summary for every fixture frame.',
|
|
36
|
-
diff: 'Compare the Git base and working-tree source/frame union. Existing frames require exact pixels and CSS/device size; added Frame parent declarations enable structural part evidence under diff.thresholds. Defaults to both themes at 2× and <configured output>/diff, overwriting previous diff artifacts and writing a self-contained index.html review page, before/after/difference PNGs and report.json. --impacted also writes review-sheet.png with
|
|
37
|
-
review: 'Generate one
|
|
38
|
+
diff: 'Compare the Git base and working-tree source/frame union. Existing frames require exact pixels and CSS/device size; added Frame parent declarations enable structural part evidence under diff.thresholds. Defaults to both themes at 2× and <configured output>/diff, overwriting previous diff artifacts and writing a self-contained index.html review page, before/after/difference PNGs and report.json. --impacted also writes review-sheet.png with up to 12 image cards at 2× plus lists of removed and moved frames. The sheet uses the explicit single theme or system appearance. --theme=system resolves the current macOS appearance, otherwise light. --impacted captures only scheduled rows (both themes when either theme of a frame is impacted); unqualified both-theme runs count fresh proofs toward full coverage. Required parents/support always capture. A structural batch requires all existing frames in both themes; source/frame/theme restrictions report partial coverage. Exit 0 identical/structural, 1 changed, 2 incomplete.',
|
|
39
|
+
review: 'Generate one review of the Git base and working tree. Defaults to interactive HTML, the system theme and <configured output>/review.html. Use --format=embed for a compact inline review widget at <configured output>/review-embed.html, or --format=png for a static summary at <configured output>/review.png. --out must match the selected format. Uses structural prefiltering with pixel comparison for the remaining frames. --exact uses pixel comparison for every frame scheduled by impact analysis. A registered hub supplies HTML frame links, or set --viewer-url. Exit 0 when written, including changes, or 2 for incomplete generation.',
|
|
38
40
|
owner: 'Find owning design sources, parts, frames and tokens from an implementation path, rendered text, absolute CSS color or token name. Paths resolve from the project root; quote globs. --part reverses the lookup from a design source or source#Export to implementation bindings with resolved files and symbol regions. --line returns the containing export/anchor region, including unmapped exports; non-exported helpers belong to the preceding export. Text is NFC/whitespace normalized and exact unless --contains; --locale filters exact Frame locale tags without translation. Colors use 8-bit sRGB RGBA equality. Owner evidence is scoped to the query: mappings for files, text runs for text, computed paint for colors and authored references for tokens. Text authoredIn lists literal-search copy candidates; escaped or concatenated strings may be missed. Color evidence may include compact same-element/property references. Defaults to both themes. Broad color/token JSON can be around 100 KB; read owners first and narrow with --theme. Empty, stale and ambiguous results exit 0; invalid/incomplete requests exit 2.',
|
|
39
41
|
inspect: 'Read TSX frame structure, text, CSS-pixel boxes, computed styles and token-reference evidence. Without a unique frame, return a catalog. Default: both themes, all fields, full depth. Field groups: structure,layout,typography,color,text. Shared styles, semantic wrappers, repeated subtrees and a sparse dark delta keep the default compact. --expand reconstructs ordinary element records for both themes. No consumer application or viewer is started. Exit 0 completed observation, 2 invalid/incomplete.',
|
|
40
42
|
impact: 'Query direct/transitive candidates from sources, named parts, tokens or implementation mappings, or compare exact Git endpoints. --base includes staged, unstaged and untracked working files; --head selects another exact commit. Hypothetical selectors cannot prove skips; token candidates assume unchanged Tailwind classification. Git mode freshly executes both endpoint source sets and compares eligible materialized inputs. Closure or occurrence absence never proves safety. Groups merge equal theme and same-source frame records; noncandidate proofs remain counts. --explain samples witnesses/digests without splitting groups. No browser launch. Render/check/diff --impacted compute their own operation-local proofs. Exit 0 completed, including empty/stale mappings; 2 invalid/incomplete.',
|
|
@@ -44,7 +46,7 @@ const helpExamples = {
|
|
|
44
46
|
render: 'adg render --impacted --base=HEAD --json\nadg render arch/catalog.mmd --base=HEAD --json',
|
|
45
47
|
check: 'adg check --impacted --base=HEAD --read-only --json\nadg check --read-only --json',
|
|
46
48
|
diff: 'adg diff --base=HEAD --impacted --json',
|
|
47
|
-
review: 'adg review --base=HEAD --json',
|
|
49
|
+
review: 'adg review --base=HEAD --json\nadg review --base=HEAD --format=embed --json\nadg review --base=HEAD --format=png --json',
|
|
48
50
|
};
|
|
49
51
|
export function help(command) {
|
|
50
52
|
if (command) return `Usage: adg ${command} ${usage[command]}\n\n${details[command]}${helpExamples[command] ? `\n\nExamples:\n${helpExamples[command]}` : ''}\n\n-h, --help Show help\nExit codes: 0 success, 1 check/compare/diff problems, 2 usage/configuration/environment error.`;
|
|
@@ -56,18 +58,22 @@ export function parseCli(args) {
|
|
|
56
58
|
const explicit = commands.includes(args[0]), command = explicit ? args[0] : 'open';
|
|
57
59
|
const options = { help: { type: 'boolean', short: 'h' }, version: { type: 'boolean', short: 'v' }, json: { type: 'boolean' } };
|
|
58
60
|
const locators = ['asset', 'frame', 'group', 'layer', 'mode', 'base'];
|
|
59
|
-
const strings = { comments: ['status', 'source', 'frame', 'author', 'message', 'state-dir'], open: ['port', 'state-dir', ...locators], link: [...locators, 'comment'], serve: ['port', 'state-dir'], root: ['depth', 'state-dir'], service: ['port', 'state-dir', 'public-origin'], check: ['base', 'frame', 'theme', 'state-dir'], render: ['scale', 'frame', 'theme', 'out-dir', 'base', 'state-dir'], diff: ['base', 'frame', 'theme', 'scale', 'out-dir', 'state-dir'], compare: ['frame', 'fixture', 'region', 'selector', 'viewport', 'origin'], owner: ['file', 'text', 'color', 'token', 'part', 'line', 'symbol', 'locale', 'theme', 'state-dir'], impact: ['source', 'part', 'token', 'file', 'line', 'symbol', 'base', 'head', 'theme', 'state-dir'], inspect: ['frame','theme','part','element','text','depth','fields','wrappers','state-dir'] };
|
|
61
|
+
const strings = { comments: ['status', 'source', 'frame', 'author', 'message', 'state-dir'], open: ['port', 'state-dir', ...locators], link: [...locators, 'comment'], serve: ['port', 'state-dir'], root: ['depth', 'state-dir'], service: ['port', 'state-dir', 'public-origin'], check: ['base', 'frame', 'theme', 'state-dir'], render: ['scale', 'frame', 'theme', 'out-dir', 'base', 'state-dir'], diff: ['base', 'frame', 'theme', 'scale', 'out-dir', 'state-dir'], compare: ['frame', 'fixture', 'region', 'selector', 'viewport', 'origin'], owner: ['transition','file', 'text', 'color', 'token', 'part', 'line', 'symbol', 'locale', 'theme', 'state-dir'], impact: ['source', 'part', 'token', 'file', 'line', 'symbol', 'base', 'head', 'theme', 'state-dir'], inspect: ['transition','frame','theme','part','element','text','depth','fields','wrappers','state-dir'] };
|
|
60
62
|
for (const name of strings[command] ?? []) options[name] = { type: 'string' };
|
|
61
63
|
if (command === 'review') {
|
|
62
|
-
for (const name of ['base', 'theme', 'out', 'viewer-url']) options[name] = { type: 'string' };
|
|
64
|
+
for (const name of ['base', 'format', 'theme', 'out', 'viewer-url']) options[name] = { type: 'string' };
|
|
63
65
|
options.exact = { type: 'boolean' };
|
|
64
66
|
}
|
|
65
67
|
if (command === 'serve') for (const name of ['print-key', 'rotate-key']) options[name] = { type: 'boolean' };
|
|
66
68
|
if (command === 'open') options['no-open'] = { type: 'boolean' };
|
|
67
69
|
if (command === 'open' || command === 'link') options.tokens = { type: 'boolean' };
|
|
68
|
-
if (command === 'check')
|
|
70
|
+
if (command === 'check') for (const name of ['read-only','motion-only','motion-details']) options[name] = { type: 'boolean' };
|
|
71
|
+
if (command === 'compare') options['no-screenshots'] = { type: 'boolean' };
|
|
72
|
+
if (command === 'motion') options.css = { type: 'boolean' };
|
|
69
73
|
if (['render', 'check', 'diff'].includes(command)) { options.impacted = { type: 'boolean' }; options.explain = { type: 'boolean' }; }
|
|
70
74
|
if (command === 'owner' || command === 'inspect') options.contains = { type: 'boolean' };
|
|
75
|
+
if (['inspect','owner','impact','check'].includes(command)) options.transitions = {type:'boolean'};
|
|
76
|
+
if (command === 'inspect') options.explain = {type:'boolean'};
|
|
71
77
|
if (command === 'inspect') options.expand = { type: 'boolean' };
|
|
72
78
|
if (command === 'impact') {
|
|
73
79
|
options.explain = { type: 'boolean' };
|
|
@@ -81,10 +87,19 @@ export function parseCli(args) {
|
|
|
81
87
|
const { values, positionals } = parsed;
|
|
82
88
|
if (globalJson) values.json = true;
|
|
83
89
|
if (!values.help && !values.version) {
|
|
84
|
-
if (command === '
|
|
85
|
-
|
|
86
|
-
(values
|
|
87
|
-
throw new CliError('USAGE_INVALID', '
|
|
90
|
+
if (command === 'motion' && (positionals.length || values.css && values.json)) throw new CliError('USAGE_INVALID', 'Choose --css or --json.');
|
|
91
|
+
if (command === 'check' && ((values['motion-only'] && (positionals.length || values.impacted || values.transitions)) ||
|
|
92
|
+
(values['motion-details'] && (positionals.length || values.impacted))))
|
|
93
|
+
throw new CliError('USAGE_INVALID', 'Motion inventory flags apply to a whole-project check.');
|
|
94
|
+
if (command === 'review') {
|
|
95
|
+
const format = values.format ?? 'html';
|
|
96
|
+
const extension = format === 'png' ? '.png' : '.html';
|
|
97
|
+
if (positionals.length || !values.base?.trim() ||
|
|
98
|
+
!['html', 'png', 'embed'].includes(format) ||
|
|
99
|
+
(values.theme !== undefined && !['system', 'light', 'dark'].includes(values.theme)) ||
|
|
100
|
+
(values.out !== undefined && !values.out.toLowerCase().endsWith(extension)) || values['viewer-url'] === '') {
|
|
101
|
+
throw new CliError('USAGE_INVALID', 'Set --base=<rev>, choose one theme and format, and match --out to the format; run adg review --help.');
|
|
102
|
+
}
|
|
88
103
|
}
|
|
89
104
|
if (['render', 'check', 'diff'].includes(command)) {
|
|
90
105
|
if (!values.impacted && (values.explain !== undefined || values['state-dir'] !== undefined)) throw new CliError('USAGE_INVALID', '--explain and --state-dir require --impacted --base=<rev>.');
|
|
@@ -96,6 +111,9 @@ export function parseCli(args) {
|
|
|
96
111
|
for(const token of parsed.tokens)if(token.kind==='option'&&!['json','help','version'].includes(token.name)){
|
|
97
112
|
if(seen.has(token.name))throw new CliError('USAGE_INVALID',`Do not repeat --${token.name}; run adg inspect --help.`);seen.add(token.name);
|
|
98
113
|
}
|
|
114
|
+
if ((values.transition!==undefined && (positionals.length || Object.keys(values).some(k=>!['transition','json','theme','explain','state-dir'].includes(k)))) ||
|
|
115
|
+
(values.explain && !values.transition) || (values.transitions && (!values.frame || positionals.length!==1 || Object.keys(values).some(k=>!['frame','transitions','state-dir','json'].includes(k)))))
|
|
116
|
+
throw new CliError('USAGE_INVALID','Choose --transition=<id> or <source> --frame=<name> --transitions.');
|
|
99
117
|
if(positionals.length>1 || strings.inspect.some(k=>values[k]!==undefined&&!values[k].trim()) ||
|
|
100
118
|
['part','element','text'].filter(k=>values[k]!==undefined).length>1 || values.contains!==undefined&&values.text===undefined ||
|
|
101
119
|
values.theme!==undefined&&!['both','light','dark'].includes(values.theme) ||
|
|
@@ -117,12 +135,13 @@ export function parseCli(args) {
|
|
|
117
135
|
values.line !== undefined && (!/^[1-9]\d*$/.test(values.line) || !Number.isSafeInteger(Number(values.line)))) throw new CliError('USAGE_INVALID', 'Choose one nonempty impact selector family and compatible options; run adg impact --help.');
|
|
118
136
|
}
|
|
119
137
|
if (command === 'owner') {
|
|
120
|
-
const kinds = ['file', 'text', 'color', 'token', 'part'].filter(key => values[key] !== undefined);
|
|
138
|
+
const kinds = ['file', 'text', 'color', 'token', 'part','transition'].filter(key => values[key] !== undefined);
|
|
121
139
|
const seen = new Set();
|
|
122
140
|
for (const token of parsed.tokens) if (token.kind === 'option' && !['json', 'help', 'version'].includes(token.name)) {
|
|
123
141
|
if (seen.has(token.name)) throw new CliError('USAGE_INVALID', `Do not repeat --${token.name}; run adg owner --help.`);
|
|
124
142
|
seen.add(token.name);
|
|
125
143
|
}
|
|
144
|
+
if (values.transitions && !['token','file'].includes(kinds[0])) throw new CliError('USAGE_INVALID','Use --transitions with --file or --token.');
|
|
126
145
|
if (positionals.length || kinds.length !== 1 || strings.owner.some(key => values[key] !== undefined && !values[key].trim()) ||
|
|
127
146
|
values.theme !== undefined && !['both', 'light', 'dark'].includes(values.theme) ||
|
|
128
147
|
(values.line !== undefined || values.symbol !== undefined) && kinds[0] !== 'file' ||
|
|
@@ -224,6 +243,21 @@ async function dispatch({ command, values, positionals }, cwd, output, serviceOp
|
|
|
224
243
|
if (!values.json) output.log(JSON.stringify(data, null, 2));
|
|
225
244
|
return { data };
|
|
226
245
|
}
|
|
246
|
+
if (command === 'motion') {
|
|
247
|
+
const { loadMotionPatterns, patternParameters } = await import('./toolkit/motion-patterns.mjs');
|
|
248
|
+
const { motionTokenCss } = await import('./toolkit/motion-primitives.mjs');
|
|
249
|
+
const { tokens, springs, patterns } = loadMotionPatterns(config);
|
|
250
|
+
if (values.css) {
|
|
251
|
+
output.log(motionTokenCss(tokens).trimEnd());
|
|
252
|
+
return { data: null };
|
|
253
|
+
}
|
|
254
|
+
const used = new Set([...patterns.values()].flatMap(pattern => ['enter', 'exit'].flatMap(direction => Object.values(patternParameters(pattern, direction)))));
|
|
255
|
+
const names = Object.fromEntries([...tokens.light].filter(([name]) => used.has(name) || /^--(?:adg-motion|motion)-/.test(name)).map(([name, value]) =>
|
|
256
|
+
[name, { light: value, ...(tokens.dark.has(name) ? { dark: tokens.dark.get(name) } : {}) }]));
|
|
257
|
+
const data = { tokens: names, springs };
|
|
258
|
+
if (!values.json) output.log(JSON.stringify(data, null, 2));
|
|
259
|
+
return { data };
|
|
260
|
+
}
|
|
227
261
|
if (command === 'inspect') return (await import('./toolkit/inspect.mjs')).inspect(config, positionals, { ...values, ...(values['state-dir'] !== undefined ? { 'state-dir': path.resolve(cwd, values['state-dir']) } : {}) }, { log: output.log });
|
|
228
262
|
if (command === 'impact') return (await import('./toolkit/impact.mjs')).impact(config, { ...values, ...(values['state-dir'] !== undefined ? { 'state-dir': path.resolve(cwd, values['state-dir']) } : {}) }, { log: output.log });
|
|
229
263
|
if (command === 'owner') return (await import('./toolkit/owner.mjs')).owner(config, { ...values, ...(values['state-dir'] !== undefined ? { 'state-dir': path.resolve(cwd, values['state-dir']) } : {}) }, { log: output.log });
|
package/src/http.mjs
CHANGED
|
@@ -12,9 +12,12 @@ export const viewerFiles = {
|
|
|
12
12
|
'/boards.js': 'boards.js', '/assets.js': 'assets.js', '/frame-identity.js': 'frame-identity.js', '/icons.js': 'icons.js', '/layout.js': 'layout.js',
|
|
13
13
|
'/arrangement.js': 'arrangement.js', '/arrangement-worker.js': 'arrangement-worker.js',
|
|
14
14
|
'/relationships.js': 'relationships.js', '/selection.js': 'selection.js', '/style.css': 'style.css', '/tokens.css': 'tokens.css',
|
|
15
|
-
'/token-catalog.js': 'token-catalog.js',
|
|
15
|
+
'/token-catalog.js': 'token-catalog.js', '/motion-specimens.js': 'motion-specimens.js',
|
|
16
16
|
'/comments.js': 'comments.js', '/comments.css': 'comments.css', '/comment-anchors.js': 'comment-anchors.js', '/context-menu.js': 'context-menu.js',
|
|
17
|
-
'/
|
|
17
|
+
'/player.js': 'player.js', '/player.css': 'player.css', '/motion-identity.js': 'motion-identity.js',
|
|
18
|
+
'/motion-flow.js': 'motion-flow.js', '/motion-scene.js': 'motion-scene.js', '/motion-paint.js': 'motion-paint.js',
|
|
19
|
+
'/view-boards.js': 'view-boards.js', '/view-boards.css': 'view-boards.css',
|
|
20
|
+
'/recent-updates.js': 'recent-updates.js', '/view-route.js': 'view-route.js',
|
|
18
21
|
};
|
|
19
22
|
export const viewerFile = pathname => isViewPath(pathname) ? 'index.html' : viewerFiles[pathname];
|
|
20
23
|
const designFiles = { 'tokens.css': 'tokens.css', 'favicon.svg': 'art/adg-mark.svg' };
|