msw 0.0.0-fetch.rc-19 → 0.0.0-fetch.rc-21

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 (56) hide show
  1. package/README.md +5 -2
  2. package/lib/browser/index.d.ts +21 -8
  3. package/lib/browser/index.js +14 -6
  4. package/lib/browser/index.mjs +14 -6
  5. package/lib/core/{GraphQLHandler-2e60cda6.d.ts → GraphQLHandler-a441dd03.d.ts} +19 -7
  6. package/lib/core/HttpResponse.d.ts +1 -1
  7. package/lib/core/{RequestHandler-e964183f.d.ts → RequestHandler-b59044ae.d.ts} +44 -17
  8. package/lib/core/SetupApi.d.ts +1 -1
  9. package/lib/core/bypass.d.ts +7 -7
  10. package/lib/core/bypass.js +10 -68
  11. package/lib/core/bypass.mjs +10 -68
  12. package/lib/core/delay.d.ts +3 -0
  13. package/lib/core/graphql.d.ts +62 -30
  14. package/lib/core/graphql.js +38 -16
  15. package/lib/core/graphql.mjs +38 -16
  16. package/lib/core/handlers/GraphQLHandler.d.ts +2 -2
  17. package/lib/core/handlers/GraphQLHandler.js +26 -20
  18. package/lib/core/handlers/GraphQLHandler.mjs +26 -20
  19. package/lib/core/handlers/HttpHandler.d.ts +18 -6
  20. package/lib/core/handlers/HttpHandler.js +17 -16
  21. package/lib/core/handlers/HttpHandler.mjs +17 -16
  22. package/lib/core/handlers/RequestHandler.d.ts +1 -1
  23. package/lib/core/handlers/RequestHandler.js +43 -35
  24. package/lib/core/handlers/RequestHandler.mjs +43 -35
  25. package/lib/core/http.d.ts +18 -9
  26. package/lib/core/index.d.ts +2 -2
  27. package/lib/core/passthrough.d.ts +3 -1
  28. package/lib/core/sharedOptions.d.ts +1 -1
  29. package/lib/core/utils/HttpResponse/decorators.d.ts +1 -1
  30. package/lib/core/utils/getResponse.d.ts +1 -1
  31. package/lib/core/utils/getResponse.js +2 -2
  32. package/lib/core/utils/getResponse.mjs +2 -2
  33. package/lib/core/utils/handleRequest.d.ts +1 -1
  34. package/lib/core/utils/internal/parseGraphQLRequest.d.ts +2 -2
  35. package/lib/core/utils/internal/parseMultipartData.d.ts +1 -1
  36. package/lib/core/utils/internal/requestHandlerUtils.d.ts +2 -2
  37. package/lib/core/utils/logging/serializeRequest.d.ts +1 -3
  38. package/lib/core/utils/logging/serializeRequest.js +1 -2
  39. package/lib/core/utils/logging/serializeRequest.mjs +1 -2
  40. package/lib/core/utils/logging/serializeResponse.d.ts +1 -3
  41. package/lib/core/utils/logging/serializeResponse.js +1 -2
  42. package/lib/core/utils/logging/serializeResponse.mjs +1 -2
  43. package/lib/core/utils/request/onUnhandledRequest.d.ts +1 -1
  44. package/lib/core/utils/request/onUnhandledRequest.js +1 -1
  45. package/lib/core/utils/request/onUnhandledRequest.mjs +1 -1
  46. package/lib/core/utils/toResponseInit.js +1 -2
  47. package/lib/core/utils/toResponseInit.mjs +1 -2
  48. package/lib/iife/index.js +2182 -2094
  49. package/lib/mockServiceWorker.js +4 -17
  50. package/lib/native/index.d.ts +20 -7
  51. package/lib/native/index.js +5 -0
  52. package/lib/native/index.mjs +5 -0
  53. package/lib/node/index.d.ts +20 -7
  54. package/lib/node/index.js +5 -0
  55. package/lib/node/index.mjs +5 -0
  56. package/package.json +5 -6
package/lib/iife/index.js CHANGED
@@ -504,20 +504,20 @@ var MockServiceWorker = (() => {
504
504
 
505
505
  // src/core/handlers/RequestHandler.ts
506
506
  var RequestHandler = class {
507
- constructor(options) {
508
- this.resolver = options.resolver;
509
- this.once = options.once || false;
507
+ constructor(args) {
508
+ this.resolver = args.resolver;
509
+ this.options = args.options;
510
510
  const callFrame = getCallFrame(new Error());
511
- this.info = __spreadProps(__spreadValues({}, options.info), {
511
+ this.info = __spreadProps(__spreadValues({}, args.info), {
512
512
  callFrame
513
513
  });
514
514
  this.isUsed = false;
515
515
  }
516
516
  /**
517
- * Parse the captured request to extract additional information from it.
517
+ * Parse the intercepted request to extract additional information from it.
518
518
  * Parsed result is then exposed to other methods of this request handler.
519
519
  */
520
- parse(_request, _resolutionContext) {
520
+ parse(_args) {
521
521
  return __async(this, null, function* () {
522
522
  return {};
523
523
  });
@@ -525,53 +525,61 @@ var MockServiceWorker = (() => {
525
525
  /**
526
526
  * Test if this handler matches the given request.
527
527
  */
528
- test(request, resolutionContext) {
528
+ test(args) {
529
529
  return __async(this, null, function* () {
530
- return this.predicate(
531
- request,
532
- yield this.parse(request.clone(), resolutionContext),
533
- resolutionContext
534
- );
530
+ const parsedResult = yield this.parse({
531
+ request: args.request,
532
+ resolutionContext: args.resolutionContext
533
+ });
534
+ return this.predicate({
535
+ request: args.request,
536
+ parsedResult,
537
+ resolutionContext: args.resolutionContext
538
+ });
535
539
  });
536
540
  }
537
- extendInfo(_request, _parsedResult) {
541
+ extendResolverArgs(_args) {
538
542
  return {};
539
543
  }
540
544
  /**
541
545
  * Execute this request handler and produce a mocked response
542
546
  * using the given resolver function.
543
547
  */
544
- run(request, resolutionContext) {
548
+ run(args) {
545
549
  return __async(this, null, function* () {
546
- if (this.isUsed && this.once) {
550
+ var _a3;
551
+ if (this.isUsed && ((_a3 = this.options) == null ? void 0 : _a3.once)) {
547
552
  return null;
548
553
  }
549
- const mainRequestRef = request.clone();
554
+ const mainRequestRef = args.request.clone();
550
555
  this.isUsed = true;
551
- const parsedResult = yield this.parse(
552
- mainRequestRef.clone(),
553
- resolutionContext
554
- );
555
- const shouldInterceptRequest = this.predicate(
556
- mainRequestRef.clone(),
556
+ const parsedResult = yield this.parse({
557
+ request: args.request,
558
+ resolutionContext: args.resolutionContext
559
+ });
560
+ const shouldInterceptRequest = this.predicate({
561
+ request: args.request,
557
562
  parsedResult,
558
- resolutionContext
559
- );
563
+ resolutionContext: args.resolutionContext
564
+ });
560
565
  if (!shouldInterceptRequest) {
561
566
  return null;
562
567
  }
563
568
  const executeResolver = this.wrapResolver(this.resolver);
564
- const resolverExtras = this.extendInfo(request, parsedResult);
569
+ const resolverExtras = this.extendResolverArgs({
570
+ request: args.request,
571
+ parsedResult
572
+ });
565
573
  const mockedResponse = yield executeResolver(__spreadProps(__spreadValues({}, resolverExtras), {
566
- request
574
+ request: args.request
567
575
  }));
568
- const executionResult = this.createExecutionResult(
576
+ const executionResult = this.createExecutionResult({
569
577
  // Pass the cloned request to the result so that logging
570
578
  // and other consumers could read its body once more.
571
- mainRequestRef,
572
- parsedResult,
573
- mockedResponse
574
- );
579
+ request: mainRequestRef,
580
+ response: mockedResponse,
581
+ parsedResult
582
+ });
575
583
  return executionResult;
576
584
  });
577
585
  }
@@ -603,12 +611,12 @@ var MockServiceWorker = (() => {
603
611
  return result;
604
612
  });
605
613
  }
606
- createExecutionResult(request, parsedResult, response) {
614
+ createExecutionResult(args) {
607
615
  return {
608
616
  handler: this,
609
- parsedResult,
610
- request,
611
- response
617
+ request: args.request,
618
+ response: args.response,
619
+ parsedResult: args.parsedResult
612
620
  };
613
621
  }
614
622
  };
@@ -635,7 +643,21 @@ var MockServiceWorker = (() => {
635
643
  return [now.getHours(), now.getMinutes(), now.getSeconds()].map(String).map((chunk) => chunk.slice(0, 2)).map((chunk) => chunk.padStart(2, "0")).join(":");
636
644
  }
637
645
 
638
- // node_modules/.pnpm/headers-polyfill@3.2.3/node_modules/headers-polyfill/lib/index.mjs
646
+ // src/core/utils/logging/serializeRequest.ts
647
+ function serializeRequest(request) {
648
+ return __async(this, null, function* () {
649
+ const requestClone = request.clone();
650
+ const requestText = yield requestClone.text();
651
+ return {
652
+ url: new URL(request.url),
653
+ method: request.method,
654
+ headers: Object.fromEntries(request.headers.entries()),
655
+ body: requestText
656
+ };
657
+ });
658
+ }
659
+
660
+ // node_modules/.pnpm/@bundled-es-modules+statuses@1.0.1/node_modules/@bundled-es-modules/statuses/index-esm.js
639
661
  var __create = Object.create;
640
662
  var __defProp2 = Object.defineProperty;
641
663
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
@@ -654,1476 +676,1286 @@ var MockServiceWorker = (() => {
654
676
  return to;
655
677
  };
656
678
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps2(
679
+ // If the importer is in node compatibility mode or this is not an ESM
680
+ // file that has been converted to a CommonJS file using a Babel-
681
+ // compatible transform (i.e. "__esModule" has not been set), then set
682
+ // "default" to the CommonJS "module.exports" for node compatibility.
657
683
  isNodeMode || !mod || !mod.__esModule ? __defProp2(target, "default", { value: mod, enumerable: true }) : target,
658
684
  mod
659
685
  ));
660
- var require_set_cookie = __commonJS({
661
- "node_modules/set-cookie-parser/lib/set-cookie.js"(exports, module) {
686
+ var require_codes = __commonJS({
687
+ "node_modules/statuses/codes.json"(exports, module) {
688
+ module.exports = {
689
+ "100": "Continue",
690
+ "101": "Switching Protocols",
691
+ "102": "Processing",
692
+ "103": "Early Hints",
693
+ "200": "OK",
694
+ "201": "Created",
695
+ "202": "Accepted",
696
+ "203": "Non-Authoritative Information",
697
+ "204": "No Content",
698
+ "205": "Reset Content",
699
+ "206": "Partial Content",
700
+ "207": "Multi-Status",
701
+ "208": "Already Reported",
702
+ "226": "IM Used",
703
+ "300": "Multiple Choices",
704
+ "301": "Moved Permanently",
705
+ "302": "Found",
706
+ "303": "See Other",
707
+ "304": "Not Modified",
708
+ "305": "Use Proxy",
709
+ "307": "Temporary Redirect",
710
+ "308": "Permanent Redirect",
711
+ "400": "Bad Request",
712
+ "401": "Unauthorized",
713
+ "402": "Payment Required",
714
+ "403": "Forbidden",
715
+ "404": "Not Found",
716
+ "405": "Method Not Allowed",
717
+ "406": "Not Acceptable",
718
+ "407": "Proxy Authentication Required",
719
+ "408": "Request Timeout",
720
+ "409": "Conflict",
721
+ "410": "Gone",
722
+ "411": "Length Required",
723
+ "412": "Precondition Failed",
724
+ "413": "Payload Too Large",
725
+ "414": "URI Too Long",
726
+ "415": "Unsupported Media Type",
727
+ "416": "Range Not Satisfiable",
728
+ "417": "Expectation Failed",
729
+ "418": "I'm a Teapot",
730
+ "421": "Misdirected Request",
731
+ "422": "Unprocessable Entity",
732
+ "423": "Locked",
733
+ "424": "Failed Dependency",
734
+ "425": "Too Early",
735
+ "426": "Upgrade Required",
736
+ "428": "Precondition Required",
737
+ "429": "Too Many Requests",
738
+ "431": "Request Header Fields Too Large",
739
+ "451": "Unavailable For Legal Reasons",
740
+ "500": "Internal Server Error",
741
+ "501": "Not Implemented",
742
+ "502": "Bad Gateway",
743
+ "503": "Service Unavailable",
744
+ "504": "Gateway Timeout",
745
+ "505": "HTTP Version Not Supported",
746
+ "506": "Variant Also Negotiates",
747
+ "507": "Insufficient Storage",
748
+ "508": "Loop Detected",
749
+ "509": "Bandwidth Limit Exceeded",
750
+ "510": "Not Extended",
751
+ "511": "Network Authentication Required"
752
+ };
753
+ }
754
+ });
755
+ var require_statuses = __commonJS({
756
+ "node_modules/statuses/index.js"(exports, module) {
662
757
  "use strict";
663
- var defaultParseOptions = {
664
- decodeValues: true,
665
- map: false,
666
- silent: false
758
+ var codes = require_codes();
759
+ module.exports = status2;
760
+ status2.message = codes;
761
+ status2.code = createMessageToStatusCodeMap(codes);
762
+ status2.codes = createStatusCodeList(codes);
763
+ status2.redirect = {
764
+ 300: true,
765
+ 301: true,
766
+ 302: true,
767
+ 303: true,
768
+ 305: true,
769
+ 307: true,
770
+ 308: true
667
771
  };
668
- function isNonEmptyString(str) {
669
- return typeof str === "string" && !!str.trim();
772
+ status2.empty = {
773
+ 204: true,
774
+ 205: true,
775
+ 304: true
776
+ };
777
+ status2.retry = {
778
+ 502: true,
779
+ 503: true,
780
+ 504: true
781
+ };
782
+ function createMessageToStatusCodeMap(codes2) {
783
+ var map = {};
784
+ Object.keys(codes2).forEach(function forEachCode(code) {
785
+ var message3 = codes2[code];
786
+ var status3 = Number(code);
787
+ map[message3.toLowerCase()] = status3;
788
+ });
789
+ return map;
670
790
  }
671
- function parseString(setCookieValue, options) {
672
- var parts = setCookieValue.split(";").filter(isNonEmptyString);
673
- var nameValuePairStr = parts.shift();
674
- var parsed = parseNameValuePair(nameValuePairStr);
675
- var name = parsed.name;
676
- var value = parsed.value;
677
- options = options ? Object.assign({}, defaultParseOptions, options) : defaultParseOptions;
678
- try {
679
- value = options.decodeValues ? decodeURIComponent(value) : value;
680
- } catch (e) {
681
- console.error(
682
- "set-cookie-parser encountered an error while decoding a cookie with value '" + value + "'. Set options.decodeValues to false to disable this feature.",
683
- e
684
- );
685
- }
686
- var cookie = {
687
- name,
688
- value
689
- };
690
- parts.forEach(function(part) {
691
- var sides = part.split("=");
692
- var key = sides.shift().trimLeft().toLowerCase();
693
- var value2 = sides.join("=");
694
- if (key === "expires") {
695
- cookie.expires = new Date(value2);
696
- } else if (key === "max-age") {
697
- cookie.maxAge = parseInt(value2, 10);
698
- } else if (key === "secure") {
699
- cookie.secure = true;
700
- } else if (key === "httponly") {
701
- cookie.httpOnly = true;
702
- } else if (key === "samesite") {
703
- cookie.sameSite = value2;
704
- } else {
705
- cookie[key] = value2;
706
- }
791
+ function createStatusCodeList(codes2) {
792
+ return Object.keys(codes2).map(function mapCode(code) {
793
+ return Number(code);
707
794
  });
708
- return cookie;
709
795
  }
710
- function parseNameValuePair(nameValuePairStr) {
711
- var name = "";
712
- var value = "";
713
- var nameValueArr = nameValuePairStr.split("=");
714
- if (nameValueArr.length > 1) {
715
- name = nameValueArr.shift();
716
- value = nameValueArr.join("=");
717
- } else {
718
- value = nameValuePairStr;
796
+ function getStatusCode(message3) {
797
+ var msg = message3.toLowerCase();
798
+ if (!Object.prototype.hasOwnProperty.call(status2.code, msg)) {
799
+ throw new Error('invalid status message: "' + message3 + '"');
719
800
  }
720
- return { name, value };
801
+ return status2.code[msg];
721
802
  }
722
- function parse3(input, options) {
723
- options = options ? Object.assign({}, defaultParseOptions, options) : defaultParseOptions;
724
- if (!input) {
725
- if (!options.map) {
726
- return [];
727
- } else {
728
- return {};
729
- }
803
+ function getStatusMessage(code) {
804
+ if (!Object.prototype.hasOwnProperty.call(status2.message, code)) {
805
+ throw new Error("invalid status code: " + code);
730
806
  }
731
- if (input.headers) {
732
- if (typeof input.headers.getSetCookie === "function") {
733
- input = input.headers.getSetCookie();
734
- } else if (input.headers["set-cookie"]) {
735
- input = input.headers["set-cookie"];
736
- } else {
737
- var sch = input.headers[Object.keys(input.headers).find(function(key) {
738
- return key.toLowerCase() === "set-cookie";
739
- })];
740
- if (!sch && input.headers.cookie && !options.silent) {
741
- console.warn(
742
- "Warning: set-cookie-parser appears to have been called on a request object. It is designed to parse Set-Cookie headers from responses, not Cookie headers from requests. Set the option {silent: true} to suppress this warning."
743
- );
744
- }
745
- input = sch;
746
- }
807
+ return status2.message[code];
808
+ }
809
+ function status2(code) {
810
+ if (typeof code === "number") {
811
+ return getStatusMessage(code);
747
812
  }
748
- if (!Array.isArray(input)) {
749
- input = [input];
813
+ if (typeof code !== "string") {
814
+ throw new TypeError("code must be a number or string");
750
815
  }
751
- options = options ? Object.assign({}, defaultParseOptions, options) : defaultParseOptions;
752
- if (!options.map) {
753
- return input.filter(isNonEmptyString).map(function(str) {
754
- return parseString(str, options);
755
- });
756
- } else {
757
- var cookies = {};
758
- return input.filter(isNonEmptyString).reduce(function(cookies2, str) {
759
- var cookie = parseString(str, options);
760
- cookies2[cookie.name] = cookie;
761
- return cookies2;
762
- }, cookies);
816
+ var n = parseInt(code, 10);
817
+ if (!isNaN(n)) {
818
+ return getStatusMessage(n);
763
819
  }
820
+ return getStatusCode(code);
764
821
  }
765
- function splitCookiesString2(cookiesString) {
766
- if (Array.isArray(cookiesString)) {
767
- return cookiesString;
768
- }
769
- if (typeof cookiesString !== "string") {
770
- return [];
771
- }
772
- var cookiesStrings = [];
773
- var pos = 0;
774
- var start;
775
- var ch;
776
- var lastComma;
777
- var nextStart;
778
- var cookiesSeparatorFound;
779
- function skipWhitespace() {
780
- while (pos < cookiesString.length && /\s/.test(cookiesString.charAt(pos))) {
781
- pos += 1;
822
+ }
823
+ });
824
+ var import_statuses = __toESM(require_statuses(), 1);
825
+ var source_default = import_statuses.default;
826
+
827
+ // src/core/utils/logging/serializeResponse.ts
828
+ var { message } = source_default;
829
+ function serializeResponse(response) {
830
+ return __async(this, null, function* () {
831
+ const responseClone = response.clone();
832
+ const responseText = yield responseClone.text();
833
+ const responseStatus = responseClone.status || 200;
834
+ const responseStatusText = responseClone.statusText || message[responseStatus] || "OK";
835
+ return {
836
+ status: responseStatus,
837
+ statusText: responseStatusText,
838
+ headers: Object.fromEntries(responseClone.headers.entries()),
839
+ body: responseText
840
+ };
841
+ });
842
+ }
843
+
844
+ // node_modules/.pnpm/path-to-regexp@6.2.1/node_modules/path-to-regexp/dist.es2015/index.js
845
+ function lexer(str) {
846
+ var tokens = [];
847
+ var i = 0;
848
+ while (i < str.length) {
849
+ var char = str[i];
850
+ if (char === "*" || char === "+" || char === "?") {
851
+ tokens.push({ type: "MODIFIER", index: i, value: str[i++] });
852
+ continue;
853
+ }
854
+ if (char === "\\") {
855
+ tokens.push({ type: "ESCAPED_CHAR", index: i++, value: str[i++] });
856
+ continue;
857
+ }
858
+ if (char === "{") {
859
+ tokens.push({ type: "OPEN", index: i, value: str[i++] });
860
+ continue;
861
+ }
862
+ if (char === "}") {
863
+ tokens.push({ type: "CLOSE", index: i, value: str[i++] });
864
+ continue;
865
+ }
866
+ if (char === ":") {
867
+ var name = "";
868
+ var j = i + 1;
869
+ while (j < str.length) {
870
+ var code = str.charCodeAt(j);
871
+ if (
872
+ // `0-9`
873
+ code >= 48 && code <= 57 || // `A-Z`
874
+ code >= 65 && code <= 90 || // `a-z`
875
+ code >= 97 && code <= 122 || // `_`
876
+ code === 95
877
+ ) {
878
+ name += str[j++];
879
+ continue;
782
880
  }
783
- return pos < cookiesString.length;
881
+ break;
784
882
  }
785
- function notSpecialChar() {
786
- ch = cookiesString.charAt(pos);
787
- return ch !== "=" && ch !== ";" && ch !== ",";
883
+ if (!name)
884
+ throw new TypeError("Missing parameter name at ".concat(i));
885
+ tokens.push({ type: "NAME", index: i, value: name });
886
+ i = j;
887
+ continue;
888
+ }
889
+ if (char === "(") {
890
+ var count = 1;
891
+ var pattern = "";
892
+ var j = i + 1;
893
+ if (str[j] === "?") {
894
+ throw new TypeError('Pattern cannot start with "?" at '.concat(j));
788
895
  }
789
- while (pos < cookiesString.length) {
790
- start = pos;
791
- cookiesSeparatorFound = false;
792
- while (skipWhitespace()) {
793
- ch = cookiesString.charAt(pos);
794
- if (ch === ",") {
795
- lastComma = pos;
796
- pos += 1;
797
- skipWhitespace();
798
- nextStart = pos;
799
- while (pos < cookiesString.length && notSpecialChar()) {
800
- pos += 1;
801
- }
802
- if (pos < cookiesString.length && cookiesString.charAt(pos) === "=") {
803
- cookiesSeparatorFound = true;
804
- pos = nextStart;
805
- cookiesStrings.push(cookiesString.substring(start, lastComma));
806
- start = pos;
807
- } else {
808
- pos = lastComma + 1;
809
- }
810
- } else {
811
- pos += 1;
812
- }
896
+ while (j < str.length) {
897
+ if (str[j] === "\\") {
898
+ pattern += str[j++] + str[j++];
899
+ continue;
813
900
  }
814
- if (!cookiesSeparatorFound || pos >= cookiesString.length) {
815
- cookiesStrings.push(cookiesString.substring(start, cookiesString.length));
901
+ if (str[j] === ")") {
902
+ count--;
903
+ if (count === 0) {
904
+ j++;
905
+ break;
906
+ }
907
+ } else if (str[j] === "(") {
908
+ count++;
909
+ if (str[j + 1] !== "?") {
910
+ throw new TypeError("Capturing groups are not allowed at ".concat(j));
911
+ }
816
912
  }
913
+ pattern += str[j++];
817
914
  }
818
- return cookiesStrings;
915
+ if (count)
916
+ throw new TypeError("Unbalanced pattern at ".concat(i));
917
+ if (!pattern)
918
+ throw new TypeError("Missing pattern at ".concat(i));
919
+ tokens.push({ type: "PATTERN", index: i, value: pattern });
920
+ i = j;
921
+ continue;
819
922
  }
820
- module.exports = parse3;
821
- module.exports.parse = parse3;
822
- module.exports.parseString = parseString;
823
- module.exports.splitCookiesString = splitCookiesString2;
824
- }
825
- });
826
- var import_set_cookie_parser = __toESM(require_set_cookie());
827
- var HEADERS_INVALID_CHARACTERS = /[^a-z0-9\-#$%&'*+.^_`|~]/i;
828
- function normalizeHeaderName(name) {
829
- if (typeof name !== "string") {
830
- name = String(name);
831
- }
832
- if (HEADERS_INVALID_CHARACTERS.test(name) || name.trim() === "") {
833
- throw new TypeError("Invalid character in header field name");
923
+ tokens.push({ type: "CHAR", index: i, value: str[i++] });
834
924
  }
835
- return name.toLowerCase();
925
+ tokens.push({ type: "END", index: i, value: "" });
926
+ return tokens;
836
927
  }
837
- function normalizeHeaderValue(value) {
838
- if (typeof value !== "string") {
839
- value = String(value);
928
+ function parse(str, options) {
929
+ if (options === void 0) {
930
+ options = {};
840
931
  }
841
- return value;
842
- }
843
- var NORMALIZED_HEADERS = Symbol("normalizedHeaders");
844
- var RAW_HEADER_NAMES = Symbol("rawHeaderNames");
845
- var HEADER_VALUE_DELIMITER = ", ";
846
- var _a;
847
- var _b;
848
- var HeadersPolyfill = class {
849
- constructor(init) {
850
- this[_a] = {};
851
- this[_b] = /* @__PURE__ */ new Map();
852
- if (["Headers", "HeadersPolyfill"].includes(init == null ? void 0 : init.constructor.name) || init instanceof HeadersPolyfill) {
853
- const initialHeaders = init;
854
- initialHeaders.forEach((value, name) => {
855
- this.append(name, value);
856
- }, this);
857
- } else if (Array.isArray(init)) {
858
- init.forEach(([name, value]) => {
859
- this.append(
860
- name,
861
- Array.isArray(value) ? value.join(HEADER_VALUE_DELIMITER) : value
862
- );
863
- });
864
- } else if (init) {
865
- Object.getOwnPropertyNames(init).forEach((name) => {
866
- const value = init[name];
867
- this.append(
868
- name,
869
- Array.isArray(value) ? value.join(HEADER_VALUE_DELIMITER) : value
870
- );
871
- });
932
+ var tokens = lexer(str);
933
+ var _a3 = options.prefixes, prefixes = _a3 === void 0 ? "./" : _a3;
934
+ var defaultPattern = "[^".concat(escapeString(options.delimiter || "/#?"), "]+?");
935
+ var result = [];
936
+ var key = 0;
937
+ var i = 0;
938
+ var path = "";
939
+ var tryConsume = function(type) {
940
+ if (i < tokens.length && tokens[i].type === type)
941
+ return tokens[i++].value;
942
+ };
943
+ var mustConsume = function(type) {
944
+ var value2 = tryConsume(type);
945
+ if (value2 !== void 0)
946
+ return value2;
947
+ var _a4 = tokens[i], nextType = _a4.type, index = _a4.index;
948
+ throw new TypeError("Unexpected ".concat(nextType, " at ").concat(index, ", expected ").concat(type));
949
+ };
950
+ var consumeText = function() {
951
+ var result2 = "";
952
+ var value2;
953
+ while (value2 = tryConsume("CHAR") || tryConsume("ESCAPED_CHAR")) {
954
+ result2 += value2;
872
955
  }
873
- }
874
- [(_a = NORMALIZED_HEADERS, _b = RAW_HEADER_NAMES, Symbol.iterator)]() {
875
- return this.entries();
876
- }
877
- *keys() {
878
- for (const name of Object.keys(this[NORMALIZED_HEADERS])) {
879
- yield name;
956
+ return result2;
957
+ };
958
+ while (i < tokens.length) {
959
+ var char = tryConsume("CHAR");
960
+ var name = tryConsume("NAME");
961
+ var pattern = tryConsume("PATTERN");
962
+ if (name || pattern) {
963
+ var prefix = char || "";
964
+ if (prefixes.indexOf(prefix) === -1) {
965
+ path += prefix;
966
+ prefix = "";
967
+ }
968
+ if (path) {
969
+ result.push(path);
970
+ path = "";
971
+ }
972
+ result.push({
973
+ name: name || key++,
974
+ prefix,
975
+ suffix: "",
976
+ pattern: pattern || defaultPattern,
977
+ modifier: tryConsume("MODIFIER") || ""
978
+ });
979
+ continue;
880
980
  }
881
- }
882
- *values() {
883
- for (const value of Object.values(this[NORMALIZED_HEADERS])) {
884
- yield value;
981
+ var value = char || tryConsume("ESCAPED_CHAR");
982
+ if (value) {
983
+ path += value;
984
+ continue;
885
985
  }
886
- }
887
- *entries() {
888
- for (const name of Object.keys(this[NORMALIZED_HEADERS])) {
889
- yield [name, this.get(name)];
986
+ if (path) {
987
+ result.push(path);
988
+ path = "";
890
989
  }
891
- }
892
- get(name) {
893
- var _a3;
894
- return (_a3 = this[NORMALIZED_HEADERS][normalizeHeaderName(name)]) != null ? _a3 : null;
895
- }
896
- set(name, value) {
897
- const normalizedName = normalizeHeaderName(name);
898
- this[NORMALIZED_HEADERS][normalizedName] = normalizeHeaderValue(value);
899
- this[RAW_HEADER_NAMES].set(normalizedName, name);
900
- }
901
- append(name, value) {
902
- const normalizedName = normalizeHeaderName(name);
903
- let resolvedValue = this.has(normalizedName) ? `${this.get(normalizedName)}, ${value}` : value;
904
- this.set(name, resolvedValue);
905
- }
906
- delete(name) {
907
- if (!this.has(name)) {
908
- return;
990
+ var open = tryConsume("OPEN");
991
+ if (open) {
992
+ var prefix = consumeText();
993
+ var name_1 = tryConsume("NAME") || "";
994
+ var pattern_1 = tryConsume("PATTERN") || "";
995
+ var suffix = consumeText();
996
+ mustConsume("CLOSE");
997
+ result.push({
998
+ name: name_1 || (pattern_1 ? key++ : ""),
999
+ pattern: name_1 && !pattern_1 ? defaultPattern : pattern_1,
1000
+ prefix,
1001
+ suffix,
1002
+ modifier: tryConsume("MODIFIER") || ""
1003
+ });
1004
+ continue;
909
1005
  }
910
- const normalizedName = normalizeHeaderName(name);
911
- delete this[NORMALIZED_HEADERS][normalizedName];
912
- this[RAW_HEADER_NAMES].delete(normalizedName);
1006
+ mustConsume("END");
913
1007
  }
914
- all() {
915
- return this[NORMALIZED_HEADERS];
1008
+ return result;
1009
+ }
1010
+ function match(str, options) {
1011
+ var keys = [];
1012
+ var re = pathToRegexp(str, keys, options);
1013
+ return regexpToFunction(re, keys, options);
1014
+ }
1015
+ function regexpToFunction(re, keys, options) {
1016
+ if (options === void 0) {
1017
+ options = {};
916
1018
  }
917
- raw() {
918
- const rawHeaders = {};
919
- for (const [name, value] of this.entries()) {
920
- rawHeaders[this[RAW_HEADER_NAMES].get(name)] = value;
1019
+ var _a3 = options.decode, decode = _a3 === void 0 ? function(x) {
1020
+ return x;
1021
+ } : _a3;
1022
+ return function(pathname) {
1023
+ var m = re.exec(pathname);
1024
+ if (!m)
1025
+ return false;
1026
+ var path = m[0], index = m.index;
1027
+ var params = /* @__PURE__ */ Object.create(null);
1028
+ var _loop_1 = function(i2) {
1029
+ if (m[i2] === void 0)
1030
+ return "continue";
1031
+ var key = keys[i2 - 1];
1032
+ if (key.modifier === "*" || key.modifier === "+") {
1033
+ params[key.name] = m[i2].split(key.prefix + key.suffix).map(function(value) {
1034
+ return decode(value, key);
1035
+ });
1036
+ } else {
1037
+ params[key.name] = decode(m[i2], key);
1038
+ }
1039
+ };
1040
+ for (var i = 1; i < m.length; i++) {
1041
+ _loop_1(i);
921
1042
  }
922
- return rawHeaders;
1043
+ return { path, index, params };
1044
+ };
1045
+ }
1046
+ function escapeString(str) {
1047
+ return str.replace(/([.+*?=^!:${}()[\]|/\\])/g, "\\$1");
1048
+ }
1049
+ function flags(options) {
1050
+ return options && options.sensitive ? "" : "i";
1051
+ }
1052
+ function regexpToRegexp(path, keys) {
1053
+ if (!keys)
1054
+ return path;
1055
+ var groupsRegex = /\((?:\?<(.*?)>)?(?!\?)/g;
1056
+ var index = 0;
1057
+ var execResult = groupsRegex.exec(path.source);
1058
+ while (execResult) {
1059
+ keys.push({
1060
+ // Use parenthesized substring match if available, index otherwise
1061
+ name: execResult[1] || index++,
1062
+ prefix: "",
1063
+ suffix: "",
1064
+ modifier: "",
1065
+ pattern: ""
1066
+ });
1067
+ execResult = groupsRegex.exec(path.source);
923
1068
  }
924
- has(name) {
925
- return this[NORMALIZED_HEADERS].hasOwnProperty(normalizeHeaderName(name));
1069
+ return path;
1070
+ }
1071
+ function arrayToRegexp(paths, keys, options) {
1072
+ var parts = paths.map(function(path) {
1073
+ return pathToRegexp(path, keys, options).source;
1074
+ });
1075
+ return new RegExp("(?:".concat(parts.join("|"), ")"), flags(options));
1076
+ }
1077
+ function stringToRegexp(path, keys, options) {
1078
+ return tokensToRegexp(parse(path, options), keys, options);
1079
+ }
1080
+ function tokensToRegexp(tokens, keys, options) {
1081
+ if (options === void 0) {
1082
+ options = {};
926
1083
  }
927
- forEach(callback, thisArg) {
928
- for (const name in this[NORMALIZED_HEADERS]) {
929
- if (this[NORMALIZED_HEADERS].hasOwnProperty(name)) {
930
- callback.call(thisArg, this[NORMALIZED_HEADERS][name], name, this);
1084
+ var _a3 = options.strict, strict = _a3 === void 0 ? false : _a3, _b2 = options.start, start = _b2 === void 0 ? true : _b2, _c = options.end, end = _c === void 0 ? true : _c, _d = options.encode, encode = _d === void 0 ? function(x) {
1085
+ return x;
1086
+ } : _d, _e = options.delimiter, delimiter = _e === void 0 ? "/#?" : _e, _f = options.endsWith, endsWith = _f === void 0 ? "" : _f;
1087
+ var endsWithRe = "[".concat(escapeString(endsWith), "]|$");
1088
+ var delimiterRe = "[".concat(escapeString(delimiter), "]");
1089
+ var route = start ? "^" : "";
1090
+ for (var _i = 0, tokens_1 = tokens; _i < tokens_1.length; _i++) {
1091
+ var token = tokens_1[_i];
1092
+ if (typeof token === "string") {
1093
+ route += escapeString(encode(token));
1094
+ } else {
1095
+ var prefix = escapeString(encode(token.prefix));
1096
+ var suffix = escapeString(encode(token.suffix));
1097
+ if (token.pattern) {
1098
+ if (keys)
1099
+ keys.push(token);
1100
+ if (prefix || suffix) {
1101
+ if (token.modifier === "+" || token.modifier === "*") {
1102
+ var mod = token.modifier === "*" ? "?" : "";
1103
+ route += "(?:".concat(prefix, "((?:").concat(token.pattern, ")(?:").concat(suffix).concat(prefix, "(?:").concat(token.pattern, "))*)").concat(suffix, ")").concat(mod);
1104
+ } else {
1105
+ route += "(?:".concat(prefix, "(").concat(token.pattern, ")").concat(suffix, ")").concat(token.modifier);
1106
+ }
1107
+ } else {
1108
+ if (token.modifier === "+" || token.modifier === "*") {
1109
+ route += "((?:".concat(token.pattern, ")").concat(token.modifier, ")");
1110
+ } else {
1111
+ route += "(".concat(token.pattern, ")").concat(token.modifier);
1112
+ }
1113
+ }
1114
+ } else {
1115
+ route += "(?:".concat(prefix).concat(suffix, ")").concat(token.modifier);
931
1116
  }
932
1117
  }
933
1118
  }
934
- getSetCookie() {
935
- const setCookieHeader = this.get("set-cookie");
936
- if (setCookieHeader === null) {
937
- return [];
1119
+ if (end) {
1120
+ if (!strict)
1121
+ route += "".concat(delimiterRe, "?");
1122
+ route += !options.endsWith ? "$" : "(?=".concat(endsWithRe, ")");
1123
+ } else {
1124
+ var endToken = tokens[tokens.length - 1];
1125
+ var isEndDelimited = typeof endToken === "string" ? delimiterRe.indexOf(endToken[endToken.length - 1]) > -1 : endToken === void 0;
1126
+ if (!strict) {
1127
+ route += "(?:".concat(delimiterRe, "(?=").concat(endsWithRe, "))?");
938
1128
  }
939
- if (setCookieHeader === "") {
940
- return [""];
1129
+ if (!isEndDelimited) {
1130
+ route += "(?=".concat(delimiterRe, "|").concat(endsWithRe, ")");
941
1131
  }
942
- return (0, import_set_cookie_parser.splitCookiesString)(setCookieHeader);
943
1132
  }
944
- };
945
- var singleValueHeaders = ["user-agent"];
946
- function headersToObject(headers) {
947
- const headersObject = {};
948
- headers.forEach((value, name) => {
949
- const isMultiValue = !singleValueHeaders.includes(name.toLowerCase()) && value.includes(",");
950
- headersObject[name] = isMultiValue ? value.split(",").map((s) => s.trim()) : value;
951
- });
952
- return headersObject;
1133
+ return new RegExp(route, flags(options));
953
1134
  }
954
- function stringToHeaders(str) {
955
- const lines = str.trim().split(/[\r\n]+/);
956
- return lines.reduce((headers, line) => {
957
- if (line.trim() === "") {
958
- return headers;
959
- }
960
- const parts = line.split(": ");
961
- const name = parts.shift();
962
- const value = parts.join(": ");
963
- headers.append(name, value);
964
- return headers;
965
- }, new HeadersPolyfill());
966
- }
967
- function reduceHeadersObject(headers, reducer, initialState) {
968
- return Object.keys(headers).reduce((nextHeaders, name) => {
969
- return reducer(nextHeaders, name, headers[name]);
970
- }, initialState);
971
- }
972
- function flattenHeadersObject(headersObject) {
973
- return reduceHeadersObject(
974
- headersObject,
975
- (headers, name, value) => {
976
- headers[name] = [].concat(value).join(", ");
977
- return headers;
978
- },
979
- {}
980
- );
1135
+ function pathToRegexp(path, keys, options) {
1136
+ if (path instanceof RegExp)
1137
+ return regexpToRegexp(path, keys);
1138
+ if (Array.isArray(path))
1139
+ return arrayToRegexp(path, keys, options);
1140
+ return stringToRegexp(path, keys, options);
981
1141
  }
982
1142
 
983
- // src/core/utils/logging/serializeRequest.ts
984
- function serializeRequest(request) {
985
- return __async(this, null, function* () {
986
- const requestClone = request.clone();
987
- const requestText = yield requestClone.text();
988
- return {
989
- url: new URL(request.url),
990
- method: request.method,
991
- headers: headersToObject(request.headers),
992
- body: requestText
993
- };
994
- });
1143
+ // node_modules/.pnpm/is-node-process@1.2.0/node_modules/is-node-process/lib/index.mjs
1144
+ function isNodeProcess() {
1145
+ if (typeof navigator !== "undefined" && navigator.product === "ReactNative") {
1146
+ return true;
1147
+ }
1148
+ if (typeof process !== "undefined") {
1149
+ const type = process.type;
1150
+ if (type === "renderer" || type === "worker") {
1151
+ return false;
1152
+ }
1153
+ return !!(process.versions && process.versions.node);
1154
+ }
1155
+ return false;
995
1156
  }
996
1157
 
997
- // node_modules/.pnpm/@bundled-es-modules+statuses@1.0.1/node_modules/@bundled-es-modules/statuses/index-esm.js
998
- var __create2 = Object.create;
1158
+ // node_modules/.pnpm/@open-draft+logger@0.3.0/node_modules/@open-draft/logger/lib/index.mjs
999
1159
  var __defProp3 = Object.defineProperty;
1000
- var __getOwnPropDesc3 = Object.getOwnPropertyDescriptor;
1001
- var __getOwnPropNames3 = Object.getOwnPropertyNames;
1002
- var __getProtoOf2 = Object.getPrototypeOf;
1003
- var __hasOwnProp3 = Object.prototype.hasOwnProperty;
1004
- var __commonJS2 = (cb, mod) => function __require() {
1005
- return mod || (0, cb[__getOwnPropNames3(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
1006
- };
1007
- var __copyProps3 = (to, from, except, desc) => {
1008
- if (from && typeof from === "object" || typeof from === "function") {
1009
- for (let key of __getOwnPropNames3(from))
1010
- if (!__hasOwnProp3.call(to, key) && key !== except)
1011
- __defProp3(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc3(from, key)) || desc.enumerable });
1012
- }
1013
- return to;
1160
+ var __export2 = (target, all) => {
1161
+ for (var name in all)
1162
+ __defProp3(target, name, { get: all[name], enumerable: true });
1014
1163
  };
1015
- var __toESM2 = (mod, isNodeMode, target) => (target = mod != null ? __create2(__getProtoOf2(mod)) : {}, __copyProps3(
1016
- // If the importer is in node compatibility mode or this is not an ESM
1017
- // file that has been converted to a CommonJS file using a Babel-
1018
- // compatible transform (i.e. "__esModule" has not been set), then set
1019
- // "default" to the CommonJS "module.exports" for node compatibility.
1020
- isNodeMode || !mod || !mod.__esModule ? __defProp3(target, "default", { value: mod, enumerable: true }) : target,
1021
- mod
1022
- ));
1023
- var require_codes = __commonJS2({
1024
- "node_modules/statuses/codes.json"(exports, module) {
1025
- module.exports = {
1026
- "100": "Continue",
1027
- "101": "Switching Protocols",
1028
- "102": "Processing",
1029
- "103": "Early Hints",
1030
- "200": "OK",
1031
- "201": "Created",
1032
- "202": "Accepted",
1033
- "203": "Non-Authoritative Information",
1034
- "204": "No Content",
1035
- "205": "Reset Content",
1036
- "206": "Partial Content",
1037
- "207": "Multi-Status",
1038
- "208": "Already Reported",
1039
- "226": "IM Used",
1040
- "300": "Multiple Choices",
1041
- "301": "Moved Permanently",
1042
- "302": "Found",
1043
- "303": "See Other",
1044
- "304": "Not Modified",
1045
- "305": "Use Proxy",
1046
- "307": "Temporary Redirect",
1047
- "308": "Permanent Redirect",
1048
- "400": "Bad Request",
1049
- "401": "Unauthorized",
1050
- "402": "Payment Required",
1051
- "403": "Forbidden",
1052
- "404": "Not Found",
1053
- "405": "Method Not Allowed",
1054
- "406": "Not Acceptable",
1055
- "407": "Proxy Authentication Required",
1056
- "408": "Request Timeout",
1057
- "409": "Conflict",
1058
- "410": "Gone",
1059
- "411": "Length Required",
1060
- "412": "Precondition Failed",
1061
- "413": "Payload Too Large",
1062
- "414": "URI Too Long",
1063
- "415": "Unsupported Media Type",
1064
- "416": "Range Not Satisfiable",
1065
- "417": "Expectation Failed",
1066
- "418": "I'm a Teapot",
1067
- "421": "Misdirected Request",
1068
- "422": "Unprocessable Entity",
1069
- "423": "Locked",
1070
- "424": "Failed Dependency",
1071
- "425": "Too Early",
1072
- "426": "Upgrade Required",
1073
- "428": "Precondition Required",
1074
- "429": "Too Many Requests",
1075
- "431": "Request Header Fields Too Large",
1076
- "451": "Unavailable For Legal Reasons",
1077
- "500": "Internal Server Error",
1078
- "501": "Not Implemented",
1079
- "502": "Bad Gateway",
1080
- "503": "Service Unavailable",
1081
- "504": "Gateway Timeout",
1082
- "505": "HTTP Version Not Supported",
1083
- "506": "Variant Also Negotiates",
1084
- "507": "Insufficient Storage",
1085
- "508": "Loop Detected",
1086
- "509": "Bandwidth Limit Exceeded",
1087
- "510": "Not Extended",
1088
- "511": "Network Authentication Required"
1089
- };
1090
- }
1164
+ var colors_exports = {};
1165
+ __export2(colors_exports, {
1166
+ blue: () => blue,
1167
+ gray: () => gray,
1168
+ green: () => green,
1169
+ red: () => red,
1170
+ yellow: () => yellow
1091
1171
  });
1092
- var require_statuses = __commonJS2({
1093
- "node_modules/statuses/index.js"(exports, module) {
1094
- "use strict";
1095
- var codes = require_codes();
1096
- module.exports = status2;
1097
- status2.message = codes;
1098
- status2.code = createMessageToStatusCodeMap(codes);
1099
- status2.codes = createStatusCodeList(codes);
1100
- status2.redirect = {
1101
- 300: true,
1102
- 301: true,
1103
- 302: true,
1104
- 303: true,
1105
- 305: true,
1106
- 307: true,
1107
- 308: true
1108
- };
1109
- status2.empty = {
1110
- 204: true,
1111
- 205: true,
1112
- 304: true
1113
- };
1114
- status2.retry = {
1115
- 502: true,
1116
- 503: true,
1117
- 504: true
1118
- };
1119
- function createMessageToStatusCodeMap(codes2) {
1120
- var map = {};
1121
- Object.keys(codes2).forEach(function forEachCode(code) {
1122
- var message3 = codes2[code];
1123
- var status3 = Number(code);
1124
- map[message3.toLowerCase()] = status3;
1125
- });
1126
- return map;
1127
- }
1128
- function createStatusCodeList(codes2) {
1129
- return Object.keys(codes2).map(function mapCode(code) {
1130
- return Number(code);
1131
- });
1172
+ function yellow(text) {
1173
+ return `\x1B[33m${text}\x1B[0m`;
1174
+ }
1175
+ function blue(text) {
1176
+ return `\x1B[34m${text}\x1B[0m`;
1177
+ }
1178
+ function gray(text) {
1179
+ return `\x1B[90m${text}\x1B[0m`;
1180
+ }
1181
+ function red(text) {
1182
+ return `\x1B[31m${text}\x1B[0m`;
1183
+ }
1184
+ function green(text) {
1185
+ return `\x1B[32m${text}\x1B[0m`;
1186
+ }
1187
+ var IS_NODE = isNodeProcess();
1188
+ var Logger = class {
1189
+ constructor(name) {
1190
+ __publicField(this, "prefix");
1191
+ this.name = name;
1192
+ this.prefix = `[${this.name}]`;
1193
+ const LOGGER_NAME = getVariable("DEBUG");
1194
+ const LOGGER_LEVEL = getVariable("LOG_LEVEL");
1195
+ const isLoggingEnabled = LOGGER_NAME === "1" || LOGGER_NAME === "true" || typeof LOGGER_NAME !== "undefined" && this.name.startsWith(LOGGER_NAME);
1196
+ if (isLoggingEnabled) {
1197
+ this.debug = isDefinedAndNotEquals(LOGGER_LEVEL, "debug") ? noop : this.debug;
1198
+ this.info = isDefinedAndNotEquals(LOGGER_LEVEL, "info") ? noop : this.info;
1199
+ this.success = isDefinedAndNotEquals(LOGGER_LEVEL, "success") ? noop : this.success;
1200
+ this.warning = isDefinedAndNotEquals(LOGGER_LEVEL, "warning") ? noop : this.warning;
1201
+ this.error = isDefinedAndNotEquals(LOGGER_LEVEL, "error") ? noop : this.error;
1202
+ } else {
1203
+ this.info = noop;
1204
+ this.success = noop;
1205
+ this.warning = noop;
1206
+ this.error = noop;
1207
+ this.only = noop;
1132
1208
  }
1133
- function getStatusCode(message3) {
1134
- var msg = message3.toLowerCase();
1135
- if (!Object.prototype.hasOwnProperty.call(status2.code, msg)) {
1136
- throw new Error('invalid status message: "' + message3 + '"');
1209
+ }
1210
+ extend(domain) {
1211
+ return new Logger(`${this.name}:${domain}`);
1212
+ }
1213
+ /**
1214
+ * Print a debug message.
1215
+ * @example
1216
+ * logger.debug('no duplicates found, creating a document...')
1217
+ */
1218
+ debug(message3, ...positionals) {
1219
+ this.logEntry({
1220
+ level: "debug",
1221
+ message: gray(message3),
1222
+ positionals,
1223
+ prefix: this.prefix,
1224
+ colors: {
1225
+ prefix: "gray"
1137
1226
  }
1138
- return status2.code[msg];
1139
- }
1140
- function getStatusMessage(code) {
1141
- if (!Object.prototype.hasOwnProperty.call(status2.message, code)) {
1142
- throw new Error("invalid status code: " + code);
1227
+ });
1228
+ }
1229
+ /**
1230
+ * Print an info message.
1231
+ * @example
1232
+ * logger.info('start parsing...')
1233
+ */
1234
+ info(message3, ...positionals) {
1235
+ this.logEntry({
1236
+ level: "info",
1237
+ message: message3,
1238
+ positionals,
1239
+ prefix: this.prefix,
1240
+ colors: {
1241
+ prefix: "blue"
1143
1242
  }
1144
- return status2.message[code];
1145
- }
1146
- function status2(code) {
1147
- if (typeof code === "number") {
1148
- return getStatusMessage(code);
1243
+ });
1244
+ const performance2 = new PerformanceEntry();
1245
+ return (message22, ...positionals2) => {
1246
+ performance2.measure();
1247
+ this.logEntry({
1248
+ level: "info",
1249
+ message: `${message22} ${gray(`${performance2.deltaTime}ms`)}`,
1250
+ positionals: positionals2,
1251
+ prefix: this.prefix,
1252
+ colors: {
1253
+ prefix: "blue"
1254
+ }
1255
+ });
1256
+ };
1257
+ }
1258
+ /**
1259
+ * Print a success message.
1260
+ * @example
1261
+ * logger.success('successfully created document')
1262
+ */
1263
+ success(message3, ...positionals) {
1264
+ this.logEntry({
1265
+ level: "info",
1266
+ message: message3,
1267
+ positionals,
1268
+ prefix: `\u2714 ${this.prefix}`,
1269
+ colors: {
1270
+ timestamp: "green",
1271
+ prefix: "green"
1149
1272
  }
1150
- if (typeof code !== "string") {
1151
- throw new TypeError("code must be a number or string");
1273
+ });
1274
+ }
1275
+ /**
1276
+ * Print a warning.
1277
+ * @example
1278
+ * logger.warning('found legacy document format')
1279
+ */
1280
+ warning(message3, ...positionals) {
1281
+ this.logEntry({
1282
+ level: "warning",
1283
+ message: message3,
1284
+ positionals,
1285
+ prefix: `\u26A0 ${this.prefix}`,
1286
+ colors: {
1287
+ timestamp: "yellow",
1288
+ prefix: "yellow"
1152
1289
  }
1153
- var n = parseInt(code, 10);
1154
- if (!isNaN(n)) {
1155
- return getStatusMessage(n);
1290
+ });
1291
+ }
1292
+ /**
1293
+ * Print an error message.
1294
+ * @example
1295
+ * logger.error('something went wrong')
1296
+ */
1297
+ error(message3, ...positionals) {
1298
+ this.logEntry({
1299
+ level: "error",
1300
+ message: message3,
1301
+ positionals,
1302
+ prefix: `\u2716 ${this.prefix}`,
1303
+ colors: {
1304
+ timestamp: "red",
1305
+ prefix: "red"
1156
1306
  }
1157
- return getStatusCode(code);
1158
- }
1307
+ });
1159
1308
  }
1160
- });
1161
- var import_statuses = __toESM2(require_statuses(), 1);
1162
- var source_default = import_statuses.default;
1163
-
1164
- // src/core/utils/logging/serializeResponse.ts
1165
- var { message } = source_default;
1166
- function serializeResponse(response) {
1167
- return __async(this, null, function* () {
1168
- const responseClone = response.clone();
1169
- const responseText = yield responseClone.text();
1170
- const responseStatus = responseClone.status || 200;
1171
- const responseStatusText = responseClone.statusText || message[responseStatus] || "OK";
1309
+ /**
1310
+ * Execute the given callback only when the logging is enabled.
1311
+ * This is skipped in its entirety and has no runtime cost otherwise.
1312
+ * This executes regardless of the log level.
1313
+ * @example
1314
+ * logger.only(() => {
1315
+ * logger.info('additional info')
1316
+ * })
1317
+ */
1318
+ only(callback) {
1319
+ callback();
1320
+ }
1321
+ createEntry(level, message3) {
1172
1322
  return {
1173
- status: responseStatus,
1174
- statusText: responseStatusText,
1175
- headers: headersToObject(responseClone.headers),
1176
- body: responseText
1323
+ timestamp: /* @__PURE__ */ new Date(),
1324
+ level,
1325
+ message: message3
1177
1326
  };
1178
- });
1179
- }
1180
-
1181
- // node_modules/.pnpm/path-to-regexp@6.2.1/node_modules/path-to-regexp/dist.es2015/index.js
1182
- function lexer(str) {
1183
- var tokens = [];
1184
- var i = 0;
1185
- while (i < str.length) {
1186
- var char = str[i];
1187
- if (char === "*" || char === "+" || char === "?") {
1188
- tokens.push({ type: "MODIFIER", index: i, value: str[i++] });
1189
- continue;
1190
- }
1191
- if (char === "\\") {
1192
- tokens.push({ type: "ESCAPED_CHAR", index: i++, value: str[i++] });
1193
- continue;
1194
- }
1195
- if (char === "{") {
1196
- tokens.push({ type: "OPEN", index: i, value: str[i++] });
1197
- continue;
1198
- }
1199
- if (char === "}") {
1200
- tokens.push({ type: "CLOSE", index: i, value: str[i++] });
1201
- continue;
1202
- }
1203
- if (char === ":") {
1204
- var name = "";
1205
- var j = i + 1;
1206
- while (j < str.length) {
1207
- var code = str.charCodeAt(j);
1208
- if (
1209
- // `0-9`
1210
- code >= 48 && code <= 57 || // `A-Z`
1211
- code >= 65 && code <= 90 || // `a-z`
1212
- code >= 97 && code <= 122 || // `_`
1213
- code === 95
1214
- ) {
1215
- name += str[j++];
1216
- continue;
1217
- }
1218
- break;
1327
+ }
1328
+ logEntry(args) {
1329
+ const {
1330
+ level,
1331
+ message: message3,
1332
+ prefix,
1333
+ colors: customColors,
1334
+ positionals = []
1335
+ } = args;
1336
+ const entry = this.createEntry(level, message3);
1337
+ const timestampColor = (customColors == null ? void 0 : customColors.timestamp) || "gray";
1338
+ const prefixColor = (customColors == null ? void 0 : customColors.prefix) || "gray";
1339
+ const colorize = {
1340
+ timestamp: colors_exports[timestampColor],
1341
+ prefix: colors_exports[prefixColor]
1342
+ };
1343
+ const write = this.getWriter(level);
1344
+ write(
1345
+ [colorize.timestamp(this.formatTimestamp(entry.timestamp))].concat(prefix != null ? colorize.prefix(prefix) : []).concat(serializeInput(message3)).join(" "),
1346
+ ...positionals.map(serializeInput)
1347
+ );
1348
+ }
1349
+ formatTimestamp(timestamp) {
1350
+ return `${timestamp.toLocaleTimeString(
1351
+ "en-GB"
1352
+ )}:${timestamp.getMilliseconds()}`;
1353
+ }
1354
+ getWriter(level) {
1355
+ switch (level) {
1356
+ case "debug":
1357
+ case "success":
1358
+ case "info": {
1359
+ return log;
1219
1360
  }
1220
- if (!name)
1221
- throw new TypeError("Missing parameter name at ".concat(i));
1222
- tokens.push({ type: "NAME", index: i, value: name });
1223
- i = j;
1224
- continue;
1225
- }
1226
- if (char === "(") {
1227
- var count = 1;
1228
- var pattern = "";
1229
- var j = i + 1;
1230
- if (str[j] === "?") {
1231
- throw new TypeError('Pattern cannot start with "?" at '.concat(j));
1361
+ case "warning": {
1362
+ return warn2;
1232
1363
  }
1233
- while (j < str.length) {
1234
- if (str[j] === "\\") {
1235
- pattern += str[j++] + str[j++];
1236
- continue;
1237
- }
1238
- if (str[j] === ")") {
1239
- count--;
1240
- if (count === 0) {
1241
- j++;
1242
- break;
1243
- }
1244
- } else if (str[j] === "(") {
1245
- count++;
1246
- if (str[j + 1] !== "?") {
1247
- throw new TypeError("Capturing groups are not allowed at ".concat(j));
1248
- }
1249
- }
1250
- pattern += str[j++];
1364
+ case "error": {
1365
+ return error2;
1251
1366
  }
1252
- if (count)
1253
- throw new TypeError("Unbalanced pattern at ".concat(i));
1254
- if (!pattern)
1255
- throw new TypeError("Missing pattern at ".concat(i));
1256
- tokens.push({ type: "PATTERN", index: i, value: pattern });
1257
- i = j;
1258
- continue;
1259
1367
  }
1260
- tokens.push({ type: "CHAR", index: i, value: str[i++] });
1261
1368
  }
1262
- tokens.push({ type: "END", index: i, value: "" });
1263
- return tokens;
1369
+ };
1370
+ var PerformanceEntry = class {
1371
+ constructor() {
1372
+ __publicField(this, "startTime");
1373
+ __publicField(this, "endTime");
1374
+ __publicField(this, "deltaTime");
1375
+ this.startTime = performance.now();
1376
+ }
1377
+ measure() {
1378
+ this.endTime = performance.now();
1379
+ const deltaTime = this.endTime - this.startTime;
1380
+ this.deltaTime = deltaTime.toFixed(2);
1381
+ }
1382
+ };
1383
+ var noop = () => void 0;
1384
+ function log(message3, ...positionals) {
1385
+ if (IS_NODE) {
1386
+ process.stdout.write(format(message3, ...positionals) + "\n");
1387
+ return;
1388
+ }
1389
+ console.log(message3, ...positionals);
1264
1390
  }
1265
- function parse(str, options) {
1266
- if (options === void 0) {
1267
- options = {};
1391
+ function warn2(message3, ...positionals) {
1392
+ if (IS_NODE) {
1393
+ process.stderr.write(format(message3, ...positionals) + "\n");
1394
+ return;
1268
1395
  }
1269
- var tokens = lexer(str);
1270
- var _a3 = options.prefixes, prefixes = _a3 === void 0 ? "./" : _a3;
1271
- var defaultPattern = "[^".concat(escapeString(options.delimiter || "/#?"), "]+?");
1272
- var result = [];
1273
- var key = 0;
1274
- var i = 0;
1275
- var path = "";
1276
- var tryConsume = function(type) {
1277
- if (i < tokens.length && tokens[i].type === type)
1278
- return tokens[i++].value;
1279
- };
1280
- var mustConsume = function(type) {
1281
- var value2 = tryConsume(type);
1282
- if (value2 !== void 0)
1283
- return value2;
1284
- var _a4 = tokens[i], nextType = _a4.type, index = _a4.index;
1285
- throw new TypeError("Unexpected ".concat(nextType, " at ").concat(index, ", expected ").concat(type));
1286
- };
1287
- var consumeText = function() {
1288
- var result2 = "";
1289
- var value2;
1290
- while (value2 = tryConsume("CHAR") || tryConsume("ESCAPED_CHAR")) {
1291
- result2 += value2;
1292
- }
1293
- return result2;
1294
- };
1295
- while (i < tokens.length) {
1296
- var char = tryConsume("CHAR");
1297
- var name = tryConsume("NAME");
1298
- var pattern = tryConsume("PATTERN");
1299
- if (name || pattern) {
1300
- var prefix = char || "";
1301
- if (prefixes.indexOf(prefix) === -1) {
1302
- path += prefix;
1303
- prefix = "";
1304
- }
1305
- if (path) {
1306
- result.push(path);
1307
- path = "";
1308
- }
1309
- result.push({
1310
- name: name || key++,
1311
- prefix,
1312
- suffix: "",
1313
- pattern: pattern || defaultPattern,
1314
- modifier: tryConsume("MODIFIER") || ""
1315
- });
1316
- continue;
1317
- }
1318
- var value = char || tryConsume("ESCAPED_CHAR");
1319
- if (value) {
1320
- path += value;
1321
- continue;
1322
- }
1323
- if (path) {
1324
- result.push(path);
1325
- path = "";
1326
- }
1327
- var open = tryConsume("OPEN");
1328
- if (open) {
1329
- var prefix = consumeText();
1330
- var name_1 = tryConsume("NAME") || "";
1331
- var pattern_1 = tryConsume("PATTERN") || "";
1332
- var suffix = consumeText();
1333
- mustConsume("CLOSE");
1334
- result.push({
1335
- name: name_1 || (pattern_1 ? key++ : ""),
1336
- pattern: name_1 && !pattern_1 ? defaultPattern : pattern_1,
1337
- prefix,
1338
- suffix,
1339
- modifier: tryConsume("MODIFIER") || ""
1340
- });
1341
- continue;
1342
- }
1343
- mustConsume("END");
1396
+ console.warn(message3, ...positionals);
1397
+ }
1398
+ function error2(message3, ...positionals) {
1399
+ if (IS_NODE) {
1400
+ process.stderr.write(format(message3, ...positionals) + "\n");
1401
+ return;
1344
1402
  }
1345
- return result;
1403
+ console.error(message3, ...positionals);
1346
1404
  }
1347
- function match(str, options) {
1348
- var keys = [];
1349
- var re = pathToRegexp(str, keys, options);
1350
- return regexpToFunction(re, keys, options);
1405
+ function getVariable(variableName) {
1406
+ var _a3;
1407
+ if (IS_NODE) {
1408
+ return process.env[variableName];
1409
+ }
1410
+ return (_a3 = globalThis[variableName]) == null ? void 0 : _a3.toString();
1351
1411
  }
1352
- function regexpToFunction(re, keys, options) {
1353
- if (options === void 0) {
1354
- options = {};
1412
+ function isDefinedAndNotEquals(value, expected) {
1413
+ return value !== void 0 && value !== expected;
1414
+ }
1415
+ function serializeInput(message3) {
1416
+ if (typeof message3 === "undefined") {
1417
+ return "undefined";
1355
1418
  }
1356
- var _a3 = options.decode, decode = _a3 === void 0 ? function(x) {
1357
- return x;
1358
- } : _a3;
1359
- return function(pathname) {
1360
- var m = re.exec(pathname);
1361
- if (!m)
1362
- return false;
1363
- var path = m[0], index = m.index;
1364
- var params = /* @__PURE__ */ Object.create(null);
1365
- var _loop_1 = function(i2) {
1366
- if (m[i2] === void 0)
1367
- return "continue";
1368
- var key = keys[i2 - 1];
1369
- if (key.modifier === "*" || key.modifier === "+") {
1370
- params[key.name] = m[i2].split(key.prefix + key.suffix).map(function(value) {
1371
- return decode(value, key);
1372
- });
1373
- } else {
1374
- params[key.name] = decode(m[i2], key);
1375
- }
1376
- };
1377
- for (var i = 1; i < m.length; i++) {
1378
- _loop_1(i);
1379
- }
1380
- return { path, index, params };
1381
- };
1382
- }
1383
- function escapeString(str) {
1384
- return str.replace(/([.+*?=^!:${}()[\]|/\\])/g, "\\$1");
1385
- }
1386
- function flags(options) {
1387
- return options && options.sensitive ? "" : "i";
1388
- }
1389
- function regexpToRegexp(path, keys) {
1390
- if (!keys)
1391
- return path;
1392
- var groupsRegex = /\((?:\?<(.*?)>)?(?!\?)/g;
1393
- var index = 0;
1394
- var execResult = groupsRegex.exec(path.source);
1395
- while (execResult) {
1396
- keys.push({
1397
- // Use parenthesized substring match if available, index otherwise
1398
- name: execResult[1] || index++,
1399
- prefix: "",
1400
- suffix: "",
1401
- modifier: "",
1402
- pattern: ""
1403
- });
1404
- execResult = groupsRegex.exec(path.source);
1419
+ if (message3 === null) {
1420
+ return "null";
1405
1421
  }
1406
- return path;
1407
- }
1408
- function arrayToRegexp(paths, keys, options) {
1409
- var parts = paths.map(function(path) {
1410
- return pathToRegexp(path, keys, options).source;
1411
- });
1412
- return new RegExp("(?:".concat(parts.join("|"), ")"), flags(options));
1422
+ if (typeof message3 === "string") {
1423
+ return message3;
1424
+ }
1425
+ if (typeof message3 === "object") {
1426
+ return JSON.stringify(message3);
1427
+ }
1428
+ return message3.toString();
1413
1429
  }
1414
- function stringToRegexp(path, keys, options) {
1415
- return tokensToRegexp(parse(path, options), keys, options);
1430
+
1431
+ // node_modules/.pnpm/@mswjs+interceptors@0.25.1/node_modules/@mswjs/interceptors/lib/node/chunk-RGYCLCLK.mjs
1432
+ function nextTick(callback) {
1433
+ setTimeout(callback, 0);
1416
1434
  }
1417
- function tokensToRegexp(tokens, keys, options) {
1418
- if (options === void 0) {
1419
- options = {};
1435
+ var AsyncEventEmitter = class extends Emitter {
1436
+ constructor() {
1437
+ super();
1438
+ this.logger = new Logger("async-event-emitter");
1439
+ this.queue = /* @__PURE__ */ new Map();
1440
+ this.readyState = "ACTIVE";
1420
1441
  }
1421
- var _a3 = options.strict, strict = _a3 === void 0 ? false : _a3, _b2 = options.start, start = _b2 === void 0 ? true : _b2, _c = options.end, end = _c === void 0 ? true : _c, _d = options.encode, encode = _d === void 0 ? function(x) {
1422
- return x;
1423
- } : _d, _e = options.delimiter, delimiter = _e === void 0 ? "/#?" : _e, _f = options.endsWith, endsWith = _f === void 0 ? "" : _f;
1424
- var endsWithRe = "[".concat(escapeString(endsWith), "]|$");
1425
- var delimiterRe = "[".concat(escapeString(delimiter), "]");
1426
- var route = start ? "^" : "";
1427
- for (var _i = 0, tokens_1 = tokens; _i < tokens_1.length; _i++) {
1428
- var token = tokens_1[_i];
1429
- if (typeof token === "string") {
1430
- route += escapeString(encode(token));
1431
- } else {
1432
- var prefix = escapeString(encode(token.prefix));
1433
- var suffix = escapeString(encode(token.suffix));
1434
- if (token.pattern) {
1435
- if (keys)
1436
- keys.push(token);
1437
- if (prefix || suffix) {
1438
- if (token.modifier === "+" || token.modifier === "*") {
1439
- var mod = token.modifier === "*" ? "?" : "";
1440
- route += "(?:".concat(prefix, "((?:").concat(token.pattern, ")(?:").concat(suffix).concat(prefix, "(?:").concat(token.pattern, "))*)").concat(suffix, ")").concat(mod);
1441
- } else {
1442
- route += "(?:".concat(prefix, "(").concat(token.pattern, ")").concat(suffix, ")").concat(token.modifier);
1443
- }
1444
- } else {
1445
- if (token.modifier === "+" || token.modifier === "*") {
1446
- route += "((?:".concat(token.pattern, ")").concat(token.modifier, ")");
1447
- } else {
1448
- route += "(".concat(token.pattern, ")").concat(token.modifier);
1449
- }
1450
- }
1451
- } else {
1452
- route += "(?:".concat(prefix).concat(suffix, ")").concat(token.modifier);
1453
- }
1442
+ on(eventName, listener) {
1443
+ const logger = this.logger.extend("on");
1444
+ logger.info('adding "%s" listener...', eventName);
1445
+ if (this.readyState === "DEACTIVATED") {
1446
+ logger.info("the emitter is destroyed, skipping!");
1447
+ return this;
1454
1448
  }
1449
+ return super.on(eventName, (...args) => __async(this, null, function* () {
1450
+ const queue = this.openListenerQueue(eventName);
1451
+ logger.info('awaiting the "%s" listener...', eventName);
1452
+ queue.push({
1453
+ args,
1454
+ done: new Promise((resolve, reject) => __async(this, null, function* () {
1455
+ try {
1456
+ yield listener(...args);
1457
+ resolve();
1458
+ logger.info('"%s" listener has resolved!', eventName);
1459
+ } catch (error3) {
1460
+ logger.info('"%s" listener has rejected!', error3);
1461
+ reject(error3);
1462
+ }
1463
+ }))
1464
+ });
1465
+ }));
1455
1466
  }
1456
- if (end) {
1457
- if (!strict)
1458
- route += "".concat(delimiterRe, "?");
1459
- route += !options.endsWith ? "$" : "(?=".concat(endsWithRe, ")");
1460
- } else {
1461
- var endToken = tokens[tokens.length - 1];
1462
- var isEndDelimited = typeof endToken === "string" ? delimiterRe.indexOf(endToken[endToken.length - 1]) > -1 : endToken === void 0;
1463
- if (!strict) {
1464
- route += "(?:".concat(delimiterRe, "(?=").concat(endsWithRe, "))?");
1467
+ emit(eventName, ...data) {
1468
+ const logger = this.logger.extend("emit");
1469
+ logger.info('emitting "%s" event...', eventName);
1470
+ if (this.readyState === "DEACTIVATED") {
1471
+ logger.info("the emitter is destroyed, skipping!");
1472
+ return false;
1465
1473
  }
1466
- if (!isEndDelimited) {
1467
- route += "(?=".concat(delimiterRe, "|").concat(endsWithRe, ")");
1474
+ if (this.isInternalEventName(eventName)) {
1475
+ return super.emit(eventName, ...data);
1468
1476
  }
1477
+ this.openListenerQueue(eventName);
1478
+ logger.info('appending a one-time cleanup "%s" listener...', eventName);
1479
+ this.once(eventName, () => {
1480
+ nextTick(() => {
1481
+ this.queue.delete(eventName);
1482
+ logger.info('cleaned up "%s" listeners queue!', eventName);
1483
+ });
1484
+ });
1485
+ return super.emit(eventName, ...data);
1469
1486
  }
1470
- return new RegExp(route, flags(options));
1471
- }
1472
- function pathToRegexp(path, keys, options) {
1473
- if (path instanceof RegExp)
1474
- return regexpToRegexp(path, keys);
1475
- if (Array.isArray(path))
1476
- return arrayToRegexp(path, keys, options);
1477
- return stringToRegexp(path, keys, options);
1478
- }
1479
-
1480
- // node_modules/.pnpm/is-node-process@1.2.0/node_modules/is-node-process/lib/index.mjs
1481
- function isNodeProcess() {
1482
- if (typeof navigator !== "undefined" && navigator.product === "ReactNative") {
1483
- return true;
1487
+ /**
1488
+ * Returns a promise that resolves when all the listeners for the given event
1489
+ * has been called. Awaits asynchronous listeners.
1490
+ * If the event has no listeners, resolves immediately.
1491
+ */
1492
+ untilIdle(eventName, filter = () => true) {
1493
+ return __async(this, null, function* () {
1494
+ const listenersQueue = this.queue.get(eventName) || [];
1495
+ yield Promise.all(
1496
+ listenersQueue.filter(filter).map(({ done }) => done)
1497
+ ).finally(() => {
1498
+ this.queue.delete(eventName);
1499
+ });
1500
+ });
1484
1501
  }
1485
- if (typeof process !== "undefined") {
1486
- const type = process.type;
1487
- if (type === "renderer" || type === "worker") {
1488
- return false;
1502
+ openListenerQueue(eventName) {
1503
+ const logger = this.logger.extend("openListenerQueue");
1504
+ logger.info('opening "%s" listeners queue...', eventName);
1505
+ const queue = this.queue.get(eventName);
1506
+ if (!queue) {
1507
+ logger.info("no queue found, creating one...");
1508
+ this.queue.set(eventName, []);
1509
+ return [];
1489
1510
  }
1490
- return !!(process.versions && process.versions.node);
1511
+ logger.info("returning an exising queue:", queue);
1512
+ return queue;
1513
+ }
1514
+ removeAllListeners(eventName) {
1515
+ const logger = this.logger.extend("removeAllListeners");
1516
+ logger.info("event:", eventName);
1517
+ if (eventName) {
1518
+ this.queue.delete(eventName);
1519
+ logger.info(
1520
+ 'cleared the "%s" listeners queue!',
1521
+ eventName,
1522
+ this.queue.get(eventName)
1523
+ );
1524
+ } else {
1525
+ this.queue.clear();
1526
+ logger.info("cleared the listeners queue!", this.queue);
1527
+ }
1528
+ return super.removeAllListeners(eventName);
1529
+ }
1530
+ activate() {
1531
+ const logger = this.logger.extend("activate");
1532
+ this.readyState = "ACTIVE";
1533
+ logger.info("set state to:", this.readyState);
1534
+ }
1535
+ /**
1536
+ * Deactivate this event emitter.
1537
+ * Deactivated emitter can no longer emit and listen to events
1538
+ * and needs to be activated again in order to do so.
1539
+ */
1540
+ deactivate() {
1541
+ const logger = this.logger.extend("deactivate");
1542
+ logger.info("removing all listeners...");
1543
+ this.removeAllListeners();
1544
+ this.readyState = "DEACTIVATED";
1545
+ logger.info("set state to:", this.readyState);
1546
+ }
1547
+ isInternalEventName(eventName) {
1548
+ return eventName === "newListener" || eventName === "removeListener";
1491
1549
  }
1492
- return false;
1493
- }
1494
-
1495
- // node_modules/.pnpm/@open-draft+logger@0.3.0/node_modules/@open-draft/logger/lib/index.mjs
1496
- var __defProp4 = Object.defineProperty;
1497
- var __export2 = (target, all) => {
1498
- for (var name in all)
1499
- __defProp4(target, name, { get: all[name], enumerable: true });
1500
1550
  };
1501
- var colors_exports = {};
1502
- __export2(colors_exports, {
1503
- blue: () => blue,
1504
- gray: () => gray,
1505
- green: () => green,
1506
- red: () => red,
1507
- yellow: () => yellow
1508
- });
1509
- function yellow(text) {
1510
- return `\x1B[33m${text}\x1B[0m`;
1511
- }
1512
- function blue(text) {
1513
- return `\x1B[34m${text}\x1B[0m`;
1514
- }
1515
- function gray(text) {
1516
- return `\x1B[90m${text}\x1B[0m`;
1551
+ function getGlobalSymbol(symbol) {
1552
+ return (
1553
+ // @ts-ignore https://github.com/Microsoft/TypeScript/issues/24587
1554
+ globalThis[symbol] || void 0
1555
+ );
1517
1556
  }
1518
- function red(text) {
1519
- return `\x1B[31m${text}\x1B[0m`;
1557
+ function setGlobalSymbol(symbol, value) {
1558
+ globalThis[symbol] = value;
1520
1559
  }
1521
- function green(text) {
1522
- return `\x1B[32m${text}\x1B[0m`;
1560
+ function deleteGlobalSymbol(symbol) {
1561
+ delete globalThis[symbol];
1523
1562
  }
1524
- var IS_NODE = isNodeProcess();
1525
- var Logger = class {
1526
- constructor(name) {
1527
- __publicField(this, "prefix");
1528
- this.name = name;
1529
- this.prefix = `[${this.name}]`;
1530
- const LOGGER_NAME = getVariable("DEBUG");
1531
- const LOGGER_LEVEL = getVariable("LOG_LEVEL");
1532
- const isLoggingEnabled = LOGGER_NAME === "1" || LOGGER_NAME === "true" || typeof LOGGER_NAME !== "undefined" && this.name.startsWith(LOGGER_NAME);
1533
- if (isLoggingEnabled) {
1534
- this.debug = isDefinedAndNotEquals(LOGGER_LEVEL, "debug") ? noop : this.debug;
1535
- this.info = isDefinedAndNotEquals(LOGGER_LEVEL, "info") ? noop : this.info;
1536
- this.success = isDefinedAndNotEquals(LOGGER_LEVEL, "success") ? noop : this.success;
1537
- this.warning = isDefinedAndNotEquals(LOGGER_LEVEL, "warning") ? noop : this.warning;
1538
- this.error = isDefinedAndNotEquals(LOGGER_LEVEL, "error") ? noop : this.error;
1539
- } else {
1540
- this.info = noop;
1541
- this.success = noop;
1542
- this.warning = noop;
1543
- this.error = noop;
1544
- this.only = noop;
1545
- }
1546
- }
1547
- extend(domain) {
1548
- return new Logger(`${this.name}:${domain}`);
1563
+ var Interceptor = class {
1564
+ constructor(symbol) {
1565
+ this.symbol = symbol;
1566
+ this.readyState = "INACTIVE";
1567
+ this.emitter = new AsyncEventEmitter();
1568
+ this.subscriptions = [];
1569
+ this.logger = new Logger(symbol.description);
1570
+ this.emitter.setMaxListeners(0);
1571
+ this.logger.info("constructing the interceptor...");
1549
1572
  }
1550
1573
  /**
1551
- * Print a debug message.
1552
- * @example
1553
- * logger.debug('no duplicates found, creating a document...')
1574
+ * Determine if this interceptor can be applied
1575
+ * in the current environment.
1554
1576
  */
1555
- debug(message3, ...positionals) {
1556
- this.logEntry({
1557
- level: "debug",
1558
- message: gray(message3),
1559
- positionals,
1560
- prefix: this.prefix,
1561
- colors: {
1562
- prefix: "gray"
1563
- }
1564
- });
1577
+ checkEnvironment() {
1578
+ return true;
1565
1579
  }
1566
1580
  /**
1567
- * Print an info message.
1568
- * @example
1569
- * logger.info('start parsing...')
1581
+ * Apply this interceptor to the current process.
1582
+ * Returns an already running interceptor instance if it's present.
1570
1583
  */
1571
- info(message3, ...positionals) {
1572
- this.logEntry({
1573
- level: "info",
1574
- message: message3,
1575
- positionals,
1576
- prefix: this.prefix,
1577
- colors: {
1578
- prefix: "blue"
1579
- }
1580
- });
1581
- const performance2 = new PerformanceEntry();
1582
- return (message22, ...positionals2) => {
1583
- performance2.measure();
1584
- this.logEntry({
1585
- level: "info",
1586
- message: `${message22} ${gray(`${performance2.deltaTime}ms`)}`,
1587
- positionals: positionals2,
1588
- prefix: this.prefix,
1589
- colors: {
1590
- prefix: "blue"
1591
- }
1592
- });
1593
- };
1584
+ apply() {
1585
+ const logger = this.logger.extend("apply");
1586
+ logger.info("applying the interceptor...");
1587
+ if (this.readyState === "APPLIED") {
1588
+ logger.info("intercepted already applied!");
1589
+ return;
1590
+ }
1591
+ const shouldApply = this.checkEnvironment();
1592
+ if (!shouldApply) {
1593
+ logger.info("the interceptor cannot be applied in this environment!");
1594
+ return;
1595
+ }
1596
+ this.readyState = "APPLYING";
1597
+ this.emitter.activate();
1598
+ logger.info("activated the emiter!", this.emitter.readyState);
1599
+ const runningInstance = this.getInstance();
1600
+ if (runningInstance) {
1601
+ logger.info("found a running instance, reusing...");
1602
+ this.on = (event, listener) => {
1603
+ logger.info('proxying the "%s" listener', event);
1604
+ runningInstance.emitter.addListener(event, listener);
1605
+ this.subscriptions.push(() => {
1606
+ runningInstance.emitter.removeListener(event, listener);
1607
+ logger.info('removed proxied "%s" listener!', event);
1608
+ });
1609
+ };
1610
+ this.readyState = "APPLIED";
1611
+ return;
1612
+ }
1613
+ logger.info("no running instance found, setting up a new instance...");
1614
+ this.setup();
1615
+ this.setInstance();
1616
+ this.readyState = "APPLIED";
1594
1617
  }
1595
1618
  /**
1596
- * Print a success message.
1597
- * @example
1598
- * logger.success('successfully created document')
1619
+ * Setup the module augments and stubs necessary for this interceptor.
1620
+ * This method is not run if there's a running interceptor instance
1621
+ * to prevent instantiating an interceptor multiple times.
1599
1622
  */
1600
- success(message3, ...positionals) {
1601
- this.logEntry({
1602
- level: "info",
1603
- message: message3,
1604
- positionals,
1605
- prefix: `\u2714 ${this.prefix}`,
1606
- colors: {
1607
- timestamp: "green",
1608
- prefix: "green"
1609
- }
1610
- });
1623
+ setup() {
1611
1624
  }
1612
1625
  /**
1613
- * Print a warning.
1614
- * @example
1615
- * logger.warning('found legacy document format')
1626
+ * Listen to the interceptor's public events.
1616
1627
  */
1617
- warning(message3, ...positionals) {
1618
- this.logEntry({
1619
- level: "warning",
1620
- message: message3,
1621
- positionals,
1622
- prefix: `\u26A0 ${this.prefix}`,
1623
- colors: {
1624
- timestamp: "yellow",
1625
- prefix: "yellow"
1626
- }
1627
- });
1628
+ on(eventName, listener) {
1629
+ const logger = this.logger.extend("on");
1630
+ if (this.readyState === "DISPOSING" || this.readyState === "DISPOSED") {
1631
+ logger.info("cannot listen to events, already disposed!");
1632
+ return;
1633
+ }
1634
+ logger.info('adding "%s" event listener:', eventName, listener.name);
1635
+ this.emitter.on(eventName, listener);
1628
1636
  }
1629
1637
  /**
1630
- * Print an error message.
1631
- * @example
1632
- * logger.error('something went wrong')
1638
+ * Disposes of any side-effects this interceptor has introduced.
1633
1639
  */
1634
- error(message3, ...positionals) {
1635
- this.logEntry({
1636
- level: "error",
1637
- message: message3,
1638
- positionals,
1639
- prefix: `\u2716 ${this.prefix}`,
1640
- colors: {
1641
- timestamp: "red",
1642
- prefix: "red"
1640
+ dispose() {
1641
+ const logger = this.logger.extend("dispose");
1642
+ if (this.readyState === "DISPOSED") {
1643
+ logger.info("cannot dispose, already disposed!");
1644
+ return;
1645
+ }
1646
+ logger.info("disposing the interceptor...");
1647
+ this.readyState = "DISPOSING";
1648
+ if (!this.getInstance()) {
1649
+ logger.info("no interceptors running, skipping dispose...");
1650
+ return;
1651
+ }
1652
+ this.clearInstance();
1653
+ logger.info("global symbol deleted:", getGlobalSymbol(this.symbol));
1654
+ if (this.subscriptions.length > 0) {
1655
+ logger.info("disposing of %d subscriptions...", this.subscriptions.length);
1656
+ for (const dispose of this.subscriptions) {
1657
+ dispose();
1643
1658
  }
1644
- });
1645
- }
1646
- /**
1647
- * Execute the given callback only when the logging is enabled.
1648
- * This is skipped in its entirety and has no runtime cost otherwise.
1649
- * This executes regardless of the log level.
1650
- * @example
1651
- * logger.only(() => {
1652
- * logger.info('additional info')
1653
- * })
1654
- */
1655
- only(callback) {
1656
- callback();
1659
+ this.subscriptions = [];
1660
+ logger.info("disposed of all subscriptions!", this.subscriptions.length);
1661
+ }
1662
+ this.emitter.deactivate();
1663
+ logger.info("destroyed the listener!");
1664
+ this.readyState = "DISPOSED";
1657
1665
  }
1658
- createEntry(level, message3) {
1659
- return {
1660
- timestamp: /* @__PURE__ */ new Date(),
1661
- level,
1662
- message: message3
1663
- };
1666
+ getInstance() {
1667
+ var _a3;
1668
+ const instance = getGlobalSymbol(this.symbol);
1669
+ this.logger.info("retrieved global instance:", (_a3 = instance == null ? void 0 : instance.constructor) == null ? void 0 : _a3.name);
1670
+ return instance;
1664
1671
  }
1665
- logEntry(args) {
1666
- const {
1667
- level,
1668
- message: message3,
1669
- prefix,
1670
- colors: customColors,
1671
- positionals = []
1672
- } = args;
1673
- const entry = this.createEntry(level, message3);
1674
- const timestampColor = (customColors == null ? void 0 : customColors.timestamp) || "gray";
1675
- const prefixColor = (customColors == null ? void 0 : customColors.prefix) || "gray";
1676
- const colorize = {
1677
- timestamp: colors_exports[timestampColor],
1678
- prefix: colors_exports[prefixColor]
1679
- };
1680
- const write = this.getWriter(level);
1681
- write(
1682
- [colorize.timestamp(this.formatTimestamp(entry.timestamp))].concat(prefix != null ? colorize.prefix(prefix) : []).concat(serializeInput(message3)).join(" "),
1683
- ...positionals.map(serializeInput)
1684
- );
1672
+ setInstance() {
1673
+ setGlobalSymbol(this.symbol, this);
1674
+ this.logger.info("set global instance!", this.symbol.description);
1685
1675
  }
1686
- formatTimestamp(timestamp) {
1687
- return `${timestamp.toLocaleTimeString(
1688
- "en-GB"
1689
- )}:${timestamp.getMilliseconds()}`;
1690
- }
1691
- getWriter(level) {
1692
- switch (level) {
1693
- case "debug":
1694
- case "success":
1695
- case "info": {
1696
- return log;
1697
- }
1698
- case "warning": {
1699
- return warn2;
1700
- }
1701
- case "error": {
1702
- return error2;
1703
- }
1704
- }
1676
+ clearInstance() {
1677
+ deleteGlobalSymbol(this.symbol);
1678
+ this.logger.info("cleared global instance!", this.symbol.description);
1705
1679
  }
1706
1680
  };
1707
- var PerformanceEntry = class {
1708
- constructor() {
1709
- __publicField(this, "startTime");
1710
- __publicField(this, "endTime");
1711
- __publicField(this, "deltaTime");
1712
- this.startTime = performance.now();
1713
- }
1714
- measure() {
1715
- this.endTime = performance.now();
1716
- const deltaTime = this.endTime - this.startTime;
1717
- this.deltaTime = deltaTime.toFixed(2);
1681
+
1682
+ // node_modules/.pnpm/@mswjs+interceptors@0.25.1/node_modules/@mswjs/interceptors/lib/node/chunk-VS3GJPUE.mjs
1683
+ var BatchInterceptor = class extends Interceptor {
1684
+ constructor(options) {
1685
+ BatchInterceptor.symbol = Symbol(options.name);
1686
+ super(BatchInterceptor.symbol);
1687
+ this.interceptors = options.interceptors;
1718
1688
  }
1719
- };
1720
- var noop = () => void 0;
1721
- function log(message3, ...positionals) {
1722
- if (IS_NODE) {
1723
- process.stdout.write(format(message3, ...positionals) + "\n");
1724
- return;
1689
+ setup() {
1690
+ const logger = this.logger.extend("setup");
1691
+ logger.info("applying all %d interceptors...", this.interceptors.length);
1692
+ for (const interceptor of this.interceptors) {
1693
+ logger.info('applying "%s" interceptor...', interceptor.constructor.name);
1694
+ interceptor.apply();
1695
+ logger.info("adding interceptor dispose subscription");
1696
+ this.subscriptions.push(() => interceptor.dispose());
1697
+ }
1725
1698
  }
1726
- console.log(message3, ...positionals);
1727
- }
1728
- function warn2(message3, ...positionals) {
1729
- if (IS_NODE) {
1730
- process.stderr.write(format(message3, ...positionals) + "\n");
1731
- return;
1699
+ on(event, listener) {
1700
+ this.interceptors.forEach((interceptor) => {
1701
+ interceptor.on(event, listener);
1702
+ });
1732
1703
  }
1733
- console.warn(message3, ...positionals);
1704
+ };
1705
+
1706
+ // node_modules/.pnpm/@mswjs+interceptors@0.25.1/node_modules/@mswjs/interceptors/lib/node/chunk-7II4SWKS.mjs
1707
+ var encoder = new TextEncoder();
1708
+
1709
+ // node_modules/.pnpm/@mswjs+interceptors@0.25.1/node_modules/@mswjs/interceptors/lib/node/chunk-GFH37L5D.mjs
1710
+ var IS_PATCHED_MODULE = Symbol("isPatchedModule");
1711
+
1712
+ // node_modules/.pnpm/@mswjs+interceptors@0.25.1/node_modules/@mswjs/interceptors/lib/node/index.mjs
1713
+ function getCleanUrl(url, isAbsolute = true) {
1714
+ return [isAbsolute && url.origin, url.pathname].filter(Boolean).join("");
1734
1715
  }
1735
- function error2(message3, ...positionals) {
1736
- if (IS_NODE) {
1737
- process.stderr.write(format(message3, ...positionals) + "\n");
1738
- return;
1739
- }
1740
- console.error(message3, ...positionals);
1716
+
1717
+ // src/core/utils/url/cleanUrl.ts
1718
+ var REDUNDANT_CHARACTERS_EXP = /[\?|#].*$/g;
1719
+ function getSearchParams(path) {
1720
+ return new URL(`/${path}`, "http://localhost").searchParams;
1741
1721
  }
1742
- function getVariable(variableName) {
1743
- var _a3;
1744
- if (IS_NODE) {
1745
- return process.env[variableName];
1746
- }
1747
- return (_a3 = globalThis[variableName]) == null ? void 0 : _a3.toString();
1722
+ function cleanUrl(path) {
1723
+ return path.replace(REDUNDANT_CHARACTERS_EXP, "");
1748
1724
  }
1749
- function isDefinedAndNotEquals(value, expected) {
1750
- return value !== void 0 && value !== expected;
1725
+
1726
+ // src/core/utils/url/isAbsoluteUrl.ts
1727
+ function isAbsoluteUrl(url) {
1728
+ return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url);
1751
1729
  }
1752
- function serializeInput(message3) {
1753
- if (typeof message3 === "undefined") {
1754
- return "undefined";
1755
- }
1756
- if (message3 === null) {
1757
- return "null";
1758
- }
1759
- if (typeof message3 === "string") {
1760
- return message3;
1730
+
1731
+ // src/core/utils/url/getAbsoluteUrl.ts
1732
+ function getAbsoluteUrl(path, baseUrl) {
1733
+ if (isAbsoluteUrl(path)) {
1734
+ return path;
1761
1735
  }
1762
- if (typeof message3 === "object") {
1763
- return JSON.stringify(message3);
1736
+ if (path.startsWith("*")) {
1737
+ return path;
1764
1738
  }
1765
- return message3.toString();
1739
+ const origin = baseUrl || typeof document !== "undefined" && document.baseURI;
1740
+ return origin ? (
1741
+ // Encode and decode the path to preserve escaped characters.
1742
+ decodeURI(new URL(encodeURI(path), origin).href)
1743
+ ) : path;
1766
1744
  }
1767
1745
 
1768
- // node_modules/.pnpm/@mswjs+interceptors@0.25.1/node_modules/@mswjs/interceptors/lib/node/chunk-RGYCLCLK.mjs
1769
- function nextTick(callback) {
1770
- setTimeout(callback, 0);
1771
- }
1772
- var AsyncEventEmitter = class extends Emitter {
1773
- constructor() {
1774
- super();
1775
- this.logger = new Logger("async-event-emitter");
1776
- this.queue = /* @__PURE__ */ new Map();
1777
- this.readyState = "ACTIVE";
1778
- }
1779
- on(eventName, listener) {
1780
- const logger = this.logger.extend("on");
1781
- logger.info('adding "%s" listener...', eventName);
1782
- if (this.readyState === "DEACTIVATED") {
1783
- logger.info("the emitter is destroyed, skipping!");
1784
- return this;
1785
- }
1786
- return super.on(eventName, (...args) => __async(this, null, function* () {
1787
- const queue = this.openListenerQueue(eventName);
1788
- logger.info('awaiting the "%s" listener...', eventName);
1789
- queue.push({
1790
- args,
1791
- done: new Promise((resolve, reject) => __async(this, null, function* () {
1792
- try {
1793
- yield listener(...args);
1794
- resolve();
1795
- logger.info('"%s" listener has resolved!', eventName);
1796
- } catch (error3) {
1797
- logger.info('"%s" listener has rejected!', error3);
1798
- reject(error3);
1799
- }
1800
- }))
1801
- });
1802
- }));
1746
+ // src/core/utils/matching/normalizePath.ts
1747
+ function normalizePath(path, baseUrl) {
1748
+ if (path instanceof RegExp) {
1749
+ return path;
1803
1750
  }
1804
- emit(eventName, ...data) {
1805
- const logger = this.logger.extend("emit");
1806
- logger.info('emitting "%s" event...', eventName);
1807
- if (this.readyState === "DEACTIVATED") {
1808
- logger.info("the emitter is destroyed, skipping!");
1809
- return false;
1810
- }
1811
- if (this.isInternalEventName(eventName)) {
1812
- return super.emit(eventName, ...data);
1751
+ const maybeAbsoluteUrl = getAbsoluteUrl(path, baseUrl);
1752
+ return cleanUrl(maybeAbsoluteUrl);
1753
+ }
1754
+
1755
+ // src/core/utils/matching/matchRequestUrl.ts
1756
+ function coercePath(path) {
1757
+ return path.replace(
1758
+ /([:a-zA-Z_-]*)(\*{1,2})+/g,
1759
+ (_, parameterName, wildcard) => {
1760
+ const expression = "(.*)";
1761
+ if (!parameterName) {
1762
+ return expression;
1763
+ }
1764
+ return parameterName.startsWith(":") ? `${parameterName}${wildcard}` : `${parameterName}${expression}`;
1813
1765
  }
1814
- this.openListenerQueue(eventName);
1815
- logger.info('appending a one-time cleanup "%s" listener...', eventName);
1816
- this.once(eventName, () => {
1817
- nextTick(() => {
1818
- this.queue.delete(eventName);
1819
- logger.info('cleaned up "%s" listeners queue!', eventName);
1820
- });
1821
- });
1822
- return super.emit(eventName, ...data);
1766
+ ).replace(/([^\/])(:)(?=\d+)/, "$1\\$2").replace(/^([^\/]+)(:)(?=\/\/)/, "$1\\$2");
1767
+ }
1768
+ function matchRequestUrl(url, path, baseUrl) {
1769
+ const normalizedPath = normalizePath(path, baseUrl);
1770
+ const cleanPath = typeof normalizedPath === "string" ? coercePath(normalizedPath) : normalizedPath;
1771
+ const cleanUrl2 = getCleanUrl(url);
1772
+ const result = match(cleanPath, { decode: decodeURIComponent })(cleanUrl2);
1773
+ const params = result && result.params || {};
1774
+ return {
1775
+ matches: result !== false,
1776
+ params
1777
+ };
1778
+ }
1779
+
1780
+ // src/core/utils/request/getPublicUrlFromRequest.ts
1781
+ function getPublicUrlFromRequest(request) {
1782
+ if (typeof location === "undefined") {
1783
+ return request.url;
1823
1784
  }
1824
- /**
1825
- * Returns a promise that resolves when all the listeners for the given event
1826
- * has been called. Awaits asynchronous listeners.
1827
- * If the event has no listeners, resolves immediately.
1828
- */
1829
- untilIdle(eventName, filter = () => true) {
1830
- return __async(this, null, function* () {
1831
- const listenersQueue = this.queue.get(eventName) || [];
1832
- yield Promise.all(
1833
- listenersQueue.filter(filter).map(({ done }) => done)
1834
- ).finally(() => {
1835
- this.queue.delete(eventName);
1836
- });
1837
- });
1838
- }
1839
- openListenerQueue(eventName) {
1840
- const logger = this.logger.extend("openListenerQueue");
1841
- logger.info('opening "%s" listeners queue...', eventName);
1842
- const queue = this.queue.get(eventName);
1843
- if (!queue) {
1844
- logger.info("no queue found, creating one...");
1845
- this.queue.set(eventName, []);
1846
- return [];
1847
- }
1848
- logger.info("returning an exising queue:", queue);
1849
- return queue;
1850
- }
1851
- removeAllListeners(eventName) {
1852
- const logger = this.logger.extend("removeAllListeners");
1853
- logger.info("event:", eventName);
1854
- if (eventName) {
1855
- this.queue.delete(eventName);
1856
- logger.info(
1857
- 'cleared the "%s" listeners queue!',
1858
- eventName,
1859
- this.queue.get(eventName)
1860
- );
1861
- } else {
1862
- this.queue.clear();
1863
- logger.info("cleared the listeners queue!", this.queue);
1864
- }
1865
- return super.removeAllListeners(eventName);
1866
- }
1867
- activate() {
1868
- const logger = this.logger.extend("activate");
1869
- this.readyState = "ACTIVE";
1870
- logger.info("set state to:", this.readyState);
1871
- }
1872
- /**
1873
- * Deactivate this event emitter.
1874
- * Deactivated emitter can no longer emit and listen to events
1875
- * and needs to be activated again in order to do so.
1876
- */
1877
- deactivate() {
1878
- const logger = this.logger.extend("deactivate");
1879
- logger.info("removing all listeners...");
1880
- this.removeAllListeners();
1881
- this.readyState = "DEACTIVATED";
1882
- logger.info("set state to:", this.readyState);
1883
- }
1884
- isInternalEventName(eventName) {
1885
- return eventName === "newListener" || eventName === "removeListener";
1785
+ const url = new URL(request.url);
1786
+ return url.origin === location.origin ? url.pathname : url.origin + url.pathname;
1787
+ }
1788
+
1789
+ // node_modules/.pnpm/@bundled-es-modules+cookie@2.0.0/node_modules/@bundled-es-modules/cookie/index-esm.js
1790
+ var __create2 = Object.create;
1791
+ var __defProp4 = Object.defineProperty;
1792
+ var __getOwnPropDesc3 = Object.getOwnPropertyDescriptor;
1793
+ var __getOwnPropNames3 = Object.getOwnPropertyNames;
1794
+ var __getProtoOf2 = Object.getPrototypeOf;
1795
+ var __hasOwnProp3 = Object.prototype.hasOwnProperty;
1796
+ var __commonJS2 = (cb, mod) => function __require() {
1797
+ return mod || (0, cb[__getOwnPropNames3(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
1798
+ };
1799
+ var __copyProps3 = (to, from, except, desc) => {
1800
+ if (from && typeof from === "object" || typeof from === "function") {
1801
+ for (let key of __getOwnPropNames3(from))
1802
+ if (!__hasOwnProp3.call(to, key) && key !== except)
1803
+ __defProp4(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc3(from, key)) || desc.enumerable });
1886
1804
  }
1805
+ return to;
1887
1806
  };
1888
- function getGlobalSymbol(symbol) {
1889
- return (
1890
- // @ts-ignore https://github.com/Microsoft/TypeScript/issues/24587
1891
- globalThis[symbol] || void 0
1892
- );
1893
- }
1894
- function setGlobalSymbol(symbol, value) {
1895
- globalThis[symbol] = value;
1896
- }
1897
- function deleteGlobalSymbol(symbol) {
1898
- delete globalThis[symbol];
1899
- }
1900
- var Interceptor = class {
1901
- constructor(symbol) {
1902
- this.symbol = symbol;
1903
- this.readyState = "INACTIVE";
1904
- this.emitter = new AsyncEventEmitter();
1905
- this.subscriptions = [];
1906
- this.logger = new Logger(symbol.description);
1907
- this.emitter.setMaxListeners(0);
1908
- this.logger.info("constructing the interceptor...");
1909
- }
1910
- /**
1911
- * Determine if this interceptor can be applied
1912
- * in the current environment.
1913
- */
1914
- checkEnvironment() {
1915
- return true;
1916
- }
1917
- /**
1918
- * Apply this interceptor to the current process.
1919
- * Returns an already running interceptor instance if it's present.
1920
- */
1921
- apply() {
1922
- const logger = this.logger.extend("apply");
1923
- logger.info("applying the interceptor...");
1924
- if (this.readyState === "APPLIED") {
1925
- logger.info("intercepted already applied!");
1926
- return;
1807
+ var __toESM2 = (mod, isNodeMode, target) => (target = mod != null ? __create2(__getProtoOf2(mod)) : {}, __copyProps3(
1808
+ // If the importer is in node compatibility mode or this is not an ESM
1809
+ // file that has been converted to a CommonJS file using a Babel-
1810
+ // compatible transform (i.e. "__esModule" has not been set), then set
1811
+ // "default" to the CommonJS "module.exports" for node compatibility.
1812
+ isNodeMode || !mod || !mod.__esModule ? __defProp4(target, "default", { value: mod, enumerable: true }) : target,
1813
+ mod
1814
+ ));
1815
+ var require_cookie = __commonJS2({
1816
+ "node_modules/cookie/index.js"(exports) {
1817
+ "use strict";
1818
+ exports.parse = parse3;
1819
+ exports.serialize = serialize;
1820
+ var __toString = Object.prototype.toString;
1821
+ var fieldContentRegExp = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;
1822
+ function parse3(str, options) {
1823
+ if (typeof str !== "string") {
1824
+ throw new TypeError("argument str must be a string");
1825
+ }
1826
+ var obj = {};
1827
+ var opt = options || {};
1828
+ var dec = opt.decode || decode;
1829
+ var index = 0;
1830
+ while (index < str.length) {
1831
+ var eqIdx = str.indexOf("=", index);
1832
+ if (eqIdx === -1) {
1833
+ break;
1834
+ }
1835
+ var endIdx = str.indexOf(";", index);
1836
+ if (endIdx === -1) {
1837
+ endIdx = str.length;
1838
+ } else if (endIdx < eqIdx) {
1839
+ index = str.lastIndexOf(";", eqIdx - 1) + 1;
1840
+ continue;
1841
+ }
1842
+ var key = str.slice(index, eqIdx).trim();
1843
+ if (void 0 === obj[key]) {
1844
+ var val = str.slice(eqIdx + 1, endIdx).trim();
1845
+ if (val.charCodeAt(0) === 34) {
1846
+ val = val.slice(1, -1);
1847
+ }
1848
+ obj[key] = tryDecode(val, dec);
1849
+ }
1850
+ index = endIdx + 1;
1851
+ }
1852
+ return obj;
1927
1853
  }
1928
- const shouldApply = this.checkEnvironment();
1929
- if (!shouldApply) {
1930
- logger.info("the interceptor cannot be applied in this environment!");
1931
- return;
1854
+ function serialize(name, val, options) {
1855
+ var opt = options || {};
1856
+ var enc = opt.encode || encode;
1857
+ if (typeof enc !== "function") {
1858
+ throw new TypeError("option encode is invalid");
1859
+ }
1860
+ if (!fieldContentRegExp.test(name)) {
1861
+ throw new TypeError("argument name is invalid");
1862
+ }
1863
+ var value = enc(val);
1864
+ if (value && !fieldContentRegExp.test(value)) {
1865
+ throw new TypeError("argument val is invalid");
1866
+ }
1867
+ var str = name + "=" + value;
1868
+ if (null != opt.maxAge) {
1869
+ var maxAge = opt.maxAge - 0;
1870
+ if (isNaN(maxAge) || !isFinite(maxAge)) {
1871
+ throw new TypeError("option maxAge is invalid");
1872
+ }
1873
+ str += "; Max-Age=" + Math.floor(maxAge);
1874
+ }
1875
+ if (opt.domain) {
1876
+ if (!fieldContentRegExp.test(opt.domain)) {
1877
+ throw new TypeError("option domain is invalid");
1878
+ }
1879
+ str += "; Domain=" + opt.domain;
1880
+ }
1881
+ if (opt.path) {
1882
+ if (!fieldContentRegExp.test(opt.path)) {
1883
+ throw new TypeError("option path is invalid");
1884
+ }
1885
+ str += "; Path=" + opt.path;
1886
+ }
1887
+ if (opt.expires) {
1888
+ var expires = opt.expires;
1889
+ if (!isDate(expires) || isNaN(expires.valueOf())) {
1890
+ throw new TypeError("option expires is invalid");
1891
+ }
1892
+ str += "; Expires=" + expires.toUTCString();
1893
+ }
1894
+ if (opt.httpOnly) {
1895
+ str += "; HttpOnly";
1896
+ }
1897
+ if (opt.secure) {
1898
+ str += "; Secure";
1899
+ }
1900
+ if (opt.priority) {
1901
+ var priority = typeof opt.priority === "string" ? opt.priority.toLowerCase() : opt.priority;
1902
+ switch (priority) {
1903
+ case "low":
1904
+ str += "; Priority=Low";
1905
+ break;
1906
+ case "medium":
1907
+ str += "; Priority=Medium";
1908
+ break;
1909
+ case "high":
1910
+ str += "; Priority=High";
1911
+ break;
1912
+ default:
1913
+ throw new TypeError("option priority is invalid");
1914
+ }
1915
+ }
1916
+ if (opt.sameSite) {
1917
+ var sameSite = typeof opt.sameSite === "string" ? opt.sameSite.toLowerCase() : opt.sameSite;
1918
+ switch (sameSite) {
1919
+ case true:
1920
+ str += "; SameSite=Strict";
1921
+ break;
1922
+ case "lax":
1923
+ str += "; SameSite=Lax";
1924
+ break;
1925
+ case "strict":
1926
+ str += "; SameSite=Strict";
1927
+ break;
1928
+ case "none":
1929
+ str += "; SameSite=None";
1930
+ break;
1931
+ default:
1932
+ throw new TypeError("option sameSite is invalid");
1933
+ }
1934
+ }
1935
+ return str;
1932
1936
  }
1933
- this.readyState = "APPLYING";
1934
- this.emitter.activate();
1935
- logger.info("activated the emiter!", this.emitter.readyState);
1936
- const runningInstance = this.getInstance();
1937
- if (runningInstance) {
1938
- logger.info("found a running instance, reusing...");
1939
- this.on = (event, listener) => {
1940
- logger.info('proxying the "%s" listener', event);
1941
- runningInstance.emitter.addListener(event, listener);
1942
- this.subscriptions.push(() => {
1943
- runningInstance.emitter.removeListener(event, listener);
1944
- logger.info('removed proxied "%s" listener!', event);
1945
- });
1946
- };
1947
- this.readyState = "APPLIED";
1948
- return;
1937
+ function decode(str) {
1938
+ return str.indexOf("%") !== -1 ? decodeURIComponent(str) : str;
1949
1939
  }
1950
- logger.info("no running instance found, setting up a new instance...");
1951
- this.setup();
1952
- this.setInstance();
1953
- this.readyState = "APPLIED";
1954
- }
1955
- /**
1956
- * Setup the module augments and stubs necessary for this interceptor.
1957
- * This method is not run if there's a running interceptor instance
1958
- * to prevent instantiating an interceptor multiple times.
1959
- */
1960
- setup() {
1961
- }
1962
- /**
1963
- * Listen to the interceptor's public events.
1964
- */
1965
- on(eventName, listener) {
1966
- const logger = this.logger.extend("on");
1967
- if (this.readyState === "DISPOSING" || this.readyState === "DISPOSED") {
1968
- logger.info("cannot listen to events, already disposed!");
1969
- return;
1940
+ function encode(val) {
1941
+ return encodeURIComponent(val);
1970
1942
  }
1971
- logger.info('adding "%s" event listener:', eventName, listener.name);
1972
- this.emitter.on(eventName, listener);
1973
- }
1974
- /**
1975
- * Disposes of any side-effects this interceptor has introduced.
1976
- */
1977
- dispose() {
1978
- const logger = this.logger.extend("dispose");
1979
- if (this.readyState === "DISPOSED") {
1980
- logger.info("cannot dispose, already disposed!");
1981
- return;
1982
- }
1983
- logger.info("disposing the interceptor...");
1984
- this.readyState = "DISPOSING";
1985
- if (!this.getInstance()) {
1986
- logger.info("no interceptors running, skipping dispose...");
1987
- return;
1988
- }
1989
- this.clearInstance();
1990
- logger.info("global symbol deleted:", getGlobalSymbol(this.symbol));
1991
- if (this.subscriptions.length > 0) {
1992
- logger.info("disposing of %d subscriptions...", this.subscriptions.length);
1993
- for (const dispose of this.subscriptions) {
1994
- dispose();
1995
- }
1996
- this.subscriptions = [];
1997
- logger.info("disposed of all subscriptions!", this.subscriptions.length);
1998
- }
1999
- this.emitter.deactivate();
2000
- logger.info("destroyed the listener!");
2001
- this.readyState = "DISPOSED";
2002
- }
2003
- getInstance() {
2004
- var _a3;
2005
- const instance = getGlobalSymbol(this.symbol);
2006
- this.logger.info("retrieved global instance:", (_a3 = instance == null ? void 0 : instance.constructor) == null ? void 0 : _a3.name);
2007
- return instance;
2008
- }
2009
- setInstance() {
2010
- setGlobalSymbol(this.symbol, this);
2011
- this.logger.info("set global instance!", this.symbol.description);
2012
- }
2013
- clearInstance() {
2014
- deleteGlobalSymbol(this.symbol);
2015
- this.logger.info("cleared global instance!", this.symbol.description);
2016
- }
2017
- };
2018
-
2019
- // node_modules/.pnpm/@mswjs+interceptors@0.25.1/node_modules/@mswjs/interceptors/lib/node/chunk-VS3GJPUE.mjs
2020
- var BatchInterceptor = class extends Interceptor {
2021
- constructor(options) {
2022
- BatchInterceptor.symbol = Symbol(options.name);
2023
- super(BatchInterceptor.symbol);
2024
- this.interceptors = options.interceptors;
2025
- }
2026
- setup() {
2027
- const logger = this.logger.extend("setup");
2028
- logger.info("applying all %d interceptors...", this.interceptors.length);
2029
- for (const interceptor of this.interceptors) {
2030
- logger.info('applying "%s" interceptor...', interceptor.constructor.name);
2031
- interceptor.apply();
2032
- logger.info("adding interceptor dispose subscription");
2033
- this.subscriptions.push(() => interceptor.dispose());
1943
+ function isDate(val) {
1944
+ return __toString.call(val) === "[object Date]" || val instanceof Date;
2034
1945
  }
2035
- }
2036
- on(event, listener) {
2037
- this.interceptors.forEach((interceptor) => {
2038
- interceptor.on(event, listener);
2039
- });
2040
- }
2041
- };
2042
-
2043
- // node_modules/.pnpm/@mswjs+interceptors@0.25.1/node_modules/@mswjs/interceptors/lib/node/chunk-7II4SWKS.mjs
2044
- var encoder = new TextEncoder();
2045
-
2046
- // node_modules/.pnpm/@mswjs+interceptors@0.25.1/node_modules/@mswjs/interceptors/lib/node/chunk-GFH37L5D.mjs
2047
- var IS_PATCHED_MODULE = Symbol("isPatchedModule");
2048
-
2049
- // node_modules/.pnpm/@mswjs+interceptors@0.25.1/node_modules/@mswjs/interceptors/lib/node/index.mjs
2050
- function getCleanUrl(url, isAbsolute = true) {
2051
- return [isAbsolute && url.origin, url.pathname].filter(Boolean).join("");
2052
- }
2053
-
2054
- // src/core/utils/url/cleanUrl.ts
2055
- var REDUNDANT_CHARACTERS_EXP = /[\?|#].*$/g;
2056
- function getSearchParams(path) {
2057
- return new URL(`/${path}`, "http://localhost").searchParams;
2058
- }
2059
- function cleanUrl(path) {
2060
- return path.replace(REDUNDANT_CHARACTERS_EXP, "");
2061
- }
2062
-
2063
- // src/core/utils/url/isAbsoluteUrl.ts
2064
- function isAbsoluteUrl(url) {
2065
- return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url);
2066
- }
2067
-
2068
- // src/core/utils/url/getAbsoluteUrl.ts
2069
- function getAbsoluteUrl(path, baseUrl) {
2070
- if (isAbsoluteUrl(path)) {
2071
- return path;
2072
- }
2073
- if (path.startsWith("*")) {
2074
- return path;
2075
- }
2076
- const origin = baseUrl || typeof document !== "undefined" && document.baseURI;
2077
- return origin ? (
2078
- // Encode and decode the path to preserve escaped characters.
2079
- decodeURI(new URL(encodeURI(path), origin).href)
2080
- ) : path;
2081
- }
2082
-
2083
- // src/core/utils/matching/normalizePath.ts
2084
- function normalizePath(path, baseUrl) {
2085
- if (path instanceof RegExp) {
2086
- return path;
2087
- }
2088
- const maybeAbsoluteUrl = getAbsoluteUrl(path, baseUrl);
2089
- return cleanUrl(maybeAbsoluteUrl);
2090
- }
2091
-
2092
- // src/core/utils/matching/matchRequestUrl.ts
2093
- function coercePath(path) {
2094
- return path.replace(
2095
- /([:a-zA-Z_-]*)(\*{1,2})+/g,
2096
- (_, parameterName, wildcard) => {
2097
- const expression = "(.*)";
2098
- if (!parameterName) {
2099
- return expression;
1946
+ function tryDecode(str, decode2) {
1947
+ try {
1948
+ return decode2(str);
1949
+ } catch (e) {
1950
+ return str;
2100
1951
  }
2101
- return parameterName.startsWith(":") ? `${parameterName}${wildcard}` : `${parameterName}${expression}`;
2102
1952
  }
2103
- ).replace(/([^\/])(:)(?=\d+)/, "$1\\$2").replace(/^([^\/]+)(:)(?=\/\/)/, "$1\\$2");
2104
- }
2105
- function matchRequestUrl(url, path, baseUrl) {
2106
- const normalizedPath = normalizePath(path, baseUrl);
2107
- const cleanPath = typeof normalizedPath === "string" ? coercePath(normalizedPath) : normalizedPath;
2108
- const cleanUrl2 = getCleanUrl(url);
2109
- const result = match(cleanPath, { decode: decodeURIComponent })(cleanUrl2);
2110
- const params = result && result.params || {};
2111
- return {
2112
- matches: result !== false,
2113
- params
2114
- };
2115
- }
2116
-
2117
- // src/core/utils/request/getPublicUrlFromRequest.ts
2118
- function getPublicUrlFromRequest(request) {
2119
- if (typeof location === "undefined") {
2120
- return request.url;
2121
1953
  }
2122
- const url = new URL(request.url);
2123
- return url.origin === location.origin ? url.pathname : url.origin + url.pathname;
2124
- }
1954
+ });
1955
+ var import_cookie = __toESM2(require_cookie(), 1);
1956
+ var source_default2 = import_cookie.default;
2125
1957
 
2126
- // node_modules/.pnpm/@bundled-es-modules+cookie@2.0.0/node_modules/@bundled-es-modules/cookie/index-esm.js
1958
+ // node_modules/.pnpm/@mswjs+cookies@1.0.0/node_modules/@mswjs/cookies/lib/index.mjs
2127
1959
  var __create3 = Object.create;
2128
1960
  var __defProp5 = Object.defineProperty;
2129
1961
  var __getOwnPropDesc4 = Object.getOwnPropertyDescriptor;
@@ -2142,243 +1974,74 @@ var MockServiceWorker = (() => {
2142
1974
  return to;
2143
1975
  };
2144
1976
  var __toESM3 = (mod, isNodeMode, target) => (target = mod != null ? __create3(__getProtoOf3(mod)) : {}, __copyProps4(
2145
- // If the importer is in node compatibility mode or this is not an ESM
2146
- // file that has been converted to a CommonJS file using a Babel-
2147
- // compatible transform (i.e. "__esModule" has not been set), then set
2148
- // "default" to the CommonJS "module.exports" for node compatibility.
2149
1977
  isNodeMode || !mod || !mod.__esModule ? __defProp5(target, "default", { value: mod, enumerable: true }) : target,
2150
1978
  mod
2151
1979
  ));
2152
- var require_cookie = __commonJS3({
2153
- "node_modules/cookie/index.js"(exports) {
1980
+ var require_set_cookie = __commonJS3({
1981
+ "node_modules/set-cookie-parser/lib/set-cookie.js"(exports, module) {
2154
1982
  "use strict";
2155
- exports.parse = parse3;
2156
- exports.serialize = serialize;
2157
- var __toString = Object.prototype.toString;
2158
- var fieldContentRegExp = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;
2159
- function parse3(str, options) {
2160
- if (typeof str !== "string") {
2161
- throw new TypeError("argument str must be a string");
2162
- }
2163
- var obj = {};
2164
- var opt = options || {};
2165
- var dec = opt.decode || decode;
2166
- var index = 0;
2167
- while (index < str.length) {
2168
- var eqIdx = str.indexOf("=", index);
2169
- if (eqIdx === -1) {
2170
- break;
1983
+ var defaultParseOptions = {
1984
+ decodeValues: true,
1985
+ map: false,
1986
+ silent: false
1987
+ };
1988
+ function isNonEmptyString(str) {
1989
+ return typeof str === "string" && !!str.trim();
1990
+ }
1991
+ function parseString(setCookieValue, options) {
1992
+ var parts = setCookieValue.split(";").filter(isNonEmptyString);
1993
+ var nameValue = parts.shift().split("=");
1994
+ var name = nameValue.shift();
1995
+ var value = nameValue.join("=");
1996
+ options = options ? Object.assign({}, defaultParseOptions, options) : defaultParseOptions;
1997
+ var cookie = {
1998
+ name,
1999
+ value: options.decodeValues ? decodeURIComponent(value) : value
2000
+ };
2001
+ parts.forEach(function(part) {
2002
+ var sides = part.split("=");
2003
+ var key = sides.shift().trimLeft().toLowerCase();
2004
+ var value2 = sides.join("=");
2005
+ if (key === "expires") {
2006
+ cookie.expires = new Date(value2);
2007
+ } else if (key === "max-age") {
2008
+ cookie.maxAge = parseInt(value2, 10);
2009
+ } else if (key === "secure") {
2010
+ cookie.secure = true;
2011
+ } else if (key === "httponly") {
2012
+ cookie.httpOnly = true;
2013
+ } else if (key === "samesite") {
2014
+ cookie.sameSite = value2;
2015
+ } else {
2016
+ cookie[key] = value2;
2171
2017
  }
2172
- var endIdx = str.indexOf(";", index);
2173
- if (endIdx === -1) {
2174
- endIdx = str.length;
2175
- } else if (endIdx < eqIdx) {
2176
- index = str.lastIndexOf(";", eqIdx - 1) + 1;
2177
- continue;
2018
+ });
2019
+ return cookie;
2020
+ }
2021
+ function parse3(input, options) {
2022
+ options = options ? Object.assign({}, defaultParseOptions, options) : defaultParseOptions;
2023
+ if (!input) {
2024
+ if (!options.map) {
2025
+ return [];
2026
+ } else {
2027
+ return {};
2178
2028
  }
2179
- var key = str.slice(index, eqIdx).trim();
2180
- if (void 0 === obj[key]) {
2181
- var val = str.slice(eqIdx + 1, endIdx).trim();
2182
- if (val.charCodeAt(0) === 34) {
2183
- val = val.slice(1, -1);
2184
- }
2185
- obj[key] = tryDecode(val, dec);
2029
+ }
2030
+ if (input.headers && input.headers["set-cookie"]) {
2031
+ input = input.headers["set-cookie"];
2032
+ } else if (input.headers) {
2033
+ var sch = input.headers[Object.keys(input.headers).find(function(key) {
2034
+ return key.toLowerCase() === "set-cookie";
2035
+ })];
2036
+ if (!sch && input.headers.cookie && !options.silent) {
2037
+ console.warn(
2038
+ "Warning: set-cookie-parser appears to have been called on a request object. It is designed to parse Set-Cookie headers from responses, not Cookie headers from requests. Set the option {silent: true} to suppress this warning."
2039
+ );
2186
2040
  }
2187
- index = endIdx + 1;
2041
+ input = sch;
2188
2042
  }
2189
- return obj;
2190
- }
2191
- function serialize(name, val, options) {
2192
- var opt = options || {};
2193
- var enc = opt.encode || encode;
2194
- if (typeof enc !== "function") {
2195
- throw new TypeError("option encode is invalid");
2196
- }
2197
- if (!fieldContentRegExp.test(name)) {
2198
- throw new TypeError("argument name is invalid");
2199
- }
2200
- var value = enc(val);
2201
- if (value && !fieldContentRegExp.test(value)) {
2202
- throw new TypeError("argument val is invalid");
2203
- }
2204
- var str = name + "=" + value;
2205
- if (null != opt.maxAge) {
2206
- var maxAge = opt.maxAge - 0;
2207
- if (isNaN(maxAge) || !isFinite(maxAge)) {
2208
- throw new TypeError("option maxAge is invalid");
2209
- }
2210
- str += "; Max-Age=" + Math.floor(maxAge);
2211
- }
2212
- if (opt.domain) {
2213
- if (!fieldContentRegExp.test(opt.domain)) {
2214
- throw new TypeError("option domain is invalid");
2215
- }
2216
- str += "; Domain=" + opt.domain;
2217
- }
2218
- if (opt.path) {
2219
- if (!fieldContentRegExp.test(opt.path)) {
2220
- throw new TypeError("option path is invalid");
2221
- }
2222
- str += "; Path=" + opt.path;
2223
- }
2224
- if (opt.expires) {
2225
- var expires = opt.expires;
2226
- if (!isDate(expires) || isNaN(expires.valueOf())) {
2227
- throw new TypeError("option expires is invalid");
2228
- }
2229
- str += "; Expires=" + expires.toUTCString();
2230
- }
2231
- if (opt.httpOnly) {
2232
- str += "; HttpOnly";
2233
- }
2234
- if (opt.secure) {
2235
- str += "; Secure";
2236
- }
2237
- if (opt.priority) {
2238
- var priority = typeof opt.priority === "string" ? opt.priority.toLowerCase() : opt.priority;
2239
- switch (priority) {
2240
- case "low":
2241
- str += "; Priority=Low";
2242
- break;
2243
- case "medium":
2244
- str += "; Priority=Medium";
2245
- break;
2246
- case "high":
2247
- str += "; Priority=High";
2248
- break;
2249
- default:
2250
- throw new TypeError("option priority is invalid");
2251
- }
2252
- }
2253
- if (opt.sameSite) {
2254
- var sameSite = typeof opt.sameSite === "string" ? opt.sameSite.toLowerCase() : opt.sameSite;
2255
- switch (sameSite) {
2256
- case true:
2257
- str += "; SameSite=Strict";
2258
- break;
2259
- case "lax":
2260
- str += "; SameSite=Lax";
2261
- break;
2262
- case "strict":
2263
- str += "; SameSite=Strict";
2264
- break;
2265
- case "none":
2266
- str += "; SameSite=None";
2267
- break;
2268
- default:
2269
- throw new TypeError("option sameSite is invalid");
2270
- }
2271
- }
2272
- return str;
2273
- }
2274
- function decode(str) {
2275
- return str.indexOf("%") !== -1 ? decodeURIComponent(str) : str;
2276
- }
2277
- function encode(val) {
2278
- return encodeURIComponent(val);
2279
- }
2280
- function isDate(val) {
2281
- return __toString.call(val) === "[object Date]" || val instanceof Date;
2282
- }
2283
- function tryDecode(str, decode2) {
2284
- try {
2285
- return decode2(str);
2286
- } catch (e) {
2287
- return str;
2288
- }
2289
- }
2290
- }
2291
- });
2292
- var import_cookie = __toESM3(require_cookie(), 1);
2293
- var source_default2 = import_cookie.default;
2294
-
2295
- // node_modules/.pnpm/@mswjs+cookies@1.0.0/node_modules/@mswjs/cookies/lib/index.mjs
2296
- var __create4 = Object.create;
2297
- var __defProp6 = Object.defineProperty;
2298
- var __getOwnPropDesc5 = Object.getOwnPropertyDescriptor;
2299
- var __getOwnPropNames5 = Object.getOwnPropertyNames;
2300
- var __getProtoOf4 = Object.getPrototypeOf;
2301
- var __hasOwnProp5 = Object.prototype.hasOwnProperty;
2302
- var __commonJS4 = (cb, mod) => function __require() {
2303
- return mod || (0, cb[__getOwnPropNames5(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
2304
- };
2305
- var __copyProps5 = (to, from, except, desc) => {
2306
- if (from && typeof from === "object" || typeof from === "function") {
2307
- for (let key of __getOwnPropNames5(from))
2308
- if (!__hasOwnProp5.call(to, key) && key !== except)
2309
- __defProp6(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc5(from, key)) || desc.enumerable });
2310
- }
2311
- return to;
2312
- };
2313
- var __toESM4 = (mod, isNodeMode, target) => (target = mod != null ? __create4(__getProtoOf4(mod)) : {}, __copyProps5(
2314
- isNodeMode || !mod || !mod.__esModule ? __defProp6(target, "default", { value: mod, enumerable: true }) : target,
2315
- mod
2316
- ));
2317
- var require_set_cookie2 = __commonJS4({
2318
- "node_modules/set-cookie-parser/lib/set-cookie.js"(exports, module) {
2319
- "use strict";
2320
- var defaultParseOptions = {
2321
- decodeValues: true,
2322
- map: false,
2323
- silent: false
2324
- };
2325
- function isNonEmptyString(str) {
2326
- return typeof str === "string" && !!str.trim();
2327
- }
2328
- function parseString(setCookieValue, options) {
2329
- var parts = setCookieValue.split(";").filter(isNonEmptyString);
2330
- var nameValue = parts.shift().split("=");
2331
- var name = nameValue.shift();
2332
- var value = nameValue.join("=");
2333
- options = options ? Object.assign({}, defaultParseOptions, options) : defaultParseOptions;
2334
- var cookie = {
2335
- name,
2336
- value: options.decodeValues ? decodeURIComponent(value) : value
2337
- };
2338
- parts.forEach(function(part) {
2339
- var sides = part.split("=");
2340
- var key = sides.shift().trimLeft().toLowerCase();
2341
- var value2 = sides.join("=");
2342
- if (key === "expires") {
2343
- cookie.expires = new Date(value2);
2344
- } else if (key === "max-age") {
2345
- cookie.maxAge = parseInt(value2, 10);
2346
- } else if (key === "secure") {
2347
- cookie.secure = true;
2348
- } else if (key === "httponly") {
2349
- cookie.httpOnly = true;
2350
- } else if (key === "samesite") {
2351
- cookie.sameSite = value2;
2352
- } else {
2353
- cookie[key] = value2;
2354
- }
2355
- });
2356
- return cookie;
2357
- }
2358
- function parse3(input, options) {
2359
- options = options ? Object.assign({}, defaultParseOptions, options) : defaultParseOptions;
2360
- if (!input) {
2361
- if (!options.map) {
2362
- return [];
2363
- } else {
2364
- return {};
2365
- }
2366
- }
2367
- if (input.headers && input.headers["set-cookie"]) {
2368
- input = input.headers["set-cookie"];
2369
- } else if (input.headers) {
2370
- var sch = input.headers[Object.keys(input.headers).find(function(key) {
2371
- return key.toLowerCase() === "set-cookie";
2372
- })];
2373
- if (!sch && input.headers.cookie && !options.silent) {
2374
- console.warn(
2375
- "Warning: set-cookie-parser appears to have been called on a request object. It is designed to parse Set-Cookie headers from responses, not Cookie headers from requests. Set the option {silent: true} to suppress this warning."
2376
- );
2377
- }
2378
- input = sch;
2379
- }
2380
- if (!Array.isArray(input)) {
2381
- input = [input];
2043
+ if (!Array.isArray(input)) {
2044
+ input = [input];
2382
2045
  }
2383
2046
  options = options ? Object.assign({}, defaultParseOptions, options) : defaultParseOptions;
2384
2047
  if (!options.map) {
@@ -2455,7 +2118,7 @@ var MockServiceWorker = (() => {
2455
2118
  module.exports.splitCookiesString = splitCookiesString;
2456
2119
  }
2457
2120
  });
2458
- var import_set_cookie_parser2 = __toESM4(require_set_cookie2());
2121
+ var import_set_cookie_parser = __toESM3(require_set_cookie());
2459
2122
  var PERSISTENCY_KEY = "MSW_COOKIE_STORE";
2460
2123
  function supportsLocalStorage() {
2461
2124
  try {
@@ -2485,7 +2148,7 @@ var MockServiceWorker = (() => {
2485
2148
  return;
2486
2149
  }
2487
2150
  const now = Date.now();
2488
- const parsedResponseCookies = (0, import_set_cookie_parser2.parse)(responseCookies).map(
2151
+ const parsedResponseCookies = (0, import_set_cookie_parser.parse)(responseCookies).map(
2489
2152
  (_a3) => {
2490
2153
  var _b2 = _a3, { maxAge } = _b2, cookie = __objRest(_b2, ["maxAge"]);
2491
2154
  return __spreadProps(__spreadValues({}, cookie), {
@@ -2508,7 +2171,7 @@ var MockServiceWorker = (() => {
2508
2171
  if (typeof document === "undefined") {
2509
2172
  return originCookies;
2510
2173
  }
2511
- const documentCookies = (0, import_set_cookie_parser2.parse)(document.cookie);
2174
+ const documentCookies = (0, import_set_cookie_parser.parse)(document.cookie);
2512
2175
  documentCookies.forEach((cookie) => {
2513
2176
  originCookies.set(cookie.name, cookie);
2514
2177
  });
@@ -2657,7 +2320,7 @@ Invalid value has been removed from localStorage to prevent subsequent failed pa
2657
2320
  method
2658
2321
  },
2659
2322
  resolver,
2660
- once: options == null ? void 0 : options.once
2323
+ options
2661
2324
  });
2662
2325
  this.checkRedundantQueryParameters();
2663
2326
  }
@@ -2679,46 +2342,47 @@ Invalid value has been removed from localStorage to prevent subsequent failed pa
2679
2342
  `Found a redundant usage of query parameters in the request handler URL for "${method} ${path}". Please match against a path instead and access query parameters in the response resolver function using "req.url.searchParams".`
2680
2343
  );
2681
2344
  }
2682
- parse(request, resolutionContext) {
2345
+ parse(args) {
2683
2346
  return __async(this, null, function* () {
2684
- const url = new URL(request.url);
2347
+ var _a3;
2348
+ const url = new URL(args.request.url);
2685
2349
  const match2 = matchRequestUrl(
2686
2350
  url,
2687
2351
  this.info.path,
2688
- resolutionContext == null ? void 0 : resolutionContext.baseUrl
2352
+ (_a3 = args.resolutionContext) == null ? void 0 : _a3.baseUrl
2689
2353
  );
2690
- const cookies = getAllRequestCookies(request);
2354
+ const cookies = getAllRequestCookies(args.request);
2691
2355
  return {
2692
2356
  match: match2,
2693
2357
  cookies
2694
2358
  };
2695
2359
  });
2696
2360
  }
2697
- predicate(request, parsedResult) {
2698
- const hasMatchingMethod = this.matchMethod(request.method);
2699
- const hasMatchingUrl = parsedResult.match.matches;
2361
+ predicate(args) {
2362
+ const hasMatchingMethod = this.matchMethod(args.request.method);
2363
+ const hasMatchingUrl = args.parsedResult.match.matches;
2700
2364
  return hasMatchingMethod && hasMatchingUrl;
2701
2365
  }
2702
2366
  matchMethod(actualMethod) {
2703
2367
  return this.info.method instanceof RegExp ? this.info.method.test(actualMethod) : isStringEqual(this.info.method, actualMethod);
2704
2368
  }
2705
- extendInfo(_request, parsedResult) {
2369
+ extendResolverArgs(args) {
2706
2370
  var _a3;
2707
2371
  return {
2708
- params: ((_a3 = parsedResult.match) == null ? void 0 : _a3.params) || {},
2709
- cookies: parsedResult.cookies
2372
+ params: ((_a3 = args.parsedResult.match) == null ? void 0 : _a3.params) || {},
2373
+ cookies: args.parsedResult.cookies
2710
2374
  };
2711
2375
  }
2712
- log(request, response) {
2376
+ log(args) {
2713
2377
  return __async(this, null, function* () {
2714
- const publicUrl = getPublicUrlFromRequest(request);
2715
- const loggedRequest = yield serializeRequest(request);
2716
- const loggedResponse = yield serializeResponse(response);
2378
+ const publicUrl = getPublicUrlFromRequest(args.request);
2379
+ const loggedRequest = yield serializeRequest(args.request);
2380
+ const loggedResponse = yield serializeResponse(args.response);
2717
2381
  const statusColor = getStatusCodeColor(loggedResponse.status);
2718
2382
  console.groupCollapsed(
2719
2383
  devUtils.formatMessage("%s %s %s (%c%s%c)"),
2720
2384
  getTimestamp(),
2721
- request.method,
2385
+ args.request.method,
2722
2386
  publicUrl,
2723
2387
  `color:${statusColor}`,
2724
2388
  `${loggedResponse.status} ${loggedResponse.statusText}`,
@@ -2749,7 +2413,7 @@ Invalid value has been removed from localStorage to prevent subsequent failed pa
2749
2413
  options: createHttpHandler("OPTIONS" /* OPTIONS */)
2750
2414
  };
2751
2415
 
2752
- // node_modules/.pnpm/graphql@16.8.0/node_modules/graphql/jsutils/devAssert.mjs
2416
+ // node_modules/.pnpm/graphql@16.8.1/node_modules/graphql/jsutils/devAssert.mjs
2753
2417
  function devAssert(condition, message3) {
2754
2418
  const booleanCondition = Boolean(condition);
2755
2419
  if (!booleanCondition) {
@@ -2757,12 +2421,12 @@ Invalid value has been removed from localStorage to prevent subsequent failed pa
2757
2421
  }
2758
2422
  }
2759
2423
 
2760
- // node_modules/.pnpm/graphql@16.8.0/node_modules/graphql/jsutils/isObjectLike.mjs
2424
+ // node_modules/.pnpm/graphql@16.8.1/node_modules/graphql/jsutils/isObjectLike.mjs
2761
2425
  function isObjectLike(value) {
2762
2426
  return typeof value == "object" && value !== null;
2763
2427
  }
2764
2428
 
2765
- // node_modules/.pnpm/graphql@16.8.0/node_modules/graphql/jsutils/invariant.mjs
2429
+ // node_modules/.pnpm/graphql@16.8.1/node_modules/graphql/jsutils/invariant.mjs
2766
2430
  function invariant2(condition, message3) {
2767
2431
  const booleanCondition = Boolean(condition);
2768
2432
  if (!booleanCondition) {
@@ -2772,7 +2436,7 @@ Invalid value has been removed from localStorage to prevent subsequent failed pa
2772
2436
  }
2773
2437
  }
2774
2438
 
2775
- // node_modules/.pnpm/graphql@16.8.0/node_modules/graphql/language/location.mjs
2439
+ // node_modules/.pnpm/graphql@16.8.1/node_modules/graphql/language/location.mjs
2776
2440
  var LineRegExp = /\r\n|[\n\r]/g;
2777
2441
  function getLocation(source, position) {
2778
2442
  let lastLineStart = 0;
@@ -2791,7 +2455,7 @@ Invalid value has been removed from localStorage to prevent subsequent failed pa
2791
2455
  };
2792
2456
  }
2793
2457
 
2794
- // node_modules/.pnpm/graphql@16.8.0/node_modules/graphql/language/printLocation.mjs
2458
+ // node_modules/.pnpm/graphql@16.8.1/node_modules/graphql/language/printLocation.mjs
2795
2459
  function printLocation(location2) {
2796
2460
  return printSourceLocation(
2797
2461
  location2.source,
@@ -2838,7 +2502,7 @@ Invalid value has been removed from localStorage to prevent subsequent failed pa
2838
2502
  return existingLines.map(([prefix, line]) => prefix.padStart(padLen) + (line ? " " + line : "")).join("\n");
2839
2503
  }
2840
2504
 
2841
- // node_modules/.pnpm/graphql@16.8.0/node_modules/graphql/error/GraphQLError.mjs
2505
+ // node_modules/.pnpm/graphql@16.8.1/node_modules/graphql/error/GraphQLError.mjs
2842
2506
  function toNormalizedOptions(args) {
2843
2507
  const firstArg = args[0];
2844
2508
  if (firstArg == null || "kind" in firstArg || "length" in firstArg) {
@@ -2987,7 +2651,7 @@ Invalid value has been removed from localStorage to prevent subsequent failed pa
2987
2651
  return array === void 0 || array.length === 0 ? void 0 : array;
2988
2652
  }
2989
2653
 
2990
- // node_modules/.pnpm/graphql@16.8.0/node_modules/graphql/error/syntaxError.mjs
2654
+ // node_modules/.pnpm/graphql@16.8.1/node_modules/graphql/error/syntaxError.mjs
2991
2655
  function syntaxError(source, position, description) {
2992
2656
  return new GraphQLError(`Syntax Error: ${description}`, {
2993
2657
  source,
@@ -2995,7 +2659,7 @@ Invalid value has been removed from localStorage to prevent subsequent failed pa
2995
2659
  });
2996
2660
  }
2997
2661
 
2998
- // node_modules/.pnpm/graphql@16.8.0/node_modules/graphql/language/ast.mjs
2662
+ // node_modules/.pnpm/graphql@16.8.1/node_modules/graphql/language/ast.mjs
2999
2663
  var Location = class {
3000
2664
  /**
3001
2665
  * The character offset at which this Node begins.
@@ -3161,7 +2825,7 @@ Invalid value has been removed from localStorage to prevent subsequent failed pa
3161
2825
  OperationTypeNode2["SUBSCRIPTION"] = "subscription";
3162
2826
  })(OperationTypeNode || (OperationTypeNode = {}));
3163
2827
 
3164
- // node_modules/.pnpm/graphql@16.8.0/node_modules/graphql/language/directiveLocation.mjs
2828
+ // node_modules/.pnpm/graphql@16.8.1/node_modules/graphql/language/directiveLocation.mjs
3165
2829
  var DirectiveLocation;
3166
2830
  (function(DirectiveLocation2) {
3167
2831
  DirectiveLocation2["QUERY"] = "QUERY";
@@ -3185,7 +2849,7 @@ Invalid value has been removed from localStorage to prevent subsequent failed pa
3185
2849
  DirectiveLocation2["INPUT_FIELD_DEFINITION"] = "INPUT_FIELD_DEFINITION";
3186
2850
  })(DirectiveLocation || (DirectiveLocation = {}));
3187
2851
 
3188
- // node_modules/.pnpm/graphql@16.8.0/node_modules/graphql/language/kinds.mjs
2852
+ // node_modules/.pnpm/graphql@16.8.1/node_modules/graphql/language/kinds.mjs
3189
2853
  var Kind;
3190
2854
  (function(Kind2) {
3191
2855
  Kind2["NAME"] = "Name";
@@ -3233,7 +2897,7 @@ Invalid value has been removed from localStorage to prevent subsequent failed pa
3233
2897
  Kind2["INPUT_OBJECT_TYPE_EXTENSION"] = "InputObjectTypeExtension";
3234
2898
  })(Kind || (Kind = {}));
3235
2899
 
3236
- // node_modules/.pnpm/graphql@16.8.0/node_modules/graphql/language/characterClasses.mjs
2900
+ // node_modules/.pnpm/graphql@16.8.1/node_modules/graphql/language/characterClasses.mjs
3237
2901
  function isWhiteSpace(code) {
3238
2902
  return code === 9 || code === 32;
3239
2903
  }
@@ -3251,7 +2915,7 @@ Invalid value has been removed from localStorage to prevent subsequent failed pa
3251
2915
  return isLetter(code) || isDigit(code) || code === 95;
3252
2916
  }
3253
2917
 
3254
- // node_modules/.pnpm/graphql@16.8.0/node_modules/graphql/language/blockString.mjs
2918
+ // node_modules/.pnpm/graphql@16.8.1/node_modules/graphql/language/blockString.mjs
3255
2919
  function dedentBlockStringLines(lines) {
3256
2920
  var _firstNonEmptyLine2;
3257
2921
  let commonIndent = Number.MAX_SAFE_INTEGER;
@@ -3283,7 +2947,7 @@ Invalid value has been removed from localStorage to prevent subsequent failed pa
3283
2947
  return i;
3284
2948
  }
3285
2949
 
3286
- // node_modules/.pnpm/graphql@16.8.0/node_modules/graphql/language/tokenKind.mjs
2950
+ // node_modules/.pnpm/graphql@16.8.1/node_modules/graphql/language/tokenKind.mjs
3287
2951
  var TokenKind;
3288
2952
  (function(TokenKind2) {
3289
2953
  TokenKind2["SOF"] = "<SOF>";
@@ -3310,7 +2974,7 @@ Invalid value has been removed from localStorage to prevent subsequent failed pa
3310
2974
  TokenKind2["COMMENT"] = "Comment";
3311
2975
  })(TokenKind || (TokenKind = {}));
3312
2976
 
3313
- // node_modules/.pnpm/graphql@16.8.0/node_modules/graphql/language/lexer.mjs
2977
+ // node_modules/.pnpm/graphql@16.8.1/node_modules/graphql/language/lexer.mjs
3314
2978
  var Lexer = class {
3315
2979
  /**
3316
2980
  * The previously focused non-ignored token.
@@ -3811,7 +3475,7 @@ Invalid value has been removed from localStorage to prevent subsequent failed pa
3811
3475
  );
3812
3476
  }
3813
3477
 
3814
- // node_modules/.pnpm/graphql@16.8.0/node_modules/graphql/jsutils/inspect.mjs
3478
+ // node_modules/.pnpm/graphql@16.8.1/node_modules/graphql/jsutils/inspect.mjs
3815
3479
  var MAX_ARRAY_LENGTH = 10;
3816
3480
  var MAX_RECURSIVE_DEPTH = 2;
3817
3481
  function inspect(value) {
@@ -3894,7 +3558,7 @@ Invalid value has been removed from localStorage to prevent subsequent failed pa
3894
3558
  return tag;
3895
3559
  }
3896
3560
 
3897
- // node_modules/.pnpm/graphql@16.8.0/node_modules/graphql/jsutils/instanceOf.mjs
3561
+ // node_modules/.pnpm/graphql@16.8.1/node_modules/graphql/jsutils/instanceOf.mjs
3898
3562
  var instanceOf = (
3899
3563
  /* c8 ignore next 6 */
3900
3564
  // FIXME: https://github.com/graphql/graphql-js/issues/2317
@@ -3931,7 +3595,7 @@ spurious results.`);
3931
3595
  }
3932
3596
  );
3933
3597
 
3934
- // node_modules/.pnpm/graphql@16.8.0/node_modules/graphql/language/source.mjs
3598
+ // node_modules/.pnpm/graphql@16.8.1/node_modules/graphql/language/source.mjs
3935
3599
  var Source = class {
3936
3600
  constructor(body, name = "GraphQL request", locationOffset = {
3937
3601
  line: 1,
@@ -3958,7 +3622,7 @@ spurious results.`);
3958
3622
  return instanceOf(source, Source);
3959
3623
  }
3960
3624
 
3961
- // node_modules/.pnpm/graphql@16.8.0/node_modules/graphql/language/parser.mjs
3625
+ // node_modules/.pnpm/graphql@16.8.1/node_modules/graphql/language/parser.mjs
3962
3626
  function parse2(source, options) {
3963
3627
  const parser = new Parser(source, options);
3964
3628
  return parser.parseDocument();
@@ -4809,411 +4473,836 @@ spurious results.`);
4809
4473
  return this.parseInputObjectTypeExtension();
4810
4474
  }
4811
4475
  }
4812
- throw this.unexpected(keywordToken);
4476
+ throw this.unexpected(keywordToken);
4477
+ }
4478
+ /**
4479
+ * ```
4480
+ * SchemaExtension :
4481
+ * - extend schema Directives[Const]? { OperationTypeDefinition+ }
4482
+ * - extend schema Directives[Const]
4483
+ * ```
4484
+ */
4485
+ parseSchemaExtension() {
4486
+ const start = this._lexer.token;
4487
+ this.expectKeyword("extend");
4488
+ this.expectKeyword("schema");
4489
+ const directives = this.parseConstDirectives();
4490
+ const operationTypes = this.optionalMany(
4491
+ TokenKind.BRACE_L,
4492
+ this.parseOperationTypeDefinition,
4493
+ TokenKind.BRACE_R
4494
+ );
4495
+ if (directives.length === 0 && operationTypes.length === 0) {
4496
+ throw this.unexpected();
4497
+ }
4498
+ return this.node(start, {
4499
+ kind: Kind.SCHEMA_EXTENSION,
4500
+ directives,
4501
+ operationTypes
4502
+ });
4503
+ }
4504
+ /**
4505
+ * ScalarTypeExtension :
4506
+ * - extend scalar Name Directives[Const]
4507
+ */
4508
+ parseScalarTypeExtension() {
4509
+ const start = this._lexer.token;
4510
+ this.expectKeyword("extend");
4511
+ this.expectKeyword("scalar");
4512
+ const name = this.parseName();
4513
+ const directives = this.parseConstDirectives();
4514
+ if (directives.length === 0) {
4515
+ throw this.unexpected();
4516
+ }
4517
+ return this.node(start, {
4518
+ kind: Kind.SCALAR_TYPE_EXTENSION,
4519
+ name,
4520
+ directives
4521
+ });
4522
+ }
4523
+ /**
4524
+ * ObjectTypeExtension :
4525
+ * - extend type Name ImplementsInterfaces? Directives[Const]? FieldsDefinition
4526
+ * - extend type Name ImplementsInterfaces? Directives[Const]
4527
+ * - extend type Name ImplementsInterfaces
4528
+ */
4529
+ parseObjectTypeExtension() {
4530
+ const start = this._lexer.token;
4531
+ this.expectKeyword("extend");
4532
+ this.expectKeyword("type");
4533
+ const name = this.parseName();
4534
+ const interfaces = this.parseImplementsInterfaces();
4535
+ const directives = this.parseConstDirectives();
4536
+ const fields = this.parseFieldsDefinition();
4537
+ if (interfaces.length === 0 && directives.length === 0 && fields.length === 0) {
4538
+ throw this.unexpected();
4539
+ }
4540
+ return this.node(start, {
4541
+ kind: Kind.OBJECT_TYPE_EXTENSION,
4542
+ name,
4543
+ interfaces,
4544
+ directives,
4545
+ fields
4546
+ });
4547
+ }
4548
+ /**
4549
+ * InterfaceTypeExtension :
4550
+ * - extend interface Name ImplementsInterfaces? Directives[Const]? FieldsDefinition
4551
+ * - extend interface Name ImplementsInterfaces? Directives[Const]
4552
+ * - extend interface Name ImplementsInterfaces
4553
+ */
4554
+ parseInterfaceTypeExtension() {
4555
+ const start = this._lexer.token;
4556
+ this.expectKeyword("extend");
4557
+ this.expectKeyword("interface");
4558
+ const name = this.parseName();
4559
+ const interfaces = this.parseImplementsInterfaces();
4560
+ const directives = this.parseConstDirectives();
4561
+ const fields = this.parseFieldsDefinition();
4562
+ if (interfaces.length === 0 && directives.length === 0 && fields.length === 0) {
4563
+ throw this.unexpected();
4564
+ }
4565
+ return this.node(start, {
4566
+ kind: Kind.INTERFACE_TYPE_EXTENSION,
4567
+ name,
4568
+ interfaces,
4569
+ directives,
4570
+ fields
4571
+ });
4572
+ }
4573
+ /**
4574
+ * UnionTypeExtension :
4575
+ * - extend union Name Directives[Const]? UnionMemberTypes
4576
+ * - extend union Name Directives[Const]
4577
+ */
4578
+ parseUnionTypeExtension() {
4579
+ const start = this._lexer.token;
4580
+ this.expectKeyword("extend");
4581
+ this.expectKeyword("union");
4582
+ const name = this.parseName();
4583
+ const directives = this.parseConstDirectives();
4584
+ const types = this.parseUnionMemberTypes();
4585
+ if (directives.length === 0 && types.length === 0) {
4586
+ throw this.unexpected();
4587
+ }
4588
+ return this.node(start, {
4589
+ kind: Kind.UNION_TYPE_EXTENSION,
4590
+ name,
4591
+ directives,
4592
+ types
4593
+ });
4594
+ }
4595
+ /**
4596
+ * EnumTypeExtension :
4597
+ * - extend enum Name Directives[Const]? EnumValuesDefinition
4598
+ * - extend enum Name Directives[Const]
4599
+ */
4600
+ parseEnumTypeExtension() {
4601
+ const start = this._lexer.token;
4602
+ this.expectKeyword("extend");
4603
+ this.expectKeyword("enum");
4604
+ const name = this.parseName();
4605
+ const directives = this.parseConstDirectives();
4606
+ const values = this.parseEnumValuesDefinition();
4607
+ if (directives.length === 0 && values.length === 0) {
4608
+ throw this.unexpected();
4609
+ }
4610
+ return this.node(start, {
4611
+ kind: Kind.ENUM_TYPE_EXTENSION,
4612
+ name,
4613
+ directives,
4614
+ values
4615
+ });
4616
+ }
4617
+ /**
4618
+ * InputObjectTypeExtension :
4619
+ * - extend input Name Directives[Const]? InputFieldsDefinition
4620
+ * - extend input Name Directives[Const]
4621
+ */
4622
+ parseInputObjectTypeExtension() {
4623
+ const start = this._lexer.token;
4624
+ this.expectKeyword("extend");
4625
+ this.expectKeyword("input");
4626
+ const name = this.parseName();
4627
+ const directives = this.parseConstDirectives();
4628
+ const fields = this.parseInputFieldsDefinition();
4629
+ if (directives.length === 0 && fields.length === 0) {
4630
+ throw this.unexpected();
4631
+ }
4632
+ return this.node(start, {
4633
+ kind: Kind.INPUT_OBJECT_TYPE_EXTENSION,
4634
+ name,
4635
+ directives,
4636
+ fields
4637
+ });
4638
+ }
4639
+ /**
4640
+ * ```
4641
+ * DirectiveDefinition :
4642
+ * - Description? directive @ Name ArgumentsDefinition? `repeatable`? on DirectiveLocations
4643
+ * ```
4644
+ */
4645
+ parseDirectiveDefinition() {
4646
+ const start = this._lexer.token;
4647
+ const description = this.parseDescription();
4648
+ this.expectKeyword("directive");
4649
+ this.expectToken(TokenKind.AT);
4650
+ const name = this.parseName();
4651
+ const args = this.parseArgumentDefs();
4652
+ const repeatable = this.expectOptionalKeyword("repeatable");
4653
+ this.expectKeyword("on");
4654
+ const locations = this.parseDirectiveLocations();
4655
+ return this.node(start, {
4656
+ kind: Kind.DIRECTIVE_DEFINITION,
4657
+ description,
4658
+ name,
4659
+ arguments: args,
4660
+ repeatable,
4661
+ locations
4662
+ });
4663
+ }
4664
+ /**
4665
+ * DirectiveLocations :
4666
+ * - `|`? DirectiveLocation
4667
+ * - DirectiveLocations | DirectiveLocation
4668
+ */
4669
+ parseDirectiveLocations() {
4670
+ return this.delimitedMany(TokenKind.PIPE, this.parseDirectiveLocation);
4671
+ }
4672
+ /*
4673
+ * DirectiveLocation :
4674
+ * - ExecutableDirectiveLocation
4675
+ * - TypeSystemDirectiveLocation
4676
+ *
4677
+ * ExecutableDirectiveLocation : one of
4678
+ * `QUERY`
4679
+ * `MUTATION`
4680
+ * `SUBSCRIPTION`
4681
+ * `FIELD`
4682
+ * `FRAGMENT_DEFINITION`
4683
+ * `FRAGMENT_SPREAD`
4684
+ * `INLINE_FRAGMENT`
4685
+ *
4686
+ * TypeSystemDirectiveLocation : one of
4687
+ * `SCHEMA`
4688
+ * `SCALAR`
4689
+ * `OBJECT`
4690
+ * `FIELD_DEFINITION`
4691
+ * `ARGUMENT_DEFINITION`
4692
+ * `INTERFACE`
4693
+ * `UNION`
4694
+ * `ENUM`
4695
+ * `ENUM_VALUE`
4696
+ * `INPUT_OBJECT`
4697
+ * `INPUT_FIELD_DEFINITION`
4698
+ */
4699
+ parseDirectiveLocation() {
4700
+ const start = this._lexer.token;
4701
+ const name = this.parseName();
4702
+ if (Object.prototype.hasOwnProperty.call(DirectiveLocation, name.value)) {
4703
+ return name;
4704
+ }
4705
+ throw this.unexpected(start);
4706
+ }
4707
+ // Core parsing utility functions
4708
+ /**
4709
+ * Returns a node that, if configured to do so, sets a "loc" field as a
4710
+ * location object, used to identify the place in the source that created a
4711
+ * given parsed object.
4712
+ */
4713
+ node(startToken, node) {
4714
+ if (this._options.noLocation !== true) {
4715
+ node.loc = new Location(
4716
+ startToken,
4717
+ this._lexer.lastToken,
4718
+ this._lexer.source
4719
+ );
4720
+ }
4721
+ return node;
4722
+ }
4723
+ /**
4724
+ * Determines if the next token is of a given kind
4725
+ */
4726
+ peek(kind) {
4727
+ return this._lexer.token.kind === kind;
4728
+ }
4729
+ /**
4730
+ * If the next token is of the given kind, return that token after advancing the lexer.
4731
+ * Otherwise, do not change the parser state and throw an error.
4732
+ */
4733
+ expectToken(kind) {
4734
+ const token = this._lexer.token;
4735
+ if (token.kind === kind) {
4736
+ this.advanceLexer();
4737
+ return token;
4738
+ }
4739
+ throw syntaxError(
4740
+ this._lexer.source,
4741
+ token.start,
4742
+ `Expected ${getTokenKindDesc(kind)}, found ${getTokenDesc(token)}.`
4743
+ );
4744
+ }
4745
+ /**
4746
+ * If the next token is of the given kind, return "true" after advancing the lexer.
4747
+ * Otherwise, do not change the parser state and return "false".
4748
+ */
4749
+ expectOptionalToken(kind) {
4750
+ const token = this._lexer.token;
4751
+ if (token.kind === kind) {
4752
+ this.advanceLexer();
4753
+ return true;
4754
+ }
4755
+ return false;
4756
+ }
4757
+ /**
4758
+ * If the next token is a given keyword, advance the lexer.
4759
+ * Otherwise, do not change the parser state and throw an error.
4760
+ */
4761
+ expectKeyword(value) {
4762
+ const token = this._lexer.token;
4763
+ if (token.kind === TokenKind.NAME && token.value === value) {
4764
+ this.advanceLexer();
4765
+ } else {
4766
+ throw syntaxError(
4767
+ this._lexer.source,
4768
+ token.start,
4769
+ `Expected "${value}", found ${getTokenDesc(token)}.`
4770
+ );
4771
+ }
4772
+ }
4773
+ /**
4774
+ * If the next token is a given keyword, return "true" after advancing the lexer.
4775
+ * Otherwise, do not change the parser state and return "false".
4776
+ */
4777
+ expectOptionalKeyword(value) {
4778
+ const token = this._lexer.token;
4779
+ if (token.kind === TokenKind.NAME && token.value === value) {
4780
+ this.advanceLexer();
4781
+ return true;
4782
+ }
4783
+ return false;
4784
+ }
4785
+ /**
4786
+ * Helper function for creating an error when an unexpected lexed token is encountered.
4787
+ */
4788
+ unexpected(atToken) {
4789
+ const token = atToken !== null && atToken !== void 0 ? atToken : this._lexer.token;
4790
+ return syntaxError(
4791
+ this._lexer.source,
4792
+ token.start,
4793
+ `Unexpected ${getTokenDesc(token)}.`
4794
+ );
4795
+ }
4796
+ /**
4797
+ * Returns a possibly empty list of parse nodes, determined by the parseFn.
4798
+ * This list begins with a lex token of openKind and ends with a lex token of closeKind.
4799
+ * Advances the parser to the next lex token after the closing token.
4800
+ */
4801
+ any(openKind, parseFn, closeKind) {
4802
+ this.expectToken(openKind);
4803
+ const nodes = [];
4804
+ while (!this.expectOptionalToken(closeKind)) {
4805
+ nodes.push(parseFn.call(this));
4806
+ }
4807
+ return nodes;
4808
+ }
4809
+ /**
4810
+ * Returns a list of parse nodes, determined by the parseFn.
4811
+ * It can be empty only if open token is missing otherwise it will always return non-empty list
4812
+ * that begins with a lex token of openKind and ends with a lex token of closeKind.
4813
+ * Advances the parser to the next lex token after the closing token.
4814
+ */
4815
+ optionalMany(openKind, parseFn, closeKind) {
4816
+ if (this.expectOptionalToken(openKind)) {
4817
+ const nodes = [];
4818
+ do {
4819
+ nodes.push(parseFn.call(this));
4820
+ } while (!this.expectOptionalToken(closeKind));
4821
+ return nodes;
4822
+ }
4823
+ return [];
4824
+ }
4825
+ /**
4826
+ * Returns a non-empty list of parse nodes, determined by the parseFn.
4827
+ * This list begins with a lex token of openKind and ends with a lex token of closeKind.
4828
+ * Advances the parser to the next lex token after the closing token.
4829
+ */
4830
+ many(openKind, parseFn, closeKind) {
4831
+ this.expectToken(openKind);
4832
+ const nodes = [];
4833
+ do {
4834
+ nodes.push(parseFn.call(this));
4835
+ } while (!this.expectOptionalToken(closeKind));
4836
+ return nodes;
4837
+ }
4838
+ /**
4839
+ * Returns a non-empty list of parse nodes, determined by the parseFn.
4840
+ * This list may begin with a lex token of delimiterKind followed by items separated by lex tokens of tokenKind.
4841
+ * Advances the parser to the next lex token after last item in the list.
4842
+ */
4843
+ delimitedMany(delimiterKind, parseFn) {
4844
+ this.expectOptionalToken(delimiterKind);
4845
+ const nodes = [];
4846
+ do {
4847
+ nodes.push(parseFn.call(this));
4848
+ } while (this.expectOptionalToken(delimiterKind));
4849
+ return nodes;
4850
+ }
4851
+ advanceLexer() {
4852
+ const { maxTokens } = this._options;
4853
+ const token = this._lexer.advance();
4854
+ if (maxTokens !== void 0 && token.kind !== TokenKind.EOF) {
4855
+ ++this._tokenCounter;
4856
+ if (this._tokenCounter > maxTokens) {
4857
+ throw syntaxError(
4858
+ this._lexer.source,
4859
+ token.start,
4860
+ `Document contains more that ${maxTokens} tokens. Parsing aborted.`
4861
+ );
4862
+ }
4863
+ }
4864
+ }
4865
+ };
4866
+ function getTokenDesc(token) {
4867
+ const value = token.value;
4868
+ return getTokenKindDesc(token.kind) + (value != null ? ` "${value}"` : "");
4869
+ }
4870
+ function getTokenKindDesc(kind) {
4871
+ return isPunctuatorTokenKind(kind) ? `"${kind}"` : kind;
4872
+ }
4873
+
4874
+ // src/core/utils/internal/jsonParse.ts
4875
+ function jsonParse(value) {
4876
+ try {
4877
+ return JSON.parse(value);
4878
+ } catch (error3) {
4879
+ return void 0;
4880
+ }
4881
+ }
4882
+
4883
+ // node_modules/.pnpm/headers-polyfill@4.0.1/node_modules/headers-polyfill/lib/index.mjs
4884
+ var __create4 = Object.create;
4885
+ var __defProp6 = Object.defineProperty;
4886
+ var __getOwnPropDesc5 = Object.getOwnPropertyDescriptor;
4887
+ var __getOwnPropNames5 = Object.getOwnPropertyNames;
4888
+ var __getProtoOf4 = Object.getPrototypeOf;
4889
+ var __hasOwnProp5 = Object.prototype.hasOwnProperty;
4890
+ var __commonJS4 = (cb, mod) => function __require() {
4891
+ return mod || (0, cb[__getOwnPropNames5(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
4892
+ };
4893
+ var __copyProps5 = (to, from, except, desc) => {
4894
+ if (from && typeof from === "object" || typeof from === "function") {
4895
+ for (let key of __getOwnPropNames5(from))
4896
+ if (!__hasOwnProp5.call(to, key) && key !== except)
4897
+ __defProp6(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc5(from, key)) || desc.enumerable });
4898
+ }
4899
+ return to;
4900
+ };
4901
+ var __toESM4 = (mod, isNodeMode, target) => (target = mod != null ? __create4(__getProtoOf4(mod)) : {}, __copyProps5(
4902
+ // If the importer is in node compatibility mode or this is not an ESM
4903
+ // file that has been converted to a CommonJS file using a Babel-
4904
+ // compatible transform (i.e. "__esModule" has not been set), then set
4905
+ // "default" to the CommonJS "module.exports" for node compatibility.
4906
+ isNodeMode || !mod || !mod.__esModule ? __defProp6(target, "default", { value: mod, enumerable: true }) : target,
4907
+ mod
4908
+ ));
4909
+ var require_set_cookie2 = __commonJS4({
4910
+ "node_modules/set-cookie-parser/lib/set-cookie.js"(exports, module) {
4911
+ "use strict";
4912
+ var defaultParseOptions = {
4913
+ decodeValues: true,
4914
+ map: false,
4915
+ silent: false
4916
+ };
4917
+ function isNonEmptyString(str) {
4918
+ return typeof str === "string" && !!str.trim();
4919
+ }
4920
+ function parseString(setCookieValue, options) {
4921
+ var parts = setCookieValue.split(";").filter(isNonEmptyString);
4922
+ var nameValuePairStr = parts.shift();
4923
+ var parsed = parseNameValuePair(nameValuePairStr);
4924
+ var name = parsed.name;
4925
+ var value = parsed.value;
4926
+ options = options ? Object.assign({}, defaultParseOptions, options) : defaultParseOptions;
4927
+ try {
4928
+ value = options.decodeValues ? decodeURIComponent(value) : value;
4929
+ } catch (e) {
4930
+ console.error(
4931
+ "set-cookie-parser encountered an error while decoding a cookie with value '" + value + "'. Set options.decodeValues to false to disable this feature.",
4932
+ e
4933
+ );
4934
+ }
4935
+ var cookie = {
4936
+ name,
4937
+ value
4938
+ };
4939
+ parts.forEach(function(part) {
4940
+ var sides = part.split("=");
4941
+ var key = sides.shift().trimLeft().toLowerCase();
4942
+ var value2 = sides.join("=");
4943
+ if (key === "expires") {
4944
+ cookie.expires = new Date(value2);
4945
+ } else if (key === "max-age") {
4946
+ cookie.maxAge = parseInt(value2, 10);
4947
+ } else if (key === "secure") {
4948
+ cookie.secure = true;
4949
+ } else if (key === "httponly") {
4950
+ cookie.httpOnly = true;
4951
+ } else if (key === "samesite") {
4952
+ cookie.sameSite = value2;
4953
+ } else {
4954
+ cookie[key] = value2;
4955
+ }
4956
+ });
4957
+ return cookie;
4958
+ }
4959
+ function parseNameValuePair(nameValuePairStr) {
4960
+ var name = "";
4961
+ var value = "";
4962
+ var nameValueArr = nameValuePairStr.split("=");
4963
+ if (nameValueArr.length > 1) {
4964
+ name = nameValueArr.shift();
4965
+ value = nameValueArr.join("=");
4966
+ } else {
4967
+ value = nameValuePairStr;
4968
+ }
4969
+ return { name, value };
4970
+ }
4971
+ function parse3(input, options) {
4972
+ options = options ? Object.assign({}, defaultParseOptions, options) : defaultParseOptions;
4973
+ if (!input) {
4974
+ if (!options.map) {
4975
+ return [];
4976
+ } else {
4977
+ return {};
4978
+ }
4979
+ }
4980
+ if (input.headers) {
4981
+ if (typeof input.headers.getSetCookie === "function") {
4982
+ input = input.headers.getSetCookie();
4983
+ } else if (input.headers["set-cookie"]) {
4984
+ input = input.headers["set-cookie"];
4985
+ } else {
4986
+ var sch = input.headers[Object.keys(input.headers).find(function(key) {
4987
+ return key.toLowerCase() === "set-cookie";
4988
+ })];
4989
+ if (!sch && input.headers.cookie && !options.silent) {
4990
+ console.warn(
4991
+ "Warning: set-cookie-parser appears to have been called on a request object. It is designed to parse Set-Cookie headers from responses, not Cookie headers from requests. Set the option {silent: true} to suppress this warning."
4992
+ );
4993
+ }
4994
+ input = sch;
4995
+ }
4996
+ }
4997
+ if (!Array.isArray(input)) {
4998
+ input = [input];
4999
+ }
5000
+ options = options ? Object.assign({}, defaultParseOptions, options) : defaultParseOptions;
5001
+ if (!options.map) {
5002
+ return input.filter(isNonEmptyString).map(function(str) {
5003
+ return parseString(str, options);
5004
+ });
5005
+ } else {
5006
+ var cookies = {};
5007
+ return input.filter(isNonEmptyString).reduce(function(cookies2, str) {
5008
+ var cookie = parseString(str, options);
5009
+ cookies2[cookie.name] = cookie;
5010
+ return cookies2;
5011
+ }, cookies);
5012
+ }
5013
+ }
5014
+ function splitCookiesString2(cookiesString) {
5015
+ if (Array.isArray(cookiesString)) {
5016
+ return cookiesString;
5017
+ }
5018
+ if (typeof cookiesString !== "string") {
5019
+ return [];
5020
+ }
5021
+ var cookiesStrings = [];
5022
+ var pos = 0;
5023
+ var start;
5024
+ var ch;
5025
+ var lastComma;
5026
+ var nextStart;
5027
+ var cookiesSeparatorFound;
5028
+ function skipWhitespace() {
5029
+ while (pos < cookiesString.length && /\s/.test(cookiesString.charAt(pos))) {
5030
+ pos += 1;
5031
+ }
5032
+ return pos < cookiesString.length;
5033
+ }
5034
+ function notSpecialChar() {
5035
+ ch = cookiesString.charAt(pos);
5036
+ return ch !== "=" && ch !== ";" && ch !== ",";
5037
+ }
5038
+ while (pos < cookiesString.length) {
5039
+ start = pos;
5040
+ cookiesSeparatorFound = false;
5041
+ while (skipWhitespace()) {
5042
+ ch = cookiesString.charAt(pos);
5043
+ if (ch === ",") {
5044
+ lastComma = pos;
5045
+ pos += 1;
5046
+ skipWhitespace();
5047
+ nextStart = pos;
5048
+ while (pos < cookiesString.length && notSpecialChar()) {
5049
+ pos += 1;
5050
+ }
5051
+ if (pos < cookiesString.length && cookiesString.charAt(pos) === "=") {
5052
+ cookiesSeparatorFound = true;
5053
+ pos = nextStart;
5054
+ cookiesStrings.push(cookiesString.substring(start, lastComma));
5055
+ start = pos;
5056
+ } else {
5057
+ pos = lastComma + 1;
5058
+ }
5059
+ } else {
5060
+ pos += 1;
5061
+ }
5062
+ }
5063
+ if (!cookiesSeparatorFound || pos >= cookiesString.length) {
5064
+ cookiesStrings.push(cookiesString.substring(start, cookiesString.length));
5065
+ }
5066
+ }
5067
+ return cookiesStrings;
5068
+ }
5069
+ module.exports = parse3;
5070
+ module.exports.parse = parse3;
5071
+ module.exports.parseString = parseString;
5072
+ module.exports.splitCookiesString = splitCookiesString2;
4813
5073
  }
4814
- /**
4815
- * ```
4816
- * SchemaExtension :
4817
- * - extend schema Directives[Const]? { OperationTypeDefinition+ }
4818
- * - extend schema Directives[Const]
4819
- * ```
4820
- */
4821
- parseSchemaExtension() {
4822
- const start = this._lexer.token;
4823
- this.expectKeyword("extend");
4824
- this.expectKeyword("schema");
4825
- const directives = this.parseConstDirectives();
4826
- const operationTypes = this.optionalMany(
4827
- TokenKind.BRACE_L,
4828
- this.parseOperationTypeDefinition,
4829
- TokenKind.BRACE_R
4830
- );
4831
- if (directives.length === 0 && operationTypes.length === 0) {
4832
- throw this.unexpected();
4833
- }
4834
- return this.node(start, {
4835
- kind: Kind.SCHEMA_EXTENSION,
4836
- directives,
4837
- operationTypes
4838
- });
5074
+ });
5075
+ var import_set_cookie_parser2 = __toESM4(require_set_cookie2());
5076
+ var HEADERS_INVALID_CHARACTERS = /[^a-z0-9\-#$%&'*+.^_`|~]/i;
5077
+ function normalizeHeaderName(name) {
5078
+ if (HEADERS_INVALID_CHARACTERS.test(name) || name.trim() === "") {
5079
+ throw new TypeError("Invalid character in header field name");
4839
5080
  }
4840
- /**
4841
- * ScalarTypeExtension :
4842
- * - extend scalar Name Directives[Const]
4843
- */
4844
- parseScalarTypeExtension() {
4845
- const start = this._lexer.token;
4846
- this.expectKeyword("extend");
4847
- this.expectKeyword("scalar");
4848
- const name = this.parseName();
4849
- const directives = this.parseConstDirectives();
4850
- if (directives.length === 0) {
4851
- throw this.unexpected();
4852
- }
4853
- return this.node(start, {
4854
- kind: Kind.SCALAR_TYPE_EXTENSION,
4855
- name,
4856
- directives
4857
- });
5081
+ return name.trim().toLowerCase();
5082
+ }
5083
+ var charCodesToRemove = [
5084
+ String.fromCharCode(10),
5085
+ String.fromCharCode(13),
5086
+ String.fromCharCode(9),
5087
+ String.fromCharCode(32)
5088
+ ];
5089
+ var HEADER_VALUE_REMOVE_REGEXP = new RegExp(
5090
+ `(^[${charCodesToRemove.join("")}]|$[${charCodesToRemove.join("")}])`,
5091
+ "g"
5092
+ );
5093
+ function normalizeHeaderValue(value) {
5094
+ const nextValue = value.replace(HEADER_VALUE_REMOVE_REGEXP, "");
5095
+ return nextValue;
5096
+ }
5097
+ function isValidHeaderName(value) {
5098
+ if (typeof value !== "string") {
5099
+ return false;
4858
5100
  }
4859
- /**
4860
- * ObjectTypeExtension :
4861
- * - extend type Name ImplementsInterfaces? Directives[Const]? FieldsDefinition
4862
- * - extend type Name ImplementsInterfaces? Directives[Const]
4863
- * - extend type Name ImplementsInterfaces
4864
- */
4865
- parseObjectTypeExtension() {
4866
- const start = this._lexer.token;
4867
- this.expectKeyword("extend");
4868
- this.expectKeyword("type");
4869
- const name = this.parseName();
4870
- const interfaces = this.parseImplementsInterfaces();
4871
- const directives = this.parseConstDirectives();
4872
- const fields = this.parseFieldsDefinition();
4873
- if (interfaces.length === 0 && directives.length === 0 && fields.length === 0) {
4874
- throw this.unexpected();
4875
- }
4876
- return this.node(start, {
4877
- kind: Kind.OBJECT_TYPE_EXTENSION,
4878
- name,
4879
- interfaces,
4880
- directives,
4881
- fields
4882
- });
5101
+ if (value.length === 0) {
5102
+ return false;
4883
5103
  }
4884
- /**
4885
- * InterfaceTypeExtension :
4886
- * - extend interface Name ImplementsInterfaces? Directives[Const]? FieldsDefinition
4887
- * - extend interface Name ImplementsInterfaces? Directives[Const]
4888
- * - extend interface Name ImplementsInterfaces
4889
- */
4890
- parseInterfaceTypeExtension() {
4891
- const start = this._lexer.token;
4892
- this.expectKeyword("extend");
4893
- this.expectKeyword("interface");
4894
- const name = this.parseName();
4895
- const interfaces = this.parseImplementsInterfaces();
4896
- const directives = this.parseConstDirectives();
4897
- const fields = this.parseFieldsDefinition();
4898
- if (interfaces.length === 0 && directives.length === 0 && fields.length === 0) {
4899
- throw this.unexpected();
5104
+ for (let i = 0; i < value.length; i++) {
5105
+ const character = value.charCodeAt(i);
5106
+ if (character > 127 || !isToken(character)) {
5107
+ return false;
4900
5108
  }
4901
- return this.node(start, {
4902
- kind: Kind.INTERFACE_TYPE_EXTENSION,
4903
- name,
4904
- interfaces,
4905
- directives,
4906
- fields
4907
- });
4908
5109
  }
4909
- /**
4910
- * UnionTypeExtension :
4911
- * - extend union Name Directives[Const]? UnionMemberTypes
4912
- * - extend union Name Directives[Const]
4913
- */
4914
- parseUnionTypeExtension() {
4915
- const start = this._lexer.token;
4916
- this.expectKeyword("extend");
4917
- this.expectKeyword("union");
4918
- const name = this.parseName();
4919
- const directives = this.parseConstDirectives();
4920
- const types = this.parseUnionMemberTypes();
4921
- if (directives.length === 0 && types.length === 0) {
4922
- throw this.unexpected();
4923
- }
4924
- return this.node(start, {
4925
- kind: Kind.UNION_TYPE_EXTENSION,
4926
- name,
4927
- directives,
4928
- types
4929
- });
5110
+ return true;
5111
+ }
5112
+ function isToken(value) {
5113
+ return ![
5114
+ 127,
5115
+ 32,
5116
+ "(",
5117
+ ")",
5118
+ "<",
5119
+ ">",
5120
+ "@",
5121
+ ",",
5122
+ ";",
5123
+ ":",
5124
+ "\\",
5125
+ '"',
5126
+ "/",
5127
+ "[",
5128
+ "]",
5129
+ "?",
5130
+ "=",
5131
+ "{",
5132
+ "}"
5133
+ ].includes(value);
5134
+ }
5135
+ function isValidHeaderValue(value) {
5136
+ if (typeof value !== "string") {
5137
+ return false;
4930
5138
  }
4931
- /**
4932
- * EnumTypeExtension :
4933
- * - extend enum Name Directives[Const]? EnumValuesDefinition
4934
- * - extend enum Name Directives[Const]
4935
- */
4936
- parseEnumTypeExtension() {
4937
- const start = this._lexer.token;
4938
- this.expectKeyword("extend");
4939
- this.expectKeyword("enum");
4940
- const name = this.parseName();
4941
- const directives = this.parseConstDirectives();
4942
- const values = this.parseEnumValuesDefinition();
4943
- if (directives.length === 0 && values.length === 0) {
4944
- throw this.unexpected();
4945
- }
4946
- return this.node(start, {
4947
- kind: Kind.ENUM_TYPE_EXTENSION,
4948
- name,
4949
- directives,
4950
- values
4951
- });
5139
+ if (value.trim() !== value) {
5140
+ return false;
4952
5141
  }
4953
- /**
4954
- * InputObjectTypeExtension :
4955
- * - extend input Name Directives[Const]? InputFieldsDefinition
4956
- * - extend input Name Directives[Const]
4957
- */
4958
- parseInputObjectTypeExtension() {
4959
- const start = this._lexer.token;
4960
- this.expectKeyword("extend");
4961
- this.expectKeyword("input");
4962
- const name = this.parseName();
4963
- const directives = this.parseConstDirectives();
4964
- const fields = this.parseInputFieldsDefinition();
4965
- if (directives.length === 0 && fields.length === 0) {
4966
- throw this.unexpected();
5142
+ for (let i = 0; i < value.length; i++) {
5143
+ const character = value.charCodeAt(i);
5144
+ if (
5145
+ // NUL.
5146
+ character === 0 || // HTTP newline bytes.
5147
+ character === 10 || character === 13
5148
+ ) {
5149
+ return false;
4967
5150
  }
4968
- return this.node(start, {
4969
- kind: Kind.INPUT_OBJECT_TYPE_EXTENSION,
4970
- name,
4971
- directives,
4972
- fields
4973
- });
4974
- }
4975
- /**
4976
- * ```
4977
- * DirectiveDefinition :
4978
- * - Description? directive @ Name ArgumentsDefinition? `repeatable`? on DirectiveLocations
4979
- * ```
4980
- */
4981
- parseDirectiveDefinition() {
4982
- const start = this._lexer.token;
4983
- const description = this.parseDescription();
4984
- this.expectKeyword("directive");
4985
- this.expectToken(TokenKind.AT);
4986
- const name = this.parseName();
4987
- const args = this.parseArgumentDefs();
4988
- const repeatable = this.expectOptionalKeyword("repeatable");
4989
- this.expectKeyword("on");
4990
- const locations = this.parseDirectiveLocations();
4991
- return this.node(start, {
4992
- kind: Kind.DIRECTIVE_DEFINITION,
4993
- description,
4994
- name,
4995
- arguments: args,
4996
- repeatable,
4997
- locations
4998
- });
4999
- }
5000
- /**
5001
- * DirectiveLocations :
5002
- * - `|`? DirectiveLocation
5003
- * - DirectiveLocations | DirectiveLocation
5004
- */
5005
- parseDirectiveLocations() {
5006
- return this.delimitedMany(TokenKind.PIPE, this.parseDirectiveLocation);
5007
5151
  }
5008
- /*
5009
- * DirectiveLocation :
5010
- * - ExecutableDirectiveLocation
5011
- * - TypeSystemDirectiveLocation
5012
- *
5013
- * ExecutableDirectiveLocation : one of
5014
- * `QUERY`
5015
- * `MUTATION`
5016
- * `SUBSCRIPTION`
5017
- * `FIELD`
5018
- * `FRAGMENT_DEFINITION`
5019
- * `FRAGMENT_SPREAD`
5020
- * `INLINE_FRAGMENT`
5021
- *
5022
- * TypeSystemDirectiveLocation : one of
5023
- * `SCHEMA`
5024
- * `SCALAR`
5025
- * `OBJECT`
5026
- * `FIELD_DEFINITION`
5027
- * `ARGUMENT_DEFINITION`
5028
- * `INTERFACE`
5029
- * `UNION`
5030
- * `ENUM`
5031
- * `ENUM_VALUE`
5032
- * `INPUT_OBJECT`
5033
- * `INPUT_FIELD_DEFINITION`
5034
- */
5035
- parseDirectiveLocation() {
5036
- const start = this._lexer.token;
5037
- const name = this.parseName();
5038
- if (Object.prototype.hasOwnProperty.call(DirectiveLocation, name.value)) {
5039
- return name;
5152
+ return true;
5153
+ }
5154
+ var NORMALIZED_HEADERS = Symbol("normalizedHeaders");
5155
+ var RAW_HEADER_NAMES = Symbol("rawHeaderNames");
5156
+ var HEADER_VALUE_DELIMITER = ", ";
5157
+ var _a;
5158
+ var _b;
5159
+ var Headers2 = class _Headers {
5160
+ constructor(init) {
5161
+ this[_a] = {};
5162
+ this[_b] = /* @__PURE__ */ new Map();
5163
+ if (["Headers", "HeadersPolyfill"].includes(init == null ? void 0 : init.constructor.name) || init instanceof _Headers) {
5164
+ const initialHeaders = init;
5165
+ initialHeaders.forEach((value, name) => {
5166
+ this.append(name, value);
5167
+ }, this);
5168
+ } else if (Array.isArray(init)) {
5169
+ init.forEach(([name, value]) => {
5170
+ this.append(
5171
+ name,
5172
+ Array.isArray(value) ? value.join(HEADER_VALUE_DELIMITER) : value
5173
+ );
5174
+ });
5175
+ } else if (init) {
5176
+ Object.getOwnPropertyNames(init).forEach((name) => {
5177
+ const value = init[name];
5178
+ this.append(
5179
+ name,
5180
+ Array.isArray(value) ? value.join(HEADER_VALUE_DELIMITER) : value
5181
+ );
5182
+ });
5040
5183
  }
5041
- throw this.unexpected(start);
5042
5184
  }
5043
- // Core parsing utility functions
5044
- /**
5045
- * Returns a node that, if configured to do so, sets a "loc" field as a
5046
- * location object, used to identify the place in the source that created a
5047
- * given parsed object.
5048
- */
5049
- node(startToken, node) {
5050
- if (this._options.noLocation !== true) {
5051
- node.loc = new Location(
5052
- startToken,
5053
- this._lexer.lastToken,
5054
- this._lexer.source
5055
- );
5056
- }
5057
- return node;
5185
+ [(_a = NORMALIZED_HEADERS, _b = RAW_HEADER_NAMES, Symbol.iterator)]() {
5186
+ return this.entries();
5058
5187
  }
5059
- /**
5060
- * Determines if the next token is of a given kind
5061
- */
5062
- peek(kind) {
5063
- return this._lexer.token.kind === kind;
5188
+ *keys() {
5189
+ for (const [name] of this.entries()) {
5190
+ yield name;
5191
+ }
5064
5192
  }
5065
- /**
5066
- * If the next token is of the given kind, return that token after advancing the lexer.
5067
- * Otherwise, do not change the parser state and throw an error.
5068
- */
5069
- expectToken(kind) {
5070
- const token = this._lexer.token;
5071
- if (token.kind === kind) {
5072
- this.advanceLexer();
5073
- return token;
5193
+ *values() {
5194
+ for (const [, value] of this.entries()) {
5195
+ yield value;
5074
5196
  }
5075
- throw syntaxError(
5076
- this._lexer.source,
5077
- token.start,
5078
- `Expected ${getTokenKindDesc(kind)}, found ${getTokenDesc(token)}.`
5079
- );
5080
5197
  }
5081
- /**
5082
- * If the next token is of the given kind, return "true" after advancing the lexer.
5083
- * Otherwise, do not change the parser state and return "false".
5084
- */
5085
- expectOptionalToken(kind) {
5086
- const token = this._lexer.token;
5087
- if (token.kind === kind) {
5088
- this.advanceLexer();
5089
- return true;
5198
+ *entries() {
5199
+ let sortedKeys = Object.keys(this[NORMALIZED_HEADERS]).sort(
5200
+ (a, b) => a.localeCompare(b)
5201
+ );
5202
+ for (const name of sortedKeys) {
5203
+ if (name === "set-cookie") {
5204
+ for (const value of this.getSetCookie()) {
5205
+ yield [name, value];
5206
+ }
5207
+ } else {
5208
+ yield [name, this.get(name)];
5209
+ }
5090
5210
  }
5091
- return false;
5092
5211
  }
5093
5212
  /**
5094
- * If the next token is a given keyword, advance the lexer.
5095
- * Otherwise, do not change the parser state and throw an error.
5213
+ * Returns a boolean stating whether a `Headers` object contains a certain header.
5096
5214
  */
5097
- expectKeyword(value) {
5098
- const token = this._lexer.token;
5099
- if (token.kind === TokenKind.NAME && token.value === value) {
5100
- this.advanceLexer();
5101
- } else {
5102
- throw syntaxError(
5103
- this._lexer.source,
5104
- token.start,
5105
- `Expected "${value}", found ${getTokenDesc(token)}.`
5106
- );
5215
+ has(name) {
5216
+ if (!isValidHeaderName(name)) {
5217
+ throw new TypeError(`Invalid header name "${name}"`);
5107
5218
  }
5219
+ return this[NORMALIZED_HEADERS].hasOwnProperty(normalizeHeaderName(name));
5108
5220
  }
5109
5221
  /**
5110
- * If the next token is a given keyword, return "true" after advancing the lexer.
5111
- * Otherwise, do not change the parser state and return "false".
5222
+ * Returns a `ByteString` sequence of all the values of a header with a given name.
5112
5223
  */
5113
- expectOptionalKeyword(value) {
5114
- const token = this._lexer.token;
5115
- if (token.kind === TokenKind.NAME && token.value === value) {
5116
- this.advanceLexer();
5117
- return true;
5224
+ get(name) {
5225
+ var _a3;
5226
+ if (!isValidHeaderName(name)) {
5227
+ throw TypeError(`Invalid header name "${name}"`);
5118
5228
  }
5119
- return false;
5229
+ return (_a3 = this[NORMALIZED_HEADERS][normalizeHeaderName(name)]) != null ? _a3 : null;
5120
5230
  }
5121
5231
  /**
5122
- * Helper function for creating an error when an unexpected lexed token is encountered.
5232
+ * Sets a new value for an existing header inside a `Headers` object, or adds the header if it does not already exist.
5123
5233
  */
5124
- unexpected(atToken) {
5125
- const token = atToken !== null && atToken !== void 0 ? atToken : this._lexer.token;
5126
- return syntaxError(
5127
- this._lexer.source,
5128
- token.start,
5129
- `Unexpected ${getTokenDesc(token)}.`
5130
- );
5234
+ set(name, value) {
5235
+ if (!isValidHeaderName(name) || !isValidHeaderValue(value)) {
5236
+ return;
5237
+ }
5238
+ const normalizedName = normalizeHeaderName(name);
5239
+ const normalizedValue = normalizeHeaderValue(value);
5240
+ this[NORMALIZED_HEADERS][normalizedName] = normalizeHeaderValue(normalizedValue);
5241
+ this[RAW_HEADER_NAMES].set(normalizedName, name);
5131
5242
  }
5132
5243
  /**
5133
- * Returns a possibly empty list of parse nodes, determined by the parseFn.
5134
- * This list begins with a lex token of openKind and ends with a lex token of closeKind.
5135
- * Advances the parser to the next lex token after the closing token.
5244
+ * Appends a new value onto an existing header inside a `Headers` object, or adds the header if it does not already exist.
5136
5245
  */
5137
- any(openKind, parseFn, closeKind) {
5138
- this.expectToken(openKind);
5139
- const nodes = [];
5140
- while (!this.expectOptionalToken(closeKind)) {
5141
- nodes.push(parseFn.call(this));
5246
+ append(name, value) {
5247
+ if (!isValidHeaderName(name) || !isValidHeaderValue(value)) {
5248
+ return;
5142
5249
  }
5143
- return nodes;
5250
+ const normalizedName = normalizeHeaderName(name);
5251
+ const normalizedValue = normalizeHeaderValue(value);
5252
+ let resolvedValue = this.has(normalizedName) ? `${this.get(normalizedName)}, ${normalizedValue}` : normalizedValue;
5253
+ this.set(name, resolvedValue);
5144
5254
  }
5145
5255
  /**
5146
- * Returns a list of parse nodes, determined by the parseFn.
5147
- * It can be empty only if open token is missing otherwise it will always return non-empty list
5148
- * that begins with a lex token of openKind and ends with a lex token of closeKind.
5149
- * Advances the parser to the next lex token after the closing token.
5256
+ * Deletes a header from the `Headers` object.
5150
5257
  */
5151
- optionalMany(openKind, parseFn, closeKind) {
5152
- if (this.expectOptionalToken(openKind)) {
5153
- const nodes = [];
5154
- do {
5155
- nodes.push(parseFn.call(this));
5156
- } while (!this.expectOptionalToken(closeKind));
5157
- return nodes;
5258
+ delete(name) {
5259
+ if (!isValidHeaderName(name)) {
5260
+ return;
5158
5261
  }
5159
- return [];
5262
+ if (!this.has(name)) {
5263
+ return;
5264
+ }
5265
+ const normalizedName = normalizeHeaderName(name);
5266
+ delete this[NORMALIZED_HEADERS][normalizedName];
5267
+ this[RAW_HEADER_NAMES].delete(normalizedName);
5160
5268
  }
5161
5269
  /**
5162
- * Returns a non-empty list of parse nodes, determined by the parseFn.
5163
- * This list begins with a lex token of openKind and ends with a lex token of closeKind.
5164
- * Advances the parser to the next lex token after the closing token.
5270
+ * Traverses the `Headers` object,
5271
+ * calling the given callback for each header.
5165
5272
  */
5166
- many(openKind, parseFn, closeKind) {
5167
- this.expectToken(openKind);
5168
- const nodes = [];
5169
- do {
5170
- nodes.push(parseFn.call(this));
5171
- } while (!this.expectOptionalToken(closeKind));
5172
- return nodes;
5273
+ forEach(callback, thisArg) {
5274
+ for (const [name, value] of this.entries()) {
5275
+ callback.call(thisArg, value, name, this);
5276
+ }
5173
5277
  }
5174
5278
  /**
5175
- * Returns a non-empty list of parse nodes, determined by the parseFn.
5176
- * This list may begin with a lex token of delimiterKind followed by items separated by lex tokens of tokenKind.
5177
- * Advances the parser to the next lex token after last item in the list.
5279
+ * Returns an array containing the values
5280
+ * of all Set-Cookie headers associated
5281
+ * with a response
5178
5282
  */
5179
- delimitedMany(delimiterKind, parseFn) {
5180
- this.expectOptionalToken(delimiterKind);
5181
- const nodes = [];
5182
- do {
5183
- nodes.push(parseFn.call(this));
5184
- } while (this.expectOptionalToken(delimiterKind));
5185
- return nodes;
5186
- }
5187
- advanceLexer() {
5188
- const { maxTokens } = this._options;
5189
- const token = this._lexer.advance();
5190
- if (maxTokens !== void 0 && token.kind !== TokenKind.EOF) {
5191
- ++this._tokenCounter;
5192
- if (this._tokenCounter > maxTokens) {
5193
- throw syntaxError(
5194
- this._lexer.source,
5195
- token.start,
5196
- `Document contains more that ${maxTokens} tokens. Parsing aborted.`
5197
- );
5198
- }
5283
+ getSetCookie() {
5284
+ const setCookieHeader = this.get("set-cookie");
5285
+ if (setCookieHeader === null) {
5286
+ return [];
5199
5287
  }
5288
+ if (setCookieHeader === "") {
5289
+ return [""];
5290
+ }
5291
+ return (0, import_set_cookie_parser2.splitCookiesString)(setCookieHeader);
5200
5292
  }
5201
5293
  };
5202
- function getTokenDesc(token) {
5203
- const value = token.value;
5204
- return getTokenKindDesc(token.kind) + (value != null ? ` "${value}"` : "");
5205
- }
5206
- function getTokenKindDesc(kind) {
5207
- return isPunctuatorTokenKind(kind) ? `"${kind}"` : kind;
5208
- }
5209
-
5210
- // src/core/utils/internal/jsonParse.ts
5211
- function jsonParse(value) {
5212
- try {
5213
- return JSON.parse(value);
5214
- } catch (error3) {
5215
- return void 0;
5216
- }
5294
+ function stringToHeaders(str) {
5295
+ const lines = str.trim().split(/[\r\n]+/);
5296
+ return lines.reduce((headers, line) => {
5297
+ if (line.trim() === "") {
5298
+ return headers;
5299
+ }
5300
+ const parts = line.split(": ");
5301
+ const name = parts.shift();
5302
+ const value = parts.join(": ");
5303
+ headers.append(name, value);
5304
+ return headers;
5305
+ }, new Headers2());
5217
5306
  }
5218
5307
 
5219
5308
  // src/core/utils/internal/parseMultipartData.ts
@@ -5406,7 +5495,7 @@ spurious results.`);
5406
5495
  return typeof value === "object" && "kind" in value && "definitions" in value;
5407
5496
  }
5408
5497
  var GraphQLHandler = class extends RequestHandler {
5409
- constructor(operationType, operationName, endpoint, resolver) {
5498
+ constructor(operationType, operationName, endpoint, resolver, options) {
5410
5499
  let resolvedOperationName = operationName;
5411
5500
  if (isDocumentNode(operationName)) {
5412
5501
  const parsedNode = parseDocumentNode(operationName);
@@ -5429,47 +5518,53 @@ spurious results.`);
5429
5518
  operationType,
5430
5519
  operationName: resolvedOperationName
5431
5520
  },
5432
- resolver
5521
+ resolver,
5522
+ options
5433
5523
  });
5434
5524
  this.endpoint = endpoint;
5435
5525
  }
5436
- parse(request) {
5526
+ parse(args) {
5437
5527
  return __async(this, null, function* () {
5438
- return parseGraphQLRequest(request).catch((error3) => {
5528
+ return parseGraphQLRequest(args.request).catch((error3) => {
5439
5529
  console.error(error3);
5440
5530
  return void 0;
5441
5531
  });
5442
5532
  });
5443
5533
  }
5444
- predicate(request, parsedResult) {
5445
- if (!parsedResult) {
5534
+ predicate(args) {
5535
+ if (!args.parsedResult) {
5446
5536
  return false;
5447
5537
  }
5448
- if (!parsedResult.operationName && this.info.operationType !== "all") {
5449
- const publicUrl = getPublicUrlFromRequest(request);
5450
- devUtils.warn(`Failed to intercept a GraphQL request at "${request.method} ${publicUrl}": anonymous GraphQL operations are not supported.
5538
+ if (!args.parsedResult.operationName && this.info.operationType !== "all") {
5539
+ const publicUrl = getPublicUrlFromRequest(args.request);
5540
+ devUtils.warn(`Failed to intercept a GraphQL request at "${args.request.method} ${publicUrl}": anonymous GraphQL operations are not supported.
5451
5541
 
5452
5542
  Consider naming this operation or using "graphql.operation()" request handler to intercept GraphQL requests regardless of their operation name/type. Read more: https://mswjs.io/docs/api/graphql/operation`);
5453
5543
  return false;
5454
5544
  }
5455
- const hasMatchingUrl = matchRequestUrl(new URL(request.url), this.endpoint);
5456
- const hasMatchingOperationType = this.info.operationType === "all" || parsedResult.operationType === this.info.operationType;
5457
- const hasMatchingOperationName = this.info.operationName instanceof RegExp ? this.info.operationName.test(parsedResult.operationName || "") : parsedResult.operationName === this.info.operationName;
5545
+ const hasMatchingUrl = matchRequestUrl(
5546
+ new URL(args.request.url),
5547
+ this.endpoint
5548
+ );
5549
+ const hasMatchingOperationType = this.info.operationType === "all" || args.parsedResult.operationType === this.info.operationType;
5550
+ const hasMatchingOperationName = this.info.operationName instanceof RegExp ? this.info.operationName.test(args.parsedResult.operationName || "") : args.parsedResult.operationName === this.info.operationName;
5458
5551
  return hasMatchingUrl.matches && hasMatchingOperationType && hasMatchingOperationName;
5459
5552
  }
5460
- extendInfo(_request, parsedResult) {
5553
+ extendResolverArgs(args) {
5554
+ var _a3, _b2, _c;
5461
5555
  return {
5462
- query: (parsedResult == null ? void 0 : parsedResult.query) || "",
5463
- operationName: (parsedResult == null ? void 0 : parsedResult.operationName) || "",
5464
- variables: (parsedResult == null ? void 0 : parsedResult.variables) || {}
5556
+ query: ((_a3 = args.parsedResult) == null ? void 0 : _a3.query) || "",
5557
+ operationName: ((_b2 = args.parsedResult) == null ? void 0 : _b2.operationName) || "",
5558
+ variables: ((_c = args.parsedResult) == null ? void 0 : _c.variables) || {}
5465
5559
  };
5466
5560
  }
5467
- log(request, response, parsedRequest) {
5561
+ log(args) {
5468
5562
  return __async(this, null, function* () {
5469
- const loggedRequest = yield serializeRequest(request);
5470
- const loggedResponse = yield serializeResponse(response);
5563
+ var _a3, _b2, _c, _d;
5564
+ const loggedRequest = yield serializeRequest(args.request);
5565
+ const loggedResponse = yield serializeResponse(args.response);
5471
5566
  const statusColor = getStatusCodeColor(loggedResponse.status);
5472
- const requestInfo = (parsedRequest == null ? void 0 : parsedRequest.operationName) ? `${parsedRequest == null ? void 0 : parsedRequest.operationType} ${parsedRequest == null ? void 0 : parsedRequest.operationName}` : `anonymous ${parsedRequest == null ? void 0 : parsedRequest.operationType}`;
5567
+ const requestInfo = ((_a3 = args.parsedResult) == null ? void 0 : _a3.operationName) ? `${(_b2 = args.parsedResult) == null ? void 0 : _b2.operationType} ${(_c = args.parsedResult) == null ? void 0 : _c.operationName}` : `anonymous ${(_d = args.parsedResult) == null ? void 0 : _d.operationType}`;
5473
5568
  console.groupCollapsed(
5474
5569
  devUtils.formatMessage("%s %s (%c%s%c)"),
5475
5570
  getTimestamp(),
@@ -5488,8 +5583,14 @@ Consider naming this operation or using "graphql.operation()" request handler to
5488
5583
 
5489
5584
  // src/core/graphql.ts
5490
5585
  function createScopedGraphQLHandler(operationType, url) {
5491
- return (operationName, resolver) => {
5492
- return new GraphQLHandler(operationType, operationName, url, resolver);
5586
+ return (operationName, resolver, options = {}) => {
5587
+ return new GraphQLHandler(
5588
+ operationType,
5589
+ operationName,
5590
+ url,
5591
+ resolver,
5592
+ options
5593
+ );
5493
5594
  };
5494
5595
  }
5495
5596
  function createGraphQLOperationHandler(url) {
@@ -5499,32 +5600,39 @@ Consider naming this operation or using "graphql.operation()" request handler to
5499
5600
  }
5500
5601
  var standardGraphQLHandlers = {
5501
5602
  /**
5502
- * Captures any GraphQL operation, regardless of its name, under the current scope.
5503
- * @example
5504
- * graphql.operation(() => {
5505
- * return HttpResponse.json({ data: { name: 'John' } })
5506
- * })
5507
- * @see {@link https://mswjs.io/docs/api/graphql/operation `graphql.operation()`}
5508
- */
5509
- operation: createGraphQLOperationHandler("*"),
5510
- /**
5511
- * Captures a GraphQL query by a given name.
5603
+ * Intercepts a GraphQL query by a given name.
5604
+ *
5512
5605
  * @example
5513
5606
  * graphql.query('GetUser', () => {
5514
5607
  * return HttpResponse.json({ data: { user: { name: 'John' } } })
5515
5608
  * })
5516
- * @see {@link https://mswjs.io/docs/api/graphql/query `graphql.query()`}
5609
+ *
5610
+ * @see {@link https://mswjs.io/docs/api/graphql#graphqlqueryqueryname-resolver `graphql.query()` API reference}
5517
5611
  */
5518
5612
  query: createScopedGraphQLHandler("query", "*"),
5519
5613
  /**
5520
- * Captures a GraphQL mutation by a given name.
5614
+ * Intercepts a GraphQL mutation by its name.
5615
+ *
5521
5616
  * @example
5522
5617
  * graphql.mutation('SavePost', () => {
5523
5618
  * return HttpResponse.json({ data: { post: { id: 'abc-123 } } })
5524
5619
  * })
5525
- * @see {@link https://mswjs.io/docs/api/graphql/mutation `graphql.mutation()`}
5620
+ *
5621
+ * @see {@link https://mswjs.io/docs/api/graphql#graphqlmutationmutationname-resolver `graphql.query()` API reference}
5622
+ *
5623
+ */
5624
+ mutation: createScopedGraphQLHandler("mutation", "*"),
5625
+ /**
5626
+ * Intercepts any GraphQL operation, regardless of its type or name.
5627
+ *
5628
+ * @example
5629
+ * graphql.operation(() => {
5630
+ * return HttpResponse.json({ data: { name: 'John' } })
5631
+ * })
5632
+ *
5633
+ * @see {@link https://mswjs.io/docs/api/graphql#graphloperationresolver `graphql.operation()` API reference}
5526
5634
  */
5527
- mutation: createScopedGraphQLHandler("mutation", "*")
5635
+ operation: createGraphQLOperationHandler("*")
5528
5636
  };
5529
5637
  function createGraphQLLink(url) {
5530
5638
  return {
@@ -5534,6 +5642,15 @@ Consider naming this operation or using "graphql.operation()" request handler to
5534
5642
  };
5535
5643
  }
5536
5644
  var graphql = __spreadProps(__spreadValues({}, standardGraphQLHandlers), {
5645
+ /**
5646
+ * Intercepts GraphQL operations scoped by the given URL.
5647
+ *
5648
+ * @example
5649
+ * const github = graphql.link('https://api.github.com/graphql')
5650
+ * github.query('GetRepo', resolver)
5651
+ *
5652
+ * @see {@link https://mswjs.io/docs/api/graphql#graphqllinkurl `graphql.link()` API reference}
5653
+ */
5537
5654
  link: createGraphQLLink
5538
5655
  });
5539
5656
 
@@ -5554,7 +5671,7 @@ Consider naming this operation or using "graphql.operation()" request handler to
5554
5671
  let matchingHandler = null;
5555
5672
  let result = null;
5556
5673
  for (const handler of handlers) {
5557
- result = yield handler.run(request, resolutionContext);
5674
+ result = yield handler.run({ request, resolutionContext });
5558
5675
  if (result !== null) {
5559
5676
  matchingHandler = handler;
5560
5677
  }
@@ -5565,7 +5682,7 @@ Consider naming this operation or using "graphql.operation()" request handler to
5565
5682
  if (matchingHandler) {
5566
5683
  return {
5567
5684
  handler: matchingHandler,
5568
- parsedRequest: result == null ? void 0 : result.parsedResult,
5685
+ parsedResult: result == null ? void 0 : result.parsedResult,
5569
5686
  response: result == null ? void 0 : result.response
5570
5687
  };
5571
5688
  }
@@ -5776,7 +5893,7 @@ ${handlers.map((handler) => ` \u2022 ${handler.info.header}`).join("\n")}`;
5776
5893
  const requestHeader = parsedGraphQLQuery ? getGraphQLRequestHeader(parsedGraphQLQuery) : `${request.method} ${publicUrl}`;
5777
5894
  const handlerSuggestion = generateHandlerSuggestion();
5778
5895
  const messageTemplate = [
5779
- `captured a request without a matching request handler:`,
5896
+ `intercepted a request without a matching request handler:`,
5780
5897
  ` \u2022 ${requestHeader}`,
5781
5898
  handlerSuggestion,
5782
5899
  `If you still wish to intercept this unhandled request, please create a request handler for it.
@@ -6034,53 +6151,16 @@ Read more: https://mswjs.io/docs/getting-started/mocks`
6034
6151
 
6035
6152
  // src/core/bypass.ts
6036
6153
  function bypass(input, init) {
6037
- return __async(this, null, function* () {
6038
- if (isRequest(input)) {
6039
- invariant(
6040
- !input.bodyUsed,
6041
- 'Failed to create a bypassed request to "%s %s": given request instance already has its body read. Make sure to clone the intercepted request if you wish to read its body before bypassing it.',
6042
- input.method,
6043
- input.url
6044
- );
6045
- }
6046
- const url = isRequest(input) ? input.url : input.toString();
6047
- const resolvedInit = typeof init !== "undefined" ? init : yield getRequestInit(input);
6048
- const headers = new HeadersPolyfill(resolvedInit.headers);
6049
- headers.set("x-msw-intention", "bypass");
6050
- resolvedInit.headers = headers;
6051
- return [url, resolvedInit];
6052
- });
6053
- }
6054
- function isRequest(input) {
6055
- return typeof input === "object" && input.constructor.name === "Request" && "clone" in input && typeof input.clone === "function";
6056
- }
6057
- function getRequestInit(input) {
6058
- return __async(this, null, function* () {
6059
- if (!isRequest(input)) {
6060
- return {};
6061
- }
6062
- const init = {
6063
- // Set each request init property explicitly
6064
- // to prevent leaking internal properties of whichever
6065
- // Request polyfill provided as the input.
6066
- mode: input.mode,
6067
- method: input.method,
6068
- cache: input.cache,
6069
- headers: input.headers,
6070
- credentials: input.credentials,
6071
- signal: input.signal,
6072
- referrerPolicy: input.referrerPolicy,
6073
- referrer: input.referrer,
6074
- redirect: input.redirect,
6075
- integrity: input.integrity,
6076
- keepalive: input.keepalive
6077
- };
6078
- if (init.method !== "HEAD" && input.method !== "GET") {
6079
- init.body = yield input.clone().arrayBuffer();
6080
- init.duplex = input.duplex;
6081
- }
6082
- return init;
6083
- });
6154
+ const request = input instanceof Request ? input : new Request(input, init);
6155
+ invariant(
6156
+ !request.bodyUsed,
6157
+ 'Failed to create a bypassed request to "%s %s": given request instance already has its body read. Make sure to clone the intercepted request if you wish to read its body before bypassing it.',
6158
+ request.method,
6159
+ request.url
6160
+ );
6161
+ const requestClone = request.clone();
6162
+ requestClone.headers.set("x-msw-intention", "bypass");
6163
+ return requestClone;
6084
6164
  }
6085
6165
 
6086
6166
  // src/core/passthrough.ts
@@ -6259,7 +6339,7 @@ Learn more about creating the Service Worker script: https://mswjs.io/docs/cli/i
6259
6339
  return {
6260
6340
  status: response.status,
6261
6341
  statusText: response.statusText,
6262
- headers: flattenHeadersObject(headersToObject(response.headers))
6342
+ headers: Object.fromEntries(response.headers.entries())
6263
6343
  };
6264
6344
  }
6265
6345
 
@@ -6284,7 +6364,7 @@ Learn more about creating the Service Worker script: https://mswjs.io/docs/cli/i
6284
6364
  messageChannel.postMessage("NOT_FOUND");
6285
6365
  },
6286
6366
  onMockedResponse(_0, _1) {
6287
- return __async(this, arguments, function* (response, { handler, parsedRequest }) {
6367
+ return __async(this, arguments, function* (response, { handler, parsedResult }) {
6288
6368
  const responseClone = response.clone();
6289
6369
  const responseInit = toResponseInit(response);
6290
6370
  const responseStream = responseClone.body;
@@ -6299,7 +6379,11 @@ Learn more about creating the Service Worker script: https://mswjs.io/docs/cli/i
6299
6379
  );
6300
6380
  if (!options.quiet) {
6301
6381
  context.emitter.once("response:mocked", ({ response: response2 }) => {
6302
- handler.log(requestCloneForLogs, response2, parsedRequest);
6382
+ handler.log({
6383
+ request: requestCloneForLogs,
6384
+ response: response2,
6385
+ parsedResult
6386
+ });
6303
6387
  });
6304
6388
  }
6305
6389
  });
@@ -6342,9 +6426,9 @@ This exception has been gracefully handled as a 500 response, however, it's stro
6342
6426
  const { payload: actualChecksum } = yield context.events.once(
6343
6427
  "INTEGRITY_CHECK_RESPONSE"
6344
6428
  );
6345
- if (actualChecksum !== "e2d8525b2d1bdadf89a15ae5a2619512") {
6429
+ if (actualChecksum !== "0877fcdc026242810f5bfde0d7178db4") {
6346
6430
  throw new Error(
6347
- `Currently active Service Worker (${actualChecksum}) is behind the latest published one (${"e2d8525b2d1bdadf89a15ae5a2619512"}).`
6431
+ `Currently active Service Worker (${actualChecksum}) is behind the latest published one (${"0877fcdc026242810f5bfde0d7178db4"}).`
6348
6432
  );
6349
6433
  }
6350
6434
  return serviceWorker;
@@ -7813,10 +7897,14 @@ If this message still persists after updating, please report an issue: https://g
7813
7897
  options,
7814
7898
  context.emitter,
7815
7899
  {
7816
- onMockedResponse(_, { handler, parsedRequest }) {
7900
+ onMockedResponse(_, { handler, parsedResult }) {
7817
7901
  if (!options.quiet) {
7818
7902
  context.emitter.once("response:mocked", ({ response: response2 }) => {
7819
- handler.log(requestCloneForLogs, response2, parsedRequest);
7903
+ handler.log({
7904
+ request: requestCloneForLogs,
7905
+ response: response2,
7906
+ parsedResult
7907
+ });
7820
7908
  });
7821
7909
  }
7822
7910
  }