@shell-shock/plugin-console 0.2.12 → 0.2.15
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/dist/_virtual/_rolldown/runtime.cjs +29 -1
- package/dist/components/console-builtin.cjs +1892 -80
- package/dist/components/console-builtin.d.cts.map +1 -1
- package/dist/components/console-builtin.d.mts.map +1 -1
- package/dist/components/console-builtin.mjs +1874 -80
- package/dist/components/console-builtin.mjs.map +1 -1
- package/dist/components/index.cjs +21 -1
- package/dist/components/index.mjs +3 -1
- package/dist/index.cjs +30 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +26 -1
- package/dist/index.mjs.map +1 -1
- package/dist/types/index.mjs +1 -1
- package/dist/types/plugin.d.cts.map +1 -1
- package/dist/types/plugin.d.mts.map +1 -1
- package/dist/types/plugin.mjs +1 -1
- package/package.json +14 -14
|
@@ -1,4 +1,36 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
3
|
+
let _alloy_js_core = require("@alloy-js/core");
|
|
4
|
+
let _alloy_js_typescript = require("@alloy-js/typescript");
|
|
5
|
+
let _powerlines_plugin_alloy_core_components_spacing = require("@powerlines/plugin-alloy/core/components/spacing");
|
|
6
|
+
let _powerlines_plugin_alloy_typescript = require("@powerlines/plugin-alloy/typescript");
|
|
7
|
+
let _powerlines_plugin_alloy_typescript_components_builtin_file = require("@powerlines/plugin-alloy/typescript/components/builtin-file");
|
|
8
|
+
let _powerlines_plugin_alloy_typescript_components_tsdoc = require("@powerlines/plugin-alloy/typescript/components/tsdoc");
|
|
9
|
+
let _shell_shock_core_components_helpers = require("@shell-shock/core/components/helpers");
|
|
10
|
+
let _shell_shock_plugin_theme_contexts_theme = require("@shell-shock/plugin-theme/contexts/theme");
|
|
11
|
+
let _shell_shock_plugin_theme_helpers_ansi_utils = require("@shell-shock/plugin-theme/helpers/ansi-utils");
|
|
12
|
+
let _stryke_string_format = require("@stryke/string-format");
|
|
13
|
+
let _stryke_string_format_vowels = require("@stryke/string-format/vowels");
|
|
14
|
+
let _stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
|
|
15
|
+
let defu = require("defu");
|
|
16
|
+
|
|
17
|
+
//#region src/components/console-builtin.tsx
|
|
18
|
+
function AnsiHelpersDeclarations() {
|
|
19
|
+
return [
|
|
20
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
|
|
21
|
+
"const": true,
|
|
22
|
+
"export": true,
|
|
23
|
+
name: "beep",
|
|
24
|
+
doc: "The ASCII Bell character, which can be used to trigger a beep sound in the console.",
|
|
25
|
+
children: _alloy_js_core.code` "\\u0007"; `
|
|
26
|
+
}),
|
|
27
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
28
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
|
|
29
|
+
"const": true,
|
|
30
|
+
"export": true,
|
|
31
|
+
name: "cursor",
|
|
32
|
+
doc: "An object containing ANSI escape codes for controlling the console cursor.",
|
|
33
|
+
children: _alloy_js_core.code` {
|
|
2
34
|
to(x: number, y?: number) {
|
|
3
35
|
if (!y) {
|
|
4
36
|
return \`\\x1B[\${x + 1}G\`;
|
|
@@ -34,7 +66,15 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_
|
|
|
34
66
|
show: "\\x1B[?25h",
|
|
35
67
|
save: "\\x1B7",
|
|
36
68
|
restore: "\\x1B8"
|
|
37
|
-
} `
|
|
69
|
+
} `
|
|
70
|
+
}),
|
|
71
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
72
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
|
|
73
|
+
"const": true,
|
|
74
|
+
"export": true,
|
|
75
|
+
name: "erase",
|
|
76
|
+
doc: "An object containing ANSI escape codes for erasing parts of the console.",
|
|
77
|
+
children: _alloy_js_core.code` {
|
|
38
78
|
screen: "\\x1B[2J",
|
|
39
79
|
up: (count = 1) => "\\x1B[1J".repeat(count),
|
|
40
80
|
down: (count = 1) => "\\x1B[J".repeat(count),
|
|
@@ -53,10 +93,34 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_
|
|
|
53
93
|
|
|
54
94
|
return lineClear;
|
|
55
95
|
}
|
|
56
|
-
} `
|
|
96
|
+
} `
|
|
97
|
+
}),
|
|
98
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
99
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
|
|
100
|
+
"const": true,
|
|
101
|
+
"export": true,
|
|
102
|
+
name: "scroll",
|
|
103
|
+
doc: "An object containing ANSI escape codes for scrolling the console.",
|
|
104
|
+
children: _alloy_js_core.code` {
|
|
57
105
|
up: (count = 1) => "\\x1B[S".repeat(count),
|
|
58
106
|
down: (count = 1) => "\\x1B[T".repeat(count)
|
|
59
|
-
} `
|
|
107
|
+
} `
|
|
108
|
+
}),
|
|
109
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
110
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
111
|
+
"export": true,
|
|
112
|
+
name: "clear",
|
|
113
|
+
doc: "A helper function to clear the console based on a count of lines",
|
|
114
|
+
parameters: [{
|
|
115
|
+
name: "current",
|
|
116
|
+
type: "string",
|
|
117
|
+
doc: "The current console output to be cleared"
|
|
118
|
+
}, {
|
|
119
|
+
name: "consoleWidth",
|
|
120
|
+
type: "number",
|
|
121
|
+
doc: "The number of characters per line in the console"
|
|
122
|
+
}],
|
|
123
|
+
children: _alloy_js_core.code`if (!consoleWidth) {
|
|
60
124
|
return erase.line + cursor.to(0);
|
|
61
125
|
}
|
|
62
126
|
|
|
@@ -66,7 +130,16 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_
|
|
|
66
130
|
rows += 1 + Math.floor(Math.max([...stripAnsi(line)].length - 1, 0) / consoleWidth);
|
|
67
131
|
}
|
|
68
132
|
|
|
69
|
-
return erase.lines(rows); `
|
|
133
|
+
return erase.lines(rows); `
|
|
134
|
+
}),
|
|
135
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {})
|
|
136
|
+
];
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* A component to generate a console message function in a Shell Shock project.
|
|
140
|
+
*/
|
|
141
|
+
function ColorFunction({ ansi16, ansi256, ansi16m, skipBackground = false }) {
|
|
142
|
+
return _alloy_js_core.code` (text: string | number | boolean | null | undefined${skipBackground ? "" : `, background = false`}): string => {
|
|
70
143
|
try {
|
|
71
144
|
if (text === undefined || text === null || text === "") {
|
|
72
145
|
return "";
|
|
@@ -77,17 +150,321 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_
|
|
|
77
150
|
}
|
|
78
151
|
|
|
79
152
|
if (colorSupportLevels.stdout === 1) {
|
|
80
|
-
return wrapAnsi(String(text), ${
|
|
153
|
+
return wrapAnsi(String(text), ${skipBackground ? `"${ansi16.open}", "${ansi16.close}"` : `background ? "${ansi16.background.open}" : "${ansi16.open}", background ? "${ansi16.background.close}" : "${ansi16.close}"`});
|
|
81
154
|
} else if (colorSupportLevels.stdout === 2) {
|
|
82
|
-
return wrapAnsi(String(text), ${
|
|
155
|
+
return wrapAnsi(String(text), ${skipBackground ? `"${ansi256.open}", "${ansi256.close}"` : `background ? "${ansi256.background.open}" : "${ansi256.open}", background ? "${ansi256.background.close}" : "${ansi256.close}"`});
|
|
83
156
|
}
|
|
84
157
|
|
|
85
|
-
return wrapAnsi(String(text), ${
|
|
158
|
+
return wrapAnsi(String(text), ${skipBackground ? `"${ansi16m.open}", "${ansi16m.close}"` : `background ? "${ansi16m.background.open}" : "${ansi16m.open}", background ? "${ansi16m.background.close}" : "${ansi16m.close}"`});
|
|
86
159
|
} catch {
|
|
87
160
|
return String(text);
|
|
88
161
|
}
|
|
89
162
|
}
|
|
90
|
-
|
|
163
|
+
`;
|
|
164
|
+
}
|
|
165
|
+
function ThemeColorTypeDefinition(props) {
|
|
166
|
+
const { ansi16, ansi256, ansi16m, type, subType } = props;
|
|
167
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.For, {
|
|
168
|
+
get each() {
|
|
169
|
+
return Object.entries(ansi16);
|
|
170
|
+
},
|
|
171
|
+
semicolon: true,
|
|
172
|
+
doubleHardline: true,
|
|
173
|
+
enderPunctuation: true,
|
|
174
|
+
children: ([color, value]) => [(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
175
|
+
get when() {
|
|
176
|
+
return (0, _stryke_type_checks_is_set_object.isSetObject)(value);
|
|
177
|
+
},
|
|
178
|
+
get children() {
|
|
179
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
180
|
+
get when() {
|
|
181
|
+
return "open" in value && "close" in value;
|
|
182
|
+
},
|
|
183
|
+
get fallback() {
|
|
184
|
+
return [
|
|
185
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, { heading: `An object containing various ${subType ? `${subType} ` : ""}${color}${type ? ` ${type}` : ""} theme coloring functions.` }),
|
|
186
|
+
(0, _alloy_js_core_jsx_runtime.memo)(() => _alloy_js_core.code` ${(0, _stryke_string_format.camelCase)(color)}: { `),
|
|
187
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
188
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(ThemeColorTypeDefinition, {
|
|
189
|
+
get ansi16() {
|
|
190
|
+
return ansi16[color];
|
|
191
|
+
},
|
|
192
|
+
get ansi256() {
|
|
193
|
+
return ansi256[color];
|
|
194
|
+
},
|
|
195
|
+
get ansi16m() {
|
|
196
|
+
return ansi16m[color];
|
|
197
|
+
},
|
|
198
|
+
type: subType || type,
|
|
199
|
+
subType: color
|
|
200
|
+
}),
|
|
201
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
202
|
+
_alloy_js_core.code` }`
|
|
203
|
+
];
|
|
204
|
+
},
|
|
205
|
+
get children() {
|
|
206
|
+
return [(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
207
|
+
get heading() {
|
|
208
|
+
return `A function that applies ${(0, _stryke_string_format_vowels.getIndefiniteArticle)(color)} ${color}${type ? ` ${type}` : ""}${subType ? ` ${subType}` : ""} color styling to provided console text.`;
|
|
209
|
+
},
|
|
210
|
+
get children() {
|
|
211
|
+
return [
|
|
212
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocRemarks, { children: `This function takes a string and an optional boolean indicating whether to apply the color as a background. It returns the input string wrapped in the appropriate ANSI escape codes for ${color}${type ? ` ${type}` : ""}${subType ? ` ${subType}` : ""} color styling, based on the terminal's color support level. If colors are not supported, it simply returns the input text as a string.` }),
|
|
213
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
214
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
215
|
+
name: "text",
|
|
216
|
+
children: `The console text to which the ${color}${type ? ` ${type}` : ""}${subType ? ` ${subType}` : ""} color styling should be applied.`
|
|
217
|
+
}),
|
|
218
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
219
|
+
name: "background",
|
|
220
|
+
children: `A boolean indicating whether to apply the color as a background. Defaults to \`false\`.`
|
|
221
|
+
}),
|
|
222
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns, { children: `A string with ANSI escape codes applied for ${color}${type ? ` ${type}` : ""}${subType ? ` ${subType}` : ""} color styling, or the original text if the style is not supported in the current terminal.` })
|
|
223
|
+
];
|
|
224
|
+
}
|
|
225
|
+
}), (0, _alloy_js_core_jsx_runtime.memo)(() => _alloy_js_core.code`${(0, _stryke_string_format.camelCase)(color)}: (text: string, background?: boolean) => string`)];
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
})]
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
function ThemeColorObjectDefinition(props) {
|
|
233
|
+
const { ansi16, ansi256, ansi16m, type, subType } = props;
|
|
234
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.For, {
|
|
235
|
+
get each() {
|
|
236
|
+
return Object.entries(ansi16);
|
|
237
|
+
},
|
|
238
|
+
comma: true,
|
|
239
|
+
doubleHardline: true,
|
|
240
|
+
enderPunctuation: true,
|
|
241
|
+
children: ([color, value]) => [(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
242
|
+
get when() {
|
|
243
|
+
return (0, _stryke_type_checks_is_set_object.isSetObject)(value);
|
|
244
|
+
},
|
|
245
|
+
get children() {
|
|
246
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
247
|
+
get when() {
|
|
248
|
+
return "open" in value && "close" in value;
|
|
249
|
+
},
|
|
250
|
+
get fallback() {
|
|
251
|
+
return [
|
|
252
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, { heading: `An object containing various ${subType ? `${subType} ` : ""}${color}${type ? ` ${type}` : ""} theme coloring functions.` }),
|
|
253
|
+
(0, _alloy_js_core_jsx_runtime.memo)(() => _alloy_js_core.code` ${(0, _stryke_string_format.camelCase)(color)}: { `),
|
|
254
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
255
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(ThemeColorObjectDefinition, {
|
|
256
|
+
get ansi16() {
|
|
257
|
+
return ansi16[color];
|
|
258
|
+
},
|
|
259
|
+
get ansi256() {
|
|
260
|
+
return ansi256[color];
|
|
261
|
+
},
|
|
262
|
+
get ansi16m() {
|
|
263
|
+
return ansi16m[color];
|
|
264
|
+
},
|
|
265
|
+
type: subType || type,
|
|
266
|
+
subType: color
|
|
267
|
+
}),
|
|
268
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
269
|
+
_alloy_js_core.code` }`
|
|
270
|
+
];
|
|
271
|
+
},
|
|
272
|
+
get children() {
|
|
273
|
+
return [
|
|
274
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
275
|
+
get heading() {
|
|
276
|
+
return `A function that applies ${(0, _stryke_string_format_vowels.getIndefiniteArticle)(color)} ${color}${type ? ` ${type}` : ""}${subType ? ` ${subType}` : ""} color styling to provided console text.`;
|
|
277
|
+
},
|
|
278
|
+
get children() {
|
|
279
|
+
return [
|
|
280
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocRemarks, { children: `This function takes a string and an optional boolean indicating whether to apply the color as a background. It returns the input string wrapped in the appropriate ANSI escape codes for ${color}${type ? ` ${type}` : ""}${subType ? ` ${subType}` : ""} color styling, based on the terminal's color support level. If colors are not supported, it simply returns the input text as a string.` }),
|
|
281
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
282
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
283
|
+
name: "text",
|
|
284
|
+
children: `The console text to which the ${color}${type ? ` ${type}` : ""}${subType ? ` ${subType}` : ""} color styling should be applied.`
|
|
285
|
+
}),
|
|
286
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
287
|
+
name: "background",
|
|
288
|
+
children: `A boolean indicating whether to apply the color as a background. Defaults to \`false\`.`
|
|
289
|
+
}),
|
|
290
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns, { children: `A string with ANSI escape codes applied for ${color}${type ? ` ${type}` : ""}${subType ? ` ${subType}` : ""} color styling, or the original text if the style is not supported in the current terminal.` })
|
|
291
|
+
];
|
|
292
|
+
}
|
|
293
|
+
}),
|
|
294
|
+
(0, _alloy_js_core_jsx_runtime.memo)(() => _alloy_js_core.code`${(0, _stryke_string_format.camelCase)(color)}: `),
|
|
295
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(ColorFunction, {
|
|
296
|
+
get ansi16() {
|
|
297
|
+
return ansi16[color];
|
|
298
|
+
},
|
|
299
|
+
get ansi256() {
|
|
300
|
+
return ansi256[color];
|
|
301
|
+
},
|
|
302
|
+
get ansi16m() {
|
|
303
|
+
return ansi16m[color];
|
|
304
|
+
}
|
|
305
|
+
})
|
|
306
|
+
];
|
|
307
|
+
}
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
})]
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* A component to generate an object containing functions for coloring text in a Shell Shock project.
|
|
315
|
+
*/
|
|
316
|
+
function AnsiStyleFunctionsDeclaration() {
|
|
317
|
+
const colors = (0, _shell_shock_plugin_theme_contexts_theme.useColors)();
|
|
318
|
+
return [
|
|
319
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.For, {
|
|
320
|
+
each: _shell_shock_plugin_theme_helpers_ansi_utils.modifierKeys,
|
|
321
|
+
semicolon: true,
|
|
322
|
+
doubleHardline: true,
|
|
323
|
+
enderPunctuation: true,
|
|
324
|
+
children: (modifier) => [(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
325
|
+
get heading() {
|
|
326
|
+
return `A function that applies ${(0, _stryke_string_format_vowels.getIndefiniteArticle)((0, _stryke_string_format.titleCase)(modifier))} ${(0, _stryke_string_format.titleCase)(modifier)} text-style to provided console text.`;
|
|
327
|
+
},
|
|
328
|
+
get children() {
|
|
329
|
+
return [(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
330
|
+
name: "text",
|
|
331
|
+
get children() {
|
|
332
|
+
return `The console text to which the ${(0, _stryke_string_format.titleCase)(modifier)} text-style should be applied.`;
|
|
333
|
+
}
|
|
334
|
+
}), (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns, { get children() {
|
|
335
|
+
return `A string with ANSI escape codes applied for ${(0, _stryke_string_format.titleCase)(modifier)} text-style, or the original text if the style is not supported in the current terminal.`;
|
|
336
|
+
} })];
|
|
337
|
+
}
|
|
338
|
+
}), (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
|
|
339
|
+
"const": true,
|
|
340
|
+
"export": true,
|
|
341
|
+
get name() {
|
|
342
|
+
return (0, _stryke_string_format.camelCase)(modifier);
|
|
343
|
+
},
|
|
344
|
+
get initializer() {
|
|
345
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(ColorFunction, {
|
|
346
|
+
get ansi16() {
|
|
347
|
+
return colors.ansi16[modifier];
|
|
348
|
+
},
|
|
349
|
+
get ansi256() {
|
|
350
|
+
return colors.ansi256[modifier];
|
|
351
|
+
},
|
|
352
|
+
get ansi16m() {
|
|
353
|
+
return colors.ansi16m[modifier];
|
|
354
|
+
},
|
|
355
|
+
skipBackground: true
|
|
356
|
+
});
|
|
357
|
+
}
|
|
358
|
+
})]
|
|
359
|
+
}),
|
|
360
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
361
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.For, {
|
|
362
|
+
each: _shell_shock_plugin_theme_helpers_ansi_utils.colorKeys,
|
|
363
|
+
semicolon: true,
|
|
364
|
+
doubleHardline: true,
|
|
365
|
+
enderPunctuation: true,
|
|
366
|
+
children: (color) => [(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
367
|
+
get heading() {
|
|
368
|
+
return `A function that applies ${(0, _stryke_string_format_vowels.getIndefiniteArticle)((0, _stryke_string_format.titleCase)(color))} ${(0, _stryke_string_format.titleCase)(color)} color styling to provided console text.`;
|
|
369
|
+
},
|
|
370
|
+
get children() {
|
|
371
|
+
return [
|
|
372
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocRemarks, { get children() {
|
|
373
|
+
return `This function takes a string and an optional boolean indicating whether to apply the color as a background. It returns the input string wrapped in the appropriate ANSI escape codes for ${(0, _stryke_string_format_vowels.getIndefiniteArticle)((0, _stryke_string_format.titleCase)(color))} ${(0, _stryke_string_format.titleCase)(color)} color styling, based on the terminal's color support level. If colors are not supported, it simply returns the input text as a string.`;
|
|
374
|
+
} }),
|
|
375
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
376
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
377
|
+
name: "text",
|
|
378
|
+
get children() {
|
|
379
|
+
return `The console text to which the ${(0, _stryke_string_format.titleCase)(color)} color styling should be applied.`;
|
|
380
|
+
}
|
|
381
|
+
}),
|
|
382
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
383
|
+
name: "background",
|
|
384
|
+
children: `A boolean indicating whether to apply the color as a background. Defaults to \`false\`.`
|
|
385
|
+
}),
|
|
386
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns, { get children() {
|
|
387
|
+
return `A string with ANSI escape codes applied for ${(0, _stryke_string_format.titleCase)(color)} color styling, or the original text if the style is not supported in the current terminal.`;
|
|
388
|
+
} })
|
|
389
|
+
];
|
|
390
|
+
}
|
|
391
|
+
}), (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
|
|
392
|
+
"const": true,
|
|
393
|
+
"export": true,
|
|
394
|
+
get name() {
|
|
395
|
+
return (0, _stryke_string_format.camelCase)(color);
|
|
396
|
+
},
|
|
397
|
+
get initializer() {
|
|
398
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(ColorFunction, {
|
|
399
|
+
get ansi16() {
|
|
400
|
+
return colors.ansi16[color];
|
|
401
|
+
},
|
|
402
|
+
get ansi256() {
|
|
403
|
+
return colors.ansi256[color];
|
|
404
|
+
},
|
|
405
|
+
get ansi16m() {
|
|
406
|
+
return colors.ansi16m[color];
|
|
407
|
+
}
|
|
408
|
+
});
|
|
409
|
+
}
|
|
410
|
+
})]
|
|
411
|
+
}),
|
|
412
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
413
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.For, {
|
|
414
|
+
get each() {
|
|
415
|
+
return Object.keys(colors.ansi16.theme);
|
|
416
|
+
},
|
|
417
|
+
semicolon: true,
|
|
418
|
+
doubleHardline: true,
|
|
419
|
+
enderPunctuation: true,
|
|
420
|
+
children: (type) => [(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, { heading: `A nested object containing functions for applying ${type} theme colors to the console.` }), (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
|
|
421
|
+
"export": true,
|
|
422
|
+
get name() {
|
|
423
|
+
return `${(0, _stryke_string_format.camelCase)(type)}Colors`;
|
|
424
|
+
},
|
|
425
|
+
get initializer() {
|
|
426
|
+
return [
|
|
427
|
+
_alloy_js_core.code` {`,
|
|
428
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
429
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(ThemeColorObjectDefinition, {
|
|
430
|
+
get ansi16() {
|
|
431
|
+
return colors.ansi16.theme[type];
|
|
432
|
+
},
|
|
433
|
+
get ansi256() {
|
|
434
|
+
return colors.ansi256.theme[type];
|
|
435
|
+
},
|
|
436
|
+
get ansi16m() {
|
|
437
|
+
return colors.ansi16m.theme[type];
|
|
438
|
+
},
|
|
439
|
+
type
|
|
440
|
+
}),
|
|
441
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
442
|
+
_alloy_js_core.code`}`
|
|
443
|
+
];
|
|
444
|
+
}
|
|
445
|
+
})]
|
|
446
|
+
}),
|
|
447
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {})
|
|
448
|
+
];
|
|
449
|
+
}
|
|
450
|
+
/**
|
|
451
|
+
* A component to generate the `splitText` function in the `shell-shock:console` builtin module.
|
|
452
|
+
*/
|
|
453
|
+
function SplitTextFunctionDeclaration() {
|
|
454
|
+
return [
|
|
455
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
456
|
+
name: "adjustIndex",
|
|
457
|
+
parameters: [{
|
|
458
|
+
name: "line",
|
|
459
|
+
type: "string",
|
|
460
|
+
doc: "An input line which may contain ANSI escape codes. This is used to adjust the index for splitting the line based on visible characters rather than raw string length, ensuring that ANSI codes do not cause incorrect splitting of the text."
|
|
461
|
+
}, {
|
|
462
|
+
name: "index",
|
|
463
|
+
type: "number",
|
|
464
|
+
doc: "The index at which to split the line, based on visible characters (does not account for ANSI escape codes)."
|
|
465
|
+
}],
|
|
466
|
+
returnType: "number",
|
|
467
|
+
children: _alloy_js_core.code`let adjustedIndex = 0;
|
|
91
468
|
let visibleCount = 0;
|
|
92
469
|
const ansiRegex = new RegExp([
|
|
93
470
|
String.raw\`[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)\`,
|
|
@@ -106,7 +483,20 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_
|
|
|
106
483
|
}
|
|
107
484
|
}
|
|
108
485
|
|
|
109
|
-
return adjustedIndex; `
|
|
486
|
+
return adjustedIndex; `
|
|
487
|
+
}),
|
|
488
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
489
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
490
|
+
name: "breakLine",
|
|
491
|
+
parameters: [{
|
|
492
|
+
name: "line",
|
|
493
|
+
type: "string"
|
|
494
|
+
}, {
|
|
495
|
+
name: "index",
|
|
496
|
+
type: "number"
|
|
497
|
+
}],
|
|
498
|
+
returnType: "[string, string]",
|
|
499
|
+
children: _alloy_js_core.code`const adjustedIndex = adjustIndex(line, index);
|
|
110
500
|
const first = line.slice(0, adjustedIndex);
|
|
111
501
|
const second = line.slice(adjustedIndex);
|
|
112
502
|
|
|
@@ -155,7 +545,37 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_
|
|
|
155
545
|
// Prepend open codes to the start of "second"
|
|
156
546
|
const openSequence = openCodes.join("");
|
|
157
547
|
|
|
158
|
-
return [first.replace(/^\\s+/, "").replace(/\\s+$/, "") + closeSequence, openSequence + second.replace(/^\\s+/, "").replace(/\\s+$/, "")]; `
|
|
548
|
+
return [first.replace(/^\\s+/, "").replace(/\\s+$/, "") + closeSequence, openSequence + second.replace(/^\\s+/, "").replace(/\\s+$/, "")]; `
|
|
549
|
+
}),
|
|
550
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
551
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
552
|
+
heading: "Split text into multiple lines based on a maximum length.",
|
|
553
|
+
get children() {
|
|
554
|
+
return [
|
|
555
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocRemarks, { children: `This function splits the provided text into multiple lines based on the specified maximum length, ensuring that words are not broken in the middle.` }),
|
|
556
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
557
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
558
|
+
name: "text",
|
|
559
|
+
children: `The text to split into multiple lines.`
|
|
560
|
+
}),
|
|
561
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
562
|
+
name: "maxLength",
|
|
563
|
+
children: `The maximum length of each line.`
|
|
564
|
+
})
|
|
565
|
+
];
|
|
566
|
+
}
|
|
567
|
+
}),
|
|
568
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
569
|
+
name: "splitText",
|
|
570
|
+
"export": true,
|
|
571
|
+
parameters: [{
|
|
572
|
+
name: "text",
|
|
573
|
+
type: "string"
|
|
574
|
+
}, {
|
|
575
|
+
name: "maxLength",
|
|
576
|
+
type: "number | SizeToken"
|
|
577
|
+
}],
|
|
578
|
+
children: _alloy_js_core.code`let line = text;
|
|
159
579
|
let result = [] as string[];
|
|
160
580
|
|
|
161
581
|
const calculatedMaxLength = isSizeToken(maxLength) ? calculateWidth(maxLength) : maxLength;
|
|
@@ -193,35 +613,272 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_
|
|
|
193
613
|
}
|
|
194
614
|
|
|
195
615
|
result.push(line);
|
|
196
|
-
return result; `
|
|
616
|
+
return result; `
|
|
617
|
+
})
|
|
618
|
+
];
|
|
619
|
+
}
|
|
620
|
+
/**
|
|
621
|
+
* A component to generate the `write` function in the `shell-shock:console` builtin module.
|
|
622
|
+
*/
|
|
623
|
+
function WriteFunctionDeclaration() {
|
|
624
|
+
return [
|
|
625
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceDeclaration, {
|
|
626
|
+
"export": true,
|
|
627
|
+
name: "WriteOptions",
|
|
628
|
+
doc: "Options for writing to the console.",
|
|
629
|
+
get children() {
|
|
630
|
+
return [(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
631
|
+
heading: "Console function to use for writing to the console",
|
|
632
|
+
get children() {
|
|
633
|
+
return [
|
|
634
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocRemarks, { children: `The console function to use for writing to the console. If not specified, the default console function \`console.log\` will be used.` }),
|
|
635
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
636
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocDefaultValue, {
|
|
637
|
+
type: "any",
|
|
638
|
+
defaultValue: `\`console.log\``
|
|
639
|
+
})
|
|
640
|
+
];
|
|
641
|
+
}
|
|
642
|
+
}), (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceMember, {
|
|
643
|
+
name: "consoleFn",
|
|
644
|
+
optional: true,
|
|
645
|
+
type: "(text: string) => void"
|
|
646
|
+
})];
|
|
647
|
+
}
|
|
648
|
+
}),
|
|
649
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
650
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
651
|
+
heading: "Write to the console.",
|
|
652
|
+
get children() {
|
|
653
|
+
return [
|
|
654
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocRemarks, { children: `This function writes to the console, applying the appropriate padding as defined in the current theme configuration and wrapping as needed.` }),
|
|
655
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
656
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
657
|
+
name: "text",
|
|
658
|
+
children: `The text to write to the console.`
|
|
659
|
+
}),
|
|
660
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
661
|
+
name: "options",
|
|
662
|
+
children: `The options to apply when writing to the console.`
|
|
663
|
+
})
|
|
664
|
+
];
|
|
665
|
+
}
|
|
666
|
+
}),
|
|
667
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
668
|
+
"export": true,
|
|
669
|
+
name: "write",
|
|
670
|
+
parameters: [{
|
|
671
|
+
name: "text",
|
|
672
|
+
type: "string | number | boolean | null",
|
|
673
|
+
optional: true
|
|
674
|
+
}, {
|
|
675
|
+
name: "options",
|
|
676
|
+
type: "WriteOptions",
|
|
677
|
+
default: "{}"
|
|
678
|
+
}],
|
|
679
|
+
children: _alloy_js_core.code`const consoleFn = options.consoleFn ?? console.log;
|
|
197
680
|
if (text === undefined || text === null || text === "") {
|
|
198
681
|
consoleFn("");
|
|
199
682
|
return;
|
|
200
683
|
}
|
|
201
684
|
|
|
202
|
-
consoleFn(String(text)); `
|
|
685
|
+
consoleFn(String(text)); `
|
|
686
|
+
})
|
|
687
|
+
];
|
|
688
|
+
}
|
|
689
|
+
/**
|
|
690
|
+
* A component to generate the `writeLine` function in the `shell-shock:console` builtin module.
|
|
691
|
+
*/
|
|
692
|
+
function WriteLineFunctionDeclaration() {
|
|
693
|
+
const theme = (0, _shell_shock_plugin_theme_contexts_theme.useTheme)();
|
|
694
|
+
return [
|
|
695
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceDeclaration, {
|
|
696
|
+
"export": true,
|
|
697
|
+
name: "WriteLineOptions",
|
|
698
|
+
doc: "Options for writing a line to the console.",
|
|
699
|
+
"extends": ["WriteOptions"],
|
|
700
|
+
get children() {
|
|
701
|
+
return [
|
|
702
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
703
|
+
heading: "Padding to apply to the line",
|
|
704
|
+
get children() {
|
|
705
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocRemarks, { children: `The amount of padding (in spaces) to apply to the line when writing to the console. This value is applied to both the left and right sides of the line. If not specified, the default padding defined in the current theme configuration will be used.` });
|
|
706
|
+
}
|
|
707
|
+
}),
|
|
708
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceMember, {
|
|
709
|
+
name: "padding",
|
|
710
|
+
optional: true,
|
|
711
|
+
type: "number"
|
|
712
|
+
}),
|
|
713
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
714
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
715
|
+
heading: "Color of the line text",
|
|
716
|
+
get children() {
|
|
717
|
+
return [(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocRemarks, { children: `The color to apply to the line text when writing to the console. This can be one of the predefined color themes: "primary", "secondary", or "tertiary". If not specified, no specific coloring will be applied to the text (the default/system terminal text color will likely be used).` }), (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {})];
|
|
718
|
+
}
|
|
719
|
+
}),
|
|
720
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceMember, {
|
|
721
|
+
name: "color",
|
|
722
|
+
optional: true,
|
|
723
|
+
type: "\"primary\" | \"secondary\" | \"tertiary\""
|
|
724
|
+
})
|
|
725
|
+
];
|
|
726
|
+
}
|
|
727
|
+
}),
|
|
728
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
729
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
730
|
+
heading: "Write a line to the console.",
|
|
731
|
+
get children() {
|
|
732
|
+
return [
|
|
733
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocRemarks, { children: `This function writes a line to the console, applying the appropriate padding as defined in the current theme configuration and wrapping as needed.` }),
|
|
734
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
735
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
736
|
+
name: "text",
|
|
737
|
+
children: `The line text to write to the console.`
|
|
738
|
+
}),
|
|
739
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
740
|
+
name: "options",
|
|
741
|
+
children: `The options to apply when writing the line to the console.`
|
|
742
|
+
})
|
|
743
|
+
];
|
|
744
|
+
}
|
|
745
|
+
}),
|
|
746
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
747
|
+
"export": true,
|
|
748
|
+
name: "writeLine",
|
|
749
|
+
parameters: [{
|
|
750
|
+
name: "text",
|
|
751
|
+
type: "string | number | boolean | null",
|
|
752
|
+
optional: true
|
|
753
|
+
}, {
|
|
754
|
+
name: "options",
|
|
755
|
+
type: "WriteLineOptions",
|
|
756
|
+
default: "{}"
|
|
757
|
+
}],
|
|
758
|
+
get children() {
|
|
759
|
+
return _alloy_js_core.code`const color = options.color;
|
|
203
760
|
if (text === undefined || text === null || text === "") {
|
|
204
761
|
write("", options);
|
|
205
762
|
return;
|
|
206
763
|
}
|
|
207
764
|
|
|
208
|
-
write(\`\${" ".repeat(Math.max(options.padding ?? ${
|
|
765
|
+
write(\`\${" ".repeat(Math.max(options.padding ?? ${theme.padding.app}, 0))}\${color ? textColors.body[color](String(text)) : String(text)}\`, options); `;
|
|
766
|
+
}
|
|
767
|
+
})
|
|
768
|
+
];
|
|
769
|
+
}
|
|
770
|
+
/**
|
|
771
|
+
* A component to generate the message functions in the `shell-shock:console` builtin module.
|
|
772
|
+
*/
|
|
773
|
+
function MessageFunctionDeclaration(props) {
|
|
774
|
+
const { type, variant, consoleFnName, description, prefix, parameters, timestamp, color = variant } = props;
|
|
775
|
+
const theme = (0, _shell_shock_plugin_theme_contexts_theme.useTheme)();
|
|
776
|
+
return [(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
777
|
+
get heading() {
|
|
778
|
+
return `Write ${(0, _stryke_string_format_vowels.getIndefiniteArticle)(description)} ${description} message to the console.`;
|
|
779
|
+
},
|
|
780
|
+
get children() {
|
|
781
|
+
return [
|
|
782
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocRemarks, { children: `This function initializes the Powerlines environment configuration object.` }),
|
|
783
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
784
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
785
|
+
name: "message",
|
|
786
|
+
children: `The message to write to the console.`
|
|
787
|
+
}),
|
|
788
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
789
|
+
name: "header",
|
|
790
|
+
children: `An optional header to display above the message. If not provided, a default header based on the message type and variant will be used if defined in the theme configuration; otherwise, no header will be displayed.`
|
|
791
|
+
})
|
|
792
|
+
];
|
|
793
|
+
}
|
|
794
|
+
}), (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
795
|
+
"export": true,
|
|
796
|
+
name: type,
|
|
797
|
+
parameters: parameters ?? [{
|
|
798
|
+
name: "message",
|
|
799
|
+
type: "string",
|
|
800
|
+
optional: false
|
|
801
|
+
}, {
|
|
802
|
+
name: "header",
|
|
803
|
+
type: "string",
|
|
804
|
+
optional: true
|
|
805
|
+
}],
|
|
806
|
+
get children() {
|
|
807
|
+
return [(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
808
|
+
get when() {
|
|
809
|
+
return Boolean(prefix);
|
|
810
|
+
},
|
|
811
|
+
get children() {
|
|
812
|
+
return [
|
|
813
|
+
prefix,
|
|
814
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
815
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {})
|
|
816
|
+
];
|
|
817
|
+
}
|
|
818
|
+
}), (0, _alloy_js_core_jsx_runtime.memo)(() => _alloy_js_core.code`
|
|
209
819
|
if (!message) {
|
|
210
820
|
return;
|
|
211
821
|
}
|
|
212
822
|
|
|
213
|
-
${!
|
|
823
|
+
${!theme.labels.message.footer[variant] && timestamp ? `const timestamp = \`\${textColors.message.footer.${color}(new Date().toLocaleDateString())} \${borderColors.message.outline.${color}("${theme.borderStyles.message.outline[variant].bottom}")} \${textColors.message.footer.${color}(new Date().toLocaleTimeString())}\`; ` : ""}
|
|
214
824
|
|
|
215
|
-
writeLine(borderColors.message.outline.${
|
|
825
|
+
writeLine(borderColors.message.outline.${color}("${theme.borderStyles.message.outline[variant].topLeft}") + ${theme.labels.message.header[variant] || theme.icons.message.header[variant] ? `borderColors.message.outline.${color}("${theme.borderStyles.message.outline[variant].top}".repeat(4)) + " " + ${theme.icons.message.header[variant] ? `borderColors.message.outline.${color}("${theme.icons.message.header[variant]}") + " " +` : ""} bold(textColors.message.header.${color}(header || "${theme.labels.message.header[variant]}")) + " " + borderColors.message.outline.${color}("${theme.borderStyles.message.outline[variant].top}".repeat(Math.max(getTerminalSize().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)))` : `borderColors.message.outline.${color}("${theme.borderStyles.message.outline[variant].top}".repeat(Math.max(getTerminalSize().columns - ${Math.max(theme.padding.app, 0) * 2 + theme.borderStyles.message.outline[variant].topLeft.length + theme.borderStyles.message.outline[variant].topRight.length}, 0)))`} + borderColors.message.outline.${color}("${theme.borderStyles.message.outline[variant].topRight}"), { consoleFn: console.${consoleFnName} });
|
|
216
826
|
splitText(
|
|
217
827
|
message,
|
|
218
|
-
Math.max(getTerminalSize().columns - ${(Math.max(
|
|
828
|
+
Math.max(getTerminalSize().columns - ${(Math.max(theme.padding.app, 0) + Math.max(theme.padding.message, 0)) * 2 + theme.borderStyles.message.outline[variant].left.length + theme.borderStyles.message.outline[variant].right.length}, 12)
|
|
219
829
|
).forEach(line => {
|
|
220
|
-
writeLine(borderColors.message.outline.${
|
|
830
|
+
writeLine(borderColors.message.outline.${color}("${theme.borderStyles.message.outline[variant].left + " ".repeat(Math.max(theme.padding.message, 0))}") + textColors.message.description.${color}(line) + " ".repeat(Math.max(getTerminalSize().columns - (stripAnsi(line).length + ${Math.max(theme.padding.app, 0) * 2 + Math.max(theme.padding.message, 0) + theme.borderStyles.message.outline[variant].left.length + theme.borderStyles.message.outline[variant].right.length}), 0)) + borderColors.message.outline.${color}("${theme.borderStyles.message.outline[variant].right}"), { consoleFn: console.${consoleFnName} });
|
|
221
831
|
});
|
|
222
|
-
writeLine(borderColors.message.outline.${
|
|
223
|
-
`)]
|
|
224
|
-
|
|
832
|
+
writeLine(borderColors.message.outline.${color}("${theme.borderStyles.message.outline[variant].bottomLeft}") + ${theme.labels.message.footer[variant] || timestamp ? `borderColors.message.outline.${color}("${theme.borderStyles.message.outline[variant].bottom}".repeat(Math.max(getTerminalSize().columns - ${Math.max(theme.padding.app, 0) * 2 + 4 + (theme.labels.message.footer[variant] ? theme.labels.message.footer[variant].length + 2 : 0) + theme.borderStyles.message.outline[variant].bottomLeft.length + theme.borderStyles.message.outline[variant].bottomRight.length}${!theme.labels.message.footer[variant] && timestamp ? " - (stripAnsi(timestamp).length + 2)" : ""}, 0))) + " " + ${`bold(textColors.message.footer.${color}(${theme.labels.message.footer[variant] ? `"${theme.labels.message.footer[variant]}"` : timestamp && "timestamp"}))`} + " " + borderColors.message.outline.${color}("${theme.borderStyles.message.outline[variant].bottom}".repeat(4))` : `borderColors.message.outline.${color}("${theme.borderStyles.message.outline[variant].bottom}".repeat(Math.max(getTerminalSize().columns - ${Math.max(theme.padding.app, 0) * 2 + theme.borderStyles.message.outline[variant].bottomLeft.length + theme.borderStyles.message.outline[variant].bottomRight.length}, 0)))`} + borderColors.message.outline.${color}("${theme.borderStyles.message.outline[variant].bottomRight}"), { consoleFn: console.${consoleFnName} });
|
|
833
|
+
`)];
|
|
834
|
+
}
|
|
835
|
+
})];
|
|
836
|
+
}
|
|
837
|
+
/**
|
|
838
|
+
* A component to generate the `wrapAnsi` function in the `shell-shock:console` builtin module.
|
|
839
|
+
*/
|
|
840
|
+
function WrapAnsiFunction() {
|
|
841
|
+
return [(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
842
|
+
heading: "Applies ANSI escape codes to a string.",
|
|
843
|
+
get children() {
|
|
844
|
+
return [
|
|
845
|
+
(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/closing tags.` }),
|
|
846
|
+
(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"` }),
|
|
847
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
848
|
+
name: "text",
|
|
849
|
+
children: `The text to apply ANSI codes to.`
|
|
850
|
+
}),
|
|
851
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
852
|
+
name: "open",
|
|
853
|
+
children: `The opening ANSI code.`
|
|
854
|
+
}),
|
|
855
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
856
|
+
name: "close",
|
|
857
|
+
children: `The closing ANSI code.`
|
|
858
|
+
}),
|
|
859
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns, { children: `The text with ANSI codes applied.` })
|
|
860
|
+
];
|
|
861
|
+
}
|
|
862
|
+
}), (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
863
|
+
name: "wrapAnsi",
|
|
864
|
+
parameters: [
|
|
865
|
+
{
|
|
866
|
+
name: "text",
|
|
867
|
+
type: "string | number",
|
|
868
|
+
optional: false
|
|
869
|
+
},
|
|
870
|
+
{
|
|
871
|
+
name: "open",
|
|
872
|
+
type: "string",
|
|
873
|
+
optional: false
|
|
874
|
+
},
|
|
875
|
+
{
|
|
876
|
+
name: "close",
|
|
877
|
+
type: "string",
|
|
878
|
+
optional: false
|
|
879
|
+
}
|
|
880
|
+
],
|
|
881
|
+
children: _alloy_js_core.code`const str = String(text);
|
|
225
882
|
const tokens = [] as string[];
|
|
226
883
|
|
|
227
884
|
let last = 0;
|
|
@@ -254,15 +911,235 @@ console.log(result); // "\\\\x1b[36mHello\\\\x1b[39\\\\x1b[31mWorld\\\\x1b[0m\\\
|
|
|
254
911
|
}
|
|
255
912
|
|
|
256
913
|
return result;
|
|
257
|
-
`
|
|
914
|
+
`
|
|
915
|
+
})];
|
|
916
|
+
}
|
|
917
|
+
/**
|
|
918
|
+
* A component to generate the `stripAnsi` function in the `shell-shock:console` builtin module.
|
|
919
|
+
*/
|
|
920
|
+
function StripAnsiFunctionDeclaration() {
|
|
921
|
+
return [(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
922
|
+
heading: "Removes ANSI escape codes from a string.",
|
|
923
|
+
get children() {
|
|
924
|
+
return [
|
|
925
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocExample, { children: `const result = stripAnsi("Hello\\\\x1b[31mWorld\\\\x1b[0mAgain"); // "HelloWorldAgain"` }),
|
|
926
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
927
|
+
name: "text",
|
|
928
|
+
children: `The text to strip ANSI codes from.`
|
|
929
|
+
}),
|
|
930
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns, { children: `The text with ANSI codes removed.` })
|
|
931
|
+
];
|
|
932
|
+
}
|
|
933
|
+
}), (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
934
|
+
"export": true,
|
|
935
|
+
name: "stripAnsi",
|
|
936
|
+
parameters: [{
|
|
937
|
+
name: "text",
|
|
938
|
+
type: "string | number",
|
|
939
|
+
optional: false
|
|
940
|
+
}],
|
|
941
|
+
children: _alloy_js_core.code`return String(text).replace(new RegExp([
|
|
258
942
|
String.raw\`[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)\`,
|
|
259
943
|
String.raw\`(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))\`
|
|
260
|
-
].join("|"), "g"), "");`
|
|
944
|
+
].join("|"), "g"), "");`
|
|
945
|
+
})];
|
|
946
|
+
}
|
|
947
|
+
/**
|
|
948
|
+
* A component to generate the `stripAnsi` function in the `shell-shock:console` builtin module.
|
|
949
|
+
*/
|
|
950
|
+
function DividerFunctionDeclaration() {
|
|
951
|
+
const theme = (0, _shell_shock_plugin_theme_contexts_theme.useTheme)();
|
|
952
|
+
return [
|
|
953
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceDeclaration, {
|
|
954
|
+
"export": true,
|
|
955
|
+
name: "DividerOptions",
|
|
956
|
+
doc: "Options for formatting the divider line written to console.",
|
|
957
|
+
get children() {
|
|
958
|
+
return [
|
|
959
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceMember, {
|
|
960
|
+
name: "width",
|
|
961
|
+
optional: true,
|
|
962
|
+
type: "number",
|
|
963
|
+
doc: "The width of the divider line. If not specified, the divider will span the full width of the console, minus the padding."
|
|
964
|
+
}),
|
|
965
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
966
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
967
|
+
heading: "The border of the divider line. Can be 'primary', 'secondary', 'tertiary', or 'none'. If not specified, the default border style will be used.",
|
|
968
|
+
get children() {
|
|
969
|
+
return [(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocRemarks, { children: `The value provided will determine the border style and color based on the current theme configuration.` }), (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocDefaultValue, {
|
|
970
|
+
type: "string",
|
|
971
|
+
defaultValue: "primary"
|
|
972
|
+
})];
|
|
973
|
+
}
|
|
974
|
+
}),
|
|
975
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceMember, {
|
|
976
|
+
name: "border",
|
|
977
|
+
optional: true,
|
|
978
|
+
type: "\"primary\" | \"secondary\" | \"tertiary\"",
|
|
979
|
+
doc: "The border style/color of the divider line. Can be 'primary', 'secondary', 'tertiary', or 'none'. If not specified, the default border style will be used."
|
|
980
|
+
}),
|
|
981
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
982
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
983
|
+
heading: "Padding to apply to the line",
|
|
984
|
+
get children() {
|
|
985
|
+
return [(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocRemarks, { children: `The amount of padding (in spaces) to apply to the line when writing to the console. This value is applied to both the left and right sides of the line. If not specified, the default padding defined in the current theme configuration will be used.` }), (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocDefaultValue, {
|
|
986
|
+
type: "number",
|
|
987
|
+
get defaultValue() {
|
|
988
|
+
return theme.padding.app * 4;
|
|
989
|
+
}
|
|
990
|
+
})];
|
|
991
|
+
}
|
|
992
|
+
}),
|
|
993
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceMember, {
|
|
994
|
+
name: "padding",
|
|
995
|
+
optional: true,
|
|
996
|
+
type: "number"
|
|
997
|
+
})
|
|
998
|
+
];
|
|
999
|
+
}
|
|
1000
|
+
}),
|
|
1001
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1002
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
1003
|
+
heading: "Write a horizontal divider line to the console.",
|
|
1004
|
+
get children() {
|
|
1005
|
+
return [(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocExample, { children: `divider({ width: 50, border: "primary" }); // Writes a horizontal divider line of width 50 with primary border.` }), (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
1006
|
+
name: "options",
|
|
1007
|
+
children: `Options for formatting the divider line.`
|
|
1008
|
+
})];
|
|
1009
|
+
}
|
|
1010
|
+
}),
|
|
1011
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
1012
|
+
"export": true,
|
|
1013
|
+
name: "divider",
|
|
1014
|
+
parameters: [{
|
|
1015
|
+
name: "options",
|
|
1016
|
+
type: "DividerOptions",
|
|
1017
|
+
optional: false
|
|
1018
|
+
}],
|
|
1019
|
+
get children() {
|
|
1020
|
+
return _alloy_js_core.code`const padding = options.padding ?? ${Math.max(theme.padding.app, 1) * 4};
|
|
261
1021
|
const width = options.width ?? (getTerminalSize().columns - (Math.max(padding, 0) * 2));
|
|
262
|
-
const border = options.border === "tertiary" ? borderColors.app.divider.tertiary("${
|
|
1022
|
+
const border = options.border === "tertiary" ? borderColors.app.divider.tertiary("${theme.borderStyles.app.divider.tertiary.top}") : options.border === "secondary" ? borderColors.app.divider.secondary("${theme.borderStyles.app.divider.secondary.top}") : borderColors.app.divider.primary("${theme.borderStyles.app.divider.primary.top}");
|
|
263
1023
|
|
|
264
|
-
writeLine(" ".repeat(Math.max(padding - ${
|
|
265
|
-
|
|
1024
|
+
writeLine(" ".repeat(Math.max(padding - ${theme.padding.app}, 0)) + border.repeat(Math.max(width / ${theme.borderStyles.app.divider.primary.top.length ?? 1}, 0)));
|
|
1025
|
+
`;
|
|
1026
|
+
}
|
|
1027
|
+
})
|
|
1028
|
+
];
|
|
1029
|
+
}
|
|
1030
|
+
/**
|
|
1031
|
+
* A component to generate the `link` function in the `shell-shock:console` builtin module.
|
|
1032
|
+
*/
|
|
1033
|
+
function LinkFunctionDeclaration() {
|
|
1034
|
+
const theme = (0, _shell_shock_plugin_theme_contexts_theme.useTheme)();
|
|
1035
|
+
return [
|
|
1036
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceDeclaration, {
|
|
1037
|
+
"export": true,
|
|
1038
|
+
name: "LinkOptions",
|
|
1039
|
+
doc: "Options for formatting a hyperlink in the console.",
|
|
1040
|
+
get children() {
|
|
1041
|
+
return [
|
|
1042
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceMember, {
|
|
1043
|
+
name: "external",
|
|
1044
|
+
optional: true,
|
|
1045
|
+
type: "boolean",
|
|
1046
|
+
doc: "Whether the link is external. If true, an external link icon will be displayed next to the link text (if supported by the terminal) and the link may be styled differently based on the current theme configuration."
|
|
1047
|
+
}),
|
|
1048
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1049
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceMember, {
|
|
1050
|
+
name: "text",
|
|
1051
|
+
optional: true,
|
|
1052
|
+
type: "string",
|
|
1053
|
+
doc: "The text to display for the link. If not provided, the URL will be used as the text."
|
|
1054
|
+
}),
|
|
1055
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1056
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceMember, {
|
|
1057
|
+
name: "useTextWhenUnsupported",
|
|
1058
|
+
optional: true,
|
|
1059
|
+
type: "boolean",
|
|
1060
|
+
doc: "Whether to use the text when the hyperlink is not supported. If true, the text will be displayed even if the terminal does not support hyperlinks."
|
|
1061
|
+
})
|
|
1062
|
+
];
|
|
1063
|
+
}
|
|
1064
|
+
}),
|
|
1065
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1066
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
1067
|
+
heading: "Render a hyperlink in the console.",
|
|
1068
|
+
get children() {
|
|
1069
|
+
return [
|
|
1070
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
1071
|
+
name: "url",
|
|
1072
|
+
children: `The URL to render as a hyperlink.`
|
|
1073
|
+
}),
|
|
1074
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
1075
|
+
name: "options",
|
|
1076
|
+
children: `Options for formatting the hyperlink.`
|
|
1077
|
+
}),
|
|
1078
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns, { children: `The formatted hyperlink string for display in the console.` })
|
|
1079
|
+
];
|
|
1080
|
+
}
|
|
1081
|
+
}),
|
|
1082
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
1083
|
+
"export": true,
|
|
1084
|
+
name: "link",
|
|
1085
|
+
parameters: [{
|
|
1086
|
+
name: "url",
|
|
1087
|
+
type: "string",
|
|
1088
|
+
optional: false
|
|
1089
|
+
}, {
|
|
1090
|
+
name: "options",
|
|
1091
|
+
type: "LinkOptions",
|
|
1092
|
+
default: "{}"
|
|
1093
|
+
}],
|
|
1094
|
+
get children() {
|
|
1095
|
+
return [
|
|
1096
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
|
|
1097
|
+
condition: _alloy_js_core.code`isHyperlinkSupported()`,
|
|
1098
|
+
get children() {
|
|
1099
|
+
return _alloy_js_core.code`return \`\\x1b]8;;\${url}\\u0007\${options.text ? options.text : url}\\x1b]8;;\\u0007\${options.external === true ? "${theme.icons.link.external}" : ""}\`;`;
|
|
1100
|
+
}
|
|
1101
|
+
}),
|
|
1102
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1103
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
|
|
1104
|
+
condition: _alloy_js_core.code`isColorSupported`,
|
|
1105
|
+
get children() {
|
|
1106
|
+
return _alloy_js_core.code`return \`\${underline(textColors.body.link(\`\${options.useTextWhenUnsupported && options.text ? options.text : url}\`))}\${options.external === true ? "${theme.icons.link.external}" : ""}\`;`;
|
|
1107
|
+
}
|
|
1108
|
+
}),
|
|
1109
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1110
|
+
(0, _alloy_js_core_jsx_runtime.memo)(() => _alloy_js_core.code`return \`\${options.useTextWhenUnsupported && options.text ? options.text : url}\${options.external === true ? "${theme.icons.link.external}" : ""}\`;`)
|
|
1111
|
+
];
|
|
1112
|
+
}
|
|
1113
|
+
})
|
|
1114
|
+
];
|
|
1115
|
+
}
|
|
1116
|
+
/**
|
|
1117
|
+
* A component to generate the `blockquote` function declaration
|
|
1118
|
+
*/
|
|
1119
|
+
function BlockquoteFunctionDeclaration() {
|
|
1120
|
+
const theme = (0, _shell_shock_plugin_theme_contexts_theme.useTheme)();
|
|
1121
|
+
return [
|
|
1122
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1123
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
1124
|
+
heading: `Format a string with blockquote styling for display in console.`,
|
|
1125
|
+
get children() {
|
|
1126
|
+
return [(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
1127
|
+
name: "text",
|
|
1128
|
+
children: `The text to format with blockquote styling.`
|
|
1129
|
+
}), (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns, { children: `The formatted string with blockquote styling.` })];
|
|
1130
|
+
}
|
|
1131
|
+
}),
|
|
1132
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
1133
|
+
"export": true,
|
|
1134
|
+
name: "blockquote",
|
|
1135
|
+
parameters: [{
|
|
1136
|
+
name: "text",
|
|
1137
|
+
type: "string | number | boolean | null",
|
|
1138
|
+
optional: true
|
|
1139
|
+
}],
|
|
1140
|
+
returnType: "string",
|
|
1141
|
+
get children() {
|
|
1142
|
+
return _alloy_js_core.code`if (text === undefined || text === null || text === "") {
|
|
266
1143
|
return "";
|
|
267
1144
|
}
|
|
268
1145
|
|
|
@@ -271,7 +1148,42 @@ console.log(result); // "\\\\x1b[36mHello\\\\x1b[39\\\\x1b[31mWorld\\\\x1b[0m\\\
|
|
|
271
1148
|
Math.max(getTerminalSize().columns, 20) - 6
|
|
272
1149
|
);
|
|
273
1150
|
|
|
274
|
-
return lines.map(line => \`\${borderColors.app.blockquote.primary(isUnicodeSupported() ? "${
|
|
1151
|
+
return lines.map(line => \`\${borderColors.app.blockquote.primary(isUnicodeSupported() ? "${theme.borderStyles.app.blockquote.primary.left}" : "|")} \${italic(line)} \`).join("\\n"); `;
|
|
1152
|
+
}
|
|
1153
|
+
})
|
|
1154
|
+
];
|
|
1155
|
+
}
|
|
1156
|
+
/**
|
|
1157
|
+
* A component to generate the `code` function declaration
|
|
1158
|
+
*/
|
|
1159
|
+
function CodeFunctionDeclaration() {
|
|
1160
|
+
const theme = (0, _shell_shock_plugin_theme_contexts_theme.useTheme)();
|
|
1161
|
+
return [
|
|
1162
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1163
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
1164
|
+
heading: `Format a source code string for display in console.`,
|
|
1165
|
+
get children() {
|
|
1166
|
+
return [(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
1167
|
+
name: "text",
|
|
1168
|
+
children: `The source code text to format with code styling.`
|
|
1169
|
+
}), (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns, { children: `The formatted string with code styling.` })];
|
|
1170
|
+
}
|
|
1171
|
+
}),
|
|
1172
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
1173
|
+
"export": true,
|
|
1174
|
+
name: "code",
|
|
1175
|
+
parameters: [{
|
|
1176
|
+
name: "text",
|
|
1177
|
+
type: "string | number | boolean | null",
|
|
1178
|
+
optional: true
|
|
1179
|
+
}, {
|
|
1180
|
+
name: "language",
|
|
1181
|
+
type: "string",
|
|
1182
|
+
optional: true
|
|
1183
|
+
}],
|
|
1184
|
+
returnType: "string",
|
|
1185
|
+
get children() {
|
|
1186
|
+
return _alloy_js_core.code`if (text === undefined || text === null || text === "") {
|
|
275
1187
|
return "";
|
|
276
1188
|
}
|
|
277
1189
|
|
|
@@ -280,12 +1192,185 @@ console.log(result); // "\\\\x1b[36mHello\\\\x1b[39\\\\x1b[31mWorld\\\\x1b[0m\\\
|
|
|
280
1192
|
Math.max(getTerminalSize().columns, 20)
|
|
281
1193
|
);
|
|
282
1194
|
|
|
283
|
-
return \` \${borderColors.app.divider.primary("${
|
|
1195
|
+
return \` \${borderColors.app.divider.primary("${theme.borderStyles.app.divider.primary.top}".repeat(4))}\${language ? \` \${borderColors.app.divider.primary(language)} \` : ""}\${borderColors.app.divider.primary("${theme.borderStyles.app.divider.primary.top}".repeat(getTerminalSize().columns - (language ? language.length + 2 : 0) - 5))} \\n\${lines.map((line, index) => \` \${" ".repeat(String(lines.length).length - String(index + 1).length)}\${textColors.body.tertiary(index + 1)} \${textColors.body.primary(line)}\`).join("\\n")}\`; `;
|
|
1196
|
+
}
|
|
1197
|
+
})
|
|
1198
|
+
];
|
|
1199
|
+
}
|
|
1200
|
+
/**
|
|
1201
|
+
* A component to generate the `inlineCode` function declaration
|
|
1202
|
+
*/
|
|
1203
|
+
function InlineCodeFunctionDeclaration() {
|
|
1204
|
+
return [
|
|
1205
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1206
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
1207
|
+
heading: `Format a string with inline code styling for display in console.`,
|
|
1208
|
+
get children() {
|
|
1209
|
+
return [(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
1210
|
+
name: "text",
|
|
1211
|
+
children: `The text to format with inline code styling.`
|
|
1212
|
+
}), (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns, { children: `The formatted string with inline code styling.` })];
|
|
1213
|
+
}
|
|
1214
|
+
}),
|
|
1215
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
1216
|
+
"export": true,
|
|
1217
|
+
name: "inlineCode",
|
|
1218
|
+
parameters: [{
|
|
1219
|
+
name: "text",
|
|
1220
|
+
type: "string | number | boolean | null",
|
|
1221
|
+
optional: true
|
|
1222
|
+
}],
|
|
1223
|
+
returnType: "string",
|
|
1224
|
+
children: _alloy_js_core.code`if (text === undefined || text === null || text === "") {
|
|
284
1225
|
return "";
|
|
285
1226
|
}
|
|
286
1227
|
|
|
287
|
-
return inverse(\`\${text}\`); `
|
|
288
|
-
|
|
1228
|
+
return inverse(\`\${text}\`); `
|
|
1229
|
+
})
|
|
1230
|
+
];
|
|
1231
|
+
}
|
|
1232
|
+
/**
|
|
1233
|
+
* A component to generate the `spinner` function in the `shell-shock:console` builtin module.
|
|
1234
|
+
*/
|
|
1235
|
+
function SpinnerFunctionDeclaration() {
|
|
1236
|
+
const theme = (0, _shell_shock_plugin_theme_contexts_theme.useTheme)();
|
|
1237
|
+
return [
|
|
1238
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.TypeDeclaration, {
|
|
1239
|
+
name: "WriteStream",
|
|
1240
|
+
children: `NodeJS.WriteStream;`
|
|
1241
|
+
}),
|
|
1242
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1243
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
|
|
1244
|
+
"const": true,
|
|
1245
|
+
name: "activeHooksPerStream",
|
|
1246
|
+
initializer: "new Set();"
|
|
1247
|
+
}),
|
|
1248
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1249
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceDeclaration, {
|
|
1250
|
+
"export": true,
|
|
1251
|
+
name: "SpinnerOptions",
|
|
1252
|
+
doc: "Options for configuring the spinner.",
|
|
1253
|
+
get children() {
|
|
1254
|
+
return [
|
|
1255
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceMember, {
|
|
1256
|
+
name: "message",
|
|
1257
|
+
optional: true,
|
|
1258
|
+
type: "string",
|
|
1259
|
+
doc: "The message text to display next to the spinner. Defaults to an empty string."
|
|
1260
|
+
}),
|
|
1261
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1262
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceMember, {
|
|
1263
|
+
name: "stream",
|
|
1264
|
+
optional: true,
|
|
1265
|
+
type: "WriteStream",
|
|
1266
|
+
doc: "The output stream to write the spinner to. Defaults to process.stderr."
|
|
1267
|
+
}),
|
|
1268
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1269
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceMember, {
|
|
1270
|
+
name: "spinner",
|
|
1271
|
+
optional: true,
|
|
1272
|
+
type: "ThemeSpinnerResolvedConfig | SpinnerPreset",
|
|
1273
|
+
doc: "The spinner animation to use. Should be an object with a 'frames' property (an array of strings representing each frame of the animation) and an 'interval' property (the time in milliseconds between each frame). If not specified, a default spinner animation will be used."
|
|
1274
|
+
})
|
|
1275
|
+
];
|
|
1276
|
+
}
|
|
1277
|
+
}),
|
|
1278
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1279
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.ClassDeclaration, {
|
|
1280
|
+
name: "Spinner",
|
|
1281
|
+
get children() {
|
|
1282
|
+
return [
|
|
1283
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.ClassField, {
|
|
1284
|
+
name: "frames",
|
|
1285
|
+
isPrivateMember: true,
|
|
1286
|
+
type: "string[]"
|
|
1287
|
+
}),
|
|
1288
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1289
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.ClassField, {
|
|
1290
|
+
name: "interval",
|
|
1291
|
+
isPrivateMember: true,
|
|
1292
|
+
type: "number"
|
|
1293
|
+
}),
|
|
1294
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1295
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.ClassField, {
|
|
1296
|
+
name: "currentFrame",
|
|
1297
|
+
isPrivateMember: true,
|
|
1298
|
+
type: "number",
|
|
1299
|
+
children: _alloy_js_core.code`-1`
|
|
1300
|
+
}),
|
|
1301
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1302
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.ClassField, {
|
|
1303
|
+
name: "timer",
|
|
1304
|
+
isPrivateMember: true,
|
|
1305
|
+
optional: true,
|
|
1306
|
+
type: "NodeJS.Timeout"
|
|
1307
|
+
}),
|
|
1308
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1309
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.ClassField, {
|
|
1310
|
+
name: "message",
|
|
1311
|
+
isPrivateMember: true,
|
|
1312
|
+
type: "string",
|
|
1313
|
+
children: _alloy_js_core.code`""`
|
|
1314
|
+
}),
|
|
1315
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1316
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.ClassField, {
|
|
1317
|
+
name: "stream",
|
|
1318
|
+
isPrivateMember: true,
|
|
1319
|
+
type: "WriteStream",
|
|
1320
|
+
children: _alloy_js_core.code`process.stderr`
|
|
1321
|
+
}),
|
|
1322
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1323
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.ClassField, {
|
|
1324
|
+
name: "lines",
|
|
1325
|
+
isPrivateMember: true,
|
|
1326
|
+
type: "number",
|
|
1327
|
+
children: _alloy_js_core.code`0`
|
|
1328
|
+
}),
|
|
1329
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1330
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.ClassField, {
|
|
1331
|
+
name: "exitHandlerBound",
|
|
1332
|
+
isPrivateMember: true,
|
|
1333
|
+
type: "(signal: any) => void",
|
|
1334
|
+
children: _alloy_js_core.code`() => {}`
|
|
1335
|
+
}),
|
|
1336
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1337
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.ClassField, {
|
|
1338
|
+
name: "lastSpinnerFrameTime",
|
|
1339
|
+
isPrivateMember: true,
|
|
1340
|
+
type: "number",
|
|
1341
|
+
children: _alloy_js_core.code`0`
|
|
1342
|
+
}),
|
|
1343
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1344
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.ClassField, {
|
|
1345
|
+
name: "isSpinning",
|
|
1346
|
+
isPrivateMember: true,
|
|
1347
|
+
type: "boolean",
|
|
1348
|
+
children: _alloy_js_core.code`false`
|
|
1349
|
+
}),
|
|
1350
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1351
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.ClassField, {
|
|
1352
|
+
name: "hookedStreams",
|
|
1353
|
+
isPrivateMember: true,
|
|
1354
|
+
type: "Map<WriteStream, { write?: WriteStream[\"write\"]; originalWrite: WriteStream[\"write\"]; hookedWrite: WriteStream[\"write\"] }>",
|
|
1355
|
+
children: _alloy_js_core.code`new Map()`
|
|
1356
|
+
}),
|
|
1357
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1358
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.ClassField, {
|
|
1359
|
+
name: "isInternalWrite",
|
|
1360
|
+
isPrivateMember: true,
|
|
1361
|
+
type: "boolean",
|
|
1362
|
+
children: _alloy_js_core.code`false`
|
|
1363
|
+
}),
|
|
1364
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1365
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.ClassField, {
|
|
1366
|
+
name: "isDeferringRender",
|
|
1367
|
+
isPrivateMember: true,
|
|
1368
|
+
type: "boolean",
|
|
1369
|
+
children: _alloy_js_core.code`false`
|
|
1370
|
+
}),
|
|
1371
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1372
|
+
(0, _alloy_js_core_jsx_runtime.memo)(() => _alloy_js_core.code`constructor(options: SpinnerOptions = {}) {
|
|
1373
|
+
const spinner = (typeof options.spinner === "string" ? resolveSpinner(options.spinner as SpinnerPreset) : options.spinner) ?? ${JSON.stringify(theme.spinner)};
|
|
289
1374
|
this.#frames = spinner.frames;
|
|
290
1375
|
this.#interval = spinner.interval;
|
|
291
1376
|
|
|
@@ -489,7 +1574,49 @@ console.log(result); // "\\\\x1b[36mHello\\\\x1b[39\\\\x1b[31mWorld\\\\x1b[0m\\\
|
|
|
489
1574
|
}
|
|
490
1575
|
|
|
491
1576
|
process.exit(signal === "SIGINT" ? 130 : (signal === "SIGTERM" ? 143 : 1));
|
|
492
|
-
} `),
|
|
1577
|
+
} `),
|
|
1578
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.ClassPropertyGet, {
|
|
1579
|
+
"public": true,
|
|
1580
|
+
name: "isSpinning",
|
|
1581
|
+
type: "boolean",
|
|
1582
|
+
doc: "Whether the spinner is currently active and spinning.",
|
|
1583
|
+
children: _alloy_js_core.code`return this.#isSpinning;`
|
|
1584
|
+
}),
|
|
1585
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1586
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.ClassPropertySet, {
|
|
1587
|
+
"public": true,
|
|
1588
|
+
name: "message",
|
|
1589
|
+
type: "string",
|
|
1590
|
+
doc: "Set the message displayed by the spinner.",
|
|
1591
|
+
children: _alloy_js_core.code`this.#message = value;`
|
|
1592
|
+
}),
|
|
1593
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1594
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.ClassPropertyGet, {
|
|
1595
|
+
"public": true,
|
|
1596
|
+
name: "message",
|
|
1597
|
+
type: "string",
|
|
1598
|
+
doc: "Get the message displayed by the spinner.",
|
|
1599
|
+
children: _alloy_js_core.code`return this.#message;`
|
|
1600
|
+
}),
|
|
1601
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1602
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.ClassMethod, {
|
|
1603
|
+
name: "start",
|
|
1604
|
+
doc: "Start the spinner animation.",
|
|
1605
|
+
parameters: [{
|
|
1606
|
+
name: "message",
|
|
1607
|
+
type: "string"
|
|
1608
|
+
}],
|
|
1609
|
+
get children() {
|
|
1610
|
+
return [
|
|
1611
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
|
|
1612
|
+
condition: _alloy_js_core.code`message !== undefined`,
|
|
1613
|
+
children: _alloy_js_core.code`this.#message = message;`
|
|
1614
|
+
}),
|
|
1615
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
|
|
1616
|
+
condition: _alloy_js_core.code`this.isSpinning`,
|
|
1617
|
+
children: _alloy_js_core.code`return this;`
|
|
1618
|
+
}),
|
|
1619
|
+
_alloy_js_core.code`this.#isSpinning = true;
|
|
493
1620
|
this.#hideCursor();
|
|
494
1621
|
this.#installHook();
|
|
495
1622
|
this.#render();
|
|
@@ -502,7 +1629,20 @@ console.log(result); // "\\\\x1b[36mHello\\\\x1b[39\\\\x1b[31mWorld\\\\x1b[0m\\\
|
|
|
502
1629
|
}
|
|
503
1630
|
|
|
504
1631
|
return this;
|
|
505
|
-
`
|
|
1632
|
+
`
|
|
1633
|
+
];
|
|
1634
|
+
}
|
|
1635
|
+
}),
|
|
1636
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1637
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.ClassMethod, {
|
|
1638
|
+
name: "stop",
|
|
1639
|
+
doc: "Stop the spinner animation.",
|
|
1640
|
+
parameters: [{
|
|
1641
|
+
name: "finalMessage",
|
|
1642
|
+
optional: true,
|
|
1643
|
+
type: "string"
|
|
1644
|
+
}],
|
|
1645
|
+
children: _alloy_js_core.code`if (!this.isSpinning) {
|
|
506
1646
|
return this;
|
|
507
1647
|
}
|
|
508
1648
|
|
|
@@ -526,7 +1666,13 @@ console.log(result); // "\\\\x1b[36mHello\\\\x1b[39\\\\x1b[31mWorld\\\\x1b[0m\\\
|
|
|
526
1666
|
|
|
527
1667
|
return this;
|
|
528
1668
|
|
|
529
|
-
`
|
|
1669
|
+
`
|
|
1670
|
+
}),
|
|
1671
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1672
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.ClassMethod, {
|
|
1673
|
+
name: "clear",
|
|
1674
|
+
doc: "Clear the spinner animation.",
|
|
1675
|
+
children: _alloy_js_core.code`if (!isInteractive) {
|
|
530
1676
|
return this;
|
|
531
1677
|
}
|
|
532
1678
|
|
|
@@ -547,20 +1693,474 @@ console.log(result); // "\\\\x1b[36mHello\\\\x1b[39\\\\x1b[31mWorld\\\\x1b[0m\\\
|
|
|
547
1693
|
});
|
|
548
1694
|
|
|
549
1695
|
this.#lines = 0;
|
|
550
|
-
return this; `
|
|
1696
|
+
return this; `
|
|
1697
|
+
}),
|
|
1698
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1699
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.ClassMethod, {
|
|
1700
|
+
name: "success",
|
|
1701
|
+
doc: "Mark the spinner as successful.",
|
|
1702
|
+
parameters: [{
|
|
1703
|
+
name: "message",
|
|
1704
|
+
type: "string"
|
|
1705
|
+
}],
|
|
1706
|
+
get children() {
|
|
1707
|
+
return _alloy_js_core.code`return this.#stopWithIcon(textColors.spinner.icon.success("${theme.icons.spinner.success}"), textColors.spinner.message.success(message)); `;
|
|
1708
|
+
}
|
|
1709
|
+
}),
|
|
1710
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1711
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.ClassMethod, {
|
|
1712
|
+
name: "error",
|
|
1713
|
+
doc: "Mark the spinner as failed.",
|
|
1714
|
+
parameters: [{
|
|
1715
|
+
name: "message",
|
|
1716
|
+
type: "string"
|
|
1717
|
+
}],
|
|
1718
|
+
get children() {
|
|
1719
|
+
return _alloy_js_core.code`return this.#stopWithIcon(textColors.spinner.icon.error("${theme.icons.spinner.error}"), textColors.spinner.message.error(message)); `;
|
|
1720
|
+
}
|
|
1721
|
+
}),
|
|
1722
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1723
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.ClassMethod, {
|
|
1724
|
+
name: "warning",
|
|
1725
|
+
doc: "Mark the spinner as warning.",
|
|
1726
|
+
parameters: [{
|
|
1727
|
+
name: "message",
|
|
1728
|
+
type: "string"
|
|
1729
|
+
}],
|
|
1730
|
+
get children() {
|
|
1731
|
+
return _alloy_js_core.code`return this.#stopWithIcon(textColors.spinner.icon.warning("${theme.icons.spinner.warning}"), textColors.spinner.message.warning(message)); `;
|
|
1732
|
+
}
|
|
1733
|
+
}),
|
|
1734
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1735
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.ClassMethod, {
|
|
1736
|
+
name: "info",
|
|
1737
|
+
doc: "Mark the spinner as informational.",
|
|
1738
|
+
parameters: [{
|
|
1739
|
+
name: "message",
|
|
1740
|
+
type: "string"
|
|
1741
|
+
}],
|
|
1742
|
+
get children() {
|
|
1743
|
+
return _alloy_js_core.code`return this.#stopWithIcon(textColors.spinner.icon.info("${theme.icons.spinner.info}"), textColors.spinner.message.info(message)); `;
|
|
1744
|
+
}
|
|
1745
|
+
}),
|
|
1746
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1747
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.ClassMethod, {
|
|
1748
|
+
name: "help",
|
|
1749
|
+
doc: "Mark the spinner as help.",
|
|
1750
|
+
parameters: [{
|
|
1751
|
+
name: "message",
|
|
1752
|
+
type: "string"
|
|
1753
|
+
}],
|
|
1754
|
+
get children() {
|
|
1755
|
+
return _alloy_js_core.code`return this.#stopWithIcon(textColors.spinner.icon.help("${theme.icons.spinner.help}"), textColors.spinner.message.help(message)); `;
|
|
1756
|
+
}
|
|
1757
|
+
}),
|
|
1758
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {})
|
|
1759
|
+
];
|
|
1760
|
+
}
|
|
1761
|
+
}),
|
|
1762
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1763
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
1764
|
+
heading: "Render a spinner in the console.",
|
|
1765
|
+
get children() {
|
|
1766
|
+
return [(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
1767
|
+
name: "options",
|
|
1768
|
+
children: `Options for configuring the spinner, including the message to display, the output stream to write to, and the spinner animation to use.`
|
|
1769
|
+
}), (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns, { children: `An instance of the Spinner class, which can be used to control the spinner animation (e.g., start, stop, mark as success/error, etc.).` })];
|
|
1770
|
+
}
|
|
1771
|
+
}),
|
|
1772
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
1773
|
+
"export": true,
|
|
1774
|
+
name: "createSpinner",
|
|
1775
|
+
parameters: [{
|
|
1776
|
+
name: "options",
|
|
1777
|
+
type: "SpinnerOptions",
|
|
1778
|
+
optional: true
|
|
1779
|
+
}],
|
|
1780
|
+
children: _alloy_js_core.code`return new Spinner(options);`
|
|
1781
|
+
})
|
|
1782
|
+
];
|
|
1783
|
+
}
|
|
1784
|
+
function extractBorderOptionsObject(direction, theme) {
|
|
1785
|
+
return `borderOptions.${direction} === "primary" ? borderColors.app.table.primary("${theme.borderStyles.app.table.primary[direction]}") : borderOptions.${direction} === "secondary" ? borderColors.app.table.secondary("${theme.borderStyles.app.table.secondary[direction]}") : borderOptions.${direction} === "tertiary" ? borderColors.app.table.tertiary("${theme.borderStyles.app.table.tertiary[direction]}") : !borderOptions.${direction} || borderOptions.${direction} === "none" ? "" : borderOptions.${direction}`;
|
|
1786
|
+
}
|
|
1787
|
+
function extractBorderOptionsString(direction, theme) {
|
|
1788
|
+
return `borderOptions === "primary" ? borderColors.app.table.primary("${theme.borderStyles.app.table.primary[direction]}") : borderOptions === "secondary" ? borderColors.app.table.secondary("${theme.borderStyles.app.table.secondary[direction]}") : borderOptions === "tertiary" ? borderColors.app.table.tertiary("${theme.borderStyles.app.table.tertiary[direction]}") : !borderOptions || borderOptions === "none" ? "" : borderOptions`;
|
|
1789
|
+
}
|
|
1790
|
+
/**
|
|
1791
|
+
* Props for the TableFunctionDeclaration component.
|
|
1792
|
+
*/
|
|
1793
|
+
/**
|
|
1794
|
+
* A component to generate the table functions in the `shell-shock:console` builtin module.
|
|
1795
|
+
*/
|
|
1796
|
+
function TableFunctionDeclaration(props) {
|
|
1797
|
+
const theme = (0, _shell_shock_plugin_theme_contexts_theme.useTheme)();
|
|
1798
|
+
return [
|
|
1799
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.TypeDeclaration, {
|
|
1800
|
+
"export": true,
|
|
1801
|
+
name: "SizeToken",
|
|
1802
|
+
doc: "A type representing the width size of an item in the console.",
|
|
1803
|
+
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%"`
|
|
1804
|
+
}),
|
|
1805
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1806
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
1807
|
+
heading: "Determine if a value is a valid size token.",
|
|
1808
|
+
get children() {
|
|
1809
|
+
return [
|
|
1810
|
+
(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%").` }),
|
|
1811
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
1812
|
+
name: "value",
|
|
1813
|
+
children: `The value to check for being a valid size token.`
|
|
1814
|
+
}),
|
|
1815
|
+
(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.` })
|
|
1816
|
+
];
|
|
1817
|
+
}
|
|
1818
|
+
}),
|
|
1819
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
1820
|
+
"export": true,
|
|
1821
|
+
doc: "Determines if the provided value is a valid size token.",
|
|
1822
|
+
name: "isSizeToken",
|
|
1823
|
+
parameters: [{
|
|
1824
|
+
name: "value",
|
|
1825
|
+
type: "any"
|
|
1826
|
+
}],
|
|
1827
|
+
returnType: "value is SizeToken",
|
|
1828
|
+
get children() {
|
|
1829
|
+
return [(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
|
|
1830
|
+
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)`,
|
|
1831
|
+
children: _alloy_js_core.code`return true; `
|
|
1832
|
+
}), _alloy_js_core.code`return false; `];
|
|
1833
|
+
}
|
|
1834
|
+
}),
|
|
1835
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1836
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
1837
|
+
heading: "Calculate the width in characters based on the provided width size.",
|
|
1838
|
+
get children() {
|
|
1839
|
+
return [
|
|
1840
|
+
(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 (getTerminalSize().columns).` }),
|
|
1841
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
1842
|
+
name: "size",
|
|
1843
|
+
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%").`
|
|
1844
|
+
}),
|
|
1845
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns, { children: `The calculated width in characters.` })
|
|
1846
|
+
];
|
|
1847
|
+
}
|
|
1848
|
+
}),
|
|
1849
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
1850
|
+
"export": true,
|
|
1851
|
+
name: "calculateWidth",
|
|
1852
|
+
parameters: [{
|
|
1853
|
+
name: "size",
|
|
1854
|
+
type: "SizeToken",
|
|
1855
|
+
optional: false
|
|
1856
|
+
}],
|
|
1857
|
+
returnType: "number",
|
|
1858
|
+
get children() {
|
|
1859
|
+
return [
|
|
1860
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
|
|
1861
|
+
condition: _alloy_js_core.code`["full", "100%", "1/1"]. includes(size)`,
|
|
1862
|
+
children: _alloy_js_core.code`return getTerminalSize().columns;`
|
|
1863
|
+
}),
|
|
1864
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.ElseIfClause, {
|
|
1865
|
+
condition: _alloy_js_core.code`["1/2", "50%"].includes(size)`,
|
|
1866
|
+
children: _alloy_js_core.code`return Math.round(getTerminalSize().columns / 2);`
|
|
1867
|
+
}),
|
|
1868
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.ElseIfClause, {
|
|
1869
|
+
condition: _alloy_js_core.code`["1/3", "33.33%"].includes(size)`,
|
|
1870
|
+
children: _alloy_js_core.code`return Math.round(getTerminalSize().columns / 3);`
|
|
1871
|
+
}),
|
|
1872
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.ElseIfClause, {
|
|
1873
|
+
condition: _alloy_js_core.code`["1/4", "25%"].includes(size)`,
|
|
1874
|
+
children: _alloy_js_core.code`return Math.round(getTerminalSize().columns / 4);`
|
|
1875
|
+
}),
|
|
1876
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.ElseIfClause, {
|
|
1877
|
+
condition: _alloy_js_core.code`["1/5", "20%"].includes(size)`,
|
|
1878
|
+
children: _alloy_js_core.code`return Math.round(getTerminalSize().columns / 5);`
|
|
1879
|
+
}),
|
|
1880
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.ElseIfClause, {
|
|
1881
|
+
condition: _alloy_js_core.code`["1/6", "10%"].includes(size)`,
|
|
1882
|
+
children: _alloy_js_core.code`return Math.round(getTerminalSize().columns / 6);`
|
|
1883
|
+
}),
|
|
1884
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.ElseIfClause, {
|
|
1885
|
+
condition: _alloy_js_core.code`["1/12", "5%"].includes(size)`,
|
|
1886
|
+
children: _alloy_js_core.code`return Math.round(getTerminalSize().columns / 12);`
|
|
1887
|
+
}),
|
|
1888
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.ElseIfClause, {
|
|
1889
|
+
condition: _alloy_js_core.code`["1/24", "2.5%"].includes(size)`,
|
|
1890
|
+
children: _alloy_js_core.code`return Math.round(getTerminalSize().columns / 24);`
|
|
1891
|
+
}),
|
|
1892
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.ElseClause, { children: _alloy_js_core.code`
|
|
551
1893
|
const match = size.match(/(\\d+(\\.\\d+)?)%/);
|
|
552
1894
|
if (match) {
|
|
553
1895
|
return Math.round((getTerminalSize().columns * parseFloat(match[1])) / 100);
|
|
554
1896
|
}
|
|
555
1897
|
|
|
556
1898
|
throw new Error(\`Invalid width size: \${size}\`);
|
|
557
|
-
`
|
|
1899
|
+
` }),
|
|
1900
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {})
|
|
1901
|
+
];
|
|
1902
|
+
}
|
|
1903
|
+
}),
|
|
1904
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.TypeDeclaration, {
|
|
1905
|
+
"export": true,
|
|
1906
|
+
name: "BorderOption",
|
|
1907
|
+
doc: "The border options applied to table cells.",
|
|
1908
|
+
children: _alloy_js_core.code`"primary" | "secondary" | "tertiary" | "none" | string; `
|
|
1909
|
+
}),
|
|
1910
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1911
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceDeclaration, {
|
|
1912
|
+
"export": true,
|
|
1913
|
+
name: "TableOutputOptions",
|
|
1914
|
+
doc: "Options to customize the output of the {@link table} function.",
|
|
1915
|
+
get children() {
|
|
1916
|
+
return [
|
|
1917
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
1918
|
+
heading: "Border variant for the table cell.",
|
|
1919
|
+
get children() {
|
|
1920
|
+
return [
|
|
1921
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocRemarks, { children: `The border variant to use for the table cell. This determines the color and style of the border around the cell.` }),
|
|
1922
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1923
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocDefaultValue, {
|
|
1924
|
+
type: "any",
|
|
1925
|
+
defaultValue: "primary"
|
|
1926
|
+
})
|
|
1927
|
+
];
|
|
1928
|
+
}
|
|
1929
|
+
}),
|
|
1930
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceMember, {
|
|
1931
|
+
name: "border",
|
|
1932
|
+
optional: true,
|
|
1933
|
+
type: "BorderOption | { top?: BorderOption; right?: BorderOption; bottom?: BorderOption; left?: BorderOption; topLeft?: BorderOption; topRight?: BorderOption; bottomLeft?: BorderOption; bottomRight?: BorderOption; }"
|
|
1934
|
+
}),
|
|
1935
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1936
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
1937
|
+
heading: "Padding for the table cell.",
|
|
1938
|
+
get children() {
|
|
1939
|
+
return [
|
|
1940
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocRemarks, { children: `The amount of padding (in spaces) to apply to the table cell. This value is applied to both the left and right sides of the cell. If not specified, the default table padding defined in the current theme configuration will be used.` }),
|
|
1941
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1942
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocDefaultValue, {
|
|
1943
|
+
type: "any",
|
|
1944
|
+
get defaultValue() {
|
|
1945
|
+
return `\`${theme.padding.table}\``;
|
|
1946
|
+
}
|
|
1947
|
+
})
|
|
1948
|
+
];
|
|
1949
|
+
}
|
|
1950
|
+
}),
|
|
1951
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceMember, {
|
|
1952
|
+
name: "padding",
|
|
1953
|
+
optional: true,
|
|
1954
|
+
type: "number"
|
|
1955
|
+
}),
|
|
1956
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1957
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
1958
|
+
heading: "Alignment for the table cell.",
|
|
1959
|
+
get children() {
|
|
1960
|
+
return [
|
|
1961
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocRemarks, { children: `The alignment for the table cell. This determines how the text within the cell is aligned. If not specified, the default alignment is "left".` }),
|
|
1962
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1963
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocDefaultValue, {
|
|
1964
|
+
type: "any",
|
|
1965
|
+
defaultValue: "left"
|
|
1966
|
+
})
|
|
1967
|
+
];
|
|
1968
|
+
}
|
|
1969
|
+
}),
|
|
1970
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceMember, {
|
|
1971
|
+
name: "align",
|
|
1972
|
+
optional: true,
|
|
1973
|
+
type: "\"left\" | \"right\" | \"center\""
|
|
1974
|
+
}),
|
|
1975
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {})
|
|
1976
|
+
];
|
|
1977
|
+
}
|
|
1978
|
+
}),
|
|
1979
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1980
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceDeclaration, {
|
|
1981
|
+
"export": true,
|
|
1982
|
+
name: "TableCellOptions",
|
|
1983
|
+
"extends": "TableOutputOptions",
|
|
1984
|
+
doc: "Options for a specific table cell provided to the {@link table} function.",
|
|
1985
|
+
get children() {
|
|
1986
|
+
return [
|
|
1987
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceMember, {
|
|
1988
|
+
name: "value",
|
|
1989
|
+
optional: true,
|
|
1990
|
+
type: "string",
|
|
1991
|
+
doc: "The actual string value of the table cell."
|
|
1992
|
+
}),
|
|
1993
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1994
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
1995
|
+
heading: "Width of the table cell.",
|
|
1996
|
+
get children() {
|
|
1997
|
+
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.` });
|
|
1998
|
+
}
|
|
1999
|
+
}),
|
|
2000
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceMember, {
|
|
2001
|
+
name: "maxWidth",
|
|
2002
|
+
type: "number | SizeToken | undefined"
|
|
2003
|
+
}),
|
|
2004
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {})
|
|
2005
|
+
];
|
|
2006
|
+
}
|
|
2007
|
+
}),
|
|
2008
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2009
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceDeclaration, {
|
|
2010
|
+
"export": true,
|
|
2011
|
+
name: "TableRowOptions",
|
|
2012
|
+
"extends": "TableOutputOptions",
|
|
2013
|
+
doc: "Options for a specific table row provided to the {@link table} function.",
|
|
2014
|
+
get children() {
|
|
2015
|
+
return [(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceMember, {
|
|
2016
|
+
name: "values",
|
|
2017
|
+
optional: true,
|
|
2018
|
+
type: "(string | TableCellOptions)[]",
|
|
2019
|
+
doc: "The actual string values of the table row's cells."
|
|
2020
|
+
}), (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {})];
|
|
2021
|
+
}
|
|
2022
|
+
}),
|
|
2023
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2024
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceDeclaration, {
|
|
2025
|
+
"export": true,
|
|
2026
|
+
name: "TableOptions",
|
|
2027
|
+
"extends": "TableOutputOptions",
|
|
2028
|
+
doc: "Options for a specific table cell provided to the {@link table} function.",
|
|
2029
|
+
get children() {
|
|
2030
|
+
return [(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceMember, {
|
|
2031
|
+
name: "values",
|
|
2032
|
+
optional: true,
|
|
2033
|
+
type: "(string | TableCellOptions)[][]",
|
|
2034
|
+
doc: "The actual string values of the table's rows' cells."
|
|
2035
|
+
}), (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {})];
|
|
2036
|
+
}
|
|
2037
|
+
}),
|
|
2038
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2039
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceDeclaration, {
|
|
2040
|
+
name: "Dimensions",
|
|
2041
|
+
doc: "The height and width for a specific table/cell used internally in the {@link table} function.",
|
|
2042
|
+
get children() {
|
|
2043
|
+
return [
|
|
2044
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceMember, {
|
|
2045
|
+
name: "height",
|
|
2046
|
+
type: "number",
|
|
2047
|
+
doc: "The height of the row/cell (where 1 is a single line in the terminal)."
|
|
2048
|
+
}),
|
|
2049
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
2050
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceMember, {
|
|
2051
|
+
name: "width",
|
|
2052
|
+
type: "number",
|
|
2053
|
+
doc: "The width of the row/cell (where 1 is a single character in the terminal)."
|
|
2054
|
+
}),
|
|
2055
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {})
|
|
2056
|
+
];
|
|
2057
|
+
}
|
|
2058
|
+
}),
|
|
2059
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2060
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceDeclaration, {
|
|
2061
|
+
name: "TableCellBorder",
|
|
2062
|
+
doc: "The resolved complete border styles for a table cell.",
|
|
2063
|
+
get children() {
|
|
2064
|
+
return [
|
|
2065
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceMember, {
|
|
2066
|
+
name: "top",
|
|
2067
|
+
type: "string",
|
|
2068
|
+
doc: "The top border style of the table cell."
|
|
2069
|
+
}),
|
|
2070
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
2071
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceMember, {
|
|
2072
|
+
name: "bottom",
|
|
2073
|
+
type: "string",
|
|
2074
|
+
doc: "The bottom border style of the table cell."
|
|
2075
|
+
}),
|
|
2076
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
2077
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceMember, {
|
|
2078
|
+
name: "right",
|
|
2079
|
+
type: "string",
|
|
2080
|
+
doc: "The right border style of the table cell."
|
|
2081
|
+
}),
|
|
2082
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
2083
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceMember, {
|
|
2084
|
+
name: "left",
|
|
2085
|
+
type: "string",
|
|
2086
|
+
doc: "The left border style of the table cell."
|
|
2087
|
+
}),
|
|
2088
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
2089
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceMember, {
|
|
2090
|
+
name: "topLeft",
|
|
2091
|
+
type: "string",
|
|
2092
|
+
doc: "The top-left border style of the table cell."
|
|
2093
|
+
}),
|
|
2094
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
2095
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceMember, {
|
|
2096
|
+
name: "topRight",
|
|
2097
|
+
type: "string",
|
|
2098
|
+
doc: "The top-right border style of the table cell."
|
|
2099
|
+
}),
|
|
2100
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
2101
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceMember, {
|
|
2102
|
+
name: "bottomLeft",
|
|
2103
|
+
type: "string",
|
|
2104
|
+
doc: "The bottom-left border style of the table cell."
|
|
2105
|
+
}),
|
|
2106
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
2107
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.InterfaceMember, {
|
|
2108
|
+
name: "bottomRight",
|
|
2109
|
+
type: "string",
|
|
2110
|
+
doc: "The bottom-right border style of the table cell."
|
|
2111
|
+
}),
|
|
2112
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {})
|
|
2113
|
+
];
|
|
2114
|
+
}
|
|
2115
|
+
}),
|
|
2116
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2117
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.TypeDeclaration, {
|
|
2118
|
+
name: "TableCell",
|
|
2119
|
+
doc: "The internal state of a formatted table cell in the {@link table} function.",
|
|
2120
|
+
children: _alloy_js_core.code`Required<Omit<TableCellOptions, "maxWidth" | "border">> & Dimensions & {
|
|
558
2121
|
border: TableCellBorder;
|
|
559
2122
|
maxWidth?: number;
|
|
560
2123
|
};
|
|
561
|
-
`
|
|
2124
|
+
`
|
|
2125
|
+
}),
|
|
2126
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2127
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
2128
|
+
heading: "Write a table to the console.",
|
|
2129
|
+
get children() {
|
|
2130
|
+
return [
|
|
2131
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocRemarks, { children: `This function writes a table to the console, applying the appropriate padding as defined in the current theme configuration and wrapping as needed.` }),
|
|
2132
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
2133
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
2134
|
+
name: "options",
|
|
2135
|
+
children: `Options to customize the table output.`
|
|
2136
|
+
})
|
|
2137
|
+
];
|
|
2138
|
+
}
|
|
2139
|
+
}),
|
|
2140
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, (0, _alloy_js_core_jsx_runtime.mergeProps)({ "export": true }, props, {
|
|
2141
|
+
name: "table",
|
|
2142
|
+
parameters: [{
|
|
2143
|
+
name: "options",
|
|
2144
|
+
type: "TableOptions | TableRowOptions[] | TableCellOptions[][] | string[] | string[][]",
|
|
2145
|
+
optional: false
|
|
2146
|
+
}],
|
|
2147
|
+
get children() {
|
|
2148
|
+
return [
|
|
2149
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
|
|
2150
|
+
condition: _alloy_js_core.code`!options ||
|
|
562
2151
|
(!Array.isArray(options) && (typeof options !== "object" || !options.values || !Array.isArray(options.values) || options.values.length === 0)) ||
|
|
563
|
-
(Array.isArray(options) && !options.every(item => typeof item === "object" || typeof item === "string" || Array.isArray(item))) `,
|
|
2152
|
+
(Array.isArray(options) && !options.every(item => typeof item === "object" || typeof item === "string" || Array.isArray(item))) `,
|
|
2153
|
+
children: _alloy_js_core.code`return;`
|
|
2154
|
+
}),
|
|
2155
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2156
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
|
|
2157
|
+
"let": true,
|
|
2158
|
+
name: "cells",
|
|
2159
|
+
type: `TableCell[][]`,
|
|
2160
|
+
initializer: _alloy_js_core.code`[];`
|
|
2161
|
+
}),
|
|
2162
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
2163
|
+
(0, _alloy_js_core_jsx_runtime.memo)(() => _alloy_js_core.code`
|
|
564
2164
|
const extractTableCell = (cell: string | TableCellOptions, columnIndex: number, rowLength: number, opts?: TableOutputOptions): TableCell => {
|
|
565
2165
|
if (typeof cell === "string") {
|
|
566
2166
|
const borderOptions = opts?.border || "primary";
|
|
@@ -568,27 +2168,27 @@ console.log(result); // "\\\\x1b[36mHello\\\\x1b[39\\\\x1b[31mWorld\\\\x1b[0m\\\
|
|
|
568
2168
|
let border = {} as TableCellBorder;
|
|
569
2169
|
if (typeof borderOptions === "object") {
|
|
570
2170
|
border = {
|
|
571
|
-
top: ${
|
|
572
|
-
bottom: ${
|
|
573
|
-
left: ${
|
|
574
|
-
right: ${
|
|
575
|
-
topLeft: ${
|
|
576
|
-
topRight: ${
|
|
577
|
-
bottomLeft: ${
|
|
578
|
-
bottomRight: ${
|
|
2171
|
+
top: ${extractBorderOptionsObject("top", theme)},
|
|
2172
|
+
bottom: ${extractBorderOptionsObject("bottom", theme)},
|
|
2173
|
+
left: ${extractBorderOptionsObject("left", theme)},
|
|
2174
|
+
right: ${extractBorderOptionsObject("right", theme)},
|
|
2175
|
+
topLeft: ${extractBorderOptionsObject("topLeft", theme)},
|
|
2176
|
+
topRight: ${extractBorderOptionsObject("topRight", theme)},
|
|
2177
|
+
bottomLeft: ${extractBorderOptionsObject("bottomLeft", theme)},
|
|
2178
|
+
bottomRight: ${extractBorderOptionsObject("bottomRight", theme)},
|
|
579
2179
|
};
|
|
580
2180
|
} else {
|
|
581
|
-
border.top = ${
|
|
582
|
-
border.bottom = ${
|
|
583
|
-
border.left = ${
|
|
584
|
-
border.right = ${
|
|
585
|
-
border.topLeft = ${
|
|
586
|
-
border.topRight = ${
|
|
587
|
-
border.bottomLeft = ${
|
|
588
|
-
border.bottomRight = ${
|
|
2181
|
+
border.top = ${extractBorderOptionsString("top", theme)};
|
|
2182
|
+
border.bottom = ${extractBorderOptionsString("bottom", theme)};
|
|
2183
|
+
border.left = ${extractBorderOptionsString("left", theme)};
|
|
2184
|
+
border.right = ${extractBorderOptionsString("right", theme)};
|
|
2185
|
+
border.topLeft = ${extractBorderOptionsString("topLeft", theme)};
|
|
2186
|
+
border.topRight = ${extractBorderOptionsString("topRight", theme)};
|
|
2187
|
+
border.bottomLeft = ${extractBorderOptionsString("bottomLeft", theme)};
|
|
2188
|
+
border.bottomRight = ${extractBorderOptionsString("bottomRight", theme)};
|
|
589
2189
|
}
|
|
590
2190
|
|
|
591
|
-
const padding = Math.max(0, opts?.padding ?? ${
|
|
2191
|
+
const padding = Math.max(0, opts?.padding ?? ${theme.padding.table}) * (columnIndex === 0 || columnIndex === rowLength - 1 ? 2 : 1);
|
|
592
2192
|
const value = cell ?? "";
|
|
593
2193
|
const width = stripAnsi(value).length + padding * 2;
|
|
594
2194
|
|
|
@@ -606,27 +2206,27 @@ console.log(result); // "\\\\x1b[36mHello\\\\x1b[39\\\\x1b[31mWorld\\\\x1b[0m\\\
|
|
|
606
2206
|
let border = {} as TableCellBorder;
|
|
607
2207
|
if (typeof borderOptions === "object") {
|
|
608
2208
|
border = {
|
|
609
|
-
top: ${
|
|
610
|
-
bottom: ${
|
|
611
|
-
left: ${
|
|
612
|
-
right: ${
|
|
613
|
-
topLeft: ${
|
|
614
|
-
topRight: ${
|
|
615
|
-
bottomLeft: ${
|
|
616
|
-
bottomRight: ${
|
|
2209
|
+
top: ${extractBorderOptionsObject("top", theme)},
|
|
2210
|
+
bottom: ${extractBorderOptionsObject("bottom", theme)},
|
|
2211
|
+
left: ${extractBorderOptionsObject("left", theme)},
|
|
2212
|
+
right: ${extractBorderOptionsObject("right", theme)},
|
|
2213
|
+
topLeft: ${extractBorderOptionsObject("topLeft", theme)},
|
|
2214
|
+
topRight: ${extractBorderOptionsObject("topRight", theme)},
|
|
2215
|
+
bottomLeft: ${extractBorderOptionsObject("bottomLeft", theme)},
|
|
2216
|
+
bottomRight: ${extractBorderOptionsObject("bottomRight", theme)},
|
|
617
2217
|
};
|
|
618
2218
|
} else {
|
|
619
|
-
border.top = ${
|
|
620
|
-
border.bottom = ${
|
|
621
|
-
border.left = ${
|
|
622
|
-
border.right = ${
|
|
623
|
-
border.topLeft = ${
|
|
624
|
-
border.topRight = ${
|
|
625
|
-
border.bottomLeft = ${
|
|
626
|
-
border.bottomRight = ${
|
|
2219
|
+
border.top = ${extractBorderOptionsString("top", theme)};
|
|
2220
|
+
border.bottom = ${extractBorderOptionsString("bottom", theme)};
|
|
2221
|
+
border.left = ${extractBorderOptionsString("left", theme)};
|
|
2222
|
+
border.right = ${extractBorderOptionsString("right", theme)};
|
|
2223
|
+
border.topLeft = ${extractBorderOptionsString("topLeft", theme)};
|
|
2224
|
+
border.topRight = ${extractBorderOptionsString("topRight", theme)};
|
|
2225
|
+
border.bottomLeft = ${extractBorderOptionsString("bottomLeft", theme)};
|
|
2226
|
+
border.bottomRight = ${extractBorderOptionsString("bottomRight", theme)};
|
|
627
2227
|
}
|
|
628
2228
|
|
|
629
|
-
const padding = Math.max(0, cell.padding ?? opts?.padding ?? ${
|
|
2229
|
+
const padding = Math.max(0, cell.padding ?? opts?.padding ?? ${theme.padding.table});
|
|
630
2230
|
const value = cell.value ?? "";
|
|
631
2231
|
const width = stripAnsi(value).length + padding * 2;
|
|
632
2232
|
const maxWidth = cell.maxWidth ? typeof cell.maxWidth === "number" ? cell.maxWidth : calculateWidth(cell.maxWidth) : undefined;
|
|
@@ -644,7 +2244,15 @@ console.log(result); // "\\\\x1b[36mHello\\\\x1b[39\\\\x1b[31mWorld\\\\x1b[0m\\\
|
|
|
644
2244
|
};
|
|
645
2245
|
|
|
646
2246
|
let colMaxWidths = [] as (number | undefined)[];
|
|
647
|
-
`),
|
|
2247
|
+
`),
|
|
2248
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
2249
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
|
|
2250
|
+
condition: _alloy_js_core.code`Array.isArray(options)`,
|
|
2251
|
+
get children() {
|
|
2252
|
+
return [(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
|
|
2253
|
+
condition: _alloy_js_core.code`options.every(row => typeof row === "string" || (typeof row === "object" && !Array.isArray(row) && !("values" in row)))`,
|
|
2254
|
+
children: _alloy_js_core.code`cells.push(options.map((cell, index) => extractTableCell(cell as string | TableCellOptions, index, options.length)));`
|
|
2255
|
+
}), (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.ElseClause, { children: _alloy_js_core.code`
|
|
648
2256
|
cells.push(
|
|
649
2257
|
...options.map(row => Array.isArray(row)
|
|
650
2258
|
? row.reduce((cellRow, cell, index) => {
|
|
@@ -671,7 +2279,10 @@ console.log(result); // "\\\\x1b[36mHello\\\\x1b[39\\\\x1b[31mWorld\\\\x1b[0m\\\
|
|
|
671
2279
|
}, [] as TableCell[]) ?? []
|
|
672
2280
|
)
|
|
673
2281
|
);
|
|
674
|
-
`})]
|
|
2282
|
+
` })];
|
|
2283
|
+
}
|
|
2284
|
+
}),
|
|
2285
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.ElseClause, { children: _alloy_js_core.code`
|
|
675
2286
|
cells.push(
|
|
676
2287
|
...options.values!.map(row => Array.isArray(row)
|
|
677
2288
|
? row.reduce((cellRow, cell, index) => {
|
|
@@ -699,7 +2310,9 @@ console.log(result); // "\\\\x1b[36mHello\\\\x1b[39\\\\x1b[31mWorld\\\\x1b[0m\\\
|
|
|
699
2310
|
)
|
|
700
2311
|
);
|
|
701
2312
|
|
|
702
|
-
`}),
|
|
2313
|
+
` }),
|
|
2314
|
+
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
2315
|
+
(0, _alloy_js_core_jsx_runtime.memo)(() => _alloy_js_core.code`
|
|
703
2316
|
cells = cells.filter(row => row.length > 0);
|
|
704
2317
|
if (cells.length === 0) {
|
|
705
2318
|
return;
|
|
@@ -760,7 +2373,7 @@ do {
|
|
|
760
2373
|
}
|
|
761
2374
|
|
|
762
2375
|
rowDims.forEach((row, rowIndex) => {
|
|
763
|
-
if (!recalculate && row.width > Math.max(getTerminalSize().columns - ${Math.max(
|
|
2376
|
+
if (!recalculate && row.width > Math.max(getTerminalSize().columns - ${Math.max(theme.padding.app, 0) * 2}, 0)) {
|
|
764
2377
|
const cell = cells[rowIndex]!.reduce((largestCell, cell) => {
|
|
765
2378
|
if (cell.width > largestCell.width) {
|
|
766
2379
|
return cell;
|
|
@@ -770,7 +2383,7 @@ do {
|
|
|
770
2383
|
|
|
771
2384
|
const lines = splitText(
|
|
772
2385
|
cell.value,
|
|
773
|
-
Math.min(Math.max(getTerminalSize().columns - ${Math.max(
|
|
2386
|
+
Math.min(Math.max(getTerminalSize().columns - ${Math.max(theme.padding.app, 0) * 2} - (row.width - (cell.width - cell.padding * 2)), 0),
|
|
774
2387
|
cell.maxWidth ?? Number.POSITIVE_INFINITY)
|
|
775
2388
|
);
|
|
776
2389
|
|
|
@@ -782,7 +2395,7 @@ do {
|
|
|
782
2395
|
}
|
|
783
2396
|
});
|
|
784
2397
|
|
|
785
|
-
if (!recalculate && colWidths.reduce((a, b) => a + b, 0) > Math.max(getTerminalSize().columns - ${Math.max(
|
|
2398
|
+
if (!recalculate && colWidths.reduce((a, b) => a + b, 0) > Math.max(getTerminalSize().columns - ${Math.max(theme.padding.app, 0) * 2}, 0)) {
|
|
786
2399
|
let colIndex = 0;
|
|
787
2400
|
const cell = cells.reduce((ret, row) => {
|
|
788
2401
|
return row.reduce((largest, current, index) => {
|
|
@@ -796,7 +2409,7 @@ do {
|
|
|
796
2409
|
|
|
797
2410
|
const lines = splitText(
|
|
798
2411
|
cell.value,
|
|
799
|
-
Math.min(Math.max(getTerminalSize().columns - ${Math.max(
|
|
2412
|
+
Math.min(Math.max(getTerminalSize().columns - ${Math.max(theme.padding.app, 0) * 2} - (colWidths.filter((_, i) => i !== colIndex).reduce((a, b) => a + b, 0)) - cell.padding * 2, 0),
|
|
800
2413
|
cell.maxWidth ?? Number.POSITIVE_INFINITY)
|
|
801
2414
|
);
|
|
802
2415
|
|
|
@@ -846,7 +2459,167 @@ cells.forEach((row, rowIndex) => {
|
|
|
846
2459
|
writeLine(outputs.map(output => output[index] ?? "").join(""));
|
|
847
2460
|
}
|
|
848
2461
|
});
|
|
849
|
-
`)
|
|
2462
|
+
`)
|
|
2463
|
+
];
|
|
2464
|
+
}
|
|
2465
|
+
}))
|
|
2466
|
+
];
|
|
2467
|
+
}
|
|
2468
|
+
/**
|
|
2469
|
+
* A built-in console utilities module for Shell Shock.
|
|
2470
|
+
*/
|
|
2471
|
+
function ConsoleBuiltin(props) {
|
|
2472
|
+
const { children, imports, builtinImports } = props;
|
|
2473
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_builtin_file.BuiltinFile, {
|
|
2474
|
+
id: "console",
|
|
2475
|
+
description: "A collection of helper utilities to assist in generating content meant for display in the console.",
|
|
2476
|
+
get imports() {
|
|
2477
|
+
return (0, defu.defu)(imports, {
|
|
2478
|
+
"@shell-shock/plugin-theme/types/theme": ["ThemeSpinnerResolvedConfig"],
|
|
2479
|
+
"@shell-shock/plugin-theme/helpers/spinners": ["SpinnerPreset", "resolveSpinner"],
|
|
2480
|
+
"node:util": ["stripVTControlCharacters"]
|
|
2481
|
+
});
|
|
2482
|
+
},
|
|
2483
|
+
get builtinImports() {
|
|
2484
|
+
return (0, defu.defu)(builtinImports, {
|
|
2485
|
+
utils: [
|
|
2486
|
+
"isInteractive",
|
|
2487
|
+
"isColorSupported",
|
|
2488
|
+
"colorSupportLevels",
|
|
2489
|
+
"isUnicodeSupported",
|
|
2490
|
+
"isHyperlinkSupported",
|
|
2491
|
+
"getTerminalSize"
|
|
2492
|
+
],
|
|
2493
|
+
env: [
|
|
2494
|
+
"env",
|
|
2495
|
+
"isDevelopment",
|
|
2496
|
+
"isDebug"
|
|
2497
|
+
],
|
|
2498
|
+
state: ["hasFlag"]
|
|
2499
|
+
});
|
|
2500
|
+
},
|
|
2501
|
+
get children() {
|
|
2502
|
+
return [
|
|
2503
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(AnsiHelpersDeclarations, {}),
|
|
2504
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2505
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(StripAnsiFunctionDeclaration, {}),
|
|
2506
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2507
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(WrapAnsiFunction, {}),
|
|
2508
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2509
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(AnsiStyleFunctionsDeclaration, {}),
|
|
2510
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2511
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(WriteFunctionDeclaration, {}),
|
|
2512
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2513
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(WriteLineFunctionDeclaration, {}),
|
|
2514
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2515
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(SplitTextFunctionDeclaration, {}),
|
|
2516
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2517
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(LinkFunctionDeclaration, {}),
|
|
2518
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2519
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(DividerFunctionDeclaration, {}),
|
|
2520
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2521
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(SpinnerFunctionDeclaration, {}),
|
|
2522
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2523
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(MessageFunctionDeclaration, {
|
|
2524
|
+
type: "help",
|
|
2525
|
+
variant: "help",
|
|
2526
|
+
consoleFnName: "log",
|
|
2527
|
+
description: "help"
|
|
2528
|
+
}),
|
|
2529
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2530
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(MessageFunctionDeclaration, {
|
|
2531
|
+
type: "success",
|
|
2532
|
+
variant: "success",
|
|
2533
|
+
consoleFnName: "info",
|
|
2534
|
+
description: "success"
|
|
2535
|
+
}),
|
|
2536
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2537
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(MessageFunctionDeclaration, {
|
|
2538
|
+
type: "info",
|
|
2539
|
+
variant: "info",
|
|
2540
|
+
consoleFnName: "info",
|
|
2541
|
+
description: "informational"
|
|
2542
|
+
}),
|
|
2543
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2544
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(MessageFunctionDeclaration, {
|
|
2545
|
+
type: "debug",
|
|
2546
|
+
variant: "debug",
|
|
2547
|
+
consoleFnName: "debug",
|
|
2548
|
+
description: "debug",
|
|
2549
|
+
timestamp: true,
|
|
2550
|
+
get prefix() {
|
|
2551
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
|
|
2552
|
+
get condition() {
|
|
2553
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(_shell_shock_core_components_helpers.IsNotDebug, {});
|
|
2554
|
+
},
|
|
2555
|
+
children: _alloy_js_core.code`return; `
|
|
2556
|
+
});
|
|
2557
|
+
}
|
|
2558
|
+
}),
|
|
2559
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2560
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(MessageFunctionDeclaration, {
|
|
2561
|
+
type: "verbose",
|
|
2562
|
+
variant: "info",
|
|
2563
|
+
color: "debug",
|
|
2564
|
+
consoleFnName: "debug",
|
|
2565
|
+
description: "verbose",
|
|
2566
|
+
timestamp: true,
|
|
2567
|
+
get prefix() {
|
|
2568
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
|
|
2569
|
+
get condition() {
|
|
2570
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(_shell_shock_core_components_helpers.IsNotVerbose, {});
|
|
2571
|
+
},
|
|
2572
|
+
children: _alloy_js_core.code`return; `
|
|
2573
|
+
});
|
|
2574
|
+
}
|
|
2575
|
+
}),
|
|
2576
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2577
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(MessageFunctionDeclaration, {
|
|
2578
|
+
type: "warn",
|
|
2579
|
+
variant: "warning",
|
|
2580
|
+
consoleFnName: "warn",
|
|
2581
|
+
description: "warning"
|
|
2582
|
+
}),
|
|
2583
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2584
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(MessageFunctionDeclaration, {
|
|
2585
|
+
type: "danger",
|
|
2586
|
+
variant: "danger",
|
|
2587
|
+
consoleFnName: "error",
|
|
2588
|
+
description: "destructive/danger"
|
|
2589
|
+
}),
|
|
2590
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2591
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(MessageFunctionDeclaration, {
|
|
2592
|
+
type: "error",
|
|
2593
|
+
variant: "error",
|
|
2594
|
+
consoleFnName: "error",
|
|
2595
|
+
description: "error",
|
|
2596
|
+
timestamp: true,
|
|
2597
|
+
parameters: [{
|
|
2598
|
+
name: "err",
|
|
2599
|
+
type: "string | { message: string; stack?: string }",
|
|
2600
|
+
optional: false
|
|
2601
|
+
}, {
|
|
2602
|
+
name: "header",
|
|
2603
|
+
type: "string",
|
|
2604
|
+
optional: true
|
|
2605
|
+
}],
|
|
2606
|
+
get prefix() {
|
|
2607
|
+
return [
|
|
2608
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.VarDeclaration, {
|
|
2609
|
+
"let": true,
|
|
2610
|
+
name: "message",
|
|
2611
|
+
type: "string | undefined"
|
|
2612
|
+
}),
|
|
2613
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2614
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
|
|
2615
|
+
condition: _alloy_js_core.code`(err as { message: string; stack?: string })?.message`,
|
|
2616
|
+
children: _alloy_js_core.code`message = (err as { message: string; stack?: string }).message;`
|
|
2617
|
+
}),
|
|
2618
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.ElseClause, { children: _alloy_js_core.code`message = String(err);` }),
|
|
2619
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2620
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
|
|
2621
|
+
condition: _alloy_js_core.code`env.STACKTRACE && typeof err === "object" && (err as { stack?: string })?.stack`,
|
|
2622
|
+
children: _alloy_js_core.code`message += " \\n\\n" + (err as { stack: string }).stack.split("\\n").slice(1).map(line => {
|
|
850
2623
|
const match = line.match(/at (?:(.+?)\\s+\\()?(?:(.+?):(\\d+)(?::(\\d+))?|([^)]+))\\)?/);
|
|
851
2624
|
if (match) {
|
|
852
2625
|
const filePath = match[2] || match[5] || "<unknown>";
|
|
@@ -854,4 +2627,43 @@ cells.forEach((row, rowIndex) => {
|
|
|
854
2627
|
}
|
|
855
2628
|
|
|
856
2629
|
return line.trim();
|
|
857
|
-
}).join("\\n"); `
|
|
2630
|
+
}).join("\\n"); `
|
|
2631
|
+
})
|
|
2632
|
+
];
|
|
2633
|
+
}
|
|
2634
|
+
}),
|
|
2635
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2636
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(TableFunctionDeclaration, {}),
|
|
2637
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2638
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(BlockquoteFunctionDeclaration, {}),
|
|
2639
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2640
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(CodeFunctionDeclaration, {}),
|
|
2641
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2642
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(InlineCodeFunctionDeclaration, {}),
|
|
2643
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
2644
|
+
children,
|
|
2645
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {})
|
|
2646
|
+
];
|
|
2647
|
+
}
|
|
2648
|
+
});
|
|
2649
|
+
}
|
|
2650
|
+
|
|
2651
|
+
//#endregion
|
|
2652
|
+
exports.AnsiHelpersDeclarations = AnsiHelpersDeclarations;
|
|
2653
|
+
exports.AnsiStyleFunctionsDeclaration = AnsiStyleFunctionsDeclaration;
|
|
2654
|
+
exports.BlockquoteFunctionDeclaration = BlockquoteFunctionDeclaration;
|
|
2655
|
+
exports.CodeFunctionDeclaration = CodeFunctionDeclaration;
|
|
2656
|
+
exports.ConsoleBuiltin = ConsoleBuiltin;
|
|
2657
|
+
exports.DividerFunctionDeclaration = DividerFunctionDeclaration;
|
|
2658
|
+
exports.InlineCodeFunctionDeclaration = InlineCodeFunctionDeclaration;
|
|
2659
|
+
exports.LinkFunctionDeclaration = LinkFunctionDeclaration;
|
|
2660
|
+
exports.MessageFunctionDeclaration = MessageFunctionDeclaration;
|
|
2661
|
+
exports.SpinnerFunctionDeclaration = SpinnerFunctionDeclaration;
|
|
2662
|
+
exports.SplitTextFunctionDeclaration = SplitTextFunctionDeclaration;
|
|
2663
|
+
exports.StripAnsiFunctionDeclaration = StripAnsiFunctionDeclaration;
|
|
2664
|
+
exports.TableFunctionDeclaration = TableFunctionDeclaration;
|
|
2665
|
+
exports.ThemeColorObjectDefinition = ThemeColorObjectDefinition;
|
|
2666
|
+
exports.ThemeColorTypeDefinition = ThemeColorTypeDefinition;
|
|
2667
|
+
exports.WrapAnsiFunction = WrapAnsiFunction;
|
|
2668
|
+
exports.WriteFunctionDeclaration = WriteFunctionDeclaration;
|
|
2669
|
+
exports.WriteLineFunctionDeclaration = WriteLineFunctionDeclaration;
|