msw 2.4.10 → 2.4.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 +14 -96
- package/lib/browser/index.js.map +1 -1
- package/lib/browser/index.mjs +14 -96
- 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 +108 -180
- package/lib/iife/index.js.map +1 -1
- package/lib/mockServiceWorker.js +1 -1
- package/package.json +21 -22
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
|
}
|
|
@@ -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);
|
|
@@ -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.',
|
|
@@ -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
|
);
|
|
@@ -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
|
);
|