@netlify/plugin-nextjs 5.10.0 → 5.10.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.
Files changed (48) hide show
  1. package/LICENSE +22 -0
  2. package/dist/build/advanced-api-routes.js +136 -4
  3. package/dist/build/cache.js +25 -4
  4. package/dist/build/content/prerendered.js +293 -11
  5. package/dist/build/content/server.js +219 -11
  6. package/dist/build/content/static.js +112 -15
  7. package/dist/build/functions/edge.js +540 -7
  8. package/dist/build/functions/server.js +130 -11
  9. package/dist/build/image-cdn.js +1599 -3
  10. package/dist/build/plugin-context.js +292 -6
  11. package/dist/build/verification.js +104 -9
  12. package/dist/esm-chunks/{package-F536DQ6H.js → package-7HACW4PO.js} +11 -10
  13. package/dist/index.js +19 -40
  14. package/dist/run/config.js +6 -7
  15. package/dist/run/constants.js +7 -5
  16. package/dist/run/handlers/cache.cjs +93 -1713
  17. package/dist/run/handlers/request-context.cjs +10 -3
  18. package/dist/run/handlers/server.js +14 -34
  19. package/dist/run/handlers/tracer.cjs +17 -116
  20. package/dist/run/handlers/tracing.js +2 -4
  21. package/dist/run/handlers/wait-until.cjs +2 -116
  22. package/dist/run/headers.js +183 -10
  23. package/dist/run/next.cjs +10 -1625
  24. package/dist/run/revalidate.js +24 -3
  25. package/dist/run/{regional-blob-store.cjs → storage/regional-blob-store.cjs} +44 -8
  26. package/dist/run/storage/request-scoped-in-memory-cache.cjs +1475 -0
  27. package/dist/run/storage/storage.cjs +84 -0
  28. package/dist/shared/blob-types.cjs +37 -0
  29. package/dist/shared/blobkey.js +15 -3
  30. package/package.json +1 -1
  31. package/dist/esm-chunks/chunk-3RQSTU2O.js +0 -554
  32. package/dist/esm-chunks/chunk-72ZI2IVI.js +0 -36
  33. package/dist/esm-chunks/chunk-AMY4NOT5.js +0 -1610
  34. package/dist/esm-chunks/chunk-DLBTTDNJ.js +0 -309
  35. package/dist/esm-chunks/chunk-DLVROEVU.js +0 -144
  36. package/dist/esm-chunks/chunk-GFYWJNQR.js +0 -305
  37. package/dist/esm-chunks/chunk-IJZEDP6B.js +0 -235
  38. package/dist/esm-chunks/chunk-K4RDUZYO.js +0 -609
  39. package/dist/esm-chunks/chunk-SGXRYMYQ.js +0 -127
  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-VTKZZRGT.js +0 -132
  43. package/dist/esm-chunks/chunk-WHUPSPWV.js +0 -73
  44. package/dist/esm-chunks/chunk-XS27YRA5.js +0 -34
  45. package/dist/esm-chunks/chunk-YMNWVS6T.js +0 -218
  46. package/dist/esm-chunks/chunk-ZENB67PD.js +0 -148
  47. package/dist/esm-chunks/chunk-ZSVHJNNY.js +0 -120
  48. package/dist/esm-chunks/next-7JK63CHT.js +0 -567
@@ -4,10 +4,31 @@
4
4
  return createRequire(import.meta.url);
5
5
  })();
6
6
 
7
- import {
8
- nextResponseProxy
9
- } from "../esm-chunks/chunk-XS27YRA5.js";
10
7
  import "../esm-chunks/chunk-OEQOKJGE.js";
8
+
9
+ // src/run/revalidate.ts
10
+ import { isPromise } from "node:util/types";
11
+ function isRevalidateMethod(key, nextResponseField) {
12
+ return key === "revalidate" && typeof nextResponseField === "function";
13
+ }
14
+ var nextResponseProxy = (res, requestContext) => {
15
+ return new Proxy(res, {
16
+ get(target, key) {
17
+ const originalValue = Reflect.get(target, key);
18
+ if (isRevalidateMethod(key, originalValue)) {
19
+ return function newRevalidate(...args) {
20
+ requestContext.didPagesRouterOnDemandRevalidate = true;
21
+ const result = originalValue.apply(target, args);
22
+ if (result && isPromise(result)) {
23
+ requestContext.trackBackgroundWork(result);
24
+ }
25
+ return result;
26
+ };
27
+ }
28
+ return originalValue;
29
+ }
30
+ });
31
+ };
11
32
  export {
12
33
  nextResponseProxy
13
34
  };
@@ -17,14 +17,15 @@ var __copyProps = (to, from, except, desc) => {
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
 
20
- // src/run/regional-blob-store.cts
20
+ // src/run/storage/regional-blob-store.cts
21
21
  var regional_blob_store_exports = {};
22
22
  __export(regional_blob_store_exports, {
23
- getRegionalBlobStore: () => getRegionalBlobStore
23
+ getRegionalBlobStore: () => getRegionalBlobStore,
24
+ setFetchBeforeNextPatchedIt: () => setFetchBeforeNextPatchedIt
24
25
  });
25
26
  module.exports = __toCommonJS(regional_blob_store_exports);
26
27
 
27
- // node_modules/@netlify/blobs/dist/chunk-GUEW34CP.js
28
+ // node_modules/@netlify/blobs/dist/chunk-XR3MUBBK.js
28
29
  var NF_ERROR = "x-nf-error";
29
30
  var NF_REQUEST_ID = "x-nf-request-id";
30
31
  var BlobsInternalError = class extends Error {
@@ -142,7 +143,10 @@ var BlobsConsistencyError = class extends Error {
142
143
  var REGION_AUTO = "auto";
143
144
  var regions = {
144
145
  "us-east-1": true,
145
- "us-east-2": true
146
+ "us-east-2": true,
147
+ "eu-central-1": true,
148
+ "ap-southeast-1": true,
149
+ "ap-southeast-2": true
146
150
  };
147
151
  var isValidRegion = (input) => Object.keys(regions).includes(input);
148
152
  var InvalidBlobsRegionError = class extends Error {
@@ -613,16 +617,48 @@ var getDeployStore = (input = {}) => {
613
617
  return new Store({ client, deployID, name: options.name });
614
618
  };
615
619
 
616
- // src/run/regional-blob-store.cts
617
- var fetchBeforeNextPatchedIt = globalThis.fetch;
620
+ // src/run/storage/regional-blob-store.cts
621
+ var FETCH_BEFORE_NEXT_PATCHED_IT = Symbol.for("nf-not-patched-fetch");
622
+ var extendedGlobalThis = globalThis;
623
+ function attemptToGetOriginalFetch(fetch) {
624
+ return fetch._nextOriginalFetch ?? fetch;
625
+ }
626
+ function forceOptOutOfUsingDataCache(fetch) {
627
+ return (input, init) => {
628
+ return fetch(input, {
629
+ ...init,
630
+ next: {
631
+ ...init?.next,
632
+ // setting next.internal = true should prevent from trying to use data cache
633
+ // https://github.com/vercel/next.js/blob/fa214c74c1d8023098c0e94e57f917ef9f1afd1a/packages/next/src/server/lib/patch-fetch.ts#L174
634
+ // https://github.com/vercel/next.js/blob/fa214c74c1d8023098c0e94e57f917ef9f1afd1a/packages/next/src/server/lib/patch-fetch.ts#L210-L213
635
+ // this is last line of defense in case we didn't manage to get unpatched fetch that will not affect
636
+ // fetch if it's unpatched so it should be safe to apply always if we aren't sure if we use patched fetch
637
+ // @ts-expect-error - this is an internal field that Next.js doesn't add to its global
638
+ // type overrides for RequestInit type (like `next.revalidate` or `next.tags`)
639
+ internal: true
640
+ }
641
+ });
642
+ };
643
+ }
644
+ var setFetchBeforeNextPatchedIt = (fetch) => {
645
+ extendedGlobalThis[FETCH_BEFORE_NEXT_PATCHED_IT] = forceOptOutOfUsingDataCache(
646
+ attemptToGetOriginalFetch(fetch)
647
+ );
648
+ };
649
+ var fetchBeforeNextPatchedItFallback = forceOptOutOfUsingDataCache(
650
+ attemptToGetOriginalFetch(globalThis.fetch)
651
+ );
652
+ var getFetchBeforeNextPatchedIt = () => extendedGlobalThis[FETCH_BEFORE_NEXT_PATCHED_IT] ?? fetchBeforeNextPatchedItFallback;
618
653
  var getRegionalBlobStore = (args = {}) => {
619
654
  return getDeployStore({
620
655
  ...args,
621
- fetch: fetchBeforeNextPatchedIt,
656
+ fetch: getFetchBeforeNextPatchedIt(),
622
657
  region: process.env.USE_REGIONAL_BLOBS?.toUpperCase() === "TRUE" ? void 0 : "us-east-2"
623
658
  });
624
659
  };
625
660
  // Annotate the CommonJS export names for ESM import in node:
626
661
  0 && (module.exports = {
627
- getRegionalBlobStore
662
+ getRegionalBlobStore,
663
+ setFetchBeforeNextPatchedIt
628
664
  });