* The component a wrapper call hands over — `observer(Login)`, `React.memo(Login)`, * `connect(mapState)(Login)`, `withTranslation()(withRouter(Login))`: its last * argument list's lone argument, or a component ahead of the options after it * (`React.memo(TableBody, areEqual)`, `withAuthZ(Page, {
(expression: string)
| 645 | * `forwardRef` drops). |
| 646 | */ |
| 647 | function wrappedName(expression: string): string | null { |
| 648 | const s = expression.trim(); |
| 649 | const callee = /^[A-Za-z_$][\w$]*(?:\s*\.\s*[A-Za-z_$][\w$]*)*\s*(?:<[^()]*>)?\s*(?=\()/.exec(s); |
| 650 | if (!callee) return null; |
| 651 | let end = callee[0].length; |
| 652 | let args: string[] = []; |
| 653 | for (let open = end; s[open] === '('; ) { |
| 654 | const close = matchBracket(s, open); |
| 655 | if (close < 0) return null; |
| 656 | args = topLevelItems(s.slice(open + 1, close)); |
| 657 | end = close + 1; |
| 658 | for (open = end; /\s/.test(s[open] ?? ''); ) open++; |
| 659 | } |
| 660 | if (!/^(?:\s+(?:as|satisfies)\s[\s\S]*)?$/.test(s.slice(end))) return null; |
| 661 | const first = args[0] ?? ''; |
| 662 | // `connect(mapState, mapDispatch)` hands over no component yet. |
| 663 | if (args.length > 1 && !/^[A-Z]/.test(first)) return null; |
| 664 | return /^[A-Za-z_$][\w$]*$/.test(first) ? first : first ? wrappedName(first) : null; |
| 665 | } |
| 666 | |
| 667 | /** True when the module's default export is the binding `local` itself: `export default Page;`, `export { Page as default }`. */ |
| 668 | function exportsBinding(source: string, local: string): boolean { |
no test coverage detected