foundry-design 0.2.0-beta.1
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/LICENSE +21 -0
- package/README.md +98 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +449 -0
- package/dist/index.js.map +1 -0
- package/dist/indexer.d.ts +4 -0
- package/dist/indexer.d.ts.map +1 -0
- package/dist/indexer.js +200 -0
- package/dist/indexer.js.map +1 -0
- package/dist/installer.d.ts +72 -0
- package/dist/installer.d.ts.map +1 -0
- package/dist/installer.js +458 -0
- package/dist/installer.js.map +1 -0
- package/dist/project.d.ts +4 -0
- package/dist/project.d.ts.map +1 -0
- package/dist/project.js +37 -0
- package/dist/project.js.map +1 -0
- package/package.json +46 -0
package/dist/indexer.js
ADDED
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { readFile, readdir, stat } from 'node:fs/promises';
|
|
3
|
+
import { basename, extname, join, relative } from 'node:path';
|
|
4
|
+
import { PROTOCOL_VERSION, projectDesignGraphSchema, } from 'foundry-design-protocol';
|
|
5
|
+
const SOURCE_EXTENSIONS = new Set([
|
|
6
|
+
'.css',
|
|
7
|
+
'.scss',
|
|
8
|
+
'.sass',
|
|
9
|
+
'.less',
|
|
10
|
+
'.ts',
|
|
11
|
+
'.tsx',
|
|
12
|
+
'.js',
|
|
13
|
+
'.jsx',
|
|
14
|
+
'.mjs',
|
|
15
|
+
'.cjs',
|
|
16
|
+
'.json',
|
|
17
|
+
]);
|
|
18
|
+
function stableId(prefix, value) {
|
|
19
|
+
return `${prefix}_${createHash('sha1').update(value).digest('hex').slice(0, 12)}`;
|
|
20
|
+
}
|
|
21
|
+
function lineAt(content, index) {
|
|
22
|
+
return content.slice(0, index).split('\n').length;
|
|
23
|
+
}
|
|
24
|
+
function tokenCategory(name, value) {
|
|
25
|
+
const hint = `${name} ${value}`.toLowerCase();
|
|
26
|
+
if (/color|background|foreground|#[0-9a-f]{3,8}|rgba?\(|oklch\(|hsl\(/.test(hint))
|
|
27
|
+
return 'color';
|
|
28
|
+
if (/radius|rounded/.test(hint))
|
|
29
|
+
return 'radius';
|
|
30
|
+
if (/shadow/.test(hint))
|
|
31
|
+
return 'shadow';
|
|
32
|
+
if (/duration|easing|transition|spring/.test(hint))
|
|
33
|
+
return 'motion';
|
|
34
|
+
if (/font|line-height|tracking|letter/.test(hint))
|
|
35
|
+
return 'typography';
|
|
36
|
+
if (/space|gap|padding|margin/.test(hint))
|
|
37
|
+
return 'spacing';
|
|
38
|
+
if (/width|height|size/.test(hint))
|
|
39
|
+
return 'size';
|
|
40
|
+
return 'other';
|
|
41
|
+
}
|
|
42
|
+
async function sourceFiles(root, exclusions) {
|
|
43
|
+
const files = [];
|
|
44
|
+
const excluded = new Set([
|
|
45
|
+
'.git',
|
|
46
|
+
'.foundry',
|
|
47
|
+
'node_modules',
|
|
48
|
+
'dist',
|
|
49
|
+
'build',
|
|
50
|
+
'.next',
|
|
51
|
+
...exclusions,
|
|
52
|
+
]);
|
|
53
|
+
async function visit(directory) {
|
|
54
|
+
if (files.length >= 6_000)
|
|
55
|
+
return;
|
|
56
|
+
for (const entry of await readdir(directory, { withFileTypes: true }).catch(() => [])) {
|
|
57
|
+
if (excluded.has(entry.name))
|
|
58
|
+
continue;
|
|
59
|
+
const path = join(directory, entry.name);
|
|
60
|
+
if (entry.isDirectory())
|
|
61
|
+
await visit(path);
|
|
62
|
+
else if (entry.isFile() && SOURCE_EXTENSIONS.has(extname(entry.name))) {
|
|
63
|
+
const info = await stat(path).catch(() => undefined);
|
|
64
|
+
if (info && info.size <= 750_000)
|
|
65
|
+
files.push(path);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
await visit(root);
|
|
70
|
+
return files;
|
|
71
|
+
}
|
|
72
|
+
export async function indexProjectDesign(root, config, revision) {
|
|
73
|
+
const files = await sourceFiles(root, config?.design?.exclude ?? []);
|
|
74
|
+
const tokens = new Map();
|
|
75
|
+
const components = new Map();
|
|
76
|
+
const breakpoints = new Map();
|
|
77
|
+
const themes = new Set();
|
|
78
|
+
const motion = new Map();
|
|
79
|
+
const storyVariants = new Map();
|
|
80
|
+
for (const path of files) {
|
|
81
|
+
const content = await readFile(path, 'utf8').catch(() => '');
|
|
82
|
+
const file = relative(root, path).replaceAll('\\', '/');
|
|
83
|
+
for (const match of content.matchAll(/(--[\w-]+)\s*:\s*([^;}\n]+)/g)) {
|
|
84
|
+
const name = match[1];
|
|
85
|
+
const value = match[2].trim();
|
|
86
|
+
tokens.set(name, {
|
|
87
|
+
id: stableId('tok', name),
|
|
88
|
+
name,
|
|
89
|
+
value,
|
|
90
|
+
category: tokenCategory(name, value),
|
|
91
|
+
cssVariable: name,
|
|
92
|
+
source: { file, line: lineAt(content, match.index ?? 0) },
|
|
93
|
+
confidence: 'instrumented',
|
|
94
|
+
evidence: ['CSS custom property'],
|
|
95
|
+
});
|
|
96
|
+
if (/duration|motion/.test(name)) {
|
|
97
|
+
const duration = /([\d.]+)m?s/.exec(value);
|
|
98
|
+
motion.set(name, {
|
|
99
|
+
id: stableId('mot', name),
|
|
100
|
+
label: name.replace(/^--/, ''),
|
|
101
|
+
duration: duration ? Number(duration[1]) * (value.includes('ms') ? 1 : 1000) : undefined,
|
|
102
|
+
source: { file, line: lineAt(content, match.index ?? 0) },
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
for (const match of content.matchAll(/@media\s*\([^)]*(?:min|max)-width\s*:\s*(\d+)px[^)]*\)/g)) {
|
|
107
|
+
const width = Number(match[1]);
|
|
108
|
+
breakpoints.set(width, {
|
|
109
|
+
width,
|
|
110
|
+
source: { file, line: lineAt(content, match.index ?? 0) },
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
for (const match of content.matchAll(/(?:data-theme=["']|\[data-theme=["'])([\w-]+)/g)) {
|
|
114
|
+
themes.add(match[1]);
|
|
115
|
+
}
|
|
116
|
+
if (/(?:^|\s)\.dark(?:\s|[{,:])/.test(content))
|
|
117
|
+
themes.add('dark');
|
|
118
|
+
if (/\.(?:tsx?|jsx?|mjs|cjs)$/.test(path)) {
|
|
119
|
+
if (/\.stories\.[cm]?[jt]sx?$/.test(path)) {
|
|
120
|
+
const componentName = basename(path).replace(/\.stories\.[cm]?[jt]sx?$/, '');
|
|
121
|
+
const variants = [...content.matchAll(/export\s+const\s+([A-Z][A-Za-z0-9_]*)/g)].map((story) => ({
|
|
122
|
+
id: stableId('var', `${file}:${story[1]}`),
|
|
123
|
+
label: story[1],
|
|
124
|
+
property: 'story',
|
|
125
|
+
value: story[1],
|
|
126
|
+
source: { file, line: lineAt(content, story.index ?? 0) },
|
|
127
|
+
}));
|
|
128
|
+
storyVariants.set(componentName, variants);
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
for (const match of content.matchAll(/export\s+(?:default\s+)?(?:async\s+)?(?:function|class|const)\s+([A-Z][A-Za-z0-9_]*)/g)) {
|
|
132
|
+
const name = match[1];
|
|
133
|
+
const id = stableId('cmp', `${file}:${name}`);
|
|
134
|
+
const component = components.get(id) ?? {
|
|
135
|
+
id,
|
|
136
|
+
name,
|
|
137
|
+
source: { file, line: lineAt(content, match.index ?? 0) },
|
|
138
|
+
instances: 0,
|
|
139
|
+
variants: [],
|
|
140
|
+
evidence: ['exported component'],
|
|
141
|
+
};
|
|
142
|
+
components.set(id, component);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
for (const [componentName, variants] of storyVariants) {
|
|
147
|
+
const component = [...components.values()].find((item) => item.name === componentName);
|
|
148
|
+
if (component) {
|
|
149
|
+
component.variants = variants;
|
|
150
|
+
component.evidence.push('Storybook story');
|
|
151
|
+
}
|
|
152
|
+
else if (variants[0]?.source) {
|
|
153
|
+
const id = stableId('cmp', `${variants[0].source.file}:${componentName}`);
|
|
154
|
+
components.set(id, {
|
|
155
|
+
id,
|
|
156
|
+
name: componentName,
|
|
157
|
+
source: variants[0].source,
|
|
158
|
+
instances: 0,
|
|
159
|
+
variants,
|
|
160
|
+
evidence: ['Storybook story'],
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
const configuredViewports = config?.design?.viewports ?? [];
|
|
165
|
+
const graphBreakpoints = configuredViewports.length
|
|
166
|
+
? configuredViewports.map((item) => ({ ...item, height: item.height ?? 900 }))
|
|
167
|
+
: breakpoints.size
|
|
168
|
+
? [...breakpoints.values()]
|
|
169
|
+
.sort((a, b) => a.width - b.width)
|
|
170
|
+
.map((item) => ({
|
|
171
|
+
id: `viewport-${item.width}`,
|
|
172
|
+
label: `${item.width}px`,
|
|
173
|
+
width: item.width,
|
|
174
|
+
height: 900,
|
|
175
|
+
mediaQuery: `width: ${item.width}px`,
|
|
176
|
+
source: item.source,
|
|
177
|
+
}))
|
|
178
|
+
: [
|
|
179
|
+
{ id: 'mobile', label: 'Mobile', width: 390, height: 844 },
|
|
180
|
+
{ id: 'tablet', label: 'Tablet', width: 768, height: 1024 },
|
|
181
|
+
{ id: 'desktop', label: 'Desktop', width: 1440, height: 900 },
|
|
182
|
+
];
|
|
183
|
+
const configuredThemes = config?.design?.themes ?? [];
|
|
184
|
+
const graphThemes = configuredThemes.length
|
|
185
|
+
? configuredThemes
|
|
186
|
+
: [...themes].map((id) => ({ id, label: id[0].toUpperCase() + id.slice(1) }));
|
|
187
|
+
return projectDesignGraphSchema.parse({
|
|
188
|
+
protocolVersion: PROTOCOL_VERSION,
|
|
189
|
+
projectRoot: root,
|
|
190
|
+
revision,
|
|
191
|
+
tokens: [...tokens.values()],
|
|
192
|
+
components: [...components.values()],
|
|
193
|
+
breakpoints: graphBreakpoints,
|
|
194
|
+
themes: graphThemes,
|
|
195
|
+
states: config?.design?.states ?? [],
|
|
196
|
+
motionPresets: [...motion.values()],
|
|
197
|
+
indexedAt: new Date().toISOString(),
|
|
198
|
+
});
|
|
199
|
+
}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undry-design-protocol';
|
|
2
|
+
export type Agent = 'codex' | 'cursor' | 'claude';
|
|
3
|
+
export type WebFramework = 'next' | 'vite' | 'html' | 'generic';
|
|
4
|
+
export interface FoundryProjectConfig {
|
|
5
|
+
version: 1 | 2;
|
|
6
|
+
platform: Platform;
|
|
7
|
+
framework?: WebFramework;
|
|
8
|
+
runtimeUrl: string;
|
|
9
|
+
targetUrl?: string;
|
|
10
|
+
devCommand?: {
|
|
11
|
+
command: string;
|
|
12
|
+
args: string[];
|
|
13
|
+
};
|
|
14
|
+
instrumented: boolean;
|
|
15
|
+
design?: {
|
|
16
|
+
tokenFiles?: string[];
|
|
17
|
+
componentRoots?: string[];
|
|
18
|
+
exclude?: string[];
|
|
19
|
+
viewports?: Array<{
|
|
20
|
+
id: string;
|
|
21
|
+
label: string;
|
|
22
|
+
width: number;
|
|
23
|
+
height?: number;
|
|
24
|
+
}>;
|
|
25
|
+
themes?: Array<{
|
|
26
|
+
id: string;
|
|
27
|
+
label: string;
|
|
28
|
+
selector?: string;
|
|
29
|
+
attribute?: string;
|
|
30
|
+
value?: string;
|
|
31
|
+
}>;
|
|
32
|
+
states?: Array<{
|
|
33
|
+
id: string;
|
|
34
|
+
label: string;
|
|
35
|
+
theme?: string;
|
|
36
|
+
pseudoStates?: Array<'hover' | 'focus' | 'active' | 'disabled'>;
|
|
37
|
+
reducedMotion?: boolean;
|
|
38
|
+
query?: Record<string, string>;
|
|
39
|
+
}>;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
export interface SetupOptions {
|
|
43
|
+
agents?: Agent[];
|
|
44
|
+
targetUrl?: string;
|
|
45
|
+
runtimeUrl?: string;
|
|
46
|
+
packageRoot?: string;
|
|
47
|
+
}
|
|
48
|
+
export interface SetupPlan {
|
|
49
|
+
root: string;
|
|
50
|
+
platform: Platform;
|
|
51
|
+
framework?: WebFramework;
|
|
52
|
+
agents: Agent[];
|
|
53
|
+
files: string[];
|
|
54
|
+
integrationFile?: string;
|
|
55
|
+
targetUrl?: string;
|
|
56
|
+
devCommand?: {
|
|
57
|
+
command: string;
|
|
58
|
+
args: string[];
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
export interface SetupResult extends SetupPlan {
|
|
62
|
+
changed: string[];
|
|
63
|
+
}
|
|
64
|
+
export interface UninstallResult {
|
|
65
|
+
removed: string[];
|
|
66
|
+
preserved: string[];
|
|
67
|
+
}
|
|
68
|
+
export declare function detectWebFramework(root: string): Promise<WebFramework>;
|
|
69
|
+
export declare function createSetupPlan(rootInput: string, options?: SetupOptions): Promise<SetupPlan>;
|
|
70
|
+
export declare function setupProject(rootInput: string, options?: SetupOptions): Promise<SetupResult>;
|
|
71
|
+
export declare function uninstallProject(rootInput: string): Promise<UninstallResult>;
|
|
72
|
+
//# sourceMappingURL=installer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"installer.d.ts","sourceRoot":"","sources":["../src/installer.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAGxD,MAAM,MAAM,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAClD,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;AAEhE,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,CAAC,GAAG,CAAC,CAAC;IACf,QAAQ,EAAE,QAAQ,CAAC;IACnB,SAAS,CAAC,EAAE,YAAY,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC;IACjD,YAAY,EAAE,OAAO,CAAC;IACtB,MAAM,CAAC,EAAE;QACP,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;QACtB,cAAc,CAAC,EAA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