@outfitter/cli 0.2.0 → 0.4.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 (261) hide show
  1. package/README.md +47 -4
  2. package/dist/actions.js +0 -2
  3. package/dist/cli.d.ts +1 -1
  4. package/dist/cli.js +1 -2
  5. package/dist/{render → colors}/colors.d.ts +1 -1
  6. package/dist/{render → colors}/colors.js +2 -6
  7. package/dist/colors/index.d.ts +1 -1
  8. package/dist/colors/index.js +3 -4
  9. package/dist/command.d.ts +1 -1
  10. package/dist/command.js +1 -2
  11. package/dist/index.d.ts +3 -3
  12. package/dist/index.js +4 -5
  13. package/dist/input.d.ts +3 -26
  14. package/dist/input.js +1 -31
  15. package/dist/output.d.ts +3 -3
  16. package/dist/output.js +4 -3
  17. package/dist/pagination.d.ts +1 -1
  18. package/dist/pagination.js +0 -2
  19. package/dist/shared/@outfitter/{cli-ttt7r0j7.d.ts → cli-02kyvj7h.d.ts} +2 -13
  20. package/dist/shared/@outfitter/{cli-8gg0hck1.js → cli-7wp5nj0s.js} +16 -12
  21. package/dist/shared/@outfitter/{cli-72kg550t.d.ts → cli-f79bwzsp.d.ts} +30 -2
  22. package/dist/shared/@outfitter/{cli-d9ad0rqj.js → cli-jbj78ac5.js} +1 -6
  23. package/dist/shared/@outfitter/{cli-5g6rkv3d.js → cli-rk9zagkm.js} +24 -32
  24. package/dist/shared/@outfitter/{cli-efy6jfcj.js → cli-zahqsaby.js} +33 -10
  25. package/dist/terminal/detection.js +1 -5
  26. package/dist/terminal/index.js +1 -6
  27. package/dist/{shared/@outfitter/cli-4cb5g831.d.ts → text.d.ts} +1 -1
  28. package/dist/{shared/@outfitter/cli-mwxsh3sr.js → text.js} +15 -14
  29. package/dist/types.d.ts +2 -2
  30. package/dist/types.js +0 -2
  31. package/package.json +35 -213
  32. package/dist/borders/index.d.ts +0 -3
  33. package/dist/borders/index.js +0 -13
  34. package/dist/box/index.d.ts +0 -4
  35. package/dist/box/index.js +0 -13
  36. package/dist/demo/index.d.ts +0 -78
  37. package/dist/demo/index.js +0 -148
  38. package/dist/demo/registry.d.ts +0 -7
  39. package/dist/demo/registry.js +0 -28
  40. package/dist/demo/renderers/borders.d.ts +0 -7
  41. package/dist/demo/renderers/borders.js +0 -17
  42. package/dist/demo/renderers/box.d.ts +0 -7
  43. package/dist/demo/renderers/box.js +0 -18
  44. package/dist/demo/renderers/colors.d.ts +0 -7
  45. package/dist/demo/renderers/colors.js +0 -18
  46. package/dist/demo/renderers/indicators.d.ts +0 -7
  47. package/dist/demo/renderers/indicators.js +0 -17
  48. package/dist/demo/renderers/list.d.ts +0 -7
  49. package/dist/demo/renderers/list.js +0 -19
  50. package/dist/demo/renderers/markdown.d.ts +0 -7
  51. package/dist/demo/renderers/markdown.js +0 -18
  52. package/dist/demo/renderers/progress.d.ts +0 -7
  53. package/dist/demo/renderers/progress.js +0 -17
  54. package/dist/demo/renderers/spinner.d.ts +0 -7
  55. package/dist/demo/renderers/spinner.js +0 -19
  56. package/dist/demo/renderers/table.d.ts +0 -7
  57. package/dist/demo/renderers/table.js +0 -19
  58. package/dist/demo/renderers/text.d.ts +0 -7
  59. package/dist/demo/renderers/text.js +0 -16
  60. package/dist/demo/renderers/tree.d.ts +0 -7
  61. package/dist/demo/renderers/tree.js +0 -18
  62. package/dist/demo/section.d.ts +0 -5
  63. package/dist/demo/section.js +0 -23
  64. package/dist/demo/templates.d.ts +0 -4
  65. package/dist/demo/templates.js +0 -10
  66. package/dist/demo/types.d.ts +0 -3
  67. package/dist/demo/types.js +0 -8
  68. package/dist/list/index.d.ts +0 -3
  69. package/dist/list/index.js +0 -9
  70. package/dist/preset/full.d.ts +0 -14
  71. package/dist/preset/full.js +0 -41
  72. package/dist/preset/standard.d.ts +0 -11
  73. package/dist/preset/standard.js +0 -30
  74. package/dist/prompt/confirm.d.ts +0 -4
  75. package/dist/prompt/confirm.js +0 -9
  76. package/dist/prompt/group.d.ts +0 -4
  77. package/dist/prompt/group.js +0 -9
  78. package/dist/prompt/index.d.ts +0 -7
  79. package/dist/prompt/index.js +0 -32
  80. package/dist/prompt/select.d.ts +0 -4
  81. package/dist/prompt/select.js +0 -11
  82. package/dist/prompt/text.d.ts +0 -4
  83. package/dist/prompt/text.js +0 -11
  84. package/dist/prompt/types.d.ts +0 -3
  85. package/dist/prompt/types.js +0 -8
  86. package/dist/prompt/validators.d.ts +0 -2
  87. package/dist/prompt/validators.js +0 -8
  88. package/dist/render/borders.d.ts +0 -2
  89. package/dist/render/borders.js +0 -15
  90. package/dist/render/box.d.ts +0 -3
  91. package/dist/render/box.js +0 -23
  92. package/dist/render/date.d.ts +0 -2
  93. package/dist/render/date.js +0 -12
  94. package/dist/render/format-relative.d.ts +0 -2
  95. package/dist/render/format-relative.js +0 -8
  96. package/dist/render/format.d.ts +0 -2
  97. package/dist/render/format.js +0 -10
  98. package/dist/render/heading.d.ts +0 -3
  99. package/dist/render/heading.js +0 -14
  100. package/dist/render/index.d.ts +0 -32
  101. package/dist/render/index.js +0 -235
  102. package/dist/render/indicators.d.ts +0 -2
  103. package/dist/render/indicators.js +0 -16
  104. package/dist/render/json.d.ts +0 -2
  105. package/dist/render/json.js +0 -10
  106. package/dist/render/layout.d.ts +0 -5
  107. package/dist/render/layout.js +0 -25
  108. package/dist/render/list.d.ts +0 -2
  109. package/dist/render/list.js +0 -8
  110. package/dist/render/markdown.d.ts +0 -2
  111. package/dist/render/markdown.js +0 -10
  112. package/dist/render/progress.d.ts +0 -2
  113. package/dist/render/progress.js +0 -8
  114. package/dist/render/separator.d.ts +0 -3
  115. package/dist/render/separator.js +0 -14
  116. package/dist/render/shapes.d.ts +0 -2
  117. package/dist/render/shapes.js +0 -35
  118. package/dist/render/spinner.d.ts +0 -2
  119. package/dist/render/spinner.js +0 -12
  120. package/dist/render/stack.d.ts +0 -3
  121. package/dist/render/stack.js +0 -38
  122. package/dist/render/table.d.ts +0 -3
  123. package/dist/render/table.js +0 -12
  124. package/dist/render/text.d.ts +0 -2
  125. package/dist/render/text.js +0 -27
  126. package/dist/render/tree.d.ts +0 -2
  127. package/dist/render/tree.js +0 -10
  128. package/dist/render/types.d.ts +0 -2
  129. package/dist/shared/@outfitter/cli-0djg8q91.js +0 -7
  130. package/dist/shared/@outfitter/cli-0w242qtv.d.ts +0 -48
  131. package/dist/shared/@outfitter/cli-1g8tt31a.d.ts +0 -119
  132. package/dist/shared/@outfitter/cli-1kwbnt86.d.ts +0 -45
  133. package/dist/shared/@outfitter/cli-1sb3xvnw.js +0 -95
  134. package/dist/shared/@outfitter/cli-1vy0vtga.js +0 -135
  135. package/dist/shared/@outfitter/cli-2g8bx1aq.d.ts +0 -50
  136. package/dist/shared/@outfitter/cli-33e97cjs.d.ts +0 -42
  137. package/dist/shared/@outfitter/cli-3b7ed3rm.d.ts +0 -97
  138. package/dist/shared/@outfitter/cli-3hk2xf3c.js +0 -82
  139. package/dist/shared/@outfitter/cli-3hp8qwx3.js +0 -11
  140. package/dist/shared/@outfitter/cli-47yw5h6a.js +0 -7
  141. package/dist/shared/@outfitter/cli-4b6tbp68.d.ts +0 -36
  142. package/dist/shared/@outfitter/cli-4fcz51qa.js +0 -70
  143. package/dist/shared/@outfitter/cli-4x6pqnez.js +0 -20
  144. package/dist/shared/@outfitter/cli-4zk2y4a2.d.ts +0 -61
  145. package/dist/shared/@outfitter/cli-60b5xh1r.js +0 -20
  146. package/dist/shared/@outfitter/cli-6bztk73z.d.ts +0 -51
  147. package/dist/shared/@outfitter/cli-6fxffp8k.js +0 -1
  148. package/dist/shared/@outfitter/cli-6hg0sg2d.d.ts +0 -93
  149. package/dist/shared/@outfitter/cli-6r3m2knf.js +0 -62
  150. package/dist/shared/@outfitter/cli-6ty1nvws.js +0 -179
  151. package/dist/shared/@outfitter/cli-7n610r63.js +0 -20
  152. package/dist/shared/@outfitter/cli-7na6p4fs.d.ts +0 -59
  153. package/dist/shared/@outfitter/cli-83jwvj1t.d.ts +0 -17
  154. package/dist/shared/@outfitter/cli-85fg2vr5.js +0 -123
  155. package/dist/shared/@outfitter/cli-8bwaw3pz.js +0 -7
  156. package/dist/shared/@outfitter/cli-8hngbjyr.d.ts +0 -164
  157. package/dist/shared/@outfitter/cli-8j5k6mr3.js +0 -71
  158. package/dist/shared/@outfitter/cli-8xsmsbbd.d.ts +0 -223
  159. package/dist/shared/@outfitter/cli-914d47mt.js +0 -20
  160. package/dist/shared/@outfitter/cli-9bcm4zhf.d.ts +0 -87
  161. package/dist/shared/@outfitter/cli-9khk3cbq.d.ts +0 -190
  162. package/dist/shared/@outfitter/cli-a4q87517.d.ts +0 -64
  163. package/dist/shared/@outfitter/cli-aem6v4c8.js +0 -146
  164. package/dist/shared/@outfitter/cli-b0tzqgnf.d.ts +0 -132
  165. package/dist/shared/@outfitter/cli-b5c2k0d7.js +0 -39
  166. package/dist/shared/@outfitter/cli-b5epywry.js +0 -1
  167. package/dist/shared/@outfitter/cli-bc17qeh2.js +0 -19
  168. package/dist/shared/@outfitter/cli-bcmcaz1b.js +0 -23
  169. package/dist/shared/@outfitter/cli-bv09nme3.d.ts +0 -56
  170. package/dist/shared/@outfitter/cli-c6pbxpw0.d.ts +0 -112
  171. package/dist/shared/@outfitter/cli-c8fqdaes.js +0 -117
  172. package/dist/shared/@outfitter/cli-c8q4f71g.js +0 -144
  173. package/dist/shared/@outfitter/cli-c9knfqn5.d.ts +0 -30
  174. package/dist/shared/@outfitter/cli-cf1xexgn.d.ts +0 -53
  175. package/dist/shared/@outfitter/cli-cf2s94s1.d.ts +0 -42
  176. package/dist/shared/@outfitter/cli-cwgj6mcs.js +0 -214
  177. package/dist/shared/@outfitter/cli-d8ahdd9d.js +0 -272
  178. package/dist/shared/@outfitter/cli-dbyteh27.d.ts +0 -24
  179. package/dist/shared/@outfitter/cli-e5ms1y0x.d.ts +0 -91
  180. package/dist/shared/@outfitter/cli-en6zn6sj.js +0 -1
  181. package/dist/shared/@outfitter/cli-evx7qcp1.d.ts +0 -300
  182. package/dist/shared/@outfitter/cli-f6fsaayd.js +0 -94
  183. package/dist/shared/@outfitter/cli-fakncnjp.d.ts +0 -106
  184. package/dist/shared/@outfitter/cli-ffa0jwb7.js +0 -122
  185. package/dist/shared/@outfitter/cli-h20jc0bs.d.ts +0 -66
  186. package/dist/shared/@outfitter/cli-h3jz0bxz.js +0 -48
  187. package/dist/shared/@outfitter/cli-h4wpzb3f.js +0 -67
  188. package/dist/shared/@outfitter/cli-hda6mc28.js +0 -126
  189. package/dist/shared/@outfitter/cli-hnpbqmc8.d.ts +0 -328
  190. package/dist/shared/@outfitter/cli-j19a91ck.js +0 -30
  191. package/dist/shared/@outfitter/cli-jejfypgf.js +0 -85
  192. package/dist/shared/@outfitter/cli-jp0k3qd9.js +0 -279
  193. package/dist/shared/@outfitter/cli-k76e7173.js +0 -128
  194. package/dist/shared/@outfitter/cli-kc3ffp1v.d.ts +0 -23
  195. package/dist/shared/@outfitter/cli-kk5hnndk.d.ts +0 -128
  196. package/dist/shared/@outfitter/cli-ktqme80d.js +0 -7
  197. package/dist/shared/@outfitter/cli-mq0jp15z.js +0 -1
  198. package/dist/shared/@outfitter/cli-n0c33vba.js +0 -25
  199. package/dist/shared/@outfitter/cli-n17gt1dz.js +0 -19
  200. package/dist/shared/@outfitter/cli-n9dbh0hp.js +0 -51
  201. package/dist/shared/@outfitter/cli-ndem6tz8.js +0 -63
  202. package/dist/shared/@outfitter/cli-nj4nqy1h.d.ts +0 -24
  203. package/dist/shared/@outfitter/cli-nkns8p4r.js +0 -61
  204. package/dist/shared/@outfitter/cli-p3dqm1vd.js +0 -22
  205. package/dist/shared/@outfitter/cli-pndwprz8.js +0 -118
  206. package/dist/shared/@outfitter/cli-pvrwv6rb.js +0 -352
  207. package/dist/shared/@outfitter/cli-py02m79x.d.ts +0 -20
  208. package/dist/shared/@outfitter/cli-qj83y5wj.d.ts +0 -71
  209. package/dist/shared/@outfitter/cli-regjbef6.d.ts +0 -26
  210. package/dist/shared/@outfitter/cli-s1tx5kha.d.ts +0 -59
  211. package/dist/shared/@outfitter/cli-sam2sq50.js +0 -37
  212. package/dist/shared/@outfitter/cli-snxj55n6.js +0 -43
  213. package/dist/shared/@outfitter/cli-symyxb0z.js +0 -20
  214. package/dist/shared/@outfitter/cli-tvw1xrdj.js +0 -20
  215. package/dist/shared/@outfitter/cli-v1tzwxkt.js +0 -32
  216. package/dist/shared/@outfitter/cli-vd60dj65.js +0 -1
  217. package/dist/shared/@outfitter/cli-vfcrskfj.d.ts +0 -41
  218. package/dist/shared/@outfitter/cli-vstbkzky.d.ts +0 -74
  219. package/dist/shared/@outfitter/cli-vtg0sqk2.d.ts +0 -54
  220. package/dist/shared/@outfitter/cli-x4cavvc0.js +0 -1
  221. package/dist/shared/@outfitter/cli-xep6v2c0.js +0 -52
  222. package/dist/shared/@outfitter/cli-xg5y5fhk.js +0 -86
  223. package/dist/shared/@outfitter/cli-y7k1t81k.js +0 -30
  224. package/dist/shared/@outfitter/cli-yfyzy95c.js +0 -67
  225. package/dist/shared/@outfitter/cli-z78mkrc7.js +0 -59
  226. package/dist/shared/@outfitter/cli-znc47004.js +0 -134
  227. package/dist/shared/@outfitter/cli-zx598p8q.d.ts +0 -26
  228. package/dist/streaming/ansi.d.ts +0 -2
  229. package/dist/streaming/ansi.js +0 -8
  230. package/dist/streaming/index.d.ts +0 -4
  231. package/dist/streaming/index.js +0 -17
  232. package/dist/streaming/spinner.d.ts +0 -3
  233. package/dist/streaming/spinner.js +0 -10
  234. package/dist/streaming/writer.d.ts +0 -2
  235. package/dist/streaming/writer.js +0 -9
  236. package/dist/table/index.d.ts +0 -4
  237. package/dist/table/index.js +0 -13
  238. package/dist/theme/context.d.ts +0 -9
  239. package/dist/theme/context.js +0 -14
  240. package/dist/theme/create.d.ts +0 -8
  241. package/dist/theme/create.js +0 -12
  242. package/dist/theme/index.d.ts +0 -17
  243. package/dist/theme/index.js +0 -42
  244. package/dist/theme/presets/bold.d.ts +0 -8
  245. package/dist/theme/presets/bold.js +0 -12
  246. package/dist/theme/presets/default.d.ts +0 -8
  247. package/dist/theme/presets/default.js +0 -11
  248. package/dist/theme/presets/index.d.ts +0 -12
  249. package/dist/theme/presets/index.js +0 -24
  250. package/dist/theme/presets/minimal.d.ts +0 -8
  251. package/dist/theme/presets/minimal.js +0 -12
  252. package/dist/theme/presets/rounded.d.ts +0 -8
  253. package/dist/theme/presets/rounded.js +0 -12
  254. package/dist/theme/resolve.d.ts +0 -8
  255. package/dist/theme/resolve.js +0 -11
  256. package/dist/theme/types.d.ts +0 -7
  257. package/dist/theme/types.js +0 -1
  258. package/dist/tree/index.d.ts +0 -3
  259. package/dist/tree/index.js +0 -11
  260. /package/dist/shared/@outfitter/{cli-ykxn7rb2.d.ts → cli-xppg982q.d.ts} +0 -0
  261. /package/dist/{render/types.js → shared/@outfitter/cli-zw75pdk8.js} +0 -0
@@ -1,146 +0,0 @@
1
- // @bun
2
- import {
3
- init_box,
4
- normalizeBorders,
5
- normalizePadding
6
- } from "./cli-jp0k3qd9.js";
7
-
8
- // packages/cli/src/render/layout.ts
9
- init_box();
10
- function getTerminalWidth() {
11
- return process.stdout.columns ?? 80;
12
- }
13
- function getBoxOverhead(options) {
14
- const pad = normalizePadding(options.padding, 1);
15
- const borders = normalizeBorders(options.borders);
16
- return {
17
- horizontal: (borders.left ? 1 : 0) + (borders.right ? 1 : 0) + pad.left + pad.right,
18
- vertical: (borders.top ? 1 : 0) + (borders.bottom ? 1 : 0) + pad.top + pad.bottom
19
- };
20
- }
21
- function getContentWidth(options) {
22
- const { horizontal } = getBoxOverhead(options);
23
- if (options.width) {
24
- const content = options.width - horizontal;
25
- return Math.max(0, content);
26
- }
27
- return Math.max(0, getTerminalWidth() - horizontal);
28
- }
29
- function resolveWidth(mode, ctx) {
30
- if (typeof mode === "number") {
31
- return mode;
32
- }
33
- if (mode === "text") {
34
- return 0;
35
- }
36
- if (mode === "full") {
37
- return getTerminalWidth();
38
- }
39
- if (mode === "container") {
40
- if (!ctx) {
41
- throw new Error("container width mode requires LayoutContext");
42
- }
43
- return ctx.width;
44
- }
45
- const percent = Number.parseInt(mode.slice(0, -1), 10);
46
- const baseWidth = ctx?.width ?? getTerminalWidth();
47
- return Math.floor(baseWidth * (percent / 100));
48
- }
49
- function createLayoutContext(options, parent) {
50
- const effectiveOptions = { ...options };
51
- if (effectiveOptions.width === undefined && parent) {
52
- effectiveOptions.width = parent.width;
53
- }
54
- const width = getContentWidth(effectiveOptions);
55
- return {
56
- width,
57
- ...parent && { parent }
58
- };
59
- }
60
- function getWidth(text) {
61
- return Bun.stringWidth(text);
62
- }
63
- function splitLines(block) {
64
- return block.split(`
65
- `);
66
- }
67
- function padToWidth(text, width) {
68
- const currentWidth = getWidth(text);
69
- if (currentWidth >= width)
70
- return text;
71
- return text + " ".repeat(width - currentWidth);
72
- }
73
- function createFilledArray(length, value) {
74
- const result = [];
75
- for (let i = 0;i < length; i++) {
76
- result.push(value);
77
- }
78
- return result;
79
- }
80
- function joinHorizontal(blocks, options) {
81
- if (blocks.length === 0)
82
- return "";
83
- const first = blocks[0];
84
- if (first === undefined)
85
- return "";
86
- if (blocks.length === 1)
87
- return first;
88
- const gap = options?.gap ?? 0;
89
- const align = options?.align ?? "top";
90
- const gapString = " ".repeat(gap);
91
- const blockLines = blocks.map(splitLines);
92
- const maxHeight = Math.max(...blockLines.map((lines) => lines.length));
93
- const blockWidths = blockLines.map((lines) => Math.max(...lines.map(getWidth)));
94
- const paddedBlocks = blockLines.map((lines, blockIndex) => {
95
- const width = blockWidths[blockIndex] ?? 0;
96
- const height = lines.length;
97
- const padding = maxHeight - height;
98
- let topPadding;
99
- switch (align) {
100
- case "top":
101
- topPadding = 0;
102
- break;
103
- case "center":
104
- topPadding = Math.floor(padding / 2);
105
- break;
106
- case "bottom":
107
- topPadding = padding;
108
- break;
109
- default: {
110
- const _exhaustive = align;
111
- topPadding = _exhaustive;
112
- }
113
- }
114
- const bottomPadding = padding - topPadding;
115
- const emptyLine = " ".repeat(width);
116
- const paddedLines = [
117
- ...createFilledArray(topPadding, emptyLine),
118
- ...lines.map((line) => padToWidth(line, width)),
119
- ...createFilledArray(bottomPadding, emptyLine)
120
- ];
121
- return paddedLines;
122
- });
123
- const resultLines = [];
124
- for (let i = 0;i < maxHeight; i++) {
125
- const lineSegments = paddedBlocks.map((block) => block[i] ?? "");
126
- resultLines.push(lineSegments.join(gapString));
127
- }
128
- return resultLines.join(`
129
- `);
130
- }
131
- function joinVertical(blocks, options) {
132
- if (blocks.length === 0)
133
- return "";
134
- const first = blocks[0];
135
- if (first === undefined)
136
- return "";
137
- if (blocks.length === 1)
138
- return first;
139
- const gap = options?.gap ?? 0;
140
- const gapLines = gap > 0 ? `
141
- `.repeat(gap) : "";
142
- return blocks.join(`
143
- ${gapLines}`);
144
- }
145
-
146
- export { getTerminalWidth, getBoxOverhead, getContentWidth, resolveWidth, createLayoutContext, joinHorizontal, joinVertical };
@@ -1,132 +0,0 @@
1
- /**
2
- * List rendering utilities.
3
- *
4
- * Renders arrays as bullet lists with optional nesting and multiple styles.
5
- *
6
- * @packageDocumentation
7
- */
8
- /**
9
- * Available list styles for {@link renderList}.
10
- *
11
- * - `dash`: Uses - character (default)
12
- * - `bullet`: Uses • character
13
- * - `number`: Uses 1. for top-level, a. for nested, i. for deeply nested
14
- * - `checkbox`: Uses ☐ for unchecked, ☑ for checked
15
- */
16
- type ListStyle = "dash" | "bullet" | "number" | "checkbox";
17
- /**
18
- * Options for customizing list rendering.
19
- *
20
- * @example
21
- * ```typescript
22
- * // Numbered list with custom indent
23
- * renderList(items, { style: "number", indent: 4 });
24
- *
25
- * // Checkbox list with some items checked
26
- * renderList(items, { style: "checkbox", checked: new Set([1, 3]) });
27
- * ```
28
- */
29
- interface ListOptions {
30
- /**
31
- * The list style to use.
32
- * @default "dash"
33
- */
34
- style?: ListStyle;
35
- /**
36
- * Indices of checked top-level items (0-indexed) for checkbox style.
37
- * Only applies to top-level items. For nested items, use the
38
- * `checked` property on {@link NestedListItem} instead.
39
- */
40
- checked?: Set<number>;
41
- /**
42
- * Number of spaces per indentation level.
43
- * @default 2
44
- */
45
- indent?: number;
46
- }
47
- /**
48
- * A list item with optional nested children for {@link renderList}.
49
- *
50
- * @example
51
- * ```typescript
52
- * const item: NestedListItem = {
53
- * text: "Parent item",
54
- * children: ["Child 1", "Child 2"],
55
- * };
56
- *
57
- * // Checkbox item with checked state
58
- * const checkboxItem: NestedListItem = {
59
- * text: "Completed task",
60
- * checked: true,
61
- * };
62
- *
63
- * // Mixed styles: numbered parent with bullet children
64
- * const mixedItem: NestedListItem = {
65
- * text: "Section 1",
66
- * childStyle: "bullet",
67
- * children: ["Unordered item A", "Unordered item B"],
68
- * };
69
- * ```
70
- */
71
- interface NestedListItem {
72
- /** The text content of this list item */
73
- text: string;
74
- /** Optional nested child items (strings or nested items) */
75
- children?: Array<string | NestedListItem>;
76
- /** Whether this item is checked (for checkbox style) */
77
- checked?: boolean;
78
- /** Override style for children (enables mixed numbered/bullet lists) */
79
- childStyle?: ListStyle;
80
- }
81
- /**
82
- * A list item that can be either a simple string or a nested item with children.
83
- *
84
- * @example
85
- * ```typescript
86
- * const items: ListItem[] = [
87
- * "Simple item",
88
- * { text: "Parent", children: ["Child 1", "Child 2"] },
89
- * ];
90
- * ```
91
- */
92
- type ListItem = string | NestedListItem;
93
- /**
94
- * Renders items as a list with optional nesting and multiple styles.
95
- *
96
- * Supports both simple string items and nested items with children.
97
- * The default style uses dash (-) characters.
98
- *
99
- * For numbered lists, child items are indented to align with the parent's
100
- * content (after the marker), creating proper visual hierarchy.
101
- *
102
- * @param items - Array of list items (strings or nested items)
103
- * @param options - Optional configuration for style, checked items, and indent
104
- * @returns Formatted list string
105
- *
106
- * @example
107
- * ```typescript
108
- * // Simple dash list (default)
109
- * console.log(renderList(["First", "Second", "Third"]));
110
- * // - First
111
- * // - Second
112
- * // - Third
113
- *
114
- * // Numbered list with nesting
115
- * console.log(renderList([
116
- * { text: "First section", children: [
117
- * { text: "Subsection A", children: ["Detail i", "Detail ii"] },
118
- * ]},
119
- * ], { style: "number" }));
120
- * // 1. First section
121
- * // a. Subsection A
122
- * // i. Detail i
123
- * // ii. Detail ii
124
- *
125
- * // Checkbox list
126
- * console.log(renderList(["Todo 1", "Todo 2"], { style: "checkbox", checked: new Set([1]) }));
127
- * // ☐ Todo 1
128
- * // ☑ Todo 2
129
- * ```
130
- */
131
- declare function renderList(items: ListItem[], options?: ListOptions): string;
132
- export { ListStyle, ListOptions, NestedListItem, ListItem, renderList };
@@ -1,39 +0,0 @@
1
- // @bun
2
- // packages/cli/src/render/tree.ts
3
- var TREE_GUIDES = {
4
- single: { vertical: "\u2502 ", fork: "\u251C\u2500\u2500 ", end: "\u2514\u2500\u2500 " },
5
- heavy: { vertical: "\u2503 ", fork: "\u2523\u2501\u2501 ", end: "\u2517\u2501\u2501 " },
6
- double: { vertical: "\u2551 ", fork: "\u2560\u2550\u2550 ", end: "\u255A\u2550\u2550 " },
7
- rounded: { vertical: "\u2502 ", fork: "\u251C\u2500\u2500 ", end: "\u2570\u2500\u2500 " }
8
- };
9
- function renderTree(tree, options) {
10
- const guide = TREE_GUIDES[options?.guide ?? "single"];
11
- const maxDepth = options?.maxDepth;
12
- const renderLabel = options?.renderLabel ?? ((key) => key);
13
- const lines = [];
14
- const renderNode = (key, value, prefix, isLast, depth) => {
15
- if (maxDepth !== undefined && depth >= maxDepth) {
16
- return;
17
- }
18
- const connector = isLast ? guide.end : guide.fork;
19
- const label = renderLabel(key, value, depth);
20
- lines.push(prefix + connector + label);
21
- if (value !== null && typeof value === "object") {
22
- const entries2 = Object.entries(value);
23
- const childPrefix = prefix + (isLast ? " " : guide.vertical);
24
- entries2.forEach(([childKey, childValue], index) => {
25
- const childIsLast = index === entries2.length - 1;
26
- renderNode(childKey, childValue, childPrefix, childIsLast, depth + 1);
27
- });
28
- }
29
- };
30
- const entries = Object.entries(tree);
31
- entries.forEach(([key, value], index) => {
32
- const isLast = index === entries.length - 1;
33
- renderNode(key, value, "", isLast, 0);
34
- });
35
- return lines.join(`
36
- `);
37
- }
38
-
39
- export { TREE_GUIDES, renderTree };
@@ -1 +0,0 @@
1
- // @bun
@@ -1,19 +0,0 @@
1
- // @bun
2
- // packages/cli/src/render/progress.ts
3
- function renderProgress(options) {
4
- const { current, total, width = 20, showPercent = false } = options;
5
- if (total <= 0) {
6
- const bar2 = "\u2591".repeat(width);
7
- return showPercent ? `[${bar2}] 0%` : `[${bar2}]`;
8
- }
9
- const percent = Math.min(100, Math.max(0, current / total * 100));
10
- const filled = Math.round(percent / 100 * width);
11
- const empty = width - filled;
12
- const bar = "\u2588".repeat(filled) + "\u2591".repeat(empty);
13
- if (showPercent) {
14
- return `[${bar}] ${Math.round(percent)}%`;
15
- }
16
- return `[${bar}]`;
17
- }
18
-
19
- export { renderProgress };
@@ -1,23 +0,0 @@
1
- // @bun
2
- import {
3
- createCancelledError
4
- } from "./cli-8bwaw3pz.js";
5
-
6
- // packages/cli/src/prompt/confirm.ts
7
- import { confirm, isCancel } from "@clack/prompts";
8
- import { Result } from "better-result";
9
- async function promptConfirm(options) {
10
- const confirmOptions = {
11
- message: options.message
12
- };
13
- if (options.initialValue !== undefined) {
14
- confirmOptions.initialValue = options.initialValue;
15
- }
16
- const result = await confirm(confirmOptions);
17
- if (isCancel(result)) {
18
- return Result.err(createCancelledError());
19
- }
20
- return Result.ok(result);
21
- }
22
-
23
- export { promptConfirm };
@@ -1,56 +0,0 @@
1
- import { SpinnerStyle } from "./cli-e5ms1y0x";
2
- import { ListStyle } from "./cli-b0tzqgnf";
3
- import { BorderStyle } from "./cli-fakncnjp";
4
- import { PrimitiveId, PrimitiveMeta, ThemeMethodMeta, VariantMeta } from "./cli-c6pbxpw0";
5
- import { Theme } from "./cli-ykxn7rb2";
6
- /**
7
- * Type-safe metadata for all theme methods.
8
- *
9
- * Uses `keyof Theme` to ensure every theme method has metadata.
10
- * Adding a new method to Theme without updating this causes a compile error.
11
- */
12
- declare const THEME_METHOD_META: Record<keyof Theme, ThemeMethodMeta>;
13
- /**
14
- * Gets theme methods grouped by category.
15
- */
16
- declare function getThemeMethodsByCategory(): {
17
- semantic: Array<keyof Theme>;
18
- utility: Array<keyof Theme>;
19
- };
20
- /**
21
- * Type-safe metadata for all border styles.
22
- */
23
- declare const BORDER_STYLE_META: Record<BorderStyle, VariantMeta<BorderStyle>>;
24
- /**
25
- * Gets all border styles as an array.
26
- */
27
- declare function getBorderStyles(): BorderStyle[];
28
- /**
29
- * Type-safe metadata for all spinner styles.
30
- */
31
- declare const SPINNER_STYLE_META: Record<SpinnerStyle, VariantMeta<SpinnerStyle>>;
32
- /**
33
- * Gets all spinner styles as an array.
34
- */
35
- declare function getSpinnerStyles(): SpinnerStyle[];
36
- /**
37
- * Type-safe metadata for all list styles.
38
- */
39
- declare const LIST_STYLE_META: Record<ListStyle, VariantMeta<ListStyle>>;
40
- /**
41
- * Gets all list styles as an array.
42
- */
43
- declare function getListStyles(): ListStyle[];
44
- /**
45
- * Type-safe metadata for all primitives.
46
- */
47
- declare const PRIMITIVE_META: Record<PrimitiveId, PrimitiveMeta>;
48
- /**
49
- * Gets all primitive IDs as an array.
50
- */
51
- declare function getPrimitiveIds(): PrimitiveId[];
52
- /**
53
- * Gets metadata for a specific primitive.
54
- */
55
- declare function getPrimitiveMeta(id: PrimitiveId): PrimitiveMeta;
56
- export { THEME_METHOD_META, getThemeMethodsByCategory, BORDER_STYLE_META, getBorderStyles, SPINNER_STYLE_META, getSpinnerStyles, LIST_STYLE_META, getListStyles, PRIMITIVE_META, getPrimitiveIds, getPrimitiveMeta };
@@ -1,112 +0,0 @@
1
- import { Theme } from "./cli-ykxn7rb2";
2
- /**
3
- * Available primitive types for demos.
4
- */
5
- type PrimitiveId = "colors" | "borders" | "spinner" | "list" | "box" | "table" | "progress" | "tree" | "text" | "markdown" | "indicators";
6
- /**
7
- * Categorization for theme methods.
8
- */
9
- type ThemeMethodCategory = "semantic" | "utility";
10
- /**
11
- * Metadata for a theme method.
12
- */
13
- interface ThemeMethodMeta {
14
- /** Method category (semantic or utility) */
15
- category: ThemeMethodCategory;
16
- /** Human-readable description */
17
- description: string;
18
- /** Default example text */
19
- defaultExample: string;
20
- }
21
- /**
22
- * Metadata for a primitive variant (spinner styles, border styles, etc).
23
- */
24
- interface VariantMeta<T extends string> {
25
- /** The variant value */
26
- value: T;
27
- /** Human-readable label */
28
- label: string;
29
- /** Description of the variant */
30
- description: string;
31
- }
32
- /**
33
- * Metadata describing a primitive for demo generation.
34
- */
35
- interface PrimitiveMeta {
36
- /** Primitive identifier */
37
- id: PrimitiveId;
38
- /** Human-readable name */
39
- name: string;
40
- /** Brief description */
41
- description: string;
42
- /** Import statement example */
43
- importExample: string;
44
- }
45
- /**
46
- * Customizable example texts for demos.
47
- *
48
- * Keys correspond to theme method names and other example contexts.
49
- */
50
- interface ExampleTexts {
51
- success: string;
52
- warning: string;
53
- error: string;
54
- info: string;
55
- primary: string;
56
- secondary: string;
57
- muted: string;
58
- accent: string;
59
- highlight: string;
60
- link: string;
61
- destructive: string;
62
- subtle: string;
63
- bold: string;
64
- italic: string;
65
- underline: string;
66
- dim: string;
67
- boxContent: string;
68
- boxTitle: string;
69
- spinnerMessage: string;
70
- progressLabel: string;
71
- listItems: string[];
72
- tableData: Record<string, unknown>[];
73
- treeData: Record<string, unknown>;
74
- markdownSample: string;
75
- }
76
- /**
77
- * Configuration for demo rendering.
78
- */
79
- interface DemoConfig {
80
- /**
81
- * Override default example texts.
82
- */
83
- examples?: Partial<ExampleTexts>;
84
- /**
85
- * Whether to show import statements.
86
- * @default true
87
- */
88
- showCode?: boolean;
89
- /**
90
- * Whether to show method/variant descriptions.
91
- * @default true
92
- */
93
- showDescriptions?: boolean;
94
- }
95
- /**
96
- * Function that renders a demo section for a primitive.
97
- */
98
- type DemoRenderer = (config: DemoConfig, theme: Theme) => string;
99
- /**
100
- * Registry entry for a primitive demo.
101
- */
102
- interface DemoRegistryEntry {
103
- /** Primitive metadata */
104
- meta: PrimitiveMeta;
105
- /** Render function */
106
- render: DemoRenderer;
107
- }
108
- /**
109
- * Checks if a string is a valid PrimitiveId.
110
- */
111
- declare function isPrimitiveId(value: string): value is PrimitiveId;
112
- export { PrimitiveId, ThemeMethodCategory, ThemeMethodMeta, VariantMeta, PrimitiveMeta, ExampleTexts, DemoConfig, DemoRenderer, DemoRegistryEntry, isPrimitiveId };
@@ -1,117 +0,0 @@
1
- // @bun
2
- import {
3
- getStringWidth,
4
- init_text,
5
- padText,
6
- truncateText
7
- } from "./cli-mwxsh3sr.js";
8
- import {
9
- getBorderCharacters,
10
- init_borders
11
- } from "./cli-85fg2vr5.js";
12
-
13
- // packages/cli/src/render/table.ts
14
- init_borders();
15
- init_text();
16
- function renderTable(data, options) {
17
- if (data.length === 0) {
18
- return "";
19
- }
20
- const allKeys = new Set;
21
- for (const row of data) {
22
- for (const key of Object.keys(row)) {
23
- allKeys.add(key);
24
- }
25
- }
26
- const keys = Array.from(allKeys);
27
- const headers = options?.headers ?? {};
28
- const getHeader = (key) => headers[key] ?? key;
29
- const columnWidths = {};
30
- for (const key of keys) {
31
- const headerWidth = getStringWidth(getHeader(key));
32
- let maxDataWidth = 0;
33
- for (const row of data) {
34
- const value = row[key];
35
- const strValue = value === undefined || value === null ? "" : String(value);
36
- const width = getStringWidth(strValue);
37
- if (width > maxDataWidth) {
38
- maxDataWidth = width;
39
- }
40
- }
41
- const optionWidth = options?.columnWidths?.[key];
42
- columnWidths[key] = optionWidth ?? Math.max(headerWidth, maxDataWidth);
43
- }
44
- const compact = options?.compact ?? false;
45
- const borderStyle = compact ? "none" : options?.border ?? "single";
46
- const chars = getBorderCharacters(borderStyle);
47
- const hasBorders = borderStyle !== "none";
48
- return hasBorders ? renderWithBorders(data, keys, columnWidths, getHeader, chars) : renderCompact(data, keys, columnWidths, getHeader);
49
- }
50
- function renderWithBorders(data, keys, columnWidths, getHeader, chars) {
51
- const lines = [];
52
- const colWidthsForBorder = keys.map((k) => (columnWidths[k] ?? 0) + 2);
53
- lines.push(drawHorizontalBorder(chars, colWidthsForBorder, "top"));
54
- lines.push(drawDataRow(keys.map((k) => getHeader(k)), keys.map((k) => columnWidths[k] ?? 0), chars.vertical));
55
- lines.push(drawHorizontalBorder(chars, colWidthsForBorder, "middle"));
56
- for (const row of data) {
57
- const values = keys.map((k) => {
58
- const value = row[k];
59
- let strValue = value === undefined || value === null ? "" : String(value);
60
- const width = columnWidths[k] ?? 0;
61
- if (getStringWidth(strValue) > width) {
62
- strValue = truncateText(strValue, width);
63
- }
64
- return strValue;
65
- });
66
- lines.push(drawDataRow(values, keys.map((k) => columnWidths[k] ?? 0), chars.vertical));
67
- }
68
- lines.push(drawHorizontalBorder(chars, colWidthsForBorder, "bottom"));
69
- return lines.join(`
70
- `);
71
- }
72
- function renderCompact(data, keys, columnWidths, getHeader) {
73
- const lines = [];
74
- const headerValues = keys.map((k) => {
75
- const header = getHeader(k);
76
- const width = columnWidths[k] ?? 0;
77
- return padText(header, width);
78
- });
79
- lines.push(headerValues.join(" "));
80
- for (const row of data) {
81
- const values = keys.map((k) => {
82
- const value = row[k];
83
- let strValue = value === undefined || value === null ? "" : String(value);
84
- const width = columnWidths[k] ?? 0;
85
- if (getStringWidth(strValue) > width) {
86
- strValue = truncateText(strValue, width);
87
- }
88
- return padText(strValue, width);
89
- });
90
- lines.push(values.join(" "));
91
- }
92
- return lines.join(`
93
- `);
94
- }
95
- function drawHorizontalBorder(chars, colWidths, position) {
96
- const positionChars = {
97
- top: { left: chars.topLeft, right: chars.topRight, cross: chars.topT },
98
- middle: { left: chars.leftT, right: chars.rightT, cross: chars.cross },
99
- bottom: {
100
- left: chars.bottomLeft,
101
- right: chars.bottomRight,
102
- cross: chars.bottomT
103
- }
104
- };
105
- const { left, right, cross } = positionChars[position];
106
- const segments = colWidths.map((w) => chars.horizontal.repeat(w));
107
- return `${left}${segments.join(cross)}${right}`;
108
- }
109
- function drawDataRow(values, widths, vertical) {
110
- const cells = values.map((value, i) => {
111
- const width = widths[i] ?? 0;
112
- return ` ${padText(value, width)} `;
113
- });
114
- return `${vertical}${cells.join(vertical)}${vertical}`;
115
- }
116
-
117
- export { renderTable };