expo-router 4.0.18 → 4.0.20-canary-20250320-7a205d3

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 (98) hide show
  1. package/build/Route.d.ts +10 -10
  2. package/build/Route.d.ts.map +1 -1
  3. package/build/Route.js +4 -27
  4. package/build/Route.js.map +1 -1
  5. package/build/exports.d.ts +1 -0
  6. package/build/exports.d.ts.map +1 -1
  7. package/build/exports.js +3 -1
  8. package/build/exports.js.map +1 -1
  9. package/build/fork/NavigationContainer.js.map +1 -1
  10. package/build/fork/getStateFromPath-forks.d.ts +1 -1
  11. package/build/fork/useBackButton.d.ts +1 -1
  12. package/build/fork/useBackButton.d.ts.map +1 -1
  13. package/build/fork/useBackButton.js.map +1 -1
  14. package/build/fork/useDocumentTitle.d.ts +1 -1
  15. package/build/fork/useDocumentTitle.d.ts.map +1 -1
  16. package/build/fork/useDocumentTitle.js.map +1 -1
  17. package/build/fork/useLinking.d.ts +2 -1
  18. package/build/fork/useLinking.d.ts.map +1 -1
  19. package/build/fork/useLinking.js +5 -1
  20. package/build/fork/useLinking.js.map +1 -1
  21. package/build/fork/useLinking.native.d.ts +1 -0
  22. package/build/fork/useLinking.native.d.ts.map +1 -1
  23. package/build/fork/useLinking.native.js +21 -9
  24. package/build/fork/useLinking.native.js.map +1 -1
  25. package/build/getDevServer/index.native.d.ts.map +1 -1
  26. package/build/getDevServer/index.native.js +1 -1
  27. package/build/getDevServer/index.native.js.map +1 -1
  28. package/build/getRoutesCore.js +23 -19
  29. package/build/getRoutesCore.js.map +1 -1
  30. package/build/global-state/routing.d.ts +1 -1
  31. package/build/global-state/routing.js.map +1 -1
  32. package/build/head/ExpoHead.ios.d.ts.map +1 -1
  33. package/build/head/ExpoHead.ios.js +18 -3
  34. package/build/head/ExpoHead.ios.js.map +1 -1
  35. package/build/hooks.d.ts +23 -8
  36. package/build/hooks.d.ts.map +1 -1
  37. package/build/hooks.js +4 -4
  38. package/build/hooks.js.map +1 -1
  39. package/build/imperative-api.d.ts +2 -2
  40. package/build/imperative-api.js.map +1 -1
  41. package/build/layouts/DrawerClient.d.ts +6 -6
  42. package/build/layouts/StackClient.d.ts +6 -6
  43. package/build/layouts/TabsClient.d.ts +6 -6
  44. package/build/layouts/withLayoutContext.d.ts +28 -2
  45. package/build/layouts/withLayoutContext.d.ts.map +1 -1
  46. package/build/layouts/withLayoutContext.js +34 -4
  47. package/build/layouts/withLayoutContext.js.map +1 -1
  48. package/build/link/Link.d.ts +2 -2
  49. package/build/link/Link.d.ts.map +1 -1
  50. package/build/link/Link.js.map +1 -1
  51. package/build/link/linking.d.ts.map +1 -1
  52. package/build/link/linking.js +19 -17
  53. package/build/link/linking.js.map +1 -1
  54. package/build/link/useLinkHooks.d.ts +1 -1
  55. package/build/link/useLinkHooks.js.map +1 -1
  56. package/build/link/useLinkToPathProps.d.ts.map +1 -1
  57. package/build/link/useLinkToPathProps.js +2 -2
  58. package/build/link/useLinkToPathProps.js.map +1 -1
  59. package/build/rsc/router/client.js +1 -1
  60. package/build/rsc/router/client.js.map +1 -1
  61. package/build/rsc/router/host.d.ts +5 -5
  62. package/build/rsc/router/host.d.ts.map +1 -1
  63. package/build/rsc/router/host.js +15 -1
  64. package/build/rsc/router/host.js.map +1 -1
  65. package/build/typed-routes/types.d.ts +40 -16
  66. package/build/typed-routes/types.d.ts.map +1 -1
  67. package/build/typed-routes/types.js.map +1 -1
  68. package/build/ui/TabContext.d.ts +2 -8
  69. package/build/ui/TabContext.d.ts.map +1 -1
  70. package/build/ui/TabContext.js.map +1 -1
  71. package/build/ui/TabRouter.d.ts +1 -1
  72. package/build/ui/TabRouter.d.ts.map +1 -1
  73. package/build/ui/TabRouter.js.map +1 -1
  74. package/build/ui/TabSlot.d.ts +5 -6
  75. package/build/ui/TabSlot.d.ts.map +1 -1
  76. package/build/ui/TabSlot.js +4 -7
  77. package/build/ui/TabSlot.js.map +1 -1
  78. package/build/ui/Tabs.d.ts +13 -8
  79. package/build/ui/Tabs.d.ts.map +1 -1
  80. package/build/ui/Tabs.js +17 -4
  81. package/build/ui/Tabs.js.map +1 -1
  82. package/build/ui/useComponent.d.ts +1 -1
  83. package/build/ui/useComponent.d.ts.map +1 -1
  84. package/build/ui/useComponent.js.map +1 -1
  85. package/build/useNavigation.d.ts +2 -2
  86. package/build/useNavigation.js +2 -2
  87. package/build/useNavigation.js.map +1 -1
  88. package/build/useScreens.d.ts +5 -5
  89. package/build/useScreens.d.ts.map +1 -1
  90. package/build/useScreens.js +14 -8
  91. package/build/useScreens.js.map +1 -1
  92. package/build/views/Navigator.d.ts +1 -1
  93. package/build/views/Navigator.d.ts.map +1 -1
  94. package/build/views/Try.d.ts +1 -1
  95. package/expo-module.config.json +2 -3
  96. package/package.json +8 -9
  97. package/plugin/build/index.js +0 -4
  98. package/plugin/src/index.ts +0 -5
package/build/ui/Tabs.js CHANGED
@@ -53,7 +53,13 @@ function Tabs(props) {
53
53
  const Comp = asChild ? common_1.SafeAreaViewSlot : react_native_1.View;
54
54
  const { NavigationContent } = useTabsWithChildren({
55
55
  // asChild adds an extra layer, so we need to process the child's children
56
- children: asChild && (0, react_1.isValidElement)(children) ? children.props.children : children,
56
+ children: asChild &&
57
+ (0, react_1.isValidElement)(children) &&
58
+ children.props &&
59
+ typeof children.props === 'object' &&
60
+ 'children' in children.props
61
+ ? children.props.children
62
+ : children,
57
63
  ...options,
58
64
  });
59
65
  return (<Comp style={styles.tabsRoot} {...rest}>
@@ -63,7 +69,10 @@ function Tabs(props) {
63
69
  exports.Tabs = Tabs;
64
70
  /**
65
71
  * Hook version of `Tabs`. The returned NavigationContent component
66
- * should be rendered.
72
+ * should be rendered. Using the hook requires using the `<TabList />`
73
+ * and `<TabTrigger />` components exported from Expo Router.
74
+ *
75
+ * The `useTabsWithTriggers()` hook can be used for custom components.
67
76
  *
68
77
  * @see [`Tabs`](#tabs) for the component version of this hook.
69
78
  * @example
@@ -139,7 +148,11 @@ function parseTriggersFromChildren(children, screenTriggers = [], isInTabList =
139
148
  if ((0, TabList_1.isTabList)(child) && typeof child.props.children !== 'function') {
140
149
  let children = child.props.children;
141
150
  // <TabList asChild /> adds an extra layer. We need to parse the child's children
142
- if (child.props.asChild && (0, react_1.isValidElement)(children)) {
151
+ if (child.props.asChild &&
152
+ (0, react_1.isValidElement)(children) &&
153
+ children.props &&
154
+ typeof children.props === 'object' &&
155
+ 'children' in children.props) {
143
156
  children = children.props.children;
144
157
  }
145
158
  return parseTriggersFromChildren(children, screenTriggers, isInTabList || (0, TabList_1.isTabList)(child));
@@ -151,7 +164,7 @@ function parseTriggersFromChildren(children, screenTriggers = [], isInTabList =
151
164
  const { href, name } = child.props;
152
165
  if (!href) {
153
166
  if (process.env.NODE_ENV === 'development') {
154
- console.warn(`<TabTrigger name={${name}}> does not have a 'href' prop. TabTriggers within a <TabList /> are required to have a href.`);
167
+ console.warn(`<TabTrigger name={${name}}> does not have a 'href' prop. TabTriggers within a <TabList /> are required to have an href.`);
155
168
  }
156
169
  return;
157
170
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Tabs.js","sourceRoot":"","sources":["../../src/ui/Tabs.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,qDAQkC;AAClC,iCASe;AACf,+CAA2D;AAE3D,6CAKsB;AACtB,uCAAsC;AACtC,2CAAkE;AAClE,uCAAsC;AACtC,6CAA4C;AAC5C,qCAA8E;AAC9E,iDAA8C;AAC9C,oCAAuD;AACvD,oCAAwC;AACxC,uCAA2C;AAC3C,sCAAoD;AACpD,kDAA6E;AAE7E,+CAA6B;AAC7B,4CAA0B;AAC1B,4CAA0B;AAC1B,+CAA6B;AAyB7B;;;;;;;;;;;;;GAaG;AACH,SAAgB,IAAI,CAAC,KAAgB;IACnC,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,IAAI,EAAE,GAAG,KAAK,CAAC;IACtD,MAAM,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC,yBAA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G,CAAC,QAAQ,KAAK,aAAa,EAAE;gBAC1C,OAAO,CAAC,IAAI,CACV,qBAAqB,IAAI,+FAA+F,CACzH,CAAC;aACH;YACD,OAAO;SACR;QAED,MAAM,YAAY,GAAG,IAAA,kBAAW,EAAC,IAAI,CAAC,CAAC;QAEvC,IAAI,IAAA,0BAAoB,EAAC,YAAY,CAAC,EAAE;YACtC,OAAO,cAAc,CAAC,IAAI,CAAC;gBACzB,IAAI,EAAE,UAAU;gBAChB,IAAI;gBACJ,IAAI,EAAE,YAAY;aACnB,CAAC,CAAC;SACJ;QAED,IAAI,CAAC,IAAI,EAAE;YACT,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa,EAAE;gBAC1C,OAAO,CAAC,IAAI,CACV,yGAAyG,CAC1G,CAAC;aACH;YACD,OAAO;SACR;QAED,OAAO,cAAc,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7E,CAAC,CAAC,CAAC;IAEH,OAAO,cAAc,CAAC;AACxB,CAAC;AAED,SAAS,UAAU,CACjB,KAAwB;IAExB,OAAO,KAAK,CAAC,IAAI,KAAK,gBAAQ,CAAC;AACjC,CAAC;AAED,MAAM,MAAM,GAAG,yBAAU,CAAC,MAAM,CAAC;IAC/B,QAAQ,EAAE;QACR,IAAI,EAAE,CAAC;KACR;CACF,CAAC,CAAC","sourcesContent":["import {\n DefaultNavigatorOptions,\n LinkingContext,\n ParamListBase,\n TabActionHelpers,\n TabNavigationState,\n TabRouterOptions,\n useNavigationBuilder,\n} from '@react-navigation/native';\nimport {\n Children,\n ComponentProps,\n Fragment,\n ReactElement,\n ReactNode,\n isValidElement,\n useContext,\n useMemo,\n} from 'react';\nimport { StyleSheet, ViewProps, View } from 'react-native';\n\nimport {\n ExpoTabsScreenOptions,\n TabNavigationEventMap,\n TabTriggerMapContext,\n TabsContextValue,\n} from './TabContext';\nimport { isTabList } from './TabList';\nimport { ExpoTabRouter, ExpoTabRouterOptions } from './TabRouter';\nimport { isTabSlot } from './TabSlot';\nimport { isTabTrigger } from './TabTrigger';\nimport { SafeAreaViewSlot, ScreenTrigger, triggersToScreens } from './common';\nimport { useComponent } from './useComponent';\nimport { useRouteNode, useContextKey } from '../Route';\nimport { useRouteInfo } from '../hooks';\nimport { resolveHref } from '../link/href';\nimport { shouldLinkExternally } from '../utils/url';\nimport { NavigatorContext, NavigatorContextValue } from '../views/Navigator';\n\nexport * from './TabContext';\nexport * from './TabList';\nexport * from './TabSlot';\nexport * from './TabTrigger';\n\n/**\n * Options to provide to the Tab Router.\n */\nexport type UseTabsOptions = Omit<\n DefaultNavigatorOptions<\n ParamListBase,\n any,\n TabNavigationState<any>,\n ExpoTabsScreenOptions,\n TabNavigationEventMap,\n any\n >,\n 'children'\n> & {\n backBehavior?: TabRouterOptions['backBehavior'];\n};\n\nexport type TabsProps = ViewProps & {\n /** Forward props to child component and removes the extra `<View>`. Useful for custom wrappers. */\n asChild?: boolean;\n options?: UseTabsOptions;\n};\n\n/**\n * Root component for the headless tabs.\n *\n * @see [`useTabsWithChildren`](#usetabswithchildrenoptions) for a hook version of this component.\n * @example\n * ```tsx\n * <Tabs>\n * <TabSlot />\n * <TabList>\n * <TabTrigger name=\"home\" href=\"/\" />\n * </TabList>\n * </Tabs>\n * ```\n */\nexport function Tabs(props: TabsProps) {\n const { children, asChild, options, ...rest } = props;\n const Comp = asChild ? SafeAreaViewSlot : View;\n\n const { NavigationContent } = useTabsWithChildren({\n // asChild adds an extra layer, so we need to process the child's children\n children: asChild && isValidElement(children) ? children.props.children : children,\n ...options,\n });\n\n return (\n <Comp style={styles.tabsRoot} {...rest}>\n <NavigationContent>{children}</NavigationContent>\n </Comp>\n );\n}\n\nexport type UseTabsWithChildrenOptions = UseTabsOptions & {\n children: ReactNode;\n};\n\nexport type UseTabsWithTriggersOptions = UseTabsOptions & {\n triggers: ScreenTrigger[];\n};\n\n/**\n * Hook version of `Tabs`. The returned NavigationContent component\n * should be rendered.\n *\n * @see [`Tabs`](#tabs) for the component version of this hook.\n * @example\n * ```tsx\n * export function MyTabs({ children }) {\n * const { NavigationContent } = useTabsWithChildren({ children })\n *\n * return <NavigationContent />\n * }\n * ```\n */\nexport function useTabsWithChildren(options: UseTabsWithChildrenOptions) {\n const { children, ...rest } = options;\n return useTabsWithTriggers({ triggers: parseTriggersFromChildren(children), ...rest });\n}\n\n/**\n * Alternative hook version of `Tabs` that uses explicit triggers\n * instead of `children`.\n *\n * @see [`Tabs`](#tabs) for the component version of this hook.\n * @example\n * ```tsx\n * export function MyTabs({ children }) {\n * const { NavigationContent } = useTabsWithChildren({ triggers: [] })\n *\n * return <NavigationContent />\n * }\n * ```\n */\nexport function useTabsWithTriggers(options: UseTabsWithTriggersOptions): TabsContextValue {\n const { triggers, ...rest } = options;\n // Ensure we extend the parent triggers, so we can trigger them as well\n const parentTriggerMap = useContext(TabTriggerMapContext);\n const routeNode = useRouteNode();\n const contextKey = useContextKey();\n const linking = useContext(LinkingContext).options;\n const routeInfo = useRouteInfo();\n\n if (!routeNode || !linking) {\n throw new Error('No RouteNode. This is likely a bug in expo-router.');\n }\n\n const initialRouteName = routeNode.initialRouteName;\n\n const { children, triggerMap } = triggersToScreens(\n triggers,\n routeNode,\n linking,\n initialRouteName,\n parentTriggerMap,\n routeInfo,\n contextKey\n );\n\n const navigatorContext = useNavigationBuilder<\n TabNavigationState<any>,\n ExpoTabRouterOptions,\n TabActionHelpers<ParamListBase>,\n ExpoTabsScreenOptions,\n TabNavigationEventMap\n >(ExpoTabRouter, {\n children,\n ...rest,\n triggerMap,\n id: contextKey,\n initialRouteName,\n });\n\n const {\n state,\n descriptors,\n navigation,\n describe,\n NavigationContent: RNNavigationContent,\n } = navigatorContext;\n\n const navigatorContextValue = useMemo<NavigatorContextValue>(\n () => ({\n ...(navigatorContext as unknown as ReturnType<typeof useNavigationBuilder>),\n contextKey,\n router: ExpoTabRouter,\n }),\n [navigatorContext, contextKey, ExpoTabRouter]\n );\n\n const NavigationContent = useComponent((children: React.ReactNode) => (\n <TabTriggerMapContext.Provider value={triggerMap}>\n <NavigatorContext.Provider value={navigatorContextValue}>\n <RNNavigationContent>{children}</RNNavigationContent>\n </NavigatorContext.Provider>\n </TabTriggerMapContext.Provider>\n )) as TabsContextValue['NavigationContent'];\n\n return { state, descriptors, navigation, NavigationContent, describe };\n}\n\nfunction parseTriggersFromChildren(\n children: ReactNode,\n screenTriggers: ScreenTrigger[] = [],\n isInTabList = false\n) {\n Children.forEach(children, (child) => {\n if (!child || !isValidElement(child) || isTabSlot(child)) {\n return;\n }\n\n if (isFragment(child) && typeof child.props.children !== 'function') {\n return parseTriggersFromChildren(\n child.props.children,\n screenTriggers,\n isInTabList || isTabList(child)\n );\n }\n\n if (isTabList(child) && typeof child.props.children !== 'function') {\n let children = child.props.children;\n\n // <TabList asChild /> adds an extra layer. We need to parse the child's children\n if (child.props.asChild && isValidElement(children)) {\n children = children.props.children;\n }\n\n return parseTriggersFromChildren(children, screenTriggers, isInTabList || isTabList(child));\n }\n\n // We should only process TabTriggers within the TabList. All other components will be ignored\n if (!isInTabList || !isTabTrigger(child)) {\n return;\n }\n\n const { href, name } = child.props;\n\n if (!href) {\n if (process.env.NODE_ENV === 'development') {\n console.warn(\n `<TabTrigger name={${name}}> does not have a 'href' prop. TabTriggers within a <TabList /> are required to have a href.`\n );\n }\n return;\n }\n\n const resolvedHref = resolveHref(href);\n\n if (shouldLinkExternally(resolvedHref)) {\n return screenTriggers.push({\n type: 'external',\n name,\n href: resolvedHref,\n });\n }\n\n if (!name) {\n if (process.env.NODE_ENV === 'development') {\n console.warn(\n `<TabTrigger> does not have a 'name' prop. TabTriggers within a <TabList /> are required to have a name.`\n );\n }\n return;\n }\n\n return screenTriggers.push({ type: 'internal', href: resolvedHref, name });\n });\n\n return screenTriggers;\n}\n\nfunction isFragment(\n child: ReactElement<any>\n): child is ReactElement<ComponentProps<typeof Fragment>> {\n return child.type === Fragment;\n}\n\nconst styles = StyleSheet.create({\n tabsRoot: {\n flex: 1,\n },\n});\n"]}
1
+ {"version":3,"file":"Tabs.js","sourceRoot":"","sources":["../../src/ui/Tabs.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,qDAQkC;AAClC,iCAUe;AACf,+CAA2D;AAE3D,6CAKsB;AACtB,uCAAsC;AACtC,2CAAkE;AAClE,uCAAsC;AACtC,6CAA4C;AAC5C,qCAA8E;AAC9E,iDAA8C;AAC9C,oCAAuD;AACvD,oCAAwC;AACxC,uCAA2C;AAC3C,sCAAoD;AACpD,kDAA6E;AAE7E,+CAA6B;AAC7B,4CAA0B;AAC1B,4CAA0B;AAC1B,+CAA6B;AA0B7B;;;;;;;;;;;;;GAaG;AACH,SAAgB,IAAI,CAAC,KAAgB;IACnC,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,IAAI,EAAE,GAAG,KAAK,CAAC;IACtD,MAAM,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC,yBAAgB,CAAC,CAAC,CAAC,mBAAI,CAAC;IAE/C,MAAM,EAAE,iBAAiB,EAAE,GAAG,mBAAmB,CAAC;QAChD,0EAA0E;QAC1E,QAAQ,EACN,OAAO;YACP,IAAA,sBAAc,EAAC,QAAQ,CAAC;YACxB,QAAQ,CAAC,KAAK;YACd,OAAO,QAAQ,CAAC,KAAK,KAAK,QAAQ;YAClC,UAAU,IAAI,QAAQ,CAAC,KAAK;YAC1B,CAAC,CAAE,QAAQ,CAAC,KAAK,CAAC,QAAsB;YACxC,CAAC,CAAC,QAAQ;QACd,GAAG,OAAO;KACX,CAAC,CAAC;IAEH,OAAO,CACL,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,IAAI,IAAI,CAAC,CACrC;MAAA,CAAC,iBAAiB,CAAC,CAAC,QAAQ,CAAC,EAAE,iBAAiB,CAClD;IAAA,EAAE,IAAI,CAAC,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,IAAI,CAAC,IAAI,EAAE;YACT,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa,EAAE;gBAC1C,OAAO,CAAC,IAAI,CACV,yGAAyG,CAC1G,CAAC;aACH;YACD,OAAO;SACR;QAED,OAAO,cAAc,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7E,CAAC,CAAC,CAAC;IAEH,OAAO,cAAc,CAAC;AACxB,CAAC;AAED,SAAS,UAAU,CACjB,KAAwB;IAExB,OAAO,KAAK,CAAC,IAAI,KAAK,gBAAQ,CAAC;AACjC,CAAC;AAED,MAAM,MAAM,GAAG,yBAAU,CAAC,MAAM,CAAC;IAC/B,QAAQ,EAAE;QACR,IAAI,EAAE,CAAC;KACR;CACF,CAAC,CAAC","sourcesContent":["import {\n DefaultNavigatorOptions,\n LinkingContext,\n ParamListBase,\n TabActionHelpers,\n TabNavigationState,\n TabRouterOptions,\n useNavigationBuilder,\n} from '@react-navigation/native';\nimport {\n Children,\n ComponentProps,\n Fragment,\n ReactElement,\n ReactNode,\n isValidElement,\n useContext,\n useMemo,\n PropsWithChildren,\n} from 'react';\nimport { StyleSheet, ViewProps, View } from 'react-native';\n\nimport {\n ExpoTabsScreenOptions,\n TabNavigationEventMap,\n TabTriggerMapContext,\n TabsContextValue,\n} from './TabContext';\nimport { isTabList } from './TabList';\nimport { ExpoTabRouter, ExpoTabRouterOptions } from './TabRouter';\nimport { isTabSlot } from './TabSlot';\nimport { isTabTrigger } from './TabTrigger';\nimport { SafeAreaViewSlot, ScreenTrigger, triggersToScreens } from './common';\nimport { useComponent } from './useComponent';\nimport { useRouteNode, useContextKey } from '../Route';\nimport { useRouteInfo } from '../hooks';\nimport { resolveHref } from '../link/href';\nimport { shouldLinkExternally } from '../utils/url';\nimport { NavigatorContext, NavigatorContextValue } from '../views/Navigator';\n\nexport * from './TabContext';\nexport * from './TabList';\nexport * from './TabSlot';\nexport * from './TabTrigger';\nexport { ExpoTabsResetValue } from './TabRouter';\n\n/**\n * Options to provide to the Tab Router.\n */\nexport type UseTabsOptions = Omit<\n DefaultNavigatorOptions<\n ParamListBase,\n any,\n TabNavigationState<any>,\n ExpoTabsScreenOptions,\n TabNavigationEventMap,\n any\n >,\n 'children'\n> & {\n backBehavior?: TabRouterOptions['backBehavior'];\n};\n\nexport type TabsProps = ViewProps & {\n /** Forward props to child component and removes the extra `<View>`. Useful for custom wrappers. */\n asChild?: boolean;\n options?: UseTabsOptions;\n};\n\n/**\n * Root component for the headless tabs.\n *\n * @see [`useTabsWithChildren`](#usetabswithchildrenoptions) for a hook version of this component.\n * @example\n * ```tsx\n * <Tabs>\n * <TabSlot />\n * <TabList>\n * <TabTrigger name=\"home\" href=\"/\" />\n * </TabList>\n * </Tabs>\n * ```\n */\nexport function Tabs(props: TabsProps) {\n const { children, asChild, options, ...rest } = props;\n const Comp = asChild ? SafeAreaViewSlot : View;\n\n const { NavigationContent } = useTabsWithChildren({\n // asChild adds an extra layer, so we need to process the child's children\n children:\n asChild &&\n isValidElement(children) &&\n children.props &&\n typeof children.props === 'object' &&\n 'children' in children.props\n ? (children.props.children as ReactNode)\n : children,\n ...options,\n });\n\n return (\n <Comp style={styles.tabsRoot} {...rest}>\n <NavigationContent>{children}</NavigationContent>\n </Comp>\n );\n}\n\n// @docsMissing\nexport type UseTabsWithChildrenOptions = PropsWithChildren<UseTabsOptions>;\n\n// @docsMissing\nexport type UseTabsWithTriggersOptions = UseTabsOptions & {\n triggers: ScreenTrigger[];\n};\n\n/**\n * Hook version of `Tabs`. The returned NavigationContent component\n * should be rendered. Using the hook requires using the `<TabList />`\n * and `<TabTrigger />` components exported from Expo Router.\n *\n * The `useTabsWithTriggers()` hook can be used for custom components.\n *\n * @see [`Tabs`](#tabs) for the component version of this hook.\n * @example\n * ```tsx\n * export function MyTabs({ children }) {\n * const { NavigationContent } = useTabsWithChildren({ children })\n *\n * return <NavigationContent />\n * }\n * ```\n */\nexport function useTabsWithChildren(options: UseTabsWithChildrenOptions) {\n const { children, ...rest } = options;\n return useTabsWithTriggers({ triggers: parseTriggersFromChildren(children), ...rest });\n}\n\n/**\n * Alternative hook version of `Tabs` that uses explicit triggers\n * instead of `children`.\n *\n * @see [`Tabs`](#tabs) for the component version of this hook.\n * @example\n * ```tsx\n * export function MyTabs({ children }) {\n * const { NavigationContent } = useTabsWithChildren({ triggers: [] })\n *\n * return <NavigationContent />\n * }\n * ```\n */\nexport function useTabsWithTriggers(options: UseTabsWithTriggersOptions): TabsContextValue {\n const { triggers, ...rest } = options;\n // Ensure we extend the parent triggers, so we can trigger them as well\n const parentTriggerMap = useContext(TabTriggerMapContext);\n const routeNode = useRouteNode();\n const contextKey = useContextKey();\n const linking = useContext(LinkingContext).options;\n const routeInfo = useRouteInfo();\n\n if (!routeNode || !linking) {\n throw new Error('No RouteNode. This is likely a bug in expo-router.');\n }\n\n const initialRouteName = routeNode.initialRouteName;\n\n const { children, triggerMap } = triggersToScreens(\n triggers,\n routeNode,\n linking,\n initialRouteName,\n parentTriggerMap,\n routeInfo,\n contextKey\n );\n\n const navigatorContext = useNavigationBuilder<\n TabNavigationState<any>,\n ExpoTabRouterOptions,\n TabActionHelpers<ParamListBase>,\n ExpoTabsScreenOptions,\n TabNavigationEventMap\n >(ExpoTabRouter, {\n children,\n ...rest,\n triggerMap,\n id: contextKey,\n initialRouteName,\n });\n\n const {\n state,\n descriptors,\n navigation,\n describe,\n NavigationContent: RNNavigationContent,\n } = navigatorContext;\n\n const navigatorContextValue = useMemo<NavigatorContextValue>(\n () => ({\n ...(navigatorContext as unknown as ReturnType<typeof useNavigationBuilder>),\n contextKey,\n router: ExpoTabRouter,\n }),\n [navigatorContext, contextKey, ExpoTabRouter]\n );\n\n const NavigationContent = useComponent((children: React.ReactNode) => (\n <TabTriggerMapContext.Provider value={triggerMap}>\n <NavigatorContext.Provider value={navigatorContextValue}>\n <RNNavigationContent>{children}</RNNavigationContent>\n </NavigatorContext.Provider>\n </TabTriggerMapContext.Provider>\n )) as TabsContextValue['NavigationContent'];\n\n return { state, descriptors, navigation, NavigationContent, describe };\n}\n\nfunction parseTriggersFromChildren(\n children: ReactNode,\n screenTriggers: ScreenTrigger[] = [],\n isInTabList = false\n) {\n Children.forEach(children, (child) => {\n if (!child || !isValidElement(child) || isTabSlot(child)) {\n return;\n }\n\n if (isFragment(child) && typeof child.props.children !== 'function') {\n return parseTriggersFromChildren(\n child.props.children,\n screenTriggers,\n isInTabList || isTabList(child)\n );\n }\n\n if (isTabList(child) && typeof child.props.children !== 'function') {\n let children = child.props.children;\n\n // <TabList asChild /> adds an extra layer. We need to parse the child's children\n if (\n child.props.asChild &&\n isValidElement(children) &&\n children.props &&\n typeof children.props === 'object' &&\n 'children' in children.props\n ) {\n children = children.props.children as ReactNode;\n }\n\n return parseTriggersFromChildren(children, screenTriggers, isInTabList || isTabList(child));\n }\n\n // We should only process TabTriggers within the TabList. All other components will be ignored\n if (!isInTabList || !isTabTrigger(child)) {\n return;\n }\n\n const { href, name } = child.props;\n\n if (!href) {\n if (process.env.NODE_ENV === 'development') {\n console.warn(\n `<TabTrigger name={${name}}> does not have a 'href' prop. TabTriggers within a <TabList /> are required to have an href.`\n );\n }\n return;\n }\n\n const resolvedHref = resolveHref(href);\n\n if (shouldLinkExternally(resolvedHref)) {\n return screenTriggers.push({\n type: 'external',\n name,\n href: resolvedHref,\n });\n }\n\n if (!name) {\n if (process.env.NODE_ENV === 'development') {\n console.warn(\n `<TabTrigger> does not have a 'name' prop. TabTriggers within a <TabList /> are required to have a name.`\n );\n }\n return;\n }\n\n return screenTriggers.push({ type: 'internal', href: resolvedHref, name });\n });\n\n return screenTriggers;\n}\n\nfunction isFragment(\n child: ReactElement<any>\n): child is ReactElement<ComponentProps<typeof Fragment>> {\n return child.type === Fragment;\n}\n\nconst styles = StyleSheet.create({\n tabsRoot: {\n flex: 1,\n },\n});\n"]}
@@ -1,4 +1,4 @@
1
- /// <reference types="react" />
1
+ import { JSX } from 'react';
2
2
  /**
3
3
  * Copied from @react-navigation/core
4
4
  */
@@ -1 +1 @@
1
- {"version":3,"file":"useComponent.d.ts","sourceRoot":"","sources":["../../src/ui/useComponent.tsx"],"names":[],"mappings":";AAEA;;GAEG;AACH,KAAK,MAAM,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,SAAS,KAAK,GAAG,CAAC,OAAO,CAAC;AAWzD,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM;cAaD,MAAM,SAAS;4CAYxD"}
1
+ {"version":3,"file":"useComponent.d.ts","sourceRoot":"","sources":["../../src/ui/useComponent.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAiC,GAAG,EAAE,MAAM,OAAO,CAAC;AAE3D;;GAEG;AACH,KAAK,MAAM,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,SAAS,KAAK,GAAG,CAAC,OAAO,CAAC;AAWzD,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM;cAaD,MAAM,SAAS;4CAYxD"}
@@ -1 +1 @@
1
- {"version":3,"file":"useComponent.js","sourceRoot":"","sources":["../../src/ui/useComponent.tsx"],"names":[],"mappings":";;;AAAA,iCAAsD;AAYtD,MAAM,iBAAiB,GAAG,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAS,EAAE,EAAE;IACxD,OAAO,MAAM,CAAC,QAAQ,CAAC,CAAC;AAC1B,CAAC,CAAC;AAEF,SAAgB,YAAY,CAAC,MAAc;IACzC,MAAM,SAAS,GAAG,IAAA,cAAM,EAAgB,MAAM,CAAC,CAAC;IAEhD,+CAA+C;IAC/C,mDAAmD;IACnD,yCAAyC;IACzC,SAAS,CAAC,OAAO,GAAG,MAAM,CAAC;IAE3B,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,SAAS,CAAC,OAAO,GAAG,IAAI,CAAC;IAC3B,CAAC,CAAC,CAAC;IAEH,OAAO,IAAA,cAAM,EACX,IAAA,kBAAU,EAAC,CAAC,EAAE,QAAQ,EAAiC,EAAE,IAAI,EAAE,EAAE;QAC/D,MAAM,MAAM,GAAG,SAAS,CAAC,OAAO,CAAC;QAEjC,IAAI,MAAM,KAAK,IAAI,EAAE;YACnB,MAAM,IAAI,KAAK,CACb,+EAA+E,CAChF,CAAC;SACH;QAED,OAAO,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,iBAAiB,CAAC,CAAC;IAC3E,CAAC,CAAC,CACH,CAAC,OAAO,CAAC;AACZ,CAAC;AAzBD,oCAyBC","sourcesContent":["import { useRef, forwardRef, useEffect } from 'react';\n\n/**\n * Copied from @react-navigation/core\n */\ntype Render = (children: React.ReactNode) => JSX.Element;\n\ntype Props = {\n render: Render;\n children: React.ReactNode;\n};\n\nconst NavigationContent = ({ render, children }: Props) => {\n return render(children);\n};\n\nexport function useComponent(render: Render) {\n const renderRef = useRef<Render | null>(render);\n\n // Normally refs shouldn't be mutated in render\n // But we return a component which will be rendered\n // So it's just for immediate consumption\n renderRef.current = render;\n\n useEffect(() => {\n renderRef.current = null;\n });\n\n return useRef(\n forwardRef(({ children }: { children: React.ReactNode }, _ref) => {\n const render = renderRef.current;\n\n if (render === null) {\n throw new Error(\n 'The returned component must be rendered in the same render phase as the hook.'\n );\n }\n\n return <NavigationContent render={render}>{children}</NavigationContent>;\n })\n ).current;\n}\n"]}
1
+ {"version":3,"file":"useComponent.js","sourceRoot":"","sources":["../../src/ui/useComponent.tsx"],"names":[],"mappings":";;;AAAA,iCAA2D;AAY3D,MAAM,iBAAiB,GAAG,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAS,EAAE,EAAE;IACxD,OAAO,MAAM,CAAC,QAAQ,CAAC,CAAC;AAC1B,CAAC,CAAC;AAEF,SAAgB,YAAY,CAAC,MAAc;IACzC,MAAM,SAAS,GAAG,IAAA,cAAM,EAAgB,MAAM,CAAC,CAAC;IAEhD,+CAA+C;IAC/C,mDAAmD;IACnD,yCAAyC;IACzC,SAAS,CAAC,OAAO,GAAG,MAAM,CAAC;IAE3B,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,SAAS,CAAC,OAAO,GAAG,IAAI,CAAC;IAC3B,CAAC,CAAC,CAAC;IAEH,OAAO,IAAA,cAAM,EACX,IAAA,kBAAU,EAAC,CAAC,EAAE,QAAQ,EAAiC,EAAE,IAAI,EAAE,EAAE;QAC/D,MAAM,MAAM,GAAG,SAAS,CAAC,OAAO,CAAC;QAEjC,IAAI,MAAM,KAAK,IAAI,EAAE;YACnB,MAAM,IAAI,KAAK,CACb,+EAA+E,CAChF,CAAC;SACH;QAED,OAAO,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,iBAAiB,CAAC,CAAC;IAC3E,CAAC,CAAC,CACH,CAAC,OAAO,CAAC;AACZ,CAAC;AAzBD,oCAyBC","sourcesContent":["import { useRef, forwardRef, useEffect, JSX } from 'react';\n\n/**\n * Copied from @react-navigation/core\n */\ntype Render = (children: React.ReactNode) => JSX.Element;\n\ntype Props = {\n render: Render;\n children: React.ReactNode;\n};\n\nconst NavigationContent = ({ render, children }: Props) => {\n return render(children);\n};\n\nexport function useComponent(render: Render) {\n const renderRef = useRef<Render | null>(render);\n\n // Normally refs shouldn't be mutated in render\n // But we return a component which will be rendered\n // So it's just for immediate consumption\n renderRef.current = render;\n\n useEffect(() => {\n renderRef.current = null;\n });\n\n return useRef(\n forwardRef(({ children }: { children: React.ReactNode }, _ref) => {\n const render = renderRef.current;\n\n if (render === null) {\n throw new Error(\n 'The returned component must be rendered in the same render phase as the hook.'\n );\n }\n\n return <NavigationContent render={render}>{children}</NavigationContent>;\n })\n ).current;\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  import { NavigationProp, NavigationState } from '@react-navigation/native';
2
2
  import { Href } from './types';
3
3
  /**
4
- * Returns the underlying React Navigation [`navigation` prop](https://reactnavigation.org/docs/navigation-prop)
4
+ * Returns the underlying React Navigation [`navigation` object](https://reactnavigation.org/docs/navigation-object)
5
5
  * to imperatively access layout-specific functionality like `navigation.openDrawer()` in a
6
6
  * [Drawer](/router/advanced/drawer/) layout.
7
7
  *
@@ -49,7 +49,7 @@ import { Href } from './types';
49
49
  * @param parent Provide an absolute path such as `/(root)` to the parent route or a relative path like `../../` to the parent route.
50
50
  * @returns The navigation object for the current route.
51
51
  *
52
- * @see React Navigation documentation on [navigation dependent functions](https://reactnavigation.org/docs/navigation-prop/#navigator-dependent-functions)
52
+ * @see React Navigation documentation on [navigation dependent functions](https://reactnavigation.org/docs/navigation-object/#navigator-dependent-functions)
53
53
  * for more information.
54
54
  */
55
55
  export declare function useNavigation<T = Omit<NavigationProp<ReactNavigation.RootParamList>, 'getState'> & {
@@ -11,7 +11,7 @@ const router_store_1 = require("./global-state/router-store");
11
11
  const hooks_1 = require("./hooks");
12
12
  const href_1 = require("./link/href");
13
13
  /**
14
- * Returns the underlying React Navigation [`navigation` prop](https://reactnavigation.org/docs/navigation-prop)
14
+ * Returns the underlying React Navigation [`navigation` object](https://reactnavigation.org/docs/navigation-object)
15
15
  * to imperatively access layout-specific functionality like `navigation.openDrawer()` in a
16
16
  * [Drawer](/router/advanced/drawer/) layout.
17
17
  *
@@ -59,7 +59,7 @@ const href_1 = require("./link/href");
59
59
  * @param parent Provide an absolute path such as `/(root)` to the parent route or a relative path like `../../` to the parent route.
60
60
  * @returns The navigation object for the current route.
61
61
  *
62
- * @see React Navigation documentation on [navigation dependent functions](https://reactnavigation.org/docs/navigation-prop/#navigator-dependent-functions)
62
+ * @see React Navigation documentation on [navigation dependent functions](https://reactnavigation.org/docs/navigation-object/#navigator-dependent-functions)
63
63
  * for more information.
64
64
  */
65
65
  function useNavigation(parent) {
@@ -1 +1 @@
1
- {"version":3,"file":"useNavigation.js","sourceRoot":"","sources":["../src/useNavigation.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;AACb,qDAIkC;AAClC,kDAA0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n NavigationProp,\n NavigationState,\n} from '@react-navigation/native';\nimport React from 'react';\n\nimport { store } from './global-state/router-store';\nimport { useSegments } from './hooks';\nimport { resolveHref } from './link/href';\nimport { Href } from './types';\n\n/**\n * Returns the underlying React Navigation [`navigation` prop](https://reactnavigation.org/docs/navigation-prop)\n * to imperatively access layout-specific functionality like `navigation.openDrawer()` in a\n * [Drawer](/router/advanced/drawer/) layout.\n *\n * @example\n * ```tsx app/index.tsx\n * import { useNavigation } from 'expo-router';\n *\n * export default function Route() {\n * // Access the current navigation object for the current route.\n * const navigation = useNavigation();\n *\n * return (\n * <View>\n * <Text onPress={() => {\n * // Open the drawer view.\n * navigation.openDrawer();\n * }}>\n * Open Drawer\n * </Text>\n * </View>\n * );\n * }\n * ```\n *\n * When using nested layouts, you can access higher-order layouts by passing a secondary argument denoting the layout route.\n * For example, `/menu/_layout.tsx` is nested inside `/app/orders/`, you can use `useNavigation('/orders/menu/')`.\n *\n * @example\n * ```tsx app/orders/menu/index.tsx\n * import { useNavigation } from 'expo-router';\n *\n * export default function MenuRoute() {\n * const rootLayout = useNavigation('/');\n * const ordersLayout = useNavigation('/orders');\n *\n * // Same as the default results of `useNavigation()` when invoked in this route.\n * const parentLayout = useNavigation('/orders/menu');\n * }\n * ```\n *\n * If you attempt to access a layout that doesn't exist, an error such as\n * `Could not find parent navigation with route \"/non-existent\"` is thrown.\n *\n *\n * @param parent Provide an absolute path such as `/(root)` to the parent route or a relative path like `../../` to the parent route.\n * @returns The navigation object for the current route.\n *\n * @see React Navigation documentation on [navigation dependent functions](https://reactnavigation.org/docs/navigation-prop/#navigator-dependent-functions)\n * for more information.\n */\nexport function useNavigation<\n T = Omit<NavigationProp<ReactNavigation.RootParamList>, 'getState'> & {\n getState(): NavigationState | undefined;\n },\n>(parent?: string | Href): T {\n let navigation = useUpstreamNavigation<any>();\n const initialNavigation = navigation;\n const segments = useSegments();\n\n const targetNavigatorContextKey = React.useMemo(() => {\n if (!parent) {\n return;\n }\n\n if (typeof parent === 'object') {\n parent = resolveHref(parent);\n }\n\n if (parent === '/') {\n return '';\n }\n\n let state = store.getStateFromPath(parent.startsWith('../') ? segments.join('/') : parent);\n\n // Reconstruct the context key from the state\n let contextKey = '';\n const names: string[] = [];\n\n while (state) {\n const routes = state.routes;\n const route = routes[state.index ?? routes.length - 1];\n\n if (route.state) {\n contextKey = `${contextKey}/${route.name}`;\n names.push(route.name);\n\n if (parent === contextKey) {\n break;\n }\n\n state = route.state;\n } else {\n break;\n }\n }\n\n if (parent.startsWith('../')) {\n const parentSegments = parent.split('/').filter(Boolean);\n\n for (const segment of parentSegments) {\n if (segment === '..') {\n names.pop();\n } else {\n throw new Error(\n \"Relative parent paths may only contain '..' and cannot contain other segments\"\n );\n }\n }\n\n contextKey = names.length > 0 ? `/${names.join('/')}` : '';\n }\n\n return contextKey;\n }, [segments, parent]);\n\n if (targetNavigatorContextKey !== undefined) {\n navigation = navigation.getParent(targetNavigatorContextKey as any);\n }\n\n if (!navigation) {\n const ids: (string | undefined)[] = [];\n\n navigation = initialNavigation;\n\n while (navigation) {\n ids.push(navigation.getId() || '/');\n navigation = navigation.getParent();\n }\n\n throw new Error(\n `Could not find parent navigation with route \"${parent}\". Available routes are: '${ids.join(\"', '\")}'`\n );\n }\n\n return navigation;\n}\n"]}
1
+ {"version":3,"file":"useNavigation.js","sourceRoot":"","sources":["../src/useNavigation.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;AACb,qDAIkC;AAClC,kDAA0B;AAE1B,8DAAoD;AACpD,mCAAsC;AACtC,sCAA0C;AAG1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,SAAgB,aAAa,CAI3B,MAAsB;IACtB,IAAI,UAAU,GAAG,IAAA,sBAAqB,GAAO,CAAC;IAC9C,MAAM,iBAAiB,GAAG,UAAU,CAAC;IACrC,MAAM,QAAQ,GAAG,IAAA,mBAAW,GAAE,CAAC;IAE/B,MAAM,y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I,EAAE;oBACpB,KAAK,CAAC,GAAG,EAAE,CAAC;iBACb;qBAAM;oBACL,MAAM,IAAI,KAAK,CACb,+EAA+E,CAChF,CAAC;iBACH;aACF;YAED,UAAU,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC5D;QAED,OAAO,UAAU,CAAC;IACpB,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;IAEvB,IAAI,yBAAyB,KAAK,SAAS,EAAE;QAC3C,UAAU,GAAG,UAAU,CAAC,SAAS,CAAC,yBAAgC,CAAC,CAAC;KACrE;IAED,IAAI,CAAC,UAAU,EAAE;QACf,MAAM,GAAG,GAA2B,EAAE,CAAC;QAEvC,UAAU,GAAG,iBAAiB,CAAC;QAE/B,OAAO,UAAU,EAAE;YACjB,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,IAAI,GAAG,CAAC,CAAC;YACpC,UAAU,GAAG,UAAU,CAAC,SAAS,EAAE,CAAC;SACrC;QAED,MAAM,IAAI,KAAK,CACb,gDAAgD,MAAM,6BAA6B,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CACvG,CAAC;KACH;IAED,OAAO,UAAU,CAAC;AACpB,CAAC;AArFD,sCAqFC","sourcesContent":["'use client';\nimport {\n useNavigation as useUpstreamNavigation,\n NavigationProp,\n NavigationState,\n} from '@react-navigation/native';\nimport React from 'react';\n\nimport { store } from './global-state/router-store';\nimport { useSegments } from './hooks';\nimport { resolveHref } from './link/href';\nimport { Href } from './types';\n\n/**\n * Returns the underlying React Navigation [`navigation` object](https://reactnavigation.org/docs/navigation-object)\n * to imperatively access layout-specific functionality like `navigation.openDrawer()` in a\n * [Drawer](/router/advanced/drawer/) layout.\n *\n * @example\n * ```tsx app/index.tsx\n * import { useNavigation } from 'expo-router';\n *\n * export default function Route() {\n * // Access the current navigation object for the current route.\n * const navigation = useNavigation();\n *\n * return (\n * <View>\n * <Text onPress={() => {\n * // Open the drawer view.\n * navigation.openDrawer();\n * }}>\n * Open Drawer\n * </Text>\n * </View>\n * );\n * }\n * ```\n *\n * When using nested layouts, you can access higher-order layouts by passing a secondary argument denoting the layout route.\n * For example, `/menu/_layout.tsx` is nested inside `/app/orders/`, you can use `useNavigation('/orders/menu/')`.\n *\n * @example\n * ```tsx app/orders/menu/index.tsx\n * import { useNavigation } from 'expo-router';\n *\n * export default function MenuRoute() {\n * const rootLayout = useNavigation('/');\n * const ordersLayout = useNavigation('/orders');\n *\n * // Same as the default results of `useNavigation()` when invoked in this route.\n * const parentLayout = useNavigation('/orders/menu');\n * }\n * ```\n *\n * If you attempt to access a layout that doesn't exist, an error such as\n * `Could not find parent navigation with route \"/non-existent\"` is thrown.\n *\n *\n * @param parent Provide an absolute path such as `/(root)` to the parent route or a relative path like `../../` to the parent route.\n * @returns The navigation object for the current route.\n *\n * @see React Navigation documentation on [navigation dependent functions](https://reactnavigation.org/docs/navigation-object/#navigator-dependent-functions)\n * for more information.\n */\nexport function useNavigation<\n T = Omit<NavigationProp<ReactNavigation.RootParamList>, 'getState'> & {\n getState(): NavigationState | undefined;\n },\n>(parent?: string | Href): T {\n let navigation = useUpstreamNavigation<any>();\n const initialNavigation = navigation;\n const segments = useSegments();\n\n const targetNavigatorContextKey = React.useMemo(() => {\n if (!parent) {\n return;\n }\n\n if (typeof parent === 'object') {\n parent = resolveHref(parent);\n }\n\n if (parent === '/') {\n return '';\n }\n\n let state = store.getStateFromPath(parent.startsWith('../') ? segments.join('/') : parent);\n\n // Reconstruct the context key from the state\n let contextKey = '';\n const names: string[] = [];\n\n while (state) {\n const routes = state.routes;\n const route = routes[state.index ?? routes.length - 1];\n\n if (route.state) {\n contextKey = `${contextKey}/${route.name}`;\n names.push(route.name);\n\n if (parent === contextKey) {\n break;\n }\n\n state = route.state;\n } else {\n break;\n }\n }\n\n if (parent.startsWith('../')) {\n const parentSegments = parent.split('/').filter(Boolean);\n\n for (const segment of parentSegments) {\n if (segment === '..') {\n names.pop();\n } else {\n throw new Error(\n \"Relative parent paths may only contain '..' and cannot contain other segments\"\n );\n }\n }\n\n contextKey = names.length > 0 ? `/${names.join('/')}` : '';\n }\n\n return contextKey;\n }, [segments, parent]);\n\n if (targetNavigatorContextKey !== undefined) {\n navigation = navigation.getParent(targetNavigatorContextKey as any);\n }\n\n if (!navigation) {\n const ids: (string | undefined)[] = [];\n\n navigation = initialNavigation;\n\n while (navigation) {\n ids.push(navigation.getId() || '/');\n navigation = navigation.getParent();\n }\n\n throw new Error(\n `Could not find parent navigation with route \"${parent}\". Available routes are: '${ids.join(\"', '\")}'`\n );\n }\n\n return navigation;\n}\n"]}
@@ -28,10 +28,10 @@ export type ScreenProps<TOptions extends Record<string, any> = Record<string, an
28
28
  export declare function useSortedScreens(order: ScreenProps[]): React.ReactNode[];
29
29
  /** Wrap the component with various enhancements and add access to child routes. */
30
30
  export declare function getQualifiedRouteComponent(value: RouteNode): React.ComponentType<any> | React.ForwardRefExoticComponent<Omit<any, "ref"> & React.RefAttributes<unknown>>;
31
- /** @returns a function which provides a screen id that matches the dynamic route name in params. */
32
- export declare function createGetIdForRoute(route: Pick<RouteNode, 'dynamic' | 'route' | 'contextKey' | 'children'>): ({ params }?: {
33
- params?: Record<string, any> | undefined;
34
- }) => any;
31
+ /**
32
+ * @param getId Override that will be wrapped to remove __EXPO_ROUTER_key which is added by PUSH
33
+ * @returns a function which provides a screen id that matches the dynamic route name in params. */
34
+ export declare function createGetIdForRoute(route: Pick<RouteNode, 'dynamic' | 'route' | 'contextKey' | 'children'>, getId: ScreenProps['getId']): ScreenProps['getId'];
35
35
  export declare function screenOptionsFactory(route: RouteNode, options?: ScreenProps['options']): RouteConfig<any, any, any, any, any, any>['options'];
36
- export declare function routeToScreen(route: RouteNode, { options, ...props }?: Partial<ScreenProps>): React.JSX.Element;
36
+ export declare function routeToScreen(route: RouteNode, { options, getId, ...props }?: Partial<ScreenProps>): React.JSX.Element;
37
37
  //# sourceMappingURL=useScreens.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useScreens.d.ts","sourceRoot":"","sources":["../src/useScreens.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,YAAY,EACZ,eAAe,EACf,aAAa,EACb,WAAW,EACX,SAAS,EACT,eAAe,EAChB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAIL,SAAS,EAGV,MAAM,SAAS,CAAC;AAOjB,MAAM,MAAM,WAAW,CACrB,QAAQ,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC1D,MAAM,SAAS,eAAe,GAAG,eAAe,EAChD,SAAS,SAAS,YAAY,GAAG,YAAY,IAC3C;IACF,4DAA4D;IAC5D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACpC,OAAO,CAAC,EACJ,QAAQ,GACR,CAAC,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,SAAS,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;QAAC,UAAU,EAAE,GAAG,CAAA;KAAE,KAAK,QAAQ,CAAC,CAAC;IAEvF,SAAS,CAAC,EACN,eAAe,CAAC,MAAM,EAAE,SAAS,CAAC,GAClC,CAAC,CAAC,IAAI,EAAE;QACN,KAAK,EAAE,SAAS,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;QACxC,UAAU,EAAE,GAAG,CAAC;KACjB,KAAK,eAAe,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;IAE9C,KAAK,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE;QAAE,MAAM,CAAC,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WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,SAAS,CAAC,CAqBtD;AAED,wBAAgB,aAAa,CAC3B,KAAK,EAAE,SAAS,EAChB,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,KAAK,EAAE,GAAE,OAAO,CAAC,WAAW,CAAM,qBAYxD"}
@@ -138,19 +138,27 @@ function getQualifiedRouteComponent(value) {
138
138
  return QualifiedRoute;
139
139
  }
140
140
  exports.getQualifiedRouteComponent = getQualifiedRouteComponent;
141
- /** @returns a function which provides a screen id that matches the dynamic route name in params. */
142
- function createGetIdForRoute(route) {
141
+ /**
142
+ * @param getId Override that will be wrapped to remove __EXPO_ROUTER_key which is added by PUSH
143
+ * @returns a function which provides a screen id that matches the dynamic route name in params. */
144
+ function createGetIdForRoute(route, getId) {
143
145
  const include = new Map();
144
146
  if (route.dynamic) {
145
147
  for (const segment of route.dynamic) {
146
148
  include.set(segment.name, segment);
147
149
  }
148
150
  }
149
- return ({ params = {} } = {}) => {
151
+ return (options = {}) => {
152
+ const { params = {} } = options;
150
153
  if (params.__EXPO_ROUTER_key) {
151
154
  const key = params.__EXPO_ROUTER_key;
152
155
  delete params.__EXPO_ROUTER_key;
153
- return key;
156
+ if (getId == null) {
157
+ return key;
158
+ }
159
+ }
160
+ if (getId != null) {
161
+ return getId(options);
154
162
  }
155
163
  const segments = [];
156
164
  for (const dynamic of include.values()) {
@@ -195,10 +203,8 @@ function screenOptionsFactory(route, options) {
195
203
  };
196
204
  }
197
205
  exports.screenOptionsFactory = screenOptionsFactory;
198
- function routeToScreen(route, { options, ...props } = {}) {
199
- return (<primitives_1.Screen
200
- // Users can override the screen getId function.
201
- getId={createGetIdForRoute(route)} {...props} name={route.route} key={route.route} options={screenOptionsFactory(route, options)} getComponent={() => getQualifiedRouteComponent(route)}/>);
206
+ function routeToScreen(route, { options, getId, ...props } = {}) {
207
+ return (<primitives_1.Screen {...props} getId={createGetIdForRoute(route, getId)} name={route.route} key={route.route} options={screenOptionsFactory(route, options)} getComponent={() => getQualifiedRouteComponent(route)}/>);
202
208
  }
203
209
  exports.routeToScreen = routeToScreen;
204
210
  //# sourceMappingURL=useScreens.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useScreens.js","sourceRoot":"","sources":["../src/useScreens.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;AAUb,kDAA0B;AAE1B,mCAOiB;AACjB,gEAAoD;AACpD,6CAAsC;AACtC,mDAAgD;AAChD,+DAA4D;AAC5D,qCAAkC;AA6BlC,SAAS,iBAAiB,CACxB,QAAqB,EACrB,KAAqB,EACrB,gBAAyB;IAEzB,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE;QAClB,OAAO,QAAQ;aACZ,IAAI,CAAC,IAAA,6BAAqB,EAAC,gBAAgB,CAAC,CAAC;aAC7C,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;KAC3C;IACD,MAAM,OAAO,GAAG,CAAC,GAAG,QAAQ,CAAC,CAAC;IAE9B,MAAM,OAAO,GAAG,KAAK;SAClB,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,aAAa,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE;QACpE,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;YACnB,OAAO,CAAC,IAAI,CAAC,uDAAuD,IAAI,kBAAkB,CAAC,CAAC;YAC5F,OAAO,IAAI,CAAC;SACb;QACD,MAAM,UAAU,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC;QACtE,IAAI,UAAU,KAAK,CAAC,CAAC,EAAE;YACrB,OAAO,CAAC,IAAI,CACV,sCAAsC,IAAI,8BAA8B,EACxE,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M,CAAC,eAAe,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;YAC7C,MAAM,CAAC,YAAY,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC;YACjC,qFAAqF;YACrF,MAAM,CAAC,eAAe,GAAG,EAAE,MAAM,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;SACzD;QAED,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;AACJ,CAAC;AAxBD,oDAwBC;AAED,SAAgB,aAAa,CAAC,KAAgB,EAAE,EAAE,OAAO,EAAE,GAAG,KAAK,KAA2B,EAAE;IAC9F,OAAO,CACL,CAAC,mBAAM;IACL,gDAAgD;IAChD,KAAK,CAAC,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC,CAClC,IAAI,KAAK,CAAC,CACV,IAAI,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAClB,GAAG,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CACjB,OAAO,CAAC,CAAC,oBAAoB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAC9C,YAAY,CAAC,CAAC,GAAG,EAAE,CAAC,0BAA0B,CAAC,KAAK,CAAC,CAAC,EACtD,CACH,CAAC;AACJ,CAAC;AAZD,sCAYC","sourcesContent":["'use client';\n\nimport type {\n EventMapBase,\n NavigationState,\n ParamListBase,\n RouteConfig,\n RouteProp,\n ScreenListeners,\n} from '@react-navigation/native';\nimport React from 'react';\n\nimport {\n DynamicConvention,\n LoadedRoute,\n Route,\n RouteNode,\n sortRoutesWithInitial,\n useRouteNode,\n} from './Route';\nimport EXPO_ROUTER_IMPORT_MODE from './import-mode';\nimport { Screen } from './primitives';\nimport { EmptyRoute } from './views/EmptyRoute';\nimport { SuspenseFallback } from './views/SuspenseFallback';\nimport { Try } from './views/Try';\n\nexport type ScreenProps<\n TOptions extends Record<string, any> = Record<string, any>,\n TState extends NavigationState = NavigationState,\n TEventMap extends EventMapBase = EventMapBase,\n> = {\n /** Name is required when used inside a Layout component. */\n name?: string;\n /**\n * Redirect to the nearest sibling route.\n * If all children are `redirect={true}`, the layout will render `null` as there are no children to render.\n */\n redirect?: boolean;\n initialParams?: Record<string, any>;\n options?:\n | TOptions\n | ((prop: { route: RouteProp<ParamListBase, string>; navigation: any }) => TOptions);\n\n listeners?:\n | ScreenListeners<TState, TEventMap>\n | ((prop: {\n route: RouteProp<ParamListBase, string>;\n navigation: any;\n }) => ScreenListeners<TState, TEventMap>);\n\n getId?: ({ params }: { params?: Record<string, any> }) => string | undefined;\n};\n\nfunction getSortedChildren(\n children: RouteNode[],\n order?: ScreenProps[],\n initialRouteName?: string\n): { route: RouteNode; props: Partial<ScreenProps> }[] {\n if (!order?.length) {\n return children\n .sort(sortRoutesWithInitial(initialRouteName))\n .map((route) => ({ route, props: {} }));\n }\n const entries = [...children];\n\n const ordered = order\n .map(({ name, redirect, initialParams, listeners, options, getId }) => {\n if (!entries.length) {\n console.warn(`[Layout children]: Too many screens defined. Route \"${name}\" is extraneous.`);\n return null;\n }\n const matchIndex = entries.findIndex((child) => child.route === name);\n if (matchIndex === -1) {\n console.warn(\n `[Layout children]: No route named \"${name}\" exists in nested children:`,\n children.map(({ route }) => route)\n );\n return null;\n } else {\n // Get match and remove from entries\n const match = entries[matchIndex];\n entries.splice(matchIndex, 1);\n\n // Ensure to return null after removing from entries.\n if (redirect) {\n if (typeof redirect === 'string') {\n throw new Error(`Redirecting to a specific route is not supported yet.`);\n }\n return null;\n }\n\n return {\n route: match,\n props: { initialParams, listeners, options, getId },\n };\n }\n })\n .filter(Boolean) as {\n route: RouteNode;\n props: Partial<ScreenProps>;\n }[];\n\n // Add any remaining children\n ordered.push(\n ...entries.sort(sortRoutesWithInitial(initialRouteName)).map((route) => ({ route, props: {} }))\n );\n\n return ordered;\n}\n\n/**\n * @returns React Navigation screens sorted by the `route` property.\n */\nexport function useSortedScreens(order: ScreenProps[]): React.ReactNode[] {\n const node = useRouteNode();\n\n const sorted = node?.children?.length\n ? getSortedChildren(node.children, order, node.initialRouteName)\n : [];\n return React.useMemo(\n () => sorted.map((value) => routeToScreen(value.route, value.props)),\n [sorted]\n );\n}\n\nfunction fromImport({ ErrorBoundary, ...component }: LoadedRoute) {\n if (ErrorBoundary) {\n return {\n default: React.forwardRef((props: any, ref: any) => {\n const children = React.createElement(component.default || EmptyRoute, {\n ...props,\n ref,\n });\n return <Try catch={ErrorBoundary}>{children}</Try>;\n }),\n };\n }\n if (process.env.NODE_ENV !== 'production') {\n if (\n typeof component.default === 'object' &&\n component.default &&\n Object.keys(component.default).length === 0\n ) {\n return { default: EmptyRoute };\n }\n }\n\n return { default: component.default };\n}\n\nfunction fromLoadedRoute(res: LoadedRoute) {\n if (!(res instanceof Promise)) {\n return fromImport(res);\n }\n\n return res.then(fromImport);\n}\n\n// TODO: Maybe there's a more React-y way to do this?\n// Without this store, the process enters a recursive loop.\nconst qualifiedStore = new WeakMap<RouteNode, React.ComponentType<any>>();\n\n/** Wrap the component with various enhancements and add access to child routes. */\nexport function getQualifiedRouteComponent(value: RouteNode) {\n if (qualifiedStore.has(value)) {\n return qualifiedStore.get(value)!;\n }\n\n let ScreenComponent: React.ForwardRefExoticComponent<React.RefAttributes<unknown>>;\n\n // TODO: This ensures sync doesn't use React.lazy, but it's not ideal.\n if (EXPO_ROUTER_IMPORT_MODE === 'lazy') {\n ScreenComponent = React.lazy(async () => {\n const res = value.loadRoute();\n return fromLoadedRoute(res) as Promise<{\n default: React.ComponentType<any>;\n }>;\n });\n } else {\n const res = value.loadRoute();\n const Component = fromImport(res).default as React.ComponentType<any>;\n ScreenComponent = React.forwardRef((props, ref) => {\n return <Component {...props} ref={ref} />;\n });\n }\n\n const getLoadable = (props: any, ref: any) => (\n <React.Suspense fallback={<SuspenseFallback route={value} />}>\n <ScreenComponent\n {...{\n ...props,\n ref,\n // Expose the template segment path, e.g. `(home)`, `[foo]`, `index`\n // the intention is to make it possible to deduce shared routes.\n segment: value.route,\n }}\n />\n </React.Suspense>\n );\n\n const QualifiedRoute = React.forwardRef(\n (\n {\n // Remove these React Navigation props to\n // enforce usage of expo-router hooks (where the query params are correct).\n route,\n navigation,\n\n // Pass all other props to the component\n ...props\n }: any,\n ref: any\n ) => {\n const loadable = getLoadable(props, ref);\n\n return (\n <Route node={value} route={route}>\n {loadable}\n </Route>\n );\n }\n );\n\n QualifiedRoute.displayName = `Route(${value.route})`;\n\n qualifiedStore.set(value, QualifiedRoute);\n return QualifiedRoute;\n}\n\n/** @returns a function which provides a screen id that matches the dynamic route name in params. */\nexport function createGetIdForRoute(\n route: Pick<RouteNode, 'dynamic' | 'route' | 'contextKey' | 'children'>\n) {\n const include = new Map<string, DynamicConvention>();\n\n if (route.dynamic) {\n for (const segment of route.dynamic) {\n include.set(segment.name, segment);\n }\n }\n\n return ({ params = {} } = {} as { params?: Record<string, any> }) => {\n if (params.__EXPO_ROUTER_key) {\n const key = params.__EXPO_ROUTER_key;\n delete params.__EXPO_ROUTER_key;\n return key;\n }\n\n const segments: string[] = [];\n\n for (const dynamic of include.values()) {\n const value = params?.[dynamic.name];\n if (Array.isArray(value) && value.length > 0) {\n // If we are an array with a value\n segments.push(value.join('/'));\n } else if (value && !Array.isArray(value)) {\n // If we have a value and not an empty array\n segments.push(value);\n } else if (dynamic.deep) {\n segments.push(`[...${dynamic.name}]`);\n } else {\n segments.push(`[${dynamic.name}]`);\n }\n }\n\n return segments.join('/') ?? route.contextKey;\n };\n}\n\nexport function screenOptionsFactory(\n route: RouteNode,\n options?: ScreenProps['options']\n): RouteConfig<any, any, any, any, any, any>['options'] {\n return (args) => {\n // Only eager load generated components\n const staticOptions = route.generated ? route.loadRoute()?.getNavOptions : null;\n const staticResult = typeof staticOptions === 'function' ? staticOptions(args) : staticOptions;\n const dynamicResult = typeof options === 'function' ? options?.(args) : options;\n const output = {\n ...staticResult,\n ...dynamicResult,\n };\n\n // Prevent generated screens from showing up in the tab bar.\n if (route.generated) {\n output.tabBarItemStyle = { display: 'none' };\n output.tabBarButton = () => null;\n // TODO: React Navigation doesn't provide a way to prevent rendering the drawer item.\n output.drawerItemStyle = { height: 0, display: 'none' };\n }\n\n return output;\n };\n}\n\nexport function routeToScreen(route: RouteNode, { options, ...props }: Partial<ScreenProps> = {}) {\n return (\n <Screen\n // Users can override the screen getId function.\n getId={createGetIdForRoute(route)}\n {...props}\n name={route.route}\n key={route.route}\n options={screenOptionsFactory(route, options)}\n getComponent={() => getQualifiedRouteComponent(route)}\n />\n );\n}\n"]}
1
+ {"version":3,"file":"useScreens.js","sourceRoot":"","sources":["../src/useScreens.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;AAUb,kDAA0B;AAE1B,mCAOiB;AACjB,gEAAoD;AACpD,6CAAsC;AACtC,mDAAgD;AAChD,+DAA4D;AAC5D,qCAAkC;AA6BlC,SAAS,iBAAiB,CACxB,QAAqB,EACrB,KAAqB,EACrB,gBAAyB;IAEzB,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE;QAClB,OAAO,QAAQ;aACZ,IAAI,CAAC,IAAA,6BAAqB,EAAC,gBAAgB,CAAC,CAAC;aAC7C,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;KAC3C;IACD,MAAM,OAAO,GAAG,CAAC,GAAG,QAAQ,CAAC,CAAC;IAE9B,MAAM,OAAO,GAAG,KAAK;SAClB,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,aAAa,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE;QACpE,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;YACnB,OAAO,CAAC,IAAI,CAAC,uDAAuD,IAAI,kBAAkB,CAAC,CAAC;YAC5F,OAAO,IAAI,CAAC;SACb;QACD,MAAM,UAAU,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK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CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC;QAC/F,MAAM,aAAa,GAAG,OAAO,OAAO,KAAK,UAAU,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;QAChF,MAAM,MAAM,GAAG;YACb,GAAG,YAAY;YACf,GAAG,aAAa;SACjB,CAAC;QAEF,4DAA4D;QAC5D,IAAI,KAAK,CAAC,SAAS,EAAE;YACnB,MAAM,CAAC,eAAe,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;YAC7C,MAAM,CAAC,YAAY,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC;YACjC,qFAAqF;YACrF,MAAM,CAAC,eAAe,GAAG,EAAE,MAAM,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;SACzD;QAED,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;AACJ,CAAC;AAxBD,oDAwBC;AAED,SAAgB,aAAa,CAC3B,KAAgB,EAChB,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,KAAK,KAA2B,EAAE;IAEvD,OAAO,CACL,CAAC,mBAAM,CACL,IAAI,KAAK,CAAC,CACV,KAAK,CAAC,CAAC,mBAAmB,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CACzC,IAAI,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAClB,GAAG,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CACjB,OAAO,CAAC,CAAC,oBAAoB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAC9C,YAAY,CAAC,CAAC,GAAG,EAAE,CAAC,0BAA0B,CAAC,KAAK,CAAC,CAAC,EACtD,CACH,CAAC;AACJ,CAAC;AAdD,sCAcC","sourcesContent":["'use client';\n\nimport type {\n EventMapBase,\n NavigationState,\n ParamListBase,\n RouteConfig,\n RouteProp,\n ScreenListeners,\n} from '@react-navigation/native';\nimport React from 'react';\n\nimport {\n DynamicConvention,\n LoadedRoute,\n Route,\n RouteNode,\n sortRoutesWithInitial,\n useRouteNode,\n} from './Route';\nimport EXPO_ROUTER_IMPORT_MODE from './import-mode';\nimport { Screen } from './primitives';\nimport { EmptyRoute } from './views/EmptyRoute';\nimport { SuspenseFallback } from './views/SuspenseFallback';\nimport { Try } from './views/Try';\n\nexport type ScreenProps<\n TOptions extends Record<string, any> = Record<string, any>,\n TState extends NavigationState = NavigationState,\n TEventMap extends EventMapBase = EventMapBase,\n> = {\n /** Name is required when used inside a Layout component. */\n name?: string;\n /**\n * Redirect to the nearest sibling route.\n * If all children are `redirect={true}`, the layout will render `null` as there are no children to render.\n */\n redirect?: boolean;\n initialParams?: Record<string, any>;\n options?:\n | TOptions\n | ((prop: { route: RouteProp<ParamListBase, string>; navigation: any }) => TOptions);\n\n listeners?:\n | ScreenListeners<TState, TEventMap>\n | ((prop: {\n route: RouteProp<ParamListBase, string>;\n navigation: any;\n }) => ScreenListeners<TState, TEventMap>);\n\n getId?: ({ params }: { params?: Record<string, any> }) => string | undefined;\n};\n\nfunction getSortedChildren(\n children: RouteNode[],\n order?: ScreenProps[],\n initialRouteName?: string\n): { route: RouteNode; props: Partial<ScreenProps> }[] {\n if (!order?.length) {\n return children\n .sort(sortRoutesWithInitial(initialRouteName))\n .map((route) => ({ route, props: {} }));\n }\n const entries = [...children];\n\n const ordered = order\n .map(({ name, redirect, initialParams, listeners, options, getId }) => {\n if (!entries.length) {\n console.warn(`[Layout children]: Too many screens defined. Route \"${name}\" is extraneous.`);\n return null;\n }\n const matchIndex = entries.findIndex((child) => child.route === name);\n if (matchIndex === -1) {\n console.warn(\n `[Layout children]: No route named \"${name}\" exists in nested children:`,\n children.map(({ route }) => route)\n );\n return null;\n } else {\n // Get match and remove from entries\n const match = entries[matchIndex];\n entries.splice(matchIndex, 1);\n\n // Ensure to return null after removing from entries.\n if (redirect) {\n if (typeof redirect === 'string') {\n throw new Error(`Redirecting to a specific route is not supported yet.`);\n }\n return null;\n }\n\n return {\n route: match,\n props: { initialParams, listeners, options, getId },\n };\n }\n })\n .filter(Boolean) as {\n route: RouteNode;\n props: Partial<ScreenProps>;\n }[];\n\n // Add any remaining children\n ordered.push(\n ...entries.sort(sortRoutesWithInitial(initialRouteName)).map((route) => ({ route, props: {} }))\n );\n\n return ordered;\n}\n\n/**\n * @returns React Navigation screens sorted by the `route` property.\n */\nexport function useSortedScreens(order: ScreenProps[]): React.ReactNode[] {\n const node = useRouteNode();\n\n const sorted = node?.children?.length\n ? getSortedChildren(node.children, order, node.initialRouteName)\n : [];\n return React.useMemo(\n () => sorted.map((value) => routeToScreen(value.route, value.props)),\n [sorted]\n );\n}\n\nfunction fromImport({ ErrorBoundary, ...component }: LoadedRoute) {\n if (ErrorBoundary) {\n return {\n default: React.forwardRef((props: any, ref: any) => {\n const children = React.createElement(component.default || EmptyRoute, {\n ...props,\n ref,\n });\n return <Try catch={ErrorBoundary}>{children}</Try>;\n }),\n };\n }\n if (process.env.NODE_ENV !== 'production') {\n if (\n typeof component.default === 'object' &&\n component.default &&\n Object.keys(component.default).length === 0\n ) {\n return { default: EmptyRoute };\n }\n }\n\n return { default: component.default };\n}\n\nfunction fromLoadedRoute(res: LoadedRoute) {\n if (!(res instanceof Promise)) {\n return fromImport(res);\n }\n\n return res.then(fromImport);\n}\n\n// TODO: Maybe there's a more React-y way to do this?\n// Without this store, the process enters a recursive loop.\nconst qualifiedStore = new WeakMap<RouteNode, React.ComponentType<any>>();\n\n/** Wrap the component with various enhancements and add access to child routes. */\nexport function getQualifiedRouteComponent(value: RouteNode) {\n if (qualifiedStore.has(value)) {\n return qualifiedStore.get(value)!;\n }\n\n let ScreenComponent: React.ForwardRefExoticComponent<React.RefAttributes<unknown>>;\n\n // TODO: This ensures sync doesn't use React.lazy, but it's not ideal.\n if (EXPO_ROUTER_IMPORT_MODE === 'lazy') {\n ScreenComponent = React.lazy(async () => {\n const res = value.loadRoute();\n return fromLoadedRoute(res) as Promise<{\n default: React.ComponentType<any>;\n }>;\n });\n } else {\n const res = value.loadRoute();\n const Component = fromImport(res).default as React.ComponentType<any>;\n ScreenComponent = React.forwardRef((props, ref) => {\n return <Component {...props} ref={ref} />;\n });\n }\n\n const getLoadable = (props: any, ref: any) => (\n <React.Suspense fallback={<SuspenseFallback route={value} />}>\n <ScreenComponent\n {...{\n ...props,\n ref,\n // Expose the template segment path, e.g. `(home)`, `[foo]`, `index`\n // the intention is to make it possible to deduce shared routes.\n segment: value.route,\n }}\n />\n </React.Suspense>\n );\n\n const QualifiedRoute = React.forwardRef(\n (\n {\n // Remove these React Navigation props to\n // enforce usage of expo-router hooks (where the query params are correct).\n route,\n navigation,\n\n // Pass all other props to the component\n ...props\n }: any,\n ref: any\n ) => {\n const loadable = getLoadable(props, ref);\n\n return (\n <Route node={value} route={route}>\n {loadable}\n </Route>\n );\n }\n );\n\n QualifiedRoute.displayName = `Route(${value.route})`;\n\n qualifiedStore.set(value, QualifiedRoute);\n return QualifiedRoute;\n}\n\n/**\n * @param getId Override that will be wrapped to remove __EXPO_ROUTER_key which is added by PUSH\n * @returns a function which provides a screen id that matches the dynamic route name in params. */\nexport function createGetIdForRoute(\n route: Pick<RouteNode, 'dynamic' | 'route' | 'contextKey' | 'children'>,\n getId: ScreenProps['getId']\n): ScreenProps['getId'] {\n const include = new Map<string, DynamicConvention>();\n\n if (route.dynamic) {\n for (const segment of route.dynamic) {\n include.set(segment.name, segment);\n }\n }\n\n return (options = {}) => {\n const { params = {} } = options;\n if (params.__EXPO_ROUTER_key) {\n const key = params.__EXPO_ROUTER_key;\n delete params.__EXPO_ROUTER_key;\n if (getId == null) {\n return key;\n }\n }\n\n if (getId != null) {\n return getId(options);\n }\n\n const segments: string[] = [];\n\n for (const dynamic of include.values()) {\n const value = params?.[dynamic.name];\n if (Array.isArray(value) && value.length > 0) {\n // If we are an array with a value\n segments.push(value.join('/'));\n } else if (value && !Array.isArray(value)) {\n // If we have a value and not an empty array\n segments.push(value);\n } else if (dynamic.deep) {\n segments.push(`[...${dynamic.name}]`);\n } else {\n segments.push(`[${dynamic.name}]`);\n }\n }\n\n return segments.join('/') ?? route.contextKey;\n };\n}\n\nexport function screenOptionsFactory(\n route: RouteNode,\n options?: ScreenProps['options']\n): RouteConfig<any, any, any, any, any, any>['options'] {\n return (args) => {\n // Only eager load generated components\n const staticOptions = route.generated ? route.loadRoute()?.getNavOptions : null;\n const staticResult = typeof staticOptions === 'function' ? staticOptions(args) : staticOptions;\n const dynamicResult = typeof options === 'function' ? options?.(args) : options;\n const output = {\n ...staticResult,\n ...dynamicResult,\n };\n\n // Prevent generated screens from showing up in the tab bar.\n if (route.generated) {\n output.tabBarItemStyle = { display: 'none' };\n output.tabBarButton = () => null;\n // TODO: React Navigation doesn't provide a way to prevent rendering the drawer item.\n output.drawerItemStyle = { height: 0, display: 'none' };\n }\n\n return output;\n };\n}\n\nexport function routeToScreen(\n route: RouteNode,\n { options, getId, ...props }: Partial<ScreenProps> = {}\n) {\n return (\n <Screen\n {...props}\n getId={createGetIdForRoute(route, getId)}\n name={route.route}\n key={route.route}\n options={screenOptionsFactory(route, options)}\n getComponent={() => getQualifiedRouteComponent(route)}\n />\n );\n}\n"]}
@@ -44,7 +44,7 @@ export declare function Slot(props: Omit<NavigatorProps<any>, 'children'>): Reac
44
44
  /**
45
45
  * Render the current navigator content.
46
46
  */
47
- declare function NavigatorSlot(): JSX.Element;
47
+ declare function NavigatorSlot(): any;
48
48
  /**
49
49
  * The default navigator for the app when no root _layout is provided.
50
50
  */
@@ -1 +1 @@
1
- {"version":3,"file":"Navigator.d.ts","sourceRoot":"","sources":["../../src/views/Navigator.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAC5F,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAQ/B,MAAM,MAAM,qBAAqB,GAAG,UAAU,CAAC,OAAO,oBAAoB,CAAC,GAAG;IAC5E,UAAU,EAAE,M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C,cAAc,CAAC,GAAG,CAAC,EAAE,UAAU,CAAC,qBAchE;AAED;;GAEG;AACH,iBAAS,aAAa,QAMrB;AAED;;GAEG;AACH,wBAAgB,gBAAgB,sBAM/B"}
@@ -18,6 +18,6 @@ export declare class Try extends Component<PropsWithChildren<{
18
18
  error: Error;
19
19
  } | null;
20
20
  retry: () => Promise<void>;
21
- render(): string | number | boolean | Iterable<React.ReactNode> | React.JSX.Element | null | undefined;
21
+ render(): string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | React.JSX.Element | null | undefined;
22
22
  }
23
23
  //# sourceMappingURL=Try.d.ts.map
@@ -1,8 +1,7 @@
1
1
  {
2
- "platforms": ["ios", "web"],
3
- "ios": {
2
+ "platforms": ["apple", "web"],
3
+ "apple": {
4
4
  "modules": ["ExpoHeadModule"],
5
5
  "appDelegateSubscribers": ["ExpoHeadAppDelegateSubscriber"]
6
6
  }
7
7
  }
8
-
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-router",
3
- "version": "4.0.18",
3
+ "version": "4.0.20-canary-20250320-7a205d3",
4
4
  "description": "Expo Router is a file-based router for React Native and web applications.",
5
5
  "author": "650 Industries, Inc.",
6
6
  "license": "MIT",
@@ -75,9 +75,9 @@
75
75
  ],
76
76
  "peerDependencies": {
77
77
  "@react-navigation/drawer": "^7.1.1",
78
- "expo": "*",
79
- "expo-constants": "*",
80
- "expo-linking": "*",
78
+ "expo": "53.0.0-canary-20250320-7a205d3",
79
+ "expo-constants": "18.0.0-canary-20250320-7a205d3",
80
+ "expo-linking": "7.1.0-canary-20250320-7a205d3",
81
81
  "react-native-reanimated": "*",
82
82
  "react-native-safe-area-context": "*",
83
83
  "react-native-screens": "*"
@@ -97,14 +97,14 @@
97
97
  "@react-navigation/drawer": "^7.1.1",
98
98
  "@testing-library/jest-native": "^5.4.2",
99
99
  "@testing-library/react": "^15.0.7",
100
- "@testing-library/react-native": "^12.5.1",
100
+ "@testing-library/react-native": "^13.1.0",
101
101
  "immer": "^10.1.1",
102
102
  "react-server-dom-webpack": "19.0.0-rc-6230622a1a-20240610",
103
103
  "tsd": "^0.28.1"
104
104
  },
105
105
  "dependencies": {
106
- "@expo/metro-runtime": "4.0.1",
107
- "@expo/server": "^0.5.2",
106
+ "@expo/metro-runtime": "5.0.0-canary-20250320-7a205d3",
107
+ "@expo/server": "0.5.4-canary-20250320-7a205d3",
108
108
  "@radix-ui/react-slot": "1.0.1",
109
109
  "@react-navigation/bottom-tabs": "^7.2.0",
110
110
  "@react-navigation/native": "^7.0.14",
@@ -116,6 +116,5 @@
116
116
  "schema-utils": "^4.0.1",
117
117
  "semver": "~7.6.3",
118
118
  "server-only": "^0.0.1"
119
- },
120
- "gitHead": "1992dd3ba012ec59a646e383b9895ea6b577948b"
119
+ }
121
120
  }
@@ -30,10 +30,6 @@ const withRouter = (config, _props) => {
30
30
  extra: {
31
31
  ...config.extra,
32
32
  router: {
33
- // RSC enables location origin by default because it's required for requests.
34
- origin: config.experiments?.reactServerComponentRoutes || config.experiments?.reactServerFunctions
35
- ? undefined
36
- : false,
37
33
  ...config.extra?.router,
38
34
  ...props,
39
35
  },
@@ -49,11 +49,6 @@ const withRouter: ConfigPlugin<
49
49
  extra: {
50
50
  ...config.extra,
51
51
  router: {
52
- // RSC enables location origin by default because it's required for requests.
53
- origin:
54
- config.experiments?.reactServerComponentRoutes || config.experiments?.reactServerFunctions
55
- ? undefined
56
- : false,
57
52
  ...config.extra?.router,
58
53
  ...props,
59
54
  },