expo-router 55.0.5 → 55.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/android/build.gradle +2 -2
  2. package/build/ExpoRoot.js +6 -12
  3. package/build/ExpoRoot.js.map +1 -1
  4. package/build/fork/getPathFromState.js +1 -1
  5. package/build/fork/getPathFromState.js.map +1 -1
  6. package/build/fork/getStateFromPath-forks.js +1 -1
  7. package/build/fork/getStateFromPath-forks.js.map +1 -1
  8. package/build/fork/useLinking.d.ts.map +1 -1
  9. package/build/fork/useLinking.js +3 -1
  10. package/build/fork/useLinking.js.map +1 -1
  11. package/build/global-state/serverLocationContext.d.ts +1 -0
  12. package/build/global-state/serverLocationContext.d.ts.map +1 -1
  13. package/build/global-state/serverLocationContext.js.map +1 -1
  14. package/build/layouts/DrawerClient.d.ts +15 -11
  15. package/build/layouts/DrawerClient.d.ts.map +1 -1
  16. package/build/layouts/StackClient.d.ts.map +1 -1
  17. package/build/layouts/StackClient.js +23 -9
  18. package/build/layouts/StackClient.js.map +1 -1
  19. package/expo-module.config.json +1 -1
  20. package/local-maven-repo/expo/modules/router/expo.modules.router/{55.0.5/expo.modules.router-55.0.5.module → 55.0.6/expo.modules.router-55.0.6.module} +7 -7
  21. package/local-maven-repo/expo/modules/router/expo.modules.router/55.0.6/expo.modules.router-55.0.6.module.md5 +1 -0
  22. package/local-maven-repo/expo/modules/router/expo.modules.router/55.0.6/expo.modules.router-55.0.6.module.sha1 +1 -0
  23. package/local-maven-repo/expo/modules/router/expo.modules.router/55.0.6/expo.modules.router-55.0.6.module.sha256 +1 -0
  24. package/local-maven-repo/expo/modules/router/expo.modules.router/55.0.6/expo.modules.router-55.0.6.module.sha512 +1 -0
  25. package/local-maven-repo/expo/modules/router/expo.modules.router/{55.0.5/expo.modules.router-55.0.5.pom → 55.0.6/expo.modules.router-55.0.6.pom} +1 -1
  26. package/local-maven-repo/expo/modules/router/expo.modules.router/55.0.6/expo.modules.router-55.0.6.pom.md5 +1 -0
  27. package/local-maven-repo/expo/modules/router/expo.modules.router/55.0.6/expo.modules.router-55.0.6.pom.sha1 +1 -0
  28. package/local-maven-repo/expo/modules/router/expo.modules.router/55.0.6/expo.modules.router-55.0.6.pom.sha256 +1 -0
  29. package/local-maven-repo/expo/modules/router/expo.modules.router/55.0.6/expo.modules.router-55.0.6.pom.sha512 +1 -0
  30. package/local-maven-repo/expo/modules/router/expo.modules.router/maven-metadata.xml +4 -4
  31. package/local-maven-repo/expo/modules/router/expo.modules.router/maven-metadata.xml.md5 +1 -1
  32. package/local-maven-repo/expo/modules/router/expo.modules.router/maven-metadata.xml.sha1 +1 -1
  33. package/local-maven-repo/expo/modules/router/expo.modules.router/maven-metadata.xml.sha256 +1 -1
  34. package/local-maven-repo/expo/modules/router/expo.modules.router/maven-metadata.xml.sha512 +1 -1
  35. package/package.json +8 -8
  36. package/local-maven-repo/expo/modules/router/expo.modules.router/55.0.5/expo.modules.router-55.0.5.module.md5 +0 -1
  37. package/local-maven-repo/expo/modules/router/expo.modules.router/55.0.5/expo.modules.router-55.0.5.module.sha1 +0 -1
  38. package/local-maven-repo/expo/modules/router/expo.modules.router/55.0.5/expo.modules.router-55.0.5.module.sha256 +0 -1
  39. package/local-maven-repo/expo/modules/router/expo.modules.router/55.0.5/expo.modules.router-55.0.5.module.sha512 +0 -1
  40. package/local-maven-repo/expo/modules/router/expo.modules.router/55.0.5/expo.modules.router-55.0.5.pom.md5 +0 -1
  41. package/local-maven-repo/expo/modules/router/expo.modules.router/55.0.5/expo.modules.router-55.0.5.pom.sha1 +0 -1
  42. package/local-maven-repo/expo/modules/router/expo.modules.router/55.0.5/expo.modules.router-55.0.5.pom.sha256 +0 -1
  43. package/local-maven-repo/expo/modules/router/expo.modules.router/55.0.5/expo.modules.router-55.0.5.pom.sha512 +0 -1
  44. /package/local-maven-repo/expo/modules/router/expo.modules.router/{55.0.5/expo.modules.router-55.0.5-sources.jar → 55.0.6/expo.modules.router-55.0.6-sources.jar} +0 -0
  45. /package/local-maven-repo/expo/modules/router/expo.modules.router/{55.0.5/expo.modules.router-55.0.5-sources.jar.md5 → 55.0.6/expo.modules.router-55.0.6-sources.jar.md5} +0 -0
  46. /package/local-maven-repo/expo/modules/router/expo.modules.router/{55.0.5/expo.modules.router-55.0.5-sources.jar.sha1 → 55.0.6/expo.modules.router-55.0.6-sources.jar.sha1} +0 -0
  47. /package/local-maven-repo/expo/modules/router/expo.modules.router/{55.0.5/expo.modules.router-55.0.5-sources.jar.sha256 → 55.0.6/expo.modules.router-55.0.6-sources.jar.sha256} +0 -0
  48. /package/local-maven-repo/expo/modules/router/expo.modules.router/{55.0.5/expo.modules.router-55.0.5-sources.jar.sha512 → 55.0.6/expo.modules.router-55.0.6-sources.jar.sha512} +0 -0
  49. /package/local-maven-repo/expo/modules/router/expo.modules.router/{55.0.5/expo.modules.router-55.0.5.aar → 55.0.6/expo.modules.router-55.0.6.aar} +0 -0
  50. /package/local-maven-repo/expo/modules/router/expo.modules.router/{55.0.5/expo.modules.router-55.0.5.aar.md5 → 55.0.6/expo.modules.router-55.0.6.aar.md5} +0 -0
  51. /package/local-maven-repo/expo/modules/router/expo.modules.router/{55.0.5/expo.modules.router-55.0.5.aar.sha1 → 55.0.6/expo.modules.router-55.0.6.aar.sha1} +0 -0
  52. /package/local-maven-repo/expo/modules/router/expo.modules.router/{55.0.5/expo.modules.router-55.0.5.aar.sha256 → 55.0.6/expo.modules.router-55.0.6.aar.sha256} +0 -0
  53. /package/local-maven-repo/expo/modules/router/expo.modules.router/{55.0.5/expo.modules.router-55.0.5.aar.sha512 → 55.0.6/expo.modules.router-55.0.6.aar.sha512} +0 -0
@@ -4,13 +4,13 @@ plugins {
4
4
  }
5
5
 
6
6
  group = 'expo.modules.router'
7
- version = '55.0.5'
7
+ version = '55.0.6'
8
8
 
9
9
  android {
10
10
  namespace "expo.modules.router"
11
11
  defaultConfig {
12
12
  versionCode 1
13
- versionName "55.0.5"
13
+ versionName "55.0.6"
14
14
  }
15
15
  lintOptions {
16
16
  abortOnError false
package/build/ExpoRoot.js CHANGED
@@ -101,21 +101,15 @@ function ContextNavigator({ context, location: initialLocation = initialUrl, wra
101
101
  // - linking.getInitialURL is used on native
102
102
  const serverContext = (0, react_1.useMemo)(() => {
103
103
  let contextType = {};
104
- if (initialLocation instanceof URL) {
105
- contextType = {
106
- location: {
107
- pathname: initialLocation.pathname + initialLocation.hash,
108
- search: initialLocation.search,
109
- },
110
- };
111
- }
112
- else if (typeof initialLocation === 'string') {
113
- // The initial location is a string, so we need to parse it into a URL.
114
- const url = (0, url_1.parseUrlUsingCustomBase)(initialLocation);
104
+ const url = typeof initialLocation === 'string'
105
+ ? (0, url_1.parseUrlUsingCustomBase)(initialLocation)
106
+ : initialLocation;
107
+ if (url && url instanceof URL) {
115
108
  contextType = {
116
109
  location: {
117
110
  pathname: url.pathname,
118
111
  search: url.search,
112
+ hash: url.hash,
119
113
  },
120
114
  };
121
115
  }
@@ -126,7 +120,7 @@ function ContextNavigator({ context, location: initialLocation = initialUrl, wra
126
120
  * e.g Static renders, units tests, etc
127
121
  */
128
122
  const serverUrl = serverContext.location
129
- ? `${serverContext.location.pathname}${serverContext.location.search}`
123
+ ? `${serverContext.location.pathname}${serverContext.location.search}${serverContext.location.hash ?? ''}`
130
124
  : undefined;
131
125
  const store = (0, router_store_1.useStore)(context, linking, serverUrl);
132
126
  (0, useDomComponentNavigation_1.useDomComponentNavigation)();
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoRoot.js","sourceRoot":"","sources":["../src/ExpoRoot.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6Db,4BA4BC;AAvFD,qDAKkC;AAClC,+CAA6F;AAC7F,+CAAmE;AACnE,mFAAkE;AAElE,2CAA2F;AAC3F,yFAAsF;AACtF,oEAAgG;AAEhG,8DAA8D;AAC9D,gFAAwF;AACxF,8DAA2D;AAC3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\n\nimport {\n LinkingOptions,\n NavigationAction,\n StackRouter,\n useNavigationBuilder,\n} from '@react-navigation/native';\nimport React, { type PropsWithChildren, Fragment, type ComponentType, useMemo } from 'react';\nimport { StatusBar, useColorScheme, Platform } from 'react-native';\nimport { SafeAreaProvider } from 'react-native-safe-area-context';\n\nimport { INTERNAL_SLOT_NAME, NOT_FOUND_ROUTE_NAME, SITEMAP_ROUTE_NAME } from './constants';\nimport { useDomComponentNavigation } from './domComponents/useDomComponentNavigation';\nimport { NavigationContainer as UpstreamNavigationContainer } from './fork/NavigationContainer';\nimport { ExpoLinkingOptions } from './getLinkingConfig';\nimport { store, useStore } from './global-state/router-store';\nimport { ServerContext, ServerContextType } from './global-state/serverLocationContext';\nimport { StoreContext } from './global-state/storeContext';\nimport { shouldAppendNotFound, shouldAppendSitemap } from './global-state/utils';\nimport { LinkPreviewContextProvider } from './link/preview/LinkPreviewContext';\nimport { Screen } from './primitives';\nimport { initScreensFeatureFlags } from './screensFeatureFlags';\nimport { RequireContext } from './types';\nimport { canOverrideStatusBarBehavior } from './utils/statusbar';\nimport { parseUrlUsingCustomBase } from './utils/url';\nimport { Sitemap } from './views/Sitemap';\nimport * as SplashScreen from './views/Splash';\nimport { Unmatched } from './views/Unmatched';\n\nexport type ExpoRootProps = {\n context: RequireContext;\n location?: URL | string;\n wrapper?: ComponentType<PropsWithChildren>;\n linking?: Partial<ExpoLinkingOptions>;\n};\n\nexport type NativeIntent = {\n redirectSystemPath?: (event: {\n path: string | null;\n initial: boolean;\n }) => Promise<string | null | undefined> | string | null | undefined;\n};\n\nconst isTestEnv = process.env.NODE_ENV === 'test';\n\nconst INITIAL_METRICS =\n Platform.OS === 'web' || isTestEnv\n ? {\n frame: { x: 0, y: 0, width: 0, height: 0 },\n insets: { top: 0, left: 0, right: 0, bottom: 0 },\n }\n : undefined;\n\nconst documentTitle = {\n enabled: false,\n};\n\n/**\n * @hidden\n */\nexport function ExpoRoot({ wrapper: ParentWrapper = Fragment, ...props }: ExpoRootProps) {\n initScreensFeatureFlags();\n /*\n * Due to static rendering we need to wrap these top level views in second wrapper\n * View's like <SafeAreaProvider /> generate a <div> so if the parent wrapper\n * is a HTML document, we need to ensure its inside the <body>\n */\n const wrapper = useMemo(\n () =>\n ({ children }: PropsWithChildren) => {\n return (\n <ParentWrapper>\n <LinkPreviewContextProvider>\n <SafeAreaProvider\n // SSR support\n initialMetrics={INITIAL_METRICS}>\n {/* Users can override this by adding another StatusBar element anywhere higher in the component tree. */}\n {canOverrideStatusBarBehavior && <AutoStatusBar />}\n {children}\n </SafeAreaProvider>\n </LinkPreviewContextProvider>\n </ParentWrapper>\n );\n },\n [ParentWrapper]\n );\n\n return <ContextNavigator {...props} wrapper={wrapper} />;\n}\n\nfunction AutoStatusBar() {\n return <StatusBar barStyle={useColorScheme() === 'light' ? 'dark-content' : 'light-content'} />;\n}\n\nconst initialUrl =\n Platform.OS === 'web' && typeof window !== 'undefined'\n ? new URL(window.location.href)\n : undefined;\n\nfunction ContextNavigator({\n context,\n location: initialLocation = initialUrl,\n wrapper: WrapperComponent = Fragment,\n linking = {},\n}: ExpoRootProps) {\n // location and linking.getInitialURL are both used to initialize the router state\n // - location is used on web and during static rendering\n // - linking.getInitialURL is used on native\n const serverContext = useMemo(() => {\n let contextType: ServerContextType = {};\n\n if (initialLocation instanceof URL) {\n contextType = {\n location: {\n pathname: initialLocation.pathname + initialLocation.hash,\n search: initialLocation.search,\n },\n };\n } else if (typeof initialLocation === 'string') {\n // The initial location is a string, so we need to parse it into a URL.\n const url = parseUrlUsingCustomBase(initialLocation);\n contextType = {\n location: {\n pathname: url.pathname,\n search: url.search,\n },\n };\n }\n\n return contextType;\n }, []);\n\n /*\n * The serverUrl is an initial URL used in server rendering environments.\n * e.g Static renders, units tests, etc\n */\n const serverUrl = serverContext.location\n ? `${serverContext.location.pathname}${serverContext.location.search}`\n : undefined;\n\n const store = useStore(context, linking, serverUrl);\n\n useDomComponentNavigation();\n\n if (store.shouldShowTutorial()) {\n SplashScreen.hideAsync();\n if (process.env.NODE_ENV === 'development') {\n const Tutorial = require('./onboard/Tutorial').Tutorial;\n return (\n <WrapperComponent>\n <Tutorial />\n </WrapperComponent>\n );\n } else {\n // Ensure tutorial styles are stripped in production.\n return null;\n }\n }\n\n return (\n <StoreContext.Provider value={store}>\n <UpstreamNavigationContainer\n ref={store.navigationRef}\n initialState={store.state}\n linking={store.linking as LinkingOptions<any>}\n onUnhandledAction={onUnhandledAction}\n onStateChange={store.onStateChange}\n documentTitle={documentTitle}\n onReady={store.onReady}>\n <ServerContext.Provider value={serverContext}>\n <WrapperComponent>\n <Content />\n </WrapperComponent>\n </ServerContext.Provider>\n </UpstreamNavigationContainer>\n </StoreContext.Provider>\n );\n}\n\nfunction Content() {\n const children = [<Screen name={INTERNAL_SLOT_NAME} component={store.rootComponent} />];\n if (shouldAppendNotFound()) {\n children.push(<Screen name={NOT_FOUND_ROUTE_NAME} component={Unmatched} />);\n }\n if (shouldAppendSitemap()) {\n children.push(<Screen name={SITEMAP_ROUTE_NAME} component={Sitemap} />);\n }\n const { state, descriptors, NavigationContent } = useNavigationBuilder(StackRouter, {\n children,\n id: INTERNAL_SLOT_NAME,\n });\n\n return (\n <NavigationContent>{descriptors[state.routes[state.index].key].render()}</NavigationContent>\n );\n}\n\nlet onUnhandledAction: (action: NavigationAction) => void;\n\nif (process.env.NODE_ENV !== 'production') {\n onUnhandledAction = (action: NavigationAction) => {\n const payload: Record<string, any> | undefined = action.payload;\n\n let message = `The action '${action.type}'${\n payload ? ` with payload ${JSON.stringify(action.payload)}` : ''\n } was not handled by any navigator.`;\n\n switch (action.type) {\n case 'NAVIGATE':\n case 'PUSH':\n case 'REPLACE':\n case 'JUMP_TO':\n if (payload?.name) {\n message += `\\n\\nDo you have a route named '${payload.name}'?`;\n } else {\n message += `\\n\\nYou need to pass the name of the screen to navigate to. This may be a bug.`;\n }\n\n break;\n case 'GO_BACK':\n case 'POP':\n case 'POP_TO_TOP':\n message += `\\n\\nIs there any screen to go back to?`;\n break;\n case 'OPEN_DRAWER':\n case 'CLOSE_DRAWER':\n case 'TOGGLE_DRAWER':\n message += `\\n\\nIs your screen inside a Drawer navigator?`;\n break;\n }\n\n message += `\\n\\nThis is a development-only warning and won't be shown in production.`;\n\n if (process.env.NODE_ENV === 'test') {\n throw new Error(message);\n }\n console.error(message);\n };\n} else {\n onUnhandledAction = function () {};\n}\n"]}
1
+ {"version":3,"file":"ExpoRoot.js","sourceRoot":"","sources":["../src/ExpoRoot.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6Db,4BA4BC;AAvFD,qDAKkC;AAClC,+CAA6F;AAC7F,+CAAmE;AACnE,mFAAkE;AAElE,2CAA2F;AAC3F,yFAAsF;AACtF,oEAAgG;AAEhG,8DAA8D;AAC9D,gFAAwF;AACxF,8DAA2D;AAC3D,gDAAiF;AACjF,0EAA+E;AAC/E,6CAAsC;AACtC,+DAAgE;AAEhE,iDAAiE;AACjE,qCAAsD;AACtD,6CAA0C;AAC1C,6DAA+C;AAC/C,iDAA8C;AAgB9C,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,MAAM,CAAC;AAElD,MAAM,eAAe,GACnB,uBAAQ,CAAC,EAAE,KAAK,KAAK,IAAI,SAAS;IAChC,CAAC,CAAC;QACE,KAAK,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE;QAC1C,MAAM,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE;KACjD;IACH,CAAC,CAAC,SAAS,CAAC;AAEhB,MAAM,aAAa,GAAG;IACpB,OAAO,EAAE,KAAK;CACf,CAAC;AAEF;;GAEG;AACH,SAAgB,QAAQ,CAAC,EAAE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AK,YAAY;gBACf,OAAO,IAAI,wCAAwC,CAAC;gBACpD,MAAM;YACR,KAAK,aAAa,CAAC;YACnB,KAAK,cAAc,CAAC;YACpB,KAAK,eAAe;gBAClB,OAAO,IAAI,+CAA+C,CAAC;gBAC3D,MAAM;QACV,CAAC;QAED,OAAO,IAAI,0EAA0E,CAAC;QAEtF,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,MAAM,EAAE,CAAC;YACpC,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;QAC3B,CAAC;QACD,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACzB,CAAC,CAAC;AACJ,CAAC;KAAM,CAAC;IACN,iBAAiB,GAAG,cAAa,CAAC,CAAC;AACrC,CAAC","sourcesContent":["'use client';\n\nimport {\n LinkingOptions,\n NavigationAction,\n StackRouter,\n useNavigationBuilder,\n} from '@react-navigation/native';\nimport React, { type PropsWithChildren, Fragment, type ComponentType, useMemo } from 'react';\nimport { StatusBar, useColorScheme, Platform } from 'react-native';\nimport { SafeAreaProvider } from 'react-native-safe-area-context';\n\nimport { INTERNAL_SLOT_NAME, NOT_FOUND_ROUTE_NAME, SITEMAP_ROUTE_NAME } from './constants';\nimport { useDomComponentNavigation } from './domComponents/useDomComponentNavigation';\nimport { NavigationContainer as UpstreamNavigationContainer } from './fork/NavigationContainer';\nimport { ExpoLinkingOptions } from './getLinkingConfig';\nimport { store, useStore } from './global-state/router-store';\nimport { ServerContext, ServerContextType } from './global-state/serverLocationContext';\nimport { StoreContext } from './global-state/storeContext';\nimport { shouldAppendNotFound, shouldAppendSitemap } from './global-state/utils';\nimport { LinkPreviewContextProvider } from './link/preview/LinkPreviewContext';\nimport { Screen } from './primitives';\nimport { initScreensFeatureFlags } from './screensFeatureFlags';\nimport { RequireContext } from './types';\nimport { canOverrideStatusBarBehavior } from './utils/statusbar';\nimport { parseUrlUsingCustomBase } from './utils/url';\nimport { Sitemap } from './views/Sitemap';\nimport * as SplashScreen from './views/Splash';\nimport { Unmatched } from './views/Unmatched';\n\nexport type ExpoRootProps = {\n context: RequireContext;\n location?: URL | string;\n wrapper?: ComponentType<PropsWithChildren>;\n linking?: Partial<ExpoLinkingOptions>;\n};\n\nexport type NativeIntent = {\n redirectSystemPath?: (event: {\n path: string | null;\n initial: boolean;\n }) => Promise<string | null | undefined> | string | null | undefined;\n};\n\nconst isTestEnv = process.env.NODE_ENV === 'test';\n\nconst INITIAL_METRICS =\n Platform.OS === 'web' || isTestEnv\n ? {\n frame: { x: 0, y: 0, width: 0, height: 0 },\n insets: { top: 0, left: 0, right: 0, bottom: 0 },\n }\n : undefined;\n\nconst documentTitle = {\n enabled: false,\n};\n\n/**\n * @hidden\n */\nexport function ExpoRoot({ wrapper: ParentWrapper = Fragment, ...props }: ExpoRootProps) {\n initScreensFeatureFlags();\n /*\n * Due to static rendering we need to wrap these top level views in second wrapper\n * View's like <SafeAreaProvider /> generate a <div> so if the parent wrapper\n * is a HTML document, we need to ensure its inside the <body>\n */\n const wrapper = useMemo(\n () =>\n ({ children }: PropsWithChildren) => {\n return (\n <ParentWrapper>\n <LinkPreviewContextProvider>\n <SafeAreaProvider\n // SSR support\n initialMetrics={INITIAL_METRICS}>\n {/* Users can override this by adding another StatusBar element anywhere higher in the component tree. */}\n {canOverrideStatusBarBehavior && <AutoStatusBar />}\n {children}\n </SafeAreaProvider>\n </LinkPreviewContextProvider>\n </ParentWrapper>\n );\n },\n [ParentWrapper]\n );\n\n return <ContextNavigator {...props} wrapper={wrapper} />;\n}\n\nfunction AutoStatusBar() {\n return <StatusBar barStyle={useColorScheme() === 'light' ? 'dark-content' : 'light-content'} />;\n}\n\nconst initialUrl =\n Platform.OS === 'web' && typeof window !== 'undefined'\n ? new URL(window.location.href)\n : undefined;\n\nfunction ContextNavigator({\n context,\n location: initialLocation = initialUrl,\n wrapper: WrapperComponent = Fragment,\n linking = {},\n}: ExpoRootProps) {\n // location and linking.getInitialURL are both used to initialize the router state\n // - location is used on web and during static rendering\n // - linking.getInitialURL is used on native\n const serverContext = useMemo(() => {\n let contextType: ServerContextType = {};\n\n const url =\n typeof initialLocation === 'string'\n ? parseUrlUsingCustomBase(initialLocation)\n : initialLocation;\n\n if (url && url instanceof URL) {\n contextType = {\n location: {\n pathname: url.pathname,\n search: url.search,\n hash: url.hash,\n },\n };\n }\n\n return contextType;\n }, []);\n\n /*\n * The serverUrl is an initial URL used in server rendering environments.\n * e.g Static renders, units tests, etc\n */\n const serverUrl = serverContext.location\n ? `${serverContext.location.pathname}${serverContext.location.search}${serverContext.location.hash ?? ''}`\n : undefined;\n\n const store = useStore(context, linking, serverUrl);\n\n useDomComponentNavigation();\n\n if (store.shouldShowTutorial()) {\n SplashScreen.hideAsync();\n if (process.env.NODE_ENV === 'development') {\n const Tutorial = require('./onboard/Tutorial').Tutorial;\n return (\n <WrapperComponent>\n <Tutorial />\n </WrapperComponent>\n );\n } else {\n // Ensure tutorial styles are stripped in production.\n return null;\n }\n }\n\n return (\n <StoreContext.Provider value={store}>\n <UpstreamNavigationContainer\n ref={store.navigationRef}\n initialState={store.state}\n linking={store.linking as LinkingOptions<any>}\n onUnhandledAction={onUnhandledAction}\n onStateChange={store.onStateChange}\n documentTitle={documentTitle}\n onReady={store.onReady}>\n <ServerContext.Provider value={serverContext}>\n <WrapperComponent>\n <Content />\n </WrapperComponent>\n </ServerContext.Provider>\n </UpstreamNavigationContainer>\n </StoreContext.Provider>\n );\n}\n\nfunction Content() {\n const children = [<Screen name={INTERNAL_SLOT_NAME} component={store.rootComponent} />];\n if (shouldAppendNotFound()) {\n children.push(<Screen name={NOT_FOUND_ROUTE_NAME} component={Unmatched} />);\n }\n if (shouldAppendSitemap()) {\n children.push(<Screen name={SITEMAP_ROUTE_NAME} component={Sitemap} />);\n }\n const { state, descriptors, NavigationContent } = useNavigationBuilder(StackRouter, {\n children,\n id: INTERNAL_SLOT_NAME,\n });\n\n return (\n <NavigationContent>{descriptors[state.routes[state.index].key].render()}</NavigationContent>\n );\n}\n\nlet onUnhandledAction: (action: NavigationAction) => void;\n\nif (process.env.NODE_ENV !== 'production') {\n onUnhandledAction = (action: NavigationAction) => {\n const payload: Record<string, any> | undefined = action.payload;\n\n let message = `The action '${action.type}'${\n payload ? ` with payload ${JSON.stringify(action.payload)}` : ''\n } was not handled by any navigator.`;\n\n switch (action.type) {\n case 'NAVIGATE':\n case 'PUSH':\n case 'REPLACE':\n case 'JUMP_TO':\n if (payload?.name) {\n message += `\\n\\nDo you have a route named '${payload.name}'?`;\n } else {\n message += `\\n\\nYou need to pass the name of the screen to navigate to. This may be a bug.`;\n }\n\n break;\n case 'GO_BACK':\n case 'POP':\n case 'POP_TO_TOP':\n message += `\\n\\nIs there any screen to go back to?`;\n break;\n case 'OPEN_DRAWER':\n case 'CLOSE_DRAWER':\n case 'TOGGLE_DRAWER':\n message += `\\n\\nIs your screen inside a Drawer navigator?`;\n break;\n }\n\n message += `\\n\\nThis is a development-only warning and won't be shown in production.`;\n\n if (process.env.NODE_ENV === 'test') {\n throw new Error(message);\n }\n console.error(message);\n };\n} else {\n onUnhandledAction = function () {};\n}\n"]}
@@ -257,7 +257,7 @@ function getPathDataFromState(state, options) {
257
257
  }
258
258
  // END FORK
259
259
  if (!focusedParams) {
260
- focusedParams = focusedRoute.params;
260
+ focusedParams = focusedRoute.params ? { ...focusedRoute.params } : undefined;
261
261
  }
262
262
  if (route.state) {
263
263
  path += '/';
@@ -1 +1 @@
1
- {"version":3,"file":"getPathFromState.js","sourceRoot":"","sources":["../../src/fork/getPathFromState.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2EA,4CAKC;AAED,oDA6PC;AAsDD,sCAUC;AA7YD,0DAA4C;AAE5C,+DAAiD;AAEjD,0DAAqE;AAoBrE,WAAW;AAEX,MAAM,cAAc,GAAG,CAAC,KAAY,EAAqC,EAAE;IACzE,MAAM,KAAK,GACT,OAAO,KAAK,CAAC,KAAK,KAAK,QAAQ;QAC7B,C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,OAA8B,EAC9B,OAAgB,EACY,EAAE,CAC9B,MAAM,CAAC,WAAW,CAChB,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE;IACxC,MAAM,MAAM,GAAG,gBAAgB,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;IAE5C,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AACxB,CAAC,CAAC,CACH,CAAC;AAEJ,SAAgB,aAAa,CAC3B,IAAY,EACZ,UAA8B,OAAO,CAAC,GAAG,CAAC,aAAa;IAEvD,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa,EAAE,CAAC;QAC3C,IAAI,OAAO,EAAE,CAAC;YACZ,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC;QACrE,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import { PathConfig, PathConfigMap } from '@react-navigation/native';\nimport type { NavigationState, PartialState, Route } from '@react-navigation/routers';\nimport * as queryString from 'query-string';\n\nimport * as expo from './getPathFromState-forks';\nimport type { ExpoConfigItem, ExpoOptions } from './getPathFromState-forks';\nimport { removeInternalExpoRouterParams } from '../navigationParams';\n\n// START FORK\nexport type Options<ParamList extends object> = ExpoOptions & {\n path?: string;\n initialRouteName?: string;\n screens: PathConfigMap<ParamList>;\n};\n// END FORK\n\nexport type State = NavigationState | Omit<PartialState<NavigationState>, 'stale'>;\n\nexport type StringifyConfig = Record<string, (value: any) => string>;\n\n// START FORK\ntype ConfigItem = ExpoConfigItem & {\n pattern?: string;\n stringify?: StringifyConfig;\n screens?: Record<string, ConfigItem>;\n};\n// END FORK\n\nconst getActiveRoute = (state: State): { name: string; params?: object } => {\n const route =\n typeof state.index === 'number'\n ? state.routes[state.index]\n : state.routes[state.routes.length - 1];\n\n if (route.state) {\n return getActiveRoute(route.state);\n }\n\n return route;\n};\n\nlet cachedNormalizedConfigs: [PathConfigMap<object> | undefined, Record<string, ConfigItem>] = [\n undefined,\n {},\n];\n\n/**\n * Utility to serialize a navigation state object to a path string.\n *\n * @example\n * ```js\n * getPathFromState(\n * {\n * routes: [\n * {\n * name: 'Chat',\n * params: { author: 'Jane', id: 42 },\n * },\n * ],\n * },\n * {\n * screens: {\n * Chat: {\n * path: 'chat/:author/:id',\n * stringify: { author: author => author.toLowerCase() }\n * }\n * }\n * }\n * )\n * ```\n *\n * @param state Navigation state to serialize.\n * @param options Extra options to fine-tune how to serialize the path.\n * @returns Path representing the state, e.g. /foo/bar?count=42.\n */\nexport function getPathFromState<ParamList extends object>(\n state: State,\n options?: Options<ParamList>\n): string {\n return getPathDataFromState(state, options).path;\n}\n\nexport function getPathDataFromState<ParamList extends object>(\n state: State,\n options?: Options<ParamList>\n) {\n if (state == null) {\n throw Error(\"Got 'undefined' for the navigation state. You must pass a valid state object.\");\n }\n\n if (options) {\n // START FORK\n expo.validatePathConfig(options);\n // validatePathConfig(options);\n // END FORK\n }\n\n // Create a normalized configs object which will be easier to use\n if (cachedNormalizedConfigs[0] !== options?.screens) {\n cachedNormalizedConfigs = [\n options?.screens,\n options?.screens ? createNormalizedConfigs(options.screens) : {},\n ];\n }\n const configs: Record<string, ConfigItem> = cachedNormalizedConfigs[1];\n\n let path = '/';\n let current: State | undefined = state;\n\n const allParams: Record<string, any> = {};\n\n while (current) {\n let index = typeof current.index === 'number' ? current.index : 0;\n let route = current.routes[index] as Route<string> & {\n state?: State;\n };\n\n let pattern: string | undefined;\n\n let focusedParams: Record<string, any> | undefined;\n const focusedRoute = getActiveRoute(state);\n let currentOptions = configs;\n\n // Keep all the route names that appeared during going deeper in config in case the pattern is resolved to undefined\n const nestedRouteNames: string[] = [];\n\n let hasNext = true;\n\n while (route.name in currentOptions && hasNext) {\n pattern = currentOptions[route.name].pattern;\n\n nestedRouteNames.push(route.name);\n\n if (route.params) {\n const stringify = currentOptions[route.name]?.stringify;\n\n // START FORK\n // This mutates allParams\n const currentParams = expo.fixCurrentParams(allParams, route, stringify);\n\n // const currentParams = Object.fromEntries(\n // Object.entries(route.params).map(([key, value]) => [\n // key,\n // stringify?.[key] ? stringify[key](value) : String(value),\n // ])\n // );\n\n // if (pattern) {\n // Object.assign(allParams, currentParams);\n // }\n // END FORK\n\n if (focusedRoute === route) {\n // If this is the focused route, keep the params for later use\n // We save it here since it's been stringified already\n focusedParams = { ...currentParams };\n\n pattern\n ?.split('/')\n .filter((p) => expo.isDynamicPart(p))\n // eslint-disable-next-line no-loop-func\n .forEach((p) => {\n const name = expo.getParamName(p);\n\n // Remove the params present in the pattern since we'll only use the rest for query string\n if (focusedParams) {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete focusedParams[name];\n }\n });\n }\n }\n\n // If there is no `screens` property or no nested state, we return pattern\n if (!currentOptions[route.name].screens || route.state === undefined) {\n // START FORK\n // Expo Router allows you to navigate to a (group) and not specify a target screen\n // This is different from React Navigation, which requires a target screen\n // We need to handle this case here, by selecting either the index screen or the first screen of the group\n\n // IMPORTANT: This does not affect groups that use _layout files with initialRouteNames\n // Layout files create a new route config. This only affects groups without layouts that have their screens\n // hoisted.\n\n // Example:\n // - /home/_layout\n // - /home/(a|b|c)/index --> Hoisted to /home/_layout navigator\n // - /home/(a|b|c)/other --> Hoisted to /home/_layout navigator\n // - /home/(profile)/me --> Hoisted to /home/_layout navigator\n //\n // route.push('/home/(a)') --> This should navigate to /home/(a)/index\n // route.push('/home/(profile)') --> This should navigate to /home/(profile)/me\n const screens = currentOptions[route.name].screens;\n\n // Determine what screen the user wants to navigate to. If no screen is specified, assume there is an index screen\n // In the examples above, this ensures that /home/(a) navigates to /home/(a)/index\n const targetScreen =\n // This is typed as unknown, so we need to add these extra assertions\n route.params && 'screen' in route.params && typeof route.params.screen === 'string'\n ? route.params.screen\n : 'index';\n\n // If the target screen is not in the screens object, default to the first screen\n // In the examples above, this ensures that /home/(profile) navigates to /home/(profile)/me\n // As there is no index screen in the group\n const screen = screens\n ? screens[targetScreen]\n ? targetScreen\n : Object.keys(screens)[0]\n : undefined;\n\n if (screen && screens && currentOptions[route.name].screens?.[screen]) {\n const nestedParams = (route.params as { params?: object } | undefined)?.params;\n route = { ...screens[screen], name: screen, key: screen, params: nestedParams };\n currentOptions = screens;\n } else {\n hasNext = false;\n }\n // hasNext = false;\n // END FORK\n } else {\n index =\n typeof route.state.index === 'number' ? route.state.index : route.state.routes.length - 1;\n\n const nextRoute = route.state.routes[index];\n const nestedConfig = currentOptions[route.name].screens;\n\n // if there is config for next route name, we go deeper\n if (nestedConfig && nextRoute.name in nestedConfig) {\n route = nextRoute as Route<string> & { state?: State };\n currentOptions = nestedConfig;\n } else {\n // If not, there is no sense in going deeper in config\n hasNext = false;\n }\n }\n }\n\n if (pattern === undefined) {\n pattern = nestedRouteNames.join('/');\n }\n\n if (currentOptions[route.name] !== undefined) {\n // START FORK\n path += expo.getPathWithConventionsCollapsed({\n ...options,\n pattern,\n route,\n params: allParams,\n initialRouteName: configs[route.name]?.initialRouteName,\n });\n // path += pattern\n // .split('/')\n // .map((p) => {\n // const name = getParamName(p);\n\n // // We don't know what to show for wildcard patterns\n // // Showing the route name seems ok, though whatever we show here will be incorrect\n // // Since the page doesn't actually exist\n // if (p === '*') {\n // return route.name;\n // }\n\n // // If the path has a pattern for a param, put the param in the path\n // if (p.startsWith(':')) {\n // const value = allParams[name];\n\n // if (value === undefined && p.endsWith('?')) {\n // // Optional params without value assigned in route.params should be ignored\n // return '';\n // }\n\n // // Valid characters according to\n // // https://datatracker.ietf.org/doc/html/rfc3986#section-3.3 (see pchar definition)\n // return String(value).replace(/[^A-Za-z0-9\\-._~!$&'()*+,;=:@]/g, (char) =>\n // encodeURIComponent(char)\n // );\n // }\n\n // return encodeURIComponent(p);\n // })\n // .join('/');\n // } else {\n } else if (!route.name.startsWith('+')) {\n path += encodeURIComponent(route.name);\n }\n // END FORK\n\n if (!focusedParams) {\n focusedParams = focusedRoute.params;\n }\n\n if (route.state) {\n path += '/';\n } else if (focusedParams) {\n for (const param in focusedParams) {\n if (focusedParams[param] === 'undefined') {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete focusedParams[param];\n }\n }\n\n // START FORK\n delete focusedParams['#'];\n focusedParams = removeInternalExpoRouterParams(focusedParams);\n // END FORK\n\n const query = queryString.stringify(focusedParams, { sort: false });\n if (query) {\n path += `?${query}`;\n }\n }\n\n current = route.state;\n }\n\n // Remove multiple as well as trailing slashes\n path = path.replace(/\\/+/g, '/');\n path = path.length > 1 ? path.replace(/\\/$/, '') : path;\n\n // Include the root path if specified\n if (options?.path) {\n path = joinPaths(options.path, path);\n }\n\n // START FORK\n path = expo.appendBaseUrl(path);\n if (allParams['#']) {\n path += `#${allParams['#']}`;\n }\n // END FORK\n\n // START FORK\n return { path, params: allParams };\n // END FORK\n}\n\n// const getParamName = (pattern: string) => pattern.replace(/^:/, '').replace(/\\?$/, '');\n\nconst joinPaths = (...paths: string[]): string =>\n ([] as string[])\n .concat(...paths.map((p) => p.split('/')))\n .filter(Boolean)\n .join('/');\n\nconst createConfigItem = (\n config: PathConfig<object> | string,\n parentPattern?: string\n): ConfigItem => {\n if (typeof config === 'string') {\n // If a string is specified as the value of the key(e.g. Foo: '/path'), use it as the pattern\n const pattern = parentPattern ? joinPaths(parentPattern, config) : config;\n\n return { pattern };\n }\n\n if (config.exact && config.path === undefined) {\n throw new Error(\n \"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: ''`.\"\n );\n }\n\n // If an object is specified as the value (e.g. Foo: { ... }),\n // It can have `path` property and `screens` prop which has nested configs\n const pattern =\n config.exact !== true ? joinPaths(parentPattern || '', config.path || '') : config.path || '';\n\n const screens = config.screens ? createNormalizedConfigs(config.screens, pattern) : undefined;\n\n return {\n // Normalize pattern to remove any leading, trailing slashes, duplicate slashes etc.\n pattern: pattern?.split('/').filter(Boolean).join('/'),\n stringify: config.stringify,\n screens,\n };\n};\n\nconst createNormalizedConfigs = (\n options: PathConfigMap<object>,\n pattern?: string\n): Record<string, ConfigItem> =>\n Object.fromEntries(\n Object.entries(options).map(([name, c]) => {\n const result = createConfigItem(c, pattern);\n\n return [name, result];\n })\n );\n\nexport function appendBaseUrl(\n path: string,\n baseUrl: string | undefined = process.env.EXPO_BASE_URL\n) {\n if (process.env.NODE_ENV !== 'development') {\n if (baseUrl) {\n return `/${baseUrl.replace(/^\\/+/, '').replace(/\\/$/, '')}${path}`;\n }\n }\n return path;\n}\n"]}
1
+ {"version":3,"file":"getPathFromState.js","sourceRoot":"","sources":["../../src/fork/getPathFromState.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2EA,4CAKC;AAED,oDA6PC;AAsDD,sCAUC;AA7YD,0DAA4C;AAE5C,+DAAiD;AAEjD,0DAAqE;AAoBrE,WAAW;AAEX,MAAM,cAAc,GAAG,CAAC,KAAY,EAAqC,EAAE;IACzE,MAAM,KAAK,GACT,OAAO,KAAK,CAAC,KAAK,KAAK,QAAQ;QAC7B,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC;QAC3B,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAE5C,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;QAChB,OAAO,cAAc,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACrC,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF,IAAI,uBAAuB,GAAoE;IAC7F,SAAS;IACT,EAAE;CACH,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,SAAgB,gBAAgB,CAC9B,KAAY,EACZ,OAA4B;IAE5B,OAAO,oBA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IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa,EAAE,CAAC;QAC3C,IAAI,OAAO,EAAE,CAAC;YACZ,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC;QACrE,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import { PathConfig, PathConfigMap } from '@react-navigation/native';\nimport type { NavigationState, PartialState, Route } from '@react-navigation/routers';\nimport * as queryString from 'query-string';\n\nimport * as expo from './getPathFromState-forks';\nimport type { ExpoConfigItem, ExpoOptions } from './getPathFromState-forks';\nimport { removeInternalExpoRouterParams } from '../navigationParams';\n\n// START FORK\nexport type Options<ParamList extends object> = ExpoOptions & {\n path?: string;\n initialRouteName?: string;\n screens: PathConfigMap<ParamList>;\n};\n// END FORK\n\nexport type State = NavigationState | Omit<PartialState<NavigationState>, 'stale'>;\n\nexport type StringifyConfig = Record<string, (value: any) => string>;\n\n// START FORK\ntype ConfigItem = ExpoConfigItem & {\n pattern?: string;\n stringify?: StringifyConfig;\n screens?: Record<string, ConfigItem>;\n};\n// END FORK\n\nconst getActiveRoute = (state: State): { name: string; params?: object } => {\n const route =\n typeof state.index === 'number'\n ? state.routes[state.index]\n : state.routes[state.routes.length - 1];\n\n if (route.state) {\n return getActiveRoute(route.state);\n }\n\n return route;\n};\n\nlet cachedNormalizedConfigs: [PathConfigMap<object> | undefined, Record<string, ConfigItem>] = [\n undefined,\n {},\n];\n\n/**\n * Utility to serialize a navigation state object to a path string.\n *\n * @example\n * ```js\n * getPathFromState(\n * {\n * routes: [\n * {\n * name: 'Chat',\n * params: { author: 'Jane', id: 42 },\n * },\n * ],\n * },\n * {\n * screens: {\n * Chat: {\n * path: 'chat/:author/:id',\n * stringify: { author: author => author.toLowerCase() }\n * }\n * }\n * }\n * )\n * ```\n *\n * @param state Navigation state to serialize.\n * @param options Extra options to fine-tune how to serialize the path.\n * @returns Path representing the state, e.g. /foo/bar?count=42.\n */\nexport function getPathFromState<ParamList extends object>(\n state: State,\n options?: Options<ParamList>\n): string {\n return getPathDataFromState(state, options).path;\n}\n\nexport function getPathDataFromState<ParamList extends object>(\n state: State,\n options?: Options<ParamList>\n) {\n if (state == null) {\n throw Error(\"Got 'undefined' for the navigation state. You must pass a valid state object.\");\n }\n\n if (options) {\n // START FORK\n expo.validatePathConfig(options);\n // validatePathConfig(options);\n // END FORK\n }\n\n // Create a normalized configs object which will be easier to use\n if (cachedNormalizedConfigs[0] !== options?.screens) {\n cachedNormalizedConfigs = [\n options?.screens,\n options?.screens ? createNormalizedConfigs(options.screens) : {},\n ];\n }\n const configs: Record<string, ConfigItem> = cachedNormalizedConfigs[1];\n\n let path = '/';\n let current: State | undefined = state;\n\n const allParams: Record<string, any> = {};\n\n while (current) {\n let index = typeof current.index === 'number' ? current.index : 0;\n let route = current.routes[index] as Route<string> & {\n state?: State;\n };\n\n let pattern: string | undefined;\n\n let focusedParams: Record<string, any> | undefined;\n const focusedRoute = getActiveRoute(state);\n let currentOptions = configs;\n\n // Keep all the route names that appeared during going deeper in config in case the pattern is resolved to undefined\n const nestedRouteNames: string[] = [];\n\n let hasNext = true;\n\n while (route.name in currentOptions && hasNext) {\n pattern = currentOptions[route.name].pattern;\n\n nestedRouteNames.push(route.name);\n\n if (route.params) {\n const stringify = currentOptions[route.name]?.stringify;\n\n // START FORK\n // This mutates allParams\n const currentParams = expo.fixCurrentParams(allParams, route, stringify);\n\n // const currentParams = Object.fromEntries(\n // Object.entries(route.params).map(([key, value]) => [\n // key,\n // stringify?.[key] ? stringify[key](value) : String(value),\n // ])\n // );\n\n // if (pattern) {\n // Object.assign(allParams, currentParams);\n // }\n // END FORK\n\n if (focusedRoute === route) {\n // If this is the focused route, keep the params for later use\n // We save it here since it's been stringified already\n focusedParams = { ...currentParams };\n\n pattern\n ?.split('/')\n .filter((p) => expo.isDynamicPart(p))\n // eslint-disable-next-line no-loop-func\n .forEach((p) => {\n const name = expo.getParamName(p);\n\n // Remove the params present in the pattern since we'll only use the rest for query string\n if (focusedParams) {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete focusedParams[name];\n }\n });\n }\n }\n\n // If there is no `screens` property or no nested state, we return pattern\n if (!currentOptions[route.name].screens || route.state === undefined) {\n // START FORK\n // Expo Router allows you to navigate to a (group) and not specify a target screen\n // This is different from React Navigation, which requires a target screen\n // We need to handle this case here, by selecting either the index screen or the first screen of the group\n\n // IMPORTANT: This does not affect groups that use _layout files with initialRouteNames\n // Layout files create a new route config. This only affects groups without layouts that have their screens\n // hoisted.\n\n // Example:\n // - /home/_layout\n // - /home/(a|b|c)/index --> Hoisted to /home/_layout navigator\n // - /home/(a|b|c)/other --> Hoisted to /home/_layout navigator\n // - /home/(profile)/me --> Hoisted to /home/_layout navigator\n //\n // route.push('/home/(a)') --> This should navigate to /home/(a)/index\n // route.push('/home/(profile)') --> This should navigate to /home/(profile)/me\n const screens = currentOptions[route.name].screens;\n\n // Determine what screen the user wants to navigate to. If no screen is specified, assume there is an index screen\n // In the examples above, this ensures that /home/(a) navigates to /home/(a)/index\n const targetScreen =\n // This is typed as unknown, so we need to add these extra assertions\n route.params && 'screen' in route.params && typeof route.params.screen === 'string'\n ? route.params.screen\n : 'index';\n\n // If the target screen is not in the screens object, default to the first screen\n // In the examples above, this ensures that /home/(profile) navigates to /home/(profile)/me\n // As there is no index screen in the group\n const screen = screens\n ? screens[targetScreen]\n ? targetScreen\n : Object.keys(screens)[0]\n : undefined;\n\n if (screen && screens && currentOptions[route.name].screens?.[screen]) {\n const nestedParams = (route.params as { params?: object } | undefined)?.params;\n route = { ...screens[screen], name: screen, key: screen, params: nestedParams };\n currentOptions = screens;\n } else {\n hasNext = false;\n }\n // hasNext = false;\n // END FORK\n } else {\n index =\n typeof route.state.index === 'number' ? route.state.index : route.state.routes.length - 1;\n\n const nextRoute = route.state.routes[index];\n const nestedConfig = currentOptions[route.name].screens;\n\n // if there is config for next route name, we go deeper\n if (nestedConfig && nextRoute.name in nestedConfig) {\n route = nextRoute as Route<string> & { state?: State };\n currentOptions = nestedConfig;\n } else {\n // If not, there is no sense in going deeper in config\n hasNext = false;\n }\n }\n }\n\n if (pattern === undefined) {\n pattern = nestedRouteNames.join('/');\n }\n\n if (currentOptions[route.name] !== undefined) {\n // START FORK\n path += expo.getPathWithConventionsCollapsed({\n ...options,\n pattern,\n route,\n params: allParams,\n initialRouteName: configs[route.name]?.initialRouteName,\n });\n // path += pattern\n // .split('/')\n // .map((p) => {\n // const name = getParamName(p);\n\n // // We don't know what to show for wildcard patterns\n // // Showing the route name seems ok, though whatever we show here will be incorrect\n // // Since the page doesn't actually exist\n // if (p === '*') {\n // return route.name;\n // }\n\n // // If the path has a pattern for a param, put the param in the path\n // if (p.startsWith(':')) {\n // const value = allParams[name];\n\n // if (value === undefined && p.endsWith('?')) {\n // // Optional params without value assigned in route.params should be ignored\n // return '';\n // }\n\n // // Valid characters according to\n // // https://datatracker.ietf.org/doc/html/rfc3986#section-3.3 (see pchar definition)\n // return String(value).replace(/[^A-Za-z0-9\\-._~!$&'()*+,;=:@]/g, (char) =>\n // encodeURIComponent(char)\n // );\n // }\n\n // return encodeURIComponent(p);\n // })\n // .join('/');\n // } else {\n } else if (!route.name.startsWith('+')) {\n path += encodeURIComponent(route.name);\n }\n // END FORK\n\n if (!focusedParams) {\n focusedParams = focusedRoute.params ? { ...focusedRoute.params } : undefined;\n }\n\n if (route.state) {\n path += '/';\n } else if (focusedParams) {\n for (const param in focusedParams) {\n if (focusedParams[param] === 'undefined') {\n // eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n delete focusedParams[param];\n }\n }\n\n // START FORK\n delete focusedParams['#'];\n focusedParams = removeInternalExpoRouterParams(focusedParams);\n // END FORK\n\n const query = queryString.stringify(focusedParams, { sort: false });\n if (query) {\n path += `?${query}`;\n }\n }\n\n current = route.state;\n }\n\n // Remove multiple as well as trailing slashes\n path = path.replace(/\\/+/g, '/');\n path = path.length > 1 ? path.replace(/\\/$/, '') : path;\n\n // Include the root path if specified\n if (options?.path) {\n path = joinPaths(options.path, path);\n }\n\n // START FORK\n path = expo.appendBaseUrl(path);\n if (allParams['#']) {\n path += `#${allParams['#']}`;\n }\n // END FORK\n\n // START FORK\n return { path, params: allParams };\n // END FORK\n}\n\n// const getParamName = (pattern: string) => pattern.replace(/^:/, '').replace(/\\?$/, '');\n\nconst joinPaths = (...paths: string[]): string =>\n ([] as string[])\n .concat(...paths.map((p) => p.split('/')))\n .filter(Boolean)\n .join('/');\n\nconst createConfigItem = (\n config: PathConfig<object> | string,\n parentPattern?: string\n): ConfigItem => {\n if (typeof config === 'string') {\n // If a string is specified as the value of the key(e.g. Foo: '/path'), use it as the pattern\n const pattern = parentPattern ? joinPaths(parentPattern, config) : config;\n\n return { pattern };\n }\n\n if (config.exact && config.path === undefined) {\n throw new Error(\n \"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: ''`.\"\n );\n }\n\n // If an object is specified as the value (e.g. Foo: { ... }),\n // It can have `path` property and `screens` prop which has nested configs\n const pattern =\n config.exact !== true ? joinPaths(parentPattern || '', config.path || '') : config.path || '';\n\n const screens = config.screens ? createNormalizedConfigs(config.screens, pattern) : undefined;\n\n return {\n // Normalize pattern to remove any leading, trailing slashes, duplicate slashes etc.\n pattern: pattern?.split('/').filter(Boolean).join('/'),\n stringify: config.stringify,\n screens,\n };\n};\n\nconst createNormalizedConfigs = (\n options: PathConfigMap<object>,\n pattern?: string\n): Record<string, ConfigItem> =>\n Object.fromEntries(\n Object.entries(options).map(([name, c]) => {\n const result = createConfigItem(c, pattern);\n\n return [name, result];\n })\n );\n\nexport function appendBaseUrl(\n path: string,\n baseUrl: string | undefined = process.env.EXPO_BASE_URL\n) {\n if (process.env.NODE_ENV !== 'development') {\n if (baseUrl) {\n return `/${baseUrl.replace(/^\\/+/, '').replace(/\\/$/, '')}${path}`;\n }\n }\n return path;\n}\n"]}
@@ -131,7 +131,7 @@ function getParamValue(p, value) {
131
131
  }
132
132
  function formatRegexPattern(it) {
133
133
  // Allow spaces in file path names.
134
- it = it.replace(' ', '%20');
134
+ it = it.replace(/ /g, '%20');
135
135
  if (it.startsWith(':')) {
136
136
  // TODO: Remove unused match group
137
137
  return `(([^/]+\\/)${it.endsWith('?') ? '?' : ''})`;
@@ -1 +1 @@
1
- {"version":3,"file":"getStateFromPath-forks.js","sourceRoot":"","sources":["../../src/fork/getStateFromPath-forks.ts"],"names":[],"mappings":";;;;;AA4BA,wCAQC;AAED,4DAMC;AASD,oFAyBC;AAED,oCAiDC;AAED,sCAIC;AAED,oCAIC;AAED,sCAEC;AAED,kCAEC;AAED,sCAOC;AAwBD,0CAsBC;AAED,kEAKC;AAED,oCAUC;AAED,8CAgCC;AAED,0CAWC;AAQD,oDA4JC;AAED,4CAgCC;AAED,8BAUC;AAED,kDAeC;AAhfD,gFAA0C;AAI1C,0CAAyE;AACzE,sCAAuD;AAiBvD;;;;GAIG;AACH,SAAgB,cAAc,CAAC,MAAsB,EAAE,MAA4B;IACjF,IAAI,CAAC,MAAM,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO;IAEnE,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;IACnC,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAgB,wBAAwB,CAAC,GAAW;IAClD,IAAI,CAAC;QACH,OAAO,kBAAkB,CAAC,GAAG,CAAC,CAAC;IACjC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,GAAG,CAAC;IACb,CAAC;AACH,CAAC;AASD,SAAgB,oCAAoC,CAClD,IAAY,EACZ,UAA8B,OAAO,CAAC,GAAG,CA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AAC,iDAAiD;IAE1E,sCAAsC;IACtC,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,CAAC;AAChD,CAAC;AAED,SAAgB,mBAAmB,CAAC,OAAe;IACjD,OAAO,IAAI,MAAM,CACf,KAAK,OAAO;SACT,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE;QACV,IAAI,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YAC3C,OAAO,GAAG,EAAE,GAAG,CAAC;QAClB,CAAC;aAAM,IAAI,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YAC9B,OAAO,cAAc,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC;QACtD,CAAC;QAED,OAAO,GAAG,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAA,8BAAM,EAAC,EAAE,CAAC,KAAK,CAAC;IAChD,CAAC,CAAC;SACD,IAAI,CAAC,EAAE,CAAC,GAAG,CACf,CAAC;AACJ,CAAC","sourcesContent":["import { InitialState } from '@react-navigation/native';\nimport escape from 'escape-string-regexp';\nimport * as queryString from 'query-string';\n\nimport type { InitialRouteConfig, Options, ParsedRoute, RouteConfig } from './getStateFromPath';\nimport { matchGroupName, stripGroupSegmentsFromPath } from '../matchers';\nimport { parseUrlUsingCustomBase } from '../utils/url';\n\nexport type ExpoOptions = {\n previousSegments?: string[];\n};\n\nexport type ExpoRouteConfig = {\n type: 'static' | 'dynamic' | 'layout';\n userReadableName: string;\n isIndex: boolean;\n isInitial?: boolean;\n hasChildren: boolean;\n expandedRouteNames: string[];\n parts: string[];\n staticPartCount: number;\n};\n\n/**\n * In Expo Router, the params are available at all levels of the routing config\n * @param routes\n * @returns\n */\nexport function populateParams(routes?: ParsedRoute[], params?: Record<string, any>) {\n if (!routes || !params || Object.keys(params).length === 0) return;\n\n for (const route of routes) {\n Object.assign(route, { params });\n }\n\n return routes;\n}\n\nexport function safelyDecodeURIComponent(str: string) {\n try {\n return decodeURIComponent(str);\n } catch {\n return str;\n }\n}\n\ninterface UrlWithReactNavigationConcessions {\n path: string;\n nonstandardPathname: string;\n hash: string;\n pathWithoutGroups: string;\n}\n\nexport function getUrlWithReactNavigationConcessions(\n path: string,\n baseUrl: string | undefined = process.env.EXPO_BASE_URL\n): UrlWithReactNavigationConcessions {\n const pathWithoutGroups = stripGroupSegmentsFromPath(stripBaseUrl(path, baseUrl));\n\n let pathname = '';\n let hash = '';\n try {\n const parsed = parseUrlUsingCustomBase(path);\n pathname = parsed.pathname;\n hash = parsed.hash;\n } catch {\n // Do nothing with invalid URLs.\n }\n\n const withoutBaseUrl = stripBaseUrl(pathname, baseUrl);\n return {\n path,\n // Make sure there is a trailing slash\n // The slashes are at the end, not the beginning\n nonstandardPathname: withoutBaseUrl.replace(/^\\/+/g, '').replace(/\\/+$/g, '') + '/',\n hash,\n pathWithoutGroups,\n };\n}\n\nexport function createConfig(\n screen: string,\n pattern: string,\n routeNames: string[],\n config: Record<string, any> = {}\n): Omit<ExpoRouteConfig, 'isInitial'> {\n const parts: string[] = [];\n let isDynamic = false;\n const isIndex = screen === 'index' || screen.endsWith('/index');\n let staticPartCount = 0;\n\n for (const part of pattern.split('/')) {\n if (part) {\n // If any part is dynamic, then the route is dynamic\n const isDynamicPart =\n part.startsWith(':') || part.startsWith('*') || part.includes('*not-found');\n\n isDynamic ||= isDynamicPart;\n\n if (!matchGroupName(part)) {\n parts.push(part);\n\n if (!isDynamicPart) {\n staticPartCount++;\n }\n }\n }\n }\n\n const hasChildren = config.screens ? !!Object.keys(config.screens)?.length : false;\n const type = hasChildren ? 'layout' : isDynamic ? 'dynamic' : 'static';\n\n if (isIndex) {\n parts.push('index');\n staticPartCount++;\n }\n\n return {\n type,\n isIndex,\n hasChildren,\n parts,\n staticPartCount,\n userReadableName: [...routeNames.slice(0, -1), config.path || screen].join('/'),\n // Don't include the __root route name\n expandedRouteNames: routeNames.slice(1).flatMap((name) => {\n return name.split('/');\n }),\n };\n}\n\nexport function assertScreens(options?: Options<object>): asserts options is Options<object> {\n if (!options?.screens) {\n throw Error(\"You must pass a 'screens' object to 'getStateFromPath' to generate a path.\");\n }\n}\n\nexport function configRegExp(config: RouteConfig) {\n return config.pattern\n ? new RegExp(`^(${config.pattern.split('/').map(formatRegexPattern).join('')})$`)\n : undefined;\n}\n\nexport function isDynamicPart(p: string) {\n return p.length > 1 && (p.startsWith(':') || p.startsWith('*'));\n}\n\nexport function replacePart(p: string) {\n return p.replace(/^[:*]/, '').replace(/\\?$/, '');\n}\n\nexport function getParamValue(p: string, value: string) {\n if (p.startsWith('*')) {\n const values = value.split('/').filter((v) => v !== '');\n return values.length === 0 && p.endsWith('?') ? undefined : values;\n } else {\n return value;\n }\n}\n\nfunction formatRegexPattern(it: string): string {\n // Allow spaces in file path names.\n it = it.replace(' ', '%20');\n\n if (it.startsWith(':')) {\n // TODO: Remove unused match group\n return `(([^/]+\\\\/)${it.endsWith('?') ? '?' : ''})`;\n } else if (it.startsWith('*')) {\n return `((.*\\\\/)${it.endsWith('?') ? '?' : ''})`;\n }\n\n // Strip groups from the matcher\n if (matchGroupName(it) != null) {\n // Groups are optional segments\n // this enables us to match `/bar` and `/(foo)/bar` for the same route\n // NOTE(EvanBacon): Ignore this match in the regex to avoid capturing the group\n return `(?:${escape(it)}\\\\/)?`;\n }\n\n return escape(it) + `\\\\/`;\n}\n\nexport function handleUrlParams(route: ParsedRoute, params?: queryString.ParsedQuery) {\n if (params) {\n route.params = Object.assign(Object.create(null), route.params) as Record<string, any>;\n for (const [name, value] of Object.entries(params)) {\n if (route.params?.[name]) {\n if (process.env.NODE_ENV !== 'production') {\n console.warn(\n `Route '/${route.name}' with param '${name}' was specified both in the path and as a param, removing from path`\n );\n }\n }\n\n if (!route.params?.[name]) {\n route.params[name] = value;\n continue;\n }\n }\n\n if (Object.keys(route.params).length === 0) {\n delete route.params;\n }\n }\n}\n\nexport function spreadParamsAcrossAllStates(state: InitialState, params?: Record<string, any>) {\n while (state) {\n const route = state.routes[0];\n (route as any).params = Object.assign({}, route.params, params);\n }\n}\n\nexport function stripBaseUrl(\n path: string,\n baseUrl: string | undefined = process.env.EXPO_BASE_URL\n) {\n if (process.env.NODE_ENV !== 'development') {\n if (baseUrl) {\n return path.replace(/^\\/+/g, '/').replace(new RegExp(`^\\\\/?${escape(baseUrl)}`, 'g'), '');\n }\n }\n return path;\n}\n\nexport function matchForEmptyPath(configs: RouteConfig[]) {\n // We need to add special handling of empty path so navigation to empty path also works\n // When handling empty path, we should only look at the root level config\n\n // NOTE(EvanBacon): We only care about matching leaf nodes.\n const leafNodes = configs\n .filter((config) => !config.hasChildren)\n .map((value) => {\n return {\n ...value,\n // Collapse all levels of group segments before testing.\n // This enables `app/(one)/(two)/index.js` to be matched.\n path: stripGroupSegmentsFromPath(value.path),\n };\n });\n\n const match =\n leafNodes.find(\n (config) =>\n // NOTE(EvanBacon): Test leaf node index routes that either don't have a regex or match an empty string.\n config.path === '' && (!config.regex || config.regex.test(''))\n ) ??\n leafNodes.find(\n (config) =>\n // NOTE(EvanBacon): Test leaf node dynamic routes that match an empty string.\n config.path.startsWith(':') && config.regex!.test('')\n ) ??\n // NOTE(EvanBacon): Test leaf node deep dynamic routes that match a slash.\n // This should be done last to enable dynamic routes having a higher priority.\n leafNodes.find((config) => config.path.startsWith('*') && config.regex!.test('/'));\n\n return match;\n}\n\nexport function appendIsInitial(initialRoutes: InitialRouteConfig[]) {\n const resolvedInitialPatterns = initialRoutes.map((route) =>\n joinPaths(...route.parentScreens, route.initialRouteName)\n );\n\n return function (config: RouteConfig) {\n // TODO(EvanBacon): Probably a safer way to do this\n // Mark initial routes to give them potential priority over other routes that match.\n config.isInitial = resolvedInitialPatterns.includes(config.routeNames.join('/'));\n return config;\n };\n}\n\nconst joinPaths = (...paths: string[]): string =>\n ([] as string[])\n .concat(...paths.map((p) => p.split('/')))\n .filter(Boolean)\n .join('/');\n\nexport function getRouteConfigSorter(previousSegments: string[] = []) {\n return function sortConfigs(a: RouteConfig, b: RouteConfig) {\n // Sort config so that:\n // - the most exhaustive ones are always at the beginning\n // - patterns with wildcard are always at the end\n\n // If 2 patterns are same, move the one with less route names up\n // This is an error state, so it's only useful for consistent error messages\n if (a.pattern === b.pattern) {\n return b.routeNames.join('>').localeCompare(a.routeNames.join('>'));\n }\n\n /*\n * If one of the patterns starts with the other, it is earlier in the config sorting.\n * However, configs are a mix of route configs and layout configs\n * e.g There will be a config for `/(group)`, but maybe there isn't a `/(group)/index.tsx`\n *\n * This is because you can navigate to a directory and its navigator will determine the route\n * These routes should be later in the config sorting, as their patterns are very open\n * and will prevent routes from being matched\n *\n * Therefore before we compare segment parts, we force these layout configs later in the sorting\n *\n * NOTE(marklawlor): Is this a feature we want? I'm unsure if this is a gimmick or a feature.\n */\n if (a.pattern.startsWith(b.pattern) && !b.isIndex) {\n return -1;\n }\n\n if (b.pattern.startsWith(a.pattern) && !a.isIndex) {\n return 1;\n }\n\n /*\n * Static routes should always be higher than dynamic and layout routes.\n */\n if (a.type === 'static' && b.type !== 'static') {\n return -1;\n } else if (a.type !== 'static' && b.type === 'static') {\n return 1;\n }\n\n /*\n * If the routes have any static segments, the one the most static segments should be higher\n */\n if (a.staticPartCount !== b.staticPartCount) {\n return b.staticPartCount - a.staticPartCount;\n }\n\n /*\n * If both are static/dynamic or a layout file, then we check group similarity\n */\n const similarToPreviousA = previousSegments.filter((value, index) => {\n return value === a.expandedRouteNames[index] && value.startsWith('(') && value.endsWith(')');\n });\n\n const similarToPreviousB = previousSegments.filter((value, index) => {\n return value === b.expandedRouteNames[index] && value.startsWith('(') && value.endsWith(')');\n });\n\n if (\n (similarToPreviousA.length > 0 || similarToPreviousB.length > 0) &&\n similarToPreviousA.length !== similarToPreviousB.length\n ) {\n // One matches more than the other, so pick the one that matches more\n return similarToPreviousB.length - similarToPreviousA.length;\n }\n\n /*\n * If there is not difference in similarity, then each non-group segment is compared against each other\n */\n for (let i = 0; i < Math.max(a.parts.length, b.parts.length); i++) {\n // if b is longer, b get higher priority\n if (a.parts[i] == null) {\n return 1;\n }\n // if a is longer, a get higher priority\n if (b.parts[i] == null) {\n return -1;\n }\n\n const aWildCard = a.parts[i].startsWith('*');\n const bWildCard = b.parts[i].startsWith('*');\n // if both are wildcard we compare next component\n if (aWildCard && bWildCard) {\n const aNotFound = a.parts[i].match(/^[*]not-found$/);\n const bNotFound = b.parts[i].match(/^[*]not-found$/);\n\n if (aNotFound && bNotFound) {\n continue;\n } else if (aNotFound) {\n return 1;\n } else if (bNotFound) {\n return -1;\n }\n continue;\n }\n // if only a is wild card, b get higher priority\n if (aWildCard) {\n return 1;\n }\n // if only b is wild card, a get higher priority\n if (bWildCard) {\n return -1;\n }\n\n const aSlug = a.parts[i].startsWith(':');\n const bSlug = b.parts[i].startsWith(':');\n // if both are wildcard we compare next component\n if (aSlug && bSlug) {\n const aNotFound = a.parts[i].match(/^[*]not-found$/);\n const bNotFound = b.parts[i].match(/^[*]not-found$/);\n\n if (aNotFound && bNotFound) {\n continue;\n } else if (aNotFound) {\n return 1;\n } else if (bNotFound) {\n return -1;\n }\n\n continue;\n }\n // if only a is wild card, b get higher priority\n if (aSlug) {\n return 1;\n }\n // if only b is wild card, a get higher priority\n if (bSlug) {\n return -1;\n }\n }\n\n /*\n * Both configs are identical in specificity and segments count/type\n * Try and sort by initial instead.\n *\n * TODO: We don't differentiate between the default initialRoute and group specific default routes\n *\n * const unstable_settings = {\n * \"group\": {\n * initialRouteName: \"article\"\n * }\n * }\n *\n * \"article\" will be ranked higher because its an initialRoute for a group - even if not your not currently in\n * that group. The current work around is to ways provide initialRouteName for all groups\n */\n if (a.isInitial && !b.isInitial) {\n return -1;\n } else if (!a.isInitial && b.isInitial) {\n return 1;\n }\n\n return b.parts.length - a.parts.length;\n };\n}\n\nexport function parseQueryParams(\n path: string,\n route: ParsedRoute,\n parseConfig?: Record<string, (value: string) => any>,\n hash?: string\n) {\n const searchParams = parseUrlUsingCustomBase(path).searchParams;\n const params: Record<string, string | string[]> = Object.create(null);\n\n if (hash) {\n params['#'] = hash.slice(1);\n }\n\n for (const name of searchParams.keys()) {\n if (route.params?.[name]) {\n if (process.env.NODE_ENV !== 'production') {\n console.warn(\n `Route '/${route.name}' with param '${name}' was specified both in the path and as a param, removing from path`\n );\n }\n } else {\n const values = parseConfig?.hasOwnProperty(name)\n ? searchParams.getAll(name).map((value) => parseConfig[name](value))\n : searchParams.getAll(name);\n\n // searchParams.getAll returns an array.\n // if we only have a single value, and its not an array param, we need to extract the value\n params[name] = values.length === 1 ? values[0] : values;\n }\n }\n\n return Object.keys(params).length ? params : undefined;\n}\n\nexport function cleanPath(path: string) {\n path = path\n // let remaining = path\n // END FORK\n .replace(/\\/+/g, '/') // Replace multiple slash (//) with single ones\n .replace(/^\\//, '') // Remove extra leading slash\n .replace(/\\?.*$/, ''); // Remove query params which we will handle later\n\n // Make sure there is a trailing slash\n return path.endsWith('/') ? path : `${path}/`;\n}\n\nexport function routePatternToRegex(pattern: string) {\n return new RegExp(\n `^(${pattern\n .split('/')\n .map((it) => {\n if (it.startsWith('(') && it.endsWith(')')) {\n return `${it}?`;\n } else if (it.startsWith(':')) {\n return `(([^/]+\\\\/)${it.endsWith('?') ? '?' : ''})`;\n }\n\n return `${it === '*' ? '.*' : escape(it)}\\\\/`;\n })\n .join('')})`\n );\n}\n"]}
1
+ {"version":3,"file":"getStateFromPath-forks.js","sourceRoot":"","sources":["../../src/fork/getStateFromPath-forks.ts"],"names":[],"mappings":";;;;;AA4BA,wCAQC;AAED,4DAMC;AASD,oFAyBC;AAED,oCAiDC;AAED,sCAIC;AAED,oCAIC;AAED,sCAEC;AAED,kCAEC;AAED,sCAOC;AAwB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GAAG,CAAC,EAAE,CAAC;YAC9B,OAAO,cAAc,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC;QACtD,CAAC;QAED,OAAO,GAAG,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAA,8BAAM,EAAC,EAAE,CAAC,KAAK,CAAC;IAChD,CAAC,CAAC;SACD,IAAI,CAAC,EAAE,CAAC,GAAG,CACf,CAAC;AACJ,CAAC","sourcesContent":["import { InitialState } from '@react-navigation/native';\nimport escape from 'escape-string-regexp';\nimport * as queryString from 'query-string';\n\nimport type { InitialRouteConfig, Options, ParsedRoute, RouteConfig } from './getStateFromPath';\nimport { matchGroupName, stripGroupSegmentsFromPath } from '../matchers';\nimport { parseUrlUsingCustomBase } from '../utils/url';\n\nexport type ExpoOptions = {\n previousSegments?: string[];\n};\n\nexport type ExpoRouteConfig = {\n type: 'static' | 'dynamic' | 'layout';\n userReadableName: string;\n isIndex: boolean;\n isInitial?: boolean;\n hasChildren: boolean;\n expandedRouteNames: string[];\n parts: string[];\n staticPartCount: number;\n};\n\n/**\n * In Expo Router, the params are available at all levels of the routing config\n * @param routes\n * @returns\n */\nexport function populateParams(routes?: ParsedRoute[], params?: Record<string, any>) {\n if (!routes || !params || Object.keys(params).length === 0) return;\n\n for (const route of routes) {\n Object.assign(route, { params });\n }\n\n return routes;\n}\n\nexport function safelyDecodeURIComponent(str: string) {\n try {\n return decodeURIComponent(str);\n } catch {\n return str;\n }\n}\n\ninterface UrlWithReactNavigationConcessions {\n path: string;\n nonstandardPathname: string;\n hash: string;\n pathWithoutGroups: string;\n}\n\nexport function getUrlWithReactNavigationConcessions(\n path: string,\n baseUrl: string | undefined = process.env.EXPO_BASE_URL\n): UrlWithReactNavigationConcessions {\n const pathWithoutGroups = stripGroupSegmentsFromPath(stripBaseUrl(path, baseUrl));\n\n let pathname = '';\n let hash = '';\n try {\n const parsed = parseUrlUsingCustomBase(path);\n pathname = parsed.pathname;\n hash = parsed.hash;\n } catch {\n // Do nothing with invalid URLs.\n }\n\n const withoutBaseUrl = stripBaseUrl(pathname, baseUrl);\n return {\n path,\n // Make sure there is a trailing slash\n // The slashes are at the end, not the beginning\n nonstandardPathname: withoutBaseUrl.replace(/^\\/+/g, '').replace(/\\/+$/g, '') + '/',\n hash,\n pathWithoutGroups,\n };\n}\n\nexport function createConfig(\n screen: string,\n pattern: string,\n routeNames: string[],\n config: Record<string, any> = {}\n): Omit<ExpoRouteConfig, 'isInitial'> {\n const parts: string[] = [];\n let isDynamic = false;\n const isIndex = screen === 'index' || screen.endsWith('/index');\n let staticPartCount = 0;\n\n for (const part of pattern.split('/')) {\n if (part) {\n // If any part is dynamic, then the route is dynamic\n const isDynamicPart =\n part.startsWith(':') || part.startsWith('*') || part.includes('*not-found');\n\n isDynamic ||= isDynamicPart;\n\n if (!matchGroupName(part)) {\n parts.push(part);\n\n if (!isDynamicPart) {\n staticPartCount++;\n }\n }\n }\n }\n\n const hasChildren = config.screens ? !!Object.keys(config.screens)?.length : false;\n const type = hasChildren ? 'layout' : isDynamic ? 'dynamic' : 'static';\n\n if (isIndex) {\n parts.push('index');\n staticPartCount++;\n }\n\n return {\n type,\n isIndex,\n hasChildren,\n parts,\n staticPartCount,\n userReadableName: [...routeNames.slice(0, -1), config.path || screen].join('/'),\n // Don't include the __root route name\n expandedRouteNames: routeNames.slice(1).flatMap((name) => {\n return name.split('/');\n }),\n };\n}\n\nexport function assertScreens(options?: Options<object>): asserts options is Options<object> {\n if (!options?.screens) {\n throw Error(\"You must pass a 'screens' object to 'getStateFromPath' to generate a path.\");\n }\n}\n\nexport function configRegExp(config: RouteConfig) {\n return config.pattern\n ? new RegExp(`^(${config.pattern.split('/').map(formatRegexPattern).join('')})$`)\n : undefined;\n}\n\nexport function isDynamicPart(p: string) {\n return p.length > 1 && (p.startsWith(':') || p.startsWith('*'));\n}\n\nexport function replacePart(p: string) {\n return p.replace(/^[:*]/, '').replace(/\\?$/, '');\n}\n\nexport function getParamValue(p: string, value: string) {\n if (p.startsWith('*')) {\n const values = value.split('/').filter((v) => v !== '');\n return values.length === 0 && p.endsWith('?') ? undefined : values;\n } else {\n return value;\n }\n}\n\nfunction formatRegexPattern(it: string): string {\n // Allow spaces in file path names.\n it = it.replace(/ /g, '%20');\n\n if (it.startsWith(':')) {\n // TODO: Remove unused match group\n return `(([^/]+\\\\/)${it.endsWith('?') ? '?' : ''})`;\n } else if (it.startsWith('*')) {\n return `((.*\\\\/)${it.endsWith('?') ? '?' : ''})`;\n }\n\n // Strip groups from the matcher\n if (matchGroupName(it) != null) {\n // Groups are optional segments\n // this enables us to match `/bar` and `/(foo)/bar` for the same route\n // NOTE(EvanBacon): Ignore this match in the regex to avoid capturing the group\n return `(?:${escape(it)}\\\\/)?`;\n }\n\n return escape(it) + `\\\\/`;\n}\n\nexport function handleUrlParams(route: ParsedRoute, params?: queryString.ParsedQuery) {\n if (params) {\n route.params = Object.assign(Object.create(null), route.params) as Record<string, any>;\n for (const [name, value] of Object.entries(params)) {\n if (route.params?.[name]) {\n if (process.env.NODE_ENV !== 'production') {\n console.warn(\n `Route '/${route.name}' with param '${name}' was specified both in the path and as a param, removing from path`\n );\n }\n }\n\n if (!route.params?.[name]) {\n route.params[name] = value;\n continue;\n }\n }\n\n if (Object.keys(route.params).length === 0) {\n delete route.params;\n }\n }\n}\n\nexport function spreadParamsAcrossAllStates(state: InitialState, params?: Record<string, any>) {\n while (state) {\n const route = state.routes[0];\n (route as any).params = Object.assign({}, route.params, params);\n }\n}\n\nexport function stripBaseUrl(\n path: string,\n baseUrl: string | undefined = process.env.EXPO_BASE_URL\n) {\n if (process.env.NODE_ENV !== 'development') {\n if (baseUrl) {\n return path.replace(/^\\/+/g, '/').replace(new RegExp(`^\\\\/?${escape(baseUrl)}`, 'g'), '');\n }\n }\n return path;\n}\n\nexport function matchForEmptyPath(configs: RouteConfig[]) {\n // We need to add special handling of empty path so navigation to empty path also works\n // When handling empty path, we should only look at the root level config\n\n // NOTE(EvanBacon): We only care about matching leaf nodes.\n const leafNodes = configs\n .filter((config) => !config.hasChildren)\n .map((value) => {\n return {\n ...value,\n // Collapse all levels of group segments before testing.\n // This enables `app/(one)/(two)/index.js` to be matched.\n path: stripGroupSegmentsFromPath(value.path),\n };\n });\n\n const match =\n leafNodes.find(\n (config) =>\n // NOTE(EvanBacon): Test leaf node index routes that either don't have a regex or match an empty string.\n config.path === '' && (!config.regex || config.regex.test(''))\n ) ??\n leafNodes.find(\n (config) =>\n // NOTE(EvanBacon): Test leaf node dynamic routes that match an empty string.\n config.path.startsWith(':') && config.regex!.test('')\n ) ??\n // NOTE(EvanBacon): Test leaf node deep dynamic routes that match a slash.\n // This should be done last to enable dynamic routes having a higher priority.\n leafNodes.find((config) => config.path.startsWith('*') && config.regex!.test('/'));\n\n return match;\n}\n\nexport function appendIsInitial(initialRoutes: InitialRouteConfig[]) {\n const resolvedInitialPatterns = initialRoutes.map((route) =>\n joinPaths(...route.parentScreens, route.initialRouteName)\n );\n\n return function (config: RouteConfig) {\n // TODO(EvanBacon): Probably a safer way to do this\n // Mark initial routes to give them potential priority over other routes that match.\n config.isInitial = resolvedInitialPatterns.includes(config.routeNames.join('/'));\n return config;\n };\n}\n\nconst joinPaths = (...paths: string[]): string =>\n ([] as string[])\n .concat(...paths.map((p) => p.split('/')))\n .filter(Boolean)\n .join('/');\n\nexport function getRouteConfigSorter(previousSegments: string[] = []) {\n return function sortConfigs(a: RouteConfig, b: RouteConfig) {\n // Sort config so that:\n // - the most exhaustive ones are always at the beginning\n // - patterns with wildcard are always at the end\n\n // If 2 patterns are same, move the one with less route names up\n // This is an error state, so it's only useful for consistent error messages\n if (a.pattern === b.pattern) {\n return b.routeNames.join('>').localeCompare(a.routeNames.join('>'));\n }\n\n /*\n * If one of the patterns starts with the other, it is earlier in the config sorting.\n * However, configs are a mix of route configs and layout configs\n * e.g There will be a config for `/(group)`, but maybe there isn't a `/(group)/index.tsx`\n *\n * This is because you can navigate to a directory and its navigator will determine the route\n * These routes should be later in the config sorting, as their patterns are very open\n * and will prevent routes from being matched\n *\n * Therefore before we compare segment parts, we force these layout configs later in the sorting\n *\n * NOTE(marklawlor): Is this a feature we want? I'm unsure if this is a gimmick or a feature.\n */\n if (a.pattern.startsWith(b.pattern) && !b.isIndex) {\n return -1;\n }\n\n if (b.pattern.startsWith(a.pattern) && !a.isIndex) {\n return 1;\n }\n\n /*\n * Static routes should always be higher than dynamic and layout routes.\n */\n if (a.type === 'static' && b.type !== 'static') {\n return -1;\n } else if (a.type !== 'static' && b.type === 'static') {\n return 1;\n }\n\n /*\n * If the routes have any static segments, the one the most static segments should be higher\n */\n if (a.staticPartCount !== b.staticPartCount) {\n return b.staticPartCount - a.staticPartCount;\n }\n\n /*\n * If both are static/dynamic or a layout file, then we check group similarity\n */\n const similarToPreviousA = previousSegments.filter((value, index) => {\n return value === a.expandedRouteNames[index] && value.startsWith('(') && value.endsWith(')');\n });\n\n const similarToPreviousB = previousSegments.filter((value, index) => {\n return value === b.expandedRouteNames[index] && value.startsWith('(') && value.endsWith(')');\n });\n\n if (\n (similarToPreviousA.length > 0 || similarToPreviousB.length > 0) &&\n similarToPreviousA.length !== similarToPreviousB.length\n ) {\n // One matches more than the other, so pick the one that matches more\n return similarToPreviousB.length - similarToPreviousA.length;\n }\n\n /*\n * If there is not difference in similarity, then each non-group segment is compared against each other\n */\n for (let i = 0; i < Math.max(a.parts.length, b.parts.length); i++) {\n // if b is longer, b get higher priority\n if (a.parts[i] == null) {\n return 1;\n }\n // if a is longer, a get higher priority\n if (b.parts[i] == null) {\n return -1;\n }\n\n const aWildCard = a.parts[i].startsWith('*');\n const bWildCard = b.parts[i].startsWith('*');\n // if both are wildcard we compare next component\n if (aWildCard && bWildCard) {\n const aNotFound = a.parts[i].match(/^[*]not-found$/);\n const bNotFound = b.parts[i].match(/^[*]not-found$/);\n\n if (aNotFound && bNotFound) {\n continue;\n } else if (aNotFound) {\n return 1;\n } else if (bNotFound) {\n return -1;\n }\n continue;\n }\n // if only a is wild card, b get higher priority\n if (aWildCard) {\n return 1;\n }\n // if only b is wild card, a get higher priority\n if (bWildCard) {\n return -1;\n }\n\n const aSlug = a.parts[i].startsWith(':');\n const bSlug = b.parts[i].startsWith(':');\n // if both are wildcard we compare next component\n if (aSlug && bSlug) {\n const aNotFound = a.parts[i].match(/^[*]not-found$/);\n const bNotFound = b.parts[i].match(/^[*]not-found$/);\n\n if (aNotFound && bNotFound) {\n continue;\n } else if (aNotFound) {\n return 1;\n } else if (bNotFound) {\n return -1;\n }\n\n continue;\n }\n // if only a is wild card, b get higher priority\n if (aSlug) {\n return 1;\n }\n // if only b is wild card, a get higher priority\n if (bSlug) {\n return -1;\n }\n }\n\n /*\n * Both configs are identical in specificity and segments count/type\n * Try and sort by initial instead.\n *\n * TODO: We don't differentiate between the default initialRoute and group specific default routes\n *\n * const unstable_settings = {\n * \"group\": {\n * initialRouteName: \"article\"\n * }\n * }\n *\n * \"article\" will be ranked higher because its an initialRoute for a group - even if not your not currently in\n * that group. The current work around is to ways provide initialRouteName for all groups\n */\n if (a.isInitial && !b.isInitial) {\n return -1;\n } else if (!a.isInitial && b.isInitial) {\n return 1;\n }\n\n return b.parts.length - a.parts.length;\n };\n}\n\nexport function parseQueryParams(\n path: string,\n route: ParsedRoute,\n parseConfig?: Record<string, (value: string) => any>,\n hash?: string\n) {\n const searchParams = parseUrlUsingCustomBase(path).searchParams;\n const params: Record<string, string | string[]> = Object.create(null);\n\n if (hash) {\n params['#'] = hash.slice(1);\n }\n\n for (const name of searchParams.keys()) {\n if (route.params?.[name]) {\n if (process.env.NODE_ENV !== 'production') {\n console.warn(\n `Route '/${route.name}' with param '${name}' was specified both in the path and as a param, removing from path`\n );\n }\n } else {\n const values = parseConfig?.hasOwnProperty(name)\n ? searchParams.getAll(name).map((value) => parseConfig[name](value))\n : searchParams.getAll(name);\n\n // searchParams.getAll returns an array.\n // if we only have a single value, and its not an array param, we need to extract the value\n params[name] = values.length === 1 ? values[0] : values;\n }\n }\n\n return Object.keys(params).length ? params : undefined;\n}\n\nexport function cleanPath(path: string) {\n path = path\n // let remaining = path\n // END FORK\n .replace(/\\/+/g, '/') // Replace multiple slash (//) with single ones\n .replace(/^\\//, '') // Remove extra leading slash\n .replace(/\\?.*$/, ''); // Remove query params which we will handle later\n\n // Make sure there is a trailing slash\n return path.endsWith('/') ? path : `${path}/`;\n}\n\nexport function routePatternToRegex(pattern: string) {\n return new RegExp(\n `^(${pattern\n .split('/')\n .map((it) => {\n if (it.startsWith('(') && it.endsWith(')')) {\n return `${it}?`;\n } else if (it.startsWith(':')) {\n return `(([^/]+\\\\/)${it.endsWith('?') ? '?' : ''})`;\n }\n\n return `${it === '*' ? '.*' : escape(it)}\\\\/`;\n })\n .join('')})`\n );\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"useLinking.d.ts","sourceRoot":"","sources":["../../src/fork/useLinking.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EAId,gBAAgB,IAAI,uBAAuB,EAC3C,KAAK,sBAAsB,EAE3B,KAAK,aAAa,EAEnB,MAAM,0BAA0B,CAAC;AAElC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAQ/B,KAAK,WAAW,GAAG,UAAU,CAAC,OAAO,uBAAuB,CAAC,CAAC;AA0C9D;;GAEG;AACH,eAAO,MAAM,MAAM,GAAI,IAAI,MAAM,OAAO,CAAC,IAAI,CAAC,eAM7C,CAAC;AAIF,KAAK,OAAO,GAAG,cAAc,CAAC,aAAa,CAAC,CAAC;AAE7C,wBAAgB,UAAU,CACxB,GAAG,EAAE,KAAK,CAAC,SAAS,CAAC,sBAAsB,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,EAClE,EACE,OAAc,EACd,MAAM,EACN,gBAA0C,EAC1C,gBAA0C,EAC1C,kBAA8C,GAC/C,EAAE,OAAO,EACV,kBAAkB,EAAE,CAAC,mBAAmB,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI;2BA4GhD,WAAW,CAAC,WAAW,GAAG,SAAS,CAAC;EA8R1D;AAED,wBAAgB,wBAAwB,IAAI,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAEjF"}
1
+ {"version":3,"file":"useLinking.d.ts","sourceRoot":"","sources":["../../src/fork/useLinking.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EAId,gBAAgB,IAAI,uBAAuB,EAC3C,KAAK,sBAAsB,EAE3B,KAAK,aAAa,EAEnB,MAAM,0BAA0B,CAAC;AAElC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAQ/B,KAAK,WAAW,GAAG,UAAU,CAAC,OAAO,uBAAuB,CAAC,CAAC;AA0C9D;;GAEG;AACH,eAAO,MAAM,MAAM,GAAI,IAAI,MAAM,OAAO,CAAC,IAAI,CAAC,eAM7C,CAAC;AAIF,KAAK,OAAO,GAAG,cAAc,CAAC,aAAa,CAAC,CAAC;AAE7C,wBAAgB,UAAU,CACxB,GAAG,EAAE,KAAK,CAAC,SAAS,CAAC,sBAAsB,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,EAClE,EACE,OAAc,EACd,MAAM,EACN,gBAA0C,EAC1C,gBAA0C,EAC1C,kBAA8C,GAC/C,EAAE,OAAO,EACV,kBAAkB,EAAE,CAAC,mBAAmB,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI;2BA8GhD,WAAW,CAAC,WAAW,GAAG,SAAS,CAAC;EA8R1D;AAED,wBAAgB,wBAAwB,IAAI,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAEjF"}
@@ -153,7 +153,9 @@ function useLinking(ref, { enabled = true, config, getStateFromPath = native_1.g
153
153
  let value;
154
154
  if (enabledRef.current) {
155
155
  const location = server?.location ?? (typeof window !== 'undefined' ? window.location : undefined);
156
- const path = location ? location.pathname + location.search : undefined;
156
+ const path = location
157
+ ? location.pathname + location.search + (location.hash ?? '')
158
+ : undefined;
157
159
  if (path) {
158
160
  value = getStateFromPathRef.current(path, configRef.current);
159
161
  }
@@ -1 +1 @@
1
- {"version":3,"file":"useLinking.js","sourceRoot":"","sources":["../../src/fork/useLinking.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6EA,gCAmZC;AAED,4DAEC;AApeD,qDAUkC;AAClC,sEAAsC;AACtC,6CAA+B;AAE/B,+DAA4D;AAC5D,yDAAmD;AACnD,iFAAsE;AACtE,+DAAkE;AAClE,iDAA+D;AAI/D;;;GAGG;AACH,MAAM,iBAAiB,GAAG,CACxB,CAAgB,EAChB,CAAgB,EACgB,EAAE;IAClC,IAAI,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,SAAS,IAAI,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,GAAG,EAAE,CAAC;QAC1D,OAAO,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;IAChC,CAAC;IAED,uFAAuF;IACvF,MAAM,cAAc,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC;IACtE,MAAM,cAAc,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC;IAEtE,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IACjC,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IAEjC,MAAM,WAAW,GAAG,MAAM,CAAC,KAAsB,CAAC;IAClD,MAAM,WAAW,GAAG,MAAM,CAAC,KAAsB,CAAC;IAElD,sDAAsD;IACtD,gCAAgC;IAChC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AC,CAAC;IAClE,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC;IAE5B,OAAO;QACL,eAAe;KAChB,CAAC;AACJ,CAAC;AAED,SAAgB,wBAAwB;IACtC,OAAO,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;AACnE,CAAC","sourcesContent":["import {\n LinkingOptions,\n findFocusedRoute,\n getActionFromState as getActionFromStateDefault,\n getPathFromState as getPathFromStateDefault,\n getStateFromPath as getStateFromPathDefault,\n type NavigationContainerRef,\n type NavigationState,\n type ParamListBase,\n useNavigationIndependentTree,\n} from '@react-navigation/native';\nimport isEqual from 'fast-deep-equal';\nimport * as React from 'react';\n\nimport { createMemoryHistory } from './createMemoryHistory';\nimport { appendBaseUrl } from './getPathFromState';\nimport { ServerContext } from '../global-state/serverLocationContext';\nimport { useExpoRouterStore } from '../global-state/storeContext';\nimport { getRootStackRouteNames } from '../global-state/utils';\n\ntype ResultState = ReturnType<typeof getStateFromPathDefault>;\n\n/**\n * Find the matching navigation state that changed between 2 navigation states\n * e.g.: a -> b -> c -> d and a -> b -> c -> e -> f, if history in b changed, b is the matching state\n */\nconst findMatchingState = <T extends NavigationState>(\n a: T | undefined,\n b: T | undefined\n): [T | undefined, T | undefined] => {\n if (a === undefined || b === undefined || a.key !== b.key) {\n return [undefined, undefined];\n }\n\n // Tab and drawer will have `history` property, but stack will have history in `routes`\n const aHistoryLength = a.history ? a.history.length : a.routes.length;\n const bHistoryLength = b.history ? b.history.length : b.routes.length;\n\n const aRoute = a.routes[a.index];\n const bRoute = b.routes[b.index];\n\n const aChildState = aRoute.state as T | undefined;\n const bChildState = bRoute.state as T | undefined;\n\n // Stop here if this is the state object that changed:\n // - history length is different\n // - focused routes are different\n // - one of them doesn't have child state\n // - child state keys are different\n if (\n aHistoryLength !== bHistoryLength ||\n aRoute.key !== bRoute.key ||\n aChildState === undefined ||\n bChildState === undefined ||\n aChildState.key !== bChildState.key\n ) {\n return [a, b];\n }\n\n return findMatchingState(aChildState, bChildState);\n};\n\n/**\n * Run async function in series as it's called.\n */\nexport const series = (cb: () => Promise<void>) => {\n let queue = Promise.resolve();\n const callback = () => {\n queue = queue.then(cb);\n };\n return callback;\n};\n\nconst linkingHandlers: symbol[] = [];\n\ntype Options = LinkingOptions<ParamListBase>;\n\nexport function useLinking(\n ref: React.RefObject<NavigationContainerRef<ParamListBase> | null>,\n {\n enabled = true,\n config,\n getStateFromPath = getStateFromPathDefault,\n getPathFromState = getPathFromStateDefault,\n getActionFromState = getActionFromStateDefault,\n }: Options,\n onUnhandledLinking: (lastUnhandledLining: string | undefined) => void\n) {\n const independent = useNavigationIndependentTree();\n\n const store = useExpoRouterStore();\n\n React.useEffect(() => {\n if (process.env.NODE_ENV === 'production') {\n return undefined;\n }\n\n if (independent) {\n return undefined;\n }\n\n if (enabled !== false && linkingHandlers.length) {\n console.error(\n [\n '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:',\n \"- You don't have multiple NavigationContainers in the app each with 'linking' enabled\",\n '- Only a single instance of the root component is rendered',\n ]\n .join('\\n')\n .trim()\n );\n }\n\n const handler = Symbol();\n\n if (enabled !== false) {\n linkingHandlers.push(handler);\n }\n\n return () => {\n const index = linkingHandlers.indexOf(handler);\n\n if (index > -1) {\n linkingHandlers.splice(index, 1);\n }\n };\n }, [enabled, independent]);\n\n const [history] = React.useState(createMemoryHistory);\n\n // We store these options in ref to avoid re-creating getInitialState and re-subscribing listeners\n // This lets user avoid wrapping the items in `React.useCallback` or `React.useMemo`\n // Not re-creating `getInitialState` is important coz it makes it easier for the user to use in an effect\n const enabledRef = React.useRef(enabled);\n const configRef = React.useRef(config);\n const getStateFromPathRef = React.useRef(getStateFromPath);\n const getPathFromStateRef = React.useRef(getPathFromState);\n const getActionFromStateRef = React.useRef(getActionFromState);\n\n React.useEffect(() => {\n enabledRef.current = enabled;\n configRef.current = config;\n getStateFromPathRef.current = getStateFromPath;\n getPathFromStateRef.current = getPathFromState;\n getActionFromStateRef.current = getActionFromState;\n });\n\n const validateRoutesNotExistInRootState = React.useCallback(\n (state: ResultState) => {\n // START FORK\n // Instead of using the rootState, we use INTERNAL_SLOT_NAME, which is the only route in the root navigator in Expo Router\n // const navigation = ref.current;\n // const rootState = navigation?.getRootState();\n const routeNames = getRootStackRouteNames();\n // END FORK\n\n // Make sure that the routes in the state exist in the root navigator\n // Otherwise there's an error in the linking configuration\n // START FORK\n // return state?.routes.some((r) => !rootState?.routeNames?.includes(r.name));\n return state?.routes.some((r) => !routeNames.includes(r.name));\n // END FORK\n },\n [ref]\n );\n\n const server = React.use(ServerContext);\n\n const getInitialState = React.useCallback(() => {\n let value: ResultState | undefined;\n\n if (enabledRef.current) {\n const location =\n server?.location ?? (typeof window !== 'undefined' ? window.location : undefined);\n\n const path = location ? location.pathname + location.search : undefined;\n\n if (path) {\n value = getStateFromPathRef.current(path, configRef.current);\n }\n\n // If the link were handled, it gets cleared in NavigationContainer\n onUnhandledLinking(path);\n }\n\n const thenable = {\n then(onfulfilled?: (state: ResultState | undefined) => void) {\n return Promise.resolve(onfulfilled ? onfulfilled(value) : value);\n },\n catch() {\n return thenable;\n },\n };\n\n return thenable as PromiseLike<ResultState | undefined>;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n const previousIndexRef = React.useRef<number | undefined>(undefined);\n const previousStateRef = React.useRef<NavigationState | undefined>(undefined);\n const pendingPopStatePathRef = React.useRef<string | undefined>(undefined);\n\n React.useEffect(() => {\n previousIndexRef.current = history.index;\n\n return history.listen(() => {\n const navigation = ref.current;\n\n if (!navigation || !enabled) {\n return;\n }\n\n const { location } = window;\n\n const path = location.pathname + location.search + location.hash;\n const index = history.index;\n\n const previousIndex = previousIndexRef.current ?? 0;\n\n previousIndexRef.current = index;\n pendingPopStatePathRef.current = path;\n\n // When browser back/forward is clicked, we first need to check if state object for this index exists\n // If it does we'll reset to that state object\n // Otherwise, we'll handle it like a regular deep link\n const record = history.get(index);\n\n if (record?.path === path && record?.state) {\n navigation.resetRoot(record.state);\n return;\n }\n\n const state = getStateFromPathRef.current(path, configRef.current);\n\n // We should only dispatch an action when going forward\n // Otherwise the action will likely add items to history, which would mess things up\n if (state) {\n // If the link were handled, it gets cleared in NavigationContainer\n onUnhandledLinking(path);\n // Make sure that the routes in the state exist in the root navigator\n // Otherwise there's an error in the linking configuration\n if (validateRoutesNotExistInRootState(state)) {\n return;\n }\n\n if (\n index > previousIndex ||\n /* START FORK\n *\n * This is a workaround for React Navigation's handling of hashes (it doesn't handle them)\n * When you click on <a href=\"#hash\">, the browser will first fire a popstate event\n * and this callback will be called.\n *\n * From React Navigation's perspective, it's treating the new hash change like a back/forward\n * button press, so it thinks it should reset the state. When we should\n * be to be pushing the new state\n *\n * Our fix is to check if the index is the same as the previous index\n * and if the incoming path is the same as the old path but with the hash added,\n * then treat it as a push instead of a reset\n *\n * This also works for subsequent hash changes, as internally RN\n * doesn't store the hash in the history state.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/popstate_event#when_popstate_is_sent\n */\n (index === previousIndex && (!record || `${record?.path}${location.hash}` === path))\n // END FORK\n ) {\n const action = getActionFromStateRef.current(state, configRef.current);\n\n if (action !== undefined) {\n try {\n navigation.dispatch(action);\n } catch (e) {\n // Ignore any errors from deep linking.\n // This could happen in case of malformed links, navigation object not being initialized etc.\n console.warn(\n `An error occurred when trying to handle the link '${path}': ${\n typeof e === 'object' && e != null && 'message' in e ? e.message : e\n }`\n );\n }\n } else {\n navigation.resetRoot(state);\n }\n } else {\n navigation.resetRoot(state);\n }\n } else {\n // if current path didn't return any state, we should revert to initial state\n navigation.resetRoot(state);\n }\n });\n }, [enabled, history, onUnhandledLinking, ref, validateRoutesNotExistInRootState]);\n\n React.useEffect(() => {\n if (!enabled) {\n return;\n }\n\n const getPathForRoute = (\n route: ReturnType<typeof findFocusedRoute>,\n state: NavigationState\n ): string => {\n let path;\n\n // If the `route` object contains a `path`, use that path as long as `route.name` and `params` still match\n // This makes sure that we preserve the original URL for wildcard routes\n if (route?.path) {\n const stateForPath = getStateFromPathRef.current(route.path, configRef.current);\n\n if (stateForPath) {\n const focusedRoute = findFocusedRoute(stateForPath);\n\n if (\n focusedRoute &&\n focusedRoute.name === route.name &&\n isEqual({ ...focusedRoute.params }, { ...route.params })\n ) {\n // START FORK - Ensure paths coming from events (e.g refresh) have the base URL\n // path = route.path;\n path = appendBaseUrl(route.path);\n // END FORK\n }\n }\n }\n\n if (path == null) {\n path = getPathFromStateRef.current(state, configRef.current);\n }\n\n // START FORK - ExpoRouter manually handles hashes. This code is intentionally removed\n // const previousRoute = previousStateRef.current\n // ? findFocusedRoute(previousStateRef.current)\n // : undefined;\n\n // Preserve the hash if the route didn't change\n // if (\n // previousRoute &&\n // route &&\n // 'key' in previousRoute &&\n // 'key' in route &&\n // previousRoute.key === route.key\n // ) {\n // path = path + location.hash;\n // }\n // END FORK\n\n return path;\n };\n\n if (ref.current) {\n // We need to record the current metadata on the first render if they aren't set\n // This will allow the initial state to be in the history entry\n\n // START FORK\n // Instead of using the rootState (which might be stale) we should use the focused state\n // const state = ref.current.getRootState();\n const rootState = ref.current.getRootState();\n const state = store.state as NavigationState;\n\n // END FORK\n\n if (state) {\n const route = findFocusedRoute(state);\n const path = getPathForRoute(route, state);\n\n if (previousStateRef.current === undefined) {\n // START FORK\n // previousStateRef.current = state;\n previousStateRef.current = rootState;\n // END FORK\n }\n\n history.replace({ path, state });\n }\n }\n\n const onStateChange = async () => {\n const navigation = ref.current;\n\n if (!navigation || !enabled) {\n return;\n }\n\n const previousState = previousStateRef.current;\n // START FORK\n // Instead of using the rootState (which might be stale) we should use the focused state\n // const state = navigation.getRootState();\n const rootState = navigation.getRootState();\n const state = store.state as NavigationState;\n\n // END FORK\n\n // root state may not available, for example when root navigators switch inside the container\n if (!state) {\n return;\n }\n\n const pendingPath = pendingPopStatePathRef.current;\n const route = findFocusedRoute(state);\n const path = getPathForRoute(route, state);\n\n // START FORK\n // previousStateRef.current = state;\n previousStateRef.current = rootState;\n // END FORK\n pendingPopStatePathRef.current = undefined;\n\n // To detect the kind of state change, we need to:\n // - Find the common focused navigation state in previous and current state\n // - If only the route keys changed, compare history/routes.length to check if we go back/forward/replace\n // - If no common focused navigation state found, it's a replace\n const [previousFocusedState, focusedState] = findMatchingState(previousState, state);\n\n if (\n previousFocusedState &&\n focusedState &&\n // We should only handle push/pop if path changed from what was in last `popstate`\n // Otherwise it's likely a change triggered by `popstate`\n path !== pendingPath\n ) {\n const historyDelta =\n (focusedState.history ? focusedState.history.length : focusedState.routes.length) -\n (previousFocusedState.history\n ? previousFocusedState.history.length\n : previousFocusedState.routes.length);\n\n if (historyDelta > 0) {\n // If history length is increased, we should pushState\n // Note that path might not actually change here, for example, drawer open should pushState\n history.push({ path, state });\n } else if (historyDelta < 0) {\n // If history length is decreased, i.e. entries were removed, we want to go back\n\n const nextIndex = history.backIndex({ path });\n const currentIndex = history.index;\n\n try {\n if (\n nextIndex !== -1 &&\n nextIndex < currentIndex &&\n // We should only go back if the entry exists and it's less than current index\n history.get(nextIndex - currentIndex)\n ) {\n // An existing entry for this path exists and it's less than current index, go back to that\n await history.go(nextIndex - currentIndex);\n } else {\n // We couldn't find an existing entry to go back to, so we'll go back by the delta\n // This won't be correct if multiple routes were pushed in one go before\n // Usually this shouldn't happen and this is a fallback for that\n await history.go(historyDelta);\n }\n\n // Store the updated state as well as fix the path if incorrect\n history.replace({ path, state });\n } catch {\n // The navigation was interrupted\n }\n } else {\n // If history length is unchanged, we want to replaceState\n history.replace({ path, state });\n }\n } else {\n // If no common navigation state was found, assume it's a replace\n // This would happen if the user did a reset/conditionally changed navigators\n history.replace({ path, state });\n }\n };\n\n // We debounce onStateChange coz we don't want multiple state changes to be handled at one time\n // This could happen since `history.go(n)` is asynchronous\n // If `pushState` or `replaceState` were called before `history.go(n)` completes, it'll mess stuff up\n return ref.current?.addListener('state', series(onStateChange));\n }, [enabled, history, ref]);\n\n return {\n getInitialState,\n };\n}\n\nexport function getInitialURLWithTimeout(): string | null | Promise<string | null> {\n return typeof window === 'undefined' ? '' : window.location.href;\n}\n"]}
1
+ {"version":3,"file":"useLinking.js","sourceRoot":"","sources":["../../src/fork/useLinking.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6EA,gCAqZC;AAED,4DAEC;AAteD,qDAUkC;AAClC,sEAAsC;AACtC,6CAA+B;AAE/B,+DAA4D;AAC5D,yDAAmD;AACnD,iFAAsE;AACtE,+DAAkE;AAClE,iDAA+D;AAI/D;;;GAGG;AACH,MAAM,iBAAiB,GAAG,CACxB,CAAgB,EAChB,CAAgB,EACgB,EAAE;IAClC,IAAI,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,SAAS,IAAI,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,GAAG,EAAE,CAAC;QAC1D,OAAO,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;IAChC,CAAC;IAED,uFAAuF;IACvF,MAAM,cAAc,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC;IACtE,MAAM,cAAc,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC;IAEtE,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IACjC,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IAEjC,MAAM,WAAW,GAAG,MAAM,CAAC,KAAsB,CAAC;IAClD,MAAM,WAAW,GAAG,MAAM,CAAC,KAAsB,CAA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G,OAAO,GAAG,CAAC,OAAO,EAAE,WAAW,CAAC,OAAO,EAAE,IAAA,cAAM,EAAC,aAAa,CAAC,CAAC,CAAC;IAClE,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC;IAE5B,OAAO;QACL,eAAe;KAChB,CAAC;AACJ,CAAC;AAED,SAAgB,wBAAwB;IACtC,OAAO,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;AACnE,CAAC","sourcesContent":["import {\n LinkingOptions,\n findFocusedRoute,\n getActionFromState as getActionFromStateDefault,\n getPathFromState as getPathFromStateDefault,\n getStateFromPath as getStateFromPathDefault,\n type NavigationContainerRef,\n type NavigationState,\n type ParamListBase,\n useNavigationIndependentTree,\n} from '@react-navigation/native';\nimport isEqual from 'fast-deep-equal';\nimport * as React from 'react';\n\nimport { createMemoryHistory } from './createMemoryHistory';\nimport { appendBaseUrl } from './getPathFromState';\nimport { ServerContext } from '../global-state/serverLocationContext';\nimport { useExpoRouterStore } from '../global-state/storeContext';\nimport { getRootStackRouteNames } from '../global-state/utils';\n\ntype ResultState = ReturnType<typeof getStateFromPathDefault>;\n\n/**\n * Find the matching navigation state that changed between 2 navigation states\n * e.g.: a -> b -> c -> d and a -> b -> c -> e -> f, if history in b changed, b is the matching state\n */\nconst findMatchingState = <T extends NavigationState>(\n a: T | undefined,\n b: T | undefined\n): [T | undefined, T | undefined] => {\n if (a === undefined || b === undefined || a.key !== b.key) {\n return [undefined, undefined];\n }\n\n // Tab and drawer will have `history` property, but stack will have history in `routes`\n const aHistoryLength = a.history ? a.history.length : a.routes.length;\n const bHistoryLength = b.history ? b.history.length : b.routes.length;\n\n const aRoute = a.routes[a.index];\n const bRoute = b.routes[b.index];\n\n const aChildState = aRoute.state as T | undefined;\n const bChildState = bRoute.state as T | undefined;\n\n // Stop here if this is the state object that changed:\n // - history length is different\n // - focused routes are different\n // - one of them doesn't have child state\n // - child state keys are different\n if (\n aHistoryLength !== bHistoryLength ||\n aRoute.key !== bRoute.key ||\n aChildState === undefined ||\n bChildState === undefined ||\n aChildState.key !== bChildState.key\n ) {\n return [a, b];\n }\n\n return findMatchingState(aChildState, bChildState);\n};\n\n/**\n * Run async function in series as it's called.\n */\nexport const series = (cb: () => Promise<void>) => {\n let queue = Promise.resolve();\n const callback = () => {\n queue = queue.then(cb);\n };\n return callback;\n};\n\nconst linkingHandlers: symbol[] = [];\n\ntype Options = LinkingOptions<ParamListBase>;\n\nexport function useLinking(\n ref: React.RefObject<NavigationContainerRef<ParamListBase> | null>,\n {\n enabled = true,\n config,\n getStateFromPath = getStateFromPathDefault,\n getPathFromState = getPathFromStateDefault,\n getActionFromState = getActionFromStateDefault,\n }: Options,\n onUnhandledLinking: (lastUnhandledLining: string | undefined) => void\n) {\n const independent = useNavigationIndependentTree();\n\n const store = useExpoRouterStore();\n\n React.useEffect(() => {\n if (process.env.NODE_ENV === 'production') {\n return undefined;\n }\n\n if (independent) {\n return undefined;\n }\n\n if (enabled !== false && linkingHandlers.length) {\n console.error(\n [\n '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:',\n \"- You don't have multiple NavigationContainers in the app each with 'linking' enabled\",\n '- Only a single instance of the root component is rendered',\n ]\n .join('\\n')\n .trim()\n );\n }\n\n const handler = Symbol();\n\n if (enabled !== false) {\n linkingHandlers.push(handler);\n }\n\n return () => {\n const index = linkingHandlers.indexOf(handler);\n\n if (index > -1) {\n linkingHandlers.splice(index, 1);\n }\n };\n }, [enabled, independent]);\n\n const [history] = React.useState(createMemoryHistory);\n\n // We store these options in ref to avoid re-creating getInitialState and re-subscribing listeners\n // This lets user avoid wrapping the items in `React.useCallback` or `React.useMemo`\n // Not re-creating `getInitialState` is important coz it makes it easier for the user to use in an effect\n const enabledRef = React.useRef(enabled);\n const configRef = React.useRef(config);\n const getStateFromPathRef = React.useRef(getStateFromPath);\n const getPathFromStateRef = React.useRef(getPathFromState);\n const getActionFromStateRef = React.useRef(getActionFromState);\n\n React.useEffect(() => {\n enabledRef.current = enabled;\n configRef.current = config;\n getStateFromPathRef.current = getStateFromPath;\n getPathFromStateRef.current = getPathFromState;\n getActionFromStateRef.current = getActionFromState;\n });\n\n const validateRoutesNotExistInRootState = React.useCallback(\n (state: ResultState) => {\n // START FORK\n // Instead of using the rootState, we use INTERNAL_SLOT_NAME, which is the only route in the root navigator in Expo Router\n // const navigation = ref.current;\n // const rootState = navigation?.getRootState();\n const routeNames = getRootStackRouteNames();\n // END FORK\n\n // Make sure that the routes in the state exist in the root navigator\n // Otherwise there's an error in the linking configuration\n // START FORK\n // return state?.routes.some((r) => !rootState?.routeNames?.includes(r.name));\n return state?.routes.some((r) => !routeNames.includes(r.name));\n // END FORK\n },\n [ref]\n );\n\n const server = React.use(ServerContext);\n\n const getInitialState = React.useCallback(() => {\n let value: ResultState | undefined;\n\n if (enabledRef.current) {\n const location =\n server?.location ?? (typeof window !== 'undefined' ? window.location : undefined);\n\n const path = location\n ? location.pathname + location.search + (location.hash ?? '')\n : undefined;\n\n if (path) {\n value = getStateFromPathRef.current(path, configRef.current);\n }\n\n // If the link were handled, it gets cleared in NavigationContainer\n onUnhandledLinking(path);\n }\n\n const thenable = {\n then(onfulfilled?: (state: ResultState | undefined) => void) {\n return Promise.resolve(onfulfilled ? onfulfilled(value) : value);\n },\n catch() {\n return thenable;\n },\n };\n\n return thenable as PromiseLike<ResultState | undefined>;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n const previousIndexRef = React.useRef<number | undefined>(undefined);\n const previousStateRef = React.useRef<NavigationState | undefined>(undefined);\n const pendingPopStatePathRef = React.useRef<string | undefined>(undefined);\n\n React.useEffect(() => {\n previousIndexRef.current = history.index;\n\n return history.listen(() => {\n const navigation = ref.current;\n\n if (!navigation || !enabled) {\n return;\n }\n\n const { location } = window;\n\n const path = location.pathname + location.search + location.hash;\n const index = history.index;\n\n const previousIndex = previousIndexRef.current ?? 0;\n\n previousIndexRef.current = index;\n pendingPopStatePathRef.current = path;\n\n // When browser back/forward is clicked, we first need to check if state object for this index exists\n // If it does we'll reset to that state object\n // Otherwise, we'll handle it like a regular deep link\n const record = history.get(index);\n\n if (record?.path === path && record?.state) {\n navigation.resetRoot(record.state);\n return;\n }\n\n const state = getStateFromPathRef.current(path, configRef.current);\n\n // We should only dispatch an action when going forward\n // Otherwise the action will likely add items to history, which would mess things up\n if (state) {\n // If the link were handled, it gets cleared in NavigationContainer\n onUnhandledLinking(path);\n // Make sure that the routes in the state exist in the root navigator\n // Otherwise there's an error in the linking configuration\n if (validateRoutesNotExistInRootState(state)) {\n return;\n }\n\n if (\n index > previousIndex ||\n /* START FORK\n *\n * This is a workaround for React Navigation's handling of hashes (it doesn't handle them)\n * When you click on <a href=\"#hash\">, the browser will first fire a popstate event\n * and this callback will be called.\n *\n * From React Navigation's perspective, it's treating the new hash change like a back/forward\n * button press, so it thinks it should reset the state. When we should\n * be to be pushing the new state\n *\n * Our fix is to check if the index is the same as the previous index\n * and if the incoming path is the same as the old path but with the hash added,\n * then treat it as a push instead of a reset\n *\n * This also works for subsequent hash changes, as internally RN\n * doesn't store the hash in the history state.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/popstate_event#when_popstate_is_sent\n */\n (index === previousIndex && (!record || `${record?.path}${location.hash}` === path))\n // END FORK\n ) {\n const action = getActionFromStateRef.current(state, configRef.current);\n\n if (action !== undefined) {\n try {\n navigation.dispatch(action);\n } catch (e) {\n // Ignore any errors from deep linking.\n // This could happen in case of malformed links, navigation object not being initialized etc.\n console.warn(\n `An error occurred when trying to handle the link '${path}': ${\n typeof e === 'object' && e != null && 'message' in e ? e.message : e\n }`\n );\n }\n } else {\n navigation.resetRoot(state);\n }\n } else {\n navigation.resetRoot(state);\n }\n } else {\n // if current path didn't return any state, we should revert to initial state\n navigation.resetRoot(state);\n }\n });\n }, [enabled, history, onUnhandledLinking, ref, validateRoutesNotExistInRootState]);\n\n React.useEffect(() => {\n if (!enabled) {\n return;\n }\n\n const getPathForRoute = (\n route: ReturnType<typeof findFocusedRoute>,\n state: NavigationState\n ): string => {\n let path;\n\n // If the `route` object contains a `path`, use that path as long as `route.name` and `params` still match\n // This makes sure that we preserve the original URL for wildcard routes\n if (route?.path) {\n const stateForPath = getStateFromPathRef.current(route.path, configRef.current);\n\n if (stateForPath) {\n const focusedRoute = findFocusedRoute(stateForPath);\n\n if (\n focusedRoute &&\n focusedRoute.name === route.name &&\n isEqual({ ...focusedRoute.params }, { ...route.params })\n ) {\n // START FORK - Ensure paths coming from events (e.g refresh) have the base URL\n // path = route.path;\n path = appendBaseUrl(route.path);\n // END FORK\n }\n }\n }\n\n if (path == null) {\n path = getPathFromStateRef.current(state, configRef.current);\n }\n\n // START FORK - ExpoRouter manually handles hashes. This code is intentionally removed\n // const previousRoute = previousStateRef.current\n // ? findFocusedRoute(previousStateRef.current)\n // : undefined;\n\n // Preserve the hash if the route didn't change\n // if (\n // previousRoute &&\n // route &&\n // 'key' in previousRoute &&\n // 'key' in route &&\n // previousRoute.key === route.key\n // ) {\n // path = path + location.hash;\n // }\n // END FORK\n\n return path;\n };\n\n if (ref.current) {\n // We need to record the current metadata on the first render if they aren't set\n // This will allow the initial state to be in the history entry\n\n // START FORK\n // Instead of using the rootState (which might be stale) we should use the focused state\n // const state = ref.current.getRootState();\n const rootState = ref.current.getRootState();\n const state = store.state as NavigationState;\n\n // END FORK\n\n if (state) {\n const route = findFocusedRoute(state);\n const path = getPathForRoute(route, state);\n\n if (previousStateRef.current === undefined) {\n // START FORK\n // previousStateRef.current = state;\n previousStateRef.current = rootState;\n // END FORK\n }\n\n history.replace({ path, state });\n }\n }\n\n const onStateChange = async () => {\n const navigation = ref.current;\n\n if (!navigation || !enabled) {\n return;\n }\n\n const previousState = previousStateRef.current;\n // START FORK\n // Instead of using the rootState (which might be stale) we should use the focused state\n // const state = navigation.getRootState();\n const rootState = navigation.getRootState();\n const state = store.state as NavigationState;\n\n // END FORK\n\n // root state may not available, for example when root navigators switch inside the container\n if (!state) {\n return;\n }\n\n const pendingPath = pendingPopStatePathRef.current;\n const route = findFocusedRoute(state);\n const path = getPathForRoute(route, state);\n\n // START FORK\n // previousStateRef.current = state;\n previousStateRef.current = rootState;\n // END FORK\n pendingPopStatePathRef.current = undefined;\n\n // To detect the kind of state change, we need to:\n // - Find the common focused navigation state in previous and current state\n // - If only the route keys changed, compare history/routes.length to check if we go back/forward/replace\n // - If no common focused navigation state found, it's a replace\n const [previousFocusedState, focusedState] = findMatchingState(previousState, state);\n\n if (\n previousFocusedState &&\n focusedState &&\n // We should only handle push/pop if path changed from what was in last `popstate`\n // Otherwise it's likely a change triggered by `popstate`\n path !== pendingPath\n ) {\n const historyDelta =\n (focusedState.history ? focusedState.history.length : focusedState.routes.length) -\n (previousFocusedState.history\n ? previousFocusedState.history.length\n : previousFocusedState.routes.length);\n\n if (historyDelta > 0) {\n // If history length is increased, we should pushState\n // Note that path might not actually change here, for example, drawer open should pushState\n history.push({ path, state });\n } else if (historyDelta < 0) {\n // If history length is decreased, i.e. entries were removed, we want to go back\n\n const nextIndex = history.backIndex({ path });\n const currentIndex = history.index;\n\n try {\n if (\n nextIndex !== -1 &&\n nextIndex < currentIndex &&\n // We should only go back if the entry exists and it's less than current index\n history.get(nextIndex - currentIndex)\n ) {\n // An existing entry for this path exists and it's less than current index, go back to that\n await history.go(nextIndex - currentIndex);\n } else {\n // We couldn't find an existing entry to go back to, so we'll go back by the delta\n // This won't be correct if multiple routes were pushed in one go before\n // Usually this shouldn't happen and this is a fallback for that\n await history.go(historyDelta);\n }\n\n // Store the updated state as well as fix the path if incorrect\n history.replace({ path, state });\n } catch {\n // The navigation was interrupted\n }\n } else {\n // If history length is unchanged, we want to replaceState\n history.replace({ path, state });\n }\n } else {\n // If no common navigation state was found, assume it's a replace\n // This would happen if the user did a reset/conditionally changed navigators\n history.replace({ path, state });\n }\n };\n\n // We debounce onStateChange coz we don't want multiple state changes to be handled at one time\n // This could happen since `history.go(n)` is asynchronous\n // If `pushState` or `replaceState` were called before `history.go(n)` completes, it'll mess stuff up\n return ref.current?.addListener('state', series(onStateChange));\n }, [enabled, history, ref]);\n\n return {\n getInitialState,\n };\n}\n\nexport function getInitialURLWithTimeout(): string | null | Promise<string | null> {\n return typeof window === 'undefined' ? '' : window.location.href;\n}\n"]}
@@ -2,6 +2,7 @@ export type ServerContextType = {
2
2
  location?: {
3
3
  pathname: string;
4
4
  search: string;
5
+ hash?: string;
5
6
  };
6
7
  };
7
8
  export declare const ServerContext: import("react").Context<ServerContextType | undefined>;
@@ -1 +1 @@
1
- {"version":3,"file":"serverLocationContext.d.ts","sourceRoot":"","sources":["../../src/global-state/serverLocationContext.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,CAAC,EAAE;QACT,QAAQ,EAAE,MAAM,CAAC;QACjB,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;CACH,CAAC;AAEF,eAAO,MAAM,aAAa,wDAA0D,CAAC"}
1
+ {"version":3,"file":"serverLocationContext.d.ts","sourceRoot":"","sources":["../../src/global-state/serverLocationContext.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,CAAC,EAAE;QACT,QAAQ,EAAE,MAAM,CAAC;QACjB,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,CAAC,EAAE,MAAM,CAAC;KACf,CAAC;CACH,CAAC;AAEF,eAAO,MAAM,aAAa,wDAA0D,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"serverLocationContext.js","sourceRoot":"","sources":["../../src/global-state/serverLocationContext.ts"],"names":[],"mappings":";;;AAAA,iIAAiI;AACjI,iCAAsC;AASzB,QAAA,aAAa,GAAG,IAAA,qBAAa,EAAgC,SAAS,CAAC,CAAC","sourcesContent":["// This is file should mirror https://github.com/react-navigation/react-navigation/blob/6.x/packages/native/src/ServerContext.tsx\nimport { createContext } from 'react';\n\nexport type ServerContextType = {\n location?: {\n pathname: string;\n search: string;\n };\n};\n\nexport const ServerContext = createContext<ServerContextType | undefined>(undefined);\n"]}
1
+ {"version":3,"file":"serverLocationContext.js","sourceRoot":"","sources":["../../src/global-state/serverLocationContext.ts"],"names":[],"mappings":";;;AAAA,iIAAiI;AACjI,iCAAsC;AAUzB,QAAA,aAAa,GAAG,IAAA,qBAAa,EAAgC,SAAS,CAAC,CAAC","sourcesContent":["// This is file should mirror https://github.com/react-navigation/react-navigation/blob/6.x/packages/native/src/ServerContext.tsx\nimport { createContext } from 'react';\n\nexport type ServerContextType = {\n location?: {\n pathname: string;\n search: string;\n hash?: string;\n };\n};\n\nexport const ServerContext = createContext<ServerContextType | undefined>(undefined);\n"]}