@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
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var isCommonAssetRequest_exports = {};
|
|
20
|
+
__export(isCommonAssetRequest_exports, {
|
|
21
|
+
isCommonAssetRequest: () => isCommonAssetRequest
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(isCommonAssetRequest_exports);
|
|
24
|
+
function isCommonAssetRequest(request) {
|
|
25
|
+
const url = new URL(request.url);
|
|
26
|
+
if (url.protocol === "file:") {
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
if (/(fonts\.googleapis\.com)/.test(url.hostname)) {
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
if (/node_modules/.test(url.pathname)) {
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
if (url.pathname.includes("@vite")) {
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
return /\.(s?css|less|m?jsx?|m?tsx?|html|ttf|otf|woff|woff2|eot|gif|jpe?g|png|avif|webp|svg|mp4|webm|ogg|mov|mp3|wav|ogg|flac|aac|pdf|txt|csv|json|xml|md|zip|tar|gz|rar|7z)$/i.test(
|
|
39
|
+
url.pathname
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=isCommonAssetRequest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/core/isCommonAssetRequest.ts"],"sourcesContent":["/**\n * Determines if the given request is a static asset request.\n * Useful when deciding which unhandled requests to ignore.\n * @note Despite being ignored, you can still intercept and mock\n * static assets by creating request handlers for them.\n *\n * @example\n * import { isCommonAssetRequest } from 'msw'\n *\n * await worker.start({\n * onUnhandledRequest(request, print) {\n * if (!isCommonAssetRequest(request)) {\n * print.warning()\n * }\n * }\n * })\n */\nexport function isCommonAssetRequest(request: Request): boolean {\n const url = new URL(request.url)\n\n // Ignore certain protocols.\n if (url.protocol === 'file:') {\n return true\n }\n\n // Ignore static assets hosts.\n if (/(fonts\\.googleapis\\.com)/.test(url.hostname)) {\n return true\n }\n\n // Ignore node modules served over HTTP.\n if (/node_modules/.test(url.pathname)) {\n return true\n }\n\n // Ignore internal Vite requests, like \"/@vite/client\".\n if (url.pathname.includes('@vite')) {\n return true\n }\n\n // Ignore common static assets.\n return /\\.(s?css|less|m?jsx?|m?tsx?|html|ttf|otf|woff|woff2|eot|gif|jpe?g|png|avif|webp|svg|mp4|webm|ogg|mov|mp3|wav|ogg|flac|aac|pdf|txt|csv|json|xml|md|zip|tar|gz|rar|7z)$/i.test(\n url.pathname,\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAiBO,SAAS,qBAAqB,SAA2B;AAC9D,QAAM,MAAM,IAAI,IAAI,QAAQ,GAAG;AAG/B,MAAI,IAAI,aAAa,SAAS;AAC5B,WAAO;AAAA,EACT;AAGA,MAAI,2BAA2B,KAAK,IAAI,QAAQ,GAAG;AACjD,WAAO;AAAA,EACT;AAGA,MAAI,eAAe,KAAK,IAAI,QAAQ,GAAG;AACrC,WAAO;AAAA,EACT;AAGA,MAAI,IAAI,SAAS,SAAS,OAAO,GAAG;AAClC,WAAO;AAAA,EACT;AAGA,SAAO,yKAAyK;AAAA,IAC9K,IAAI;AAAA,EACN;AACF;","names":[]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
function isCommonAssetRequest(request) {
|
|
2
|
+
const url = new URL(request.url);
|
|
3
|
+
if (url.protocol === "file:") {
|
|
4
|
+
return true;
|
|
5
|
+
}
|
|
6
|
+
if (/(fonts\.googleapis\.com)/.test(url.hostname)) {
|
|
7
|
+
return true;
|
|
8
|
+
}
|
|
9
|
+
if (/node_modules/.test(url.pathname)) {
|
|
10
|
+
return true;
|
|
11
|
+
}
|
|
12
|
+
if (url.pathname.includes("@vite")) {
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
return /\.(s?css|less|m?jsx?|m?tsx?|html|ttf|otf|woff|woff2|eot|gif|jpe?g|png|avif|webp|svg|mp4|webm|ogg|mov|mp3|wav|ogg|flac|aac|pdf|txt|csv|json|xml|md|zip|tar|gz|rar|7z)$/i.test(
|
|
16
|
+
url.pathname
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
export {
|
|
20
|
+
isCommonAssetRequest
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=isCommonAssetRequest.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/core/isCommonAssetRequest.ts"],"sourcesContent":["/**\n * Determines if the given request is a static asset request.\n * Useful when deciding which unhandled requests to ignore.\n * @note Despite being ignored, you can still intercept and mock\n * static assets by creating request handlers for them.\n *\n * @example\n * import { isCommonAssetRequest } from 'msw'\n *\n * await worker.start({\n * onUnhandledRequest(request, print) {\n * if (!isCommonAssetRequest(request)) {\n * print.warning()\n * }\n * }\n * })\n */\nexport function isCommonAssetRequest(request: Request): boolean {\n const url = new URL(request.url)\n\n // Ignore certain protocols.\n if (url.protocol === 'file:') {\n return true\n }\n\n // Ignore static assets hosts.\n if (/(fonts\\.googleapis\\.com)/.test(url.hostname)) {\n return true\n }\n\n // Ignore node modules served over HTTP.\n if (/node_modules/.test(url.pathname)) {\n return true\n }\n\n // Ignore internal Vite requests, like \"/@vite/client\".\n if (url.pathname.includes('@vite')) {\n return true\n }\n\n // Ignore common static assets.\n return /\\.(s?css|less|m?jsx?|m?tsx?|html|ttf|otf|woff|woff2|eot|gif|jpe?g|png|avif|webp|svg|mp4|webm|ogg|mov|mp3|wav|ogg|flac|aac|pdf|txt|csv|json|xml|md|zip|tar|gz|rar|7z)$/i.test(\n url.pathname,\n )\n}\n"],"mappings":"AAiBO,SAAS,qBAAqB,SAA2B;AAC9D,QAAM,MAAM,IAAI,IAAI,QAAQ,GAAG;AAG/B,MAAI,IAAI,aAAa,SAAS;AAC5B,WAAO;AAAA,EACT;AAGA,MAAI,2BAA2B,KAAK,IAAI,QAAQ,GAAG;AACjD,WAAO;AAAA,EACT;AAGA,MAAI,eAAe,KAAK,IAAI,QAAQ,GAAG;AACrC,WAAO;AAAA,EACT;AAGA,MAAI,IAAI,SAAS,SAAS,OAAO,GAAG;AAClC,WAAO;AAAA,EACT;AAGA,SAAO,yKAAyK;AAAA,IAC9K,IAAI;AAAA,EACN;AACF;","names":[]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { H as HttpResponse } from './HttpResponse-Be4eT3x6.mjs';
|
|
2
|
+
import '@mswjs/interceptors';
|
|
3
|
+
import './utils/internal/isIterable.mjs';
|
|
4
|
+
import './typeUtils.mjs';
|
|
5
|
+
import 'graphql';
|
|
6
|
+
import './utils/matching/matchRequestUrl.mjs';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Performs the intercepted request as-is.
|
|
10
|
+
*
|
|
11
|
+
* This stops request handler lookup so no other handlers
|
|
12
|
+
* can affect this request past this point.
|
|
13
|
+
* Unlike `bypass()`, this will not trigger an additional request.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* http.get('/resource', () => {
|
|
17
|
+
* return passthrough()
|
|
18
|
+
* })
|
|
19
|
+
*
|
|
20
|
+
* @see {@link https://mswjs.io/docs/api/passthrough `passthrough()` API reference}
|
|
21
|
+
*/
|
|
22
|
+
declare function passthrough(): HttpResponse<any>;
|
|
23
|
+
|
|
24
|
+
export { passthrough };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { H as HttpResponse } from './HttpResponse-Dj6ibgFJ.js';
|
|
2
|
+
import '@mswjs/interceptors';
|
|
3
|
+
import './utils/internal/isIterable.js';
|
|
4
|
+
import './typeUtils.js';
|
|
5
|
+
import 'graphql';
|
|
6
|
+
import './utils/matching/matchRequestUrl.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Performs the intercepted request as-is.
|
|
10
|
+
*
|
|
11
|
+
* This stops request handler lookup so no other handlers
|
|
12
|
+
* can affect this request past this point.
|
|
13
|
+
* Unlike `bypass()`, this will not trigger an additional request.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* http.get('/resource', () => {
|
|
17
|
+
* return passthrough()
|
|
18
|
+
* })
|
|
19
|
+
*
|
|
20
|
+
* @see {@link https://mswjs.io/docs/api/passthrough `passthrough()` API reference}
|
|
21
|
+
*/
|
|
22
|
+
declare function passthrough(): HttpResponse<any>;
|
|
23
|
+
|
|
24
|
+
export { passthrough };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var passthrough_exports = {};
|
|
20
|
+
__export(passthrough_exports, {
|
|
21
|
+
passthrough: () => passthrough
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(passthrough_exports);
|
|
24
|
+
function passthrough() {
|
|
25
|
+
return new Response(null, {
|
|
26
|
+
status: 302,
|
|
27
|
+
statusText: "Passthrough",
|
|
28
|
+
headers: {
|
|
29
|
+
"x-msw-intention": "passthrough"
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=passthrough.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/core/passthrough.ts"],"sourcesContent":["import type { HttpResponse } from './HttpResponse'\n\n/**\n * Performs the intercepted request as-is.\n *\n * This stops request handler lookup so no other handlers\n * can affect this request past this point.\n * Unlike `bypass()`, this will not trigger an additional request.\n *\n * @example\n * http.get('/resource', () => {\n * return passthrough()\n * })\n *\n * @see {@link https://mswjs.io/docs/api/passthrough `passthrough()` API reference}\n */\nexport function passthrough(): HttpResponse<any> {\n return new Response(null, {\n status: 302,\n statusText: 'Passthrough',\n headers: {\n 'x-msw-intention': 'passthrough',\n },\n }) as HttpResponse<any>\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBO,SAAS,cAAiC;AAC/C,SAAO,IAAI,SAAS,MAAM;AAAA,IACxB,QAAQ;AAAA,IACR,YAAY;AAAA,IACZ,SAAS;AAAA,MACP,mBAAmB;AAAA,IACrB;AAAA,EACF,CAAC;AACH;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/core/passthrough.ts"],"sourcesContent":["import type { HttpResponse } from './HttpResponse'\n\n/**\n * Performs the intercepted request as-is.\n *\n * This stops request handler lookup so no other handlers\n * can affect this request past this point.\n * Unlike `bypass()`, this will not trigger an additional request.\n *\n * @example\n * http.get('/resource', () => {\n * return passthrough()\n * })\n *\n * @see {@link https://mswjs.io/docs/api/passthrough `passthrough()` API reference}\n */\nexport function passthrough(): HttpResponse<any> {\n return new Response(null, {\n status: 302,\n statusText: 'Passthrough',\n headers: {\n 'x-msw-intention': 'passthrough',\n },\n }) as HttpResponse<any>\n}\n"],"mappings":"AAgBO,SAAS,cAAiC;AAC/C,SAAO,IAAI,SAAS,MAAM;AAAA,IACxB,QAAQ;AAAA,IACR,YAAY;AAAA,IACZ,SAAS;AAAA,MACP,mBAAmB;AAAA,IACrB;AAAA,EACF,CAAC;AACH;","names":[]}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { Emitter } from 'strict-event-emitter';
|
|
2
|
+
import { UnhandledRequestStrategy } from './utils/request/onUnhandledRequest.mjs';
|
|
3
|
+
|
|
4
|
+
interface SharedOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Specifies how to react to a request that has no corresponding
|
|
7
|
+
* request handler. Warns on unhandled requests by default.
|
|
8
|
+
*
|
|
9
|
+
* @example worker.start({ onUnhandledRequest: 'bypass' })
|
|
10
|
+
* @example worker.start({ onUnhandledRequest: 'warn' })
|
|
11
|
+
* @example server.listen({ onUnhandledRequest: 'error' })
|
|
12
|
+
*/
|
|
13
|
+
onUnhandledRequest?: UnhandledRequestStrategy;
|
|
14
|
+
}
|
|
15
|
+
type LifeCycleEventsMap = {
|
|
16
|
+
'request:start': [
|
|
17
|
+
args: {
|
|
18
|
+
request: Request;
|
|
19
|
+
requestId: string;
|
|
20
|
+
}
|
|
21
|
+
];
|
|
22
|
+
'request:match': [
|
|
23
|
+
args: {
|
|
24
|
+
request: Request;
|
|
25
|
+
requestId: string;
|
|
26
|
+
}
|
|
27
|
+
];
|
|
28
|
+
'request:unhandled': [
|
|
29
|
+
args: {
|
|
30
|
+
request: Request;
|
|
31
|
+
requestId: string;
|
|
32
|
+
}
|
|
33
|
+
];
|
|
34
|
+
'request:end': [
|
|
35
|
+
args: {
|
|
36
|
+
request: Request;
|
|
37
|
+
requestId: string;
|
|
38
|
+
}
|
|
39
|
+
];
|
|
40
|
+
'response:mocked': [
|
|
41
|
+
args: {
|
|
42
|
+
response: Response;
|
|
43
|
+
request: Request;
|
|
44
|
+
requestId: string;
|
|
45
|
+
}
|
|
46
|
+
];
|
|
47
|
+
'response:bypass': [
|
|
48
|
+
args: {
|
|
49
|
+
response: Response;
|
|
50
|
+
request: Request;
|
|
51
|
+
requestId: string;
|
|
52
|
+
}
|
|
53
|
+
];
|
|
54
|
+
unhandledException: [
|
|
55
|
+
args: {
|
|
56
|
+
error: Error;
|
|
57
|
+
request: Request;
|
|
58
|
+
requestId: string;
|
|
59
|
+
}
|
|
60
|
+
];
|
|
61
|
+
};
|
|
62
|
+
type LifeCycleEventEmitter<EventsMap extends Record<string | symbol, any>> = Pick<Emitter<EventsMap>, 'on' | 'removeListener' | 'removeAllListeners'>;
|
|
63
|
+
|
|
64
|
+
export type { LifeCycleEventEmitter, LifeCycleEventsMap, SharedOptions };
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { Emitter } from 'strict-event-emitter';
|
|
2
|
+
import { UnhandledRequestStrategy } from './utils/request/onUnhandledRequest.js';
|
|
3
|
+
|
|
4
|
+
interface SharedOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Specifies how to react to a request that has no corresponding
|
|
7
|
+
* request handler. Warns on unhandled requests by default.
|
|
8
|
+
*
|
|
9
|
+
* @example worker.start({ onUnhandledRequest: 'bypass' })
|
|
10
|
+
* @example worker.start({ onUnhandledRequest: 'warn' })
|
|
11
|
+
* @example server.listen({ onUnhandledRequest: 'error' })
|
|
12
|
+
*/
|
|
13
|
+
onUnhandledRequest?: UnhandledRequestStrategy;
|
|
14
|
+
}
|
|
15
|
+
type LifeCycleEventsMap = {
|
|
16
|
+
'request:start': [
|
|
17
|
+
args: {
|
|
18
|
+
request: Request;
|
|
19
|
+
requestId: string;
|
|
20
|
+
}
|
|
21
|
+
];
|
|
22
|
+
'request:match': [
|
|
23
|
+
args: {
|
|
24
|
+
request: Request;
|
|
25
|
+
requestId: string;
|
|
26
|
+
}
|
|
27
|
+
];
|
|
28
|
+
'request:unhandled': [
|
|
29
|
+
args: {
|
|
30
|
+
request: Request;
|
|
31
|
+
requestId: string;
|
|
32
|
+
}
|
|
33
|
+
];
|
|
34
|
+
'request:end': [
|
|
35
|
+
args: {
|
|
36
|
+
request: Request;
|
|
37
|
+
requestId: string;
|
|
38
|
+
}
|
|
39
|
+
];
|
|
40
|
+
'response:mocked': [
|
|
41
|
+
args: {
|
|
42
|
+
response: Response;
|
|
43
|
+
request: Request;
|
|
44
|
+
requestId: string;
|
|
45
|
+
}
|
|
46
|
+
];
|
|
47
|
+
'response:bypass': [
|
|
48
|
+
args: {
|
|
49
|
+
response: Response;
|
|
50
|
+
request: Request;
|
|
51
|
+
requestId: string;
|
|
52
|
+
}
|
|
53
|
+
];
|
|
54
|
+
unhandledException: [
|
|
55
|
+
args: {
|
|
56
|
+
error: Error;
|
|
57
|
+
request: Request;
|
|
58
|
+
requestId: string;
|
|
59
|
+
}
|
|
60
|
+
];
|
|
61
|
+
};
|
|
62
|
+
type LifeCycleEventEmitter<EventsMap extends Record<string | symbol, any>> = Pick<Emitter<EventsMap>, 'on' | 'removeListener' | 'removeAllListeners'>;
|
|
63
|
+
|
|
64
|
+
export type { LifeCycleEventEmitter, LifeCycleEventsMap, SharedOptions };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var sharedOptions_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(sharedOptions_exports);
|
|
17
|
+
//# sourceMappingURL=sharedOptions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/core/sharedOptions.ts"],"sourcesContent":["import type { Emitter } from 'strict-event-emitter'\nimport type { UnhandledRequestStrategy } from './utils/request/onUnhandledRequest'\n\nexport interface SharedOptions {\n /**\n * Specifies how to react to a request that has no corresponding\n * request handler. Warns on unhandled requests by default.\n *\n * @example worker.start({ onUnhandledRequest: 'bypass' })\n * @example worker.start({ onUnhandledRequest: 'warn' })\n * @example server.listen({ onUnhandledRequest: 'error' })\n */\n onUnhandledRequest?: UnhandledRequestStrategy\n}\n\nexport type LifeCycleEventsMap = {\n 'request:start': [\n args: {\n request: Request\n requestId: string\n },\n ]\n 'request:match': [\n args: {\n request: Request\n requestId: string\n },\n ]\n 'request:unhandled': [\n args: {\n request: Request\n requestId: string\n },\n ]\n 'request:end': [\n args: {\n request: Request\n requestId: string\n },\n ]\n 'response:mocked': [\n args: {\n response: Response\n request: Request\n requestId: string\n },\n ]\n 'response:bypass': [\n args: {\n response: Response\n request: Request\n requestId: string\n },\n ]\n unhandledException: [\n args: {\n error: Error\n request: Request\n requestId: string\n },\n ]\n}\n\nexport type LifeCycleEventEmitter<\n EventsMap extends Record<string | symbol, any>,\n> = Pick<Emitter<EventsMap>, 'on' | 'removeListener' | 'removeAllListeners'>\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=sharedOptions.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { Emitter } from 'strict-event-emitter';
|
|
2
|
+
import { a as ResponseResolver } from './HttpResponse-Be4eT3x6.mjs';
|
|
3
|
+
import { HttpRequestResolverExtras, HttpHandler } from './handlers/HttpHandler.mjs';
|
|
4
|
+
import { PathParams, Path } from './utils/matching/matchRequestUrl.mjs';
|
|
5
|
+
import '@mswjs/interceptors';
|
|
6
|
+
import './utils/internal/isIterable.mjs';
|
|
7
|
+
import './typeUtils.mjs';
|
|
8
|
+
import 'graphql';
|
|
9
|
+
|
|
10
|
+
type EventMapConstraint = {
|
|
11
|
+
message?: unknown;
|
|
12
|
+
[key: string]: unknown;
|
|
13
|
+
[key: symbol | number]: never;
|
|
14
|
+
};
|
|
15
|
+
type ServerSentEventResolverExtras<EventMap extends EventMapConstraint, Params extends PathParams> = HttpRequestResolverExtras<Params> & {
|
|
16
|
+
client: ServerSentEventClient<EventMap>;
|
|
17
|
+
server: ServerSentEventServer;
|
|
18
|
+
};
|
|
19
|
+
type ServerSentEventResolver<EventMap extends EventMapConstraint, Params extends PathParams> = ResponseResolver<ServerSentEventResolverExtras<EventMap, Params>, any, any>;
|
|
20
|
+
type ServerSentEventRequestHandler = <EventMap extends EventMapConstraint = {
|
|
21
|
+
message: unknown;
|
|
22
|
+
}, Params extends PathParams<keyof Params> = PathParams, RequestPath extends Path = Path>(path: RequestPath, resolver: ServerSentEventResolver<EventMap, Params>) => HttpHandler;
|
|
23
|
+
type ServerSentEventMessage<EventMap extends EventMapConstraint = {
|
|
24
|
+
message: unknown;
|
|
25
|
+
}> = ToEventDiscriminatedUnion<EventMap & {
|
|
26
|
+
message: unknown;
|
|
27
|
+
}> | {
|
|
28
|
+
id?: never;
|
|
29
|
+
event?: never;
|
|
30
|
+
data?: never;
|
|
31
|
+
retry: number;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Intercept Server-Sent Events (SSE).
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* sse('http://localhost:4321', ({ client }) => {
|
|
38
|
+
* client.send({ data: 'hello world' })
|
|
39
|
+
* })
|
|
40
|
+
*
|
|
41
|
+
* @see {@link https://mswjs.io/docs/sse/ Mocking Server-Sent Events}
|
|
42
|
+
* @see {@link https://mswjs.io/docs/api/sse `sse()` API reference}
|
|
43
|
+
*/
|
|
44
|
+
declare const sse: ServerSentEventRequestHandler;
|
|
45
|
+
type Values<T> = T[keyof T];
|
|
46
|
+
type Identity<T> = {
|
|
47
|
+
[K in keyof T]: T[K];
|
|
48
|
+
} & unknown;
|
|
49
|
+
type ToEventDiscriminatedUnion<T> = Values<{
|
|
50
|
+
[K in keyof T]: Identity<(K extends 'message' ? {
|
|
51
|
+
id?: string;
|
|
52
|
+
event?: K;
|
|
53
|
+
data?: T[K];
|
|
54
|
+
retry?: never;
|
|
55
|
+
} : {
|
|
56
|
+
id?: string;
|
|
57
|
+
event: K;
|
|
58
|
+
data?: T[K];
|
|
59
|
+
retry?: never;
|
|
60
|
+
}) & (undefined extends T[K] ? unknown : {
|
|
61
|
+
data: unknown;
|
|
62
|
+
})>;
|
|
63
|
+
}>;
|
|
64
|
+
type ServerSentEventClientEventMap = {
|
|
65
|
+
message: [
|
|
66
|
+
payload: {
|
|
67
|
+
id?: string;
|
|
68
|
+
event: string;
|
|
69
|
+
data?: unknown;
|
|
70
|
+
frames: Array<string>;
|
|
71
|
+
}
|
|
72
|
+
];
|
|
73
|
+
error: [];
|
|
74
|
+
close: [];
|
|
75
|
+
};
|
|
76
|
+
declare class ServerSentEventClient<EventMap extends EventMapConstraint = {
|
|
77
|
+
message: unknown;
|
|
78
|
+
}> {
|
|
79
|
+
#private;
|
|
80
|
+
constructor(args: {
|
|
81
|
+
controller: ReadableStreamDefaultController;
|
|
82
|
+
emitter: Emitter<ServerSentEventClientEventMap>;
|
|
83
|
+
});
|
|
84
|
+
/**
|
|
85
|
+
* Sends the given payload to the intercepted `EventSource`.
|
|
86
|
+
*/
|
|
87
|
+
send(payload: ServerSentEventMessage<EventMap>): void;
|
|
88
|
+
/**
|
|
89
|
+
* Dispatches the given event on the intercepted `EventSource`.
|
|
90
|
+
*/
|
|
91
|
+
dispatchEvent(event: Event): void;
|
|
92
|
+
/**
|
|
93
|
+
* Errors the underlying `EventSource`, closing the connection with an error.
|
|
94
|
+
* This is equivalent to aborting the connection and will produce a `TypeError: Failed to fetch`
|
|
95
|
+
* error.
|
|
96
|
+
*/
|
|
97
|
+
error(): void;
|
|
98
|
+
/**
|
|
99
|
+
* Closes the underlying `EventSource`, closing the connection.
|
|
100
|
+
*/
|
|
101
|
+
close(): void;
|
|
102
|
+
}
|
|
103
|
+
declare class ServerSentEventServer {
|
|
104
|
+
#private;
|
|
105
|
+
constructor(args: {
|
|
106
|
+
request: Request;
|
|
107
|
+
client: ServerSentEventClient<any>;
|
|
108
|
+
});
|
|
109
|
+
/**
|
|
110
|
+
* Establishes the actual connection for this SSE request
|
|
111
|
+
* and returns the `EventSource` instance.
|
|
112
|
+
*/
|
|
113
|
+
connect(): EventSource;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export { type ServerSentEventMessage, type ServerSentEventRequestHandler, type ServerSentEventResolver, type ServerSentEventResolverExtras, sse };
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { Emitter } from 'strict-event-emitter';
|
|
2
|
+
import { a as ResponseResolver } from './HttpResponse-Dj6ibgFJ.js';
|
|
3
|
+
import { HttpRequestResolverExtras, HttpHandler } from './handlers/HttpHandler.js';
|
|
4
|
+
import { PathParams, Path } from './utils/matching/matchRequestUrl.js';
|
|
5
|
+
import '@mswjs/interceptors';
|
|
6
|
+
import './utils/internal/isIterable.js';
|
|
7
|
+
import './typeUtils.js';
|
|
8
|
+
import 'graphql';
|
|
9
|
+
|
|
10
|
+
type EventMapConstraint = {
|
|
11
|
+
message?: unknown;
|
|
12
|
+
[key: string]: unknown;
|
|
13
|
+
[key: symbol | number]: never;
|
|
14
|
+
};
|
|
15
|
+
type ServerSentEventResolverExtras<EventMap extends EventMapConstraint, Params extends PathParams> = HttpRequestResolverExtras<Params> & {
|
|
16
|
+
client: ServerSentEventClient<EventMap>;
|
|
17
|
+
server: ServerSentEventServer;
|
|
18
|
+
};
|
|
19
|
+
type ServerSentEventResolver<EventMap extends EventMapConstraint, Params extends PathParams> = ResponseResolver<ServerSentEventResolverExtras<EventMap, Params>, any, any>;
|
|
20
|
+
type ServerSentEventRequestHandler = <EventMap extends EventMapConstraint = {
|
|
21
|
+
message: unknown;
|
|
22
|
+
}, Params extends PathParams<keyof Params> = PathParams, RequestPath extends Path = Path>(path: RequestPath, resolver: ServerSentEventResolver<EventMap, Params>) => HttpHandler;
|
|
23
|
+
type ServerSentEventMessage<EventMap extends EventMapConstraint = {
|
|
24
|
+
message: unknown;
|
|
25
|
+
}> = ToEventDiscriminatedUnion<EventMap & {
|
|
26
|
+
message: unknown;
|
|
27
|
+
}> | {
|
|
28
|
+
id?: never;
|
|
29
|
+
event?: never;
|
|
30
|
+
data?: never;
|
|
31
|
+
retry: number;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Intercept Server-Sent Events (SSE).
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* sse('http://localhost:4321', ({ client }) => {
|
|
38
|
+
* client.send({ data: 'hello world' })
|
|
39
|
+
* })
|
|
40
|
+
*
|
|
41
|
+
* @see {@link https://mswjs.io/docs/sse/ Mocking Server-Sent Events}
|
|
42
|
+
* @see {@link https://mswjs.io/docs/api/sse `sse()` API reference}
|
|
43
|
+
*/
|
|
44
|
+
declare const sse: ServerSentEventRequestHandler;
|
|
45
|
+
type Values<T> = T[keyof T];
|
|
46
|
+
type Identity<T> = {
|
|
47
|
+
[K in keyof T]: T[K];
|
|
48
|
+
} & unknown;
|
|
49
|
+
type ToEventDiscriminatedUnion<T> = Values<{
|
|
50
|
+
[K in keyof T]: Identity<(K extends 'message' ? {
|
|
51
|
+
id?: string;
|
|
52
|
+
event?: K;
|
|
53
|
+
data?: T[K];
|
|
54
|
+
retry?: never;
|
|
55
|
+
} : {
|
|
56
|
+
id?: string;
|
|
57
|
+
event: K;
|
|
58
|
+
data?: T[K];
|
|
59
|
+
retry?: never;
|
|
60
|
+
}) & (undefined extends T[K] ? unknown : {
|
|
61
|
+
data: unknown;
|
|
62
|
+
})>;
|
|
63
|
+
}>;
|
|
64
|
+
type ServerSentEventClientEventMap = {
|
|
65
|
+
message: [
|
|
66
|
+
payload: {
|
|
67
|
+
id?: string;
|
|
68
|
+
event: string;
|
|
69
|
+
data?: unknown;
|
|
70
|
+
frames: Array<string>;
|
|
71
|
+
}
|
|
72
|
+
];
|
|
73
|
+
error: [];
|
|
74
|
+
close: [];
|
|
75
|
+
};
|
|
76
|
+
declare class ServerSentEventClient<EventMap extends EventMapConstraint = {
|
|
77
|
+
message: unknown;
|
|
78
|
+
}> {
|
|
79
|
+
#private;
|
|
80
|
+
constructor(args: {
|
|
81
|
+
controller: ReadableStreamDefaultController;
|
|
82
|
+
emitter: Emitter<ServerSentEventClientEventMap>;
|
|
83
|
+
});
|
|
84
|
+
/**
|
|
85
|
+
* Sends the given payload to the intercepted `EventSource`.
|
|
86
|
+
*/
|
|
87
|
+
send(payload: ServerSentEventMessage<EventMap>): void;
|
|
88
|
+
/**
|
|
89
|
+
* Dispatches the given event on the intercepted `EventSource`.
|
|
90
|
+
*/
|
|
91
|
+
dispatchEvent(event: Event): void;
|
|
92
|
+
/**
|
|
93
|
+
* Errors the underlying `EventSource`, closing the connection with an error.
|
|
94
|
+
* This is equivalent to aborting the connection and will produce a `TypeError: Failed to fetch`
|
|
95
|
+
* error.
|
|
96
|
+
*/
|
|
97
|
+
error(): void;
|
|
98
|
+
/**
|
|
99
|
+
* Closes the underlying `EventSource`, closing the connection.
|
|
100
|
+
*/
|
|
101
|
+
close(): void;
|
|
102
|
+
}
|
|
103
|
+
declare class ServerSentEventServer {
|
|
104
|
+
#private;
|
|
105
|
+
constructor(args: {
|
|
106
|
+
request: Request;
|
|
107
|
+
client: ServerSentEventClient<any>;
|
|
108
|
+
});
|
|
109
|
+
/**
|
|
110
|
+
* Establishes the actual connection for this SSE request
|
|
111
|
+
* and returns the `EventSource` instance.
|
|
112
|
+
*/
|
|
113
|
+
connect(): EventSource;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export { type ServerSentEventMessage, type ServerSentEventRequestHandler, type ServerSentEventResolver, type ServerSentEventResolverExtras, sse };
|