@fragments-sdk/cli 0.9.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (166) hide show
  1. package/dist/bin.d.ts +1 -0
  2. package/dist/bin.js +502 -84
  3. package/dist/bin.js.map +1 -1
  4. package/dist/{chunk-CJEGT3WD.js → chunk-566BNPQZ.js} +21 -6
  5. package/dist/chunk-566BNPQZ.js.map +1 -0
  6. package/dist/{chunk-WI6SLMSO.js → chunk-CAMXG5HJ.js} +5 -5
  7. package/dist/chunk-D2CDBRNU.js +2 -0
  8. package/dist/{chunk-YMPGYEWK.js → chunk-D5PYOXEI.js} +2 -2
  9. package/dist/{chunk-NGIMCIK2.js → chunk-OQO55NKV.js} +405 -34
  10. package/dist/chunk-OQO55NKV.js.map +1 -0
  11. package/dist/{chunk-TOIE7VXF.js → chunk-PW7QTQA6.js} +2 -2
  12. package/dist/{chunk-AWYCDRPG.js → chunk-WXSR2II7.js} +2 -2
  13. package/dist/chunk-WXSR2II7.js.map +1 -0
  14. package/dist/{chunk-2JIKCJX3.js → chunk-ZDA3PLQ6.js} +17 -14
  15. package/dist/chunk-ZDA3PLQ6.js.map +1 -0
  16. package/dist/core/index.d.ts +1 -2092
  17. package/dist/core/index.js +26 -21
  18. package/dist/{discovery-Z4RDDFVR.js → discovery-NEOY4MPN.js} +3 -3
  19. package/dist/generate-BGKTKO6E.js +459 -0
  20. package/dist/generate-BGKTKO6E.js.map +1 -0
  21. package/dist/index.d.ts +3 -5
  22. package/dist/index.js +7 -8
  23. package/dist/index.js.map +1 -1
  24. package/dist/{init-KSAAS7X3.js → init-Q53R5Q2T.js} +66 -76
  25. package/dist/init-Q53R5Q2T.js.map +1 -0
  26. package/dist/mcp-bin.js +5 -7
  27. package/dist/mcp-bin.js.map +1 -1
  28. package/dist/scan-OQU7M4GH.js +14 -0
  29. package/dist/scan-generate-T5QNUG7N.js +691 -0
  30. package/dist/scan-generate-T5QNUG7N.js.map +1 -0
  31. package/dist/{service-A5GIGGGK.js → service-TQYWY65E.js} +4 -5
  32. package/dist/{static-viewer-NSODM5VX.js → static-viewer-NUBFPKWH.js} +4 -5
  33. package/dist/static-viewer-NUBFPKWH.js.map +1 -0
  34. package/dist/{test-RPWZAYSJ.js → test-2CSOSS3B.js} +4 -5
  35. package/dist/{test-RPWZAYSJ.js.map → test-2CSOSS3B.js.map} +1 -1
  36. package/dist/{tokens-NIXSZRX7.js → tokens-DXEGYTOJ.js} +6 -7
  37. package/dist/{tokens-NIXSZRX7.js.map → tokens-DXEGYTOJ.js.map} +1 -1
  38. package/dist/{viewer-SBTJDMP7.js → viewer-DBEPYM3G.js} +245 -23
  39. package/dist/viewer-DBEPYM3G.js.map +1 -0
  40. package/package.json +2 -1
  41. package/src/bin.ts +33 -1
  42. package/src/build.ts +13 -3
  43. package/src/commands/__tests__/scan-generate.test.ts +308 -0
  44. package/src/commands/build.ts +16 -2
  45. package/src/commands/generate.ts +383 -68
  46. package/src/commands/init.ts +81 -56
  47. package/src/commands/perf.ts +1 -1
  48. package/src/commands/scan-generate.ts +1013 -0
  49. package/src/commands/setup.ts +499 -0
  50. package/src/core/auto-props.ts +1 -1
  51. package/src/core/bundle-measurer.ts +2 -2
  52. package/src/core/config.ts +16 -4
  53. package/src/core/discovery.ts +2 -2
  54. package/src/core/generators/context.ts +1 -1
  55. package/src/core/generators/registry.ts +3 -3
  56. package/src/core/generators/typescript-extractor.ts +11 -1
  57. package/src/core/graph-extractor.ts +1 -1
  58. package/src/core/index.ts +3 -190
  59. package/src/core/loader.ts +2 -2
  60. package/src/core/parser.ts +1 -1
  61. package/src/core/previewLoader.ts +1 -1
  62. package/src/index.ts +2 -2
  63. package/src/migrate/converter.ts +9 -1
  64. package/src/migrate/parser.ts +2 -0
  65. package/src/migrate/types.ts +2 -0
  66. package/src/service/snippet-validation.test.ts +1 -1
  67. package/src/service/snippet-validation.ts +2 -2
  68. package/src/setup.ts +69 -24
  69. package/src/viewer/__tests__/viewer-integration.test.ts +4 -10
  70. package/src/viewer/components/AccessibilityPanel.tsx +305 -312
  71. package/src/viewer/components/ActionsPanel.tsx +31 -29
  72. package/src/viewer/components/AllVariantsPreview.tsx +78 -0
  73. package/src/viewer/components/App.tsx +187 -740
  74. package/src/viewer/components/BottomPanel.tsx +228 -132
  75. package/src/viewer/components/CodePanel.tsx +1 -1
  76. package/src/viewer/components/CommandPalette.tsx +7 -10
  77. package/src/viewer/components/ComponentDocView.tsx +164 -0
  78. package/src/viewer/components/ComponentGraph.tsx +111 -142
  79. package/src/viewer/components/ContractPanel.tsx +6 -6
  80. package/src/viewer/components/EmptyVariantMessage.tsx +54 -0
  81. package/src/viewer/components/FigmaEmbed.tsx +20 -18
  82. package/src/viewer/components/FragmentEditor.tsx +92 -115
  83. package/src/viewer/components/HeaderSearch.tsx +24 -0
  84. package/src/viewer/components/HealthDashboard.tsx +16 -2
  85. package/src/viewer/components/Icons.tsx +9 -0
  86. package/src/viewer/components/InteractionsPanel.tsx +101 -117
  87. package/src/viewer/components/IsolatedPreviewFrame.tsx +1 -0
  88. package/src/viewer/components/LandingPage.tsx +3 -3
  89. package/src/viewer/components/LeftSidebar.tsx +141 -63
  90. package/src/viewer/components/LoadErrorMessage.tsx +102 -0
  91. package/src/viewer/components/MultiViewportPreview.tsx +61 -142
  92. package/src/viewer/components/NoVariantsMessage.tsx +59 -0
  93. package/src/viewer/components/PanelShell.tsx +161 -0
  94. package/src/viewer/components/PerformancePanel.tsx +31 -28
  95. package/src/viewer/components/PreviewArea.tsx +1 -1
  96. package/src/viewer/components/PreviewAside.tsx +168 -0
  97. package/src/viewer/components/PreviewFrameHost.tsx +3 -3
  98. package/src/viewer/components/PropsEditor.tsx +70 -156
  99. package/src/viewer/components/ResizablePanel.tsx +103 -263
  100. package/src/viewer/components/RightSidebar.tsx +3 -9
  101. package/src/viewer/components/SkeletonLoader.tsx +13 -13
  102. package/src/viewer/components/TokenStylePanel.tsx +182 -209
  103. package/src/viewer/components/TopToolbar.tsx +159 -0
  104. package/src/viewer/components/VariantMatrix.tsx +42 -86
  105. package/src/viewer/components/VariantTabs.tsx +3 -3
  106. package/src/viewer/components/ViewerHeader.tsx +69 -0
  107. package/src/viewer/components/WebMCPDevTools.tsx +17 -23
  108. package/src/viewer/components/viewer-utils.ts +16 -0
  109. package/src/viewer/entry.tsx +5 -0
  110. package/src/viewer/hooks/useAppState.ts +27 -4
  111. package/src/viewer/hooks/usePreviewBridge.ts +2 -2
  112. package/src/viewer/preview-frame.html +6 -12
  113. package/src/viewer/server.ts +169 -2
  114. package/src/viewer/vendor/shared/src/ComponentDocContent.module.scss +10 -0
  115. package/src/viewer/vendor/shared/src/ComponentDocContent.module.scss.d.ts +2 -0
  116. package/src/viewer/vendor/shared/src/ComponentDocContent.tsx +274 -0
  117. package/src/viewer/vendor/shared/src/DocsHeaderBar.tsx +6 -18
  118. package/src/viewer/vendor/shared/src/DocsPageShell.tsx +5 -0
  119. package/src/viewer/vendor/shared/src/DocsSidebarNav.tsx +5 -16
  120. package/src/viewer/vendor/shared/src/PropsTable.module.scss +68 -0
  121. package/src/viewer/vendor/shared/src/PropsTable.module.scss.d.ts +2 -0
  122. package/src/viewer/vendor/shared/src/PropsTable.tsx +76 -0
  123. package/src/viewer/vendor/shared/src/VariantPreviewCard.module.scss +114 -0
  124. package/src/viewer/vendor/shared/src/VariantPreviewCard.module.scss.d.ts +2 -0
  125. package/src/viewer/vendor/shared/src/VariantPreviewCard.tsx +134 -0
  126. package/src/viewer/vendor/shared/src/index.ts +8 -0
  127. package/src/viewer/vendor/shared/src/types.ts +12 -0
  128. package/src/viewer/vite-plugin.ts +109 -4
  129. package/dist/chunk-2JIKCJX3.js.map +0 -1
  130. package/dist/chunk-AWYCDRPG.js.map +0 -1
  131. package/dist/chunk-CJEGT3WD.js.map +0 -1
  132. package/dist/chunk-EKLMXTWU.js +0 -80
  133. package/dist/chunk-EKLMXTWU.js.map +0 -1
  134. package/dist/chunk-GOVI6COW.js +0 -195
  135. package/dist/chunk-GOVI6COW.js.map +0 -1
  136. package/dist/chunk-NGIMCIK2.js.map +0 -1
  137. package/dist/defineFragment-D0UTve-I.d.ts +0 -665
  138. package/dist/generate-35OIMW4Y.js +0 -252
  139. package/dist/generate-35OIMW4Y.js.map +0 -1
  140. package/dist/init-KSAAS7X3.js.map +0 -1
  141. package/dist/scan-65RH3QMM.js +0 -15
  142. package/dist/viewer-SBTJDMP7.js.map +0 -1
  143. package/src/core/__tests__/preview-runtime.test.tsx +0 -111
  144. package/src/core/composition.test.ts +0 -262
  145. package/src/core/composition.ts +0 -318
  146. package/src/core/constants.ts +0 -114
  147. package/src/core/context.ts +0 -2
  148. package/src/core/defineFragment.ts +0 -141
  149. package/src/core/figma.ts +0 -263
  150. package/src/core/fragment-types.ts +0 -214
  151. package/src/core/performance-presets.ts +0 -142
  152. package/src/core/preview-runtime.tsx +0 -144
  153. package/src/core/schema.ts +0 -221
  154. package/src/core/storyAdapter.test.ts +0 -571
  155. package/src/core/storyAdapter.ts +0 -761
  156. package/src/core/storybook-csf.ts +0 -11
  157. package/src/core/token-parser.ts +0 -321
  158. package/src/core/token-types.ts +0 -287
  159. package/src/core/types.ts +0 -762
  160. /package/dist/{chunk-WI6SLMSO.js.map → chunk-CAMXG5HJ.js.map} +0 -0
  161. /package/dist/{discovery-Z4RDDFVR.js.map → chunk-D2CDBRNU.js.map} +0 -0
  162. /package/dist/{chunk-YMPGYEWK.js.map → chunk-D5PYOXEI.js.map} +0 -0
  163. /package/dist/{chunk-TOIE7VXF.js.map → chunk-PW7QTQA6.js.map} +0 -0
  164. /package/dist/{scan-65RH3QMM.js.map → discovery-NEOY4MPN.js.map} +0 -0
  165. /package/dist/{service-A5GIGGGK.js.map → scan-OQU7M4GH.js.map} +0 -0
  166. /package/dist/{static-viewer-NSODM5VX.js.map → service-TQYWY65E.js.map} +0 -0
@@ -1,24 +1,45 @@
1
1
  import { createRequire as __banner_createRequire } from 'module'; const require = __banner_createRequire(import.meta.url);
2
+ import "../chunk-D2CDBRNU.js";
2
3
  import {
4
+ BRAND,
5
+ DEFAULTS,
3
6
  PRESET_NAMES,
4
7
  PreviewVariantRuntime,
8
+ aiMetadataSchema,
5
9
  analyzeComposition,
10
+ blockDefinitionSchema,
6
11
  budgetBar,
12
+ checkStoryExclusion,
7
13
  classifyComplexity,
8
14
  compileBlock,
9
15
  compileFragment,
10
16
  compileRecipe,
17
+ componentRelationSchema,
11
18
  defineBlock,
12
19
  defineFragment,
13
20
  defineRecipe,
21
+ detectSubComponentPaths,
14
22
  executeVariantLoaders,
15
23
  figma,
24
+ figmaPropMappingSchema,
16
25
  formatBytes,
26
+ fragmentBanSchema,
27
+ fragmentContractSchema,
28
+ fragmentDefinitionSchema,
29
+ fragmentGeneratedSchema,
30
+ fragmentMetaSchema,
31
+ fragmentUsageSchema,
32
+ fragmentVariantSchema,
33
+ fragmentsConfigSchema,
17
34
  generateContext,
18
35
  getPreviewConfig,
36
+ isConfigExcluded,
19
37
  isExportStory,
20
38
  isFigmaPropMapping,
39
+ isForceIncluded,
21
40
  parseTokenFile,
41
+ propDefinitionSchema,
42
+ recipeDefinitionSchema,
22
43
  resolveFigmaMapping,
23
44
  resolvePerformanceConfig,
24
45
  resolvePreviewRuntimeState,
@@ -27,27 +48,7 @@ import {
27
48
  storyNameFromExport,
28
49
  toId,
29
50
  usePreviewVariantRuntime
30
- } from "../chunk-NGIMCIK2.js";
31
- import {
32
- aiMetadataSchema,
33
- blockDefinitionSchema,
34
- componentRelationSchema,
35
- figmaPropMappingSchema,
36
- fragmentBanSchema,
37
- fragmentContractSchema,
38
- fragmentDefinitionSchema,
39
- fragmentGeneratedSchema,
40
- fragmentMetaSchema,
41
- fragmentUsageSchema,
42
- fragmentVariantSchema,
43
- fragmentsConfigSchema,
44
- propDefinitionSchema,
45
- recipeDefinitionSchema
46
- } from "../chunk-GOVI6COW.js";
47
- import {
48
- BRAND,
49
- DEFAULTS
50
- } from "../chunk-EKLMXTWU.js";
51
+ } from "../chunk-OQO55NKV.js";
51
52
  import "../chunk-Z7EY4VHE.js";
52
53
  export {
53
54
  BRAND,
@@ -58,6 +59,7 @@ export {
58
59
  analyzeComposition,
59
60
  blockDefinitionSchema,
60
61
  budgetBar,
62
+ checkStoryExclusion,
61
63
  classifyComplexity,
62
64
  compileBlock,
63
65
  compileFragment,
@@ -66,6 +68,7 @@ export {
66
68
  defineBlock,
67
69
  defineFragment,
68
70
  defineRecipe,
71
+ detectSubComponentPaths,
69
72
  executeVariantLoaders,
70
73
  figma,
71
74
  figmaPropMappingSchema,
@@ -80,8 +83,10 @@ export {
80
83
  fragmentsConfigSchema,
81
84
  generateContext,
82
85
  getPreviewConfig,
86
+ isConfigExcluded,
83
87
  isExportStory,
84
88
  isFigmaPropMapping,
89
+ isForceIncluded,
85
90
  parseTokenFile,
86
91
  propDefinitionSchema,
87
92
  recipeDefinitionSchema,
@@ -10,8 +10,8 @@ import {
10
10
  discoverRecipeFiles,
11
11
  discoverTokenFiles,
12
12
  extractComponentName
13
- } from "./chunk-AWYCDRPG.js";
14
- import "./chunk-EKLMXTWU.js";
13
+ } from "./chunk-WXSR2II7.js";
14
+ import "./chunk-OQO55NKV.js";
15
15
  import "./chunk-Z7EY4VHE.js";
16
16
  export {
17
17
  discoverAllComponents,
@@ -25,4 +25,4 @@ export {
25
25
  discoverTokenFiles,
26
26
  extractComponentName
27
27
  };
28
- //# sourceMappingURL=discovery-Z4RDDFVR.js.map
28
+ //# sourceMappingURL=discovery-NEOY4MPN.js.map
@@ -0,0 +1,459 @@
1
+ import { createRequire as __banner_createRequire } from 'module'; const require = __banner_createRequire(import.meta.url);
2
+ import {
3
+ extractPropsFromFile
4
+ } from "./chunk-566BNPQZ.js";
5
+ import "./chunk-WXSR2II7.js";
6
+ import "./chunk-D2CDBRNU.js";
7
+ import {
8
+ BRAND
9
+ } from "./chunk-OQO55NKV.js";
10
+ import "./chunk-Z7EY4VHE.js";
11
+
12
+ // src/commands/generate.ts
13
+ import { readFile, writeFile, access } from "fs/promises";
14
+ import { resolve, basename, dirname, relative, join } from "path";
15
+ import pc from "picocolors";
16
+ import fg from "fast-glob";
17
+ async function generate(options = {}) {
18
+ const projectRoot = resolve(options.projectRoot || process.cwd());
19
+ const generated = [];
20
+ const skipped = [];
21
+ const errors = [];
22
+ console.log(pc.cyan(`
23
+ ${BRAND.name} Generate
24
+ `));
25
+ const componentPattern = options.componentPattern || "src/components/**/*.tsx";
26
+ const componentFiles = await fg(componentPattern, {
27
+ cwd: projectRoot,
28
+ ignore: [
29
+ "**/node_modules/**",
30
+ "**/*.stories.*",
31
+ "**/*.fragment.*",
32
+ "**/*.test.*",
33
+ "**/*.spec.*",
34
+ "**/*.d.ts",
35
+ "**/index.tsx"
36
+ // Often just re-exports
37
+ ],
38
+ absolute: true
39
+ });
40
+ const storyFiles = await fg(["src/**/*.stories.tsx", "src/**/*.stories.ts"], {
41
+ cwd: projectRoot,
42
+ ignore: ["**/node_modules/**"],
43
+ absolute: true
44
+ });
45
+ const storyMap = /* @__PURE__ */ new Map();
46
+ for (const storyFile of storyFiles) {
47
+ try {
48
+ const content = await readFile(storyFile, "utf-8");
49
+ const componentName = extractComponentNameFromStory(content, storyFile);
50
+ if (componentName) {
51
+ const variants = extractStoryVariants(content);
52
+ storyMap.set(componentName, variants);
53
+ }
54
+ } catch {
55
+ }
56
+ }
57
+ console.log(pc.dim(`Found ${componentFiles.length} component files
58
+ `));
59
+ for (const filePath of componentFiles) {
60
+ try {
61
+ const extracted = extractPropsFromFile(filePath);
62
+ if (!extracted || !extracted.componentName) {
63
+ continue;
64
+ }
65
+ const componentName = extracted.componentName;
66
+ if (options.component && componentName !== options.component) {
67
+ continue;
68
+ }
69
+ const componentDir = dirname(filePath);
70
+ const componentBaseName = basename(filePath, ".tsx");
71
+ const fragmentPath = join(componentDir, `${componentBaseName}${BRAND.fileExtension}`);
72
+ let fragmentExists = false;
73
+ try {
74
+ await access(fragmentPath);
75
+ fragmentExists = true;
76
+ } catch {
77
+ }
78
+ if (fragmentExists && !options.force) {
79
+ skipped.push({ name: componentName, reason: "Fragment already exists" });
80
+ console.log(pc.dim(` Skipping ${componentName} (fragment exists)`));
81
+ continue;
82
+ }
83
+ const storyVariants = storyMap.get(componentName) || [];
84
+ const fragmentContent = generateFragmentTsx(
85
+ componentName,
86
+ componentBaseName,
87
+ extracted,
88
+ filePath,
89
+ storyVariants
90
+ );
91
+ await writeFile(fragmentPath, fragmentContent, "utf-8");
92
+ generated.push({ name: componentName, path: relative(projectRoot, fragmentPath) });
93
+ console.log(pc.green(` \u2713 Generated ${componentName}${BRAND.fileExtension}`));
94
+ } catch (e) {
95
+ const fileName = basename(filePath);
96
+ errors.push({
97
+ name: fileName,
98
+ error: e instanceof Error ? e.message : String(e)
99
+ });
100
+ console.log(pc.red(` \u2717 Failed: ${fileName}`));
101
+ }
102
+ }
103
+ console.log();
104
+ if (generated.length > 0) {
105
+ console.log(pc.green(`\u2713 Generated ${generated.length} fragment(s)`));
106
+ }
107
+ if (skipped.length > 0) {
108
+ console.log(pc.dim(` Skipped ${skipped.length} (use --force to overwrite)`));
109
+ }
110
+ if (errors.length > 0) {
111
+ console.log(pc.yellow(` ${errors.length} error(s)`));
112
+ }
113
+ console.log();
114
+ return {
115
+ success: errors.length === 0,
116
+ generated,
117
+ skipped,
118
+ errors
119
+ };
120
+ }
121
+ function generateFragmentTsx(componentName, componentBaseName, extracted, filePath, storyVariants) {
122
+ const storyNames = storyVariants.map((v) => v.name);
123
+ const whenToUse = inferUsageFromStories(storyNames);
124
+ const description = generateDescription(componentName, extracted.props);
125
+ const status = inferStatus(filePath);
126
+ const accessibility = inferAccessibility(extracted.props);
127
+ const propsEntries = Object.entries(extracted.props || {});
128
+ const whenLines = whenToUse.length > 0 ? whenToUse.map((w) => ` '${escapeQuotes(w)}',`).join("\n") : ` 'TODO: describe when to use ${componentName}',`;
129
+ let propsBlock = "{}";
130
+ if (propsEntries.length > 0) {
131
+ const propLines = propsEntries.map(([name, info]) => {
132
+ const propInfo = info;
133
+ const rawType = propInfo.type ? String(propInfo.type) : "";
134
+ const classified = classifyPropType(rawType);
135
+ const desc = propInfo.description ? String(propInfo.description).replace(/\n/g, " ") : "";
136
+ const required = propInfo.required ? "true" : "false";
137
+ const parts = [` type: '${classified.type}'`];
138
+ if (desc) parts.push(` description: '${escapeQuotes(desc)}'`);
139
+ parts.push(` required: ${required}`);
140
+ if (propInfo.default !== void 0) {
141
+ parts.push(` default: ${JSON.stringify(propInfo.default)}`);
142
+ }
143
+ const values = classified.values || (propInfo.values && Array.isArray(propInfo.values) ? propInfo.values : null);
144
+ if (values && values.length > 0) {
145
+ parts.push(` values: ${JSON.stringify(values)}`);
146
+ }
147
+ return ` ${name}: {
148
+ ${parts.join(",\n")},
149
+ }`;
150
+ });
151
+ propsBlock = `{
152
+ ${propLines.join(",\n")},
153
+ }`;
154
+ }
155
+ let accessibilityBlock = "";
156
+ if (accessibility.role || accessibility.requirements && accessibility.requirements.length > 0) {
157
+ const parts = [];
158
+ if (accessibility.role) {
159
+ parts.push(` role: '${accessibility.role}'`);
160
+ }
161
+ if (accessibility.requirements && accessibility.requirements.length > 0) {
162
+ const reqs = accessibility.requirements.map((r) => `'${escapeQuotes(r)}'`).join(", ");
163
+ parts.push(` requirements: [${reqs}]`);
164
+ }
165
+ accessibilityBlock = `
166
+
167
+ accessibility: {
168
+ ${parts.join(",\n")},
169
+ },`;
170
+ }
171
+ const variants = buildVariants(componentName, storyVariants);
172
+ const componentImportStatement = extracted.isDefaultExport ? `import ${componentName} from './${componentBaseName}';` : `import { ${componentName} } from './${componentBaseName}';`;
173
+ return `import React from 'react';
174
+ import { defineFragment } from '@fragments-sdk/cli/core';
175
+ ${componentImportStatement}
176
+
177
+ export default defineFragment({
178
+ component: ${componentName},
179
+
180
+ meta: {
181
+ name: '${escapeQuotes(componentName)}',
182
+ description: '${escapeQuotes(description)}',
183
+ category: '${inferCategory(componentName, extracted.props)}',
184
+ status: '${status}',
185
+ },
186
+
187
+ usage: {
188
+ when: [
189
+ ${whenLines}
190
+ ],
191
+ whenNot: [],
192
+ },
193
+
194
+ props: ${propsBlock},${accessibilityBlock}
195
+
196
+ variants: [
197
+ ${variants}
198
+ ],
199
+ });
200
+ `;
201
+ }
202
+ function escapeQuotes(str) {
203
+ return str.replace(/'/g, "\\'");
204
+ }
205
+ function classifyPropType(rawType) {
206
+ const t = rawType.replace(/\s+/g, " ").trim();
207
+ const lower = t.toLowerCase();
208
+ if (lower === "string") return { type: "string" };
209
+ if (lower === "number") return { type: "number" };
210
+ if (lower === "boolean" || lower === "bool") return { type: "boolean" };
211
+ if (/^["'][^"']*["'](\s*\|\s*["'][^"']*["'])*$/.test(t)) {
212
+ const values = [...t.matchAll(/["']([^"']+)["']/g)].map((m) => m[1]);
213
+ if (values.length > 0) return { type: "enum", values };
214
+ }
215
+ if (lower.includes("=>") || lower.includes("handler") || lower.includes("callback") || lower.includes("dispatch") || lower.includes("listener") || /^\(/.test(t)) {
216
+ return { type: "function" };
217
+ }
218
+ if (lower.includes("reactnode") || lower.includes("react.reactnode") || lower === "node") {
219
+ return { type: "node" };
220
+ }
221
+ if (lower.includes("reactelement") || lower.includes("react.reactelement") || lower.includes("jsx.element")) {
222
+ return { type: "element" };
223
+ }
224
+ if (lower.includes("[]") || lower.startsWith("array<") || lower.startsWith("readonly ")) {
225
+ return { type: "array" };
226
+ }
227
+ if (lower.startsWith("{") || lower.includes("record<") || lower === "object") {
228
+ return { type: "object" };
229
+ }
230
+ if (lower.includes("|")) {
231
+ const parts = t.split("|").map((p) => p.trim());
232
+ const allStringLiterals = parts.every((p) => /^["'].*["']$/.test(p));
233
+ if (allStringLiterals) {
234
+ const values = parts.map((p) => p.replace(/^["']|["']$/g, ""));
235
+ return { type: "enum", values };
236
+ }
237
+ return { type: "union" };
238
+ }
239
+ return { type: "custom" };
240
+ }
241
+ function inferCategory(componentName, props) {
242
+ const lower = componentName.toLowerCase();
243
+ const categoryPatterns = {
244
+ "Actions": ["button", "action", "cta", "fab", "floatingaction"],
245
+ "Forms": ["form", "input", "select", "checkbox", "radio", "textarea", "field", "textfield", "datepicker", "switch", "slider", "segmented"],
246
+ "Layout": ["layout", "container", "grid", "flex", "stack", "box", "divider", "spacer", "sidebar"],
247
+ "Navigation": ["nav", "menu", "breadcrumb", "tab", "link", "pagination", "stepper", "topbar"],
248
+ "Feedback": ["alert", "toast", "notification", "message", "badge", "indicator", "progress", "spinner", "loading", "loader", "lozenge", "chip"],
249
+ "Data Display": ["table", "list", "card", "avatar", "stat", "timeline", "tree", "datalist", "datacard"],
250
+ "Overlays": ["modal", "dialog", "drawer", "popover", "tooltip", "dropdown", "slidepanel"],
251
+ "Typography": ["text", "heading", "title", "label", "paragraph"],
252
+ "Media": ["image", "video", "icon", "carousel"]
253
+ };
254
+ for (const [category, patterns] of Object.entries(categoryPatterns)) {
255
+ for (const pattern of patterns) {
256
+ if (lower.includes(pattern)) {
257
+ return category;
258
+ }
259
+ }
260
+ }
261
+ if ("onClick" in props || "onPress" in props) return "Actions";
262
+ if ("value" in props || "defaultValue" in props) return "Forms";
263
+ if ("children" in props) return "Layout";
264
+ return "Components";
265
+ }
266
+ function extractComponentNameFromStory(content, filePath) {
267
+ const titleMatch = content.match(/title:\s*['"](?:[^'"]+\/)?([^'"]+)['"]/);
268
+ if (titleMatch) {
269
+ return titleMatch[1];
270
+ }
271
+ const fileName = basename(filePath);
272
+ const componentName = fileName.replace(/\.stories\.(tsx?|jsx?)$/, "");
273
+ if (/^[A-Z]/.test(componentName)) {
274
+ return componentName;
275
+ }
276
+ return null;
277
+ }
278
+ function extractStoryVariants(content) {
279
+ const variants = [];
280
+ const exportMatches = content.matchAll(
281
+ /export\s+const\s+([A-Z][a-zA-Z0-9]*)\s*[=:]/g
282
+ );
283
+ for (const match of exportMatches) {
284
+ const name = match[1];
285
+ if (name === "default" || name.endsWith("Args") || name.endsWith("Meta")) {
286
+ continue;
287
+ }
288
+ const args = extractStoryArgs(content, name);
289
+ variants.push({ name, args });
290
+ }
291
+ return variants;
292
+ }
293
+ function extractStoryArgs(content, storyName) {
294
+ const storyPattern = new RegExp(
295
+ `export\\s+const\\s+${storyName}[^=]*=\\s*\\{([\\s\\S]*?)\\n\\};`
296
+ );
297
+ const storyMatch = content.match(storyPattern);
298
+ if (!storyMatch) return {};
299
+ const storyBody = storyMatch[1];
300
+ const argsStart = storyBody.indexOf("args:");
301
+ if (argsStart === -1) return {};
302
+ const braceStart = storyBody.indexOf("{", argsStart);
303
+ if (braceStart === -1) return {};
304
+ let depth = 0;
305
+ let braceEnd = -1;
306
+ for (let i = braceStart; i < storyBody.length; i++) {
307
+ if (storyBody[i] === "{") depth++;
308
+ else if (storyBody[i] === "}") {
309
+ depth--;
310
+ if (depth === 0) {
311
+ braceEnd = i;
312
+ break;
313
+ }
314
+ }
315
+ }
316
+ if (braceEnd === -1) return {};
317
+ const argsBlock = storyBody.slice(braceStart + 1, braceEnd).trim();
318
+ return parseArgsBlock(argsBlock);
319
+ }
320
+ function parseArgsBlock(argsBlock) {
321
+ const args = {};
322
+ const pairPattern = /(\w+)\s*:\s*(?:['"]([^'"]*?)['"]|(true|false)|(\d+(?:\.\d+)?))/g;
323
+ let pairMatch;
324
+ while ((pairMatch = pairPattern.exec(argsBlock)) !== null) {
325
+ const key = pairMatch[1];
326
+ if (pairMatch[2] !== void 0) {
327
+ args[key] = pairMatch[2];
328
+ } else if (pairMatch[3] !== void 0) {
329
+ args[key] = pairMatch[3] === "true";
330
+ } else if (pairMatch[4] !== void 0) {
331
+ args[key] = Number(pairMatch[4]);
332
+ }
333
+ }
334
+ return args;
335
+ }
336
+ function buildVariants(componentName, storyVariants) {
337
+ const hasDefault = storyVariants.some((v) => v.name === "Default");
338
+ const entries = [];
339
+ if (!hasDefault) {
340
+ entries.push(formatVariantEntry(componentName, "Default", `Default ${componentName}`, {}));
341
+ }
342
+ for (const variant of storyVariants) {
343
+ const description = variant.name.replace(/([A-Z])/g, " $1").trim();
344
+ entries.push(formatVariantEntry(componentName, variant.name, `${description} ${componentName}`, variant.args));
345
+ }
346
+ return entries.join("\n");
347
+ }
348
+ function formatVariantEntry(componentName, name, description, args) {
349
+ const jsxCode = buildJsxString(componentName, args);
350
+ return ` {
351
+ name: '${escapeQuotes(name)}',
352
+ description: '${escapeQuotes(description)}',
353
+ code: \`${jsxCode}\`,
354
+ render: () => ${jsxCode},
355
+ },`;
356
+ }
357
+ function buildJsxString(componentName, args) {
358
+ const { children, ...restArgs } = args;
359
+ const propParts = [];
360
+ for (const [key, value] of Object.entries(restArgs)) {
361
+ if (typeof value === "string") {
362
+ propParts.push(`${key}="${escapeQuotes(value)}"`);
363
+ } else if (typeof value === "boolean") {
364
+ propParts.push(value ? key : `${key}={false}`);
365
+ } else if (typeof value === "number") {
366
+ propParts.push(`${key}={${value}}`);
367
+ }
368
+ }
369
+ const propsStr = propParts.length > 0 ? " " + propParts.join(" ") : "";
370
+ if (typeof children === "string") {
371
+ return `<${componentName}${propsStr}>${children}</${componentName}>`;
372
+ }
373
+ return `<${componentName}${propsStr} />`;
374
+ }
375
+ function inferUsageFromStories(storyNames) {
376
+ const usage = [];
377
+ for (const name of storyNames) {
378
+ const sentence = name.replace(/([A-Z])/g, " $1").trim().toLowerCase();
379
+ if (["default", "primary", "basic", "example", "playground"].includes(
380
+ sentence.toLowerCase()
381
+ )) {
382
+ continue;
383
+ }
384
+ if (sentence.includes("loading")) {
385
+ usage.push("Showing loading states");
386
+ } else if (sentence.includes("disabled")) {
387
+ usage.push("Preventing user interaction");
388
+ } else if (sentence.includes("error")) {
389
+ usage.push("Displaying error states");
390
+ } else if (sentence.includes("success")) {
391
+ usage.push("Showing success feedback");
392
+ } else if (sentence.includes("empty")) {
393
+ usage.push("Handling empty states");
394
+ } else if (sentence.includes("with")) {
395
+ const withPart = sentence.replace("with ", "");
396
+ usage.push(`Displaying with ${withPart}`);
397
+ }
398
+ }
399
+ return usage;
400
+ }
401
+ function generateDescription(componentName, props) {
402
+ const words = componentName.replace(/([A-Z])/g, " $1").trim().toLowerCase();
403
+ const hasOnClick = "onClick" in props || "onPress" in props;
404
+ const hasValue = "value" in props || "defaultValue" in props;
405
+ const hasChildren = "children" in props;
406
+ if (hasOnClick && !hasValue) {
407
+ return `Interactive ${words} element for triggering actions`;
408
+ }
409
+ if (hasValue) {
410
+ return `Form ${words} for user input`;
411
+ }
412
+ if (hasChildren) {
413
+ return `Container ${words} for grouping content`;
414
+ }
415
+ return `${words.charAt(0).toUpperCase() + words.slice(1)} component`;
416
+ }
417
+ function inferAccessibility(props) {
418
+ const accessibility = {};
419
+ const hasOnClick = "onClick" in props || "onPress" in props;
420
+ const hasAriaLabel = "ariaLabel" in props || "aria-label" in props;
421
+ const hasDisabled = "disabled" in props;
422
+ const hasHref = "href" in props;
423
+ if (hasOnClick && !hasHref) {
424
+ accessibility.role = "button";
425
+ } else if (hasHref) {
426
+ accessibility.role = "link";
427
+ }
428
+ const requirements = [];
429
+ if (hasOnClick && !hasAriaLabel) {
430
+ requirements.push("Should have visible text or aria-label");
431
+ }
432
+ if (hasDisabled) {
433
+ requirements.push("Disabled state should be conveyed to assistive technology");
434
+ }
435
+ if (requirements.length > 0) {
436
+ accessibility.requirements = requirements;
437
+ }
438
+ return accessibility;
439
+ }
440
+ function inferStatus(filePath) {
441
+ const lowerPath = filePath.toLowerCase();
442
+ if (lowerPath.includes("/experimental/") || lowerPath.includes("/labs/")) {
443
+ return "experimental";
444
+ }
445
+ if (lowerPath.includes("/beta/")) {
446
+ return "beta";
447
+ }
448
+ if (lowerPath.includes("/deprecated/") || lowerPath.includes("/legacy/")) {
449
+ return "deprecated";
450
+ }
451
+ if (lowerPath.includes("/draft/") || lowerPath.includes("/wip/")) {
452
+ return "draft";
453
+ }
454
+ return "stable";
455
+ }
456
+ export {
457
+ generate
458
+ };
459
+ //# sourceMappingURL=generate-BGKTKO6E.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,GAA4B;AACrF,QAAM,cAAc,QAAQ,QAAQ,eAAe,QAAQ,IAAI,CAAC;AAChE,QAAM,YAAmD,CAAC;AAC1D,QAAM,UAAmD,CAAC;AAC1D,QAAM,SAAiD,CAAC;AAExD,UAAQ,IAAI,GAAG,KAAK;AAAA,EAAK,MAAM,IAAI;AAAA,CAAa,CAAC;AAGjD,QAAM,mBACJ,QAAQ,oBACR;AAEF,QAAM,iBAAiB,MAAM,GAAG,kBAAkB;AAAA,IAChD,KAAK;AAAA,IACL,QAAQ;AAAA,MACN;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAAA,IACF;AAAA,IACA,UAAU;AAAA,EACZ,CAAC;AAGD,QAAM,aAAa,MAAM,GAAG,CAAC,wBAAwB,qBAAqB,GAAG;AAAA,IAC3E,KAAK;AAAA,IACL,QAAQ,CAAC,oBAAoB;AAAA,IAC7B,UAAU;AAAA,EACZ,CAAC;AAGD,QAAM,WAAW,oBAAI,IAA4B;AACjD,aAAW,aAAa,YAAY;AAClC,QAAI;AACF,YAAM,UAAU,MAAM,SAAS,WAAW,OAAO;AACjD,YAAM,gBAAgB,8BAA8B,SA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