* Extract ALL block configs from a file, filtering out hidden blocks
(fileContent: string)
| 957 | * Extract ALL block configs from a file, filtering out hidden blocks |
| 958 | */ |
| 959 | function extractAllBlockConfigs(fileContent: string): BlockConfig[] { |
| 960 | const configs: BlockConfig[] = [] |
| 961 | |
| 962 | // First, extract the primary icon from the file (for V2 blocks that inherit via spread) |
| 963 | const primaryIcon = extractIconNameFromContent(fileContent) |
| 964 | |
| 965 | // Find all block exports in the file |
| 966 | const exportRegex = /export\s+const\s+(\w+)Block\s*:\s*BlockConfig[^=]*=\s*\{/g |
| 967 | let match |
| 968 | |
| 969 | while ((match = exportRegex.exec(fileContent)) !== null) { |
| 970 | const blockName = match[1] |
| 971 | const startIndex = match.index + match[0].length - 1 // Position of opening brace |
| 972 | |
| 973 | // Extract the block content by matching braces |
| 974 | const endIndex = findMatchingClose(fileContent, startIndex) |
| 975 | |
| 976 | if (endIndex !== -1) { |
| 977 | const blockContent = fileContent.substring(startIndex, endIndex) |
| 978 | |
| 979 | // Check if this block has hideFromToolbar: true |
| 980 | const hideFromToolbar = /hideFromToolbar\s*:\s*true/.test(blockContent) |
| 981 | if (hideFromToolbar) { |
| 982 | console.log(`Skipping ${blockName}Block - hideFromToolbar is true`) |
| 983 | continue |
| 984 | } |
| 985 | |
| 986 | // Pass fileContent to enable spread inheritance resolution |
| 987 | const config = extractBlockConfigFromContent(blockContent, blockName, fileContent) |
| 988 | if (config) { |
| 989 | // For V2 blocks that don't have an explicit icon, use the primary icon from the file |
| 990 | if (!config.iconName && primaryIcon) { |
| 991 | ;(config as any).iconName = primaryIcon |
| 992 | } |
| 993 | configs.push(config) |
| 994 | } |
| 995 | } |
| 996 | } |
| 997 | |
| 998 | return configs |
| 999 | } |
| 1000 | |
| 1001 | /** |
| 1002 | * Extract the name of the spread base block (e.g., "GitHubBlock" from "...GitHubBlock") |
no test coverage detected