expo-router 2.0.5 → 3.1.0

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 (390) hide show
  1. package/README.md +1 -1
  2. package/{_ctx.android.tsx → _ctx.android.js} +1 -2
  3. package/_ctx.d.ts +1 -0
  4. package/{_ctx.ios.tsx → _ctx.ios.js} +1 -2
  5. package/_ctx.js +1 -0
  6. package/{_ctx.web.tsx → _ctx.web.js} +1 -2
  7. package/_error.js +2 -4
  8. package/app.plugin.js +1 -1
  9. package/babel.js +44 -55
  10. package/build/ExpoRoot.d.ts +2 -2
  11. package/build/ExpoRoot.d.ts.map +1 -1
  12. package/build/ExpoRoot.js +82 -0
  13. package/build/ExpoRoot.js.map +1 -0
  14. package/build/LocationProvider.d.ts +2 -2
  15. package/build/LocationProvider.d.ts.map +1 -1
  16. package/build/LocationProvider.js +30 -0
  17. package/build/LocationProvider.js.map +1 -0
  18. package/build/Route.d.ts +3 -3
  19. package/build/Route.d.ts.map +1 -1
  20. package/build/Route.js +68 -0
  21. package/build/Route.js.map +1 -0
  22. package/build/exports.d.ts +12 -12
  23. package/build/exports.js +17 -0
  24. package/build/exports.js.map +1 -0
  25. package/build/fork/NavigationContainer.d.ts +1 -1
  26. package/build/fork/NavigationContainer.js +4 -0
  27. package/build/fork/NavigationContainer.js.map +1 -0
  28. package/build/fork/NavigationContainer.native.d.ts +3 -8
  29. package/build/fork/NavigationContainer.native.d.ts.map +1 -1
  30. package/build/fork/NavigationContainer.native.js +81 -0
  31. package/build/fork/NavigationContainer.native.js.map +1 -0
  32. package/build/fork/extractPathFromURL.d.ts.map +1 -1
  33. package/build/fork/extractPathFromURL.js +76 -0
  34. package/build/fork/extractPathFromURL.js.map +1 -0
  35. package/build/fork/findFocusedRoute.d.ts +1 -1
  36. package/build/fork/findFocusedRoute.js +10 -0
  37. package/build/fork/findFocusedRoute.js.map +1 -0
  38. package/build/fork/getPathFromState.d.ts +3 -3
  39. package/build/fork/getPathFromState.d.ts.map +1 -1
  40. package/build/fork/getPathFromState.js +420 -0
  41. package/build/fork/getPathFromState.js.map +1 -0
  42. package/build/fork/getStateFromPath.d.ts +3 -3
  43. package/build/fork/getStateFromPath.d.ts.map +1 -1
  44. package/build/fork/getStateFromPath.js +503 -0
  45. package/build/fork/getStateFromPath.js.map +1 -0
  46. package/build/fork/react-native-web-container.d.ts +8 -0
  47. package/build/fork/react-native-web-container.d.ts.map +1 -0
  48. package/build/fork/react-native-web-container.js +6 -0
  49. package/build/fork/react-native-web-container.js.map +1 -0
  50. package/build/fork/useLinking.d.ts.map +1 -1
  51. package/build/fork/useLinking.js +3 -0
  52. package/build/fork/useLinking.js.map +1 -0
  53. package/build/fork/useLinking.native.d.ts +3 -3
  54. package/build/fork/useLinking.native.d.ts.map +1 -1
  55. package/build/fork/useLinking.native.js +154 -0
  56. package/build/fork/useLinking.native.js.map +1 -0
  57. package/build/fork/validatePathConfig.d.ts.map +1 -1
  58. package/build/fork/validatePathConfig.js +19 -0
  59. package/build/fork/validatePathConfig.js.map +1 -0
  60. package/build/getDevServer/index.js +30 -0
  61. package/build/getDevServer/index.js.map +1 -0
  62. package/build/getDevServer/index.native.js +2 -0
  63. package/build/getDevServer/index.native.js.map +1 -0
  64. package/build/getLinkingConfig.d.ts +4 -4
  65. package/build/getLinkingConfig.d.ts.map +1 -1
  66. package/build/getLinkingConfig.js +43 -0
  67. package/build/getLinkingConfig.js.map +1 -0
  68. package/build/getReactNavigationConfig.d.ts +1 -1
  69. package/build/getReactNavigationConfig.d.ts.map +1 -1
  70. package/build/getReactNavigationConfig.js +69 -0
  71. package/build/getReactNavigationConfig.js.map +1 -0
  72. package/build/getRoutes.d.ts +4 -4
  73. package/build/getRoutes.d.ts.map +1 -1
  74. package/build/getRoutes.js +378 -0
  75. package/build/getRoutes.js.map +1 -0
  76. package/build/global-state/router-store.d.ts +14 -14
  77. package/build/global-state/router-store.d.ts.map +1 -1
  78. package/build/global-state/router-store.js +179 -0
  79. package/build/global-state/router-store.js.map +1 -0
  80. package/build/global-state/routing.d.ts +6 -6
  81. package/build/global-state/routing.d.ts.map +1 -1
  82. package/build/global-state/routing.js +160 -0
  83. package/build/global-state/routing.js.map +1 -0
  84. package/build/global-state/sort-routes.d.ts +1 -1
  85. package/build/global-state/sort-routes.d.ts.map +1 -1
  86. package/build/global-state/sort-routes.js +8 -0
  87. package/build/global-state/sort-routes.js.map +1 -0
  88. package/build/head/ExpoHead.android.d.ts +10 -0
  89. package/build/head/ExpoHead.android.d.ts.map +1 -0
  90. package/build/head/ExpoHead.android.js +6 -0
  91. package/build/head/ExpoHead.android.js.map +1 -0
  92. package/build/head/ExpoHead.d.ts +8 -0
  93. package/build/head/ExpoHead.d.ts.map +1 -0
  94. package/build/head/ExpoHead.ios.d.ts +7 -0
  95. package/build/head/ExpoHead.ios.d.ts.map +1 -0
  96. package/build/head/ExpoHead.ios.js +240 -0
  97. package/build/head/ExpoHead.ios.js.map +1 -0
  98. package/build/head/ExpoHead.js +7 -0
  99. package/build/head/ExpoHead.js.map +1 -0
  100. package/build/head/ExpoHeadModule.d.ts +33 -0
  101. package/build/head/ExpoHeadModule.d.ts.map +1 -0
  102. package/build/head/ExpoHeadModule.js +4 -0
  103. package/build/head/ExpoHeadModule.js.map +1 -0
  104. package/build/head/ExpoHeadModule.native.d.ts +3 -0
  105. package/build/head/ExpoHeadModule.native.d.ts.map +1 -0
  106. package/build/head/ExpoHeadModule.native.js +10 -0
  107. package/build/head/ExpoHeadModule.native.js.map +1 -0
  108. package/build/head/index.d.ts +2 -0
  109. package/build/head/index.d.ts.map +1 -0
  110. package/build/head/index.js +2 -0
  111. package/build/head/index.js.map +1 -0
  112. package/build/head/url.d.ts +2 -0
  113. package/build/head/url.d.ts.map +1 -0
  114. package/build/head/url.js +64 -0
  115. package/build/head/url.js.map +1 -0
  116. package/build/hooks.d.ts +1 -1
  117. package/build/hooks.d.ts.map +1 -1
  118. package/{src/hooks.ts → build/hooks.js} +34 -70
  119. package/build/hooks.js.map +1 -0
  120. package/build/imperative-api.d.ts +1 -1
  121. package/build/imperative-api.js +9 -0
  122. package/build/imperative-api.js.map +1 -0
  123. package/{src/import-mode/index.android.ts → build/import-mode/index.android.js} +1 -0
  124. package/build/import-mode/index.android.js.map +1 -0
  125. package/{src/import-mode/index.ios.ts → build/import-mode/index.ios.js} +1 -0
  126. package/build/import-mode/index.ios.js.map +1 -0
  127. package/build/import-mode/index.js +2 -0
  128. package/build/import-mode/index.js.map +1 -0
  129. package/{src/import-mode/index.web.ts → build/import-mode/index.web.js} +1 -0
  130. package/build/import-mode/index.web.js.map +1 -0
  131. package/build/index.d.ts +3 -3
  132. package/build/index.js +4 -0
  133. package/build/index.js.map +1 -0
  134. package/build/layouts/Drawer.d.ts +2 -2
  135. package/build/layouts/Drawer.d.ts.map +1 -1
  136. package/build/layouts/Drawer.js +6 -0
  137. package/build/layouts/Drawer.js.map +1 -0
  138. package/build/layouts/Stack.d.ts +2 -2
  139. package/build/layouts/Stack.js +6 -0
  140. package/build/layouts/Stack.js.map +1 -0
  141. package/build/layouts/Tabs.d.ts +5 -5
  142. package/build/layouts/Tabs.d.ts.map +1 -1
  143. package/build/layouts/Tabs.js +34 -0
  144. package/build/layouts/Tabs.js.map +1 -0
  145. package/build/layouts/withLayoutContext.d.ts +5 -5
  146. package/build/layouts/withLayoutContext.d.ts.map +1 -1
  147. package/build/layouts/withLayoutContext.js +65 -0
  148. package/build/layouts/withLayoutContext.js.map +1 -0
  149. package/build/link/Link.d.ts +4 -5
  150. package/build/link/Link.d.ts.map +1 -1
  151. package/build/link/Link.js +62 -0
  152. package/build/link/Link.js.map +1 -0
  153. package/build/link/href.js +46 -0
  154. package/build/link/href.js.map +1 -0
  155. package/build/link/linking.d.ts +2 -2
  156. package/build/link/linking.d.ts.map +1 -1
  157. package/build/link/linking.js +86 -0
  158. package/build/link/linking.js.map +1 -0
  159. package/build/link/path.d.ts.map +1 -1
  160. package/build/link/path.js +143 -0
  161. package/build/link/path.js.map +1 -0
  162. package/build/link/stateOperations.d.ts +3 -3
  163. package/build/link/stateOperations.d.ts.map +1 -1
  164. package/build/link/stateOperations.js +98 -0
  165. package/build/link/stateOperations.js.map +1 -0
  166. package/build/link/useLinkToPathProps.d.ts +3 -3
  167. package/build/link/useLinkToPathProps.d.ts.map +1 -1
  168. package/build/link/useLinkToPathProps.js +45 -0
  169. package/build/link/useLinkToPathProps.js.map +1 -0
  170. package/build/link/useLoadedNavigation.d.ts +1 -1
  171. package/build/link/useLoadedNavigation.js +46 -0
  172. package/build/link/useLoadedNavigation.js.map +1 -0
  173. package/build/loadStaticParamsAsync.d.ts +1 -1
  174. package/build/loadStaticParamsAsync.d.ts.map +1 -1
  175. package/build/loadStaticParamsAsync.js +117 -0
  176. package/build/loadStaticParamsAsync.js.map +1 -0
  177. package/build/matchers.js +49 -0
  178. package/build/matchers.js.map +1 -0
  179. package/build/onboard/Tutorial.d.ts.map +1 -1
  180. package/build/onboard/Tutorial.js +168 -0
  181. package/build/onboard/Tutorial.js.map +1 -0
  182. package/{src/onboard/createEntryFile.ts → build/onboard/createEntryFile.js} +19 -22
  183. package/build/onboard/createEntryFile.js.map +1 -0
  184. package/build/primitives.js +5 -0
  185. package/build/primitives.js.map +1 -0
  186. package/build/qualified-entry.d.ts +3 -0
  187. package/build/qualified-entry.d.ts.map +1 -0
  188. package/{_app.tsx → build/qualified-entry.js} +7 -10
  189. package/build/qualified-entry.js.map +1 -0
  190. package/build/renderRootComponent.d.ts +1 -1
  191. package/build/renderRootComponent.d.ts.map +1 -1
  192. package/build/renderRootComponent.js +78 -0
  193. package/build/renderRootComponent.js.map +1 -0
  194. package/build/static/getRootComponent.d.ts.map +1 -1
  195. package/build/static/getRootComponent.js +22 -0
  196. package/build/static/getRootComponent.js.map +1 -0
  197. package/build/static/html.d.ts +1 -1
  198. package/build/static/html.js +25 -0
  199. package/build/static/html.js.map +1 -0
  200. package/build/static/renderStaticContent.d.ts +6 -1
  201. package/build/static/renderStaticContent.d.ts.map +1 -1
  202. package/build/static/renderStaticContent.js +85 -0
  203. package/build/static/renderStaticContent.js.map +1 -0
  204. package/build/testing-library/context-stubs.d.ts +1 -1
  205. package/build/testing-library/context-stubs.d.ts.map +1 -1
  206. package/build/testing-library/context-stubs.js +30 -0
  207. package/build/testing-library/context-stubs.js.map +1 -0
  208. package/build/testing-library/expect.js +14 -0
  209. package/build/testing-library/expect.js.map +1 -0
  210. package/build/testing-library/index.d.ts +4 -4
  211. package/build/testing-library/index.d.ts.map +1 -1
  212. package/build/testing-library/index.js +57 -0
  213. package/build/testing-library/index.js.map +1 -0
  214. package/build/testing-library/mocks.d.ts +1 -1
  215. package/build/testing-library/mocks.js +33 -0
  216. package/build/testing-library/mocks.js.map +1 -0
  217. package/build/testing-library/require-context-ponyfill.d.ts +1 -1
  218. package/build/testing-library/require-context-ponyfill.d.ts.map +1 -1
  219. package/build/testing-library/require-context-ponyfill.js +31 -0
  220. package/build/testing-library/require-context-ponyfill.js.map +1 -0
  221. package/build/types.d.ts +1 -1
  222. package/build/types.d.ts.map +1 -1
  223. package/build/types.js +2 -0
  224. package/build/types.js.map +1 -0
  225. package/build/useDeprecated.d.ts.map +1 -1
  226. package/build/useDeprecated.js +23 -0
  227. package/build/useDeprecated.js.map +1 -0
  228. package/build/useFocusEffect.d.ts.map +1 -1
  229. package/build/useFocusEffect.js +98 -0
  230. package/build/useFocusEffect.js.map +1 -0
  231. package/build/useNavigation.d.ts +1 -1
  232. package/build/useNavigation.d.ts.map +1 -1
  233. package/build/useNavigation.js +63 -0
  234. package/build/useNavigation.js.map +1 -0
  235. package/build/useScreens.d.ts +5 -5
  236. package/build/useScreens.d.ts.map +1 -1
  237. package/build/useScreens.js +183 -0
  238. package/build/useScreens.js.map +1 -0
  239. package/build/utils/mockState.d.ts +1 -1
  240. package/build/utils/mockState.d.ts.map +1 -1
  241. package/build/utils/mockState.js +24 -0
  242. package/build/utils/mockState.js.map +1 -0
  243. package/{src/utils/url.ts → build/utils/url.js} +3 -2
  244. package/build/utils/url.js.map +1 -0
  245. package/build/views/EmptyRoute.js +9 -0
  246. package/build/views/EmptyRoute.js.map +1 -0
  247. package/build/views/ErrorBoundary.d.ts +1 -1
  248. package/build/views/ErrorBoundary.d.ts.map +1 -1
  249. package/build/views/ErrorBoundary.js +149 -0
  250. package/build/views/ErrorBoundary.js.map +1 -0
  251. package/build/views/Navigator.d.ts +11 -11
  252. package/build/views/Navigator.d.ts.map +1 -1
  253. package/build/views/Navigator.js +87 -0
  254. package/build/views/Navigator.js.map +1 -0
  255. package/build/views/Pressable.d.ts +25 -0
  256. package/build/views/Pressable.d.ts.map +1 -0
  257. package/build/views/Pressable.js +3 -0
  258. package/build/views/Pressable.js.map +1 -0
  259. package/build/views/Screen.d.ts.map +1 -1
  260. package/build/views/Screen.js +30 -0
  261. package/build/views/Screen.js.map +1 -0
  262. package/build/views/Sitemap.d.ts +1 -1
  263. package/build/views/Sitemap.d.ts.map +1 -1
  264. package/build/views/Sitemap.js +156 -0
  265. package/build/views/Sitemap.js.map +1 -0
  266. package/build/views/Splash.js +109 -0
  267. package/build/views/Splash.js.map +1 -0
  268. package/build/views/SuspenseFallback.d.ts +1 -1
  269. package/build/views/SuspenseFallback.d.ts.map +1 -1
  270. package/build/views/SuspenseFallback.js +7 -0
  271. package/build/views/SuspenseFallback.js.map +1 -0
  272. package/build/views/Toast.d.ts +1 -1
  273. package/build/views/Toast.d.ts.map +1 -1
  274. package/build/views/Toast.js +79 -0
  275. package/build/views/Toast.js.map +1 -0
  276. package/build/views/Try.d.ts +1 -1
  277. package/build/views/Try.js +27 -0
  278. package/build/views/Try.js.map +1 -0
  279. package/build/views/Unmatched.d.ts.map +1 -1
  280. package/build/views/Unmatched.js +72 -0
  281. package/build/views/Unmatched.js.map +1 -0
  282. package/drawer.d.ts +2 -0
  283. package/drawer.js +1 -0
  284. package/entry.js +4 -5
  285. package/expo-module.config.json +8 -0
  286. package/head.d.ts +1 -0
  287. package/head.js +1 -0
  288. package/html.js +1 -0
  289. package/ios/ExpoHead.podspec +32 -0
  290. package/ios/ExpoHeadAppDelegateSubscriber.swift +94 -0
  291. package/ios/ExpoHeadModule.swift +186 -0
  292. package/node/getExpoConstantsManifest.js +22 -38
  293. package/node/render.js +1 -1
  294. package/package.json +39 -47
  295. package/plugin/build/index.d.ts +1 -1
  296. package/plugin/build/index.js +4 -2
  297. package/plugin/jest.config.js +1 -0
  298. package/stack.d.ts +2 -0
  299. package/stack.js +1 -0
  300. package/tabs.d.ts +2 -0
  301. package/tabs.js +1 -0
  302. package/testing-library.d.ts +1 -0
  303. package/testing-library.js +1 -0
  304. package/types/expect.d.ts +1 -1
  305. package/types/global.d.ts +7 -7
  306. package/types/metro-require.d.ts +1 -1
  307. package/types/react-native-web.d.ts +16 -18
  308. package/_ctx.tsx +0 -5
  309. package/_entry.tsx +0 -33
  310. package/_html-ctx.tsx +0 -9
  311. package/build/fork/expo/createRoot.d.ts +0 -2
  312. package/build/fork/expo/createRoot.d.ts.map +0 -1
  313. package/build/fork/expo/createRoot.native.d.ts +0 -3
  314. package/build/fork/expo/createRoot.native.d.ts.map +0 -1
  315. package/build/fork/expo/registerRootComponent.d.ts +0 -16
  316. package/build/fork/expo/registerRootComponent.d.ts.map +0 -1
  317. package/drawer.ts +0 -2
  318. package/head.ts +0 -6
  319. package/html.ts +0 -1
  320. package/plugin/src/index.ts +0 -54
  321. package/src/ExpoRoot.tsx +0 -128
  322. package/src/LocationProvider.tsx +0 -52
  323. package/src/Route.tsx +0 -120
  324. package/src/exports.ts +0 -34
  325. package/src/fork/NavigationContainer.native.tsx +0 -159
  326. package/src/fork/NavigationContainer.tsx +0 -4
  327. package/src/fork/expo/createRoot.native.tsx +0 -8
  328. package/src/fork/expo/createRoot.tsx +0 -1
  329. package/src/fork/expo/registerRootComponent.tsx +0 -77
  330. package/src/fork/extractPathFromURL.ts +0 -103
  331. package/src/fork/findFocusedRoute.tsx +0 -15
  332. package/src/fork/getPathFromState.ts +0 -647
  333. package/src/fork/getStateFromPath.ts +0 -776
  334. package/src/fork/useLinking.native.ts +0 -224
  335. package/src/fork/useLinking.ts +0 -4
  336. package/src/fork/validatePathConfig.ts +0 -32
  337. package/src/getDevServer/index.native.ts +0 -1
  338. package/src/getDevServer/index.ts +0 -37
  339. package/src/getLinkingConfig.ts +0 -69
  340. package/src/getReactNavigationConfig.ts +0 -103
  341. package/src/getRoutes.ts +0 -520
  342. package/src/global-state/router-store.tsx +0 -251
  343. package/src/global-state/routing.ts +0 -220
  344. package/src/global-state/sort-routes.ts +0 -12
  345. package/src/imperative-api.ts +0 -10
  346. package/src/import-mode/index.ts +0 -1
  347. package/src/index.tsx +0 -3
  348. package/src/layouts/Drawer.tsx +0 -19
  349. package/src/layouts/Stack.tsx +0 -19
  350. package/src/layouts/Tabs.tsx +0 -65
  351. package/src/layouts/withLayoutContext.tsx +0 -119
  352. package/src/link/Link.tsx +0 -104
  353. package/src/link/href.ts +0 -62
  354. package/src/link/linking.ts +0 -106
  355. package/src/link/path.ts +0 -141
  356. package/src/link/stateOperations.ts +0 -163
  357. package/src/link/useLinkToPathProps.tsx +0 -60
  358. package/src/link/useLoadedNavigation.ts +0 -60
  359. package/src/loadStaticParamsAsync.ts +0 -196
  360. package/src/matchers.tsx +0 -56
  361. package/src/onboard/Tutorial.tsx +0 -196
  362. package/src/primitives.tsx +0 -5
  363. package/src/renderRootComponent.tsx +0 -87
  364. package/src/static/getRootComponent.ts +0 -28
  365. package/src/static/html.tsx +0 -38
  366. package/src/static/renderStaticContent.tsx +0 -103
  367. package/src/testing-library/context-stubs.ts +0 -52
  368. package/src/testing-library/expect.ts +0 -15
  369. package/src/testing-library/index.tsx +0 -103
  370. package/src/testing-library/mocks.ts +0 -39
  371. package/src/testing-library/require-context-ponyfill.ts +0 -44
  372. package/src/ts-declarations.d.ts +0 -1
  373. package/src/types.ts +0 -30
  374. package/src/useDeprecated.ts +0 -35
  375. package/src/useFocusEffect.tsx +0 -121
  376. package/src/useNavigation.ts +0 -84
  377. package/src/useScreens.tsx +0 -310
  378. package/src/utils/mockState.ts +0 -31
  379. package/src/views/EmptyRoute.tsx +0 -16
  380. package/src/views/ErrorBoundary.tsx +0 -171
  381. package/src/views/Navigator.tsx +0 -164
  382. package/src/views/Screen.tsx +0 -67
  383. package/src/views/Sitemap.tsx +0 -269
  384. package/src/views/Splash.tsx +0 -125
  385. package/src/views/SuspenseFallback.tsx +0 -12
  386. package/src/views/Toast.tsx +0 -102
  387. package/src/views/Try.tsx +0 -46
  388. package/src/views/Unmatched.tsx +0 -97
  389. package/stack.ts +0 -2
  390. package/tabs.ts +0 -2
package/README.md CHANGED
@@ -1,3 +1,3 @@
1
1
  # expo-router
2
2
 
3
- Check out the [Expo Router documentation](https://expo.github.io/router/docs) for more information.
3
+ Check out the [Expo Router documentation](https://docs.expo.dev/routing/introduction/) for more information.
@@ -1,7 +1,6 @@
1
1
  export const ctx = require.context(
2
- process.env.EXPO_ROUTER_APP_ROOT!,
2
+ process.env.EXPO_ROUTER_APP_ROOT,
3
3
  true,
4
4
  /.*/,
5
- // @ts-expect-error
6
5
  process.env.EXPO_ROUTER_IMPORT_MODE_ANDROID
7
6
  );
package/_ctx.d.ts ADDED
@@ -0,0 +1 @@
1
+ export const ctx: ReturnType<typeof require.context>;
@@ -1,7 +1,6 @@
1
1
  export const ctx = require.context(
2
- process.env.EXPO_ROUTER_APP_ROOT!,
2
+ process.env.EXPO_ROUTER_APP_ROOT,
3
3
  true,
4
4
  /.*/,
5
- // @ts-expect-error
6
5
  process.env.EXPO_ROUTER_IMPORT_MODE_IOS
7
6
  );
package/_ctx.js ADDED
@@ -0,0 +1 @@
1
+ export const ctx = require.context(process.env.EXPO_ROUTER_APP_ROOT, true, /.*/);
@@ -1,7 +1,6 @@
1
1
  export const ctx = require.context(
2
- process.env.EXPO_ROUTER_APP_ROOT!,
2
+ process.env.EXPO_ROUTER_APP_ROOT,
3
3
  true,
4
4
  /.*/,
5
- // @ts-expect-error
6
5
  process.env.EXPO_ROUTER_IMPORT_MODE_WEB
7
6
  );
package/_error.js CHANGED
@@ -1,6 +1,4 @@
1
- // import "@expo/metro-runtime";
2
-
3
- import { LogBoxInspectorContainer } from "@expo/metro-runtime/build/error-overlay/ErrorOverlay";
4
- import { registerRootComponent } from "expo";
1
+ import { LogBoxInspectorContainer } from '@expo/metro-runtime/build/error-overlay/ErrorOverlay';
2
+ import { registerRootComponent } from 'expo';
5
3
 
6
4
  registerRootComponent(LogBoxInspectorContainer);
package/app.plugin.js CHANGED
@@ -1 +1 @@
1
- module.exports = require("./plugin/build");
1
+ module.exports = require('./plugin/build');
package/babel.js CHANGED
@@ -1,11 +1,11 @@
1
- const { getConfig } = require("expo/config");
2
- const fs = require("fs");
3
- const nodePath = require("path");
4
- const resolveFrom = require("resolve-from");
1
+ const { getConfig } = require('expo/config');
2
+ const fs = require('fs');
3
+ const nodePath = require('path');
4
+ const resolveFrom = require('resolve-from');
5
5
 
6
- const { getExpoConstantsManifest } = require("./node/getExpoConstantsManifest");
6
+ const { getExpoConstantsManifest } = require('./node/getExpoConstantsManifest');
7
7
 
8
- const debug = require("debug")("expo:router:babel");
8
+ const debug = require('debug')('expo:router:babel');
9
9
 
10
10
  function getExpoAppManifest(projectRoot) {
11
11
  if (process.env.APP_MANIFEST) {
@@ -14,7 +14,7 @@ function getExpoAppManifest(projectRoot) {
14
14
 
15
15
  const exp = getExpoConstantsManifest(projectRoot);
16
16
 
17
- debug("public manifest", exp);
17
+ debug('public manifest', exp);
18
18
 
19
19
  return JSON.stringify(exp);
20
20
  }
@@ -29,7 +29,7 @@ function getConfigMemo(projectRoot) {
29
29
  }
30
30
 
31
31
  function getExpoRouterImportMode(projectRoot, platform) {
32
- const envVar = "EXPO_ROUTER_IMPORT_MODE_" + platform.toUpperCase();
32
+ const envVar = 'EXPO_ROUTER_IMPORT_MODE_' + platform.toUpperCase();
33
33
  if (process.env[envVar]) {
34
34
  return process.env[envVar];
35
35
  }
@@ -41,30 +41,30 @@ function getExpoRouterImportMode(projectRoot, platform) {
41
41
 
42
42
  if (exp.extra?.router?.asyncRoutes) {
43
43
  const asyncRoutes = exp.extra?.router?.asyncRoutes;
44
- if (typeof asyncRoutes === "string") {
44
+ if (typeof asyncRoutes === 'string') {
45
45
  asyncRoutesSetting = asyncRoutes;
46
- } else if (typeof asyncRoutes === "object") {
46
+ } else if (typeof asyncRoutes === 'object') {
47
47
  asyncRoutesSetting = asyncRoutes[platform] ?? asyncRoutes.default;
48
48
  }
49
49
  }
50
50
 
51
- let mode = [env, true].includes(asyncRoutesSetting) ? "lazy" : "sync";
51
+ let mode = [env, true].includes(asyncRoutesSetting) ? 'lazy' : 'sync';
52
52
 
53
53
  // TODO: Production bundle splitting
54
54
 
55
- if (env === "production" && mode === "lazy") {
55
+ if (env === 'production' && mode === 'lazy') {
56
56
  throw new Error(
57
- "Async routes are not supported in production yet. Set the `expo-router` Config Plugin prop `asyncRoutes` to `development`, `false`, or `undefined`."
57
+ 'Async routes are not supported in production yet. Set the `expo-router` Config Plugin prop `asyncRoutes` to `development`, `false`, or `undefined`.'
58
58
  );
59
59
  }
60
60
 
61
61
  // NOTE: This is a temporary workaround for static rendering on web.
62
- if (platform === "web" && (exp.web || {}).output === "static") {
63
- mode = "sync";
62
+ if (platform === 'web' && (exp.web || {}).output === 'static') {
63
+ mode = 'sync';
64
64
  }
65
65
 
66
66
  // Development
67
- debug("Router import mode", mode);
67
+ debug('Router import mode', mode);
68
68
 
69
69
  process.env[envVar] = mode;
70
70
  return mode;
@@ -76,13 +76,13 @@ function directoryExistsSync(file) {
76
76
 
77
77
  function getRouterDirectory(projectRoot) {
78
78
  // more specific directories first
79
- if (directoryExistsSync(nodePath.join(projectRoot, "src/app"))) {
79
+ if (directoryExistsSync(nodePath.join(projectRoot, 'src/app'))) {
80
80
  // Log.log(chalk.gray('Using src/app as the root directory for Expo Router.'));
81
- return "./src/app";
81
+ return './src/app';
82
82
  }
83
83
 
84
84
  // Log.debug('Using app as the root directory for Expo Router.');
85
- return "./app";
85
+ return './app';
86
86
  }
87
87
 
88
88
  function getExpoRouterAppRoot(projectRoot) {
@@ -92,12 +92,12 @@ function getExpoRouterAppRoot(projectRoot) {
92
92
  if (process.env.EXPO_ROUTER_APP_ROOT_2) {
93
93
  return process.env.EXPO_ROUTER_APP_ROOT_2;
94
94
  }
95
- const routerEntry = resolveFrom.silent(projectRoot, "expo-router/entry");
95
+ const routerEntry = resolveFrom.silent(projectRoot, 'expo-router/entry');
96
96
 
97
97
  // It doesn't matter if the app folder exists.
98
98
  const appFolder = getExpoRouterAbsoluteAppRoot(projectRoot);
99
99
  const appRoot = nodePath.relative(nodePath.dirname(routerEntry), appFolder);
100
- debug("routerEntry", routerEntry, appFolder, appRoot);
100
+ debug('routerEntry', routerEntry, appFolder, appRoot);
101
101
 
102
102
  process.env.EXPO_ROUTER_APP_ROOT_2 = appRoot;
103
103
  return appRoot;
@@ -108,15 +108,12 @@ function getExpoRouterAbsoluteAppRoot(projectRoot) {
108
108
  return process.env.EXPO_ROUTER_ABS_APP_ROOT;
109
109
  }
110
110
  const { exp } = getConfigMemo(projectRoot);
111
- const customSrc =
112
- exp.extra?.router?.unstable_src || getRouterDirectory(projectRoot);
113
- const isAbsolute = customSrc.startsWith("/");
111
+ const customSrc = exp.extra?.router?.unstable_src || getRouterDirectory(projectRoot);
112
+ const isAbsolute = customSrc.startsWith('/');
114
113
  // It doesn't matter if the app folder exists.
115
- const appFolder = isAbsolute
116
- ? customSrc
117
- : nodePath.join(projectRoot, customSrc);
114
+ const appFolder = isAbsolute ? customSrc : nodePath.join(projectRoot, customSrc);
118
115
  const appRoot = appFolder;
119
- debug("absolute router entry", appFolder, appRoot);
116
+ debug('absolute router entry', appFolder, appRoot);
120
117
 
121
118
  process.env.EXPO_ROUTER_ABS_APP_ROOT = appFolder;
122
119
  return appRoot;
@@ -125,16 +122,15 @@ function getExpoRouterAbsoluteAppRoot(projectRoot) {
125
122
 
126
123
  module.exports = function (api) {
127
124
  const { types: t } = api;
128
- const getRelPath = (state) =>
129
- "./" + nodePath.relative(state.file.opts.root, state.filename);
125
+ const getRelPath = (state) => './' + nodePath.relative(state.file.opts.root, state.filename);
130
126
 
131
127
  const platform = api.caller((caller) => caller?.platform);
132
128
  return {
133
- name: "expo-router",
129
+ name: 'expo-router',
134
130
  visitor: {
135
131
  // Add support for Node.js __filename
136
132
  Identifier(path, state) {
137
- if (path.node.name === "__filename") {
133
+ if (path.node.name === '__filename') {
138
134
  path.replaceWith(
139
135
  t.stringLiteral(
140
136
  // `/index.js` is the value used by Webpack.
@@ -144,16 +140,16 @@ module.exports = function (api) {
144
140
  }
145
141
  // Add support for Node.js `__dirname`.
146
142
  // This static value comes from Webpack somewhere.
147
- if (path.node.name === "__dirname") {
148
- path.replaceWith(t.stringLiteral("/"));
143
+ if (path.node.name === '__dirname') {
144
+ path.replaceWith(t.stringLiteral('/'));
149
145
  }
150
146
  },
151
147
 
152
148
  // Convert `process.env.EXPO_ROUTER_APP_ROOT` to a string literal
153
149
  MemberExpression(path, state) {
154
150
  if (
155
- !t.isIdentifier(path.node.object, { name: "process" }) ||
156
- !t.isIdentifier(path.node.property, { name: "env" })
151
+ !t.isIdentifier(path.node.object, { name: 'process' }) ||
152
+ !t.isIdentifier(path.node.property, { name: 'env' })
157
153
  ) {
158
154
  return;
159
155
  }
@@ -163,13 +159,12 @@ module.exports = function (api) {
163
159
  return;
164
160
  }
165
161
 
166
- const projectRoot =
167
- process.env.EXPO_PROJECT_ROOT || state.file.opts.root || "";
162
+ const projectRoot = process.env.EXPO_PROJECT_ROOT || state.file.opts.root || '';
168
163
 
169
164
  // Used for log box and stuff
170
165
  if (
171
166
  t.isIdentifier(parent.node.property, {
172
- name: "EXPO_PROJECT_ROOT",
167
+ name: 'EXPO_PROJECT_ROOT',
173
168
  }) &&
174
169
  !parent.parentPath.isAssignmentExpression()
175
170
  ) {
@@ -179,40 +174,36 @@ module.exports = function (api) {
179
174
  // TODO: Use a serializer or something to ensure this changes without
180
175
  // needing to clear the cache.
181
176
  t.isIdentifier(parent.node.property, {
182
- name: "EXPO_PUBLIC_USE_STATIC",
177
+ name: 'EXPO_PUBLIC_USE_STATIC',
183
178
  }) &&
184
179
  !parent.parentPath.isAssignmentExpression() &&
185
180
  process.env.EXPO_PUBLIC_USE_STATIC
186
181
  ) {
187
- parent.replaceWith(
188
- t.stringLiteral(process.env.EXPO_PUBLIC_USE_STATIC)
189
- );
182
+ parent.replaceWith(t.stringLiteral(process.env.EXPO_PUBLIC_USE_STATIC));
190
183
  } else if (
191
184
  // Surfaces the `app.json` (config) as an environment variable which is then parsed by
192
185
  // `expo-constants` https://docs.expo.dev/versions/latest/sdk/constants/
193
186
  t.isIdentifier(parent.node.property, {
194
- name: "APP_MANIFEST",
187
+ name: 'APP_MANIFEST',
195
188
  }) &&
196
189
  !parent.parentPath.isAssignmentExpression()
197
190
  ) {
198
191
  const manifest = getExpoAppManifest(projectRoot);
199
192
  parent.replaceWith(t.stringLiteral(manifest));
200
193
  } else if (
201
- process.env.NODE_ENV !== "test" &&
194
+ process.env.NODE_ENV !== 'test' &&
202
195
  t.isIdentifier(parent.node.property, {
203
- name: "EXPO_ROUTER_ABS_APP_ROOT",
196
+ name: 'EXPO_ROUTER_ABS_APP_ROOT',
204
197
  }) &&
205
198
  !parent.parentPath.isAssignmentExpression()
206
199
  ) {
207
- parent.replaceWith(
208
- t.stringLiteral(getExpoRouterAbsoluteAppRoot(projectRoot))
209
- );
200
+ parent.replaceWith(t.stringLiteral(getExpoRouterAbsoluteAppRoot(projectRoot)));
210
201
  } else if (
211
202
  // Skip loading the app root in tests.
212
203
  // This is handled by the testing-library utils
213
- process.env.NODE_ENV !== "test" &&
204
+ process.env.NODE_ENV !== 'test' &&
214
205
  t.isIdentifier(parent.node.property, {
215
- name: "EXPO_ROUTER_APP_ROOT",
206
+ name: 'EXPO_ROUTER_APP_ROOT',
216
207
  }) &&
217
208
  !parent.parentPath.isAssignmentExpression()
218
209
  ) {
@@ -224,13 +215,11 @@ module.exports = function (api) {
224
215
  // Expose the app route import mode.
225
216
  platform &&
226
217
  t.isIdentifier(parent.node.property, {
227
- name: "EXPO_ROUTER_IMPORT_MODE_" + platform.toUpperCase(),
218
+ name: 'EXPO_ROUTER_IMPORT_MODE_' + platform.toUpperCase(),
228
219
  }) &&
229
220
  !parent.parentPath.isAssignmentExpression()
230
221
  ) {
231
- parent.replaceWith(
232
- t.stringLiteral(getExpoRouterImportMode(projectRoot, platform))
233
- );
222
+ parent.replaceWith(t.stringLiteral(getExpoRouterImportMode(projectRoot, platform)));
234
223
  }
235
224
  },
236
225
  },
@@ -1,5 +1,5 @@
1
- import { FunctionComponent, ReactNode } from "react";
2
- import { RequireContext } from "./types";
1
+ import { FunctionComponent, ReactNode } from 'react';
2
+ import { RequireContext } from './types';
3
3
  export type ExpoRootProps = {
4
4
  context: RequireContext;
5
5
  location?: URL;
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoRoot.d.ts","sourceRoot":"","sources":["../src/ExpoRoot.tsx"],"names":[],"mappings":"AAEA,OAAc,EAAE,iBAAiB,EAAE,SAAS,EAAY,MAAM,OAAO,CAAC;AAMtE,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAGzC,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,EAAE,cAAc,CAAC;IACxB,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,OAAO,CAAC,EAAE,iBAAiB,CAAC;QAAE,QAAQ,EAAE,SAAS,CAAA;KAAE,CAAC,CAAC;CACtD,CAAC;AAqCF,wBAAgB,QAAQ,CAAC,EACvB,OAAO,EAAE,aAAwB,EACjC,GAAG,KAAK,EACT,EAAE,aAAa,eA2Bf"}
1
+ {"version":3,"file":"ExpoRoot.d.ts","sourceRoot":"","sources":["../src/ExpoRoot.tsx"],"names":[],"mappings":"AAEA,OAAc,EAAE,iBAAiB,EAAE,SAAS,EAAY,MAAM,OAAO,CAAC;AAMtE,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAGzC,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,EAAE,cAAc,CAAC;IACxB,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,OAAO,CAAC,EAAE,iBAAiB,CAAC;QAAE,QAAQ,EAAE,SAAS,CAAA;KAAE,CAAC,CAAC;CACtD,CAAC;AAoCF,wBAAgB,QAAQ,CAAC,EAAE,OAAO,EAAE,aAAwB,EAAE,GAAG,KAAK,EAAE,EAAE,aAAa,eAuBtF"}
@@ -0,0 +1,82 @@
1
+ import Constants from 'expo-constants';
2
+ import { StatusBar } from 'expo-status-bar';
3
+ import React, { Fragment } from 'react';
4
+ import { Platform, StyleSheet } from 'react-native';
5
+ import { SafeAreaProvider } from 'react-native-safe-area-context';
6
+ import UpstreamNavigationContainer from './fork/NavigationContainer';
7
+ import { useInitializeExpoRouter } from './global-state/router-store';
8
+ import { SplashScreen } from './views/Splash';
9
+ function getGestureHandlerRootView() {
10
+ try {
11
+ const { GestureHandlerRootView } = require('react-native-gesture-handler');
12
+ if (!GestureHandlerRootView) {
13
+ return React.Fragment;
14
+ }
15
+ // eslint-disable-next-line no-inner-declarations
16
+ function GestureHandler(props) {
17
+ return React.createElement(GestureHandlerRootView, { style: styles.gesture, ...props });
18
+ }
19
+ if (process.env.NODE_ENV === 'development') {
20
+ // @ts-expect-error
21
+ GestureHandler.displayName = 'GestureHandlerRootView';
22
+ }
23
+ return GestureHandler;
24
+ }
25
+ catch {
26
+ return React.Fragment;
27
+ }
28
+ }
29
+ const GestureHandlerRootView = getGestureHandlerRootView();
30
+ const INITIAL_METRICS = {
31
+ frame: { x: 0, y: 0, width: 0, height: 0 },
32
+ insets: { top: 0, left: 0, right: 0, bottom: 0 },
33
+ };
34
+ const hasViewControllerBasedStatusBarAppearance = Platform.OS === 'ios' &&
35
+ !!Constants.expoConfig?.ios?.infoPlist?.UIViewControllerBasedStatusBarAppearance;
36
+ export function ExpoRoot({ wrapper: ParentWrapper = Fragment, ...props }) {
37
+ /*
38
+ * Due to static rendering we need to wrap these top level views in second wrapper
39
+ * View's like <GestureHandlerRootView /> generate a <div> so if the parent wrapper
40
+ * is a HTML document, we need to ensure its inside the <body>
41
+ */
42
+ const wrapper = ({ children }) => {
43
+ return (React.createElement(ParentWrapper, null,
44
+ React.createElement(GestureHandlerRootView, null,
45
+ React.createElement(SafeAreaProvider
46
+ // SSR support
47
+ , {
48
+ // SSR support
49
+ initialMetrics: INITIAL_METRICS },
50
+ children,
51
+ !hasViewControllerBasedStatusBarAppearance && React.createElement(StatusBar, { style: "auto" })))));
52
+ };
53
+ return React.createElement(ContextNavigator, { ...props, wrapper: wrapper });
54
+ }
55
+ const initialUrl = Platform.OS === 'web' && typeof window !== 'undefined'
56
+ ? new URL(window.location.href)
57
+ : undefined;
58
+ function ContextNavigator({ context, location: initialLocation = initialUrl, wrapper: WrapperComponent = Fragment, }) {
59
+ const store = useInitializeExpoRouter(context, initialLocation);
60
+ if (store.shouldShowTutorial()) {
61
+ SplashScreen.hideAsync();
62
+ if (process.env.NODE_ENV === 'development') {
63
+ const Tutorial = require('./onboard/Tutorial').Tutorial;
64
+ return (React.createElement(WrapperComponent, null,
65
+ React.createElement(Tutorial, null)));
66
+ }
67
+ else {
68
+ // Ensure tutorial styles are stripped in production.
69
+ return null;
70
+ }
71
+ }
72
+ const Component = store.rootComponent;
73
+ return (React.createElement(UpstreamNavigationContainer, { ref: store.navigationRef, initialState: store.initialState, linking: store.linking, documentTitle: {
74
+ enabled: false,
75
+ } },
76
+ React.createElement(WrapperComponent, null,
77
+ React.createElement(Component, null))));
78
+ }
79
+ const styles = StyleSheet.create({
80
+ gesture: { flex: 1 },
81
+ });
82
+ //# sourceMappingURL=ExpoRoot.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExpoRoot.js","sourceRoot":"","sources":["../src/ExpoRoot.tsx"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,iBA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OAAO,CACL,oBAAC,gBAAgB;gBACf,oBAAC,QAAQ,OAAG,CACK,CACpB,CAAC;SACH;aAAM;YACL,qDAAqD;YACrD,OAAO,IAAI,CAAC;SACb;KACF;IAED,MAAM,SAAS,GAAG,KAAK,CAAC,aAAa,CAAC;IAEtC,OAAO,CACL,oBAAC,2BAA2B,IAC1B,GAAG,EAAE,KAAK,CAAC,aAAa,EACxB,YAAY,EAAE,KAAK,CAAC,YAAY,EAChC,OAAO,EAAE,KAAK,CAAC,OAAO,EACtB,aAAa,EAAE;YACb,OAAO,EAAE,KAAK;SACf;QACD,oBAAC,gBAAgB;YACf,oBAAC,SAAS,OAAG,CACI,CACS,CAC/B,CAAC;AACJ,CAAC;AAED,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IAC/B,OAAO,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE;CACrB,CAAC,CAAC","sourcesContent":["import Constants from 'expo-constants';\nimport { StatusBar } from 'expo-status-bar';\nimport React, { FunctionComponent, ReactNode, Fragment } from 'react';\nimport { Platform, StyleSheet } from 'react-native';\nimport { SafeAreaProvider } from 'react-native-safe-area-context';\n\nimport UpstreamNavigationContainer from './fork/NavigationContainer';\nimport { useInitializeExpoRouter } from './global-state/router-store';\nimport { RequireContext } from './types';\nimport { SplashScreen } from './views/Splash';\n\nexport type ExpoRootProps = {\n context: RequireContext;\n location?: URL;\n wrapper?: FunctionComponent<{ children: ReactNode }>;\n};\n\nfunction getGestureHandlerRootView() {\n try {\n const { GestureHandlerRootView } =\n require('react-native-gesture-handler') as typeof import('react-native-gesture-handler');\n\n if (!GestureHandlerRootView) {\n return React.Fragment;\n }\n\n // eslint-disable-next-line no-inner-declarations\n function GestureHandler(props: any) {\n return <GestureHandlerRootView style={styles.gesture} {...props} />;\n }\n if (process.env.NODE_ENV === 'development') {\n // @ts-expect-error\n GestureHandler.displayName = 'GestureHandlerRootView';\n }\n return GestureHandler;\n } catch {\n return React.Fragment;\n }\n}\n\nconst GestureHandlerRootView = getGestureHandlerRootView();\n\nconst INITIAL_METRICS = {\n frame: { x: 0, y: 0, width: 0, height: 0 },\n insets: { top: 0, left: 0, right: 0, bottom: 0 },\n};\n\nconst hasViewControllerBasedStatusBarAppearance =\n Platform.OS === 'ios' &&\n !!Constants.expoConfig?.ios?.infoPlist?.UIViewControllerBasedStatusBarAppearance;\n\nexport function ExpoRoot({ wrapper: ParentWrapper = Fragment, ...props }: ExpoRootProps) {\n /*\n * Due to static rendering we need to wrap these top level views in second wrapper\n * View's like <GestureHandlerRootView /> generate a <div> so if the parent wrapper\n * is a HTML document, we need to ensure its inside the <body>\n */\n const wrapper = ({ children }) => {\n return (\n <ParentWrapper>\n <GestureHandlerRootView>\n <SafeAreaProvider\n // SSR support\n initialMetrics={INITIAL_METRICS}>\n {children}\n {/* Users can override this by adding another StatusBar element anywhere higher in the component tree. */}\n {!hasViewControllerBasedStatusBarAppearance && <StatusBar style=\"auto\" />}\n </SafeAreaProvider>\n </GestureHandlerRootView>\n </ParentWrapper>\n );\n };\n\n return <ContextNavigator {...props} wrapper={wrapper} />;\n}\n\nconst initialUrl =\n Platform.OS === 'web' && typeof window !== 'undefined'\n ? new URL(window.location.href)\n : undefined;\n\nfunction ContextNavigator({\n context,\n location: initialLocation = initialUrl,\n wrapper: WrapperComponent = Fragment,\n}: ExpoRootProps) {\n const store = useInitializeExpoRouter(context, initialLocation);\n\n if (store.shouldShowTutorial()) {\n SplashScreen.hideAsync();\n if (process.env.NODE_ENV === 'development') {\n const Tutorial = require('./onboard/Tutorial').Tutorial;\n return (\n <WrapperComponent>\n <Tutorial />\n </WrapperComponent>\n );\n } else {\n // Ensure tutorial styles are stripped in production.\n return null;\n }\n }\n\n const Component = store.rootComponent;\n\n return (\n <UpstreamNavigationContainer\n ref={store.navigationRef}\n initialState={store.initialState}\n linking={store.linking}\n documentTitle={{\n enabled: false,\n }}>\n <WrapperComponent>\n <Component />\n </WrapperComponent>\n </UpstreamNavigationContainer>\n );\n}\n\nconst styles = StyleSheet.create({\n gesture: { flex: 1 },\n});\n"]}
@@ -1,4 +1,4 @@
1
- import { State } from "./fork/getPathFromState";
1
+ import type { State } from './fork/getPathFromState';
2
2
  type SearchParams = Record<string, string | string[]>;
3
3
  export type UrlObject = {
4
4
  unstable_globalHref: string;
@@ -13,6 +13,6 @@ export declare function getRouteInfoFromState(getPathFromState: (state: State, a
13
13
  export declare function getNormalizedStatePath({ path: statePath, params, }: {
14
14
  path: string;
15
15
  params: any;
16
- }): Pick<UrlObject, "segments" | "params">;
16
+ }): Pick<UrlObject, 'segments' | 'params'>;
17
17
  export {};
18
18
  //# sourceMappingURL=LocationProvider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"LocationProvider.d.ts","sourceRoot":"","sources":["../src/LocationProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAEhD,KAAK,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC;AAEtD,MAAM,MAAM,SAAS,GAAG;IACtB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB,CAAC;AAEF,wBAAgB,qBAAqB,CACnC,gBAAgB,EAAE,CAChB,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,OAAO,KACZ;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,GAAG,CAAA;CAAE,EAClC,KAAK,EAAE,KAAK,GACX,SAAS,CASX;AAGD,wBAAgB,sBAAsB,CAAC,EACrC,IAAI,EAAE,SAAS,EACf,MAAM,GACP,EAAE;IACD,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,GAAG,CAAC;CACb,GAAG,IAAI,CAAC,SAAS,EAAE,UAAU,GAAG,QAAQ,CAAC,CAgBzC"}
1
+ {"version":3,"file":"LocationProvider.d.ts","sourceRoot":"","sources":["../src/LocationProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAErD,KAAK,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC;AAEtD,MAAM,MAAM,SAAS,GAAG;IACtB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB,CAAC;AAEF,wBAAgB,qBAAqB,CACnC,gBAAgB,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,KAAK;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,GAAG,CAAA;CAAE,EAClF,KAAK,EAAE,KAAK,GACX,SAAS,CASX;AAGD,wBAAgB,sBAAsB,CAAC,EACrC,IAAI,EAAE,SAAS,EACf,MAAM,GACP,EAAE;IACD,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,GAAG,CAAC;CACb,GAAG,IAAI,CAAC,SAAS,EAAE,UAAU,GAAG,QAAQ,CAAC,CAgBzC"}
@@ -0,0 +1,30 @@
1
+ export function getRouteInfoFromState(getPathFromState, state) {
2
+ const { path } = getPathFromState(state, false);
3
+ const qualified = getPathFromState(state, true);
4
+ return {
5
+ // TODO: This may have a predefined origin attached in the future.
6
+ unstable_globalHref: path,
7
+ pathname: path.split('?')['0'],
8
+ ...getNormalizedStatePath(qualified),
9
+ };
10
+ }
11
+ // TODO: Split up getPathFromState to return all this info at once.
12
+ export function getNormalizedStatePath({ path: statePath, params, }) {
13
+ const [pathname] = statePath.split('?');
14
+ return {
15
+ // Strip empty path at the start
16
+ segments: pathname.split('/').filter(Boolean).map(decodeURIComponent),
17
+ // TODO: This is not efficient, we should generate based on the state instead
18
+ // of converting to string then back to object
19
+ params: Object.entries(params).reduce((prev, [key, value]) => {
20
+ if (Array.isArray(value)) {
21
+ prev[key] = value.map(decodeURIComponent);
22
+ }
23
+ else {
24
+ prev[key] = decodeURIComponent(value);
25
+ }
26
+ return prev;
27
+ }, {}),
28
+ };
29
+ }
30
+ //# sourceMappingURL=LocationProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LocationProvider.js","sourceRoot":"","sources":["../src/LocationProvider.tsx"],"names":[],"mappings":"AAWA,MAAM,UAAU,qBAAqB,CACnC,gBAAkF,EAClF,KAAY;IAEZ,MAAM,EAAE,IAAI,EAAE,GAAG,gBAAgB,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IAChD,MAAM,SAAS,GAAG,gBAAgB,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IAChD,OAAO;QACL,kEAAkE;QAClE,mBAAmB,EAAE,IAAI;QACzB,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC;QAC9B,GAAG,sBAAsB,CAAC,SAAS,CAAC;KACrC,CAAC;AACJ,CAAC;AAED,mEAAmE;AACnE,MAAM,UAAU,sBAAsB,CAAC,EACrC,IAAI,EAAE,SAAS,EACf,MAAM,GAIP;IACC,MAAM,CAAC,QAAQ,CAAC,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACxC,OAAO;QACL,gCAAgC;QAChC,QAAQ,EAAE,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,kBAAkB,CAAC;QACrE,6EAA6E;QAC7E,8CAA8C;QAC9C,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;YAC3D,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;gBACxB,IAAI,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;aAC3C;iBAAM;gBACL,IAAI,CAAC,GAAG,CAAC,GAAG,kBAAkB,CAAC,KAAe,CAAC,CAAC;aACjD;YACD,OAAO,IAAI,CAAC;QACd,CAAC,EAAE,EAAkB,CAAC;KACvB,CAAC;AACJ,CAAC","sourcesContent":["import type { State } from './fork/getPathFromState';\n\ntype SearchParams = Record<string, string | string[]>;\n\nexport type UrlObject = {\n unstable_globalHref: string;\n pathname: string;\n readonly params: SearchParams;\n segments: string[];\n};\n\nexport function getRouteInfoFromState(\n getPathFromState: (state: State, asPath: boolean) => { path: string; params: any },\n state: State\n): UrlObject {\n const { path } = getPathFromState(state, false);\n const qualified = getPathFromState(state, true);\n return {\n // TODO: This may have a predefined origin attached in the future.\n unstable_globalHref: path,\n pathname: path.split('?')['0'],\n ...getNormalizedStatePath(qualified),\n };\n}\n\n// TODO: Split up getPathFromState to return all this info at once.\nexport function getNormalizedStatePath({\n path: statePath,\n params,\n}: {\n path: string;\n params: any;\n}): Pick<UrlObject, 'segments' | 'params'> {\n const [pathname] = statePath.split('?');\n return {\n // Strip empty path at the start\n segments: pathname.split('/').filter(Boolean).map(decodeURIComponent),\n // TODO: This is not efficient, we should generate based on the state instead\n // of converting to string then back to object\n params: Object.entries(params).reduce((prev, [key, value]) => {\n if (Array.isArray(value)) {\n prev[key] = value.map(decodeURIComponent);\n } else {\n prev[key] = decodeURIComponent(value as string);\n }\n return prev;\n }, {} as SearchParams),\n };\n}\n"]}
package/build/Route.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import React, { ReactNode } from "react";
2
- import type { ErrorBoundaryProps } from "./exports";
1
+ import React, { ReactNode } from 'react';
2
+ import type { ErrorBoundaryProps } from './exports';
3
3
  export type DynamicConvention = {
4
4
  name: string;
5
5
  deep: boolean;
@@ -35,7 +35,7 @@ export type RouteNode = {
35
35
  export declare function useRouteNode(): RouteNode | null;
36
36
  export declare function useContextKey(): string;
37
37
  /** Provides the matching routes and filename to the children. */
38
- export declare function Route({ children, node, }: {
38
+ export declare function Route({ children, node }: {
39
39
  children: ReactNode;
40
40
  node: RouteNode;
41
41
  }): JSX.Element;
@@ -1 +1 @@
1
- {"version":3,"file":"Route.d.ts","sourceRoot":"","sources":["../src/Route.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAc,MAAM,OAAO,CAAC;AAErD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAGpD,MAAM,MAAM,iBAAiB,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,OAAO,CAAA;CAAE,CAAC;AAEhE,MAAM,MAAM,WAAW,GAAG;IACxB,aAAa,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,kBAAkB,CAAC,CAAC;IACxD,OAAO,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;IACnC,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACxC,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,GAAG,CAAC;IACnC,oBAAoB,CAAC,EAAE,CAAC,KAAK,EAAE;QAC7B,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC;KAC5C,KAAK,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,EAAE,CAAC;CAC3C,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,kEAAkE;IAClE,SAAS,EAAE,MAAM,OAAO,CAAC,WAAW,CAAC,CAAC;IACtC,iCAAiC;IACjC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,oBAAoB;IACpB,QAAQ,EAAE,SAAS,EAAE,CAAC;IACtB,kCAAkC;IAClC,OAAO,EAAE,IAA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import { getContextKey, matchGroupName } from './matchers';
3
+ const CurrentRouteContext = React.createContext(null);
4
+ if (process.env.NODE_ENV !== 'production') {
5
+ CurrentRouteContext.displayName = 'RouteNode';
6
+ }
7
+ /** Return the RouteNode at the current contextual boundary. */
8
+ export function useRouteNode() {
9
+ return useContext(CurrentRouteContext);
10
+ }
11
+ export function useContextKey() {
12
+ const node = useRouteNode();
13
+ if (node == null) {
14
+ throw new Error('No filename found. This is likely a bug in expo-router.');
15
+ }
16
+ return getContextKey(node.contextKey);
17
+ }
18
+ /** Provides the matching routes and filename to the children. */
19
+ export function Route({ children, node }) {
20
+ return React.createElement(CurrentRouteContext.Provider, { value: node }, children);
21
+ }
22
+ export function sortRoutesWithInitial(initialRouteName) {
23
+ return (a, b) => {
24
+ if (initialRouteName) {
25
+ if (a.route === initialRouteName) {
26
+ return -1;
27
+ }
28
+ if (b.route === initialRouteName) {
29
+ return 1;
30
+ }
31
+ }
32
+ return sortRoutes(a, b);
33
+ };
34
+ }
35
+ export function sortRoutes(a, b) {
36
+ if (a.dynamic && !b.dynamic) {
37
+ return 1;
38
+ }
39
+ if (!a.dynamic && b.dynamic) {
40
+ return -1;
41
+ }
42
+ if (a.dynamic && b.dynamic) {
43
+ if (a.dynamic.length !== b.dynamic.length) {
44
+ return b.dynamic.length - a.dynamic.length;
45
+ }
46
+ for (let i = 0; i < a.dynamic.length; i++) {
47
+ const aDynamic = a.dynamic[i];
48
+ const bDynamic = b.dynamic[i];
49
+ if (aDynamic.deep && !bDynamic.deep) {
50
+ return 1;
51
+ }
52
+ if (!aDynamic.deep && bDynamic.deep) {
53
+ return -1;
54
+ }
55
+ }
56
+ return 0;
57
+ }
58
+ const aIndex = a.route === 'index' || matchGroupName(a.route) != null;
59
+ const bIndex = b.route === 'index' || matchGroupName(b.route) != null;
60
+ if (aIndex && !bIndex) {
61
+ return -1;
62
+ }
63
+ if (!aIndex && bIndex) {
64
+ return 1;
65
+ }
66
+ return a.route.length - b.route.length;
67
+ }
68
+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,CAAC;IAEtE,IAAI,MAAM,IAAI,CAAC,MAAM,EAAE;QACrB,OAAO,CAAC,CAAC,CAAC;KACX;IACD,IAAI,CAAC,MAAM,IAAI,MAAM,EAAE;QACrB,OAAO,CAAC,CAAC;KACV;IAED,OAAO,CAAC,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC;AACzC,CAAC","sourcesContent":["import React, { ReactNode, useContext } from 'react';\n\nimport type { ErrorBoundaryProps } from './exports';\nimport { getContextKey, matchGroupName } from './matchers';\n\nexport type DynamicConvention = { name: string; deep: boolean };\n\nexport type LoadedRoute = {\n ErrorBoundary?: React.ComponentType<ErrorBoundaryProps>;\n default?: React.ComponentType<any>;\n unstable_settings?: Record<string, any>;\n getNavOptions?: (args: any) => any;\n generateStaticParams?: (props: {\n params?: Record<string, string | string[]>;\n }) => Record<string, string | string[]>[];\n};\n\nexport type RouteNode = {\n /** Load a route into memory. Returns the exports from a route. */\n loadRoute: () => Partial<LoadedRoute>;\n /** Loaded initial route name. */\n initialRouteName?: string;\n /** nested routes */\n children: RouteNode[];\n /** Is the route a dynamic path */\n dynamic: null | DynamicConvention[];\n /** `index`, `error-boundary`, etc. */\n route: string;\n /** Context Module ID, used for matching children. */\n contextKey: string;\n /** Added in-memory */\n generated?: boolean;\n /** Internal screens like the directory or the auto 404 should be marked as internal. */\n internal?: boolean;\n};\n\nconst CurrentRouteContext = React.createContext<RouteNode | null>(null);\n\nif (process.env.NODE_ENV !== 'production') {\n CurrentRouteContext.displayName = 'RouteNode';\n}\n\n/** Return the RouteNode at the current contextual boundary. */\nexport function useRouteNode(): RouteNode | null {\n return useContext(CurrentRouteContext);\n}\n\nexport function useContextKey(): string {\n const node = useRouteNode();\n if (node == null) {\n throw new Error('No filename found. This is likely a bug in expo-router.');\n }\n return getContextKey(node.contextKey);\n}\n\n/** Provides the matching routes and filename to the children. */\nexport function Route({ children, node }: { children: ReactNode; node: RouteNode }) {\n return <CurrentRouteContext.Provider value={node}>{children}</CurrentRouteContext.Provider>;\n}\n\nexport function sortRoutesWithInitial(initialRouteName?: string) {\n return (a: RouteNode, b: RouteNode): number => {\n if (initialRouteName) {\n if (a.route === initialRouteName) {\n return -1;\n }\n if (b.route === initialRouteName) {\n return 1;\n }\n }\n return sortRoutes(a, b);\n };\n}\n\nexport function sortRoutes(a: RouteNode, b: RouteNode): number {\n if (a.dynamic && !b.dynamic) {\n return 1;\n }\n if (!a.dynamic && b.dynamic) {\n return -1;\n }\n if (a.dynamic && b.dynamic) {\n if (a.dynamic.length !== b.dynamic.length) {\n return b.dynamic.length - a.dynamic.length;\n }\n for (let i = 0; i < a.dynamic.length; i++) {\n const aDynamic = a.dynamic[i];\n const bDynamic = b.dynamic[i];\n if (aDynamic.deep && !bDynamic.deep) {\n return 1;\n }\n if (!aDynamic.deep && bDynamic.deep) {\n return -1;\n }\n }\n return 0;\n }\n\n const aIndex = a.route === 'index' || matchGroupName(a.route) != null;\n const bIndex = b.route === 'index' || matchGroupName(b.route) != null;\n\n if (aIndex && !bIndex) {\n return -1;\n }\n if (!aIndex && bIndex) {\n return 1;\n }\n\n return a.route.length - b.route.length;\n}\n"]}
@@ -1,14 +1,14 @@
1
- import { Navigator, Slot } from "./views/Navigator";
2
- export { useRouter, useUnstableGlobalHref, usePathname, useGlobalSearchParams, useLocalSearchParams, useSearchParams, useSegments, useRootNavigation, useRootNavigationState, } from "./hooks";
3
- export { router } from "./imperative-api";
4
- export { Link, Redirect } from "./link/Link";
5
- export { withLayoutContext } from "./layouts/withLayoutContext";
1
+ import { Navigator, Slot } from './views/Navigator';
2
+ export { useRouter, useUnstableGlobalHref, usePathname, useGlobalSearchParams, useLocalSearchParams, useSearchParams, useSegments, useRootNavigation, useRootNavigationState, } from './hooks';
3
+ export { router } from './imperative-api';
4
+ export { Link, Redirect } from './link/Link';
5
+ export { withLayoutContext } from './layouts/withLayoutContext';
6
6
  export { Navigator, Slot };
7
- export { ExpoRoot } from "./ExpoRoot";
8
- export { Unmatched } from "./views/Unmatched";
9
- export { ErrorBoundaryProps } from "./views/Try";
10
- export { ErrorBoundary } from "./views/ErrorBoundary";
11
- export { SplashScreen } from "./views/Splash";
12
- export { useNavigation } from "./useNavigation";
13
- export { useFocusEffect } from "./useFocusEffect";
7
+ export { ExpoRoot } from './ExpoRoot';
8
+ export { Unmatched } from './views/Unmatched';
9
+ export { ErrorBoundaryProps } from './views/Try';
10
+ export { ErrorBoundary } from './views/ErrorBoundary';
11
+ export { SplashScreen } from './views/Splash';
12
+ export { useNavigation } from './useNavigation';
13
+ export { useFocusEffect } from './useFocusEffect';
14
14
  //# sourceMappingURL=exports.d.ts.map
@@ -0,0 +1,17 @@
1
+ // Expo Router API
2
+ import { Navigator, Slot } from './views/Navigator';
3
+ export { useRouter, useUnstableGlobalHref, usePathname, useGlobalSearchParams, useLocalSearchParams, useSearchParams, useSegments, useRootNavigation, useRootNavigationState, } from './hooks';
4
+ export { router } from './imperative-api';
5
+ export { Link, Redirect } from './link/Link';
6
+ export { withLayoutContext } from './layouts/withLayoutContext';
7
+ export { Navigator, Slot };
8
+ // Expo Router Views
9
+ export { ExpoRoot } from './ExpoRoot';
10
+ export { Unmatched } from './views/Unmatched';
11
+ export { ErrorBoundary } from './views/ErrorBoundary';
12
+ // Platform
13
+ export { SplashScreen } from './views/Splash';
14
+ // React Navigation
15
+ export { useNavigation } from './useNavigation';
16
+ export { useFocusEffect } from './useFocusEffect';
17
+ //# sourceMappingURL=exports.js.map