one 1.1.320 → 1.1.322
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cjs/Root.js +182 -0
- package/dist/cjs/Route.js +45 -0
- package/dist/cjs/cleanUrl.js +41 -0
- package/dist/cjs/cli/label-process.js +25 -0
- package/dist/cjs/cli/main.js +46 -0
- package/dist/cjs/cli/patch.js +34 -0
- package/dist/cjs/cli/prebuild.js +34 -0
- package/dist/cjs/cli/run.js +52 -0
- package/dist/cjs/cli/runAndroid.js +34 -0
- package/dist/cjs/cli/runIos.js +34 -0
- package/dist/cjs/cli.js +220 -0
- package/dist/cjs/clientLoaderResolver.js +32 -0
- package/dist/cjs/config.js +27 -0
- package/dist/cjs/constants.js +28 -0
- package/dist/cjs/createApp.js +46 -0
- package/dist/cjs/createHandleRequest.js +138 -0
- package/dist/cjs/createRoute.js +37 -0
- package/dist/cjs/fallbackViews/Sitemap.js +82 -0
- package/dist/cjs/fallbackViews/Unmatched.js +58 -0
- package/dist/cjs/fork/NavigationContainer.js +85 -0
- package/dist/cjs/fork/createMemoryHistory.js +100 -0
- package/dist/cjs/fork/extractPathFromURL.js +62 -0
- package/dist/cjs/fork/findFocusedRoute.js +26 -0
- package/dist/cjs/fork/getPathFromState.js +265 -0
- package/dist/cjs/fork/getStateFromPath.js +381 -0
- package/dist/cjs/fork/useLinking.js +182 -0
- package/dist/cjs/fork/validatePathConfig.js +46 -0
- package/dist/cjs/getLinkingConfig.js +59 -0
- package/dist/cjs/getReactNavigationConfig.js +69 -0
- package/dist/cjs/getRoutes.js +294 -0
- package/dist/cjs/getURL.js +24 -0
- package/dist/cjs/head/Head.js +23 -0
- package/dist/cjs/head/HeadModule.js +22 -0
- package/dist/cjs/head/index.js +15 -0
- package/dist/cjs/head/types.js +14 -0
- package/dist/cjs/head/url.js +52 -0
- package/dist/cjs/hooks.js +99 -0
- package/dist/cjs/imperative-api.js +45 -0
- package/dist/cjs/import-mode/index.js +21 -0
- package/dist/cjs/import-mode/index.web.js +21 -0
- package/dist/cjs/index.js +65 -0
- package/dist/cjs/interfaces/router.js +23 -0
- package/dist/cjs/layouts/Drawer.js +24 -0
- package/dist/cjs/layouts/Stack.js +24 -0
- package/dist/cjs/layouts/Tabs.js +52 -0
- package/dist/cjs/layouts/withLayoutContext.js +77 -0
- package/dist/cjs/link/Link.js +98 -0
- package/dist/cjs/link/Redirect.js +31 -0
- package/dist/cjs/link/href.js +50 -0
- package/dist/cjs/link/linking.js +82 -0
- package/dist/cjs/link/path.js +65 -0
- package/dist/cjs/link/useLinkTo.js +42 -0
- package/dist/cjs/link/useLoadedNavigation.js +50 -0
- package/dist/cjs/matchers.js +68 -0
- package/dist/cjs/platform.js +21 -0
- package/dist/cjs/polyfills-mobile.js +26 -0
- package/dist/cjs/polyfills-server.js +23 -0
- package/dist/cjs/render.js +44 -0
- package/dist/cjs/router/RouterStore.js +14 -0
- package/dist/cjs/router/getNormalizedStatePath.js +50 -0
- package/dist/cjs/router/lastAction.js +25 -0
- package/dist/cjs/router/router.js +345 -0
- package/dist/cjs/router/serverLocationContext.js +22 -0
- package/dist/cjs/router/useInitializeOneRouter.js +43 -0
- package/dist/cjs/serve.js +184 -0
- package/dist/cjs/server/createRoutesManifest.js +40 -0
- package/dist/cjs/server/getServerManifest.js +109 -0
- package/dist/cjs/server-render.js +42 -0
- package/dist/cjs/sortRoutes.js +64 -0
- package/dist/cjs/typed-routes/generateRouteTypes.js +33 -0
- package/dist/cjs/typed-routes/getTypedRoutesDeclarationFile.js +83 -0
- package/dist/cjs/types.js +14 -0
- package/dist/cjs/useFocusEffect.js +79 -0
- package/dist/cjs/useLoader.js +97 -0
- package/dist/cjs/useNavigation.js +60 -0
- package/dist/cjs/useScreens.js +176 -0
- package/dist/cjs/useViteRoutes.js +77 -0
- package/dist/cjs/utils/assertIsReady.js +26 -0
- package/dist/cjs/utils/dynamicImport.js +24 -0
- package/dist/cjs/utils/existsAsync.js +28 -0
- package/dist/cjs/utils/getPageExport.js +38 -0
- package/dist/cjs/utils/globDir.js +37 -0
- package/dist/cjs/utils/hashString.js +32 -0
- package/dist/cjs/utils/isResponse.js +23 -0
- package/dist/cjs/utils/isStatus.js +23 -0
- package/dist/cjs/utils/promiseWithResolvers.js +26 -0
- package/dist/cjs/utils/rand.js +21 -0
- package/dist/cjs/utils/redirect.js +28 -0
- package/dist/cjs/utils/removeSearch.js +23 -0
- package/dist/cjs/utils/removeUndefined.js +26 -0
- package/dist/cjs/utils/url.js +31 -0
- package/dist/cjs/utils/weakKey.js +24 -0
- package/dist/cjs/utils/weakMemo.js +30 -0
- package/dist/cjs/views/EmptyRoute.js +25 -0
- package/dist/cjs/views/ErrorBoundary.js +33 -0
- package/dist/cjs/views/LoadProgressBar.js +83 -0
- package/dist/cjs/views/Navigator.js +101 -0
- package/dist/cjs/views/PreloadLinks.js +42 -0
- package/dist/cjs/views/RootErrorBoundary.js +47 -0
- package/dist/cjs/views/Screen.js +29 -0
- package/dist/cjs/views/ScrollRestoration.js +70 -0
- package/dist/cjs/views/Try.js +44 -0
- package/dist/cjs/vite/build.js +377 -0
- package/dist/cjs/vite/clientTreeShakePlugin.js +76 -0
- package/dist/cjs/vite/constants.js +22 -0
- package/dist/cjs/vite/createFileSystemRouter.cjs +2 -1
- package/dist/cjs/vite/createFileSystemRouter.js +244 -0
- package/dist/cjs/vite/createFileSystemRouter.js.map +6 -0
- package/dist/cjs/vite/createFileSystemRouter.native.js +2 -1
- package/dist/cjs/vite/createFileSystemRouter.native.js.map +2 -2
- package/dist/cjs/vite/customNodeExternals.js +52 -0
- package/dist/cjs/vite/ensureTsConfig.js +66 -0
- package/dist/cjs/vite/findDepsToOptimize.js +66 -0
- package/dist/cjs/vite/fixDependenciesPlugin.js +43 -0
- package/dist/cjs/vite/generateTypesForRoutes.js +36 -0
- package/dist/cjs/vite/getManifest.js +27 -0
- package/dist/cjs/vite/headers.js +39 -0
- package/dist/cjs/vite/makePluginWebOnly.js +27 -0
- package/dist/cjs/vite/one.js +290 -0
- package/dist/cjs/vite/removeReactNativeWebAnimatedPlugin.js +50 -0
- package/dist/cjs/vite/replaceLoader.js +34 -0
- package/dist/cjs/vite/resolveAPIRequest.js +71 -0
- package/dist/cjs/vite/server.js +16 -0
- package/dist/cjs/vite/types.js +14 -0
- package/dist/cjs/vite/virtualEntryPlugin.js +67 -0
- package/dist/cjs/vite/vitePluginSsrCss.js +130 -0
- package/dist/cjs/vite.cjs +2 -0
- package/dist/cjs/vite.js +29 -0
- package/dist/cjs/vite.js.map +6 -0
- package/dist/cjs/vite.native.js +3 -1
- package/dist/cjs/vite.native.js.map +1 -1
- package/dist/cjs/zero/getQueryKey.js +24 -0
- package/dist/cjs/zero/isZeroQuery.js +23 -0
- package/dist/cjs/zero/resolveQuery.js +38 -0
- package/dist/cjs/zero/subscribeToQuery.js +28 -0
- package/dist/cjs/zero/types.js +14 -0
- package/dist/cjs/zero/useQuery.js +47 -0
- package/dist/cjs/zero/useQueryZero.js +38 -0
- package/dist/cjs/zero.js +23 -0
- package/dist/esm/vite/createFileSystemRouter.js +2 -1
- package/dist/esm/vite/createFileSystemRouter.js.map +1 -1
- package/dist/esm/vite/createFileSystemRouter.mjs +2 -1
- package/dist/esm/vite/createFileSystemRouter.mjs.map +1 -1
- package/dist/esm/vite/createFileSystemRouter.native.js +2 -1
- package/dist/esm/vite/createFileSystemRouter.native.js.map +2 -2
- package/dist/esm/vite.js +2 -0
- package/dist/esm/vite.js.map +1 -1
- package/dist/esm/vite.mjs +2 -1
- package/dist/esm/vite.mjs.map +1 -1
- package/dist/esm/vite.native.js +2 -0
- package/dist/esm/vite.native.js.map +2 -2
- package/package.json +8 -8
- package/src/vite/createFileSystemRouter.tsx +1 -1
- package/src/vite.ts +1 -0
- package/types/vite.d.ts +1 -0
- package/types/vite.d.ts.map +1 -1
- package/dist/cjs/createApp.native.cjs +0 -38
- package/dist/cjs/createApp.native.cjs.map +0 -6
- package/dist/cjs/fork/NavigationContainer.native.cjs +0 -103
- package/dist/cjs/fork/NavigationContainer.native.cjs.map +0 -6
- package/dist/cjs/fork/useLinking.native.cjs +0 -126
- package/dist/cjs/fork/useLinking.native.cjs.map +0 -6
- package/dist/cjs/getURL.native.cjs +0 -48
- package/dist/cjs/getURL.native.cjs.map +0 -6
- package/dist/cjs/head/Head.android.cjs +0 -28
- package/dist/cjs/head/Head.android.cjs.map +0 -6
- package/dist/cjs/head/Head.ios.cjs +0 -210
- package/dist/cjs/head/Head.ios.cjs.map +0 -6
- package/dist/cjs/import-mode/index.android.cjs +0 -26
- package/dist/cjs/import-mode/index.android.cjs.map +0 -6
- package/dist/cjs/import-mode/index.ios.cjs +0 -26
- package/dist/cjs/import-mode/index.ios.cjs.map +0 -6
- package/dist/cjs/import-mode/index.native.cjs +0 -26
- package/dist/cjs/import-mode/index.native.cjs.map +0 -6
- package/dist/cjs/render.native.cjs +0 -28
- package/dist/cjs/render.native.cjs.map +0 -6
- package/dist/cjs/views/PreloadLinks.native.cjs +0 -28
- package/dist/cjs/views/PreloadLinks.native.cjs.map +0 -6
- package/dist/cjs/vite/createFileSystemRouter.cjs.map +0 -6
- package/dist/cjs/vite/headers.native.cjs +0 -32
- package/dist/cjs/vite/headers.native.cjs.map +0 -6
- package/dist/cjs/vite.cjs.map +0 -6
- /package/dist/cjs/{Root.cjs.map → Root.js.map} +0 -0
- /package/dist/cjs/{Route.cjs.map → Route.js.map} +0 -0
- /package/dist/cjs/{cleanUrl.cjs.map → cleanUrl.js.map} +0 -0
- /package/dist/cjs/cli/{label-process.cjs.map → label-process.js.map} +0 -0
- /package/dist/cjs/cli/{main.cjs.map → main.js.map} +0 -0
- /package/dist/cjs/cli/{patch.cjs.map → patch.js.map} +0 -0
- /package/dist/cjs/cli/{prebuild.cjs.map → prebuild.js.map} +0 -0
- /package/dist/cjs/cli/{run.cjs.map → run.js.map} +0 -0
- /package/dist/cjs/cli/{runAndroid.cjs.map → runAndroid.js.map} +0 -0
- /package/dist/cjs/cli/{runIos.cjs.map → runIos.js.map} +0 -0
- /package/dist/cjs/{cli.cjs.map → cli.js.map} +0 -0
- /package/dist/cjs/{clientLoaderResolver.cjs.map → clientLoaderResolver.js.map} +0 -0
- /package/dist/cjs/{config.cjs.map → config.js.map} +0 -0
- /package/dist/cjs/{constants.cjs.map → constants.js.map} +0 -0
- /package/dist/cjs/{createApp.cjs.map → createApp.js.map} +0 -0
- /package/dist/cjs/{createHandleRequest.cjs.map → createHandleRequest.js.map} +0 -0
- /package/dist/cjs/{createRoute.cjs.map → createRoute.js.map} +0 -0
- /package/dist/cjs/fallbackViews/{Sitemap.cjs.map → Sitemap.js.map} +0 -0
- /package/dist/cjs/fallbackViews/{Unmatched.cjs.map → Unmatched.js.map} +0 -0
- /package/dist/cjs/fork/{NavigationContainer.cjs.map → NavigationContainer.js.map} +0 -0
- /package/dist/cjs/fork/{createMemoryHistory.cjs.map → createMemoryHistory.js.map} +0 -0
- /package/dist/cjs/fork/{extractPathFromURL.cjs.map → extractPathFromURL.js.map} +0 -0
- /package/dist/cjs/fork/{findFocusedRoute.cjs.map → findFocusedRoute.js.map} +0 -0
- /package/dist/cjs/fork/{getPathFromState.cjs.map → getPathFromState.js.map} +0 -0
- /package/dist/cjs/fork/{getStateFromPath.cjs.map → getStateFromPath.js.map} +0 -0
- /package/dist/cjs/fork/{useLinking.cjs.map → useLinking.js.map} +0 -0
- /package/dist/cjs/fork/{validatePathConfig.cjs.map → validatePathConfig.js.map} +0 -0
- /package/dist/cjs/{getLinkingConfig.cjs.map → getLinkingConfig.js.map} +0 -0
- /package/dist/cjs/{getReactNavigationConfig.cjs.map → getReactNavigationConfig.js.map} +0 -0
- /package/dist/cjs/{getRoutes.cjs.map → getRoutes.js.map} +0 -0
- /package/dist/cjs/{getURL.cjs.map → getURL.js.map} +0 -0
- /package/dist/cjs/head/{Head.cjs.map → Head.js.map} +0 -0
- /package/dist/cjs/head/{HeadModule.cjs.map → HeadModule.js.map} +0 -0
- /package/dist/cjs/head/{index.cjs.map → index.js.map} +0 -0
- /package/dist/cjs/head/{types.cjs.map → types.js.map} +0 -0
- /package/dist/cjs/head/{url.cjs.map → url.js.map} +0 -0
- /package/dist/cjs/{hooks.cjs.map → hooks.js.map} +0 -0
- /package/dist/cjs/{imperative-api.cjs.map → imperative-api.js.map} +0 -0
- /package/dist/cjs/import-mode/{index.cjs.map → index.js.map} +0 -0
- /package/dist/cjs/import-mode/{index.web.cjs.map → index.web.js.map} +0 -0
- /package/dist/cjs/{index.cjs.map → index.js.map} +0 -0
- /package/dist/cjs/interfaces/{router.cjs.map → router.js.map} +0 -0
- /package/dist/cjs/layouts/{Drawer.cjs.map → Drawer.js.map} +0 -0
- /package/dist/cjs/layouts/{Stack.cjs.map → Stack.js.map} +0 -0
- /package/dist/cjs/layouts/{Tabs.cjs.map → Tabs.js.map} +0 -0
- /package/dist/cjs/layouts/{withLayoutContext.cjs.map → withLayoutContext.js.map} +0 -0
- /package/dist/cjs/link/{Link.cjs.map → Link.js.map} +0 -0
- /package/dist/cjs/link/{Redirect.cjs.map → Redirect.js.map} +0 -0
- /package/dist/cjs/link/{href.cjs.map → href.js.map} +0 -0
- /package/dist/cjs/link/{linking.cjs.map → linking.js.map} +0 -0
- /package/dist/cjs/link/{path.cjs.map → path.js.map} +0 -0
- /package/dist/cjs/link/{useLinkTo.cjs.map → useLinkTo.js.map} +0 -0
- /package/dist/cjs/link/{useLoadedNavigation.cjs.map → useLoadedNavigation.js.map} +0 -0
- /package/dist/cjs/{matchers.cjs.map → matchers.js.map} +0 -0
- /package/dist/cjs/{platform.cjs.map → platform.js.map} +0 -0
- /package/dist/cjs/{polyfills-mobile.cjs.map → polyfills-mobile.js.map} +0 -0
- /package/dist/cjs/{polyfills-server.cjs.map → polyfills-server.js.map} +0 -0
- /package/dist/cjs/{render.cjs.map → render.js.map} +0 -0
- /package/dist/cjs/router/{RouterStore.cjs.map → RouterStore.js.map} +0 -0
- /package/dist/cjs/router/{getNormalizedStatePath.cjs.map → getNormalizedStatePath.js.map} +0 -0
- /package/dist/cjs/router/{lastAction.cjs.map → lastAction.js.map} +0 -0
- /package/dist/cjs/router/{router.cjs.map → router.js.map} +0 -0
- /package/dist/cjs/router/{serverLocationContext.cjs.map → serverLocationContext.js.map} +0 -0
- /package/dist/cjs/router/{useInitializeOneRouter.cjs.map → useInitializeOneRouter.js.map} +0 -0
- /package/dist/cjs/{serve.cjs.map → serve.js.map} +0 -0
- /package/dist/cjs/server/{createRoutesManifest.cjs.map → createRoutesManifest.js.map} +0 -0
- /package/dist/cjs/server/{getServerManifest.cjs.map → getServerManifest.js.map} +0 -0
- /package/dist/cjs/{server-render.cjs.map → server-render.js.map} +0 -0
- /package/dist/cjs/{sortRoutes.cjs.map → sortRoutes.js.map} +0 -0
- /package/dist/cjs/typed-routes/{generateRouteTypes.cjs.map → generateRouteTypes.js.map} +0 -0
- /package/dist/cjs/typed-routes/{getTypedRoutesDeclarationFile.cjs.map → getTypedRoutesDeclarationFile.js.map} +0 -0
- /package/dist/cjs/{types.cjs.map → types.js.map} +0 -0
- /package/dist/cjs/{useFocusEffect.cjs.map → useFocusEffect.js.map} +0 -0
- /package/dist/cjs/{useLoader.cjs.map → useLoader.js.map} +0 -0
- /package/dist/cjs/{useNavigation.cjs.map → useNavigation.js.map} +0 -0
- /package/dist/cjs/{useScreens.cjs.map → useScreens.js.map} +0 -0
- /package/dist/cjs/{useViteRoutes.cjs.map → useViteRoutes.js.map} +0 -0
- /package/dist/cjs/utils/{assertIsReady.cjs.map → assertIsReady.js.map} +0 -0
- /package/dist/cjs/utils/{dynamicImport.cjs.map → dynamicImport.js.map} +0 -0
- /package/dist/cjs/utils/{existsAsync.cjs.map → existsAsync.js.map} +0 -0
- /package/dist/cjs/utils/{getPageExport.cjs.map → getPageExport.js.map} +0 -0
- /package/dist/cjs/utils/{globDir.cjs.map → globDir.js.map} +0 -0
- /package/dist/cjs/utils/{hashString.cjs.map → hashString.js.map} +0 -0
- /package/dist/cjs/utils/{isResponse.cjs.map → isResponse.js.map} +0 -0
- /package/dist/cjs/utils/{isStatus.cjs.map → isStatus.js.map} +0 -0
- /package/dist/cjs/utils/{promiseWithResolvers.cjs.map → promiseWithResolvers.js.map} +0 -0
- /package/dist/cjs/utils/{rand.cjs.map → rand.js.map} +0 -0
- /package/dist/cjs/utils/{redirect.cjs.map → redirect.js.map} +0 -0
- /package/dist/cjs/utils/{removeSearch.cjs.map → removeSearch.js.map} +0 -0
- /package/dist/cjs/utils/{removeUndefined.cjs.map → removeUndefined.js.map} +0 -0
- /package/dist/cjs/utils/{url.cjs.map → url.js.map} +0 -0
- /package/dist/cjs/utils/{weakKey.cjs.map → weakKey.js.map} +0 -0
- /package/dist/cjs/utils/{weakMemo.cjs.map → weakMemo.js.map} +0 -0
- /package/dist/cjs/views/{EmptyRoute.cjs.map → EmptyRoute.js.map} +0 -0
- /package/dist/cjs/views/{ErrorBoundary.cjs.map → ErrorBoundary.js.map} +0 -0
- /package/dist/cjs/views/{LoadProgressBar.cjs.map → LoadProgressBar.js.map} +0 -0
- /package/dist/cjs/views/{Navigator.cjs.map → Navigator.js.map} +0 -0
- /package/dist/cjs/views/{PreloadLinks.cjs.map → PreloadLinks.js.map} +0 -0
- /package/dist/cjs/views/{RootErrorBoundary.cjs.map → RootErrorBoundary.js.map} +0 -0
- /package/dist/cjs/views/{Screen.cjs.map → Screen.js.map} +0 -0
- /package/dist/cjs/views/{ScrollRestoration.cjs.map → ScrollRestoration.js.map} +0 -0
- /package/dist/cjs/views/{Try.cjs.map → Try.js.map} +0 -0
- /package/dist/cjs/vite/{build.cjs.map → build.js.map} +0 -0
- /package/dist/cjs/vite/{clientTreeShakePlugin.cjs.map → clientTreeShakePlugin.js.map} +0 -0
- /package/dist/cjs/vite/{constants.cjs.map → constants.js.map} +0 -0
- /package/dist/cjs/vite/{customNodeExternals.cjs.map → customNodeExternals.js.map} +0 -0
- /package/dist/cjs/vite/{ensureTsConfig.cjs.map → ensureTsConfig.js.map} +0 -0
- /package/dist/cjs/vite/{findDepsToOptimize.cjs.map → findDepsToOptimize.js.map} +0 -0
- /package/dist/cjs/vite/{fixDependenciesPlugin.cjs.map → fixDependenciesPlugin.js.map} +0 -0
- /package/dist/cjs/vite/{generateTypesForRoutes.cjs.map → generateTypesForRoutes.js.map} +0 -0
- /package/dist/cjs/vite/{getManifest.cjs.map → getManifest.js.map} +0 -0
- /package/dist/cjs/vite/{headers.cjs.map → headers.js.map} +0 -0
- /package/dist/cjs/vite/{makePluginWebOnly.cjs.map → makePluginWebOnly.js.map} +0 -0
- /package/dist/cjs/vite/{one.cjs.map → one.js.map} +0 -0
- /package/dist/cjs/vite/{removeReactNativeWebAnimatedPlugin.cjs.map → removeReactNativeWebAnimatedPlugin.js.map} +0 -0
- /package/dist/cjs/vite/{replaceLoader.cjs.map → replaceLoader.js.map} +0 -0
- /package/dist/cjs/vite/{resolveAPIRequest.cjs.map → resolveAPIRequest.js.map} +0 -0
- /package/dist/cjs/vite/{server.cjs.map → server.js.map} +0 -0
- /package/dist/cjs/vite/{types.cjs.map → types.js.map} +0 -0
- /package/dist/cjs/vite/{virtualEntryPlugin.cjs.map → virtualEntryPlugin.js.map} +0 -0
- /package/dist/cjs/vite/{vitePluginSsrCss.cjs.map → vitePluginSsrCss.js.map} +0 -0
- /package/dist/cjs/zero/{getQueryKey.cjs.map → getQueryKey.js.map} +0 -0
- /package/dist/cjs/zero/{isZeroQuery.cjs.map → isZeroQuery.js.map} +0 -0
- /package/dist/cjs/zero/{resolveQuery.cjs.map → resolveQuery.js.map} +0 -0
- /package/dist/cjs/zero/{subscribeToQuery.cjs.map → subscribeToQuery.js.map} +0 -0
- /package/dist/cjs/zero/{types.cjs.map → types.js.map} +0 -0
- /package/dist/cjs/zero/{useQuery.cjs.map → useQuery.js.map} +0 -0
- /package/dist/cjs/zero/{useQueryZero.cjs.map → useQueryZero.js.map} +0 -0
- /package/dist/cjs/{zero.cjs.map → zero.js.map} +0 -0
@@ -0,0 +1,381 @@
|
|
1
|
+
var __create = Object.create;
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
+
var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
+
var __export = (target, all) => {
|
7
|
+
for (var name in all)
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
9
|
+
}, __copyProps = (to, from, except, desc) => {
|
10
|
+
if (from && typeof from == "object" || typeof from == "function")
|
11
|
+
for (let key of __getOwnPropNames(from))
|
12
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
13
|
+
return to;
|
14
|
+
};
|
15
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
16
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
17
|
+
// file that has been converted to a CommonJS file using a Babel-
|
18
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
19
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
|
21
|
+
mod
|
22
|
+
)), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
23
|
+
var getStateFromPath_exports = {};
|
24
|
+
__export(getStateFromPath_exports, {
|
25
|
+
default: () => getStateFromPath,
|
26
|
+
getMatchableRouteConfigs: () => getMatchableRouteConfigs,
|
27
|
+
getUrlWithReactNavigationConcessions: () => getUrlWithReactNavigationConcessions,
|
28
|
+
stripBaseUrl: () => stripBaseUrl
|
29
|
+
});
|
30
|
+
module.exports = __toCommonJS(getStateFromPath_exports);
|
31
|
+
var import_escape_string_regexp = __toESM(require("escape-string-regexp"), 1), import_matchers = require("../matchers"), import_findFocusedRoute = require("./findFocusedRoute"), import_validatePathConfig = __toESM(require("./validatePathConfig"), 1);
|
32
|
+
function getUrlWithReactNavigationConcessions(path, baseUrl = process.env.EXPO_BASE_URL) {
|
33
|
+
let parsed;
|
34
|
+
try {
|
35
|
+
parsed = new URL(path, baseUrl || "http://phony.example");
|
36
|
+
} catch (err) {
|
37
|
+
return console.warn(`Error parsing url ${path}: ${err?.message}`), {
|
38
|
+
nonstandardPathname: path,
|
39
|
+
inputPathnameWithoutHash: path.replace(/#.*$/g, ""),
|
40
|
+
url: null
|
41
|
+
};
|
42
|
+
}
|
43
|
+
const pathname = parsed.pathname;
|
44
|
+
return {
|
45
|
+
// The slashes are at the end, not the beginning
|
46
|
+
nonstandardPathname: stripBaseUrl(pathname, baseUrl).replace(/^\/+/g, "").replace(/\/+$/g, "") + "/",
|
47
|
+
url: parsed
|
48
|
+
};
|
49
|
+
}
|
50
|
+
function getStateFromPath(path, options) {
|
51
|
+
const { initialRoutes, configs } = getMatchableRouteConfigs(options);
|
52
|
+
return getStateFromPathWithConfigs(path, configs, initialRoutes);
|
53
|
+
}
|
54
|
+
function getMatchableRouteConfigs(options) {
|
55
|
+
options && (0, import_validatePathConfig.default)(options);
|
56
|
+
const screens = options?.screens;
|
57
|
+
if (!screens)
|
58
|
+
throw Error("You must pass a 'screens' object to 'getStateFromPath' to generate a path.");
|
59
|
+
const initialRoutes = [];
|
60
|
+
options?.initialRouteName && initialRoutes.push({
|
61
|
+
initialRouteName: options.initialRouteName,
|
62
|
+
parentScreens: []
|
63
|
+
});
|
64
|
+
const converted = Object.keys(screens).flatMap((key) => createNormalizedConfigs(key, screens, [], initialRoutes)).flat(), resolvedInitialPatterns = initialRoutes.map(
|
65
|
+
(route) => joinPaths(...route.parentScreens, route.initialRouteName)
|
66
|
+
), configs = converted.map((config) => ({
|
67
|
+
...config,
|
68
|
+
// TODO: Probably a safer way to do this
|
69
|
+
// Mark initial routes to give them potential priority over other routes that match.
|
70
|
+
isInitial: resolvedInitialPatterns.includes(config.routeNames.join("/"))
|
71
|
+
})).sort(sortConfigs);
|
72
|
+
return assertConfigDuplicates(configs), { configs, initialRoutes };
|
73
|
+
}
|
74
|
+
function assertConfigDuplicates(configs) {
|
75
|
+
configs.reduce((acc, config) => {
|
76
|
+
const indexedKey = config.regex?.toString() ?? config.pattern, alpha = acc[indexedKey];
|
77
|
+
if (alpha && !alpha.hasChildren && !config.hasChildren) {
|
78
|
+
const a = alpha.routeNames, b = config.routeNames;
|
79
|
+
if (!(a.length > b.length ? b.every((it, i) => a[i] === it) : a.every((it, i) => b[i] === it))) {
|
80
|
+
const last = config.pattern.split("/").pop();
|
81
|
+
if (!last?.match(/^\*not-found$/)) {
|
82
|
+
const routeType = last?.startsWith(":") ? "dynamic route" : last?.startsWith("*") ? "dynamic-rest route" : "route";
|
83
|
+
throw new Error(
|
84
|
+
`The ${routeType} pattern '${config.pattern || "/"}' resolves to both '${alpha.userReadableName}' and '${config.userReadableName}'. Patterns must be unique and cannot resolve to more than one route.`
|
85
|
+
);
|
86
|
+
}
|
87
|
+
}
|
88
|
+
}
|
89
|
+
return Object.assign(acc, {
|
90
|
+
[indexedKey]: config
|
91
|
+
});
|
92
|
+
}, {});
|
93
|
+
}
|
94
|
+
function sortConfigs(a, b) {
|
95
|
+
if (a.pattern === b.pattern)
|
96
|
+
return b.routeNames.join(">").localeCompare(a.routeNames.join(">"));
|
97
|
+
if (a.pattern.startsWith(b.pattern) && // NOTE: This is a hack to make sure that `*` is always at the end
|
98
|
+
b.screen !== "index")
|
99
|
+
return -1;
|
100
|
+
if (b.pattern.startsWith(a.pattern) && a.screen !== "index")
|
101
|
+
return 1;
|
102
|
+
const aParts = a.pattern.split("/").filter((part) => (0, import_matchers.matchGroupName)(part) == null);
|
103
|
+
(a.screen === "index" || a.screen.match(/\/index$/)) && aParts.push("index");
|
104
|
+
const bParts = b.pattern.split("/").filter((part) => (0, import_matchers.matchGroupName)(part) == null);
|
105
|
+
(b.screen === "index" || b.screen.match(/\/index$/)) && bParts.push("index");
|
106
|
+
for (let i = 0; i < Math.max(aParts.length, bParts.length); i++) {
|
107
|
+
if (aParts[i] == null)
|
108
|
+
return 1;
|
109
|
+
if (bParts[i] == null)
|
110
|
+
return -1;
|
111
|
+
const aWildCard = aParts[i].startsWith("*"), bWildCard = bParts[i].startsWith("*");
|
112
|
+
if (aWildCard && bWildCard) {
|
113
|
+
const aNotFound = aParts[i].match(/^[*]not-found$/), bNotFound = bParts[i].match(/^[*]not-found$/);
|
114
|
+
if (aNotFound && bNotFound)
|
115
|
+
continue;
|
116
|
+
if (aNotFound)
|
117
|
+
return 1;
|
118
|
+
if (bNotFound)
|
119
|
+
return -1;
|
120
|
+
continue;
|
121
|
+
}
|
122
|
+
if (aWildCard)
|
123
|
+
return 1;
|
124
|
+
if (bWildCard)
|
125
|
+
return -1;
|
126
|
+
const aSlug = aParts[i].startsWith(":"), bSlug = bParts[i].startsWith(":");
|
127
|
+
if (aSlug && bSlug) {
|
128
|
+
const aNotFound = aParts[i].match(/^[*]not-found$/), bNotFound = bParts[i].match(/^[*]not-found$/);
|
129
|
+
if (aNotFound && bNotFound)
|
130
|
+
continue;
|
131
|
+
if (aNotFound)
|
132
|
+
return 1;
|
133
|
+
if (bNotFound)
|
134
|
+
return -1;
|
135
|
+
continue;
|
136
|
+
}
|
137
|
+
if (aSlug)
|
138
|
+
return 1;
|
139
|
+
if (bSlug)
|
140
|
+
return -1;
|
141
|
+
}
|
142
|
+
return a.isInitial && !b.isInitial ? -1 : !a.isInitial && b.isInitial ? 1 : bParts.length - aParts.length;
|
143
|
+
}
|
144
|
+
function getStateFromEmptyPathWithConfigs(path, hash, configs, initialRoutes) {
|
145
|
+
const leafNodes = configs.filter((config) => !config.hasChildren).map((value) => ({
|
146
|
+
...value,
|
147
|
+
// Collapse all levels of group segments before testing.
|
148
|
+
// This enables `app/(one)/(two)/index.js` to be matched.
|
149
|
+
path: (0, import_matchers.stripGroupSegmentsFromPath)(value.path)
|
150
|
+
})), match = leafNodes.find(
|
151
|
+
(config) => (
|
152
|
+
// NOTE: Test leaf node index routes that either don't have a regex or match an empty string.
|
153
|
+
config.path === "" && (!config.regex || config.regex.test(""))
|
154
|
+
)
|
155
|
+
) ?? leafNodes.find(
|
156
|
+
(config) => (
|
157
|
+
// NOTE: Test leaf node dynamic routes that match an empty string.
|
158
|
+
config.path.startsWith(":") && config.regex.test("")
|
159
|
+
)
|
160
|
+
) ?? // NOTE: Test leaf node deep dynamic routes that match a slash.
|
161
|
+
// This should be done last to enable dynamic routes having a higher priority.
|
162
|
+
leafNodes.find((config) => config.path.startsWith("*") && config.regex.test("/"));
|
163
|
+
if (!match)
|
164
|
+
return;
|
165
|
+
const routes = match.routeNames.map((name) => match._route ? {
|
166
|
+
name,
|
167
|
+
_route: match._route
|
168
|
+
} : { name });
|
169
|
+
return createNestedStateObject(path, hash, routes, configs, initialRoutes);
|
170
|
+
}
|
171
|
+
function getStateFromPathWithConfigs(path, configs, initialRoutes, baseUrl = process.env.EXPO_BASE_URL) {
|
172
|
+
const formattedPaths = getUrlWithReactNavigationConcessions(path);
|
173
|
+
if (!formattedPaths.url) {
|
174
|
+
console.warn(`No url found for ${path}`);
|
175
|
+
return;
|
176
|
+
}
|
177
|
+
let cleanPath = stripBaseUrl((0, import_matchers.stripGroupSegmentsFromPath)(formattedPaths.url.pathname), baseUrl) + formattedPaths.url.search;
|
178
|
+
if (path.startsWith("/") || (cleanPath = cleanPath.slice(1)), formattedPaths.nonstandardPathname === "/")
|
179
|
+
return getStateFromEmptyPathWithConfigs(
|
180
|
+
cleanPath,
|
181
|
+
formattedPaths.url.hash.slice(1),
|
182
|
+
configs,
|
183
|
+
initialRoutes
|
184
|
+
);
|
185
|
+
const routes = matchAgainstConfigs(formattedPaths.nonstandardPathname, configs);
|
186
|
+
if (routes != null)
|
187
|
+
return createNestedStateObject(
|
188
|
+
cleanPath,
|
189
|
+
formattedPaths.url.hash.slice(1),
|
190
|
+
routes,
|
191
|
+
configs,
|
192
|
+
initialRoutes
|
193
|
+
);
|
194
|
+
}
|
195
|
+
const joinPaths = (...paths) => [].concat(...paths.map((p) => p.split("/"))).filter(Boolean).join("/");
|
196
|
+
function matchAgainstConfigs(remaining, configs) {
|
197
|
+
let routes, remainingPath = remaining;
|
198
|
+
for (const config of configs) {
|
199
|
+
if (!config.regex)
|
200
|
+
continue;
|
201
|
+
const match = remainingPath.match(config.regex);
|
202
|
+
if (!match)
|
203
|
+
continue;
|
204
|
+
const matchedParams = config.pattern?.split("/").filter((p) => p.match(/^[:*]/)).reduce((acc, p, i) => p.match(/^\*/) ? {
|
205
|
+
...acc,
|
206
|
+
[p]: match[(i + 1) * 2]
|
207
|
+
//?.replace(/\//, ""),
|
208
|
+
} : Object.assign(acc, {
|
209
|
+
// The param segments appear every second item starting from 2 in the regex match result.
|
210
|
+
// This will only work if we ensure groups aren't included in the match.
|
211
|
+
[p]: match[(i + 1) * 2]?.replace(/\//, "")
|
212
|
+
}), {}), routeFromName = (name) => {
|
213
|
+
const config2 = configs.find((c) => c.screen === name);
|
214
|
+
if (!config2?.path)
|
215
|
+
return { name };
|
216
|
+
const segments = config2.path.split("/"), params = {};
|
217
|
+
return segments.filter((p) => p.match(/^[:*]/)).forEach((p) => {
|
218
|
+
let value = matchedParams[p];
|
219
|
+
if (value) {
|
220
|
+
p.match(/^\*/) && (value = value?.split("/").filter(Boolean));
|
221
|
+
const key = p.replace(/^[:*]/, "").replace(/\?$/, "");
|
222
|
+
params[key] = config2.parse?.[key] ? config2.parse[key](value) : value;
|
223
|
+
}
|
224
|
+
}), params && Object.keys(params).length ? { name, params } : { name };
|
225
|
+
};
|
226
|
+
routes = config.routeNames.map((name) => config._route ? {
|
227
|
+
...routeFromName(name),
|
228
|
+
_route: config._route
|
229
|
+
} : { ...routeFromName(name) });
|
230
|
+
const combinedParams = routes.reduce(
|
231
|
+
(acc, r) => Object.assign(acc, r.params),
|
232
|
+
{}
|
233
|
+
), hasCombinedParams = Object.keys(combinedParams).length > 0;
|
234
|
+
routes = routes.map((r) => (hasCombinedParams && (r.params = combinedParams), r)), remainingPath = remainingPath.replace(match[1], "");
|
235
|
+
break;
|
236
|
+
}
|
237
|
+
return routes;
|
238
|
+
}
|
239
|
+
function equalHeritage(a, b) {
|
240
|
+
if (a.length !== b.length)
|
241
|
+
return !1;
|
242
|
+
for (let i = 0; i < a.length; i++)
|
243
|
+
if (a[i].localeCompare(b[i]) !== 0)
|
244
|
+
return !1;
|
245
|
+
return !0;
|
246
|
+
}
|
247
|
+
const createNormalizedConfigs = (screen, routeConfig, routeNames = [], initials = [], parentScreens = [], parentPattern) => {
|
248
|
+
const configs = [];
|
249
|
+
routeNames.push(screen), parentScreens.push(screen);
|
250
|
+
const config = routeConfig[screen];
|
251
|
+
if (typeof config == "string") {
|
252
|
+
const pattern = parentPattern ? joinPaths(parentPattern, config) : config;
|
253
|
+
configs.push(createConfigItem(screen, routeNames, pattern, config, !1));
|
254
|
+
} else if (typeof config == "object") {
|
255
|
+
let pattern;
|
256
|
+
const { _route } = config;
|
257
|
+
if (typeof config.path == "string") {
|
258
|
+
if (config.exact && config.path === void 0)
|
259
|
+
throw new Error(
|
260
|
+
"A 'path' needs to be specified when specifying 'exact: true'. If you don't want this screen in the URL, specify it as empty string, e.g. `path: ''`."
|
261
|
+
);
|
262
|
+
pattern = config.exact !== !0 ? joinPaths(parentPattern || "", config.path || "") : config.path || "", configs.push(
|
263
|
+
createConfigItem(
|
264
|
+
screen,
|
265
|
+
routeNames,
|
266
|
+
pattern,
|
267
|
+
config.path,
|
268
|
+
config.screens ? !!Object.keys(config.screens)?.length : !1,
|
269
|
+
config.parse,
|
270
|
+
_route
|
271
|
+
)
|
272
|
+
);
|
273
|
+
}
|
274
|
+
config.screens && (config.initialRouteName && initials.push({
|
275
|
+
initialRouteName: config.initialRouteName,
|
276
|
+
parentScreens
|
277
|
+
}), Object.keys(config.screens).forEach((nestedConfig) => {
|
278
|
+
const result = createNormalizedConfigs(
|
279
|
+
nestedConfig,
|
280
|
+
config.screens,
|
281
|
+
routeNames,
|
282
|
+
initials,
|
283
|
+
[...parentScreens],
|
284
|
+
pattern ?? parentPattern
|
285
|
+
);
|
286
|
+
configs.push(...result);
|
287
|
+
}));
|
288
|
+
}
|
289
|
+
return routeNames.pop(), configs;
|
290
|
+
};
|
291
|
+
function formatRegexPattern(it) {
|
292
|
+
return it = it.replace(" ", "%20"), it.startsWith(":") ? `(([^/]+\\/)${it.endsWith("?") ? "?" : ""})` : it.startsWith("*") ? `((.*\\/)${it.endsWith("?") ? "?" : ""})` : (0, import_matchers.matchGroupName)(it) != null ? `(?:${(0, import_escape_string_regexp.default)(it)}\\/)?` : (0, import_escape_string_regexp.default)(it) + "\\/";
|
293
|
+
}
|
294
|
+
const createConfigItem = (screen, routeNames, pattern, path, hasChildren, parse, _route) => {
|
295
|
+
pattern = pattern.split("/").filter(Boolean).join("/");
|
296
|
+
const regex = pattern ? new RegExp(`^(${pattern.split("/").map(formatRegexPattern).join("")})$`) : void 0;
|
297
|
+
return {
|
298
|
+
screen,
|
299
|
+
regex,
|
300
|
+
pattern,
|
301
|
+
path,
|
302
|
+
// The routeNames array is mutated, so copy it to keep the current state
|
303
|
+
routeNames: [...routeNames],
|
304
|
+
parse,
|
305
|
+
userReadableName: [...routeNames.slice(0, -1), path || screen].join("/"),
|
306
|
+
hasChildren: !!hasChildren,
|
307
|
+
_route
|
308
|
+
};
|
309
|
+
}, findParseConfigForRoute = (routeName, routeConfigs) => {
|
310
|
+
for (const config of routeConfigs)
|
311
|
+
if (routeName === config.routeNames[config.routeNames.length - 1])
|
312
|
+
return config.parse;
|
313
|
+
}, findInitialRoute = (routeName, parentScreens, initialRoutes) => {
|
314
|
+
for (const config of initialRoutes)
|
315
|
+
if (equalHeritage(parentScreens, config.parentScreens))
|
316
|
+
return routeName !== config.initialRouteName ? config.initialRouteName : void 0;
|
317
|
+
}, createStateObject = (route, isEmpty, initialRoute) => isEmpty ? initialRoute ? {
|
318
|
+
index: 1,
|
319
|
+
routes: [{ name: initialRoute }, route]
|
320
|
+
} : {
|
321
|
+
routes: [route]
|
322
|
+
} : initialRoute ? {
|
323
|
+
index: 1,
|
324
|
+
routes: [{ name: initialRoute }, { ...route, state: { routes: [] } }]
|
325
|
+
} : {
|
326
|
+
routes: [{ ...route, state: { routes: [] } }]
|
327
|
+
}, createNestedStateObject = (path, hash, routes, routeConfigs, initialRoutes) => {
|
328
|
+
let route = routes.shift();
|
329
|
+
const parentScreens = [];
|
330
|
+
let initialRoute = findInitialRoute(route.name, parentScreens, initialRoutes);
|
331
|
+
parentScreens.push(route.name);
|
332
|
+
const state = createStateObject(route, routes.length === 0, initialRoute);
|
333
|
+
if (routes.length > 0) {
|
334
|
+
let nestedState = state;
|
335
|
+
for (; route = routes.shift(); ) {
|
336
|
+
initialRoute = findInitialRoute(route.name, parentScreens, initialRoutes);
|
337
|
+
const nestedStateIndex = nestedState.index || nestedState.routes.length - 1;
|
338
|
+
nestedState.routes[nestedStateIndex].state = createStateObject(
|
339
|
+
route,
|
340
|
+
routes.length === 0,
|
341
|
+
initialRoute
|
342
|
+
), routes.length > 0 && (nestedState = nestedState.routes[nestedStateIndex].state), parentScreens.push(route.name);
|
343
|
+
}
|
344
|
+
}
|
345
|
+
route = (0, import_findFocusedRoute.findFocusedRoute)(state), route.path = path;
|
346
|
+
const params = parseQueryParams(route.path, findParseConfigForRoute(route.name, routeConfigs));
|
347
|
+
if (params) {
|
348
|
+
route.params = Object.assign(/* @__PURE__ */ Object.create(null), route.params);
|
349
|
+
for (const [name, value] of Object.entries(params))
|
350
|
+
if (route.params?.[name] && process.env.NODE_ENV !== "production" && console.warn(
|
351
|
+
`Route '/${route.name}' with param '${name}' was specified both in the path and as a param, removing from path`
|
352
|
+
), !route.params?.[name]) {
|
353
|
+
route.params[name] = value;
|
354
|
+
continue;
|
355
|
+
}
|
356
|
+
Object.keys(route.params).length === 0 && delete route.params;
|
357
|
+
}
|
358
|
+
return hash && (route.params = Object.assign(/* @__PURE__ */ Object.create(null), route.params), route.params["#"] = hash), state;
|
359
|
+
}, parseQueryParams = (path, parseConfig) => {
|
360
|
+
const query = path.split("?")[1], searchParams = new URLSearchParams(query), params = Object.fromEntries(
|
361
|
+
// @ts-ignore: [Symbol.iterator] is indeed, available on every platform.
|
362
|
+
searchParams
|
363
|
+
);
|
364
|
+
return parseConfig && Object.keys(params).forEach((name) => {
|
365
|
+
Object.hasOwnProperty.call(parseConfig, name) && typeof params[name] == "string" && (params[name] = parseConfig[name](params[name]));
|
366
|
+
}), Object.keys(params).length ? params : void 0;
|
367
|
+
}, baseUrlCache = /* @__PURE__ */ new Map();
|
368
|
+
function getBaseUrlRegex(baseUrl) {
|
369
|
+
if (baseUrlCache.has(baseUrl))
|
370
|
+
return baseUrlCache.get(baseUrl);
|
371
|
+
const regex = new RegExp(`^\\/?${(0, import_escape_string_regexp.default)(baseUrl)}`, "g");
|
372
|
+
return baseUrlCache.set(baseUrl, regex), regex;
|
373
|
+
}
|
374
|
+
function stripBaseUrl(path, baseUrl = process.env.EXPO_BASE_URL) {
|
375
|
+
if (process.env.NODE_ENV !== "development" && baseUrl) {
|
376
|
+
const reg = getBaseUrlRegex(baseUrl);
|
377
|
+
return path.replace(/^\/+/g, "/").replace(reg, "");
|
378
|
+
}
|
379
|
+
return path;
|
380
|
+
}
|
381
|
+
//# sourceMappingURL=getStateFromPath.js.map
|
@@ -0,0 +1,182 @@
|
|
1
|
+
var __create = Object.create;
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
+
var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
+
var __export = (target, all) => {
|
7
|
+
for (var name in all)
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
9
|
+
}, __copyProps = (to, from, except, desc) => {
|
10
|
+
if (from && typeof from == "object" || typeof from == "function")
|
11
|
+
for (let key of __getOwnPropNames(from))
|
12
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
13
|
+
return to;
|
14
|
+
};
|
15
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
16
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
17
|
+
// file that has been converted to a CommonJS file using a Babel-
|
18
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
19
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
|
21
|
+
mod
|
22
|
+
)), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
23
|
+
var useLinking_exports = {};
|
24
|
+
__export(useLinking_exports, {
|
25
|
+
default: () => useLinking,
|
26
|
+
series: () => series
|
27
|
+
});
|
28
|
+
module.exports = __toCommonJS(useLinking_exports);
|
29
|
+
var import_core = require("@react-navigation/core"), import_fast_deep_equal = __toESM(require("fast-deep-equal"), 1), React = __toESM(require("react"), 1), import_createMemoryHistory = __toESM(require("./createMemoryHistory"), 1), import_serverLocationContext = require("../router/serverLocationContext"), import_getPathFromState = require("./getPathFromState");
|
30
|
+
const historyGlobal = (0, import_createMemoryHistory.default)();
|
31
|
+
typeof window < "u" && historyGlobal.listen(() => {
|
32
|
+
globalThis.__vxrntodopath = window.location.pathname;
|
33
|
+
});
|
34
|
+
const findMatchingState = (a, b) => {
|
35
|
+
if (a === void 0 || b === void 0 || a.key !== b.key)
|
36
|
+
return [void 0, void 0];
|
37
|
+
const aHistoryLength = a.history ? a.history.length : a.routes.length, bHistoryLength = b.history ? b.history.length : b.routes.length, aRoute = a.routes[a.index], bRoute = b.routes[b.index], aChildState = aRoute.state, bChildState = bRoute.state;
|
38
|
+
return aHistoryLength !== bHistoryLength || aRoute.key !== bRoute.key || aChildState === void 0 || bChildState === void 0 || aChildState.key !== bChildState.key ? [a, b] : findMatchingState(aChildState, bChildState);
|
39
|
+
}, series = (cb) => {
|
40
|
+
let queue = Promise.resolve();
|
41
|
+
return () => {
|
42
|
+
queue = queue.then(cb);
|
43
|
+
};
|
44
|
+
};
|
45
|
+
let linkingHandlers = [];
|
46
|
+
function useLinking(ref, {
|
47
|
+
independent,
|
48
|
+
enabled = !0,
|
49
|
+
config,
|
50
|
+
getStateFromPath = import_core.getStateFromPath,
|
51
|
+
getPathFromState = import_core.getPathFromState,
|
52
|
+
getActionFromState = import_core.getActionFromState
|
53
|
+
}) {
|
54
|
+
React.useEffect(() => {
|
55
|
+
if (process.env.NODE_ENV === "production" || independent)
|
56
|
+
return;
|
57
|
+
enabled !== !1 && linkingHandlers.length && console.error(
|
58
|
+
[
|
59
|
+
"Looks like you have configured linking in multiple places. This is likely an error since deep links should only be handled in one place to avoid conflicts. Make sure that:",
|
60
|
+
"- You don't have multiple NavigationContainers in the app each with 'linking' enabled",
|
61
|
+
"- Only a single instance of the root component is rendered"
|
62
|
+
].join(`
|
63
|
+
`).trim()
|
64
|
+
);
|
65
|
+
const handler = Symbol();
|
66
|
+
return enabled !== !1 && linkingHandlers.push(handler), () => {
|
67
|
+
const index = linkingHandlers.indexOf(handler);
|
68
|
+
index > -1 && linkingHandlers.splice(index, 1);
|
69
|
+
};
|
70
|
+
}, [enabled, independent]);
|
71
|
+
const [history] = React.useState(historyGlobal), enabledRef = React.useRef(enabled), configRef = React.useRef(config), getStateFromPathRef = React.useRef(getStateFromPath), getPathFromStateRef = React.useRef(getPathFromState), getActionFromStateRef = React.useRef(getActionFromState);
|
72
|
+
React.useEffect(() => {
|
73
|
+
enabledRef.current = enabled, configRef.current = config, getStateFromPathRef.current = getStateFromPath, getPathFromStateRef.current = getPathFromState, getActionFromStateRef.current = getActionFromState;
|
74
|
+
});
|
75
|
+
const server = { location: React.useContext(import_serverLocationContext.ServerLocationContext) }, getInitialState = React.useCallback(() => {
|
76
|
+
let value;
|
77
|
+
if (enabledRef.current) {
|
78
|
+
const location2 = server?.location ?? (typeof window < "u" ? window.location : void 0), path = location2 ? location2.pathname + location2.search : void 0;
|
79
|
+
path && (value = getStateFromPathRef.current(path, configRef.current));
|
80
|
+
}
|
81
|
+
const thenable = {
|
82
|
+
// biome-ignore lint/suspicious/noThenProperty: <explanation>
|
83
|
+
then(onfulfilled) {
|
84
|
+
return Promise.resolve(onfulfilled ? onfulfilled(value) : value);
|
85
|
+
},
|
86
|
+
catch() {
|
87
|
+
return thenable;
|
88
|
+
}
|
89
|
+
};
|
90
|
+
return thenable;
|
91
|
+
}, []), previousIndexRef = React.useRef(void 0), previousStateRef = React.useRef(void 0), pendingPopStatePathRef = React.useRef(void 0);
|
92
|
+
return React.useEffect(() => (previousIndexRef.current = history.index, history.listen(() => {
|
93
|
+
const navigation = ref.current;
|
94
|
+
if (!navigation || !enabled)
|
95
|
+
return;
|
96
|
+
const { location: location2 } = window, path = location2.pathname + location2.search, index = history.index, previousIndex = previousIndexRef.current ?? 0;
|
97
|
+
previousIndexRef.current = index, pendingPopStatePathRef.current = path;
|
98
|
+
const record = history.get(index);
|
99
|
+
if (record?.path === path && record?.state) {
|
100
|
+
navigation.resetRoot(record.state);
|
101
|
+
return;
|
102
|
+
}
|
103
|
+
const state = getStateFromPathRef.current(path, configRef.current);
|
104
|
+
if (state) {
|
105
|
+
const rootState = navigation.getRootState();
|
106
|
+
if (state.routes.some((r) => !rootState?.routeNames.includes(r.name))) {
|
107
|
+
console.warn(
|
108
|
+
"The navigation state parsed from the URL contains routes not present in the root navigator. This usually means that the linking configuration doesn't match the navigation structure. See https://reactnavigation.org/docs/configuring-links for more details on how to specify a linking configuration."
|
109
|
+
);
|
110
|
+
return;
|
111
|
+
}
|
112
|
+
if (index > previousIndex) {
|
113
|
+
const action = getActionFromStateRef.current(state, configRef.current);
|
114
|
+
if (action !== void 0)
|
115
|
+
try {
|
116
|
+
navigation.dispatch(action);
|
117
|
+
} catch (e) {
|
118
|
+
console.warn(
|
119
|
+
`An error occurred when trying to handle the link '${path}': ${typeof e == "object" && e != null && "message" in e ? e.message : e}`
|
120
|
+
);
|
121
|
+
}
|
122
|
+
else
|
123
|
+
navigation.resetRoot(state);
|
124
|
+
} else
|
125
|
+
navigation.resetRoot(state);
|
126
|
+
} else
|
127
|
+
navigation.resetRoot(state);
|
128
|
+
})), [enabled, history, ref]), React.useEffect(() => {
|
129
|
+
if (!enabled)
|
130
|
+
return;
|
131
|
+
const getPathForRoute = (route, state) => {
|
132
|
+
if (route?.path) {
|
133
|
+
const stateForPath = getStateFromPathRef.current(route.path, configRef.current);
|
134
|
+
if (stateForPath) {
|
135
|
+
const focusedRoute = (0, import_core.findFocusedRoute)(stateForPath);
|
136
|
+
if (focusedRoute && focusedRoute.name === route.name && (0, import_fast_deep_equal.default)(focusedRoute.params, route.params))
|
137
|
+
return (0, import_getPathFromState.appendBaseUrl)(route.path);
|
138
|
+
}
|
139
|
+
}
|
140
|
+
return getPathFromStateRef.current(state, configRef.current);
|
141
|
+
};
|
142
|
+
if (ref.current) {
|
143
|
+
const state = ref.current.getRootState();
|
144
|
+
if (state) {
|
145
|
+
const route = (0, import_core.findFocusedRoute)(state), path = getPathForRoute(route, state);
|
146
|
+
previousStateRef.current === void 0 && (previousStateRef.current = state), history.replace({ path, state });
|
147
|
+
}
|
148
|
+
}
|
149
|
+
const onStateChange = async () => {
|
150
|
+
const navigation = ref.current;
|
151
|
+
if (!navigation || !enabled)
|
152
|
+
return;
|
153
|
+
const previousState = previousStateRef.current, state = navigation.getRootState();
|
154
|
+
if (!state)
|
155
|
+
return;
|
156
|
+
const pendingPath = pendingPopStatePathRef.current, route = (0, import_core.findFocusedRoute)(state), path = getPathForRoute(route, state);
|
157
|
+
previousStateRef.current = state, pendingPopStatePathRef.current = void 0;
|
158
|
+
const [previousFocusedState, focusedState] = findMatchingState(previousState, state);
|
159
|
+
if (previousFocusedState && focusedState && // We should only handle push/pop if path changed from what was in last `popstate`
|
160
|
+
// Otherwise it's likely a change triggered by `popstate`
|
161
|
+
path !== pendingPath) {
|
162
|
+
const historyDelta = (focusedState.history ? focusedState.history.length : focusedState.routes.length) - (previousFocusedState.history ? previousFocusedState.history.length : previousFocusedState.routes.length);
|
163
|
+
if (historyDelta > 0)
|
164
|
+
history.push({ path, state });
|
165
|
+
else if (historyDelta < 0) {
|
166
|
+
const nextIndex = history.backIndex({ path }), currentIndex = history.index;
|
167
|
+
try {
|
168
|
+
nextIndex !== -1 && nextIndex < currentIndex && // We should only go back if the entry exists and it's less than current index
|
169
|
+
history.get(nextIndex - currentIndex) ? await history.go(nextIndex - currentIndex) : await history.go(historyDelta), history.replace({ path, state });
|
170
|
+
} catch {
|
171
|
+
}
|
172
|
+
} else
|
173
|
+
history.replace({ path, state });
|
174
|
+
} else
|
175
|
+
history.replace({ path, state });
|
176
|
+
};
|
177
|
+
return ref.current?.addListener("state", series(onStateChange));
|
178
|
+
}, [enabled, history, ref]), {
|
179
|
+
getInitialState
|
180
|
+
};
|
181
|
+
}
|
182
|
+
//# sourceMappingURL=useLinking.js.map
|
@@ -0,0 +1,46 @@
|
|
1
|
+
var __defProp = Object.defineProperty;
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
5
|
+
var __export = (target, all) => {
|
6
|
+
for (var name in all)
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
8
|
+
}, __copyProps = (to, from, except, desc) => {
|
9
|
+
if (from && typeof from == "object" || typeof from == "function")
|
10
|
+
for (let key of __getOwnPropNames(from))
|
11
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
12
|
+
return to;
|
13
|
+
};
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
15
|
+
var validatePathConfig_exports = {};
|
16
|
+
__export(validatePathConfig_exports, {
|
17
|
+
default: () => validatePathConfig
|
18
|
+
});
|
19
|
+
module.exports = __toCommonJS(validatePathConfig_exports);
|
20
|
+
const formatToList = (items) => items.map((key) => `- ${key}`).join(`
|
21
|
+
`);
|
22
|
+
function validatePathConfig(config, root = !0) {
|
23
|
+
const validKeys = ["initialRouteName", "screens", "_route"];
|
24
|
+
root || validKeys.push("path", "exact", "stringify", "parse");
|
25
|
+
const invalidKeys = Object.keys(config).filter((key) => !validKeys.includes(key));
|
26
|
+
if (invalidKeys.length)
|
27
|
+
throw new Error(
|
28
|
+
`Found invalid properties in the configuration:
|
29
|
+
${formatToList(
|
30
|
+
invalidKeys
|
31
|
+
)}
|
32
|
+
|
33
|
+
Did you forget to specify them under a 'screens' property?
|
34
|
+
|
35
|
+
You can only specify the following properties:
|
36
|
+
${formatToList(
|
37
|
+
validKeys
|
38
|
+
)}
|
39
|
+
|
40
|
+
See https://reactnavigation.org/docs/configuring-links for more details on how to specify a linking configuration.`
|
41
|
+
);
|
42
|
+
config.screens && Object.entries(config.screens).forEach(([_, value]) => {
|
43
|
+
typeof value != "string" && validatePathConfig(value, !1);
|
44
|
+
});
|
45
|
+
}
|
46
|
+
//# sourceMappingURL=validatePathConfig.js.map
|
@@ -0,0 +1,59 @@
|
|
1
|
+
var __defProp = Object.defineProperty;
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
5
|
+
var __export = (target, all) => {
|
6
|
+
for (var name in all)
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: !0 });
|
8
|
+
}, __copyProps = (to, from, except, desc) => {
|
9
|
+
if (from && typeof from == "object" || typeof from == "function")
|
10
|
+
for (let key of __getOwnPropNames(from))
|
11
|
+
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
12
|
+
return to;
|
13
|
+
};
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
15
|
+
var getLinkingConfig_exports = {};
|
16
|
+
__export(getLinkingConfig_exports, {
|
17
|
+
getLinkingConfig: () => getLinkingConfig,
|
18
|
+
getNavigationConfig: () => getNavigationConfig,
|
19
|
+
stateCache: () => stateCache
|
20
|
+
});
|
21
|
+
module.exports = __toCommonJS(getLinkingConfig_exports);
|
22
|
+
var import_native = require("@react-navigation/native"), import_getReactNavigationConfig = require("./getReactNavigationConfig"), import_linking = require("./link/linking");
|
23
|
+
function getNavigationConfig(routes, metaOnly = !0) {
|
24
|
+
return (0, import_getReactNavigationConfig.getReactNavigationConfig)(routes, metaOnly);
|
25
|
+
}
|
26
|
+
function getLinkingConfig(routes, metaOnly = !0) {
|
27
|
+
return {
|
28
|
+
prefixes: [],
|
29
|
+
// @ts-expect-error
|
30
|
+
config: getNavigationConfig(routes, metaOnly),
|
31
|
+
// A custom getInitialURL is used on native to ensure the app always starts at
|
32
|
+
// the root path if it's launched from something other than a deep link.
|
33
|
+
// This helps keep the native functionality working like the web functionality.
|
34
|
+
// For example, if you had a root navigator where the first screen was `/settings` and the second was `/index`
|
35
|
+
// then `/index` would be used on web and `/settings` would be used on native.
|
36
|
+
getInitialURL: import_linking.getInitialURL,
|
37
|
+
subscribe: import_linking.addEventListener,
|
38
|
+
getStateFromPath: getStateFromPathMemoized,
|
39
|
+
getPathFromState(state, options) {
|
40
|
+
return (0, import_linking.getPathFromState)(state, {
|
41
|
+
screens: [],
|
42
|
+
...this.config,
|
43
|
+
...options
|
44
|
+
}) ?? "/";
|
45
|
+
},
|
46
|
+
// Add all functions to ensure the types never need to fallback.
|
47
|
+
// This is a convenience for usage in the package.
|
48
|
+
getActionFromState: import_native.getActionFromState
|
49
|
+
};
|
50
|
+
}
|
51
|
+
const stateCache = /* @__PURE__ */ new Map();
|
52
|
+
function getStateFromPathMemoized(path, options) {
|
53
|
+
const cached = stateCache.get(path);
|
54
|
+
if (cached)
|
55
|
+
return cached;
|
56
|
+
const result = (0, import_linking.getStateFromPath)(path, options);
|
57
|
+
return stateCache.set(path, result), result;
|
58
|
+
}
|
59
|
+
//# sourceMappingURL=getLinkingConfig.js.map
|