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