@tpitre/story-ui 3.6.2 → 3.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +36 -32
- package/dist/cli/index.js +0 -5
- package/dist/cli/setup.js +1 -1
- package/dist/mcp-server/routes/generateStory.d.ts.map +1 -1
- package/dist/mcp-server/routes/generateStory.js +142 -87
- package/dist/mcp-server/routes/generateStoryStream.d.ts.map +1 -1
- package/dist/mcp-server/routes/generateStoryStream.js +149 -31
- package/dist/story-generator/dynamicPackageDiscovery.d.ts +35 -2
- package/dist/story-generator/dynamicPackageDiscovery.d.ts.map +1 -1
- package/dist/story-generator/dynamicPackageDiscovery.js +332 -6
- package/dist/story-generator/enhancedComponentDiscovery.d.ts.map +1 -1
- package/dist/story-generator/enhancedComponentDiscovery.js +149 -2
- package/dist/story-generator/framework-adapters/base-adapter.d.ts +1 -0
- package/dist/story-generator/framework-adapters/base-adapter.d.ts.map +1 -1
- package/dist/story-generator/framework-adapters/base-adapter.js +12 -2
- package/dist/story-generator/framework-adapters/react-adapter.d.ts.map +1 -1
- package/dist/story-generator/framework-adapters/react-adapter.js +2 -0
- package/dist/story-generator/framework-adapters/svelte-adapter.d.ts.map +1 -1
- package/dist/story-generator/framework-adapters/svelte-adapter.js +53 -7
- package/dist/story-generator/framework-adapters/vue-adapter.d.ts.map +1 -1
- package/dist/story-generator/framework-adapters/vue-adapter.js +21 -1
- package/dist/story-generator/framework-adapters/web-components-adapter.d.ts.map +1 -1
- package/dist/story-generator/framework-adapters/web-components-adapter.js +4 -0
- package/dist/story-generator/llm-providers/openai-provider.js +2 -2
- package/dist/story-generator/promptGenerator.d.ts.map +1 -1
- package/dist/story-generator/promptGenerator.js +179 -26
- package/dist/story-generator/selfHealingLoop.d.ts +112 -0
- package/dist/story-generator/selfHealingLoop.d.ts.map +1 -0
- package/dist/story-generator/selfHealingLoop.js +202 -0
- package/dist/story-generator/validateStory.d.ts.map +1 -1
- package/dist/story-generator/validateStory.js +81 -12
- package/dist/story-ui.config.d.ts +2 -0
- package/dist/story-ui.config.d.ts.map +1 -1
- package/dist/templates/StoryUI/StoryUIPanel.d.ts +0 -5
- package/dist/templates/StoryUI/StoryUIPanel.d.ts.map +1 -1
- package/dist/templates/StoryUI/StoryUIPanel.js +411 -223
- package/package.json +4 -4
- package/templates/StoryUI/StoryUIPanel.mdx +84 -0
- package/templates/StoryUI/StoryUIPanel.tsx +493 -265
- package/dist/templates/StoryUI/StoryUIPanel.stories.d.ts +0 -18
- package/dist/templates/StoryUI/StoryUIPanel.stories.d.ts.map +0 -1
- package/dist/templates/StoryUI/StoryUIPanel.stories.js +0 -37
- package/templates/StoryUI/StoryUIPanel.stories.tsx +0 -44
- package/templates/StoryUI/manager.tsx +0 -859
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Self-Healing Loop for Story Generation
|
|
3
|
+
*
|
|
4
|
+
* Provides LLM-assisted error correction when validation fails
|
|
5
|
+
* and auto-fix cannot repair the code.
|
|
6
|
+
*
|
|
7
|
+
* Design-system agnostic - uses discovered components from the user's project.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Check if validation errors object is empty (no errors)
|
|
11
|
+
*/
|
|
12
|
+
export function hasNoErrors(errors) {
|
|
13
|
+
return (errors.syntaxErrors.length === 0 &&
|
|
14
|
+
errors.patternErrors.length === 0 &&
|
|
15
|
+
errors.importErrors.length === 0);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Get total error count
|
|
19
|
+
*/
|
|
20
|
+
export function getTotalErrorCount(errors) {
|
|
21
|
+
return (errors.syntaxErrors.length +
|
|
22
|
+
errors.patternErrors.length +
|
|
23
|
+
errors.importErrors.length);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Create empty validation errors object
|
|
27
|
+
*/
|
|
28
|
+
export function createEmptyErrors() {
|
|
29
|
+
return {
|
|
30
|
+
syntaxErrors: [],
|
|
31
|
+
patternErrors: [],
|
|
32
|
+
importErrors: [],
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Aggregate validation errors from different validation systems
|
|
37
|
+
*/
|
|
38
|
+
export function aggregateValidationErrors(astResult, patternErrors, importErrors) {
|
|
39
|
+
const errors = createEmptyErrors();
|
|
40
|
+
// Add AST validation errors
|
|
41
|
+
if (astResult && !astResult.isValid) {
|
|
42
|
+
errors.syntaxErrors = [...astResult.errors];
|
|
43
|
+
}
|
|
44
|
+
// Add pattern validation errors
|
|
45
|
+
if (patternErrors && patternErrors.length > 0) {
|
|
46
|
+
errors.patternErrors = patternErrors.map((e) => `Line ${e.line}: ${e.message}`);
|
|
47
|
+
}
|
|
48
|
+
// Add import validation errors
|
|
49
|
+
if (importErrors && importErrors.length > 0) {
|
|
50
|
+
errors.importErrors = [...importErrors];
|
|
51
|
+
}
|
|
52
|
+
return errors;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Determine if we should continue retrying based on error history
|
|
56
|
+
*/
|
|
57
|
+
export function shouldContinueRetrying(attempts, maxAttempts, errorHistory) {
|
|
58
|
+
// Don't exceed max attempts
|
|
59
|
+
if (attempts >= maxAttempts) {
|
|
60
|
+
return { shouldRetry: false, reason: 'Maximum retry attempts reached' };
|
|
61
|
+
}
|
|
62
|
+
// If we have at least 2 attempts, check if errors are repeating
|
|
63
|
+
if (errorHistory.length >= 2) {
|
|
64
|
+
const currentErrors = errorHistory[errorHistory.length - 1];
|
|
65
|
+
const previousErrors = errorHistory[errorHistory.length - 2];
|
|
66
|
+
// Convert to sets for comparison
|
|
67
|
+
const currentSet = new Set([
|
|
68
|
+
...currentErrors.syntaxErrors,
|
|
69
|
+
...currentErrors.patternErrors,
|
|
70
|
+
...currentErrors.importErrors,
|
|
71
|
+
]);
|
|
72
|
+
const previousSet = new Set([
|
|
73
|
+
...previousErrors.syntaxErrors,
|
|
74
|
+
...previousErrors.patternErrors,
|
|
75
|
+
...previousErrors.importErrors,
|
|
76
|
+
]);
|
|
77
|
+
// Check if same errors are repeating (LLM is stuck)
|
|
78
|
+
if (currentSet.size === previousSet.size) {
|
|
79
|
+
let allSame = true;
|
|
80
|
+
for (const error of currentSet) {
|
|
81
|
+
if (!previousSet.has(error)) {
|
|
82
|
+
allSame = false;
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
if (allSame && currentSet.size > 0) {
|
|
87
|
+
return {
|
|
88
|
+
shouldRetry: false,
|
|
89
|
+
reason: 'Same errors repeating - LLM appears stuck',
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return { shouldRetry: true, reason: '' };
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Build the self-healing prompt to send to the LLM
|
|
98
|
+
* Design-system agnostic - uses discovered components
|
|
99
|
+
*/
|
|
100
|
+
export function buildSelfHealingPrompt(originalCode, errors, attempt, options) {
|
|
101
|
+
const sections = [];
|
|
102
|
+
sections.push(`## CODE CORRECTION REQUIRED (Attempt ${attempt} of ${options.maxAttempts})`);
|
|
103
|
+
sections.push('');
|
|
104
|
+
sections.push('Your previous code contained errors. Please fix them while preserving the original intent.');
|
|
105
|
+
sections.push('');
|
|
106
|
+
// Syntax errors section
|
|
107
|
+
if (errors.syntaxErrors.length > 0) {
|
|
108
|
+
sections.push('### TypeScript Syntax Errors');
|
|
109
|
+
sections.push('These prevent the code from compiling:');
|
|
110
|
+
errors.syntaxErrors.forEach((e) => sections.push(`- ${e}`));
|
|
111
|
+
sections.push('');
|
|
112
|
+
}
|
|
113
|
+
// Pattern errors section
|
|
114
|
+
if (errors.patternErrors.length > 0) {
|
|
115
|
+
sections.push('### Forbidden Patterns');
|
|
116
|
+
sections.push('These patterns are not allowed in this codebase:');
|
|
117
|
+
errors.patternErrors.forEach((e) => sections.push(`- ${e}`));
|
|
118
|
+
sections.push('');
|
|
119
|
+
}
|
|
120
|
+
// Import errors section
|
|
121
|
+
if (errors.importErrors.length > 0) {
|
|
122
|
+
sections.push('### Import Errors');
|
|
123
|
+
sections.push(`These components do not exist in "${options.importPath}":`);
|
|
124
|
+
errors.importErrors.forEach((e) => sections.push(`- ${e}`));
|
|
125
|
+
sections.push('');
|
|
126
|
+
// Show available components (design-system agnostic)
|
|
127
|
+
if (options.availableComponents.length > 0) {
|
|
128
|
+
sections.push('**Available components include:**');
|
|
129
|
+
const displayComponents = options.availableComponents.slice(0, 20);
|
|
130
|
+
sections.push(displayComponents.join(', '));
|
|
131
|
+
if (options.availableComponents.length > 20) {
|
|
132
|
+
sections.push(`... and ${options.availableComponents.length - 20} more`);
|
|
133
|
+
}
|
|
134
|
+
sections.push('');
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
// Original code section
|
|
138
|
+
sections.push('### Original Code (with errors)');
|
|
139
|
+
sections.push('```tsx');
|
|
140
|
+
sections.push(originalCode);
|
|
141
|
+
sections.push('```');
|
|
142
|
+
sections.push('');
|
|
143
|
+
// Correction instructions
|
|
144
|
+
sections.push('### Correction Instructions');
|
|
145
|
+
sections.push('1. Fix ALL errors listed above');
|
|
146
|
+
sections.push('2. Keep the same component structure and layout');
|
|
147
|
+
sections.push('3. Do NOT add new features - only fix the errors');
|
|
148
|
+
sections.push('4. Ensure all JSX elements are properly opened and closed');
|
|
149
|
+
sections.push(`5. Only import components that exist in "${options.importPath}"`);
|
|
150
|
+
sections.push('6. Return the COMPLETE corrected code in a ```tsx code block');
|
|
151
|
+
sections.push('7. Do NOT include any explanation - just the corrected code block');
|
|
152
|
+
return sections.join('\n');
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Format errors for logging
|
|
156
|
+
*/
|
|
157
|
+
export function formatErrorsForLog(errors) {
|
|
158
|
+
const parts = [];
|
|
159
|
+
if (errors.syntaxErrors.length > 0) {
|
|
160
|
+
parts.push(`Syntax(${errors.syntaxErrors.length})`);
|
|
161
|
+
}
|
|
162
|
+
if (errors.patternErrors.length > 0) {
|
|
163
|
+
parts.push(`Pattern(${errors.patternErrors.length})`);
|
|
164
|
+
}
|
|
165
|
+
if (errors.importErrors.length > 0) {
|
|
166
|
+
parts.push(`Import(${errors.importErrors.length})`);
|
|
167
|
+
}
|
|
168
|
+
return parts.length > 0 ? parts.join(', ') : 'None';
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Create generation metrics from error history
|
|
172
|
+
*/
|
|
173
|
+
export function createGenerationMetrics(attempts, errorHistory, autoFixApplied) {
|
|
174
|
+
return {
|
|
175
|
+
attempts,
|
|
176
|
+
selfHealingUsed: attempts > 1,
|
|
177
|
+
validationHistory: errorHistory.map((errors, index) => ({
|
|
178
|
+
attempt: index + 1,
|
|
179
|
+
syntaxErrors: errors.syntaxErrors.length,
|
|
180
|
+
patternErrors: errors.patternErrors.length,
|
|
181
|
+
importErrors: errors.importErrors.length,
|
|
182
|
+
autoFixApplied: autoFixApplied[index] || false,
|
|
183
|
+
})),
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Select the best code from multiple attempts based on error count
|
|
188
|
+
*/
|
|
189
|
+
export function selectBestAttempt(attempts) {
|
|
190
|
+
if (attempts.length === 0)
|
|
191
|
+
return null;
|
|
192
|
+
let best = attempts[0];
|
|
193
|
+
let bestErrorCount = getTotalErrorCount(best.errors);
|
|
194
|
+
for (const attempt of attempts) {
|
|
195
|
+
const errorCount = getTotalErrorCount(attempt.errors);
|
|
196
|
+
if (errorCount < bestErrorCount) {
|
|
197
|
+
best = attempt;
|
|
198
|
+
bestErrorCount = errorCount;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
return best;
|
|
202
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validateStory.d.ts","sourceRoot":"","sources":["../../story-generator/validateStory.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAoB,EAAE,MAAM,CAAC,EAAE,GAAG,GAAG,gBAAgB,
|
|
1
|
+
{"version":3,"file":"validateStory.d.ts","sourceRoot":"","sources":["../../story-generator/validateStory.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAoB,EAAE,MAAM,CAAC,EAAE,GAAG,GAAG,gBAAgB,CA+G9G;AAqcD;;GAEG;AACH,wBAAgB,2BAA2B,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,GAAG,GAAG,gBAAgB,CAqC9F;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,GAAG,MAAM,CA+BvE"}
|
|
@@ -9,12 +9,17 @@ export function validateStoryCode(code, fileName = 'story.tsx', config) {
|
|
|
9
9
|
errors: [],
|
|
10
10
|
warnings: []
|
|
11
11
|
};
|
|
12
|
+
// Determine framework from config
|
|
13
|
+
const framework = config?.componentFramework || config?.framework || 'react';
|
|
14
|
+
const isJsxFramework = framework === 'react' || framework === 'vue';
|
|
12
15
|
try {
|
|
13
16
|
// Create a TypeScript source file
|
|
14
|
-
|
|
17
|
+
// Use appropriate script kind based on framework
|
|
18
|
+
const scriptKind = isJsxFramework ? ts.ScriptKind.TSX : ts.ScriptKind.TS;
|
|
19
|
+
const sourceFile = ts.createSourceFile(fileName, code, ts.ScriptTarget.Latest, true, scriptKind);
|
|
15
20
|
// Check for syntax errors using the program API
|
|
16
21
|
const compilerOptions = {
|
|
17
|
-
jsx: ts.JsxEmit.ReactJSX,
|
|
22
|
+
jsx: isJsxFramework ? ts.JsxEmit.ReactJSX : ts.JsxEmit.None,
|
|
18
23
|
target: ts.ScriptTarget.Latest,
|
|
19
24
|
module: ts.ModuleKind.ESNext,
|
|
20
25
|
allowJs: true,
|
|
@@ -47,11 +52,13 @@ export function validateStoryCode(code, fileName = 'story.tsx', config) {
|
|
|
47
52
|
}
|
|
48
53
|
}
|
|
49
54
|
}
|
|
50
|
-
// Additional semantic checks
|
|
51
|
-
|
|
52
|
-
|
|
55
|
+
// Additional semantic checks - only for JSX frameworks (React, Vue with JSX)
|
|
56
|
+
// For non-JSX frameworks (Angular, Svelte, Web Components), skip JSX-specific validation
|
|
57
|
+
if (isJsxFramework) {
|
|
58
|
+
const semanticErrors = performSemanticChecks(sourceFile, config);
|
|
59
|
+
result.errors.push(...semanticErrors);
|
|
60
|
+
}
|
|
53
61
|
// Check for React import - but only for React-based frameworks
|
|
54
|
-
const framework = config?.framework || 'react';
|
|
55
62
|
const isReactFramework = framework === 'react' || framework.includes('react');
|
|
56
63
|
const hasJSX = code.includes('<') || code.includes('/>');
|
|
57
64
|
const hasReactImport = code.includes('import React from \'react\';');
|
|
@@ -61,6 +68,12 @@ export function validateStoryCode(code, fileName = 'story.tsx', config) {
|
|
|
61
68
|
result.errors.push('Missing React import - add "import React from \'react\';" at the top of the file');
|
|
62
69
|
result.isValid = false;
|
|
63
70
|
}
|
|
71
|
+
// CRITICAL: For non-React frameworks, REMOVE any React imports that the LLM incorrectly generated
|
|
72
|
+
if (!isReactFramework && hasReactImport) {
|
|
73
|
+
result.warnings.push(`Removed incorrect React import for ${framework} framework`);
|
|
74
|
+
code = removeReactImport(code);
|
|
75
|
+
result.fixedCode = code;
|
|
76
|
+
}
|
|
64
77
|
if (result.errors.length > 0) {
|
|
65
78
|
result.isValid = false;
|
|
66
79
|
// Attempt to fix common issues
|
|
@@ -89,6 +102,7 @@ function performSemanticChecks(sourceFile, config) {
|
|
|
89
102
|
const errors = [];
|
|
90
103
|
const availableComponents = new Set();
|
|
91
104
|
const importedComponents = new Set();
|
|
105
|
+
const usedJsxComponents = new Set();
|
|
92
106
|
// If config is provided, collect available components
|
|
93
107
|
if (config && config.componentsToImport) {
|
|
94
108
|
config.componentsToImport.forEach((comp) => availableComponents.add(comp));
|
|
@@ -127,19 +141,54 @@ function performSemanticChecks(sourceFile, config) {
|
|
|
127
141
|
});
|
|
128
142
|
}
|
|
129
143
|
}
|
|
144
|
+
// Track all named imports from any module (React, icons, etc.)
|
|
145
|
+
if (ts.isNamedImports(node.importClause.namedBindings)) {
|
|
146
|
+
node.importClause.namedBindings.elements.forEach(element => {
|
|
147
|
+
importedComponents.add(element.name.text);
|
|
148
|
+
});
|
|
149
|
+
}
|
|
130
150
|
}
|
|
131
151
|
}
|
|
132
|
-
//
|
|
133
|
-
if (ts.
|
|
134
|
-
|
|
152
|
+
// Track default imports (e.g., import React from 'react')
|
|
153
|
+
if (ts.isImportDeclaration(node) && node.importClause && node.importClause.name) {
|
|
154
|
+
importedComponents.add(node.importClause.name.text);
|
|
135
155
|
}
|
|
136
|
-
//
|
|
137
|
-
if (ts.
|
|
138
|
-
|
|
156
|
+
// Track JSX element names - CRITICAL: Catch undefined components
|
|
157
|
+
if (ts.isJsxOpeningElement(node) || ts.isJsxSelfClosingElement(node)) {
|
|
158
|
+
const tagName = node.tagName;
|
|
159
|
+
// Handle different tag name types
|
|
160
|
+
if (ts.isIdentifier(tagName)) {
|
|
161
|
+
// Simple identifier like <Card> or <CardSection>
|
|
162
|
+
const name = tagName.text;
|
|
163
|
+
// Only track PascalCase names (components, not HTML elements like div, span)
|
|
164
|
+
if (/^[A-Z]/.test(name)) {
|
|
165
|
+
usedJsxComponents.add(name);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
else if (ts.isPropertyAccessExpression(tagName)) {
|
|
169
|
+
// Compound component like <Card.Section>
|
|
170
|
+
// The parent (Card) needs to be imported, not Card.Section
|
|
171
|
+
if (ts.isIdentifier(tagName.expression)) {
|
|
172
|
+
const parentName = tagName.expression.text;
|
|
173
|
+
if (/^[A-Z]/.test(parentName)) {
|
|
174
|
+
usedJsxComponents.add(parentName);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
139
178
|
}
|
|
140
179
|
ts.forEachChild(node, visit);
|
|
141
180
|
}
|
|
142
181
|
visit(sourceFile);
|
|
182
|
+
// CRITICAL CHECK: Verify all used JSX components are imported
|
|
183
|
+
// This catches bugs where a component is used but never imported
|
|
184
|
+
// This is framework-agnostic - works for any JSX-based framework
|
|
185
|
+
for (const componentName of usedJsxComponents) {
|
|
186
|
+
if (!importedComponents.has(componentName)) {
|
|
187
|
+
errors.push(`JSX error: "${componentName}" is used but was never imported. ` +
|
|
188
|
+
`Either add it to your imports, or if you intended to use a sub-component, ` +
|
|
189
|
+
`use the correct syntax (e.g., Parent.Child instead of ParentChild).`);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
143
192
|
return errors;
|
|
144
193
|
}
|
|
145
194
|
/**
|
|
@@ -307,6 +356,26 @@ function fixMissingReactImport(code) {
|
|
|
307
356
|
}
|
|
308
357
|
return code;
|
|
309
358
|
}
|
|
359
|
+
/**
|
|
360
|
+
* Removes React import for non-React frameworks (Vue, Angular, Svelte, Web Components)
|
|
361
|
+
* The LLM sometimes incorrectly generates React imports for these frameworks
|
|
362
|
+
*/
|
|
363
|
+
function removeReactImport(code) {
|
|
364
|
+
// Remove various forms of React import
|
|
365
|
+
const reactImportPatterns = [
|
|
366
|
+
/import\s+React\s+from\s+['"]react['"]\s*;?\n?/g,
|
|
367
|
+
/import\s+\*\s+as\s+React\s+from\s+['"]react['"]\s*;?\n?/g,
|
|
368
|
+
/import\s+React,?\s*\{[^}]*\}\s+from\s+['"]react['"]\s*;?\n?/g,
|
|
369
|
+
/import\s+\{[^}]*\}\s+from\s+['"]react['"]\s*;?\n?/g,
|
|
370
|
+
];
|
|
371
|
+
let cleanedCode = code;
|
|
372
|
+
for (const pattern of reactImportPatterns) {
|
|
373
|
+
cleanedCode = cleanedCode.replace(pattern, '');
|
|
374
|
+
}
|
|
375
|
+
// Clean up any resulting double newlines
|
|
376
|
+
cleanedCode = cleanedCode.replace(/\n\n\n+/g, '\n\n');
|
|
377
|
+
return cleanedCode;
|
|
378
|
+
}
|
|
310
379
|
/**
|
|
311
380
|
* Fixes unclosed JSX elements
|
|
312
381
|
*/
|
|
@@ -59,6 +59,8 @@ export interface StoryUIConfig {
|
|
|
59
59
|
componentPrefix: string;
|
|
60
60
|
/** Framework type for story generation (e.g., 'react', 'web-components', 'angular', 'vue', 'svelte') */
|
|
61
61
|
framework?: string;
|
|
62
|
+
/** Component framework type for discovery routing (e.g., 'react', 'vue', 'angular', 'svelte', 'web-components') */
|
|
63
|
+
componentFramework?: string;
|
|
62
64
|
components: ComponentConfig[];
|
|
63
65
|
layoutComponents?: ComponentConfig[];
|
|
64
66
|
layoutRules: LayoutRules;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"story-ui.config.d.ts","sourceRoot":"","sources":["../story-ui.config.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,QAAQ,GAAG,SAAS,GAAG,MAAM,GAAG,YAAY,GAAG,UAAU,GAAG,OAAO,CAAC;IAC/E,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;CAClB;AAGD,MAAM,WAAW,WAA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"mappings":"
|
|
1
|
+
{"version":3,"file":"StoryUIPanel.d.ts","sourceRoot":"","sources":["../../../templates/StoryUI/StoryUIPanel.tsx"],"names":[],"mappings":"AAymDA,iBAAS,YAAY,4CAuyCpB;AAED,eAAe,YAAY,CAAC;AAC5B,OAAO,EAAE,YAAY,EAAE,CAAC"}
|