@vitest-agent/ui 4.1.0 → 5.0.1

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 (37) hide show
  1. package/README.md +3 -3
  2. package/dispatcher/cells/single-file-fail.js +1 -5
  3. package/dispatcher/cells/single-file-pass.js +1 -5
  4. package/dispatcher/cells/single-file-threshold.js +1 -5
  5. package/dispatcher/cells/single-project-fail.js +1 -5
  6. package/dispatcher/cells/single-project-pass.js +1 -5
  7. package/dispatcher/cells/single-project-threshold.js +1 -5
  8. package/dispatcher/cells/single-test-fail.js +1 -5
  9. package/dispatcher/cells/single-test-pass.js +1 -5
  10. package/dispatcher/cells/workspace-fail.js +1 -5
  11. package/dispatcher/cells/workspace-pass.js +1 -5
  12. package/dispatcher/cells/workspace-threshold.js +1 -5
  13. package/dispatcher/dispatch.js +20 -25
  14. package/index.d.ts +45 -316
  15. package/index.js +4 -17
  16. package/{render-ink → ink}/CountColumns.js +2 -2
  17. package/{render-ink → ink}/CoverageBlock.js +2 -2
  18. package/{render-ink → ink}/FailureSection.js +2 -2
  19. package/{render-ink → ink}/FailuresSection.js +2 -2
  20. package/{render-ink → ink}/ModuleHeader.js +1 -1
  21. package/{render-ink → ink}/ProjectRow.js +1 -1
  22. package/{render-ink → ink}/StatusIcon.js +2 -2
  23. package/{render-ink → ink}/StreamApp.js +14 -5
  24. package/{render-ink → ink}/SuggestedActions.js +2 -2
  25. package/{render-ink → ink}/TagColumns.js +1 -1
  26. package/{render-ink → ink}/TestRow.js +1 -1
  27. package/{render-ink → ink}/TrendLine.js +2 -2
  28. package/ink/dispatch-ink.js +61 -0
  29. package/{dispatcher → ink}/ink-helpers.js +1 -1
  30. package/ink.d.ts +789 -0
  31. package/ink.js +15 -0
  32. package/package.json +12 -7
  33. package/reducer.js +2 -1
  34. package/render-agent.js +2 -0
  35. package/{render-ink/spinner.js → spinner.js} +1 -1
  36. package/synthesize.js +2 -1
  37. package/render-ink/index.js +0 -15
@@ -0,0 +1,61 @@
1
+ import { dispatcherTable, scopedCoverageNoteFor, strayOutputNoteFor } from "../dispatcher/dispatch.js";
2
+ import { renderAgentStringAsInk } from "./ink-helpers.js";
3
+ import { Box, Text } from "ink";
4
+ import { createElement } from "react";
5
+
6
+ //#region src/ink/dispatch-ink.ts
7
+ /** The Ink half of a cell whose live view is its agent string, painted. */
8
+ const asInk = (agent) => (inputs, opts) => renderAgentStringAsInk(agent(inputs, opts));
9
+ const inkOf = (shape, outcome) => asInk(dispatcherTable[shape][outcome].agent);
10
+ /**
11
+ * The 4×3 Ink cell table, keyed by the same `(RunShape, RunOutcome)`
12
+ * matrix as the root entry's `dispatcherTable`. An `undefined` entry is a
13
+ * cell with no Ink half (`single-test × threshold-violation`).
14
+ *
15
+ * @public
16
+ */
17
+ const inkDispatcherTable = {
18
+ "single-test": {
19
+ "all-pass": inkOf("single-test", "all-pass"),
20
+ "some-fail": inkOf("single-test", "some-fail"),
21
+ "threshold-violation": void 0
22
+ },
23
+ "single-file": {
24
+ "all-pass": inkOf("single-file", "all-pass"),
25
+ "some-fail": inkOf("single-file", "some-fail"),
26
+ "threshold-violation": inkOf("single-file", "threshold-violation")
27
+ },
28
+ "single-project": {
29
+ "all-pass": inkOf("single-project", "all-pass"),
30
+ "some-fail": inkOf("single-project", "some-fail"),
31
+ "threshold-violation": inkOf("single-project", "threshold-violation")
32
+ },
33
+ workspace: {
34
+ "all-pass": inkOf("workspace", "all-pass"),
35
+ "some-fail": inkOf("workspace", "some-fail"),
36
+ "threshold-violation": inkOf("workspace", "threshold-violation")
37
+ }
38
+ };
39
+ /**
40
+ * Dispatch to the cell that matches `(inputs.shape, inputs.outcome)`
41
+ * and return its Ink-half React tree, followed by the scoped-coverage
42
+ * note on a partial run. Returns `null` when the matched cell has no Ink
43
+ * half — callers fall back to the root entry's `dispatch` string then.
44
+ *
45
+ * @param inputs - the classified dispatch inputs
46
+ * @param opts - cell rendering options
47
+ * @returns the Ink React element, or `null` when the cell has no Ink half
48
+ * @public
49
+ */
50
+ const dispatchInk = (inputs, opts) => {
51
+ const cell = inkDispatcherTable[inputs.shape][inputs.outcome];
52
+ if (cell === void 0) return null;
53
+ const element = cell(inputs, opts);
54
+ const note = scopedCoverageNoteFor(inputs);
55
+ const stray = strayOutputNoteFor(inputs);
56
+ if (note === null && stray === null) return element;
57
+ return createElement(Box, { flexDirection: "column" }, element, note !== null ? createElement(Text, null, note) : null, stray !== null ? createElement(Box, { marginTop: 1 }, createElement(Text, null, stray)) : null);
58
+ };
59
+
60
+ //#endregion
61
+ export { dispatchInk, inkDispatcherTable };
@@ -2,7 +2,7 @@ import { inkStyle, statusGlyph, statusInkStyle } from "../theme.js";
2
2
  import { Box, Text } from "ink";
3
3
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
4
4
 
5
- //#region src/dispatcher/ink-helpers.tsx
5
+ //#region src/ink/ink-helpers.tsx
6
6
  /**
7
7
  * Render an agent-string output as a column of Ink Text rows, applying
8
8
  * color to the leading status glyph on each line.