claude-exode-mcp 7.5.7 → 7.5.8
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/MCP_DOCUMENTATION.md +1 -0
- package/SKILL.md +10 -0
- package/examples/aurum-product-page.exode +3208 -0
- package/examples/bell-ring-icon.exode +1 -0
- package/examples/drift-kinetic-type.exode +770 -0
- package/examples/earbuds-product.exode +214 -0
- package/examples/energy-flow.exode +1736 -0
- package/examples/flux-hero.exode +223 -0
- package/examples/gooey-toggle.exode +214 -0
- package/examples/gravity-well.exode +3113 -0
- package/examples/heart-icon.exode +1 -0
- package/examples/hologram-temple.exode +8100 -0
- package/examples/jarful-app.exode +1 -0
- package/examples/kip-character-rig.exode +1 -0
- package/examples/low-tide-tilt.exode +2216 -0
- package/examples/manifest.json +352 -0
- package/examples/swipe-stack-carousel.exode +4048 -0
- package/examples/tokyo-neon-weather.exode +470 -0
- package/examples/typographic-collapse.exode +1578 -0
- package/examples/void-product-ad.exode +1269 -0
- package/examples/wire-globe-card.exode +580 -0
- package/index.d.ts +41 -1
- package/index.js +2553 -2407
- package/package.json +4 -2
- package/render-runtime/exode-runtime.js +20 -20
- package/skills/creative-motion/SKILL.md +10 -0
- package/skills/creative-motion/recipes/character-rig.js +104 -0
- package/skills/creative-motion/recipes/dashboard.js +120 -0
- package/skills/creative-motion/recipes/game-arcade.js +203 -0
- package/skills/creative-motion/recipes/hero-physics.js +65 -0
- package/skills/creative-motion/recipes/pricing.js +88 -0
- package/skills/creative-motion/recipes/title-sequence.js +62 -0
- package/skills/creative-motion/references/apps.md +37 -0
- package/skills/creative-motion/references/gotchas.md +80 -0
- package/skills/creative-motion/references/native-layers.md +60 -0
- package/skills/creative-motion/references/quality.md +54 -0
- package/src/__tests__/buildKit.test.ts +127 -0
- package/src/__tests__/effectKnobs.test.ts +162 -0
- package/src/__tests__/nativeLayers.test.ts +178 -0
- package/src/buildKit.d.ts +301 -0
- package/src/buildKit.d.ts.map +1 -0
- package/src/buildKit.js +559 -0
- package/src/buildKit.js.map +1 -0
- package/src/buildKit.ts +520 -0
- package/src/compiler.d.ts +4 -0
- package/src/compiler.d.ts.map +1 -1
- package/src/compiler.js +21 -45
- package/src/compiler.js.map +1 -1
- package/src/compiler.ts +22 -51
- package/src/critique.d.ts +8 -0
- package/src/critique.d.ts.map +1 -0
- package/src/critique.js +348 -0
- package/src/critique.js.map +1 -0
- package/src/critique.ts +239 -0
- package/src/effectKnobs.d.ts +72 -0
- package/src/effectKnobs.d.ts.map +1 -0
- package/src/effectKnobs.js +541 -0
- package/src/effectKnobs.js.map +1 -0
- package/src/effectKnobs.ts +445 -0
- package/src/effectOptimizer.d.ts +18 -0
- package/src/effectOptimizer.d.ts.map +1 -0
- package/src/effectOptimizer.js +125 -0
- package/src/effectOptimizer.js.map +1 -0
- package/src/effectOptimizer.ts +104 -0
- package/src/engine/layout.js +1 -1
- package/src/engine/layout.js.map +1 -1
- package/src/engine/layout.ts +1 -1
- package/src/examples.d.ts +30 -0
- package/src/examples.d.ts.map +1 -0
- package/src/examples.js +168 -0
- package/src/examples.js.map +1 -0
- package/src/examples.ts +151 -0
- package/src/handlers/artboardHandlers.d.ts.map +1 -1
- package/src/handlers/artboardHandlers.js +45 -10
- package/src/handlers/artboardHandlers.js.map +1 -1
- package/src/handlers/artboardHandlers.ts +43 -12
- package/src/handlers/buildHandlers.d.ts +2 -0
- package/src/handlers/buildHandlers.d.ts.map +1 -0
- package/src/handlers/buildHandlers.js +86 -0
- package/src/handlers/buildHandlers.js.map +1 -0
- package/src/handlers/buildHandlers.ts +76 -0
- package/src/handlers/compilerHandlers.d.ts.map +1 -1
- package/src/handlers/compilerHandlers.js +32 -2
- package/src/handlers/compilerHandlers.js.map +1 -1
- package/src/handlers/compilerHandlers.ts +31 -2
- package/src/handlers/exampleHandlers.d.ts +2 -0
- package/src/handlers/exampleHandlers.d.ts.map +1 -0
- package/src/handlers/exampleHandlers.js +81 -0
- package/src/handlers/exampleHandlers.js.map +1 -0
- package/src/handlers/exampleHandlers.ts +76 -0
- package/src/handlers/renderHandlers.d.ts.map +1 -1
- package/src/handlers/renderHandlers.js +100 -2
- package/src/handlers/renderHandlers.js.map +1 -1
- package/src/handlers/renderHandlers.ts +90 -2
- package/src/handlers/scaffoldHandlers.d.ts.map +1 -1
- package/src/handlers/scaffoldHandlers.js +3 -0
- package/src/handlers/scaffoldHandlers.js.map +1 -1
- package/src/handlers/scaffoldHandlers.ts +2 -0
- package/src/handlers/widgetHandlers.js +1 -1
- package/src/handlers/widgetHandlers.js.map +1 -1
- package/src/handlers/widgetHandlers.ts +1 -1
- package/src/lottie/convert.d.ts +16 -0
- package/src/lottie/convert.d.ts.map +1 -0
- package/src/lottie/convert.js +1225 -0
- package/src/lottie/convert.js.map +1 -0
- package/src/lottie/convert.ts +1134 -0
- package/src/lottie/evaluate.d.ts +48 -0
- package/src/lottie/evaluate.d.ts.map +1 -0
- package/src/lottie/evaluate.js +174 -0
- package/src/lottie/evaluate.js.map +1 -0
- package/src/lottie/evaluate.ts +184 -0
- package/src/nativeLayers.d.ts +76 -0
- package/src/nativeLayers.d.ts.map +1 -0
- package/src/nativeLayers.js +404 -0
- package/src/nativeLayers.js.map +1 -0
- package/src/nativeLayers.ts +339 -0
- package/src/render/motionBrief.d.ts.map +1 -1
- package/src/render/motionBrief.js +4 -0
- package/src/render/motionBrief.js.map +1 -1
- package/src/render/motionBrief.ts +4 -0
- package/src/render/videoRenderer.d.ts.map +1 -1
- package/src/render/videoRenderer.js +5 -2
- package/src/render/videoRenderer.js.map +1 -1
- package/src/render/videoRenderer.ts +5 -2
- package/src/rive/convert.d.ts +17 -0
- package/src/rive/convert.d.ts.map +1 -0
- package/src/rive/convert.js +1779 -0
- package/src/rive/convert.js.map +1 -0
- package/src/rive/convert.ts +1492 -0
- package/src/rive/font.d.ts +13 -0
- package/src/rive/font.d.ts.map +1 -0
- package/src/rive/font.js +154 -0
- package/src/rive/font.js.map +1 -0
- package/src/rive/font.ts +132 -0
- package/src/rive/layout.d.ts +20 -0
- package/src/rive/layout.d.ts.map +1 -0
- package/src/rive/layout.js +145 -0
- package/src/rive/layout.js.map +1 -0
- package/src/rive/layout.ts +140 -0
- package/src/rive/reader.d.ts +32 -0
- package/src/rive/reader.d.ts.map +1 -0
- package/src/rive/reader.js +172 -0
- package/src/rive/reader.js.map +1 -0
- package/src/rive/reader.ts +160 -0
- package/src/rive/schema.generated.d.ts +9 -0
- package/src/rive/schema.generated.d.ts.map +1 -0
- package/src/rive/schema.generated.js +13 -0
- package/src/rive/schema.generated.js.map +1 -0
- package/src/rive/schema.generated.ts +13 -0
- package/src/schema.d.ts +5 -0
- package/src/schema.d.ts.map +1 -1
- package/src/schema.js +5 -0
- package/src/schema.js.map +1 -1
- package/src/schema.ts +6 -0
- package/src/serverInstructions.d.ts +2 -0
- package/src/serverInstructions.d.ts.map +1 -0
- package/src/serverInstructions.js +22 -0
- package/src/serverInstructions.js.map +1 -0
- package/src/serverInstructions.ts +21 -0
- package/src/sseServer.d.ts +2 -0
- package/src/sseServer.d.ts.map +1 -0
- package/src/sseServer.js +165 -0
- package/src/sseServer.js.map +1 -0
- package/src/sseServer.ts +189 -0
- package/src/utils.d.ts.map +1 -1
- package/src/utils.js +23 -1
- package/src/utils.js.map +1 -1
- package/src/utils.ts +13 -1
- package/src/widgets.d.ts +26 -0
- package/src/widgets.d.ts.map +1 -1
- package/src/widgets.js +89 -45
- package/src/widgets.js.map +1 -1
- package/src/widgets.ts +88 -45
package/src/critique.ts
ADDED
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
// critique_artboard: the design and runtime review an experienced Exode
|
|
2
|
+
// author does by eye, as static checks. Each issue says what to change.
|
|
3
|
+
import { estimateTextWidth } from './buildKit.js';
|
|
4
|
+
|
|
5
|
+
export interface Issue { severity: 'error' | 'warn' | 'tip'; code: string; message: string }
|
|
6
|
+
|
|
7
|
+
const STOCK = new Set(['#3b82f6', '#2563eb', '#1d4ed8', '#60a5fa', '#cbd5e1', '#94a3b8', '#e5e7eb', '#9ca3af', '#6b7280', '#111827', '#374151', '#ff0000', '#00ff00', '#0000ff', '#ffff00', '#ff00ff', '#00ffff']);
|
|
8
|
+
const GENERIC_NAME = /^(rectangle|ellipse|text|path|shape|group|frame|image|svg|layer|object|copy|untitled)[\s_-]*\d*$/i;
|
|
9
|
+
|
|
10
|
+
function rgb(c: string): number[] | null {
|
|
11
|
+
if (typeof c !== 'string') return null;
|
|
12
|
+
const m = c.trim().match(/^#([0-9a-f]{3}|[0-9a-f]{6})$/i);
|
|
13
|
+
if (m) { let h = m[1]!; if (h.length === 3) h = h.split('').map((x) => x + x).join(''); return [0, 2, 4].map((i) => parseInt(h.slice(i, i + 2), 16)); }
|
|
14
|
+
const r = c.match(/rgba?\(([^)]+)\)/i); if (r) return r[1]!.split(',').slice(0, 3).map((v) => parseFloat(v));
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
const lum = (c: number[]) => { const f = (v: number) => { v /= 255; return v <= 0.03928 ? v / 12.92 : Math.pow((v + 0.055) / 1.055, 2.4); }; return 0.2126 * f(c[0]!) + 0.7152 * f(c[1]!) + 0.0722 * f(c[2]!); };
|
|
18
|
+
const contrast = (a: number[], b: number[]) => { const [x, y] = [lum(a), lum(b)].sort((p, q) => q - p); return (x! + 0.05) / (y! + 0.05); };
|
|
19
|
+
const sat = (c: number[]) => { const mx = Math.max(...c), mn = Math.min(...c); return mx === 0 ? 0 : (mx - mn) / mx; };
|
|
20
|
+
|
|
21
|
+
/** Absolute centre and size of every object (children are relative to their parent). */
|
|
22
|
+
function absolute(objects: any[]) {
|
|
23
|
+
const byId = new Map(objects.map((o) => [o.id, o]));
|
|
24
|
+
const memo = new Map<string, { x: number; y: number; w: number; h: number }>();
|
|
25
|
+
const box = (o: any): { x: number; y: number; w: number; h: number } => {
|
|
26
|
+
if (memo.has(o.id)) return memo.get(o.id)!;
|
|
27
|
+
const g = o.geometry || {};
|
|
28
|
+
const sx = Math.abs(o.transform?.scale_x ?? 1), sy = Math.abs(o.transform?.scale_y ?? 1);
|
|
29
|
+
const w = (g.width ?? o.width ?? 0) * sx, h = (g.height ?? o.height ?? 0) * sy;
|
|
30
|
+
let x = o.transform?.x ?? 0, y = o.transform?.y ?? 0;
|
|
31
|
+
const p = o.parentId ? byId.get(o.parentId) : undefined;
|
|
32
|
+
if (p && p.type !== 'Bone') { const pb = box(p); x += pb.x; y += pb.y; }
|
|
33
|
+
const r = { x, y, w, h }; memo.set(o.id, r); return r;
|
|
34
|
+
};
|
|
35
|
+
return box;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function critiqueArtboard(ab: any): Issue[] {
|
|
39
|
+
const issues: Issue[] = [];
|
|
40
|
+
const add = (severity: Issue['severity'], code: string, message: string) => issues.push({ severity, code, message });
|
|
41
|
+
const objects: any[] = ab.objects || [];
|
|
42
|
+
const W = ab.width || 0, H = ab.height || 0;
|
|
43
|
+
const box = absolute(objects);
|
|
44
|
+
const bg = rgb(ab.backgroundColor) || [0, 0, 0];
|
|
45
|
+
const texts = objects.filter((o) => o.geometry?.type === 'Text' && o.isVisible !== false);
|
|
46
|
+
const anims: any[] = ab.animations || [];
|
|
47
|
+
const sm = ab.stateMachine || { inputs: [], layers: [] };
|
|
48
|
+
|
|
49
|
+
// ── naming ──
|
|
50
|
+
const unnamed = objects.filter((o) => !o.name || GENERIC_NAME.test(o.name));
|
|
51
|
+
if (unnamed.length) add('warn', 'unnamed-layers', `${unnamed.length} layer(s) have generic names (${unnamed.slice(0, 5).map((o) => `"${o.name || o.id}"`).join(', ')}). Name each by purpose ("Hero title", "Card / price") so the file reads in the editor.`);
|
|
52
|
+
|
|
53
|
+
// ── colour ──
|
|
54
|
+
const colours = new Map<string, number>();
|
|
55
|
+
const note = (c: any) => { if (typeof c === 'string' && rgb(c)) colours.set(c.toLowerCase(), (colours.get(c.toLowerCase()) || 0) + 1); };
|
|
56
|
+
for (const o of objects) { note(o.style?.fill?.color); (o.style?.fill?.stops || []).forEach((s: any) => note(s.color)); if (o.style?.stroke?.width) note(o.style?.stroke?.color); }
|
|
57
|
+
note(ab.backgroundColor);
|
|
58
|
+
const stock = [...colours.keys()].filter((c) => STOCK.has(c));
|
|
59
|
+
if (stock.length) add('warn', 'stock-colours', `Stock/default colours ${stock.join(', ')} make it look generated. Pick a deliberate palette (build_from_script: exode.palette('obsidian' | 'paper' | …)) or the user's brand colours.`);
|
|
60
|
+
const vivid = [...colours.keys()].map(rgb).filter((c) => c && sat(c) > 0.35);
|
|
61
|
+
const vividHues = new Set(vivid.map((c) => { const [r, g, b] = c!; const mx = Math.max(r!, g!, b!); return mx === r ? 'r' + Math.round(g! / 64) : mx === g ? 'g' + Math.round(b! / 64) : 'b' + Math.round(r! / 64); }));
|
|
62
|
+
if (vividHues.size > 4) add('tip', 'palette-discipline', `${vividHues.size} different saturated hues. Premium work uses one neutral ramp plus one or two accents (~10% of the surface).`);
|
|
63
|
+
|
|
64
|
+
// ── typography ──
|
|
65
|
+
const families = new Set(texts.map((t) => t.geometry.fontFamily));
|
|
66
|
+
if (families.size > 2) add('tip', 'too-many-fonts', `${families.size} font families (${[...families].join(', ')}). Use one, two at most.`);
|
|
67
|
+
for (const t of texts) {
|
|
68
|
+
const g = t.geometry;
|
|
69
|
+
if (/[,"']/.test(String(g.fontFamily || ''))) add('error', 'font-family', `"${t.name}": fontFamily "${g.fontFamily}" must be ONE unquoted family (e.g. Inter). Lists and quotes render as fallback sans or 10px.`);
|
|
70
|
+
if ((g.fontSize ?? 16) < 10) add('warn', 'tiny-text', `"${t.name}" is ${g.fontSize}px; under 10px is unreadable on most screens.`);
|
|
71
|
+
const need = estimateTextWidth(g.text ?? '', g.fontSize ?? 16, g.letterSpacing ?? 0);
|
|
72
|
+
if (g.width && need > g.width * 1.15) {
|
|
73
|
+
/* text wraps at its box width; the risk is the wrapped block outgrowing its box height and running into neighbours */
|
|
74
|
+
const lines = String(g.text ?? '').split('\n').reduce((n, l) => n + Math.max(1, Math.ceil(estimateTextWidth(l, g.fontSize ?? 16, g.letterSpacing ?? 0) / g.width)), 0);
|
|
75
|
+
const needH = lines * (g.fontSize ?? 16) * (g.lineHeight ?? 1.2);
|
|
76
|
+
if (g.height && needH > g.height * 1.25) add('warn', 'text-overflow', `"${t.name}" wraps to ~${lines} lines (~${Math.round(needH)}px) in a ${Math.round(g.height)}px-tall box, so it spills into its neighbours. Set its height (h) or widen it.`);
|
|
77
|
+
}
|
|
78
|
+
const b = box(t);
|
|
79
|
+
/* straddling an edge is a layout slip; text parked entirely outside is deliberate */
|
|
80
|
+
const inside = W && H && b.x + b.w / 2 > 0 && b.x - b.w / 2 < W && b.y + b.h / 2 > 0 && b.y - b.h / 2 < H;
|
|
81
|
+
if (inside && (b.x - b.w / 2 < -2 || b.x + b.w / 2 > W + 2 || b.y - b.h / 2 < -2 || b.y + b.h / 2 > H + 2) && (t.transform?.opacity ?? 1) > 0) add('warn', 'text-off-artboard', `"${t.name}" is cut by the artboard edge.`);
|
|
82
|
+
// contrast against the topmost opaque rectangle behind it, else the background
|
|
83
|
+
const tc = rgb(t.style?.fill?.color);
|
|
84
|
+
const driven = (t.style?.effects || []).some((e: any) => e.type === 'CustomEffect') || anims.some((a) => (a.tracks || []).some((k: any) => k.object_id === t.id && /fill|color/.test(k.property)));
|
|
85
|
+
if (tc && !driven) {
|
|
86
|
+
let behind = bg;
|
|
87
|
+
for (const o of objects) {
|
|
88
|
+
if (o === t || (o.zIndex ?? 0) >= (t.zIndex ?? 0) || o.geometry?.type !== 'Rectangle' || (o.physics?.enabled && o.physics.bodyType !== 'Static') || (o.style?.effects || []).some((e: any) => e.type === 'CustomEffect' && e.isEnabled !== false)) continue;
|
|
89
|
+
const f = o.style?.fill; if (f?.type !== 'Solid' || (f.opacity ?? 1) < 0.85 || (o.transform?.opacity ?? 1) < 0.85) continue;
|
|
90
|
+
const ob = box(o); if (Math.abs(ob.x - b.x) < ob.w / 2 && Math.abs(ob.y - b.y) < ob.h / 2) { const c = rgb(f.color); if (c) behind = c; }
|
|
91
|
+
}
|
|
92
|
+
/* muted secondary text is fine down to ~3:1; ~1:1 means a deliberate overlay or knock-out, not a mistake */
|
|
93
|
+
const ratio = contrast(tc, behind), need2 = (g.fontSize ?? 16) >= 24 ? 2 : 3;
|
|
94
|
+
if (ratio < need2 && ratio > 1.15) add('warn', 'low-contrast', `"${t.name}" contrast ${ratio.toFixed(1)}:1 against its background is hard to read at ${g.fontSize}px (aim for 4.5:1 body, 3:1 large or muted).`);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
// overlapping text (stacked captions read as a pile in the editor)
|
|
98
|
+
const roots = texts.filter((t) => !t.parentId || objects.find((o) => o.id === t.parentId)?.type !== 'Bone');
|
|
99
|
+
let overlaps = 0; const pairs: string[] = [];
|
|
100
|
+
for (let i = 0; i < roots.length; i++) for (let j = i + 1; j < roots.length; j++) {
|
|
101
|
+
const a = box(roots[i]), c = box(roots[j]);
|
|
102
|
+
const ix = Math.min(a.x + a.w / 2, c.x + c.w / 2) - Math.max(a.x - a.w / 2, c.x - c.w / 2);
|
|
103
|
+
const iy = Math.min(a.y + a.h / 2, c.y + c.h / 2) - Math.max(a.y - a.h / 2, c.y - c.h / 2);
|
|
104
|
+
/* only siblings: stacked cards and slides overlap on purpose */
|
|
105
|
+
if ((roots[i].parentId || '') !== (roots[j].parentId || '')) continue;
|
|
106
|
+
if (ix > 0 && iy > 0 && ix * iy > 0.3 * Math.min(a.w * a.h, c.w * c.h)) { overlaps++; if (pairs.length < 3) pairs.push(`"${roots[i].name}" × "${roots[j].name}"`); }
|
|
107
|
+
}
|
|
108
|
+
if (overlaps) add('warn', 'text-overlap', `${overlaps} pair(s) of text boxes overlap (${pairs.join(', ')}). If they are alternates, reuse one Text and keyframe its text; otherwise fix the layout.`);
|
|
109
|
+
|
|
110
|
+
// ── opacity / keyframes ──
|
|
111
|
+
/* values above 1 are percentages (100 = full); only 1 < v < 5 is the overshoot bug (1.2 → 1.2%) */
|
|
112
|
+
const over = (v: any) => typeof v === 'number' && v > 1 && v < 5;
|
|
113
|
+
const overObjs = objects.filter((o) => over(o.transform?.opacity) || over(o.style?.fill?.opacity));
|
|
114
|
+
if (overObjs.length) add('error', 'opacity-over-1', `${overObjs.length} object(s) have opacity just above 1 (${overObjs.slice(0, 4).map((o) => `"${o.name}"`).join(', ')}), read as a percentage (1.2 → 1.2%). Use ≤ 1.`);
|
|
115
|
+
for (const a of anims) for (const tr of a.tracks || []) {
|
|
116
|
+
const ks = tr.keyframes || [];
|
|
117
|
+
if (/opacity$/.test(tr.property) && ks.some((k: any) => over(k.value))) add('error', 'opacity-over-1', `Animation "${a.name}" keys ${tr.property} above 1 (read as a percentage).`);
|
|
118
|
+
if (tr.property === 'geometry.text') for (let i = 1; i < ks.length; i++) {
|
|
119
|
+
const p = String(ks[i - 1].value), q = String(ks[i].value);
|
|
120
|
+
if (/^\d/.test(p) && /^\d/.test(q) && ks[i].time - ks[i - 1].time > 0.002 && p !== q && /\D/.test(p + q)) { add('warn', 'text-number-interp', `Animation "${a.name}": text "${p}" → "${q}" both start with a digit and interpolate as numbers. Hold the old value until 0.001 s before the swap.`); break; }
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
const allLinear = anims.length && anims.every((a) => (a.tracks || []).every((t: any) => (t.keyframes || []).every((k: any) => !k.easing || k.easing === 'linear')));
|
|
124
|
+
if (allLinear) add('tip', 'linear-motion', 'Every keyframe is linear. Use one signature easing (e.g. easeOutCubic for entrances, easeInOutSine for loops).');
|
|
125
|
+
|
|
126
|
+
// ── state machine wiring and ownership ──
|
|
127
|
+
const layers: any[] = sm.layers || [];
|
|
128
|
+
const played = new Set(layers.flatMap((l) => (l.states || []).map((s: any) => s.animationId)).filter(Boolean));
|
|
129
|
+
/* interactions can play animations directly ("Play Animation" → targetAnimationId) */
|
|
130
|
+
for (const o of objects) for (const ix of (o.interactions || [])) for (const k of ['targetAnimationId', 'animationId']) if (ix[k]) played.add(ix[k]);
|
|
131
|
+
const orphan = anims.filter((a) => !played.has(a.id) && (a.tracks || []).length);
|
|
132
|
+
if (orphan.length && layers.length) add('warn', 'unwired-animations', `${orphan.length} animation(s) never play (no state points at them): ${orphan.slice(0, 5).map((a) => `"${a.name}"`).join(', ')}.`);
|
|
133
|
+
if (anims.some((a) => (a.tracks || []).length) && !layers.length) add('error', 'no-state-machine', 'Animations exist but no state machine layer plays them, so the file renders static. Add a layer with a state per animation.');
|
|
134
|
+
const owner = new Map<string, string>(); const fights = new Set<string>();
|
|
135
|
+
const animById = new Map(anims.map((a) => [a.id, a]));
|
|
136
|
+
for (const l of layers) for (const s of l.states || []) for (const tr of (animById.get(s.animationId)?.tracks || [])) {
|
|
137
|
+
const k = `${tr.object_id}|${tr.property}`; const prev = owner.get(k);
|
|
138
|
+
if (prev && prev !== l.name) fights.add(`${objects.find((o) => o.id === tr.object_id)?.name || tr.object_id} ${tr.property} (${prev} vs ${l.name})`); else owner.set(k, l.name);
|
|
139
|
+
}
|
|
140
|
+
if (fights.size) add('warn', 'property-fight', `Two layers write the same property: ${[...fights].slice(0, 4).join('; ')}. Give each property one owner (animate a parent group instead).`);
|
|
141
|
+
for (const l of layers) for (const s of l.states || []) for (const t of s.transitions || []) if (!(t.conditions || []).length) add('error', 'empty-transition', `Layer "${l.name}", state "${s.name}": a transition with no conditions fires every frame.`);
|
|
142
|
+
|
|
143
|
+
// ── interaction ──
|
|
144
|
+
const interactive = objects.filter((o) => (o.interactions || []).length || o.type === 'Widget' || o.behaviors?.length);
|
|
145
|
+
const navObjs = new Set((ab.navigation || []).map((n: any) => n.objectId));
|
|
146
|
+
const looksClickable = objects.filter((o) => /(\b|_)(button|btn|cta)(\b|_)/i.test(o.name || '') && o.geometry?.type !== 'Text' && !navObjs.has(o.id));
|
|
147
|
+
const live = objects.filter((o) => (o.interactions || []).length || navObjs.has(o.id));
|
|
148
|
+
const covered = (o: any) => { const b = box(o); return live.some((h) => { if (h === o) return false; const hb = box(h); return Math.abs(hb.x - b.x) <= hb.w / 2 && Math.abs(hb.y - b.y) <= hb.h / 2; }); };
|
|
149
|
+
const dead = looksClickable.filter((o) => !(o.interactions || []).length && o.type !== 'Widget' && !covered(o));
|
|
150
|
+
if (dead.length) add('warn', 'dead-controls', `${dead.length} control(s) don't respond to hover or press: ${dead.slice(0, 5).map((o) => `"${o.name}"`).join(', ')}. Every interactive object answers hover AND press (build_from_script: d.interactive(obj)).`);
|
|
151
|
+
if (!interactive.length && !(sm.inputs || []).length && objects.length > 6) add('tip', 'no-customisation', 'No inputs and no interactions. Expose what a user would change (copy, key colours, speed) as inputs, and make controls respond.');
|
|
152
|
+
|
|
153
|
+
// ── gradients ──
|
|
154
|
+
for (const o of objects) for (const st of (o.style?.fill?.stops || [])) if (typeof st.color === 'string' && !st.color.startsWith('#')) { add('error', 'gradient-stop-colour', `"${o.name}": gradient stop "${st.color}" is not hex. The runtime paints non-hex stops white; use hex plus the stop's opacity.`); break; }
|
|
155
|
+
|
|
156
|
+
// hard-edged glows: a radial fill still visible where the shape's short side clips it
|
|
157
|
+
for (const o of objects) {
|
|
158
|
+
const f = o.style?.fill; if (f?.type !== 'RadialGradient' || !f.stops?.length) continue;
|
|
159
|
+
const w = o.geometry?.width ?? o.width ?? 0, h = o.geometry?.height ?? o.height ?? 0; if (!w || !h) continue;
|
|
160
|
+
const last = f.stops[f.stops.length - 1]; const lastA = last.opacity === undefined ? 1 : last.opacity > 1 ? last.opacity / 100 : last.opacity;
|
|
161
|
+
const reach = (f.radius ?? 0.5) * Math.max(w, h), cx = (f.center?.[0] ?? f.center?.x ?? 0.5), cy = (f.center?.[1] ?? f.center?.y ?? 0.5);
|
|
162
|
+
const nearest = Math.min(cx * w, (1 - cx) * w, cy * h, (1 - cy) * h);
|
|
163
|
+
const glowLike = o.geometry?.type === 'Ellipse';
|
|
164
|
+
if (glowLike && reach > nearest * 1.08 && (lastA > 0.05 || reach * 0.75 > nearest)) add('warn', 'hard-edge-glow', `"${o.name}": its radial gradient is still visible where the shape's edge cuts it, so the glow shows a hard ${o.geometry?.type === 'Ellipse' ? 'oval' : 'box'} edge. Make it a circle (w = h) and stretch with scale_y, keep radius ≤ 0.5, and fade the last stop to opacity 0.`);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// dead time: long stretches where nothing moves (looping layers count as motion)
|
|
168
|
+
const loops = layers.some((l) => (l.states || []).some((s: any) => s.loop && (animById.get(s.animationId)?.tracks || []).length));
|
|
169
|
+
const timed = anims.filter((a) => !a.loop && (a.tracks || []).length);
|
|
170
|
+
if (timed.length && !loops) {
|
|
171
|
+
const total = Math.max(...timed.map((a) => a.duration || 0));
|
|
172
|
+
const spans: [number, number][] = [];
|
|
173
|
+
for (const a of timed) for (const tr of a.tracks) { const ks = [...(tr.keyframes || [])].sort((p: any, q: any) => p.time - q.time); for (let i = 1; i < ks.length; i++) if (JSON.stringify(ks[i].value) !== JSON.stringify(ks[i - 1].value)) spans.push([ks[i - 1].time, ks[i].time]); }
|
|
174
|
+
spans.sort((p, q) => p[0] - q[0]);
|
|
175
|
+
let gap = 0, gapAt = 0, cur = 0;
|
|
176
|
+
for (const [a, b] of spans) { if (a - cur > gap) { gap = a - cur; gapAt = cur; } cur = Math.max(cur, b); }
|
|
177
|
+
if (total - cur > gap) { gap = total - cur; gapAt = cur; }
|
|
178
|
+
if (total >= 3 && gap >= Math.max(1.5, total * 0.3)) add('warn', 'dead-time', `Nothing moves from ${gapAt.toFixed(1)}s to ${(gapAt + gap).toFixed(1)}s (${Math.round((gap / total) * 100)}% of the piece). Holds should breathe: add a slow ambient loop (light drift, glow pulse, grain, a 1–2% scale push) or a secondary beat (tagline, detail, texture).`);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
if (ab.physics?.enabled) {
|
|
182
|
+
const implicit = objects.filter((o) => !o.physics && o.type === 'Shape');
|
|
183
|
+
if (implicit.length) add('error', 'implicit-bodies', `Scene physics is on and ${implicit.length} shape(s) have no physics block (${implicit.slice(0, 4).map((o) => `"${o.name}"`).join(', ')}): the runtime makes them dynamic bodies, so they fall. Set physics: { enabled: false } on everything that isn't meant to move.`);
|
|
184
|
+
}
|
|
185
|
+
const dyn = objects.filter((o) => o.physics?.enabled && o.physics.bodyType !== 'Static');
|
|
186
|
+
if (dyn.length) {
|
|
187
|
+
const g = ab.physics?.gravity || { x: 0, y: 0 };
|
|
188
|
+
if (!ab.physics?.enabled) add('error', 'physics-off', `${dyn.length} dynamic bodies but artboard physics is disabled; nothing will move.`);
|
|
189
|
+
else if (!g.x && !g.y && !objects.some((o) => (o.style?.effects || []).some((e: any) => /update\s*\(/.test(e.code || ''))) && !dyn.some((o) => o.behaviors?.length)) add('warn', 'physics-inert', 'Dynamic bodies with zero gravity, no draggable behaviour and no update() effect: nothing in the file sets them moving (host page JavaScript would be needed). Give gravity a value or drive forces in an update(env, dt) effect.');
|
|
190
|
+
const bouncy = dyn.filter((o) => (o.physics.restitution ?? 0) > 0.7);
|
|
191
|
+
if (bouncy.length) add('tip', 'physics-bouncy', `${bouncy.length} body/bodies with restitution > 0.7 bounce forever and read as toy-like. 0.1–0.4 lands with weight.`);
|
|
192
|
+
if (!objects.some((o) => o.physics?.bodyType === 'Static') && !ab.physics?.collideWithBounds) add('warn', 'physics-no-floor', 'Dynamic bodies but no static floor or walls: they will fall off the artboard.');
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// ── effect code ──
|
|
196
|
+
for (const o of objects) for (const e of (o.style?.effects || [])) {
|
|
197
|
+
if (e.type !== 'CustomEffect' || !e.code) continue;
|
|
198
|
+
if (/(^|[^:"'*])\/\/(?!.*\*\/)/m.test(e.code.replace(/(["'`])(?:\\.|(?!\1).)*\1/g, '""'))) add('warn', 'effect-line-comment', `Effect on "${o.name}" uses // comments; the .bexode minifier collapses lines, so use /* */ only.`);
|
|
199
|
+
/* a random per-engine key (engineKey) is meant to be random; only flag randomness used for drawing or logic */
|
|
200
|
+
if (/Math\.random\(/.test(e.code.replace(/^.*engineKey.*$/gm, '').replace(/function NK_engine[\s\S]*?\n\}/g, ''))) add('tip', 'effect-random', `Effect on "${o.name}" uses Math.random(); seed it (env.time-based or a seeded PRNG) so renders are deterministic.`);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// content spilling out of (or jammed against) the card it sits in, through any depth of nesting
|
|
204
|
+
const byIdC = new Map(objects.map((o) => [o.id, o]));
|
|
205
|
+
const isCard = (p: any) => p && p.geometry?.type === 'Rectangle' && p.type !== 'Group' && p.style?.fill && p.style.fill.type !== 'None' && (p.style.fill.opacity ?? 1) >= 0.05;
|
|
206
|
+
const cardOf = (o: any) => { let p = o.parentId ? byIdC.get(o.parentId) : null; while (p) { if (isCard(p)) return p; p = p.parentId ? byIdC.get(p.parentId) : null; } return null; };
|
|
207
|
+
const spills: string[] = [], tight: string[] = [];
|
|
208
|
+
for (const o of objects) {
|
|
209
|
+
if (o.geometry?.type === 'Text' || o.physics?.enabled || !o.geometry?.width) continue;
|
|
210
|
+
const card = cardOf(o); if (!card) continue;
|
|
211
|
+
const c = box(o), b = box(card), sw = o.style?.stroke?.width && o.style.stroke.color !== 'transparent' ? o.style.stroke.width / 2 : 0;
|
|
212
|
+
if (c.w >= b.w * 0.9 || c.h >= b.h * 0.9) continue; /* full-bleed layers (dividers, media) are deliberate */
|
|
213
|
+
const inside = c.x > b.x - b.w / 2 && c.x < b.x + b.w / 2 && c.y > b.y - b.h / 2 && c.y < b.y + b.h / 2; if (!inside) continue;
|
|
214
|
+
const pad = Math.min(c.x - c.w / 2 - sw - (b.x - b.w / 2), b.x + b.w / 2 - (c.x + c.w / 2 + sw), c.y - c.h / 2 - sw - (b.y - b.h / 2), b.y + b.h / 2 - (c.y + c.h / 2 + sw));
|
|
215
|
+
if (pad < -2) spills.push(`"${o.name}" in "${card.name}"`); else if (pad < 12 && c.w * c.h > 2500) tight.push(`"${o.name}" (${Math.max(0, Math.round(pad))}px)`);
|
|
216
|
+
}
|
|
217
|
+
if (spills.length) add('warn', 'spills-out-of-card', `${spills.length} element(s) cross the edge of the card they sit in: ${spills.slice(0, 4).join(', ')}. Shrink or move them inside, with at least 24px padding.`);
|
|
218
|
+
if (tight.length) add('warn', 'cramped-card', `${tight.length} element(s) sit almost on their card's edge: ${tight.slice(0, 4).join(', ')} (strokes included). Premium cards keep 24px or more of padding.`);
|
|
219
|
+
|
|
220
|
+
// ── composition ──
|
|
221
|
+
if (W && H) {
|
|
222
|
+
const lost = objects.filter((o) => !o.parentId && o.geometry?.type !== 'Text' && !o.physics?.enabled && (o.transform?.opacity ?? 1) > 0 && o.isVisible !== false).filter((o) => {
|
|
223
|
+
const b = box(o); return b.w > 0 && (b.x + b.w / 2 < 0 || b.x - b.w / 2 > W || b.y + b.h / 2 < 0 || b.y - b.h / 2 > H);
|
|
224
|
+
});
|
|
225
|
+
if (lost.length) add('tip', 'off-artboard', `${lost.length} visible object(s) sit entirely outside the artboard (${lost.slice(0, 4).map((o) => `"${o.name}"`).join(', ')}). Fine for parked overlays; otherwise they're lost.`);
|
|
226
|
+
}
|
|
227
|
+
if (W && H && W < H && W < 500 && texts.length > 3) { /* mobile canvas: fine, nothing to say */ }
|
|
228
|
+
|
|
229
|
+
const rank = { error: 0, warn: 1, tip: 2 } as const;
|
|
230
|
+
return issues.sort((a, b) => rank[a.severity] - rank[b.severity]);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
export function formatIssues(issues: Issue[], limit = 20): string {
|
|
234
|
+
if (!issues.length) return 'Design check: no issues found. Still look at the frames (preview_frames) before calling it done.';
|
|
235
|
+
const icon = { error: '✖', warn: '▲', tip: '·' };
|
|
236
|
+
const lines = issues.slice(0, limit).map((i) => `${icon[i.severity]} [${i.code}] ${i.message}`);
|
|
237
|
+
const counts = (['error', 'warn', 'tip'] as const).map((s) => `${issues.filter((i) => i.severity === s).length} ${s}`).join(', ');
|
|
238
|
+
return `Design check (${counts}):\n${lines.join('\n')}${issues.length > limit ? `\n… ${issues.length - limit} more` : ''}`;
|
|
239
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lifts the tunable numbers out of CustomEffect code so they show up as parameters.
|
|
3
|
+
*
|
|
4
|
+
* The editor's Effects panel turns every top-level `var NAME = <number | colour | boolean>` into a
|
|
5
|
+
* control (slider, colour picker, toggle). Generated effects usually bury those values inside
|
|
6
|
+
* render()/update(): `ctx.lineWidth = 3.4`, `L.rgba(col, 0.75 * ax)`, `Math.sin(t * 2.4)`. This pass
|
|
7
|
+
* moves them to named top-level variables and puts the name where the number was, so the effect
|
|
8
|
+
* looks and behaves exactly the same until someone moves a slider.
|
|
9
|
+
*
|
|
10
|
+
* Only values with a clear meaning are lifted (nothing structural like indices, loop bounds or ids):
|
|
11
|
+
* - style assignments: x.lineWidth = 3.4 → WIDTH, x.globalAlpha → ALPHA, x.shadowBlur → BLUR,
|
|
12
|
+
* x.fillStyle / strokeStyle / shadowColor = '#5eeaff' → FILL / STROKE / SHADOW
|
|
13
|
+
* - time rates: t * 2.4, env.time * 0.35, dt * 2.6 → SPEED
|
|
14
|
+
* - colour opacity: a 0..1 factor multiplied inside an rgba()/hsla() call or a fill/stroke style
|
|
15
|
+
* expression → ALPHA
|
|
16
|
+
* Names come from the section comment above the code (`/* temple tank ripples *\/` → TEMPLE_TANK_RIPPLES_SPEED),
|
|
17
|
+
* else from the helper function's name. Running it twice changes nothing.
|
|
18
|
+
*/
|
|
19
|
+
export interface LiftedKnob {
|
|
20
|
+
name: string;
|
|
21
|
+
value: number | string;
|
|
22
|
+
count: number;
|
|
23
|
+
}
|
|
24
|
+
export interface LiftResult {
|
|
25
|
+
code: string;
|
|
26
|
+
knobs: LiftedKnob[];
|
|
27
|
+
changed: boolean;
|
|
28
|
+
reason?: string;
|
|
29
|
+
}
|
|
30
|
+
/** Effects that must stay as written: shared libraries, group mirrors, code with no entry point. */
|
|
31
|
+
export declare function liftable(code: string): string | null;
|
|
32
|
+
export declare function liftEffectKnobs(code: string): LiftResult;
|
|
33
|
+
/** Shared multi-part app/game scripts (the apps-topic convention: `var GAME = { part: 'world' };` + one script
|
|
34
|
+
* copied into several layers). Lifting their numbers would mint the same knobs once per layer, as
|
|
35
|
+
* meaningless inputs (riverSpeed, rocksSpeed2, …), so these are left as written. */
|
|
36
|
+
export declare function isSharedPartScript(code: string): boolean;
|
|
37
|
+
/** Lifts knobs in every CustomEffect of an artboard or multi-screen document, in place. */
|
|
38
|
+
export declare function liftKnobsInDoc(doc: any): {
|
|
39
|
+
effects: number;
|
|
40
|
+
changed: number;
|
|
41
|
+
knobs: number;
|
|
42
|
+
lines: string[];
|
|
43
|
+
};
|
|
44
|
+
export interface CodeSetting {
|
|
45
|
+
name: string;
|
|
46
|
+
value: number | string | boolean;
|
|
47
|
+
}
|
|
48
|
+
/** Top-level `var NAME = <number | colour string | boolean>` declarations: what the editor shows as parameters. */
|
|
49
|
+
export declare function topLevelSettings(code: string): CodeSetting[];
|
|
50
|
+
/** Writes the binding block for `binds` (setting → input name); with none, removes it. */
|
|
51
|
+
export declare function bindEffectCode(code: string, binds: Array<{
|
|
52
|
+
name: string;
|
|
53
|
+
input: string;
|
|
54
|
+
value: number | string | boolean;
|
|
55
|
+
}>): string;
|
|
56
|
+
/**
|
|
57
|
+
* Declares a state-machine input for every effect setting on one artboard (or screen) and binds the
|
|
58
|
+
* code to it. Input names: the setting in camelCase (bloomWidth), prefixed with the layer id when two
|
|
59
|
+
* effects would share a name (camMotionYawSpeed). Defaults follow the code's current values.
|
|
60
|
+
*/
|
|
61
|
+
export declare function bindKnobInputs(board: any): {
|
|
62
|
+
effects: number;
|
|
63
|
+
inputs: number;
|
|
64
|
+
lines: string[];
|
|
65
|
+
};
|
|
66
|
+
/** bindKnobInputs on an artboard or every screen of a multi-screen document. */
|
|
67
|
+
export declare function bindKnobsInDoc(doc: any): {
|
|
68
|
+
effects: number;
|
|
69
|
+
inputs: number;
|
|
70
|
+
lines: string[];
|
|
71
|
+
};
|
|
72
|
+
//# sourceMappingURL=effectKnobs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"effectKnobs.d.ts","sourceRoot":"","sources":["effectKnobs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,MAAM,WAAW,UAAU;IAAG,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE;AACnF,MAAM,WAAW,UAAU;IAAG,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,UAAU,EAAE,CAAC;IAAC,OAAO,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE;AA0FpG,oGAAoG;AACpG,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAOpD;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAyIxD;AAGD;;qFAEqF;AACrF,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAExD;AAED,2FAA2F;AAC3F,wBAAgB,cAAc,CAAC,GAAG,EAAE,GAAG,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,EAAE,CAAA;CAAE,CAoB7G;AAYD,MAAM,WAAW,WAAW;IAAG,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAA;CAAE;AAE/E,mHAAmH;AACnH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,EAAE,CA6B5D;AAmBD,0FAA0F;AAC1F,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAA;CAAE,CAAC,GAAG,MAAM,CAyBpI;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,GAAG,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,EAAE,CAAA;CAAE,CAoD/F;AAED,gFAAgF;AAChF,wBAAgB,cAAc,CAAC,GAAG,EAAE,GAAG;;;WAEa,MAAM,EAAE;EAG3D"}
|