expo-router 6.1.0-canary-20251015-a6a1272 → 7.0.0-canary-20251031-b135dff

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (279) hide show
  1. package/_error.js +36 -3
  2. package/build/ExpoRoot.js +1 -1
  3. package/build/ExpoRoot.js.map +1 -1
  4. package/build/global-state/router-store.d.ts +2 -0
  5. package/build/global-state/router-store.d.ts.map +1 -1
  6. package/build/global-state/router-store.js +16 -12
  7. package/build/global-state/router-store.js.map +1 -1
  8. package/build/global-state/routing.d.ts +12 -4
  9. package/build/global-state/routing.d.ts.map +1 -1
  10. package/build/global-state/routing.js +35 -10
  11. package/build/global-state/routing.js.map +1 -1
  12. package/build/global-state/storeContext.d.ts +2 -0
  13. package/build/global-state/storeContext.d.ts.map +1 -1
  14. package/build/internal/routing.d.ts +7 -0
  15. package/build/internal/routing.d.ts.map +1 -0
  16. package/build/internal/routing.js +21 -0
  17. package/build/internal/routing.js.map +1 -0
  18. package/build/internal/rsc.d.ts +5 -0
  19. package/build/internal/rsc.d.ts.map +1 -0
  20. package/build/internal/rsc.js +18 -0
  21. package/build/internal/rsc.js.map +1 -0
  22. package/build/internal/static.d.ts +3 -0
  23. package/build/internal/static.d.ts.map +1 -0
  24. package/build/internal/static.js +8 -0
  25. package/build/internal/static.js.map +1 -0
  26. package/build/internal/testing.d.ts +3 -0
  27. package/build/internal/testing.d.ts.map +1 -0
  28. package/build/internal/testing.js +11 -0
  29. package/build/internal/testing.js.map +1 -0
  30. package/build/internal/utils.d.ts +2 -0
  31. package/build/internal/utils.d.ts.map +1 -0
  32. package/build/internal/utils.js +6 -0
  33. package/build/internal/utils.js.map +1 -0
  34. package/build/layouts/BaseStack.d.ts +3 -0
  35. package/build/layouts/BaseStack.d.ts.map +1 -0
  36. package/build/layouts/BaseStack.js +8 -0
  37. package/build/layouts/BaseStack.js.map +1 -0
  38. package/build/layouts/ExperimentalModalStack.d.ts +9 -0
  39. package/build/layouts/ExperimentalModalStack.d.ts.map +1 -0
  40. package/build/layouts/ExperimentalModalStack.js +15 -0
  41. package/build/layouts/ExperimentalModalStack.js.map +1 -0
  42. package/build/layouts/IsWithinLayoutContext.d.ts +2 -0
  43. package/build/layouts/IsWithinLayoutContext.d.ts.map +1 -0
  44. package/build/layouts/IsWithinLayoutContext.js +7 -0
  45. package/build/layouts/IsWithinLayoutContext.js.map +1 -0
  46. package/build/layouts/Stack.web.d.ts +1 -14
  47. package/build/layouts/Stack.web.d.ts.map +1 -1
  48. package/build/layouts/Stack.web.js +10 -13
  49. package/build/layouts/Stack.web.js.map +1 -1
  50. package/build/layouts/_web-modal.d.ts +3 -0
  51. package/build/layouts/_web-modal.d.ts.map +1 -0
  52. package/build/layouts/_web-modal.js +8 -0
  53. package/build/layouts/_web-modal.js.map +1 -0
  54. package/build/layouts/withLayoutContext.d.ts.map +1 -1
  55. package/build/layouts/withLayoutContext.js +5 -2
  56. package/build/layouts/withLayoutContext.js.map +1 -1
  57. package/build/loaders/ServerDataLoaderContext.d.ts +2 -1
  58. package/build/loaders/ServerDataLoaderContext.d.ts.map +1 -1
  59. package/build/loaders/ServerDataLoaderContext.js.map +1 -1
  60. package/build/modal/web/ModalStack.d.ts.map +1 -1
  61. package/build/modal/web/ModalStack.js +7 -2
  62. package/build/modal/web/ModalStack.js.map +1 -1
  63. package/build/native-tabs/{NativeBottomTabs/NativeBottomTabsNavigator.d.ts → NativeBottomTabsNavigator.d.ts} +3 -3
  64. package/build/native-tabs/NativeBottomTabsNavigator.d.ts.map +1 -0
  65. package/build/native-tabs/{NativeBottomTabs/NativeBottomTabsNavigator.js → NativeBottomTabsNavigator.js} +49 -14
  66. package/build/native-tabs/NativeBottomTabsNavigator.js.map +1 -0
  67. package/build/native-tabs/NativeBottomTabsRouter.d.ts.map +1 -0
  68. package/build/native-tabs/{NativeBottomTabs/NativeBottomTabsRouter.js → NativeBottomTabsRouter.js} +1 -1
  69. package/build/native-tabs/NativeBottomTabsRouter.js.map +1 -0
  70. package/build/native-tabs/{NativeBottomTabs/NativeTabTrigger.d.ts → NativeTabTrigger.d.ts} +1 -1
  71. package/build/native-tabs/NativeTabTrigger.d.ts.map +1 -0
  72. package/build/native-tabs/{NativeBottomTabs/NativeTabTrigger.js → NativeTabTrigger.js} +9 -5
  73. package/build/native-tabs/NativeTabTrigger.js.map +1 -0
  74. package/build/native-tabs/NativeTabs.d.ts.map +1 -0
  75. package/build/native-tabs/{NativeBottomTabs/NativeTabs.js → NativeTabs.js} +2 -0
  76. package/build/native-tabs/NativeTabs.js.map +1 -0
  77. package/build/native-tabs/NativeTabsTriggerTabBar.d.ts.map +1 -0
  78. package/build/native-tabs/NativeTabsTriggerTabBar.js.map +1 -0
  79. package/build/native-tabs/NativeTabsView.d.ts.map +1 -0
  80. package/build/native-tabs/NativeTabsView.js +103 -0
  81. package/build/native-tabs/NativeTabsView.js.map +1 -0
  82. package/build/native-tabs/NativeTabsView.web.d.ts.map +1 -0
  83. package/build/native-tabs/{NativeBottomTabs/NativeTabsView.web.js → NativeTabsView.web.js} +18 -57
  84. package/build/native-tabs/NativeTabsView.web.js.map +1 -0
  85. package/build/native-tabs/{NativeBottomTabs/appearance.d.ts → appearance.d.ts} +2 -2
  86. package/build/native-tabs/appearance.d.ts.map +1 -0
  87. package/build/native-tabs/{NativeBottomTabs/appearance.js → appearance.js} +18 -6
  88. package/build/native-tabs/appearance.js.map +1 -0
  89. package/build/native-tabs/common/elements.d.ts +1 -1
  90. package/build/native-tabs/common/elements.d.ts.map +1 -1
  91. package/build/native-tabs/common/elements.js.map +1 -1
  92. package/build/native-tabs/index.d.ts +4 -4
  93. package/build/native-tabs/index.d.ts.map +1 -1
  94. package/build/native-tabs/index.js +3 -3
  95. package/build/native-tabs/index.js.map +1 -1
  96. package/build/native-tabs/{NativeBottomTabs/types.d.ts → types.d.ts} +19 -6
  97. package/build/native-tabs/types.d.ts.map +1 -0
  98. package/build/native-tabs/types.js.map +1 -0
  99. package/build/native-tabs/{NativeBottomTabs/utils.d.ts → utils/children.d.ts} +1 -3
  100. package/build/native-tabs/utils/children.d.ts.map +1 -0
  101. package/build/native-tabs/{NativeBottomTabs/utils.js → utils/children.js} +1 -7
  102. package/build/native-tabs/utils/children.js.map +1 -0
  103. package/build/native-tabs/utils/icon.d.ts +25 -0
  104. package/build/native-tabs/utils/icon.d.ts.map +1 -0
  105. package/build/native-tabs/utils/icon.js +68 -0
  106. package/build/native-tabs/utils/icon.js.map +1 -0
  107. package/build/native-tabs/utils/index.d.ts +4 -0
  108. package/build/native-tabs/utils/index.d.ts.map +1 -0
  109. package/build/native-tabs/utils/index.js +11 -0
  110. package/build/native-tabs/utils/index.js.map +1 -0
  111. package/build/native-tabs/utils/label.d.ts +6 -0
  112. package/build/native-tabs/utils/label.d.ts.map +1 -0
  113. package/build/native-tabs/utils/label.js +15 -0
  114. package/build/native-tabs/utils/label.js.map +1 -0
  115. package/build/renderRootComponent.d.ts.map +1 -1
  116. package/build/renderRootComponent.js +4 -7
  117. package/build/renderRootComponent.js.map +1 -1
  118. package/build/split-view/elements.d.ts +10 -0
  119. package/build/split-view/elements.d.ts.map +1 -0
  120. package/build/split-view/elements.js +15 -0
  121. package/build/split-view/elements.js.map +1 -0
  122. package/build/split-view/index.d.ts +2 -0
  123. package/build/split-view/index.d.ts.map +1 -0
  124. package/build/split-view/index.js +6 -0
  125. package/build/split-view/index.js.map +1 -0
  126. package/build/split-view/split-view.d.ts +13 -0
  127. package/build/split-view/split-view.d.ts.map +1 -0
  128. package/build/split-view/split-view.js +93 -0
  129. package/build/split-view/split-view.js.map +1 -0
  130. package/build/static/html.d.ts +5 -15
  131. package/build/static/html.d.ts.map +1 -1
  132. package/build/static/html.js +9 -25
  133. package/build/static/html.js.map +1 -1
  134. package/build/static/registerRootComponent.d.ts +11 -0
  135. package/build/static/registerRootComponent.d.ts.map +1 -0
  136. package/build/static/registerRootComponent.js +11 -0
  137. package/build/static/registerRootComponent.js.map +1 -0
  138. package/build/types.d.ts +4 -2
  139. package/build/types.d.ts.map +1 -1
  140. package/build/types.js.map +1 -1
  141. package/build/ui/TabRouter.d.ts +3 -4
  142. package/build/ui/TabRouter.d.ts.map +1 -1
  143. package/build/ui/TabRouter.js +14 -67
  144. package/build/ui/TabRouter.js.map +1 -1
  145. package/build/ui/TabTrigger.d.ts +4 -5
  146. package/build/ui/TabTrigger.d.ts.map +1 -1
  147. package/build/ui/TabTrigger.js +9 -8
  148. package/build/ui/TabTrigger.js.map +1 -1
  149. package/build/ui/Tabs.d.ts +0 -1
  150. package/build/ui/Tabs.d.ts.map +1 -1
  151. package/build/ui/Tabs.js.map +1 -1
  152. package/html.js +1 -1
  153. package/internal/routing.d.ts +1 -0
  154. package/internal/routing.js +1 -0
  155. package/internal/rsc.d.ts +1 -0
  156. package/internal/rsc.js +1 -0
  157. package/internal/static.d.ts +1 -0
  158. package/internal/static.js +1 -0
  159. package/internal/testing.d.ts +1 -0
  160. package/internal/testing.js +1 -0
  161. package/internal/utils.d.ts +1 -0
  162. package/internal/utils.js +1 -0
  163. package/package.json +13 -11
  164. package/plugin/build/index.js +10 -0
  165. package/plugin/options.json +5 -0
  166. package/plugin/src/index.ts +17 -1
  167. package/rsc/headers.d.ts +1 -1
  168. package/rsc/headers.js +1 -1
  169. package/unstable-split-view.d.ts +1 -0
  170. package/unstable-split-view.js +1 -0
  171. package/build/getRoutesSSR.d.ts +0 -20
  172. package/build/getRoutesSSR.d.ts.map +0 -1
  173. package/build/getRoutesSSR.js +0 -97
  174. package/build/getRoutesSSR.js.map +0 -1
  175. package/build/getServerManifest.d.ts +0 -88
  176. package/build/getServerManifest.d.ts.map +0 -1
  177. package/build/getServerManifest.js +0 -238
  178. package/build/getServerManifest.js.map +0 -1
  179. package/build/loadStaticParamsAsync.d.ts +0 -9
  180. package/build/loadStaticParamsAsync.d.ts.map +0 -1
  181. package/build/loadStaticParamsAsync.js +0 -163
  182. package/build/loadStaticParamsAsync.js.map +0 -1
  183. package/build/native-tabs/NativeBottomTabs/NativeBottomTabsNavigator.d.ts.map +0 -1
  184. package/build/native-tabs/NativeBottomTabs/NativeBottomTabsNavigator.js.map +0 -1
  185. package/build/native-tabs/NativeBottomTabs/NativeBottomTabsRouter.d.ts.map +0 -1
  186. package/build/native-tabs/NativeBottomTabs/NativeBottomTabsRouter.js.map +0 -1
  187. package/build/native-tabs/NativeBottomTabs/NativeTabTrigger.d.ts.map +0 -1
  188. package/build/native-tabs/NativeBottomTabs/NativeTabTrigger.js.map +0 -1
  189. package/build/native-tabs/NativeBottomTabs/NativeTabs.d.ts.map +0 -1
  190. package/build/native-tabs/NativeBottomTabs/NativeTabs.js.map +0 -1
  191. package/build/native-tabs/NativeBottomTabs/NativeTabsTriggerTabBar.d.ts.map +0 -1
  192. package/build/native-tabs/NativeBottomTabs/NativeTabsTriggerTabBar.js.map +0 -1
  193. package/build/native-tabs/NativeBottomTabs/NativeTabsView.d.ts.map +0 -1
  194. package/build/native-tabs/NativeBottomTabs/NativeTabsView.js +0 -187
  195. package/build/native-tabs/NativeBottomTabs/NativeTabsView.js.map +0 -1
  196. package/build/native-tabs/NativeBottomTabs/NativeTabsView.web.d.ts.map +0 -1
  197. package/build/native-tabs/NativeBottomTabs/NativeTabsView.web.js.map +0 -1
  198. package/build/native-tabs/NativeBottomTabs/appearance.d.ts.map +0 -1
  199. package/build/native-tabs/NativeBottomTabs/appearance.js.map +0 -1
  200. package/build/native-tabs/NativeBottomTabs/types.d.ts.map +0 -1
  201. package/build/native-tabs/NativeBottomTabs/types.js.map +0 -1
  202. package/build/native-tabs/NativeBottomTabs/utils.d.ts.map +0 -1
  203. package/build/native-tabs/NativeBottomTabs/utils.js.map +0 -1
  204. package/build/routes-manifest.d.ts +0 -28
  205. package/build/routes-manifest.d.ts.map +0 -1
  206. package/build/routes-manifest.js +0 -30
  207. package/build/routes-manifest.js.map +0 -1
  208. package/build/rsc/middleware.d.ts +0 -8
  209. package/build/rsc/middleware.d.ts.map +0 -1
  210. package/build/rsc/middleware.js +0 -105
  211. package/build/rsc/middleware.js.map +0 -1
  212. package/build/rsc/path.d.ts +0 -34
  213. package/build/rsc/path.d.ts.map +0 -1
  214. package/build/rsc/path.js +0 -174
  215. package/build/rsc/path.js.map +0 -1
  216. package/build/rsc/router/create-expo-pages.d.ts +0 -20
  217. package/build/rsc/router/create-expo-pages.d.ts.map +0 -1
  218. package/build/rsc/router/create-expo-pages.js +0 -21
  219. package/build/rsc/router/create-expo-pages.js.map +0 -1
  220. package/build/rsc/router/create-pages.d.ts +0 -80
  221. package/build/rsc/router/create-pages.d.ts.map +0 -1
  222. package/build/rsc/router/create-pages.js +0 -232
  223. package/build/rsc/router/create-pages.js.map +0 -1
  224. package/build/rsc/router/defineRouter.d.ts +0 -30
  225. package/build/rsc/router/defineRouter.d.ts.map +0 -1
  226. package/build/rsc/router/defineRouter.js +0 -171
  227. package/build/rsc/router/defineRouter.js.map +0 -1
  228. package/build/rsc/router/expo-definedRouter.d.ts +0 -3
  229. package/build/rsc/router/expo-definedRouter.d.ts.map +0 -1
  230. package/build/rsc/router/expo-definedRouter.js +0 -112
  231. package/build/rsc/router/expo-definedRouter.js.map +0 -1
  232. package/build/rsc/router/noopRouter.d.ts +0 -3
  233. package/build/rsc/router/noopRouter.d.ts.map +0 -1
  234. package/build/rsc/router/noopRouter.js +0 -7
  235. package/build/rsc/router/noopRouter.js.map +0 -1
  236. package/build/rsc/rsc-renderer.d.ts +0 -44
  237. package/build/rsc/rsc-renderer.d.ts.map +0 -1
  238. package/build/rsc/rsc-renderer.js +0 -200
  239. package/build/rsc/rsc-renderer.js.map +0 -1
  240. package/build/rsc/server.d.ts +0 -65
  241. package/build/rsc/server.d.ts.map +0 -1
  242. package/build/rsc/server.js +0 -89
  243. package/build/rsc/server.js.map +0 -1
  244. package/build/static/getRootComponent.d.ts +0 -2
  245. package/build/static/getRootComponent.d.ts.map +0 -1
  246. package/build/static/getRootComponent.js +0 -25
  247. package/build/static/getRootComponent.js.map +0 -1
  248. package/build/static/getServerManifest.d.ts +0 -22
  249. package/build/static/getServerManifest.d.ts.map +0 -1
  250. package/build/static/getServerManifest.js +0 -50
  251. package/build/static/getServerManifest.js.map +0 -1
  252. package/build/static/renderStaticContent.d.ts +0 -15
  253. package/build/static/renderStaticContent.d.ts.map +0 -1
  254. package/build/static/renderStaticContent.js +0 -130
  255. package/build/static/renderStaticContent.js.map +0 -1
  256. package/build/typed-routes/generate.d.ts +0 -8
  257. package/build/typed-routes/generate.d.ts.map +0 -1
  258. package/build/typed-routes/generate.js +0 -186
  259. package/build/typed-routes/generate.js.map +0 -1
  260. package/build/typed-routes/index.d.ts +0 -35
  261. package/build/typed-routes/index.d.ts.map +0 -1
  262. package/build/typed-routes/index.js +0 -99
  263. package/build/typed-routes/index.js.map +0 -1
  264. package/build/typed-routes/testSetup.d.ts +0 -2
  265. package/build/typed-routes/testSetup.d.ts.map +0 -1
  266. package/build/typed-routes/testSetup.js +0 -42
  267. package/build/typed-routes/testSetup.js.map +0 -1
  268. package/build/utils/html.d.ts +0 -12
  269. package/build/utils/html.d.ts.map +0 -1
  270. package/build/utils/html.js +0 -29
  271. package/build/utils/html.js.map +0 -1
  272. package/node/render.js +0 -3
  273. /package/build/native-tabs/{NativeBottomTabs/NativeBottomTabsRouter.d.ts → NativeBottomTabsRouter.d.ts} +0 -0
  274. /package/build/native-tabs/{NativeBottomTabs/NativeTabs.d.ts → NativeTabs.d.ts} +0 -0
  275. /package/build/native-tabs/{NativeBottomTabs/NativeTabsTriggerTabBar.d.ts → NativeTabsTriggerTabBar.d.ts} +0 -0
  276. /package/build/native-tabs/{NativeBottomTabs/NativeTabsTriggerTabBar.js → NativeTabsTriggerTabBar.js} +0 -0
  277. /package/build/native-tabs/{NativeBottomTabs/NativeTabsView.d.ts → NativeTabsView.d.ts} +0 -0
  278. /package/build/native-tabs/{NativeBottomTabs/NativeTabsView.web.d.ts → NativeTabsView.web.d.ts} +0 -0
  279. /package/build/native-tabs/{NativeBottomTabs/types.js → types.js} +0 -0
@@ -1,25 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getRootComponent = getRootComponent;
4
- /**
5
- * Copyright © 2023 650 Industries.
6
- *
7
- * This source code is licensed under the MIT license found in the
8
- * LICENSE file in the root directory of this source tree.
9
- */
10
- const _ctx_html_1 = require("expo-router/_ctx-html");
11
- function getRootComponent() {
12
- const keys = _ctx_html_1.ctx.keys();
13
- if (!keys.length) {
14
- return require('./html').Html;
15
- }
16
- if (keys.length > 1) {
17
- throw new Error(`Multiple components match the root HTML element: ${keys.join(', ')}`);
18
- }
19
- const exp = (0, _ctx_html_1.ctx)(keys[0]);
20
- if (!exp.default) {
21
- throw new Error(`The root HTML element "${keys[0]}" is missing the required default export.`);
22
- }
23
- return exp.default;
24
- }
25
- //# sourceMappingURL=getRootComponent.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getRootComponent.js","sourceRoot":"","sources":["../../src/static/getRootComponent.ts"],"names":[],"mappings":";;AAQA,4CAeC;AAvBD;;;;;GAKG;AACH,qDAA2D;AAE3D,SAAgB,gBAAgB;IAC9B,MAAM,IAAI,GAAG,eAAW,CAAC,IAAI,EAAE,CAAC;IAChC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;QACjB,OAAQ,OAAO,CAAC,QAAQ,CAA6B,CAAC,IAAI,CAAC;IAC7D,CAAC;IACD,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CAAC,oDAAoD,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACzF,CAAC;IACD,MAAM,GAAG,GAAG,IAAA,eAAW,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IAEjC,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CAAC,0BAA0B,IAAI,CAAC,CAAC,CAAC,2CAA2C,CAAC,CAAC;IAChG,CAAC;IAED,OAAO,GAAG,CAAC,OAAO,CAAC;AACrB,CAAC","sourcesContent":["/**\n * Copyright © 2023 650 Industries.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport { ctx as rootContext } from 'expo-router/_ctx-html';\n\nexport function getRootComponent() {\n const keys = rootContext.keys();\n if (!keys.length) {\n return (require('./html') as typeof import('./html')).Html;\n }\n if (keys.length > 1) {\n throw new Error(`Multiple components match the root HTML element: ${keys.join(', ')}`);\n }\n const exp = rootContext(keys[0]);\n\n if (!exp.default) {\n throw new Error(`The root HTML element \"${keys[0]}\" is missing the required default export.`);\n }\n\n return exp.default;\n}\n"]}
@@ -1,22 +0,0 @@
1
- /**
2
- * Copyright © 2024 650 Industries.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- */
7
- import { Options } from '../getRoutes';
8
- import { ExpoRouterServerManifestV1 } from '../getServerManifest';
9
- /**
10
- * Get the server manifest with all dynamic routes loaded with `generateStaticParams`.
11
- * Unlike the `expo-router/src/routes-manifest.ts` method, this requires loading the entire app in-memory, which
12
- * takes substantially longer and requires Metro bundling.
13
- *
14
- * This is used for the production manifest where we pre-render certain pages and should no longer treat them as dynamic.
15
- */
16
- export declare function getBuildTimeServerManifestAsync(options?: Options): Promise<ExpoRouterServerManifestV1>;
17
- /** Get the linking manifest from a Node.js process. */
18
- export declare function getManifest(options?: Options): Promise<{
19
- initialRouteName: undefined;
20
- screens: Record<string, import("../getReactNavigationConfig").Screen>;
21
- }>;
22
- //# sourceMappingURL=getServerManifest.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getServerManifest.d.ts","sourceRoot":"","sources":["../../src/static/getServerManifest.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAa,OAAO,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,0BAA0B,EAAqB,MAAM,sBAAsB,CAAC;AAGrF;;;;;;GAMG;AACH,wBAAsB,+BAA+B,CACnD,OAAO,GAAE,OAAY,GACpB,OAAO,CAAC,0BAA0B,CAAC,CAcrC;AAED,uDAAuD;AACvD,wBAAsB,WAAW,CAAC,OAAO,GAAE,OAAY;;;GAgBtD"}
@@ -1,50 +0,0 @@
1
- "use strict";
2
- /**
3
- * Copyright © 2024 650 Industries.
4
- *
5
- * This source code is licensed under the MIT license found in the
6
- * LICENSE file in the root directory of this source tree.
7
- */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.getBuildTimeServerManifestAsync = getBuildTimeServerManifestAsync;
10
- exports.getManifest = getManifest;
11
- const _ctx_1 = require("../../_ctx");
12
- const getReactNavigationConfig_1 = require("../getReactNavigationConfig");
13
- const getRoutes_1 = require("../getRoutes");
14
- const getServerManifest_1 = require("../getServerManifest");
15
- const loadStaticParamsAsync_1 = require("../loadStaticParamsAsync");
16
- /**
17
- * Get the server manifest with all dynamic routes loaded with `generateStaticParams`.
18
- * Unlike the `expo-router/src/routes-manifest.ts` method, this requires loading the entire app in-memory, which
19
- * takes substantially longer and requires Metro bundling.
20
- *
21
- * This is used for the production manifest where we pre-render certain pages and should no longer treat them as dynamic.
22
- */
23
- async function getBuildTimeServerManifestAsync(options = {}) {
24
- const routeTree = (0, getRoutes_1.getRoutes)(_ctx_1.ctx, {
25
- platform: 'web',
26
- ...options,
27
- });
28
- if (!routeTree) {
29
- throw new Error('No routes found');
30
- }
31
- // Evaluate all static params
32
- await (0, loadStaticParamsAsync_1.loadStaticParamsAsync)(routeTree);
33
- return (0, getServerManifest_1.getServerManifest)(routeTree, options);
34
- }
35
- /** Get the linking manifest from a Node.js process. */
36
- async function getManifest(options = {}) {
37
- const routeTree = (0, getRoutes_1.getRoutes)(_ctx_1.ctx, {
38
- preserveApiRoutes: true,
39
- preserveRedirectAndRewrites: true,
40
- platform: 'web',
41
- ...options,
42
- });
43
- if (!routeTree) {
44
- throw new Error('No routes found');
45
- }
46
- // Evaluate all static params
47
- await (0, loadStaticParamsAsync_1.loadStaticParamsAsync)(routeTree);
48
- return (0, getReactNavigationConfig_1.getReactNavigationConfig)(routeTree, false);
49
- }
50
- //# sourceMappingURL=getServerManifest.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getServerManifest.js","sourceRoot":"","sources":["../../src/static/getServerManifest.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAeH,0EAgBC;AAGD,kCAgBC;AAhDD,qCAAiC;AACjC,0EAAuE;AACvE,4CAAkD;AAClD,4DAAqF;AACrF,oEAAiE;AAEjE;;;;;;GAMG;AACI,KAAK,UAAU,+BAA+B,CACnD,UAAmB,EAAE;IAErB,MAAM,SAAS,GAAG,IAAA,qBAAS,EAAC,UAAG,EAAE;QAC/B,QAAQ,EAAE,KAAK;QACf,GAAG,OAAO;KACX,CAAC,CAAC;IAEH,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACrC,CAAC;IAED,6BAA6B;IAC7B,MAAM,IAAA,6CAAqB,EAAC,SAAS,CAAC,CAAC;IAEvC,OAAO,IAAA,qCAAiB,EAAC,SAAS,EAAE,OAAO,CAAC,CAAC;AAC/C,CAAC;AAED,uDAAuD;AAChD,KAAK,UAAU,WAAW,CAAC,UAAmB,EAAE;IACrD,MAAM,SAAS,GAAG,IAAA,qBAAS,EAAC,UAAG,EAAE;QAC/B,iBAAiB,EAAE,IAAI;QACvB,2BAA2B,EAAE,IAAI;QACjC,QAAQ,EAAE,KAAK;QACf,GAAG,OAAO;KACX,CAAC,CAAC;IAEH,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACrC,CAAC;IAED,6BAA6B;IAC7B,MAAM,IAAA,6CAAqB,EAAC,SAAS,CAAC,CAAC;IAEvC,OAAO,IAAA,mDAAwB,EAAC,SAAS,EAAE,KAAK,CAAC,CAAC;AACpD,CAAC","sourcesContent":["/**\n * Copyright © 2024 650 Industries.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport { ctx } from '../../_ctx';\nimport { getReactNavigationConfig } from '../getReactNavigationConfig';\nimport { getRoutes, Options } from '../getRoutes';\nimport { ExpoRouterServerManifestV1, getServerManifest } from '../getServerManifest';\nimport { loadStaticParamsAsync } from '../loadStaticParamsAsync';\n\n/**\n * Get the server manifest with all dynamic routes loaded with `generateStaticParams`.\n * Unlike the `expo-router/src/routes-manifest.ts` method, this requires loading the entire app in-memory, which\n * takes substantially longer and requires Metro bundling.\n *\n * This is used for the production manifest where we pre-render certain pages and should no longer treat them as dynamic.\n */\nexport async function getBuildTimeServerManifestAsync(\n options: Options = {}\n): Promise<ExpoRouterServerManifestV1> {\n const routeTree = getRoutes(ctx, {\n platform: 'web',\n ...options,\n });\n\n if (!routeTree) {\n throw new Error('No routes found');\n }\n\n // Evaluate all static params\n await loadStaticParamsAsync(routeTree);\n\n return getServerManifest(routeTree, options);\n}\n\n/** Get the linking manifest from a Node.js process. */\nexport async function getManifest(options: Options = {}) {\n const routeTree = getRoutes(ctx, {\n preserveApiRoutes: true,\n preserveRedirectAndRewrites: true,\n platform: 'web',\n ...options,\n });\n\n if (!routeTree) {\n throw new Error('No routes found');\n }\n\n // Evaluate all static params\n await loadStaticParamsAsync(routeTree);\n\n return getReactNavigationConfig(routeTree, false);\n}\n"]}
@@ -1,15 +0,0 @@
1
- /**
2
- * Copyright © 2023 650 Industries.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- */
7
- import '@expo/metro-runtime';
8
- type GetStaticContentOptions = {
9
- loader?: {
10
- data?: any;
11
- };
12
- };
13
- export declare function getStaticContent(location: URL, options?: GetStaticContentOptions): Promise<string>;
14
- export { getBuildTimeServerManifestAsync, getManifest } from './getServerManifest';
15
- //# sourceMappingURL=renderStaticContent.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"renderStaticContent.d.ts","sourceRoot":"","sources":["../../src/static/renderStaticContent.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,qBAAqB,CAAC;AA8B7B,KAAK,uBAAuB,GAAG;IAC7B,MAAM,CAAC,EAAE;QACP,IAAI,CAAC,EAAE,GAAG,CAAC;KACZ,CAAC;CACH,CAAC;AAEF,wBAAsB,gBAAgB,CACpC,QAAQ,EAAE,GAAG,EACb,OAAO,CAAC,EAAE,uBAAuB,GAChC,OAAO,CAAC,MAAM,CAAC,CA+DjB;AAmBD,OAAO,EAAE,+BAA+B,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC"}
@@ -1,130 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- var __importDefault = (this && this.__importDefault) || function (mod) {
36
- return (mod && mod.__esModule) ? mod : { "default": mod };
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.getManifest = exports.getBuildTimeServerManifestAsync = void 0;
40
- exports.getStaticContent = getStaticContent;
41
- /**
42
- * Copyright © 2023 650 Industries.
43
- *
44
- * This source code is licensed under the MIT license found in the
45
- * LICENSE file in the root directory of this source tree.
46
- */
47
- require("@expo/metro-runtime");
48
- const native_1 = require("@react-navigation/native");
49
- const Font = __importStar(require("expo-font/build/server"));
50
- const react_1 = __importDefault(require("react"));
51
- const server_node_1 = __importDefault(require("react-dom/server.node"));
52
- // @ts-expect-error: TODO(@kitten): Define this type (seems to differ from react-native)
53
- const react_native_web_1 = require("react-native-web");
54
- const getRootComponent_1 = require("./getRootComponent");
55
- const _ctx_1 = require("../../_ctx");
56
- const ExpoRoot_1 = require("../ExpoRoot");
57
- const head_1 = require("../head");
58
- const html_1 = require("./html");
59
- const ServerDataLoaderContext_1 = require("../loaders/ServerDataLoaderContext");
60
- const debug = require('debug')('expo:router:renderStaticContent');
61
- react_native_web_1.AppRegistry.registerComponent('App', () => ExpoRoot_1.ExpoRoot);
62
- function resetReactNavigationContexts() {
63
- // https://github.com/expo/router/discussions/588
64
- // https://github.com/react-navigation/react-navigation/blob/9fe34b445fcb86e5666f61e144007d7540f014fa/packages/elements/src/getNamedContext.tsx#LL3C1-L4C1
65
- // React Navigation is storing providers in a global, this is fine for the first static render
66
- // but subsequent static renders of Stack or Tabs will cause React to throw a warning. To prevent this warning, we'll reset the globals before rendering.
67
- const contexts = '__react_navigation__elements_contexts';
68
- global[contexts] = new Map();
69
- }
70
- async function getStaticContent(location, options) {
71
- const headContext = {};
72
- const ref = react_1.default.createRef();
73
- const {
74
- // NOTE: The `element` that's returned adds two extra Views and
75
- // the seemingly unused `RootTagContext.Provider`.
76
- element, getStyleElement, } = react_native_web_1.AppRegistry.getApplication('App', {
77
- initialProps: {
78
- location,
79
- context: _ctx_1.ctx,
80
- wrapper: ({ children }) => (<Root>
81
- <div id="root">{children}</div>
82
- </Root>),
83
- },
84
- });
85
- const Root = (0, getRootComponent_1.getRootComponent)();
86
- // Clear any existing static resources from the global scope to attempt to prevent leaking between pages.
87
- // This could break if pages are rendered in parallel or if fonts are loaded outside of the React tree
88
- Font.resetServerContext();
89
- // This MUST be run before `ReactDOMServer.renderToString` to prevent
90
- // "Warning: Detected multiple renderers concurrently rendering the same context provider. This is currently unsupported."
91
- resetReactNavigationContexts();
92
- const loadedData = options?.loader?.data ? { [location.pathname]: options.loader.data } : null;
93
- const html = await server_node_1.default.renderToString(<head_1.Head.Provider context={headContext}>
94
- <ServerDataLoaderContext_1.ServerDataLoaderContext value={loadedData}>
95
- <native_1.ServerContainer ref={ref}>{element}</native_1.ServerContainer>
96
- </ServerDataLoaderContext_1.ServerDataLoaderContext>
97
- </head_1.Head.Provider>);
98
- // Eval the CSS after the HTML is rendered so that the CSS is in the same order
99
- const css = server_node_1.default.renderToStaticMarkup(getStyleElement());
100
- let output = mixHeadComponentsWithStaticResults(headContext.helmet, html);
101
- output = output.replace('</head>', `${css}</head>`);
102
- const fonts = Font.getServerResources();
103
- debug(`Pushing static fonts: (count: ${fonts.length})`, fonts);
104
- // debug('Push static fonts:', fonts)
105
- // Inject static fonts loaded with expo-font
106
- output = output.replace('</head>', `${fonts.join('')}</head>`);
107
- if (loadedData) {
108
- const loaderDataScript = server_node_1.default.renderToStaticMarkup(<html_1.PreloadedDataScript data={loadedData}/>);
109
- output = output.replace('</head>', `${loaderDataScript}</head>`);
110
- }
111
- return '<!DOCTYPE html>' + output;
112
- }
113
- function mixHeadComponentsWithStaticResults(helmet, html) {
114
- // Head components
115
- for (const key of ['title', 'priority', 'meta', 'link', 'script', 'style'].reverse()) {
116
- const result = helmet?.[key]?.toString();
117
- if (result) {
118
- html = html.replace('<head>', `<head>${result}`);
119
- }
120
- }
121
- // attributes
122
- html = html.replace('<html ', `<html ${helmet?.htmlAttributes.toString()} `);
123
- html = html.replace('<body ', `<body ${helmet?.bodyAttributes.toString()} `);
124
- return html;
125
- }
126
- // Re-export for use in server
127
- var getServerManifest_1 = require("./getServerManifest");
128
- Object.defineProperty(exports, "getBuildTimeServerManifestAsync", { enumerable: true, get: function () { return getServerManifest_1.getBuildTimeServerManifestAsync; } });
129
- Object.defineProperty(exports, "getManifest", { enumerable: true, get: function () { return getServerManifest_1.getManifest; } });
130
- //# sourceMappingURL=renderStaticContent.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"renderStaticContent.js","sourceRoot":"","sources":["../../src/static/renderStaticContent.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0CA,4CAkEC;AA5GD;;;;;GAKG;AACH,+BAA6B;AAE7B,qDAA+E;AAC/E,6DAA+C;AAC/C,kDAA0B;AAC1B,wEAAmD;AACnD,wFAAwF;AACxF,uDAA+C;AAE/C,yDAAsD;AACtD,qCAAiC;AACjC,0CAAuC;AACvC,kCAA+B;AAC/B,iCAA6C;AAC7C,gFAA6E;AAE7E,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,iCAAiC,CAAC,CAAC;AAElE,8BAAW,CAAC,iBAAiB,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC,mBAAQ,CAAC,CAAC;AAErD,SAAS,4BAA4B;IACnC,iDAAiD;IACjD,0JAA0J;IAE1J,8FAA8F;IAC9F,yJAAyJ;IACzJ,MAAM,QAAQ,GAAG,uCAAuC,CAAC;IACzD,MAAM,CAAC,QAAQ,CAAC,GAAG,IAAI,GAAG,EAA8B,CAAC;AAC3D,CAAC;AAQM,KAAK,UAAU,gBAAgB,CACpC,QAAa,EACb,OAAiC;IAEjC,MAAM,WAAW,GAAqB,EAAE,CAAC;IAEzC,MAAM,GAAG,GAAG,eAAK,CAAC,SAAS,EAAsB,CAAC;IAElD,MAAM;IACJ,+DAA+D;IAC/D,kDAAkD;IAClD,OAAO,EACP,eAAe,GAChB,GAAG,8BAAW,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,SAAS,MAAM,EAAE,cAAc,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;IAE7E,OAAO,IAAI,CAAC;AACd,CAAC;AAED,8BAA8B;AAC9B,yDAAmF;AAA1E,oIAAA,+BAA+B,OAAA;AAAE,gHAAA,WAAW,OAAA","sourcesContent":["/**\n * Copyright © 2023 650 Industries.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport '@expo/metro-runtime';\n\nimport { ServerContainer, ServerContainerRef } from '@react-navigation/native';\nimport * as Font from 'expo-font/build/server';\nimport React from 'react';\nimport ReactDOMServer from 'react-dom/server.node';\n// @ts-expect-error: TODO(@kitten): Define this type (seems to differ from react-native)\nimport { AppRegistry } from 'react-native-web';\n\nimport { getRootComponent } from './getRootComponent';\nimport { ctx } from '../../_ctx';\nimport { ExpoRoot } from '../ExpoRoot';\nimport { Head } from '../head';\nimport { PreloadedDataScript } from './html';\nimport { ServerDataLoaderContext } from '../loaders/ServerDataLoaderContext';\n\nconst debug = require('debug')('expo:router:renderStaticContent');\n\nAppRegistry.registerComponent('App', () => ExpoRoot);\n\nfunction resetReactNavigationContexts() {\n // https://github.com/expo/router/discussions/588\n // https://github.com/react-navigation/react-navigation/blob/9fe34b445fcb86e5666f61e144007d7540f014fa/packages/elements/src/getNamedContext.tsx#LL3C1-L4C1\n\n // React Navigation is storing providers in a global, this is fine for the first static render\n // but subsequent static renders of Stack or Tabs will cause React to throw a warning. To prevent this warning, we'll reset the globals before rendering.\n const contexts = '__react_navigation__elements_contexts';\n global[contexts] = new Map<string, React.Context<any>>();\n}\n\ntype GetStaticContentOptions = {\n loader?: {\n data?: any;\n };\n};\n\nexport async function getStaticContent(\n location: URL,\n options?: GetStaticContentOptions\n): Promise<string> {\n const headContext: { helmet?: any } = {};\n\n const ref = React.createRef<ServerContainerRef>();\n\n const {\n // NOTE: The `element` that's returned adds two extra Views and\n // the seemingly unused `RootTagContext.Provider`.\n element,\n getStyleElement,\n } = AppRegistry.getApplication('App', {\n initialProps: {\n location,\n context: ctx,\n wrapper: ({ children }: React.ComponentProps<any>) => (\n <Root>\n <div id=\"root\">{children}</div>\n </Root>\n ),\n },\n });\n\n const Root = getRootComponent();\n\n // Clear any existing static resources from the global scope to attempt to prevent leaking between pages.\n // This could break if pages are rendered in parallel or if fonts are loaded outside of the React tree\n Font.resetServerContext();\n\n // This MUST be run before `ReactDOMServer.renderToString` to prevent\n // \"Warning: Detected multiple renderers concurrently rendering the same context provider. This is currently unsupported.\"\n resetReactNavigationContexts();\n\n const loadedData = options?.loader?.data ? { [location.pathname]: options.loader.data } : null;\n\n const html = await ReactDOMServer.renderToString(\n <Head.Provider context={headContext}>\n <ServerDataLoaderContext value={loadedData}>\n <ServerContainer ref={ref}>{element}</ServerContainer>\n </ServerDataLoaderContext>\n </Head.Provider>\n );\n\n // Eval the CSS after the HTML is rendered so that the CSS is in the same order\n const css = ReactDOMServer.renderToStaticMarkup(getStyleElement());\n\n let output = mixHeadComponentsWithStaticResults(headContext.helmet, html);\n\n output = output.replace('</head>', `${css}</head>`);\n\n const fonts = Font.getServerResources();\n debug(`Pushing static fonts: (count: ${fonts.length})`, fonts);\n // debug('Push static fonts:', fonts)\n // Inject static fonts loaded with expo-font\n output = output.replace('</head>', `${fonts.join('')}</head>`);\n\n if (loadedData) {\n const loaderDataScript = ReactDOMServer.renderToStaticMarkup(\n <PreloadedDataScript data={loadedData} />\n );\n output = output.replace('</head>', `${loaderDataScript}</head>`);\n }\n\n return '<!DOCTYPE html>' + output;\n}\n\nfunction mixHeadComponentsWithStaticResults(helmet: any, html: string) {\n // Head components\n for (const key of ['title', 'priority', 'meta', 'link', 'script', 'style'].reverse()) {\n const result = helmet?.[key]?.toString();\n if (result) {\n html = html.replace('<head>', `<head>${result}`);\n }\n }\n\n // attributes\n html = html.replace('<html ', `<html ${helmet?.htmlAttributes.toString()} `);\n html = html.replace('<body ', `<body ${helmet?.bodyAttributes.toString()} `);\n\n return html;\n}\n\n// Re-export for use in server\nexport { getBuildTimeServerManifestAsync, getManifest } from './getServerManifest';\n"]}
@@ -1,8 +0,0 @@
1
- import { RequireContext } from '../types';
2
- export type GetTypedRoutesDeclarationFileOptions = {
3
- partialTypedGroups?: boolean;
4
- testIgnoreComments?: boolean;
5
- unstable_useServerMiddleware?: boolean;
6
- };
7
- export declare function getTypedRoutesDeclarationFile(ctx: RequireContext, { partialTypedGroups, testIgnoreComments, unstable_useServerMiddleware, }?: GetTypedRoutesDeclarationFileOptions): string;
8
- //# sourceMappingURL=generate.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../src/typed-routes/generate.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAW1C,MAAM,MAAM,oCAAoC,GAAG;IACjD,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,4BAA4B,CAAC,EAAE,OAAO,CAAC;CACxC,CAAC;AAEF,wBAAgB,6BAA6B,CAC3C,GAAG,EAAE,cAAc,EACnB,EACE,kBAA0B,EAC1B,kBAA0B,EAC1B,4BAAoC,GACrC,GAAE,oCAAyC,UA4G7C"}
@@ -1,186 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getTypedRoutesDeclarationFile = getTypedRoutesDeclarationFile;
4
- const getRoutes_1 = require("../getRoutes");
5
- const matchers_1 = require("../matchers");
6
- // /[...param1]/ - Match [...param1]
7
- const CATCH_ALL = /\[\.\.\..+?\]/g;
8
- // /[param1] - Match [param1]
9
- const SLUG = /\[.+?\]/g;
10
- // /(group)/path/(group2)/route - Match [(group), (group2)]
11
- const GROUP = /(?:^|\/)\(.*?\)/g;
12
- const urlParams = "${`?${string}` | `#${string}` | ''}";
13
- function getTypedRoutesDeclarationFile(ctx, { partialTypedGroups = false, testIgnoreComments = false, unstable_useServerMiddleware = false, } = {}) {
14
- let routeNode = null;
15
- try {
16
- routeNode = (0, getRoutes_1.getRoutes)(ctx, {
17
- ignore: [/_layout\.[tj]sx?$/], // Skip layout files
18
- platformRoutes: false, // We don't need to generate platform specific routes
19
- notFound: false, // We don't need +not-found routes either
20
- ignoreEntryPoints: true,
21
- ignoreRequireErrors: true,
22
- importMode: 'async', // Don't load the file
23
- // NOTE(@hassankhan): We should ensure that getRoutes() doesn't have optional options in the future
24
- unstable_useServerMiddleware,
25
- });
26
- }
27
- catch {
28
- // Ignore errors from `getRoutes`. This is also called inside the app, which has
29
- // a nicer UX for showing error messages
30
- }
31
- const groupedNodes = groupRouteNodes(routeNode);
32
- const staticRoutesStrings = ['Router.RelativePathString', 'Router.ExternalPathString'];
33
- const staticRouteInputObjects = [
34
- '{ pathname: Router.RelativePathString, params?: Router.UnknownInputParams }',
35
- '{ pathname: Router.ExternalPathString, params?: Router.UnknownInputParams }',
36
- ];
37
- const staticRouteOutputObjects = [
38
- '{ pathname: Router.RelativePathString, params?: Router.UnknownOutputParams }',
39
- '{ pathname: Router.ExternalPathString, params?: Router.UnknownOutputParams }',
40
- ];
41
- for (const type of groupedNodes.static) {
42
- staticRoutesStrings.push(contextKeyToType(type + urlParams, partialTypedGroups));
43
- staticRouteInputObjects.push(`{ pathname: ${contextKeyToType(type, partialTypedGroups)}; params?: Router.UnknownInputParams; }`);
44
- staticRouteOutputObjects.push(`{ pathname: ${contextKeyToType(type, partialTypedGroups)}; params?: Router.UnknownOutputParams; }`);
45
- }
46
- const dynamicRouteStrings = [];
47
- const dynamicRouteInputObjects = [];
48
- const dynamicRouteOutputObjects = [];
49
- for (const [dynamicRouteTemplate, paramsNames] of groupedNodes.dynamic) {
50
- const inputParams = paramsNames
51
- .map((param) => {
52
- const key = param.startsWith('...') ? param.slice(3) : param;
53
- const value = param.startsWith('...') ? '(string | number)[]' : 'string | number';
54
- return `${contextKeyToProperty(key)}: ${value};`;
55
- })
56
- .join('');
57
- const outputParams = paramsNames
58
- .map((param) => {
59
- const key = param.startsWith('...') ? param.slice(3) : param;
60
- const value = param.startsWith('...') ? 'string[]' : 'string';
61
- return `${contextKeyToProperty(key)}: ${value};`;
62
- })
63
- .join('');
64
- dynamicRouteStrings.push(contextKeyToType(dynamicRouteTemplate
65
- .replaceAll(CATCH_ALL, '${string}')
66
- .replaceAll(SLUG, '${Router.SingleRoutePart<T>}') + urlParams, partialTypedGroups));
67
- dynamicRouteInputObjects.push(`{ pathname: ${contextKeyToType(dynamicRouteTemplate, partialTypedGroups)}, params: Router.UnknownInputParams & { ${inputParams} } }`);
68
- dynamicRouteOutputObjects.push(`{ pathname: ${contextKeyToType(dynamicRouteTemplate, partialTypedGroups)}, params: Router.UnknownOutputParams & { ${outputParams} } }`);
69
- }
70
- const href = [
71
- ...staticRoutesStrings,
72
- ...staticRouteInputObjects,
73
- ...dynamicRouteStrings,
74
- ...dynamicRouteInputObjects,
75
- ].join(' | ');
76
- const hrefInputParams = [...staticRouteInputObjects, ...dynamicRouteInputObjects].join(' | ');
77
- const hrefOutputParams = [...staticRouteOutputObjects, ...dynamicRouteOutputObjects].join(' | ');
78
- const tsExpectError = testIgnoreComments
79
- ? '// @ts-ignore-error -- During tests we need to ignore the "duplicate" declaration error, as multiple fixture declare types \n '
80
- : '';
81
- return `/* eslint-disable */
82
- import * as Router from 'expo-router';
83
-
84
- export * from 'expo-router';
85
-
86
- declare module 'expo-router' {
87
- export namespace ExpoRouter {
88
- export interface __routes<T extends string | object = string> {
89
- ${tsExpectError}hrefInputParams: ${hrefInputParams};
90
- ${tsExpectError}hrefOutputParams: ${hrefOutputParams};
91
- ${tsExpectError}href: ${href};
92
- }
93
- }
94
- }
95
- `;
96
- }
97
- function groupRouteNodes(routeNode, groupedContextKeys = {
98
- static: new Set(),
99
- dynamic: new Map(),
100
- }) {
101
- if (!routeNode) {
102
- return groupedContextKeys;
103
- }
104
- // Skip non-route files
105
- if (routeNode.type !== 'route') {
106
- // Except the root layout
107
- if (routeNode.route === '') {
108
- for (const child of routeNode.children) {
109
- groupRouteNodes(child, groupedContextKeys);
110
- }
111
- return groupedContextKeys;
112
- }
113
- return groupedContextKeys;
114
- }
115
- let routeKey;
116
- if (routeNode.generated) {
117
- // Some routes like the root _layout, _sitemap, +not-found are generated.
118
- // We cannot use the contextKey, as their context key does not specify a route
119
- routeKey = routeNode.route;
120
- }
121
- else {
122
- routeKey = (0, matchers_1.removeSupportedExtensions)(routeNode.contextKey)
123
- .replace(/\/index$/, '') // Remove any trailing /index
124
- .replace(/^\./, ''); // Remove any leading .
125
- }
126
- routeKey ||= '/'; // A routeKey may be empty for contextKey '' or './index.js'
127
- if (!routeKey.startsWith('/')) {
128
- // Not all generated files will have the `/` prefix
129
- routeKey = `/${routeKey}`;
130
- }
131
- routeKey = routeKey.replace(/\\/g, '/');
132
- if (routeNode.dynamic) {
133
- groupedContextKeys.dynamic.set(routeKey, routeKey
134
- .split('/')
135
- .filter((segment) => {
136
- return segment.startsWith('[') && segment.endsWith(']');
137
- })
138
- .map((segment) => {
139
- return segment.slice(1, -1);
140
- }));
141
- }
142
- else {
143
- groupedContextKeys.static.add(routeKey);
144
- }
145
- for (const child of routeNode.children) {
146
- groupRouteNodes(child, groupedContextKeys);
147
- }
148
- return groupedContextKeys;
149
- }
150
- function contextKeyToProperty(contextKey) {
151
- return !/^(?!\d)[\w$]+$/.test(contextKey) ? JSON.stringify(contextKey) : contextKey;
152
- }
153
- function contextKeyToType(contextKey, partialTypedGroups) {
154
- if (contextKey.match(GROUP) === null) {
155
- return `\`${contextKey}\``;
156
- }
157
- // If the route has groups, turn them into template strings
158
- const typeWithGroups = contextKey.replaceAll(GROUP, (match) => {
159
- const groups = match.slice(2, -1); // Remove the leading ( and the trailing )
160
- // When `partialRoutes` is enabled, we always change a group to a template
161
- if (groups.length > 1 || partialTypedGroups) {
162
- // Ensure each group has the trailing slash
163
- const groupsAsType = groups.split(',').map((group) => `'/(${group})'`);
164
- // `partialRoutes` allow you to skip a group
165
- if (partialTypedGroups) {
166
- groupsAsType.push("''");
167
- }
168
- // Combine together into a union
169
- return `\${${groupsAsType.join(' | ')}}`;
170
- }
171
- else {
172
- return match;
173
- }
174
- });
175
- let typeWithoutGroups = contextKey.replaceAll(GROUP, '') || '/';
176
- /**
177
- * When getting the static routes, they include a urlParams string at the end.
178
- * If we have a route like `/(group)/(group2)`, this would normally be collapsed to `/`.
179
- * But because of the urlParams, it becomes `${urlParams}` and we need to add a `/` to the start.
180
- */
181
- if (typeWithoutGroups.startsWith(urlParams)) {
182
- typeWithoutGroups = `/${typeWithoutGroups}`;
183
- }
184
- return `\`${typeWithGroups}\` | \`${typeWithoutGroups}\``;
185
- }
186
- //# sourceMappingURL=generate.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"generate.js","sourceRoot":"","sources":["../../src/typed-routes/generate.ts"],"names":[],"mappings":";;AAoBA,sEAkHC;AArID,4CAAyC;AACzC,0CAAwD;AAGxD,oCAAoC;AACpC,MAAM,SAAS,GAAG,gBAAgB,CAAC;AACnC,6BAA6B;AAC7B,MAAM,IAAI,GAAG,UAAU,CAAC;AACxB,2DAA2D;AAC3D,MAAM,KAAK,GAAG,kBAAkB,CAAC;AAEjC,MAAM,SAAS,GAAG,qCAAqC,CAAC;AAQxD,SAAgB,6BAA6B,CAC3C,GAAmB,EACnB,EACE,kBAAkB,GAAG,KAAK,EAC1B,kBAAkB,GAAG,KAAK,EAC1B,4BAA4B,GAAG,KAAK,MACI,EAAE;IAE5C,IAAI,SAAS,GAAqB,IAAI,CAAC;IAEvC,IAAI,CAAC;QACH,SAAS,GAAG,IAAA,qBAAS,EAAC,GAAG,EAAE;YACzB,MAAM,EAAE,CAAC,mBAAmB,CAAC,EAAE,oBAAoB;YACnD,cAAc,EAAE,KAAK,EAAE,qDAAqD;YAC5E,QAAQ,EAAE,KAAK,EAAE,yCAAyC;YAC1D,iBAAiB,EAAE,IAAI;YACvB,mBAAmB,EAAE,IAAI;YACzB,UAAU,EAAE,OAAO,EAAE,sBAAsB;YAC3C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from '../matchers';\nimport { RequireContext } from '../types';\n\n// /[...param1]/ - Match [...param1]\nconst CATCH_ALL = /\\[\\.\\.\\..+?\\]/g;\n// /[param1] - Match [param1]\nconst SLUG = /\\[.+?\\]/g;\n// /(group)/path/(group2)/route - Match [(group), (group2)]\nconst GROUP = /(?:^|\\/)\\(.*?\\)/g;\n\nconst urlParams = \"${`?${string}` | `#${string}` | ''}\";\n\nexport type GetTypedRoutesDeclarationFileOptions = {\n partialTypedGroups?: boolean;\n testIgnoreComments?: boolean;\n unstable_useServerMiddleware?: boolean;\n};\n\nexport function getTypedRoutesDeclarationFile(\n ctx: RequireContext,\n {\n partialTypedGroups = false,\n testIgnoreComments = false,\n unstable_useServerMiddleware = false,\n }: GetTypedRoutesDeclarationFileOptions = {}\n) {\n let routeNode: RouteNode | null = null;\n\n try {\n routeNode = getRoutes(ctx, {\n ignore: [/_layout\\.[tj]sx?$/], // Skip layout files\n platformRoutes: false, // We don't need to generate platform specific routes\n notFound: false, // We don't need +not-found routes either\n ignoreEntryPoints: true,\n ignoreRequireErrors: true,\n importMode: 'async', // Don't load the file\n // NOTE(@hassankhan): We should ensure that getRoutes() doesn't have optional options in the future\n unstable_useServerMiddleware,\n });\n } catch {\n // Ignore errors from `getRoutes`. This is also called inside the app, which has\n // a nicer UX for showing error messages\n }\n\n const groupedNodes = groupRouteNodes(routeNode);\n const staticRoutesStrings: string[] = ['Router.RelativePathString', 'Router.ExternalPathString'];\n const staticRouteInputObjects: string[] = [\n '{ pathname: Router.RelativePathString, params?: Router.UnknownInputParams }',\n '{ pathname: Router.ExternalPathString, params?: Router.UnknownInputParams }',\n ];\n const staticRouteOutputObjects: string[] = [\n '{ pathname: Router.RelativePathString, params?: Router.UnknownOutputParams }',\n '{ pathname: Router.ExternalPathString, params?: Router.UnknownOutputParams }',\n ];\n\n for (const type of groupedNodes.static) {\n staticRoutesStrings.push(contextKeyToType(type + urlParams, partialTypedGroups));\n staticRouteInputObjects.push(\n `{ pathname: ${contextKeyToType(type, partialTypedGroups)}; params?: Router.UnknownInputParams; }`\n );\n staticRouteOutputObjects.push(\n `{ pathname: ${contextKeyToType(type, partialTypedGroups)}; params?: Router.UnknownOutputParams; }`\n );\n }\n\n const dynamicRouteStrings: string[] = [];\n const dynamicRouteInputObjects: string[] = [];\n const dynamicRouteOutputObjects: string[] = [];\n\n for (const [dynamicRouteTemplate, paramsNames] of groupedNodes.dynamic) {\n const inputParams = paramsNames\n .map((param) => {\n const key = param.startsWith('...') ? param.slice(3) : param;\n const value = param.startsWith('...') ? '(string | number)[]' : 'string | number';\n return `${contextKeyToProperty(key)}: ${value};`;\n })\n .join('');\n\n const outputParams = paramsNames\n .map((param) => {\n const key = param.startsWith('...') ? param.slice(3) : param;\n const value = param.startsWith('...') ? 'string[]' : 'string';\n return `${contextKeyToProperty(key)}: ${value};`;\n })\n .join('');\n\n dynamicRouteStrings.push(\n contextKeyToType(\n dynamicRouteTemplate\n .replaceAll(CATCH_ALL, '${string}')\n .replaceAll(SLUG, '${Router.SingleRoutePart<T>}') + urlParams,\n partialTypedGroups\n )\n );\n\n dynamicRouteInputObjects.push(\n `{ pathname: ${contextKeyToType(dynamicRouteTemplate, partialTypedGroups)}, params: Router.UnknownInputParams & { ${inputParams} } }`\n );\n dynamicRouteOutputObjects.push(\n `{ pathname: ${contextKeyToType(dynamicRouteTemplate, partialTypedGroups)}, params: Router.UnknownOutputParams & { ${outputParams} } }`\n );\n }\n\n const href = [\n ...staticRoutesStrings,\n ...staticRouteInputObjects,\n ...dynamicRouteStrings,\n ...dynamicRouteInputObjects,\n ].join(' | ');\n\n const hrefInputParams = [...staticRouteInputObjects, ...dynamicRouteInputObjects].join(' | ');\n const hrefOutputParams = [...staticRouteOutputObjects, ...dynamicRouteOutputObjects].join(' | ');\n\n const tsExpectError = testIgnoreComments\n ? '// @ts-ignore-error -- During tests we need to ignore the \"duplicate\" declaration error, as multiple fixture declare types \\n '\n : '';\n\n return `/* eslint-disable */\nimport * as Router from 'expo-router';\n\nexport * from 'expo-router';\n\ndeclare module 'expo-router' {\n export namespace ExpoRouter {\n export interface __routes<T extends string | object = string> {\n ${tsExpectError}hrefInputParams: ${hrefInputParams};\n ${tsExpectError}hrefOutputParams: ${hrefOutputParams};\n ${tsExpectError}href: ${href};\n }\n }\n}\n`;\n}\n\nfunction groupRouteNodes(\n routeNode: RouteNode | null,\n groupedContextKeys = {\n static: new Set<string>(),\n dynamic: new Map<string, string[]>(),\n }\n) {\n if (!routeNode) {\n return groupedContextKeys;\n }\n\n // Skip non-route files\n if (routeNode.type !== 'route') {\n // Except the root layout\n if (routeNode.route === '') {\n for (const child of routeNode.children) {\n groupRouteNodes(child, groupedContextKeys);\n }\n return groupedContextKeys;\n }\n\n return groupedContextKeys;\n }\n\n let routeKey: string;\n\n if (routeNode.generated) {\n // Some routes like the root _layout, _sitemap, +not-found are generated.\n // We cannot use the contextKey, as their context key does not specify a route\n routeKey = routeNode.route;\n } else {\n routeKey = removeSupportedExtensions(routeNode.contextKey)\n .replace(/\\/index$/, '') // Remove any trailing /index\n .replace(/^\\./, ''); // Remove any leading .\n }\n\n routeKey ||= '/'; // A routeKey may be empty for contextKey '' or './index.js'\n\n if (!routeKey.startsWith('/')) {\n // Not all generated files will have the `/` prefix\n routeKey = `/${routeKey}`;\n }\n\n routeKey = routeKey.replace(/\\\\/g, '/');\n\n if (routeNode.dynamic) {\n groupedContextKeys.dynamic.set(\n routeKey,\n routeKey\n .split('/')\n .filter((segment) => {\n return segment.startsWith('[') && segment.endsWith(']');\n })\n .map((segment) => {\n return segment.slice(1, -1);\n })\n );\n } else {\n groupedContextKeys.static.add(routeKey);\n }\n\n for (const child of routeNode.children) {\n groupRouteNodes(child, groupedContextKeys);\n }\n\n return groupedContextKeys;\n}\n\nfunction contextKeyToProperty(contextKey: string) {\n return !/^(?!\\d)[\\w$]+$/.test(contextKey) ? JSON.stringify(contextKey) : contextKey;\n}\n\nfunction contextKeyToType(contextKey: string, partialTypedGroups: boolean) {\n if (contextKey.match(GROUP) === null) {\n return `\\`${contextKey}\\``;\n }\n\n // If the route has groups, turn them into template strings\n const typeWithGroups = contextKey.replaceAll(GROUP, (match) => {\n const groups = match.slice(2, -1); // Remove the leading ( and the trailing )\n // When `partialRoutes` is enabled, we always change a group to a template\n if (groups.length > 1 || partialTypedGroups) {\n // Ensure each group has the trailing slash\n const groupsAsType = groups.split(',').map((group) => `'/(${group})'`);\n // `partialRoutes` allow you to skip a group\n if (partialTypedGroups) {\n groupsAsType.push(\"''\");\n }\n // Combine together into a union\n return `\\${${groupsAsType.join(' | ')}}`;\n } else {\n return match;\n }\n });\n\n let typeWithoutGroups = contextKey.replaceAll(GROUP, '') || '/';\n\n /**\n * When getting the static routes, they include a urlParams string at the end.\n * If we have a route like `/(group)/(group2)`, this would normally be collapsed to `/`.\n * But because of the urlParams, it becomes `${urlParams}` and we need to add a `/` to the start.\n */\n if (typeWithoutGroups.startsWith(urlParams)) {\n typeWithoutGroups = `/${typeWithoutGroups}`;\n }\n\n return `\\`${typeWithGroups}\\` | \\`${typeWithoutGroups}\\``;\n}\n"]}
@@ -1,35 +0,0 @@
1
- import { RequireContextPonyFill } from '../testing-library/require-context-ponyfill';
2
- export type { RequireContextPonyFill } from '../testing-library/require-context-ponyfill';
3
- /**
4
- * This file is imported via `@expo/cli`. While users should be using the same SDK version of `expo-router` as `@expo/cli`,
5
- * this export allows us to ensure that the version of the `expo-router` package is compatible with the version of `@expo/cli`.
6
- */
7
- export declare const version = 52;
8
- /**
9
- * Generate a Metro watch handler that regenerates the typed routes declaration file
10
- */
11
- export declare function getWatchHandler(outputDir: string, { ctx, regenerateFn }?: {
12
- ctx?: RequireContextPonyFill | undefined;
13
- regenerateFn?: ((outputDir: string, options?: {
14
- partialTypedGroups?: boolean;
15
- } | undefined, ctx?: RequireContextPonyFill | undefined) => void) | undefined;
16
- }): ({ filePath, type }: {
17
- filePath: string;
18
- type: string;
19
- }) => Promise<void>;
20
- /**
21
- * Regenerate the declaration file.
22
- *
23
- * This function needs to be debounced due to Metro's handling of renaming folders.
24
- * For example, if you have the file /(tabs)/route.tsx and you rename the folder to /(tabs,test)/route.tsx
25
- *
26
- * Metro will fire 2 filesystem events:
27
- * - ADD /(tabs,test)/router.tsx
28
- * - DELETE /(tabs)/router.tsx
29
- *
30
- * If you process the types after the ADD, then they will crash as you will have conflicting routes
31
- */
32
- export declare const regenerateDeclarations: (outputDir: string, options?: {
33
- partialTypedGroups?: boolean;
34
- } | undefined, ctx?: RequireContextPonyFill | undefined) => void;
35
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/typed-routes/index.ts"],"names":[],"mappings":"AAMA,OAAuB,EACrB,sBAAsB,EACvB,MAAM,6CAA6C,CAAC;AAIrD,YAAY,EAAE,sBAAsB,EAAE,MAAM,6CAA6C,CAAC;AAE1F;;;GAGG;AACH,eAAO,MAAM,OAAO,KAAK,CAAC;AAE1B;;GAEG;AACH,wBAAgB,eAAe,CAC7B,SAAS,EAAE,MAAM,EACjB,EAAE,GAAgB,EAAE,YAAqC,EAAE;;;6BAyDzB,OAAO;gEAqBZ,IAAI;CA9E+B,IAIjC,oBAAoB;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,mBAoCtF;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,sBAAsB;yBAGC,OAAO;4DAqBZ,IAAI,AATlC,CAAC"}