| 238 | * Used by middleware + config detectors as app-wide declared state. |
| 239 | */ |
| 240 | export function extractBrightScriptGlobalFields(content: string): GlobalFieldRegistration[] { |
| 241 | const out: GlobalFieldRegistration[] = []; |
| 242 | const lines = content.split("\n"); |
| 243 | const pattern = /\bm\.global\.(?:AddField|addField)\s*\(\s*["']([^"']+)["']\s*,\s*["']([^"']+)["']/gi; |
| 244 | for (let i = 0; i < lines.length; i++) { |
| 245 | let m: RegExpExecArray | null; |
| 246 | pattern.lastIndex = 0; |
| 247 | while ((m = pattern.exec(lines[i])) !== null) { |
| 248 | out.push({ name: m[1], type: m[2], line: i + 1 }); |
| 249 | } |
| 250 | } |
| 251 | return out; |
| 252 | } |
| 253 | |
| 254 | /** |
| 255 | * Heuristic: RudderstackTask event name payloads. |