expo-router 1.2.2 → 1.3.0
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/_root.tsx +1 -1
- package/build/ExpoRoot.d.ts +6 -0
- package/build/ExpoRoot.d.ts.map +1 -0
- package/build/LocationProvider.d.ts +25 -0
- package/build/LocationProvider.d.ts.map +1 -0
- package/build/NavigationContainer.d.ts +8 -0
- package/build/NavigationContainer.d.ts.map +1 -0
- package/build/Route.d.ts +34 -0
- package/build/Route.d.ts.map +1 -0
- package/build/exports.d.ts +15 -0
- package/build/exports.d.ts.map +1 -0
- package/build/fork/NavigationContainer.d.ts +3 -0
- package/build/fork/NavigationContainer.d.ts.map +1 -0
- package/build/fork/NavigationContainer.native.d.ts +26 -0
- package/build/fork/NavigationContainer.native.d.ts.map +1 -0
- package/build/fork/expo/createRoot.d.ts +2 -0
- package/build/fork/expo/createRoot.d.ts.map +1 -0
- package/build/fork/expo/createRoot.native.d.ts +3 -0
- package/build/fork/expo/createRoot.native.d.ts.map +1 -0
- package/build/fork/expo/registerRootComponent.d.ts +16 -0
- package/build/fork/expo/registerRootComponent.d.ts.map +1 -0
- package/build/fork/extractPathFromURL.d.ts +2 -0
- package/build/fork/extractPathFromURL.d.ts.map +1 -0
- package/build/fork/getPathFromState.d.ts +50 -0
- package/build/fork/getPathFromState.d.ts.map +1 -0
- package/build/fork/getStateFromPath.d.ts +33 -0
- package/build/fork/getStateFromPath.d.ts.map +1 -0
- package/build/fork/useLinking.d.ts +3 -0
- package/build/fork/useLinking.d.ts.map +1 -0
- package/build/fork/useLinking.native.d.ts +49 -0
- package/build/fork/useLinking.native.d.ts.map +1 -0
- package/build/getDevServer/index.d.ts +7 -0
- package/build/getDevServer/index.d.ts.map +1 -0
- package/build/getDevServer/index.native.d.ts +2 -0
- package/build/getDevServer/index.native.d.ts.map +1 -0
- package/build/getLinkingConfig.d.ts +15 -0
- package/build/getLinkingConfig.d.ts.map +1 -0
- package/build/getRoutes.d.ts +33 -0
- package/build/getRoutes.d.ts.map +1 -0
- package/build/head/Head.d.ts +7 -0
- package/build/head/Head.d.ts.map +1 -0
- package/build/head/Head.native.d.ts +11 -0
- package/build/head/Head.native.d.ts.map +1 -0
- package/build/index.d.ts +4 -0
- package/build/index.d.ts.map +1 -0
- package/build/layouts/Drawer.d.ts +107 -0
- package/build/layouts/Drawer.d.ts.map +1 -0
- package/build/layouts/Stack.d.ts +107 -0
- package/build/layouts/Stack.d.ts.map +1 -0
- package/build/layouts/Tabs.d.ts +154 -0
- package/build/layouts/Tabs.d.ts.map +1 -0
- package/build/layouts/withLayoutContext.d.ts +16 -0
- package/build/layouts/withLayoutContext.d.ts.map +1 -0
- package/build/link/Link.d.ts +33 -0
- package/build/link/Link.d.ts.map +1 -0
- package/build/link/href.d.ts +10 -0
- package/build/link/href.d.ts.map +1 -0
- package/build/link/linking.d.ts +7 -0
- package/build/link/linking.d.ts.map +1 -0
- package/build/link/path.d.ts +2 -0
- package/build/link/path.d.ts.map +1 -0
- package/build/link/stateOperations.d.ts +81 -0
- package/build/link/stateOperations.d.ts.map +1 -0
- package/build/link/useHref.d.ts +10 -0
- package/build/link/useHref.d.ts.map +1 -0
- package/build/link/useLinkToPath.d.ts +6 -0
- package/build/link/useLinkToPath.d.ts.map +1 -0
- package/build/link/useLinkToPathProps.d.ts +11 -0
- package/build/link/useLinkToPathProps.d.ts.map +1 -0
- package/build/link/useLinkingContext.d.ts +7 -0
- package/build/link/useLinkingContext.d.ts.map +1 -0
- package/build/link/useLoadedNavigation.d.ts +7 -0
- package/build/link/useLoadedNavigation.d.ts.map +1 -0
- package/build/link/useRouter.d.ts +15 -0
- package/build/link/useRouter.d.ts.map +1 -0
- package/build/matchers.d.ts +12 -0
- package/build/matchers.d.ts.map +1 -0
- package/build/onboard/Tutorial.d.ts +3 -0
- package/build/onboard/Tutorial.d.ts.map +1 -0
- package/build/onboard/createEntryFile.d.ts +3 -0
- package/build/onboard/createEntryFile.d.ts.map +1 -0
- package/build/onboard/useTutorial.d.ts +4 -0
- package/build/onboard/useTutorial.d.ts.map +1 -0
- package/build/primitives.d.ts +19 -0
- package/build/primitives.d.ts.map +1 -0
- package/build/renderRootComponent.d.ts +7 -0
- package/build/renderRootComponent.d.ts.map +1 -0
- package/build/static/renderStaticContent.d.ts +8 -0
- package/build/static/renderStaticContent.d.ts.map +1 -0
- package/build/static/useServerState.d.ts +42 -0
- package/build/static/useServerState.d.ts.map +1 -0
- package/build/static/useServerState.native.d.ts +2 -0
- package/build/static/useServerState.native.d.ts.map +1 -0
- package/build/types.d.ts +13 -0
- package/build/types.d.ts.map +1 -0
- package/build/useFocusEffect.d.ts +11 -0
- package/build/useFocusEffect.d.ts.map +1 -0
- package/build/useInitialRootState.d.ts +42 -0
- package/build/useInitialRootState.d.ts.map +1 -0
- package/build/useInitialRootState.native.d.ts +3 -0
- package/build/useInitialRootState.native.d.ts.map +1 -0
- package/build/useInitialRootStateContext.d.ts +13 -0
- package/build/useInitialRootStateContext.d.ts.map +1 -0
- package/build/useNavigation.d.ts +9 -0
- package/build/useNavigation.d.ts.map +1 -0
- package/build/useRootNavigation.d.ts +9 -0
- package/build/useRootNavigation.d.ts.map +1 -0
- package/build/useRootRouteNodeContext.d.ts +11 -0
- package/build/useRootRouteNodeContext.d.ts.map +1 -0
- package/build/useScreens.d.ts +27 -0
- package/build/useScreens.d.ts.map +1 -0
- package/build/utils/mockState.d.ts +11 -0
- package/build/utils/mockState.d.ts.map +1 -0
- package/build/views/ErrorBoundary.d.ts +4 -0
- package/build/views/ErrorBoundary.d.ts.map +1 -0
- package/build/views/Navigator.d.ts +280 -0
- package/build/views/Navigator.d.ts.map +1 -0
- package/build/views/Screen.d.ts +19 -0
- package/build/views/Screen.d.ts.map +1 -0
- package/build/views/Sitemap.d.ts +5 -0
- package/build/views/Sitemap.d.ts.map +1 -0
- package/build/views/Splash.d.ts +26 -0
- package/build/views/Splash.d.ts.map +1 -0
- package/build/views/Try.d.ts +24 -0
- package/build/views/Try.d.ts.map +1 -0
- package/build/views/Unmatched.d.ts +4 -0
- package/build/views/Unmatched.d.ts.map +1 -0
- package/package.json +6 -5
- package/src/fork/getStateFromPath.ts +1 -2
- package/src/link/Link.tsx +12 -7
- package/src/link/href.ts +2 -2
- package/src/link/stateOperations.ts +22 -14
- package/src/link/useLinkToPath.ts +3 -7
- package/src/ts-declarations.d.ts +1 -0
- package/src/useFocusEffect.tsx +1 -1
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A stack based component for keeping the splash screen visible.
|
|
3
|
+
* Useful for stacked requests that need to be completed before the app is ready.
|
|
4
|
+
* After all instances have been unmounted, the splash screen will be hidden.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```tsx
|
|
8
|
+
* function App() {
|
|
9
|
+
* const [isLoading, setIsLoading] = React.useState(true);
|
|
10
|
+
*
|
|
11
|
+
* if (isLoading) {
|
|
12
|
+
* return <SplashScreen />
|
|
13
|
+
* }
|
|
14
|
+
*
|
|
15
|
+
* return <Text>Ready!</Text>
|
|
16
|
+
* }
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export declare function SplashScreen(): null;
|
|
20
|
+
export declare namespace SplashScreen {
|
|
21
|
+
var hideAsync: () => void;
|
|
22
|
+
var preventAutoHideAsync: () => void;
|
|
23
|
+
var _pushEntry: () => any;
|
|
24
|
+
var _popEntry: (entry: string) => void;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=Splash.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Splash.d.ts","sourceRoot":"","sources":["../../src/views/Splash.tsx"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,YAAY,SAG3B;yBAHe,YAAY"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
/** Props passed to a page's `ErrorBoundary` export. */
|
|
3
|
+
export type ErrorBoundaryProps = {
|
|
4
|
+
/** Retry rendering the component by clearing the `error` state. */
|
|
5
|
+
retry: () => Promise<void>;
|
|
6
|
+
/** The error that was thrown. */
|
|
7
|
+
error: Error;
|
|
8
|
+
};
|
|
9
|
+
export declare class Try extends React.Component<{
|
|
10
|
+
catch: React.ComponentType<ErrorBoundaryProps>;
|
|
11
|
+
children: React.ReactNode;
|
|
12
|
+
}, {
|
|
13
|
+
error?: Error;
|
|
14
|
+
}> {
|
|
15
|
+
state: {
|
|
16
|
+
error: undefined;
|
|
17
|
+
};
|
|
18
|
+
static getDerivedStateFromError(error: Error): {
|
|
19
|
+
error: Error;
|
|
20
|
+
};
|
|
21
|
+
retry: () => Promise<void>;
|
|
22
|
+
render(): string | number | boolean | React.ReactFragment | JSX.Element | null | undefined;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=Try.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Try.d.ts","sourceRoot":"","sources":["../../src/views/Try.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,uDAAuD;AACvD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,mEAAmE;IACnE,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3B,iCAAiC;IACjC,KAAK,EAAE,KAAK,CAAC;CACd,CAAC;AAGF,qBAAa,GAAI,SAAQ,KAAK,CAAC,SAAS,CACtC;IACE,KAAK,EAAE,KAAK,CAAC,aAAa,CAAC,kBAAkB,CAAC,CAAC;IAC/C,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,EACD;IAAE,KAAK,CAAC,EAAE,KAAK,CAAA;CAAE,CAClB;IACC,KAAK;;MAAwB;IAE7B,MAAM,CAAC,wBAAwB,CAAC,KAAK,EAAE,KAAK;;;IAO5C,KAAK,sBAMH;IAEF,MAAM;CAQP"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Unmatched.d.ts","sourceRoot":"","sources":["../../src/views/Unmatched.tsx"],"names":[],"mappings":";AAQA,2CAA2C;AAC3C,wBAAgB,SAAS,gBAwCxB"}
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-router",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"main": "src/index.tsx",
|
|
5
|
-
"types": "
|
|
5
|
+
"types": "build/index.d.ts",
|
|
6
6
|
"files": [
|
|
7
7
|
"src",
|
|
8
|
+
"build",
|
|
8
9
|
"node",
|
|
9
10
|
"entry.js",
|
|
10
11
|
"_root.tsx",
|
|
@@ -26,12 +27,12 @@
|
|
|
26
27
|
},
|
|
27
28
|
"homepage": "https://expo.github.io/router/docs/",
|
|
28
29
|
"scripts": {
|
|
29
|
-
"build": "expo-module typecheck",
|
|
30
|
+
"build": "expo-module typecheck --noEmit false",
|
|
30
31
|
"clean": "expo-module clean",
|
|
31
32
|
"lint": "expo-module lint",
|
|
32
33
|
"test": "expo-module test",
|
|
33
34
|
"prepare": "expo-module prepare",
|
|
34
|
-
"prepublishOnly": "expo-module prepublishOnly",
|
|
35
|
+
"prepublishOnly": "expo-module prepublishOnly && expo-module typecheck --noEmit false",
|
|
35
36
|
"expo-module": "expo-module"
|
|
36
37
|
},
|
|
37
38
|
"keywords": [
|
|
@@ -73,7 +74,7 @@
|
|
|
73
74
|
},
|
|
74
75
|
"dependencies": {
|
|
75
76
|
"@bacons/react-views": "^1.1.3",
|
|
76
|
-
"@expo/metro-runtime": "1.1.
|
|
77
|
+
"@expo/metro-runtime": "1.1.1",
|
|
77
78
|
"@radix-ui/react-slot": "^1.0.0",
|
|
78
79
|
"@react-navigation/bottom-tabs": "~6.5.7",
|
|
79
80
|
"@react-navigation/native": "~6.1.6",
|
|
@@ -472,8 +472,7 @@ const createNormalizedConfigs = (
|
|
|
472
472
|
|
|
473
473
|
parentScreens.push(screen);
|
|
474
474
|
|
|
475
|
-
|
|
476
|
-
const config = routeConfig[screen];
|
|
475
|
+
const config = (routeConfig as any)[screen];
|
|
477
476
|
|
|
478
477
|
if (typeof config === "string") {
|
|
479
478
|
// If a string is specified as the value of the key(e.g. Foo: '/path'), use it as the pattern
|
package/src/link/Link.tsx
CHANGED
|
@@ -10,7 +10,7 @@ import useLinkToPathProps from "./useLinkToPathProps";
|
|
|
10
10
|
import { useRouter } from "./useRouter";
|
|
11
11
|
import { useFocusEffect } from "../useFocusEffect";
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
export interface LinkProps extends Omit<TextProps, "href" | "hoverStyle"> {
|
|
14
14
|
/** Path to route to. */
|
|
15
15
|
href: Href;
|
|
16
16
|
|
|
@@ -24,7 +24,7 @@ type Props = {
|
|
|
24
24
|
onPress?: (
|
|
25
25
|
e: React.MouseEvent<HTMLAnchorElement, MouseEvent> | GestureResponderEvent
|
|
26
26
|
) => void;
|
|
27
|
-
}
|
|
27
|
+
}
|
|
28
28
|
|
|
29
29
|
/** Redirects to the href as soon as the component is mounted. */
|
|
30
30
|
export function Redirect({ href }: { href: Href }) {
|
|
@@ -35,6 +35,12 @@ export function Redirect({ href }: { href: Href }) {
|
|
|
35
35
|
return null;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
+
export interface LinkComponent {
|
|
39
|
+
(props: React.PropsWithChildren<LinkProps>): JSX.Element;
|
|
40
|
+
/** Helper method to resolve an Href object into a string. */
|
|
41
|
+
resolveHref: typeof resolveHref;
|
|
42
|
+
}
|
|
43
|
+
|
|
38
44
|
/**
|
|
39
45
|
* Component to render link to another route using a path.
|
|
40
46
|
* Uses an anchor tag on the web.
|
|
@@ -44,10 +50,9 @@ export function Redirect({ href }: { href: Href }) {
|
|
|
44
50
|
* @param props.asChild Forward props to child component. Useful for custom buttons.
|
|
45
51
|
* @param props.children Child elements to render the content.
|
|
46
52
|
*/
|
|
47
|
-
export const Link = React.forwardRef(
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
} & React.ForwardRefExoticComponent<Props>;
|
|
53
|
+
export const Link = React.forwardRef(
|
|
54
|
+
ExpoRouterLink
|
|
55
|
+
) as unknown as LinkComponent;
|
|
51
56
|
|
|
52
57
|
Link.resolveHref = resolveHref;
|
|
53
58
|
|
|
@@ -58,7 +63,7 @@ function ExpoRouterLink(
|
|
|
58
63
|
// TODO: This does not prevent default on the anchor tag.
|
|
59
64
|
asChild,
|
|
60
65
|
...rest
|
|
61
|
-
}:
|
|
66
|
+
}: LinkProps,
|
|
62
67
|
ref: React.ForwardedRef<Text>
|
|
63
68
|
) {
|
|
64
69
|
const resolvedHref = React.useMemo(() => {
|
package/src/link/href.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
export type Href = string | HrefObject;
|
|
2
2
|
|
|
3
|
-
export
|
|
3
|
+
export interface HrefObject {
|
|
4
4
|
/** Path representing the selected route `/[id]`. */
|
|
5
5
|
pathname?: string;
|
|
6
6
|
/** Query parameters for the path. */
|
|
7
7
|
params?: Record<string, any>;
|
|
8
|
-
}
|
|
8
|
+
}
|
|
9
9
|
|
|
10
10
|
/** Resolve an href object into a fully qualified, relative href. */
|
|
11
11
|
export const resolveHref = (href: Href): string => {
|
|
@@ -1,12 +1,25 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
InitialState,
|
|
3
|
+
NavigationState,
|
|
4
|
+
ParamListBase,
|
|
5
|
+
getActionFromState,
|
|
6
|
+
} from "@react-navigation/native";
|
|
2
7
|
|
|
3
8
|
import { ResultState } from "../fork/getStateFromPath";
|
|
4
9
|
|
|
5
|
-
export type
|
|
6
|
-
|
|
10
|
+
export type NavigateAction = Extract<
|
|
11
|
+
ReturnType<typeof getActionFromState>,
|
|
12
|
+
{ type: "NAVIGATE" }
|
|
13
|
+
> & {
|
|
14
|
+
payload: NavigateActionParams;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export type NavigateActionParams = {
|
|
18
|
+
params?: NavigateActionParams;
|
|
7
19
|
path: string;
|
|
8
20
|
initial: boolean;
|
|
9
21
|
screen: string;
|
|
22
|
+
name?: string;
|
|
10
23
|
};
|
|
11
24
|
|
|
12
25
|
// Get the last state for a given target state (generated from a path).
|
|
@@ -95,19 +108,12 @@ export function getQualifiedStateForTopOfTargetState(
|
|
|
95
108
|
return currentRoot;
|
|
96
109
|
}
|
|
97
110
|
|
|
98
|
-
type SubState = NavigationState & {
|
|
99
|
-
key?: string;
|
|
100
|
-
type: string;
|
|
101
|
-
routes?: { name: string; state?: SubState }[];
|
|
102
|
-
index?: number;
|
|
103
|
-
};
|
|
104
|
-
|
|
105
111
|
// Given the root state and a target state from `getStateFromPath`,
|
|
106
112
|
// return the root state containing the highest target route matching the root state.
|
|
107
113
|
// This can be used to determine what type of navigator action should be used.
|
|
108
|
-
export function getEarliestMismatchedRoute(
|
|
109
|
-
rootState:
|
|
110
|
-
actionParams:
|
|
114
|
+
export function getEarliestMismatchedRoute<T extends ParamListBase>(
|
|
115
|
+
rootState: NavigationState<T> | undefined,
|
|
116
|
+
actionParams: NavigateActionParams
|
|
111
117
|
): { name: string; params?: any; type?: string } | null {
|
|
112
118
|
const actionName = actionParams.name ?? actionParams.screen;
|
|
113
119
|
if (!rootState?.routes || rootState.index == null) {
|
|
@@ -126,7 +132,9 @@ export function getEarliestMismatchedRoute(
|
|
|
126
132
|
}
|
|
127
133
|
|
|
128
134
|
return getEarliestMismatchedRoute(
|
|
129
|
-
|
|
135
|
+
// @react-navigation/native types this as NavigationState | Partial<NavigationState> | undefined
|
|
136
|
+
// In our usage, it's always a NavigationState | undefined
|
|
137
|
+
nextCurrentRoot.state as NavigationState<T> | undefined,
|
|
130
138
|
actionParams.params
|
|
131
139
|
);
|
|
132
140
|
}
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
getEarliestMismatchedRoute,
|
|
15
15
|
getQualifiedStateForTopOfTargetState,
|
|
16
16
|
isMovingToSiblingRoute,
|
|
17
|
+
NavigateAction,
|
|
17
18
|
} from "./stateOperations";
|
|
18
19
|
import { useLinkingContext } from "./useLinkingContext";
|
|
19
20
|
|
|
@@ -116,14 +117,9 @@ export function useLinkToPath() {
|
|
|
116
117
|
// Then find the nearest mismatched route in the existing state.
|
|
117
118
|
// Finally, use the correct navigator-based action to replace the nested screens.
|
|
118
119
|
// NOTE(EvanBacon): A future version of this will involve splitting the navigation request so we replace as much as possible, then push the remaining screens to fulfill the request.
|
|
119
|
-
if (
|
|
120
|
-
event === "REPLACE" &&
|
|
121
|
-
action.type === "NAVIGATE" &&
|
|
122
|
-
isAbsoluteInitialRoute(action)
|
|
123
|
-
) {
|
|
120
|
+
if (event === "REPLACE" && isAbsoluteInitialRoute(action)) {
|
|
124
121
|
const earliest = getEarliestMismatchedRoute(
|
|
125
122
|
rootState,
|
|
126
|
-
// @ts-expect-error
|
|
127
123
|
action.payload
|
|
128
124
|
);
|
|
129
125
|
if (earliest) {
|
|
@@ -159,7 +155,7 @@ export function useLinkToPath() {
|
|
|
159
155
|
/** @returns `true` if the action is moving to the first screen of all the navigators in the action. */
|
|
160
156
|
export function isAbsoluteInitialRoute(
|
|
161
157
|
action: ReturnType<typeof getActionFromState>
|
|
162
|
-
) {
|
|
158
|
+
): action is NavigateAction {
|
|
163
159
|
if (action?.type !== "NAVIGATE") {
|
|
164
160
|
return false;
|
|
165
161
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/// <reference path="../../../ts-declarations/index.d.ts" />
|
package/src/useFocusEffect.tsx
CHANGED