@whzxc/agent-design-gallery 0.14.1 → 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 +29 -16
- package/package.json +2 -1
- package/public/access.css +15 -2
- package/public/app.js +1284 -521
- package/public/arrangement-worker.js +7 -7
- package/public/arrangement.js +35 -30
- package/public/assets.js +85 -48
- package/public/auth.js +59 -4
- package/public/boards.js +129 -0
- package/public/comment-anchors.js +50 -0
- package/public/comments.css +400 -0
- package/public/comments.js +1106 -0
- package/public/context-menu.js +97 -0
- package/public/frame-identity.js +51 -14
- package/public/hub.css +25 -3
- package/public/hub.html +10 -2
- package/public/hub.js +127 -23
- package/public/icons.js +9 -0
- package/public/index.html +26 -10
- package/public/instance-actions.js +9 -2
- package/public/layout.js +156 -86
- 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/selection.js +1 -1
- package/public/style.css +91 -154
- package/public/switcher.css +5 -4
- package/public/switcher.js +109 -34
- package/public/token-catalog.js +8 -3
- package/public/tokens.css +20 -1
- package/public/view-boards.css +131 -0
- package/public/view-boards.js +350 -0
- package/public/view-route.js +1 -2
- package/src/boards/board.mjs +30 -0
- package/src/boards/motion-board.mjs +202 -0
- package/src/boards/token-board.mjs +200 -0
- package/src/cli-output.mjs +10 -5
- package/src/cli.mjs +89 -35
- package/src/comments.mjs +293 -0
- package/src/http.mjs +7 -5
- package/src/hub/project-link.mjs +41 -0
- package/src/hub/registry.mjs +5 -0
- package/src/hub.mjs +14 -10
- package/src/link.mjs +13 -1
- 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 +285 -110
- package/src/service.mjs +46 -12
- package/src/toolkit/arch-git.mjs +8 -14
- package/src/toolkit/arch.mjs +3 -2
- package/src/toolkit/asset-rules.mjs +24 -1
- 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 +105 -9
- package/src/toolkit/compare.mjs +13 -11
- package/src/toolkit/config.mjs +2 -2
- package/{public/review.js → src/toolkit/diff-document.mjs} +137 -43
- package/src/toolkit/diff-inputs.mjs +97 -52
- package/src/toolkit/diff.mjs +198 -43
- 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 +27 -12
- package/src/toolkit/impact.mjs +49 -15
- 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/move-pairing.mjs +140 -0
- package/src/toolkit/owner.mjs +19 -6
- package/src/toolkit/play-endpoint.mjs +66 -0
- package/src/toolkit/project-index.mjs +4 -4
- package/src/toolkit/recent-structure.mjs +201 -0
- package/src/toolkit/results.mjs +3 -3
- package/src/toolkit/review-document.mjs +440 -0
- package/src/toolkit/review-embed-document.mjs +671 -0
- package/src/toolkit/review-filmstrip.mjs +76 -0
- package/src/toolkit/review-groups.mjs +29 -0
- package/src/toolkit/review-motion-card.mjs +51 -0
- package/src/toolkit/review-motion.mjs +159 -0
- package/src/toolkit/review-observation.mjs +131 -0
- package/src/toolkit/review-playback.js +123 -0
- package/src/toolkit/review-sheet.mjs +125 -0
- package/src/toolkit/review-specimens.mjs +60 -0
- package/src/toolkit/review.mjs +240 -0
- package/src/toolkit/runtime.mjs +8 -2
- package/src/toolkit/theme.mjs +16 -0
- package/src/viewer-cache.mjs +48 -12
- package/public/annotations.js +0 -816
- package/public/labels.js +0 -122
- package/src/annotations.mjs +0 -238
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { labelResolver } from './motion-label.mjs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { CliError } from '../cli-output.mjs';
|
|
4
|
+
import { listSources, relative, selectSources, sourceDirectories, loadTokens } from './project.mjs';
|
|
5
|
+
import { loadImplementationMap, validateImplementationMap } from './implementation-map.mjs';
|
|
6
|
+
import { readMotion, motionRows, motionSummary, resolveMotionToken, timingRefs } from './motion.mjs';
|
|
7
|
+
import { motionEvaluator } from './motion-check.mjs';
|
|
8
|
+
import { buildSource } from './build.mjs';
|
|
9
|
+
import { launch } from './browser.mjs';
|
|
10
|
+
|
|
11
|
+
async function labeled(config,records) {
|
|
12
|
+
const label = labelResolver(config);
|
|
13
|
+
return Promise.all(records.map(async r=>({id:r.edge.id,label:await label(r)})));
|
|
14
|
+
}
|
|
15
|
+
export function targetsFor(edge, side) {
|
|
16
|
+
return [
|
|
17
|
+
...(side === 'from' ? [edge.trigger.target] : edge.focus.target ? [edge.focus.target] : []),
|
|
18
|
+
...edge.phases
|
|
19
|
+
.flat()
|
|
20
|
+
.filter((track) => side === 'from' || track.mode !== 'exit')
|
|
21
|
+
.flatMap((t) => t.targets)
|
|
22
|
+
];
|
|
23
|
+
}
|
|
24
|
+
export function usesTiming(edge, tokens, names, themes) {
|
|
25
|
+
return timingRefs(edge).some((ref) =>
|
|
26
|
+
themes.some((theme) => resolveMotionToken(tokens, theme, ref.name, ref.kind).names.some((name) => names.includes(name)))
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
export async function tokenEdges(config, values, data) {
|
|
30
|
+
const graph = readMotion(config);
|
|
31
|
+
if (!graph.records.length) {
|
|
32
|
+
motionSummary(data, [], values.transitions);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const tokens = loadTokens(config),
|
|
36
|
+
themes = values.theme && values.theme !== 'both' ? [values.theme] : ['light', 'dark'];
|
|
37
|
+
const records = motionRows(graph.records.filter((r) => r.valid && usesTiming(r.edge, tokens, [values.token], themes)));
|
|
38
|
+
motionSummary(
|
|
39
|
+
data,
|
|
40
|
+
values.transitions ? await labeled(config,records) : records.map(r=>r.edge.id),
|
|
41
|
+
values.transitions
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
export async function boundEdges(config, bindings, data, expanded = false) {
|
|
45
|
+
const active = (bindings ?? []).filter((b) => b.active);
|
|
46
|
+
let ids = active.map((b) => b.design.transition);
|
|
47
|
+
if (data.query.kind === 'part') {
|
|
48
|
+
const { source, part } = data.query;
|
|
49
|
+
if (!part) ids = active.filter((b) => b.design.source === source).map((b) => b.design.transition);
|
|
50
|
+
else if (ids.length) {
|
|
51
|
+
const allowed = new Set(ids);
|
|
52
|
+
ids = readMotion(config)
|
|
53
|
+
.records.filter(
|
|
54
|
+
(r) =>
|
|
55
|
+
r.valid &&
|
|
56
|
+
allowed.has(r.edge.id) &&
|
|
57
|
+
['from', 'to'].some((side) => targetsFor(r.edge, side).some((t) => t.part === source + '#' + part))
|
|
58
|
+
)
|
|
59
|
+
.map((r) => r.edge.id);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
const unique = [...new Set(ids)].sort();
|
|
63
|
+
motionSummary(data, expanded && unique.length ? await labeled(config,motionRows(readMotion(config).records.filter(r=>unique.includes(r.edge?.id)))) : unique, expanded);
|
|
64
|
+
}
|
|
65
|
+
async function behaviorMap(config, owner) {
|
|
66
|
+
const map = await loadImplementationMap(config);
|
|
67
|
+
const validated = await validateImplementationMap(config, map, {
|
|
68
|
+
targetFilter: (target) => target.transition && target.source === owner,
|
|
69
|
+
sources: listSources(config.design, sourceDirectories(config)).map((f) => relative(config, f))
|
|
70
|
+
});
|
|
71
|
+
return { map, ...validated };
|
|
72
|
+
}
|
|
73
|
+
export async function transitionQuery(config, command, args, values, log) {
|
|
74
|
+
const graph = readMotion(config);
|
|
75
|
+
const data = {
|
|
76
|
+
project: config.root,
|
|
77
|
+
complete: true,
|
|
78
|
+
motionVersion: 1,
|
|
79
|
+
mode: values.transitions ? 'transitions' : 'transition'
|
|
80
|
+
};
|
|
81
|
+
const label = labelResolver(config);
|
|
82
|
+
if (values.transitions) {
|
|
83
|
+
const [file] = selectSources(config, args, { write: false }),
|
|
84
|
+
source = relative(config, file);
|
|
85
|
+
const built = await buildSource(config, file, { write: false });
|
|
86
|
+
if (!built.frames.some((f) => f.name === values.frame))
|
|
87
|
+
throw new CliError('FRAME_NOT_FOUND', 'Unknown frame ' + values.frame);
|
|
88
|
+
const rows = motionRows(
|
|
89
|
+
graph.records.filter(
|
|
90
|
+
(r) => r.valid && [r.edge.from, r.edge.to].some((ref) => ref.source === source && ref.frame === values.frame)
|
|
91
|
+
)
|
|
92
|
+
);
|
|
93
|
+
motionSummary(
|
|
94
|
+
data,
|
|
95
|
+
await Promise.all(rows.map(async (r) => ({
|
|
96
|
+
id: r.edge.id, label:await label(r), from:r.edge.from, to:r.edge.to, input:r.edge.trigger.on,
|
|
97
|
+
...(r.edge.proposed ? { proposed:r.edge.proposed } : {})
|
|
98
|
+
}))),
|
|
99
|
+
true
|
|
100
|
+
);
|
|
101
|
+
} else {
|
|
102
|
+
const records = graph.ids.get(values.transition) ?? [];
|
|
103
|
+
if (!records.length) throw new CliError('MOTION_EDGE_NOT_FOUND', 'Unknown transition ' + values.transition + '.');
|
|
104
|
+
if (records.length !== 1)
|
|
105
|
+
throw new CliError('SOURCE_BUILD_FAILED', 'Conflicting transition ID ' + values.transition + '; run adg check.');
|
|
106
|
+
const [r] = records,
|
|
107
|
+
validated = await behaviorMap(config, r.owner);
|
|
108
|
+
const bindings = validated.transitionBindings.filter((b) => b.active && b.design.transition === r.edge.id);
|
|
109
|
+
data.label = await label(r);
|
|
110
|
+
if (command === 'owner') {
|
|
111
|
+
data.query = { kind: 'transition', id: r.edge.id };
|
|
112
|
+
data.bindings = bindings.map((b) => ({
|
|
113
|
+
selector: b.implementation,
|
|
114
|
+
files: b.files,
|
|
115
|
+
anchorLine: b.anchorLine,
|
|
116
|
+
pointer: b.pointer
|
|
117
|
+
}));
|
|
118
|
+
data.mappingFindings = validated.findings;
|
|
119
|
+
} else {
|
|
120
|
+
data.findings = graph.findings.filter(
|
|
121
|
+
(f) => f.source === r.source && (f.pointer === r.pointer || f.pointer.startsWith(r.pointer + '/'))
|
|
122
|
+
);
|
|
123
|
+
data.edge = r.edge;
|
|
124
|
+
if (r.valid) {
|
|
125
|
+
let browser, page;
|
|
126
|
+
try {
|
|
127
|
+
const evaluate = motionEvaluator(config, {
|
|
128
|
+
flows: graph.flows,
|
|
129
|
+
bindings,
|
|
130
|
+
hasMap: validated.map.present,
|
|
131
|
+
themes: values.theme && values.theme !== 'both' ? [values.theme] : ['light', 'dark'],
|
|
132
|
+
getPage: async () => {
|
|
133
|
+
browser ??= await launch();
|
|
134
|
+
return (page ??= await browser.newPage());
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
for (const peer of graph.records) {
|
|
138
|
+
if (
|
|
139
|
+
peer !== r &&
|
|
140
|
+
peer.valid &&
|
|
141
|
+
peer.edge.from.source === r.edge.from.source &&
|
|
142
|
+
peer.edge.from.frame === r.edge.from.frame
|
|
143
|
+
)
|
|
144
|
+
await evaluate(peer);
|
|
145
|
+
}
|
|
146
|
+
const { detail, findings } = await evaluate(r);
|
|
147
|
+
data.bound = detail.bound;
|
|
148
|
+
data.themes = detail.themes;
|
|
149
|
+
data.findings.push(...findings);
|
|
150
|
+
if (!values.explain)
|
|
151
|
+
for (const facts of Object.values(data.themes)) {
|
|
152
|
+
if (facts.limitations)
|
|
153
|
+
facts.limitations = Object.fromEntries(
|
|
154
|
+
[...new Set(facts.limitations.map((l) => l.reason))].map((reason) => [
|
|
155
|
+
reason,
|
|
156
|
+
facts.limitations.filter((l) => l.reason === reason).length
|
|
157
|
+
])
|
|
158
|
+
);
|
|
159
|
+
for (const k of ['pairs', 'targets', 'tracks', 'ambiguous', 'conflicts']) delete facts[k];
|
|
160
|
+
}
|
|
161
|
+
} finally {
|
|
162
|
+
await browser?.close();
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
if (!values.json) log(JSON.stringify(data, null, 2));
|
|
168
|
+
return { data, warnings: [] };
|
|
169
|
+
}
|
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { existsSync, readdirSync, readFileSync } from 'node:fs';
|
|
3
|
+
import { lexer } from 'css-tree';
|
|
4
|
+
import { CliError } from '../cli-output.mjs';
|
|
5
|
+
import { jsonLocations } from './json-locations.mjs';
|
|
6
|
+
import { portablePath } from './owner-locators.mjs';
|
|
7
|
+
import { motionFlows } from './motion-flows.mjs';
|
|
8
|
+
import { relative } from './project.mjs';
|
|
9
|
+
import { loadMotionPatterns, patternEdge } from './motion-patterns.mjs';
|
|
10
|
+
import { motionPrimitives } from './motion-primitives.mjs';
|
|
11
|
+
|
|
12
|
+
const object = (value) => value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
13
|
+
const fields = (value, allowed) => object(value) && Object.keys(value).every((key) => allowed.includes(key));
|
|
14
|
+
const text = (value) => typeof value === 'string' && value.trim().length > 0;
|
|
15
|
+
export const edgeId = (value) => typeof value === 'string' && /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/.test(value);
|
|
16
|
+
const frameRef = (value) =>
|
|
17
|
+
fields(value, ['source', 'frame']) && portablePath(value.source) && value.source.endsWith('.tsx') && text(value.frame);
|
|
18
|
+
const modes = ['match', 'enter', 'exit', 'crossfade'];
|
|
19
|
+
function target(value) {
|
|
20
|
+
if (fields(value, ['frame'])) return value.frame === true;
|
|
21
|
+
if (fields(value, ['anchor'])) return text(value.anchor);
|
|
22
|
+
if (!fields(value, ['part', 'key']) || !text(value.part)) return false;
|
|
23
|
+
const [source, part, ...extra] = value.part.split('#');
|
|
24
|
+
return (
|
|
25
|
+
!extra.length &&
|
|
26
|
+
portablePath(source) &&
|
|
27
|
+
source.endsWith('.tsx') &&
|
|
28
|
+
text(part) &&
|
|
29
|
+
(value.key === undefined || text(value.key) || Number.isFinite(value.key))
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function validateShape(e, issue) {
|
|
34
|
+
if (
|
|
35
|
+
!fields(e, [
|
|
36
|
+
'id',
|
|
37
|
+
'label',
|
|
38
|
+
'from',
|
|
39
|
+
'to',
|
|
40
|
+
'trigger',
|
|
41
|
+
'duration',
|
|
42
|
+
'easing',
|
|
43
|
+
'phases',
|
|
44
|
+
'interrupt',
|
|
45
|
+
'reduced',
|
|
46
|
+
'focus',
|
|
47
|
+
'rememberTrigger',
|
|
48
|
+
'proposed',
|
|
49
|
+
'unsupported'
|
|
50
|
+
])
|
|
51
|
+
)
|
|
52
|
+
issue('MOTION_SCHEMA', '', 'Use only version 1 edge fields.');
|
|
53
|
+
if (!object(e)) return;
|
|
54
|
+
if (!edgeId(e.id)) issue('MOTION_SCHEMA', '/id', 'Use a project-unique kebab-case ID.');
|
|
55
|
+
for (const side of ['from', 'to'])
|
|
56
|
+
if (!frameRef(e[side])) issue('MOTION_SCHEMA', '/' + side, 'Expected an exact project-relative TSX source and frame.');
|
|
57
|
+
if (e.label !== undefined && (!text(e.label) || /[\r\n\x00-\x1f]|<\/?[a-z][^>]*>/i.test(e.label)))
|
|
58
|
+
issue('MOTION_SCHEMA', '/label', 'Use a nonempty plain-text action name.');
|
|
59
|
+
const t = e.trigger;
|
|
60
|
+
if (
|
|
61
|
+
!fields(t, ['on', 'target', 'key', 'value']) ||
|
|
62
|
+
!['click', 'hover', 'focus', 'key', 'input'].includes(t.on) ||
|
|
63
|
+
!target(t.target) ||
|
|
64
|
+
(t.on === 'input' ? typeof t.value !== 'string' : t.value !== undefined) ||
|
|
65
|
+
(t.on === 'key' ? !(text(t.key) || t.key === ' ') : t.key !== undefined)
|
|
66
|
+
)
|
|
67
|
+
issue('MOTION_SCHEMA', '/trigger', 'Choose an input and a unique target; key takes a key and input takes an exact string value.');
|
|
68
|
+
if (e.interrupt !== 'finish') issue('MOTION_SCHEMA', '/interrupt', 'Version 1 requires finish.');
|
|
69
|
+
if (e.reduced !== 'instant') issue('MOTION_REDUCED_MISSING', '/reduced', 'Declare the instant fallback.');
|
|
70
|
+
if (
|
|
71
|
+
!['frame', 'preserve', 'restore-trigger'].includes(e.focus) &&
|
|
72
|
+
!(fields(e.focus, ['target']) && target(e.focus.target))
|
|
73
|
+
)
|
|
74
|
+
issue('MOTION_FOCUS', '/focus', 'Declare a focus outcome or one destination target.');
|
|
75
|
+
if (e.rememberTrigger !== undefined && ![true, 'replace'].includes(e.rememberTrigger))
|
|
76
|
+
issue('MOTION_SCHEMA', '/rememberTrigger', 'Use true or replace.');
|
|
77
|
+
if (e.proposed !== undefined && !text(e.proposed)) issue('MOTION_STATUS', '/proposed', 'Name an active review scope.');
|
|
78
|
+
if (
|
|
79
|
+
e.unsupported !== undefined &&
|
|
80
|
+
!(
|
|
81
|
+
Array.isArray(e.unsupported) &&
|
|
82
|
+
e.unsupported.length &&
|
|
83
|
+
e.unsupported.every((u) => fields(u, ['effect', 'reason']) && text(u.effect) && text(u.reason))
|
|
84
|
+
)
|
|
85
|
+
)
|
|
86
|
+
issue('MOTION_SCHEMA', '/unsupported', 'Name each unsupported effect and its reason.');
|
|
87
|
+
if (!Array.isArray(e.phases)) {
|
|
88
|
+
issue('MOTION_SCHEMA', '/phases', 'Declare a phase array.');
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
e.phases.forEach((phase, i) => {
|
|
92
|
+
const at = '/phases/' + i;
|
|
93
|
+
if (!Array.isArray(phase) || !phase.length) {
|
|
94
|
+
issue('MOTION_SCHEMA', at, 'A phase needs tracks.');
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
phase.forEach((track, j) => {
|
|
98
|
+
const p = at + '/' + j;
|
|
99
|
+
if (
|
|
100
|
+
!fields(track, ['targets', 'properties', 'mode', 'duration', 'easing', 'fromOpacity']) ||
|
|
101
|
+
!modes.includes(track.mode) ||
|
|
102
|
+
!Array.isArray(track.targets) ||
|
|
103
|
+
!track.targets.length ||
|
|
104
|
+
!track.targets.every(target)
|
|
105
|
+
) {
|
|
106
|
+
issue('MOTION_SCHEMA', p, 'Invalid track mode, targets or fields.');
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
if (
|
|
110
|
+
track.fromOpacity !== undefined &&
|
|
111
|
+
!(track.mode === 'enter' && Number.isFinite(track.fromOpacity) && track.fromOpacity >= 0 && track.fromOpacity <= 1)
|
|
112
|
+
)
|
|
113
|
+
issue('MOTION_SCHEMA', p + '/fromOpacity', 'Only enter accepts a starting opacity in [0,1].');
|
|
114
|
+
const props = track.properties,
|
|
115
|
+
allowed = track.mode === 'match' ? ['x', 'y', 'width', 'height', 'opacity'] : ['opacity'];
|
|
116
|
+
if (
|
|
117
|
+
!Array.isArray(props) ||
|
|
118
|
+
!props.length ||
|
|
119
|
+
props.some((prop) => !allowed.includes(prop)) ||
|
|
120
|
+
new Set(props).size !== props.length
|
|
121
|
+
)
|
|
122
|
+
issue('MOTION_TRACK_CONFLICT', p + '/properties', 'Select distinct properties supported by this track mode.');
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export function motionFiles(config) {
|
|
128
|
+
function visit(dir) {
|
|
129
|
+
if (!existsSync(dir)) return [];
|
|
130
|
+
return readdirSync(dir, { withFileTypes: true }).flatMap((entry) => {
|
|
131
|
+
if (entry.name.startsWith('.') || entry.name === 'node_modules') return [];
|
|
132
|
+
const file = path.join(dir, entry.name);
|
|
133
|
+
return entry.isDirectory() ? visit(file) : entry.isFile() && file.endsWith('.motion.json') ? [file] : [];
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
return visit(config.design).sort();
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export function readMotion(config, files = motionFiles(config)) {
|
|
140
|
+
const records = [],
|
|
141
|
+
declarations = [],
|
|
142
|
+
findings = [],
|
|
143
|
+
ids = new Map();
|
|
144
|
+
let catalog;
|
|
145
|
+
for (const file of files) {
|
|
146
|
+
const source = relative(config, file),
|
|
147
|
+
owner = source.replace(/\.motion\.json$/, '.tsx');
|
|
148
|
+
let raw, doc;
|
|
149
|
+
try {
|
|
150
|
+
raw = readFileSync(file, 'utf8');
|
|
151
|
+
doc = JSON.parse(raw);
|
|
152
|
+
} catch (cause) {
|
|
153
|
+
throw new CliError('SOURCE_BUILD_FAILED', source + ': ' + cause.message, { cause });
|
|
154
|
+
}
|
|
155
|
+
if (object(doc) && Object.hasOwn(doc, 'version') && doc.version !== 1)
|
|
156
|
+
throw new CliError('SOURCE_BUILD_FAILED', source + ': unsupported motion version.');
|
|
157
|
+
const locations = jsonLocations(raw);
|
|
158
|
+
function issue(code, pointer, message, id) {
|
|
159
|
+
findings.push({
|
|
160
|
+
code,
|
|
161
|
+
source,
|
|
162
|
+
pointer,
|
|
163
|
+
message,
|
|
164
|
+
transition: id ?? null,
|
|
165
|
+
...(locations[pointer] ?? locations['']),
|
|
166
|
+
frame: null,
|
|
167
|
+
theme: null
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
if (!fields(doc, ['version', 'edges', 'flows']) || doc.version !== 1 || !Array.isArray(doc.edges)) {
|
|
171
|
+
issue('MOTION_SCHEMA', '', 'Expected version 1 and an edges array.');
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
if (doc.flows !== undefined && !Array.isArray(doc.flows))
|
|
175
|
+
issue('MOTION_FLOW_SCHEMA', '/flows', 'Expected a flows array.');
|
|
176
|
+
for (const [index, declaration] of (Array.isArray(doc.flows) ? doc.flows : []).entries()) {
|
|
177
|
+
const pointer = '/flows/' + index;
|
|
178
|
+
if (!fields(declaration, ['start', 'anchor', 'stage', 'ends']) ||
|
|
179
|
+
!frameRef(declaration.start) || declaration.start.source !== owner ||
|
|
180
|
+
!target(declaration.anchor) || declaration.anchor.frame ||
|
|
181
|
+
(declaration.stage !== undefined && (!fields(declaration.stage, ['width', 'height']) ||
|
|
182
|
+
![declaration.stage.width, declaration.stage.height].every((value) => Number.isFinite(value) && value > 0)))) {
|
|
183
|
+
issue('MOTION_FLOW_SCHEMA', pointer, 'Use a start frame in this sidecar’s source, a part or motion anchor, and optional positive stage dimensions.');
|
|
184
|
+
continue;
|
|
185
|
+
}
|
|
186
|
+
let ends;
|
|
187
|
+
if (declaration.ends !== undefined) {
|
|
188
|
+
if (!Array.isArray(declaration.ends) || declaration.ends.some(ref =>
|
|
189
|
+
!fields(ref, ['source', 'frame']) || !frameRef({ source: owner, ...ref }))) {
|
|
190
|
+
issue('MOTION_FLOW_SCHEMA', pointer + '/ends', 'Use an array of frame references. Omit source for frames in this sidecar’s source.');
|
|
191
|
+
continue;
|
|
192
|
+
}
|
|
193
|
+
ends = declaration.ends.map(ref => ({ source: owner, ...ref }));
|
|
194
|
+
}
|
|
195
|
+
declarations.push({ declaration: { ...declaration, ...(ends && { ends }) }, source, pointer, locations });
|
|
196
|
+
}
|
|
197
|
+
doc.edges.forEach((edge, index) => {
|
|
198
|
+
const pointer = '/edges/' + index,
|
|
199
|
+
problems = [];
|
|
200
|
+
const report = (code, suffix, message) => {
|
|
201
|
+
problems.push(code);
|
|
202
|
+
issue(code, pointer + suffix, message, edge?.id);
|
|
203
|
+
};
|
|
204
|
+
const pattern = edge?.pattern;
|
|
205
|
+
const resolved = pattern === undefined ? edge : patternEdge(edge, catalog ??= loadMotionPatterns(config), report);
|
|
206
|
+
if (!problems.length) validateShape(resolved, report);
|
|
207
|
+
const record = { source, owner, edge: resolved, pointer, locations, valid: problems.length === 0,
|
|
208
|
+
...(pattern === undefined ? {} : { pattern }) };
|
|
209
|
+
records.push(record);
|
|
210
|
+
if (!edgeId(edge?.id)) return;
|
|
211
|
+
if (!ids.has(edge.id)) ids.set(edge.id, []);
|
|
212
|
+
ids.get(edge.id).push(record);
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
for (const group of ids.values())
|
|
216
|
+
if (group.length > 1)
|
|
217
|
+
for (const r of group) {
|
|
218
|
+
r.valid = false;
|
|
219
|
+
const pointer = r.pointer + '/id';
|
|
220
|
+
findings.push({
|
|
221
|
+
code: 'MOTION_ID_CONFLICT',
|
|
222
|
+
source: r.source,
|
|
223
|
+
pointer,
|
|
224
|
+
...r.locations[pointer],
|
|
225
|
+
transition: r.edge.id,
|
|
226
|
+
frame: null,
|
|
227
|
+
theme: null,
|
|
228
|
+
message: 'Duplicate transition ID ' + r.edge.id
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
const { byFrame: flows, findings: flowFindings, deadEnds } = motionFlows(records.filter((r) => r.valid), declarations);
|
|
232
|
+
findings.push(...flowFindings);
|
|
233
|
+
return { records, findings, ids, declarations, flows, deadEnds, files: files.map((f) => relative(config, f)) };
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
const cssNumber = '[+-]?(?:\\d+(?:\\.\\d+)?|\\.\\d+)(?:[eE][+-]?\\d+)?';
|
|
237
|
+
const linearStop = new RegExp(
|
|
238
|
+
'^(?:' + cssNumber + '(?:\\s+' + cssNumber + '%){0,2}|(?:' + cssNumber + '%\\s+){1,2}' + cssNumber + ')$'
|
|
239
|
+
);
|
|
240
|
+
function validEasing(raw) {
|
|
241
|
+
// The bundled CSS grammar predates the piecewise linear() function.
|
|
242
|
+
const linear = /^linear\(([^()]*)\)$/i.exec(raw);
|
|
243
|
+
if (linear) {
|
|
244
|
+
const stops = linear[1].split(',').map((value) => value.trim());
|
|
245
|
+
return stops.length >= 2 && stops.every((stop) => linearStop.test(stop));
|
|
246
|
+
}
|
|
247
|
+
if (!lexer.matchType('easing-function', raw).matched) return false;
|
|
248
|
+
const steps = /^steps\(\s*(\d+)\s*(?:,\s*([\w-]+)\s*)?\)$/i.exec(raw);
|
|
249
|
+
return !steps || Number(steps[1]) >= (steps[2]?.toLowerCase() === 'jump-none' ? 2 : 1);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
const expandedTokens = new WeakMap();
|
|
253
|
+
export function resolveMotionToken(tokens, theme, name, kind) {
|
|
254
|
+
if (typeof name === 'string' && /^(--adg-motion-|--motion-spring-)/.test(name)) {
|
|
255
|
+
if (!expandedTokens.has(tokens)) expandedTokens.set(tokens, motionPrimitives(tokens).tokens);
|
|
256
|
+
tokens = expandedTokens.get(tokens);
|
|
257
|
+
}
|
|
258
|
+
const names = [],
|
|
259
|
+
invalid = () => ({ names, value: null });
|
|
260
|
+
if (typeof name !== 'string' || !/^--[\w-]+$/.test(name)) return invalid();
|
|
261
|
+
let key = name;
|
|
262
|
+
while (!names.includes(key)) {
|
|
263
|
+
names.push(key);
|
|
264
|
+
const raw = (theme === 'dark' ? tokens.dark.get(key) : undefined) ?? tokens.light.get(key);
|
|
265
|
+
if (!raw) return invalid();
|
|
266
|
+
const alias = /^var\(\s*(--[\w-]+)\s*\)$/.exec(raw);
|
|
267
|
+
if (alias) {
|
|
268
|
+
key = alias[1];
|
|
269
|
+
continue;
|
|
270
|
+
}
|
|
271
|
+
if (kind === 'duration') {
|
|
272
|
+
const time = /^(\+?(?:\d+(?:\.\d+)?|\.\d+))(ms|s)$/i.exec(raw);
|
|
273
|
+
const ms = time ? Number(time[1]) * (time[2].toLowerCase() === 's' ? 1000 : 1) : NaN;
|
|
274
|
+
return Number.isFinite(ms) ? { names, value: ms } : invalid();
|
|
275
|
+
}
|
|
276
|
+
if (!validEasing(raw)) return invalid();
|
|
277
|
+
return { names, value: raw };
|
|
278
|
+
}
|
|
279
|
+
return invalid();
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
export function timingRefs(edge) {
|
|
283
|
+
const refs = [{ pointer: '', scope: edge }];
|
|
284
|
+
edge.phases.forEach((phase, i) => phase.forEach((scope, j) => refs.push({ pointer: '/phases/' + i + '/' + j, scope })));
|
|
285
|
+
return refs.flatMap(({ pointer, scope }) =>
|
|
286
|
+
['duration', 'easing']
|
|
287
|
+
.filter((kind) => !pointer || Object.hasOwn(scope, kind))
|
|
288
|
+
.map((kind) => ({ pointer: pointer + '/' + kind, kind, name: scope[kind] }))
|
|
289
|
+
);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
export function motionSummary(data, rows, expanded = false) {
|
|
293
|
+
if (rows.length || expanded) data.motion = { count: rows.length, ...(expanded ? { edges: rows } : {}) };
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
export function motionRows(records) {
|
|
297
|
+
return [...new Map(records.filter((r) => edgeId(r.edge?.id)).map((r) => [r.edge.id, r])).values()].sort((a, b) =>
|
|
298
|
+
a.edge.id.localeCompare(b.edge.id, 'en')
|
|
299
|
+
);
|
|
300
|
+
}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { relative, sourceDirectories, sourceFeature } from './project.mjs';
|
|
3
|
+
import { frameOwners } from './source-facts.mjs';
|
|
4
|
+
|
|
5
|
+
function sourcePaths(config) {
|
|
6
|
+
const design = relative(config, config.design), layers = sourceDirectories(config);
|
|
7
|
+
const designPath = source => path.posix.relative(design, source);
|
|
8
|
+
return { designPath, featurePath: source => sourceFeature(designPath(source), layers) };
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function sourceRelations(inputs) {
|
|
12
|
+
const renames = new Map(inputs.renames?.map(rename => [rename.before, rename.after]));
|
|
13
|
+
const before = sourcePaths(inputs.before.config), after = sourcePaths(inputs.after.config);
|
|
14
|
+
const owned = new Map();
|
|
15
|
+
const partNames = (row, { designPath, featurePath }, frame) => {
|
|
16
|
+
if (!owned.has(row)) {
|
|
17
|
+
const source = designPath(row.source), feature = featurePath(row.source);
|
|
18
|
+
const owners = frame.owners ?? frameOwners(frame.html ?? '');
|
|
19
|
+
owned.set(row, new Set(owners.filter(owner =>
|
|
20
|
+
owner.source === source || (feature !== source && owner.source.startsWith(feature + '/')),
|
|
21
|
+
).map(owner => owner.export)));
|
|
22
|
+
}
|
|
23
|
+
return owned.get(row);
|
|
24
|
+
};
|
|
25
|
+
return [
|
|
26
|
+
(old, current) => renames.get(old.source) === current.source,
|
|
27
|
+
(old, current) => {
|
|
28
|
+
const feature = after.featurePath(current.source);
|
|
29
|
+
return feature !== after.designPath(current.source) && before.designPath(old.source) === feature + '.tsx';
|
|
30
|
+
},
|
|
31
|
+
(old, current) => {
|
|
32
|
+
const currentParts = partNames(current, after, current.after);
|
|
33
|
+
return [...partNames(old, before, old.before)].some(name => currentParts.has(name));
|
|
34
|
+
},
|
|
35
|
+
];
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** Strongest relation wins. Only mutually unique endpoints pair within each tier. */
|
|
39
|
+
export async function pairFrameMoves(rows, inputs, fingerprint, themes = ['light', 'dark']) {
|
|
40
|
+
const additions = rows.filter(row => row.status === 'added');
|
|
41
|
+
const removals = rows.filter(row => row.status === 'removed');
|
|
42
|
+
if (!additions.length || !removals.length) return rows;
|
|
43
|
+
const added = new Map(), pending = new Set();
|
|
44
|
+
for (const row of additions) {
|
|
45
|
+
const group = added.get(row.frame) ?? [];
|
|
46
|
+
group.push(row);
|
|
47
|
+
added.set(row.frame, group);
|
|
48
|
+
}
|
|
49
|
+
for (const old of removals) {
|
|
50
|
+
for (const current of added.get(old.frame) ?? []) {
|
|
51
|
+
if (old.source !== current.source) pending.add({ old, current });
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
const removed = new Set(), paired = new Map(), ambiguous = new Map();
|
|
55
|
+
const addCandidate = (row, candidate) => {
|
|
56
|
+
const candidates = ambiguous.get(row) ?? [];
|
|
57
|
+
candidates.push({ source: candidate.source, frame: candidate.frame });
|
|
58
|
+
ambiguous.set(row, candidates);
|
|
59
|
+
};
|
|
60
|
+
function resolve(edges, related) {
|
|
61
|
+
const candidates = [...edges].filter(({ old, current }) => related(old, current));
|
|
62
|
+
const left = new Map(), right = new Map();
|
|
63
|
+
for (const { old, current } of candidates) {
|
|
64
|
+
left.set(old, (left.get(old) ?? 0) + 1);
|
|
65
|
+
right.set(current, (right.get(current) ?? 0) + 1);
|
|
66
|
+
}
|
|
67
|
+
for (const { old, current } of candidates) {
|
|
68
|
+
if (left.get(old) === 1 && right.get(current) === 1) {
|
|
69
|
+
removed.add(old);
|
|
70
|
+
paired.set(current, {
|
|
71
|
+
...current, before: old.before, previousSource: old.source, previousFrame: old.frame, status: 'matched',
|
|
72
|
+
matchKind: 'exact', matchCandidates: [],
|
|
73
|
+
change: { kind: 'direct', causes: [old.source, current.source].sort() },
|
|
74
|
+
});
|
|
75
|
+
} else {
|
|
76
|
+
addCandidate(old, current);
|
|
77
|
+
addCandidate(current, old);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
// A weaker relation must not pick a winner among stronger ambiguous candidates.
|
|
81
|
+
for (const edge of edges) if (left.has(edge.old) || right.has(edge.current)) edges.delete(edge);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const relations = sourceRelations(inputs);
|
|
85
|
+
const fingerprints = new Map(themes.map(theme => [theme, new Map()]));
|
|
86
|
+
async function capture(candidates, theme) {
|
|
87
|
+
const saved = fingerprints.get(theme);
|
|
88
|
+
const missing = [...new Set(candidates)].filter(row => !saved.has(row));
|
|
89
|
+
if (missing.length) {
|
|
90
|
+
const captured = await fingerprint(missing, theme);
|
|
91
|
+
for (const row of missing) saved.set(row, captured.get(row));
|
|
92
|
+
}
|
|
93
|
+
return saved;
|
|
94
|
+
}
|
|
95
|
+
const endpoints = edges => [...edges].flatMap(({ old, current }) => [old, current]);
|
|
96
|
+
const identical = saved => (old, current) => saved.get(old) !== undefined && saved.get(old) === saved.get(current);
|
|
97
|
+
|
|
98
|
+
for (const related of relations) resolve(pending, related);
|
|
99
|
+
if (pending.size) {
|
|
100
|
+
const sameFirst = identical(await capture(endpoints(pending), themes[0]));
|
|
101
|
+
for (const edge of pending) if (!sameFirst(edge.old, edge.current)) pending.delete(edge);
|
|
102
|
+
if (pending.size) resolve(pending, identical(await capture(endpoints(pending), themes[1])));
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const oldUnpaired = removals.filter(row => !removed.has(row));
|
|
106
|
+
const currentUnpaired = additions.filter(row => !paired.has(row));
|
|
107
|
+
if (oldUnpaired.length && currentUnpaired.length) {
|
|
108
|
+
const first = await capture([...oldUnpaired, ...currentUnpaired], themes[0]);
|
|
109
|
+
const byRender = new Map();
|
|
110
|
+
for (const current of currentUnpaired) {
|
|
111
|
+
const key = first.get(current);
|
|
112
|
+
if (key === undefined) continue;
|
|
113
|
+
const group = byRender.get(key) ?? [];
|
|
114
|
+
group.push(current);
|
|
115
|
+
byRender.set(key, group);
|
|
116
|
+
}
|
|
117
|
+
const renamed = new Set();
|
|
118
|
+
for (const old of oldUnpaired) {
|
|
119
|
+
for (const current of byRender.get(first.get(old)) ?? []) {
|
|
120
|
+
if (old.frame !== current.frame) renamed.add({ old, current });
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
if (renamed.size) {
|
|
124
|
+
const sameSecond = identical(await capture(endpoints(renamed), themes[1]));
|
|
125
|
+
for (const edge of renamed) if (!sameSecond(edge.old, edge.current)) renamed.delete(edge);
|
|
126
|
+
for (const related of relations) resolve(renamed, related);
|
|
127
|
+
resolve(renamed, () => true);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
const identity = ({ source, frame }) => JSON.stringify([source, frame]);
|
|
131
|
+
const moved = new Set([...removed, ...paired.keys()].map(identity));
|
|
132
|
+
return rows.flatMap(row => {
|
|
133
|
+
if (removed.has(row)) return [];
|
|
134
|
+
if (paired.has(row)) return [paired.get(row)];
|
|
135
|
+
const entries = [...row.matchCandidates, ...(ambiguous.get(row) ?? [])];
|
|
136
|
+
const candidates = new Map(entries.map(candidate => [identity(candidate), candidate]).filter(([key]) => !moved.has(key)));
|
|
137
|
+
if (!ambiguous.has(row) && candidates.size === row.matchCandidates.length) return [row];
|
|
138
|
+
return [{ ...row, matchCandidates: [...candidates.values()], matchKind: candidates.size ? 'renamed_or_unknown' : 'unmatched' }];
|
|
139
|
+
});
|
|
140
|
+
}
|
package/src/toolkit/owner.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { boundEdges, tokenEdges, transitionQuery } from './motion-queries.mjs';
|
|
1
2
|
import { readFile } from 'node:fs/promises';
|
|
2
3
|
import path from 'node:path';
|
|
3
4
|
import { CliError, nextActions } from '../cli-output.mjs';
|
|
@@ -49,15 +50,24 @@ async function ownerPart(config, values, { log = console.log } = {}) {
|
|
|
49
50
|
for (const implementation of implementations) row.evidence.push({ matchKind: 'mapping_part', frame: null, theme: null, elementPath: null, boxes: [], owners: [], detail: { kind: 'mapping', file: map.source, pointer: binding.pointer, implementation: implementation.file, selector, symbol: selector.symbol ?? null, region: implementation.region } });
|
|
50
51
|
data.owners.push(row);
|
|
51
52
|
}
|
|
53
|
+
await boundEdges(config,validated.transitionBindings,data,values.transitions);
|
|
52
54
|
data.complete = true;
|
|
53
|
-
if (!data.owners.length) warnings.push({ code: 'OWNER_NO_MATCH', message: 'No implementation binding matched the requested design part.', next: [] });
|
|
55
|
+
if (!data.owners.length && !data.motion?.count) warnings.push({ code: 'OWNER_NO_MATCH', message: 'No implementation binding matched the requested design part.', next: [] });
|
|
54
56
|
if (!values.json) for (const row of data.owners) log(`${row.source}${row.part ? `#${row.part}` : ''} [${row.matchKind}] ${row.evidence.map(e => e.detail.implementation).join(', ')}`);
|
|
55
57
|
return { data, warnings };
|
|
56
58
|
}
|
|
57
59
|
|
|
58
60
|
export async function owner(config, values, { log = console.log, openIndex = openProjectIndex, launchBrowser = launch, environment = observationEnvironment } = {}) {
|
|
61
|
+
if (values.transition !== undefined) return transitionQuery(config,'owner',[],values,log);
|
|
59
62
|
if (values.part !== undefined) return ownerPart(config, values, { log });
|
|
60
|
-
if (values.file === undefined)
|
|
63
|
+
if (values.file === undefined) {
|
|
64
|
+
const result=await (await import('./owner-search.mjs')).searchOwner(config, values, { log, openIndex, launchBrowser, environment });
|
|
65
|
+
if(values.token!==undefined){
|
|
66
|
+
await tokenEdges(config,values,result.data);
|
|
67
|
+
if(result.data.motion?.count)result.warnings=result.warnings.filter(w=>w.code!=='OWNER_NO_MATCH');
|
|
68
|
+
}
|
|
69
|
+
return result;
|
|
70
|
+
}
|
|
61
71
|
const { query, text } = await normalizeFileQuery(config, values);
|
|
62
72
|
const data = { project: config.root, complete: false, query, region: null, owners: [], tokens: [], ambiguous: false, tokenAmbiguous: false, matchedImplementationFiles: [], mappingFindings: [],
|
|
63
73
|
coverage: { discoveredSources: 0, builtSources: 0, requestedObservations: 0, completedObservations: 0, mappingState: 'absent', activeBindings: 0, excludedBindings: 0, domain: 'tsx' } };
|
|
@@ -79,11 +89,14 @@ export async function owner(config, values, { log = console.log, openIndex = ope
|
|
|
79
89
|
const validated = await index.mappings({ map, mappingIndices, implementationSelection: files, onFinding: finding => { data.mappingFindings.push(finding); data.coverage.mappingState = 'stale'; } });
|
|
80
90
|
data.mappingFindings = validated.findings;
|
|
81
91
|
data.coverage.mappingState = !map.present ? 'absent' : validated.findings.length ? 'stale' : 'valid';
|
|
92
|
+
await boundEdges(config,validated.transitionBindings,data,values.transitions);
|
|
82
93
|
const active = validated.bindings.filter(binding => binding.active);
|
|
83
|
-
|
|
94
|
+
const allBindings = [...validated.bindings, ...validated.transitionBindings];
|
|
95
|
+
const activeBindings = allBindings.filter(binding => binding.active);
|
|
96
|
+
data.coverage.activeBindings = activeBindings.length; data.coverage.excludedBindings = allBindings.length - activeBindings.length;
|
|
84
97
|
if (!map.present) warn('OWNER_MAPPING_MISSING', 'Add implementation.json to declare implementation ownership, then validate it.');
|
|
85
98
|
if (validated.findings.length) warn('OWNER_MAPPING_STALE', 'Repair the reported implementation mapping findings, then repeat the query.');
|
|
86
|
-
if ((query.line !== null || query.symbol !== null) && !
|
|
99
|
+
if ((query.line !== null || query.symbol !== null) && !activeBindings.some(binding => binding.implementation.symbol)) warn('OWNER_LOCATOR_UNMAPPED', 'Add or refine a symbol/anchor binding for this implementation region, then repeat the query.', true);
|
|
87
100
|
const tasks = new Map();
|
|
88
101
|
for (const binding of active) {
|
|
89
102
|
const target = binding.design, key = JSON.stringify([target.source, target.part ?? null]), kind = bindingKind(binding.implementation, query), rank = fileRank(binding.implementation, kind);
|
|
@@ -175,11 +188,11 @@ export async function owner(config, values, { log = console.log, openIndex = ope
|
|
|
175
188
|
data.tokens.sort((a, b) => compareNames(a.name, b.name));
|
|
176
189
|
data.ambiguous = data.owners.length > 1 && compareRanks(data.owners[0].rank, data.owners[1].rank) === 0;
|
|
177
190
|
if (data.ambiguous) warn('OWNER_AMBIGUOUS', 'Several owners share the best rank; narrow the file locator, text or theme before choosing an owner.', true);
|
|
178
|
-
if (!data.owners.length && !data.tokens.length) warn('OWNER_NO_MATCH', 'No ownership evidence matched. Validate current sources and add or refine an implementation mapping.');
|
|
191
|
+
if (!data.owners.length && !data.tokens.length && !data.motion?.count) warn('OWNER_NO_MATCH', 'No ownership evidence matched. Validate current sources and add or refine an implementation mapping.');
|
|
179
192
|
if (!data.coverage.discoveredSources) warnings.push({ code: 'EMPTY_SELECTION', message: 'No TSX design sources were discovered.', next: [] });
|
|
180
193
|
data.complete = true;
|
|
181
194
|
if (!values.json) {
|
|
182
|
-
if (!data.owners.length) log('No ownership evidence matched.');
|
|
195
|
+
if (!data.owners.length && !data.motion?.count) log('No ownership evidence matched.');
|
|
183
196
|
if (data.ambiguous) log('Multiple owners share the best rank.');
|
|
184
197
|
for (const row of data.owners) log(`${row.source}${row.part ? `#${row.part}` : ''} [${row.matchKind}] ${[...new Set(row.frames.map(frame => frame.frame))].join(', ')}${row.tokens.length ? `; tokens: ${row.tokens.join(', ')}` : ''}`);
|
|
185
198
|
for (const warning of warnings) log(`${warning.code}: ${warning.message}`);
|