msw 2.4.9 → 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 +23 -106
- package/lib/browser/index.js.map +1 -1
- package/lib/browser/index.mjs +23 -106
- 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 -190
- package/lib/iife/index.js.map +1 -1
- package/lib/mockServiceWorker.js +1 -1
- package/package.json +21 -22
- package/src/browser/setupWorker/start/utils/getWorkerInstance.ts +12 -10
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
|
}
|
|
@@ -147,16 +149,15 @@ var getWorkerInstance = async (url, options = {}, findWorker) => {
|
|
|
147
149
|
}
|
|
148
150
|
const [existingRegistration] = mockRegistrations;
|
|
149
151
|
if (existingRegistration) {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
});
|
|
152
|
+
existingRegistration.update();
|
|
153
|
+
return [
|
|
154
|
+
getWorkerByRegistration(
|
|
155
|
+
existingRegistration,
|
|
156
|
+
absoluteWorkerUrl,
|
|
157
|
+
findWorker
|
|
158
|
+
),
|
|
159
|
+
existingRegistration
|
|
160
|
+
];
|
|
160
161
|
}
|
|
161
162
|
const registrationResult = await until(
|
|
162
163
|
async () => {
|
|
@@ -435,90 +436,6 @@ function isResponseError(response) {
|
|
|
435
436
|
return isPropertyAccessible(response, "type") && response.type === "error";
|
|
436
437
|
}
|
|
437
438
|
|
|
438
|
-
// node_modules/.pnpm/outvariant@1.4.3/node_modules/outvariant/lib/index.mjs
|
|
439
|
-
var POSITIONALS_EXP2 = /(%?)(%([sdijo]))/g;
|
|
440
|
-
function serializePositional2(positional, flag) {
|
|
441
|
-
switch (flag) {
|
|
442
|
-
case "s":
|
|
443
|
-
return positional;
|
|
444
|
-
case "d":
|
|
445
|
-
case "i":
|
|
446
|
-
return Number(positional);
|
|
447
|
-
case "j":
|
|
448
|
-
return JSON.stringify(positional);
|
|
449
|
-
case "o": {
|
|
450
|
-
if (typeof positional === "string") {
|
|
451
|
-
return positional;
|
|
452
|
-
}
|
|
453
|
-
const json = JSON.stringify(positional);
|
|
454
|
-
if (json === "{}" || json === "[]" || /^\[object .+?\]$/.test(json)) {
|
|
455
|
-
return positional;
|
|
456
|
-
}
|
|
457
|
-
return json;
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
function format2(message, ...positionals) {
|
|
462
|
-
if (positionals.length === 0) {
|
|
463
|
-
return message;
|
|
464
|
-
}
|
|
465
|
-
let positionalIndex = 0;
|
|
466
|
-
let formattedMessage = message.replace(
|
|
467
|
-
POSITIONALS_EXP2,
|
|
468
|
-
(match, isEscaped, _, flag) => {
|
|
469
|
-
const positional = positionals[positionalIndex];
|
|
470
|
-
const value = serializePositional2(positional, flag);
|
|
471
|
-
if (!isEscaped) {
|
|
472
|
-
positionalIndex++;
|
|
473
|
-
return value;
|
|
474
|
-
}
|
|
475
|
-
return match;
|
|
476
|
-
}
|
|
477
|
-
);
|
|
478
|
-
if (positionalIndex < positionals.length) {
|
|
479
|
-
formattedMessage += ` ${positionals.slice(positionalIndex).join(" ")}`;
|
|
480
|
-
}
|
|
481
|
-
formattedMessage = formattedMessage.replace(/%{2,2}/g, "%");
|
|
482
|
-
return formattedMessage;
|
|
483
|
-
}
|
|
484
|
-
var STACK_FRAMES_TO_IGNORE2 = 2;
|
|
485
|
-
function cleanErrorStack2(error2) {
|
|
486
|
-
if (!error2.stack) {
|
|
487
|
-
return;
|
|
488
|
-
}
|
|
489
|
-
const nextStack = error2.stack.split("\n");
|
|
490
|
-
nextStack.splice(1, STACK_FRAMES_TO_IGNORE2);
|
|
491
|
-
error2.stack = nextStack.join("\n");
|
|
492
|
-
}
|
|
493
|
-
var InvariantError2 = class extends Error {
|
|
494
|
-
constructor(message, ...positionals) {
|
|
495
|
-
super(message);
|
|
496
|
-
this.message = message;
|
|
497
|
-
this.name = "Invariant Violation";
|
|
498
|
-
this.message = format2(message, ...positionals);
|
|
499
|
-
cleanErrorStack2(this);
|
|
500
|
-
}
|
|
501
|
-
};
|
|
502
|
-
var invariant2 = (predicate, message, ...positionals) => {
|
|
503
|
-
if (!predicate) {
|
|
504
|
-
throw new InvariantError2(message, ...positionals);
|
|
505
|
-
}
|
|
506
|
-
};
|
|
507
|
-
invariant2.as = (ErrorConstructor, predicate, message, ...positionals) => {
|
|
508
|
-
if (!predicate) {
|
|
509
|
-
const formatMessage = positionals.length === 0 ? message : format2(message, ...positionals);
|
|
510
|
-
let error2;
|
|
511
|
-
try {
|
|
512
|
-
error2 = Reflect.construct(ErrorConstructor, [
|
|
513
|
-
formatMessage
|
|
514
|
-
]);
|
|
515
|
-
} catch (err) {
|
|
516
|
-
error2 = ErrorConstructor(formatMessage);
|
|
517
|
-
}
|
|
518
|
-
throw error2;
|
|
519
|
-
}
|
|
520
|
-
};
|
|
521
|
-
|
|
522
439
|
// node_modules/.pnpm/@open-draft+logger@0.3.0/node_modules/@open-draft/logger/lib/index.mjs
|
|
523
440
|
var __defProp = Object.defineProperty;
|
|
524
441
|
var __export = (target, all) => {
|
|
@@ -747,21 +664,21 @@ var PerformanceEntry = class {
|
|
|
747
664
|
var noop = () => void 0;
|
|
748
665
|
function log(message, ...positionals) {
|
|
749
666
|
if (IS_NODE) {
|
|
750
|
-
process.stdout.write(
|
|
667
|
+
process.stdout.write(format(message, ...positionals) + "\n");
|
|
751
668
|
return;
|
|
752
669
|
}
|
|
753
670
|
console.log(message, ...positionals);
|
|
754
671
|
}
|
|
755
672
|
function warn(message, ...positionals) {
|
|
756
673
|
if (IS_NODE) {
|
|
757
|
-
process.stderr.write(
|
|
674
|
+
process.stderr.write(format(message, ...positionals) + "\n");
|
|
758
675
|
return;
|
|
759
676
|
}
|
|
760
677
|
console.warn(message, ...positionals);
|
|
761
678
|
}
|
|
762
679
|
function error(message, ...positionals) {
|
|
763
680
|
if (IS_NODE) {
|
|
764
|
-
process.stderr.write(
|
|
681
|
+
process.stderr.write(format(message, ...positionals) + "\n");
|
|
765
682
|
return;
|
|
766
683
|
}
|
|
767
684
|
console.error(message, ...positionals);
|
|
@@ -1412,7 +1329,7 @@ var RequestController = class {
|
|
|
1412
1329
|
* controller.respondWith(Response.error())
|
|
1413
1330
|
*/
|
|
1414
1331
|
respondWith(response) {
|
|
1415
|
-
|
|
1332
|
+
invariant.as(
|
|
1416
1333
|
InterceptorError,
|
|
1417
1334
|
!this[kRequestHandled],
|
|
1418
1335
|
'Failed to respond to the "%s %s" request: the "request" event has already been handled.',
|
|
@@ -1429,7 +1346,7 @@ var RequestController = class {
|
|
|
1429
1346
|
* controller.errorWith(new Error('Oops!'))
|
|
1430
1347
|
*/
|
|
1431
1348
|
errorWith(error2) {
|
|
1432
|
-
|
|
1349
|
+
invariant.as(
|
|
1433
1350
|
InterceptorError,
|
|
1434
1351
|
!this[kRequestHandled],
|
|
1435
1352
|
'Failed to error the "%s %s" request: the "request" event has already been handled.',
|
|
@@ -1640,7 +1557,7 @@ var _FetchInterceptor = class extends Interceptor {
|
|
|
1640
1557
|
}
|
|
1641
1558
|
async setup() {
|
|
1642
1559
|
const pureFetch = globalThis.fetch;
|
|
1643
|
-
|
|
1560
|
+
invariant(
|
|
1644
1561
|
!pureFetch[IS_PATCHED_MODULE],
|
|
1645
1562
|
'Failed to patch the "fetch" module: already patched.'
|
|
1646
1563
|
);
|
|
@@ -2278,7 +2195,7 @@ var XMLHttpRequestController = class {
|
|
|
2278
2195
|
}
|
|
2279
2196
|
}
|
|
2280
2197
|
get responseText() {
|
|
2281
|
-
|
|
2198
|
+
invariant(
|
|
2282
2199
|
this.request.responseType === "" || this.request.responseType === "text",
|
|
2283
2200
|
"InvalidStateError: The object is in invalid state."
|
|
2284
2201
|
);
|
|
@@ -2290,7 +2207,7 @@ var XMLHttpRequestController = class {
|
|
|
2290
2207
|
return responseText;
|
|
2291
2208
|
}
|
|
2292
2209
|
get responseXML() {
|
|
2293
|
-
|
|
2210
|
+
invariant(
|
|
2294
2211
|
this.request.responseType === "" || this.request.responseType === "document",
|
|
2295
2212
|
"InvalidStateError: The object is in invalid state."
|
|
2296
2213
|
);
|
|
@@ -2506,7 +2423,7 @@ var _XMLHttpRequestInterceptor = class extends Interceptor {
|
|
|
2506
2423
|
const logger = this.logger.extend("setup");
|
|
2507
2424
|
logger.info('patching "XMLHttpRequest" module...');
|
|
2508
2425
|
const PureXMLHttpRequest = globalThis.XMLHttpRequest;
|
|
2509
|
-
|
|
2426
|
+
invariant(
|
|
2510
2427
|
!PureXMLHttpRequest[IS_PATCHED_MODULE],
|
|
2511
2428
|
'Failed to patch the "XMLHttpRequest" module: already patched.'
|
|
2512
2429
|
);
|