@outfitter/cli 0.1.0-rc.2 → 0.1.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.
- package/README.md +21 -32
- package/dist/actions.d.ts +12 -1
- package/dist/actions.js +170 -3
- package/dist/borders/index.d.ts +3 -0
- package/dist/borders/index.js +13 -0
- package/dist/box/index.d.ts +4 -0
- package/dist/box/index.js +13 -0
- package/dist/cli.js +1 -1
- package/dist/colors/index.d.ts +3 -0
- package/dist/colors/index.js +18 -0
- package/dist/command.d.ts +40 -3
- package/dist/command.js +45 -3
- package/dist/demo/index.d.ts +78 -0
- package/dist/demo/index.js +148 -0
- package/dist/demo/registry.d.ts +7 -0
- package/dist/demo/registry.js +28 -0
- package/dist/demo/renderers/borders.d.ts +7 -0
- package/dist/demo/renderers/borders.js +17 -0
- package/dist/demo/renderers/box.d.ts +7 -0
- package/dist/demo/renderers/box.js +18 -0
- package/dist/demo/renderers/colors.d.ts +7 -0
- package/dist/demo/renderers/colors.js +18 -0
- package/dist/demo/renderers/indicators.d.ts +7 -0
- package/dist/demo/renderers/indicators.js +17 -0
- package/dist/demo/renderers/list.d.ts +7 -0
- package/dist/demo/renderers/list.js +19 -0
- package/dist/demo/renderers/markdown.d.ts +7 -0
- package/dist/demo/renderers/markdown.js +18 -0
- package/dist/demo/renderers/progress.d.ts +7 -0
- package/dist/demo/renderers/progress.js +17 -0
- package/dist/demo/renderers/spinner.d.ts +7 -0
- package/dist/demo/renderers/spinner.js +19 -0
- package/dist/demo/renderers/table.d.ts +7 -0
- package/dist/demo/renderers/table.js +19 -0
- package/dist/demo/renderers/text.d.ts +7 -0
- package/dist/demo/renderers/text.js +16 -0
- package/dist/demo/renderers/tree.d.ts +7 -0
- package/dist/demo/renderers/tree.js +18 -0
- package/dist/demo/section.d.ts +5 -0
- package/dist/demo/section.js +23 -0
- package/dist/demo/templates.d.ts +4 -0
- package/dist/demo/templates.js +10 -0
- package/dist/demo/types.d.ts +3 -0
- package/dist/demo/types.js +8 -0
- package/dist/index.d.ts +5 -8
- package/dist/index.js +9 -43
- package/dist/input.d.ts +163 -2
- package/dist/input.js +425 -11
- package/dist/list/index.d.ts +3 -0
- package/dist/list/index.js +9 -0
- package/dist/output.js +1 -1
- package/dist/pagination.d.ts +62 -2
- package/dist/pagination.js +84 -6
- package/dist/preset/full.d.ts +14 -0
- package/dist/preset/full.js +41 -0
- package/dist/preset/standard.d.ts +11 -0
- package/dist/preset/standard.js +30 -0
- package/dist/prompt/confirm.d.ts +4 -0
- package/dist/prompt/confirm.js +9 -0
- package/dist/prompt/group.d.ts +4 -0
- package/dist/prompt/group.js +9 -0
- package/dist/prompt/index.d.ts +7 -0
- package/dist/prompt/index.js +32 -0
- package/dist/prompt/select.d.ts +4 -0
- package/dist/prompt/select.js +11 -0
- package/dist/prompt/text.d.ts +4 -0
- package/dist/prompt/text.js +11 -0
- package/dist/prompt/types.d.ts +3 -0
- package/dist/prompt/types.js +8 -0
- package/dist/prompt/validators.d.ts +2 -0
- package/dist/prompt/validators.js +8 -0
- package/dist/render/borders.d.ts +2 -0
- package/dist/render/borders.js +15 -0
- package/dist/render/box.d.ts +3 -0
- package/dist/render/box.js +23 -0
- package/dist/render/colors.d.ts +1 -1
- package/dist/render/colors.js +6 -3
- package/dist/render/date.js +1 -1
- package/dist/render/format-relative.js +1 -1
- package/dist/render/format.js +1 -1
- package/dist/render/heading.d.ts +3 -0
- package/dist/render/heading.js +14 -0
- package/dist/render/index.d.ts +26 -7
- package/dist/render/index.js +160 -26
- package/dist/render/indicators.d.ts +2 -0
- package/dist/render/indicators.js +14 -0
- package/dist/render/json.js +1 -1
- package/dist/render/layout.d.ts +5 -0
- package/dist/render/layout.js +25 -0
- package/dist/render/list.d.ts +2 -2
- package/dist/render/list.js +2 -2
- package/dist/render/markdown.js +4 -4
- package/dist/render/progress.js +1 -1
- package/dist/render/separator.d.ts +3 -0
- package/dist/render/separator.js +14 -0
- package/dist/render/shapes.js +10 -9
- package/dist/render/spinner.d.ts +2 -0
- package/dist/render/spinner.js +12 -0
- package/dist/render/stack.d.ts +3 -0
- package/dist/render/stack.js +38 -0
- package/dist/render/table.d.ts +2 -1
- package/dist/render/table.js +6 -5
- package/dist/render/text.d.ts +1 -1
- package/dist/render/text.js +7 -4
- package/dist/render/tree.d.ts +2 -2
- package/dist/render/tree.js +5 -3
- package/dist/render/types.d.ts +2 -0
- package/dist/render/types.js +1 -0
- package/dist/shared/@outfitter/cli-0ggcy7fa.js +20 -0
- package/dist/shared/@outfitter/cli-0psys2vm.js +7 -0
- package/dist/shared/@outfitter/cli-1bghjef6.js +352 -0
- package/dist/shared/@outfitter/cli-1kwbnt86.d.ts +45 -0
- package/dist/shared/@outfitter/cli-2g8bx1aq.d.ts +50 -0
- package/dist/shared/@outfitter/cli-34fqr7bp.js +37 -0
- package/dist/shared/@outfitter/cli-3b7ed3rm.d.ts +97 -0
- package/dist/shared/@outfitter/cli-3dxmmy4c.d.ts +20 -0
- package/dist/shared/@outfitter/cli-3f12z5kf.d.ts +83 -0
- package/dist/shared/@outfitter/cli-3t2zaenc.d.ts +59 -0
- package/dist/shared/@outfitter/{cli-dds0qqvm.d.ts → cli-4cb5g831.d.ts} +2 -0
- package/dist/shared/@outfitter/cli-4w2a1rfy.d.ts +23 -0
- package/dist/shared/@outfitter/cli-4x6pqnez.js +20 -0
- package/dist/shared/@outfitter/cli-671sxkhj.js +146 -0
- package/dist/shared/@outfitter/cli-6bztk73z.d.ts +51 -0
- package/dist/shared/@outfitter/cli-6fxffp8k.js +1 -0
- package/dist/shared/@outfitter/cli-6j9qynm8.js +118 -0
- package/dist/shared/@outfitter/cli-6m988kh0.d.ts +61 -0
- package/dist/shared/@outfitter/cli-74ba31gz.js +134 -0
- package/dist/shared/@outfitter/cli-7gnrb8cr.js +214 -0
- package/dist/shared/@outfitter/cli-7nm6edvh.d.ts +17 -0
- package/dist/shared/@outfitter/cli-85fg2vr5.js +123 -0
- package/dist/shared/@outfitter/cli-8a8xrzhy.js +20 -0
- package/dist/shared/@outfitter/cli-8bwaw3pz.js +7 -0
- package/dist/shared/@outfitter/cli-8rx4g3s5.d.ts +41 -0
- package/dist/shared/@outfitter/cli-8xsmsbbd.d.ts +223 -0
- package/dist/shared/@outfitter/cli-96b2p4td.d.ts +56 -0
- package/dist/shared/@outfitter/cli-9khk3cbq.d.ts +190 -0
- package/dist/shared/@outfitter/cli-9mtjjykw.js +67 -0
- package/dist/shared/@outfitter/{cli-ag0w4pk0.js → cli-9nbyj2bt.js} +60 -21
- package/dist/shared/@outfitter/{cli-azzk8a1d.js → cli-afhjqmg3.js} +7 -3
- package/dist/shared/@outfitter/cli-an9j0h80.js +117 -0
- package/dist/shared/@outfitter/cli-ay411nbr.js +122 -0
- package/dist/shared/@outfitter/cli-b0tzqgnf.d.ts +132 -0
- package/dist/shared/@outfitter/cli-b5c2k0d7.js +39 -0
- package/dist/shared/@outfitter/cli-b5epywry.js +1 -0
- package/dist/shared/@outfitter/cli-bcmcaz1b.js +23 -0
- package/dist/shared/@outfitter/cli-bf3vma4q.js +61 -0
- package/dist/shared/@outfitter/cli-cf1xexgn.d.ts +53 -0
- package/dist/shared/@outfitter/cli-cs45xd6q.js +59 -0
- package/dist/shared/@outfitter/cli-d7jpshq5.d.ts +128 -0
- package/dist/shared/@outfitter/{cli-jbj78ac5.js → cli-d9ad0rqj.js} +6 -1
- package/dist/shared/@outfitter/cli-daw296mv.js +61 -0
- package/dist/shared/@outfitter/cli-e5ms1y0x.d.ts +91 -0
- package/dist/shared/@outfitter/cli-e73v3qqy.d.ts +93 -0
- package/dist/shared/@outfitter/cli-en6zn6sj.js +1 -0
- package/dist/shared/@outfitter/cli-ep2cvtk8.js +48 -0
- package/dist/shared/@outfitter/cli-f75h8e94.js +7 -0
- package/dist/shared/@outfitter/cli-fakncnjp.d.ts +106 -0
- package/dist/shared/@outfitter/cli-feb5j90n.js +94 -0
- package/dist/shared/@outfitter/cli-h20jc0bs.d.ts +66 -0
- package/dist/shared/@outfitter/cli-hnpbqmc8.d.ts +328 -0
- package/dist/shared/@outfitter/cli-j4n8gaf3.js +95 -0
- package/dist/shared/@outfitter/cli-jejfypgf.js +85 -0
- package/dist/shared/@outfitter/{cli-wqc652mx.js → cli-jhcdwvpn.js} +8 -8
- package/dist/shared/@outfitter/{cli-v9mjsvjh.js → cli-jjemfdta.js} +13 -46
- package/dist/shared/@outfitter/cli-kc84wmch.js +267 -0
- package/dist/shared/@outfitter/cli-ktqme80d.js +7 -0
- package/dist/shared/@outfitter/cli-mq0jp15z.js +1 -0
- package/dist/shared/@outfitter/cli-mymyavvj.d.ts +26 -0
- package/dist/shared/@outfitter/cli-n17gt1dz.js +19 -0
- package/dist/shared/@outfitter/cli-n9dbh0hp.js +51 -0
- package/dist/shared/@outfitter/cli-nvvc92c8.js +128 -0
- package/dist/shared/@outfitter/cli-p1m5dhrs.js +169 -0
- package/dist/shared/@outfitter/cli-p38sfxyk.js +25 -0
- package/dist/shared/@outfitter/cli-p3dqm1vd.js +22 -0
- package/dist/shared/@outfitter/cli-p9j1phge.js +20 -0
- package/dist/shared/@outfitter/cli-pkxmzavm.js +62 -0
- package/dist/shared/@outfitter/cli-q8r6jarq.d.ts +24 -0
- package/dist/shared/@outfitter/{cli-2y3kxew8.d.ts → cli-qj83y5wj.d.ts} +22 -9
- package/dist/shared/@outfitter/cli-qjfc3j11.d.ts +112 -0
- package/dist/shared/@outfitter/cli-qp4cbhqr.js +70 -0
- package/dist/shared/@outfitter/cli-s0kkx9m1.d.ts +164 -0
- package/dist/shared/@outfitter/cli-snxj55n6.js +43 -0
- package/dist/shared/@outfitter/cli-swwxvjvm.d.ts +24 -0
- package/dist/shared/@outfitter/cli-sx67mmfx.d.ts +98 -0
- package/dist/shared/@outfitter/cli-tarpsa8a.js +30 -0
- package/dist/shared/@outfitter/cli-thvzhjd1.js +126 -0
- package/dist/shared/@outfitter/cli-tqewy503.d.ts +36 -0
- package/dist/shared/@outfitter/cli-tvw1xrdj.js +20 -0
- package/dist/shared/@outfitter/cli-v1tzwxkt.js +32 -0
- package/dist/shared/@outfitter/cli-vd60dj65.js +1 -0
- package/dist/shared/@outfitter/cli-vp88gxev.js +279 -0
- package/dist/shared/@outfitter/cli-vstbkzky.d.ts +74 -0
- package/dist/shared/@outfitter/cli-vtg0sqk2.d.ts +54 -0
- package/dist/shared/@outfitter/cli-w5y3xepp.js +20 -0
- package/dist/shared/@outfitter/cli-x4cavvc0.js +1 -0
- package/dist/shared/@outfitter/cli-xep6v2c0.js +52 -0
- package/dist/shared/@outfitter/cli-xg5y5fhk.js +86 -0
- package/dist/shared/@outfitter/{cli-n51t773m.d.ts → cli-xsaheemc.d.ts} +44 -4
- package/dist/shared/@outfitter/cli-xvqtqjxk.js +82 -0
- package/dist/shared/@outfitter/cli-y25tt8nc.d.ts +48 -0
- package/dist/streaming/ansi.d.ts +2 -0
- package/dist/streaming/ansi.js +8 -0
- package/dist/streaming/index.d.ts +4 -0
- package/dist/streaming/index.js +17 -0
- package/dist/streaming/spinner.d.ts +3 -0
- package/dist/streaming/spinner.js +10 -0
- package/dist/streaming/writer.d.ts +2 -0
- package/dist/streaming/writer.js +9 -0
- package/dist/table/index.d.ts +4 -0
- package/dist/table/index.js +13 -0
- package/dist/terminal/detection.js +5 -2
- package/dist/terminal/index.js +6 -2
- package/dist/theme/context.d.ts +9 -0
- package/dist/theme/context.js +14 -0
- package/dist/theme/create.d.ts +8 -0
- package/dist/theme/create.js +12 -0
- package/dist/theme/index.d.ts +17 -0
- package/dist/theme/index.js +42 -0
- package/dist/theme/presets/bold.d.ts +8 -0
- package/dist/theme/presets/bold.js +12 -0
- package/dist/theme/presets/default.d.ts +8 -0
- package/dist/theme/presets/default.js +11 -0
- package/dist/theme/presets/index.d.ts +12 -0
- package/dist/theme/presets/index.js +24 -0
- package/dist/theme/presets/minimal.d.ts +8 -0
- package/dist/theme/presets/minimal.js +12 -0
- package/dist/theme/presets/rounded.d.ts +8 -0
- package/dist/theme/presets/rounded.js +12 -0
- package/dist/theme/resolve.d.ts +8 -0
- package/dist/theme/resolve.js +11 -0
- package/dist/theme/types.d.ts +7 -0
- package/dist/theme/types.js +1 -0
- package/dist/tree/index.d.ts +3 -0
- package/dist/tree/index.js +11 -0
- package/dist/types.js +1 -1
- package/package.json +168 -54
- package/dist/shared/@outfitter/cli-2vs2gxa8.js +0 -429
- package/dist/shared/@outfitter/cli-2yq94zst.d.ts +0 -39
- package/dist/shared/@outfitter/cli-6xc869x1.js +0 -26
- package/dist/shared/@outfitter/cli-7km1e58p.js +0 -85
- package/dist/shared/@outfitter/cli-8r0bnyyx.js +0 -43
- package/dist/shared/@outfitter/cli-afecwfrn.d.ts +0 -13
- package/dist/shared/@outfitter/cli-bt423m6y.js +0 -4
- package/dist/shared/@outfitter/cli-d4fegbad.d.ts +0 -66
- package/dist/shared/@outfitter/cli-e0ecw3x1.js +0 -64
- package/dist/shared/@outfitter/cli-fheaaa6b.js +0 -25
- package/dist/shared/@outfitter/cli-j361wp3g.d.ts +0 -41
- package/dist/shared/@outfitter/cli-p0m2fc51.js +0 -172
- package/dist/shared/@outfitter/cli-tyajr8qa.d.ts +0 -63
- package/dist/shared/@outfitter/cli-zs6jy1am.d.ts +0 -164
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { VisualTheme } from "./cli-s0kkx9m1";
|
|
2
|
+
import { LayoutContext } from "./cli-2g8bx1aq";
|
|
3
|
+
/**
|
|
4
|
+
* Layout context extended with theme information.
|
|
5
|
+
*
|
|
6
|
+
* Allows themes to cascade through component hierarchies. Children
|
|
7
|
+
* inherit their parent's theme unless explicitly overridden.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* import { createThemedContext, roundedTheme } from "@outfitter/cli/theme";
|
|
12
|
+
*
|
|
13
|
+
* // Create root context with theme
|
|
14
|
+
* const ctx = createThemedContext({ theme: roundedTheme, width: 80 });
|
|
15
|
+
*
|
|
16
|
+
* // Child inherits theme from parent
|
|
17
|
+
* const childCtx = createThemedContext({ width: 40, parent: ctx });
|
|
18
|
+
* console.log(childCtx.theme.border); // "rounded" (inherited)
|
|
19
|
+
*
|
|
20
|
+
* // Child can override theme
|
|
21
|
+
* const overrideCtx = createThemedContext({
|
|
22
|
+
* theme: boldTheme,
|
|
23
|
+
* width: 40,
|
|
24
|
+
* parent: ctx
|
|
25
|
+
* });
|
|
26
|
+
* console.log(overrideCtx.theme.border); // "heavy"
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
interface ThemedLayoutContext extends LayoutContext {
|
|
30
|
+
/** The visual theme for this context */
|
|
31
|
+
readonly theme: VisualTheme;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Options for creating a themed layout context.
|
|
35
|
+
*/
|
|
36
|
+
interface ThemedContextOptions {
|
|
37
|
+
/** Visual theme (inherited from parent if not specified) */
|
|
38
|
+
theme?: VisualTheme;
|
|
39
|
+
/** Available width in characters */
|
|
40
|
+
width?: number;
|
|
41
|
+
/** Parent context for inheritance */
|
|
42
|
+
parent?: ThemedLayoutContext;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Creates a themed layout context with cascading inheritance.
|
|
46
|
+
*
|
|
47
|
+
* Theme inheritance rules:
|
|
48
|
+
* 1. Explicit theme → use it
|
|
49
|
+
* 2. Parent exists → inherit parent's theme
|
|
50
|
+
* 3. No theme or parent → use defaultTheme
|
|
51
|
+
*
|
|
52
|
+
* Width inheritance rules:
|
|
53
|
+
* 1. Explicit width → use it
|
|
54
|
+
* 2. Parent exists → inherit parent's width
|
|
55
|
+
* 3. No width or parent → use terminal width (via getTerminalWidth)
|
|
56
|
+
*
|
|
57
|
+
* @param options - Context configuration
|
|
58
|
+
* @returns A ThemedLayoutContext with resolved theme and width
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```typescript
|
|
62
|
+
* // Root context with explicit theme and width
|
|
63
|
+
* const root = createThemedContext({ theme: roundedTheme, width: 100 });
|
|
64
|
+
*
|
|
65
|
+
* // Child with inherited theme, explicit width
|
|
66
|
+
* const child = createThemedContext({ width: 50, parent: root });
|
|
67
|
+
*
|
|
68
|
+
* // Nested child with overridden theme
|
|
69
|
+
* const nested = createThemedContext({
|
|
70
|
+
* theme: boldTheme,
|
|
71
|
+
* parent: child
|
|
72
|
+
* });
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
declare function createThemedContext(options: ThemedContextOptions): ThemedLayoutContext;
|
|
76
|
+
/**
|
|
77
|
+
* Gets the theme from a context, with fallback to defaultTheme.
|
|
78
|
+
*
|
|
79
|
+
* Useful when you have an optional context and need a theme.
|
|
80
|
+
*
|
|
81
|
+
* @param ctx - Optional themed context
|
|
82
|
+
* @returns The context's theme or defaultTheme if no context
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* ```typescript
|
|
86
|
+
* function renderComponent(ctx?: ThemedLayoutContext) {
|
|
87
|
+
* const theme = getContextTheme(ctx);
|
|
88
|
+
* // theme is always defined
|
|
89
|
+
* }
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
declare function getContextTheme(ctx?: ThemedLayoutContext): VisualTheme;
|
|
93
|
+
export { ThemedLayoutContext, ThemedContextOptions, createThemedContext, getContextTheme };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
// @bun
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
defaultTheme
|
|
4
|
+
} from "./cli-cs45xd6q.js";
|
|
5
|
+
import {
|
|
6
|
+
BORDERS,
|
|
7
|
+
init_borders
|
|
8
|
+
} from "./cli-85fg2vr5.js";
|
|
9
|
+
|
|
10
|
+
// packages/cli/src/theme/create.ts
|
|
11
|
+
init_borders();
|
|
12
|
+
function createVisualTheme(options) {
|
|
13
|
+
const base = options?.extends ?? defaultTheme;
|
|
14
|
+
const overrides = options?.overrides ?? {};
|
|
15
|
+
const border = overrides.border ?? base.border;
|
|
16
|
+
const borderChars = overrides.borderChars ?? (overrides.border ? BORDERS[overrides.border] : base.borderChars);
|
|
17
|
+
const colors = {
|
|
18
|
+
...base.colors,
|
|
19
|
+
...overrides.colors
|
|
20
|
+
};
|
|
21
|
+
const spacing = {
|
|
22
|
+
...base.spacing,
|
|
23
|
+
...overrides.spacing
|
|
24
|
+
};
|
|
25
|
+
const markers = {
|
|
26
|
+
...base.markers,
|
|
27
|
+
...overrides.markers
|
|
28
|
+
};
|
|
29
|
+
const checkbox = {
|
|
30
|
+
checked: overrides.checkbox?.checked ?? base.checkbox.checked,
|
|
31
|
+
unchecked: overrides.checkbox?.unchecked ?? base.checkbox.unchecked
|
|
32
|
+
};
|
|
33
|
+
return {
|
|
34
|
+
name: overrides.name ?? base.name,
|
|
35
|
+
border,
|
|
36
|
+
borderChars,
|
|
37
|
+
treeGuide: overrides.treeGuide ?? base.treeGuide,
|
|
38
|
+
delimiter: overrides.delimiter ?? base.delimiter,
|
|
39
|
+
markers,
|
|
40
|
+
listBullet: overrides.listBullet ?? base.listBullet,
|
|
41
|
+
checkbox,
|
|
42
|
+
colors,
|
|
43
|
+
spacing,
|
|
44
|
+
spinner: overrides.spinner ?? base.spinner
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export { createVisualTheme };
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Box-drawing border utilities.
|
|
3
|
+
*
|
|
4
|
+
* Provides border character sets and line drawing functions for tables, boxes, and panels.
|
|
5
|
+
*
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Available border style presets.
|
|
10
|
+
*
|
|
11
|
+
* - `single`: Standard Unicode single-line borders (┌─┐)
|
|
12
|
+
* - `double`: Double-line borders (╔═╗)
|
|
13
|
+
* - `rounded`: Rounded corners with single lines (╭─╮)
|
|
14
|
+
* - `heavy`: Thick/heavy borders (┏━┓)
|
|
15
|
+
* - `ascii`: ASCII-only fallback (+, -, |)
|
|
16
|
+
* - `none`: No borders (empty strings)
|
|
17
|
+
*/
|
|
18
|
+
type BorderStyle = "single" | "double" | "rounded" | "heavy" | "ascii" | "none";
|
|
19
|
+
/**
|
|
20
|
+
* Complete set of box-drawing characters for a border style.
|
|
21
|
+
*
|
|
22
|
+
* Includes corners, edges, and intersection characters for building
|
|
23
|
+
* tables, boxes, and other bordered elements.
|
|
24
|
+
*/
|
|
25
|
+
interface BorderCharacters {
|
|
26
|
+
/** Top-left corner (e.g., ┌ ╔ ╭ ┏) */
|
|
27
|
+
topLeft: string;
|
|
28
|
+
/** Top-right corner (e.g., ┐ ╗ ╮ ┓) */
|
|
29
|
+
topRight: string;
|
|
30
|
+
/** Bottom-left corner (e.g., └ ╚ ╰ ┗) */
|
|
31
|
+
bottomLeft: string;
|
|
32
|
+
/** Bottom-right corner (e.g., ┘ ╝ ╯ ┛) */
|
|
33
|
+
bottomRight: string;
|
|
34
|
+
/** Horizontal line (e.g., ─ ═ ━) */
|
|
35
|
+
horizontal: string;
|
|
36
|
+
/** Vertical line (e.g., │ ║ ┃) */
|
|
37
|
+
vertical: string;
|
|
38
|
+
/** Top T-intersection for column separators (e.g., ┬ ╦ ┳) */
|
|
39
|
+
topT: string;
|
|
40
|
+
/** Bottom T-intersection for column separators (e.g., ┴ ╩ ┻) */
|
|
41
|
+
bottomT: string;
|
|
42
|
+
/** Left T-intersection for row separators (e.g., ├ ╠ ┣) */
|
|
43
|
+
leftT: string;
|
|
44
|
+
/** Right T-intersection for row separators (e.g., ┤ ╣ ┫) */
|
|
45
|
+
rightT: string;
|
|
46
|
+
/** Cross intersection for table cells (e.g., ┼ ╬ ╋) */
|
|
47
|
+
cross: string;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Preset border character sets for each style.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```typescript
|
|
54
|
+
* import { BORDERS } from "@outfitter/cli";
|
|
55
|
+
*
|
|
56
|
+
* const single = BORDERS.single;
|
|
57
|
+
* console.log(`${single.topLeft}${single.horizontal.repeat(10)}${single.topRight}`);
|
|
58
|
+
* // Output: ┌──────────┐
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
declare const BORDERS: Record<BorderStyle, BorderCharacters>;
|
|
62
|
+
/**
|
|
63
|
+
* Returns the border character set for the given style.
|
|
64
|
+
*
|
|
65
|
+
* @param style - The border style preset
|
|
66
|
+
* @returns The complete set of border characters
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```typescript
|
|
70
|
+
* const chars = getBorderCharacters("rounded");
|
|
71
|
+
* console.log(chars.topLeft); // ╭
|
|
72
|
+
* console.log(chars.topRight); // ╮
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
declare function getBorderCharacters(style: BorderStyle): BorderCharacters;
|
|
76
|
+
/**
|
|
77
|
+
* Position of a horizontal line within a bordered element.
|
|
78
|
+
*/
|
|
79
|
+
type LinePosition = "top" | "middle" | "bottom";
|
|
80
|
+
/**
|
|
81
|
+
* Draws a horizontal line with the appropriate corner/intersection characters.
|
|
82
|
+
*
|
|
83
|
+
* Used for building table borders and box edges. Handles column intersections
|
|
84
|
+
* when column widths are provided.
|
|
85
|
+
*
|
|
86
|
+
* @param width - Total width of the line content (excluding corners)
|
|
87
|
+
* @param chars - Border character set to use
|
|
88
|
+
* @param position - Position of line: "top", "middle", or "bottom"
|
|
89
|
+
* @param columnWidths - Optional array of column widths for intersection placement
|
|
90
|
+
* @returns The formatted horizontal line string
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* ```typescript
|
|
94
|
+
* const chars = getBorderCharacters("single");
|
|
95
|
+
*
|
|
96
|
+
* // Simple line (no columns)
|
|
97
|
+
* drawHorizontalLine(10, chars, "top");
|
|
98
|
+
* // Returns: ┌──────────┐
|
|
99
|
+
*
|
|
100
|
+
* // Line with column intersections
|
|
101
|
+
* drawHorizontalLine(14, chars, "middle", [5, 7]);
|
|
102
|
+
* // Returns: ├─────┼───────┤
|
|
103
|
+
* ```
|
|
104
|
+
*/
|
|
105
|
+
declare function drawHorizontalLine(width: number, chars: BorderCharacters, position: LinePosition, columnWidths?: number[]): string;
|
|
106
|
+
export { BorderStyle, BorderCharacters, BORDERS, getBorderCharacters, LinePosition, drawHorizontalLine };
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
renderTable
|
|
4
|
+
} from "./cli-an9j0h80.js";
|
|
5
|
+
import {
|
|
6
|
+
BORDER_STYLE_META,
|
|
7
|
+
getBorderStyles
|
|
8
|
+
} from "./cli-kc84wmch.js";
|
|
9
|
+
import {
|
|
10
|
+
getExample
|
|
11
|
+
} from "./cli-xep6v2c0.js";
|
|
12
|
+
import {
|
|
13
|
+
demoSection
|
|
14
|
+
} from "./cli-34fqr7bp.js";
|
|
15
|
+
|
|
16
|
+
// packages/cli/src/demo/renderers/table.ts
|
|
17
|
+
function renderTableDemo(config, theme) {
|
|
18
|
+
const showCode = config.showCode ?? true;
|
|
19
|
+
const showDescriptions = config.showDescriptions ?? true;
|
|
20
|
+
const lines = [];
|
|
21
|
+
lines.push(demoSection("Basic Table"));
|
|
22
|
+
lines.push("");
|
|
23
|
+
if (showCode) {
|
|
24
|
+
lines.push('import { renderTable } from "@outfitter/cli/render";');
|
|
25
|
+
lines.push("");
|
|
26
|
+
lines.push("renderTable([");
|
|
27
|
+
lines.push(' { id: 1, name: "Alice", status: "Active" },');
|
|
28
|
+
lines.push(' { id: 2, name: "Bob", status: "Pending" },');
|
|
29
|
+
lines.push("])");
|
|
30
|
+
lines.push("");
|
|
31
|
+
}
|
|
32
|
+
const basicData = getExample("tableData", config.examples);
|
|
33
|
+
lines.push(renderTable(basicData));
|
|
34
|
+
lines.push("");
|
|
35
|
+
lines.push(demoSection("Custom Headers"));
|
|
36
|
+
lines.push("");
|
|
37
|
+
if (showCode) {
|
|
38
|
+
lines.push("renderTable(data, {");
|
|
39
|
+
lines.push(' headers: { id: "Task ID", name: "Assignee" }');
|
|
40
|
+
lines.push("})");
|
|
41
|
+
lines.push("");
|
|
42
|
+
}
|
|
43
|
+
lines.push(renderTable(basicData, {
|
|
44
|
+
headers: { id: "Task ID", name: "Assignee" }
|
|
45
|
+
}));
|
|
46
|
+
lines.push("");
|
|
47
|
+
lines.push(demoSection("Border Styles"));
|
|
48
|
+
lines.push("");
|
|
49
|
+
const styles = getBorderStyles().filter((s) => s !== "none");
|
|
50
|
+
const smallData = [
|
|
51
|
+
{ id: 1, name: "Alice" },
|
|
52
|
+
{ id: 2, name: "Bob" }
|
|
53
|
+
];
|
|
54
|
+
for (const style of styles) {
|
|
55
|
+
const meta = BORDER_STYLE_META[style];
|
|
56
|
+
lines.push(`${meta.label.toUpperCase()} (border: "${style}")`);
|
|
57
|
+
if (showDescriptions) {
|
|
58
|
+
lines.push(theme.muted(meta.description));
|
|
59
|
+
}
|
|
60
|
+
lines.push("");
|
|
61
|
+
lines.push(renderTable(smallData, { border: style }));
|
|
62
|
+
lines.push("");
|
|
63
|
+
}
|
|
64
|
+
lines.push(demoSection("Compact Mode"));
|
|
65
|
+
lines.push("");
|
|
66
|
+
if (showCode) {
|
|
67
|
+
lines.push("renderTable(data, { compact: true })");
|
|
68
|
+
lines.push("");
|
|
69
|
+
}
|
|
70
|
+
lines.push(renderTable(smallData, { compact: true }));
|
|
71
|
+
lines.push("");
|
|
72
|
+
lines.push(theme.muted("Compact mode removes borders and uses space separators."));
|
|
73
|
+
lines.push("");
|
|
74
|
+
lines.push(demoSection("Wide Characters (CJK/Emoji)"));
|
|
75
|
+
lines.push("");
|
|
76
|
+
if (showCode) {
|
|
77
|
+
lines.push("renderTable([");
|
|
78
|
+
lines.push(' { id: 1, name: "\u5C71\u7530\u592A\u90CE", status: "\u5B8C\u4E86" },');
|
|
79
|
+
lines.push(' { id: 2, name: "Party \uD83C\uDF89", status: "\uD83D\uDE80" },');
|
|
80
|
+
lines.push("])");
|
|
81
|
+
lines.push("");
|
|
82
|
+
}
|
|
83
|
+
const wideData = [
|
|
84
|
+
{ id: 1, name: "\u5C71\u7530\u592A\u90CE", status: "\u5B8C\u4E86" },
|
|
85
|
+
{ id: 2, name: "Party \uD83C\uDF89", status: "\uD83D\uDE80" }
|
|
86
|
+
];
|
|
87
|
+
lines.push(renderTable(wideData));
|
|
88
|
+
lines.push("");
|
|
89
|
+
lines.push(theme.muted("Uses Bun.stringWidth() for correct column alignment."));
|
|
90
|
+
return lines.join(`
|
|
91
|
+
`);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export { renderTableDemo };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { WritableStream } from "./cli-cf1xexgn";
|
|
2
|
+
/**
|
|
3
|
+
* Spinner frame sets.
|
|
4
|
+
*/
|
|
5
|
+
declare const SPINNER_FRAMES: {
|
|
6
|
+
readonly dots: readonly ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
|
|
7
|
+
readonly line: readonly ["-", "\\", "|", "/"];
|
|
8
|
+
readonly simple: readonly ["◐", "◓", "◑", "◒"];
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Available spinner styles.
|
|
12
|
+
*/
|
|
13
|
+
type SpinnerStyle = keyof typeof SPINNER_FRAMES;
|
|
14
|
+
/**
|
|
15
|
+
* Options for creating a spinner.
|
|
16
|
+
*/
|
|
17
|
+
interface SpinnerOptions {
|
|
18
|
+
/** Spinner style */
|
|
19
|
+
style?: SpinnerStyle;
|
|
20
|
+
/** Target stream */
|
|
21
|
+
stream?: WritableStream;
|
|
22
|
+
/** Frame interval in ms */
|
|
23
|
+
interval?: number;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Spinner interface for animated progress indication.
|
|
27
|
+
*/
|
|
28
|
+
interface Spinner {
|
|
29
|
+
/** Start the spinner */
|
|
30
|
+
start(): void;
|
|
31
|
+
/** Update the spinner message */
|
|
32
|
+
update(message: string): void;
|
|
33
|
+
/** Stop with success state */
|
|
34
|
+
succeed(message?: string): void;
|
|
35
|
+
/** Stop with failure state */
|
|
36
|
+
fail(message?: string): void;
|
|
37
|
+
/** Stop the spinner */
|
|
38
|
+
stop(): void;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Creates an animated spinner for indicating progress.
|
|
42
|
+
*
|
|
43
|
+
* In TTY mode, shows an animated spinner. In non-TTY mode,
|
|
44
|
+
* falls back to static output.
|
|
45
|
+
*
|
|
46
|
+
* @param message - Initial spinner message
|
|
47
|
+
* @param options - Spinner configuration
|
|
48
|
+
* @returns Spinner instance
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```typescript
|
|
52
|
+
* import { createSpinner } from "@outfitter/cli/streaming";
|
|
53
|
+
*
|
|
54
|
+
* const spinner = createSpinner("Installing dependencies");
|
|
55
|
+
* spinner.start();
|
|
56
|
+
*
|
|
57
|
+
* try {
|
|
58
|
+
* await install();
|
|
59
|
+
* spinner.succeed("Dependencies installed");
|
|
60
|
+
* } catch (error) {
|
|
61
|
+
* spinner.fail("Installation failed");
|
|
62
|
+
* }
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
declare function createSpinner(message: string, options?: SpinnerOptions): Spinner;
|
|
66
|
+
export { SpinnerStyle, SpinnerOptions, Spinner, createSpinner };
|