expo-router 3.1.2 → 3.2.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/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 +17 -5
- package/build/LocationProvider.js.map +1 -1
- package/build/Route.d.ts +1 -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 +10 -35
- 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 +59 -48
- 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 +1 -2
- package/build/getRoutes.d.ts.map +1 -1
- package/build/getRoutes.js +51 -49
- package/build/getRoutes.js.map +1 -1
- package/build/getServerManifest.d.ts +4 -0
- 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 +28 -2
- 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 +75 -95
- 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/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/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.js +3 -2
- 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.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.js +11 -9
- package/build/static/html.js.map +1 -1
- package/build/static/renderStaticContent.d.ts +39 -2
- package/build/static/renderStaticContent.d.ts.map +1 -1
- package/build/static/renderStaticContent.js +28 -6
- package/build/static/renderStaticContent.js.map +1 -1
- package/build/testing-library/index.js +2 -2
- 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 +7 -5
- 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.js +19 -16
- package/build/useScreens.js.map +1 -1
- package/build/views/EmptyRoute.js +5 -2
- package/build/views/EmptyRoute.js.map +1 -1
- package/build/views/ErrorBoundary.js +43 -28
- 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 +49 -35
- 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.js +3 -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/ios/ExpoHead.podspec +1 -1
- package/package.json +7 -18
- 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/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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routes-manifest.js","sourceRoot":"","sources":["../src/routes-manifest.ts"],"names":[],"mappings":";;;AAAA,0CAA0C;AAC1C,sBAAsB;AACtB,2CAAwC;AACxC,2DAAwD;
|
|
1
|
+
{"version":3,"file":"routes-manifest.js","sourceRoot":"","sources":["../src/routes-manifest.ts"],"names":[],"mappings":";;;AAAA,0CAA0C;AAC1C,sBAAsB;AACtB,2CAAwC;AACxC,2DAAwD;AAgBxD,SAAS,uBAAuB,CAAC,MAAgB,EAAE;IACjD,MAAM,aAAa,GAAG,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,EAAE,OAAO,KAAI,CAAC,EAAE,CAAC,CAAC;IAElD,MAAM,CAAC,cAAc,CAAC,aAAa,EAAE,MAAM,EAAE;QAC3C,KAAK,EAAE,GAAG,EAAE,CAAC,GAAG;KACjB,CAAC,CAAC;IAEH,OAAO,aAA+B,CAAC;AACzC,CAAC;AAED,SAAgB,oBAAoB,CAAC,KAAe;IAClD,mCAAmC;IACnC,MAAM,SAAS,GAAG,IAAA,qBAAS,EAAC,uBAAuB,CAAC,KAAK,CAAC,EAAE;QAC1D,iBAAiB,EAAE,IAAI;QACvB,mBAAmB,EAAE,IAAI;KAC1B,CAAC,CAAC;IAEH,IAAI,CAAC,SAAS,EAAE;QACd,OAAO,IAAI,CAAC;KACb;IACD,OAAO,IAAA,qCAAiB,EAAC,SAAS,CAAC,CAAC;AACtC,CAAC;AAXD,oDAWC","sourcesContent":["// This file runs in Node.js environments.\n// no relative imports\nimport { getRoutes } from './getRoutes';\nimport { getServerManifest } from './getServerManifest';\nimport { RequireContext } from './types';\n\nexport type RouteInfo<TRegex = string> = {\n file: string;\n page: string;\n namedRegex: TRegex;\n routeKeys: { [named: string]: string };\n};\n\nexport type ExpoRoutesManifestV1<TRegex = string> = {\n apiRoutes: RouteInfo<TRegex>[];\n htmlRoutes: RouteInfo<TRegex>[];\n notFoundRoutes: RouteInfo<TRegex>[];\n};\n\nfunction createMockContextModule(map: string[] = []) {\n const contextModule = (key) => ({ default() {} });\n\n Object.defineProperty(contextModule, 'keys', {\n value: () => map,\n });\n\n return contextModule as RequireContext;\n}\n\nexport function createRoutesManifest(paths: string[]): ExpoRoutesManifestV1 | null {\n // TODO: Drop this part for Node.js\n const routeTree = getRoutes(createMockContextModule(paths), {\n preserveApiRoutes: true,\n ignoreRequireErrors: true,\n });\n\n if (!routeTree) {\n return null;\n }\n return getServerManifest(routeTree);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sortRoutes.d.ts","sourceRoot":"","sources":["../src/sortRoutes.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"sortRoutes.d.ts","sourceRoot":"","sources":["../src/sortRoutes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,SAAS,EAAE,MAAM,SAAS,CAAC;AAavD,wBAAgB,UAAU,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,SAAS,GAAG,MAAM,CAgD7D;AAED,wBAAgB,qBAAqB,CAAC,gBAAgB,CAAC,EAAE,MAAM,OAClD,SAAS,KAAK,SAAS,KAAG,MAAM,CAW5C"}
|
package/build/sortRoutes.js
CHANGED
|
@@ -2,6 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.sortRoutesWithInitial = exports.sortRoutes = void 0;
|
|
4
4
|
const matchers_1 = require("./matchers");
|
|
5
|
+
function sortDynamicConvention(a, b) {
|
|
6
|
+
if (a.deep && !b.deep) {
|
|
7
|
+
return 1;
|
|
8
|
+
}
|
|
9
|
+
if (!a.deep && b.deep) {
|
|
10
|
+
return -1;
|
|
11
|
+
}
|
|
12
|
+
return 0;
|
|
13
|
+
}
|
|
5
14
|
function sortRoutes(a, b) {
|
|
6
15
|
if (a.dynamic && !b.dynamic) {
|
|
7
16
|
return 1;
|
|
@@ -16,12 +25,22 @@ function sortRoutes(a, b) {
|
|
|
16
25
|
for (let i = 0; i < a.dynamic.length; i++) {
|
|
17
26
|
const aDynamic = a.dynamic[i];
|
|
18
27
|
const bDynamic = b.dynamic[i];
|
|
19
|
-
if (aDynamic.
|
|
28
|
+
if (aDynamic.notFound && bDynamic.notFound) {
|
|
29
|
+
const s = sortDynamicConvention(aDynamic, bDynamic);
|
|
30
|
+
if (s) {
|
|
31
|
+
return s;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if (aDynamic.notFound && !bDynamic.notFound) {
|
|
20
35
|
return 1;
|
|
21
36
|
}
|
|
22
|
-
if (!aDynamic.
|
|
37
|
+
if (!aDynamic.notFound && bDynamic.notFound) {
|
|
23
38
|
return -1;
|
|
24
39
|
}
|
|
40
|
+
const s = sortDynamicConvention(aDynamic, bDynamic);
|
|
41
|
+
if (s) {
|
|
42
|
+
return s;
|
|
43
|
+
}
|
|
25
44
|
}
|
|
26
45
|
return 0;
|
|
27
46
|
}
|
package/build/sortRoutes.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sortRoutes.js","sourceRoot":"","sources":["../src/sortRoutes.ts"],"names":[],"mappings":";;;AACA,yCAA4C;AAE5C,SAAgB,UAAU,CAAC,CAAY,EAAE,CAAY;IACnD,IAAI,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,CAAC,OAAO,EAAE;QAC3B,OAAO,CAAC,CAAC;KACV;IACD,IAAI,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,OAAO,EAAE;QAC3B,OAAO,CAAC,CAAC,CAAC;KACX;IACD,IAAI,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,OAAO,EAAE;QAC1B,IAAI,CAAC,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE;YACzC,OAAO,CAAC,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC;SAC5C;
|
|
1
|
+
{"version":3,"file":"sortRoutes.js","sourceRoot":"","sources":["../src/sortRoutes.ts"],"names":[],"mappings":";;;AACA,yCAA4C;AAE5C,SAAS,qBAAqB,CAAC,CAAoB,EAAE,CAAoB;IACvE,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE;QACrB,OAAO,CAAC,CAAC;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3C,OAAO,CAAC,CAAC,CAAC;aACX;YAED,MAAM,CAAC,GAAG,qBAAqB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;YACpD,IAAI,CAAC,EAAE;gBACL,OAAO,CAAC,CAAC;aACV;SACF;QACD,OAAO,CAAC,CAAC;KACV;IAED,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,KAAK,OAAO,IAAI,IAAA,yBAAc,EAAC,CAAC,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC;IACtE,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,KAAK,OAAO,IAAI,IAAA,yBAAc,EAAC,CAAC,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC;IAEtE,IAAI,MAAM,IAAI,CAAC,MAAM,EAAE;QACrB,OAAO,CAAC,CAAC,CAAC;KACX;IACD,IAAI,CAAC,MAAM,IAAI,MAAM,EAAE;QACrB,OAAO,CAAC,CAAC;KACV;IAED,OAAO,CAAC,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC;AACzC,CAAC;AAhDD,gCAgDC;AAED,SAAgB,qBAAqB,CAAC,gBAAyB;IAC7D,OAAO,CAAC,CAAY,EAAE,CAAY,EAAU,EAAE;QAC5C,IAAI,gBAAgB,EAAE;YACpB,IAAI,CAAC,CAAC,KAAK,KAAK,gBAAgB,EAAE;gBAChC,OAAO,CAAC,CAAC,CAAC;aACX;YACD,IAAI,CAAC,CAAC,KAAK,KAAK,gBAAgB,EAAE;gBAChC,OAAO,CAAC,CAAC;aACV;SACF;QACD,OAAO,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC1B,CAAC,CAAC;AACJ,CAAC;AAZD,sDAYC","sourcesContent":["import { DynamicConvention, RouteNode } from './Route';\nimport { matchGroupName } from './matchers';\n\nfunction sortDynamicConvention(a: DynamicConvention, b: DynamicConvention) {\n if (a.deep && !b.deep) {\n return 1;\n }\n if (!a.deep && b.deep) {\n return -1;\n }\n return 0;\n}\n\nexport function sortRoutes(a: RouteNode, b: RouteNode): number {\n if (a.dynamic && !b.dynamic) {\n return 1;\n }\n if (!a.dynamic && b.dynamic) {\n return -1;\n }\n if (a.dynamic && b.dynamic) {\n if (a.dynamic.length !== b.dynamic.length) {\n return b.dynamic.length - a.dynamic.length;\n }\n\n for (let i = 0; i < a.dynamic.length; i++) {\n const aDynamic = a.dynamic[i];\n const bDynamic = b.dynamic[i];\n\n if (aDynamic.notFound && bDynamic.notFound) {\n const s = sortDynamicConvention(aDynamic, bDynamic);\n if (s) {\n return s;\n }\n }\n if (aDynamic.notFound && !bDynamic.notFound) {\n return 1;\n }\n if (!aDynamic.notFound && bDynamic.notFound) {\n return -1;\n }\n\n const s = sortDynamicConvention(aDynamic, bDynamic);\n if (s) {\n return s;\n }\n }\n return 0;\n }\n\n const aIndex = a.route === 'index' || matchGroupName(a.route) != null;\n const bIndex = b.route === 'index' || matchGroupName(b.route) != null;\n\n if (aIndex && !bIndex) {\n return -1;\n }\n if (!aIndex && bIndex) {\n return 1;\n }\n\n return a.route.length - b.route.length;\n}\n\nexport function sortRoutesWithInitial(initialRouteName?: string) {\n return (a: RouteNode, b: RouteNode): number => {\n if (initialRouteName) {\n if (a.route === initialRouteName) {\n return -1;\n }\n if (b.route === initialRouteName) {\n return 1;\n }\n }\n return sortRoutes(a, b);\n };\n}\n"]}
|
package/build/static/html.js
CHANGED
|
@@ -15,19 +15,21 @@ const react_1 = __importDefault(require("react"));
|
|
|
15
15
|
* Root style-reset for full-screen React Native web apps with a root `<ScrollView />` should use the following styles to ensure native parity. [Learn more](https://necolas.github.io/react-native-web/docs/setup/#root-element).
|
|
16
16
|
*/
|
|
17
17
|
function ScrollViewStyleReset() {
|
|
18
|
-
return (
|
|
18
|
+
return (<style id="expo-reset" dangerouslySetInnerHTML={{
|
|
19
19
|
__html: `#root,body{display:flex}#root,body,html{width:100%;-webkit-overflow-scrolling:touch;margin:0;padding:0;min-height:100%}#root{flex-shrink:0;flex-basis:auto;flex-grow:1;flex:1}html{scroll-behavior:smooth;-webkit-text-size-adjust:100%;height:calc(100% + env(safe-area-inset-top))}body{overflow-y:auto;overscroll-behavior-y:none;text-rendering:optimizeLegibility;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;-ms-overflow-style:scrollbar}`,
|
|
20
|
-
}
|
|
20
|
+
}}/>);
|
|
21
21
|
}
|
|
22
22
|
exports.ScrollViewStyleReset = ScrollViewStyleReset;
|
|
23
23
|
function Html({ children }) {
|
|
24
|
-
return (
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
24
|
+
return (<html lang="en">
|
|
25
|
+
<head>
|
|
26
|
+
<meta charSet="utf-8"/>
|
|
27
|
+
<meta httpEquiv="X-UA-Compatible" content="IE=edge"/>
|
|
28
|
+
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1.00001,viewport-fit=cover"/>
|
|
29
|
+
<ScrollViewStyleReset />
|
|
30
|
+
</head>
|
|
31
|
+
<body>{children}</body>
|
|
32
|
+
</html>);
|
|
31
33
|
}
|
|
32
34
|
exports.Html = Html;
|
|
33
35
|
//# sourceMappingURL=html.js.map
|
package/build/static/html.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html.js","sourceRoot":"","sources":["../../src/static/html.tsx"],"names":[],"mappings":";;;;;;AAAA;;;;;GAKG;AACH,kDAA0B;AAE1B;;GAEG;AACH,SAAgB,oBAAoB;IAClC,OAAO,CACL,
|
|
1
|
+
{"version":3,"file":"html.js","sourceRoot":"","sources":["../../src/static/html.tsx"],"names":[],"mappings":";;;;;;AAAA;;;;;GAKG;AACH,kDAA0B;AAE1B;;GAEG;AACH,SAAgB,oBAAoB;IAClC,OAAO,CACL,CAAC,KAAK,CACJ,EAAE,CAAC,YAAY,CACf,uBAAuB,CAAC,CAAC;YACvB,MAAM,EAAE,2cAA2c;SACpd,CAAC,EACF,CACH,CAAC;AACJ,CAAC;AATD,oDASC;AAED,SAAgB,IAAI,CAAC,EAAE,QAAQ,EAAiC;IAC9D,OAAO,CACL,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CACb;MAAA,CAAC,IAAI,CACH;QAAA,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,EACrB;QAAA,CAAC,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAC,OAAO,CAAC,SAAS,EACnD;QAAA,CAAC,IAAI,CACH,IAAI,CAAC,UAAU,CACf,OAAO,CAAC,6FAA6F,EAEvG;QAAA,CAAC,oBAAoB,CAAC,AAAD,EACvB;MAAA,EAAE,IAAI,CACN;MAAA,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,EAAE,IAAI,CACxB;IAAA,EAAE,IAAI,CAAC,CACR,CAAC;AACJ,CAAC;AAfD,oBAeC","sourcesContent":["/**\n * Copyright © 2023 650 Industries.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport React from 'react';\n\n/**\n * Root style-reset for full-screen React Native web apps with a root `<ScrollView />` should use the following styles to ensure native parity. [Learn more](https://necolas.github.io/react-native-web/docs/setup/#root-element).\n */\nexport function ScrollViewStyleReset() {\n return (\n <style\n id=\"expo-reset\"\n dangerouslySetInnerHTML={{\n __html: `#root,body{display:flex}#root,body,html{width:100%;-webkit-overflow-scrolling:touch;margin:0;padding:0;min-height:100%}#root{flex-shrink:0;flex-basis:auto;flex-grow:1;flex:1}html{scroll-behavior:smooth;-webkit-text-size-adjust:100%;height:calc(100% + env(safe-area-inset-top))}body{overflow-y:auto;overscroll-behavior-y:none;text-rendering:optimizeLegibility;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;-ms-overflow-style:scrollbar}`,\n }}\n />\n );\n}\n\nexport function Html({ children }: { children: React.ReactNode }) {\n return (\n <html lang=\"en\">\n <head>\n <meta charSet=\"utf-8\" />\n <meta httpEquiv=\"X-UA-Compatible\" content=\"IE=edge\" />\n <meta\n name=\"viewport\"\n content=\"width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1.00001,viewport-fit=cover\"\n />\n <ScrollViewStyleReset />\n </head>\n <body>{children}</body>\n </html>\n );\n}\n"]}
|
|
@@ -5,11 +5,48 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import '@expo/metro-runtime';
|
|
8
|
+
import { getRoutes } from '../getRoutes';
|
|
8
9
|
/** Get the linking manifest from a Node.js process. */
|
|
9
|
-
declare function getManifest(options
|
|
10
|
+
declare function getManifest(options?: Parameters<typeof getRoutes>[1]): Promise<{
|
|
10
11
|
initialRouteName?: string | undefined;
|
|
11
12
|
screens: Record<string, import("../getReactNavigationConfig").Screen>;
|
|
12
13
|
}>;
|
|
14
|
+
/**
|
|
15
|
+
* Get the server manifest with all dynamic routes loaded with `generateStaticParams`.
|
|
16
|
+
* Unlike the `expo-router/src/routes-manifest.ts` method, this requires loading the entire app in-memory, which
|
|
17
|
+
* takes substantially longer and requires Metro bundling.
|
|
18
|
+
*
|
|
19
|
+
* This is used for the production manifest where we pre-render certain pages and should no longer treat them as dynamic.
|
|
20
|
+
*/
|
|
21
|
+
declare function getBuildTimeServerManifestAsync(options?: Parameters<typeof getRoutes>[1]): Promise<{
|
|
22
|
+
apiRoutes: {
|
|
23
|
+
generated: boolean | undefined;
|
|
24
|
+
file: string;
|
|
25
|
+
page: string;
|
|
26
|
+
namedRegex: string;
|
|
27
|
+
routeKeys: {
|
|
28
|
+
[named: string]: string;
|
|
29
|
+
};
|
|
30
|
+
}[];
|
|
31
|
+
htmlRoutes: {
|
|
32
|
+
generated: boolean | undefined;
|
|
33
|
+
file: string;
|
|
34
|
+
page: string;
|
|
35
|
+
namedRegex: string;
|
|
36
|
+
routeKeys: {
|
|
37
|
+
[named: string]: string;
|
|
38
|
+
};
|
|
39
|
+
}[];
|
|
40
|
+
notFoundRoutes: {
|
|
41
|
+
generated: boolean | undefined;
|
|
42
|
+
file: string;
|
|
43
|
+
page: string;
|
|
44
|
+
namedRegex: string;
|
|
45
|
+
routeKeys: {
|
|
46
|
+
[named: string]: string;
|
|
47
|
+
};
|
|
48
|
+
}[];
|
|
49
|
+
}>;
|
|
13
50
|
export declare function getStaticContent(location: URL): string;
|
|
14
|
-
export { getManifest };
|
|
51
|
+
export { getManifest, getBuildTimeServerManifestAsync };
|
|
15
52
|
//# sourceMappingURL=renderStaticContent.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderStaticContent.d.ts","sourceRoot":"","sources":["../../src/static/renderStaticContent.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"renderStaticContent.d.ts","sourceRoot":"","sources":["../../src/static/renderStaticContent.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,qBAAqB,CAAC;AAY7B,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AASzC,uDAAuD;AACvD,iBAAe,WAAW,CAAC,OAAO,GAAE,UAAU,CAAC,OAAO,SAAS,CAAC,CAAC,CAAC,CAAM;;;GAWvE;AAED;;;;;;GAMG;AACH,iBAAe,+BAA+B,CAAC,OAAO,GAAE,UAAU,CAAC,OAAO,SAAS,CAAC,CAAC,CAAC,CAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAa3F;AAYD,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,GAAG,GAAG,MAAM,CAoDtD;AAmBD,OAAO,EAAE,WAAW,EAAE,+BAA+B,EAAE,CAAC"}
|
|
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.getManifest = exports.getStaticContent = void 0;
|
|
29
|
+
exports.getBuildTimeServerManifestAsync = exports.getManifest = exports.getStaticContent = void 0;
|
|
30
30
|
/**
|
|
31
31
|
* Copyright © 2023 650 Industries.
|
|
32
32
|
*
|
|
@@ -44,12 +44,13 @@ const _ctx_1 = require("../../_ctx");
|
|
|
44
44
|
const ExpoRoot_1 = require("../ExpoRoot");
|
|
45
45
|
const getLinkingConfig_1 = require("../getLinkingConfig");
|
|
46
46
|
const getRoutes_1 = require("../getRoutes");
|
|
47
|
+
const getServerManifest_1 = require("../getServerManifest");
|
|
47
48
|
const head_1 = require("../head");
|
|
48
49
|
const loadStaticParamsAsync_1 = require("../loadStaticParamsAsync");
|
|
49
50
|
const debug = require('debug')('expo:router:renderStaticContent');
|
|
50
51
|
react_native_web_1.AppRegistry.registerComponent('App', () => ExpoRoot_1.ExpoRoot);
|
|
51
52
|
/** Get the linking manifest from a Node.js process. */
|
|
52
|
-
async function getManifest(options) {
|
|
53
|
+
async function getManifest(options = {}) {
|
|
53
54
|
const routeTree = (0, getRoutes_1.getRoutes)(_ctx_1.ctx, { preserveApiRoutes: true, ...options });
|
|
54
55
|
if (!routeTree) {
|
|
55
56
|
throw new Error('No routes found');
|
|
@@ -59,6 +60,25 @@ async function getManifest(options) {
|
|
|
59
60
|
return (0, getLinkingConfig_1.getNavigationConfig)(routeTree);
|
|
60
61
|
}
|
|
61
62
|
exports.getManifest = getManifest;
|
|
63
|
+
/**
|
|
64
|
+
* Get the server manifest with all dynamic routes loaded with `generateStaticParams`.
|
|
65
|
+
* Unlike the `expo-router/src/routes-manifest.ts` method, this requires loading the entire app in-memory, which
|
|
66
|
+
* takes substantially longer and requires Metro bundling.
|
|
67
|
+
*
|
|
68
|
+
* This is used for the production manifest where we pre-render certain pages and should no longer treat them as dynamic.
|
|
69
|
+
*/
|
|
70
|
+
async function getBuildTimeServerManifestAsync(options = {}) {
|
|
71
|
+
const routeTree = (0, getRoutes_1.getRoutes)(_ctx_1.ctx, {
|
|
72
|
+
...options,
|
|
73
|
+
});
|
|
74
|
+
if (!routeTree) {
|
|
75
|
+
throw new Error('No routes found');
|
|
76
|
+
}
|
|
77
|
+
// Evaluate all static params
|
|
78
|
+
await (0, loadStaticParamsAsync_1.loadStaticParamsAsync)(routeTree);
|
|
79
|
+
return (0, getServerManifest_1.getServerManifest)(routeTree);
|
|
80
|
+
}
|
|
81
|
+
exports.getBuildTimeServerManifestAsync = getBuildTimeServerManifestAsync;
|
|
62
82
|
function resetReactNavigationContexts() {
|
|
63
83
|
// https://github.com/expo/router/discussions/588
|
|
64
84
|
// https://github.com/react-navigation/react-navigation/blob/9fe34b445fcb86e5666f61e144007d7540f014fa/packages/elements/src/getNamedContext.tsx#LL3C1-L4C1
|
|
@@ -77,8 +97,9 @@ function getStaticContent(location) {
|
|
|
77
97
|
initialProps: {
|
|
78
98
|
location,
|
|
79
99
|
context: _ctx_1.ctx,
|
|
80
|
-
wrapper: ({ children }) => (
|
|
81
|
-
|
|
100
|
+
wrapper: ({ children }) => (<Root>
|
|
101
|
+
<div id="root">{children}</div>
|
|
102
|
+
</Root>),
|
|
82
103
|
},
|
|
83
104
|
});
|
|
84
105
|
const Root = (0, getRootComponent_1.getRootComponent)();
|
|
@@ -88,8 +109,9 @@ function getStaticContent(location) {
|
|
|
88
109
|
// This MUST be run before `ReactDOMServer.renderToString` to prevent
|
|
89
110
|
// "Warning: Detected multiple renderers concurrently rendering the same context provider. This is currently unsupported."
|
|
90
111
|
resetReactNavigationContexts();
|
|
91
|
-
const html = server_1.default.renderToString(
|
|
92
|
-
|
|
112
|
+
const html = server_1.default.renderToString(<head_1.Head.Provider context={headContext}>
|
|
113
|
+
<native_1.ServerContainer ref={ref}>{element}</native_1.ServerContainer>
|
|
114
|
+
</head_1.Head.Provider>);
|
|
93
115
|
// Eval the CSS after the HTML is rendered so that the CSS is in the same order
|
|
94
116
|
const css = server_1.default.renderToStaticMarkup(getStyleElement());
|
|
95
117
|
let output = mixHeadComponentsWithStaticResults(headContext.helmet, html);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderStaticContent.js","sourceRoot":"","sources":["../../src/static/renderStaticContent.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;GAKG;AACH,+BAA6B;AAE7B,qDAA+E;AAC/E,6DAA+C;AAC/C,kDAA0B;AAC1B,8DAA8C;AAC9C,uDAA+C;AAE/C,yDAAsD;AACtD,qCAAiC;AACjC,0CAAuC;AACvC,0DAA0D;AAC1D,4CAAyC;AACzC,kCAA+B;AAC/B,oEAAiE;AAEjE,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,iCAAiC,CAAC,CAAC;AAElE,8BAAW,CAAC,iBAAiB,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC,mBAAQ,CAAC,CAAC;AAErD,uDAAuD;AACvD,KAAK,UAAU,WAAW,CAAC,
|
|
1
|
+
{"version":3,"file":"renderStaticContent.js","sourceRoot":"","sources":["../../src/static/renderStaticContent.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;GAKG;AACH,+BAA6B;AAE7B,qDAA+E;AAC/E,6DAA+C;AAC/C,kDAA0B;AAC1B,8DAA8C;AAC9C,uDAA+C;AAE/C,yDAAsD;AACtD,qCAAiC;AACjC,0CAAuC;AACvC,0DAA0D;AAC1D,4CAAyC;AACzC,4DAAyD;AACzD,kCAA+B;AAC/B,oEAAiE;AAEjE,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,iCAAiC,CAAC,CAAC;AAElE,8BAAW,CAAC,iBAAiB,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC,mBAAQ,CAAC,CAAC;AAErD,uDAAuD;AACvD,KAAK,UAAU,WAAW,CAAC,UAA2C,EAAE;IACtE,MAAM,SAAS,GAAG,IAAA,qBAAS,EAAC,UAAG,EAAE,EAAE,iBAAiB,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAE1E,IAAI,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AAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QACpF,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,QAAQ,EAAE,CAAC;QACzC,IAAI,MAAM,EAAE;YACV,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC,CAAC;SAClD;KACF;IAED,aAAa;IACb,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,cAAc,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;IAC7E,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,cAAc,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;IAE7E,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["/**\n * Copyright © 2023 650 Industries.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport '@expo/metro-runtime';\n\nimport { ServerContainer, ServerContainerRef } from '@react-navigation/native';\nimport * as Font from 'expo-font/build/server';\nimport React from 'react';\nimport ReactDOMServer from 'react-dom/server';\nimport { AppRegistry } from 'react-native-web';\n\nimport { getRootComponent } from './getRootComponent';\nimport { ctx } from '../../_ctx';\nimport { ExpoRoot } from '../ExpoRoot';\nimport { getNavigationConfig } from '../getLinkingConfig';\nimport { getRoutes } from '../getRoutes';\nimport { getServerManifest } from '../getServerManifest';\nimport { Head } from '../head';\nimport { loadStaticParamsAsync } from '../loadStaticParamsAsync';\n\nconst debug = require('debug')('expo:router:renderStaticContent');\n\nAppRegistry.registerComponent('App', () => ExpoRoot);\n\n/** Get the linking manifest from a Node.js process. */\nasync function getManifest(options: Parameters<typeof getRoutes>[1] = {}) {\n const routeTree = getRoutes(ctx, { preserveApiRoutes: true, ...options });\n\n if (!routeTree) {\n throw new Error('No routes found');\n }\n\n // Evaluate all static params\n await loadStaticParamsAsync(routeTree);\n\n return getNavigationConfig(routeTree);\n}\n\n/**\n * Get the server manifest with all dynamic routes loaded with `generateStaticParams`.\n * Unlike the `expo-router/src/routes-manifest.ts` method, this requires loading the entire app in-memory, which\n * takes substantially longer and requires Metro bundling.\n *\n * This is used for the production manifest where we pre-render certain pages and should no longer treat them as dynamic.\n */\nasync function getBuildTimeServerManifestAsync(options: Parameters<typeof getRoutes>[1] = {}) {\n const routeTree = getRoutes(ctx, {\n ...options,\n });\n\n if (!routeTree) {\n throw new Error('No routes found');\n }\n\n // Evaluate all static params\n await loadStaticParamsAsync(routeTree);\n\n return getServerManifest(routeTree);\n}\n\nfunction resetReactNavigationContexts() {\n // https://github.com/expo/router/discussions/588\n // https://github.com/react-navigation/react-navigation/blob/9fe34b445fcb86e5666f61e144007d7540f014fa/packages/elements/src/getNamedContext.tsx#LL3C1-L4C1\n\n // React Navigation is storing providers in a global, this is fine for the first static render\n // but subsequent static renders of Stack or Tabs will cause React to throw a warning. To prevent this warning, we'll reset the globals before rendering.\n const contexts = '__react_navigation__elements_contexts';\n global[contexts] = new Map<string, React.Context<any>>();\n}\n\nexport function getStaticContent(location: URL): string {\n const headContext: { helmet?: any } = {};\n\n const ref = React.createRef<ServerContainerRef>();\n\n const {\n // NOTE: The `element` that's returned adds two extra Views and\n // the seemingly unused `RootTagContext.Provider`.\n element,\n getStyleElement,\n } = AppRegistry.getApplication('App', {\n initialProps: {\n location,\n context: ctx,\n wrapper: ({ children }) => (\n <Root>\n <div id=\"root\">{children}</div>\n </Root>\n ),\n },\n });\n\n const Root = getRootComponent();\n\n // Clear any existing static resources from the global scope to attempt to prevent leaking between pages.\n // This could break if pages are rendered in parallel or if fonts are loaded outside of the React tree\n Font.resetServerContext();\n\n // This MUST be run before `ReactDOMServer.renderToString` to prevent\n // \"Warning: Detected multiple renderers concurrently rendering the same context provider. This is currently unsupported.\"\n resetReactNavigationContexts();\n\n const html = ReactDOMServer.renderToString(\n <Head.Provider context={headContext}>\n <ServerContainer ref={ref}>{element}</ServerContainer>\n </Head.Provider>\n );\n\n // Eval the CSS after the HTML is rendered so that the CSS is in the same order\n const css = ReactDOMServer.renderToStaticMarkup(getStyleElement());\n\n let output = mixHeadComponentsWithStaticResults(headContext.helmet, html);\n\n output = output.replace('</head>', `${css}</head>`);\n\n const fonts = Font.getServerResources();\n debug(`Pushing static fonts: (count: ${fonts.length})`, fonts);\n // debug('Push static fonts:', fonts)\n // Inject static fonts loaded with expo-font\n output = output.replace('</head>', `${fonts.join('')}</head>`);\n\n return '<!DOCTYPE html>' + output;\n}\n\nfunction mixHeadComponentsWithStaticResults(helmet: any, html: string) {\n // Head components\n for (const key of ['title', 'priority', 'meta', 'link', 'script', 'style'].reverse()) {\n const result = helmet?.[key]?.toString();\n if (result) {\n html = html.replace('<head>', `<head>${result}`);\n }\n }\n\n // attributes\n html = html.replace('<html ', `<html ${helmet?.htmlAttributes.toString()} `);\n html = html.replace('<body ', `<body ${helmet?.bodyAttributes.toString()} `);\n\n return html;\n}\n\n// Re-export for use in server\nexport { getManifest, getBuildTimeServerManifestAsync };\n"]}
|
|
@@ -37,7 +37,7 @@ function renderRouter(context = './app', { initialUrl = '/', ...options } = {})
|
|
|
37
37
|
jest.useFakeTimers();
|
|
38
38
|
let ctx;
|
|
39
39
|
// Reset the initial URL
|
|
40
|
-
mocks_1.
|
|
40
|
+
(0, mocks_1.setInitialUrl)(initialUrl);
|
|
41
41
|
// Force the render to be synchronous
|
|
42
42
|
process.env.EXPO_ROUTER_IMPORT_MODE_WEB = 'sync';
|
|
43
43
|
process.env.EXPO_ROUTER_IMPORT_MODE_IOS = 'sync';
|
|
@@ -59,7 +59,7 @@ function renderRouter(context = './app', { initialUrl = '/', ...options } = {})
|
|
|
59
59
|
else if (initialUrl instanceof URL) {
|
|
60
60
|
location = initialUrl;
|
|
61
61
|
}
|
|
62
|
-
const result = (0, react_native_1.render)(
|
|
62
|
+
const result = (0, react_native_1.render)(<ExpoRoot_1.ExpoRoot context={ctx} location={location}/>, {
|
|
63
63
|
...options,
|
|
64
64
|
});
|
|
65
65
|
return Object.assign(result, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/testing-library/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,0CAA0C;AAC1C,oBAAkB;AAElB,gEAAqE;AACrE,gDAAwB;AACxB,kDAA0B;AAE1B,mDAKyB;AACzB,mCAAwC;AACxC,0CAAuC;AACvC,0DAAiD;AACjD,+DAAqD;AAGrD,uBAAuB;AACvB,gEAA8C;AAY9C,SAAS,iBAAiB,CACxB,OAAe;IAEf,OAAO,OAAO,CAAC,OAAO,OAAO,KAAK,QAAQ,IAAI,QAAQ,IAAI,OAAO,CAAC,CAAC;AACrE,CAAC;AAWD,SAAgB,YAAY,CAC1B,UAG+B,OAAO,EACtC,EAAE,UAAU,GAAG,GAAG,EAAE,GAAG,OAAO,KAA0B,EAAE;IAE1D,IAAI,CAAC,aAAa,EAAE,CAAC;IAErB,IAAI,GAAmB,CAAC;IAExB,wBAAwB;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/testing-library/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,0CAA0C;AAC1C,oBAAkB;AAElB,gEAAqE;AACrE,gDAAwB;AACxB,kDAA0B;AAE1B,mDAKyB;AACzB,mCAAwC;AACxC,0CAAuC;AACvC,0DAAiD;AACjD,+DAAqD;AAGrD,uBAAuB;AACvB,gEAA8C;AAY9C,SAAS,iBAAiB,CACxB,OAAe;IAEf,OAAO,OAAO,CAAC,OAAO,OAAO,KAAK,QAAQ,IAAI,QAAQ,IAAI,OAAO,CAAC,CAAC;AACrE,CAAC;AAWD,SAAgB,YAAY,CAC1B,UAG+B,OAAO,EACtC,EAAE,UAAU,GAAG,GAAG,EAAE,GAAG,OAAO,KAA0B,EAAE;IAE1D,IAA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AAC;QACD,WAAW;YACT,OAAO,oBAAK,CAAC,iBAAiB,EAAE,CAAC,QAAQ,CAAC;QAC5C,CAAC;QACD,eAAe;YACb,OAAO,oBAAK,CAAC,iBAAiB,EAAE,CAAC,MAAM,CAAC;QAC1C,CAAC;KACF,CAAC,CAAC;AACL,CAAC;AArDD,oCAqDC","sourcesContent":["/// <reference types=\"../../types/jest\" />\nimport './expect';\n\nimport { render, RenderResult } from '@testing-library/react-native';\nimport path from 'path';\nimport React from 'react';\n\nimport {\n FileStub,\n inMemoryContext,\n requireContext,\n requireContextWithOverrides,\n} from './context-stubs';\nimport { setInitialUrl } from './mocks';\nimport { ExpoRoot } from '../ExpoRoot';\nimport { stateCache } from '../getLinkingConfig';\nimport { store } from '../global-state/router-store';\nimport { RequireContext } from '../types';\n\n// re-export everything\nexport * from '@testing-library/react-native';\n\ntype RenderRouterOptions = Parameters<typeof render>[1] & {\n initialUrl?: any;\n};\n\ntype Result = ReturnType<typeof render> & {\n getPathname(): string;\n getSegments(): string[];\n getSearchParams(): Record<string, string | string[]>;\n};\n\nfunction isOverrideContext(\n context: object\n): context is { appDir: string; overrides: Record<string, FileStub> } {\n return Boolean(typeof context === 'object' && 'appDir' in context);\n}\n\nexport function renderRouter(context?: string, options?: RenderRouterOptions): Result;\nexport function renderRouter(\n context: Record<string, FileStub>,\n options?: RenderRouterOptions\n): Result;\nexport function renderRouter(\n context: { appDir: string; overrides: Record<string, FileStub> },\n options?: RenderRouterOptions\n): Result;\nexport function renderRouter(\n context:\n | string\n | { appDir: string; overrides: Record<string, FileStub> }\n | Record<string, FileStub> = './app',\n { initialUrl = '/', ...options }: RenderRouterOptions = {}\n): Result {\n jest.useFakeTimers();\n\n let ctx: RequireContext;\n\n // Reset the initial URL\n\n setInitialUrl(initialUrl);\n\n // Force the render to be synchronous\n process.env.EXPO_ROUTER_IMPORT_MODE_WEB = 'sync';\n process.env.EXPO_ROUTER_IMPORT_MODE_IOS = 'sync';\n process.env.EXPO_ROUTER_IMPORT_MODE_ANDROID = 'sync';\n\n if (typeof context === 'string') {\n ctx = requireContext(path.resolve(process.cwd(), context));\n } else if (isOverrideContext(context)) {\n ctx = requireContextWithOverrides(context.appDir, context.overrides);\n } else {\n ctx = inMemoryContext(context);\n }\n\n stateCache.clear();\n\n let location: URL | undefined;\n\n if (typeof initialUrl === 'string') {\n location = new URL(initialUrl, 'test://');\n } else if (initialUrl instanceof URL) {\n location = initialUrl;\n }\n\n const result = render(<ExpoRoot context={ctx} location={location} />, {\n ...options,\n });\n\n return Object.assign(result, {\n getPathname(this: RenderResult): string {\n return store.routeInfoSnapshot().pathname;\n },\n getSegments(this: RenderResult): string[] {\n return store.routeInfoSnapshot().segments;\n },\n getSearchParams(this: RenderResult): Record<string, string | string[]> {\n return store.routeInfoSnapshot().params;\n },\n });\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mocks.d.ts","sourceRoot":"","sources":["../../src/testing-library/mocks.ts"],"names":[],"mappings":"AAAA,OAAO,4CAA4C,CAAC;
|
|
1
|
+
{"version":3,"file":"mocks.d.ts","sourceRoot":"","sources":["../../src/testing-library/mocks.ts"],"names":[],"mappings":"AAAA,OAAO,4CAA4C,CAAC;AAkBpD,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,QAE1C"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.setInitialUrl = void 0;
|
|
4
4
|
require("@testing-library/jest-native/extend-expect");
|
|
5
5
|
// include this section and the NativeAnimatedHelper section for mocking react-native-reanimated
|
|
6
6
|
jest.mock('react-native-reanimated', () => {
|
|
@@ -12,9 +12,11 @@ jest.mock('react-native-reanimated', () => {
|
|
|
12
12
|
});
|
|
13
13
|
// Silence the warning: Animated: `useNativeDriver` is not supported because the native animated module is missing
|
|
14
14
|
jest.mock('react-native/Libraries/Animated/NativeAnimatedHelper');
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
let mockInitialUrl = '';
|
|
16
|
+
function setInitialUrl(value) {
|
|
17
|
+
mockInitialUrl = value;
|
|
18
|
+
}
|
|
19
|
+
exports.setInitialUrl = setInitialUrl;
|
|
18
20
|
jest.mock('expo-linking', () => {
|
|
19
21
|
const module = {
|
|
20
22
|
...jest.requireActual('expo-linking'),
|
|
@@ -28,7 +30,7 @@ jest.mock('expo-linking', () => {
|
|
|
28
30
|
return { remove() { } };
|
|
29
31
|
},
|
|
30
32
|
async getInitialURL() {
|
|
31
|
-
return
|
|
33
|
+
return mockInitialUrl;
|
|
32
34
|
},
|
|
33
35
|
};
|
|
34
36
|
return module;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mocks.js","sourceRoot":"","sources":["../../src/testing-library/mocks.ts"],"names":[],"mappings":";;;AAAA,sDAAoD;AAEpD,gGAAgG;AAChG,IAAI,CAAC,IAAI,CAAC,yBAAyB,EAAE,GAAG,EAAE;IACxC,MAAM,UAAU,GAAG,OAAO,CAAC,8BAA8B,CAAC,CAAC;IAE3D,wEAAwE;IACxE,iCAAiC;IACjC,UAAU,CAAC,OAAO,CAAC,IAAI,GAAG,GAAG,EAAE,GAAE,CAAC,CAAC;IAEnC,OAAO,UAAU,CAAC;AACpB,CAAC,CAAC,CAAC;AAEH,kHAAkH;AAClH,IAAI,CAAC,IAAI,CAAC,sDAAsD,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"mocks.js","sourceRoot":"","sources":["../../src/testing-library/mocks.ts"],"names":[],"mappings":";;;AAAA,sDAAoD;AAEpD,gGAAgG;AAChG,IAAI,CAAC,IAAI,CAAC,yBAAyB,EAAE,GAAG,EAAE;IACxC,MAAM,UAAU,GAAG,OAAO,CAAC,8BAA8B,CAAC,CAAC;IAE3D,wEAAwE;IACxE,iCAAiC;IACjC,UAAU,CAAC,OAAO,CAAC,IAAI,GAAG,GAAG,EAAE,GAAE,CAAC,CAAC;IAEnC,OAAO,UAAU,CAAC;AACpB,CAAC,CAAC,CAAC;AAEH,kHAAkH;AAClH,IAAI,CAAC,IAAI,CAAC,sDAAsD,CAAC,CAAC;AAElE,IAAI,cAAc,GAA6B,EAAE,CAAC;AAElD,SAAgB,aAAa,CAAC,KAAa;IACzC,cAAc,GAAG,KAAK,CAAC;AACzB,CAAC;AAFD,sCAEC;AAED,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,GAAG,EAAE;IAC7B,MAAM,MAAM,GAAkC;QAC5C,GAAG,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC;QACrC,SAAS,CAAC,IAAY;YACpB,OAAO,eAAe,GAAG,IAAI,CAAC;QAChC,CAAC;QACD,aAAa;YACX,OAAO,YAAY,CAAC;QACtB,CAAC;QACD,gBAAgB;YACd,OAAO,EAAE,MAAM,KAAI,CAAC,EAAS,CAAC;QAChC,CAAC;QACD,KAAK,CAAC,aAAa;YACjB,OAAO,cAAc,CAAC;QACxB,CAAC;KACF,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC,CAAC","sourcesContent":["import '@testing-library/jest-native/extend-expect';\n\n// include this section and the NativeAnimatedHelper section for mocking react-native-reanimated\njest.mock('react-native-reanimated', () => {\n const Reanimated = require('react-native-reanimated/mock');\n\n // The mock for `call` immediately calls the callback which is incorrect\n // So we override it with a no-op\n Reanimated.default.call = () => {};\n\n return Reanimated;\n});\n\n// Silence the warning: Animated: `useNativeDriver` is not supported because the native animated module is missing\njest.mock('react-native/Libraries/Animated/NativeAnimatedHelper');\n\nlet mockInitialUrl: string | Promise<string> = '';\n\nexport function setInitialUrl(value: string) {\n mockInitialUrl = value;\n}\n\njest.mock('expo-linking', () => {\n const module: typeof import('expo-linking') = {\n ...jest.requireActual('expo-linking'),\n createURL(path: string) {\n return 'yourscheme://' + path;\n },\n resolveScheme() {\n return 'yourscheme';\n },\n addEventListener() {\n return { remove() {} } as any;\n },\n async getInitialURL() {\n return mockInitialUrl;\n },\n };\n\n return module;\n});\n"]}
|
|
@@ -3,16 +3,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
// @ts-
|
|
6
|
+
// @ts-ignore: types node
|
|
7
7
|
const node_fs_1 = __importDefault(require("node:fs"));
|
|
8
|
-
// @ts-
|
|
8
|
+
// @ts-ignore: types node
|
|
9
9
|
const node_path_1 = __importDefault(require("node:path"));
|
|
10
10
|
function requireContext(base = '.', scanSubDirectories = true, regularExpression = /\.[tj]sx?$/) {
|
|
11
11
|
const files = {};
|
|
12
12
|
function readDirectory(directory) {
|
|
13
13
|
node_fs_1.default.readdirSync(directory).forEach((file) => {
|
|
14
14
|
const fullPath = node_path_1.default.resolve(directory, file);
|
|
15
|
-
const relativePath = `./${node_path_1.default.relative(base, fullPath)}`;
|
|
15
|
+
const relativePath = `./${node_path_1.default.relative(base, fullPath).split(node_path_1.default.sep).join('/')}`;
|
|
16
16
|
if (node_fs_1.default.statSync(fullPath).isDirectory()) {
|
|
17
17
|
if (scanSubDirectories)
|
|
18
18
|
readDirectory(fullPath);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"require-context-ponyfill.js","sourceRoot":"","sources":["../../src/testing-library/require-context-ponyfill.ts"],"names":[],"mappings":";;;;;AAAA
|
|
1
|
+
{"version":3,"file":"require-context-ponyfill.js","sourceRoot":"","sources":["../../src/testing-library/require-context-ponyfill.ts"],"names":[],"mappings":";;;;;AAAA,yBAAyB;AACzB,sDAAyB;AACzB,yBAAyB;AACzB,0DAA6B;AAI7B,SAAwB,cAAc,CACpC,IAAI,GAAG,GAAG,EACV,kBAAkB,GAAG,IAAI,EACzB,iBAAiB,GAAG,YAAY;IAEhC,MAAM,KAAK,GAA4B,EAAE,CAAC;IAE1C,SAAS,aAAa,CAAC,SAAiB;QACtC,iBAAE,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,CAAC,IAAY,EAAE,EAAE;YACjD,MAAM,QAAQ,GAAG,mBAAI,CAAC,OAAO,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;YAC/C,MAAM,YAAY,GAAG,KAAK,mBAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,KAAK,CAAC,mBAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;YAEpF,IAAI,iBAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,WAAW,EAAE,EAAE;gBACvC,IAAI,kBAAkB;oBAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;gBAEhD,OAAO;aACR;YAED,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC;gBAAE,OAAO;YAE9C,KAAK,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC;QAC7B,CAAC,CAAC,CAAC;IACL,CAAC;IAED,aAAa,CAAC,IAAI,CAAC,CAAC;IAEpB,MAAM,OAAO,GAAmB,MAAM,CAAC,MAAM,CAC3C,SAAS,MAAM,CAAC,IAAY;QAC1B,OAAO,OAAO,CAAC,mBAAI,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;IACxC,CAAC,EACD;QACE,IAAI,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC;QAC9B,OAAO,EAAE,CAAC,GAAW,EAAE,EAAE,CAAC,GAAG;QAC7B,EAAE,EAAE,GAAG;KACR,CACF,CAAC;IAEF,OAAO,OAAO,CAAC;AACjB,CAAC;AAtCD,iCAsCC","sourcesContent":["// @ts-ignore: types node\nimport fs from 'node:fs';\n// @ts-ignore: types node\nimport path from 'node:path';\n\nimport { RequireContext } from '../types';\n\nexport default function requireContext(\n base = '.',\n scanSubDirectories = true,\n regularExpression = /\\.[tj]sx?$/\n) {\n const files: Record<string, unknown> = {};\n\n function readDirectory(directory: string) {\n fs.readdirSync(directory).forEach((file: string) => {\n const fullPath = path.resolve(directory, file);\n const relativePath = `./${path.relative(base, fullPath).split(path.sep).join('/')}`;\n\n if (fs.statSync(fullPath).isDirectory()) {\n if (scanSubDirectories) readDirectory(fullPath);\n\n return;\n }\n\n if (!regularExpression.test(fullPath)) return;\n\n files[relativePath] = true;\n });\n }\n\n readDirectory(base);\n\n const context: RequireContext = Object.assign(\n function Module(file: string) {\n return require(path.join(base, file));\n },\n {\n keys: () => Object.keys(files),\n resolve: (key: string) => key,\n id: '0',\n }\n );\n\n return context;\n}\n"]}
|
package/build/useScreens.js
CHANGED
|
@@ -70,7 +70,7 @@ function fromImport({ ErrorBoundary, ...component }) {
|
|
|
70
70
|
...props,
|
|
71
71
|
ref,
|
|
72
72
|
});
|
|
73
|
-
return
|
|
73
|
+
return <Try_1.Try catch={ErrorBoundary}>{children}</Try_1.Try>;
|
|
74
74
|
}),
|
|
75
75
|
};
|
|
76
76
|
}
|
|
@@ -104,24 +104,29 @@ function getQualifiedRouteComponent(value) {
|
|
|
104
104
|
const res = value.loadRoute();
|
|
105
105
|
return fromLoadedRoute(res);
|
|
106
106
|
});
|
|
107
|
-
getLoadable = (props, ref) => (react_1.default.
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
107
|
+
getLoadable = (props, ref) => (<react_1.default.Suspense fallback={<SuspenseFallback_1.SuspenseFallback route={value}/>}>
|
|
108
|
+
<AsyncComponent {...{
|
|
109
|
+
...props,
|
|
110
|
+
ref,
|
|
111
|
+
// Expose the template segment path, e.g. `(home)`, `[foo]`, `index`
|
|
112
|
+
// the intention is to make it possible to deduce shared routes.
|
|
113
|
+
segment: value.route,
|
|
114
|
+
}}/>
|
|
115
|
+
</react_1.default.Suspense>);
|
|
113
116
|
}
|
|
114
117
|
else {
|
|
115
118
|
const res = value.loadRoute();
|
|
116
119
|
const Component = fromImport(res).default;
|
|
117
120
|
const SyncComponent = react_1.default.forwardRef((props, ref) => {
|
|
118
|
-
return
|
|
121
|
+
return <Component {...props} ref={ref}/>;
|
|
119
122
|
});
|
|
120
|
-
getLoadable = (props, ref) => (
|
|
123
|
+
getLoadable = (props, ref) => (<SyncComponent {...{
|
|
124
|
+
...props,
|
|
121
125
|
ref,
|
|
122
126
|
// Expose the template segment path, e.g. `(home)`, `[foo]`, `index`
|
|
123
127
|
// the intention is to make it possible to deduce shared routes.
|
|
124
|
-
segment: value.route
|
|
128
|
+
segment: value.route,
|
|
129
|
+
}}/>);
|
|
125
130
|
}
|
|
126
131
|
const QualifiedRoute = react_1.default.forwardRef(({
|
|
127
132
|
// Remove these React Navigation props to
|
|
@@ -130,7 +135,7 @@ function getQualifiedRouteComponent(value) {
|
|
|
130
135
|
// Pass all other props to the component
|
|
131
136
|
...props }, ref) => {
|
|
132
137
|
const loadable = getLoadable(props, ref);
|
|
133
|
-
return
|
|
138
|
+
return <Route_1.Route node={value}>{loadable}</Route_1.Route>;
|
|
134
139
|
});
|
|
135
140
|
QualifiedRoute.displayName = `Route(${value.route})`;
|
|
136
141
|
qualifiedStore.set(value, QualifiedRoute);
|
|
@@ -167,11 +172,9 @@ function createGetIdForRoute(route) {
|
|
|
167
172
|
}
|
|
168
173
|
exports.createGetIdForRoute = createGetIdForRoute;
|
|
169
174
|
function routeToScreen(route, { options, ...props } = {}) {
|
|
170
|
-
return (
|
|
175
|
+
return (<primitives_1.Screen
|
|
171
176
|
// Users can override the screen getId function.
|
|
172
|
-
|
|
173
|
-
// Users can override the screen getId function.
|
|
174
|
-
getId: createGetIdForRoute(route), ...props, name: route.route, key: route.route, options: (args) => {
|
|
177
|
+
getId={createGetIdForRoute(route)} {...props} name={route.route} key={route.route} options={(args) => {
|
|
175
178
|
// Only eager load generated components
|
|
176
179
|
const staticOptions = route.generated ? route.loadRoute()?.getNavOptions : null;
|
|
177
180
|
const staticResult = typeof staticOptions === 'function' ? staticOptions(args) : staticOptions;
|
|
@@ -187,6 +190,6 @@ function routeToScreen(route, { options, ...props } = {}) {
|
|
|
187
190
|
output.drawerItemStyle = { height: 0, display: 'none' };
|
|
188
191
|
}
|
|
189
192
|
return output;
|
|
190
|
-
}
|
|
193
|
+
}} getComponent={() => getQualifiedRouteComponent(route)}/>);
|
|
191
194
|
}
|
|
192
195
|
//# sourceMappingURL=useScreens.js.map
|
package/build/useScreens.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useScreens.js","sourceRoot":"","sources":["../src/useScreens.tsx"],"names":[],"mappings":";;;;;;AAOA,kDAA0B;AAE1B,mCAOiB;AACjB,gEAAoD;AACpD,6CAAsC;AACtC,mDAAgD;AAChD,+DAA4D;AAC5D,qCAAkC;AA2BlC,SAAS,iBAAiB,CACxB,QAAqB,EACrB,KAAqB,EACrB,gBAAyB;IAEzB,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE;QAClB,OAAO,QAAQ;aACZ,IAAI,CAAC,IAAA,6BAAqB,EAAC,gBAAgB,CAAC,CAAC;aAC7C,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;KAC3C;IACD,MAAM,OAAO,GAAG,CAAC,GAAG,QAAQ,CAAC,CAAC;IAE9B,MAAM,OAAO,GAAG,KAAK;SAClB,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,aAAa,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE;QACpE,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;YACnB,OAAO,CAAC,IAAI,CAAC,uDAAuD,IAAI,kBAAkB,CAAC,CAAC;YAC5F,OAAO,IAAI,CAAC;SACb;QACD,MAAM,UAAU,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,KAAK,IAAI,C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C,IAAI,CAAC;gBACjC,qFAAqF;gBACrF,MAAM,CAAC,eAAe,GAAG,EAAE,MAAM,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;aACzD;YAED,OAAO,MAAM,CAAC;QAChB,CAAC,EACD,YAAY,EAAE,GAAG,EAAE,CAAC,0BAA0B,CAAC,KAAK,CAAC,GACrD,CACH,CAAC;AACJ,CAAC","sourcesContent":["import type {\n EventMapBase,\n NavigationState,\n ParamListBase,\n RouteProp,\n ScreenListeners,\n} from '@react-navigation/native';\nimport React from 'react';\n\nimport {\n DynamicConvention,\n LoadedRoute,\n Route,\n RouteNode,\n sortRoutesWithInitial,\n useRouteNode,\n} from './Route';\nimport EXPO_ROUTER_IMPORT_MODE from './import-mode';\nimport { Screen } from './primitives';\nimport { EmptyRoute } from './views/EmptyRoute';\nimport { SuspenseFallback } from './views/SuspenseFallback';\nimport { Try } from './views/Try';\n\nexport type ScreenProps<\n TOptions extends Record<string, any> = Record<string, any>,\n State extends NavigationState = NavigationState,\n EventMap extends EventMapBase = EventMapBase,\n> = {\n /** Name is required when used inside a Layout component. */\n name?: string;\n /**\n * Redirect to the nearest sibling route.\n * If all children are redirect={true}, the layout will render `null` as there are no children to render.\n */\n redirect?: boolean;\n initialParams?: { [key: string]: any };\n options?: TOptions;\n\n listeners?:\n | ScreenListeners<State, EventMap>\n | ((prop: {\n route: RouteProp<ParamListBase, string>;\n navigation: any;\n }) => ScreenListeners<State, EventMap>);\n\n getId?: ({ params }: { params?: Record<string, any> | undefined }) => string | undefined;\n};\n\nfunction getSortedChildren(\n children: RouteNode[],\n order?: ScreenProps[],\n initialRouteName?: string\n): { route: RouteNode; props: Partial<ScreenProps> }[] {\n if (!order?.length) {\n return children\n .sort(sortRoutesWithInitial(initialRouteName))\n .map((route) => ({ route, props: {} }));\n }\n const entries = [...children];\n\n const ordered = order\n .map(({ name, redirect, initialParams, listeners, options, getId }) => {\n if (!entries.length) {\n console.warn(`[Layout children]: Too many screens defined. Route \"${name}\" is extraneous.`);\n return null;\n }\n const matchIndex = entries.findIndex((child) => child.route === name);\n if (matchIndex === -1) {\n console.warn(\n `[Layout children]: No route named \"${name}\" exists in nested children:`,\n children.map(({ route }) => route)\n );\n return null;\n } else {\n // Get match and remove from entries\n const match = entries[matchIndex];\n entries.splice(matchIndex, 1);\n\n // Ensure to return null after removing from entries.\n if (redirect) {\n if (typeof redirect === 'string') {\n throw new Error(`Redirecting to a specific route is not supported yet.`);\n }\n return null;\n }\n\n return {\n route: match,\n props: { initialParams, listeners, options, getId },\n };\n }\n })\n .filter(Boolean) as {\n route: RouteNode;\n props: Partial<ScreenProps>;\n }[];\n\n // Add any remaining children\n ordered.push(\n ...entries.sort(sortRoutesWithInitial(initialRouteName)).map((route) => ({ route, props: {} }))\n );\n\n return ordered;\n}\n\n/**\n * @returns React Navigation screens sorted by the `route` property.\n */\nexport function useSortedScreens(order: ScreenProps[]): React.ReactNode[] {\n const node = useRouteNode();\n\n const sorted = node?.children?.length\n ? getSortedChildren(node.children, order, node.initialRouteName)\n : [];\n return React.useMemo(\n () => sorted.map((value) => routeToScreen(value.route, value.props)),\n [sorted]\n );\n}\n\nfunction fromImport({ ErrorBoundary, ...component }: LoadedRoute) {\n if (ErrorBoundary) {\n return {\n default: React.forwardRef((props: any, ref: any) => {\n const children = React.createElement(component.default || EmptyRoute, {\n ...props,\n ref,\n });\n return <Try catch={ErrorBoundary}>{children}</Try>;\n }),\n };\n }\n if (process.env.NODE_ENV !== 'production') {\n if (\n typeof component.default === 'object' &&\n component.default &&\n Object.keys(component.default).length === 0\n ) {\n return { default: EmptyRoute };\n }\n }\n return { default: component.default || EmptyRoute };\n}\n\nfunction fromLoadedRoute(res: LoadedRoute) {\n if (!(res instanceof Promise)) {\n return fromImport(res);\n }\n\n return res.then(fromImport);\n}\n\n// TODO: Maybe there's a more React-y way to do this?\n// Without this store, the process enters a recursive loop.\nconst qualifiedStore = new WeakMap<RouteNode, React.ComponentType<any>>();\n\n/** Wrap the component with various enhancements and add access to child routes. */\nexport function getQualifiedRouteComponent(value: RouteNode) {\n if (qualifiedStore.has(value)) {\n return qualifiedStore.get(value)!;\n }\n\n let getLoadable: (props: any, ref: any) => JSX.Element;\n\n // TODO: This ensures sync doesn't use React.lazy, but it's not ideal.\n if (EXPO_ROUTER_IMPORT_MODE === 'lazy') {\n const AsyncComponent = React.lazy(async () => {\n const res = value.loadRoute();\n return fromLoadedRoute(res) as Promise<{\n default: React.ComponentType<any>;\n }>;\n });\n getLoadable = (props: any, ref: any) => (\n <React.Suspense fallback={<SuspenseFallback route={value} />}>\n <AsyncComponent\n {...{\n ...props,\n ref,\n // Expose the template segment path, e.g. `(home)`, `[foo]`, `index`\n // the intention is to make it possible to deduce shared routes.\n segment: value.route,\n }}\n />\n </React.Suspense>\n );\n } else {\n const res = value.loadRoute();\n const Component = fromImport(res).default;\n const SyncComponent = React.forwardRef((props, ref) => {\n return <Component {...props} ref={ref} />;\n });\n\n getLoadable = (props: any, ref: any) => (\n <SyncComponent\n {...{\n ...props,\n ref,\n // Expose the template segment path, e.g. `(home)`, `[foo]`, `index`\n // the intention is to make it possible to deduce shared routes.\n segment: value.route,\n }}\n />\n );\n }\n\n const QualifiedRoute = React.forwardRef(\n (\n {\n // Remove these React Navigation props to\n // enforce usage of expo-router hooks (where the query params are correct).\n route,\n navigation,\n\n // Pass all other props to the component\n ...props\n }: any,\n ref: any\n ) => {\n const loadable = getLoadable(props, ref);\n\n return <Route node={value}>{loadable}</Route>;\n }\n );\n\n QualifiedRoute.displayName = `Route(${value.route})`;\n\n qualifiedStore.set(value, QualifiedRoute);\n return QualifiedRoute;\n}\n\n/** @returns a function which provides a screen id that matches the dynamic route name in params. */\nexport function createGetIdForRoute(route: Pick<RouteNode, 'dynamic' | 'route'>) {\n if (!route.dynamic?.length) {\n return undefined;\n }\n return ({ params }: { params?: Record<string, any> }) => {\n const getPreferredId = (segment: DynamicConvention) => {\n // Params can be undefined when there are no params in the route.\n const preferredId = params?.[segment.name];\n // If the route has a dynamic segment, use the matching parameter\n // as the screen id. This enables pushing a screen like `/[user]` multiple times\n // when the user is different.\n if (preferredId) {\n if (!Array.isArray(preferredId)) {\n return preferredId;\n } else if (preferredId.length) {\n // Deep dynamic routes will return as an array, so we'll join them to create a\n // fully qualified string.\n return preferredId.join('/');\n }\n // Empty arrays...\n }\n return segment.deep ? `[...${segment.name}]` : `[${segment.name}]`;\n };\n return route.dynamic?.map((segment) => getPreferredId(segment)).join('/');\n };\n}\n\nfunction routeToScreen(route: RouteNode, { options, ...props }: Partial<ScreenProps> = {}) {\n return (\n <Screen\n // Users can override the screen getId function.\n getId={createGetIdForRoute(route)}\n {...props}\n name={route.route}\n key={route.route}\n options={(args) => {\n // Only eager load generated components\n const staticOptions = route.generated ? route.loadRoute()?.getNavOptions : null;\n const staticResult =\n typeof staticOptions === 'function' ? staticOptions(args) : staticOptions;\n const dynamicResult = typeof options === 'function' ? options?.(args) : options;\n const output = {\n ...staticResult,\n ...dynamicResult,\n };\n\n // Prevent generated screens from showing up in the tab bar.\n if (route.generated) {\n output.tabBarButton = () => null;\n // TODO: React Navigation doesn't provide a way to prevent rendering the drawer item.\n output.drawerItemStyle = { height: 0, display: 'none' };\n }\n\n return output;\n }}\n getComponent={() => getQualifiedRouteComponent(route)}\n />\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"useScreens.js","sourceRoot":"","sources":["../src/useScreens.tsx"],"names":[],"mappings":";;;;;;AAOA,kDAA0B;AAE1B,mCAOiB;AACjB,gEAAoD;AACpD,6CAAsC;AACtC,mDAAgD;AAChD,+DAA4D;AAC5D,qCAAkC;AA2BlC,SAAS,iBAAiB,CACxB,QAAqB,EACrB,KAAqB,EACrB,gBAAyB;IAEzB,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE;QAClB,OAAO,QAAQ;aACZ,IAAI,CAAC,IAAA,6BAAqB,EAAC,gBAAgB,CAAC,CAAC;aAC7C,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,C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,KAAK,CAAC,CAAC,CAClC,IAAI,KAAK,CAAC,CACV,IAAI,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAClB,GAAG,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CACjB,OAAO,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE;YAChB,uCAAuC;YACvC,MAAM,aAAa,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS,EAAE,EAAE,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC;YAChF,MAAM,YAAY,GAChB,OAAO,aAAa,KAAK,UAAU,CAAC,CAAC,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC;YAC5E,MAAM,aAAa,GAAG,OAAO,OAAO,KAAK,UAAU,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;YAChF,MAAM,MAAM,GAAG;gBACb,GAAG,YAAY;gBACf,GAAG,aAAa;aACjB,CAAC;YAEF,4DAA4D;YAC5D,IAAI,KAAK,CAAC,SAAS,EAAE;gBACnB,MAAM,CAAC,YAAY,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC;gBACjC,qFAAqF;gBACrF,MAAM,CAAC,eAAe,GAAG,EAAE,MAAM,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;aACzD;YAED,OAAO,MAAM,CAAC;QAChB,CAAC,CAAC,CACF,YAAY,CAAC,CAAC,GAAG,EAAE,CAAC,0BAA0B,CAAC,KAAK,CAAC,CAAC,EACtD,CACH,CAAC;AACJ,CAAC","sourcesContent":["import type {\n EventMapBase,\n NavigationState,\n ParamListBase,\n RouteProp,\n ScreenListeners,\n} from '@react-navigation/native';\nimport React from 'react';\n\nimport {\n DynamicConvention,\n LoadedRoute,\n Route,\n RouteNode,\n sortRoutesWithInitial,\n useRouteNode,\n} from './Route';\nimport EXPO_ROUTER_IMPORT_MODE from './import-mode';\nimport { Screen } from './primitives';\nimport { EmptyRoute } from './views/EmptyRoute';\nimport { SuspenseFallback } from './views/SuspenseFallback';\nimport { Try } from './views/Try';\n\nexport type ScreenProps<\n TOptions extends Record<string, any> = Record<string, any>,\n State extends NavigationState = NavigationState,\n EventMap extends EventMapBase = EventMapBase,\n> = {\n /** Name is required when used inside a Layout component. */\n name?: string;\n /**\n * Redirect to the nearest sibling route.\n * If all children are redirect={true}, the layout will render `null` as there are no children to render.\n */\n redirect?: boolean;\n initialParams?: { [key: string]: any };\n options?: TOptions;\n\n listeners?:\n | ScreenListeners<State, EventMap>\n | ((prop: {\n route: RouteProp<ParamListBase, string>;\n navigation: any;\n }) => ScreenListeners<State, EventMap>);\n\n getId?: ({ params }: { params?: Record<string, any> | undefined }) => string | undefined;\n};\n\nfunction getSortedChildren(\n children: RouteNode[],\n order?: ScreenProps[],\n initialRouteName?: string\n): { route: RouteNode; props: Partial<ScreenProps> }[] {\n if (!order?.length) {\n return children\n .sort(sortRoutesWithInitial(initialRouteName))\n .map((route) => ({ route, props: {} }));\n }\n const entries = [...children];\n\n const ordered = order\n .map(({ name, redirect, initialParams, listeners, options, getId }) => {\n if (!entries.length) {\n console.warn(`[Layout children]: Too many screens defined. Route \"${name}\" is extraneous.`);\n return null;\n }\n const matchIndex = entries.findIndex((child) => child.route === name);\n if (matchIndex === -1) {\n console.warn(\n `[Layout children]: No route named \"${name}\" exists in nested children:`,\n children.map(({ route }) => route)\n );\n return null;\n } else {\n // Get match and remove from entries\n const match = entries[matchIndex];\n entries.splice(matchIndex, 1);\n\n // Ensure to return null after removing from entries.\n if (redirect) {\n if (typeof redirect === 'string') {\n throw new Error(`Redirecting to a specific route is not supported yet.`);\n }\n return null;\n }\n\n return {\n route: match,\n props: { initialParams, listeners, options, getId },\n };\n }\n })\n .filter(Boolean) as {\n route: RouteNode;\n props: Partial<ScreenProps>;\n }[];\n\n // Add any remaining children\n ordered.push(\n ...entries.sort(sortRoutesWithInitial(initialRouteName)).map((route) => ({ route, props: {} }))\n );\n\n return ordered;\n}\n\n/**\n * @returns React Navigation screens sorted by the `route` property.\n */\nexport function useSortedScreens(order: ScreenProps[]): React.ReactNode[] {\n const node = useRouteNode();\n\n const sorted = node?.children?.length\n ? getSortedChildren(node.children, order, node.initialRouteName)\n : [];\n return React.useMemo(\n () => sorted.map((value) => routeToScreen(value.route, value.props)),\n [sorted]\n );\n}\n\nfunction fromImport({ ErrorBoundary, ...component }: LoadedRoute) {\n if (ErrorBoundary) {\n return {\n default: React.forwardRef((props: any, ref: any) => {\n const children = React.createElement(component.default || EmptyRoute, {\n ...props,\n ref,\n });\n return <Try catch={ErrorBoundary}>{children}</Try>;\n }),\n };\n }\n if (process.env.NODE_ENV !== 'production') {\n if (\n typeof component.default === 'object' &&\n component.default &&\n Object.keys(component.default).length === 0\n ) {\n return { default: EmptyRoute };\n }\n }\n return { default: component.default || EmptyRoute };\n}\n\nfunction fromLoadedRoute(res: LoadedRoute) {\n if (!(res instanceof Promise)) {\n return fromImport(res);\n }\n\n return res.then(fromImport);\n}\n\n// TODO: Maybe there's a more React-y way to do this?\n// Without this store, the process enters a recursive loop.\nconst qualifiedStore = new WeakMap<RouteNode, React.ComponentType<any>>();\n\n/** Wrap the component with various enhancements and add access to child routes. */\nexport function getQualifiedRouteComponent(value: RouteNode) {\n if (qualifiedStore.has(value)) {\n return qualifiedStore.get(value)!;\n }\n\n let getLoadable: (props: any, ref: any) => JSX.Element;\n\n // TODO: This ensures sync doesn't use React.lazy, but it's not ideal.\n if (EXPO_ROUTER_IMPORT_MODE === 'lazy') {\n const AsyncComponent = React.lazy(async () => {\n const res = value.loadRoute();\n return fromLoadedRoute(res) as Promise<{\n default: React.ComponentType<any>;\n }>;\n });\n getLoadable = (props: any, ref: any) => (\n <React.Suspense fallback={<SuspenseFallback route={value} />}>\n <AsyncComponent\n {...{\n ...props,\n ref,\n // Expose the template segment path, e.g. `(home)`, `[foo]`, `index`\n // the intention is to make it possible to deduce shared routes.\n segment: value.route,\n }}\n />\n </React.Suspense>\n );\n } else {\n const res = value.loadRoute();\n const Component = fromImport(res).default;\n const SyncComponent = React.forwardRef((props, ref) => {\n return <Component {...props} ref={ref} />;\n });\n\n getLoadable = (props: any, ref: any) => (\n <SyncComponent\n {...{\n ...props,\n ref,\n // Expose the template segment path, e.g. `(home)`, `[foo]`, `index`\n // the intention is to make it possible to deduce shared routes.\n segment: value.route,\n }}\n />\n );\n }\n\n const QualifiedRoute = React.forwardRef(\n (\n {\n // Remove these React Navigation props to\n // enforce usage of expo-router hooks (where the query params are correct).\n route,\n navigation,\n\n // Pass all other props to the component\n ...props\n }: any,\n ref: any\n ) => {\n const loadable = getLoadable(props, ref);\n\n return <Route node={value}>{loadable}</Route>;\n }\n );\n\n QualifiedRoute.displayName = `Route(${value.route})`;\n\n qualifiedStore.set(value, QualifiedRoute);\n return QualifiedRoute;\n}\n\n/** @returns a function which provides a screen id that matches the dynamic route name in params. */\nexport function createGetIdForRoute(route: Pick<RouteNode, 'dynamic' | 'route'>) {\n if (!route.dynamic?.length) {\n return undefined;\n }\n return ({ params }: { params?: Record<string, any> }) => {\n const getPreferredId = (segment: DynamicConvention) => {\n // Params can be undefined when there are no params in the route.\n const preferredId = params?.[segment.name];\n // If the route has a dynamic segment, use the matching parameter\n // as the screen id. This enables pushing a screen like `/[user]` multiple times\n // when the user is different.\n if (preferredId) {\n if (!Array.isArray(preferredId)) {\n return preferredId;\n } else if (preferredId.length) {\n // Deep dynamic routes will return as an array, so we'll join them to create a\n // fully qualified string.\n return preferredId.join('/');\n }\n // Empty arrays...\n }\n return segment.deep ? `[...${segment.name}]` : `[${segment.name}]`;\n };\n return route.dynamic?.map((segment) => getPreferredId(segment)).join('/');\n };\n}\n\nfunction routeToScreen(route: RouteNode, { options, ...props }: Partial<ScreenProps> = {}) {\n return (\n <Screen\n // Users can override the screen getId function.\n getId={createGetIdForRoute(route)}\n {...props}\n name={route.route}\n key={route.route}\n options={(args) => {\n // Only eager load generated components\n const staticOptions = route.generated ? route.loadRoute()?.getNavOptions : null;\n const staticResult =\n typeof staticOptions === 'function' ? staticOptions(args) : staticOptions;\n const dynamicResult = typeof options === 'function' ? options?.(args) : options;\n const output = {\n ...staticResult,\n ...dynamicResult,\n };\n\n // Prevent generated screens from showing up in the tab bar.\n if (route.generated) {\n output.tabBarButton = () => null;\n // TODO: React Navigation doesn't provide a way to prevent rendering the drawer item.\n output.drawerItemStyle = { height: 0, display: 'none' };\n }\n\n return output;\n }}\n getComponent={() => getQualifiedRouteComponent(route)}\n />\n );\n}\n"]}
|