@shell-shock/preset-script 0.6.3 → 0.6.5
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 +1 -1
- package/dist/components/banner-function-declaration.cjs +13 -7
- package/dist/components/banner-function-declaration.cjs.map +1 -1
- package/dist/components/banner-function-declaration.d.cts +2 -0
- package/dist/components/banner-function-declaration.d.cts.map +1 -1
- package/dist/components/banner-function-declaration.d.mts +2 -0
- package/dist/components/banner-function-declaration.d.mts.map +1 -1
- package/dist/components/banner-function-declaration.mjs +15 -9
- package/dist/components/banner-function-declaration.mjs.map +1 -1
- package/dist/components/bin-entry.cjs +4 -10
- package/dist/components/bin-entry.cjs.map +1 -1
- package/dist/components/bin-entry.d.cts.map +1 -1
- package/dist/components/bin-entry.d.mts.map +1 -1
- package/dist/components/bin-entry.mjs +4 -10
- package/dist/components/bin-entry.mjs.map +1 -1
- package/dist/components/command-entry.cjs +13 -12
- package/dist/components/command-entry.cjs.map +1 -1
- package/dist/components/command-entry.d.cts +1 -0
- package/dist/components/command-entry.d.cts.map +1 -1
- package/dist/components/command-entry.d.mts +1 -0
- package/dist/components/command-entry.d.mts.map +1 -1
- package/dist/components/command-entry.mjs +13 -12
- package/dist/components/command-entry.mjs.map +1 -1
- package/dist/components/command-router.cjs +2 -2
- package/dist/components/command-router.cjs.map +1 -1
- package/dist/components/command-router.d.cts.map +1 -1
- package/dist/components/command-router.d.mts.map +1 -1
- package/dist/components/command-router.mjs +2 -2
- package/dist/components/command-router.mjs.map +1 -1
- package/dist/components/console-builtin.cjs +773 -102
- package/dist/components/console-builtin.cjs.map +1 -1
- package/dist/components/console-builtin.d.cts +2 -2
- package/dist/components/console-builtin.d.cts.map +1 -1
- package/dist/components/console-builtin.d.mts +2 -2
- package/dist/components/console-builtin.d.mts.map +1 -1
- package/dist/components/console-builtin.mjs +774 -104
- package/dist/components/console-builtin.mjs.map +1 -1
- package/dist/components/help.cjs +6 -9
- package/dist/components/help.cjs.map +1 -1
- package/dist/components/help.d.cts +7 -7
- package/dist/components/help.d.cts.map +1 -1
- package/dist/components/help.d.mts +7 -7
- package/dist/components/help.d.mts.map +1 -1
- package/dist/components/help.mjs +6 -9
- package/dist/components/help.mjs.map +1 -1
- package/dist/components/helpers.d.cts +5 -5
- package/dist/components/helpers.d.mts +5 -5
- package/dist/components/index.cjs +1 -0
- package/dist/components/index.d.cts +2 -2
- package/dist/components/index.d.mts +2 -2
- package/dist/components/index.mjs +2 -2
- package/dist/components/utils-builtin.cjs +19 -36
- package/dist/components/utils-builtin.cjs.map +1 -1
- package/dist/components/utils-builtin.d.cts.map +1 -1
- package/dist/components/utils-builtin.d.mts +8 -8
- package/dist/components/utils-builtin.d.mts.map +1 -1
- package/dist/components/utils-builtin.mjs +19 -36
- package/dist/components/utils-builtin.mjs.map +1 -1
- package/dist/components/virtual-command-entry.cjs +8 -3
- package/dist/components/virtual-command-entry.cjs.map +1 -1
- package/dist/components/virtual-command-entry.d.cts +1 -0
- package/dist/components/virtual-command-entry.d.cts.map +1 -1
- package/dist/components/virtual-command-entry.d.mts +1 -0
- package/dist/components/virtual-command-entry.d.mts.map +1 -1
- package/dist/components/virtual-command-entry.mjs +8 -3
- package/dist/components/virtual-command-entry.mjs.map +1 -1
- package/dist/helpers/ansi-utils.cjs +117 -3
- package/dist/helpers/ansi-utils.cjs.map +1 -1
- package/dist/helpers/ansi-utils.d.cts.map +1 -1
- package/dist/helpers/ansi-utils.d.mts.map +1 -1
- package/dist/helpers/ansi-utils.mjs +117 -3
- package/dist/helpers/ansi-utils.mjs.map +1 -1
- package/dist/index.cjs +1 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -2
- package/dist/index.mjs.map +1 -1
- package/dist/types/plugin.d.cts.map +1 -1
- package/package.json +12 -12
|
@@ -4,6 +4,7 @@ const require_components_helpers = require('./helpers.cjs');
|
|
|
4
4
|
let __alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
5
5
|
let __alloy_js_core = require("@alloy-js/core");
|
|
6
6
|
let __alloy_js_typescript = require("@alloy-js/typescript");
|
|
7
|
+
let __powerlines_plugin_alloy_core_components_spacing = require("@powerlines/plugin-alloy/core/components/spacing");
|
|
7
8
|
let __powerlines_plugin_alloy_typescript_components_tsdoc = require("@powerlines/plugin-alloy/typescript/components/tsdoc");
|
|
8
9
|
let defu = require("defu");
|
|
9
10
|
let __powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
|
|
@@ -11,6 +12,126 @@ let __powerlines_plugin_alloy_typescript_components_builtin_file = require("@pow
|
|
|
11
12
|
let __stryke_string_format_vowels = require("@stryke/string-format/vowels");
|
|
12
13
|
|
|
13
14
|
//#region src/components/console-builtin.tsx
|
|
15
|
+
function AnsiHelpersDeclarations() {
|
|
16
|
+
return [
|
|
17
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.VarDeclaration, {
|
|
18
|
+
"const": true,
|
|
19
|
+
"export": true,
|
|
20
|
+
name: "beep",
|
|
21
|
+
doc: "The ASCII Bell character, which can be used to trigger a beep sound in the console.",
|
|
22
|
+
children: __alloy_js_core.code` "\\u0007"; `
|
|
23
|
+
}),
|
|
24
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
25
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.VarDeclaration, {
|
|
26
|
+
"const": true,
|
|
27
|
+
"export": true,
|
|
28
|
+
name: "cursor",
|
|
29
|
+
doc: "An object containing ANSI escape codes for controlling the console cursor.",
|
|
30
|
+
children: __alloy_js_core.code` {
|
|
31
|
+
to(x, y) {
|
|
32
|
+
if (!y) {
|
|
33
|
+
return \`\\x1B[\${x + 1}G\`;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return \`\\x1B[\${y + 1};\${x + 1}H\`;
|
|
37
|
+
},
|
|
38
|
+
move(x, y) {
|
|
39
|
+
let ret = '';
|
|
40
|
+
|
|
41
|
+
if (x < 0) {
|
|
42
|
+
ret += \`\\x1B[\${-x}D\`;
|
|
43
|
+
} else if (x > 0) {
|
|
44
|
+
ret += \`\\x1B[\${x}C\`;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (y < 0) {
|
|
48
|
+
ret += \`\\x1B[\${-y}A\`;
|
|
49
|
+
} else if (y > 0) {
|
|
50
|
+
ret += \`\\x1B[\${y}B\`;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return ret;
|
|
54
|
+
},
|
|
55
|
+
up: (count = 1) => \`\\x1B[\${count}A\`,
|
|
56
|
+
down: (count = 1) => \`\\x1B[\${count}B\`,
|
|
57
|
+
forward: (count = 1) => \`\\x1B[\${count}C\`,
|
|
58
|
+
backward: (count = 1) => \`\\x1B[\${count}D\`,
|
|
59
|
+
nextLine: (count = 1) => "\\x1B[E".repeat(count),
|
|
60
|
+
prevLine: (count = 1) => "\\x1B[F".repeat(count),
|
|
61
|
+
left: "\\x1B[G",
|
|
62
|
+
hide: "\\x1B[?25l",
|
|
63
|
+
show: "\\x1B[?25h",
|
|
64
|
+
save: "\\x1B7",
|
|
65
|
+
restore: "\\x1B8"
|
|
66
|
+
} `
|
|
67
|
+
}),
|
|
68
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
69
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.VarDeclaration, {
|
|
70
|
+
"const": true,
|
|
71
|
+
"export": true,
|
|
72
|
+
name: "erase",
|
|
73
|
+
doc: "An object containing ANSI escape codes for erasing parts of the console.",
|
|
74
|
+
children: __alloy_js_core.code` {
|
|
75
|
+
screen: "\\x1B[2J",
|
|
76
|
+
up: (count = 1) => "\\x1B[1J".repeat(count),
|
|
77
|
+
down: (count = 1) => "\\x1B[J".repeat(count),
|
|
78
|
+
line: "\\x1B[2K",
|
|
79
|
+
lineEnd: "\\x1B[K",
|
|
80
|
+
lineStart: "\\x1B[1K",
|
|
81
|
+
lines(count) {
|
|
82
|
+
let lineClear = "";
|
|
83
|
+
for (let i = 0; i < count; i++) {
|
|
84
|
+
lineClear += this.line + (i < count - 1 ? cursor.up() : "");
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (count) {
|
|
88
|
+
lineClear += cursor.left;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return lineClear;
|
|
92
|
+
}
|
|
93
|
+
} `
|
|
94
|
+
}),
|
|
95
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
96
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.VarDeclaration, {
|
|
97
|
+
"const": true,
|
|
98
|
+
"export": true,
|
|
99
|
+
name: "scroll",
|
|
100
|
+
doc: "An object containing ANSI escape codes for scrolling the console.",
|
|
101
|
+
children: __alloy_js_core.code` {
|
|
102
|
+
up: (count = 1) => "\\x1B[S".repeat(count),
|
|
103
|
+
down: (count = 1) => "\\x1B[T".repeat(count)
|
|
104
|
+
} `
|
|
105
|
+
}),
|
|
106
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
107
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.FunctionDeclaration, {
|
|
108
|
+
"export": true,
|
|
109
|
+
name: "clear",
|
|
110
|
+
doc: "A helper function to clear the console based on a count of lines",
|
|
111
|
+
parameters: [{
|
|
112
|
+
name: "current",
|
|
113
|
+
type: "string",
|
|
114
|
+
doc: "The current console output to be cleared"
|
|
115
|
+
}, {
|
|
116
|
+
name: "consoleWidth",
|
|
117
|
+
type: "number",
|
|
118
|
+
doc: "The number of characters per line in the console"
|
|
119
|
+
}],
|
|
120
|
+
children: __alloy_js_core.code`if (!consoleWidth) {
|
|
121
|
+
return erase.line + cursor.to(0);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
let rows = 0;
|
|
125
|
+
const lines = current.split(/\\r?\\n/);
|
|
126
|
+
for (let line of lines) {
|
|
127
|
+
rows += 1 + Math.floor(Math.max([...stripAnsi(line)].length - 1, 0) / consoleWidth);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return erase.lines(rows); `
|
|
131
|
+
}),
|
|
132
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {})
|
|
133
|
+
];
|
|
134
|
+
}
|
|
14
135
|
/**
|
|
15
136
|
* A component to generate a console message function in a Shell Shock project.
|
|
16
137
|
*/
|
|
@@ -53,8 +174,7 @@ function ColorsDeclaration() {
|
|
|
53
174
|
});
|
|
54
175
|
}
|
|
55
176
|
}),
|
|
56
|
-
(0, __alloy_js_core_jsx_runtime.
|
|
57
|
-
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
177
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
58
178
|
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
59
179
|
__alloy_js_core.code`
|
|
60
180
|
/**
|
|
@@ -64,16 +184,14 @@ function ColorsDeclaration() {
|
|
|
64
184
|
* This type allows for nested theme color definitions, enabling complex theming structures for console applications.
|
|
65
185
|
*/
|
|
66
186
|
export type ThemeColors<T> = T extends object ? { [K in keyof T]: ThemeColors<T[K]>; } : ((text: string) => string); `,
|
|
67
|
-
(0, __alloy_js_core_jsx_runtime.
|
|
68
|
-
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
187
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
69
188
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.TypeDeclaration, {
|
|
70
189
|
"export": true,
|
|
71
190
|
name: "Colors",
|
|
72
191
|
doc: "An object containing functions for coloring console applications. Each function corresponds to a terminal color. See {@link AnsiColor} for available colors.",
|
|
73
192
|
children: __alloy_js_core.code`Record<AnsiColor, (text: string) => string> & ThemeColors<ThemeColorsResolvedConfig>`
|
|
74
193
|
}),
|
|
75
|
-
(0, __alloy_js_core_jsx_runtime.
|
|
76
|
-
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
194
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
77
195
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, { heading: "An object containing functions for coloring console applications. Each function corresponds to a terminal color. See {@link Colors} for available colors." }),
|
|
78
196
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.VarDeclaration, {
|
|
79
197
|
"const": true,
|
|
@@ -784,6 +902,302 @@ function ColorsDeclaration() {
|
|
|
784
902
|
return colors.ansi16m.theme.text.usage.description;
|
|
785
903
|
}
|
|
786
904
|
})}
|
|
905
|
+
},
|
|
906
|
+
prompt: {
|
|
907
|
+
icon: {
|
|
908
|
+
active: ${(0, __alloy_js_core_jsx_runtime.createComponent)(ColorFunction, {
|
|
909
|
+
get ansi16() {
|
|
910
|
+
return colors.ansi16.theme.text.prompt.icon.active;
|
|
911
|
+
},
|
|
912
|
+
get ansi256() {
|
|
913
|
+
return colors.ansi256.theme.text.prompt.icon.active;
|
|
914
|
+
},
|
|
915
|
+
get ansi16m() {
|
|
916
|
+
return colors.ansi16m.theme.text.prompt.icon.active;
|
|
917
|
+
}
|
|
918
|
+
})},
|
|
919
|
+
warning: ${(0, __alloy_js_core_jsx_runtime.createComponent)(ColorFunction, {
|
|
920
|
+
get ansi16() {
|
|
921
|
+
return colors.ansi16.theme.text.prompt.icon.warning;
|
|
922
|
+
},
|
|
923
|
+
get ansi256() {
|
|
924
|
+
return colors.ansi256.theme.text.prompt.icon.warning;
|
|
925
|
+
},
|
|
926
|
+
get ansi16m() {
|
|
927
|
+
return colors.ansi16m.theme.text.prompt.icon.warning;
|
|
928
|
+
}
|
|
929
|
+
})},
|
|
930
|
+
error: ${(0, __alloy_js_core_jsx_runtime.createComponent)(ColorFunction, {
|
|
931
|
+
get ansi16() {
|
|
932
|
+
return colors.ansi16.theme.text.prompt.icon.error;
|
|
933
|
+
},
|
|
934
|
+
get ansi256() {
|
|
935
|
+
return colors.ansi256.theme.text.prompt.icon.error;
|
|
936
|
+
},
|
|
937
|
+
get ansi16m() {
|
|
938
|
+
return colors.ansi16m.theme.text.prompt.icon.error;
|
|
939
|
+
}
|
|
940
|
+
})},
|
|
941
|
+
submitted: ${(0, __alloy_js_core_jsx_runtime.createComponent)(ColorFunction, {
|
|
942
|
+
get ansi16() {
|
|
943
|
+
return colors.ansi16.theme.text.prompt.icon.submitted;
|
|
944
|
+
},
|
|
945
|
+
get ansi256() {
|
|
946
|
+
return colors.ansi256.theme.text.prompt.icon.submitted;
|
|
947
|
+
},
|
|
948
|
+
get ansi16m() {
|
|
949
|
+
return colors.ansi16m.theme.text.prompt.icon.submitted;
|
|
950
|
+
}
|
|
951
|
+
})},
|
|
952
|
+
cancelled: ${(0, __alloy_js_core_jsx_runtime.createComponent)(ColorFunction, {
|
|
953
|
+
get ansi16() {
|
|
954
|
+
return colors.ansi16.theme.text.prompt.icon.cancelled;
|
|
955
|
+
},
|
|
956
|
+
get ansi256() {
|
|
957
|
+
return colors.ansi256.theme.text.prompt.icon.cancelled;
|
|
958
|
+
},
|
|
959
|
+
get ansi16m() {
|
|
960
|
+
return colors.ansi16m.theme.text.prompt.icon.cancelled;
|
|
961
|
+
}
|
|
962
|
+
})},
|
|
963
|
+
disabled: ${(0, __alloy_js_core_jsx_runtime.createComponent)(ColorFunction, {
|
|
964
|
+
get ansi16() {
|
|
965
|
+
return colors.ansi16.theme.text.prompt.icon.disabled;
|
|
966
|
+
},
|
|
967
|
+
get ansi256() {
|
|
968
|
+
return colors.ansi256.theme.text.prompt.icon.disabled;
|
|
969
|
+
},
|
|
970
|
+
get ansi16m() {
|
|
971
|
+
return colors.ansi16m.theme.text.prompt.icon.disabled;
|
|
972
|
+
}
|
|
973
|
+
})}
|
|
974
|
+
},
|
|
975
|
+
message: {
|
|
976
|
+
active: ${(0, __alloy_js_core_jsx_runtime.createComponent)(ColorFunction, {
|
|
977
|
+
get ansi16() {
|
|
978
|
+
return colors.ansi16.theme.text.prompt.message.active;
|
|
979
|
+
},
|
|
980
|
+
get ansi256() {
|
|
981
|
+
return colors.ansi256.theme.text.prompt.message.active;
|
|
982
|
+
},
|
|
983
|
+
get ansi16m() {
|
|
984
|
+
return colors.ansi16m.theme.text.prompt.message.active;
|
|
985
|
+
}
|
|
986
|
+
})},
|
|
987
|
+
warning: ${(0, __alloy_js_core_jsx_runtime.createComponent)(ColorFunction, {
|
|
988
|
+
get ansi16() {
|
|
989
|
+
return colors.ansi16.theme.text.prompt.message.warning;
|
|
990
|
+
},
|
|
991
|
+
get ansi256() {
|
|
992
|
+
return colors.ansi256.theme.text.prompt.message.warning;
|
|
993
|
+
},
|
|
994
|
+
get ansi16m() {
|
|
995
|
+
return colors.ansi16m.theme.text.prompt.message.warning;
|
|
996
|
+
}
|
|
997
|
+
})},
|
|
998
|
+
error: ${(0, __alloy_js_core_jsx_runtime.createComponent)(ColorFunction, {
|
|
999
|
+
get ansi16() {
|
|
1000
|
+
return colors.ansi16.theme.text.prompt.message.error;
|
|
1001
|
+
},
|
|
1002
|
+
get ansi256() {
|
|
1003
|
+
return colors.ansi256.theme.text.prompt.message.error;
|
|
1004
|
+
},
|
|
1005
|
+
get ansi16m() {
|
|
1006
|
+
return colors.ansi16m.theme.text.prompt.message.error;
|
|
1007
|
+
}
|
|
1008
|
+
})},
|
|
1009
|
+
submitted: ${(0, __alloy_js_core_jsx_runtime.createComponent)(ColorFunction, {
|
|
1010
|
+
get ansi16() {
|
|
1011
|
+
return colors.ansi16.theme.text.prompt.message.submitted;
|
|
1012
|
+
},
|
|
1013
|
+
get ansi256() {
|
|
1014
|
+
return colors.ansi256.theme.text.prompt.message.submitted;
|
|
1015
|
+
},
|
|
1016
|
+
get ansi16m() {
|
|
1017
|
+
return colors.ansi16m.theme.text.prompt.message.submitted;
|
|
1018
|
+
}
|
|
1019
|
+
})},
|
|
1020
|
+
cancelled: ${(0, __alloy_js_core_jsx_runtime.createComponent)(ColorFunction, {
|
|
1021
|
+
get ansi16() {
|
|
1022
|
+
return colors.ansi16.theme.text.prompt.message.cancelled;
|
|
1023
|
+
},
|
|
1024
|
+
get ansi256() {
|
|
1025
|
+
return colors.ansi256.theme.text.prompt.message.cancelled;
|
|
1026
|
+
},
|
|
1027
|
+
get ansi16m() {
|
|
1028
|
+
return colors.ansi16m.theme.text.prompt.message.cancelled;
|
|
1029
|
+
}
|
|
1030
|
+
})},
|
|
1031
|
+
disabled: ${(0, __alloy_js_core_jsx_runtime.createComponent)(ColorFunction, {
|
|
1032
|
+
get ansi16() {
|
|
1033
|
+
return colors.ansi16.theme.text.prompt.message.disabled;
|
|
1034
|
+
},
|
|
1035
|
+
get ansi256() {
|
|
1036
|
+
return colors.ansi256.theme.text.prompt.message.disabled;
|
|
1037
|
+
},
|
|
1038
|
+
get ansi16m() {
|
|
1039
|
+
return colors.ansi16m.theme.text.prompt.message.disabled;
|
|
1040
|
+
}
|
|
1041
|
+
})}
|
|
1042
|
+
},
|
|
1043
|
+
input: {
|
|
1044
|
+
active: ${(0, __alloy_js_core_jsx_runtime.createComponent)(ColorFunction, {
|
|
1045
|
+
get ansi16() {
|
|
1046
|
+
return colors.ansi16.theme.text.prompt.input.active;
|
|
1047
|
+
},
|
|
1048
|
+
get ansi256() {
|
|
1049
|
+
return colors.ansi256.theme.text.prompt.input.active;
|
|
1050
|
+
},
|
|
1051
|
+
get ansi16m() {
|
|
1052
|
+
return colors.ansi16m.theme.text.prompt.input.active;
|
|
1053
|
+
}
|
|
1054
|
+
})},
|
|
1055
|
+
inactive: ${(0, __alloy_js_core_jsx_runtime.createComponent)(ColorFunction, {
|
|
1056
|
+
get ansi16() {
|
|
1057
|
+
return colors.ansi16.theme.text.prompt.input.inactive;
|
|
1058
|
+
},
|
|
1059
|
+
get ansi256() {
|
|
1060
|
+
return colors.ansi256.theme.text.prompt.input.inactive;
|
|
1061
|
+
},
|
|
1062
|
+
get ansi16m() {
|
|
1063
|
+
return colors.ansi16m.theme.text.prompt.input.inactive;
|
|
1064
|
+
}
|
|
1065
|
+
})},
|
|
1066
|
+
warning: ${(0, __alloy_js_core_jsx_runtime.createComponent)(ColorFunction, {
|
|
1067
|
+
get ansi16() {
|
|
1068
|
+
return colors.ansi16.theme.text.prompt.input.warning;
|
|
1069
|
+
},
|
|
1070
|
+
get ansi256() {
|
|
1071
|
+
return colors.ansi256.theme.text.prompt.input.warning;
|
|
1072
|
+
},
|
|
1073
|
+
get ansi16m() {
|
|
1074
|
+
return colors.ansi16m.theme.text.prompt.input.warning;
|
|
1075
|
+
}
|
|
1076
|
+
})},
|
|
1077
|
+
error: ${(0, __alloy_js_core_jsx_runtime.createComponent)(ColorFunction, {
|
|
1078
|
+
get ansi16() {
|
|
1079
|
+
return colors.ansi16.theme.text.prompt.input.error;
|
|
1080
|
+
},
|
|
1081
|
+
get ansi256() {
|
|
1082
|
+
return colors.ansi256.theme.text.prompt.input.error;
|
|
1083
|
+
},
|
|
1084
|
+
get ansi16m() {
|
|
1085
|
+
return colors.ansi16m.theme.text.prompt.input.error;
|
|
1086
|
+
}
|
|
1087
|
+
})},
|
|
1088
|
+
submitted: ${(0, __alloy_js_core_jsx_runtime.createComponent)(ColorFunction, {
|
|
1089
|
+
get ansi16() {
|
|
1090
|
+
return colors.ansi16.theme.text.prompt.input.submitted;
|
|
1091
|
+
},
|
|
1092
|
+
get ansi256() {
|
|
1093
|
+
return colors.ansi256.theme.text.prompt.input.submitted;
|
|
1094
|
+
},
|
|
1095
|
+
get ansi16m() {
|
|
1096
|
+
return colors.ansi16m.theme.text.prompt.input.submitted;
|
|
1097
|
+
}
|
|
1098
|
+
})},
|
|
1099
|
+
cancelled: ${(0, __alloy_js_core_jsx_runtime.createComponent)(ColorFunction, {
|
|
1100
|
+
get ansi16() {
|
|
1101
|
+
return colors.ansi16.theme.text.prompt.input.cancelled;
|
|
1102
|
+
},
|
|
1103
|
+
get ansi256() {
|
|
1104
|
+
return colors.ansi256.theme.text.prompt.input.cancelled;
|
|
1105
|
+
},
|
|
1106
|
+
get ansi16m() {
|
|
1107
|
+
return colors.ansi16m.theme.text.prompt.input.cancelled;
|
|
1108
|
+
}
|
|
1109
|
+
})},
|
|
1110
|
+
disabled: ${(0, __alloy_js_core_jsx_runtime.createComponent)(ColorFunction, {
|
|
1111
|
+
get ansi16() {
|
|
1112
|
+
return colors.ansi16.theme.text.prompt.input.disabled;
|
|
1113
|
+
},
|
|
1114
|
+
get ansi256() {
|
|
1115
|
+
return colors.ansi256.theme.text.prompt.input.disabled;
|
|
1116
|
+
},
|
|
1117
|
+
get ansi16m() {
|
|
1118
|
+
return colors.ansi16m.theme.text.prompt.input.disabled;
|
|
1119
|
+
}
|
|
1120
|
+
})}
|
|
1121
|
+
},
|
|
1122
|
+
description: {
|
|
1123
|
+
active: ${(0, __alloy_js_core_jsx_runtime.createComponent)(ColorFunction, {
|
|
1124
|
+
get ansi16() {
|
|
1125
|
+
return colors.ansi16.theme.text.prompt.description.active;
|
|
1126
|
+
},
|
|
1127
|
+
get ansi256() {
|
|
1128
|
+
return colors.ansi256.theme.text.prompt.description.active;
|
|
1129
|
+
},
|
|
1130
|
+
get ansi16m() {
|
|
1131
|
+
return colors.ansi16m.theme.text.prompt.description.active;
|
|
1132
|
+
}
|
|
1133
|
+
})},
|
|
1134
|
+
inactive: ${(0, __alloy_js_core_jsx_runtime.createComponent)(ColorFunction, {
|
|
1135
|
+
get ansi16() {
|
|
1136
|
+
return colors.ansi16.theme.text.prompt.description.inactive;
|
|
1137
|
+
},
|
|
1138
|
+
get ansi256() {
|
|
1139
|
+
return colors.ansi256.theme.text.prompt.description.inactive;
|
|
1140
|
+
},
|
|
1141
|
+
get ansi16m() {
|
|
1142
|
+
return colors.ansi16m.theme.text.prompt.description.inactive;
|
|
1143
|
+
}
|
|
1144
|
+
})},
|
|
1145
|
+
warning: ${(0, __alloy_js_core_jsx_runtime.createComponent)(ColorFunction, {
|
|
1146
|
+
get ansi16() {
|
|
1147
|
+
return colors.ansi16.theme.text.prompt.description.warning;
|
|
1148
|
+
},
|
|
1149
|
+
get ansi256() {
|
|
1150
|
+
return colors.ansi256.theme.text.prompt.description.warning;
|
|
1151
|
+
},
|
|
1152
|
+
get ansi16m() {
|
|
1153
|
+
return colors.ansi16m.theme.text.prompt.description.warning;
|
|
1154
|
+
}
|
|
1155
|
+
})},
|
|
1156
|
+
error: ${(0, __alloy_js_core_jsx_runtime.createComponent)(ColorFunction, {
|
|
1157
|
+
get ansi16() {
|
|
1158
|
+
return colors.ansi16.theme.text.prompt.description.error;
|
|
1159
|
+
},
|
|
1160
|
+
get ansi256() {
|
|
1161
|
+
return colors.ansi256.theme.text.prompt.description.error;
|
|
1162
|
+
},
|
|
1163
|
+
get ansi16m() {
|
|
1164
|
+
return colors.ansi16m.theme.text.prompt.description.error;
|
|
1165
|
+
}
|
|
1166
|
+
})},
|
|
1167
|
+
submitted: ${(0, __alloy_js_core_jsx_runtime.createComponent)(ColorFunction, {
|
|
1168
|
+
get ansi16() {
|
|
1169
|
+
return colors.ansi16.theme.text.prompt.description.submitted;
|
|
1170
|
+
},
|
|
1171
|
+
get ansi256() {
|
|
1172
|
+
return colors.ansi256.theme.text.prompt.description.submitted;
|
|
1173
|
+
},
|
|
1174
|
+
get ansi16m() {
|
|
1175
|
+
return colors.ansi16m.theme.text.prompt.description.submitted;
|
|
1176
|
+
}
|
|
1177
|
+
})},
|
|
1178
|
+
cancelled: ${(0, __alloy_js_core_jsx_runtime.createComponent)(ColorFunction, {
|
|
1179
|
+
get ansi16() {
|
|
1180
|
+
return colors.ansi16.theme.text.prompt.description.cancelled;
|
|
1181
|
+
},
|
|
1182
|
+
get ansi256() {
|
|
1183
|
+
return colors.ansi256.theme.text.prompt.description.cancelled;
|
|
1184
|
+
},
|
|
1185
|
+
get ansi16m() {
|
|
1186
|
+
return colors.ansi16m.theme.text.prompt.description.cancelled;
|
|
1187
|
+
}
|
|
1188
|
+
})},
|
|
1189
|
+
disabled: ${(0, __alloy_js_core_jsx_runtime.createComponent)(ColorFunction, {
|
|
1190
|
+
get ansi16() {
|
|
1191
|
+
return colors.ansi16.theme.text.prompt.description.disabled;
|
|
1192
|
+
},
|
|
1193
|
+
get ansi256() {
|
|
1194
|
+
return colors.ansi256.theme.text.prompt.description.disabled;
|
|
1195
|
+
},
|
|
1196
|
+
get ansi16m() {
|
|
1197
|
+
return colors.ansi16m.theme.text.prompt.description.disabled;
|
|
1198
|
+
}
|
|
1199
|
+
})}
|
|
1200
|
+
}
|
|
787
1201
|
}
|
|
788
1202
|
},
|
|
789
1203
|
border: {
|
|
@@ -1105,6 +1519,102 @@ function ColorsDeclaration() {
|
|
|
1105
1519
|
function WriteLineFunctionDeclaration() {
|
|
1106
1520
|
const theme = require_contexts_theme.useTheme();
|
|
1107
1521
|
return [
|
|
1522
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.FunctionDeclaration, {
|
|
1523
|
+
name: "adjustIndex",
|
|
1524
|
+
parameters: [{
|
|
1525
|
+
name: "line",
|
|
1526
|
+
type: "string"
|
|
1527
|
+
}, {
|
|
1528
|
+
name: "index",
|
|
1529
|
+
type: "number"
|
|
1530
|
+
}],
|
|
1531
|
+
returnType: "number",
|
|
1532
|
+
children: __alloy_js_core.code`let adjustedIndex = 0;
|
|
1533
|
+
|
|
1534
|
+
const segments = line.match(/\\x1b\\[(\\d|;)+m.*\\x1b\\[(\\d|;)+m/gi);
|
|
1535
|
+
if (segments && segments.length > 0) {
|
|
1536
|
+
segments.reduce((count, matched) => {
|
|
1537
|
+
if (count < index) {
|
|
1538
|
+
const stripped = stripAnsi(matched);
|
|
1539
|
+
if (count + stripped.length < index) {
|
|
1540
|
+
count += stripped.length;
|
|
1541
|
+
adjustedIndex += matched.length;
|
|
1542
|
+
} else {
|
|
1543
|
+
adjustedIndex += index - count + (matched.slice(0, index - count).match(/\\x1b\\[(\\d|;)+m/g)?.join("")?.length ?? 0);
|
|
1544
|
+
count = index;
|
|
1545
|
+
}
|
|
1546
|
+
}
|
|
1547
|
+
|
|
1548
|
+
return count;
|
|
1549
|
+
}, 0);
|
|
1550
|
+
} else {
|
|
1551
|
+
adjustedIndex = index;
|
|
1552
|
+
}
|
|
1553
|
+
|
|
1554
|
+
return adjustedIndex - (line.slice(0, adjustedIndex).match(/\\x1b\\[/g)?.length ?? 0); `
|
|
1555
|
+
}),
|
|
1556
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1557
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.FunctionDeclaration, {
|
|
1558
|
+
name: "breakLine",
|
|
1559
|
+
parameters: [{
|
|
1560
|
+
name: "line",
|
|
1561
|
+
type: "string"
|
|
1562
|
+
}, {
|
|
1563
|
+
name: "index",
|
|
1564
|
+
type: "number"
|
|
1565
|
+
}],
|
|
1566
|
+
returnType: "[string, string]",
|
|
1567
|
+
children: __alloy_js_core.code`const first = line.slice(0, index);
|
|
1568
|
+
const second = line.slice(index);
|
|
1569
|
+
|
|
1570
|
+
// Match all ANSI escape sequences in the first string
|
|
1571
|
+
const ansiRegex = /[\\x1b\\u009b][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007))|(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))/g;
|
|
1572
|
+
|
|
1573
|
+
const openCodes: string[] = [];
|
|
1574
|
+
const closeCodes: string[] = [];
|
|
1575
|
+
let match: RegExpExecArray | null;
|
|
1576
|
+
|
|
1577
|
+
while ((match = ansiRegex.exec(first)) !== null) {
|
|
1578
|
+
const code = match[0];
|
|
1579
|
+
// Check if this is a reset/close code (e.g., \\x1b[0m, \\x1b[39m, \\x1b[49m, etc.)
|
|
1580
|
+
if (/\\x1b\\[(?:0|22|23|24|27|28|29|39|49)m/.test(code)) {
|
|
1581
|
+
// A close/reset code cancels the last open code
|
|
1582
|
+
openCodes.pop();
|
|
1583
|
+
closeCodes.pop();
|
|
1584
|
+
} else {
|
|
1585
|
+
openCodes.push(code);
|
|
1586
|
+
// Derive a close code: map SGR open codes to their reset counterparts
|
|
1587
|
+
const sgrMatch = code.match(/\\x1b\\[(\\d+)m/);
|
|
1588
|
+
if (sgrMatch) {
|
|
1589
|
+
const n = parseInt(sgrMatch[1]!, 10);
|
|
1590
|
+
let closeCode: string;
|
|
1591
|
+
if (n >= 30 && n <= 37) closeCode = "\\x1b[39m";
|
|
1592
|
+
else if (n >= 40 && n <= 47) closeCode = "\\x1b[49m";
|
|
1593
|
+
else if (n >= 90 && n <= 97) closeCode = "\\x1b[39m";
|
|
1594
|
+
else if (n >= 100 && n <= 107) closeCode = "\\x1b[49m";
|
|
1595
|
+
else if (n === 1) closeCode = "\\x1b[22m";
|
|
1596
|
+
else if (n === 2) closeCode = "\\x1b[22m";
|
|
1597
|
+
else if (n === 3) closeCode = "\\x1b[23m";
|
|
1598
|
+
else if (n === 4) closeCode = "\\x1b[24m";
|
|
1599
|
+
else if (n === 7) closeCode = "\\x1b[27m";
|
|
1600
|
+
else if (n === 8) closeCode = "\\x1b[28m";
|
|
1601
|
+
else if (n === 9) closeCode = "\\x1b[29m";
|
|
1602
|
+
else closeCode = "\\x1b[0m";
|
|
1603
|
+
closeCodes.push(closeCode);
|
|
1604
|
+
} else {
|
|
1605
|
+
closeCodes.push("\\x1b[0m");
|
|
1606
|
+
}
|
|
1607
|
+
}
|
|
1608
|
+
}
|
|
1609
|
+
|
|
1610
|
+
// Append close codes to the end of "first" (in reverse order)
|
|
1611
|
+
const closeSequence = closeCodes.slice().reverse().join("");
|
|
1612
|
+
// Prepend open codes to the start of "second"
|
|
1613
|
+
const openSequence = openCodes.join("");
|
|
1614
|
+
|
|
1615
|
+
return [first.replace(/^\\s+/, "").replace(/\\s+$/, "") + closeSequence, openSequence + second.replace(/^\\s+/, "").replace(/\\s+$/, "")]; `
|
|
1616
|
+
}),
|
|
1617
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1108
1618
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
1109
1619
|
heading: "Split text into multiple lines based on a maximum length.",
|
|
1110
1620
|
get children() {
|
|
@@ -1130,23 +1640,24 @@ function WriteLineFunctionDeclaration() {
|
|
|
1130
1640
|
type: "string"
|
|
1131
1641
|
}, {
|
|
1132
1642
|
name: "maxLength",
|
|
1133
|
-
type: "number"
|
|
1643
|
+
type: "number | SizeToken"
|
|
1134
1644
|
}],
|
|
1135
1645
|
children: __alloy_js_core.code`
|
|
1136
1646
|
let line = text;
|
|
1137
1647
|
let result = [] as string[];
|
|
1138
1648
|
|
|
1139
|
-
|
|
1649
|
+
const calculatedMaxLength = isSizeToken(maxLength) ? calculateWidth(maxLength) : maxLength;
|
|
1650
|
+
while (stripAnsi(line).length > calculatedMaxLength || line.indexOf("\\n") !== -1) {
|
|
1140
1651
|
if (line.indexOf("\\n") !== -1) {
|
|
1141
|
-
result.push(...splitText(line.slice(0, line.indexOf("\\n")).replace(
|
|
1652
|
+
result.push(...splitText(line.slice(0, line.indexOf("\\n")).replace(/(\\r)?\\n/, ""), calculatedMaxLength));
|
|
1142
1653
|
line = line.indexOf("\\n") + 1 < line.length
|
|
1143
1654
|
? line.slice(line.indexOf("\\n") + 1)
|
|
1144
1655
|
: "";
|
|
1145
1656
|
} else {
|
|
1146
|
-
const index = [" ", "/", "
|
|
1657
|
+
const index = [" ", "/", ".", ",", "-", ":", "|", "@", "+"].reduce((ret, split) => {
|
|
1147
1658
|
let current = ret;
|
|
1148
|
-
while (stripAnsi(line).indexOf(split, current + 1) !== -1 && stripAnsi(line).indexOf(split, current + 1) <=
|
|
1149
|
-
current = line.indexOf(split, current + 1);
|
|
1659
|
+
while (stripAnsi(line).indexOf(split, current + 1) !== -1 && stripAnsi(line).indexOf(split, current + 1) <= calculatedMaxLength) {
|
|
1660
|
+
current = line.indexOf(split, adjustIndex(line, current + 1));
|
|
1150
1661
|
}
|
|
1151
1662
|
|
|
1152
1663
|
return current;
|
|
@@ -1155,22 +1666,23 @@ function WriteLineFunctionDeclaration() {
|
|
|
1155
1666
|
break;
|
|
1156
1667
|
}
|
|
1157
1668
|
|
|
1158
|
-
|
|
1159
|
-
|
|
1669
|
+
const lines = breakLine(line, index);
|
|
1670
|
+
result.push(lines[0]);
|
|
1671
|
+
line = lines[1];
|
|
1160
1672
|
}
|
|
1161
1673
|
}
|
|
1162
1674
|
|
|
1163
|
-
while (stripAnsi(line).length >
|
|
1164
|
-
|
|
1165
|
-
|
|
1675
|
+
while (stripAnsi(line).length > calculatedMaxLength) {
|
|
1676
|
+
const lines = breakLine(line, calculatedMaxLength);
|
|
1677
|
+
result.push(lines[0]);
|
|
1678
|
+
line = lines[1];
|
|
1166
1679
|
}
|
|
1167
1680
|
|
|
1168
1681
|
result.push(line);
|
|
1169
1682
|
return result;
|
|
1170
1683
|
`
|
|
1171
1684
|
}),
|
|
1172
|
-
(0, __alloy_js_core_jsx_runtime.
|
|
1173
|
-
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1685
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1174
1686
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.InterfaceDeclaration, {
|
|
1175
1687
|
"export": true,
|
|
1176
1688
|
name: "WriteLineOptions",
|
|
@@ -1224,8 +1736,7 @@ function WriteLineFunctionDeclaration() {
|
|
|
1224
1736
|
];
|
|
1225
1737
|
}
|
|
1226
1738
|
}),
|
|
1227
|
-
(0, __alloy_js_core_jsx_runtime.
|
|
1228
|
-
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1739
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1229
1740
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
1230
1741
|
heading: "Write a line to the console.",
|
|
1231
1742
|
get children() {
|
|
@@ -1315,6 +1826,8 @@ function MessageFunctionDeclaration(props) {
|
|
|
1315
1826
|
}
|
|
1316
1827
|
|
|
1317
1828
|
${!theme.labels.message.footer[variant] && timestamp ? `const timestamp = \`\${colors.text.message.footer.${color}(new Date().toLocaleDateString())} \${colors.border.message.outline.${color}("${theme.borderStyles.message.outline[variant].bottom}")} \${colors.text.message.footer.${color}(new Date().toLocaleTimeString())}\`; ` : ""}
|
|
1829
|
+
|
|
1830
|
+
writeLine("");
|
|
1318
1831
|
writeLine(colors.border.message.outline.${color}("${theme.borderStyles.message.outline[variant].topLeft}") + ${theme.labels.message.header[variant] || theme.icons.message.header[variant] ? `colors.border.message.outline.${color}("${theme.borderStyles.message.outline[variant].top}".repeat(4)) + " " + ${theme.icons.message.header[variant] ? `colors.border.message.outline.${color}("${theme.icons.message.header[variant]}") + " " +` : ""} colors.bold(colors.text.message.header.${color}("${theme.labels.message.header[variant]}")) + " " + colors.border.message.outline.${color}("${theme.borderStyles.message.outline[variant].top}".repeat(Math.max(process.stdout.columns - ${Math.max(theme.padding.app, 0) * 2 + theme.borderStyles.message.outline[variant].topLeft.length + 4 + (theme.icons.message.header[variant] ? 2 + (theme.labels.message.header[variant] ? 0 : 1) : 0) + (theme.labels.message.header[variant] ? theme.labels.message.header[variant].length + 2 : 0) + theme.borderStyles.message.outline[variant].topRight.length}, 0)))` : `colors.border.message.outline.${color}("${theme.borderStyles.message.outline[variant].top}".repeat(Math.max(process.stdout.columns - ${Math.max(theme.padding.app, 0) * 2 + theme.borderStyles.message.outline[variant].topLeft.length + theme.borderStyles.message.outline[variant].topRight.length}, 0)))`} + colors.border.message.outline.${color}("${theme.borderStyles.message.outline[variant].topRight}"), { consoleFn: console.${consoleFnName} });
|
|
1319
1832
|
splitText(
|
|
1320
1833
|
message,
|
|
@@ -1335,8 +1848,8 @@ function WrapAnsiFunction() {
|
|
|
1335
1848
|
heading: "Applies ANSI escape codes to a string.",
|
|
1336
1849
|
get children() {
|
|
1337
1850
|
return [
|
|
1338
|
-
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDocRemarks, { children: `Split text by /\\\\
|
|
1339
|
-
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDocExample, { children: `const result = wrapAnsi("Hello\\\\
|
|
1851
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDocRemarks, { children: `Split text by /\\\\x1b[\\[|\\]][0-9;]*m/ and wrap non-ANSI parts with open/closeing tags.` }),
|
|
1852
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDocExample, { children: `const result = wrapAnsi("Hello\\\\x1b[31mWorld\\\\x1b[0mAgain", "\\\\x1b[36m", "\\\\x1b[39");\nconsole.log(result); // "\\\\x1b[36mHello\\\\x1b[39\\\\x1b[31mWorld\\\\x1b[0m\\\\x1b[36mAgain\\\\x1b[39"` }),
|
|
1340
1853
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
1341
1854
|
name: "text",
|
|
1342
1855
|
children: `The text to apply ANSI codes to.`
|
|
@@ -1376,7 +1889,7 @@ function WrapAnsiFunction() {
|
|
|
1376
1889
|
|
|
1377
1890
|
let last = 0;
|
|
1378
1891
|
let match: RegExpExecArray | null;
|
|
1379
|
-
while ((match = /\\\\
|
|
1892
|
+
while ((match = /\\\\x1b[\\[|\\]][0-9;]*m/g.exec(str)) !== null) {
|
|
1380
1893
|
if (match.index > last) tokens.push(str.slice(last, match.index));
|
|
1381
1894
|
tokens.push(match[0]);
|
|
1382
1895
|
last = match.index + match[0].length;
|
|
@@ -1389,7 +1902,7 @@ function WrapAnsiFunction() {
|
|
|
1389
1902
|
let result = "";
|
|
1390
1903
|
for (let i = 0; i < tokens.length; i++) {
|
|
1391
1904
|
const seg = tokens[i]!;
|
|
1392
|
-
if (/^\\\\
|
|
1905
|
+
if (/^\\\\x1b[\\[|\\]][0-9;]*m$/.test(seg)) {
|
|
1393
1906
|
result += seg;
|
|
1394
1907
|
continue;
|
|
1395
1908
|
}
|
|
@@ -1398,7 +1911,7 @@ function WrapAnsiFunction() {
|
|
|
1398
1911
|
continue;
|
|
1399
1912
|
}
|
|
1400
1913
|
|
|
1401
|
-
result += i > 0 && /^\\\\
|
|
1914
|
+
result += i > 0 && /^\\\\x1b[\\[|\\]][0-9;]*m$/.test(tokens[i - 1]!) && i + 1 < tokens.length && /^\\\\x1b[\\[|\\]][0-9;]*m$/.test(tokens[i + 1]!)
|
|
1402
1915
|
? seg
|
|
1403
1916
|
: \`\${open}\${seg}\${close}\`;
|
|
1404
1917
|
}
|
|
@@ -1415,7 +1928,7 @@ function StripAnsiFunctionDeclaration() {
|
|
|
1415
1928
|
heading: "Removes ANSI escape codes from a string.",
|
|
1416
1929
|
get children() {
|
|
1417
1930
|
return [
|
|
1418
|
-
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDocExample, { children: `const result = stripAnsi("Hello\\\\
|
|
1931
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDocExample, { children: `const result = stripAnsi("Hello\\\\x1b[31mWorld\\\\x1b[0mAgain"); // "HelloWorldAgain"` }),
|
|
1419
1932
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
1420
1933
|
name: "text",
|
|
1421
1934
|
children: `The text to strip ANSI codes from.`
|
|
@@ -1495,8 +2008,7 @@ function DividerFunctionDeclaration() {
|
|
|
1495
2008
|
];
|
|
1496
2009
|
}
|
|
1497
2010
|
}),
|
|
1498
|
-
(0, __alloy_js_core_jsx_runtime.
|
|
1499
|
-
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
2011
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1500
2012
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
1501
2013
|
heading: "Write a divider line to the console.",
|
|
1502
2014
|
get children() {
|
|
@@ -1560,7 +2072,7 @@ function LinkFunctionDeclaration() {
|
|
|
1560
2072
|
return [
|
|
1561
2073
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.IfStatement, {
|
|
1562
2074
|
condition: __alloy_js_core.code`isHyperlinkSupported()`,
|
|
1563
|
-
children: __alloy_js_core.code`return \`\\
|
|
2075
|
+
children: __alloy_js_core.code`return \`\\x1b]8;;\${url}\\u0007\${text ?? url}\\x1b]8;;\\u0007\`;`
|
|
1564
2076
|
}),
|
|
1565
2077
|
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1566
2078
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.IfStatement, {
|
|
@@ -1588,14 +2100,119 @@ function extractBorderOptionsString(direction, theme) {
|
|
|
1588
2100
|
function TableFunctionDeclaration(props) {
|
|
1589
2101
|
const theme = require_contexts_theme.useTheme();
|
|
1590
2102
|
return [
|
|
2103
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.TypeDeclaration, {
|
|
2104
|
+
"export": true,
|
|
2105
|
+
name: "SizeToken",
|
|
2106
|
+
doc: "A type representing the width size of an item in the console.",
|
|
2107
|
+
children: __alloy_js_core.code`"full" | "1/1" | "1/2" | "1/3" | "1/4" | "1/5" | "1/6" | "1/12" | "1/24" | "100%" | "50%" | "33.33%" | "25%" | "20%" | "10%" | "5%" | "2.5%"`
|
|
2108
|
+
}),
|
|
2109
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2110
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
2111
|
+
heading: "Determine if a value is a valid size token.",
|
|
2112
|
+
get children() {
|
|
2113
|
+
return [
|
|
2114
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDocRemarks, { children: `This function checks if the provided value is a valid size token, which can be one of the predefined strings representing common width sizes (e.g., "full", "1/2", "1/3", etc.) or percentage strings (e.g., "50%").` }),
|
|
2115
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
2116
|
+
name: "value",
|
|
2117
|
+
children: `The value to check for being a valid size token.`
|
|
2118
|
+
}),
|
|
2119
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns, { children: `True if the value is a valid size token, false otherwise.` })
|
|
2120
|
+
];
|
|
2121
|
+
}
|
|
2122
|
+
}),
|
|
2123
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.FunctionDeclaration, {
|
|
2124
|
+
"export": true,
|
|
2125
|
+
doc: "Determines if the provided value is a valid size token.",
|
|
2126
|
+
name: "isSizeToken",
|
|
2127
|
+
parameters: [{
|
|
2128
|
+
name: "value",
|
|
2129
|
+
type: "any"
|
|
2130
|
+
}],
|
|
2131
|
+
returnType: "value is SizeToken",
|
|
2132
|
+
get children() {
|
|
2133
|
+
return [(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.IfStatement, {
|
|
2134
|
+
condition: __alloy_js_core.code`["full", "1/1", "1/2", "1/3", "1/4", "1/5", "1/6", "1/12", "1/24", "100%", "50%", "33.33%", "25%", "20%", "10%", "5%", "2.5%"].includes(value)`,
|
|
2135
|
+
children: __alloy_js_core.code`return true; `
|
|
2136
|
+
}), __alloy_js_core.code`return false; `];
|
|
2137
|
+
}
|
|
2138
|
+
}),
|
|
2139
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2140
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
2141
|
+
heading: "Calculate the width in characters based on the provided width size.",
|
|
2142
|
+
get children() {
|
|
2143
|
+
return [
|
|
2144
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDocRemarks, { children: `This function calculates the width in characters based on the provided width size, which can be a predefined string (e.g., "full", "1/2", "1/3", etc.) or a percentage string (e.g., "50%"). The calculation is based on the current width of the console (process.stdout.columns).` }),
|
|
2145
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
2146
|
+
name: "size",
|
|
2147
|
+
children: `The width size to calculate. This can be a predefined string (e.g., "full", "1/2", "1/3", etc.) or a percentage string (e.g., "50%").`
|
|
2148
|
+
}),
|
|
2149
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns, { children: `The calculated width in characters.` })
|
|
2150
|
+
];
|
|
2151
|
+
}
|
|
2152
|
+
}),
|
|
2153
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.FunctionDeclaration, {
|
|
2154
|
+
"export": true,
|
|
2155
|
+
name: "calculateWidth",
|
|
2156
|
+
parameters: [{
|
|
2157
|
+
name: "size",
|
|
2158
|
+
type: "SizeToken",
|
|
2159
|
+
optional: false
|
|
2160
|
+
}],
|
|
2161
|
+
returnType: "number",
|
|
2162
|
+
get children() {
|
|
2163
|
+
return [
|
|
2164
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.IfStatement, {
|
|
2165
|
+
condition: __alloy_js_core.code`["full", "100%", "1/1"]. includes(size)`,
|
|
2166
|
+
children: __alloy_js_core.code`return process.stdout.columns;`
|
|
2167
|
+
}),
|
|
2168
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.ElseIfClause, {
|
|
2169
|
+
condition: __alloy_js_core.code`["1/2", "50%"].includes(size)`,
|
|
2170
|
+
children: __alloy_js_core.code`return Math.round(process.stdout.columns / 2);`
|
|
2171
|
+
}),
|
|
2172
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.ElseIfClause, {
|
|
2173
|
+
condition: __alloy_js_core.code`["1/3", "33.33%"].includes(size)`,
|
|
2174
|
+
children: __alloy_js_core.code`return Math.round(process.stdout.columns / 3);`
|
|
2175
|
+
}),
|
|
2176
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.ElseIfClause, {
|
|
2177
|
+
condition: __alloy_js_core.code`["1/4", "25%"].includes(size)`,
|
|
2178
|
+
children: __alloy_js_core.code`return Math.round(process.stdout.columns / 4);`
|
|
2179
|
+
}),
|
|
2180
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.ElseIfClause, {
|
|
2181
|
+
condition: __alloy_js_core.code`["1/5", "20%"].includes(size)`,
|
|
2182
|
+
children: __alloy_js_core.code`return Math.round(process.stdout.columns / 5);`
|
|
2183
|
+
}),
|
|
2184
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.ElseIfClause, {
|
|
2185
|
+
condition: __alloy_js_core.code`["1/6", "10%"].includes(size)`,
|
|
2186
|
+
children: __alloy_js_core.code`return Math.round(process.stdout.columns / 6);`
|
|
2187
|
+
}),
|
|
2188
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.ElseIfClause, {
|
|
2189
|
+
condition: __alloy_js_core.code`["1/12", "5%"].includes(size)`,
|
|
2190
|
+
children: __alloy_js_core.code`return Math.round(process.stdout.columns / 12);`
|
|
2191
|
+
}),
|
|
2192
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.ElseIfClause, {
|
|
2193
|
+
condition: __alloy_js_core.code`["1/24", "2.5%"].includes(size)`,
|
|
2194
|
+
children: __alloy_js_core.code`return Math.round(process.stdout.columns / 24);`
|
|
2195
|
+
}),
|
|
2196
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.ElseClause, { children: __alloy_js_core.code`
|
|
2197
|
+
const match = size.match(/(\\d+(\\.\\d+)?)%/);
|
|
2198
|
+
if (match) {
|
|
2199
|
+
return Math.round((process.stdout.columns * parseFloat(match[1])) / 100);
|
|
2200
|
+
}
|
|
2201
|
+
|
|
2202
|
+
throw new Error(\`Invalid width size: \${size}\`);
|
|
2203
|
+
` }),
|
|
2204
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
2205
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {})
|
|
2206
|
+
];
|
|
2207
|
+
}
|
|
2208
|
+
}),
|
|
1591
2209
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.TypeDeclaration, {
|
|
1592
2210
|
"export": true,
|
|
1593
2211
|
name: "BorderOption",
|
|
1594
2212
|
doc: "The border options applied to table cells.",
|
|
1595
2213
|
children: __alloy_js_core.code`"primary" | "secondary" | "tertiary" | "none" | string; `
|
|
1596
2214
|
}),
|
|
1597
|
-
(0, __alloy_js_core_jsx_runtime.
|
|
1598
|
-
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
2215
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1599
2216
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.InterfaceDeclaration, {
|
|
1600
2217
|
"export": true,
|
|
1601
2218
|
name: "TableOutputOptions",
|
|
@@ -1670,24 +2287,36 @@ function TableFunctionDeclaration(props) {
|
|
|
1670
2287
|
];
|
|
1671
2288
|
}
|
|
1672
2289
|
}),
|
|
1673
|
-
(0, __alloy_js_core_jsx_runtime.
|
|
1674
|
-
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
2290
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1675
2291
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.InterfaceDeclaration, {
|
|
1676
2292
|
"export": true,
|
|
1677
2293
|
name: "TableCellOptions",
|
|
1678
2294
|
"extends": "TableOutputOptions",
|
|
1679
2295
|
doc: "Options for a specific table cell provided to the {@link table} function.",
|
|
1680
2296
|
get children() {
|
|
1681
|
-
return [
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
2297
|
+
return [
|
|
2298
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.InterfaceMember, {
|
|
2299
|
+
name: "value",
|
|
2300
|
+
optional: true,
|
|
2301
|
+
type: "string",
|
|
2302
|
+
doc: "The actual string value of the table cell."
|
|
2303
|
+
}),
|
|
2304
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
2305
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
2306
|
+
heading: "Width of the table cell.",
|
|
2307
|
+
get children() {
|
|
2308
|
+
return (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDocRemarks, { children: `The width of the table cell (where 1 is a single character in the terminal). If not specified, the width will be determined based on the content of the cell and the available space in the console.` });
|
|
2309
|
+
}
|
|
2310
|
+
}),
|
|
2311
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.InterfaceMember, {
|
|
2312
|
+
name: "maxWidth",
|
|
2313
|
+
type: "number | SizeToken | undefined"
|
|
2314
|
+
}),
|
|
2315
|
+
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {})
|
|
2316
|
+
];
|
|
1687
2317
|
}
|
|
1688
2318
|
}),
|
|
1689
|
-
(0, __alloy_js_core_jsx_runtime.
|
|
1690
|
-
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
2319
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1691
2320
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.InterfaceDeclaration, {
|
|
1692
2321
|
"export": true,
|
|
1693
2322
|
name: "TableRowOptions",
|
|
@@ -1702,8 +2331,7 @@ function TableFunctionDeclaration(props) {
|
|
|
1702
2331
|
}), (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {})];
|
|
1703
2332
|
}
|
|
1704
2333
|
}),
|
|
1705
|
-
(0, __alloy_js_core_jsx_runtime.
|
|
1706
|
-
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
2334
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1707
2335
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.InterfaceDeclaration, {
|
|
1708
2336
|
"export": true,
|
|
1709
2337
|
name: "TableOptions",
|
|
@@ -1718,8 +2346,7 @@ function TableFunctionDeclaration(props) {
|
|
|
1718
2346
|
}), (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {})];
|
|
1719
2347
|
}
|
|
1720
2348
|
}),
|
|
1721
|
-
(0, __alloy_js_core_jsx_runtime.
|
|
1722
|
-
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
2349
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1723
2350
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.InterfaceDeclaration, {
|
|
1724
2351
|
name: "Dimensions",
|
|
1725
2352
|
doc: "The height and width for a specific table/cell used internally in the {@link table} function.",
|
|
@@ -1740,8 +2367,7 @@ function TableFunctionDeclaration(props) {
|
|
|
1740
2367
|
];
|
|
1741
2368
|
}
|
|
1742
2369
|
}),
|
|
1743
|
-
(0, __alloy_js_core_jsx_runtime.
|
|
1744
|
-
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
2370
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1745
2371
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.InterfaceDeclaration, {
|
|
1746
2372
|
name: "TableCellBorder",
|
|
1747
2373
|
doc: "The resolved complete border styles for a table cell.",
|
|
@@ -1798,18 +2424,17 @@ function TableFunctionDeclaration(props) {
|
|
|
1798
2424
|
];
|
|
1799
2425
|
}
|
|
1800
2426
|
}),
|
|
1801
|
-
(0, __alloy_js_core_jsx_runtime.
|
|
1802
|
-
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
2427
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1803
2428
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.TypeDeclaration, {
|
|
1804
2429
|
name: "TableCell",
|
|
1805
2430
|
doc: "The internal state of a formatted table cell in the {@link table} function.",
|
|
1806
|
-
children: __alloy_js_core.code`Required<Omit<TableCellOptions, "border">> & Dimensions & {
|
|
2431
|
+
children: __alloy_js_core.code`Required<Omit<TableCellOptions, "maxWidth" | "border">> & Dimensions & {
|
|
1807
2432
|
border: TableCellBorder;
|
|
2433
|
+
maxWidth?: number;
|
|
1808
2434
|
};
|
|
1809
2435
|
`
|
|
1810
2436
|
}),
|
|
1811
|
-
(0, __alloy_js_core_jsx_runtime.
|
|
1812
|
-
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
2437
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1813
2438
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
1814
2439
|
heading: "Write a table to the console.",
|
|
1815
2440
|
get children() {
|
|
@@ -1848,7 +2473,7 @@ function TableFunctionDeclaration(props) {
|
|
|
1848
2473
|
}),
|
|
1849
2474
|
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1850
2475
|
(0, __alloy_js_core_jsx_runtime.memo)(() => __alloy_js_core.code`
|
|
1851
|
-
const extractTableCell = (cell: string | TableCellOptions, opts?: TableOutputOptions): TableCell => {
|
|
2476
|
+
const extractTableCell = (cell: string | TableCellOptions, columnIndex: number, rowLength: number, opts?: TableOutputOptions): TableCell => {
|
|
1852
2477
|
if (typeof cell === "string") {
|
|
1853
2478
|
const borderOptions = opts?.border || "primary";
|
|
1854
2479
|
|
|
@@ -1875,7 +2500,7 @@ function TableFunctionDeclaration(props) {
|
|
|
1875
2500
|
border.bottomRight = ${extractBorderOptionsString("bottomRight", theme)};
|
|
1876
2501
|
}
|
|
1877
2502
|
|
|
1878
|
-
const padding = Math.max(0, opts?.padding ?? ${theme.padding.table});
|
|
2503
|
+
const padding = Math.max(0, opts?.padding ?? ${theme.padding.table}) * (columnIndex === 0 || columnIndex === rowLength - 1 ? 2 : 1);
|
|
1879
2504
|
const value = cell ?? "";
|
|
1880
2505
|
const width = stripAnsi(value).length + padding * 2;
|
|
1881
2506
|
|
|
@@ -1916,17 +2541,21 @@ function TableFunctionDeclaration(props) {
|
|
|
1916
2541
|
const padding = Math.max(0, cell.padding ?? opts?.padding ?? ${theme.padding.table});
|
|
1917
2542
|
const value = cell.value ?? "";
|
|
1918
2543
|
const width = stripAnsi(value).length + padding * 2;
|
|
2544
|
+
const maxWidth = cell.maxWidth ? typeof cell.maxWidth === "number" ? cell.maxWidth : calculateWidth(cell.maxWidth) : undefined;
|
|
1919
2545
|
|
|
1920
2546
|
return {
|
|
1921
2547
|
value,
|
|
1922
2548
|
height: 1,
|
|
1923
2549
|
width,
|
|
2550
|
+
maxWidth,
|
|
1924
2551
|
border,
|
|
1925
2552
|
padding,
|
|
1926
2553
|
align: cell.align || opts?.align || "left",
|
|
1927
2554
|
};
|
|
1928
2555
|
}
|
|
1929
2556
|
};
|
|
2557
|
+
|
|
2558
|
+
let colMaxWidths = [] as (number | undefined)[];
|
|
1930
2559
|
`),
|
|
1931
2560
|
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1932
2561
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.IfStatement, {
|
|
@@ -1934,16 +2563,30 @@ function TableFunctionDeclaration(props) {
|
|
|
1934
2563
|
get children() {
|
|
1935
2564
|
return [(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.IfStatement, {
|
|
1936
2565
|
condition: __alloy_js_core.code`options.every(row => typeof row === "string" || (typeof row === "object" && !Array.isArray(row) && !("values" in row)))`,
|
|
1937
|
-
children: __alloy_js_core.code`cells.push(options.map(cell => extractTableCell(cell as string | TableCellOptions)));`
|
|
2566
|
+
children: __alloy_js_core.code`cells.push(options.map((cell, index) => extractTableCell(cell as string | TableCellOptions, index, options.length)));`
|
|
1938
2567
|
}), (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.ElseClause, { children: __alloy_js_core.code`
|
|
1939
2568
|
cells.push(
|
|
1940
2569
|
...options.map(row => Array.isArray(row)
|
|
1941
|
-
? row.reduce((cellRow, cell) => {
|
|
1942
|
-
|
|
2570
|
+
? row.reduce((cellRow, cell, index) => {
|
|
2571
|
+
if (colMaxWidths.length <= index) {
|
|
2572
|
+
colMaxWidths.push(undefined);
|
|
2573
|
+
}
|
|
2574
|
+
const newCell = extractTableCell(cell, index, row.length);
|
|
2575
|
+
if (newCell.maxWidth && (!colMaxWidths[index] || newCell.maxWidth < colMaxWidths[index]!)) {
|
|
2576
|
+
colMaxWidths[index] = newCell.maxWidth;
|
|
2577
|
+
}
|
|
2578
|
+
cellRow.push(newCell);
|
|
1943
2579
|
return cellRow;
|
|
1944
2580
|
}, [] as TableCell[])
|
|
1945
|
-
: (row as TableRowOptions).values?.reduce((cellRow, cell) => {
|
|
1946
|
-
|
|
2581
|
+
: (row as TableRowOptions).values?.reduce((cellRow, cell, index) => {
|
|
2582
|
+
if (colMaxWidths.length <= index) {
|
|
2583
|
+
colMaxWidths.push(undefined);
|
|
2584
|
+
}
|
|
2585
|
+
const newCell = extractTableCell(cell, index, (row as TableRowOptions).values?.length ?? 1, row as TableRowOptions);
|
|
2586
|
+
if (newCell.maxWidth && (!colMaxWidths[index] || newCell.maxWidth < colMaxWidths[index]!)) {
|
|
2587
|
+
colMaxWidths[index] = newCell.maxWidth;
|
|
2588
|
+
}
|
|
2589
|
+
cellRow.push(newCell);
|
|
1947
2590
|
return cellRow;
|
|
1948
2591
|
}, [] as TableCell[]) ?? []
|
|
1949
2592
|
)
|
|
@@ -1954,12 +2597,26 @@ function TableFunctionDeclaration(props) {
|
|
|
1954
2597
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.ElseClause, { children: __alloy_js_core.code`
|
|
1955
2598
|
cells.push(
|
|
1956
2599
|
...options.values!.map(row => Array.isArray(row)
|
|
1957
|
-
? row.reduce((cellRow, cell) => {
|
|
1958
|
-
|
|
2600
|
+
? row.reduce((cellRow, cell, index) => {
|
|
2601
|
+
if (colMaxWidths.length <= index) {
|
|
2602
|
+
colMaxWidths.push(undefined);
|
|
2603
|
+
}
|
|
2604
|
+
const newCell = extractTableCell(cell, index, row.length);
|
|
2605
|
+
if (newCell.maxWidth && (!colMaxWidths[index] || newCell.maxWidth < colMaxWidths[index]!)) {
|
|
2606
|
+
colMaxWidths[index] = newCell.maxWidth;
|
|
2607
|
+
}
|
|
2608
|
+
cellRow.push(newCell);
|
|
1959
2609
|
return cellRow;
|
|
1960
2610
|
}, [] as TableCell[])
|
|
1961
|
-
: (row as TableRowOptions).values?.reduce((cellRow, cell) => {
|
|
1962
|
-
|
|
2611
|
+
: (row as TableRowOptions).values?.reduce((cellRow, cell, index) => {
|
|
2612
|
+
if (colMaxWidths.length <= index) {
|
|
2613
|
+
colMaxWidths.push(undefined);
|
|
2614
|
+
}
|
|
2615
|
+
const newCell = extractTableCell(cell, index, (row as TableRowOptions).values?.length ?? 1, options);
|
|
2616
|
+
if (newCell.maxWidth && (!colMaxWidths[index] || newCell.maxWidth < colMaxWidths[index]!)) {
|
|
2617
|
+
colMaxWidths[index] = newCell.maxWidth;
|
|
2618
|
+
}
|
|
2619
|
+
cellRow.push(newCell);
|
|
1963
2620
|
return cellRow;
|
|
1964
2621
|
}, [] as TableCell[]) ?? []
|
|
1965
2622
|
)
|
|
@@ -1973,6 +2630,12 @@ if (cells.length === 0) {
|
|
|
1973
2630
|
return;
|
|
1974
2631
|
}
|
|
1975
2632
|
|
|
2633
|
+
cells.forEach(row => row.forEach((cell, index) => {
|
|
2634
|
+
if (colMaxWidths[index] && cell.maxWidth !== colMaxWidths[index]!) {
|
|
2635
|
+
cell.maxWidth = colMaxWidths[index]!;
|
|
2636
|
+
}
|
|
2637
|
+
}));
|
|
2638
|
+
|
|
1976
2639
|
// Calculate table dimensions
|
|
1977
2640
|
let colWidths = [] as number[];
|
|
1978
2641
|
let rowDims = [] as Dimensions[];
|
|
@@ -2001,6 +2664,26 @@ do {
|
|
|
2001
2664
|
recalculate = false;
|
|
2002
2665
|
rowDims = calculateRowDimensions();
|
|
2003
2666
|
|
|
2667
|
+
if (!recalculate && colWidths.some((colWidth, index) => colMaxWidths[index] && colWidth > colMaxWidths[index]!)) {
|
|
2668
|
+
(colWidths.map((colWidth, index) => colMaxWidths[index] && colWidth > colMaxWidths[index]! ? index : undefined).filter(colWidth => colWidth !== undefined) as number[]).forEach(index => {
|
|
2669
|
+
cells.forEach(row => {
|
|
2670
|
+
const cell = row[index]!;
|
|
2671
|
+
if (colMaxWidths[index] && cell.width > colMaxWidths[index]) {
|
|
2672
|
+
const lines = splitText(
|
|
2673
|
+
cell.value,
|
|
2674
|
+
colMaxWidths[index] - cell.padding * 2,
|
|
2675
|
+
);
|
|
2676
|
+
|
|
2677
|
+
cell.value = lines.join("\\n");
|
|
2678
|
+
cell.height = lines.length;
|
|
2679
|
+
cell.width = Math.max(...lines.map(line => stripAnsi(line).length)) + cell.padding * 2;
|
|
2680
|
+
|
|
2681
|
+
recalculate = true;
|
|
2682
|
+
}
|
|
2683
|
+
});
|
|
2684
|
+
});
|
|
2685
|
+
}
|
|
2686
|
+
|
|
2004
2687
|
rowDims.forEach((row, rowIndex) => {
|
|
2005
2688
|
if (!recalculate && row.width > Math.max(process.stdout.columns - ${Math.max(theme.padding.app, 0) * 2}, 0)) {
|
|
2006
2689
|
const cell = cells[rowIndex]!.reduce((largestCell, cell) => {
|
|
@@ -2012,7 +2695,8 @@ do {
|
|
|
2012
2695
|
|
|
2013
2696
|
const lines = splitText(
|
|
2014
2697
|
cell.value,
|
|
2015
|
-
Math.max(process.stdout.columns - ${Math.max(theme.padding.app, 0) * 2} - (row.width - (cell.width - cell.padding * 2)), 0)
|
|
2698
|
+
Math.min(Math.max(process.stdout.columns - ${Math.max(theme.padding.app, 0) * 2} - (row.width - (cell.width - cell.padding * 2)), 0),
|
|
2699
|
+
cell.maxWidth ?? Number.POSITIVE_INFINITY)
|
|
2016
2700
|
);
|
|
2017
2701
|
|
|
2018
2702
|
cell.value = lines.join("\\n");
|
|
@@ -2026,9 +2710,9 @@ do {
|
|
|
2026
2710
|
if (!recalculate && colWidths.reduce((a, b) => a + b, 0) > Math.max(process.stdout.columns - ${Math.max(theme.padding.app, 0) * 2}, 0)) {
|
|
2027
2711
|
let colIndex = 0;
|
|
2028
2712
|
const cell = cells.reduce((ret, row) => {
|
|
2029
|
-
return row.reduce((largest, current,
|
|
2713
|
+
return row.reduce((largest, current, index) => {
|
|
2030
2714
|
if (largest.width < current.width) {
|
|
2031
|
-
colIndex =
|
|
2715
|
+
colIndex = index;
|
|
2032
2716
|
return current;
|
|
2033
2717
|
}
|
|
2034
2718
|
return largest;
|
|
@@ -2037,7 +2721,8 @@ do {
|
|
|
2037
2721
|
|
|
2038
2722
|
const lines = splitText(
|
|
2039
2723
|
cell.value,
|
|
2040
|
-
Math.max(process.stdout.columns - ${Math.max(theme.padding.app, 0) * 2} - (colWidths.filter((_, i) => i !== colIndex).reduce((a, b) => a + b, 0)) - cell.padding * 2, 0)
|
|
2724
|
+
Math.min(Math.max(process.stdout.columns - ${Math.max(theme.padding.app, 0) * 2} - (colWidths.filter((_, i) => i !== colIndex).reduce((a, b) => a + b, 0)) - cell.padding * 2, 0),
|
|
2725
|
+
cell.maxWidth ?? Number.POSITIVE_INFINITY)
|
|
2041
2726
|
);
|
|
2042
2727
|
|
|
2043
2728
|
cell.value = lines.join("\\n");
|
|
@@ -2124,48 +2809,41 @@ function ConsoleBuiltin(props) {
|
|
|
2124
2809
|
},
|
|
2125
2810
|
get children() {
|
|
2126
2811
|
return [
|
|
2812
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(AnsiHelpersDeclarations, {}),
|
|
2813
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2127
2814
|
(0, __alloy_js_core_jsx_runtime.createComponent)(StripAnsiFunctionDeclaration, {}),
|
|
2128
|
-
(0, __alloy_js_core_jsx_runtime.
|
|
2129
|
-
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
2815
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2130
2816
|
(0, __alloy_js_core_jsx_runtime.createComponent)(WrapAnsiFunction, {}),
|
|
2131
|
-
(0, __alloy_js_core_jsx_runtime.
|
|
2132
|
-
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
2817
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2133
2818
|
(0, __alloy_js_core_jsx_runtime.createComponent)(ColorsDeclaration, {}),
|
|
2134
|
-
(0, __alloy_js_core_jsx_runtime.
|
|
2135
|
-
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
2819
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2136
2820
|
(0, __alloy_js_core_jsx_runtime.createComponent)(WriteLineFunctionDeclaration, {}),
|
|
2137
|
-
(0, __alloy_js_core_jsx_runtime.
|
|
2138
|
-
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
2821
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2139
2822
|
(0, __alloy_js_core_jsx_runtime.createComponent)(LinkFunctionDeclaration, {}),
|
|
2140
|
-
(0, __alloy_js_core_jsx_runtime.
|
|
2141
|
-
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
2823
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2142
2824
|
(0, __alloy_js_core_jsx_runtime.createComponent)(DividerFunctionDeclaration, {}),
|
|
2143
|
-
(0, __alloy_js_core_jsx_runtime.
|
|
2144
|
-
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
2825
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2145
2826
|
(0, __alloy_js_core_jsx_runtime.createComponent)(MessageFunctionDeclaration, {
|
|
2146
2827
|
type: "help",
|
|
2147
2828
|
variant: "help",
|
|
2148
2829
|
consoleFnName: "log",
|
|
2149
2830
|
description: "help"
|
|
2150
2831
|
}),
|
|
2151
|
-
(0, __alloy_js_core_jsx_runtime.
|
|
2152
|
-
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
2832
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2153
2833
|
(0, __alloy_js_core_jsx_runtime.createComponent)(MessageFunctionDeclaration, {
|
|
2154
2834
|
type: "success",
|
|
2155
2835
|
variant: "success",
|
|
2156
2836
|
consoleFnName: "info",
|
|
2157
2837
|
description: "success"
|
|
2158
2838
|
}),
|
|
2159
|
-
(0, __alloy_js_core_jsx_runtime.
|
|
2160
|
-
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
2839
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2161
2840
|
(0, __alloy_js_core_jsx_runtime.createComponent)(MessageFunctionDeclaration, {
|
|
2162
2841
|
type: "info",
|
|
2163
2842
|
variant: "info",
|
|
2164
2843
|
consoleFnName: "info",
|
|
2165
2844
|
description: "informational"
|
|
2166
2845
|
}),
|
|
2167
|
-
(0, __alloy_js_core_jsx_runtime.
|
|
2168
|
-
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
2846
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2169
2847
|
(0, __alloy_js_core_jsx_runtime.createComponent)(MessageFunctionDeclaration, {
|
|
2170
2848
|
type: "debug",
|
|
2171
2849
|
variant: "debug",
|
|
@@ -2181,8 +2859,7 @@ function ConsoleBuiltin(props) {
|
|
|
2181
2859
|
});
|
|
2182
2860
|
}
|
|
2183
2861
|
}),
|
|
2184
|
-
(0, __alloy_js_core_jsx_runtime.
|
|
2185
|
-
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
2862
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2186
2863
|
(0, __alloy_js_core_jsx_runtime.createComponent)(MessageFunctionDeclaration, {
|
|
2187
2864
|
type: "verbose",
|
|
2188
2865
|
variant: "info",
|
|
@@ -2199,24 +2876,21 @@ function ConsoleBuiltin(props) {
|
|
|
2199
2876
|
});
|
|
2200
2877
|
}
|
|
2201
2878
|
}),
|
|
2202
|
-
(0, __alloy_js_core_jsx_runtime.
|
|
2203
|
-
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
2879
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2204
2880
|
(0, __alloy_js_core_jsx_runtime.createComponent)(MessageFunctionDeclaration, {
|
|
2205
2881
|
type: "warn",
|
|
2206
2882
|
variant: "warning",
|
|
2207
2883
|
consoleFnName: "warn",
|
|
2208
2884
|
description: "warning"
|
|
2209
2885
|
}),
|
|
2210
|
-
(0, __alloy_js_core_jsx_runtime.
|
|
2211
|
-
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
2886
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2212
2887
|
(0, __alloy_js_core_jsx_runtime.createComponent)(MessageFunctionDeclaration, {
|
|
2213
2888
|
type: "danger",
|
|
2214
2889
|
variant: "danger",
|
|
2215
2890
|
consoleFnName: "error",
|
|
2216
2891
|
description: "destructive/danger"
|
|
2217
2892
|
}),
|
|
2218
|
-
(0, __alloy_js_core_jsx_runtime.
|
|
2219
|
-
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
2893
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2220
2894
|
(0, __alloy_js_core_jsx_runtime.createComponent)(MessageFunctionDeclaration, {
|
|
2221
2895
|
type: "error",
|
|
2222
2896
|
variant: "error",
|
|
@@ -2235,8 +2909,7 @@ function ConsoleBuiltin(props) {
|
|
|
2235
2909
|
name: "message",
|
|
2236
2910
|
type: "string | undefined"
|
|
2237
2911
|
}),
|
|
2238
|
-
(0, __alloy_js_core_jsx_runtime.
|
|
2239
|
-
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
2912
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2240
2913
|
(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.IfStatement, {
|
|
2241
2914
|
condition: __alloy_js_core.code`(err as Error)?.message`,
|
|
2242
2915
|
get children() {
|
|
@@ -2250,20 +2923,18 @@ function ConsoleBuiltin(props) {
|
|
|
2250
2923
|
];
|
|
2251
2924
|
}
|
|
2252
2925
|
}),
|
|
2253
|
-
(0, __alloy_js_core_jsx_runtime.
|
|
2254
|
-
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
2926
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2255
2927
|
(0, __alloy_js_core_jsx_runtime.createComponent)(TableFunctionDeclaration, {}),
|
|
2256
|
-
(0, __alloy_js_core_jsx_runtime.
|
|
2257
|
-
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
2928
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2258
2929
|
children,
|
|
2259
|
-
(0, __alloy_js_core_jsx_runtime.
|
|
2260
|
-
(0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {})
|
|
2930
|
+
(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {})
|
|
2261
2931
|
];
|
|
2262
2932
|
}
|
|
2263
2933
|
});
|
|
2264
2934
|
}
|
|
2265
2935
|
|
|
2266
2936
|
//#endregion
|
|
2937
|
+
exports.AnsiHelpersDeclarations = AnsiHelpersDeclarations;
|
|
2267
2938
|
exports.ColorsDeclaration = ColorsDeclaration;
|
|
2268
2939
|
exports.ConsoleBuiltin = ConsoleBuiltin;
|
|
2269
2940
|
exports.DividerFunctionDeclaration = DividerFunctionDeclaration;
|