* The loader function an initializer hands a lazy wrapper: the first function * among its call's arguments, through the wrappers around it (`Loadable(lazy(() * => import('./x')))`) and before the options after it (`dynamic(…, { ssr: * false })`), or an options object's `loader` (`Loadable({ loade
(text: string)
| 764 | * import(…) })`). Null for an initializer that is no such call. |
| 765 | */ |
| 766 | function loaderOf(text: string): string | null { |
| 767 | const s = text.trim(); |
| 768 | const call = /^[A-Za-z_$][\w$]*(?:\s*\.\s*[A-Za-z_$][\w$]*)*\s*(?:<[^()]*>)?\s*\(/.exec(s); |
| 769 | if (!call) return conditionalLoader(s); |
| 770 | const open = call[0].length - 1; |
| 771 | const close = matchBracket(s, open); |
| 772 | if (close < 0) return null; |
| 773 | for (const arg of topLevelItems(s.slice(open + 1, close))) { |
| 774 | const item = arg.trim(); |
| 775 | if (!item) continue; |
| 776 | if (functionParts(item)) return item; |
| 777 | if (item.startsWith('{')) { |
| 778 | const loader = matchBracket(item, 0) === item.length - 1 ? objectEntries(item.slice(1, -1)).props.get('loader') : undefined; |
| 779 | if (loader !== undefined && functionParts(loader)) return loader; |
| 780 | continue; |
| 781 | } |
| 782 | const inner = loaderOf(item); |
| 783 | if (inner) return inner; |
| 784 | } |
| 785 | return conditionalLoader(s); |
| 786 | } |
| 787 | |
| 788 | /** |
| 789 | * The loader of a conditional's one branch that has one: SigNoz's `IS_DEV ? |
no test coverage detected