expo-router 5.0.2-preview.6 → 5.0.3
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/ExpoRoot.d.ts.map +1 -1
- package/build/ExpoRoot.js +19 -18
- package/build/ExpoRoot.js.map +1 -1
- package/build/constants.d.ts +2 -0
- package/build/constants.d.ts.map +1 -0
- package/build/constants.js +5 -0
- package/build/constants.js.map +1 -0
- package/build/{link/useDomComponentNavigation.d.ts → domComponents/emitDomEvent.d.ts} +2 -4
- package/build/domComponents/emitDomEvent.d.ts.map +1 -0
- package/build/domComponents/emitDomEvent.js +32 -0
- package/build/domComponents/emitDomEvent.js.map +1 -0
- package/build/domComponents/events.d.ts +6 -0
- package/build/domComponents/events.d.ts.map +1 -0
- package/build/domComponents/events.js +9 -0
- package/build/domComponents/events.js.map +1 -0
- package/build/domComponents/useDomComponentNavigation.d.ts +2 -0
- package/build/domComponents/useDomComponentNavigation.d.ts.map +1 -0
- package/build/domComponents/useDomComponentNavigation.js +37 -0
- package/build/domComponents/useDomComponentNavigation.js.map +1 -0
- package/build/fork/getStateFromPath.d.ts +1 -2
- package/build/fork/getStateFromPath.d.ts.map +1 -1
- package/build/fork/getStateFromPath.js +11 -5
- package/build/fork/getStateFromPath.js.map +1 -1
- package/build/getLinkingConfig.d.ts +6 -7
- package/build/getLinkingConfig.d.ts.map +1 -1
- package/build/getLinkingConfig.js +10 -9
- package/build/getLinkingConfig.js.map +1 -1
- package/build/getRoutesRedirects.d.ts +2 -0
- package/build/getRoutesRedirects.d.ts.map +1 -1
- package/build/getRoutesRedirects.js +56 -0
- package/build/getRoutesRedirects.js.map +1 -1
- package/build/global-state/routeInfo.d.ts +29 -4
- package/build/global-state/routeInfo.d.ts.map +1 -1
- package/build/global-state/routeInfo.js +124 -55
- package/build/global-state/routeInfo.js.map +1 -1
- package/build/global-state/router-store.d.ts +35 -83
- package/build/global-state/router-store.d.ts.map +1 -1
- package/build/global-state/router-store.js +138 -238
- package/build/global-state/router-store.js.map +1 -1
- package/build/global-state/routing.d.ts +13 -14
- package/build/global-state/routing.d.ts.map +1 -1
- package/build/global-state/routing.js +32 -30
- package/build/global-state/routing.js.map +1 -1
- package/build/global-state/storeContext.d.ts +29 -0
- package/build/global-state/storeContext.d.ts.map +1 -0
- package/build/global-state/storeContext.js +9 -0
- package/build/global-state/storeContext.js.map +1 -0
- package/build/hooks.d.ts +13 -4
- package/build/hooks.d.ts.map +1 -1
- package/build/hooks.js +13 -23
- package/build/hooks.js.map +1 -1
- package/build/imperative-api.d.ts.map +1 -1
- package/build/imperative-api.js +13 -13
- package/build/imperative-api.js.map +1 -1
- package/build/layouts/DrawerClient.d.ts +3 -2
- package/build/layouts/DrawerClient.d.ts.map +1 -1
- package/build/layouts/StackClient.d.ts +5 -2
- package/build/layouts/StackClient.d.ts.map +1 -1
- package/build/layouts/StackClient.js +2 -0
- package/build/layouts/StackClient.js.map +1 -1
- package/build/layouts/TabsClient.d.ts +3 -2
- package/build/layouts/TabsClient.d.ts.map +1 -1
- package/build/layouts/withLayoutContext.d.ts +6 -1
- package/build/layouts/withLayoutContext.d.ts.map +1 -1
- package/build/layouts/withLayoutContext.js +28 -20
- package/build/layouts/withLayoutContext.js.map +1 -1
- package/build/link/linking.d.ts +2 -2
- package/build/link/linking.d.ts.map +1 -1
- package/build/link/linking.js +5 -4
- package/build/link/linking.js.map +1 -1
- package/build/link/useLinkToPathProps.d.ts.map +1 -1
- package/build/link/useLinkToPathProps.js +4 -5
- package/build/link/useLinkToPathProps.js.map +1 -1
- package/build/link/useLoadedNavigation.d.ts.map +1 -1
- package/build/link/useLoadedNavigation.js +2 -3
- package/build/link/useLoadedNavigation.js.map +1 -1
- package/build/primitives.d.ts.map +1 -1
- package/build/primitives.js +1 -0
- package/build/primitives.js.map +1 -1
- package/build/testing-library/index.d.ts +3 -3
- package/build/testing-library/index.d.ts.map +1 -1
- package/build/testing-library/index.js +5 -10
- package/build/testing-library/index.js.map +1 -1
- package/build/ui/common.d.ts.map +1 -1
- package/build/ui/common.js +4 -3
- package/build/ui/common.js.map +1 -1
- package/build/useNavigation.d.ts.map +1 -1
- package/build/useNavigation.js +47 -56
- package/build/useNavigation.js.map +1 -1
- package/build/useScreens.d.ts +2 -2
- package/build/useScreens.d.ts.map +1 -1
- package/build/useScreens.js +18 -3
- package/build/useScreens.js.map +1 -1
- package/build/views/ErrorBoundary.d.ts.map +1 -1
- package/build/views/ErrorBoundary.js +2 -68
- package/build/views/ErrorBoundary.js.map +1 -1
- package/build/views/Navigator.d.ts.map +1 -1
- package/build/views/Navigator.js +4 -4
- package/build/views/Navigator.js.map +1 -1
- package/build/views/Protected.d.ts +8 -0
- package/build/views/Protected.d.ts.map +1 -0
- package/build/views/Protected.js +11 -0
- package/build/views/Protected.js.map +1 -0
- package/build/views/Screen.d.ts +4 -0
- package/build/views/Screen.d.ts.map +1 -1
- package/build/views/Screen.js +52 -4
- package/build/views/Screen.js.map +1 -1
- package/build/views/Sitemap.js +5 -2
- package/build/views/Sitemap.js.map +1 -1
- package/package.json +3 -3
- package/build/link/useDomComponentNavigation.d.ts.map +0 -1
- package/build/link/useDomComponentNavigation.js +0 -68
- package/build/link/useDomComponentNavigation.js.map +0 -1
|
@@ -37,267 +37,167 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
37
37
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
38
|
};
|
|
39
39
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
-
exports.store =
|
|
41
|
-
exports.
|
|
42
|
-
exports.
|
|
43
|
-
exports.useStoreRouteInfo = useStoreRouteInfo;
|
|
44
|
-
exports.useInitializeExpoRouter = useInitializeExpoRouter;
|
|
40
|
+
exports.store = void 0;
|
|
41
|
+
exports.useStore = useStore;
|
|
42
|
+
exports.useRouteInfo = useRouteInfo;
|
|
45
43
|
const native_1 = require("@react-navigation/native");
|
|
46
44
|
const expo_constants_1 = __importDefault(require("expo-constants"));
|
|
47
|
-
const Linking = __importStar(require("expo-linking"));
|
|
48
|
-
const fast_deep_equal_1 = __importDefault(require("fast-deep-equal"));
|
|
49
45
|
const react_1 = require("react");
|
|
50
46
|
const react_native_1 = require("react-native");
|
|
51
|
-
const routing_1 = require("./routing");
|
|
52
|
-
const sort_routes_1 = require("./sort-routes");
|
|
53
|
-
const LocationProvider_1 = require("../LocationProvider");
|
|
54
|
-
const getPathFromState_1 = require("../fork/getPathFromState");
|
|
55
47
|
const getStateFromPath_forks_1 = require("../fork/getStateFromPath-forks");
|
|
56
48
|
const getLinkingConfig_1 = require("../getLinkingConfig");
|
|
57
49
|
const getReactNavigationConfig_1 = require("../getReactNavigationConfig");
|
|
58
50
|
const getRoutes_1 = require("../getRoutes");
|
|
59
|
-
const
|
|
60
|
-
const href_1 = require("../link/href");
|
|
51
|
+
const routeInfo_1 = require("./routeInfo");
|
|
61
52
|
const useScreens_1 = require("../useScreens");
|
|
62
53
|
const url_1 = require("../utils/url");
|
|
63
54
|
const SplashScreen = __importStar(require("../views/Splash"));
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
canGoBack = routing_1.canGoBack.bind(this);
|
|
90
|
-
push = routing_1.push.bind(this);
|
|
91
|
-
dismiss = routing_1.dismiss.bind(this);
|
|
92
|
-
dismissTo = routing_1.dismissTo.bind(this);
|
|
93
|
-
replace = routing_1.replace.bind(this);
|
|
94
|
-
dismissAll = routing_1.dismissAll.bind(this);
|
|
95
|
-
canDismiss = routing_1.canDismiss.bind(this);
|
|
96
|
-
setParams = routing_1.setParams.bind(this);
|
|
97
|
-
navigate = routing_1.navigate.bind(this);
|
|
98
|
-
reload = routing_1.reload.bind(this);
|
|
99
|
-
prefetch = routing_1.prefetch.bind(this);
|
|
100
|
-
initialize(context, navigationRef, linkingConfigOptions = {}) {
|
|
101
|
-
// Clean up any previous state
|
|
102
|
-
this.initialState = undefined;
|
|
103
|
-
this.rootState = undefined;
|
|
104
|
-
this.nextState = undefined;
|
|
105
|
-
this.linking = undefined;
|
|
106
|
-
this.navigationRefSubscription?.();
|
|
107
|
-
this.rootStateSubscribers.clear();
|
|
108
|
-
this.storeSubscribers.clear();
|
|
109
|
-
this.config = expo_constants_1.default.expoConfig?.extra?.router;
|
|
110
|
-
// On the client, there is no difference between redirects and rewrites
|
|
111
|
-
this.redirects = [this.config?.redirects, this.config?.rewrites]
|
|
112
|
-
.filter(Boolean)
|
|
113
|
-
.flat()
|
|
114
|
-
.map((route) => {
|
|
115
|
-
return [
|
|
116
|
-
(0, getStateFromPath_forks_1.routePatternToRegex)((0, getReactNavigationConfig_1.parseRouteSegments)(route.source)),
|
|
117
|
-
route,
|
|
118
|
-
(0, url_1.shouldLinkExternally)(route.destination),
|
|
119
|
-
];
|
|
120
|
-
});
|
|
121
|
-
this.routeNode = (0, getRoutes_1.getRoutes)(context, {
|
|
122
|
-
...expo_constants_1.default.expoConfig?.extra?.router,
|
|
123
|
-
ignoreEntryPoints: true,
|
|
124
|
-
platform: react_native_1.Platform.OS,
|
|
125
|
-
});
|
|
126
|
-
// We always needs routeInfo, even if there are no routes. This can happen if:
|
|
127
|
-
// - there are no routes (we are showing the onboarding screen)
|
|
128
|
-
// - getInitialURL() is async
|
|
129
|
-
this.routeInfo = {
|
|
130
|
-
unstable_globalHref: '',
|
|
131
|
-
pathname: '',
|
|
132
|
-
isIndex: false,
|
|
133
|
-
params: {},
|
|
134
|
-
segments: [],
|
|
135
|
-
};
|
|
136
|
-
if (this.routeNode) {
|
|
137
|
-
// We have routes, so get the linking config and the root component
|
|
138
|
-
this.linking = (0, getLinkingConfig_1.getLinkingConfig)(this, this.routeNode, context, {
|
|
139
|
-
...expo_constants_1.default.expoConfig?.extra?.router,
|
|
140
|
-
...linkingConfigOptions,
|
|
141
|
-
});
|
|
142
|
-
this.rootComponent = (0, useScreens_1.getQualifiedRouteComponent)(this.routeNode);
|
|
143
|
-
// By default React Navigation is async and does not render anything in the first pass as it waits for `getInitialURL`
|
|
144
|
-
// This will cause static rendering to fail, which once performs a single pass.
|
|
145
|
-
// If the initialURL is a string, we can prefetch the state and routeInfo, skipping React Navigation's async behavior.
|
|
146
|
-
const initialURL = this.linking?.getInitialURL?.();
|
|
147
|
-
if (typeof initialURL === 'string') {
|
|
148
|
-
this.rootState = this.linking.getStateFromPath?.(initialURL, this.linking.config);
|
|
149
|
-
this.initialState = this.rootState;
|
|
150
|
-
if (this.rootState) {
|
|
151
|
-
this.routeInfo = this.getRouteInfo(this.rootState);
|
|
152
|
-
}
|
|
153
|
-
}
|
|
55
|
+
const storeRef = {
|
|
56
|
+
current: {},
|
|
57
|
+
};
|
|
58
|
+
const routeInfoCache = new WeakMap();
|
|
59
|
+
let splashScreenAnimationFrame;
|
|
60
|
+
let hasAttemptedToHideSplash = false;
|
|
61
|
+
exports.store = {
|
|
62
|
+
shouldShowTutorial() {
|
|
63
|
+
return !storeRef.current.routeNode && process.env.NODE_ENV === 'development';
|
|
64
|
+
},
|
|
65
|
+
get state() {
|
|
66
|
+
return storeRef.current.state;
|
|
67
|
+
},
|
|
68
|
+
get focusedState() {
|
|
69
|
+
return storeRef.current.focusedState;
|
|
70
|
+
},
|
|
71
|
+
get navigationRef() {
|
|
72
|
+
return storeRef.current.navigationRef;
|
|
73
|
+
},
|
|
74
|
+
get routeNode() {
|
|
75
|
+
return storeRef.current.routeNode;
|
|
76
|
+
},
|
|
77
|
+
getRouteInfo(state = storeRef.current.focusedState) {
|
|
78
|
+
if (!state) {
|
|
79
|
+
return routeInfo_1.defaultRouteInfo;
|
|
154
80
|
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
}
|
|
160
|
-
// In development, we will show the onboarding screen
|
|
161
|
-
this.rootComponent = react_1.Fragment;
|
|
81
|
+
let routeInfo = routeInfoCache.get(state);
|
|
82
|
+
if (!routeInfo) {
|
|
83
|
+
routeInfo = (0, routeInfo_1.getRouteInfoFromState)(state);
|
|
84
|
+
routeInfoCache.set(state, routeInfo);
|
|
162
85
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
if (state && state !== this.rootState) {
|
|
189
|
-
exports.store.updateState(state, undefined);
|
|
190
|
-
shouldUpdateSubscribers = true;
|
|
86
|
+
return routeInfo;
|
|
87
|
+
},
|
|
88
|
+
get redirects() {
|
|
89
|
+
return storeRef.current.redirects || [];
|
|
90
|
+
},
|
|
91
|
+
get rootComponent() {
|
|
92
|
+
return storeRef.current.rootComponent;
|
|
93
|
+
},
|
|
94
|
+
get linking() {
|
|
95
|
+
return storeRef.current.linking;
|
|
96
|
+
},
|
|
97
|
+
setFocusedState(state) {
|
|
98
|
+
storeRef.current.focusedState = state;
|
|
99
|
+
},
|
|
100
|
+
onReady() {
|
|
101
|
+
if (!hasAttemptedToHideSplash) {
|
|
102
|
+
hasAttemptedToHideSplash = true;
|
|
103
|
+
// NOTE(EvanBacon): `navigationRef.isReady` is sometimes not true when state is called initially.
|
|
104
|
+
splashScreenAnimationFrame = requestAnimationFrame(() => {
|
|
105
|
+
SplashScreen._internal_maybeHideAsync?.();
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
storeRef.current.navigationRef.addListener('state', (e) => {
|
|
109
|
+
if (e.data.state) {
|
|
110
|
+
storeRef.current.state = e.data.state;
|
|
191
111
|
}
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
for (const subscriber of this.rootStateSubscribers) {
|
|
195
|
-
subscriber();
|
|
196
|
-
}
|
|
112
|
+
for (const callback of routeInfoSubscribers) {
|
|
113
|
+
callback();
|
|
197
114
|
}
|
|
198
115
|
});
|
|
199
|
-
|
|
200
|
-
|
|
116
|
+
},
|
|
117
|
+
assertIsReady() {
|
|
118
|
+
if (!storeRef.current.navigationRef.isReady()) {
|
|
119
|
+
throw new Error('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.');
|
|
201
120
|
}
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
121
|
+
},
|
|
122
|
+
};
|
|
123
|
+
function useStore(context, linkingConfigOptions, serverUrl) {
|
|
124
|
+
const navigationRef = (0, native_1.useNavigationContainerRef)();
|
|
125
|
+
const config = expo_constants_1.default.expoConfig?.extra?.router;
|
|
126
|
+
let linking;
|
|
127
|
+
let rootComponent = react_1.Fragment;
|
|
128
|
+
let initialState;
|
|
129
|
+
const routeNode = (0, getRoutes_1.getRoutes)(context, {
|
|
130
|
+
...config,
|
|
131
|
+
ignoreEntryPoints: true,
|
|
132
|
+
platform: react_native_1.Platform.OS,
|
|
133
|
+
});
|
|
134
|
+
const redirects = [config?.redirects, config?.rewrites]
|
|
135
|
+
.filter(Boolean)
|
|
136
|
+
.flat()
|
|
137
|
+
.map((route) => {
|
|
138
|
+
return [
|
|
139
|
+
(0, getStateFromPath_forks_1.routePatternToRegex)((0, getReactNavigationConfig_1.parseRouteSegments)(route.source)),
|
|
140
|
+
route,
|
|
141
|
+
(0, url_1.shouldLinkExternally)(route.destination),
|
|
142
|
+
];
|
|
143
|
+
});
|
|
144
|
+
if (routeNode) {
|
|
145
|
+
// We have routes, so get the linking config and the root component
|
|
146
|
+
linking = (0, getLinkingConfig_1.getLinkingConfig)(routeNode, context, () => exports.store.getRouteInfo(), {
|
|
147
|
+
metaOnly: linkingConfigOptions.metaOnly,
|
|
148
|
+
serverUrl,
|
|
149
|
+
redirects,
|
|
150
|
+
});
|
|
151
|
+
rootComponent = (0, useScreens_1.getQualifiedRouteComponent)(routeNode);
|
|
152
|
+
// By default React Navigation is async and does not render anything in the first pass as it waits for `getInitialURL`
|
|
153
|
+
// This will cause static rendering to fail, which once performs a single pass.
|
|
154
|
+
// If the initialURL is a string, we can prefetch the state and routeInfo, skipping React Navigation's async behavior.
|
|
155
|
+
const initialURL = linking?.getInitialURL?.();
|
|
156
|
+
if (typeof initialURL === 'string') {
|
|
157
|
+
initialState = linking.getStateFromPath(initialURL, linking.config);
|
|
158
|
+
const initialRouteInfo = (0, routeInfo_1.getRouteInfoFromState)(initialState);
|
|
159
|
+
routeInfoCache.set(initialState, initialRouteInfo);
|
|
209
160
|
}
|
|
210
161
|
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
...this.linking?.config,
|
|
216
|
-
preserveDynamicRoutes: asPath,
|
|
217
|
-
preserveGroups: asPath,
|
|
218
|
-
shouldEncodeURISegment: false,
|
|
219
|
-
});
|
|
220
|
-
}, state);
|
|
221
|
-
}
|
|
222
|
-
// This is only used in development, to show the onboarding screen
|
|
223
|
-
// In production we should have errored during the initialization
|
|
224
|
-
shouldShowTutorial() {
|
|
225
|
-
return !this.routeNode && process.env.NODE_ENV === 'development';
|
|
226
|
-
}
|
|
227
|
-
/** Make sure these are arrow functions so `this` is correctly bound */
|
|
228
|
-
subscribeToRootState = (subscriber) => {
|
|
229
|
-
this.rootStateSubscribers.add(subscriber);
|
|
230
|
-
return () => this.rootStateSubscribers.delete(subscriber);
|
|
231
|
-
};
|
|
232
|
-
subscribeToStore = (subscriber) => {
|
|
233
|
-
this.storeSubscribers.add(subscriber);
|
|
234
|
-
return () => this.storeSubscribers.delete(subscriber);
|
|
235
|
-
};
|
|
236
|
-
snapshot = () => {
|
|
237
|
-
return this;
|
|
238
|
-
};
|
|
239
|
-
rootStateSnapshot = () => {
|
|
240
|
-
return this.rootState;
|
|
241
|
-
};
|
|
242
|
-
routeInfoSnapshot = () => {
|
|
243
|
-
return this.routeInfo;
|
|
244
|
-
};
|
|
245
|
-
cleanup() {
|
|
246
|
-
if (this.splashScreenAnimationFrame) {
|
|
247
|
-
cancelAnimationFrame(this.splashScreenAnimationFrame);
|
|
162
|
+
else {
|
|
163
|
+
// Only error in production, in development we will show the onboarding screen
|
|
164
|
+
if (process.env.NODE_ENV === 'production') {
|
|
165
|
+
throw new Error('No routes found');
|
|
248
166
|
}
|
|
167
|
+
// In development, we will show the onboarding screen
|
|
168
|
+
rootComponent = react_1.Fragment;
|
|
249
169
|
}
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
170
|
+
storeRef.current = {
|
|
171
|
+
navigationRef,
|
|
172
|
+
routeNode,
|
|
173
|
+
config,
|
|
174
|
+
rootComponent,
|
|
175
|
+
linking,
|
|
176
|
+
redirects,
|
|
177
|
+
state: initialState,
|
|
178
|
+
};
|
|
179
|
+
if (initialState) {
|
|
180
|
+
storeRef.current.focusedState = initialState;
|
|
254
181
|
}
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
if (!redirect) {
|
|
262
|
-
return url;
|
|
263
|
-
}
|
|
264
|
-
// If the redirect is external, open the URL
|
|
265
|
-
if (redirect[2]) {
|
|
266
|
-
let href = redirect[1].destination;
|
|
267
|
-
if (href.startsWith('//') && react_native_1.Platform.OS !== 'web') {
|
|
268
|
-
href = `https:${href}`;
|
|
182
|
+
(0, react_1.useEffect)(() => {
|
|
183
|
+
return () => {
|
|
184
|
+
// listener();
|
|
185
|
+
if (splashScreenAnimationFrame) {
|
|
186
|
+
cancelAnimationFrame(splashScreenAnimationFrame);
|
|
187
|
+
splashScreenAnimationFrame = undefined;
|
|
269
188
|
}
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
}
|
|
273
|
-
return this.applyRedirects((0, getRoutesRedirects_1.convertRedirect)(url, redirect[1]));
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
exports.RouterStore = RouterStore;
|
|
277
|
-
exports.store = new RouterStore();
|
|
278
|
-
function useExpoRouter() {
|
|
279
|
-
return (0, react_1.useSyncExternalStore)(exports.store.subscribeToStore, exports.store.snapshot, exports.store.snapshot);
|
|
280
|
-
}
|
|
281
|
-
function syncStoreRootState() {
|
|
282
|
-
if (exports.store.navigationRef.isReady()) {
|
|
283
|
-
const currentState = exports.store.navigationRef.getRootState();
|
|
284
|
-
if (exports.store.rootState !== currentState) {
|
|
285
|
-
exports.store.updateState(currentState);
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
function useStoreRootState() {
|
|
290
|
-
syncStoreRootState();
|
|
291
|
-
return (0, react_1.useSyncExternalStore)(exports.store.subscribeToRootState, exports.store.rootStateSnapshot, exports.store.rootStateSnapshot);
|
|
292
|
-
}
|
|
293
|
-
function useStoreRouteInfo() {
|
|
294
|
-
syncStoreRootState();
|
|
295
|
-
return (0, react_1.useSyncExternalStore)(exports.store.subscribeToRootState, exports.store.routeInfoSnapshot, exports.store.routeInfoSnapshot);
|
|
296
|
-
}
|
|
297
|
-
function useInitializeExpoRouter(context, options) {
|
|
298
|
-
const navigationRef = (0, native_1.useNavigationContainerRef)();
|
|
299
|
-
(0, react_1.useMemo)(() => exports.store.initialize(context, navigationRef, options), [context]);
|
|
300
|
-
useExpoRouter();
|
|
189
|
+
};
|
|
190
|
+
});
|
|
301
191
|
return exports.store;
|
|
302
192
|
}
|
|
193
|
+
const routeInfoSubscribers = new Set();
|
|
194
|
+
const routeInfoSubscribe = (callback) => {
|
|
195
|
+
routeInfoSubscribers.add(callback);
|
|
196
|
+
return () => {
|
|
197
|
+
routeInfoSubscribers.delete(callback);
|
|
198
|
+
};
|
|
199
|
+
};
|
|
200
|
+
function useRouteInfo() {
|
|
201
|
+
return (0, react_1.useSyncExternalStore)(routeInfoSubscribe, exports.store.getRouteInfo, exports.store.getRouteInfo);
|
|
202
|
+
}
|
|
303
203
|
//# sourceMappingURL=router-store.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router-store.js","sourceRoot":"","sources":["../../src/global-state/router-store.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2Sb,sCAEC;AAYD,8CAOC;AAED,8CAOC;AAED,0DAKC;AA9UD,qDAGkC;AAClC,oEAAuC;AACvC,sDAAwC;AACxC,sEAAoC;AACpC,iCAA+E;AAC/E,+CAAwC;AAExC,uCAemB;AACnB,+CAAgD;AAChD,0DAAuE;AAEvE,+DAAkF;AAClF,2EAAgF;AAChF,0DAAiG;AACjG,0EAAiE;AACjE,4CAAyC;AAEzC,8DAAwD;AACxD,uCAA0E;AAE1E,8CAA2D;AAC3D,sCAAoD;AACpD,8DAAgD;AAIhD;;;;GAIG;AACH,MAAa,WAAW;IACtB,SAAS,CAAoB;IAC7B,aAAa,CAAiB;IAC9B,OAAO,CAAsB;IACrB,wBAAwB,GAAY,KAAK,CAAC;IAElD,YAAY,CAAe;IAC3B,SAAS,CAAe;IACxB,SAAS,CAAe;IACxB,SAAS,CAAa;IACtB,0BAA0B,CAAU;IAEpC,gCAAgC;IAChC,MAAM,CAAM;IACZ,SAAS,CAAkD;IAE3D,aAAa,CAAoE;IACjF,yBAAyB,CAAc;IAEvC,oBAAoB,GAAG,IAAI,GAAG,EAAc,CAAC;IAC7C,gBAAgB,GAAG,IAAI,GAAG,EAAc,CAAC;IAEzC,MAAM,GAAG,gBAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC3B,eAAe,GAAG,6BAAe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AG,aAAK,CAAC,aAAa,CAAC,YAAY,EAA4B,CAAC;QAElF,IAAI,aAAK,CAAC,SAAS,KAAK,YAAY,EAAE,CAAC;YACrC,aAAK,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;QAClC,CAAC;IACH,CAAC;AACH,CAAC;AAED,SAAgB,iBAAiB;IAC/B,kBAAkB,EAAE,CAAC;IACrB,OAAO,IAAA,4BAAoB,EACzB,aAAK,CAAC,oBAAoB,EAC1B,aAAK,CAAC,iBAAiB,EACvB,aAAK,CAAC,iBAAiB,CACxB,CAAC;AACJ,CAAC;AAED,SAAgB,iBAAiB;IAC/B,kBAAkB,EAAE,CAAC;IACrB,OAAO,IAAA,4BAAoB,EACzB,aAAK,CAAC,oBAAoB,EAC1B,aAAK,CAAC,iBAAiB,EACvB,aAAK,CAAC,iBAAiB,CACxB,CAAC;AACJ,CAAC;AAED,SAAgB,uBAAuB,CAAC,OAAuB,EAAE,OAA6B;IAC5F,MAAM,aAAa,GAAG,IAAA,kCAAyB,GAAE,CAAC;IAClD,IAAA,eAAO,EAAC,GAAG,EAAE,CAAC,aAAK,CAAC,UAAU,CAAC,OAAO,EAAE,aAAa,EAAE,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAC5E,aAAa,EAAE,CAAC;IAChB,OAAO,aAAK,CAAC;AACf,CAAC","sourcesContent":["'use client';\n\nimport {\n NavigationContainerRefWithCurrent,\n useNavigationContainerRef,\n} from '@react-navigation/native';\nimport Constants from 'expo-constants';\nimport * as Linking from 'expo-linking';\nimport equal from 'fast-deep-equal';\nimport { useSyncExternalStore, useMemo, ComponentType, Fragment } from 'react';\nimport { Platform } from 'react-native';\n\nimport {\n canGoBack,\n canDismiss,\n goBack,\n linkTo,\n navigate,\n dismiss,\n dismissAll,\n push,\n reload,\n replace,\n setParams,\n dismissTo,\n LinkToOptions,\n prefetch,\n} from './routing';\nimport { getSortedRoutes } from './sort-routes';\nimport { UrlObject, getRouteInfoFromState } from '../LocationProvider';\nimport { RouteNode } from '../Route';\nimport { getPathDataFromState, getPathFromState } from '../fork/getPathFromState';\nimport { cleanPath, routePatternToRegex } from '../fork/getStateFromPath-forks';\nimport { ExpoLinkingOptions, LinkingConfigOptions, getLinkingConfig } from '../getLinkingConfig';\nimport { parseRouteSegments } from '../getReactNavigationConfig';\nimport { getRoutes } from '../getRoutes';\nimport { RedirectConfig } from '../getRoutesCore';\nimport { convertRedirect } from '../getRoutesRedirects';\nimport { resolveHref, resolveHrefStringWithSegments } from '../link/href';\nimport { Href, RequireContext } from '../types';\nimport { getQualifiedRouteComponent } from '../useScreens';\nimport { shouldLinkExternally } from '../utils/url';\nimport * as SplashScreen from '../views/Splash';\n\ntype ResultState = any;\n\n/**\n * This is the global state for the router. It is used to keep track of the current route, and to provide a way to navigate to other routes.\n *\n * There should only be one instance of this class and be initialized via `useInitializeExpoRouter`\n */\nexport class RouterStore {\n routeNode!: RouteNode | null;\n rootComponent!: ComponentType;\n linking?: ExpoLinkingOptions;\n private hasAttemptedToHideSplash: boolean = false;\n\n initialState?: ResultState;\n rootState?: ResultState;\n nextState?: ResultState;\n routeInfo?: UrlObject;\n splashScreenAnimationFrame?: number;\n\n // The expo-router config plugin\n config: any;\n redirects?: (readonly [RegExp, RedirectConfig, boolean])[];\n\n navigationRef!: NavigationContainerRefWithCurrent<ReactNavigation.RootParamList>;\n navigationRefSubscription!: () => void;\n\n rootStateSubscribers = new Set<() => void>();\n storeSubscribers = new Set<() => void>();\n\n linkTo = linkTo.bind(this);\n getSortedRoutes = getSortedRoutes.bind(this);\n goBack = goBack.bind(this);\n canGoBack = canGoBack.bind(this);\n push = push.bind(this);\n dismiss = dismiss.bind(this);\n dismissTo = dismissTo.bind(this);\n replace = replace.bind(this);\n dismissAll = dismissAll.bind(this);\n canDismiss = canDismiss.bind(this);\n setParams = setParams.bind(this);\n navigate = navigate.bind(this);\n reload = reload.bind(this);\n prefetch = prefetch.bind(this);\n\n initialize(\n context: RequireContext,\n navigationRef: NavigationContainerRefWithCurrent<ReactNavigation.RootParamList>,\n linkingConfigOptions: LinkingConfigOptions = {}\n ) {\n // Clean up any previous state\n this.initialState = undefined;\n this.rootState = undefined;\n this.nextState = undefined;\n this.linking = undefined;\n this.navigationRefSubscription?.();\n this.rootStateSubscribers.clear();\n this.storeSubscribers.clear();\n\n this.config = Constants.expoConfig?.extra?.router;\n // On the client, there is no difference between redirects and rewrites\n this.redirects = [this.config?.redirects, this.config?.rewrites]\n .filter(Boolean)\n .flat()\n .map((route) => {\n return [\n routePatternToRegex(parseRouteSegments(route.source)),\n route,\n shouldLinkExternally(route.destination),\n ] as const;\n });\n\n this.routeNode = getRoutes(context, {\n ...Constants.expoConfig?.extra?.router,\n ignoreEntryPoints: true,\n platform: Platform.OS,\n });\n\n // We always needs routeInfo, even if there are no routes. This can happen if:\n // - there are no routes (we are showing the onboarding screen)\n // - getInitialURL() is async\n this.routeInfo = {\n unstable_globalHref: '',\n pathname: '',\n isIndex: false,\n params: {},\n segments: [],\n };\n\n if (this.routeNode) {\n // We have routes, so get the linking config and the root component\n this.linking = getLinkingConfig(this, this.routeNode, context, {\n ...Constants.expoConfig?.extra?.router,\n ...linkingConfigOptions,\n });\n this.rootComponent = getQualifiedRouteComponent(this.routeNode);\n\n // By default React Navigation is async and does not render anything in the first pass as it waits for `getInitialURL`\n // This will cause static rendering to fail, which once performs a single pass.\n // If the initialURL is a string, we can prefetch the state and routeInfo, skipping React Navigation's async behavior.\n const initialURL = this.linking?.getInitialURL?.();\n if (typeof initialURL === 'string') {\n this.rootState = this.linking.getStateFromPath?.(initialURL, this.linking.config);\n this.initialState = this.rootState;\n if (this.rootState) {\n this.routeInfo = this.getRouteInfo(this.rootState);\n }\n }\n } else {\n // Only error in production, in development we will show the onboarding screen\n if (process.env.NODE_ENV === 'production') {\n throw new Error('No routes found');\n }\n\n // In development, we will show the onboarding screen\n this.rootComponent = Fragment;\n }\n\n /**\n * Counter intuitively - this fires AFTER both React Navigation's state changes and the subsequent paint.\n * This poses a couple of issues for Expo Router,\n * - Ensuring hooks (e.g. useSearchParams()) have data in the initial render\n * - Reacting to state changes after a navigation event\n *\n * This is why the initial render renders a Fragment and we wait until `onReady()` is called\n * Additionally, some hooks compare the state from both the store and the navigationRef. If the store it stale,\n * that hooks will manually update the store.\n *\n */\n this.navigationRef = navigationRef;\n this.navigationRefSubscription = navigationRef.addListener('state', (data) => {\n const state = data.data.state as ResultState;\n\n if (!this.hasAttemptedToHideSplash) {\n this.hasAttemptedToHideSplash = true;\n // NOTE(EvanBacon): `navigationRef.isReady` is sometimes not true when state is called initially.\n this.splashScreenAnimationFrame = requestAnimationFrame(() => {\n SplashScreen._internal_maybeHideAsync?.();\n });\n }\n\n let shouldUpdateSubscribers = this.nextState === state;\n this.nextState = undefined;\n\n // This can sometimes be undefined when an error is thrown in the Root Layout Route.\n // Additionally that state may already equal the rootState if it was updated within a hook\n if (state && state !== this.rootState) {\n store.updateState(state, undefined);\n shouldUpdateSubscribers = true;\n }\n\n // If the state has changed, or was changed inside a hook we need to update the subscribers\n if (shouldUpdateSubscribers) {\n for (const subscriber of this.rootStateSubscribers) {\n subscriber();\n }\n }\n });\n\n for (const subscriber of this.storeSubscribers) {\n subscriber();\n }\n }\n\n updateState(state: ResultState, nextState = state) {\n store.rootState = state;\n store.nextState = nextState;\n\n const nextRouteInfo = store.getRouteInfo(state);\n\n if (!equal(this.routeInfo, nextRouteInfo)) {\n store.routeInfo = nextRouteInfo;\n }\n }\n\n getRouteInfo(state: ResultState) {\n return getRouteInfoFromState(\n (state: Parameters<typeof getPathFromState>[0], asPath: boolean) => {\n return getPathDataFromState(state, {\n screens: {},\n ...this.linking?.config,\n preserveDynamicRoutes: asPath,\n preserveGroups: asPath,\n shouldEncodeURISegment: false,\n });\n },\n state\n );\n }\n\n // This is only used in development, to show the onboarding screen\n // In production we should have errored during the initialization\n shouldShowTutorial() {\n return !this.routeNode && process.env.NODE_ENV === 'development';\n }\n\n /** Make sure these are arrow functions so `this` is correctly bound */\n subscribeToRootState = (subscriber: () => void) => {\n this.rootStateSubscribers.add(subscriber);\n return () => this.rootStateSubscribers.delete(subscriber);\n };\n subscribeToStore = (subscriber: () => void) => {\n this.storeSubscribers.add(subscriber);\n return () => this.storeSubscribers.delete(subscriber);\n };\n snapshot = () => {\n return this;\n };\n rootStateSnapshot = () => {\n return this.rootState!;\n };\n routeInfoSnapshot = () => {\n return this.routeInfo!;\n };\n\n cleanup() {\n if (this.splashScreenAnimationFrame) {\n cancelAnimationFrame(this.splashScreenAnimationFrame);\n }\n }\n\n getStateFromPath(href: Href, options: LinkToOptions = {}) {\n href = resolveHref(href);\n href = resolveHrefStringWithSegments(href, this.routeInfo, options);\n return this.linking?.getStateFromPath?.(href, this.linking.config);\n }\n\n applyRedirects<T extends string | null | undefined>(url: T): T | undefined {\n if (typeof url !== 'string') {\n return url;\n }\n\n const nextUrl = cleanPath(url);\n const redirect = this.redirects?.find(([regex]) => regex.test(nextUrl));\n\n if (!redirect) {\n return url;\n }\n\n // If the redirect is external, open the URL\n if (redirect[2]) {\n let href = redirect[1].destination as T & string;\n if (href.startsWith('//') && Platform.OS !== 'web') {\n href = `https:${href}` as T & string;\n }\n\n Linking.openURL(href);\n return;\n }\n\n return this.applyRedirects<T>(convertRedirect(url, redirect[1]) as T);\n }\n}\n\nexport const store = new RouterStore();\n\nexport function useExpoRouter() {\n return useSyncExternalStore(store.subscribeToStore, store.snapshot, store.snapshot);\n}\n\nfunction syncStoreRootState() {\n if (store.navigationRef.isReady()) {\n const currentState = store.navigationRef.getRootState() as unknown as ResultState;\n\n if (store.rootState !== currentState) {\n store.updateState(currentState);\n }\n }\n}\n\nexport function useStoreRootState() {\n syncStoreRootState();\n return useSyncExternalStore(\n store.subscribeToRootState,\n store.rootStateSnapshot,\n store.rootStateSnapshot\n );\n}\n\nexport function useStoreRouteInfo() {\n syncStoreRootState();\n return useSyncExternalStore(\n store.subscribeToRootState,\n store.routeInfoSnapshot,\n store.routeInfoSnapshot\n );\n}\n\nexport function useInitializeExpoRouter(context: RequireContext, options: LinkingConfigOptions) {\n const navigationRef = useNavigationContainerRef();\n useMemo(() => store.initialize(context, navigationRef, options), [context]);\n useExpoRouter();\n return store;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"router-store.js","sourceRoot":"","sources":["../../src/global-state/router-store.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2Hb,4BAmFC;AAUD,oCAEC;AAxND,qDAMkC;AAClC,oEAAuC;AACvC,iCAAiF;AACjF,+CAAwC;AAGxC,2EAAqE;AACrE,0DAAiG;AACjG,0EAAiE;AACjE,4CAAyC;AAEzC,2CAAiF;AAEjF,8CAA2D;AAC3D,sCAAoD;AACpD,8DAAgD;AAmBhD,MAAM,QAAQ,GAAG;IACf,OAAO,EAAE,EAAc;CACxB,CAAC;AAEF,MAAM,cAAc,GAAG,IAAI,OAAO,EAAuD,CAAC;AAE1F,IAAI,0BAA8C,CAAC;AACnD,IAAI,wBAAwB,GAAG,KAAK,CAAC;AAExB,QAAA,KAAK,GAAG;IACnB,kBAAkB;QAChB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,SAAS,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa,CAAC;IAC/E,CAAC;IACD,IAAI,KAAK;QACP,OAAO,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC;IAChC,CAAC;IACD,IAAI,YAAY;QACd,OAAO,QAAQ,CAAC,OAAO,CAAC,YAAY,CAAC;IACvC,CAAC;IACD,IAAI,aAAa;QACf,OAAO,QAAQ,CAAC,OAAO,CAAC,aAAa,CAAC;IACxC,CAAC;IACD,IAAI,SAAS;QACX,OAAO,QAAQ,CAAC,OAAO,CAAC,SAAS,CAAC;IACpC,CAAC;IACD,YAAY,CACV,QAA8D,QAAQ,CAAC,OAAO,CAAC,YAAY;QAE3F,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,OAA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AC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACnC,OAAO,GAAG,EAAE;QACV,oBAAoB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IACxC,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,SAAgB,YAAY;IAC1B,OAAO,IAAA,4BAAoB,EAAC,kBAAkB,EAAE,aAAK,CAAC,YAAY,EAAE,aAAK,CAAC,YAAY,CAAC,CAAC;AAC1F,CAAC","sourcesContent":["'use client';\n\nimport {\n NavigationContainerRefWithCurrent,\n NavigationState,\n PartialState,\n useNavigationContainerRef,\n useStateForPath,\n} from '@react-navigation/native';\nimport Constants from 'expo-constants';\nimport { ComponentType, Fragment, useEffect, useSyncExternalStore } from 'react';\nimport { Platform } from 'react-native';\n\nimport { RouteNode } from '../Route';\nimport { routePatternToRegex } from '../fork/getStateFromPath-forks';\nimport { ExpoLinkingOptions, LinkingConfigOptions, getLinkingConfig } from '../getLinkingConfig';\nimport { parseRouteSegments } from '../getReactNavigationConfig';\nimport { getRoutes } from '../getRoutes';\nimport { RedirectConfig } from '../getRoutesCore';\nimport { defaultRouteInfo, getRouteInfoFromState, UrlObject } from './routeInfo';\nimport { RequireContext } from '../types';\nimport { getQualifiedRouteComponent } from '../useScreens';\nimport { shouldLinkExternally } from '../utils/url';\nimport * as SplashScreen from '../views/Splash';\n\nexport type StoreRedirects = readonly [RegExp, RedirectConfig, boolean];\nexport type ReactNavigationState = NavigationState | PartialState<NavigationState>;\nexport type FocusedRouteState = NonNullable<ReturnType<typeof useStateForPath>>;\n\nexport type RouterStore = typeof store;\n\ntype StoreRef = {\n navigationRef: NavigationContainerRefWithCurrent<ReactNavigation.RootParamList>;\n routeNode: RouteNode | null;\n rootComponent: ComponentType<any>;\n state?: ReactNavigationState;\n focusedState?: FocusedRouteState;\n linking?: ExpoLinkingOptions;\n config: any;\n redirects: StoreRedirects[];\n};\n\nconst storeRef = {\n current: {} as StoreRef,\n};\n\nconst routeInfoCache = new WeakMap<FocusedRouteState | ReactNavigationState, UrlObject>();\n\nlet splashScreenAnimationFrame: number | undefined;\nlet hasAttemptedToHideSplash = false;\n\nexport const store = {\n shouldShowTutorial() {\n return !storeRef.current.routeNode && process.env.NODE_ENV === 'development';\n },\n get state() {\n return storeRef.current.state;\n },\n get focusedState() {\n return storeRef.current.focusedState;\n },\n get navigationRef() {\n return storeRef.current.navigationRef;\n },\n get routeNode() {\n return storeRef.current.routeNode;\n },\n getRouteInfo(\n state: FocusedRouteState | ReactNavigationState | undefined = storeRef.current.focusedState\n ): UrlObject {\n if (!state) {\n return defaultRouteInfo;\n }\n\n let routeInfo = routeInfoCache.get(state);\n\n if (!routeInfo) {\n routeInfo = getRouteInfoFromState(state);\n routeInfoCache.set(state, routeInfo);\n }\n\n return routeInfo;\n },\n get redirects() {\n return storeRef.current.redirects || [];\n },\n get rootComponent() {\n return storeRef.current.rootComponent;\n },\n get linking() {\n return storeRef.current.linking;\n },\n setFocusedState(state: FocusedRouteState) {\n storeRef.current.focusedState = state;\n },\n onReady() {\n if (!hasAttemptedToHideSplash) {\n hasAttemptedToHideSplash = true;\n // NOTE(EvanBacon): `navigationRef.isReady` is sometimes not true when state is called initially.\n splashScreenAnimationFrame = requestAnimationFrame(() => {\n SplashScreen._internal_maybeHideAsync?.();\n });\n }\n\n storeRef.current.navigationRef.addListener('state', (e) => {\n if (e.data.state) {\n storeRef.current.state = e.data.state;\n }\n\n for (const callback of routeInfoSubscribers) {\n callback();\n }\n });\n },\n assertIsReady() {\n if (!storeRef.current.navigationRef.isReady()) {\n throw new Error(\n '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.'\n );\n }\n },\n};\n\nexport function useStore(\n context: RequireContext,\n linkingConfigOptions: LinkingConfigOptions,\n serverUrl?: string\n) {\n const navigationRef = useNavigationContainerRef();\n const config = Constants.expoConfig?.extra?.router;\n\n let linking: ExpoLinkingOptions | undefined;\n let rootComponent: ComponentType<any> = Fragment;\n let initialState: ReactNavigationState | undefined;\n\n const routeNode = getRoutes(context, {\n ...config,\n ignoreEntryPoints: true,\n platform: Platform.OS,\n });\n\n const redirects: StoreRedirects[] = [config?.redirects, config?.rewrites]\n .filter(Boolean)\n .flat()\n .map((route) => {\n return [\n routePatternToRegex(parseRouteSegments(route.source)),\n route,\n shouldLinkExternally(route.destination),\n ];\n });\n\n if (routeNode) {\n // We have routes, so get the linking config and the root component\n linking = getLinkingConfig(routeNode, context, () => store.getRouteInfo(), {\n metaOnly: linkingConfigOptions.metaOnly,\n serverUrl,\n redirects,\n });\n rootComponent = getQualifiedRouteComponent(routeNode);\n\n // By default React Navigation is async and does not render anything in the first pass as it waits for `getInitialURL`\n // This will cause static rendering to fail, which once performs a single pass.\n // If the initialURL is a string, we can prefetch the state and routeInfo, skipping React Navigation's async behavior.\n const initialURL = linking?.getInitialURL?.();\n if (typeof initialURL === 'string') {\n initialState = linking.getStateFromPath(initialURL, linking.config);\n const initialRouteInfo = getRouteInfoFromState(initialState);\n routeInfoCache.set(initialState as any, initialRouteInfo);\n }\n } else {\n // Only error in production, in development we will show the onboarding screen\n if (process.env.NODE_ENV === 'production') {\n throw new Error('No routes found');\n }\n\n // In development, we will show the onboarding screen\n rootComponent = Fragment;\n }\n\n storeRef.current = {\n navigationRef,\n routeNode,\n config,\n rootComponent,\n linking,\n redirects,\n state: initialState,\n };\n\n if (initialState) {\n storeRef.current.focusedState = initialState as FocusedRouteState;\n }\n\n useEffect(() => {\n return () => {\n // listener();\n\n if (splashScreenAnimationFrame) {\n cancelAnimationFrame(splashScreenAnimationFrame);\n splashScreenAnimationFrame = undefined;\n }\n };\n });\n\n return store;\n}\n\nconst routeInfoSubscribers = new Set<() => void>();\nconst routeInfoSubscribe = (callback: () => void) => {\n routeInfoSubscribers.add(callback);\n return () => {\n routeInfoSubscribers.delete(callback);\n };\n};\n\nexport function useRouteInfo() {\n return useSyncExternalStore(routeInfoSubscribe, store.getRouteInfo, store.getRouteInfo);\n}\n"]}
|
|
@@ -1,19 +1,18 @@
|
|
|
1
|
-
import { type RouterStore } from './router-store';
|
|
2
1
|
import { Href } from '../types';
|
|
3
2
|
import { SingularOptions } from '../useScreens';
|
|
4
3
|
export type NavigationOptions = Omit<LinkToOptions, 'event'>;
|
|
5
|
-
export declare function navigate(
|
|
6
|
-
export declare function reload(
|
|
7
|
-
export declare function prefetch(
|
|
8
|
-
export declare function push(
|
|
9
|
-
export declare function dismiss(
|
|
10
|
-
export declare function dismissTo(
|
|
11
|
-
export declare function replace(
|
|
12
|
-
export declare function dismissAll(
|
|
13
|
-
export declare function goBack(
|
|
14
|
-
export declare function canGoBack(
|
|
15
|
-
export declare function canDismiss(
|
|
16
|
-
export declare function setParams(
|
|
4
|
+
export declare function navigate(url: Href, options?: NavigationOptions): void;
|
|
5
|
+
export declare function reload(): void;
|
|
6
|
+
export declare function prefetch(href: Href, options?: NavigationOptions): void;
|
|
7
|
+
export declare function push(url: Href, options?: NavigationOptions): void;
|
|
8
|
+
export declare function dismiss(count?: number): void;
|
|
9
|
+
export declare function dismissTo(href: Href, options?: NavigationOptions): void;
|
|
10
|
+
export declare function replace(url: Href, options?: NavigationOptions): void;
|
|
11
|
+
export declare function dismissAll(): void;
|
|
12
|
+
export declare function goBack(): void;
|
|
13
|
+
export declare function canGoBack(): boolean;
|
|
14
|
+
export declare function canDismiss(): boolean;
|
|
15
|
+
export declare function setParams(params?: Record<string, undefined | string | number | (string | number)[]>): any;
|
|
17
16
|
export type LinkToOptions = {
|
|
18
17
|
event?: string;
|
|
19
18
|
/**
|
|
@@ -32,5 +31,5 @@ export type LinkToOptions = {
|
|
|
32
31
|
*/
|
|
33
32
|
dangerouslySingular?: SingularOptions;
|
|
34
33
|
};
|
|
35
|
-
export declare function linkTo(
|
|
34
|
+
export declare function linkTo(originalHref: Href, options?: LinkToOptions): void;
|
|
36
35
|
//# sourceMappingURL=routing.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routing.d.ts","sourceRoot":"","sources":["../../src/global-state/routing.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"routing.d.ts","sourceRoot":"","sources":["../../src/global-state/routing.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAWhD,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;AAE7D,wBAAgB,QAAQ,CAAC,GAAG,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,iBAAiB,QAE9D;AAED,wBAAgB,MAAM,SAGrB;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,iBAAiB,QAE/D;AAED,wBAAgB,IAAI,CAAC,GAAG,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,iBAAiB,QAE1D;AAED,wBAAgB,OAAO,CAAC,KAAK,GAAE,MAAU,QAMxC;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,iBAAiB,QAEhE;AAED,wBAAgB,OAAO,CAAC,GAAG,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,iBAAiB,QAE7D;AAED,wBAAgB,UAAU,SAKzB;AAED,wBAAgB,MAAM,SAMrB;AAED,wBAAgB,SAAS,IAAI,OAAO,CAenC;AAED,wBAAgB,UAAU,IAAI,OAAO,CAmBpC;AAED,wBAAgB,SAAS,CACvB,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAM,OAO/E;AAED,MAAM,MAAM,aAAa,GAAG;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;;OAGG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAE9B;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;I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