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
|
@@ -1,65 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.loadStaticParamsAsync = void 0;
|
|
4
|
-
async function recurseAndFlattenNodes(nodes, props, func) {
|
|
5
|
-
const tarr = await Promise.all(nodes.map((node) => func(node, props)).flat());
|
|
6
|
-
return tarr.filter(Boolean);
|
|
7
|
-
}
|
|
3
|
+
exports.assertStaticParams = exports.loadStaticParamsAsync = void 0;
|
|
8
4
|
async function loadStaticParamsAsync(route) {
|
|
9
|
-
const
|
|
10
|
-
route.children =
|
|
5
|
+
const expandedChildren = await Promise.all(route.children.map((route) => loadStaticParamsRecursive(route, { parentParams: {} })));
|
|
6
|
+
route.children = expandedChildren.flat();
|
|
11
7
|
return route;
|
|
12
8
|
}
|
|
13
9
|
exports.loadStaticParamsAsync = loadStaticParamsAsync;
|
|
14
|
-
function assertStaticParams(route, params) {
|
|
15
|
-
const matches = route.dynamic.every((dynamic) => {
|
|
16
|
-
const value = params[dynamic.name];
|
|
17
|
-
return value !== undefined && value !== null;
|
|
18
|
-
});
|
|
19
|
-
if (!matches) {
|
|
20
|
-
throw new Error(`generateStaticParams() must return an array of params that match the dynamic route. Received ${JSON.stringify(params)}`);
|
|
21
|
-
}
|
|
22
|
-
const validateSingleParam = (dynamic, value, allowMultipleSegments) => {
|
|
23
|
-
if (typeof value !== 'string') {
|
|
24
|
-
throw new Error(`generateStaticParams() for route "${route.contextKey}" expected param "${dynamic.name}" to be of type string, instead found "${typeof value}" while parsing "${value}".`);
|
|
25
|
-
}
|
|
26
|
-
const parts = value.split('/').filter(Boolean);
|
|
27
|
-
if (parts.length > 1 && !allowMultipleSegments) {
|
|
28
|
-
throw new Error(`generateStaticParams() for route "${route.contextKey}" expected param "${dynamic.name}" to not contain "/" (multiple segments) while parsing "${value}".`);
|
|
29
|
-
}
|
|
30
|
-
if (parts.length === 0) {
|
|
31
|
-
throw new Error(`generateStaticParams() for route "${route.contextKey}" expected param "${dynamic.name}" not to be empty while parsing "${value}".`);
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
route.dynamic.forEach((dynamic) => {
|
|
35
|
-
const value = params[dynamic.name];
|
|
36
|
-
if (dynamic.deep) {
|
|
37
|
-
// TODO: We could split strings by `/` and use that too.
|
|
38
|
-
if (!Array.isArray(value)) {
|
|
39
|
-
validateSingleParam(dynamic, value, true);
|
|
40
|
-
}
|
|
41
|
-
else {
|
|
42
|
-
validateSingleParam(dynamic, value.filter(Boolean).join('/'), true);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
validateSingleParam(dynamic, value);
|
|
47
|
-
}
|
|
48
|
-
return value !== undefined && value !== null;
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
/** lodash.uniqBy */
|
|
52
|
-
function uniqBy(array, key) {
|
|
53
|
-
const seen = {};
|
|
54
|
-
return array.filter((item) => {
|
|
55
|
-
const k = key(item);
|
|
56
|
-
if (seen[k]) {
|
|
57
|
-
return false;
|
|
58
|
-
}
|
|
59
|
-
seen[k] = true;
|
|
60
|
-
return true;
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
10
|
async function loadStaticParamsRecursive(route, props) {
|
|
64
11
|
if (!route?.dynamic && !route?.children?.length) {
|
|
65
12
|
return [route];
|
|
@@ -70,19 +17,28 @@ async function loadStaticParamsRecursive(route, props) {
|
|
|
70
17
|
staticParams = await loaded.generateStaticParams({
|
|
71
18
|
params: props.parentParams || {},
|
|
72
19
|
});
|
|
73
|
-
|
|
74
|
-
throw new Error(`generateStaticParams() must return an array of params, received ${staticParams}`);
|
|
75
|
-
}
|
|
20
|
+
assertStaticParamsType(staticParams);
|
|
76
21
|
// Assert that at least one param from each matches the dynamic route.
|
|
77
22
|
staticParams.forEach((params) => assertStaticParams(route, params));
|
|
78
23
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
24
|
+
const traverseForNode = async (nextParams) => {
|
|
25
|
+
const nextChildren = [];
|
|
26
|
+
for (const child of route.children) {
|
|
27
|
+
const children = await loadStaticParamsRecursive(child, {
|
|
28
|
+
...props,
|
|
29
|
+
parentParams: nextParams,
|
|
30
|
+
});
|
|
31
|
+
nextChildren.push(...children);
|
|
32
|
+
}
|
|
33
|
+
return uniqBy(nextChildren, (i) => i.route);
|
|
34
|
+
};
|
|
35
|
+
if (!staticParams.length) {
|
|
36
|
+
const nextParams = {
|
|
82
37
|
...props.parentParams,
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
38
|
+
};
|
|
39
|
+
route.children = await traverseForNode(nextParams);
|
|
40
|
+
return [route];
|
|
41
|
+
}
|
|
86
42
|
const createParsedRouteName = (input, params) => {
|
|
87
43
|
let parsedRouteName = input;
|
|
88
44
|
route.dynamic?.map((query) => {
|
|
@@ -98,6 +54,11 @@ async function loadStaticParamsRecursive(route, props) {
|
|
|
98
54
|
return parsedRouteName;
|
|
99
55
|
};
|
|
100
56
|
const generatedRoutes = await Promise.all(staticParams.map(async (params) => {
|
|
57
|
+
const nextParams = {
|
|
58
|
+
...props.parentParams,
|
|
59
|
+
...params,
|
|
60
|
+
};
|
|
61
|
+
const dynamicChildren = await traverseForNode(nextParams);
|
|
101
62
|
const parsedRoute = createParsedRouteName(route.route, params);
|
|
102
63
|
const generatedContextKey = createParsedRouteName(route.contextKey, params);
|
|
103
64
|
return {
|
|
@@ -107,15 +68,89 @@ async function loadStaticParamsRecursive(route, props) {
|
|
|
107
68
|
// Convert the dynamic route to a static route.
|
|
108
69
|
dynamic: null,
|
|
109
70
|
route: parsedRoute,
|
|
110
|
-
children:
|
|
111
|
-
...props,
|
|
112
|
-
parentParams: {
|
|
113
|
-
...props.parentParams,
|
|
114
|
-
...staticParams,
|
|
115
|
-
},
|
|
116
|
-
}, loadStaticParamsRecursive)).flat(), (i) => i.route),
|
|
71
|
+
children: dynamicChildren,
|
|
117
72
|
};
|
|
118
73
|
}));
|
|
119
74
|
return [route, ...generatedRoutes];
|
|
120
75
|
}
|
|
76
|
+
/** lodash.uniqBy */
|
|
77
|
+
function uniqBy(array, key) {
|
|
78
|
+
const seen = {};
|
|
79
|
+
return array.filter((item) => {
|
|
80
|
+
const k = key(item);
|
|
81
|
+
if (seen[k]) {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
seen[k] = true;
|
|
85
|
+
return true;
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
function assertStaticParamsType(params) {
|
|
89
|
+
if (!Array.isArray(params)) {
|
|
90
|
+
throw new Error(`generateStaticParams() must return an array of params, received ${params}`);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
function formatExpected(expected, received) {
|
|
94
|
+
const total = {
|
|
95
|
+
...received,
|
|
96
|
+
};
|
|
97
|
+
for (const item of expected) {
|
|
98
|
+
if (total[item] == null) {
|
|
99
|
+
total[item] = String(total[item]);
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
total[item] = `"${total[item]}"`;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return [
|
|
106
|
+
'{',
|
|
107
|
+
Object.entries(total)
|
|
108
|
+
.map(([key, value]) => ` "${key}": ${value}`)
|
|
109
|
+
.join(',\n'),
|
|
110
|
+
'}',
|
|
111
|
+
].join('\n');
|
|
112
|
+
}
|
|
113
|
+
function assertStaticParams(route, params) {
|
|
114
|
+
// Type checking
|
|
115
|
+
if (!route.dynamic) {
|
|
116
|
+
throw new Error('assertStaticParams() must be called on a dynamic route.');
|
|
117
|
+
}
|
|
118
|
+
const matches = route.dynamic.every((dynamic) => {
|
|
119
|
+
const value = params[dynamic.name];
|
|
120
|
+
return value !== undefined && value !== null;
|
|
121
|
+
});
|
|
122
|
+
if (!matches) {
|
|
123
|
+
const plural = route.dynamic.length > 1 ? 's' : '';
|
|
124
|
+
const expected = route.dynamic.map((dynamic) => dynamic.name);
|
|
125
|
+
throw new Error(`[${route.contextKey}]: generateStaticParams() must return an array of params that match the dynamic route${plural}. Expected non-nullish values for key${plural}: ${expected
|
|
126
|
+
.map((v) => `"${v}"`)
|
|
127
|
+
.join(', ')}.\nReceived:\n${formatExpected(expected, params)}`);
|
|
128
|
+
}
|
|
129
|
+
const validateSingleParam = (dynamic, value, allowMultipleSegments) => {
|
|
130
|
+
if (typeof value !== 'string') {
|
|
131
|
+
throw new Error(`generateStaticParams() for route "${route.contextKey}" expected param "${dynamic.name}" to be of type string, instead found "${typeof value}" while parsing "${value}".`);
|
|
132
|
+
}
|
|
133
|
+
const parts = value.split('/').filter(Boolean);
|
|
134
|
+
if (parts.length > 1 && !allowMultipleSegments) {
|
|
135
|
+
throw new Error(`generateStaticParams() for route "${route.contextKey}" expected param "${dynamic.name}" to not contain "/" (multiple segments) while parsing "${value}".`);
|
|
136
|
+
}
|
|
137
|
+
if (parts.length === 0) {
|
|
138
|
+
throw new Error(`generateStaticParams() for route "${route.contextKey}" expected param "${dynamic.name}" not to be empty while parsing "${value}".`);
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
// `[shape]/bar/[...colors]` -> `[shape]`, `[...colors]`
|
|
142
|
+
for (const dynamic of route.dynamic) {
|
|
143
|
+
let parameter = params[dynamic.name];
|
|
144
|
+
if (dynamic.deep) {
|
|
145
|
+
if (Array.isArray(parameter)) {
|
|
146
|
+
parameter = parameter.filter(Boolean).join('/');
|
|
147
|
+
}
|
|
148
|
+
validateSingleParam(dynamic, parameter, true);
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
validateSingleParam(dynamic, parameter);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
exports.assertStaticParams = assertStaticParams;
|
|
121
156
|
//# sourceMappingURL=loadStaticParamsAsync.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadStaticParamsAsync.js","sourceRoot":"","sources":["../src/loadStaticParamsAsync.ts"],"names":[],"mappings":";;;AAEA,KAAK,UAAU,sBAAsB,CAInC,KAAU,EAAE,KAAa,EAAE,IAAc;IACzC,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IAC9E,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAQ,CAAC;AACrC,CAAC;AAEM,KAAK,UAAU,qBAAqB,CAAC,KAAgB;IAC1D,MAAM,SAAS,GAAG,CAChB,MAAM,OAAO,CAAC,GAAG,CACf,KAAK,CAAC,QA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route';\n\nasync function recurseAndFlattenNodes<\n T,\n TProps,\n TProcess extends (node: T, props: any) => Promise<T[]>,\n>(nodes: T[], props: TProps, func: TProcess): Promise<T[]> {\n const tarr = await Promise.all(nodes.map((node) => func(node, props)).flat());\n return tarr.filter(Boolean) as T[];\n}\n\nexport async function loadStaticParamsAsync(route: RouteNode): Promise<RouteNode> {\n const processed = (\n await Promise.all(\n route.children.map((route) => loadStaticParamsRecursive(route, { parentParams: {} }))\n )\n ).flat();\n\n route.children = processed;\n return route;\n}\n\nfunction assertStaticParams(route: RouteNode, params: Record<string, string | string[]>) {\n const matches = route.dynamic!.every((dynamic) => {\n const value = params[dynamic.name];\n return value !== undefined && value !== null;\n });\n if (!matches) {\n throw new Error(\n `generateStaticParams() must return an array of params that match the dynamic route. Received ${JSON.stringify(\n params\n )}`\n );\n }\n\n const validateSingleParam = (\n dynamic: DynamicConvention,\n value: any,\n allowMultipleSegments?: boolean\n ) => {\n if (typeof value !== 'string') {\n throw new Error(\n `generateStaticParams() for route \"${route.contextKey}\" expected param \"${\n dynamic.name\n }\" to be of type string, instead found \"${typeof value}\" while parsing \"${value}\".`\n );\n }\n const parts = value.split('/').filter(Boolean);\n if (parts.length > 1 && !allowMultipleSegments) {\n throw new Error(\n `generateStaticParams() for route \"${route.contextKey}\" expected param \"${dynamic.name}\" to not contain \"/\" (multiple segments) while parsing \"${value}\".`\n );\n }\n if (parts.length === 0) {\n throw new Error(\n `generateStaticParams() for route \"${route.contextKey}\" expected param \"${dynamic.name}\" not to be empty while parsing \"${value}\".`\n );\n }\n };\n\n route.dynamic!.forEach((dynamic) => {\n const value = params[dynamic.name];\n if (dynamic.deep) {\n // TODO: We could split strings by `/` and use that too.\n if (!Array.isArray(value)) {\n validateSingleParam(dynamic, value, true);\n } else {\n validateSingleParam(dynamic, value.filter(Boolean).join('/'), true);\n }\n } else {\n validateSingleParam(dynamic, value);\n }\n return value !== undefined && value !== null;\n });\n}\n\n/** lodash.uniqBy */\nfunction uniqBy<T>(array: T[], key: (item: T) => string): T[] {\n const seen: { [key: string]: boolean } = {};\n return array.filter((item) => {\n const k = key(item);\n if (seen[k]) {\n return false;\n }\n seen[k] = true;\n return true;\n });\n}\n\nasync function loadStaticParamsRecursive(\n route: RouteNode,\n props: { parentParams: any }\n): Promise<RouteNode[]> {\n if (!route?.dynamic && !route?.children?.length) {\n return [route];\n }\n\n const loaded = await route.loadRoute();\n\n let staticParams: Record<string, string | string[]>[] = [];\n\n if (loaded.generateStaticParams) {\n staticParams = await loaded.generateStaticParams({\n params: props.parentParams || {},\n });\n if (!Array.isArray(staticParams)) {\n throw new Error(\n `generateStaticParams() must return an array of params, received ${staticParams}`\n );\n }\n\n // Assert that at least one param from each matches the dynamic route.\n staticParams.forEach((params) => assertStaticParams(route, params));\n }\n\n route.children = uniqBy(\n (\n await recurseAndFlattenNodes(\n [...route.children],\n {\n ...props,\n parentParams: {\n ...props.parentParams,\n ...staticParams,\n },\n },\n loadStaticParamsRecursive\n )\n ).flat(),\n (i) => i.route\n );\n\n const createParsedRouteName = (input: string, params: any) => {\n let parsedRouteName = input;\n route.dynamic?.map((query) => {\n const param = params[query.name];\n const formattedParameter = Array.isArray(param) ? param.join('/') : param;\n if (query.deep) {\n parsedRouteName = parsedRouteName.replace(`[...${query.name}]`, formattedParameter);\n } else {\n parsedRouteName = parsedRouteName.replace(`[${query.name}]`, param);\n }\n });\n\n return parsedRouteName;\n };\n\n const generatedRoutes = await Promise.all(\n staticParams.map(async (params) => {\n const parsedRoute = createParsedRouteName(route.route, params);\n const generatedContextKey = createParsedRouteName(route.contextKey, params);\n\n return {\n ...route,\n // TODO: Add a new field for this\n contextKey: generatedContextKey,\n // Convert the dynamic route to a static route.\n dynamic: null,\n route: parsedRoute,\n children: uniqBy(\n (\n await recurseAndFlattenNodes(\n [...route.children],\n {\n ...props,\n parentParams: {\n ...props.parentParams,\n ...staticParams,\n },\n },\n loadStaticParamsRecursive\n )\n ).flat(),\n (i) => i.route\n ),\n };\n })\n );\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I,EAAE;YAChB,IAAI,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE;gBAC5B,SAAS,GAAG,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;aACjD;YACD,mBAAmB,CAAC,OAAO,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC;SAC/C;aAAM;YACL,mBAAmB,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;SACzC;KACF;AACH,CAAC;AA7DD,gDA6DC","sourcesContent":["import type { DynamicConvention, RouteNode } from './Route';\n\nexport async function loadStaticParamsAsync(route: RouteNode): Promise<RouteNode> {\n const expandedChildren = await Promise.all(\n route.children.map((route) => loadStaticParamsRecursive(route, { parentParams: {} }))\n );\n route.children = expandedChildren.flat();\n return route;\n}\n\nasync function loadStaticParamsRecursive(\n route: RouteNode,\n props: { parentParams: any }\n): Promise<RouteNode[]> {\n if (!route?.dynamic && !route?.children?.length) {\n return [route];\n }\n\n const loaded = await route.loadRoute();\n\n let staticParams: Record<string, string | string[]>[] = [];\n\n if (loaded.generateStaticParams) {\n staticParams = await loaded.generateStaticParams({\n params: props.parentParams || {},\n });\n\n assertStaticParamsType(staticParams);\n // Assert that at least one param from each matches the dynamic route.\n staticParams.forEach((params) => assertStaticParams(route, params));\n }\n\n const traverseForNode = async (nextParams: Record<string, string | string[]>) => {\n const nextChildren: RouteNode[] = [];\n for (const child of route.children) {\n const children = await loadStaticParamsRecursive(child, {\n ...props,\n parentParams: nextParams,\n });\n nextChildren.push(...children);\n }\n\n return uniqBy(nextChildren, (i) => i.route);\n };\n\n if (!staticParams.length) {\n const nextParams = {\n ...props.parentParams,\n };\n\n route.children = await traverseForNode(nextParams);\n\n return [route];\n }\n\n const createParsedRouteName = (input: string, params: any) => {\n let parsedRouteName = input;\n route.dynamic?.map((query) => {\n const param = params[query.name];\n const formattedParameter = Array.isArray(param) ? param.join('/') : param;\n if (query.deep) {\n parsedRouteName = parsedRouteName.replace(`[...${query.name}]`, formattedParameter);\n } else {\n parsedRouteName = parsedRouteName.replace(`[${query.name}]`, param);\n }\n });\n\n return parsedRouteName;\n };\n\n const generatedRoutes = await Promise.all(\n staticParams.map(async (params) => {\n const nextParams = {\n ...props.parentParams,\n ...params,\n };\n\n const dynamicChildren = await traverseForNode(nextParams);\n const parsedRoute = createParsedRouteName(route.route, params);\n const generatedContextKey = createParsedRouteName(route.contextKey, params);\n\n return {\n ...route,\n // TODO: Add a new field for this\n contextKey: generatedContextKey,\n // Convert the dynamic route to a static route.\n dynamic: null,\n route: parsedRoute,\n children: dynamicChildren,\n };\n })\n );\n\n return [route, ...generatedRoutes];\n}\n\n/** lodash.uniqBy */\nfunction uniqBy<T>(array: T[], key: (item: T) => string): T[] {\n const seen: { [key: string]: boolean } = {};\n return array.filter((item) => {\n const k = key(item);\n if (seen[k]) {\n return false;\n }\n seen[k] = true;\n return true;\n });\n}\n\nfunction assertStaticParamsType(params: any): asserts params is Record<string, string | string[]> {\n if (!Array.isArray(params)) {\n throw new Error(`generateStaticParams() must return an array of params, received ${params}`);\n }\n}\n\nfunction formatExpected(expected: string[], received: Record<string, any>): string {\n const total = {\n ...received,\n };\n for (const item of expected) {\n if (total[item] == null) {\n total[item] = String(total[item]);\n } else {\n total[item] = `\"${total[item]}\"`;\n }\n }\n\n return [\n '{',\n Object.entries(total)\n .map(([key, value]) => ` \"${key}\": ${value}`)\n .join(',\\n'),\n '}',\n ].join('\\n');\n}\n\nexport function assertStaticParams(\n route: Pick<RouteNode, 'contextKey' | 'dynamic'>,\n params: Record<string, string | string[]>\n) {\n // Type checking\n if (!route.dynamic) {\n throw new Error('assertStaticParams() must be called on a dynamic route.');\n }\n const matches = route.dynamic.every((dynamic) => {\n const value = params[dynamic.name];\n return value !== undefined && value !== null;\n });\n if (!matches) {\n const plural = route.dynamic.length > 1 ? 's' : '';\n const expected = route.dynamic.map((dynamic) => dynamic.name);\n throw new Error(\n `[${\n route.contextKey\n }]: generateStaticParams() must return an array of params that match the dynamic route${plural}. Expected non-nullish values for key${plural}: ${expected\n .map((v) => `\"${v}\"`)\n .join(', ')}.\\nReceived:\\n${formatExpected(expected, params)}`\n );\n }\n\n const validateSingleParam = (\n dynamic: DynamicConvention,\n value: any,\n allowMultipleSegments?: boolean\n ) => {\n if (typeof value !== 'string') {\n throw new Error(\n `generateStaticParams() for route \"${route.contextKey}\" expected param \"${\n dynamic.name\n }\" to be of type string, instead found \"${typeof value}\" while parsing \"${value}\".`\n );\n }\n const parts = value.split('/').filter(Boolean);\n if (parts.length > 1 && !allowMultipleSegments) {\n throw new Error(\n `generateStaticParams() for route \"${route.contextKey}\" expected param \"${dynamic.name}\" to not contain \"/\" (multiple segments) while parsing \"${value}\".`\n );\n }\n if (parts.length === 0) {\n throw new Error(\n `generateStaticParams() for route \"${route.contextKey}\" expected param \"${dynamic.name}\" not to be empty while parsing \"${value}\".`\n );\n }\n };\n\n // `[shape]/bar/[...colors]` -> `[shape]`, `[...colors]`\n for (const dynamic of route.dynamic) {\n let parameter = params[dynamic.name];\n if (dynamic.deep) {\n if (Array.isArray(parameter)) {\n parameter = parameter.filter(Boolean).join('/');\n }\n validateSingleParam(dynamic, parameter, true);\n } else {\n validateSingleParam(dynamic, parameter);\n }\n }\n}\n"]}
|
package/build/matchers.js
CHANGED
|
@@ -15,7 +15,7 @@ function matchDeepDynamicRouteName(name) {
|
|
|
15
15
|
exports.matchDeepDynamicRouteName = matchDeepDynamicRouteName;
|
|
16
16
|
/** Match `(page)` -> `page` */
|
|
17
17
|
function matchGroupName(name) {
|
|
18
|
-
return name.match(
|
|
18
|
+
return name.match(/^(?:[^\\(\\)])*?\(([^\\/]+)\).*?$/)?.[1];
|
|
19
19
|
}
|
|
20
20
|
exports.matchGroupName = matchGroupName;
|
|
21
21
|
function getNameFromFilePath(name) {
|
package/build/matchers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"matchers.js","sourceRoot":"","sources":["../src/matchers.tsx"],"names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,CAAC,IAAI,CAAC,CAAC;IAC/C,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE;QAC/B,OAAO,MAAM,CAAC;KACf;IACD,OAAO,MAAM,CAAC,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC;AAC3C,CAAC;AARD,sCAQC;AAED,0CAA0C;AAC1C,SAAgB,yBAAyB,CAAC,IAAY;IACpD,OAAO,IAAI,CAAC,OAAO,CAAC,qBAAqB,EAAE,EAAE,CAAC,CAAC;AACjD,CAAC;AAFD,8DAEC;AAED,mEAAmE;AACnE,SAAgB,oBAAoB,CAAC,QAAgB;IACnD,OAAO,QAAQ,CAAC,OAAO,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAC;AAChD,CAAC;AAFD,oDAEC;AAED,SAAgB,0BAA0B,CAAC,IAAY;IACrD,OAAO,IAAI;SACR,KAAK,CAAC,GAAG,CAAC;SACV,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE;QACjB,IAAI,cAAc,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE;YAC7B,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SACb;QACD,OAAO,GAAG,CAAC;IACb,CAAC,EAAE,EAAc,CAAC;SACjB,IAAI,CAAC,GAAG,CAAC,CAAC;AACf,CAAC;AAVD,gEAUC;AAED,SAAgB,8BAA8B,CAAC,IAAY;IACzD,OAAO,0BAA0B,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;AACnE,CAAC;AAFD,wEAEC","sourcesContent":["/** Match `[page]` -> `page` */\nexport function matchDynamicName(name: string): string | undefined {\n // Don't match `...` or `[` or `]` inside the brackets\n // eslint-disable-next-line no-useless-escape\n return name.match(/^\\[([^[\\](?:\\.\\.\\.)]+?)\\]$/)?.[1];\n}\n\n/** Match `[...page]` -> `page` */\nexport function matchDeepDynamicRouteName(name: string): string | undefined {\n return name.match(/^\\[\\.\\.\\.([^/]+?)\\]$/)?.[1];\n}\n\n/** Match `(page)` -> `page` */\nexport function matchGroupName(name: string): string | undefined {\n return name.match(/^(?:[^\\\\(\\\\)])*?\\(([^\\\\/]+)\\).*?$/)?.[1];\n}\n\nexport function getNameFromFilePath(name: string): string {\n return removeSupportedExtensions(removeFileSystemDots(name));\n}\n\nexport function getContextKey(name: string): string {\n // The root path is `` (empty string) so always prepend `/` to ensure\n // there is some value.\n const normal = '/' + getNameFromFilePath(name);\n if (!normal.endsWith('_layout')) {\n return normal;\n }\n return normal.replace(/\\/?_layout$/, '');\n}\n\n/** Remove `.js`, `.ts`, `.jsx`, `.tsx` */\nexport function removeSupportedExtensions(name: string): string {\n return name.replace(/(\\+api)?\\.[jt]sx?$/g, '');\n}\n\n// Remove any amount of `./` and `../` from the start of the string\nexport function removeFileSystemDots(filePath: string): string {\n return filePath.replace(/^(?:\\.\\.?\\/)+/g, '');\n}\n\nexport function stripGroupSegmentsFromPath(path: string): string {\n return path\n .split('/')\n .reduce((acc, v) => {\n if (matchGroupName(v) == null) {\n acc.push(v);\n }\n return acc;\n }, [] as string[])\n .join('/');\n}\n\nexport function stripInvisibleSegmentsFromPath(path: string): string {\n return stripGroupSegmentsFromPath(path).replace(/\\/?index$/, '');\n}\n"]}
|
|
@@ -12,15 +12,19 @@ const exports_1 = require("../exports");
|
|
|
12
12
|
const Pressable_1 = require("../views/Pressable");
|
|
13
13
|
// TODO: Use openLinkFromBrowser thing
|
|
14
14
|
function Header() {
|
|
15
|
-
return (
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
return (<Pressable_1.Pressable>
|
|
16
|
+
{({ hovered }) => (<react_native_1.Text role="heading" aria-level={1} style={[styles.title, react_native_1.Platform.OS !== 'web' && { textAlign: 'left' }]}>
|
|
17
|
+
Welcome to{' '}
|
|
18
|
+
<exports_1.Link href="https://github.com/expo/expo-router/" style={[
|
|
19
19
|
hovered && {
|
|
20
20
|
textDecorationColor: 'white',
|
|
21
21
|
textDecorationLine: 'underline',
|
|
22
22
|
},
|
|
23
|
-
]
|
|
23
|
+
]}>
|
|
24
|
+
Expo
|
|
25
|
+
</exports_1.Link>
|
|
26
|
+
</react_native_1.Text>)}
|
|
27
|
+
</Pressable_1.Pressable>);
|
|
24
28
|
}
|
|
25
29
|
const canAutoTouchFile = process.env.EXPO_ROUTER_APP_ROOT != null;
|
|
26
30
|
function Tutorial() {
|
|
@@ -39,19 +43,20 @@ function Tutorial() {
|
|
|
39
43
|
}
|
|
40
44
|
}
|
|
41
45
|
}, []);
|
|
42
|
-
return (
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
46
|
+
return (<react_native_1.View style={styles.background}>
|
|
47
|
+
<react_native_1.StatusBar barStyle="light-content"/>
|
|
48
|
+
|
|
49
|
+
<react_native_safe_area_context_1.SafeAreaView style={styles.safeArea}>
|
|
50
|
+
<react_native_1.View style={styles.container}>
|
|
51
|
+
<Header />
|
|
52
|
+
<react_native_1.Text role="heading" aria-level={2} style={styles.subtitle}>
|
|
53
|
+
Start by creating a file{'\n'}in the{' '}
|
|
54
|
+
<react_native_1.Text style={{ fontWeight: 'bold' }}>{getRootDir()}</react_native_1.Text> directory.
|
|
55
|
+
</react_native_1.Text>
|
|
56
|
+
{canAutoTouchFile && <Button />}
|
|
57
|
+
</react_native_1.View>
|
|
58
|
+
</react_native_safe_area_context_1.SafeAreaView>
|
|
59
|
+
</react_native_1.View>);
|
|
55
60
|
}
|
|
56
61
|
exports.Tutorial = Tutorial;
|
|
57
62
|
function getRootDir() {
|
|
@@ -65,9 +70,9 @@ function getRootDir() {
|
|
|
65
70
|
return dir.split('/').pop() ?? dir;
|
|
66
71
|
}
|
|
67
72
|
function Button() {
|
|
68
|
-
return (
|
|
73
|
+
return (<Pressable_1.Pressable onPress={() => {
|
|
69
74
|
(0, createEntryFile_1.createEntryFileAsync)();
|
|
70
|
-
}
|
|
75
|
+
}} style={{
|
|
71
76
|
...react_native_1.Platform.select({
|
|
72
77
|
web: {
|
|
73
78
|
// subtle white shadow
|
|
@@ -81,20 +86,22 @@ function Button() {
|
|
|
81
86
|
overflow: 'hidden',
|
|
82
87
|
},
|
|
83
88
|
}),
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
89
|
+
}}>
|
|
90
|
+
{({ pressed, hovered }) => (<react_native_1.View style={[
|
|
91
|
+
styles.buttonContainer,
|
|
92
|
+
hovered && {
|
|
93
|
+
backgroundColor: 'white',
|
|
94
|
+
},
|
|
95
|
+
pressed && {
|
|
96
|
+
backgroundColor: 'rgba(255,255,255,0.7)',
|
|
97
|
+
},
|
|
98
|
+
]}>
|
|
99
|
+
<react_native_1.Text style={[styles.code, hovered && { color: 'black' }]}>
|
|
100
|
+
<react_native_1.Text style={{ color: '#BCC3CD' }}>$</react_native_1.Text> touch {getRootDir()}
|
|
101
|
+
/index.js
|
|
102
|
+
</react_native_1.Text>
|
|
103
|
+
</react_native_1.View>)}
|
|
104
|
+
</Pressable_1.Pressable>);
|
|
98
105
|
}
|
|
99
106
|
const styles = react_native_1.StyleSheet.create({
|
|
100
107
|
background: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tutorial.js","sourceRoot":"","sources":["../../src/onboard/Tutorial.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,+CAA2E;AAC3E,mFAA8D;AAE9D,uDAAyD;AACzD,wCAAkC;AAClC,kDAA+C;AAE/C,sCAAsC;AACtC,SAAS,MAAM;IACb,OAAO,CACL,
|
|
1
|
+
{"version":3,"file":"Tutorial.js","sourceRoot":"","sources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ACF,CAAC;QAEF,UAAU,EAAE,MAAM;QAClB,QAAQ,EAAE,EAAE;QACZ,UAAU,EAAE,MAAM;KACnB;IACD,QAAQ,EAAE;QACR,KAAK,EAAE,SAAS;QAChB,QAAQ,EAAE,EAAE;QACZ,UAAU,EAAE,KAAK;QACjB,aAAa,EAAE,EAAE;QACjB,QAAQ,EAAE,GAAG;KACd;CACF,CAAC,CAAC","sourcesContent":["import React from 'react';\nimport { Platform, StatusBar, StyleSheet, Text, View } from 'react-native';\nimport { SafeAreaView } from 'react-native-safe-area-context';\n\nimport { createEntryFileAsync } from './createEntryFile';\nimport { Link } from '../exports';\nimport { Pressable } from '../views/Pressable';\n\n// TODO: Use openLinkFromBrowser thing\nfunction Header() {\n return (\n <Pressable>\n {({ hovered }) => (\n <Text\n role=\"heading\"\n aria-level={1}\n style={[styles.title, Platform.OS !== 'web' && { textAlign: 'left' }]}>\n Welcome to{' '}\n <Link\n href=\"https://github.com/expo/expo-router/\"\n style={[\n hovered && {\n textDecorationColor: 'white',\n textDecorationLine: 'underline',\n },\n ]}>\n Expo\n </Link>\n </Text>\n )}\n </Pressable>\n );\n}\n\nconst canAutoTouchFile = process.env.EXPO_ROUTER_APP_ROOT != null;\n\nexport function Tutorial() {\n React.useEffect(() => {\n if (Platform.OS === 'web') {\n // Reset the route on web so the initial route isn't a 404 after\n // the user has created the entry file.\n // This is useful for cases where you are testing the tutorial.\n // To test: touch the new file, then navigate to a missing route `/foobar`, then delete the app folder.\n // you should see the tutorial again and be able to create the entry file once more.\n if (typeof location !== 'undefined' && location.pathname !== '/') {\n location.replace('/');\n }\n if (typeof window !== 'undefined' && typeof window.document !== 'undefined') {\n window.document.title = 'npx expo start';\n }\n }\n }, []);\n\n return (\n <View style={styles.background}>\n <StatusBar barStyle=\"light-content\" />\n\n <SafeAreaView style={styles.safeArea}>\n <View style={styles.container}>\n <Header />\n <Text role=\"heading\" aria-level={2} style={styles.subtitle}>\n Start by creating a file{'\\n'}in the{' '}\n <Text style={{ fontWeight: 'bold' }}>{getRootDir()}</Text> directory.\n </Text>\n {canAutoTouchFile && <Button />}\n </View>\n </SafeAreaView>\n </View>\n );\n}\n\nfunction getRootDir() {\n const dir = process.env.EXPO_ROUTER_ABS_APP_ROOT!;\n if (dir.match(/\\/src\\/app$/)) {\n return 'src/app';\n } else if (dir.match(/\\/app$/)) {\n return 'app';\n }\n return dir.split('/').pop() ?? dir;\n}\n\nfunction Button() {\n return (\n <Pressable\n onPress={() => {\n createEntryFileAsync();\n }}\n style={{\n ...Platform.select({\n web: {\n // subtle white shadow\n boxShadow: 'rgba(255, 255, 255, 0.15) 0px 0px 20px 5px',\n },\n native: {\n position: 'absolute',\n bottom: 24,\n left: 24,\n right: 24,\n overflow: 'hidden',\n },\n }),\n }}>\n {({ pressed, hovered }) => (\n <View\n style={[\n styles.buttonContainer,\n hovered && {\n backgroundColor: 'white',\n },\n pressed && {\n backgroundColor: 'rgba(255,255,255,0.7)',\n },\n ]}>\n <Text style={[styles.code, hovered && { color: 'black' }]}>\n <Text style={{ color: '#BCC3CD' }}>$</Text> touch {getRootDir()}\n /index.js\n </Text>\n </View>\n )}\n </Pressable>\n );\n}\n\nconst styles = StyleSheet.create({\n background: {\n ...Platform.select({\n web: {\n backgroundImage:\n 'radial-gradient(circle at 1px 1px, rgba(255,255,255,0.15) 1px, transparent 0)',\n backgroundPositionX: -3,\n backgroundPositionY: -3,\n backgroundSize: '40px 40px',\n },\n }),\n backgroundColor: 'black',\n flex: 1,\n },\n safeArea: {\n flex: 1,\n maxWidth: 960,\n marginHorizontal: 'auto',\n alignItems: 'stretch',\n },\n container: {\n flex: 1,\n padding: 24,\n alignItems: 'flex-start',\n justifyContent: 'center',\n },\n title: {\n color: 'white',\n fontSize: 64,\n paddingBottom: 24,\n fontWeight: 'bold',\n },\n buttonContainer: {\n ...Platform.select({\n web: {\n transitionDuration: '200ms',\n backgroundColor: 'transparent',\n },\n default: {\n backgroundColor: 'white',\n },\n }),\n\n borderColor: 'white',\n borderWidth: 2,\n paddingVertical: 12,\n paddingHorizontal: 24,\n },\n buttonText: {\n color: 'black',\n },\n code: {\n ...Platform.select({\n web: {\n transitionDuration: '200ms',\n color: 'white',\n fontFamily: 'Courier',\n },\n default: {\n color: 'black',\n fontFamily: Platform.select({\n ios: 'Courier New',\n android: 'monospace',\n }),\n },\n }),\n\n userSelect: 'none',\n fontSize: 18,\n fontWeight: 'bold',\n },\n subtitle: {\n color: '#BCC3CD',\n fontSize: 36,\n fontWeight: '100',\n paddingBottom: 36,\n maxWidth: 960,\n },\n});\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"qualified-entry.d.ts","sourceRoot":"","sources":["../src/qualified-entry.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"qualified-entry.d.ts","sourceRoot":"","sources":["../src/qualified-entry.tsx"],"names":[],"mappings":";AAcA,wBAAgB,GAAG,gBAMlB"}
|
package/build/qualified-entry.js
CHANGED
|
@@ -1,21 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
// The entry component (one that uses context modules) cannot be in the same file as the
|
|
3
|
+
// entry side-effects, otherwise they'll be updated when files are added/removed from the
|
|
4
|
+
// app directory. This will cause a lot of unfortunate errors regarding HMR and Fast Refresh.
|
|
5
|
+
// This is because Fast Refresh is sending the entire file containing an updated component.
|
|
2
6
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
7
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
8
|
};
|
|
5
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
10
|
exports.App = void 0;
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
|
|
10
|
-
// This is because Fast Refresh is sending the entire file containing an updated component.
|
|
11
|
+
// This has to be the string "expo-router/_ctx" as we resolve the exact string to
|
|
12
|
+
// a different file in a custom resolver for bundle splitting in Node.js.
|
|
13
|
+
const _ctx_1 = require("expo-router/_ctx");
|
|
11
14
|
const react_1 = __importDefault(require("react"));
|
|
12
15
|
const ExpoRoot_1 = require("./ExpoRoot");
|
|
13
16
|
const head_1 = require("./head");
|
|
14
|
-
const _ctx_1 = require("../_ctx");
|
|
15
17
|
// Must be exported or Fast Refresh won't update the context
|
|
16
18
|
function App() {
|
|
17
|
-
return (
|
|
18
|
-
|
|
19
|
+
return (<head_1.Head.Provider>
|
|
20
|
+
<ExpoRoot_1.ExpoRoot context={_ctx_1.ctx}/>
|
|
21
|
+
</head_1.Head.Provider>);
|
|
19
22
|
}
|
|
20
23
|
exports.App = App;
|
|
21
24
|
//# sourceMappingURL=qualified-entry.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"qualified-entry.js","sourceRoot":"","sources":["../src/qualified-entry.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"qualified-entry.js","sourceRoot":"","sources":["../src/qualified-entry.tsx"],"names":[],"mappings":";AAAA,wFAAwF;AACxF,yFAAyF;AACzF,6FAA6F;AAC7F,2FAA2F;;;;;;AAE3F,iFAAiF;AACjF,yEAAyE;AACzE,2CAAuC;AACvC,kDAA0B;AAE1B,yCAAsC;AACtC,iCAA8B;AAE9B,4DAA4D;AAC5D,SAAgB,GAAG;IACjB,OAAO,CACL,CAAC,WAAI,CAAC,QAAQ,CACZ;MAAA,CAAC,mBAAQ,CAAC,OAAO,CAAC,CAAC,UAAG,CAAC,EACzB;IAAA,EAAE,WAAI,CAAC,QAAQ,CAAC,CACjB,CAAC;AACJ,CAAC;AAND,kBAMC","sourcesContent":["// The entry component (one that uses context modules) cannot be in the same file as the\n// entry side-effects, otherwise they'll be updated when files are added/removed from the\n// app directory. This will cause a lot of unfortunate errors regarding HMR and Fast Refresh.\n// This is because Fast Refresh is sending the entire file containing an updated component.\n\n// This has to be the string \"expo-router/_ctx\" as we resolve the exact string to\n// a different file in a custom resolver for bundle splitting in Node.js.\nimport { ctx } from 'expo-router/_ctx';\nimport React from 'react';\n\nimport { ExpoRoot } from './ExpoRoot';\nimport { Head } from './head';\n\n// Must be exported or Fast Refresh won't update the context\nexport function App() {\n return (\n <Head.Provider>\n <ExpoRoot context={ctx} />\n </Head.Provider>\n );\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderRootComponent.d.ts","sourceRoot":"","sources":["../src/renderRootComponent.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"renderRootComponent.d.ts","sourceRoot":"","sources":["../src/renderRootComponent.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AA6C1B;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,QAuCtE"}
|
|
@@ -1,13 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
27
|
};
|
|
5
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
29
|
exports.renderRootComponent = void 0;
|
|
7
30
|
const expo_1 = require("expo");
|
|
31
|
+
const SplashScreen = __importStar(require("expo-splash-screen"));
|
|
8
32
|
const react_1 = __importDefault(require("react"));
|
|
9
33
|
const react_native_1 = require("react-native");
|
|
10
|
-
const Splash_1 = require("./views/Splash");
|
|
11
34
|
function isBaseObject(obj) {
|
|
12
35
|
if (Object.prototype.toString.call(obj) !== '[object Object]') {
|
|
13
36
|
return false;
|
|
@@ -50,7 +73,8 @@ function renderRootComponent(Component) {
|
|
|
50
73
|
try {
|
|
51
74
|
// This must be delayed so the user has a chance to call it first.
|
|
52
75
|
setTimeout(() => {
|
|
53
|
-
|
|
76
|
+
// @ts-expect-error: This function is native-only and for internal-use only.
|
|
77
|
+
SplashScreen._internal_preventAutoHideAsync?.();
|
|
54
78
|
});
|
|
55
79
|
if (process.env.NODE_ENV !== 'production') {
|
|
56
80
|
const { withErrorOverlay } = require('@expo/metro-runtime/error-overlay');
|
|
@@ -62,13 +86,13 @@ function renderRootComponent(Component) {
|
|
|
62
86
|
}
|
|
63
87
|
catch (e) {
|
|
64
88
|
// Hide the splash screen if there was an error so the user can see it.
|
|
65
|
-
|
|
89
|
+
SplashScreen.hideAsync();
|
|
66
90
|
const error = convertError(e);
|
|
67
91
|
// Prevent the app from throwing confusing:
|
|
68
92
|
// ERROR Invariant Violation: "main" has not been registered. This can happen if:
|
|
69
93
|
// * Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.
|
|
70
94
|
// * A module failed to load due to an error and `AppRegistry.registerComponent` wasn't called.
|
|
71
|
-
(0, expo_1.registerRootComponent)(() =>
|
|
95
|
+
(0, expo_1.registerRootComponent)(() => <react_native_1.View />);
|
|
72
96
|
// Console is pretty useless on native, on web you get interactive stack traces.
|
|
73
97
|
if (react_native_1.Platform.OS === 'web') {
|
|
74
98
|
console.error(error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderRootComponent.js","sourceRoot":"","sources":["../src/renderRootComponent.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"renderRootComponent.js","sourceRoot":"","sources":["../src/renderRootComponent.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+BAA6C;AAC7C,iEAAmD;AACnD,kDAA0B;AAC1B,+CAA8C;AAE9C,SAAS,YAAY,CAAC,GAAQ;IAC5B,IAAI,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,iBAAiB,EAAE;QAC7D,OAAO,KAAK,CAAC;KACd;IACD,MAAM,KAAK,GAAG,MAAM,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;IACzC,IAAI,KAAK,KAAK,IAAI,EAAE;QAClB,OAAO,IAAI,CAAC;KACb;IACD,OAAO,KAAK,KAAK,MAAM,CAAC,SAAS,CAAC;AACpC,CAAC;AAED,SAAS,aAAa,CAAC,KAAU;IAC/B,OAAO,CACL,KAAK;QACL,OAAO,KAAK,KAAK,QAAQ;QACzB,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ;QAC9B,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ,CAClC,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,SAAS,YAAY,CAAC,KAAU;IAC9B,IAAI,aAAa,CAAC,KAAK,CAAC,EAAE;QACxB,OAAO,KAAK,CAAC;KACd;IAED,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa,EAAE;QAC1C,IAAI,KAAK,IAAI,IAAI,EAAE;YACjB,OAAO,IAAI,KAAK,CAAC,oCAAoC,CAAC,CA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AAC;AAvCD,kDAuCC","sourcesContent":["import { registerRootComponent } from 'expo';\nimport * as SplashScreen from 'expo-splash-screen';\nimport React from 'react';\nimport { Platform, View } from 'react-native';\n\nfunction isBaseObject(obj: any) {\n if (Object.prototype.toString.call(obj) !== '[object Object]') {\n return false;\n }\n const proto = Object.getPrototypeOf(obj);\n if (proto === null) {\n return true;\n }\n return proto === Object.prototype;\n}\n\nfunction isErrorShaped(error: any): error is Error {\n return (\n error &&\n typeof error === 'object' &&\n typeof error.name === 'string' &&\n typeof error.message === 'string'\n );\n}\n\n/**\n * After we throw this error, any number of tools could handle it.\n * This check ensures the error is always in a reason state before surfacing it to the runtime.\n */\nfunction convertError(error: any) {\n if (isErrorShaped(error)) {\n return error;\n }\n\n if (process.env.NODE_ENV === 'development') {\n if (error == null) {\n return new Error('A null/undefined error was thrown.');\n }\n }\n\n if (isBaseObject(error)) {\n return new Error(JSON.stringify(error));\n }\n\n return new Error(String(error));\n}\n\n/**\n * Register and mount the root component using the predefined rendering\n * method. This function ensures the Splash Screen and errors are handled correctly.\n */\nexport function renderRootComponent(Component: React.ComponentType<any>) {\n try {\n // This must be delayed so the user has a chance to call it first.\n setTimeout(() => {\n // @ts-expect-error: This function is native-only and for internal-use only.\n SplashScreen._internal_preventAutoHideAsync?.();\n });\n\n if (process.env.NODE_ENV !== 'production') {\n const { withErrorOverlay } =\n require('@expo/metro-runtime/error-overlay') as typeof import('@expo/metro-runtime/error-overlay');\n registerRootComponent(withErrorOverlay(Component));\n } else {\n registerRootComponent(Component);\n }\n } catch (e) {\n // Hide the splash screen if there was an error so the user can see it.\n SplashScreen.hideAsync();\n\n const error = convertError(e);\n // Prevent the app from throwing confusing:\n // ERROR Invariant Violation: \"main\" has not been registered. This can happen if:\n // * Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and restart it in the current project.\n // * A module failed to load due to an error and `AppRegistry.registerComponent` wasn't called.\n registerRootComponent(() => <View />);\n\n // Console is pretty useless on native, on web you get interactive stack traces.\n if (Platform.OS === 'web') {\n console.error(error);\n console.error(`A runtime error has occurred while rendering the root component.`);\n }\n\n // Give React a tick to render before throwing.\n setTimeout(() => {\n throw error;\n });\n\n // TODO: Render a production-only error screen.\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routes-manifest.d.ts","sourceRoot":"","sources":["../src/routes-manifest.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,SAAS,CAAC,MAAM,GAAG,MAAM,IAAI;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE;QAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;CACxC,CAAC;AAEF,MAAM,MAAM,oBAAoB,CAAC,MAAM,GAAG,MAAM,IAAI;IAClD,SAAS,EAAE,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC;IAC/B,UAAU,EAAE,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC;IAChC,cAAc,EAAE,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC;CACrC,CAAC;AAYF,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,oBAAoB,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"routes-manifest.d.ts","sourceRoot":"","sources":["../src/routes-manifest.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,SAAS,CAAC,MAAM,GAAG,MAAM,IAAI;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE;QAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;CACxC,CAAC;AAEF,MAAM,MAAM,oBAAoB,CAAC,MAAM,GAAG,MAAM,IAAI;IAClD,SAAS,EAAE,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC;IAC/B,UAAU,EAAE,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC;IAChC,cAAc,EAAE,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC;CACrC,CAAC;AAYF,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,oBAAoB,GAAG,IAAI,CAYjF"}
|