@depup/msw 2.13.2-depup.0 → 2.15.0-depup.7
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/README.md +9 -12
- package/changes.json +14 -26
- package/cli/init.js +1 -1
- package/lib/browser/index.js +547 -177
- package/lib/browser/index.js.map +1 -1
- package/lib/browser/index.mjs +547 -177
- package/lib/browser/index.mjs.map +1 -1
- package/lib/core/{HttpResponse-DlRR1D-f.d.mts → HttpResponse-BE_Y2Ak9.d.mts} +52 -1
- package/lib/core/{HttpResponse-CksOMVAa.d.ts → HttpResponse-DL-P1EeG.d.ts} +52 -1
- package/lib/core/HttpResponse.d.mts +1 -1
- package/lib/core/HttpResponse.d.ts +1 -1
- package/lib/core/HttpResponse.js +2 -2
- package/lib/core/HttpResponse.js.map +1 -1
- package/lib/core/HttpResponse.mjs +2 -2
- package/lib/core/HttpResponse.mjs.map +1 -1
- package/lib/core/experimental/compat.d.mts +2 -2
- package/lib/core/experimental/compat.d.ts +2 -2
- package/lib/core/experimental/compat.js +1 -0
- package/lib/core/experimental/compat.js.map +1 -1
- package/lib/core/experimental/compat.mjs +1 -0
- package/lib/core/experimental/compat.mjs.map +1 -1
- package/lib/core/experimental/define-network.d.mts +2 -2
- package/lib/core/experimental/define-network.d.ts +2 -2
- package/lib/core/experimental/define-network.js +21 -11
- package/lib/core/experimental/define-network.js.map +1 -1
- package/lib/core/experimental/define-network.mjs +23 -11
- package/lib/core/experimental/define-network.mjs.map +1 -1
- package/lib/core/experimental/frames/http-frame.d.mts +2 -2
- package/lib/core/experimental/frames/http-frame.d.ts +2 -2
- package/lib/core/experimental/frames/http-frame.js +5 -2
- package/lib/core/experimental/frames/http-frame.js.map +1 -1
- package/lib/core/experimental/frames/http-frame.mjs +8 -3
- package/lib/core/experimental/frames/http-frame.mjs.map +1 -1
- package/lib/core/experimental/frames/network-frame.d.mts +2 -2
- package/lib/core/experimental/frames/network-frame.d.ts +2 -2
- package/lib/core/experimental/frames/network-frame.js +2 -0
- package/lib/core/experimental/frames/network-frame.js.map +1 -1
- package/lib/core/experimental/frames/network-frame.mjs +2 -0
- package/lib/core/experimental/frames/network-frame.mjs.map +1 -1
- package/lib/core/experimental/frames/websocket-frame.d.mts +2 -2
- package/lib/core/experimental/frames/websocket-frame.d.ts +2 -2
- package/lib/core/experimental/frames/websocket-frame.js +2 -0
- package/lib/core/experimental/frames/websocket-frame.js.map +1 -1
- package/lib/core/experimental/frames/websocket-frame.mjs +2 -0
- package/lib/core/experimental/frames/websocket-frame.mjs.map +1 -1
- package/lib/core/experimental/handlers-controller.d.mts +2 -1
- package/lib/core/experimental/handlers-controller.d.ts +2 -1
- package/lib/core/experimental/handlers-controller.js +31 -6
- package/lib/core/experimental/handlers-controller.js.map +1 -1
- package/lib/core/experimental/handlers-controller.mjs +31 -6
- package/lib/core/experimental/handlers-controller.mjs.map +1 -1
- package/lib/core/experimental/index.d.mts +5 -5
- package/lib/core/experimental/index.d.ts +5 -5
- package/lib/core/experimental/index.js +3 -1
- package/lib/core/experimental/index.js.map +1 -1
- package/lib/core/experimental/index.mjs +9 -2
- package/lib/core/experimental/index.mjs.map +1 -1
- package/lib/core/experimental/on-unhandled-frame.d.mts +2 -2
- package/lib/core/experimental/on-unhandled-frame.d.ts +2 -2
- package/lib/core/experimental/on-unhandled-frame.js +1 -0
- package/lib/core/experimental/on-unhandled-frame.js.map +1 -1
- package/lib/core/experimental/on-unhandled-frame.mjs +1 -0
- package/lib/core/experimental/on-unhandled-frame.mjs.map +1 -1
- package/lib/core/experimental/setup-api.d.mts +1 -1
- package/lib/core/experimental/setup-api.d.ts +1 -1
- package/lib/core/experimental/setup-api.js +2 -5
- package/lib/core/experimental/setup-api.js.map +1 -1
- package/lib/core/experimental/setup-api.mjs +2 -5
- package/lib/core/experimental/setup-api.mjs.map +1 -1
- package/lib/core/experimental/sources/interceptor-source.d.mts +2 -2
- package/lib/core/experimental/sources/interceptor-source.d.ts +2 -2
- package/lib/core/experimental/sources/interceptor-source.js +23 -10
- package/lib/core/experimental/sources/interceptor-source.js.map +1 -1
- package/lib/core/experimental/sources/interceptor-source.mjs +24 -13
- package/lib/core/experimental/sources/interceptor-source.mjs.map +1 -1
- package/lib/core/experimental/sources/network-source.d.mts +3 -3
- package/lib/core/experimental/sources/network-source.d.ts +3 -3
- package/lib/core/experimental/sources/network-source.js +1 -0
- package/lib/core/experimental/sources/network-source.js.map +1 -1
- package/lib/core/experimental/sources/network-source.mjs +2 -0
- package/lib/core/experimental/sources/network-source.mjs.map +1 -1
- package/lib/core/getResponse.d.mts +1 -1
- package/lib/core/getResponse.d.ts +1 -1
- package/lib/core/graphql.d.mts +1 -1
- package/lib/core/graphql.d.ts +1 -1
- package/lib/core/graphql.js +1 -0
- package/lib/core/graphql.js.map +1 -1
- package/lib/core/graphql.mjs +2 -0
- package/lib/core/graphql.mjs.map +1 -1
- package/lib/core/handlers/GraphQLHandler.d.mts +1 -1
- package/lib/core/handlers/GraphQLHandler.d.ts +1 -1
- package/lib/core/handlers/GraphQLHandler.js +1 -0
- package/lib/core/handlers/GraphQLHandler.js.map +1 -1
- package/lib/core/handlers/GraphQLHandler.mjs +4 -1
- package/lib/core/handlers/GraphQLHandler.mjs.map +1 -1
- package/lib/core/handlers/HttpHandler.d.mts +1 -1
- package/lib/core/handlers/HttpHandler.d.ts +1 -1
- package/lib/core/handlers/HttpHandler.js +1 -0
- package/lib/core/handlers/HttpHandler.js.map +1 -1
- package/lib/core/handlers/HttpHandler.mjs +1 -0
- package/lib/core/handlers/HttpHandler.mjs.map +1 -1
- package/lib/core/handlers/RequestHandler.d.mts +1 -1
- package/lib/core/handlers/RequestHandler.d.ts +1 -1
- package/lib/core/handlers/RequestHandler.js +197 -4
- package/lib/core/handlers/RequestHandler.js.map +1 -1
- package/lib/core/handlers/RequestHandler.mjs +198 -4
- package/lib/core/handlers/RequestHandler.mjs.map +1 -1
- package/lib/core/handlers/WebSocketHandler.d.mts +5 -2
- package/lib/core/handlers/WebSocketHandler.d.ts +5 -2
- package/lib/core/handlers/WebSocketHandler.js +30 -12
- package/lib/core/handlers/WebSocketHandler.js.map +1 -1
- package/lib/core/handlers/WebSocketHandler.mjs +30 -12
- package/lib/core/handlers/WebSocketHandler.mjs.map +1 -1
- package/lib/core/http.d.mts +1 -1
- package/lib/core/http.d.ts +1 -1
- package/lib/core/http.js +1 -0
- package/lib/core/http.js.map +1 -1
- package/lib/core/http.mjs +2 -0
- package/lib/core/http.mjs.map +1 -1
- package/lib/core/index.d.mts +1 -1
- package/lib/core/index.d.ts +1 -1
- package/lib/core/{network-frame-usYiHS0K.d.ts → on-unhandled-frame-0KmwUmeV.d.ts} +13 -13
- package/lib/core/{network-frame-B7A0ggXE.d.mts → on-unhandled-frame-gkokW4Rr.d.mts} +13 -13
- package/lib/core/passthrough.d.mts +1 -1
- package/lib/core/passthrough.d.ts +1 -1
- package/lib/core/sse.d.mts +4 -18
- package/lib/core/sse.d.ts +4 -18
- package/lib/core/sse.js +149 -66
- package/lib/core/sse.js.map +1 -1
- package/lib/core/sse.mjs +149 -66
- package/lib/core/sse.mjs.map +1 -1
- package/lib/core/utils/HttpResponse/decorators.d.mts +9 -4
- package/lib/core/utils/HttpResponse/decorators.d.ts +9 -4
- package/lib/core/utils/HttpResponse/decorators.js +18 -11
- package/lib/core/utils/HttpResponse/decorators.js.map +1 -1
- package/lib/core/utils/HttpResponse/decorators.mjs +18 -11
- package/lib/core/utils/HttpResponse/decorators.mjs.map +1 -1
- package/lib/core/utils/cookieStore.js.map +1 -1
- package/lib/core/utils/cookieStore.mjs.map +1 -1
- package/lib/core/utils/executeHandlers.d.mts +1 -1
- package/lib/core/utils/executeHandlers.d.ts +1 -1
- package/lib/core/utils/executeHandlers.js +1 -0
- package/lib/core/utils/executeHandlers.js.map +1 -1
- package/lib/core/utils/executeHandlers.mjs +1 -0
- package/lib/core/utils/executeHandlers.mjs.map +1 -1
- package/lib/core/utils/handleRequest.d.mts +1 -1
- package/lib/core/utils/handleRequest.d.ts +1 -1
- package/lib/core/utils/handleRequest.js.map +1 -1
- package/lib/core/utils/handleRequest.mjs.map +1 -1
- package/lib/core/utils/internal/Disposable.js +19 -1
- package/lib/core/utils/internal/Disposable.js.map +1 -1
- package/lib/core/utils/internal/Disposable.mjs +19 -1
- package/lib/core/utils/internal/Disposable.mjs.map +1 -1
- package/lib/core/utils/internal/attachSiblingHandlers.d.mts +15 -0
- package/lib/core/utils/internal/attachSiblingHandlers.d.ts +15 -0
- package/lib/core/utils/internal/attachSiblingHandlers.js +44 -0
- package/lib/core/utils/internal/attachSiblingHandlers.js.map +1 -0
- package/lib/core/utils/internal/attachSiblingHandlers.mjs +24 -0
- package/lib/core/utils/internal/attachSiblingHandlers.mjs.map +1 -0
- package/lib/core/utils/internal/isHandlerKind.d.mts +1 -1
- package/lib/core/utils/internal/isHandlerKind.d.ts +1 -1
- package/lib/core/utils/internal/observe-response-body-stream.d.mts +18 -0
- package/lib/core/utils/internal/observe-response-body-stream.d.ts +18 -0
- package/lib/core/utils/internal/observe-response-body-stream.js +64 -0
- package/lib/core/utils/internal/observe-response-body-stream.js.map +1 -0
- package/lib/core/utils/internal/observe-response-body-stream.mjs +44 -0
- package/lib/core/utils/internal/observe-response-body-stream.mjs.map +1 -0
- package/lib/core/utils/internal/parseGraphQLRequest.d.mts +1 -1
- package/lib/core/utils/internal/parseGraphQLRequest.d.ts +1 -1
- package/lib/core/utils/internal/parseMultipartData.d.mts +1 -1
- package/lib/core/utils/internal/parseMultipartData.d.ts +1 -1
- package/lib/core/utils/internal/parseMultipartData.js +1 -0
- package/lib/core/utils/internal/parseMultipartData.js.map +1 -1
- package/lib/core/utils/internal/parseMultipartData.mjs +1 -0
- package/lib/core/utils/internal/parseMultipartData.mjs.map +1 -1
- package/lib/core/utils/internal/pipeEvents.js +1 -0
- package/lib/core/utils/internal/pipeEvents.js.map +1 -1
- package/lib/core/utils/internal/pipeEvents.mjs +1 -0
- package/lib/core/utils/internal/pipeEvents.mjs.map +1 -1
- package/lib/core/utils/request/storeResponseCookies.js +1 -1
- package/lib/core/utils/request/storeResponseCookies.js.map +1 -1
- package/lib/core/utils/request/storeResponseCookies.mjs +2 -2
- package/lib/core/utils/request/storeResponseCookies.mjs.map +1 -1
- package/lib/core/ws/WebSocketClientManager.js +4 -0
- package/lib/core/ws/WebSocketClientManager.js.map +1 -1
- package/lib/core/ws/WebSocketClientManager.mjs +4 -0
- package/lib/core/ws/WebSocketClientManager.mjs.map +1 -1
- package/lib/core/ws/WebSocketIndexedDBClientStore.js +1 -0
- package/lib/core/ws/WebSocketIndexedDBClientStore.js.map +1 -1
- package/lib/core/ws/WebSocketIndexedDBClientStore.mjs +1 -0
- package/lib/core/ws/WebSocketIndexedDBClientStore.mjs.map +1 -1
- package/lib/core/ws/WebSocketMemoryClientStore.js +1 -0
- package/lib/core/ws/WebSocketMemoryClientStore.js.map +1 -1
- package/lib/core/ws/WebSocketMemoryClientStore.mjs +1 -0
- package/lib/core/ws/WebSocketMemoryClientStore.mjs.map +1 -1
- package/lib/core/ws/handleWebSocketEvent.d.mts +1 -1
- package/lib/core/ws/handleWebSocketEvent.d.ts +1 -1
- package/lib/core/ws/handleWebSocketEvent.js.map +1 -1
- package/lib/core/ws/handleWebSocketEvent.mjs.map +1 -1
- package/lib/core/ws.d.mts +17 -4
- package/lib/core/ws.d.ts +17 -4
- package/lib/core/ws.js +30 -5
- package/lib/core/ws.js.map +1 -1
- package/lib/core/ws.mjs +34 -6
- package/lib/core/ws.mjs.map +1 -1
- package/lib/iife/index.js +10138 -6034
- package/lib/iife/index.js.map +1 -1
- package/lib/mockServiceWorker.js +21 -9
- package/lib/native/index.js.map +1 -1
- package/lib/native/index.mjs.map +1 -1
- package/lib/node/index.d.mts +1 -1
- package/lib/node/index.d.ts +1 -1
- package/lib/node/index.js +2 -0
- package/lib/node/index.js.map +1 -1
- package/lib/node/index.mjs +1 -0
- package/lib/node/index.mjs.map +1 -1
- package/lib/shims/cookie.js +152 -62
- package/lib/shims/cookie.mjs +152 -62
- package/package.json +50 -69
- package/src/browser/glossary.ts +1 -1
- package/src/browser/setup-worker.ts +2 -2
- package/src/browser/sources/service-worker-source.ts +142 -40
- package/src/browser/utils/deserializeRequest.ts +2 -2
- package/src/browser/utils/pruneGetRequestBody.ts +3 -3
- package/src/browser/utils/should-invalidate-worker.test.ts +122 -0
- package/src/browser/utils/should-invalidate-worker.ts +13 -0
- package/src/browser/utils/workerChannel.ts +43 -21
- package/src/core/experimental/define-network.ts +44 -15
- package/src/core/experimental/frames/http-frame.test.ts +8 -2
- package/src/core/experimental/frames/http-frame.ts +12 -4
- package/src/core/experimental/frames/websocket-frame.test.ts +2 -4
- package/src/core/experimental/frames/websocket-frame.ts +3 -2
- package/src/core/experimental/handlers-controller.test.ts +139 -5
- package/src/core/experimental/handlers-controller.ts +39 -10
- package/src/core/experimental/index.ts +11 -1
- package/src/core/experimental/on-unhandled-frame.test.ts +2 -4
- package/src/core/experimental/setup-api.ts +4 -8
- package/src/core/experimental/sources/interceptor-source.ts +36 -16
- package/src/core/experimental/sources/network-source.ts +1 -1
- package/src/core/graphql.ts +8 -8
- package/src/core/handlers/GraphQLHandler.test.ts +3 -4
- package/src/core/handlers/GraphQLHandler.ts +15 -11
- package/src/core/handlers/HttpHandler.test.ts +92 -2
- package/src/core/handlers/HttpHandler.ts +7 -7
- package/src/core/handlers/RequestHandler.ts +329 -22
- package/src/core/handlers/WebSocketHandler.test.ts +58 -0
- package/src/core/handlers/WebSocketHandler.ts +37 -8
- package/src/core/http.ts +5 -5
- package/src/core/sse.ts +217 -73
- package/src/core/utils/HttpResponse/decorators.ts +28 -22
- package/src/core/utils/cookieStore.ts +1 -1
- package/src/core/utils/executeHandlers.ts +2 -4
- package/src/core/utils/handleRequest.test.ts +5 -4
- package/src/core/utils/handleRequest.ts +3 -3
- package/src/core/utils/internal/Disposable.ts +22 -1
- package/src/core/utils/internal/attachSiblingHandlers.ts +28 -0
- package/src/core/utils/internal/observe-response-body-stream.test.ts +64 -0
- package/src/core/utils/internal/observe-response-body-stream.ts +77 -0
- package/src/core/utils/internal/parseGraphQLRequest.test.ts +2 -4
- package/src/core/utils/internal/parseMultipartData.ts +1 -1
- package/src/core/utils/internal/pipeEvents.ts +2 -1
- package/src/core/utils/request/onUnhandledRequest.test.ts +2 -4
- package/src/core/utils/request/storeResponseCookies.ts +2 -4
- package/src/core/ws/WebSocketClientManager.test.ts +2 -4
- package/src/core/ws/WebSocketClientManager.ts +1 -1
- package/src/core/ws/WebSocketIndexedDBClientStore.ts +3 -5
- package/src/core/ws/WebSocketMemoryClientStore.ts +3 -5
- package/src/core/ws/handleWebSocketEvent.ts +3 -3
- package/src/core/ws.ts +66 -7
- package/src/mockServiceWorker.js +19 -7
- package/src/native/index.ts +2 -2
- package/src/node/async-handlers-controller.ts +2 -2
- package/src/node/index.ts +1 -0
- package/src/node/setup-server-common.ts +4 -4
- package/src/node/setup-server.ts +2 -2
- package/lib/core/utils/internal/requestHandlerUtils.d.mts +0 -12
- package/lib/core/utils/internal/requestHandlerUtils.d.ts +0 -12
- package/lib/core/utils/internal/requestHandlerUtils.js +0 -37
- package/lib/core/utils/internal/requestHandlerUtils.js.map +0 -1
- package/lib/core/utils/internal/requestHandlerUtils.mjs +0 -17
- package/lib/core/utils/internal/requestHandlerUtils.mjs.map +0 -1
- package/src/core/utils/internal/requestHandlerUtils.ts +0 -21
|
@@ -169,7 +169,22 @@ type AsyncResponseResolverReturnType<ResponseBodyType extends DefaultBodyType> =
|
|
|
169
169
|
type ResponseResolverInfo<ResolverExtraInfo extends Record<string, unknown>, RequestBodyType extends DefaultBodyType = DefaultBodyType> = {
|
|
170
170
|
request: StrictRequest<RequestBodyType>;
|
|
171
171
|
requestId: string;
|
|
172
|
+
/**
|
|
173
|
+
* Schedule a callback to run after this response resolver completes.
|
|
174
|
+
* Handy for cleaning up the side effects introduced in the resolver.
|
|
175
|
+
*
|
|
176
|
+
* For responses with a `ReadableStream` body (including `sse()` handlers),
|
|
177
|
+
* the callback runs once the response stream settles: it is read to
|
|
178
|
+
* completion, errored, or canceled, or the request is aborted.
|
|
179
|
+
* @example
|
|
180
|
+
* sse('/', ({ client, finalize }) => {
|
|
181
|
+
* const interval = setInterval(() => client.send({ data: 'ping' }))
|
|
182
|
+
* finalize(() => clearInterval(interval))
|
|
183
|
+
* })
|
|
184
|
+
*/
|
|
185
|
+
finalize: ResponseResolverFinalizeFunction;
|
|
172
186
|
} & ResolverExtraInfo;
|
|
187
|
+
type ResponseResolverFinalizeFunction = (callback: () => MaybePromise<void>) => void;
|
|
173
188
|
type ResponseResolver<ResolverExtraInfo extends Record<string, unknown> = Record<string, unknown>, RequestBodyType extends DefaultBodyType = DefaultBodyType, ResponseBodyType extends DefaultBodyType = undefined> = (info: ResponseResolverInfo<ResolverExtraInfo, RequestBodyType>) => AsyncResponseResolverReturnType<ResponseBodyType>;
|
|
174
189
|
interface RequestHandlerArgs<HandlerInfo, HandlerOptions extends RequestHandlerOptions> {
|
|
175
190
|
info: HandlerInfo;
|
|
@@ -192,7 +207,9 @@ declare abstract class RequestHandler<HandlerInfo extends RequestHandlerDefaultI
|
|
|
192
207
|
protected resolver: ResponseResolver<ResolverExtras, any, any>;
|
|
193
208
|
private resolverIterator?;
|
|
194
209
|
private resolverIteratorResult?;
|
|
210
|
+
private resolverIteratorCleanups?;
|
|
195
211
|
private options?;
|
|
212
|
+
private scheduledCleanups;
|
|
196
213
|
info: HandlerInfo & RequestHandlerInternalInfo;
|
|
197
214
|
/**
|
|
198
215
|
* Indicates whether this request handler has been used
|
|
@@ -200,6 +217,19 @@ declare abstract class RequestHandler<HandlerInfo extends RequestHandlerDefaultI
|
|
|
200
217
|
*/
|
|
201
218
|
isUsed: boolean;
|
|
202
219
|
constructor(args: RequestHandlerArgs<HandlerInfo, HandlerOptions>);
|
|
220
|
+
/**
|
|
221
|
+
* Reset the runtime state accumulated during response resolution,
|
|
222
|
+
* such as generator iterator progress. Called when this handler is
|
|
223
|
+
* removed from the active handlers list so re-adding it later starts
|
|
224
|
+
* from a clean state.
|
|
225
|
+
*/
|
|
226
|
+
protected reset(): void;
|
|
227
|
+
/**
|
|
228
|
+
* Restore this handler so it can match requests again after being
|
|
229
|
+
* exhausted (e.g. via `{ once: true }`). Also clears any accumulated
|
|
230
|
+
* resolution state.
|
|
231
|
+
*/
|
|
232
|
+
protected restore(): void;
|
|
203
233
|
/**
|
|
204
234
|
* Determine if the intercepted request should be mocked.
|
|
205
235
|
*/
|
|
@@ -251,7 +281,28 @@ declare abstract class RequestHandler<HandlerInfo extends RequestHandlerDefaultI
|
|
|
251
281
|
}): Promise<RequestHandlerExecutionResult<ParsedResult> | null>;
|
|
252
282
|
private wrapResolver;
|
|
253
283
|
private createExecutionResult;
|
|
284
|
+
private scheduleCleanup;
|
|
285
|
+
private exhaustCleanups;
|
|
286
|
+
/**
|
|
287
|
+
* Remove and return the cleanups scheduled for the given request
|
|
288
|
+
* (or the pending iterator cleanups for generator resolvers).
|
|
289
|
+
*/
|
|
290
|
+
private takeScheduledCleanups;
|
|
291
|
+
private runScheduledCleanups;
|
|
292
|
+
/**
|
|
293
|
+
* Conclude the response resolution for the given request.
|
|
294
|
+
* Runs the scheduled cleanups immediately for responses without a
|
|
295
|
+
* `ReadableStream` body. For streamed responses, returns an observed
|
|
296
|
+
* copy of the response and defers the cleanups until its body settles
|
|
297
|
+
* (is read to completion, errored, or canceled) or the request is
|
|
298
|
+
* aborted, whichever comes first.
|
|
299
|
+
*/
|
|
300
|
+
private complete;
|
|
254
301
|
}
|
|
302
|
+
/**
|
|
303
|
+
* Forwards the cookies from the given response to `document.cookie`.
|
|
304
|
+
*/
|
|
305
|
+
declare function forwardResponseCookies(response: Response): void;
|
|
255
306
|
|
|
256
307
|
interface HttpResponseInit extends ResponseInit {
|
|
257
308
|
type?: ResponseType;
|
|
@@ -335,4 +386,4 @@ declare class HttpResponse<BodyType extends DefaultBodyType> extends FetchRespon
|
|
|
335
386
|
static formData(body?: FormData, init?: HttpResponseInit): HttpResponse<FormData>;
|
|
336
387
|
}
|
|
337
388
|
|
|
338
|
-
export { type AsyncResponseResolverReturnType as A, type
|
|
389
|
+
export { type AsyncResponseResolverReturnType as A, type GraphQLCustomPredicateResult as B, type GraphQLHandlerInfo as C, type DefaultBodyType as D, type GraphQLHandlerNameSelector as E, type GraphQLRequestParsedResult as F, type GraphQLCustomPredicate as G, HttpResponse as H, isDocumentNode as I, type JsonBodyType as J, type RequestHandlerArgs as K, type RequestHandlerExecutionResult as L, type MaybeAsyncResponseResolverReturnType as M, type RequestHandlerInternalInfo as N, forwardResponseCookies as O, type ParsedGraphQLRequest as P, type DefaultUnsafeFetchResponse as Q, RequestHandler as R, type StrictRequest as S, bodyType as T, kDefaultContentType as U, type DefaultRequestMultipartBody as a, GraphQLHandler as b, type GraphQLJsonRequestBody as c, type GraphQLOperationType as d, type GraphQLQuery as e, type GraphQLRequestBody as f, type GraphQLResponseBody as g, type GraphQLVariables as h, type HttpResponseInit as i, type RequestHandlerOptions as j, type ResponseResolutionContext as k, type ResponseResolver as l, type ResponseResolverInfo as m, type ResponseResolverReturnType as n, type StrictResponse as o, type GraphQLPredicate as p, type GraphQLResolverExtras as q, type RequestHandlerDefaultInfo as r, type HandlersExecutionResult as s, executeHandlers as t, type GraphQLMultipartRequestBody as u, type GraphQLParsedOperationsMap as v, type ParsedGraphQLQuery as w, parseDocumentNode as x, parseGraphQLRequest as y, type DocumentTypeDecoration as z };
|
|
@@ -169,7 +169,22 @@ type AsyncResponseResolverReturnType<ResponseBodyType extends DefaultBodyType> =
|
|
|
169
169
|
type ResponseResolverInfo<ResolverExtraInfo extends Record<string, unknown>, RequestBodyType extends DefaultBodyType = DefaultBodyType> = {
|
|
170
170
|
request: StrictRequest<RequestBodyType>;
|
|
171
171
|
requestId: string;
|
|
172
|
+
/**
|
|
173
|
+
* Schedule a callback to run after this response resolver completes.
|
|
174
|
+
* Handy for cleaning up the side effects introduced in the resolver.
|
|
175
|
+
*
|
|
176
|
+
* For responses with a `ReadableStream` body (including `sse()` handlers),
|
|
177
|
+
* the callback runs once the response stream settles: it is read to
|
|
178
|
+
* completion, errored, or canceled, or the request is aborted.
|
|
179
|
+
* @example
|
|
180
|
+
* sse('/', ({ client, finalize }) => {
|
|
181
|
+
* const interval = setInterval(() => client.send({ data: 'ping' }))
|
|
182
|
+
* finalize(() => clearInterval(interval))
|
|
183
|
+
* })
|
|
184
|
+
*/
|
|
185
|
+
finalize: ResponseResolverFinalizeFunction;
|
|
172
186
|
} & ResolverExtraInfo;
|
|
187
|
+
type ResponseResolverFinalizeFunction = (callback: () => MaybePromise<void>) => void;
|
|
173
188
|
type ResponseResolver<ResolverExtraInfo extends Record<string, unknown> = Record<string, unknown>, RequestBodyType extends DefaultBodyType = DefaultBodyType, ResponseBodyType extends DefaultBodyType = undefined> = (info: ResponseResolverInfo<ResolverExtraInfo, RequestBodyType>) => AsyncResponseResolverReturnType<ResponseBodyType>;
|
|
174
189
|
interface RequestHandlerArgs<HandlerInfo, HandlerOptions extends RequestHandlerOptions> {
|
|
175
190
|
info: HandlerInfo;
|
|
@@ -192,7 +207,9 @@ declare abstract class RequestHandler<HandlerInfo extends RequestHandlerDefaultI
|
|
|
192
207
|
protected resolver: ResponseResolver<ResolverExtras, any, any>;
|
|
193
208
|
private resolverIterator?;
|
|
194
209
|
private resolverIteratorResult?;
|
|
210
|
+
private resolverIteratorCleanups?;
|
|
195
211
|
private options?;
|
|
212
|
+
private scheduledCleanups;
|
|
196
213
|
info: HandlerInfo & RequestHandlerInternalInfo;
|
|
197
214
|
/**
|
|
198
215
|
* Indicates whether this request handler has been used
|
|
@@ -200,6 +217,19 @@ declare abstract class RequestHandler<HandlerInfo extends RequestHandlerDefaultI
|
|
|
200
217
|
*/
|
|
201
218
|
isUsed: boolean;
|
|
202
219
|
constructor(args: RequestHandlerArgs<HandlerInfo, HandlerOptions>);
|
|
220
|
+
/**
|
|
221
|
+
* Reset the runtime state accumulated during response resolution,
|
|
222
|
+
* such as generator iterator progress. Called when this handler is
|
|
223
|
+
* removed from the active handlers list so re-adding it later starts
|
|
224
|
+
* from a clean state.
|
|
225
|
+
*/
|
|
226
|
+
protected reset(): void;
|
|
227
|
+
/**
|
|
228
|
+
* Restore this handler so it can match requests again after being
|
|
229
|
+
* exhausted (e.g. via `{ once: true }`). Also clears any accumulated
|
|
230
|
+
* resolution state.
|
|
231
|
+
*/
|
|
232
|
+
protected restore(): void;
|
|
203
233
|
/**
|
|
204
234
|
* Determine if the intercepted request should be mocked.
|
|
205
235
|
*/
|
|
@@ -251,7 +281,28 @@ declare abstract class RequestHandler<HandlerInfo extends RequestHandlerDefaultI
|
|
|
251
281
|
}): Promise<RequestHandlerExecutionResult<ParsedResult> | null>;
|
|
252
282
|
private wrapResolver;
|
|
253
283
|
private createExecutionResult;
|
|
284
|
+
private scheduleCleanup;
|
|
285
|
+
private exhaustCleanups;
|
|
286
|
+
/**
|
|
287
|
+
* Remove and return the cleanups scheduled for the given request
|
|
288
|
+
* (or the pending iterator cleanups for generator resolvers).
|
|
289
|
+
*/
|
|
290
|
+
private takeScheduledCleanups;
|
|
291
|
+
private runScheduledCleanups;
|
|
292
|
+
/**
|
|
293
|
+
* Conclude the response resolution for the given request.
|
|
294
|
+
* Runs the scheduled cleanups immediately for responses without a
|
|
295
|
+
* `ReadableStream` body. For streamed responses, returns an observed
|
|
296
|
+
* copy of the response and defers the cleanups until its body settles
|
|
297
|
+
* (is read to completion, errored, or canceled) or the request is
|
|
298
|
+
* aborted, whichever comes first.
|
|
299
|
+
*/
|
|
300
|
+
private complete;
|
|
254
301
|
}
|
|
302
|
+
/**
|
|
303
|
+
* Forwards the cookies from the given response to `document.cookie`.
|
|
304
|
+
*/
|
|
305
|
+
declare function forwardResponseCookies(response: Response): void;
|
|
255
306
|
|
|
256
307
|
interface HttpResponseInit extends ResponseInit {
|
|
257
308
|
type?: ResponseType;
|
|
@@ -335,4 +386,4 @@ declare class HttpResponse<BodyType extends DefaultBodyType> extends FetchRespon
|
|
|
335
386
|
static formData(body?: FormData, init?: HttpResponseInit): HttpResponse<FormData>;
|
|
336
387
|
}
|
|
337
388
|
|
|
338
|
-
export { type AsyncResponseResolverReturnType as A, type
|
|
389
|
+
export { type AsyncResponseResolverReturnType as A, type GraphQLCustomPredicateResult as B, type GraphQLHandlerInfo as C, type DefaultBodyType as D, type GraphQLHandlerNameSelector as E, type GraphQLRequestParsedResult as F, type GraphQLCustomPredicate as G, HttpResponse as H, isDocumentNode as I, type JsonBodyType as J, type RequestHandlerArgs as K, type RequestHandlerExecutionResult as L, type MaybeAsyncResponseResolverReturnType as M, type RequestHandlerInternalInfo as N, forwardResponseCookies as O, type ParsedGraphQLRequest as P, type DefaultUnsafeFetchResponse as Q, RequestHandler as R, type StrictRequest as S, bodyType as T, kDefaultContentType as U, type DefaultRequestMultipartBody as a, GraphQLHandler as b, type GraphQLJsonRequestBody as c, type GraphQLOperationType as d, type GraphQLQuery as e, type GraphQLRequestBody as f, type GraphQLResponseBody as g, type GraphQLVariables as h, type HttpResponseInit as i, type RequestHandlerOptions as j, type ResponseResolutionContext as k, type ResponseResolver as l, type ResponseResolverInfo as m, type ResponseResolverReturnType as n, type StrictResponse as o, type GraphQLPredicate as p, type GraphQLResolverExtras as q, type RequestHandlerDefaultInfo as r, type HandlersExecutionResult as s, executeHandlers as t, type GraphQLMultipartRequestBody as u, type GraphQLParsedOperationsMap as v, type ParsedGraphQLQuery as w, parseDocumentNode as x, parseGraphQLRequest as y, type DocumentTypeDecoration as z };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import '@mswjs/interceptors';
|
|
2
|
-
export { Q as DefaultUnsafeFetchResponse, H as HttpResponse,
|
|
2
|
+
export { Q as DefaultUnsafeFetchResponse, H as HttpResponse, i as HttpResponseInit, S as StrictRequest, o as StrictResponse, T as bodyType, U as kDefaultContentType } from './HttpResponse-BE_Y2Ak9.mjs';
|
|
3
3
|
import './typeUtils.mjs';
|
|
4
4
|
import './utils/internal/isIterable.mjs';
|
|
5
5
|
import 'graphql';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import '@mswjs/interceptors';
|
|
2
|
-
export { Q as DefaultUnsafeFetchResponse, H as HttpResponse,
|
|
2
|
+
export { Q as DefaultUnsafeFetchResponse, H as HttpResponse, i as HttpResponseInit, S as StrictRequest, o as StrictResponse, T as bodyType, U as kDefaultContentType } from './HttpResponse-DL-P1EeG.js';
|
|
3
3
|
import './typeUtils.js';
|
|
4
4
|
import './utils/internal/isIterable.js';
|
|
5
5
|
import 'graphql';
|
package/lib/core/HttpResponse.js
CHANGED
|
@@ -25,8 +25,8 @@ __export(HttpResponse_exports, {
|
|
|
25
25
|
module.exports = __toCommonJS(HttpResponse_exports);
|
|
26
26
|
var import_interceptors = require("@mswjs/interceptors");
|
|
27
27
|
var import_decorators = require("./utils/HttpResponse/decorators");
|
|
28
|
-
const bodyType = Symbol("bodyType");
|
|
29
|
-
const kDefaultContentType = Symbol.for("kDefaultContentType");
|
|
28
|
+
const bodyType = /* @__PURE__ */ Symbol("bodyType");
|
|
29
|
+
const kDefaultContentType = /* @__PURE__ */ Symbol.for("kDefaultContentType");
|
|
30
30
|
class HttpResponse extends import_interceptors.FetchResponse {
|
|
31
31
|
[bodyType] = null;
|
|
32
32
|
constructor(body, init) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/HttpResponse.ts"],"sourcesContent":["import { FetchResponse } from '@mswjs/interceptors'\nimport type { DefaultBodyType, JsonBodyType } from './handlers/RequestHandler'\nimport type { NoInfer } from './typeUtils'\nimport {\n decorateResponse,\n normalizeResponseInit,\n} from './utils/HttpResponse/decorators'\n\nexport interface HttpResponseInit extends ResponseInit {\n type?: ResponseType\n}\n\nexport const bodyType: unique symbol = Symbol('bodyType')\nexport type DefaultUnsafeFetchResponse = Response & {\n [bodyType]?: never\n}\n\nexport interface StrictRequest<BodyType extends JsonBodyType> extends Request {\n json(): Promise<BodyType>\n clone(): StrictRequest<BodyType>\n}\n\n/**\n * Opaque `Response` type that supports strict body type.\n *\n * @deprecated Please use {@link HttpResponse} instead.\n */\nexport type StrictResponse<BodyType extends DefaultBodyType> =\n HttpResponse<BodyType>\n\nexport const kDefaultContentType = Symbol.for('kDefaultContentType')\n\n/**\n * A drop-in replacement for the standard `Response` class\n * to allow additional features, like mocking the response `Set-Cookie` header.\n *\n * @example\n * new HttpResponse('Hello world', { status: 201 })\n * HttpResponse.json({ name: 'John' })\n * HttpResponse.formData(form)\n *\n * @see {@link https://mswjs.io/docs/api/http-response `HttpResponse` API reference}\n */\nexport class HttpResponse<\n BodyType extends DefaultBodyType,\n> extends FetchResponse {\n readonly [bodyType]: BodyType = null as any\n\n constructor(body?: NoInfer<BodyType> | null, init?: HttpResponseInit) {\n const responseInit = normalizeResponseInit(init)\n super(body as BodyInit, responseInit)\n decorateResponse(this, responseInit)\n }\n\n static error(): HttpResponse<any> {\n return super.error() as HttpResponse<any>\n }\n\n /**\n * Create a `Response` with a `Content-Type: \"text/plain\"` body.\n * @example\n * HttpResponse.text('hello world')\n * HttpResponse.text('Error', { status: 500 })\n */\n static text<BodyType extends string>(\n body?: NoInfer<BodyType> | null,\n init?: HttpResponseInit,\n ): HttpResponse<BodyType> {\n const responseInit = normalizeResponseInit(init)\n const hasExplicitContentType = responseInit.headers.has('Content-Type')\n\n if (!hasExplicitContentType) {\n responseInit.headers.set('Content-Type', 'text/plain')\n }\n\n // Automatically set the \"Content-Length\" response header\n // for non-empty text responses. This enforces consistency and\n // brings mocked responses closer to production.\n if (!responseInit.headers.has('Content-Length')) {\n responseInit.headers.set(\n 'Content-Length',\n body ? new Blob([body]).size.toString() : '0',\n )\n }\n\n const response = new HttpResponse(body, responseInit)\n\n if (!hasExplicitContentType) {\n Object.defineProperty(response, kDefaultContentType, {\n value: true,\n enumerable: false,\n })\n }\n\n return response\n }\n\n /**\n * Create a `Response` with a `Content-Type: \"application/json\"` body.\n * @example\n * HttpResponse.json({ firstName: 'John' })\n * HttpResponse.json({ error: 'Not Authorized' }, { status: 401 })\n */\n static json<BodyType extends JsonBodyType>(\n body?: NoInfer<BodyType> | null | undefined,\n init?: HttpResponseInit,\n ): HttpResponse<BodyType> {\n const responseInit = normalizeResponseInit(init)\n const hasExplicitContentType = responseInit.headers.has('Content-Type')\n\n if (!hasExplicitContentType) {\n responseInit.headers.set('Content-Type', 'application/json')\n }\n\n /**\n * @note TypeScript is incorrect here.\n * Stringifying undefined will return undefined.\n */\n const responseText = JSON.stringify(body) as string | undefined\n\n if (!responseInit.headers.has('Content-Length')) {\n responseInit.headers.set(\n 'Content-Length',\n responseText ? new Blob([responseText]).size.toString() : '0',\n )\n }\n\n const response = new HttpResponse(responseText, responseInit)\n\n if (!hasExplicitContentType) {\n Object.defineProperty(response, kDefaultContentType, {\n value: true,\n enumerable: false,\n })\n }\n\n return response as HttpResponse<BodyType>\n }\n\n /**\n * Create a `Response` with a `Content-Type: \"application/xml\"` body.\n * @example\n * HttpResponse.xml(`<user name=\"John\" />`)\n * HttpResponse.xml(`<article id=\"abc-123\" />`, { status: 201 })\n */\n static xml<BodyType extends string>(\n body?: BodyType | null,\n init?: HttpResponseInit,\n ): HttpResponse<BodyType> {\n const responseInit = normalizeResponseInit(init)\n const hasExplicitContentType = responseInit.headers.has('Content-Type')\n\n if (!hasExplicitContentType) {\n responseInit.headers.set('Content-Type', 'text/xml')\n }\n\n const response = new HttpResponse(body, responseInit)\n\n if (!hasExplicitContentType) {\n Object.defineProperty(response, kDefaultContentType, {\n value: true,\n enumerable: false,\n })\n }\n\n return response as HttpResponse<BodyType>\n }\n\n /**\n * Create a `Response` with a `Content-Type: \"text/html\"` body.\n * @example\n * HttpResponse.html(`<p class=\"author\">Jane Doe</p>`)\n * HttpResponse.html(`<main id=\"abc-123\">Main text</main>`, { status: 201 })\n */\n static html<BodyType extends string>(\n body?: BodyType | null,\n init?: HttpResponseInit,\n ): HttpResponse<BodyType> {\n const responseInit = normalizeResponseInit(init)\n const hasExplicitContentType = responseInit.headers.has('Content-Type')\n\n if (!hasExplicitContentType) {\n responseInit.headers.set('Content-Type', 'text/html')\n }\n\n const response = new HttpResponse(body, responseInit)\n\n if (!hasExplicitContentType) {\n Object.defineProperty(response, kDefaultContentType, {\n value: true,\n enumerable: false,\n })\n }\n\n return response as HttpResponse<BodyType>\n }\n\n /**\n * Create a `Response` with an `ArrayBuffer` body.\n * @example\n * const buffer = new ArrayBuffer(3)\n * const view = new Uint8Array(buffer)\n * view.set([1, 2, 3])\n *\n * HttpResponse.arrayBuffer(buffer)\n */\n static arrayBuffer<BodyType extends ArrayBuffer | SharedArrayBuffer>(\n body?: BodyType,\n init?: HttpResponseInit,\n ): HttpResponse<BodyType> {\n const responseInit = normalizeResponseInit(init)\n const hasExplicitContentType = responseInit.headers.has('Content-Type')\n\n if (!hasExplicitContentType) {\n responseInit.headers.set('Content-Type', 'application/octet-stream')\n }\n\n if (body && !responseInit.headers.has('Content-Length')) {\n responseInit.headers.set('Content-Length', body.byteLength.toString())\n }\n\n const response = new HttpResponse(body, responseInit)\n\n if (!hasExplicitContentType) {\n Object.defineProperty(response, kDefaultContentType, {\n value: true,\n enumerable: false,\n })\n }\n\n return response as HttpResponse<BodyType>\n }\n\n /**\n * Create a `Response` with a `FormData` body.\n * @example\n * const data = new FormData()\n * data.set('name', 'Alice')\n *\n * HttpResponse.formData(data)\n */\n static formData(\n body?: FormData,\n init?: HttpResponseInit,\n ): HttpResponse<FormData> {\n return new HttpResponse(body, normalizeResponseInit(init))\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAA8B;AAG9B,wBAGO;AAMA,MAAM,WAA0B,OAAO,UAAU;AAkBjD,MAAM,sBAAsB,OAAO,IAAI,qBAAqB;AAa5D,MAAM,qBAEH,kCAAc;AAAA,EACtB,CAAU,QAAQ,IAAc;AAAA,EAEhC,YAAY,MAAiC,MAAyB;AACpE,UAAM,mBAAe,yCAAsB,IAAI;AAC/C,UAAM,M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AQ,CAAC,aAAa,QAAQ,IAAI,gBAAgB,GAAG;AACvD,mBAAa,QAAQ,IAAI,kBAAkB,KAAK,WAAW,SAAS,CAAC;AAAA,IACvE;AAEA,UAAM,WAAW,IAAI,aAAa,MAAM,YAAY;AAEpD,QAAI,CAAC,wBAAwB;AAC3B,aAAO,eAAe,UAAU,qBAAqB;AAAA,QACnD,OAAO;AAAA,QACP,YAAY;AAAA,MACd,CAAC;AAAA,IACH;AAEA,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,OAAO,SACL,MACA,MACwB;AACxB,WAAO,IAAI,aAAa,UAAM,yCAAsB,IAAI,CAAC;AAAA,EAC3D;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/core/HttpResponse.ts"],"sourcesContent":["import { FetchResponse } from '@mswjs/interceptors'\nimport type { DefaultBodyType, JsonBodyType } from './handlers/RequestHandler'\nimport type { NoInfer } from './typeUtils'\nimport {\n decorateResponse,\n normalizeResponseInit,\n} from './utils/HttpResponse/decorators'\n\nexport interface HttpResponseInit extends ResponseInit {\n type?: ResponseType\n}\n\nexport const bodyType: unique symbol = Symbol('bodyType')\nexport type DefaultUnsafeFetchResponse = Response & {\n [bodyType]?: never\n}\n\nexport interface StrictRequest<BodyType extends JsonBodyType> extends Request {\n json(): Promise<BodyType>\n clone(): StrictRequest<BodyType>\n}\n\n/**\n * Opaque `Response` type that supports strict body type.\n *\n * @deprecated Please use {@link HttpResponse} instead.\n */\nexport type StrictResponse<BodyType extends DefaultBodyType> =\n HttpResponse<BodyType>\n\nexport const kDefaultContentType = Symbol.for('kDefaultContentType')\n\n/**\n * A drop-in replacement for the standard `Response` class\n * to allow additional features, like mocking the response `Set-Cookie` header.\n *\n * @example\n * new HttpResponse('Hello world', { status: 201 })\n * HttpResponse.json({ name: 'John' })\n * HttpResponse.formData(form)\n *\n * @see {@link https://mswjs.io/docs/api/http-response `HttpResponse` API reference}\n */\nexport class HttpResponse<\n BodyType extends DefaultBodyType,\n> extends FetchResponse {\n readonly [bodyType]: BodyType = null as any\n\n constructor(body?: NoInfer<BodyType> | null, init?: HttpResponseInit) {\n const responseInit = normalizeResponseInit(init)\n super(body as BodyInit, responseInit)\n decorateResponse(this, responseInit)\n }\n\n static error(): HttpResponse<any> {\n return super.error() as HttpResponse<any>\n }\n\n /**\n * Create a `Response` with a `Content-Type: \"text/plain\"` body.\n * @example\n * HttpResponse.text('hello world')\n * HttpResponse.text('Error', { status: 500 })\n */\n static text<BodyType extends string>(\n body?: NoInfer<BodyType> | null,\n init?: HttpResponseInit,\n ): HttpResponse<BodyType> {\n const responseInit = normalizeResponseInit(init)\n const hasExplicitContentType = responseInit.headers.has('Content-Type')\n\n if (!hasExplicitContentType) {\n responseInit.headers.set('Content-Type', 'text/plain')\n }\n\n // Automatically set the \"Content-Length\" response header\n // for non-empty text responses. This enforces consistency and\n // brings mocked responses closer to production.\n if (!responseInit.headers.has('Content-Length')) {\n responseInit.headers.set(\n 'Content-Length',\n body ? new Blob([body]).size.toString() : '0',\n )\n }\n\n const response = new HttpResponse(body, responseInit)\n\n if (!hasExplicitContentType) {\n Object.defineProperty(response, kDefaultContentType, {\n value: true,\n enumerable: false,\n })\n }\n\n return response\n }\n\n /**\n * Create a `Response` with a `Content-Type: \"application/json\"` body.\n * @example\n * HttpResponse.json({ firstName: 'John' })\n * HttpResponse.json({ error: 'Not Authorized' }, { status: 401 })\n */\n static json<BodyType extends JsonBodyType>(\n body?: NoInfer<BodyType> | null | undefined,\n init?: HttpResponseInit,\n ): HttpResponse<BodyType> {\n const responseInit = normalizeResponseInit(init)\n const hasExplicitContentType = responseInit.headers.has('Content-Type')\n\n if (!hasExplicitContentType) {\n responseInit.headers.set('Content-Type', 'application/json')\n }\n\n /**\n * @note TypeScript is incorrect here.\n * Stringifying undefined will return undefined.\n */\n const responseText = JSON.stringify(body) as string | undefined\n\n if (!responseInit.headers.has('Content-Length')) {\n responseInit.headers.set(\n 'Content-Length',\n responseText ? new Blob([responseText]).size.toString() : '0',\n )\n }\n\n const response = new HttpResponse(responseText, responseInit)\n\n if (!hasExplicitContentType) {\n Object.defineProperty(response, kDefaultContentType, {\n value: true,\n enumerable: false,\n })\n }\n\n return response as HttpResponse<BodyType>\n }\n\n /**\n * Create a `Response` with a `Content-Type: \"application/xml\"` body.\n * @example\n * HttpResponse.xml(`<user name=\"John\" />`)\n * HttpResponse.xml(`<article id=\"abc-123\" />`, { status: 201 })\n */\n static xml<BodyType extends string>(\n body?: BodyType | null,\n init?: HttpResponseInit,\n ): HttpResponse<BodyType> {\n const responseInit = normalizeResponseInit(init)\n const hasExplicitContentType = responseInit.headers.has('Content-Type')\n\n if (!hasExplicitContentType) {\n responseInit.headers.set('Content-Type', 'text/xml')\n }\n\n const response = new HttpResponse(body, responseInit)\n\n if (!hasExplicitContentType) {\n Object.defineProperty(response, kDefaultContentType, {\n value: true,\n enumerable: false,\n })\n }\n\n return response as HttpResponse<BodyType>\n }\n\n /**\n * Create a `Response` with a `Content-Type: \"text/html\"` body.\n * @example\n * HttpResponse.html(`<p class=\"author\">Jane Doe</p>`)\n * HttpResponse.html(`<main id=\"abc-123\">Main text</main>`, { status: 201 })\n */\n static html<BodyType extends string>(\n body?: BodyType | null,\n init?: HttpResponseInit,\n ): HttpResponse<BodyType> {\n const responseInit = normalizeResponseInit(init)\n const hasExplicitContentType = responseInit.headers.has('Content-Type')\n\n if (!hasExplicitContentType) {\n responseInit.headers.set('Content-Type', 'text/html')\n }\n\n const response = new HttpResponse(body, responseInit)\n\n if (!hasExplicitContentType) {\n Object.defineProperty(response, kDefaultContentType, {\n value: true,\n enumerable: false,\n })\n }\n\n return response as HttpResponse<BodyType>\n }\n\n /**\n * Create a `Response` with an `ArrayBuffer` body.\n * @example\n * const buffer = new ArrayBuffer(3)\n * const view = new Uint8Array(buffer)\n * view.set([1, 2, 3])\n *\n * HttpResponse.arrayBuffer(buffer)\n */\n static arrayBuffer<BodyType extends ArrayBuffer | SharedArrayBuffer>(\n body?: BodyType,\n init?: HttpResponseInit,\n ): HttpResponse<BodyType> {\n const responseInit = normalizeResponseInit(init)\n const hasExplicitContentType = responseInit.headers.has('Content-Type')\n\n if (!hasExplicitContentType) {\n responseInit.headers.set('Content-Type', 'application/octet-stream')\n }\n\n if (body && !responseInit.headers.has('Content-Length')) {\n responseInit.headers.set('Content-Length', body.byteLength.toString())\n }\n\n const response = new HttpResponse(body, responseInit)\n\n if (!hasExplicitContentType) {\n Object.defineProperty(response, kDefaultContentType, {\n value: true,\n enumerable: false,\n })\n }\n\n return response as HttpResponse<BodyType>\n }\n\n /**\n * Create a `Response` with a `FormData` body.\n * @example\n * const data = new FormData()\n * data.set('name', 'Alice')\n *\n * HttpResponse.formData(data)\n */\n static formData(\n body?: FormData,\n init?: HttpResponseInit,\n ): HttpResponse<FormData> {\n return new HttpResponse(body, normalizeResponseInit(init))\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAA8B;AAG9B,wBAGO;AAMA,MAAM,WAA0B,uBAAO,UAAU;AAkBjD,MAAM,sBAAsB,uBAAO,IAAI,qBAAqB;AAa5D,MAAM,qBAEH,kCAAc;AAAA,EACtB,CAAU,QAAQ,IAAc;AAAA,EAEhC,YAAY,MAAiC,MAAyB;AACpE,UAAM,mBAAe,yCAAsB,IAAI;AAC/C,UAAM,MAAkB,YAAY;AACpC,4CAAiB,MAAM,YAAY;AAAA,EACrC;AAAA,EAEA,OAAO,QAA2B;AAChC,WAAO,MAAM,MAAM;AAAA,EACrB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,OAAO,KACL,MACA,MACwB;AACxB,UAAM,mBAAe,yCAAsB,IAAI;AAC/C,UAAM,yBAAyB,aAAa,QAAQ,IAAI,cAAc;AAEtE,QAAI,CAAC,wBAAwB;AAC3B,mBAAa,QAAQ,IAAI,gBAAgB,YAAY;AAAA,IACv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AAA;AAAA;AAAA,EAUA,OAAO,SACL,MACA,MACwB;AACxB,WAAO,IAAI,aAAa,UAAM,yCAAsB,IAAI,CAAC;AAAA,EAC3D;AACF;","names":[]}
|
|
@@ -3,8 +3,8 @@ import {
|
|
|
3
3
|
decorateResponse,
|
|
4
4
|
normalizeResponseInit
|
|
5
5
|
} from './utils/HttpResponse/decorators.mjs';
|
|
6
|
-
const bodyType = Symbol("bodyType");
|
|
7
|
-
const kDefaultContentType = Symbol.for("kDefaultContentType");
|
|
6
|
+
const bodyType = /* @__PURE__ */ Symbol("bodyType");
|
|
7
|
+
const kDefaultContentType = /* @__PURE__ */ Symbol.for("kDefaultContentType");
|
|
8
8
|
class HttpResponse extends FetchResponse {
|
|
9
9
|
[bodyType] = null;
|
|
10
10
|
constructor(body, init) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/HttpResponse.ts"],"sourcesContent":["import { FetchResponse } from '@mswjs/interceptors'\nimport type { DefaultBodyType, JsonBodyType } from './handlers/RequestHandler'\nimport type { NoInfer } from './typeUtils'\nimport {\n decorateResponse,\n normalizeResponseInit,\n} from './utils/HttpResponse/decorators'\n\nexport interface HttpResponseInit extends ResponseInit {\n type?: ResponseType\n}\n\nexport const bodyType: unique symbol = Symbol('bodyType')\nexport type DefaultUnsafeFetchResponse = Response & {\n [bodyType]?: never\n}\n\nexport interface StrictRequest<BodyType extends JsonBodyType> extends Request {\n json(): Promise<BodyType>\n clone(): StrictRequest<BodyType>\n}\n\n/**\n * Opaque `Response` type that supports strict body type.\n *\n * @deprecated Please use {@link HttpResponse} instead.\n */\nexport type StrictResponse<BodyType extends DefaultBodyType> =\n HttpResponse<BodyType>\n\nexport const kDefaultContentType = Symbol.for('kDefaultContentType')\n\n/**\n * A drop-in replacement for the standard `Response` class\n * to allow additional features, like mocking the response `Set-Cookie` header.\n *\n * @example\n * new HttpResponse('Hello world', { status: 201 })\n * HttpResponse.json({ name: 'John' })\n * HttpResponse.formData(form)\n *\n * @see {@link https://mswjs.io/docs/api/http-response `HttpResponse` API reference}\n */\nexport class HttpResponse<\n BodyType extends DefaultBodyType,\n> extends FetchResponse {\n readonly [bodyType]: BodyType = null as any\n\n constructor(body?: NoInfer<BodyType> | null, init?: HttpResponseInit) {\n const responseInit = normalizeResponseInit(init)\n super(body as BodyInit, responseInit)\n decorateResponse(this, responseInit)\n }\n\n static error(): HttpResponse<any> {\n return super.error() as HttpResponse<any>\n }\n\n /**\n * Create a `Response` with a `Content-Type: \"text/plain\"` body.\n * @example\n * HttpResponse.text('hello world')\n * HttpResponse.text('Error', { status: 500 })\n */\n static text<BodyType extends string>(\n body?: NoInfer<BodyType> | null,\n init?: HttpResponseInit,\n ): HttpResponse<BodyType> {\n const responseInit = normalizeResponseInit(init)\n const hasExplicitContentType = responseInit.headers.has('Content-Type')\n\n if (!hasExplicitContentType) {\n responseInit.headers.set('Content-Type', 'text/plain')\n }\n\n // Automatically set the \"Content-Length\" response header\n // for non-empty text responses. This enforces consistency and\n // brings mocked responses closer to production.\n if (!responseInit.headers.has('Content-Length')) {\n responseInit.headers.set(\n 'Content-Length',\n body ? new Blob([body]).size.toString() : '0',\n )\n }\n\n const response = new HttpResponse(body, responseInit)\n\n if (!hasExplicitContentType) {\n Object.defineProperty(response, kDefaultContentType, {\n value: true,\n enumerable: false,\n })\n }\n\n return response\n }\n\n /**\n * Create a `Response` with a `Content-Type: \"application/json\"` body.\n * @example\n * HttpResponse.json({ firstName: 'John' })\n * HttpResponse.json({ error: 'Not Authorized' }, { status: 401 })\n */\n static json<BodyType extends JsonBodyType>(\n body?: NoInfer<BodyType> | null | undefined,\n init?: HttpResponseInit,\n ): HttpResponse<BodyType> {\n const responseInit = normalizeResponseInit(init)\n const hasExplicitContentType = responseInit.headers.has('Content-Type')\n\n if (!hasExplicitContentType) {\n responseInit.headers.set('Content-Type', 'application/json')\n }\n\n /**\n * @note TypeScript is incorrect here.\n * Stringifying undefined will return undefined.\n */\n const responseText = JSON.stringify(body) as string | undefined\n\n if (!responseInit.headers.has('Content-Length')) {\n responseInit.headers.set(\n 'Content-Length',\n responseText ? new Blob([responseText]).size.toString() : '0',\n )\n }\n\n const response = new HttpResponse(responseText, responseInit)\n\n if (!hasExplicitContentType) {\n Object.defineProperty(response, kDefaultContentType, {\n value: true,\n enumerable: false,\n })\n }\n\n return response as HttpResponse<BodyType>\n }\n\n /**\n * Create a `Response` with a `Content-Type: \"application/xml\"` body.\n * @example\n * HttpResponse.xml(`<user name=\"John\" />`)\n * HttpResponse.xml(`<article id=\"abc-123\" />`, { status: 201 })\n */\n static xml<BodyType extends string>(\n body?: BodyType | null,\n init?: HttpResponseInit,\n ): HttpResponse<BodyType> {\n const responseInit = normalizeResponseInit(init)\n const hasExplicitContentType = responseInit.headers.has('Content-Type')\n\n if (!hasExplicitContentType) {\n responseInit.headers.set('Content-Type', 'text/xml')\n }\n\n const response = new HttpResponse(body, responseInit)\n\n if (!hasExplicitContentType) {\n Object.defineProperty(response, kDefaultContentType, {\n value: true,\n enumerable: false,\n })\n }\n\n return response as HttpResponse<BodyType>\n }\n\n /**\n * Create a `Response` with a `Content-Type: \"text/html\"` body.\n * @example\n * HttpResponse.html(`<p class=\"author\">Jane Doe</p>`)\n * HttpResponse.html(`<main id=\"abc-123\">Main text</main>`, { status: 201 })\n */\n static html<BodyType extends string>(\n body?: BodyType | null,\n init?: HttpResponseInit,\n ): HttpResponse<BodyType> {\n const responseInit = normalizeResponseInit(init)\n const hasExplicitContentType = responseInit.headers.has('Content-Type')\n\n if (!hasExplicitContentType) {\n responseInit.headers.set('Content-Type', 'text/html')\n }\n\n const response = new HttpResponse(body, responseInit)\n\n if (!hasExplicitContentType) {\n Object.defineProperty(response, kDefaultContentType, {\n value: true,\n enumerable: false,\n })\n }\n\n return response as HttpResponse<BodyType>\n }\n\n /**\n * Create a `Response` with an `ArrayBuffer` body.\n * @example\n * const buffer = new ArrayBuffer(3)\n * const view = new Uint8Array(buffer)\n * view.set([1, 2, 3])\n *\n * HttpResponse.arrayBuffer(buffer)\n */\n static arrayBuffer<BodyType extends ArrayBuffer | SharedArrayBuffer>(\n body?: BodyType,\n init?: HttpResponseInit,\n ): HttpResponse<BodyType> {\n const responseInit = normalizeResponseInit(init)\n const hasExplicitContentType = responseInit.headers.has('Content-Type')\n\n if (!hasExplicitContentType) {\n responseInit.headers.set('Content-Type', 'application/octet-stream')\n }\n\n if (body && !responseInit.headers.has('Content-Length')) {\n responseInit.headers.set('Content-Length', body.byteLength.toString())\n }\n\n const response = new HttpResponse(body, responseInit)\n\n if (!hasExplicitContentType) {\n Object.defineProperty(response, kDefaultContentType, {\n value: true,\n enumerable: false,\n })\n }\n\n return response as HttpResponse<BodyType>\n }\n\n /**\n * Create a `Response` with a `FormData` body.\n * @example\n * const data = new FormData()\n * data.set('name', 'Alice')\n *\n * HttpResponse.formData(data)\n */\n static formData(\n body?: FormData,\n init?: HttpResponseInit,\n ): HttpResponse<FormData> {\n return new HttpResponse(body, normalizeResponseInit(init))\n }\n}\n"],"mappings":"AAAA,SAAS,qBAAqB;AAG9B;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAMA,MAAM,WAA0B,OAAO,UAAU;AAkBjD,MAAM,sBAAsB,OAAO,IAAI,qBAAqB;AAa5D,MAAM,qBAEH,cAAc;AAAA,EACtB,CAAU,QAAQ,IAAc;AAAA,EAEhC,YAAY,MAAiC,MAAyB;AACpE,UAAM,eAAe,sBAAsB,IAAI;AAC/C,UAAM,MAAkB,YAAY;AACpC,qBAAiB,MAAM,YAAY;AAAA,EACrC;AAAA,EAEA,OAAO,QAA2B;AAChC,WAAO,MAAM,MAAM;AAAA,EACrB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,OAAO,KACL,MACA,MACwB;AACxB,UAAM,eAAe,sBAAsB,IAAI;AAC/C,UAAM,yBAAyB,aAAa,QAAQ,IAAI,cAAc;AAEtE,QAAI,CAAC,wBAAwB;AAC3B,mBAAa,QAAQ,IAAI,gBAAg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AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,OAAO,SACL,MACA,MACwB;AACxB,WAAO,IAAI,aAAa,MAAM,sBAAsB,IAAI,CAAC;AAAA,EAC3D;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/core/HttpResponse.ts"],"sourcesContent":["import { FetchResponse } from '@mswjs/interceptors'\nimport type { DefaultBodyType, JsonBodyType } from './handlers/RequestHandler'\nimport type { NoInfer } from './typeUtils'\nimport {\n decorateResponse,\n normalizeResponseInit,\n} from './utils/HttpResponse/decorators'\n\nexport interface HttpResponseInit extends ResponseInit {\n type?: ResponseType\n}\n\nexport const bodyType: unique symbol = Symbol('bodyType')\nexport type DefaultUnsafeFetchResponse = Response & {\n [bodyType]?: never\n}\n\nexport interface StrictRequest<BodyType extends JsonBodyType> extends Request {\n json(): Promise<BodyType>\n clone(): StrictRequest<BodyType>\n}\n\n/**\n * Opaque `Response` type that supports strict body type.\n *\n * @deprecated Please use {@link HttpResponse} instead.\n */\nexport type StrictResponse<BodyType extends DefaultBodyType> =\n HttpResponse<BodyType>\n\nexport const kDefaultContentType = Symbol.for('kDefaultContentType')\n\n/**\n * A drop-in replacement for the standard `Response` class\n * to allow additional features, like mocking the response `Set-Cookie` header.\n *\n * @example\n * new HttpResponse('Hello world', { status: 201 })\n * HttpResponse.json({ name: 'John' })\n * HttpResponse.formData(form)\n *\n * @see {@link https://mswjs.io/docs/api/http-response `HttpResponse` API reference}\n */\nexport class HttpResponse<\n BodyType extends DefaultBodyType,\n> extends FetchResponse {\n readonly [bodyType]: BodyType = null as any\n\n constructor(body?: NoInfer<BodyType> | null, init?: HttpResponseInit) {\n const responseInit = normalizeResponseInit(init)\n super(body as BodyInit, responseInit)\n decorateResponse(this, responseInit)\n }\n\n static error(): HttpResponse<any> {\n return super.error() as HttpResponse<any>\n }\n\n /**\n * Create a `Response` with a `Content-Type: \"text/plain\"` body.\n * @example\n * HttpResponse.text('hello world')\n * HttpResponse.text('Error', { status: 500 })\n */\n static text<BodyType extends string>(\n body?: NoInfer<BodyType> | null,\n init?: HttpResponseInit,\n ): HttpResponse<BodyType> {\n const responseInit = normalizeResponseInit(init)\n const hasExplicitContentType = responseInit.headers.has('Content-Type')\n\n if (!hasExplicitContentType) {\n responseInit.headers.set('Content-Type', 'text/plain')\n }\n\n // Automatically set the \"Content-Length\" response header\n // for non-empty text responses. This enforces consistency and\n // brings mocked responses closer to production.\n if (!responseInit.headers.has('Content-Length')) {\n responseInit.headers.set(\n 'Content-Length',\n body ? new Blob([body]).size.toString() : '0',\n )\n }\n\n const response = new HttpResponse(body, responseInit)\n\n if (!hasExplicitContentType) {\n Object.defineProperty(response, kDefaultContentType, {\n value: true,\n enumerable: false,\n })\n }\n\n return response\n }\n\n /**\n * Create a `Response` with a `Content-Type: \"application/json\"` body.\n * @example\n * HttpResponse.json({ firstName: 'John' })\n * HttpResponse.json({ error: 'Not Authorized' }, { status: 401 })\n */\n static json<BodyType extends JsonBodyType>(\n body?: NoInfer<BodyType> | null | undefined,\n init?: HttpResponseInit,\n ): HttpResponse<BodyType> {\n const responseInit = normalizeResponseInit(init)\n const hasExplicitContentType = responseInit.headers.has('Content-Type')\n\n if (!hasExplicitContentType) {\n responseInit.headers.set('Content-Type', 'application/json')\n }\n\n /**\n * @note TypeScript is incorrect here.\n * Stringifying undefined will return undefined.\n */\n const responseText = JSON.stringify(body) as string | undefined\n\n if (!responseInit.headers.has('Content-Length')) {\n responseInit.headers.set(\n 'Content-Length',\n responseText ? new Blob([responseText]).size.toString() : '0',\n )\n }\n\n const response = new HttpResponse(responseText, responseInit)\n\n if (!hasExplicitContentType) {\n Object.defineProperty(response, kDefaultContentType, {\n value: true,\n enumerable: false,\n })\n }\n\n return response as HttpResponse<BodyType>\n }\n\n /**\n * Create a `Response` with a `Content-Type: \"application/xml\"` body.\n * @example\n * HttpResponse.xml(`<user name=\"John\" />`)\n * HttpResponse.xml(`<article id=\"abc-123\" />`, { status: 201 })\n */\n static xml<BodyType extends string>(\n body?: BodyType | null,\n init?: HttpResponseInit,\n ): HttpResponse<BodyType> {\n const responseInit = normalizeResponseInit(init)\n const hasExplicitContentType = responseInit.headers.has('Content-Type')\n\n if (!hasExplicitContentType) {\n responseInit.headers.set('Content-Type', 'text/xml')\n }\n\n const response = new HttpResponse(body, responseInit)\n\n if (!hasExplicitContentType) {\n Object.defineProperty(response, kDefaultContentType, {\n value: true,\n enumerable: false,\n })\n }\n\n return response as HttpResponse<BodyType>\n }\n\n /**\n * Create a `Response` with a `Content-Type: \"text/html\"` body.\n * @example\n * HttpResponse.html(`<p class=\"author\">Jane Doe</p>`)\n * HttpResponse.html(`<main id=\"abc-123\">Main text</main>`, { status: 201 })\n */\n static html<BodyType extends string>(\n body?: BodyType | null,\n init?: HttpResponseInit,\n ): HttpResponse<BodyType> {\n const responseInit = normalizeResponseInit(init)\n const hasExplicitContentType = responseInit.headers.has('Content-Type')\n\n if (!hasExplicitContentType) {\n responseInit.headers.set('Content-Type', 'text/html')\n }\n\n const response = new HttpResponse(body, responseInit)\n\n if (!hasExplicitContentType) {\n Object.defineProperty(response, kDefaultContentType, {\n value: true,\n enumerable: false,\n })\n }\n\n return response as HttpResponse<BodyType>\n }\n\n /**\n * Create a `Response` with an `ArrayBuffer` body.\n * @example\n * const buffer = new ArrayBuffer(3)\n * const view = new Uint8Array(buffer)\n * view.set([1, 2, 3])\n *\n * HttpResponse.arrayBuffer(buffer)\n */\n static arrayBuffer<BodyType extends ArrayBuffer | SharedArrayBuffer>(\n body?: BodyType,\n init?: HttpResponseInit,\n ): HttpResponse<BodyType> {\n const responseInit = normalizeResponseInit(init)\n const hasExplicitContentType = responseInit.headers.has('Content-Type')\n\n if (!hasExplicitContentType) {\n responseInit.headers.set('Content-Type', 'application/octet-stream')\n }\n\n if (body && !responseInit.headers.has('Content-Length')) {\n responseInit.headers.set('Content-Length', body.byteLength.toString())\n }\n\n const response = new HttpResponse(body, responseInit)\n\n if (!hasExplicitContentType) {\n Object.defineProperty(response, kDefaultContentType, {\n value: true,\n enumerable: false,\n })\n }\n\n return response as HttpResponse<BodyType>\n }\n\n /**\n * Create a `Response` with a `FormData` body.\n * @example\n * const data = new FormData()\n * data.set('name', 'Alice')\n *\n * HttpResponse.formData(data)\n */\n static formData(\n body?: FormData,\n init?: HttpResponseInit,\n ): HttpResponse<FormData> {\n return new HttpResponse(body, normalizeResponseInit(init))\n }\n}\n"],"mappings":"AAAA,SAAS,qBAAqB;AAG9B;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAMA,MAAM,WAA0B,uBAAO,UAAU;AAkBjD,MAAM,sBAAsB,uBAAO,IAAI,qBAAqB;AAa5D,MAAM,qBAEH,cAAc;AAAA,EACtB,CAAU,QAAQ,IAAc;AAAA,EAEhC,YAAY,MAAiC,MAAyB;AACpE,UAAM,eAAe,sBAAsB,IAAI;AAC/C,UAAM,MAAkB,YAAY;AACpC,qBAAiB,MAAM,YAAY;AAAA,EACrC;AAAA,EAEA,OAAO,QAA2B;AAChC,WAAO,MAAM,MAAM;AAAA,EACrB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,OAAO,KACL,MACA,MACwB;AACxB,UAAM,eAAe,sBAAsB,IAAI;AAC/C,UAAM,yBAAyB,aAAa,QAAQ,IAAI,cAAc;AAEtE,QAAI,CAAC,wBAAwB;AAC3B,mBAAa,QAAQ,IAAI,gBAAgB,YAAY;AAAA,IACvD;AAKA,QAAI,CAAC,aAAa,QAAQ,IAAI,gBAAgB,GAAG;AAC/C,mBAAa,QAAQ;AAAA,QACnB;AAAA,QACA,OAAO,IAAI,KAAK,CAAC,IAAI,CAAC,EAAE,KAAK,SAAS,IAAI;AAAA,MAC5C;AAAA,IACF;AAEA,UAAM,WAAW,IAAI,aAAa,MAAM,YAAY;AAEpD,QAAI,CAAC,wBAAwB;AAC3B,aAAO,eAAe,UAAU,qBAAqB;AAAA,QACnD,OAAO;AAAA,QACP,YAAY;AAAA,MACd,CAAC;AAAA,IACH;AAEA,WAAO;AA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AAC,wBAAwB;AAC3B,mBAAa,QAAQ,IAAI,gBAAgB,WAAW;AAAA,IACtD;AAEA,UAAM,WAAW,IAAI,aAAa,MAAM,YAAY;AAEpD,QAAI,CAAC,wBAAwB;AAC3B,aAAO,eAAe,UAAU,qBAAqB;AAAA,QACnD,OAAO;AAAA,QACP,YAAY;AAAA,MACd,CAAC;AAAA,IACH;AAEA,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,OAAO,YACL,MACA,MACwB;AACxB,UAAM,eAAe,sBAAsB,IAAI;AAC/C,UAAM,yBAAyB,aAAa,QAAQ,IAAI,cAAc;AAEtE,QAAI,CAAC,wBAAwB;AAC3B,mBAAa,QAAQ,IAAI,gBAAgB,0BAA0B;AAAA,IACrE;AAEA,QAAI,QAAQ,CAAC,aAAa,QAAQ,IAAI,gBAAgB,GAAG;AACvD,mBAAa,QAAQ,IAAI,kBAAkB,KAAK,WAAW,SAAS,CAAC;AAAA,IACvE;AAEA,UAAM,WAAW,IAAI,aAAa,MAAM,YAAY;AAEpD,QAAI,CAAC,wBAAwB;AAC3B,aAAO,eAAe,UAAU,qBAAqB;AAAA,QACnD,OAAO;AAAA,QACP,YAAY;AAAA,MACd,CAAC;AAAA,IACH;AAEA,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,OAAO,SACL,MACA,MACwB;AACxB,WAAO,IAAI,aAAa,MAAM,sBAAsB,IAAI,CAAC;AAAA,EAC3D;AACF;","names":[]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { UnhandledRequestStrategy } from '../utils/request/onUnhandledRequest.mjs';
|
|
2
|
-
import { U as UnhandledFrameCallback } from '../
|
|
2
|
+
import { U as UnhandledFrameCallback } from '../on-unhandled-frame-gkokW4Rr.mjs';
|
|
3
3
|
import 'rettime';
|
|
4
4
|
import './handlers-controller.mjs';
|
|
5
|
-
import '../HttpResponse-
|
|
5
|
+
import '../HttpResponse-BE_Y2Ak9.mjs';
|
|
6
6
|
import '@mswjs/interceptors';
|
|
7
7
|
import '../utils/internal/isIterable.mjs';
|
|
8
8
|
import '../typeUtils.mjs';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { UnhandledRequestStrategy } from '../utils/request/onUnhandledRequest.js';
|
|
2
|
-
import { U as UnhandledFrameCallback } from '../
|
|
2
|
+
import { U as UnhandledFrameCallback } from '../on-unhandled-frame-0KmwUmeV.js';
|
|
3
3
|
import 'rettime';
|
|
4
4
|
import './handlers-controller.js';
|
|
5
|
-
import '../HttpResponse-
|
|
5
|
+
import '../HttpResponse-DL-P1EeG.js';
|
|
6
6
|
import '@mswjs/interceptors';
|
|
7
7
|
import '../utils/internal/isIterable.js';
|
|
8
8
|
import '../typeUtils.js';
|
|
@@ -22,6 +22,7 @@ __export(compat_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(compat_exports);
|
|
24
24
|
var import_outvariant = require("outvariant");
|
|
25
|
+
var import_onUnhandledRequest = require("../utils/request/onUnhandledRequest");
|
|
25
26
|
var import_on_unhandled_frame = require("./on-unhandled-frame");
|
|
26
27
|
var import_http_frame = require("./frames/http-frame");
|
|
27
28
|
var import_websocket_frame = require("./frames/websocket-frame");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/core/experimental/compat.ts"],"sourcesContent":["/**\n * Collection of helpers for bridging the compatibility between the old and the new APIs.\n */\nimport { invariant } from 'outvariant'\nimport { type UnhandledRequestStrategy } from '../utils/request/onUnhandledRequest'\nimport {\n executeUnhandledFrameHandle,\n type UnhandledFrameCallback,\n} from './on-unhandled-frame'\nimport { HttpNetworkFrame } from './frames/http-frame'\nimport { WebSocketNetworkFrame } from './frames/websocket-frame'\n\nexport function fromLegacyOnUnhandledRequest(\n getLegacyValue: () => UnhandledRequestStrategy | undefined,\n): UnhandledFrameCallback {\n return ({ frame, defaults }) => {\n const legacyOnUnhandledRequestStrategy = getLegacyValue()\n\n if (legacyOnUnhandledRequestStrategy == null) {\n return\n }\n\n if (typeof legacyOnUnhandledRequestStrategy === 'function') {\n const request =\n frame instanceof HttpNetworkFrame\n ? frame.data.request\n : frame instanceof WebSocketNetworkFrame\n ? new Request(frame.data.connection.client.url, {\n headers: {\n connection: 'upgrade',\n upgrade: 'websocket',\n },\n })\n : null\n\n invariant(\n request != null,\n 'Failed to coerce a network frame to a legacy `onUnhandledRequest` strategy: unknown frame protocol \"%s\"',\n frame.protocol,\n )\n\n return legacyOnUnhandledRequestStrategy(request, {\n warning: defaults.warn,\n error: defaults.error,\n })\n }\n\n return executeUnhandledFrameHandle(frame, legacyOnUnhandledRequestStrategy)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,wBAA0B;
|
|
1
|
+
{"version":3,"sources":["../../../src/core/experimental/compat.ts"],"sourcesContent":["/**\n * Collection of helpers for bridging the compatibility between the old and the new APIs.\n */\nimport { invariant } from 'outvariant'\nimport { type UnhandledRequestStrategy } from '../utils/request/onUnhandledRequest'\nimport {\n executeUnhandledFrameHandle,\n type UnhandledFrameCallback,\n} from './on-unhandled-frame'\nimport { HttpNetworkFrame } from './frames/http-frame'\nimport { WebSocketNetworkFrame } from './frames/websocket-frame'\n\nexport function fromLegacyOnUnhandledRequest(\n getLegacyValue: () => UnhandledRequestStrategy | undefined,\n): UnhandledFrameCallback {\n return ({ frame, defaults }) => {\n const legacyOnUnhandledRequestStrategy = getLegacyValue()\n\n if (legacyOnUnhandledRequestStrategy == null) {\n return\n }\n\n if (typeof legacyOnUnhandledRequestStrategy === 'function') {\n const request =\n frame instanceof HttpNetworkFrame\n ? frame.data.request\n : frame instanceof WebSocketNetworkFrame\n ? new Request(frame.data.connection.client.url, {\n headers: {\n connection: 'upgrade',\n upgrade: 'websocket',\n },\n })\n : null\n\n invariant(\n request != null,\n 'Failed to coerce a network frame to a legacy `onUnhandledRequest` strategy: unknown frame protocol \"%s\"',\n frame.protocol,\n )\n\n return legacyOnUnhandledRequestStrategy(request, {\n warning: defaults.warn,\n error: defaults.error,\n })\n }\n\n return executeUnhandledFrameHandle(frame, legacyOnUnhandledRequestStrategy)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,wBAA0B;AAC1B,gCAA8C;AAC9C,gCAGO;AACP,wBAAiC;AACjC,6BAAsC;AAE/B,SAAS,6BACd,gBACwB;AACxB,SAAO,CAAC,EAAE,OAAO,SAAS,MAAM;AAC9B,UAAM,mCAAmC,eAAe;AAExD,QAAI,oCAAoC,MAAM;AAC5C;AAAA,IACF;AAEA,QAAI,OAAO,qCAAqC,YAAY;AAC1D,YAAM,UACJ,iBAAiB,qCACb,MAAM,KAAK,UACX,iBAAiB,+CACf,IAAI,QAAQ,MAAM,KAAK,WAAW,OAAO,KAAK;AAAA,QAC5C,SAAS;AAAA,UACP,YAAY;AAAA,UACZ,SAAS;AAAA,QACX;AAAA,MACF,CAAC,IACD;AAER;AAAA,QACE,WAAW;AAAA,QACX;AAAA,QACA,MAAM;AAAA,MACR;AAEA,aAAO,iCAAiC,SAAS;AAAA,QAC/C,SAAS,SAAS;AAAA,QAClB,OAAO,SAAS;AAAA,MAClB,CAAC;AAAA,IACH;AAEA,eAAO,uDAA4B,OAAO,gCAAgC;AAAA,EAC5E;AACF;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/core/experimental/compat.ts"],"sourcesContent":["/**\n * Collection of helpers for bridging the compatibility between the old and the new APIs.\n */\nimport { invariant } from 'outvariant'\nimport { type UnhandledRequestStrategy } from '../utils/request/onUnhandledRequest'\nimport {\n executeUnhandledFrameHandle,\n type UnhandledFrameCallback,\n} from './on-unhandled-frame'\nimport { HttpNetworkFrame } from './frames/http-frame'\nimport { WebSocketNetworkFrame } from './frames/websocket-frame'\n\nexport function fromLegacyOnUnhandledRequest(\n getLegacyValue: () => UnhandledRequestStrategy | undefined,\n): UnhandledFrameCallback {\n return ({ frame, defaults }) => {\n const legacyOnUnhandledRequestStrategy = getLegacyValue()\n\n if (legacyOnUnhandledRequestStrategy == null) {\n return\n }\n\n if (typeof legacyOnUnhandledRequestStrategy === 'function') {\n const request =\n frame instanceof HttpNetworkFrame\n ? frame.data.request\n : frame instanceof WebSocketNetworkFrame\n ? new Request(frame.data.connection.client.url, {\n headers: {\n connection: 'upgrade',\n upgrade: 'websocket',\n },\n })\n : null\n\n invariant(\n request != null,\n 'Failed to coerce a network frame to a legacy `onUnhandledRequest` strategy: unknown frame protocol \"%s\"',\n frame.protocol,\n )\n\n return legacyOnUnhandledRequestStrategy(request, {\n warning: defaults.warn,\n error: defaults.error,\n })\n }\n\n return executeUnhandledFrameHandle(frame, legacyOnUnhandledRequestStrategy)\n }\n}\n"],"mappings":"AAGA,SAAS,iBAAiB;
|
|
1
|
+
{"version":3,"sources":["../../../src/core/experimental/compat.ts"],"sourcesContent":["/**\n * Collection of helpers for bridging the compatibility between the old and the new APIs.\n */\nimport { invariant } from 'outvariant'\nimport { type UnhandledRequestStrategy } from '../utils/request/onUnhandledRequest'\nimport {\n executeUnhandledFrameHandle,\n type UnhandledFrameCallback,\n} from './on-unhandled-frame'\nimport { HttpNetworkFrame } from './frames/http-frame'\nimport { WebSocketNetworkFrame } from './frames/websocket-frame'\n\nexport function fromLegacyOnUnhandledRequest(\n getLegacyValue: () => UnhandledRequestStrategy | undefined,\n): UnhandledFrameCallback {\n return ({ frame, defaults }) => {\n const legacyOnUnhandledRequestStrategy = getLegacyValue()\n\n if (legacyOnUnhandledRequestStrategy == null) {\n return\n }\n\n if (typeof legacyOnUnhandledRequestStrategy === 'function') {\n const request =\n frame instanceof HttpNetworkFrame\n ? frame.data.request\n : frame instanceof WebSocketNetworkFrame\n ? new Request(frame.data.connection.client.url, {\n headers: {\n connection: 'upgrade',\n upgrade: 'websocket',\n },\n })\n : null\n\n invariant(\n request != null,\n 'Failed to coerce a network frame to a legacy `onUnhandledRequest` strategy: unknown frame protocol \"%s\"',\n frame.protocol,\n )\n\n return legacyOnUnhandledRequestStrategy(request, {\n warning: defaults.warn,\n error: defaults.error,\n })\n }\n\n return executeUnhandledFrameHandle(frame, legacyOnUnhandledRequestStrategy)\n }\n}\n"],"mappings":"AAGA,SAAS,iBAAiB;AAC1B,eAA8C;AAC9C;AAAA,EACE;AAAA,OAEK;AACP,SAAS,wBAAwB;AACjC,SAAS,6BAA6B;AAE/B,SAAS,6BACd,gBACwB;AACxB,SAAO,CAAC,EAAE,OAAO,SAAS,MAAM;AAC9B,UAAM,mCAAmC,eAAe;AAExD,QAAI,oCAAoC,MAAM;AAC5C;AAAA,IACF;AAEA,QAAI,OAAO,qCAAqC,YAAY;AAC1D,YAAM,UACJ,iBAAiB,mBACb,MAAM,KAAK,UACX,iBAAiB,wBACf,IAAI,QAAQ,MAAM,KAAK,WAAW,OAAO,KAAK;AAAA,QAC5C,SAAS;AAAA,UACP,YAAY;AAAA,UACZ,SAAS;AAAA,QACX;AAAA,MACF,CAAC,IACD;AAER;AAAA,QACE,WAAW;AAAA,QACX;AAAA,QACA,MAAM;AAAA,MACR;AAEA,aAAO,iCAAiC,SAAS;AAAA,QAC/C,SAAS,SAAS;AAAA,QAClB,OAAO,SAAS;AAAA,MAClB,CAAC;AAAA,IACH;AAEA,WAAO,4BAA4B,OAAO,gCAAgC;AAAA,EAC5E;AACF;","names":[]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Emitter, DefaultEventMap } from 'rettime';
|
|
2
2
|
import { NetworkSource, ExtractSourceEvents } from './sources/network-source.mjs';
|
|
3
|
-
import { a as NetworkFrameResolutionContext, b as UnhandledFrameHandle } from '../
|
|
3
|
+
import { a as NetworkFrameResolutionContext, b as UnhandledFrameHandle } from '../on-unhandled-frame-gkokW4Rr.mjs';
|
|
4
4
|
import { AnyHandler, HandlersController } from './handlers-controller.mjs';
|
|
5
|
-
import '../HttpResponse-
|
|
5
|
+
import '../HttpResponse-BE_Y2Ak9.mjs';
|
|
6
6
|
import '@mswjs/interceptors';
|
|
7
7
|
import '../utils/internal/isIterable.mjs';
|
|
8
8
|
import '../typeUtils.mjs';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Emitter, DefaultEventMap } from 'rettime';
|
|
2
2
|
import { NetworkSource, ExtractSourceEvents } from './sources/network-source.js';
|
|
3
|
-
import { a as NetworkFrameResolutionContext, b as UnhandledFrameHandle } from '../
|
|
3
|
+
import { a as NetworkFrameResolutionContext, b as UnhandledFrameHandle } from '../on-unhandled-frame-0KmwUmeV.js';
|
|
4
4
|
import { AnyHandler, HandlersController } from './handlers-controller.js';
|
|
5
|
-
import '../HttpResponse-
|
|
5
|
+
import '../HttpResponse-DL-P1EeG.js';
|
|
6
6
|
import '@mswjs/interceptors';
|
|
7
7
|
import '../utils/internal/isIterable.js';
|
|
8
8
|
import '../typeUtils.js';
|
|
@@ -24,8 +24,12 @@ __export(define_network_exports, {
|
|
|
24
24
|
module.exports = __toCommonJS(define_network_exports);
|
|
25
25
|
var import_outvariant = require("outvariant");
|
|
26
26
|
var import_rettime = require("rettime");
|
|
27
|
+
var import_network_source = require("./sources/network-source");
|
|
28
|
+
var import_network_frame = require("./frames/network-frame");
|
|
29
|
+
var import_on_unhandled_frame = require("./on-unhandled-frame");
|
|
27
30
|
var import_handlers_controller = require("./handlers-controller");
|
|
28
31
|
var import_toReadonlyArray = require("../utils/internal/toReadonlyArray");
|
|
32
|
+
var import_Disposable = require("../utils/internal/Disposable");
|
|
29
33
|
function colorlessPromiseAll(values) {
|
|
30
34
|
const promises = [];
|
|
31
35
|
for (const value of values) {
|
|
@@ -46,6 +50,7 @@ var NetworkReadyState = /* @__PURE__ */ ((NetworkReadyState2) => {
|
|
|
46
50
|
function defineNetwork(options) {
|
|
47
51
|
let readyState = 0 /* DISABLED */;
|
|
48
52
|
const events = new import_rettime.Emitter();
|
|
53
|
+
const disposable = new import_Disposable.Disposable();
|
|
49
54
|
const deriveHandlersController = (handlers) => {
|
|
50
55
|
return handlers instanceof import_handlers_controller.HandlersController ? handlers : new import_handlers_controller.InMemoryHandlersController(handlers || []);
|
|
51
56
|
};
|
|
@@ -53,14 +58,16 @@ function defineNetwork(options) {
|
|
|
53
58
|
...options
|
|
54
59
|
};
|
|
55
60
|
let handlersController = deriveHandlersController(resolvedOptions.handlers);
|
|
56
|
-
let listenersController;
|
|
57
61
|
return {
|
|
58
62
|
get readyState() {
|
|
59
63
|
return readyState;
|
|
60
64
|
},
|
|
61
65
|
events,
|
|
62
66
|
configure(options2) {
|
|
63
|
-
(0, import_outvariant.invariant)(
|
|
67
|
+
(0, import_outvariant.invariant)(
|
|
68
|
+
readyState === 0 /* DISABLED */,
|
|
69
|
+
'Failed to call "configure()" on the network: cannot configure an already enabled network.'
|
|
70
|
+
);
|
|
64
71
|
if (options2.handlers && !Object.is(options2.handlers, resolvedOptions.handlers)) {
|
|
65
72
|
handlersController = deriveHandlersController(options2.handlers);
|
|
66
73
|
}
|
|
@@ -74,12 +81,19 @@ function defineNetwork(options) {
|
|
|
74
81
|
readyState === 0 /* DISABLED */,
|
|
75
82
|
'Failed to call "enable" on the network: already enabled'
|
|
76
83
|
);
|
|
77
|
-
listenersController = new AbortController();
|
|
78
84
|
readyState = 1 /* ENABLED */;
|
|
85
|
+
const session = { active: true };
|
|
86
|
+
disposable["subscriptions"].push(() => {
|
|
87
|
+
session.active = false;
|
|
88
|
+
});
|
|
79
89
|
const result = resolvedOptions.sources.map((source) => {
|
|
90
|
+
import_network_source.NetworkSource.prototype.disable.call(source);
|
|
80
91
|
source.on("frame", async ({ frame }) => {
|
|
81
|
-
frame.events.on("*", (event) =>
|
|
82
|
-
|
|
92
|
+
frame.events.on("*", (event) => {
|
|
93
|
+
if (!session.active) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
events.emit(event);
|
|
83
97
|
});
|
|
84
98
|
const handlers = frame.getHandlers(handlersController);
|
|
85
99
|
await frame.resolve(
|
|
@@ -97,8 +111,8 @@ function defineNetwork(options) {
|
|
|
97
111
|
readyState === 1 /* ENABLED */,
|
|
98
112
|
'Failed to call "disable" on the network: already disabled'
|
|
99
113
|
);
|
|
100
|
-
listenersController.abort();
|
|
101
114
|
readyState = 0 /* DISABLED */;
|
|
115
|
+
disposable.dispose();
|
|
102
116
|
return colorlessPromiseAll(
|
|
103
117
|
resolvedOptions.sources.map((source) => source.disable())
|
|
104
118
|
);
|
|
@@ -110,11 +124,7 @@ function defineNetwork(options) {
|
|
|
110
124
|
handlersController.reset(handlers);
|
|
111
125
|
},
|
|
112
126
|
restoreHandlers() {
|
|
113
|
-
|
|
114
|
-
if ("isUsed" in handler) {
|
|
115
|
-
handler.isUsed = false;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
127
|
+
handlersController.restore();
|
|
118
128
|
},
|
|
119
129
|
listHandlers() {
|
|
120
130
|
return (0, import_toReadonlyArray.toReadonlyArray)(handlersController.currentHandlers());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/core/experimental/define-network.ts"],"sourcesContent":["import { invariant } from 'outvariant'\nimport { Emitter, type DefaultEventMap } from 'rettime'\nimport {\n
|
|
1
|
+
{"version":3,"sources":["../../../src/core/experimental/define-network.ts"],"sourcesContent":["import { invariant } from 'outvariant'\nimport { Emitter, type DefaultEventMap } from 'rettime'\nimport {\n NetworkSource,\n type ExtractSourceEvents,\n} from './sources/network-source'\nimport { type NetworkFrameResolutionContext } from './frames/network-frame'\nimport { type UnhandledFrameHandle } from './on-unhandled-frame'\nimport {\n HandlersController,\n InMemoryHandlersController,\n type AnyHandler,\n} from './handlers-controller'\nimport { toReadonlyArray } from '../utils/internal/toReadonlyArray'\nimport { Disposable } from '../utils/internal/Disposable'\n\ntype UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (\n k: infer I,\n) => void\n ? I\n : never\n\ntype MergeEventMaps<Sources extends Array<NetworkSource<any>>> =\n UnionToIntersection<ExtractSourceEvents<Sources[number]>> extends infer R\n ? R extends Record<string, any>\n ? R\n : DefaultEventMap\n : DefaultEventMap\n\ntype MaybePromise<T> =\n Extract<T, Promise<unknown>> extends never ? void : Promise<void>\n\nexport interface DefineNetworkOptions<\n Sources extends Array<NetworkSource<any>>,\n> {\n /**\n * List of the network sources.\n * Every network source emits frames, and every frame describes how\n * to handle the various network scenarios, like mocking a response,\n * erroring the request, or performing it as-is.\n */\n sources: Sources\n /**\n * List of handlers to describe the network.\n */\n handlers?: Array<AnyHandler> | HandlersController\n context?: NetworkFrameResolutionContext\n onUnhandledFrame?: UnhandledFrameHandle\n}\n\nexport interface NetworkApi<\n Sources extends Array<NetworkSource<any>>,\n> extends NetworkHandlersApi {\n readyState: NetworkReadyState\n /**\n * Enable the network interception and handling.\n */\n enable: () => MaybePromise<ReturnType<Sources[number]['enable']>>\n /**\n * Disable the network interception and handling.\n */\n disable: () => MaybePromise<ReturnType<Sources[number]['disable']>>\n /**\n * Configure the network instance with additional options.\n * The options provided in the `.configure()` call will override the same\n * options in the `defineNetwork()` call.\n */\n configure: (options: Partial<DefineNetworkOptions<Sources>>) => void\n events: Emitter<MergeEventMaps<Sources>>\n}\n\nexport interface NetworkHandlersApi {\n use: (...handlers: Array<AnyHandler>) => void\n resetHandlers: (...handlers: Array<AnyHandler>) => void\n restoreHandlers: () => void\n listHandlers: () => ReadonlyArray<AnyHandler>\n}\n\nfunction colorlessPromiseAll<T>(values: Array<T>): MaybePromise<T>\nfunction colorlessPromiseAll(values: Array<unknown>): Promise<void> | void {\n const promises: Array<Promise<void>> = []\n\n for (const value of values) {\n if (value instanceof Promise) {\n promises.push(value)\n }\n }\n\n if (promises.length > 0) {\n return Promise.all(promises).then(() => {})\n }\n}\n\nexport enum NetworkReadyState {\n DISABLED,\n ENABLED,\n}\n\n/**\n * Define a network instance with the given configuration.\n * @example\n * import { InterceptorSource } from 'msw/experimental'\n * import { handlers } from './handlers'\n *\n * const network = defineNetwork({\n * sources: [new InterceptorSource({ interceptors })],\n * handlers,\n * })\n * await network.enable()\n */\nexport function defineNetwork<Sources extends Array<NetworkSource<any>>>(\n options: DefineNetworkOptions<Sources>,\n): NetworkApi<Sources> {\n let readyState: NetworkReadyState = NetworkReadyState.DISABLED\n const events = new Emitter<MergeEventMaps<Sources>>()\n const disposable = new Disposable()\n\n const deriveHandlersController = (\n handlers: DefineNetworkOptions<Sources>['handlers'],\n ) => {\n return handlers instanceof HandlersController\n ? handlers\n : new InMemoryHandlersController(handlers || [])\n }\n\n let resolvedOptions: DefineNetworkOptions<Sources> = {\n ...options,\n }\n\n /**\n * @note Create the handlers controller immediately because\n * certain setup APIs, like `setupServer`, don't await `.enable` (`.listen`).\n */\n let handlersController = deriveHandlersController(resolvedOptions.handlers)\n\n return {\n get readyState() {\n return readyState\n },\n events,\n configure(options) {\n invariant(\n readyState === NetworkReadyState.DISABLED,\n 'Failed to call \"configure()\" on the network: cannot configure an already enabled network.',\n )\n\n if (\n options.handlers &&\n !Object.is(options.handlers, resolvedOptions.handlers)\n ) {\n handlersController = deriveHandlersController(options.handlers)\n }\n\n resolvedOptions = {\n ...resolvedOptions,\n ...options,\n }\n },\n enable() {\n invariant(\n readyState === NetworkReadyState.DISABLED,\n 'Failed to call \"enable\" on the network: already enabled',\n )\n\n readyState = NetworkReadyState.ENABLED\n\n /**\n * @note Use a session object scoped to the current \"enable()\"\n * to prevent \"frame.events\" listeners from surviving across enable/disable cycles.\n * @see The note about `AbortController` below.\n */\n const session = { active: true }\n disposable['subscriptions'].push(() => {\n session.active = false\n })\n\n const result = resolvedOptions.sources.map((source) => {\n /**\n * @note Preemptively disable the network source before enabling.\n * This intentionally calls only the prototype method that clears the\n * event listeners and nothing else. This prevents the \"frame\" listeners\n * from accumulating across enable/disable in case the source is a singleton.\n */\n NetworkSource.prototype.disable.call(source)\n\n source.on('frame', async ({ frame }) => {\n frame.events.on('*', (event) => {\n /**\n * @note Prevent event forwarding manually and not via an AbortController\n * because certain runtimes, like Cloudflare, throw when referencing an\n * AbortController created in a different context. Bear in mind that the frame\n * events run in the patched request client context while the AbortController\n * is created outside, in the \"defineNetwork\" closure, which is a test context.\n */\n if (!session.active) {\n return\n }\n\n events.emit(event)\n })\n\n const handlers = frame.getHandlers(handlersController)\n\n await frame.resolve(\n handlers,\n resolvedOptions.onUnhandledFrame || 'warn',\n resolvedOptions.context,\n )\n })\n\n return source.enable()\n })\n\n return colorlessPromiseAll(result) as MaybePromise<\n ReturnType<Sources[number]['enable']>\n >\n },\n disable() {\n invariant(\n readyState === NetworkReadyState.ENABLED,\n 'Failed to call \"disable\" on the network: already disabled',\n )\n\n readyState = NetworkReadyState.DISABLED\n disposable.dispose()\n\n return colorlessPromiseAll(\n resolvedOptions.sources.map((source) => source.disable()),\n ) as MaybePromise<ReturnType<Sources[number]['disable']>>\n },\n use(...handlers) {\n handlersController.use(handlers)\n },\n resetHandlers(...handlers) {\n handlersController.reset(handlers)\n },\n restoreHandlers() {\n handlersController.restore()\n },\n listHandlers() {\n return toReadonlyArray(handlersController.currentHandlers())\n },\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAA0B;AAC1B,qBAA8C;AAC9C,4BAGO;AACP,2BAAmD;AACnD,gCAA0C;AAC1C,iCAIO;AACP,6BAAgC;AAChC,wBAA2B;AAiE3B,SAAS,oBAAoB,QAA8C;AACzE,QAAM,WAAiC,CAAC;AAExC,aAAW,SAAS,QAAQ;AAC1B,QAAI,iBAAiB,SAAS;AAC5B,eAAS,KAAK,KAAK;AAAA,IACrB;AAAA,EACF;AAEA,MAAI,SAAS,SAAS,GAAG;AACvB,WAAO,QAAQ,IAAI,QAAQ,EAAE,KAAK,MAAM;AAAA,IAAC,CAAC;AAAA,EAC5C;AACF;AAEO,IAAK,oBAAL,kBAAKA,uBAAL;AACL,EAAAA,sCAAA;AACA,EAAAA,sCAAA;AAFU,SAAAA;AAA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