@effect-uai/google 0.15.0 → 0.16.0

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 (44) hide show
  1. package/README.md +11 -2
  2. package/dist/Gemini.d.mts +1 -1
  3. package/dist/GeminiEmbedding.d.mts +1 -1
  4. package/dist/GeminiImageGenerator.d.mts +1 -1
  5. package/dist/GeminiLiveSession.d.mts +17 -0
  6. package/dist/GeminiLiveSession.d.mts.map +1 -0
  7. package/dist/GeminiLiveSession.mjs +26 -0
  8. package/dist/GeminiLiveSession.mjs.map +1 -0
  9. package/dist/GeminiSynthesizer.d.mts +1 -1
  10. package/dist/GeminiSynthesizer.test.mjs +1 -1
  11. package/dist/GoogleDeepResearch.d.mts +1 -1
  12. package/dist/GoogleDeepResearch.test.mjs +1 -1
  13. package/dist/LyriaGenerator.d.mts +1 -1
  14. package/dist/LyriaGenerator.test.mjs +1 -1
  15. package/dist/codec.d.mts +5 -2
  16. package/dist/codec.d.mts.map +1 -1
  17. package/dist/codec.mjs +4 -1
  18. package/dist/codec.mjs.map +1 -1
  19. package/dist/geminiSpeechCodec.test.mjs +1 -1
  20. package/dist/geminiTools.test.mjs +1 -1
  21. package/dist/index.d.mts +3 -2
  22. package/dist/index.mjs +2 -1
  23. package/dist/models-BVSKJwCx.d.mts +87 -0
  24. package/dist/models-BVSKJwCx.d.mts.map +1 -0
  25. package/dist/models.d.mts +2 -75
  26. package/dist/realtimeSession-7HSIjWh4.d.mts +62 -0
  27. package/dist/realtimeSession-7HSIjWh4.d.mts.map +1 -0
  28. package/dist/realtimeSession.d.mts +2 -0
  29. package/dist/realtimeSession.mjs +406 -0
  30. package/dist/realtimeSession.mjs.map +1 -0
  31. package/dist/realtimeSession.test.d.mts +1 -0
  32. package/dist/realtimeSession.test.mjs +505 -0
  33. package/dist/realtimeSession.test.mjs.map +1 -0
  34. package/dist/{test.DNmyFkvJ-N3QqMRwZ.mjs → test.DNmyFkvJ-BPz3G1HS.mjs} +531 -22
  35. package/dist/test.DNmyFkvJ-BPz3G1HS.mjs.map +1 -0
  36. package/package.json +6 -2
  37. package/src/GeminiLiveSession.ts +45 -0
  38. package/src/codec.ts +3 -2
  39. package/src/index.ts +1 -0
  40. package/src/models.ts +19 -0
  41. package/src/realtimeSession.test.ts +415 -0
  42. package/src/realtimeSession.ts +807 -0
  43. package/dist/models.d.mts.map +0 -1
  44. package/dist/test.DNmyFkvJ-N3QqMRwZ.mjs.map +0 -1
@@ -3148,31 +3148,31 @@ function delay(timeout, scheduler = setTimeout) {
3148
3148
  }
3149
3149
  //#endregion
3150
3150
  //#region ../../../node_modules/.pnpm/@vitest+utils@4.1.11/node_modules/@vitest/utils/dist/chunk-pathe.M-eThtNZ.js
3151
- const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
3152
- function normalizeWindowsPath(input = "") {
3151
+ const _DRIVE_LETTER_START_RE$1 = /^[A-Za-z]:\//;
3152
+ function normalizeWindowsPath$1(input = "") {
3153
3153
  if (!input) return input;
3154
- return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
3154
+ return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE$1, (r) => r.toUpperCase());
3155
3155
  }
3156
- const _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
3156
+ const _IS_ABSOLUTE_RE$1 = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
3157
3157
  function cwd() {
3158
3158
  if (typeof process !== "undefined" && typeof process.cwd === "function") return process.cwd().replace(/\\/g, "/");
3159
3159
  return "/";
3160
3160
  }
3161
3161
  const resolve = function(...arguments_) {
3162
- arguments_ = arguments_.map((argument) => normalizeWindowsPath(argument));
3162
+ arguments_ = arguments_.map((argument) => normalizeWindowsPath$1(argument));
3163
3163
  let resolvedPath = "";
3164
3164
  let resolvedAbsolute = false;
3165
3165
  for (let index = arguments_.length - 1; index >= -1 && !resolvedAbsolute; index--) {
3166
3166
  const path = index >= 0 ? arguments_[index] : cwd();
3167
3167
  if (!path || path.length === 0) continue;
3168
3168
  resolvedPath = `${path}/${resolvedPath}`;
3169
- resolvedAbsolute = isAbsolute(path);
3169
+ resolvedAbsolute = isAbsolute$1(path);
3170
3170
  }
3171
- resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute);
3172
- if (resolvedAbsolute && !isAbsolute(resolvedPath)) return `/${resolvedPath}`;
3171
+ resolvedPath = normalizeString$1(resolvedPath, !resolvedAbsolute);
3172
+ if (resolvedAbsolute && !isAbsolute$1(resolvedPath)) return `/${resolvedPath}`;
3173
3173
  return resolvedPath.length > 0 ? resolvedPath : ".";
3174
3174
  };
3175
- function normalizeString(path, allowAboveRoot) {
3175
+ function normalizeString$1(path, allowAboveRoot) {
3176
3176
  let res = "";
3177
3177
  let lastSegmentLength = 0;
3178
3178
  let lastSlash = -1;
@@ -3222,8 +3222,8 @@ function normalizeString(path, allowAboveRoot) {
3222
3222
  }
3223
3223
  return res;
3224
3224
  }
3225
- const isAbsolute = function(p) {
3226
- return _IS_ABSOLUTE_RE.test(p);
3225
+ const isAbsolute$1 = function(p) {
3226
+ return _IS_ABSOLUTE_RE$1.test(p);
3227
3227
  };
3228
3228
  //#endregion
3229
3229
  //#region ../../../node_modules/.pnpm/@vitest+utils@4.1.11/node_modules/@vitest/utils/dist/source-map.js
@@ -3594,6 +3594,88 @@ function getOriginalPosition(map, needle) {
3594
3594
  return result;
3595
3595
  }
3596
3596
  //#endregion
3597
+ //#region ../../../node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs
3598
+ const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
3599
+ function normalizeWindowsPath(input = "") {
3600
+ if (!input) return input;
3601
+ return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
3602
+ }
3603
+ const _UNC_REGEX = /^[/\\]{2}/;
3604
+ const _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
3605
+ const _DRIVE_LETTER_RE = /^[A-Za-z]:$/;
3606
+ const normalize = function(path) {
3607
+ if (path.length === 0) return ".";
3608
+ path = normalizeWindowsPath(path);
3609
+ const isUNCPath = path.match(_UNC_REGEX);
3610
+ const isPathAbsolute = isAbsolute(path);
3611
+ const trailingSeparator = path[path.length - 1] === "/";
3612
+ path = normalizeString(path, !isPathAbsolute);
3613
+ if (path.length === 0) {
3614
+ if (isPathAbsolute) return "/";
3615
+ return trailingSeparator ? "./" : ".";
3616
+ }
3617
+ if (trailingSeparator) path += "/";
3618
+ if (_DRIVE_LETTER_RE.test(path)) path += "/";
3619
+ if (isUNCPath) {
3620
+ if (!isPathAbsolute) return `//./${path}`;
3621
+ return `//${path}`;
3622
+ }
3623
+ return isPathAbsolute && !isAbsolute(path) ? `/${path}` : path;
3624
+ };
3625
+ function normalizeString(path, allowAboveRoot) {
3626
+ let res = "";
3627
+ let lastSegmentLength = 0;
3628
+ let lastSlash = -1;
3629
+ let dots = 0;
3630
+ let char = null;
3631
+ for (let index = 0; index <= path.length; ++index) {
3632
+ if (index < path.length) char = path[index];
3633
+ else if (char === "/") break;
3634
+ else char = "/";
3635
+ if (char === "/") {
3636
+ if (lastSlash === index - 1 || dots === 1);
3637
+ else if (dots === 2) {
3638
+ if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
3639
+ if (res.length > 2) {
3640
+ const lastSlashIndex = res.lastIndexOf("/");
3641
+ if (lastSlashIndex === -1) {
3642
+ res = "";
3643
+ lastSegmentLength = 0;
3644
+ } else {
3645
+ res = res.slice(0, lastSlashIndex);
3646
+ lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
3647
+ }
3648
+ lastSlash = index;
3649
+ dots = 0;
3650
+ continue;
3651
+ } else if (res.length > 0) {
3652
+ res = "";
3653
+ lastSegmentLength = 0;
3654
+ lastSlash = index;
3655
+ dots = 0;
3656
+ continue;
3657
+ }
3658
+ }
3659
+ if (allowAboveRoot) {
3660
+ res += res.length > 0 ? "/.." : "..";
3661
+ lastSegmentLength = 2;
3662
+ }
3663
+ } else {
3664
+ if (res.length > 0) res += `/${path.slice(lastSlash + 1, index)}`;
3665
+ else res = path.slice(lastSlash + 1, index);
3666
+ lastSegmentLength = index - lastSlash - 1;
3667
+ }
3668
+ lastSlash = index;
3669
+ dots = 0;
3670
+ } else if (char === "." && dots !== -1) ++dots;
3671
+ else dots = -1;
3672
+ }
3673
+ return res;
3674
+ }
3675
+ const isAbsolute = function(p) {
3676
+ return _IS_ABSOLUTE_RE.test(p);
3677
+ };
3678
+ //#endregion
3597
3679
  //#region ../../../node_modules/.pnpm/@vitest+runner@4.1.11/node_modules/@vitest/runner/dist/chunk-artifact.js
3598
3680
  var PendingError = class extends Error {
3599
3681
  code = "VITEST_PENDING";
@@ -3620,6 +3702,9 @@ const hooksMap = /* @__PURE__ */ new WeakMap();
3620
3702
  function setFn(key, fn) {
3621
3703
  fnMap.set(key, fn);
3622
3704
  }
3705
+ function getFn(key) {
3706
+ return fnMap.get(key);
3707
+ }
3623
3708
  function setTestFixture(key, fixture) {
3624
3709
  testFixtureMap.set(key, fixture);
3625
3710
  }
@@ -3974,6 +4059,7 @@ function splitByComma(s) {
3974
4059
  if (lastToken) result.push(lastToken);
3975
4060
  return result;
3976
4061
  }
4062
+ function getCurrentTest() {}
3977
4063
  const kChainableContext = Symbol("kChainableContext");
3978
4064
  function getChainableContext(chainable) {
3979
4065
  return chainable?.[kChainableContext];
@@ -4226,6 +4312,21 @@ function findTestFileStackTrace(testFilePath, error) {
4226
4312
  if (stack && stack.file === testFilePath) return stack;
4227
4313
  }
4228
4314
  }
4315
+ const filterMap = /* @__PURE__ */ new WeakMap();
4316
+ /**
4317
+ * @experimental
4318
+ */
4319
+ function matchesTags(testTags) {
4320
+ const runner = getRunner();
4321
+ const tagsFilter = runner._currentSpecification?.testTagsFilter ?? runner.config.tagsFilter;
4322
+ if (!tagsFilter) return true;
4323
+ let tagsFilterPredicate = filterMap.get(tagsFilter);
4324
+ if (!tagsFilterPredicate) {
4325
+ tagsFilterPredicate = createTagsFilter(tagsFilter, runner.config.tags);
4326
+ filterMap.set(tagsFilter, tagsFilterPredicate);
4327
+ }
4328
+ return tagsFilterPredicate(testTags);
4329
+ }
4229
4330
  function validateTags(config, tags) {
4230
4331
  if (!config.strictTags) return;
4231
4332
  const availableTags = new Set(config.tags.map((tag) => tag.name));
@@ -4235,6 +4336,215 @@ function createNoTagsError(availableTags, tag, prefix = "tag") {
4235
4336
  if (!availableTags.length) throw new Error(`The Vitest config does't define any "tags", cannot apply "${tag}" ${prefix} for this test. See: https://vitest.dev/guide/test-tags`);
4236
4337
  throw new Error(`The ${prefix} "${tag}" is not defined in the configuration. Available tags are:\n${availableTags.map((t) => `- ${t.name}${t.description ? `: ${t.description}` : ""}`).join("\n")}`);
4237
4338
  }
4339
+ function createTagsFilter(tagsExpr, availableTags) {
4340
+ const matchers = tagsExpr.map((expr) => parseTagsExpression(expr, availableTags));
4341
+ return (testTags) => {
4342
+ return matchers.every((matcher) => matcher(testTags));
4343
+ };
4344
+ }
4345
+ function parseTagsExpression(expr, availableTags) {
4346
+ const stream = new TokenStream(tokenize(expr), expr);
4347
+ const ast = parseOrExpression(stream, availableTags);
4348
+ if (stream.peek().type !== "EOF") throw new Error(`Invalid tags expression: unexpected "${formatToken(stream.peek())}" in "${expr}"`);
4349
+ return (tags) => evaluateNode(ast, tags);
4350
+ }
4351
+ function formatToken(token) {
4352
+ switch (token.type) {
4353
+ case "TAG": return token.value;
4354
+ default: return formatTokenType(token.type);
4355
+ }
4356
+ }
4357
+ function tokenize(expr) {
4358
+ const tokens = [];
4359
+ let i = 0;
4360
+ while (i < expr.length) {
4361
+ if (expr[i] === " " || expr[i] === " ") {
4362
+ i++;
4363
+ continue;
4364
+ }
4365
+ if (expr[i] === "(") {
4366
+ tokens.push({ type: "LPAREN" });
4367
+ i++;
4368
+ continue;
4369
+ }
4370
+ if (expr[i] === ")") {
4371
+ tokens.push({ type: "RPAREN" });
4372
+ i++;
4373
+ continue;
4374
+ }
4375
+ if (expr[i] === "!") {
4376
+ tokens.push({ type: "NOT" });
4377
+ i++;
4378
+ continue;
4379
+ }
4380
+ if (expr.slice(i, i + 2) === "&&") {
4381
+ tokens.push({ type: "AND" });
4382
+ i += 2;
4383
+ continue;
4384
+ }
4385
+ if (expr.slice(i, i + 2) === "||") {
4386
+ tokens.push({ type: "OR" });
4387
+ i += 2;
4388
+ continue;
4389
+ }
4390
+ if (/^and(?:\s|\)|$)/i.test(expr.slice(i))) {
4391
+ tokens.push({ type: "AND" });
4392
+ i += 3;
4393
+ continue;
4394
+ }
4395
+ if (/^or(?:\s|\)|$)/i.test(expr.slice(i))) {
4396
+ tokens.push({ type: "OR" });
4397
+ i += 2;
4398
+ continue;
4399
+ }
4400
+ if (/^not\s/i.test(expr.slice(i))) {
4401
+ tokens.push({ type: "NOT" });
4402
+ i += 3;
4403
+ continue;
4404
+ }
4405
+ let tag = "";
4406
+ while (i < expr.length && expr[i] !== " " && expr[i] !== " " && expr[i] !== "(" && expr[i] !== ")" && expr[i] !== "!" && expr[i] !== "&" && expr[i] !== "|") {
4407
+ const remaining = expr.slice(i);
4408
+ if (tag === "" && (/^and(?:\s|\)|$)/i.test(remaining) || /^or(?:\s|\)|$)/i.test(remaining) || /^not\s/i.test(remaining))) break;
4409
+ tag += expr[i];
4410
+ i++;
4411
+ }
4412
+ if (tag) tokens.push({
4413
+ type: "TAG",
4414
+ value: tag
4415
+ });
4416
+ }
4417
+ tokens.push({ type: "EOF" });
4418
+ return tokens;
4419
+ }
4420
+ var TokenStream = class {
4421
+ pos = 0;
4422
+ constructor(tokens, expr) {
4423
+ this.tokens = tokens;
4424
+ this.expr = expr;
4425
+ }
4426
+ peek() {
4427
+ return this.tokens[this.pos];
4428
+ }
4429
+ next() {
4430
+ return this.tokens[this.pos++];
4431
+ }
4432
+ expect(type) {
4433
+ const token = this.next();
4434
+ if (token.type !== type) {
4435
+ if (type === "RPAREN" && token.type === "EOF") throw new Error(`Invalid tags expression: missing closing ")" in "${this.expr}"`);
4436
+ throw new Error(`Invalid tags expression: expected "${formatTokenType(type)}" but got "${formatToken(token)}" in "${this.expr}"`);
4437
+ }
4438
+ return token;
4439
+ }
4440
+ unexpectedToken() {
4441
+ const token = this.peek();
4442
+ if (token.type === "EOF") throw new Error(`Invalid tags expression: unexpected end of expression in "${this.expr}"`);
4443
+ throw new Error(`Invalid tags expression: unexpected "${formatToken(token)}" in "${this.expr}"`);
4444
+ }
4445
+ };
4446
+ function formatTokenType(type) {
4447
+ switch (type) {
4448
+ case "TAG": return "tag";
4449
+ case "AND": return "and";
4450
+ case "OR": return "or";
4451
+ case "NOT": return "not";
4452
+ case "LPAREN": return "(";
4453
+ case "RPAREN": return ")";
4454
+ case "EOF": return "end of expression";
4455
+ }
4456
+ }
4457
+ function parseOrExpression(stream, availableTags) {
4458
+ let left = parseAndExpression(stream, availableTags);
4459
+ while (stream.peek().type === "OR") {
4460
+ stream.next();
4461
+ const right = parseAndExpression(stream, availableTags);
4462
+ left = {
4463
+ type: "or",
4464
+ left,
4465
+ right
4466
+ };
4467
+ }
4468
+ return left;
4469
+ }
4470
+ function parseAndExpression(stream, availableTags) {
4471
+ let left = parseUnaryExpression(stream, availableTags);
4472
+ while (stream.peek().type === "AND") {
4473
+ stream.next();
4474
+ const right = parseUnaryExpression(stream, availableTags);
4475
+ left = {
4476
+ type: "and",
4477
+ left,
4478
+ right
4479
+ };
4480
+ }
4481
+ return left;
4482
+ }
4483
+ function parseUnaryExpression(stream, availableTags) {
4484
+ if (stream.peek().type === "NOT") {
4485
+ stream.next();
4486
+ return {
4487
+ type: "not",
4488
+ operand: parseUnaryExpression(stream, availableTags)
4489
+ };
4490
+ }
4491
+ return parsePrimaryExpression(stream, availableTags);
4492
+ }
4493
+ function parsePrimaryExpression(stream, availableTags) {
4494
+ const token = stream.peek();
4495
+ if (token.type === "LPAREN") {
4496
+ stream.next();
4497
+ const expr = parseOrExpression(stream, availableTags);
4498
+ stream.expect("RPAREN");
4499
+ return expr;
4500
+ }
4501
+ if (token.type === "TAG") {
4502
+ stream.next();
4503
+ const tagValue = token.value;
4504
+ return {
4505
+ type: "tag",
4506
+ value: tagValue,
4507
+ pattern: resolveTagPattern(tagValue, availableTags)
4508
+ };
4509
+ }
4510
+ stream.unexpectedToken();
4511
+ }
4512
+ function createWildcardRegex(pattern) {
4513
+ return new RegExp(`^${pattern.replace(/[.+?^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".*")}$`);
4514
+ }
4515
+ function resolveTagPattern(tagPattern, availableTags) {
4516
+ if (tagPattern.includes("*")) {
4517
+ const regex = createWildcardRegex(tagPattern);
4518
+ if (!availableTags.some((tag) => regex.test(tag.name))) throw createNoTagsError(availableTags, tagPattern, "tag pattern");
4519
+ return regex;
4520
+ }
4521
+ if (!availableTags.length || !availableTags.some((tag) => tag.name === tagPattern)) throw createNoTagsError(availableTags, tagPattern, "tag pattern");
4522
+ return null;
4523
+ }
4524
+ function evaluateNode(node, tags) {
4525
+ switch (node.type) {
4526
+ case "tag":
4527
+ if (node.pattern) return tags.some((tag) => node.pattern.test(tag));
4528
+ return tags.includes(node.value);
4529
+ case "not": return !evaluateNode(node.operand, tags);
4530
+ case "and": return evaluateNode(node.left, tags) && evaluateNode(node.right, tags);
4531
+ case "or": return evaluateNode(node.left, tags) || evaluateNode(node.right, tags);
4532
+ }
4533
+ }
4534
+ function isTestCase(s) {
4535
+ return s.type === "test";
4536
+ }
4537
+ function getTests(suite) {
4538
+ const tests = [];
4539
+ const arraySuites = toArray(suite);
4540
+ for (const s of arraySuites) if (isTestCase(s)) tests.push(s);
4541
+ else for (const task of s.tasks) if (isTestCase(task)) tests.push(task);
4542
+ else {
4543
+ const taskTests = getTests(task);
4544
+ for (const test of taskTests) tests.push(test);
4545
+ }
4546
+ return tests;
4547
+ }
4238
4548
  function getNames(task) {
4239
4549
  const names = [task.name];
4240
4550
  let current = task;
@@ -4245,6 +4555,9 @@ function getNames(task) {
4245
4555
  if (current !== task.file) names.unshift(task.file.name);
4246
4556
  return names;
4247
4557
  }
4558
+ function getTestName(task, separator = " > ") {
4559
+ return getNames(task).slice(1).join(separator);
4560
+ }
4248
4561
  function createTaskName(names, separator = " > ") {
4249
4562
  return names.filter((name) => name !== void 0).join(separator);
4250
4563
  }
@@ -4309,7 +4622,7 @@ const suite = createSuite();
4309
4622
  * ```
4310
4623
  */
4311
4624
  const test$2 = createTest(function(name, optionsOrFn, optionsOrTest) {
4312
- getCurrentSuite().test.fn.call(this, formatName(name), optionsOrFn, optionsOrTest);
4625
+ getCurrentSuite().test.fn.call(this, formatName$1(name), optionsOrFn, optionsOrTest);
4313
4626
  });
4314
4627
  /**
4315
4628
  * Creates a suite of tests, allowing for grouping and hierarchical organization of tests.
@@ -4499,7 +4812,7 @@ function createSuiteCollector(name, factory = () => {}, mode, each, suiteOptions
4499
4812
  if (options.concurrent != null && concurrent != null) options.concurrent = concurrent;
4500
4813
  const sequential = this.sequential ?? (!this.concurrent && options?.sequential);
4501
4814
  if (options.sequential != null && sequential != null) options.sequential = sequential;
4502
- const test = task(formatName(name), {
4815
+ const test = task(formatName$1(name), {
4503
4816
  ...this,
4504
4817
  ...options,
4505
4818
  handler
@@ -4592,7 +4905,7 @@ function createSuite() {
4592
4905
  if (isConcurrent != null) options.concurrent = isConcurrent && !isSequential;
4593
4906
  if (isSequential != null) options.sequential = isSequential && !isConcurrent;
4594
4907
  if (parentMeta) options.meta = Object.assign(Object.create(null), parentMeta, options.meta);
4595
- return createSuiteCollector(formatName(name), factory, mode, this.each, options);
4908
+ return createSuiteCollector(formatName$1(name), factory, mode, this.each, options);
4596
4909
  }
4597
4910
  suiteFn.each = function(cases, ...args) {
4598
4911
  const context = getChainableContext(this);
@@ -4600,7 +4913,7 @@ function createSuite() {
4600
4913
  context.setContext("each", true);
4601
4914
  if (Array.isArray(cases) && args.length) cases = formatTemplateString(cases, args);
4602
4915
  return (name, optionsOrFn, fnOrOptions) => {
4603
- const _name = formatName(name);
4916
+ const _name = formatName$1(name);
4604
4917
  const arrayOnlyCases = cases.every(Array.isArray);
4605
4918
  const { options, handler } = parseArguments(optionsOrFn, fnOrOptions);
4606
4919
  const fnFirst = typeof optionsOrFn === "function";
@@ -4618,7 +4931,7 @@ function createSuite() {
4618
4931
  suiteFn.for = function(cases, ...args) {
4619
4932
  if (Array.isArray(cases) && args.length) cases = formatTemplateString(cases, args);
4620
4933
  return (name, optionsOrFn, fnOrOptions) => {
4621
- const name_ = formatName(name);
4934
+ const name_ = formatName$1(name);
4622
4935
  const { options, handler } = parseArguments(optionsOrFn, fnOrOptions);
4623
4936
  cases.forEach((item, idx) => {
4624
4937
  suite(formatTitle(name_, toArray(item), idx), options, handler ? () => handler(item) : void 0);
@@ -4644,7 +4957,7 @@ function createTaskCollector(fn) {
4644
4957
  context.setContext("each", true);
4645
4958
  if (Array.isArray(cases) && args.length) cases = formatTemplateString(cases, args);
4646
4959
  return (name, optionsOrFn, fnOrOptions) => {
4647
- const _name = formatName(name);
4960
+ const _name = formatName$1(name);
4648
4961
  const arrayOnlyCases = cases.every(Array.isArray);
4649
4962
  const { options, handler } = parseArguments(optionsOrFn, fnOrOptions);
4650
4963
  const fnFirst = typeof optionsOrFn === "function";
@@ -4663,7 +4976,7 @@ function createTaskCollector(fn) {
4663
4976
  const test = getChainableContext(this).withContext();
4664
4977
  if (Array.isArray(cases) && args.length) cases = formatTemplateString(cases, args);
4665
4978
  return (name, optionsOrFn, fnOrOptions) => {
4666
- const _name = formatName(name);
4979
+ const _name = formatName$1(name);
4667
4980
  const { options, handler } = parseArguments(optionsOrFn, fnOrOptions);
4668
4981
  cases.forEach((item, idx) => {
4669
4982
  const handlerWrapper = handler ? (ctx) => handler(item, ctx) : void 0;
@@ -4731,7 +5044,7 @@ function createTaskCollector(fn) {
4731
5044
  const userFixtures = parseBuilderFixtures(fixturesOrName, optionsOrFn, maybeFn);
4732
5045
  const fixtures = getChainableContext(this).getFixtures().extend(runner, userFixtures);
4733
5046
  const _test = createTest(function(name, optionsOrFn, optionsOrTest) {
4734
- fn.call(this, formatName(name), optionsOrFn, optionsOrTest);
5047
+ fn.call(this, formatName$1(name), optionsOrFn, optionsOrTest);
4735
5048
  });
4736
5049
  getChainableContext(_test).mergeContext({ fixtures });
4737
5050
  return _test;
@@ -4756,7 +5069,7 @@ function createTaskCollector(fn) {
4756
5069
  function createTest(fn) {
4757
5070
  return createTaskCollector(fn);
4758
5071
  }
4759
- function formatName(name) {
5072
+ function formatName$1(name) {
4760
5073
  return typeof name === "string" ? name : typeof name === "function" ? name.name || "<anonymous>" : String(name);
4761
5074
  }
4762
5075
  function formatTitle(template, items, idx) {
@@ -5135,6 +5448,39 @@ async function waitForImportsToResolve() {
5135
5448
  await waitForImportsToResolve();
5136
5449
  }
5137
5450
  //#endregion
5451
+ //#region ../../../node_modules/.pnpm/vitest@4.1.11_@types+node@26.2.0_vite@7.3.2_@types+node@26.2.0_jiti@2.6.1_lightningcss@1.32.0_tsx@4.23.12_yaml@2.9.0_/node_modules/vitest/dist/chunks/benchmark.CX_oY03V.js
5452
+ const benchFns = /* @__PURE__ */ new WeakMap();
5453
+ const benchOptsMap = /* @__PURE__ */ new WeakMap();
5454
+ function getBenchOptions(key) {
5455
+ return benchOptsMap.get(key);
5456
+ }
5457
+ function getBenchFn(key) {
5458
+ return benchFns.get(key);
5459
+ }
5460
+ createBenchmark(function(name, fn = noop, options = {}) {
5461
+ if (getWorkerState().config.mode !== "benchmark") throw new Error("`bench()` is only available in benchmark mode.");
5462
+ const task = getCurrentSuite().task(formatName(name), {
5463
+ ...this,
5464
+ meta: { benchmark: true }
5465
+ });
5466
+ benchFns.set(task, fn);
5467
+ benchOptsMap.set(task, options);
5468
+ if (!this.todo && task.mode === "todo") task.mode = "run";
5469
+ });
5470
+ function createBenchmark(fn) {
5471
+ const benchmark = createChainable([
5472
+ "skip",
5473
+ "only",
5474
+ "todo"
5475
+ ], fn);
5476
+ benchmark.skipIf = (condition) => condition ? benchmark.skip : benchmark;
5477
+ benchmark.runIf = (condition) => condition ? benchmark : benchmark.skip;
5478
+ return benchmark;
5479
+ }
5480
+ function formatName(name) {
5481
+ return typeof name === "string" ? name : typeof name === "function" ? name.name || "<anonymous>" : String(name);
5482
+ }
5483
+ //#endregion
5138
5484
  //#region ../../../node_modules/.pnpm/@vitest+spy@4.1.11/node_modules/@vitest/spy/dist/index.js
5139
5485
  function isMockFunction(fn) {
5140
5486
  return typeof fn === "function" && "_isMockFunction" in fn && fn._isMockFunction === true;
@@ -10048,6 +10394,10 @@ function resetDate() {
10048
10394
  globalThis.Date = RealDate;
10049
10395
  }
10050
10396
  const { get } = Reflect;
10397
+ function rpc() {
10398
+ const { rpc } = getWorkerState();
10399
+ return rpc;
10400
+ }
10051
10401
  //#endregion
10052
10402
  //#region ../../../node_modules/.pnpm/@vitest+snapshot@4.1.11/node_modules/@vitest/snapshot/dist/index.js
10053
10403
  function getDefaultExportFromCjs(x) {
@@ -13652,7 +14002,166 @@ Object.defineProperty(globalThis, GLOBAL_EXPECT, {
13652
14002
  writable: true,
13653
14003
  configurable: true
13654
14004
  });
14005
+ /**
14006
+ * Gives access to injected context provided from the main thread.
14007
+ * This usually returns a value provided by `globalSetup` or an external library.
14008
+ */
14009
+ function inject(key) {
14010
+ return getWorkerState().providedContext[key];
14011
+ }
14012
+ var TestRunner = class {
14013
+ snapshotClient = getSnapshotClient();
14014
+ workerState = getWorkerState();
14015
+ moduleRunner;
14016
+ cancelRun = false;
14017
+ assertionsErrors = /* @__PURE__ */ new WeakMap();
14018
+ pool = this.workerState.ctx.pool;
14019
+ _otel;
14020
+ viteEnvironment;
14021
+ viteModuleRunner;
14022
+ constructor(config) {
14023
+ this.config = config;
14024
+ const environment = this.workerState.environment;
14025
+ this.viteEnvironment = environment.viteEnvironment || environment.name;
14026
+ this.viteModuleRunner = config.experimental.viteModuleRunner;
14027
+ }
14028
+ importFile(filepath, source) {
14029
+ if (source === "setup") {
14030
+ const moduleNode = this.workerState.evaluatedModules.getModuleById(filepath);
14031
+ if (moduleNode) this.workerState.evaluatedModules.invalidateModule(moduleNode);
14032
+ }
14033
+ return this._otel.$(`vitest.module.import_${source === "setup" ? "setup" : "spec"}`, { attributes: { "code.file.path": filepath } }, () => {
14034
+ if (!this.viteModuleRunner) filepath = `${filepath}?vitest=${Date.now()}`;
14035
+ return this.moduleRunner.import(filepath);
14036
+ });
14037
+ }
14038
+ onCollectStart(file) {
14039
+ this.workerState.current = file;
14040
+ }
14041
+ onCleanupWorkerContext(listener) {
14042
+ this.workerState.onCleanup(listener);
14043
+ }
14044
+ onAfterRunFiles() {
14045
+ this.snapshotClient.clear();
14046
+ this.workerState.current = void 0;
14047
+ }
14048
+ async onAfterRunSuite(suite) {
14049
+ if (this.config.logHeapUsage && typeof process !== "undefined") suite.result.heap = process.memoryUsage().heapUsed;
14050
+ if (suite.mode !== "skip" && "filepath" in suite) {
14051
+ for (const test of getTests(suite)) if (test.mode === "skip") {
14052
+ const name = getNames(test).slice(1).join(" > ");
14053
+ this.snapshotClient.skipTest(suite.file.filepath, name);
14054
+ }
14055
+ const result = await this.snapshotClient.finish(suite.file.filepath);
14056
+ if (this.workerState.config.snapshotOptions.updateSnapshot === "none" && result.unchecked) {
14057
+ let message = `Obsolete snapshots found when no snapshot update is expected.\n`;
14058
+ for (const key of result.uncheckedKeys) message += `· ${key}\n`;
14059
+ suite.result.errors ??= [];
14060
+ suite.result.errors.push(processError(new Error(message)));
14061
+ suite.result.state = "fail";
14062
+ }
14063
+ await rpc().snapshotSaved(result);
14064
+ }
14065
+ this.workerState.current = suite.suite || suite.file;
14066
+ }
14067
+ onAfterRunTask(test) {
14068
+ if (this.config.logHeapUsage && typeof process !== "undefined") test.result.heap = process.memoryUsage().heapUsed;
14069
+ this.workerState.current = test.suite || test.file;
14070
+ }
14071
+ cancel(_reason) {
14072
+ this.cancelRun = true;
14073
+ }
14074
+ injectValue(key) {
14075
+ return inject(key);
14076
+ }
14077
+ async onBeforeRunTask(test) {
14078
+ if (this.cancelRun) test.mode = "skip";
14079
+ if (test.mode !== "run" && test.mode !== "queued") return;
14080
+ this.workerState.current = test;
14081
+ }
14082
+ async onBeforeRunSuite(suite) {
14083
+ if (this.cancelRun) suite.mode = "skip";
14084
+ if (suite.mode !== "skip" && "filepath" in suite) await this.snapshotClient.setup(suite.file.filepath, this.workerState.config.snapshotOptions);
14085
+ this.workerState.current = suite;
14086
+ }
14087
+ onBeforeTryTask(test) {
14088
+ clearModuleMocks(this.config);
14089
+ this.snapshotClient.clearTest(test.file.filepath, test.id);
14090
+ setState({
14091
+ assertionCalls: 0,
14092
+ isExpectingAssertions: false,
14093
+ isExpectingAssertionsError: null,
14094
+ expectedAssertionsNumber: null,
14095
+ expectedAssertionsNumberErrorGen: null,
14096
+ currentTestName: getTestName(test),
14097
+ snapshotState: this.snapshotClient.getSnapshotState(test.file.filepath)
14098
+ }, globalThis[GLOBAL_EXPECT]);
14099
+ }
14100
+ onAfterTryTask(test) {
14101
+ const { assertionCalls, expectedAssertionsNumber, expectedAssertionsNumberErrorGen, isExpectingAssertions, isExpectingAssertionsError } = test.context._local ? test.context.expect.getState() : getState(globalThis[GLOBAL_EXPECT]);
14102
+ if (expectedAssertionsNumber !== null && assertionCalls !== expectedAssertionsNumber) throw expectedAssertionsNumberErrorGen();
14103
+ if (isExpectingAssertions === true && assertionCalls === 0) throw isExpectingAssertionsError;
14104
+ if (this.config.expect.requireAssertions && assertionCalls === 0) throw this.assertionsErrors.get(test);
14105
+ }
14106
+ extendTaskContext(context) {
14107
+ if (this.config.expect.requireAssertions) this.assertionsErrors.set(context.task, /* @__PURE__ */ new Error("expected any number of assertion, but got none"));
14108
+ let _expect;
14109
+ Object.defineProperty(context, "expect", { get() {
14110
+ if (!_expect) _expect = createExpect(context.task);
14111
+ return _expect;
14112
+ } });
14113
+ Object.defineProperty(context, "_local", { get() {
14114
+ return _expect != null;
14115
+ } });
14116
+ return context;
14117
+ }
14118
+ getImportDurations() {
14119
+ const { limit } = this.config.experimental.importDurations;
14120
+ if (limit === 0) return {};
14121
+ const sortedEntries = [...this.workerState.moduleExecutionInfo?.entries() || []].sort(([, a], [, b]) => b.duration - a.duration).slice(0, limit);
14122
+ const importDurations = {};
14123
+ for (const [filepath, { duration, selfTime, external, importer }] of sortedEntries) importDurations[normalize(filepath)] = {
14124
+ selfTime,
14125
+ totalTime: duration,
14126
+ external,
14127
+ importer
14128
+ };
14129
+ return importDurations;
14130
+ }
14131
+ trace = (name, attributes, cb) => {
14132
+ const options = typeof attributes === "object" ? { attributes } : {};
14133
+ return this._otel.$(`vitest.test.runner.${name}`, options, cb || attributes);
14134
+ };
14135
+ __setTraces(traces) {
14136
+ this._otel = traces;
14137
+ }
14138
+ static createTaskCollector = createTaskCollector;
14139
+ static getCurrentSuite = getCurrentSuite;
14140
+ static getCurrentTest = getCurrentTest;
14141
+ static createChainable = createChainable;
14142
+ static getSuiteHooks = getHooks;
14143
+ static getTestFn = getFn;
14144
+ static setSuiteHooks = getHooks;
14145
+ static setTestFn = getFn;
14146
+ static matchesTags = matchesTags;
14147
+ /**
14148
+ * @deprecated
14149
+ */
14150
+ static getBenchFn = getBenchFn;
14151
+ /**
14152
+ * @deprecated
14153
+ */
14154
+ static getBenchOptions = getBenchOptions;
14155
+ };
14156
+ function clearModuleMocks(config) {
14157
+ const { clearMocks, mockReset, restoreMocks, unstubEnvs, unstubGlobals } = config;
14158
+ if (restoreMocks) vi.restoreAllMocks();
14159
+ if (mockReset) vi.resetAllMocks();
14160
+ if (clearMocks) vi.clearAllMocks();
14161
+ if (unstubEnvs) vi.unstubAllEnvs();
14162
+ if (unstubGlobals) vi.unstubAllGlobals();
14163
+ }
13655
14164
  //#endregion
13656
- export { describe as n, it as r, globalExpect as t };
14165
+ export { beforeEach as a, beforeAll as i, globalExpect as n, describe as o, afterAll as r, it as s, TestRunner as t };
13657
14166
 
13658
- //# sourceMappingURL=test.DNmyFkvJ-N3QqMRwZ.mjs.map
14167
+ //# sourceMappingURL=test.DNmyFkvJ-BPz3G1HS.mjs.map