@fragments-sdk/cli 0.9.0 → 0.9.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/dist/bin.js +83 -33
- package/dist/bin.js.map +1 -1
- package/dist/{chunk-WI6SLMSO.js → chunk-5GT62FCB.js} +2 -2
- package/dist/{chunk-CJEGT3WD.js → chunk-BW3ZATBW.js} +20 -3
- package/dist/chunk-BW3ZATBW.js.map +1 -0
- package/dist/{chunk-2JIKCJX3.js → chunk-D7372LQX.js} +13 -6
- package/dist/chunk-D7372LQX.js.map +1 -0
- package/dist/chunk-EZYXYWNF.js +131 -0
- package/dist/chunk-EZYXYWNF.js.map +1 -0
- package/dist/{chunk-NGIMCIK2.js → chunk-GF6OVPIN.js} +2 -2
- package/dist/{chunk-GOVI6COW.js → chunk-NVSPGSKB.js} +12 -4
- package/dist/chunk-NVSPGSKB.js.map +1 -0
- package/dist/core/index.d.ts +105 -3
- package/dist/core/index.js +12 -2
- package/dist/{defineFragment-D0UTve-I.d.ts → defineFragment-CBMS7Bab.d.ts} +21 -1
- package/dist/generate-LQA2R7FN.js +461 -0
- package/dist/generate-LQA2R7FN.js.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +5 -4
- package/dist/index.js.map +1 -1
- package/dist/{init-KSAAS7X3.js → init-2GEGVIUQ.js} +13 -75
- package/dist/init-2GEGVIUQ.js.map +1 -0
- package/dist/mcp-bin.js +4 -3
- package/dist/mcp-bin.js.map +1 -1
- package/dist/{scan-65RH3QMM.js → scan-JGS65S7P.js} +6 -5
- package/dist/{service-A5GIGGGK.js → service-XP2EAJXD.js} +4 -3
- package/dist/{static-viewer-NSODM5VX.js → static-viewer-XCS7UJTO.js} +4 -3
- package/dist/storyFilters-3LUYAFZF.js +15 -0
- package/dist/storyFilters-3LUYAFZF.js.map +1 -0
- package/dist/{test-RPWZAYSJ.js → test-TD6TJNVY.js} +3 -3
- package/dist/{tokens-NIXSZRX7.js → tokens-2EXPCVP3.js} +5 -4
- package/dist/{tokens-NIXSZRX7.js.map → tokens-2EXPCVP3.js.map} +1 -1
- package/dist/{viewer-SBTJDMP7.js → viewer-RFA2KVBG.js} +243 -18
- package/dist/viewer-RFA2KVBG.js.map +1 -0
- package/package.json +1 -1
- package/src/build.ts +12 -2
- package/src/commands/build.ts +16 -2
- package/src/commands/generate.ts +383 -68
- package/src/commands/init.ts +9 -51
- package/src/core/config.ts +15 -2
- package/src/core/generators/typescript-extractor.ts +10 -0
- package/src/core/index.ts +15 -0
- package/src/core/schema.ts +10 -2
- package/src/core/storyFilters.test.ts +350 -0
- package/src/core/storyFilters.ts +253 -0
- package/src/core/types.ts +22 -0
- package/src/migrate/converter.ts +9 -1
- package/src/migrate/parser.ts +2 -0
- package/src/migrate/types.ts +2 -0
- package/src/setup.ts +69 -24
- package/src/viewer/__tests__/viewer-integration.test.ts +1 -1
- package/src/viewer/components/AccessibilityPanel.tsx +305 -312
- package/src/viewer/components/ActionsPanel.tsx +31 -29
- package/src/viewer/components/AllVariantsPreview.tsx +78 -0
- package/src/viewer/components/App.tsx +187 -740
- package/src/viewer/components/BottomPanel.tsx +228 -132
- package/src/viewer/components/CodePanel.tsx +1 -1
- package/src/viewer/components/CommandPalette.tsx +7 -10
- package/src/viewer/components/ComponentDocView.tsx +164 -0
- package/src/viewer/components/ComponentGraph.tsx +111 -142
- package/src/viewer/components/ContractPanel.tsx +6 -6
- package/src/viewer/components/EmptyVariantMessage.tsx +54 -0
- package/src/viewer/components/FigmaEmbed.tsx +20 -18
- package/src/viewer/components/FragmentEditor.tsx +92 -115
- package/src/viewer/components/HeaderSearch.tsx +24 -0
- package/src/viewer/components/HealthDashboard.tsx +16 -2
- package/src/viewer/components/Icons.tsx +9 -0
- package/src/viewer/components/InteractionsPanel.tsx +101 -117
- package/src/viewer/components/IsolatedPreviewFrame.tsx +1 -0
- package/src/viewer/components/LandingPage.tsx +3 -3
- package/src/viewer/components/LeftSidebar.tsx +141 -63
- package/src/viewer/components/LoadErrorMessage.tsx +102 -0
- package/src/viewer/components/MultiViewportPreview.tsx +61 -142
- package/src/viewer/components/NoVariantsMessage.tsx +59 -0
- package/src/viewer/components/PanelShell.tsx +161 -0
- package/src/viewer/components/PerformancePanel.tsx +31 -28
- package/src/viewer/components/PreviewArea.tsx +1 -1
- package/src/viewer/components/PreviewAside.tsx +168 -0
- package/src/viewer/components/PreviewFrameHost.tsx +3 -3
- package/src/viewer/components/PropsEditor.tsx +70 -156
- package/src/viewer/components/ResizablePanel.tsx +103 -263
- package/src/viewer/components/RightSidebar.tsx +3 -9
- package/src/viewer/components/SkeletonLoader.tsx +13 -13
- package/src/viewer/components/TokenStylePanel.tsx +182 -209
- package/src/viewer/components/TopToolbar.tsx +159 -0
- package/src/viewer/components/VariantMatrix.tsx +42 -86
- package/src/viewer/components/VariantTabs.tsx +3 -3
- package/src/viewer/components/ViewerHeader.tsx +69 -0
- package/src/viewer/components/WebMCPDevTools.tsx +17 -23
- package/src/viewer/components/viewer-utils.ts +16 -0
- package/src/viewer/entry.tsx +5 -0
- package/src/viewer/hooks/useAppState.ts +27 -4
- package/src/viewer/hooks/usePreviewBridge.ts +2 -2
- package/src/viewer/preview-frame.html +6 -12
- package/src/viewer/server.ts +169 -2
- package/src/viewer/vendor/shared/src/ComponentDocContent.module.scss +10 -0
- package/src/viewer/vendor/shared/src/ComponentDocContent.module.scss.d.ts +2 -0
- package/src/viewer/vendor/shared/src/ComponentDocContent.tsx +274 -0
- package/src/viewer/vendor/shared/src/DocsHeaderBar.tsx +6 -18
- package/src/viewer/vendor/shared/src/DocsPageShell.tsx +5 -0
- package/src/viewer/vendor/shared/src/DocsSidebarNav.tsx +5 -16
- package/src/viewer/vendor/shared/src/PropsTable.module.scss +68 -0
- package/src/viewer/vendor/shared/src/PropsTable.module.scss.d.ts +2 -0
- package/src/viewer/vendor/shared/src/PropsTable.tsx +76 -0
- package/src/viewer/vendor/shared/src/VariantPreviewCard.module.scss +122 -0
- package/src/viewer/vendor/shared/src/VariantPreviewCard.module.scss.d.ts +2 -0
- package/src/viewer/vendor/shared/src/VariantPreviewCard.tsx +134 -0
- package/src/viewer/vendor/shared/src/index.ts +8 -0
- package/src/viewer/vendor/shared/src/types.ts +12 -0
- package/src/viewer/vite-plugin.ts +109 -4
- package/dist/chunk-2JIKCJX3.js.map +0 -1
- package/dist/chunk-CJEGT3WD.js.map +0 -1
- package/dist/chunk-GOVI6COW.js.map +0 -1
- package/dist/generate-35OIMW4Y.js +0 -252
- package/dist/generate-35OIMW4Y.js.map +0 -1
- package/dist/init-KSAAS7X3.js.map +0 -1
- package/dist/viewer-SBTJDMP7.js.map +0 -1
- /package/dist/{chunk-WI6SLMSO.js.map → chunk-5GT62FCB.js.map} +0 -0
- /package/dist/{chunk-NGIMCIK2.js.map → chunk-GF6OVPIN.js.map} +0 -0
- /package/dist/{scan-65RH3QMM.js.map → scan-JGS65S7P.js.map} +0 -0
- /package/dist/{service-A5GIGGGK.js.map → service-XP2EAJXD.js.map} +0 -0
- /package/dist/{static-viewer-NSODM5VX.js.map → static-viewer-XCS7UJTO.js.map} +0 -0
- /package/dist/{test-RPWZAYSJ.js.map → test-TD6TJNVY.js.map} +0 -0
|
@@ -0,0 +1,461 @@
|
|
|
1
|
+
import { createRequire as __banner_createRequire } from 'module'; const require = __banner_createRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
extractPropsFromFile
|
|
4
|
+
} from "./chunk-BW3ZATBW.js";
|
|
5
|
+
import "./chunk-AWYCDRPG.js";
|
|
6
|
+
import "./chunk-GF6OVPIN.js";
|
|
7
|
+
import "./chunk-NVSPGSKB.js";
|
|
8
|
+
import "./chunk-EZYXYWNF.js";
|
|
9
|
+
import {
|
|
10
|
+
BRAND
|
|
11
|
+
} from "./chunk-EKLMXTWU.js";
|
|
12
|
+
import "./chunk-Z7EY4VHE.js";
|
|
13
|
+
|
|
14
|
+
// src/commands/generate.ts
|
|
15
|
+
import { readFile, writeFile, access } from "fs/promises";
|
|
16
|
+
import { resolve, basename, dirname, relative, join } from "path";
|
|
17
|
+
import pc from "picocolors";
|
|
18
|
+
import fg from "fast-glob";
|
|
19
|
+
async function generate(options = {}) {
|
|
20
|
+
const projectRoot = resolve(options.projectRoot || process.cwd());
|
|
21
|
+
const generated = [];
|
|
22
|
+
const skipped = [];
|
|
23
|
+
const errors = [];
|
|
24
|
+
console.log(pc.cyan(`
|
|
25
|
+
${BRAND.name} Generate
|
|
26
|
+
`));
|
|
27
|
+
const componentPattern = options.componentPattern || "src/components/**/*.tsx";
|
|
28
|
+
const componentFiles = await fg(componentPattern, {
|
|
29
|
+
cwd: projectRoot,
|
|
30
|
+
ignore: [
|
|
31
|
+
"**/node_modules/**",
|
|
32
|
+
"**/*.stories.*",
|
|
33
|
+
"**/*.fragment.*",
|
|
34
|
+
"**/*.test.*",
|
|
35
|
+
"**/*.spec.*",
|
|
36
|
+
"**/*.d.ts",
|
|
37
|
+
"**/index.tsx"
|
|
38
|
+
// Often just re-exports
|
|
39
|
+
],
|
|
40
|
+
absolute: true
|
|
41
|
+
});
|
|
42
|
+
const storyFiles = await fg(["src/**/*.stories.tsx", "src/**/*.stories.ts"], {
|
|
43
|
+
cwd: projectRoot,
|
|
44
|
+
ignore: ["**/node_modules/**"],
|
|
45
|
+
absolute: true
|
|
46
|
+
});
|
|
47
|
+
const storyMap = /* @__PURE__ */ new Map();
|
|
48
|
+
for (const storyFile of storyFiles) {
|
|
49
|
+
try {
|
|
50
|
+
const content = await readFile(storyFile, "utf-8");
|
|
51
|
+
const componentName = extractComponentNameFromStory(content, storyFile);
|
|
52
|
+
if (componentName) {
|
|
53
|
+
const variants = extractStoryVariants(content);
|
|
54
|
+
storyMap.set(componentName, variants);
|
|
55
|
+
}
|
|
56
|
+
} catch {
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
console.log(pc.dim(`Found ${componentFiles.length} component files
|
|
60
|
+
`));
|
|
61
|
+
for (const filePath of componentFiles) {
|
|
62
|
+
try {
|
|
63
|
+
const extracted = extractPropsFromFile(filePath);
|
|
64
|
+
if (!extracted || !extracted.componentName) {
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
const componentName = extracted.componentName;
|
|
68
|
+
if (options.component && componentName !== options.component) {
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
const componentDir = dirname(filePath);
|
|
72
|
+
const componentBaseName = basename(filePath, ".tsx");
|
|
73
|
+
const fragmentPath = join(componentDir, `${componentBaseName}${BRAND.fileExtension}`);
|
|
74
|
+
let fragmentExists = false;
|
|
75
|
+
try {
|
|
76
|
+
await access(fragmentPath);
|
|
77
|
+
fragmentExists = true;
|
|
78
|
+
} catch {
|
|
79
|
+
}
|
|
80
|
+
if (fragmentExists && !options.force) {
|
|
81
|
+
skipped.push({ name: componentName, reason: "Fragment already exists" });
|
|
82
|
+
console.log(pc.dim(` Skipping ${componentName} (fragment exists)`));
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
const storyVariants = storyMap.get(componentName) || [];
|
|
86
|
+
const fragmentContent = generateFragmentTsx(
|
|
87
|
+
componentName,
|
|
88
|
+
componentBaseName,
|
|
89
|
+
extracted,
|
|
90
|
+
filePath,
|
|
91
|
+
storyVariants
|
|
92
|
+
);
|
|
93
|
+
await writeFile(fragmentPath, fragmentContent, "utf-8");
|
|
94
|
+
generated.push({ name: componentName, path: relative(projectRoot, fragmentPath) });
|
|
95
|
+
console.log(pc.green(` \u2713 Generated ${componentName}${BRAND.fileExtension}`));
|
|
96
|
+
} catch (e) {
|
|
97
|
+
const fileName = basename(filePath);
|
|
98
|
+
errors.push({
|
|
99
|
+
name: fileName,
|
|
100
|
+
error: e instanceof Error ? e.message : String(e)
|
|
101
|
+
});
|
|
102
|
+
console.log(pc.red(` \u2717 Failed: ${fileName}`));
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
console.log();
|
|
106
|
+
if (generated.length > 0) {
|
|
107
|
+
console.log(pc.green(`\u2713 Generated ${generated.length} fragment(s)`));
|
|
108
|
+
}
|
|
109
|
+
if (skipped.length > 0) {
|
|
110
|
+
console.log(pc.dim(` Skipped ${skipped.length} (use --force to overwrite)`));
|
|
111
|
+
}
|
|
112
|
+
if (errors.length > 0) {
|
|
113
|
+
console.log(pc.yellow(` ${errors.length} error(s)`));
|
|
114
|
+
}
|
|
115
|
+
console.log();
|
|
116
|
+
return {
|
|
117
|
+
success: errors.length === 0,
|
|
118
|
+
generated,
|
|
119
|
+
skipped,
|
|
120
|
+
errors
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
function generateFragmentTsx(componentName, componentBaseName, extracted, filePath, storyVariants) {
|
|
124
|
+
const storyNames = storyVariants.map((v) => v.name);
|
|
125
|
+
const whenToUse = inferUsageFromStories(storyNames);
|
|
126
|
+
const description = generateDescription(componentName, extracted.props);
|
|
127
|
+
const status = inferStatus(filePath);
|
|
128
|
+
const accessibility = inferAccessibility(extracted.props);
|
|
129
|
+
const propsEntries = Object.entries(extracted.props || {});
|
|
130
|
+
const whenLines = whenToUse.length > 0 ? whenToUse.map((w) => ` '${escapeQuotes(w)}',`).join("\n") : ` 'TODO: describe when to use ${componentName}',`;
|
|
131
|
+
let propsBlock = "{}";
|
|
132
|
+
if (propsEntries.length > 0) {
|
|
133
|
+
const propLines = propsEntries.map(([name, info]) => {
|
|
134
|
+
const propInfo = info;
|
|
135
|
+
const rawType = propInfo.type ? String(propInfo.type) : "";
|
|
136
|
+
const classified = classifyPropType(rawType);
|
|
137
|
+
const desc = propInfo.description ? String(propInfo.description).replace(/\n/g, " ") : "";
|
|
138
|
+
const required = propInfo.required ? "true" : "false";
|
|
139
|
+
const parts = [` type: '${classified.type}'`];
|
|
140
|
+
if (desc) parts.push(` description: '${escapeQuotes(desc)}'`);
|
|
141
|
+
parts.push(` required: ${required}`);
|
|
142
|
+
if (propInfo.default !== void 0) {
|
|
143
|
+
parts.push(` default: ${JSON.stringify(propInfo.default)}`);
|
|
144
|
+
}
|
|
145
|
+
const values = classified.values || (propInfo.values && Array.isArray(propInfo.values) ? propInfo.values : null);
|
|
146
|
+
if (values && values.length > 0) {
|
|
147
|
+
parts.push(` values: ${JSON.stringify(values)}`);
|
|
148
|
+
}
|
|
149
|
+
return ` ${name}: {
|
|
150
|
+
${parts.join(",\n")},
|
|
151
|
+
}`;
|
|
152
|
+
});
|
|
153
|
+
propsBlock = `{
|
|
154
|
+
${propLines.join(",\n")},
|
|
155
|
+
}`;
|
|
156
|
+
}
|
|
157
|
+
let accessibilityBlock = "";
|
|
158
|
+
if (accessibility.role || accessibility.requirements && accessibility.requirements.length > 0) {
|
|
159
|
+
const parts = [];
|
|
160
|
+
if (accessibility.role) {
|
|
161
|
+
parts.push(` role: '${accessibility.role}'`);
|
|
162
|
+
}
|
|
163
|
+
if (accessibility.requirements && accessibility.requirements.length > 0) {
|
|
164
|
+
const reqs = accessibility.requirements.map((r) => `'${escapeQuotes(r)}'`).join(", ");
|
|
165
|
+
parts.push(` requirements: [${reqs}]`);
|
|
166
|
+
}
|
|
167
|
+
accessibilityBlock = `
|
|
168
|
+
|
|
169
|
+
accessibility: {
|
|
170
|
+
${parts.join(",\n")},
|
|
171
|
+
},`;
|
|
172
|
+
}
|
|
173
|
+
const variants = buildVariants(componentName, storyVariants);
|
|
174
|
+
const componentImportStatement = extracted.isDefaultExport ? `import ${componentName} from './${componentBaseName}';` : `import { ${componentName} } from './${componentBaseName}';`;
|
|
175
|
+
return `import React from 'react';
|
|
176
|
+
import { defineFragment } from '@fragments-sdk/cli/core';
|
|
177
|
+
${componentImportStatement}
|
|
178
|
+
|
|
179
|
+
export default defineFragment({
|
|
180
|
+
component: ${componentName},
|
|
181
|
+
|
|
182
|
+
meta: {
|
|
183
|
+
name: '${escapeQuotes(componentName)}',
|
|
184
|
+
description: '${escapeQuotes(description)}',
|
|
185
|
+
category: '${inferCategory(componentName, extracted.props)}',
|
|
186
|
+
status: '${status}',
|
|
187
|
+
},
|
|
188
|
+
|
|
189
|
+
usage: {
|
|
190
|
+
when: [
|
|
191
|
+
${whenLines}
|
|
192
|
+
],
|
|
193
|
+
whenNot: [],
|
|
194
|
+
},
|
|
195
|
+
|
|
196
|
+
props: ${propsBlock},${accessibilityBlock}
|
|
197
|
+
|
|
198
|
+
variants: [
|
|
199
|
+
${variants}
|
|
200
|
+
],
|
|
201
|
+
});
|
|
202
|
+
`;
|
|
203
|
+
}
|
|
204
|
+
function escapeQuotes(str) {
|
|
205
|
+
return str.replace(/'/g, "\\'");
|
|
206
|
+
}
|
|
207
|
+
function classifyPropType(rawType) {
|
|
208
|
+
const t = rawType.replace(/\s+/g, " ").trim();
|
|
209
|
+
const lower = t.toLowerCase();
|
|
210
|
+
if (lower === "string") return { type: "string" };
|
|
211
|
+
if (lower === "number") return { type: "number" };
|
|
212
|
+
if (lower === "boolean" || lower === "bool") return { type: "boolean" };
|
|
213
|
+
if (/^["'][^"']*["'](\s*\|\s*["'][^"']*["'])*$/.test(t)) {
|
|
214
|
+
const values = [...t.matchAll(/["']([^"']+)["']/g)].map((m) => m[1]);
|
|
215
|
+
if (values.length > 0) return { type: "enum", values };
|
|
216
|
+
}
|
|
217
|
+
if (lower.includes("=>") || lower.includes("handler") || lower.includes("callback") || lower.includes("dispatch") || lower.includes("listener") || /^\(/.test(t)) {
|
|
218
|
+
return { type: "function" };
|
|
219
|
+
}
|
|
220
|
+
if (lower.includes("reactnode") || lower.includes("react.reactnode") || lower === "node") {
|
|
221
|
+
return { type: "node" };
|
|
222
|
+
}
|
|
223
|
+
if (lower.includes("reactelement") || lower.includes("react.reactelement") || lower.includes("jsx.element")) {
|
|
224
|
+
return { type: "element" };
|
|
225
|
+
}
|
|
226
|
+
if (lower.includes("[]") || lower.startsWith("array<") || lower.startsWith("readonly ")) {
|
|
227
|
+
return { type: "array" };
|
|
228
|
+
}
|
|
229
|
+
if (lower.startsWith("{") || lower.includes("record<") || lower === "object") {
|
|
230
|
+
return { type: "object" };
|
|
231
|
+
}
|
|
232
|
+
if (lower.includes("|")) {
|
|
233
|
+
const parts = t.split("|").map((p) => p.trim());
|
|
234
|
+
const allStringLiterals = parts.every((p) => /^["'].*["']$/.test(p));
|
|
235
|
+
if (allStringLiterals) {
|
|
236
|
+
const values = parts.map((p) => p.replace(/^["']|["']$/g, ""));
|
|
237
|
+
return { type: "enum", values };
|
|
238
|
+
}
|
|
239
|
+
return { type: "union" };
|
|
240
|
+
}
|
|
241
|
+
return { type: "custom" };
|
|
242
|
+
}
|
|
243
|
+
function inferCategory(componentName, props) {
|
|
244
|
+
const lower = componentName.toLowerCase();
|
|
245
|
+
const categoryPatterns = {
|
|
246
|
+
"Actions": ["button", "action", "cta", "fab", "floatingaction"],
|
|
247
|
+
"Forms": ["form", "input", "select", "checkbox", "radio", "textarea", "field", "textfield", "datepicker", "switch", "slider", "segmented"],
|
|
248
|
+
"Layout": ["layout", "container", "grid", "flex", "stack", "box", "divider", "spacer", "sidebar"],
|
|
249
|
+
"Navigation": ["nav", "menu", "breadcrumb", "tab", "link", "pagination", "stepper", "topbar"],
|
|
250
|
+
"Feedback": ["alert", "toast", "notification", "message", "badge", "indicator", "progress", "spinner", "loading", "loader", "lozenge", "chip"],
|
|
251
|
+
"Data Display": ["table", "list", "card", "avatar", "stat", "timeline", "tree", "datalist", "datacard"],
|
|
252
|
+
"Overlays": ["modal", "dialog", "drawer", "popover", "tooltip", "dropdown", "slidepanel"],
|
|
253
|
+
"Typography": ["text", "heading", "title", "label", "paragraph"],
|
|
254
|
+
"Media": ["image", "video", "icon", "carousel"]
|
|
255
|
+
};
|
|
256
|
+
for (const [category, patterns] of Object.entries(categoryPatterns)) {
|
|
257
|
+
for (const pattern of patterns) {
|
|
258
|
+
if (lower.includes(pattern)) {
|
|
259
|
+
return category;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
if ("onClick" in props || "onPress" in props) return "Actions";
|
|
264
|
+
if ("value" in props || "defaultValue" in props) return "Forms";
|
|
265
|
+
if ("children" in props) return "Layout";
|
|
266
|
+
return "Components";
|
|
267
|
+
}
|
|
268
|
+
function extractComponentNameFromStory(content, filePath) {
|
|
269
|
+
const titleMatch = content.match(/title:\s*['"](?:[^'"]+\/)?([^'"]+)['"]/);
|
|
270
|
+
if (titleMatch) {
|
|
271
|
+
return titleMatch[1];
|
|
272
|
+
}
|
|
273
|
+
const fileName = basename(filePath);
|
|
274
|
+
const componentName = fileName.replace(/\.stories\.(tsx?|jsx?)$/, "");
|
|
275
|
+
if (/^[A-Z]/.test(componentName)) {
|
|
276
|
+
return componentName;
|
|
277
|
+
}
|
|
278
|
+
return null;
|
|
279
|
+
}
|
|
280
|
+
function extractStoryVariants(content) {
|
|
281
|
+
const variants = [];
|
|
282
|
+
const exportMatches = content.matchAll(
|
|
283
|
+
/export\s+const\s+([A-Z][a-zA-Z0-9]*)\s*[=:]/g
|
|
284
|
+
);
|
|
285
|
+
for (const match of exportMatches) {
|
|
286
|
+
const name = match[1];
|
|
287
|
+
if (name === "default" || name.endsWith("Args") || name.endsWith("Meta")) {
|
|
288
|
+
continue;
|
|
289
|
+
}
|
|
290
|
+
const args = extractStoryArgs(content, name);
|
|
291
|
+
variants.push({ name, args });
|
|
292
|
+
}
|
|
293
|
+
return variants;
|
|
294
|
+
}
|
|
295
|
+
function extractStoryArgs(content, storyName) {
|
|
296
|
+
const storyPattern = new RegExp(
|
|
297
|
+
`export\\s+const\\s+${storyName}[^=]*=\\s*\\{([\\s\\S]*?)\\n\\};`
|
|
298
|
+
);
|
|
299
|
+
const storyMatch = content.match(storyPattern);
|
|
300
|
+
if (!storyMatch) return {};
|
|
301
|
+
const storyBody = storyMatch[1];
|
|
302
|
+
const argsStart = storyBody.indexOf("args:");
|
|
303
|
+
if (argsStart === -1) return {};
|
|
304
|
+
const braceStart = storyBody.indexOf("{", argsStart);
|
|
305
|
+
if (braceStart === -1) return {};
|
|
306
|
+
let depth = 0;
|
|
307
|
+
let braceEnd = -1;
|
|
308
|
+
for (let i = braceStart; i < storyBody.length; i++) {
|
|
309
|
+
if (storyBody[i] === "{") depth++;
|
|
310
|
+
else if (storyBody[i] === "}") {
|
|
311
|
+
depth--;
|
|
312
|
+
if (depth === 0) {
|
|
313
|
+
braceEnd = i;
|
|
314
|
+
break;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
if (braceEnd === -1) return {};
|
|
319
|
+
const argsBlock = storyBody.slice(braceStart + 1, braceEnd).trim();
|
|
320
|
+
return parseArgsBlock(argsBlock);
|
|
321
|
+
}
|
|
322
|
+
function parseArgsBlock(argsBlock) {
|
|
323
|
+
const args = {};
|
|
324
|
+
const pairPattern = /(\w+)\s*:\s*(?:['"]([^'"]*?)['"]|(true|false)|(\d+(?:\.\d+)?))/g;
|
|
325
|
+
let pairMatch;
|
|
326
|
+
while ((pairMatch = pairPattern.exec(argsBlock)) !== null) {
|
|
327
|
+
const key = pairMatch[1];
|
|
328
|
+
if (pairMatch[2] !== void 0) {
|
|
329
|
+
args[key] = pairMatch[2];
|
|
330
|
+
} else if (pairMatch[3] !== void 0) {
|
|
331
|
+
args[key] = pairMatch[3] === "true";
|
|
332
|
+
} else if (pairMatch[4] !== void 0) {
|
|
333
|
+
args[key] = Number(pairMatch[4]);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
return args;
|
|
337
|
+
}
|
|
338
|
+
function buildVariants(componentName, storyVariants) {
|
|
339
|
+
const hasDefault = storyVariants.some((v) => v.name === "Default");
|
|
340
|
+
const entries = [];
|
|
341
|
+
if (!hasDefault) {
|
|
342
|
+
entries.push(formatVariantEntry(componentName, "Default", `Default ${componentName}`, {}));
|
|
343
|
+
}
|
|
344
|
+
for (const variant of storyVariants) {
|
|
345
|
+
const description = variant.name.replace(/([A-Z])/g, " $1").trim();
|
|
346
|
+
entries.push(formatVariantEntry(componentName, variant.name, `${description} ${componentName}`, variant.args));
|
|
347
|
+
}
|
|
348
|
+
return entries.join("\n");
|
|
349
|
+
}
|
|
350
|
+
function formatVariantEntry(componentName, name, description, args) {
|
|
351
|
+
const jsxCode = buildJsxString(componentName, args);
|
|
352
|
+
return ` {
|
|
353
|
+
name: '${escapeQuotes(name)}',
|
|
354
|
+
description: '${escapeQuotes(description)}',
|
|
355
|
+
code: \`${jsxCode}\`,
|
|
356
|
+
render: () => ${jsxCode},
|
|
357
|
+
},`;
|
|
358
|
+
}
|
|
359
|
+
function buildJsxString(componentName, args) {
|
|
360
|
+
const { children, ...restArgs } = args;
|
|
361
|
+
const propParts = [];
|
|
362
|
+
for (const [key, value] of Object.entries(restArgs)) {
|
|
363
|
+
if (typeof value === "string") {
|
|
364
|
+
propParts.push(`${key}="${escapeQuotes(value)}"`);
|
|
365
|
+
} else if (typeof value === "boolean") {
|
|
366
|
+
propParts.push(value ? key : `${key}={false}`);
|
|
367
|
+
} else if (typeof value === "number") {
|
|
368
|
+
propParts.push(`${key}={${value}}`);
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
const propsStr = propParts.length > 0 ? " " + propParts.join(" ") : "";
|
|
372
|
+
if (typeof children === "string") {
|
|
373
|
+
return `<${componentName}${propsStr}>${children}</${componentName}>`;
|
|
374
|
+
}
|
|
375
|
+
return `<${componentName}${propsStr} />`;
|
|
376
|
+
}
|
|
377
|
+
function inferUsageFromStories(storyNames) {
|
|
378
|
+
const usage = [];
|
|
379
|
+
for (const name of storyNames) {
|
|
380
|
+
const sentence = name.replace(/([A-Z])/g, " $1").trim().toLowerCase();
|
|
381
|
+
if (["default", "primary", "basic", "example", "playground"].includes(
|
|
382
|
+
sentence.toLowerCase()
|
|
383
|
+
)) {
|
|
384
|
+
continue;
|
|
385
|
+
}
|
|
386
|
+
if (sentence.includes("loading")) {
|
|
387
|
+
usage.push("Showing loading states");
|
|
388
|
+
} else if (sentence.includes("disabled")) {
|
|
389
|
+
usage.push("Preventing user interaction");
|
|
390
|
+
} else if (sentence.includes("error")) {
|
|
391
|
+
usage.push("Displaying error states");
|
|
392
|
+
} else if (sentence.includes("success")) {
|
|
393
|
+
usage.push("Showing success feedback");
|
|
394
|
+
} else if (sentence.includes("empty")) {
|
|
395
|
+
usage.push("Handling empty states");
|
|
396
|
+
} else if (sentence.includes("with")) {
|
|
397
|
+
const withPart = sentence.replace("with ", "");
|
|
398
|
+
usage.push(`Displaying with ${withPart}`);
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
return usage;
|
|
402
|
+
}
|
|
403
|
+
function generateDescription(componentName, props) {
|
|
404
|
+
const words = componentName.replace(/([A-Z])/g, " $1").trim().toLowerCase();
|
|
405
|
+
const hasOnClick = "onClick" in props || "onPress" in props;
|
|
406
|
+
const hasValue = "value" in props || "defaultValue" in props;
|
|
407
|
+
const hasChildren = "children" in props;
|
|
408
|
+
if (hasOnClick && !hasValue) {
|
|
409
|
+
return `Interactive ${words} element for triggering actions`;
|
|
410
|
+
}
|
|
411
|
+
if (hasValue) {
|
|
412
|
+
return `Form ${words} for user input`;
|
|
413
|
+
}
|
|
414
|
+
if (hasChildren) {
|
|
415
|
+
return `Container ${words} for grouping content`;
|
|
416
|
+
}
|
|
417
|
+
return `${words.charAt(0).toUpperCase() + words.slice(1)} component`;
|
|
418
|
+
}
|
|
419
|
+
function inferAccessibility(props) {
|
|
420
|
+
const accessibility = {};
|
|
421
|
+
const hasOnClick = "onClick" in props || "onPress" in props;
|
|
422
|
+
const hasAriaLabel = "ariaLabel" in props || "aria-label" in props;
|
|
423
|
+
const hasDisabled = "disabled" in props;
|
|
424
|
+
const hasHref = "href" in props;
|
|
425
|
+
if (hasOnClick && !hasHref) {
|
|
426
|
+
accessibility.role = "button";
|
|
427
|
+
} else if (hasHref) {
|
|
428
|
+
accessibility.role = "link";
|
|
429
|
+
}
|
|
430
|
+
const requirements = [];
|
|
431
|
+
if (hasOnClick && !hasAriaLabel) {
|
|
432
|
+
requirements.push("Should have visible text or aria-label");
|
|
433
|
+
}
|
|
434
|
+
if (hasDisabled) {
|
|
435
|
+
requirements.push("Disabled state should be conveyed to assistive technology");
|
|
436
|
+
}
|
|
437
|
+
if (requirements.length > 0) {
|
|
438
|
+
accessibility.requirements = requirements;
|
|
439
|
+
}
|
|
440
|
+
return accessibility;
|
|
441
|
+
}
|
|
442
|
+
function inferStatus(filePath) {
|
|
443
|
+
const lowerPath = filePath.toLowerCase();
|
|
444
|
+
if (lowerPath.includes("/experimental/") || lowerPath.includes("/labs/")) {
|
|
445
|
+
return "experimental";
|
|
446
|
+
}
|
|
447
|
+
if (lowerPath.includes("/beta/")) {
|
|
448
|
+
return "beta";
|
|
449
|
+
}
|
|
450
|
+
if (lowerPath.includes("/deprecated/") || lowerPath.includes("/legacy/")) {
|
|
451
|
+
return "deprecated";
|
|
452
|
+
}
|
|
453
|
+
if (lowerPath.includes("/draft/") || lowerPath.includes("/wip/")) {
|
|
454
|
+
return "draft";
|
|
455
|
+
}
|
|
456
|
+
return "stable";
|
|
457
|
+
}
|
|
458
|
+
export {
|
|
459
|
+
generate
|
|
460
|
+
};
|
|
461
|
+
//# sourceMappingURL=generate-LQA2R7FN.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/commands/generate.ts"],"sourcesContent":["/**\n * fragments generate - Generate fragment files from component source code\n *\n * Analyzes component source code and generates proper defineFragment() TSX files\n * colocated next to the component source. These files are parseable by the\n * build command and renderable by the dev viewer.\n */\n\nimport { readFile, writeFile, access } from \"node:fs/promises\";\nimport { resolve, basename, dirname, relative, join } from \"node:path\";\nimport pc from \"picocolors\";\nimport fg from \"fast-glob\";\nimport { BRAND } from \"../core/index.js\";\nimport { extractPropsFromFile } from \"../core/node.js\";\n\nexport interface GenerateOptions {\n /** Project root directory */\n projectRoot?: string;\n /** Specific component name to generate (optional) */\n component?: string;\n /** Overwrite existing fragment files */\n force?: boolean;\n /** Pattern for component files */\n componentPattern?: string;\n}\n\nexport interface GenerateResult {\n success: boolean;\n generated: Array<{ name: string; path: string }>;\n skipped: Array<{ name: string; reason: string }>;\n errors: Array<{ name: string; error: string }>;\n}\n\n/**\n * Generate fragment files from component source code\n */\nexport async function generate(options: GenerateOptions = {}): Promise<GenerateResult> {\n const projectRoot = resolve(options.projectRoot || process.cwd());\n const generated: Array<{ name: string; path: string }> = [];\n const skipped: Array<{ name: string; reason: string }> = [];\n const errors: Array<{ name: string; error: string }> = [];\n\n console.log(pc.cyan(`\\n${BRAND.name} Generate\\n`));\n\n // Find component files\n const componentPattern =\n options.componentPattern ||\n \"src/components/**/*.tsx\";\n\n const componentFiles = await fg(componentPattern, {\n cwd: projectRoot,\n ignore: [\n \"**/node_modules/**\",\n \"**/*.stories.*\",\n \"**/*.fragment.*\",\n \"**/*.test.*\",\n \"**/*.spec.*\",\n \"**/*.d.ts\",\n \"**/index.tsx\", // Often just re-exports\n ],\n absolute: true,\n });\n\n // Find story files for pattern inference\n const storyFiles = await fg([\"src/**/*.stories.tsx\", \"src/**/*.stories.ts\"], {\n cwd: projectRoot,\n ignore: [\"**/node_modules/**\"],\n absolute: true,\n });\n\n // Build story map for pattern inference (names + args)\n const storyMap = new Map<string, StoryVariant[]>();\n for (const storyFile of storyFiles) {\n try {\n const content = await readFile(storyFile, \"utf-8\");\n const componentName = extractComponentNameFromStory(content, storyFile);\n if (componentName) {\n const variants = extractStoryVariants(content);\n storyMap.set(componentName, variants);\n }\n } catch {\n // Ignore parsing errors\n }\n }\n\n console.log(pc.dim(`Found ${componentFiles.length} component files\\n`));\n\n // Process each component file\n for (const filePath of componentFiles) {\n try {\n const extracted = extractPropsFromFile(filePath);\n\n if (!extracted || !extracted.componentName) {\n continue;\n }\n\n const componentName = extracted.componentName;\n\n // Filter by component name if specified\n if (options.component && componentName !== options.component) {\n continue;\n }\n\n // Write fragment file colocated next to the component source\n const componentDir = dirname(filePath);\n const componentBaseName = basename(filePath, \".tsx\");\n const fragmentPath = join(componentDir, `${componentBaseName}${BRAND.fileExtension}`);\n\n let fragmentExists = false;\n try {\n await access(fragmentPath);\n fragmentExists = true;\n } catch {\n // Fragment doesn't exist\n }\n\n if (fragmentExists && !options.force) {\n skipped.push({ name: componentName, reason: \"Fragment already exists\" });\n console.log(pc.dim(` Skipping ${componentName} (fragment exists)`));\n continue;\n }\n\n // Generate proper defineFragment() TSX content\n const storyVariants = storyMap.get(componentName) || [];\n const fragmentContent = generateFragmentTsx(\n componentName,\n componentBaseName,\n extracted,\n filePath,\n storyVariants\n );\n\n // Write fragment file\n await writeFile(fragmentPath, fragmentContent, \"utf-8\");\n generated.push({ name: componentName, path: relative(projectRoot, fragmentPath) });\n console.log(pc.green(` ✓ Generated ${componentName}${BRAND.fileExtension}`));\n } catch (e) {\n const fileName = basename(filePath);\n errors.push({\n name: fileName,\n error: e instanceof Error ? e.message : String(e),\n });\n console.log(pc.red(` ✗ Failed: ${fileName}`));\n }\n }\n\n // Summary\n console.log();\n if (generated.length > 0) {\n console.log(pc.green(`✓ Generated ${generated.length} fragment(s)`));\n }\n if (skipped.length > 0) {\n console.log(pc.dim(` Skipped ${skipped.length} (use --force to overwrite)`));\n }\n if (errors.length > 0) {\n console.log(pc.yellow(` ${errors.length} error(s)`));\n }\n console.log();\n\n return {\n success: errors.length === 0,\n generated,\n skipped,\n errors,\n };\n}\n\n/**\n * Generate proper defineFragment() TSX file content\n */\nfunction generateFragmentTsx(\n componentName: string,\n componentBaseName: string,\n extracted: ReturnType<typeof extractPropsFromFile> & { componentName: string },\n filePath: string,\n storyVariants: StoryVariant[]\n): string {\n const storyNames = storyVariants.map((v) => v.name);\n const whenToUse = inferUsageFromStories(storyNames);\n const description = generateDescription(componentName, extracted.props);\n const status = inferStatus(filePath);\n const accessibility = inferAccessibility(extracted.props);\n\n // Build props object for defineFragment\n const propsEntries = Object.entries(extracted.props || {});\n\n // Format when array\n const whenLines = whenToUse.length > 0\n ? whenToUse.map((w) => ` '${escapeQuotes(w)}',`).join(\"\\n\")\n : ` 'TODO: describe when to use ${componentName}',`;\n\n // Format props\n let propsBlock = \"{}\";\n if (propsEntries.length > 0) {\n const propLines = propsEntries.map(([name, info]) => {\n const propInfo = info as Record<string, unknown>;\n const rawType = propInfo.type ? String(propInfo.type) : \"\";\n const classified = classifyPropType(rawType);\n const desc = propInfo.description ? String(propInfo.description).replace(/\\n/g, \" \") : \"\";\n const required = propInfo.required ? \"true\" : \"false\";\n const parts = [` type: '${classified.type}'`];\n if (desc) parts.push(` description: '${escapeQuotes(desc)}'`);\n parts.push(` required: ${required}`);\n if (propInfo.default !== undefined) {\n parts.push(` default: ${JSON.stringify(propInfo.default)}`);\n }\n // Use classified values (from string literal unions) or existing values\n const values = classified.values || (propInfo.values && Array.isArray(propInfo.values) ? propInfo.values : null);\n if (values && values.length > 0) {\n parts.push(` values: ${JSON.stringify(values)}`);\n }\n return ` ${name}: {\\n${parts.join(\",\\n\")},\\n }`;\n });\n propsBlock = `{\\n${propLines.join(\",\\n\")},\\n }`;\n }\n\n // Build accessibility section\n let accessibilityBlock = \"\";\n if (accessibility.role || (accessibility.requirements && accessibility.requirements.length > 0)) {\n const parts: string[] = [];\n if (accessibility.role) {\n parts.push(` role: '${accessibility.role}'`);\n }\n if (accessibility.requirements && accessibility.requirements.length > 0) {\n const reqs = accessibility.requirements.map((r) => `'${escapeQuotes(r)}'`).join(\", \");\n parts.push(` requirements: [${reqs}]`);\n }\n accessibilityBlock = `\n\n accessibility: {\n${parts.join(\",\\n\")},\n },`;\n }\n\n // Build variants from story args or fallback to bare render\n const variants = buildVariants(componentName, storyVariants);\n\n // Use default import when the source component uses export default\n const componentImportStatement = extracted.isDefaultExport\n ? `import ${componentName} from './${componentBaseName}';`\n : `import { ${componentName} } from './${componentBaseName}';`;\n\n return `import React from 'react';\nimport { defineFragment } from '@fragments-sdk/cli/core';\n${componentImportStatement}\n\nexport default defineFragment({\n component: ${componentName},\n\n meta: {\n name: '${escapeQuotes(componentName)}',\n description: '${escapeQuotes(description)}',\n category: '${inferCategory(componentName, extracted.props)}',\n status: '${status}',\n },\n\n usage: {\n when: [\n${whenLines}\n ],\n whenNot: [],\n },\n\n props: ${propsBlock},${accessibilityBlock}\n\n variants: [\n${variants}\n ],\n});\n`;\n}\n\n/**\n * Escape single quotes in strings\n */\nfunction escapeQuotes(str: string): string {\n return str.replace(/'/g, \"\\\\'\");\n}\n\n/**\n * Classify a raw TypeScript type string into a valid fragment prop type enum value.\n * Returns the classified type and optionally extracted enum values.\n */\nfunction classifyPropType(rawType: string): { type: string; values?: string[] } {\n const t = rawType.replace(/\\s+/g, \" \").trim();\n const lower = t.toLowerCase();\n\n // Direct primitive matches\n if (lower === \"string\") return { type: \"string\" };\n if (lower === \"number\") return { type: \"number\" };\n if (lower === \"boolean\" || lower === \"bool\") return { type: \"boolean\" };\n\n // String/number literal unions → enum with values\n // e.g., '\"primary\" | \"secondary\"' or \"'default' | 'modal'\"\n if (/^[\"'][^\"']*[\"'](\\s*\\|\\s*[\"'][^\"']*[\"'])*$/.test(t)) {\n const values = [...t.matchAll(/[\"']([^\"']+)[\"']/g)].map((m) => m[1]);\n if (values.length > 0) return { type: \"enum\", values };\n }\n\n // Function types — arrow functions, callbacks, handlers, dispatchers\n if (\n lower.includes(\"=>\") ||\n lower.includes(\"handler\") ||\n lower.includes(\"callback\") ||\n lower.includes(\"dispatch\") ||\n lower.includes(\"listener\") ||\n /^\\(/.test(t)\n ) {\n return { type: \"function\" };\n }\n\n // React node types\n if (\n lower.includes(\"reactnode\") ||\n lower.includes(\"react.reactnode\") ||\n lower === \"node\"\n ) {\n return { type: \"node\" };\n }\n\n // React element types\n if (\n lower.includes(\"reactelement\") ||\n lower.includes(\"react.reactelement\") ||\n lower.includes(\"jsx.element\")\n ) {\n return { type: \"element\" };\n }\n\n // Array types\n if (lower.includes(\"[]\") || lower.startsWith(\"array<\") || lower.startsWith(\"readonly \")) {\n return { type: \"array\" };\n }\n\n // Object types (must come after array check since objects can contain [])\n if (lower.startsWith(\"{\") || lower.includes(\"record<\") || lower === \"object\") {\n return { type: \"object\" };\n }\n\n // Union types (mixed types with |)\n if (lower.includes(\"|\")) {\n // Check if it's a union of just string literals (enum)\n const parts = t.split(\"|\").map((p) => p.trim());\n const allStringLiterals = parts.every((p) => /^[\"'].*[\"']$/.test(p));\n if (allStringLiterals) {\n const values = parts.map((p) => p.replace(/^[\"']|[\"']$/g, \"\"));\n return { type: \"enum\", values };\n }\n return { type: \"union\" };\n }\n\n // Anything else\n return { type: \"custom\" };\n}\n\n/**\n * Infer category from component name and props\n */\nfunction inferCategory(componentName: string, props: Record<string, unknown>): string {\n const lower = componentName.toLowerCase();\n\n const categoryPatterns: Record<string, string[]> = {\n \"Actions\": [\"button\", \"action\", \"cta\", \"fab\", \"floatingaction\"],\n \"Forms\": [\"form\", \"input\", \"select\", \"checkbox\", \"radio\", \"textarea\", \"field\", \"textfield\", \"datepicker\", \"switch\", \"slider\", \"segmented\"],\n \"Layout\": [\"layout\", \"container\", \"grid\", \"flex\", \"stack\", \"box\", \"divider\", \"spacer\", \"sidebar\"],\n \"Navigation\": [\"nav\", \"menu\", \"breadcrumb\", \"tab\", \"link\", \"pagination\", \"stepper\", \"topbar\"],\n \"Feedback\": [\"alert\", \"toast\", \"notification\", \"message\", \"badge\", \"indicator\", \"progress\", \"spinner\", \"loading\", \"loader\", \"lozenge\", \"chip\"],\n \"Data Display\": [\"table\", \"list\", \"card\", \"avatar\", \"stat\", \"timeline\", \"tree\", \"datalist\", \"datacard\"],\n \"Overlays\": [\"modal\", \"dialog\", \"drawer\", \"popover\", \"tooltip\", \"dropdown\", \"slidepanel\"],\n \"Typography\": [\"text\", \"heading\", \"title\", \"label\", \"paragraph\"],\n \"Media\": [\"image\", \"video\", \"icon\", \"carousel\"],\n };\n\n for (const [category, patterns] of Object.entries(categoryPatterns)) {\n for (const pattern of patterns) {\n if (lower.includes(pattern)) {\n return category;\n }\n }\n }\n\n if (\"onClick\" in props || \"onPress\" in props) return \"Actions\";\n if (\"value\" in props || \"defaultValue\" in props) return \"Forms\";\n if (\"children\" in props) return \"Layout\";\n\n return \"Components\";\n}\n\n/**\n * Extract component name from story file\n */\nfunction extractComponentNameFromStory(content: string, filePath: string): string | null {\n const titleMatch = content.match(/title:\\s*['\"](?:[^'\"]+\\/)?([^'\"]+)['\"]/);\n if (titleMatch) {\n return titleMatch[1];\n }\n\n const fileName = basename(filePath);\n const componentName = fileName.replace(/\\.stories\\.(tsx?|jsx?)$/, \"\");\n if (/^[A-Z]/.test(componentName)) {\n return componentName;\n }\n\n return null;\n}\n\ninterface StoryVariant {\n name: string;\n args: Record<string, unknown>;\n}\n\n/**\n * Extract story names and their args from story file content (CSF3 format).\n * Parses patterns like:\n * export const Primary: Story = { args: { variant: 'primary', children: 'Click me' } }\n */\nfunction extractStoryVariants(content: string): StoryVariant[] {\n const variants: StoryVariant[] = [];\n\n const exportMatches = content.matchAll(\n /export\\s+const\\s+([A-Z][a-zA-Z0-9]*)\\s*[=:]/g\n );\n\n for (const match of exportMatches) {\n const name = match[1];\n if (name === \"default\" || name.endsWith(\"Args\") || name.endsWith(\"Meta\")) {\n continue;\n }\n\n const args = extractStoryArgs(content, name);\n variants.push({ name, args });\n }\n\n return variants;\n}\n\n/**\n * Extract the `args` object from a named story export.\n * Uses balanced-brace matching to handle nested objects.\n */\nfunction extractStoryArgs(content: string, storyName: string): Record<string, unknown> {\n // Find the story export and look for an args block\n const storyPattern = new RegExp(\n `export\\\\s+const\\\\s+${storyName}[^=]*=\\\\s*\\\\{([\\\\s\\\\S]*?)\\\\n\\\\};`,\n );\n const storyMatch = content.match(storyPattern);\n if (!storyMatch) return {};\n\n const storyBody = storyMatch[1];\n\n // Find the args block within the story body\n const argsStart = storyBody.indexOf('args:');\n if (argsStart === -1) return {};\n\n // Find the opening brace after \"args:\"\n const braceStart = storyBody.indexOf('{', argsStart);\n if (braceStart === -1) return {};\n\n // Balanced brace matching to find the full args object\n let depth = 0;\n let braceEnd = -1;\n for (let i = braceStart; i < storyBody.length; i++) {\n if (storyBody[i] === '{') depth++;\n else if (storyBody[i] === '}') {\n depth--;\n if (depth === 0) {\n braceEnd = i;\n break;\n }\n }\n }\n if (braceEnd === -1) return {};\n\n const argsBlock = storyBody.slice(braceStart + 1, braceEnd).trim();\n return parseArgsBlock(argsBlock);\n}\n\n/**\n * Parse a simplified args block into key-value pairs.\n * Handles string literals, numbers, booleans, and simple expressions.\n */\nfunction parseArgsBlock(argsBlock: string): Record<string, unknown> {\n const args: Record<string, unknown> = {};\n\n // Match key: value pairs (handles string, number, boolean values)\n const pairPattern = /(\\w+)\\s*:\\s*(?:['\"]([^'\"]*?)['\"]|(true|false)|(\\d+(?:\\.\\d+)?))/g;\n let pairMatch: RegExpExecArray | null;\n\n while ((pairMatch = pairPattern.exec(argsBlock)) !== null) {\n const key = pairMatch[1];\n if (pairMatch[2] !== undefined) {\n // String value\n args[key] = pairMatch[2];\n } else if (pairMatch[3] !== undefined) {\n // Boolean\n args[key] = pairMatch[3] === 'true';\n } else if (pairMatch[4] !== undefined) {\n // Number\n args[key] = Number(pairMatch[4]);\n }\n }\n\n return args;\n}\n\n/**\n * Build variant entries from story args.\n * If stories have args, generates JSX with those props.\n * Falls back to a bare `<Component />` for the Default variant.\n */\nfunction buildVariants(componentName: string, storyVariants: StoryVariant[]): string {\n // Filter to variants with args, plus always include a Default\n const hasDefault = storyVariants.some((v) => v.name === 'Default');\n const entries: string[] = [];\n\n if (!hasDefault) {\n entries.push(formatVariantEntry(componentName, 'Default', `Default ${componentName}`, {}));\n }\n\n for (const variant of storyVariants) {\n const description = variant.name\n .replace(/([A-Z])/g, ' $1')\n .trim();\n entries.push(formatVariantEntry(componentName, variant.name, `${description} ${componentName}`, variant.args));\n }\n\n // Deduplicate: if stories provided a Default, don't double-add\n return entries.join('\\n');\n}\n\n/**\n * Format a single variant entry with JSX code and render function.\n * Handles `children` as JSX children, all other args as props.\n */\nfunction formatVariantEntry(\n componentName: string,\n name: string,\n description: string,\n args: Record<string, unknown>\n): string {\n const jsxCode = buildJsxString(componentName, args);\n return ` {\n name: '${escapeQuotes(name)}',\n description: '${escapeQuotes(description)}',\n code: \\`${jsxCode}\\`,\n render: () => ${jsxCode},\n },`;\n}\n\n/**\n * Build a JSX string from component name and args.\n * `children` string args become JSX children, others become props.\n */\nfunction buildJsxString(componentName: string, args: Record<string, unknown>): string {\n const { children, ...restArgs } = args;\n const propParts: string[] = [];\n\n for (const [key, value] of Object.entries(restArgs)) {\n if (typeof value === 'string') {\n propParts.push(`${key}=\"${escapeQuotes(value)}\"`);\n } else if (typeof value === 'boolean') {\n propParts.push(value ? key : `${key}={false}`);\n } else if (typeof value === 'number') {\n propParts.push(`${key}={${value}}`);\n }\n }\n\n const propsStr = propParts.length > 0 ? ' ' + propParts.join(' ') : '';\n\n if (typeof children === 'string') {\n return `<${componentName}${propsStr}>${children}</${componentName}>`;\n }\n\n return `<${componentName}${propsStr} />`;\n}\n\n/**\n * Infer usage scenarios from story names\n */\nfunction inferUsageFromStories(storyNames: string[]): string[] {\n const usage: string[] = [];\n\n for (const name of storyNames) {\n const sentence = name\n .replace(/([A-Z])/g, \" $1\")\n .trim()\n .toLowerCase();\n\n if (\n [\"default\", \"primary\", \"basic\", \"example\", \"playground\"].includes(\n sentence.toLowerCase()\n )\n ) {\n continue;\n }\n\n if (sentence.includes(\"loading\")) {\n usage.push(\"Showing loading states\");\n } else if (sentence.includes(\"disabled\")) {\n usage.push(\"Preventing user interaction\");\n } else if (sentence.includes(\"error\")) {\n usage.push(\"Displaying error states\");\n } else if (sentence.includes(\"success\")) {\n usage.push(\"Showing success feedback\");\n } else if (sentence.includes(\"empty\")) {\n usage.push(\"Handling empty states\");\n } else if (sentence.includes(\"with\")) {\n const withPart = sentence.replace(\"with \", \"\");\n usage.push(`Displaying with ${withPart}`);\n }\n }\n\n return usage;\n}\n\n/**\n * Generate description from component name and props\n */\nfunction generateDescription(\n componentName: string,\n props: Record<string, unknown>\n): string {\n const words = componentName\n .replace(/([A-Z])/g, \" $1\")\n .trim()\n .toLowerCase();\n\n const hasOnClick = \"onClick\" in props || \"onPress\" in props;\n const hasValue = \"value\" in props || \"defaultValue\" in props;\n const hasChildren = \"children\" in props;\n\n if (hasOnClick && !hasValue) {\n return `Interactive ${words} element for triggering actions`;\n }\n\n if (hasValue) {\n return `Form ${words} for user input`;\n }\n\n if (hasChildren) {\n return `Container ${words} for grouping content`;\n }\n\n return `${words.charAt(0).toUpperCase() + words.slice(1)} component`;\n}\n\n/**\n * Infer accessibility from props\n */\nfunction inferAccessibility(props: Record<string, unknown>): {\n role?: string;\n requirements?: string[];\n} {\n const accessibility: { role?: string; requirements?: string[] } = {};\n\n const hasOnClick = \"onClick\" in props || \"onPress\" in props;\n const hasAriaLabel = \"ariaLabel\" in props || \"aria-label\" in props;\n const hasDisabled = \"disabled\" in props;\n const hasHref = \"href\" in props;\n\n if (hasOnClick && !hasHref) {\n accessibility.role = \"button\";\n } else if (hasHref) {\n accessibility.role = \"link\";\n }\n\n const requirements: string[] = [];\n\n if (hasOnClick && !hasAriaLabel) {\n requirements.push(\"Should have visible text or aria-label\");\n }\n\n if (hasDisabled) {\n requirements.push(\"Disabled state should be conveyed to assistive technology\");\n }\n\n if (requirements.length > 0) {\n accessibility.requirements = requirements;\n }\n\n return accessibility;\n}\n\n/**\n * Infer status from file path\n */\nfunction inferStatus(\n filePath: string\n): \"draft\" | \"experimental\" | \"beta\" | \"stable\" | \"deprecated\" {\n const lowerPath = filePath.toLowerCase();\n\n if (lowerPath.includes(\"/experimental/\") || lowerPath.includes(\"/labs/\")) {\n return \"experimental\";\n }\n if (lowerPath.includes(\"/beta/\")) {\n return \"beta\";\n }\n if (lowerPath.includes(\"/deprecated/\") || lowerPath.includes(\"/legacy/\")) {\n return \"deprecated\";\n }\n if (lowerPath.includes(\"/draft/\") || lowerPath.includes(\"/wip/\")) {\n return \"draft\";\n }\n\n return \"stable\";\n}\n"],"mappings":";;;;;;;;;;;;;;AAQA,SAAS,UAAU,WAAW,cAAc;AAC5C,SAAS,SAAS,UAAU,SAAS,UAAU,YAAY;AAC3D,OAAO,QAAQ;AACf,OAAO,QAAQ;AAyBf,eAAsB,SAAS,UAA2B,CAAC,GA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vB;AAEA,QAAM,eAAyB,CAAC;AAEhC,MAAI,cAAc,CAAC,cAAc;AAC/B,iBAAa,KAAK,wCAAwC;AAAA,EAC5D;AAEA,MAAI,aAAa;AACf,iBAAa,KAAK,2DAA2D;AAAA,EAC/E;AAEA,MAAI,aAAa,SAAS,GAAG;AAC3B,kBAAc,eAAe;AAAA,EAC/B;AAEA,SAAO;AACT;AAKA,SAAS,YACP,UAC6D;AAC7D,QAAM,YAAY,SAAS,YAAY;AAEvC,MAAI,UAAU,SAAS,gBAAgB,KAAK,UAAU,SAAS,QAAQ,GAAG;AACxE,WAAO;AAAA,EACT;AACA,MAAI,UAAU,SAAS,QAAQ,GAAG;AAChC,WAAO;AAAA,EACT;AACA,MAAI,UAAU,SAAS,cAAc,KAAK,UAAU,SAAS,UAAU,GAAG;AACxE,WAAO;AAAA,EACT;AACA,MAAI,UAAU,SAAS,SAAS,KAAK,UAAU,SAAS,OAAO,GAAG;AAChE,WAAO;AAAA,EACT;AAEA,SAAO;AACT;","names":[]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { F as FragmentsConfig, T as Theme, D as DiffResult } from './defineFragment-
|
|
2
|
-
export { a as defineBlock, d as defineFragment } from './defineFragment-
|
|
1
|
+
import { F as FragmentsConfig, T as Theme, D as DiffResult } from './defineFragment-CBMS7Bab.js';
|
|
2
|
+
export { a as defineBlock, d as defineFragment } from './defineFragment-CBMS7Bab.js';
|
|
3
3
|
import { CompiledFragmentsFile } from '@fragments-sdk/context/types';
|
|
4
4
|
export { CLI_COMMANDS, CLI_COMMAND_CATEGORIES, CliCategoryInfo, CliCommandCategory, CliCommandDef, CliOptionDef } from '@fragments-sdk/context/cli-commands';
|
|
5
5
|
import 'react';
|
package/dist/index.js
CHANGED
|
@@ -12,11 +12,11 @@ import {
|
|
|
12
12
|
validateCoverage,
|
|
13
13
|
validateSchema,
|
|
14
14
|
validateSnippets
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-D7372LQX.js";
|
|
16
16
|
import {
|
|
17
17
|
findConfigFile,
|
|
18
18
|
loadConfig
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-BW3ZATBW.js";
|
|
20
20
|
import {
|
|
21
21
|
discoverComponentFiles,
|
|
22
22
|
discoverFragmentFiles,
|
|
@@ -26,8 +26,9 @@ import "./chunk-YMPGYEWK.js";
|
|
|
26
26
|
import {
|
|
27
27
|
defineBlock,
|
|
28
28
|
defineFragment
|
|
29
|
-
} from "./chunk-
|
|
30
|
-
import "./chunk-
|
|
29
|
+
} from "./chunk-GF6OVPIN.js";
|
|
30
|
+
import "./chunk-NVSPGSKB.js";
|
|
31
|
+
import "./chunk-EZYXYWNF.js";
|
|
31
32
|
import "./chunk-EKLMXTWU.js";
|
|
32
33
|
import "./chunk-Z7EY4VHE.js";
|
|
33
34
|
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/cli-commands.ts"],"sourcesContent":["/**\n * CLI command metadata — re-exported from @fragments-sdk/context for convenience.\n *\n * The source of truth lives in @fragments-sdk/context/cli-commands so that\n * browser-safe consumers (like the docs site) can import without pulling in\n * Node.js dependencies from the CLI package.\n */\nexport {\n CLI_COMMANDS,\n CLI_COMMAND_CATEGORIES,\n} from '@fragments-sdk/context/cli-commands';\n\nexport type {\n CliCommandDef,\n CliOptionDef,\n CliCommandCategory,\n CliCategoryInfo,\n} from '@fragments-sdk/context/cli-commands';\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/cli-commands.ts"],"sourcesContent":["/**\n * CLI command metadata — re-exported from @fragments-sdk/context for convenience.\n *\n * The source of truth lives in @fragments-sdk/context/cli-commands so that\n * browser-safe consumers (like the docs site) can import without pulling in\n * Node.js dependencies from the CLI package.\n */\nexport {\n CLI_COMMANDS,\n CLI_COMMAND_CATEGORIES,\n} from '@fragments-sdk/context/cli-commands';\n\nexport type {\n CliCommandDef,\n CliOptionDef,\n CliCommandCategory,\n CliCategoryInfo,\n} from '@fragments-sdk/context/cli-commands';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA;AAAA,EACE;AAAA,EACA;AAAA,OACK;","names":[]}
|