(content: string)
| 369 | |
| 370 | /** The `@Component` classes a file declares, in order, with whether each is the default export. */ |
| 371 | export function componentClassesIn(content: string): Array<{ name: string; isDefault: boolean; decoratorAt: number }> { |
| 372 | const out: Array<{ name: string; isDefault: boolean; decoratorAt: number }> = []; |
| 373 | const safe = stripCommentsForRegex(content, 'typescript'); |
| 374 | COMPONENT_CLASS.lastIndex = 0; |
| 375 | let m: RegExpExecArray | null; |
| 376 | while ((m = COMPONENT_CLASS.exec(safe)) !== null) { |
| 377 | const open = m.index + m[0].length - 1; |
| 378 | const close = matchBracket(safe, open); |
| 379 | if (close < 0) continue; |
| 380 | const after = /^\s*(export\s+)?(default\s+)?(?:abstract\s+)?class\s+([A-Za-z_$][\w$]*)/.exec(safe.slice(close + 1, close + 400)); |
| 381 | if (after) out.push({ name: after[3]!, isDefault: !!after[2], decoratorAt: m.index }); |
| 382 | COMPONENT_CLASS.lastIndex = close; |
| 383 | } |
| 384 | return out; |
| 385 | } |
| 386 | |
| 387 | /** The component class a lazily loaded file provides: the member named, else its default export, else its only component. */ |
| 388 | function lazyComponent(spec: string, member: string | null, fromFile: string, context: ResolutionContext): Node | null { |
no test coverage detected