@shware/security 2.2.0 → 2.2.2

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.
@@ -5,7 +5,7 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __getProtoOf = Object.getPrototypeOf;
6
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
7
  var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
8
- get: (a3, b4) => (typeof require !== "undefined" ? require : a3)[b4]
8
+ get: (a4, b4) => (typeof require !== "undefined" ? require : a4)[b4]
9
9
  }) : x)(function(x) {
10
10
  if (typeof require !== "undefined") return require.apply(this, arguments);
11
11
  throw Error('Dynamic require of "' + x + '" is not supported');
@@ -113,12 +113,12 @@ var require_dist = __commonJS({
113
113
  // src/session/__tests__/redis.test.ts
114
114
  import Redis from "ioredis";
115
115
 
116
- // ../../node_modules/.pnpm/vitest@4.0.18_@types+node@25.3.0_jiti@2.6.1_lightningcss@1.30.2_terser@5.44.1_yaml@2.8.2/node_modules/vitest/dist/index.js
116
+ // ../../node_modules/.pnpm/vitest@4.1.0_@opentelemetry+api@1.9.0_@types+node@25.3.0_vite@7.3.1_@types+node@25.3.0__1256cd9683254972294f67b42fe9fd18/node_modules/vitest/dist/index.js
117
117
  var import_expect_type = __toESM(require_dist(), 1);
118
- import { b as b2, c as c2, g as g3, i as i2, s as s2, v, d as d3 } from "./chunks/vi.2VT5v0um.js.mjs";
119
- import { b as b3 } from "./chunks/benchmark.B3N2zMcH.js.mjs";
118
+ import { N, T, a as a2, c as c2, g as g3, i as i2, s as s2, v as v2, b as b2 } from "./chunks/test.CTcmp4Su.js.mjs";
119
+ import { b as b3 } from "./chunks/benchmark.D0SlKNbZ.js.mjs";
120
120
  import { V } from "./chunks/evaluatedModules.Dg1zASAC.js.mjs";
121
- import { a as a2 } from "./chunks/index.Z5E_ObnR.js.mjs";
121
+ import { a as a3 } from "./chunks/index.DlDSLQD3.js.mjs";
122
122
 
123
123
  // ../../node_modules/.pnpm/tinyrainbow@3.0.3/node_modules/tinyrainbow/dist/index.js
124
124
  var d = {
@@ -170,20 +170,20 @@ function g(e2) {
170
170
  g.open = "";
171
171
  g.close = "";
172
172
  function h() {
173
- let e2 = typeof process != "undefined" ? process : void 0, n2 = (e2 == null ? void 0 : e2.env) || {}, a3 = n2.FORCE_TTY !== "false", i3 = (e2 == null ? void 0 : e2.argv) || [];
174
- return !("NO_COLOR" in n2 || i3.includes("--no-color")) && ("FORCE_COLOR" in n2 || i3.includes("--color") || (e2 == null ? void 0 : e2.platform) === "win32" || a3 && n2.TERM !== "dumb" || "CI" in n2) || typeof window != "undefined" && !!window.chrome;
173
+ let e2 = typeof process != "undefined" ? process : void 0, n2 = (e2 == null ? void 0 : e2.env) || {}, a4 = n2.FORCE_TTY !== "false", i3 = (e2 == null ? void 0 : e2.argv) || [];
174
+ return !("NO_COLOR" in n2 || i3.includes("--no-color")) && ("FORCE_COLOR" in n2 || i3.includes("--color") || (e2 == null ? void 0 : e2.platform) === "win32" || a4 && n2.TERM !== "dumb" || "CI" in n2) || typeof window != "undefined" && !!window.chrome;
175
175
  }
176
176
  function f() {
177
- let e2 = h(), n2 = (r2, t2, u, o2) => {
177
+ let e2 = h(), n2 = (r2, t2, u2, o2) => {
178
178
  let l2 = "", s3 = 0;
179
179
  do
180
- l2 += r2.substring(s3, o2) + u, s3 = o2 + t2.length, o2 = r2.indexOf(t2, s3);
180
+ l2 += r2.substring(s3, o2) + u2, s3 = o2 + t2.length, o2 = r2.indexOf(t2, s3);
181
181
  while (~o2);
182
182
  return l2 + r2.substring(s3);
183
- }, a3 = (r2, t2, u = r2) => {
183
+ }, a4 = (r2, t2, u2 = r2) => {
184
184
  let o2 = (l2) => {
185
185
  let s3 = String(l2), b4 = s3.indexOf(t2, r2.length);
186
- return ~b4 ? r2 + n2(s3, t2, u, b4) + t2 : r2 + s3 + t2;
186
+ return ~b4 ? r2 + n2(s3, t2, u2, b4) + t2 : r2 + s3 + t2;
187
187
  };
188
188
  return o2.open = r2, o2.close = t2, o2;
189
189
  }, i3 = {
@@ -191,7 +191,7 @@ function f() {
191
191
  }, c3 = (r2) => `\x1B[${r2}m`;
192
192
  for (let r2 in d) {
193
193
  let t2 = d[r2];
194
- i3[r2] = e2 ? a3(
194
+ i3[r2] = e2 ? a4(
195
195
  c3(t2[0]),
196
196
  c3(t2[1]),
197
197
  t2[2]
@@ -201,13 +201,13 @@ function f() {
201
201
  }
202
202
  var C = f();
203
203
 
204
- // ../../node_modules/.pnpm/@vitest+pretty-format@4.0.18/node_modules/@vitest/pretty-format/dist/index.js
204
+ // ../../node_modules/.pnpm/@vitest+pretty-format@4.1.0/node_modules/@vitest/pretty-format/dist/index.js
205
205
  function _mergeNamespaces(n2, m2) {
206
206
  m2.forEach(function(e2) {
207
207
  e2 && typeof e2 !== "string" && !Array.isArray(e2) && Object.keys(e2).forEach(function(k2) {
208
208
  if (k2 !== "default" && !(k2 in n2)) {
209
- var d4 = Object.getOwnPropertyDescriptor(e2, k2);
210
- Object.defineProperty(n2, k2, d4.get ? d4 : {
209
+ var d3 = Object.getOwnPropertyDescriptor(e2, k2);
210
+ Object.defineProperty(n2, k2, d3.get ? d3 : {
211
211
  enumerable: true,
212
212
  get: function() {
213
213
  return e2[k2];
@@ -460,7 +460,20 @@ function nodeIsComment(node) {
460
460
  function nodeIsFragment(node) {
461
461
  return node.nodeType === FRAGMENT_NODE;
462
462
  }
463
- var serialize$3 = (node, config, indentation, depth, refs, printer2) => {
463
+ function filterChildren(children, filterNode) {
464
+ let filtered = children.filter((node) => {
465
+ if (node.nodeType === TEXT_NODE) {
466
+ const text = node.data || "";
467
+ return text.trim().length > 0;
468
+ }
469
+ return true;
470
+ });
471
+ if (filterNode) {
472
+ filtered = filtered.filter(filterNode);
473
+ }
474
+ return filtered;
475
+ }
476
+ function serializeDOM(node, config, indentation, depth, refs, printer2, filterNode) {
464
477
  if (nodeIsText(node)) {
465
478
  return printText(node.data, config);
466
479
  }
@@ -471,11 +484,22 @@ var serialize$3 = (node, config, indentation, depth, refs, printer2) => {
471
484
  if (++depth > config.maxDepth) {
472
485
  return printElementAsLeaf(type, config);
473
486
  }
487
+ const children = Array.prototype.slice.call(node.childNodes || node.children);
488
+ const shadowChildren = nodeIsFragment(node) || !node.shadowRoot ? [] : Array.prototype.slice.call(node.shadowRoot.children);
489
+ const resolvedChildren = filterNode ? filterChildren(children, filterNode) : children;
490
+ const resolvedShadowChildren = filterNode ? filterChildren(shadowChildren, filterNode) : shadowChildren;
474
491
  return printElement(type, printProps(nodeIsFragment(node) ? [] : Array.from(node.attributes, (attr) => attr.name).sort(), nodeIsFragment(node) ? {} : [...node.attributes].reduce((props, attribute) => {
475
492
  props[attribute.name] = attribute.value;
476
493
  return props;
477
- }, {}), config, indentation + config.indent, depth, refs, printer2), (nodeIsFragment(node) || !node.shadowRoot ? "" : printShadowRoot(Array.prototype.slice.call(node.shadowRoot.children), config, indentation + config.indent, depth, refs, printer2)) + printChildren(Array.prototype.slice.call(node.childNodes || node.children), config, indentation + config.indent, depth, refs, printer2), config, indentation);
478
- };
494
+ }, {}), config, indentation + config.indent, depth, refs, printer2), (resolvedShadowChildren.length > 0 ? printShadowRoot(resolvedShadowChildren, config, indentation + config.indent, depth, refs, printer2) : "") + printChildren(resolvedChildren, config, indentation + config.indent, depth, refs, printer2), config, indentation);
495
+ }
496
+ var serialize$3 = (node, config, indentation, depth, refs, printer2) => serializeDOM(node, config, indentation, depth, refs, printer2);
497
+ function createDOMElementFilter(filterNode) {
498
+ return {
499
+ test: test$3,
500
+ serialize: (node, config, indentation, depth, refs, printer2) => serializeDOM(node, config, indentation, depth, refs, printer2, filterNode)
501
+ };
502
+ }
479
503
  var plugin$3 = {
480
504
  serialize: serialize$3,
481
505
  test: test$3
@@ -668,29 +692,29 @@ var hasRequiredReactIs_production_min;
668
692
  function requireReactIs_production_min() {
669
693
  if (hasRequiredReactIs_production_min) return reactIs_production_min;
670
694
  hasRequiredReactIs_production_min = 1;
671
- var b4 = /* @__PURE__ */ Symbol.for("react.element"), c3 = /* @__PURE__ */ Symbol.for("react.portal"), d4 = /* @__PURE__ */ Symbol.for("react.fragment"), e2 = /* @__PURE__ */ Symbol.for("react.strict_mode"), f3 = /* @__PURE__ */ Symbol.for("react.profiler"), g4 = /* @__PURE__ */ Symbol.for("react.provider"), h3 = /* @__PURE__ */ Symbol.for("react.context"), k2 = /* @__PURE__ */ Symbol.for("react.server_context"), l2 = /* @__PURE__ */ Symbol.for("react.forward_ref"), m2 = /* @__PURE__ */ Symbol.for("react.suspense"), n2 = /* @__PURE__ */ Symbol.for("react.suspense_list"), p2 = /* @__PURE__ */ Symbol.for("react.memo"), q2 = /* @__PURE__ */ Symbol.for("react.lazy"), t2 = /* @__PURE__ */ Symbol.for("react.offscreen"), u;
672
- u = /* @__PURE__ */ Symbol.for("react.module.reference");
673
- function v2(a3) {
674
- if ("object" === typeof a3 && null !== a3) {
675
- var r2 = a3.$$typeof;
695
+ var b4 = /* @__PURE__ */ Symbol.for("react.element"), c3 = /* @__PURE__ */ Symbol.for("react.portal"), d3 = /* @__PURE__ */ Symbol.for("react.fragment"), e2 = /* @__PURE__ */ Symbol.for("react.strict_mode"), f3 = /* @__PURE__ */ Symbol.for("react.profiler"), g4 = /* @__PURE__ */ Symbol.for("react.provider"), h3 = /* @__PURE__ */ Symbol.for("react.context"), k2 = /* @__PURE__ */ Symbol.for("react.server_context"), l2 = /* @__PURE__ */ Symbol.for("react.forward_ref"), m2 = /* @__PURE__ */ Symbol.for("react.suspense"), n2 = /* @__PURE__ */ Symbol.for("react.suspense_list"), p2 = /* @__PURE__ */ Symbol.for("react.memo"), q2 = /* @__PURE__ */ Symbol.for("react.lazy"), t2 = /* @__PURE__ */ Symbol.for("react.offscreen"), u2;
696
+ u2 = /* @__PURE__ */ Symbol.for("react.module.reference");
697
+ function v3(a4) {
698
+ if ("object" === typeof a4 && null !== a4) {
699
+ var r2 = a4.$$typeof;
676
700
  switch (r2) {
677
701
  case b4:
678
- switch (a3 = a3.type, a3) {
679
- case d4:
702
+ switch (a4 = a4.type, a4) {
703
+ case d3:
680
704
  case f3:
681
705
  case e2:
682
706
  case m2:
683
707
  case n2:
684
- return a3;
708
+ return a4;
685
709
  default:
686
- switch (a3 = a3 && a3.$$typeof, a3) {
710
+ switch (a4 = a4 && a4.$$typeof, a4) {
687
711
  case k2:
688
712
  case h3:
689
713
  case l2:
690
714
  case q2:
691
715
  case p2:
692
716
  case g4:
693
- return a3;
717
+ return a4;
694
718
  default:
695
719
  return r2;
696
720
  }
@@ -704,7 +728,7 @@ function requireReactIs_production_min() {
704
728
  reactIs_production_min.ContextProvider = g4;
705
729
  reactIs_production_min.Element = b4;
706
730
  reactIs_production_min.ForwardRef = l2;
707
- reactIs_production_min.Fragment = d4;
731
+ reactIs_production_min.Fragment = d3;
708
732
  reactIs_production_min.Lazy = q2;
709
733
  reactIs_production_min.Memo = p2;
710
734
  reactIs_production_min.Portal = c3;
@@ -718,46 +742,46 @@ function requireReactIs_production_min() {
718
742
  reactIs_production_min.isConcurrentMode = function() {
719
743
  return false;
720
744
  };
721
- reactIs_production_min.isContextConsumer = function(a3) {
722
- return v2(a3) === h3;
745
+ reactIs_production_min.isContextConsumer = function(a4) {
746
+ return v3(a4) === h3;
723
747
  };
724
- reactIs_production_min.isContextProvider = function(a3) {
725
- return v2(a3) === g4;
748
+ reactIs_production_min.isContextProvider = function(a4) {
749
+ return v3(a4) === g4;
726
750
  };
727
- reactIs_production_min.isElement = function(a3) {
728
- return "object" === typeof a3 && null !== a3 && a3.$$typeof === b4;
751
+ reactIs_production_min.isElement = function(a4) {
752
+ return "object" === typeof a4 && null !== a4 && a4.$$typeof === b4;
729
753
  };
730
- reactIs_production_min.isForwardRef = function(a3) {
731
- return v2(a3) === l2;
754
+ reactIs_production_min.isForwardRef = function(a4) {
755
+ return v3(a4) === l2;
732
756
  };
733
- reactIs_production_min.isFragment = function(a3) {
734
- return v2(a3) === d4;
757
+ reactIs_production_min.isFragment = function(a4) {
758
+ return v3(a4) === d3;
735
759
  };
736
- reactIs_production_min.isLazy = function(a3) {
737
- return v2(a3) === q2;
760
+ reactIs_production_min.isLazy = function(a4) {
761
+ return v3(a4) === q2;
738
762
  };
739
- reactIs_production_min.isMemo = function(a3) {
740
- return v2(a3) === p2;
763
+ reactIs_production_min.isMemo = function(a4) {
764
+ return v3(a4) === p2;
741
765
  };
742
- reactIs_production_min.isPortal = function(a3) {
743
- return v2(a3) === c3;
766
+ reactIs_production_min.isPortal = function(a4) {
767
+ return v3(a4) === c3;
744
768
  };
745
- reactIs_production_min.isProfiler = function(a3) {
746
- return v2(a3) === f3;
769
+ reactIs_production_min.isProfiler = function(a4) {
770
+ return v3(a4) === f3;
747
771
  };
748
- reactIs_production_min.isStrictMode = function(a3) {
749
- return v2(a3) === e2;
772
+ reactIs_production_min.isStrictMode = function(a4) {
773
+ return v3(a4) === e2;
750
774
  };
751
- reactIs_production_min.isSuspense = function(a3) {
752
- return v2(a3) === m2;
775
+ reactIs_production_min.isSuspense = function(a4) {
776
+ return v3(a4) === m2;
753
777
  };
754
- reactIs_production_min.isSuspenseList = function(a3) {
755
- return v2(a3) === n2;
778
+ reactIs_production_min.isSuspenseList = function(a4) {
779
+ return v3(a4) === n2;
756
780
  };
757
- reactIs_production_min.isValidElementType = function(a3) {
758
- return "string" === typeof a3 || "function" === typeof a3 || a3 === d4 || a3 === f3 || a3 === e2 || a3 === m2 || a3 === n2 || a3 === t2 || "object" === typeof a3 && null !== a3 && (a3.$$typeof === q2 || a3.$$typeof === p2 || a3.$$typeof === g4 || a3.$$typeof === h3 || a3.$$typeof === l2 || a3.$$typeof === u || void 0 !== a3.getModuleId) ? true : false;
781
+ reactIs_production_min.isValidElementType = function(a4) {
782
+ return "string" === typeof a4 || "function" === typeof a4 || a4 === d3 || a4 === f3 || a4 === e2 || a4 === m2 || a4 === n2 || a4 === t2 || "object" === typeof a4 && null !== a4 && (a4.$$typeof === q2 || a4.$$typeof === p2 || a4.$$typeof === g4 || a4.$$typeof === h3 || a4.$$typeof === l2 || a4.$$typeof === u2 || void 0 !== a4.getModuleId) ? true : false;
759
783
  };
760
- reactIs_production_min.typeOf = v2;
784
+ reactIs_production_min.typeOf = v3;
761
785
  return reactIs_production_min;
762
786
  }
763
787
  var hasRequiredReactIs;
@@ -792,7 +816,7 @@ var reactIsMethods = [
792
816
  "isSuspenseList",
793
817
  "isValidElementType"
794
818
  ];
795
- var ReactIs = Object.fromEntries(reactIsMethods.map((m2) => [m2, (v2) => ReactIs18[m2](v2) || ReactIs19[m2](v2)]));
819
+ var ReactIs = Object.fromEntries(reactIsMethods.map((m2) => [m2, (v3) => ReactIs18[m2](v3) || ReactIs19[m2](v3)]));
796
820
  function getChildren(arg, children = []) {
797
821
  if (Array.isArray(arg)) {
798
822
  for (const item of arg) {
@@ -1161,7 +1185,7 @@ var plugins = {
1161
1185
  Error: ErrorPlugin
1162
1186
  };
1163
1187
 
1164
- // ../../node_modules/.pnpm/@vitest+utils@4.0.18/node_modules/@vitest/utils/dist/helpers.js
1188
+ // ../../node_modules/.pnpm/@vitest+utils@4.1.0/node_modules/@vitest/utils/dist/helpers.js
1165
1189
  import { VALID_ID_PREFIX, NULL_BYTE_PLACEHOLDER } from "./constants.js.mjs";
1166
1190
  function assertTypes(value, name, types) {
1167
1191
  const receivedType = typeof value;
@@ -1170,6 +1194,31 @@ function assertTypes(value, name, types) {
1170
1194
  throw new TypeError(`${name} value must be ${types.join(" or ")}, received "${receivedType}"`);
1171
1195
  }
1172
1196
  }
1197
+ function filterOutComments(s3) {
1198
+ const result = [];
1199
+ let commentState = "none";
1200
+ for (let i3 = 0; i3 < s3.length; ++i3) {
1201
+ if (commentState === "singleline") {
1202
+ if (s3[i3] === "\n") {
1203
+ commentState = "none";
1204
+ }
1205
+ } else if (commentState === "multiline") {
1206
+ if (s3[i3 - 1] === "*" && s3[i3] === "/") {
1207
+ commentState = "none";
1208
+ }
1209
+ } else if (commentState === "none") {
1210
+ if (s3[i3] === "/" && s3[i3 + 1] === "/") {
1211
+ commentState = "singleline";
1212
+ } else if (s3[i3] === "/" && s3[i3 + 1] === "*") {
1213
+ commentState = "multiline";
1214
+ i3 += 2;
1215
+ } else {
1216
+ result.push(s3[i3]);
1217
+ }
1218
+ }
1219
+ }
1220
+ return result.join("");
1221
+ }
1173
1222
  function toArray(array) {
1174
1223
  if (array === null || array === void 0) {
1175
1224
  array = [];
@@ -1214,8 +1263,25 @@ function isNegativeNaN(val) {
1214
1263
  const isNegative = u32[1] >>> 31 === 1;
1215
1264
  return isNegative;
1216
1265
  }
1266
+ function ordinal(i3) {
1267
+ const j2 = i3 % 10;
1268
+ const k2 = i3 % 100;
1269
+ if (j2 === 1 && k2 !== 11) {
1270
+ return `${i3}st`;
1271
+ }
1272
+ if (j2 === 2 && k2 !== 12) {
1273
+ return `${i3}nd`;
1274
+ }
1275
+ if (j2 === 3 && k2 !== 13) {
1276
+ return `${i3}rd`;
1277
+ }
1278
+ return `${i3}th`;
1279
+ }
1280
+ function unique(array) {
1281
+ return Array.from(new Set(array));
1282
+ }
1217
1283
 
1218
- // ../../node_modules/.pnpm/@vitest+utils@4.0.18/node_modules/@vitest/utils/dist/timers.js
1284
+ // ../../node_modules/.pnpm/@vitest+utils@4.1.0/node_modules/@vitest/utils/dist/timers.js
1219
1285
  var SAFE_TIMERS_SYMBOL = /* @__PURE__ */ Symbol("vitest:SAFE_TIMERS");
1220
1286
  function getSafeTimers() {
1221
1287
  const { setTimeout: safeSetTimeout, setInterval: safeSetInterval, clearInterval: safeClearInterval, clearTimeout: safeClearTimeout, setImmediate: safeSetImmediate, clearImmediate: safeClearImmediate, queueMicrotask: safeQueueMicrotask } = globalThis[SAFE_TIMERS_SYMBOL] || globalThis;
@@ -1232,7 +1298,7 @@ function getSafeTimers() {
1232
1298
  };
1233
1299
  }
1234
1300
 
1235
- // ../../node_modules/.pnpm/@vitest+utils@4.0.18/node_modules/@vitest/utils/dist/display.js
1301
+ // ../../node_modules/.pnpm/@vitest+utils@4.1.0/node_modules/@vitest/utils/dist/display.js
1236
1302
  var ansiColors = {
1237
1303
  bold: ["1", "22"],
1238
1304
  dim: ["2", "22"],
@@ -1759,14 +1825,23 @@ var PLUGINS = [
1759
1825
  Immutable,
1760
1826
  AsymmetricMatcher
1761
1827
  ];
1762
- function stringify(object, maxDepth = 10, { maxLength, ...options } = {}) {
1828
+ function stringify(object, maxDepth = 10, { maxLength, filterNode, ...options } = {}) {
1763
1829
  const MAX_LENGTH = maxLength ?? 1e4;
1764
1830
  let result;
1831
+ const filterFn = typeof filterNode === "string" ? createNodeFilterFromSelector(filterNode) : filterNode;
1832
+ const plugins2 = filterFn ? [
1833
+ ReactTestComponent,
1834
+ ReactElement,
1835
+ createDOMElementFilter(filterFn),
1836
+ DOMCollection,
1837
+ Immutable,
1838
+ AsymmetricMatcher
1839
+ ] : PLUGINS;
1765
1840
  try {
1766
1841
  result = format(object, {
1767
1842
  maxDepth,
1768
1843
  escapeString: false,
1769
- plugins: PLUGINS,
1844
+ plugins: plugins2,
1770
1845
  ...options
1771
1846
  });
1772
1847
  } catch {
@@ -1774,15 +1849,33 @@ function stringify(object, maxDepth = 10, { maxLength, ...options } = {}) {
1774
1849
  callToJSON: false,
1775
1850
  maxDepth,
1776
1851
  escapeString: false,
1777
- plugins: PLUGINS,
1852
+ plugins: plugins2,
1778
1853
  ...options
1779
1854
  });
1780
1855
  }
1781
1856
  return result.length >= MAX_LENGTH && maxDepth > 1 ? stringify(object, Math.floor(Math.min(maxDepth, Number.MAX_SAFE_INTEGER) / 2), {
1782
1857
  maxLength,
1858
+ filterNode,
1783
1859
  ...options
1784
1860
  }) : result;
1785
1861
  }
1862
+ function createNodeFilterFromSelector(selector) {
1863
+ const ELEMENT_NODE2 = 1;
1864
+ const COMMENT_NODE2 = 8;
1865
+ return (node) => {
1866
+ if (node.nodeType === COMMENT_NODE2) {
1867
+ return false;
1868
+ }
1869
+ if (node.nodeType === ELEMENT_NODE2 && node.matches) {
1870
+ try {
1871
+ return !node.matches(selector);
1872
+ } catch {
1873
+ return true;
1874
+ }
1875
+ }
1876
+ return true;
1877
+ };
1878
+ }
1786
1879
  var formatRegExp = /%[sdjifoOc%]/g;
1787
1880
  function baseFormat(args, options = {}) {
1788
1881
  const formatArg = (item, inspecOptions) => {
@@ -1839,6 +1932,9 @@ function baseFormat(args, options = {}) {
1839
1932
  if (typeof value === "bigint") {
1840
1933
  return `${value.toString()}n`;
1841
1934
  }
1935
+ if (typeof value === "symbol") {
1936
+ return "NaN";
1937
+ }
1842
1938
  return Number(value).toString();
1843
1939
  }
1844
1940
  case "%i": {
@@ -1877,7 +1973,7 @@ function baseFormat(args, options = {}) {
1877
1973
  });
1878
1974
  for (let x = args[i3]; i3 < len; x = args[++i3]) {
1879
1975
  if (x === null || typeof x !== "object") {
1880
- str += ` ${x}`;
1976
+ str += ` ${typeof x === "symbol" ? x.toString() : x}`;
1881
1977
  } else {
1882
1978
  str += ` ${formatArg(x)}`;
1883
1979
  }
@@ -1916,8 +2012,8 @@ function objDisplay(obj, options = {}) {
1916
2012
  return str;
1917
2013
  }
1918
2014
 
1919
- // ../../node_modules/.pnpm/@vitest+runner@4.0.18/node_modules/@vitest/runner/dist/index.js
1920
- import { c as createChainable, e as createTaskName, f as findTestFileStackTrace, b as createFileTask, a as calculateSuiteHash, s as someTasksAreOnly, i as interpretTaskModes, l as limitConcurrency, p as partitionSuiteChildren, r as hasTests, q as hasFailed } from "./chunk-tasks.js.mjs";
2015
+ // ../../node_modules/.pnpm/@vitest+runner@4.1.0/node_modules/@vitest/runner/dist/index.js
2016
+ import { w as getChainableContext, a as createChainable, v as validateTags, e as createTaskName, x as createNoTagsError, f as findTestFileStackTrace, d as createTagsFilter, b as createFileTask, c as calculateSuiteHash, u as someTasksAreOnly, q as interpretTaskModes, s as limitConcurrency, t as partitionSuiteChildren, p as hasTests, o as hasFailed } from "./chunk-tasks.js.mjs";
1921
2017
  var PendingError = class extends Error {
1922
2018
  code = "VITEST_PENDING";
1923
2019
  taskId;
@@ -1928,6 +2024,15 @@ var PendingError = class extends Error {
1928
2024
  this.taskId = task.id;
1929
2025
  }
1930
2026
  };
2027
+ var FixtureDependencyError = class extends Error {
2028
+ name = "FixtureDependencyError";
2029
+ };
2030
+ var FixtureAccessError = class extends Error {
2031
+ name = "FixtureAccessError";
2032
+ };
2033
+ var FixtureParseError = class extends Error {
2034
+ name = "FixtureParseError";
2035
+ };
1931
2036
  var fnMap = /* @__PURE__ */ new WeakMap();
1932
2037
  var testFixtureMap = /* @__PURE__ */ new WeakMap();
1933
2038
  var hooksMap = /* @__PURE__ */ new WeakMap();
@@ -1937,7 +2042,7 @@ function setFn(key, fn) {
1937
2042
  function setTestFixture(key, fixture) {
1938
2043
  testFixtureMap.set(key, fixture);
1939
2044
  }
1940
- function getTestFixture(key) {
2045
+ function getTestFixtures(key) {
1941
2046
  return testFixtureMap.get(key);
1942
2047
  }
1943
2048
  function setHooks(key, hooks) {
@@ -1946,165 +2051,290 @@ function setHooks(key, hooks) {
1946
2051
  function getHooks(key) {
1947
2052
  return hooksMap.get(key);
1948
2053
  }
1949
- function mergeScopedFixtures(testFixtures, scopedFixtures) {
1950
- const scopedFixturesMap = scopedFixtures.reduce((map, fixture) => {
1951
- map[fixture.prop] = fixture;
1952
- return map;
1953
- }, {});
1954
- const newFixtures = {};
1955
- testFixtures.forEach((fixture) => {
1956
- const useFixture = scopedFixturesMap[fixture.prop] || { ...fixture };
1957
- newFixtures[useFixture.prop] = useFixture;
1958
- });
1959
- for (const fixtureKep in newFixtures) {
1960
- var _fixture$deps;
1961
- const fixture = newFixtures[fixtureKep];
1962
- fixture.deps = (_fixture$deps = fixture.deps) === null || _fixture$deps === void 0 ? void 0 : _fixture$deps.map((dep) => newFixtures[dep.prop]);
1963
- }
1964
- return Object.values(newFixtures);
1965
- }
1966
- function mergeContextFixtures(fixtures, context, runner2) {
1967
- const fixtureOptionKeys = [
2054
+ var TestFixtures = class _TestFixtures {
2055
+ _suiteContexts;
2056
+ _overrides = /* @__PURE__ */ new WeakMap();
2057
+ _registrations;
2058
+ static _definitions = [];
2059
+ static _builtinFixtures = [
2060
+ "task",
2061
+ "signal",
2062
+ "onTestFailed",
2063
+ "onTestFinished",
2064
+ "skip",
2065
+ "annotate"
2066
+ ];
2067
+ static _fixtureOptionKeys = [
1968
2068
  "auto",
1969
2069
  "injected",
1970
2070
  "scope"
1971
2071
  ];
1972
- const fixtureArray = Object.entries(fixtures).map(([prop, value]) => {
1973
- const fixtureItem = { value };
1974
- if (Array.isArray(value) && value.length >= 2 && isObject(value[1]) && Object.keys(value[1]).some((key) => fixtureOptionKeys.includes(key))) {
1975
- var _runner$injectValue;
1976
- Object.assign(fixtureItem, value[1]);
1977
- const userValue = value[0];
1978
- fixtureItem.value = fixtureItem.injected ? ((_runner$injectValue = runner2.injectValue) === null || _runner$injectValue === void 0 ? void 0 : _runner$injectValue.call(runner2, prop)) ?? userValue : userValue;
1979
- }
1980
- fixtureItem.scope = fixtureItem.scope || "test";
1981
- if (fixtureItem.scope === "worker" && !runner2.getWorkerContext) {
1982
- fixtureItem.scope = "file";
1983
- }
1984
- fixtureItem.prop = prop;
1985
- fixtureItem.isFn = typeof fixtureItem.value === "function";
1986
- return fixtureItem;
1987
- });
1988
- if (Array.isArray(context.fixtures)) {
1989
- context.fixtures = context.fixtures.concat(fixtureArray);
1990
- } else {
1991
- context.fixtures = fixtureArray;
2072
+ static _fixtureScopes = [
2073
+ "test",
2074
+ "file",
2075
+ "worker"
2076
+ ];
2077
+ static _workerContextSuite = { type: "worker" };
2078
+ static clearDefinitions() {
2079
+ _TestFixtures._definitions.length = 0;
2080
+ }
2081
+ static getWorkerContexts() {
2082
+ return _TestFixtures._definitions.map((f3) => f3.getWorkerContext());
2083
+ }
2084
+ static getFileContexts(file) {
2085
+ return _TestFixtures._definitions.map((f3) => f3.getFileContext(file));
2086
+ }
2087
+ constructor(registrations) {
2088
+ this._registrations = registrations ?? /* @__PURE__ */ new Map();
2089
+ this._suiteContexts = /* @__PURE__ */ new WeakMap();
2090
+ _TestFixtures._definitions.push(this);
2091
+ }
2092
+ extend(runner2, userFixtures) {
2093
+ const { suite: suite2 } = getCurrentSuite();
2094
+ const isTopLevel = !suite2 || suite2.file === suite2;
2095
+ const registrations = this.parseUserFixtures(runner2, userFixtures, isTopLevel);
2096
+ return new _TestFixtures(registrations);
2097
+ }
2098
+ get(suite2) {
2099
+ let currentSuite = suite2;
2100
+ while (currentSuite) {
2101
+ const overrides = this._overrides.get(currentSuite);
2102
+ if (overrides) {
2103
+ return overrides;
2104
+ }
2105
+ if (currentSuite === currentSuite.file) {
2106
+ break;
2107
+ }
2108
+ currentSuite = currentSuite.suite || currentSuite.file;
2109
+ }
2110
+ return this._registrations;
2111
+ }
2112
+ override(runner2, userFixtures) {
2113
+ const { suite: currentSuite, file } = getCurrentSuite();
2114
+ const suite2 = currentSuite || file;
2115
+ const isTopLevel = !currentSuite || currentSuite.file === currentSuite;
2116
+ const suiteRegistrations = new Map(this.get(suite2));
2117
+ const registrations = this.parseUserFixtures(runner2, userFixtures, isTopLevel, suiteRegistrations);
2118
+ if (isTopLevel) {
2119
+ this._registrations = registrations;
2120
+ } else {
2121
+ this._overrides.set(suite2, registrations);
2122
+ }
2123
+ }
2124
+ getFileContext(file) {
2125
+ if (!this._suiteContexts.has(file)) {
2126
+ this._suiteContexts.set(file, /* @__PURE__ */ Object.create(null));
2127
+ }
2128
+ return this._suiteContexts.get(file);
2129
+ }
2130
+ getWorkerContext() {
2131
+ if (!this._suiteContexts.has(_TestFixtures._workerContextSuite)) {
2132
+ this._suiteContexts.set(_TestFixtures._workerContextSuite, /* @__PURE__ */ Object.create(null));
2133
+ }
2134
+ return this._suiteContexts.get(_TestFixtures._workerContextSuite);
1992
2135
  }
1993
- fixtureArray.forEach((fixture) => {
1994
- if (fixture.isFn) {
1995
- const usedProps = getUsedProps(fixture.value);
1996
- if (usedProps.length) {
1997
- fixture.deps = context.fixtures.filter(({ prop }) => prop !== fixture.prop && usedProps.includes(prop));
2136
+ parseUserFixtures(runner2, userFixtures, supportNonTest, registrations = new Map(this._registrations)) {
2137
+ const errors = [];
2138
+ Object.entries(userFixtures).forEach(([name, fn]) => {
2139
+ let options;
2140
+ let value;
2141
+ let _options;
2142
+ if (Array.isArray(fn) && fn.length >= 2 && isObject(fn[1]) && Object.keys(fn[1]).some((key) => _TestFixtures._fixtureOptionKeys.includes(key))) {
2143
+ _options = fn[1];
2144
+ options = {
2145
+ auto: _options.auto ?? false,
2146
+ scope: _options.scope ?? "test",
2147
+ injected: _options.injected ?? false
2148
+ };
2149
+ value = options.injected ? runner2.injectValue?.(name) ?? fn[0] : fn[0];
2150
+ } else {
2151
+ value = fn;
1998
2152
  }
1999
- if (fixture.scope !== "test") {
2000
- var _fixture$deps2;
2001
- (_fixture$deps2 = fixture.deps) === null || _fixture$deps2 === void 0 ? void 0 : _fixture$deps2.forEach((dep) => {
2002
- if (!dep.isFn) {
2003
- return;
2004
- }
2005
- if (fixture.scope === "worker" && dep.scope === "worker") {
2006
- return;
2007
- }
2008
- if (fixture.scope === "file" && dep.scope !== "test") {
2009
- return;
2010
- }
2011
- throw new SyntaxError(`cannot use the ${dep.scope} fixture "${dep.prop}" inside the ${fixture.scope} fixture "${fixture.prop}"`);
2012
- });
2153
+ const parent = registrations.get(name);
2154
+ if (parent && options) {
2155
+ if (parent.scope !== options.scope) {
2156
+ errors.push(new FixtureDependencyError(`The "${name}" fixture was already registered with a "${options.scope}" scope.`));
2157
+ }
2158
+ if (parent.auto !== options.auto) {
2159
+ errors.push(new FixtureDependencyError(`The "${name}" fixture was already registered as { auto: ${options.auto} }.`));
2160
+ }
2161
+ } else if (parent) {
2162
+ options = {
2163
+ auto: parent.auto,
2164
+ scope: parent.scope,
2165
+ injected: parent.injected
2166
+ };
2167
+ } else if (!options) {
2168
+ options = {
2169
+ auto: false,
2170
+ injected: false,
2171
+ scope: "test"
2172
+ };
2173
+ }
2174
+ if (options.scope && !_TestFixtures._fixtureScopes.includes(options.scope)) {
2175
+ errors.push(new FixtureDependencyError(`The "${name}" fixture has unknown scope "${options.scope}".`));
2176
+ }
2177
+ if (!supportNonTest && options.scope !== "test") {
2178
+ errors.push(new FixtureDependencyError(`The "${name}" fixture cannot be defined with a ${options.scope} scope${!_options?.scope && parent?.scope ? " (inherited from the base fixture)" : ""} inside the describe block. Define it at the top level of the file instead.`));
2179
+ }
2180
+ const deps = isFixtureFunction(value) ? getUsedProps(value) : /* @__PURE__ */ new Set();
2181
+ const item = {
2182
+ name,
2183
+ value,
2184
+ auto: options.auto ?? false,
2185
+ injected: options.injected ?? false,
2186
+ scope: options.scope ?? "test",
2187
+ deps,
2188
+ parent
2189
+ };
2190
+ registrations.set(name, item);
2191
+ if (item.scope === "worker" && (runner2.pool === "vmThreads" || runner2.pool === "vmForks")) {
2192
+ item.scope = "file";
2193
+ }
2194
+ });
2195
+ for (const fixture of registrations.values()) {
2196
+ for (const depName of fixture.deps) {
2197
+ if (_TestFixtures._builtinFixtures.includes(depName)) {
2198
+ continue;
2199
+ }
2200
+ const dep = registrations.get(depName);
2201
+ if (!dep) {
2202
+ errors.push(new FixtureDependencyError(`The "${fixture.name}" fixture depends on unknown fixture "${depName}".`));
2203
+ continue;
2204
+ }
2205
+ if (depName === fixture.name && !fixture.parent) {
2206
+ errors.push(new FixtureDependencyError(`The "${fixture.name}" fixture depends on itself, but does not have a base implementation.`));
2207
+ continue;
2208
+ }
2209
+ if (_TestFixtures._fixtureScopes.indexOf(fixture.scope) > _TestFixtures._fixtureScopes.indexOf(dep.scope)) {
2210
+ errors.push(new FixtureDependencyError(`The ${fixture.scope} "${fixture.name}" fixture cannot depend on a ${dep.scope} fixture "${dep.name}".`));
2211
+ continue;
2212
+ }
2013
2213
  }
2014
2214
  }
2015
- });
2016
- return context;
2017
- }
2018
- var fixtureValueMaps = /* @__PURE__ */ new Map();
2019
- var cleanupFnArrayMap = /* @__PURE__ */ new Map();
2020
- function withFixtures(runner2, fn, testContext) {
2021
- return (hookContext) => {
2022
- const context = hookContext || testContext;
2215
+ if (errors.length === 1) {
2216
+ throw errors[0];
2217
+ } else if (errors.length > 1) {
2218
+ throw new AggregateError(errors, "Cannot resolve user fixtures. See errors for more information.");
2219
+ }
2220
+ return registrations;
2221
+ }
2222
+ };
2223
+ var cleanupFnArrayMap = /* @__PURE__ */ new WeakMap();
2224
+ var contextHasFixturesCache = /* @__PURE__ */ new WeakMap();
2225
+ function withFixtures(fn, options) {
2226
+ const collector = getCurrentSuite();
2227
+ const suite2 = options?.suite || collector.suite || collector.file;
2228
+ return async (hookContext) => {
2229
+ const context = hookContext || options?.context;
2023
2230
  if (!context) {
2231
+ if (options?.suiteHook) {
2232
+ validateSuiteHook(fn, options.suiteHook, options.stackTraceError);
2233
+ }
2024
2234
  return fn({});
2025
2235
  }
2026
- const fixtures = getTestFixture(context);
2027
- if (!(fixtures === null || fixtures === void 0 ? void 0 : fixtures.length)) {
2236
+ const fixtures = options?.fixtures || getTestFixtures(context);
2237
+ if (!fixtures) {
2028
2238
  return fn(context);
2029
2239
  }
2030
- const usedProps = getUsedProps(fn);
2031
- const hasAutoFixture = fixtures.some(({ auto }) => auto);
2032
- if (!usedProps.length && !hasAutoFixture) {
2240
+ const registrations = fixtures.get(suite2);
2241
+ if (!registrations.size) {
2033
2242
  return fn(context);
2034
2243
  }
2035
- if (!fixtureValueMaps.get(context)) {
2036
- fixtureValueMaps.set(context, /* @__PURE__ */ new Map());
2244
+ const usedFixtures = [];
2245
+ const usedProps = getUsedProps(fn);
2246
+ for (const fixture of registrations.values()) {
2247
+ if (fixture.auto || usedProps.has(fixture.name)) {
2248
+ usedFixtures.push(fixture);
2249
+ }
2250
+ }
2251
+ if (!usedFixtures.length) {
2252
+ return fn(context);
2037
2253
  }
2038
- const fixtureValueMap = fixtureValueMaps.get(context);
2039
2254
  if (!cleanupFnArrayMap.has(context)) {
2040
2255
  cleanupFnArrayMap.set(context, []);
2041
2256
  }
2042
2257
  const cleanupFnArray = cleanupFnArrayMap.get(context);
2043
- const usedFixtures = fixtures.filter(({ prop, auto }) => auto || usedProps.includes(prop));
2044
- const pendingFixtures = resolveDeps(usedFixtures);
2258
+ const pendingFixtures = resolveDeps(usedFixtures, registrations);
2045
2259
  if (!pendingFixtures.length) {
2046
2260
  return fn(context);
2047
2261
  }
2048
- async function resolveFixtures() {
2049
- for (const fixture of pendingFixtures) {
2050
- if (fixtureValueMap.has(fixture)) {
2051
- continue;
2262
+ if (options?.suiteHook) {
2263
+ const testScopedFixtures = pendingFixtures.filter((f3) => f3.scope === "test");
2264
+ if (testScopedFixtures.length > 0) {
2265
+ const fixtureNames = testScopedFixtures.map((f3) => `"${f3.name}"`).join(", ");
2266
+ const alternativeHook = {
2267
+ aroundAll: "aroundEach",
2268
+ beforeAll: "beforeEach",
2269
+ afterAll: "afterEach"
2270
+ };
2271
+ const error = new FixtureDependencyError(`Test-scoped fixtures cannot be used inside ${options.suiteHook} hook. The following fixtures are test-scoped: ${fixtureNames}. Use { scope: 'file' } or { scope: 'worker' } fixtures instead, or move the logic to ${alternativeHook[options.suiteHook]} hook.`);
2272
+ if (options.stackTraceError?.stack) {
2273
+ error.stack = error.message + options.stackTraceError.stack.replace(options.stackTraceError.message, "");
2052
2274
  }
2053
- const resolvedValue = await resolveFixtureValue(runner2, fixture, context, cleanupFnArray);
2054
- context[fixture.prop] = resolvedValue;
2055
- fixtureValueMap.set(fixture, resolvedValue);
2056
- if (fixture.scope === "test") {
2057
- cleanupFnArray.unshift(() => {
2058
- fixtureValueMap.delete(fixture);
2059
- });
2275
+ throw error;
2276
+ }
2277
+ }
2278
+ if (!contextHasFixturesCache.has(context)) {
2279
+ contextHasFixturesCache.set(context, /* @__PURE__ */ new WeakSet());
2280
+ }
2281
+ const cachedFixtures = contextHasFixturesCache.get(context);
2282
+ for (const fixture of pendingFixtures) {
2283
+ if (fixture.scope === "test") {
2284
+ if (cachedFixtures.has(fixture)) {
2285
+ continue;
2060
2286
  }
2287
+ cachedFixtures.add(fixture);
2288
+ const resolvedValue = await resolveTestFixtureValue(fixture, context, cleanupFnArray);
2289
+ context[fixture.name] = resolvedValue;
2290
+ cleanupFnArray.push(() => {
2291
+ cachedFixtures.delete(fixture);
2292
+ });
2293
+ } else {
2294
+ const resolvedValue = await resolveScopeFixtureValue(fixtures, suite2, fixture);
2295
+ context[fixture.name] = resolvedValue;
2061
2296
  }
2062
2297
  }
2063
- return resolveFixtures().then(() => fn(context));
2298
+ return fn(context);
2064
2299
  };
2065
2300
  }
2066
- var globalFixturePromise = /* @__PURE__ */ new WeakMap();
2067
- function resolveFixtureValue(runner2, fixture, context, cleanupFnArray) {
2068
- var _runner$getWorkerCont;
2069
- const fileContext = getFileContext(context.task.file);
2070
- const workerContext = (_runner$getWorkerCont = runner2.getWorkerContext) === null || _runner$getWorkerCont === void 0 ? void 0 : _runner$getWorkerCont.call(runner2);
2071
- if (!fixture.isFn) {
2072
- var _fixture$prop;
2073
- fileContext[_fixture$prop = fixture.prop] ?? (fileContext[_fixture$prop] = fixture.value);
2074
- if (workerContext) {
2075
- var _fixture$prop2;
2076
- workerContext[_fixture$prop2 = fixture.prop] ?? (workerContext[_fixture$prop2] = fixture.value);
2077
- }
2301
+ function isFixtureFunction(value) {
2302
+ return typeof value === "function";
2303
+ }
2304
+ function resolveTestFixtureValue(fixture, context, cleanupFnArray) {
2305
+ if (!isFixtureFunction(fixture.value)) {
2078
2306
  return fixture.value;
2079
2307
  }
2080
- if (fixture.scope === "test") {
2081
- return resolveFixtureFunction(fixture.value, context, cleanupFnArray);
2308
+ return resolveFixtureFunction(fixture.value, context, cleanupFnArray);
2309
+ }
2310
+ var scopedFixturePromiseCache = /* @__PURE__ */ new WeakMap();
2311
+ async function resolveScopeFixtureValue(fixtures, suite2, fixture) {
2312
+ const workerContext = fixtures.getWorkerContext();
2313
+ const fileContext = fixtures.getFileContext(suite2.file);
2314
+ const fixtureContext = fixture.scope === "worker" ? workerContext : fileContext;
2315
+ if (!isFixtureFunction(fixture.value)) {
2316
+ fixtureContext[fixture.name] = fixture.value;
2317
+ return fixture.value;
2082
2318
  }
2083
- if (globalFixturePromise.has(fixture)) {
2084
- return globalFixturePromise.get(fixture);
2319
+ if (fixture.name in fixtureContext) {
2320
+ return fixtureContext[fixture.name];
2085
2321
  }
2086
- let fixtureContext;
2087
- if (fixture.scope === "worker") {
2088
- if (!workerContext) {
2089
- throw new TypeError("[@vitest/runner] The worker context is not available in the current test runner. Please, provide the `getWorkerContext` method when initiating the runner.");
2090
- }
2091
- fixtureContext = workerContext;
2092
- } else {
2093
- fixtureContext = fileContext;
2094
- }
2095
- if (fixture.prop in fixtureContext) {
2096
- return fixtureContext[fixture.prop];
2322
+ if (scopedFixturePromiseCache.has(fixture)) {
2323
+ return scopedFixturePromiseCache.get(fixture);
2097
2324
  }
2098
2325
  if (!cleanupFnArrayMap.has(fixtureContext)) {
2099
2326
  cleanupFnArrayMap.set(fixtureContext, []);
2100
2327
  }
2101
2328
  const cleanupFnFileArray = cleanupFnArrayMap.get(fixtureContext);
2102
- const promise = resolveFixtureFunction(fixture.value, fixtureContext, cleanupFnFileArray).then((value) => {
2103
- fixtureContext[fixture.prop] = value;
2104
- globalFixturePromise.delete(fixture);
2329
+ const promise = resolveFixtureFunction(fixture.value, fixture.scope === "file" ? {
2330
+ ...workerContext,
2331
+ ...fileContext
2332
+ } : fixtureContext, cleanupFnFileArray).then((value) => {
2333
+ fixtureContext[fixture.name] = value;
2334
+ scopedFixturePromiseCache.delete(fixture);
2105
2335
  return value;
2106
2336
  });
2107
- globalFixturePromise.set(fixture, promise);
2337
+ scopedFixturePromiseCache.set(fixture, promise);
2108
2338
  return promise;
2109
2339
  }
2110
2340
  async function resolveFixtureFunction(fixtureFn, context, cleanupFnArray) {
@@ -2128,82 +2358,97 @@ async function resolveFixtureFunction(fixtureFn, context, cleanupFnArray) {
2128
2358
  });
2129
2359
  return useFnArgPromise;
2130
2360
  }
2131
- function resolveDeps(fixtures, depSet = /* @__PURE__ */ new Set(), pendingFixtures = []) {
2132
- fixtures.forEach((fixture) => {
2361
+ function resolveDeps(usedFixtures, registrations, depSet = /* @__PURE__ */ new Set(), pendingFixtures = []) {
2362
+ usedFixtures.forEach((fixture) => {
2133
2363
  if (pendingFixtures.includes(fixture)) {
2134
2364
  return;
2135
2365
  }
2136
- if (!fixture.isFn || !fixture.deps) {
2366
+ if (!isFixtureFunction(fixture.value) || !fixture.deps) {
2137
2367
  pendingFixtures.push(fixture);
2138
2368
  return;
2139
2369
  }
2140
2370
  if (depSet.has(fixture)) {
2141
- throw new Error(`Circular fixture dependency detected: ${fixture.prop} <- ${[...depSet].reverse().map((d4) => d4.prop).join(" <- ")}`);
2371
+ if (fixture.parent) {
2372
+ fixture = fixture.parent;
2373
+ } else {
2374
+ throw new Error(`Circular fixture dependency detected: ${fixture.name} <- ${[...depSet].reverse().map((d3) => d3.name).join(" <- ")}`);
2375
+ }
2142
2376
  }
2143
2377
  depSet.add(fixture);
2144
- resolveDeps(fixture.deps, depSet, pendingFixtures);
2378
+ resolveDeps([...fixture.deps].map((n2) => n2 === fixture.name ? fixture.parent : registrations.get(n2)).filter((n2) => !!n2), registrations, depSet, pendingFixtures);
2145
2379
  pendingFixtures.push(fixture);
2146
2380
  depSet.clear();
2147
2381
  });
2148
2382
  return pendingFixtures;
2149
2383
  }
2150
- function getUsedProps(fn) {
2151
- let fnString = filterOutComments(fn.toString());
2384
+ function validateSuiteHook(fn, hook, suiteError) {
2385
+ const usedProps = getUsedProps(fn, {
2386
+ sourceError: suiteError,
2387
+ suiteHook: hook
2388
+ });
2389
+ if (usedProps.size) {
2390
+ const error = new FixtureAccessError(`The ${hook} hook uses fixtures "${[...usedProps].join('", "')}", but has no access to context. Did you forget to call it as "test.${hook}()" instead of "${hook}()"?
2391
+ If you used internal "suite" task as the first argument previously, access it in the second argument instead. See https://vitest.dev/guide/test-context#suite-level-hooks`);
2392
+ if (suiteError) {
2393
+ error.stack = suiteError.stack?.replace(suiteError.message, error.message);
2394
+ }
2395
+ throw error;
2396
+ }
2397
+ }
2398
+ var kPropsSymbol = /* @__PURE__ */ Symbol("$vitest:fixture-props");
2399
+ var kPropNamesSymbol = /* @__PURE__ */ Symbol("$vitest:fixture-prop-names");
2400
+ function configureProps(fn, options) {
2401
+ Object.defineProperty(fn, kPropsSymbol, {
2402
+ value: options,
2403
+ enumerable: false
2404
+ });
2405
+ }
2406
+ function memoProps(fn, props) {
2407
+ fn[kPropNamesSymbol] = props;
2408
+ return props;
2409
+ }
2410
+ function getUsedProps(fn, { sourceError, suiteHook } = {}) {
2411
+ if (kPropNamesSymbol in fn) {
2412
+ return fn[kPropNamesSymbol];
2413
+ }
2414
+ const { index: fixturesIndex = 0, original: implementation = fn } = kPropsSymbol in fn ? fn[kPropsSymbol] : {};
2415
+ let fnString = filterOutComments(implementation.toString());
2152
2416
  if (/__async\((?:this|null), (?:null|arguments|\[[_0-9, ]*\]), function\*/.test(fnString)) {
2153
2417
  fnString = fnString.split(/__async\((?:this|null),/)[1];
2154
2418
  }
2155
2419
  const match = fnString.match(/[^(]*\(([^)]*)/);
2156
2420
  if (!match) {
2157
- return [];
2421
+ return memoProps(fn, /* @__PURE__ */ new Set());
2158
2422
  }
2159
2423
  const args = splitByComma(match[1]);
2160
2424
  if (!args.length) {
2161
- return [];
2425
+ return memoProps(fn, /* @__PURE__ */ new Set());
2162
2426
  }
2163
- let first = args[0];
2164
- if ("__VITEST_FIXTURE_INDEX__" in fn) {
2165
- first = args[fn.__VITEST_FIXTURE_INDEX__];
2166
- if (!first) {
2167
- return [];
2168
- }
2427
+ const fixturesArgument = args[fixturesIndex];
2428
+ if (!fixturesArgument) {
2429
+ return memoProps(fn, /* @__PURE__ */ new Set());
2169
2430
  }
2170
- if (!(first[0] === "{" && first.endsWith("}"))) {
2171
- throw new Error(`The first argument inside a fixture must use object destructuring pattern, e.g. ({ test } => {}). Instead, received "${first}".`);
2431
+ if (!(fixturesArgument[0] === "{" && fixturesArgument.endsWith("}"))) {
2432
+ const ordinalArgument = ordinal(fixturesIndex + 1);
2433
+ const error = new FixtureParseError(`The ${ordinalArgument} argument inside a fixture must use object destructuring pattern, e.g. ({ task } => {}). Instead, received "${fixturesArgument}".${suiteHook ? ` If you used internal "suite" task as the ${ordinalArgument} argument previously, access it in the ${ordinal(fixturesIndex + 2)} argument instead.` : ""}`);
2434
+ if (sourceError) {
2435
+ error.stack = sourceError.stack?.replace(sourceError.message, error.message);
2436
+ }
2437
+ throw error;
2172
2438
  }
2173
- const _first = first.slice(1, -1).replace(/\s/g, "");
2439
+ const _first = fixturesArgument.slice(1, -1).replace(/\s/g, "");
2174
2440
  const props = splitByComma(_first).map((prop) => {
2175
2441
  return prop.replace(/:.*|=.*/g, "");
2176
2442
  });
2177
2443
  const last = props.at(-1);
2178
2444
  if (last && last.startsWith("...")) {
2179
- throw new Error(`Rest parameters are not supported in fixtures, received "${last}".`);
2180
- }
2181
- return props;
2182
- }
2183
- function filterOutComments(s3) {
2184
- const result = [];
2185
- let commentState = "none";
2186
- for (let i3 = 0; i3 < s3.length; ++i3) {
2187
- if (commentState === "singleline") {
2188
- if (s3[i3] === "\n") {
2189
- commentState = "none";
2190
- }
2191
- } else if (commentState === "multiline") {
2192
- if (s3[i3 - 1] === "*" && s3[i3] === "/") {
2193
- commentState = "none";
2194
- }
2195
- } else if (commentState === "none") {
2196
- if (s3[i3] === "/" && s3[i3 + 1] === "/") {
2197
- commentState = "singleline";
2198
- } else if (s3[i3] === "/" && s3[i3 + 1] === "*") {
2199
- commentState = "multiline";
2200
- i3 += 2;
2201
- } else {
2202
- result.push(s3[i3]);
2203
- }
2445
+ const error = new FixtureParseError(`Rest parameters are not supported in fixtures, received "${last}".`);
2446
+ if (sourceError) {
2447
+ error.stack = sourceError.stack?.replace(sourceError.message, error.message);
2204
2448
  }
2449
+ throw error;
2205
2450
  }
2206
- return result.join("");
2451
+ return memoProps(fn, new Set(props));
2207
2452
  }
2208
2453
  function splitByComma(s3) {
2209
2454
  const result = [];
@@ -2237,40 +2482,99 @@ function getDefaultHookTimeout() {
2237
2482
  }
2238
2483
  var CLEANUP_TIMEOUT_KEY = /* @__PURE__ */ Symbol.for("VITEST_CLEANUP_TIMEOUT");
2239
2484
  var CLEANUP_STACK_TRACE_KEY = /* @__PURE__ */ Symbol.for("VITEST_CLEANUP_STACK_TRACE");
2485
+ var AROUND_TIMEOUT_KEY = /* @__PURE__ */ Symbol.for("VITEST_AROUND_TIMEOUT");
2486
+ var AROUND_STACK_TRACE_KEY = /* @__PURE__ */ Symbol.for("VITEST_AROUND_STACK_TRACE");
2240
2487
  function beforeAll(fn, timeout = getDefaultHookTimeout()) {
2241
2488
  assertTypes(fn, '"beforeAll" callback', ["function"]);
2242
2489
  const stackTraceError = new Error("STACK_TRACE_ERROR");
2243
- return getCurrentSuite().on("beforeAll", Object.assign(withTimeout(fn, timeout, true, stackTraceError), {
2490
+ const context = getChainableContext(this);
2491
+ return getCurrentSuite().on("beforeAll", Object.assign(withTimeout(withSuiteFixtures("beforeAll", fn, context, stackTraceError), timeout, true, stackTraceError), {
2244
2492
  [CLEANUP_TIMEOUT_KEY]: timeout,
2245
2493
  [CLEANUP_STACK_TRACE_KEY]: stackTraceError
2246
2494
  }));
2247
2495
  }
2248
2496
  function afterAll(fn, timeout) {
2249
2497
  assertTypes(fn, '"afterAll" callback', ["function"]);
2250
- return getCurrentSuite().on("afterAll", withTimeout(fn, timeout ?? getDefaultHookTimeout(), true, new Error("STACK_TRACE_ERROR")));
2498
+ const context = getChainableContext(this);
2499
+ const stackTraceError = new Error("STACK_TRACE_ERROR");
2500
+ return getCurrentSuite().on("afterAll", withTimeout(withSuiteFixtures("afterAll", fn, context, stackTraceError), timeout ?? getDefaultHookTimeout(), true, stackTraceError));
2251
2501
  }
2252
2502
  function beforeEach(fn, timeout = getDefaultHookTimeout()) {
2253
2503
  assertTypes(fn, '"beforeEach" callback', ["function"]);
2254
2504
  const stackTraceError = new Error("STACK_TRACE_ERROR");
2255
- const runner2 = getRunner();
2256
- return getCurrentSuite().on("beforeEach", Object.assign(withTimeout(withFixtures(runner2, fn), timeout ?? getDefaultHookTimeout(), true, stackTraceError, abortIfTimeout), {
2505
+ const wrapper = (context, suite2) => {
2506
+ const fixtureResolver = withFixtures(fn, { suite: suite2 });
2507
+ return fixtureResolver(context);
2508
+ };
2509
+ return getCurrentSuite().on("beforeEach", Object.assign(withTimeout(wrapper, timeout ?? getDefaultHookTimeout(), true, stackTraceError, abortIfTimeout), {
2257
2510
  [CLEANUP_TIMEOUT_KEY]: timeout,
2258
2511
  [CLEANUP_STACK_TRACE_KEY]: stackTraceError
2259
2512
  }));
2260
2513
  }
2261
2514
  function afterEach(fn, timeout) {
2262
2515
  assertTypes(fn, '"afterEach" callback', ["function"]);
2263
- const runner2 = getRunner();
2264
- return getCurrentSuite().on("afterEach", withTimeout(withFixtures(runner2, fn), timeout ?? getDefaultHookTimeout(), true, new Error("STACK_TRACE_ERROR"), abortIfTimeout));
2516
+ const wrapper = (context, suite2) => {
2517
+ const fixtureResolver = withFixtures(fn, { suite: suite2 });
2518
+ return fixtureResolver(context);
2519
+ };
2520
+ return getCurrentSuite().on("afterEach", withTimeout(wrapper, timeout ?? getDefaultHookTimeout(), true, new Error("STACK_TRACE_ERROR"), abortIfTimeout));
2265
2521
  }
2266
2522
  var onTestFailed = createTestHook("onTestFailed", (test3, handler, timeout) => {
2267
- test3.onFailed || (test3.onFailed = []);
2523
+ test3.onFailed ||= [];
2268
2524
  test3.onFailed.push(withTimeout(handler, timeout ?? getDefaultHookTimeout(), true, new Error("STACK_TRACE_ERROR"), abortIfTimeout));
2269
2525
  });
2270
2526
  var onTestFinished = createTestHook("onTestFinished", (test3, handler, timeout) => {
2271
- test3.onFinished || (test3.onFinished = []);
2527
+ test3.onFinished ||= [];
2272
2528
  test3.onFinished.push(withTimeout(handler, timeout ?? getDefaultHookTimeout(), true, new Error("STACK_TRACE_ERROR"), abortIfTimeout));
2273
2529
  });
2530
+ function aroundAll(fn, timeout) {
2531
+ assertTypes(fn, '"aroundAll" callback', ["function"]);
2532
+ const stackTraceError = new Error("STACK_TRACE_ERROR");
2533
+ const resolvedTimeout = timeout ?? getDefaultHookTimeout();
2534
+ const context = getChainableContext(this);
2535
+ return getCurrentSuite().on("aroundAll", Object.assign(withSuiteFixtures("aroundAll", fn, context, stackTraceError, 1), {
2536
+ [AROUND_TIMEOUT_KEY]: resolvedTimeout,
2537
+ [AROUND_STACK_TRACE_KEY]: stackTraceError
2538
+ }));
2539
+ }
2540
+ function aroundEach(fn, timeout) {
2541
+ assertTypes(fn, '"aroundEach" callback', ["function"]);
2542
+ const stackTraceError = new Error("STACK_TRACE_ERROR");
2543
+ const resolvedTimeout = timeout ?? getDefaultHookTimeout();
2544
+ const wrapper = (runTest, context, suite2) => {
2545
+ const innerFn = (ctx) => fn(runTest, ctx, suite2);
2546
+ configureProps(innerFn, {
2547
+ index: 1,
2548
+ original: fn
2549
+ });
2550
+ const fixtureResolver = withFixtures(innerFn, { suite: suite2 });
2551
+ return fixtureResolver(context);
2552
+ };
2553
+ return getCurrentSuite().on("aroundEach", Object.assign(wrapper, {
2554
+ [AROUND_TIMEOUT_KEY]: resolvedTimeout,
2555
+ [AROUND_STACK_TRACE_KEY]: stackTraceError
2556
+ }));
2557
+ }
2558
+ function withSuiteFixtures(suiteHook, fn, context, stackTraceError, contextIndex = 0) {
2559
+ return (...args) => {
2560
+ const suite2 = args.at(-1);
2561
+ const prefix = args.slice(0, -1);
2562
+ const wrapper = (ctx) => fn(...prefix, ctx, suite2);
2563
+ configureProps(wrapper, {
2564
+ index: contextIndex,
2565
+ original: fn
2566
+ });
2567
+ const fixtures = context?.getFixtures();
2568
+ const fileContext = fixtures?.getFileContext(suite2.file);
2569
+ const fixtured = withFixtures(wrapper, {
2570
+ suiteHook,
2571
+ fixtures,
2572
+ context: fileContext,
2573
+ stackTraceError
2574
+ });
2575
+ return fixtured();
2576
+ };
2577
+ }
2274
2578
  function createTestHook(name, handler) {
2275
2579
  return (fn, timeout) => {
2276
2580
  assertTypes(fn, `"${name}" callback`, ["function"]);
@@ -2316,9 +2620,12 @@ function createSuiteHooks() {
2316
2620
  beforeAll: [],
2317
2621
  afterAll: [],
2318
2622
  beforeEach: [],
2319
- afterEach: []
2623
+ afterEach: [],
2624
+ aroundEach: [],
2625
+ aroundAll: []
2320
2626
  };
2321
2627
  }
2628
+ var POSITIVE_INFINITY = Number.POSITIVE_INFINITY;
2322
2629
  function parseArguments(optionsOrFn, timeoutOrTest) {
2323
2630
  if (timeoutOrTest != null && typeof timeoutOrTest === "object") {
2324
2631
  throw new TypeError(`Signature "test(name, fn, { ... })" was deprecated in Vitest 3 and removed in Vitest 4. Please, provide options as a second argument instead.`);
@@ -2344,32 +2651,66 @@ function parseArguments(optionsOrFn, timeoutOrTest) {
2344
2651
  };
2345
2652
  }
2346
2653
  function createSuiteCollector(name, factory = () => {
2347
- }, mode, each, suiteOptions, parentCollectorFixtures) {
2654
+ }, mode, each, suiteOptions) {
2348
2655
  const tasks = [];
2349
2656
  let suite2;
2350
2657
  initSuite(true);
2351
2658
  const task = function(name2 = "", options = {}) {
2352
- var _collectorContext$cur, _collectorContext$cur2, _collectorContext$cur3;
2353
- const timeout = (options === null || options === void 0 ? void 0 : options.timeout) ?? runner.config.testTimeout;
2354
- const currentSuite = (_collectorContext$cur = collectorContext.currentSuite) === null || _collectorContext$cur === void 0 ? void 0 : _collectorContext$cur.suite;
2659
+ const currentSuite = collectorContext.currentSuite?.suite;
2660
+ const parentTask = currentSuite ?? collectorContext.currentSuite?.file;
2661
+ const parentTags = parentTask?.tags || [];
2662
+ const testTags = unique([...parentTags, ...toArray(options.tags)]);
2663
+ const tagsOptions = testTags.map((tag) => {
2664
+ const tagDefinition = runner.config.tags?.find((t2) => t2.name === tag);
2665
+ if (!tagDefinition && runner.config.strictTags) {
2666
+ throw createNoTagsError(runner.config.tags, tag);
2667
+ }
2668
+ return tagDefinition;
2669
+ }).filter((r2) => r2 != null).sort((tag1, tag2) => (tag2.priority ?? POSITIVE_INFINITY) - (tag1.priority ?? POSITIVE_INFINITY)).reduce((acc, tag) => {
2670
+ const { name: name3, description, priority, meta, ...options2 } = tag;
2671
+ Object.assign(acc, options2);
2672
+ if (meta) {
2673
+ acc.meta = Object.assign(acc.meta ?? /* @__PURE__ */ Object.create(null), meta);
2674
+ }
2675
+ return acc;
2676
+ }, {});
2677
+ const testOwnMeta = options.meta;
2678
+ options = {
2679
+ ...tagsOptions,
2680
+ ...options
2681
+ };
2682
+ const timeout = options.timeout ?? runner.config.testTimeout;
2683
+ const parentMeta = currentSuite?.meta;
2684
+ const tagMeta = tagsOptions.meta;
2685
+ const testMeta = /* @__PURE__ */ Object.create(null);
2686
+ if (tagMeta) {
2687
+ Object.assign(testMeta, tagMeta);
2688
+ }
2689
+ if (parentMeta) {
2690
+ Object.assign(testMeta, parentMeta);
2691
+ }
2692
+ if (testOwnMeta) {
2693
+ Object.assign(testMeta, testOwnMeta);
2694
+ }
2355
2695
  const task2 = {
2356
2696
  id: "",
2357
2697
  name: name2,
2358
- fullName: createTaskName([(currentSuite === null || currentSuite === void 0 ? void 0 : currentSuite.fullName) ?? ((_collectorContext$cur2 = collectorContext.currentSuite) === null || _collectorContext$cur2 === void 0 || (_collectorContext$cur2 = _collectorContext$cur2.file) === null || _collectorContext$cur2 === void 0 ? void 0 : _collectorContext$cur2.fullName), name2]),
2359
- fullTestName: createTaskName([currentSuite === null || currentSuite === void 0 ? void 0 : currentSuite.fullTestName, name2]),
2698
+ fullName: createTaskName([currentSuite?.fullName ?? collectorContext.currentSuite?.file?.fullName, name2]),
2699
+ fullTestName: createTaskName([currentSuite?.fullTestName, name2]),
2360
2700
  suite: currentSuite,
2361
2701
  each: options.each,
2362
2702
  fails: options.fails,
2363
2703
  context: void 0,
2364
2704
  type: "test",
2365
- file: (currentSuite === null || currentSuite === void 0 ? void 0 : currentSuite.file) ?? ((_collectorContext$cur3 = collectorContext.currentSuite) === null || _collectorContext$cur3 === void 0 ? void 0 : _collectorContext$cur3.file),
2705
+ file: currentSuite?.file ?? collectorContext.currentSuite?.file,
2366
2706
  timeout,
2367
2707
  retry: options.retry ?? runner.config.retry,
2368
2708
  repeats: options.repeats,
2369
2709
  mode: options.only ? "only" : options.skip ? "skip" : options.todo ? "todo" : "run",
2370
- meta: options.meta ?? /* @__PURE__ */ Object.create(null),
2710
+ meta: testMeta,
2371
2711
  annotations: [],
2372
- artifacts: []
2712
+ artifacts: [],
2713
+ tags: testTags
2373
2714
  };
2374
2715
  const handler = options.handler;
2375
2716
  if (task2.mode === "run" && !handler) {
@@ -2378,19 +2719,19 @@ function createSuiteCollector(name, factory = () => {
2378
2719
  if (options.concurrent || !options.sequential && runner.config.sequence.concurrent) {
2379
2720
  task2.concurrent = true;
2380
2721
  }
2381
- task2.shuffle = suiteOptions === null || suiteOptions === void 0 ? void 0 : suiteOptions.shuffle;
2722
+ task2.shuffle = suiteOptions?.shuffle;
2382
2723
  const context = createTestContext(task2, runner);
2383
2724
  Object.defineProperty(task2, "context", {
2384
2725
  value: context,
2385
2726
  enumerable: false
2386
2727
  });
2387
- setTestFixture(context, options.fixtures);
2728
+ setTestFixture(context, options.fixtures ?? new TestFixtures());
2388
2729
  const limit = Error.stackTraceLimit;
2389
- Error.stackTraceLimit = 15;
2730
+ Error.stackTraceLimit = 10;
2390
2731
  const stackTraceError = new Error("STACK_TRACE_ERROR");
2391
2732
  Error.stackTraceLimit = limit;
2392
2733
  if (handler) {
2393
- setFn(task2, withTimeout(withAwaitAsyncAssertions(withFixtures(runner, handler, context), task2), timeout, false, stackTraceError, (_, error) => abortIfTimeout([context], error)));
2734
+ setFn(task2, withTimeout(withCancel(withAwaitAsyncAssertions(withFixtures(handler, { context }), task2), task2.context.signal), timeout, false, stackTraceError, (_, error) => abortIfTimeout([context], error)));
2394
2735
  }
2395
2736
  if (runner.config.includeTaskLocation) {
2396
2737
  const error = stackTraceError.stack;
@@ -2410,8 +2751,14 @@ function createSuiteCollector(name, factory = () => {
2410
2751
  if (typeof suiteOptions === "object") {
2411
2752
  options = Object.assign({}, suiteOptions, options);
2412
2753
  }
2413
- options.concurrent = this.concurrent || !this.sequential && (options === null || options === void 0 ? void 0 : options.concurrent);
2414
- options.sequential = this.sequential || !this.concurrent && (options === null || options === void 0 ? void 0 : options.sequential);
2754
+ const concurrent = this.concurrent ?? (!this.sequential && options?.concurrent);
2755
+ if (options.concurrent != null && concurrent != null) {
2756
+ options.concurrent = concurrent;
2757
+ }
2758
+ const sequential = this.sequential ?? (!this.concurrent && options?.sequential);
2759
+ if (options.sequential != null && sequential != null) {
2760
+ options.sequential = sequential;
2761
+ }
2415
2762
  const test4 = task(formatName(name2), {
2416
2763
  ...this,
2417
2764
  ...options,
@@ -2419,7 +2766,6 @@ function createSuiteCollector(name, factory = () => {
2419
2766
  });
2420
2767
  test4.type = "test";
2421
2768
  });
2422
- let collectorFixtures = parentCollectorFixtures;
2423
2769
  const collector = {
2424
2770
  type: "collector",
2425
2771
  name,
@@ -2427,44 +2773,39 @@ function createSuiteCollector(name, factory = () => {
2427
2773
  suite: suite2,
2428
2774
  options: suiteOptions,
2429
2775
  test: test3,
2776
+ file: suite2.file,
2430
2777
  tasks,
2431
2778
  collect,
2432
2779
  task,
2433
2780
  clear,
2434
- on: addHook,
2435
- fixtures() {
2436
- return collectorFixtures;
2437
- },
2438
- scoped(fixtures) {
2439
- const parsed = mergeContextFixtures(fixtures, { fixtures: collectorFixtures }, runner);
2440
- if (parsed.fixtures) {
2441
- collectorFixtures = parsed.fixtures;
2442
- }
2443
- }
2781
+ on: addHook
2444
2782
  };
2445
2783
  function addHook(name2, ...fn) {
2446
2784
  getHooks(suite2)[name2].push(...fn);
2447
2785
  }
2448
2786
  function initSuite(includeLocation) {
2449
- var _collectorContext$cur4, _collectorContext$cur5, _collectorContext$cur6;
2450
2787
  if (typeof suiteOptions === "number") {
2451
2788
  suiteOptions = { timeout: suiteOptions };
2452
2789
  }
2453
- const currentSuite = (_collectorContext$cur4 = collectorContext.currentSuite) === null || _collectorContext$cur4 === void 0 ? void 0 : _collectorContext$cur4.suite;
2790
+ const currentSuite = collectorContext.currentSuite?.suite;
2791
+ const parentTask = currentSuite ?? collectorContext.currentSuite?.file;
2792
+ const suiteTags = toArray(suiteOptions?.tags);
2793
+ validateTags(runner.config, suiteTags);
2454
2794
  suite2 = {
2455
2795
  id: "",
2456
2796
  type: "suite",
2457
2797
  name,
2458
- fullName: createTaskName([(currentSuite === null || currentSuite === void 0 ? void 0 : currentSuite.fullName) ?? ((_collectorContext$cur5 = collectorContext.currentSuite) === null || _collectorContext$cur5 === void 0 || (_collectorContext$cur5 = _collectorContext$cur5.file) === null || _collectorContext$cur5 === void 0 ? void 0 : _collectorContext$cur5.fullName), name]),
2459
- fullTestName: createTaskName([currentSuite === null || currentSuite === void 0 ? void 0 : currentSuite.fullTestName, name]),
2798
+ fullName: createTaskName([currentSuite?.fullName ?? collectorContext.currentSuite?.file?.fullName, name]),
2799
+ fullTestName: createTaskName([currentSuite?.fullTestName, name]),
2460
2800
  suite: currentSuite,
2461
2801
  mode,
2462
2802
  each,
2463
- file: (currentSuite === null || currentSuite === void 0 ? void 0 : currentSuite.file) ?? ((_collectorContext$cur6 = collectorContext.currentSuite) === null || _collectorContext$cur6 === void 0 ? void 0 : _collectorContext$cur6.file),
2464
- shuffle: suiteOptions === null || suiteOptions === void 0 ? void 0 : suiteOptions.shuffle,
2803
+ file: currentSuite?.file ?? collectorContext.currentSuite?.file,
2804
+ shuffle: suiteOptions?.shuffle,
2465
2805
  tasks: [],
2466
- meta: /* @__PURE__ */ Object.create(null),
2467
- concurrent: suiteOptions === null || suiteOptions === void 0 ? void 0 : suiteOptions.concurrent
2806
+ meta: suiteOptions?.meta ?? /* @__PURE__ */ Object.create(null),
2807
+ concurrent: suiteOptions?.concurrent,
2808
+ tags: unique([...parentTask?.tags || [], ...suiteTags])
2468
2809
  };
2469
2810
  if (runner && includeLocation && runner.config.includeTaskLocation) {
2470
2811
  const limit = Error.stackTraceLimit;
@@ -2517,32 +2858,43 @@ function withAwaitAsyncAssertions(fn, task) {
2517
2858
  }
2518
2859
  function createSuite() {
2519
2860
  function suiteFn(name, factoryOrOptions, optionsOrFactory) {
2520
- var _currentSuite$options;
2521
2861
  if (getCurrentTest()) {
2522
2862
  throw new Error("Calling the suite function inside test function is not allowed. It can be only called at the top level or inside another suite function.");
2523
2863
  }
2524
- let mode = this.only ? "only" : this.skip ? "skip" : this.todo ? "todo" : "run";
2525
2864
  const currentSuite = collectorContext.currentSuite || defaultSuite;
2526
2865
  let { options, handler: factory } = parseArguments(factoryOrOptions, optionsOrFactory);
2527
- if (mode === "run" && !factory) {
2528
- mode = "todo";
2529
- }
2530
2866
  const isConcurrentSpecified = options.concurrent || this.concurrent || options.sequential === false;
2531
2867
  const isSequentialSpecified = options.sequential || this.sequential || options.concurrent === false;
2868
+ const { meta: parentMeta, ...parentOptions } = currentSuite?.options || {};
2532
2869
  options = {
2533
- ...currentSuite === null || currentSuite === void 0 ? void 0 : currentSuite.options,
2534
- ...options,
2535
- shuffle: this.shuffle ?? options.shuffle ?? (currentSuite === null || currentSuite === void 0 || (_currentSuite$options = currentSuite.options) === null || _currentSuite$options === void 0 ? void 0 : _currentSuite$options.shuffle) ?? (runner === null || runner === void 0 ? void 0 : runner.config.sequence.shuffle)
2870
+ ...parentOptions,
2871
+ ...options
2536
2872
  };
2873
+ const shuffle2 = this.shuffle ?? options.shuffle ?? currentSuite?.options?.shuffle ?? runner?.config.sequence.shuffle;
2874
+ if (shuffle2 != null) {
2875
+ options.shuffle = shuffle2;
2876
+ }
2877
+ let mode = this.only ?? options.only ? "only" : this.skip ?? options.skip ? "skip" : this.todo ?? options.todo ? "todo" : "run";
2878
+ if (mode === "run" && !factory) {
2879
+ mode = "todo";
2880
+ }
2537
2881
  const isConcurrent = isConcurrentSpecified || options.concurrent && !isSequentialSpecified;
2538
2882
  const isSequential = isSequentialSpecified || options.sequential && !isConcurrentSpecified;
2539
- options.concurrent = isConcurrent && !isSequential;
2540
- options.sequential = isSequential && !isConcurrent;
2541
- return createSuiteCollector(formatName(name), factory, mode, this.each, options, currentSuite === null || currentSuite === void 0 ? void 0 : currentSuite.fixtures());
2883
+ if (isConcurrent != null) {
2884
+ options.concurrent = isConcurrent && !isSequential;
2885
+ }
2886
+ if (isSequential != null) {
2887
+ options.sequential = isSequential && !isConcurrent;
2888
+ }
2889
+ if (parentMeta) {
2890
+ options.meta = Object.assign(/* @__PURE__ */ Object.create(null), parentMeta, options.meta);
2891
+ }
2892
+ return createSuiteCollector(formatName(name), factory, mode, this.each, options);
2542
2893
  }
2543
2894
  suiteFn.each = function(cases, ...args) {
2544
- const suite2 = this.withContext();
2545
- this.setContext("each", true);
2895
+ const context = getChainableContext(this);
2896
+ const suite2 = context.withContext();
2897
+ context.setContext("each", true);
2546
2898
  if (Array.isArray(cases) && args.length) {
2547
2899
  cases = formatTemplateString(cases, args);
2548
2900
  }
@@ -2567,7 +2919,7 @@ function createSuite() {
2567
2919
  }
2568
2920
  }
2569
2921
  });
2570
- this.setContext("each", void 0);
2922
+ context.setContext("each", void 0);
2571
2923
  };
2572
2924
  };
2573
2925
  suiteFn.for = function(cases, ...args) {
@@ -2593,11 +2945,12 @@ function createSuite() {
2593
2945
  "todo"
2594
2946
  ], suiteFn);
2595
2947
  }
2596
- function createTaskCollector(fn, context) {
2948
+ function createTaskCollector(fn) {
2597
2949
  const taskFn = fn;
2598
2950
  taskFn.each = function(cases, ...args) {
2599
- const test3 = this.withContext();
2600
- this.setContext("each", true);
2951
+ const context = getChainableContext(this);
2952
+ const test3 = context.withContext();
2953
+ context.setContext("each", true);
2601
2954
  if (Array.isArray(cases) && args.length) {
2602
2955
  cases = formatTemplateString(cases, args);
2603
2956
  }
@@ -2622,11 +2975,12 @@ function createTaskCollector(fn, context) {
2622
2975
  }
2623
2976
  }
2624
2977
  });
2625
- this.setContext("each", void 0);
2978
+ context.setContext("each", void 0);
2626
2979
  };
2627
2980
  };
2628
2981
  taskFn.for = function(cases, ...args) {
2629
- const test3 = this.withContext();
2982
+ const context = getChainableContext(this);
2983
+ const test3 = context.withContext();
2630
2984
  if (Array.isArray(cases) && args.length) {
2631
2985
  cases = formatTemplateString(cases, args);
2632
2986
  }
@@ -2636,8 +2990,10 @@ function createTaskCollector(fn, context) {
2636
2990
  cases.forEach((item, idx) => {
2637
2991
  const handlerWrapper = handler ? (ctx) => handler(item, ctx) : void 0;
2638
2992
  if (handlerWrapper) {
2639
- handlerWrapper.__VITEST_FIXTURE_INDEX__ = 1;
2640
- handlerWrapper.toString = () => handler.toString();
2993
+ configureProps(handlerWrapper, {
2994
+ index: 1,
2995
+ original: handler
2996
+ });
2641
2997
  }
2642
2998
  test3(formatTitle(_name, toArray(item), idx), options, handlerWrapper);
2643
2999
  });
@@ -2649,27 +3005,78 @@ function createTaskCollector(fn, context) {
2649
3005
  taskFn.runIf = function(condition) {
2650
3006
  return condition ? this : this.skip;
2651
3007
  };
3008
+ function parseBuilderFixtures(fixturesOrName, optionsOrFn, maybeFn) {
3009
+ if (typeof fixturesOrName !== "string") {
3010
+ return fixturesOrName;
3011
+ }
3012
+ const fixtureName = fixturesOrName;
3013
+ let fixtureOptions;
3014
+ let fixtureValue;
3015
+ if (maybeFn !== void 0) {
3016
+ fixtureOptions = optionsOrFn;
3017
+ fixtureValue = maybeFn;
3018
+ } else {
3019
+ if (optionsOrFn !== null && typeof optionsOrFn === "object" && !Array.isArray(optionsOrFn) && ("scope" in optionsOrFn || "auto" in optionsOrFn)) {
3020
+ fixtureOptions = optionsOrFn;
3021
+ fixtureValue = {};
3022
+ } else {
3023
+ fixtureOptions = void 0;
3024
+ fixtureValue = optionsOrFn;
3025
+ }
3026
+ }
3027
+ if (typeof fixtureValue === "function") {
3028
+ const builderFn = fixtureValue;
3029
+ const fixture = async (ctx, use) => {
3030
+ let cleanup;
3031
+ const onCleanup = (fn2) => {
3032
+ if (cleanup !== void 0) {
3033
+ throw new Error(`onCleanup can only be called once per fixture. Define separate fixtures if you need multiple cleanup functions.`);
3034
+ }
3035
+ cleanup = fn2;
3036
+ };
3037
+ const value = await builderFn(ctx, { onCleanup });
3038
+ await use(value);
3039
+ if (cleanup) {
3040
+ await cleanup();
3041
+ }
3042
+ };
3043
+ configureProps(fixture, { original: builderFn });
3044
+ if (fixtureOptions) {
3045
+ return { [fixtureName]: [fixture, fixtureOptions] };
3046
+ }
3047
+ return { [fixtureName]: fixture };
3048
+ }
3049
+ if (fixtureOptions) {
3050
+ return { [fixtureName]: [fixtureValue, fixtureOptions] };
3051
+ }
3052
+ return { [fixtureName]: fixtureValue };
3053
+ }
3054
+ taskFn.override = function(fixturesOrName, optionsOrFn, maybeFn) {
3055
+ const userFixtures = parseBuilderFixtures(fixturesOrName, optionsOrFn, maybeFn);
3056
+ getChainableContext(this).getFixtures().override(runner, userFixtures);
3057
+ return this;
3058
+ };
2652
3059
  taskFn.scoped = function(fixtures) {
2653
- const collector = getCurrentSuite();
2654
- collector.scoped(fixtures);
3060
+ console.warn(`test.scoped() is deprecated and will be removed in future versions. Please use test.override() instead.`);
3061
+ return this.override(fixtures);
2655
3062
  };
2656
- taskFn.extend = function(fixtures) {
2657
- const _context = mergeContextFixtures(fixtures, context || {}, runner);
2658
- const originalWrapper = fn;
2659
- return createTest(function(name, optionsOrFn, optionsOrTest) {
2660
- const collector = getCurrentSuite();
2661
- const scopedFixtures = collector.fixtures();
2662
- const context2 = { ...this };
2663
- if (scopedFixtures) {
2664
- context2.fixtures = mergeScopedFixtures(context2.fixtures || [], scopedFixtures);
2665
- }
2666
- originalWrapper.call(context2, formatName(name), optionsOrFn, optionsOrTest);
2667
- }, _context);
3063
+ taskFn.extend = function(fixturesOrName, optionsOrFn, maybeFn) {
3064
+ const userFixtures = parseBuilderFixtures(fixturesOrName, optionsOrFn, maybeFn);
3065
+ const fixtures = getChainableContext(this).getFixtures().extend(runner, userFixtures);
3066
+ const _test3 = createTest(function(name, optionsOrFn2, optionsOrTest) {
3067
+ fn.call(this, formatName(name), optionsOrFn2, optionsOrTest);
3068
+ });
3069
+ getChainableContext(_test3).mergeContext({ fixtures });
3070
+ return _test3;
2668
3071
  };
3072
+ taskFn.describe = suite;
3073
+ taskFn.suite = suite;
2669
3074
  taskFn.beforeEach = beforeEach;
2670
3075
  taskFn.afterEach = afterEach;
2671
3076
  taskFn.beforeAll = beforeAll;
2672
3077
  taskFn.afterAll = afterAll;
3078
+ taskFn.aroundEach = aroundEach;
3079
+ taskFn.aroundAll = aroundAll;
2673
3080
  const _test2 = createChainable([
2674
3081
  "concurrent",
2675
3082
  "sequential",
@@ -2677,14 +3084,11 @@ function createTaskCollector(fn, context) {
2677
3084
  "only",
2678
3085
  "todo",
2679
3086
  "fails"
2680
- ], taskFn);
2681
- if (context) {
2682
- _test2.mergeContext(context);
2683
- }
3087
+ ], taskFn, { fixtures: new TestFixtures() });
2684
3088
  return _test2;
2685
3089
  }
2686
- function createTest(fn, context) {
2687
- return createTaskCollector(fn, context);
3090
+ function createTest(fn) {
3091
+ return createTaskCollector(fn);
2688
3092
  }
2689
3093
  function formatName(name) {
2690
3094
  return typeof name === "string" ? name : typeof name === "function" ? name.name || "<anonymous>" : String(name);
@@ -2709,14 +3113,13 @@ function formatTitle(template, items, idx) {
2709
3113
  const isObjectItem = isObject(items[0]);
2710
3114
  function formatAttribute(s3) {
2711
3115
  return s3.replace(/\$([$\w.]+)/g, (_, key) => {
2712
- var _runner$config;
2713
3116
  const isArrayKey = /^\d+$/.test(key);
2714
3117
  if (!isObjectItem && !isArrayKey) {
2715
3118
  return `$${key}`;
2716
3119
  }
2717
3120
  const arrayElement = isArrayKey ? objectAttr(items, key) : void 0;
2718
3121
  const value = isObjectItem ? objectAttr(items[0], key, arrayElement) : arrayElement;
2719
- return objDisplay(value, { truncate: runner === null || runner === void 0 || (_runner$config = runner.config) === null || _runner$config === void 0 || (_runner$config = _runner$config.chaiConfig) === null || _runner$config === void 0 ? void 0 : _runner$config.truncateThreshold });
3122
+ return objDisplay(value, { truncate: runner?.config?.chaiConfig?.truncateThreshold });
2720
3123
  });
2721
3124
  }
2722
3125
  let output = "";
@@ -2764,14 +3167,13 @@ function formatTemplateString(cases, args) {
2764
3167
  }
2765
3168
  return res;
2766
3169
  }
2767
- var now$2 = Date.now;
3170
+ var now$2 = globalThis.performance ? globalThis.performance.now.bind(globalThis.performance) : Date.now;
2768
3171
  var collectorContext = {
2769
3172
  tasks: [],
2770
3173
  currentSuite: null
2771
3174
  };
2772
3175
  function collectTask(task) {
2773
- var _collectorContext$cur;
2774
- (_collectorContext$cur = collectorContext.currentSuite) === null || _collectorContext$cur === void 0 ? void 0 : _collectorContext$cur.tasks.push(task);
3176
+ collectorContext.currentSuite?.tasks.push(task);
2775
3177
  }
2776
3178
  async function runWithSuite(suite2, fn) {
2777
3179
  const prev = collectorContext.currentSuite;
@@ -2790,15 +3192,14 @@ function withTimeout(fn, timeout, isHook = false, stackTraceError, onTimeout) {
2790
3192
  runner2._currentTaskStartTime = startTime;
2791
3193
  runner2._currentTaskTimeout = timeout;
2792
3194
  return new Promise((resolve_, reject_) => {
2793
- var _timer$unref;
2794
3195
  const timer = setTimeout3(() => {
2795
3196
  clearTimeout3(timer);
2796
3197
  rejectTimeoutError();
2797
3198
  }, timeout);
2798
- (_timer$unref = timer.unref) === null || _timer$unref === void 0 ? void 0 : _timer$unref.call(timer);
3199
+ timer.unref?.();
2799
3200
  function rejectTimeoutError() {
2800
3201
  const error = makeTimeoutError(isHook, timeout, stackTraceError);
2801
- onTimeout === null || onTimeout === void 0 ? void 0 : onTimeout(args, error);
3202
+ onTimeout?.(args, error);
2802
3203
  reject_(error);
2803
3204
  }
2804
3205
  function resolve(result) {
@@ -2830,6 +3231,23 @@ function withTimeout(fn, timeout, isHook = false, stackTraceError, onTimeout) {
2830
3231
  });
2831
3232
  });
2832
3233
  }
3234
+ function withCancel(fn, signal) {
3235
+ return (function runWithCancel(...args) {
3236
+ return new Promise((resolve, reject) => {
3237
+ signal.addEventListener("abort", () => reject(signal.reason));
3238
+ try {
3239
+ const result = fn(...args);
3240
+ if (typeof result === "object" && result != null && typeof result.then === "function") {
3241
+ result.then(resolve, reject);
3242
+ } else {
3243
+ resolve(result);
3244
+ }
3245
+ } catch (error) {
3246
+ reject(error);
3247
+ }
3248
+ });
3249
+ });
3250
+ }
2833
3251
  var abortControllers = /* @__PURE__ */ new WeakMap();
2834
3252
  function abortIfTimeout([context], error) {
2835
3253
  if (context) {
@@ -2838,10 +3256,9 @@ function abortIfTimeout([context], error) {
2838
3256
  }
2839
3257
  function abortContextSignal(context, error) {
2840
3258
  const abortController = abortControllers.get(context);
2841
- abortController === null || abortController === void 0 ? void 0 : abortController.abort(error);
3259
+ abortController?.abort(error);
2842
3260
  }
2843
3261
  function createTestContext(test3, runner2) {
2844
- var _runner$extendTaskCon;
2845
3262
  const context = function() {
2846
3263
  throw new Error("done() callback is deprecated, use promise instead");
2847
3264
  };
@@ -2856,7 +3273,7 @@ function createTestContext(test3, runner2) {
2856
3273
  if (condition === false) {
2857
3274
  return void 0;
2858
3275
  }
2859
- test3.result ?? (test3.result = { state: "skip" });
3276
+ test3.result ??= { state: "skip" };
2860
3277
  test3.result.pending = true;
2861
3278
  throw new PendingError("test is skipped; abort execution", test3, typeof condition === "string" ? condition : note);
2862
3279
  };
@@ -2887,32 +3304,24 @@ function createTestContext(test3, runner2) {
2887
3304
  }));
2888
3305
  });
2889
3306
  context.onTestFailed = (handler, timeout) => {
2890
- test3.onFailed || (test3.onFailed = []);
3307
+ test3.onFailed ||= [];
2891
3308
  test3.onFailed.push(withTimeout(handler, timeout ?? runner2.config.hookTimeout, true, new Error("STACK_TRACE_ERROR"), (_, error) => abortController.abort(error)));
2892
3309
  };
2893
3310
  context.onTestFinished = (handler, timeout) => {
2894
- test3.onFinished || (test3.onFinished = []);
3311
+ test3.onFinished ||= [];
2895
3312
  test3.onFinished.push(withTimeout(handler, timeout ?? runner2.config.hookTimeout, true, new Error("STACK_TRACE_ERROR"), (_, error) => abortController.abort(error)));
2896
3313
  };
2897
- return ((_runner$extendTaskCon = runner2.extendTaskContext) === null || _runner$extendTaskCon === void 0 ? void 0 : _runner$extendTaskCon.call(runner2, context)) || context;
3314
+ return runner2.extendTaskContext?.(context) || context;
2898
3315
  }
2899
3316
  function makeTimeoutError(isHook, timeout, stackTraceError) {
2900
3317
  const message = `${isHook ? "Hook" : "Test"} timed out in ${timeout}ms.
2901
3318
  If this is a long-running ${isHook ? "hook" : "test"}, pass a timeout value as the last argument or configure it globally with "${isHook ? "hookTimeout" : "testTimeout"}".`;
2902
3319
  const error = new Error(message);
2903
- if (stackTraceError === null || stackTraceError === void 0 ? void 0 : stackTraceError.stack) {
3320
+ if (stackTraceError?.stack) {
2904
3321
  error.stack = stackTraceError.stack.replace(error.message, stackTraceError.message);
2905
3322
  }
2906
3323
  return error;
2907
3324
  }
2908
- var fileContexts = /* @__PURE__ */ new WeakMap();
2909
- function getFileContext(file) {
2910
- const context = fileContexts.get(file);
2911
- if (!context) {
2912
- throw new Error(`Cannot find file context for ${file.name}`);
2913
- }
2914
- return context;
2915
- }
2916
3325
  var now$1 = globalThis.performance ? globalThis.performance.now.bind(globalThis.performance) : Date.now;
2917
3326
  var now = globalThis.performance ? globalThis.performance.now.bind(globalThis.performance) : Date.now;
2918
3327
  var unixNow = Date.now;
@@ -2922,7 +3331,6 @@ var eventsPacks = [];
2922
3331
  var pendingTasksUpdates = [];
2923
3332
  function sendTasksUpdate(runner2) {
2924
3333
  if (packs.size) {
2925
- var _runner$onTaskUpdate;
2926
3334
  const taskPacks = Array.from(packs).map(([id, task]) => {
2927
3335
  return [
2928
3336
  id,
@@ -2930,7 +3338,7 @@ function sendTasksUpdate(runner2) {
2930
3338
  task[1]
2931
3339
  ];
2932
3340
  });
2933
- const p2 = (_runner$onTaskUpdate = runner2.onTaskUpdate) === null || _runner$onTaskUpdate === void 0 ? void 0 : _runner$onTaskUpdate.call(runner2, taskPacks, eventsPacks);
3341
+ const p2 = runner2.onTaskUpdate?.(taskPacks, eventsPacks);
2934
3342
  if (p2) {
2935
3343
  pendingTasksUpdates.push(p2);
2936
3344
  p2.then(() => pendingTasksUpdates.splice(pendingTasksUpdates.indexOf(p2), 1), () => {
@@ -2955,15 +3363,12 @@ function throttle(fn, ms) {
2955
3363
  pendingCall = void 0;
2956
3364
  return fn.apply(this, args);
2957
3365
  }
2958
- pendingCall ?? (pendingCall = setTimeout2(() => call.bind(this)(...args), ms));
3366
+ pendingCall ??= setTimeout2(() => call.bind(this)(...args), ms);
2959
3367
  };
2960
3368
  }
2961
3369
  var sendTasksUpdateThrottled = throttle(sendTasksUpdate, 100);
2962
3370
  async function recordArtifact(task, artifact) {
2963
3371
  const runner2 = getRunner();
2964
- if (task.result && task.result.state !== "run") {
2965
- throw new Error(`Cannot record a test artifact outside of the test run. The test "${task.name}" finished running with the "${task.result.state}" state already.`);
2966
- }
2967
3372
  const stack = findTestFileStackTrace(task.file.filepath, new Error("STACK_TRACE").stack);
2968
3373
  if (stack) {
2969
3374
  artifact.location = {
@@ -3007,28 +3412,28 @@ function encodeUint8Array(bytes) {
3007
3412
  const len = bytes.byteLength;
3008
3413
  for (let i3 = 0; i3 < len; i3 += 3) {
3009
3414
  if (len === i3 + 1) {
3010
- const a3 = (bytes[i3] & 252) >> 2;
3415
+ const a4 = (bytes[i3] & 252) >> 2;
3011
3416
  const b4 = (bytes[i3] & 3) << 4;
3012
- base64 += table[a3];
3417
+ base64 += table[a4];
3013
3418
  base64 += table[b4];
3014
3419
  base64 += "==";
3015
3420
  } else if (len === i3 + 2) {
3016
- const a3 = (bytes[i3] & 252) >> 2;
3421
+ const a4 = (bytes[i3] & 252) >> 2;
3017
3422
  const b4 = (bytes[i3] & 3) << 4 | (bytes[i3 + 1] & 240) >> 4;
3018
3423
  const c3 = (bytes[i3 + 1] & 15) << 2;
3019
- base64 += table[a3];
3424
+ base64 += table[a4];
3020
3425
  base64 += table[b4];
3021
3426
  base64 += table[c3];
3022
3427
  base64 += "=";
3023
3428
  } else {
3024
- const a3 = (bytes[i3] & 252) >> 2;
3429
+ const a4 = (bytes[i3] & 252) >> 2;
3025
3430
  const b4 = (bytes[i3] & 3) << 4 | (bytes[i3 + 1] & 240) >> 4;
3026
3431
  const c3 = (bytes[i3 + 1] & 15) << 2 | (bytes[i3 + 2] & 192) >> 6;
3027
- const d4 = bytes[i3 + 2] & 63;
3028
- base64 += table[a3];
3432
+ const d3 = bytes[i3 + 2] & 63;
3433
+ base64 += table[a4];
3029
3434
  base64 += table[b4];
3030
3435
  base64 += table[c3];
3031
- base64 += table[d4];
3436
+ base64 += table[d3];
3032
3437
  }
3033
3438
  }
3034
3439
  return base64;
@@ -3061,15 +3466,16 @@ function manageArtifactAttachment(attachment) {
3061
3466
  }
3062
3467
  }
3063
3468
 
3064
- // ../../node_modules/.pnpm/vitest@4.0.18_@types+node@25.3.0_jiti@2.6.1_lightningcss@1.30.2_terser@5.44.1_yaml@2.8.2/node_modules/vitest/dist/index.js
3065
- import "./chunks/utils.DvEY5TfP.js.mjs";
3469
+ // ../../node_modules/.pnpm/vitest@4.1.0_@opentelemetry+api@1.9.0_@types+node@25.3.0_vite@7.3.1_@types+node@25.3.0__1256cd9683254972294f67b42fe9fd18/node_modules/vitest/dist/index.js
3470
+ import "./chunks/utils.BX5Fg8C4.js.mjs";
3066
3471
 
3067
- // ../../node_modules/.pnpm/@vitest+runner@4.0.18/node_modules/@vitest/runner/dist/utils.js
3068
- import { a, c, b, e, f as f2, g as g2, d as d2, h as h2, j, k, m, n, o, q, r, i, t, l, p, s } from "./chunk-tasks.js.mjs";
3472
+ // ../../node_modules/.pnpm/@vitest+runner@4.1.0/node_modules/@vitest/runner/dist/utils.js
3473
+ import { c, a, b, d as d2, e, f as f2, g as g2, h as h2, i, j, k, l, m, n, o, p, q, r, s, t, u, v } from "./chunk-tasks.js.mjs";
3069
3474
 
3070
- // ../../node_modules/.pnpm/vitest@4.0.18_@types+node@25.3.0_jiti@2.6.1_lightningcss@1.30.2_terser@5.44.1_yaml@2.8.2/node_modules/vitest/dist/index.js
3475
+ // ../../node_modules/.pnpm/vitest@4.1.0_@opentelemetry+api@1.9.0_@types+node@25.3.0_vite@7.3.1_@types+node@25.3.0__1256cd9683254972294f67b42fe9fd18/node_modules/vitest/dist/index.js
3071
3476
  import "./chunks/_commonjsHelpers.D26ty3Ew.js.mjs";
3072
- import "./chunks/date.Bq6ZW5rf.js.mjs";
3477
+ import "./chunks/rpc.MzXet3jl.js.mjs";
3478
+ import "./chunks/index.Chj8NDwU.js.mjs";
3073
3479
 
3074
3480
  // ../../node_modules/.pnpm/vite@7.3.1_@types+node@25.3.0_jiti@2.6.1_lightningcss@1.30.2_terser@5.44.1_yaml@2.8.2/node_modules/vite/dist/node/module-runner.js
3075
3481
  var SOURCEMAPPING_URL = "sourceMa";