msw 2.11.2 → 2.11.3

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.
@@ -7,7 +7,7 @@
7
7
  * - Please do NOT modify this file.
8
8
  */
9
9
 
10
- const PACKAGE_VERSION = '2.11.2'
10
+ const PACKAGE_VERSION = '2.11.3'
11
11
  const INTEGRITY_CHECKSUM = '4db4a41e972cec1b64cc569c66952d82'
12
12
  const IS_MOCKED_RESPONSE = Symbol('isMockedResponse')
13
13
  const activeClientIds = new Set()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "msw",
3
- "version": "2.11.2",
3
+ "version": "2.11.3",
4
4
  "description": "Seamless REST/GraphQL API mocking library for browser and Node.js.",
5
5
  "type": "commonjs",
6
6
  "main": "./lib/core/index.js",
@@ -219,7 +219,6 @@
219
219
  "@inquirer/confirm": "^5.0.0",
220
220
  "@mswjs/interceptors": "^0.39.1",
221
221
  "@open-draft/deferred-promise": "^2.2.0",
222
- "@open-draft/until": "^2.1.0",
223
222
  "@types/cookie": "^0.6.0",
224
223
  "@types/statuses": "^2.0.4",
225
224
  "graphql": "^16.8.1",
@@ -232,6 +231,7 @@
232
231
  "strict-event-emitter": "^0.5.1",
233
232
  "tough-cookie": "^6.0.0",
234
233
  "type-fest": "^4.26.1",
234
+ "until-async": "^3.0.2",
235
235
  "yargs": "^17.7.2"
236
236
  },
237
237
  "devDependencies": {
@@ -283,11 +283,11 @@
283
283
  "typescript-eslint": "^8.42.0",
284
284
  "undici": "^6.20.0",
285
285
  "url-loader": "^4.1.1",
286
- "vitest": "^3.1.4",
286
+ "vitest": "^3.2.4",
287
287
  "vitest-environment-miniflare": "^2.14.4",
288
288
  "webpack": "^5.95.0",
289
289
  "webpack-http-server": "^0.5.0",
290
- "msw": "2.11.2"
290
+ "msw": "2.11.3"
291
291
  },
292
292
  "peerDependencies": {
293
293
  "typescript": ">= 4.8.x"
@@ -1,4 +1,4 @@
1
- import { until } from '@open-draft/until'
1
+ import { until } from 'until-async'
2
2
  import { devUtils } from '~/core/utils/internal/devUtils'
3
3
  import { getAbsoluteWorkerUrl } from '../../../utils/getAbsoluteWorkerUrl'
4
4
  import { getWorkerByRegistration } from './getWorkerByRegistration'
@@ -52,21 +52,22 @@ export const getWorkerInstance = async (
52
52
  }
53
53
 
54
54
  // When the Service Worker wasn't found, register it anew and return the reference.
55
- const registrationResult = await until<Error, ServiceWorkerInstanceTuple>(
56
- async () => {
57
- const registration = await navigator.serviceWorker.register(url, options)
58
- return [
59
- // Compare existing worker registration by its worker URL,
60
- // to prevent irrelevant workers to resolve here (such as Codesandbox worker).
61
- getWorkerByRegistration(registration, absoluteWorkerUrl, findWorker),
62
- registration,
63
- ]
64
- },
65
- )
55
+ const [registrationError, registrationResult] = await until<
56
+ Error,
57
+ ServiceWorkerInstanceTuple
58
+ >(async () => {
59
+ const registration = await navigator.serviceWorker.register(url, options)
60
+ return [
61
+ // Compare existing worker registration by its worker URL,
62
+ // to prevent irrelevant workers to resolve here (such as Codesandbox worker).
63
+ getWorkerByRegistration(registration, absoluteWorkerUrl, findWorker),
64
+ registration,
65
+ ]
66
+ })
66
67
 
67
68
  // Handle Service Worker registration errors.
68
- if (registrationResult.error) {
69
- const isWorkerMissing = registrationResult.error.message.includes('(404)')
69
+ if (registrationError) {
70
+ const isWorkerMissing = registrationError.message.includes('(404)')
70
71
 
71
72
  // Produce a custom error message when given a non-existing Service Worker url.
72
73
  // Suggest developers to check their setup.
@@ -87,10 +88,10 @@ Learn more about creating the Service Worker script: https://mswjs.io/docs/cli/i
87
88
  throw new Error(
88
89
  devUtils.formatMessage(
89
90
  'Failed to register the Service Worker:\n\n%s',
90
- registrationResult.error.message,
91
+ registrationError.message,
91
92
  ),
92
93
  )
93
94
  }
94
95
 
95
- return registrationResult.data
96
+ return registrationResult
96
97
  }
@@ -1,4 +1,4 @@
1
- import { until } from '@open-draft/until'
1
+ import { until } from 'until-async'
2
2
 
3
3
  /**
4
4
  * Intercepts and defers any requests on the page
@@ -1,4 +1,4 @@
1
- import { until } from '@open-draft/until'
1
+ import { until } from 'until-async'
2
2
  import { Emitter } from 'strict-event-emitter'
3
3
  import { LifeCycleEventsMap, SharedOptions } from '../sharedOptions'
4
4
  import { RequiredDeep } from '../typeUtils'
@@ -54,7 +54,7 @@ export async function handleRequest(
54
54
  }
55
55
 
56
56
  // Resolve a mocked response from the list of request handlers.
57
- const lookupResult = await until(() => {
57
+ const [lookupError, lookupResult] = await until(() => {
58
58
  return executeHandlers({
59
59
  request,
60
60
  requestId,
@@ -63,19 +63,19 @@ export async function handleRequest(
63
63
  })
64
64
  })
65
65
 
66
- if (lookupResult.error) {
66
+ if (lookupError) {
67
67
  // Allow developers to react to unhandled exceptions in request handlers.
68
68
  emitter.emit('unhandledException', {
69
- error: lookupResult.error,
69
+ error: lookupError,
70
70
  request,
71
71
  requestId,
72
72
  })
73
- throw lookupResult.error
73
+ throw lookupError
74
74
  }
75
75
 
76
76
  // If the handler lookup returned nothing, no request handler was found
77
77
  // matching this request. Report the request as unhandled.
78
- if (!lookupResult.data) {
78
+ if (!lookupResult) {
79
79
  await onUnhandledRequest(request, options.onUnhandledRequest)
80
80
  emitter.emit('request:unhandled', { request, requestId })
81
81
  emitter.emit('request:end', { request, requestId })
@@ -83,7 +83,7 @@ export async function handleRequest(
83
83
  return
84
84
  }
85
85
 
86
- const { response } = lookupResult.data
86
+ const { response } = lookupResult
87
87
 
88
88
  // When the handled request returned no mocked response, warn the developer,
89
89
  // as it may be an oversight on their part. Perform the request as-is.
@@ -110,7 +110,7 @@ export async function handleRequest(
110
110
  emitter.emit('request:match', { request, requestId })
111
111
 
112
112
  const requiredLookupResult =
113
- lookupResult.data as RequiredDeep<HandlersExecutionResult>
113
+ lookupResult as RequiredDeep<HandlersExecutionResult>
114
114
 
115
115
  handleRequestOptions?.onMockedResponse?.(response, requiredLookupResult)
116
116