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.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
|
}
|
|
@@ -396,7 +398,7 @@ You can also automate this process and make the worker script update automatical
|
|
|
396
398
|
}
|
|
397
399
|
}
|
|
398
400
|
|
|
399
|
-
// node_modules/.pnpm/@mswjs+interceptors@0.
|
|
401
|
+
// node_modules/.pnpm/@mswjs+interceptors@0.36.5/node_modules/@mswjs/interceptors/lib/browser/chunk-6HYIRFX2.mjs
|
|
400
402
|
var encoder = new TextEncoder();
|
|
401
403
|
function encodeBuffer(text) {
|
|
402
404
|
return encoder.encode(text);
|
|
@@ -412,7 +414,7 @@ function toArrayBuffer(array) {
|
|
|
412
414
|
);
|
|
413
415
|
}
|
|
414
416
|
|
|
415
|
-
// node_modules/.pnpm/@mswjs+interceptors@0.
|
|
417
|
+
// node_modules/.pnpm/@mswjs+interceptors@0.36.5/node_modules/@mswjs/interceptors/lib/browser/chunk-XVPRNJO7.mjs
|
|
416
418
|
var IS_PATCHED_MODULE = Symbol("isPatchedModule");
|
|
417
419
|
function isPropertyAccessible(obj, key) {
|
|
418
420
|
try {
|
|
@@ -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);
|
|
@@ -982,7 +900,7 @@ var _Emitter = class {
|
|
|
982
900
|
var Emitter = _Emitter;
|
|
983
901
|
Emitter.defaultMaxListeners = 10;
|
|
984
902
|
|
|
985
|
-
// node_modules/.pnpm/@mswjs+interceptors@0.
|
|
903
|
+
// node_modules/.pnpm/@mswjs+interceptors@0.36.5/node_modules/@mswjs/interceptors/lib/browser/chunk-QED3Q6Z2.mjs
|
|
986
904
|
var INTERNAL_REQUEST_ID_HEADER_NAME = "x-interceptors-internal-request-id";
|
|
987
905
|
function getGlobalSymbol(symbol) {
|
|
988
906
|
return (
|
|
@@ -1130,7 +1048,7 @@ function createRequestId() {
|
|
|
1130
1048
|
return Math.random().toString(16).slice(2);
|
|
1131
1049
|
}
|
|
1132
1050
|
|
|
1133
|
-
// node_modules/.pnpm/@mswjs+interceptors@0.
|
|
1051
|
+
// node_modules/.pnpm/@mswjs+interceptors@0.36.5/node_modules/@mswjs/interceptors/lib/browser/index.mjs
|
|
1134
1052
|
var BatchInterceptor = class extends Interceptor {
|
|
1135
1053
|
constructor(options) {
|
|
1136
1054
|
BatchInterceptor.symbol = Symbol(options.name);
|
|
@@ -1414,7 +1332,7 @@ var DeferredPromise = class extends Promise {
|
|
|
1414
1332
|
}
|
|
1415
1333
|
};
|
|
1416
1334
|
|
|
1417
|
-
// node_modules/.pnpm/@mswjs+interceptors@0.
|
|
1335
|
+
// node_modules/.pnpm/@mswjs+interceptors@0.36.5/node_modules/@mswjs/interceptors/lib/browser/chunk-THPGBWJQ.mjs
|
|
1418
1336
|
var InterceptorError = class extends Error {
|
|
1419
1337
|
constructor(message) {
|
|
1420
1338
|
super(message);
|
|
@@ -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.',
|
|
@@ -1582,7 +1500,7 @@ async function handleRequest2(options) {
|
|
|
1582
1500
|
return false;
|
|
1583
1501
|
}
|
|
1584
1502
|
|
|
1585
|
-
// node_modules/.pnpm/@mswjs+interceptors@0.
|
|
1503
|
+
// node_modules/.pnpm/@mswjs+interceptors@0.36.5/node_modules/@mswjs/interceptors/lib/browser/chunk-GHRPKS6J.mjs
|
|
1586
1504
|
function canParseUrl(url) {
|
|
1587
1505
|
try {
|
|
1588
1506
|
new URL(url);
|
|
@@ -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
|
);
|
|
@@ -1744,12 +1662,12 @@ var _FetchInterceptor = class extends Interceptor {
|
|
|
1744
1662
|
this.logger.info(
|
|
1745
1663
|
"no mocked response received, performing request as-is..."
|
|
1746
1664
|
);
|
|
1747
|
-
return pureFetch(request).then((response) => {
|
|
1665
|
+
return pureFetch(request).then(async (response) => {
|
|
1748
1666
|
this.logger.info("original fetch performed", response);
|
|
1749
1667
|
if (this.emitter.listenerCount("response") > 0) {
|
|
1750
1668
|
this.logger.info('emitting the "response" event...');
|
|
1751
1669
|
const responseClone = response.clone();
|
|
1752
|
-
this.emitter
|
|
1670
|
+
await emitAsync(this.emitter, "response", {
|
|
1753
1671
|
response: responseClone,
|
|
1754
1672
|
isMockedResponse: false,
|
|
1755
1673
|
request,
|
|
@@ -1779,7 +1697,7 @@ var _FetchInterceptor = class extends Interceptor {
|
|
|
1779
1697
|
var FetchInterceptor = _FetchInterceptor;
|
|
1780
1698
|
FetchInterceptor.symbol = Symbol("fetch");
|
|
1781
1699
|
|
|
1782
|
-
// node_modules/.pnpm/@mswjs+interceptors@0.
|
|
1700
|
+
// node_modules/.pnpm/@mswjs+interceptors@0.36.5/node_modules/@mswjs/interceptors/lib/browser/chunk-SUQ32ZQK.mjs
|
|
1783
1701
|
function concatArrayBuffer(left, right) {
|
|
1784
1702
|
const result = new Uint8Array(left.byteLength + right.byteLength);
|
|
1785
1703
|
result.set(left, 0);
|
|
@@ -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
|
);
|