@edgeone/opennextjs-pages 0.2.6 → 0.2.7

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.
@@ -119,21 +119,45 @@ function getServerRoutes(staticRoutes, prerenderManifest, basePath = "") {
119
119
  }
120
120
  return routes;
121
121
  }
122
- function getApiRoutes(appPathsManifest, basePath = "") {
122
+ function getAppRoutes(appPathsManifest, basePath = "", existingPaths = /* @__PURE__ */ new Set()) {
123
123
  if (!appPathsManifest) {
124
124
  return [];
125
125
  }
126
126
  const routes = [];
127
+ const emitted = /* @__PURE__ */ new Set();
127
128
  for (const routePath of Object.keys(appPathsManifest)) {
128
- if (routePath.includes("/api/") && routePath.endsWith("/route")) {
129
- const apiPath = routePath.replace(/\/route$/, "");
130
- if (apiPath.includes("[")) {
131
- continue;
132
- }
133
- const escapedPath = apiPath.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
134
- const src = `^${basePath}${escapedPath}$`;
135
- routes.push({ src });
129
+ if (routePath.startsWith("/_")) {
130
+ continue;
131
+ }
132
+ let pagePath;
133
+ if (routePath.endsWith("/route")) {
134
+ pagePath = routePath.replace(/\/route$/, "");
135
+ } else if (routePath.endsWith("/page")) {
136
+ pagePath = routePath.replace(/\/page$/, "") || "/";
137
+ } else {
138
+ continue;
139
+ }
140
+ pagePath = pagePath.replace(/\/\([^)]+\)/g, "");
141
+ if (!pagePath) pagePath = "/";
142
+ if (pagePath.includes("@")) {
143
+ continue;
144
+ }
145
+ if (pagePath.includes("[")) {
146
+ continue;
147
+ }
148
+ if (pagePath === "/") {
149
+ continue;
150
+ }
151
+ if (existingPaths.has(pagePath)) {
152
+ continue;
153
+ }
154
+ if (emitted.has(pagePath)) {
155
+ continue;
136
156
  }
157
+ emitted.add(pagePath);
158
+ const escapedPath = pagePath.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
159
+ const src = `^${basePath}${escapedPath}(?:/)?$`;
160
+ routes.push({ src });
137
161
  }
138
162
  return routes;
139
163
  }
@@ -345,9 +369,10 @@ var createRouteMeta = async (ctx) => {
345
369
  if (dataRoutes.length > 0) {
346
370
  routes.push(...getDataRoutes(dataRoutes, basePath));
347
371
  }
348
- const apiRoutes = getApiRoutes(appPathsManifest, basePath);
349
- if (apiRoutes.length > 0) {
350
- routes.push(...apiRoutes);
372
+ const existingPaths = new Set(staticRoutes.map((r) => r.page));
373
+ const appRoutes = getAppRoutes(appPathsManifest, basePath, existingPaths);
374
+ if (appRoutes.length > 0) {
375
+ routes.push(...appRoutes);
351
376
  }
352
377
  routes.push({
353
378
  src: `^${basePath}/.*$`
@@ -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.2.6";
31
+ var version = "0.2.7";
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.2.6",
3
+ "version": "0.2.7",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "type": "module",