msw 2.4.10 → 2.4.12
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 +23 -105
- package/lib/browser/index.js.map +1 -1
- package/lib/browser/index.mjs +23 -105
- package/lib/browser/index.mjs.map +1 -1
- package/lib/core/{GraphQLHandler-5pZBHLn9.d.mts → GraphQLHandler-ClMB0BOy.d.mts} +1 -1
- package/lib/core/{GraphQLHandler-Cu4Xvg4S.d.ts → GraphQLHandler-D6mLMXGZ.d.ts} +1 -1
- package/lib/core/{HttpResponse-DE19n76Q.d.ts → HttpResponse-DaYkf3ml.d.ts} +1 -1
- package/lib/core/{HttpResponse-Gtw1lt3H.d.mts → HttpResponse-vn-Pb4Bi.d.mts} +1 -1
- package/lib/core/HttpResponse.d.mts +1 -1
- package/lib/core/HttpResponse.d.ts +1 -1
- package/lib/core/SetupApi.d.mts +1 -1
- package/lib/core/SetupApi.d.ts +1 -1
- package/lib/core/getResponse.d.mts +1 -1
- package/lib/core/getResponse.d.ts +1 -1
- package/lib/core/graphql.d.mts +2 -2
- package/lib/core/graphql.d.ts +2 -2
- package/lib/core/handlers/GraphQLHandler.d.mts +2 -2
- package/lib/core/handlers/GraphQLHandler.d.ts +2 -2
- package/lib/core/handlers/HttpHandler.d.mts +1 -1
- package/lib/core/handlers/HttpHandler.d.ts +1 -1
- package/lib/core/handlers/RequestHandler.d.mts +1 -1
- package/lib/core/handlers/RequestHandler.d.ts +1 -1
- package/lib/core/http.d.mts +1 -1
- package/lib/core/http.d.ts +1 -1
- package/lib/core/index.d.mts +2 -2
- package/lib/core/index.d.ts +2 -2
- package/lib/core/passthrough.d.mts +1 -1
- package/lib/core/passthrough.d.ts +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/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/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/iife/index.js +117 -189
- package/lib/iife/index.js.map +1 -1
- package/lib/mockServiceWorker.js +1 -1
- package/package.json +22 -23
package/lib/browser/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// node_modules/.pnpm/outvariant@1.4.
|
|
1
|
+
// node_modules/.pnpm/outvariant@1.4.3/node_modules/outvariant/lib/index.mjs
|
|
2
2
|
var POSITIONALS_EXP = /(%?)(%([sdijo]))/g;
|
|
3
3
|
function serializePositional(positional, flag) {
|
|
4
4
|
switch (flag) {
|
|
@@ -69,10 +69,12 @@ var invariant = (predicate, message, ...positionals) => {
|
|
|
69
69
|
};
|
|
70
70
|
invariant.as = (ErrorConstructor, predicate, message, ...positionals) => {
|
|
71
71
|
if (!predicate) {
|
|
72
|
-
const formatMessage = positionals.length === 0 ? message : format(message, positionals);
|
|
72
|
+
const formatMessage = positionals.length === 0 ? message : format(message, ...positionals);
|
|
73
73
|
let error2;
|
|
74
74
|
try {
|
|
75
|
-
error2 = Reflect.construct(ErrorConstructor, [
|
|
75
|
+
error2 = Reflect.construct(ErrorConstructor, [
|
|
76
|
+
formatMessage
|
|
77
|
+
]);
|
|
76
78
|
} catch (err) {
|
|
77
79
|
error2 = ErrorConstructor(formatMessage);
|
|
78
80
|
}
|
|
@@ -369,7 +371,7 @@ You can also automate this process and make the worker script update automatical
|
|
|
369
371
|
}
|
|
370
372
|
}
|
|
371
373
|
|
|
372
|
-
// node_modules/.pnpm/@mswjs+interceptors@0.
|
|
374
|
+
// node_modules/.pnpm/@mswjs+interceptors@0.36.5/node_modules/@mswjs/interceptors/lib/browser/chunk-6HYIRFX2.mjs
|
|
373
375
|
var encoder = new TextEncoder();
|
|
374
376
|
function encodeBuffer(text) {
|
|
375
377
|
return encoder.encode(text);
|
|
@@ -385,7 +387,7 @@ function toArrayBuffer(array) {
|
|
|
385
387
|
);
|
|
386
388
|
}
|
|
387
389
|
|
|
388
|
-
// node_modules/.pnpm/@mswjs+interceptors@0.
|
|
390
|
+
// node_modules/.pnpm/@mswjs+interceptors@0.36.5/node_modules/@mswjs/interceptors/lib/browser/chunk-XVPRNJO7.mjs
|
|
389
391
|
var IS_PATCHED_MODULE = Symbol("isPatchedModule");
|
|
390
392
|
function isPropertyAccessible(obj, key) {
|
|
391
393
|
try {
|
|
@@ -434,90 +436,6 @@ function isResponseError(response) {
|
|
|
434
436
|
return isPropertyAccessible(response, "type") && response.type === "error";
|
|
435
437
|
}
|
|
436
438
|
|
|
437
|
-
// node_modules/.pnpm/outvariant@1.4.3/node_modules/outvariant/lib/index.mjs
|
|
438
|
-
var POSITIONALS_EXP2 = /(%?)(%([sdijo]))/g;
|
|
439
|
-
function serializePositional2(positional, flag) {
|
|
440
|
-
switch (flag) {
|
|
441
|
-
case "s":
|
|
442
|
-
return positional;
|
|
443
|
-
case "d":
|
|
444
|
-
case "i":
|
|
445
|
-
return Number(positional);
|
|
446
|
-
case "j":
|
|
447
|
-
return JSON.stringify(positional);
|
|
448
|
-
case "o": {
|
|
449
|
-
if (typeof positional === "string") {
|
|
450
|
-
return positional;
|
|
451
|
-
}
|
|
452
|
-
const json = JSON.stringify(positional);
|
|
453
|
-
if (json === "{}" || json === "[]" || /^\[object .+?\]$/.test(json)) {
|
|
454
|
-
return positional;
|
|
455
|
-
}
|
|
456
|
-
return json;
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
|
-
function format2(message, ...positionals) {
|
|
461
|
-
if (positionals.length === 0) {
|
|
462
|
-
return message;
|
|
463
|
-
}
|
|
464
|
-
let positionalIndex = 0;
|
|
465
|
-
let formattedMessage = message.replace(
|
|
466
|
-
POSITIONALS_EXP2,
|
|
467
|
-
(match, isEscaped, _, flag) => {
|
|
468
|
-
const positional = positionals[positionalIndex];
|
|
469
|
-
const value = serializePositional2(positional, flag);
|
|
470
|
-
if (!isEscaped) {
|
|
471
|
-
positionalIndex++;
|
|
472
|
-
return value;
|
|
473
|
-
}
|
|
474
|
-
return match;
|
|
475
|
-
}
|
|
476
|
-
);
|
|
477
|
-
if (positionalIndex < positionals.length) {
|
|
478
|
-
formattedMessage += ` ${positionals.slice(positionalIndex).join(" ")}`;
|
|
479
|
-
}
|
|
480
|
-
formattedMessage = formattedMessage.replace(/%{2,2}/g, "%");
|
|
481
|
-
return formattedMessage;
|
|
482
|
-
}
|
|
483
|
-
var STACK_FRAMES_TO_IGNORE2 = 2;
|
|
484
|
-
function cleanErrorStack2(error2) {
|
|
485
|
-
if (!error2.stack) {
|
|
486
|
-
return;
|
|
487
|
-
}
|
|
488
|
-
const nextStack = error2.stack.split("\n");
|
|
489
|
-
nextStack.splice(1, STACK_FRAMES_TO_IGNORE2);
|
|
490
|
-
error2.stack = nextStack.join("\n");
|
|
491
|
-
}
|
|
492
|
-
var InvariantError2 = class extends Error {
|
|
493
|
-
constructor(message, ...positionals) {
|
|
494
|
-
super(message);
|
|
495
|
-
this.message = message;
|
|
496
|
-
this.name = "Invariant Violation";
|
|
497
|
-
this.message = format2(message, ...positionals);
|
|
498
|
-
cleanErrorStack2(this);
|
|
499
|
-
}
|
|
500
|
-
};
|
|
501
|
-
var invariant2 = (predicate, message, ...positionals) => {
|
|
502
|
-
if (!predicate) {
|
|
503
|
-
throw new InvariantError2(message, ...positionals);
|
|
504
|
-
}
|
|
505
|
-
};
|
|
506
|
-
invariant2.as = (ErrorConstructor, predicate, message, ...positionals) => {
|
|
507
|
-
if (!predicate) {
|
|
508
|
-
const formatMessage = positionals.length === 0 ? message : format2(message, ...positionals);
|
|
509
|
-
let error2;
|
|
510
|
-
try {
|
|
511
|
-
error2 = Reflect.construct(ErrorConstructor, [
|
|
512
|
-
formatMessage
|
|
513
|
-
]);
|
|
514
|
-
} catch (err) {
|
|
515
|
-
error2 = ErrorConstructor(formatMessage);
|
|
516
|
-
}
|
|
517
|
-
throw error2;
|
|
518
|
-
}
|
|
519
|
-
};
|
|
520
|
-
|
|
521
439
|
// node_modules/.pnpm/@open-draft+logger@0.3.0/node_modules/@open-draft/logger/lib/index.mjs
|
|
522
440
|
var __defProp = Object.defineProperty;
|
|
523
441
|
var __export = (target, all) => {
|
|
@@ -746,21 +664,21 @@ var PerformanceEntry = class {
|
|
|
746
664
|
var noop = () => void 0;
|
|
747
665
|
function log(message, ...positionals) {
|
|
748
666
|
if (IS_NODE) {
|
|
749
|
-
process.stdout.write(
|
|
667
|
+
process.stdout.write(format(message, ...positionals) + "\n");
|
|
750
668
|
return;
|
|
751
669
|
}
|
|
752
670
|
console.log(message, ...positionals);
|
|
753
671
|
}
|
|
754
672
|
function warn(message, ...positionals) {
|
|
755
673
|
if (IS_NODE) {
|
|
756
|
-
process.stderr.write(
|
|
674
|
+
process.stderr.write(format(message, ...positionals) + "\n");
|
|
757
675
|
return;
|
|
758
676
|
}
|
|
759
677
|
console.warn(message, ...positionals);
|
|
760
678
|
}
|
|
761
679
|
function error(message, ...positionals) {
|
|
762
680
|
if (IS_NODE) {
|
|
763
|
-
process.stderr.write(
|
|
681
|
+
process.stderr.write(format(message, ...positionals) + "\n");
|
|
764
682
|
return;
|
|
765
683
|
}
|
|
766
684
|
console.error(message, ...positionals);
|
|
@@ -955,7 +873,7 @@ var _Emitter = class {
|
|
|
955
873
|
var Emitter = _Emitter;
|
|
956
874
|
Emitter.defaultMaxListeners = 10;
|
|
957
875
|
|
|
958
|
-
// node_modules/.pnpm/@mswjs+interceptors@0.
|
|
876
|
+
// node_modules/.pnpm/@mswjs+interceptors@0.36.5/node_modules/@mswjs/interceptors/lib/browser/chunk-QED3Q6Z2.mjs
|
|
959
877
|
var INTERNAL_REQUEST_ID_HEADER_NAME = "x-interceptors-internal-request-id";
|
|
960
878
|
function getGlobalSymbol(symbol) {
|
|
961
879
|
return (
|
|
@@ -1103,7 +1021,7 @@ function createRequestId() {
|
|
|
1103
1021
|
return Math.random().toString(16).slice(2);
|
|
1104
1022
|
}
|
|
1105
1023
|
|
|
1106
|
-
// node_modules/.pnpm/@mswjs+interceptors@0.
|
|
1024
|
+
// node_modules/.pnpm/@mswjs+interceptors@0.36.5/node_modules/@mswjs/interceptors/lib/browser/index.mjs
|
|
1107
1025
|
var BatchInterceptor = class extends Interceptor {
|
|
1108
1026
|
constructor(options) {
|
|
1109
1027
|
BatchInterceptor.symbol = Symbol(options.name);
|
|
@@ -1387,7 +1305,7 @@ var DeferredPromise = class extends Promise {
|
|
|
1387
1305
|
}
|
|
1388
1306
|
};
|
|
1389
1307
|
|
|
1390
|
-
// node_modules/.pnpm/@mswjs+interceptors@0.
|
|
1308
|
+
// node_modules/.pnpm/@mswjs+interceptors@0.36.5/node_modules/@mswjs/interceptors/lib/browser/chunk-THPGBWJQ.mjs
|
|
1391
1309
|
var InterceptorError = class extends Error {
|
|
1392
1310
|
constructor(message) {
|
|
1393
1311
|
super(message);
|
|
@@ -1411,7 +1329,7 @@ var RequestController = class {
|
|
|
1411
1329
|
* controller.respondWith(Response.error())
|
|
1412
1330
|
*/
|
|
1413
1331
|
respondWith(response) {
|
|
1414
|
-
|
|
1332
|
+
invariant.as(
|
|
1415
1333
|
InterceptorError,
|
|
1416
1334
|
!this[kRequestHandled],
|
|
1417
1335
|
'Failed to respond to the "%s %s" request: the "request" event has already been handled.',
|
|
@@ -1428,7 +1346,7 @@ var RequestController = class {
|
|
|
1428
1346
|
* controller.errorWith(new Error('Oops!'))
|
|
1429
1347
|
*/
|
|
1430
1348
|
errorWith(error2) {
|
|
1431
|
-
|
|
1349
|
+
invariant.as(
|
|
1432
1350
|
InterceptorError,
|
|
1433
1351
|
!this[kRequestHandled],
|
|
1434
1352
|
'Failed to error the "%s %s" request: the "request" event has already been handled.',
|
|
@@ -1555,7 +1473,7 @@ async function handleRequest2(options) {
|
|
|
1555
1473
|
return false;
|
|
1556
1474
|
}
|
|
1557
1475
|
|
|
1558
|
-
// node_modules/.pnpm/@mswjs+interceptors@0.
|
|
1476
|
+
// node_modules/.pnpm/@mswjs+interceptors@0.36.5/node_modules/@mswjs/interceptors/lib/browser/chunk-GHRPKS6J.mjs
|
|
1559
1477
|
function canParseUrl(url) {
|
|
1560
1478
|
try {
|
|
1561
1479
|
new URL(url);
|
|
@@ -1639,7 +1557,7 @@ var _FetchInterceptor = class extends Interceptor {
|
|
|
1639
1557
|
}
|
|
1640
1558
|
async setup() {
|
|
1641
1559
|
const pureFetch = globalThis.fetch;
|
|
1642
|
-
|
|
1560
|
+
invariant(
|
|
1643
1561
|
!pureFetch[IS_PATCHED_MODULE],
|
|
1644
1562
|
'Failed to patch the "fetch" module: already patched.'
|
|
1645
1563
|
);
|
|
@@ -1717,12 +1635,12 @@ var _FetchInterceptor = class extends Interceptor {
|
|
|
1717
1635
|
this.logger.info(
|
|
1718
1636
|
"no mocked response received, performing request as-is..."
|
|
1719
1637
|
);
|
|
1720
|
-
return pureFetch(request).then((response) => {
|
|
1638
|
+
return pureFetch(request).then(async (response) => {
|
|
1721
1639
|
this.logger.info("original fetch performed", response);
|
|
1722
1640
|
if (this.emitter.listenerCount("response") > 0) {
|
|
1723
1641
|
this.logger.info('emitting the "response" event...');
|
|
1724
1642
|
const responseClone = response.clone();
|
|
1725
|
-
this.emitter
|
|
1643
|
+
await emitAsync(this.emitter, "response", {
|
|
1726
1644
|
response: responseClone,
|
|
1727
1645
|
isMockedResponse: false,
|
|
1728
1646
|
request,
|
|
@@ -1752,7 +1670,7 @@ var _FetchInterceptor = class extends Interceptor {
|
|
|
1752
1670
|
var FetchInterceptor = _FetchInterceptor;
|
|
1753
1671
|
FetchInterceptor.symbol = Symbol("fetch");
|
|
1754
1672
|
|
|
1755
|
-
// node_modules/.pnpm/@mswjs+interceptors@0.
|
|
1673
|
+
// node_modules/.pnpm/@mswjs+interceptors@0.36.5/node_modules/@mswjs/interceptors/lib/browser/chunk-SUQ32ZQK.mjs
|
|
1756
1674
|
function concatArrayBuffer(left, right) {
|
|
1757
1675
|
const result = new Uint8Array(left.byteLength + right.byteLength);
|
|
1758
1676
|
result.set(left, 0);
|
|
@@ -2277,7 +2195,7 @@ var XMLHttpRequestController = class {
|
|
|
2277
2195
|
}
|
|
2278
2196
|
}
|
|
2279
2197
|
get responseText() {
|
|
2280
|
-
|
|
2198
|
+
invariant(
|
|
2281
2199
|
this.request.responseType === "" || this.request.responseType === "text",
|
|
2282
2200
|
"InvalidStateError: The object is in invalid state."
|
|
2283
2201
|
);
|
|
@@ -2289,7 +2207,7 @@ var XMLHttpRequestController = class {
|
|
|
2289
2207
|
return responseText;
|
|
2290
2208
|
}
|
|
2291
2209
|
get responseXML() {
|
|
2292
|
-
|
|
2210
|
+
invariant(
|
|
2293
2211
|
this.request.responseType === "" || this.request.responseType === "document",
|
|
2294
2212
|
"InvalidStateError: The object is in invalid state."
|
|
2295
2213
|
);
|
|
@@ -2505,7 +2423,7 @@ var _XMLHttpRequestInterceptor = class extends Interceptor {
|
|
|
2505
2423
|
const logger = this.logger.extend("setup");
|
|
2506
2424
|
logger.info('patching "XMLHttpRequest" module...');
|
|
2507
2425
|
const PureXMLHttpRequest = globalThis.XMLHttpRequest;
|
|
2508
|
-
|
|
2426
|
+
invariant(
|
|
2509
2427
|
!PureXMLHttpRequest[IS_PATCHED_MODULE],
|
|
2510
2428
|
'Failed to patch the "XMLHttpRequest" module: already patched.'
|
|
2511
2429
|
);
|