msw 0.41.1 → 0.42.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,11 +1,7 @@
1
- var __create = Object.create;
2
1
  var __defProp = Object.defineProperty;
3
2
  var __defProps = Object.defineProperties;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
3
  var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
- var __getOwnPropNames = Object.getOwnPropertyNames;
7
4
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
- var __getProtoOf = Object.getPrototypeOf;
9
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
10
6
  var __propIsEnum = Object.prototype.propertyIsEnumerable;
11
7
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
@@ -40,215 +36,24 @@ var __objRest = (source, exclude) => {
40
36
  }
41
37
  return target;
42
38
  };
43
- var __esm = (fn, res) => function __init() {
44
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
45
- };
46
- var __commonJS = (cb, mod) => function __require2() {
47
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
48
- };
49
- var __copyProps = (to, from, except, desc) => {
50
- if (from && typeof from === "object" || typeof from === "function") {
51
- for (let key of __getOwnPropNames(from))
52
- if (!__hasOwnProp.call(to, key) && key !== except)
53
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
54
- }
55
- return to;
56
- };
57
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
58
-
59
- // node_modules/tsup/assets/esm_shims.js
60
- var init_esm_shims = __esm({
61
- "node_modules/tsup/assets/esm_shims.js"() {
62
- }
63
- });
64
39
 
65
40
  // config/polyfills-node.ts
66
41
  import { setTimeout as nodeSetTimeout } from "timers";
67
- var setTimeout;
68
- var init_polyfills_node = __esm({
69
- "config/polyfills-node.ts"() {
70
- setTimeout = nodeSetTimeout;
71
- }
72
- });
73
-
74
- // node_modules/outvariant/lib/format.js
75
- var require_format = __commonJS({
76
- "node_modules/outvariant/lib/format.js"(exports) {
77
- "use strict";
78
- init_esm_shims();
79
- init_polyfills_node();
80
- Object.defineProperty(exports, "__esModule", { value: true });
81
- exports.format = void 0;
82
- var POSITIONALS_EXP = /(%?)(%([sdjo]))/g;
83
- function serializePositional(positional, flag) {
84
- switch (flag) {
85
- case "s":
86
- return positional;
87
- case "d":
88
- case "i":
89
- return Number(positional);
90
- case "j":
91
- return JSON.stringify(positional);
92
- case "o": {
93
- if (typeof positional === "string") {
94
- return positional;
95
- }
96
- var json2 = JSON.stringify(positional);
97
- if (json2 === "{}" || json2 === "[]" || /^\[object .+?\]$/.test(json2)) {
98
- return positional;
99
- }
100
- return json2;
101
- }
102
- }
103
- }
104
- function format2(message) {
105
- var positionals = [];
106
- for (var _i = 1; _i < arguments.length; _i++) {
107
- positionals[_i - 1] = arguments[_i];
108
- }
109
- if (positionals.length === 0) {
110
- return message;
111
- }
112
- var positionalIndex = 0;
113
- var formattedMessage = message.replace(POSITIONALS_EXP, function(match2, isEscaped, _, flag) {
114
- var positional = positionals[positionalIndex];
115
- var value = serializePositional(positional, flag);
116
- if (!isEscaped) {
117
- positionalIndex++;
118
- return value;
119
- }
120
- return match2;
121
- });
122
- if (positionalIndex < positionals.length) {
123
- formattedMessage += " " + positionals.slice(positionalIndex).join(" ");
124
- }
125
- formattedMessage = formattedMessage.replace(/%{2,2}/g, "%");
126
- return formattedMessage;
127
- }
128
- exports.format = format2;
129
- }
130
- });
131
-
132
- // node_modules/outvariant/lib/invariant.js
133
- var require_invariant = __commonJS({
134
- "node_modules/outvariant/lib/invariant.js"(exports) {
135
- "use strict";
136
- init_esm_shims();
137
- init_polyfills_node();
138
- var __extends = exports && exports.__extends || function() {
139
- var extendStatics = function(d, b) {
140
- extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
141
- d2.__proto__ = b2;
142
- } || function(d2, b2) {
143
- for (var p in b2)
144
- if (Object.prototype.hasOwnProperty.call(b2, p))
145
- d2[p] = b2[p];
146
- };
147
- return extendStatics(d, b);
148
- };
149
- return function(d, b) {
150
- if (typeof b !== "function" && b !== null)
151
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
152
- extendStatics(d, b);
153
- function __() {
154
- this.constructor = d;
155
- }
156
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
157
- };
158
- }();
159
- var __spreadArray = exports && exports.__spreadArray || function(to, from) {
160
- for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
161
- to[j] = from[i];
162
- return to;
163
- };
164
- Object.defineProperty(exports, "__esModule", { value: true });
165
- exports.invariant = exports.InvariantError = void 0;
166
- var format_1 = require_format();
167
- var STACK_FRAMES_TO_IGNORE = 2;
168
- var InvariantError = function(_super) {
169
- __extends(InvariantError2, _super);
170
- function InvariantError2(message) {
171
- var positionals = [];
172
- for (var _i = 1; _i < arguments.length; _i++) {
173
- positionals[_i - 1] = arguments[_i];
174
- }
175
- var _this = _super.call(this, message) || this;
176
- _this.name = "Invariant Violation";
177
- _this.message = format_1.format.apply(void 0, __spreadArray([message], positionals));
178
- if (_this.stack) {
179
- var nextStack = _this.stack.split("\n");
180
- nextStack.splice(1, STACK_FRAMES_TO_IGNORE);
181
- _this.stack = nextStack.join("\n");
182
- }
183
- return _this;
184
- }
185
- return InvariantError2;
186
- }(Error);
187
- exports.InvariantError = InvariantError;
188
- function invariant(predicate, message) {
189
- var positionals = [];
190
- for (var _i = 2; _i < arguments.length; _i++) {
191
- positionals[_i - 2] = arguments[_i];
192
- }
193
- if (!predicate) {
194
- throw new (InvariantError.bind.apply(InvariantError, __spreadArray([void 0, message], positionals)))();
195
- }
196
- }
197
- exports.invariant = invariant;
198
- }
199
- });
200
-
201
- // node_modules/outvariant/lib/index.js
202
- var require_lib = __commonJS({
203
- "node_modules/outvariant/lib/index.js"(exports) {
204
- "use strict";
205
- init_esm_shims();
206
- init_polyfills_node();
207
- var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
208
- if (k2 === void 0)
209
- k2 = k;
210
- Object.defineProperty(o, k2, { enumerable: true, get: function() {
211
- return m[k];
212
- } });
213
- } : function(o, m, k, k2) {
214
- if (k2 === void 0)
215
- k2 = k;
216
- o[k2] = m[k];
217
- });
218
- var __exportStar = exports && exports.__exportStar || function(m, exports2) {
219
- for (var p in m)
220
- if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p))
221
- __createBinding(exports2, m, p);
222
- };
223
- Object.defineProperty(exports, "__esModule", { value: true });
224
- __exportStar(require_invariant(), exports);
225
- __exportStar(require_format(), exports);
226
- }
227
- });
228
-
229
- // src/node/index.ts
230
- init_esm_shims();
231
- init_polyfills_node();
42
+ var setTimeout = nodeSetTimeout;
232
43
 
233
44
  // src/node/setupServer.ts
234
- init_esm_shims();
235
- init_polyfills_node();
236
- import { interceptClientRequest } from "@mswjs/interceptors/lib/interceptors/ClientRequest";
237
- import { interceptXMLHttpRequest } from "@mswjs/interceptors/lib/interceptors/XMLHttpRequest";
45
+ import { ClientRequestInterceptor } from "@mswjs/interceptors/lib/interceptors/ClientRequest";
46
+ import { XMLHttpRequestInterceptor } from "@mswjs/interceptors/lib/interceptors/XMLHttpRequest";
238
47
 
239
48
  // src/node/createSetupServer.ts
240
- init_esm_shims();
241
- init_polyfills_node();
242
49
  import { bold } from "chalk";
243
50
  import { isNodeProcess as isNodeProcess3 } from "is-node-process";
244
51
  import { StrictEventEmitter } from "strict-event-emitter";
245
52
  import {
246
- createInterceptor
53
+ BatchInterceptor
247
54
  } from "@mswjs/interceptors";
248
55
 
249
56
  // src/utils/internal/requestHandlerUtils.ts
250
- init_esm_shims();
251
- init_polyfills_node();
252
57
  function use(currentHandlers, ...handlers) {
253
58
  currentHandlers.unshift(...handlers);
254
59
  }
@@ -261,23 +66,13 @@ function resetHandlers(initialHandlers, ...nextHandlers) {
261
66
  return nextHandlers.length > 0 ? [...nextHandlers] : [...initialHandlers];
262
67
  }
263
68
 
264
- // src/utils/request/parseIsomorphicRequest.ts
265
- init_esm_shims();
266
- init_polyfills_node();
267
-
268
69
  // src/handlers/RequestHandler.ts
269
- init_esm_shims();
270
- init_polyfills_node();
271
70
  import { Headers as Headers3 } from "headers-polyfill";
272
71
 
273
72
  // src/response.ts
274
- init_esm_shims();
275
- init_polyfills_node();
276
73
  import { Headers } from "headers-polyfill";
277
74
 
278
75
  // src/utils/internal/compose.ts
279
- init_esm_shims();
280
- init_polyfills_node();
281
76
  function compose(...fns) {
282
77
  return (...args) => {
283
78
  return fns.reduceRight((leftFn, rightFn) => {
@@ -287,8 +82,6 @@ function compose(...fns) {
287
82
  }
288
83
 
289
84
  // src/utils/NetworkError.ts
290
- init_esm_shims();
291
- init_polyfills_node();
292
85
  var NetworkError = class extends Error {
293
86
  constructor(message) {
294
87
  super(message);
@@ -329,8 +122,6 @@ var response = Object.assign(createResponseComposition(), {
329
122
  });
330
123
 
331
124
  // src/utils/internal/getCallFrame.ts
332
- init_esm_shims();
333
- init_polyfills_node();
334
125
  var SOURCE_FRAME = /\/msw\/src\/(.+)/;
335
126
  var BUILD_FRAME = /(node_modules)?[\/\\]lib[\/\\](umd|esm|iief|cjs)[\/\\]|^[^\/\\]*$/;
336
127
  function getCallFrame(error2) {
@@ -350,8 +141,6 @@ function getCallFrame(error2) {
350
141
  }
351
142
 
352
143
  // src/utils/internal/isIterable.ts
353
- init_esm_shims();
354
- init_polyfills_node();
355
144
  function isIterable(fn) {
356
145
  if (!fn) {
357
146
  return false;
@@ -360,8 +149,6 @@ function isIterable(fn) {
360
149
  }
361
150
 
362
151
  // src/context/status.ts
363
- init_esm_shims();
364
- init_polyfills_node();
365
152
  import statuses from "statuses/codes.json";
366
153
  var status = (statusCode, statusText) => {
367
154
  return (res) => {
@@ -372,8 +159,6 @@ var status = (statusCode, statusText) => {
372
159
  };
373
160
 
374
161
  // src/context/set.ts
375
- init_esm_shims();
376
- init_polyfills_node();
377
162
  import { objectToHeaders } from "headers-polyfill";
378
163
  function set(...args) {
379
164
  return (res) => {
@@ -391,8 +176,6 @@ function set(...args) {
391
176
  }
392
177
 
393
178
  // src/context/delay.ts
394
- init_esm_shims();
395
- init_polyfills_node();
396
179
  import { isNodeProcess } from "is-node-process";
397
180
  var SET_TIMEOUT_MAX_ALLOWED_INT = 2147483647;
398
181
  var MIN_SERVER_RESPONSE_TIME = 100;
@@ -435,8 +218,6 @@ var delay = (durationOrMode) => {
435
218
  };
436
219
 
437
220
  // src/context/fetch.ts
438
- init_esm_shims();
439
- init_polyfills_node();
440
221
  import { isNodeProcess as isNodeProcess2 } from "is-node-process";
441
222
  import { Headers as Headers2 } from "headers-polyfill";
442
223
  var useFetch = isNodeProcess2() ? __require("node-fetch") : window.fetch;
@@ -552,13 +333,7 @@ function passthrough() {
552
333
  };
553
334
  }
554
335
 
555
- // src/utils/request/parseBody.ts
556
- init_esm_shims();
557
- init_polyfills_node();
558
-
559
336
  // src/utils/internal/jsonParse.ts
560
- init_esm_shims();
561
- init_polyfills_node();
562
337
  function jsonParse(value) {
563
338
  try {
564
339
  return JSON.parse(value);
@@ -568,8 +343,6 @@ function jsonParse(value) {
568
343
  }
569
344
 
570
345
  // src/utils/internal/parseMultipartData.ts
571
- init_esm_shims();
572
- init_polyfills_node();
573
346
  import { stringToHeaders } from "headers-polyfill";
574
347
  function parseContentHeaders(headersString) {
575
348
  var _a, _b;
@@ -648,14 +421,10 @@ function parseBody(body2, headers) {
648
421
  }
649
422
 
650
423
  // src/utils/request/setRequestCookies.ts
651
- init_esm_shims();
652
- init_polyfills_node();
653
424
  import * as cookieUtils2 from "cookie";
654
425
  import { store } from "@mswjs/cookies";
655
426
 
656
427
  // src/utils/request/getRequestCookies.ts
657
- init_esm_shims();
658
- init_polyfills_node();
659
428
  import * as cookieUtils from "cookie";
660
429
  function getAllCookies() {
661
430
  return cookieUtils.parse(document.cookie);
@@ -720,13 +489,9 @@ function parseIsomorphicRequest(request) {
720
489
  }
721
490
 
722
491
  // src/utils/handleRequest.ts
723
- init_esm_shims();
724
- init_polyfills_node();
725
492
  import { until } from "@open-draft/until";
726
493
 
727
494
  // src/utils/getResponse.ts
728
- init_esm_shims();
729
- init_polyfills_node();
730
495
  var getResponse = async (request, handlers, resolutionContext) => {
731
496
  const relevantHandlers = handlers.filter((handler) => {
732
497
  return handler.test(request, resolutionContext);
@@ -774,12 +539,10 @@ var getResponse = async (request, handlers, resolutionContext) => {
774
539
  };
775
540
 
776
541
  // src/utils/internal/devUtils.ts
777
- init_esm_shims();
778
- init_polyfills_node();
779
- var import_outvariant = __toESM(require_lib());
542
+ import { format } from "outvariant";
780
543
  var LIBRARY_PREFIX = "[MSW]";
781
544
  function formatMessage(message, ...positionals) {
782
- const interpolatedMessage = (0, import_outvariant.format)(message, ...positionals);
545
+ const interpolatedMessage = format(message, ...positionals);
783
546
  return `${LIBRARY_PREFIX} ${interpolatedMessage}`;
784
547
  }
785
548
  function warn(message, ...positionals) {
@@ -795,20 +558,14 @@ var devUtils = {
795
558
  };
796
559
 
797
560
  // src/utils/request/onUnhandledRequest.ts
798
- init_esm_shims();
799
- init_polyfills_node();
800
561
  import getStringMatchScore from "js-levenshtein";
801
562
 
802
563
  // src/utils/internal/parseGraphQLRequest.ts
803
- init_esm_shims();
804
- init_polyfills_node();
805
564
  import {
806
565
  parse as parse3
807
566
  } from "graphql";
808
567
 
809
568
  // src/utils/request/getPublicUrlFromRequest.ts
810
- init_esm_shims();
811
- init_polyfills_node();
812
569
  var getPublicUrlFromRequest = (request) => {
813
570
  return request.referrer.startsWith(request.url.origin) ? request.url.pathname : new URL(request.url.pathname, `${request.url.protocol}//${request.url.host}`).href;
814
571
  };
@@ -909,23 +666,11 @@ function parseGraphQLRequest(request) {
909
666
  }
910
667
 
911
668
  // src/utils/internal/isStringEqual.ts
912
- init_esm_shims();
913
- init_polyfills_node();
914
669
  function isStringEqual(actual, expected) {
915
670
  return actual.toLowerCase() === expected.toLowerCase();
916
671
  }
917
672
 
918
- // src/handlers/RestHandler.ts
919
- init_esm_shims();
920
- init_polyfills_node();
921
-
922
- // src/context/index.ts
923
- init_esm_shims();
924
- init_polyfills_node();
925
-
926
673
  // src/context/cookie.ts
927
- init_esm_shims();
928
- init_polyfills_node();
929
674
  import * as cookieUtils3 from "cookie";
930
675
  var cookie = (name, value, options) => {
931
676
  return (res) => {
@@ -939,8 +684,6 @@ var cookie = (name, value, options) => {
939
684
  };
940
685
 
941
686
  // src/context/body.ts
942
- init_esm_shims();
943
- init_polyfills_node();
944
687
  var body = (value) => {
945
688
  return (res) => {
946
689
  res.body = value;
@@ -948,17 +691,7 @@ var body = (value) => {
948
691
  };
949
692
  };
950
693
 
951
- // src/context/data.ts
952
- init_esm_shims();
953
- init_polyfills_node();
954
-
955
- // src/utils/internal/mergeRight.ts
956
- init_esm_shims();
957
- init_polyfills_node();
958
-
959
694
  // src/utils/internal/isObject.ts
960
- init_esm_shims();
961
- init_polyfills_node();
962
695
  function isObject(value) {
963
696
  return value != null && typeof value === "object" && !Array.isArray(value);
964
697
  }
@@ -981,8 +714,6 @@ function mergeRight(left, right) {
981
714
  }
982
715
 
983
716
  // src/context/json.ts
984
- init_esm_shims();
985
- init_polyfills_node();
986
717
  var json = (body2) => {
987
718
  return (res) => {
988
719
  res.headers.set("Content-Type", "application/json");
@@ -1001,8 +732,6 @@ var data = (payload) => {
1001
732
  };
1002
733
 
1003
734
  // src/context/extensions.ts
1004
- init_esm_shims();
1005
- init_polyfills_node();
1006
735
  var extensions = (payload) => {
1007
736
  return (res) => {
1008
737
  const prevBody = jsonParse(res.body) || {};
@@ -1012,8 +741,6 @@ var extensions = (payload) => {
1012
741
  };
1013
742
 
1014
743
  // src/context/errors.ts
1015
- init_esm_shims();
1016
- init_polyfills_node();
1017
744
  var errors = (errorsList) => {
1018
745
  return (res) => {
1019
746
  if (errorsList == null) {
@@ -1026,8 +753,6 @@ var errors = (errorsList) => {
1026
753
  };
1027
754
 
1028
755
  // src/context/text.ts
1029
- init_esm_shims();
1030
- init_polyfills_node();
1031
756
  var text = (body2) => {
1032
757
  return (res) => {
1033
758
  res.headers.set("Content-Type", "text/plain");
@@ -1037,8 +762,6 @@ var text = (body2) => {
1037
762
  };
1038
763
 
1039
764
  // src/context/xml.ts
1040
- init_esm_shims();
1041
- init_polyfills_node();
1042
765
  var xml = (body2) => {
1043
766
  return (res) => {
1044
767
  res.headers.set("Content-Type", "text/xml");
@@ -1048,8 +771,6 @@ var xml = (body2) => {
1048
771
  };
1049
772
 
1050
773
  // src/utils/logging/getStatusCodeColor.ts
1051
- init_esm_shims();
1052
- init_polyfills_node();
1053
774
  function getStatusCodeColor(status2) {
1054
775
  if (status2 < 300) {
1055
776
  return "#69AB32" /* Success */;
@@ -1061,16 +782,12 @@ function getStatusCodeColor(status2) {
1061
782
  }
1062
783
 
1063
784
  // src/utils/logging/getTimestamp.ts
1064
- init_esm_shims();
1065
- init_polyfills_node();
1066
785
  function getTimestamp() {
1067
786
  const now = new Date();
1068
787
  return [now.getHours(), now.getMinutes(), now.getSeconds()].map(String).map((chunk) => chunk.slice(0, 2)).map((chunk) => chunk.padStart(2, "0")).join(":");
1069
788
  }
1070
789
 
1071
790
  // src/utils/logging/prepareRequest.ts
1072
- init_esm_shims();
1073
- init_polyfills_node();
1074
791
  function prepareRequest(request) {
1075
792
  return __spreadProps(__spreadValues({}, request), {
1076
793
  headers: request.headers.all()
@@ -1078,8 +795,6 @@ function prepareRequest(request) {
1078
795
  }
1079
796
 
1080
797
  // src/utils/logging/prepareResponse.ts
1081
- init_esm_shims();
1082
- init_polyfills_node();
1083
798
  import { objectToHeaders as objectToHeaders2 } from "headers-polyfill";
1084
799
  function prepareResponse(res) {
1085
800
  const responseHeaders = objectToHeaders2(res.headers);
@@ -1089,18 +804,10 @@ function prepareResponse(res) {
1089
804
  }
1090
805
 
1091
806
  // src/utils/matching/matchRequestUrl.ts
1092
- init_esm_shims();
1093
- init_polyfills_node();
1094
807
  import { match } from "path-to-regexp";
1095
808
  import { getCleanUrl } from "@mswjs/interceptors/lib/utils/getCleanUrl";
1096
809
 
1097
- // src/utils/matching/normalizePath.ts
1098
- init_esm_shims();
1099
- init_polyfills_node();
1100
-
1101
810
  // src/utils/url/cleanUrl.ts
1102
- init_esm_shims();
1103
- init_polyfills_node();
1104
811
  var REDUNDANT_CHARACTERS_EXP = /[\?|#].*$/g;
1105
812
  function getSearchParams(path) {
1106
813
  return new URL(`/${path}`, "http://localhost").searchParams;
@@ -1109,13 +816,7 @@ function cleanUrl(path) {
1109
816
  return path.replace(REDUNDANT_CHARACTERS_EXP, "");
1110
817
  }
1111
818
 
1112
- // src/utils/url/getAbsoluteUrl.ts
1113
- init_esm_shims();
1114
- init_polyfills_node();
1115
-
1116
819
  // src/utils/url/isAbsoluteUrl.ts
1117
- init_esm_shims();
1118
- init_polyfills_node();
1119
820
  function isAbsoluteUrl(url) {
1120
821
  return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url);
1121
822
  }
@@ -1228,13 +929,7 @@ var RestHandler = class extends RequestHandler {
1228
929
  }
1229
930
  };
1230
931
 
1231
- // src/handlers/GraphQLHandler.ts
1232
- init_esm_shims();
1233
- init_polyfills_node();
1234
-
1235
932
  // src/utils/internal/tryCatch.ts
1236
- init_esm_shims();
1237
- init_polyfills_node();
1238
933
  function tryCatch(fn, onException) {
1239
934
  try {
1240
935
  const result = fn();
@@ -1429,8 +1124,6 @@ Read more: https://mswjs.io/docs/getting-started/mocks`
1429
1124
  }
1430
1125
 
1431
1126
  // src/utils/request/readResponseCookies.ts
1432
- init_esm_shims();
1433
- init_polyfills_node();
1434
1127
  import { store as store2 } from "@mswjs/cookies";
1435
1128
  function readResponseCookies(request, response2) {
1436
1129
  store2.add(__spreadProps(__spreadValues({}, request), { url: request.url.toString() }), response2);
@@ -1492,8 +1185,6 @@ async function handleRequest(request, handlers, options, emitter, handleRequestO
1492
1185
  }
1493
1186
 
1494
1187
  // src/utils/internal/pipeEvents.ts
1495
- init_esm_shims();
1496
- init_polyfills_node();
1497
1188
  function pipeEvents(source, destination) {
1498
1189
  const rawEmit = source.emit;
1499
1190
  if (rawEmit._isPiped) {
@@ -1524,21 +1215,26 @@ function createSetupServer(...interceptors) {
1524
1215
  throw new Error(devUtils.formatMessage("Failed to execute `setupServer` in the environment that is not Node.js (i.e. a browser). Consider using `setupWorker` instead."));
1525
1216
  }
1526
1217
  let resolvedOptions = {};
1527
- const interceptor = createInterceptor({
1528
- modules: interceptors,
1529
- async resolver(request) {
1530
- const mockedRequest = parseIsomorphicRequest(request);
1531
- return handleRequest(mockedRequest, currentHandlers, resolvedOptions, emitter, {
1532
- transformResponse(response2) {
1533
- return {
1534
- status: response2.status,
1535
- statusText: response2.statusText,
1536
- headers: response2.headers.all(),
1537
- body: response2.body
1538
- };
1539
- }
1540
- });
1218
+ const interceptor = new BatchInterceptor({
1219
+ name: "setup-server",
1220
+ interceptors
1221
+ });
1222
+ interceptor.on("request", async function setupServerListener(request) {
1223
+ const mockedRequest = parseIsomorphicRequest(request);
1224
+ const response2 = await handleRequest(mockedRequest, currentHandlers, resolvedOptions, emitter, {
1225
+ transformResponse(response3) {
1226
+ return {
1227
+ status: response3.status,
1228
+ statusText: response3.statusText,
1229
+ headers: response3.headers.all(),
1230
+ body: response3.body
1231
+ };
1232
+ }
1233
+ });
1234
+ if (response2) {
1235
+ request.respondWith(response2);
1541
1236
  }
1237
+ return;
1542
1238
  });
1543
1239
  interceptor.on("response", (request, response2) => {
1544
1240
  if (!request.id) {
@@ -1587,14 +1283,14 @@ function createSetupServer(...interceptors) {
1587
1283
  close() {
1588
1284
  emitter.removeAllListeners();
1589
1285
  publicEmitter.removeAllListeners();
1590
- interceptor.restore();
1286
+ interceptor.dispose();
1591
1287
  }
1592
1288
  };
1593
1289
  };
1594
1290
  }
1595
1291
 
1596
1292
  // src/node/setupServer.ts
1597
- var setupServer = createSetupServer(interceptClientRequest, interceptXMLHttpRequest);
1293
+ var setupServer = createSetupServer(new ClientRequestInterceptor(), new XMLHttpRequestInterceptor());
1598
1294
  export {
1599
1295
  setupServer
1600
1296
  };