import { Emitter, DefaultEventMap } from 'rettime'; import { NetworkSource, ExtractSourceEvents } from './sources/network-source.js'; import { a as NetworkFrameResolutionContext, b as UnhandledFrameHandle } from '../on-unhandled-frame-BBR-P3kV.js'; import { AnyHandler, HandlersController } from './handlers-controller.js'; import '../HttpResponse-aGiIzO91.js'; import '@mswjs/interceptors'; import '../utils/internal/isIterable.js'; import '../typeUtils.js'; import 'graphql'; import '../utils/matching/matchRequestUrl.js'; import '../handlers/WebSocketHandler.js'; import 'strict-event-emitter'; import '@mswjs/interceptors/WebSocket'; type UnionToIntersection = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never; type MergeEventMaps>> = UnionToIntersection> extends infer R ? R extends Record ? R : DefaultEventMap : DefaultEventMap; type MaybePromise = Extract> extends never ? void : Promise; interface DefineNetworkOptions>> { /** * List of the network sources. * Every network source emits frames, and every frame describes how * to handle the various network scenarios, like mocking a response, * erroring the request, or performing it as-is. */ sources: Sources; /** * List of handlers to describe the network. */ handlers?: Array | HandlersController; context?: NetworkFrameResolutionContext; onUnhandledFrame?: UnhandledFrameHandle; } interface NetworkApi>> extends NetworkHandlersApi { readyState: NetworkReadyState; /** * Enable the network interception and handling. */ enable: () => MaybePromise>; /** * Disable the network interception and handling. */ disable: () => MaybePromise>; /** * Configure the network instance with additional options. * The options provided in the `.configure()` call will override the same * options in the `defineNetwork()` call. */ configure: (options: Partial>) => void; events: Emitter>; } interface NetworkHandlersApi { use: (...handlers: Array) => void; resetHandlers: (...handlers: Array) => void; restoreHandlers: () => void; listHandlers: () => ReadonlyArray; } declare enum NetworkReadyState { DISABLED = 0, ENABLED = 1 } /** * Define a network instance with the given configuration. * @example * import { InterceptorSource } from 'msw/experimental' * import { handlers } from './handlers' * * const network = defineNetwork({ * sources: [new InterceptorSource({ interceptors })], * handlers, * }) * await network.enable() */ declare function defineNetwork>>(options: DefineNetworkOptions): NetworkApi; export { type DefineNetworkOptions, type NetworkApi, type NetworkHandlersApi, NetworkReadyState, defineNetwork };