@edgeone/opennextjs-pages 0.1.5-beta.2 → 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({
|
|
@@ -285,12 +327,19 @@ var createRouteMeta = async (ctx) => {
|
|
|
285
327
|
console.warn("[opennext] Warning: Failed to convert fallback rewrites:", e);
|
|
286
328
|
}
|
|
287
329
|
}
|
|
330
|
+
if (staticRoutes.length > 0) {
|
|
331
|
+
routes.push(...getStaticRoutes(staticRoutes, basePath));
|
|
332
|
+
}
|
|
288
333
|
if (dynamicRoutes.length > 0) {
|
|
289
334
|
routes.push(...getDynamicRoutes(dynamicRoutes, basePath));
|
|
290
335
|
}
|
|
291
336
|
if (dataRoutes.length > 0) {
|
|
292
337
|
routes.push(...getDataRoutes(dataRoutes, basePath));
|
|
293
338
|
}
|
|
339
|
+
const apiRoutes = getApiRoutes(appPathsManifest, basePath);
|
|
340
|
+
if (apiRoutes.length > 0) {
|
|
341
|
+
routes.push(...apiRoutes);
|
|
342
|
+
}
|
|
294
343
|
routes.push({
|
|
295
344
|
src: `^${basePath}/.*$`
|
|
296
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");
|