msw 2.14.2 → 2.14.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/browser/index.js +88 -38
- package/lib/browser/index.js.map +1 -1
- package/lib/browser/index.mjs +88 -38
- package/lib/browser/index.mjs.map +1 -1
- package/lib/core/experimental/sources/interceptor-source.js +14 -10
- package/lib/core/experimental/sources/interceptor-source.js.map +1 -1
- package/lib/core/experimental/sources/interceptor-source.mjs +14 -10
- package/lib/core/experimental/sources/interceptor-source.mjs.map +1 -1
- package/lib/iife/index.js +102 -48
- package/lib/iife/index.js.map +1 -1
- package/lib/mockServiceWorker.js +1 -1
- package/package.json +5 -4
- package/src/browser/sources/service-worker-source.ts +17 -12
- package/src/core/experimental/sources/interceptor-source.ts +20 -10
|
@@ -72,16 +72,20 @@ class InterceptorSource extends import_network_source.NetworkSource {
|
|
|
72
72
|
return;
|
|
73
73
|
}
|
|
74
74
|
queueMicrotask(() => {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
75
|
+
try {
|
|
76
|
+
httpFrame.events.emit(
|
|
77
|
+
new import_http_frame.ResponseEvent(
|
|
78
|
+
isMockedResponse ? "response:mocked" : "response:bypass",
|
|
79
|
+
{
|
|
80
|
+
requestId,
|
|
81
|
+
request,
|
|
82
|
+
response
|
|
83
|
+
}
|
|
84
|
+
)
|
|
85
|
+
);
|
|
86
|
+
} finally {
|
|
87
|
+
httpFrame.events.removeAllListeners();
|
|
88
|
+
}
|
|
85
89
|
});
|
|
86
90
|
}
|
|
87
91
|
async #handleWebSocketConnection(connection) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/core/experimental/sources/interceptor-source.ts"],"sourcesContent":["import type { Interceptor, RequestController } from '@mswjs/interceptors'\nimport { BatchInterceptor, type HttpRequestEventMap } from '@mswjs/interceptors'\nimport type {\n WebSocketConnectionData,\n WebSocketEventMap,\n} from '@mswjs/interceptors/WebSocket'\nimport { NetworkSource } from './network-source'\nimport { InternalError } from '../../utils/internal/devUtils'\nimport { HttpNetworkFrame, ResponseEvent } from '../frames/http-frame'\nimport { WebSocketNetworkFrame } from '../frames/websocket-frame'\nimport { deleteRequestPassthroughHeader } from '../request-utils'\n\nexport interface InterceptorSourceOptions {\n interceptors: Array<Interceptor<HttpRequestEventMap | WebSocketEventMap>>\n}\n\n/**\n * Create a network source from the given list of interceptors.\n */\nexport class InterceptorSource extends NetworkSource {\n #interceptor: BatchInterceptor<\n InterceptorSourceOptions['interceptors'],\n HttpRequestEventMap | WebSocketEventMap\n >\n\n #frames: Map<string, HttpNetworkFrame>\n\n constructor(options: InterceptorSourceOptions) {\n super()\n\n this.#interceptor = new BatchInterceptor({\n name: 'interceptor-source',\n interceptors: options.interceptors,\n })\n this.#frames = new Map()\n }\n\n public enable(): void {\n this.#interceptor.apply()\n\n /**\n * @todo @fixme BatchInterceptor infers event types but not listener types.\n */\n this.#interceptor\n .on('request', this.#handleRequest.bind(this) as any)\n .on('response', this.#handleResponse.bind(this) as any)\n .on('connection', this.#handleWebSocketConnection.bind(this) as any)\n }\n\n public disable(): void {\n super.disable()\n this.#interceptor.dispose()\n\n /**\n * @todo We can also abort any pending frames here, given we implement\n * the `NetworkFrame.abort()` method.\n */\n this.#frames.clear()\n }\n\n async #handleRequest({\n requestId,\n request,\n controller,\n }: HttpRequestEventMap['request'][0]): Promise<void> {\n const httpFrame = new InterceptorHttpNetworkFrame({\n id: requestId,\n request,\n controller,\n })\n\n this.#frames.set(requestId, httpFrame)\n await this.queue(httpFrame)\n }\n\n async #handleResponse({\n requestId,\n request,\n response,\n isMockedResponse,\n }: HttpRequestEventMap['response'][0]): Promise<void> {\n const httpFrame = this.#frames.get(requestId)\n this.#frames.delete(requestId)\n\n if (httpFrame == null) {\n return\n }\n\n queueMicrotask(() => {\n httpFrame.events.emit(\n
|
|
1
|
+
{"version":3,"sources":["../../../../src/core/experimental/sources/interceptor-source.ts"],"sourcesContent":["import type { Interceptor, RequestController } from '@mswjs/interceptors'\nimport { BatchInterceptor, type HttpRequestEventMap } from '@mswjs/interceptors'\nimport type {\n WebSocketConnectionData,\n WebSocketEventMap,\n} from '@mswjs/interceptors/WebSocket'\nimport { NetworkSource } from './network-source'\nimport { InternalError } from '../../utils/internal/devUtils'\nimport { HttpNetworkFrame, ResponseEvent } from '../frames/http-frame'\nimport { WebSocketNetworkFrame } from '../frames/websocket-frame'\nimport { deleteRequestPassthroughHeader } from '../request-utils'\n\nexport interface InterceptorSourceOptions {\n interceptors: Array<Interceptor<HttpRequestEventMap | WebSocketEventMap>>\n}\n\n/**\n * Create a network source from the given list of interceptors.\n */\nexport class InterceptorSource extends NetworkSource {\n #interceptor: BatchInterceptor<\n InterceptorSourceOptions['interceptors'],\n HttpRequestEventMap | WebSocketEventMap\n >\n\n #frames: Map<string, HttpNetworkFrame>\n\n constructor(options: InterceptorSourceOptions) {\n super()\n\n this.#interceptor = new BatchInterceptor({\n name: 'interceptor-source',\n interceptors: options.interceptors,\n })\n this.#frames = new Map()\n }\n\n public enable(): void {\n this.#interceptor.apply()\n\n /**\n * @todo @fixme BatchInterceptor infers event types but not listener types.\n */\n this.#interceptor\n .on('request', this.#handleRequest.bind(this) as any)\n .on('response', this.#handleResponse.bind(this) as any)\n .on('connection', this.#handleWebSocketConnection.bind(this) as any)\n }\n\n public disable(): void {\n super.disable()\n this.#interceptor.dispose()\n\n /**\n * @todo We can also abort any pending frames here, given we implement\n * the `NetworkFrame.abort()` method.\n */\n this.#frames.clear()\n }\n\n async #handleRequest({\n requestId,\n request,\n controller,\n }: HttpRequestEventMap['request'][0]): Promise<void> {\n const httpFrame = new InterceptorHttpNetworkFrame({\n id: requestId,\n request,\n controller,\n })\n\n this.#frames.set(requestId, httpFrame)\n await this.queue(httpFrame)\n }\n\n async #handleResponse({\n requestId,\n request,\n response,\n isMockedResponse,\n }: HttpRequestEventMap['response'][0]): Promise<void> {\n const httpFrame = this.#frames.get(requestId)\n this.#frames.delete(requestId)\n\n if (httpFrame == null) {\n return\n }\n\n queueMicrotask(() => {\n try {\n httpFrame.events.emit(\n new ResponseEvent(\n isMockedResponse ? 'response:mocked' : 'response:bypass',\n {\n requestId,\n request,\n response,\n },\n ),\n )\n } finally {\n /**\n * @note Remove any listeners from this frame.\n * Past this point, it won't emit anything. The removal is crucial\n * to prevent \"rettime\" from keeping the abort cleanup listeners internally.\n * @see https://github.com/mswjs/msw/issues/2735\n */\n httpFrame.events.removeAllListeners()\n }\n })\n }\n\n async #handleWebSocketConnection(\n connection: WebSocketEventMap['connection'][0],\n ): Promise<void> {\n await this.queue(\n new InterceptorWebSocketNetworkFrame({\n connection,\n }),\n )\n }\n}\n\nclass InterceptorHttpNetworkFrame extends HttpNetworkFrame {\n #controller: RequestController\n\n constructor(options: {\n id: string\n request: Request\n controller: RequestController\n }) {\n super({\n id: options.id,\n request: options.request,\n })\n\n this.#controller = options.controller\n }\n\n public passthrough(): void {\n deleteRequestPassthroughHeader(this.data.request)\n }\n\n public respondWith(response?: Response): void {\n if (response) {\n this.#controller.respondWith(response)\n }\n }\n\n public errorWith(reason?: unknown): void {\n if (reason instanceof Response) {\n return this.respondWith(reason)\n }\n\n if (reason instanceof InternalError) {\n this.#controller.errorWith(reason)\n }\n\n throw reason\n }\n}\n\nclass InterceptorWebSocketNetworkFrame extends WebSocketNetworkFrame {\n constructor(args: { connection: WebSocketConnectionData }) {\n super({ connection: args.connection })\n }\n\n public errorWith(reason?: unknown): void {\n if (reason instanceof Error) {\n const { client } = this.data.connection\n\n /**\n * Use `client.errorWith(reason)` in the future.\n * @see https://github.com/mswjs/interceptors/issues/747\n */\n const errorEvent = new Event('error')\n\n Object.defineProperty(errorEvent, 'cause', {\n enumerable: true,\n configurable: false,\n value: reason,\n })\n\n client.socket.dispatchEvent(errorEvent)\n }\n }\n\n public passthrough() {\n this.data.conn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C;AAAA,EACF;AAAA,EAEO,cAAc;AACnB,SAAK,KAAK,WAAW,OAAO,QAAQ;AAAA,EACtC;AACF;","names":[]}
|
|
@@ -49,16 +49,20 @@ class InterceptorSource extends NetworkSource {
|
|
|
49
49
|
return;
|
|
50
50
|
}
|
|
51
51
|
queueMicrotask(() => {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
52
|
+
try {
|
|
53
|
+
httpFrame.events.emit(
|
|
54
|
+
new ResponseEvent(
|
|
55
|
+
isMockedResponse ? "response:mocked" : "response:bypass",
|
|
56
|
+
{
|
|
57
|
+
requestId,
|
|
58
|
+
request,
|
|
59
|
+
response
|
|
60
|
+
}
|
|
61
|
+
)
|
|
62
|
+
);
|
|
63
|
+
} finally {
|
|
64
|
+
httpFrame.events.removeAllListeners();
|
|
65
|
+
}
|
|
62
66
|
});
|
|
63
67
|
}
|
|
64
68
|
async #handleWebSocketConnection(connection) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/core/experimental/sources/interceptor-source.ts"],"sourcesContent":["import type { Interceptor, RequestController } from '@mswjs/interceptors'\nimport { BatchInterceptor, type HttpRequestEventMap } from '@mswjs/interceptors'\nimport type {\n WebSocketConnectionData,\n WebSocketEventMap,\n} from '@mswjs/interceptors/WebSocket'\nimport { NetworkSource } from './network-source'\nimport { InternalError } from '../../utils/internal/devUtils'\nimport { HttpNetworkFrame, ResponseEvent } from '../frames/http-frame'\nimport { WebSocketNetworkFrame } from '../frames/websocket-frame'\nimport { deleteRequestPassthroughHeader } from '../request-utils'\n\nexport interface InterceptorSourceOptions {\n interceptors: Array<Interceptor<HttpRequestEventMap | WebSocketEventMap>>\n}\n\n/**\n * Create a network source from the given list of interceptors.\n */\nexport class InterceptorSource extends NetworkSource {\n #interceptor: BatchInterceptor<\n InterceptorSourceOptions['interceptors'],\n HttpRequestEventMap | WebSocketEventMap\n >\n\n #frames: Map<string, HttpNetworkFrame>\n\n constructor(options: InterceptorSourceOptions) {\n super()\n\n this.#interceptor = new BatchInterceptor({\n name: 'interceptor-source',\n interceptors: options.interceptors,\n })\n this.#frames = new Map()\n }\n\n public enable(): void {\n this.#interceptor.apply()\n\n /**\n * @todo @fixme BatchInterceptor infers event types but not listener types.\n */\n this.#interceptor\n .on('request', this.#handleRequest.bind(this) as any)\n .on('response', this.#handleResponse.bind(this) as any)\n .on('connection', this.#handleWebSocketConnection.bind(this) as any)\n }\n\n public disable(): void {\n super.disable()\n this.#interceptor.dispose()\n\n /**\n * @todo We can also abort any pending frames here, given we implement\n * the `NetworkFrame.abort()` method.\n */\n this.#frames.clear()\n }\n\n async #handleRequest({\n requestId,\n request,\n controller,\n }: HttpRequestEventMap['request'][0]): Promise<void> {\n const httpFrame = new InterceptorHttpNetworkFrame({\n id: requestId,\n request,\n controller,\n })\n\n this.#frames.set(requestId, httpFrame)\n await this.queue(httpFrame)\n }\n\n async #handleResponse({\n requestId,\n request,\n response,\n isMockedResponse,\n }: HttpRequestEventMap['response'][0]): Promise<void> {\n const httpFrame = this.#frames.get(requestId)\n this.#frames.delete(requestId)\n\n if (httpFrame == null) {\n return\n }\n\n queueMicrotask(() => {\n httpFrame.events.emit(\n
|
|
1
|
+
{"version":3,"sources":["../../../../src/core/experimental/sources/interceptor-source.ts"],"sourcesContent":["import type { Interceptor, RequestController } from '@mswjs/interceptors'\nimport { BatchInterceptor, type HttpRequestEventMap } from '@mswjs/interceptors'\nimport type {\n WebSocketConnectionData,\n WebSocketEventMap,\n} from '@mswjs/interceptors/WebSocket'\nimport { NetworkSource } from './network-source'\nimport { InternalError } from '../../utils/internal/devUtils'\nimport { HttpNetworkFrame, ResponseEvent } from '../frames/http-frame'\nimport { WebSocketNetworkFrame } from '../frames/websocket-frame'\nimport { deleteRequestPassthroughHeader } from '../request-utils'\n\nexport interface InterceptorSourceOptions {\n interceptors: Array<Interceptor<HttpRequestEventMap | WebSocketEventMap>>\n}\n\n/**\n * Create a network source from the given list of interceptors.\n */\nexport class InterceptorSource extends NetworkSource {\n #interceptor: BatchInterceptor<\n InterceptorSourceOptions['interceptors'],\n HttpRequestEventMap | WebSocketEventMap\n >\n\n #frames: Map<string, HttpNetworkFrame>\n\n constructor(options: InterceptorSourceOptions) {\n super()\n\n this.#interceptor = new BatchInterceptor({\n name: 'interceptor-source',\n interceptors: options.interceptors,\n })\n this.#frames = new Map()\n }\n\n public enable(): void {\n this.#interceptor.apply()\n\n /**\n * @todo @fixme BatchInterceptor infers event types but not listener types.\n */\n this.#interceptor\n .on('request', this.#handleRequest.bind(this) as any)\n .on('response', this.#handleResponse.bind(this) as any)\n .on('connection', this.#handleWebSocketConnection.bind(this) as any)\n }\n\n public disable(): void {\n super.disable()\n this.#interceptor.dispose()\n\n /**\n * @todo We can also abort any pending frames here, given we implement\n * the `NetworkFrame.abort()` method.\n */\n this.#frames.clear()\n }\n\n async #handleRequest({\n requestId,\n request,\n controller,\n }: HttpRequestEventMap['request'][0]): Promise<void> {\n const httpFrame = new InterceptorHttpNetworkFrame({\n id: requestId,\n request,\n controller,\n })\n\n this.#frames.set(requestId, httpFrame)\n await this.queue(httpFrame)\n }\n\n async #handleResponse({\n requestId,\n request,\n response,\n isMockedResponse,\n }: HttpRequestEventMap['response'][0]): Promise<void> {\n const httpFrame = this.#frames.get(requestId)\n this.#frames.delete(requestId)\n\n if (httpFrame == null) {\n return\n }\n\n queueMicrotask(() => {\n try {\n httpFrame.events.emit(\n new ResponseEvent(\n isMockedResponse ? 'response:mocked' : 'response:bypass',\n {\n requestId,\n request,\n response,\n },\n ),\n )\n } finally {\n /**\n * @note Remove any listeners from this frame.\n * Past this point, it won't emit anything. The removal is crucial\n * to prevent \"rettime\" from keeping the abort cleanup listeners internally.\n * @see https://github.com/mswjs/msw/issues/2735\n */\n httpFrame.events.removeAllListeners()\n }\n })\n }\n\n async #handleWebSocketConnection(\n connection: WebSocketEventMap['connection'][0],\n ): Promise<void> {\n await this.queue(\n new InterceptorWebSocketNetworkFrame({\n connection,\n }),\n )\n }\n}\n\nclass InterceptorHttpNetworkFrame extends HttpNetworkFrame {\n #controller: RequestController\n\n constructor(options: {\n id: string\n request: Request\n controller: RequestController\n }) {\n super({\n id: options.id,\n request: options.request,\n })\n\n this.#controller = options.controller\n }\n\n public passthrough(): void {\n deleteRequestPassthroughHeader(this.data.request)\n }\n\n public respondWith(response?: Response): void {\n if (response) {\n this.#controller.respondWith(response)\n }\n }\n\n public errorWith(reason?: unknown): void {\n if (reason instanceof Response) {\n return this.respondWith(reason)\n }\n\n if (reason instanceof InternalError) {\n this.#controller.errorWith(reason)\n }\n\n throw reason\n }\n}\n\nclass InterceptorWebSocketNetworkFrame extends WebSocketNetworkFrame {\n constructor(args: { connection: WebSocketConnectionData }) {\n super({ connection: args.connection })\n }\n\n public errorWith(reason?: unknown): void {\n if (reason instanceof Error) {\n const { client } = this.data.connection\n\n /**\n * Use `client.errorWith(reason)` in the future.\n * @see https://github.com/mswjs/interceptors/issues/747\n */\n const errorEvent = new Event('error')\n\n Object.defineProperty(errorEvent, 'cause', {\n enumerable: true,\n configurable: false,\n value: reason,\n })\n\n client.socket.dispatchEvent(errorEvent)\n }\n }\n\n public passthrough() {\n this.data.connection.server.connect()\n }\n}\n"],"mappings":"AACA,SAAS,wBAAkD;AAK3D,SAAS,qBAAqB;AAC9B,SAAS,qBAAqB;AAC9B,SAAS,kBAAkB,qBAAqB;AAChD,SAAS,6BAA6B;AACtC,SAAS,sCAAsC;AASxC,MAAM,0BAA0B,cAAc;AAAA,EACnD;AAAA,EAKA;AAAA,EAEA,YAAY,SAAmC;AAC7C,UAAM;AAEN,SAAK,eAAe,IAAI,iBAAiB;AAAA,MACvC,MAAM;AAAA,MACN,cAAc,QAAQ;AAAA,IACxB,CAAC;AACD,SAAK,UAAU,oBAAI,IAAI;AAAA,EACzB;AAAA,EAEO,SAAe;AACpB,SAAK,aAAa,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SAAS,QAAQ;AAAA,IACnB,CAAC;AAED,SAAK,cAAc,QAAQ;AAAA,EAC7B;AAAA,EAEO,cAAoB;AACzB,mCAA+B,KAAK,KAAK,OAAO;AAAA,EAClD;AAAA,EAEO,YAAY,UAA2B;AAC5C,QAAI,UAAU;AACZ,WAAK,YAAY,YAAY,QAAQ;AAAA,IACvC;AAAA,EACF;AAAA,EAEO,UAAU,QAAwB;AACvC,QAAI,kBAAkB,UAAU;AAC9B,aAAO,KAAK,YAAY,MAAM;AAAA,IAChC;AAEA,QAAI,kBAAkB,eAAe;AACnC,WAAK,YAAY,UAAU,MAAM;AAAA,IACnC;AAEA,UAAM;AAAA,EACR;AACF;AAEA,MAAM,yCAAyC,sBAAsB;AAAA,EACnE,YAAY,MAA+C;AACzD,UAAM,EAAE,YAAY,KAAK,WAAW,CAAC;AAAA,EACvC;AAAA,EAEO,UAAU,QAAwB;AACvC,QAAI,kBAAkB,OAAO;AAC3B,YAAM,EAAE,OAAO,IAAI,KAAK,KAAK;AAM7B,YAAM,aAAa,IAAI,MAAM,OAAO;AAEpC,aAAO,eAAe,YAAY,SAAS;AAAA,QACzC,YAAY;AAAA,QACZ,cAAc;AAAA,QACd,OAAO;AAAA,MACT,CAAC;AAED,aAAO,OAAO,cAAc,UAAU;AAAA,IACxC;AAAA,EACF;AAAA,EAEO,cAAc;AACnB,SAAK,KAAK,WAAW,OAAO,QAAQ;AAAA,EACtC;AACF;","names":[]}
|
package/lib/iife/index.js
CHANGED
|
@@ -14335,7 +14335,7 @@ ${operationTypes.join("\n")}
|
|
|
14335
14335
|
);
|
|
14336
14336
|
}
|
|
14337
14337
|
|
|
14338
|
-
// node_modules/.pnpm/rettime@0.11.
|
|
14338
|
+
// node_modules/.pnpm/rettime@0.11.11/node_modules/rettime/build/lens-list.mjs
|
|
14339
14339
|
var LensList = class {
|
|
14340
14340
|
#list;
|
|
14341
14341
|
#lens;
|
|
@@ -14377,15 +14377,17 @@ ${operationTypes.join("\n")}
|
|
|
14377
14377
|
}
|
|
14378
14378
|
/**
|
|
14379
14379
|
* Delete the value belonging to the given key.
|
|
14380
|
+
* Returns `true` if the value was present and removed, `false` otherwise.
|
|
14380
14381
|
*/
|
|
14381
14382
|
delete(key, value) {
|
|
14382
|
-
if (this.size === 0) return;
|
|
14383
|
-
this.#list = this.#list.filter((item) => item[1] !== value);
|
|
14383
|
+
if (this.size === 0) return false;
|
|
14384
14384
|
const values = this.#lens.get(key);
|
|
14385
|
-
if (values)
|
|
14386
|
-
|
|
14387
|
-
|
|
14388
|
-
|
|
14385
|
+
if (!values) return false;
|
|
14386
|
+
const index = values.indexOf(value);
|
|
14387
|
+
if (index === -1) return false;
|
|
14388
|
+
values.splice(index, 1);
|
|
14389
|
+
this.#list.splice(this.#list.findIndex((item) => item[0] === key && item[1] === value), 1);
|
|
14390
|
+
return true;
|
|
14389
14391
|
}
|
|
14390
14392
|
/**
|
|
14391
14393
|
* Delete all values belogning to the given key.
|
|
@@ -14408,7 +14410,7 @@ ${operationTypes.join("\n")}
|
|
|
14408
14410
|
}
|
|
14409
14411
|
};
|
|
14410
14412
|
|
|
14411
|
-
// node_modules/.pnpm/rettime@0.11.
|
|
14413
|
+
// node_modules/.pnpm/rettime@0.11.11/node_modules/rettime/build/index.mjs
|
|
14412
14414
|
var kDefaultPrevented = Symbol("kDefaultPrevented");
|
|
14413
14415
|
var kPropagationStopped = Symbol("kPropagationStopped");
|
|
14414
14416
|
var kImmediatePropagationStopped = Symbol("kImmediatePropagationStopped");
|
|
@@ -14441,37 +14443,66 @@ ${operationTypes.join("\n")}
|
|
|
14441
14443
|
var Emitter = class {
|
|
14442
14444
|
#listeners;
|
|
14443
14445
|
#listenerOptions;
|
|
14446
|
+
#listenerAbortCleanups;
|
|
14444
14447
|
#typelessListeners;
|
|
14445
14448
|
#hookListeners;
|
|
14446
14449
|
#hookListenerOptions;
|
|
14450
|
+
#hookListenerAbortCleanups;
|
|
14447
14451
|
hooks;
|
|
14448
14452
|
constructor() {
|
|
14449
14453
|
this.#listeners = new LensList();
|
|
14450
14454
|
this.#listenerOptions = /* @__PURE__ */ new WeakMap();
|
|
14455
|
+
this.#listenerAbortCleanups = /* @__PURE__ */ new WeakMap();
|
|
14451
14456
|
this.#typelessListeners = /* @__PURE__ */ new WeakSet();
|
|
14452
14457
|
this.#hookListeners = new LensList();
|
|
14453
14458
|
this.#hookListenerOptions = /* @__PURE__ */ new WeakMap();
|
|
14459
|
+
this.#hookListenerAbortCleanups = /* @__PURE__ */ new WeakMap();
|
|
14454
14460
|
this.hooks = {
|
|
14455
14461
|
on: (hook, callback, options) => {
|
|
14462
|
+
if (options?.signal?.aborted) return;
|
|
14456
14463
|
if (options?.once) {
|
|
14457
14464
|
const original = callback;
|
|
14458
14465
|
const wrapper = ((...args) => {
|
|
14459
|
-
this.#
|
|
14466
|
+
this.#deleteHookListener(hook, wrapper);
|
|
14460
14467
|
return original(...args);
|
|
14461
14468
|
});
|
|
14462
14469
|
callback = wrapper;
|
|
14463
14470
|
}
|
|
14464
14471
|
this.#hookListeners.append(hook, callback);
|
|
14465
14472
|
if (options) this.#hookListenerOptions.set(callback, options);
|
|
14466
|
-
if (options?.signal)
|
|
14467
|
-
|
|
14468
|
-
|
|
14473
|
+
if (options?.signal) {
|
|
14474
|
+
const { signal } = options;
|
|
14475
|
+
const onAbort = () => {
|
|
14476
|
+
this.#deleteHookListener(hook, callback);
|
|
14477
|
+
};
|
|
14478
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
14479
|
+
this.#hookListenerAbortCleanups.set(callback, () => {
|
|
14480
|
+
signal.removeEventListener("abort", onAbort);
|
|
14481
|
+
});
|
|
14482
|
+
}
|
|
14469
14483
|
},
|
|
14470
14484
|
removeListener: (hook, callback) => {
|
|
14471
|
-
this.#
|
|
14485
|
+
this.#deleteHookListener(hook, callback);
|
|
14472
14486
|
}
|
|
14473
14487
|
};
|
|
14474
14488
|
}
|
|
14489
|
+
#deleteHookListener(hook, callback) {
|
|
14490
|
+
this.#hookListeners.delete(hook, callback);
|
|
14491
|
+
const cleanup = this.#hookListenerAbortCleanups.get(callback);
|
|
14492
|
+
if (cleanup) {
|
|
14493
|
+
cleanup();
|
|
14494
|
+
this.#hookListenerAbortCleanups.delete(callback);
|
|
14495
|
+
}
|
|
14496
|
+
}
|
|
14497
|
+
#deleteListener(type, listener) {
|
|
14498
|
+
const removed = this.#listeners.delete(type, listener);
|
|
14499
|
+
const cleanup = this.#listenerAbortCleanups.get(listener);
|
|
14500
|
+
if (cleanup) {
|
|
14501
|
+
cleanup();
|
|
14502
|
+
this.#listenerAbortCleanups.delete(listener);
|
|
14503
|
+
}
|
|
14504
|
+
return removed;
|
|
14505
|
+
}
|
|
14475
14506
|
/**
|
|
14476
14507
|
* Adds a listener for the given event type.
|
|
14477
14508
|
*/
|
|
@@ -14573,8 +14604,8 @@ ${operationTypes.join("\n")}
|
|
|
14573
14604
|
*/
|
|
14574
14605
|
removeListener(type, listener) {
|
|
14575
14606
|
const options = this.#listenerOptions.get(listener);
|
|
14576
|
-
this.#
|
|
14577
|
-
for (const hook of this.#hookListeners.get("removeListener")) hook(type, listener, options);
|
|
14607
|
+
if (!this.#deleteListener(type, listener)) return;
|
|
14608
|
+
for (const hook of this.#hookListeners.get("removeListener").slice()) hook(type, listener, options);
|
|
14578
14609
|
}
|
|
14579
14610
|
/**
|
|
14580
14611
|
* Removes all listeners for the given event type.
|
|
@@ -14582,11 +14613,12 @@ ${operationTypes.join("\n")}
|
|
|
14582
14613
|
*/
|
|
14583
14614
|
removeAllListeners(type) {
|
|
14584
14615
|
if (type == null) {
|
|
14585
|
-
this.#listeners.
|
|
14586
|
-
for (const [hookType, hookListener] of this.#hookListeners) if (!this.#hookListenerOptions.get(hookListener)?.persist) this.#
|
|
14616
|
+
for (const [listenerType, listeners$1] of this.#listeners.entries()) while (listeners$1.length > 0) this.removeListener(listenerType, listeners$1[0]);
|
|
14617
|
+
for (const [hookType, hookListener] of [...this.#hookListeners]) if (!this.#hookListenerOptions.get(hookListener)?.persist) this.#deleteHookListener(hookType, hookListener);
|
|
14587
14618
|
return;
|
|
14588
14619
|
}
|
|
14589
|
-
this
|
|
14620
|
+
const listeners = this.listeners(type);
|
|
14621
|
+
while (listeners.length > 0) this.removeListener(type, listeners[0]);
|
|
14590
14622
|
}
|
|
14591
14623
|
/**
|
|
14592
14624
|
* Returns the list of listeners for the given event type.
|
|
@@ -14605,15 +14637,23 @@ ${operationTypes.join("\n")}
|
|
|
14605
14637
|
return this.listeners(type).length;
|
|
14606
14638
|
}
|
|
14607
14639
|
#addListener(type, listener, options, insertMode = "append") {
|
|
14608
|
-
|
|
14640
|
+
if (options?.signal?.aborted) return;
|
|
14641
|
+
for (const hook of this.#hookListeners.get("newListener").slice()) hook(type, listener, options);
|
|
14609
14642
|
if (type === "*") this.#typelessListeners.add(listener);
|
|
14610
14643
|
if (insertMode === "prepend") this.#listeners.prepend(type, listener);
|
|
14611
14644
|
else this.#listeners.append(type, listener);
|
|
14612
14645
|
if (options) {
|
|
14613
14646
|
this.#listenerOptions.set(listener, options);
|
|
14614
|
-
if (options.signal)
|
|
14615
|
-
|
|
14616
|
-
|
|
14647
|
+
if (options.signal) {
|
|
14648
|
+
const { signal } = options;
|
|
14649
|
+
const onAbort = () => {
|
|
14650
|
+
this.removeListener(type, listener);
|
|
14651
|
+
};
|
|
14652
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
14653
|
+
this.#listenerAbortCleanups.set(listener, () => {
|
|
14654
|
+
signal.removeEventListener("abort", onAbort);
|
|
14655
|
+
});
|
|
14656
|
+
}
|
|
14617
14657
|
}
|
|
14618
14658
|
}
|
|
14619
14659
|
#proxyEvent(event) {
|
|
@@ -14630,22 +14670,27 @@ ${operationTypes.join("\n")}
|
|
|
14630
14670
|
};
|
|
14631
14671
|
}
|
|
14632
14672
|
#callListener(event, listener) {
|
|
14633
|
-
for (const hook of this.#hookListeners.get("beforeEmit")) if (hook(event) === false) return;
|
|
14673
|
+
for (const hook of this.#hookListeners.get("beforeEmit").slice()) if (hook(event) === false) return;
|
|
14634
14674
|
const returnValue = listener.call(this, event);
|
|
14635
14675
|
const options = this.#listenerOptions.get(listener);
|
|
14636
14676
|
if (options?.once) {
|
|
14637
14677
|
const type = this.#isTypelessListener(listener) ? "*" : event.type;
|
|
14638
|
-
this.#
|
|
14639
|
-
for (const hook of this.#hookListeners.get("removeListener")) hook(type, listener, options);
|
|
14678
|
+
if (this.#deleteListener(type, listener)) for (const hook of this.#hookListeners.get("removeListener").slice()) hook(type, listener, options);
|
|
14640
14679
|
}
|
|
14641
14680
|
return returnValue;
|
|
14642
14681
|
}
|
|
14643
14682
|
/**
|
|
14644
14683
|
* Return a list of all event listeners relevant for the given event type.
|
|
14645
14684
|
* This includes the explicit event listeners and also typeless event listeners.
|
|
14685
|
+
*
|
|
14686
|
+
* @note Snapshot the matching listeners before yielding. Listeners can add or
|
|
14687
|
+
* remove other listeners during emission (e.g. `earlyOn` unshifts `#list`),
|
|
14688
|
+
* which would otherwise shift the live iterator and re-yield prior entries.
|
|
14646
14689
|
*/
|
|
14647
14690
|
*#matchListeners(type) {
|
|
14648
|
-
|
|
14691
|
+
const snapshot = [];
|
|
14692
|
+
for (const [key, listener] of this.#listeners) if (key === "*" || key === type) snapshot.push(listener);
|
|
14693
|
+
yield* snapshot;
|
|
14649
14694
|
}
|
|
14650
14695
|
#isTypelessListener(listener) {
|
|
14651
14696
|
return this.#typelessListeners.has(listener);
|
|
@@ -22937,16 +22982,20 @@ Read more: https://mswjs.io/docs/websocket`;
|
|
|
22937
22982
|
return;
|
|
22938
22983
|
}
|
|
22939
22984
|
queueMicrotask(() => {
|
|
22940
|
-
|
|
22941
|
-
|
|
22942
|
-
|
|
22943
|
-
|
|
22944
|
-
|
|
22945
|
-
|
|
22946
|
-
|
|
22947
|
-
|
|
22948
|
-
|
|
22949
|
-
|
|
22985
|
+
try {
|
|
22986
|
+
httpFrame.events.emit(
|
|
22987
|
+
new ResponseEvent(
|
|
22988
|
+
isMockedResponse ? "response:mocked" : "response:bypass",
|
|
22989
|
+
{
|
|
22990
|
+
requestId,
|
|
22991
|
+
request,
|
|
22992
|
+
response
|
|
22993
|
+
}
|
|
22994
|
+
)
|
|
22995
|
+
);
|
|
22996
|
+
} finally {
|
|
22997
|
+
httpFrame.events.removeAllListeners();
|
|
22998
|
+
}
|
|
22950
22999
|
});
|
|
22951
23000
|
}
|
|
22952
23001
|
async #handleWebSocketConnection(connection) {
|
|
@@ -23439,11 +23488,12 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
|
|
|
23439
23488
|
}
|
|
23440
23489
|
async #handleResponse(event) {
|
|
23441
23490
|
const { request, response, isMockedResponse } = event.data;
|
|
23491
|
+
const frame = this.#frames.get(request.id);
|
|
23442
23492
|
if (response.type?.includes("opaque")) {
|
|
23443
23493
|
this.#frames.delete(request.id);
|
|
23494
|
+
frame?.events.removeAllListeners();
|
|
23444
23495
|
return;
|
|
23445
23496
|
}
|
|
23446
|
-
const frame = this.#frames.get(request.id);
|
|
23447
23497
|
this.#frames.delete(request.id);
|
|
23448
23498
|
if (frame == null) {
|
|
23449
23499
|
return;
|
|
@@ -23467,17 +23517,21 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
|
|
|
23467
23517
|
url: request.url
|
|
23468
23518
|
}
|
|
23469
23519
|
);
|
|
23470
|
-
|
|
23471
|
-
|
|
23472
|
-
|
|
23473
|
-
|
|
23474
|
-
|
|
23475
|
-
|
|
23476
|
-
|
|
23477
|
-
|
|
23478
|
-
|
|
23479
|
-
|
|
23480
|
-
|
|
23520
|
+
try {
|
|
23521
|
+
frame.events.emit(
|
|
23522
|
+
new ResponseEvent(
|
|
23523
|
+
isMockedResponse ? "response:mocked" : "response:bypass",
|
|
23524
|
+
{
|
|
23525
|
+
requestId: frame.data.id,
|
|
23526
|
+
request: fetchRequest,
|
|
23527
|
+
response: fetchResponse,
|
|
23528
|
+
isMockedResponse
|
|
23529
|
+
}
|
|
23530
|
+
)
|
|
23531
|
+
);
|
|
23532
|
+
} finally {
|
|
23533
|
+
frame.events.removeAllListeners();
|
|
23534
|
+
}
|
|
23481
23535
|
}
|
|
23482
23536
|
#defaultFindWorker = (workerUrl, mockServiceWorkerUrl) => {
|
|
23483
23537
|
return workerUrl === mockServiceWorkerUrl;
|