* Parse the NativeProps interface body and return prop names. * Each prop is `name?: Type;` or `name: Type;` on its own line. * We don't care about types — just the JS-visible name.
(body: string)
| 116 | * We don't care about types — just the JS-visible name. |
| 117 | */ |
| 118 | function extractPropNames(body: string): string[] { |
| 119 | const props: string[] = []; |
| 120 | // Anchor to start-of-line (after optional whitespace), then capture an |
| 121 | // identifier, then optional `?`, then `:`. Skip lines that look like |
| 122 | // method declarations (`name(`) — those are TurboModule spec methods, |
| 123 | // not view props. |
| 124 | const regex = /^\s*([A-Za-z_][A-Za-z0-9_]*)\??\s*:/gm; |
| 125 | let m: RegExpExecArray | null; |
| 126 | while ((m = regex.exec(body)) !== null) { |
| 127 | const name = m[1]!; |
| 128 | // Exclude any line that immediately turns into a function-shape (e.g. |
| 129 | // `onTap?: () => void` is fine — it's a prop, not a method body — |
| 130 | // but a literal `name(arg: T): R` is a method declaration). |
| 131 | const after = body.slice(m.index + m[0].length, m.index + m[0].length + 80); |
| 132 | if (/^\s*\(/.test(after)) continue; // method-shape, skip |
| 133 | props.push(name); |
| 134 | } |
| 135 | return props; |
| 136 | } |
| 137 | |
| 138 | /** |
| 139 | * Extract legacy Paper view-manager declarations from a .m/.mm file. |
no test coverage detected