one 1.2.57 → 1.2.58
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.
- package/dist/cjs/cli/buildPage.cjs +1 -1
- package/dist/cjs/cli/buildPage.js +1 -1
- package/dist/cjs/cli/buildPage.native.js +1 -1
- package/dist/cjs/cli/buildPage.native.js.map +1 -1
- package/dist/cjs/cli/dev.cjs +4 -4
- package/dist/cjs/cli/dev.js +4 -4
- package/dist/cjs/cli/dev.js.map +1 -1
- package/dist/cjs/cli/dev.native.js +4 -4
- package/dist/cjs/cli/dev.native.js.map +1 -1
- package/dist/cjs/createApp.cjs +2 -1
- package/dist/cjs/createApp.js +2 -2
- package/dist/cjs/createApp.js.map +1 -1
- package/dist/cjs/createHandleRequest.test.js +3 -1
- package/dist/cjs/createHandleRequest.test.js.map +1 -1
- package/dist/cjs/createHandleRequest.test.native.js.map +1 -1
- package/dist/cjs/devtools/registry.cjs +30 -0
- package/dist/cjs/devtools/registry.js +25 -0
- package/dist/cjs/devtools/registry.js.map +6 -0
- package/dist/cjs/devtools/registry.native.js +33 -0
- package/dist/cjs/devtools/registry.native.js.map +1 -0
- package/dist/cjs/fork/createMemoryHistory.cjs +20 -9
- package/dist/cjs/fork/createMemoryHistory.js +22 -4
- package/dist/cjs/fork/createMemoryHistory.js.map +1 -1
- package/dist/cjs/fork/createMemoryHistory.native.js +20 -9
- package/dist/cjs/fork/createMemoryHistory.native.js.map +1 -1
- package/dist/cjs/fork/useLinking.cjs +11 -5
- package/dist/cjs/fork/useLinking.js +6 -6
- package/dist/cjs/fork/useLinking.js.map +1 -1
- package/dist/cjs/index.cjs +17 -1
- package/dist/cjs/index.js +12 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/index.native.js +17 -1
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/layouts/withLayoutContext.cjs +34 -15
- package/dist/cjs/layouts/withLayoutContext.js +29 -13
- package/dist/cjs/layouts/withLayoutContext.js.map +1 -1
- package/dist/cjs/layouts/withLayoutContext.native.js +42 -19
- package/dist/cjs/layouts/withLayoutContext.native.js.map +1 -1
- package/dist/cjs/link/Link.cjs +5 -2
- package/dist/cjs/link/Link.js +3 -2
- package/dist/cjs/link/Link.js.map +1 -1
- package/dist/cjs/link/Link.native.js +6 -1
- package/dist/cjs/link/Link.native.js.map +1 -1
- package/dist/cjs/link/useLinkTo.cjs +11 -3
- package/dist/cjs/link/useLinkTo.js +6 -3
- package/dist/cjs/link/useLinkTo.js.map +1 -1
- package/dist/cjs/link/useLinkTo.native.js +11 -3
- package/dist/cjs/link/useLinkTo.native.js.map +1 -1
- package/dist/cjs/router/Route.js.map +1 -1
- package/dist/cjs/router/Route.native.js.map +1 -1
- package/dist/cjs/router/findRouteNode.cjs +70 -0
- package/dist/cjs/router/findRouteNode.js +72 -0
- package/dist/cjs/router/findRouteNode.js.map +6 -0
- package/dist/cjs/router/findRouteNode.native.js +104 -0
- package/dist/cjs/router/findRouteNode.native.js.map +1 -0
- package/dist/cjs/router/router.cjs +160 -11
- package/dist/cjs/router/router.js +142 -7
- package/dist/cjs/router/router.js.map +2 -2
- package/dist/cjs/router/router.native.js +241 -57
- package/dist/cjs/router/router.native.js.map +1 -1
- package/dist/cjs/router/useScreens.cjs +1 -1
- package/dist/cjs/router/useScreens.js +1 -1
- package/dist/cjs/router/useScreens.js.map +1 -1
- package/dist/cjs/router/useScreens.native.js +5 -2
- package/dist/cjs/router/useScreens.native.js.map +1 -1
- package/dist/cjs/server/oneServe.js.map +1 -1
- package/dist/cjs/server/oneServe.native.js.map +1 -1
- package/dist/cjs/useBlocker.cjs +158 -0
- package/dist/cjs/useBlocker.js +145 -0
- package/dist/cjs/useBlocker.js.map +6 -0
- package/dist/cjs/useBlocker.native.js +89 -0
- package/dist/cjs/useBlocker.native.js.map +1 -0
- package/dist/cjs/useLoader.cjs +69 -3
- package/dist/cjs/useLoader.js +57 -4
- package/dist/cjs/useLoader.js.map +2 -2
- package/dist/cjs/useLoader.native.js +90 -6
- package/dist/cjs/useLoader.native.js.map +1 -1
- package/dist/cjs/useScrollGroup.cjs +37 -0
- package/dist/cjs/useScrollGroup.js +30 -0
- package/dist/cjs/useScrollGroup.js.map +6 -0
- package/dist/cjs/useScrollGroup.native.js +29 -0
- package/dist/cjs/useScrollGroup.native.js.map +1 -0
- package/dist/cjs/validateParams.cjs +80 -0
- package/dist/cjs/validateParams.js +84 -0
- package/dist/cjs/validateParams.js.map +6 -0
- package/dist/cjs/validateParams.native.js +180 -0
- package/dist/cjs/validateParams.native.js.map +1 -0
- package/dist/cjs/validateSearch.cjs +104 -0
- package/dist/cjs/validateSearch.js +99 -0
- package/dist/cjs/validateSearch.js.map +6 -0
- package/dist/cjs/validateSearch.native.js +202 -0
- package/dist/cjs/validateSearch.native.js.map +1 -0
- package/dist/cjs/views/ErrorBoundary.cjs +293 -10
- package/dist/cjs/views/ErrorBoundary.js +328 -8
- package/dist/cjs/views/ErrorBoundary.js.map +2 -2
- package/dist/cjs/views/ErrorBoundary.native.js +159 -4
- package/dist/cjs/views/ErrorBoundary.native.js.map +1 -1
- package/dist/cjs/views/Navigator.cjs +10 -3
- package/dist/cjs/views/Navigator.js +7 -3
- package/dist/cjs/views/Navigator.js.map +1 -1
- package/dist/cjs/views/Navigator.native.js +12 -3
- package/dist/cjs/views/Navigator.native.js.map +1 -1
- package/dist/cjs/views/Protected.cjs +36 -0
- package/dist/cjs/views/Protected.js +27 -0
- package/dist/cjs/views/Protected.js.map +6 -0
- package/dist/cjs/views/Protected.native.js +44 -0
- package/dist/cjs/views/Protected.native.js.map +1 -0
- package/dist/cjs/views/RootErrorBoundary.cjs +193 -8
- package/dist/cjs/views/RootErrorBoundary.js +213 -8
- package/dist/cjs/views/RootErrorBoundary.js.map +1 -1
- package/dist/cjs/views/RootErrorBoundary.native.js +192 -8
- package/dist/cjs/views/RootErrorBoundary.native.js.map +1 -1
- package/dist/cjs/views/ScrollBehavior.cjs +49 -11
- package/dist/cjs/views/ScrollBehavior.js +47 -11
- package/dist/cjs/views/ScrollBehavior.js.map +1 -1
- package/dist/cjs/views/ScrollBehavior.native.js +68 -10
- package/dist/cjs/views/ScrollBehavior.native.js.map +1 -1
- package/dist/cjs/views/SourceInspector.cjs +28 -0
- package/dist/cjs/views/SourceInspector.js +23 -0
- package/dist/cjs/views/SourceInspector.js.map +6 -0
- package/dist/cjs/views/SourceInspector.native.js +32 -0
- package/dist/cjs/views/SourceInspector.native.js.map +1 -0
- package/dist/cjs/views/Try.cjs +40 -7
- package/dist/cjs/views/Try.js +38 -4
- package/dist/cjs/views/Try.js.map +1 -1
- package/dist/cjs/views/Try.native.js +42 -7
- package/dist/cjs/views/Try.native.js.map +1 -1
- package/dist/cjs/vite/DevHead.cjs +797 -43
- package/dist/cjs/vite/DevHead.js +802 -51
- package/dist/cjs/vite/DevHead.js.map +1 -1
- package/dist/cjs/vite/DevHead.native.js +783 -1
- package/dist/cjs/vite/DevHead.native.js.map +1 -1
- package/dist/cjs/vite/one.cjs +7 -1
- package/dist/cjs/vite/one.js +7 -2
- package/dist/cjs/vite/one.js.map +1 -1
- package/dist/cjs/vite/one.native.js +11 -1
- package/dist/cjs/vite/one.native.js.map +1 -1
- package/dist/cjs/vite/plugins/SSRCSSPlugin.cjs +44 -4
- package/dist/cjs/vite/plugins/SSRCSSPlugin.js +48 -4
- package/dist/cjs/vite/plugins/SSRCSSPlugin.js.map +1 -1
- package/dist/cjs/vite/plugins/SSRCSSPlugin.native.js +62 -5
- package/dist/cjs/vite/plugins/SSRCSSPlugin.native.js.map +1 -1
- package/dist/cjs/vite/plugins/fileSystemRouterPlugin.js +6 -3
- package/dist/cjs/vite/plugins/fileSystemRouterPlugin.js.map +1 -1
- package/dist/cjs/vite/plugins/fileSystemRouterPlugin.native.js.map +1 -1
- package/dist/cjs/vite/plugins/generateFileSystemRouteTypesPlugin.cjs +5 -1
- package/dist/cjs/vite/plugins/generateFileSystemRouteTypesPlugin.js +11 -6
- package/dist/cjs/vite/plugins/generateFileSystemRouteTypesPlugin.js.map +1 -1
- package/dist/cjs/vite/plugins/generateFileSystemRouteTypesPlugin.native.js +1 -0
- package/dist/cjs/vite/plugins/generateFileSystemRouteTypesPlugin.native.js.map +1 -1
- package/dist/cjs/vite/plugins/sourceInspectorPlugin.cjs +155 -0
- package/dist/cjs/vite/plugins/sourceInspectorPlugin.js +148 -0
- package/dist/cjs/vite/plugins/sourceInspectorPlugin.js.map +6 -0
- package/dist/cjs/vite/plugins/sourceInspectorPlugin.native.js +231 -0
- package/dist/cjs/vite/plugins/sourceInspectorPlugin.native.js.map +1 -0
- package/dist/cjs/vite/plugins/virtualEntryPlugin.cjs +25 -6
- package/dist/cjs/vite/plugins/virtualEntryPlugin.js +16 -6
- package/dist/cjs/vite/plugins/virtualEntryPlugin.js.map +1 -1
- package/dist/cjs/vite/plugins/virtualEntryPlugin.native.js +26 -7
- package/dist/cjs/vite/plugins/virtualEntryPlugin.native.js.map +1 -1
- package/dist/esm/cli/buildPage.js +1 -1
- package/dist/esm/cli/buildPage.mjs +1 -1
- package/dist/esm/cli/buildPage.mjs.map +1 -1
- package/dist/esm/cli/buildPage.native.js +1 -1
- package/dist/esm/cli/buildPage.native.js.map +1 -1
- package/dist/esm/cli/dev.js +4 -4
- package/dist/esm/cli/dev.js.map +1 -1
- package/dist/esm/cli/dev.mjs +4 -4
- package/dist/esm/cli/dev.mjs.map +1 -1
- package/dist/esm/cli/dev.native.js +4 -4
- package/dist/esm/cli/dev.native.js.map +1 -1
- package/dist/esm/createApp.js +2 -2
- package/dist/esm/createApp.js.map +1 -1
- package/dist/esm/createApp.mjs +2 -1
- package/dist/esm/createApp.mjs.map +1 -1
- package/dist/esm/createHandleRequest.test.js +3 -1
- package/dist/esm/createHandleRequest.test.js.map +1 -1
- package/dist/esm/createHandleRequest.test.mjs.map +1 -1
- package/dist/esm/createHandleRequest.test.native.js.map +1 -1
- package/dist/esm/devtools/registry.js +9 -0
- package/dist/esm/devtools/registry.js.map +6 -0
- package/dist/esm/devtools/registry.mjs +6 -0
- package/dist/esm/devtools/registry.mjs.map +1 -0
- package/dist/esm/devtools/registry.native.js +6 -0
- package/dist/esm/devtools/registry.native.js.map +1 -0
- package/dist/esm/fork/createMemoryHistory.js +22 -4
- package/dist/esm/fork/createMemoryHistory.js.map +1 -1
- package/dist/esm/fork/createMemoryHistory.mjs +20 -9
- package/dist/esm/fork/createMemoryHistory.mjs.map +1 -1
- package/dist/esm/fork/createMemoryHistory.native.js +20 -9
- package/dist/esm/fork/createMemoryHistory.native.js.map +1 -1
- package/dist/esm/fork/useLinking.js +6 -5
- package/dist/esm/fork/useLinking.js.map +1 -1
- package/dist/esm/fork/useLinking.mjs +11 -5
- package/dist/esm/fork/useLinking.mjs.map +1 -1
- package/dist/esm/index.js +30 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.mjs +8 -2
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/index.native.js +8 -2
- package/dist/esm/index.native.js.map +1 -1
- package/dist/esm/layouts/withLayoutContext.js +30 -12
- package/dist/esm/layouts/withLayoutContext.js.map +1 -1
- package/dist/esm/layouts/withLayoutContext.mjs +34 -15
- package/dist/esm/layouts/withLayoutContext.mjs.map +1 -1
- package/dist/esm/layouts/withLayoutContext.native.js +42 -19
- package/dist/esm/layouts/withLayoutContext.native.js.map +1 -1
- package/dist/esm/link/Link.js +3 -2
- package/dist/esm/link/Link.js.map +1 -1
- package/dist/esm/link/Link.mjs +5 -2
- package/dist/esm/link/Link.mjs.map +1 -1
- package/dist/esm/link/Link.native.js +6 -1
- package/dist/esm/link/Link.native.js.map +1 -1
- package/dist/esm/link/useLinkTo.js +6 -3
- package/dist/esm/link/useLinkTo.js.map +1 -1
- package/dist/esm/link/useLinkTo.mjs +11 -3
- package/dist/esm/link/useLinkTo.mjs.map +1 -1
- package/dist/esm/link/useLinkTo.native.js +11 -3
- package/dist/esm/link/useLinkTo.native.js.map +1 -1
- package/dist/esm/router/Route.js.map +1 -1
- package/dist/esm/router/Route.mjs.map +1 -1
- package/dist/esm/router/Route.native.js.map +1 -1
- package/dist/esm/router/findRouteNode.js +56 -0
- package/dist/esm/router/findRouteNode.js.map +6 -0
- package/dist/esm/router/findRouteNode.mjs +44 -0
- package/dist/esm/router/findRouteNode.mjs.map +1 -0
- package/dist/esm/router/findRouteNode.native.js +75 -0
- package/dist/esm/router/findRouteNode.native.js.map +1 -0
- package/dist/esm/router/router.js +154 -6
- package/dist/esm/router/router.js.map +1 -1
- package/dist/esm/router/router.mjs +151 -10
- package/dist/esm/router/router.mjs.map +1 -1
- package/dist/esm/router/router.native.js +232 -56
- package/dist/esm/router/router.native.js.map +1 -1
- package/dist/esm/router/useScreens.js +1 -1
- package/dist/esm/router/useScreens.js.map +1 -1
- package/dist/esm/router/useScreens.mjs +1 -1
- package/dist/esm/router/useScreens.mjs.map +1 -1
- package/dist/esm/router/useScreens.native.js +5 -2
- package/dist/esm/router/useScreens.native.js.map +1 -1
- package/dist/esm/server/oneServe.js.map +1 -1
- package/dist/esm/server/oneServe.mjs.map +1 -1
- package/dist/esm/server/oneServe.native.js.map +1 -1
- package/dist/esm/useBlocker.js +122 -0
- package/dist/esm/useBlocker.js.map +6 -0
- package/dist/esm/useBlocker.mjs +123 -0
- package/dist/esm/useBlocker.mjs.map +1 -0
- package/dist/esm/useBlocker.native.js +51 -0
- package/dist/esm/useBlocker.native.js.map +1 -0
- package/dist/esm/useLoader.js +57 -3
- package/dist/esm/useLoader.js.map +2 -2
- package/dist/esm/useLoader.mjs +69 -4
- package/dist/esm/useLoader.mjs.map +1 -1
- package/dist/esm/useLoader.native.js +90 -7
- package/dist/esm/useLoader.native.js.map +1 -1
- package/dist/esm/useScrollGroup.js +16 -0
- package/dist/esm/useScrollGroup.js.map +6 -0
- package/dist/esm/useScrollGroup.mjs +14 -0
- package/dist/esm/useScrollGroup.mjs.map +1 -0
- package/dist/esm/useScrollGroup.native.js +3 -0
- package/dist/esm/useScrollGroup.native.js.map +1 -0
- package/dist/esm/validateParams.js +68 -0
- package/dist/esm/validateParams.js.map +6 -0
- package/dist/esm/validateParams.mjs +54 -0
- package/dist/esm/validateParams.mjs.map +1 -0
- package/dist/esm/validateParams.native.js +151 -0
- package/dist/esm/validateParams.native.js.map +1 -0
- package/dist/esm/validateSearch.js +83 -0
- package/dist/esm/validateSearch.js.map +6 -0
- package/dist/esm/validateSearch.mjs +77 -0
- package/dist/esm/validateSearch.mjs.map +1 -0
- package/dist/esm/validateSearch.native.js +172 -0
- package/dist/esm/validateSearch.native.js.map +1 -0
- package/dist/esm/views/ErrorBoundary.js +325 -7
- package/dist/esm/views/ErrorBoundary.js.map +2 -2
- package/dist/esm/views/ErrorBoundary.mjs +289 -6
- package/dist/esm/views/ErrorBoundary.mjs.map +1 -1
- package/dist/esm/views/ErrorBoundary.native.js +159 -4
- package/dist/esm/views/ErrorBoundary.native.js.map +1 -1
- package/dist/esm/views/Navigator.js +7 -2
- package/dist/esm/views/Navigator.js.map +1 -1
- package/dist/esm/views/Navigator.mjs +10 -3
- package/dist/esm/views/Navigator.mjs.map +1 -1
- package/dist/esm/views/Navigator.native.js +12 -3
- package/dist/esm/views/Navigator.native.js.map +1 -1
- package/dist/esm/views/Protected.js +14 -0
- package/dist/esm/views/Protected.js.map +6 -0
- package/dist/esm/views/Protected.mjs +11 -0
- package/dist/esm/views/Protected.mjs.map +1 -0
- package/dist/esm/views/Protected.native.js +16 -0
- package/dist/esm/views/Protected.native.js.map +1 -0
- package/dist/esm/views/RootErrorBoundary.js +214 -7
- package/dist/esm/views/RootErrorBoundary.js.map +1 -1
- package/dist/esm/views/RootErrorBoundary.mjs +192 -7
- package/dist/esm/views/RootErrorBoundary.mjs.map +1 -1
- package/dist/esm/views/RootErrorBoundary.native.js +191 -7
- package/dist/esm/views/RootErrorBoundary.native.js.map +1 -1
- package/dist/esm/views/ScrollBehavior.js +47 -11
- package/dist/esm/views/ScrollBehavior.js.map +1 -1
- package/dist/esm/views/ScrollBehavior.mjs +48 -11
- package/dist/esm/views/ScrollBehavior.mjs.map +1 -1
- package/dist/esm/views/ScrollBehavior.native.js +67 -10
- package/dist/esm/views/ScrollBehavior.native.js.map +1 -1
- package/dist/esm/views/SourceInspector.js +7 -0
- package/dist/esm/views/SourceInspector.js.map +6 -0
- package/dist/esm/views/SourceInspector.mjs +5 -0
- package/dist/esm/views/SourceInspector.mjs.map +1 -0
- package/dist/esm/views/SourceInspector.native.js +6 -0
- package/dist/esm/views/SourceInspector.native.js.map +1 -0
- package/dist/esm/views/Try.js +38 -4
- package/dist/esm/views/Try.js.map +1 -1
- package/dist/esm/views/Try.mjs +40 -7
- package/dist/esm/views/Try.mjs.map +1 -1
- package/dist/esm/views/Try.native.js +42 -7
- package/dist/esm/views/Try.native.js.map +1 -1
- package/dist/esm/vite/DevHead.js +802 -51
- package/dist/esm/vite/DevHead.js.map +1 -1
- package/dist/esm/vite/DevHead.mjs +797 -43
- package/dist/esm/vite/DevHead.mjs.map +1 -1
- package/dist/esm/vite/DevHead.native.js +782 -0
- package/dist/esm/vite/DevHead.native.js.map +1 -1
- package/dist/esm/vite/one.js +7 -1
- package/dist/esm/vite/one.js.map +1 -1
- package/dist/esm/vite/one.mjs +7 -1
- package/dist/esm/vite/one.mjs.map +1 -1
- package/dist/esm/vite/one.native.js +11 -1
- package/dist/esm/vite/one.native.js.map +1 -1
- package/dist/esm/vite/plugins/SSRCSSPlugin.js +48 -4
- package/dist/esm/vite/plugins/SSRCSSPlugin.js.map +1 -1
- package/dist/esm/vite/plugins/SSRCSSPlugin.mjs +44 -4
- package/dist/esm/vite/plugins/SSRCSSPlugin.mjs.map +1 -1
- package/dist/esm/vite/plugins/SSRCSSPlugin.native.js +61 -4
- package/dist/esm/vite/plugins/SSRCSSPlugin.native.js.map +1 -1
- package/dist/esm/vite/plugins/fileSystemRouterPlugin.js +6 -3
- package/dist/esm/vite/plugins/fileSystemRouterPlugin.js.map +1 -1
- package/dist/esm/vite/plugins/fileSystemRouterPlugin.mjs.map +1 -1
- package/dist/esm/vite/plugins/fileSystemRouterPlugin.native.js.map +1 -1
- package/dist/esm/vite/plugins/generateFileSystemRouteTypesPlugin.js +11 -6
- package/dist/esm/vite/plugins/generateFileSystemRouteTypesPlugin.js.map +1 -1
- package/dist/esm/vite/plugins/generateFileSystemRouteTypesPlugin.mjs +5 -1
- package/dist/esm/vite/plugins/generateFileSystemRouteTypesPlugin.mjs.map +1 -1
- package/dist/esm/vite/plugins/generateFileSystemRouteTypesPlugin.native.js +1 -0
- package/dist/esm/vite/plugins/generateFileSystemRouteTypesPlugin.native.js.map +1 -1
- package/dist/esm/vite/plugins/sourceInspectorPlugin.js +126 -0
- package/dist/esm/vite/plugins/sourceInspectorPlugin.js.map +6 -0
- package/dist/esm/vite/plugins/sourceInspectorPlugin.mjs +121 -0
- package/dist/esm/vite/plugins/sourceInspectorPlugin.mjs.map +1 -0
- package/dist/esm/vite/plugins/sourceInspectorPlugin.native.js +194 -0
- package/dist/esm/vite/plugins/sourceInspectorPlugin.native.js.map +1 -0
- package/dist/esm/vite/plugins/virtualEntryPlugin.js +16 -6
- package/dist/esm/vite/plugins/virtualEntryPlugin.js.map +1 -1
- package/dist/esm/vite/plugins/virtualEntryPlugin.mjs +25 -6
- package/dist/esm/vite/plugins/virtualEntryPlugin.mjs.map +1 -1
- package/dist/esm/vite/plugins/virtualEntryPlugin.native.js +26 -7
- package/dist/esm/vite/plugins/virtualEntryPlugin.native.js.map +1 -1
- package/package.json +11 -9
- package/src/cli/buildPage.ts +1 -1
- package/src/cli/dev.ts +4 -4
- package/src/createApp.tsx +11 -1
- package/src/createHandleRequest.test.ts +3 -1
- package/src/devtools/registry.ts +21 -0
- package/src/fork/createMemoryHistory.tsx +43 -11
- package/src/fork/useLinking.ts +14 -4
- package/src/index.ts +34 -1
- package/src/interfaces/router.ts +48 -0
- package/src/layouts/withLayoutContext.tsx +48 -8
- package/src/link/Link.tsx +7 -2
- package/src/link/useLinkTo.tsx +7 -3
- package/src/router/Route.tsx +32 -3
- package/src/router/findRouteNode.ts +127 -0
- package/src/router/router.ts +286 -2
- package/src/router/useScreens.tsx +9 -3
- package/src/useBlocker.native.ts +153 -0
- package/src/useBlocker.ts +340 -0
- package/src/useLoader.ts +139 -1
- package/src/useScrollGroup.native.ts +7 -0
- package/src/useScrollGroup.ts +44 -0
- package/src/validateParams.ts +196 -0
- package/src/validateSearch.ts +241 -0
- package/src/views/ErrorBoundary.tsx +154 -156
- package/src/views/ErrorBoundary.web.tsx +321 -0
- package/src/views/Navigator.tsx +14 -2
- package/src/views/Protected.tsx +62 -0
- package/src/views/RootErrorBoundary.tsx +214 -17
- package/src/views/ScrollBehavior.tsx +82 -3
- package/src/views/SourceInspector.tsx +39 -0
- package/src/views/Try.tsx +81 -12
- package/src/vite/DevHead.tsx +819 -54
- package/src/vite/one.ts +13 -0
- package/src/vite/plugins/SSRCSSPlugin.ts +104 -0
- package/src/vite/plugins/fileSystemRouterPlugin.tsx +11 -8
- package/src/vite/plugins/generateFileSystemRouteTypesPlugin.tsx +4 -0
- package/src/vite/plugins/sourceInspectorPlugin.ts +246 -0
- package/src/vite/plugins/virtualEntryPlugin.ts +35 -10
- package/src/vite/types.ts +28 -0
- package/types/Route.d.ts.map +1 -0
- package/types/cleanUrl.d.ts.map +1 -0
- package/types/cli/run.d.ts.map +1 -0
- package/types/createApp.d.ts +5 -0
- package/types/createApp.d.ts.map +1 -1
- package/types/createRoute.d.ts.map +1 -0
- package/types/devtools/registry.d.ts +15 -0
- package/types/devtools/registry.d.ts.map +1 -0
- package/types/fork/NavigationContainer.native.d.ts.map +1 -0
- package/types/fork/createMemoryHistory.d.ts +8 -3
- package/types/fork/createMemoryHistory.d.ts.map +1 -1
- package/types/fork/useLinking.d.ts.map +1 -1
- package/types/getLinkingConfig.d.ts.map +1 -0
- package/types/getRoutes.d.ts.map +1 -0
- package/types/imperative-api.d.ts.map +1 -0
- package/types/index.d.ts +8 -1
- package/types/index.d.ts.map +1 -1
- package/types/interfaces/router.d.ts +47 -0
- package/types/interfaces/router.d.ts.map +1 -1
- package/types/layouts/withLayoutContext.d.ts +2 -1
- package/types/layouts/withLayoutContext.d.ts.map +1 -1
- package/types/link/Link.d.ts.map +1 -1
- package/types/link/useLinkTo.d.ts +1 -0
- package/types/link/useLinkTo.d.ts.map +1 -1
- package/types/matchers.d.ts.map +1 -0
- package/types/platform.d.ts.map +1 -0
- package/types/router/Route.d.ts +32 -3
- package/types/router/Route.d.ts.map +1 -1
- package/types/router/findRouteNode.d.ts +31 -0
- package/types/router/findRouteNode.d.ts.map +1 -0
- package/types/router/router.d.ts +35 -0
- package/types/router/router.d.ts.map +1 -1
- package/types/router/useScreens.d.ts +2 -0
- package/types/router/useScreens.d.ts.map +1 -1
- package/types/server/oneServe.d.ts.map +1 -1
- package/types/sortRoutes.d.ts.map +1 -0
- package/types/useBlocker.d.ts +72 -0
- package/types/useBlocker.d.ts.map +1 -0
- package/types/useBlocker.native.d.ts +60 -0
- package/types/useBlocker.native.d.ts.map +1 -0
- package/types/useLoader.d.ts +10 -0
- package/types/useLoader.d.ts.map +1 -1
- package/types/useNavigation.d.ts.map +1 -0
- package/types/useScreens.d.ts.map +1 -0
- package/types/useScrollGroup.d.ts +27 -0
- package/types/useScrollGroup.d.ts.map +1 -0
- package/types/useScrollGroup.native.d.ts +6 -0
- package/types/useScrollGroup.native.d.ts.map +1 -0
- package/types/useSearch.d.ts.map +1 -0
- package/types/useViteRoutes.d.ts.map +1 -0
- package/types/validateParams.d.ts +85 -0
- package/types/validateParams.d.ts.map +1 -0
- package/types/validateSearch.d.ts +107 -0
- package/types/validateSearch.d.ts.map +1 -0
- package/types/views/ErrorBoundary.d.ts +11 -1
- package/types/views/ErrorBoundary.d.ts.map +1 -1
- package/types/views/ErrorBoundary.web.d.ts +13 -0
- package/types/views/ErrorBoundary.web.d.ts.map +1 -0
- package/types/views/Navigator.d.ts.map +1 -1
- package/types/views/Protected.d.ts +39 -0
- package/types/views/Protected.d.ts.map +1 -0
- package/types/views/RootErrorBoundary.d.ts +14 -8
- package/types/views/RootErrorBoundary.d.ts.map +1 -1
- package/types/views/ScrollBehavior.d.ts +8 -0
- package/types/views/ScrollBehavior.d.ts.map +1 -1
- package/types/views/ScrollRestoration.d.ts.map +1 -0
- package/types/views/SourceInspector.d.ts +35 -0
- package/types/views/SourceInspector.d.ts.map +1 -0
- package/types/views/Try.d.ts +29 -6
- package/types/views/Try.d.ts.map +1 -1
- package/types/vite/DevHead.d.ts.map +1 -1
- package/types/vite/build.d.ts.map +1 -0
- package/types/vite/headers.d.ts.map +1 -0
- package/types/vite/headers.native.d.ts.map +1 -0
- package/types/vite/one.d.ts.map +1 -1
- package/types/vite/plugins/SSRCSSPlugin.d.ts.map +1 -1
- package/types/vite/plugins/fileSystemRouterPlugin.d.ts.map +1 -1
- package/types/vite/plugins/generateFileSystemRouteTypesPlugin.d.ts.map +1 -1
- package/types/vite/plugins/seoPreviewPlugin.d.ts.map +1 -0
- package/types/vite/plugins/sourceInspectorPlugin.d.ts +3 -0
- package/types/vite/plugins/sourceInspectorPlugin.d.ts.map +1 -0
- package/types/vite/plugins/virtualEntryPlugin.d.ts.map +1 -1
- package/types/vite/resolveAPIRequest.d.ts.map +1 -0
- package/types/vite/server.d.ts.map +1 -0
- package/types/vite/types.d.ts +24 -0
- package/types/vite/types.d.ts.map +1 -1
|
@@ -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
|
-
|
|
5
|
-
|
|
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
|
-
|
|
9
|
-
return { hasError: true }
|
|
20
|
+
static getDerivedStateFromError(error: Error) {
|
|
21
|
+
return { hasError: true, error }
|
|
10
22
|
}
|
|
11
23
|
|
|
12
|
-
componentDidCatch(error, info) {
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
`
|
|
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
|
-
|
|
26
|
-
|
|
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
|
|
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[
|
|
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
|
|
91
|
-
|
|
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
|
-
|
|
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
|
}
|