one 1.2.57 → 1.2.59

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 (612) hide show
  1. package/dist/cjs/cli/build.cjs +3 -1
  2. package/dist/cjs/cli/build.js +1 -1
  3. package/dist/cjs/cli/build.js.map +1 -1
  4. package/dist/cjs/cli/build.native.js +13 -12
  5. package/dist/cjs/cli/build.native.js.map +1 -1
  6. package/dist/cjs/cli/buildPage.cjs +1 -1
  7. package/dist/cjs/cli/buildPage.js +1 -1
  8. package/dist/cjs/cli/buildPage.native.js +2 -2
  9. package/dist/cjs/cli/buildPage.native.js.map +1 -1
  10. package/dist/cjs/cli/dev.cjs +4 -4
  11. package/dist/cjs/cli/dev.js +4 -4
  12. package/dist/cjs/cli/dev.js.map +1 -1
  13. package/dist/cjs/cli/dev.native.js +4 -4
  14. package/dist/cjs/cli/dev.native.js.map +1 -1
  15. package/dist/cjs/cli/generateRoutes.cjs +1 -1
  16. package/dist/cjs/cli/generateRoutes.js +1 -1
  17. package/dist/cjs/cli/generateRoutes.native.js +1 -1
  18. package/dist/cjs/cli/generateRoutes.native.js.map +1 -1
  19. package/dist/cjs/cli/generateSitemap.native.js +7 -7
  20. package/dist/cjs/cli/generateSitemap.native.js.map +1 -1
  21. package/dist/cjs/config.native.js +2 -2
  22. package/dist/cjs/config.native.js.map +1 -1
  23. package/dist/cjs/constants.native.js +1 -1
  24. package/dist/cjs/constants.native.js.map +1 -1
  25. package/dist/cjs/createApp.cjs +2 -1
  26. package/dist/cjs/createApp.js +2 -2
  27. package/dist/cjs/createApp.js.map +1 -1
  28. package/dist/cjs/createHandleRequest.test.js +3 -1
  29. package/dist/cjs/createHandleRequest.test.js.map +1 -1
  30. package/dist/cjs/createHandleRequest.test.native.js.map +1 -1
  31. package/dist/cjs/devtools/registry.cjs +30 -0
  32. package/dist/cjs/devtools/registry.js +25 -0
  33. package/dist/cjs/devtools/registry.js.map +6 -0
  34. package/dist/cjs/devtools/registry.native.js +33 -0
  35. package/dist/cjs/devtools/registry.native.js.map +1 -0
  36. package/dist/cjs/fork/NavigationContainer.native.js +5 -5
  37. package/dist/cjs/fork/NavigationContainer.native.js.map +1 -1
  38. package/dist/cjs/fork/createMemoryHistory.cjs +20 -9
  39. package/dist/cjs/fork/createMemoryHistory.js +22 -4
  40. package/dist/cjs/fork/createMemoryHistory.js.map +1 -1
  41. package/dist/cjs/fork/createMemoryHistory.native.js +22 -11
  42. package/dist/cjs/fork/createMemoryHistory.native.js.map +1 -1
  43. package/dist/cjs/fork/extractPathFromURL.native.js +8 -8
  44. package/dist/cjs/fork/extractPathFromURL.native.js.map +1 -1
  45. package/dist/cjs/fork/findFocusedRoute.native.js +2 -3
  46. package/dist/cjs/fork/findFocusedRoute.native.js.map +1 -1
  47. package/dist/cjs/fork/getPathFromState-mods.native.js +2 -3
  48. package/dist/cjs/fork/getPathFromState-mods.native.js.map +1 -1
  49. package/dist/cjs/fork/getStateFromPath-mods.native.js +3 -3
  50. package/dist/cjs/fork/getStateFromPath-mods.native.js.map +1 -1
  51. package/dist/cjs/fork/useLinking.cjs +11 -5
  52. package/dist/cjs/fork/useLinking.js +6 -6
  53. package/dist/cjs/fork/useLinking.js.map +1 -1
  54. package/dist/cjs/fork/useLinking.native.js.map +1 -1
  55. package/dist/cjs/head/url.native.js +2 -3
  56. package/dist/cjs/head/url.native.js.map +1 -1
  57. package/dist/cjs/hooks.js.map +1 -1
  58. package/dist/cjs/hooks.native.js.map +1 -1
  59. package/dist/cjs/index.cjs +17 -1
  60. package/dist/cjs/index.js +12 -2
  61. package/dist/cjs/index.js.map +1 -1
  62. package/dist/cjs/index.native.js +17 -1
  63. package/dist/cjs/index.native.js.map +1 -1
  64. package/dist/cjs/layouts/withLayoutContext.cjs +34 -15
  65. package/dist/cjs/layouts/withLayoutContext.js +29 -13
  66. package/dist/cjs/layouts/withLayoutContext.js.map +1 -1
  67. package/dist/cjs/layouts/withLayoutContext.native.js +42 -19
  68. package/dist/cjs/layouts/withLayoutContext.native.js.map +1 -1
  69. package/dist/cjs/link/Link.cjs +5 -2
  70. package/dist/cjs/link/Link.js +3 -2
  71. package/dist/cjs/link/Link.js.map +1 -1
  72. package/dist/cjs/link/Link.native.js +6 -1
  73. package/dist/cjs/link/Link.native.js.map +1 -1
  74. package/dist/cjs/link/href.native.js +2 -2
  75. package/dist/cjs/link/href.native.js.map +1 -1
  76. package/dist/cjs/link/useLinkTo.cjs +11 -3
  77. package/dist/cjs/link/useLinkTo.js +6 -3
  78. package/dist/cjs/link/useLinkTo.js.map +1 -1
  79. package/dist/cjs/link/useLinkTo.native.js +11 -3
  80. package/dist/cjs/link/useLinkTo.native.js.map +1 -1
  81. package/dist/cjs/router/Route.js.map +1 -1
  82. package/dist/cjs/router/Route.native.js.map +1 -1
  83. package/dist/cjs/router/findRouteNode.cjs +70 -0
  84. package/dist/cjs/router/findRouteNode.js +72 -0
  85. package/dist/cjs/router/findRouteNode.js.map +6 -0
  86. package/dist/cjs/router/findRouteNode.native.js +104 -0
  87. package/dist/cjs/router/findRouteNode.native.js.map +1 -0
  88. package/dist/cjs/router/getRoutes.native.js +3 -3
  89. package/dist/cjs/router/getRoutes.native.js.map +1 -1
  90. package/dist/cjs/router/router.cjs +160 -11
  91. package/dist/cjs/router/router.js +142 -7
  92. package/dist/cjs/router/router.js.map +2 -2
  93. package/dist/cjs/router/router.native.js +247 -67
  94. package/dist/cjs/router/router.native.js.map +1 -1
  95. package/dist/cjs/router/useNavigation.js.map +1 -1
  96. package/dist/cjs/router/useNavigation.native.js.map +1 -1
  97. package/dist/cjs/router/useScreens.cjs +1 -1
  98. package/dist/cjs/router/useScreens.js +1 -1
  99. package/dist/cjs/router/useScreens.js.map +1 -1
  100. package/dist/cjs/router/useScreens.native.js +6 -3
  101. package/dist/cjs/router/useScreens.native.js.map +1 -1
  102. package/dist/cjs/router/utils/getNavigateAction.native.js +2 -4
  103. package/dist/cjs/router/utils/getNavigateAction.native.js.map +1 -1
  104. package/dist/cjs/server/oneServe.js.map +1 -1
  105. package/dist/cjs/server/oneServe.native.js +4 -4
  106. package/dist/cjs/server/oneServe.native.js.map +1 -1
  107. package/dist/cjs/server/setupBuildOptions.native.js +1 -1
  108. package/dist/cjs/server/setupBuildOptions.native.js.map +1 -1
  109. package/dist/cjs/ui/common.native.js +6 -5
  110. package/dist/cjs/ui/common.native.js.map +1 -1
  111. package/dist/cjs/useBlocker.cjs +158 -0
  112. package/dist/cjs/useBlocker.js +145 -0
  113. package/dist/cjs/useBlocker.js.map +6 -0
  114. package/dist/cjs/useBlocker.native.js +89 -0
  115. package/dist/cjs/useBlocker.native.js.map +1 -0
  116. package/dist/cjs/useFocusEffect.cjs +2 -2
  117. package/dist/cjs/useFocusEffect.js +2 -2
  118. package/dist/cjs/useFocusEffect.js.map +1 -1
  119. package/dist/cjs/useFocusEffect.native.js +2 -2
  120. package/dist/cjs/useFocusEffect.native.js.map +1 -1
  121. package/dist/cjs/useLoader.cjs +69 -3
  122. package/dist/cjs/useLoader.js +57 -4
  123. package/dist/cjs/useLoader.js.map +2 -2
  124. package/dist/cjs/useLoader.native.js +90 -6
  125. package/dist/cjs/useLoader.native.js.map +1 -1
  126. package/dist/cjs/useScrollGroup.cjs +37 -0
  127. package/dist/cjs/useScrollGroup.js +30 -0
  128. package/dist/cjs/useScrollGroup.js.map +6 -0
  129. package/dist/cjs/useScrollGroup.native.js +29 -0
  130. package/dist/cjs/useScrollGroup.native.js.map +1 -0
  131. package/dist/cjs/validateParams.cjs +80 -0
  132. package/dist/cjs/validateParams.js +84 -0
  133. package/dist/cjs/validateParams.js.map +6 -0
  134. package/dist/cjs/validateParams.native.js +180 -0
  135. package/dist/cjs/validateParams.native.js.map +1 -0
  136. package/dist/cjs/validateSearch.cjs +104 -0
  137. package/dist/cjs/validateSearch.js +99 -0
  138. package/dist/cjs/validateSearch.js.map +6 -0
  139. package/dist/cjs/validateSearch.native.js +202 -0
  140. package/dist/cjs/validateSearch.native.js.map +1 -0
  141. package/dist/cjs/vercel/build/buildVercelOutputDirectory.native.js +2 -2
  142. package/dist/cjs/vercel/build/buildVercelOutputDirectory.native.js.map +1 -1
  143. package/dist/cjs/views/ErrorBoundary.cjs +293 -10
  144. package/dist/cjs/views/ErrorBoundary.js +328 -8
  145. package/dist/cjs/views/ErrorBoundary.js.map +2 -2
  146. package/dist/cjs/views/ErrorBoundary.native.js +159 -4
  147. package/dist/cjs/views/ErrorBoundary.native.js.map +1 -1
  148. package/dist/cjs/views/Navigator.cjs +10 -3
  149. package/dist/cjs/views/Navigator.js +11 -3
  150. package/dist/cjs/views/Navigator.js.map +1 -1
  151. package/dist/cjs/views/Navigator.native.js +15 -6
  152. package/dist/cjs/views/Navigator.native.js.map +1 -1
  153. package/dist/cjs/views/Protected.cjs +36 -0
  154. package/dist/cjs/views/Protected.js +27 -0
  155. package/dist/cjs/views/Protected.js.map +6 -0
  156. package/dist/cjs/views/Protected.native.js +44 -0
  157. package/dist/cjs/views/Protected.native.js.map +1 -0
  158. package/dist/cjs/views/RootErrorBoundary.cjs +193 -8
  159. package/dist/cjs/views/RootErrorBoundary.js +213 -8
  160. package/dist/cjs/views/RootErrorBoundary.js.map +1 -1
  161. package/dist/cjs/views/RootErrorBoundary.native.js +192 -8
  162. package/dist/cjs/views/RootErrorBoundary.native.js.map +1 -1
  163. package/dist/cjs/views/ScrollBehavior.cjs +49 -11
  164. package/dist/cjs/views/ScrollBehavior.js +47 -11
  165. package/dist/cjs/views/ScrollBehavior.js.map +1 -1
  166. package/dist/cjs/views/ScrollBehavior.native.js +68 -10
  167. package/dist/cjs/views/ScrollBehavior.native.js.map +1 -1
  168. package/dist/cjs/views/SourceInspector.cjs +28 -0
  169. package/dist/cjs/views/SourceInspector.js +23 -0
  170. package/dist/cjs/views/SourceInspector.js.map +6 -0
  171. package/dist/cjs/views/SourceInspector.native.js +32 -0
  172. package/dist/cjs/views/SourceInspector.native.js.map +1 -0
  173. package/dist/cjs/views/Try.cjs +40 -7
  174. package/dist/cjs/views/Try.js +38 -4
  175. package/dist/cjs/views/Try.js.map +1 -1
  176. package/dist/cjs/views/Try.native.js +42 -7
  177. package/dist/cjs/views/Try.native.js.map +1 -1
  178. package/dist/cjs/vite/DevHead.cjs +797 -43
  179. package/dist/cjs/vite/DevHead.js +802 -51
  180. package/dist/cjs/vite/DevHead.js.map +1 -1
  181. package/dist/cjs/vite/DevHead.native.js +783 -1
  182. package/dist/cjs/vite/DevHead.native.js.map +1 -1
  183. package/dist/cjs/vite/one.cjs +7 -1
  184. package/dist/cjs/vite/one.js +7 -2
  185. package/dist/cjs/vite/one.js.map +1 -1
  186. package/dist/cjs/vite/one.native.js +17 -7
  187. package/dist/cjs/vite/one.native.js.map +1 -1
  188. package/dist/cjs/vite/plugins/SSRCSSPlugin.cjs +44 -4
  189. package/dist/cjs/vite/plugins/SSRCSSPlugin.js +48 -4
  190. package/dist/cjs/vite/plugins/SSRCSSPlugin.js.map +1 -1
  191. package/dist/cjs/vite/plugins/SSRCSSPlugin.native.js +62 -5
  192. package/dist/cjs/vite/plugins/SSRCSSPlugin.native.js.map +1 -1
  193. package/dist/cjs/vite/plugins/clientTreeShakePlugin.cjs +34 -15
  194. package/dist/cjs/vite/plugins/clientTreeShakePlugin.js +24 -3
  195. package/dist/cjs/vite/plugins/clientTreeShakePlugin.js.map +1 -1
  196. package/dist/cjs/vite/plugins/clientTreeShakePlugin.native.js +55 -19
  197. package/dist/cjs/vite/plugins/clientTreeShakePlugin.native.js.map +1 -1
  198. package/dist/cjs/vite/plugins/clientTreeShakePlugin.test.cjs +129 -0
  199. package/dist/cjs/vite/plugins/clientTreeShakePlugin.test.js +129 -0
  200. package/dist/cjs/vite/plugins/clientTreeShakePlugin.test.js.map +6 -0
  201. package/dist/cjs/vite/plugins/clientTreeShakePlugin.test.native.js +140 -0
  202. package/dist/cjs/vite/plugins/clientTreeShakePlugin.test.native.js.map +1 -0
  203. package/dist/cjs/vite/plugins/fileSystemRouterPlugin.js +6 -3
  204. package/dist/cjs/vite/plugins/fileSystemRouterPlugin.js.map +1 -1
  205. package/dist/cjs/vite/plugins/fileSystemRouterPlugin.native.js +3 -3
  206. package/dist/cjs/vite/plugins/fileSystemRouterPlugin.native.js.map +1 -1
  207. package/dist/cjs/vite/plugins/generateFileSystemRouteTypesPlugin.cjs +5 -1
  208. package/dist/cjs/vite/plugins/generateFileSystemRouteTypesPlugin.js +11 -6
  209. package/dist/cjs/vite/plugins/generateFileSystemRouteTypesPlugin.js.map +1 -1
  210. package/dist/cjs/vite/plugins/generateFileSystemRouteTypesPlugin.native.js +1 -0
  211. package/dist/cjs/vite/plugins/generateFileSystemRouteTypesPlugin.native.js.map +1 -1
  212. package/dist/cjs/vite/plugins/sourceInspectorPlugin.cjs +155 -0
  213. package/dist/cjs/vite/plugins/sourceInspectorPlugin.js +148 -0
  214. package/dist/cjs/vite/plugins/sourceInspectorPlugin.js.map +6 -0
  215. package/dist/cjs/vite/plugins/sourceInspectorPlugin.native.js +231 -0
  216. package/dist/cjs/vite/plugins/sourceInspectorPlugin.native.js.map +1 -0
  217. package/dist/cjs/vite/plugins/virtualEntryPlugin.cjs +25 -6
  218. package/dist/cjs/vite/plugins/virtualEntryPlugin.js +16 -6
  219. package/dist/cjs/vite/plugins/virtualEntryPlugin.js.map +1 -1
  220. package/dist/cjs/vite/plugins/virtualEntryPlugin.native.js +26 -7
  221. package/dist/cjs/vite/plugins/virtualEntryPlugin.native.js.map +1 -1
  222. package/dist/esm/cli/build.js +1 -1
  223. package/dist/esm/cli/build.js.map +1 -1
  224. package/dist/esm/cli/build.mjs +3 -1
  225. package/dist/esm/cli/build.mjs.map +1 -1
  226. package/dist/esm/cli/build.native.js +13 -12
  227. package/dist/esm/cli/build.native.js.map +1 -1
  228. package/dist/esm/cli/buildPage.js +1 -1
  229. package/dist/esm/cli/buildPage.mjs +1 -1
  230. package/dist/esm/cli/buildPage.mjs.map +1 -1
  231. package/dist/esm/cli/buildPage.native.js +2 -2
  232. package/dist/esm/cli/buildPage.native.js.map +1 -1
  233. package/dist/esm/cli/dev.js +4 -4
  234. package/dist/esm/cli/dev.js.map +1 -1
  235. package/dist/esm/cli/dev.mjs +4 -4
  236. package/dist/esm/cli/dev.mjs.map +1 -1
  237. package/dist/esm/cli/dev.native.js +4 -4
  238. package/dist/esm/cli/dev.native.js.map +1 -1
  239. package/dist/esm/cli/generateRoutes.js +1 -1
  240. package/dist/esm/cli/generateRoutes.mjs +1 -1
  241. package/dist/esm/cli/generateRoutes.mjs.map +1 -1
  242. package/dist/esm/cli/generateRoutes.native.js +1 -1
  243. package/dist/esm/cli/generateRoutes.native.js.map +1 -1
  244. package/dist/esm/cli/generateSitemap.native.js +7 -7
  245. package/dist/esm/cli/generateSitemap.native.js.map +1 -1
  246. package/dist/esm/config.native.js +2 -2
  247. package/dist/esm/config.native.js.map +1 -1
  248. package/dist/esm/constants.native.js +2 -2
  249. package/dist/esm/constants.native.js.map +1 -1
  250. package/dist/esm/createApp.js +2 -2
  251. package/dist/esm/createApp.js.map +1 -1
  252. package/dist/esm/createApp.mjs +2 -1
  253. package/dist/esm/createApp.mjs.map +1 -1
  254. package/dist/esm/createHandleRequest.test.js +3 -1
  255. package/dist/esm/createHandleRequest.test.js.map +1 -1
  256. package/dist/esm/createHandleRequest.test.mjs.map +1 -1
  257. package/dist/esm/createHandleRequest.test.native.js.map +1 -1
  258. package/dist/esm/devtools/registry.js +9 -0
  259. package/dist/esm/devtools/registry.js.map +6 -0
  260. package/dist/esm/devtools/registry.mjs +6 -0
  261. package/dist/esm/devtools/registry.mjs.map +1 -0
  262. package/dist/esm/devtools/registry.native.js +6 -0
  263. package/dist/esm/devtools/registry.native.js.map +1 -0
  264. package/dist/esm/fork/NavigationContainer.native.js +5 -5
  265. package/dist/esm/fork/NavigationContainer.native.js.map +1 -1
  266. package/dist/esm/fork/createMemoryHistory.js +22 -4
  267. package/dist/esm/fork/createMemoryHistory.js.map +1 -1
  268. package/dist/esm/fork/createMemoryHistory.mjs +20 -9
  269. package/dist/esm/fork/createMemoryHistory.mjs.map +1 -1
  270. package/dist/esm/fork/createMemoryHistory.native.js +22 -11
  271. package/dist/esm/fork/createMemoryHistory.native.js.map +1 -1
  272. package/dist/esm/fork/extractPathFromURL.native.js +8 -8
  273. package/dist/esm/fork/extractPathFromURL.native.js.map +1 -1
  274. package/dist/esm/fork/findFocusedRoute.native.js +2 -3
  275. package/dist/esm/fork/findFocusedRoute.native.js.map +1 -1
  276. package/dist/esm/fork/getPathFromState-mods.native.js +2 -3
  277. package/dist/esm/fork/getPathFromState-mods.native.js.map +1 -1
  278. package/dist/esm/fork/getStateFromPath-mods.native.js +3 -3
  279. package/dist/esm/fork/getStateFromPath-mods.native.js.map +1 -1
  280. package/dist/esm/fork/useLinking.js +6 -5
  281. package/dist/esm/fork/useLinking.js.map +1 -1
  282. package/dist/esm/fork/useLinking.mjs +11 -5
  283. package/dist/esm/fork/useLinking.mjs.map +1 -1
  284. package/dist/esm/fork/useLinking.native.js.map +1 -1
  285. package/dist/esm/head/url.native.js +2 -3
  286. package/dist/esm/head/url.native.js.map +1 -1
  287. package/dist/esm/hooks.js.map +1 -1
  288. package/dist/esm/hooks.mjs.map +1 -1
  289. package/dist/esm/hooks.native.js.map +1 -1
  290. package/dist/esm/index.js +30 -2
  291. package/dist/esm/index.js.map +1 -1
  292. package/dist/esm/index.mjs +8 -2
  293. package/dist/esm/index.mjs.map +1 -1
  294. package/dist/esm/index.native.js +8 -2
  295. package/dist/esm/index.native.js.map +1 -1
  296. package/dist/esm/layouts/withLayoutContext.js +30 -12
  297. package/dist/esm/layouts/withLayoutContext.js.map +1 -1
  298. package/dist/esm/layouts/withLayoutContext.mjs +34 -15
  299. package/dist/esm/layouts/withLayoutContext.mjs.map +1 -1
  300. package/dist/esm/layouts/withLayoutContext.native.js +42 -19
  301. package/dist/esm/layouts/withLayoutContext.native.js.map +1 -1
  302. package/dist/esm/link/Link.js +3 -2
  303. package/dist/esm/link/Link.js.map +1 -1
  304. package/dist/esm/link/Link.mjs +5 -2
  305. package/dist/esm/link/Link.mjs.map +1 -1
  306. package/dist/esm/link/Link.native.js +6 -1
  307. package/dist/esm/link/Link.native.js.map +1 -1
  308. package/dist/esm/link/href.native.js +2 -2
  309. package/dist/esm/link/href.native.js.map +1 -1
  310. package/dist/esm/link/useLinkTo.js +6 -3
  311. package/dist/esm/link/useLinkTo.js.map +1 -1
  312. package/dist/esm/link/useLinkTo.mjs +11 -3
  313. package/dist/esm/link/useLinkTo.mjs.map +1 -1
  314. package/dist/esm/link/useLinkTo.native.js +11 -3
  315. package/dist/esm/link/useLinkTo.native.js.map +1 -1
  316. package/dist/esm/router/Route.js.map +1 -1
  317. package/dist/esm/router/Route.mjs.map +1 -1
  318. package/dist/esm/router/Route.native.js.map +1 -1
  319. package/dist/esm/router/findRouteNode.js +56 -0
  320. package/dist/esm/router/findRouteNode.js.map +6 -0
  321. package/dist/esm/router/findRouteNode.mjs +44 -0
  322. package/dist/esm/router/findRouteNode.mjs.map +1 -0
  323. package/dist/esm/router/findRouteNode.native.js +75 -0
  324. package/dist/esm/router/findRouteNode.native.js.map +1 -0
  325. package/dist/esm/router/getRoutes.native.js +3 -3
  326. package/dist/esm/router/getRoutes.native.js.map +1 -1
  327. package/dist/esm/router/router.js +154 -6
  328. package/dist/esm/router/router.js.map +1 -1
  329. package/dist/esm/router/router.mjs +151 -10
  330. package/dist/esm/router/router.mjs.map +1 -1
  331. package/dist/esm/router/router.native.js +238 -66
  332. package/dist/esm/router/router.native.js.map +1 -1
  333. package/dist/esm/router/useNavigation.js.map +1 -1
  334. package/dist/esm/router/useNavigation.mjs.map +1 -1
  335. package/dist/esm/router/useNavigation.native.js.map +1 -1
  336. package/dist/esm/router/useScreens.js +1 -1
  337. package/dist/esm/router/useScreens.js.map +1 -1
  338. package/dist/esm/router/useScreens.mjs +1 -1
  339. package/dist/esm/router/useScreens.mjs.map +1 -1
  340. package/dist/esm/router/useScreens.native.js +6 -3
  341. package/dist/esm/router/useScreens.native.js.map +1 -1
  342. package/dist/esm/router/utils/getNavigateAction.native.js +2 -4
  343. package/dist/esm/router/utils/getNavigateAction.native.js.map +1 -1
  344. package/dist/esm/server/oneServe.js.map +1 -1
  345. package/dist/esm/server/oneServe.mjs.map +1 -1
  346. package/dist/esm/server/oneServe.native.js +4 -4
  347. package/dist/esm/server/oneServe.native.js.map +1 -1
  348. package/dist/esm/server/setupBuildOptions.native.js +1 -1
  349. package/dist/esm/server/setupBuildOptions.native.js.map +1 -1
  350. package/dist/esm/ui/common.native.js +6 -5
  351. package/dist/esm/ui/common.native.js.map +1 -1
  352. package/dist/esm/useBlocker.js +122 -0
  353. package/dist/esm/useBlocker.js.map +6 -0
  354. package/dist/esm/useBlocker.mjs +123 -0
  355. package/dist/esm/useBlocker.mjs.map +1 -0
  356. package/dist/esm/useBlocker.native.js +51 -0
  357. package/dist/esm/useBlocker.native.js.map +1 -0
  358. package/dist/esm/useFocusEffect.js +2 -2
  359. package/dist/esm/useFocusEffect.js.map +1 -1
  360. package/dist/esm/useFocusEffect.mjs +2 -2
  361. package/dist/esm/useFocusEffect.mjs.map +1 -1
  362. package/dist/esm/useFocusEffect.native.js +2 -2
  363. package/dist/esm/useFocusEffect.native.js.map +1 -1
  364. package/dist/esm/useLoader.js +57 -3
  365. package/dist/esm/useLoader.js.map +2 -2
  366. package/dist/esm/useLoader.mjs +69 -4
  367. package/dist/esm/useLoader.mjs.map +1 -1
  368. package/dist/esm/useLoader.native.js +90 -7
  369. package/dist/esm/useLoader.native.js.map +1 -1
  370. package/dist/esm/useScrollGroup.js +16 -0
  371. package/dist/esm/useScrollGroup.js.map +6 -0
  372. package/dist/esm/useScrollGroup.mjs +14 -0
  373. package/dist/esm/useScrollGroup.mjs.map +1 -0
  374. package/dist/esm/useScrollGroup.native.js +3 -0
  375. package/dist/esm/useScrollGroup.native.js.map +1 -0
  376. package/dist/esm/validateParams.js +68 -0
  377. package/dist/esm/validateParams.js.map +6 -0
  378. package/dist/esm/validateParams.mjs +54 -0
  379. package/dist/esm/validateParams.mjs.map +1 -0
  380. package/dist/esm/validateParams.native.js +151 -0
  381. package/dist/esm/validateParams.native.js.map +1 -0
  382. package/dist/esm/validateSearch.js +83 -0
  383. package/dist/esm/validateSearch.js.map +6 -0
  384. package/dist/esm/validateSearch.mjs +77 -0
  385. package/dist/esm/validateSearch.mjs.map +1 -0
  386. package/dist/esm/validateSearch.native.js +172 -0
  387. package/dist/esm/validateSearch.native.js.map +1 -0
  388. package/dist/esm/vercel/build/buildVercelOutputDirectory.native.js +2 -2
  389. package/dist/esm/vercel/build/buildVercelOutputDirectory.native.js.map +1 -1
  390. package/dist/esm/views/ErrorBoundary.js +325 -7
  391. package/dist/esm/views/ErrorBoundary.js.map +2 -2
  392. package/dist/esm/views/ErrorBoundary.mjs +289 -6
  393. package/dist/esm/views/ErrorBoundary.mjs.map +1 -1
  394. package/dist/esm/views/ErrorBoundary.native.js +159 -4
  395. package/dist/esm/views/ErrorBoundary.native.js.map +1 -1
  396. package/dist/esm/views/Navigator.js +11 -2
  397. package/dist/esm/views/Navigator.js.map +1 -1
  398. package/dist/esm/views/Navigator.mjs +10 -3
  399. package/dist/esm/views/Navigator.mjs.map +1 -1
  400. package/dist/esm/views/Navigator.native.js +15 -6
  401. package/dist/esm/views/Navigator.native.js.map +1 -1
  402. package/dist/esm/views/Protected.js +14 -0
  403. package/dist/esm/views/Protected.js.map +6 -0
  404. package/dist/esm/views/Protected.mjs +11 -0
  405. package/dist/esm/views/Protected.mjs.map +1 -0
  406. package/dist/esm/views/Protected.native.js +16 -0
  407. package/dist/esm/views/Protected.native.js.map +1 -0
  408. package/dist/esm/views/RootErrorBoundary.js +214 -7
  409. package/dist/esm/views/RootErrorBoundary.js.map +1 -1
  410. package/dist/esm/views/RootErrorBoundary.mjs +192 -7
  411. package/dist/esm/views/RootErrorBoundary.mjs.map +1 -1
  412. package/dist/esm/views/RootErrorBoundary.native.js +191 -7
  413. package/dist/esm/views/RootErrorBoundary.native.js.map +1 -1
  414. package/dist/esm/views/ScrollBehavior.js +47 -11
  415. package/dist/esm/views/ScrollBehavior.js.map +1 -1
  416. package/dist/esm/views/ScrollBehavior.mjs +48 -11
  417. package/dist/esm/views/ScrollBehavior.mjs.map +1 -1
  418. package/dist/esm/views/ScrollBehavior.native.js +67 -10
  419. package/dist/esm/views/ScrollBehavior.native.js.map +1 -1
  420. package/dist/esm/views/SourceInspector.js +7 -0
  421. package/dist/esm/views/SourceInspector.js.map +6 -0
  422. package/dist/esm/views/SourceInspector.mjs +5 -0
  423. package/dist/esm/views/SourceInspector.mjs.map +1 -0
  424. package/dist/esm/views/SourceInspector.native.js +6 -0
  425. package/dist/esm/views/SourceInspector.native.js.map +1 -0
  426. package/dist/esm/views/Try.js +38 -4
  427. package/dist/esm/views/Try.js.map +1 -1
  428. package/dist/esm/views/Try.mjs +40 -7
  429. package/dist/esm/views/Try.mjs.map +1 -1
  430. package/dist/esm/views/Try.native.js +42 -7
  431. package/dist/esm/views/Try.native.js.map +1 -1
  432. package/dist/esm/vite/DevHead.js +802 -51
  433. package/dist/esm/vite/DevHead.js.map +1 -1
  434. package/dist/esm/vite/DevHead.mjs +797 -43
  435. package/dist/esm/vite/DevHead.mjs.map +1 -1
  436. package/dist/esm/vite/DevHead.native.js +782 -0
  437. package/dist/esm/vite/DevHead.native.js.map +1 -1
  438. package/dist/esm/vite/one.js +7 -1
  439. package/dist/esm/vite/one.js.map +1 -1
  440. package/dist/esm/vite/one.mjs +7 -1
  441. package/dist/esm/vite/one.mjs.map +1 -1
  442. package/dist/esm/vite/one.native.js +17 -7
  443. package/dist/esm/vite/one.native.js.map +1 -1
  444. package/dist/esm/vite/plugins/SSRCSSPlugin.js +48 -4
  445. package/dist/esm/vite/plugins/SSRCSSPlugin.js.map +1 -1
  446. package/dist/esm/vite/plugins/SSRCSSPlugin.mjs +44 -4
  447. package/dist/esm/vite/plugins/SSRCSSPlugin.mjs.map +1 -1
  448. package/dist/esm/vite/plugins/SSRCSSPlugin.native.js +61 -4
  449. package/dist/esm/vite/plugins/SSRCSSPlugin.native.js.map +1 -1
  450. package/dist/esm/vite/plugins/clientTreeShakePlugin.js +24 -3
  451. package/dist/esm/vite/plugins/clientTreeShakePlugin.js.map +1 -1
  452. package/dist/esm/vite/plugins/clientTreeShakePlugin.mjs +34 -15
  453. package/dist/esm/vite/plugins/clientTreeShakePlugin.mjs.map +1 -1
  454. package/dist/esm/vite/plugins/clientTreeShakePlugin.native.js +55 -19
  455. package/dist/esm/vite/plugins/clientTreeShakePlugin.native.js.map +1 -1
  456. package/dist/esm/vite/plugins/clientTreeShakePlugin.test.js +130 -0
  457. package/dist/esm/vite/plugins/clientTreeShakePlugin.test.js.map +6 -0
  458. package/dist/esm/vite/plugins/clientTreeShakePlugin.test.mjs +130 -0
  459. package/dist/esm/vite/plugins/clientTreeShakePlugin.test.mjs.map +1 -0
  460. package/dist/esm/vite/plugins/clientTreeShakePlugin.test.native.js +138 -0
  461. package/dist/esm/vite/plugins/clientTreeShakePlugin.test.native.js.map +1 -0
  462. package/dist/esm/vite/plugins/fileSystemRouterPlugin.js +6 -3
  463. package/dist/esm/vite/plugins/fileSystemRouterPlugin.js.map +1 -1
  464. package/dist/esm/vite/plugins/fileSystemRouterPlugin.mjs.map +1 -1
  465. package/dist/esm/vite/plugins/fileSystemRouterPlugin.native.js +3 -3
  466. package/dist/esm/vite/plugins/fileSystemRouterPlugin.native.js.map +1 -1
  467. package/dist/esm/vite/plugins/generateFileSystemRouteTypesPlugin.js +11 -6
  468. package/dist/esm/vite/plugins/generateFileSystemRouteTypesPlugin.js.map +1 -1
  469. package/dist/esm/vite/plugins/generateFileSystemRouteTypesPlugin.mjs +5 -1
  470. package/dist/esm/vite/plugins/generateFileSystemRouteTypesPlugin.mjs.map +1 -1
  471. package/dist/esm/vite/plugins/generateFileSystemRouteTypesPlugin.native.js +1 -0
  472. package/dist/esm/vite/plugins/generateFileSystemRouteTypesPlugin.native.js.map +1 -1
  473. package/dist/esm/vite/plugins/sourceInspectorPlugin.js +126 -0
  474. package/dist/esm/vite/plugins/sourceInspectorPlugin.js.map +6 -0
  475. package/dist/esm/vite/plugins/sourceInspectorPlugin.mjs +121 -0
  476. package/dist/esm/vite/plugins/sourceInspectorPlugin.mjs.map +1 -0
  477. package/dist/esm/vite/plugins/sourceInspectorPlugin.native.js +194 -0
  478. package/dist/esm/vite/plugins/sourceInspectorPlugin.native.js.map +1 -0
  479. package/dist/esm/vite/plugins/virtualEntryPlugin.js +16 -6
  480. package/dist/esm/vite/plugins/virtualEntryPlugin.js.map +1 -1
  481. package/dist/esm/vite/plugins/virtualEntryPlugin.mjs +25 -6
  482. package/dist/esm/vite/plugins/virtualEntryPlugin.mjs.map +1 -1
  483. package/dist/esm/vite/plugins/virtualEntryPlugin.native.js +26 -7
  484. package/dist/esm/vite/plugins/virtualEntryPlugin.native.js.map +1 -1
  485. package/package.json +16 -14
  486. package/src/cli/build.ts +1 -1
  487. package/src/cli/buildPage.ts +1 -1
  488. package/src/cli/dev.ts +4 -4
  489. package/src/cli/generateRoutes.ts +1 -1
  490. package/src/createApp.tsx +11 -1
  491. package/src/createHandleRequest.test.ts +3 -1
  492. package/src/devtools/registry.ts +21 -0
  493. package/src/fork/createMemoryHistory.tsx +43 -11
  494. package/src/fork/useLinking.ts +14 -4
  495. package/src/hooks.tsx +71 -21
  496. package/src/index.ts +34 -1
  497. package/src/interfaces/router.ts +48 -0
  498. package/src/layouts/withLayoutContext.tsx +48 -8
  499. package/src/link/Link.tsx +7 -2
  500. package/src/link/useLinkTo.tsx +7 -3
  501. package/src/router/Route.tsx +32 -3
  502. package/src/router/findRouteNode.ts +127 -0
  503. package/src/router/router.ts +291 -2
  504. package/src/router/useNavigation.ts +12 -3
  505. package/src/router/useScreens.tsx +9 -3
  506. package/src/useBlocker.native.ts +153 -0
  507. package/src/useBlocker.ts +340 -0
  508. package/src/useFocusEffect.ts +18 -5
  509. package/src/useLoader.ts +193 -2
  510. package/src/useScrollGroup.native.ts +7 -0
  511. package/src/useScrollGroup.ts +35 -0
  512. package/src/validateParams.ts +196 -0
  513. package/src/validateSearch.ts +241 -0
  514. package/src/views/ErrorBoundary.tsx +154 -156
  515. package/src/views/ErrorBoundary.web.tsx +321 -0
  516. package/src/views/Navigator.tsx +18 -2
  517. package/src/views/Protected.tsx +62 -0
  518. package/src/views/RootErrorBoundary.tsx +214 -17
  519. package/src/views/ScrollBehavior.tsx +82 -3
  520. package/src/views/SourceInspector.tsx +39 -0
  521. package/src/views/Try.tsx +81 -12
  522. package/src/vite/DevHead.tsx +819 -54
  523. package/src/vite/one.ts +13 -0
  524. package/src/vite/plugins/SSRCSSPlugin.ts +104 -0
  525. package/src/vite/plugins/clientTreeShakePlugin.test.ts +174 -0
  526. package/src/vite/plugins/clientTreeShakePlugin.ts +50 -4
  527. package/src/vite/plugins/fileSystemRouterPlugin.tsx +11 -8
  528. package/src/vite/plugins/generateFileSystemRouteTypesPlugin.tsx +4 -0
  529. package/src/vite/plugins/sourceInspectorPlugin.ts +246 -0
  530. package/src/vite/plugins/virtualEntryPlugin.ts +36 -10
  531. package/src/vite/types.ts +28 -0
  532. package/types/createApp.d.ts +5 -0
  533. package/types/createApp.d.ts.map +1 -1
  534. package/types/devtools/registry.d.ts +15 -0
  535. package/types/devtools/registry.d.ts.map +1 -0
  536. package/types/fork/createMemoryHistory.d.ts +8 -3
  537. package/types/fork/createMemoryHistory.d.ts.map +1 -1
  538. package/types/fork/useLinking.d.ts.map +1 -1
  539. package/types/hooks.d.ts +71 -20
  540. package/types/hooks.d.ts.map +1 -1
  541. package/types/index.d.ts +8 -1
  542. package/types/index.d.ts.map +1 -1
  543. package/types/interfaces/router.d.ts +47 -0
  544. package/types/interfaces/router.d.ts.map +1 -1
  545. package/types/layouts/Drawer.d.ts +15 -11
  546. package/types/layouts/Drawer.d.ts.map +1 -1
  547. package/types/layouts/withLayoutContext.d.ts +2 -1
  548. package/types/layouts/withLayoutContext.d.ts.map +1 -1
  549. package/types/link/Link.d.ts.map +1 -1
  550. package/types/link/useLinkTo.d.ts +1 -0
  551. package/types/link/useLinkTo.d.ts.map +1 -1
  552. package/types/router/Route.d.ts +32 -3
  553. package/types/router/Route.d.ts.map +1 -1
  554. package/types/router/findRouteNode.d.ts +31 -0
  555. package/types/router/findRouteNode.d.ts.map +1 -0
  556. package/types/router/router.d.ts +35 -0
  557. package/types/router/router.d.ts.map +1 -1
  558. package/types/router/useNavigation.d.ts +12 -3
  559. package/types/router/useNavigation.d.ts.map +1 -1
  560. package/types/router/useScreens.d.ts +2 -0
  561. package/types/router/useScreens.d.ts.map +1 -1
  562. package/types/server/oneServe.d.ts.map +1 -1
  563. package/types/ui/TabContext.d.ts +1 -1
  564. package/types/ui/TabContext.d.ts.map +1 -1
  565. package/types/ui/Tabs.d.ts +2 -2
  566. package/types/ui/Tabs.d.ts.map +1 -1
  567. package/types/useBlocker.d.ts +72 -0
  568. package/types/useBlocker.d.ts.map +1 -0
  569. package/types/useBlocker.native.d.ts +60 -0
  570. package/types/useBlocker.native.d.ts.map +1 -0
  571. package/types/useFocusEffect.d.ts +17 -4
  572. package/types/useFocusEffect.d.ts.map +1 -1
  573. package/types/useLoader.d.ts +63 -0
  574. package/types/useLoader.d.ts.map +1 -1
  575. package/types/useScrollGroup.d.ts +18 -0
  576. package/types/useScrollGroup.d.ts.map +1 -0
  577. package/types/useScrollGroup.native.d.ts +6 -0
  578. package/types/useScrollGroup.native.d.ts.map +1 -0
  579. package/types/validateParams.d.ts +85 -0
  580. package/types/validateParams.d.ts.map +1 -0
  581. package/types/validateSearch.d.ts +107 -0
  582. package/types/validateSearch.d.ts.map +1 -0
  583. package/types/views/ErrorBoundary.d.ts +11 -1
  584. package/types/views/ErrorBoundary.d.ts.map +1 -1
  585. package/types/views/ErrorBoundary.web.d.ts +13 -0
  586. package/types/views/ErrorBoundary.web.d.ts.map +1 -0
  587. package/types/views/Navigator.d.ts.map +1 -1
  588. package/types/views/Protected.d.ts +39 -0
  589. package/types/views/Protected.d.ts.map +1 -0
  590. package/types/views/RootErrorBoundary.d.ts +14 -8
  591. package/types/views/RootErrorBoundary.d.ts.map +1 -1
  592. package/types/views/ScrollBehavior.d.ts +8 -0
  593. package/types/views/ScrollBehavior.d.ts.map +1 -1
  594. package/types/views/SourceInspector.d.ts +35 -0
  595. package/types/views/SourceInspector.d.ts.map +1 -0
  596. package/types/views/Try.d.ts +29 -6
  597. package/types/views/Try.d.ts.map +1 -1
  598. package/types/vite/DevHead.d.ts.map +1 -1
  599. package/types/vite/one.d.ts.map +1 -1
  600. package/types/vite/plugins/SSRCSSPlugin.d.ts.map +1 -1
  601. package/types/vite/plugins/clientTreeShakePlugin.d.ts.map +1 -1
  602. package/types/vite/plugins/clientTreeShakePlugin.test.d.ts +2 -0
  603. package/types/vite/plugins/clientTreeShakePlugin.test.d.ts.map +1 -0
  604. package/types/vite/plugins/fileSystemRouterPlugin.d.ts.map +1 -1
  605. package/types/vite/plugins/generateFileSystemRouteTypesPlugin.d.ts.map +1 -1
  606. package/types/vite/plugins/sourceInspectorPlugin.d.ts +3 -0
  607. package/types/vite/plugins/sourceInspectorPlugin.d.ts.map +1 -0
  608. package/types/vite/plugins/virtualEntryPlugin.d.ts.map +1 -1
  609. package/types/vite/types.d.ts +24 -0
  610. package/types/vite/types.d.ts.map +1 -1
  611. package/types/env.d.ts +0 -66
  612. /package/types/vercel/build/generate/{createSSRServerlessFunction.d.ts → createSsrServerlessFunction.d.ts} +0 -0
@@ -0,0 +1,62 @@
1
+ import { createNavigatorFactory } from '@react-navigation/core'
2
+ import {
3
+ type FunctionComponent,
4
+ type ReactElement,
5
+ type ReactNode,
6
+ isValidElement,
7
+ } from 'react'
8
+
9
+ // Get Group component directly from react-navigation core
10
+ // (avoids pulling in @react-navigation/elements which has asset imports)
11
+ const { Group } = createNavigatorFactory({} as any)()
12
+
13
+ export type ProtectedProps = {
14
+ guard: boolean
15
+ children?: ReactNode
16
+ }
17
+
18
+ /**
19
+ * Wrap screens in a Protected component to conditionally show/hide them based on the guard prop.
20
+ *
21
+ * When `guard` is `false`, the wrapped screens are filtered out and cannot be navigated to.
22
+ * When `guard` is `true`, the wrapped screens are available for navigation.
23
+ *
24
+ * Works with any navigator: Stack, Tabs, Drawer, or custom Navigator.
25
+ *
26
+ * @example
27
+ * ```tsx
28
+ * import { Stack, Protected } from 'one'
29
+ *
30
+ * export default function Layout() {
31
+ * const { isAuthed } = useAuth()
32
+ * return (
33
+ * <Stack>
34
+ * <Stack.Screen name="login" />
35
+ * <Protected guard={isAuthed}>
36
+ * <Stack.Screen name="dashboard" />
37
+ * <Stack.Screen name="settings" />
38
+ * </Protected>
39
+ * </Stack>
40
+ * )
41
+ * }
42
+ * ```
43
+ */
44
+ export const Protected = Group as FunctionComponent<ProtectedProps>
45
+
46
+ // Export Group for use in isProtectedElement check
47
+ export { Group }
48
+
49
+ /**
50
+ * Type guard to check if a React element is a Protected component with a guard prop.
51
+ */
52
+ export function isProtectedElement(
53
+ child: ReactNode
54
+ ): child is ReactElement<ProtectedProps> {
55
+ return Boolean(
56
+ isValidElement(child) &&
57
+ child.type === Group &&
58
+ child.props &&
59
+ typeof child.props === 'object' &&
60
+ 'guard' in child.props
61
+ )
62
+ }
@@ -1,35 +1,232 @@
1
1
  import React from 'react'
2
- import { Text, View } from 'react-native'
2
+ import { Platform, Text, View } from 'react-native'
3
3
 
4
- export class RootErrorBoundary extends React.Component<{ children: any }> {
5
- state = { hasError: false }
4
+ type RootErrorBoundaryState = {
5
+ hasError: boolean
6
+ error: Error | null
7
+ componentStack: string | null
8
+ }
9
+
10
+ export class RootErrorBoundary extends React.Component<
11
+ { children: React.ReactNode },
12
+ RootErrorBoundaryState
13
+ > {
14
+ state: RootErrorBoundaryState = {
15
+ hasError: false,
16
+ error: null,
17
+ componentStack: null,
18
+ }
6
19
 
7
- static getDerivedStateFromError(error) {
8
- // Update state so the next render will show the fallback UI.
9
- return { hasError: true }
20
+ static getDerivedStateFromError(error: Error) {
21
+ return { hasError: true, error }
10
22
  }
11
23
 
12
- componentDidCatch(error, info) {
13
- // Example "componentStack":
14
- // in ComponentThatThrows (created by App)
15
- // in ErrorBoundary (created by App)
16
- // in div (created by App)
17
- // in App
24
+ componentDidCatch(error: Error, info: React.ErrorInfo) {
25
+ this.setState({ componentStack: info.componentStack || null })
26
+
18
27
  console.error(
19
- `RootErrorBoundary.error:\n${printError(error)}\n${info.componentStack}`
28
+ `[One] Root error boundary caught error:\n${printError(error)}\n${info.componentStack}`
20
29
  )
30
+
31
+ // Dispatch error event for devtools
32
+ if (typeof window !== 'undefined') {
33
+ window.dispatchEvent(
34
+ new CustomEvent('one-error', {
35
+ detail: {
36
+ error: {
37
+ message: error.message,
38
+ stack: error.stack,
39
+ name: error.name,
40
+ },
41
+ componentStack: info.componentStack,
42
+ timestamp: Date.now(),
43
+ type: 'render',
44
+ },
45
+ })
46
+ )
47
+ }
48
+ }
49
+
50
+ handleRetry = () => {
51
+ this.setState({ hasError: false, error: null, componentStack: null })
21
52
  }
22
53
 
23
54
  render() {
24
55
  if (this.state.hasError) {
25
- // You can render any custom fallback UI
26
- return null
56
+ const { error, componentStack } = this.state
57
+ const isDev = process.env.NODE_ENV === 'development'
58
+
59
+ // Web fallback UI
60
+ if (Platform.OS === 'web') {
61
+ return (
62
+ <div
63
+ style={{
64
+ minHeight: '100vh',
65
+ display: 'flex',
66
+ alignItems: 'center',
67
+ justifyContent: 'center',
68
+ backgroundColor: '#0a0a0f',
69
+ fontFamily:
70
+ '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif',
71
+ color: '#e8e8e8',
72
+ padding: 24,
73
+ }}
74
+ >
75
+ <div
76
+ style={{
77
+ maxWidth: 500,
78
+ width: '100%',
79
+ textAlign: 'center',
80
+ }}
81
+ >
82
+ <div
83
+ style={{
84
+ width: 64,
85
+ height: 64,
86
+ backgroundColor: '#ef4444',
87
+ borderRadius: '50%',
88
+ display: 'flex',
89
+ alignItems: 'center',
90
+ justifyContent: 'center',
91
+ margin: '0 auto 24px',
92
+ }}
93
+ >
94
+ <svg
95
+ width="32"
96
+ height="32"
97
+ viewBox="0 0 24 24"
98
+ fill="none"
99
+ stroke="white"
100
+ strokeWidth="2"
101
+ >
102
+ <circle cx="12" cy="12" r="10" />
103
+ <line x1="12" y1="8" x2="12" y2="12" />
104
+ <line x1="12" y1="16" x2="12.01" y2="16" />
105
+ </svg>
106
+ </div>
107
+ <h1
108
+ style={{
109
+ fontSize: 24,
110
+ fontWeight: 600,
111
+ marginBottom: 8,
112
+ }}
113
+ >
114
+ Something went wrong
115
+ </h1>
116
+ <p
117
+ style={{
118
+ fontSize: 14,
119
+ color: '#888',
120
+ marginBottom: 24,
121
+ }}
122
+ >
123
+ {error?.message || 'An unexpected error occurred'}
124
+ </p>
125
+ <div style={{ display: 'flex', gap: 12, justifyContent: 'center' }}>
126
+ <button
127
+ onClick={this.handleRetry}
128
+ style={{
129
+ padding: '12px 24px',
130
+ backgroundColor: '#3b82f6',
131
+ color: 'white',
132
+ border: 'none',
133
+ borderRadius: 8,
134
+ fontSize: 14,
135
+ fontWeight: 500,
136
+ cursor: 'pointer',
137
+ }}
138
+ >
139
+ Try Again
140
+ </button>
141
+ <button
142
+ onClick={() => {
143
+ if (typeof window !== 'undefined') {
144
+ window.location.href = '/'
145
+ }
146
+ }}
147
+ style={{
148
+ padding: '12px 24px',
149
+ backgroundColor: 'transparent',
150
+ color: '#888',
151
+ border: '1px solid #3a3a5a',
152
+ borderRadius: 8,
153
+ fontSize: 14,
154
+ fontWeight: 500,
155
+ cursor: 'pointer',
156
+ }}
157
+ >
158
+ Go Home
159
+ </button>
160
+ </div>
161
+ {isDev && (
162
+ <p
163
+ style={{
164
+ fontSize: 11,
165
+ color: '#666',
166
+ marginTop: 24,
167
+ }}
168
+ >
169
+ Press Alt+E to view error details
170
+ </p>
171
+ )}
172
+ </div>
173
+ </div>
174
+ )
175
+ }
176
+
177
+ // Native fallback UI
178
+ return (
179
+ <View
180
+ style={{
181
+ flex: 1,
182
+ alignItems: 'center',
183
+ justifyContent: 'center',
184
+ backgroundColor: '#0a0a0f',
185
+ padding: 24,
186
+ }}
187
+ >
188
+ <View
189
+ style={{
190
+ width: 64,
191
+ height: 64,
192
+ backgroundColor: '#ef4444',
193
+ borderRadius: 32,
194
+ alignItems: 'center',
195
+ justifyContent: 'center',
196
+ marginBottom: 24,
197
+ }}
198
+ >
199
+ <Text style={{ color: 'white', fontSize: 32 }}>!</Text>
200
+ </View>
201
+ <Text
202
+ style={{
203
+ fontSize: 20,
204
+ fontWeight: '600',
205
+ color: '#e8e8e8',
206
+ marginBottom: 8,
207
+ textAlign: 'center',
208
+ }}
209
+ >
210
+ Something went wrong
211
+ </Text>
212
+ <Text
213
+ style={{
214
+ fontSize: 14,
215
+ color: '#888',
216
+ textAlign: 'center',
217
+ marginBottom: 24,
218
+ }}
219
+ >
220
+ {error?.message || 'An unexpected error occurred'}
221
+ </Text>
222
+ </View>
223
+ )
27
224
  }
28
225
 
29
226
  return this.props.children
30
227
  }
31
228
  }
32
229
 
33
- function printError(err) {
34
- return `${err instanceof Error ? `${err.message}\n${err.stack}` : err}`
230
+ function printError(err: unknown): string {
231
+ return err instanceof Error ? `${err.message}\n${err.stack}` : String(err)
35
232
  }
@@ -3,12 +3,45 @@ import { setLastAction } from '../router/lastAction'
3
3
  import { subscribeToLoadingState, subscribeToRootState } from '../router/router'
4
4
 
5
5
  const KEY = 'one-sr'
6
+ const GROUP_KEY = 'one-sr-groups'
6
7
 
7
8
  const getState = () => JSON.parse(sessionStorage.getItem(KEY) || '{}')
9
+ const getGroupState = () => JSON.parse(sessionStorage.getItem(GROUP_KEY) || '{}')
8
10
 
9
11
  // prevent scroll to top on first load
10
12
  let isFirstLoad = true
11
13
 
14
+ // Active scroll groups - defined by layouts
15
+ let activeGroups: Set<string> = new Set()
16
+
17
+ /**
18
+ * Scroll Position Groups allow layouts to preserve their scroll position
19
+ * independently of child route changes. This is useful for:
20
+ * - Tab layouts where switching tabs shouldn't reset parent scroll
21
+ * - Side panels where main content scroll is preserved
22
+ * - Any nested layout that wants independent scroll restoration
23
+ */
24
+ export function registerScrollGroup(groupId: string) {
25
+ activeGroups.add(groupId)
26
+ return () => {
27
+ activeGroups.delete(groupId)
28
+ }
29
+ }
30
+
31
+ function getGroupKey(pathname: string): string | null {
32
+ // Find the longest matching group for this pathname
33
+ let longestMatch: string | null = null
34
+ for (const group of activeGroups) {
35
+ if (
36
+ pathname.startsWith(group) &&
37
+ (!longestMatch || group.length > longestMatch.length)
38
+ ) {
39
+ longestMatch = group
40
+ }
41
+ }
42
+ return longestMatch
43
+ }
44
+
12
45
  function restorePosition() {
13
46
  try {
14
47
  const positions = getState()
@@ -24,13 +57,42 @@ function restorePosition() {
24
57
  }
25
58
  }
26
59
 
60
+ function restoreGroupPosition(groupId: string) {
61
+ try {
62
+ const positions = getGroupState()
63
+ const saved = positions[groupId]
64
+ if (typeof saved === 'number') {
65
+ setTimeout(() => {
66
+ window.scrollTo(0, saved)
67
+ })
68
+ }
69
+ } catch (error) {
70
+ console.error(`Error restoring scroll position for group ${groupId}`, error)
71
+ sessionStorage.removeItem(GROUP_KEY)
72
+ }
73
+ }
74
+
27
75
  let didPop = false
76
+ let previousPathname: string | null = null
28
77
 
29
78
  function rememberScrollPosition() {
30
79
  didPop = false
80
+ const pathname = window.location.pathname
81
+
82
+ // Save standard per-path scroll position
31
83
  const state = getState()
32
- state[window.location.pathname] = window.scrollY
84
+ state[pathname] = window.scrollY
33
85
  sessionStorage.setItem(KEY, JSON.stringify(state))
86
+
87
+ // Also save for any active scroll group
88
+ const groupKey = getGroupKey(pathname)
89
+ if (groupKey) {
90
+ const groupState = getGroupState()
91
+ groupState[groupKey] = window.scrollY
92
+ sessionStorage.setItem(GROUP_KEY, JSON.stringify(groupState))
93
+ }
94
+
95
+ previousPathname = pathname
34
96
  }
35
97
 
36
98
  type ScrollBehaviorProps = {
@@ -68,6 +130,7 @@ function configure(props: ScrollBehaviorProps) {
68
130
  const disposeOnRootState = subscribeToRootState((state) => {
69
131
  if (isFirstLoad) {
70
132
  isFirstLoad = false
133
+ previousPathname = window.location.pathname
71
134
  return
72
135
  }
73
136
 
@@ -76,6 +139,7 @@ function configure(props: ScrollBehaviorProps) {
76
139
  }
77
140
 
78
141
  const { hash } = state
142
+ const currentPathname = window.location.pathname
79
143
 
80
144
  if (hash) {
81
145
  setTimeout(() => {
@@ -87,9 +151,24 @@ function configure(props: ScrollBehaviorProps) {
87
151
  restorePosition()
88
152
  }
89
153
  } else {
90
- // if new page just set back to top
91
- window.scrollTo(0, 0)
154
+ // Check if we're navigating within a scroll group
155
+ // If both previous and current paths are in the same group, restore group position
156
+ const prevGroup = previousPathname ? getGroupKey(previousPathname) : null
157
+ const currentGroup = getGroupKey(currentPathname)
158
+
159
+ if (prevGroup && currentGroup && prevGroup === currentGroup) {
160
+ // Same scroll group - restore the group's scroll position
161
+ restoreGroupPosition(currentGroup)
162
+ } else if (state.linkOptions?.scrollGroup) {
163
+ // Custom scroll group specified in link options
164
+ restoreGroupPosition(state.linkOptions.scrollGroup)
165
+ } else {
166
+ // Different group or no group - scroll to top
167
+ window.scrollTo(0, 0)
168
+ }
92
169
  }
170
+
171
+ previousPathname = currentPathname
93
172
  })
94
173
 
95
174
  disable = () => {
@@ -0,0 +1,39 @@
1
+ import type { ReactNode } from 'react'
2
+
3
+ /**
4
+ * SourceInspector component - the actual functionality is now injected via DevHead.tsx
5
+ * This component is kept for backwards compatibility and returns null.
6
+ *
7
+ * The source inspector is automatically enabled in development mode when
8
+ * devtools.inspector is enabled (default: true).
9
+ *
10
+ * Usage: Hold Shift+Cmd (Mac) or Shift+Ctrl (Windows/Linux) and hover over elements.
11
+ */
12
+
13
+ type ModifierKey = 'Alt' | 'Control' | 'Meta' | 'Shift'
14
+ type KeyboardKey = ModifierKey | (string & {})
15
+
16
+ export type SourceInspectorProps = {
17
+ /**
18
+ * The hotkey combination to activate the inspector.
19
+ * Hold these keys and hover over elements to see their source location.
20
+ * @default ['Shift', 'Meta'] on Mac, ['Shift', 'Control'] on Windows/Linux
21
+ * @deprecated - hotkey is now configured in the devtools script
22
+ */
23
+ hotkey?: KeyboardKey[]
24
+ /**
25
+ * Whether the source inspector is enabled
26
+ * @default true in development
27
+ * @deprecated - enabled status is controlled via devtools.inspector config
28
+ */
29
+ enabled?: boolean
30
+ }
31
+
32
+ /**
33
+ * @deprecated - Source inspector functionality is now automatically injected.
34
+ * This component is kept for backwards compatibility and renders nothing.
35
+ * Remove <SourceInspector /> from your layout for cleaner code.
36
+ */
37
+ export function SourceInspector(_props: SourceInspectorProps = {}): ReactNode {
38
+ return null
39
+ }
package/src/views/Try.tsx CHANGED
@@ -1,22 +1,47 @@
1
1
  import React from 'react'
2
2
 
3
+ /**
4
+ * Route context information passed to error boundaries.
5
+ * Provides details about where the error occurred.
6
+ */
7
+ export type ErrorRouteInfo = {
8
+ /** The current pathname (e.g., "/users/123") */
9
+ pathname?: string
10
+ /** The route name/key (e.g., "users/[id]") */
11
+ routeName?: string
12
+ /** Route parameters extracted from the path */
13
+ params?: Record<string, string | string[]>
14
+ /** The error type classification */
15
+ errorType?: 'render' | 'loader' | 'hydration'
16
+ /** Component stack trace from React */
17
+ componentStack?: string
18
+ }
19
+
3
20
  /** Props passed to a page's `ErrorBoundary` export. */
4
21
  export type ErrorBoundaryProps = {
5
22
  /** Retry rendering the component by clearing the `error` state. */
6
23
  retry: () => Promise<void>
7
24
  /** The error that was thrown. */
8
25
  error: Error
26
+ /** Route information about where the error occurred. */
27
+ route?: ErrorRouteInfo
28
+ }
29
+
30
+ type TryProps = {
31
+ catch: React.ComponentType<ErrorBoundaryProps>
32
+ children: React.ReactNode
33
+ /** Optional route information to pass to the error boundary */
34
+ routeInfo?: ErrorRouteInfo
35
+ }
36
+
37
+ type TryState = {
38
+ error?: Error
39
+ componentStack?: string
9
40
  }
10
41
 
11
42
  // No way to access `getDerivedStateFromError` from a functional component afaict.
12
- export class Try extends React.Component<
13
- {
14
- catch: React.ComponentType<ErrorBoundaryProps>
15
- children: React.ReactNode
16
- },
17
- { error?: Error }
18
- > {
19
- state = { error: undefined }
43
+ export class Try extends React.Component<TryProps, TryState> {
44
+ state: TryState = { error: undefined, componentStack: undefined }
20
45
 
21
46
  static getDerivedStateFromError(error: Error) {
22
47
  // Force hide the splash screen if an error occurs.
@@ -25,20 +50,64 @@ export class Try extends React.Component<
25
50
  return { error }
26
51
  }
27
52
 
53
+ componentDidCatch(error: Error, errorInfo: React.ErrorInfo) {
54
+ // Store component stack for debugging
55
+ this.setState({ componentStack: errorInfo.componentStack || undefined })
56
+
57
+ // Log error in development
58
+ if (process.env.NODE_ENV === 'development') {
59
+ const routeInfo = this.props.routeInfo
60
+ console.error(
61
+ `[One] Error in route${routeInfo?.routeName ? ` "${routeInfo.routeName}"` : ''}:`,
62
+ error,
63
+ '\nComponent Stack:',
64
+ errorInfo.componentStack
65
+ )
66
+ }
67
+
68
+ // Dispatch error event for devtools integration
69
+ if (typeof window !== 'undefined') {
70
+ window.dispatchEvent(
71
+ new CustomEvent('one-error', {
72
+ detail: {
73
+ error: {
74
+ message: error.message,
75
+ stack: error.stack,
76
+ name: error.name,
77
+ },
78
+ route: this.props.routeInfo || {},
79
+ componentStack: errorInfo.componentStack,
80
+ timestamp: Date.now(),
81
+ type: 'render',
82
+ },
83
+ })
84
+ )
85
+ }
86
+ }
87
+
28
88
  retry = () => {
29
89
  return new Promise<void>((resolve) => {
30
- this.setState({ error: undefined }, () => {
90
+ this.setState({ error: undefined, componentStack: undefined }, () => {
31
91
  resolve()
32
92
  })
33
93
  })
34
94
  }
35
95
 
36
96
  render() {
37
- const { error } = this.state
38
- const { catch: ErrorBoundary, children } = this.props
97
+ const { error, componentStack } = this.state
98
+ const { catch: ErrorBoundary, children, routeInfo } = this.props
99
+
39
100
  if (!error) {
40
101
  return children
41
102
  }
42
- return <ErrorBoundary error={error} retry={this.retry} />
103
+
104
+ // Combine route info with component stack
105
+ const enhancedRouteInfo: ErrorRouteInfo = {
106
+ ...routeInfo,
107
+ errorType: 'render',
108
+ componentStack,
109
+ }
110
+
111
+ return <ErrorBoundary error={error} retry={this.retry} route={enhancedRouteInfo} />
43
112
  }
44
113
  }