expo-router 0.0.10 → 0.0.13
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.
- package/build/ContextNavigationContainer.d.ts +10 -10
- package/build/ContextNavigationContainer.d.ts.map +1 -1
- package/build/ContextNavigationContainer.js +34 -20
- package/build/ContextNavigationContainer.js.map +1 -1
- package/build/getLinkingConfig.d.ts +1 -0
- package/build/getLinkingConfig.d.ts.map +1 -1
- package/build/getLinkingConfig.js +8 -2
- package/build/getLinkingConfig.js.map +1 -1
- package/build/index.d.ts +1 -0
- package/build/index.d.ts.map +1 -1
- package/build/index.js +1 -0
- package/build/index.js.map +1 -1
- package/build/linking.d.ts +1 -7
- package/build/linking.d.ts.map +1 -1
- package/build/linking.js +11 -22
- package/build/linking.js.map +1 -1
- package/build/useCurrentRoute.d.ts +10 -0
- package/build/useCurrentRoute.d.ts.map +1 -0
- package/build/useCurrentRoute.js +13 -0
- package/build/useCurrentRoute.js.map +1 -0
- package/package.json +3 -2
- package/build/useOptionalNavigation.d.ts +0 -8
- package/build/useOptionalNavigation.d.ts.map +0 -1
- package/build/useOptionalNavigation.js +0 -14
- package/build/useOptionalNavigation.js.map +0 -1
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import React from
|
|
1
|
+
import { NavigationContainer, NavigationContainerRef } from '@react-navigation/native';
|
|
2
|
+
import React from 'react';
|
|
3
3
|
declare type NavigationContainerProps = React.ComponentProps<typeof NavigationContainer>;
|
|
4
4
|
export declare function useNavigationContainerContext(): [Partial<import("@react-navigation/native").NavigationContainerProps & {
|
|
5
5
|
theme?: import("@react-navigation/native").Theme | undefined;
|
|
6
|
-
linking?: LinkingOptions<{}> | undefined;
|
|
6
|
+
linking?: import("@react-navigation/native").LinkingOptions<{}> | undefined;
|
|
7
7
|
fallback?: React.ReactNode;
|
|
8
8
|
documentTitle?: import("@react-navigation/native").DocumentTitleOptions | undefined;
|
|
9
9
|
onReady?: (() => void) | undefined;
|
|
10
10
|
} & {
|
|
11
|
-
ref?: React.Ref<
|
|
11
|
+
ref?: React.Ref<NavigationContainerRef<{}>> | undefined;
|
|
12
12
|
}>, (props: Partial<import("@react-navigation/native").NavigationContainerProps & {
|
|
13
13
|
theme?: import("@react-navigation/native").Theme | undefined;
|
|
14
|
-
linking?: LinkingOptions<{}> | undefined;
|
|
14
|
+
linking?: import("@react-navigation/native").LinkingOptions<{}> | undefined;
|
|
15
15
|
fallback?: React.ReactNode;
|
|
16
16
|
documentTitle?: import("@react-navigation/native").DocumentTitleOptions | undefined;
|
|
17
17
|
onReady?: (() => void) | undefined;
|
|
18
18
|
} & {
|
|
19
|
-
ref?: React.Ref<
|
|
19
|
+
ref?: React.Ref<NavigationContainerRef<{}>> | undefined;
|
|
20
20
|
}>) => void];
|
|
21
21
|
/** react-navigation `NavigationContainer` with automatic `linking` prop generated from the routes context. */
|
|
22
22
|
export declare const ContextNavigationContainer: React.ForwardRefExoticComponent<Pick<import("@react-navigation/native").NavigationContainerProps & {
|
|
23
23
|
theme?: import("@react-navigation/native").Theme | undefined;
|
|
24
|
-
linking?: LinkingOptions<{}> | undefined;
|
|
24
|
+
linking?: import("@react-navigation/native").LinkingOptions<{}> | undefined;
|
|
25
25
|
fallback?: React.ReactNode;
|
|
26
26
|
documentTitle?: import("@react-navigation/native").DocumentTitleOptions | undefined;
|
|
27
27
|
onReady?: (() => void) | undefined;
|
|
28
28
|
} & {
|
|
29
|
-
ref?: React.Ref<
|
|
30
|
-
}, keyof import("@react-navigation/native").NavigationContainerProps | "theme" | "linking" | "fallback" | "documentTitle" | "onReady"> & React.RefAttributes<
|
|
31
|
-
export declare function RootContainer({ documentTitle, fallback, initialState, onStateChange, onUnhandledAction, theme }: Omit<NavigationContainerProps, 'independent' | '
|
|
29
|
+
ref?: React.Ref<NavigationContainerRef<{}>> | undefined;
|
|
30
|
+
}, keyof import("@react-navigation/native").NavigationContainerProps | "theme" | "linking" | "fallback" | "documentTitle" | "onReady"> & React.RefAttributes<NavigationContainerRef<{}>>>;
|
|
31
|
+
export declare function RootContainer({ documentTitle, fallback, onReady, initialState, onStateChange, onUnhandledAction, theme }: Omit<NavigationContainerProps, 'independent' | 'ref' | 'children' | 'linking'>): null;
|
|
32
32
|
export {};
|
|
33
33
|
//# sourceMappingURL=ContextNavigationContainer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContextNavigationContainer.d.ts","sourceRoot":"","sources":["../src/ContextNavigationContainer.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"ContextNavigationContainer.d.ts","sourceRoot":"","sources":["../src/ContextNavigationContainer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAoB,mBAAmB,EAAE,sBAAsB,EAAiB,MAAM,0BAA0B,CAAC;AACxH,OAAO,KAAsB,MAAM,OAAO,CAAC;AAM3C,aAAK,wBAAwB,GAAG,KAAK,CAAC,cAAc,CAChD,OAAO,mBAAmB,CAC7B,CAAC;AAIF,wBAAgB,6BAA6B;;;;;;;;;;;;;;;;aAQ5C;AAED,8GAA8G;AAC9G,eAAO,MAAM,0BAA0B;;;;;;;;yLAsBtC,CAAC;AAiDF,wBAAgB,aAAa,CAAC,EAAE,aAAa,EAAE,QAAQ,EAAE,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,iBAAiB,EAAE,KAAK,EAAE,EAAE,IAAI,CAAC,wBAAwB,EAAE,aAAa,GAAG,KAAK,GAAG,UAAU,GAAG,SAAS,CAAC,QAQxM"}
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
import { NavigationContainer } from
|
|
2
|
-
import React, {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
function useLinkingConfig() {
|
|
7
|
-
const routes = useRoutesContext();
|
|
8
|
-
return useMemo(() => getLinkingConfig(routes), [routes]);
|
|
9
|
-
}
|
|
1
|
+
import { findFocusedRoute, NavigationContainer } from '@react-navigation/native';
|
|
2
|
+
import React, { useCallback } from 'react';
|
|
3
|
+
import { useLinkingConfig } from './getLinkingConfig';
|
|
4
|
+
import SplashModule from './splash';
|
|
5
|
+
import { VirtualRouteContext } from './useCurrentRoute';
|
|
10
6
|
const NavigationContainerContext = React.createContext([{}, function () { }]);
|
|
11
7
|
export function useNavigationContainerContext() {
|
|
12
8
|
const context = React.useContext(NavigationContainerContext);
|
|
@@ -20,32 +16,50 @@ export const ContextNavigationContainer = React.forwardRef((props, ref) => {
|
|
|
20
16
|
const [state, setState] = React.useState({});
|
|
21
17
|
const linking = useLinkingConfig();
|
|
22
18
|
console.log('linking', linking);
|
|
23
|
-
const onReady = useCallback(() => {
|
|
24
|
-
props.onReady?.();
|
|
25
|
-
SplashModule?.hideAsync();
|
|
26
|
-
}, [props.onReady]);
|
|
27
19
|
return (React.createElement(NavigationContainerContext.Provider, { value: [
|
|
28
20
|
{
|
|
29
21
|
...props,
|
|
30
22
|
linking,
|
|
31
|
-
onReady,
|
|
32
23
|
...state,
|
|
33
24
|
},
|
|
34
25
|
setState,
|
|
35
26
|
] },
|
|
36
27
|
React.createElement(InternalContextNavigationContainer, { ref: ref })));
|
|
37
28
|
});
|
|
29
|
+
function trimQuery(pathname) {
|
|
30
|
+
const queryIndex = pathname.indexOf('?');
|
|
31
|
+
if (queryIndex !== -1) {
|
|
32
|
+
return pathname.substring(0, queryIndex);
|
|
33
|
+
}
|
|
34
|
+
return pathname;
|
|
35
|
+
}
|
|
38
36
|
const InternalContextNavigationContainer = React.forwardRef((props, ref) => {
|
|
39
37
|
const [contextProps] = useNavigationContainerContext();
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
38
|
+
const [state, setState] = React.useState({ pathname: null, query: {} });
|
|
39
|
+
const onStateChange = useCallback((state) => {
|
|
40
|
+
if (state) {
|
|
41
|
+
const currentRoute = findFocusedRoute(state);
|
|
42
|
+
setState({ pathname: trimQuery(currentRoute?.path ?? '/'), query: currentRoute?.params ?? {} });
|
|
43
|
+
}
|
|
44
|
+
}, [setState]);
|
|
45
|
+
const navigationRef = React.useRef(null);
|
|
46
|
+
React.useImperativeHandle(ref, () => navigationRef.current, [navigationRef]);
|
|
47
|
+
return (React.createElement(VirtualRouteContext.Provider, { value: state },
|
|
48
|
+
React.createElement(NavigationContainer, { ...props, ...contextProps, ref: navigationRef, onReady: () => {
|
|
49
|
+
contextProps.onReady?.();
|
|
50
|
+
SplashModule?.hideAsync();
|
|
51
|
+
const initialState = navigationRef.current?.getRootState();
|
|
52
|
+
onStateChange(initialState);
|
|
53
|
+
}, onStateChange: (state) => {
|
|
54
|
+
contextProps.onStateChange?.(state);
|
|
55
|
+
onStateChange(state);
|
|
56
|
+
} })));
|
|
43
57
|
});
|
|
44
|
-
export function RootContainer({ documentTitle, fallback, initialState, onStateChange, onUnhandledAction, theme }) {
|
|
58
|
+
export function RootContainer({ documentTitle, fallback, onReady, initialState, onStateChange, onUnhandledAction, theme }) {
|
|
45
59
|
const [, setProps] = useNavigationContainerContext();
|
|
46
60
|
React.useEffect(() => {
|
|
47
|
-
setProps({ documentTitle, fallback, initialState, onStateChange, onUnhandledAction, theme });
|
|
48
|
-
}, [documentTitle, fallback, initialState, onStateChange, onUnhandledAction, theme]);
|
|
61
|
+
setProps({ documentTitle, fallback, onReady, initialState, onStateChange, onUnhandledAction, theme });
|
|
62
|
+
}, [documentTitle, fallback, onReady, initialState, onStateChange, onUnhandledAction, theme]);
|
|
49
63
|
return null;
|
|
50
64
|
}
|
|
51
65
|
//# sourceMappingURL=ContextNavigationContainer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContextNavigationContainer.js","sourceRoot":"","sources":["../src/ContextNavigationContainer.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"ContextNavigationContainer.js","sourceRoot":"","sources":["../src/ContextNavigationContainer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAyC,MAAM,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AAE,CAAC;gBAC3D,aAAa,CAAC,YAAY,CAAC,CAAC;YAChC,CAAC,EACD,aAAa,EAAE,CAAC,KAAK,EAAE,EAAE;gBACrB,YAAY,CAAC,aAAa,EAAE,CAAC,KAAK,CAAC,CAAC;gBACpC,aAAa,CAAC,KAAK,CAAC,CAAC;YACzB,CAAC,GACH,CACyB,CAClC,CAAC;AACN,CAAC,CACJ,CAAC;AAEF,MAAM,UAAU,aAAa,CAAC,EAAE,aAAa,EAAE,QAAQ,EAAE,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,iBAAiB,EAAE,KAAK,EAAkF;IACrM,MAAM,CAAC,EAAE,QAAQ,CAAC,GAAG,6BAA6B,EAAE,CAAC;IAErD,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACjB,QAAQ,CAAC,EAAE,aAAa,EAAE,QAAQ,EAAE,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,iBAAiB,EAAE,KAAK,EAAE,CAAC,CAAC;IAC1G,CAAC,EAAE,CAAC,aAAa,EAAE,QAAQ,EAAE,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,iBAAiB,EAAE,KAAK,CAAC,CAAC,CAAC;IAE9F,OAAO,IAAI,CAAC;AAChB,CAAC","sourcesContent":["import { findFocusedRoute, NavigationContainer, NavigationContainerRef, ParamListBase } from '@react-navigation/native';\nimport React, { useCallback } from 'react';\n\nimport { useLinkingConfig } from './getLinkingConfig';\nimport SplashModule from './splash';\nimport { VirtualRouteContext } from './useCurrentRoute';\n\ntype NavigationContainerProps = React.ComponentProps<\n typeof NavigationContainer\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\n return (\n <NavigationContainerContext.Provider value={[\n {\n ...props,\n linking,\n ...state,\n },\n setState,\n ]}>\n <InternalContextNavigationContainer\n ref={ref}\n />\n </NavigationContainerContext.Provider>\n );\n }\n);\n\nfunction trimQuery(pathname: string): string {\n const queryIndex = pathname.indexOf('?');\n if (queryIndex !== -1) {\n return pathname.substring(0, queryIndex);\n }\n return pathname;\n}\n\nconst InternalContextNavigationContainer = React.forwardRef(\n (props: {}, ref: NavigationContainerProps[\"ref\"]) => {\n const [contextProps] = useNavigationContainerContext();\n const [state, setState] = React.useState<{ pathname: string | null, query: Record<string, any> }>({ pathname: null, query: {} });\n\n const onStateChange = useCallback((state) => {\n if (state) {\n const currentRoute = findFocusedRoute(state);\n setState({ pathname: trimQuery(currentRoute?.path ?? '/'), query: currentRoute?.params ?? {} });\n }\n }, [setState]);\n\n const navigationRef = React.useRef<NavigationContainerRef<ParamListBase>>(null);\n\n React.useImperativeHandle(ref, () => navigationRef.current!, [navigationRef]);\n\n return (\n <VirtualRouteContext.Provider value={state}>\n { /* @ts-expect-error: children are required */}\n <NavigationContainer\n {...props}\n {...contextProps}\n ref={navigationRef}\n onReady={() => {\n contextProps.onReady?.();\n SplashModule?.hideAsync();\n const initialState = navigationRef.current?.getRootState();\n onStateChange(initialState);\n }}\n onStateChange={(state) => {\n contextProps.onStateChange?.(state);\n onStateChange(state);\n }}\n />\n </VirtualRouteContext.Provider>\n );\n }\n);\n\nexport function RootContainer({ documentTitle, fallback, onReady, initialState, onStateChange, onUnhandledAction, theme }: Omit<NavigationContainerProps, 'independent' | 'ref' | 'children' | 'linking'>) {\n const [, setProps] = useNavigationContainerContext();\n\n React.useEffect(() => {\n setProps({ documentTitle, fallback, onReady, initialState, onStateChange, onUnhandledAction, theme });\n }, [documentTitle, fallback, onReady, initialState, onStateChange, onUnhandledAction, theme]);\n\n return null;\n}"]}
|
|
@@ -2,4 +2,5 @@ import { LinkingOptions, PathConfigMap } from "@react-navigation/native";
|
|
|
2
2
|
import { RouteNode } from "./Route";
|
|
3
3
|
export declare function treeToReactNavigationLinkingRoutes(nodes: RouteNode[], parents?: string[]): PathConfigMap<{}>;
|
|
4
4
|
export declare function getLinkingConfig(routes: RouteNode[]): LinkingOptions<{}>;
|
|
5
|
+
export declare function useLinkingConfig(): LinkingOptions<{}>;
|
|
5
6
|
//# 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;
|
|
1
|
+
{"version":3,"file":"getLinkingConfig.d.ts","sourceRoot":"","sources":["../src/getLinkingConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAUzE,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AA6BpC,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;AAED,wBAAgB,gBAAgB,IAAI,cAAc,CAAC,EAAE,CAAC,CAGrD"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { useMemo } from "react";
|
|
1
2
|
import { getAllWebRedirects } from "./aasa";
|
|
2
3
|
import { matchDeepDynamicRouteName, matchDynamicName, matchFragmentName, } from "./matchers";
|
|
3
|
-
import { addEventListener, getInitialURL,
|
|
4
|
+
import { addEventListener, getInitialURL, getRootURL, getPathFromState, getStateFromPath, } from "./linking";
|
|
5
|
+
import { useRoutesContext } from "./context";
|
|
4
6
|
// `[page]` -> `:page`
|
|
5
7
|
// `page` -> `page`
|
|
6
8
|
function convertDynamicRouteToReactNavigation(name) {
|
|
@@ -41,7 +43,7 @@ export function getLinkingConfig(routes) {
|
|
|
41
43
|
return {
|
|
42
44
|
prefixes: [
|
|
43
45
|
/* your linking prefixes */
|
|
44
|
-
|
|
46
|
+
getRootURL(),
|
|
45
47
|
// This ensures that we can redirect correctly when the user comes from an associated domain
|
|
46
48
|
// i.e. iOS Safari banner.
|
|
47
49
|
...getAllWebRedirects(),
|
|
@@ -60,4 +62,8 @@ export function getLinkingConfig(routes) {
|
|
|
60
62
|
getPathFromState,
|
|
61
63
|
};
|
|
62
64
|
}
|
|
65
|
+
export function useLinkingConfig() {
|
|
66
|
+
const routes = useRoutesContext();
|
|
67
|
+
return useMemo(() => getLinkingConfig(routes), [routes]);
|
|
68
|
+
}
|
|
63
69
|
//# sourceMappingURL=getLinkingConfig.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getLinkingConfig.js","sourceRoot":"","sources":["../src/getLinkingConfig.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getLinkingConfig.js","sourceRoot":"","sources":["../src/getLinkingConfig.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAEhC,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,UAAU,EACV,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAE7C,sBAAsB;AACtB,mBAAmB;AACnB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U,EAAE;YAEZ,4FAA4F;YAC5F,0BAA0B;YAC1B,GAAG,kBAAkB,EAAE;SACxB;QACD,MAAM,EAAE;YACN,OAAO,EAAE,kCAAkC,CAAC,MAAM,CAAC;SACpD;QACD,8EAA8E;QAC9E,wEAAwE;QACxE,+EAA+E;QAC/E,8GAA8G;QAC9G,8EAA8E;QAC9E,aAAa,EAAE,aAAa;QAC5B,SAAS,EAAE,gBAAgB;QAC3B,gBAAgB;QAChB,gBAAgB;KACjB,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,gBAAgB;IAC9B,MAAM,MAAM,GAAG,gBAAgB,EAAE,CAAC;IAClC,OAAO,OAAO,CAAC,GAAG,EAAE,CAAC,gBAAgB,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;AAC3D,CAAC","sourcesContent":["import { LinkingOptions, PathConfigMap } from \"@react-navigation/native\";\nimport { useMemo } from \"react\";\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 getRootURL,\n getPathFromState,\n getStateFromPath,\n} from \"./linking\";\nimport { useRoutesContext } from \"./context\";\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 getRootURL(),\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\nexport function useLinkingConfig(): LinkingOptions<{}> {\n const routes = useRoutesContext();\n return useMemo(() => getLinkingConfig(routes), [routes]);\n}\n"]}
|
package/build/index.d.ts
CHANGED
|
@@ -12,5 +12,6 @@ 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 { useCurrentRoute } from "./useCurrentRoute";
|
|
15
16
|
export * as Linking from './linking';
|
|
16
17
|
//# sourceMappingURL=index.d.ts.map
|
package/build/index.d.ts.map
CHANGED
|
@@ -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,EAA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uB,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;AAC5F,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,KAAK,OAAO,MAAM,WAAW,CAAA"}
|
package/build/index.js
CHANGED
|
@@ -11,6 +11,7 @@ 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
|
+
export { useCurrentRoute } from "./useCurrentRoute";
|
|
14
15
|
import * as Linking_1 from './linking';
|
|
15
16
|
export { Linking_1 as Linking };
|
|
16
17
|
//# sourceMappingURL=index.js.map
|
package/build/index.js.map
CHANGED
|
@@ -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;
|
|
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;AAC5F,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;2BAE3B,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\";\nexport { useCurrentRoute } from \"./useCurrentRoute\";\n\nexport * as Linking from './linking'"]}
|
package/build/linking.d.ts
CHANGED
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
import getPathFromState from "./fork/getPathFromState";
|
|
2
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
3
|
export declare function getInitialURL(): Promise<string>;
|
|
10
|
-
export declare
|
|
4
|
+
export declare function getRootURL(): string;
|
|
11
5
|
export declare function addEventListener(listener: (url: string) => void): () => void;
|
|
12
6
|
export { getStateFromPath, getPathFromState };
|
|
13
7
|
//# sourceMappingURL=linking.d.ts.map
|
package/build/linking.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linking.d.ts","sourceRoot":"","sources":["../src/linking.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"linking.d.ts","sourceRoot":"","sources":["../src/linking.ts"],"names":[],"mappings":"AAGA,OAAO,gBAAgB,MAAM,yBAAyB,CAAC;AACvD,OAAO,gBAAgB,MAAM,yBAAyB,CAAC;AAOvD,wBAAsB,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC,CA+BrD;AAID,wBAAgB,UAAU,WAKzB;AAED,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,cAiC/D;AAED,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,CAAC"}
|
package/build/linking.js
CHANGED
|
@@ -1,24 +1,7 @@
|
|
|
1
1
|
import Constants, { ExecutionEnvironment } from "expo-constants";
|
|
2
2
|
import * as Linking from "expo-linking";
|
|
3
|
-
import { Platform } from "react-native";
|
|
4
3
|
import getPathFromState from "./fork/getPathFromState";
|
|
5
4
|
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
5
|
// A custom getInitialURL is used on native to ensure the app always starts at
|
|
23
6
|
// the root path if it's launched from something other than a deep link.
|
|
24
7
|
// This helps keep the native functionality working like the web functionality.
|
|
@@ -37,21 +20,27 @@ export async function getInitialURL() {
|
|
|
37
20
|
// If the URL is defined (default in Expo Go dev apps) and the URL has no path:
|
|
38
21
|
// `exp://192.168.87.39:19000/` then use the default `exp://192.168.87.39:19000/--/`
|
|
39
22
|
if (parsed.path === null || ["", "/"].includes(parsed.path)) {
|
|
40
|
-
return
|
|
23
|
+
return getRootURL();
|
|
41
24
|
}
|
|
42
25
|
}
|
|
43
26
|
// The path will be nullish in bare apps when the app is launched from the home screen.
|
|
44
27
|
// TODO(EvanBacon): define some policy around notifications.
|
|
45
|
-
return url ??
|
|
28
|
+
return url ?? getRootURL();
|
|
46
29
|
})(),
|
|
47
30
|
new Promise((resolve) =>
|
|
48
31
|
// Timeout in 150ms if `getInitialState` doesn't resolve
|
|
49
32
|
// Workaround for https://github.com/facebook/react-native/issues/25675
|
|
50
|
-
setTimeout(() => resolve(
|
|
33
|
+
setTimeout(() => resolve(getRootURL()), 150)),
|
|
51
34
|
]);
|
|
52
35
|
return url;
|
|
53
36
|
}
|
|
54
|
-
|
|
37
|
+
let _rootURL;
|
|
38
|
+
export function getRootURL() {
|
|
39
|
+
if (_rootURL === undefined) {
|
|
40
|
+
_rootURL = Linking.createURL("/");
|
|
41
|
+
}
|
|
42
|
+
return _rootURL;
|
|
43
|
+
}
|
|
55
44
|
export function addEventListener(listener) {
|
|
56
45
|
let callback = undefined;
|
|
57
46
|
if (Constants.executionEnvironment === ExecutionEnvironment.StoreClient) {
|
|
@@ -61,7 +50,7 @@ export function addEventListener(listener) {
|
|
|
61
50
|
// If the URL is defined (default in Expo Go dev apps) and the URL has no path:
|
|
62
51
|
// `exp://192.168.87.39:19000/` then use the default `exp://192.168.87.39:19000/--/`
|
|
63
52
|
if (parsed.path === null || ["", "/"].includes(parsed.path)) {
|
|
64
|
-
listener(
|
|
53
|
+
listener(getRootURL());
|
|
65
54
|
}
|
|
66
55
|
else {
|
|
67
56
|
listener(url);
|
package/build/linking.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linking.js","sourceRoot":"","sources":["../src/linking.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,EAAE,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACjE,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"linking.js","sourceRoot":"","sources":["../src/linking.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,EAAE,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACjE,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AAExC,OAAO,gBAAgB,MAAM,yBAAyB,CAAC;AACvD,OAAO,gBAAgB,MAAM,yBAAy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D,SAAS,CAAC;IAE3E,IAAI,SAAS,CAAC,oBAAoB,KAAK,oBAAoB,CAAC,WAAW,EAAE;QACvE,mDAAmD;QACnD,QAAQ,GAAG,CAAC,EAAE,GAAG,EAAmB,EAAE,EAAE;YACtC,MAAM,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAClC,+EAA+E;YAC/E,oFAAoF;YACpF,IAAI,MAAM,CAAC,IAAI,KAAK,IAAI,IAAI,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;gBAC3D,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC;aACxB;iBAAM;gBACL,QAAQ,CAAC,GAAG,CAAC,CAAC;aACf;QACH,CAAC,CAAC;KACH;SAAM;QACL,QAAQ,GAAG,CAAC,EAAE,GAAG,EAAmB,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;KACxD;IACD,MAAM,YAAY,GAAG,OAAO,CAAC,gBAAgB,CAAC,KAAK,EAAE,QAAQ,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\";\n\nimport getPathFromState from \"./fork/getPathFromState\";\nimport getStateFromPath from \"./fork/getStateFromPath\";\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 getRootURL();\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 ?? getRootURL();\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(getRootURL()), 150)\n ),\n ]);\n return url;\n}\n\nlet _rootURL: string | undefined;\n\nexport function getRootURL() {\n if (_rootURL === undefined) {\n _rootURL = Linking.createURL(\"/\");\n }\n return _rootURL;\n}\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(getRootURL());\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,10 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export declare const VirtualRouteContext: React.Context<{
|
|
3
|
+
pathname: string | null;
|
|
4
|
+
query: Record<string, any>;
|
|
5
|
+
}>;
|
|
6
|
+
export declare function useCurrentRoute(): {
|
|
7
|
+
pathname: string | null;
|
|
8
|
+
query: Record<string, any>;
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=useCurrentRoute.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCurrentRoute.d.ts","sourceRoot":"","sources":["../src/useCurrentRoute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,eAAO,MAAM,mBAAmB;cACpB,MAAM,GAAG,IAAI;WAChB,OAAO,MAAM,EAAE,GAAG,CAAC;EACK,CAAC;AAMlC,wBAAgB,eAAe;;;EAQ9B"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export const VirtualRouteContext = React.createContext({ pathname: null, query: {} });
|
|
3
|
+
if (process.env.NODE_ENV !== "production") {
|
|
4
|
+
VirtualRouteContext.displayName = "VirtualRouteContext";
|
|
5
|
+
}
|
|
6
|
+
export function useCurrentRoute() {
|
|
7
|
+
const context = React.useContext(VirtualRouteContext);
|
|
8
|
+
if (!context) {
|
|
9
|
+
throw new Error("useCurrentRoute must be used within a NavigationContainerContext");
|
|
10
|
+
}
|
|
11
|
+
return context;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=useCurrentRoute.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCurrentRoute.js","sourceRoot":"","sources":["../src/useCurrentRoute.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,CAAC,MAAM,mBAAmB,GAAG,KAAK,CAAC,aAAa,CAGnD,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC;AAElC,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE;IACzC,mBAAmB,CAAC,WAAW,GAAG,qBAAqB,CAAC;CACzD;AAED,MAAM,UAAU,eAAe;IAC7B,MAAM,OAAO,GAAG,KAAK,CAAC,UAAU,CAAC,mBAAmB,CAAC,CAAC;IACtD,IAAI,CAAC,OAAO,EAAE;QACZ,MAAM,IAAI,KAAK,CACb,kEAAkE,CACnE,CAAC;KACH;IACD,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import React from \"react\";\n\nexport const VirtualRouteContext = React.createContext<{\n pathname: string | null;\n query: Record<string, any>;\n}>({ pathname: null, query: {} });\n\nif (process.env.NODE_ENV !== \"production\") {\n VirtualRouteContext.displayName = \"VirtualRouteContext\";\n}\n\nexport function useCurrentRoute() {\n const context = React.useContext(VirtualRouteContext);\n if (!context) {\n throw new Error(\n \"useCurrentRoute must be used within a NavigationContainerContext\"\n );\n }\n return context;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-router",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.13",
|
|
4
4
|
"main": "build/index.js",
|
|
5
5
|
"files": [
|
|
6
6
|
"entry.js",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"jest": "^26.6.3"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@bacons/expo-metro-runtime": "^
|
|
47
|
+
"@bacons/expo-metro-runtime": "^2.0.1",
|
|
48
48
|
"@bacons/react-views": "^1.1.3",
|
|
49
49
|
"@radix-ui/react-slot": "^1.0.0",
|
|
50
50
|
"@react-navigation/bottom-tabs": "^6.3.3",
|
|
@@ -54,6 +54,7 @@
|
|
|
54
54
|
"@react-navigation/stack": "^6.2.3",
|
|
55
55
|
"expo-constants": "~13.2.4",
|
|
56
56
|
"expo-linking": "^3.2.2",
|
|
57
|
+
"expo-splash-screen": "^0.16.2",
|
|
57
58
|
"expo-status-bar": "^1.4.0",
|
|
58
59
|
"react-native-gesture-handler": "~2.5.0",
|
|
59
60
|
"react-native-reanimated": "~2.9.1",
|
|
@@ -1,8 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,14 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"]}
|