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.
Files changed (45) hide show
  1. package/lib/browser/index.js +23 -106
  2. package/lib/browser/index.js.map +1 -1
  3. package/lib/browser/index.mjs +23 -106
  4. package/lib/browser/index.mjs.map +1 -1
  5. package/lib/core/{GraphQLHandler-5pZBHLn9.d.mts → GraphQLHandler-ClMB0BOy.d.mts} +1 -1
  6. package/lib/core/{GraphQLHandler-Cu4Xvg4S.d.ts → GraphQLHandler-D6mLMXGZ.d.ts} +1 -1
  7. package/lib/core/{HttpResponse-DE19n76Q.d.ts → HttpResponse-DaYkf3ml.d.ts} +1 -1
  8. package/lib/core/{HttpResponse-Gtw1lt3H.d.mts → HttpResponse-vn-Pb4Bi.d.mts} +1 -1
  9. package/lib/core/HttpResponse.d.mts +1 -1
  10. package/lib/core/HttpResponse.d.ts +1 -1
  11. package/lib/core/SetupApi.d.mts +1 -1
  12. package/lib/core/SetupApi.d.ts +1 -1
  13. package/lib/core/getResponse.d.mts +1 -1
  14. package/lib/core/getResponse.d.ts +1 -1
  15. package/lib/core/graphql.d.mts +2 -2
  16. package/lib/core/graphql.d.ts +2 -2
  17. package/lib/core/handlers/GraphQLHandler.d.mts +2 -2
  18. package/lib/core/handlers/GraphQLHandler.d.ts +2 -2
  19. package/lib/core/handlers/HttpHandler.d.mts +1 -1
  20. package/lib/core/handlers/HttpHandler.d.ts +1 -1
  21. package/lib/core/handlers/RequestHandler.d.mts +1 -1
  22. package/lib/core/handlers/RequestHandler.d.ts +1 -1
  23. package/lib/core/http.d.mts +1 -1
  24. package/lib/core/http.d.ts +1 -1
  25. package/lib/core/index.d.mts +2 -2
  26. package/lib/core/index.d.ts +2 -2
  27. package/lib/core/passthrough.d.mts +1 -1
  28. package/lib/core/passthrough.d.ts +1 -1
  29. package/lib/core/utils/HttpResponse/decorators.d.mts +1 -1
  30. package/lib/core/utils/HttpResponse/decorators.d.ts +1 -1
  31. package/lib/core/utils/executeHandlers.d.mts +1 -1
  32. package/lib/core/utils/executeHandlers.d.ts +1 -1
  33. package/lib/core/utils/handleRequest.d.mts +1 -1
  34. package/lib/core/utils/handleRequest.d.ts +1 -1
  35. package/lib/core/utils/internal/parseGraphQLRequest.d.mts +2 -2
  36. package/lib/core/utils/internal/parseGraphQLRequest.d.ts +2 -2
  37. package/lib/core/utils/internal/parseMultipartData.d.mts +1 -1
  38. package/lib/core/utils/internal/parseMultipartData.d.ts +1 -1
  39. package/lib/core/utils/internal/requestHandlerUtils.d.mts +1 -1
  40. package/lib/core/utils/internal/requestHandlerUtils.d.ts +1 -1
  41. package/lib/iife/index.js +117 -190
  42. package/lib/iife/index.js.map +1 -1
  43. package/lib/mockServiceWorker.js +1 -1
  44. package/package.json +21 -22
  45. package/src/browser/setupWorker/start/utils/getWorkerInstance.ts +12 -10
@@ -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.2/node_modules/outvariant/lib/index.mjs
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, [formatMessage]);
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
- return existingRegistration.update().then(() => {
178
- return [
179
- getWorkerByRegistration(
180
- existingRegistration,
181
- absoluteWorkerUrl,
182
- findWorker
183
- ),
184
- existingRegistration
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(format2(message, ...positionals) + "\n");
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(format2(message, ...positionals) + "\n");
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(format2(message, ...positionals) + "\n");
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
- invariant2.as(
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
- invariant2.as(
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
- invariant2(
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
- invariant2(
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
- invariant2(
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
- invariant2(
2453
+ invariant(
2537
2454
  !PureXMLHttpRequest[IS_PATCHED_MODULE],
2538
2455
  'Failed to patch the "XMLHttpRequest" module: already patched.'
2539
2456
  );