@edgeone/opennextjs-pages 0.1.5-beta.2 → 0.1.5-beta.4

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.
@@ -89,6 +89,51 @@ function getDataRoutes(dataRoutes, basePath = "") {
89
89
  }
90
90
  return routes;
91
91
  }
92
+ function getServerRoutes(staticRoutes, prerenderManifest, basePath = "") {
93
+ const routes = [];
94
+ const prerenderRoutes = prerenderManifest?.routes || {};
95
+ for (const route of staticRoutes) {
96
+ if (route.page.startsWith("/_")) {
97
+ continue;
98
+ }
99
+ const prerenderInfo = prerenderRoutes[route.page];
100
+ if (prerenderInfo && prerenderInfo.initialRevalidateSeconds === false) {
101
+ continue;
102
+ }
103
+ if (route.namedRegex) {
104
+ let src = convertNamedRegexToSrc(route.namedRegex, basePath);
105
+ if (src) {
106
+ src = src.replace(/\(\?:\/\)\?\$$/, "$");
107
+ routes.push({ src });
108
+ }
109
+ } else if (route.regex) {
110
+ if (isRE2Compatible(route.regex)) {
111
+ let src = route.regex;
112
+ if (basePath && !src.startsWith(`^${basePath}`)) {
113
+ src = src.replace(/^\^/, `^${basePath}`);
114
+ }
115
+ src = src.replace(/\(\?:\/\)\?\$$/, "$");
116
+ routes.push({ src });
117
+ }
118
+ }
119
+ }
120
+ return routes;
121
+ }
122
+ function getApiRoutes(appPathsManifest, basePath = "") {
123
+ if (!appPathsManifest) {
124
+ return [];
125
+ }
126
+ const routes = [];
127
+ for (const routePath of Object.keys(appPathsManifest)) {
128
+ if (routePath.includes("/api/") && routePath.endsWith("/route")) {
129
+ const apiPath = routePath.replace(/\/route$/, "");
130
+ const escapedPath = apiPath.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
131
+ const src = `^${basePath}${escapedPath}$`;
132
+ routes.push({ src });
133
+ }
134
+ }
135
+ return routes;
136
+ }
92
137
  async function getMiddlewareConfig(ctx) {
93
138
  try {
94
139
  const manifest = await ctx.getMiddlewareManifest();
@@ -199,6 +244,9 @@ var createRouteMeta = async (ctx) => {
199
244
  }
200
245
  const dynamicRoutes = routesManifest?.dynamicRoutes || [];
201
246
  const dataRoutes = routesManifest?.dataRoutes || [];
247
+ const staticRoutes = routesManifest?.staticRoutes || [];
248
+ const appPathsManifest = await ctx.getAppPathsManifest?.() || null;
249
+ const prerenderManifest = await ctx.getPrerenderManifest?.() || null;
202
250
  const buildId = getBuildId(ctx);
203
251
  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
252
  routes.push({
@@ -285,12 +333,19 @@ var createRouteMeta = async (ctx) => {
285
333
  console.warn("[opennext] Warning: Failed to convert fallback rewrites:", e);
286
334
  }
287
335
  }
336
+ if (staticRoutes.length > 0) {
337
+ routes.push(...getServerRoutes(staticRoutes, prerenderManifest, basePath));
338
+ }
288
339
  if (dynamicRoutes.length > 0) {
289
340
  routes.push(...getDynamicRoutes(dynamicRoutes, basePath));
290
341
  }
291
342
  if (dataRoutes.length > 0) {
292
343
  routes.push(...getDataRoutes(dataRoutes, basePath));
293
344
  }
345
+ const apiRoutes = getApiRoutes(appPathsManifest, basePath);
346
+ if (apiRoutes.length > 0) {
347
+ routes.push(...apiRoutes);
348
+ }
294
349
  routes.push({
295
350
  src: `^${basePath}/.*$`
296
351
  });
@@ -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.2";
31
+ var version = "0.1.5-beta.4";
32
32
 
33
33
  // src/run/handlers/tags-handler.cts
34
34
  var import_request_context = require("./request-context.cjs");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edgeone/opennextjs-pages",
3
- "version": "0.1.5-beta.2",
3
+ "version": "0.1.5-beta.4",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "type": "module",