@edgeone/opennextjs-pages 0.1.5-beta.1 → 0.1.5-beta.3
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/dist/build/routes.js
CHANGED
|
@@ -89,6 +89,46 @@ function getDataRoutes(dataRoutes, basePath = "") {
|
|
|
89
89
|
}
|
|
90
90
|
return routes;
|
|
91
91
|
}
|
|
92
|
+
function getStaticRoutes(staticRoutes, basePath = "") {
|
|
93
|
+
const routes = [];
|
|
94
|
+
for (const route of staticRoutes) {
|
|
95
|
+
if (route.page.startsWith("/_")) {
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
if (route.namedRegex) {
|
|
99
|
+
let src = convertNamedRegexToSrc(route.namedRegex, basePath);
|
|
100
|
+
if (src) {
|
|
101
|
+
src = src.replace(/\(\?:\/\)\?\$$/, "$");
|
|
102
|
+
routes.push({ src });
|
|
103
|
+
}
|
|
104
|
+
} else if (route.regex) {
|
|
105
|
+
if (isRE2Compatible(route.regex)) {
|
|
106
|
+
let src = route.regex;
|
|
107
|
+
if (basePath && !src.startsWith(`^${basePath}`)) {
|
|
108
|
+
src = src.replace(/^\^/, `^${basePath}`);
|
|
109
|
+
}
|
|
110
|
+
src = src.replace(/\(\?:\/\)\?\$$/, "$");
|
|
111
|
+
routes.push({ src });
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return routes;
|
|
116
|
+
}
|
|
117
|
+
function getApiRoutes(appPathsManifest, basePath = "") {
|
|
118
|
+
if (!appPathsManifest) {
|
|
119
|
+
return [];
|
|
120
|
+
}
|
|
121
|
+
const routes = [];
|
|
122
|
+
for (const routePath of Object.keys(appPathsManifest)) {
|
|
123
|
+
if (routePath.includes("/api/") && routePath.endsWith("/route")) {
|
|
124
|
+
const apiPath = routePath.replace(/\/route$/, "");
|
|
125
|
+
const escapedPath = apiPath.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
126
|
+
const src = `^${basePath}${escapedPath}$`;
|
|
127
|
+
routes.push({ src });
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return routes;
|
|
131
|
+
}
|
|
92
132
|
async function getMiddlewareConfig(ctx) {
|
|
93
133
|
try {
|
|
94
134
|
const manifest = await ctx.getMiddlewareManifest();
|
|
@@ -199,6 +239,8 @@ var createRouteMeta = async (ctx) => {
|
|
|
199
239
|
}
|
|
200
240
|
const dynamicRoutes = routesManifest?.dynamicRoutes || [];
|
|
201
241
|
const dataRoutes = routesManifest?.dataRoutes || [];
|
|
242
|
+
const staticRoutes = routesManifest?.staticRoutes || [];
|
|
243
|
+
const appPathsManifest = await ctx.getAppPathsManifest?.() || null;
|
|
202
244
|
const buildId = getBuildId(ctx);
|
|
203
245
|
const staticCacheRegex = buildId ? `^${basePath}/_next/static/(?:[^/]+/pages|pages|chunks|runtime|css|image|media|${buildId.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")})/.+` : `^${basePath}/_next/static/(?:[^/]+/pages|pages|chunks|runtime|css|image|media)/.+`;
|
|
204
246
|
routes.push({
|
|
@@ -237,11 +279,12 @@ var createRouteMeta = async (ctx) => {
|
|
|
237
279
|
}
|
|
238
280
|
if (isAppRouter) {
|
|
239
281
|
const rscVary = "RSC, Next-Router-State-Tree, Next-Router-Prefetch, Next-Router-Segment-Prefetch";
|
|
282
|
+
const rscContentType = "text/x-component";
|
|
240
283
|
routes.push({
|
|
241
284
|
src: `^${basePath}/?$`,
|
|
242
285
|
has: [{ type: "header", key: "rsc", value: "1" }],
|
|
243
286
|
dest: `${basePath}/index.rsc`,
|
|
244
|
-
headers: { vary: rscVary },
|
|
287
|
+
headers: { vary: rscVary, "content-type": rscContentType },
|
|
245
288
|
continue: true
|
|
246
289
|
});
|
|
247
290
|
routes.push({
|
|
@@ -249,7 +292,7 @@ var createRouteMeta = async (ctx) => {
|
|
|
249
292
|
exclude: "\\.rsc/?$",
|
|
250
293
|
has: [{ type: "header", key: "rsc", value: "1" }],
|
|
251
294
|
dest: `${basePath}/$1.rsc`,
|
|
252
|
-
headers: { vary: rscVary },
|
|
295
|
+
headers: { vary: rscVary, "content-type": rscContentType },
|
|
253
296
|
continue: true
|
|
254
297
|
});
|
|
255
298
|
}
|
|
@@ -284,12 +327,19 @@ var createRouteMeta = async (ctx) => {
|
|
|
284
327
|
console.warn("[opennext] Warning: Failed to convert fallback rewrites:", e);
|
|
285
328
|
}
|
|
286
329
|
}
|
|
330
|
+
if (staticRoutes.length > 0) {
|
|
331
|
+
routes.push(...getStaticRoutes(staticRoutes, basePath));
|
|
332
|
+
}
|
|
287
333
|
if (dynamicRoutes.length > 0) {
|
|
288
334
|
routes.push(...getDynamicRoutes(dynamicRoutes, basePath));
|
|
289
335
|
}
|
|
290
336
|
if (dataRoutes.length > 0) {
|
|
291
337
|
routes.push(...getDataRoutes(dataRoutes, basePath));
|
|
292
338
|
}
|
|
339
|
+
const apiRoutes = getApiRoutes(appPathsManifest, basePath);
|
|
340
|
+
if (apiRoutes.length > 0) {
|
|
341
|
+
routes.push(...apiRoutes);
|
|
342
|
+
}
|
|
293
343
|
routes.push({
|
|
294
344
|
src: `^${basePath}/.*$`
|
|
295
345
|
});
|
|
@@ -28,7 +28,7 @@ module.exports = __toCommonJS(tags_handler_exports);
|
|
|
28
28
|
|
|
29
29
|
// package.json
|
|
30
30
|
var name = "@edgeone/opennextjs-pages";
|
|
31
|
-
var version = "0.1.5-beta.
|
|
31
|
+
var version = "0.1.5-beta.3";
|
|
32
32
|
|
|
33
33
|
// src/run/handlers/tags-handler.cts
|
|
34
34
|
var import_request_context = require("./request-context.cjs");
|