@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.
package/dist/build/routes.js
CHANGED
|
@@ -119,21 +119,45 @@ function getServerRoutes(staticRoutes, prerenderManifest, basePath = "") {
|
|
|
119
119
|
}
|
|
120
120
|
return routes;
|
|
121
121
|
}
|
|
122
|
-
function
|
|
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.
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
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
|
|
349
|
-
|
|
350
|
-
|
|
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.
|
|
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");
|