@depup/msw 2.12.13-depup.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/LICENSE.md +21 -0
- package/README.md +40 -0
- package/browser/package.json +31 -0
- package/changes.json +46 -0
- package/cli/index.js +35 -0
- package/cli/init.js +226 -0
- package/cli/invariant.js +9 -0
- package/cli/package.json +3 -0
- package/config/constants.js +13 -0
- package/config/package.json +3 -0
- package/config/scripts/postinstall.js +36 -0
- package/lib/browser/index.d.mts +102 -0
- package/lib/browser/index.d.ts +102 -0
- package/lib/browser/index.js +2911 -0
- package/lib/browser/index.js.map +1 -0
- package/lib/browser/index.mjs +2888 -0
- package/lib/browser/index.mjs.map +1 -0
- package/lib/core/HttpResponse-Be4eT3x6.d.mts +338 -0
- package/lib/core/HttpResponse-Dj6ibgFJ.d.ts +338 -0
- package/lib/core/HttpResponse.d.mts +6 -0
- package/lib/core/HttpResponse.d.ts +6 -0
- package/lib/core/HttpResponse.js +176 -0
- package/lib/core/HttpResponse.js.map +1 -0
- package/lib/core/HttpResponse.mjs +159 -0
- package/lib/core/HttpResponse.mjs.map +1 -0
- package/lib/core/SetupApi.d.mts +44 -0
- package/lib/core/SetupApi.d.ts +44 -0
- package/lib/core/SetupApi.js +112 -0
- package/lib/core/SetupApi.js.map +1 -0
- package/lib/core/SetupApi.mjs +92 -0
- package/lib/core/SetupApi.mjs.map +1 -0
- package/lib/core/bypass.d.mts +16 -0
- package/lib/core/bypass.d.ts +16 -0
- package/lib/core/bypass.js +42 -0
- package/lib/core/bypass.js.map +1 -0
- package/lib/core/bypass.mjs +22 -0
- package/lib/core/bypass.mjs.map +1 -0
- package/lib/core/delay.d.mts +18 -0
- package/lib/core/delay.d.ts +18 -0
- package/lib/core/delay.js +77 -0
- package/lib/core/delay.js.map +1 -0
- package/lib/core/delay.mjs +57 -0
- package/lib/core/delay.mjs.map +1 -0
- package/lib/core/getResponse.d.mts +18 -0
- package/lib/core/getResponse.d.ts +18 -0
- package/lib/core/getResponse.js +35 -0
- package/lib/core/getResponse.js.map +1 -0
- package/lib/core/getResponse.mjs +17 -0
- package/lib/core/getResponse.mjs.map +1 -0
- package/lib/core/graphql.d.mts +76 -0
- package/lib/core/graphql.d.ts +76 -0
- package/lib/core/graphql.js +90 -0
- package/lib/core/graphql.js.map +1 -0
- package/lib/core/graphql.mjs +72 -0
- package/lib/core/graphql.mjs.map +1 -0
- package/lib/core/handlers/GraphQLHandler.d.mts +6 -0
- package/lib/core/handlers/GraphQLHandler.d.ts +6 -0
- package/lib/core/handlers/GraphQLHandler.js +231 -0
- package/lib/core/handlers/GraphQLHandler.js.map +1 -0
- package/lib/core/handlers/GraphQLHandler.mjs +218 -0
- package/lib/core/handlers/GraphQLHandler.mjs.map +1 -0
- package/lib/core/handlers/HttpHandler.d.mts +75 -0
- package/lib/core/handlers/HttpHandler.d.ts +75 -0
- package/lib/core/handlers/HttpHandler.js +128 -0
- package/lib/core/handlers/HttpHandler.js.map +1 -0
- package/lib/core/handlers/HttpHandler.mjs +112 -0
- package/lib/core/handlers/HttpHandler.mjs.map +1 -0
- package/lib/core/handlers/RequestHandler.d.mts +6 -0
- package/lib/core/handlers/RequestHandler.d.ts +6 -0
- package/lib/core/handlers/RequestHandler.js +173 -0
- package/lib/core/handlers/RequestHandler.js.map +1 -0
- package/lib/core/handlers/RequestHandler.mjs +155 -0
- package/lib/core/handlers/RequestHandler.mjs.map +1 -0
- package/lib/core/handlers/WebSocketHandler.d.mts +42 -0
- package/lib/core/handlers/WebSocketHandler.d.ts +42 -0
- package/lib/core/handlers/WebSocketHandler.js +147 -0
- package/lib/core/handlers/WebSocketHandler.js.map +1 -0
- package/lib/core/handlers/WebSocketHandler.mjs +129 -0
- package/lib/core/handlers/WebSocketHandler.mjs.map +1 -0
- package/lib/core/handlers/common.d.mts +3 -0
- package/lib/core/handlers/common.d.ts +3 -0
- package/lib/core/handlers/common.js +17 -0
- package/lib/core/handlers/common.js.map +1 -0
- package/lib/core/handlers/common.mjs +1 -0
- package/lib/core/handlers/common.mjs.map +1 -0
- package/lib/core/http.d.mts +31 -0
- package/lib/core/http.d.ts +31 -0
- package/lib/core/http.js +40 -0
- package/lib/core/http.js.map +1 -0
- package/lib/core/http.mjs +23 -0
- package/lib/core/http.mjs.map +1 -0
- package/lib/core/index.d.mts +32 -0
- package/lib/core/index.d.ts +32 -0
- package/lib/core/index.js +64 -0
- package/lib/core/index.js.map +1 -0
- package/lib/core/index.mjs +52 -0
- package/lib/core/index.mjs.map +1 -0
- package/lib/core/isCommonAssetRequest.d.mts +20 -0
- package/lib/core/isCommonAssetRequest.d.ts +20 -0
- package/lib/core/isCommonAssetRequest.js +42 -0
- package/lib/core/isCommonAssetRequest.js.map +1 -0
- package/lib/core/isCommonAssetRequest.mjs +22 -0
- package/lib/core/isCommonAssetRequest.mjs.map +1 -0
- package/lib/core/passthrough.d.mts +24 -0
- package/lib/core/passthrough.d.ts +24 -0
- package/lib/core/passthrough.js +33 -0
- package/lib/core/passthrough.js.map +1 -0
- package/lib/core/passthrough.mjs +13 -0
- package/lib/core/passthrough.mjs.map +1 -0
- package/lib/core/sharedOptions.d.mts +64 -0
- package/lib/core/sharedOptions.d.ts +64 -0
- package/lib/core/sharedOptions.js +17 -0
- package/lib/core/sharedOptions.js.map +1 -0
- package/lib/core/sharedOptions.mjs +1 -0
- package/lib/core/sharedOptions.mjs.map +1 -0
- package/lib/core/sse.d.mts +116 -0
- package/lib/core/sse.d.ts +116 -0
- package/lib/core/sse.js +607 -0
- package/lib/core/sse.js.map +1 -0
- package/lib/core/sse.mjs +589 -0
- package/lib/core/sse.mjs.map +1 -0
- package/lib/core/typeUtils.d.mts +12 -0
- package/lib/core/typeUtils.d.ts +12 -0
- package/lib/core/typeUtils.js +17 -0
- package/lib/core/typeUtils.js.map +1 -0
- package/lib/core/typeUtils.mjs +1 -0
- package/lib/core/typeUtils.mjs.map +1 -0
- package/lib/core/utils/HttpResponse/decorators.d.mts +17 -0
- package/lib/core/utils/HttpResponse/decorators.d.ts +17 -0
- package/lib/core/utils/HttpResponse/decorators.js +77 -0
- package/lib/core/utils/HttpResponse/decorators.js.map +1 -0
- package/lib/core/utils/HttpResponse/decorators.mjs +47 -0
- package/lib/core/utils/HttpResponse/decorators.mjs.map +1 -0
- package/lib/core/utils/cookieStore.d.mts +13 -0
- package/lib/core/utils/cookieStore.d.ts +13 -0
- package/lib/core/utils/cookieStore.js +90 -0
- package/lib/core/utils/cookieStore.js.map +1 -0
- package/lib/core/utils/cookieStore.mjs +74 -0
- package/lib/core/utils/cookieStore.mjs.map +1 -0
- package/lib/core/utils/executeHandlers.d.mts +6 -0
- package/lib/core/utils/executeHandlers.d.ts +6 -0
- package/lib/core/utils/executeHandlers.js +50 -0
- package/lib/core/utils/executeHandlers.js.map +1 -0
- package/lib/core/utils/executeHandlers.mjs +30 -0
- package/lib/core/utils/executeHandlers.mjs.map +1 -0
- package/lib/core/utils/handleRequest.d.mts +29 -0
- package/lib/core/utils/handleRequest.d.ts +29 -0
- package/lib/core/utils/handleRequest.js +76 -0
- package/lib/core/utils/handleRequest.js.map +1 -0
- package/lib/core/utils/handleRequest.mjs +58 -0
- package/lib/core/utils/handleRequest.mjs.map +1 -0
- package/lib/core/utils/internal/Disposable.d.mts +7 -0
- package/lib/core/utils/internal/Disposable.d.ts +7 -0
- package/lib/core/utils/internal/Disposable.js +33 -0
- package/lib/core/utils/internal/Disposable.js.map +1 -0
- package/lib/core/utils/internal/Disposable.mjs +13 -0
- package/lib/core/utils/internal/Disposable.mjs.map +1 -0
- package/lib/core/utils/internal/checkGlobals.d.mts +3 -0
- package/lib/core/utils/internal/checkGlobals.d.ts +3 -0
- package/lib/core/utils/internal/checkGlobals.js +34 -0
- package/lib/core/utils/internal/checkGlobals.js.map +1 -0
- package/lib/core/utils/internal/checkGlobals.mjs +14 -0
- package/lib/core/utils/internal/checkGlobals.mjs.map +1 -0
- package/lib/core/utils/internal/devUtils.d.mts +28 -0
- package/lib/core/utils/internal/devUtils.d.ts +28 -0
- package/lib/core/utils/internal/devUtils.js +48 -0
- package/lib/core/utils/internal/devUtils.js.map +1 -0
- package/lib/core/utils/internal/devUtils.mjs +28 -0
- package/lib/core/utils/internal/devUtils.mjs.map +1 -0
- package/lib/core/utils/internal/getCallFrame.d.mts +6 -0
- package/lib/core/utils/internal/getCallFrame.d.ts +6 -0
- package/lib/core/utils/internal/getCallFrame.js +41 -0
- package/lib/core/utils/internal/getCallFrame.js.map +1 -0
- package/lib/core/utils/internal/getCallFrame.mjs +21 -0
- package/lib/core/utils/internal/getCallFrame.mjs.map +1 -0
- package/lib/core/utils/internal/hasRefCounted.d.mts +3 -0
- package/lib/core/utils/internal/hasRefCounted.d.ts +3 -0
- package/lib/core/utils/internal/hasRefCounted.js +27 -0
- package/lib/core/utils/internal/hasRefCounted.js.map +1 -0
- package/lib/core/utils/internal/hasRefCounted.mjs +7 -0
- package/lib/core/utils/internal/hasRefCounted.mjs.map +1 -0
- package/lib/core/utils/internal/isHandlerKind.d.mts +19 -0
- package/lib/core/utils/internal/isHandlerKind.d.ts +19 -0
- package/lib/core/utils/internal/isHandlerKind.js +29 -0
- package/lib/core/utils/internal/isHandlerKind.js.map +1 -0
- package/lib/core/utils/internal/isHandlerKind.mjs +9 -0
- package/lib/core/utils/internal/isHandlerKind.mjs.map +1 -0
- package/lib/core/utils/internal/isIterable.d.mts +20 -0
- package/lib/core/utils/internal/isIterable.d.ts +20 -0
- package/lib/core/utils/internal/isIterable.js +30 -0
- package/lib/core/utils/internal/isIterable.js.map +1 -0
- package/lib/core/utils/internal/isIterable.mjs +10 -0
- package/lib/core/utils/internal/isIterable.mjs.map +1 -0
- package/lib/core/utils/internal/isObject.d.mts +6 -0
- package/lib/core/utils/internal/isObject.d.ts +6 -0
- package/lib/core/utils/internal/isObject.js +27 -0
- package/lib/core/utils/internal/isObject.js.map +1 -0
- package/lib/core/utils/internal/isObject.mjs +7 -0
- package/lib/core/utils/internal/isObject.mjs.map +1 -0
- package/lib/core/utils/internal/isStringEqual.d.mts +6 -0
- package/lib/core/utils/internal/isStringEqual.d.ts +6 -0
- package/lib/core/utils/internal/isStringEqual.js +27 -0
- package/lib/core/utils/internal/isStringEqual.js.map +1 -0
- package/lib/core/utils/internal/isStringEqual.mjs +7 -0
- package/lib/core/utils/internal/isStringEqual.mjs.map +1 -0
- package/lib/core/utils/internal/jsonParse.d.mts +7 -0
- package/lib/core/utils/internal/jsonParse.d.ts +7 -0
- package/lib/core/utils/internal/jsonParse.js +31 -0
- package/lib/core/utils/internal/jsonParse.js.map +1 -0
- package/lib/core/utils/internal/jsonParse.mjs +11 -0
- package/lib/core/utils/internal/jsonParse.mjs.map +1 -0
- package/lib/core/utils/internal/mergeRight.d.mts +7 -0
- package/lib/core/utils/internal/mergeRight.d.ts +7 -0
- package/lib/core/utils/internal/mergeRight.js +43 -0
- package/lib/core/utils/internal/mergeRight.js.map +1 -0
- package/lib/core/utils/internal/mergeRight.mjs +23 -0
- package/lib/core/utils/internal/mergeRight.mjs.map +1 -0
- package/lib/core/utils/internal/parseGraphQLRequest.d.mts +6 -0
- package/lib/core/utils/internal/parseGraphQLRequest.d.ts +6 -0
- package/lib/core/utils/internal/parseGraphQLRequest.js +146 -0
- package/lib/core/utils/internal/parseGraphQLRequest.js.map +1 -0
- package/lib/core/utils/internal/parseGraphQLRequest.mjs +129 -0
- package/lib/core/utils/internal/parseGraphQLRequest.mjs.map +1 -0
- package/lib/core/utils/internal/parseMultipartData.d.mts +14 -0
- package/lib/core/utils/internal/parseMultipartData.d.ts +14 -0
- package/lib/core/utils/internal/parseMultipartData.js +83 -0
- package/lib/core/utils/internal/parseMultipartData.js.map +1 -0
- package/lib/core/utils/internal/parseMultipartData.mjs +63 -0
- package/lib/core/utils/internal/parseMultipartData.mjs.map +1 -0
- package/lib/core/utils/internal/pipeEvents.d.mts +8 -0
- package/lib/core/utils/internal/pipeEvents.d.ts +8 -0
- package/lib/core/utils/internal/pipeEvents.js +36 -0
- package/lib/core/utils/internal/pipeEvents.js.map +1 -0
- package/lib/core/utils/internal/pipeEvents.mjs +16 -0
- package/lib/core/utils/internal/pipeEvents.mjs.map +1 -0
- package/lib/core/utils/internal/requestHandlerUtils.d.mts +12 -0
- package/lib/core/utils/internal/requestHandlerUtils.d.ts +12 -0
- package/lib/core/utils/internal/requestHandlerUtils.js +37 -0
- package/lib/core/utils/internal/requestHandlerUtils.js.map +1 -0
- package/lib/core/utils/internal/requestHandlerUtils.mjs +17 -0
- package/lib/core/utils/internal/requestHandlerUtils.mjs.map +1 -0
- package/lib/core/utils/internal/toReadonlyArray.d.mts +6 -0
- package/lib/core/utils/internal/toReadonlyArray.d.ts +6 -0
- package/lib/core/utils/internal/toReadonlyArray.js +29 -0
- package/lib/core/utils/internal/toReadonlyArray.js.map +1 -0
- package/lib/core/utils/internal/toReadonlyArray.mjs +9 -0
- package/lib/core/utils/internal/toReadonlyArray.mjs.map +1 -0
- package/lib/core/utils/internal/tryCatch.d.mts +3 -0
- package/lib/core/utils/internal/tryCatch.d.ts +3 -0
- package/lib/core/utils/internal/tryCatch.js +32 -0
- package/lib/core/utils/internal/tryCatch.js.map +1 -0
- package/lib/core/utils/internal/tryCatch.mjs +12 -0
- package/lib/core/utils/internal/tryCatch.mjs.map +1 -0
- package/lib/core/utils/logging/getStatusCodeColor.d.mts +11 -0
- package/lib/core/utils/logging/getStatusCodeColor.d.ts +11 -0
- package/lib/core/utils/logging/getStatusCodeColor.js +40 -0
- package/lib/core/utils/logging/getStatusCodeColor.js.map +1 -0
- package/lib/core/utils/logging/getStatusCodeColor.mjs +20 -0
- package/lib/core/utils/logging/getStatusCodeColor.mjs.map +1 -0
- package/lib/core/utils/logging/getTimestamp.d.mts +9 -0
- package/lib/core/utils/logging/getTimestamp.d.ts +9 -0
- package/lib/core/utils/logging/getTimestamp.js +32 -0
- package/lib/core/utils/logging/getTimestamp.js.map +1 -0
- package/lib/core/utils/logging/getTimestamp.mjs +12 -0
- package/lib/core/utils/logging/getTimestamp.mjs.map +1 -0
- package/lib/core/utils/logging/serializeRequest.d.mts +12 -0
- package/lib/core/utils/logging/serializeRequest.d.ts +12 -0
- package/lib/core/utils/logging/serializeRequest.js +34 -0
- package/lib/core/utils/logging/serializeRequest.js.map +1 -0
- package/lib/core/utils/logging/serializeRequest.mjs +14 -0
- package/lib/core/utils/logging/serializeRequest.mjs.map +1 -0
- package/lib/core/utils/logging/serializeResponse.d.mts +9 -0
- package/lib/core/utils/logging/serializeResponse.d.ts +9 -0
- package/lib/core/utils/logging/serializeResponse.js +48 -0
- package/lib/core/utils/logging/serializeResponse.js.map +1 -0
- package/lib/core/utils/logging/serializeResponse.mjs +18 -0
- package/lib/core/utils/logging/serializeResponse.mjs.map +1 -0
- package/lib/core/utils/matching/matchRequestUrl.d.mts +20 -0
- package/lib/core/utils/matching/matchRequestUrl.d.ts +20 -0
- package/lib/core/utils/matching/matchRequestUrl.js +55 -0
- package/lib/core/utils/matching/matchRequestUrl.js.map +1 -0
- package/lib/core/utils/matching/matchRequestUrl.mjs +35 -0
- package/lib/core/utils/matching/matchRequestUrl.mjs.map +1 -0
- package/lib/core/utils/matching/normalizePath.d.mts +13 -0
- package/lib/core/utils/matching/normalizePath.d.ts +13 -0
- package/lib/core/utils/matching/normalizePath.js +33 -0
- package/lib/core/utils/matching/normalizePath.js.map +1 -0
- package/lib/core/utils/matching/normalizePath.mjs +13 -0
- package/lib/core/utils/matching/normalizePath.mjs.map +1 -0
- package/lib/core/utils/request/getAllAcceptedMimeTypes.d.mts +14 -0
- package/lib/core/utils/request/getAllAcceptedMimeTypes.d.ts +14 -0
- package/lib/core/utils/request/getAllAcceptedMimeTypes.js +61 -0
- package/lib/core/utils/request/getAllAcceptedMimeTypes.js.map +1 -0
- package/lib/core/utils/request/getAllAcceptedMimeTypes.mjs +41 -0
- package/lib/core/utils/request/getAllAcceptedMimeTypes.mjs.map +1 -0
- package/lib/core/utils/request/getRequestCookies.d.mts +3 -0
- package/lib/core/utils/request/getRequestCookies.d.ts +3 -0
- package/lib/core/utils/request/getRequestCookies.js +79 -0
- package/lib/core/utils/request/getRequestCookies.js.map +1 -0
- package/lib/core/utils/request/getRequestCookies.mjs +62 -0
- package/lib/core/utils/request/getRequestCookies.mjs.map +1 -0
- package/lib/core/utils/request/onUnhandledRequest.d.mts +9 -0
- package/lib/core/utils/request/onUnhandledRequest.d.ts +9 -0
- package/lib/core/utils/request/onUnhandledRequest.js +76 -0
- package/lib/core/utils/request/onUnhandledRequest.js.map +1 -0
- package/lib/core/utils/request/onUnhandledRequest.mjs +56 -0
- package/lib/core/utils/request/onUnhandledRequest.mjs.map +1 -0
- package/lib/core/utils/request/storeResponseCookies.d.mts +3 -0
- package/lib/core/utils/request/storeResponseCookies.d.ts +3 -0
- package/lib/core/utils/request/storeResponseCookies.js +32 -0
- package/lib/core/utils/request/storeResponseCookies.js.map +1 -0
- package/lib/core/utils/request/storeResponseCookies.mjs +12 -0
- package/lib/core/utils/request/storeResponseCookies.mjs.map +1 -0
- package/lib/core/utils/request/toPublicUrl.d.mts +7 -0
- package/lib/core/utils/request/toPublicUrl.d.ts +7 -0
- package/lib/core/utils/request/toPublicUrl.js +31 -0
- package/lib/core/utils/request/toPublicUrl.js.map +1 -0
- package/lib/core/utils/request/toPublicUrl.mjs +11 -0
- package/lib/core/utils/request/toPublicUrl.mjs.map +1 -0
- package/lib/core/utils/toResponseInit.d.mts +3 -0
- package/lib/core/utils/toResponseInit.d.ts +3 -0
- package/lib/core/utils/toResponseInit.js +31 -0
- package/lib/core/utils/toResponseInit.js.map +1 -0
- package/lib/core/utils/toResponseInit.mjs +11 -0
- package/lib/core/utils/toResponseInit.mjs.map +1 -0
- package/lib/core/utils/url/cleanUrl.d.mts +7 -0
- package/lib/core/utils/url/cleanUrl.d.ts +7 -0
- package/lib/core/utils/url/cleanUrl.js +31 -0
- package/lib/core/utils/url/cleanUrl.js.map +1 -0
- package/lib/core/utils/url/cleanUrl.mjs +11 -0
- package/lib/core/utils/url/cleanUrl.mjs.map +1 -0
- package/lib/core/utils/url/getAbsoluteUrl.d.mts +6 -0
- package/lib/core/utils/url/getAbsoluteUrl.d.ts +6 -0
- package/lib/core/utils/url/getAbsoluteUrl.js +38 -0
- package/lib/core/utils/url/getAbsoluteUrl.js.map +1 -0
- package/lib/core/utils/url/getAbsoluteUrl.mjs +18 -0
- package/lib/core/utils/url/getAbsoluteUrl.mjs.map +1 -0
- package/lib/core/utils/url/isAbsoluteUrl.d.mts +6 -0
- package/lib/core/utils/url/isAbsoluteUrl.d.ts +6 -0
- package/lib/core/utils/url/isAbsoluteUrl.js +27 -0
- package/lib/core/utils/url/isAbsoluteUrl.js.map +1 -0
- package/lib/core/utils/url/isAbsoluteUrl.mjs +7 -0
- package/lib/core/utils/url/isAbsoluteUrl.mjs.map +1 -0
- package/lib/core/ws/WebSocketClientManager.d.mts +65 -0
- package/lib/core/ws/WebSocketClientManager.d.ts +65 -0
- package/lib/core/ws/WebSocketClientManager.js +159 -0
- package/lib/core/ws/WebSocketClientManager.js.map +1 -0
- package/lib/core/ws/WebSocketClientManager.mjs +139 -0
- package/lib/core/ws/WebSocketClientManager.mjs.map +1 -0
- package/lib/core/ws/WebSocketClientStore.d.mts +13 -0
- package/lib/core/ws/WebSocketClientStore.d.ts +13 -0
- package/lib/core/ws/WebSocketClientStore.js +26 -0
- package/lib/core/ws/WebSocketClientStore.js.map +1 -0
- package/lib/core/ws/WebSocketClientStore.mjs +6 -0
- package/lib/core/ws/WebSocketClientStore.mjs.map +1 -0
- package/lib/core/ws/WebSocketIndexedDBClientStore.d.mts +14 -0
- package/lib/core/ws/WebSocketIndexedDBClientStore.d.ts +14 -0
- package/lib/core/ws/WebSocketIndexedDBClientStore.js +130 -0
- package/lib/core/ws/WebSocketIndexedDBClientStore.js.map +1 -0
- package/lib/core/ws/WebSocketIndexedDBClientStore.mjs +110 -0
- package/lib/core/ws/WebSocketIndexedDBClientStore.mjs.map +1 -0
- package/lib/core/ws/WebSocketMemoryClientStore.d.mts +12 -0
- package/lib/core/ws/WebSocketMemoryClientStore.d.ts +12 -0
- package/lib/core/ws/WebSocketMemoryClientStore.js +41 -0
- package/lib/core/ws/WebSocketMemoryClientStore.js.map +1 -0
- package/lib/core/ws/WebSocketMemoryClientStore.mjs +21 -0
- package/lib/core/ws/WebSocketMemoryClientStore.mjs.map +1 -0
- package/lib/core/ws/handleWebSocketEvent.d.mts +20 -0
- package/lib/core/ws/handleWebSocketEvent.d.ts +20 -0
- package/lib/core/ws/handleWebSocketEvent.js +61 -0
- package/lib/core/ws/handleWebSocketEvent.js.map +1 -0
- package/lib/core/ws/handleWebSocketEvent.mjs +43 -0
- package/lib/core/ws/handleWebSocketEvent.mjs.map +1 -0
- package/lib/core/ws/utils/attachWebSocketLogger.d.mts +18 -0
- package/lib/core/ws/utils/attachWebSocketLogger.d.ts +18 -0
- package/lib/core/ws/utils/attachWebSocketLogger.js +199 -0
- package/lib/core/ws/utils/attachWebSocketLogger.js.map +1 -0
- package/lib/core/ws/utils/attachWebSocketLogger.mjs +179 -0
- package/lib/core/ws/utils/attachWebSocketLogger.mjs.map +1 -0
- package/lib/core/ws/utils/getMessageLength.d.mts +11 -0
- package/lib/core/ws/utils/getMessageLength.d.ts +11 -0
- package/lib/core/ws/utils/getMessageLength.js +34 -0
- package/lib/core/ws/utils/getMessageLength.js.map +1 -0
- package/lib/core/ws/utils/getMessageLength.mjs +14 -0
- package/lib/core/ws/utils/getMessageLength.mjs.map +1 -0
- package/lib/core/ws/utils/getPublicData.d.mts +5 -0
- package/lib/core/ws/utils/getPublicData.d.ts +5 -0
- package/lib/core/ws/utils/getPublicData.js +37 -0
- package/lib/core/ws/utils/getPublicData.js.map +1 -0
- package/lib/core/ws/utils/getPublicData.mjs +17 -0
- package/lib/core/ws/utils/getPublicData.mjs.map +1 -0
- package/lib/core/ws/utils/truncateMessage.d.mts +3 -0
- package/lib/core/ws/utils/truncateMessage.d.ts +3 -0
- package/lib/core/ws/utils/truncateMessage.js +31 -0
- package/lib/core/ws/utils/truncateMessage.js.map +1 -0
- package/lib/core/ws/utils/truncateMessage.mjs +11 -0
- package/lib/core/ws/utils/truncateMessage.mjs.map +1 -0
- package/lib/core/ws/webSocketInterceptor.d.mts +5 -0
- package/lib/core/ws/webSocketInterceptor.d.ts +5 -0
- package/lib/core/ws/webSocketInterceptor.js +26 -0
- package/lib/core/ws/webSocketInterceptor.js.map +1 -0
- package/lib/core/ws/webSocketInterceptor.mjs +6 -0
- package/lib/core/ws/webSocketInterceptor.mjs.map +1 -0
- package/lib/core/ws.d.mts +75 -0
- package/lib/core/ws.d.ts +75 -0
- package/lib/core/ws.js +69 -0
- package/lib/core/ws.js.map +1 -0
- package/lib/core/ws.mjs +52 -0
- package/lib/core/ws.mjs.map +1 -0
- package/lib/iife/index.js +23752 -0
- package/lib/iife/index.js.map +1 -0
- package/lib/mockServiceWorker.js +349 -0
- package/lib/native/index.d.mts +74 -0
- package/lib/native/index.d.ts +74 -0
- package/lib/native/index.js +156 -0
- package/lib/native/index.js.map +1 -0
- package/lib/native/index.mjs +134 -0
- package/lib/native/index.mjs.map +1 -0
- package/lib/node/index.d.mts +91 -0
- package/lib/node/index.d.ts +91 -0
- package/lib/node/index.js +209 -0
- package/lib/node/index.js.map +1 -0
- package/lib/node/index.mjs +184 -0
- package/lib/node/index.mjs.map +1 -0
- package/lib/shims/cookie.d.mts +7 -0
- package/lib/shims/cookie.d.ts +7 -0
- package/lib/shims/cookie.js +204 -0
- package/lib/shims/cookie.mjs +196 -0
- package/lib/shims/statuses.d.mts +6 -0
- package/lib/shims/statuses.d.ts +6 -0
- package/lib/shims/statuses.js +195 -0
- package/lib/shims/statuses.mjs +187 -0
- package/native/package.json +30 -0
- package/node/package.json +33 -0
- package/package.json +381 -0
- package/src/browser/global.browser.d.ts +1 -0
- package/src/browser/index.ts +3 -0
- package/src/browser/setupWorker/glossary.ts +138 -0
- package/src/browser/setupWorker/setupWorker.node.test.ts +10 -0
- package/src/browser/setupWorker/setupWorker.ts +184 -0
- package/src/browser/setupWorker/start/createFallbackRequestListener.ts +71 -0
- package/src/browser/setupWorker/start/createRequestListener.ts +138 -0
- package/src/browser/setupWorker/start/createResponseListener.ts +57 -0
- package/src/browser/setupWorker/start/createStartHandler.ts +137 -0
- package/src/browser/setupWorker/start/utils/enableMocking.ts +30 -0
- package/src/browser/setupWorker/start/utils/getWorkerByRegistration.ts +25 -0
- package/src/browser/setupWorker/start/utils/getWorkerInstance.ts +97 -0
- package/src/browser/setupWorker/start/utils/prepareStartHandler.test.ts +59 -0
- package/src/browser/setupWorker/start/utils/prepareStartHandler.ts +44 -0
- package/src/browser/setupWorker/start/utils/printStartMessage.test.ts +84 -0
- package/src/browser/setupWorker/start/utils/printStartMessage.ts +51 -0
- package/src/browser/setupWorker/start/utils/validateWorkerScope.ts +18 -0
- package/src/browser/setupWorker/stop/utils/printStopMessage.test.ts +26 -0
- package/src/browser/setupWorker/stop/utils/printStopMessage.ts +13 -0
- package/src/browser/tsconfig.browser.build.json +6 -0
- package/src/browser/tsconfig.browser.json +9 -0
- package/src/browser/utils/checkWorkerIntegrity.ts +42 -0
- package/src/browser/utils/deserializeRequest.ts +15 -0
- package/src/browser/utils/getAbsoluteWorkerUrl.test.ts +29 -0
- package/src/browser/utils/getAbsoluteWorkerUrl.ts +7 -0
- package/src/browser/utils/pruneGetRequestBody.test.ts +53 -0
- package/src/browser/utils/pruneGetRequestBody.ts +21 -0
- package/src/browser/utils/supports.ts +30 -0
- package/src/browser/utils/workerChannel.ts +159 -0
- package/src/core/HttpResponse.test.ts +378 -0
- package/src/core/HttpResponse.ts +248 -0
- package/src/core/SetupApi.ts +127 -0
- package/src/core/bypass.test.ts +80 -0
- package/src/core/bypass.ts +46 -0
- package/src/core/delay.ts +82 -0
- package/src/core/getResponse.test.ts +74 -0
- package/src/core/getResponse.ts +29 -0
- package/src/core/graphql.test.ts +11 -0
- package/src/core/graphql.ts +136 -0
- package/src/core/handlers/GraphQLHandler.test.ts +873 -0
- package/src/core/handlers/GraphQLHandler.ts +437 -0
- package/src/core/handlers/HttpHandler.test.ts +253 -0
- package/src/core/handlers/HttpHandler.ts +214 -0
- package/src/core/handlers/RequestHandler.ts +391 -0
- package/src/core/handlers/WebSocketHandler.test.ts +127 -0
- package/src/core/handlers/WebSocketHandler.ts +209 -0
- package/src/core/handlers/common.ts +1 -0
- package/src/core/http.test.ts +15 -0
- package/src/core/http.ts +64 -0
- package/src/core/index.ts +110 -0
- package/src/core/isCommonAssetRequest.ts +45 -0
- package/src/core/passthrough.test.ts +11 -0
- package/src/core/passthrough.ts +25 -0
- package/src/core/sharedOptions.ts +66 -0
- package/src/core/sse.ts +916 -0
- package/src/core/typeUtils.ts +26 -0
- package/src/core/utils/HttpResponse/decorators.ts +76 -0
- package/src/core/utils/cookieStore.ts +94 -0
- package/src/core/utils/executeHandlers.ts +69 -0
- package/src/core/utils/handleRequest.test.ts +573 -0
- package/src/core/utils/handleRequest.ts +117 -0
- package/src/core/utils/internal/Disposable.ts +12 -0
- package/src/core/utils/internal/checkGlobals.ts +17 -0
- package/src/core/utils/internal/devUtils.test.ts +21 -0
- package/src/core/utils/internal/devUtils.ts +44 -0
- package/src/core/utils/internal/getCallFrame.test.ts +154 -0
- package/src/core/utils/internal/getCallFrame.ts +35 -0
- package/src/core/utils/internal/hasRefCounted.test.ts +16 -0
- package/src/core/utils/internal/hasRefCounted.ts +8 -0
- package/src/core/utils/internal/isHandlerKind.test.ts +64 -0
- package/src/core/utils/internal/isHandlerKind.ts +21 -0
- package/src/core/utils/internal/isIterable.test.ts +23 -0
- package/src/core/utils/internal/isIterable.ts +32 -0
- package/src/core/utils/internal/isObject.test.ts +20 -0
- package/src/core/utils/internal/isObject.ts +6 -0
- package/src/core/utils/internal/isStringEqual.test.ts +45 -0
- package/src/core/utils/internal/isStringEqual.ts +6 -0
- package/src/core/utils/internal/jsonParse.test.ts +13 -0
- package/src/core/utils/internal/jsonParse.ts +13 -0
- package/src/core/utils/internal/mergeRight.test.ts +43 -0
- package/src/core/utils/internal/mergeRight.ts +30 -0
- package/src/core/utils/internal/parseGraphQLRequest.test.ts +99 -0
- package/src/core/utils/internal/parseGraphQLRequest.ts +214 -0
- package/src/core/utils/internal/parseMultipartData.test.ts +76 -0
- package/src/core/utils/internal/parseMultipartData.ts +106 -0
- package/src/core/utils/internal/pipeEvents.test.ts +14 -0
- package/src/core/utils/internal/pipeEvents.ts +25 -0
- package/src/core/utils/internal/requestHandlerUtils.ts +21 -0
- package/src/core/utils/internal/toReadonlyArray.test.ts +30 -0
- package/src/core/utils/internal/toReadonlyArray.ts +8 -0
- package/src/core/utils/internal/tryCatch.test.ts +29 -0
- package/src/core/utils/internal/tryCatch.ts +11 -0
- package/src/core/utils/logging/getStatusCodeColor.test.ts +22 -0
- package/src/core/utils/logging/getStatusCodeColor.ts +20 -0
- package/src/core/utils/logging/getTimestamp.test.ts +32 -0
- package/src/core/utils/logging/getTimestamp.ts +17 -0
- package/src/core/utils/logging/serializeRequest.test.ts +23 -0
- package/src/core/utils/logging/serializeRequest.ts +23 -0
- package/src/core/utils/logging/serializeResponse.test.ts +77 -0
- package/src/core/utils/logging/serializeResponse.ts +31 -0
- package/src/core/utils/matching/matchRequestUrl.test.ts +183 -0
- package/src/core/utils/matching/matchRequestUrl.ts +77 -0
- package/src/core/utils/matching/normalizePath.node.test.ts +44 -0
- package/src/core/utils/matching/normalizePath.test.ts +56 -0
- package/src/core/utils/matching/normalizePath.ts +22 -0
- package/src/core/utils/request/getAllAcceptedMimeTypes.test.ts +86 -0
- package/src/core/utils/request/getAllAcceptedMimeTypes.ts +70 -0
- package/src/core/utils/request/getRequestCookies.ts +88 -0
- package/src/core/utils/request/onUnhandledRequest.node.test.ts +62 -0
- package/src/core/utils/request/onUnhandledRequest.test.ts +228 -0
- package/src/core/utils/request/onUnhandledRequest.ts +81 -0
- package/src/core/utils/request/storeResponseCookies.ts +17 -0
- package/src/core/utils/request/toPublicUrl.node.test.ts +17 -0
- package/src/core/utils/request/toPublicUrl.test.ts +16 -0
- package/src/core/utils/request/toPublicUrl.ts +16 -0
- package/src/core/utils/toResponseInit.ts +7 -0
- package/src/core/utils/url/cleanUrl.test.ts +22 -0
- package/src/core/utils/url/cleanUrl.ts +16 -0
- package/src/core/utils/url/getAbsoluteUrl.node.test.ts +19 -0
- package/src/core/utils/url/getAbsoluteUrl.test.ts +47 -0
- package/src/core/utils/url/getAbsoluteUrl.ts +25 -0
- package/src/core/utils/url/isAbsoluteUrl.test.ts +32 -0
- package/src/core/utils/url/isAbsoluteUrl.ts +6 -0
- package/src/core/ws/WebSocketClientManager.test.ts +164 -0
- package/src/core/ws/WebSocketClientManager.ts +241 -0
- package/src/core/ws/WebSocketClientStore.ts +14 -0
- package/src/core/ws/WebSocketIndexedDBClientStore.ts +140 -0
- package/src/core/ws/WebSocketMemoryClientStore.ts +27 -0
- package/src/core/ws/handleWebSocketEvent.ts +64 -0
- package/src/core/ws/utils/attachWebSocketLogger.ts +245 -0
- package/src/core/ws/utils/getMessageLength.test.ts +16 -0
- package/src/core/ws/utils/getMessageLength.ts +20 -0
- package/src/core/ws/utils/getPublicData.test.ts +38 -0
- package/src/core/ws/utils/getPublicData.ts +18 -0
- package/src/core/ws/utils/truncateMessage.test.ts +12 -0
- package/src/core/ws/utils/truncateMessage.ts +9 -0
- package/src/core/ws/webSocketInterceptor.ts +3 -0
- package/src/core/ws.test.ts +23 -0
- package/src/core/ws.ts +161 -0
- package/src/iife/index.ts +2 -0
- package/src/mockServiceWorker.js +349 -0
- package/src/native/index.ts +21 -0
- package/src/node/SetupServerApi.ts +87 -0
- package/src/node/SetupServerCommonApi.ts +169 -0
- package/src/node/glossary.ts +74 -0
- package/src/node/index.ts +3 -0
- package/src/node/setupServer.ts +15 -0
- package/src/package.json +3 -0
- package/src/shims/cookie.ts +7 -0
- package/src/shims/statuses.ts +6 -0
- package/src/tsconfig.core.build.json +6 -0
- package/src/tsconfig.node.build.json +6 -0
- package/src/tsconfig.node.json +8 -0
- package/src/tsconfig.src.json +10 -0
- package/src/tsconfig.worker.json +13 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2018–present Artem Zakharchenko
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# @depup/msw
|
|
2
|
+
|
|
3
|
+
> Dependency-bumped version of [msw](https://www.npmjs.com/package/msw)
|
|
4
|
+
|
|
5
|
+
Generated by [DepUp](https://github.com/depup/npm) -- all production
|
|
6
|
+
dependencies bumped to latest versions.
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install @depup/msw
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
| Field | Value |
|
|
15
|
+
|-------|-------|
|
|
16
|
+
| Original | [msw](https://www.npmjs.com/package/msw) @ 2.12.13 |
|
|
17
|
+
| Processed | 2026-03-17 |
|
|
18
|
+
| Smoke test | passed |
|
|
19
|
+
| Deps updated | 10 |
|
|
20
|
+
|
|
21
|
+
## Dependency Changes
|
|
22
|
+
|
|
23
|
+
| Dependency | From | To |
|
|
24
|
+
|------------|------|-----|
|
|
25
|
+
| @inquirer/confirm | ^5.0.0 | ^6.0.10 |
|
|
26
|
+
| @mswjs/interceptors | ^0.41.2 | ^0.41.3 |
|
|
27
|
+
| cookie | ^1.0.2 | ^1.1.1 |
|
|
28
|
+
| graphql | ^16.12.0 | ^16.13.1 |
|
|
29
|
+
| headers-polyfill | ^4.0.2 | ^5.0.1 |
|
|
30
|
+
| path-to-regexp | ^6.3.0 | ^8.3.0 |
|
|
31
|
+
| rettime | ^0.10.1 | ^0.11.7 |
|
|
32
|
+
| tough-cookie | ^6.0.0 | ^6.0.1 |
|
|
33
|
+
| type-fest | ^5.2.0 | ^5.4.4 |
|
|
34
|
+
| yargs | ^17.7.2 | ^18.0.0 |
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
Source: https://github.com/depup/npm | Original: https://www.npmjs.com/package/msw
|
|
39
|
+
|
|
40
|
+
License inherited from the original package.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"type": "module",
|
|
3
|
+
"main": "../lib/browser/index.js",
|
|
4
|
+
"module": "../lib/browser/index.mjs",
|
|
5
|
+
"types": "../lib/browser/index.d.ts",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"module-sync": {
|
|
9
|
+
"types": "./../lib/browser/index.d.mts",
|
|
10
|
+
"default": "./../lib/browser/index.mjs"
|
|
11
|
+
},
|
|
12
|
+
"module": {
|
|
13
|
+
"types": "./../lib/browser/index.d.mts",
|
|
14
|
+
"default": "./../lib/browser/index.mjs"
|
|
15
|
+
},
|
|
16
|
+
"browser": {
|
|
17
|
+
"types": "./../lib/browser/index.d.mts",
|
|
18
|
+
"default": "./../lib/browser/index.mjs"
|
|
19
|
+
},
|
|
20
|
+
"import": {
|
|
21
|
+
"types": "./../lib/browser/index.d.mts",
|
|
22
|
+
"default": "./../lib/browser/index.mjs"
|
|
23
|
+
},
|
|
24
|
+
"default": {
|
|
25
|
+
"types": "./../lib/browser/index.d.ts",
|
|
26
|
+
"default": "./../lib/browser/index.js"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"./package.json": "./package.json"
|
|
30
|
+
}
|
|
31
|
+
}
|
package/changes.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"bumped": {
|
|
3
|
+
"@inquirer/confirm": {
|
|
4
|
+
"from": "^5.0.0",
|
|
5
|
+
"to": "^6.0.10"
|
|
6
|
+
},
|
|
7
|
+
"@mswjs/interceptors": {
|
|
8
|
+
"from": "^0.41.2",
|
|
9
|
+
"to": "^0.41.3"
|
|
10
|
+
},
|
|
11
|
+
"cookie": {
|
|
12
|
+
"from": "^1.0.2",
|
|
13
|
+
"to": "^1.1.1"
|
|
14
|
+
},
|
|
15
|
+
"graphql": {
|
|
16
|
+
"from": "^16.12.0",
|
|
17
|
+
"to": "^16.13.1"
|
|
18
|
+
},
|
|
19
|
+
"headers-polyfill": {
|
|
20
|
+
"from": "^4.0.2",
|
|
21
|
+
"to": "^5.0.1"
|
|
22
|
+
},
|
|
23
|
+
"path-to-regexp": {
|
|
24
|
+
"from": "^6.3.0",
|
|
25
|
+
"to": "^8.3.0"
|
|
26
|
+
},
|
|
27
|
+
"rettime": {
|
|
28
|
+
"from": "^0.10.1",
|
|
29
|
+
"to": "^0.11.7"
|
|
30
|
+
},
|
|
31
|
+
"tough-cookie": {
|
|
32
|
+
"from": "^6.0.0",
|
|
33
|
+
"to": "^6.0.1"
|
|
34
|
+
},
|
|
35
|
+
"type-fest": {
|
|
36
|
+
"from": "^5.2.0",
|
|
37
|
+
"to": "^5.4.4"
|
|
38
|
+
},
|
|
39
|
+
"yargs": {
|
|
40
|
+
"from": "^17.7.2",
|
|
41
|
+
"to": "^18.0.0"
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"timestamp": "2026-03-17T16:37:44.061Z",
|
|
45
|
+
"totalUpdated": 10
|
|
46
|
+
}
|
package/cli/index.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import yargs from 'yargs'
|
|
3
|
+
import { init } from './init.js'
|
|
4
|
+
|
|
5
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
6
|
+
yargs(process.argv.slice(2))
|
|
7
|
+
.usage('$0 <cmd> [args]')
|
|
8
|
+
.command(
|
|
9
|
+
'init',
|
|
10
|
+
'Initializes Mock Service Worker at the specified directory',
|
|
11
|
+
(yargs) => {
|
|
12
|
+
yargs
|
|
13
|
+
.positional('publicDir', {
|
|
14
|
+
type: 'string',
|
|
15
|
+
description: 'Relative path to the public directory',
|
|
16
|
+
demandOption: false,
|
|
17
|
+
normalize: true,
|
|
18
|
+
})
|
|
19
|
+
.option('save', {
|
|
20
|
+
type: 'boolean',
|
|
21
|
+
description: 'Save the worker directory in your package.json',
|
|
22
|
+
})
|
|
23
|
+
.option('cwd', {
|
|
24
|
+
type: 'string',
|
|
25
|
+
description: 'Custom current worker directory',
|
|
26
|
+
normalize: true,
|
|
27
|
+
})
|
|
28
|
+
.example('msw init')
|
|
29
|
+
.example('msw init ./public')
|
|
30
|
+
.example('msw init ./static --save')
|
|
31
|
+
},
|
|
32
|
+
init,
|
|
33
|
+
)
|
|
34
|
+
.demandCommand()
|
|
35
|
+
.help().argv
|
package/cli/init.js
ADDED
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import fs from 'node:fs'
|
|
2
|
+
import path from 'node:path'
|
|
3
|
+
import colors from 'picocolors'
|
|
4
|
+
import confirm from '@inquirer/confirm'
|
|
5
|
+
import { invariant } from './invariant.js'
|
|
6
|
+
import { SERVICE_WORKER_BUILD_PATH } from '../config/constants.js'
|
|
7
|
+
|
|
8
|
+
export async function init(args) {
|
|
9
|
+
const CWD = args.cwd || process.cwd()
|
|
10
|
+
const publicDir = args._[1] ? normalizePath(args._[1]) : undefined
|
|
11
|
+
|
|
12
|
+
const packageJsonPath = path.resolve(CWD, 'package.json')
|
|
13
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'))
|
|
14
|
+
const savedWorkerDirectories = Array.prototype
|
|
15
|
+
.concat((packageJson.msw && packageJson.msw.workerDirectory) || [])
|
|
16
|
+
.map(normalizePath)
|
|
17
|
+
|
|
18
|
+
if (publicDir) {
|
|
19
|
+
// If the public directory was provided, copy the worker script
|
|
20
|
+
// to that directory only. Even if there are paths stored in "msw.workerDirectory",
|
|
21
|
+
// those will not be touched.
|
|
22
|
+
await copyWorkerScript(publicDir, CWD)
|
|
23
|
+
const relativePublicDir = path.relative(CWD, publicDir)
|
|
24
|
+
printSuccessMessage([publicDir])
|
|
25
|
+
|
|
26
|
+
if (args.save) {
|
|
27
|
+
// Only save the public path if it's not already saved in "package.json".
|
|
28
|
+
if (!savedWorkerDirectories.includes(relativePublicDir)) {
|
|
29
|
+
saveWorkerDirectory(packageJsonPath, relativePublicDir)
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
// Explicitly check if "save" was not provided (was null).
|
|
33
|
+
// You can also provide the "--no-save" option, and then "args.save"
|
|
34
|
+
// will equal to false.
|
|
35
|
+
else if (args.save == null) {
|
|
36
|
+
// eslint-disable-next-line no-console
|
|
37
|
+
console.log(`\
|
|
38
|
+
${colors.cyan(
|
|
39
|
+
'INFO',
|
|
40
|
+
)} In order to ease the future updates to the worker script,
|
|
41
|
+
we recommend saving the path to the worker directory in your package.json.`)
|
|
42
|
+
|
|
43
|
+
// If the "--save" flag was not provided, prompt to save
|
|
44
|
+
// the public path.
|
|
45
|
+
promptWorkerDirectoryUpdate(
|
|
46
|
+
`Do you wish to save "${relativePublicDir}" as the worker directory?`,
|
|
47
|
+
packageJsonPath,
|
|
48
|
+
relativePublicDir,
|
|
49
|
+
)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Calling "init" without a public directory but with the "--save" flag is a no-op.
|
|
56
|
+
invariant(
|
|
57
|
+
args.save == null,
|
|
58
|
+
'Failed to copy the worker script: cannot call the "init" command without a public directory but with the "--save" flag. Either drop the "--save" flag to copy the worker script to all paths listed in "msw.workerDirectory", or add an explicit public directory to the command, like "npx msw init ./public".',
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
// If the public directory was not provided, check any existing
|
|
62
|
+
// paths in "msw.workerDirectory". When called without the public
|
|
63
|
+
// directory, the "init" command must copy the worker script
|
|
64
|
+
// to all the paths stored in "msw.workerDirectory".
|
|
65
|
+
if (savedWorkerDirectories.length > 0) {
|
|
66
|
+
const copyResults = await Promise.allSettled(
|
|
67
|
+
savedWorkerDirectories.map((destination) => {
|
|
68
|
+
return copyWorkerScript(destination, CWD).catch((error) => {
|
|
69
|
+
// Inject the absolute destination path onto the copy function rejections
|
|
70
|
+
// so it's available in the failed paths array below.
|
|
71
|
+
throw [toAbsolutePath(destination, CWD), error]
|
|
72
|
+
})
|
|
73
|
+
}),
|
|
74
|
+
)
|
|
75
|
+
const successfulPaths = copyResults
|
|
76
|
+
.filter((result) => result.status === 'fulfilled')
|
|
77
|
+
.map((result) => result.value)
|
|
78
|
+
const failedPathsWithErrors = copyResults
|
|
79
|
+
.filter((result) => result.status === 'rejected')
|
|
80
|
+
.map((result) => result.reason)
|
|
81
|
+
|
|
82
|
+
// Notify about failed copies, if any.
|
|
83
|
+
if (failedPathsWithErrors.length > 0) {
|
|
84
|
+
printFailureMessage(failedPathsWithErrors)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Notify about successful copies, if any.
|
|
88
|
+
if (successfulPaths.length > 0) {
|
|
89
|
+
printSuccessMessage(successfulPaths)
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* @param {string} maybeAbsolutePath
|
|
96
|
+
* @param {string} cwd
|
|
97
|
+
* @returns {string}
|
|
98
|
+
*/
|
|
99
|
+
function toAbsolutePath(maybeAbsolutePath, cwd) {
|
|
100
|
+
return path.isAbsolute(maybeAbsolutePath)
|
|
101
|
+
? maybeAbsolutePath
|
|
102
|
+
: path.resolve(cwd, maybeAbsolutePath)
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* @param {string} destination
|
|
107
|
+
* @param {string} cwd
|
|
108
|
+
* @returns {Promise<string>}
|
|
109
|
+
*/
|
|
110
|
+
async function copyWorkerScript(destination, cwd) {
|
|
111
|
+
// When running as a part of "postinstall" script, "cwd" equals the library's directory.
|
|
112
|
+
// The "postinstall" script resolves the right absolute public directory path.
|
|
113
|
+
const absolutePublicDir = toAbsolutePath(destination, cwd)
|
|
114
|
+
|
|
115
|
+
if (!fs.existsSync(absolutePublicDir)) {
|
|
116
|
+
await fs.promises
|
|
117
|
+
.mkdir(absolutePublicDir, { recursive: true })
|
|
118
|
+
.catch((error) => {
|
|
119
|
+
throw new Error(
|
|
120
|
+
invariant(
|
|
121
|
+
false,
|
|
122
|
+
'Failed to copy the worker script at "%s": directory does not exist and could not be created.\nMake sure to include a relative path to the public directory of your application.\n\nSee the original error below:\n\n%s',
|
|
123
|
+
absolutePublicDir,
|
|
124
|
+
error,
|
|
125
|
+
),
|
|
126
|
+
)
|
|
127
|
+
})
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// eslint-disable-next-line no-console
|
|
131
|
+
console.log('Copying the worker script at "%s"...', absolutePublicDir)
|
|
132
|
+
|
|
133
|
+
const workerFilename = path.basename(SERVICE_WORKER_BUILD_PATH)
|
|
134
|
+
const workerDestinationPath = path.resolve(absolutePublicDir, workerFilename)
|
|
135
|
+
|
|
136
|
+
fs.copyFileSync(SERVICE_WORKER_BUILD_PATH, workerDestinationPath)
|
|
137
|
+
|
|
138
|
+
return workerDestinationPath
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* @param {Array<string>} paths
|
|
143
|
+
*/
|
|
144
|
+
function printSuccessMessage(paths) {
|
|
145
|
+
// eslint-disable-next-line no-console
|
|
146
|
+
console.log(`
|
|
147
|
+
${colors.green('Worker script successfully copied!')}
|
|
148
|
+
${paths.map((path) => colors.gray(` - ${path}\n`))}
|
|
149
|
+
Continue by describing the network in your application:
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
${colors.red(colors.bold('https://mswjs.io/docs/quick-start'))}
|
|
153
|
+
`)
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function printFailureMessage(pathsWithErrors) {
|
|
157
|
+
// eslint-disable-next-line no-console
|
|
158
|
+
console.error(`\
|
|
159
|
+
${colors.red('Copying the worker script failed at following paths:')}
|
|
160
|
+
${pathsWithErrors
|
|
161
|
+
.map(([path, error]) => colors.gray(` - ${path}`) + '\n' + ` ${error}`)
|
|
162
|
+
.join('\n\n')}
|
|
163
|
+
`)
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* @param {string} packageJsonPath
|
|
168
|
+
* @param {string} publicDir
|
|
169
|
+
*/
|
|
170
|
+
function saveWorkerDirectory(packageJsonPath, publicDir) {
|
|
171
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'))
|
|
172
|
+
|
|
173
|
+
// eslint-disable-next-line no-console
|
|
174
|
+
console.log(
|
|
175
|
+
colors.gray('Updating "msw.workerDirectory" at "%s"...'),
|
|
176
|
+
packageJsonPath,
|
|
177
|
+
)
|
|
178
|
+
|
|
179
|
+
const prevWorkerDirectory = Array.prototype.concat(
|
|
180
|
+
(packageJson.msw && packageJson.msw.workerDirectory) || [],
|
|
181
|
+
)
|
|
182
|
+
const nextWorkerDirectory = Array.from(
|
|
183
|
+
new Set(prevWorkerDirectory).add(publicDir),
|
|
184
|
+
)
|
|
185
|
+
|
|
186
|
+
const nextPackageJson = Object.assign({}, packageJson, {
|
|
187
|
+
msw: {
|
|
188
|
+
workerDirectory: nextWorkerDirectory,
|
|
189
|
+
},
|
|
190
|
+
})
|
|
191
|
+
|
|
192
|
+
fs.writeFileSync(
|
|
193
|
+
packageJsonPath,
|
|
194
|
+
JSON.stringify(nextPackageJson, null, 2),
|
|
195
|
+
'utf8',
|
|
196
|
+
)
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* @param {string} message
|
|
201
|
+
* @param {string} packageJsonPath
|
|
202
|
+
* @param {string} publicDir
|
|
203
|
+
* @returns {void}
|
|
204
|
+
*/
|
|
205
|
+
function promptWorkerDirectoryUpdate(message, packageJsonPath, publicDir) {
|
|
206
|
+
return confirm({
|
|
207
|
+
theme: {
|
|
208
|
+
prefix: colors.yellowBright('?'),
|
|
209
|
+
},
|
|
210
|
+
message,
|
|
211
|
+
}).then((answer) => {
|
|
212
|
+
if (answer) {
|
|
213
|
+
saveWorkerDirectory(packageJsonPath, publicDir)
|
|
214
|
+
}
|
|
215
|
+
})
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Normalizes the given path, replacing ambiguous path separators
|
|
220
|
+
* with the platform-specific path separator.
|
|
221
|
+
* @param {string} input Path to normalize.
|
|
222
|
+
* @returns {string}
|
|
223
|
+
*/
|
|
224
|
+
function normalizePath(input) {
|
|
225
|
+
return input.replace(/[\\|\/]+/g, path.sep)
|
|
226
|
+
}
|
package/cli/invariant.js
ADDED
package/cli/package.json
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import url from 'node:url'
|
|
2
|
+
import path from 'node:path'
|
|
3
|
+
|
|
4
|
+
export const SERVICE_WORKER_SOURCE_PATH = url.fileURLToPath(
|
|
5
|
+
new URL('../src/mockServiceWorker.js', import.meta.url),
|
|
6
|
+
)
|
|
7
|
+
|
|
8
|
+
export const SERVICE_WORKER_BUILD_PATH = url.fileURLToPath(
|
|
9
|
+
new URL(
|
|
10
|
+
path.join('../lib', path.basename(SERVICE_WORKER_SOURCE_PATH)),
|
|
11
|
+
import.meta.url,
|
|
12
|
+
),
|
|
13
|
+
)
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import fs from 'node:fs'
|
|
2
|
+
import path from 'node:path'
|
|
3
|
+
import { execFileSync } from 'node:child_process'
|
|
4
|
+
|
|
5
|
+
// When executing the "postinstall" script, the "process.cwd" equals
|
|
6
|
+
// the package directory, not the parent project where the package is installed.
|
|
7
|
+
// NPM stores the parent project directory in the "INIT_CWD" env variable.
|
|
8
|
+
const parentPackageCwd = process.env.INIT_CWD
|
|
9
|
+
|
|
10
|
+
function postInstall() {
|
|
11
|
+
const packageJson = JSON.parse(
|
|
12
|
+
fs.readFileSync(path.resolve(parentPackageCwd, 'package.json'), 'utf8'),
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
if (!packageJson.msw || !packageJson.msw.workerDirectory) {
|
|
16
|
+
return
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const cliExecutable = path.resolve(process.cwd(), 'cli/index.js')
|
|
20
|
+
|
|
21
|
+
try {
|
|
22
|
+
/**
|
|
23
|
+
* @note Call the "init" command directly. It will now copy the worker script
|
|
24
|
+
* to all saved paths in "msw.workerDirectory"
|
|
25
|
+
*/
|
|
26
|
+
execFileSync(process.execPath, [cliExecutable, 'init'], {
|
|
27
|
+
cwd: parentPackageCwd,
|
|
28
|
+
})
|
|
29
|
+
} catch (error) {
|
|
30
|
+
console.error(
|
|
31
|
+
`[MSW] Failed to automatically update the worker script.\n\n${error}`,
|
|
32
|
+
)
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
postInstall()
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { SharedOptions, LifeCycleEventEmitter, LifeCycleEventsMap } from "../core/sharedOptions.mjs";
|
|
2
|
+
import { RequestHandler } from "../core/handlers/RequestHandler.mjs";
|
|
3
|
+
import { WebSocketHandler } from "../core/handlers/WebSocketHandler.mjs";
|
|
4
|
+
import { SetupApi } from "../core/SetupApi.mjs";
|
|
5
|
+
|
|
6
|
+
type FindWorker = (scriptUrl: string, mockServiceWorkerUrl: string) => boolean;
|
|
7
|
+
interface StartOptions extends SharedOptions {
|
|
8
|
+
/**
|
|
9
|
+
* Service Worker registration options.
|
|
10
|
+
*/
|
|
11
|
+
serviceWorker?: {
|
|
12
|
+
/**
|
|
13
|
+
* Custom url to the worker script.
|
|
14
|
+
* @default "/mockServiceWorker.js"
|
|
15
|
+
*/
|
|
16
|
+
url?: string;
|
|
17
|
+
options?: RegistrationOptions;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Disables the logging of the intercepted requests
|
|
21
|
+
* into browser's console.
|
|
22
|
+
* @default false
|
|
23
|
+
*/
|
|
24
|
+
quiet?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Defers any network requests until the Service Worker
|
|
27
|
+
* instance is activated.
|
|
28
|
+
* @default true
|
|
29
|
+
*/
|
|
30
|
+
waitUntilReady?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* A custom lookup function to find a Mock Service Worker in the list
|
|
33
|
+
* of all registered Service Workers on the page.
|
|
34
|
+
*/
|
|
35
|
+
findWorker?: FindWorker;
|
|
36
|
+
}
|
|
37
|
+
type StartReturnType = Promise<ServiceWorkerRegistration | undefined>;
|
|
38
|
+
type StopHandler = () => void;
|
|
39
|
+
interface SetupWorker {
|
|
40
|
+
/**
|
|
41
|
+
* Registers and activates the mock Service Worker.
|
|
42
|
+
*
|
|
43
|
+
* @see {@link https://mswjs.io/docs/api/setup-worker/start `worker.start()` API reference}
|
|
44
|
+
*/
|
|
45
|
+
start: (options?: StartOptions) => StartReturnType;
|
|
46
|
+
/**
|
|
47
|
+
* Stops requests interception for the current client.
|
|
48
|
+
*
|
|
49
|
+
* @see {@link https://mswjs.io/docs/api/setup-worker/stop `worker.stop()` API reference}
|
|
50
|
+
*/
|
|
51
|
+
stop: StopHandler;
|
|
52
|
+
/**
|
|
53
|
+
* Prepends given request handlers to the list of existing handlers.
|
|
54
|
+
* @param {RequestHandler[]} handlers List of runtime request handlers.
|
|
55
|
+
*
|
|
56
|
+
* @see {@link https://mswjs.io/docs/api/setup-worker/use `worker.use()` API reference}
|
|
57
|
+
*/
|
|
58
|
+
use: (...handlers: Array<RequestHandler | WebSocketHandler>) => void;
|
|
59
|
+
/**
|
|
60
|
+
* Marks all request handlers that respond using `res.once()` as unused.
|
|
61
|
+
*
|
|
62
|
+
* @see {@link https://mswjs.io/docs/api/setup-worker/restore-handlers `worker.restoreHandlers()` API reference}
|
|
63
|
+
*/
|
|
64
|
+
restoreHandlers: () => void;
|
|
65
|
+
/**
|
|
66
|
+
* Resets request handlers to the initial list given to the `setupWorker` call, or to the explicit next request handlers list, if given.
|
|
67
|
+
* @param {RequestHandler[]} nextHandlers List of the new initial request handlers.
|
|
68
|
+
*
|
|
69
|
+
* @see {@link https://mswjs.io/docs/api/setup-worker/reset-handlers `worker.resetHandlers()` API reference}
|
|
70
|
+
*/
|
|
71
|
+
resetHandlers: (...nextHandlers: Array<RequestHandler | WebSocketHandler>) => void;
|
|
72
|
+
/**
|
|
73
|
+
* Returns a readonly list of currently active request handlers.
|
|
74
|
+
*
|
|
75
|
+
* @see {@link https://mswjs.io/docs/api/setup-worker/list-handlers `worker.listHandlers()` API reference}
|
|
76
|
+
*/
|
|
77
|
+
listHandlers(): ReadonlyArray<RequestHandler | WebSocketHandler>;
|
|
78
|
+
/**
|
|
79
|
+
* Life-cycle events.
|
|
80
|
+
* Life-cycle events allow you to subscribe to the internal library events occurring during the request/response handling.
|
|
81
|
+
*
|
|
82
|
+
* @see {@link https://mswjs.io/docs/api/life-cycle-events Life-cycle Events API reference}
|
|
83
|
+
*/
|
|
84
|
+
events: LifeCycleEventEmitter<LifeCycleEventsMap>;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
declare class SetupWorkerApi extends SetupApi<LifeCycleEventsMap> implements SetupWorker {
|
|
88
|
+
private context;
|
|
89
|
+
constructor(...handlers: Array<RequestHandler | WebSocketHandler>);
|
|
90
|
+
private createWorkerContext;
|
|
91
|
+
start(options?: StartOptions): StartReturnType;
|
|
92
|
+
stop(): void;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Sets up a requests interception in the browser with the given request handlers.
|
|
96
|
+
* @param {RequestHandler[]} handlers List of request handlers.
|
|
97
|
+
*
|
|
98
|
+
* @see {@link https://mswjs.io/docs/api/setup-worker `setupWorker()` API reference}
|
|
99
|
+
*/
|
|
100
|
+
declare function setupWorker(...handlers: Array<RequestHandler | WebSocketHandler>): SetupWorker;
|
|
101
|
+
|
|
102
|
+
export { type SetupWorker, SetupWorkerApi, type StartOptions, setupWorker };
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { SharedOptions, LifeCycleEventEmitter, LifeCycleEventsMap } from "../core/sharedOptions";
|
|
2
|
+
import { RequestHandler } from "../core/handlers/RequestHandler";
|
|
3
|
+
import { WebSocketHandler } from "../core/handlers/WebSocketHandler";
|
|
4
|
+
import { SetupApi } from "../core/SetupApi";
|
|
5
|
+
|
|
6
|
+
type FindWorker = (scriptUrl: string, mockServiceWorkerUrl: string) => boolean;
|
|
7
|
+
interface StartOptions extends SharedOptions {
|
|
8
|
+
/**
|
|
9
|
+
* Service Worker registration options.
|
|
10
|
+
*/
|
|
11
|
+
serviceWorker?: {
|
|
12
|
+
/**
|
|
13
|
+
* Custom url to the worker script.
|
|
14
|
+
* @default "/mockServiceWorker.js"
|
|
15
|
+
*/
|
|
16
|
+
url?: string;
|
|
17
|
+
options?: RegistrationOptions;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Disables the logging of the intercepted requests
|
|
21
|
+
* into browser's console.
|
|
22
|
+
* @default false
|
|
23
|
+
*/
|
|
24
|
+
quiet?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Defers any network requests until the Service Worker
|
|
27
|
+
* instance is activated.
|
|
28
|
+
* @default true
|
|
29
|
+
*/
|
|
30
|
+
waitUntilReady?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* A custom lookup function to find a Mock Service Worker in the list
|
|
33
|
+
* of all registered Service Workers on the page.
|
|
34
|
+
*/
|
|
35
|
+
findWorker?: FindWorker;
|
|
36
|
+
}
|
|
37
|
+
type StartReturnType = Promise<ServiceWorkerRegistration | undefined>;
|
|
38
|
+
type StopHandler = () => void;
|
|
39
|
+
interface SetupWorker {
|
|
40
|
+
/**
|
|
41
|
+
* Registers and activates the mock Service Worker.
|
|
42
|
+
*
|
|
43
|
+
* @see {@link https://mswjs.io/docs/api/setup-worker/start `worker.start()` API reference}
|
|
44
|
+
*/
|
|
45
|
+
start: (options?: StartOptions) => StartReturnType;
|
|
46
|
+
/**
|
|
47
|
+
* Stops requests interception for the current client.
|
|
48
|
+
*
|
|
49
|
+
* @see {@link https://mswjs.io/docs/api/setup-worker/stop `worker.stop()` API reference}
|
|
50
|
+
*/
|
|
51
|
+
stop: StopHandler;
|
|
52
|
+
/**
|
|
53
|
+
* Prepends given request handlers to the list of existing handlers.
|
|
54
|
+
* @param {RequestHandler[]} handlers List of runtime request handlers.
|
|
55
|
+
*
|
|
56
|
+
* @see {@link https://mswjs.io/docs/api/setup-worker/use `worker.use()` API reference}
|
|
57
|
+
*/
|
|
58
|
+
use: (...handlers: Array<RequestHandler | WebSocketHandler>) => void;
|
|
59
|
+
/**
|
|
60
|
+
* Marks all request handlers that respond using `res.once()` as unused.
|
|
61
|
+
*
|
|
62
|
+
* @see {@link https://mswjs.io/docs/api/setup-worker/restore-handlers `worker.restoreHandlers()` API reference}
|
|
63
|
+
*/
|
|
64
|
+
restoreHandlers: () => void;
|
|
65
|
+
/**
|
|
66
|
+
* Resets request handlers to the initial list given to the `setupWorker` call, or to the explicit next request handlers list, if given.
|
|
67
|
+
* @param {RequestHandler[]} nextHandlers List of the new initial request handlers.
|
|
68
|
+
*
|
|
69
|
+
* @see {@link https://mswjs.io/docs/api/setup-worker/reset-handlers `worker.resetHandlers()` API reference}
|
|
70
|
+
*/
|
|
71
|
+
resetHandlers: (...nextHandlers: Array<RequestHandler | WebSocketHandler>) => void;
|
|
72
|
+
/**
|
|
73
|
+
* Returns a readonly list of currently active request handlers.
|
|
74
|
+
*
|
|
75
|
+
* @see {@link https://mswjs.io/docs/api/setup-worker/list-handlers `worker.listHandlers()` API reference}
|
|
76
|
+
*/
|
|
77
|
+
listHandlers(): ReadonlyArray<RequestHandler | WebSocketHandler>;
|
|
78
|
+
/**
|
|
79
|
+
* Life-cycle events.
|
|
80
|
+
* Life-cycle events allow you to subscribe to the internal library events occurring during the request/response handling.
|
|
81
|
+
*
|
|
82
|
+
* @see {@link https://mswjs.io/docs/api/life-cycle-events Life-cycle Events API reference}
|
|
83
|
+
*/
|
|
84
|
+
events: LifeCycleEventEmitter<LifeCycleEventsMap>;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
declare class SetupWorkerApi extends SetupApi<LifeCycleEventsMap> implements SetupWorker {
|
|
88
|
+
private context;
|
|
89
|
+
constructor(...handlers: Array<RequestHandler | WebSocketHandler>);
|
|
90
|
+
private createWorkerContext;
|
|
91
|
+
start(options?: StartOptions): StartReturnType;
|
|
92
|
+
stop(): void;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Sets up a requests interception in the browser with the given request handlers.
|
|
96
|
+
* @param {RequestHandler[]} handlers List of request handlers.
|
|
97
|
+
*
|
|
98
|
+
* @see {@link https://mswjs.io/docs/api/setup-worker `setupWorker()` API reference}
|
|
99
|
+
*/
|
|
100
|
+
declare function setupWorker(...handlers: Array<RequestHandler | WebSocketHandler>): SetupWorker;
|
|
101
|
+
|
|
102
|
+
export { type SetupWorker, SetupWorkerApi, type StartOptions, setupWorker };
|