@@ -18,60 +18,16 @@ import { wrapComponent } from './codegen/utils/wrap-component'
1818import { exportDevup , importDevup } from './commands/devup'
1919import { exportAssets } from './commands/exportAssets'
2020import { exportComponents } from './commands/exportComponents'
21- import { exportPagesAndComponents } from './commands/exportPagesAndComponents'
21+ import {
22+ exportPagesAndComponents ,
23+ extractCustomComponentImports ,
24+ extractImports ,
25+ } from './commands/exportPagesAndComponents'
26+ export { extractCustomComponentImports , extractImports }
27+
2228import { getComponentName , resetTextStyleCache } from './utils'
2329import { toPascal } from './utils/to-pascal'
2430
25- const DEVUP_COMPONENTS = [
26- 'Center' ,
27- 'VStack' ,
28- 'Flex' ,
29- 'Grid' ,
30- 'Box' ,
31- 'Text' ,
32- 'Image' ,
33- ]
34-
35- export function extractImports (
36- componentsCodes : ReadonlyArray < readonly [ string , string ] > ,
37- ) : string [ ] {
38- const allCode = componentsCodes . map ( ( [ _ , code ] ) => code ) . join ( '\n' )
39- const imports = new Set < string > ( )
40-
41- for ( const component of DEVUP_COMPONENTS ) {
42- const regex = new RegExp ( `<${ component } [\\s/>]` , 'g' )
43- if ( regex . test ( allCode ) ) {
44- imports . add ( component )
45- }
46- }
47-
48- if ( / \b k e y f r a m e s \s * ( \( | ` ) / . test ( allCode ) ) {
49- imports . add ( 'keyframes' )
50- }
51-
52- return Array . from ( imports ) . sort ( )
53- }
54-
55- export function extractCustomComponentImports (
56- componentsCodes : ReadonlyArray < readonly [ string , string ] > ,
57- ) : string [ ] {
58- const allCode = componentsCodes . map ( ( [ _ , code ] ) => code ) . join ( '\n' )
59- const customImports = new Set < string > ( )
60-
61- // Find all component usages in JSX: <ComponentName or <ComponentName>
62- const componentUsageRegex = / < ( [ A - Z ] [ a - z A - Z 0 - 9 ] * ) / g
63- const matches = allCode . matchAll ( componentUsageRegex )
64- for ( const match of matches ) {
65- const componentName = match [ 1 ]
66- // Skip devup-ui components and components defined in this code
67- if ( ! DEVUP_COMPONENTS . includes ( componentName ) ) {
68- customImports . add ( componentName )
69- }
70- }
71-
72- return Array . from ( customImports ) . sort ( )
73- }
74-
7531function generateImportStatements (
7632 componentsCodes : ReadonlyArray < readonly [ string , string ] > ,
7733) : string {
@@ -357,9 +313,6 @@ export function registerCodegen(ctx: typeof figma) {
357313 componentsResponsiveCodes = responsiveResults
358314 }
359315
360- console . info ( `[benchmark] devup-ui end ${ Date . now ( ) - time } ms` )
361- console . info ( perfReport ( ) )
362-
363316 // Check if node itself is SECTION or has a parent SECTION
364317 const isNodeSection = ResponsiveCodegen . canGenerateResponsive ( node )
365318 const parentSection = ResponsiveCodegen . hasParentSection ( node )
@@ -416,6 +369,8 @@ export function registerCodegen(ctx: typeof figma) {
416369 }
417370 }
418371 if ( debug ) {
372+ console . info ( `[benchmark] devup-ui end ${ Date . now ( ) - time } ms` )
373+ console . info ( perfReport ( ) )
419374 // Track AFTER codegen — collects all node properties for test case
420375 // generation without Proxy overhead during the hot codegen path.
421376 nodeProxyTracker . trackTree ( node )
0 commit comments