msw 2.8.7 → 2.9.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.
package/lib/iife/index.js CHANGED
@@ -29038,11 +29038,11 @@ Learn more about creating the Service Worker script: https://mswjs.io/docs/cli/i
29038
29038
  return request.body;
29039
29039
  }
29040
29040
 
29041
- // src/browser/utils/parseWorkerRequest.ts
29042
- function parseWorkerRequest(incomingRequest) {
29043
- return new Request(incomingRequest.url, {
29044
- ...incomingRequest,
29045
- body: pruneGetRequestBody(incomingRequest)
29041
+ // src/browser/utils/deserializeRequest.ts
29042
+ function deserializeRequest(serializedRequest) {
29043
+ return new Request(serializedRequest.url, {
29044
+ ...serializedRequest,
29045
+ body: pruneGetRequestBody(serializedRequest)
29046
29046
  });
29047
29047
  }
29048
29048
 
@@ -29067,11 +29067,10 @@ Learn more about creating the Service Worker script: https://mswjs.io/docs/cli/i
29067
29067
  return async (event, message3) => {
29068
29068
  const messageChannel = new WorkerChannel(event.ports[0]);
29069
29069
  const requestId = message3.payload.id;
29070
- const request = parseWorkerRequest(message3.payload);
29070
+ const request = deserializeRequest(message3.payload);
29071
29071
  const requestCloneForLogs = request.clone();
29072
29072
  const requestClone = request.clone();
29073
29073
  RequestHandler.cache.set(request, requestClone);
29074
- context.requests.set(requestId, requestClone);
29075
29074
  try {
29076
29075
  await handleRequest(
29077
29076
  request,
@@ -29149,7 +29148,7 @@ This exception has been gracefully handled as a 500 response, however, it's stro
29149
29148
  async function checkWorkerIntegrity(context) {
29150
29149
  context.workerChannel.send("INTEGRITY_CHECK_REQUEST");
29151
29150
  const { payload } = await context.events.once("INTEGRITY_CHECK_RESPONSE");
29152
- if (payload.checksum !== "00729d72e3b82faf54ca8b9621dbb96f") {
29151
+ if (payload.checksum !== "f5825c521429caf22a4dd13b66e243af") {
29153
29152
  devUtils.warn(
29154
29153
  `The currently registered Service Worker has been generated by a different version of MSW (${payload.packageVersion}) and may not be fully compatible with the installed version.
29155
29154
 
@@ -29166,20 +29165,18 @@ You can also automate this process and make the worker script update automatical
29166
29165
  function createResponseListener(context) {
29167
29166
  return (_, message3) => {
29168
29167
  const { payload: responseJson } = message3;
29169
- const { requestId } = responseJson;
29170
- const request = context.requests.get(requestId);
29171
- context.requests.delete(requestId);
29172
- if (responseJson.type?.includes("opaque")) {
29168
+ const request = deserializeRequest(responseJson.request);
29169
+ if (responseJson.response.type?.includes("opaque")) {
29173
29170
  return;
29174
29171
  }
29175
- const response = responseJson.status === 0 ? Response.error() : new FetchResponse(
29172
+ const response = responseJson.response.status === 0 ? Response.error() : new FetchResponse(
29176
29173
  /**
29177
29174
  * Responses may be streams here, but when we create a response object
29178
29175
  * with null-body status codes, like 204, 205, 304 Response will
29179
29176
  * throw when passed a non-null body, so ensure it's null here
29180
29177
  * for those codes
29181
29178
  */
29182
- FetchResponse.isResponseWithBody(responseJson.status) ? responseJson.body : null,
29179
+ FetchResponse.isResponseWithBody(responseJson.response.status) ? responseJson.response.body : null,
29183
29180
  {
29184
29181
  ...responseJson,
29185
29182
  /**
@@ -29193,9 +29190,9 @@ You can also automate this process and make the worker script update automatical
29193
29190
  context.emitter.emit(
29194
29191
  responseJson.isMockedResponse ? "response:mocked" : "response:bypass",
29195
29192
  {
29196
- response,
29193
+ requestId: responseJson.request.id,
29197
29194
  request,
29198
- requestId: responseJson.requestId
29195
+ response
29199
29196
  }
29200
29197
  );
29201
29198
  };
@@ -31685,7 +31682,6 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
31685
31682
  return this.handlersController.currentHandlers();
31686
31683
  },
31687
31684
  registration: null,
31688
- requests: /* @__PURE__ */ new Map(),
31689
31685
  emitter: this.emitter,
31690
31686
  workerChannel: {
31691
31687
  on: (eventType, callback) => {