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