one 1.12.6 → 1.12.7

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 (520) hide show
  1. package/devtools/source-inspector.mjs +1 -0
  2. package/dist/cjs/Frozen.native.js +1 -1
  3. package/dist/cjs/Root.native.js +5 -5
  4. package/dist/cjs/Root.native.js.map +1 -1
  5. package/dist/cjs/__mocks__/@react-navigation/native-stack.native.js.map +1 -1
  6. package/dist/cjs/__mocks__/expo-linking.native.js.map +1 -1
  7. package/dist/cjs/__mocks__/expo-modules-core.native.js.map +1 -1
  8. package/dist/cjs/__mocks__/react-native-screens.native.js.map +1 -1
  9. package/dist/cjs/babel-plugins/environment-guard.native.js.map +1 -1
  10. package/dist/cjs/babel-plugins/inline-one-server-url.native.js.map +1 -1
  11. package/dist/cjs/babel-plugins/one-router-metro.cjs +6 -3
  12. package/dist/cjs/babel-plugins/one-router-metro.native.js +3 -3
  13. package/dist/cjs/babel-plugins/one-router-metro.native.js.map +1 -1
  14. package/dist/cjs/babel-plugins/one-router-metro.test.cjs +93 -0
  15. package/dist/cjs/babel-plugins/one-router-metro.test.native.js +100 -0
  16. package/dist/cjs/babel-plugins/one-router-metro.test.native.js.map +1 -0
  17. package/dist/cjs/babel-plugins/remove-server-code.cjs +46 -46
  18. package/dist/cjs/babel-plugins/remove-server-code.native.js +46 -84
  19. package/dist/cjs/babel-plugins/remove-server-code.native.js.map +1 -1
  20. package/dist/cjs/cli/build.cjs +4 -6
  21. package/dist/cjs/cli/build.native.js +21 -23
  22. package/dist/cjs/cli/build.native.js.map +1 -1
  23. package/dist/cjs/cli/buildPage.native.js +6 -6
  24. package/dist/cjs/cli/buildPage.native.js.map +1 -1
  25. package/dist/cjs/cli/buildPageWorker.native.js +1 -1
  26. package/dist/cjs/cli/buildPageWorker.native.js.map +1 -1
  27. package/dist/cjs/cli/checkNodeVersion.native.js.map +1 -1
  28. package/dist/cjs/cli/daemon.native.js +1 -1
  29. package/dist/cjs/cli/daemon.native.js.map +1 -1
  30. package/dist/cjs/cli/dev.cjs +2 -3
  31. package/dist/cjs/cli/dev.native.js +6 -7
  32. package/dist/cjs/cli/dev.native.js.map +1 -1
  33. package/dist/cjs/cli/generateRoutes.native.js +3 -3
  34. package/dist/cjs/cli/generateRoutes.native.js.map +1 -1
  35. package/dist/cjs/cli/generateSitemap.native.js.map +1 -1
  36. package/dist/cjs/cli/generateSitemap.test.native.js +1 -1
  37. package/dist/cjs/cli/generateSitemap.test.native.js.map +1 -1
  38. package/dist/cjs/cli/label-process.native.js.map +1 -1
  39. package/dist/cjs/cli/main.native.js +1 -1
  40. package/dist/cjs/cli/main.native.js.map +1 -1
  41. package/dist/cjs/cli/patch.native.js +1 -1
  42. package/dist/cjs/cli/patch.native.js.map +1 -1
  43. package/dist/cjs/cli/prebuild.native.js.map +1 -1
  44. package/dist/cjs/cli/runAndroid.native.js.map +1 -1
  45. package/dist/cjs/cli/runIos.native.js.map +1 -1
  46. package/dist/cjs/cli/securityScan.cjs +2 -1
  47. package/dist/cjs/cli/securityScan.native.js +2 -1
  48. package/dist/cjs/cli/securityScan.native.js.map +1 -1
  49. package/dist/cjs/cli/workerPool.native.js.map +1 -1
  50. package/dist/cjs/cli.native.js.map +1 -1
  51. package/dist/cjs/clientLoaderResolver.native.js.map +1 -1
  52. package/dist/cjs/config.native.js +1 -1
  53. package/dist/cjs/config.native.js.map +1 -1
  54. package/dist/cjs/constants.native.js +1 -1
  55. package/dist/cjs/constants.native.js.map +1 -1
  56. package/dist/cjs/createAPIRoute.native.js.map +1 -1
  57. package/dist/cjs/createApp.cjs +2 -15
  58. package/dist/cjs/createApp.native.js +3 -3
  59. package/dist/cjs/createHandleRequest.native.js +5 -5
  60. package/dist/cjs/createHandleRequest.native.js.map +1 -1
  61. package/dist/cjs/createHandleRequest.test.native.js +1 -1
  62. package/dist/cjs/createHandleRequest.test.native.js.map +1 -1
  63. package/dist/cjs/createMiddleware.native.js.map +1 -1
  64. package/dist/cjs/daemon/index.native.js +7 -7
  65. package/dist/cjs/daemon/index.native.js.map +1 -1
  66. package/dist/cjs/daemon/ipc.native.js +1 -1
  67. package/dist/cjs/daemon/ipc.native.js.map +1 -1
  68. package/dist/cjs/daemon/picker.native.js.map +1 -1
  69. package/dist/cjs/daemon/proxy.native.js.map +1 -1
  70. package/dist/cjs/daemon/registry.native.js.map +1 -1
  71. package/dist/cjs/daemon/server.native.js +4 -4
  72. package/dist/cjs/daemon/server.native.js.map +1 -1
  73. package/dist/cjs/daemon/tui.native.js +3 -3
  74. package/dist/cjs/daemon/tui.native.js.map +1 -1
  75. package/dist/cjs/daemon/types.native.js.map +1 -1
  76. package/dist/cjs/daemon/utils.native.js.map +1 -1
  77. package/dist/cjs/devtools/registry.native.js.map +1 -1
  78. package/dist/cjs/drawer.native.js +1 -1
  79. package/dist/cjs/drawer.native.js.map +1 -1
  80. package/dist/cjs/fallbackViews/Sitemap.native.js.map +1 -1
  81. package/dist/cjs/fallbackViews/Unmatched.native.js.map +1 -1
  82. package/dist/cjs/fork/NavigationContainer.native.js +5 -5
  83. package/dist/cjs/fork/NavigationContainer.native.js.map +1 -1
  84. package/dist/cjs/fork/SSRNavigationContainer.native.js.map +1 -1
  85. package/dist/cjs/fork/__tests__/getPathFromState.test.native.js +2 -2
  86. package/dist/cjs/fork/__tests__/getPathFromState.test.native.js.map +1 -1
  87. package/dist/cjs/fork/__tests__/getStateFromPath.test.native.js +3 -3
  88. package/dist/cjs/fork/__tests__/getStateFromPath.test.native.js.map +1 -1
  89. package/dist/cjs/fork/_shared.native.js.map +1 -1
  90. package/dist/cjs/fork/createMemoryHistory.native.js.map +1 -1
  91. package/dist/cjs/fork/extractPathFromURL.native.js.map +1 -1
  92. package/dist/cjs/fork/findFocusedRoute.native.js.map +1 -1
  93. package/dist/cjs/fork/getPathFromState-mods.native.js +2 -2
  94. package/dist/cjs/fork/getPathFromState-mods.native.js.map +1 -1
  95. package/dist/cjs/fork/getPathFromState.native.js +3 -3
  96. package/dist/cjs/fork/getPathFromState.native.js.map +1 -1
  97. package/dist/cjs/fork/getPathFromState.test.native.js +1 -1
  98. package/dist/cjs/fork/getPathFromState.test.native.js.map +1 -1
  99. package/dist/cjs/fork/getStateFromPath-mods.cjs +8 -3
  100. package/dist/cjs/fork/getStateFromPath-mods.native.js +9 -4
  101. package/dist/cjs/fork/getStateFromPath-mods.native.js.map +1 -1
  102. package/dist/cjs/fork/getStateFromPath.native.js +4 -4
  103. package/dist/cjs/fork/getStateFromPath.native.js.map +1 -1
  104. package/dist/cjs/fork/getStateFromPath.test.native.js +4 -4
  105. package/dist/cjs/fork/getStateFromPath.test.native.js.map +1 -1
  106. package/dist/cjs/fork/useLinking.native.js +1 -1
  107. package/dist/cjs/fork/useThenable.native.js.map +1 -1
  108. package/dist/cjs/fork/validatePathConfig.native.js.map +1 -1
  109. package/dist/cjs/getDevServer.native.js +4 -2
  110. package/dist/cjs/getDevServer.native.js.map +1 -1
  111. package/dist/cjs/getReactNavigationConfig.native.js +1 -1
  112. package/dist/cjs/getReactNavigationConfig.native.js.map +1 -1
  113. package/dist/cjs/getURL.native.js +1 -1
  114. package/dist/cjs/head/Head.native.js +1 -1
  115. package/dist/cjs/head/Head.native.js.map +1 -1
  116. package/dist/cjs/head/HeadModule.native.js.map +1 -1
  117. package/dist/cjs/head/index.native.js +1 -1
  118. package/dist/cjs/head/index.native.js.map +1 -1
  119. package/dist/cjs/head/types.native.js.map +1 -1
  120. package/dist/cjs/head/url.native.js.map +1 -1
  121. package/dist/cjs/headless.cjs +45 -0
  122. package/dist/cjs/headless.native.js +54 -0
  123. package/dist/cjs/headless.native.js.map +1 -0
  124. package/dist/cjs/hooks.native.js +4 -4
  125. package/dist/cjs/hooks.native.js.map +1 -1
  126. package/dist/cjs/hooks.test.native.js.map +1 -1
  127. package/dist/cjs/href.native.js.map +1 -1
  128. package/dist/cjs/image/getImageData.native.js.map +1 -1
  129. package/dist/cjs/image.native.js +1 -1
  130. package/dist/cjs/image.native.js.map +1 -1
  131. package/dist/cjs/index.native.js +42 -42
  132. package/dist/cjs/index.native.js.map +1 -1
  133. package/dist/cjs/interfaces/router.native.js.map +1 -1
  134. package/dist/cjs/layouts/Drawer.native.js +1 -1
  135. package/dist/cjs/layouts/Drawer.native.js.map +1 -1
  136. package/dist/cjs/layouts/Stack.native.js +5 -5
  137. package/dist/cjs/layouts/Stack.native.js.map +1 -1
  138. package/dist/cjs/layouts/Tabs.native.js +2 -2
  139. package/dist/cjs/layouts/Tabs.native.js.map +1 -1
  140. package/dist/cjs/layouts/stack-utils/StackHeaderBackButton.native.js.map +1 -1
  141. package/dist/cjs/layouts/stack-utils/StackHeaderComponent.native.js +6 -6
  142. package/dist/cjs/layouts/stack-utils/StackHeaderComponent.native.js.map +1 -1
  143. package/dist/cjs/layouts/stack-utils/StackHeaderLeft.native.js.map +1 -1
  144. package/dist/cjs/layouts/stack-utils/StackHeaderRight.native.js.map +1 -1
  145. package/dist/cjs/layouts/stack-utils/StackHeaderSearchBar.native.js.map +1 -1
  146. package/dist/cjs/layouts/stack-utils/StackHeaderTitle.native.js +1 -1
  147. package/dist/cjs/layouts/stack-utils/StackHeaderTitle.native.js.map +1 -1
  148. package/dist/cjs/layouts/stack-utils/StackScreen.native.js +2 -2
  149. package/dist/cjs/layouts/stack-utils/StackScreen.native.js.map +1 -1
  150. package/dist/cjs/layouts/stack-utils/__tests__/composition.test.native.js +8 -8
  151. package/dist/cjs/layouts/stack-utils/__tests__/composition.test.native.js.map +1 -1
  152. package/dist/cjs/layouts/stack-utils/index.native.js +7 -7
  153. package/dist/cjs/layouts/stack-utils/index.native.js.map +1 -1
  154. package/dist/cjs/layouts/withLayoutContext.native.js +7 -7
  155. package/dist/cjs/layouts/withLayoutContext.native.js.map +1 -1
  156. package/dist/cjs/link/Link.native.js +2 -2
  157. package/dist/cjs/link/Link.native.js.map +1 -1
  158. package/dist/cjs/link/Redirect.native.js +2 -2
  159. package/dist/cjs/link/Redirect.native.js.map +1 -1
  160. package/dist/cjs/link/href.native.js.map +1 -1
  161. package/dist/cjs/link/linking.native.js +3 -3
  162. package/dist/cjs/link/path.native.js.map +1 -1
  163. package/dist/cjs/link/prefetchIntent.native.js.map +1 -1
  164. package/dist/cjs/link/prefetchIntent.test.native.js +1 -1
  165. package/dist/cjs/link/prefetchIntent.test.native.js.map +1 -1
  166. package/dist/cjs/link/prefetchViewport.native.js.map +1 -1
  167. package/dist/cjs/link/prefetchViewport.test.native.js +1 -1
  168. package/dist/cjs/link/prefetchViewport.test.native.js.map +1 -1
  169. package/dist/cjs/link/useLinkTo.native.js +3 -3
  170. package/dist/cjs/link/useLinkTo.native.js.map +1 -1
  171. package/dist/cjs/link/useLoadedNavigation.native.js +1 -1
  172. package/dist/cjs/link/useLoadedNavigation.native.js.map +1 -1
  173. package/dist/cjs/metro-config/getViteMetroPluginOptions.cjs +18 -7
  174. package/dist/cjs/metro-config/getViteMetroPluginOptions.native.js +13 -4
  175. package/dist/cjs/metro-config/getViteMetroPluginOptions.native.js.map +1 -1
  176. package/dist/cjs/notFoundState.native.js.map +1 -1
  177. package/dist/cjs/polyfills-mobile.native.js +1 -1
  178. package/dist/cjs/polyfills-mobile.native.js.map +1 -1
  179. package/dist/cjs/polyfills-server.native.js.map +1 -1
  180. package/dist/cjs/router/FlagsContext.native.js.map +1 -1
  181. package/dist/cjs/router/Route.native.js +2 -2
  182. package/dist/cjs/router/Route.native.js.map +1 -1
  183. package/dist/cjs/router/RouteInfoContext.native.js +1 -1
  184. package/dist/cjs/router/RouteInfoContext.native.js.map +1 -1
  185. package/dist/cjs/router/RouterStore.native.js.map +1 -1
  186. package/dist/cjs/router/SpaShellContext.native.js.map +1 -1
  187. package/dist/cjs/router/createRoute.native.js +1 -1
  188. package/dist/cjs/router/createRoute.native.js.map +1 -1
  189. package/dist/cjs/router/filterRootHTML.native.js.map +1 -1
  190. package/dist/cjs/router/findRouteNode.native.js.map +1 -1
  191. package/dist/cjs/router/getLinkingConfig.native.js +2 -2
  192. package/dist/cjs/router/getLinkingConfig.native.js.map +1 -1
  193. package/dist/cjs/router/getNormalizedStatePath.native.js +1 -1
  194. package/dist/cjs/router/getNormalizedStatePath.native.js.map +1 -1
  195. package/dist/cjs/router/getRouteInfo.native.js +5 -5
  196. package/dist/cjs/router/getRouteInfo.native.js.map +1 -1
  197. package/dist/cjs/router/getRoutes.native.js +4 -4
  198. package/dist/cjs/router/getRoutes.native.js.map +1 -1
  199. package/dist/cjs/router/getRoutes.test.native.js +1 -1
  200. package/dist/cjs/router/getRoutes.test.native.js.map +1 -1
  201. package/dist/cjs/router/glob-patterns.native.js.map +1 -1
  202. package/dist/cjs/router/imperative-api.native.js +1 -1
  203. package/dist/cjs/router/imperative-api.native.js.map +1 -1
  204. package/dist/cjs/router/interceptRoutes.native.js +2 -2
  205. package/dist/cjs/router/interceptRoutes.native.js.map +1 -1
  206. package/dist/cjs/router/isIndexPath.native.js.map +1 -1
  207. package/dist/cjs/router/lastAction.native.js.map +1 -1
  208. package/dist/cjs/router/linkingConfig.native.js +3 -3
  209. package/dist/cjs/router/linkingConfig.native.js.map +1 -1
  210. package/dist/cjs/router/matchers.native.js.map +1 -1
  211. package/dist/cjs/router/matchers.test.native.js +1 -1
  212. package/dist/cjs/router/matchers.test.native.js.map +1 -1
  213. package/dist/cjs/router/router.native.js +24 -24
  214. package/dist/cjs/router/router.native.js.map +1 -1
  215. package/dist/cjs/router/serverLocationContext.native.js.map +1 -1
  216. package/dist/cjs/router/sortRoutes.native.js +1 -1
  217. package/dist/cjs/router/sortRoutes.native.js.map +1 -1
  218. package/dist/cjs/router/useInitializeOneRouter.native.js +4 -4
  219. package/dist/cjs/router/useInitializeOneRouter.native.js.map +1 -1
  220. package/dist/cjs/router/useNavigation.native.js +2 -2
  221. package/dist/cjs/router/useNavigation.native.js.map +1 -1
  222. package/dist/cjs/router/useScreens.native.js +11 -11
  223. package/dist/cjs/router/useScreens.native.js.map +1 -1
  224. package/dist/cjs/router/useViteRoutes.native.js +1 -1
  225. package/dist/cjs/router/useViteRoutes.native.js.map +1 -1
  226. package/dist/cjs/router/utils/getNavigateAction.native.js +2 -2
  227. package/dist/cjs/router/utils/getNavigateAction.native.js.map +1 -1
  228. package/dist/cjs/router/utils/getNavigateAction.test.native.js +1 -1
  229. package/dist/cjs/router/utils/getNavigateAction.test.native.js.map +1 -1
  230. package/dist/cjs/screensFeatureFlags.native.js.map +1 -1
  231. package/dist/cjs/serve-worker.native.js +5 -5
  232. package/dist/cjs/serve-worker.native.js.map +1 -1
  233. package/dist/cjs/serve.native.js +4 -4
  234. package/dist/cjs/serve.native.js.map +1 -1
  235. package/dist/cjs/server/ServerContextScript.native.js +4 -4
  236. package/dist/cjs/server/ServerContextScript.native.js.map +1 -1
  237. package/dist/cjs/server/createRoutesManifest.native.js +2 -2
  238. package/dist/cjs/server/createRoutesManifest.native.js.map +1 -1
  239. package/dist/cjs/server/getServerManifest.native.js +1 -1
  240. package/dist/cjs/server/getServerManifest.native.js.map +1 -1
  241. package/dist/cjs/server/getServerManifest.test.native.js +1 -1
  242. package/dist/cjs/server/getServerManifest.test.native.js.map +1 -1
  243. package/dist/cjs/server/oneServe.native.js +6 -6
  244. package/dist/cjs/server/oneServe.native.js.map +1 -1
  245. package/dist/cjs/server/setServerGlobals.native.js.map +1 -1
  246. package/dist/cjs/server/setupBuildOptions.native.js.map +1 -1
  247. package/dist/cjs/server/setupServerGlobals.native.js +1 -1
  248. package/dist/cjs/server/setupServerGlobals.native.js.map +1 -1
  249. package/dist/cjs/server/ssrLoaderData.native.js.map +1 -1
  250. package/dist/cjs/server/staticHtmlFetcher.native.js.map +1 -1
  251. package/dist/cjs/server/workerHandler.native.js +7 -7
  252. package/dist/cjs/server/workerHandler.native.js.map +1 -1
  253. package/dist/cjs/server-render.native.js.map +1 -1
  254. package/dist/cjs/skewProtection.native.js +2 -2
  255. package/dist/cjs/skewProtection.native.js.map +1 -1
  256. package/dist/cjs/testing-utils.native.js +2 -2
  257. package/dist/cjs/testing-utils.native.js.map +1 -1
  258. package/dist/cjs/typed-routes/generateRouteTypes.native.js +5 -5
  259. package/dist/cjs/typed-routes/generateRouteTypes.native.js.map +1 -1
  260. package/dist/cjs/typed-routes/getTypedRoutesDeclarationFile.native.js +2 -2
  261. package/dist/cjs/typed-routes/getTypedRoutesDeclarationFile.native.js.map +1 -1
  262. package/dist/cjs/typed-routes/injectRouteHelpers.native.js.map +1 -1
  263. package/dist/cjs/types.native.js.map +1 -1
  264. package/dist/cjs/ui/Slot.native.js.map +1 -1
  265. package/dist/cjs/ui/TabContext.native.js.map +1 -1
  266. package/dist/cjs/ui/TabList.native.js +1 -1
  267. package/dist/cjs/ui/TabList.native.js.map +1 -1
  268. package/dist/cjs/ui/TabRouter.native.js.map +1 -1
  269. package/dist/cjs/ui/TabSlot.native.js +2 -2
  270. package/dist/cjs/ui/TabSlot.native.js.map +1 -1
  271. package/dist/cjs/ui/TabTrigger.native.js +5 -5
  272. package/dist/cjs/ui/TabTrigger.native.js.map +1 -1
  273. package/dist/cjs/ui/Tabs.native.js +16 -16
  274. package/dist/cjs/ui/Tabs.native.js.map +1 -1
  275. package/dist/cjs/ui/common.native.js +4 -4
  276. package/dist/cjs/ui/common.native.js.map +1 -1
  277. package/dist/cjs/ui/index.native.js +1 -1
  278. package/dist/cjs/ui/index.native.js.map +1 -1
  279. package/dist/cjs/ui/useComponent.native.js.map +1 -1
  280. package/dist/cjs/useFocusEffect.native.js +1 -1
  281. package/dist/cjs/useFocusEffect.native.js.map +1 -1
  282. package/dist/cjs/useLoader.native.js +16 -16
  283. package/dist/cjs/useLoader.native.js.map +1 -1
  284. package/dist/cjs/useMatches.native.js +1 -1
  285. package/dist/cjs/useMatches.native.js.map +1 -1
  286. package/dist/cjs/useMatches.test.native.js +1 -1
  287. package/dist/cjs/useMatches.test.native.js.map +1 -1
  288. package/dist/cjs/useServerHeadInsertion.native.js.map +1 -1
  289. package/dist/cjs/utils/assertIsReady.native.js.map +1 -1
  290. package/dist/cjs/utils/children.native.js.map +1 -1
  291. package/dist/cjs/utils/cleanUrl.native.js +3 -3
  292. package/dist/cjs/utils/cleanUrl.native.js.map +1 -1
  293. package/dist/cjs/utils/cleanUrl.test.native.js +1 -1
  294. package/dist/cjs/utils/cleanUrl.test.native.js.map +1 -1
  295. package/dist/cjs/utils/dynamicImport.native.js.map +1 -1
  296. package/dist/cjs/utils/ensureExists.native.js.map +1 -1
  297. package/dist/cjs/utils/evictOldest.native.js.map +1 -1
  298. package/dist/cjs/utils/existsAsync.native.js.map +1 -1
  299. package/dist/cjs/utils/findRootLayout.cjs +39 -0
  300. package/dist/cjs/utils/findRootLayout.native.js +44 -0
  301. package/dist/cjs/utils/findRootLayout.native.js.map +1 -0
  302. package/dist/cjs/utils/getPageExport.native.js.map +1 -1
  303. package/dist/cjs/utils/getPathnameFromFilePath.native.js.map +1 -1
  304. package/dist/cjs/utils/getPathnameFromFilePath.test.native.js +1 -1
  305. package/dist/cjs/utils/getPathnameFromFilePath.test.native.js.map +1 -1
  306. package/dist/cjs/utils/getRouterRootFromOneOptions.native.js.map +1 -1
  307. package/dist/cjs/utils/globDir.native.js.map +1 -1
  308. package/dist/cjs/utils/hashString.native.js.map +1 -1
  309. package/dist/cjs/utils/htmlEscape.native.js.map +1 -1
  310. package/dist/cjs/utils/isResponse.native.js.map +1 -1
  311. package/dist/cjs/utils/isRolldown.native.js.map +1 -1
  312. package/dist/cjs/utils/isStatus.native.js.map +1 -1
  313. package/dist/cjs/utils/pLimit.native.js.map +1 -1
  314. package/dist/cjs/utils/platform.native.js.map +1 -1
  315. package/dist/cjs/utils/promiseWithResolvers.native.js.map +1 -1
  316. package/dist/cjs/utils/rand.native.js.map +1 -1
  317. package/dist/cjs/utils/redirect.native.js +2 -2
  318. package/dist/cjs/utils/redirect.native.js.map +1 -1
  319. package/dist/cjs/utils/removeParams.native.js.map +1 -1
  320. package/dist/cjs/utils/removeSearch.native.js.map +1 -1
  321. package/dist/cjs/utils/removeUndefined.native.js.map +1 -1
  322. package/dist/cjs/utils/style.native.js.map +1 -1
  323. package/dist/cjs/utils/toAbsolute.native.js.map +1 -1
  324. package/dist/cjs/utils/trackLoaderDependencies.native.js +1 -1
  325. package/dist/cjs/utils/trackLoaderDependencies.native.js.map +1 -1
  326. package/dist/cjs/utils/url.native.js.map +1 -1
  327. package/dist/cjs/utils/useConstant.native.js.map +1 -1
  328. package/dist/cjs/utils/watchFile.native.js.map +1 -1
  329. package/dist/cjs/utils/weakKey.native.js.map +1 -1
  330. package/dist/cjs/utils/weakMemo.native.js.map +1 -1
  331. package/dist/cjs/utils/withStaticProperties.native.js.map +1 -1
  332. package/dist/cjs/utils/workerImport.native.js.map +1 -1
  333. package/dist/cjs/validateParams.native.js.map +1 -1
  334. package/dist/cjs/validateSearch.native.js.map +1 -1
  335. package/dist/cjs/vercel/build/buildVercelOutputDirectory.native.js +5 -5
  336. package/dist/cjs/vercel/build/buildVercelOutputDirectory.native.js.map +1 -1
  337. package/dist/cjs/vercel/build/config/vc-build-output-config-base.native.js.map +1 -1
  338. package/dist/cjs/vercel/build/config/vc-config-base.native.js.map +1 -1
  339. package/dist/cjs/vercel/build/config/vc-package-base.native.js.map +1 -1
  340. package/dist/cjs/vercel/build/generate/createApiServerlessFunction.native.js +3 -3
  341. package/dist/cjs/vercel/build/generate/createApiServerlessFunction.native.js.map +1 -1
  342. package/dist/cjs/vercel/build/generate/createSsrServerlessFunction.native.js +3 -3
  343. package/dist/cjs/vercel/build/generate/createSsrServerlessFunction.native.js.map +1 -1
  344. package/dist/cjs/vercel/build/getPathFromRoute.native.js +1 -1
  345. package/dist/cjs/vercel/build/getPathFromRoute.native.js.map +1 -1
  346. package/dist/cjs/views/EmptyRoute.native.js +1 -1
  347. package/dist/cjs/views/EmptyRoute.native.js.map +1 -1
  348. package/dist/cjs/views/ErrorBoundary.native.js.map +1 -1
  349. package/dist/cjs/views/LoadProgressBar.native.js +1 -1
  350. package/dist/cjs/views/LoadProgressBar.native.js.map +1 -1
  351. package/dist/cjs/views/Navigator.native.js +8 -8
  352. package/dist/cjs/views/Navigator.native.js.map +1 -1
  353. package/dist/cjs/views/OneStackRouter.native.js.map +1 -1
  354. package/dist/cjs/views/Protected.native.js.map +1 -1
  355. package/dist/cjs/views/RootErrorBoundary.native.js.map +1 -1
  356. package/dist/cjs/views/Screen.native.js +1 -1
  357. package/dist/cjs/views/Screen.native.js.map +1 -1
  358. package/dist/cjs/views/ScrollBehavior.native.js +2 -2
  359. package/dist/cjs/views/ScrollBehavior.native.js.map +1 -1
  360. package/dist/cjs/views/SourceInspector.native.js.map +1 -1
  361. package/dist/cjs/views/Try.native.js.map +1 -1
  362. package/dist/cjs/vite/DevHead.native.js +1 -1
  363. package/dist/cjs/vite/DevHead.native.js.map +1 -1
  364. package/dist/cjs/vite/constants.native.js.map +1 -1
  365. package/dist/cjs/vite/customNodeExternals.native.js.map +1 -1
  366. package/dist/cjs/vite/ensureTsConfig.native.js +2 -2
  367. package/dist/cjs/vite/ensureTsConfig.native.js.map +1 -1
  368. package/dist/cjs/vite/findDepsToOptimize.native.js.map +1 -1
  369. package/dist/cjs/vite/getManifest.native.js +2 -2
  370. package/dist/cjs/vite/getManifest.native.js.map +1 -1
  371. package/dist/cjs/vite/loadConfig.native.js +1 -1
  372. package/dist/cjs/vite/loadConfig.native.js.map +1 -1
  373. package/dist/cjs/vite/makePluginWebOnly.native.js.map +1 -1
  374. package/dist/cjs/vite/one.cjs +41 -1
  375. package/dist/cjs/vite/one.native.js +77 -19
  376. package/dist/cjs/vite/one.native.js.map +1 -1
  377. package/dist/cjs/vite/plugins/SSRCSSPlugin.native.js +1 -1
  378. package/dist/cjs/vite/plugins/SSRCSSPlugin.native.js.map +1 -1
  379. package/dist/cjs/vite/plugins/clientTreeShakePlugin.native.js +1 -1
  380. package/dist/cjs/vite/plugins/clientTreeShakePlugin.native.js.map +1 -1
  381. package/dist/cjs/vite/plugins/clientTreeShakePlugin.test.native.js +1 -1
  382. package/dist/cjs/vite/plugins/clientTreeShakePlugin.test.native.js.map +1 -1
  383. package/dist/cjs/vite/plugins/criticalCSSPlugin.native.js.map +1 -1
  384. package/dist/cjs/vite/plugins/criticalCSSPlugin.test.native.js.map +1 -1
  385. package/dist/cjs/vite/plugins/devtoolsPlugin.native.js.map +1 -1
  386. package/dist/cjs/vite/plugins/environmentGuardPlugin.native.js.map +1 -1
  387. package/dist/cjs/vite/plugins/environmentGuardPlugin.test.native.js +1 -1
  388. package/dist/cjs/vite/plugins/environmentGuardPlugin.test.native.js.map +1 -1
  389. package/dist/cjs/vite/plugins/fileSystemRouterPlugin.native.js +12 -12
  390. package/dist/cjs/vite/plugins/fileSystemRouterPlugin.native.js.map +1 -1
  391. package/dist/cjs/vite/plugins/fixDependenciesPlugin.native.js.map +1 -1
  392. package/dist/cjs/vite/plugins/generateFileSystemRouteTypesPlugin.native.js +2 -2
  393. package/dist/cjs/vite/plugins/generateFileSystemRouteTypesPlugin.native.js.map +1 -1
  394. package/dist/cjs/vite/plugins/imageDataPlugin.native.js +1 -1
  395. package/dist/cjs/vite/plugins/imageDataPlugin.native.js.map +1 -1
  396. package/dist/cjs/vite/plugins/imageDataPlugin.test.native.js.map +1 -1
  397. package/dist/cjs/vite/plugins/removeReactNativeWebAnimatedPlugin.native.js.map +1 -1
  398. package/dist/cjs/vite/plugins/sourceInspectorPlugin.cjs +28 -11
  399. package/dist/cjs/vite/plugins/sourceInspectorPlugin.native.js +51 -13
  400. package/dist/cjs/vite/plugins/sourceInspectorPlugin.native.js.map +1 -1
  401. package/dist/cjs/vite/plugins/useDomPlugin.native.js.map +1 -1
  402. package/dist/cjs/vite/plugins/virtualEntryConstants.native.js.map +1 -1
  403. package/dist/cjs/vite/plugins/virtualEntryPlugin.cjs +2 -3
  404. package/dist/cjs/vite/plugins/virtualEntryPlugin.native.js +4 -5
  405. package/dist/cjs/vite/plugins/virtualEntryPlugin.native.js.map +1 -1
  406. package/dist/cjs/vite/plugins/virtualEntryPlugin.test.native.js +1 -1
  407. package/dist/cjs/vite/plugins/virtualEntryPlugin.test.native.js.map +1 -1
  408. package/dist/cjs/vite/plugins/warmRoutesPlugin.native.js.map +1 -1
  409. package/dist/cjs/vite/replaceLoader.native.js.map +1 -1
  410. package/dist/cjs/vite/resolveResponse.native.js +2 -2
  411. package/dist/cjs/vite/resolveResponse.native.js.map +1 -1
  412. package/dist/cjs/vite/types.native.js.map +1 -1
  413. package/dist/cjs/vite-auto-warm.native.js +1 -1
  414. package/dist/cjs/vite-auto-warm.native.js.map +1 -1
  415. package/dist/cjs/vite.native.js +9 -9
  416. package/dist/cjs/vite.native.js.map +1 -1
  417. package/dist/cjs/zero/getQueryKey.native.js +1 -1
  418. package/dist/cjs/zero/getQueryKey.native.js.map +1 -1
  419. package/dist/cjs/zero/isZeroQuery.native.js.map +1 -1
  420. package/dist/cjs/zero/resolveQuery.native.js.map +1 -1
  421. package/dist/cjs/zero/subscribeToQuery.native.js.map +1 -1
  422. package/dist/cjs/zero/types.native.js.map +1 -1
  423. package/dist/cjs/zero/useQuery.native.js +4 -4
  424. package/dist/cjs/zero/useQuery.native.js.map +1 -1
  425. package/dist/cjs/zero/useQueryZero.native.js.map +1 -1
  426. package/dist/cjs/zero.native.js +3 -3
  427. package/dist/cjs/zero.native.js.map +1 -1
  428. package/dist/esm/babel-plugins/one-router-metro.mjs +6 -3
  429. package/dist/esm/babel-plugins/one-router-metro.mjs.map +1 -1
  430. package/dist/esm/babel-plugins/one-router-metro.native.js +3 -3
  431. package/dist/esm/babel-plugins/one-router-metro.native.js.map +1 -1
  432. package/dist/esm/babel-plugins/one-router-metro.test.mjs +72 -0
  433. package/dist/esm/babel-plugins/one-router-metro.test.mjs.map +1 -0
  434. package/dist/esm/babel-plugins/one-router-metro.test.native.js +76 -0
  435. package/dist/esm/babel-plugins/one-router-metro.test.native.js.map +1 -0
  436. package/dist/esm/babel-plugins/remove-server-code.mjs +45 -45
  437. package/dist/esm/babel-plugins/remove-server-code.mjs.map +1 -1
  438. package/dist/esm/babel-plugins/remove-server-code.native.js +45 -83
  439. package/dist/esm/babel-plugins/remove-server-code.native.js.map +1 -1
  440. package/dist/esm/cli/build.mjs +4 -6
  441. package/dist/esm/cli/build.mjs.map +1 -1
  442. package/dist/esm/cli/build.native.js +4 -6
  443. package/dist/esm/cli/build.native.js.map +1 -1
  444. package/dist/esm/cli/dev.mjs +2 -3
  445. package/dist/esm/cli/dev.mjs.map +1 -1
  446. package/dist/esm/cli/dev.native.js +2 -3
  447. package/dist/esm/cli/dev.native.js.map +1 -1
  448. package/dist/esm/cli/securityScan.mjs +2 -1
  449. package/dist/esm/cli/securityScan.mjs.map +1 -1
  450. package/dist/esm/cli/securityScan.native.js +2 -1
  451. package/dist/esm/cli/securityScan.native.js.map +1 -1
  452. package/dist/esm/createApp.mjs +2 -15
  453. package/dist/esm/createApp.mjs.map +1 -1
  454. package/dist/esm/fork/getStateFromPath-mods.mjs +8 -3
  455. package/dist/esm/fork/getStateFromPath-mods.mjs.map +1 -1
  456. package/dist/esm/fork/getStateFromPath-mods.native.js +8 -3
  457. package/dist/esm/fork/getStateFromPath-mods.native.js.map +1 -1
  458. package/dist/esm/getDevServer.native.js +4 -2
  459. package/dist/esm/getDevServer.native.js.map +1 -1
  460. package/dist/esm/headless.mjs +20 -0
  461. package/dist/esm/headless.mjs.map +1 -0
  462. package/dist/esm/headless.native.js +26 -0
  463. package/dist/esm/headless.native.js.map +1 -0
  464. package/dist/esm/metro-config/getViteMetroPluginOptions.mjs +18 -7
  465. package/dist/esm/metro-config/getViteMetroPluginOptions.mjs.map +1 -1
  466. package/dist/esm/metro-config/getViteMetroPluginOptions.native.js +12 -3
  467. package/dist/esm/metro-config/getViteMetroPluginOptions.native.js.map +1 -1
  468. package/dist/esm/utils/findRootLayout.mjs +16 -0
  469. package/dist/esm/utils/findRootLayout.mjs.map +1 -0
  470. package/dist/esm/utils/findRootLayout.native.js +18 -0
  471. package/dist/esm/utils/findRootLayout.native.js.map +1 -0
  472. package/dist/esm/vite/one.mjs +41 -1
  473. package/dist/esm/vite/one.mjs.map +1 -1
  474. package/dist/esm/vite/one.native.js +59 -1
  475. package/dist/esm/vite/one.native.js.map +1 -1
  476. package/dist/esm/vite/plugins/sourceInspectorPlugin.mjs +27 -10
  477. package/dist/esm/vite/plugins/sourceInspectorPlugin.mjs.map +1 -1
  478. package/dist/esm/vite/plugins/sourceInspectorPlugin.native.js +50 -12
  479. package/dist/esm/vite/plugins/sourceInspectorPlugin.native.js.map +1 -1
  480. package/dist/esm/vite/plugins/virtualEntryPlugin.mjs +2 -3
  481. package/dist/esm/vite/plugins/virtualEntryPlugin.mjs.map +1 -1
  482. package/dist/esm/vite/plugins/virtualEntryPlugin.native.js +2 -3
  483. package/dist/esm/vite/plugins/virtualEntryPlugin.native.js.map +1 -1
  484. package/package.json +15 -11
  485. package/src/babel-plugins/one-router-metro.test.ts +115 -0
  486. package/src/babel-plugins/one-router-metro.ts +17 -3
  487. package/src/babel-plugins/remove-server-code.ts +116 -189
  488. package/src/cli/build.ts +4 -4
  489. package/src/cli/dev.ts +4 -3
  490. package/src/cli/securityScan.ts +1 -1
  491. package/src/createApp.tsx +2 -38
  492. package/src/fork/getStateFromPath-mods.ts +16 -2
  493. package/src/getDevServer.native.ts +7 -1
  494. package/src/headless.tsx +46 -0
  495. package/src/metro-config/getViteMetroPluginOptions.ts +16 -0
  496. package/src/utils/findRootLayout.ts +25 -0
  497. package/src/vite/one.ts +52 -0
  498. package/src/vite/plugins/sourceInspectorPlugin.ts +33 -19
  499. package/src/vite/plugins/virtualEntryPlugin.ts +2 -3
  500. package/src/vite/types.ts +31 -0
  501. package/types/babel-plugins/one-router-metro.d.ts.map +1 -1
  502. package/types/babel-plugins/one-router-metro.test.d.ts +2 -0
  503. package/types/babel-plugins/one-router-metro.test.d.ts.map +1 -0
  504. package/types/babel-plugins/remove-server-code.d.ts +8 -11
  505. package/types/babel-plugins/remove-server-code.d.ts.map +1 -1
  506. package/types/cli/dev.d.ts.map +1 -1
  507. package/types/createApp.d.ts.map +1 -1
  508. package/types/fork/getStateFromPath-mods.d.ts.map +1 -1
  509. package/types/getDevServer.native.d.ts +4 -1
  510. package/types/getDevServer.native.d.ts.map +1 -1
  511. package/types/headless.d.ts +13 -0
  512. package/types/headless.d.ts.map +1 -0
  513. package/types/metro-config/getViteMetroPluginOptions.d.ts.map +1 -1
  514. package/types/utils/findRootLayout.d.ts +2 -0
  515. package/types/utils/findRootLayout.d.ts.map +1 -0
  516. package/types/vite/one.d.ts.map +1 -1
  517. package/types/vite/plugins/sourceInspectorPlugin.d.ts.map +1 -1
  518. package/types/vite/plugins/virtualEntryPlugin.d.ts.map +1 -1
  519. package/types/vite/types.d.ts +30 -0
  520. package/types/vite/types.d.ts.map +1 -1
@@ -1,34 +1,34 @@
1
1
  /**
2
2
  * Babel plugin to remove server-only code (loader, generateStaticParams) from native bundles.
3
3
  *
4
- * This plugin transforms route files to remove server-only exports so they don't
5
- * get included in the native bundle. It's the Metro equivalent of clientTreeShakePlugin.
4
+ * This is the Metro equivalent of clientTreeShakePlugin. It:
5
+ * 1. Captures referenced identifiers BEFORE removing exports (critical for DCE)
6
+ * 2. Removes server-only exports (loader, generateStaticParams)
7
+ * 3. Re-parses the modified code and runs standalone DCE with the pre-removal references
8
+ * 4. Adds empty stubs back to prevent "missing export" errors
6
9
  *
7
- * What it does:
8
- * 1. Captures referenced identifiers BEFORE removing exports
9
- * 2. Removes `export function loader() { ... }` and `export const loader = ...`
10
- * 3. Removes `export function generateStaticParams() { ... }` and `export const generateStaticParams = ...`
11
- * 4. Runs dead code elimination to remove imports that were only used by removed functions
12
- * 5. Adds empty stubs back to prevent "missing export" errors
13
- *
14
- * Options:
15
- * - routerRoot: The router root directory (e.g., 'app'). Only files in this directory are transformed.
10
+ * The re-parse step is necessary because babel-dead-code-elimination uses NodePath
11
+ * identity (Set.has) which breaks when called within a babel plugin's traversal context
12
+ * due to different NodePath instances across traversal boundaries.
16
13
  */
17
14
 
18
15
  import type { NodePath, PluginObj } from '@babel/core'
16
+ import BabelGenerate from '@babel/generator'
17
+ import { parse } from '@babel/parser'
18
+ import BabelTraverse from '@babel/traverse'
19
19
  import * as t from '@babel/types'
20
20
  import {
21
21
  deadCodeElimination,
22
22
  findReferencedIdentifiers,
23
23
  } from 'babel-dead-code-elimination'
24
24
 
25
- const SERVER_EXPORTS = ['loader', 'generateStaticParams'] as const
25
+ const generate = (BabelGenerate['default'] ||
26
+ BabelGenerate) as any as typeof BabelGenerate
27
+ const traverse = (BabelTraverse['default'] || BabelTraverse) as typeof BabelTraverse
26
28
 
29
+ const SERVER_EXPORTS = ['loader', 'generateStaticParams'] as const
27
30
  type ServerExport = (typeof SERVER_EXPORTS)[number]
28
-
29
- type PluginOptions = {
30
- routerRoot?: string
31
- }
31
+ type PluginOptions = { routerRoot?: string }
32
32
 
33
33
  function removeServerCodePlugin(_: unknown, options: PluginOptions): PluginObj {
34
34
  const { routerRoot = 'app' } = options
@@ -37,198 +37,125 @@ function removeServerCodePlugin(_: unknown, options: PluginOptions): PluginObj {
37
37
  name: 'one-remove-server-code',
38
38
  visitor: {
39
39
  Program: {
40
- enter(
41
- path: NodePath<t.Program>,
42
- state: { filename?: string; referenced?: Set<string> }
43
- ) {
40
+ exit(path: NodePath<t.Program>, state: { filename?: string }) {
44
41
  const filename = state.filename
42
+ if (!filename) return
45
43
 
46
- // Only process route files in the router root
47
- if (!filename) {
48
- return
49
- }
50
-
51
- // Check if file is in the router root directory
52
44
  const routerRootPattern = new RegExp(`[/\\\\]${routerRoot}[/\\\\]`)
53
- if (!routerRootPattern.test(filename)) {
54
- return
55
- }
56
-
57
- // Skip node_modules
58
- if (filename.includes('node_modules')) {
59
- return
60
- }
45
+ if (!routerRootPattern.test(filename)) return
46
+ if (filename.includes('node_modules')) return
61
47
 
62
- // Quick check if file even has these exports
63
48
  const code = path.toString()
64
- if (!/generateStaticParams|loader/.test(code)) {
65
- return
66
- }
67
-
68
- // Capture referenced identifiers BEFORE removing exports
69
- // This is critical for dead code elimination to work
49
+ if (!/generateStaticParams|loader/.test(code)) return
50
+
51
+ // mirror the clientTreeShakePlugin approach exactly:
52
+ // 1. parse fresh AST from the current code
53
+ // 2. capture referenced identifiers BEFORE removing exports
54
+ // 3. remove server exports
55
+ // 4. run DCE with pre-removal references
56
+ // 5. replace the program body
70
57
  try {
71
- state.referenced = findReferencedIdentifiers(path.node as any) as any
72
- } catch (error) {
73
- console.warn(
74
- `[one/metro] Skipping tree shaking for ${filename} due to identifier analysis error:`,
75
- error instanceof Error ? error.message : String(error)
76
- )
77
- }
78
- },
79
-
80
- exit(
81
- path: NodePath<t.Program>,
82
- state: { filename?: string; referenced?: Set<string> }
83
- ) {
84
- const filename = state.filename
85
-
86
- // Only process route files in the router root
87
- if (!filename) {
88
- return
89
- }
90
-
91
- // Check if file is in the router root directory
92
- const routerRootPattern = new RegExp(`[/\\\\]${routerRoot}[/\\\\]`)
93
- if (!routerRootPattern.test(filename)) {
94
- return
95
- }
96
-
97
- // Skip node_modules
98
- if (filename.includes('node_modules')) {
99
- return
100
- }
101
-
102
- // If we don't have referenced set from enter, skip
103
- if (!state.referenced) {
104
- return
105
- }
106
-
107
- const removedExports: Set<ServerExport> = new Set()
108
-
109
- // Find and remove server exports
110
- // Note: babel-preset-expo may have already transformed async functions like:
111
- // export async function loader() { ... }
112
- // into:
113
- // function _loader() { _loader = _asyncToGenerator(...); return _loader.apply(...) }
114
- // export function loader() { return _loader.apply(...) }
115
- // So we need to handle both the original form and the transformed form
116
- path.traverse({
117
- ExportNamedDeclaration(exportPath: NodePath<t.ExportNamedDeclaration>) {
118
- const declaration = exportPath.node.declaration
119
-
120
- // Handle: export function loader() { ... }
121
- if (t.isFunctionDeclaration(declaration) && declaration.id) {
122
- const name = declaration.id.name as ServerExport
123
- if (SERVER_EXPORTS.includes(name)) {
124
- removedExports.add(name)
125
- exportPath.remove()
126
- }
127
- }
128
- // Handle: export const loader = async () => { ... }
129
- // Handle: export const loader = route.createLoader(...)
130
- else if (t.isVariableDeclaration(declaration)) {
131
- for (let i = declaration.declarations.length - 1; i >= 0; i--) {
132
- const declarator = declaration.declarations[i]
133
- if (t.isIdentifier(declarator.id)) {
134
- const name = declarator.id.name as ServerExport
135
- if (SERVER_EXPORTS.includes(name)) {
136
- removedExports.add(name)
137
-
138
- // Remove just this declarator
139
- if (declaration.declarations.length === 1) {
140
- exportPath.remove()
141
- } else {
142
- declaration.declarations.splice(i, 1)
143
- }
58
+ const freshAst = parse(code, {
59
+ sourceType: 'module',
60
+ plugins: ['typescript', 'jsx'],
61
+ }) as any
62
+
63
+ // capture references BEFORE removal (critical for DCE to work)
64
+ const referenced = findReferencedIdentifiers(freshAst)
65
+
66
+ const removed = { loader: false, generateStaticParams: false }
67
+
68
+ // remove server exports from the fresh AST
69
+ traverse(freshAst, {
70
+ ExportNamedDeclaration(expPath) {
71
+ const declaration = expPath.node.declaration
72
+ if (!declaration) return
73
+
74
+ if (declaration.type === 'FunctionDeclaration' && declaration.id) {
75
+ const name = declaration.id.name
76
+ if (name === 'loader' || name === 'generateStaticParams') {
77
+ expPath.remove()
78
+ removed[name] = true
79
+ }
80
+ } else if (declaration.type === 'VariableDeclaration') {
81
+ const decl = expPath.get(
82
+ 'declaration'
83
+ ) as NodePath<t.VariableDeclaration>
84
+ const declarators = decl.get('declarations')
85
+ // iterate in reverse so indices stay valid after removal
86
+ for (let i = declarators.length - 1; i >= 0; i--) {
87
+ const declarator = declarators[i]
88
+ const id = declarator.node.id
89
+ if (
90
+ id.type === 'Identifier' &&
91
+ (id.name === 'loader' || id.name === 'generateStaticParams')
92
+ ) {
93
+ declarator.remove()
94
+ removed[id.name as ServerExport] = true
144
95
  }
145
96
  }
146
- }
147
- }
148
- },
149
-
150
- // Also remove helper functions created by babel's async-to-generator transform
151
- // These are named _loader, _generateStaticParams, etc.
152
- FunctionDeclaration(funcPath: NodePath<t.FunctionDeclaration>) {
153
- if (!funcPath.node.id) return
154
- const name = funcPath.node.id.name
155
- // Check for helper functions like _loader, _generateStaticParams
156
- for (const serverExport of SERVER_EXPORTS) {
157
- if (name === `_${serverExport}`) {
158
- // Verify this is indeed a babel-generated async helper
159
- // by checking if it contains _asyncToGenerator
160
- let isAsyncHelper = false
161
- funcPath.traverse({
162
- Identifier(idPath) {
163
- if (idPath.node.name === '_asyncToGenerator') {
164
- isAsyncHelper = true
165
- idPath.stop()
166
- }
167
- },
168
- })
169
- if (isAsyncHelper) {
170
- removedExports.add(serverExport)
171
- funcPath.remove()
97
+ // if all declarators were removed, clean up the empty export
98
+ if (decl.node && decl.node.declarations.length === 0) {
99
+ expPath.remove()
172
100
  }
173
101
  }
174
- }
175
- },
176
- })
102
+ },
103
+ })
177
104
 
178
- // Only proceed if we removed something
179
- if (removedExports.size === 0) {
180
- return
181
- }
182
-
183
- // Run dead code elimination to remove imports that were only used by removed functions
184
- try {
185
- deadCodeElimination(path.node as any, state.referenced as any)
186
- } catch (error) {
187
- console.warn(
188
- `[one/metro] Dead code elimination failed for ${filename}:`,
189
- error instanceof Error ? error.message : String(error)
105
+ const removedFunctions = Object.keys(removed).filter(
106
+ (key) => removed[key as keyof typeof removed]
190
107
  )
191
- }
192
108
 
193
- // Add back empty stubs for removed exports to prevent "missing export" errors
194
- const stubs: t.Statement[] = []
195
-
196
- if (removedExports.has('loader')) {
197
- // export function loader() { return "__vxrn__loader__"; }
198
- stubs.push(
199
- t.exportNamedDeclaration(
200
- t.functionDeclaration(
201
- t.identifier('loader'),
202
- [],
203
- t.blockStatement([
204
- t.returnStatement(t.stringLiteral('__vxrn__loader__')),
205
- ])
109
+ if (removedFunctions.length === 0) return
110
+
111
+ // run DCE with pre-removal references (same as clientTreeShakePlugin)
112
+ deadCodeElimination(freshAst, referenced)
113
+
114
+ // add empty stubs to prevent "missing export" errors
115
+ if (removed.loader) {
116
+ freshAst.program.body.push(
117
+ t.exportNamedDeclaration(
118
+ t.functionDeclaration(
119
+ t.identifier('loader'),
120
+ [],
121
+ t.blockStatement([
122
+ t.returnStatement(t.stringLiteral('__vxrn__loader__')),
123
+ ])
124
+ )
206
125
  )
207
126
  )
208
- )
209
- }
210
-
211
- if (removedExports.has('generateStaticParams')) {
212
- // export function generateStaticParams() { }
213
- stubs.push(
214
- t.exportNamedDeclaration(
215
- t.functionDeclaration(
216
- t.identifier('generateStaticParams'),
217
- [],
218
- t.blockStatement([])
127
+ }
128
+ if (removed.generateStaticParams) {
129
+ freshAst.program.body.push(
130
+ t.exportNamedDeclaration(
131
+ t.functionDeclaration(
132
+ t.identifier('generateStaticParams'),
133
+ [],
134
+ t.blockStatement([])
135
+ )
219
136
  )
220
137
  )
221
- )
222
- }
138
+ }
223
139
 
224
- // Add stubs at the end of the file
225
- for (const stub of stubs) {
226
- path.pushContainer('body', stub)
227
- }
140
+ // generate cleaned code and re-parse to get proper NodePaths for babel
141
+ const out = generate(freshAst, { retainLines: true })
142
+ const finalAst = parse(out.code, {
143
+ sourceType: 'module',
144
+ plugins: ['typescript', 'jsx'],
145
+ }) as any
146
+
147
+ path.node.body = finalAst.program.body
148
+ path.node.directives = finalAst.program.directives
228
149
 
229
- if (process.env.DEBUG) {
230
- console.info(
231
- ` 🧹 [one/metro] ${filename} removed ${removedExports.size} server-only exports`
150
+ if (process.env.DEBUG) {
151
+ console.info(
152
+ ` 🧹 [one/metro] ${filename} removed ${removedFunctions.length} server-only exports`
153
+ )
154
+ }
155
+ } catch (error) {
156
+ console.warn(
157
+ `[one/metro] Tree shaking failed for ${filename}:`,
158
+ error instanceof Error ? error.message : String(error)
232
159
  )
233
160
  }
234
161
  },
package/src/cli/build.ts CHANGED
@@ -148,7 +148,7 @@ export async function build(args: {
148
148
 
149
149
  if (url) {
150
150
  process.env.ONE_SERVER_URL = url
151
- console.info(`\n ☁️ ONE_SERVER_URL: ${url}\n`)
151
+ console.info(`\n ☁️ ONE_SERVER_URL: ${url}\n`)
152
152
  }
153
153
  }
154
154
 
@@ -182,7 +182,7 @@ export async function build(args: {
182
182
  )
183
183
 
184
184
  const bundleTime = performance.now() - buildStartTime
185
- console.info(`\n ⏱️ vite bundle: ${(bundleTime / 1000).toFixed(2)}s\n`)
185
+ console.info(`\n ⏱️ vite bundle: ${(bundleTime / 1000).toFixed(2)}s\n`)
186
186
 
187
187
  if (!vxrnOutput || args.platform !== 'web') {
188
188
  return
@@ -912,7 +912,7 @@ export async function build(args: {
912
912
 
913
913
  const staticTime = performance.now() - staticStartTime
914
914
  console.info(
915
- `\n ⏱️ static routes: ${(staticTime / 1000).toFixed(2)}s (${builtRoutes.length} pages)\n`
915
+ `\n ⏱️ static routes: ${(staticTime / 1000).toFixed(2)}s (${builtRoutes.length} pages)\n`
916
916
  )
917
917
  printBuildTimings()
918
918
 
@@ -1302,7 +1302,7 @@ export default {
1302
1302
  })
1303
1303
  }
1304
1304
 
1305
- console.info(`\n\n 💛 build complete\n\n`)
1305
+ console.info(`\n 💛 build complete\n`)
1306
1306
  }
1307
1307
 
1308
1308
  const TRAILING_INDEX_REGEX = /\/index(\.(web))?/
package/src/cli/dev.ts CHANGED
@@ -24,7 +24,8 @@ export async function dev(args: {
24
24
  const root = process.cwd()
25
25
  let daemonServerId: string | undefined
26
26
  let useDaemon = false
27
- let effectivePort = args.port ? +args.port : DEFAULT_PORT
27
+ // only set port if user explicitly passed --port; otherwise let vite.config.ts decide
28
+ let effectivePort: number | undefined = args.port ? +args.port : undefined
28
29
 
29
30
  // check if daemon is running
30
31
  const {
@@ -79,7 +80,7 @@ export async function dev(args: {
79
80
  if (useDaemon && bundleId) {
80
81
  try {
81
82
  daemonServerId = await registerWithDaemon({
82
- port: effectivePort,
83
+ port: effectivePort!,
83
84
  bundleId,
84
85
  root,
85
86
  })
@@ -89,7 +90,7 @@ export async function dev(args: {
89
90
  )
90
91
  )
91
92
  // persist for daemon restart recovery
92
- writeServerFile({ port: effectivePort, bundleId, root, pid: process.pid })
93
+ writeServerFile({ port: effectivePort!, bundleId, root, pid: process.pid })
93
94
  } catch (err) {
94
95
  console.log(colors.yellow(`[daemon] Failed to register: ${err}`))
95
96
  }
@@ -157,7 +157,7 @@ export async function runSecurityScan(
157
157
  const { clean, findings } = await scanBundleForSecrets(clientDir, safePatterns)
158
158
 
159
159
  if (clean) {
160
- console.info(` 🔒 security scan passed — no secrets found\n`)
160
+ console.info(`\n 🔒 security scan passed — no secrets found\n`)
161
161
  return true
162
162
  }
163
163
 
package/src/createApp.tsx CHANGED
@@ -8,6 +8,7 @@ import { render } from './render'
8
8
  import { initClientMatches } from './router/router'
9
9
  import { registerPreloadedRoute } from './router/useViteRoutes'
10
10
  import { setupSkewProtection } from './skewProtection'
11
+ import { findRootLayout } from './utils/findRootLayout'
11
12
  import type { RenderAppProps } from './types'
12
13
  import { getServerHeadInsertions } from './useServerHeadInsertion'
13
14
  import { ensureExists } from './utils/ensureExists'
@@ -228,43 +229,6 @@ export function createApp(options: CreateAppProps) {
228
229
  }
229
230
  }
230
231
 
231
- // find root layout in routes regardless of render mode suffix (+ssg, +ssr, +spa)
232
- // the glob keys include the suffix (e.g., /app/_layout+ssg.tsx) but we need to
233
- // match any root layout variant to ensure it's preloaded before rendering
234
- function findAndPreloadRootLayout(
235
- routes: Record<string, () => Promise<unknown>>,
236
- routerRoot: string
237
- ): Promise<unknown> | undefined {
238
- // try exact match first (no suffix)
239
- const exactKey = `/${routerRoot}/_layout.tsx`
240
- if (routes[exactKey]) {
241
- return routes[exactKey]()
242
- }
243
-
244
- // try with render mode suffixes
245
- for (const suffix of ['+ssg', '+ssr', '+spa']) {
246
- const key = `/${routerRoot}/_layout${suffix}.tsx`
247
- if (routes[key]) {
248
- return routes[key]()
249
- }
250
- }
251
-
252
- // try .ts extension variants
253
- const exactKeyTs = `/${routerRoot}/_layout.ts`
254
- if (routes[exactKeyTs]) {
255
- return routes[exactKeyTs]()
256
- }
257
-
258
- for (const suffix of ['+ssg', '+ssr', '+spa']) {
259
- const key = `/${routerRoot}/_layout${suffix}.ts`
260
- if (routes[key]) {
261
- return routes[key]()
262
- }
263
- }
264
-
265
- return undefined
266
- }
267
-
268
232
  // skew protection: auto-reload on chunk load failures
269
233
  if (typeof window !== 'undefined' && process.env.ONE_SKEW_PROTECTION !== 'false') {
270
234
  window.addEventListener('vite:preloadError', (e) => {
@@ -317,7 +281,7 @@ export function createApp(options: CreateAppProps) {
317
281
  registerPreloadedRoute(routeKey, mod)
318
282
  return mod
319
283
  })
320
- : [findAndPreloadRootLayout(options.routes, options.routerRoot)]
284
+ : [findRootLayout(options.routes, options.routerRoot)]
321
285
 
322
286
  // for 404 pages, use history.state.__tempLocation to route to notFoundPath
323
287
  // without changing the browser URL. the router checks __tempLocation and uses
@@ -41,8 +41,19 @@ export function getUrlWithReactNavigationConcessions(
41
41
  if (hashIndex >= 0) {
42
42
  hash = path.slice(hashIndex)
43
43
  }
44
- const end = hashIndex >= 0 ? hashIndex : queryIndex >= 0 ? queryIndex : path.length
44
+ // pathname ends before query or hash, whichever comes first
45
+ let end = path.length
46
+ if (queryIndex >= 0) end = Math.min(end, queryIndex)
47
+ if (hashIndex >= 0) end = Math.min(end, hashIndex)
45
48
  pathname = path.slice(0, end)
49
+
50
+ // strip origin from absolute URLs (e.g. https://acme.com/path -> /path)
51
+ if (pathname.startsWith('http://') || pathname.startsWith('https://')) {
52
+ const originEnd = pathname.indexOf('/', pathname.indexOf('//') + 2)
53
+ if (originEnd >= 0) {
54
+ pathname = pathname.slice(originEnd)
55
+ }
56
+ }
46
57
  } catch {
47
58
  // Do nothing with invalid URLs.
48
59
  }
@@ -386,8 +397,11 @@ export function parseQueryParamsExtended(
386
397
  hash?: string
387
398
  ) {
388
399
  const queryIndex = path.indexOf('?')
400
+ const hashIndex = path.indexOf('#')
401
+ // only parse between ? and # to avoid hash leaking into search params
402
+ const queryEnd = hashIndex >= 0 && hashIndex > queryIndex ? hashIndex : undefined
389
403
  const searchParams = new URLSearchParams(
390
- queryIndex >= 0 ? path.slice(queryIndex + 1) : ''
404
+ queryIndex >= 0 ? path.slice(queryIndex + 1, queryEnd) : ''
391
405
  )
392
406
  const params: Record<string, string | string[]> = Object.create(null)
393
407
 
@@ -1,3 +1,9 @@
1
1
  // Isolated to suppress deprecation warning for deep import
2
2
  // React Native 0.81+ discourages deep imports but doesn't provide official alternative yet
3
- export { default as getDevServer } from 'react-native/Libraries/Core/Devtools/getDevServer'
3
+ import getDevServerDefault from 'react-native/Libraries/Core/Devtools/getDevServer'
4
+
5
+ // handle CJS/ESM interop — Metro may wrap the default export in a module object
6
+ export const getDevServer: () => { url: string; bundleLoadedFromServer: boolean } =
7
+ typeof getDevServerDefault === 'function'
8
+ ? getDevServerDefault
9
+ : ((getDevServerDefault as any).default ?? getDevServerDefault)
@@ -0,0 +1,46 @@
1
+ import './setup'
2
+
3
+ import { Root } from './Root'
4
+ import { resolveClientLoader } from './clientLoaderResolver'
5
+ import { render } from './render'
6
+ import { findRootLayout } from './utils/findRootLayout'
7
+ import type { One } from './vite/types'
8
+
9
+ export { Root }
10
+
11
+ export type CreateHeadlessAppProps = {
12
+ routes: Record<string, () => Promise<unknown>>
13
+ routerRoot: string
14
+ path?: string
15
+ flags?: One.Flags
16
+ getSetupPromise?: () => Promise<unknown>
17
+ }
18
+
19
+ export function createApp(options: CreateHeadlessAppProps) {
20
+ // always spa mode — render() checks this to use createRoot instead of hydrateRoot
21
+ globalThis['__vxrnIsSPA'] = true
22
+
23
+ const setupComplete = options.getSetupPromise
24
+ ? options.getSetupPromise()
25
+ : Promise.resolve()
26
+
27
+ return setupComplete
28
+ .then(() => findRootLayout(options.routes, options.routerRoot))
29
+ .then(() => resolveClientLoader({}))
30
+ .then(() => {
31
+ render(
32
+ <Root
33
+ isClient
34
+ flags={options.flags}
35
+ routes={options.routes}
36
+ routerRoot={options.routerRoot}
37
+ path={
38
+ options.path || (typeof window !== 'undefined' ? window.location.href : '/')
39
+ }
40
+ />
41
+ )
42
+ })
43
+ .catch((err) => {
44
+ console.error(`[one/headless] Error during initialization:`, err)
45
+ })
46
+ }
@@ -135,6 +135,22 @@ export function getViteMetroPluginOptions({
135
135
  }
136
136
  }
137
137
 
138
+ // react-native-svg's package.json has "react-native": "src/index.ts"
139
+ // which points to TS source that only type-exports Svg/Circle/Path etc.
140
+ // force resolution to the compiled JS which has proper named value exports.
141
+ if (moduleName === 'react-native-svg') {
142
+ const defaultResolveRequest =
143
+ defaultConfig?.resolver?.resolveRequest || context.resolveRequest
144
+ const res = defaultResolveRequest(context, moduleName, platform)
145
+ if (res && 'filePath' in res && res.filePath.includes('/src/index.ts')) {
146
+ return {
147
+ ...res,
148
+ filePath: res.filePath.replace('/src/index.ts', '/lib/commonjs/index.js'),
149
+ }
150
+ }
151
+ return res
152
+ }
153
+
138
154
  const defaultResolveRequest =
139
155
  defaultConfig?.resolver?.resolveRequest || context.resolveRequest
140
156
  const res = defaultResolveRequest(context, moduleName, platform)
@@ -0,0 +1,25 @@
1
+ // find root layout in routes regardless of render mode suffix (+ssg, +ssr, +spa)
2
+ // the glob keys include the suffix (e.g., /app/_layout+ssg.tsx) but we need to
3
+ // match any root layout variant to ensure it's preloaded before rendering
4
+ export function findRootLayout(
5
+ routes: Record<string, () => Promise<unknown>>,
6
+ routerRoot: string
7
+ ): Promise<unknown> | undefined {
8
+ const exactKey = `/${routerRoot}/_layout.tsx`
9
+ if (routes[exactKey]) return routes[exactKey]()
10
+
11
+ for (const suffix of ['+ssg', '+ssr', '+spa']) {
12
+ const key = `/${routerRoot}/_layout${suffix}.tsx`
13
+ if (routes[key]) return routes[key]()
14
+ }
15
+
16
+ const exactKeyTs = `/${routerRoot}/_layout.ts`
17
+ if (routes[exactKeyTs]) return routes[exactKeyTs]()
18
+
19
+ for (const suffix of ['+ssg', '+ssr', '+spa']) {
20
+ const key = `/${routerRoot}/_layout${suffix}.ts`
21
+ if (routes[key]) return routes[key]()
22
+ }
23
+
24
+ return undefined
25
+ }