()
| 47 | let cachedList: readonly IntegrationDescriptor[] | null = null |
| 48 | |
| 49 | function buildMatcher(): IntegrationMatcher { |
| 50 | const byName = new Map<string, IntegrationDescriptor>() |
| 51 | const names: string[] = [] |
| 52 | |
| 53 | for (const block of getCanonicalBlocksByCategory('tools')) { |
| 54 | if (!block.name || block.name.trim().length < 2) continue |
| 55 | const displayName = normalizeDisplayName(block.name) |
| 56 | const key = displayName.toLowerCase() |
| 57 | if (byName.has(key)) continue |
| 58 | byName.set(key, { |
| 59 | blockType: block.type, |
| 60 | name: displayName, |
| 61 | icon: block.icon, |
| 62 | bgColor: block.bgColor, |
| 63 | }) |
| 64 | names.push(displayName) |
| 65 | } |
| 66 | |
| 67 | names.sort((a, b) => b.length - a.length) |
| 68 | const regex = names.length |
| 69 | ? new RegExp(`(?<![A-Za-z0-9_])(${names.map(escapeRegex).join('|')})(?![A-Za-z0-9_])`, 'gi') |
| 70 | : null |
| 71 | |
| 72 | return { regex, byName } |
| 73 | } |
| 74 | |
| 75 | /** |
| 76 | * Lazily builds (once per session) and returns the precomputed integration |
no test coverage detected