expo-router 3.1.2 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/_ctx.android.js +1 -1
- package/_ctx.ios.js +1 -1
- package/_ctx.web.js +1 -1
- package/babel.js +1 -209
- package/build/ExpoRoot.d.ts.map +1 -1
- package/build/ExpoRoot.js +57 -15
- package/build/ExpoRoot.js.map +1 -1
- package/build/LocationProvider.d.ts +3 -2
- package/build/LocationProvider.d.ts.map +1 -1
- package/build/LocationProvider.js +31 -7
- package/build/LocationProvider.js.map +1 -1
- package/build/Route.d.ts +3 -0
- package/build/Route.d.ts.map +1 -1
- package/build/Route.js +1 -1
- package/build/Route.js.map +1 -1
- package/build/fork/NavigationContainer.native.js +5 -3
- package/build/fork/NavigationContainer.native.js.map +1 -1
- package/build/fork/extractPathFromURL.d.ts.map +1 -1
- package/build/fork/extractPathFromURL.js +17 -16
- package/build/fork/extractPathFromURL.js.map +1 -1
- package/build/fork/getPathFromState.d.ts +1 -1
- package/build/fork/getPathFromState.d.ts.map +1 -1
- package/build/fork/getPathFromState.js +17 -38
- package/build/fork/getPathFromState.js.map +1 -1
- package/build/fork/getStateFromPath.d.ts +2 -2
- package/build/fork/getStateFromPath.d.ts.map +1 -1
- package/build/fork/getStateFromPath.js +71 -52
- package/build/fork/getStateFromPath.js.map +1 -1
- package/build/getDevServer/index.d.ts +0 -3
- package/build/getDevServer/index.d.ts.map +1 -1
- package/build/getDevServer/index.js +1 -28
- package/build/getDevServer/index.js.map +1 -1
- package/build/getReactNavigationConfig.d.ts.map +1 -1
- package/build/getReactNavigationConfig.js +3 -0
- package/build/getReactNavigationConfig.js.map +1 -1
- package/build/getRoutes.d.ts +8 -5
- package/build/getRoutes.d.ts.map +1 -1
- package/build/getRoutes.js +150 -67
- package/build/getRoutes.js.map +1 -1
- package/build/getServerManifest.d.ts +14 -33
- package/build/getServerManifest.d.ts.map +1 -1
- package/build/getServerManifest.js +6 -5
- package/build/getServerManifest.js.map +1 -1
- package/build/global-state/router-store.d.ts.map +1 -1
- package/build/global-state/router-store.js +29 -3
- package/build/global-state/router-store.js.map +1 -1
- package/build/global-state/routing.d.ts +0 -4
- package/build/global-state/routing.d.ts.map +1 -1
- package/build/global-state/routing.js +76 -96
- package/build/global-state/routing.js.map +1 -1
- package/build/head/ExpoHead.ios.js +4 -4
- package/build/head/ExpoHead.ios.js.map +1 -1
- package/build/head/ExpoHead.js +1 -1
- package/build/head/ExpoHead.js.map +1 -1
- package/build/head/url.d.ts.map +1 -1
- package/build/head/url.js +5 -6
- package/build/head/url.js.map +1 -1
- package/build/hooks.d.ts.map +1 -1
- package/build/hooks.js +24 -5
- package/build/hooks.js.map +1 -1
- package/build/import-mode/index.d.ts +1 -1
- package/build/import-mode/index.d.ts.map +1 -1
- package/build/import-mode/index.js +1 -1
- package/build/import-mode/index.js.map +1 -1
- package/build/layouts/Tabs.js +2 -2
- package/build/layouts/Tabs.js.map +1 -1
- package/build/layouts/withLayoutContext.js +1 -1
- package/build/layouts/withLayoutContext.js.map +1 -1
- package/build/link/Link.d.ts +54 -1
- package/build/link/Link.d.ts.map +1 -1
- package/build/link/Link.js +54 -12
- package/build/link/Link.js.map +1 -1
- package/build/link/useLinkToPathProps.js +2 -2
- package/build/link/useLinkToPathProps.js.map +1 -1
- package/build/loadStaticParamsAsync.d.ts +1 -0
- package/build/loadStaticParamsAsync.d.ts.map +1 -1
- package/build/loadStaticParamsAsync.js +107 -72
- package/build/loadStaticParamsAsync.js.map +1 -1
- package/build/matchers.js +1 -1
- package/build/matchers.js.map +1 -1
- package/build/onboard/Tutorial.js +41 -34
- package/build/onboard/Tutorial.js.map +1 -1
- package/build/qualified-entry.d.ts.map +1 -1
- package/build/qualified-entry.js +10 -7
- package/build/qualified-entry.js.map +1 -1
- package/build/renderRootComponent.d.ts.map +1 -1
- package/build/renderRootComponent.js +28 -4
- package/build/renderRootComponent.js.map +1 -1
- package/build/routes-manifest.d.ts +1 -0
- package/build/routes-manifest.d.ts.map +1 -1
- package/build/routes-manifest.js +1 -0
- package/build/routes-manifest.js.map +1 -1
- package/build/sortRoutes.d.ts.map +1 -1
- package/build/sortRoutes.js +21 -2
- package/build/sortRoutes.js.map +1 -1
- package/build/static/html.d.ts.map +1 -1
- package/build/static/html.js +12 -10
- package/build/static/html.js.map +1 -1
- package/build/static/renderStaticContent.d.ts +13 -3
- package/build/static/renderStaticContent.d.ts.map +1 -1
- package/build/static/renderStaticContent.js +35 -11
- package/build/static/renderStaticContent.js.map +1 -1
- package/build/testing-library/index.js +3 -5
- package/build/testing-library/index.js.map +1 -1
- package/build/testing-library/mocks.d.ts +1 -3
- package/build/testing-library/mocks.d.ts.map +1 -1
- package/build/testing-library/mocks.js +17 -10
- package/build/testing-library/mocks.js.map +1 -1
- package/build/testing-library/require-context-ponyfill.js +3 -3
- package/build/testing-library/require-context-ponyfill.js.map +1 -1
- package/build/useScreens.d.ts.map +1 -1
- package/build/useScreens.js +19 -23
- package/build/useScreens.js.map +1 -1
- package/build/utils/url.d.ts +2 -0
- package/build/utils/url.d.ts.map +1 -1
- package/build/utils/url.js +13 -1
- package/build/utils/url.js.map +1 -1
- package/build/views/EmptyRoute.js +5 -2
- package/build/views/EmptyRoute.js.map +1 -1
- package/build/views/ErrorBoundary.js +50 -31
- package/build/views/ErrorBoundary.js.map +1 -1
- package/build/views/Navigator.js +16 -10
- package/build/views/Navigator.js.map +1 -1
- package/build/views/Sitemap.js +54 -36
- package/build/views/Sitemap.js.map +1 -1
- package/build/views/Splash.d.ts +1 -27
- package/build/views/Splash.d.ts.map +1 -1
- package/build/views/Splash.js +2 -112
- package/build/views/Splash.js.map +1 -1
- package/build/views/SuspenseFallback.d.ts +1 -1
- package/build/views/SuspenseFallback.d.ts.map +1 -1
- package/build/views/SuspenseFallback.js +7 -2
- package/build/views/SuspenseFallback.js.map +1 -1
- package/build/views/Toast.js +23 -18
- package/build/views/Toast.js.map +1 -1
- package/build/views/Try.js +1 -1
- package/build/views/Try.js.map +1 -1
- package/build/views/Unmatched.js +29 -17
- package/build/views/Unmatched.js.map +1 -1
- package/html.d.ts +1 -0
- package/ios/ExpoHead.podspec +1 -1
- package/ios/ExpoHeadModule.swift +0 -2
- package/package.json +11 -19
- package/plugin/build/index.d.ts +2 -2
- package/plugin/options.json +3 -3
- package/build/fork/react-native-web-container.d.ts +0 -8
- package/build/fork/react-native-web-container.d.ts.map +0 -1
- package/build/fork/react-native-web-container.js +0 -8
- package/build/fork/react-native-web-container.js.map +0 -1
- package/build/import-mode/index.android.d.ts +0 -3
- package/build/import-mode/index.android.d.ts.map +0 -1
- package/build/import-mode/index.android.js +0 -4
- package/build/import-mode/index.android.js.map +0 -1
- package/build/import-mode/index.ios.d.ts +0 -3
- package/build/import-mode/index.ios.d.ts.map +0 -1
- package/build/import-mode/index.ios.js +0 -4
- package/build/import-mode/index.ios.js.map +0 -1
- package/build/import-mode/index.web.d.ts +0 -3
- package/build/import-mode/index.web.d.ts.map +0 -1
- package/build/import-mode/index.web.js +0 -4
- package/build/import-mode/index.web.js.map +0 -1
- package/build/link/stateOperations.d.ts +0 -81
- package/build/link/stateOperations.d.ts.map +0 -1
- package/build/link/stateOperations.js +0 -105
- package/build/link/stateOperations.js.map +0 -1
- package/types/global.d.ts +0 -38
- package/types/metro-require.d.ts +0 -52
- package/types/react-native-web.d.ts +0 -295
package/build/routes-manifest.js
CHANGED
|
@@ -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;QACzB,iBAAiB,EAAE,IAAI;KACxB,CAAC,CAAC;IAEH,IAAI,CAAC,SAAS,EAAE;QACd,OAAO,IAAI,CAAC;KACb;IACD,OAAO,IAAA,qCAAiB,EAAC,SAAS,CAAC,CAAC;AACtC,CAAC;AAZD,oDAYC","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 ignoreEntryPoints: 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;KACV;IACD,IAAI,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,IAAI,EAAE;QACrB,OAAO,CAAC,CAAC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AC,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"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html.d.ts","sourceRoot":"","sources":["../../src/static/html.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B;;GAEG;AACH,wBAAgB,oBAAoB,gBASnC;AAED,wBAAgB,IAAI,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,
|
|
1
|
+
{"version":3,"file":"html.d.ts","sourceRoot":"","sources":["../../src/static/html.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B;;GAEG;AACH,wBAAgB,oBAAoB,gBASnC;AAED,wBAAgB,IAAI,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,eAY/D"}
|
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 (
|
|
19
|
-
__html: `#root,body
|
|
20
|
-
}
|
|
18
|
+
return (<style id="expo-reset" dangerouslySetInnerHTML={{
|
|
19
|
+
__html: `#root,body,html{height:100%}body{overflow:hidden}#root{display:flex}`,
|
|
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, shrink-to-fit=no"/>
|
|
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,sEAAsE;SAC/E,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,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,uDAAuD,EACrF;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;AAZD,oBAYC","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,html{height:100%}body{overflow:hidden}#root{display:flex}`,\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 name=\"viewport\" content=\"width=device-width, initial-scale=1, shrink-to-fit=no\" />\n <ScrollViewStyleReset />\n </head>\n <body>{children}</body>\n </html>\n );\n}\n"]}
|
|
@@ -5,11 +5,21 @@
|
|
|
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';
|
|
9
|
+
import { ExpoRouterServerManifestV1 } from '../getServerManifest';
|
|
8
10
|
/** Get the linking manifest from a Node.js process. */
|
|
9
|
-
declare function getManifest(options
|
|
11
|
+
declare function getManifest(options?: Parameters<typeof getRoutes>[1]): Promise<{
|
|
10
12
|
initialRouteName?: string | undefined;
|
|
11
13
|
screens: Record<string, import("../getReactNavigationConfig").Screen>;
|
|
12
14
|
}>;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
/**
|
|
16
|
+
* Get the server manifest with all dynamic routes loaded with `generateStaticParams`.
|
|
17
|
+
* Unlike the `expo-router/src/routes-manifest.ts` method, this requires loading the entire app in-memory, which
|
|
18
|
+
* takes substantially longer and requires Metro bundling.
|
|
19
|
+
*
|
|
20
|
+
* This is used for the production manifest where we pre-render certain pages and should no longer treat them as dynamic.
|
|
21
|
+
*/
|
|
22
|
+
declare function getBuildTimeServerManifestAsync(options?: Parameters<typeof getRoutes>[1]): Promise<ExpoRouterServerManifestV1>;
|
|
23
|
+
export declare function getStaticContent(location: URL): Promise<string>;
|
|
24
|
+
export { getManifest, getBuildTimeServerManifestAsync };
|
|
15
25
|
//# 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;AACzC,OAAO,EAAE,0BAA0B,EAAqB,MAAM,sBAAsB,CAAC;AAQrF,uDAAuD;AACvD,iBAAe,WAAW,CAAC,OAAO,GAAE,UAAU,CAAC,OAAO,SAAS,CAAC,CAAC,CAAC,CAAM;;;GAWvE;AAED;;;;;;GAMG;AACH,iBAAe,+BAA+B,CAC5C,OAAO,GAAE,UAAU,CAAC,OAAO,SAAS,CAAC,CAAC,CAAC,CAAM,GAC5C,OAAO,CAAC,0BAA0B,CAAC,CAWrC;AAYD,wBAAsB,gBAAgB,CAAC,QAAQ,EAAE,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC,CA0DrE;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
|
*
|
|
@@ -37,28 +37,46 @@ require("@expo/metro-runtime");
|
|
|
37
37
|
const native_1 = require("@react-navigation/native");
|
|
38
38
|
const Font = __importStar(require("expo-font/build/server"));
|
|
39
39
|
const react_1 = __importDefault(require("react"));
|
|
40
|
-
const
|
|
40
|
+
const server_node_1 = __importDefault(require("react-dom/server.node"));
|
|
41
41
|
const react_native_web_1 = require("react-native-web");
|
|
42
42
|
const getRootComponent_1 = require("./getRootComponent");
|
|
43
43
|
const _ctx_1 = require("../../_ctx");
|
|
44
44
|
const ExpoRoot_1 = require("../ExpoRoot");
|
|
45
|
-
const
|
|
45
|
+
const getReactNavigationConfig_1 = require("../getReactNavigationConfig");
|
|
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');
|
|
56
57
|
}
|
|
57
58
|
// Evaluate all static params
|
|
58
59
|
await (0, loadStaticParamsAsync_1.loadStaticParamsAsync)(routeTree);
|
|
59
|
-
return (0,
|
|
60
|
+
return (0, getReactNavigationConfig_1.getReactNavigationConfig)(routeTree, false);
|
|
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, options);
|
|
72
|
+
if (!routeTree) {
|
|
73
|
+
throw new Error('No routes found');
|
|
74
|
+
}
|
|
75
|
+
// Evaluate all static params
|
|
76
|
+
await (0, loadStaticParamsAsync_1.loadStaticParamsAsync)(routeTree);
|
|
77
|
+
return (0, getServerManifest_1.getServerManifest)(routeTree);
|
|
78
|
+
}
|
|
79
|
+
exports.getBuildTimeServerManifestAsync = getBuildTimeServerManifestAsync;
|
|
62
80
|
function resetReactNavigationContexts() {
|
|
63
81
|
// https://github.com/expo/router/discussions/588
|
|
64
82
|
// https://github.com/react-navigation/react-navigation/blob/9fe34b445fcb86e5666f61e144007d7540f014fa/packages/elements/src/getNamedContext.tsx#LL3C1-L4C1
|
|
@@ -67,7 +85,7 @@ function resetReactNavigationContexts() {
|
|
|
67
85
|
const contexts = '__react_navigation__elements_contexts';
|
|
68
86
|
global[contexts] = new Map();
|
|
69
87
|
}
|
|
70
|
-
function getStaticContent(location) {
|
|
88
|
+
async function getStaticContent(location) {
|
|
71
89
|
const headContext = {};
|
|
72
90
|
const ref = react_1.default.createRef();
|
|
73
91
|
const {
|
|
@@ -77,8 +95,9 @@ function getStaticContent(location) {
|
|
|
77
95
|
initialProps: {
|
|
78
96
|
location,
|
|
79
97
|
context: _ctx_1.ctx,
|
|
80
|
-
wrapper: ({ children }) => (
|
|
81
|
-
|
|
98
|
+
wrapper: ({ children }) => (<Root>
|
|
99
|
+
<div id="root">{children}</div>
|
|
100
|
+
</Root>),
|
|
82
101
|
},
|
|
83
102
|
});
|
|
84
103
|
const Root = (0, getRootComponent_1.getRootComponent)();
|
|
@@ -88,10 +107,15 @@ function getStaticContent(location) {
|
|
|
88
107
|
// This MUST be run before `ReactDOMServer.renderToString` to prevent
|
|
89
108
|
// "Warning: Detected multiple renderers concurrently rendering the same context provider. This is currently unsupported."
|
|
90
109
|
resetReactNavigationContexts();
|
|
91
|
-
const
|
|
92
|
-
|
|
110
|
+
const stream = await server_node_1.default.renderToStaticNodeStream(<head_1.Head.Provider context={headContext}>
|
|
111
|
+
<native_1.ServerContainer ref={ref}>{element}</native_1.ServerContainer>
|
|
112
|
+
</head_1.Head.Provider>);
|
|
113
|
+
let html = '';
|
|
114
|
+
for await (const chunk of stream) {
|
|
115
|
+
html += chunk;
|
|
116
|
+
}
|
|
93
117
|
// Eval the CSS after the HTML is rendered so that the CSS is in the same order
|
|
94
|
-
const css =
|
|
118
|
+
const css = server_node_1.default.renderToStaticMarkup(getStyleElement());
|
|
95
119
|
let output = mixHeadComponentsWithStaticResults(headContext.helmet, html);
|
|
96
120
|
output = output.replace('</head>', `${css}</head>`);
|
|
97
121
|
const fonts = Font.getServerResources();
|
|
@@ -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,
|
|
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,wEAAmD;AACnD,uDAA+C;AAE/C,yDAAsD;AACtD,qCAAiC;AACjC,0CAAuC;AACvC,0EAAuE;AACvE,4CAAyC;AACzC,4DAAqF;AACrF,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,CAAC,SAAS,EAAE;QACd,MAAM,IAAI,KAAK,CAA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,SAAS,kCAAkC,CAAC,MAAW,EAAE,IAAY;IACnE,kBAAkB;IAClB,KAAK,MAAM,GAAG,IAAI,CAAC,OAAO,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.node';\nimport { AppRegistry } from 'react-native-web';\n\nimport { getRootComponent } from './getRootComponent';\nimport { ctx } from '../../_ctx';\nimport { ExpoRoot } from '../ExpoRoot';\nimport { getReactNavigationConfig } from '../getReactNavigationConfig';\nimport { getRoutes } from '../getRoutes';\nimport { ExpoRouterServerManifestV1, 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 getReactNavigationConfig(routeTree, false);\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(\n options: Parameters<typeof getRoutes>[1] = {}\n): Promise<ExpoRouterServerManifestV1> {\n const routeTree = getRoutes(ctx, 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 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 async function getStaticContent(location: URL): Promise<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 stream = await ReactDOMServer.renderToStaticNodeStream(\n <Head.Provider context={headContext}>\n <ServerContainer ref={ref}>{element}</ServerContainer>\n </Head.Provider>\n );\n\n let html = '';\n\n for await (const chunk of stream) {\n html += chunk;\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,11 +37,9 @@ 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
|
-
process.env.
|
|
43
|
-
process.env.EXPO_ROUTER_IMPORT_MODE_IOS = 'sync';
|
|
44
|
-
process.env.EXPO_ROUTER_IMPORT_MODE_ANDROID = 'sync';
|
|
42
|
+
process.env.EXPO_ROUTER_IMPORT_MODE = 'sync';
|
|
45
43
|
if (typeof context === 'string') {
|
|
46
44
|
ctx = (0, context_stubs_1.requireContext)(path_1.default.resolve(process.cwd(), context));
|
|
47
45
|
}
|
|
@@ -59,7 +57,7 @@ function renderRouter(context = './app', { initialUrl = '/', ...options } = {})
|
|
|
59
57
|
else if (initialUrl instanceof URL) {
|
|
60
58
|
location = initialUrl;
|
|
61
59
|
}
|
|
62
|
-
const result = (0, react_native_1.render)(
|
|
60
|
+
const result = (0, react_native_1.render)(<ExpoRoot_1.ExpoRoot context={ctx} location={location}/>, {
|
|
63
61
|
...options,
|
|
64
62
|
});
|
|
65
63
|
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;AAC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AAC,mBAAQ,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,EAAG,EAAE;QACpE,GAAG,OAAO;KACX,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE;QAC3B,WAAW;YACT,OAAO,oBAAK,CAAC,iBAAiB,EAAE,CAAC,QAAQ,CAAC;QAC5C,CAAC;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;AAnDD,oCAmDC","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 = '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;AAsBpD,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,QAE1C"}
|
|
@@ -1,20 +1,27 @@
|
|
|
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', () => {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
try {
|
|
8
|
+
const Reanimated = require('react-native-reanimated/mock');
|
|
9
|
+
// The mock for `call` immediately calls the callback which is incorrect
|
|
10
|
+
// So we override it with a no-op
|
|
11
|
+
Reanimated.default.call = () => { };
|
|
12
|
+
return Reanimated;
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
return {};
|
|
16
|
+
}
|
|
12
17
|
});
|
|
13
18
|
// Silence the warning: Animated: `useNativeDriver` is not supported because the native animated module is missing
|
|
14
19
|
jest.mock('react-native/Libraries/Animated/NativeAnimatedHelper');
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
20
|
+
let mockInitialUrl = '';
|
|
21
|
+
function setInitialUrl(value) {
|
|
22
|
+
mockInitialUrl = value;
|
|
23
|
+
}
|
|
24
|
+
exports.setInitialUrl = setInitialUrl;
|
|
18
25
|
jest.mock('expo-linking', () => {
|
|
19
26
|
const module = {
|
|
20
27
|
...jest.requireActual('expo-linking'),
|
|
@@ -28,7 +35,7 @@ jest.mock('expo-linking', () => {
|
|
|
28
35
|
return { remove() { } };
|
|
29
36
|
},
|
|
30
37
|
async getInitialURL() {
|
|
31
|
-
return
|
|
38
|
+
return mockInitialUrl;
|
|
32
39
|
},
|
|
33
40
|
};
|
|
34
41
|
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;
|
|
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,IAAI;QACF,MAAM,UAAU,GAAG,OAAO,CAAC,8BAA8B,CAAC,CAAC;QAE3D,wEAAwE;QACxE,iCAAiC;QACjC,UAAU,CAAC,OAAO,CAAC,IAAI,GAAG,GAAG,EAAE,GAAE,CAAC,CAAC;QAEnC,OAAO,UAAU,CAAC;KACnB;IAAC,MAAM;QACN,OAAO,EAAE,CAAC;KACX;AACH,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 try {\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 } catch {\n return {};\n }\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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AE,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"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useScreens.d.ts","sourceRoot":"","sources":["../src/useScreens.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,eAAe,EACf,aAAa,EACb,SAAS,EACT,eAAe,EAChB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAIL,SAAS,EAGV,MAAM,SAAS,CAAC;AAOjB,MAAM,MAAM,WAAW,CACrB,QAAQ,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC1D,KAAK,SAAS,eAAe,GAAG,eAAe,EAC/C,QAAQ,SAAS,YAAY,GAAG,YAAY,IAC1C;IACF,4DAA4D;IAC5D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;OA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AAQ,CAAC,EAAE,OAAO,CAAC;IACnB,aAAa,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAC;IACvC,OAAO,CAAC,EAAE,QAAQ,CAAC;IAEnB,SAAS,CAAC,EACN,eAAe,CAAC,KAAK,EAAE,QAAQ,CAAC,GAChC,CAAC,CAAC,IAAI,EAAE;QACN,KAAK,EAAE,SAAS,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;QACxC,UAAU,EAAE,GAAG,CAAC;KACjB,KAAK,eAAe,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC;IAE5C,KAAK,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,SAAS,CAAA;KAAE,KAAK,MAAM,GAAG,SAAS,CAAC;CAC1F,CAAC;AA2DF;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,WAAW,EAAE,GAAG,KAAK,CAAC,SAAS,EAAE,CAUxE;AAuCD,mFAAmF;AACnF,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,SAAS,kIA4D1D;AAED,oGAAoG;AACpG,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,IAAI,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC;;sCAyB9E"}
|
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
|
}
|
|
@@ -81,7 +81,7 @@ function fromImport({ ErrorBoundary, ...component }) {
|
|
|
81
81
|
return { default: EmptyRoute_1.EmptyRoute };
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
|
-
return { default: component.default
|
|
84
|
+
return { default: component.default };
|
|
85
85
|
}
|
|
86
86
|
function fromLoadedRoute(res) {
|
|
87
87
|
if (!(res instanceof Promise)) {
|
|
@@ -97,32 +97,30 @@ function getQualifiedRouteComponent(value) {
|
|
|
97
97
|
if (qualifiedStore.has(value)) {
|
|
98
98
|
return qualifiedStore.get(value);
|
|
99
99
|
}
|
|
100
|
-
let
|
|
100
|
+
let ScreenComponent;
|
|
101
101
|
// TODO: This ensures sync doesn't use React.lazy, but it's not ideal.
|
|
102
102
|
if (import_mode_1.default === 'lazy') {
|
|
103
|
-
|
|
103
|
+
ScreenComponent = react_1.default.lazy(async () => {
|
|
104
104
|
const res = value.loadRoute();
|
|
105
105
|
return fromLoadedRoute(res);
|
|
106
106
|
});
|
|
107
|
-
getLoadable = (props, ref) => (react_1.default.createElement(react_1.default.Suspense, { fallback: react_1.default.createElement(SuspenseFallback_1.SuspenseFallback, { route: value }) },
|
|
108
|
-
react_1.default.createElement(AsyncComponent, { ...props,
|
|
109
|
-
ref,
|
|
110
|
-
// Expose the template segment path, e.g. `(home)`, `[foo]`, `index`
|
|
111
|
-
// the intention is to make it possible to deduce shared routes.
|
|
112
|
-
segment: value.route })));
|
|
113
107
|
}
|
|
114
108
|
else {
|
|
115
109
|
const res = value.loadRoute();
|
|
116
110
|
const Component = fromImport(res).default;
|
|
117
|
-
|
|
118
|
-
return
|
|
111
|
+
ScreenComponent = react_1.default.forwardRef((props, ref) => {
|
|
112
|
+
return <Component {...props} ref={ref}/>;
|
|
119
113
|
});
|
|
120
|
-
getLoadable = (props, ref) => (react_1.default.createElement(SyncComponent, { ...props,
|
|
121
|
-
ref,
|
|
122
|
-
// Expose the template segment path, e.g. `(home)`, `[foo]`, `index`
|
|
123
|
-
// the intention is to make it possible to deduce shared routes.
|
|
124
|
-
segment: value.route }));
|
|
125
114
|
}
|
|
115
|
+
const getLoadable = (props, ref) => (<react_1.default.Suspense fallback={<SuspenseFallback_1.SuspenseFallback route={value}/>}>
|
|
116
|
+
<ScreenComponent {...{
|
|
117
|
+
...props,
|
|
118
|
+
ref,
|
|
119
|
+
// Expose the template segment path, e.g. `(home)`, `[foo]`, `index`
|
|
120
|
+
// the intention is to make it possible to deduce shared routes.
|
|
121
|
+
segment: value.route,
|
|
122
|
+
}}/>
|
|
123
|
+
</react_1.default.Suspense>);
|
|
126
124
|
const QualifiedRoute = react_1.default.forwardRef(({
|
|
127
125
|
// Remove these React Navigation props to
|
|
128
126
|
// enforce usage of expo-router hooks (where the query params are correct).
|
|
@@ -130,7 +128,7 @@ function getQualifiedRouteComponent(value) {
|
|
|
130
128
|
// Pass all other props to the component
|
|
131
129
|
...props }, ref) => {
|
|
132
130
|
const loadable = getLoadable(props, ref);
|
|
133
|
-
return
|
|
131
|
+
return <Route_1.Route node={value}>{loadable}</Route_1.Route>;
|
|
134
132
|
});
|
|
135
133
|
QualifiedRoute.displayName = `Route(${value.route})`;
|
|
136
134
|
qualifiedStore.set(value, QualifiedRoute);
|
|
@@ -167,11 +165,9 @@ function createGetIdForRoute(route) {
|
|
|
167
165
|
}
|
|
168
166
|
exports.createGetIdForRoute = createGetIdForRoute;
|
|
169
167
|
function routeToScreen(route, { options, ...props } = {}) {
|
|
170
|
-
return (
|
|
168
|
+
return (<primitives_1.Screen
|
|
171
169
|
// 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) => {
|
|
170
|
+
getId={createGetIdForRoute(route)} {...props} name={route.route} key={route.route} options={(args) => {
|
|
175
171
|
// Only eager load generated components
|
|
176
172
|
const staticOptions = route.generated ? route.loadRoute()?.getNavOptions : null;
|
|
177
173
|
const staticResult = typeof staticOptions === 'function' ? staticOptions(args) : staticOptions;
|
|
@@ -187,6 +183,6 @@ function routeToScreen(route, { options, ...props } = {}) {
|
|
|
187
183
|
output.drawerItemStyle = { height: 0, display: 'none' };
|
|
188
184
|
}
|
|
189
185
|
return output;
|
|
190
|
-
}
|
|
186
|
+
}} getComponent={() => getQualifiedRouteComponent(route)}/>);
|
|
191
187
|
}
|
|
192
188
|
//# sourceMappingURL=useScreens.js.map
|