msw 2.10.0 → 2.10.1
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 +8 -8
- package/lib/browser/index.js.map +1 -1
- package/lib/browser/index.mjs +8 -8
- package/lib/browser/index.mjs.map +1 -1
- package/lib/core/handlers/WebSocketHandler.d.mts +6 -3
- package/lib/core/handlers/WebSocketHandler.d.ts +6 -3
- package/lib/core/handlers/WebSocketHandler.js.map +1 -1
- package/lib/core/handlers/WebSocketHandler.mjs.map +1 -1
- package/lib/core/ws/WebSocketClientManager.d.mts +4 -2
- package/lib/core/ws/WebSocketClientManager.d.ts +4 -2
- package/lib/core/ws/WebSocketClientManager.js +10 -0
- package/lib/core/ws/WebSocketClientManager.js.map +1 -1
- package/lib/core/ws/WebSocketClientManager.mjs +10 -0
- package/lib/core/ws/WebSocketClientManager.mjs.map +1 -1
- package/lib/iife/index.js +19 -9
- package/lib/iife/index.js.map +1 -1
- package/lib/mockServiceWorker.js +1 -1
- package/package.json +3 -3
- package/src/core/handlers/WebSocketHandler.ts +12 -3
- package/src/core/ws/WebSocketClientManager.ts +33 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Emitter } from 'strict-event-emitter';
|
|
2
|
-
import { WebSocketConnectionData } from '@mswjs/interceptors/WebSocket';
|
|
2
|
+
import { WebSocketClientConnectionProtocol, WebSocketServerConnectionProtocol, WebSocketConnectionData } from '@mswjs/interceptors/WebSocket';
|
|
3
3
|
import { PathParams, Path, Match } from '../utils/matching/matchRequestUrl.mjs';
|
|
4
4
|
|
|
5
5
|
type WebSocketHandlerParsedResult = {
|
|
@@ -8,7 +8,10 @@ type WebSocketHandlerParsedResult = {
|
|
|
8
8
|
type WebSocketHandlerEventMap = {
|
|
9
9
|
connection: [args: WebSocketHandlerConnection];
|
|
10
10
|
};
|
|
11
|
-
interface WebSocketHandlerConnection
|
|
11
|
+
interface WebSocketHandlerConnection {
|
|
12
|
+
client: WebSocketClientConnectionProtocol;
|
|
13
|
+
server: WebSocketServerConnectionProtocol;
|
|
14
|
+
info: WebSocketConnectionData['info'];
|
|
12
15
|
params: PathParams;
|
|
13
16
|
}
|
|
14
17
|
declare const kEmitter: unique symbol;
|
|
@@ -27,7 +30,7 @@ declare class WebSocketHandler {
|
|
|
27
30
|
url: URL;
|
|
28
31
|
parsedResult: WebSocketHandlerParsedResult;
|
|
29
32
|
}): boolean;
|
|
30
|
-
run(connection:
|
|
33
|
+
run(connection: Omit<WebSocketHandlerConnection, 'params'>): Promise<boolean>;
|
|
31
34
|
protected connect(connection: WebSocketHandlerConnection): boolean;
|
|
32
35
|
}
|
|
33
36
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Emitter } from 'strict-event-emitter';
|
|
2
|
-
import { WebSocketConnectionData } from '@mswjs/interceptors/WebSocket';
|
|
2
|
+
import { WebSocketClientConnectionProtocol, WebSocketServerConnectionProtocol, WebSocketConnectionData } from '@mswjs/interceptors/WebSocket';
|
|
3
3
|
import { PathParams, Path, Match } from '../utils/matching/matchRequestUrl.js';
|
|
4
4
|
|
|
5
5
|
type WebSocketHandlerParsedResult = {
|
|
@@ -8,7 +8,10 @@ type WebSocketHandlerParsedResult = {
|
|
|
8
8
|
type WebSocketHandlerEventMap = {
|
|
9
9
|
connection: [args: WebSocketHandlerConnection];
|
|
10
10
|
};
|
|
11
|
-
interface WebSocketHandlerConnection
|
|
11
|
+
interface WebSocketHandlerConnection {
|
|
12
|
+
client: WebSocketClientConnectionProtocol;
|
|
13
|
+
server: WebSocketServerConnectionProtocol;
|
|
14
|
+
info: WebSocketConnectionData['info'];
|
|
12
15
|
params: PathParams;
|
|
13
16
|
}
|
|
14
17
|
declare const kEmitter: unique symbol;
|
|
@@ -27,7 +30,7 @@ declare class WebSocketHandler {
|
|
|
27
30
|
url: URL;
|
|
28
31
|
parsedResult: WebSocketHandlerParsedResult;
|
|
29
32
|
}): boolean;
|
|
30
|
-
run(connection:
|
|
33
|
+
run(connection: Omit<WebSocketHandlerConnection, 'params'>): Promise<boolean>;
|
|
31
34
|
protected connect(connection: WebSocketHandlerConnection): boolean;
|
|
32
35
|
}
|
|
33
36
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/core/handlers/WebSocketHandler.ts"],"sourcesContent":["import { Emitter } from 'strict-event-emitter'\nimport { createRequestId } from '@mswjs/interceptors'\nimport type {
|
|
1
|
+
{"version":3,"sources":["../../../src/core/handlers/WebSocketHandler.ts"],"sourcesContent":["import { Emitter } from 'strict-event-emitter'\nimport { createRequestId } from '@mswjs/interceptors'\nimport type {\n WebSocketClientConnectionProtocol,\n WebSocketConnectionData,\n WebSocketServerConnectionProtocol,\n} from '@mswjs/interceptors/WebSocket'\nimport {\n type Match,\n type Path,\n type PathParams,\n matchRequestUrl,\n} from '../utils/matching/matchRequestUrl'\nimport { getCallFrame } from '../utils/internal/getCallFrame'\nimport type { HandlerKind } from './common'\n\ntype WebSocketHandlerParsedResult = {\n match: Match\n}\n\nexport type WebSocketHandlerEventMap = {\n connection: [args: WebSocketHandlerConnection]\n}\n\nexport interface WebSocketHandlerConnection {\n client: WebSocketClientConnectionProtocol\n server: WebSocketServerConnectionProtocol\n info: WebSocketConnectionData['info']\n params: PathParams\n}\n\nexport const kEmitter = Symbol('kEmitter')\nexport const kSender = Symbol('kSender')\nconst kStopPropagationPatched = Symbol('kStopPropagationPatched')\nconst KOnStopPropagation = Symbol('KOnStopPropagation')\n\nexport class WebSocketHandler {\n private readonly __kind: HandlerKind\n\n public id: string\n public callFrame?: string\n\n protected [kEmitter]: Emitter<WebSocketHandlerEventMap>\n\n constructor(private readonly url: Path) {\n this.id = createRequestId()\n\n this[kEmitter] = new Emitter()\n this.callFrame = getCallFrame(new Error())\n this.__kind = 'EventHandler'\n }\n\n public parse(args: { url: URL }): WebSocketHandlerParsedResult {\n const clientUrl = new URL(args.url)\n\n /**\n * @note Remove the Socket.IO path prefix from the WebSocket\n * client URL. This is an exception to keep the users from\n * including the implementation details in their handlers.\n */\n clientUrl.pathname = clientUrl.pathname.replace(/^\\/socket.io\\//, '/')\n\n const match = matchRequestUrl(clientUrl, this.url)\n\n return {\n match,\n }\n }\n\n public predicate(args: {\n url: URL\n parsedResult: WebSocketHandlerParsedResult\n }): boolean {\n return args.parsedResult.match.matches\n }\n\n public async run(\n connection: Omit<WebSocketHandlerConnection, 'params'>,\n ): Promise<boolean> {\n const parsedResult = this.parse({\n url: connection.client.url,\n })\n\n if (!this.predicate({ url: connection.client.url, parsedResult })) {\n return false\n }\n\n const resolvedConnection: WebSocketHandlerConnection = {\n ...connection,\n params: parsedResult.match.params || {},\n }\n\n return this.connect(resolvedConnection)\n }\n\n protected connect(connection: WebSocketHandlerConnection): boolean {\n // Support `event.stopPropagation()` for various client/server events.\n connection.client.addEventListener(\n 'message',\n createStopPropagationListener(this),\n )\n connection.client.addEventListener(\n 'close',\n createStopPropagationListener(this),\n )\n\n connection.server.addEventListener(\n 'open',\n createStopPropagationListener(this),\n )\n connection.server.addEventListener(\n 'message',\n createStopPropagationListener(this),\n )\n connection.server.addEventListener(\n 'error',\n createStopPropagationListener(this),\n )\n connection.server.addEventListener(\n 'close',\n createStopPropagationListener(this),\n )\n\n // Emit the connection event on the handler.\n // This is what the developer adds listeners for.\n return this[kEmitter].emit('connection', connection)\n }\n}\n\nfunction createStopPropagationListener(handler: WebSocketHandler) {\n return function stopPropagationListener(event: Event) {\n const propagationStoppedAt = Reflect.get(event, 'kPropagationStoppedAt') as\n | string\n | undefined\n\n if (propagationStoppedAt && handler.id !== propagationStoppedAt) {\n event.stopImmediatePropagation()\n return\n }\n\n Object.defineProperty(event, KOnStopPropagation, {\n value(this: WebSocketHandler) {\n Object.defineProperty(event, 'kPropagationStoppedAt', {\n value: handler.id,\n })\n },\n configurable: true,\n })\n\n // Since the same event instance is shared between all client/server objects,\n // make sure to patch its `stopPropagation` method only once.\n if (!Reflect.get(event, kStopPropagationPatched)) {\n event.stopPropagation = new Proxy(event.stopPropagation, {\n apply: (target, thisArg, args) => {\n Reflect.get(event, KOnStopPropagation)?.call(handler)\n return Reflect.apply(target, thisArg, args)\n },\n })\n\n Object.defineProperty(event, kStopPropagationPatched, {\n value: true,\n // If something else attempts to redefine this, throw.\n configurable: false,\n })\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kCAAwB;AACxB,0BAAgC;AAMhC,6BAKO;AACP,0BAA6B;AAkBtB,MAAM,WAAW,OAAO,UAAU;AAClC,MAAM,UAAU,OAAO,SAAS;AACvC,MAAM,0BAA0B,OAAO,yBAAyB;AAChE,MAAM,qBAAqB,OAAO,oBAAoB;AAE/C,MAAM,iBAAiB;AAAA,EAQ5B,YAA6B,KAAW;AAAX;AAC3B,SAAK,SAAK,qCAAgB;AAE1B,SAAK,QAAQ,IAAI,IAAI,oCAAQ;AAC7B,SAAK,gBAAY,kCAAa,IAAI,MAAM,CAAC;AACzC,SAAK,SAAS;AAAA,EAChB;AAAA,EAbiB;AAAA,EAEV;AAAA,EACA;AAAA,EAEP,CAAW,QAAQ;AAAA,EAUZ,MAAM,MAAkD;AAC7D,UAAM,YAAY,IAAI,IAAI,KAAK,GAAG;AAOlC,cAAU,WAAW,UAAU,SAAS,QAAQ,kBAAkB,GAAG;AAErE,UAAM,YAAQ,wCAAgB,WAAW,KAAK,GAAG;AAEjD,WAAO;AAAA,MACL;AAAA,IACF;AAAA,EACF;AAAA,EAEO,UAAU,MAGL;AACV,WAAO,KAAK,aAAa,MAAM;AAAA,EACjC;AAAA,EAEA,MAAa,IACX,YACkB;AAClB,UAAM,eAAe,KAAK,MAAM;AAAA,MAC9B,KAAK,WAAW,OAAO;AAAA,IACzB,CAAC;AAED,QAAI,CAAC,KAAK,UAAU,EAAE,KAAK,WAAW,OAAO,KAAK,aAAa,CAAC,GAAG;AACjE,aAAO;AAAA,IACT;AAEA,UAAM,qBAAiD;AAAA,M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F,CAAC;AAED,aAAO,eAAe,OAAO,yBAAyB;AAAA,QACpD,OAAO;AAAA;AAAA,QAEP,cAAc;AAAA,MAChB,CAAC;AAAA,IACH;AAAA,EACF;AACF;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/core/handlers/WebSocketHandler.ts"],"sourcesContent":["import { Emitter } from 'strict-event-emitter'\nimport { createRequestId } from '@mswjs/interceptors'\nimport type {
|
|
1
|
+
{"version":3,"sources":["../../../src/core/handlers/WebSocketHandler.ts"],"sourcesContent":["import { Emitter } from 'strict-event-emitter'\nimport { createRequestId } from '@mswjs/interceptors'\nimport type {\n WebSocketClientConnectionProtocol,\n WebSocketConnectionData,\n WebSocketServerConnectionProtocol,\n} from '@mswjs/interceptors/WebSocket'\nimport {\n type Match,\n type Path,\n type PathParams,\n matchRequestUrl,\n} from '../utils/matching/matchRequestUrl'\nimport { getCallFrame } from '../utils/internal/getCallFrame'\nimport type { HandlerKind } from './common'\n\ntype WebSocketHandlerParsedResult = {\n match: Match\n}\n\nexport type WebSocketHandlerEventMap = {\n connection: [args: WebSocketHandlerConnection]\n}\n\nexport interface WebSocketHandlerConnection {\n client: WebSocketClientConnectionProtocol\n server: WebSocketServerConnectionProtocol\n info: WebSocketConnectionData['info']\n params: PathParams\n}\n\nexport const kEmitter = Symbol('kEmitter')\nexport const kSender = Symbol('kSender')\nconst kStopPropagationPatched = Symbol('kStopPropagationPatched')\nconst KOnStopPropagation = Symbol('KOnStopPropagation')\n\nexport class WebSocketHandler {\n private readonly __kind: HandlerKind\n\n public id: string\n public callFrame?: string\n\n protected [kEmitter]: Emitter<WebSocketHandlerEventMap>\n\n constructor(private readonly url: Path) {\n this.id = createRequestId()\n\n this[kEmitter] = new Emitter()\n this.callFrame = getCallFrame(new Error())\n this.__kind = 'EventHandler'\n }\n\n public parse(args: { url: URL }): WebSocketHandlerParsedResult {\n const clientUrl = new URL(args.url)\n\n /**\n * @note Remove the Socket.IO path prefix from the WebSocket\n * client URL. This is an exception to keep the users from\n * including the implementation details in their handlers.\n */\n clientUrl.pathname = clientUrl.pathname.replace(/^\\/socket.io\\//, '/')\n\n const match = matchRequestUrl(clientUrl, this.url)\n\n return {\n match,\n }\n }\n\n public predicate(args: {\n url: URL\n parsedResult: WebSocketHandlerParsedResult\n }): boolean {\n return args.parsedResult.match.matches\n }\n\n public async run(\n connection: Omit<WebSocketHandlerConnection, 'params'>,\n ): Promise<boolean> {\n const parsedResult = this.parse({\n url: connection.client.url,\n })\n\n if (!this.predicate({ url: connection.client.url, parsedResult })) {\n return false\n }\n\n const resolvedConnection: WebSocketHandlerConnection = {\n ...connection,\n params: parsedResult.match.params || {},\n }\n\n return this.connect(resolvedConnection)\n }\n\n protected connect(connection: WebSocketHandlerConnection): boolean {\n // Support `event.stopPropagation()` for various client/server events.\n connection.client.addEventListener(\n 'message',\n createStopPropagationListener(this),\n )\n connection.client.addEventListener(\n 'close',\n createStopPropagationListener(this),\n )\n\n connection.server.addEventListener(\n 'open',\n createStopPropagationListener(this),\n )\n connection.server.addEventListener(\n 'message',\n createStopPropagationListener(this),\n )\n connection.server.addEventListener(\n 'error',\n createStopPropagationListener(this),\n )\n connection.server.addEventListener(\n 'close',\n createStopPropagationListener(this),\n )\n\n // Emit the connection event on the handler.\n // This is what the developer adds listeners for.\n return this[kEmitter].emit('connection', connection)\n }\n}\n\nfunction createStopPropagationListener(handler: WebSocketHandler) {\n return function stopPropagationListener(event: Event) {\n const propagationStoppedAt = Reflect.get(event, 'kPropagationStoppedAt') as\n | string\n | undefined\n\n if (propagationStoppedAt && handler.id !== propagationStoppedAt) {\n event.stopImmediatePropagation()\n return\n }\n\n Object.defineProperty(event, KOnStopPropagation, {\n value(this: WebSocketHandler) {\n Object.defineProperty(event, 'kPropagationStoppedAt', {\n value: handler.id,\n })\n },\n configurable: true,\n })\n\n // Since the same event instance is shared between all client/server objects,\n // make sure to patch its `stopPropagation` method only once.\n if (!Reflect.get(event, kStopPropagationPatched)) {\n event.stopPropagation = new Proxy(event.stopPropagation, {\n apply: (target, thisArg, args) => {\n Reflect.get(event, KOnStopPropagation)?.call(handler)\n return Reflect.apply(target, thisArg, args)\n },\n })\n\n Object.defineProperty(event, kStopPropagationPatched, {\n value: true,\n // If something else attempts to redefine this, throw.\n configurable: false,\n })\n }\n }\n}\n"],"mappings":"AAAA,SAAS,eAAe;AACxB,SAAS,uBAAuB;AAMhC;AAAA,EAIE;AAAA,OACK;AACP,SAAS,oBAAoB;AAkBtB,MAAM,WAAW,OAAO,UAAU;AAClC,MAAM,UAAU,OAAO,SAAS;AACvC,MAAM,0BAA0B,OAAO,yBAAyB;AAChE,MAAM,qBAAqB,OAAO,oBAAoB;AAE/C,MAAM,iBAAiB;AAAA,EAQ5B,YAA6B,KAAW;AAAX;AAC3B,SAAK,KAAK,gBAAgB;AAE1B,SAAK,QAAQ,IAAI,IAAI,QAAQ;AAC7B,SAAK,YAAY,aAAa,IAAI,MAAM,CAAC;AACzC,SAAK,SAAS;AAAA,EAChB;AAAA,EAbiB;AAAA,EAEV;AAAA,EACA;AAAA,EAEP,CAAW,QAAQ;AAAA,EAUZ,MAAM,MAAkD;AAC7D,UAAM,YAAY,IAAI,IAAI,KAAK,GAAG;AAOlC,cAAU,WAAW,UAAU,SAAS,QAAQ,kBAAkB,GAAG;AAErE,UAAM,QAAQ,gBAAgB,WAAW,KAAK,GAAG;AAEjD,WAAO;AAAA,MACL;AAAA,IACF;AAAA,EACF;AAAA,EAEO,UAAU,MAGL;AACV,WAAO,KAAK,aAAa,MAAM;AAAA,EACjC;AAAA,EAEA,MAAa,IACX,YACkB;AAClB,UAAM,eAAe,KAAK,MAAM;AAAA,MAC9B,KAAK,WAAW,OAAO;AAAA,IACzB,CAAC;AAED,QAAI,CAAC,KAAK,UAAU,EAAE,KAAK,WAAW,OAAO,KAAK,aAAa,CAAC,GAAG;AACjE,aAAO;AAAA,IACT;AAEA,UAAM,qBAAiD;AAAA,MACrD,GAAG;AAAA,MACH,Q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e,OAAO,yBAAyB;AAAA,QACpD,OAAO;AAAA;AAAA,QAEP,cAAc;AAAA,MAChB,CAAC;AAAA,IACH;AAAA,EACF;AACF;","names":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WebSocketData, WebSocketClientConnectionProtocol,
|
|
1
|
+
import { WebSocketData, WebSocketClientConnectionProtocol, WebSocketClientEventMap } from '@mswjs/interceptors/WebSocket';
|
|
2
2
|
|
|
3
3
|
type WebSocketBroadcastChannelMessage = {
|
|
4
4
|
type: 'extraneous:send';
|
|
@@ -42,7 +42,7 @@ declare class WebSocketClientManager {
|
|
|
42
42
|
* connection object because `addConnection()` is called only
|
|
43
43
|
* for the opened connections in the same runtime.
|
|
44
44
|
*/
|
|
45
|
-
addConnection(client:
|
|
45
|
+
addConnection(client: WebSocketClientConnectionProtocol): Promise<void>;
|
|
46
46
|
}
|
|
47
47
|
/**
|
|
48
48
|
* A wrapper class to operate with WebSocket client connections
|
|
@@ -58,6 +58,8 @@ declare class WebSocketRemoteClientConnection implements WebSocketClientConnecti
|
|
|
58
58
|
constructor(id: string, url: URL, channel: BroadcastChannel);
|
|
59
59
|
send(data: WebSocketData): void;
|
|
60
60
|
close(code?: number | undefined, reason?: string | undefined): void;
|
|
61
|
+
addEventListener<EventType extends keyof WebSocketClientEventMap>(_type: EventType, _listener: (this: WebSocket, event: WebSocketClientEventMap[EventType]) => void, _options?: AddEventListenerOptions | boolean): void;
|
|
62
|
+
removeEventListener<EventType extends keyof WebSocketClientEventMap>(_event: EventType, _listener: (this: WebSocket, event: WebSocketClientEventMap[EventType]) => void, _options?: EventListenerOptions | boolean): void;
|
|
61
63
|
}
|
|
62
64
|
|
|
63
65
|
export { type WebSocketBroadcastChannelMessage, WebSocketClientManager, WebSocketRemoteClientConnection };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WebSocketData, WebSocketClientConnectionProtocol,
|
|
1
|
+
import { WebSocketData, WebSocketClientConnectionProtocol, WebSocketClientEventMap } from '@mswjs/interceptors/WebSocket';
|
|
2
2
|
|
|
3
3
|
type WebSocketBroadcastChannelMessage = {
|
|
4
4
|
type: 'extraneous:send';
|
|
@@ -42,7 +42,7 @@ declare class WebSocketClientManager {
|
|
|
42
42
|
* connection object because `addConnection()` is called only
|
|
43
43
|
* for the opened connections in the same runtime.
|
|
44
44
|
*/
|
|
45
|
-
addConnection(client:
|
|
45
|
+
addConnection(client: WebSocketClientConnectionProtocol): Promise<void>;
|
|
46
46
|
}
|
|
47
47
|
/**
|
|
48
48
|
* A wrapper class to operate with WebSocket client connections
|
|
@@ -58,6 +58,8 @@ declare class WebSocketRemoteClientConnection implements WebSocketClientConnecti
|
|
|
58
58
|
constructor(id: string, url: URL, channel: BroadcastChannel);
|
|
59
59
|
send(data: WebSocketData): void;
|
|
60
60
|
close(code?: number | undefined, reason?: string | undefined): void;
|
|
61
|
+
addEventListener<EventType extends keyof WebSocketClientEventMap>(_type: EventType, _listener: (this: WebSocket, event: WebSocketClientEventMap[EventType]) => void, _options?: AddEventListenerOptions | boolean): void;
|
|
62
|
+
removeEventListener<EventType extends keyof WebSocketClientEventMap>(_event: EventType, _listener: (this: WebSocket, event: WebSocketClientEventMap[EventType]) => void, _options?: EventListenerOptions | boolean): void;
|
|
61
63
|
}
|
|
62
64
|
|
|
63
65
|
export { type WebSocketBroadcastChannelMessage, WebSocketClientManager, WebSocketRemoteClientConnection };
|
|
@@ -145,5 +145,15 @@ class WebSocketRemoteClientConnection {
|
|
|
145
145
|
}
|
|
146
146
|
});
|
|
147
147
|
}
|
|
148
|
+
addEventListener(_type, _listener, _options) {
|
|
149
|
+
throw new Error(
|
|
150
|
+
"WebSocketRemoteClientConnection.addEventListener is not supported"
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
removeEventListener(_event, _listener, _options) {
|
|
154
|
+
throw new Error(
|
|
155
|
+
"WebSocketRemoteClientConnection.removeEventListener is not supported"
|
|
156
|
+
);
|
|
157
|
+
}
|
|
148
158
|
}
|
|
149
159
|
//# sourceMappingURL=WebSocketClientManager.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/core/ws/WebSocketClientManager.ts"],"sourcesContent":["import type {\n WebSocketData,\n
|
|
1
|
+
{"version":3,"sources":["../../../src/core/ws/WebSocketClientManager.ts"],"sourcesContent":["import type {\n WebSocketData,\n WebSocketClientConnectionProtocol,\n WebSocketClientEventMap,\n} from '@mswjs/interceptors/WebSocket'\nimport { WebSocketClientStore } from './WebSocketClientStore'\nimport { WebSocketMemoryClientStore } from './WebSocketMemoryClientStore'\nimport { WebSocketIndexedDBClientStore } from './WebSocketIndexedDBClientStore'\n\nexport type WebSocketBroadcastChannelMessage =\n | {\n type: 'extraneous:send'\n payload: {\n clientId: string\n data: WebSocketData\n }\n }\n | {\n type: 'extraneous:close'\n payload: {\n clientId: string\n code?: number\n reason?: string\n }\n }\n\n/**\n * A manager responsible for accumulating WebSocket client\n * connections across different browser runtimes.\n */\nexport class WebSocketClientManager {\n private store: WebSocketClientStore\n private runtimeClients: Map<string, WebSocketClientConnectionProtocol>\n private allClients: Set<WebSocketClientConnectionProtocol>\n\n constructor(private channel: BroadcastChannel) {\n // Store the clients in the IndexedDB in the browser,\n // otherwise, store the clients in memory.\n this.store =\n typeof indexedDB !== 'undefined'\n ? new WebSocketIndexedDBClientStore()\n : new WebSocketMemoryClientStore()\n\n this.runtimeClients = new Map()\n this.allClients = new Set()\n\n this.channel.addEventListener('message', (message) => {\n if (message.data?.type === 'db:update') {\n this.flushDatabaseToMemory()\n }\n })\n\n if (typeof window !== 'undefined') {\n window.addEventListener('message', async (message) => {\n if (message.data?.type === 'msw/worker:stop') {\n await this.removeRuntimeClients()\n }\n })\n }\n }\n\n private async flushDatabaseToMemory() {\n const storedClients = await this.store.getAll()\n\n this.allClients = new Set(\n storedClients.map((client) => {\n const runtimeClient = this.runtimeClients.get(client.id)\n\n /**\n * @note For clients originating in this runtime, use their\n * direct references. No need to wrap them in a remote connection.\n */\n if (runtimeClient) {\n return runtimeClient\n }\n\n return new WebSocketRemoteClientConnection(\n client.id,\n new URL(client.url),\n this.channel,\n )\n }),\n )\n }\n\n private async removeRuntimeClients(): Promise<void> {\n await this.store.deleteMany(Array.from(this.runtimeClients.keys()))\n this.runtimeClients.clear()\n await this.flushDatabaseToMemory()\n this.notifyOthersAboutDatabaseUpdate()\n }\n\n /**\n * All active WebSocket client connections.\n */\n get clients(): Set<WebSocketClientConnectionProtocol> {\n return this.allClients\n }\n\n /**\n * Notify other runtimes about the database update\n * using the shared `BroadcastChannel` instance.\n */\n private notifyOthersAboutDatabaseUpdate(): void {\n this.channel.postMessage({ type: 'db:update' })\n }\n\n private async addClient(\n client: WebSocketClientConnectionProtocol,\n ): Promise<void> {\n await this.store.add(client)\n // Sync the in-memory clients in this runtime with the\n // updated database. This pulls in all the stored clients.\n await this.flushDatabaseToMemory()\n this.notifyOthersAboutDatabaseUpdate()\n }\n\n /**\n * Adds the given `WebSocket` client connection to the set\n * of all connections. The given connection is always the complete\n * connection object because `addConnection()` is called only\n * for the opened connections in the same runtime.\n */\n public async addConnection(\n client: WebSocketClientConnectionProtocol,\n ): Promise<void> {\n // Store this client in the map of clients created in this runtime.\n // This way, the manager can distinguish between this runtime clients\n // and extraneous runtime clients when synchronizing clients storage.\n this.runtimeClients.set(client.id, client)\n\n // Add the new client to the storage.\n await this.addClient(client)\n\n // Handle the incoming BroadcastChannel messages from other runtimes\n // that attempt to control this runtime (via a remote connection wrapper).\n // E.g. another runtime calling `client.send()` for the client in this runtime.\n const handleExtraneousMessage = (\n message: MessageEvent<WebSocketBroadcastChannelMessage>,\n ) => {\n const { type, payload } = message.data\n\n // Ignore broadcasted messages for other clients.\n if (\n typeof payload === 'object' &&\n 'clientId' in payload &&\n payload.clientId !== client.id\n ) {\n return\n }\n\n switch (type) {\n case 'extraneous:send': {\n client.send(payload.data)\n break\n }\n\n case 'extraneous:close': {\n client.close(payload.code, payload.reason)\n break\n }\n }\n }\n\n const abortController = new AbortController()\n\n this.channel.addEventListener('message', handleExtraneousMessage, {\n signal: abortController.signal,\n })\n\n // Once closed, this connection cannot be operated on.\n // This must include the extraneous runtimes as well.\n client.addEventListener('close', () => abortController.abort(), {\n once: true,\n })\n }\n}\n\n/**\n * A wrapper class to operate with WebSocket client connections\n * from other runtimes. This class maintains 1-1 public API\n * compatibility to the `WebSocketClientConnection` but relies\n * on the given `BroadcastChannel` to communicate instructions\n * with the client connections from other runtimes.\n */\nexport class WebSocketRemoteClientConnection\n implements WebSocketClientConnectionProtocol\n{\n constructor(\n public readonly id: string,\n public readonly url: URL,\n private channel: BroadcastChannel,\n ) {}\n\n send(data: WebSocketData): void {\n this.channel.postMessage({\n type: 'extraneous:send',\n payload: {\n clientId: this.id,\n data,\n },\n } as WebSocketBroadcastChannelMessage)\n }\n\n close(code?: number | undefined, reason?: string | undefined): void {\n this.channel.postMessage({\n type: 'extraneous:close',\n payload: {\n clientId: this.id,\n code,\n reason,\n },\n } as WebSocketBroadcastChannelMessage)\n }\n\n addEventListener<EventType extends keyof WebSocketClientEventMap>(\n _type: EventType,\n _listener: (\n this: WebSocket,\n event: WebSocketClientEventMap[EventType],\n ) => void,\n _options?: AddEventListenerOptions | boolean,\n ): void {\n throw new Error(\n 'WebSocketRemoteClientConnection.addEventListener is not supported',\n )\n }\n\n removeEventListener<EventType extends keyof WebSocketClientEventMap>(\n _event: EventType,\n _listener: (\n this: WebSocket,\n event: WebSocketClientEventMap[EventType],\n ) => void,\n _options?: EventListenerOptions | boolean,\n ): void {\n throw new Error(\n 'WebSocketRemoteClientConnection.removeEventListener is not supported',\n )\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,wCAA2C;AAC3C,2CAA8C;AAuBvC,MAAM,uBAAuB;AAAA,EAKlC,YAAoB,SAA2B;AAA3B;AAGlB,SAAK,QACH,OAAO,cAAc,cACjB,IAAI,mEAA8B,IAClC,IAAI,6DAA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N,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAAA,EAEA,oBACE,QACA,WAIA,UACM;AACN,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
|
@@ -121,6 +121,16 @@ class WebSocketRemoteClientConnection {
|
|
|
121
121
|
}
|
|
122
122
|
});
|
|
123
123
|
}
|
|
124
|
+
addEventListener(_type, _listener, _options) {
|
|
125
|
+
throw new Error(
|
|
126
|
+
"WebSocketRemoteClientConnection.addEventListener is not supported"
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
removeEventListener(_event, _listener, _options) {
|
|
130
|
+
throw new Error(
|
|
131
|
+
"WebSocketRemoteClientConnection.removeEventListener is not supported"
|
|
132
|
+
);
|
|
133
|
+
}
|
|
124
134
|
}
|
|
125
135
|
export {
|
|
126
136
|
WebSocketClientManager,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/core/ws/WebSocketClientManager.ts"],"sourcesContent":["import type {\n WebSocketData,\n
|
|
1
|
+
{"version":3,"sources":["../../../src/core/ws/WebSocketClientManager.ts"],"sourcesContent":["import type {\n WebSocketData,\n WebSocketClientConnectionProtocol,\n WebSocketClientEventMap,\n} from '@mswjs/interceptors/WebSocket'\nimport { WebSocketClientStore } from './WebSocketClientStore'\nimport { WebSocketMemoryClientStore } from './WebSocketMemoryClientStore'\nimport { WebSocketIndexedDBClientStore } from './WebSocketIndexedDBClientStore'\n\nexport type WebSocketBroadcastChannelMessage =\n | {\n type: 'extraneous:send'\n payload: {\n clientId: string\n data: WebSocketData\n }\n }\n | {\n type: 'extraneous:close'\n payload: {\n clientId: string\n code?: number\n reason?: string\n }\n }\n\n/**\n * A manager responsible for accumulating WebSocket client\n * connections across different browser runtimes.\n */\nexport class WebSocketClientManager {\n private store: WebSocketClientStore\n private runtimeClients: Map<string, WebSocketClientConnectionProtocol>\n private allClients: Set<WebSocketClientConnectionProtocol>\n\n constructor(private channel: BroadcastChannel) {\n // Store the clients in the IndexedDB in the browser,\n // otherwise, store the clients in memory.\n this.store =\n typeof indexedDB !== 'undefined'\n ? new WebSocketIndexedDBClientStore()\n : new WebSocketMemoryClientStore()\n\n this.runtimeClients = new Map()\n this.allClients = new Set()\n\n this.channel.addEventListener('message', (message) => {\n if (message.data?.type === 'db:update') {\n this.flushDatabaseToMemory()\n }\n })\n\n if (typeof window !== 'undefined') {\n window.addEventListener('message', async (message) => {\n if (message.data?.type === 'msw/worker:stop') {\n await this.removeRuntimeClients()\n }\n })\n }\n }\n\n private async flushDatabaseToMemory() {\n const storedClients = await this.store.getAll()\n\n this.allClients = new Set(\n storedClients.map((client) => {\n const runtimeClient = this.runtimeClients.get(client.id)\n\n /**\n * @note For clients originating in this runtime, use their\n * direct references. No need to wrap them in a remote connection.\n */\n if (runtimeClient) {\n return runtimeClient\n }\n\n return new WebSocketRemoteClientConnection(\n client.id,\n new URL(client.url),\n this.channel,\n )\n }),\n )\n }\n\n private async removeRuntimeClients(): Promise<void> {\n await this.store.deleteMany(Array.from(this.runtimeClients.keys()))\n this.runtimeClients.clear()\n await this.flushDatabaseToMemory()\n this.notifyOthersAboutDatabaseUpdate()\n }\n\n /**\n * All active WebSocket client connections.\n */\n get clients(): Set<WebSocketClientConnectionProtocol> {\n return this.allClients\n }\n\n /**\n * Notify other runtimes about the database update\n * using the shared `BroadcastChannel` instance.\n */\n private notifyOthersAboutDatabaseUpdate(): void {\n this.channel.postMessage({ type: 'db:update' })\n }\n\n private async addClient(\n client: WebSocketClientConnectionProtocol,\n ): Promise<void> {\n await this.store.add(client)\n // Sync the in-memory clients in this runtime with the\n // updated database. This pulls in all the stored clients.\n await this.flushDatabaseToMemory()\n this.notifyOthersAboutDatabaseUpdate()\n }\n\n /**\n * Adds the given `WebSocket` client connection to the set\n * of all connections. The given connection is always the complete\n * connection object because `addConnection()` is called only\n * for the opened connections in the same runtime.\n */\n public async addConnection(\n client: WebSocketClientConnectionProtocol,\n ): Promise<void> {\n // Store this client in the map of clients created in this runtime.\n // This way, the manager can distinguish between this runtime clients\n // and extraneous runtime clients when synchronizing clients storage.\n this.runtimeClients.set(client.id, client)\n\n // Add the new client to the storage.\n await this.addClient(client)\n\n // Handle the incoming BroadcastChannel messages from other runtimes\n // that attempt to control this runtime (via a remote connection wrapper).\n // E.g. another runtime calling `client.send()` for the client in this runtime.\n const handleExtraneousMessage = (\n message: MessageEvent<WebSocketBroadcastChannelMessage>,\n ) => {\n const { type, payload } = message.data\n\n // Ignore broadcasted messages for other clients.\n if (\n typeof payload === 'object' &&\n 'clientId' in payload &&\n payload.clientId !== client.id\n ) {\n return\n }\n\n switch (type) {\n case 'extraneous:send': {\n client.send(payload.data)\n break\n }\n\n case 'extraneous:close': {\n client.close(payload.code, payload.reason)\n break\n }\n }\n }\n\n const abortController = new AbortController()\n\n this.channel.addEventListener('message', handleExtraneousMessage, {\n signal: abortController.signal,\n })\n\n // Once closed, this connection cannot be operated on.\n // This must include the extraneous runtimes as well.\n client.addEventListener('close', () => abortController.abort(), {\n once: true,\n })\n }\n}\n\n/**\n * A wrapper class to operate with WebSocket client connections\n * from other runtimes. This class maintains 1-1 public API\n * compatibility to the `WebSocketClientConnection` but relies\n * on the given `BroadcastChannel` to communicate instructions\n * with the client connections from other runtimes.\n */\nexport class WebSocketRemoteClientConnection\n implements WebSocketClientConnectionProtocol\n{\n constructor(\n public readonly id: string,\n public readonly url: URL,\n private channel: BroadcastChannel,\n ) {}\n\n send(data: WebSocketData): void {\n this.channel.postMessage({\n type: 'extraneous:send',\n payload: {\n clientId: this.id,\n data,\n },\n } as WebSocketBroadcastChannelMessage)\n }\n\n close(code?: number | undefined, reason?: string | undefined): void {\n this.channel.postMessage({\n type: 'extraneous:close',\n payload: {\n clientId: this.id,\n code,\n reason,\n },\n } as WebSocketBroadcastChannelMessage)\n }\n\n addEventListener<EventType extends keyof WebSocketClientEventMap>(\n _type: EventType,\n _listener: (\n this: WebSocket,\n event: WebSocketClientEventMap[EventType],\n ) => void,\n _options?: AddEventListenerOptions | boolean,\n ): void {\n throw new Error(\n 'WebSocketRemoteClientConnection.addEventListener is not supported',\n )\n }\n\n removeEventListener<EventType extends keyof WebSocketClientEventMap>(\n _event: EventType,\n _listener: (\n this: WebSocket,\n event: WebSocketClientEventMap[EventType],\n ) => void,\n _options?: EventListenerOptions | boolean,\n ): void {\n throw new Error(\n 'WebSocketRemoteClientConnection.removeEventListener is not supported',\n )\n }\n}\n"],"mappings":"AAMA,SAAS,kCAAkC;AAC3C,SAAS,qCAAqC;AAuBvC,MAAM,uBAAuB;AAAA,EAKlC,YAAoB,SAA2B;AAA3B;AAGlB,SAAK,QACH,OAAO,cAAc,cACjB,IAAI,8BAA8B,IAClC,IAAI,2BAA2B;AAErC,SAAK,iBAAiB,oBAAI,IAAI;AAC9B,SAAK,aAAa,oBAAI,IAAI;AAE1B,SAAK,QAAQ,iBAAiB,WAAW,CAAC,YAAY;AACpD,UAAI,QAAQ,MAAM,SAAS,aAAa;AACtC,aAAK,sBAAsB;AAAA,MAC7B;AAAA,IACF,CAAC;AAED,QAAI,OAAO,WAAW,aAAa;AACjC,aAAO,iBAAiB,WAAW,OAAO,YAAY;AACpD,YAAI,QAAQ,MAAM,SAAS,mBAAmB;AAC5C,gBAAM,KAAK,qBAAqB;AAAA,QAClC;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AAAA,EA5BQ;AAAA,EACA;AAAA,EACA;AAAA,EA4BR,MAAc,wBAAwB;AACpC,UAAM,gBAAgB,MAAM,KAAK,MAAM,OAAO;AAE9C,SAAK,aAAa,IAAI;AAAA,MACpB,cAAc,IAAI,CAAC,WAAW;AAC5B,cAAM,gBAAgB,KAAK,eAAe,IAAI,OAAO,EAAE;AAMvD,YAAI,eAAe;AACjB,iBAAO;AAAA,QACT;AAEA,eAAO,IAAI;AAAA,UACT,OAAO;AAAA,UACP,IAAI,IAAI,OAAO,GAAG;AAAA,UAClB,KAAK;AAAA,QACP;AAAA,MACF,CAAC;A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H;AACF;AASO,MAAM,gCAEb;AAAA,EACE,YACkB,IACA,KACR,SACR;AAHgB;AACA;AACR;AAAA,EACP;AAAA,EAEH,KAAK,MAA2B;AAC9B,SAAK,QAAQ,YAAY;AAAA,MACvB,MAAM;AAAA,MACN,SAAS;AAAA,QACP,UAAU,KAAK;AAAA,QACf;AAAA,MACF;AAAA,IACF,CAAqC;AAAA,EACvC;AAAA,EAEA,MAAM,MAA2B,QAAmC;AAClE,SAAK,QAAQ,YAAY;AAAA,MACvB,MAAM;AAAA,MACN,SAAS;AAAA,QACP,UAAU,KAAK;AAAA,QACf;AAAA,QACA;AAAA,MACF;AAAA,IACF,CAAqC;AAAA,EACvC;AAAA,EAEA,iBACE,OACA,WAIA,UACM;AACN,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAAA,EAEA,oBACE,QACA,WAIA,UACM;AACN,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
package/lib/iife/index.js
CHANGED
|
@@ -14246,7 +14246,7 @@ ${operationTypes.join("\n")}
|
|
|
14246
14246
|
return stringToRegexp(path, keys, options);
|
|
14247
14247
|
}
|
|
14248
14248
|
|
|
14249
|
-
// node_modules/.pnpm/@mswjs+interceptors@0.
|
|
14249
|
+
// node_modules/.pnpm/@mswjs+interceptors@0.39.1/node_modules/@mswjs/interceptors/lib/browser/chunk-6HYIRFX2.mjs
|
|
14250
14250
|
var encoder = new TextEncoder();
|
|
14251
14251
|
function encodeBuffer(text) {
|
|
14252
14252
|
return encoder.encode(text);
|
|
@@ -14262,7 +14262,7 @@ ${operationTypes.join("\n")}
|
|
|
14262
14262
|
);
|
|
14263
14263
|
}
|
|
14264
14264
|
|
|
14265
|
-
// node_modules/.pnpm/@mswjs+interceptors@0.
|
|
14265
|
+
// node_modules/.pnpm/@mswjs+interceptors@0.39.1/node_modules/@mswjs/interceptors/lib/browser/chunk-3RXCRGL2.mjs
|
|
14266
14266
|
var IS_PATCHED_MODULE = Symbol("isPatchedModule");
|
|
14267
14267
|
function canParseUrl(url) {
|
|
14268
14268
|
try {
|
|
@@ -14643,7 +14643,7 @@ ${operationTypes.join("\n")}
|
|
|
14643
14643
|
return message3.toString();
|
|
14644
14644
|
}
|
|
14645
14645
|
|
|
14646
|
-
// node_modules/.pnpm/@mswjs+interceptors@0.
|
|
14646
|
+
// node_modules/.pnpm/@mswjs+interceptors@0.39.1/node_modules/@mswjs/interceptors/lib/browser/chunk-QED3Q6Z2.mjs
|
|
14647
14647
|
var INTERNAL_REQUEST_ID_HEADER_NAME = "x-interceptors-internal-request-id";
|
|
14648
14648
|
function getGlobalSymbol(symbol) {
|
|
14649
14649
|
return (
|
|
@@ -14791,7 +14791,7 @@ ${operationTypes.join("\n")}
|
|
|
14791
14791
|
return Math.random().toString(16).slice(2);
|
|
14792
14792
|
}
|
|
14793
14793
|
|
|
14794
|
-
// node_modules/.pnpm/@mswjs+interceptors@0.
|
|
14794
|
+
// node_modules/.pnpm/@mswjs+interceptors@0.39.1/node_modules/@mswjs/interceptors/lib/browser/index.mjs
|
|
14795
14795
|
var BatchInterceptor = class extends Interceptor {
|
|
14796
14796
|
constructor(options) {
|
|
14797
14797
|
BatchInterceptor.symbol = Symbol(options.name);
|
|
@@ -28450,6 +28450,16 @@ Consider naming this operation or using "graphql.operation()" request handler to
|
|
|
28450
28450
|
}
|
|
28451
28451
|
});
|
|
28452
28452
|
}
|
|
28453
|
+
addEventListener(_type, _listener, _options) {
|
|
28454
|
+
throw new Error(
|
|
28455
|
+
"WebSocketRemoteClientConnection.addEventListener is not supported"
|
|
28456
|
+
);
|
|
28457
|
+
}
|
|
28458
|
+
removeEventListener(_event, _listener, _options) {
|
|
28459
|
+
throw new Error(
|
|
28460
|
+
"WebSocketRemoteClientConnection.removeEventListener is not supported"
|
|
28461
|
+
);
|
|
28462
|
+
}
|
|
28453
28463
|
};
|
|
28454
28464
|
|
|
28455
28465
|
// src/core/ws.ts
|
|
@@ -29361,7 +29371,7 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
|
|
|
29361
29371
|
}
|
|
29362
29372
|
};
|
|
29363
29373
|
|
|
29364
|
-
// node_modules/.pnpm/@mswjs+interceptors@0.
|
|
29374
|
+
// node_modules/.pnpm/@mswjs+interceptors@0.39.1/node_modules/@mswjs/interceptors/lib/browser/chunk-L37TY7LC.mjs
|
|
29365
29375
|
var InterceptorError = class extends Error {
|
|
29366
29376
|
constructor(message3) {
|
|
29367
29377
|
super(message3);
|
|
@@ -29578,7 +29588,7 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
|
|
|
29578
29588
|
return false;
|
|
29579
29589
|
}
|
|
29580
29590
|
|
|
29581
|
-
// node_modules/.pnpm/@mswjs+interceptors@0.
|
|
29591
|
+
// node_modules/.pnpm/@mswjs+interceptors@0.39.1/node_modules/@mswjs/interceptors/lib/browser/chunk-TX5GBTFY.mjs
|
|
29582
29592
|
function hasConfigurableGlobal(propertyName) {
|
|
29583
29593
|
const descriptor = Object.getOwnPropertyDescriptor(globalThis, propertyName);
|
|
29584
29594
|
if (typeof descriptor === "undefined") {
|
|
@@ -29599,7 +29609,7 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
|
|
|
29599
29609
|
return true;
|
|
29600
29610
|
}
|
|
29601
29611
|
|
|
29602
|
-
// node_modules/.pnpm/@mswjs+interceptors@0.
|
|
29612
|
+
// node_modules/.pnpm/@mswjs+interceptors@0.39.1/node_modules/@mswjs/interceptors/lib/browser/chunk-ARPHZXGT.mjs
|
|
29603
29613
|
function createNetworkError(cause) {
|
|
29604
29614
|
return Object.assign(new TypeError("Failed to fetch"), {
|
|
29605
29615
|
cause
|
|
@@ -29855,7 +29865,7 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
|
|
|
29855
29865
|
var FetchInterceptor = _FetchInterceptor;
|
|
29856
29866
|
FetchInterceptor.symbol = Symbol("fetch");
|
|
29857
29867
|
|
|
29858
|
-
// node_modules/.pnpm/@mswjs+interceptors@0.
|
|
29868
|
+
// node_modules/.pnpm/@mswjs+interceptors@0.39.1/node_modules/@mswjs/interceptors/lib/browser/chunk-QKSBFQDK.mjs
|
|
29859
29869
|
function concatArrayBuffer(left, right) {
|
|
29860
29870
|
const result = new Uint8Array(left.byteLength + right.byteLength);
|
|
29861
29871
|
result.set(left, 0);
|
|
@@ -30728,7 +30738,7 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
|
|
|
30728
30738
|
}
|
|
30729
30739
|
}
|
|
30730
30740
|
|
|
30731
|
-
// node_modules/.pnpm/@mswjs+interceptors@0.
|
|
30741
|
+
// node_modules/.pnpm/@mswjs+interceptors@0.39.1/node_modules/@mswjs/interceptors/lib/browser/interceptors/WebSocket/index.mjs
|
|
30732
30742
|
function bindEvent(target, event) {
|
|
30733
30743
|
Object.defineProperties(event, {
|
|
30734
30744
|
target: {
|