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.js
CHANGED
|
@@ -25,7 +25,7 @@ __export(browser_exports, {
|
|
|
25
25
|
});
|
|
26
26
|
module.exports = __toCommonJS(browser_exports);
|
|
27
27
|
|
|
28
|
-
// node_modules/.pnpm/outvariant@1.4.
|
|
28
|
+
// node_modules/.pnpm/outvariant@1.4.3/node_modules/outvariant/lib/index.mjs
|
|
29
29
|
var POSITIONALS_EXP = /(%?)(%([sdijo]))/g;
|
|
30
30
|
function serializePositional(positional, flag) {
|
|
31
31
|
switch (flag) {
|
|
@@ -96,10 +96,12 @@ var invariant = (predicate, message, ...positionals) => {
|
|
|
96
96
|
};
|
|
97
97
|
invariant.as = (ErrorConstructor, predicate, message, ...positionals) => {
|
|
98
98
|
if (!predicate) {
|
|
99
|
-
const formatMessage = positionals.length === 0 ? message : format(message, positionals);
|
|
99
|
+
const formatMessage = positionals.length === 0 ? message : format(message, ...positionals);
|
|
100
100
|
let error2;
|
|
101
101
|
try {
|
|
102
|
-
error2 = Reflect.construct(ErrorConstructor, [
|
|
102
|
+
error2 = Reflect.construct(ErrorConstructor, [
|
|
103
|
+
formatMessage
|
|
104
|
+
]);
|
|
103
105
|
} catch (err) {
|
|
104
106
|
error2 = ErrorConstructor(formatMessage);
|
|
105
107
|
}
|
|
@@ -461,90 +463,6 @@ function isResponseError(response) {
|
|
|
461
463
|
return isPropertyAccessible(response, "type") && response.type === "error";
|
|
462
464
|
}
|
|
463
465
|
|
|
464
|
-
// node_modules/.pnpm/outvariant@1.4.3/node_modules/outvariant/lib/index.mjs
|
|
465
|
-
var POSITIONALS_EXP2 = /(%?)(%([sdijo]))/g;
|
|
466
|
-
function serializePositional2(positional, flag) {
|
|
467
|
-
switch (flag) {
|
|
468
|
-
case "s":
|
|
469
|
-
return positional;
|
|
470
|
-
case "d":
|
|
471
|
-
case "i":
|
|
472
|
-
return Number(positional);
|
|
473
|
-
case "j":
|
|
474
|
-
return JSON.stringify(positional);
|
|
475
|
-
case "o": {
|
|
476
|
-
if (typeof positional === "string") {
|
|
477
|
-
return positional;
|
|
478
|
-
}
|
|
479
|
-
const json = JSON.stringify(positional);
|
|
480
|
-
if (json === "{}" || json === "[]" || /^\[object .+?\]$/.test(json)) {
|
|
481
|
-
return positional;
|
|
482
|
-
}
|
|
483
|
-
return json;
|
|
484
|
-
}
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
function format2(message, ...positionals) {
|
|
488
|
-
if (positionals.length === 0) {
|
|
489
|
-
return message;
|
|
490
|
-
}
|
|
491
|
-
let positionalIndex = 0;
|
|
492
|
-
let formattedMessage = message.replace(
|
|
493
|
-
POSITIONALS_EXP2,
|
|
494
|
-
(match, isEscaped, _, flag) => {
|
|
495
|
-
const positional = positionals[positionalIndex];
|
|
496
|
-
const value = serializePositional2(positional, flag);
|
|
497
|
-
if (!isEscaped) {
|
|
498
|
-
positionalIndex++;
|
|
499
|
-
return value;
|
|
500
|
-
}
|
|
501
|
-
return match;
|
|
502
|
-
}
|
|
503
|
-
);
|
|
504
|
-
if (positionalIndex < positionals.length) {
|
|
505
|
-
formattedMessage += ` ${positionals.slice(positionalIndex).join(" ")}`;
|
|
506
|
-
}
|
|
507
|
-
formattedMessage = formattedMessage.replace(/%{2,2}/g, "%");
|
|
508
|
-
return formattedMessage;
|
|
509
|
-
}
|
|
510
|
-
var STACK_FRAMES_TO_IGNORE2 = 2;
|
|
511
|
-
function cleanErrorStack2(error2) {
|
|
512
|
-
if (!error2.stack) {
|
|
513
|
-
return;
|
|
514
|
-
}
|
|
515
|
-
const nextStack = error2.stack.split("\n");
|
|
516
|
-
nextStack.splice(1, STACK_FRAMES_TO_IGNORE2);
|
|
517
|
-
error2.stack = nextStack.join("\n");
|
|
518
|
-
}
|
|
519
|
-
var InvariantError2 = class extends Error {
|
|
520
|
-
constructor(message, ...positionals) {
|
|
521
|
-
super(message);
|
|
522
|
-
this.message = message;
|
|
523
|
-
this.name = "Invariant Violation";
|
|
524
|
-
this.message = format2(message, ...positionals);
|
|
525
|
-
cleanErrorStack2(this);
|
|
526
|
-
}
|
|
527
|
-
};
|
|
528
|
-
var invariant2 = (predicate, message, ...positionals) => {
|
|
529
|
-
if (!predicate) {
|
|
530
|
-
throw new InvariantError2(message, ...positionals);
|
|
531
|
-
}
|
|
532
|
-
};
|
|
533
|
-
invariant2.as = (ErrorConstructor, predicate, message, ...positionals) => {
|
|
534
|
-
if (!predicate) {
|
|
535
|
-
const formatMessage = positionals.length === 0 ? message : format2(message, ...positionals);
|
|
536
|
-
let error2;
|
|
537
|
-
try {
|
|
538
|
-
error2 = Reflect.construct(ErrorConstructor, [
|
|
539
|
-
formatMessage
|
|
540
|
-
]);
|
|
541
|
-
} catch (err) {
|
|
542
|
-
error2 = ErrorConstructor(formatMessage);
|
|
543
|
-
}
|
|
544
|
-
throw error2;
|
|
545
|
-
}
|
|
546
|
-
};
|
|
547
|
-
|
|
548
466
|
// node_modules/.pnpm/@open-draft+logger@0.3.0/node_modules/@open-draft/logger/lib/index.mjs
|
|
549
467
|
var __defProp2 = Object.defineProperty;
|
|
550
468
|
var __export2 = (target, all) => {
|
|
@@ -773,21 +691,21 @@ var PerformanceEntry = class {
|
|
|
773
691
|
var noop = () => void 0;
|
|
774
692
|
function log(message, ...positionals) {
|
|
775
693
|
if (IS_NODE) {
|
|
776
|
-
process.stdout.write(
|
|
694
|
+
process.stdout.write(format(message, ...positionals) + "\n");
|
|
777
695
|
return;
|
|
778
696
|
}
|
|
779
697
|
console.log(message, ...positionals);
|
|
780
698
|
}
|
|
781
699
|
function warn(message, ...positionals) {
|
|
782
700
|
if (IS_NODE) {
|
|
783
|
-
process.stderr.write(
|
|
701
|
+
process.stderr.write(format(message, ...positionals) + "\n");
|
|
784
702
|
return;
|
|
785
703
|
}
|
|
786
704
|
console.warn(message, ...positionals);
|
|
787
705
|
}
|
|
788
706
|
function error(message, ...positionals) {
|
|
789
707
|
if (IS_NODE) {
|
|
790
|
-
process.stderr.write(
|
|
708
|
+
process.stderr.write(format(message, ...positionals) + "\n");
|
|
791
709
|
return;
|
|
792
710
|
}
|
|
793
711
|
console.error(message, ...positionals);
|
|
@@ -1438,7 +1356,7 @@ var RequestController = class {
|
|
|
1438
1356
|
* controller.respondWith(Response.error())
|
|
1439
1357
|
*/
|
|
1440
1358
|
respondWith(response) {
|
|
1441
|
-
|
|
1359
|
+
invariant.as(
|
|
1442
1360
|
InterceptorError,
|
|
1443
1361
|
!this[kRequestHandled],
|
|
1444
1362
|
'Failed to respond to the "%s %s" request: the "request" event has already been handled.',
|
|
@@ -1455,7 +1373,7 @@ var RequestController = class {
|
|
|
1455
1373
|
* controller.errorWith(new Error('Oops!'))
|
|
1456
1374
|
*/
|
|
1457
1375
|
errorWith(error2) {
|
|
1458
|
-
|
|
1376
|
+
invariant.as(
|
|
1459
1377
|
InterceptorError,
|
|
1460
1378
|
!this[kRequestHandled],
|
|
1461
1379
|
'Failed to error the "%s %s" request: the "request" event has already been handled.',
|
|
@@ -1666,7 +1584,7 @@ var _FetchInterceptor = class extends Interceptor {
|
|
|
1666
1584
|
}
|
|
1667
1585
|
async setup() {
|
|
1668
1586
|
const pureFetch = globalThis.fetch;
|
|
1669
|
-
|
|
1587
|
+
invariant(
|
|
1670
1588
|
!pureFetch[IS_PATCHED_MODULE],
|
|
1671
1589
|
'Failed to patch the "fetch" module: already patched.'
|
|
1672
1590
|
);
|
|
@@ -2304,7 +2222,7 @@ var XMLHttpRequestController = class {
|
|
|
2304
2222
|
}
|
|
2305
2223
|
}
|
|
2306
2224
|
get responseText() {
|
|
2307
|
-
|
|
2225
|
+
invariant(
|
|
2308
2226
|
this.request.responseType === "" || this.request.responseType === "text",
|
|
2309
2227
|
"InvalidStateError: The object is in invalid state."
|
|
2310
2228
|
);
|
|
@@ -2316,7 +2234,7 @@ var XMLHttpRequestController = class {
|
|
|
2316
2234
|
return responseText;
|
|
2317
2235
|
}
|
|
2318
2236
|
get responseXML() {
|
|
2319
|
-
|
|
2237
|
+
invariant(
|
|
2320
2238
|
this.request.responseType === "" || this.request.responseType === "document",
|
|
2321
2239
|
"InvalidStateError: The object is in invalid state."
|
|
2322
2240
|
);
|
|
@@ -2532,7 +2450,7 @@ var _XMLHttpRequestInterceptor = class extends Interceptor {
|
|
|
2532
2450
|
const logger = this.logger.extend("setup");
|
|
2533
2451
|
logger.info('patching "XMLHttpRequest" module...');
|
|
2534
2452
|
const PureXMLHttpRequest = globalThis.XMLHttpRequest;
|
|
2535
|
-
|
|
2453
|
+
invariant(
|
|
2536
2454
|
!PureXMLHttpRequest[IS_PATCHED_MODULE],
|
|
2537
2455
|
'Failed to patch the "XMLHttpRequest" module: already patched.'
|
|
2538
2456
|
);
|