@edgeone/opennextjs-pages 0.2.2 → 0.2.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.
|
@@ -2935,6 +2935,43 @@ function getExternalMock(id) {
|
|
|
2935
2935
|
return result;
|
|
2936
2936
|
}
|
|
2937
2937
|
|
|
2938
|
+
// shared-cache-controls mock - must be matched before the general incremental-cache mock
|
|
2939
|
+
// Next.js 16+ uses SharedCacheControls from this module in IncrementalCache constructor
|
|
2940
|
+
if (id.includes('shared-cache-controls')) {
|
|
2941
|
+
class SharedCacheControls {
|
|
2942
|
+
constructor(prerenderManifest) {
|
|
2943
|
+
this.prerenderManifest = prerenderManifest;
|
|
2944
|
+
this.controls = new Map();
|
|
2945
|
+
}
|
|
2946
|
+
get(key) { return this.controls.get(key); }
|
|
2947
|
+
set(key, value) { this.controls.set(key, value); }
|
|
2948
|
+
}
|
|
2949
|
+
const result = {
|
|
2950
|
+
SharedCacheControls,
|
|
2951
|
+
default: { SharedCacheControls }
|
|
2952
|
+
};
|
|
2953
|
+
Object.defineProperty(result, '__esModule', { value: true });
|
|
2954
|
+
return result;
|
|
2955
|
+
}
|
|
2956
|
+
|
|
2957
|
+
// shared-revalidate-timings mock - similarly used by IncrementalCache in older versions
|
|
2958
|
+
if (id.includes('shared-revalidate-timings')) {
|
|
2959
|
+
class SharedRevalidateTimings {
|
|
2960
|
+
constructor(prerenderManifest) {
|
|
2961
|
+
this.prerenderManifest = prerenderManifest;
|
|
2962
|
+
this.timings = new Map();
|
|
2963
|
+
}
|
|
2964
|
+
get(key) { return this.timings.get(key); }
|
|
2965
|
+
set(key, value) { this.timings.set(key, value); }
|
|
2966
|
+
}
|
|
2967
|
+
const result = {
|
|
2968
|
+
SharedRevalidateTimings,
|
|
2969
|
+
default: { SharedRevalidateTimings }
|
|
2970
|
+
};
|
|
2971
|
+
Object.defineProperty(result, '__esModule', { value: true });
|
|
2972
|
+
return result;
|
|
2973
|
+
}
|
|
2974
|
+
|
|
2938
2975
|
// incremental-cache/tags-manifest mock
|
|
2939
2976
|
if (id.includes('incremental-cache') || id.includes('tags-manifest')) {
|
|
2940
2977
|
const result = {
|
|
@@ -141,21 +141,32 @@ var EdgeoneCacheHandler = class {
|
|
|
141
141
|
const prerenderManifest = await this.getPrerenderManifest(this.options.serverDistDir);
|
|
142
142
|
if (typeof cacheControl !== "undefined") {
|
|
143
143
|
try {
|
|
144
|
-
const
|
|
144
|
+
const sharedCacheControlsModule = await import(
|
|
145
145
|
// @ts-expect-error supporting multiple next version, this module is not resolvable with currently used dev dependency
|
|
146
146
|
// eslint-disable-next-line import/no-unresolved, n/no-missing-import
|
|
147
147
|
"next/dist/server/lib/incremental-cache/shared-cache-controls.external.js"
|
|
148
148
|
);
|
|
149
|
+
const SharedCacheControls = sharedCacheControlsModule.SharedCacheControls || sharedCacheControlsModule.default?.SharedCacheControls || sharedCacheControlsModule.default;
|
|
150
|
+
if (typeof SharedCacheControls !== "function") {
|
|
151
|
+
throw new Error("SharedCacheControls is not a constructor in .external.js module");
|
|
152
|
+
}
|
|
149
153
|
const sharedCacheControls = new SharedCacheControls(prerenderManifest);
|
|
150
154
|
sharedCacheControls.set(key, cacheControl);
|
|
151
155
|
} catch {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
156
|
+
try {
|
|
157
|
+
const sharedCacheControlsModule = await import(
|
|
158
|
+
// @ts-expect-error supporting multiple next version, this module is not resolvable with currently used dev dependency
|
|
159
|
+
// eslint-disable-next-line import/no-unresolved, n/no-missing-import
|
|
160
|
+
"next/dist/server/lib/incremental-cache/shared-cache-controls.js"
|
|
161
|
+
);
|
|
162
|
+
const SharedCacheControls = sharedCacheControlsModule.SharedCacheControls || sharedCacheControlsModule.default?.SharedCacheControls || sharedCacheControlsModule.default;
|
|
163
|
+
if (typeof SharedCacheControls !== "function") {
|
|
164
|
+
throw new Error("SharedCacheControls is not a constructor in .js module");
|
|
165
|
+
}
|
|
166
|
+
const sharedCacheControls = new SharedCacheControls(prerenderManifest);
|
|
167
|
+
sharedCacheControls.set(key, cacheControl);
|
|
168
|
+
} catch {
|
|
169
|
+
}
|
|
159
170
|
}
|
|
160
171
|
} else if (typeof revalidate === "number" || revalidate === false) {
|
|
161
172
|
try {
|
|
@@ -3124,6 +3124,18 @@ var disableFaultyTransferEncodingHandling = (res) => {
|
|
|
3124
3124
|
return originalStoreHeader.call(this, firstLine, headers);
|
|
3125
3125
|
};
|
|
3126
3126
|
};
|
|
3127
|
+
function getRealHostInfo(headers) {
|
|
3128
|
+
const get = (key) => {
|
|
3129
|
+
if (typeof headers.get === "function") {
|
|
3130
|
+
return headers.get(key) || "";
|
|
3131
|
+
}
|
|
3132
|
+
return headers[key] || "";
|
|
3133
|
+
};
|
|
3134
|
+
const host = get("eo-pages-host") || get("host") || "localhost";
|
|
3135
|
+
const protocol = get("x-forwarded-proto") || "https";
|
|
3136
|
+
return { host, protocol };
|
|
3137
|
+
}
|
|
3138
|
+
var NEXT_REQUEST_META = Symbol.for("NextInternalRequestMeta");
|
|
3127
3139
|
var server_default = async (request, _context, topLevelSpan, requestContext) => {
|
|
3128
3140
|
const tracer = getTracer();
|
|
3129
3141
|
if (!nextHandler) {
|
|
@@ -3139,9 +3151,14 @@ var server_default = async (request, _context, topLevelSpan, requestContext) =>
|
|
|
3139
3151
|
});
|
|
3140
3152
|
}
|
|
3141
3153
|
return await tracer.withActiveSpan("generate response", async (span) => {
|
|
3154
|
+
const { host: realHost, protocol: realProtocol } = getRealHostInfo(request.headers);
|
|
3142
3155
|
const headersList = [];
|
|
3143
3156
|
for (var key in request.headers) {
|
|
3144
|
-
|
|
3157
|
+
if (key === "host") {
|
|
3158
|
+
headersList.push([key, realHost]);
|
|
3159
|
+
} else {
|
|
3160
|
+
headersList.push([key, request.headers[key]]);
|
|
3161
|
+
}
|
|
3145
3162
|
}
|
|
3146
3163
|
let bodyStream = request.body;
|
|
3147
3164
|
if (typeof bodyStream === "undefined" && request.method !== "GET" && request.method !== "HEAD") {
|
|
@@ -3166,7 +3183,7 @@ var server_default = async (request, _context, topLevelSpan, requestContext) =>
|
|
|
3166
3183
|
const { req, res } = toReqRes({
|
|
3167
3184
|
...request,
|
|
3168
3185
|
body: bodyStream,
|
|
3169
|
-
url:
|
|
3186
|
+
url: `${realProtocol}://${realHost}${request.url}`,
|
|
3170
3187
|
headers: headersList
|
|
3171
3188
|
});
|
|
3172
3189
|
Object.defineProperty(req, "connection", {
|
|
@@ -3180,6 +3197,21 @@ var server_default = async (request, _context, topLevelSpan, requestContext) =>
|
|
|
3180
3197
|
}
|
|
3181
3198
|
});
|
|
3182
3199
|
disableFaultyTransferEncodingHandling(res);
|
|
3200
|
+
const realOrigin = `${realProtocol}://${realHost}`;
|
|
3201
|
+
const metaProxy = new Proxy({}, {
|
|
3202
|
+
set(target, prop, value) {
|
|
3203
|
+
if (prop === "initURL" && typeof value === "string") {
|
|
3204
|
+
target[prop] = value.replace(/^https?:\/\/localhost(:\d+)?/, realOrigin);
|
|
3205
|
+
} else {
|
|
3206
|
+
target[prop] = value;
|
|
3207
|
+
}
|
|
3208
|
+
return true;
|
|
3209
|
+
},
|
|
3210
|
+
get(target, prop) {
|
|
3211
|
+
return target[prop];
|
|
3212
|
+
}
|
|
3213
|
+
});
|
|
3214
|
+
req[NEXT_REQUEST_META] = metaProxy;
|
|
3183
3215
|
const resProxy = nextResponseProxy(res, requestContext);
|
|
3184
3216
|
const nextHandlerPromise = nextHandler(req, resProxy).catch((error) => {
|
|
3185
3217
|
getLogger().withError(error).error("next handler error");
|
|
@@ -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.3";
|
|
32
32
|
|
|
33
33
|
// src/run/handlers/tags-handler.cts
|
|
34
34
|
var import_request_context = require("./request-context.cjs");
|