| 1109 | // `useRoutes(…)` / `createBrowserRouter(…)` hand the router a table; so does |
| 1110 | // `AppRoutes.map(…)` when its callback renders a `<Route>` from each item. |
| 1111 | const routerCall = (at: number): { map?: TableName } | null => { |
| 1112 | if (!options.uses) return null; |
| 1113 | let j = at - 1; |
| 1114 | while (j >= 0 && /\s/.test(source[j]!)) j--; |
| 1115 | if (source[j] !== 's' && source[j] !== 'r' && source[j] !== 'p') return null; |
| 1116 | const before = source.slice(Math.max(0, at - 64), at); |
| 1117 | if (/(?:^|[^\w$.])(?:useRoutes|create(?:Browser|Hash|Memory)Router)\s*$/.test(before)) return {}; |
| 1118 | const map = /(?:^|[^\w$.])([A-Za-z_$][\w$]*)\s*\??\.\s*map\s*$/.exec(before); |
| 1119 | if (!map) return null; |
| 1120 | return { map: { name: map[1]!, call: false, at: at - before.length + map.index + map[0].indexOf(map[1]!) } }; |
| 1121 | }; |
| 1122 | const routesFromElements = (at: number): boolean => { |
| 1123 | let j = at - 1; |
| 1124 | while (j >= 0 && /\s/.test(source[j]!)) j--; |