expo-router 3.1.2 → 3.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/_ctx.android.js +1 -1
- package/_ctx.ios.js +1 -1
- package/_ctx.web.js +1 -1
- package/babel.js +1 -209
- package/build/ExpoRoot.d.ts.map +1 -1
- package/build/ExpoRoot.js +57 -15
- package/build/ExpoRoot.js.map +1 -1
- package/build/LocationProvider.d.ts +3 -2
- package/build/LocationProvider.d.ts.map +1 -1
- package/build/LocationProvider.js +31 -7
- package/build/LocationProvider.js.map +1 -1
- package/build/Route.d.ts +3 -0
- package/build/Route.d.ts.map +1 -1
- package/build/Route.js +1 -1
- package/build/Route.js.map +1 -1
- package/build/fork/NavigationContainer.native.js +5 -3
- package/build/fork/NavigationContainer.native.js.map +1 -1
- package/build/fork/extractPathFromURL.d.ts.map +1 -1
- package/build/fork/extractPathFromURL.js +17 -16
- package/build/fork/extractPathFromURL.js.map +1 -1
- package/build/fork/getPathFromState.d.ts +1 -1
- package/build/fork/getPathFromState.d.ts.map +1 -1
- package/build/fork/getPathFromState.js +17 -38
- package/build/fork/getPathFromState.js.map +1 -1
- package/build/fork/getStateFromPath.d.ts +2 -2
- package/build/fork/getStateFromPath.d.ts.map +1 -1
- package/build/fork/getStateFromPath.js +71 -52
- package/build/fork/getStateFromPath.js.map +1 -1
- package/build/getDevServer/index.d.ts +0 -3
- package/build/getDevServer/index.d.ts.map +1 -1
- package/build/getDevServer/index.js +1 -28
- package/build/getDevServer/index.js.map +1 -1
- package/build/getReactNavigationConfig.d.ts.map +1 -1
- package/build/getReactNavigationConfig.js +3 -0
- package/build/getReactNavigationConfig.js.map +1 -1
- package/build/getRoutes.d.ts +8 -5
- package/build/getRoutes.d.ts.map +1 -1
- package/build/getRoutes.js +150 -67
- package/build/getRoutes.js.map +1 -1
- package/build/getServerManifest.d.ts +14 -33
- package/build/getServerManifest.d.ts.map +1 -1
- package/build/getServerManifest.js +6 -5
- package/build/getServerManifest.js.map +1 -1
- package/build/global-state/router-store.d.ts.map +1 -1
- package/build/global-state/router-store.js +29 -3
- package/build/global-state/router-store.js.map +1 -1
- package/build/global-state/routing.d.ts +0 -4
- package/build/global-state/routing.d.ts.map +1 -1
- package/build/global-state/routing.js +76 -96
- package/build/global-state/routing.js.map +1 -1
- package/build/head/ExpoHead.ios.js +4 -4
- package/build/head/ExpoHead.ios.js.map +1 -1
- package/build/head/ExpoHead.js +1 -1
- package/build/head/ExpoHead.js.map +1 -1
- package/build/head/url.d.ts.map +1 -1
- package/build/head/url.js +5 -6
- package/build/head/url.js.map +1 -1
- package/build/hooks.d.ts.map +1 -1
- package/build/hooks.js +24 -5
- package/build/hooks.js.map +1 -1
- package/build/import-mode/index.d.ts +1 -1
- package/build/import-mode/index.d.ts.map +1 -1
- package/build/import-mode/index.js +1 -1
- package/build/import-mode/index.js.map +1 -1
- package/build/layouts/Tabs.js +2 -2
- package/build/layouts/Tabs.js.map +1 -1
- package/build/layouts/withLayoutContext.js +1 -1
- package/build/layouts/withLayoutContext.js.map +1 -1
- package/build/link/Link.d.ts +54 -1
- package/build/link/Link.d.ts.map +1 -1
- package/build/link/Link.js +54 -12
- package/build/link/Link.js.map +1 -1
- package/build/link/useLinkToPathProps.js +2 -2
- package/build/link/useLinkToPathProps.js.map +1 -1
- package/build/loadStaticParamsAsync.d.ts +1 -0
- package/build/loadStaticParamsAsync.d.ts.map +1 -1
- package/build/loadStaticParamsAsync.js +107 -72
- package/build/loadStaticParamsAsync.js.map +1 -1
- package/build/matchers.js +1 -1
- package/build/matchers.js.map +1 -1
- package/build/onboard/Tutorial.js +41 -34
- package/build/onboard/Tutorial.js.map +1 -1
- package/build/qualified-entry.d.ts.map +1 -1
- package/build/qualified-entry.js +10 -7
- package/build/qualified-entry.js.map +1 -1
- package/build/renderRootComponent.d.ts.map +1 -1
- package/build/renderRootComponent.js +28 -4
- package/build/renderRootComponent.js.map +1 -1
- package/build/routes-manifest.d.ts +1 -0
- package/build/routes-manifest.d.ts.map +1 -1
- package/build/routes-manifest.js +1 -0
- package/build/routes-manifest.js.map +1 -1
- package/build/sortRoutes.d.ts.map +1 -1
- package/build/sortRoutes.js +21 -2
- package/build/sortRoutes.js.map +1 -1
- package/build/static/html.d.ts.map +1 -1
- package/build/static/html.js +12 -10
- package/build/static/html.js.map +1 -1
- package/build/static/renderStaticContent.d.ts +13 -3
- package/build/static/renderStaticContent.d.ts.map +1 -1
- package/build/static/renderStaticContent.js +35 -11
- package/build/static/renderStaticContent.js.map +1 -1
- package/build/testing-library/index.js +3 -5
- package/build/testing-library/index.js.map +1 -1
- package/build/testing-library/mocks.d.ts +1 -3
- package/build/testing-library/mocks.d.ts.map +1 -1
- package/build/testing-library/mocks.js +17 -10
- package/build/testing-library/mocks.js.map +1 -1
- package/build/testing-library/require-context-ponyfill.js +3 -3
- package/build/testing-library/require-context-ponyfill.js.map +1 -1
- package/build/useScreens.d.ts.map +1 -1
- package/build/useScreens.js +19 -23
- package/build/useScreens.js.map +1 -1
- package/build/utils/url.d.ts +2 -0
- package/build/utils/url.d.ts.map +1 -1
- package/build/utils/url.js +13 -1
- package/build/utils/url.js.map +1 -1
- package/build/views/EmptyRoute.js +5 -2
- package/build/views/EmptyRoute.js.map +1 -1
- package/build/views/ErrorBoundary.js +50 -31
- package/build/views/ErrorBoundary.js.map +1 -1
- package/build/views/Navigator.js +16 -10
- package/build/views/Navigator.js.map +1 -1
- package/build/views/Sitemap.js +54 -36
- package/build/views/Sitemap.js.map +1 -1
- package/build/views/Splash.d.ts +1 -27
- package/build/views/Splash.d.ts.map +1 -1
- package/build/views/Splash.js +2 -112
- package/build/views/Splash.js.map +1 -1
- package/build/views/SuspenseFallback.d.ts +1 -1
- package/build/views/SuspenseFallback.d.ts.map +1 -1
- package/build/views/SuspenseFallback.js +7 -2
- package/build/views/SuspenseFallback.js.map +1 -1
- package/build/views/Toast.js +23 -18
- package/build/views/Toast.js.map +1 -1
- package/build/views/Try.js +1 -1
- package/build/views/Try.js.map +1 -1
- package/build/views/Unmatched.js +29 -17
- package/build/views/Unmatched.js.map +1 -1
- package/html.d.ts +1 -0
- package/ios/ExpoHead.podspec +1 -1
- package/ios/ExpoHeadModule.swift +0 -2
- package/package.json +11 -19
- package/plugin/build/index.d.ts +2 -2
- package/plugin/options.json +3 -3
- package/build/fork/react-native-web-container.d.ts +0 -8
- package/build/fork/react-native-web-container.d.ts.map +0 -1
- package/build/fork/react-native-web-container.js +0 -8
- package/build/fork/react-native-web-container.js.map +0 -1
- package/build/import-mode/index.android.d.ts +0 -3
- package/build/import-mode/index.android.d.ts.map +0 -1
- package/build/import-mode/index.android.js +0 -4
- package/build/import-mode/index.android.js.map +0 -1
- package/build/import-mode/index.ios.d.ts +0 -3
- package/build/import-mode/index.ios.d.ts.map +0 -1
- package/build/import-mode/index.ios.js +0 -4
- package/build/import-mode/index.ios.js.map +0 -1
- package/build/import-mode/index.web.d.ts +0 -3
- package/build/import-mode/index.web.d.ts.map +0 -1
- package/build/import-mode/index.web.js +0 -4
- package/build/import-mode/index.web.js.map +0 -1
- package/build/link/stateOperations.d.ts +0 -81
- package/build/link/stateOperations.d.ts.map +0 -1
- package/build/link/stateOperations.js +0 -105
- package/build/link/stateOperations.js.map +0 -1
- package/types/global.d.ts +0 -38
- package/types/metro-require.d.ts +0 -52
- package/types/react-native-web.d.ts +0 -295
package/_ctx.android.js
CHANGED
package/_ctx.ios.js
CHANGED
package/_ctx.web.js
CHANGED
package/babel.js
CHANGED
|
@@ -1,209 +1 @@
|
|
|
1
|
-
|
|
2
|
-
const fs = require('fs');
|
|
3
|
-
const nodePath = require('path');
|
|
4
|
-
const resolveFrom = require('resolve-from');
|
|
5
|
-
|
|
6
|
-
const { getExpoConstantsManifest } = require('./node/getExpoConstantsManifest');
|
|
7
|
-
|
|
8
|
-
const debug = require('debug')('expo:router:babel');
|
|
9
|
-
|
|
10
|
-
function getExpoAppManifest(projectRoot) {
|
|
11
|
-
if (process.env.APP_MANIFEST) {
|
|
12
|
-
return process.env.APP_MANIFEST;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const exp = getExpoConstantsManifest(projectRoot);
|
|
16
|
-
|
|
17
|
-
debug('public manifest', exp);
|
|
18
|
-
|
|
19
|
-
return JSON.stringify(exp);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
let config;
|
|
23
|
-
|
|
24
|
-
function getConfigMemo(projectRoot) {
|
|
25
|
-
if (!config) {
|
|
26
|
-
config = getConfig(projectRoot);
|
|
27
|
-
}
|
|
28
|
-
return config;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function getExpoRouterImportMode(projectRoot, platform) {
|
|
32
|
-
const envVar = 'EXPO_ROUTER_IMPORT_MODE_' + platform.toUpperCase();
|
|
33
|
-
if (process.env[envVar]) {
|
|
34
|
-
return process.env[envVar];
|
|
35
|
-
}
|
|
36
|
-
const env = process.env.NODE_ENV || process.env.BABEL_ENV;
|
|
37
|
-
|
|
38
|
-
const { exp } = getConfigMemo(projectRoot);
|
|
39
|
-
|
|
40
|
-
let asyncRoutesSetting;
|
|
41
|
-
|
|
42
|
-
if (exp.extra?.router?.asyncRoutes) {
|
|
43
|
-
const asyncRoutes = exp.extra?.router?.asyncRoutes;
|
|
44
|
-
if (typeof asyncRoutes === 'string') {
|
|
45
|
-
asyncRoutesSetting = asyncRoutes;
|
|
46
|
-
} else if (typeof asyncRoutes === 'object') {
|
|
47
|
-
asyncRoutesSetting = asyncRoutes[platform] ?? asyncRoutes.default;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
let mode = [env, true].includes(asyncRoutesSetting) ? 'lazy' : 'sync';
|
|
52
|
-
|
|
53
|
-
// TODO: Production bundle splitting
|
|
54
|
-
|
|
55
|
-
if (env === 'production' && mode === 'lazy') {
|
|
56
|
-
throw new Error(
|
|
57
|
-
'Async routes are not supported in production yet. Set the `expo-router` Config Plugin prop `asyncRoutes` to `development`, `false`, or `undefined`.'
|
|
58
|
-
);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// NOTE: This is a temporary workaround for static rendering on web.
|
|
62
|
-
if (platform === 'web' && (exp.web || {}).output === 'static') {
|
|
63
|
-
mode = 'sync';
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// Development
|
|
67
|
-
debug('Router import mode', mode);
|
|
68
|
-
|
|
69
|
-
process.env[envVar] = mode;
|
|
70
|
-
return mode;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
function directoryExistsSync(file) {
|
|
74
|
-
return fs.statSync(file, { throwIfNoEntry: false })?.isDirectory() ?? false;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
function getRouterDirectory(projectRoot) {
|
|
78
|
-
// more specific directories first
|
|
79
|
-
if (directoryExistsSync(nodePath.join(projectRoot, 'src/app'))) {
|
|
80
|
-
// Log.log(chalk.gray('Using src/app as the root directory for Expo Router.'));
|
|
81
|
-
return './src/app';
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
// Log.debug('Using app as the root directory for Expo Router.');
|
|
85
|
-
return './app';
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
function getExpoRouterAppRoot(projectRoot) {
|
|
89
|
-
// Bump to v2 to prevent the CLI from setting the variable anymore.
|
|
90
|
-
// TODO: Bump to v3 to revert back to the CLI setting the variable again, but with custom value
|
|
91
|
-
// support.
|
|
92
|
-
if (process.env.EXPO_ROUTER_APP_ROOT_2) {
|
|
93
|
-
return process.env.EXPO_ROUTER_APP_ROOT_2;
|
|
94
|
-
}
|
|
95
|
-
const routerEntry = resolveFrom.silent(projectRoot, 'expo-router/entry');
|
|
96
|
-
|
|
97
|
-
// It doesn't matter if the app folder exists.
|
|
98
|
-
const appFolder = getExpoRouterAbsoluteAppRoot(projectRoot);
|
|
99
|
-
const appRoot = nodePath.relative(nodePath.dirname(routerEntry), appFolder);
|
|
100
|
-
debug('routerEntry', routerEntry, appFolder, appRoot);
|
|
101
|
-
|
|
102
|
-
process.env.EXPO_ROUTER_APP_ROOT_2 = appRoot;
|
|
103
|
-
return appRoot;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
function getExpoRouterAbsoluteAppRoot(projectRoot) {
|
|
107
|
-
if (process.env.EXPO_ROUTER_ABS_APP_ROOT) {
|
|
108
|
-
return process.env.EXPO_ROUTER_ABS_APP_ROOT;
|
|
109
|
-
}
|
|
110
|
-
const { exp } = getConfigMemo(projectRoot);
|
|
111
|
-
const customSrc = exp.extra?.router?.unstable_src || getRouterDirectory(projectRoot);
|
|
112
|
-
const isAbsolute = customSrc.startsWith('/');
|
|
113
|
-
// It doesn't matter if the app folder exists.
|
|
114
|
-
const appFolder = isAbsolute ? customSrc : nodePath.join(projectRoot, customSrc);
|
|
115
|
-
const appRoot = appFolder;
|
|
116
|
-
debug('absolute router entry', appFolder, appRoot);
|
|
117
|
-
|
|
118
|
-
process.env.EXPO_ROUTER_ABS_APP_ROOT = appFolder;
|
|
119
|
-
return appRoot;
|
|
120
|
-
}
|
|
121
|
-
// TODO: Strip the function `generateStaticParams` when bundling for node.js environments.
|
|
122
|
-
|
|
123
|
-
module.exports = function (api) {
|
|
124
|
-
const { types: t } = api;
|
|
125
|
-
|
|
126
|
-
const platform = api.caller((caller) => caller?.platform);
|
|
127
|
-
return {
|
|
128
|
-
name: 'expo-router',
|
|
129
|
-
visitor: {
|
|
130
|
-
// Convert `process.env.EXPO_ROUTER_APP_ROOT` to a string literal
|
|
131
|
-
MemberExpression(path, state) {
|
|
132
|
-
if (
|
|
133
|
-
!t.isIdentifier(path.node.object, { name: 'process' }) ||
|
|
134
|
-
!t.isIdentifier(path.node.property, { name: 'env' })
|
|
135
|
-
) {
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
const parent = path.parentPath;
|
|
140
|
-
if (!t.isMemberExpression(parent.node)) {
|
|
141
|
-
return;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
const projectRoot = process.env.EXPO_PROJECT_ROOT || state.file.opts.root || '';
|
|
145
|
-
|
|
146
|
-
// Used for log box and stuff
|
|
147
|
-
if (
|
|
148
|
-
t.isIdentifier(parent.node.property, {
|
|
149
|
-
name: 'EXPO_PROJECT_ROOT',
|
|
150
|
-
}) &&
|
|
151
|
-
!parent.parentPath.isAssignmentExpression()
|
|
152
|
-
) {
|
|
153
|
-
parent.replaceWith(t.stringLiteral(projectRoot));
|
|
154
|
-
} else if (
|
|
155
|
-
// Enable static rendering
|
|
156
|
-
// TODO: Use a serializer or something to ensure this changes without
|
|
157
|
-
// needing to clear the cache.
|
|
158
|
-
t.isIdentifier(parent.node.property, {
|
|
159
|
-
name: 'EXPO_PUBLIC_USE_STATIC',
|
|
160
|
-
}) &&
|
|
161
|
-
!parent.parentPath.isAssignmentExpression() &&
|
|
162
|
-
process.env.EXPO_PUBLIC_USE_STATIC
|
|
163
|
-
) {
|
|
164
|
-
parent.replaceWith(t.stringLiteral(process.env.EXPO_PUBLIC_USE_STATIC));
|
|
165
|
-
} else if (
|
|
166
|
-
// Surfaces the `app.json` (config) as an environment variable which is then parsed by
|
|
167
|
-
// `expo-constants` https://docs.expo.dev/versions/latest/sdk/constants/
|
|
168
|
-
t.isIdentifier(parent.node.property, {
|
|
169
|
-
name: 'APP_MANIFEST',
|
|
170
|
-
}) &&
|
|
171
|
-
!parent.parentPath.isAssignmentExpression()
|
|
172
|
-
) {
|
|
173
|
-
const manifest = getExpoAppManifest(projectRoot);
|
|
174
|
-
parent.replaceWith(t.stringLiteral(manifest));
|
|
175
|
-
} else if (
|
|
176
|
-
process.env.NODE_ENV !== 'test' &&
|
|
177
|
-
t.isIdentifier(parent.node.property, {
|
|
178
|
-
name: 'EXPO_ROUTER_ABS_APP_ROOT',
|
|
179
|
-
}) &&
|
|
180
|
-
!parent.parentPath.isAssignmentExpression()
|
|
181
|
-
) {
|
|
182
|
-
parent.replaceWith(t.stringLiteral(getExpoRouterAbsoluteAppRoot(projectRoot)));
|
|
183
|
-
} else if (
|
|
184
|
-
// Skip loading the app root in tests.
|
|
185
|
-
// This is handled by the testing-library utils
|
|
186
|
-
process.env.NODE_ENV !== 'test' &&
|
|
187
|
-
t.isIdentifier(parent.node.property, {
|
|
188
|
-
name: 'EXPO_ROUTER_APP_ROOT',
|
|
189
|
-
}) &&
|
|
190
|
-
!parent.parentPath.isAssignmentExpression()
|
|
191
|
-
) {
|
|
192
|
-
parent.replaceWith(
|
|
193
|
-
// This is defined in Expo CLI when using Metro. It points to the relative path for the project app directory.
|
|
194
|
-
t.stringLiteral(getExpoRouterAppRoot(projectRoot))
|
|
195
|
-
);
|
|
196
|
-
} else if (
|
|
197
|
-
// Expose the app route import mode.
|
|
198
|
-
platform &&
|
|
199
|
-
t.isIdentifier(parent.node.property, {
|
|
200
|
-
name: 'EXPO_ROUTER_IMPORT_MODE_' + platform.toUpperCase(),
|
|
201
|
-
}) &&
|
|
202
|
-
!parent.parentPath.isAssignmentExpression()
|
|
203
|
-
) {
|
|
204
|
-
parent.replaceWith(t.stringLiteral(getExpoRouterImportMode(projectRoot, platform)));
|
|
205
|
-
}
|
|
206
|
-
},
|
|
207
|
-
},
|
|
208
|
-
};
|
|
209
|
-
};
|
|
1
|
+
throw new Error('expo-router/babel is deprecated in favor of babel-preset-expo in SDK 50.');
|
package/build/ExpoRoot.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoRoot.d.ts","sourceRoot":"","sources":["../src/ExpoRoot.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ExpoRoot.d.ts","sourceRoot":"","sources":["../src/ExpoRoot.tsx"],"names":[],"mappings":"AAGA,OAAc,EAAE,iBAAiB,EAAE,SAAS,EAAY,MAAM,OAAO,CAAC;AAMtE,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAGzC,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,EAAE,cAAc,CAAC;IACxB,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,OAAO,CAAC,EAAE,iBAAiB,CAAC;QAAE,QAAQ,EAAE,SAAS,CAAA;KAAE,CAAC,CAAC;CACtD,CAAC;AAgBF,wBAAgB,QAAQ,CAAC,EAAE,OAAO,EAAE,aAAwB,EAAE,GAAG,KAAK,EAAE,EAAE,aAAa,eAqBtF"}
|
package/build/ExpoRoot.js
CHANGED
|
@@ -51,16 +51,17 @@ function ExpoRoot({ wrapper: ParentWrapper = react_1.Fragment, ...props }) {
|
|
|
51
51
|
* is a HTML document, we need to ensure its inside the <body>
|
|
52
52
|
*/
|
|
53
53
|
const wrapper = ({ children }) => {
|
|
54
|
-
return (
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
54
|
+
return (<ParentWrapper>
|
|
55
|
+
<react_native_safe_area_context_1.SafeAreaProvider
|
|
56
|
+
// SSR support
|
|
57
|
+
initialMetrics={INITIAL_METRICS}>
|
|
58
|
+
{children}
|
|
59
|
+
{/* Users can override this by adding another StatusBar element anywhere higher in the component tree. */}
|
|
60
|
+
{!hasViewControllerBasedStatusBarAppearance && <expo_status_bar_1.StatusBar style="auto"/>}
|
|
61
|
+
</react_native_safe_area_context_1.SafeAreaProvider>
|
|
62
|
+
</ParentWrapper>);
|
|
62
63
|
};
|
|
63
|
-
return
|
|
64
|
+
return <ContextNavigator {...props} wrapper={wrapper}/>;
|
|
64
65
|
}
|
|
65
66
|
exports.ExpoRoot = ExpoRoot;
|
|
66
67
|
const initialUrl = react_native_1.Platform.OS === 'web' && typeof window !== 'undefined'
|
|
@@ -72,8 +73,9 @@ function ContextNavigator({ context, location: initialLocation = initialUrl, wra
|
|
|
72
73
|
Splash_1.SplashScreen.hideAsync();
|
|
73
74
|
if (process.env.NODE_ENV === 'development') {
|
|
74
75
|
const Tutorial = require('./onboard/Tutorial').Tutorial;
|
|
75
|
-
return (
|
|
76
|
-
|
|
76
|
+
return (<WrapperComponent>
|
|
77
|
+
<Tutorial />
|
|
78
|
+
</WrapperComponent>);
|
|
77
79
|
}
|
|
78
80
|
else {
|
|
79
81
|
// Ensure tutorial styles are stripped in production.
|
|
@@ -81,10 +83,50 @@ function ContextNavigator({ context, location: initialLocation = initialUrl, wra
|
|
|
81
83
|
}
|
|
82
84
|
}
|
|
83
85
|
const Component = store.rootComponent;
|
|
84
|
-
return (
|
|
86
|
+
return (<NavigationContainer_1.default ref={store.navigationRef} initialState={store.initialState} linking={store.linking} onUnhandledAction={onUnhandledAction} documentTitle={{
|
|
85
87
|
enabled: false,
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
|
|
88
|
+
}}>
|
|
89
|
+
<WrapperComponent>
|
|
90
|
+
<Component />
|
|
91
|
+
</WrapperComponent>
|
|
92
|
+
</NavigationContainer_1.default>);
|
|
93
|
+
}
|
|
94
|
+
let onUnhandledAction;
|
|
95
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
96
|
+
onUnhandledAction = (action) => {
|
|
97
|
+
const payload = action.payload;
|
|
98
|
+
let message = `The action '${action.type}'${payload ? ` with payload ${JSON.stringify(action.payload)}` : ''} was not handled by any navigator.`;
|
|
99
|
+
switch (action.type) {
|
|
100
|
+
case 'NAVIGATE':
|
|
101
|
+
case 'PUSH':
|
|
102
|
+
case 'REPLACE':
|
|
103
|
+
case 'JUMP_TO':
|
|
104
|
+
if (payload?.name) {
|
|
105
|
+
message += `\n\nDo you have a route named '${payload.name}'?`;
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
message += `\n\nYou need to pass the name of the screen to navigate to. This may be a bug.`;
|
|
109
|
+
}
|
|
110
|
+
break;
|
|
111
|
+
case 'GO_BACK':
|
|
112
|
+
case 'POP':
|
|
113
|
+
case 'POP_TO_TOP':
|
|
114
|
+
message += `\n\nIs there any screen to go back to?`;
|
|
115
|
+
break;
|
|
116
|
+
case 'OPEN_DRAWER':
|
|
117
|
+
case 'CLOSE_DRAWER':
|
|
118
|
+
case 'TOGGLE_DRAWER':
|
|
119
|
+
message += `\n\nIs your screen inside a Drawer navigator?`;
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
message += `\n\nThis is a development-only warning and won't be shown in production.`;
|
|
123
|
+
if (process.env.NODE_ENV === 'test') {
|
|
124
|
+
throw new Error(message);
|
|
125
|
+
}
|
|
126
|
+
console.error(message);
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
onUnhandledAction = function () { };
|
|
89
131
|
}
|
|
90
132
|
//# sourceMappingURL=ExpoRoot.js.map
|
package/build/ExpoRoot.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoRoot.js","sourceRoot":"","sources":["../src/ExpoRoot.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"ExpoRoot.js","sourceRoot":"","sources":["../src/ExpoRoot.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,oEAAuC;AACvC,qDAA4C;AAC5C,+CAAsE;AACtE,+CAAwC;AACxC,mFAAkE;AAElE,qFAAqE;AACrE,8DAAsE;AAEtE,2CAA8C;AAQ9C,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,MAAM,CAAC;AAElD,MAAM,eAAe,GACnB,uBAAQ,CAAC,EAAE,KAAK,KAAK,IAAI,SAAS;IAChC,CAAC,CAAC;QACE,KAAK,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE;QAC1C,MAAM,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE;KACjD;IACH,CAAC,CAAC,SAAS,CAAC;AAEhB,MAAM,yCAAyC,GAC7C,uBAAQ,CAAC,EAAE,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,IAAI,EAAE;oBACjB,OAAO,IAAI,kCAAkC,OAAO,CAAC,IAAI,IAAI,CAAC;iBAC/D;qBAAM;oBACL,OAAO,IAAI,gFAAgF,CAAC;iBAC7F;gBAED,MAAM;YACR,KAAK,SAAS,CAAC;YACf,KAAK,KAAK,CAAC;YACX,KAAK,YAAY;gBACf,OAAO,IAAI,wCAAwC,CAAC;gBACpD,MAAM;YACR,KAAK,aAAa,CAAC;YACnB,KAAK,cAAc,CAAC;YACpB,KAAK,eAAe;gBAClB,OAAO,IAAI,+CAA+C,CAAC;gBAC3D,MAAM;SACT;QAED,OAAO,IAAI,0EAA0E,CAAC;QAEtF,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,MAAM,EAAE;YACnC,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;SAC1B;QACD,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACzB,CAAC,CAAC;CACH;KAAM;IACL,iBAAiB,GAAG,cAAa,CAAC,CAAC;CACpC","sourcesContent":["import { NavigationAction } from '@react-navigation/native';\nimport Constants from 'expo-constants';\nimport { StatusBar } from 'expo-status-bar';\nimport React, { FunctionComponent, ReactNode, Fragment } from 'react';\nimport { Platform } from 'react-native';\nimport { SafeAreaProvider } from 'react-native-safe-area-context';\n\nimport UpstreamNavigationContainer from './fork/NavigationContainer';\nimport { useInitializeExpoRouter } from './global-state/router-store';\nimport { RequireContext } from './types';\nimport { SplashScreen } from './views/Splash';\n\nexport type ExpoRootProps = {\n context: RequireContext;\n location?: URL;\n wrapper?: FunctionComponent<{ children: ReactNode }>;\n};\n\nconst isTestEnv = process.env.NODE_ENV === 'test';\n\nconst INITIAL_METRICS =\n Platform.OS === 'web' || isTestEnv\n ? {\n frame: { x: 0, y: 0, width: 0, height: 0 },\n insets: { top: 0, left: 0, right: 0, bottom: 0 },\n }\n : undefined;\n\nconst hasViewControllerBasedStatusBarAppearance =\n Platform.OS === 'ios' &&\n !!Constants.expoConfig?.ios?.infoPlist?.UIViewControllerBasedStatusBarAppearance;\n\nexport function ExpoRoot({ wrapper: ParentWrapper = Fragment, ...props }: ExpoRootProps) {\n /*\n * Due to static rendering we need to wrap these top level views in second wrapper\n * View's like <SafeAreaProvider /> generate a <div> so if the parent wrapper\n * is a HTML document, we need to ensure its inside the <body>\n */\n const wrapper = ({ children }) => {\n return (\n <ParentWrapper>\n <SafeAreaProvider\n // SSR support\n initialMetrics={INITIAL_METRICS}>\n {children}\n {/* Users can override this by adding another StatusBar element anywhere higher in the component tree. */}\n {!hasViewControllerBasedStatusBarAppearance && <StatusBar style=\"auto\" />}\n </SafeAreaProvider>\n </ParentWrapper>\n );\n };\n\n return <ContextNavigator {...props} wrapper={wrapper} />;\n}\n\nconst initialUrl =\n Platform.OS === 'web' && typeof window !== 'undefined'\n ? new URL(window.location.href)\n : undefined;\n\nfunction ContextNavigator({\n context,\n location: initialLocation = initialUrl,\n wrapper: WrapperComponent = Fragment,\n}: ExpoRootProps) {\n const store = useInitializeExpoRouter(context, initialLocation);\n\n if (store.shouldShowTutorial()) {\n SplashScreen.hideAsync();\n if (process.env.NODE_ENV === 'development') {\n const Tutorial = require('./onboard/Tutorial').Tutorial;\n return (\n <WrapperComponent>\n <Tutorial />\n </WrapperComponent>\n );\n } else {\n // Ensure tutorial styles are stripped in production.\n return null;\n }\n }\n\n const Component = store.rootComponent;\n\n return (\n <UpstreamNavigationContainer\n ref={store.navigationRef}\n initialState={store.initialState}\n linking={store.linking}\n onUnhandledAction={onUnhandledAction}\n documentTitle={{\n enabled: false,\n }}>\n <WrapperComponent>\n <Component />\n </WrapperComponent>\n </UpstreamNavigationContainer>\n );\n}\n\nlet onUnhandledAction: (action: NavigationAction) => void;\n\nif (process.env.NODE_ENV !== 'production') {\n onUnhandledAction = (action: NavigationAction) => {\n const payload: Record<string, any> | undefined = action.payload;\n\n let message = `The action '${action.type}'${\n payload ? ` with payload ${JSON.stringify(action.payload)}` : ''\n } was not handled by any navigator.`;\n\n switch (action.type) {\n case 'NAVIGATE':\n case 'PUSH':\n case 'REPLACE':\n case 'JUMP_TO':\n if (payload?.name) {\n message += `\\n\\nDo you have a route named '${payload.name}'?`;\n } else {\n message += `\\n\\nYou need to pass the name of the screen to navigate to. This may be a bug.`;\n }\n\n break;\n case 'GO_BACK':\n case 'POP':\n case 'POP_TO_TOP':\n message += `\\n\\nIs there any screen to go back to?`;\n break;\n case 'OPEN_DRAWER':\n case 'CLOSE_DRAWER':\n case 'TOGGLE_DRAWER':\n message += `\\n\\nIs your screen inside a Drawer navigator?`;\n break;\n }\n\n message += `\\n\\nThis is a development-only warning and won't be shown in production.`;\n\n if (process.env.NODE_ENV === 'test') {\n throw new Error(message);\n }\n console.error(message);\n };\n} else {\n onUnhandledAction = function () {};\n}\n"]}
|
|
@@ -5,14 +5,15 @@ export type UrlObject = {
|
|
|
5
5
|
pathname: string;
|
|
6
6
|
readonly params: SearchParams;
|
|
7
7
|
segments: string[];
|
|
8
|
+
isIndex: boolean;
|
|
8
9
|
};
|
|
9
10
|
export declare function getRouteInfoFromState(getPathFromState: (state: State, asPath: boolean) => {
|
|
10
11
|
path: string;
|
|
11
12
|
params: any;
|
|
12
|
-
}, state: State,
|
|
13
|
+
}, state: State, baseUrl?: string): UrlObject;
|
|
13
14
|
export declare function getNormalizedStatePath({ path: statePath, params, }: {
|
|
14
15
|
path: string;
|
|
15
16
|
params: any;
|
|
16
|
-
},
|
|
17
|
+
}, baseUrl?: string): Pick<UrlObject, 'segments' | 'params'>;
|
|
17
18
|
export {};
|
|
18
19
|
//# sourceMappingURL=LocationProvider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LocationProvider.d.ts","sourceRoot":"","sources":["../src/LocationProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAGrD,KAAK,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC;AAEtD,MAAM,MAAM,SAAS,GAAG;IACtB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,EAAE,MAAM,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"LocationProvider.d.ts","sourceRoot":"","sources":["../src/LocationProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAGrD,KAAK,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC;AAEtD,MAAM,MAAM,SAAS,GAAG;IACtB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,wBAAgB,qBAAqB,CACnC,gBAAgB,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,KAAK;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,GAAG,CAAA;CAAE,EAClF,KAAK,EAAE,KAAK,EACZ,OAAO,CAAC,EAAE,MAAM,GACf,SAAS,CAWX;AAeD,wBAAgB,sBAAsB,CACpC,EACE,IAAI,EAAE,SAAS,EACf,MAAM,GACP,EAAE;IACD,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,GAAG,CAAC;CACb,EACD,OAAO,CAAC,EAAE,MAAM,GACf,IAAI,CAAC,SAAS,EAAE,UAAU,GAAG,QAAQ,CAAC,CA0BxC"}
|
|
@@ -2,31 +2,55 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getNormalizedStatePath = exports.getRouteInfoFromState = void 0;
|
|
4
4
|
const getStateFromPath_1 = require("./fork/getStateFromPath");
|
|
5
|
-
function getRouteInfoFromState(getPathFromState, state,
|
|
5
|
+
function getRouteInfoFromState(getPathFromState, state, baseUrl) {
|
|
6
6
|
const { path } = getPathFromState(state, false);
|
|
7
7
|
const qualified = getPathFromState(state, true);
|
|
8
8
|
return {
|
|
9
9
|
// TODO: This may have a predefined origin attached in the future.
|
|
10
10
|
unstable_globalHref: path,
|
|
11
|
-
pathname: (0, getStateFromPath_1.
|
|
12
|
-
|
|
11
|
+
pathname: (0, getStateFromPath_1.stripBaseUrl)(path, baseUrl).split('?')['0'],
|
|
12
|
+
isIndex: isIndexPath(state),
|
|
13
|
+
...getNormalizedStatePath(qualified, baseUrl),
|
|
13
14
|
};
|
|
14
15
|
}
|
|
15
16
|
exports.getRouteInfoFromState = getRouteInfoFromState;
|
|
17
|
+
function isIndexPath(state) {
|
|
18
|
+
const route = state.routes[state.index ?? state.routes.length - 1];
|
|
19
|
+
if (route.state) {
|
|
20
|
+
return isIndexPath(route.state);
|
|
21
|
+
}
|
|
22
|
+
// router.params is typed as 'object', so this usual syntax is to please TypeScript
|
|
23
|
+
if (route.params && 'screen' in route.params) {
|
|
24
|
+
return route.params.screen === 'index';
|
|
25
|
+
}
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
16
28
|
// TODO: Split up getPathFromState to return all this info at once.
|
|
17
|
-
function getNormalizedStatePath({ path: statePath, params, },
|
|
29
|
+
function getNormalizedStatePath({ path: statePath, params, }, baseUrl) {
|
|
18
30
|
const [pathname] = statePath.split('?');
|
|
19
31
|
return {
|
|
20
32
|
// Strip empty path at the start
|
|
21
|
-
segments: (0, getStateFromPath_1.
|
|
33
|
+
segments: (0, getStateFromPath_1.stripBaseUrl)(pathname, baseUrl).split('/').filter(Boolean).map(decodeURIComponent),
|
|
22
34
|
// TODO: This is not efficient, we should generate based on the state instead
|
|
23
35
|
// of converting to string then back to object
|
|
24
36
|
params: Object.entries(params).reduce((prev, [key, value]) => {
|
|
25
37
|
if (Array.isArray(value)) {
|
|
26
|
-
prev[key] = value.map(
|
|
38
|
+
prev[key] = value.map((v) => {
|
|
39
|
+
try {
|
|
40
|
+
return decodeURIComponent(v);
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
return v;
|
|
44
|
+
}
|
|
45
|
+
});
|
|
27
46
|
}
|
|
28
47
|
else {
|
|
29
|
-
|
|
48
|
+
try {
|
|
49
|
+
prev[key] = decodeURIComponent(value);
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
prev[key] = value;
|
|
53
|
+
}
|
|
30
54
|
}
|
|
31
55
|
return prev;
|
|
32
56
|
}, {}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LocationProvider.js","sourceRoot":"","sources":["../src/LocationProvider.tsx"],"names":[],"mappings":";;;AACA,
|
|
1
|
+
{"version":3,"file":"LocationProvider.js","sourceRoot":"","sources":["../src/LocationProvider.tsx"],"names":[],"mappings":";;;AACA,8DAAuD;AAYvD,SAAgB,qBAAqB,CACnC,gBAAkF,EAClF,KAAY,EACZ,OAAgB;IAEhB,MAAM,EAAE,IAAI,EAAE,GAAG,gBAAgB,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IAChD,MAAM,SAAS,GAAG,gBAAgB,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IAEhD,OAAO;QACL,kEAAkE;QAClE,mBAAmB,EAAE,IAAI;QACzB,QAAQ,EAAE,IAAA,+BAAY,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC;QACrD,OAAO,EAAE,WAAW,CAAC,KAAK,CAAC;QAC3B,GAAG,sBAAsB,CAAC,SAAS,EAAE,OAAO,CAAC;KAC9C,CAAC;AACJ,CAAC;AAfD,sDAeC;AAED,SAAS,WAAW,CAAC,KAAY;IAC/B,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,IAAI,KAAK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C,MAAM;oBACN,IAAI,CAAC,GAAG,CAAC,GAAG,KAAe,CAAC;iBAC7B;aACF;YACD,OAAO,IAAI,CAAC;QACd,CAAC,EAAE,EAAkB,CAAC;KACvB,CAAC;AACJ,CAAC;AAnCD,wDAmCC","sourcesContent":["import type { State } from './fork/getPathFromState';\nimport { stripBaseUrl } from './fork/getStateFromPath';\n\ntype SearchParams = Record<string, string | string[]>;\n\nexport type UrlObject = {\n unstable_globalHref: string;\n pathname: string;\n readonly params: SearchParams;\n segments: string[];\n isIndex: boolean;\n};\n\nexport function getRouteInfoFromState(\n getPathFromState: (state: State, asPath: boolean) => { path: string; params: any },\n state: State,\n baseUrl?: string\n): UrlObject {\n const { path } = getPathFromState(state, false);\n const qualified = getPathFromState(state, true);\n\n return {\n // TODO: This may have a predefined origin attached in the future.\n unstable_globalHref: path,\n pathname: stripBaseUrl(path, baseUrl).split('?')['0'],\n isIndex: isIndexPath(state),\n ...getNormalizedStatePath(qualified, baseUrl),\n };\n}\n\nfunction isIndexPath(state: State) {\n const route = state.routes[state.index ?? state.routes.length - 1];\n if (route.state) {\n return isIndexPath(route.state);\n }\n // router.params is typed as 'object', so this usual syntax is to please TypeScript\n if (route.params && 'screen' in route.params) {\n return route.params.screen === 'index';\n }\n return false;\n}\n\n// TODO: Split up getPathFromState to return all this info at once.\nexport function getNormalizedStatePath(\n {\n path: statePath,\n params,\n }: {\n path: string;\n params: any;\n },\n baseUrl?: string\n): Pick<UrlObject, 'segments' | 'params'> {\n const [pathname] = statePath.split('?');\n return {\n // Strip empty path at the start\n segments: stripBaseUrl(pathname, baseUrl).split('/').filter(Boolean).map(decodeURIComponent),\n // TODO: This is not efficient, we should generate based on the state instead\n // of converting to string then back to object\n params: Object.entries(params).reduce((prev, [key, value]) => {\n if (Array.isArray(value)) {\n prev[key] = value.map((v: string) => {\n try {\n return decodeURIComponent(v);\n } catch {\n return v;\n }\n });\n } else {\n try {\n prev[key] = decodeURIComponent(value as string);\n } catch {\n prev[key] = value as string;\n }\n }\n return prev;\n }, {} as SearchParams),\n };\n}\n"]}
|
package/build/Route.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { sortRoutesWithInitial, sortRoutes } from './sortRoutes';
|
|
|
4
4
|
export type DynamicConvention = {
|
|
5
5
|
name: string;
|
|
6
6
|
deep: boolean;
|
|
7
|
+
notFound?: boolean;
|
|
7
8
|
};
|
|
8
9
|
export type LoadedRoute = {
|
|
9
10
|
ErrorBoundary?: React.ComponentType<ErrorBoundaryProps>;
|
|
@@ -31,6 +32,8 @@ export type RouteNode = {
|
|
|
31
32
|
generated?: boolean;
|
|
32
33
|
/** Internal screens like the directory or the auto 404 should be marked as internal. */
|
|
33
34
|
internal?: boolean;
|
|
35
|
+
/** File paths for async entry modules that should be included in the initial chunk request to ensure the runtime JavaScript matches the statically rendered HTML representation. */
|
|
36
|
+
entryPoints?: string[];
|
|
34
37
|
};
|
|
35
38
|
/** Return the RouteNode at the current contextual boundary. */
|
|
36
39
|
export declare function useRouteNode(): RouteNode | null;
|
package/build/Route.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Route.d.ts","sourceRoot":"","sources":["../src/Route.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAc,MAAM,OAAO,CAAC;AAErD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAEpD,OAAO,EAAE,qBAAqB,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAEjE,MAAM,MAAM,iBAAiB,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,OAAO,CAAA;CAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"Route.d.ts","sourceRoot":"","sources":["../src/Route.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAc,MAAM,OAAO,CAAC;AAErD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,WAAW,CA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MAAM,EAAE,CAAC;CACxB,CAAC;AAQF,+DAA+D;AAC/D,wBAAgB,YAAY,IAAI,SAAS,GAAG,IAAI,CAE/C;AAED,wBAAgB,aAAa,IAAI,MAAM,CAMtC;AAED,iEAAiE;AACjE,wBAAgB,KAAK,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE;IAAE,QAAQ,EAAE,SAAS,CAAC;IAAC,IAAI,EAAE,SAAS,CAAA;CAAE,eAEjF;AAED,OAAO,EAAE,qBAAqB,EAAE,UAAU,EAAE,CAAC"}
|
package/build/Route.js
CHANGED
|
@@ -48,7 +48,7 @@ function useContextKey() {
|
|
|
48
48
|
exports.useContextKey = useContextKey;
|
|
49
49
|
/** Provides the matching routes and filename to the children. */
|
|
50
50
|
function Route({ children, node }) {
|
|
51
|
-
return
|
|
51
|
+
return <CurrentRouteContext.Provider value={node}>{children}</CurrentRouteContext.Provider>;
|
|
52
52
|
}
|
|
53
53
|
exports.Route = Route;
|
|
54
54
|
//# sourceMappingURL=Route.js.map
|
package/build/Route.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Route.js","sourceRoot":"","sources":["../src/Route.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAqD;AAGrD,yCAA2C;AAC3C,6CAAiE;
|
|
1
|
+
{"version":3,"file":"Route.js","sourceRoot":"","sources":["../src/Route.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAqD;AAGrD,yCAA2C;AAC3C,6CAAiE;AA2DxD,sGA3DA,kCAAqB,OA2DA;AAAE,2FA3DA,uBAAU,OA2DA;AAxB1C,MAAM,mBAAmB,GAAG,eAAK,CAAC,aAAa,CAAmB,IAAI,CAAC,CAAC;AAExE,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,EAAE;IACzC,mBAAmB,CAAC,WAAW,GAAG,WAAW,CAAC;CAC/C;AAED,+DAA+D;AAC/D,SAAgB,YAAY;IAC1B,OAAO,IAAA,kBAAU,EAAC,mBAAmB,CAAC,CAAC;AACzC,CAAC;AAFD,oCAEC;AAED,SAAgB,aAAa;IAC3B,MAAM,IAAI,GAAG,YAAY,EAAE,CAAC;IAC5B,IAAI,IAAI,IAAI,IAAI,EAAE;QAChB,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAC;KAC5E;IACD,OAAO,IAAA,wBAAa,EAAC,IAAI,CAAC,UAAU,CAAC,CAAC;AACxC,CAAC;AAND,sCAMC;AAED,iEAAiE;AACjE,SAAgB,KAAK,CAAC,EAAE,QAAQ,EAAE,IAAI,EAA4C;IAChF,OAAO,CAAC,mBAAmB,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,mBAAmB,CAAC,QAAQ,CAAC,CAAC;AAC9F,CAAC;AAFD,sBAEC","sourcesContent":["import React, { ReactNode, useContext } from 'react';\n\nimport type { ErrorBoundaryProps } from './exports';\nimport { getContextKey } from './matchers';\nimport { sortRoutesWithInitial, sortRoutes } from './sortRoutes';\n\nexport type DynamicConvention = { name: string; deep: boolean; notFound?: boolean };\n\nexport type LoadedRoute = {\n ErrorBoundary?: React.ComponentType<ErrorBoundaryProps>;\n default?: React.ComponentType<any>;\n unstable_settings?: Record<string, any>;\n getNavOptions?: (args: any) => any;\n generateStaticParams?: (props: {\n params?: Record<string, string | string[]>;\n }) => Record<string, string | string[]>[];\n};\n\nexport type RouteNode = {\n /** Load a route into memory. Returns the exports from a route. */\n loadRoute: () => Partial<LoadedRoute>;\n /** Loaded initial route name. */\n initialRouteName?: string;\n /** nested routes */\n children: RouteNode[];\n /** Is the route a dynamic path */\n dynamic: null | DynamicConvention[];\n /** `index`, `error-boundary`, etc. */\n route: string;\n /** Context Module ID, used for matching children. */\n contextKey: string;\n /** Added in-memory */\n generated?: boolean;\n /** Internal screens like the directory or the auto 404 should be marked as internal. */\n internal?: boolean;\n /** File paths for async entry modules that should be included in the initial chunk request to ensure the runtime JavaScript matches the statically rendered HTML representation. */\n entryPoints?: string[];\n};\n\nconst CurrentRouteContext = React.createContext<RouteNode | null>(null);\n\nif (process.env.NODE_ENV !== 'production') {\n CurrentRouteContext.displayName = 'RouteNode';\n}\n\n/** Return the RouteNode at the current contextual boundary. */\nexport function useRouteNode(): RouteNode | null {\n return useContext(CurrentRouteContext);\n}\n\nexport function useContextKey(): string {\n const node = useRouteNode();\n if (node == null) {\n throw new Error('No filename found. This is likely a bug in expo-router.');\n }\n return getContextKey(node.contextKey);\n}\n\n/** Provides the matching routes and filename to the children. */\nexport function Route({ children, node }: { children: ReactNode; node: RouteNode }) {\n return <CurrentRouteContext.Provider value={node}>{children}</CurrentRouteContext.Provider>;\n}\n\nexport { sortRoutesWithInitial, sortRoutes };\n"]}
|
|
@@ -100,9 +100,11 @@ function NavigationContainerInner({ theme = native_1.DefaultTheme, linking, fall
|
|
|
100
100
|
// Then the fallback will be handled by a parent `Suspense` component
|
|
101
101
|
return fallback;
|
|
102
102
|
}
|
|
103
|
-
return (
|
|
104
|
-
|
|
105
|
-
|
|
103
|
+
return (<native_1.LinkingContext.Provider value={linkingContext}>
|
|
104
|
+
<native_1.ThemeProvider value={theme}>
|
|
105
|
+
<core_1.BaseNavigationContainer {...rest} initialState={rest.initialState == null ? initialState : rest.initialState} ref={refContainer}/>
|
|
106
|
+
</native_1.ThemeProvider>
|
|
107
|
+
</native_1.LinkingContext.Provider>);
|
|
106
108
|
}
|
|
107
109
|
const NavigationContainer = React.forwardRef(NavigationContainerInner);
|
|
108
110
|
exports.default = NavigationContainer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NavigationContainer.native.js","sourceRoot":"","sources":["../../src/fork/NavigationContainer.native.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uGAAuG;AACvG,6GAA6G;AAC7G,iDASgC;AAChC,qDAOkC;AAClC,+FAAu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,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAC3E,GAAG,CAAC,CAAC,YAAY,CAAC,EAEtB;MAAA,EAAE,sBAAa,CACjB;IAAA,EAAE,uBAAc,CAAC,QAAQ,CAAC,CAC3B,CAAC;AACJ,CAAC;AAED,MAAM,mBAAmB,GAAG,KAAK,CAAC,UAAU,CAAC,wBAAwB,CAM9C,CAAC;AAExB,kBAAe,mBAAmB,CAAC","sourcesContent":["// Forked from React Navigation in order to use a custom `useLinking` -> `extractPathFromURL` function.\n// https://github.com/react-navigation/react-navigation/blob/main/packages/native/src/NavigationContainer.tsx\nimport {\n BaseNavigationContainer,\n getActionFromState,\n getPathFromState,\n getStateFromPath,\n NavigationContainerProps,\n NavigationContainerRef,\n ParamListBase,\n validatePathConfig,\n} from '@react-navigation/core';\nimport {\n DefaultTheme,\n DocumentTitleOptions,\n LinkingContext,\n LinkingOptions,\n Theme,\n ThemeProvider,\n} from '@react-navigation/native';\nimport useBackButton from '@react-navigation/native/src/useBackButton';\nimport useDocumentTitle from '@react-navigation/native/src/useDocumentTitle';\nimport useThenable from '@react-navigation/native/src/useThenable';\nimport * as React from 'react';\n\nimport useLinking from './useLinking';\n\nglobal.REACT_NAVIGATION_DEVTOOLS = new WeakMap();\n\ntype Props<ParamList extends object> = NavigationContainerProps & {\n theme?: Theme;\n linking?: LinkingOptions<ParamList>;\n fallback?: React.ReactNode;\n documentTitle?: DocumentTitleOptions;\n onReady?: () => void;\n};\n\n/**\n * Container component which holds the navigation state designed for React Native apps.\n * This should be rendered at the root wrapping the whole app.\n *\n * @param props.initialState Initial state object for the navigation tree. When deep link handling is enabled, this will override deep links when specified. Make sure that you don't specify an `initialState` when there's a deep link (`Linking.getInitialURL()`).\n * @param props.onReady Callback which is called after the navigation tree mounts.\n * @param props.onStateChange Callback which is called with the latest navigation state when it changes.\n * @param props.theme Theme object for the navigators.\n * @param props.linking Options for deep linking. Deep link handling is enabled when this prop is provided, unless `linking.enabled` is `false`.\n * @param props.fallback Fallback component to render until we have finished getting initial state when linking is enabled. Defaults to `null`.\n * @param props.documentTitle Options to configure the document title on Web. Updating document title is handled by default unless `documentTitle.enabled` is `false`.\n * @param props.children Child elements to render the content.\n * @param props.ref Ref object which refers to the navigation object containing helper methods.\n */\nfunction NavigationContainerInner(\n {\n theme = DefaultTheme,\n linking,\n fallback = null,\n documentTitle,\n onReady,\n ...rest\n }: Props<ParamListBase>,\n ref?: React.Ref<NavigationContainerRef<ParamListBase> | null>\n) {\n const isLinkingEnabled = linking ? linking.enabled !== false : false;\n\n if (linking?.config) {\n validatePathConfig(linking.config);\n }\n\n const refContainer = React.useRef<NavigationContainerRef<ParamListBase>>(null);\n\n useBackButton(refContainer);\n useDocumentTitle(refContainer, documentTitle);\n\n const { getInitialState } = useLinking(refContainer, {\n // independent: rest.independent,\n enabled: isLinkingEnabled,\n prefixes: [],\n ...linking,\n });\n\n // Add additional linking related info to the ref\n // This will be used by the devtools\n React.useEffect(() => {\n if (refContainer.current) {\n REACT_NAVIGATION_DEVTOOLS.set(refContainer.current, {\n get linking() {\n return {\n ...linking,\n enabled: isLinkingEnabled,\n prefixes: linking?.prefixes ?? [],\n getStateFromPath: linking?.getStateFromPath ?? getStateFromPath,\n getPathFromState: linking?.getPathFromState ?? getPathFromState,\n getActionFromState: linking?.getActionFromState ?? getActionFromState,\n };\n },\n });\n }\n });\n\n const [isResolved, initialState] = useThenable(getInitialState);\n\n React.useImperativeHandle(ref, () => refContainer.current);\n\n const linkingContext = React.useMemo(() => ({ options: linking }), [linking]);\n\n const isReady = rest.initialState != null || !isLinkingEnabled || isResolved;\n\n const onReadyRef = React.useRef(onReady);\n\n React.useEffect(() => {\n onReadyRef.current = onReady;\n });\n\n React.useEffect(() => {\n if (isReady) {\n onReadyRef.current?.();\n }\n }, [isReady]);\n\n if (!isReady) {\n // This is temporary until we have Suspense for data-fetching\n // Then the fallback will be handled by a parent `Suspense` component\n return fallback as React.ReactElement;\n }\n\n return (\n <LinkingContext.Provider value={linkingContext}>\n <ThemeProvider value={theme}>\n <BaseNavigationContainer\n {...rest}\n initialState={rest.initialState == null ? initialState : rest.initialState}\n ref={refContainer}\n />\n </ThemeProvider>\n </LinkingContext.Provider>\n );\n}\n\nconst NavigationContainer = React.forwardRef(NavigationContainerInner) as <\n RootParamList extends object = ReactNavigation.RootParamList,\n>(\n props: Props<RootParamList> & {\n ref?: React.Ref<NavigationContainerRef<RootParamList>>;\n }\n) => React.ReactElement;\n\nexport default NavigationContainer;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extractPathFromURL.d.ts","sourceRoot":"","sources":["../../src/fork/extractPathFromURL.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"extractPathFromURL.d.ts","sourceRoot":"","sources":["../../src/fork/extractPathFromURL.ts"],"names":[],"mappings":"AAwFA,wBAAgB,sBAAsB,CAAC,GAAG,GAAE,MAAW,UAGtD;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,UAMjF"}
|