msw 2.3.0-ws.rc-1 → 2.3.0-ws.rc-2
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 +8 -3
- package/cli/init.js +1 -1
- package/lib/browser/index.d.mts +4 -4
- package/lib/browser/index.js +64 -59
- package/lib/browser/index.js.map +1 -1
- package/lib/browser/index.mjs +64 -59
- package/lib/browser/index.mjs.map +1 -1
- package/lib/core/{GraphQLHandler-Cbu12sb0.d.ts → GraphQLHandler-3gvpA65n.d.ts} +3 -3
- package/lib/core/{GraphQLHandler-QGQY_9Rc.d.mts → GraphQLHandler-4DPdxG0R.d.mts} +3 -3
- package/lib/core/{HttpResponse-BWB1yDNM.d.mts → HttpResponse-aJY-D0oG.d.ts} +3 -3
- package/lib/core/{HttpResponse-DeJBWGN5.d.ts → HttpResponse-xuSipbNt.d.mts} +3 -3
- package/lib/core/HttpResponse.d.mts +1 -1
- package/lib/core/HttpResponse.d.ts +1 -1
- package/lib/core/HttpResponse.js.map +1 -1
- package/lib/core/HttpResponse.mjs.map +1 -1
- package/lib/core/SetupApi.d.mts +1 -1
- package/lib/core/SetupApi.d.ts +1 -1
- package/lib/core/bypass.js +6 -1
- package/lib/core/bypass.js.map +1 -1
- package/lib/core/bypass.mjs +6 -1
- package/lib/core/bypass.mjs.map +1 -1
- package/lib/core/getResponse.d.mts +1 -1
- package/lib/core/getResponse.d.ts +1 -1
- package/lib/core/getResponse.js +2 -2
- package/lib/core/getResponse.js.map +1 -1
- package/lib/core/getResponse.mjs +2 -2
- package/lib/core/getResponse.mjs.map +1 -1
- package/lib/core/graphql.d.mts +8 -6
- package/lib/core/graphql.d.ts +8 -6
- package/lib/core/graphql.js.map +1 -1
- package/lib/core/graphql.mjs.map +1 -1
- package/lib/core/handlers/GraphQLHandler.d.mts +2 -2
- package/lib/core/handlers/GraphQLHandler.d.ts +2 -2
- package/lib/core/handlers/GraphQLHandler.js.map +1 -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 -1
- package/lib/core/handlers/HttpHandler.js.map +1 -1
- package/lib/core/handlers/HttpHandler.mjs +1 -1
- 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/WebSocketHandler.d.mts +11 -17
- package/lib/core/handlers/WebSocketHandler.d.ts +11 -17
- package/lib/core/handlers/WebSocketHandler.js +9 -12
- package/lib/core/handlers/WebSocketHandler.js.map +1 -1
- package/lib/core/handlers/WebSocketHandler.mjs +9 -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/index.d.mts +4 -4
- package/lib/core/index.d.ts +4 -4
- package/lib/core/index.js +2 -0
- package/lib/core/index.js.map +1 -1
- package/lib/core/index.mjs +4 -0
- package/lib/core/index.mjs.map +1 -1
- package/lib/core/passthrough.d.mts +1 -1
- package/lib/core/passthrough.d.ts +1 -1
- package/lib/core/typeUtils.d.mts +6 -1
- package/lib/core/typeUtils.d.ts +6 -1
- package/lib/core/typeUtils.js.map +1 -1
- package/lib/core/utils/HttpResponse/decorators.d.mts +1 -1
- package/lib/core/utils/HttpResponse/decorators.d.ts +1 -1
- package/lib/core/utils/HttpResponse/decorators.js +4 -1
- package/lib/core/utils/HttpResponse/decorators.js.map +1 -1
- package/lib/core/utils/HttpResponse/decorators.mjs +4 -1
- package/lib/core/utils/HttpResponse/decorators.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/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/handleWebSocketEvent.d.mts +8 -2
- package/lib/core/utils/handleWebSocketEvent.d.ts +8 -2
- package/lib/core/utils/handleWebSocketEvent.js +20 -17
- package/lib/core/utils/handleWebSocketEvent.js.map +1 -1
- package/lib/core/utils/handleWebSocketEvent.mjs +21 -22
- package/lib/core/utils/handleWebSocketEvent.mjs.map +1 -1
- package/lib/core/utils/internal/mergeRight.js +15 -12
- package/lib/core/utils/internal/mergeRight.js.map +1 -1
- package/lib/core/utils/internal/mergeRight.mjs +15 -12
- package/lib/core/utils/internal/mergeRight.mjs.map +1 -1
- package/lib/core/utils/internal/parseGraphQLRequest.d.mts +2 -2
- package/lib/core/utils/internal/parseGraphQLRequest.d.ts +2 -2
- 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/requestHandlerUtils.d.mts +1 -1
- package/lib/core/utils/internal/requestHandlerUtils.d.ts +1 -1
- package/lib/core/utils/logging/getTimestamp.d.mts +4 -1
- package/lib/core/utils/logging/getTimestamp.d.ts +4 -1
- package/lib/core/utils/logging/getTimestamp.js +6 -2
- package/lib/core/utils/logging/getTimestamp.js.map +1 -1
- package/lib/core/utils/logging/getTimestamp.mjs +6 -2
- package/lib/core/utils/logging/getTimestamp.mjs.map +1 -1
- package/lib/core/ws/utils/attachWebSocketLogger.d.mts +34 -0
- package/lib/core/ws/utils/attachWebSocketLogger.d.ts +34 -0
- package/lib/core/ws/utils/attachWebSocketLogger.js +211 -0
- package/lib/core/ws/utils/attachWebSocketLogger.js.map +1 -0
- package/lib/core/ws/utils/attachWebSocketLogger.mjs +191 -0
- package/lib/core/ws/utils/attachWebSocketLogger.mjs.map +1 -0
- package/lib/core/ws/utils/getMessageLength.d.mts +11 -0
- package/lib/core/ws/utils/getMessageLength.d.ts +11 -0
- package/lib/core/ws/utils/getMessageLength.js +33 -0
- package/lib/core/ws/utils/getMessageLength.js.map +1 -0
- package/lib/core/ws/utils/getMessageLength.mjs +13 -0
- package/lib/core/ws/utils/getMessageLength.mjs.map +1 -0
- package/lib/core/ws/utils/getPublicData.d.mts +5 -0
- package/lib/core/ws/utils/getPublicData.d.ts +5 -0
- package/lib/core/ws/utils/getPublicData.js +36 -0
- package/lib/core/ws/utils/getPublicData.js.map +1 -0
- package/lib/core/ws/utils/getPublicData.mjs +16 -0
- package/lib/core/ws/utils/getPublicData.mjs.map +1 -0
- package/lib/core/ws/utils/truncateMessage.d.mts +3 -0
- package/lib/core/ws/utils/truncateMessage.d.ts +3 -0
- package/lib/core/{utils/internal/randomId.js → ws/utils/truncateMessage.js} +11 -7
- package/lib/core/ws/utils/truncateMessage.js.map +1 -0
- package/lib/core/ws/utils/truncateMessage.mjs +11 -0
- package/lib/core/ws/utils/truncateMessage.mjs.map +1 -0
- package/lib/iife/index.js +508 -231
- package/lib/iife/index.js.map +1 -1
- package/lib/mockServiceWorker.js +8 -11
- package/lib/native/index.d.mts +4 -4
- package/lib/native/index.js +8 -2
- package/lib/native/index.js.map +1 -1
- package/lib/native/index.mjs +8 -2
- package/lib/native/index.mjs.map +1 -1
- package/lib/node/index.d.mts +6 -6
- package/lib/node/index.d.ts +2 -2
- package/lib/node/index.js +8 -2
- package/lib/node/index.js.map +1 -1
- package/lib/node/index.mjs +8 -2
- package/lib/node/index.mjs.map +1 -1
- package/package.json +8 -11
- package/src/browser/setupWorker/glossary.ts +4 -1
- package/src/browser/setupWorker/setupWorker.ts +19 -2
- package/src/browser/setupWorker/start/createRequestListener.ts +1 -1
- package/src/browser/setupWorker/start/createStartHandler.ts +9 -19
- package/src/browser/setupWorker/start/utils/createMessageChannel.ts +1 -1
- package/src/browser/utils/checkWorkerIntegrity.ts +34 -0
- package/src/core/HttpResponse.ts +3 -2
- package/src/core/bypass.test.ts +22 -0
- package/src/core/bypass.ts +9 -1
- package/src/core/getResponse.ts +2 -2
- package/src/core/graphql.ts +6 -3
- package/src/core/handlers/GraphQLHandler.test.ts +4 -5
- package/src/core/handlers/GraphQLHandler.ts +7 -4
- package/src/core/handlers/HttpHandler.test.ts +5 -5
- package/src/core/handlers/HttpHandler.ts +1 -1
- package/src/core/handlers/WebSocketHandler.ts +21 -39
- package/src/core/index.ts +6 -2
- package/src/core/typeUtils.ts +16 -10
- package/src/core/utils/HttpResponse/decorators.ts +8 -4
- package/src/core/utils/handleRequest.test.ts +14 -14
- package/src/core/utils/handleRequest.ts +1 -1
- package/src/core/utils/handleWebSocketEvent.ts +39 -29
- package/src/core/utils/internal/mergeRight.ts +16 -13
- package/src/core/utils/logging/getTimestamp.test.ts +20 -6
- package/src/core/utils/logging/getTimestamp.ts +11 -6
- package/src/core/ws/utils/attachWebSocketLogger.ts +262 -0
- package/src/core/ws/utils/getMessageLength.test.ts +16 -0
- package/src/core/ws/utils/getMessageLength.ts +19 -0
- package/src/core/ws/utils/getPublicData.test.ts +38 -0
- package/src/core/ws/utils/getPublicData.ts +17 -0
- package/src/core/ws/utils/truncateMessage.test.ts +12 -0
- package/src/core/ws/utils/truncateMessage.ts +9 -0
- package/src/mockServiceWorker.js +7 -10
- package/src/node/SetupServerApi.ts +4 -4
- package/src/node/SetupServerCommonApi.ts +6 -2
- package/src/node/glossary.ts +3 -3
- package/lib/core/utils/internal/randomId.d.mts +0 -3
- package/lib/core/utils/internal/randomId.d.ts +0 -3
- package/lib/core/utils/internal/randomId.js.map +0 -1
- package/lib/core/utils/internal/randomId.mjs +0 -7
- package/lib/core/utils/internal/randomId.mjs.map +0 -1
- package/src/browser/utils/requestIntegrityCheck.ts +0 -23
- package/src/core/utils/internal/randomId.ts +0 -3
package/lib/browser/index.mjs
CHANGED
|
@@ -95,6 +95,9 @@ function isNodeProcess() {
|
|
|
95
95
|
return false;
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
+
// src/browser/setupWorker/start/createStartHandler.ts
|
|
99
|
+
import { devUtils as devUtils7 } from '../core/utils/internal/devUtils.mjs';
|
|
100
|
+
|
|
98
101
|
// node_modules/.pnpm/@open-draft+until@2.1.0/node_modules/@open-draft/until/lib/index.mjs
|
|
99
102
|
var until = async (promise) => {
|
|
100
103
|
try {
|
|
@@ -107,9 +110,6 @@ var until = async (promise) => {
|
|
|
107
110
|
}
|
|
108
111
|
};
|
|
109
112
|
|
|
110
|
-
// src/browser/setupWorker/start/createStartHandler.ts
|
|
111
|
-
import { devUtils as devUtils6 } from '../core/utils/internal/devUtils.mjs';
|
|
112
|
-
|
|
113
113
|
// src/browser/setupWorker/start/utils/getWorkerInstance.ts
|
|
114
114
|
import { devUtils } from '../core/utils/internal/devUtils.mjs';
|
|
115
115
|
|
|
@@ -288,7 +288,7 @@ var createRequestListener = (context, options) => {
|
|
|
288
288
|
context.emitter,
|
|
289
289
|
{
|
|
290
290
|
onPassthroughResponse() {
|
|
291
|
-
messageChannel.postMessage("
|
|
291
|
+
messageChannel.postMessage("PASSTHROUGH");
|
|
292
292
|
},
|
|
293
293
|
async onMockedResponse(response, { handler, parsedResult }) {
|
|
294
294
|
const responseClone = response.clone();
|
|
@@ -352,21 +352,25 @@ This exception has been gracefully handled as a 500 response, however, it's stro
|
|
|
352
352
|
};
|
|
353
353
|
};
|
|
354
354
|
|
|
355
|
-
// src/browser/utils/
|
|
356
|
-
|
|
355
|
+
// src/browser/utils/checkWorkerIntegrity.ts
|
|
356
|
+
import { devUtils as devUtils5 } from '../core/utils/internal/devUtils.mjs';
|
|
357
|
+
async function checkWorkerIntegrity(context) {
|
|
357
358
|
context.workerChannel.send("INTEGRITY_CHECK_REQUEST");
|
|
358
|
-
const { payload
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
359
|
+
const { payload } = await context.events.once("INTEGRITY_CHECK_RESPONSE");
|
|
360
|
+
if (payload.checksum !== "26357c79639bfa20d64c0efca2a87423") {
|
|
361
|
+
devUtils5.warn(
|
|
362
|
+
`The currently registered Service Worker has been generated by a different version of MSW (${payload.packageVersion}) and may not be fully compatible with the installed version.
|
|
363
|
+
|
|
364
|
+
It's recommended you update your worker script by running this command:
|
|
365
|
+
|
|
366
|
+
\u2022 npx msw init <PUBLIC_DIR>
|
|
367
|
+
|
|
368
|
+
You can also automate this process and make the worker script update automatically upon the library installations. Read more: https://mswjs.io/docs/cli/init.`
|
|
364
369
|
);
|
|
365
370
|
}
|
|
366
|
-
return serviceWorker;
|
|
367
371
|
}
|
|
368
372
|
|
|
369
|
-
// node_modules/.pnpm/@mswjs+interceptors@0.26.
|
|
373
|
+
// node_modules/.pnpm/@mswjs+interceptors@0.26.15/node_modules/@mswjs/interceptors/lib/browser/chunk-UJZOJSMP.mjs
|
|
370
374
|
var encoder = new TextEncoder();
|
|
371
375
|
function encodeBuffer(text) {
|
|
372
376
|
return encoder.encode(text);
|
|
@@ -392,7 +396,7 @@ function isResponseWithoutBody(status) {
|
|
|
392
396
|
return RESPONSE_STATUS_CODES_WITHOUT_BODY.has(status);
|
|
393
397
|
}
|
|
394
398
|
|
|
395
|
-
// node_modules/.pnpm/@mswjs+interceptors@0.26.
|
|
399
|
+
// node_modules/.pnpm/@mswjs+interceptors@0.26.15/node_modules/@mswjs/interceptors/lib/browser/chunk-HAGW22AN.mjs
|
|
396
400
|
var IS_PATCHED_MODULE = Symbol("isPatchedModule");
|
|
397
401
|
|
|
398
402
|
// node_modules/.pnpm/@open-draft+logger@0.3.0/node_modules/@open-draft/logger/lib/index.mjs
|
|
@@ -832,7 +836,8 @@ var _Emitter = class {
|
|
|
832
836
|
var Emitter = _Emitter;
|
|
833
837
|
Emitter.defaultMaxListeners = 10;
|
|
834
838
|
|
|
835
|
-
// node_modules/.pnpm/@mswjs+interceptors@0.26.
|
|
839
|
+
// node_modules/.pnpm/@mswjs+interceptors@0.26.15/node_modules/@mswjs/interceptors/lib/browser/chunk-QED3Q6Z2.mjs
|
|
840
|
+
var INTERNAL_REQUEST_ID_HEADER_NAME = "x-interceptors-internal-request-id";
|
|
836
841
|
function getGlobalSymbol(symbol) {
|
|
837
842
|
return (
|
|
838
843
|
// @ts-ignore https://github.com/Microsoft/TypeScript/issues/24587
|
|
@@ -975,8 +980,11 @@ var Interceptor = class {
|
|
|
975
980
|
this.logger.info("cleared global instance!", this.symbol.description);
|
|
976
981
|
}
|
|
977
982
|
};
|
|
983
|
+
function createRequestId() {
|
|
984
|
+
return Math.random().toString(16).slice(2);
|
|
985
|
+
}
|
|
978
986
|
|
|
979
|
-
// node_modules/.pnpm/@mswjs+interceptors@0.26.
|
|
987
|
+
// node_modules/.pnpm/@mswjs+interceptors@0.26.15/node_modules/@mswjs/interceptors/lib/browser/index.mjs
|
|
980
988
|
var BatchInterceptor = class extends Interceptor {
|
|
981
989
|
constructor(options) {
|
|
982
990
|
BatchInterceptor.symbol = Symbol(options.name);
|
|
@@ -1058,10 +1066,10 @@ function createResponseListener(context) {
|
|
|
1058
1066
|
}
|
|
1059
1067
|
|
|
1060
1068
|
// src/browser/setupWorker/start/utils/validateWorkerScope.ts
|
|
1061
|
-
import { devUtils as
|
|
1069
|
+
import { devUtils as devUtils6 } from '../core/utils/internal/devUtils.mjs';
|
|
1062
1070
|
function validateWorkerScope(registration, options) {
|
|
1063
1071
|
if (!options?.quiet && !location.href.startsWith(registration.scope)) {
|
|
1064
|
-
|
|
1072
|
+
devUtils6.warn(
|
|
1065
1073
|
`Cannot intercept requests on this page because it's outside of the worker's scope ("${registration.scope}"). If you wish to mock API requests on this page, you must resolve this scope issue.
|
|
1066
1074
|
|
|
1067
1075
|
- (Recommended) Register the worker at the root level ("/") of your application.
|
|
@@ -1087,14 +1095,14 @@ var createStartHandler = (context) => {
|
|
|
1087
1095
|
);
|
|
1088
1096
|
const [worker, registration] = instance;
|
|
1089
1097
|
if (!worker) {
|
|
1090
|
-
const missingWorkerMessage = customOptions?.findWorker ?
|
|
1098
|
+
const missingWorkerMessage = customOptions?.findWorker ? devUtils7.formatMessage(
|
|
1091
1099
|
`Failed to locate the Service Worker registration using a custom "findWorker" predicate.
|
|
1092
1100
|
|
|
1093
1101
|
Please ensure that the custom predicate properly locates the Service Worker registration at "%s".
|
|
1094
1102
|
More details: https://mswjs.io/docs/api/setup-worker/start#findworker
|
|
1095
1103
|
`,
|
|
1096
1104
|
options.serviceWorker.url
|
|
1097
|
-
) :
|
|
1105
|
+
) : devUtils7.formatMessage(
|
|
1098
1106
|
`Failed to locate the Service Worker registration.
|
|
1099
1107
|
|
|
1100
1108
|
This most likely means that the worker script URL "%s" cannot resolve against the actual public hostname (%s). This may happen if your application runs behind a proxy, or has a dynamic hostname.
|
|
@@ -1113,19 +1121,12 @@ Please consider using a custom "serviceWorker.url" option to point to the actual
|
|
|
1113
1121
|
}
|
|
1114
1122
|
window.clearInterval(context.keepAliveInterval);
|
|
1115
1123
|
});
|
|
1116
|
-
|
|
1117
|
-
(
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
The mocking is still enabled, but it's highly recommended that you update your Service Worker by running:
|
|
1123
|
-
|
|
1124
|
-
$ npx msw init <PUBLIC_DIR>
|
|
1125
|
-
|
|
1126
|
-
This is necessary to ensure that the Service Worker is in sync with the library to guarantee its stability.
|
|
1127
|
-
If this message still persists after updating, please report an issue: https://github.com/open-draft/msw/issues `);
|
|
1128
|
-
}
|
|
1124
|
+
await checkWorkerIntegrity(context).catch((error2) => {
|
|
1125
|
+
devUtils7.error(
|
|
1126
|
+
"Error while checking the worker script integrity. Please report this on GitHub (https://github.com/mswjs/msw/issues), including the original error below."
|
|
1127
|
+
);
|
|
1128
|
+
console.error(error2);
|
|
1129
|
+
});
|
|
1129
1130
|
context.keepAliveInterval = window.setInterval(
|
|
1130
1131
|
() => context.workerChannel.send("KEEPALIVE_REQUEST"),
|
|
1131
1132
|
5e3
|
|
@@ -1156,16 +1157,16 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
1156
1157
|
};
|
|
1157
1158
|
|
|
1158
1159
|
// src/browser/setupWorker/stop/createStop.ts
|
|
1159
|
-
import { devUtils as
|
|
1160
|
+
import { devUtils as devUtils9 } from '../core/utils/internal/devUtils.mjs';
|
|
1160
1161
|
|
|
1161
1162
|
// src/browser/setupWorker/stop/utils/printStopMessage.ts
|
|
1162
|
-
import { devUtils as
|
|
1163
|
+
import { devUtils as devUtils8 } from '../core/utils/internal/devUtils.mjs';
|
|
1163
1164
|
function printStopMessage(args = {}) {
|
|
1164
1165
|
if (args.quiet) {
|
|
1165
1166
|
return;
|
|
1166
1167
|
}
|
|
1167
1168
|
console.log(
|
|
1168
|
-
`%c${
|
|
1169
|
+
`%c${devUtils8.formatMessage("Mocking disabled.")}`,
|
|
1169
1170
|
"color:orangered;font-weight:bold;"
|
|
1170
1171
|
);
|
|
1171
1172
|
}
|
|
@@ -1174,7 +1175,7 @@ function printStopMessage(args = {}) {
|
|
|
1174
1175
|
var createStop = (context) => {
|
|
1175
1176
|
return function stop() {
|
|
1176
1177
|
if (!context.isMockingEnabled) {
|
|
1177
|
-
|
|
1178
|
+
devUtils9.warn(
|
|
1178
1179
|
'Found a redundant "worker.stop()" call. Note that stopping the worker while mocking already stopped has no effect. Consider removing this "worker.stop()" call.'
|
|
1179
1180
|
);
|
|
1180
1181
|
return;
|
|
@@ -1267,7 +1268,7 @@ var DeferredPromise = class extends Promise {
|
|
|
1267
1268
|
}
|
|
1268
1269
|
};
|
|
1269
1270
|
|
|
1270
|
-
// node_modules/.pnpm/@mswjs+interceptors@0.26.
|
|
1271
|
+
// node_modules/.pnpm/@mswjs+interceptors@0.26.15/node_modules/@mswjs/interceptors/lib/browser/chunk-OUWBQF3Z.mjs
|
|
1271
1272
|
var RequestController = class {
|
|
1272
1273
|
constructor(request) {
|
|
1273
1274
|
this.request = request;
|
|
@@ -1305,16 +1306,7 @@ async function emitAsync(emitter, eventName, ...data) {
|
|
|
1305
1306
|
}
|
|
1306
1307
|
}
|
|
1307
1308
|
|
|
1308
|
-
// node_modules/.pnpm/@mswjs+interceptors@0.26.
|
|
1309
|
-
function uuidv4() {
|
|
1310
|
-
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
|
|
1311
|
-
const r = Math.random() * 16 | 0;
|
|
1312
|
-
const v = c == "x" ? r : r & 3 | 8;
|
|
1313
|
-
return v.toString(16);
|
|
1314
|
-
});
|
|
1315
|
-
}
|
|
1316
|
-
|
|
1317
|
-
// node_modules/.pnpm/@mswjs+interceptors@0.26.8/node_modules/@mswjs/interceptors/lib/browser/chunk-65OQZE6W.mjs
|
|
1309
|
+
// node_modules/.pnpm/@mswjs+interceptors@0.26.15/node_modules/@mswjs/interceptors/lib/browser/chunk-3FNUI33J.mjs
|
|
1318
1310
|
function isPropertyAccessible(obj, key) {
|
|
1319
1311
|
try {
|
|
1320
1312
|
obj[key];
|
|
@@ -1338,7 +1330,7 @@ var _FetchInterceptor = class extends Interceptor {
|
|
|
1338
1330
|
checkEnvironment() {
|
|
1339
1331
|
return typeof globalThis !== "undefined" && typeof globalThis.fetch !== "undefined";
|
|
1340
1332
|
}
|
|
1341
|
-
setup() {
|
|
1333
|
+
async setup() {
|
|
1342
1334
|
const pureFetch = globalThis.fetch;
|
|
1343
1335
|
invariant(
|
|
1344
1336
|
!pureFetch[IS_PATCHED_MODULE],
|
|
@@ -1346,7 +1338,7 @@ var _FetchInterceptor = class extends Interceptor {
|
|
|
1346
1338
|
);
|
|
1347
1339
|
globalThis.fetch = async (input, init) => {
|
|
1348
1340
|
var _a;
|
|
1349
|
-
const requestId =
|
|
1341
|
+
const requestId = createRequestId();
|
|
1350
1342
|
const resolvedInput = typeof input === "string" && typeof location !== "undefined" && !canParseUrl(input) ? new URL(input, location.origin) : input;
|
|
1351
1343
|
const request = new Request(resolvedInput, init);
|
|
1352
1344
|
this.logger.info("[%s] %s", request.method, request.url);
|
|
@@ -1461,7 +1453,7 @@ function createNetworkError(cause) {
|
|
|
1461
1453
|
});
|
|
1462
1454
|
}
|
|
1463
1455
|
|
|
1464
|
-
// node_modules/.pnpm/@mswjs+interceptors@0.26.
|
|
1456
|
+
// node_modules/.pnpm/@mswjs+interceptors@0.26.15/node_modules/@mswjs/interceptors/lib/browser/chunk-VYFS2IF2.mjs
|
|
1465
1457
|
function concatArrayBuffer(left, right) {
|
|
1466
1458
|
const result = new Uint8Array(left.byteLength + right.byteLength);
|
|
1467
1459
|
result.set(left, 0);
|
|
@@ -1655,7 +1647,7 @@ var XMLHttpRequestController = class {
|
|
|
1655
1647
|
this.method = "GET";
|
|
1656
1648
|
this.url = null;
|
|
1657
1649
|
this.events = /* @__PURE__ */ new Map();
|
|
1658
|
-
this.requestId =
|
|
1650
|
+
this.requestId = createRequestId();
|
|
1659
1651
|
this.requestHeaders = new Headers();
|
|
1660
1652
|
this.responseBuffer = new Uint8Array();
|
|
1661
1653
|
this.request = createProxy(initialRequest, {
|
|
@@ -1737,7 +1729,10 @@ var XMLHttpRequestController = class {
|
|
|
1737
1729
|
this.request.readyState
|
|
1738
1730
|
);
|
|
1739
1731
|
if (IS_NODE2) {
|
|
1740
|
-
this.request.setRequestHeader(
|
|
1732
|
+
this.request.setRequestHeader(
|
|
1733
|
+
INTERNAL_REQUEST_ID_HEADER_NAME,
|
|
1734
|
+
this.requestId
|
|
1735
|
+
);
|
|
1741
1736
|
}
|
|
1742
1737
|
return invoke();
|
|
1743
1738
|
}
|
|
@@ -2271,7 +2266,7 @@ function createFallbackStop(context) {
|
|
|
2271
2266
|
}
|
|
2272
2267
|
|
|
2273
2268
|
// src/browser/setupWorker/setupWorker.ts
|
|
2274
|
-
import { devUtils as
|
|
2269
|
+
import { devUtils as devUtils10 } from '../core/utils/internal/devUtils.mjs';
|
|
2275
2270
|
import { SetupApi } from '../core/SetupApi.mjs';
|
|
2276
2271
|
import { mergeRight as mergeRight2 } from '../core/utils/internal/mergeRight.mjs';
|
|
2277
2272
|
|
|
@@ -2292,6 +2287,7 @@ function supportsReadableStreamTransfer() {
|
|
|
2292
2287
|
// src/browser/setupWorker/setupWorker.ts
|
|
2293
2288
|
import { webSocketInterceptor } from '../core/ws/webSocketInterceptor.mjs';
|
|
2294
2289
|
import { handleWebSocketEvent } from '../core/utils/handleWebSocketEvent.mjs';
|
|
2290
|
+
import { attachWebSocketLogger } from '../core/ws/utils/attachWebSocketLogger.mjs';
|
|
2295
2291
|
var SetupWorkerApi = class extends SetupApi {
|
|
2296
2292
|
context;
|
|
2297
2293
|
startHandler = null;
|
|
@@ -2301,7 +2297,7 @@ var SetupWorkerApi = class extends SetupApi {
|
|
|
2301
2297
|
super(...handlers);
|
|
2302
2298
|
invariant(
|
|
2303
2299
|
!isNodeProcess(),
|
|
2304
|
-
|
|
2300
|
+
devUtils10.formatMessage(
|
|
2305
2301
|
"Failed to execute `setupWorker` in a non-browser environment. Consider using `setupServer` for Node.js environment instead."
|
|
2306
2302
|
)
|
|
2307
2303
|
);
|
|
@@ -2399,7 +2395,7 @@ var SetupWorkerApi = class extends SetupApi {
|
|
|
2399
2395
|
}
|
|
2400
2396
|
async start(options = {}) {
|
|
2401
2397
|
if (options.waitUntilReady === true) {
|
|
2402
|
-
|
|
2398
|
+
devUtils10.warn(
|
|
2403
2399
|
'The "waitUntilReady" option has been deprecated. Please remove it from this "worker.start()" call. Follow the recommended Browser integration (https://mswjs.io/docs/integrations/browser) to eliminate any race conditions between the Service Worker registration and any requests made by your application on initial render.'
|
|
2404
2400
|
);
|
|
2405
2401
|
}
|
|
@@ -2407,8 +2403,17 @@ var SetupWorkerApi = class extends SetupApi {
|
|
|
2407
2403
|
DEFAULT_START_OPTIONS,
|
|
2408
2404
|
options
|
|
2409
2405
|
);
|
|
2410
|
-
handleWebSocketEvent(
|
|
2411
|
-
|
|
2406
|
+
handleWebSocketEvent({
|
|
2407
|
+
getHandlers: () => {
|
|
2408
|
+
return this.handlersController.currentHandlers();
|
|
2409
|
+
},
|
|
2410
|
+
onMockedConnection: (connection) => {
|
|
2411
|
+
if (!this.context.startOptions.quiet) {
|
|
2412
|
+
attachWebSocketLogger(connection);
|
|
2413
|
+
}
|
|
2414
|
+
},
|
|
2415
|
+
onPassthroughConnection() {
|
|
2416
|
+
}
|
|
2412
2417
|
});
|
|
2413
2418
|
webSocketInterceptor.apply();
|
|
2414
2419
|
this.subscriptions.push(() => {
|