expo-router 0.0.10 → 0.0.14
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 +3 -4
- package/build/index.d.ts.map +1 -1
- package/build/index.js +5 -4
- 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/onboard/Tutorial.d.ts.map +1 -1
- package/build/onboard/Tutorial.js +13 -5
- package/build/onboard/Tutorial.js.map +1 -1
- package/build/onboard/createEntryFile.js +2 -3
- package/build/onboard/createEntryFile.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/build/useLink.d.ts +7 -0
- package/build/useLink.d.ts.map +1 -0
- package/build/useLink.js +19 -0
- package/build/useLink.js.map +1 -0
- package/build/views/Link.d.ts +16 -6
- package/build/views/Link.d.ts.map +1 -1
- package/build/views/Link.js +53 -13
- package/build/views/Link.js.map +1 -1
- package/build/views/Unmatched.js +1 -1
- package/build/views/Unmatched.js.map +1 -1
- 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,0BAA0B,CAAC;AACxH,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAE3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,YAAY,MAAM,UAAU,CAAC;AACpC,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAMxD,MAAM,0BAA0B,GAAG,KAAK,CAAC,aAAa,CAA0F,CAAC,EAAE,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC;AAEvK,MAAM,UAAU,6BAA6B;IACzC,MAAM,OAAO,GAAG,KAAK,CAAC,UAAU,CAAC,0BAA0B,CAAC,CAAC;IAC7D,IAAI,CAAC,OAAO,EAAE;QACV,MAAM,IAAI,KAAK,CACX,gFAAgF,CACnF,CAAC;KACL;IACD,OAAO,OAAO,CAAC;AACnB,CAAC;AAED,8GAA8G;AAC9G,MAAM,CAAC,MAAM,0BAA0B,GAAG,KAAK,CAAC,UAAU,CACtD,CAAC,KAA+B,EAAE,GAAoC,EAAE,EAAE;IACtE,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAoC,EAAE,CAAC,CAAC;IAEhF,MAAM,OAAO,GAAG,gBAAgB,EAAE,CAAC;IACnC,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAE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AG,EAAE,CAAC,aAAa,CAAC,OAAQ,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC;IAE9E,OAAO,CACH,oBAAC,mBAAmB,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK;QAEtC,oBAAC,mBAAmB,OACZ,KAAK,KACL,YAAY,EAChB,GAAG,EAAE,aAAa,EAClB,OAAO,EAAE,GAAG,EAAE;gBACV,YAAY,CAAC,OAAO,EAAE,EAAE,CAAC;gBACzB,YAAY,EAAE,SAAS,EAAE,CAAC;gBAC1B,MAAM,YAAY,GAAG,aAAa,CAAC,OAAO,EAAE,YAAY,EAAE,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"],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EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,CAAU,CAAC;IAClD,CAAC,CAAC;SACD,MAAM,CAAoB,CAAC,GAAG,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,EAAE,EAAE;QACnD,GAAG,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC;QACrB,OAAO,GAAG,CAAC;IACb,CAAC,EAAE,EAAE,CAAC,CAAC;IAET,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,MAAmB;IAClD,OAAO;QACL,QAAQ,EAAE;YACR,2BAA2B;YAC3B,UAAU,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
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
export { useRoutes } from "./Route";
|
|
2
|
-
export { useScreens } from "./useScreens";
|
|
3
1
|
export { ErrorBoundaryProps } from "./views/Try";
|
|
4
2
|
export { Stack } from "./layouts/Stack";
|
|
5
3
|
export { NativeStack } from "./layouts/NativeStack";
|
|
@@ -11,6 +9,7 @@ export { Unmatched } from "./views/Unmatched";
|
|
|
11
9
|
export { ErrorBoundary } from "./views/ErrorBoundary";
|
|
12
10
|
export { Layout, Children } from "./views/Layout";
|
|
13
11
|
export { Link } from "./views/Link";
|
|
14
|
-
export {
|
|
15
|
-
export
|
|
12
|
+
export { useLink } from "./useLink";
|
|
13
|
+
export { RootContainer } from "./ContextNavigationContainer";
|
|
14
|
+
export * as Linking from "./linking";
|
|
16
15
|
//# 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":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAGA,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,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAG7D,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC"}
|
package/build/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { useRoutes } from "./Route";
|
|
2
|
-
export { useScreens } from "./useScreens";
|
|
1
|
+
// export { useRoutes } from "./Route";
|
|
2
|
+
// export { useScreens } from "./useScreens";
|
|
3
3
|
export { Stack } from "./layouts/Stack";
|
|
4
4
|
export { NativeStack } from "./layouts/NativeStack";
|
|
5
5
|
export { Tabs } from "./layouts/Tabs";
|
|
@@ -10,7 +10,8 @@ export { Unmatched } from "./views/Unmatched";
|
|
|
10
10
|
export { ErrorBoundary } from "./views/ErrorBoundary";
|
|
11
11
|
export { Layout, Children } from "./views/Layout";
|
|
12
12
|
export { Link } from "./views/Link";
|
|
13
|
-
export {
|
|
14
|
-
|
|
13
|
+
export { useLink } from "./useLink";
|
|
14
|
+
export { RootContainer } from "./ContextNavigationContainer";
|
|
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,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,6CAA6C;AAI7C,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,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;2BAGpC,WAAW;sBAAxB,OAAO","sourcesContent":["// export { useRoutes } from \"./Route\";\n// export { 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 { useLink } from \"./useLink\";\nexport { RootContainer } from \"./ContextNavigationContainer\";\n// export { useCurrentRoute } from \"./useCurrentRoute\";\n\nexport * as Linking from \"./linking\";\n"]}
|
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,yBAAyB,CAAC;AAEvD,8EAA8E;AAC9E,wEAAwE;AACxE,+EAA+E;AAC/E,8GAA8G;AAC9G,8EAA8E;AAC9E,MAAM,CAAC,KAAK,UAAU,aAAa;IACjC,MAAM,GAAG,GAAG,MAAM,OAAO,CAAC,IAAI,CAAS;QACrC,CAAC,KAAK,IAAI,EAAE;YACV,MAAM,GAAG,GAAG,MAAM,OAAO,CAAC,aAAa,EAAE,CAAC;YAE1C,gFAAgF;YAChF,oDAAoD;YAEpD,2DAA2D;YAC3D,IACE,GAAG;gBACH,SAAS,CAAC,oBAAoB,KAAK,oBAAoB,CAAC,WAAW,EACnE;gBACA,MAAM,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;gBAClC,+EAA+E;gBAC/E,oFAAoF;gBACpF,IAAI,MAAM,CAAC,IAAI,KAAK,IAAI,IAAI,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;oBAC3D,OAAO,UAAU,EAAE,CAAC;iBACrB;aACF;YACD,uFAAuF;YACvF,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AAC;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"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tutorial.d.ts","sourceRoot":"","sources":["../../src/onboard/Tutorial.tsx"],"names":[],"mappings":";AAmCA,wBAAgB,QAAQ,
|
|
1
|
+
{"version":3,"file":"Tutorial.d.ts","sourceRoot":"","sources":["../../src/onboard/Tutorial.tsx"],"names":[],"mappings":";AAmCA,wBAAgB,QAAQ,gBAyDvB"}
|
|
@@ -26,7 +26,8 @@ export function Tutorial() {
|
|
|
26
26
|
if (typeof location !== "undefined" && location.pathname !== "/") {
|
|
27
27
|
location.replace("/");
|
|
28
28
|
}
|
|
29
|
-
if (typeof window !== "undefined" &&
|
|
29
|
+
if (typeof window !== "undefined" &&
|
|
30
|
+
typeof window.document !== "undefined") {
|
|
30
31
|
window.document.title = "npx expo start";
|
|
31
32
|
}
|
|
32
33
|
}
|
|
@@ -45,7 +46,7 @@ export function Tutorial() {
|
|
|
45
46
|
marginHorizontal: "auto",
|
|
46
47
|
alignItems: "stretch",
|
|
47
48
|
} },
|
|
48
|
-
React.createElement(View, {
|
|
49
|
+
React.createElement(View, { style: styles.container },
|
|
49
50
|
React.createElement(Header, null),
|
|
50
51
|
React.createElement(Text, { accessibilityRole: "header", accessibilityLevel: 2, style: styles.subtitle },
|
|
51
52
|
"Get started by creating a file",
|
|
@@ -65,15 +66,19 @@ function Button() {
|
|
|
65
66
|
...Platform.select({
|
|
66
67
|
native: {
|
|
67
68
|
position: "absolute",
|
|
68
|
-
bottom:
|
|
69
|
+
bottom: 24,
|
|
69
70
|
left: 24,
|
|
70
71
|
right: 24,
|
|
72
|
+
overflow: "hidden",
|
|
71
73
|
},
|
|
72
74
|
}),
|
|
73
75
|
} }, ({ pressed, hovered }) => (React.createElement(View, { style: [
|
|
74
76
|
{
|
|
75
77
|
transitionDuration: "200ms",
|
|
76
|
-
backgroundColor:
|
|
78
|
+
backgroundColor: Platform.select({
|
|
79
|
+
web: "transparent",
|
|
80
|
+
default: "white",
|
|
81
|
+
}),
|
|
77
82
|
borderColor: "white",
|
|
78
83
|
borderWidth: 2,
|
|
79
84
|
paddingVertical: 12,
|
|
@@ -91,7 +96,10 @@ function Button() {
|
|
|
91
96
|
fontSize: 18,
|
|
92
97
|
transitionDuration: "200ms",
|
|
93
98
|
fontWeight: "bold",
|
|
94
|
-
color:
|
|
99
|
+
color: Platform.select({
|
|
100
|
+
web: "white",
|
|
101
|
+
default: "black",
|
|
102
|
+
}),
|
|
95
103
|
},
|
|
96
104
|
styles.code,
|
|
97
105
|
hovered && { color: "black" },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tutorial.js","sourceRoot":"","sources":["../../src/onboard/Tutorial.tsx"],"names":[],"mappings":"AAAA,OAAO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,CACb,CAAC;AACJ,CAAC;AAED,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IAC/B,SAAS,EAAE;QACT,IAAI,EAAE,CAAC;QACP,OAAO,EAAE,EAAE;QACX,UAAU,EAAE,OAAO;QACnB,cAAc,EAAE,QAAQ;KACzB;IACD,KAAK,EAAE;QACL,KAAK,EAAE,OAAO;QACd,QAAQ,EAAE,EAAE;QACZ,aAAa,EAAE,EAAE;QACjB,UAAU,EAAE,MAAM;KACnB;IACD,UAAU,EAAE;QACV,KAAK,EAAE,OAAO;KACf;IACD,IAAI,EAAE;QACJ,UAAU,EAAE,QAAQ,CAAC,MAAM,CAAC;YAC1B,OAAO,EAAE,SAAS;YAClB,GAAG,EAAE,aAAa;YAClB,OAAO,EAAE,WAAW;SACrB,CAAC;KACH;IACD,QAAQ,EAAE;QACR,KAAK,EAAE,SAAS;QAChB,QAAQ,EAAE,EAAE;QACZ,UAAU,EAAE,OAAO;QACnB,aAAa,EAAE,EAAE;QACjB,QAAQ,EAAE,GAAG;KACd;CACF,CAAC,CAAC","sourcesContent":["import React from \"react\";\nimport { SafeAreaView, StatusBar, Platform } from \"react-native\";\nimport { View, Text, Pressable, StyleSheet } from \"@bacons/react-views\";\nimport { createEntryFileAsync } from \"./createEntryFile\";\n\n// TODO: Use openLinkFromBrowser thing\nfunction Header() {\n return (\n <Pressable>\n {({ hovered }) => (\n <Text\n accessibilityRole=\"header\"\n accessibilityLevel={1}\n style={[styles.title, Platform.OS !== \"web\" && { textAlign: \"left\" }]}\n >\n Welcome to{\" \"}\n <Text\n href=\"https://github.com/expo/expo-router/\"\n style={[\n hovered && {\n textDecorationColor: \"white\",\n textDecorationLine: \"underline\",\n },\n ]}\n >\n Expo\n </Text>\n </Text>\n )}\n </Pressable>\n );\n}\n\nconst canAutoTouchFile = process.env.EXPO_ROUTER_APP_ROOT != null;\n\nexport function Tutorial() {\n React.useEffect(() => {\n if (Platform.OS === \"web\") {\n // Reset the route on web so the initial route isn't a 404 after\n // the user has created the entry file.\n // This is useful for cases where you are testing the tutorial.\n // To test: touch the new file, then navigate to a missing route `/foobar`, then delete the app folder.\n // you should see the tutorial again and be able to create the entry file once more.\n if (typeof location !== \"undefined\" && location.pathname !== \"/\") {\n location.replace(\"/\");\n }\n if (\n typeof window !== \"undefined\" &&\n typeof window.document !== \"undefined\"\n ) {\n window.document.title = \"npx expo start\";\n }\n }\n }, []);\n\n return (\n <View\n style={{\n backgroundColor: \"black\",\n flex: 1,\n backgroundImage:\n \"radial-gradient(circle at 1px 1px, rgba(255,255,255,0.15) 1px, transparent 0)\",\n backgroundPosition: \"-3px -3px\",\n backgroundSize: \"40px 40px\",\n }}\n >\n <StatusBar barStyle=\"light-content\" />\n\n <SafeAreaView\n style={{\n flex: 1,\n maxWidth: 960,\n marginHorizontal: \"auto\",\n alignItems: \"stretch\",\n }}\n >\n <View style={styles.container}>\n <Header />\n <Text\n accessibilityRole=\"header\"\n accessibilityLevel={2}\n style={styles.subtitle}\n >\n Get started by creating a file{\"\\n\"}in the{\" \"}\n <Text style={{ fontWeight: \"bold\" }}>app</Text> directory{\"\\n\"}that\n exports a React component.\n </Text>\n {canAutoTouchFile && <Button />}\n </View>\n </SafeAreaView>\n </View>\n );\n}\n\nfunction Button() {\n return (\n <Pressable\n onPress={() => {\n createEntryFileAsync();\n }}\n style={{\n ...Platform.select({\n native: {\n position: \"absolute\",\n bottom: 24,\n left: 24,\n right: 24,\n overflow: \"hidden\",\n },\n }),\n }}\n >\n {({ pressed, hovered }) => (\n <View\n style={[\n {\n transitionDuration: \"200ms\",\n backgroundColor: Platform.select({\n web: \"transparent\",\n default: \"white\",\n }),\n\n borderColor: \"white\",\n borderWidth: 2,\n paddingVertical: 12,\n paddingHorizontal: 24,\n },\n hovered && {\n backgroundColor: \"white\",\n },\n pressed && {\n backgroundColor: \"rgba(255,255,255,0.7)\",\n },\n ]}\n >\n <Text\n selectable={false}\n style={[\n {\n fontSize: 18,\n transitionDuration: \"200ms\",\n fontWeight: \"bold\",\n color: Platform.select({\n web: \"white\",\n default: \"black\",\n }),\n },\n styles.code,\n hovered && { color: \"black\" },\n ]}\n >\n <Text style={{ color: \"#BCC3CD\" }}>$</Text> touch app/index.js\n </Text>\n </View>\n )}\n </Pressable>\n );\n}\n\nconst styles = StyleSheet.create({\n container: {\n flex: 1,\n padding: 24,\n alignItems: \"start\",\n justifyContent: \"center\",\n },\n title: {\n color: \"white\",\n fontSize: 64,\n paddingBottom: 24,\n fontWeight: \"bold\",\n },\n buttonText: {\n color: \"black\",\n },\n code: {\n fontFamily: Platform.select({\n default: \"Courier\",\n ios: \"Courier New\",\n android: \"monospace\",\n }),\n },\n subtitle: {\n color: \"#BCC3CD\",\n fontSize: 36,\n fontWeight: \"light\",\n paddingBottom: 36,\n maxWidth: 960,\n },\n});\n"]}
|
|
@@ -22,9 +22,7 @@ export default function Page() {
|
|
|
22
22
|
<View style={styles.container}>
|
|
23
23
|
<View style={styles.main}>
|
|
24
24
|
<Text style={styles.title}>Hello World</Text>
|
|
25
|
-
<Text style={styles.subtitle}>
|
|
26
|
-
This is the first page of your{"\\n"}native app, and website.
|
|
27
|
-
</Text>
|
|
25
|
+
<Text style={styles.subtitle}>This is the first page of your app.</Text>
|
|
28
26
|
</View>
|
|
29
27
|
</View>
|
|
30
28
|
);
|
|
@@ -34,6 +32,7 @@ const styles = StyleSheet.create({
|
|
|
34
32
|
container: {
|
|
35
33
|
flex: 1,
|
|
36
34
|
alignItems: "center",
|
|
35
|
+
padding: 24,
|
|
37
36
|
},
|
|
38
37
|
main: {
|
|
39
38
|
flex: 1,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createEntryFile.js","sourceRoot":"","sources":["../../src/onboard/createEntryFile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,4DAA4D;AAC5D,MAAM,UAAU,oBAAoB;IAClC,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE;QACzC,gBAAgB;QAChB,OAAO,CAAC,IAAI,CAAC,gDAAgD,CAAC,CAAC;QAC/D,OAAO;KACR;IAED,+CAA+C;IAC/C,OAAO,KAAK,CAAC,YAAY,EAAE,CAAC,GAAG,GAAG,aAAa,EAAE;QAC/C,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;YACnB,QAAQ,EAAE,QAAQ;YAClB,IAAI,EAAE,gBAAgB;SACvB,CAAC;KACH,CAAC,CAAC;AACL,CAAC;AAED,MAAM,QAAQ,GAAG
|
|
1
|
+
{"version":3,"file":"createEntryFile.js","sourceRoot":"","sources":["../../src/onboard/createEntryFile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,4DAA4D;AAC5D,MAAM,UAAU,oBAAoB;IAClC,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE;QACzC,gBAAgB;QAChB,OAAO,CAAC,IAAI,CAAC,gDAAgD,CAAC,CAAC;QAC/D,OAAO;KACR;IAED,+CAA+C;IAC/C,OAAO,KAAK,CAAC,YAAY,EAAE,CAAC,GAAG,GAAG,aAAa,EAAE;QAC/C,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;YACnB,QAAQ,EAAE,QAAQ;YAClB,IAAI,EAAE,gBAAgB;SACvB,CAAC;KACH,CAAC,CAAC;AACL,CAAC;AAED,MAAM,QAAQ,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkChB,CAAC","sourcesContent":["import { getDevServer } from \"../getDevServer\";\n\n/** Middleware for creating an entry file in the project. */\nexport function createEntryFileAsync() {\n if (process.env.NODE_ENV === \"production\") {\n // No dev server\n console.warn(\"createEntryFile() cannot be used in production\");\n return;\n }\n\n // Pings middleware in the Expo CLI dev server.\n return fetch(getDevServer().url + \"_expo/touch\", {\n method: \"POST\",\n body: JSON.stringify({\n contents: TEMPLATE,\n path: \"./app/index.js\",\n }),\n });\n}\n\nconst TEMPLATE = `import { StyleSheet, Text, View } from \"react-native\";\n\nexport default function Page() {\n return (\n <View style={styles.container}>\n <View style={styles.main}>\n <Text style={styles.title}>Hello World</Text>\n <Text style={styles.subtitle}>This is the first page of your app.</Text>\n </View>\n </View>\n );\n}\n\nconst styles = StyleSheet.create({\n container: {\n flex: 1,\n alignItems: \"center\",\n padding: 24,\n },\n main: {\n flex: 1,\n justifyContent: \"center\",\n maxWidth: 960,\n marginHorizontal: \"auto\",\n },\n title: {\n fontSize: 64,\n fontWeight: \"bold\",\n },\n subtitle: {\n fontSize: 36,\n color: \"#38434D\",\n },\n});\n`;\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"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLink.d.ts","sourceRoot":"","sources":["../src/useLink.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGjD,wBAAgB,OAAO,IAAI;IACzB,IAAI,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IAC3B,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,KAAK,EAAE,OAAO,WAAW,CAAC;CAC3B,CAiBA"}
|
package/build/useLink.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { useLinkTo, useNavigation } from "@react-navigation/native";
|
|
2
|
+
import { useMemo } from "react";
|
|
3
|
+
import { resolveHref } from "./views/Link";
|
|
4
|
+
// Wraps useLinkTo to provide an API which is similar to the Link component.
|
|
5
|
+
export function useLink() {
|
|
6
|
+
const linkTo = useLinkTo();
|
|
7
|
+
const navigation = useNavigation();
|
|
8
|
+
return useMemo(() => ({
|
|
9
|
+
push: (url) => {
|
|
10
|
+
const href = resolveHref(url);
|
|
11
|
+
linkTo(href);
|
|
12
|
+
},
|
|
13
|
+
back: () => navigation?.goBack(),
|
|
14
|
+
parse: resolveHref,
|
|
15
|
+
// TODO(EvanBacon): add `replace`, `pathname`, `query`, maybe `reload`
|
|
16
|
+
// TODO(EvanBacon): add `canGoBack` but maybe more like a `hasContext`
|
|
17
|
+
}), [navigation, linkTo]);
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=useLink.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLink.js","sourceRoot":"","sources":["../src/useLink.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAEhC,OAAO,EAAQ,WAAW,EAAE,MAAM,cAAc,CAAC;AAEjD,4EAA4E;AAC5E,MAAM,UAAU,OAAO;IAKrB,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;IAC3B,MAAM,UAAU,GAAG,aAAa,EAAE,CAAC;IAEnC,OAAO,OAAO,CACZ,GAAG,EAAE,CAAC,CAAC;QACL,IAAI,EAAE,CAAC,GAAS,EAAE,EAAE;YAClB,MAAM,IAAI,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC;YAC9B,MAAM,CAAC,IAAI,CAAC,CAAC;QACf,CAAC;QACD,IAAI,EAAE,GAAG,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE;QAChC,KAAK,EAAE,WAAW;QAClB,sEAAsE;QACtE,sEAAsE;KACvE,CAAC,EACF,CAAC,UAAU,EAAE,MAAM,CAAC,CACrB,CAAC;AACJ,CAAC","sourcesContent":["import { useLinkTo, useNavigation } from \"@react-navigation/native\";\nimport { useMemo } from \"react\";\n\nimport { Href, resolveHref } from \"./views/Link\";\n\n// Wraps useLinkTo to provide an API which is similar to the Link component.\nexport function useLink(): {\n push: (href: Href) => void;\n back: () => void;\n parse: typeof resolveHref;\n} {\n const linkTo = useLinkTo();\n const navigation = useNavigation();\n\n return useMemo(\n () => ({\n push: (url: Href) => {\n const href = resolveHref(url);\n linkTo(href);\n },\n back: () => navigation?.goBack(),\n parse: resolveHref,\n // TODO(EvanBacon): add `replace`, `pathname`, `query`, maybe `reload`\n // TODO(EvanBacon): add `canGoBack` but maybe more like a `hasContext`\n }),\n [navigation, linkTo]\n );\n}\n"]}
|
package/build/views/Link.d.ts
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
|
-
import
|
|
2
|
-
import * as React from
|
|
3
|
-
import { GestureResponderEvent } from
|
|
4
|
-
import {
|
|
5
|
-
import type { To } from
|
|
1
|
+
import { TextProps } from "@bacons/react-views";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { GestureResponderEvent } from "react-native";
|
|
4
|
+
import type { NavigationAction } from "@react-navigation/core";
|
|
5
|
+
import type { To } from "@react-navigation/native/src/useLinkTo";
|
|
6
|
+
export declare type Href = string | {
|
|
7
|
+
pathname?: string;
|
|
8
|
+
query?: Record<string, any>;
|
|
9
|
+
};
|
|
6
10
|
declare type Props<ParamList extends ReactNavigation.RootParamList> = {
|
|
11
|
+
/** Add a property which is familiar to */
|
|
12
|
+
href?: Href;
|
|
13
|
+
/** Forward props to child component. Useful for custom buttons. */
|
|
7
14
|
asChild?: boolean;
|
|
8
|
-
href?: string;
|
|
9
15
|
to?: To<ParamList>;
|
|
10
16
|
action?: NavigationAction;
|
|
11
17
|
target?: string;
|
|
@@ -22,5 +28,9 @@ declare type Props<ParamList extends ReactNavigation.RootParamList> = {
|
|
|
22
28
|
* @param props.children Child elements to render the content.
|
|
23
29
|
*/
|
|
24
30
|
export declare const Link: React.ForwardRefExoticComponent<Pick<Props<ReactNavigation.RootParamList>, "children" | "key" | "action" | "allowFontScaling" | "ellipsizeMode" | "lineBreakMode" | "numberOfLines" | "onLayout" | "onTextLayout" | "onPress" | "onPressIn" | "onPressOut" | "onLongPress" | "testID" | "nativeID" | "maxFontSizeMultiplier" | "adjustsFontSizeToFit" | "minimumFontScale" | "suppressHighlighting" | "selectable" | "selectionColor" | "textBreakStrategy" | "dataDetectorType" | "android_hyphenationFrequency" | "accessible" | "accessibilityActions" | "accessibilityLabel" | "accessibilityState" | "accessibilityHint" | "accessibilityValue" | "onAccessibilityAction" | "accessibilityLiveRegion" | "importantForAccessibility" | "accessibilityElementsHidden" | "accessibilityViewIsModal" | "onAccessibilityEscape" | "onAccessibilityTap" | "onMagicTap" | "accessibilityIgnoresInvertColors" | "asChild" | "to" | keyof import("@bacons/react-views/build/Text").WebTextProps> & React.RefAttributes<Text>>;
|
|
31
|
+
export declare const resolveHref: (href: {
|
|
32
|
+
pathname?: string;
|
|
33
|
+
query?: Record<string, any>;
|
|
34
|
+
} | string) => string;
|
|
25
35
|
export {};
|
|
26
36
|
//# sourceMappingURL=Link.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Link.d.ts","sourceRoot":"","sources":["../../src/views/Link.tsx"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"Link.d.ts","sourceRoot":"","sources":["../../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1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { useLinkProps
|
|
5
|
-
import
|
|
1
|
+
// Fork of @react-navigation/native Link.tsx
|
|
2
|
+
import { Text } from "@bacons/react-views";
|
|
3
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
4
|
+
import { useLinkProps } from "@react-navigation/native";
|
|
5
|
+
import * as React from "react";
|
|
6
|
+
import { Platform } from "react-native";
|
|
6
7
|
/**
|
|
7
8
|
* Component to render link to another screen using a path.
|
|
8
9
|
* Uses an anchor tag on the web.
|
|
@@ -12,22 +13,61 @@ import { Slot } from '@radix-ui/react-slot';
|
|
|
12
13
|
* @param props.children Child elements to render the content.
|
|
13
14
|
*/
|
|
14
15
|
export const Link = React.forwardRef(BaseLink);
|
|
15
|
-
|
|
16
|
+
export const resolveHref = (href) => {
|
|
17
|
+
if (typeof href === "string") {
|
|
18
|
+
return href ?? "";
|
|
19
|
+
}
|
|
20
|
+
const path = href.pathname ?? "";
|
|
21
|
+
if (!href?.query) {
|
|
22
|
+
return path;
|
|
23
|
+
}
|
|
24
|
+
const { pathname, query } = createQualifiedPathname(path, { ...href.query });
|
|
25
|
+
return pathname + (Object.keys(query).length ? `?${createQuery(query)}` : "");
|
|
26
|
+
};
|
|
27
|
+
function createQualifiedPathname(pathname, query) {
|
|
28
|
+
for (const [key, value = ""] of Object.entries(query)) {
|
|
29
|
+
const dynamicKey = `[${key}]`;
|
|
30
|
+
const deepDynamicKey = `[...${key}]`;
|
|
31
|
+
if (pathname.includes(dynamicKey)) {
|
|
32
|
+
pathname = pathname.replace(dynamicKey, Array.isArray(value) ? value.join("/") : value);
|
|
33
|
+
}
|
|
34
|
+
else if (pathname.includes(deepDynamicKey)) {
|
|
35
|
+
pathname = pathname.replace(deepDynamicKey, Array.isArray(value) ? value.join("/") : value);
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
delete query[key];
|
|
41
|
+
}
|
|
42
|
+
return { pathname, query };
|
|
43
|
+
}
|
|
44
|
+
function createQuery(query) {
|
|
45
|
+
return Object.keys(query)
|
|
46
|
+
.map((key) => `${key}=${query[key]}`)
|
|
47
|
+
.join("&");
|
|
48
|
+
}
|
|
49
|
+
function useResolvedHref({ href, to, }) {
|
|
16
50
|
// TODO: Auto use router's client-side event.
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
51
|
+
return React.useMemo(() => {
|
|
52
|
+
if (href) {
|
|
53
|
+
return resolveHref(href);
|
|
54
|
+
}
|
|
55
|
+
if (to == null) {
|
|
20
56
|
throw new Error(`You must specify either 'href' or 'to' prop in a <Link />.`);
|
|
21
57
|
}
|
|
22
|
-
if (typeof
|
|
58
|
+
if (typeof to === "string" && !to.startsWith("/")) {
|
|
23
59
|
// TODO: Auto delegate out external links
|
|
24
|
-
return
|
|
60
|
+
return "/";
|
|
25
61
|
}
|
|
26
|
-
return
|
|
62
|
+
return to;
|
|
27
63
|
}, [href, to]);
|
|
64
|
+
}
|
|
65
|
+
function BaseLink({ to, href, action, asChild, ...rest }, ref) {
|
|
66
|
+
// TODO: Auto use router's client-side event.
|
|
67
|
+
const resolvedTo = useResolvedHref({ href, to });
|
|
28
68
|
const props = useLinkProps({ to: resolvedTo, action });
|
|
29
69
|
const onPress = (e) => {
|
|
30
|
-
if (
|
|
70
|
+
if ("onPress" in rest) {
|
|
31
71
|
rest.onPress?.(e);
|
|
32
72
|
}
|
|
33
73
|
props.onPress(e);
|
package/build/views/Link.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Link.js","sourceRoot":"","sources":["../../src/views/Link.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Link.js","sourceRoot":"","sources":["../../src/views/Link.tsx"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,OAAO,EAAE,IAAI,EAAa,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CA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AQ,CACf,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,EAAoB,EACxD,GAA6B;IAE7B,6CAA6C;IAC7C,MAAM,UAAU,GAAG,eAAe,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;IAEjD,MAAM,KAAK,GAAG,YAAY,CAAY,EAAE,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC,CAAC;IAElE,MAAM,OAAO,GAAG,CACd,CAA0E,EAC1E,EAAE;QACF,IAAI,SAAS,IAAI,IAAI,EAAE;YACrB,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC;SACnB;QACD,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IACnB,CAAC,CAAC;IAEF,OAAO,KAAK,CAAC,aAAa;IACxB,0CAA0C;IAC1C,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EACrB;QACE,GAAG;QACH,GAAG,KAAK;QACR,GAAG,IAAI;QACP,GAAG,QAAQ,CAAC,MAAM,CAAC;YACjB,GAAG,EAAE,EAAE,OAAO,EAAE,OAAO,EAAS;YAChC,OAAO,EAAE,EAAE,OAAO,EAAE;SACrB,CAAC;KACH,CACF,CAAC;AACJ,CAAC","sourcesContent":["// Fork of @react-navigation/native Link.tsx\nimport { Text, TextProps } from \"@bacons/react-views\";\nimport { Slot } from \"@radix-ui/react-slot\";\nimport { useLinkProps } from \"@react-navigation/native\";\nimport * as React from \"react\";\nimport { GestureResponderEvent, Platform } from \"react-native\";\n\nimport type { NavigationAction } from \"@react-navigation/core\";\nimport type { To } from \"@react-navigation/native/src/useLinkTo\";\n\nexport type Href = string | { pathname?: string; query?: Record<string, any> };\n\ntype Props<ParamList extends ReactNavigation.RootParamList> = {\n /** Add a property which is familiar to */\n href?: Href;\n\n /** Forward props to child component. Useful for custom buttons. */\n asChild?: boolean;\n\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\nexport const resolveHref = (\n href: { pathname?: string; query?: Record<string, any> } | string\n): string => {\n if (typeof href === \"string\") {\n return href ?? \"\";\n }\n const path = href.pathname ?? \"\";\n if (!href?.query) {\n return path;\n }\n const { pathname, query } = createQualifiedPathname(path, { ...href.query });\n return pathname + (Object.keys(query).length ? `?${createQuery(query)}` : \"\");\n};\n\nfunction createQualifiedPathname(pathname: string, query: Record<string, any>) {\n for (const [key, value = \"\"] of Object.entries(query)) {\n const dynamicKey = `[${key}]`;\n const deepDynamicKey = `[...${key}]`;\n if (pathname.includes(dynamicKey)) {\n pathname = pathname.replace(\n dynamicKey,\n Array.isArray(value) ? value.join(\"/\") : value\n );\n } else if (pathname.includes(deepDynamicKey)) {\n pathname = pathname.replace(\n deepDynamicKey,\n Array.isArray(value) ? value.join(\"/\") : value\n );\n } else {\n continue;\n }\n\n delete query[key];\n }\n return { pathname, query };\n}\n\nfunction createQuery(query: Record<string, any>) {\n return Object.keys(query)\n .map((key) => `${key}=${query[key]}`)\n .join(\"&\");\n}\n\nfunction useResolvedHref<ParamList extends ReactNavigation.RootParamList>({\n href,\n to,\n}: Pick<Props<ParamList>, \"href\" | \"to\">) {\n // TODO: Auto use router's client-side event.\n return React.useMemo(() => {\n if (href) {\n return resolveHref(href);\n }\n\n if (to == null) {\n throw new Error(\n `You must specify either 'href' or 'to' prop in a <Link />.`\n );\n }\n if (typeof to === \"string\" && !to.startsWith(\"/\")) {\n // TODO: Auto delegate out external links\n return \"/\";\n }\n return to;\n }, [href, to]);\n}\n\nfunction BaseLink<ParamList extends ReactNavigation.RootParamList>(\n { to, href, action, asChild, ...rest }: Props<ParamList>,\n ref: React.ForwardedRef<Text>\n) {\n // TODO: Auto use router's client-side event.\n const resolvedTo = useResolvedHref({ href, to });\n\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 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}\n"]}
|
package/build/views/Unmatched.js
CHANGED
|
@@ -8,7 +8,7 @@ export const Unmatched = forwardRef((props, ref) => {
|
|
|
8
8
|
const url = createURL("");
|
|
9
9
|
return (
|
|
10
10
|
// @ts-ignore
|
|
11
|
-
React.createElement(View, { ref: ref,
|
|
11
|
+
React.createElement(View, { ref: ref, style: styles.container },
|
|
12
12
|
React.createElement(Text, { accessibilityRole: "header", accessibilityLevel: 1, style: styles.title }, "Unmatched Route"),
|
|
13
13
|
React.createElement(Text, { accessibilityRole: "header", accessibilityLevel: 2, style: styles.subtitle },
|
|
14
14
|
"Page could not be found.",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Unmatched.js","sourceRoot":"","sources":["../../src/views/Unmatched.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAEjD,2CAA2C;AAC3C,MAAM,CAAC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GAAG,CACD;QAEN,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa,IAAI,CACvC,oBAAC,IAAI,IAAC,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,CAAC,IAAI,cAEnC,CACV,CACE,CACV,CAAC;AACN,CAAC,CAAC,CAAC;AAEH,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IAC7B,SAAS,EAAE;QACP,IAAI,EAAE,CAAC;QACP,eAAe,EAAE,OAAO;QACxB,OAAO,EAAE,EAAE;QACX,UAAU,EAAE,QAAQ;QACpB,cAAc,EAAE,QAAQ;KAC3B;IACD,KAAK,EAAE;QACH,KAAK,EAAE,OAAO;QACd,QAAQ,EAAE,EAAE;QACZ,aAAa,EAAE,EAAE;QACjB,YAAY,EAAE,EAAE;QAChB,iBAAiB,EAAE,SAAS;QAC5B,iBAAiB,EAAE,CAAC;QACpB,SAAS,EAAE,QAAQ;QACnB,UAAU,EAAE,MAAM;KACrB;IACD,QAAQ,EAAE;QACN,KAAK,EAAE,OAAO;QACd,QAAQ,EAAE,EAAE;QACZ,YAAY,EAAE,EAAE;QAChB,SAAS,EAAE,QAAQ;KACtB;IACD,IAAI,EAAE,EAAE,KAAK,EAAE,uBAAuB,EAAE,SAAS,EAAE,QAAQ,EAAE;CAChE,CAAC,CAAC","sourcesContent":["import React, { forwardRef } from \"react\";\nimport { createURL } from \"expo-linking\";\nimport { StyleSheet } from \"@bacons/react-views\";\nimport { Link } from \"./Link\";\nimport { Text, View } from \"@bacons/react-views\";\n\n/** Default screen for unmatched routes. */\nexport const Unmatched = forwardRef((props, ref) => {\n const url = createURL(\"\");\n return (\n // @ts-ignore\n <View ref={ref} style={styles.container}>\n <Text\n accessibilityRole=\"header\"\n accessibilityLevel={1}\n style={styles.title}\n >\n Unmatched Route\n </Text>\n <Text\n accessibilityRole=\"header\"\n accessibilityLevel={2}\n style={styles.subtitle}\n >\n Page could not be found.{\" \"}\n <Link href=\"/\" style={styles.link}>\n Go back.\n </Link>\n </Text>\n\n <Link href={\"/\"} style={styles.link}>\n {url}\n </Link>\n\n {process.env.NODE_ENV === \"development\" && (\n <Link href={\"/__index\"} style={styles.link}>\n Sitemap\n </Link>\n )}\n </View>\n );\n});\n\nconst styles = StyleSheet.create({\n container: {\n flex: 1,\n backgroundColor: \"black\",\n padding: 24,\n alignItems: \"center\",\n justifyContent: \"center\",\n },\n title: {\n color: \"white\",\n fontSize: 36,\n paddingBottom: 12,\n marginBottom: 12,\n borderBottomColor: \"#323232\",\n borderBottomWidth: 1,\n textAlign: \"center\",\n fontWeight: \"bold\",\n },\n subtitle: {\n color: \"white\",\n fontSize: 18,\n marginBottom: 12,\n textAlign: \"center\",\n },\n link: { color: \"rgba(255,255,255,0.4)\", textAlign: \"center\" },\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.14",
|
|
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"]}
|