@netlify/plugin-nextjs 5.0.0-beta.9 → 5.0.0-rc.1
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/content/static.js +1 -1
- package/dist/build/functions/edge.js +2 -2
- package/dist/build/functions/server.js +2 -2
- package/dist/build/image-cdn.js +3 -1
- package/dist/build/plugin-context.js +1 -1
- package/dist/esm-chunks/{chunk-NL5YH5N6.js → chunk-3SUDZQ7L.js} +1 -1
- package/dist/esm-chunks/{chunk-DWC6JSN7.js → chunk-655Y7ISI.js} +23 -7
- package/dist/esm-chunks/{chunk-T6AZTXZF.js → chunk-GAZUUVZW.js} +1 -1
- package/dist/esm-chunks/chunk-RL4K4CVH.js +27 -0
- package/dist/esm-chunks/{chunk-AU7XDLZH.js → chunk-UTCWWUFW.js} +10 -3
- package/dist/esm-chunks/{chunk-ZWFKLYLH.js → chunk-WQIG4U66.js} +5 -4
- package/dist/esm-chunks/chunk-XXBTIYSL.js +7199 -0
- package/dist/esm-chunks/chunk-ZZOGIP2V.js +531 -0
- package/dist/esm-chunks/{package-6DFWHFJA.js → package-QW5XSFQ4.js} +9 -5
- package/dist/index.js +8 -13
- package/dist/run/config.js +1 -1
- package/dist/run/handlers/cache.cjs +10 -0
- package/dist/run/handlers/server.js +6 -6
- package/dist/run/handlers/tracing.js +1 -1
- package/dist/run/headers.js +1 -1
- package/dist/run/next.cjs +6 -1
- package/dist/run/revalidate.js +1 -1
- package/edge-runtime/lib/next-request.ts +14 -9
- package/edge-runtime/lib/response.ts +4 -3
- package/edge-runtime/lib/util.ts +1 -1
- package/package.json +1 -1
- package/dist/esm-chunks/chunk-TOK7TKP3.js +0 -28
- package/dist/esm-chunks/chunk-WT2HN3M6.js +0 -255
- package/dist/esm-chunks/chunk-YIE34LVX.js +0 -134
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
} from "../../esm-chunks/chunk-HYBEXB2Z.js";
|
|
13
13
|
import {
|
|
14
14
|
getTagsManifest
|
|
15
|
-
} from "../../esm-chunks/chunk-
|
|
15
|
+
} from "../../esm-chunks/chunk-3SUDZQ7L.js";
|
|
16
16
|
import "../../esm-chunks/chunk-UYKENJEU.js";
|
|
17
17
|
import {
|
|
18
18
|
adjustDateHeader,
|
|
@@ -20,11 +20,11 @@ import {
|
|
|
20
20
|
setCacheStatusHeader,
|
|
21
21
|
setCacheTagsHeaders,
|
|
22
22
|
setVaryHeaders
|
|
23
|
-
} from "../../esm-chunks/chunk-
|
|
23
|
+
} from "../../esm-chunks/chunk-UTCWWUFW.js";
|
|
24
24
|
import "../../esm-chunks/chunk-TYCYFZ22.js";
|
|
25
25
|
import {
|
|
26
26
|
nextResponseProxy
|
|
27
|
-
} from "../../esm-chunks/chunk-
|
|
27
|
+
} from "../../esm-chunks/chunk-RL4K4CVH.js";
|
|
28
28
|
import {
|
|
29
29
|
__commonJS,
|
|
30
30
|
__toESM
|
|
@@ -3292,8 +3292,8 @@ var server_default = async (request) => {
|
|
|
3292
3292
|
}
|
|
3293
3293
|
return await tracer.startActiveSpan("generate response", async (span) => {
|
|
3294
3294
|
const { req, res } = toReqRes(request);
|
|
3295
|
-
const resProxy = nextResponseProxy(res);
|
|
3296
3295
|
const requestContext = createRequestContext();
|
|
3296
|
+
const resProxy = nextResponseProxy(res, requestContext);
|
|
3297
3297
|
const nextHandlerPromise = runWithRequestContext(
|
|
3298
3298
|
requestContext,
|
|
3299
3299
|
() => nextHandler(req, resProxy).catch((error) => {
|
|
@@ -3315,8 +3315,8 @@ var server_default = async (request) => {
|
|
|
3315
3315
|
span.setAttribute("responseCacheKey", requestContext.responseCacheKey);
|
|
3316
3316
|
}
|
|
3317
3317
|
await adjustDateHeader({ headers: response.headers, request, span, tracer, requestContext });
|
|
3318
|
-
setCacheControlHeaders(response.headers, request);
|
|
3319
|
-
setCacheTagsHeaders(response.headers, request, tagsManifest);
|
|
3318
|
+
setCacheControlHeaders(response.headers, request, requestContext);
|
|
3319
|
+
setCacheTagsHeaders(response.headers, request, tagsManifest, requestContext);
|
|
3320
3320
|
setVaryHeaders(response.headers, request, nextConfig);
|
|
3321
3321
|
setCacheStatusHeader(response.headers);
|
|
3322
3322
|
if (response.status > 300 && response.status < 400 || response.status >= 500) {
|
|
@@ -52794,7 +52794,7 @@ var import_semantic_conventions = __toESM(require_src2(), 1);
|
|
|
52794
52794
|
var import_api = __toESM(require_src(), 1);
|
|
52795
52795
|
var {
|
|
52796
52796
|
default: { version, name }
|
|
52797
|
-
} = await import("../../esm-chunks/package-
|
|
52797
|
+
} = await import("../../esm-chunks/package-QW5XSFQ4.js");
|
|
52798
52798
|
var sdk = new import_sdk_node.NodeSDK({
|
|
52799
52799
|
resource: new import_resources.Resource({
|
|
52800
52800
|
[import_semantic_conventions.SemanticResourceAttributes.SERVICE_NAME]: name,
|
package/dist/run/headers.js
CHANGED
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
setCacheStatusHeader,
|
|
11
11
|
setCacheTagsHeaders,
|
|
12
12
|
setVaryHeaders
|
|
13
|
-
} from "../esm-chunks/chunk-
|
|
13
|
+
} from "../esm-chunks/chunk-UTCWWUFW.js";
|
|
14
14
|
import "../esm-chunks/chunk-TYCYFZ22.js";
|
|
15
15
|
import "../esm-chunks/chunk-5JVNISGM.js";
|
|
16
16
|
export {
|
package/dist/run/next.cjs
CHANGED
|
@@ -2734,11 +2734,11 @@ var pipeline = (0, import_util.promisify)(import_stream.default.pipeline);
|
|
|
2734
2734
|
// src/run/next.cts
|
|
2735
2735
|
var import_api = __toESM(require_src());
|
|
2736
2736
|
var import_fs_monkey = __toESM(require_lib());
|
|
2737
|
+
var import_request_context = require("./handlers/request-context.cjs");
|
|
2737
2738
|
var fetchBeforeNextPatchedIt = globalThis.fetch;
|
|
2738
2739
|
async function getMockedRequestHandlers(...args) {
|
|
2739
2740
|
const tracer = import_api.trace.getTracer("Next.js Runtime");
|
|
2740
2741
|
return tracer.startActiveSpan("mocked request handler", async (span) => {
|
|
2741
|
-
const store = getDeployStore({ fetch: fetchBeforeNextPatchedIt });
|
|
2742
2742
|
const ofs = { ...import_promises.default };
|
|
2743
2743
|
const { encodeBlobKey: encodeBlobKey2 } = await Promise.resolve().then(() => (init_blobkey(), blobkey_exports));
|
|
2744
2744
|
async function readFileFallbackBlobStore(...fsargs) {
|
|
@@ -2747,9 +2747,14 @@ async function getMockedRequestHandlers(...args) {
|
|
|
2747
2747
|
return await ofs.readFile(path, options);
|
|
2748
2748
|
} catch (error) {
|
|
2749
2749
|
if (typeof path === "string" && path.endsWith(".html")) {
|
|
2750
|
+
const store = getDeployStore({ fetch: fetchBeforeNextPatchedIt });
|
|
2750
2751
|
const relPath = (0, import_path.relative)((0, import_path.resolve)(".next/server/pages"), path);
|
|
2751
2752
|
const file = await store.get(await encodeBlobKey2(relPath));
|
|
2752
2753
|
if (file !== null) {
|
|
2754
|
+
const requestContext = (0, import_request_context.getRequestContext)();
|
|
2755
|
+
if (requestContext) {
|
|
2756
|
+
requestContext.usedFsRead = true;
|
|
2757
|
+
}
|
|
2753
2758
|
return file;
|
|
2754
2759
|
}
|
|
2755
2760
|
}
|
package/dist/run/revalidate.js
CHANGED
|
@@ -24,6 +24,7 @@ export interface RequestData {
|
|
|
24
24
|
basePath?: string
|
|
25
25
|
i18n?: I18NConfig | null
|
|
26
26
|
trailingSlash?: boolean
|
|
27
|
+
skipMiddlewareUrlNormalize?: boolean
|
|
27
28
|
}
|
|
28
29
|
page?: {
|
|
29
30
|
name?: string
|
|
@@ -50,19 +51,23 @@ const normalizeRequestURL = (
|
|
|
50
51
|
url.pathname,
|
|
51
52
|
nextConfig?.i18n?.locales,
|
|
52
53
|
)
|
|
53
|
-
|
|
54
|
+
if (!nextConfig?.skipMiddlewareUrlNormalize) {
|
|
55
|
+
url.pathname = pathname || '/'
|
|
56
|
+
}
|
|
54
57
|
detectedLocale = detected
|
|
55
58
|
}
|
|
56
59
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
60
|
+
if (!nextConfig?.skipMiddlewareUrlNormalize) {
|
|
61
|
+
// We want to run middleware for data requests and expose the URL of the
|
|
62
|
+
// corresponding pages, so we have to normalize the URLs before running
|
|
63
|
+
// the handler.
|
|
64
|
+
url.pathname = normalizeDataUrl(url.pathname)
|
|
61
65
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
+
// Normalizing the trailing slash based on the `trailingSlash` configuration
|
|
67
|
+
// property from the Next.js config.
|
|
68
|
+
if (nextConfig?.trailingSlash && url.pathname !== '/' && !url.pathname.endsWith('/')) {
|
|
69
|
+
url.pathname = `${url.pathname}/`
|
|
70
|
+
}
|
|
66
71
|
}
|
|
67
72
|
|
|
68
73
|
if (didRemoveBasePath) {
|
|
@@ -195,7 +195,7 @@ export const buildResponse = async ({
|
|
|
195
195
|
|
|
196
196
|
// If we are redirecting a request that had a locale in the URL, we need to add it back in
|
|
197
197
|
if (redirect && requestLocale) {
|
|
198
|
-
redirect = normalizeLocalizedTarget({ target: redirect, request, nextConfig })
|
|
198
|
+
redirect = normalizeLocalizedTarget({ target: redirect, request, nextConfig, requestLocale })
|
|
199
199
|
if (redirect === request.url) {
|
|
200
200
|
logger.withFields({ rewrite_url: rewrite }).debug('Rewrite url is same as original url')
|
|
201
201
|
return
|
|
@@ -247,9 +247,10 @@ function normalizeLocalizedTarget({
|
|
|
247
247
|
!normalizedTarget.pathname.startsWith(`/api/`) &&
|
|
248
248
|
!normalizedTarget.pathname.startsWith(`/_next/static/`)
|
|
249
249
|
) {
|
|
250
|
-
targetUrl.pathname =
|
|
250
|
+
targetUrl.pathname =
|
|
251
|
+
addBasePath(`/${locale}${normalizedTarget.pathname}`, nextConfig?.basePath) || `/`
|
|
251
252
|
} else {
|
|
252
|
-
targetUrl.pathname = addBasePath(normalizedTarget.pathname, nextConfig?.basePath)
|
|
253
|
+
targetUrl.pathname = addBasePath(normalizedTarget.pathname, nextConfig?.basePath) || `/`
|
|
253
254
|
}
|
|
254
255
|
return targetUrl.toString()
|
|
255
256
|
}
|
package/edge-runtime/lib/util.ts
CHANGED
|
@@ -56,7 +56,7 @@ export function normalizeLocalePath(pathname: string, locales?: string[]): PathL
|
|
|
56
56
|
if (pathnameParts[1] && pathnameParts[1].toLowerCase() === locale.toLowerCase()) {
|
|
57
57
|
detectedLocale = locale
|
|
58
58
|
pathnameParts.splice(1, 1)
|
|
59
|
-
pathname = pathnameParts.join('/')
|
|
59
|
+
pathname = pathnameParts.join('/')
|
|
60
60
|
return true
|
|
61
61
|
}
|
|
62
62
|
return false
|
package/package.json
CHANGED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
var require = await (async () => {
|
|
3
|
-
var { createRequire } = await import("node:module");
|
|
4
|
-
return createRequire(import.meta.url);
|
|
5
|
-
})();
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
// src/build/image-cdn.ts
|
|
9
|
-
var setImageConfig = async (ctx) => {
|
|
10
|
-
const {
|
|
11
|
-
images: { path: imageEndpointPath, loader: imageLoader }
|
|
12
|
-
} = ctx.buildConfig;
|
|
13
|
-
if (imageLoader === "default") {
|
|
14
|
-
ctx.netlifyConfig.redirects.push({
|
|
15
|
-
from: imageEndpointPath,
|
|
16
|
-
// w and q are too short to be used as params with id-length rule
|
|
17
|
-
// but we are forced to do so because of the next/image loader decides on their names
|
|
18
|
-
// eslint-disable-next-line id-length
|
|
19
|
-
query: { url: ":url", w: ":width", q: ":quality" },
|
|
20
|
-
to: "/.netlify/images?url=:url&w=:width&q=:quality",
|
|
21
|
-
status: 200
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export {
|
|
27
|
-
setImageConfig
|
|
28
|
-
};
|
|
@@ -1,255 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
var require = await (async () => {
|
|
3
|
-
var { createRequire } = await import("node:module");
|
|
4
|
-
return createRequire(import.meta.url);
|
|
5
|
-
})();
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
__commonJS,
|
|
9
|
-
__require,
|
|
10
|
-
__toESM
|
|
11
|
-
} from "./chunk-5JVNISGM.js";
|
|
12
|
-
|
|
13
|
-
// node_modules/is-promise/index.js
|
|
14
|
-
var require_is_promise = __commonJS({
|
|
15
|
-
"node_modules/is-promise/index.js"(exports, module) {
|
|
16
|
-
module.exports = isPromise;
|
|
17
|
-
module.exports.default = isPromise;
|
|
18
|
-
function isPromise(obj) {
|
|
19
|
-
return !!obj && (typeof obj === "object" || typeof obj === "function") && typeof obj.then === "function";
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
// node_modules/@netlify/functions/dist/lib/consts.js
|
|
25
|
-
var require_consts = __commonJS({
|
|
26
|
-
"node_modules/@netlify/functions/dist/lib/consts.js"(exports) {
|
|
27
|
-
"use strict";
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.METADATA_VERSION = exports.HTTP_STATUS_OK = exports.HTTP_STATUS_METHOD_NOT_ALLOWED = exports.BUILDER_FUNCTIONS_FLAG = void 0;
|
|
30
|
-
var BUILDER_FUNCTIONS_FLAG = true;
|
|
31
|
-
exports.BUILDER_FUNCTIONS_FLAG = BUILDER_FUNCTIONS_FLAG;
|
|
32
|
-
var HTTP_STATUS_METHOD_NOT_ALLOWED = 405;
|
|
33
|
-
exports.HTTP_STATUS_METHOD_NOT_ALLOWED = HTTP_STATUS_METHOD_NOT_ALLOWED;
|
|
34
|
-
var HTTP_STATUS_OK = 200;
|
|
35
|
-
exports.HTTP_STATUS_OK = HTTP_STATUS_OK;
|
|
36
|
-
var METADATA_VERSION = 1;
|
|
37
|
-
exports.METADATA_VERSION = METADATA_VERSION;
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
// node_modules/@netlify/functions/dist/lib/builder.js
|
|
42
|
-
var require_builder = __commonJS({
|
|
43
|
-
"node_modules/@netlify/functions/dist/lib/builder.js"(exports) {
|
|
44
|
-
"use strict";
|
|
45
|
-
var __importDefault = exports && exports.__importDefault || function(mod) {
|
|
46
|
-
return mod && mod.__esModule ? mod : { "default": mod };
|
|
47
|
-
};
|
|
48
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
49
|
-
exports.builder = void 0;
|
|
50
|
-
var is_promise_1 = __importDefault(require_is_promise());
|
|
51
|
-
var consts_js_1 = require_consts();
|
|
52
|
-
var augmentResponse = (response) => {
|
|
53
|
-
if (!response) {
|
|
54
|
-
return response;
|
|
55
|
-
}
|
|
56
|
-
const metadata = { version: consts_js_1.METADATA_VERSION, builder_function: consts_js_1.BUILDER_FUNCTIONS_FLAG, ttl: response.ttl || 0 };
|
|
57
|
-
return {
|
|
58
|
-
...response,
|
|
59
|
-
metadata
|
|
60
|
-
};
|
|
61
|
-
};
|
|
62
|
-
var wrapHandler = (handler) => (
|
|
63
|
-
// eslint-disable-next-line promise/prefer-await-to-callbacks
|
|
64
|
-
(event, context, callback) => {
|
|
65
|
-
if (event.httpMethod !== "GET" && event.httpMethod !== "HEAD") {
|
|
66
|
-
return Promise.resolve({
|
|
67
|
-
body: "Method Not Allowed",
|
|
68
|
-
statusCode: consts_js_1.HTTP_STATUS_METHOD_NOT_ALLOWED
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
const modifiedEvent = {
|
|
72
|
-
...event,
|
|
73
|
-
multiValueQueryStringParameters: {},
|
|
74
|
-
queryStringParameters: {}
|
|
75
|
-
};
|
|
76
|
-
const wrappedCallback = (error, response) => (
|
|
77
|
-
// eslint-disable-next-line promise/prefer-await-to-callbacks
|
|
78
|
-
callback ? callback(error, augmentResponse(response)) : null
|
|
79
|
-
);
|
|
80
|
-
const execution = handler(modifiedEvent, context, wrappedCallback);
|
|
81
|
-
if ((0, is_promise_1.default)(execution)) {
|
|
82
|
-
return execution.then(augmentResponse);
|
|
83
|
-
}
|
|
84
|
-
return execution;
|
|
85
|
-
}
|
|
86
|
-
);
|
|
87
|
-
exports.builder = wrapHandler;
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
// node_modules/@netlify/functions/dist/lib/purge_cache.js
|
|
92
|
-
var require_purge_cache = __commonJS({
|
|
93
|
-
"node_modules/@netlify/functions/dist/lib/purge_cache.js"(exports) {
|
|
94
|
-
"use strict";
|
|
95
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
96
|
-
exports.purgeCache = void 0;
|
|
97
|
-
var process_1 = __require("process");
|
|
98
|
-
var purgeCache2 = async (options = {}) => {
|
|
99
|
-
if (globalThis.fetch === void 0) {
|
|
100
|
-
throw new Error("`fetch` is not available. Please ensure you're using Node.js version 18.0.0 or above. Refer to https://ntl.fyi/functions-runtime for more information.");
|
|
101
|
-
}
|
|
102
|
-
const payload = {
|
|
103
|
-
cache_tags: options.tags,
|
|
104
|
-
deploy_alias: options.deployAlias
|
|
105
|
-
};
|
|
106
|
-
const token = process_1.env.NETLIFY_PURGE_API_TOKEN || options.token;
|
|
107
|
-
if ("siteSlug" in options) {
|
|
108
|
-
payload.site_slug = options.siteSlug;
|
|
109
|
-
} else if ("domain" in options) {
|
|
110
|
-
payload.domain = options.domain;
|
|
111
|
-
} else {
|
|
112
|
-
const siteID = options.siteID || process_1.env.SITE_ID;
|
|
113
|
-
if (!siteID) {
|
|
114
|
-
throw new Error("The Netlify site ID was not found in the execution environment. Please supply it manually using the `siteID` property.");
|
|
115
|
-
}
|
|
116
|
-
payload.site_id = siteID;
|
|
117
|
-
}
|
|
118
|
-
if (!token) {
|
|
119
|
-
throw new Error("The cache purge API token was not found in the execution environment. Please supply it manually using the `token` property.");
|
|
120
|
-
}
|
|
121
|
-
const apiURL = options.apiURL || "https://api.netlify.com";
|
|
122
|
-
const response = await fetch(`${apiURL}/api/v1/purge`, {
|
|
123
|
-
method: "POST",
|
|
124
|
-
headers: {
|
|
125
|
-
"Content-Type": "application/json; charset=utf8",
|
|
126
|
-
Authorization: `Bearer ${token}`
|
|
127
|
-
},
|
|
128
|
-
body: JSON.stringify(payload)
|
|
129
|
-
});
|
|
130
|
-
if (!response.ok) {
|
|
131
|
-
throw new Error(`Cache purge API call returned an unexpected status code: ${response.status}`);
|
|
132
|
-
}
|
|
133
|
-
};
|
|
134
|
-
exports.purgeCache = purgeCache2;
|
|
135
|
-
}
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
// node_modules/@netlify/functions/dist/lib/schedule.js
|
|
139
|
-
var require_schedule = __commonJS({
|
|
140
|
-
"node_modules/@netlify/functions/dist/lib/schedule.js"(exports) {
|
|
141
|
-
"use strict";
|
|
142
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
143
|
-
exports.schedule = void 0;
|
|
144
|
-
var schedule = (cron, handler) => handler;
|
|
145
|
-
exports.schedule = schedule;
|
|
146
|
-
}
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
// node_modules/@netlify/functions/dist/lib/stream.js
|
|
150
|
-
var require_stream = __commonJS({
|
|
151
|
-
"node_modules/@netlify/functions/dist/lib/stream.js"(exports) {
|
|
152
|
-
"use strict";
|
|
153
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
154
|
-
exports.stream = void 0;
|
|
155
|
-
var node_stream_1 = __require("node:stream");
|
|
156
|
-
var node_util_1 = __require("node:util");
|
|
157
|
-
var pipeline = (0, node_util_1.promisify)(node_stream_1.pipeline);
|
|
158
|
-
var stream = (handler) => awslambda.streamifyResponse(async (event, responseStream, context) => {
|
|
159
|
-
const { body, ...httpResponseMetadata } = await handler(event, context);
|
|
160
|
-
const responseBody = awslambda.HttpResponseStream.from(responseStream, httpResponseMetadata);
|
|
161
|
-
if (typeof body === "undefined") {
|
|
162
|
-
responseBody.end();
|
|
163
|
-
} else if (typeof body === "string") {
|
|
164
|
-
responseBody.write(body);
|
|
165
|
-
responseBody.end();
|
|
166
|
-
} else {
|
|
167
|
-
await pipeline(body, responseBody);
|
|
168
|
-
}
|
|
169
|
-
});
|
|
170
|
-
exports.stream = stream;
|
|
171
|
-
}
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
// node_modules/@netlify/functions/dist/function/index.js
|
|
175
|
-
var require_function = __commonJS({
|
|
176
|
-
"node_modules/@netlify/functions/dist/function/index.js"(exports) {
|
|
177
|
-
"use strict";
|
|
178
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
179
|
-
}
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
// node_modules/@netlify/functions/dist/main.js
|
|
183
|
-
var require_main = __commonJS({
|
|
184
|
-
"node_modules/@netlify/functions/dist/main.js"(exports) {
|
|
185
|
-
"use strict";
|
|
186
|
-
var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
187
|
-
if (k2 === void 0)
|
|
188
|
-
k2 = k;
|
|
189
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
190
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
191
|
-
desc = { enumerable: true, get: function() {
|
|
192
|
-
return m[k];
|
|
193
|
-
} };
|
|
194
|
-
}
|
|
195
|
-
Object.defineProperty(o, k2, desc);
|
|
196
|
-
} : function(o, m, k, k2) {
|
|
197
|
-
if (k2 === void 0)
|
|
198
|
-
k2 = k;
|
|
199
|
-
o[k2] = m[k];
|
|
200
|
-
});
|
|
201
|
-
var __exportStar = exports && exports.__exportStar || function(m, exports2) {
|
|
202
|
-
for (var p in m)
|
|
203
|
-
if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p))
|
|
204
|
-
__createBinding(exports2, m, p);
|
|
205
|
-
};
|
|
206
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
207
|
-
exports.stream = exports.schedule = exports.purgeCache = exports.builder = void 0;
|
|
208
|
-
var builder_js_1 = require_builder();
|
|
209
|
-
Object.defineProperty(exports, "builder", { enumerable: true, get: function() {
|
|
210
|
-
return builder_js_1.builder;
|
|
211
|
-
} });
|
|
212
|
-
var purge_cache_js_1 = require_purge_cache();
|
|
213
|
-
Object.defineProperty(exports, "purgeCache", { enumerable: true, get: function() {
|
|
214
|
-
return purge_cache_js_1.purgeCache;
|
|
215
|
-
} });
|
|
216
|
-
var schedule_js_1 = require_schedule();
|
|
217
|
-
Object.defineProperty(exports, "schedule", { enumerable: true, get: function() {
|
|
218
|
-
return schedule_js_1.schedule;
|
|
219
|
-
} });
|
|
220
|
-
var stream_js_1 = require_stream();
|
|
221
|
-
Object.defineProperty(exports, "stream", { enumerable: true, get: function() {
|
|
222
|
-
return stream_js_1.stream;
|
|
223
|
-
} });
|
|
224
|
-
__exportStar(require_function(), exports);
|
|
225
|
-
}
|
|
226
|
-
});
|
|
227
|
-
|
|
228
|
-
// src/run/revalidate.ts
|
|
229
|
-
var import_functions = __toESM(require_main(), 1);
|
|
230
|
-
var nextResponseProxy = (res) => {
|
|
231
|
-
return new Proxy(res, {
|
|
232
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
233
|
-
get(target, key) {
|
|
234
|
-
const originalValue = target[key];
|
|
235
|
-
if (key === "revalidate") {
|
|
236
|
-
return async function newRevalidate(...args) {
|
|
237
|
-
try {
|
|
238
|
-
console.debug("Purging cache for:", [args[0]]);
|
|
239
|
-
await (0, import_functions.purgeCache)({ tags: [`_N_T_${args[0]}`] });
|
|
240
|
-
} catch {
|
|
241
|
-
throw new Error(
|
|
242
|
-
`An internal error occurred while trying to purge cache for ${args[0]}}`
|
|
243
|
-
);
|
|
244
|
-
}
|
|
245
|
-
return originalValue?.apply(target, args);
|
|
246
|
-
};
|
|
247
|
-
}
|
|
248
|
-
return originalValue;
|
|
249
|
-
}
|
|
250
|
-
});
|
|
251
|
-
};
|
|
252
|
-
|
|
253
|
-
export {
|
|
254
|
-
nextResponseProxy
|
|
255
|
-
};
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
var require = await (async () => {
|
|
3
|
-
var { createRequire } = await import("node:module");
|
|
4
|
-
return createRequire(import.meta.url);
|
|
5
|
-
})();
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
require_out
|
|
9
|
-
} from "./chunk-VZNKO4OO.js";
|
|
10
|
-
import {
|
|
11
|
-
EDGE_HANDLER_NAME
|
|
12
|
-
} from "./chunk-DWC6JSN7.js";
|
|
13
|
-
import {
|
|
14
|
-
__toESM
|
|
15
|
-
} from "./chunk-5JVNISGM.js";
|
|
16
|
-
|
|
17
|
-
// src/build/functions/edge.ts
|
|
18
|
-
var import_fast_glob = __toESM(require_out(), 1);
|
|
19
|
-
import { cp, mkdir, readFile, rm, writeFile } from "node:fs/promises";
|
|
20
|
-
import { dirname, join, relative } from "node:path";
|
|
21
|
-
var writeEdgeManifest = async (ctx, manifest) => {
|
|
22
|
-
await mkdir(ctx.edgeFunctionsDir, { recursive: true });
|
|
23
|
-
await writeFile(join(ctx.edgeFunctionsDir, "manifest.json"), JSON.stringify(manifest, null, 2));
|
|
24
|
-
};
|
|
25
|
-
var copyRuntime = async (ctx, handlerDirectory) => {
|
|
26
|
-
const files = await (0, import_fast_glob.glob)("edge-runtime/**/*", {
|
|
27
|
-
cwd: ctx.pluginDir,
|
|
28
|
-
ignore: ["**/*.test.ts"],
|
|
29
|
-
dot: true
|
|
30
|
-
});
|
|
31
|
-
await Promise.all(
|
|
32
|
-
files.map(
|
|
33
|
-
(path) => cp(join(ctx.pluginDir, path), join(handlerDirectory, path), { recursive: true })
|
|
34
|
-
)
|
|
35
|
-
);
|
|
36
|
-
};
|
|
37
|
-
var writeHandlerFile = async (ctx, { matchers, name }) => {
|
|
38
|
-
const nextConfig = ctx.buildConfig;
|
|
39
|
-
const handlerName = getHandlerName({ name });
|
|
40
|
-
const handlerDirectory = join(ctx.edgeFunctionsDir, handlerName);
|
|
41
|
-
const handlerRuntimeDirectory = join(handlerDirectory, "edge-runtime");
|
|
42
|
-
await copyRuntime(ctx, handlerDirectory);
|
|
43
|
-
await writeFile(join(handlerRuntimeDirectory, "matchers.json"), JSON.stringify(matchers));
|
|
44
|
-
const minimalNextConfig = {
|
|
45
|
-
basePath: nextConfig.basePath,
|
|
46
|
-
i18n: nextConfig.i18n,
|
|
47
|
-
trailingSlash: nextConfig.trailingSlash
|
|
48
|
-
};
|
|
49
|
-
await writeFile(
|
|
50
|
-
join(handlerRuntimeDirectory, "next.config.json"),
|
|
51
|
-
JSON.stringify(minimalNextConfig)
|
|
52
|
-
);
|
|
53
|
-
await writeFile(
|
|
54
|
-
join(handlerDirectory, `${handlerName}.js`),
|
|
55
|
-
`
|
|
56
|
-
import {handleMiddleware} from './edge-runtime/middleware.ts';
|
|
57
|
-
import handler from './server/${name}.js';
|
|
58
|
-
export default (req, context) => handleMiddleware(req, context, handler);
|
|
59
|
-
`
|
|
60
|
-
);
|
|
61
|
-
};
|
|
62
|
-
var copyHandlerDependencies = async (ctx, { name, files, wasm }) => {
|
|
63
|
-
const srcDir = join(ctx.standaloneDir, ctx.nextDistDir);
|
|
64
|
-
const destDir = join(ctx.edgeFunctionsDir, getHandlerName({ name }));
|
|
65
|
-
await Promise.all(
|
|
66
|
-
files.map(async (file) => {
|
|
67
|
-
if (file === `server/${name}.js`) {
|
|
68
|
-
const edgeRuntimeDir = join(ctx.pluginDir, "edge-runtime");
|
|
69
|
-
const shimPath = join(edgeRuntimeDir, "shim/index.js");
|
|
70
|
-
const shim = await readFile(shimPath, "utf8");
|
|
71
|
-
const importsDir = relative(dirname(join(srcDir, file)), join(srcDir, "server"));
|
|
72
|
-
const importsSrc = `${importsDir || "."}/edge-runtime-webpack.js`;
|
|
73
|
-
const imports = `import '${importsSrc}';`;
|
|
74
|
-
const exports = `export default _ENTRIES["middleware_${name}"].default;`;
|
|
75
|
-
const parts = [shim, imports];
|
|
76
|
-
if (wasm?.length) {
|
|
77
|
-
parts.push(
|
|
78
|
-
`import { decode as _base64Decode } from "../edge-runtime/vendor/deno.land/std@0.175.0/encoding/base64.ts";`
|
|
79
|
-
);
|
|
80
|
-
for (const wasmChunk of wasm ?? []) {
|
|
81
|
-
const data = await readFile(join(srcDir, wasmChunk.filePath));
|
|
82
|
-
parts.push(
|
|
83
|
-
`const ${wasmChunk.name} = _base64Decode(${JSON.stringify(
|
|
84
|
-
data.toString("base64")
|
|
85
|
-
)}).buffer`
|
|
86
|
-
);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
const entrypoint = await readFile(join(srcDir, file), "utf8");
|
|
90
|
-
await mkdir(dirname(join(destDir, file)), { recursive: true });
|
|
91
|
-
await writeFile(join(destDir, file), [...parts, entrypoint, exports].join("\n;"));
|
|
92
|
-
} else {
|
|
93
|
-
await cp(join(srcDir, file), join(destDir, file));
|
|
94
|
-
}
|
|
95
|
-
})
|
|
96
|
-
);
|
|
97
|
-
};
|
|
98
|
-
var createEdgeHandler = async (ctx, definition) => {
|
|
99
|
-
await copyHandlerDependencies(ctx, definition);
|
|
100
|
-
await writeHandlerFile(ctx, definition);
|
|
101
|
-
};
|
|
102
|
-
var getHandlerName = ({ name }) => `${EDGE_HANDLER_NAME}-${name.replace(/\W/g, "-")}`;
|
|
103
|
-
var buildHandlerDefinition = (ctx, { name, matchers, page }) => {
|
|
104
|
-
const fun = getHandlerName({ name });
|
|
105
|
-
const funName = name.endsWith("middleware") ? "Next.js Middleware Handler" : `Next.js Edge Handler: ${page}`;
|
|
106
|
-
const cache = name.endsWith("middleware") ? void 0 : "manual";
|
|
107
|
-
const generator = `${ctx.pluginName}@${ctx.pluginVersion}`;
|
|
108
|
-
return matchers.map((matcher) => ({
|
|
109
|
-
function: fun,
|
|
110
|
-
name: funName,
|
|
111
|
-
pattern: matcher.regexp,
|
|
112
|
-
cache,
|
|
113
|
-
generator
|
|
114
|
-
}));
|
|
115
|
-
};
|
|
116
|
-
var createEdgeHandlers = async (ctx) => {
|
|
117
|
-
await rm(ctx.edgeFunctionsDir, { recursive: true, force: true });
|
|
118
|
-
const nextManifest = await ctx.getMiddlewareManifest();
|
|
119
|
-
const nextDefinitions = [
|
|
120
|
-
...Object.values(nextManifest.middleware)
|
|
121
|
-
// ...Object.values(nextManifest.functions)
|
|
122
|
-
];
|
|
123
|
-
await Promise.all(nextDefinitions.map((def) => createEdgeHandler(ctx, def)));
|
|
124
|
-
const netlifyDefinitions = nextDefinitions.flatMap((def) => buildHandlerDefinition(ctx, def));
|
|
125
|
-
const netlifyManifest = {
|
|
126
|
-
version: 1,
|
|
127
|
-
functions: netlifyDefinitions
|
|
128
|
-
};
|
|
129
|
-
await writeEdgeManifest(ctx, netlifyManifest);
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
export {
|
|
133
|
-
createEdgeHandlers
|
|
134
|
-
};
|