@jcheesepkg/nanobot 0.8.7 → 0.8.9

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 (99) hide show
  1. package/dist/_virtual/_rolldown/runtime.mjs +7 -0
  2. package/dist/agent/tools/flex.test.d.mts +1 -0
  3. package/dist/agent/tools/flex.test.mjs +258 -0
  4. package/dist/agent/tools/flex.test.mjs.map +1 -0
  5. package/dist/channels/line.d.mts +3 -1
  6. package/dist/channels/line.d.mts.map +1 -1
  7. package/dist/channels/line.mjs +56 -6
  8. package/dist/channels/line.mjs.map +1 -1
  9. package/dist/channels/line.test.d.mts +1 -0
  10. package/dist/channels/line.test.mjs +202 -0
  11. package/dist/channels/line.test.mjs.map +1 -0
  12. package/dist/config/schema.d.mts +18 -18
  13. package/dist/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs +78 -0
  14. package/dist/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs.map +1 -0
  15. package/dist/node_modules/@vitest/expect/dist/index.mjs +1257 -0
  16. package/dist/node_modules/@vitest/expect/dist/index.mjs.map +1 -0
  17. package/dist/node_modules/@vitest/pretty-format/dist/index.mjs +815 -0
  18. package/dist/node_modules/@vitest/pretty-format/dist/index.mjs.map +1 -0
  19. package/dist/node_modules/@vitest/runner/dist/chunk-tasks.mjs +43 -0
  20. package/dist/node_modules/@vitest/runner/dist/chunk-tasks.mjs.map +1 -0
  21. package/dist/node_modules/@vitest/runner/dist/index.mjs +563 -0
  22. package/dist/node_modules/@vitest/runner/dist/index.mjs.map +1 -0
  23. package/dist/node_modules/@vitest/runner/dist/utils.mjs +3 -0
  24. package/dist/node_modules/@vitest/snapshot/dist/index.mjs +1736 -0
  25. package/dist/node_modules/@vitest/snapshot/dist/index.mjs.map +1 -0
  26. package/dist/node_modules/@vitest/snapshot/node_modules/pathe/dist/shared/pathe.ff20891b.mjs +82 -0
  27. package/dist/node_modules/@vitest/snapshot/node_modules/pathe/dist/shared/pathe.ff20891b.mjs.map +1 -0
  28. package/dist/node_modules/@vitest/spy/dist/index.mjs +139 -0
  29. package/dist/node_modules/@vitest/spy/dist/index.mjs.map +1 -0
  30. package/dist/node_modules/@vitest/utils/dist/chunk-_commonjsHelpers.mjs +119 -0
  31. package/dist/node_modules/@vitest/utils/dist/chunk-_commonjsHelpers.mjs.map +1 -0
  32. package/dist/node_modules/@vitest/utils/dist/diff.mjs +1227 -0
  33. package/dist/node_modules/@vitest/utils/dist/diff.mjs.map +1 -0
  34. package/dist/node_modules/@vitest/utils/dist/error.mjs +92 -0
  35. package/dist/node_modules/@vitest/utils/dist/error.mjs.map +1 -0
  36. package/dist/node_modules/@vitest/utils/dist/helpers.mjs +113 -0
  37. package/dist/node_modules/@vitest/utils/dist/helpers.mjs.map +1 -0
  38. package/dist/node_modules/@vitest/utils/dist/index.mjs +455 -0
  39. package/dist/node_modules/@vitest/utils/dist/index.mjs.map +1 -0
  40. package/dist/node_modules/@vitest/utils/dist/source-map.mjs +164 -0
  41. package/dist/node_modules/@vitest/utils/dist/source-map.mjs.map +1 -0
  42. package/dist/node_modules/chai/index.mjs +3088 -0
  43. package/dist/node_modules/chai/index.mjs.map +1 -0
  44. package/dist/node_modules/loupe/lib/arguments.mjs +12 -0
  45. package/dist/node_modules/loupe/lib/arguments.mjs.map +1 -0
  46. package/dist/node_modules/loupe/lib/array.mjs +17 -0
  47. package/dist/node_modules/loupe/lib/array.mjs.map +1 -0
  48. package/dist/node_modules/loupe/lib/bigint.mjs +12 -0
  49. package/dist/node_modules/loupe/lib/bigint.mjs.map +1 -0
  50. package/dist/node_modules/loupe/lib/class.mjs +16 -0
  51. package/dist/node_modules/loupe/lib/class.mjs.map +1 -0
  52. package/dist/node_modules/loupe/lib/date.mjs +14 -0
  53. package/dist/node_modules/loupe/lib/date.mjs.map +1 -0
  54. package/dist/node_modules/loupe/lib/error.mjs +35 -0
  55. package/dist/node_modules/loupe/lib/error.mjs.map +1 -0
  56. package/dist/node_modules/loupe/lib/function.mjs +13 -0
  57. package/dist/node_modules/loupe/lib/function.mjs.map +1 -0
  58. package/dist/node_modules/loupe/lib/helpers.mjs +123 -0
  59. package/dist/node_modules/loupe/lib/helpers.mjs.map +1 -0
  60. package/dist/node_modules/loupe/lib/html.mjs +40 -0
  61. package/dist/node_modules/loupe/lib/html.mjs.map +1 -0
  62. package/dist/node_modules/loupe/lib/index.mjs +100 -0
  63. package/dist/node_modules/loupe/lib/index.mjs.map +1 -0
  64. package/dist/node_modules/loupe/lib/map.mjs +26 -0
  65. package/dist/node_modules/loupe/lib/map.mjs.map +1 -0
  66. package/dist/node_modules/loupe/lib/number.mjs +15 -0
  67. package/dist/node_modules/loupe/lib/number.mjs.map +1 -0
  68. package/dist/node_modules/loupe/lib/object.mjs +22 -0
  69. package/dist/node_modules/loupe/lib/object.mjs.map +1 -0
  70. package/dist/node_modules/loupe/lib/promise.mjs +6 -0
  71. package/dist/node_modules/loupe/lib/promise.mjs.map +1 -0
  72. package/dist/node_modules/loupe/lib/regexp.mjs +13 -0
  73. package/dist/node_modules/loupe/lib/regexp.mjs.map +1 -0
  74. package/dist/node_modules/loupe/lib/set.mjs +19 -0
  75. package/dist/node_modules/loupe/lib/set.mjs.map +1 -0
  76. package/dist/node_modules/loupe/lib/string.mjs +26 -0
  77. package/dist/node_modules/loupe/lib/string.mjs.map +1 -0
  78. package/dist/node_modules/loupe/lib/symbol.mjs +9 -0
  79. package/dist/node_modules/loupe/lib/symbol.mjs.map +1 -0
  80. package/dist/node_modules/loupe/lib/typedarray.mjs +31 -0
  81. package/dist/node_modules/loupe/lib/typedarray.mjs.map +1 -0
  82. package/dist/node_modules/magic-string/dist/magic-string.es.mjs +940 -0
  83. package/dist/node_modules/magic-string/dist/magic-string.es.mjs.map +1 -0
  84. package/dist/node_modules/tinyrainbow/dist/chunk-BVHSVHOK.mjs +82 -0
  85. package/dist/node_modules/tinyrainbow/dist/chunk-BVHSVHOK.mjs.map +1 -0
  86. package/dist/node_modules/tinyrainbow/dist/node.mjs +9 -0
  87. package/dist/node_modules/tinyrainbow/dist/node.mjs.map +1 -0
  88. package/dist/node_modules/tinyspy/dist/index.mjs +79 -0
  89. package/dist/node_modules/tinyspy/dist/index.mjs.map +1 -0
  90. package/dist/node_modules/vitest/dist/chunks/_commonjsHelpers.BFTU3MAI.mjs +9 -0
  91. package/dist/node_modules/vitest/dist/chunks/_commonjsHelpers.BFTU3MAI.mjs.map +1 -0
  92. package/dist/node_modules/vitest/dist/chunks/date.W2xKR2qe.mjs +51 -0
  93. package/dist/node_modules/vitest/dist/chunks/date.W2xKR2qe.mjs.map +1 -0
  94. package/dist/node_modules/vitest/dist/chunks/utils.C8RiOc4B.mjs +49 -0
  95. package/dist/node_modules/vitest/dist/chunks/utils.C8RiOc4B.mjs.map +1 -0
  96. package/dist/node_modules/vitest/dist/chunks/vi.DgezovHB.mjs +2425 -0
  97. package/dist/node_modules/vitest/dist/chunks/vi.DgezovHB.mjs.map +1 -0
  98. package/package.json +1 -1
  99. package/skills/skill-creator/SKILL.md +29 -0
@@ -0,0 +1,563 @@
1
+ import { format, objDisplay } from "../../utils/dist/chunk-_commonjsHelpers.mjs";
2
+ import { assertTypes, createDefer, isNegativeNaN, isObject, objectAttr, toArray } from "../../utils/dist/helpers.mjs";
3
+ import { getSafeTimers } from "../../utils/dist/index.mjs";
4
+ import { processError } from "../../utils/dist/error.mjs";
5
+ import { parseSingleStack } from "../../utils/dist/source-map.mjs";
6
+ import { createChainable } from "./chunk-tasks.mjs";
7
+
8
+ //#region node_modules/@vitest/runner/dist/index.js
9
+ var PendingError = class extends Error {
10
+ constructor(message, task) {
11
+ super(message);
12
+ this.message = message;
13
+ this.taskId = task.id;
14
+ }
15
+ code = "VITEST_PENDING";
16
+ taskId;
17
+ };
18
+ const collectorContext = {
19
+ tasks: [],
20
+ currentSuite: null
21
+ };
22
+ function collectTask(task) {
23
+ var _a;
24
+ (_a = collectorContext.currentSuite) == null || _a.tasks.push(task);
25
+ }
26
+ async function runWithSuite(suite, fn) {
27
+ const prev = collectorContext.currentSuite;
28
+ collectorContext.currentSuite = suite;
29
+ await fn();
30
+ collectorContext.currentSuite = prev;
31
+ }
32
+ function withTimeout(fn, timeout, isHook = false) {
33
+ if (timeout <= 0 || timeout === Number.POSITIVE_INFINITY) return fn;
34
+ const { setTimeout, clearTimeout } = getSafeTimers();
35
+ return function runWithTimeout(...args) {
36
+ return Promise.race([fn(...args), new Promise((resolve, reject) => {
37
+ var _a;
38
+ const timer = setTimeout(() => {
39
+ clearTimeout(timer);
40
+ reject(new Error(makeTimeoutMsg(isHook, timeout)));
41
+ }, timeout);
42
+ (_a = timer.unref) == null || _a.call(timer);
43
+ })]);
44
+ };
45
+ }
46
+ function createTestContext(test, runner) {
47
+ var _a;
48
+ const context = function() {
49
+ throw new Error("done() callback is deprecated, use promise instead");
50
+ };
51
+ context.task = test;
52
+ context.skip = () => {
53
+ test.pending = true;
54
+ throw new PendingError("test is skipped; abort execution", test);
55
+ };
56
+ context.onTestFailed = (fn) => {
57
+ test.onFailed || (test.onFailed = []);
58
+ test.onFailed.push(fn);
59
+ };
60
+ context.onTestFinished = (fn) => {
61
+ test.onFinished || (test.onFinished = []);
62
+ test.onFinished.push(fn);
63
+ };
64
+ return ((_a = runner.extendTaskContext) == null ? void 0 : _a.call(runner, context)) || context;
65
+ }
66
+ function makeTimeoutMsg(isHook, timeout) {
67
+ return `${isHook ? "Hook" : "Test"} timed out in ${timeout}ms.
68
+ 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"}".`;
69
+ }
70
+ const fnMap = /* @__PURE__ */ new WeakMap();
71
+ const fixtureMap = /* @__PURE__ */ new WeakMap();
72
+ const hooksMap = /* @__PURE__ */ new WeakMap();
73
+ function setFn(key, fn) {
74
+ fnMap.set(key, fn);
75
+ }
76
+ function setFixture(key, fixture) {
77
+ fixtureMap.set(key, fixture);
78
+ }
79
+ function getFixture(key) {
80
+ return fixtureMap.get(key);
81
+ }
82
+ function setHooks(key, hooks) {
83
+ hooksMap.set(key, hooks);
84
+ }
85
+ function getHooks(key) {
86
+ return hooksMap.get(key);
87
+ }
88
+ function mergeContextFixtures(fixtures, context = {}) {
89
+ const fixtureOptionKeys = ["auto"];
90
+ const fixtureArray = Object.entries(fixtures).map(([prop, value]) => {
91
+ const fixtureItem = { value };
92
+ if (Array.isArray(value) && value.length >= 2 && isObject(value[1]) && Object.keys(value[1]).some((key) => fixtureOptionKeys.includes(key))) {
93
+ Object.assign(fixtureItem, value[1]);
94
+ fixtureItem.value = value[0];
95
+ }
96
+ fixtureItem.prop = prop;
97
+ fixtureItem.isFn = typeof fixtureItem.value === "function";
98
+ return fixtureItem;
99
+ });
100
+ if (Array.isArray(context.fixtures)) context.fixtures = context.fixtures.concat(fixtureArray);
101
+ else context.fixtures = fixtureArray;
102
+ fixtureArray.forEach((fixture) => {
103
+ if (fixture.isFn) {
104
+ const usedProps = getUsedProps(fixture.value);
105
+ if (usedProps.length) fixture.deps = context.fixtures.filter(({ prop }) => prop !== fixture.prop && usedProps.includes(prop));
106
+ }
107
+ });
108
+ return context;
109
+ }
110
+ const fixtureValueMaps = /* @__PURE__ */ new Map();
111
+ const cleanupFnArrayMap = /* @__PURE__ */ new Map();
112
+ function withFixtures(fn, testContext) {
113
+ return (hookContext) => {
114
+ const context = hookContext || testContext;
115
+ if (!context) return fn({});
116
+ const fixtures = getFixture(context);
117
+ if (!(fixtures == null ? void 0 : fixtures.length)) return fn(context);
118
+ const usedProps = getUsedProps(fn);
119
+ const hasAutoFixture = fixtures.some(({ auto }) => auto);
120
+ if (!usedProps.length && !hasAutoFixture) return fn(context);
121
+ if (!fixtureValueMaps.get(context)) fixtureValueMaps.set(context, /* @__PURE__ */ new Map());
122
+ const fixtureValueMap = fixtureValueMaps.get(context);
123
+ if (!cleanupFnArrayMap.has(context)) cleanupFnArrayMap.set(context, []);
124
+ const cleanupFnArray = cleanupFnArrayMap.get(context);
125
+ const pendingFixtures = resolveDeps(fixtures.filter(({ prop, auto }) => auto || usedProps.includes(prop)));
126
+ if (!pendingFixtures.length) return fn(context);
127
+ async function resolveFixtures() {
128
+ for (const fixture of pendingFixtures) {
129
+ if (fixtureValueMap.has(fixture)) continue;
130
+ const resolvedValue = fixture.isFn ? await resolveFixtureFunction(fixture.value, context, cleanupFnArray) : fixture.value;
131
+ context[fixture.prop] = resolvedValue;
132
+ fixtureValueMap.set(fixture, resolvedValue);
133
+ cleanupFnArray.unshift(() => {
134
+ fixtureValueMap.delete(fixture);
135
+ });
136
+ }
137
+ }
138
+ return resolveFixtures().then(() => fn(context));
139
+ };
140
+ }
141
+ async function resolveFixtureFunction(fixtureFn, context, cleanupFnArray) {
142
+ const useFnArgPromise = createDefer();
143
+ let isUseFnArgResolved = false;
144
+ const fixtureReturn = fixtureFn(context, async (useFnArg) => {
145
+ isUseFnArgResolved = true;
146
+ useFnArgPromise.resolve(useFnArg);
147
+ const useReturnPromise = createDefer();
148
+ cleanupFnArray.push(async () => {
149
+ useReturnPromise.resolve();
150
+ await fixtureReturn;
151
+ });
152
+ await useReturnPromise;
153
+ }).catch((e) => {
154
+ if (!isUseFnArgResolved) {
155
+ useFnArgPromise.reject(e);
156
+ return;
157
+ }
158
+ throw e;
159
+ });
160
+ return useFnArgPromise;
161
+ }
162
+ function resolveDeps(fixtures, depSet = /* @__PURE__ */ new Set(), pendingFixtures = []) {
163
+ fixtures.forEach((fixture) => {
164
+ if (pendingFixtures.includes(fixture)) return;
165
+ if (!fixture.isFn || !fixture.deps) {
166
+ pendingFixtures.push(fixture);
167
+ return;
168
+ }
169
+ if (depSet.has(fixture)) throw new Error(`Circular fixture dependency detected: ${fixture.prop} <- ${[...depSet].reverse().map((d) => d.prop).join(" <- ")}`);
170
+ depSet.add(fixture);
171
+ resolveDeps(fixture.deps, depSet, pendingFixtures);
172
+ pendingFixtures.push(fixture);
173
+ depSet.clear();
174
+ });
175
+ return pendingFixtures;
176
+ }
177
+ function getUsedProps(fn) {
178
+ let fnString = fn.toString();
179
+ if (/__async\(this, (?:null|arguments|\[[_0-9, ]*\]), function\*/.test(fnString)) fnString = fnString.split("__async(this,")[1];
180
+ const match = fnString.match(/[^(]*\(([^)]*)/);
181
+ if (!match) return [];
182
+ const args = splitByComma(match[1]);
183
+ if (!args.length) return [];
184
+ let first = args[0];
185
+ if ("__VITEST_FIXTURE_INDEX__" in fn) {
186
+ first = args[fn.__VITEST_FIXTURE_INDEX__];
187
+ if (!first) return [];
188
+ }
189
+ if (!(first.startsWith("{") && first.endsWith("}"))) throw new Error(`The first argument inside a fixture must use object destructuring pattern, e.g. ({ test } => {}). Instead, received "${first}".`);
190
+ const props = splitByComma(first.slice(1, -1).replace(/\s/g, "")).map((prop) => {
191
+ return prop.replace(/:.*|=.*/g, "");
192
+ });
193
+ const last = props.at(-1);
194
+ if (last && last.startsWith("...")) throw new Error(`Rest parameters are not supported in fixtures, received "${last}".`);
195
+ return props;
196
+ }
197
+ function splitByComma(s) {
198
+ const result = [];
199
+ const stack = [];
200
+ let start = 0;
201
+ for (let i = 0; i < s.length; i++) if (s[i] === "{" || s[i] === "[") stack.push(s[i] === "{" ? "}" : "]");
202
+ else if (s[i] === stack[stack.length - 1]) stack.pop();
203
+ else if (!stack.length && s[i] === ",") {
204
+ const token = s.substring(start, i).trim();
205
+ if (token) result.push(token);
206
+ start = i + 1;
207
+ }
208
+ const lastToken = s.substring(start).trim();
209
+ if (lastToken) result.push(lastToken);
210
+ return result;
211
+ }
212
+ let _test;
213
+ function getCurrentTest() {
214
+ return _test;
215
+ }
216
+ const suite = createSuite();
217
+ const test = createTest(function(name, optionsOrFn, optionsOrTest) {
218
+ if (getCurrentTest()) throw new Error("Calling the test function inside another test function is not allowed. Please put it inside \"describe\" or \"suite\" so it can be properly collected.");
219
+ getCurrentSuite().test.fn.call(this, formatName(name), optionsOrFn, optionsOrTest);
220
+ });
221
+ const describe = suite;
222
+ const it = test;
223
+ let runner;
224
+ let defaultSuite;
225
+ let currentTestFilepath;
226
+ function assert(condition, message) {
227
+ if (!condition) throw new Error(`Vitest failed to find ${message}. This is a bug in Vitest. Please, open an issue with reproduction.`);
228
+ }
229
+ function getTestFilepath() {
230
+ return currentTestFilepath;
231
+ }
232
+ function getRunner() {
233
+ assert(runner, "the runner");
234
+ return runner;
235
+ }
236
+ function getCurrentSuite() {
237
+ const currentSuite = collectorContext.currentSuite || defaultSuite;
238
+ assert(currentSuite, "the current suite");
239
+ return currentSuite;
240
+ }
241
+ function createSuiteHooks() {
242
+ return {
243
+ beforeAll: [],
244
+ afterAll: [],
245
+ beforeEach: [],
246
+ afterEach: []
247
+ };
248
+ }
249
+ function parseArguments(optionsOrFn, optionsOrTest) {
250
+ let options = {};
251
+ let fn = () => {};
252
+ if (typeof optionsOrTest === "object") {
253
+ if (typeof optionsOrFn === "object") throw new TypeError("Cannot use two objects as arguments. Please provide options and a function callback in that order.");
254
+ options = optionsOrTest;
255
+ } else if (typeof optionsOrTest === "number") options = { timeout: optionsOrTest };
256
+ else if (typeof optionsOrFn === "object") options = optionsOrFn;
257
+ if (typeof optionsOrFn === "function") {
258
+ if (typeof optionsOrTest === "function") throw new TypeError("Cannot use two functions as arguments. Please use the second argument for options.");
259
+ fn = optionsOrFn;
260
+ } else if (typeof optionsOrTest === "function") fn = optionsOrTest;
261
+ return {
262
+ options,
263
+ handler: fn
264
+ };
265
+ }
266
+ function createSuiteCollector(name, factory = () => {}, mode, shuffle, each, suiteOptions) {
267
+ const tasks = [];
268
+ const factoryQueue = [];
269
+ let suite2;
270
+ initSuite(true);
271
+ const task = function(name2 = "", options = {}) {
272
+ const task2 = {
273
+ id: "",
274
+ name: name2,
275
+ suite: void 0,
276
+ each: options.each,
277
+ fails: options.fails,
278
+ context: void 0,
279
+ type: "custom",
280
+ file: void 0,
281
+ retry: options.retry ?? runner.config.retry,
282
+ repeats: options.repeats,
283
+ mode: options.only ? "only" : options.skip ? "skip" : options.todo ? "todo" : "run",
284
+ meta: options.meta ?? /* @__PURE__ */ Object.create(null)
285
+ };
286
+ const handler = options.handler;
287
+ if (options.concurrent || !options.sequential && runner.config.sequence.concurrent) task2.concurrent = true;
288
+ if (shuffle) task2.shuffle = true;
289
+ const context = createTestContext(task2, runner);
290
+ Object.defineProperty(task2, "context", {
291
+ value: context,
292
+ enumerable: false
293
+ });
294
+ setFixture(context, options.fixtures);
295
+ if (handler) setFn(task2, withTimeout(withAwaitAsyncAssetions(withFixtures(handler, context), task2), (options == null ? void 0 : options.timeout) ?? runner.config.testTimeout));
296
+ if (runner.config.includeTaskLocation) {
297
+ const limit = Error.stackTraceLimit;
298
+ Error.stackTraceLimit = 15;
299
+ const error = (/* @__PURE__ */ new Error("stacktrace")).stack;
300
+ Error.stackTraceLimit = limit;
301
+ const stack = findTestFileStackTrace(error, task2.each ?? false);
302
+ if (stack) task2.location = stack;
303
+ }
304
+ tasks.push(task2);
305
+ return task2;
306
+ };
307
+ const test2 = createTest(function(name2, optionsOrFn, optionsOrTest) {
308
+ let { options, handler } = parseArguments(optionsOrFn, optionsOrTest);
309
+ if (typeof suiteOptions === "object") options = Object.assign({}, suiteOptions, options);
310
+ options.concurrent = this.concurrent || !this.sequential && (options == null ? void 0 : options.concurrent);
311
+ options.sequential = this.sequential || !this.concurrent && (options == null ? void 0 : options.sequential);
312
+ const test3 = task(formatName(name2), {
313
+ ...this,
314
+ ...options,
315
+ handler
316
+ });
317
+ test3.type = "test";
318
+ });
319
+ const collector = {
320
+ type: "collector",
321
+ name,
322
+ mode,
323
+ options: suiteOptions,
324
+ test: test2,
325
+ tasks,
326
+ collect,
327
+ task,
328
+ clear,
329
+ on: addHook
330
+ };
331
+ function addHook(name2, ...fn) {
332
+ getHooks(suite2)[name2].push(...fn);
333
+ }
334
+ function initSuite(includeLocation) {
335
+ if (typeof suiteOptions === "number") suiteOptions = { timeout: suiteOptions };
336
+ suite2 = {
337
+ id: "",
338
+ type: "suite",
339
+ name,
340
+ mode,
341
+ each,
342
+ file: void 0,
343
+ shuffle,
344
+ tasks: [],
345
+ meta: /* @__PURE__ */ Object.create(null),
346
+ concurrent: suiteOptions == null ? void 0 : suiteOptions.concurrent
347
+ };
348
+ if (runner && includeLocation && runner.config.includeTaskLocation) {
349
+ const limit = Error.stackTraceLimit;
350
+ Error.stackTraceLimit = 15;
351
+ const error = (/* @__PURE__ */ new Error("stacktrace")).stack;
352
+ Error.stackTraceLimit = limit;
353
+ const stack = findTestFileStackTrace(error, suite2.each ?? false);
354
+ if (stack) suite2.location = stack;
355
+ }
356
+ setHooks(suite2, createSuiteHooks());
357
+ }
358
+ function clear() {
359
+ tasks.length = 0;
360
+ factoryQueue.length = 0;
361
+ initSuite(false);
362
+ }
363
+ async function collect(file) {
364
+ if (!file) throw new TypeError("File is required to collect tasks.");
365
+ factoryQueue.length = 0;
366
+ if (factory) await runWithSuite(collector, () => factory(test2));
367
+ const allChildren = [];
368
+ for (const i of [...factoryQueue, ...tasks]) allChildren.push(i.type === "collector" ? await i.collect(file) : i);
369
+ suite2.file = file;
370
+ suite2.tasks = allChildren;
371
+ allChildren.forEach((task2) => {
372
+ task2.suite = suite2;
373
+ task2.file = file;
374
+ });
375
+ return suite2;
376
+ }
377
+ collectTask(collector);
378
+ return collector;
379
+ }
380
+ function withAwaitAsyncAssetions(fn, task) {
381
+ return async (...args) => {
382
+ await fn(...args);
383
+ if (task.promises) {
384
+ const errors = (await Promise.allSettled(task.promises)).map((r) => r.status === "rejected" ? r.reason : void 0).filter(Boolean);
385
+ if (errors.length) throw errors;
386
+ }
387
+ };
388
+ }
389
+ function createSuite() {
390
+ function suiteFn(name, factoryOrOptions, optionsOrFactory = {}) {
391
+ const mode = this.only ? "only" : this.skip ? "skip" : this.todo ? "todo" : "run";
392
+ const currentSuite = collectorContext.currentSuite || defaultSuite;
393
+ let { options, handler: factory } = parseArguments(factoryOrOptions, optionsOrFactory);
394
+ const isConcurrentSpecified = options.concurrent || this.concurrent || options.sequential === false;
395
+ const isSequentialSpecified = options.sequential || this.sequential || options.concurrent === false;
396
+ if (currentSuite == null ? void 0 : currentSuite.options) options = {
397
+ ...currentSuite.options,
398
+ ...options
399
+ };
400
+ const isConcurrent = isConcurrentSpecified || options.concurrent && !isSequentialSpecified;
401
+ const isSequential = isSequentialSpecified || options.sequential && !isConcurrentSpecified;
402
+ options.concurrent = isConcurrent && !isSequential;
403
+ options.sequential = isSequential && !isConcurrent;
404
+ return createSuiteCollector(formatName(name), factory, mode, this.shuffle, this.each, options);
405
+ }
406
+ suiteFn.each = function(cases, ...args) {
407
+ const suite2 = this.withContext();
408
+ this.setContext("each", true);
409
+ if (Array.isArray(cases) && args.length) cases = formatTemplateString(cases, args);
410
+ return (name, optionsOrFn, fnOrOptions) => {
411
+ const _name = formatName(name);
412
+ const arrayOnlyCases = cases.every(Array.isArray);
413
+ const { options, handler } = parseArguments(optionsOrFn, fnOrOptions);
414
+ const fnFirst = typeof optionsOrFn === "function";
415
+ cases.forEach((i, idx) => {
416
+ const items = Array.isArray(i) ? i : [i];
417
+ if (fnFirst) if (arrayOnlyCases) suite2(formatTitle(_name, items, idx), () => handler(...items), options);
418
+ else suite2(formatTitle(_name, items, idx), () => handler(i), options);
419
+ else if (arrayOnlyCases) suite2(formatTitle(_name, items, idx), options, () => handler(...items));
420
+ else suite2(formatTitle(_name, items, idx), options, () => handler(i));
421
+ });
422
+ this.setContext("each", void 0);
423
+ };
424
+ };
425
+ suiteFn.skipIf = (condition) => condition ? suite.skip : suite;
426
+ suiteFn.runIf = (condition) => condition ? suite : suite.skip;
427
+ return createChainable([
428
+ "concurrent",
429
+ "sequential",
430
+ "shuffle",
431
+ "skip",
432
+ "only",
433
+ "todo"
434
+ ], suiteFn);
435
+ }
436
+ function createTaskCollector(fn, context) {
437
+ const taskFn = fn;
438
+ taskFn.each = function(cases, ...args) {
439
+ const test2 = this.withContext();
440
+ this.setContext("each", true);
441
+ if (Array.isArray(cases) && args.length) cases = formatTemplateString(cases, args);
442
+ return (name, optionsOrFn, fnOrOptions) => {
443
+ const _name = formatName(name);
444
+ const arrayOnlyCases = cases.every(Array.isArray);
445
+ const { options, handler } = parseArguments(optionsOrFn, fnOrOptions);
446
+ const fnFirst = typeof optionsOrFn === "function";
447
+ cases.forEach((i, idx) => {
448
+ const items = Array.isArray(i) ? i : [i];
449
+ if (fnFirst) if (arrayOnlyCases) test2(formatTitle(_name, items, idx), () => handler(...items), options);
450
+ else test2(formatTitle(_name, items, idx), () => handler(i), options);
451
+ else if (arrayOnlyCases) test2(formatTitle(_name, items, idx), options, () => handler(...items));
452
+ else test2(formatTitle(_name, items, idx), options, () => handler(i));
453
+ });
454
+ this.setContext("each", void 0);
455
+ };
456
+ };
457
+ taskFn.for = function(cases, ...args) {
458
+ const test2 = this.withContext();
459
+ if (Array.isArray(cases) && args.length) cases = formatTemplateString(cases, args);
460
+ return (name, optionsOrFn, fnOrOptions) => {
461
+ const _name = formatName(name);
462
+ const { options, handler } = parseArguments(optionsOrFn, fnOrOptions);
463
+ cases.forEach((item, idx) => {
464
+ const handlerWrapper = (ctx) => handler(item, ctx);
465
+ handlerWrapper.__VITEST_FIXTURE_INDEX__ = 1;
466
+ handlerWrapper.toString = () => handler.toString();
467
+ test2(formatTitle(_name, toArray(item), idx), options, handlerWrapper);
468
+ });
469
+ };
470
+ };
471
+ taskFn.skipIf = function(condition) {
472
+ return condition ? this.skip : this;
473
+ };
474
+ taskFn.runIf = function(condition) {
475
+ return condition ? this : this.skip;
476
+ };
477
+ taskFn.extend = function(fixtures) {
478
+ return createTest(function fn2(name, optionsOrFn, optionsOrTest) {
479
+ getCurrentSuite().test.fn.call(this, formatName(name), optionsOrFn, optionsOrTest);
480
+ }, mergeContextFixtures(fixtures, context));
481
+ };
482
+ const _test = createChainable([
483
+ "concurrent",
484
+ "sequential",
485
+ "skip",
486
+ "only",
487
+ "todo",
488
+ "fails"
489
+ ], taskFn);
490
+ if (context) _test.mergeContext(context);
491
+ return _test;
492
+ }
493
+ function createTest(fn, context) {
494
+ return createTaskCollector(fn, context);
495
+ }
496
+ function formatName(name) {
497
+ return typeof name === "string" ? name : name instanceof Function ? name.name || "<anonymous>" : String(name);
498
+ }
499
+ function formatTitle(template, items, idx) {
500
+ if (template.includes("%#")) template = template.replace(/%%/g, "__vitest_escaped_%__").replace(/%#/g, `${idx}`).replace(/__vitest_escaped_%__/g, "%%");
501
+ const count = template.split("%").length - 1;
502
+ if (template.includes("%f")) (template.match(/%f/g) || []).forEach((_, i) => {
503
+ if (isNegativeNaN(items[i]) || Object.is(items[i], -0)) {
504
+ let occurrence = 0;
505
+ template = template.replace(/%f/g, (match) => {
506
+ occurrence++;
507
+ return occurrence === i + 1 ? "-%f" : match;
508
+ });
509
+ }
510
+ });
511
+ let formatted = format(template, ...items.slice(0, count));
512
+ if (isObject(items[0])) formatted = formatted.replace(/\$([$\w.]+)/g, (_, key) => {
513
+ var _a, _b;
514
+ return objDisplay(objectAttr(items[0], key), { truncate: (_b = (_a = runner == null ? void 0 : runner.config) == null ? void 0 : _a.chaiConfig) == null ? void 0 : _b.truncateThreshold });
515
+ });
516
+ return formatted;
517
+ }
518
+ function formatTemplateString(cases, args) {
519
+ const header = cases.join("").trim().replace(/ /g, "").split("\n").map((i) => i.split("|"))[0];
520
+ const res = [];
521
+ for (let i = 0; i < Math.floor(args.length / header.length); i++) {
522
+ const oneCase = {};
523
+ for (let j = 0; j < header.length; j++) oneCase[header[j]] = args[i * header.length + j];
524
+ res.push(oneCase);
525
+ }
526
+ return res;
527
+ }
528
+ function findTestFileStackTrace(error, each) {
529
+ const lines = error.split("\n").slice(1);
530
+ for (const line of lines) {
531
+ const stack = parseSingleStack(line);
532
+ if (stack && stack.file === getTestFilepath()) return {
533
+ line: stack.line,
534
+ column: each ? stack.column + 1 : stack.column
535
+ };
536
+ }
537
+ }
538
+ function getDefaultHookTimeout() {
539
+ return getRunner().config.hookTimeout;
540
+ }
541
+ const onTestFailed = createTestHook("onTestFailed", (test, handler, timeout) => {
542
+ test.onFailed || (test.onFailed = []);
543
+ test.onFailed.push(withTimeout(handler, timeout ?? getDefaultHookTimeout(), true));
544
+ });
545
+ const onTestFinished = createTestHook("onTestFinished", (test, handler, timeout) => {
546
+ test.onFinished || (test.onFinished = []);
547
+ test.onFinished.push(withTimeout(handler, timeout ?? getDefaultHookTimeout(), true));
548
+ });
549
+ function createTestHook(name, handler) {
550
+ return (fn, timeout) => {
551
+ assertTypes(fn, `"${name}" callback`, ["function"]);
552
+ const current = getCurrentTest();
553
+ if (!current) throw new Error(`Hook ${name}() can only be called inside a test`);
554
+ return handler(current, fn, timeout);
555
+ };
556
+ }
557
+ const now$1 = globalThis.performance ? globalThis.performance.now.bind(globalThis.performance) : Date.now;
558
+ const now = globalThis.performance ? globalThis.performance.now.bind(globalThis.performance) : Date.now;
559
+ const unixNow = Date.now;
560
+
561
+ //#endregion
562
+ export { describe, getCurrentTest, it };
563
+ //# sourceMappingURL=index.mjs.map