msw 2.0.9 → 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.
@@ -320,9 +320,9 @@ function requestIntegrityCheck(context, serviceWorker) {
320
320
  const { payload: actualChecksum } = yield context.events.once(
321
321
  "INTEGRITY_CHECK_RESPONSE"
322
322
  );
323
- if (actualChecksum !== "0877fcdc026242810f5bfde0d7178db4") {
323
+ if (actualChecksum !== "c5f7f8e188b673ea4e677df7ea3c5a39") {
324
324
  throw new Error(
325
- `Currently active Service Worker (${actualChecksum}) is behind the latest published one (${"0877fcdc026242810f5bfde0d7178db4"}).`
325
+ `Currently active Service Worker (${actualChecksum}) is behind the latest published one (${"c5f7f8e188b673ea4e677df7ea3c5a39"}).`
326
326
  );
327
327
  }
328
328
  return serviceWorker;
@@ -348,6 +348,7 @@ function deferNetworkRequestsUntil(predicatePromise) {
348
348
  }
349
349
 
350
350
  // src/browser/setupWorker/start/createResponseListener.ts
351
+ var import_interceptors = require("@mswjs/interceptors");
351
352
  function createResponseListener(context) {
352
353
  return (_, message) => {
353
354
  var _a;
@@ -355,7 +356,16 @@ function createResponseListener(context) {
355
356
  if ((_a = responseJson.type) == null ? void 0 : _a.includes("opaque")) {
356
357
  return;
357
358
  }
358
- const response = responseJson.status === 0 ? Response.error() : new Response(responseJson.body, responseJson);
359
+ const response = responseJson.status === 0 ? Response.error() : new Response(
360
+ /**
361
+ * Responses may be streams here, but when we create a response object
362
+ * with null-body status codes, like 204, 205, 304 Response will
363
+ * throw when passed a non-null body, so ensure it's null here
364
+ * for those codes
365
+ */
366
+ (0, import_interceptors.isResponseWithoutBody)(responseJson.status) ? null : responseJson.body,
367
+ responseJson
368
+ );
359
369
  context.emitter.emit(
360
370
  responseJson.isMockedResponse ? "response:mocked" : "response:bypass",
361
371
  {
@@ -520,12 +530,12 @@ var DEFAULT_START_OPTIONS = {
520
530
  };
521
531
 
522
532
  // src/browser/setupWorker/start/createFallbackRequestListener.ts
523
- var import_interceptors = require("@mswjs/interceptors");
533
+ var import_interceptors2 = require("@mswjs/interceptors");
524
534
  var import_fetch = require("@mswjs/interceptors/fetch");
525
535
  var import_XMLHttpRequest = require("@mswjs/interceptors/XMLHttpRequest");
526
536
  var import_handleRequest2 = require("../core/utils/handleRequest.js");
527
537
  function createFallbackRequestListener(context, options) {
528
- const interceptor = new import_interceptors.BatchInterceptor({
538
+ const interceptor = new import_interceptors2.BatchInterceptor({
529
539
  name: "fallback",
530
540
  interceptors: [new import_fetch.FetchInterceptor(), new import_XMLHttpRequest.XMLHttpRequestInterceptor()]
531
541
  });
@@ -296,9 +296,9 @@ function requestIntegrityCheck(context, serviceWorker) {
296
296
  const { payload: actualChecksum } = yield context.events.once(
297
297
  "INTEGRITY_CHECK_RESPONSE"
298
298
  );
299
- if (actualChecksum !== "0877fcdc026242810f5bfde0d7178db4") {
299
+ if (actualChecksum !== "c5f7f8e188b673ea4e677df7ea3c5a39") {
300
300
  throw new Error(
301
- `Currently active Service Worker (${actualChecksum}) is behind the latest published one (${"0877fcdc026242810f5bfde0d7178db4"}).`
301
+ `Currently active Service Worker (${actualChecksum}) is behind the latest published one (${"c5f7f8e188b673ea4e677df7ea3c5a39"}).`
302
302
  );
303
303
  }
304
304
  return serviceWorker;
@@ -324,6 +324,7 @@ function deferNetworkRequestsUntil(predicatePromise) {
324
324
  }
325
325
 
326
326
  // src/browser/setupWorker/start/createResponseListener.ts
327
+ import { isResponseWithoutBody } from "@mswjs/interceptors";
327
328
  function createResponseListener(context) {
328
329
  return (_, message) => {
329
330
  var _a;
@@ -331,7 +332,16 @@ function createResponseListener(context) {
331
332
  if ((_a = responseJson.type) == null ? void 0 : _a.includes("opaque")) {
332
333
  return;
333
334
  }
334
- const response = responseJson.status === 0 ? Response.error() : new Response(responseJson.body, responseJson);
335
+ const response = responseJson.status === 0 ? Response.error() : new Response(
336
+ /**
337
+ * Responses may be streams here, but when we create a response object
338
+ * with null-body status codes, like 204, 205, 304 Response will
339
+ * throw when passed a non-null body, so ensure it's null here
340
+ * for those codes
341
+ */
342
+ isResponseWithoutBody(responseJson.status) ? null : responseJson.body,
343
+ responseJson
344
+ );
335
345
  context.emitter.emit(
336
346
  responseJson.isMockedResponse ? "response:mocked" : "response:bypass",
337
347
  {
@@ -1,5 +1,5 @@
1
1
  import { OperationTypeNode, DocumentNode, GraphQLError } from 'graphql';
2
- import { g as RequestHandlerDefaultInfo, D as DefaultBodyType, R as RequestHandler, a as ResponseResolver, c as RequestHandlerOptions } from './RequestHandler-bb5cbb8f.js';
2
+ import { g as RequestHandlerDefaultInfo, D as DefaultBodyType, R as RequestHandler, a as ResponseResolver, c as RequestHandlerOptions } from './RequestHandler-50ddea0c.js';
3
3
  import { Match, Path } from './utils/matching/matchRequestUrl.js';
4
4
 
5
5
  interface ParsedGraphQLQuery {
@@ -1,2 +1,2 @@
1
- export { f as HttpResponse, H as HttpResponseInit, S as StrictRequest, e as StrictResponse } from './RequestHandler-bb5cbb8f.js';
1
+ export { f as HttpResponse, H as HttpResponseInit, S as StrictRequest, e as StrictResponse } from './RequestHandler-50ddea0c.js';
2
2
  import './typeUtils.js';
@@ -149,6 +149,10 @@ declare abstract class RequestHandler<HandlerInfo extends RequestHandlerDefaultI
149
149
  }): Promise<ParsedResult>;
150
150
  /**
151
151
  * Test if this handler matches the given request.
152
+ *
153
+ * This method is not used internally but is exposed
154
+ * as a convenience method for consumers writing custom
155
+ * handlers.
152
156
  */
153
157
  test(args: {
154
158
  request: Request;
@@ -1,5 +1,5 @@
1
1
  import { EventMap, Emitter } from 'strict-event-emitter';
2
- import { R as RequestHandler, g as RequestHandlerDefaultInfo } from './RequestHandler-bb5cbb8f.js';
2
+ import { R as RequestHandler, g as RequestHandlerDefaultInfo } from './RequestHandler-50ddea0c.js';
3
3
  import { LifeCycleEventEmitter } from './sharedOptions.js';
4
4
  import { Disposable } from './utils/internal/Disposable.js';
5
5
  import './typeUtils.js';
@@ -1,6 +1,6 @@
1
1
  import { DocumentNode } from 'graphql';
2
- import { a as ResponseResolver, c as RequestHandlerOptions } from './RequestHandler-bb5cbb8f.js';
3
- import { a as GraphQLVariables, d as GraphQLHandlerNameSelector, e as GraphQLResolverExtras, f as GraphQLResponseBody, G as GraphQLHandler } from './GraphQLHandler-efb5b362.js';
2
+ import { a as ResponseResolver, c as RequestHandlerOptions } from './RequestHandler-50ddea0c.js';
3
+ import { a as GraphQLVariables, d as GraphQLHandlerNameSelector, e as GraphQLResolverExtras, f as GraphQLResponseBody, G as GraphQLHandler } from './GraphQLHandler-907fc607.js';
4
4
  import { Path } from './utils/matching/matchRequestUrl.js';
5
5
  import './typeUtils.js';
6
6
 
@@ -1,5 +1,5 @@
1
1
  import 'graphql';
2
- import '../RequestHandler-bb5cbb8f.js';
2
+ import '../RequestHandler-50ddea0c.js';
3
3
  import '../utils/matching/matchRequestUrl.js';
4
- export { E as ExpectedOperationTypeNode, G as GraphQLHandler, k as GraphQLHandlerInfo, d as GraphQLHandlerNameSelector, c as GraphQLJsonRequestBody, b as GraphQLRequestBody, l as GraphQLRequestParsedResult, e as GraphQLResolverExtras, f as GraphQLResponseBody, a as GraphQLVariables, m as isDocumentNode } from '../GraphQLHandler-efb5b362.js';
4
+ export { E as ExpectedOperationTypeNode, G as GraphQLHandler, k as GraphQLHandlerInfo, d as GraphQLHandlerNameSelector, c as GraphQLJsonRequestBody, b as GraphQLRequestBody, l as GraphQLRequestParsedResult, e as GraphQLResolverExtras, f as GraphQLResponseBody, a as GraphQLVariables, m as isDocumentNode } from '../GraphQLHandler-907fc607.js';
5
5
  import '../typeUtils.js';
@@ -1,4 +1,4 @@
1
- import { g as RequestHandlerDefaultInfo, R as RequestHandler, a as ResponseResolver, c as RequestHandlerOptions, i as ResponseResolutionContext } from '../RequestHandler-bb5cbb8f.js';
1
+ import { g as RequestHandlerDefaultInfo, R as RequestHandler, a as ResponseResolver, c as RequestHandlerOptions, i as ResponseResolutionContext } from '../RequestHandler-50ddea0c.js';
2
2
  import { Path, Match, PathParams } from '../utils/matching/matchRequestUrl.js';
3
3
  import '../typeUtils.js';
4
4
 
@@ -1,2 +1,2 @@
1
- export { A as AsyncResponseResolverReturnType, D as DefaultBodyType, d as DefaultRequestMultipartBody, J as JsonBodyType, M as MaybeAsyncResponseResolverReturnType, R as RequestHandler, m as RequestHandlerArgs, g as RequestHandlerDefaultInfo, n as RequestHandlerExecutionResult, k as RequestHandlerInternalInfo, c as RequestHandlerOptions, a as ResponseResolver, l as ResponseResolverInfo, b as ResponseResolverReturnType } from '../RequestHandler-bb5cbb8f.js';
1
+ export { A as AsyncResponseResolverReturnType, D as DefaultBodyType, d as DefaultRequestMultipartBody, J as JsonBodyType, M as MaybeAsyncResponseResolverReturnType, R as RequestHandler, m as RequestHandlerArgs, g as RequestHandlerDefaultInfo, n as RequestHandlerExecutionResult, k as RequestHandlerInternalInfo, c as RequestHandlerOptions, a as ResponseResolver, l as ResponseResolverInfo, b as ResponseResolverReturnType } from '../RequestHandler-50ddea0c.js';
2
2
  import '../typeUtils.js';
@@ -82,6 +82,10 @@ class RequestHandler {
82
82
  }
83
83
  /**
84
84
  * Test if this handler matches the given request.
85
+ *
86
+ * This method is not used internally but is exposed
87
+ * as a convenience method for consumers writing custom
88
+ * handlers.
85
89
  */
86
90
  test(args) {
87
91
  return __async(this, null, function* () {
@@ -61,6 +61,10 @@ class RequestHandler {
61
61
  }
62
62
  /**
63
63
  * Test if this handler matches the given request.
64
+ *
65
+ * This method is not used internally but is exposed
66
+ * as a convenience method for consumers writing custom
67
+ * handlers.
64
68
  */
65
69
  test(args) {
66
70
  return __async(this, null, function* () {
@@ -1,4 +1,4 @@
1
- import { D as DefaultBodyType, a as ResponseResolver, c as RequestHandlerOptions } from './RequestHandler-bb5cbb8f.js';
1
+ import { D as DefaultBodyType, a as ResponseResolver, c as RequestHandlerOptions } from './RequestHandler-50ddea0c.js';
2
2
  import { HttpRequestResolverExtras, HttpHandler } from './handlers/HttpHandler.js';
3
3
  import { PathParams, Path } from './utils/matching/matchRequestUrl.js';
4
4
  import './typeUtils.js';
@@ -1,9 +1,9 @@
1
1
  export { SetupApi } from './SetupApi.js';
2
- export { A as AsyncResponseResolverReturnType, D as DefaultBodyType, d as DefaultRequestMultipartBody, f as HttpResponse, H as HttpResponseInit, J as JsonBodyType, R as RequestHandler, c as RequestHandlerOptions, a as ResponseResolver, b as ResponseResolverReturnType, S as StrictRequest, e as StrictResponse } from './RequestHandler-bb5cbb8f.js';
2
+ export { A as AsyncResponseResolverReturnType, D as DefaultBodyType, d as DefaultRequestMultipartBody, f as HttpResponse, H as HttpResponseInit, J as JsonBodyType, R as RequestHandler, c as RequestHandlerOptions, a as ResponseResolver, b as ResponseResolverReturnType, S as StrictRequest, e as StrictResponse } from './RequestHandler-50ddea0c.js';
3
3
  export { http } from './http.js';
4
4
  export { HttpHandler, HttpMethods, HttpRequestParsedResult, RequestQuery } from './handlers/HttpHandler.js';
5
5
  export { graphql } from './graphql.js';
6
- export { G as GraphQLHandler, c as GraphQLJsonRequestBody, b as GraphQLRequestBody, a as GraphQLVariables, P as ParsedGraphQLRequest } from './GraphQLHandler-efb5b362.js';
6
+ export { G as GraphQLHandler, c as GraphQLJsonRequestBody, b as GraphQLRequestBody, a as GraphQLVariables, P as ParsedGraphQLRequest } from './GraphQLHandler-907fc607.js';
7
7
  export { Match, Path, PathParams, matchRequestUrl } from './utils/matching/matchRequestUrl.js';
8
8
  export { HandleRequestOptions, handleRequest } from './utils/handleRequest.js';
9
9
  export { cleanUrl } from './utils/url/cleanUrl.js';
@@ -1,6 +1,6 @@
1
1
  import { Emitter } from 'strict-event-emitter';
2
2
  import { UnhandledRequestStrategy } from './utils/request/onUnhandledRequest.js';
3
- import './RequestHandler-bb5cbb8f.js';
3
+ import './RequestHandler-50ddea0c.js';
4
4
  import './typeUtils.js';
5
5
 
6
6
  interface SharedOptions {
@@ -1,4 +1,4 @@
1
- import { H as HttpResponseInit } from '../../RequestHandler-bb5cbb8f.js';
1
+ import { H as HttpResponseInit } from '../../RequestHandler-50ddea0c.js';
2
2
  import '../../typeUtils.js';
3
3
 
4
4
  interface HttpResponseDecoratedInit extends HttpResponseInit {
@@ -1,2 +1,2 @@
1
- export { h as ResponseLookupResult, i as ResponseResolutionContext, j as getResponse } from '../RequestHandler-bb5cbb8f.js';
1
+ export { h as ResponseLookupResult, i as ResponseResolutionContext, j as getResponse } from '../RequestHandler-50ddea0c.js';
2
2
  import '../typeUtils.js';
@@ -1,14 +1,21 @@
1
1
  import { Emitter } from 'strict-event-emitter';
2
- import { h as ResponseLookupResult, R as RequestHandler } from '../RequestHandler-bb5cbb8f.js';
2
+ import { h as ResponseLookupResult, R as RequestHandler } from '../RequestHandler-50ddea0c.js';
3
3
  import { SharedOptions, LifeCycleEventsMap } from '../sharedOptions.js';
4
4
  import { RequiredDeep } from '../typeUtils.js';
5
5
  import './request/onUnhandledRequest.js';
6
6
 
7
7
  interface HandleRequestOptions {
8
8
  /**
9
- * Options for the response resolution process.
9
+ * `resolutionContext` is not part of the general public api
10
+ * but is exposed to aid in creating extensions like
11
+ * `@mswjs/http-middleware`.
10
12
  */
11
13
  resolutionContext?: {
14
+ /**
15
+ * A base url to use when resolving relative urls.
16
+ * @note This is primarily used by the `@mswjs/http-middleware`
17
+ * to resolve relative urls in the context of the running server
18
+ */
12
19
  baseUrl?: string;
13
20
  };
14
21
  /**
@@ -1,5 +1,5 @@
1
1
  import 'graphql';
2
- export { i as GraphQLMultipartRequestBody, h as GraphQLParsedOperationsMap, g as ParsedGraphQLQuery, P as ParsedGraphQLRequest, p as parseDocumentNode, j as parseGraphQLRequest } from '../../GraphQLHandler-efb5b362.js';
3
- import '../../RequestHandler-bb5cbb8f.js';
2
+ export { i as GraphQLMultipartRequestBody, h as GraphQLParsedOperationsMap, g as ParsedGraphQLQuery, P as ParsedGraphQLRequest, p as parseDocumentNode, j as parseGraphQLRequest } from '../../GraphQLHandler-907fc607.js';
3
+ import '../../RequestHandler-50ddea0c.js';
4
4
  import '../../typeUtils.js';
5
5
  import '../matching/matchRequestUrl.js';
@@ -1,4 +1,4 @@
1
- import { d as DefaultRequestMultipartBody } from '../../RequestHandler-bb5cbb8f.js';
1
+ import { d as DefaultRequestMultipartBody } from '../../RequestHandler-50ddea0c.js';
2
2
  import '../../typeUtils.js';
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { R as RequestHandler, g as RequestHandlerDefaultInfo, c as RequestHandlerOptions } from '../../RequestHandler-bb5cbb8f.js';
1
+ import { R as RequestHandler, g as RequestHandlerDefaultInfo, c as RequestHandlerOptions } from '../../RequestHandler-50ddea0c.js';
2
2
  import '../../typeUtils.js';
3
3
 
4
4
  declare function use(currentHandlers: Array<RequestHandler>, ...handlers: Array<RequestHandler>): void;
@@ -1,4 +1,4 @@
1
- import { R as RequestHandler } from '../../RequestHandler-bb5cbb8f.js';
1
+ import { R as RequestHandler } from '../../RequestHandler-50ddea0c.js';
2
2
  import '../../typeUtils.js';
3
3
 
4
4
  interface UnhandledRequestPrint {
package/lib/iife/index.js CHANGED
@@ -528,6 +528,10 @@ var MockServiceWorker = (() => {
528
528
  }
529
529
  /**
530
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.
531
535
  */
532
536
  test(args) {
533
537
  return __async(this, null, function* () {
@@ -1147,6 +1151,32 @@ var MockServiceWorker = (() => {
1147
1151
  return stringToRegexp(path, keys, options);
1148
1152
  }
1149
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
+
1150
1180
  // node_modules/.pnpm/is-node-process@1.2.0/node_modules/is-node-process/lib/index.mjs
1151
1181
  function isNodeProcess() {
1152
1182
  if (typeof navigator !== "undefined" && navigator.product === "ReactNative") {
@@ -1600,7 +1630,8 @@ var MockServiceWorker = (() => {
1600
1630
  var Emitter2 = _Emitter2;
1601
1631
  Emitter2.defaultMaxListeners = 10;
1602
1632
 
1603
- // 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");
1604
1635
  function getGlobalSymbol(symbol) {
1605
1636
  return (
1606
1637
  // @ts-ignore https://github.com/Microsoft/TypeScript/issues/24587
@@ -1744,7 +1775,7 @@ var MockServiceWorker = (() => {
1744
1775
  }
1745
1776
  };
1746
1777
 
1747
- // 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
1748
1779
  var BatchInterceptor = class extends Interceptor {
1749
1780
  constructor(options) {
1750
1781
  BatchInterceptor.symbol = Symbol(options.name);
@@ -1786,14 +1817,6 @@ var MockServiceWorker = (() => {
1786
1817
  return this;
1787
1818
  }
1788
1819
  };
1789
-
1790
- // node_modules/.pnpm/@mswjs+interceptors@0.25.11/node_modules/@mswjs/interceptors/lib/node/chunk-7II4SWKS.mjs
1791
- var encoder = new TextEncoder();
1792
-
1793
- // node_modules/.pnpm/@mswjs+interceptors@0.25.11/node_modules/@mswjs/interceptors/lib/node/chunk-GFH37L5D.mjs
1794
- var IS_PATCHED_MODULE = Symbol("isPatchedModule");
1795
-
1796
- // node_modules/.pnpm/@mswjs+interceptors@0.25.11/node_modules/@mswjs/interceptors/lib/node/index.mjs
1797
1820
  function getCleanUrl(url, isAbsolute = true) {
1798
1821
  return [isAbsolute && url.origin, url.pathname].filter(Boolean).join("");
1799
1822
  }
@@ -6556,9 +6579,9 @@ This exception has been gracefully handled as a 500 response, however, it's stro
6556
6579
  const { payload: actualChecksum } = yield context.events.once(
6557
6580
  "INTEGRITY_CHECK_RESPONSE"
6558
6581
  );
6559
- if (actualChecksum !== "0877fcdc026242810f5bfde0d7178db4") {
6582
+ if (actualChecksum !== "c5f7f8e188b673ea4e677df7ea3c5a39") {
6560
6583
  throw new Error(
6561
- `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"}).`
6562
6585
  );
6563
6586
  }
6564
6587
  return serviceWorker;
@@ -6590,7 +6613,16 @@ This exception has been gracefully handled as a 500 response, however, it's stro
6590
6613
  if ((_a3 = responseJson.type) == null ? void 0 : _a3.includes("opaque")) {
6591
6614
  return;
6592
6615
  }
6593
- 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
+ );
6594
6626
  context.emitter.emit(
6595
6627
  responseJson.isMockedResponse ? "response:mocked" : "response:bypass",
6596
6628
  {
@@ -6837,7 +6869,7 @@ If this message still persists after updating, please report an issue: https://g
6837
6869
  });
6838
6870
  }, _a2);
6839
6871
 
6840
- // 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
6841
6873
  function uuidv4() {
6842
6874
  return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
6843
6875
  const r = Math.random() * 16 | 0;
@@ -6884,152 +6916,7 @@ If this message still persists after updating, please report an issue: https://g
6884
6916
  });
6885
6917
  }
6886
6918
 
6887
- // node_modules/.pnpm/@mswjs+interceptors@0.25.11/node_modules/@mswjs/interceptors/lib/browser/chunk-S72SKXXQ.mjs
6888
- var IS_PATCHED_MODULE2 = Symbol("isPatchedModule");
6889
- function getGlobalSymbol2(symbol) {
6890
- return (
6891
- // @ts-ignore https://github.com/Microsoft/TypeScript/issues/24587
6892
- globalThis[symbol] || void 0
6893
- );
6894
- }
6895
- function setGlobalSymbol2(symbol, value) {
6896
- globalThis[symbol] = value;
6897
- }
6898
- function deleteGlobalSymbol2(symbol) {
6899
- delete globalThis[symbol];
6900
- }
6901
- var Interceptor2 = class {
6902
- constructor(symbol) {
6903
- this.symbol = symbol;
6904
- this.readyState = "INACTIVE";
6905
- this.emitter = new Emitter2();
6906
- this.subscriptions = [];
6907
- this.logger = new Logger(symbol.description);
6908
- this.emitter.setMaxListeners(0);
6909
- this.logger.info("constructing the interceptor...");
6910
- }
6911
- /**
6912
- * Determine if this interceptor can be applied
6913
- * in the current environment.
6914
- */
6915
- checkEnvironment() {
6916
- return true;
6917
- }
6918
- /**
6919
- * Apply this interceptor to the current process.
6920
- * Returns an already running interceptor instance if it's present.
6921
- */
6922
- apply() {
6923
- const logger = this.logger.extend("apply");
6924
- logger.info("applying the interceptor...");
6925
- if (this.readyState === "APPLIED") {
6926
- logger.info("intercepted already applied!");
6927
- return;
6928
- }
6929
- const shouldApply = this.checkEnvironment();
6930
- if (!shouldApply) {
6931
- logger.info("the interceptor cannot be applied in this environment!");
6932
- return;
6933
- }
6934
- this.readyState = "APPLYING";
6935
- const runningInstance = this.getInstance();
6936
- if (runningInstance) {
6937
- logger.info("found a running instance, reusing...");
6938
- this.on = (event, listener) => {
6939
- logger.info('proxying the "%s" listener', event);
6940
- runningInstance.emitter.addListener(event, listener);
6941
- this.subscriptions.push(() => {
6942
- runningInstance.emitter.removeListener(event, listener);
6943
- logger.info('removed proxied "%s" listener!', event);
6944
- });
6945
- return this;
6946
- };
6947
- this.readyState = "APPLIED";
6948
- return;
6949
- }
6950
- logger.info("no running instance found, setting up a new instance...");
6951
- this.setup();
6952
- this.setInstance();
6953
- this.readyState = "APPLIED";
6954
- }
6955
- /**
6956
- * Setup the module augments and stubs necessary for this interceptor.
6957
- * This method is not run if there's a running interceptor instance
6958
- * to prevent instantiating an interceptor multiple times.
6959
- */
6960
- setup() {
6961
- }
6962
- /**
6963
- * Listen to the interceptor's public events.
6964
- */
6965
- on(event, listener) {
6966
- const logger = this.logger.extend("on");
6967
- if (this.readyState === "DISPOSING" || this.readyState === "DISPOSED") {
6968
- logger.info("cannot listen to events, already disposed!");
6969
- return this;
6970
- }
6971
- logger.info('adding "%s" event listener:', event, listener);
6972
- this.emitter.on(event, listener);
6973
- return this;
6974
- }
6975
- once(event, listener) {
6976
- this.emitter.once(event, listener);
6977
- return this;
6978
- }
6979
- off(event, listener) {
6980
- this.emitter.off(event, listener);
6981
- return this;
6982
- }
6983
- removeAllListeners(event) {
6984
- this.emitter.removeAllListeners(event);
6985
- return this;
6986
- }
6987
- /**
6988
- * Disposes of any side-effects this interceptor has introduced.
6989
- */
6990
- dispose() {
6991
- const logger = this.logger.extend("dispose");
6992
- if (this.readyState === "DISPOSED") {
6993
- logger.info("cannot dispose, already disposed!");
6994
- return;
6995
- }
6996
- logger.info("disposing the interceptor...");
6997
- this.readyState = "DISPOSING";
6998
- if (!this.getInstance()) {
6999
- logger.info("no interceptors running, skipping dispose...");
7000
- return;
7001
- }
7002
- this.clearInstance();
7003
- logger.info("global symbol deleted:", getGlobalSymbol2(this.symbol));
7004
- if (this.subscriptions.length > 0) {
7005
- logger.info("disposing of %d subscriptions...", this.subscriptions.length);
7006
- for (const dispose of this.subscriptions) {
7007
- dispose();
7008
- }
7009
- this.subscriptions = [];
7010
- logger.info("disposed of all subscriptions!", this.subscriptions.length);
7011
- }
7012
- this.emitter.removeAllListeners();
7013
- logger.info("destroyed the listener!");
7014
- this.readyState = "DISPOSED";
7015
- }
7016
- getInstance() {
7017
- var _a3;
7018
- const instance = getGlobalSymbol2(this.symbol);
7019
- this.logger.info("retrieved global instance:", (_a3 = instance == null ? void 0 : instance.constructor) == null ? void 0 : _a3.name);
7020
- return instance;
7021
- }
7022
- setInstance() {
7023
- setGlobalSymbol2(this.symbol, this);
7024
- this.logger.info("set global instance!", this.symbol.description);
7025
- }
7026
- clearInstance() {
7027
- deleteGlobalSymbol2(this.symbol);
7028
- this.logger.info("cleared global instance!", this.symbol.description);
7029
- }
7030
- };
7031
-
7032
- // 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
7033
6920
  function isPropertyAccessible2(obj, key) {
7034
6921
  try {
7035
6922
  obj[key];
@@ -7038,7 +6925,7 @@ If this message still persists after updating, please report an issue: https://g
7038
6925
  return false;
7039
6926
  }
7040
6927
  }
7041
- var _FetchInterceptor = class extends Interceptor2 {
6928
+ var _FetchInterceptor = class extends Interceptor {
7042
6929
  constructor() {
7043
6930
  super(_FetchInterceptor.symbol);
7044
6931
  }
@@ -7048,7 +6935,7 @@ If this message still persists after updating, please report an issue: https://g
7048
6935
  setup() {
7049
6936
  const pureFetch = globalThis.fetch;
7050
6937
  invariant(
7051
- !pureFetch[IS_PATCHED_MODULE2],
6938
+ !pureFetch[IS_PATCHED_MODULE],
7052
6939
  'Failed to patch the "fetch" module: already patched.'
7053
6940
  );
7054
6941
  globalThis.fetch = (input, init) => __async(this, null, function* () {
@@ -7141,13 +7028,13 @@ If this message still persists after updating, please report an issue: https://g
7141
7028
  return response;
7142
7029
  });
7143
7030
  });
7144
- Object.defineProperty(globalThis.fetch, IS_PATCHED_MODULE2, {
7031
+ Object.defineProperty(globalThis.fetch, IS_PATCHED_MODULE, {
7145
7032
  enumerable: true,
7146
7033
  configurable: true,
7147
7034
  value: true
7148
7035
  });
7149
7036
  this.subscriptions.push(() => {
7150
- Object.defineProperty(globalThis.fetch, IS_PATCHED_MODULE2, {
7037
+ Object.defineProperty(globalThis.fetch, IS_PATCHED_MODULE, {
7151
7038
  value: void 0
7152
7039
  });
7153
7040
  globalThis.fetch = pureFetch;
@@ -7166,23 +7053,7 @@ If this message still persists after updating, please report an issue: https://g
7166
7053
  });
7167
7054
  }
7168
7055
 
7169
- // node_modules/.pnpm/@mswjs+interceptors@0.25.11/node_modules/@mswjs/interceptors/lib/browser/chunk-7II4SWKS.mjs
7170
- var encoder2 = new TextEncoder();
7171
- function encodeBuffer2(text) {
7172
- return encoder2.encode(text);
7173
- }
7174
- function decodeBuffer2(buffer, encoding) {
7175
- const decoder = new TextDecoder(encoding);
7176
- return decoder.decode(buffer);
7177
- }
7178
- function toArrayBuffer(array) {
7179
- return array.buffer.slice(
7180
- array.byteOffset,
7181
- array.byteOffset + array.byteLength
7182
- );
7183
- }
7184
-
7185
- // 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
7186
7057
  function concatArrayBuffer(left, right) {
7187
7058
  const result = new Uint8Array(left.byteLength + right.byteLength);
7188
7059
  result.set(left, 0);
@@ -7344,11 +7215,8 @@ If this message still persists after updating, please report an issue: https://g
7344
7215
  return null;
7345
7216
  }
7346
7217
  }
7347
- var responseStatusCodesWithoutBody = [204, 205, 304];
7348
7218
  function createResponse(request, body) {
7349
- const responseBodyOrNull = responseStatusCodesWithoutBody.includes(
7350
- request.status
7351
- ) ? null : body;
7219
+ const responseBodyOrNull = isResponseWithoutBody(request.status) ? null : body;
7352
7220
  return new Response(responseBodyOrNull, {
7353
7221
  status: request.status,
7354
7222
  statusText: request.statusText,
@@ -7428,7 +7296,7 @@ If this message still persists after updating, please report an issue: https://g
7428
7296
  case "send": {
7429
7297
  const [body] = args;
7430
7298
  if (body != null) {
7431
- this.requestBody = typeof body === "string" ? encodeBuffer2(body) : body;
7299
+ this.requestBody = typeof body === "string" ? encodeBuffer(body) : body;
7432
7300
  }
7433
7301
  this.request.addEventListener("load", () => {
7434
7302
  if (typeof this.onResponse !== "undefined") {
@@ -7597,7 +7465,7 @@ If this message still persists after updating, please report an issue: https://g
7597
7465
  }
7598
7466
  }
7599
7467
  responseBufferToText() {
7600
- return decodeBuffer2(this.responseBuffer);
7468
+ return decodeBuffer(this.responseBuffer);
7601
7469
  }
7602
7470
  get response() {
7603
7471
  this.logger.info(
@@ -7878,7 +7746,7 @@ If this message still persists after updating, please report an issue: https://g
7878
7746
  });
7879
7747
  return XMLHttpRequestProxy;
7880
7748
  }
7881
- var _XMLHttpRequestInterceptor = class extends Interceptor2 {
7749
+ var _XMLHttpRequestInterceptor = class extends Interceptor {
7882
7750
  constructor() {
7883
7751
  super(_XMLHttpRequestInterceptor.interceptorSymbol);
7884
7752
  }
@@ -7890,7 +7758,7 @@ If this message still persists after updating, please report an issue: https://g
7890
7758
  logger.info('patching "XMLHttpRequest" module...');
7891
7759
  const PureXMLHttpRequest = globalThis.XMLHttpRequest;
7892
7760
  invariant(
7893
- !PureXMLHttpRequest[IS_PATCHED_MODULE2],
7761
+ !PureXMLHttpRequest[IS_PATCHED_MODULE],
7894
7762
  'Failed to patch the "XMLHttpRequest" module: already patched.'
7895
7763
  );
7896
7764
  globalThis.XMLHttpRequest = createXMLHttpRequestProxy({
@@ -7901,13 +7769,13 @@ If this message still persists after updating, please report an issue: https://g
7901
7769
  'native "XMLHttpRequest" module patched!',
7902
7770
  globalThis.XMLHttpRequest.name
7903
7771
  );
7904
- Object.defineProperty(globalThis.XMLHttpRequest, IS_PATCHED_MODULE2, {
7772
+ Object.defineProperty(globalThis.XMLHttpRequest, IS_PATCHED_MODULE, {
7905
7773
  enumerable: true,
7906
7774
  configurable: true,
7907
7775
  value: true
7908
7776
  });
7909
7777
  this.subscriptions.push(() => {
7910
- Object.defineProperty(globalThis.XMLHttpRequest, IS_PATCHED_MODULE2, {
7778
+ Object.defineProperty(globalThis.XMLHttpRequest, IS_PATCHED_MODULE, {
7911
7779
  value: void 0
7912
7780
  });
7913
7781
  globalThis.XMLHttpRequest = PureXMLHttpRequest;
@@ -2,13 +2,13 @@
2
2
  /* tslint:disable */
3
3
 
4
4
  /**
5
- * Mock Service Worker (2.0.9).
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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "msw",
3
- "version": "2.0.9",
3
+ "version": "2.0.10",
4
4
  "description": "Seamless REST/GraphQL API mocking library for browser and Node.js.",
5
5
  "main": "./lib/core/index.js",
6
6
  "module": "./lib/core/index.mjs",
@@ -94,7 +94,7 @@
94
94
  "@bundled-es-modules/js-levenshtein": "^2.0.1",
95
95
  "@bundled-es-modules/statuses": "^1.0.1",
96
96
  "@mswjs/cookies": "^1.1.0",
97
- "@mswjs/interceptors": "^0.25.11",
97
+ "@mswjs/interceptors": "^0.25.13",
98
98
  "@open-draft/until": "^2.1.0",
99
99
  "@types/cookie": "^0.4.1",
100
100
  "@types/js-levenshtein": "^1.1.1",