msw 2.6.4 → 2.6.6

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,6 +1,6 @@
1
1
  type Path = string | RegExp;
2
2
  type PathParams<KeyType extends keyof any = string> = {
3
- [ParamName in KeyType]: string | ReadonlyArray<string>;
3
+ [ParamName in KeyType]?: string | ReadonlyArray<string>;
4
4
  };
5
5
  interface Match {
6
6
  matches: boolean;
@@ -1,6 +1,6 @@
1
1
  type Path = string | RegExp;
2
2
  type PathParams<KeyType extends keyof any = string> = {
3
- [ParamName in KeyType]: string | ReadonlyArray<string>;
3
+ [ParamName in KeyType]?: string | ReadonlyArray<string>;
4
4
  };
5
5
  interface Match {
6
6
  matches: boolean;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/core/utils/matching/matchRequestUrl.ts"],"sourcesContent":["import { match } from 'path-to-regexp'\nimport { getCleanUrl } from '@mswjs/interceptors'\nimport { normalizePath } from './normalizePath'\n\nexport type Path = string | RegExp\nexport type PathParams<KeyType extends keyof any = string> = {\n [ParamName in KeyType]: string | ReadonlyArray<string>\n}\n\nexport interface Match {\n matches: boolean\n params?: PathParams\n}\n\n/**\n * Coerce a path supported by MSW into a path\n * supported by \"path-to-regexp\".\n */\nexport function coercePath(path: string): string {\n return (\n path\n /**\n * Replace wildcards (\"*\") with unnamed capturing groups\n * because \"path-to-regexp\" doesn't support wildcards.\n * Ignore path parameter' modifiers (i.e. \":name*\").\n */\n .replace(\n /([:a-zA-Z_-]*)(\\*{1,2})+/g,\n (_, parameterName: string | undefined, wildcard: string) => {\n const expression = '(.*)'\n\n if (!parameterName) {\n return expression\n }\n\n return parameterName.startsWith(':')\n ? `${parameterName}${wildcard}`\n : `${parameterName}${expression}`\n },\n )\n /**\n * Escape the port so that \"path-to-regexp\" can match\n * absolute URLs including port numbers.\n */\n .replace(/([^\\/])(:)(?=\\d+)/, '$1\\\\$2')\n /**\n * Escape the protocol so that \"path-to-regexp\" could match\n * absolute URL.\n * @see https://github.com/pillarjs/path-to-regexp/issues/259\n */\n .replace(/^([^\\/]+)(:)(?=\\/\\/)/, '$1\\\\$2')\n )\n}\n\n/**\n * Returns the result of matching given request URL against a mask.\n */\nexport function matchRequestUrl(url: URL, path: Path, baseUrl?: string): Match {\n const normalizedPath = normalizePath(path, baseUrl)\n const cleanPath =\n typeof normalizedPath === 'string'\n ? coercePath(normalizedPath)\n : normalizedPath\n\n const cleanUrl = getCleanUrl(url)\n const result = match(cleanPath, { decode: decodeURIComponent })(cleanUrl)\n const params = (result && (result.params as PathParams)) || {}\n\n return {\n matches: result !== false,\n params,\n }\n}\n\nexport function isPath(value: unknown): value is Path {\n return typeof value === 'string' || value instanceof RegExp\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4BAAsB;AACtB,0BAA4B;AAC5B,2BAA8B;AAgBvB,SAAS,WAAW,MAAsB;AAC/C,SACE,KAMG;AAAA,IACC;AAAA,IACA,CAAC,GAAG,eAAmC,aAAqB;AAC1D,YAAM,aAAa;AAEnB,UAAI,CAAC,eAAe;AAClB,eAAO;AAAA,MACT;AAEA,aAAO,cAAc,WAAW,GAAG,IAC/B,GAAG,aAAa,GAAG,QAAQ,KAC3B,GAAG,aAAa,GAAG,UAAU;AAAA,IACnC;AAAA,EACF,EAKC,QAAQ,qBAAqB,QAAQ,EAMrC,QAAQ,wBAAwB,QAAQ;AAE/C;AAKO,SAAS,gBAAgB,KAAU,MAAY,SAAyB;AAC7E,QAAM,qBAAiB,oCAAc,MAAM,OAAO;AAClD,QAAM,YACJ,OAAO,mBAAmB,WACtB,WAAW,cAAc,IACzB;AAEN,QAAM,eAAW,iCAAY,GAAG;AAChC,QAAM,aAAS,6BAAM,WAAW,EAAE,QAAQ,mBAAmB,CAAC,EAAE,QAAQ;AACxE,QAAM,SAAU,UAAW,OAAO,UAA0B,CAAC;AAE7D,SAAO;AAAA,IACL,SAAS,WAAW;AAAA,IACpB;AAAA,EACF;AACF;AAEO,SAAS,OAAO,OAA+B;AACpD,SAAO,OAAO,UAAU,YAAY,iBAAiB;AACvD;","names":[]}
1
+ {"version":3,"sources":["../../../../src/core/utils/matching/matchRequestUrl.ts"],"sourcesContent":["import { match } from 'path-to-regexp'\nimport { getCleanUrl } from '@mswjs/interceptors'\nimport { normalizePath } from './normalizePath'\n\nexport type Path = string | RegExp\nexport type PathParams<KeyType extends keyof any = string> = {\n [ParamName in KeyType]?: string | ReadonlyArray<string>\n}\n\nexport interface Match {\n matches: boolean\n params?: PathParams\n}\n\n/**\n * Coerce a path supported by MSW into a path\n * supported by \"path-to-regexp\".\n */\nexport function coercePath(path: string): string {\n return (\n path\n /**\n * Replace wildcards (\"*\") with unnamed capturing groups\n * because \"path-to-regexp\" doesn't support wildcards.\n * Ignore path parameter' modifiers (i.e. \":name*\").\n */\n .replace(\n /([:a-zA-Z_-]*)(\\*{1,2})+/g,\n (_, parameterName: string | undefined, wildcard: string) => {\n const expression = '(.*)'\n\n if (!parameterName) {\n return expression\n }\n\n return parameterName.startsWith(':')\n ? `${parameterName}${wildcard}`\n : `${parameterName}${expression}`\n },\n )\n /**\n * Escape the port so that \"path-to-regexp\" can match\n * absolute URLs including port numbers.\n */\n .replace(/([^\\/])(:)(?=\\d+)/, '$1\\\\$2')\n /**\n * Escape the protocol so that \"path-to-regexp\" could match\n * absolute URL.\n * @see https://github.com/pillarjs/path-to-regexp/issues/259\n */\n .replace(/^([^\\/]+)(:)(?=\\/\\/)/, '$1\\\\$2')\n )\n}\n\n/**\n * Returns the result of matching given request URL against a mask.\n */\nexport function matchRequestUrl(url: URL, path: Path, baseUrl?: string): Match {\n const normalizedPath = normalizePath(path, baseUrl)\n const cleanPath =\n typeof normalizedPath === 'string'\n ? coercePath(normalizedPath)\n : normalizedPath\n\n const cleanUrl = getCleanUrl(url)\n const result = match(cleanPath, { decode: decodeURIComponent })(cleanUrl)\n const params = (result && (result.params as PathParams)) || {}\n\n return {\n matches: result !== false,\n params,\n }\n}\n\nexport function isPath(value: unknown): value is Path {\n return typeof value === 'string' || value instanceof RegExp\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,4BAAsB;AACtB,0BAA4B;AAC5B,2BAA8B;AAgBvB,SAAS,WAAW,MAAsB;AAC/C,SACE,KAMG;AAAA,IACC;AAAA,IACA,CAAC,GAAG,eAAmC,aAAqB;AAC1D,YAAM,aAAa;AAEnB,UAAI,CAAC,eAAe;AAClB,eAAO;AAAA,MACT;AAEA,aAAO,cAAc,WAAW,GAAG,IAC/B,GAAG,aAAa,GAAG,QAAQ,KAC3B,GAAG,aAAa,GAAG,UAAU;AAAA,IACnC;AAAA,EACF,EAKC,QAAQ,qBAAqB,QAAQ,EAMrC,QAAQ,wBAAwB,QAAQ;AAE/C;AAKO,SAAS,gBAAgB,KAAU,MAAY,SAAyB;AAC7E,QAAM,qBAAiB,oCAAc,MAAM,OAAO;AAClD,QAAM,YACJ,OAAO,mBAAmB,WACtB,WAAW,cAAc,IACzB;AAEN,QAAM,eAAW,iCAAY,GAAG;AAChC,QAAM,aAAS,6BAAM,WAAW,EAAE,QAAQ,mBAAmB,CAAC,EAAE,QAAQ;AACxE,QAAM,SAAU,UAAW,OAAO,UAA0B,CAAC;AAE7D,SAAO;AAAA,IACL,SAAS,WAAW;AAAA,IACpB;AAAA,EACF;AACF;AAEO,SAAS,OAAO,OAA+B;AACpD,SAAO,OAAO,UAAU,YAAY,iBAAiB;AACvD;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/core/utils/matching/matchRequestUrl.ts"],"sourcesContent":["import { match } from 'path-to-regexp'\nimport { getCleanUrl } from '@mswjs/interceptors'\nimport { normalizePath } from './normalizePath'\n\nexport type Path = string | RegExp\nexport type PathParams<KeyType extends keyof any = string> = {\n [ParamName in KeyType]: string | ReadonlyArray<string>\n}\n\nexport interface Match {\n matches: boolean\n params?: PathParams\n}\n\n/**\n * Coerce a path supported by MSW into a path\n * supported by \"path-to-regexp\".\n */\nexport function coercePath(path: string): string {\n return (\n path\n /**\n * Replace wildcards (\"*\") with unnamed capturing groups\n * because \"path-to-regexp\" doesn't support wildcards.\n * Ignore path parameter' modifiers (i.e. \":name*\").\n */\n .replace(\n /([:a-zA-Z_-]*)(\\*{1,2})+/g,\n (_, parameterName: string | undefined, wildcard: string) => {\n const expression = '(.*)'\n\n if (!parameterName) {\n return expression\n }\n\n return parameterName.startsWith(':')\n ? `${parameterName}${wildcard}`\n : `${parameterName}${expression}`\n },\n )\n /**\n * Escape the port so that \"path-to-regexp\" can match\n * absolute URLs including port numbers.\n */\n .replace(/([^\\/])(:)(?=\\d+)/, '$1\\\\$2')\n /**\n * Escape the protocol so that \"path-to-regexp\" could match\n * absolute URL.\n * @see https://github.com/pillarjs/path-to-regexp/issues/259\n */\n .replace(/^([^\\/]+)(:)(?=\\/\\/)/, '$1\\\\$2')\n )\n}\n\n/**\n * Returns the result of matching given request URL against a mask.\n */\nexport function matchRequestUrl(url: URL, path: Path, baseUrl?: string): Match {\n const normalizedPath = normalizePath(path, baseUrl)\n const cleanPath =\n typeof normalizedPath === 'string'\n ? coercePath(normalizedPath)\n : normalizedPath\n\n const cleanUrl = getCleanUrl(url)\n const result = match(cleanPath, { decode: decodeURIComponent })(cleanUrl)\n const params = (result && (result.params as PathParams)) || {}\n\n return {\n matches: result !== false,\n params,\n }\n}\n\nexport function isPath(value: unknown): value is Path {\n return typeof value === 'string' || value instanceof RegExp\n}\n"],"mappings":"AAAA,SAAS,aAAa;AACtB,SAAS,mBAAmB;AAC5B,SAAS,qBAAqB;AAgBvB,SAAS,WAAW,MAAsB;AAC/C,SACE,KAMG;AAAA,IACC;AAAA,IACA,CAAC,GAAG,eAAmC,aAAqB;AAC1D,YAAM,aAAa;AAEnB,UAAI,CAAC,eAAe;AAClB,eAAO;AAAA,MACT;AAEA,aAAO,cAAc,WAAW,GAAG,IAC/B,GAAG,aAAa,GAAG,QAAQ,KAC3B,GAAG,aAAa,GAAG,UAAU;AAAA,IACnC;AAAA,EACF,EAKC,QAAQ,qBAAqB,QAAQ,EAMrC,QAAQ,wBAAwB,QAAQ;AAE/C;AAKO,SAAS,gBAAgB,KAAU,MAAY,SAAyB;AAC7E,QAAM,iBAAiB,cAAc,MAAM,OAAO;AAClD,QAAM,YACJ,OAAO,mBAAmB,WACtB,WAAW,cAAc,IACzB;AAEN,QAAM,WAAW,YAAY,GAAG;AAChC,QAAM,SAAS,MAAM,WAAW,EAAE,QAAQ,mBAAmB,CAAC,EAAE,QAAQ;AACxE,QAAM,SAAU,UAAW,OAAO,UAA0B,CAAC;AAE7D,SAAO;AAAA,IACL,SAAS,WAAW;AAAA,IACpB;AAAA,EACF;AACF;AAEO,SAAS,OAAO,OAA+B;AACpD,SAAO,OAAO,UAAU,YAAY,iBAAiB;AACvD;","names":[]}
1
+ {"version":3,"sources":["../../../../src/core/utils/matching/matchRequestUrl.ts"],"sourcesContent":["import { match } from 'path-to-regexp'\nimport { getCleanUrl } from '@mswjs/interceptors'\nimport { normalizePath } from './normalizePath'\n\nexport type Path = string | RegExp\nexport type PathParams<KeyType extends keyof any = string> = {\n [ParamName in KeyType]?: string | ReadonlyArray<string>\n}\n\nexport interface Match {\n matches: boolean\n params?: PathParams\n}\n\n/**\n * Coerce a path supported by MSW into a path\n * supported by \"path-to-regexp\".\n */\nexport function coercePath(path: string): string {\n return (\n path\n /**\n * Replace wildcards (\"*\") with unnamed capturing groups\n * because \"path-to-regexp\" doesn't support wildcards.\n * Ignore path parameter' modifiers (i.e. \":name*\").\n */\n .replace(\n /([:a-zA-Z_-]*)(\\*{1,2})+/g,\n (_, parameterName: string | undefined, wildcard: string) => {\n const expression = '(.*)'\n\n if (!parameterName) {\n return expression\n }\n\n return parameterName.startsWith(':')\n ? `${parameterName}${wildcard}`\n : `${parameterName}${expression}`\n },\n )\n /**\n * Escape the port so that \"path-to-regexp\" can match\n * absolute URLs including port numbers.\n */\n .replace(/([^\\/])(:)(?=\\d+)/, '$1\\\\$2')\n /**\n * Escape the protocol so that \"path-to-regexp\" could match\n * absolute URL.\n * @see https://github.com/pillarjs/path-to-regexp/issues/259\n */\n .replace(/^([^\\/]+)(:)(?=\\/\\/)/, '$1\\\\$2')\n )\n}\n\n/**\n * Returns the result of matching given request URL against a mask.\n */\nexport function matchRequestUrl(url: URL, path: Path, baseUrl?: string): Match {\n const normalizedPath = normalizePath(path, baseUrl)\n const cleanPath =\n typeof normalizedPath === 'string'\n ? coercePath(normalizedPath)\n : normalizedPath\n\n const cleanUrl = getCleanUrl(url)\n const result = match(cleanPath, { decode: decodeURIComponent })(cleanUrl)\n const params = (result && (result.params as PathParams)) || {}\n\n return {\n matches: result !== false,\n params,\n }\n}\n\nexport function isPath(value: unknown): value is Path {\n return typeof value === 'string' || value instanceof RegExp\n}\n"],"mappings":"AAAA,SAAS,aAAa;AACtB,SAAS,mBAAmB;AAC5B,SAAS,qBAAqB;AAgBvB,SAAS,WAAW,MAAsB;AAC/C,SACE,KAMG;AAAA,IACC;AAAA,IACA,CAAC,GAAG,eAAmC,aAAqB;AAC1D,YAAM,aAAa;AAEnB,UAAI,CAAC,eAAe;AAClB,eAAO;AAAA,MACT;AAEA,aAAO,cAAc,WAAW,GAAG,IAC/B,GAAG,aAAa,GAAG,QAAQ,KAC3B,GAAG,aAAa,GAAG,UAAU;AAAA,IACnC;AAAA,EACF,EAKC,QAAQ,qBAAqB,QAAQ,EAMrC,QAAQ,wBAAwB,QAAQ;AAE/C;AAKO,SAAS,gBAAgB,KAAU,MAAY,SAAyB;AAC7E,QAAM,iBAAiB,cAAc,MAAM,OAAO;AAClD,QAAM,YACJ,OAAO,mBAAmB,WACtB,WAAW,cAAc,IACzB;AAEN,QAAM,WAAW,YAAY,GAAG;AAChC,QAAM,SAAS,MAAM,WAAW,EAAE,QAAQ,mBAAmB,CAAC,EAAE,QAAQ;AACxE,QAAM,SAAU,UAAW,OAAO,UAA0B,CAAC;AAE7D,SAAO;AAAA,IACL,SAAS,WAAW;AAAA,IACpB;AAAA,EACF;AACF;AAEO,SAAS,OAAO,OAA+B;AACpD,SAAO,OAAO,UAAU,YAAY,iBAAiB;AACvD;","names":[]}
package/lib/iife/index.js CHANGED
@@ -14456,7 +14456,7 @@ ${operationTypes.join("\n")}
14456
14456
  return stringToRegexp(path, keys, options);
14457
14457
  }
14458
14458
 
14459
- // node_modules/.pnpm/@mswjs+interceptors@0.36.10/node_modules/@mswjs/interceptors/lib/browser/chunk-6HYIRFX2.mjs
14459
+ // node_modules/.pnpm/@mswjs+interceptors@0.37.0/node_modules/@mswjs/interceptors/lib/browser/chunk-6HYIRFX2.mjs
14460
14460
  var encoder = new TextEncoder();
14461
14461
  function encodeBuffer(text) {
14462
14462
  return encoder.encode(text);
@@ -14472,54 +14472,67 @@ ${operationTypes.join("\n")}
14472
14472
  );
14473
14473
  }
14474
14474
 
14475
- // node_modules/.pnpm/@mswjs+interceptors@0.36.10/node_modules/@mswjs/interceptors/lib/browser/chunk-6MOMO77R.mjs
14475
+ // node_modules/.pnpm/@mswjs+interceptors@0.37.0/node_modules/@mswjs/interceptors/lib/browser/chunk-F4BN745U.mjs
14476
14476
  var IS_PATCHED_MODULE = Symbol("isPatchedModule");
14477
- function isPropertyAccessible(obj, key) {
14478
- try {
14479
- obj[key];
14480
- return true;
14481
- } catch (e) {
14482
- return false;
14477
+ var _FetchResponse = class extends Response {
14478
+ static isConfigurableStatusCode(status) {
14479
+ return status >= 200 && status <= 599;
14483
14480
  }
14484
- }
14485
- var RESPONSE_STATUS_CODES_WITHOUT_BODY = /* @__PURE__ */ new Set([
14486
- 101,
14487
- 103,
14488
- 204,
14489
- 205,
14490
- 304
14491
- ]);
14492
- var RESPONSE_STATUS_CODES_WITH_REDIRECT = /* @__PURE__ */ new Set([
14493
- 301,
14494
- 302,
14495
- 303,
14496
- 307,
14497
- 308
14498
- ]);
14499
- function isResponseWithoutBody(status) {
14500
- return RESPONSE_STATUS_CODES_WITHOUT_BODY.has(status);
14501
- }
14502
- function createServerErrorResponse(body) {
14503
- return new Response(
14504
- JSON.stringify(
14505
- body instanceof Error ? {
14506
- name: body.name,
14507
- message: body.message,
14508
- stack: body.stack
14509
- } : body
14510
- ),
14511
- {
14512
- status: 500,
14513
- statusText: "Unhandled Exception",
14514
- headers: {
14515
- "Content-Type": "application/json"
14481
+ static isRedirectResponse(status) {
14482
+ return _FetchResponse.STATUS_CODES_WITH_REDIRECT.includes(status);
14483
+ }
14484
+ /**
14485
+ * Returns a boolean indicating whether the given response status
14486
+ * code represents a response that can have a body.
14487
+ */
14488
+ static isResponseWithBody(status) {
14489
+ return !_FetchResponse.STATUS_CODES_WITHOUT_BODY.includes(status);
14490
+ }
14491
+ static setUrl(url, response) {
14492
+ if (!url) {
14493
+ return;
14494
+ }
14495
+ if (response.url != "") {
14496
+ return;
14497
+ }
14498
+ Object.defineProperty(response, "url", {
14499
+ value: url,
14500
+ enumerable: true,
14501
+ configurable: true,
14502
+ writable: false
14503
+ });
14504
+ }
14505
+ constructor(body, init = {}) {
14506
+ var _a2;
14507
+ const status = (_a2 = init.status) != null ? _a2 : 200;
14508
+ const safeStatus = _FetchResponse.isConfigurableStatusCode(status) ? status : 200;
14509
+ const finalBody = _FetchResponse.isResponseWithBody(status) ? body : null;
14510
+ super(finalBody, {
14511
+ ...init,
14512
+ status: safeStatus
14513
+ });
14514
+ if (status !== safeStatus) {
14515
+ const stateSymbol = Object.getOwnPropertySymbols(this).find(
14516
+ (symbol) => symbol.description === "state"
14517
+ );
14518
+ if (stateSymbol) {
14519
+ const state = Reflect.get(this, stateSymbol);
14520
+ Reflect.set(state, "status", status);
14521
+ } else {
14522
+ Object.defineProperty(this, "status", {
14523
+ value: status,
14524
+ enumerable: true,
14525
+ configurable: true,
14526
+ writable: false
14527
+ });
14516
14528
  }
14517
14529
  }
14518
- );
14519
- }
14520
- function isResponseError(response) {
14521
- return isPropertyAccessible(response, "type") && response.type === "error";
14522
- }
14530
+ _FetchResponse.setUrl(init.url, this);
14531
+ }
14532
+ };
14533
+ var FetchResponse = _FetchResponse;
14534
+ FetchResponse.STATUS_CODES_WITHOUT_BODY = [101, 103, 204, 205, 304];
14535
+ FetchResponse.STATUS_CODES_WITH_REDIRECT = [301, 302, 303, 307, 308];
14523
14536
 
14524
14537
  // node_modules/.pnpm/is-node-process@1.2.0/node_modules/is-node-process/lib/index.mjs
14525
14538
  function isNodeProcess() {
@@ -14808,7 +14821,7 @@ ${operationTypes.join("\n")}
14808
14821
  return message3.toString();
14809
14822
  }
14810
14823
 
14811
- // node_modules/.pnpm/@mswjs+interceptors@0.36.10/node_modules/@mswjs/interceptors/lib/browser/chunk-QED3Q6Z2.mjs
14824
+ // node_modules/.pnpm/@mswjs+interceptors@0.37.0/node_modules/@mswjs/interceptors/lib/browser/chunk-QED3Q6Z2.mjs
14812
14825
  var INTERNAL_REQUEST_ID_HEADER_NAME = "x-interceptors-internal-request-id";
14813
14826
  function getGlobalSymbol(symbol) {
14814
14827
  return (
@@ -14956,7 +14969,7 @@ ${operationTypes.join("\n")}
14956
14969
  return Math.random().toString(16).slice(2);
14957
14970
  }
14958
14971
 
14959
- // node_modules/.pnpm/@mswjs+interceptors@0.36.10/node_modules/@mswjs/interceptors/lib/browser/index.mjs
14972
+ // node_modules/.pnpm/@mswjs+interceptors@0.37.0/node_modules/@mswjs/interceptors/lib/browser/index.mjs
14960
14973
  var BatchInterceptor = class extends Interceptor {
14961
14974
  constructor(options) {
14962
14975
  BatchInterceptor.symbol = Symbol(options.name);
@@ -29314,23 +29327,24 @@ You can also automate this process and make the worker script update automatical
29314
29327
  if (responseJson.type?.includes("opaque")) {
29315
29328
  return;
29316
29329
  }
29317
- const response = responseJson.status === 0 ? Response.error() : new Response(
29330
+ const response = responseJson.status === 0 ? Response.error() : new FetchResponse(
29318
29331
  /**
29319
29332
  * Responses may be streams here, but when we create a response object
29320
29333
  * with null-body status codes, like 204, 205, 304 Response will
29321
29334
  * throw when passed a non-null body, so ensure it's null here
29322
29335
  * for those codes
29323
29336
  */
29324
- isResponseWithoutBody(responseJson.status) ? null : responseJson.body,
29325
- responseJson
29337
+ FetchResponse.isResponseWithBody(responseJson.status) ? responseJson.body : null,
29338
+ {
29339
+ ...responseJson,
29340
+ /**
29341
+ * Set response URL if it's not set already.
29342
+ * @see https://github.com/mswjs/msw/issues/2030
29343
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Response/url
29344
+ */
29345
+ url: request.url
29346
+ }
29326
29347
  );
29327
- if (!response.url) {
29328
- Object.defineProperty(response, "url", {
29329
- value: request.url,
29330
- enumerable: true,
29331
- writable: false
29332
- });
29333
- }
29334
29348
  context.emitter.emit(
29335
29349
  responseJson.isMockedResponse ? "response:mocked" : "response:bypass",
29336
29350
  {
@@ -29500,7 +29514,7 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
29500
29514
  }
29501
29515
  };
29502
29516
 
29503
- // node_modules/.pnpm/@mswjs+interceptors@0.36.10/node_modules/@mswjs/interceptors/lib/browser/chunk-4RQHC4IY.mjs
29517
+ // node_modules/.pnpm/@mswjs+interceptors@0.37.0/node_modules/@mswjs/interceptors/lib/browser/chunk-H5O73WD2.mjs
29504
29518
  var InterceptorError = class extends Error {
29505
29519
  constructor(message3) {
29506
29520
  super(message3);
@@ -29561,6 +29575,35 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
29561
29575
  await listener.apply(emitter, data);
29562
29576
  }
29563
29577
  }
29578
+ function isPropertyAccessible(obj, key) {
29579
+ try {
29580
+ obj[key];
29581
+ return true;
29582
+ } catch (e) {
29583
+ return false;
29584
+ }
29585
+ }
29586
+ function createServerErrorResponse(body) {
29587
+ return new Response(
29588
+ JSON.stringify(
29589
+ body instanceof Error ? {
29590
+ name: body.name,
29591
+ message: body.message,
29592
+ stack: body.stack
29593
+ } : body
29594
+ ),
29595
+ {
29596
+ status: 500,
29597
+ statusText: "Unhandled Exception",
29598
+ headers: {
29599
+ "Content-Type": "application/json"
29600
+ }
29601
+ }
29602
+ );
29603
+ }
29604
+ function isResponseError(response) {
29605
+ return isPropertyAccessible(response, "type") && response.type === "error";
29606
+ }
29564
29607
  function isNodeLikeError(error3) {
29565
29608
  if (error3 == null) {
29566
29609
  return false;
@@ -29672,7 +29715,7 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
29672
29715
  return false;
29673
29716
  }
29674
29717
 
29675
- // node_modules/.pnpm/@mswjs+interceptors@0.36.10/node_modules/@mswjs/interceptors/lib/browser/chunk-TX5GBTFY.mjs
29718
+ // node_modules/.pnpm/@mswjs+interceptors@0.37.0/node_modules/@mswjs/interceptors/lib/browser/chunk-TX5GBTFY.mjs
29676
29719
  function hasConfigurableGlobal(propertyName) {
29677
29720
  const descriptor = Object.getOwnPropertyDescriptor(globalThis, propertyName);
29678
29721
  if (typeof descriptor === "undefined") {
@@ -29693,7 +29736,7 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
29693
29736
  return true;
29694
29737
  }
29695
29738
 
29696
- // node_modules/.pnpm/@mswjs+interceptors@0.36.10/node_modules/@mswjs/interceptors/lib/browser/chunk-VXLPKFY4.mjs
29739
+ // node_modules/.pnpm/@mswjs+interceptors@0.37.0/node_modules/@mswjs/interceptors/lib/browser/chunk-HER3NHBG.mjs
29697
29740
  function canParseUrl(url) {
29698
29741
  try {
29699
29742
  new URL(url);
@@ -29869,8 +29912,9 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
29869
29912
  rawResponse
29870
29913
  });
29871
29914
  const decompressedStream = decompressResponse(rawResponse);
29872
- const response = decompressedStream === null ? rawResponse : new Response(decompressedStream, rawResponse);
29873
- if (RESPONSE_STATUS_CODES_WITH_REDIRECT.has(response.status)) {
29915
+ const response = decompressedStream === null ? rawResponse : new FetchResponse(decompressedStream, rawResponse);
29916
+ FetchResponse.setUrl(request.url, response);
29917
+ if (FetchResponse.isRedirectResponse(response.status)) {
29874
29918
  if (request.redirect === "error") {
29875
29919
  responsePromise.reject(createNetworkError("unexpected redirect"));
29876
29920
  return;
@@ -29887,12 +29931,6 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
29887
29931
  return;
29888
29932
  }
29889
29933
  }
29890
- Object.defineProperty(response, "url", {
29891
- writable: false,
29892
- enumerable: true,
29893
- configurable: false,
29894
- value: request.url
29895
- });
29896
29934
  if (this.emitter.listenerCount("response") > 0) {
29897
29935
  this.logger.info('emitting the "response" event...');
29898
29936
  await emitAsync(this.emitter, "response", {
@@ -29958,7 +29996,7 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
29958
29996
  var FetchInterceptor = _FetchInterceptor;
29959
29997
  FetchInterceptor.symbol = Symbol("fetch");
29960
29998
 
29961
- // node_modules/.pnpm/@mswjs+interceptors@0.36.10/node_modules/@mswjs/interceptors/lib/browser/chunk-MMAVIMED.mjs
29999
+ // node_modules/.pnpm/@mswjs+interceptors@0.37.0/node_modules/@mswjs/interceptors/lib/browser/chunk-4SRQFK76.mjs
29962
30000
  function concatArrayBuffer(left, right) {
29963
30001
  const result = new Uint8Array(left.byteLength + right.byteLength);
29964
30002
  result.set(left, 0);
@@ -30121,8 +30159,9 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
30121
30159
  }
30122
30160
  }
30123
30161
  function createResponse(request, body) {
30124
- const responseBodyOrNull = isResponseWithoutBody(request.status) ? null : body;
30125
- return new Response(responseBodyOrNull, {
30162
+ const responseBodyOrNull = FetchResponse.isResponseWithBody(request.status) ? body : null;
30163
+ return new FetchResponse(responseBodyOrNull, {
30164
+ url: request.responseURL,
30126
30165
  status: request.status,
30127
30166
  statusText: request.statusText,
30128
30167
  headers: createHeadersFromXMLHttpReqestHeaders(
@@ -30829,7 +30868,7 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
30829
30868
  }
30830
30869
  }
30831
30870
 
30832
- // node_modules/.pnpm/@mswjs+interceptors@0.36.10/node_modules/@mswjs/interceptors/lib/browser/interceptors/WebSocket/index.mjs
30871
+ // node_modules/.pnpm/@mswjs+interceptors@0.37.0/node_modules/@mswjs/interceptors/lib/browser/interceptors/WebSocket/index.mjs
30833
30872
  function bindEvent(target, event) {
30834
30873
  Object.defineProperties(event, {
30835
30874
  target: {