@netlify/plugin-nextjs 5.1.1 → 5.2.0

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.
Files changed (42) hide show
  1. package/dist/build/advanced-api-routes.js +121 -4
  2. package/dist/build/cache.js +25 -4
  3. package/dist/build/content/prerendered.js +234 -8
  4. package/dist/build/content/server.js +259 -14
  5. package/dist/build/content/static.js +96 -11
  6. package/dist/build/functions/edge.js +511 -5
  7. package/dist/build/functions/server.js +131 -12
  8. package/dist/build/image-cdn.js +1626 -3
  9. package/dist/build/plugin-context.js +236 -5
  10. package/dist/build/templates/handler-monorepo.tmpl.js +3 -0
  11. package/dist/build/templates/handler.tmpl.js +3 -0
  12. package/dist/build/verification.js +81 -8
  13. package/dist/esm-chunks/{package-YB7ERSH4.js → package-ZBRSUKN7.js} +6 -6
  14. package/dist/index.js +25 -36
  15. package/dist/run/config.js +25 -6
  16. package/dist/run/constants.js +7 -5
  17. package/dist/run/handlers/cache.cjs +6 -567
  18. package/dist/run/handlers/request-context.cjs +8 -1
  19. package/dist/run/handlers/server.js +20 -22
  20. package/dist/run/handlers/tracing.js +1 -1
  21. package/dist/run/headers.js +198 -8
  22. package/dist/run/next.cjs +49 -567
  23. package/dist/{esm-chunks/chunk-PMRBBOBY.js → run/regional-blob-store.cjs} +117 -263
  24. package/dist/run/revalidate.js +17 -3
  25. package/dist/run/systemlog.js +94 -3
  26. package/dist/shared/blobkey.js +15 -3
  27. package/package.json +1 -1
  28. package/dist/esm-chunks/chunk-3NYX5FXN.js +0 -188
  29. package/dist/esm-chunks/chunk-3SUDZQ7L.js +0 -40
  30. package/dist/esm-chunks/chunk-72ZI2IVI.js +0 -36
  31. package/dist/esm-chunks/chunk-74THQNRG.js +0 -110
  32. package/dist/esm-chunks/chunk-BG455SFE.js +0 -133
  33. package/dist/esm-chunks/chunk-F5VQRN6L.js +0 -127
  34. package/dist/esm-chunks/chunk-HYBEXB2Z.js +0 -105
  35. package/dist/esm-chunks/chunk-MCEOSJH6.js +0 -1637
  36. package/dist/esm-chunks/chunk-MRD3XSKD.js +0 -248
  37. package/dist/esm-chunks/chunk-OBKVBMAL.js +0 -524
  38. package/dist/esm-chunks/chunk-PH26UF2W.js +0 -86
  39. package/dist/esm-chunks/chunk-RL4K4CVH.js +0 -27
  40. package/dist/esm-chunks/chunk-TYCYFZ22.js +0 -25
  41. package/dist/esm-chunks/chunk-UYKENJEU.js +0 -19
  42. package/dist/esm-chunks/chunk-ZKJEJNSJ.js +0 -278
@@ -1,17 +1,39 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
1
19
 
2
- var require = await (async () => {
3
- var { createRequire } = await import("node:module");
4
- return createRequire(import.meta.url);
5
- })();
6
-
7
- import {
8
- encodeBlobKey
9
- } from "./chunk-TYCYFZ22.js";
20
+ // src/run/regional-blob-store.cts
21
+ var regional_blob_store_exports = {};
22
+ __export(regional_blob_store_exports, {
23
+ getRegionalBlobStore: () => getRegionalBlobStore
24
+ });
25
+ module.exports = __toCommonJS(regional_blob_store_exports);
10
26
 
11
- // node_modules/@netlify/blobs/dist/chunk-6TGYNZGH.js
27
+ // node_modules/@netlify/blobs/dist/chunk-SGXOM2EY.js
28
+ var NF_ERROR = "x-nf-error";
29
+ var NF_REQUEST_ID = "x-nf-request-id";
12
30
  var BlobsInternalError = class extends Error {
13
- constructor(statusCode) {
14
- super(`Netlify Blobs has generated an internal error: ${statusCode} response`);
31
+ constructor(res) {
32
+ let details = res.headers.get(NF_ERROR) || `${res.status} status code`;
33
+ if (res.headers.has(NF_REQUEST_ID)) {
34
+ details += `, ID: ${res.headers.get(NF_REQUEST_ID)}`;
35
+ }
36
+ super(`Netlify Blobs has generated an internal error (${details})`);
15
37
  this.name = "BlobsInternalError";
16
38
  }
17
39
  };
@@ -23,19 +45,55 @@ var collectIterator = async (iterator) => {
23
45
  return result;
24
46
  };
25
47
  var base64Decode = (input) => {
26
- const { Buffer } = globalThis;
27
- if (Buffer) {
28
- return Buffer.from(input, "base64").toString();
48
+ const { Buffer: Buffer2 } = globalThis;
49
+ if (Buffer2) {
50
+ return Buffer2.from(input, "base64").toString();
29
51
  }
30
52
  return atob(input);
31
53
  };
32
54
  var base64Encode = (input) => {
33
- const { Buffer } = globalThis;
34
- if (Buffer) {
35
- return Buffer.from(input).toString("base64");
55
+ const { Buffer: Buffer2 } = globalThis;
56
+ if (Buffer2) {
57
+ return Buffer2.from(input).toString("base64");
36
58
  }
37
59
  return btoa(input);
38
60
  };
61
+ var getEnvironment = () => {
62
+ const { Deno, Netlify, process: process2 } = globalThis;
63
+ return Netlify?.env ?? Deno?.env ?? {
64
+ delete: (key) => delete process2?.env[key],
65
+ get: (key) => process2?.env[key],
66
+ has: (key) => Boolean(process2?.env[key]),
67
+ set: (key, value) => {
68
+ if (process2?.env) {
69
+ process2.env[key] = value;
70
+ }
71
+ },
72
+ toObject: () => process2?.env ?? {}
73
+ };
74
+ };
75
+ var getEnvironmentContext = () => {
76
+ const context = globalThis.netlifyBlobsContext || getEnvironment().get("NETLIFY_BLOBS_CONTEXT");
77
+ if (typeof context !== "string" || !context) {
78
+ return {};
79
+ }
80
+ const data = base64Decode(context);
81
+ try {
82
+ return JSON.parse(data);
83
+ } catch {
84
+ }
85
+ return {};
86
+ };
87
+ var MissingBlobsEnvironmentError = class extends Error {
88
+ constructor(requiredProperties) {
89
+ super(
90
+ `The environment has not been configured to use Netlify Blobs. To use it manually, supply the following properties when creating a store: ${requiredProperties.join(
91
+ ", "
92
+ )}`
93
+ );
94
+ this.name = "MissingBlobsEnvironmentError";
95
+ }
96
+ };
39
97
  var BASE64_PREFIX = "b64;";
40
98
  var METADATA_HEADER_INTERNAL = "x-amz-meta-user";
41
99
  var METADATA_HEADER_EXTERNAL = "netlify-blobs-metadata";
@@ -81,42 +139,6 @@ var BlobsConsistencyError = class extends Error {
81
139
  this.name = "BlobsConsistencyError";
82
140
  }
83
141
  };
84
- var getEnvironment = () => {
85
- const { Deno, Netlify, process } = globalThis;
86
- return Netlify?.env ?? Deno?.env ?? {
87
- delete: (key) => delete process?.env[key],
88
- get: (key) => process?.env[key],
89
- has: (key) => Boolean(process?.env[key]),
90
- set: (key, value) => {
91
- if (process?.env) {
92
- process.env[key] = value;
93
- }
94
- },
95
- toObject: () => process?.env ?? {}
96
- };
97
- };
98
- var getEnvironmentContext = () => {
99
- const context = globalThis.netlifyBlobsContext || getEnvironment().get("NETLIFY_BLOBS_CONTEXT");
100
- if (typeof context !== "string" || !context) {
101
- return {};
102
- }
103
- const data = base64Decode(context);
104
- try {
105
- return JSON.parse(data);
106
- } catch {
107
- }
108
- return {};
109
- };
110
- var MissingBlobsEnvironmentError = class extends Error {
111
- constructor(requiredProperties) {
112
- super(
113
- `The environment has not been configured to use Netlify Blobs. To use it manually, supply the following properties when creating a store: ${requiredProperties.join(
114
- ", "
115
- )}`
116
- );
117
- this.name = "MissingBlobsEnvironmentError";
118
- }
119
- };
120
142
  var DEFAULT_RETRY_DELAY = getEnvironment().get("NODE_ENV") === "test" ? 1 : 5e3;
121
143
  var MIN_RETRY_DELAY = 1e3;
122
144
  var MAX_RETRY = 5;
@@ -150,11 +172,12 @@ var sleep = (ms) => new Promise((resolve) => {
150
172
  });
151
173
  var SIGNED_URL_ACCEPT_HEADER = "application/json;type=signed-url";
152
174
  var Client = class {
153
- constructor({ apiURL, consistency, edgeURL, fetch, siteID, token, uncachedEdgeURL }) {
175
+ constructor({ apiURL, consistency, edgeURL, fetch, region, siteID, token, uncachedEdgeURL }) {
154
176
  this.apiURL = apiURL;
155
177
  this.consistency = consistency ?? "eventual";
156
178
  this.edgeURL = edgeURL;
157
179
  this.fetch = fetch ?? globalThis.fetch;
180
+ this.region = region;
158
181
  this.siteID = siteID;
159
182
  this.token = token;
160
183
  this.uncachedEdgeURL = uncachedEdgeURL;
@@ -191,6 +214,9 @@ var Client = class {
191
214
  if (encodedMetadata) {
192
215
  headers[METADATA_HEADER_INTERNAL] = encodedMetadata;
193
216
  }
217
+ if (this.region) {
218
+ urlPath = `/region:${this.region}${urlPath}`;
219
+ }
194
220
  const url2 = new URL(urlPath, consistency === "strong" ? this.uncachedEdgeURL : this.edgeURL);
195
221
  for (const key2 in parameters) {
196
222
  url2.searchParams.set(key2, parameters[key2]);
@@ -205,6 +231,9 @@ var Client = class {
205
231
  for (const key2 in parameters) {
206
232
  url.searchParams.set(key2, parameters[key2]);
207
233
  }
234
+ if (this.region) {
235
+ url.searchParams.set("region", this.region);
236
+ }
208
237
  if (storeName === void 0 || key === void 0) {
209
238
  return {
210
239
  headers: apiHeaders,
@@ -225,7 +254,7 @@ var Client = class {
225
254
  method
226
255
  });
227
256
  if (res.status !== 200) {
228
- throw new Error(`Netlify Blobs has generated an internal error: ${res.status} response`);
257
+ throw new BlobsInternalError(res);
229
258
  }
230
259
  const { url: signedURL } = await res.json();
231
260
  const userHeaders = encodedMetadata ? { [METADATA_HEADER_INTERNAL]: encodedMetadata } : void 0;
@@ -282,6 +311,7 @@ var getClientOptions = (options, contextOverride) => {
282
311
  consistency: options.consistency,
283
312
  edgeURL: context.edgeURL ?? options.edgeURL,
284
313
  fetch: options.fetch,
314
+ region: options.region,
285
315
  siteID,
286
316
  token,
287
317
  uncachedEdgeURL: context.uncachedEdgeURL ?? options.uncachedEdgeURL
@@ -311,7 +341,7 @@ var Store = class _Store {
311
341
  async delete(key) {
312
342
  const res = await this.client.makeRequest({ key, method: "delete", storeName: this.name });
313
343
  if (![200, 204, 404].includes(res.status)) {
314
- throw new BlobsInternalError(res.status);
344
+ throw new BlobsInternalError(res);
315
345
  }
316
346
  }
317
347
  async get(key, options) {
@@ -321,7 +351,7 @@ var Store = class _Store {
321
351
  return null;
322
352
  }
323
353
  if (res.status !== 200) {
324
- throw new BlobsInternalError(res.status);
354
+ throw new BlobsInternalError(res);
325
355
  }
326
356
  if (type === void 0 || type === "text") {
327
357
  return res.text();
@@ -338,7 +368,7 @@ var Store = class _Store {
338
368
  if (type === "stream") {
339
369
  return res.body;
340
370
  }
341
- throw new BlobsInternalError(res.status);
371
+ throw new BlobsInternalError(res);
342
372
  }
343
373
  async getMetadata(key, { consistency } = {}) {
344
374
  const res = await this.client.makeRequest({ consistency, key, method: "head", storeName: this.name });
@@ -346,7 +376,7 @@ var Store = class _Store {
346
376
  return null;
347
377
  }
348
378
  if (res.status !== 200 && res.status !== 304) {
349
- throw new BlobsInternalError(res.status);
379
+ throw new BlobsInternalError(res);
350
380
  }
351
381
  const etag = res?.headers.get("etag") ?? void 0;
352
382
  const metadata = getMetadataFromResponse(res);
@@ -370,7 +400,7 @@ var Store = class _Store {
370
400
  return null;
371
401
  }
372
402
  if (res.status !== 200 && res.status !== 304) {
373
- throw new BlobsInternalError(res.status);
403
+ throw new BlobsInternalError(res);
374
404
  }
375
405
  const responseETag = res?.headers.get("etag") ?? void 0;
376
406
  const metadata = getMetadataFromResponse(res);
@@ -423,7 +453,7 @@ var Store = class _Store {
423
453
  storeName: this.name
424
454
  });
425
455
  if (res.status !== 200) {
426
- throw new BlobsInternalError(res.status);
456
+ throw new BlobsInternalError(res);
427
457
  }
428
458
  }
429
459
  async setJSON(key, data, { metadata } = {}) {
@@ -441,7 +471,7 @@ var Store = class _Store {
441
471
  storeName: this.name
442
472
  });
443
473
  if (res.status !== 200) {
444
- throw new BlobsInternalError(res.status);
474
+ throw new BlobsInternalError(res);
445
475
  }
446
476
  }
447
477
  static formatListResultBlob(result) {
@@ -535,211 +565,35 @@ var getDeployStore = (options = {}) => {
535
565
  throw new MissingBlobsEnvironmentError(["deployID"]);
536
566
  }
537
567
  const clientOptions = getClientOptions(options, context);
538
- const client = new Client(clientOptions);
539
- return new Store({ client, deployID });
540
- };
541
-
542
- // src/run/headers.ts
543
- var ALL_VARIATIONS = Symbol.for("ALL_VARIATIONS");
544
- var NetlifyVaryKeys = /* @__PURE__ */ new Set(["header", "language", "cookie", "query", "country"]);
545
- var isNetlifyVaryKey = (key) => NetlifyVaryKeys.has(key);
546
- var generateNetlifyVaryValues = ({
547
- header,
548
- language,
549
- cookie,
550
- query,
551
- country
552
- }) => {
553
- const values = [];
554
- if (query.length !== 0) {
555
- if (query.includes(ALL_VARIATIONS)) {
556
- values.push(`query`);
557
- } else {
558
- values.push(`query=${query.join(`|`)}`);
568
+ if (options.experimentalRegion === "context") {
569
+ if (!context.primaryRegion) {
570
+ throw new Error(
571
+ 'The Netlify Blobs client was initialized with `experimentalRegion: "context"` but there is no region configured in the environment'
572
+ );
559
573
  }
560
- }
561
- if (header.length !== 0) {
562
- values.push(`header=${header.join(`|`)}`);
563
- }
564
- if (language.length !== 0) {
565
- values.push(`language=${language.join(`|`)}`);
566
- }
567
- if (cookie.length !== 0) {
568
- values.push(`cookie=${cookie.join(`|`)}`);
569
- }
570
- if (country.length !== 0) {
571
- values.push(`country=${country.join(`|`)}`);
572
- }
573
- return values.join(",");
574
- };
575
- var getHeaderValueArray = (header) => {
576
- return header.split(",").map((value) => value.trim());
577
- };
578
- var omitHeaderValues = (header, values) => {
579
- const headerValues = getHeaderValueArray(header);
580
- const filteredValues = headerValues.filter(
581
- (value) => !values.some((val) => value.startsWith(val))
582
- );
583
- return filteredValues.join(", ");
584
- };
585
- var mapHeaderValues = (header, callback) => {
586
- const headerValues = getHeaderValueArray(header);
587
- const mappedValues = headerValues.map(callback);
588
- return mappedValues.join(", ");
589
- };
590
- var setVaryHeaders = (headers, request, { basePath, i18n }) => {
591
- const netlifyVaryValues = {
592
- header: ["x-nextjs-data"],
593
- language: [],
594
- cookie: ["__prerender_bypass", "__next_preview_data"],
595
- query: [],
596
- country: []
597
- };
598
- const vary = headers.get("vary");
599
- if (vary !== null) {
600
- netlifyVaryValues.header.push(...getHeaderValueArray(vary));
601
- }
602
- const path = new URL(request.url).pathname;
603
- const locales = i18n && i18n.localeDetection !== false ? i18n.locales : [];
604
- if (locales.length > 1 && (path === "/" || path === basePath)) {
605
- netlifyVaryValues.language.push(...locales);
606
- netlifyVaryValues.cookie.push(`NEXT_LOCALE`);
607
- }
608
- const userNetlifyVary = headers.get("netlify-vary");
609
- if (userNetlifyVary) {
610
- const directives = getHeaderValueArray(userNetlifyVary);
611
- for (const directive of directives) {
612
- const [key, value] = directive.split("=");
613
- if (key === "query" && !value) {
614
- netlifyVaryValues.query.push(ALL_VARIATIONS);
615
- } else if (value && isNetlifyVaryKey(key)) {
616
- netlifyVaryValues[key].push(...value.split("|"));
617
- }
574
+ clientOptions.region = context.primaryRegion;
575
+ } else if (options.experimentalRegion === "auto") {
576
+ if (clientOptions.edgeURL) {
577
+ throw new Error(
578
+ 'The Netlify Blobs client was initialized with `experimentalRegion: "auto"` which is not compatible with the `edgeURL` property; consider using `apiURL` instead'
579
+ );
618
580
  }
581
+ clientOptions.region = options.experimentalRegion;
619
582
  }
620
- headers.set(`netlify-vary`, generateNetlifyVaryValues(netlifyVaryValues));
583
+ const client = new Client(clientOptions);
584
+ return new Store({ client, deployID });
621
585
  };
586
+
587
+ // src/run/regional-blob-store.cts
622
588
  var fetchBeforeNextPatchedIt = globalThis.fetch;
623
- var adjustDateHeader = async ({
624
- headers,
625
- request,
626
- span,
627
- tracer,
628
- requestContext
629
- }) => {
630
- const cacheState = headers.get("x-nextjs-cache");
631
- const isServedFromCache = cacheState === "HIT" || cacheState === "STALE";
632
- span.setAttributes({
633
- "x-nextjs-cache": cacheState ?? void 0,
634
- isServedFromCache
589
+ var getRegionalBlobStore = (args = {}) => {
590
+ return getDeployStore({
591
+ ...args,
592
+ fetch: fetchBeforeNextPatchedIt,
593
+ experimentalRegion: process.env.USE_REGIONAL_BLOBS?.toUpperCase() === "TRUE" ? "context" : void 0
635
594
  });
636
- if (!isServedFromCache) {
637
- return;
638
- }
639
- const key = new URL(request.url).pathname;
640
- let lastModified;
641
- if (requestContext.responseCacheGetLastModified) {
642
- lastModified = requestContext.responseCacheGetLastModified;
643
- } else {
644
- span.recordException(
645
- new Error("lastModified not found in requestContext, falling back to trying blobs")
646
- );
647
- span.setAttributes({
648
- severity: "alert",
649
- warning: true
650
- });
651
- const blobKey = await encodeBlobKey(key);
652
- const blobStore = getDeployStore({ fetch: fetchBeforeNextPatchedIt, consistency: "strong" });
653
- lastModified = await tracer.withActiveSpan(
654
- "get cache to calculate date header",
655
- async (getBlobForDateSpan) => {
656
- getBlobForDateSpan.setAttributes({
657
- key,
658
- blobKey
659
- });
660
- const blob = await blobStore.get(blobKey, { type: "json" }) ?? {};
661
- getBlobForDateSpan.addEvent(blob ? "Cache hit" : "Cache miss");
662
- return blob.lastModified;
663
- }
664
- );
665
- }
666
- if (!lastModified) {
667
- span.recordException(
668
- new Error(
669
- "lastModified not found in either requestContext or blobs, date header for cached response is not set"
670
- )
671
- );
672
- span.setAttributes({
673
- severity: "alert",
674
- warning: true
675
- });
676
- return;
677
- }
678
- const lastModifiedDate = new Date(lastModified);
679
- headers.set("x-nextjs-date", headers.get("date") ?? lastModifiedDate.toUTCString());
680
- headers.set("date", lastModifiedDate.toUTCString());
681
- };
682
- var setCacheControlHeaders = (headers, request, requestContext) => {
683
- if (typeof requestContext.routeHandlerRevalidate !== "undefined" && ["GET", "HEAD"].includes(request.method) && !headers.has("cdn-cache-control") && !headers.has("netlify-cdn-cache-control")) {
684
- const cdnCacheControl = (
685
- // if we are serving already stale response, instruct edge to not attempt to cache that response
686
- headers.get("x-nextjs-cache") === "STALE" ? "public, max-age=0, must-revalidate" : `s-maxage=${requestContext.routeHandlerRevalidate === false ? 31536e3 : requestContext.routeHandlerRevalidate}, stale-while-revalidate=31536000`
687
- );
688
- headers.set("netlify-cdn-cache-control", cdnCacheControl);
689
- return;
690
- }
691
- const cacheControl = headers.get("cache-control");
692
- if (cacheControl !== null && ["GET", "HEAD"].includes(request.method) && !headers.has("cdn-cache-control") && !headers.has("netlify-cdn-cache-control")) {
693
- const browserCacheControl = omitHeaderValues(cacheControl, [
694
- "s-maxage",
695
- "stale-while-revalidate"
696
- ]);
697
- const cdnCacheControl = (
698
- // if we are serving already stale response, instruct edge to not attempt to cache that response
699
- headers.get("x-nextjs-cache") === "STALE" ? "public, max-age=0, must-revalidate" : mapHeaderValues(
700
- cacheControl,
701
- (value) => value === "stale-while-revalidate" ? "stale-while-revalidate=31536000" : value
702
- )
703
- );
704
- headers.set("cache-control", browserCacheControl || "public, max-age=0, must-revalidate");
705
- headers.set("netlify-cdn-cache-control", cdnCacheControl);
706
- return;
707
- }
708
- if (cacheControl === null && !headers.has("cdn-cache-control") && !headers.has("netlify-cdn-cache-control") && requestContext.usedFsRead) {
709
- headers.set("cache-control", "public, max-age=0, must-revalidate");
710
- headers.set("netlify-cdn-cache-control", `max-age=31536000`);
711
- }
712
- };
713
- function getCanonicalPathFromCacheKey(cacheKey) {
714
- return cacheKey === "/index" ? "/" : cacheKey;
715
- }
716
- var setCacheTagsHeaders = (headers, request, manifest, requestContext) => {
717
- const path = getCanonicalPathFromCacheKey(requestContext.responseCacheKey) ?? new URL(request.url).pathname;
718
- const tags = manifest[path];
719
- if (tags !== void 0) {
720
- headers.set("netlify-cache-tag", tags);
721
- }
722
- };
723
- var NEXT_CACHE_TO_CACHE_STATUS = {
724
- HIT: `hit`,
725
- MISS: `fwd=miss`,
726
- STALE: `hit; fwd=stale`
727
- };
728
- var setCacheStatusHeader = (headers) => {
729
- const nextCache = headers.get("x-nextjs-cache");
730
- if (typeof nextCache === "string") {
731
- if (nextCache in NEXT_CACHE_TO_CACHE_STATUS) {
732
- const cacheStatus = NEXT_CACHE_TO_CACHE_STATUS[nextCache];
733
- headers.set("cache-status", `"Next.js"; ${cacheStatus}`);
734
- }
735
- headers.delete("x-nextjs-cache");
736
- }
737
- };
738
-
739
- export {
740
- setVaryHeaders,
741
- adjustDateHeader,
742
- setCacheControlHeaders,
743
- setCacheTagsHeaders,
744
- setCacheStatusHeader
745
595
  };
596
+ // Annotate the CommonJS export names for ESM import in node:
597
+ 0 && (module.exports = {
598
+ getRegionalBlobStore
599
+ });
@@ -4,10 +4,24 @@
4
4
  return createRequire(import.meta.url);
5
5
  })();
6
6
 
7
- import {
8
- nextResponseProxy
9
- } from "../esm-chunks/chunk-RL4K4CVH.js";
10
7
  import "../esm-chunks/chunk-5JVNISGM.js";
8
+
9
+ // src/run/revalidate.ts
10
+ var nextResponseProxy = (res, requestContext) => {
11
+ return new Proxy(res, {
12
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
13
+ get(target, key) {
14
+ const originalValue = target[key];
15
+ if (key === "revalidate") {
16
+ return async function newRevalidate(...args) {
17
+ requestContext.didPagesRouterOnDemandRevalidate = true;
18
+ return originalValue?.apply(target, args);
19
+ };
20
+ }
21
+ return originalValue;
22
+ }
23
+ });
24
+ };
11
25
  export {
12
26
  nextResponseProxy
13
27
  };
@@ -5,9 +5,100 @@
5
5
  })();
6
6
 
7
7
  import {
8
- import_internal
9
- } from "../esm-chunks/chunk-HYBEXB2Z.js";
10
- import "../esm-chunks/chunk-5JVNISGM.js";
8
+ __commonJS,
9
+ __require,
10
+ __toESM
11
+ } from "../esm-chunks/chunk-5JVNISGM.js";
12
+
13
+ // node_modules/@netlify/functions/dist/lib/system_logger.js
14
+ var require_system_logger = __commonJS({
15
+ "node_modules/@netlify/functions/dist/lib/system_logger.js"(exports) {
16
+ "use strict";
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.systemLogger = exports.LogLevel = void 0;
19
+ var process_1 = __require("process");
20
+ var systemLogTag = "__nfSystemLog";
21
+ var serializeError = (error) => {
22
+ const cause = error?.cause instanceof Error ? serializeError(error.cause) : error.cause;
23
+ return {
24
+ error: error.message,
25
+ error_cause: cause,
26
+ error_stack: error.stack
27
+ };
28
+ };
29
+ var LogLevel2;
30
+ (function(LogLevel3) {
31
+ LogLevel3[LogLevel3["Debug"] = 1] = "Debug";
32
+ LogLevel3[LogLevel3["Log"] = 2] = "Log";
33
+ LogLevel3[LogLevel3["Error"] = 3] = "Error";
34
+ })(LogLevel2 = exports.LogLevel || (exports.LogLevel = {}));
35
+ var SystemLogger = class _SystemLogger {
36
+ fields;
37
+ logLevel;
38
+ constructor(fields = {}, logLevel = LogLevel2.Log) {
39
+ this.fields = fields;
40
+ this.logLevel = logLevel;
41
+ }
42
+ doLog(logger, message) {
43
+ if (process_1.env.NETLIFY_DEV && !process_1.env.NETLIFY_ENABLE_SYSTEM_LOGGING) {
44
+ return;
45
+ }
46
+ logger(systemLogTag, JSON.stringify({ msg: message, fields: this.fields }));
47
+ }
48
+ log(message) {
49
+ if (this.logLevel > LogLevel2.Log) {
50
+ return;
51
+ }
52
+ this.doLog(console.log, message);
53
+ }
54
+ debug(message) {
55
+ if (this.logLevel > LogLevel2.Debug) {
56
+ return;
57
+ }
58
+ this.doLog(console.debug, message);
59
+ }
60
+ error(message) {
61
+ if (this.logLevel > LogLevel2.Error) {
62
+ return;
63
+ }
64
+ this.doLog(console.error, message);
65
+ }
66
+ withLogLevel(level) {
67
+ return new _SystemLogger(this.fields, level);
68
+ }
69
+ withFields(fields) {
70
+ return new _SystemLogger({
71
+ ...this.fields,
72
+ ...fields
73
+ }, this.logLevel);
74
+ }
75
+ withError(error) {
76
+ const fields = error instanceof Error ? serializeError(error) : { error };
77
+ return this.withFields(fields);
78
+ }
79
+ };
80
+ exports.systemLogger = new SystemLogger();
81
+ }
82
+ });
83
+
84
+ // node_modules/@netlify/functions/dist/internal.js
85
+ var require_internal = __commonJS({
86
+ "node_modules/@netlify/functions/dist/internal.js"(exports) {
87
+ "use strict";
88
+ Object.defineProperty(exports, "__esModule", { value: true });
89
+ exports.LogLevel = exports.systemLogger = void 0;
90
+ var system_logger_js_1 = require_system_logger();
91
+ Object.defineProperty(exports, "systemLogger", { enumerable: true, get: function() {
92
+ return system_logger_js_1.systemLogger;
93
+ } });
94
+ Object.defineProperty(exports, "LogLevel", { enumerable: true, get: function() {
95
+ return system_logger_js_1.LogLevel;
96
+ } });
97
+ }
98
+ });
99
+
100
+ // src/run/systemlog.ts
101
+ var import_internal = __toESM(require_internal(), 1);
11
102
  var export_LogLevel = import_internal.LogLevel;
12
103
  var export_logger = import_internal.systemLogger;
13
104
  export {
@@ -4,10 +4,22 @@
4
4
  return createRequire(import.meta.url);
5
5
  })();
6
6
 
7
- import {
8
- encodeBlobKey
9
- } from "../esm-chunks/chunk-TYCYFZ22.js";
10
7
  import "../esm-chunks/chunk-5JVNISGM.js";
8
+
9
+ // src/shared/blobkey.ts
10
+ import { Buffer } from "node:buffer";
11
+ import { webcrypto as crypto } from "node:crypto";
12
+ var maxLength = 180;
13
+ async function encodeBlobKey(key) {
14
+ const buffer = Buffer.from(key);
15
+ const base64 = buffer.toString("base64url");
16
+ if (base64.length <= maxLength) {
17
+ return base64;
18
+ }
19
+ const digest = await crypto.subtle.digest("SHA-256", buffer);
20
+ const hash = Buffer.from(digest).toString("base64url");
21
+ return `${base64.slice(0, maxLength - hash.length - 1)}-${hash}`;
22
+ }
11
23
  export {
12
24
  encodeBlobKey
13
25
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netlify/plugin-nextjs",
3
- "version": "5.1.1",
3
+ "version": "5.2.0",
4
4
  "description": "Run Next.js seamlessly on Netlify",
5
5
  "main": "./dist/index.js",
6
6
  "type": "module",