@whzxc/agent-design-gallery 0.14.1 → 0.15.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 +26 -16
- package/package.json +1 -1
- package/public/access.css +15 -2
- package/public/app.js +708 -483
- package/public/arrangement-worker.js +7 -7
- package/public/arrangement.js +35 -30
- package/public/assets.js +60 -38
- package/public/auth.js +59 -4
- package/public/boards.js +124 -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 +26 -2
- package/public/hub.css +25 -3
- package/public/hub.html +10 -2
- package/public/hub.js +127 -23
- package/public/icons.js +2 -0
- package/public/index.html +13 -9
- package/public/instance-actions.js +9 -2
- package/public/layout.js +156 -86
- package/public/selection.js +1 -1
- package/public/style.css +74 -152
- package/public/switcher.css +5 -4
- package/public/switcher.js +109 -34
- package/public/token-catalog.js +8 -3
- package/public/tokens.css +14 -1
- package/public/view-route.js +0 -1
- package/src/boards/board.mjs +30 -0
- package/src/boards/token-board.mjs +196 -0
- package/src/cli-output.mjs +8 -5
- package/src/cli.mjs +49 -29
- package/src/comments.mjs +293 -0
- package/src/http.mjs +2 -3
- 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/server.mjs +57 -93
- package/src/service.mjs +46 -12
- package/src/toolkit/arch.mjs +3 -2
- package/src/toolkit/asset-rules.mjs +24 -1
- package/src/toolkit/commands.mjs +12 -7
- package/{public/review.js → src/toolkit/diff-document.mjs} +137 -43
- package/src/toolkit/diff-inputs.mjs +66 -30
- package/src/toolkit/diff.mjs +181 -39
- package/src/toolkit/impact-selection.mjs +25 -10
- package/src/toolkit/impact.mjs +32 -12
- package/src/toolkit/move-pairing.mjs +140 -0
- package/src/toolkit/project-index.mjs +2 -2
- package/src/toolkit/results.mjs +1 -1
- package/src/toolkit/review-document.mjs +435 -0
- package/src/toolkit/review-groups.mjs +29 -0
- package/src/toolkit/review-observation.mjs +131 -0
- package/src/toolkit/review-sheet.mjs +117 -0
- package/src/toolkit/review-specimens.mjs +60 -0
- package/src/toolkit/review.mjs +140 -0
- package/src/toolkit/runtime.mjs +1 -1
- package/src/toolkit/theme.mjs +16 -0
- package/public/annotations.js +0 -816
- package/public/labels.js +0 -122
- package/src/annotations.mjs +0 -238
package/public/layout.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Pure
|
|
1
|
+
// Pure board geometry. Board children use local coordinates; items use world coordinates.
|
|
2
2
|
export function bounds(boxes) {
|
|
3
3
|
if (!boxes.length) return { x: 0, y: 0, w: 1, h: 1 };
|
|
4
4
|
const x = Math.min(...boxes.map(b => b.x)), y = Math.min(...boxes.map(b => b.y));
|
|
@@ -13,102 +13,172 @@ export function rows(blocks, limit, gapX, gapY, nextWidth) {
|
|
|
13
13
|
return placed;
|
|
14
14
|
});
|
|
15
15
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
16
|
+
|
|
17
|
+
export const boardGeometry = Object.freeze({
|
|
18
|
+
width: 1680, side: 80, top: 64, bottom: 80,
|
|
19
|
+
label: 280, sectionGap: 56, sectionPadding: 48,
|
|
20
|
+
columns: 12, columnGap: 24, rowGap: 32,
|
|
21
|
+
wellX: 24, wellY: 32, wellMinHeight: 96,
|
|
22
|
+
captionGap: 12, metaLine: 17, boardGap: 240, bandGap: 480,
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const lineCount = (text, width, characterWidth) => String(text ?? '').split('\n')
|
|
26
|
+
.reduce((count, line) => count + Math.max(1, Math.ceil(line.length * characterWidth / width)), 0);
|
|
27
|
+
|
|
28
|
+
export function blockForAsset(asset) {
|
|
29
|
+
const parts = asset.parts.length ? asset.parts : [{ ...asset.full, id: 'full', name: 'Full sheet' }];
|
|
30
|
+
const box = bounds(parts.map(p => ({ x: p.x, y: p.y, w: p.width, h: p.height })));
|
|
31
|
+
const previewCrop = asset.component ? {
|
|
32
|
+
id: 'overview', name: 'All forms', x: box.x - 24, y: box.y - 32,
|
|
33
|
+
width: box.w + 48, height: box.h + 64,
|
|
34
|
+
} : undefined;
|
|
35
|
+
const filename = asset.path.split('/').at(-1);
|
|
36
|
+
return {
|
|
37
|
+
asset: asset.path, path: asset.path, kind: 'flow',
|
|
38
|
+
title: filename === 'index.tsx' ? asset.path.split('/').at(-2) : filename.replace(/\.(tsx|svg|mmd)$/, ''),
|
|
39
|
+
modified: asset.modified, modifiedAt: asset.modifiedAt, previewCrop,
|
|
40
|
+
frames: parts.map(part => ({
|
|
41
|
+
id: part.id, name: part.name, note: part.note, proposed: part.proposed, proposal: part.proposed,
|
|
42
|
+
w: part.width, h: part.height,
|
|
43
|
+
crop: { x: part.x, y: part.y, w: part.width, h: part.height },
|
|
44
|
+
})),
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// The paint window is bounded by the well padding and neighbouring legacy frames.
|
|
49
|
+
export function specimenPaintCrop(asset, crop) {
|
|
50
|
+
if (asset.layer?.toLowerCase() === 'surfaces' || asset.path.startsWith('surfaces/')) return crop;
|
|
51
|
+
let left = crop.x - 24, right = crop.x + crop.width + 24;
|
|
52
|
+
let top = crop.y - 32, bottom = crop.y + crop.height + 32;
|
|
53
|
+
if (asset.component && asset.format !== 'tsx') for (const other of asset.parts) {
|
|
54
|
+
if (other.id === crop.id) continue;
|
|
55
|
+
if (other.y < bottom && other.y + other.height > top) {
|
|
56
|
+
if (other.x >= crop.x + crop.width) right = Math.min(right, (crop.x + crop.width + other.x) / 2);
|
|
57
|
+
if (other.x + other.width <= crop.x) left = Math.max(left, (crop.x + other.x + other.width) / 2);
|
|
58
|
+
}
|
|
59
|
+
if (other.x < right && other.x + other.width > left) {
|
|
60
|
+
if (other.y >= crop.y + crop.height) bottom = Math.min(bottom, (crop.y + crop.height + other.y) / 2);
|
|
61
|
+
if (other.y + other.height <= crop.y) top = Math.max(top, (crop.y + other.y + other.height) / 2);
|
|
33
62
|
}
|
|
34
|
-
result[index] = { ...block, x:bestX, y:bestY };
|
|
35
|
-
lefts.push(bestX);rights.push(bestX+block.w+gapX);bottoms.push(bestY+block.h+gapY);
|
|
36
63
|
}
|
|
37
|
-
return
|
|
38
|
-
}
|
|
39
|
-
// Cache only the winning width, never source objects or placed coordinates.
|
|
40
|
-
// Repacking at that width gives fresh metadata after saves with unchanged geometry.
|
|
41
|
-
const widthChoices = new Map();
|
|
42
|
-
export function packingSnapshot() {return [...widthChoices];}
|
|
43
|
-
export function restorePacking(entries=[]) {
|
|
44
|
-
for(const [key,width] of entries.slice(-32))
|
|
45
|
-
if(typeof key==='string'&&key.length<=32768&&Number.isFinite(width)&&width>0)widthChoices.set(key,width);
|
|
46
|
-
while(widthChoices.size>32)widthChoices.delete(widthChoices.keys().next().value);
|
|
64
|
+
return {...crop, x:left, y:top, width:right-left, height:bottom-top};
|
|
47
65
|
}
|
|
48
|
-
|
|
49
|
-
function
|
|
50
|
-
|
|
51
|
-
const
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
Number.isSafeInteger(step * 64) && blocks.every(b => Number.isSafeInteger(b.w * 64));
|
|
61
|
-
let best, bestLimit, score = Infinity;
|
|
62
|
-
for (let limit = minimum; limit <= maximum + step; limit += step) {
|
|
63
|
-
let threshold = Infinity;
|
|
64
|
-
const placed = pack(limit, width => { threshold = Math.min(threshold, width); }), box = bounds(placed);
|
|
65
|
-
const distance = box.w * box.h * (1 + aspectPenalty * Math.abs(Math.log((box.w / box.h) / ratio)));
|
|
66
|
-
if (distance < score) { best = placed; bestLimit = limit; score = distance; }
|
|
67
|
-
if (skip) {
|
|
68
|
-
if (threshold === Infinity) break;
|
|
69
|
-
limit += Math.max(0, Math.ceil((threshold - limit) / step) - 1) * step;
|
|
66
|
+
|
|
67
|
+
function layoutSection(section, width, y, columns = boardGeometry.columns) {
|
|
68
|
+
const g = boardGeometry;
|
|
69
|
+
const areaWidth = width - g.side * 2 - g.label - g.sectionGap;
|
|
70
|
+
const columnWidth = (areaWidth + g.columnGap) / columns;
|
|
71
|
+
let column = 0, rowY = g.sectionPadding + 1, rowHeight = 0;
|
|
72
|
+
const frames = section.frames.map(frame => {
|
|
73
|
+
const span = Math.min(columns, Math.max(1, Math.ceil((frame.w + g.wellX * 2 + g.columnGap) / columnWidth)));
|
|
74
|
+
if (column + span > columns) {
|
|
75
|
+
column = 0;
|
|
76
|
+
rowY += rowHeight + g.rowGap;
|
|
77
|
+
rowHeight = 0;
|
|
70
78
|
}
|
|
79
|
+
const x = g.label + g.sectionGap + column * columnWidth;
|
|
80
|
+
const wellWidth = span * columnWidth - g.columnGap;
|
|
81
|
+
const wellHeight = Math.max(g.wellMinHeight, frame.h + g.wellY * 2);
|
|
82
|
+
const captionHeight = lineCount(frame.name, wellWidth, 7.2) * g.metaLine +
|
|
83
|
+
(frame.note || frame.proposed ? 2 + lineCount([frame.note, frame.proposed && `Proposed: ${frame.proposed}`].filter(Boolean).join(' · '), wellWidth, 6.5) * g.metaLine : 0);
|
|
84
|
+
const well = { x, y: rowY, w: wellWidth, h: wellHeight };
|
|
85
|
+
const caption = { x, y: rowY + wellHeight + g.captionGap, w: wellWidth, h: captionHeight };
|
|
86
|
+
rowHeight = Math.max(rowHeight, wellHeight + g.captionGap + captionHeight);
|
|
87
|
+
column += span;
|
|
88
|
+
return { ...frame, span, x: x + (wellWidth - frame.w) / 2, y: rowY + (wellHeight - frame.h) / 2, well, caption };
|
|
89
|
+
});
|
|
90
|
+
const labelHeight = lineCount(section.title, g.label, 12) * 28 + 20 +
|
|
91
|
+
lineCount(section.path, g.label - 18, 6.6) * 18 + (section.modified || section.modifiedAt ? 26 : 0);
|
|
92
|
+
const contentHeight = frames.length ? rowY - g.sectionPadding - 1 + rowHeight : 0;
|
|
93
|
+
return { ...section, x: g.side, y, w: width - g.side * 2,
|
|
94
|
+
h: 1 + g.sectionPadding * 2 + Math.max(labelHeight, contentHeight),
|
|
95
|
+
label: { x: 0, y: g.sectionPadding + 1, w: g.label, h: labelHeight },
|
|
96
|
+
specimenArea: { x: g.label + g.sectionGap, y: g.sectionPadding + 1, w: areaWidth, h: contentHeight },
|
|
97
|
+
frames,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function layoutBoardAtWidth(board, w, columns) {
|
|
102
|
+
const g = boardGeometry;
|
|
103
|
+
const headerHeight = 28 + 16 + lineCount(board.title, Math.max(1, w - g.side * 2 - 440 - 64), 26) * 56 + 56;
|
|
104
|
+
let y = g.top + headerHeight;
|
|
105
|
+
const blocks = board.blocks.map(section => {
|
|
106
|
+
const placed = layoutSection(section, w, y, columns);
|
|
107
|
+
y += placed.h;
|
|
108
|
+
return placed;
|
|
109
|
+
});
|
|
110
|
+
return { ...board, w, h: y + g.bottom,
|
|
111
|
+
header: { x: g.side, y: g.top, w: w - g.side * 2, h: headerHeight },
|
|
112
|
+
sourceCount: blocks.length, frameCount: blocks.reduce((sum, section) => sum + section.frames.length, 0), blocks,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function layoutBoard(board) {
|
|
117
|
+
const g = boardGeometry;
|
|
118
|
+
const baseArea = g.width - g.side * 2 - g.label - g.sectionGap;
|
|
119
|
+
const widest = Math.max(0, ...board.blocks.flatMap(section => section.frames.map(frame => frame.w + g.wellX * 2)));
|
|
120
|
+
const initialWidth = Math.max(g.width, g.side * 2 + g.label + g.sectionGap + widest);
|
|
121
|
+
let result = layoutBoardAtWidth(board, initialWidth, g.columns);
|
|
122
|
+
for (let multiplier = 2; multiplier <= 4 && result.h > 2 * result.w; multiplier++) {
|
|
123
|
+
result = layoutBoardAtWidth(board, initialWidth + (multiplier - 1) * (baseArea + g.columnGap), g.columns * multiplier);
|
|
71
124
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
125
|
+
return result;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function placeColumns(boards, count, previous = []) {
|
|
129
|
+
const g = boardGeometry;
|
|
130
|
+
const heights = Array(count).fill(0), widths = Array(count).fill(0);
|
|
131
|
+
const oldByKey = new Map(previous.map(board => [board.key, board]));
|
|
132
|
+
const placed = boards.map(board => {
|
|
133
|
+
const old = oldByKey.get(board.key);
|
|
134
|
+
const column = Number.isInteger(old?.column) && old.column < count
|
|
135
|
+
? old.column : heights.indexOf(Math.min(...heights));
|
|
136
|
+
const y = heights[column];
|
|
137
|
+
heights[column] += board.h + g.boardGap;
|
|
138
|
+
widths[column] = Math.max(widths[column], board.w, old?.columnWidth ?? 0);
|
|
139
|
+
return { ...board, column, y };
|
|
140
|
+
});
|
|
141
|
+
// Retain column widths across saves so shrinking a board does not move its neighbours.
|
|
142
|
+
for (const old of previous) if (old.column < count) widths[old.column] = Math.max(widths[old.column], old.columnWidth ?? old.w);
|
|
143
|
+
const lefts = [];
|
|
144
|
+
let x = 0;
|
|
145
|
+
for (const width of widths) { lefts.push(x); x += width + g.boardGap; }
|
|
146
|
+
return placed.map(board => ({ ...board, x: lefts[board.column], columnWidth: widths[board.column], columnCount: count }));
|
|
77
147
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
148
|
+
|
|
149
|
+
export function layoutWorld(input, { previousGroups = [] } = {}) {
|
|
150
|
+
const bands = new Map();
|
|
151
|
+
for (const [index, source] of input.entries()) {
|
|
152
|
+
const board = layoutBoard({ ...source, key: source.key ?? `${source.layer ?? ''}:${source.title ?? index}` });
|
|
153
|
+
if (!bands.has(board.layer)) bands.set(board.layer, []);
|
|
154
|
+
bands.get(board.layer).push(board);
|
|
155
|
+
}
|
|
156
|
+
const result = [];
|
|
157
|
+
let bandY = 0;
|
|
158
|
+
for (const [layer, boards] of bands) {
|
|
159
|
+
const previous = previousGroups.filter(board => board.layer === layer && Number.isInteger(board.column));
|
|
160
|
+
let placed;
|
|
161
|
+
if (previous.length) {
|
|
162
|
+
placed = placeColumns(boards, Math.max(...previous.map(board => board.columnCount ?? board.column + 1)), previous);
|
|
163
|
+
} else {
|
|
164
|
+
let distance = Infinity;
|
|
165
|
+
for (let count = 1; count <= boards.length; count++) {
|
|
166
|
+
const candidate = placeColumns(boards, count);
|
|
167
|
+
const box = bounds(candidate);
|
|
168
|
+
const score = Math.abs(box.w / box.h - 16 / 10);
|
|
169
|
+
if (score < distance) { placed = candidate; distance = score; }
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
result.push(...placed.map(board => ({ ...board, y: board.y + bandY, bandY })));
|
|
173
|
+
bandY += bounds(placed).h + boardGeometry.bandGap;
|
|
89
174
|
}
|
|
90
|
-
|
|
91
|
-
if (!placed) return null;
|
|
92
|
-
return placed.map(section => ({ ...section, blocks: section.blocks.map(block => {
|
|
93
|
-
const x = section.x + 64 + block.x, y = section.y + 104 + block.y;
|
|
94
|
-
return { ...block, x, y, ...(block.frames ? { frames: block.frames.map(frame => ({ ...frame, x: x + frame.x, y: y + frame.y })) } : {}) };
|
|
95
|
-
}) }));
|
|
175
|
+
return result;
|
|
96
176
|
}
|
|
177
|
+
|
|
97
178
|
export function componentWrapWidth(parts) {
|
|
98
|
-
const area = parts.reduce((sum, part) => sum + (part.width +
|
|
179
|
+
const area = parts.reduce((sum, part) => sum + (part.width + 48) * (part.height + 64), 0);
|
|
99
180
|
return Math.min(6400, Math.max(1600, Math.ceil(Math.sqrt(area * 1.6))));
|
|
100
181
|
}
|
|
101
|
-
export function blockForAsset(asset) {
|
|
102
|
-
const parts = asset.parts.length ? asset.parts : [{ ...asset.full, id: 'full', name: 'Full sheet' }];
|
|
103
|
-
if (asset.component || !asset.parts.length) {
|
|
104
|
-
const box = bounds(parts.map(p => ({ x: p.x, y: p.y, w: p.width, h: p.height })));
|
|
105
|
-
const crop = { x: box.x - 24, y: box.y - 36, w: box.w + 48, h: box.h + 60 };
|
|
106
|
-
return { asset: asset.path, kind: 'set', w: crop.w, h: crop.h, crop };
|
|
107
|
-
}
|
|
108
|
-
const frames = rows(parts.map(p => ({ id: p.id, name: p.name, w: p.width + 32, h: p.height + 32, crop: { x: p.x - 16, y: p.y - 16, w: p.width + 32, h: p.height + 32 } })), 3600, 64, 112);
|
|
109
|
-
const box = bounds(frames);
|
|
110
|
-
return { asset: asset.path, kind: 'flow', w: box.w, h: box.h, frames };
|
|
111
|
-
}
|
|
112
182
|
export function fitArea(width, height, sidebar = true, inspector = false) {
|
|
113
183
|
const left = (sidebar ? 272 : 0) + 20, right = width - (inspector ? 312 : 0) - 24;
|
|
114
184
|
return { x: left, y: 100, width: Math.max(1, right - left), height: Math.max(1, height - 184) };
|
package/public/selection.js
CHANGED
|
@@ -10,7 +10,7 @@ export function hitSelection(assets, x, y, elements = true) {
|
|
|
10
10
|
const part = asset.parts.find(p => (asset.component || p.id === crop.id) && contains(frameBox(asset,p), x,y));
|
|
11
11
|
if (!part) return {asset, part:asset.component ? null : asset.parts.find(p=>p.id===crop.id)};
|
|
12
12
|
const box = frameBox(asset,part);
|
|
13
|
-
const element = elements ?
|
|
13
|
+
const element = elements ? part.elements?.findLast(e => !e.commentOnly && contains(e,x-box.x,y-box.y)) : null;
|
|
14
14
|
return {asset, part, element};
|
|
15
15
|
}
|
|
16
16
|
return null;
|