@accelint/design-system 1.2.1 → 1.2.3

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 (143) hide show
  1. package/dist/components/aria/index.js.map +1 -1
  2. package/dist/components/button/button.css.d.ts +25 -24
  3. package/dist/components/button/index.d.ts +9 -40
  4. package/dist/components/button/index.js +23 -17
  5. package/dist/components/button/index.js.map +1 -1
  6. package/dist/components/button/types.d.ts +3 -2
  7. package/dist/components/checkbox/checkbox.css.d.ts +23 -23
  8. package/dist/components/checkbox/index.js.map +1 -1
  9. package/dist/components/chip/chip.css.d.ts +18 -18
  10. package/dist/components/chip/index.js.map +1 -1
  11. package/dist/components/collection/index.d.ts +3 -3
  12. package/dist/components/collection/index.js.map +1 -1
  13. package/dist/components/combo-box/combo-box.css.d.ts +9 -9
  14. package/dist/components/combo-box/index.js +9 -5
  15. package/dist/components/combo-box/index.js.map +1 -1
  16. package/dist/components/date-field/date-field.css.d.ts +17 -17
  17. package/dist/components/date-field/index.js +8 -4
  18. package/dist/components/date-field/index.js.map +1 -1
  19. package/dist/components/date-input/date-input.css.d.ts +25 -25
  20. package/dist/components/date-input/index.js +19 -8
  21. package/dist/components/date-input/index.js.map +1 -1
  22. package/dist/components/dialog/dialog.css.d.ts +16 -15
  23. package/dist/components/dialog/index.d.ts +1 -0
  24. package/dist/components/dialog/index.js +7 -5
  25. package/dist/components/dialog/index.js.map +1 -1
  26. package/dist/components/dialog/types.d.ts +1 -0
  27. package/dist/components/drawer/drawer.css.d.ts +17 -17
  28. package/dist/components/drawer/index.d.ts +1 -1
  29. package/dist/components/drawer/index.js +21 -8
  30. package/dist/components/drawer/index.js.map +1 -1
  31. package/dist/components/drawer/types.d.ts +1 -1
  32. package/dist/components/element/index.d.ts +1 -1
  33. package/dist/components/element/index.js +7 -3
  34. package/dist/components/element/index.js.map +1 -1
  35. package/dist/components/element/types.d.ts +2 -0
  36. package/dist/components/group/group.css.d.ts +7 -7
  37. package/dist/components/group/index.js +6 -6
  38. package/dist/components/group/index.js.map +1 -1
  39. package/dist/components/icon/icon.css.d.ts +9 -9
  40. package/dist/components/icon/index.js +4 -4
  41. package/dist/components/icon/index.js.map +1 -1
  42. package/dist/components/icon/types.d.ts +1 -1
  43. package/dist/components/index.d.ts +35 -35
  44. package/dist/components/input/index.js +17 -8
  45. package/dist/components/input/index.js.map +1 -1
  46. package/dist/components/input/input.css.d.ts +20 -20
  47. package/dist/components/menu/index.d.ts +2 -2
  48. package/dist/components/menu/index.js +1 -1
  49. package/dist/components/menu/index.js.map +1 -1
  50. package/dist/components/menu/menu.css.d.ts +42 -42
  51. package/dist/components/merge-provider/index.js +15 -7
  52. package/dist/components/merge-provider/index.js.map +1 -1
  53. package/dist/components/merge-provider/types.d.ts +2 -0
  54. package/dist/components/number-field/index.d.ts +1 -1
  55. package/dist/components/number-field/index.js +8 -4
  56. package/dist/components/number-field/index.js.map +1 -1
  57. package/dist/components/number-field/number-field.css.d.ts +12 -12
  58. package/dist/components/number-field/types.d.ts +1 -1
  59. package/dist/components/options/index.js +1 -1
  60. package/dist/components/options/index.js.map +1 -1
  61. package/dist/components/options/options.css.d.ts +44 -44
  62. package/dist/components/picker/index.js.map +1 -1
  63. package/dist/components/picker/picker.css.d.ts +18 -18
  64. package/dist/components/popover/index.js +8 -4
  65. package/dist/components/popover/index.js.map +1 -1
  66. package/dist/components/popover/popover.css.d.ts +12 -12
  67. package/dist/components/query-builder/action-element.js.map +1 -1
  68. package/dist/components/query-builder/dataset-sample.js.map +1 -1
  69. package/dist/components/query-builder/group.js.map +1 -1
  70. package/dist/components/query-builder/index.js.map +1 -1
  71. package/dist/components/query-builder/query-builder.css.d.ts +53 -53
  72. package/dist/components/query-builder/value-editor.js.map +1 -1
  73. package/dist/components/query-builder/value-selector.js.map +1 -1
  74. package/dist/components/radio/index.js +12 -8
  75. package/dist/components/radio/index.js.map +1 -1
  76. package/dist/components/radio/radio.css.d.ts +22 -22
  77. package/dist/components/search-field/index.js +9 -5
  78. package/dist/components/search-field/index.js.map +1 -1
  79. package/dist/components/search-field/search-field.css.d.ts +9 -9
  80. package/dist/components/select/index.js +5 -5
  81. package/dist/components/select/index.js.map +1 -1
  82. package/dist/components/select/select.css.d.ts +12 -12
  83. package/dist/components/slider/index.js +48 -20
  84. package/dist/components/slider/index.js.map +1 -1
  85. package/dist/components/slider/slider.css.d.ts +27 -27
  86. package/dist/components/switch/index.js +4 -4
  87. package/dist/components/switch/index.js.map +1 -1
  88. package/dist/components/switch/switch.css.d.ts +16 -16
  89. package/dist/components/tabs/index.js +32 -20
  90. package/dist/components/tabs/index.js.map +1 -1
  91. package/dist/components/tabs/tabs.css.d.ts +25 -25
  92. package/dist/components/text-field/index.d.ts +3 -128
  93. package/dist/components/text-field/index.js +11 -7
  94. package/dist/components/text-field/index.js.map +1 -1
  95. package/dist/components/text-field/text-field.css.d.ts +8 -8
  96. package/dist/components/textarea/index.js +16 -7
  97. package/dist/components/textarea/index.js.map +1 -1
  98. package/dist/components/textarea/textarea.css.d.ts +22 -22
  99. package/dist/components/time-field/index.js +8 -4
  100. package/dist/components/time-field/index.js.map +1 -1
  101. package/dist/components/time-field/time-field.css.d.ts +17 -17
  102. package/dist/components/tooltip/index.js +17 -9
  103. package/dist/components/tooltip/index.js.map +1 -1
  104. package/dist/components/tooltip/tooltip.css.d.ts +11 -11
  105. package/dist/components/tree/index.js +5 -2
  106. package/dist/components/tree/index.js.map +1 -1
  107. package/dist/components/tree/tree.css.d.ts +45 -45
  108. package/dist/components/tree/utils.js +3 -1
  109. package/dist/components/tree/utils.js.map +1 -1
  110. package/dist/constants.d.ts +3 -0
  111. package/dist/constants.js +8 -0
  112. package/dist/constants.js.map +1 -0
  113. package/dist/hooks/index.d.ts +13 -13
  114. package/dist/hooks/use-collection-render/index.d.ts +1 -1
  115. package/dist/hooks/use-collection-render/index.js +2 -3
  116. package/dist/hooks/use-collection-render/index.js.map +1 -1
  117. package/dist/hooks/use-context-props/index.js.map +1 -1
  118. package/dist/hooks/use-defaults/index.d.ts +32 -80
  119. package/dist/hooks/use-defaults/index.js +1 -4
  120. package/dist/hooks/use-defaults/index.js.map +1 -1
  121. package/dist/hooks/use-defaults/types.d.ts +1 -1
  122. package/dist/hooks/use-theme/index.d.ts +2 -2
  123. package/dist/hooks/use-theme/index.js.map +1 -1
  124. package/dist/hooks/use-theme/types.d.ts +1 -1
  125. package/dist/hooks/use-tree/index.js +3 -2
  126. package/dist/hooks/use-tree/index.js.map +1 -1
  127. package/dist/hooks/use-tree/utils.js +6 -9
  128. package/dist/hooks/use-tree/utils.js.map +1 -1
  129. package/dist/hooks/use-update-effect/index.js.map +1 -1
  130. package/dist/index.css +38 -38
  131. package/dist/index.d.ts +39 -39
  132. package/dist/ladle/actions.js.map +1 -1
  133. package/dist/styles/theme.css.d.ts +200 -200
  134. package/dist/test/setup.js +778 -1276
  135. package/dist/test/setup.js.map +1 -1
  136. package/dist/utils/css/index.d.ts +1 -1
  137. package/dist/utils/css/index.js.map +1 -1
  138. package/dist/utils/props/index.d.ts +1 -2
  139. package/dist/utils/props/index.js +1 -2
  140. package/dist/utils/props/index.js.map +1 -1
  141. package/dist/vanilla.d.ts +30 -30
  142. package/dist/vanilla.js +1 -1
  143. package/package.json +49 -48
@@ -3,8 +3,7 @@ import redent from 'redent.js';
3
3
  import { parse } from '@adobe/css-tools.js';
4
4
  import { computeAccessibleDescription, computeAccessibleName } from 'dom-accessibility-api.js';
5
5
  import { roles, elementRoles, roleElements } from 'aria-query.js';
6
- import chalk from 'chalk.js';
7
- import isEqualWith from 'lodash/isEqualWith.js';
6
+ import pico from 'picocolors.js';
8
7
  import escape from 'css.escape.js';
9
8
  import * as React from 'react';
10
9
  import * as DeprecatedReactTestUtils from 'react-dom/test-utils';
@@ -12,20 +11,24 @@ import 'react-dom';
12
11
  import 'react-dom/client';
13
12
  import * as prettyFormat from 'pretty-format.js';
14
13
  import lzString from 'lz-string.js';
15
- import { JestExtend, JestChaiExpect, JestAsymmetricMatchers, GLOBAL_EXPECT, ASYMMETRIC_MATCHERS_OBJECT, getState, setState, addCustomEqualityTesters, equals, iterableEquality, subsetEquality } from '@vitest/expect.js';
14
+ import { chai, JestExtend, JestChaiExpect, JestAsymmetricMatchers, GLOBAL_EXPECT, ASYMMETRIC_MATCHERS_OBJECT, getState, setState, addCustomEqualityTesters, customMatchers, equals, iterableEquality, subsetEquality } from '@vitest/expect.js';
16
15
  import { afterEach as afterEach$1, getCurrentTest } from '@vitest/runner.js';
16
+ import { getSafeTimers, delay } from '@vitest/utils/timers.js';
17
17
  import { getNames } from '@vitest/runner/utils.js';
18
- import * as chai$1 from 'chai.js';
19
- import { assertTypes, getSafeTimers, createSimpleStackTrace } from '@vitest/utils.js';
20
18
  import { stripSnapshotIndentation, addSerializer, SnapshotClient } from '@vitest/snapshot.js';
21
19
  import '@vitest/utils/error.js';
22
- import { parseSingleStack } from '@vitest/utils/source-map.js';
23
- import { fn, spyOn, mocks, isMockFunction } from '@vitest/spy.js';
20
+ import '@vitest/utils/helpers.js';
21
+ import '@vitest/spy.js';
22
+ import '@vitest/utils/offset.js';
23
+ import '@vitest/utils/source-map.js';
24
24
  import 'expect-type.js';
25
+ import 'pathe.js';
25
26
 
26
- // ../node_modules/.pnpm/@testing-library+jest-dom@6.6.3/node_modules/@testing-library/jest-dom/dist/matchers.mjs
27
+ // ../node_modules/.pnpm/@testing-library+jest-dom@6.9.1/node_modules/@testing-library/jest-dom/dist/matchers.mjs
27
28
  var matchers_exports = {};
28
29
  __export(matchers_exports, {
30
+ toAppearAfter: () => toAppearAfter,
31
+ toAppearBefore: () => toAppearBefore,
29
32
  toBeChecked: () => toBeChecked,
30
33
  toBeDisabled: () => toBeDisabled,
31
34
  toBeEmpty: () => toBeEmpty,
@@ -35,6 +38,8 @@ __export(matchers_exports, {
35
38
  toBeInTheDocument: () => toBeInTheDocument,
36
39
  toBeInvalid: () => toBeInvalid,
37
40
  toBePartiallyChecked: () => toBePartiallyChecked,
41
+ toBePartiallyPressed: () => toBePartiallyPressed,
42
+ toBePressed: () => toBePressed,
38
43
  toBeRequired: () => toBeRequired,
39
44
  toBeValid: () => toBeValid,
40
45
  toBeVisible: () => toBeVisible,
@@ -233,11 +238,11 @@ function toSentence(array2, { wordConnector = ", ", lastWordConnector = " and "
233
238
  array2.length > 1 ? lastWordConnector : ""
234
239
  );
235
240
  }
236
- function compareArraysAsSet(arr1, arr2) {
237
- if (Array.isArray(arr1) && Array.isArray(arr2)) {
238
- return [...new Set(arr1)].every((v) => new Set(arr2).has(v));
241
+ function compareAsSet(val1, val2) {
242
+ if (Array.isArray(val1) && Array.isArray(val2)) {
243
+ return [...new Set(val1)].every((v) => new Set(val2).has(v));
239
244
  }
240
- return void 0;
245
+ return val1 === val2;
241
246
  }
242
247
  function toBeInTheDOM(element, container) {
243
248
  deprecate(
@@ -781,7 +786,7 @@ function expectedDiff(diffFn, expected, computedStyles) {
781
786
  {}
782
787
  );
783
788
  const diffOutput = diffFn(printoutStyles(expected), printoutStyles(received));
784
- return diffOutput.replace(`${chalk.red("+ Received")}
789
+ return diffOutput.replace(`${pico.red("+ Received")}
785
790
  `, "");
786
791
  }
787
792
  function toHaveStyle(htmlElement, css) {
@@ -879,7 +884,7 @@ function toHaveFormValues(formElement, expectedValues) {
879
884
  const formValues = getAllFormValues(formElement);
880
885
  return {
881
886
  pass: Object.entries(expectedValues).every(
882
- ([name, expectedValue]) => isEqualWith(formValues[name], expectedValue, compareArraysAsSet)
887
+ ([name, expectedValue]) => compareAsSet(formValues[name], expectedValue)
883
888
  ),
884
889
  message: () => {
885
890
  const to = this.isNot ? "not to" : "to";
@@ -1125,7 +1130,7 @@ function toHaveValue(htmlElement, expectedValue) {
1125
1130
  receivedTypedValue = `${receivedValue} (${typeof receivedValue})`;
1126
1131
  }
1127
1132
  return {
1128
- pass: expectsValue ? isEqualWith(receivedValue, expectedValue, compareArraysAsSet) : Boolean(receivedValue),
1133
+ pass: expectsValue ? compareAsSet(receivedValue, expectedValue) : Boolean(receivedValue),
1129
1134
  message: () => {
1130
1135
  const to = this.isNot ? "not to" : "to";
1131
1136
  const matcher = this.utils.matcherHint(
@@ -1406,7 +1411,7 @@ function toHaveSelection(htmlElement, expectedSelection) {
1406
1411
  }
1407
1412
  const receivedSelection = getSelection(htmlElement);
1408
1413
  return {
1409
- pass: expectsSelection ? isEqualWith(receivedSelection, expectedSelection, compareArraysAsSet) : Boolean(receivedSelection),
1414
+ pass: expectsSelection ? compareAsSet(receivedSelection, expectedSelection) : Boolean(receivedSelection),
1410
1415
  message: () => {
1411
1416
  const to = this.isNot ? "not to" : "to";
1412
1417
  const matcher = this.utils.matcherHint(
@@ -1425,6 +1430,125 @@ function toHaveSelection(htmlElement, expectedSelection) {
1425
1430
  }
1426
1431
  };
1427
1432
  }
1433
+ function toBePressed(element) {
1434
+ checkHtmlElement(element, toBePressed, this);
1435
+ const roles3 = (element.getAttribute("role") || "").split(" ").map((role) => role.trim());
1436
+ const isButton = element.tagName.toLowerCase() === "button" || element.tagName.toLowerCase() === "input" && element.type === "button" || roles3.includes("button");
1437
+ const pressedAttribute = element.getAttribute("aria-pressed");
1438
+ const isValidAriaElement = pressedAttribute === "true" || pressedAttribute === "false";
1439
+ if (!isButton || !isValidAriaElement) {
1440
+ return {
1441
+ pass: false,
1442
+ message: () => `Only button or input with type="button" or element with role="button" and a valid aria-pressed attribute can be used with .toBePressed()`
1443
+ };
1444
+ }
1445
+ const isPressed = pressedAttribute === "true";
1446
+ return {
1447
+ pass: isButton && isPressed,
1448
+ message: () => {
1449
+ const matcher = this.utils.matcherHint(
1450
+ `${this.isNot ? ".not" : ""}.toBePressed`,
1451
+ "element",
1452
+ ""
1453
+ );
1454
+ return getMessage(
1455
+ this,
1456
+ matcher,
1457
+ `Expected element to have`,
1458
+ `aria-pressed="${this.isNot ? "false" : "true"}"`,
1459
+ `Received`,
1460
+ `aria-pressed="${pressedAttribute}"`
1461
+ );
1462
+ }
1463
+ };
1464
+ }
1465
+ function toBePartiallyPressed(element) {
1466
+ checkHtmlElement(element, toBePartiallyPressed, this);
1467
+ const roles3 = (element.getAttribute("role") || "").split(" ").map((role) => role.trim());
1468
+ const isButton = element.tagName.toLowerCase() === "button" || element.tagName.toLowerCase() === "input" && element.type === "button" || roles3.includes("button");
1469
+ const pressedAttribute = element.getAttribute("aria-pressed");
1470
+ const isValidAriaElement = pressedAttribute === "true" || pressedAttribute === "false" || pressedAttribute === "mixed";
1471
+ if (!isButton || !isValidAriaElement) {
1472
+ return {
1473
+ pass: false,
1474
+ message: () => `Only button or input with type="button" or element with role="button" and a valid aria-pressed attribute can be used with .toBePartiallyPressed()`
1475
+ };
1476
+ }
1477
+ const isPartiallyPressed = pressedAttribute === "mixed";
1478
+ return {
1479
+ pass: isButton && isPartiallyPressed,
1480
+ message: () => {
1481
+ const to = this.isNot ? "not to" : "to";
1482
+ const matcher = this.utils.matcherHint(
1483
+ `${this.isNot ? ".not" : ""}.toBePartiallyPressed`,
1484
+ "element",
1485
+ ""
1486
+ );
1487
+ return getMessage(
1488
+ this,
1489
+ matcher,
1490
+ `Expected element ${to} have`,
1491
+ `aria-pressed="mixed"`,
1492
+ `Received`,
1493
+ `aria-pressed="${pressedAttribute}"`
1494
+ );
1495
+ }
1496
+ };
1497
+ }
1498
+ var DOCUMENT_POSITION_DISCONNECTED = 1;
1499
+ var DOCUMENT_POSITION_PRECEDING = 2;
1500
+ var DOCUMENT_POSITION_FOLLOWING = 4;
1501
+ var DOCUMENT_POSITION_CONTAINS = 8;
1502
+ var DOCUMENT_POSITION_CONTAINED_BY = 16;
1503
+ var DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 32;
1504
+ var DOCUMENT_POSITIONS_STRINGS = {
1505
+ [DOCUMENT_POSITION_DISCONNECTED]: "Node.DOCUMENT_POSITION_DISCONNECTED",
1506
+ [DOCUMENT_POSITION_PRECEDING]: "Node.DOCUMENT_POSITION_PRECEDING",
1507
+ [DOCUMENT_POSITION_FOLLOWING]: "Node.DOCUMENT_POSITION_FOLLOWING",
1508
+ [DOCUMENT_POSITION_CONTAINS]: "Node.DOCUMENT_POSITION_CONTAINS",
1509
+ [DOCUMENT_POSITION_CONTAINED_BY]: "Node.DOCUMENT_POSITION_CONTAINED_BY",
1510
+ [DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC]: "Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC"
1511
+ };
1512
+ function makeDocumentPositionErrorString(documentPosition) {
1513
+ if (documentPosition in DOCUMENT_POSITIONS_STRINGS) {
1514
+ return `${DOCUMENT_POSITIONS_STRINGS[documentPosition]} (${documentPosition})`;
1515
+ }
1516
+ return `Unknown document position (${documentPosition})`;
1517
+ }
1518
+ function checkToAppear(methodName, targetDocumentPosition) {
1519
+ return function(element, secondElement) {
1520
+ checkHtmlElement(element, toAppearBefore, this);
1521
+ checkHtmlElement(secondElement, toAppearBefore, this);
1522
+ const documentPosition = element.compareDocumentPosition(secondElement);
1523
+ const pass = documentPosition === targetDocumentPosition;
1524
+ return {
1525
+ pass,
1526
+ message: () => {
1527
+ return [
1528
+ this.utils.matcherHint(
1529
+ `${this.isNot ? ".not" : ""}.${methodName}`,
1530
+ "element",
1531
+ "secondElement"
1532
+ ),
1533
+ "",
1534
+ `Received: ${makeDocumentPositionErrorString(documentPosition)}`
1535
+ ].join("\n");
1536
+ }
1537
+ };
1538
+ };
1539
+ }
1540
+ function toAppearBefore(element, secondElement) {
1541
+ return checkToAppear("toAppearBefore", DOCUMENT_POSITION_FOLLOWING).apply(
1542
+ this,
1543
+ [element, secondElement]
1544
+ );
1545
+ }
1546
+ function toAppearAfter(element, secondElement) {
1547
+ return checkToAppear("toAppearAfter", DOCUMENT_POSITION_PRECEDING).apply(
1548
+ this,
1549
+ [element, secondElement]
1550
+ );
1551
+ }
1428
1552
  function escapeHTML(str) {
1429
1553
  return str.replace(/</g, "&lt;").replace(/>/g, "&gt;");
1430
1554
  }
@@ -1518,14 +1642,14 @@ function createDOMElementFilter(filterNode) {
1518
1642
  }
1519
1643
  };
1520
1644
  }
1521
- var chalk2 = null;
1645
+ var picocolors = null;
1522
1646
  var readFileSync = null;
1523
1647
  var codeFrameColumns = null;
1524
1648
  try {
1525
1649
  const nodeRequire = module && module.require;
1526
1650
  readFileSync = nodeRequire.call(module, "fs").readFileSync;
1527
1651
  codeFrameColumns = nodeRequire.call(module, "@babel/code-frame").codeFrameColumns;
1528
- chalk2 = nodeRequire.call(module, "chalk");
1652
+ picocolors = nodeRequire.call(module, "picocolors");
1529
1653
  } catch {
1530
1654
  }
1531
1655
  function getCodeFrame(frame) {
@@ -1549,7 +1673,7 @@ function getCodeFrame(frame) {
1549
1673
  highlightCode: true,
1550
1674
  linesBelow: 0
1551
1675
  });
1552
- return chalk2.dim(frameLocation) + "\n" + codeFrame + "\n";
1676
+ return picocolors.dim(frameLocation) + "\n" + codeFrame + "\n";
1553
1677
  }
1554
1678
  function getUserCodeFrame() {
1555
1679
  if (!readFileSync || !codeFrameColumns) {
@@ -2777,8 +2901,8 @@ var queryAllByRole = function(container, role, _temp) {
2777
2901
  }
2778
2902
  }
2779
2903
  if (expanded !== void 0) {
2780
- var _allRoles$get10;
2781
- if (((_allRoles$get10 = roles.get(role)) == null ? void 0 : _allRoles$get10.props["aria-expanded"]) === void 0) {
2904
+ var _allRoles$get0;
2905
+ if (((_allRoles$get0 = roles.get(role)) == null ? void 0 : _allRoles$get0.props["aria-expanded"]) === void 0) {
2782
2906
  throw new Error('"aria-expanded" is not supported on role "' + role + '".');
2783
2907
  }
2784
2908
  }
@@ -3877,7 +4001,7 @@ typeof document !== "undefined" && document.body ? getQueriesForElement(document
3877
4001
  return helpers;
3878
4002
  }, initialValue);
3879
4003
 
3880
- // ../node_modules/.pnpm/@testing-library+react@16.3.0_@testing-library+dom@10.4.0_@types+react-dom@19.2.2_@type_42dafc68f916d85688afcbd0763451e5/node_modules/@testing-library/react/dist/@testing-library/react.esm.js
4004
+ // ../node_modules/.pnpm/@testing-library+react@16.3.1_@testing-library+dom@10.4.1_@types+react-dom@19.0.0_@type_d4bac7ed0d62de9e36e405d6771d7c0b/node_modules/@testing-library/react/dist/@testing-library/react.esm.js
3881
4005
  var reactAct = typeof React.act === "function" ? React.act : DeprecatedReactTestUtils.act;
3882
4006
  function getGlobalThis() {
3883
4007
  if (typeof globalThis !== "undefined") {
@@ -3986,11 +4110,10 @@ configure({
3986
4110
  var mountedContainers = /* @__PURE__ */ new Set();
3987
4111
  var mountedRootEntries = [];
3988
4112
  function cleanup() {
3989
- mountedRootEntries.forEach((_ref3) => {
3990
- let {
3991
- root,
3992
- container
3993
- } = _ref3;
4113
+ mountedRootEntries.forEach(({
4114
+ root,
4115
+ container
4116
+ }) => {
3994
4117
  act3(() => {
3995
4118
  root.unmount();
3996
4119
  });
@@ -4025,82 +4148,22 @@ if (typeof process === "undefined" || !process.env?.RTL_SKIP_AUTO_CLEANUP) {
4025
4148
  var NAME_WORKER_STATE = "__vitest_worker__";
4026
4149
  function getWorkerState() {
4027
4150
  const workerState = globalThis[NAME_WORKER_STATE];
4028
- if (!workerState) {
4029
- const errorMsg = 'Vitest failed to access its internal state.\n\nOne of the following is possible:\n- "vitest" is imported directly without running "vitest" command\n- "vitest" is imported inside "globalSetup" (to fix this, use "setupFiles" instead, because "globalSetup" runs in a different context)\n- Otherwise, it might be a Vitest bug. Please report it to https://github.com/vitest-dev/vitest/issues\n';
4030
- throw new Error(errorMsg);
4031
- }
4151
+ if (!workerState) throw new Error('Vitest failed to access its internal state.\n\nOne of the following is possible:\n- "vitest" is imported directly without running "vitest" command\n- "vitest" is imported inside "globalSetup" (to fix this, use "setupFiles" instead, because "globalSetup" runs in a different context)\n- "vitest" is imported inside Vite / Vitest config file\n- Otherwise, it might be a Vitest bug. Please report it to https://github.com/vitest-dev/vitest/issues\n');
4032
4152
  return workerState;
4033
4153
  }
4034
- function getCurrentEnvironment() {
4035
- const state = getWorkerState();
4036
- return state?.environment.name;
4037
- }
4038
- function isChildProcess() {
4039
- return typeof process !== "undefined" && !!process.send;
4040
- }
4041
- function resetModules(modules, resetMocks = false) {
4042
- const skipPaths = [
4043
- // Vitest
4044
- /\/vitest\/dist\//,
4045
- /\/vite-node\/dist\//,
4046
- // yarn's .store folder
4047
- /vitest-virtual-\w+\/dist/,
4048
- // cnpm
4049
- /@vitest\/dist/,
4050
- // don't clear mocks
4051
- ...!resetMocks ? [/^mock:/] : []
4052
- ];
4053
- modules.forEach((mod, path) => {
4054
- if (skipPaths.some((re) => re.test(path))) {
4055
- return;
4056
- }
4057
- modules.invalidateModule(mod);
4058
- });
4059
- }
4060
- function waitNextTick() {
4061
- const { setTimeout: setTimeout2 } = getSafeTimers();
4062
- return new Promise((resolve) => setTimeout2(resolve, 0));
4063
- }
4064
- async function waitForImportsToResolve() {
4065
- await waitNextTick();
4066
- const state = getWorkerState();
4067
- const promises = [];
4068
- let resolvingCount = 0;
4069
- for (const mod of state.moduleCache.values()) {
4070
- if (mod.promise && !mod.evaluated) {
4071
- promises.push(mod.promise);
4072
- }
4073
- if (mod.resolving) {
4074
- resolvingCount++;
4075
- }
4076
- }
4077
- if (!promises.length && !resolvingCount) {
4078
- return;
4079
- }
4080
- await Promise.allSettled(promises);
4081
- await waitForImportsToResolve();
4082
- }
4083
4154
 
4084
- // ../node_modules/.pnpm/vitest@2.1.9_@types+node@24.9.1_jsdom@25.0.1_msw@2.11.6_@types+node@24.9.1_typescript@5.8.3_/node_modules/vitest/dist/chunks/_commonjsHelpers.BFTU3MAI.js
4155
+ // ../node_modules/.pnpm/vitest@4.0.16_@types+node@25.0.3_jiti@2.6.1_jsdom@25.0.1_msw@2.12.7_@types+node@25.0.3_typescript@5.9.3__tsx@4.21.0/node_modules/vitest/dist/chunks/_commonjsHelpers.D26ty3Ew.js
4085
4156
  var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
4086
- function getDefaultExportFromCjs(x) {
4087
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
4088
- }
4089
4157
 
4090
- // ../node_modules/.pnpm/vitest@2.1.9_@types+node@24.9.1_jsdom@25.0.1_msw@2.11.6_@types+node@24.9.1_typescript@5.8.3_/node_modules/vitest/dist/chunks/date.W2xKR2qe.js
4158
+ // ../node_modules/.pnpm/vitest@4.0.16_@types+node@25.0.3_jiti@2.6.1_jsdom@25.0.1_msw@2.12.7_@types+node@25.0.3_typescript@5.9.3__tsx@4.21.0/node_modules/vitest/dist/chunks/date.Bq6ZW5rf.js
4091
4159
  var RealDate = Date;
4092
- var now = null;
4093
4160
  var MockDate = class _MockDate extends RealDate {
4094
4161
  constructor(y, m, d, h, M, s, ms) {
4095
4162
  super();
4096
4163
  let date;
4097
4164
  switch (arguments.length) {
4098
4165
  case 0:
4099
- if (now !== null) {
4100
- date = new RealDate(now.valueOf());
4101
- } else {
4102
- date = new RealDate();
4103
- }
4166
+ date = new RealDate();
4104
4167
  break;
4105
4168
  case 1:
4106
4169
  date = new RealDate(y);
@@ -4128,257 +4191,122 @@ MockDate.parse = function(dateString) {
4128
4191
  MockDate.toString = function() {
4129
4192
  return RealDate.toString();
4130
4193
  };
4131
- function mockDate(date) {
4132
- const dateObj = new RealDate(date.valueOf());
4133
- if (Number.isNaN(dateObj.getTime())) {
4134
- throw new TypeError(`mockdate: The time set is an invalid date: ${date}`);
4135
- }
4136
- globalThis.Date = MockDate;
4137
- now = dateObj.valueOf();
4138
- }
4139
- function resetDate() {
4140
- globalThis.Date = RealDate;
4141
- }
4194
+
4195
+ // ../node_modules/.pnpm/vitest@4.0.16_@types+node@25.0.3_jiti@2.6.1_jsdom@25.0.1_msw@2.12.7_@types+node@25.0.3_typescript@5.9.3__tsx@4.21.0/node_modules/vitest/dist/chunks/vi.2VT5v0um.js
4142
4196
  var unsupported = [
4143
- // .poll is meant to retry matchers until they succeed, and
4144
- // snapshots will always succeed as long as the poll method doesn't thow an error
4145
- // in this case using the `vi.waitFor` method is more appropriate
4146
4197
  "matchSnapshot",
4147
4198
  "toMatchSnapshot",
4148
4199
  "toMatchInlineSnapshot",
4149
4200
  "toThrowErrorMatchingSnapshot",
4150
4201
  "toThrowErrorMatchingInlineSnapshot",
4151
- // toThrow will never succeed because we call the poll callback until it doesn't throw
4152
4202
  "throws",
4153
4203
  "Throw",
4154
4204
  "throw",
4155
4205
  "toThrow",
4156
4206
  "toThrowError"
4157
- // these are not supported because you can call them without `.poll`,
4158
- // we throw an error inside the rejects/resolves methods to prevent this
4159
- // rejects,
4160
- // resolves
4161
4207
  ];
4162
- function createExpectPoll(expect2) {
4208
+ function throwWithCause(error, source) {
4209
+ if (error.cause == null) error.cause = /* @__PURE__ */ new Error("Matcher did not succeed in time.");
4210
+ throw copyStackTrace$1(error, source);
4211
+ }
4212
+ function createExpectPoll(expect) {
4163
4213
  return function poll(fn2, options = {}) {
4164
- const state = getWorkerState();
4165
- const defaults = state.config.expect?.poll ?? {};
4166
- const {
4167
- interval = defaults.interval ?? 50,
4168
- timeout = defaults.timeout ?? 1e3,
4169
- message
4170
- } = options;
4171
- const assertion = expect2(null, message).withContext({
4172
- poll: true
4173
- });
4214
+ const defaults = getWorkerState().config.expect?.poll ?? {};
4215
+ const { interval = defaults.interval ?? 50, timeout = defaults.timeout ?? 1e3, message } = options;
4216
+ const assertion = expect(null, message).withContext({ poll: true });
4174
4217
  fn2 = fn2.bind(assertion);
4175
- const test2 = chai$1.util.flag(assertion, "vitest-test");
4176
- if (!test2) {
4177
- throw new Error("expect.poll() must be called inside a test");
4178
- }
4179
- const proxy = new Proxy(assertion, {
4180
- get(target, key, receiver) {
4181
- const assertionFunction = Reflect.get(target, key, receiver);
4182
- if (typeof assertionFunction !== "function") {
4183
- return assertionFunction instanceof chai$1.Assertion ? proxy : assertionFunction;
4184
- }
4185
- if (key === "assert") {
4186
- return assertionFunction;
4187
- }
4188
- if (typeof key === "string" && unsupported.includes(key)) {
4189
- throw new SyntaxError(
4190
- `expect.poll() is not supported in combination with .${key}(). Use vi.waitFor() if your assertion condition is unstable.`
4191
- );
4192
- }
4193
- return function(...args) {
4194
- const STACK_TRACE_ERROR = new Error("STACK_TRACE_ERROR");
4195
- const promise = () => new Promise((resolve, reject) => {
4196
- let intervalId;
4197
- let lastError;
4198
- const { setTimeout: setTimeout2, clearTimeout: clearTimeout2 } = getSafeTimers();
4199
- const timeoutId = setTimeout2(() => {
4200
- clearTimeout2(intervalId);
4201
- reject(
4202
- copyStackTrace$1(
4203
- new Error(`Matcher did not succeed in ${timeout}ms`, {
4204
- cause: lastError
4205
- }),
4206
- STACK_TRACE_ERROR
4207
- )
4208
- );
4209
- }, timeout);
4210
- const check = async () => {
4218
+ const test2 = chai.util.flag(assertion, "vitest-test");
4219
+ if (!test2) throw new Error("expect.poll() must be called inside a test");
4220
+ const proxy = new Proxy(assertion, { get(target, key, receiver) {
4221
+ const assertionFunction = Reflect.get(target, key, receiver);
4222
+ if (typeof assertionFunction !== "function") return assertionFunction instanceof chai.Assertion ? proxy : assertionFunction;
4223
+ if (key === "assert") return assertionFunction;
4224
+ if (typeof key === "string" && unsupported.includes(key)) throw new SyntaxError(`expect.poll() is not supported in combination with .${key}(). Use vi.waitFor() if your assertion condition is unstable.`);
4225
+ return function(...args) {
4226
+ const STACK_TRACE_ERROR = /* @__PURE__ */ new Error("STACK_TRACE_ERROR");
4227
+ const promise = async () => {
4228
+ const { setTimeout: setTimeout2, clearTimeout: clearTimeout2 } = getSafeTimers();
4229
+ let executionPhase = "fn";
4230
+ let hasTimedOut = false;
4231
+ const timerId = setTimeout2(() => {
4232
+ hasTimedOut = true;
4233
+ }, timeout);
4234
+ chai.util.flag(assertion, "_name", key);
4235
+ try {
4236
+ while (true) {
4237
+ const isLastAttempt = hasTimedOut;
4238
+ if (isLastAttempt) chai.util.flag(assertion, "_isLastPollAttempt", true);
4211
4239
  try {
4212
- chai$1.util.flag(assertion, "_name", key);
4240
+ executionPhase = "fn";
4213
4241
  const obj = await fn2();
4214
- chai$1.util.flag(assertion, "object", obj);
4215
- resolve(await assertionFunction.call(assertion, ...args));
4216
- clearTimeout2(intervalId);
4217
- clearTimeout2(timeoutId);
4242
+ chai.util.flag(assertion, "object", obj);
4243
+ executionPhase = "assertion";
4244
+ return await assertionFunction.call(assertion, ...args);
4218
4245
  } catch (err) {
4219
- lastError = err;
4220
- intervalId = setTimeout2(check, interval);
4246
+ if (isLastAttempt || executionPhase === "assertion" && chai.util.flag(assertion, "_poll.assert_once")) throwWithCause(err, STACK_TRACE_ERROR);
4247
+ await delay(interval, setTimeout2);
4221
4248
  }
4222
- };
4223
- check();
4224
- });
4225
- let awaited = false;
4226
- test2.onFinished ??= [];
4227
- test2.onFinished.push(() => {
4228
- if (!awaited) {
4229
- const negated = chai$1.util.flag(assertion, "negate") ? "not." : "";
4230
- const name = chai$1.util.flag(assertion, "_poll.element") ? "element(locator)" : "poll(assertion)";
4231
- const assertionString = `expect.${name}.${negated}${String(key)}()`;
4232
- const error = new Error(
4233
- `${assertionString} was not awaited. This assertion is asynchronous and must be awaited; otherwise, it is not executed to avoid unhandled rejections:
4249
+ }
4250
+ } finally {
4251
+ clearTimeout2(timerId);
4252
+ }
4253
+ };
4254
+ let awaited = false;
4255
+ test2.onFinished ??= [];
4256
+ test2.onFinished.push(() => {
4257
+ if (!awaited) {
4258
+ const negated = chai.util.flag(assertion, "negate") ? "not." : "";
4259
+ const assertionString = `expect.${chai.util.flag(assertion, "_poll.element") ? "element(locator)" : "poll(assertion)"}.${negated}${String(key)}()`;
4260
+ throw copyStackTrace$1(/* @__PURE__ */ new Error(`${assertionString} was not awaited. This assertion is asynchronous and must be awaited; otherwise, it is not executed to avoid unhandled rejections:
4234
4261
 
4235
4262
  await ${assertionString}
4236
- `
4237
- );
4238
- throw copyStackTrace$1(error, STACK_TRACE_ERROR);
4239
- }
4240
- });
4241
- let resultPromise;
4242
- return {
4243
- then(onFulfilled, onRejected) {
4244
- awaited = true;
4245
- return (resultPromise ||= promise()).then(onFulfilled, onRejected);
4246
- },
4247
- catch(onRejected) {
4248
- return (resultPromise ||= promise()).catch(onRejected);
4249
- },
4250
- finally(onFinally) {
4251
- return (resultPromise ||= promise()).finally(onFinally);
4252
- },
4253
- [Symbol.toStringTag]: "Promise"
4254
- };
4263
+ `), STACK_TRACE_ERROR);
4264
+ }
4265
+ });
4266
+ let resultPromise;
4267
+ return {
4268
+ then(onFulfilled, onRejected) {
4269
+ awaited = true;
4270
+ return (resultPromise ||= promise()).then(onFulfilled, onRejected);
4271
+ },
4272
+ catch(onRejected) {
4273
+ return (resultPromise ||= promise()).catch(onRejected);
4274
+ },
4275
+ finally(onFinally) {
4276
+ return (resultPromise ||= promise()).finally(onFinally);
4277
+ },
4278
+ [Symbol.toStringTag]: "Promise"
4255
4279
  };
4256
- }
4257
- });
4280
+ };
4281
+ } });
4258
4282
  return proxy;
4259
4283
  };
4260
4284
  }
4261
4285
  function copyStackTrace$1(target, source) {
4262
- if (source.stack !== void 0) {
4263
- target.stack = source.stack.replace(source.message, target.message);
4264
- }
4286
+ if (source.stack !== void 0) target.stack = source.stack.replace(source.message, target.message);
4265
4287
  return target;
4266
4288
  }
4267
- function commonjsRequire(path) {
4268
- throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
4269
- }
4270
- var chaiSubset$1 = { exports: {} };
4271
- var chaiSubset = chaiSubset$1.exports;
4272
- var hasRequiredChaiSubset;
4273
- function requireChaiSubset() {
4274
- if (hasRequiredChaiSubset) return chaiSubset$1.exports;
4275
- hasRequiredChaiSubset = 1;
4276
- (function(module2, exports) {
4277
- (function() {
4278
- (function(chaiSubset2) {
4279
- if (typeof commonjsRequire === "function" && true && true) {
4280
- return module2.exports = chaiSubset2;
4281
- } else {
4282
- return chai.use(chaiSubset2);
4283
- }
4284
- })(function(chai3, utils) {
4285
- var Assertion2 = chai3.Assertion;
4286
- var assertionPrototype = Assertion2.prototype;
4287
- Assertion2.addMethod("containSubset", function(expected) {
4288
- var actual = utils.flag(this, "object");
4289
- var showDiff = chai3.config.showDiff;
4290
- assertionPrototype.assert.call(
4291
- this,
4292
- compare(expected, actual),
4293
- "expected #{act} to contain subset #{exp}",
4294
- "expected #{act} to not contain subset #{exp}",
4295
- expected,
4296
- actual,
4297
- showDiff
4298
- );
4299
- });
4300
- chai3.assert.containSubset = function(val, exp, msg) {
4301
- new chai3.Assertion(val, msg).to.be.containSubset(exp);
4302
- };
4303
- function compare(expected, actual) {
4304
- if (expected === actual) {
4305
- return true;
4306
- }
4307
- if (typeof actual !== typeof expected) {
4308
- return false;
4309
- }
4310
- if (typeof expected !== "object" || expected === null) {
4311
- return expected === actual;
4312
- }
4313
- if (!!expected && !actual) {
4314
- return false;
4315
- }
4316
- if (Array.isArray(expected)) {
4317
- if (typeof actual.length !== "number") {
4318
- return false;
4319
- }
4320
- var aa = Array.prototype.slice.call(actual);
4321
- return expected.every(function(exp) {
4322
- return aa.some(function(act4) {
4323
- return compare(exp, act4);
4324
- });
4325
- });
4326
- }
4327
- if (expected instanceof Date) {
4328
- if (actual instanceof Date) {
4329
- return expected.getTime() === actual.getTime();
4330
- } else {
4331
- return false;
4332
- }
4333
- }
4334
- return Object.keys(expected).every(function(key) {
4335
- var eo = expected[key];
4336
- var ao = actual[key];
4337
- if (typeof eo === "object" && eo !== null && ao !== null) {
4338
- return compare(eo, ao);
4339
- }
4340
- if (typeof eo === "function") {
4341
- return eo(ao);
4342
- }
4343
- return ao === eo;
4344
- });
4345
- }
4346
- });
4347
- }).call(chaiSubset);
4348
- })(chaiSubset$1);
4349
- return chaiSubset$1.exports;
4350
- }
4351
- var chaiSubsetExports = requireChaiSubset();
4352
- var Subset = /* @__PURE__ */ getDefaultExportFromCjs(chaiSubsetExports);
4353
- function createAssertionMessage(util2, assertion, hasArgs) {
4354
- const not = util2.flag(assertion, "negate") ? "not." : "";
4355
- const name = `${util2.flag(assertion, "_name")}(${"expected"})`;
4356
- const promiseName = util2.flag(assertion, "promise");
4357
- const promise = promiseName ? `.${promiseName}` : "";
4358
- return `expect(actual)${promise}.${not}${name}`;
4289
+ function createAssertionMessage(util, assertion, hasArgs) {
4290
+ const not = util.flag(assertion, "negate") ? "not." : "";
4291
+ const name = `${util.flag(assertion, "_name")}(${"expected"})`;
4292
+ const promiseName = util.flag(assertion, "promise");
4293
+ return `expect(actual)${promiseName ? `.${promiseName}` : ""}.${not}${name}`;
4359
4294
  }
4360
4295
  function recordAsyncExpect(_test, promise, assertion, error) {
4361
4296
  const test2 = _test;
4362
4297
  if (test2 && promise instanceof Promise) {
4363
4298
  promise = promise.finally(() => {
4364
- if (!test2.promises) {
4365
- return;
4366
- }
4299
+ if (!test2.promises) return;
4367
4300
  const index = test2.promises.indexOf(promise);
4368
- if (index !== -1) {
4369
- test2.promises.splice(index, 1);
4370
- }
4301
+ if (index !== -1) test2.promises.splice(index, 1);
4371
4302
  });
4372
- if (!test2.promises) {
4373
- test2.promises = [];
4374
- }
4303
+ if (!test2.promises) test2.promises = [];
4375
4304
  test2.promises.push(promise);
4376
4305
  let resolved = false;
4377
4306
  test2.onFinished ??= [];
4378
4307
  test2.onFinished.push(() => {
4379
4308
  if (!resolved) {
4380
- const processor = globalThis.__vitest_worker__?.onFilterStackTrace || ((s) => s || "");
4381
- const stack = processor(error.stack);
4309
+ const stack = (globalThis.__vitest_worker__?.onFilterStackTrace || ((s) => s || ""))(error.stack);
4382
4310
  console.warn([
4383
4311
  `Promise returned by \`${assertion}\` was not awaited. `,
4384
4312
  "Vitest currently auto-awaits hanging assertions at the end of the test, but this will cause the test to fail in Vitest 3. ",
@@ -4388,9 +4316,9 @@ function recordAsyncExpect(_test, promise, assertion, error) {
4388
4316
  }
4389
4317
  });
4390
4318
  return {
4391
- then(onFullfilled, onRejected) {
4319
+ then(onFulfilled, onRejected) {
4392
4320
  resolved = true;
4393
- return promise.then(onFullfilled, onRejected);
4321
+ return promise.then(onFulfilled, onRejected);
4394
4322
  },
4395
4323
  catch(onRejected) {
4396
4324
  return promise.catch(onRejected);
@@ -4405,22 +4333,14 @@ function recordAsyncExpect(_test, promise, assertion, error) {
4405
4333
  }
4406
4334
  var _client;
4407
4335
  function getSnapshotClient() {
4408
- if (!_client) {
4409
- _client = new SnapshotClient({
4410
- isEqual: (received, expected) => {
4411
- return equals(received, expected, [iterableEquality, subsetEquality]);
4412
- }
4413
- });
4414
- }
4336
+ if (!_client) _client = new SnapshotClient({ isEqual: (received, expected) => {
4337
+ return equals(received, expected, [iterableEquality, subsetEquality]);
4338
+ } });
4415
4339
  return _client;
4416
4340
  }
4417
4341
  function getError(expected, promise) {
4418
4342
  if (typeof expected !== "function") {
4419
- if (!promise) {
4420
- throw new Error(
4421
- `expected must be a function, received ${typeof expected}`
4422
- );
4423
- }
4343
+ if (!promise) throw new Error(`expected must be a function, received ${typeof expected}`);
4424
4344
  return expected;
4425
4345
  }
4426
4346
  try {
@@ -4431,248 +4351,174 @@ function getError(expected, promise) {
4431
4351
  throw new Error("snapshot function didn't throw");
4432
4352
  }
4433
4353
  function getTestNames(test2) {
4434
- if (!test2) {
4435
- return {};
4436
- }
4437
4354
  return {
4438
4355
  filepath: test2.file.filepath,
4439
- name: getNames(test2).slice(1).join(" > ")
4356
+ name: getNames(test2).slice(1).join(" > "),
4357
+ testId: test2.id
4440
4358
  };
4441
4359
  }
4442
4360
  var SnapshotPlugin = (chai3, utils) => {
4443
- for (const key of ["matchSnapshot", "toMatchSnapshot"]) {
4444
- utils.addMethod(
4445
- chai3.Assertion.prototype,
4446
- key,
4447
- function(properties, message) {
4448
- utils.flag(this, "_name", key);
4449
- const isNot = utils.flag(this, "negate");
4450
- if (isNot) {
4451
- throw new Error(`${key} cannot be used with "not"`);
4452
- }
4453
- const expected = utils.flag(this, "object");
4454
- const test2 = utils.flag(this, "vitest-test");
4455
- if (typeof properties === "string" && typeof message === "undefined") {
4456
- message = properties;
4457
- properties = void 0;
4458
- }
4459
- const errorMessage = utils.flag(this, "message");
4460
- getSnapshotClient().assert({
4461
- received: expected,
4462
- message,
4463
- isInline: false,
4464
- properties,
4465
- errorMessage,
4466
- ...getTestNames(test2)
4467
- });
4468
- }
4469
- );
4470
- }
4471
- utils.addMethod(
4472
- chai3.Assertion.prototype,
4473
- "toMatchFileSnapshot",
4474
- function(file, message) {
4475
- utils.flag(this, "_name", "toMatchFileSnapshot");
4476
- const isNot = utils.flag(this, "negate");
4477
- if (isNot) {
4478
- throw new Error('toMatchFileSnapshot cannot be used with "not"');
4479
- }
4480
- const error = new Error("resolves");
4481
- const expected = utils.flag(this, "object");
4482
- const test2 = utils.flag(this, "vitest-test");
4483
- const errorMessage = utils.flag(this, "message");
4484
- const promise = getSnapshotClient().assertRaw({
4485
- received: expected,
4486
- message,
4487
- isInline: false,
4488
- rawSnapshot: {
4489
- file
4490
- },
4491
- errorMessage,
4492
- ...getTestNames(test2)
4493
- });
4494
- return recordAsyncExpect(
4495
- test2,
4496
- promise,
4497
- createAssertionMessage(utils, this),
4498
- error
4499
- );
4500
- }
4501
- );
4502
- utils.addMethod(
4503
- chai3.Assertion.prototype,
4504
- "toMatchInlineSnapshot",
4505
- function __INLINE_SNAPSHOT__(properties, inlineSnapshot, message) {
4506
- utils.flag(this, "_name", "toMatchInlineSnapshot");
4507
- const isNot = utils.flag(this, "negate");
4508
- if (isNot) {
4509
- throw new Error('toMatchInlineSnapshot cannot be used with "not"');
4510
- }
4511
- const test2 = utils.flag(this, "vitest-test");
4512
- const isInsideEach = test2 && (test2.each || test2.suite?.each);
4513
- if (isInsideEach) {
4514
- throw new Error(
4515
- "InlineSnapshot cannot be used inside of test.each or describe.each"
4516
- );
4517
- }
4518
- const expected = utils.flag(this, "object");
4519
- const error = utils.flag(this, "error");
4520
- if (typeof properties === "string") {
4521
- message = inlineSnapshot;
4522
- inlineSnapshot = properties;
4523
- properties = void 0;
4524
- }
4525
- if (inlineSnapshot) {
4526
- inlineSnapshot = stripSnapshotIndentation(inlineSnapshot);
4527
- }
4528
- const errorMessage = utils.flag(this, "message");
4529
- getSnapshotClient().assert({
4530
- received: expected,
4531
- message,
4532
- isInline: true,
4533
- properties,
4534
- inlineSnapshot,
4535
- error,
4536
- errorMessage,
4537
- ...getTestNames(test2)
4538
- });
4539
- }
4540
- );
4541
- utils.addMethod(
4542
- chai3.Assertion.prototype,
4543
- "toThrowErrorMatchingSnapshot",
4544
- function(message) {
4545
- utils.flag(this, "_name", "toThrowErrorMatchingSnapshot");
4546
- const isNot = utils.flag(this, "negate");
4547
- if (isNot) {
4548
- throw new Error(
4549
- 'toThrowErrorMatchingSnapshot cannot be used with "not"'
4550
- );
4551
- }
4552
- const expected = utils.flag(this, "object");
4553
- const test2 = utils.flag(this, "vitest-test");
4554
- const promise = utils.flag(this, "promise");
4555
- const errorMessage = utils.flag(this, "message");
4556
- getSnapshotClient().assert({
4557
- received: getError(expected, promise),
4558
- message,
4559
- errorMessage,
4560
- ...getTestNames(test2)
4561
- });
4562
- }
4563
- );
4564
- utils.addMethod(
4565
- chai3.Assertion.prototype,
4566
- "toThrowErrorMatchingInlineSnapshot",
4567
- function __INLINE_SNAPSHOT__(inlineSnapshot, message) {
4568
- const isNot = utils.flag(this, "negate");
4569
- if (isNot) {
4570
- throw new Error(
4571
- 'toThrowErrorMatchingInlineSnapshot cannot be used with "not"'
4572
- );
4573
- }
4574
- const test2 = utils.flag(this, "vitest-test");
4575
- const isInsideEach = test2 && (test2.each || test2.suite?.each);
4576
- if (isInsideEach) {
4577
- throw new Error(
4578
- "InlineSnapshot cannot be used inside of test.each or describe.each"
4579
- );
4580
- }
4581
- const expected = utils.flag(this, "object");
4582
- const error = utils.flag(this, "error");
4583
- const promise = utils.flag(this, "promise");
4584
- const errorMessage = utils.flag(this, "message");
4585
- if (inlineSnapshot) {
4586
- inlineSnapshot = stripSnapshotIndentation(inlineSnapshot);
4587
- }
4588
- getSnapshotClient().assert({
4589
- received: getError(expected, promise),
4590
- message,
4591
- inlineSnapshot,
4592
- isInline: true,
4593
- error,
4594
- errorMessage,
4595
- ...getTestNames(test2)
4596
- });
4597
- }
4598
- );
4361
+ function getTest(assertionName, obj) {
4362
+ const test2 = utils.flag(obj, "vitest-test");
4363
+ if (!test2) throw new Error(`'${assertionName}' cannot be used without test context`);
4364
+ return test2;
4365
+ }
4366
+ for (const key of ["matchSnapshot", "toMatchSnapshot"]) utils.addMethod(chai3.Assertion.prototype, key, function(properties, message) {
4367
+ utils.flag(this, "_name", key);
4368
+ if (utils.flag(this, "negate")) throw new Error(`${key} cannot be used with "not"`);
4369
+ const expected = utils.flag(this, "object");
4370
+ const test2 = getTest(key, this);
4371
+ if (typeof properties === "string" && typeof message === "undefined") {
4372
+ message = properties;
4373
+ properties = void 0;
4374
+ }
4375
+ const errorMessage = utils.flag(this, "message");
4376
+ getSnapshotClient().assert({
4377
+ received: expected,
4378
+ message,
4379
+ isInline: false,
4380
+ properties,
4381
+ errorMessage,
4382
+ ...getTestNames(test2)
4383
+ });
4384
+ });
4385
+ utils.addMethod(chai3.Assertion.prototype, "toMatchFileSnapshot", function(file, message) {
4386
+ utils.flag(this, "_name", "toMatchFileSnapshot");
4387
+ if (utils.flag(this, "negate")) throw new Error('toMatchFileSnapshot cannot be used with "not"');
4388
+ const error = /* @__PURE__ */ new Error("resolves");
4389
+ const expected = utils.flag(this, "object");
4390
+ const test2 = getTest("toMatchFileSnapshot", this);
4391
+ const errorMessage = utils.flag(this, "message");
4392
+ return recordAsyncExpect(test2, getSnapshotClient().assertRaw({
4393
+ received: expected,
4394
+ message,
4395
+ isInline: false,
4396
+ rawSnapshot: { file },
4397
+ errorMessage,
4398
+ ...getTestNames(test2)
4399
+ }), createAssertionMessage(utils, this), error);
4400
+ });
4401
+ utils.addMethod(chai3.Assertion.prototype, "toMatchInlineSnapshot", function __INLINE_SNAPSHOT__(properties, inlineSnapshot, message) {
4402
+ utils.flag(this, "_name", "toMatchInlineSnapshot");
4403
+ if (utils.flag(this, "negate")) throw new Error('toMatchInlineSnapshot cannot be used with "not"');
4404
+ const test2 = getTest("toMatchInlineSnapshot", this);
4405
+ if (test2.each || test2.suite?.each) throw new Error("InlineSnapshot cannot be used inside of test.each or describe.each");
4406
+ const expected = utils.flag(this, "object");
4407
+ const error = utils.flag(this, "error");
4408
+ if (typeof properties === "string") {
4409
+ message = inlineSnapshot;
4410
+ inlineSnapshot = properties;
4411
+ properties = void 0;
4412
+ }
4413
+ if (inlineSnapshot) inlineSnapshot = stripSnapshotIndentation(inlineSnapshot);
4414
+ const errorMessage = utils.flag(this, "message");
4415
+ getSnapshotClient().assert({
4416
+ received: expected,
4417
+ message,
4418
+ isInline: true,
4419
+ properties,
4420
+ inlineSnapshot,
4421
+ error,
4422
+ errorMessage,
4423
+ ...getTestNames(test2)
4424
+ });
4425
+ });
4426
+ utils.addMethod(chai3.Assertion.prototype, "toThrowErrorMatchingSnapshot", function(message) {
4427
+ utils.flag(this, "_name", "toThrowErrorMatchingSnapshot");
4428
+ if (utils.flag(this, "negate")) throw new Error('toThrowErrorMatchingSnapshot cannot be used with "not"');
4429
+ const expected = utils.flag(this, "object");
4430
+ const test2 = getTest("toThrowErrorMatchingSnapshot", this);
4431
+ const promise = utils.flag(this, "promise");
4432
+ const errorMessage = utils.flag(this, "message");
4433
+ getSnapshotClient().assert({
4434
+ received: getError(expected, promise),
4435
+ message,
4436
+ errorMessage,
4437
+ ...getTestNames(test2)
4438
+ });
4439
+ });
4440
+ utils.addMethod(chai3.Assertion.prototype, "toThrowErrorMatchingInlineSnapshot", function __INLINE_SNAPSHOT__(inlineSnapshot, message) {
4441
+ if (utils.flag(this, "negate")) throw new Error('toThrowErrorMatchingInlineSnapshot cannot be used with "not"');
4442
+ const test2 = getTest("toThrowErrorMatchingInlineSnapshot", this);
4443
+ if (test2.each || test2.suite?.each) throw new Error("InlineSnapshot cannot be used inside of test.each or describe.each");
4444
+ const expected = utils.flag(this, "object");
4445
+ const error = utils.flag(this, "error");
4446
+ const promise = utils.flag(this, "promise");
4447
+ const errorMessage = utils.flag(this, "message");
4448
+ if (inlineSnapshot) inlineSnapshot = stripSnapshotIndentation(inlineSnapshot);
4449
+ getSnapshotClient().assert({
4450
+ received: getError(expected, promise),
4451
+ message,
4452
+ inlineSnapshot,
4453
+ isInline: true,
4454
+ error,
4455
+ errorMessage,
4456
+ ...getTestNames(test2)
4457
+ });
4458
+ });
4599
4459
  utils.addMethod(chai3.expect, "addSnapshotSerializer", addSerializer);
4600
4460
  };
4601
- chai$1.use(JestExtend);
4602
- chai$1.use(JestChaiExpect);
4603
- chai$1.use(Subset);
4604
- chai$1.use(SnapshotPlugin);
4605
- chai$1.use(JestAsymmetricMatchers);
4461
+ chai.use(JestExtend);
4462
+ chai.use(JestChaiExpect);
4463
+ chai.use(SnapshotPlugin);
4464
+ chai.use(JestAsymmetricMatchers);
4606
4465
  function createExpect(test2) {
4607
- const expect2 = (value, message) => {
4608
- const { assertionCalls } = getState(expect2);
4609
- setState({ assertionCalls: assertionCalls + 1 }, expect2);
4610
- const assert22 = chai$1.expect(value, message);
4466
+ const expect = ((value, message) => {
4467
+ const { assertionCalls } = getState(expect);
4468
+ setState({ assertionCalls: assertionCalls + 1 }, expect);
4469
+ const assert2 = chai.expect(value, message);
4611
4470
  const _test = getCurrentTest();
4612
- if (_test) {
4613
- return assert22.withTest(_test);
4614
- } else {
4615
- return assert22;
4616
- }
4617
- };
4618
- Object.assign(expect2, chai$1.expect);
4619
- Object.assign(expect2, globalThis[ASYMMETRIC_MATCHERS_OBJECT]);
4620
- expect2.getState = () => getState(expect2);
4621
- expect2.setState = (state) => setState(state, expect2);
4471
+ if (_test)
4472
+ return assert2.withTest(_test);
4473
+ else return assert2;
4474
+ });
4475
+ Object.assign(expect, chai.expect);
4476
+ Object.assign(expect, globalThis[ASYMMETRIC_MATCHERS_OBJECT]);
4477
+ expect.getState = () => getState(expect);
4478
+ expect.setState = (state) => setState(state, expect);
4622
4479
  const globalState = getState(globalThis[GLOBAL_EXPECT]) || {};
4623
- setState(
4624
- {
4625
- // this should also add "snapshotState" that is added conditionally
4626
- ...globalState,
4627
- assertionCalls: 0,
4628
- isExpectingAssertions: false,
4629
- isExpectingAssertionsError: null,
4630
- expectedAssertionsNumber: null,
4631
- expectedAssertionsNumberErrorGen: null,
4632
- environment: getCurrentEnvironment(),
4633
- get testPath() {
4634
- return getWorkerState().filepath;
4635
- },
4636
- currentTestName: globalState.currentTestName
4480
+ setState({
4481
+ ...globalState,
4482
+ assertionCalls: 0,
4483
+ isExpectingAssertions: false,
4484
+ isExpectingAssertionsError: null,
4485
+ expectedAssertionsNumber: null,
4486
+ expectedAssertionsNumberErrorGen: null,
4487
+ get testPath() {
4488
+ return getWorkerState().filepath;
4637
4489
  },
4638
- expect2
4639
- );
4640
- expect2.extend = (matchers) => chai$1.expect.extend(expect2, matchers);
4641
- expect2.addEqualityTesters = (customTesters) => addCustomEqualityTesters(customTesters);
4642
- expect2.soft = (...args) => {
4643
- return expect2(...args).withContext({ soft: true });
4490
+ currentTestName: globalState.currentTestName
4491
+ }, expect);
4492
+ expect.assert = chai.assert;
4493
+ expect.extend = (matchers) => chai.expect.extend(expect, matchers);
4494
+ expect.addEqualityTesters = (customTesters) => addCustomEqualityTesters(customTesters);
4495
+ expect.soft = (...args) => {
4496
+ return expect(...args).withContext({ soft: true });
4644
4497
  };
4645
- expect2.poll = createExpectPoll(expect2);
4646
- expect2.unreachable = (message) => {
4647
- chai$1.assert.fail(
4648
- `expected${message ? ` "${message}" ` : " "}not to be reached`
4649
- );
4498
+ expect.poll = createExpectPoll(expect);
4499
+ expect.unreachable = (message) => {
4500
+ chai.assert.fail(`expected${message ? ` "${message}" ` : " "}not to be reached`);
4650
4501
  };
4651
4502
  function assertions(expected) {
4652
- const errorGen = () => new Error(
4653
- `expected number of assertions to be ${expected}, but got ${expect2.getState().assertionCalls}`
4654
- );
4655
- if (Error.captureStackTrace) {
4656
- Error.captureStackTrace(errorGen(), assertions);
4657
- }
4658
- expect2.setState({
4503
+ const errorGen = () => /* @__PURE__ */ new Error(`expected number of assertions to be ${expected}, but got ${expect.getState().assertionCalls}`);
4504
+ if (Error.captureStackTrace) Error.captureStackTrace(errorGen(), assertions);
4505
+ expect.setState({
4659
4506
  expectedAssertionsNumber: expected,
4660
4507
  expectedAssertionsNumberErrorGen: errorGen
4661
4508
  });
4662
4509
  }
4663
4510
  function hasAssertions() {
4664
- const error = new Error("expected any number of assertion, but got none");
4665
- if (Error.captureStackTrace) {
4666
- Error.captureStackTrace(error, hasAssertions);
4667
- }
4668
- expect2.setState({
4511
+ const error = /* @__PURE__ */ new Error("expected any number of assertion, but got none");
4512
+ if (Error.captureStackTrace) Error.captureStackTrace(error, hasAssertions);
4513
+ expect.setState({
4669
4514
  isExpectingAssertions: true,
4670
4515
  isExpectingAssertionsError: error
4671
4516
  });
4672
4517
  }
4673
- chai$1.util.addMethod(expect2, "assertions", assertions);
4674
- chai$1.util.addMethod(expect2, "hasAssertions", hasAssertions);
4675
- return expect2;
4518
+ chai.util.addMethod(expect, "assertions", assertions);
4519
+ chai.util.addMethod(expect, "hasAssertions", hasAssertions);
4520
+ expect.extend(customMatchers);
4521
+ return expect;
4676
4522
  }
4677
4523
  var globalExpect = createExpect();
4678
4524
  Object.defineProperty(globalThis, GLOBAL_EXPECT, {
@@ -4680,6 +4526,8 @@ Object.defineProperty(globalThis, GLOBAL_EXPECT, {
4680
4526
  writable: true,
4681
4527
  configurable: true
4682
4528
  });
4529
+ chai.assert;
4530
+ chai.should;
4683
4531
  var fakeTimersSrc = {};
4684
4532
  var global2;
4685
4533
  var hasRequiredGlobal;
@@ -4787,42 +4635,14 @@ function requireCalledInOrder() {
4787
4635
  calledInOrder_1 = calledInOrder;
4788
4636
  return calledInOrder_1;
4789
4637
  }
4790
- var functionName;
4791
- var hasRequiredFunctionName;
4792
- function requireFunctionName() {
4793
- if (hasRequiredFunctionName) return functionName;
4794
- hasRequiredFunctionName = 1;
4795
- functionName = function functionName2(func) {
4796
- if (!func) {
4797
- return "";
4798
- }
4799
- try {
4800
- return func.displayName || func.name || // Use function decomposition as a last resort to get function
4801
- // name. Does not rely on function decomposition to work - if it
4802
- // doesn't debugging will be slightly less informative
4803
- // (i.e. toString will say 'spy' rather than 'myFunc').
4804
- (String(func).match(/function ([^\s(]+)/) || [])[1];
4805
- } catch (e) {
4806
- return "";
4807
- }
4808
- };
4809
- return functionName;
4810
- }
4811
4638
  var className_1;
4812
4639
  var hasRequiredClassName;
4813
4640
  function requireClassName() {
4814
4641
  if (hasRequiredClassName) return className_1;
4815
4642
  hasRequiredClassName = 1;
4816
- var functionName2 = requireFunctionName();
4817
4643
  function className(value) {
4818
- return value.constructor && value.constructor.name || // The next branch is for IE11 support only:
4819
- // Because the name property is not set on the prototype
4820
- // of the Function object, we finally try to grab the
4821
- // name from its definition. This will never be reached
4822
- // in node, so we are not able to test this properly.
4823
- // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/name
4824
- typeof value.constructor === "function" && /* istanbul ignore next */
4825
- functionName2(value.constructor) || null;
4644
+ const name = value.constructor && value.constructor.name;
4645
+ return name || null;
4826
4646
  }
4827
4647
  className_1 = className;
4828
4648
  return className_1;
@@ -4832,10 +4652,10 @@ var hasRequiredDeprecated;
4832
4652
  function requireDeprecated() {
4833
4653
  if (hasRequiredDeprecated) return deprecated;
4834
4654
  hasRequiredDeprecated = 1;
4835
- (function(exports) {
4836
- exports.wrap = function(func, msg) {
4655
+ (function(exports$1) {
4656
+ exports$1.wrap = function(func, msg) {
4837
4657
  var wrapped = function() {
4838
- exports.printWarning(msg);
4658
+ exports$1.printWarning(msg);
4839
4659
  return func.apply(this, arguments);
4840
4660
  };
4841
4661
  if (func.prototype) {
@@ -4843,10 +4663,10 @@ function requireDeprecated() {
4843
4663
  }
4844
4664
  return wrapped;
4845
4665
  };
4846
- exports.defaultMsg = function(packageName, funcName) {
4666
+ exports$1.defaultMsg = function(packageName, funcName) {
4847
4667
  return `${packageName}.${funcName} is deprecated and will be removed from the public API in a future version of ${packageName}.`;
4848
4668
  };
4849
- exports.printWarning = function(msg) {
4669
+ exports$1.printWarning = function(msg) {
4850
4670
  if (typeof process === "object" && process.emitWarning) {
4851
4671
  process.emitWarning(msg);
4852
4672
  } else if (console.info) {
@@ -4878,6 +4698,27 @@ function requireEvery() {
4878
4698
  };
4879
4699
  return every;
4880
4700
  }
4701
+ var functionName;
4702
+ var hasRequiredFunctionName;
4703
+ function requireFunctionName() {
4704
+ if (hasRequiredFunctionName) return functionName;
4705
+ hasRequiredFunctionName = 1;
4706
+ functionName = function functionName2(func) {
4707
+ if (!func) {
4708
+ return "";
4709
+ }
4710
+ try {
4711
+ return func.displayName || func.name || // Use function decomposition as a last resort to get function
4712
+ // name. Does not rely on function decomposition to work - if it
4713
+ // doesn't debugging will be slightly less informative
4714
+ // (i.e. toString will say 'spy' rather than 'myFunc').
4715
+ (String(func).match(/function ([^\s(]+)/) || [])[1];
4716
+ } catch (e) {
4717
+ return "";
4718
+ }
4719
+ };
4720
+ return functionName;
4721
+ }
4881
4722
  var orderByFirstCall_1;
4882
4723
  var hasRequiredOrderByFirstCall;
4883
4724
  function requireOrderByFirstCall() {
@@ -4964,7 +4805,7 @@ var hasRequiredTypeDetect;
4964
4805
  function requireTypeDetect() {
4965
4806
  if (hasRequiredTypeDetect) return typeDetect$1.exports;
4966
4807
  hasRequiredTypeDetect = 1;
4967
- (function(module2, exports) {
4808
+ (function(module2, exports$1) {
4968
4809
  (function(global3, factory) {
4969
4810
  module2.exports = factory();
4970
4811
  })(typeDetect, (function() {
@@ -5129,12 +4970,16 @@ function requireFakeTimersSrc() {
5129
4970
  if (hasRequiredFakeTimersSrc) return fakeTimersSrc;
5130
4971
  hasRequiredFakeTimersSrc = 1;
5131
4972
  const globalObject = requireLib().global;
5132
- let timersModule;
4973
+ let timersModule, timersPromisesModule;
5133
4974
  if (typeof __vitest_required__ !== "undefined") {
5134
4975
  try {
5135
4976
  timersModule = __vitest_required__.timers;
5136
4977
  } catch (e) {
5137
4978
  }
4979
+ try {
4980
+ timersPromisesModule = __vitest_required__.timersPromises;
4981
+ } catch (e) {
4982
+ }
5138
4983
  }
5139
4984
  function withGlobal(_global) {
5140
4985
  const maxTimeout = Math.pow(2, 31) - 1;
@@ -5145,26 +4990,57 @@ function requireFakeTimersSrc() {
5145
4990
  const NOOP_ARRAY = function() {
5146
4991
  return [];
5147
4992
  };
5148
- const timeoutResult = _global.setTimeout(NOOP, 0);
5149
- const addTimerReturnsObject = typeof timeoutResult === "object";
5150
- const hrtimePresent = _global.process && typeof _global.process.hrtime === "function";
5151
- const hrtimeBigintPresent = hrtimePresent && typeof _global.process.hrtime.bigint === "function";
5152
- const nextTickPresent = _global.process && typeof _global.process.nextTick === "function";
4993
+ const isPresent = {};
4994
+ let timeoutResult, addTimerReturnsObject = false;
4995
+ if (_global.setTimeout) {
4996
+ isPresent.setTimeout = true;
4997
+ timeoutResult = _global.setTimeout(NOOP, 0);
4998
+ addTimerReturnsObject = typeof timeoutResult === "object";
4999
+ }
5000
+ isPresent.clearTimeout = Boolean(_global.clearTimeout);
5001
+ isPresent.setInterval = Boolean(_global.setInterval);
5002
+ isPresent.clearInterval = Boolean(_global.clearInterval);
5003
+ isPresent.hrtime = _global.process && typeof _global.process.hrtime === "function";
5004
+ isPresent.hrtimeBigint = isPresent.hrtime && typeof _global.process.hrtime.bigint === "function";
5005
+ isPresent.nextTick = _global.process && typeof _global.process.nextTick === "function";
5153
5006
  const utilPromisify = _global.process && _global.__vitest_required__ && _global.__vitest_required__.util.promisify;
5154
- const performancePresent = _global.performance && typeof _global.performance.now === "function";
5007
+ isPresent.performance = _global.performance && typeof _global.performance.now === "function";
5155
5008
  const hasPerformancePrototype = _global.Performance && (typeof _global.Performance).match(/^(function|object)$/);
5156
5009
  const hasPerformanceConstructorPrototype = _global.performance && _global.performance.constructor && _global.performance.constructor.prototype;
5157
- const queueMicrotaskPresent = _global.hasOwnProperty("queueMicrotask");
5158
- const requestAnimationFramePresent = _global.requestAnimationFrame && typeof _global.requestAnimationFrame === "function";
5159
- const cancelAnimationFramePresent = _global.cancelAnimationFrame && typeof _global.cancelAnimationFrame === "function";
5160
- const requestIdleCallbackPresent = _global.requestIdleCallback && typeof _global.requestIdleCallback === "function";
5161
- const cancelIdleCallbackPresent = _global.cancelIdleCallback && typeof _global.cancelIdleCallback === "function";
5162
- const setImmediatePresent = _global.setImmediate && typeof _global.setImmediate === "function";
5163
- const intlPresent = _global.Intl && typeof _global.Intl === "object";
5164
- _global.clearTimeout(timeoutResult);
5010
+ isPresent.queueMicrotask = _global.hasOwnProperty("queueMicrotask");
5011
+ isPresent.requestAnimationFrame = _global.requestAnimationFrame && typeof _global.requestAnimationFrame === "function";
5012
+ isPresent.cancelAnimationFrame = _global.cancelAnimationFrame && typeof _global.cancelAnimationFrame === "function";
5013
+ isPresent.requestIdleCallback = _global.requestIdleCallback && typeof _global.requestIdleCallback === "function";
5014
+ isPresent.cancelIdleCallbackPresent = _global.cancelIdleCallback && typeof _global.cancelIdleCallback === "function";
5015
+ isPresent.setImmediate = _global.setImmediate && typeof _global.setImmediate === "function";
5016
+ isPresent.clearImmediate = _global.clearImmediate && typeof _global.clearImmediate === "function";
5017
+ isPresent.Intl = _global.Intl && typeof _global.Intl === "object";
5018
+ if (_global.clearTimeout) {
5019
+ _global.clearTimeout(timeoutResult);
5020
+ }
5165
5021
  const NativeDate = _global.Date;
5166
- const NativeIntl = _global.Intl;
5022
+ const NativeIntl = isPresent.Intl ? Object.defineProperties(
5023
+ /* @__PURE__ */ Object.create(null),
5024
+ Object.getOwnPropertyDescriptors(_global.Intl)
5025
+ ) : void 0;
5167
5026
  let uniqueTimerId = idCounterStart;
5027
+ if (NativeDate === void 0) {
5028
+ throw new Error(
5029
+ "The global scope doesn't have a `Date` object (see https://github.com/sinonjs/sinon/issues/1852#issuecomment-419622780)"
5030
+ );
5031
+ }
5032
+ isPresent.Date = true;
5033
+ class FakePerformanceEntry {
5034
+ constructor(name, entryType, startTime, duration) {
5035
+ this.name = name;
5036
+ this.entryType = entryType;
5037
+ this.startTime = startTime;
5038
+ this.duration = duration;
5039
+ }
5040
+ toJSON() {
5041
+ return JSON.stringify({ ...this });
5042
+ }
5043
+ }
5168
5044
  function isNumberFinite(num) {
5169
5045
  if (Number.isFinite) {
5170
5046
  return Number.isFinite(num);
@@ -5265,80 +5141,66 @@ ${job.error.stack.split("\n").slice(matchedLineIndex + 1).join("\n")}`;
5265
5141
  }
5266
5142
  return infiniteLoopError;
5267
5143
  }
5268
- function mirrorDateProperties(target, source) {
5269
- let prop;
5270
- for (prop in source) {
5271
- if (source.hasOwnProperty(prop)) {
5272
- target[prop] = source[prop];
5144
+ function createDate() {
5145
+ class ClockDate extends NativeDate {
5146
+ /**
5147
+ * @param {number} year
5148
+ * @param {number} month
5149
+ * @param {number} date
5150
+ * @param {number} hour
5151
+ * @param {number} minute
5152
+ * @param {number} second
5153
+ * @param {number} ms
5154
+ * @returns void
5155
+ */
5156
+ // eslint-disable-next-line no-unused-vars
5157
+ constructor(year, month, date, hour, minute, second, ms) {
5158
+ if (arguments.length === 0) {
5159
+ super(ClockDate.clock.now);
5160
+ } else {
5161
+ super(...arguments);
5162
+ }
5163
+ Object.defineProperty(this, "constructor", {
5164
+ value: NativeDate,
5165
+ enumerable: false
5166
+ });
5167
+ }
5168
+ static [Symbol.hasInstance](instance) {
5169
+ return instance instanceof NativeDate;
5273
5170
  }
5274
5171
  }
5275
- if (source.now) {
5276
- target.now = function now2() {
5277
- return target.clock.now;
5172
+ ClockDate.isFake = true;
5173
+ if (NativeDate.now) {
5174
+ ClockDate.now = function now2() {
5175
+ return ClockDate.clock.now;
5278
5176
  };
5279
- } else {
5280
- delete target.now;
5281
5177
  }
5282
- if (source.toSource) {
5283
- target.toSource = function toSource() {
5284
- return source.toSource();
5178
+ if (NativeDate.toSource) {
5179
+ ClockDate.toSource = function toSource() {
5180
+ return NativeDate.toSource();
5285
5181
  };
5286
- } else {
5287
- delete target.toSource;
5288
5182
  }
5289
- target.toString = function toString() {
5290
- return source.toString();
5183
+ ClockDate.toString = function toString() {
5184
+ return NativeDate.toString();
5291
5185
  };
5292
- target.prototype = source.prototype;
5293
- target.parse = source.parse;
5294
- target.UTC = source.UTC;
5295
- target.prototype.toUTCString = source.prototype.toUTCString;
5296
- target.isFake = true;
5297
- return target;
5298
- }
5299
- function createDate() {
5300
- function ClockDate(year, month, date, hour, minute, second, ms) {
5301
- if (!(this instanceof ClockDate)) {
5302
- return new NativeDate(ClockDate.clock.now).toString();
5303
- }
5304
- switch (arguments.length) {
5305
- case 0:
5306
- return new NativeDate(ClockDate.clock.now);
5307
- case 1:
5308
- return new NativeDate(year);
5309
- case 2:
5310
- return new NativeDate(year, month);
5311
- case 3:
5312
- return new NativeDate(year, month, date);
5313
- case 4:
5314
- return new NativeDate(year, month, date, hour);
5315
- case 5:
5316
- return new NativeDate(year, month, date, hour, minute);
5317
- case 6:
5318
- return new NativeDate(
5319
- year,
5320
- month,
5321
- date,
5322
- hour,
5323
- minute,
5324
- second
5325
- );
5326
- default:
5327
- return new NativeDate(
5328
- year,
5329
- month,
5330
- date,
5331
- hour,
5332
- minute,
5333
- second,
5334
- ms
5186
+ const ClockDateProxy = new Proxy(ClockDate, {
5187
+ // handler for [[Call]] invocations (i.e. not using `new`)
5188
+ apply() {
5189
+ if (this instanceof ClockDate) {
5190
+ throw new TypeError(
5191
+ "A Proxy should only capture `new` calls with the `construct` handler. This is not supposed to be possible, so check the logic."
5335
5192
  );
5193
+ }
5194
+ return new NativeDate(ClockDate.clock.now).toString();
5336
5195
  }
5337
- }
5338
- return mirrorDateProperties(ClockDate, NativeDate);
5196
+ });
5197
+ return ClockDateProxy;
5339
5198
  }
5340
5199
  function createIntl() {
5341
- const ClockIntl = { ...NativeIntl };
5200
+ const ClockIntl = {};
5201
+ Object.getOwnPropertyNames(NativeIntl).forEach(
5202
+ (property) => ClockIntl[property] = NativeIntl[property]
5203
+ );
5342
5204
  ClockIntl.DateTimeFormat = function(...args) {
5343
5205
  const realFormatter = new NativeIntl.DateTimeFormat(...args);
5344
5206
  const formatter = {};
@@ -5624,11 +5486,21 @@ To automatically clean-up native timers, use \`shouldClearNativeTimers\`.`
5624
5486
  timersModule[entry.methodName] = entry.original;
5625
5487
  }
5626
5488
  }
5489
+ if (clock.timersPromisesModuleMethods !== void 0) {
5490
+ for (let j = 0; j < clock.timersPromisesModuleMethods.length; j++) {
5491
+ const entry = clock.timersPromisesModuleMethods[j];
5492
+ timersPromisesModule[entry.methodName] = entry.original;
5493
+ }
5494
+ }
5627
5495
  }
5628
5496
  if (config2.shouldAdvanceTime === true) {
5629
5497
  _global.clearInterval(clock.attachedInterval);
5630
5498
  }
5631
5499
  clock.methods = [];
5500
+ for (const [listener, signal] of clock.abortListenerMap.entries()) {
5501
+ signal.removeEventListener("abort", listener);
5502
+ clock.abortListenerMap.delete(listener);
5503
+ }
5632
5504
  if (!clock.timers) {
5633
5505
  return [];
5634
5506
  }
@@ -5643,8 +5515,7 @@ To automatically clean-up native timers, use \`shouldClearNativeTimers\`.`
5643
5515
  );
5644
5516
  clock[`_${method}`] = target[method];
5645
5517
  if (method === "Date") {
5646
- const date = mirrorDateProperties(clock[method], target[method]);
5647
- target[method] = date;
5518
+ target[method] = clock[method];
5648
5519
  } else if (method === "Intl") {
5649
5520
  target[method] = clock[method];
5650
5521
  } else if (method === "performance") {
@@ -5687,36 +5558,38 @@ To automatically clean-up native timers, use \`shouldClearNativeTimers\`.`
5687
5558
  clearInterval: _global.clearInterval,
5688
5559
  Date: _global.Date
5689
5560
  };
5690
- if (setImmediatePresent) {
5561
+ if (isPresent.setImmediate) {
5691
5562
  timers.setImmediate = _global.setImmediate;
5563
+ }
5564
+ if (isPresent.clearImmediate) {
5692
5565
  timers.clearImmediate = _global.clearImmediate;
5693
5566
  }
5694
- if (hrtimePresent) {
5567
+ if (isPresent.hrtime) {
5695
5568
  timers.hrtime = _global.process.hrtime;
5696
5569
  }
5697
- if (nextTickPresent) {
5570
+ if (isPresent.nextTick) {
5698
5571
  timers.nextTick = _global.process.nextTick;
5699
5572
  }
5700
- if (performancePresent) {
5573
+ if (isPresent.performance) {
5701
5574
  timers.performance = _global.performance;
5702
5575
  }
5703
- if (requestAnimationFramePresent) {
5576
+ if (isPresent.requestAnimationFrame) {
5704
5577
  timers.requestAnimationFrame = _global.requestAnimationFrame;
5705
5578
  }
5706
- if (queueMicrotaskPresent) {
5707
- timers.queueMicrotask = true;
5579
+ if (isPresent.queueMicrotask) {
5580
+ timers.queueMicrotask = _global.queueMicrotask;
5708
5581
  }
5709
- if (cancelAnimationFramePresent) {
5582
+ if (isPresent.cancelAnimationFrame) {
5710
5583
  timers.cancelAnimationFrame = _global.cancelAnimationFrame;
5711
5584
  }
5712
- if (requestIdleCallbackPresent) {
5585
+ if (isPresent.requestIdleCallback) {
5713
5586
  timers.requestIdleCallback = _global.requestIdleCallback;
5714
5587
  }
5715
- if (cancelIdleCallbackPresent) {
5588
+ if (isPresent.cancelIdleCallback) {
5716
5589
  timers.cancelIdleCallback = _global.cancelIdleCallback;
5717
5590
  }
5718
- if (intlPresent) {
5719
- timers.Intl = _global.Intl;
5591
+ if (isPresent.Intl) {
5592
+ timers.Intl = NativeIntl;
5720
5593
  }
5721
5594
  const originalSetTimeout = _global.setImmediate || _global.setTimeout;
5722
5595
  function createClock(start, loopLimit) {
@@ -5724,11 +5597,6 @@ To automatically clean-up native timers, use \`shouldClearNativeTimers\`.`
5724
5597
  loopLimit = loopLimit || 1e3;
5725
5598
  let nanos = 0;
5726
5599
  const adjustedSystemTime = [0, 0];
5727
- if (NativeDate === void 0) {
5728
- throw new Error(
5729
- "The global scope doesn't have a `Date` object (see https://github.com/sinonjs/sinon/issues/1852#issuecomment-419622780)"
5730
- );
5731
- }
5732
5600
  const clock = {
5733
5601
  now: start,
5734
5602
  Date: createDate(),
@@ -5764,13 +5632,13 @@ To automatically clean-up native timers, use \`shouldClearNativeTimers\`.`
5764
5632
  const millis = hrt[0] * 1e3 + hrt[1] / 1e6;
5765
5633
  return millis;
5766
5634
  }
5767
- if (hrtimeBigintPresent) {
5635
+ if (isPresent.hrtimeBigint) {
5768
5636
  hrtime.bigint = function() {
5769
5637
  const parts = hrtime();
5770
5638
  return BigInt(parts[0]) * BigInt(1e9) + BigInt(parts[1]);
5771
5639
  };
5772
5640
  }
5773
- if (intlPresent) {
5641
+ if (isPresent.Intl) {
5774
5642
  clock.Intl = createIntl();
5775
5643
  clock.Intl.clock = clock;
5776
5644
  }
@@ -5833,7 +5701,7 @@ To automatically clean-up native timers, use \`shouldClearNativeTimers\`.`
5833
5701
  clock.clearInterval = function clearInterval2(timerId) {
5834
5702
  return clearTimer(clock, timerId, "Interval");
5835
5703
  };
5836
- if (setImmediatePresent) {
5704
+ if (isPresent.setImmediate) {
5837
5705
  clock.setImmediate = function setImmediate(func) {
5838
5706
  return addTimer(clock, {
5839
5707
  func,
@@ -6066,6 +5934,7 @@ To automatically clean-up native timers, use \`shouldClearNativeTimers\`.`
6066
5934
  function doRun() {
6067
5935
  originalSetTimeout(function() {
6068
5936
  try {
5937
+ runJobs(clock);
6069
5938
  let numTimers;
6070
5939
  if (i < clock.loopLimit) {
6071
5940
  if (!clock.timers) {
@@ -6113,6 +5982,7 @@ To automatically clean-up native timers, use \`shouldClearNativeTimers\`.`
6113
5982
  try {
6114
5983
  const timer = lastTimer(clock);
6115
5984
  if (!timer) {
5985
+ runJobs(clock);
6116
5986
  resolve(clock.now);
6117
5987
  }
6118
5988
  resolve(clock.tickAsync(timer.callAt - clock.now));
@@ -6155,11 +6025,11 @@ To automatically clean-up native timers, use \`shouldClearNativeTimers\`.`
6155
6025
  }
6156
6026
  clock.tick(ms);
6157
6027
  };
6158
- if (performancePresent) {
6028
+ if (isPresent.performance) {
6159
6029
  clock.performance = /* @__PURE__ */ Object.create(null);
6160
6030
  clock.performance.now = fakePerformanceNow;
6161
6031
  }
6162
- if (hrtimePresent) {
6032
+ if (isPresent.hrtime) {
6163
6033
  clock.hrtime = hrtime;
6164
6034
  }
6165
6035
  return clock;
@@ -6186,17 +6056,24 @@ To automatically clean-up native timers, use \`shouldClearNativeTimers\`.`
6186
6056
  "config.target is no longer supported. Use `withGlobal(target)` instead."
6187
6057
  );
6188
6058
  }
6059
+ function handleMissingTimer(timer) {
6060
+ if (config2.ignoreMissingTimers) {
6061
+ return;
6062
+ }
6063
+ throw new ReferenceError(
6064
+ `non-existent timers and/or objects cannot be faked: '${timer}'`
6065
+ );
6066
+ }
6189
6067
  let i, l;
6190
6068
  const clock = createClock(config2.now, config2.loopLimit);
6191
6069
  clock.shouldClearNativeTimers = config2.shouldClearNativeTimers;
6192
6070
  clock.uninstall = function() {
6193
6071
  return uninstall(clock, config2);
6194
6072
  };
6073
+ clock.abortListenerMap = /* @__PURE__ */ new Map();
6195
6074
  clock.methods = config2.toFake || [];
6196
6075
  if (clock.methods.length === 0) {
6197
- clock.methods = Object.keys(timers).filter(function(key) {
6198
- return key !== "nextTick" && key !== "queueMicrotask";
6199
- });
6076
+ clock.methods = Object.keys(timers);
6200
6077
  }
6201
6078
  if (config2.shouldAdvanceTime === true) {
6202
6079
  const intervalTick = doIntervalTick.bind(
@@ -6225,17 +6102,25 @@ To automatically clean-up native timers, use \`shouldClearNativeTimers\`.`
6225
6102
  clock.performance[name] = name.indexOf("getEntries") === 0 ? NOOP_ARRAY : NOOP;
6226
6103
  }
6227
6104
  });
6105
+ clock.performance.mark = (name) => new FakePerformanceEntry(name, "mark", 0, 0);
6106
+ clock.performance.measure = (name) => new FakePerformanceEntry(name, "measure", 0, 100);
6107
+ clock.performance.timeOrigin = getEpoch(config2.now);
6228
6108
  } else if ((config2.toFake || []).includes("performance")) {
6229
- throw new ReferenceError(
6230
- "non-existent performance object cannot be faked"
6231
- );
6109
+ return handleMissingTimer("performance");
6232
6110
  }
6233
6111
  }
6234
6112
  if (_global === globalObject && timersModule) {
6235
6113
  clock.timersModuleMethods = [];
6236
6114
  }
6115
+ if (_global === globalObject && timersPromisesModule) {
6116
+ clock.timersPromisesModuleMethods = [];
6117
+ }
6237
6118
  for (i = 0, l = clock.methods.length; i < l; i++) {
6238
6119
  const nameOfMethodToReplace = clock.methods[i];
6120
+ if (!isPresent[nameOfMethodToReplace]) {
6121
+ handleMissingTimer(nameOfMethodToReplace);
6122
+ continue;
6123
+ }
6239
6124
  if (nameOfMethodToReplace === "hrtime") {
6240
6125
  if (_global.process && typeof _global.process.hrtime === "function") {
6241
6126
  hijackMethod(_global.process, nameOfMethodToReplace, clock);
@@ -6255,6 +6140,194 @@ To automatically clean-up native timers, use \`shouldClearNativeTimers\`.`
6255
6140
  });
6256
6141
  timersModule[nameOfMethodToReplace] = _global[nameOfMethodToReplace];
6257
6142
  }
6143
+ if (clock.timersPromisesModuleMethods !== void 0) {
6144
+ if (nameOfMethodToReplace === "setTimeout") {
6145
+ clock.timersPromisesModuleMethods.push({
6146
+ methodName: "setTimeout",
6147
+ original: timersPromisesModule.setTimeout
6148
+ });
6149
+ timersPromisesModule.setTimeout = (delay2, value, options = {}) => new Promise((resolve, reject) => {
6150
+ const abort = () => {
6151
+ options.signal.removeEventListener(
6152
+ "abort",
6153
+ abort
6154
+ );
6155
+ clock.abortListenerMap.delete(abort);
6156
+ clock.clearTimeout(handle);
6157
+ reject(options.signal.reason);
6158
+ };
6159
+ const handle = clock.setTimeout(() => {
6160
+ if (options.signal) {
6161
+ options.signal.removeEventListener(
6162
+ "abort",
6163
+ abort
6164
+ );
6165
+ clock.abortListenerMap.delete(abort);
6166
+ }
6167
+ resolve(value);
6168
+ }, delay2);
6169
+ if (options.signal) {
6170
+ if (options.signal.aborted) {
6171
+ abort();
6172
+ } else {
6173
+ options.signal.addEventListener(
6174
+ "abort",
6175
+ abort
6176
+ );
6177
+ clock.abortListenerMap.set(
6178
+ abort,
6179
+ options.signal
6180
+ );
6181
+ }
6182
+ }
6183
+ });
6184
+ } else if (nameOfMethodToReplace === "setImmediate") {
6185
+ clock.timersPromisesModuleMethods.push({
6186
+ methodName: "setImmediate",
6187
+ original: timersPromisesModule.setImmediate
6188
+ });
6189
+ timersPromisesModule.setImmediate = (value, options = {}) => new Promise((resolve, reject) => {
6190
+ const abort = () => {
6191
+ options.signal.removeEventListener(
6192
+ "abort",
6193
+ abort
6194
+ );
6195
+ clock.abortListenerMap.delete(abort);
6196
+ clock.clearImmediate(handle);
6197
+ reject(options.signal.reason);
6198
+ };
6199
+ const handle = clock.setImmediate(() => {
6200
+ if (options.signal) {
6201
+ options.signal.removeEventListener(
6202
+ "abort",
6203
+ abort
6204
+ );
6205
+ clock.abortListenerMap.delete(abort);
6206
+ }
6207
+ resolve(value);
6208
+ });
6209
+ if (options.signal) {
6210
+ if (options.signal.aborted) {
6211
+ abort();
6212
+ } else {
6213
+ options.signal.addEventListener(
6214
+ "abort",
6215
+ abort
6216
+ );
6217
+ clock.abortListenerMap.set(
6218
+ abort,
6219
+ options.signal
6220
+ );
6221
+ }
6222
+ }
6223
+ });
6224
+ } else if (nameOfMethodToReplace === "setInterval") {
6225
+ clock.timersPromisesModuleMethods.push({
6226
+ methodName: "setInterval",
6227
+ original: timersPromisesModule.setInterval
6228
+ });
6229
+ timersPromisesModule.setInterval = (delay2, value, options = {}) => ({
6230
+ [Symbol.asyncIterator]: () => {
6231
+ const createResolvable = () => {
6232
+ let resolve, reject;
6233
+ const promise = new Promise((res, rej) => {
6234
+ resolve = res;
6235
+ reject = rej;
6236
+ });
6237
+ promise.resolve = resolve;
6238
+ promise.reject = reject;
6239
+ return promise;
6240
+ };
6241
+ let done = false;
6242
+ let hasThrown = false;
6243
+ let returnCall;
6244
+ let nextAvailable = 0;
6245
+ const nextQueue = [];
6246
+ const handle = clock.setInterval(() => {
6247
+ if (nextQueue.length > 0) {
6248
+ nextQueue.shift().resolve();
6249
+ } else {
6250
+ nextAvailable++;
6251
+ }
6252
+ }, delay2);
6253
+ const abort = () => {
6254
+ options.signal.removeEventListener(
6255
+ "abort",
6256
+ abort
6257
+ );
6258
+ clock.abortListenerMap.delete(abort);
6259
+ clock.clearInterval(handle);
6260
+ done = true;
6261
+ for (const resolvable of nextQueue) {
6262
+ resolvable.resolve();
6263
+ }
6264
+ };
6265
+ if (options.signal) {
6266
+ if (options.signal.aborted) {
6267
+ done = true;
6268
+ } else {
6269
+ options.signal.addEventListener(
6270
+ "abort",
6271
+ abort
6272
+ );
6273
+ clock.abortListenerMap.set(
6274
+ abort,
6275
+ options.signal
6276
+ );
6277
+ }
6278
+ }
6279
+ return {
6280
+ next: async () => {
6281
+ if (options.signal?.aborted && !hasThrown) {
6282
+ hasThrown = true;
6283
+ throw options.signal.reason;
6284
+ }
6285
+ if (done) {
6286
+ return { done: true, value: void 0 };
6287
+ }
6288
+ if (nextAvailable > 0) {
6289
+ nextAvailable--;
6290
+ return { done: false, value };
6291
+ }
6292
+ const resolvable = createResolvable();
6293
+ nextQueue.push(resolvable);
6294
+ await resolvable;
6295
+ if (returnCall && nextQueue.length === 0) {
6296
+ returnCall.resolve();
6297
+ }
6298
+ if (options.signal?.aborted && !hasThrown) {
6299
+ hasThrown = true;
6300
+ throw options.signal.reason;
6301
+ }
6302
+ if (done) {
6303
+ return { done: true, value: void 0 };
6304
+ }
6305
+ return { done: false, value };
6306
+ },
6307
+ return: async () => {
6308
+ if (done) {
6309
+ return { done: true, value: void 0 };
6310
+ }
6311
+ if (nextQueue.length > 0) {
6312
+ returnCall = createResolvable();
6313
+ await returnCall;
6314
+ }
6315
+ clock.clearInterval(handle);
6316
+ done = true;
6317
+ if (options.signal) {
6318
+ options.signal.removeEventListener(
6319
+ "abort",
6320
+ abort
6321
+ );
6322
+ clock.abortListenerMap.delete(abort);
6323
+ }
6324
+ return { done: true, value: void 0 };
6325
+ }
6326
+ };
6327
+ }
6328
+ });
6329
+ }
6330
+ }
6258
6331
  }
6259
6332
  return clock;
6260
6333
  }
@@ -6272,604 +6345,33 @@ To automatically clean-up native timers, use \`shouldClearNativeTimers\`.`
6272
6345
  fakeTimersSrc.withGlobal = withGlobal;
6273
6346
  return fakeTimersSrc;
6274
6347
  }
6275
- var fakeTimersSrcExports = requireFakeTimersSrc();
6276
- var FakeTimers = class {
6277
- _global;
6278
- _clock;
6279
- _fakingTime;
6280
- _fakingDate;
6281
- _fakeTimers;
6282
- _userConfig;
6283
- _now = RealDate.now;
6284
- constructor({
6285
- global: global3,
6286
- config: config2
6287
- }) {
6288
- this._userConfig = config2;
6289
- this._fakingDate = false;
6290
- this._fakingTime = false;
6291
- this._fakeTimers = fakeTimersSrcExports.withGlobal(global3);
6292
- this._global = global3;
6293
- }
6294
- clearAllTimers() {
6295
- if (this._fakingTime) {
6296
- this._clock.reset();
6297
- }
6298
- }
6299
- dispose() {
6300
- this.useRealTimers();
6301
- }
6302
- runAllTimers() {
6303
- if (this._checkFakeTimers()) {
6304
- this._clock.runAll();
6305
- }
6306
- }
6307
- async runAllTimersAsync() {
6308
- if (this._checkFakeTimers()) {
6309
- await this._clock.runAllAsync();
6310
- }
6311
- }
6312
- runOnlyPendingTimers() {
6313
- if (this._checkFakeTimers()) {
6314
- this._clock.runToLast();
6315
- }
6316
- }
6317
- async runOnlyPendingTimersAsync() {
6318
- if (this._checkFakeTimers()) {
6319
- await this._clock.runToLastAsync();
6320
- }
6321
- }
6322
- advanceTimersToNextTimer(steps = 1) {
6323
- if (this._checkFakeTimers()) {
6324
- for (let i = steps; i > 0; i--) {
6325
- this._clock.next();
6326
- this._clock.tick(0);
6327
- if (this._clock.countTimers() === 0) {
6328
- break;
6329
- }
6330
- }
6331
- }
6332
- }
6333
- async advanceTimersToNextTimerAsync(steps = 1) {
6334
- if (this._checkFakeTimers()) {
6335
- for (let i = steps; i > 0; i--) {
6336
- await this._clock.nextAsync();
6337
- this._clock.tick(0);
6338
- if (this._clock.countTimers() === 0) {
6339
- break;
6340
- }
6341
- }
6342
- }
6343
- }
6344
- advanceTimersByTime(msToRun) {
6345
- if (this._checkFakeTimers()) {
6346
- this._clock.tick(msToRun);
6347
- }
6348
- }
6349
- async advanceTimersByTimeAsync(msToRun) {
6350
- if (this._checkFakeTimers()) {
6351
- await this._clock.tickAsync(msToRun);
6352
- }
6353
- }
6354
- advanceTimersToNextFrame() {
6355
- if (this._checkFakeTimers()) {
6356
- this._clock.runToFrame();
6357
- }
6358
- }
6359
- runAllTicks() {
6360
- if (this._checkFakeTimers()) {
6361
- this._clock.runMicrotasks();
6362
- }
6363
- }
6364
- useRealTimers() {
6365
- if (this._fakingDate) {
6366
- resetDate();
6367
- this._fakingDate = false;
6368
- }
6369
- if (this._fakingTime) {
6370
- this._clock.uninstall();
6371
- this._fakingTime = false;
6372
- }
6373
- }
6374
- useFakeTimers() {
6375
- if (this._fakingDate) {
6376
- throw new Error(
6377
- '"setSystemTime" was called already and date was mocked. Reset timers using `vi.useRealTimers()` if you want to use fake timers again.'
6378
- );
6379
- }
6380
- if (!this._fakingTime) {
6381
- const toFake = Object.keys(this._fakeTimers.timers).filter(
6382
- (timer) => timer !== "nextTick"
6383
- );
6384
- if (this._userConfig?.toFake?.includes("nextTick") && isChildProcess()) {
6385
- throw new Error(
6386
- "process.nextTick cannot be mocked inside child_process"
6387
- );
6388
- }
6389
- const existingFakedMethods = (this._userConfig?.toFake || toFake).filter(
6390
- (method) => {
6391
- switch (method) {
6392
- case "setImmediate":
6393
- case "clearImmediate":
6394
- return method in this._global && this._global[method];
6395
- default:
6396
- return true;
6397
- }
6398
- }
6399
- );
6400
- this._clock = this._fakeTimers.install({
6401
- now: Date.now(),
6402
- ...this._userConfig,
6403
- toFake: existingFakedMethods
6404
- });
6405
- this._fakingTime = true;
6406
- }
6407
- }
6408
- reset() {
6409
- if (this._checkFakeTimers()) {
6410
- const { now: now2 } = this._clock;
6411
- this._clock.reset();
6412
- this._clock.setSystemTime(now2);
6413
- }
6414
- }
6415
- setSystemTime(now2) {
6416
- if (this._fakingTime) {
6417
- this._clock.setSystemTime(now2);
6418
- } else {
6419
- mockDate(now2 ?? this.getRealSystemTime());
6420
- this._fakingDate = true;
6421
- }
6422
- }
6423
- getRealSystemTime() {
6424
- return this._now();
6425
- }
6426
- getTimerCount() {
6427
- if (this._checkFakeTimers()) {
6428
- return this._clock.countTimers();
6429
- }
6430
- return 0;
6431
- }
6432
- configure(config2) {
6433
- this._userConfig = config2;
6434
- }
6435
- isFakeTimers() {
6436
- return this._fakingTime;
6437
- }
6438
- _checkFakeTimers() {
6439
- if (!this._fakingTime) {
6440
- throw new Error(
6441
- 'Timers are not mocked. Try calling "vi.useFakeTimers()" first.'
6442
- );
6443
- }
6444
- return this._fakingTime;
6445
- }
6446
- };
6447
- function copyStackTrace2(target, source) {
6448
- if (source.stack !== void 0) {
6449
- target.stack = source.stack.replace(source.message, target.message);
6450
- }
6451
- return target;
6452
- }
6453
- function waitFor2(callback, options = {}) {
6454
- const { setTimeout: setTimeout2, setInterval: setInterval2, clearTimeout: clearTimeout2, clearInterval: clearInterval2 } = getSafeTimers();
6455
- const { interval = 50, timeout = 1e3 } = typeof options === "number" ? { timeout: options } : options;
6456
- const STACK_TRACE_ERROR = new Error("STACK_TRACE_ERROR");
6457
- return new Promise((resolve, reject) => {
6458
- let lastError;
6459
- let promiseStatus = "idle";
6460
- let timeoutId;
6461
- let intervalId;
6462
- const onResolve = (result) => {
6463
- if (timeoutId) {
6464
- clearTimeout2(timeoutId);
6465
- }
6466
- if (intervalId) {
6467
- clearInterval2(intervalId);
6468
- }
6469
- resolve(result);
6470
- };
6471
- const handleTimeout = () => {
6472
- if (intervalId) {
6473
- clearInterval2(intervalId);
6474
- }
6475
- let error = lastError;
6476
- if (!error) {
6477
- error = copyStackTrace2(
6478
- new Error("Timed out in waitFor!"),
6479
- STACK_TRACE_ERROR
6480
- );
6481
- }
6482
- reject(error);
6483
- };
6484
- const checkCallback = () => {
6485
- if (vi.isFakeTimers()) {
6486
- vi.advanceTimersByTime(interval);
6487
- }
6488
- if (promiseStatus === "pending") {
6489
- return;
6490
- }
6491
- try {
6492
- const result = callback();
6493
- if (result !== null && typeof result === "object" && typeof result.then === "function") {
6494
- const thenable = result;
6495
- promiseStatus = "pending";
6496
- thenable.then(
6497
- (resolvedValue) => {
6498
- promiseStatus = "resolved";
6499
- onResolve(resolvedValue);
6500
- },
6501
- (rejectedValue) => {
6502
- promiseStatus = "rejected";
6503
- lastError = rejectedValue;
6504
- }
6505
- );
6506
- } else {
6507
- onResolve(result);
6508
- return true;
6509
- }
6510
- } catch (error) {
6511
- lastError = error;
6512
- }
6513
- };
6514
- if (checkCallback() === true) {
6515
- return;
6516
- }
6517
- timeoutId = setTimeout2(handleTimeout, timeout);
6518
- intervalId = setInterval2(checkCallback, interval);
6519
- });
6520
- }
6521
- function waitUntil(callback, options = {}) {
6522
- const { setTimeout: setTimeout2, setInterval: setInterval2, clearTimeout: clearTimeout2, clearInterval: clearInterval2 } = getSafeTimers();
6523
- const { interval = 50, timeout = 1e3 } = typeof options === "number" ? { timeout: options } : options;
6524
- const STACK_TRACE_ERROR = new Error("STACK_TRACE_ERROR");
6525
- return new Promise((resolve, reject) => {
6526
- let promiseStatus = "idle";
6527
- let timeoutId;
6528
- let intervalId;
6529
- const onReject = (error) => {
6530
- if (intervalId) {
6531
- clearInterval2(intervalId);
6532
- }
6533
- if (!error) {
6534
- error = copyStackTrace2(
6535
- new Error("Timed out in waitUntil!"),
6536
- STACK_TRACE_ERROR
6537
- );
6538
- }
6539
- reject(error);
6540
- };
6541
- const onResolve = (result) => {
6542
- if (!result) {
6543
- return;
6544
- }
6545
- if (timeoutId) {
6546
- clearTimeout2(timeoutId);
6547
- }
6548
- if (intervalId) {
6549
- clearInterval2(intervalId);
6550
- }
6551
- resolve(result);
6552
- return true;
6553
- };
6554
- const checkCallback = () => {
6555
- if (vi.isFakeTimers()) {
6556
- vi.advanceTimersByTime(interval);
6557
- }
6558
- if (promiseStatus === "pending") {
6559
- return;
6560
- }
6561
- try {
6562
- const result = callback();
6563
- if (result !== null && typeof result === "object" && typeof result.then === "function") {
6564
- const thenable = result;
6565
- promiseStatus = "pending";
6566
- thenable.then(
6567
- (resolvedValue) => {
6568
- promiseStatus = "resolved";
6569
- onResolve(resolvedValue);
6570
- },
6571
- (rejectedValue) => {
6572
- promiseStatus = "rejected";
6573
- onReject(rejectedValue);
6574
- }
6575
- );
6576
- } else {
6577
- return onResolve(result);
6578
- }
6579
- } catch (error) {
6580
- onReject(error);
6581
- }
6582
- };
6583
- if (checkCallback() === true) {
6584
- return;
6585
- }
6586
- timeoutId = setTimeout2(onReject, timeout);
6587
- intervalId = setInterval2(checkCallback, interval);
6588
- });
6589
- }
6590
- function createVitest() {
6591
- let _mockedDate = null;
6592
- let _config = null;
6593
- const workerState = getWorkerState();
6594
- let _timers;
6595
- const timers = () => _timers ||= new FakeTimers({
6596
- global: globalThis,
6597
- config: workerState.config.fakeTimers
6598
- });
6599
- const _stubsGlobal = /* @__PURE__ */ new Map();
6600
- const _stubsEnv = /* @__PURE__ */ new Map();
6601
- const _envBooleans = ["PROD", "DEV", "SSR"];
6602
- const utils = {
6603
- useFakeTimers(config2) {
6604
- if (isChildProcess()) {
6605
- if (config2?.toFake?.includes("nextTick") || workerState.config?.fakeTimers?.toFake?.includes("nextTick")) {
6606
- throw new Error(
6607
- 'vi.useFakeTimers({ toFake: ["nextTick"] }) is not supported in node:child_process. Use --pool=threads if mocking nextTick is required.'
6608
- );
6609
- }
6610
- }
6611
- if (config2) {
6612
- timers().configure({ ...workerState.config.fakeTimers, ...config2 });
6613
- } else {
6614
- timers().configure(workerState.config.fakeTimers);
6615
- }
6616
- timers().useFakeTimers();
6617
- return utils;
6618
- },
6619
- isFakeTimers() {
6620
- return timers().isFakeTimers();
6621
- },
6622
- useRealTimers() {
6623
- timers().useRealTimers();
6624
- _mockedDate = null;
6625
- return utils;
6626
- },
6627
- runOnlyPendingTimers() {
6628
- timers().runOnlyPendingTimers();
6629
- return utils;
6630
- },
6631
- async runOnlyPendingTimersAsync() {
6632
- await timers().runOnlyPendingTimersAsync();
6633
- return utils;
6634
- },
6635
- runAllTimers() {
6636
- timers().runAllTimers();
6637
- return utils;
6638
- },
6639
- async runAllTimersAsync() {
6640
- await timers().runAllTimersAsync();
6641
- return utils;
6642
- },
6643
- runAllTicks() {
6644
- timers().runAllTicks();
6645
- return utils;
6646
- },
6647
- advanceTimersByTime(ms) {
6648
- timers().advanceTimersByTime(ms);
6649
- return utils;
6650
- },
6651
- async advanceTimersByTimeAsync(ms) {
6652
- await timers().advanceTimersByTimeAsync(ms);
6653
- return utils;
6654
- },
6655
- advanceTimersToNextTimer() {
6656
- timers().advanceTimersToNextTimer();
6657
- return utils;
6658
- },
6659
- async advanceTimersToNextTimerAsync() {
6660
- await timers().advanceTimersToNextTimerAsync();
6661
- return utils;
6662
- },
6663
- advanceTimersToNextFrame() {
6664
- timers().advanceTimersToNextFrame();
6665
- return utils;
6666
- },
6667
- getTimerCount() {
6668
- return timers().getTimerCount();
6669
- },
6670
- setSystemTime(time) {
6671
- const date = time instanceof Date ? time : new Date(time);
6672
- _mockedDate = date;
6673
- timers().setSystemTime(date);
6674
- return utils;
6675
- },
6676
- getMockedSystemTime() {
6677
- return _mockedDate;
6678
- },
6679
- getRealSystemTime() {
6680
- return timers().getRealSystemTime();
6681
- },
6682
- clearAllTimers() {
6683
- timers().clearAllTimers();
6684
- return utils;
6685
- },
6686
- // mocks
6687
- spyOn,
6688
- fn,
6689
- waitFor: waitFor2,
6690
- waitUntil,
6691
- hoisted(factory) {
6692
- assertTypes(factory, '"vi.hoisted" factory', ["function"]);
6693
- return factory();
6694
- },
6695
- mock(path, factory) {
6696
- if (typeof path !== "string") {
6697
- throw new TypeError(
6698
- `vi.mock() expects a string path, but received a ${typeof path}`
6699
- );
6700
- }
6701
- const importer = getImporter("mock");
6702
- _mocker().queueMock(
6703
- path,
6704
- importer,
6705
- typeof factory === "function" ? () => factory(
6706
- () => _mocker().importActual(
6707
- path,
6708
- importer,
6709
- _mocker().getMockContext().callstack
6710
- )
6711
- ) : factory
6712
- );
6713
- },
6714
- unmock(path) {
6715
- if (typeof path !== "string") {
6716
- throw new TypeError(
6717
- `vi.unmock() expects a string path, but received a ${typeof path}`
6718
- );
6719
- }
6720
- _mocker().queueUnmock(path, getImporter("unmock"));
6721
- },
6722
- doMock(path, factory) {
6723
- if (typeof path !== "string") {
6724
- throw new TypeError(
6725
- `vi.doMock() expects a string path, but received a ${typeof path}`
6726
- );
6727
- }
6728
- const importer = getImporter("doMock");
6729
- _mocker().queueMock(
6730
- path,
6731
- importer,
6732
- typeof factory === "function" ? () => factory(
6733
- () => _mocker().importActual(
6734
- path,
6735
- importer,
6736
- _mocker().getMockContext().callstack
6737
- )
6738
- ) : factory
6739
- );
6740
- },
6741
- doUnmock(path) {
6742
- if (typeof path !== "string") {
6743
- throw new TypeError(
6744
- `vi.doUnmock() expects a string path, but received a ${typeof path}`
6745
- );
6746
- }
6747
- _mocker().queueUnmock(path, getImporter("doUnmock"));
6748
- },
6749
- async importActual(path) {
6750
- return _mocker().importActual(
6751
- path,
6752
- getImporter("importActual"),
6753
- _mocker().getMockContext().callstack
6754
- );
6755
- },
6756
- async importMock(path) {
6757
- return _mocker().importMock(path, getImporter("importMock"));
6758
- },
6759
- // this is typed in the interface so it's not necessary to type it here
6760
- mocked(item, _options = {}) {
6761
- return item;
6762
- },
6763
- isMockFunction(fn2) {
6764
- return isMockFunction(fn2);
6765
- },
6766
- clearAllMocks() {
6767
- mocks.forEach((spy) => spy.mockClear());
6768
- return utils;
6769
- },
6770
- resetAllMocks() {
6771
- mocks.forEach((spy) => spy.mockReset());
6772
- return utils;
6773
- },
6774
- restoreAllMocks() {
6775
- mocks.forEach((spy) => spy.mockRestore());
6776
- return utils;
6777
- },
6778
- stubGlobal(name, value) {
6779
- if (!_stubsGlobal.has(name)) {
6780
- _stubsGlobal.set(
6781
- name,
6782
- Object.getOwnPropertyDescriptor(globalThis, name)
6783
- );
6784
- }
6785
- Object.defineProperty(globalThis, name, {
6786
- value,
6787
- writable: true,
6788
- configurable: true,
6789
- enumerable: true
6790
- });
6791
- return utils;
6792
- },
6793
- stubEnv(name, value) {
6794
- if (!_stubsEnv.has(name)) {
6795
- _stubsEnv.set(name, process.env[name]);
6796
- }
6797
- if (_envBooleans.includes(name)) {
6798
- process.env[name] = value ? "1" : "";
6799
- } else if (value === void 0) {
6800
- delete process.env[name];
6801
- } else {
6802
- process.env[name] = String(value);
6803
- }
6804
- return utils;
6805
- },
6806
- unstubAllGlobals() {
6807
- _stubsGlobal.forEach((original, name) => {
6808
- if (!original) {
6809
- Reflect.deleteProperty(globalThis, name);
6810
- } else {
6811
- Object.defineProperty(globalThis, name, original);
6812
- }
6813
- });
6814
- _stubsGlobal.clear();
6815
- return utils;
6816
- },
6817
- unstubAllEnvs() {
6818
- _stubsEnv.forEach((original, name) => {
6819
- if (original === void 0) {
6820
- delete process.env[name];
6821
- } else {
6822
- process.env[name] = original;
6823
- }
6824
- });
6825
- _stubsEnv.clear();
6826
- return utils;
6827
- },
6828
- resetModules() {
6829
- resetModules(workerState.moduleCache);
6830
- return utils;
6831
- },
6832
- async dynamicImportSettled() {
6833
- return waitForImportsToResolve();
6834
- },
6835
- setConfig(config2) {
6836
- if (!_config) {
6837
- _config = { ...workerState.config };
6838
- }
6839
- Object.assign(workerState.config, config2);
6840
- },
6841
- resetConfig() {
6842
- if (_config) {
6843
- Object.assign(workerState.config, _config);
6844
- }
6845
- }
6846
- };
6847
- return utils;
6848
- }
6849
- var vitest = createVitest();
6850
- var vi = vitest;
6851
- function _mocker() {
6852
- return typeof __vitest_mocker__ !== "undefined" ? __vitest_mocker__ : new Proxy(
6853
- {},
6854
- {
6855
- get(_, name) {
6856
- throw new Error(
6857
- `Vitest mocker was not initialized in this environment. vi.${String(name)}() is forbidden.`
6858
- );
6859
- }
6860
- }
6861
- );
6348
+ requireFakeTimersSrc();
6349
+ typeof process < "u" && process.platform === "win32";
6350
+ var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
6351
+ var intToChar = new Uint8Array(64);
6352
+ var charToInt = new Uint8Array(128);
6353
+ for (let i = 0; i < chars.length; i++) {
6354
+ let c = chars.charCodeAt(i);
6355
+ intToChar[i] = c, charToInt[c] = i;
6862
6356
  }
6863
- function getImporter(name) {
6864
- const stackTrace = createSimpleStackTrace({ stackTraceLimit: 5 });
6865
- const stackArray = stackTrace.split("\n");
6866
- const importerStackIndex = stackArray.findIndex((stack2) => {
6867
- return stack2.includes(` at Object.${name}`) || stack2.includes(`${name}@`);
6868
- });
6869
- const stack = parseSingleStack(stackArray[importerStackIndex + 1]);
6870
- return stack?.file || "";
6357
+ var customizationHookNamespace = "vite-module-runner:import-meta-resolve/v1/";
6358
+ `
6359
+
6360
+ export async function resolve(specifier, context, nextResolve) {
6361
+ if (specifier.startsWith(${JSON.stringify(customizationHookNamespace)})) {
6362
+ const data = specifier.slice(${JSON.stringify(customizationHookNamespace)}.length)
6363
+ const [parsedSpecifier, parsedImporter] = JSON.parse(data)
6364
+ specifier = parsedSpecifier
6365
+ context.parentURL = parsedImporter
6366
+ }
6367
+ return nextResolve(specifier, context)
6871
6368
  }
6872
6369
 
6370
+ `;
6371
+ new Proxy({}, { get(_, p) {
6372
+ throw Error(`[module runner] Dynamic access of "import.meta.env" is not supported. Please, use "import.meta.env.${String(p)}" instead.`);
6373
+ } });
6374
+
6873
6375
  // src/test/setup.ts
6874
6376
  globalExpect.extend(matchers_exports);
6875
6377
  afterEach$1(() => {