@netlify/plugin-nextjs 5.10.0-fetch-patch-logs → 5.10.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 +136 -4
  2. package/dist/build/cache.js +25 -4
  3. package/dist/build/content/prerendered.js +293 -11
  4. package/dist/build/content/server.js +219 -11
  5. package/dist/build/content/static.js +112 -15
  6. package/dist/build/functions/edge.js +540 -7
  7. package/dist/build/functions/server.js +130 -11
  8. package/dist/build/image-cdn.js +1599 -3
  9. package/dist/build/plugin-context.js +292 -6
  10. package/dist/build/verification.js +104 -9
  11. package/dist/esm-chunks/{package-F536DQ6H.js → package-UN6EVEHD.js} +1 -1
  12. package/dist/index.js +18 -39
  13. package/dist/run/config.js +1 -4
  14. package/dist/run/constants.js +7 -5
  15. package/dist/run/handlers/cache.cjs +44 -1655
  16. package/dist/run/handlers/server.js +14 -33
  17. package/dist/run/handlers/tracer.cjs +2 -114
  18. package/dist/run/handlers/tracing.js +2 -4
  19. package/dist/run/handlers/wait-until.cjs +2 -116
  20. package/dist/run/headers.js +198 -10
  21. package/dist/run/next.cjs +11 -1624
  22. package/dist/run/regional-blob-store.cjs +37 -5
  23. package/dist/run/revalidate.js +24 -3
  24. package/dist/shared/blobkey.js +15 -3
  25. package/package.json +1 -1
  26. package/dist/esm-chunks/chunk-3RQSTU2O.js +0 -554
  27. package/dist/esm-chunks/chunk-72ZI2IVI.js +0 -36
  28. package/dist/esm-chunks/chunk-AMY4NOT5.js +0 -1610
  29. package/dist/esm-chunks/chunk-DLVROEVU.js +0 -144
  30. package/dist/esm-chunks/chunk-GFYWJNQR.js +0 -305
  31. package/dist/esm-chunks/chunk-HXVWGXWM.js +0 -218
  32. package/dist/esm-chunks/chunk-IJZEDP6B.js +0 -235
  33. package/dist/esm-chunks/chunk-JPTD4GEB.js +0 -309
  34. package/dist/esm-chunks/chunk-MKMK7FBF.js +0 -132
  35. package/dist/esm-chunks/chunk-RYJYZQ4X.js +0 -610
  36. package/dist/esm-chunks/chunk-SGXRYMYQ.js +0 -127
  37. package/dist/esm-chunks/chunk-TYCYFZ22.js +0 -25
  38. package/dist/esm-chunks/chunk-UYKENJEU.js +0 -19
  39. package/dist/esm-chunks/chunk-WHUPSPWV.js +0 -73
  40. package/dist/esm-chunks/chunk-XS27YRA5.js +0 -34
  41. package/dist/esm-chunks/chunk-ZENB67PD.js +0 -148
  42. package/dist/esm-chunks/chunk-ZSVHJNNY.js +0 -120
  43. package/dist/esm-chunks/next-LDOXJ7XH.js +0 -567
@@ -1,567 +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
- getTracer
9
- } from "./chunk-WHUPSPWV.js";
10
- import {
11
- getRegionalBlobStore
12
- } from "./chunk-RYJYZQ4X.js";
13
- import {
14
- getRequestContext
15
- } from "./chunk-SGXRYMYQ.js";
16
- import "./chunk-5QSXBV7L.js";
17
- import "./chunk-GNGHTHMQ.js";
18
- import {
19
- __commonJS,
20
- __require,
21
- __toESM
22
- } from "./chunk-OEQOKJGE.js";
23
-
24
- // node_modules/fs-monkey/lib/util/lists.js
25
- var require_lists = __commonJS({
26
- "node_modules/fs-monkey/lib/util/lists.js"(exports) {
27
- "use strict";
28
- Object.defineProperty(exports, "__esModule", {
29
- value: true
30
- });
31
- exports.fsSyncMethods = exports.fsProps = exports.fsAsyncMethods = void 0;
32
- var fsProps = exports.fsProps = ["constants", "F_OK", "R_OK", "W_OK", "X_OK", "Stats"];
33
- var fsSyncMethods = exports.fsSyncMethods = ["renameSync", "ftruncateSync", "truncateSync", "chownSync", "fchownSync", "lchownSync", "chmodSync", "fchmodSync", "lchmodSync", "statSync", "lstatSync", "fstatSync", "linkSync", "symlinkSync", "readlinkSync", "realpathSync", "unlinkSync", "rmdirSync", "mkdirSync", "mkdirpSync", "readdirSync", "closeSync", "openSync", "utimesSync", "futimesSync", "fsyncSync", "writeSync", "readSync", "readFileSync", "writeFileSync", "appendFileSync", "existsSync", "accessSync", "fdatasyncSync", "mkdtempSync", "copyFileSync", "rmSync", "createReadStream", "createWriteStream"];
34
- var fsAsyncMethods = exports.fsAsyncMethods = ["rename", "ftruncate", "truncate", "chown", "fchown", "lchown", "chmod", "fchmod", "lchmod", "stat", "lstat", "fstat", "link", "symlink", "readlink", "realpath", "unlink", "rmdir", "mkdir", "mkdirp", "readdir", "close", "open", "utimes", "futimes", "fsync", "write", "read", "readFile", "writeFile", "appendFile", "exists", "access", "fdatasync", "mkdtemp", "copyFile", "rm", "watchFile", "unwatchFile", "watch"];
35
- }
36
- });
37
-
38
- // node_modules/fs-monkey/lib/patchFs.js
39
- var require_patchFs = __commonJS({
40
- "node_modules/fs-monkey/lib/patchFs.js"(exports) {
41
- "use strict";
42
- Object.defineProperty(exports, "__esModule", {
43
- value: true
44
- });
45
- exports["default"] = patchFs2;
46
- var _lists = require_lists();
47
- function _createForOfIteratorHelper(o, allowArrayLike) {
48
- var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
49
- if (!it) {
50
- if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
51
- if (it) o = it;
52
- var i = 0;
53
- var F = function F2() {
54
- };
55
- return { s: F, n: function n() {
56
- if (i >= o.length) return { done: true };
57
- return { done: false, value: o[i++] };
58
- }, e: function e(_e) {
59
- throw _e;
60
- }, f: F };
61
- }
62
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
63
- }
64
- var normalCompletion = true, didErr = false, err;
65
- return { s: function s() {
66
- it = it.call(o);
67
- }, n: function n() {
68
- var step = it.next();
69
- normalCompletion = step.done;
70
- return step;
71
- }, e: function e(_e2) {
72
- didErr = true;
73
- err = _e2;
74
- }, f: function f() {
75
- try {
76
- if (!normalCompletion && it["return"] != null) it["return"]();
77
- } finally {
78
- if (didErr) throw err;
79
- }
80
- } };
81
- }
82
- function _unsupportedIterableToArray(o, minLen) {
83
- if (!o) return;
84
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
85
- var n = Object.prototype.toString.call(o).slice(8, -1);
86
- if (n === "Object" && o.constructor) n = o.constructor.name;
87
- if (n === "Map" || n === "Set") return Array.from(o);
88
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
89
- }
90
- function _arrayLikeToArray(arr, len) {
91
- if (len == null || len > arr.length) len = arr.length;
92
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
93
- return arr2;
94
- }
95
- function patchFs2(vol) {
96
- var fs2 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : __require("fs");
97
- var bkp = {};
98
- var patch = function patch2(key, newValue) {
99
- bkp[key] = fs2[key];
100
- fs2[key] = newValue;
101
- };
102
- var patchMethod = function patchMethod2(key) {
103
- return patch(key, vol[key].bind(vol));
104
- };
105
- var _iterator = _createForOfIteratorHelper(_lists.fsProps), _step;
106
- try {
107
- for (_iterator.s(); !(_step = _iterator.n()).done; ) {
108
- var prop = _step.value;
109
- if (typeof vol[prop] !== "undefined") patch(prop, vol[prop]);
110
- }
111
- } catch (err) {
112
- _iterator.e(err);
113
- } finally {
114
- _iterator.f();
115
- }
116
- if (typeof vol.StatWatcher === "function") {
117
- patch("StatWatcher", vol.FSWatcher.bind(null, vol));
118
- }
119
- if (typeof vol.FSWatcher === "function") {
120
- patch("FSWatcher", vol.StatWatcher.bind(null, vol));
121
- }
122
- if (typeof vol.ReadStream === "function") {
123
- patch("ReadStream", vol.ReadStream.bind(null, vol));
124
- }
125
- if (typeof vol.WriteStream === "function") {
126
- patch("WriteStream", vol.WriteStream.bind(null, vol));
127
- }
128
- if (typeof vol._toUnixTimestamp === "function") patchMethod("_toUnixTimestamp");
129
- var _iterator2 = _createForOfIteratorHelper(_lists.fsAsyncMethods), _step2;
130
- try {
131
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done; ) {
132
- var method = _step2.value;
133
- if (typeof vol[method] === "function") patchMethod(method);
134
- }
135
- } catch (err) {
136
- _iterator2.e(err);
137
- } finally {
138
- _iterator2.f();
139
- }
140
- var _iterator3 = _createForOfIteratorHelper(_lists.fsSyncMethods), _step3;
141
- try {
142
- for (_iterator3.s(); !(_step3 = _iterator3.n()).done; ) {
143
- var _method = _step3.value;
144
- if (typeof vol[_method] === "function") patchMethod(_method);
145
- }
146
- } catch (err) {
147
- _iterator3.e(err);
148
- } finally {
149
- _iterator3.f();
150
- }
151
- return function unpatch() {
152
- for (var key in bkp) fs2[key] = bkp[key];
153
- };
154
- }
155
- }
156
- });
157
-
158
- // node_modules/fs-monkey/lib/correctPath.js
159
- var require_correctPath = __commonJS({
160
- "node_modules/fs-monkey/lib/correctPath.js"(exports) {
161
- "use strict";
162
- Object.defineProperty(exports, "__esModule", {
163
- value: true
164
- });
165
- exports.correctPath = correctPath;
166
- exports.unixify = unixify;
167
- var isWin = process.platform === "win32";
168
- function removeTrailingSeparator(str) {
169
- var i = str.length - 1;
170
- if (i < 2) {
171
- return str;
172
- }
173
- while (isSeparator(str, i)) {
174
- i--;
175
- }
176
- return str.substr(0, i + 1);
177
- }
178
- function isSeparator(str, i) {
179
- var _char = str[i];
180
- return i > 0 && (_char === "/" || isWin && _char === "\\");
181
- }
182
- function normalizePath(str, stripTrailing) {
183
- if (typeof str !== "string") {
184
- throw new TypeError("expected a string");
185
- }
186
- str = str.replace(/[\\\/]+/g, "/");
187
- if (stripTrailing !== false) {
188
- str = removeTrailingSeparator(str);
189
- }
190
- return str;
191
- }
192
- function unixify(filepath) {
193
- var stripTrailing = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : true;
194
- if (isWin) {
195
- filepath = normalizePath(filepath, stripTrailing);
196
- return filepath.replace(/^([a-zA-Z]+:|\.\/)/, "");
197
- }
198
- return filepath;
199
- }
200
- function correctPath(filepath) {
201
- return unixify(filepath.replace(/^\\\\\?\\.:\\/, "\\"));
202
- }
203
- }
204
- });
205
-
206
- // node_modules/fs-monkey/lib/patchRequire.js
207
- var require_patchRequire = __commonJS({
208
- "node_modules/fs-monkey/lib/patchRequire.js"(exports) {
209
- "use strict";
210
- function _typeof(o) {
211
- "@babel/helpers - typeof";
212
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o2) {
213
- return typeof o2;
214
- } : function(o2) {
215
- return o2 && "function" == typeof Symbol && o2.constructor === Symbol && o2 !== Symbol.prototype ? "symbol" : typeof o2;
216
- }, _typeof(o);
217
- }
218
- Object.defineProperty(exports, "__esModule", {
219
- value: true
220
- });
221
- exports["default"] = patchRequire;
222
- var path = _interopRequireWildcard(__require("path"));
223
- function _getRequireWildcardCache(e) {
224
- if ("function" != typeof WeakMap) return null;
225
- var r = /* @__PURE__ */ new WeakMap(), t = /* @__PURE__ */ new WeakMap();
226
- return (_getRequireWildcardCache = function _getRequireWildcardCache2(e2) {
227
- return e2 ? t : r;
228
- })(e);
229
- }
230
- function _interopRequireWildcard(e, r) {
231
- if (!r && e && e.__esModule) return e;
232
- if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e };
233
- var t = _getRequireWildcardCache(r);
234
- if (t && t.has(e)) return t.get(e);
235
- var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor;
236
- for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) {
237
- var i = a ? Object.getOwnPropertyDescriptor(e, u) : null;
238
- i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u];
239
- }
240
- return n["default"] = e, t && t.set(e, n), n;
241
- }
242
- var isWin32 = process.platform === "win32";
243
- var correctPath = isWin32 ? require_correctPath().correctPath : function(p) {
244
- return p;
245
- };
246
- function stripBOM(content) {
247
- if (content.charCodeAt(0) === 65279) {
248
- content = content.slice(1);
249
- }
250
- return content;
251
- }
252
- function patchRequire(vol) {
253
- var unixifyPaths = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
254
- var Module = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : __require("module");
255
- if (isWin32 && unixifyPaths) {
256
- var original = vol;
257
- vol = {
258
- readFileSync: function readFileSync(path2, options) {
259
- return original.readFileSync(correctPath(path2), options);
260
- },
261
- realpathSync: function realpathSync(path2) {
262
- return original.realpathSync(correctPath(path2));
263
- },
264
- statSync: function statSync(path2) {
265
- return original.statSync(correctPath(path2));
266
- }
267
- };
268
- }
269
- function internalModuleReadFile(path2) {
270
- try {
271
- return vol.readFileSync(path2, "utf8");
272
- } catch (err) {
273
- }
274
- }
275
- function internalModuleStat(filename) {
276
- try {
277
- return vol.statSync(filename).isDirectory() ? 1 : 0;
278
- } catch (err) {
279
- return -2;
280
- }
281
- }
282
- function stat(filename) {
283
- filename = path._makeLong(filename);
284
- var cache = stat.cache;
285
- if (cache !== null) {
286
- var _result = cache.get(filename);
287
- if (_result !== void 0) return _result;
288
- }
289
- var result = internalModuleStat(filename);
290
- if (cache !== null) cache.set(filename, result);
291
- return result;
292
- }
293
- stat.cache = null;
294
- var preserveSymlinks = false;
295
- function toRealPath(requestPath) {
296
- return vol.realpathSync(requestPath);
297
- }
298
- var packageMainCache = /* @__PURE__ */ Object.create(null);
299
- function readPackage(requestPath) {
300
- var entry = packageMainCache[requestPath];
301
- if (entry) return entry;
302
- var jsonPath = path.resolve(requestPath, "package.json");
303
- var json = internalModuleReadFile(path._makeLong(jsonPath));
304
- if (json === void 0) {
305
- return false;
306
- }
307
- var pkg;
308
- try {
309
- var pkgJson = JSON.parse(json);
310
- pkg = packageMainCache[requestPath] = pkgJson.exports && pkgJson.exports.require || pkgJson.main;
311
- } catch (e) {
312
- e.path = jsonPath;
313
- e.message = "Error parsing " + jsonPath + ": " + e.message;
314
- throw e;
315
- }
316
- return pkg;
317
- }
318
- function tryFile(requestPath, isMain) {
319
- var rc = stat(requestPath);
320
- if (preserveSymlinks && !isMain) {
321
- return rc === 0 && path.resolve(requestPath);
322
- }
323
- return rc === 0 && toRealPath(requestPath);
324
- }
325
- function tryExtensions(p, exts, isMain) {
326
- for (var i = 0; i < exts.length; i++) {
327
- var filename = tryFile(p + exts[i], isMain);
328
- if (filename) {
329
- return filename;
330
- }
331
- }
332
- return false;
333
- }
334
- function tryPackage(requestPath, exts, isMain) {
335
- var pkg = readPackage(requestPath);
336
- if (!pkg) return false;
337
- var filename = path.resolve(requestPath, pkg);
338
- return tryFile(filename, isMain) || tryExtensions(filename, exts, isMain) || tryExtensions(path.resolve(filename, "index"), exts, isMain);
339
- }
340
- Module._extensions[".js"] = function(module2, filename) {
341
- var content = vol.readFileSync(filename, "utf8");
342
- module2._compile(stripBOM(content), filename);
343
- };
344
- Module._extensions[".json"] = function(module2, filename) {
345
- var content = vol.readFileSync(filename, "utf8");
346
- try {
347
- module2.exports = JSON.parse(stripBOM(content));
348
- } catch (err) {
349
- err.message = filename + ": " + err.message;
350
- throw err;
351
- }
352
- };
353
- var warned = true;
354
- Module._findPath = function(request, paths, isMain) {
355
- if (path.isAbsolute(request)) {
356
- paths = [""];
357
- } else if (!paths || paths.length === 0) {
358
- return false;
359
- }
360
- var cacheKey = request + "\0" + (paths.length === 1 ? paths[0] : paths.join("\0"));
361
- var entry = Module._pathCache[cacheKey];
362
- if (entry) return entry;
363
- var exts;
364
- var trailingSlash = request.length > 0 && request.charCodeAt(request.length - 1) === 47;
365
- for (var i = 0; i < paths.length; i++) {
366
- var curPath = paths[i];
367
- if (curPath && stat(curPath) < 1) continue;
368
- var basePath = correctPath(path.resolve(curPath, request));
369
- var filename;
370
- var rc = stat(basePath);
371
- if (!trailingSlash) {
372
- if (rc === 0) {
373
- if (preserveSymlinks && !isMain) {
374
- filename = path.resolve(basePath);
375
- } else {
376
- filename = toRealPath(basePath);
377
- }
378
- } else if (rc === 1) {
379
- if (exts === void 0) exts = Object.keys(Module._extensions);
380
- filename = tryPackage(basePath, exts, isMain);
381
- }
382
- if (!filename) {
383
- if (exts === void 0) exts = Object.keys(Module._extensions);
384
- filename = tryExtensions(basePath, exts, isMain);
385
- }
386
- }
387
- if (!filename && rc === 1) {
388
- if (exts === void 0) exts = Object.keys(Module._extensions);
389
- filename = tryPackage(basePath, exts, isMain);
390
- }
391
- if (!filename && rc === 1) {
392
- if (exts === void 0) exts = Object.keys(Module._extensions);
393
- filename = tryExtensions(path.resolve(basePath, "index"), exts, isMain);
394
- }
395
- if (filename) {
396
- if (request === "." && i > 0) {
397
- if (!warned) {
398
- warned = true;
399
- process.emitWarning("warning: require('.') resolved outside the package directory. This functionality is deprecated and will be removed soon.", "DeprecationWarning", "DEP0019");
400
- }
401
- }
402
- Module._pathCache[cacheKey] = filename;
403
- return filename;
404
- }
405
- }
406
- return false;
407
- };
408
- }
409
- }
410
- });
411
-
412
- // node_modules/fs-monkey/lib/index.js
413
- var require_lib = __commonJS({
414
- "node_modules/fs-monkey/lib/index.js"(exports) {
415
- "use strict";
416
- function _typeof(o) {
417
- "@babel/helpers - typeof";
418
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o2) {
419
- return typeof o2;
420
- } : function(o2) {
421
- return o2 && "function" == typeof Symbol && o2.constructor === Symbol && o2 !== Symbol.prototype ? "symbol" : typeof o2;
422
- }, _typeof(o);
423
- }
424
- Object.defineProperty(exports, "__esModule", {
425
- value: true
426
- });
427
- Object.defineProperty(exports, "patchFs", {
428
- enumerable: true,
429
- get: function get2() {
430
- return _patchFs["default"];
431
- }
432
- });
433
- Object.defineProperty(exports, "patchRequire", {
434
- enumerable: true,
435
- get: function get2() {
436
- return _patchRequire["default"];
437
- }
438
- });
439
- Object.defineProperty(exports, "unixify", {
440
- enumerable: true,
441
- get: function get2() {
442
- return _correctPath.unixify;
443
- }
444
- });
445
- exports.util = void 0;
446
- var _patchFs = _interopRequireDefault(require_patchFs());
447
- var _patchRequire = _interopRequireDefault(require_patchRequire());
448
- var _correctPath = require_correctPath();
449
- var util = _interopRequireWildcard(require_lists());
450
- exports.util = util;
451
- function _getRequireWildcardCache(e) {
452
- if ("function" != typeof WeakMap) return null;
453
- var r = /* @__PURE__ */ new WeakMap(), t = /* @__PURE__ */ new WeakMap();
454
- return (_getRequireWildcardCache = function _getRequireWildcardCache2(e2) {
455
- return e2 ? t : r;
456
- })(e);
457
- }
458
- function _interopRequireWildcard(e, r) {
459
- if (!r && e && e.__esModule) return e;
460
- if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e };
461
- var t = _getRequireWildcardCache(r);
462
- if (t && t.has(e)) return t.get(e);
463
- var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor;
464
- for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) {
465
- var i = a ? Object.getOwnPropertyDescriptor(e, u) : null;
466
- i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u];
467
- }
468
- return n["default"] = e, t && t.set(e, n), n;
469
- }
470
- function _interopRequireDefault(obj) {
471
- return obj && obj.__esModule ? obj : { "default": obj };
472
- }
473
- }
474
- });
475
-
476
- // src/run/next.cts
477
- var import_fs_monkey = __toESM(require_lib());
478
- import fs from "fs/promises";
479
- import { relative, resolve } from "path";
480
- process.env.NODE_ENV = "production";
481
- var { getRequestHandlers } = __require("next/dist/server/lib/start-server.js");
482
- var ResponseCache = __require("next/dist/server/response-cache/index.js").default;
483
- var originalGet = ResponseCache.prototype.get;
484
- ResponseCache.prototype.get = function get(...getArgs) {
485
- if (!this.didAddBackgroundWorkTracking) {
486
- if (typeof this.batcher !== "undefined") {
487
- const originalBatcherBatch = this.batcher.batch;
488
- this.batcher.batch = async (key, fn) => {
489
- const trackedFn = async (...workFnArgs) => {
490
- const workPromise = fn(...workFnArgs);
491
- const requestContext = getRequestContext();
492
- if (requestContext && workPromise instanceof Promise) {
493
- requestContext.trackBackgroundWork(workPromise);
494
- }
495
- return await workPromise;
496
- };
497
- return originalBatcherBatch.call(this.batcher, key, trackedFn);
498
- };
499
- } else if (typeof this.pendingResponses !== "undefined") {
500
- const backgroundWork = /* @__PURE__ */ new Map();
501
- const originalPendingResponsesSet = this.pendingResponses.set;
502
- this.pendingResponses.set = async (key, value) => {
503
- const requestContext = getRequestContext();
504
- if (requestContext && !this.pendingResponses.has(key)) {
505
- const workPromise = new Promise((_resolve) => {
506
- backgroundWork.set(key, _resolve);
507
- });
508
- requestContext.trackBackgroundWork(workPromise);
509
- }
510
- return originalPendingResponsesSet.call(this.pendingResponses, key, value);
511
- };
512
- const originalPendingResponsesDelete = this.pendingResponses.delete;
513
- this.pendingResponses.delete = async (key) => {
514
- const _resolve = backgroundWork.get(key);
515
- if (_resolve) {
516
- _resolve();
517
- }
518
- return originalPendingResponsesDelete.call(this.pendingResponses, key);
519
- };
520
- }
521
- this.didAddBackgroundWorkTracking = true;
522
- }
523
- return originalGet.apply(this, getArgs);
524
- };
525
- async function getMockedRequestHandler(...args) {
526
- const tracer = getTracer();
527
- return tracer.withActiveSpan("mocked request handler", async () => {
528
- const ofs = { ...fs };
529
- const { encodeBlobKey } = await import("../shared/blobkey.js");
530
- async function readFileFallbackBlobStore(...fsargs) {
531
- const [path, options] = fsargs;
532
- try {
533
- return await ofs.readFile(path, options);
534
- } catch (error) {
535
- if (typeof path === "string" && path.endsWith(".html")) {
536
- const store = getRegionalBlobStore();
537
- const relPath = relative(resolve(".next/server/pages"), path);
538
- const file = await store.get(await encodeBlobKey(relPath), {
539
- type: "json"
540
- });
541
- if (file !== null) {
542
- if (!file.isFallback) {
543
- const requestContext = getRequestContext();
544
- if (requestContext) {
545
- requestContext.usedFsReadForNonFallback = true;
546
- }
547
- }
548
- return file.html;
549
- }
550
- }
551
- throw error;
552
- }
553
- }
554
- (0, import_fs_monkey.patchFs)(
555
- {
556
- readFile: readFileFallbackBlobStore
557
- },
558
- // eslint-disable-next-line n/global-require, @typescript-eslint/no-var-requires
559
- __require("fs").promises
560
- );
561
- const requestHandlers = await getRequestHandlers(...args);
562
- return Array.isArray(requestHandlers) ? requestHandlers[0] : requestHandlers.requestHandler;
563
- });
564
- }
565
- export {
566
- getMockedRequestHandler
567
- };