@@ -6,11 +6,8 @@ const FILE_PATH = 'apps/frontend/src/blocks/renderBlocks.tsx';
66// Regex matches: import * as Alias from '@o2s/blocks.<name>/frontend';
77const BLOCK_IMPORT_REGEX = / ^ i m p o r t \* a s ( \w + ) f r o m ' @ o 2 s \/ b l o c k s \. ( [ ^ / ] + ) \/ f r o n t e n d ' ; $ / ;
88
9- // Regex matches: case 'SomeBlock':
10- const CASE_LINE_REGEX = / ^ \s + c a s e ' ( \w + ) ' : \s * $ / ;
11-
12- // Regex matches: return <Alias.Renderer (handles extra props like onSignOut, renderBlocks)
13- const RETURN_RENDERER_REGEX = / ^ \s + r e t u r n < ( \w + ) \. R e n d e r e r / ;
9+ // Regex matches: SomeBlock: (blockProps) => <Alias.Renderer ...
10+ const REGISTRY_ENTRY_REGEX = / ^ \s + \w + : \s * \( b l o c k P r o p s \) \s * = > \s * < ( \w + ) \. R e n d e r e r / ;
1411
1512export const transformRenderBlocks = async ( projectDir : string , selectedBlockNames : string [ ] ) : Promise < void > => {
1613 const filePath = path . join ( projectDir , FILE_PATH ) ;
@@ -39,16 +36,10 @@ export const transformRenderBlocks = async (projectDir: string, selectedBlockNam
3936
4037 if ( aliasesToRemove . size === 0 ) return ;
4138
42- // Process line by line — switch case/return pairs must be removed together
39+ // Process line by line
4340 const result : string [ ] = [ ] ;
44- let skipNext = false ;
4541
4642 for ( let i = 0 ; i < lines . length ; i ++ ) {
47- if ( skipNext ) {
48- skipNext = false ;
49- continue ;
50- }
51-
5243 const line = lines [ i ] ;
5344 if ( line === undefined ) continue ;
5445
@@ -58,18 +49,10 @@ export const transformRenderBlocks = async (projectDir: string, selectedBlockNam
5849 continue ;
5950 }
6051
61- // Detect switch case line and peek at the return line below it
62- const caseMatch = line . match ( CASE_LINE_REGEX ) ;
63- if ( caseMatch && i + 1 < lines . length ) {
64- const nextLine = lines [ i + 1 ] ;
65- if ( nextLine !== undefined ) {
66- const returnMatch = nextLine . match ( RETURN_RENDERER_REGEX ) ;
67- if ( returnMatch && returnMatch [ 1 ] && aliasesToRemove . has ( returnMatch [ 1 ] ) ) {
68- // Skip both the case line (current) and the return line (next)
69- skipNext = true ;
70- continue ;
71- }
72- }
52+ // Remove BLOCK_REGISTRY entries for unselected blocks
53+ const registryMatch = line . match ( REGISTRY_ENTRY_REGEX ) ;
54+ if ( registryMatch && registryMatch [ 1 ] && aliasesToRemove . has ( registryMatch [ 1 ] ) ) {
55+ continue ;
7356 }
7457
7558 result . push ( line ) ;
0 commit comments