@expo/router-server 56.0.8 → 56.0.10
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/getNamedParametrizedRoute.d.ts +12 -0
- package/build/getNamedParametrizedRoute.d.ts.map +1 -0
- package/build/getNamedParametrizedRoute.js +127 -0
- package/build/getNamedParametrizedRoute.js.map +1 -0
- package/build/getServerManifest.d.ts +0 -14
- package/build/getServerManifest.d.ts.map +1 -1
- package/build/getServerManifest.js +2 -131
- package/build/getServerManifest.js.map +1 -1
- package/build/rsc/middleware.d.ts +1 -1
- package/build/rsc/middleware.d.ts.map +1 -1
- package/build/rsc/middleware.js +4 -14
- package/build/rsc/middleware.js.map +1 -1
- package/build/rsc/path.d.ts +0 -17
- package/build/rsc/path.d.ts.map +1 -1
- package/build/rsc/path.js +1 -91
- package/build/rsc/path.js.map +1 -1
- package/build/rsc/router/createPages.d.ts +35 -0
- package/build/rsc/router/createPages.d.ts.map +1 -0
- package/build/rsc/router/createPages.js +258 -0
- package/build/rsc/router/createPages.js.map +1 -0
- package/build/rsc/router/defineRouter.d.ts +10 -6
- package/build/rsc/router/defineRouter.d.ts.map +1 -1
- package/build/rsc/router/defineRouter.js +38 -29
- package/build/rsc/router/defineRouter.js.map +1 -1
- package/build/rsc/router/expo-definedRouter.d.ts +3 -1
- package/build/rsc/router/expo-definedRouter.d.ts.map +1 -1
- package/build/rsc/router/expo-definedRouter.js +90 -94
- package/build/rsc/router/expo-definedRouter.js.map +1 -1
- package/build/rsc/router/index.d.ts +13 -0
- package/build/rsc/router/index.d.ts.map +1 -0
- package/build/rsc/router/index.js +13 -0
- package/build/rsc/router/index.js.map +1 -0
- package/build/rsc/router/noopRouter.d.ts +2 -1
- package/build/rsc/router/noopRouter.d.ts.map +1 -1
- package/build/rsc/router/noopRouter.js +4 -3
- package/build/rsc/router/noopRouter.js.map +1 -1
- package/build/rsc/rsc-renderer.d.ts +2 -0
- package/build/rsc/rsc-renderer.d.ts.map +1 -1
- package/build/rsc/rsc-renderer.js +34 -7
- package/build/rsc/rsc-renderer.js.map +1 -1
- package/build/rsc/server.d.ts +2 -3
- package/build/rsc/server.d.ts.map +1 -1
- package/build/rsc/server.js +7 -34
- package/build/rsc/server.js.map +1 -1
- package/build/utils/html.d.ts.map +1 -1
- package/build/utils/html.js +11 -5
- package/build/utils/html.js.map +1 -1
- package/package.json +8 -8
- package/build/rsc/router/create-expo-pages.d.ts +0 -20
- package/build/rsc/router/create-expo-pages.d.ts.map +0 -1
- package/build/rsc/router/create-expo-pages.js +0 -21
- package/build/rsc/router/create-expo-pages.js.map +0 -1
- package/build/rsc/router/create-pages.d.ts +0 -80
- package/build/rsc/router/create-pages.d.ts.map +0 -1
- package/build/rsc/router/create-pages.js +0 -232
- package/build/rsc/router/create-pages.js.map +0 -1
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare function getNamedParametrizedRoute(route: string): {
|
|
2
|
+
namedParameterizedRoute: string;
|
|
3
|
+
routeKeys: Record<string, string>;
|
|
4
|
+
/** Cleaned route-key names whose captures should be split into arrays (wildcards). */
|
|
5
|
+
wildcardKeys: Set<string>;
|
|
6
|
+
};
|
|
7
|
+
export declare function parseParameter(param: string): {
|
|
8
|
+
name: string;
|
|
9
|
+
repeat: boolean;
|
|
10
|
+
optional: boolean;
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=getNamedParametrizedRoute.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getNamedParametrizedRoute.d.ts","sourceRoot":"","sources":["../src/getNamedParametrizedRoute.ts"],"names":[],"mappings":"AA0CA,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,MAAM,GAAG;IACxD,uBAAuB,EAAE,MAAM,CAAC;IAChC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,sFAAsF;IACtF,YAAY,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CAC3B,CA6DA;AAcD,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM;;;;EAgB3C"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getNamedParametrizedRoute = getNamedParametrizedRoute;
|
|
4
|
+
exports.parseParameter = parseParameter;
|
|
5
|
+
const routing_1 = require("expo-router/internal/routing");
|
|
6
|
+
/**
|
|
7
|
+
* Builds a function to generate a minimal routeKey using only a-z and minimal
|
|
8
|
+
* number of characters.
|
|
9
|
+
*/
|
|
10
|
+
function buildGetSafeRouteKey() {
|
|
11
|
+
let currentCharCode = 96; // Starting one before 'a' to make the increment logic simpler
|
|
12
|
+
let currentLength = 1;
|
|
13
|
+
return () => {
|
|
14
|
+
let result = '';
|
|
15
|
+
let incrementNext = true;
|
|
16
|
+
// Iterate from right to left to build the key
|
|
17
|
+
for (let i = 0; i < currentLength; i++) {
|
|
18
|
+
if (incrementNext) {
|
|
19
|
+
currentCharCode++;
|
|
20
|
+
if (currentCharCode > 122) {
|
|
21
|
+
currentCharCode = 97; // Reset to 'a'
|
|
22
|
+
incrementNext = true; // Continue to increment the next character
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
incrementNext = false;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
result = String.fromCharCode(currentCharCode) + result;
|
|
29
|
+
}
|
|
30
|
+
// If all characters are 'z', increase the length of the key
|
|
31
|
+
if (incrementNext) {
|
|
32
|
+
currentLength++;
|
|
33
|
+
currentCharCode = 96; // This will make the next key start with 'a'
|
|
34
|
+
}
|
|
35
|
+
return result;
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function removeTrailingSlash(route) {
|
|
39
|
+
return route.replace(/\/$/, '') || '/';
|
|
40
|
+
}
|
|
41
|
+
function getNamedParametrizedRoute(route) {
|
|
42
|
+
const segments = removeTrailingSlash(route).slice(1).split('/');
|
|
43
|
+
const getSafeRouteKey = buildGetSafeRouteKey();
|
|
44
|
+
const routeKeys = {};
|
|
45
|
+
const wildcardKeys = new Set();
|
|
46
|
+
const namedParameterizedRoute = segments
|
|
47
|
+
.map((segment, index) => {
|
|
48
|
+
if (segment === '+not-found' && index === segments.length - 1) {
|
|
49
|
+
segment = '[...not-found]';
|
|
50
|
+
}
|
|
51
|
+
if (/^\[.*\]$/.test(segment)) {
|
|
52
|
+
const { name, optional, repeat } = parseParameter(segment);
|
|
53
|
+
// replace any non-word characters since they can break
|
|
54
|
+
// the named regex
|
|
55
|
+
let cleanedKey = name.replace(/\W/g, '');
|
|
56
|
+
let invalidKey = false;
|
|
57
|
+
// check if the key is still invalid and fallback to using a known
|
|
58
|
+
// safe key
|
|
59
|
+
if (cleanedKey.length === 0 || cleanedKey.length > 30) {
|
|
60
|
+
invalidKey = true;
|
|
61
|
+
}
|
|
62
|
+
if (!isNaN(parseInt(cleanedKey.slice(0, 1), 10))) {
|
|
63
|
+
invalidKey = true;
|
|
64
|
+
}
|
|
65
|
+
// Prevent duplicates after sanitizing the key
|
|
66
|
+
if (cleanedKey in routeKeys) {
|
|
67
|
+
invalidKey = true;
|
|
68
|
+
}
|
|
69
|
+
if (invalidKey) {
|
|
70
|
+
cleanedKey = getSafeRouteKey();
|
|
71
|
+
}
|
|
72
|
+
routeKeys[cleanedKey] = name;
|
|
73
|
+
if (repeat)
|
|
74
|
+
wildcardKeys.add(cleanedKey);
|
|
75
|
+
return repeat
|
|
76
|
+
? optional
|
|
77
|
+
? `(?:/(?<${cleanedKey}>.+?))?`
|
|
78
|
+
: `/(?<${cleanedKey}>.+?)`
|
|
79
|
+
: `/(?<${cleanedKey}>[^/]+?)`;
|
|
80
|
+
}
|
|
81
|
+
else if (/^\(.*\)$/.test(segment)) {
|
|
82
|
+
const groupName = (0, routing_1.matchGroupName)(segment)
|
|
83
|
+
.split(',')
|
|
84
|
+
.map((group) => group.trim())
|
|
85
|
+
.filter(Boolean);
|
|
86
|
+
if (groupName.length > 1) {
|
|
87
|
+
const optionalSegment = `\\((?:${groupName.map(escapeStringRegexp).join('|')})\\)`;
|
|
88
|
+
// Make section optional
|
|
89
|
+
return `(?:/${optionalSegment})?`;
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
// Use simpler regex for single groups
|
|
93
|
+
return `(?:/${escapeStringRegexp(segment)})?`;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
return `/${escapeStringRegexp(segment)}`;
|
|
98
|
+
}
|
|
99
|
+
})
|
|
100
|
+
.join('');
|
|
101
|
+
return { namedParameterizedRoute, routeKeys, wildcardKeys };
|
|
102
|
+
}
|
|
103
|
+
// regexp is based on https://github.com/sindresorhus/escape-string-regexp
|
|
104
|
+
const reHasRegExp = /[|\\{}()[\]^$+*?.-]/;
|
|
105
|
+
const reReplaceRegExp = /[|\\{}()[\]^$+*?.-]/g;
|
|
106
|
+
function escapeStringRegexp(str) {
|
|
107
|
+
// see also: https://github.com/lodash/lodash/blob/2da024c3b4f9947a48517639de7560457cd4ec6c/escapeRegExp.js#L23
|
|
108
|
+
if (reHasRegExp.test(str)) {
|
|
109
|
+
return str.replace(reReplaceRegExp, '\\$&');
|
|
110
|
+
}
|
|
111
|
+
return str;
|
|
112
|
+
}
|
|
113
|
+
function parseParameter(param) {
|
|
114
|
+
let repeat = false;
|
|
115
|
+
let optional = false;
|
|
116
|
+
let name = param;
|
|
117
|
+
if (/^\[.*\]$/.test(name)) {
|
|
118
|
+
optional = true;
|
|
119
|
+
name = name.slice(1, -1);
|
|
120
|
+
}
|
|
121
|
+
if (/^\.\.\./.test(name)) {
|
|
122
|
+
repeat = true;
|
|
123
|
+
name = name.slice(3);
|
|
124
|
+
}
|
|
125
|
+
return { name, repeat, optional };
|
|
126
|
+
}
|
|
127
|
+
//# sourceMappingURL=getNamedParametrizedRoute.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getNamedParametrizedRoute.js","sourceRoot":"","sources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AAG,CAAC,OAAO,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC;IAC9C,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAgB,cAAc,CAAC,KAAa;IAC1C,IAAI,MAAM,GAAG,KAAK,CAAC;IACnB,IAAI,QAAQ,GAAG,KAAK,CAAC;IACrB,IAAI,IAAI,GAAG,KAAK,CAAC;IAEjB,IAAI,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QAC1B,QAAQ,GAAG,IAAI,CAAC;QAChB,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAC3B,CAAC;IAED,IAAI,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QACzB,MAAM,GAAG,IAAI,CAAC;QACd,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACvB,CAAC;IAED,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;AACpC,CAAC","sourcesContent":["import { matchGroupName } from 'expo-router/internal/routing';\n\n/**\n * Builds a function to generate a minimal routeKey using only a-z and minimal\n * number of characters.\n */\nfunction buildGetSafeRouteKey() {\n let currentCharCode = 96; // Starting one before 'a' to make the increment logic simpler\n let currentLength = 1;\n\n return () => {\n let result = '';\n let incrementNext = true;\n\n // Iterate from right to left to build the key\n for (let i = 0; i < currentLength; i++) {\n if (incrementNext) {\n currentCharCode++;\n if (currentCharCode > 122) {\n currentCharCode = 97; // Reset to 'a'\n incrementNext = true; // Continue to increment the next character\n } else {\n incrementNext = false;\n }\n }\n result = String.fromCharCode(currentCharCode) + result;\n }\n\n // If all characters are 'z', increase the length of the key\n if (incrementNext) {\n currentLength++;\n currentCharCode = 96; // This will make the next key start with 'a'\n }\n\n return result;\n };\n}\n\nfunction removeTrailingSlash(route: string): string {\n return route.replace(/\\/$/, '') || '/';\n}\n\nexport function getNamedParametrizedRoute(route: string): {\n namedParameterizedRoute: string;\n routeKeys: Record<string, string>;\n /** Cleaned route-key names whose captures should be split into arrays (wildcards). */\n wildcardKeys: Set<string>;\n} {\n const segments = removeTrailingSlash(route).slice(1).split('/');\n const getSafeRouteKey = buildGetSafeRouteKey();\n const routeKeys: Record<string, string> = {};\n const wildcardKeys = new Set<string>();\n const namedParameterizedRoute = segments\n .map((segment, index) => {\n if (segment === '+not-found' && index === segments.length - 1) {\n segment = '[...not-found]';\n }\n if (/^\\[.*\\]$/.test(segment)) {\n const { name, optional, repeat } = parseParameter(segment);\n // replace any non-word characters since they can break\n // the named regex\n let cleanedKey = name.replace(/\\W/g, '');\n let invalidKey = false;\n\n // check if the key is still invalid and fallback to using a known\n // safe key\n if (cleanedKey.length === 0 || cleanedKey.length > 30) {\n invalidKey = true;\n }\n if (!isNaN(parseInt(cleanedKey.slice(0, 1), 10))) {\n invalidKey = true;\n }\n\n // Prevent duplicates after sanitizing the key\n if (cleanedKey in routeKeys) {\n invalidKey = true;\n }\n\n if (invalidKey) {\n cleanedKey = getSafeRouteKey();\n }\n\n routeKeys[cleanedKey] = name;\n if (repeat) wildcardKeys.add(cleanedKey);\n return repeat\n ? optional\n ? `(?:/(?<${cleanedKey}>.+?))?`\n : `/(?<${cleanedKey}>.+?)`\n : `/(?<${cleanedKey}>[^/]+?)`;\n } else if (/^\\(.*\\)$/.test(segment)) {\n const groupName = matchGroupName(segment)!\n .split(',')\n .map((group) => group.trim())\n .filter(Boolean);\n if (groupName.length > 1) {\n const optionalSegment = `\\\\((?:${groupName.map(escapeStringRegexp).join('|')})\\\\)`;\n // Make section optional\n return `(?:/${optionalSegment})?`;\n } else {\n // Use simpler regex for single groups\n return `(?:/${escapeStringRegexp(segment)})?`;\n }\n } else {\n return `/${escapeStringRegexp(segment)}`;\n }\n })\n .join('');\n return { namedParameterizedRoute, routeKeys, wildcardKeys };\n}\n\n// regexp is based on https://github.com/sindresorhus/escape-string-regexp\nconst reHasRegExp = /[|\\\\{}()[\\]^$+*?.-]/;\nconst reReplaceRegExp = /[|\\\\{}()[\\]^$+*?.-]/g;\n\nfunction escapeStringRegexp(str: string) {\n // see also: https://github.com/lodash/lodash/blob/2da024c3b4f9947a48517639de7560457cd4ec6c/escapeRegExp.js#L23\n if (reHasRegExp.test(str)) {\n return str.replace(reReplaceRegExp, '\\\\$&');\n }\n return str;\n}\n\nexport function parseParameter(param: string) {\n let repeat = false;\n let optional = false;\n let name = param;\n\n if (/^\\[.*\\]$/.test(name)) {\n optional = true;\n name = name.slice(1, -1);\n }\n\n if (/^\\.\\.\\./.test(name)) {\n repeat = true;\n name = name.slice(3);\n }\n\n return { name, repeat, optional };\n}\n"]}
|
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright © 2023 650 Industries.
|
|
3
|
-
* Copyright © 2023 Vercel, Inc.
|
|
4
|
-
*
|
|
5
|
-
* This source code is licensed under the MIT license found in the
|
|
6
|
-
* LICENSE file in the root directory of this source tree.
|
|
7
|
-
*
|
|
8
|
-
* Based on https://github.com/vercel/next.js/blob/1df2686bc9964f1a86c444701fa5cbf178669833/packages/next/src/shared/lib/router/utils/route-regex.ts
|
|
9
|
-
*/
|
|
10
1
|
import { type RouteNode } from 'expo-router/internal/routing';
|
|
11
2
|
import type { RoutesManifest } from 'expo-server/private';
|
|
12
3
|
export interface Group {
|
|
@@ -22,10 +13,5 @@ type GetServerManifestOptions = {
|
|
|
22
13
|
headers?: Record<string, string | string[]>;
|
|
23
14
|
};
|
|
24
15
|
export declare function getServerManifest(route: RouteNode | null, options: GetServerManifestOptions | undefined): RoutesManifest<string>;
|
|
25
|
-
export declare function parseParameter(param: string): {
|
|
26
|
-
name: string;
|
|
27
|
-
repeat: boolean;
|
|
28
|
-
optional: boolean;
|
|
29
|
-
};
|
|
30
16
|
export {};
|
|
31
17
|
//# sourceMappingURL=getServerManifest.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getServerManifest.d.ts","sourceRoot":"","sources":["../src/getServerManifest.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"getServerManifest.d.ts","sourceRoot":"","sources":["../src/getServerManifest.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6B,KAAK,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAEzF,OAAO,KAAK,EAAa,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAIrE,MAAM,WAAW,KAAK;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAC9B,EAAE,EAAE,MAAM,CAAC;CACZ;AA2BD,KAAK,wBAAwB,GAAG;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAAC;CAC7C,CAAC;AAGF,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,SAAS,GAAG,IAAI,EACvB,OAAO,EAAE,wBAAwB,GAAG,SAAS,GAC5C,cAAc,CAAC,MAAM,CAAC,CAuGxB"}
|
|
@@ -1,18 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getServerManifest = getServerManifest;
|
|
4
|
-
exports.parseParameter = parseParameter;
|
|
5
|
-
/**
|
|
6
|
-
* Copyright © 2023 650 Industries.
|
|
7
|
-
* Copyright © 2023 Vercel, Inc.
|
|
8
|
-
*
|
|
9
|
-
* This source code is licensed under the MIT license found in the
|
|
10
|
-
* LICENSE file in the root directory of this source tree.
|
|
11
|
-
*
|
|
12
|
-
* Based on https://github.com/vercel/next.js/blob/1df2686bc9964f1a86c444701fa5cbf178669833/packages/next/src/shared/lib/router/utils/route-regex.ts
|
|
13
|
-
*/
|
|
14
4
|
const routing_1 = require("expo-router/internal/routing");
|
|
15
5
|
const utils_1 = require("expo-router/internal/utils");
|
|
6
|
+
const getNamedParametrizedRoute_1 = require("./getNamedParametrizedRoute");
|
|
16
7
|
function isNotFoundRoute(route) {
|
|
17
8
|
return route.dynamic != null && (route.dynamic[route.dynamic.length - 1]?.notFound ?? false);
|
|
18
9
|
}
|
|
@@ -120,7 +111,7 @@ function getMatchableManifestForPaths(paths) {
|
|
|
120
111
|
});
|
|
121
112
|
}
|
|
122
113
|
function getNamedRouteRegex(normalizedRoute, page, file) {
|
|
123
|
-
const result = getNamedParametrizedRoute(normalizedRoute);
|
|
114
|
+
const result = (0, getNamedParametrizedRoute_1.getNamedParametrizedRoute)(normalizedRoute);
|
|
124
115
|
return {
|
|
125
116
|
file,
|
|
126
117
|
page,
|
|
@@ -128,126 +119,6 @@ function getNamedRouteRegex(normalizedRoute, page, file) {
|
|
|
128
119
|
routeKeys: result.routeKeys,
|
|
129
120
|
};
|
|
130
121
|
}
|
|
131
|
-
/**
|
|
132
|
-
* Builds a function to generate a minimal routeKey using only a-z and minimal
|
|
133
|
-
* number of characters.
|
|
134
|
-
*/
|
|
135
|
-
function buildGetSafeRouteKey() {
|
|
136
|
-
let currentCharCode = 96; // Starting one before 'a' to make the increment logic simpler
|
|
137
|
-
let currentLength = 1;
|
|
138
|
-
return () => {
|
|
139
|
-
let result = '';
|
|
140
|
-
let incrementNext = true;
|
|
141
|
-
// Iterate from right to left to build the key
|
|
142
|
-
for (let i = 0; i < currentLength; i++) {
|
|
143
|
-
if (incrementNext) {
|
|
144
|
-
currentCharCode++;
|
|
145
|
-
if (currentCharCode > 122) {
|
|
146
|
-
currentCharCode = 97; // Reset to 'a'
|
|
147
|
-
incrementNext = true; // Continue to increment the next character
|
|
148
|
-
}
|
|
149
|
-
else {
|
|
150
|
-
incrementNext = false;
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
result = String.fromCharCode(currentCharCode) + result;
|
|
154
|
-
}
|
|
155
|
-
// If all characters are 'z', increase the length of the key
|
|
156
|
-
if (incrementNext) {
|
|
157
|
-
currentLength++;
|
|
158
|
-
currentCharCode = 96; // This will make the next key start with 'a'
|
|
159
|
-
}
|
|
160
|
-
return result;
|
|
161
|
-
};
|
|
162
|
-
}
|
|
163
|
-
function removeTrailingSlash(route) {
|
|
164
|
-
return route.replace(/\/$/, '') || '/';
|
|
165
|
-
}
|
|
166
|
-
function getNamedParametrizedRoute(route) {
|
|
167
|
-
const segments = removeTrailingSlash(route).slice(1).split('/');
|
|
168
|
-
const getSafeRouteKey = buildGetSafeRouteKey();
|
|
169
|
-
const routeKeys = {};
|
|
170
|
-
return {
|
|
171
|
-
namedParameterizedRoute: segments
|
|
172
|
-
.map((segment, index) => {
|
|
173
|
-
if (segment === '+not-found' && index === segments.length - 1) {
|
|
174
|
-
segment = '[...not-found]';
|
|
175
|
-
}
|
|
176
|
-
if (/^\[.*\]$/.test(segment)) {
|
|
177
|
-
const { name, optional, repeat } = parseParameter(segment);
|
|
178
|
-
// replace any non-word characters since they can break
|
|
179
|
-
// the named regex
|
|
180
|
-
let cleanedKey = name.replace(/\W/g, '');
|
|
181
|
-
let invalidKey = false;
|
|
182
|
-
// check if the key is still invalid and fallback to using a known
|
|
183
|
-
// safe key
|
|
184
|
-
if (cleanedKey.length === 0 || cleanedKey.length > 30) {
|
|
185
|
-
invalidKey = true;
|
|
186
|
-
}
|
|
187
|
-
if (!isNaN(parseInt(cleanedKey.slice(0, 1), 10))) {
|
|
188
|
-
invalidKey = true;
|
|
189
|
-
}
|
|
190
|
-
// Prevent duplicates after sanitizing the key
|
|
191
|
-
if (cleanedKey in routeKeys) {
|
|
192
|
-
invalidKey = true;
|
|
193
|
-
}
|
|
194
|
-
if (invalidKey) {
|
|
195
|
-
cleanedKey = getSafeRouteKey();
|
|
196
|
-
}
|
|
197
|
-
routeKeys[cleanedKey] = name;
|
|
198
|
-
return repeat
|
|
199
|
-
? optional
|
|
200
|
-
? `(?:/(?<${cleanedKey}>.+?))?`
|
|
201
|
-
: `/(?<${cleanedKey}>.+?)`
|
|
202
|
-
: `/(?<${cleanedKey}>[^/]+?)`;
|
|
203
|
-
}
|
|
204
|
-
else if (/^\(.*\)$/.test(segment)) {
|
|
205
|
-
const groupName = (0, routing_1.matchGroupName)(segment)
|
|
206
|
-
.split(',')
|
|
207
|
-
.map((group) => group.trim())
|
|
208
|
-
.filter(Boolean);
|
|
209
|
-
if (groupName.length > 1) {
|
|
210
|
-
const optionalSegment = `\\((?:${groupName.map(escapeStringRegexp).join('|')})\\)`;
|
|
211
|
-
// Make section optional
|
|
212
|
-
return `(?:/${optionalSegment})?`;
|
|
213
|
-
}
|
|
214
|
-
else {
|
|
215
|
-
// Use simpler regex for single groups
|
|
216
|
-
return `(?:/${escapeStringRegexp(segment)})?`;
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
else {
|
|
220
|
-
return `/${escapeStringRegexp(segment)}`;
|
|
221
|
-
}
|
|
222
|
-
})
|
|
223
|
-
.join(''),
|
|
224
|
-
routeKeys,
|
|
225
|
-
};
|
|
226
|
-
}
|
|
227
|
-
// regexp is based on https://github.com/sindresorhus/escape-string-regexp
|
|
228
|
-
const reHasRegExp = /[|\\{}()[\]^$+*?.-]/;
|
|
229
|
-
const reReplaceRegExp = /[|\\{}()[\]^$+*?.-]/g;
|
|
230
|
-
function escapeStringRegexp(str) {
|
|
231
|
-
// see also: https://github.com/lodash/lodash/blob/2da024c3b4f9947a48517639de7560457cd4ec6c/escapeRegExp.js#L23
|
|
232
|
-
if (reHasRegExp.test(str)) {
|
|
233
|
-
return str.replace(reReplaceRegExp, '\\$&');
|
|
234
|
-
}
|
|
235
|
-
return str;
|
|
236
|
-
}
|
|
237
|
-
function parseParameter(param) {
|
|
238
|
-
let repeat = false;
|
|
239
|
-
let optional = false;
|
|
240
|
-
let name = param;
|
|
241
|
-
if (/^\[.*\]$/.test(name)) {
|
|
242
|
-
optional = true;
|
|
243
|
-
name = name.slice(1, -1);
|
|
244
|
-
}
|
|
245
|
-
if (/^\.\.\./.test(name)) {
|
|
246
|
-
repeat = true;
|
|
247
|
-
name = name.slice(3);
|
|
248
|
-
}
|
|
249
|
-
return { name, repeat, optional };
|
|
250
|
-
}
|
|
251
122
|
function getNormalizedContextKey(contextKey) {
|
|
252
123
|
return (0, routing_1.getContextKey)(contextKey).replace(/\/index$/, '') ?? '/';
|
|
253
124
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getServerManifest.js","sourceRoot":"","sources":["../src/getServerManifest.ts"],"names":[],"mappings":";;AA2DA,8CA0GC;AAuJD,wCAgBC;AA5UD;;;;;;;;GAQG;AACH,0DAKsC;AACtC,sDAAkE;AAclE,SAAS,eAAe,CAAC,KAAgB;IACvC,OAAO,KAAK,CAAC,OAAO,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,QAAQ,IAAI,KAAK,CAAC,CAAC;AAC/F,CAAC;AAED,SAAS,QAAQ,CAAI,GAAQ,EAAE,GAAwB;IACrD,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,OAAO,GAAG,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE;QACzB,MAAM,EAAE,GAAG,GAAG,CAAC,IAAI,CAAC,CAAC;QACrB,IAAI,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC;YACjB,OAAO,KAAK,CAAC;QACf,CAAC;QACD,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACb,OAAO,IAAI,CAAC;IACd,CAAC,CAAC,CAAC;AACL,CAAC;AAeD,yFAAyF;AACzF,SAAgB,iBAAiB,CAC/B,KAAuB,EACvB,OAA6C;IAE7C,SAAS,YAAY,CAAC,KAAgB,EAAE,cAAsB,EAAE;QAC9D,kGAAkG;QAClG,MAAM,aAAa,GAAG,CAAC,WAAW,EAAE,KAAK,CAAC,K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C;AAED,SAAS,uBAAuB,CAAC,UAAkB;IACjD,OAAO,IAAA,uBAAa,EAAC,UAAU,CAAC,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC;AAClE,CAAC","sourcesContent":["/**\n * Copyright © 2023 650 Industries.\n * Copyright © 2023 Vercel, Inc.\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 * Based on https://github.com/vercel/next.js/blob/1df2686bc9964f1a86c444701fa5cbf178669833/packages/next/src/shared/lib/router/utils/route-regex.ts\n */\nimport {\n getContextKey,\n matchGroupName,\n sortRoutes,\n type RouteNode,\n} from 'expo-router/internal/routing';\nimport { shouldLinkExternally } from 'expo-router/internal/utils';\nimport type { RouteInfo, RoutesManifest } from 'expo-server/private';\n\nexport interface Group {\n pos: number;\n repeat: boolean;\n optional: boolean;\n}\n\nexport interface RouteRegex {\n groups: Record<string, Group>;\n re: RegExp;\n}\n\nfunction isNotFoundRoute(route: RouteNode): boolean {\n return route.dynamic != null && (route.dynamic[route.dynamic.length - 1]?.notFound ?? false);\n}\n\nfunction uniqueBy<T>(arr: T[], key: (item: T) => string): T[] {\n const seen = new Set<string>();\n return arr.filter((item) => {\n const id = key(item);\n if (seen.has(id)) {\n return false;\n }\n seen.add(id);\n return true;\n });\n}\n\ntype FlatNode = {\n /** The context key, normalized to remove `/index` */\n normalizedContextKey: string;\n /** The complete route path, including all parent route paths */\n absoluteRoutePath: string;\n /** The route node that maps to this flattened node */\n route: RouteNode;\n};\n\ntype GetServerManifestOptions = {\n headers?: Record<string, string | string[]>;\n};\n\n// Given a nested route tree, return a flattened array of all routes that can be matched.\nexport function getServerManifest(\n route: RouteNode | null,\n options: GetServerManifestOptions | undefined\n): RoutesManifest<string> {\n function getFlatNodes(route: RouteNode, parentRoute: string = ''): FlatNode[] {\n // Use a recreated route instead of contextKey because we duplicate nodes to support array syntax.\n const absoluteRoute = [parentRoute, route.route].filter(Boolean).join('/');\n\n if (route.children.length) {\n return route.children.map((child) => getFlatNodes(child, absoluteRoute)).flat();\n }\n\n // API Routes are handled differently to HTML routes because they have no nested behavior.\n // An HTML route can be different based on parent segments due to layout routes, therefore multiple\n // copies should be rendered. However, an API route is always the same regardless of parent segments.\n let key: string;\n if (route.type.includes('api')) {\n key = getNormalizedContextKey(route.contextKey);\n } else {\n key = getNormalizedContextKey(absoluteRoute);\n }\n\n return [\n {\n normalizedContextKey: key,\n absoluteRoutePath: '/' + absoluteRoute,\n route,\n },\n ];\n }\n\n // Remove duplicates from the runtime manifest which expands array syntax.\n const flat = route\n ? getFlatNodes(route)\n .sort(({ route: a }, { route: b }) => sortRoutes(b, a))\n .reverse()\n : [];\n\n const apiRoutes = uniqueBy(\n flat.filter(({ route }) => route.type === 'api'),\n ({ normalizedContextKey }) => normalizedContextKey\n );\n\n const otherRoutes = uniqueBy(\n flat.filter(\n ({ route }) =>\n route.type === 'route' ||\n (route.type === 'rewrite' && (route.methods === undefined || route.methods.includes('GET')))\n ),\n ({ normalizedContextKey }) => normalizedContextKey\n );\n\n const redirects = uniqueBy(\n flat.filter(({ route }) => route.type === 'redirect'),\n ({ normalizedContextKey }) => normalizedContextKey\n )\n .map((redirect) => {\n // TODO(@hassankhan): ENG-16577\n // For external redirects, use `destinationContextKey` as the destination URL\n if (shouldLinkExternally(redirect.route.destinationContextKey!)) {\n redirect.absoluteRoutePath = redirect.route.destinationContextKey!;\n } else {\n redirect.absoluteRoutePath =\n flat.find(({ route }) => route.contextKey === redirect.route.destinationContextKey)\n ?.normalizedContextKey ?? '/';\n }\n\n return redirect;\n })\n .reverse();\n\n const rewrites = uniqueBy(\n flat.filter(({ route }) => route.type === 'rewrite'),\n ({ normalizedContextKey }) => normalizedContextKey\n )\n .map((rewrite) => {\n rewrite.absoluteRoutePath =\n flat.find(({ route }) => route.contextKey === rewrite.route.destinationContextKey)\n ?.normalizedContextKey ?? '/';\n\n return rewrite;\n })\n .reverse();\n\n const standardRoutes = otherRoutes.filter(({ route }) => !isNotFoundRoute(route));\n const notFoundRoutes = otherRoutes.filter(({ route }) => isNotFoundRoute(route));\n\n const manifest: RoutesManifest<string> = {\n apiRoutes: getMatchableManifestForPaths(apiRoutes),\n htmlRoutes: getMatchableManifestForPaths(standardRoutes),\n notFoundRoutes: getMatchableManifestForPaths(notFoundRoutes),\n redirects: getMatchableManifestForPaths(redirects),\n rewrites: getMatchableManifestForPaths(rewrites),\n };\n\n if (route?.middleware) {\n manifest.middleware = {\n file: route.middleware.contextKey,\n };\n }\n\n if (options?.headers) {\n manifest.headers = options.headers;\n }\n\n return manifest;\n}\n\nfunction getMatchableManifestForPaths(paths: FlatNode[]): RouteInfo<string>[] {\n return paths.map(({ normalizedContextKey, absoluteRoutePath, route }) => {\n const matcher = getNamedRouteRegex(normalizedContextKey, absoluteRoutePath, route.contextKey);\n\n if (route.generated) {\n matcher.generated = true;\n }\n\n if (route.permanent) {\n matcher.permanent = true;\n }\n\n if (route.methods) {\n matcher.methods = route.methods;\n }\n\n return matcher;\n });\n}\n\nfunction getNamedRouteRegex(\n normalizedRoute: string,\n page: string,\n file: string\n): RouteInfo<string> {\n const result = getNamedParametrizedRoute(normalizedRoute);\n return {\n file,\n page,\n namedRegex: `^${result.namedParameterizedRoute}(?:/)?$`,\n routeKeys: result.routeKeys,\n };\n}\n\n/**\n * Builds a function to generate a minimal routeKey using only a-z and minimal\n * number of characters.\n */\nfunction buildGetSafeRouteKey() {\n let currentCharCode = 96; // Starting one before 'a' to make the increment logic simpler\n let currentLength = 1;\n\n return () => {\n let result = '';\n let incrementNext = true;\n\n // Iterate from right to left to build the key\n for (let i = 0; i < currentLength; i++) {\n if (incrementNext) {\n currentCharCode++;\n if (currentCharCode > 122) {\n currentCharCode = 97; // Reset to 'a'\n incrementNext = true; // Continue to increment the next character\n } else {\n incrementNext = false;\n }\n }\n result = String.fromCharCode(currentCharCode) + result;\n }\n\n // If all characters are 'z', increase the length of the key\n if (incrementNext) {\n currentLength++;\n currentCharCode = 96; // This will make the next key start with 'a'\n }\n\n return result;\n };\n}\n\nfunction removeTrailingSlash(route: string): string {\n return route.replace(/\\/$/, '') || '/';\n}\n\nfunction getNamedParametrizedRoute(route: string) {\n const segments = removeTrailingSlash(route).slice(1).split('/');\n const getSafeRouteKey = buildGetSafeRouteKey();\n const routeKeys: Record<string, string> = {};\n return {\n namedParameterizedRoute: segments\n .map((segment, index) => {\n if (segment === '+not-found' && index === segments.length - 1) {\n segment = '[...not-found]';\n }\n if (/^\\[.*\\]$/.test(segment)) {\n const { name, optional, repeat } = parseParameter(segment);\n // replace any non-word characters since they can break\n // the named regex\n let cleanedKey = name.replace(/\\W/g, '');\n let invalidKey = false;\n\n // check if the key is still invalid and fallback to using a known\n // safe key\n if (cleanedKey.length === 0 || cleanedKey.length > 30) {\n invalidKey = true;\n }\n if (!isNaN(parseInt(cleanedKey.slice(0, 1), 10))) {\n invalidKey = true;\n }\n\n // Prevent duplicates after sanitizing the key\n if (cleanedKey in routeKeys) {\n invalidKey = true;\n }\n\n if (invalidKey) {\n cleanedKey = getSafeRouteKey();\n }\n\n routeKeys[cleanedKey] = name;\n return repeat\n ? optional\n ? `(?:/(?<${cleanedKey}>.+?))?`\n : `/(?<${cleanedKey}>.+?)`\n : `/(?<${cleanedKey}>[^/]+?)`;\n } else if (/^\\(.*\\)$/.test(segment)) {\n const groupName = matchGroupName(segment)!\n .split(',')\n .map((group) => group.trim())\n .filter(Boolean);\n if (groupName.length > 1) {\n const optionalSegment = `\\\\((?:${groupName.map(escapeStringRegexp).join('|')})\\\\)`;\n // Make section optional\n return `(?:/${optionalSegment})?`;\n } else {\n // Use simpler regex for single groups\n return `(?:/${escapeStringRegexp(segment)})?`;\n }\n } else {\n return `/${escapeStringRegexp(segment)}`;\n }\n })\n .join(''),\n routeKeys,\n };\n}\n\n// regexp is based on https://github.com/sindresorhus/escape-string-regexp\nconst reHasRegExp = /[|\\\\{}()[\\]^$+*?.-]/;\nconst reReplaceRegExp = /[|\\\\{}()[\\]^$+*?.-]/g;\n\nfunction escapeStringRegexp(str: string) {\n // see also: https://github.com/lodash/lodash/blob/2da024c3b4f9947a48517639de7560457cd4ec6c/escapeRegExp.js#L23\n if (reHasRegExp.test(str)) {\n return str.replace(reReplaceRegExp, '\\\\$&');\n }\n return str;\n}\n\nexport function parseParameter(param: string) {\n let repeat = false;\n let optional = false;\n let name = param;\n\n if (/^\\[.*\\]$/.test(name)) {\n optional = true;\n name = name.slice(1, -1);\n }\n\n if (/^\\.\\.\\./.test(name)) {\n repeat = true;\n name = name.slice(3);\n }\n\n return { name, repeat, optional };\n}\n\nfunction getNormalizedContextKey(contextKey: string): string {\n return getContextKey(contextKey).replace(/\\/index$/, '') ?? '/';\n}\n"]}
|
|
1
|
+
{"version":3,"file":"getServerManifest.js","sourceRoot":"","sources":["../src/getServerManifest.ts"],"names":[],"mappings":";;AA+CA,8CA0GC;AAzJD,0DAAyF;AACzF,sDAAkE;AAGlE,2EAAwE;AAaxE,SAAS,eAAe,CAAC,KAAgB;IACvC,OAAO,KAAK,CAAC,OAAO,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,QAAQ,IAAI,KAAK,CAAC,CAAC;AAC/F,CAAC;AAED,SAAS,QAAQ,CAAI,GAAQ,EAAE,GAAwB;IACrD,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,OAAO,GAAG,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE;QACzB,MAAM,EAAE,GAAG,GAAG,CAAC,IAAI,CAAC,CAAC;QACrB,IAAI,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC;YACjB,OAAO,KAAK,CAAC;QACf,CAAC;QACD,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACb,OAAO,IAAI,CAAC;IACd,CAAC,CAAC,CAAC;AACL,CAAC;AAeD,yFAAyF;AACzF,SAAgB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B,QAAQ,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IACrC,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,SAAS,4BAA4B,CAAC,KAAiB;IACrD,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,KAAK,EAAE,EAAE,EAAE;QACtE,MAAM,OAAO,GAAG,kBAAkB,CAAC,oBAAoB,EAAE,iBAAiB,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;QAE9F,IAAI,KAAK,CAAC,SAAS,EAAE,CAAC;YACpB,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC;QAC3B,CAAC;QAED,IAAI,KAAK,CAAC,SAAS,EAAE,CAAC;YACpB,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC;QAC3B,CAAC;QAED,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;YAClB,OAAO,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;QAClC,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,kBAAkB,CACzB,eAAuB,EACvB,IAAY,EACZ,IAAY;IAEZ,MAAM,MAAM,GAAG,IAAA,qDAAyB,EAAC,eAAe,CAAC,CAAC;IAC1D,OAAO;QACL,IAAI;QACJ,IAAI;QACJ,UAAU,EAAE,IAAI,MAAM,CAAC,uBAAuB,SAAS;QACvD,SAAS,EAAE,MAAM,CAAC,SAAS;KAC5B,CAAC;AACJ,CAAC;AAED,SAAS,uBAAuB,CAAC,UAAkB;IACjD,OAAO,IAAA,uBAAa,EAAC,UAAU,CAAC,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC;AAClE,CAAC","sourcesContent":["import { getContextKey, sortRoutes, type RouteNode } from 'expo-router/internal/routing';\nimport { shouldLinkExternally } from 'expo-router/internal/utils';\nimport type { RouteInfo, RoutesManifest } from 'expo-server/private';\n\nimport { getNamedParametrizedRoute } from './getNamedParametrizedRoute';\n\nexport interface Group {\n pos: number;\n repeat: boolean;\n optional: boolean;\n}\n\nexport interface RouteRegex {\n groups: Record<string, Group>;\n re: RegExp;\n}\n\nfunction isNotFoundRoute(route: RouteNode): boolean {\n return route.dynamic != null && (route.dynamic[route.dynamic.length - 1]?.notFound ?? false);\n}\n\nfunction uniqueBy<T>(arr: T[], key: (item: T) => string): T[] {\n const seen = new Set<string>();\n return arr.filter((item) => {\n const id = key(item);\n if (seen.has(id)) {\n return false;\n }\n seen.add(id);\n return true;\n });\n}\n\ntype FlatNode = {\n /** The context key, normalized to remove `/index` */\n normalizedContextKey: string;\n /** The complete route path, including all parent route paths */\n absoluteRoutePath: string;\n /** The route node that maps to this flattened node */\n route: RouteNode;\n};\n\ntype GetServerManifestOptions = {\n headers?: Record<string, string | string[]>;\n};\n\n// Given a nested route tree, return a flattened array of all routes that can be matched.\nexport function getServerManifest(\n route: RouteNode | null,\n options: GetServerManifestOptions | undefined\n): RoutesManifest<string> {\n function getFlatNodes(route: RouteNode, parentRoute: string = ''): FlatNode[] {\n // Use a recreated route instead of contextKey because we duplicate nodes to support array syntax.\n const absoluteRoute = [parentRoute, route.route].filter(Boolean).join('/');\n\n if (route.children.length) {\n return route.children.map((child) => getFlatNodes(child, absoluteRoute)).flat();\n }\n\n // API Routes are handled differently to HTML routes because they have no nested behavior.\n // An HTML route can be different based on parent segments due to layout routes, therefore multiple\n // copies should be rendered. However, an API route is always the same regardless of parent segments.\n let key: string;\n if (route.type.includes('api')) {\n key = getNormalizedContextKey(route.contextKey);\n } else {\n key = getNormalizedContextKey(absoluteRoute);\n }\n\n return [\n {\n normalizedContextKey: key,\n absoluteRoutePath: '/' + absoluteRoute,\n route,\n },\n ];\n }\n\n // Remove duplicates from the runtime manifest which expands array syntax.\n const flat = route\n ? getFlatNodes(route)\n .sort(({ route: a }, { route: b }) => sortRoutes(b, a))\n .reverse()\n : [];\n\n const apiRoutes = uniqueBy(\n flat.filter(({ route }) => route.type === 'api'),\n ({ normalizedContextKey }) => normalizedContextKey\n );\n\n const otherRoutes = uniqueBy(\n flat.filter(\n ({ route }) =>\n route.type === 'route' ||\n (route.type === 'rewrite' && (route.methods === undefined || route.methods.includes('GET')))\n ),\n ({ normalizedContextKey }) => normalizedContextKey\n );\n\n const redirects = uniqueBy(\n flat.filter(({ route }) => route.type === 'redirect'),\n ({ normalizedContextKey }) => normalizedContextKey\n )\n .map((redirect) => {\n // TODO(@hassankhan): ENG-16577\n // For external redirects, use `destinationContextKey` as the destination URL\n if (shouldLinkExternally(redirect.route.destinationContextKey!)) {\n redirect.absoluteRoutePath = redirect.route.destinationContextKey!;\n } else {\n redirect.absoluteRoutePath =\n flat.find(({ route }) => route.contextKey === redirect.route.destinationContextKey)\n ?.normalizedContextKey ?? '/';\n }\n\n return redirect;\n })\n .reverse();\n\n const rewrites = uniqueBy(\n flat.filter(({ route }) => route.type === 'rewrite'),\n ({ normalizedContextKey }) => normalizedContextKey\n )\n .map((rewrite) => {\n rewrite.absoluteRoutePath =\n flat.find(({ route }) => route.contextKey === rewrite.route.destinationContextKey)\n ?.normalizedContextKey ?? '/';\n\n return rewrite;\n })\n .reverse();\n\n const standardRoutes = otherRoutes.filter(({ route }) => !isNotFoundRoute(route));\n const notFoundRoutes = otherRoutes.filter(({ route }) => isNotFoundRoute(route));\n\n const manifest: RoutesManifest<string> = {\n apiRoutes: getMatchableManifestForPaths(apiRoutes),\n htmlRoutes: getMatchableManifestForPaths(standardRoutes),\n notFoundRoutes: getMatchableManifestForPaths(notFoundRoutes),\n redirects: getMatchableManifestForPaths(redirects),\n rewrites: getMatchableManifestForPaths(rewrites),\n };\n\n if (route?.middleware) {\n manifest.middleware = {\n file: route.middleware.contextKey,\n };\n }\n\n if (options?.headers) {\n manifest.headers = options.headers;\n }\n\n return manifest;\n}\n\nfunction getMatchableManifestForPaths(paths: FlatNode[]): RouteInfo<string>[] {\n return paths.map(({ normalizedContextKey, absoluteRoutePath, route }) => {\n const matcher = getNamedRouteRegex(normalizedContextKey, absoluteRoutePath, route.contextKey);\n\n if (route.generated) {\n matcher.generated = true;\n }\n\n if (route.permanent) {\n matcher.permanent = true;\n }\n\n if (route.methods) {\n matcher.methods = route.methods;\n }\n\n return matcher;\n });\n}\n\nfunction getNamedRouteRegex(\n normalizedRoute: string,\n page: string,\n file: string\n): RouteInfo<string> {\n const result = getNamedParametrizedRoute(normalizedRoute);\n return {\n file,\n page,\n namedRegex: `^${result.namedParameterizedRoute}(?:/)?$`,\n routeKeys: result.routeKeys,\n };\n}\n\nfunction getNormalizedContextKey(contextKey: string): string {\n return getContextKey(contextKey).replace(/\\/index$/, '') ?? '/';\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { RenderRscArgs } from 'expo-server/private';
|
|
2
2
|
type ImportMap = {
|
|
3
|
-
router: () => Promise<
|
|
3
|
+
router: () => Promise<import('./router').RouterModule>;
|
|
4
4
|
};
|
|
5
5
|
export declare function renderRscWithImportsAsync(distFolder: string, imports: ImportMap, { body, platform, searchParams, config, method, input, contentType, headers }: RenderRscArgs): Promise<ReadableStream<any>>;
|
|
6
6
|
export declare function renderRscAsync(distFolder: string, args: RenderRscArgs): Promise<ReadableStream<any>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../src/rsc/middleware.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../src/rsc/middleware.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAmDzD,KAAK,SAAS,GAAG;IACf,MAAM,EAAE,MAAM,OAAO,CAAC,OAAO,UAAU,EAAE,YAAY,CAAC,CAAC;CACxD,CAAC;AAEF,wBAAsB,yBAAyB,CAC7C,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,SAAS,EAClB,EAAE,IAAI,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,EAAE,aAAa,GAC3F,OAAO,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAqE9B;AAED,wBAAsB,cAAc,CAClC,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,aAAa,GAClB,OAAO,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAY9B"}
|
package/build/rsc/middleware.js
CHANGED
|
@@ -18,22 +18,11 @@ const node_path_1 = __importDefault(require("node:path"));
|
|
|
18
18
|
const rsc_renderer_1 = require("./rsc-renderer");
|
|
19
19
|
const debug_1 = require("../utils/debug");
|
|
20
20
|
const debug = (0, debug_1.createDebug)('expo:router:server:rsc-renderer');
|
|
21
|
-
// Tracking the implementation in expo/cli's MetroBundlerDevServer
|
|
22
|
-
const rscRenderContext = new Map();
|
|
23
21
|
function serverRequire(...targetOutputModulePath) {
|
|
24
22
|
// NOTE(@kitten): This `__dirname` will be located in the output file system, e.g. `dist/server/*`
|
|
25
23
|
const filePath = node_path_1.default.join(__dirname, ...targetOutputModulePath);
|
|
26
24
|
return $$require_external(filePath);
|
|
27
25
|
}
|
|
28
|
-
function getRscRenderContext(platform) {
|
|
29
|
-
// NOTE(EvanBacon): We memoize this now that there's a persistent server storage cache for Server Actions.
|
|
30
|
-
if (rscRenderContext.has(platform)) {
|
|
31
|
-
return rscRenderContext.get(platform);
|
|
32
|
-
}
|
|
33
|
-
const context = {};
|
|
34
|
-
rscRenderContext.set(platform, context);
|
|
35
|
-
return context;
|
|
36
|
-
}
|
|
37
26
|
function getServerActionManifest(_distFolder, platform) {
|
|
38
27
|
const filePath = `../../rsc/${platform}/action-manifest.js`;
|
|
39
28
|
return serverRequire(filePath);
|
|
@@ -43,12 +32,11 @@ function getSSRManifest(_distFolder, platform) {
|
|
|
43
32
|
return serverRequire(filePath);
|
|
44
33
|
}
|
|
45
34
|
async function renderRscWithImportsAsync(distFolder, imports, { body, platform, searchParams, config, method, input, contentType, headers }) {
|
|
46
|
-
globalThis.__expo_platform_header = platform;
|
|
47
35
|
if (method === 'POST' && !body) {
|
|
48
36
|
throw new Error('Server request must be provided when method is POST (server actions)');
|
|
49
37
|
}
|
|
50
|
-
|
|
51
|
-
context
|
|
38
|
+
// Must stay per-request; sharing this object across renders would leak headers between concurrent requests.
|
|
39
|
+
const context = { __expo_requestHeaders: headers };
|
|
52
40
|
const router = await imports.router();
|
|
53
41
|
const entries = router.default({
|
|
54
42
|
redirects: expo_constants_1.default.expoConfig?.extra?.router?.redirects,
|
|
@@ -61,6 +49,8 @@ async function renderRscWithImportsAsync(distFolder, imports, { body, platform,
|
|
|
61
49
|
context,
|
|
62
50
|
config,
|
|
63
51
|
input,
|
|
52
|
+
method,
|
|
53
|
+
headers,
|
|
64
54
|
contentType,
|
|
65
55
|
decodedBody: searchParams.get('x-expo-params'),
|
|
66
56
|
}, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middleware.js","sourceRoot":"","sources":["../../src/rsc/middleware.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"middleware.js","sourceRoot":"","sources":["../../src/rsc/middleware.ts"],"names":[],"mappings":";;;;;AAgEA,8DAyEC;AAED,wCAeC;AA1JD;;;;;;GAMG;AACH,2GAA2G;AAC3G,oEAAuC;AAEvC,0DAA6B;AAE7B,iDAA2C;AAC3C,0CAA6C;AAI7C,MAAM,KAAK,GAAG,IAAA,mBAAW,EAAC,iCAAiC,CAAC,CAAC;AAE7D,SAAS,aAAa,CAAU,GAAG,sBAAgC;IACjE,kGAAkG;IAClG,MAAM,QAAQ,GAAG,mBAAI,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,sBAAsB,CAAC,CAAC;IACjE,OAAO,kBAAkB,CAAC,QAAQ,CAAC,CAAC;AACtC,CAAC;AAED,SAAS,uB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M,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,4FAA4F;YAC5F,OAAO,aAAa,CAAC,aAAa,QAAQ,YAAY,CAAC,CAAC;QAC1D,CAAC;KACF,EACD,IAAI,CACL,CAAC;AACJ,CAAC","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 Constants from 'expo-constants';\nimport type { RenderRscArgs } from 'expo-server/private';\nimport path from 'node:path';\n\nimport { renderRsc } from './rsc-renderer';\nimport { createDebug } from '../utils/debug';\n\ndeclare const $$require_external: typeof require;\n\nconst debug = createDebug('expo:router:server:rsc-renderer');\n\nfunction serverRequire<T = any>(...targetOutputModulePath: string[]): T {\n // NOTE(@kitten): This `__dirname` will be located in the output file system, e.g. `dist/server/*`\n const filePath = path.join(__dirname, ...targetOutputModulePath);\n return $$require_external(filePath);\n}\n\nfunction getServerActionManifest(\n _distFolder: string,\n platform: string\n): Record<\n // Input ID\n string,\n [\n // Metro ID\n string,\n // Chunk location.\n string,\n ]\n> {\n const filePath = `../../rsc/${platform}/action-manifest.js`;\n return serverRequire(filePath);\n}\n\nfunction getSSRManifest(\n _distFolder: string,\n platform: string\n): Record<\n // Input ID\n string,\n [\n // Metro ID\n string,\n // Chunk location.\n string,\n ]\n> {\n const filePath = `../../rsc/${platform}/ssr-manifest.js`;\n return serverRequire(filePath);\n}\n\n// The import map allows us to use external modules from different bundling contexts.\ntype ImportMap = {\n router: () => Promise<import('./router').RouterModule>;\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 if (method === 'POST' && !body) {\n throw new Error('Server request must be provided when method is POST (server actions)');\n }\n\n // Must stay per-request; sharing this object across renders would leak headers between concurrent requests.\n const context = { __expo_requestHeaders: headers };\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 = getSSRManifest(distFolder, platform);\n const actionManifest = getServerActionManifest(distFolder, platform);\n return renderRsc(\n {\n body: body ?? undefined,\n context,\n config,\n input,\n method,\n headers,\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 const actionManifestFile = actionManifest[file];\n\n if (actionManifestFile == null) {\n throw new Error(\n `Could not find file in server action manifest: ${file}. ${JSON.stringify(actionManifest)}`\n );\n }\n\n const [id, chunk] = actionManifestFile;\n return {\n id,\n chunks: chunk ? [chunk] : [],\n };\n }\n\n const ssrManifestFile = ssrManifest[file];\n\n if (ssrManifestFile == null) {\n throw new Error(`Could not find file in SSR manifest: ${file}`);\n }\n\n const [id, chunk] = ssrManifestFile;\n return {\n id,\n chunks: chunk ? [chunk] : [],\n };\n },\n async loadServerModuleRsc(file) {\n debug('loadServerModuleRsc', file);\n // NOTE(@kitten): [WORKAROUND] Assumes __dirname is at `dist/server/_expo/functions/_flight`\n return serverRequire('../../../', file);\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 // NOTE(@kitten): [WORKAROUND] Assumes __dirname is at `dist/server/_expo/functions/_flight`\n return serverRequire(`../../rsc/${platform}/router.js`);\n },\n },\n args\n );\n}\n"]}
|
package/build/rsc/path.d.ts
CHANGED
|
@@ -14,21 +14,4 @@ export declare const filePathToFileURL: (filePath: string) => string;
|
|
|
14
14
|
export declare const fileURLToFilePath: (fileURL: string) => string;
|
|
15
15
|
export declare const joinPath: (...paths: string[]) => string;
|
|
16
16
|
export declare const extname: (filePath: string) => string;
|
|
17
|
-
export type PathSpecItem = {
|
|
18
|
-
type: 'literal';
|
|
19
|
-
name: string;
|
|
20
|
-
} | {
|
|
21
|
-
type: 'group';
|
|
22
|
-
name?: string;
|
|
23
|
-
} | {
|
|
24
|
-
type: 'wildcard';
|
|
25
|
-
name?: string;
|
|
26
|
-
};
|
|
27
|
-
export type PathSpec = readonly PathSpecItem[];
|
|
28
|
-
export declare const parsePathWithSlug: (path: string) => PathSpec;
|
|
29
|
-
export declare const getPathMapping: (pathSpec: PathSpec, pathname: string) => Record<string, string | string[]> | null;
|
|
30
|
-
/**
|
|
31
|
-
* Transform a path spec to a regular expression.
|
|
32
|
-
*/
|
|
33
|
-
export declare const path2regexp: (path: PathSpec) => string;
|
|
34
17
|
//# sourceMappingURL=path.d.ts.map
|
package/build/rsc/path.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../../src/rsc/path.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAYH,eAAO,MAAM,wBAAwB,GAAI,UAAU,MAAM,WAQxD,CAAC;AAEF,eAAO,MAAM,0BAA0B,GAAI,UAAU,MAAM,WAK1D,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,UAAU,MAAM,WAAoC,CAAC;AAEvF,yDAAyD;AACzD,eAAO,MAAM,iBAAiB,GAAI,SAAS,MAAM,WAahD,CAAC;AAGF,eAAO,MAAM,QAAQ,GAAI,GAAG,OAAO,MAAM,EAAE,WAmB1C,CAAC;AAEF,eAAO,MAAM,OAAO,GAAI,UAAU,MAAM,WAGvC,CAAC
|
|
1
|
+
{"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../../src/rsc/path.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAYH,eAAO,MAAM,wBAAwB,GAAI,UAAU,MAAM,WAQxD,CAAC;AAEF,eAAO,MAAM,0BAA0B,GAAI,UAAU,MAAM,WAK1D,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,UAAU,MAAM,WAAoC,CAAC;AAEvF,yDAAyD;AACzD,eAAO,MAAM,iBAAiB,GAAI,SAAS,MAAM,WAahD,CAAC;AAGF,eAAO,MAAM,QAAQ,GAAI,GAAG,OAAO,MAAM,EAAE,WAmB1C,CAAC;AAEF,eAAO,MAAM,OAAO,GAAI,UAAU,MAAM,WAGvC,CAAC"}
|