msw 2.0.8 → 2.0.10

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 (37) hide show
  1. package/lib/browser/index.js +16 -13
  2. package/lib/browser/index.mjs +14 -11
  3. package/lib/core/{GraphQLHandler-d4787f91.d.ts → GraphQLHandler-907fc607.d.ts} +22 -8
  4. package/lib/core/HttpResponse.d.ts +1 -1
  5. package/lib/core/{RequestHandler-bb5cbb8f.d.ts → RequestHandler-50ddea0c.d.ts} +4 -0
  6. package/lib/core/SetupApi.d.ts +1 -1
  7. package/lib/core/SetupApi.js +14 -11
  8. package/lib/core/SetupApi.mjs +14 -11
  9. package/lib/core/graphql.d.ts +2 -2
  10. package/lib/core/handlers/GraphQLHandler.d.ts +2 -2
  11. package/lib/core/handlers/GraphQLHandler.js +11 -13
  12. package/lib/core/handlers/GraphQLHandler.mjs +11 -13
  13. package/lib/core/handlers/HttpHandler.d.ts +1 -1
  14. package/lib/core/handlers/RequestHandler.d.ts +1 -1
  15. package/lib/core/handlers/RequestHandler.js +4 -0
  16. package/lib/core/handlers/RequestHandler.mjs +4 -0
  17. package/lib/core/http.d.ts +1 -1
  18. package/lib/core/index.d.ts +2 -2
  19. package/lib/core/sharedOptions.d.ts +1 -1
  20. package/lib/core/utils/HttpResponse/decorators.d.ts +1 -1
  21. package/lib/core/utils/getResponse.d.ts +1 -1
  22. package/lib/core/utils/handleRequest.d.ts +9 -2
  23. package/lib/core/utils/internal/parseGraphQLRequest.d.ts +2 -2
  24. package/lib/core/utils/internal/parseMultipartData.d.ts +1 -1
  25. package/lib/core/utils/internal/pipeEvents.js +3 -2
  26. package/lib/core/utils/internal/pipeEvents.mjs +3 -2
  27. package/lib/core/utils/internal/requestHandlerUtils.d.ts +1 -1
  28. package/lib/core/utils/request/onUnhandledRequest.d.ts +1 -1
  29. package/lib/iife/index.js +88 -225
  30. package/lib/mockServiceWorker.js +4 -9
  31. package/lib/native/index.d.ts +1 -12
  32. package/lib/native/index.js +4 -58
  33. package/lib/native/index.mjs +4 -48
  34. package/lib/node/index.d.ts +1 -12
  35. package/lib/node/index.js +31 -54
  36. package/lib/node/index.mjs +31 -44
  37. package/package.json +4 -3
package/lib/iife/index.js CHANGED
@@ -393,11 +393,12 @@ var MockServiceWorker = (() => {
393
393
  if (rawEmit._isPiped) {
394
394
  return;
395
395
  }
396
- source.emit = function(event, ...data) {
396
+ const sourceEmit = function sourceEmit2(event, ...data) {
397
397
  destination.emit(event, ...data);
398
398
  return rawEmit.call(this, event, ...data);
399
399
  };
400
- source.emit._isPiped = true;
400
+ sourceEmit._isPiped = true;
401
+ source.emit = sourceEmit;
401
402
  }
402
403
 
403
404
  // src/core/utils/internal/toReadonlyArray.ts
@@ -423,7 +424,12 @@ var MockServiceWorker = (() => {
423
424
  var SetupApi = class extends Disposable {
424
425
  constructor(...initialHandlers) {
425
426
  super();
426
- this.validateHandlers(...initialHandlers);
427
+ invariant(
428
+ this.validateHandlers(initialHandlers),
429
+ devUtils.formatMessage(
430
+ `Failed to apply given request handlers: invalid input. Did you forget to spread the request handlers Array?`
431
+ )
432
+ );
427
433
  this.initialHandlers = toReadonlyArray(initialHandlers);
428
434
  this.currentHandlers = [...initialHandlers];
429
435
  this.emitter = new Emitter();
@@ -435,18 +441,16 @@ var MockServiceWorker = (() => {
435
441
  this.publicEmitter.removeAllListeners();
436
442
  });
437
443
  }
438
- validateHandlers(...handlers) {
439
- for (const handler of handlers) {
440
- invariant(
441
- !Array.isArray(handler),
442
- devUtils.formatMessage(
443
- 'Failed to construct "%s" given an Array of request handlers. Make sure you spread the request handlers when calling the respective setup function.'
444
- ),
445
- this.constructor.name
446
- );
447
- }
444
+ validateHandlers(handlers) {
445
+ return handlers.every((handler) => !Array.isArray(handler));
448
446
  }
449
447
  use(...runtimeHandlers) {
448
+ invariant(
449
+ this.validateHandlers(runtimeHandlers),
450
+ devUtils.formatMessage(
451
+ `Failed to call "use()" with the given request handlers: invalid input. Did you forget to spread the array of request handlers?`
452
+ )
453
+ );
450
454
  this.currentHandlers.unshift(...runtimeHandlers);
451
455
  }
452
456
  restoreHandlers() {
@@ -524,6 +528,10 @@ var MockServiceWorker = (() => {
524
528
  }
525
529
  /**
526
530
  * Test if this handler matches the given request.
531
+ *
532
+ * This method is not used internally but is exposed
533
+ * as a convenience method for consumers writing custom
534
+ * handlers.
527
535
  */
528
536
  test(args) {
529
537
  return __async(this, null, function* () {
@@ -1143,6 +1151,32 @@ var MockServiceWorker = (() => {
1143
1151
  return stringToRegexp(path, keys, options);
1144
1152
  }
1145
1153
 
1154
+ // node_modules/.pnpm/@mswjs+interceptors@0.25.13/node_modules/@mswjs/interceptors/lib/browser/chunk-3YG2666Q.mjs
1155
+ var encoder = new TextEncoder();
1156
+ function encodeBuffer(text) {
1157
+ return encoder.encode(text);
1158
+ }
1159
+ function decodeBuffer(buffer, encoding) {
1160
+ const decoder = new TextDecoder(encoding);
1161
+ return decoder.decode(buffer);
1162
+ }
1163
+ function toArrayBuffer(array) {
1164
+ return array.buffer.slice(
1165
+ array.byteOffset,
1166
+ array.byteOffset + array.byteLength
1167
+ );
1168
+ }
1169
+ var RESPONSE_STATUS_CODES_WITHOUT_BODY = /* @__PURE__ */ new Set([
1170
+ 101,
1171
+ 103,
1172
+ 204,
1173
+ 205,
1174
+ 304
1175
+ ]);
1176
+ function isResponseWithoutBody(status) {
1177
+ return RESPONSE_STATUS_CODES_WITHOUT_BODY.has(status);
1178
+ }
1179
+
1146
1180
  // node_modules/.pnpm/is-node-process@1.2.0/node_modules/is-node-process/lib/index.mjs
1147
1181
  function isNodeProcess() {
1148
1182
  if (typeof navigator !== "undefined" && navigator.product === "ReactNative") {
@@ -1596,7 +1630,8 @@ var MockServiceWorker = (() => {
1596
1630
  var Emitter2 = _Emitter2;
1597
1631
  Emitter2.defaultMaxListeners = 10;
1598
1632
 
1599
- // node_modules/.pnpm/@mswjs+interceptors@0.25.11/node_modules/@mswjs/interceptors/lib/node/chunk-JAW6F2FR.mjs
1633
+ // node_modules/.pnpm/@mswjs+interceptors@0.25.13/node_modules/@mswjs/interceptors/lib/browser/chunk-S72SKXXQ.mjs
1634
+ var IS_PATCHED_MODULE = Symbol("isPatchedModule");
1600
1635
  function getGlobalSymbol(symbol) {
1601
1636
  return (
1602
1637
  // @ts-ignore https://github.com/Microsoft/TypeScript/issues/24587
@@ -1740,7 +1775,7 @@ var MockServiceWorker = (() => {
1740
1775
  }
1741
1776
  };
1742
1777
 
1743
- // node_modules/.pnpm/@mswjs+interceptors@0.25.11/node_modules/@mswjs/interceptors/lib/node/chunk-LNYHQTKT.mjs
1778
+ // node_modules/.pnpm/@mswjs+interceptors@0.25.13/node_modules/@mswjs/interceptors/lib/browser/index.mjs
1744
1779
  var BatchInterceptor = class extends Interceptor {
1745
1780
  constructor(options) {
1746
1781
  BatchInterceptor.symbol = Symbol(options.name);
@@ -1782,14 +1817,6 @@ var MockServiceWorker = (() => {
1782
1817
  return this;
1783
1818
  }
1784
1819
  };
1785
-
1786
- // node_modules/.pnpm/@mswjs+interceptors@0.25.11/node_modules/@mswjs/interceptors/lib/node/chunk-7II4SWKS.mjs
1787
- var encoder = new TextEncoder();
1788
-
1789
- // node_modules/.pnpm/@mswjs+interceptors@0.25.11/node_modules/@mswjs/interceptors/lib/node/chunk-GFH37L5D.mjs
1790
- var IS_PATCHED_MODULE = Symbol("isPatchedModule");
1791
-
1792
- // node_modules/.pnpm/@mswjs+interceptors@0.25.11/node_modules/@mswjs/interceptors/lib/node/index.mjs
1793
1820
  function getCleanUrl(url, isAbsolute = true) {
1794
1821
  return [isAbsolute && url.origin, url.pathname].filter(Boolean).join("");
1795
1822
  }
@@ -5636,6 +5663,9 @@ spurious results.`);
5636
5663
  }
5637
5664
  parse(args) {
5638
5665
  return __async(this, null, function* () {
5666
+ const match2 = matchRequestUrl(new URL(args.request.url), this.endpoint);
5667
+ if (!match2.matches)
5668
+ return { match: match2 };
5639
5669
  const parsedResult = yield parseGraphQLRequest(args.request).catch(
5640
5670
  (error3) => {
5641
5671
  console.error(error3);
@@ -5643,9 +5673,10 @@ spurious results.`);
5643
5673
  }
5644
5674
  );
5645
5675
  if (typeof parsedResult === "undefined") {
5646
- return void 0;
5676
+ return { match: match2 };
5647
5677
  }
5648
5678
  return {
5679
+ match: match2,
5649
5680
  query: parsedResult.query,
5650
5681
  operationType: parsedResult.operationType,
5651
5682
  operationName: parsedResult.operationName,
@@ -5654,7 +5685,7 @@ spurious results.`);
5654
5685
  });
5655
5686
  }
5656
5687
  predicate(args) {
5657
- if (!args.parsedResult) {
5688
+ if (args.parsedResult.operationType === void 0) {
5658
5689
  return false;
5659
5690
  }
5660
5691
  if (!args.parsedResult.operationName && this.info.operationType !== "all") {
@@ -5664,31 +5695,25 @@ spurious results.`);
5664
5695
  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/#graphqloperationresolver`);
5665
5696
  return false;
5666
5697
  }
5667
- const hasMatchingUrl = matchRequestUrl(
5668
- new URL(args.request.url),
5669
- this.endpoint
5670
- );
5671
5698
  const hasMatchingOperationType = this.info.operationType === "all" || args.parsedResult.operationType === this.info.operationType;
5672
5699
  const hasMatchingOperationName = this.info.operationName instanceof RegExp ? this.info.operationName.test(args.parsedResult.operationName || "") : args.parsedResult.operationName === this.info.operationName;
5673
- return hasMatchingUrl.matches && hasMatchingOperationType && hasMatchingOperationName;
5700
+ return args.parsedResult.match.matches && hasMatchingOperationType && hasMatchingOperationName;
5674
5701
  }
5675
5702
  extendResolverArgs(args) {
5676
- var _a3, _b2, _c;
5677
5703
  const cookies = getAllRequestCookies(args.request);
5678
5704
  return {
5679
- query: ((_a3 = args.parsedResult) == null ? void 0 : _a3.query) || "",
5680
- operationName: ((_b2 = args.parsedResult) == null ? void 0 : _b2.operationName) || "",
5681
- variables: ((_c = args.parsedResult) == null ? void 0 : _c.variables) || {},
5705
+ query: args.parsedResult.query || "",
5706
+ operationName: args.parsedResult.operationName || "",
5707
+ variables: args.parsedResult.variables || {},
5682
5708
  cookies
5683
5709
  };
5684
5710
  }
5685
5711
  log(args) {
5686
5712
  return __async(this, null, function* () {
5687
- var _a3, _b2, _c, _d;
5688
5713
  const loggedRequest = yield serializeRequest(args.request);
5689
5714
  const loggedResponse = yield serializeResponse(args.response);
5690
5715
  const statusColor = getStatusCodeColor(loggedResponse.status);
5691
- 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}`;
5716
+ const requestInfo = args.parsedResult.operationName ? `${args.parsedResult.operationType} ${args.parsedResult.operationName}` : `anonymous ${args.parsedResult.operationType}`;
5692
5717
  console.groupCollapsed(
5693
5718
  devUtils.formatMessage(
5694
5719
  `${getTimestamp()} ${requestInfo} (%c${loggedResponse.status} ${loggedResponse.statusText}%c)`
@@ -6437,14 +6462,7 @@ Learn more about creating the Service Worker script: https://mswjs.io/docs/cli/i
6437
6462
  }
6438
6463
  postMessage(event, ...rest) {
6439
6464
  const [data, transfer] = rest;
6440
- this.port.postMessage(
6441
- { type: event, data },
6442
- {
6443
- // @ts-ignore ReadableStream can be transferred
6444
- // but TypeScript doesn't acknowledge that.
6445
- transfer
6446
- }
6447
- );
6465
+ this.port.postMessage({ type: event, data }, { transfer });
6448
6466
  }
6449
6467
  };
6450
6468
 
@@ -6561,9 +6579,9 @@ This exception has been gracefully handled as a 500 response, however, it's stro
6561
6579
  const { payload: actualChecksum } = yield context.events.once(
6562
6580
  "INTEGRITY_CHECK_RESPONSE"
6563
6581
  );
6564
- if (actualChecksum !== "0877fcdc026242810f5bfde0d7178db4") {
6582
+ if (actualChecksum !== "c5f7f8e188b673ea4e677df7ea3c5a39") {
6565
6583
  throw new Error(
6566
- `Currently active Service Worker (${actualChecksum}) is behind the latest published one (${"0877fcdc026242810f5bfde0d7178db4"}).`
6584
+ `Currently active Service Worker (${actualChecksum}) is behind the latest published one (${"c5f7f8e188b673ea4e677df7ea3c5a39"}).`
6567
6585
  );
6568
6586
  }
6569
6587
  return serviceWorker;
@@ -6595,7 +6613,16 @@ This exception has been gracefully handled as a 500 response, however, it's stro
6595
6613
  if ((_a3 = responseJson.type) == null ? void 0 : _a3.includes("opaque")) {
6596
6614
  return;
6597
6615
  }
6598
- const response = responseJson.status === 0 ? Response.error() : new Response(responseJson.body, responseJson);
6616
+ const response = responseJson.status === 0 ? Response.error() : new Response(
6617
+ /**
6618
+ * Responses may be streams here, but when we create a response object
6619
+ * with null-body status codes, like 204, 205, 304 Response will
6620
+ * throw when passed a non-null body, so ensure it's null here
6621
+ * for those codes
6622
+ */
6623
+ isResponseWithoutBody(responseJson.status) ? null : responseJson.body,
6624
+ responseJson
6625
+ );
6599
6626
  context.emitter.emit(
6600
6627
  responseJson.isMockedResponse ? "response:mocked" : "response:bypass",
6601
6628
  {
@@ -6842,7 +6869,7 @@ If this message still persists after updating, please report an issue: https://g
6842
6869
  });
6843
6870
  }, _a2);
6844
6871
 
6845
- // node_modules/.pnpm/@mswjs+interceptors@0.25.11/node_modules/@mswjs/interceptors/lib/browser/chunk-KK6APRON.mjs
6872
+ // node_modules/.pnpm/@mswjs+interceptors@0.25.13/node_modules/@mswjs/interceptors/lib/browser/chunk-KK6APRON.mjs
6846
6873
  function uuidv4() {
6847
6874
  return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
6848
6875
  const r = Math.random() * 16 | 0;
@@ -6889,152 +6916,7 @@ If this message still persists after updating, please report an issue: https://g
6889
6916
  });
6890
6917
  }
6891
6918
 
6892
- // node_modules/.pnpm/@mswjs+interceptors@0.25.11/node_modules/@mswjs/interceptors/lib/browser/chunk-S72SKXXQ.mjs
6893
- var IS_PATCHED_MODULE2 = Symbol("isPatchedModule");
6894
- function getGlobalSymbol2(symbol) {
6895
- return (
6896
- // @ts-ignore https://github.com/Microsoft/TypeScript/issues/24587
6897
- globalThis[symbol] || void 0
6898
- );
6899
- }
6900
- function setGlobalSymbol2(symbol, value) {
6901
- globalThis[symbol] = value;
6902
- }
6903
- function deleteGlobalSymbol2(symbol) {
6904
- delete globalThis[symbol];
6905
- }
6906
- var Interceptor2 = class {
6907
- constructor(symbol) {
6908
- this.symbol = symbol;
6909
- this.readyState = "INACTIVE";
6910
- this.emitter = new Emitter2();
6911
- this.subscriptions = [];
6912
- this.logger = new Logger(symbol.description);
6913
- this.emitter.setMaxListeners(0);
6914
- this.logger.info("constructing the interceptor...");
6915
- }
6916
- /**
6917
- * Determine if this interceptor can be applied
6918
- * in the current environment.
6919
- */
6920
- checkEnvironment() {
6921
- return true;
6922
- }
6923
- /**
6924
- * Apply this interceptor to the current process.
6925
- * Returns an already running interceptor instance if it's present.
6926
- */
6927
- apply() {
6928
- const logger = this.logger.extend("apply");
6929
- logger.info("applying the interceptor...");
6930
- if (this.readyState === "APPLIED") {
6931
- logger.info("intercepted already applied!");
6932
- return;
6933
- }
6934
- const shouldApply = this.checkEnvironment();
6935
- if (!shouldApply) {
6936
- logger.info("the interceptor cannot be applied in this environment!");
6937
- return;
6938
- }
6939
- this.readyState = "APPLYING";
6940
- const runningInstance = this.getInstance();
6941
- if (runningInstance) {
6942
- logger.info("found a running instance, reusing...");
6943
- this.on = (event, listener) => {
6944
- logger.info('proxying the "%s" listener', event);
6945
- runningInstance.emitter.addListener(event, listener);
6946
- this.subscriptions.push(() => {
6947
- runningInstance.emitter.removeListener(event, listener);
6948
- logger.info('removed proxied "%s" listener!', event);
6949
- });
6950
- return this;
6951
- };
6952
- this.readyState = "APPLIED";
6953
- return;
6954
- }
6955
- logger.info("no running instance found, setting up a new instance...");
6956
- this.setup();
6957
- this.setInstance();
6958
- this.readyState = "APPLIED";
6959
- }
6960
- /**
6961
- * Setup the module augments and stubs necessary for this interceptor.
6962
- * This method is not run if there's a running interceptor instance
6963
- * to prevent instantiating an interceptor multiple times.
6964
- */
6965
- setup() {
6966
- }
6967
- /**
6968
- * Listen to the interceptor's public events.
6969
- */
6970
- on(event, listener) {
6971
- const logger = this.logger.extend("on");
6972
- if (this.readyState === "DISPOSING" || this.readyState === "DISPOSED") {
6973
- logger.info("cannot listen to events, already disposed!");
6974
- return this;
6975
- }
6976
- logger.info('adding "%s" event listener:', event, listener);
6977
- this.emitter.on(event, listener);
6978
- return this;
6979
- }
6980
- once(event, listener) {
6981
- this.emitter.once(event, listener);
6982
- return this;
6983
- }
6984
- off(event, listener) {
6985
- this.emitter.off(event, listener);
6986
- return this;
6987
- }
6988
- removeAllListeners(event) {
6989
- this.emitter.removeAllListeners(event);
6990
- return this;
6991
- }
6992
- /**
6993
- * Disposes of any side-effects this interceptor has introduced.
6994
- */
6995
- dispose() {
6996
- const logger = this.logger.extend("dispose");
6997
- if (this.readyState === "DISPOSED") {
6998
- logger.info("cannot dispose, already disposed!");
6999
- return;
7000
- }
7001
- logger.info("disposing the interceptor...");
7002
- this.readyState = "DISPOSING";
7003
- if (!this.getInstance()) {
7004
- logger.info("no interceptors running, skipping dispose...");
7005
- return;
7006
- }
7007
- this.clearInstance();
7008
- logger.info("global symbol deleted:", getGlobalSymbol2(this.symbol));
7009
- if (this.subscriptions.length > 0) {
7010
- logger.info("disposing of %d subscriptions...", this.subscriptions.length);
7011
- for (const dispose of this.subscriptions) {
7012
- dispose();
7013
- }
7014
- this.subscriptions = [];
7015
- logger.info("disposed of all subscriptions!", this.subscriptions.length);
7016
- }
7017
- this.emitter.removeAllListeners();
7018
- logger.info("destroyed the listener!");
7019
- this.readyState = "DISPOSED";
7020
- }
7021
- getInstance() {
7022
- var _a3;
7023
- const instance = getGlobalSymbol2(this.symbol);
7024
- this.logger.info("retrieved global instance:", (_a3 = instance == null ? void 0 : instance.constructor) == null ? void 0 : _a3.name);
7025
- return instance;
7026
- }
7027
- setInstance() {
7028
- setGlobalSymbol2(this.symbol, this);
7029
- this.logger.info("set global instance!", this.symbol.description);
7030
- }
7031
- clearInstance() {
7032
- deleteGlobalSymbol2(this.symbol);
7033
- this.logger.info("cleared global instance!", this.symbol.description);
7034
- }
7035
- };
7036
-
7037
- // node_modules/.pnpm/@mswjs+interceptors@0.25.11/node_modules/@mswjs/interceptors/lib/browser/chunk-KRADPSOF.mjs
6919
+ // node_modules/.pnpm/@mswjs+interceptors@0.25.13/node_modules/@mswjs/interceptors/lib/browser/chunk-KRADPSOF.mjs
7038
6920
  function isPropertyAccessible2(obj, key) {
7039
6921
  try {
7040
6922
  obj[key];
@@ -7043,7 +6925,7 @@ If this message still persists after updating, please report an issue: https://g
7043
6925
  return false;
7044
6926
  }
7045
6927
  }
7046
- var _FetchInterceptor = class extends Interceptor2 {
6928
+ var _FetchInterceptor = class extends Interceptor {
7047
6929
  constructor() {
7048
6930
  super(_FetchInterceptor.symbol);
7049
6931
  }
@@ -7053,7 +6935,7 @@ If this message still persists after updating, please report an issue: https://g
7053
6935
  setup() {
7054
6936
  const pureFetch = globalThis.fetch;
7055
6937
  invariant(
7056
- !pureFetch[IS_PATCHED_MODULE2],
6938
+ !pureFetch[IS_PATCHED_MODULE],
7057
6939
  'Failed to patch the "fetch" module: already patched.'
7058
6940
  );
7059
6941
  globalThis.fetch = (input, init) => __async(this, null, function* () {
@@ -7146,13 +7028,13 @@ If this message still persists after updating, please report an issue: https://g
7146
7028
  return response;
7147
7029
  });
7148
7030
  });
7149
- Object.defineProperty(globalThis.fetch, IS_PATCHED_MODULE2, {
7031
+ Object.defineProperty(globalThis.fetch, IS_PATCHED_MODULE, {
7150
7032
  enumerable: true,
7151
7033
  configurable: true,
7152
7034
  value: true
7153
7035
  });
7154
7036
  this.subscriptions.push(() => {
7155
- Object.defineProperty(globalThis.fetch, IS_PATCHED_MODULE2, {
7037
+ Object.defineProperty(globalThis.fetch, IS_PATCHED_MODULE, {
7156
7038
  value: void 0
7157
7039
  });
7158
7040
  globalThis.fetch = pureFetch;
@@ -7171,23 +7053,7 @@ If this message still persists after updating, please report an issue: https://g
7171
7053
  });
7172
7054
  }
7173
7055
 
7174
- // node_modules/.pnpm/@mswjs+interceptors@0.25.11/node_modules/@mswjs/interceptors/lib/browser/chunk-7II4SWKS.mjs
7175
- var encoder2 = new TextEncoder();
7176
- function encodeBuffer2(text) {
7177
- return encoder2.encode(text);
7178
- }
7179
- function decodeBuffer2(buffer, encoding) {
7180
- const decoder = new TextDecoder(encoding);
7181
- return decoder.decode(buffer);
7182
- }
7183
- function toArrayBuffer(array) {
7184
- return array.buffer.slice(
7185
- array.byteOffset,
7186
- array.byteOffset + array.byteLength
7187
- );
7188
- }
7189
-
7190
- // node_modules/.pnpm/@mswjs+interceptors@0.25.11/node_modules/@mswjs/interceptors/lib/browser/chunk-PYOA2PFX.mjs
7056
+ // node_modules/.pnpm/@mswjs+interceptors@0.25.13/node_modules/@mswjs/interceptors/lib/browser/chunk-XILA3UPG.mjs
7191
7057
  function concatArrayBuffer(left, right) {
7192
7058
  const result = new Uint8Array(left.byteLength + right.byteLength);
7193
7059
  result.set(left, 0);
@@ -7349,11 +7215,8 @@ If this message still persists after updating, please report an issue: https://g
7349
7215
  return null;
7350
7216
  }
7351
7217
  }
7352
- var responseStatusCodesWithoutBody = [204, 205, 304];
7353
7218
  function createResponse(request, body) {
7354
- const responseBodyOrNull = responseStatusCodesWithoutBody.includes(
7355
- request.status
7356
- ) ? null : body;
7219
+ const responseBodyOrNull = isResponseWithoutBody(request.status) ? null : body;
7357
7220
  return new Response(responseBodyOrNull, {
7358
7221
  status: request.status,
7359
7222
  statusText: request.statusText,
@@ -7433,7 +7296,7 @@ If this message still persists after updating, please report an issue: https://g
7433
7296
  case "send": {
7434
7297
  const [body] = args;
7435
7298
  if (body != null) {
7436
- this.requestBody = typeof body === "string" ? encodeBuffer2(body) : body;
7299
+ this.requestBody = typeof body === "string" ? encodeBuffer(body) : body;
7437
7300
  }
7438
7301
  this.request.addEventListener("load", () => {
7439
7302
  if (typeof this.onResponse !== "undefined") {
@@ -7602,7 +7465,7 @@ If this message still persists after updating, please report an issue: https://g
7602
7465
  }
7603
7466
  }
7604
7467
  responseBufferToText() {
7605
- return decodeBuffer2(this.responseBuffer);
7468
+ return decodeBuffer(this.responseBuffer);
7606
7469
  }
7607
7470
  get response() {
7608
7471
  this.logger.info(
@@ -7883,7 +7746,7 @@ If this message still persists after updating, please report an issue: https://g
7883
7746
  });
7884
7747
  return XMLHttpRequestProxy;
7885
7748
  }
7886
- var _XMLHttpRequestInterceptor = class extends Interceptor2 {
7749
+ var _XMLHttpRequestInterceptor = class extends Interceptor {
7887
7750
  constructor() {
7888
7751
  super(_XMLHttpRequestInterceptor.interceptorSymbol);
7889
7752
  }
@@ -7895,7 +7758,7 @@ If this message still persists after updating, please report an issue: https://g
7895
7758
  logger.info('patching "XMLHttpRequest" module...');
7896
7759
  const PureXMLHttpRequest = globalThis.XMLHttpRequest;
7897
7760
  invariant(
7898
- !PureXMLHttpRequest[IS_PATCHED_MODULE2],
7761
+ !PureXMLHttpRequest[IS_PATCHED_MODULE],
7899
7762
  'Failed to patch the "XMLHttpRequest" module: already patched.'
7900
7763
  );
7901
7764
  globalThis.XMLHttpRequest = createXMLHttpRequestProxy({
@@ -7906,13 +7769,13 @@ If this message still persists after updating, please report an issue: https://g
7906
7769
  'native "XMLHttpRequest" module patched!',
7907
7770
  globalThis.XMLHttpRequest.name
7908
7771
  );
7909
- Object.defineProperty(globalThis.XMLHttpRequest, IS_PATCHED_MODULE2, {
7772
+ Object.defineProperty(globalThis.XMLHttpRequest, IS_PATCHED_MODULE, {
7910
7773
  enumerable: true,
7911
7774
  configurable: true,
7912
7775
  value: true
7913
7776
  });
7914
7777
  this.subscriptions.push(() => {
7915
- Object.defineProperty(globalThis.XMLHttpRequest, IS_PATCHED_MODULE2, {
7778
+ Object.defineProperty(globalThis.XMLHttpRequest, IS_PATCHED_MODULE, {
7916
7779
  value: void 0
7917
7780
  });
7918
7781
  globalThis.XMLHttpRequest = PureXMLHttpRequest;
@@ -2,13 +2,13 @@
2
2
  /* tslint:disable */
3
3
 
4
4
  /**
5
- * Mock Service Worker (2.0.8).
5
+ * Mock Service Worker (2.0.10).
6
6
  * @see https://github.com/mswjs/msw
7
7
  * - Please do NOT modify this file.
8
8
  * - Please do NOT serve this file on production.
9
9
  */
10
10
 
11
- const INTEGRITY_CHECKSUM = '0877fcdc026242810f5bfde0d7178db4'
11
+ const INTEGRITY_CHECKSUM = 'c5f7f8e188b673ea4e677df7ea3c5a39'
12
12
  const IS_MOCKED_RESPONSE = Symbol('isMockedResponse')
13
13
  const activeClientIds = new Set()
14
14
 
@@ -121,11 +121,6 @@ async function handleRequest(event, requestId) {
121
121
  if (client && activeClientIds.has(client.id)) {
122
122
  ;(async function () {
123
123
  const responseClone = response.clone()
124
- // When performing original requests, response body will
125
- // always be a ReadableStream, even for 204 responses.
126
- // But when creating a new Response instance on the client,
127
- // the body for a 204 response must be null.
128
- const responseBody = response.status === 204 ? null : responseClone.body
129
124
 
130
125
  sendToClient(
131
126
  client,
@@ -137,11 +132,11 @@ async function handleRequest(event, requestId) {
137
132
  type: responseClone.type,
138
133
  status: responseClone.status,
139
134
  statusText: responseClone.statusText,
140
- body: responseBody,
135
+ body: responseClone.body,
141
136
  headers: Object.fromEntries(responseClone.headers.entries()),
142
137
  },
143
138
  },
144
- [responseBody],
139
+ [responseClone.body],
145
140
  )
146
141
  })()
147
142
  }
@@ -51,29 +51,18 @@ interface SetupServer {
51
51
  }
52
52
 
53
53
  declare class SetupServerApi extends SetupApi<LifeCycleEventsMap> implements SetupServer {
54
- private context;
55
54
  protected readonly interceptor: BatchInterceptor<Array<Interceptor<HttpRequestEventMap>>, HttpRequestEventMap>;
56
55
  private resolvedOptions;
57
56
  constructor(interceptors: Array<{
58
57
  new (): Interceptor<HttpRequestEventMap>;
59
58
  }>, ...handlers: Array<RequestHandler>);
60
- private createContext;
61
59
  /**
62
60
  * Subscribe to all requests that are using the interceptor object
63
61
  */
64
62
  private init;
65
63
  listen(options?: Partial<SharedOptions>): void;
66
64
  close(): void;
67
- /**
68
- * Bump the maximum number of event listeners on the
69
- * request's "AbortSignal". This prepares the request
70
- * for each request handler cloning it at least once.
71
- * Note that cloning a request automatically appends a
72
- * new "abort" event listener to the parent request's
73
- * "AbortController" so if the parent aborts, all the
74
- * clones are automatically aborted.
75
- */
76
- private setRequestAbortSignalMaxListeners;
65
+ protected onRequest(request: Request): void;
77
66
  }
78
67
 
79
68
  /**