@shell-shock/plugin-console 0.2.11 → 0.2.12

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