expo-router 0.0.8 → 0.0.10

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.
@@ -1 +1 @@
1
- {"version":3,"file":"ContextNavigationContainer.d.ts","sourceRoot":"","sources":["../src/ContextNavigationContainer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/E,OAAO,KAA+B,MAAM,OAAO,CAAC;AAIpD,aAAK,wBAAwB,GAAG,KAAK,CAAC,cAAc,CAChD,OAAO,mBAAmB,CAC7B,CAAC;AASF,wBAAgB,6BAA6B;;;;;;;;;;;;;;;;aAQ5C;AAUD,8GAA8G;AAC9G,eAAO,MAAM,0BAA0B;;;;;;;;4NA6BtC,CAAC;AAgBF,wBAAgB,aAAa,CAAC,EAAE,aAAa,EAAE,QAAQ,EAAE,YAAY,EAAE,aAAa,EAAE,iBAAiB,EAAE,KAAK,EAAE,EAAE,IAAI,CAAC,wBAAwB,EAAE,aAAa,GAAG,SAAS,GAAG,KAAK,GAAG,UAAU,GAAG,SAAS,CAAC,QAQ3M"}
1
+ {"version":3,"file":"ContextNavigationContainer.d.ts","sourceRoot":"","sources":["../src/ContextNavigationContainer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/E,OAAO,KAA+B,MAAM,OAAO,CAAC;AAKpD,aAAK,wBAAwB,GAAG,KAAK,CAAC,cAAc,CAChD,OAAO,mBAAmB,CAC7B,CAAC;AASF,wBAAgB,6BAA6B;;;;;;;;;;;;;;;;aAQ5C;AAED,8GAA8G;AAC9G,eAAO,MAAM,0BAA0B;;;;;;;;4NA2BtC,CAAC;AAgBF,wBAAgB,aAAa,CAAC,EAAE,aAAa,EAAE,QAAQ,EAAE,YAAY,EAAE,aAAa,EAAE,iBAAiB,EAAE,KAAK,EAAE,EAAE,IAAI,CAAC,wBAAwB,EAAE,aAAa,GAAG,SAAS,GAAG,KAAK,GAAG,UAAU,GAAG,SAAS,CAAC,QAQ3M"}
@@ -2,6 +2,7 @@ import { NavigationContainer } from "@react-navigation/native";
2
2
  import React, { useMemo, useCallback } from "react";
3
3
  import { useRoutesContext } from "./context";
4
4
  import { getLinkingConfig } from "./getLinkingConfig";
5
+ import SplashModule from "./splash";
5
6
  function useLinkingConfig() {
6
7
  const routes = useRoutesContext();
7
8
  return useMemo(() => getLinkingConfig(routes), [routes]);
@@ -14,13 +15,6 @@ export function useNavigationContainerContext() {
14
15
  }
15
16
  return context;
16
17
  }
17
- let hideAsync;
18
- try {
19
- hideAsync =
20
- require("expo-splash-screen").hideAsync;
21
- // Automatically handle hiding the splash screen if expo-splash-screen is installed.
22
- }
23
- catch { }
24
18
  /** react-navigation `NavigationContainer` with automatic `linking` prop generated from the routes context. */
25
19
  export const ContextNavigationContainer = React.forwardRef((props, ref) => {
26
20
  const [state, setState] = React.useState({});
@@ -28,9 +22,7 @@ export const ContextNavigationContainer = React.forwardRef((props, ref) => {
28
22
  console.log('linking', linking);
29
23
  const onReady = useCallback(() => {
30
24
  props.onReady?.();
31
- if (hideAsync) {
32
- hideAsync();
33
- }
25
+ SplashModule?.hideAsync();
34
26
  }, [props.onReady]);
35
27
  return (React.createElement(NavigationContainerContext.Provider, { value: [
36
28
  {
@@ -1 +1 @@
1
- {"version":3,"file":"ContextNavigationContainer.js","sourceRoot":"","sources":["../src/ContextNavigationContainer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAkB,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/E,OAAO,KAAK,EAAE,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAMtD,SAAS,gBAAgB;IACrB,MAAM,MAAM,GAAG,gBAAgB,EAAE,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D,QAAQ;SACX;QACG,oBAAC,kCAAkC,IAC/B,GAAG,EAAE,GAAG,GACV,CACgC,CACzC,CAAC;AACN,CAAC,CACJ,CAAC;AAEF,MAAM,kCAAkC,GAAG,KAAK,CAAC,UAAU,CACvD,CAAC,KAAS,EAAE,GAAoC,EAAE,EAAE;IAChD,MAAM,CAAC,YAAY,CAAC,GAAG,6BAA6B,EAAE,CAAC;IACvD,OAAO;IACH,0CAA0C;IAC1C,oBAAC,mBAAmB,IAChB,GAAG,EAAE,GAAG,KACJ,KAAK,KACL,YAAY,GAClB,CACL,CAAC;AACN,CAAC,CACJ,CAAC;AAEF,MAAM,UAAU,aAAa,CAAC,EAAE,aAAa,EAAE,QAAQ,EAAE,YAAY,EAAE,aAAa,EAAE,iBAAiB,EAAE,KAAK,EAA8F;IACxM,MAAM,CAAC,EAAE,QAAQ,CAAC,GAAG,6BAA6B,EAAE,CAAC;IAErD,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACjB,QAAQ,CAAC,EAAE,aAAa,EAAE,QAAQ,EAAE,YAAY,EAAE,aAAa,EAAE,iBAAiB,EAAE,KAAK,EAAE,CAAC,CAAC;IACjG,CAAC,EAAE,CAAC,aAAa,EAAE,QAAQ,EAAE,YAAY,EAAE,aAAa,EAAE,iBAAiB,EAAE,KAAK,CAAC,CAAC,CAAC;IAErF,OAAO,IAAI,CAAC;AAChB,CAAC","sourcesContent":["import { LinkingOptions, NavigationContainer } from \"@react-navigation/native\";\nimport React, { useMemo, useCallback } from \"react\";\nimport { useRoutesContext } from \"./context\";\nimport { getLinkingConfig } from \"./getLinkingConfig\";\n\ntype NavigationContainerProps = React.ComponentProps<\n typeof NavigationContainer\n>;\n\nfunction useLinkingConfig(): LinkingOptions<{}> {\n const routes = useRoutesContext();\n return useMemo(() => getLinkingConfig(routes), [routes]);\n}\n\nconst NavigationContainerContext = React.createContext<[Partial<NavigationContainerProps>, (props: Partial<NavigationContainerProps>) => void]>([{}, 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\nlet hideAsync: () => Promise<boolean> | undefined;\ntry {\n hideAsync =\n (require(\"expo-splash-screen\") as typeof import(\"expo-splash-screen\")).hideAsync;\n // Automatically handle hiding the splash screen if expo-splash-screen is installed.\n} catch { }\n\n\n/** react-navigation `NavigationContainer` with automatic `linking` prop generated from the routes context. */\nexport const ContextNavigationContainer = React.forwardRef(\n (props: NavigationContainerProps, ref: NavigationContainerProps[\"ref\"]) => {\n const [state, setState] = React.useState<Partial<NavigationContainerProps>>({});\n\n const linking = useLinkingConfig();\n console.log('linking', linking);\n const onReady = useCallback(() => {\n props.onReady?.();\n if (hideAsync) {\n hideAsync();\n }\n }, [props.onReady]);\n\n return (\n <NavigationContainerContext.Provider value={[\n {\n ...props,\n linking,\n onReady,\n ...state,\n },\n setState,\n ]}>\n <InternalContextNavigationContainer\n ref={ref}\n />\n </NavigationContainerContext.Provider>\n );\n }\n);\n\nconst InternalContextNavigationContainer = React.forwardRef(\n (props: {}, ref: NavigationContainerProps[\"ref\"]) => {\n const [contextProps] = useNavigationContainerContext();\n return (\n // @ts-expect-error: children are required\n <NavigationContainer\n ref={ref}\n {...props}\n {...contextProps}\n />\n );\n }\n);\n\nexport function RootContainer({ documentTitle, fallback, initialState, onStateChange, onUnhandledAction, theme }: Omit<NavigationContainerProps, 'independent' | 'onReady' | 'ref' | 'children' | 'linking'>) {\n const [, setProps] = useNavigationContainerContext();\n\n React.useEffect(() => {\n setProps({ documentTitle, fallback, initialState, onStateChange, onUnhandledAction, theme });\n }, [documentTitle, fallback, initialState, onStateChange, onUnhandledAction, theme]);\n\n return null;\n}"]}
1
+ {"version":3,"file":"ContextNavigationContainer.js","sourceRoot":"","sources":["../src/ContextNavigationContainer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAkB,mBAAmB,EAAE,MAAM,0BAA0B,CAAC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ACH,oBAAC,0BAA0B,CAAC,QAAQ,IAAC,KAAK,EAAE;YACxC;gBACI,GAAG,KAAK;gBACR,OAAO;gBACP,OAAO;gBACP,GAAG,KAAK;aACX;YACD,QAAQ;SACX;QACG,oBAAC,kCAAkC,IAC/B,GAAG,EAAE,GAAG,GACV,CACgC,CACzC,CAAC;AACN,CAAC,CACJ,CAAC;AAEF,MAAM,kCAAkC,GAAG,KAAK,CAAC,UAAU,CACvD,CAAC,KAAS,EAAE,GAAoC,EAAE,EAAE;IAChD,MAAM,CAAC,YAAY,CAAC,GAAG,6BAA6B,EAAE,CAAC;IACvD,OAAO;IACH,0CAA0C;IAC1C,oBAAC,mBAAmB,IAChB,GAAG,EAAE,GAAG,KACJ,KAAK,KACL,YAAY,GAClB,CACL,CAAC;AACN,CAAC,CACJ,CAAC;AAEF,MAAM,UAAU,aAAa,CAAC,EAAE,aAAa,EAAE,QAAQ,EAAE,YAAY,EAAE,aAAa,EAAE,iBAAiB,EAAE,KAAK,EAA8F;IACxM,MAAM,CAAC,EAAE,QAAQ,CAAC,GAAG,6BAA6B,EAAE,CAAC;IAErD,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACjB,QAAQ,CAAC,EAAE,aAAa,EAAE,QAAQ,EAAE,YAAY,EAAE,aAAa,EAAE,iBAAiB,EAAE,KAAK,EAAE,CAAC,CAAC;IACjG,CAAC,EAAE,CAAC,aAAa,EAAE,QAAQ,EAAE,YAAY,EAAE,aAAa,EAAE,iBAAiB,EAAE,KAAK,CAAC,CAAC,CAAC;IAErF,OAAO,IAAI,CAAC;AAChB,CAAC","sourcesContent":["import { LinkingOptions, NavigationContainer } from \"@react-navigation/native\";\nimport React, { useMemo, useCallback } from \"react\";\nimport { useRoutesContext } from \"./context\";\nimport { getLinkingConfig } from \"./getLinkingConfig\";\nimport SplashModule from \"./splash\";\n\ntype NavigationContainerProps = React.ComponentProps<\n typeof NavigationContainer\n>;\n\nfunction useLinkingConfig(): LinkingOptions<{}> {\n const routes = useRoutesContext();\n return useMemo(() => getLinkingConfig(routes), [routes]);\n}\n\nconst NavigationContainerContext = React.createContext<[Partial<NavigationContainerProps>, (props: Partial<NavigationContainerProps>) => void]>([{}, 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 const ContextNavigationContainer = React.forwardRef(\n (props: NavigationContainerProps, ref: NavigationContainerProps[\"ref\"]) => {\n const [state, setState] = React.useState<Partial<NavigationContainerProps>>({});\n\n const linking = useLinkingConfig();\n console.log('linking', linking);\n const onReady = useCallback(() => {\n props.onReady?.();\n SplashModule?.hideAsync();\n }, [props.onReady]);\n\n return (\n <NavigationContainerContext.Provider value={[\n {\n ...props,\n linking,\n onReady,\n ...state,\n },\n setState,\n ]}>\n <InternalContextNavigationContainer\n ref={ref}\n />\n </NavigationContainerContext.Provider>\n );\n }\n);\n\nconst InternalContextNavigationContainer = React.forwardRef(\n (props: {}, ref: NavigationContainerProps[\"ref\"]) => {\n const [contextProps] = useNavigationContainerContext();\n return (\n // @ts-expect-error: children are required\n <NavigationContainer\n ref={ref}\n {...props}\n {...contextProps}\n />\n );\n }\n);\n\nexport function RootContainer({ documentTitle, fallback, initialState, onStateChange, onUnhandledAction, theme }: Omit<NavigationContainerProps, 'independent' | 'onReady' | 'ref' | 'children' | 'linking'>) {\n const [, setProps] = useNavigationContainerContext();\n\n React.useEffect(() => {\n setProps({ documentTitle, fallback, initialState, onStateChange, onUnhandledAction, theme });\n }, [documentTitle, fallback, initialState, onStateChange, onUnhandledAction, theme]);\n\n return null;\n}"]}
@@ -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;AAYzE,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAqBpC,wBAAgB,kCAAkC,CAChD,KAAK,EAAE,SAAS,EAAE,EAClB,OAAO,GAAE,MAAM,EAAO,GACrB,aAAa,CAAC,EAAE,CAAC,CAwBnB;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,SAAS,EAAE,GAAG,cAAc,CAAC,EAAE,CAAC,CA0FxE"}
1
+ {"version":3,"file":"getLinkingConfig.d.ts","sourceRoot":"","sources":["../src/getLinkingConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AASzE,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AA4BpC,wBAAgB,kCAAkC,CAChD,KAAK,EAAE,SAAS,EAAE,EAClB,OAAO,GAAE,MAAM,EAAO,GACrB,aAAa,CAAC,EAAE,CAAC,CAwBnB;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,SAAS,EAAE,GAAG,cAAc,CAAC,EAAE,CAAC,CAuBxE"}
@@ -1,9 +1,6 @@
1
- import * as Linking from "expo-linking";
2
- import Constants, { ExecutionEnvironment } from "expo-constants";
3
1
  import { getAllWebRedirects } from "./aasa";
4
- import getPathFromState from "./fork/getPathFromState";
5
- import getStateFromPath from "./fork/getStateFromPath";
6
2
  import { matchDeepDynamicRouteName, matchDynamicName, matchFragmentName, } from "./matchers";
3
+ import { addEventListener, getInitialURL, rootURL, getPathFromState, getStateFromPath, } from "./linking";
7
4
  // `[page]` -> `:page`
8
5
  // `page` -> `page`
9
6
  function convertDynamicRouteToReactNavigation(name) {
@@ -41,7 +38,6 @@ export function treeToReactNavigationLinkingRoutes(nodes, parents = []) {
41
38
  return firstPass;
42
39
  }
43
40
  export function getLinkingConfig(routes) {
44
- const rootURL = Linking.createURL("/");
45
41
  return {
46
42
  prefixes: [
47
43
  /* your linking prefixes */
@@ -58,65 +54,8 @@ export function getLinkingConfig(routes) {
58
54
  // This helps keep the native functionality working like the web functionality.
59
55
  // For example, if you had a root navigator where the first screen was `/settings` and the second was `/index`
60
56
  // then `/index` would be used on web and `/settings` would be used on native.
61
- async getInitialURL() {
62
- const url = await Promise.race([
63
- (async () => {
64
- const url = await Linking.getInitialURL();
65
- // NOTE(EvanBacon): This could probably be wrapped with the development boundary
66
- // since Expo Go is mostly just used in development.
67
- // Expo Go is weird and requires the root path to be `/--/`
68
- if (url &&
69
- Constants.executionEnvironment === ExecutionEnvironment.StoreClient) {
70
- const parsed = Linking.parse(url);
71
- // If the URL is defined (default in Expo Go dev apps) and the URL has no path:
72
- // `exp://192.168.87.39:19000/` then use the default `exp://192.168.87.39:19000/--/`
73
- if (parsed.path === null || ["", "/"].includes(parsed.path)) {
74
- return rootURL;
75
- }
76
- }
77
- // The path will be nullish in bare apps when the app is launched from the home screen.
78
- // TODO(EvanBacon): define some policy around notifications.
79
- return url ?? rootURL;
80
- })(),
81
- new Promise((resolve) =>
82
- // Timeout in 150ms if `getInitialState` doesn't resolve
83
- // Workaround for https://github.com/facebook/react-native/issues/25675
84
- setTimeout(() => resolve(rootURL), 150)),
85
- ]);
86
- return url;
87
- },
88
- subscribe: (listener) => {
89
- let callback = undefined;
90
- if (Constants.executionEnvironment === ExecutionEnvironment.StoreClient) {
91
- // This extra work is only done in the Expo Go app.
92
- callback = ({ url }) => {
93
- const parsed = Linking.parse(url);
94
- // If the URL is defined (default in Expo Go dev apps) and the URL has no path:
95
- // `exp://192.168.87.39:19000/` then use the default `exp://192.168.87.39:19000/--/`
96
- if (parsed.path === null || ["", "/"].includes(parsed.path)) {
97
- listener(rootURL);
98
- }
99
- else {
100
- listener(url);
101
- }
102
- };
103
- }
104
- else {
105
- callback = ({ url }) => listener(url);
106
- }
107
- const subscription = Linking.addEventListener("url", callback);
108
- // Storing this in a local variable stops Jest from complaining about import after teardown
109
- const removeEventListener = Linking.removeEventListener?.bind(Linking);
110
- return () => {
111
- // https://github.com/facebook/react-native/commit/6d1aca806cee86ad76de771ed3a1cc62982ebcd7
112
- if (subscription?.remove) {
113
- subscription.remove();
114
- }
115
- else {
116
- removeEventListener?.("url", callback);
117
- }
118
- };
119
- },
57
+ getInitialURL: getInitialURL,
58
+ subscribe: addEventListener,
120
59
  getStateFromPath,
121
60
  getPathFromState,
122
61
  };
@@ -1 +1 @@
1
- {"version":3,"file":"getLinkingConfig.js","sourceRoot":"","sources":["../src/getLinkingConfig.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AAExC,OAAO,SAAS,EAAE,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAC;AAC5C,OAAO,gBAAgB,MAAM,yBAAyB,CAAC;AACvD,OAAO,gBAAgB,MAAM,yBAAyB,CAAC;AACvD,OAAO,EACL,yBAAyB,EACzB,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,YAAY,CAAC;AAGpB,sBAAsB;AACtB,mBAAmB;AACnB,SAAS,oCAAoC,CAAC,IAAY;IACxD,IAAI,yBAAyB,CAAC,IAAI,CAAC,EAAE;QACnC,OAAO,GAAG,CAAC;KACZ;IACD,MAAM,WAAW,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC;IAE3C,IAAI,WAAW,EAAE;QACf,OAAO,IAAI,WAAW,EAAE,CAAC;KAC1B;IAED,IAAI,IAAI,KAAK,OAAO,IAAI,iBAAiB,CAAC,IAAI,CAAC,EAAE;QAC/C,OAAO,EAAE,CAAC;KACX;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,UAAU,kCAAkC,CAChD,KAAkB,EAClB,UAAoB,EAAE;IAEtB,kEAAkE;IAClE,yFAAyF;IACzF,MAAM,SAAS,GAAG,KAAK;SACpB,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QACZ,MAAM,IAAI,GAAG,oCAAoC,CAAC,IAAI,CAAC,KAAK,CA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CAAC,CAAC;aACxD;YACD,MAAM,YAAY,GAAG,OAAO,CAAC,gBAAgB,CAAC,KAAK,EAAE,QAAQ,CAEhD,CAAC;YAEd,2FAA2F;YAC3F,MAAM,mBAAmB,GAAG,OAAO,CAAC,mBAAmB,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;YAEvE,OAAO,GAAG,EAAE;gBACV,2FAA2F;gBAC3F,IAAI,YAAY,EAAE,MAAM,EAAE;oBACxB,YAAY,CAAC,MAAM,EAAE,CAAC;iBACvB;qBAAM;oBACL,mBAAmB,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;iBACxC;YACH,CAAC,CAAC;QACJ,CAAC;QACD,gBAAgB;QAChB,gBAAgB;KACjB,CAAC;AACJ,CAAC","sourcesContent":["import { LinkingOptions, PathConfigMap } from \"@react-navigation/native\";\nimport * as Linking from \"expo-linking\";\n\nimport Constants, { ExecutionEnvironment } from \"expo-constants\";\nimport { getAllWebRedirects } from \"./aasa\";\nimport getPathFromState from \"./fork/getPathFromState\";\nimport getStateFromPath from \"./fork/getStateFromPath\";\nimport {\n matchDeepDynamicRouteName,\n matchDynamicName,\n matchFragmentName,\n} from \"./matchers\";\nimport { RouteNode } from \"./Route\";\n\n// `[page]` -> `:page`\n// `page` -> `page`\nfunction convertDynamicRouteToReactNavigation(name: string) {\n if (matchDeepDynamicRouteName(name)) {\n return \"*\";\n }\n const dynamicName = matchDynamicName(name);\n\n if (dynamicName) {\n return `:${dynamicName}`;\n }\n\n if (name === \"index\" || matchFragmentName(name)) {\n return \"\";\n }\n\n return name;\n}\n\nexport function treeToReactNavigationLinkingRoutes(\n nodes: RouteNode[],\n parents: string[] = []\n): PathConfigMap<{}> {\n // TODO: Intercept errors, strip invalid routes, and warn instead.\n // Our warnings can be more helpful than upstream since we know the associated file name.\n const firstPass = nodes\n .map((node) => {\n const path = convertDynamicRouteToReactNavigation(node.route);\n\n if (!node.children.length) {\n return [node.route, path];\n }\n\n const screens = treeToReactNavigationLinkingRoutes(node.children, [\n ...parents,\n path,\n ]);\n\n return [node.route, { path, screens }] as const;\n })\n .reduce<PathConfigMap<{}>>((acc, [route, current]) => {\n acc[route] = current;\n return acc;\n }, {});\n\n return firstPass;\n}\n\nexport function getLinkingConfig(routes: RouteNode[]): LinkingOptions<{}> {\n const rootURL = Linking.createURL(\"/\");\n\n return {\n prefixes: [\n /* your linking prefixes */\n rootURL,\n\n // This ensures that we can redirect correctly when the user comes from an associated domain\n // i.e. iOS Safari banner.\n ...getAllWebRedirects(),\n ],\n config: {\n screens: treeToReactNavigationLinkingRoutes(routes),\n },\n // A custom getInitialURL is used on native to ensure the app always starts at\n // the root path if it's launched from something other than a deep link.\n // This helps keep the native functionality working like the web functionality.\n // For example, if you had a root navigator where the first screen was `/settings` and the second was `/index`\n // then `/index` would be used on web and `/settings` would be used on native.\n async getInitialURL(): Promise<string> {\n const url = await Promise.race<string>([\n (async () => {\n const url = await Linking.getInitialURL();\n\n // NOTE(EvanBacon): This could probably be wrapped with the development boundary\n // since Expo Go is mostly just used in development.\n\n // Expo Go is weird and requires the root path to be `/--/`\n if (\n url &&\n Constants.executionEnvironment === ExecutionEnvironment.StoreClient\n ) {\n const parsed = Linking.parse(url);\n // If the URL is defined (default in Expo Go dev apps) and the URL has no path:\n // `exp://192.168.87.39:19000/` then use the default `exp://192.168.87.39:19000/--/`\n if (parsed.path === null || [\"\", \"/\"].includes(parsed.path)) {\n return rootURL;\n }\n }\n // The path will be nullish in bare apps when the app is launched from the home screen.\n // TODO(EvanBacon): define some policy around notifications.\n return url ?? rootURL;\n })(),\n new Promise<string>((resolve) =>\n // Timeout in 150ms if `getInitialState` doesn't resolve\n // Workaround for https://github.com/facebook/react-native/issues/25675\n setTimeout(() => resolve(rootURL), 150)\n ),\n ]);\n return url;\n },\n subscribe: (listener) => {\n let callback: (({ url }: { url: string }) => void) | undefined =\n undefined;\n\n if (Constants.executionEnvironment === ExecutionEnvironment.StoreClient) {\n // This extra work is only done in the Expo Go app.\n callback = ({ url }: { url: string }) => {\n const parsed = Linking.parse(url);\n // If the URL is defined (default in Expo Go dev apps) and the URL has no path:\n // `exp://192.168.87.39:19000/` then use the default `exp://192.168.87.39:19000/--/`\n if (parsed.path === null || [\"\", \"/\"].includes(parsed.path)) {\n listener(rootURL);\n } else {\n listener(url);\n }\n };\n } else {\n callback = ({ url }: { url: string }) => listener(url);\n }\n const subscription = Linking.addEventListener(\"url\", callback) as\n | { remove(): void }\n | undefined;\n\n // Storing this in a local variable stops Jest from complaining about import after teardown\n const removeEventListener = Linking.removeEventListener?.bind(Linking);\n\n return () => {\n // https://github.com/facebook/react-native/commit/6d1aca806cee86ad76de771ed3a1cc62982ebcd7\n if (subscription?.remove) {\n subscription.remove();\n } else {\n removeEventListener?.(\"url\", callback);\n }\n };\n },\n getStateFromPath,\n getPathFromState,\n };\n}\n"]}
1
+ {"version":3,"file":"getLinkingConfig.js","sourceRoot":"","sources":["../src/getLinkingConfig.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAC;AAE5C,OAAO,EACL,yBAAyB,EACzB,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,gBAAgB,EAChB,aAAa,EACb,OAAO,EACP,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,WAAW,CAAC;AAEnB,sBAAsB;AACtB,mBAAmB;AACnB,SAAS,oCAAoC,CAAC,IAAY;IACxD,IAAI,yBAAyB,CAAC,IAAI,CAAC,EAAE;QACnC,OAAO,GAAG,CAAC;KACZ;IACD,MAAM,WAAW,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC;IAE3C,IAAI,WAAW,EAAE;QACf,OAAO,IAAI,WAAW,EAAE,CAAC;KAC1B;IAED,IAAI,IAAI,KAAK,OAAO,IAAI,iBAAiB,CAAC,IAAI,CAAC,EAAE;QAC/C,OAAO,EAAE,CAAC;KACX;IAED,OAAO,IAAI,CAAC;AACd,CAAC;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/native\";\n\nimport { getAllWebRedirects } from \"./aasa\";\n\nimport {\n matchDeepDynamicRouteName,\n matchDynamicName,\n matchFragmentName,\n} from \"./matchers\";\nimport { RouteNode } from \"./Route\";\nimport {\n addEventListener,\n getInitialURL,\n rootURL,\n getPathFromState,\n getStateFromPath,\n} from \"./linking\";\n\n// `[page]` -> `:page`\n// `page` -> `page`\nfunction convertDynamicRouteToReactNavigation(name: string) {\n if (matchDeepDynamicRouteName(name)) {\n return \"*\";\n }\n const dynamicName = matchDynamicName(name);\n\n if (dynamicName) {\n return `:${dynamicName}`;\n }\n\n if (name === \"index\" || matchFragmentName(name)) {\n return \"\";\n }\n\n return name;\n}\n\nexport function treeToReactNavigationLinkingRoutes(\n nodes: RouteNode[],\n parents: string[] = []\n): PathConfigMap<{}> {\n // TODO: Intercept errors, strip invalid routes, and warn instead.\n // Our warnings can be more helpful than upstream since we know the associated file name.\n const firstPass = nodes\n .map((node) => {\n const path = convertDynamicRouteToReactNavigation(node.route);\n\n if (!node.children.length) {\n return [node.route, path];\n }\n\n const screens = treeToReactNavigationLinkingRoutes(node.children, [\n ...parents,\n path,\n ]);\n\n return [node.route, { path, screens }] as const;\n })\n .reduce<PathConfigMap<{}>>((acc, [route, current]) => {\n acc[route] = current;\n return acc;\n }, {});\n\n return firstPass;\n}\n\nexport function getLinkingConfig(routes: RouteNode[]): LinkingOptions<{}> {\n return {\n prefixes: [\n /* your linking prefixes */\n rootURL,\n\n // This ensures that we can redirect correctly when the user comes from an associated domain\n // i.e. iOS Safari banner.\n ...getAllWebRedirects(),\n ],\n config: {\n screens: treeToReactNavigationLinkingRoutes(routes),\n },\n // A custom getInitialURL is used on native to ensure the app always starts at\n // the root path if it's launched from something other than a deep link.\n // This helps keep the native functionality working like the web functionality.\n // For example, if you had a root navigator where the first screen was `/settings` and the second was `/index`\n // then `/index` would be used on web and `/settings` would be used on native.\n getInitialURL: getInitialURL,\n subscribe: addEventListener,\n getStateFromPath,\n getPathFromState,\n };\n}\n"]}
package/build/index.d.ts CHANGED
@@ -12,4 +12,5 @@ export { ErrorBoundary } from "./views/ErrorBoundary";
12
12
  export { Layout, Children } from "./views/Layout";
13
13
  export { Link } from "./views/Link";
14
14
  export { RootContainer, useNavigationContainerContext } from "./ContextNavigationContainer";
15
+ export * as Linking from './linking';
15
16
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEjD,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,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,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,6BAA6B,EAAE,MAAM,8BAA8B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEjD,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,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,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,6BAA6B,EAAE,MAAM,8BAA8B,CAAC;AAE5F,OAAO,KAAK,OAAO,MAAM,WAAW,CAAA"}
package/build/index.js CHANGED
@@ -11,4 +11,6 @@ export { ErrorBoundary } from "./views/ErrorBoundary";
11
11
  export { Layout, Children } from "./views/Layout";
12
12
  export { Link } from "./views/Link";
13
13
  export { RootContainer, useNavigationContainerContext } from "./ContextNavigationContainer";
14
+ import * as Linking_1 from './linking';
15
+ export { Linking_1 as Linking };
14
16
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAI1C,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,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,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,6BAA6B,EAAE,MAAM,8BAA8B,CAAC","sourcesContent":["export { useRoutes } from \"./Route\";\nexport { useScreens } from \"./useScreens\";\n\nexport { ErrorBoundaryProps } from \"./views/Try\";\n\nexport { Stack } from \"./layouts/Stack\";\nexport { NativeStack } from \"./layouts/NativeStack\";\nexport { Tabs } from \"./layouts/Tabs\";\nexport { Drawer } from \"./layouts/Drawer\";\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 } from \"./views/Link\";\nexport { RootContainer, useNavigationContainerContext } from \"./ContextNavigationContainer\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAI1C,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,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,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,6BAA6B,EAAE,MAAM,8BAA8B,CAAC;2BAEnE,WAAW;sBAAxB,OAAO","sourcesContent":["export { useRoutes } from \"./Route\";\nexport { useScreens } from \"./useScreens\";\n\nexport { ErrorBoundaryProps } from \"./views/Try\";\n\nexport { Stack } from \"./layouts/Stack\";\nexport { NativeStack } from \"./layouts/NativeStack\";\nexport { Tabs } from \"./layouts/Tabs\";\nexport { Drawer } from \"./layouts/Drawer\";\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 } from \"./views/Link\";\nexport { RootContainer, useNavigationContainerContext } from \"./ContextNavigationContainer\";\n\nexport * as Linking from './linking'"]}
@@ -0,0 +1,13 @@
1
+ import getPathFromState from "./fork/getPathFromState";
2
+ import getStateFromPath from "./fork/getStateFromPath";
3
+ /**
4
+ * Get the client-side URL. On web this is always the current URL, on native this may differ from the native Linking state.
5
+ *
6
+ * You can use `Linking.createURL(useClientURL())` to get the absolute URL.
7
+ */
8
+ export declare function useClientURL(): string;
9
+ export declare function getInitialURL(): Promise<string>;
10
+ export declare const rootURL: string;
11
+ export declare function addEventListener(listener: (url: string) => void): () => void;
12
+ export { getStateFromPath, getPathFromState };
13
+ //# sourceMappingURL=linking.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"linking.d.ts","sourceRoot":"","sources":["../src/linking.ts"],"names":[],"mappings":"AAIA,OAAO,gBAAgB,MAAM,yBAAyB,CAAC;AACvD,OAAO,gBAAgB,MAAM,yBAAyB,CAAC;AAGvD;;;;GAIG;AACH,wBAAgB,YAAY,WAU3B;AAOD,wBAAsB,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC,CA+BrD;AAED,eAAO,MAAM,OAAO,QAAyB,CAAC;AAE9C,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,cAiC/D;AAED,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,CAAC"}
@@ -0,0 +1,88 @@
1
+ import Constants, { ExecutionEnvironment } from "expo-constants";
2
+ import * as Linking from "expo-linking";
3
+ import { Platform } from "react-native";
4
+ import getPathFromState from "./fork/getPathFromState";
5
+ import getStateFromPath from "./fork/getStateFromPath";
6
+ import { useOptionalNavigation } from "./useOptionalNavigation";
7
+ /**
8
+ * Get the client-side URL. On web this is always the current URL, on native this may differ from the native Linking state.
9
+ *
10
+ * You can use `Linking.createURL(useClientURL())` to get the absolute URL.
11
+ */
12
+ export function useClientURL() {
13
+ if (Platform.OS === "web") {
14
+ return Linking.useURL() ?? window.location.href;
15
+ }
16
+ const navigation = useOptionalNavigation();
17
+ if (navigation) {
18
+ return getPathFromState(navigation.getState());
19
+ }
20
+ return "/";
21
+ }
22
+ // A custom getInitialURL is used on native to ensure the app always starts at
23
+ // the root path if it's launched from something other than a deep link.
24
+ // This helps keep the native functionality working like the web functionality.
25
+ // For example, if you had a root navigator where the first screen was `/settings` and the second was `/index`
26
+ // then `/index` would be used on web and `/settings` would be used on native.
27
+ export async function getInitialURL() {
28
+ const url = await Promise.race([
29
+ (async () => {
30
+ const url = await Linking.getInitialURL();
31
+ // NOTE(EvanBacon): This could probably be wrapped with the development boundary
32
+ // since Expo Go is mostly just used in development.
33
+ // Expo Go is weird and requires the root path to be `/--/`
34
+ if (url &&
35
+ Constants.executionEnvironment === ExecutionEnvironment.StoreClient) {
36
+ const parsed = Linking.parse(url);
37
+ // If the URL is defined (default in Expo Go dev apps) and the URL has no path:
38
+ // `exp://192.168.87.39:19000/` then use the default `exp://192.168.87.39:19000/--/`
39
+ if (parsed.path === null || ["", "/"].includes(parsed.path)) {
40
+ return rootURL;
41
+ }
42
+ }
43
+ // The path will be nullish in bare apps when the app is launched from the home screen.
44
+ // TODO(EvanBacon): define some policy around notifications.
45
+ return url ?? rootURL;
46
+ })(),
47
+ new Promise((resolve) =>
48
+ // Timeout in 150ms if `getInitialState` doesn't resolve
49
+ // Workaround for https://github.com/facebook/react-native/issues/25675
50
+ setTimeout(() => resolve(rootURL), 150)),
51
+ ]);
52
+ return url;
53
+ }
54
+ export const rootURL = Linking.createURL("/");
55
+ export function addEventListener(listener) {
56
+ let callback = undefined;
57
+ if (Constants.executionEnvironment === ExecutionEnvironment.StoreClient) {
58
+ // This extra work is only done in the Expo Go app.
59
+ callback = ({ url }) => {
60
+ const parsed = Linking.parse(url);
61
+ // If the URL is defined (default in Expo Go dev apps) and the URL has no path:
62
+ // `exp://192.168.87.39:19000/` then use the default `exp://192.168.87.39:19000/--/`
63
+ if (parsed.path === null || ["", "/"].includes(parsed.path)) {
64
+ listener(rootURL);
65
+ }
66
+ else {
67
+ listener(url);
68
+ }
69
+ };
70
+ }
71
+ else {
72
+ callback = ({ url }) => listener(url);
73
+ }
74
+ const subscription = Linking.addEventListener("url", callback);
75
+ // Storing this in a local variable stops Jest from complaining about import after teardown
76
+ const removeEventListener = Linking.removeEventListener?.bind(Linking);
77
+ return () => {
78
+ // https://github.com/facebook/react-native/commit/6d1aca806cee86ad76de771ed3a1cc62982ebcd7
79
+ if (subscription?.remove) {
80
+ subscription.remove();
81
+ }
82
+ else {
83
+ removeEventListener?.("url", callback);
84
+ }
85
+ };
86
+ }
87
+ export { getStateFromPath, getPathFromState };
88
+ //# sourceMappingURL=linking.js.map
@@ -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Q,CAEhD,CAAC;IAEd,2FAA2F;IAC3F,MAAM,mBAAmB,GAAG,OAAO,CAAC,mBAAmB,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IAEvE,OAAO,GAAG,EAAE;QACV,2FAA2F;QAC3F,IAAI,YAAY,EAAE,MAAM,EAAE;YACxB,YAAY,CAAC,MAAM,EAAE,CAAC;SACvB;aAAM;YACL,mBAAmB,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;SACxC;IACH,CAAC,CAAC;AACJ,CAAC;AAED,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,CAAC","sourcesContent":["import Constants, { ExecutionEnvironment } from \"expo-constants\";\nimport * as Linking from \"expo-linking\";\nimport { Platform } from \"react-native\";\n\nimport getPathFromState from \"./fork/getPathFromState\";\nimport getStateFromPath from \"./fork/getStateFromPath\";\nimport { useOptionalNavigation } from \"./useOptionalNavigation\";\n\n/**\n * Get the client-side URL. On web this is always the current URL, on native this may differ from the native Linking state.\n *\n * You can use `Linking.createURL(useClientURL())` to get the absolute URL.\n */\nexport function useClientURL() {\n if (Platform.OS === \"web\") {\n return Linking.useURL() ?? window.location.href;\n }\n const navigation = useOptionalNavigation();\n\n if (navigation) {\n return getPathFromState(navigation.getState());\n }\n return \"/\";\n}\n\n// A custom getInitialURL is used on native to ensure the app always starts at\n// the root path if it's launched from something other than a deep link.\n// This helps keep the native functionality working like the web functionality.\n// For example, if you had a root navigator where the first screen was `/settings` and the second was `/index`\n// then `/index` would be used on web and `/settings` would be used on native.\nexport async function getInitialURL(): Promise<string> {\n const url = await Promise.race<string>([\n (async () => {\n const url = await Linking.getInitialURL();\n\n // NOTE(EvanBacon): This could probably be wrapped with the development boundary\n // since Expo Go is mostly just used in development.\n\n // Expo Go is weird and requires the root path to be `/--/`\n if (\n url &&\n Constants.executionEnvironment === ExecutionEnvironment.StoreClient\n ) {\n const parsed = Linking.parse(url);\n // If the URL is defined (default in Expo Go dev apps) and the URL has no path:\n // `exp://192.168.87.39:19000/` then use the default `exp://192.168.87.39:19000/--/`\n if (parsed.path === null || [\"\", \"/\"].includes(parsed.path)) {\n return rootURL;\n }\n }\n // The path will be nullish in bare apps when the app is launched from the home screen.\n // TODO(EvanBacon): define some policy around notifications.\n return url ?? rootURL;\n })(),\n new Promise<string>((resolve) =>\n // Timeout in 150ms if `getInitialState` doesn't resolve\n // Workaround for https://github.com/facebook/react-native/issues/25675\n setTimeout(() => resolve(rootURL), 150)\n ),\n ]);\n return url;\n}\n\nexport const rootURL = Linking.createURL(\"/\");\n\nexport function addEventListener(listener: (url: string) => void) {\n let callback: (({ url }: { url: string }) => void) | undefined = undefined;\n\n if (Constants.executionEnvironment === ExecutionEnvironment.StoreClient) {\n // This extra work is only done in the Expo Go app.\n callback = ({ url }: { url: string }) => {\n const parsed = Linking.parse(url);\n // If the URL is defined (default in Expo Go dev apps) and the URL has no path:\n // `exp://192.168.87.39:19000/` then use the default `exp://192.168.87.39:19000/--/`\n if (parsed.path === null || [\"\", \"/\"].includes(parsed.path)) {\n listener(rootURL);\n } else {\n listener(url);\n }\n };\n } else {\n callback = ({ url }: { url: string }) => listener(url);\n }\n const subscription = Linking.addEventListener(\"url\", callback) as\n | { remove(): void }\n | undefined;\n\n // Storing this in a local variable stops Jest from complaining about import after teardown\n const removeEventListener = Linking.removeEventListener?.bind(Linking);\n\n return () => {\n // https://github.com/facebook/react-native/commit/6d1aca806cee86ad76de771ed3a1cc62982ebcd7\n if (subscription?.remove) {\n subscription.remove();\n } else {\n removeEventListener?.(\"url\", callback);\n }\n };\n}\n\nexport { getStateFromPath, getPathFromState };\n"]}
@@ -0,0 +1,3 @@
1
+ declare let SplashModule: typeof import("expo-splash-screen") | null;
2
+ export default SplashModule;
3
+ //# sourceMappingURL=splash.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"splash.d.ts","sourceRoot":"","sources":["../src/splash.ts"],"names":[],"mappings":"AAEA,QAAA,IAAI,YAAY,EAAE,cAAc,oBAAoB,CAAC,GAAG,IAAW,CAAC;AAUpE,eAAe,YAAY,CAAC"}
@@ -0,0 +1,12 @@
1
+ import Constants, { ExecutionEnvironment } from "expo-constants";
2
+ let SplashModule = null;
3
+ try {
4
+ if (Constants.executionEnvironment !== ExecutionEnvironment.StoreClient) {
5
+ SplashModule = require("expo-splash-screen");
6
+ }
7
+ }
8
+ catch (e) {
9
+ // Ignore
10
+ }
11
+ export default SplashModule;
12
+ //# sourceMappingURL=splash.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"splash.js","sourceRoot":"","sources":["../src/splash.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,EAAE,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAEjE,IAAI,YAAY,GAA+C,IAAI,CAAC;AAEpE,IAAI;IACF,IAAI,SAAS,CAAC,oBAAoB,KAAK,oBAAoB,CAAC,WAAW,EAAE;QACvE,YAAY,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;KAC9C;CACF;AAAC,OAAO,CAAC,EAAE;IACV,SAAS;CACV;AAED,eAAe,YAAY,CAAC","sourcesContent":["import Constants, { ExecutionEnvironment } from \"expo-constants\";\n\nlet SplashModule: typeof import(\"expo-splash-screen\") | null = null;\n\ntry {\n if (Constants.executionEnvironment !== ExecutionEnvironment.StoreClient) {\n SplashModule = require(\"expo-splash-screen\");\n }\n} catch (e) {\n // Ignore\n}\n\nexport default SplashModule;\n"]}
@@ -0,0 +1,8 @@
1
+ import { NavigationProp } from "@react-navigation/native";
2
+ /**
3
+ * Hook to access the navigation prop of the parent screen anywhere.
4
+ *
5
+ * @returns Navigation prop of the parent screen.
6
+ */
7
+ export declare function useOptionalNavigation<T = NavigationProp<ReactNavigation.RootParamList>>(): T | null;
8
+ //# sourceMappingURL=useOptionalNavigation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useOptionalNavigation.d.ts","sourceRoot":"","sources":["../src/useOptionalNavigation.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,cAAc,EACf,MAAM,0BAA0B,CAAC;AAGlC;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,CAAC,GAAG,cAAc,CAAC,eAAe,CAAC,aAAa,CAAC,KAC9C,CAAC,GAAG,IAAI,CAMZ"}
@@ -0,0 +1,14 @@
1
+ import { NavigationContainerRefContext, NavigationContext, } from "@react-navigation/native";
2
+ import * as React from "react";
3
+ /**
4
+ * Hook to access the navigation prop of the parent screen anywhere.
5
+ *
6
+ * @returns Navigation prop of the parent screen.
7
+ */
8
+ export function useOptionalNavigation() {
9
+ const root = React.useContext(NavigationContainerRefContext);
10
+ const navigation = React.useContext(NavigationContext);
11
+ // FIXME: Figure out a better way to do this
12
+ return (navigation ?? root ?? null);
13
+ }
14
+ //# sourceMappingURL=useOptionalNavigation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useOptionalNavigation.js","sourceRoot":"","sources":["../src/useOptionalNavigation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,6BAA6B,EAC7B,iBAAiB,GAElB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B;;;;GAIG;AACH,MAAM,UAAU,qBAAqB;IAGnC,MAAM,IAAI,GAAG,KAAK,CAAC,UAAU,CAAC,6BAA6B,CAAC,CAAC;IAC7D,MAAM,UAAU,GAAG,KAAK,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAAC;IAEvD,4CAA4C;IAC5C,OAAO,CAAC,UAAU,IAAI,IAAI,IAAI,IAAI,CAAwB,CAAC;AAC7D,CAAC","sourcesContent":["import {\n NavigationContainerRefContext,\n NavigationContext,\n NavigationProp,\n} from \"@react-navigation/native\";\nimport * as React from \"react\";\n\n/**\n * Hook to access the navigation prop of the parent screen anywhere.\n *\n * @returns Navigation prop of the parent screen.\n */\nexport function useOptionalNavigation<\n T = NavigationProp<ReactNavigation.RootParamList>\n>(): T | null {\n const root = React.useContext(NavigationContainerRefContext);\n const navigation = React.useContext(NavigationContext);\n\n // FIXME: Figure out a better way to do this\n return (navigation ?? root ?? null) as unknown as T | null;\n}\n"]}
@@ -26,7 +26,6 @@ function BaseLink({ to, href, action, asChild, ...rest }, ref) {
26
26
  return resolved;
27
27
  }, [href, to]);
28
28
  const props = useLinkProps({ to: resolvedTo, action });
29
- console.log('link props', resolvedTo, action, props);
30
29
  const onPress = (e) => {
31
30
  if ('onPress' in rest) {
32
31
  rest.onPress?.(e);
@@ -1 +1 @@
1
- {"version":3,"file":"Link.js","sourceRoot":"","sources":["../../src/views/Link.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAyB,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAE,IAAI,EAAa,MAAM,qBAAqB,CAAA;AACrD,OAAO,EAAE,YAAY,GAAG,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AAc3C;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,KAAK,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;AAE/C,SAAS,QAAQ,CAAkD,EAC/D,EAAE,EACF,IAAI,EACJ,MAAM,EACN,OAAO,EACP,GAAG,IAAI,EACQ,EAAE,GAA6B;IAC9C,6CAA6C;IAC7C,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE;QAClC,MAAM,QAAQ,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;QAClC,IAAI,QAAQ,IAAI,IAAI,EAAE;YAClB,MAAM,IAAI,KAAK,CACX,4DAA4D,CAC/D,CAAC;SACL;QACD,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;YAC3D,yCAAyC;YACzC,OAAO,GAAG,CAAA;SACb;QACD,OAAO,QAAQ,CAAC;IACpB,CAAC,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC;IACf,MAAM,KAAK,GAAG,YAAY,CAAY,EAAE,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC,CAAC;IAElE,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;IACrD,MAAM,OAAO,GAAG,CACZ,CAA0E,EAC5E,EAAE;QACA,IAAI,SAAS,IAAI,IAAI,EAAE;YACnB,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC;SACrB;QAED,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IACrB,CAAC,CAAC;IAEF,OAAO,KAAK,CAAC,aAAa;IACtB,0CAA0C;IAC1C,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EACrB;QACI,GAAG;QACH,GAAG,KAAK;QACR,GAAG,IAAI;QACP,GAAG,QAAQ,CAAC,MAAM,CAAC;YACf,GAAG,EAAE,EAAE,OAAO,EAAE,OAAO,EAAS;YAChC,OAAO,EAAE,EAAE,OAAO,EAAE;SACvB,CAAC;KACL,CAAC,CAAC;AACX,CAAC","sourcesContent":["// Fork of @react-navigation/native Link.tsx\nimport type { NavigationAction } from '@react-navigation/core';\nimport * as React from 'react';\nimport { GestureResponderEvent, Platform } from 'react-native';\nimport { Text, TextProps } from '@bacons/react-views'\nimport { useLinkProps, } from '@react-navigation/native';\nimport { Slot } from '@radix-ui/react-slot'\nimport type { To } from '@react-navigation/native/src/useLinkTo';\n\ntype Props<ParamList extends ReactNavigation.RootParamList> = {\n asChild?: boolean;\n href?: string;\n to?: To<ParamList>;\n action?: NavigationAction;\n target?: string;\n onPress?: (\n e: React.MouseEvent<HTMLAnchorElement, MouseEvent> | GestureResponderEvent\n ) => void;\n} & (TextProps & { children: React.ReactNode });\n\n/**\n * Component to render link to another screen using a path.\n * Uses an anchor tag on the web.\n *\n * @param props.href Absolute path to screen (e.g. `/feeds/hot`).\n * @param props.action Optional action to use for in-page navigation. By default, the path is parsed to an action based on linking config.\n * @param props.children Child elements to render the content.\n */\nexport const Link = React.forwardRef(BaseLink);\n\nfunction BaseLink<ParamList extends ReactNavigation.RootParamList>({\n to,\n href,\n action,\n asChild,\n ...rest\n}: Props<ParamList>, ref: React.ForwardedRef<Text>) {\n // TODO: Auto use router's client-side event.\n const resolvedTo = React.useMemo(() => {\n const resolved = href ? href : to;\n if (resolved == null) {\n throw new Error(\n `You must specify either 'href' or 'to' prop in a <Link />.`\n );\n }\n if (typeof resolved === 'string' && !resolved.startsWith('/')) {\n // TODO: Auto delegate out external links\n return '/'\n }\n return resolved;\n }, [href, to]);\n const props = useLinkProps<ParamList>({ to: resolvedTo, action });\n\n console.log('link props', resolvedTo, action, props);\n const onPress = (\n e: React.MouseEvent<HTMLAnchorElement, MouseEvent> | GestureResponderEvent\n ) => {\n if ('onPress' in rest) {\n rest.onPress?.(e);\n }\n\n props.onPress(e);\n };\n\n return React.createElement(\n // @ts-expect-error: slot is not type-safe\n asChild ? Slot : Text,\n {\n ref,\n ...props,\n ...rest,\n ...Platform.select({\n web: { onClick: onPress } as any,\n default: { onPress },\n }),\n });\n}\n"]}
1
+ {"version":3,"file":"Link.js","sourceRoot":"","sources":["../../src/views/Link.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAyB,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAE,IAAI,EAAa,MAAM,qBAAqB,CAAA;AACrD,OAAO,EAAE,YAAY,GAAG,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AAc3C;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,KAAK,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;AAE/C,SAAS,QAAQ,CAAkD,EAC/D,EAAE,EACF,IAAI,EACJ,MAAM,EACN,OAAO,EACP,GAAG,IAAI,EACQ,EAAE,GAA6B;IAC9C,6CAA6C;IAC7C,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE;QAClC,MAAM,QAAQ,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;QAClC,IAAI,QAAQ,IAAI,IAAI,EAAE;YAClB,MAAM,IAAI,KAAK,CACX,4DAA4D,CAC/D,CAAC;SACL;QACD,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;YAC3D,yCAAyC;YACzC,OAAO,GAAG,CAAA;SACb;QACD,OAAO,QAAQ,CAAC;IACpB,CAAC,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC;IACf,MAAM,KAAK,GAAG,YAAY,CAAY,EAAE,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC,CAAC;IAElE,MAAM,OAAO,GAAG,CACZ,CAA0E,EAC5E,EAAE;QACA,IAAI,SAAS,IAAI,IAAI,EAAE;YACnB,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC;SACrB;QAED,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IACrB,CAAC,CAAC;IAEF,OAAO,KAAK,CAAC,aAAa;IACtB,0CAA0C;IAC1C,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EACrB;QACI,GAAG;QACH,GAAG,KAAK;QACR,GAAG,IAAI;QACP,GAAG,QAAQ,CAAC,MAAM,CAAC;YACf,GAAG,EAAE,EAAE,OAAO,EAAE,OAAO,EAAS;YAChC,OAAO,EAAE,EAAE,OAAO,EAAE;SACvB,CAAC;KACL,CAAC,CAAC;AACX,CAAC","sourcesContent":["// Fork of @react-navigation/native Link.tsx\nimport type { NavigationAction } from '@react-navigation/core';\nimport * as React from 'react';\nimport { GestureResponderEvent, Platform } from 'react-native';\nimport { Text, TextProps } from '@bacons/react-views'\nimport { useLinkProps, } from '@react-navigation/native';\nimport { Slot } from '@radix-ui/react-slot'\nimport type { To } from '@react-navigation/native/src/useLinkTo';\n\ntype Props<ParamList extends ReactNavigation.RootParamList> = {\n asChild?: boolean;\n href?: string;\n to?: To<ParamList>;\n action?: NavigationAction;\n target?: string;\n onPress?: (\n e: React.MouseEvent<HTMLAnchorElement, MouseEvent> | GestureResponderEvent\n ) => void;\n} & (TextProps & { children: React.ReactNode });\n\n/**\n * Component to render link to another screen using a path.\n * Uses an anchor tag on the web.\n *\n * @param props.href Absolute path to screen (e.g. `/feeds/hot`).\n * @param props.action Optional action to use for in-page navigation. By default, the path is parsed to an action based on linking config.\n * @param props.children Child elements to render the content.\n */\nexport const Link = React.forwardRef(BaseLink);\n\nfunction BaseLink<ParamList extends ReactNavigation.RootParamList>({\n to,\n href,\n action,\n asChild,\n ...rest\n}: Props<ParamList>, ref: React.ForwardedRef<Text>) {\n // TODO: Auto use router's client-side event.\n const resolvedTo = React.useMemo(() => {\n const resolved = href ? href : to;\n if (resolved == null) {\n throw new Error(\n `You must specify either 'href' or 'to' prop in a <Link />.`\n );\n }\n if (typeof resolved === 'string' && !resolved.startsWith('/')) {\n // TODO: Auto delegate out external links\n return '/'\n }\n return resolved;\n }, [href, to]);\n const props = useLinkProps<ParamList>({ to: resolvedTo, action });\n\n const onPress = (\n e: React.MouseEvent<HTMLAnchorElement, MouseEvent> | GestureResponderEvent\n ) => {\n if ('onPress' in rest) {\n rest.onPress?.(e);\n }\n\n props.onPress(e);\n };\n\n return React.createElement(\n // @ts-expect-error: slot is not type-safe\n asChild ? Slot : Text,\n {\n ref,\n ...props,\n ...rest,\n ...Platform.select({\n web: { onClick: onPress } as any,\n default: { onPress },\n }),\n });\n}\n"]}
package/entry.js CHANGED
@@ -1,7 +1,8 @@
1
1
  import { registerRootComponent } from "expo";
2
2
  import { ExpoRoot } from "expo-router";
3
3
  import { View, Platform } from "react-native";
4
- import Constants, { ExecutionEnvironment } from "expo-constants";
4
+
5
+ import SplashModule from "expo-router/build/splash";
5
6
 
6
7
  // Must be exported or Fast Refresh won't update the context >:[
7
8
  export function App() {
@@ -53,30 +54,18 @@ function convertError(error) {
53
54
  return new Error(String(error));
54
55
  }
55
56
 
56
- function preventAutoHide() {
57
- // Not applicable to Expo Go.
58
- if (Constants.executionEnvironment !== ExecutionEnvironment.StoreClient) {
59
- try {
60
- // Automatically handle hiding the splash screen if expo-splash-screen is installed.
61
- return require("expo-splash-screen").preventAutoHideAsync();
62
- } catch {}
63
- }
64
- }
65
-
66
- function hideSplash() {
67
- try {
68
- return require("expo-splash-screen").hideAsync();
69
- } catch {}
70
- }
71
-
72
57
  (() => {
73
58
  try {
74
- preventAutoHide();
59
+ if (SplashModule) {
60
+ SplashModule.preventAutoHideAsync();
61
+ }
75
62
 
76
63
  registerRootComponent(App);
77
64
  } catch (e) {
78
65
  // Hide the splash screen if there was an error so the user can see it.
79
- hideSplash();
66
+ if (SplashModule) {
67
+ SplashModule.hideAsync();
68
+ }
80
69
 
81
70
  const error = convertError(e);
82
71
  // Prevent the app from throwing confusing:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-router",
3
- "version": "0.0.8",
3
+ "version": "0.0.10",
4
4
  "main": "build/index.js",
5
5
  "files": [
6
6
  "entry.js",