@edgeone/opennextjs-pages 0.1.0 → 0.1.2
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/cache.js +0 -4
- package/dist/build/functions/middleware/middleware.js +0 -1
- package/dist/build/functions/server.js +0 -2
- package/dist/build/routes.js +6 -7
- package/dist/index.js +0 -1
- package/dist/run/handlers/server.js +21 -0
- package/dist/run/handlers/tags-handler.cjs +1 -2
- package/package.json +1 -1
package/dist/build/cache.js
CHANGED
|
@@ -16,18 +16,14 @@ var saveBuildCache = async (ctx) => {
|
|
|
16
16
|
if (existsSync(cacheDir)) {
|
|
17
17
|
await rm(join(cacheDir, "fetch-cache"), { recursive: true, force: true });
|
|
18
18
|
await cache.save(cacheDir);
|
|
19
|
-
console.log("Next.js cache saved");
|
|
20
19
|
} else {
|
|
21
|
-
console.log("No Next.js cache to save");
|
|
22
20
|
}
|
|
23
21
|
};
|
|
24
22
|
var restoreBuildCache = async (ctx) => {
|
|
25
23
|
const { cache } = ctx.utils;
|
|
26
24
|
const cacheDir = join(ctx.publishDir, "cache");
|
|
27
25
|
if (await cache.restore(cacheDir)) {
|
|
28
|
-
console.log("Next.js cache restored");
|
|
29
26
|
} else {
|
|
30
|
-
console.log("No Next.js cache to restore");
|
|
31
27
|
}
|
|
32
28
|
};
|
|
33
29
|
export {
|
|
@@ -100,8 +100,6 @@ var getHandlerFile = async (ctx) => {
|
|
|
100
100
|
};
|
|
101
101
|
if (ctx.relativeAppDir.length !== 0) {
|
|
102
102
|
const template2 = await readFile(join(templatesDir, "handler-monorepo.tmpl.js"), "utf-8");
|
|
103
|
-
console.log("ctx.lambdaWorkingDirectory", ctx.lambdaWorkingDirectory);
|
|
104
|
-
console.log("ctx.nextServerHandler", ctx.nextServerHandler);
|
|
105
103
|
templateVariables["{{cwd}}"] = posixJoin(ctx.lambdaWorkingDirectory);
|
|
106
104
|
templateVariables["{{nextServerHandler}}"] = posixJoin(ctx.nextServerHandler);
|
|
107
105
|
return applyTemplateVariables(template2, templateVariables);
|
package/dist/build/routes.js
CHANGED
|
@@ -83,7 +83,6 @@ async function getMiddlewareConfig(ctx) {
|
|
|
83
83
|
}
|
|
84
84
|
return null;
|
|
85
85
|
} catch (error) {
|
|
86
|
-
console.log("[Middleware] Failed to read middleware config:", error);
|
|
87
86
|
return null;
|
|
88
87
|
}
|
|
89
88
|
}
|
|
@@ -95,12 +94,10 @@ function updateEdgeFunctionsMetaJson(middlewareConfig) {
|
|
|
95
94
|
const content = fs.readFileSync(metaJsonPath, "utf-8");
|
|
96
95
|
meta = JSON.parse(content);
|
|
97
96
|
} catch (error) {
|
|
98
|
-
console.log("[Middleware] Failed to parse existing meta.json, creating new one");
|
|
99
97
|
}
|
|
100
98
|
}
|
|
101
99
|
if (middlewareConfig) {
|
|
102
100
|
meta.middleware = middlewareConfig;
|
|
103
|
-
console.log("[Middleware] Updated meta.json with middleware config:", JSON.stringify(middlewareConfig.matcher));
|
|
104
101
|
}
|
|
105
102
|
const edgeFunctionsDir = path.dirname(metaJsonPath);
|
|
106
103
|
if (!fs.existsSync(edgeFunctionsDir)) {
|
|
@@ -166,10 +163,12 @@ var createRouteMeta = async (ctx) => {
|
|
|
166
163
|
const routesManifest = await ctx.getRoutesManifest();
|
|
167
164
|
if (routesManifest) {
|
|
168
165
|
const dataRoutes = routesManifest.dataRoutes;
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
166
|
+
if (dataRoutes) {
|
|
167
|
+
for (const { page, dataRouteRegex } of dataRoutes) {
|
|
168
|
+
routeMap[dataRouteRegex] = {
|
|
169
|
+
isStatic: routeMap[page]?.isStatic || false
|
|
170
|
+
};
|
|
171
|
+
}
|
|
173
172
|
}
|
|
174
173
|
}
|
|
175
174
|
const imagesManifest = await ctx.getImagesManifest();
|
package/dist/index.js
CHANGED
|
@@ -3143,8 +3143,29 @@ var server_default = async (request, _context, topLevelSpan, requestContext) =>
|
|
|
3143
3143
|
for (var key in request.headers) {
|
|
3144
3144
|
headersList.push([key, request.headers[key]]);
|
|
3145
3145
|
}
|
|
3146
|
+
let bodyStream = request.body;
|
|
3147
|
+
if (typeof bodyStream === "undefined" && request.method !== "GET" && request.method !== "HEAD") {
|
|
3148
|
+
if (typeof request.on === "function" && typeof request.read === "function") {
|
|
3149
|
+
bodyStream = new ReadableStream({
|
|
3150
|
+
start(controller) {
|
|
3151
|
+
request.on("data", (chunk) => {
|
|
3152
|
+
controller.enqueue(new Uint8Array(chunk));
|
|
3153
|
+
});
|
|
3154
|
+
request.on("end", () => {
|
|
3155
|
+
controller.close();
|
|
3156
|
+
});
|
|
3157
|
+
request.on("error", (err) => {
|
|
3158
|
+
controller.error(err);
|
|
3159
|
+
});
|
|
3160
|
+
}
|
|
3161
|
+
});
|
|
3162
|
+
} else {
|
|
3163
|
+
bodyStream = null;
|
|
3164
|
+
}
|
|
3165
|
+
}
|
|
3146
3166
|
const { req, res } = toReqRes({
|
|
3147
3167
|
...request,
|
|
3168
|
+
body: bodyStream,
|
|
3148
3169
|
url: "http://localhost:9000" + request.url,
|
|
3149
3170
|
headers: headersList
|
|
3150
3171
|
});
|
|
@@ -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.
|
|
31
|
+
var version = "0.1.2";
|
|
32
32
|
|
|
33
33
|
// src/run/handlers/tags-handler.cts
|
|
34
34
|
var import_request_context = require("./request-context.cjs");
|
|
@@ -62,7 +62,6 @@ async function purgeEdgeCache(tagOrTags) {
|
|
|
62
62
|
});
|
|
63
63
|
const data = await res.json();
|
|
64
64
|
if (data?.error) {
|
|
65
|
-
console.log(`Failed to purge CDN cache: ${data?.error.message}`);
|
|
66
65
|
}
|
|
67
66
|
}
|
|
68
67
|
async function doRevalidateTagAndPurgeEdgeCache(tags) {
|