expo-router 0.0.29 → 0.0.30

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 (63) hide show
  1. package/build/ContextNavigationContainer.d.ts.map +1 -1
  2. package/build/ContextNavigationContainer.js +9 -5
  3. package/build/ContextNavigationContainer.js.map +1 -1
  4. package/build/ContextNavigator.d.ts.map +1 -1
  5. package/build/ContextNavigator.js +14 -38
  6. package/build/ContextNavigator.js.map +1 -1
  7. package/build/Route.d.ts +5 -4
  8. package/build/Route.d.ts.map +1 -1
  9. package/build/Route.js +16 -30
  10. package/build/Route.js.map +1 -1
  11. package/build/aasa.d.ts.map +1 -1
  12. package/build/aasa.js +4 -3
  13. package/build/aasa.js.map +1 -1
  14. package/build/context.d.ts +2 -2
  15. package/build/context.d.ts.map +1 -1
  16. package/build/context.js +5 -5
  17. package/build/context.js.map +1 -1
  18. package/build/exports.d.ts.map +1 -1
  19. package/build/exports.js +0 -2
  20. package/build/exports.js.map +1 -1
  21. package/build/fork/getPathFromState.d.ts.map +1 -1
  22. package/build/fork/getPathFromState.js +7 -2
  23. package/build/fork/getPathFromState.js.map +1 -1
  24. package/build/getLinkingConfig.d.ts +8 -4
  25. package/build/getLinkingConfig.d.ts.map +1 -1
  26. package/build/getLinkingConfig.js +30 -32
  27. package/build/getLinkingConfig.js.map +1 -1
  28. package/build/getRoutes.d.ts +17 -4
  29. package/build/getRoutes.d.ts.map +1 -1
  30. package/build/getRoutes.js +93 -43
  31. package/build/getRoutes.js.map +1 -1
  32. package/build/link/href.d.ts +6 -6
  33. package/build/link/href.d.ts.map +1 -1
  34. package/build/link/href.js +13 -10
  35. package/build/link/href.js.map +1 -1
  36. package/build/link/useHref.d.ts +2 -5
  37. package/build/link/useHref.d.ts.map +1 -1
  38. package/build/link/useHref.js +6 -6
  39. package/build/link/useHref.js.map +1 -1
  40. package/build/onboard/useTutorial.d.ts +4 -0
  41. package/build/onboard/useTutorial.d.ts.map +1 -0
  42. package/build/onboard/useTutorial.js +31 -0
  43. package/build/onboard/useTutorial.js.map +1 -0
  44. package/build/useNavigation.d.ts.map +1 -1
  45. package/build/useNavigation.js +0 -1
  46. package/build/useNavigation.js.map +1 -1
  47. package/build/useScreens.d.ts +6 -4
  48. package/build/useScreens.d.ts.map +1 -1
  49. package/build/useScreens.js +18 -25
  50. package/build/useScreens.js.map +1 -1
  51. package/build/views/Directory.d.ts.map +1 -1
  52. package/build/views/Directory.js +8 -18
  53. package/build/views/Directory.js.map +1 -1
  54. package/build/views/ErrorBoundary.js +1 -1
  55. package/build/views/ErrorBoundary.js.map +1 -1
  56. package/build/views/Layout.d.ts +1 -1
  57. package/build/views/Layout.d.ts.map +1 -1
  58. package/build/views/Layout.js +10 -3
  59. package/build/views/Layout.js.map +1 -1
  60. package/build/views/Unmatched.d.ts.map +1 -1
  61. package/build/views/Unmatched.js +7 -0
  62. package/build/views/Unmatched.js.map +1 -1
  63. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"ContextNavigationContainer.d.ts","sourceRoot":"","sources":["../src/ContextNavigationContainer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,mBAAmB,EACpB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAEL,iBAAiB,EACjB,sBAAsB,EACvB,MAAM,qBAAqB,CAAC;AAK7B,aAAK,wBAAwB,GAAG,KAAK,CAAC,cAAc,CAClD,OAAO,mBAAmB,CAC3B,CAAC;AASF,wBAAgB,6BAA6B;;;;;;;;;;;;;;;;aAQ5C;AAED,8GAA8G;AAC9G,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,wBAAwB,eAsBzE;AAyBD,wBAAgB,aAAa,CAAC,EAC5B,aAAa,EACb,QAAQ,EACR,OAAO,EACP,YAAY,EACZ,aAAa,EACb,iBAAiB,EACjB,KAAK,GACN,EAAE,IAAI,CACL,wBAAwB,EACxB,aAAa,GAAG,KAAK,GAAG,UAAU,GAAG,SAAS,CAC/C,QAwBA;yBAnCe,aAAa"}
1
+ {"version":3,"file":"ContextNavigationContainer.d.ts","sourceRoot":"","sources":["../src/ContextNavigationContainer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,mBAAmB,EACpB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAO,EAEL,iBAAiB,EACjB,sBAAsB,EACvB,MAAM,qBAAqB,CAAC;AAK7B,aAAK,wBAAwB,GAAG,KAAK,CAAC,cAAc,CAClD,OAAO,mBAAmB,CAC3B,CAAC;AASF,wBAAgB,6BAA6B;;;;;;;;;;;;;;;;aAQ5C;AAED,8GAA8G;AAC9G,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,wBAAwB,eAkBzE;AAiCD,wBAAgB,aAAa,CAAC,EAC5B,aAAa,EACb,QAAQ,EACR,OAAO,EACP,YAAY,EACZ,aAAa,EACb,iBAAiB,EACjB,KAAK,GACN,EAAE,IAAI,CACL,wBAAwB,EACxB,aAAa,GAAG,KAAK,GAAG,UAAU,GAAG,SAAS,CAC/C,QAwBA;yBAnCe,aAAa"}
@@ -1,6 +1,7 @@
1
1
  import { createNavigationContainerRef, NavigationContainer, } from "@react-navigation/native";
2
2
  import React from "react";
3
- import { useLinkingConfig } from "./getLinkingConfig";
3
+ import { useRootRouteNodeContext } from "./context";
4
+ import { getLinkingConfig } from "./getLinkingConfig";
4
5
  import { RootNavigationRef, useRootNavigation, useRootNavigationState, } from "./useRootNavigation";
5
6
  import { SplashScreen } from "./views/Splash";
6
7
  const navigationRef = createNavigationContainerRef();
@@ -15,12 +16,9 @@ export function useNavigationContainerContext() {
15
16
  /** react-navigation `NavigationContainer` with automatic `linking` prop generated from the routes context. */
16
17
  export function ContextNavigationContainer(props) {
17
18
  const [state, setState] = React.useState({});
18
- const linking = useLinkingConfig();
19
- console.log("linking", linking);
20
19
  return (React.createElement(NavigationContainerContext.Provider, { value: [
21
20
  {
22
21
  ...props,
23
- linking,
24
22
  ...state,
25
23
  },
26
24
  setState,
@@ -31,9 +29,15 @@ function InternalContextNavigationContainer(props) {
31
29
  const [contextProps] = useNavigationContainerContext();
32
30
  const [isReady, setReady] = React.useState(false);
33
31
  const ref = React.useMemo(() => (isReady ? navigationRef : null), [isReady]);
32
+ const root = useRootRouteNodeContext();
33
+ const linking = React.useMemo(() => {
34
+ const linking = getLinkingConfig(root);
35
+ console.log("linking", linking);
36
+ return linking;
37
+ }, [root]);
34
38
  return (React.createElement(RootNavigationRef.Provider, { value: { ref } },
35
39
  !isReady && React.createElement(SplashScreen, null),
36
- React.createElement(NavigationContainer, { ...props, ...contextProps, ref: navigationRef, onReady: () => {
40
+ React.createElement(NavigationContainer, { ...props, ...contextProps, linking: linking, ref: navigationRef, onReady: () => {
37
41
  contextProps.onReady?.();
38
42
  setReady(true);
39
43
  } })));
@@ -1 +1 @@
1
- {"version":3,"file":"ContextNavigationContainer.js","sourceRoot":"","sources":["../src/ContextNavigationContainer.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,4BAA4B,EAC5B,mBAAmB,GACpB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,MAAM,aAAa,GAAG,4BAA4B,EAAE,CAAC;AAMrD,MAAM,0BAA0B,GAAG,KAAK,CAAC,aAAa,CAKpD,CAAC,EAAE,EAAE,cAAa,CAAC,CAAC,CAAC,CAAC;AAExB,MAAM,UAAU,6BAA6B;IAC3C,MAAM,OAAO,GAAG,KAAK,CAAC,UAAU,CAAC,0BAA0B,CAAC,CAAC;IAC7D,IAAI,CAAC,OAAO,EAAE;QACZ,MAAM,IAAI,KAAK,CACb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,CAAC,EAC5B,aAAa,EACb,QAAQ,EACR,OAAO,EACP,YAAY,EACZ,aAAa,EACb,iBAAiB,EACjB,KAAK,GAIN;IACC,MAAM,CAAC,EAAE,QAAQ,CAAC,GAAG,6BAA6B,EAAE,CAAC;IAErD,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,QAAQ,CAAC;YACP,aAAa;YACb,QAAQ;YACR,OAAO;YACP,YAAY;YACZ,aAAa;YACb,iBAAiB;YACjB,KAAK;SACN,CAAC,CAAC;IACL,CAAC,EAAE;QACD,aAAa;QACb,QAAQ;QACR,OAAO;QACP,YAAY;QACZ,aAAa;QACb,iBAAiB;QACjB,KAAK;KACN,CAAC,CAAC;IAEH,OAAO,IAAI,CAAC;AACd,CAAC;AAED,aAAa,CAAC,MAAM,GAAG,iBAAiB,CAAC;AACzC,aAAa,CAAC,QAAQ,GAAG,sBAAsB,CAAC;AAEhD,6CAA6C;AAC7C,aAAa,CAAC,MAAM,GAAG,GAAG,EAAE;IAC1B,OAAO,aAAa,CAAC;AACvB,CAAC,CAAC","sourcesContent":["import {\n createNavigationContainerRef,\n NavigationContainer,\n} from \"@react-navigation/native\";\nimport React from \"react\";\n\nimport { useLinkingConfig } from \"./getLinkingConfig\";\nimport {\n RootNavigationRef,\n useRootNavigation,\n useRootNavigationState,\n} from \"./useRootNavigation\";\nimport { SplashScreen } from \"./views/Splash\";\n\nconst navigationRef = createNavigationContainerRef();\n\ntype NavigationContainerProps = React.ComponentProps<\n typeof NavigationContainer\n>;\n\nconst NavigationContainerContext = React.createContext<\n [\n Partial<NavigationContainerProps>,\n (props: Partial<NavigationContainerProps>) => void\n ]\n>([{}, function () {}]);\n\nexport function useNavigationContainerContext() {\n const context = React.useContext(NavigationContainerContext);\n if (!context) {\n throw new Error(\n \"useNavigationContainerContext must be used within a NavigationContainerContext\"\n );\n }\n return context;\n}\n\n/** react-navigation `NavigationContainer` with automatic `linking` prop generated from the routes context. */\nexport function ContextNavigationContainer(props: NavigationContainerProps) {\n const [state, setState] = React.useState<Partial<NavigationContainerProps>>(\n {}\n );\n\n const linking = useLinkingConfig();\n console.log(\"linking\", linking);\n\n return (\n <NavigationContainerContext.Provider\n value={[\n {\n ...props,\n linking,\n ...state,\n },\n setState,\n ]}\n >\n <InternalContextNavigationContainer />\n </NavigationContainerContext.Provider>\n );\n}\n\nfunction InternalContextNavigationContainer(props: object) {\n const [contextProps] = useNavigationContainerContext();\n const [isReady, setReady] = React.useState(false);\n\n const ref = React.useMemo(() => (isReady ? navigationRef : null), [isReady]);\n\n return (\n <RootNavigationRef.Provider value={{ ref }}>\n {!isReady && <SplashScreen />}\n {/* @ts-expect-error: children are required */}\n <NavigationContainer\n {...props}\n {...contextProps}\n ref={navigationRef}\n onReady={() => {\n contextProps.onReady?.();\n setReady(true);\n }}\n />\n </RootNavigationRef.Provider>\n );\n}\n\nexport function RootContainer({\n documentTitle,\n fallback,\n onReady,\n initialState,\n onStateChange,\n onUnhandledAction,\n theme,\n}: Omit<\n NavigationContainerProps,\n \"independent\" | \"ref\" | \"children\" | \"linking\"\n>) {\n const [, setProps] = useNavigationContainerContext();\n\n React.useEffect(() => {\n setProps({\n documentTitle,\n fallback,\n onReady,\n initialState,\n onStateChange,\n onUnhandledAction,\n theme,\n });\n }, [\n documentTitle,\n fallback,\n onReady,\n initialState,\n onStateChange,\n onUnhandledAction,\n theme,\n ]);\n\n return null;\n}\n\nRootContainer.useRef = useRootNavigation;\nRootContainer.useState = useRootNavigationState;\n\n/** Get the root navigation container ref. */\nRootContainer.getRef = () => {\n return navigationRef;\n};\n"]}
1
+ {"version":3,"file":"ContextNavigationContainer.js","sourceRoot":"","sources":["../src/ContextNavigationContainer.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,4BAA4B,EAC5B,mBAAmB,GACpB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,E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C;AAEhD,6CAA6C;AAC7C,aAAa,CAAC,MAAM,GAAG,GAAG,EAAE;IAC1B,OAAO,aAAa,CAAC;AACvB,CAAC,CAAC","sourcesContent":["import {\n createNavigationContainerRef,\n NavigationContainer,\n} from \"@react-navigation/native\";\nimport React from \"react\";\n\nimport { useRootRouteNodeContext } from \"./context\";\nimport { getLinkingConfig } from \"./getLinkingConfig\";\nimport {\n RootNavigationRef,\n useRootNavigation,\n useRootNavigationState,\n} from \"./useRootNavigation\";\nimport { SplashScreen } from \"./views/Splash\";\n\nconst navigationRef = createNavigationContainerRef();\n\ntype NavigationContainerProps = React.ComponentProps<\n typeof NavigationContainer\n>;\n\nconst NavigationContainerContext = React.createContext<\n [\n Partial<NavigationContainerProps>,\n (props: Partial<NavigationContainerProps>) => void\n ]\n>([{}, function () {}]);\n\nexport function useNavigationContainerContext() {\n const context = React.useContext(NavigationContainerContext);\n if (!context) {\n throw new Error(\n \"useNavigationContainerContext must be used within a NavigationContainerContext\"\n );\n }\n return context;\n}\n\n/** react-navigation `NavigationContainer` with automatic `linking` prop generated from the routes context. */\nexport function ContextNavigationContainer(props: NavigationContainerProps) {\n const [state, setState] = React.useState<Partial<NavigationContainerProps>>(\n {}\n );\n\n return (\n <NavigationContainerContext.Provider\n value={[\n {\n ...props,\n ...state,\n },\n setState,\n ]}\n >\n <InternalContextNavigationContainer />\n </NavigationContainerContext.Provider>\n );\n}\n\nfunction InternalContextNavigationContainer(props: object) {\n const [contextProps] = useNavigationContainerContext();\n const [isReady, setReady] = React.useState(false);\n const ref = React.useMemo(() => (isReady ? navigationRef : null), [isReady]);\n\n const root = useRootRouteNodeContext();\n\n const linking = React.useMemo(() => {\n const linking = getLinkingConfig(root);\n console.log(\"linking\", linking);\n return linking;\n }, [root]);\n\n return (\n <RootNavigationRef.Provider value={{ ref }}>\n {!isReady && <SplashScreen />}\n {/* @ts-expect-error: children are required */}\n <NavigationContainer\n {...props}\n {...contextProps}\n linking={linking}\n ref={navigationRef}\n onReady={() => {\n contextProps.onReady?.();\n setReady(true);\n }}\n />\n </RootNavigationRef.Provider>\n );\n}\n\nexport function RootContainer({\n documentTitle,\n fallback,\n onReady,\n initialState,\n onStateChange,\n onUnhandledAction,\n theme,\n}: Omit<\n NavigationContainerProps,\n \"independent\" | \"ref\" | \"children\" | \"linking\"\n>) {\n const [, setProps] = useNavigationContainerContext();\n\n React.useEffect(() => {\n setProps({\n documentTitle,\n fallback,\n onReady,\n initialState,\n onStateChange,\n onUnhandledAction,\n theme,\n });\n }, [\n documentTitle,\n fallback,\n onReady,\n initialState,\n onStateChange,\n onUnhandledAction,\n theme,\n ]);\n\n return null;\n}\n\nRootContainer.useRef = useRootNavigation;\nRootContainer.useState = useRootNavigationState;\n\n/** Get the root navigation container ref. */\nRootContainer.getRef = () => {\n return navigationRef;\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"ContextNavigator.d.ts","sourceRoot":"","sources":["../src/ContextNavigator.tsx"],"names":[],"mappings":";AAOA,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AA2DzC,wBAAgB,gBAAgB,CAAC,EAAE,OAAO,EAAE,EAAE;IAAE,OAAO,EAAE,cAAc,CAAA;CAAE,eAgBxE"}
1
+ {"version":3,"file":"ContextNavigator.d.ts","sourceRoot":"","sources":["../src/ContextNavigator.tsx"],"names":[],"mappings":";AAMA,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAwBzC,wBAAgB,gBAAgB,CAAC,EAAE,OAAO,EAAE,EAAE;IAAE,OAAO,EAAE,cAAc,CAAA;CAAE,eAaxE"}
@@ -1,55 +1,31 @@
1
1
  import React, { useMemo } from "react";
2
2
  import { ContextNavigationContainer } from "./ContextNavigationContainer";
3
- import { Route } from "./Route";
4
- import { RoutesContext } from "./context";
3
+ import { RootRouteNodeContext, useRootRouteNodeContext } from "./context";
5
4
  import { getRoutes } from "./getRoutes";
6
- import { Stack } from "./layouts/Stack";
5
+ import { useTutorial } from "./onboard/useTutorial";
6
+ import { getQualifiedRouteComponent } from "./useScreens";
7
7
  function useContextModuleAsRoutes(context) {
8
8
  // TODO: Is this an optimal hook dependency?
9
9
  const keys = useMemo(() => context.keys(), [context]);
10
10
  return useMemo(() => getRoutes(context), [keys]);
11
11
  }
12
- function RoutesContextProvider({ context, children, }) {
12
+ function RootRouteNodeProvider({ context, children, }) {
13
13
  const routes = useContextModuleAsRoutes(context);
14
- return (React.createElement(RoutesContext.Provider, { value: routes }, children));
15
- }
16
- function isFunctionOrReactComponent(Component) {
17
- return (!!Component &&
18
- (typeof Component === "function" ||
19
- Component?.prototype?.isReactComponent ||
20
- Component.$$typeof === Symbol.for("react.forward_ref")));
21
- }
22
- /** Returns the Tutorial component if there are no React components exported as default from any files in the provided context module. */
23
- function useTutorial(context) {
24
- if (process.env.NODE_ENV === "production") {
25
- return null;
26
- }
27
- // eslint-disable-next-line react-hooks/rules-of-hooks
28
- const keys = useMemo(() => context.keys(), [context]);
29
- // eslint-disable-next-line react-hooks/rules-of-hooks
30
- const hasAnyValidComponent = useMemo(() => {
31
- for (const key of keys) {
32
- // NOTE(EvanBacon): This should only ever occur in development as it breaks lazily loading.
33
- const component = context(key)?.default;
34
- if (isFunctionOrReactComponent(component)) {
35
- return true;
36
- }
37
- }
38
- return false;
39
- }, [keys]);
40
- if (hasAnyValidComponent) {
41
- return null;
42
- }
43
- return require("./onboard/Tutorial").Tutorial;
14
+ return (React.createElement(RootRouteNodeContext.Provider, { value: routes }, children));
44
15
  }
45
16
  export function ContextNavigator({ context }) {
46
17
  const Tutorial = useTutorial(context);
47
18
  if (Tutorial) {
48
19
  return React.createElement(Tutorial, null);
49
20
  }
50
- return (React.createElement(RoutesContextProvider, { context: context },
51
- React.createElement(Route, { filename: "./" },
52
- React.createElement(ContextNavigationContainer, null,
53
- React.createElement(Stack, { screenOptions: { animation: "none", headerShown: false } })))));
21
+ return (React.createElement(RootRouteNodeProvider, { context: context },
22
+ React.createElement(ContextNavigationContainer, null,
23
+ React.createElement(RootRoute, null))));
24
+ }
25
+ function RootRoute() {
26
+ const root = useRootRouteNodeContext();
27
+ const Component = getQualifiedRouteComponent(root);
28
+ // @ts-expect-error: TODO: Drop navigation and route props
29
+ return React.createElement(Component, null);
54
30
  }
55
31
  //# sourceMappingURL=ContextNavigator.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ContextNavigator.js","sourceRoot":"","sources":["../src/ContextNavigator.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAGxC,SAAS,wBAAwB,CAAC,OAAuB;IACvD,4CAA4C;IAC5C,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IACtD,OAAO,OAAO,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;AACnD,CAAC;AAED,SAAS,qBAAqB,CAAC,EAC7B,OAAO,EACP,QAAQ,GAIT;IACC,MAAM,MAAM,GAAG,wBAAwB,CAAC,OAAO,CAAC,CAAC;IACjD,OAAO,CACL,oBAAC,aAAa,CAAC,QAAQ,IAAC,KAAK,EAAE,MAAM,IAAG,QAAQ,CAA0B,CAC3E,CAAC;AACJ,CAAC;AAED,SAAS,0BAA0B,CACjC,SAAc;IAEd,OAAO,CACL,CAAC,CAAC,SAAS;QACX,CAAC,OAAO,SAAS,KAAK,UAAU;YAC9B,SAAS,EAAE,SAAS,EAAE,gBAAgB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ACvB,CACc,CACzB,CAAC;AACJ,CAAC","sourcesContent":["import React, { useMemo } from \"react\";\n\nimport { ContextNavigationContainer } from \"./ContextNavigationContainer\";\nimport { Route } from \"./Route\";\nimport { RoutesContext } from \"./context\";\nimport { getRoutes } from \"./getRoutes\";\nimport { Stack } from \"./layouts/Stack\";\nimport { RequireContext } from \"./types\";\n\nfunction useContextModuleAsRoutes(context: RequireContext) {\n // TODO: Is this an optimal hook dependency?\n const keys = useMemo(() => context.keys(), [context]);\n return useMemo(() => getRoutes(context), [keys]);\n}\n\nfunction RoutesContextProvider({\n context,\n children,\n}: {\n context: RequireContext;\n children: React.ReactNode;\n}) {\n const routes = useContextModuleAsRoutes(context);\n return (\n <RoutesContext.Provider value={routes}>{children}</RoutesContext.Provider>\n );\n}\n\nfunction isFunctionOrReactComponent(\n Component: any\n): Component is React.ComponentType {\n return (\n !!Component &&\n (typeof Component === \"function\" ||\n Component?.prototype?.isReactComponent ||\n Component.$$typeof === Symbol.for(\"react.forward_ref\"))\n );\n}\n\n/** Returns the Tutorial component if there are no React components exported as default from any files in the provided context module. */\nfunction useTutorial(context: RequireContext) {\n if (process.env.NODE_ENV === \"production\") {\n return null;\n }\n\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const keys = useMemo(() => context.keys(), [context]);\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const hasAnyValidComponent = useMemo(() => {\n for (const key of keys) {\n // NOTE(EvanBacon): This should only ever occur in development as it breaks lazily loading.\n const component = context(key)?.default;\n if (isFunctionOrReactComponent(component)) {\n return true;\n }\n }\n return false;\n }, [keys]);\n\n if (hasAnyValidComponent) {\n return null;\n }\n\n return require(\"./onboard/Tutorial\").Tutorial;\n}\n\nexport function ContextNavigator({ context }: { context: RequireContext }) {\n const Tutorial = useTutorial(context);\n if (Tutorial) {\n return <Tutorial />;\n }\n\n return (\n <RoutesContextProvider context={context}>\n <Route filename=\"./\">\n <ContextNavigationContainer>\n {/* Using a switch navigator at the root to host all pages. */}\n <Stack screenOptions={{ animation: \"none\", headerShown: false }} />\n </ContextNavigationContainer>\n </Route>\n </RoutesContextProvider>\n );\n}\n"]}
1
+ {"version":3,"file":"ContextNavigator.js","sourceRoot":"","sources":["../src/ContextNavigator.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAC;AAC1E,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEpD,OAAO,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAC;AAE1D,SAAS,wBAAwB,CAAC,OAAuB;IACvD,4CAA4C;IAC5C,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IACtD,OAAO,OAAO,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;AACnD,CAAC;AAED,SAAS,qBAAqB,CAAC,EAC7B,OAAO,EACP,QAAQ,GAIT;IACC,MAAM,MAAM,GAAG,wBAAwB,CAAC,OAAO,CAAC,CAAC;IACjD,OAAO,CACL,oBAAC,oBAAoB,CAAC,QAAQ,IAAC,KAAK,EAAE,MAAM,IACzC,QAAQ,CACqB,CACjC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,EAAE,OAAO,EAA+B;IACvE,MAAM,QAAQ,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;IACtC,IAAI,QAAQ,EAAE;QACZ,OAAO,oBAAC,QAAQ,OAAG,CAAC;KACrB;IAED,OAAO,CACL,oBAAC,qBAAqB,IAAC,OAAO,EAAE,OAAO;QACrC,oBAAC,0BAA0B;YACzB,oBAAC,SAAS,OAAG,CACc,CACP,CACzB,CAAC;AACJ,CAAC;AAED,SAAS,SAAS;IAChB,MAAM,IAAI,GAAG,uBAAuB,EAAE,CAAC;IAEvC,MAAM,SAAS,GAAG,0BAA0B,CAAC,IAAI,CAAC,CAAC;IACnD,0DAA0D;IAC1D,OAAO,oBAAC,SAAS,OAAG,CAAC;AACvB,CAAC","sourcesContent":["import React, { useMemo } from \"react\";\n\nimport { ContextNavigationContainer } from \"./ContextNavigationContainer\";\nimport { RootRouteNodeContext, useRootRouteNodeContext } from \"./context\";\nimport { getRoutes } from \"./getRoutes\";\nimport { useTutorial } from \"./onboard/useTutorial\";\nimport { RequireContext } from \"./types\";\nimport { getQualifiedRouteComponent } from \"./useScreens\";\n\nfunction useContextModuleAsRoutes(context: RequireContext) {\n // TODO: Is this an optimal hook dependency?\n const keys = useMemo(() => context.keys(), [context]);\n return useMemo(() => getRoutes(context), [keys]);\n}\n\nfunction RootRouteNodeProvider({\n context,\n children,\n}: {\n context: RequireContext;\n children: React.ReactNode;\n}) {\n const routes = useContextModuleAsRoutes(context);\n return (\n <RootRouteNodeContext.Provider value={routes}>\n {children}\n </RootRouteNodeContext.Provider>\n );\n}\n\nexport function ContextNavigator({ context }: { context: RequireContext }) {\n const Tutorial = useTutorial(context);\n if (Tutorial) {\n return <Tutorial />;\n }\n\n return (\n <RootRouteNodeProvider context={context}>\n <ContextNavigationContainer>\n <RootRoute />\n </ContextNavigationContainer>\n </RootRouteNodeProvider>\n );\n}\n\nfunction RootRoute() {\n const root = useRootRouteNodeContext();\n\n const Component = getQualifiedRouteComponent(root);\n // @ts-expect-error: TODO: Drop navigation and route props\n return <Component />;\n}\n"]}
package/build/Route.d.ts CHANGED
@@ -22,13 +22,14 @@ export declare type RouteNode = {
22
22
  /** Internal screens like the directory or the auto 404 should be marked as internal. */
23
23
  internal?: boolean;
24
24
  };
25
- /** Return all the routes for the current boundary. */
26
- export declare function useRoutes(): RouteNode[];
25
+ /** Return the RouteNode at the current contextual boundary. */
26
+ export declare function useRouteNode(): RouteNode | null;
27
27
  export declare function useContextKey(): string;
28
28
  /** Provides the matching routes and filename to the children. */
29
- export declare function Route({ filename, children, }: {
30
- filename: string;
29
+ export declare function Route({ children, node, }: {
31
30
  children: ReactNode;
31
+ node: RouteNode;
32
32
  }): JSX.Element;
33
+ export declare function useRootRoute(): RouteNode | null;
33
34
  export declare function sortRoutes(a: RouteNode, b: RouteNode): number;
34
35
  //# sourceMappingURL=Route.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Route.d.ts","sourceRoot":"","sources":["../src/Route.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAc,MAAM,OAAO,CAAC;AAKrD,yFAAyF;AACzF,oBAAY,WAAW,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,GACxD,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAEtB,oBAAY,SAAS,GAAG;IACtB,oBAAoB;IACpB,QAAQ,EAAE,SAAS,EAAE,CAAC;IACtB,qCAAqC;IACrC,YAAY,EAAE,MAAM,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;IAC7C,kCAAkC;IAClC,OAAO,EAAE,IAAI,GAAG;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,OAAO,CAAA;KAAE,CAAC;IAChD,wCAAwC;IACxC,SAAS,EAAE,MAAM,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACrC,sCAAsC;IACtC,KAAK,EAAE,MAAM,CAAC;IACd,uDAAuD;IACvD,UAAU,EAAE,MAAM,CAAC;IACnB,sBAAsB;IACtB,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB,wFAAwF;IACxF,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAWF,sDA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AgB,YAAY,IAAI,SAAS,GAAG,IAAI,CAE/C;AAED,wBAAgB,aAAa,IAAI,MAAM,CAMtC;AAED,iEAAiE;AACjE,wBAAgB,KAAK,CAAC,EACpB,QAAQ,EACR,IAAI,GACL,EAAE;IACD,QAAQ,EAAE,SAAS,CAAC;IACpB,IAAI,EAAE,SAAS,CAAC;CACjB,eAkBA;AAED,wBAAgB,YAAY,IAAI,SAAS,GAAG,IAAI,CAE/C;AAED,wBAAgB,UAAU,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,SAAS,GAAG,MAAM,CA4B7D"}
package/build/Route.js CHANGED
@@ -1,14 +1,14 @@
1
1
  import React, { useContext } from "react";
2
- import { RoutesContext } from "./context";
2
+ import { RootRouteNodeContext } from "./context";
3
3
  import { getNameFromFilePath, matchFragmentName } from "./matchers";
4
4
  const CurrentRoutePathContext = React.createContext(null);
5
- const CurrentRouteContext = React.createContext([]);
5
+ const CurrentRouteContext = React.createContext(null);
6
6
  if (process.env.NODE_ENV !== "production") {
7
7
  CurrentRoutePathContext.displayName = "RoutePath";
8
8
  CurrentRouteContext.displayName = "Route";
9
9
  }
10
- /** Return all the routes for the current boundary. */
11
- export function useRoutes() {
10
+ /** Return the RouteNode at the current contextual boundary. */
11
+ export function useRouteNode() {
12
12
  return useContext(CurrentRouteContext);
13
13
  }
14
14
  export function useContextKey() {
@@ -19,35 +19,21 @@ export function useContextKey() {
19
19
  return filename;
20
20
  }
21
21
  /** Provides the matching routes and filename to the children. */
22
- export function Route({ filename, children, }) {
23
- const normalName = React.useMemo(() => getNameFromFilePath(filename), [filename]);
24
- const routes = useRoutesAtPath(normalName);
25
- return (React.createElement(CurrentRoutePathContext.Provider, { value:
22
+ export function Route({ children, node, }) {
23
+ const normalName = React.useMemo(() => {
26
24
  // The root path is `` (empty string) so always prepend `/` to ensure
27
25
  // there is some value.
28
- "/" + normalName },
29
- React.createElement(CurrentRouteContext.Provider, { value: routes }, children)));
30
- }
31
- function useRoutesAtPath(normalName) {
32
- const routes = useContext(RoutesContext);
33
- const keys = React.useMemo(() => routes.keys(), [routes]);
34
- const family = React.useMemo(() => {
35
- let children = routes;
36
- // Skip root directory
37
- if (normalName) {
38
- // split and search
39
- const parts = normalName.split("/");
40
- for (const part of parts) {
41
- const next = children.find(({ route }) => route === part);
42
- if (!next?.children) {
43
- return [];
44
- }
45
- children = next?.children;
46
- }
26
+ const normal = "/" + getNameFromFilePath(node.contextKey);
27
+ if (!normal.endsWith("_layout")) {
28
+ return normal;
47
29
  }
48
- return children.sort(sortRoutes);
49
- }, [normalName, keys]);
50
- return family;
30
+ return normal.replace(/\/?_layout$/, "");
31
+ }, [node.contextKey]);
32
+ return (React.createElement(CurrentRoutePathContext.Provider, { value: normalName },
33
+ React.createElement(CurrentRouteContext.Provider, { value: node }, children)));
34
+ }
35
+ export function useRootRoute() {
36
+ return useContext(RootRouteNodeContext);
51
37
  }
52
38
  export function sortRoutes(a, b) {
53
39
  if (a.dynamic && !b.dynamic) {
@@ -1 +1 @@
1
- {"version":3,"file":"Route.js","sourceRoot":"","sources":["../src/Route.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAa,UAAU,EAAE,MAAM,OAAO,CAAC;AAErD,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AA0BpE,MAAM,uBAAuB,GAAG,KAAK,CAAC,aAAa,CAAgB,IAAI,CAAC,CAAC;AAEzE,MAAM,mBAAmB,GAAG,KAAK,CAAC,aAAa,CAAc,EAAE,CAAC,CAAC;AAEjE,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE;IACzC,uBAAuB,CAAC,WAAW,GAAG,WAAW,CAAC;IAClD,mBAAmB,CAAC,WAAW,GAAG,OAAO,CAAC;CAC3C;AAED,sDAAsD;AACtD,MAAM,UAAU,SAAS;IACvB,OAAO,UAAU,CAAC,m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,CAAC,CAAC,CAAC;KACX;IACD,IAAI,CAAC,MAAM,IAAI,MAAM,EAAE;QACrB,OAAO,CAAC,CAAC;KACV;IAED,OAAO,CAAC,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC;AACzC,CAAC","sourcesContent":["import React, { ReactNode, useContext } from \"react\";\n\nimport { RoutesContext } from \"./context\";\nimport { getNameFromFilePath, matchFragmentName } from \"./matchers\";\n\n/** The list of input keys will become optional, everything else will remain the same. */\nexport type PickPartial<T, K extends keyof T> = Omit<T, K> &\n Partial<Pick<T, K>>;\n\nexport type RouteNode = {\n /** nested routes */\n children: RouteNode[];\n /** Lazily get the React component */\n getComponent: () => React.ComponentType<any>;\n /** Is the route a dynamic path */\n dynamic: null | { name: string; deep: boolean };\n /** All static exports from the file. */\n getExtras: () => Record<string, any>;\n /** `index`, `error-boundary`, etc. */\n route: string;\n /** require.context key, used for matching children. */\n contextKey: string;\n /** Added in-memory */\n generated?: boolean;\n\n /** Internal screens like the directory or the auto 404 should be marked as internal. */\n internal?: boolean;\n};\n\nconst CurrentRoutePathContext = React.createContext<string | null>(null);\n\nconst CurrentRouteContext = React.createContext<RouteNode[]>([]);\n\nif (process.env.NODE_ENV !== \"production\") {\n CurrentRoutePathContext.displayName = \"RoutePath\";\n CurrentRouteContext.displayName = \"Route\";\n}\n\n/** Return all the routes for the current boundary. */\nexport function useRoutes(): RouteNode[] {\n return useContext(CurrentRouteContext);\n}\n\nexport function useContextKey(): string {\n const filename = useContext(CurrentRoutePathContext);\n if (filename == null) {\n throw new Error(\"No filename found. This is likely a bug in expo-router.\");\n }\n return filename;\n}\n\n/** Provides the matching routes and filename to the children. */\nexport function Route({\n filename,\n children,\n}: {\n filename: string;\n children: ReactNode;\n}) {\n const normalName = React.useMemo(\n () => getNameFromFilePath(filename),\n [filename]\n );\n\n const routes = useRoutesAtPath(normalName);\n\n return (\n <CurrentRoutePathContext.Provider\n value={\n // The root path is `` (empty string) so always prepend `/` to ensure\n // there is some value.\n \"/\" + normalName\n }\n >\n <CurrentRouteContext.Provider value={routes}>\n {children}\n </CurrentRouteContext.Provider>\n </CurrentRoutePathContext.Provider>\n );\n}\n\nfunction useRoutesAtPath(normalName: string): RouteNode[] {\n const routes = useContext(RoutesContext);\n const keys = React.useMemo(() => routes.keys(), [routes]);\n\n const family = React.useMemo(() => {\n let children: RouteNode[] = routes;\n\n // Skip root directory\n if (normalName) {\n // split and search\n const parts = normalName.split(\"/\");\n for (const part of parts) {\n const next = children.find(({ route }) => route === part);\n\n if (!next?.children) {\n return [];\n }\n\n children = next?.children;\n }\n }\n\n return children.sort(sortRoutes);\n }, [normalName, keys]);\n\n return family;\n}\n\nexport function sortRoutes(a: RouteNode, b: RouteNode): number {\n if (a.dynamic && !b.dynamic) {\n return 1;\n }\n if (!a.dynamic && b.dynamic) {\n return -1;\n }\n if (a.dynamic && b.dynamic) {\n if (a.dynamic.deep && !b.dynamic.deep) {\n return 1;\n }\n if (!a.dynamic.deep && b.dynamic.deep) {\n return -1;\n }\n return 0;\n }\n\n const aIndex = a.route === \"index\" || matchFragmentName(a.route) != null;\n const bIndex = b.route === \"index\" || matchFragmentName(b.route) != null;\n\n if (aIndex && !bIndex) {\n return -1;\n }\n if (!aIndex && bIndex) {\n return 1;\n }\n\n return a.route.length - b.route.length;\n}\n"]}
1
+ {"version":3,"file":"Route.js","sourceRoot":"","sources":["../src/Route.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAa,UAAU,EAAE,MAAM,OAAO,CAAC;AAErD,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AA0BpE,MAAM,uBAAuB,GAAG,KAAK,CAAC,aAAa,CAAgB,IAAI,CAAC,CAAC;AAEzE,MAAM,mBAAmB,GAAG,KAAK,CAAC,aAAa,CAAmB,IAAI,CAAC,CAAC;AAExE,IAA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AAI,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,CAAC,OAAO,EAAE;QAC3B,OAAO,CAAC,CAAC;KACV;IACD,IAAI,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,OAAO,EAAE;QAC3B,OAAO,CAAC,CAAC,CAAC;KACX;IACD,IAAI,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,OAAO,EAAE;QAC1B,IAAI,CAAC,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE;YACrC,OAAO,CAAC,CAAC;SACV;QACD,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE;YACrC,OAAO,CAAC,CAAC,CAAC;SACX;QACD,OAAO,CAAC,CAAC;KACV;IAED,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,KAAK,OAAO,IAAI,iBAAiB,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC;IACzE,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,KAAK,OAAO,IAAI,iBAAiB,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC;IAEzE,IAAI,MAAM,IAAI,CAAC,MAAM,EAAE;QACrB,OAAO,CAAC,CAAC,CAAC;KACX;IACD,IAAI,CAAC,MAAM,IAAI,MAAM,EAAE;QACrB,OAAO,CAAC,CAAC;KACV;IAED,OAAO,CAAC,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC;AACzC,CAAC","sourcesContent":["import React, { ReactNode, useContext } from \"react\";\n\nimport { RootRouteNodeContext } from \"./context\";\nimport { getNameFromFilePath, matchFragmentName } from \"./matchers\";\n\n/** The list of input keys will become optional, everything else will remain the same. */\nexport type PickPartial<T, K extends keyof T> = Omit<T, K> &\n Partial<Pick<T, K>>;\n\nexport type RouteNode = {\n /** nested routes */\n children: RouteNode[];\n /** Lazily get the React component */\n getComponent: () => React.ComponentType<any>;\n /** Is the route a dynamic path */\n dynamic: null | { name: string; deep: boolean };\n /** All static exports from the file. */\n getExtras: () => Record<string, any>;\n /** `index`, `error-boundary`, etc. */\n route: string;\n /** require.context key, used for matching children. */\n contextKey: string;\n /** Added in-memory */\n generated?: boolean;\n\n /** Internal screens like the directory or the auto 404 should be marked as internal. */\n internal?: boolean;\n};\n\nconst CurrentRoutePathContext = React.createContext<string | null>(null);\n\nconst CurrentRouteContext = React.createContext<RouteNode | null>(null);\n\nif (process.env.NODE_ENV !== \"production\") {\n CurrentRoutePathContext.displayName = \"RoutePath\";\n CurrentRouteContext.displayName = \"Route\";\n}\n\n/** Return the RouteNode at the current contextual boundary. */\nexport function useRouteNode(): RouteNode | null {\n return useContext(CurrentRouteContext);\n}\n\nexport function useContextKey(): string {\n const filename = useContext(CurrentRoutePathContext);\n if (filename == null) {\n throw new Error(\"No filename found. This is likely a bug in expo-router.\");\n }\n return filename;\n}\n\n/** Provides the matching routes and filename to the children. */\nexport function Route({\n children,\n node,\n}: {\n children: ReactNode;\n node: RouteNode;\n}) {\n const normalName = React.useMemo(() => {\n // The root path is `` (empty string) so always prepend `/` to ensure\n // there is some value.\n const normal = \"/\" + getNameFromFilePath(node.contextKey);\n if (!normal.endsWith(\"_layout\")) {\n return normal;\n }\n return normal.replace(/\\/?_layout$/, \"\");\n }, [node.contextKey]);\n\n return (\n <CurrentRoutePathContext.Provider value={normalName}>\n <CurrentRouteContext.Provider value={node}>\n {children}\n </CurrentRouteContext.Provider>\n </CurrentRoutePathContext.Provider>\n );\n}\n\nexport function useRootRoute(): RouteNode | null {\n return useContext(RootRouteNodeContext);\n}\n\nexport function sortRoutes(a: RouteNode, b: RouteNode): number {\n if (a.dynamic && !b.dynamic) {\n return 1;\n }\n if (!a.dynamic && b.dynamic) {\n return -1;\n }\n if (a.dynamic && b.dynamic) {\n if (a.dynamic.deep && !b.dynamic.deep) {\n return 1;\n }\n if (!a.dynamic.deep && b.dynamic.deep) {\n return -1;\n }\n return 0;\n }\n\n const aIndex = a.route === \"index\" || matchFragmentName(a.route) != null;\n const bIndex = b.route === \"index\" || matchFragmentName(b.route) != null;\n\n if (aIndex && !bIndex) {\n return -1;\n }\n if (!aIndex && bIndex) {\n return 1;\n }\n\n return a.route.length - b.route.length;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"aasa.d.ts","sourceRoot":"","sources":["../src/aasa.ts"],"names":[],"mappings":"AAkBA,wBAAgB,kBAAkB,CAChC,SAAS,WAAoB,EAC7B,UAAU,WAAQ,YAgBnB"}
1
+ {"version":3,"file":"aasa.d.ts","sourceRoot":"","sources":["../src/aasa.ts"],"names":[],"mappings":"AAsBA,wBAAgB,kBAAkB,CAChC,SAAS,WAAoB,EAC7B,UAAU,WAAQ,YAgBnB"}
package/build/aasa.js CHANGED
@@ -8,10 +8,11 @@ function getWebUrlsFromManifest() {
8
8
  const applinks = domains
9
9
  .filter((domain) => domain.startsWith("applinks:"))
10
10
  .map((domain) => {
11
- const clean = domain.replace(/^applinks:/, "");
12
- return clean.endsWith("/") ? clean.slice(0, -1) : clean;
11
+ let clean = domain.replace(/^applinks:/, "");
12
+ clean = clean.endsWith("/") ? clean.slice(0, -1) : clean;
13
+ return clean.replace(/\?mode=(developer|managed|developer\+managed|managed\+developer)$/, "");
13
14
  });
14
- return applinks;
15
+ return [...new Set(applinks)];
15
16
  }
16
17
  export function getAllWebRedirects(protocols = ["https", "http"], subdomains = ["*"]) {
17
18
  const urls = getWebUrlsFromManifest();
package/build/aasa.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"aasa.js","sourceRoot":"","sources":["../src/aasa.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,gBAAgB,CAAC;AAEvC,SAAS,sBAAsB;IAC7B,8DAA8D;IAC9D,oFAAoF;IACpF,sDAAsD;IACtD,MAAM,OAAO,GAAG,SAAS,CAAC,UAAU,EAAE,GAAG,EAAE,iBAAiB,IAAI,EAAE,CAAC;IACnE,mEAAmE;IACnE,MAAM,QAAQ,GAAG,OAAO;SACrB,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;SAClD,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;QACd,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;QAC/C,OAAO,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IAC1D,CAAC,CAAC,CAAC;IAEL,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,MAAM,UAAU,kBAAkB,CAChC,SAAS,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,EAC7B,UAAU,GAAG,CAAC,GAAG,CAAC;IAElB,MAAM,IAAI,GAAG,sBAAsB,EAAE,CAAC;IACtC,MAAM,WAAW,GAAG,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IAC5C,OAAO,IAAI;SACR,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CACX,SAAS;SACN,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAChB,WAAW,CAAC,GAAG,CACb,CAAC,SAAS,EAAE,EAAE,CACZ,GAAG,QAAQ,MAAM,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CACjE,CACF;SACA,IAAI,EAAE,CACV;SACA,IAAI,EAAE,CAAC;AACZ,CAAC","sourcesContent":["import Constants from \"expo-constants\";\n\nfunction getWebUrlsFromManifest() {\n // TODO: Replace this with the source of truth native manifest\n // Then do a check to warn the user if the config doesn't match the native manifest.\n // TODO: Warn if the applinks have `https://` in them.\n const domains = Constants.expoConfig?.ios?.associatedDomains || [];\n // [applinks:explore-api.netlify.app/] -> [explore-api.netlify.app]\n const applinks = domains\n .filter((domain) => domain.startsWith(\"applinks:\"))\n .map((domain) => {\n const clean = domain.replace(/^applinks:/, \"\");\n return clean.endsWith(\"/\") ? clean.slice(0, -1) : clean;\n });\n\n return applinks;\n}\n\nexport function getAllWebRedirects(\n protocols = [\"https\", \"http\"],\n subdomains = [\"*\"]\n) {\n const urls = getWebUrlsFromManifest();\n const _subdomains = [\"\"].concat(subdomains);\n return urls\n .map((url) =>\n protocols\n .map((protocol) =>\n _subdomains.map(\n (subdomain) =>\n `${protocol}://${[subdomain, url].filter(Boolean).join(\".\")}/`\n )\n )\n .flat()\n )\n .flat();\n}\n"]}
1
+ {"version":3,"file":"aasa.js","sourceRoot":"","sources":["../src/aasa.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,gBAAgB,CAAC;AAEvC,SAAS,sBAAsB;IAC7B,8DAA8D;IAC9D,oFAAoF;IACpF,sDAAsD;IACtD,MAAM,OAAO,GAAG,SAAS,CAAC,UAAU,EAAE,GAAG,EAAE,iBAAiB,IAAI,EAAE,CAAC;IACnE,mEAAmE;IACnE,MAAM,QAAQ,GAAG,OAAO;SACrB,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;SAClD,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;QACd,IAAI,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;QAC7C,KAAK,GAAG,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;QACzD,OAAO,KAAK,CAAC,OAAO,CAClB,mEAAmE,EACnE,EAAE,CACH,CAAC;IACJ,CAAC,CAAC,CAAC;IAEL,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC;AAChC,CAAC;AAED,MAAM,UAAU,kBAAkB,CAChC,SAAS,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,EAC7B,UAAU,GAAG,CAAC,GAAG,CAAC;IAElB,MAAM,IAAI,GAAG,sBAAsB,EAAE,CAAC;IACtC,MAAM,WAAW,GAAG,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IAC5C,OAAO,IAAI;SACR,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CACX,SAAS;SACN,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAChB,WAAW,CAAC,GAAG,CACb,CAAC,SAAS,EAAE,EAAE,CACZ,GAAG,QAAQ,MAAM,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CACjE,CACF;SACA,IAAI,EAAE,CACV;SACA,IAAI,EAAE,CAAC;AACZ,CAAC","sourcesContent":["import Constants from \"expo-constants\";\n\nfunction getWebUrlsFromManifest() {\n // TODO: Replace this with the source of truth native manifest\n // Then do a check to warn the user if the config doesn't match the native manifest.\n // TODO: Warn if the applinks have `https://` in them.\n const domains = Constants.expoConfig?.ios?.associatedDomains || [];\n // [applinks:explore-api.netlify.app/] -> [explore-api.netlify.app]\n const applinks = domains\n .filter((domain) => domain.startsWith(\"applinks:\"))\n .map((domain) => {\n let clean = domain.replace(/^applinks:/, \"\");\n clean = clean.endsWith(\"/\") ? clean.slice(0, -1) : clean;\n return clean.replace(\n /\\?mode=(developer|managed|developer\\+managed|managed\\+developer)$/,\n \"\"\n );\n });\n\n return [...new Set(applinks)];\n}\n\nexport function getAllWebRedirects(\n protocols = [\"https\", \"http\"],\n subdomains = [\"*\"]\n) {\n const urls = getWebUrlsFromManifest();\n const _subdomains = [\"\"].concat(subdomains);\n return urls\n .map((url) =>\n protocols\n .map((protocol) =>\n _subdomains.map(\n (subdomain) =>\n `${protocol}://${[subdomain, url].filter(Boolean).join(\".\")}/`\n )\n )\n .flat()\n )\n .flat();\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
2
  import { RouteNode } from "./Route";
3
- export declare const RoutesContext: import("react").Context<RouteNode[]>;
4
- export declare function useRoutesContext(): RouteNode[];
3
+ export declare const RootRouteNodeContext: import("react").Context<RouteNode | null>;
4
+ export declare function useRootRouteNodeContext(): RouteNode;
5
5
  //# sourceMappingURL=context.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAGpC,eAAO,MAAM,aAAa,sCAAiC,CAAC;AAM5D,wBAAgB,gBAAgB,gBAQ/B"}
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAGpC,eAAO,MAAM,oBAAoB,2CAAwC,CAAC;AAM1E,wBAAgB,uBAAuB,cAQtC"}
package/build/context.js CHANGED
@@ -1,13 +1,13 @@
1
1
  import { createContext, useContext } from "react";
2
2
  // Routes context
3
- export const RoutesContext = createContext([]);
3
+ export const RootRouteNodeContext = createContext(null);
4
4
  if (process.env.NODE_ENV !== "production") {
5
- RoutesContext.displayName = "RoutesContext";
5
+ RootRouteNodeContext.displayName = "RoutesContext";
6
6
  }
7
- export function useRoutesContext() {
8
- const routes = useContext(RoutesContext);
7
+ export function useRootRouteNodeContext() {
8
+ const routes = useContext(RootRouteNodeContext);
9
9
  if (!routes) {
10
- throw new Error("useRoutes is being used outside of RoutesContext.Provider");
10
+ throw new Error("useRootRouteNodeContext is being used outside of RootRouteNodeContext.Provider");
11
11
  }
12
12
  return routes;
13
13
  }
@@ -1 +1 @@
1
- {"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAIlD,iBAAiB;AACjB,MAAM,CAAC,MAAM,aAAa,GAAG,aAAa,CAAc,EAAE,CAAC,CAAC;AAE5D,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE;IACzC,aAAa,CAAC,WAAW,GAAG,eAAe,CAAC;CAC7C;AAED,MAAM,UAAU,gBAAgB;IAC9B,MAAM,MAAM,GAAG,UAAU,CAAC,aAAa,CAAC,CAAC;IACzC,IAAI,CAAC,MAAM,EAAE;QACX,MAAM,IAAI,KAAK,CACb,2DAA2D,CAC5D,CAAC;KACH;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { createContext, useContext } from \"react\";\n\nimport { RouteNode } from \"./Route\";\n\n// Routes context\nexport const RoutesContext = createContext<RouteNode[]>([]);\n\nif (process.env.NODE_ENV !== \"production\") {\n RoutesContext.displayName = \"RoutesContext\";\n}\n\nexport function useRoutesContext() {\n const routes = useContext(RoutesContext);\n if (!routes) {\n throw new Error(\n \"useRoutes is being used outside of RoutesContext.Provider\"\n );\n }\n return routes;\n}\n"]}
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAIlD,iBAAiB;AACjB,MAAM,CAAC,MAAM,oBAAoB,GAAG,aAAa,CAAmB,IAAI,CAAC,CAAC;AAE1E,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE;IACzC,oBAAoB,CAAC,WAAW,GAAG,eAAe,CAAC;CACpD;AAED,MAAM,UAAU,uBAAuB;IACrC,MAAM,MAAM,GAAG,UAAU,CAAC,oBAAoB,CAAC,CAAC;IAChD,IAAI,CAAC,MAAM,EAAE;QACX,MAAM,IAAI,KAAK,CACb,gFAAgF,CACjF,CAAC;KACH;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { createContext, useContext } from \"react\";\n\nimport { RouteNode } from \"./Route\";\n\n// Routes context\nexport const RootRouteNodeContext = createContext<RouteNode | null>(null);\n\nif (process.env.NODE_ENV !== \"production\") {\n RootRouteNodeContext.displayName = \"RoutesContext\";\n}\n\nexport function useRootRouteNodeContext() {\n const routes = useContext(RootRouteNodeContext);\n if (!routes) {\n throw new Error(\n \"useRootRouteNodeContext is being used outside of RootRouteNodeContext.Provider\"\n );\n }\n return routes;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"exports.d.ts","sourceRoot":"","sources":["../src/exports.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAEhE,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAEtD,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAE7D,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAK1C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC"}
1
+ {"version":3,"file":"exports.d.ts","sourceRoot":"","sources":["../src/exports.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAEhE,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAEtD,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAE7D,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC"}
package/build/exports.js CHANGED
@@ -9,8 +9,6 @@ export { useLink } from "./link/useLink";
9
9
  export { RootContainer } from "./ContextNavigationContainer";
10
10
  import * as Linking_1 from "./link/linking";
11
11
  export { Linking_1 as Linking };
12
- // export { useRoutes } from "./Route";
13
- // export { useScreens } from "./useScreens";
14
12
  export { SplashScreen } from "./views/Splash";
15
13
  export { useHref } from "./link/useHref";
16
14
  export { useNavigation } from "./useNavigation";
@@ -1 +1 @@
1
- {"version":3,"file":"exports.js","sourceRoot":"","sources":["../src/exports.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAG1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAEhE,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAEtD,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;2BAEpC,gBAAgB;sBAA7B,OAAO;AAEnB,uCAAuC;AACvC,6CAA6C;AAE7C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC","sourcesContent":["export { useFocusEffect } from \"@react-navigation/native\";\nexport { ErrorBoundaryProps } from \"./views/Try\";\n\nexport { withLayoutContext } from \"./layouts/withLayoutContext\";\n\nexport { ExpoRoot } from \"./views/Root\";\nexport { Unmatched } from \"./views/Unmatched\";\nexport { ErrorBoundary } from \"./views/ErrorBoundary\";\n\nexport { Layout, Children } from \"./views/Layout\";\nexport { Link, Redirect } from \"./link/Link\";\nexport { useLink } from \"./link/useLink\";\nexport { RootContainer } from \"./ContextNavigationContainer\";\n\nexport * as Linking from \"./link/linking\";\n\n// export { useRoutes } from \"./Route\";\n// export { useScreens } from \"./useScreens\";\n\nexport { SplashScreen } from \"./views/Splash\";\nexport { useHref } from \"./link/useHref\";\nexport { useNavigation } from \"./useNavigation\";\n"]}
1
+ {"version":3,"file":"exports.js","sourceRoot":"","sources":["../src/exports.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAG1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAEhE,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAEtD,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;2BAEpC,gBAAgB;sBAA7B,OAAO;AAEnB,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC","sourcesContent":["export { useFocusEffect } from \"@react-navigation/native\";\nexport { ErrorBoundaryProps } from \"./views/Try\";\n\nexport { withLayoutContext } from \"./layouts/withLayoutContext\";\n\nexport { ExpoRoot } from \"./views/Root\";\nexport { Unmatched } from \"./views/Unmatched\";\nexport { ErrorBoundary } from \"./views/ErrorBoundary\";\n\nexport { Layout, Children } from \"./views/Layout\";\nexport { Link, Redirect } from \"./link/Link\";\nexport { useLink } from \"./link/useLink\";\nexport { RootContainer } from \"./ContextNavigationContainer\";\n\nexport * as Linking from \"./link/linking\";\n\nexport { SplashScreen } from \"./views/Splash\";\nexport { useHref } from \"./link/useHref\";\nexport { useNavigation } from \"./useNavigation\";\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"getPathFromState.d.ts","sourceRoot":"","sources":["../../src/fork/getPathFromState.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,aAAa,EACd,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EACV,eAAe,EACf,YAAY,EAEb,MAAM,2BAA2B,CAAC;AAKnC,aAAK,OAAO,CAAC,SAAS,SAAS,MAAM,IAAI;IACvC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,OAAO,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;CACnC,CAAC;AAEF,oBAAY,KAAK,GACb,eAAe,GACf,IAAI,CAAC,YAAY,CAAC,eAAe,CAAC,EAAE,OAAO,CAAC,CAAC;AA6CjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,SAAS,SAAS,MAAM,EAC/D,KAAK,EAAE,KAAK,EACZ,OAAO,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,GAC3B,MAAM,CA0LR"}
1
+ {"version":3,"file":"getPathFromState.d.ts","sourceRoot":"","sources":["../../src/fork/getPathFromState.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,aAAa,EAEd,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EACV,eAAe,EACf,YAAY,EAEb,MAAM,2BAA2B,CAAC;AAKnC,aAAK,OAAO,CAAC,SAAS,SAAS,MAAM,IAAI;IACvC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,OAAO,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;CACnC,CAAC;AAEF,oBAAY,KAAK,GACb,eAAe,GACf,IAAI,CAAC,YAAY,CAAC,eAAe,CAAC,EAAE,OAAO,CAAC,CAAC;AA6CjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,SAAS,SAAS,MAAM,EAC/D,KAAK,EAAE,KAAK,EACZ,OAAO,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,GAC3B,MAAM,CAiMR"}
@@ -1,6 +1,6 @@
1
1
  import { validatePathConfig, } from "@react-navigation/core";
2
2
  import * as queryString from "query-string";
3
- import { matchDeepDynamicRouteName } from "../matchers";
3
+ import { matchDeepDynamicRouteName, matchFragmentName } from "../matchers";
4
4
  const getActiveRoute = (state) => {
5
5
  const route = typeof state.index === "number"
6
6
  ? state.routes[state.index]
@@ -186,7 +186,12 @@ export default function getPathFromState(state, options) {
186
186
  .join("/");
187
187
  }
188
188
  else {
189
- path += encodeURIComponent(route.name);
189
+ // TODO: Probably fragment routes shouldn't get this far
190
+ path += encodeURIComponent(matchFragmentName(route.name)
191
+ ? ""
192
+ : route.name === "index"
193
+ ? ""
194
+ : route.name);
190
195
  }
191
196
  if (!focusedParams) {
192
197
  focusedParams = focusedRoute.params;
@@ -1 +1 @@
1
- {"version":3,"file":"getPathFromState.js","sourceRoot":"","sources":["../../src/fork/getPathFromState.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,GAGnB,MAAM,wBAAwB,CAAC;AAMhC,OAAO,KAAK,WAAW,MAAM,cAAc,CAAC;AAE5C,OAAO,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAmBxD,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;QACf,OAAO,cAAc,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;KACpC;IAED,IAAI,KAAK,IAAI,eAAe,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE;QAC1C,OAAO,cAAc,CAAC,eAAe,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;KACtD;IAED,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF,SAAS,eAAe,CAAC,MAAqB;IAC5C,OAAO;QACL,KAAK,EAAE,KAAK;QACZ,IAAI,EAAE,SAAS;QACf,GAAG,EAAE,SAAS;QACd,KAAK,EAAE,CAAC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9B,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","sourcesContent":["import {\n validatePathConfig,\n PathConfig,\n PathConfigMap,\n} from \"@react-navigation/core\";\nimport type {\n NavigationState,\n PartialState,\n Route,\n} from \"@react-navigation/routers\";\nimport * as queryString from \"query-string\";\n\nimport { matchDeepDynamicRouteName } from \"../matchers\";\n\ntype Options<ParamList extends object> = {\n initialRouteName?: string;\n screens: PathConfigMap<ParamList>;\n};\n\nexport type State =\n | NavigationState\n | Omit<PartialState<NavigationState>, \"stale\">;\n\ntype StringifyConfig = Record<string, (value: any) => string>;\n\ntype ConfigItem = {\n pattern?: string;\n stringify?: StringifyConfig;\n screens?: Record<string, ConfigItem>;\n};\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 if (route && isInvalidParams(route.params)) {\n return getActiveRoute(createFakeState(route.params));\n }\n\n return route;\n};\n\nfunction createFakeState(params: StateAsParams) {\n return {\n stale: false,\n type: \"UNKNOWN\",\n key: \"UNKNOWN\",\n index: 0,\n routeNames: [],\n routes: [\n {\n key: \"UNKNOWN\",\n name: params.screen,\n params: params.params,\n path: params.path,\n },\n ],\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 default function getPathFromState<ParamList extends object>(\n state: State,\n options?: Options<ParamList>\n): string {\n if (state == null) {\n throw Error(\n \"Got 'undefined' for the navigation state. You must pass a valid state object.\"\n );\n }\n\n if (options) {\n validatePathConfig(options);\n }\n\n // Create a normalized configs object which will be easier to use\n const configs: Record<string, ConfigItem> = options?.screens\n ? createNormalizedConfigs(options?.screens)\n : {};\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 // NOTE(EvanBacon): Fill in current route using state that was passed as params.\n if (!route.state && isInvalidParams(route.params)) {\n route.state = createFakeState(route.params);\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 // Keep all the route names that appeared during going deeper in config in case the pattern is resolved to undefined\n const nestedRouteNames = [];\n\n let hasNext = true;\n\n while (route.name in currentOptions && hasNext) {\n pattern = currentOptions[route.name].pattern;\n\n // @ts-expect-error\n nestedRouteNames.push(route.name);\n\n if (route.params) {\n const stringify = currentOptions[route.name]?.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\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) => p.startsWith(\":\") || p === \"*\")\n // eslint-disable-next-line no-loop-func\n .forEach((p) => {\n let name: string;\n if (p === \"*\") {\n // NOTE(EvanBacon): Drop the param name matching the wildcard route name -- this is specific to Expo Router.\n name = matchDeepDynamicRouteName(route.name) ?? route.name;\n } else {\n name = getParamName(p);\n }\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 hasNext = false;\n } else {\n index =\n typeof route.state.index === \"number\"\n ? route.state.index\n : 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 path += pattern\n .split(\"/\")\n .map((p, i) => {\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 if (i === 0) {\n // This can occur when a wildcard matches all routes and the given path was `/`.\n return route.path ?? \"\";\n }\n // remove existing segments from route.path and return it\n // this is used for nested wildcard routes. Without this, the path would add\n // all nested segments to the beginning of the wildcard route.\n const path = route.path\n ?.split(\"/\")\n .slice(i + 1)\n .join(\"/\");\n return path ?? \"\";\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 == null) {\n // Optional params without value assigned in route.params should be ignored\n return \"\";\n }\n return value;\n }\n\n return encodeURIComponent(p);\n })\n .join(\"/\");\n } else {\n path += encodeURIComponent(route.name);\n }\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 const query = queryString.stringify(focusedParams, { sort: false });\n\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 return path;\n}\n\ntype StateAsParams = {\n initial: boolean;\n path: string;\n screen: string;\n params: Record<string, any>;\n};\n\n// TODO: Make StackRouter not do this...\n// Detect if the params came from StackRouter using `params` to pass around internal state.\nfunction isInvalidParams(\n params?: Record<string, any>\n): params is StateAsParams {\n return (\n !!params &&\n \"initial\" in params &&\n \"path\" in params &&\n \"screen\" in params &&\n \"params\" in params &&\n typeof params.params === \"object\" &&\n !!params.params\n );\n}\n\nconst getParamName = (pattern: string) =>\n 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\n ? joinPaths(parentPattern || \"\", config.path || \"\")\n : config.path || \"\";\n\n const screens = config.screens\n ? createNormalizedConfigs(config.screens, pattern)\n : 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"]}
1
+ {"version":3,"file":"getPathFromState.js","sourceRoot":"","sources":["../../src/fork/getPathFromState.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,kBAAkB,GACnB,MAAM,wBAAwB,CAAC;AAMhC,OAAO,KAAK,WAAW,MAAM,cAAc,CAAC;AAE5C,OAAO,EAAE,yBAAyB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAmB3E,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;QACf,OAAO,cAAc,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;KACpC;IAED,IAAI,KAAK,IAAI,eAAe,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE;QAC1C,OAAO,cAAc,CAAC,eAAe,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;KACtD;IAED,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF,SAAS,eAAe,CAAC,MAAqB;IAC5C,OAAO;QACL,KAAK,EAAE,KAAK;QACZ,IAAI,EAAE,SAAS;QACf,GAAG,EAAE,SAAS;QACd,KAAK,EAAE,CAAC;QACR,UAAU,EAAE,EAAE;QACd,MAAM,EAAE;YACN;gBACE,GAAG,EAAE,SAAS;gBACd,IAAI,EAAE,MAAM,CAAC,MAAM;gBACnB,MAAM,EAAE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AG,CAC9B,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","sourcesContent":["import {\n PathConfig,\n PathConfigMap,\n validatePathConfig,\n} from \"@react-navigation/core\";\nimport type {\n NavigationState,\n PartialState,\n Route,\n} from \"@react-navigation/routers\";\nimport * as queryString from \"query-string\";\n\nimport { matchDeepDynamicRouteName, matchFragmentName } from \"../matchers\";\n\ntype Options<ParamList extends object> = {\n initialRouteName?: string;\n screens: PathConfigMap<ParamList>;\n};\n\nexport type State =\n | NavigationState\n | Omit<PartialState<NavigationState>, \"stale\">;\n\ntype StringifyConfig = Record<string, (value: any) => string>;\n\ntype ConfigItem = {\n pattern?: string;\n stringify?: StringifyConfig;\n screens?: Record<string, ConfigItem>;\n};\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 if (route && isInvalidParams(route.params)) {\n return getActiveRoute(createFakeState(route.params));\n }\n\n return route;\n};\n\nfunction createFakeState(params: StateAsParams) {\n return {\n stale: false,\n type: \"UNKNOWN\",\n key: \"UNKNOWN\",\n index: 0,\n routeNames: [],\n routes: [\n {\n key: \"UNKNOWN\",\n name: params.screen,\n params: params.params,\n path: params.path,\n },\n ],\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 default function getPathFromState<ParamList extends object>(\n state: State,\n options?: Options<ParamList>\n): string {\n if (state == null) {\n throw Error(\n \"Got 'undefined' for the navigation state. You must pass a valid state object.\"\n );\n }\n\n if (options) {\n validatePathConfig(options);\n }\n\n // Create a normalized configs object which will be easier to use\n const configs: Record<string, ConfigItem> = options?.screens\n ? createNormalizedConfigs(options?.screens)\n : {};\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 // NOTE(EvanBacon): Fill in current route using state that was passed as params.\n if (!route.state && isInvalidParams(route.params)) {\n route.state = createFakeState(route.params);\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 // Keep all the route names that appeared during going deeper in config in case the pattern is resolved to undefined\n const nestedRouteNames = [];\n\n let hasNext = true;\n\n while (route.name in currentOptions && hasNext) {\n pattern = currentOptions[route.name].pattern;\n\n // @ts-expect-error\n nestedRouteNames.push(route.name);\n\n if (route.params) {\n const stringify = currentOptions[route.name]?.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\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) => p.startsWith(\":\") || p === \"*\")\n // eslint-disable-next-line no-loop-func\n .forEach((p) => {\n let name: string;\n if (p === \"*\") {\n // NOTE(EvanBacon): Drop the param name matching the wildcard route name -- this is specific to Expo Router.\n name = matchDeepDynamicRouteName(route.name) ?? route.name;\n } else {\n name = getParamName(p);\n }\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 hasNext = false;\n } else {\n index =\n typeof route.state.index === \"number\"\n ? route.state.index\n : 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 path += pattern\n .split(\"/\")\n .map((p, i) => {\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 if (i === 0) {\n // This can occur when a wildcard matches all routes and the given path was `/`.\n return route.path ?? \"\";\n }\n // remove existing segments from route.path and return it\n // this is used for nested wildcard routes. Without this, the path would add\n // all nested segments to the beginning of the wildcard route.\n const path = route.path\n ?.split(\"/\")\n .slice(i + 1)\n .join(\"/\");\n return path ?? \"\";\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 == null) {\n // Optional params without value assigned in route.params should be ignored\n return \"\";\n }\n return value;\n }\n\n return encodeURIComponent(p);\n })\n .join(\"/\");\n } else {\n // TODO: Probably fragment routes shouldn't get this far\n path += encodeURIComponent(\n matchFragmentName(route.name)\n ? \"\"\n : route.name === \"index\"\n ? \"\"\n : route.name\n );\n }\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 const query = queryString.stringify(focusedParams, { sort: false });\n\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 return path;\n}\n\ntype StateAsParams = {\n initial: boolean;\n path: string;\n screen: string;\n params: Record<string, any>;\n};\n\n// TODO: Make StackRouter not do this...\n// Detect if the params came from StackRouter using `params` to pass around internal state.\nfunction isInvalidParams(\n params?: Record<string, any>\n): params is StateAsParams {\n return (\n !!params &&\n \"initial\" in params &&\n \"path\" in params &&\n \"screen\" in params &&\n \"params\" in params &&\n typeof params.params === \"object\" &&\n !!params.params\n );\n}\n\nconst getParamName = (pattern: string) =>\n 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\n ? joinPaths(parentPattern || \"\", config.path || \"\")\n : config.path || \"\";\n\n const screens = config.screens\n ? createNormalizedConfigs(config.screens, pattern)\n : 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"]}
@@ -1,6 +1,10 @@
1
- import { LinkingOptions, PathConfigMap } from "@react-navigation/native";
1
+ import { LinkingOptions } from "@react-navigation/native";
2
2
  import { RouteNode } from "./Route";
3
- export declare function treeToReactNavigationLinkingRoutes(nodes: RouteNode[], parents?: string[]): PathConfigMap<object>;
4
- export declare function getLinkingConfig(routes: RouteNode[]): LinkingOptions<object>;
5
- export declare function useLinkingConfig(): LinkingOptions<object>;
3
+ declare type Screen = string | {
4
+ path: string;
5
+ screens: Record<string, Screen>;
6
+ };
7
+ export declare function getReactNavigationScreensConfig(nodes: RouteNode[]): Record<string, Screen>;
8
+ export declare function getLinkingConfig(routes: RouteNode): LinkingOptions<object>;
9
+ export {};
6
10
  //# sourceMappingURL=getLinkingConfig.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getLinkingConfig.d.ts","sourceRoot":"","sources":["../src/getLinkingConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAGzE,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAmCpC,wBAAgB,kCAAkC,CAChD,KAAK,EAAE,SAAS,EAAE,EAClB,OAAO,GAAE,MAAM,EAAO,GACrB,aAAa,CAAC,MAAM,CAAC,CAwBvB;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,SAAS,EAAE,GAAG,cAAc,CAAC,MAAM,CAAC,CAuB5E;AAED,wBAAgB,gBAAgB,IAAI,cAAc,CAAC,MAAM,CAAC,CAGzD"}
1
+ {"version":3,"file":"getLinkingConfig.d.ts","sourceRoot":"","sources":["../src/getLinkingConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE1D,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAepC,aAAK,MAAM,GACP,MAAM,GACN;IACE,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACjC,CAAC;AA6CN,wBAAgB,+BAA+B,CAC7C,KAAK,EAAE,SAAS,EAAE,GACjB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAIxB;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,SAAS,GAAG,cAAc,CAAC,MAAM,CAAC,CAuB1E"}