@netlify/plugin-nextjs 5.8.0 → 5.9.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 (47) hide show
  1. package/README.md +3 -2
  2. package/dist/build/advanced-api-routes.js +4 -136
  3. package/dist/build/cache.js +4 -25
  4. package/dist/build/content/prerendered.js +11 -272
  5. package/dist/build/content/server.js +11 -219
  6. package/dist/build/content/static.js +14 -97
  7. package/dist/build/functions/edge.js +7 -534
  8. package/dist/build/functions/server.js +11 -130
  9. package/dist/build/image-cdn.js +3 -1599
  10. package/dist/build/plugin-context.js +6 -266
  11. package/dist/build/templates/handler-monorepo.tmpl.js +1 -1
  12. package/dist/build/templates/handler.tmpl.js +1 -1
  13. package/dist/build/verification.js +9 -104
  14. package/dist/esm-chunks/chunk-72ZI2IVI.js +36 -0
  15. package/dist/esm-chunks/chunk-AMY4NOT5.js +1610 -0
  16. package/dist/esm-chunks/chunk-BEIUVQZK.js +212 -0
  17. package/dist/esm-chunks/chunk-BFYMHE3E.js +548 -0
  18. package/dist/esm-chunks/chunk-BVYZSEV6.js +306 -0
  19. package/dist/esm-chunks/chunk-DLVROEVU.js +144 -0
  20. package/dist/esm-chunks/chunk-GFYWJNQR.js +305 -0
  21. package/dist/esm-chunks/chunk-HWMLYAVP.js +122 -0
  22. package/dist/esm-chunks/chunk-IJZEDP6B.js +235 -0
  23. package/dist/esm-chunks/chunk-K4RDUZYO.js +609 -0
  24. package/dist/esm-chunks/chunk-KBX7SJLC.js +73 -0
  25. package/dist/esm-chunks/chunk-NDSDIXRD.js +122 -0
  26. package/dist/esm-chunks/chunk-TYCYFZ22.js +25 -0
  27. package/dist/esm-chunks/chunk-UYKENJEU.js +19 -0
  28. package/dist/esm-chunks/chunk-XS27YRA5.js +34 -0
  29. package/dist/esm-chunks/chunk-ZENB67PD.js +148 -0
  30. package/dist/esm-chunks/chunk-ZSVHJNNY.js +120 -0
  31. package/dist/esm-chunks/next-4L47PQSM.js +569 -0
  32. package/dist/esm-chunks/{package-4GFWM3PF.js → package-LCNINN36.js} +8 -7
  33. package/dist/index.js +39 -18
  34. package/dist/run/config.js +4 -1
  35. package/dist/run/constants.js +5 -7
  36. package/dist/run/handlers/cache.cjs +1618 -31
  37. package/dist/run/handlers/request-context.cjs +6 -2
  38. package/dist/run/handlers/server.js +40 -20
  39. package/dist/run/handlers/tracer.cjs +83 -2
  40. package/dist/run/handlers/tracing.js +4 -2
  41. package/dist/run/handlers/wait-until.cjs +122 -0
  42. package/dist/run/headers.js +9 -194
  43. package/dist/run/next.cjs +1604 -18
  44. package/dist/run/regional-blob-store.cjs +1 -1
  45. package/dist/run/revalidate.js +3 -24
  46. package/dist/shared/blobkey.js +3 -15
  47. package/package.json +4 -4
package/dist/run/next.cjs CHANGED
@@ -5,6 +5,9 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __esm = (fn, res) => function __init() {
9
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
10
+ };
8
11
  var __commonJS = (cb, mod) => function __require() {
9
12
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
13
  };
@@ -482,18 +485,1596 @@ var require_lib = __commonJS({
482
485
  }
483
486
  });
484
487
 
488
+ // src/shared/blobkey.ts
489
+ var blobkey_exports = {};
490
+ __export(blobkey_exports, {
491
+ encodeBlobKey: () => encodeBlobKey
492
+ });
493
+ async function encodeBlobKey(key) {
494
+ const buffer = import_node_buffer.Buffer.from(key);
495
+ const base64 = buffer.toString("base64url");
496
+ if (base64.length <= maxLength) {
497
+ return base64;
498
+ }
499
+ const digest = await import_node_crypto.webcrypto.subtle.digest("SHA-256", buffer);
500
+ const hash = import_node_buffer.Buffer.from(digest).toString("base64url");
501
+ return `${base64.slice(0, maxLength - hash.length - 1)}-${hash}`;
502
+ }
503
+ var import_node_buffer, import_node_crypto, maxLength;
504
+ var init_blobkey = __esm({
505
+ "src/shared/blobkey.ts"() {
506
+ "use strict";
507
+ import_node_buffer = require("node:buffer");
508
+ import_node_crypto = require("node:crypto");
509
+ maxLength = 180;
510
+ }
511
+ });
512
+
485
513
  // src/run/next.cts
486
514
  var next_exports = {};
487
515
  __export(next_exports, {
488
- getMockedRequestHandlers: () => getMockedRequestHandlers
516
+ getMockedRequestHandler: () => getMockedRequestHandler
489
517
  });
490
518
  module.exports = __toCommonJS(next_exports);
491
519
  var import_promises = __toESM(require("fs/promises"));
492
520
  var import_path = require("path");
493
521
  var import_fs_monkey = __toESM(require_lib());
494
- var import_request_context = require("./handlers/request-context.cjs");
495
- var import_tracer = require("./handlers/tracer.cjs");
496
- var import_regional_blob_store = require("./regional-blob-store.cjs");
522
+
523
+ // src/run/handlers/request-context.cts
524
+ var import_node_async_hooks = require("node:async_hooks");
525
+
526
+ // node_modules/@netlify/functions/dist/chunk-HYMERDCV.mjs
527
+ var import_process = require("process");
528
+ var systemLogTag = "__nfSystemLog";
529
+ var serializeError = (error) => {
530
+ const cause = error?.cause instanceof Error ? serializeError(error.cause) : error.cause;
531
+ return {
532
+ error: error.message,
533
+ error_cause: cause,
534
+ error_stack: error.stack
535
+ };
536
+ };
537
+ var SystemLogger = class _SystemLogger {
538
+ fields;
539
+ logLevel;
540
+ constructor(fields = {}, logLevel = 2) {
541
+ this.fields = fields;
542
+ this.logLevel = logLevel;
543
+ }
544
+ doLog(logger, message) {
545
+ if (import_process.env.NETLIFY_DEV && !import_process.env.NETLIFY_ENABLE_SYSTEM_LOGGING) {
546
+ return;
547
+ }
548
+ logger(systemLogTag, JSON.stringify({ msg: message, fields: this.fields }));
549
+ }
550
+ log(message) {
551
+ if (this.logLevel > 2) {
552
+ return;
553
+ }
554
+ this.doLog(console.log, message);
555
+ }
556
+ debug(message) {
557
+ if (this.logLevel > 1) {
558
+ return;
559
+ }
560
+ this.doLog(console.debug, message);
561
+ }
562
+ error(message) {
563
+ if (this.logLevel > 3) {
564
+ return;
565
+ }
566
+ this.doLog(console.error, message);
567
+ }
568
+ withLogLevel(level) {
569
+ return new _SystemLogger(this.fields, level);
570
+ }
571
+ withFields(fields) {
572
+ return new _SystemLogger(
573
+ {
574
+ ...this.fields,
575
+ ...fields
576
+ },
577
+ this.logLevel
578
+ );
579
+ }
580
+ withError(error) {
581
+ const fields = error instanceof Error ? serializeError(error) : { error };
582
+ return this.withFields(fields);
583
+ }
584
+ };
585
+ var systemLogger = new SystemLogger();
586
+
587
+ // src/run/handlers/request-context.cts
588
+ var REQUEST_CONTEXT_GLOBAL_KEY = Symbol.for("nf-request-context-async-local-storage");
589
+ var requestContextAsyncLocalStorage;
590
+ function getRequestContextAsyncLocalStorage() {
591
+ if (requestContextAsyncLocalStorage) {
592
+ return requestContextAsyncLocalStorage;
593
+ }
594
+ const extendedGlobalThis = globalThis;
595
+ if (extendedGlobalThis[REQUEST_CONTEXT_GLOBAL_KEY]) {
596
+ return extendedGlobalThis[REQUEST_CONTEXT_GLOBAL_KEY];
597
+ }
598
+ const storage = new import_node_async_hooks.AsyncLocalStorage();
599
+ requestContextAsyncLocalStorage = storage;
600
+ extendedGlobalThis[REQUEST_CONTEXT_GLOBAL_KEY] = storage;
601
+ return storage;
602
+ }
603
+ var getRequestContext = () => getRequestContextAsyncLocalStorage().getStore();
604
+
605
+ // node_modules/@opentelemetry/api/build/esm/platform/node/globalThis.js
606
+ var _globalThis = typeof globalThis === "object" ? globalThis : global;
607
+
608
+ // node_modules/@opentelemetry/api/build/esm/version.js
609
+ var VERSION = "1.8.0";
610
+
611
+ // node_modules/@opentelemetry/api/build/esm/internal/semver.js
612
+ var re = /^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;
613
+ function _makeCompatibilityCheck(ownVersion) {
614
+ var acceptedVersions = /* @__PURE__ */ new Set([ownVersion]);
615
+ var rejectedVersions = /* @__PURE__ */ new Set();
616
+ var myVersionMatch = ownVersion.match(re);
617
+ if (!myVersionMatch) {
618
+ return function() {
619
+ return false;
620
+ };
621
+ }
622
+ var ownVersionParsed = {
623
+ major: +myVersionMatch[1],
624
+ minor: +myVersionMatch[2],
625
+ patch: +myVersionMatch[3],
626
+ prerelease: myVersionMatch[4]
627
+ };
628
+ if (ownVersionParsed.prerelease != null) {
629
+ return function isExactmatch(globalVersion) {
630
+ return globalVersion === ownVersion;
631
+ };
632
+ }
633
+ function _reject(v) {
634
+ rejectedVersions.add(v);
635
+ return false;
636
+ }
637
+ function _accept(v) {
638
+ acceptedVersions.add(v);
639
+ return true;
640
+ }
641
+ return function isCompatible2(globalVersion) {
642
+ if (acceptedVersions.has(globalVersion)) {
643
+ return true;
644
+ }
645
+ if (rejectedVersions.has(globalVersion)) {
646
+ return false;
647
+ }
648
+ var globalVersionMatch = globalVersion.match(re);
649
+ if (!globalVersionMatch) {
650
+ return _reject(globalVersion);
651
+ }
652
+ var globalVersionParsed = {
653
+ major: +globalVersionMatch[1],
654
+ minor: +globalVersionMatch[2],
655
+ patch: +globalVersionMatch[3],
656
+ prerelease: globalVersionMatch[4]
657
+ };
658
+ if (globalVersionParsed.prerelease != null) {
659
+ return _reject(globalVersion);
660
+ }
661
+ if (ownVersionParsed.major !== globalVersionParsed.major) {
662
+ return _reject(globalVersion);
663
+ }
664
+ if (ownVersionParsed.major === 0) {
665
+ if (ownVersionParsed.minor === globalVersionParsed.minor && ownVersionParsed.patch <= globalVersionParsed.patch) {
666
+ return _accept(globalVersion);
667
+ }
668
+ return _reject(globalVersion);
669
+ }
670
+ if (ownVersionParsed.minor <= globalVersionParsed.minor) {
671
+ return _accept(globalVersion);
672
+ }
673
+ return _reject(globalVersion);
674
+ };
675
+ }
676
+ var isCompatible = _makeCompatibilityCheck(VERSION);
677
+
678
+ // node_modules/@opentelemetry/api/build/esm/internal/global-utils.js
679
+ var major = VERSION.split(".")[0];
680
+ var GLOBAL_OPENTELEMETRY_API_KEY = Symbol.for("opentelemetry.js.api." + major);
681
+ var _global = _globalThis;
682
+ function registerGlobal(type, instance, diag, allowOverride) {
683
+ var _a;
684
+ if (allowOverride === void 0) {
685
+ allowOverride = false;
686
+ }
687
+ var api = _global[GLOBAL_OPENTELEMETRY_API_KEY] = (_a = _global[GLOBAL_OPENTELEMETRY_API_KEY]) !== null && _a !== void 0 ? _a : {
688
+ version: VERSION
689
+ };
690
+ if (!allowOverride && api[type]) {
691
+ var err = new Error("@opentelemetry/api: Attempted duplicate registration of API: " + type);
692
+ diag.error(err.stack || err.message);
693
+ return false;
694
+ }
695
+ if (api.version !== VERSION) {
696
+ var err = new Error("@opentelemetry/api: Registration of version v" + api.version + " for " + type + " does not match previously registered API v" + VERSION);
697
+ diag.error(err.stack || err.message);
698
+ return false;
699
+ }
700
+ api[type] = instance;
701
+ diag.debug("@opentelemetry/api: Registered a global for " + type + " v" + VERSION + ".");
702
+ return true;
703
+ }
704
+ function getGlobal(type) {
705
+ var _a, _b;
706
+ var globalVersion = (_a = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _a === void 0 ? void 0 : _a.version;
707
+ if (!globalVersion || !isCompatible(globalVersion)) {
708
+ return;
709
+ }
710
+ return (_b = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _b === void 0 ? void 0 : _b[type];
711
+ }
712
+ function unregisterGlobal(type, diag) {
713
+ diag.debug("@opentelemetry/api: Unregistering a global for " + type + " v" + VERSION + ".");
714
+ var api = _global[GLOBAL_OPENTELEMETRY_API_KEY];
715
+ if (api) {
716
+ delete api[type];
717
+ }
718
+ }
719
+
720
+ // node_modules/@opentelemetry/api/build/esm/diag/ComponentLogger.js
721
+ var __read = function(o, n) {
722
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
723
+ if (!m) return o;
724
+ var i = m.call(o), r, ar = [], e;
725
+ try {
726
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
727
+ } catch (error) {
728
+ e = { error };
729
+ } finally {
730
+ try {
731
+ if (r && !r.done && (m = i["return"])) m.call(i);
732
+ } finally {
733
+ if (e) throw e.error;
734
+ }
735
+ }
736
+ return ar;
737
+ };
738
+ var __spreadArray = function(to, from, pack) {
739
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
740
+ if (ar || !(i in from)) {
741
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
742
+ ar[i] = from[i];
743
+ }
744
+ }
745
+ return to.concat(ar || Array.prototype.slice.call(from));
746
+ };
747
+ var DiagComponentLogger = (
748
+ /** @class */
749
+ function() {
750
+ function DiagComponentLogger2(props) {
751
+ this._namespace = props.namespace || "DiagComponentLogger";
752
+ }
753
+ DiagComponentLogger2.prototype.debug = function() {
754
+ var args = [];
755
+ for (var _i = 0; _i < arguments.length; _i++) {
756
+ args[_i] = arguments[_i];
757
+ }
758
+ return logProxy("debug", this._namespace, args);
759
+ };
760
+ DiagComponentLogger2.prototype.error = function() {
761
+ var args = [];
762
+ for (var _i = 0; _i < arguments.length; _i++) {
763
+ args[_i] = arguments[_i];
764
+ }
765
+ return logProxy("error", this._namespace, args);
766
+ };
767
+ DiagComponentLogger2.prototype.info = function() {
768
+ var args = [];
769
+ for (var _i = 0; _i < arguments.length; _i++) {
770
+ args[_i] = arguments[_i];
771
+ }
772
+ return logProxy("info", this._namespace, args);
773
+ };
774
+ DiagComponentLogger2.prototype.warn = function() {
775
+ var args = [];
776
+ for (var _i = 0; _i < arguments.length; _i++) {
777
+ args[_i] = arguments[_i];
778
+ }
779
+ return logProxy("warn", this._namespace, args);
780
+ };
781
+ DiagComponentLogger2.prototype.verbose = function() {
782
+ var args = [];
783
+ for (var _i = 0; _i < arguments.length; _i++) {
784
+ args[_i] = arguments[_i];
785
+ }
786
+ return logProxy("verbose", this._namespace, args);
787
+ };
788
+ return DiagComponentLogger2;
789
+ }()
790
+ );
791
+ function logProxy(funcName, namespace, args) {
792
+ var logger = getGlobal("diag");
793
+ if (!logger) {
794
+ return;
795
+ }
796
+ args.unshift(namespace);
797
+ return logger[funcName].apply(logger, __spreadArray([], __read(args), false));
798
+ }
799
+
800
+ // node_modules/@opentelemetry/api/build/esm/diag/types.js
801
+ var DiagLogLevel;
802
+ (function(DiagLogLevel2) {
803
+ DiagLogLevel2[DiagLogLevel2["NONE"] = 0] = "NONE";
804
+ DiagLogLevel2[DiagLogLevel2["ERROR"] = 30] = "ERROR";
805
+ DiagLogLevel2[DiagLogLevel2["WARN"] = 50] = "WARN";
806
+ DiagLogLevel2[DiagLogLevel2["INFO"] = 60] = "INFO";
807
+ DiagLogLevel2[DiagLogLevel2["DEBUG"] = 70] = "DEBUG";
808
+ DiagLogLevel2[DiagLogLevel2["VERBOSE"] = 80] = "VERBOSE";
809
+ DiagLogLevel2[DiagLogLevel2["ALL"] = 9999] = "ALL";
810
+ })(DiagLogLevel || (DiagLogLevel = {}));
811
+
812
+ // node_modules/@opentelemetry/api/build/esm/diag/internal/logLevelLogger.js
813
+ function createLogLevelDiagLogger(maxLevel, logger) {
814
+ if (maxLevel < DiagLogLevel.NONE) {
815
+ maxLevel = DiagLogLevel.NONE;
816
+ } else if (maxLevel > DiagLogLevel.ALL) {
817
+ maxLevel = DiagLogLevel.ALL;
818
+ }
819
+ logger = logger || {};
820
+ function _filterFunc(funcName, theLevel) {
821
+ var theFunc = logger[funcName];
822
+ if (typeof theFunc === "function" && maxLevel >= theLevel) {
823
+ return theFunc.bind(logger);
824
+ }
825
+ return function() {
826
+ };
827
+ }
828
+ return {
829
+ error: _filterFunc("error", DiagLogLevel.ERROR),
830
+ warn: _filterFunc("warn", DiagLogLevel.WARN),
831
+ info: _filterFunc("info", DiagLogLevel.INFO),
832
+ debug: _filterFunc("debug", DiagLogLevel.DEBUG),
833
+ verbose: _filterFunc("verbose", DiagLogLevel.VERBOSE)
834
+ };
835
+ }
836
+
837
+ // node_modules/@opentelemetry/api/build/esm/api/diag.js
838
+ var __read2 = function(o, n) {
839
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
840
+ if (!m) return o;
841
+ var i = m.call(o), r, ar = [], e;
842
+ try {
843
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
844
+ } catch (error) {
845
+ e = { error };
846
+ } finally {
847
+ try {
848
+ if (r && !r.done && (m = i["return"])) m.call(i);
849
+ } finally {
850
+ if (e) throw e.error;
851
+ }
852
+ }
853
+ return ar;
854
+ };
855
+ var __spreadArray2 = function(to, from, pack) {
856
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
857
+ if (ar || !(i in from)) {
858
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
859
+ ar[i] = from[i];
860
+ }
861
+ }
862
+ return to.concat(ar || Array.prototype.slice.call(from));
863
+ };
864
+ var API_NAME = "diag";
865
+ var DiagAPI = (
866
+ /** @class */
867
+ function() {
868
+ function DiagAPI2() {
869
+ function _logProxy(funcName) {
870
+ return function() {
871
+ var args = [];
872
+ for (var _i = 0; _i < arguments.length; _i++) {
873
+ args[_i] = arguments[_i];
874
+ }
875
+ var logger = getGlobal("diag");
876
+ if (!logger)
877
+ return;
878
+ return logger[funcName].apply(logger, __spreadArray2([], __read2(args), false));
879
+ };
880
+ }
881
+ var self = this;
882
+ var setLogger = function(logger, optionsOrLogLevel) {
883
+ var _a, _b, _c;
884
+ if (optionsOrLogLevel === void 0) {
885
+ optionsOrLogLevel = { logLevel: DiagLogLevel.INFO };
886
+ }
887
+ if (logger === self) {
888
+ var err = new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");
889
+ self.error((_a = err.stack) !== null && _a !== void 0 ? _a : err.message);
890
+ return false;
891
+ }
892
+ if (typeof optionsOrLogLevel === "number") {
893
+ optionsOrLogLevel = {
894
+ logLevel: optionsOrLogLevel
895
+ };
896
+ }
897
+ var oldLogger = getGlobal("diag");
898
+ var newLogger = createLogLevelDiagLogger((_b = optionsOrLogLevel.logLevel) !== null && _b !== void 0 ? _b : DiagLogLevel.INFO, logger);
899
+ if (oldLogger && !optionsOrLogLevel.suppressOverrideMessage) {
900
+ var stack = (_c = new Error().stack) !== null && _c !== void 0 ? _c : "<failed to generate stacktrace>";
901
+ oldLogger.warn("Current logger will be overwritten from " + stack);
902
+ newLogger.warn("Current logger will overwrite one already registered from " + stack);
903
+ }
904
+ return registerGlobal("diag", newLogger, self, true);
905
+ };
906
+ self.setLogger = setLogger;
907
+ self.disable = function() {
908
+ unregisterGlobal(API_NAME, self);
909
+ };
910
+ self.createComponentLogger = function(options) {
911
+ return new DiagComponentLogger(options);
912
+ };
913
+ self.verbose = _logProxy("verbose");
914
+ self.debug = _logProxy("debug");
915
+ self.info = _logProxy("info");
916
+ self.warn = _logProxy("warn");
917
+ self.error = _logProxy("error");
918
+ }
919
+ DiagAPI2.instance = function() {
920
+ if (!this._instance) {
921
+ this._instance = new DiagAPI2();
922
+ }
923
+ return this._instance;
924
+ };
925
+ return DiagAPI2;
926
+ }()
927
+ );
928
+
929
+ // node_modules/@opentelemetry/api/build/esm/context/context.js
930
+ function createContextKey(description) {
931
+ return Symbol.for(description);
932
+ }
933
+ var BaseContext = (
934
+ /** @class */
935
+ /* @__PURE__ */ function() {
936
+ function BaseContext2(parentContext) {
937
+ var self = this;
938
+ self._currentContext = parentContext ? new Map(parentContext) : /* @__PURE__ */ new Map();
939
+ self.getValue = function(key) {
940
+ return self._currentContext.get(key);
941
+ };
942
+ self.setValue = function(key, value) {
943
+ var context2 = new BaseContext2(self._currentContext);
944
+ context2._currentContext.set(key, value);
945
+ return context2;
946
+ };
947
+ self.deleteValue = function(key) {
948
+ var context2 = new BaseContext2(self._currentContext);
949
+ context2._currentContext.delete(key);
950
+ return context2;
951
+ };
952
+ }
953
+ return BaseContext2;
954
+ }()
955
+ );
956
+ var ROOT_CONTEXT = new BaseContext();
957
+
958
+ // node_modules/@opentelemetry/api/build/esm/context/NoopContextManager.js
959
+ var __read3 = function(o, n) {
960
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
961
+ if (!m) return o;
962
+ var i = m.call(o), r, ar = [], e;
963
+ try {
964
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
965
+ } catch (error) {
966
+ e = { error };
967
+ } finally {
968
+ try {
969
+ if (r && !r.done && (m = i["return"])) m.call(i);
970
+ } finally {
971
+ if (e) throw e.error;
972
+ }
973
+ }
974
+ return ar;
975
+ };
976
+ var __spreadArray3 = function(to, from, pack) {
977
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
978
+ if (ar || !(i in from)) {
979
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
980
+ ar[i] = from[i];
981
+ }
982
+ }
983
+ return to.concat(ar || Array.prototype.slice.call(from));
984
+ };
985
+ var NoopContextManager = (
986
+ /** @class */
987
+ function() {
988
+ function NoopContextManager2() {
989
+ }
990
+ NoopContextManager2.prototype.active = function() {
991
+ return ROOT_CONTEXT;
992
+ };
993
+ NoopContextManager2.prototype.with = function(_context, fn, thisArg) {
994
+ var args = [];
995
+ for (var _i = 3; _i < arguments.length; _i++) {
996
+ args[_i - 3] = arguments[_i];
997
+ }
998
+ return fn.call.apply(fn, __spreadArray3([thisArg], __read3(args), false));
999
+ };
1000
+ NoopContextManager2.prototype.bind = function(_context, target) {
1001
+ return target;
1002
+ };
1003
+ NoopContextManager2.prototype.enable = function() {
1004
+ return this;
1005
+ };
1006
+ NoopContextManager2.prototype.disable = function() {
1007
+ return this;
1008
+ };
1009
+ return NoopContextManager2;
1010
+ }()
1011
+ );
1012
+
1013
+ // node_modules/@opentelemetry/api/build/esm/api/context.js
1014
+ var __read4 = function(o, n) {
1015
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
1016
+ if (!m) return o;
1017
+ var i = m.call(o), r, ar = [], e;
1018
+ try {
1019
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
1020
+ } catch (error) {
1021
+ e = { error };
1022
+ } finally {
1023
+ try {
1024
+ if (r && !r.done && (m = i["return"])) m.call(i);
1025
+ } finally {
1026
+ if (e) throw e.error;
1027
+ }
1028
+ }
1029
+ return ar;
1030
+ };
1031
+ var __spreadArray4 = function(to, from, pack) {
1032
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
1033
+ if (ar || !(i in from)) {
1034
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
1035
+ ar[i] = from[i];
1036
+ }
1037
+ }
1038
+ return to.concat(ar || Array.prototype.slice.call(from));
1039
+ };
1040
+ var API_NAME2 = "context";
1041
+ var NOOP_CONTEXT_MANAGER = new NoopContextManager();
1042
+ var ContextAPI = (
1043
+ /** @class */
1044
+ function() {
1045
+ function ContextAPI2() {
1046
+ }
1047
+ ContextAPI2.getInstance = function() {
1048
+ if (!this._instance) {
1049
+ this._instance = new ContextAPI2();
1050
+ }
1051
+ return this._instance;
1052
+ };
1053
+ ContextAPI2.prototype.setGlobalContextManager = function(contextManager) {
1054
+ return registerGlobal(API_NAME2, contextManager, DiagAPI.instance());
1055
+ };
1056
+ ContextAPI2.prototype.active = function() {
1057
+ return this._getContextManager().active();
1058
+ };
1059
+ ContextAPI2.prototype.with = function(context2, fn, thisArg) {
1060
+ var _a;
1061
+ var args = [];
1062
+ for (var _i = 3; _i < arguments.length; _i++) {
1063
+ args[_i - 3] = arguments[_i];
1064
+ }
1065
+ return (_a = this._getContextManager()).with.apply(_a, __spreadArray4([context2, fn, thisArg], __read4(args), false));
1066
+ };
1067
+ ContextAPI2.prototype.bind = function(context2, target) {
1068
+ return this._getContextManager().bind(context2, target);
1069
+ };
1070
+ ContextAPI2.prototype._getContextManager = function() {
1071
+ return getGlobal(API_NAME2) || NOOP_CONTEXT_MANAGER;
1072
+ };
1073
+ ContextAPI2.prototype.disable = function() {
1074
+ this._getContextManager().disable();
1075
+ unregisterGlobal(API_NAME2, DiagAPI.instance());
1076
+ };
1077
+ return ContextAPI2;
1078
+ }()
1079
+ );
1080
+
1081
+ // node_modules/@opentelemetry/api/build/esm/trace/trace_flags.js
1082
+ var TraceFlags;
1083
+ (function(TraceFlags2) {
1084
+ TraceFlags2[TraceFlags2["NONE"] = 0] = "NONE";
1085
+ TraceFlags2[TraceFlags2["SAMPLED"] = 1] = "SAMPLED";
1086
+ })(TraceFlags || (TraceFlags = {}));
1087
+
1088
+ // node_modules/@opentelemetry/api/build/esm/trace/invalid-span-constants.js
1089
+ var INVALID_SPANID = "0000000000000000";
1090
+ var INVALID_TRACEID = "00000000000000000000000000000000";
1091
+ var INVALID_SPAN_CONTEXT = {
1092
+ traceId: INVALID_TRACEID,
1093
+ spanId: INVALID_SPANID,
1094
+ traceFlags: TraceFlags.NONE
1095
+ };
1096
+
1097
+ // node_modules/@opentelemetry/api/build/esm/trace/NonRecordingSpan.js
1098
+ var NonRecordingSpan = (
1099
+ /** @class */
1100
+ function() {
1101
+ function NonRecordingSpan2(_spanContext) {
1102
+ if (_spanContext === void 0) {
1103
+ _spanContext = INVALID_SPAN_CONTEXT;
1104
+ }
1105
+ this._spanContext = _spanContext;
1106
+ }
1107
+ NonRecordingSpan2.prototype.spanContext = function() {
1108
+ return this._spanContext;
1109
+ };
1110
+ NonRecordingSpan2.prototype.setAttribute = function(_key, _value) {
1111
+ return this;
1112
+ };
1113
+ NonRecordingSpan2.prototype.setAttributes = function(_attributes) {
1114
+ return this;
1115
+ };
1116
+ NonRecordingSpan2.prototype.addEvent = function(_name, _attributes) {
1117
+ return this;
1118
+ };
1119
+ NonRecordingSpan2.prototype.setStatus = function(_status) {
1120
+ return this;
1121
+ };
1122
+ NonRecordingSpan2.prototype.updateName = function(_name) {
1123
+ return this;
1124
+ };
1125
+ NonRecordingSpan2.prototype.end = function(_endTime) {
1126
+ };
1127
+ NonRecordingSpan2.prototype.isRecording = function() {
1128
+ return false;
1129
+ };
1130
+ NonRecordingSpan2.prototype.recordException = function(_exception, _time) {
1131
+ };
1132
+ return NonRecordingSpan2;
1133
+ }()
1134
+ );
1135
+
1136
+ // node_modules/@opentelemetry/api/build/esm/trace/context-utils.js
1137
+ var SPAN_KEY = createContextKey("OpenTelemetry Context Key SPAN");
1138
+ function getSpan(context2) {
1139
+ return context2.getValue(SPAN_KEY) || void 0;
1140
+ }
1141
+ function getActiveSpan() {
1142
+ return getSpan(ContextAPI.getInstance().active());
1143
+ }
1144
+ function setSpan(context2, span) {
1145
+ return context2.setValue(SPAN_KEY, span);
1146
+ }
1147
+ function deleteSpan(context2) {
1148
+ return context2.deleteValue(SPAN_KEY);
1149
+ }
1150
+ function setSpanContext(context2, spanContext) {
1151
+ return setSpan(context2, new NonRecordingSpan(spanContext));
1152
+ }
1153
+ function getSpanContext(context2) {
1154
+ var _a;
1155
+ return (_a = getSpan(context2)) === null || _a === void 0 ? void 0 : _a.spanContext();
1156
+ }
1157
+
1158
+ // node_modules/@opentelemetry/api/build/esm/trace/spancontext-utils.js
1159
+ var VALID_TRACEID_REGEX = /^([0-9a-f]{32})$/i;
1160
+ var VALID_SPANID_REGEX = /^[0-9a-f]{16}$/i;
1161
+ function isValidTraceId(traceId) {
1162
+ return VALID_TRACEID_REGEX.test(traceId) && traceId !== INVALID_TRACEID;
1163
+ }
1164
+ function isValidSpanId(spanId) {
1165
+ return VALID_SPANID_REGEX.test(spanId) && spanId !== INVALID_SPANID;
1166
+ }
1167
+ function isSpanContextValid(spanContext) {
1168
+ return isValidTraceId(spanContext.traceId) && isValidSpanId(spanContext.spanId);
1169
+ }
1170
+ function wrapSpanContext(spanContext) {
1171
+ return new NonRecordingSpan(spanContext);
1172
+ }
1173
+
1174
+ // node_modules/@opentelemetry/api/build/esm/trace/NoopTracer.js
1175
+ var contextApi = ContextAPI.getInstance();
1176
+ var NoopTracer = (
1177
+ /** @class */
1178
+ function() {
1179
+ function NoopTracer2() {
1180
+ }
1181
+ NoopTracer2.prototype.startSpan = function(name, options, context2) {
1182
+ if (context2 === void 0) {
1183
+ context2 = contextApi.active();
1184
+ }
1185
+ var root = Boolean(options === null || options === void 0 ? void 0 : options.root);
1186
+ if (root) {
1187
+ return new NonRecordingSpan();
1188
+ }
1189
+ var parentFromContext = context2 && getSpanContext(context2);
1190
+ if (isSpanContext(parentFromContext) && isSpanContextValid(parentFromContext)) {
1191
+ return new NonRecordingSpan(parentFromContext);
1192
+ } else {
1193
+ return new NonRecordingSpan();
1194
+ }
1195
+ };
1196
+ NoopTracer2.prototype.startActiveSpan = function(name, arg2, arg3, arg4) {
1197
+ var opts;
1198
+ var ctx;
1199
+ var fn;
1200
+ if (arguments.length < 2) {
1201
+ return;
1202
+ } else if (arguments.length === 2) {
1203
+ fn = arg2;
1204
+ } else if (arguments.length === 3) {
1205
+ opts = arg2;
1206
+ fn = arg3;
1207
+ } else {
1208
+ opts = arg2;
1209
+ ctx = arg3;
1210
+ fn = arg4;
1211
+ }
1212
+ var parentContext = ctx !== null && ctx !== void 0 ? ctx : contextApi.active();
1213
+ var span = this.startSpan(name, opts, parentContext);
1214
+ var contextWithSpanSet = setSpan(parentContext, span);
1215
+ return contextApi.with(contextWithSpanSet, fn, void 0, span);
1216
+ };
1217
+ return NoopTracer2;
1218
+ }()
1219
+ );
1220
+ function isSpanContext(spanContext) {
1221
+ return typeof spanContext === "object" && typeof spanContext["spanId"] === "string" && typeof spanContext["traceId"] === "string" && typeof spanContext["traceFlags"] === "number";
1222
+ }
1223
+
1224
+ // node_modules/@opentelemetry/api/build/esm/trace/ProxyTracer.js
1225
+ var NOOP_TRACER = new NoopTracer();
1226
+ var ProxyTracer = (
1227
+ /** @class */
1228
+ function() {
1229
+ function ProxyTracer2(_provider, name, version, options) {
1230
+ this._provider = _provider;
1231
+ this.name = name;
1232
+ this.version = version;
1233
+ this.options = options;
1234
+ }
1235
+ ProxyTracer2.prototype.startSpan = function(name, options, context2) {
1236
+ return this._getTracer().startSpan(name, options, context2);
1237
+ };
1238
+ ProxyTracer2.prototype.startActiveSpan = function(_name, _options, _context, _fn) {
1239
+ var tracer2 = this._getTracer();
1240
+ return Reflect.apply(tracer2.startActiveSpan, tracer2, arguments);
1241
+ };
1242
+ ProxyTracer2.prototype._getTracer = function() {
1243
+ if (this._delegate) {
1244
+ return this._delegate;
1245
+ }
1246
+ var tracer2 = this._provider.getDelegateTracer(this.name, this.version, this.options);
1247
+ if (!tracer2) {
1248
+ return NOOP_TRACER;
1249
+ }
1250
+ this._delegate = tracer2;
1251
+ return this._delegate;
1252
+ };
1253
+ return ProxyTracer2;
1254
+ }()
1255
+ );
1256
+
1257
+ // node_modules/@opentelemetry/api/build/esm/trace/NoopTracerProvider.js
1258
+ var NoopTracerProvider = (
1259
+ /** @class */
1260
+ function() {
1261
+ function NoopTracerProvider2() {
1262
+ }
1263
+ NoopTracerProvider2.prototype.getTracer = function(_name, _version, _options) {
1264
+ return new NoopTracer();
1265
+ };
1266
+ return NoopTracerProvider2;
1267
+ }()
1268
+ );
1269
+
1270
+ // node_modules/@opentelemetry/api/build/esm/trace/ProxyTracerProvider.js
1271
+ var NOOP_TRACER_PROVIDER = new NoopTracerProvider();
1272
+ var ProxyTracerProvider = (
1273
+ /** @class */
1274
+ function() {
1275
+ function ProxyTracerProvider2() {
1276
+ }
1277
+ ProxyTracerProvider2.prototype.getTracer = function(name, version, options) {
1278
+ var _a;
1279
+ return (_a = this.getDelegateTracer(name, version, options)) !== null && _a !== void 0 ? _a : new ProxyTracer(this, name, version, options);
1280
+ };
1281
+ ProxyTracerProvider2.prototype.getDelegate = function() {
1282
+ var _a;
1283
+ return (_a = this._delegate) !== null && _a !== void 0 ? _a : NOOP_TRACER_PROVIDER;
1284
+ };
1285
+ ProxyTracerProvider2.prototype.setDelegate = function(delegate) {
1286
+ this._delegate = delegate;
1287
+ };
1288
+ ProxyTracerProvider2.prototype.getDelegateTracer = function(name, version, options) {
1289
+ var _a;
1290
+ return (_a = this._delegate) === null || _a === void 0 ? void 0 : _a.getTracer(name, version, options);
1291
+ };
1292
+ return ProxyTracerProvider2;
1293
+ }()
1294
+ );
1295
+
1296
+ // node_modules/@opentelemetry/api/build/esm/trace/status.js
1297
+ var SpanStatusCode;
1298
+ (function(SpanStatusCode2) {
1299
+ SpanStatusCode2[SpanStatusCode2["UNSET"] = 0] = "UNSET";
1300
+ SpanStatusCode2[SpanStatusCode2["OK"] = 1] = "OK";
1301
+ SpanStatusCode2[SpanStatusCode2["ERROR"] = 2] = "ERROR";
1302
+ })(SpanStatusCode || (SpanStatusCode = {}));
1303
+
1304
+ // node_modules/@opentelemetry/api/build/esm/context-api.js
1305
+ var context = ContextAPI.getInstance();
1306
+
1307
+ // node_modules/@opentelemetry/api/build/esm/api/trace.js
1308
+ var API_NAME3 = "trace";
1309
+ var TraceAPI = (
1310
+ /** @class */
1311
+ function() {
1312
+ function TraceAPI2() {
1313
+ this._proxyTracerProvider = new ProxyTracerProvider();
1314
+ this.wrapSpanContext = wrapSpanContext;
1315
+ this.isSpanContextValid = isSpanContextValid;
1316
+ this.deleteSpan = deleteSpan;
1317
+ this.getSpan = getSpan;
1318
+ this.getActiveSpan = getActiveSpan;
1319
+ this.getSpanContext = getSpanContext;
1320
+ this.setSpan = setSpan;
1321
+ this.setSpanContext = setSpanContext;
1322
+ }
1323
+ TraceAPI2.getInstance = function() {
1324
+ if (!this._instance) {
1325
+ this._instance = new TraceAPI2();
1326
+ }
1327
+ return this._instance;
1328
+ };
1329
+ TraceAPI2.prototype.setGlobalTracerProvider = function(provider) {
1330
+ var success = registerGlobal(API_NAME3, this._proxyTracerProvider, DiagAPI.instance());
1331
+ if (success) {
1332
+ this._proxyTracerProvider.setDelegate(provider);
1333
+ }
1334
+ return success;
1335
+ };
1336
+ TraceAPI2.prototype.getTracerProvider = function() {
1337
+ return getGlobal(API_NAME3) || this._proxyTracerProvider;
1338
+ };
1339
+ TraceAPI2.prototype.getTracer = function(name, version) {
1340
+ return this.getTracerProvider().getTracer(name, version);
1341
+ };
1342
+ TraceAPI2.prototype.disable = function() {
1343
+ unregisterGlobal(API_NAME3, DiagAPI.instance());
1344
+ this._proxyTracerProvider = new ProxyTracerProvider();
1345
+ };
1346
+ return TraceAPI2;
1347
+ }()
1348
+ );
1349
+
1350
+ // node_modules/@opentelemetry/api/build/esm/trace-api.js
1351
+ var trace = TraceAPI.getInstance();
1352
+
1353
+ // node_modules/@opentelemetry/api/build/esm/experimental/trace/SugaredTracer.js
1354
+ var defaultOnException = function(e, span) {
1355
+ span.recordException(e);
1356
+ span.setStatus({
1357
+ code: SpanStatusCode.ERROR
1358
+ });
1359
+ };
1360
+ function wrapTracer(tracer2) {
1361
+ return new SugaredTracer(tracer2);
1362
+ }
1363
+ var SugaredTracer = (
1364
+ /** @class */
1365
+ function() {
1366
+ function SugaredTracer3(tracer2) {
1367
+ this._tracer = tracer2;
1368
+ this.startSpan = tracer2.startSpan.bind(this._tracer);
1369
+ this.startActiveSpan = tracer2.startActiveSpan.bind(this._tracer);
1370
+ }
1371
+ SugaredTracer3.prototype.withActiveSpan = function(name, arg2, arg3, arg4) {
1372
+ var _a = massageParams(arg2, arg3, arg4), opts = _a.opts, ctx = _a.ctx, fn = _a.fn;
1373
+ return this._tracer.startActiveSpan(name, opts, ctx, function(span) {
1374
+ return handleFn(span, opts, fn);
1375
+ });
1376
+ };
1377
+ SugaredTracer3.prototype.withSpan = function(name, arg2, arg3, arg4) {
1378
+ var _a = massageParams(arg2, arg3, arg4), opts = _a.opts, ctx = _a.ctx, fn = _a.fn;
1379
+ var span = this._tracer.startSpan(name, opts, ctx);
1380
+ return handleFn(span, opts, fn);
1381
+ };
1382
+ return SugaredTracer3;
1383
+ }()
1384
+ );
1385
+ function massageParams(arg, arg2, arg3) {
1386
+ var opts;
1387
+ var ctx;
1388
+ var fn;
1389
+ if (!arg2 && !arg3) {
1390
+ fn = arg;
1391
+ } else if (!arg3) {
1392
+ opts = arg;
1393
+ fn = arg2;
1394
+ } else {
1395
+ opts = arg;
1396
+ ctx = arg2;
1397
+ fn = arg3;
1398
+ }
1399
+ opts = opts !== null && opts !== void 0 ? opts : {};
1400
+ ctx = ctx !== null && ctx !== void 0 ? ctx : context.active();
1401
+ return { opts, ctx, fn };
1402
+ }
1403
+ function handleFn(span, opts, fn) {
1404
+ var _a;
1405
+ var onException = (_a = opts.onException) !== null && _a !== void 0 ? _a : defaultOnException;
1406
+ var errorHandler = function(e) {
1407
+ onException(e, span);
1408
+ span.end();
1409
+ throw e;
1410
+ };
1411
+ try {
1412
+ var ret = fn(span);
1413
+ if (typeof (ret === null || ret === void 0 ? void 0 : ret.then) === "function") {
1414
+ return ret.then(function(val) {
1415
+ span.end();
1416
+ return val;
1417
+ }, errorHandler);
1418
+ }
1419
+ span.end();
1420
+ return ret;
1421
+ } catch (e) {
1422
+ throw errorHandler(e);
1423
+ }
1424
+ }
1425
+
1426
+ // src/run/handlers/tracer.cts
1427
+ var spanMeta = /* @__PURE__ */ new WeakMap();
1428
+ var spanCounter = /* @__PURE__ */ new WeakMap();
1429
+ function spanHook(span) {
1430
+ const originalEnd = span.end.bind(span);
1431
+ span.end = (endTime) => {
1432
+ originalEnd(endTime);
1433
+ const meta = spanMeta.get(span);
1434
+ if (meta) {
1435
+ const requestContext = getRequestContext();
1436
+ if (requestContext?.captureServerTiming) {
1437
+ const duration = (typeof endTime === "number" ? endTime : performance.now()) - meta.start;
1438
+ const serverTiming = requestContext.serverTiming ?? "";
1439
+ const currentRequestSpanCounter = spanCounter.get(requestContext) ?? 1;
1440
+ requestContext.serverTiming = `${serverTiming}${serverTiming.length === 0 ? "" : ", "}s${currentRequestSpanCounter};dur=${duration};desc="${meta.name}"`;
1441
+ spanCounter.set(requestContext, currentRequestSpanCounter + 1);
1442
+ }
1443
+ }
1444
+ spanMeta.delete(span);
1445
+ };
1446
+ return span;
1447
+ }
1448
+ var tracer;
1449
+ function getTracer() {
1450
+ if (!tracer) {
1451
+ const baseTracer = trace.getTracer("Next.js Runtime");
1452
+ const startSpan = baseTracer.startSpan.bind(baseTracer);
1453
+ baseTracer.startSpan = (...args) => {
1454
+ const span = startSpan(...args);
1455
+ spanMeta.set(span, { start: performance.now(), name: args[0] });
1456
+ return spanHook(span);
1457
+ };
1458
+ const startActiveSpan = baseTracer.startActiveSpan.bind(baseTracer);
1459
+ baseTracer.startActiveSpan = (...args) => {
1460
+ const [name, ...restOfArgs] = args;
1461
+ const augmentedArgs = restOfArgs.map((arg) => {
1462
+ if (typeof arg === "function") {
1463
+ return (span) => {
1464
+ spanMeta.set(span, { start: performance.now(), name: args[0] });
1465
+ spanHook(span);
1466
+ return arg(span);
1467
+ };
1468
+ }
1469
+ return arg;
1470
+ });
1471
+ return startActiveSpan(name, ...augmentedArgs);
1472
+ };
1473
+ tracer = wrapTracer(baseTracer);
1474
+ }
1475
+ return tracer;
1476
+ }
1477
+
1478
+ // node_modules/@netlify/blobs/dist/chunk-GUEW34CP.js
1479
+ var NF_ERROR = "x-nf-error";
1480
+ var NF_REQUEST_ID = "x-nf-request-id";
1481
+ var BlobsInternalError = class extends Error {
1482
+ constructor(res) {
1483
+ let details = res.headers.get(NF_ERROR) || `${res.status} status code`;
1484
+ if (res.headers.has(NF_REQUEST_ID)) {
1485
+ details += `, ID: ${res.headers.get(NF_REQUEST_ID)}`;
1486
+ }
1487
+ super(`Netlify Blobs has generated an internal error (${details})`);
1488
+ this.name = "BlobsInternalError";
1489
+ }
1490
+ };
1491
+ var collectIterator = async (iterator) => {
1492
+ const result = [];
1493
+ for await (const item of iterator) {
1494
+ result.push(item);
1495
+ }
1496
+ return result;
1497
+ };
1498
+ var base64Decode = (input) => {
1499
+ const { Buffer: Buffer3 } = globalThis;
1500
+ if (Buffer3) {
1501
+ return Buffer3.from(input, "base64").toString();
1502
+ }
1503
+ return atob(input);
1504
+ };
1505
+ var base64Encode = (input) => {
1506
+ const { Buffer: Buffer3 } = globalThis;
1507
+ if (Buffer3) {
1508
+ return Buffer3.from(input).toString("base64");
1509
+ }
1510
+ return btoa(input);
1511
+ };
1512
+ var getEnvironment = () => {
1513
+ const { Deno, Netlify, process: process2 } = globalThis;
1514
+ return Netlify?.env ?? Deno?.env ?? {
1515
+ delete: (key) => delete process2?.env[key],
1516
+ get: (key) => process2?.env[key],
1517
+ has: (key) => Boolean(process2?.env[key]),
1518
+ set: (key, value) => {
1519
+ if (process2?.env) {
1520
+ process2.env[key] = value;
1521
+ }
1522
+ },
1523
+ toObject: () => process2?.env ?? {}
1524
+ };
1525
+ };
1526
+ var getEnvironmentContext = () => {
1527
+ const context2 = globalThis.netlifyBlobsContext || getEnvironment().get("NETLIFY_BLOBS_CONTEXT");
1528
+ if (typeof context2 !== "string" || !context2) {
1529
+ return {};
1530
+ }
1531
+ const data = base64Decode(context2);
1532
+ try {
1533
+ return JSON.parse(data);
1534
+ } catch {
1535
+ }
1536
+ return {};
1537
+ };
1538
+ var MissingBlobsEnvironmentError = class extends Error {
1539
+ constructor(requiredProperties) {
1540
+ super(
1541
+ `The environment has not been configured to use Netlify Blobs. To use it manually, supply the following properties when creating a store: ${requiredProperties.join(
1542
+ ", "
1543
+ )}`
1544
+ );
1545
+ this.name = "MissingBlobsEnvironmentError";
1546
+ }
1547
+ };
1548
+ var BASE64_PREFIX = "b64;";
1549
+ var METADATA_HEADER_INTERNAL = "x-amz-meta-user";
1550
+ var METADATA_HEADER_EXTERNAL = "netlify-blobs-metadata";
1551
+ var METADATA_MAX_SIZE = 2 * 1024;
1552
+ var encodeMetadata = (metadata) => {
1553
+ if (!metadata) {
1554
+ return null;
1555
+ }
1556
+ const encodedObject = base64Encode(JSON.stringify(metadata));
1557
+ const payload = `b64;${encodedObject}`;
1558
+ if (METADATA_HEADER_EXTERNAL.length + payload.length > METADATA_MAX_SIZE) {
1559
+ throw new Error("Metadata object exceeds the maximum size");
1560
+ }
1561
+ return payload;
1562
+ };
1563
+ var decodeMetadata = (header) => {
1564
+ if (!header || !header.startsWith(BASE64_PREFIX)) {
1565
+ return {};
1566
+ }
1567
+ const encodedData = header.slice(BASE64_PREFIX.length);
1568
+ const decodedData = base64Decode(encodedData);
1569
+ const metadata = JSON.parse(decodedData);
1570
+ return metadata;
1571
+ };
1572
+ var getMetadataFromResponse = (response) => {
1573
+ if (!response.headers) {
1574
+ return {};
1575
+ }
1576
+ const value = response.headers.get(METADATA_HEADER_EXTERNAL) || response.headers.get(METADATA_HEADER_INTERNAL);
1577
+ try {
1578
+ return decodeMetadata(value);
1579
+ } catch {
1580
+ throw new Error(
1581
+ "An internal error occurred while trying to retrieve the metadata for an entry. Please try updating to the latest version of the Netlify Blobs client."
1582
+ );
1583
+ }
1584
+ };
1585
+ var BlobsConsistencyError = class extends Error {
1586
+ constructor() {
1587
+ super(
1588
+ `Netlify Blobs has failed to perform a read using strong consistency because the environment has not been configured with a 'uncachedEdgeURL' property`
1589
+ );
1590
+ this.name = "BlobsConsistencyError";
1591
+ }
1592
+ };
1593
+ var REGION_AUTO = "auto";
1594
+ var regions = {
1595
+ "us-east-1": true,
1596
+ "us-east-2": true
1597
+ };
1598
+ var isValidRegion = (input) => Object.keys(regions).includes(input);
1599
+ var InvalidBlobsRegionError = class extends Error {
1600
+ constructor(region) {
1601
+ super(
1602
+ `${region} is not a supported Netlify Blobs region. Supported values are: ${Object.keys(regions).join(", ")}.`
1603
+ );
1604
+ this.name = "InvalidBlobsRegionError";
1605
+ }
1606
+ };
1607
+ var DEFAULT_RETRY_DELAY = getEnvironment().get("NODE_ENV") === "test" ? 1 : 5e3;
1608
+ var MIN_RETRY_DELAY = 1e3;
1609
+ var MAX_RETRY = 5;
1610
+ var RATE_LIMIT_HEADER = "X-RateLimit-Reset";
1611
+ var fetchAndRetry = async (fetch, url, options, attemptsLeft = MAX_RETRY) => {
1612
+ try {
1613
+ const res = await fetch(url, options);
1614
+ if (attemptsLeft > 0 && (res.status === 429 || res.status >= 500)) {
1615
+ const delay = getDelay(res.headers.get(RATE_LIMIT_HEADER));
1616
+ await sleep(delay);
1617
+ return fetchAndRetry(fetch, url, options, attemptsLeft - 1);
1618
+ }
1619
+ return res;
1620
+ } catch (error) {
1621
+ if (attemptsLeft === 0) {
1622
+ throw error;
1623
+ }
1624
+ const delay = getDelay();
1625
+ await sleep(delay);
1626
+ return fetchAndRetry(fetch, url, options, attemptsLeft - 1);
1627
+ }
1628
+ };
1629
+ var getDelay = (rateLimitReset) => {
1630
+ if (!rateLimitReset) {
1631
+ return DEFAULT_RETRY_DELAY;
1632
+ }
1633
+ return Math.max(Number(rateLimitReset) * 1e3 - Date.now(), MIN_RETRY_DELAY);
1634
+ };
1635
+ var sleep = (ms) => new Promise((resolve2) => {
1636
+ setTimeout(resolve2, ms);
1637
+ });
1638
+ var SIGNED_URL_ACCEPT_HEADER = "application/json;type=signed-url";
1639
+ var Client = class {
1640
+ constructor({ apiURL, consistency, edgeURL, fetch, region, siteID, token, uncachedEdgeURL }) {
1641
+ this.apiURL = apiURL;
1642
+ this.consistency = consistency ?? "eventual";
1643
+ this.edgeURL = edgeURL;
1644
+ this.fetch = fetch ?? globalThis.fetch;
1645
+ this.region = region;
1646
+ this.siteID = siteID;
1647
+ this.token = token;
1648
+ this.uncachedEdgeURL = uncachedEdgeURL;
1649
+ if (!this.fetch) {
1650
+ throw new Error(
1651
+ "Netlify Blobs could not find a `fetch` client in the global scope. You can either update your runtime to a version that includes `fetch` (like Node.js 18.0.0 or above), or you can supply your own implementation using the `fetch` property."
1652
+ );
1653
+ }
1654
+ }
1655
+ async getFinalRequest({
1656
+ consistency: opConsistency,
1657
+ key,
1658
+ metadata,
1659
+ method,
1660
+ parameters = {},
1661
+ storeName
1662
+ }) {
1663
+ const encodedMetadata = encodeMetadata(metadata);
1664
+ const consistency = opConsistency ?? this.consistency;
1665
+ let urlPath = `/${this.siteID}`;
1666
+ if (storeName) {
1667
+ urlPath += `/${storeName}`;
1668
+ }
1669
+ if (key) {
1670
+ urlPath += `/${key}`;
1671
+ }
1672
+ if (this.edgeURL) {
1673
+ if (consistency === "strong" && !this.uncachedEdgeURL) {
1674
+ throw new BlobsConsistencyError();
1675
+ }
1676
+ const headers = {
1677
+ authorization: `Bearer ${this.token}`
1678
+ };
1679
+ if (encodedMetadata) {
1680
+ headers[METADATA_HEADER_INTERNAL] = encodedMetadata;
1681
+ }
1682
+ if (this.region) {
1683
+ urlPath = `/region:${this.region}${urlPath}`;
1684
+ }
1685
+ const url2 = new URL(urlPath, consistency === "strong" ? this.uncachedEdgeURL : this.edgeURL);
1686
+ for (const key2 in parameters) {
1687
+ url2.searchParams.set(key2, parameters[key2]);
1688
+ }
1689
+ return {
1690
+ headers,
1691
+ url: url2.toString()
1692
+ };
1693
+ }
1694
+ const apiHeaders = { authorization: `Bearer ${this.token}` };
1695
+ const url = new URL(`/api/v1/blobs${urlPath}`, this.apiURL ?? "https://api.netlify.com");
1696
+ for (const key2 in parameters) {
1697
+ url.searchParams.set(key2, parameters[key2]);
1698
+ }
1699
+ if (this.region) {
1700
+ url.searchParams.set("region", this.region);
1701
+ }
1702
+ if (storeName === void 0 || key === void 0) {
1703
+ return {
1704
+ headers: apiHeaders,
1705
+ url: url.toString()
1706
+ };
1707
+ }
1708
+ if (encodedMetadata) {
1709
+ apiHeaders[METADATA_HEADER_EXTERNAL] = encodedMetadata;
1710
+ }
1711
+ if (method === "head" || method === "delete") {
1712
+ return {
1713
+ headers: apiHeaders,
1714
+ url: url.toString()
1715
+ };
1716
+ }
1717
+ const res = await this.fetch(url.toString(), {
1718
+ headers: { ...apiHeaders, accept: SIGNED_URL_ACCEPT_HEADER },
1719
+ method
1720
+ });
1721
+ if (res.status !== 200) {
1722
+ throw new BlobsInternalError(res);
1723
+ }
1724
+ const { url: signedURL } = await res.json();
1725
+ const userHeaders = encodedMetadata ? { [METADATA_HEADER_INTERNAL]: encodedMetadata } : void 0;
1726
+ return {
1727
+ headers: userHeaders,
1728
+ url: signedURL
1729
+ };
1730
+ }
1731
+ async makeRequest({
1732
+ body,
1733
+ consistency,
1734
+ headers: extraHeaders,
1735
+ key,
1736
+ metadata,
1737
+ method,
1738
+ parameters,
1739
+ storeName
1740
+ }) {
1741
+ const { headers: baseHeaders = {}, url } = await this.getFinalRequest({
1742
+ consistency,
1743
+ key,
1744
+ metadata,
1745
+ method,
1746
+ parameters,
1747
+ storeName
1748
+ });
1749
+ const headers = {
1750
+ ...baseHeaders,
1751
+ ...extraHeaders
1752
+ };
1753
+ if (method === "put") {
1754
+ headers["cache-control"] = "max-age=0, stale-while-revalidate=60";
1755
+ }
1756
+ const options = {
1757
+ body,
1758
+ headers,
1759
+ method
1760
+ };
1761
+ if (body instanceof ReadableStream) {
1762
+ options.duplex = "half";
1763
+ }
1764
+ return fetchAndRetry(this.fetch, url, options);
1765
+ }
1766
+ };
1767
+ var getClientOptions = (options, contextOverride) => {
1768
+ const context2 = contextOverride ?? getEnvironmentContext();
1769
+ const siteID = context2.siteID ?? options.siteID;
1770
+ const token = context2.token ?? options.token;
1771
+ if (!siteID || !token) {
1772
+ throw new MissingBlobsEnvironmentError(["siteID", "token"]);
1773
+ }
1774
+ if (options.region !== void 0 && !isValidRegion(options.region)) {
1775
+ throw new InvalidBlobsRegionError(options.region);
1776
+ }
1777
+ const clientOptions = {
1778
+ apiURL: context2.apiURL ?? options.apiURL,
1779
+ consistency: options.consistency,
1780
+ edgeURL: context2.edgeURL ?? options.edgeURL,
1781
+ fetch: options.fetch,
1782
+ region: options.region,
1783
+ siteID,
1784
+ token,
1785
+ uncachedEdgeURL: context2.uncachedEdgeURL ?? options.uncachedEdgeURL
1786
+ };
1787
+ return clientOptions;
1788
+ };
1789
+
1790
+ // node_modules/@netlify/blobs/dist/main.js
1791
+ var DEPLOY_STORE_PREFIX = "deploy:";
1792
+ var LEGACY_STORE_INTERNAL_PREFIX = "netlify-internal/legacy-namespace/";
1793
+ var SITE_STORE_PREFIX = "site:";
1794
+ var Store = class _Store {
1795
+ constructor(options) {
1796
+ this.client = options.client;
1797
+ if ("deployID" in options) {
1798
+ _Store.validateDeployID(options.deployID);
1799
+ let name = DEPLOY_STORE_PREFIX + options.deployID;
1800
+ if (options.name) {
1801
+ name += `:${options.name}`;
1802
+ }
1803
+ this.name = name;
1804
+ } else if (options.name.startsWith(LEGACY_STORE_INTERNAL_PREFIX)) {
1805
+ const storeName = options.name.slice(LEGACY_STORE_INTERNAL_PREFIX.length);
1806
+ _Store.validateStoreName(storeName);
1807
+ this.name = storeName;
1808
+ } else {
1809
+ _Store.validateStoreName(options.name);
1810
+ this.name = SITE_STORE_PREFIX + options.name;
1811
+ }
1812
+ }
1813
+ async delete(key) {
1814
+ const res = await this.client.makeRequest({ key, method: "delete", storeName: this.name });
1815
+ if (![200, 204, 404].includes(res.status)) {
1816
+ throw new BlobsInternalError(res);
1817
+ }
1818
+ }
1819
+ async get(key, options) {
1820
+ const { consistency, type } = options ?? {};
1821
+ const res = await this.client.makeRequest({ consistency, key, method: "get", storeName: this.name });
1822
+ if (res.status === 404) {
1823
+ return null;
1824
+ }
1825
+ if (res.status !== 200) {
1826
+ throw new BlobsInternalError(res);
1827
+ }
1828
+ if (type === void 0 || type === "text") {
1829
+ return res.text();
1830
+ }
1831
+ if (type === "arrayBuffer") {
1832
+ return res.arrayBuffer();
1833
+ }
1834
+ if (type === "blob") {
1835
+ return res.blob();
1836
+ }
1837
+ if (type === "json") {
1838
+ return res.json();
1839
+ }
1840
+ if (type === "stream") {
1841
+ return res.body;
1842
+ }
1843
+ throw new BlobsInternalError(res);
1844
+ }
1845
+ async getMetadata(key, { consistency } = {}) {
1846
+ const res = await this.client.makeRequest({ consistency, key, method: "head", storeName: this.name });
1847
+ if (res.status === 404) {
1848
+ return null;
1849
+ }
1850
+ if (res.status !== 200 && res.status !== 304) {
1851
+ throw new BlobsInternalError(res);
1852
+ }
1853
+ const etag = res?.headers.get("etag") ?? void 0;
1854
+ const metadata = getMetadataFromResponse(res);
1855
+ const result = {
1856
+ etag,
1857
+ metadata
1858
+ };
1859
+ return result;
1860
+ }
1861
+ async getWithMetadata(key, options) {
1862
+ const { consistency, etag: requestETag, type } = options ?? {};
1863
+ const headers = requestETag ? { "if-none-match": requestETag } : void 0;
1864
+ const res = await this.client.makeRequest({
1865
+ consistency,
1866
+ headers,
1867
+ key,
1868
+ method: "get",
1869
+ storeName: this.name
1870
+ });
1871
+ if (res.status === 404) {
1872
+ return null;
1873
+ }
1874
+ if (res.status !== 200 && res.status !== 304) {
1875
+ throw new BlobsInternalError(res);
1876
+ }
1877
+ const responseETag = res?.headers.get("etag") ?? void 0;
1878
+ const metadata = getMetadataFromResponse(res);
1879
+ const result = {
1880
+ etag: responseETag,
1881
+ metadata
1882
+ };
1883
+ if (res.status === 304 && requestETag) {
1884
+ return { data: null, ...result };
1885
+ }
1886
+ if (type === void 0 || type === "text") {
1887
+ return { data: await res.text(), ...result };
1888
+ }
1889
+ if (type === "arrayBuffer") {
1890
+ return { data: await res.arrayBuffer(), ...result };
1891
+ }
1892
+ if (type === "blob") {
1893
+ return { data: await res.blob(), ...result };
1894
+ }
1895
+ if (type === "json") {
1896
+ return { data: await res.json(), ...result };
1897
+ }
1898
+ if (type === "stream") {
1899
+ return { data: res.body, ...result };
1900
+ }
1901
+ throw new Error(`Invalid 'type' property: ${type}. Expected: arrayBuffer, blob, json, stream, or text.`);
1902
+ }
1903
+ list(options = {}) {
1904
+ const iterator = this.getListIterator(options);
1905
+ if (options.paginate) {
1906
+ return iterator;
1907
+ }
1908
+ return collectIterator(iterator).then(
1909
+ (items) => items.reduce(
1910
+ (acc, item) => ({
1911
+ blobs: [...acc.blobs, ...item.blobs],
1912
+ directories: [...acc.directories, ...item.directories]
1913
+ }),
1914
+ { blobs: [], directories: [] }
1915
+ )
1916
+ );
1917
+ }
1918
+ async set(key, data, { metadata } = {}) {
1919
+ _Store.validateKey(key);
1920
+ const res = await this.client.makeRequest({
1921
+ body: data,
1922
+ key,
1923
+ metadata,
1924
+ method: "put",
1925
+ storeName: this.name
1926
+ });
1927
+ if (res.status !== 200) {
1928
+ throw new BlobsInternalError(res);
1929
+ }
1930
+ }
1931
+ async setJSON(key, data, { metadata } = {}) {
1932
+ _Store.validateKey(key);
1933
+ const payload = JSON.stringify(data);
1934
+ const headers = {
1935
+ "content-type": "application/json"
1936
+ };
1937
+ const res = await this.client.makeRequest({
1938
+ body: payload,
1939
+ headers,
1940
+ key,
1941
+ metadata,
1942
+ method: "put",
1943
+ storeName: this.name
1944
+ });
1945
+ if (res.status !== 200) {
1946
+ throw new BlobsInternalError(res);
1947
+ }
1948
+ }
1949
+ static formatListResultBlob(result) {
1950
+ if (!result.key) {
1951
+ return null;
1952
+ }
1953
+ return {
1954
+ etag: result.etag,
1955
+ key: result.key
1956
+ };
1957
+ }
1958
+ static validateKey(key) {
1959
+ if (key === "") {
1960
+ throw new Error("Blob key must not be empty.");
1961
+ }
1962
+ if (key.startsWith("/") || key.startsWith("%2F")) {
1963
+ throw new Error("Blob key must not start with forward slash (/).");
1964
+ }
1965
+ if (new TextEncoder().encode(key).length > 600) {
1966
+ throw new Error(
1967
+ "Blob key must be a sequence of Unicode characters whose UTF-8 encoding is at most 600 bytes long."
1968
+ );
1969
+ }
1970
+ }
1971
+ static validateDeployID(deployID) {
1972
+ if (!/^\w{1,24}$/.test(deployID)) {
1973
+ throw new Error(`'${deployID}' is not a valid Netlify deploy ID.`);
1974
+ }
1975
+ }
1976
+ static validateStoreName(name) {
1977
+ if (name.includes("/") || name.includes("%2F")) {
1978
+ throw new Error("Store name must not contain forward slashes (/).");
1979
+ }
1980
+ if (new TextEncoder().encode(name).length > 64) {
1981
+ throw new Error(
1982
+ "Store name must be a sequence of Unicode characters whose UTF-8 encoding is at most 64 bytes long."
1983
+ );
1984
+ }
1985
+ }
1986
+ getListIterator(options) {
1987
+ const { client, name: storeName } = this;
1988
+ const parameters = {};
1989
+ if (options?.prefix) {
1990
+ parameters.prefix = options.prefix;
1991
+ }
1992
+ if (options?.directories) {
1993
+ parameters.directories = "true";
1994
+ }
1995
+ return {
1996
+ [Symbol.asyncIterator]() {
1997
+ let currentCursor = null;
1998
+ let done = false;
1999
+ return {
2000
+ async next() {
2001
+ if (done) {
2002
+ return { done: true, value: void 0 };
2003
+ }
2004
+ const nextParameters = { ...parameters };
2005
+ if (currentCursor !== null) {
2006
+ nextParameters.cursor = currentCursor;
2007
+ }
2008
+ const res = await client.makeRequest({
2009
+ method: "get",
2010
+ parameters: nextParameters,
2011
+ storeName
2012
+ });
2013
+ let blobs = [];
2014
+ let directories = [];
2015
+ if (![200, 204, 404].includes(res.status)) {
2016
+ throw new BlobsInternalError(res);
2017
+ }
2018
+ if (res.status === 404) {
2019
+ done = true;
2020
+ } else {
2021
+ const page = await res.json();
2022
+ if (page.next_cursor) {
2023
+ currentCursor = page.next_cursor;
2024
+ } else {
2025
+ done = true;
2026
+ }
2027
+ blobs = (page.blobs ?? []).map(_Store.formatListResultBlob).filter(Boolean);
2028
+ directories = page.directories ?? [];
2029
+ }
2030
+ return {
2031
+ done: false,
2032
+ value: {
2033
+ blobs,
2034
+ directories
2035
+ }
2036
+ };
2037
+ }
2038
+ };
2039
+ }
2040
+ };
2041
+ }
2042
+ };
2043
+ var getDeployStore = (input = {}) => {
2044
+ const context2 = getEnvironmentContext();
2045
+ const options = typeof input === "string" ? { name: input } : input;
2046
+ const deployID = options.deployID ?? context2.deployID;
2047
+ if (!deployID) {
2048
+ throw new MissingBlobsEnvironmentError(["deployID"]);
2049
+ }
2050
+ const clientOptions = getClientOptions(options, context2);
2051
+ if (!clientOptions.region) {
2052
+ if (clientOptions.edgeURL || clientOptions.uncachedEdgeURL) {
2053
+ if (!context2.primaryRegion) {
2054
+ throw new Error(
2055
+ "When accessing a deploy store, the Netlify Blobs client needs to be configured with a region, and one was not found in the environment. To manually set the region, set the `region` property in the `getDeployStore` options. If you are using the Netlify CLI, you may have an outdated version; run `npm install -g netlify-cli@latest` to update and try again."
2056
+ );
2057
+ }
2058
+ clientOptions.region = context2.primaryRegion;
2059
+ } else {
2060
+ clientOptions.region = REGION_AUTO;
2061
+ }
2062
+ }
2063
+ const client = new Client(clientOptions);
2064
+ return new Store({ client, deployID, name: options.name });
2065
+ };
2066
+
2067
+ // src/run/regional-blob-store.cts
2068
+ var fetchBeforeNextPatchedIt = globalThis.fetch;
2069
+ var getRegionalBlobStore = (args = {}) => {
2070
+ return getDeployStore({
2071
+ ...args,
2072
+ fetch: fetchBeforeNextPatchedIt,
2073
+ region: process.env.USE_REGIONAL_BLOBS?.toUpperCase() === "TRUE" ? void 0 : "us-east-2"
2074
+ });
2075
+ };
2076
+
2077
+ // src/run/next.cts
497
2078
  process.env.NODE_ENV = "production";
498
2079
  console.time("import next server");
499
2080
  var { getRequestHandlers } = require("next/dist/server/lib/start-server.js");
@@ -506,7 +2087,7 @@ ResponseCache.prototype.get = function get(...getArgs) {
506
2087
  this.batcher.batch = async (key, fn) => {
507
2088
  const trackedFn = async (...workFnArgs) => {
508
2089
  const workPromise = fn(...workFnArgs);
509
- const requestContext = (0, import_request_context.getRequestContext)();
2090
+ const requestContext = getRequestContext();
510
2091
  if (requestContext && workPromise instanceof Promise) {
511
2092
  requestContext.trackBackgroundWork(workPromise);
512
2093
  }
@@ -518,7 +2099,7 @@ ResponseCache.prototype.get = function get(...getArgs) {
518
2099
  const backgroundWork = /* @__PURE__ */ new Map();
519
2100
  const originalPendingResponsesSet = this.pendingResponses.set;
520
2101
  this.pendingResponses.set = async (key, value) => {
521
- const requestContext = (0, import_request_context.getRequestContext)();
2102
+ const requestContext = getRequestContext();
522
2103
  if (requestContext && !this.pendingResponses.has(key)) {
523
2104
  const workPromise = new Promise((_resolve) => {
524
2105
  backgroundWork.set(key, _resolve);
@@ -541,26 +2122,30 @@ ResponseCache.prototype.get = function get(...getArgs) {
541
2122
  return originalGet.apply(this, getArgs);
542
2123
  };
543
2124
  console.timeEnd("import next server");
544
- async function getMockedRequestHandlers(...args) {
545
- const tracer = (0, import_tracer.getTracer)();
546
- return tracer.withActiveSpan("mocked request handler", async () => {
2125
+ async function getMockedRequestHandler(...args) {
2126
+ const tracer2 = getTracer();
2127
+ return tracer2.withActiveSpan("mocked request handler", async () => {
547
2128
  const ofs = { ...import_promises.default };
548
- const { encodeBlobKey } = await import("../shared/blobkey.js");
2129
+ const { encodeBlobKey: encodeBlobKey2 } = await Promise.resolve().then(() => (init_blobkey(), blobkey_exports));
549
2130
  async function readFileFallbackBlobStore(...fsargs) {
550
2131
  const [path, options] = fsargs;
551
2132
  try {
552
2133
  return await ofs.readFile(path, options);
553
2134
  } catch (error) {
554
2135
  if (typeof path === "string" && path.endsWith(".html")) {
555
- const store = (0, import_regional_blob_store.getRegionalBlobStore)();
2136
+ const store = getRegionalBlobStore();
556
2137
  const relPath = (0, import_path.relative)((0, import_path.resolve)(".next/server/pages"), path);
557
- const file = await store.get(await encodeBlobKey(relPath));
2138
+ const file = await store.get(await encodeBlobKey2(relPath), {
2139
+ type: "json"
2140
+ });
558
2141
  if (file !== null) {
559
- const requestContext = (0, import_request_context.getRequestContext)();
560
- if (requestContext) {
561
- requestContext.usedFsRead = true;
2142
+ if (!file.isFallback) {
2143
+ const requestContext = getRequestContext();
2144
+ if (requestContext) {
2145
+ requestContext.usedFsReadForNonFallback = true;
2146
+ }
562
2147
  }
563
- return file;
2148
+ return file.html;
564
2149
  }
565
2150
  }
566
2151
  throw error;
@@ -573,10 +2158,11 @@ async function getMockedRequestHandlers(...args) {
573
2158
  // eslint-disable-next-line n/global-require, @typescript-eslint/no-var-requires
574
2159
  require("fs").promises
575
2160
  );
576
- return getRequestHandlers(...args);
2161
+ const requestHandlers = await getRequestHandlers(...args);
2162
+ return Array.isArray(requestHandlers) ? requestHandlers[0] : requestHandlers.requestHandler;
577
2163
  });
578
2164
  }
579
2165
  // Annotate the CommonJS export names for ESM import in node:
580
2166
  0 && (module.exports = {
581
- getMockedRequestHandlers
2167
+ getMockedRequestHandler
582
2168
  });