@netlify/plugin-nextjs 5.1.2 → 5.2.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.
Files changed (43) 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 +237 -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 +1615 -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-RVJOBSMH.js → package-SCUAWNXR.js} +23 -23
  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 +27022 -10456
  21. package/dist/run/headers.js +198 -8
  22. package/dist/run/next.cjs +106 -655
  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/edge-runtime/lib/response.ts +3 -2
  28. package/package.json +1 -1
  29. package/dist/esm-chunks/chunk-3SUDZQ7L.js +0 -40
  30. package/dist/esm-chunks/chunk-4BNHE6TP.js +0 -278
  31. package/dist/esm-chunks/chunk-72ZI2IVI.js +0 -36
  32. package/dist/esm-chunks/chunk-BG455SFE.js +0 -133
  33. package/dist/esm-chunks/chunk-HESS57SH.js +0 -127
  34. package/dist/esm-chunks/chunk-HYBEXB2Z.js +0 -105
  35. package/dist/esm-chunks/chunk-K7BTUM7O.js +0 -97
  36. package/dist/esm-chunks/chunk-L6OM53B6.js +0 -238
  37. package/dist/esm-chunks/chunk-MCEOSJH6.js +0 -1637
  38. package/dist/esm-chunks/chunk-MRD3XSKD.js +0 -248
  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-UTQSBE5O.js +0 -524
  42. package/dist/esm-chunks/chunk-UYKENJEU.js +0 -19
  43. package/dist/esm-chunks/chunk-V2T6NUOM.js +0 -113
@@ -1,248 +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
- encodeBlobKey
9
- } from "./chunk-TYCYFZ22.js";
10
- import {
11
- wrapTracer
12
- } from "./chunk-PDPDW32D.js";
13
- import {
14
- init_esm,
15
- trace
16
- } from "./chunk-Y3K5Q6FP.js";
17
- import {
18
- require_out
19
- } from "./chunk-VZNKO4OO.js";
20
- import {
21
- __toESM
22
- } from "./chunk-5JVNISGM.js";
23
-
24
- // src/build/content/prerendered.ts
25
- init_esm();
26
- import { existsSync } from "node:fs";
27
- import { mkdir, readFile, writeFile } from "node:fs/promises";
28
- import { join } from "node:path";
29
- var import_fast_glob = __toESM(require_out(), 1);
30
-
31
- // node_modules/yocto-queue/index.js
32
- var Node = class {
33
- value;
34
- next;
35
- constructor(value) {
36
- this.value = value;
37
- }
38
- };
39
- var Queue = class {
40
- #head;
41
- #tail;
42
- #size;
43
- constructor() {
44
- this.clear();
45
- }
46
- enqueue(value) {
47
- const node = new Node(value);
48
- if (this.#head) {
49
- this.#tail.next = node;
50
- this.#tail = node;
51
- } else {
52
- this.#head = node;
53
- this.#tail = node;
54
- }
55
- this.#size++;
56
- }
57
- dequeue() {
58
- const current = this.#head;
59
- if (!current) {
60
- return;
61
- }
62
- this.#head = this.#head.next;
63
- this.#size--;
64
- return current.value;
65
- }
66
- clear() {
67
- this.#head = void 0;
68
- this.#tail = void 0;
69
- this.#size = 0;
70
- }
71
- get size() {
72
- return this.#size;
73
- }
74
- *[Symbol.iterator]() {
75
- let current = this.#head;
76
- while (current) {
77
- yield current.value;
78
- current = current.next;
79
- }
80
- }
81
- };
82
-
83
- // node_modules/p-limit/index.js
84
- function pLimit(concurrency) {
85
- if (!((Number.isInteger(concurrency) || concurrency === Number.POSITIVE_INFINITY) && concurrency > 0)) {
86
- throw new TypeError("Expected `concurrency` to be a number from 1 and up");
87
- }
88
- const queue = new Queue();
89
- let activeCount = 0;
90
- const next = () => {
91
- activeCount--;
92
- if (queue.size > 0) {
93
- queue.dequeue()();
94
- }
95
- };
96
- const run = async (fn, resolve, args) => {
97
- activeCount++;
98
- const result = (async () => fn(...args))();
99
- resolve(result);
100
- try {
101
- await result;
102
- } catch {
103
- }
104
- next();
105
- };
106
- const enqueue = (fn, resolve, args) => {
107
- queue.enqueue(run.bind(void 0, fn, resolve, args));
108
- (async () => {
109
- await Promise.resolve();
110
- if (activeCount < concurrency && queue.size > 0) {
111
- queue.dequeue()();
112
- }
113
- })();
114
- };
115
- const generator = (fn, ...args) => new Promise((resolve) => {
116
- enqueue(fn, resolve, args);
117
- });
118
- Object.defineProperties(generator, {
119
- activeCount: {
120
- get: () => activeCount
121
- },
122
- pendingCount: {
123
- get: () => queue.size
124
- },
125
- clearQueue: {
126
- value: () => {
127
- queue.clear();
128
- }
129
- }
130
- });
131
- return generator;
132
- }
133
-
134
- // src/build/content/prerendered.ts
135
- var tracer = wrapTracer(trace.getTracer("Next runtime"));
136
- var writeCacheEntry = async (route, value, lastModified, ctx) => {
137
- const path = join(ctx.blobDir, await encodeBlobKey(route));
138
- const entry = JSON.stringify({
139
- lastModified,
140
- value
141
- });
142
- await writeFile(path, entry, "utf-8");
143
- };
144
- var routeToFilePath = (path) => path === "/" ? "/index" : path;
145
- var buildPagesCacheValue = async (path) => ({
146
- kind: "PAGE",
147
- html: await readFile(`${path}.html`, "utf-8"),
148
- pageData: JSON.parse(await readFile(`${path}.json`, "utf-8")),
149
- postponed: void 0,
150
- headers: void 0,
151
- status: void 0
152
- });
153
- var buildAppCacheValue = async (path) => {
154
- const meta = JSON.parse(await readFile(`${path}.meta`, "utf-8"));
155
- const rsc = await readFile(`${path}.rsc`, "utf-8").catch(
156
- () => readFile(`${path}.prefetch.rsc`, "utf-8")
157
- );
158
- if (!meta.status && rsc.includes("NEXT_NOT_FOUND")) {
159
- meta.status = 404;
160
- }
161
- return {
162
- kind: "PAGE",
163
- html: await readFile(`${path}.html`, "utf-8"),
164
- pageData: rsc,
165
- ...meta
166
- };
167
- };
168
- var buildRouteCacheValue = async (path, initialRevalidateSeconds) => ({
169
- kind: "ROUTE",
170
- body: await readFile(`${path}.body`, "base64"),
171
- ...JSON.parse(await readFile(`${path}.meta`, "utf-8")),
172
- revalidate: initialRevalidateSeconds
173
- });
174
- var buildFetchCacheValue = async (path) => ({
175
- kind: "FETCH",
176
- ...JSON.parse(await readFile(path, "utf-8"))
177
- });
178
- var copyPrerenderedContent = async (ctx) => {
179
- return tracer.withActiveSpan("copyPrerenderedContent", async () => {
180
- try {
181
- await mkdir(ctx.blobDir, { recursive: true });
182
- const manifest = await ctx.getPrerenderManifest();
183
- const limitConcurrentPrerenderContentHandling = pLimit(10);
184
- await Promise.all(
185
- Object.entries(manifest.routes).map(
186
- ([route, meta]) => limitConcurrentPrerenderContentHandling(async () => {
187
- const lastModified = meta.initialRevalidateSeconds ? Date.now() - 31536e6 : Date.now();
188
- const key = routeToFilePath(route);
189
- let value;
190
- switch (true) {
191
- case (meta.dataRoute?.endsWith("/default.rsc") && !existsSync(join(ctx.publishDir, "server/app", `${key}.html`))):
192
- return;
193
- case meta.dataRoute?.endsWith(".json"):
194
- if (manifest.notFoundRoutes.includes(route)) {
195
- return;
196
- }
197
- value = await buildPagesCacheValue(join(ctx.publishDir, "server/pages", key));
198
- break;
199
- case meta.dataRoute?.endsWith(".rsc"):
200
- value = await buildAppCacheValue(join(ctx.publishDir, "server/app", key));
201
- break;
202
- case meta.dataRoute === null:
203
- value = await buildRouteCacheValue(
204
- join(ctx.publishDir, "server/app", key),
205
- meta.initialRevalidateSeconds
206
- );
207
- break;
208
- default:
209
- throw new Error(`Unrecognized content: ${route}`);
210
- }
211
- await writeCacheEntry(key, value, lastModified, ctx);
212
- })
213
- )
214
- );
215
- if (existsSync(join(ctx.publishDir, `server/app/_not-found.html`))) {
216
- const lastModified = Date.now();
217
- const key = "/404";
218
- const value = await buildAppCacheValue(join(ctx.publishDir, "server/app/_not-found"));
219
- await writeCacheEntry(key, value, lastModified, ctx);
220
- }
221
- } catch (error) {
222
- ctx.failBuild("Failed assembling prerendered content for upload", error);
223
- }
224
- });
225
- };
226
- var copyFetchContent = async (ctx) => {
227
- try {
228
- const paths = await (0, import_fast_glob.glob)(["!(*.*)"], {
229
- cwd: join(ctx.publishDir, "cache/fetch-cache"),
230
- extglob: true
231
- });
232
- await Promise.all(
233
- paths.map(async (key) => {
234
- const lastModified = Date.now() - 31536e6;
235
- const path = join(ctx.publishDir, "cache/fetch-cache", key);
236
- const value = await buildFetchCacheValue(path);
237
- await writeCacheEntry(key, value, lastModified, ctx);
238
- })
239
- );
240
- } catch (error) {
241
- ctx.failBuild("Failed assembling fetch content for upload", error);
242
- }
243
- };
244
-
245
- export {
246
- copyPrerenderedContent,
247
- copyFetchContent
248
- };
@@ -1,27 +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/run/revalidate.ts
9
- var nextResponseProxy = (res, requestContext) => {
10
- return new Proxy(res, {
11
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
12
- get(target, key) {
13
- const originalValue = target[key];
14
- if (key === "revalidate") {
15
- return async function newRevalidate(...args) {
16
- requestContext.didPagesRouterOnDemandRevalidate = true;
17
- return originalValue?.apply(target, args);
18
- };
19
- }
20
- return originalValue;
21
- }
22
- });
23
- };
24
-
25
- export {
26
- nextResponseProxy
27
- };
@@ -1,25 +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/shared/blobkey.ts
9
- import { Buffer } from "node:buffer";
10
- import { webcrypto as crypto } from "node:crypto";
11
- var maxLength = 180;
12
- async function encodeBlobKey(key) {
13
- const buffer = Buffer.from(key);
14
- const base64 = buffer.toString("base64url");
15
- if (base64.length <= maxLength) {
16
- return base64;
17
- }
18
- const digest = await crypto.subtle.digest("SHA-256", buffer);
19
- const hash = Buffer.from(digest).toString("base64url");
20
- return `${base64.slice(0, maxLength - hash.length - 1)}-${hash}`;
21
- }
22
-
23
- export {
24
- encodeBlobKey
25
- };