expo-router 5.0.0-sdk-52-router-patches → 5.0.1-preview.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/Route.d.ts +7 -1
- package/build/Route.d.ts.map +1 -1
- package/build/Route.js.map +1 -1
- package/build/exports.d.ts +1 -0
- package/build/exports.d.ts.map +1 -1
- package/build/exports.js.map +1 -1
- package/build/fork/getStateFromPath-forks.d.ts +3 -2
- package/build/fork/getStateFromPath-forks.d.ts.map +1 -1
- package/build/fork/getStateFromPath-forks.js +24 -27
- package/build/fork/getStateFromPath-forks.js.map +1 -1
- package/build/fork/getStateFromPath.js +24 -19
- package/build/fork/getStateFromPath.js.map +1 -1
- package/build/getLinkingConfig.d.ts +3 -1
- package/build/getLinkingConfig.d.ts.map +1 -1
- package/build/getLinkingConfig.js +11 -7
- package/build/getLinkingConfig.js.map +1 -1
- package/build/getReactNavigationConfig.d.ts +1 -0
- package/build/getReactNavigationConfig.d.ts.map +1 -1
- package/build/getReactNavigationConfig.js +2 -1
- package/build/getReactNavigationConfig.js.map +1 -1
- package/build/getRoutes.d.ts.map +1 -1
- package/build/getRoutes.js +9 -1
- package/build/getRoutes.js.map +1 -1
- package/build/getRoutesCore.d.ts +16 -1
- package/build/getRoutesCore.d.ts.map +1 -1
- package/build/getRoutesCore.js +134 -11
- package/build/getRoutesCore.js.map +1 -1
- package/build/getRoutesRedirects.d.ts +12 -0
- package/build/getRoutesRedirects.d.ts.map +1 -0
- package/build/getRoutesRedirects.js +71 -0
- package/build/getRoutesRedirects.js.map +1 -0
- package/build/getRoutesSSR.d.ts.map +1 -1
- package/build/getRoutesSSR.js +9 -1
- package/build/getRoutesSSR.js.map +1 -1
- package/build/getServerManifest.d.ts +13 -1
- package/build/getServerManifest.d.ts.map +1 -1
- package/build/getServerManifest.js +27 -2
- package/build/getServerManifest.js.map +1 -1
- package/build/global-state/router-store.d.ts +4 -0
- package/build/global-state/router-store.d.ts.map +1 -1
- package/build/global-state/router-store.js +44 -2
- package/build/global-state/router-store.js.map +1 -1
- package/build/global-state/routing.d.ts +1 -1
- package/build/global-state/routing.d.ts.map +1 -1
- package/build/global-state/routing.js +7 -1
- package/build/global-state/routing.js.map +1 -1
- package/build/link/linking.d.ts +2 -1
- package/build/link/linking.d.ts.map +1 -1
- package/build/link/linking.js +14 -8
- package/build/link/linking.js.map +1 -1
- package/build/matchers.d.ts +3 -1
- package/build/matchers.d.ts.map +1 -1
- package/build/matchers.js +7 -2
- package/build/matchers.js.map +1 -1
- package/build/routes-manifest.d.ts +6 -2
- 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/rsc/middleware.d.ts.map +1 -1
- package/build/rsc/middleware.js +6 -1
- package/build/rsc/middleware.js.map +1 -1
- package/build/rsc/router/create-expo-pages.d.ts +20 -0
- package/build/rsc/router/create-expo-pages.d.ts.map +1 -0
- package/build/rsc/router/create-expo-pages.js +22 -0
- package/build/rsc/router/create-expo-pages.js.map +1 -0
- package/build/rsc/router/expo-definedRouter.d.ts +1 -5
- package/build/rsc/router/expo-definedRouter.d.ts.map +1 -1
- package/build/rsc/router/expo-definedRouter.js +3 -2
- package/build/rsc/router/expo-definedRouter.js.map +1 -1
- package/build/rsc/router/noopRouter.d.ts +1 -5
- package/build/rsc/router/noopRouter.d.ts.map +1 -1
- package/build/rsc/router/noopRouter.js +2 -2
- package/build/rsc/router/noopRouter.js.map +1 -1
- package/build/static/getServerManifest.d.ts.map +1 -1
- package/build/static/getServerManifest.js +1 -0
- package/build/static/getServerManifest.js.map +1 -1
- package/build/useScreens.d.ts +4 -1
- package/build/useScreens.d.ts.map +1 -1
- package/build/useScreens.js +39 -34
- package/build/useScreens.js.map +1 -1
- package/package.json +4 -4
- package/plugin/options.json +33 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middleware.js","sourceRoot":"","sources":["../../src/rsc/middleware.ts"],"names":[],"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AAW,CAAC,IAAI,CAAC,CAAC;YACtC,OAAO;gBACL,EAAE;gBACF,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE;aAC7B,CAAC;QACJ,CAAC;QACD,KAAK,CAAC,mBAAmB,CAAC,IAAI;YAC5B,KAAK,CAAC,qBAAqB,EAAE,IAAI,CAAC,CAAC;YACnC,MAAM,QAAQ,GAAG,mBAAI,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;YAC9C,MAAM,CAAC,GAAG,MAAM,IAAA,wCAAiB,EAAC,QAAQ,CAAC,CAAC;YAE5C,wGAAwG;YACxG,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;gBACjC,OAAO,CAAC,CAAC,OAAO,CAAC;aAClB;YACD,OAAO,CAAC,CAAC;QACX,CAAC;QAED,OAAO,EAAE,OAAQ;KAClB,CACF,CAAC;AACJ,CAAC;AA3ED,8DA2EC;AAEM,KAAK,UAAU,cAAc,CAClC,UAAkB,EAClB,IAAmB;IAEnB,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;IAC/B,OAAO,yBAAyB,CAC9B,UAAU,EACV;QACE,MAAM,EAAE,GAAG,EAAE;YACX,mFAAmF;YACnF,MAAM,QAAQ,GAAG,aAAa,QAAQ,YAAY,CAAC;YACnD,OAAO,IAAA,wCAAiB,EAAC,QAAQ,CAAC,CAAC;QACrC,CAAC;KACF,EACD,IAAI,CACL,CAAC;AACJ,CAAC;AAhBD,wCAgBC","sourcesContent":["/**\n * Copyright © 2024 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 *\n */\n// This module is bundled with Metro in web/react-server mode and redirects to platform specific renderers.\nimport type { RenderRscArgs } from '@expo/server/build/middleware/rsc';\nimport Constants from 'expo-constants';\nimport { asyncServerImport } from 'expo-router/_async-server-import';\nimport path from 'node:path';\n\nimport { renderRsc } from './rsc-renderer';\n\nconst debug = require('debug')('expo:server:rsc-renderer');\n\n// Tracking the implementation in expo/cli's MetroBundlerDevServer\nconst rscRenderContext = new Map<string, any>();\n\nfunction getRscRenderContext(platform: string) {\n // NOTE(EvanBacon): We memoize this now that there's a persistent server storage cache for Server Actions.\n if (rscRenderContext.has(platform)) {\n return rscRenderContext.get(platform)!;\n }\n\n const context = {};\n\n rscRenderContext.set(platform, context);\n return context;\n}\n\nfunction interopDefault(mod: any) {\n if ('default' in mod && typeof mod.default === 'object' && mod.default) {\n const def = mod.default;\n if ('default' in def && typeof def.default === 'object' && def.default) {\n return def.default;\n }\n return mod.default;\n }\n return mod;\n}\n\nasync function getServerActionManifest(\n distFolder: string,\n platform: string\n): Promise<\n Record<\n // Input ID\n string,\n [\n // Metro ID\n string,\n // Chunk location.\n string,\n ]\n >\n> {\n const filePath = `../../rsc/${platform}/action-manifest.js`;\n return interopDefault(await asyncServerImport(filePath));\n}\n\nasync function getSSRManifest(\n distFolder: string,\n platform: string\n): Promise<\n Record<\n // Input ID\n string,\n [\n // Metro ID\n string,\n // Chunk location.\n string,\n ]\n >\n> {\n const filePath = `../../rsc/${platform}/ssr-manifest.js`;\n return interopDefault(await asyncServerImport(filePath));\n}\n\n// The import map allows us to use external modules from different bundling contexts.\ntype ImportMap = {\n router: () => Promise<typeof import('./router/expo-definedRouter')>;\n};\n\nexport async function renderRscWithImportsAsync(\n distFolder: string,\n imports: ImportMap,\n { body, platform, searchParams, config, method, input, contentType, headers }: RenderRscArgs\n): Promise<ReadableStream<any>> {\n globalThis.__expo_platform_header = platform;\n if (method === 'POST' && !body) {\n throw new Error('Server request must be provided when method is POST (server actions)');\n }\n\n const context = getRscRenderContext(platform);\n context['__expo_requestHeaders'] = headers;\n\n const router = await imports.router();\n const entries = router.default({\n redirects: Constants.expoConfig?.extra?.router?.redirects,\n rewrites: Constants.expoConfig?.extra?.router?.rewrites,\n });\n\n const ssrManifest = await getSSRManifest(distFolder, platform);\n const actionManifest = await getServerActionManifest(distFolder, platform);\n return renderRsc(\n {\n body: body ?? undefined,\n context,\n config,\n input,\n contentType,\n decodedBody: searchParams.get('x-expo-params'),\n },\n {\n isExporting: true,\n\n resolveClientEntry(file: string, isServer: boolean) {\n debug('resolveClientEntry', file, { isServer });\n\n if (isServer) {\n if (!(file in actionManifest)) {\n throw new Error(\n `Could not find file in server action manifest: ${file}. ${JSON.stringify(actionManifest)}`\n );\n }\n\n const [id, chunk] = actionManifest[file];\n return {\n id,\n chunks: chunk ? [chunk] : [],\n };\n }\n\n if (!(file in ssrManifest)) {\n throw new Error(`Could not find file in SSR manifest: ${file}`);\n }\n\n const [id, chunk] = ssrManifest[file];\n return {\n id,\n chunks: chunk ? [chunk] : [],\n };\n },\n async loadServerModuleRsc(file) {\n debug('loadServerModuleRsc', file);\n const filePath = path.join('../../../', file);\n const m = await asyncServerImport(filePath);\n\n // TODO: This is a hack to workaround a cloudflare/metro issue where there's an extra `default` wrapper.\n if (typeof caches !== 'undefined') {\n return m.default;\n }\n return m;\n },\n\n entries: entries!,\n }\n );\n}\n\nexport async function renderRscAsync(\n distFolder: string,\n args: RenderRscArgs\n): Promise<ReadableStream<any>> {\n const platform = args.platform;\n return renderRscWithImportsAsync(\n distFolder,\n {\n router: () => {\n // Assumes this file is saved to: `dist/server/_expo/functions/_flight/[...rsc].js`\n const filePath = `../../rsc/${platform}/router.js`;\n return asyncServerImport(filePath);\n },\n },\n args\n );\n}\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { createPages } from './create-pages';
|
|
2
|
+
import { Options as GetRoutesOptions } from '../../getRoutes';
|
|
3
|
+
import { EntriesDev } from '../server';
|
|
4
|
+
type CreatePagesFn = Parameters<typeof createPages>[0];
|
|
5
|
+
type CreatePagesFns = Parameters<CreatePagesFn>[0];
|
|
6
|
+
type CreatePagesOptions = Parameters<CreatePagesFn>[1] & {
|
|
7
|
+
getRouteOptions?: GetRoutesOptions;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Wrapper around `createPages` to pass data from the server to the fn
|
|
11
|
+
*
|
|
12
|
+
* This is separated from the `createPages` function allowing us to keep the createPages
|
|
13
|
+
* in sync with the original Waku implementation.
|
|
14
|
+
*
|
|
15
|
+
* @param fn
|
|
16
|
+
* @returns
|
|
17
|
+
*/
|
|
18
|
+
export declare function createExpoPages(fn: (fn: CreatePagesFns, options: CreatePagesOptions) => ReturnType<CreatePagesFn>): (getRouteOptions?: GetRoutesOptions) => EntriesDev;
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=create-expo-pages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-expo-pages.d.ts","sourceRoot":"","sources":["../../../src/rsc/router/create-expo-pages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC,KAAK,aAAa,GAAG,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;AACvD,KAAK,cAAc,GAAG,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;AACnD,KAAK,kBAAkB,GAAG,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,GAAG;IACvD,eAAe,CAAC,EAAE,gBAAgB,CAAC;CACpC,CAAC;AAEF;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAC7B,EAAE,EAAE,CAAC,EAAE,EAAE,cAAc,EAAE,OAAO,EAAE,kBAAkB,KAAK,UAAU,CAAC,aAAa,CAAC,sBAExD,gBAAgB,KAAG,UAAU,CAKxD"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createExpoPages = void 0;
|
|
4
|
+
const create_pages_1 = require("./create-pages");
|
|
5
|
+
/**
|
|
6
|
+
* Wrapper around `createPages` to pass data from the server to the fn
|
|
7
|
+
*
|
|
8
|
+
* This is separated from the `createPages` function allowing us to keep the createPages
|
|
9
|
+
* in sync with the original Waku implementation.
|
|
10
|
+
*
|
|
11
|
+
* @param fn
|
|
12
|
+
* @returns
|
|
13
|
+
*/
|
|
14
|
+
function createExpoPages(fn) {
|
|
15
|
+
return (getRouteOptions) => {
|
|
16
|
+
return {
|
|
17
|
+
default: (0, create_pages_1.createPages)((a, b) => fn(a, { ...b, getRouteOptions })),
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
exports.createExpoPages = createExpoPages;
|
|
22
|
+
//# sourceMappingURL=create-expo-pages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-expo-pages.js","sourceRoot":"","sources":["../../../src/rsc/router/create-expo-pages.ts"],"names":[],"mappings":";;;AAAA,iDAA6C;AAU7C;;;;;;;;GAQG;AACH,SAAgB,eAAe,CAC7B,EAAkF;IAElF,OAAO,CAAC,eAAkC,EAAc,EAAE;QACxD,OAAO;YACL,OAAO,EAAE,IAAA,0BAAW,EAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,GAAG,CAAC,EAAE,eAAe,EAAE,CAAC,CAAC;SACjE,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AARD,0CAQC","sourcesContent":["import { createPages } from './create-pages';\nimport { Options as GetRoutesOptions } from '../../getRoutes';\nimport { EntriesDev } from '../server';\n\ntype CreatePagesFn = Parameters<typeof createPages>[0];\ntype CreatePagesFns = Parameters<CreatePagesFn>[0];\ntype CreatePagesOptions = Parameters<CreatePagesFn>[1] & {\n getRouteOptions?: GetRoutesOptions;\n};\n\n/**\n * Wrapper around `createPages` to pass data from the server to the fn\n *\n * This is separated from the `createPages` function allowing us to keep the createPages\n * in sync with the original Waku implementation.\n *\n * @param fn\n * @returns\n */\nexport function createExpoPages(\n fn: (fn: CreatePagesFns, options: CreatePagesOptions) => ReturnType<CreatePagesFn>\n) {\n return (getRouteOptions?: GetRoutesOptions): EntriesDev => {\n return {\n default: createPages((a, b) => fn(a, { ...b, getRouteOptions })),\n };\n };\n}\n"]}
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
declare const _default:
|
|
2
|
-
renderEntries: import("../server").RenderEntries;
|
|
3
|
-
getBuildConfig: import("../server").GetBuildConfig | undefined;
|
|
4
|
-
getSsrConfig: import("../server").GetSsrConfig | undefined;
|
|
5
|
-
};
|
|
1
|
+
declare const _default: (getRouteOptions?: import("../../getRoutes").Options | undefined) => import("../server").EntriesDev;
|
|
6
2
|
export default _default;
|
|
7
3
|
//# sourceMappingURL=expo-definedRouter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expo-definedRouter.d.ts","sourceRoot":"","sources":["../../../src/rsc/router/expo-definedRouter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"expo-definedRouter.d.ts","sourceRoot":"","sources":["../../../src/rsc/router/expo-definedRouter.ts"],"names":[],"mappings":";AAmBA,wBAyHG"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const _ctx_1 = require("expo-router/_ctx");
|
|
4
|
-
const
|
|
4
|
+
const create_expo_pages_1 = require("./create-expo-pages");
|
|
5
5
|
const getRoutesSSR_1 = require("../../getRoutesSSR");
|
|
6
6
|
const loadStaticParamsAsync_1 = require("../../loadStaticParamsAsync");
|
|
7
7
|
const matchers_1 = require("../../matchers");
|
|
@@ -12,8 +12,9 @@ const UNIMPLEMENTED_PARAMS = new Proxy({}, {
|
|
|
12
12
|
throw new Error('generateStaticParams(): params is not implemented yet');
|
|
13
13
|
},
|
|
14
14
|
});
|
|
15
|
-
exports.default = (0,
|
|
15
|
+
exports.default = (0, create_expo_pages_1.createExpoPages)(async ({ createPage, createLayout }, { getRouteOptions }) => {
|
|
16
16
|
const routes = (0, getRoutesSSR_1.getRoutes)(_ctx_1.ctx, {
|
|
17
|
+
...getRouteOptions,
|
|
17
18
|
platform: process.env.EXPO_OS,
|
|
18
19
|
skipGenerated: true,
|
|
19
20
|
importMode: 'lazy',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expo-definedRouter.js","sourceRoot":"","sources":["../../../src/rsc/router/expo-definedRouter.ts"],"names":[],"mappings":";;AAAA,2CAAuC;AAEvC,
|
|
1
|
+
{"version":3,"file":"expo-definedRouter.js","sourceRoot":"","sources":["../../../src/rsc/router/expo-definedRouter.ts"],"names":[],"mappings":";;AAAA,2CAAuC;AAEvC,2DAAsD;AAEtD,qDAA+C;AAC/C,uEAAoE;AACpE,6CAA+C;AAC/C,iDAA8C;AAE9C,MAAM,oBAAoB,GAAG,IAAI,KAAK,CACpC,EAAE,EACF;IACE,qDAAqD;IACrD,GAAG;QACD,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;IAC3E,CAAC;CACF,CACF,CAAC;AAEF,kBAAe,IAAA,mCAAe,EAAC,KAAK,EAAE,EAAE,UAAU,EAAE,YAAY,EAAE,EAAE,EAAE,eAAe,EAAE,EAAE,EAAE;IACzF,MAAM,MAAM,GAAG,IAAA,wBAAS,EAAC,UAAG,EAAE;QAC5B,GAAG,eAAe;QAClB,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,OAAO;QAC7B,aAAa,EAAE,IAAI;QACnB,UAAU,EAAE,MAAM;KACnB,CAAC,CAAC;IAEH,IAAI,CAAC,MAAM;QAAE,OAAO;IAEpB,KAAK,UAAU,+BAA+B,CAAC,KAAgB;QAC7D,MAAM,MAAM,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;QAEjC,IAAI,WAAW,GAA2B,SAAS,CAAC;QAEpD,IAAI,KAAK,CAAC,OAAO,EAAE;YACjB,MAAM,MAA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;4BAChC,IAAI,EAAE,MAAa;4BACnB,MAAM,EAAE,SAAS;4BACjB,GAAG,QAAQ;yBACZ,CAAC,CAAC;qBACJ;iBACF;qBAAM;oBACL,UAAU,CAAC;wBACT,8DAA8D;wBAC9D,SAAS,EAAE,MAAM,CAAC,OAAc;wBAChC,IAAI,EAAE,MAAa;wBACnB,MAAM,EAAE,SAAS;wBACjB,GAAG,QAAQ;qBACZ,CAAC,CAAC;iBACJ;aACF;QACH,CAAC,CAAC,CACH,CAAC;IACJ,CAAC;IAED,MAAM,SAAS,CAAC,MAAM,CAAC,CAAC;AAC1B,CAAC,CAAC,CAAC","sourcesContent":["import { ctx } from 'expo-router/_ctx';\n\nimport { createExpoPages } from './create-expo-pages';\nimport type { RouteNode } from '../../Route';\nimport { getRoutes } from '../../getRoutesSSR';\nimport { evalStaticParamsAsync } from '../../loadStaticParamsAsync';\nimport { getContextKey } from '../../matchers';\nimport { sortRoutes } from '../../sortRoutes';\n\nconst UNIMPLEMENTED_PARAMS = new Proxy(\n {},\n {\n // Assert that params is unimplemented when accessed.\n get() {\n throw new Error('generateStaticParams(): params is not implemented yet');\n },\n }\n);\n\nexport default createExpoPages(async ({ createPage, createLayout }, { getRouteOptions }) => {\n const routes = getRoutes(ctx, {\n ...getRouteOptions,\n platform: process.env.EXPO_OS,\n skipGenerated: true,\n importMode: 'lazy',\n });\n\n if (!routes) return;\n\n async function loadAndConvertStaticParamsAsync(route: RouteNode) {\n const loaded = route.loadRoute();\n\n let staticPaths: string[][] | undefined = undefined;\n\n if (route.dynamic) {\n const params = await evalStaticParamsAsync(\n route,\n { parentParams: UNIMPLEMENTED_PARAMS },\n loaded.generateStaticParams\n );\n\n // Sort `params` like `[{a: 'x', b: 'y'}, { a: 'z', b: 'w' }]` for a route.dynamic like `[{name: 'a', deep: false}, {name: 'b', deep: false}]` to `[['a', 'y'], ['z', 'w]]`\n staticPaths = params?.map((p) => {\n const grouped: string[] = [];\n\n for (const dynamic of route.dynamic!) {\n const defined = p[dynamic.name];\n if (!defined) {\n throw new Error(\n 'generateStaticParams is missing param: ' +\n dynamic.name +\n '. In route: ' +\n route.contextKey\n );\n }\n if (Array.isArray(defined)) {\n if (defined.length > 1) {\n throw new Error(\n 'generateStaticParams does not support returning multiple static paths for deep dynamic routes in React Server Components yet. Update route: ' +\n route.contextKey\n );\n }\n }\n\n const first = Array.isArray(defined) ? defined[0] : defined;\n\n grouped.push(first);\n }\n return grouped;\n });\n } else if (loaded.generateStaticParams) {\n throw new Error(\n 'Cannot use generateStaticParams without a dynamic route: ' + route.contextKey\n );\n }\n return staticPaths;\n }\n async function addLayout(route: RouteNode) {\n const normal = getContextKey(route.contextKey).replace(/\\/index$/, '');\n\n const loaded = route.loadRoute();\n\n if (loaded.generateStaticParams) {\n throw new Error(\n 'generateStaticParams is not supported in _layout routes with React Server Components enabled yet.'\n );\n }\n\n createLayout({\n // NOTE(EvanBacon): Support routes with top-level \"use client\"\n component: loaded.default! as any,\n path: normal as any,\n render: 'static',\n ...loaded.unstable_settings,\n });\n\n await Promise.all(\n route.children.sort(sortRoutes).map(async (child) => {\n if (child.type === 'layout') {\n await addLayout(child);\n } else {\n const normal = getContextKey(child.contextKey).replace(/\\/index$/, '');\n const loaded = child.loadRoute();\n const settings = loaded.unstable_settings;\n\n // Support generateStaticParams for dynamic routes by defining the route twice.\n if (loaded.generateStaticParams) {\n createPage({\n // NOTE(EvanBacon): Support routes with top-level \"use client\"\n component: loaded.default as any,\n path: normal as any,\n render: 'static',\n ...loaded.unstable_settings,\n staticPaths: (await loadAndConvertStaticParamsAsync(child)) as any,\n });\n\n if (settings?.render !== 'static') {\n createPage({\n // NOTE(EvanBacon): Support routes with top-level \"use client\"\n component: loaded.default as any,\n path: normal as any,\n render: 'dynamic',\n ...settings,\n });\n }\n } else {\n createPage({\n // NOTE(EvanBacon): Support routes with top-level \"use client\"\n component: loaded.default as any,\n path: normal as any,\n render: 'dynamic',\n ...settings,\n });\n }\n }\n })\n );\n }\n\n await addLayout(routes);\n});\n"]}
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
declare const _default:
|
|
2
|
-
renderEntries: import("../server").RenderEntries;
|
|
3
|
-
getBuildConfig: import("../server").GetBuildConfig | undefined;
|
|
4
|
-
getSsrConfig: import("../server").GetSsrConfig | undefined;
|
|
5
|
-
};
|
|
1
|
+
declare const _default: (getRouteOptions?: import("../../getRoutes").Options | undefined) => import("../server").EntriesDev;
|
|
6
2
|
export default _default;
|
|
7
3
|
//# sourceMappingURL=noopRouter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"noopRouter.d.ts","sourceRoot":"","sources":["../../../src/rsc/router/noopRouter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"noopRouter.d.ts","sourceRoot":"","sources":["../../../src/rsc/router/noopRouter.ts"],"names":[],"mappings":";AAEA,wBAEG"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
4
|
-
exports.default = (0,
|
|
3
|
+
const create_expo_pages_1 = require("./create-expo-pages");
|
|
4
|
+
exports.default = (0, create_expo_pages_1.createExpoPages)(async () => {
|
|
5
5
|
// noop the router for client-only mode. This ensures we skip loading the routes in react-server mode.
|
|
6
6
|
});
|
|
7
7
|
//# sourceMappingURL=noopRouter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"noopRouter.js","sourceRoot":"","sources":["../../../src/rsc/router/noopRouter.ts"],"names":[],"mappings":";;AAAA,
|
|
1
|
+
{"version":3,"file":"noopRouter.js","sourceRoot":"","sources":["../../../src/rsc/router/noopRouter.ts"],"names":[],"mappings":";;AAAA,2DAAsD;AAEtD,kBAAe,IAAA,mCAAe,EAAC,KAAK,IAAI,EAAE;IACxC,sGAAsG;AACxG,CAAC,CAAC,CAAC","sourcesContent":["import { createExpoPages } from './create-expo-pages';\n\nexport default createExpoPages(async () => {\n // noop the router for client-only mode. This ensures we skip loading the routes in react-server mode.\n});\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getServerManifest.d.ts","sourceRoot":"","sources":["../../src/static/getServerManifest.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAa,OAAO,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,0BAA0B,EAAqB,MAAM,sBAAsB,CAAC;AAGrF;;;;;;GAMG;AACH,wBAAsB,+BAA+B,CACnD,OAAO,GAAE,OAAY,GACpB,OAAO,CAAC,0BAA0B,CAAC,CAcrC;AAED,uDAAuD;AACvD,wBAAsB,WAAW,CAAC,OAAO,GAAE,OAAY;;;
|
|
1
|
+
{"version":3,"file":"getServerManifest.d.ts","sourceRoot":"","sources":["../../src/static/getServerManifest.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAa,OAAO,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,0BAA0B,EAAqB,MAAM,sBAAsB,CAAC;AAGrF;;;;;;GAMG;AACH,wBAAsB,+BAA+B,CACnD,OAAO,GAAE,OAAY,GACpB,OAAO,CAAC,0BAA0B,CAAC,CAcrC;AAED,uDAAuD;AACvD,wBAAsB,WAAW,CAAC,OAAO,GAAE,OAAY;;;GAgBtD"}
|
|
@@ -36,6 +36,7 @@ exports.getBuildTimeServerManifestAsync = getBuildTimeServerManifestAsync;
|
|
|
36
36
|
async function getManifest(options = {}) {
|
|
37
37
|
const routeTree = (0, getRoutes_1.getRoutes)(_ctx_1.ctx, {
|
|
38
38
|
preserveApiRoutes: true,
|
|
39
|
+
preserveRedirectAndRewrites: true,
|
|
39
40
|
platform: 'web',
|
|
40
41
|
...options,
|
|
41
42
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getServerManifest.js","sourceRoot":"","sources":["../../src/static/getServerManifest.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,qCAAiC;AACjC,0EAAuE;AACvE,4CAAkD;AAClD,4DAAqF;AACrF,oEAAiE;AAEjE;;;;;;GAMG;AACI,KAAK,UAAU,+BAA+B,CACnD,UAAmB,EAAE;IAErB,MAAM,SAAS,GAAG,IAAA,qBAAS,EAAC,UAAG,EAAE;QAC/B,QAAQ,EAAE,KAAK;QACf,GAAG,OAAO;KACX,CAAC,CAAC;IAEH,IAAI,CAAC,SAAS,EAAE;QACd,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;KACpC;IAED,6BAA6B;IAC7B,MAAM,IAAA,6CAAqB,EAAC,SAAS,CAAC,CAAC;IAEvC,OAAO,IAAA,qCAAiB,EAAC,SAAS,CAAC,CAAC;AACtC,CAAC;AAhBD,0EAgBC;AAED,uDAAuD;AAChD,KAAK,UAAU,WAAW,CAAC,UAAmB,EAAE;IACrD,MAAM,SAAS,GAAG,IAAA,qBAAS,EAAC,UAAG,EAAE;QAC/B,iBAAiB,EAAE,IAAI;QACvB,QAAQ,EAAE,KAAK;QACf,GAAG,OAAO;KACX,CAAC,CAAC;IAEH,IAAI,CAAC,SAAS,EAAE;QACd,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;KACpC;IAED,6BAA6B;IAC7B,MAAM,IAAA,6CAAqB,EAAC,SAAS,CAAC,CAAC;IAEvC,OAAO,IAAA,mDAAwB,EAAC,SAAS,EAAE,KAAK,CAAC,CAAC;AACpD,CAAC;
|
|
1
|
+
{"version":3,"file":"getServerManifest.js","sourceRoot":"","sources":["../../src/static/getServerManifest.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,qCAAiC;AACjC,0EAAuE;AACvE,4CAAkD;AAClD,4DAAqF;AACrF,oEAAiE;AAEjE;;;;;;GAMG;AACI,KAAK,UAAU,+BAA+B,CACnD,UAAmB,EAAE;IAErB,MAAM,SAAS,GAAG,IAAA,qBAAS,EAAC,UAAG,EAAE;QAC/B,QAAQ,EAAE,KAAK;QACf,GAAG,OAAO;KACX,CAAC,CAAC;IAEH,IAAI,CAAC,SAAS,EAAE;QACd,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;KACpC;IAED,6BAA6B;IAC7B,MAAM,IAAA,6CAAqB,EAAC,SAAS,CAAC,CAAC;IAEvC,OAAO,IAAA,qCAAiB,EAAC,SAAS,CAAC,CAAC;AACtC,CAAC;AAhBD,0EAgBC;AAED,uDAAuD;AAChD,KAAK,UAAU,WAAW,CAAC,UAAmB,EAAE;IACrD,MAAM,SAAS,GAAG,IAAA,qBAAS,EAAC,UAAG,EAAE;QAC/B,iBAAiB,EAAE,IAAI;QACvB,2BAA2B,EAAE,IAAI;QACjC,QAAQ,EAAE,KAAK;QACf,GAAG,OAAO;KACX,CAAC,CAAC;IAEH,IAAI,CAAC,SAAS,EAAE;QACd,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;KACpC;IAED,6BAA6B;IAC7B,MAAM,IAAA,6CAAqB,EAAC,SAAS,CAAC,CAAC;IAEvC,OAAO,IAAA,mDAAwB,EAAC,SAAS,EAAE,KAAK,CAAC,CAAC;AACpD,CAAC;AAhBD,kCAgBC","sourcesContent":["/**\n * Copyright © 2024 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 */\n\nimport { ctx } from '../../_ctx';\nimport { getReactNavigationConfig } from '../getReactNavigationConfig';\nimport { getRoutes, Options } from '../getRoutes';\nimport { ExpoRouterServerManifestV1, getServerManifest } from '../getServerManifest';\nimport { loadStaticParamsAsync } from '../loadStaticParamsAsync';\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 */\nexport async function getBuildTimeServerManifestAsync(\n options: Options = {}\n): Promise<ExpoRouterServerManifestV1> {\n const routeTree = getRoutes(ctx, {\n platform: 'web',\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\n/** Get the linking manifest from a Node.js process. */\nexport async function getManifest(options: Options = {}) {\n const routeTree = getRoutes(ctx, {\n preserveApiRoutes: true,\n preserveRedirectAndRewrites: true,\n platform: 'web',\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 getReactNavigationConfig(routeTree, false);\n}\n"]}
|
package/build/useScreens.d.ts
CHANGED
|
@@ -30,7 +30,10 @@ export type SingularOptions = boolean | ((name: string, params: UnknownOutputPar
|
|
|
30
30
|
*/
|
|
31
31
|
export declare function useSortedScreens(order: ScreenProps[]): React.ReactNode[];
|
|
32
32
|
/** Wrap the component with various enhancements and add access to child routes. */
|
|
33
|
-
export declare function getQualifiedRouteComponent(value: RouteNode): React.ComponentType<any> |
|
|
33
|
+
export declare function getQualifiedRouteComponent(value: RouteNode): React.ComponentType<any> | {
|
|
34
|
+
({ route, navigation, ...props }: any): React.JSX.Element;
|
|
35
|
+
displayName: string;
|
|
36
|
+
};
|
|
34
37
|
export declare function screenOptionsFactory(route: RouteNode, options?: ScreenProps['options']): RouteConfig<any, any, any, any, any, any>['options'];
|
|
35
38
|
export declare function routeToScreen(route: RouteNode, { options, getId, ...props }?: Partial<ScreenProps>): React.JSX.Element;
|
|
36
39
|
export declare function getSingularId(name: string, options?: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useScreens.d.ts","sourceRoot":"","sources":["../src/useScreens.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,YAAY,EACZ,eAAe,EACf,aAAa,EACb,WAAW,EACX,SAAS,EACT,eAAe,EAChB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAsB,SAAS,EAAu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EAAE,MAAM,EAAE,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;KAAE,KAAK,MAAM,GAAG,SAAS,CAAC;IAE7E,mBAAmB,CAAC,EAAE,eAAe,CAAC;CACvC,CAAC;AAEF,MAAM,MAAM,eAAe,GACvB,OAAO,GACP,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,mBAAmB,KAAK,MAAM,GAAG,SAAS,CAAC,CAAC;AA2FxE;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,WAAW,EAAE,GAAG,KAAK,CAAC,SAAS,EAAE,CAUxE;AAkDD,mFAAmF;AACnF,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,SAAS;sCAiCtD,GAAG;;EAqBP;AAED,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,SAAS,EAChB,OAAO,CAAC,EAAE,WAAW,CAAC,SAAS,CAAC,GAC/B,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,SAAS,CAAC,CAqBtD;AAED,wBAAgB,aAAa,CAC3B,KAAK,EAAE,SAAS,EAChB,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,KAAK,EAAE,GAAE,OAAO,CAAC,WAAW,CAAM,qBAYxD;AAED,wBAAgB,aAAa,CAC3B,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,SAAS,CAAA;CAAO,UAc3D"}
|
package/build/useScreens.js
CHANGED
|
@@ -81,16 +81,24 @@ function useSortedScreens(order) {
|
|
|
81
81
|
return react_1.default.useMemo(() => sorted.map((value) => routeToScreen(value.route, value.props)), [sorted]);
|
|
82
82
|
}
|
|
83
83
|
exports.useSortedScreens = useSortedScreens;
|
|
84
|
-
function fromImport({ ErrorBoundary, ...component }) {
|
|
84
|
+
function fromImport(value, { ErrorBoundary, ...component }) {
|
|
85
|
+
// If possible, add a more helpful display name for the component stack to improve debugging of React errors such as `Text strings must be rendered within a <Text> component.`.
|
|
86
|
+
if (component?.default && __DEV__) {
|
|
87
|
+
component.default.displayName ??= `${component.default.name ?? 'Route'}(${value.contextKey})`;
|
|
88
|
+
}
|
|
85
89
|
if (ErrorBoundary) {
|
|
90
|
+
const Wrapped = react_1.default.forwardRef((props, ref) => {
|
|
91
|
+
const children = react_1.default.createElement(component.default || EmptyRoute_1.EmptyRoute, {
|
|
92
|
+
...props,
|
|
93
|
+
ref,
|
|
94
|
+
});
|
|
95
|
+
return <Try_1.Try catch={ErrorBoundary}>{children}</Try_1.Try>;
|
|
96
|
+
});
|
|
97
|
+
if (__DEV__) {
|
|
98
|
+
Wrapped.displayName = `ErrorBoundary(${value.contextKey})`;
|
|
99
|
+
}
|
|
86
100
|
return {
|
|
87
|
-
default:
|
|
88
|
-
const children = react_1.default.createElement(component.default || EmptyRoute_1.EmptyRoute, {
|
|
89
|
-
...props,
|
|
90
|
-
ref,
|
|
91
|
-
});
|
|
92
|
-
return <Try_1.Try catch={ErrorBoundary}>{children}</Try_1.Try>;
|
|
93
|
-
}),
|
|
101
|
+
default: Wrapped,
|
|
94
102
|
};
|
|
95
103
|
}
|
|
96
104
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -102,11 +110,11 @@ function fromImport({ ErrorBoundary, ...component }) {
|
|
|
102
110
|
}
|
|
103
111
|
return { default: component.default };
|
|
104
112
|
}
|
|
105
|
-
function fromLoadedRoute(res) {
|
|
113
|
+
function fromLoadedRoute(value, res) {
|
|
106
114
|
if (!(res instanceof Promise)) {
|
|
107
|
-
return fromImport(res);
|
|
115
|
+
return fromImport(value, res);
|
|
108
116
|
}
|
|
109
|
-
return res.then(fromImport);
|
|
117
|
+
return res.then(fromImport.bind(null, value));
|
|
110
118
|
}
|
|
111
119
|
// TODO: Maybe there's a more React-y way to do this?
|
|
112
120
|
// Without this store, the process enters a recursive loop.
|
|
@@ -121,39 +129,36 @@ function getQualifiedRouteComponent(value) {
|
|
|
121
129
|
if (import_mode_1.default === 'lazy') {
|
|
122
130
|
ScreenComponent = react_1.default.lazy(async () => {
|
|
123
131
|
const res = value.loadRoute();
|
|
124
|
-
return fromLoadedRoute(res);
|
|
132
|
+
return fromLoadedRoute(value, res);
|
|
125
133
|
});
|
|
134
|
+
if (__DEV__) {
|
|
135
|
+
ScreenComponent.displayName = `AsyncRoute(${value.route})`;
|
|
136
|
+
}
|
|
126
137
|
}
|
|
127
138
|
else {
|
|
128
139
|
const res = value.loadRoute();
|
|
129
|
-
|
|
130
|
-
ScreenComponent = react_1.default.forwardRef((props, ref) => {
|
|
131
|
-
return <Component {...props} ref={ref}/>;
|
|
132
|
-
});
|
|
140
|
+
ScreenComponent = fromImport(value, res).default;
|
|
133
141
|
}
|
|
134
|
-
|
|
135
|
-
<ScreenComponent {...{
|
|
136
|
-
...props,
|
|
137
|
-
ref,
|
|
138
|
-
// Expose the template segment path, e.g. `(home)`, `[foo]`, `index`
|
|
139
|
-
// the intention is to make it possible to deduce shared routes.
|
|
140
|
-
segment: value.route,
|
|
141
|
-
}}/>
|
|
142
|
-
</react_1.default.Suspense>);
|
|
143
|
-
const QualifiedRoute = react_1.default.forwardRef(({
|
|
142
|
+
function BaseRoute({
|
|
144
143
|
// Remove these React Navigation props to
|
|
145
144
|
// enforce usage of expo-router hooks (where the query params are correct).
|
|
146
145
|
route, navigation,
|
|
147
146
|
// Pass all other props to the component
|
|
148
|
-
...props }
|
|
149
|
-
const loadable = getLoadable(props, ref);
|
|
147
|
+
...props }) {
|
|
150
148
|
return (<Route_1.Route node={value} route={route}>
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
149
|
+
<react_1.default.Suspense fallback={<SuspenseFallback_1.SuspenseFallback route={value}/>}>
|
|
150
|
+
<ScreenComponent {...props}
|
|
151
|
+
// Expose the template segment path, e.g. `(home)`, `[foo]`, `index`
|
|
152
|
+
// the intention is to make it possible to deduce shared routes.
|
|
153
|
+
segment={value.route}/>
|
|
154
|
+
</react_1.default.Suspense>
|
|
155
|
+
</Route_1.Route>);
|
|
156
|
+
}
|
|
157
|
+
if (__DEV__) {
|
|
158
|
+
BaseRoute.displayName = `Route(${value.route})`;
|
|
159
|
+
}
|
|
160
|
+
qualifiedStore.set(value, BaseRoute);
|
|
161
|
+
return BaseRoute;
|
|
157
162
|
}
|
|
158
163
|
exports.getQualifiedRouteComponent = getQualifiedRouteComponent;
|
|
159
164
|
function screenOptionsFactory(route, options) {
|
package/build/useScreens.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useScreens.js","sourceRoot":"","sources":["../src/useScreens.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;AAUb,kDAA0B;AAE1B,mCAA6F;AAC7F,gEAAoD;AACpD,6CAAsC;AAEtC,mDAAgD;AAChD,+DAA4D;AAC5D,qCAAkC;AAmClC,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,CACF,CAAC,EACC,IAAI,EACJ,QAAQ,EACR,aAAa,EACb,SAAS,EACT,OAAO,EACP,KAAK,EACL,mBAAmB,EAAE,QAAQ,GAC9B,EAAE,EAAE;QACH,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;YACnB,OAAO,CAAC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KAA2B,EAAE;IAEvD,OAAO,CACL,CAAC,mBAAM,CACL,IAAI,KAAK,CAAC,CACV,IAAI,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAClB,GAAG,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CACjB,KAAK,CAAC,CAAC,KAAK,CAAC,CACb,OAAO,CAAC,CAAC,oBAAoB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAC9C,YAAY,CAAC,CAAC,GAAG,EAAE,CAAC,0BAA0B,CAAC,KAAK,CAAC,CAAC,EACtD,CACH,CAAC;AACJ,CAAC;AAdD,sCAcC;AAED,SAAgB,aAAa,CAC3B,IAAY,EACZ,UAAwD,EAAE;IAE1D,OAAO,IAAI;SACR,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE;QACf,IAAI,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE;YAC9B,OAAO,OAAO,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,OAAO,CAAC;SACrE;aAAM,IAAI,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;YAClC,OAAO,OAAO,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC;SAC1D;aAAM;YACL,OAAO,OAAO,CAAC;SAChB;IACH,CAAC,CAAC;SACD,IAAI,CAAC,GAAG,CAAC,CAAC;AACf,CAAC;AAhBD,sCAgBC","sourcesContent":["'use client';\n\nimport type {\n EventMapBase,\n NavigationState,\n ParamListBase,\n RouteConfig,\n RouteProp,\n ScreenListeners,\n} from '@react-navigation/native';\nimport React from 'react';\n\nimport { LoadedRoute, Route, RouteNode, sortRoutesWithInitial, useRouteNode } from './Route';\nimport EXPO_ROUTER_IMPORT_MODE from './import-mode';\nimport { Screen } from './primitives';\nimport { UnknownOutputParams } from './types';\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 TState extends NavigationState = NavigationState,\n TEventMap 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?: Record<string, any>;\n options?:\n | TOptions\n | ((prop: { route: RouteProp<ParamListBase, string>; navigation: any }) => TOptions);\n\n listeners?:\n | ScreenListeners<TState, TEventMap>\n | ((prop: {\n route: RouteProp<ParamListBase, string>;\n navigation: any;\n }) => ScreenListeners<TState, TEventMap>);\n\n getId?: ({ params }: { params?: Record<string, any> }) => string | undefined;\n\n dangerouslySingular?: SingularOptions;\n};\n\nexport type SingularOptions =\n | boolean\n | ((name: string, params: UnknownOutputParams) => string | undefined);\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(\n ({\n name,\n redirect,\n initialParams,\n listeners,\n options,\n getId,\n dangerouslySingular: singular,\n }) => {\n if (!entries.length) {\n console.warn(\n `[Layout children]: Too many screens defined. Route \"${name}\" is extraneous.`\n );\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 if (getId) {\n console.warn(\n `Deprecated: prop 'getId' on screen ${name} is deprecated. Please rename the prop to 'dangerouslySingular'`\n );\n if (singular) {\n console.warn(\n `Screen ${name} cannot use both getId and dangerouslySingular together.`\n );\n }\n } else if (singular) {\n // If singular is set, use it as the getId function.\n if (typeof singular === 'string') {\n getId = () => singular;\n } else if (typeof singular === 'function' && name) {\n getId = (options) => singular(name, options.params || {});\n } else if (singular === true && name) {\n getId = (options) => getSingularId(name, options);\n }\n }\n\n return {\n route: match,\n props: { initialParams, listeners, options, getId },\n };\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\n return { default: component.default };\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 ScreenComponent: React.ForwardRefExoticComponent<React.RefAttributes<unknown>>;\n\n // TODO: This ensures sync doesn't use React.lazy, but it's not ideal.\n if (EXPO_ROUTER_IMPORT_MODE === 'lazy') {\n ScreenComponent = React.lazy(async () => {\n const res = value.loadRoute();\n return fromLoadedRoute(res) as Promise<{\n default: React.ComponentType<any>;\n }>;\n });\n } else {\n const res = value.loadRoute();\n const Component = fromImport(res).default as React.ComponentType<any>;\n ScreenComponent = React.forwardRef((props, ref) => {\n return <Component {...props} ref={ref} />;\n });\n }\n\n const getLoadable = (props: any, ref: any) => (\n <React.Suspense fallback={<SuspenseFallback route={value} />}>\n <ScreenComponent\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\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 (\n <Route node={value} route={route}>\n {loadable}\n </Route>\n );\n }\n );\n\n QualifiedRoute.displayName = `Route(${value.route})`;\n\n qualifiedStore.set(value, QualifiedRoute);\n return QualifiedRoute;\n}\n\nexport function screenOptionsFactory(\n route: RouteNode,\n options?: ScreenProps['options']\n): RouteConfig<any, any, any, any, any, any>['options'] {\n return (args) => {\n // Only eager load generated components\n const staticOptions = route.generated ? route.loadRoute()?.getNavOptions : null;\n const staticResult = 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.tabBarItemStyle = { display: 'none' };\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}\n\nexport function routeToScreen(\n route: RouteNode,\n { options, getId, ...props }: Partial<ScreenProps> = {}\n) {\n return (\n <Screen\n {...props}\n name={route.route}\n key={route.route}\n getId={getId}\n options={screenOptionsFactory(route, options)}\n getComponent={() => getQualifiedRouteComponent(route)}\n />\n );\n}\n\nexport function getSingularId(\n name: string,\n options: { params?: Record<string, any> | undefined } = {}\n) {\n return name\n .split('/')\n .map((segment) => {\n if (segment.startsWith('[...')) {\n return options.params?.[segment.slice(4, -1)]?.join('/') || segment;\n } else if (segment.startsWith('[')) {\n return options.params?.[segment.slice(1, -1)] || segment;\n } else {\n return segment;\n }\n })\n .join('/');\n}\n"]}
|
|
1
|
+
{"version":3,"file":"useScreens.js","sourceRoot":"","sources":["../src/useScreens.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;AAUb,kDAA0B;AAE1B,mCAA6F;AAC7F,gEAAoD;AACpD,6CAAsC;AAEtC,mDAAgD;AAChD,+DAA4D;AAC5D,qCAAkC;AAmClC,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,CACF,CAAC,EACC,IAAI,EACJ,QAAQ,EACR,aAAa,EACb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;AACf,CAAC;AAhBD,sCAgBC","sourcesContent":["'use client';\n\nimport type {\n EventMapBase,\n NavigationState,\n ParamListBase,\n RouteConfig,\n RouteProp,\n ScreenListeners,\n} from '@react-navigation/native';\nimport React from 'react';\n\nimport { LoadedRoute, Route, RouteNode, sortRoutesWithInitial, useRouteNode } from './Route';\nimport EXPO_ROUTER_IMPORT_MODE from './import-mode';\nimport { Screen } from './primitives';\nimport { UnknownOutputParams } from './types';\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 TState extends NavigationState = NavigationState,\n TEventMap 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?: Record<string, any>;\n options?:\n | TOptions\n | ((prop: { route: RouteProp<ParamListBase, string>; navigation: any }) => TOptions);\n\n listeners?:\n | ScreenListeners<TState, TEventMap>\n | ((prop: {\n route: RouteProp<ParamListBase, string>;\n navigation: any;\n }) => ScreenListeners<TState, TEventMap>);\n\n getId?: ({ params }: { params?: Record<string, any> }) => string | undefined;\n\n dangerouslySingular?: SingularOptions;\n};\n\nexport type SingularOptions =\n | boolean\n | ((name: string, params: UnknownOutputParams) => string | undefined);\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(\n ({\n name,\n redirect,\n initialParams,\n listeners,\n options,\n getId,\n dangerouslySingular: singular,\n }) => {\n if (!entries.length) {\n console.warn(\n `[Layout children]: Too many screens defined. Route \"${name}\" is extraneous.`\n );\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 if (getId) {\n console.warn(\n `Deprecated: prop 'getId' on screen ${name} is deprecated. Please rename the prop to 'dangerouslySingular'`\n );\n if (singular) {\n console.warn(\n `Screen ${name} cannot use both getId and dangerouslySingular together.`\n );\n }\n } else if (singular) {\n // If singular is set, use it as the getId function.\n if (typeof singular === 'string') {\n getId = () => singular;\n } else if (typeof singular === 'function' && name) {\n getId = (options) => singular(name, options.params || {});\n } else if (singular === true && name) {\n getId = (options) => getSingularId(name, options);\n }\n }\n\n return {\n route: match,\n props: { initialParams, listeners, options, getId },\n };\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(value: RouteNode, { ErrorBoundary, ...component }: LoadedRoute) {\n // If possible, add a more helpful display name for the component stack to improve debugging of React errors such as `Text strings must be rendered within a <Text> component.`.\n if (component?.default && __DEV__) {\n component.default.displayName ??= `${component.default.name ?? 'Route'}(${value.contextKey})`;\n }\n\n if (ErrorBoundary) {\n const Wrapped = 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 if (__DEV__) {\n Wrapped.displayName = `ErrorBoundary(${value.contextKey})`;\n }\n\n return {\n default: Wrapped,\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\n return { default: component.default };\n}\n\nfunction fromLoadedRoute(value: RouteNode, res: LoadedRoute) {\n if (!(res instanceof Promise)) {\n return fromImport(value, res);\n }\n\n return res.then(fromImport.bind(null, value));\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 ScreenComponent:\n | React.ForwardRefExoticComponent<React.RefAttributes<unknown>>\n | React.ComponentType<any>;\n\n // TODO: This ensures sync doesn't use React.lazy, but it's not ideal.\n if (EXPO_ROUTER_IMPORT_MODE === 'lazy') {\n ScreenComponent = React.lazy(async () => {\n const res = value.loadRoute();\n return fromLoadedRoute(value, res) as Promise<{\n default: React.ComponentType<any>;\n }>;\n });\n\n if (__DEV__) {\n ScreenComponent.displayName = `AsyncRoute(${value.route})`;\n }\n } else {\n const res = value.loadRoute();\n ScreenComponent = fromImport(value, res).default!;\n }\n function BaseRoute({\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 return (\n <Route node={value} route={route}>\n <React.Suspense fallback={<SuspenseFallback route={value} />}>\n <ScreenComponent\n {...props}\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 </React.Suspense>\n </Route>\n );\n }\n\n if (__DEV__) {\n BaseRoute.displayName = `Route(${value.route})`;\n }\n\n qualifiedStore.set(value, BaseRoute);\n return BaseRoute;\n}\n\nexport function screenOptionsFactory(\n route: RouteNode,\n options?: ScreenProps['options']\n): RouteConfig<any, any, any, any, any, any>['options'] {\n return (args) => {\n // Only eager load generated components\n const staticOptions = route.generated ? route.loadRoute()?.getNavOptions : null;\n const staticResult = 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.tabBarItemStyle = { display: 'none' };\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}\n\nexport function routeToScreen(\n route: RouteNode,\n { options, getId, ...props }: Partial<ScreenProps> = {}\n) {\n return (\n <Screen\n {...props}\n name={route.route}\n key={route.route}\n getId={getId}\n options={screenOptionsFactory(route, options)}\n getComponent={() => getQualifiedRouteComponent(route)}\n />\n );\n}\n\nexport function getSingularId(\n name: string,\n options: { params?: Record<string, any> | undefined } = {}\n) {\n return name\n .split('/')\n .map((segment) => {\n if (segment.startsWith('[...')) {\n return options.params?.[segment.slice(4, -1)]?.join('/') || segment;\n } else if (segment.startsWith('[')) {\n return options.params?.[segment.slice(1, -1)] || segment;\n } else {\n return segment;\n }\n })\n .join('/');\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-router",
|
|
3
|
-
"version": "5.0.0
|
|
3
|
+
"version": "5.0.1-preview.0",
|
|
4
4
|
"description": "Expo Router is a file-based router for React Native and web applications.",
|
|
5
5
|
"author": "650 Industries, Inc.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -104,8 +104,8 @@
|
|
|
104
104
|
"tsd": "^0.28.1"
|
|
105
105
|
},
|
|
106
106
|
"dependencies": {
|
|
107
|
-
"@expo/metro-runtime": "
|
|
108
|
-
"@expo/server": "^0.
|
|
107
|
+
"@expo/metro-runtime": "5.0.0",
|
|
108
|
+
"@expo/server": "^0.6.0",
|
|
109
109
|
"@radix-ui/react-slot": "1.0.1",
|
|
110
110
|
"@react-navigation/bottom-tabs": "^7.3.0",
|
|
111
111
|
"@react-navigation/native": "^7.0.17",
|
|
@@ -119,5 +119,5 @@
|
|
|
119
119
|
"server-only": "^0.0.1",
|
|
120
120
|
"shallowequal": "^1.1.0"
|
|
121
121
|
},
|
|
122
|
-
"gitHead": "
|
|
122
|
+
"gitHead": "8d9f9581dfb14225bb7cb4e9e37b7f04c9b2f199"
|
|
123
123
|
}
|
package/plugin/options.json
CHANGED
|
@@ -74,6 +74,39 @@
|
|
|
74
74
|
"partialRouteTypes": {
|
|
75
75
|
"description": "Enable or disable partial route type generation. Defaults to `true`.",
|
|
76
76
|
"type": "boolean"
|
|
77
|
+
},
|
|
78
|
+
"redirects": {
|
|
79
|
+
"description": "Enable static redirects. Defaults to `true`.",
|
|
80
|
+
"type": "array",
|
|
81
|
+
"uniqueItems": true,
|
|
82
|
+
"items": {
|
|
83
|
+
"type": "object",
|
|
84
|
+
"required": ["source", "destination"],
|
|
85
|
+
"properties": {
|
|
86
|
+
"source": {
|
|
87
|
+
"description": "The previous file path that this route should redirect from",
|
|
88
|
+
"type": "string"
|
|
89
|
+
},
|
|
90
|
+
"destination": {
|
|
91
|
+
"description": "The target file path that this route should redirect to",
|
|
92
|
+
"type": "string"
|
|
93
|
+
},
|
|
94
|
+
"temporary": {
|
|
95
|
+
"description": "Whether the redirect is temporary or permanent. Defaults to `false`.",
|
|
96
|
+
"type": "boolean",
|
|
97
|
+
"default": false
|
|
98
|
+
},
|
|
99
|
+
"methods": {
|
|
100
|
+
"description": "HTTP methods that should be redirected. Omit to redirect all methods.",
|
|
101
|
+
"type": "array",
|
|
102
|
+
"uniqueItems": true,
|
|
103
|
+
"items": {
|
|
104
|
+
"type": "string",
|
|
105
|
+
"enum": ["GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS", "HEAD"]
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
77
110
|
}
|
|
78
111
|
},
|
|
79
112
|
"additionalProperties": false
|