msw 2.3.0-ws.rc-10 → 2.3.0-ws.rc-11
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 +7 -7
- package/lib/browser/index.js.map +1 -1
- package/lib/browser/index.mjs +7 -7
- package/lib/browser/index.mjs.map +1 -1
- package/lib/core/ws/utils/attachWebSocketLogger.d.mts +2 -24
- package/lib/core/ws/utils/attachWebSocketLogger.d.ts +2 -24
- package/lib/core/ws/utils/attachWebSocketLogger.js +39 -58
- package/lib/core/ws/utils/attachWebSocketLogger.js.map +1 -1
- package/lib/core/ws/utils/attachWebSocketLogger.mjs +39 -58
- package/lib/core/ws/utils/attachWebSocketLogger.mjs.map +1 -1
- package/lib/iife/index.js +51 -61
- package/lib/iife/index.js.map +1 -1
- package/lib/mockServiceWorker.js +1 -1
- package/package.json +2 -2
- package/src/core/ws/utils/attachWebSocketLogger.ts +43 -77
package/lib/iife/index.js
CHANGED
|
@@ -14412,7 +14412,7 @@ ${operationTypes.join("\n")}
|
|
|
14412
14412
|
return stringToRegexp(path, keys, options);
|
|
14413
14413
|
}
|
|
14414
14414
|
|
|
14415
|
-
// node_modules/.pnpm/@mswjs+interceptors@0.36.
|
|
14415
|
+
// node_modules/.pnpm/@mswjs+interceptors@0.36.1/node_modules/@mswjs/interceptors/lib/browser/chunk-6HYIRFX2.mjs
|
|
14416
14416
|
var encoder = new TextEncoder();
|
|
14417
14417
|
function encodeBuffer(text) {
|
|
14418
14418
|
return encoder.encode(text);
|
|
@@ -14428,7 +14428,7 @@ ${operationTypes.join("\n")}
|
|
|
14428
14428
|
);
|
|
14429
14429
|
}
|
|
14430
14430
|
|
|
14431
|
-
// node_modules/.pnpm/@mswjs+interceptors@0.36.
|
|
14431
|
+
// node_modules/.pnpm/@mswjs+interceptors@0.36.1/node_modules/@mswjs/interceptors/lib/browser/chunk-XVPRNJO7.mjs
|
|
14432
14432
|
var IS_PATCHED_MODULE = Symbol("isPatchedModule");
|
|
14433
14433
|
function isPropertyAccessible(obj, key) {
|
|
14434
14434
|
try {
|
|
@@ -14848,7 +14848,7 @@ ${operationTypes.join("\n")}
|
|
|
14848
14848
|
return message3.toString();
|
|
14849
14849
|
}
|
|
14850
14850
|
|
|
14851
|
-
// node_modules/.pnpm/@mswjs+interceptors@0.36.
|
|
14851
|
+
// node_modules/.pnpm/@mswjs+interceptors@0.36.1/node_modules/@mswjs/interceptors/lib/browser/chunk-QED3Q6Z2.mjs
|
|
14852
14852
|
var INTERNAL_REQUEST_ID_HEADER_NAME = "x-interceptors-internal-request-id";
|
|
14853
14853
|
function getGlobalSymbol(symbol) {
|
|
14854
14854
|
return (
|
|
@@ -14996,7 +14996,7 @@ ${operationTypes.join("\n")}
|
|
|
14996
14996
|
return Math.random().toString(16).slice(2);
|
|
14997
14997
|
}
|
|
14998
14998
|
|
|
14999
|
-
// node_modules/.pnpm/@mswjs+interceptors@0.36.
|
|
14999
|
+
// node_modules/.pnpm/@mswjs+interceptors@0.36.1/node_modules/@mswjs/interceptors/lib/browser/index.mjs
|
|
15000
15000
|
var BatchInterceptor = class extends Interceptor {
|
|
15001
15001
|
constructor(options) {
|
|
15002
15002
|
BatchInterceptor.symbol = Symbol(options.name);
|
|
@@ -29475,7 +29475,7 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
|
|
|
29475
29475
|
}
|
|
29476
29476
|
};
|
|
29477
29477
|
|
|
29478
|
-
// node_modules/.pnpm/@mswjs+interceptors@0.36.
|
|
29478
|
+
// node_modules/.pnpm/@mswjs+interceptors@0.36.1/node_modules/@mswjs/interceptors/lib/browser/chunk-THPGBWJQ.mjs
|
|
29479
29479
|
var InterceptorError = class extends Error {
|
|
29480
29480
|
constructor(message3) {
|
|
29481
29481
|
super(message3);
|
|
@@ -29643,7 +29643,7 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
|
|
|
29643
29643
|
return false;
|
|
29644
29644
|
}
|
|
29645
29645
|
|
|
29646
|
-
// node_modules/.pnpm/@mswjs+interceptors@0.36.
|
|
29646
|
+
// node_modules/.pnpm/@mswjs+interceptors@0.36.1/node_modules/@mswjs/interceptors/lib/browser/chunk-G5SOR3ND.mjs
|
|
29647
29647
|
function canParseUrl(url) {
|
|
29648
29648
|
try {
|
|
29649
29649
|
new URL(url);
|
|
@@ -29840,7 +29840,7 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
|
|
|
29840
29840
|
var FetchInterceptor = _FetchInterceptor;
|
|
29841
29841
|
FetchInterceptor.symbol = Symbol("fetch");
|
|
29842
29842
|
|
|
29843
|
-
// node_modules/.pnpm/@mswjs+interceptors@0.36.
|
|
29843
|
+
// node_modules/.pnpm/@mswjs+interceptors@0.36.1/node_modules/@mswjs/interceptors/lib/browser/chunk-SUQ32ZQK.mjs
|
|
29844
29844
|
function concatArrayBuffer(left, right) {
|
|
29845
29845
|
const result = new Uint8Array(left.byteLength + right.byteLength);
|
|
29846
29846
|
result.set(left, 0);
|
|
@@ -30711,7 +30711,7 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
|
|
|
30711
30711
|
}
|
|
30712
30712
|
}
|
|
30713
30713
|
|
|
30714
|
-
// node_modules/.pnpm/@mswjs+interceptors@0.36.
|
|
30714
|
+
// node_modules/.pnpm/@mswjs+interceptors@0.36.1/node_modules/@mswjs/interceptors/lib/browser/interceptors/WebSocket/index.mjs
|
|
30715
30715
|
function bindEvent(target, event) {
|
|
30716
30716
|
Object.defineProperties(event, {
|
|
30717
30717
|
target: {
|
|
@@ -31003,6 +31003,7 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
|
|
|
31003
31003
|
}
|
|
31004
31004
|
var kEmitter22 = Symbol("kEmitter");
|
|
31005
31005
|
var kBoundListener2 = Symbol("kBoundListener");
|
|
31006
|
+
var kSend = Symbol("kSend");
|
|
31006
31007
|
var WebSocketServerConnection = class {
|
|
31007
31008
|
constructor(client, transport, createConnection) {
|
|
31008
31009
|
this.client = client;
|
|
@@ -31017,7 +31018,7 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
|
|
|
31017
31018
|
}
|
|
31018
31019
|
queueMicrotask(() => {
|
|
31019
31020
|
if (!event.defaultPrevented) {
|
|
31020
|
-
this
|
|
31021
|
+
this[kSend](event.data);
|
|
31021
31022
|
}
|
|
31022
31023
|
});
|
|
31023
31024
|
});
|
|
@@ -31112,6 +31113,9 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
|
|
|
31112
31113
|
* server.send(new TextEncoder().encode('hello'))
|
|
31113
31114
|
*/
|
|
31114
31115
|
send(data) {
|
|
31116
|
+
this[kSend](data);
|
|
31117
|
+
}
|
|
31118
|
+
[(kEmitter22, kSend)](data) {
|
|
31115
31119
|
const { realWebSocket } = this;
|
|
31116
31120
|
invariant2(
|
|
31117
31121
|
realWebSocket,
|
|
@@ -31419,10 +31423,10 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
|
|
|
31419
31423
|
|
|
31420
31424
|
// src/core/ws/utils/attachWebSocketLogger.ts
|
|
31421
31425
|
var colors = {
|
|
31422
|
-
|
|
31423
|
-
|
|
31424
|
-
|
|
31425
|
-
|
|
31426
|
+
system: "#3b82f6",
|
|
31427
|
+
outgoing: "#22c55e",
|
|
31428
|
+
incoming: "#ef4444",
|
|
31429
|
+
mocked: "#ff6a33"
|
|
31426
31430
|
};
|
|
31427
31431
|
function attachWebSocketLogger(connection) {
|
|
31428
31432
|
const { client, server } = connection;
|
|
@@ -31433,9 +31437,6 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
|
|
|
31433
31437
|
client.addEventListener("close", (event) => {
|
|
31434
31438
|
logConnectionClose(event);
|
|
31435
31439
|
});
|
|
31436
|
-
client.socket.addEventListener("message", (event) => {
|
|
31437
|
-
logIncomingClientMessage(event);
|
|
31438
|
-
});
|
|
31439
31440
|
client.socket.addEventListener("error", (event) => {
|
|
31440
31441
|
logClientError(event);
|
|
31441
31442
|
});
|
|
@@ -31455,7 +31456,9 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
|
|
|
31455
31456
|
value: client.socket
|
|
31456
31457
|
}
|
|
31457
31458
|
});
|
|
31458
|
-
|
|
31459
|
+
queueMicrotask(() => {
|
|
31460
|
+
logIncomingMockedClientMessage(messageEvent);
|
|
31461
|
+
});
|
|
31459
31462
|
return Reflect.apply(target, thisArg, args);
|
|
31460
31463
|
}
|
|
31461
31464
|
});
|
|
@@ -31493,50 +31496,47 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
|
|
|
31493
31496
|
const publicUrl = toPublicUrl(client.url);
|
|
31494
31497
|
console.groupCollapsed(
|
|
31495
31498
|
devUtils.formatMessage(`${getTimestamp()} %c\u25B6%c ${publicUrl}`),
|
|
31496
|
-
`color:${colors.
|
|
31499
|
+
`color:${colors.system}`,
|
|
31497
31500
|
"color:inherit"
|
|
31498
31501
|
);
|
|
31499
31502
|
console.log("Client:", client.socket);
|
|
31500
31503
|
console.groupEnd();
|
|
31501
31504
|
}
|
|
31502
|
-
|
|
31503
|
-
const
|
|
31504
|
-
const
|
|
31505
|
+
function logConnectionClose(event) {
|
|
31506
|
+
const target = event.target;
|
|
31507
|
+
const publicUrl = toPublicUrl(target.url);
|
|
31505
31508
|
console.groupCollapsed(
|
|
31506
31509
|
devUtils.formatMessage(
|
|
31507
|
-
`${getTimestamp({ milliseconds: true })} %c\
|
|
31510
|
+
`${getTimestamp({ milliseconds: true })} %c\u25A0%c ${publicUrl}`
|
|
31508
31511
|
),
|
|
31509
|
-
`color:${colors.
|
|
31510
|
-
"color:inherit"
|
|
31511
|
-
"color:gray;font-weight:normal",
|
|
31512
|
-
"color:inherit;font-weight:inherit"
|
|
31512
|
+
`color:${colors.system}`,
|
|
31513
|
+
"color:inherit"
|
|
31513
31514
|
);
|
|
31514
31515
|
console.log(event);
|
|
31515
31516
|
console.groupEnd();
|
|
31516
31517
|
}
|
|
31517
|
-
|
|
31518
|
-
const
|
|
31519
|
-
const
|
|
31518
|
+
function logClientError(event) {
|
|
31519
|
+
const socket = event.target;
|
|
31520
|
+
const publicUrl = toPublicUrl(socket.url);
|
|
31520
31521
|
console.groupCollapsed(
|
|
31521
31522
|
devUtils.formatMessage(
|
|
31522
|
-
`${getTimestamp({ milliseconds: true })} %c\
|
|
31523
|
+
`${getTimestamp({ milliseconds: true })} %c\xD7%c ${publicUrl}`
|
|
31523
31524
|
),
|
|
31524
|
-
`color:${colors.
|
|
31525
|
-
"color:inherit"
|
|
31526
|
-
"color:gray;font-weight:normal",
|
|
31527
|
-
"color:inherit;font-weight:inherit"
|
|
31525
|
+
`color:${colors.system}`,
|
|
31526
|
+
"color:inherit"
|
|
31528
31527
|
);
|
|
31529
31528
|
console.log(event);
|
|
31530
31529
|
console.groupEnd();
|
|
31531
31530
|
}
|
|
31532
|
-
async function
|
|
31531
|
+
async function logOutgoingClientMessage(event) {
|
|
31533
31532
|
const byteLength = getMessageLength(event.data);
|
|
31534
31533
|
const publicData = await getPublicData(event.data);
|
|
31534
|
+
const arrow = event.defaultPrevented ? "\u21E1" : "\u2B06";
|
|
31535
31535
|
console.groupCollapsed(
|
|
31536
31536
|
devUtils.formatMessage(
|
|
31537
|
-
`${getTimestamp({ milliseconds: true })} %c
|
|
31537
|
+
`${getTimestamp({ milliseconds: true })} %c${arrow}%c ${publicData} %c${byteLength}%c`
|
|
31538
31538
|
),
|
|
31539
|
-
`color:${colors.
|
|
31539
|
+
`color:${colors.outgoing}`,
|
|
31540
31540
|
"color:inherit",
|
|
31541
31541
|
"color:gray;font-weight:normal",
|
|
31542
31542
|
"color:inherit;font-weight:inherit"
|
|
@@ -31544,14 +31544,14 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
|
|
|
31544
31544
|
console.log(event);
|
|
31545
31545
|
console.groupEnd();
|
|
31546
31546
|
}
|
|
31547
|
-
async function
|
|
31547
|
+
async function logOutgoingMockedClientMessage(event) {
|
|
31548
31548
|
const byteLength = getMessageLength(event.data);
|
|
31549
31549
|
const publicData = await getPublicData(event.data);
|
|
31550
31550
|
console.groupCollapsed(
|
|
31551
31551
|
devUtils.formatMessage(
|
|
31552
|
-
`${getTimestamp({ milliseconds: true })} %c\
|
|
31552
|
+
`${getTimestamp({ milliseconds: true })} %c\u2B06%c ${publicData} %c${byteLength}%c`
|
|
31553
31553
|
),
|
|
31554
|
-
`color:${colors.
|
|
31554
|
+
`color:${colors.mocked}`,
|
|
31555
31555
|
"color:inherit",
|
|
31556
31556
|
"color:gray;font-weight:normal",
|
|
31557
31557
|
"color:inherit;font-weight:inherit"
|
|
@@ -31559,15 +31559,17 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
|
|
|
31559
31559
|
console.log(event);
|
|
31560
31560
|
console.groupEnd();
|
|
31561
31561
|
}
|
|
31562
|
-
function
|
|
31563
|
-
const
|
|
31564
|
-
const
|
|
31562
|
+
async function logIncomingMockedClientMessage(event) {
|
|
31563
|
+
const byteLength = getMessageLength(event.data);
|
|
31564
|
+
const publicData = await getPublicData(event.data);
|
|
31565
31565
|
console.groupCollapsed(
|
|
31566
31566
|
devUtils.formatMessage(
|
|
31567
|
-
`${getTimestamp({ milliseconds: true })} %c\
|
|
31567
|
+
`${getTimestamp({ milliseconds: true })} %c\u2B07%c ${publicData} %c${byteLength}%c`
|
|
31568
31568
|
),
|
|
31569
|
-
`color:${colors.
|
|
31570
|
-
"color:inherit"
|
|
31569
|
+
`color:${colors.mocked}`,
|
|
31570
|
+
"color:inherit",
|
|
31571
|
+
"color:gray;font-weight:normal",
|
|
31572
|
+
"color:inherit;font-weight:inherit"
|
|
31571
31573
|
);
|
|
31572
31574
|
console.log(event);
|
|
31573
31575
|
console.groupEnd();
|
|
@@ -31575,11 +31577,12 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
|
|
|
31575
31577
|
async function logIncomingServerMessage(event) {
|
|
31576
31578
|
const byteLength = getMessageLength(event.data);
|
|
31577
31579
|
const publicData = await getPublicData(event.data);
|
|
31580
|
+
const arrow = event.defaultPrevented ? "\u21E3" : "\u2B07";
|
|
31578
31581
|
console.groupCollapsed(
|
|
31579
31582
|
devUtils.formatMessage(
|
|
31580
|
-
`${getTimestamp({ milliseconds: true })} %c
|
|
31583
|
+
`${getTimestamp({ milliseconds: true })} %c${arrow}%c ${publicData} %c${byteLength}%c`
|
|
31581
31584
|
),
|
|
31582
|
-
`color:${colors.
|
|
31585
|
+
`color:${colors.incoming}`,
|
|
31583
31586
|
"color:inherit",
|
|
31584
31587
|
"color:gray;font-weight:normal",
|
|
31585
31588
|
"color:inherit;font-weight:inherit"
|
|
@@ -31587,19 +31590,6 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
|
|
|
31587
31590
|
console.log(event);
|
|
31588
31591
|
console.groupEnd();
|
|
31589
31592
|
}
|
|
31590
|
-
function logClientError(event) {
|
|
31591
|
-
const socket = event.target;
|
|
31592
|
-
const publicUrl = toPublicUrl(socket.url);
|
|
31593
|
-
console.groupCollapsed(
|
|
31594
|
-
devUtils.formatMessage(
|
|
31595
|
-
`${getTimestamp({ milliseconds: true })} %c\xD7%c ${publicUrl}`
|
|
31596
|
-
),
|
|
31597
|
-
`color:${colors.blue}`,
|
|
31598
|
-
"color:inherit"
|
|
31599
|
-
);
|
|
31600
|
-
console.log(event);
|
|
31601
|
-
console.groupEnd();
|
|
31602
|
-
}
|
|
31603
31593
|
|
|
31604
31594
|
// src/browser/setupWorker/setupWorker.ts
|
|
31605
31595
|
var SetupWorkerApi = class extends SetupApi {
|