expo-router 2.0.1 → 2.0.2
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.
|
@@ -14,7 +14,6 @@ export declare class RouterStore {
|
|
|
14
14
|
routeNode: RouteNode | null;
|
|
15
15
|
rootComponent: ComponentType;
|
|
16
16
|
linking: ExpoLinkingOptions | undefined;
|
|
17
|
-
isReady: boolean;
|
|
18
17
|
private hasAttemptedToHideSplash;
|
|
19
18
|
initialState: ResultState | undefined;
|
|
20
19
|
rootState: ResultState | undefined;
|
|
@@ -36,7 +35,6 @@ export declare class RouterStore {
|
|
|
36
35
|
getRouteInfo(state: ResultState): UrlObject;
|
|
37
36
|
shouldShowTutorial(): boolean;
|
|
38
37
|
/** Make sure these are arrow functions so `this` is correctly bound */
|
|
39
|
-
onReady: () => void;
|
|
40
38
|
subscribeToRootState: (subscriber: () => void) => () => boolean;
|
|
41
39
|
subscribeToStore: (subscriber: () => void) => () => boolean;
|
|
42
40
|
snapshot: () => this;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router-store.d.ts","sourceRoot":"","sources":["../../src/global-state/router-store.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,iCAAiC,EAGlC,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAiC,aAAa,EAAY,MAAM,OAAO,CAAC;AAE/E,OAAO,EAAE,SAAS,EAAyB,MAAM,qBAAqB,CAAC;AACvE,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAErC,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAoB,MAAM,qBAAqB,CAAC;AAE3E,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAM1C;;;;GAIG;AACH,qBAAa,WAAW;IACtB,SAAS,EAAG,SAAS,GAAG,IAAI,CAAC;IAC7B,aAAa,EAAG,aAAa,CAAC;IAC9B,OAAO,EAAE,kBAAkB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AC,aAAa,CAAC,EAC/E,eAAe,CAAC,EAAE,GAAG;IAiGvB,WAAW,CAAC,KAAK,EAAE,WAAW,EAAE,SAAS,cAAQ;IAWjD,YAAY,CAAC,KAAK,EAAE,WAAW;IAgB/B,kBAAkB;IAIlB,uEAAuE;IACvE,oBAAoB,eAAgB,MAAM,IAAI,mBAG5C;IACF,gBAAgB,eAAgB,MAAM,IAAI,mBAGxC;IACF,QAAQ,aAEN;IACF,iBAAiB,oBAEf;IACF,iBAAiB,kBAEf;CACH;AAED,eAAO,MAAM,KAAK,aAAoB,CAAC;AAEvC,wBAAgB,aAAa,gBAM5B;AAaD,wBAAgB,iBAAiB,gBAOhC;AAED,wBAAgB,iBAAiB,cAOhC;AAED,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,cAAc,EACvB,eAAe,EAAE,GAAG,GAAG,SAAS,eASjC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routing.d.ts","sourceRoot":"","sources":["../../src/global-state/routing.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,kBAAkB,EAEnB,MAAM,wBAAwB,CAAC;AAIhC,OAAO,EAAE,IAAI,EAAe,MAAM,cAAc,CAAC;AAEjD,OAAO,EACL,cAAc,EAKf,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAUlD,wBAAgB,IAAI,CAAC,IAAI,EAAE,WAAW,EAAE,GAAG,EAAE,IAAI,QAEhD;AAED,wBAAgB,OAAO,CAAC,IAAI,EAAE,WAAW,EAAE,GAAG,EAAE,IAAI,QAEnD;AAED,wBAAgB,MAAM,CAAC,IAAI,EAAE,WAAW,QAGvC;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,
|
|
1
|
+
{"version":3,"file":"routing.d.ts","sourceRoot":"","sources":["../../src/global-state/routing.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,kBAAkB,EAEnB,MAAM,wBAAwB,CAAC;AAIhC,OAAO,EAAE,IAAI,EAAe,MAAM,cAAc,CAAC;AAEjD,OAAO,EACL,cAAc,EAKf,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAUlD,wBAAgB,IAAI,CAAC,IAAI,EAAE,WAAW,EAAE,GAAG,EAAE,IAAI,QAEhD;AAED,wBAAgB,OAAO,CAAC,IAAI,EAAE,WAAW,EAAE,GAAG,EAAE,IAAI,QAEnD;AAED,wBAAgB,MAAM,CAAC,IAAI,EAAE,WAAW,QAGvC;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAKpD;AAED,wBAAgB,SAAS,CACvB,IAAI,EAAE,WAAW,EACjB,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAM,OAI7C;AAED,wBAAgB,MAAM,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,QA6HrE;AAED,uGAAuG;AACvG,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,UAAU,CAAC,OAAO,kBAAkB,CAAC,GAC5C,MAAM,IAAI,cAAc,CAqB1B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-router",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2",
|
|
4
4
|
"main": "src/index.tsx",
|
|
5
5
|
"types": "build/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -104,7 +104,7 @@
|
|
|
104
104
|
},
|
|
105
105
|
"dependencies": {
|
|
106
106
|
"@bacons/react-views": "^1.1.3",
|
|
107
|
-
"@expo/metro-runtime": "2.2.
|
|
107
|
+
"@expo/metro-runtime": "2.2.5",
|
|
108
108
|
"@radix-ui/react-slot": "1.0.1",
|
|
109
109
|
"@react-navigation/bottom-tabs": "~6.5.7",
|
|
110
110
|
"@react-navigation/native": "~6.1.6",
|
|
@@ -26,7 +26,6 @@ export class RouterStore {
|
|
|
26
26
|
routeNode!: RouteNode | null;
|
|
27
27
|
rootComponent!: ComponentType;
|
|
28
28
|
linking: ExpoLinkingOptions | undefined;
|
|
29
|
-
isReady: boolean = false;
|
|
30
29
|
private hasAttemptedToHideSplash: boolean = false;
|
|
31
30
|
|
|
32
31
|
initialState: ResultState | undefined;
|
|
@@ -54,7 +53,6 @@ export class RouterStore {
|
|
|
54
53
|
initialLocation?: URL
|
|
55
54
|
) {
|
|
56
55
|
// Clean up any previous state
|
|
57
|
-
this.isReady ||= Boolean(initialLocation);
|
|
58
56
|
this.initialState = undefined;
|
|
59
57
|
this.rootState = undefined;
|
|
60
58
|
this.nextState = undefined;
|
|
@@ -119,16 +117,10 @@ export class RouterStore {
|
|
|
119
117
|
(data) => {
|
|
120
118
|
const state = data.data.state as ResultState;
|
|
121
119
|
|
|
122
|
-
if (!this.
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
requestAnimationFrame(() => _internal_maybeHideAsync());
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
if (navigationRef.isReady()) {
|
|
130
|
-
this.onReady();
|
|
131
|
-
}
|
|
120
|
+
if (!this.hasAttemptedToHideSplash) {
|
|
121
|
+
this.hasAttemptedToHideSplash = true;
|
|
122
|
+
// NOTE(EvanBacon): `navigationRef.isReady` is sometimes not true when state is called initially.
|
|
123
|
+
requestAnimationFrame(() => _internal_maybeHideAsync());
|
|
132
124
|
}
|
|
133
125
|
|
|
134
126
|
let shouldUpdateSubscribers = this.nextState === state;
|
|
@@ -187,9 +179,6 @@ export class RouterStore {
|
|
|
187
179
|
}
|
|
188
180
|
|
|
189
181
|
/** Make sure these are arrow functions so `this` is correctly bound */
|
|
190
|
-
onReady = () => {
|
|
191
|
-
this.isReady = true;
|
|
192
|
-
};
|
|
193
182
|
subscribeToRootState = (subscriber: () => void) => {
|
|
194
183
|
this.rootStateSubscribers.add(subscriber);
|
|
195
184
|
return () => this.rootStateSubscribers.delete(subscriber);
|
|
@@ -19,7 +19,7 @@ import { hasUrlProtocolPrefix } from "../utils/url";
|
|
|
19
19
|
import type { RouterStore } from "./router-store";
|
|
20
20
|
|
|
21
21
|
function assertIsReady(store: RouterStore) {
|
|
22
|
-
if (!store.
|
|
22
|
+
if (!store.navigationRef.isReady()) {
|
|
23
23
|
throw new Error(
|
|
24
24
|
"Attempted to navigate before mounting the Root Layout component. Ensure the Root Layout component is rendering a Slot, or other navigator on the first render."
|
|
25
25
|
);
|
|
@@ -40,7 +40,9 @@ export function goBack(this: RouterStore) {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
export function canGoBack(this: RouterStore): boolean {
|
|
43
|
-
|
|
43
|
+
if (!this.navigationRef.isReady()) {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
44
46
|
return this.navigationRef?.current?.canGoBack() ?? false;
|
|
45
47
|
}
|
|
46
48
|
|
|
@@ -110,23 +112,28 @@ export function linkTo(this: RouterStore, href: string, event?: string) {
|
|
|
110
112
|
state
|
|
111
113
|
)!;
|
|
112
114
|
const nextRoute = findTopRouteForTarget(state);
|
|
113
|
-
|
|
114
|
-
|
|
115
|
+
// NOTE(EvanBacon): There's an issue where moving from "a -> b" is considered siblings:
|
|
116
|
+
// a. index (initialRouteName="index")
|
|
117
|
+
// b. stack/index
|
|
118
|
+
// However, the preservation approach doesn't work because it would be moving to a route with the same name.
|
|
119
|
+
// The next check will see if the current focused route has the same name as the next route, if so, then fallback on
|
|
120
|
+
// the default React Navigation logic.
|
|
121
|
+
if (
|
|
122
|
+
findTopRouteForTarget(
|
|
123
|
+
// @ts-expect-error: stale types don't matter here
|
|
124
|
+
rootState
|
|
125
|
+
)?.name !== nextRoute.name
|
|
126
|
+
) {
|
|
115
127
|
if (event === "REPLACE") {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
} else {
|
|
126
|
-
if (event === "REPLACE") {
|
|
127
|
-
navigationRef.dispatch(
|
|
128
|
-
StackActions.replace(nextRoute.name, nextRoute.params)
|
|
129
|
-
);
|
|
128
|
+
if (knownOwnerState.type === "tab") {
|
|
129
|
+
navigationRef.dispatch(
|
|
130
|
+
TabActions.jumpTo(nextRoute.name, nextRoute.params)
|
|
131
|
+
);
|
|
132
|
+
} else {
|
|
133
|
+
navigationRef.dispatch(
|
|
134
|
+
StackActions.replace(nextRoute.name, nextRoute.params)
|
|
135
|
+
);
|
|
136
|
+
}
|
|
130
137
|
} else {
|
|
131
138
|
// NOTE: Not sure if we should pop or push here...
|
|
132
139
|
navigationRef.dispatch(
|