@shell-shock/preset-script 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/README.md +2 -2
  2. package/dist/components/args-parser-logic.d.cts +7 -7
  3. package/dist/components/args-parser-logic.d.cts.map +1 -1
  4. package/dist/components/bin-entry.cjs +0 -1
  5. package/dist/components/bin-entry.cjs.map +1 -1
  6. package/dist/components/bin-entry.d.cts.map +1 -1
  7. package/dist/components/bin-entry.d.mts.map +1 -1
  8. package/dist/components/bin-entry.mjs +0 -1
  9. package/dist/components/bin-entry.mjs.map +1 -1
  10. package/dist/components/command-entry.d.cts +4 -4
  11. package/dist/components/command-entry.d.mts +4 -4
  12. package/dist/components/command-entry.d.mts.map +1 -1
  13. package/dist/components/command-router.cjs +5 -7
  14. package/dist/components/command-router.cjs.map +1 -1
  15. package/dist/components/command-router.mjs +5 -7
  16. package/dist/components/command-router.mjs.map +1 -1
  17. package/dist/components/console-builtin.cjs +314 -82
  18. package/dist/components/console-builtin.cjs.map +1 -1
  19. package/dist/components/console-builtin.d.cts +12 -2
  20. package/dist/components/console-builtin.d.cts.map +1 -1
  21. package/dist/components/console-builtin.d.mts +12 -2
  22. package/dist/components/console-builtin.d.mts.map +1 -1
  23. package/dist/components/console-builtin.mjs +315 -84
  24. package/dist/components/console-builtin.mjs.map +1 -1
  25. package/dist/components/help.cjs +35 -23
  26. package/dist/components/help.cjs.map +1 -1
  27. package/dist/components/help.d.cts +19 -11
  28. package/dist/components/help.d.cts.map +1 -1
  29. package/dist/components/help.d.mts +19 -11
  30. package/dist/components/help.d.mts.map +1 -1
  31. package/dist/components/help.mjs +36 -24
  32. package/dist/components/help.mjs.map +1 -1
  33. package/dist/components/index.cjs +1 -0
  34. package/dist/components/index.d.cts +3 -3
  35. package/dist/components/index.d.mts +3 -3
  36. package/dist/components/index.mjs +2 -2
  37. package/dist/components/utils-builtin.cjs +18 -16
  38. package/dist/components/utils-builtin.cjs.map +1 -1
  39. package/dist/components/utils-builtin.d.cts +7 -7
  40. package/dist/components/utils-builtin.d.cts.map +1 -1
  41. package/dist/components/utils-builtin.d.mts +7 -7
  42. package/dist/components/utils-builtin.d.mts.map +1 -1
  43. package/dist/components/utils-builtin.mjs +18 -16
  44. package/dist/components/utils-builtin.mjs.map +1 -1
  45. package/dist/components/virtual-command-entry.d.cts +3 -3
  46. package/dist/components/virtual-command-entry.d.cts.map +1 -1
  47. package/dist/helpers/ansi-utils.cjs +74 -10
  48. package/dist/helpers/ansi-utils.cjs.map +1 -1
  49. package/dist/helpers/ansi-utils.mjs +74 -10
  50. package/dist/helpers/ansi-utils.mjs.map +1 -1
  51. package/dist/helpers/get-default-options.cjs +20 -0
  52. package/dist/helpers/get-default-options.cjs.map +1 -1
  53. package/dist/helpers/get-default-options.mjs +20 -0
  54. package/dist/helpers/get-default-options.mjs.map +1 -1
  55. package/dist/index.cjs +97 -75
  56. package/dist/index.cjs.map +1 -1
  57. package/dist/index.d.cts.map +1 -1
  58. package/dist/index.d.mts.map +1 -1
  59. package/dist/index.mjs +99 -77
  60. package/dist/index.mjs.map +1 -1
  61. package/package.json +10 -10
@@ -3,9 +3,13 @@ const require_contexts_theme = require('../contexts/theme.cjs');
3
3
  let __alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
4
4
  let __alloy_js_core = require("@alloy-js/core");
5
5
  let __alloy_js_typescript = require("@alloy-js/typescript");
6
+ let __shell_shock_core_plugin_utils_context_helpers = require("@shell-shock/core/plugin-utils/context-helpers");
7
+ let __powerlines_plugin_alloy_core_contexts_context = require("@powerlines/plugin-alloy/core/contexts/context");
6
8
  let __powerlines_plugin_alloy_typescript_components_tsdoc = require("@powerlines/plugin-alloy/typescript/components/tsdoc");
7
9
  let __powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
10
+ let __shell_shock_core_contexts_command = require("@shell-shock/core/contexts/command");
8
11
  let __powerlines_plugin_alloy_typescript_components_builtin_file = require("@powerlines/plugin-alloy/typescript/components/builtin-file");
12
+ let __stryke_string_format_vowels = require("@stryke/string-format/vowels");
9
13
 
10
14
  //#region src/components/console-builtin.tsx
11
15
  /**
@@ -104,61 +108,216 @@ function ColorsDeclaration() {
104
108
  (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
105
109
  __alloy_js_core.code`text: {
106
110
  banner: {
107
- title: ${(0, __alloy_js_core_jsx_runtime.createComponent)(ColorFunction, {
111
+ header: {
112
+ primary: ${(0, __alloy_js_core_jsx_runtime.createComponent)(ColorFunction, {
108
113
  get ansi16() {
109
- return colors.ansi16.theme.text.banner.title;
114
+ return colors.ansi16.theme.text.banner.header.primary;
110
115
  },
111
116
  get ansi256() {
112
- return colors.ansi256.theme.text.banner.title;
117
+ return colors.ansi256.theme.text.banner.header.primary;
113
118
  },
114
119
  get ansi16m() {
115
- return colors.ansi16m.theme.text.banner.title;
120
+ return colors.ansi16m.theme.text.banner.header.primary;
116
121
  }
117
122
  })},
118
- header: ${(0, __alloy_js_core_jsx_runtime.createComponent)(ColorFunction, {
123
+ secondary: ${(0, __alloy_js_core_jsx_runtime.createComponent)(ColorFunction, {
119
124
  get ansi16() {
120
- return colors.ansi16.theme.text.banner.header;
125
+ return colors.ansi16.theme.text.banner.header.secondary;
121
126
  },
122
127
  get ansi256() {
123
- return colors.ansi256.theme.text.banner.header;
128
+ return colors.ansi256.theme.text.banner.header.secondary;
124
129
  },
125
130
  get ansi16m() {
126
- return colors.ansi16m.theme.text.banner.header;
131
+ return colors.ansi16m.theme.text.banner.header.secondary;
127
132
  }
128
133
  })},
129
- footer: ${(0, __alloy_js_core_jsx_runtime.createComponent)(ColorFunction, {
134
+ tertiary: ${(0, __alloy_js_core_jsx_runtime.createComponent)(ColorFunction, {
135
+ get ansi16() {
136
+ return colors.ansi16.theme.text.banner.header.tertiary;
137
+ },
138
+ get ansi256() {
139
+ return colors.ansi256.theme.text.banner.header.tertiary;
140
+ },
141
+ get ansi16m() {
142
+ return colors.ansi16m.theme.text.banner.header.tertiary;
143
+ }
144
+ })}
145
+ },
146
+ footer: {
147
+ primary: ${(0, __alloy_js_core_jsx_runtime.createComponent)(ColorFunction, {
130
148
  get ansi16() {
131
- return colors.ansi16.theme.text.banner.footer;
149
+ return colors.ansi16.theme.text.banner.footer.primary;
132
150
  },
133
151
  get ansi256() {
134
- return colors.ansi256.theme.text.banner.footer;
152
+ return colors.ansi256.theme.text.banner.footer.primary;
135
153
  },
136
154
  get ansi16m() {
137
- return colors.ansi16m.theme.text.banner.footer;
155
+ return colors.ansi16m.theme.text.banner.footer.primary;
138
156
  }
139
157
  })},
140
- command: ${(0, __alloy_js_core_jsx_runtime.createComponent)(ColorFunction, {
158
+ secondary: ${(0, __alloy_js_core_jsx_runtime.createComponent)(ColorFunction, {
141
159
  get ansi16() {
142
- return colors.ansi16.theme.text.banner.command;
160
+ return colors.ansi16.theme.text.banner.footer.secondary;
143
161
  },
144
162
  get ansi256() {
145
- return colors.ansi256.theme.text.banner.command;
163
+ return colors.ansi256.theme.text.banner.footer.secondary;
146
164
  },
147
165
  get ansi16m() {
148
- return colors.ansi16m.theme.text.banner.command;
166
+ return colors.ansi16m.theme.text.banner.footer.secondary;
149
167
  }
150
168
  })},
151
- description: ${(0, __alloy_js_core_jsx_runtime.createComponent)(ColorFunction, {
169
+ tertiary: ${(0, __alloy_js_core_jsx_runtime.createComponent)(ColorFunction, {
152
170
  get ansi16() {
153
- return colors.ansi16.theme.text.banner.description;
171
+ return colors.ansi16.theme.text.banner.footer.tertiary;
154
172
  },
155
173
  get ansi256() {
156
- return colors.ansi256.theme.text.banner.description;
174
+ return colors.ansi256.theme.text.banner.footer.tertiary;
157
175
  },
158
176
  get ansi16m() {
159
- return colors.ansi16m.theme.text.banner.description;
177
+ return colors.ansi16m.theme.text.banner.footer.tertiary;
160
178
  }
161
179
  })}
180
+ },
181
+ command: {
182
+ primary: ${(0, __alloy_js_core_jsx_runtime.createComponent)(ColorFunction, {
183
+ get ansi16() {
184
+ return colors.ansi16.theme.text.banner.command.primary;
185
+ },
186
+ get ansi256() {
187
+ return colors.ansi256.theme.text.banner.command.primary;
188
+ },
189
+ get ansi16m() {
190
+ return colors.ansi16m.theme.text.banner.command.primary;
191
+ }
192
+ })},
193
+ secondary: ${(0, __alloy_js_core_jsx_runtime.createComponent)(ColorFunction, {
194
+ get ansi16() {
195
+ return colors.ansi16.theme.text.banner.command.secondary;
196
+ },
197
+ get ansi256() {
198
+ return colors.ansi256.theme.text.banner.command.secondary;
199
+ },
200
+ get ansi16m() {
201
+ return colors.ansi16m.theme.text.banner.command.secondary;
202
+ }
203
+ })},
204
+ tertiary: ${(0, __alloy_js_core_jsx_runtime.createComponent)(ColorFunction, {
205
+ get ansi16() {
206
+ return colors.ansi16.theme.text.banner.command.tertiary;
207
+ },
208
+ get ansi256() {
209
+ return colors.ansi256.theme.text.banner.command.tertiary;
210
+ },
211
+ get ansi16m() {
212
+ return colors.ansi16m.theme.text.banner.command.tertiary;
213
+ }
214
+ })},
215
+ },
216
+ title: {
217
+ primary: ${(0, __alloy_js_core_jsx_runtime.createComponent)(ColorFunction, {
218
+ get ansi16() {
219
+ return colors.ansi16.theme.text.banner.title.primary;
220
+ },
221
+ get ansi256() {
222
+ return colors.ansi256.theme.text.banner.title.primary;
223
+ },
224
+ get ansi16m() {
225
+ return colors.ansi16m.theme.text.banner.title.primary;
226
+ }
227
+ })},
228
+ secondary: ${(0, __alloy_js_core_jsx_runtime.createComponent)(ColorFunction, {
229
+ get ansi16() {
230
+ return colors.ansi16.theme.text.banner.title.secondary;
231
+ },
232
+ get ansi256() {
233
+ return colors.ansi256.theme.text.banner.title.secondary;
234
+ },
235
+ get ansi16m() {
236
+ return colors.ansi16m.theme.text.banner.title.secondary;
237
+ }
238
+ })},
239
+ tertiary: ${(0, __alloy_js_core_jsx_runtime.createComponent)(ColorFunction, {
240
+ get ansi16() {
241
+ return colors.ansi16.theme.text.banner.title.tertiary;
242
+ },
243
+ get ansi256() {
244
+ return colors.ansi256.theme.text.banner.title.tertiary;
245
+ },
246
+ get ansi16m() {
247
+ return colors.ansi16m.theme.text.banner.title.tertiary;
248
+ }
249
+ })},
250
+ },
251
+ link: {
252
+ primary: ${(0, __alloy_js_core_jsx_runtime.createComponent)(ColorFunction, {
253
+ get ansi16() {
254
+ return colors.ansi16.theme.text.banner.link.primary;
255
+ },
256
+ get ansi256() {
257
+ return colors.ansi256.theme.text.banner.link.primary;
258
+ },
259
+ get ansi16m() {
260
+ return colors.ansi16m.theme.text.banner.link.primary;
261
+ }
262
+ })},
263
+ secondary: ${(0, __alloy_js_core_jsx_runtime.createComponent)(ColorFunction, {
264
+ get ansi16() {
265
+ return colors.ansi16.theme.text.banner.link.secondary;
266
+ },
267
+ get ansi256() {
268
+ return colors.ansi256.theme.text.banner.link.secondary;
269
+ },
270
+ get ansi16m() {
271
+ return colors.ansi16m.theme.text.banner.link.secondary;
272
+ }
273
+ })},
274
+ tertiary: ${(0, __alloy_js_core_jsx_runtime.createComponent)(ColorFunction, {
275
+ get ansi16() {
276
+ return colors.ansi16.theme.text.banner.link.tertiary;
277
+ },
278
+ get ansi256() {
279
+ return colors.ansi256.theme.text.banner.link.tertiary;
280
+ },
281
+ get ansi16m() {
282
+ return colors.ansi16m.theme.text.banner.link.tertiary;
283
+ }
284
+ })},
285
+ },
286
+ description: {
287
+ primary: ${(0, __alloy_js_core_jsx_runtime.createComponent)(ColorFunction, {
288
+ get ansi16() {
289
+ return colors.ansi16.theme.text.banner.description.primary;
290
+ },
291
+ get ansi256() {
292
+ return colors.ansi256.theme.text.banner.description.primary;
293
+ },
294
+ get ansi16m() {
295
+ return colors.ansi16m.theme.text.banner.description.primary;
296
+ }
297
+ })},
298
+ secondary: ${(0, __alloy_js_core_jsx_runtime.createComponent)(ColorFunction, {
299
+ get ansi16() {
300
+ return colors.ansi16.theme.text.banner.description.secondary;
301
+ },
302
+ get ansi256() {
303
+ return colors.ansi256.theme.text.banner.description.secondary;
304
+ },
305
+ get ansi16m() {
306
+ return colors.ansi16m.theme.text.banner.description.secondary;
307
+ }
308
+ })},
309
+ tertiary: ${(0, __alloy_js_core_jsx_runtime.createComponent)(ColorFunction, {
310
+ get ansi16() {
311
+ return colors.ansi16.theme.text.banner.description.tertiary;
312
+ },
313
+ get ansi256() {
314
+ return colors.ansi256.theme.text.banner.description.tertiary;
315
+ },
316
+ get ansi16m() {
317
+ return colors.ansi16m.theme.text.banner.description.tertiary;
318
+ }
319
+ })},
320
+ }
162
321
  },
163
322
  heading: {
164
323
  primary: ${(0, __alloy_js_core_jsx_runtime.createComponent)(ColorFunction, {
@@ -193,7 +352,7 @@ function ColorsDeclaration() {
193
352
  get ansi16m() {
194
353
  return colors.ansi16m.theme.text.heading.tertiary;
195
354
  }
196
- })}
355
+ })},
197
356
  },
198
357
  body: {
199
358
  primary: ${(0, __alloy_js_core_jsx_runtime.createComponent)(ColorFunction, {
@@ -984,7 +1143,7 @@ function WriteLineFunctionDeclaration() {
984
1143
  } else {
985
1144
  const index = [" ", "/", "\\\\", ".", ",", "-", ":", "|", "@", "+"].reduce((ret, split) => {
986
1145
  let current = ret;
987
- while (stripAnsi(line).indexOf(split, current + 1) !== -1 && stripAnsi(line).indexOf(split, current + 1) <= maxLength) {
1146
+ while (stripAnsi(line).indexOf(split, current + 1) !== -1 && stripAnsi(line).indexOf(split, current + 1) <= maxLength && (!/.*\\([^)]*$/.test(stripAnsi(line).slice(0, line.indexOf(split, current + 1))) || !/^[^(]*\\).*/.test(stripAnsi(line).slice(line.indexOf(split, current + 1) + 1)) || stripAnsi(line).slice(line.indexOf(split, current + 1) + 1).replace(/^.*\\)/, "").indexOf(split) !== -1)) {
988
1147
  current = line.indexOf(split, current + 1);
989
1148
  }
990
1149
 
@@ -1115,17 +1274,11 @@ consoleFn(\`\${" ".repeat(Math.max(options.padding ?? ${theme.padding.app}, 0))}
1115
1274
  * A component to generate the message functions in the `shell-shock:console` builtin module.
1116
1275
  */
1117
1276
  function MessageFunctionDeclaration(props) {
1118
- const { type, variant, consoleFnName, description, prefix, parameters } = props;
1277
+ const { type, variant, consoleFnName, description, prefix, parameters, timestamp } = props;
1119
1278
  const theme = require_contexts_theme.useTheme();
1120
1279
  return [(0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
1121
1280
  get heading() {
1122
- return `Write ${[
1123
- "a",
1124
- "e",
1125
- "i",
1126
- "o",
1127
- "u"
1128
- ].includes(description.charAt(0)) ? "an" : "a"} ${description} message to the console.`;
1281
+ return `Write ${(0, __stryke_string_format_vowels.getIndefiniteArticle)(description)} ${description} message to the console.`;
1129
1282
  },
1130
1283
  get children() {
1131
1284
  return [
@@ -1162,19 +1315,69 @@ function MessageFunctionDeclaration(props) {
1162
1315
  return;
1163
1316
  }
1164
1317
 
1165
- writeLine(colors.border.message.outline.${variant}("${theme.borderStyles.message.outline[variant].topLeft}") + colors.border.message.outline.${variant}("${theme.borderStyles.message.outline[variant].top}".repeat(Math.max(process.stdout.columns - ${(Math.max(theme.padding.app, 0) + Math.max(theme.padding.message, 0)) * 2 + theme.borderStyles.message.outline[variant].topLeft.length + theme.borderStyles.message.outline[variant].topRight.length}, 0) / ${theme.borderStyles.message.outline[variant].top.length ?? 1})) + colors.border.message.outline.${variant}("${theme.borderStyles.message.outline[variant].topRight}"), { consoleFn: console.${consoleFnName} });
1318
+ ${!theme.labels.message.footer[variant] && timestamp ? `const timestamp = \`\${colors.text.message.footer.${variant}(new Date().toLocaleDateString())} \${colors.border.message.outline.${variant}("${theme.borderStyles.message.outline[variant].bottom}")} \${colors.text.message.footer.${variant}(new Date().toLocaleTimeString())}\`; ` : ""}
1319
+ writeLine(colors.border.message.outline.${variant}("${theme.borderStyles.message.outline[variant].topLeft}") + ${theme.labels.message.header[variant] || theme.icons.message.header[variant] ? `colors.border.message.outline.${variant}("${theme.borderStyles.message.outline[variant].top}".repeat(4)) + " " + ${theme.icons.message.header[variant] ? `colors.border.message.outline.${variant}("${theme.icons.message.header[variant]}") + " " +` : ""} colors.text.message.header.${variant}("${theme.labels.message.header[variant]}") + " " + colors.border.message.outline.${variant}("${theme.borderStyles.message.outline[variant].top}".repeat(Math.max(process.stdout.columns - ${Math.max(theme.padding.app, 0) * 2 + 4 + (theme.icons.message.header[variant] ? theme.icons.message.header[variant].length + 1 + (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].topLeft.length + theme.borderStyles.message.outline[variant].topRight.length}, 0)))` : `colors.border.message.outline.${variant}("${theme.borderStyles.message.outline[variant].top}".repeat(Math.max(process.stdout.columns - ${Math.max(theme.padding.app, 0) * 2 + theme.borderStyles.message.outline[variant].topLeft.length + theme.borderStyles.message.outline[variant].topRight.length}, 0)))`} + colors.border.message.outline.${variant}("${theme.borderStyles.message.outline[variant].topRight}"), { consoleFn: console.${consoleFnName} });
1166
1320
  splitText(
1167
1321
  message,
1168
1322
  Math.max(process.stdout.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}, 0)
1169
1323
  ).forEach((line) => {
1170
- writeLine(colors.border.message.outline.${variant}("${theme.borderStyles.message.outline[variant].left + " ".repeat(Math.max(theme.padding.message, 0))}") + line + colors.border.message.outline.${variant}("${" ".repeat(Math.max(theme.padding.message, 0)) + theme.borderStyles.message.outline[variant].right}"), { consoleFn: console.${consoleFnName} });
1324
+ writeLine(colors.border.message.outline.${variant}("${theme.borderStyles.message.outline[variant].left + " ".repeat(Math.max(theme.padding.message, 0))}") + colors.text.message.description.${variant}(line) + " ".repeat(Math.max(process.stdout.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)) + colors.border.message.outline.${variant}("${theme.borderStyles.message.outline[variant].right}"), { consoleFn: console.${consoleFnName} });
1171
1325
  });
1172
- writeLine(colors.border.message.outline.${variant}("${theme.borderStyles.message.outline[variant].bottomLeft}") + colors.border.message.outline.${variant}("${theme.borderStyles.message.outline[variant].bottom}".repeat(Math.max(process.stdout.columns - ${(Math.max(theme.padding.app, 0) + Math.max(theme.padding.message, 0)) * 2 + theme.borderStyles.message.outline[variant].bottomLeft.length + theme.borderStyles.message.outline[variant].bottomRight.length}, 0) / ${theme.borderStyles.message.outline[variant].bottom.length ?? 1})) + colors.border.message.outline.${variant}("${theme.borderStyles.message.outline[variant].bottomRight}"), { consoleFn: console.${consoleFnName} });
1326
+ writeLine(colors.border.message.outline.${variant}("${theme.borderStyles.message.outline[variant].bottomLeft}") + ${theme.labels.message.footer[variant] || timestamp ? `colors.border.message.outline.${variant}("${theme.borderStyles.message.outline[variant].bottom}".repeat(Math.max(process.stdout.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))) + " " + ${theme.labels.message.footer[variant] ? `colors.text.message.footer.${variant}("${theme.labels.message.footer[variant]}")` : timestamp && "timestamp"} + " " + colors.border.message.outline.${variant}("${theme.borderStyles.message.outline[variant].bottom}".repeat(4))` : `colors.border.message.outline.${variant}("${theme.borderStyles.message.outline[variant].bottom}".repeat(Math.max(process.stdout.columns - ${Math.max(theme.padding.app, 0) * 2 + theme.borderStyles.message.outline[variant].bottomLeft.length + theme.borderStyles.message.outline[variant].bottomRight.length}, 0)))`} + colors.border.message.outline.${variant}("${theme.borderStyles.message.outline[variant].bottomRight}"), { consoleFn: console.${consoleFnName} });
1173
1327
  `)];
1174
1328
  }
1175
1329
  })];
1176
1330
  }
1177
1331
  /**
1332
+ * A component to generate the `banner` function in the `shell-shock:console` builtin module.
1333
+ */
1334
+ function BannerFunctionDeclaration(props) {
1335
+ const { consoleFnName = "log", variant = "primary", title: titleProp } = props;
1336
+ const theme = require_contexts_theme.useTheme();
1337
+ const context = (0, __powerlines_plugin_alloy_core_contexts_context.usePowerlines)();
1338
+ const command = (0, __shell_shock_core_contexts_command.useCommand)();
1339
+ const header = (0, __alloy_js_core.computed)(() => `${theme.labels.banner.header[variant] || (0, __shell_shock_core_plugin_utils_context_helpers.getAppTitle)(context)} v${context.packageJson.version || "1.0.0"}`);
1340
+ const description = (0, __alloy_js_core.computed)(() => command?.description || (0, __shell_shock_core_plugin_utils_context_helpers.getAppDescription)(context));
1341
+ const footer = (0, __alloy_js_core.computed)(() => theme.labels.banner.footer[variant]);
1342
+ const title = (0, __alloy_js_core.computed)(() => titleProp || /(?:cli|command-line|command line)\s+(?:application|app)?$/.test(header.value.toLowerCase()) ? header.value.replace(`v${context.packageJson.version || "1.0.0"}`, "").trim() : `${header.value.replace(`v${context.packageJson.version || "1.0.0"}`, "").trim()} Command-Line Application`);
1343
+ const bannerPadding = (0, __alloy_js_core.computed)(() => Math.max(theme.padding.app, 0) * 2 + theme.borderStyles.banner.outline[variant].left.length + theme.borderStyles.banner.outline[variant].right.length);
1344
+ const totalPadding = (0, __alloy_js_core.computed)(() => Math.max(theme.padding.banner, 0) * 2 + bannerPadding.value);
1345
+ return [(0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.FunctionDeclaration, {
1346
+ "export": true,
1347
+ name: "banner",
1348
+ doc: "Write the application banner to the console.",
1349
+ get children() {
1350
+ return __alloy_js_core.code`
1351
+ if (hasFlag("no-banner") || hasFlag("hide-banner") || isCI || isMinimal) {
1352
+ return;
1353
+ }
1354
+
1355
+ writeLine(colors.border.banner.outline.${variant}("${theme.borderStyles.banner.outline[variant].topLeft}") + ${theme.icons.banner.header[variant] ? `colors.border.banner.outline.${variant}("${theme.borderStyles.banner.outline[variant].top}".repeat(4)) + " " + ${theme.icons.banner.header[variant] ? `colors.border.banner.outline.${variant}("${theme.icons.banner.header[variant]}") + " " + colors.text.banner.header.${variant}("${theme.borderStyles.banner.outline[variant].top}") + " " +` : ""} colors.text.banner.header.${variant}("${header.value}") + " " + colors.border.banner.outline.${variant}("${theme.borderStyles.banner.outline[variant].top}".repeat(Math.max(process.stdout.columns - ${4 + (theme.icons.banner.header[variant] ? theme.icons.banner.header[variant].length + 3 : 0) + (header.value ? header.value.length + 2 : 0) + bannerPadding.value}, 0)))` : `colors.border.banner.outline.${variant}("${theme.borderStyles.banner.outline[variant].top}".repeat(Math.max(process.stdout.columns - ${bannerPadding.value}, 0)))`} + colors.border.banner.outline.${variant}("${theme.borderStyles.banner.outline[variant].topRight}"), { consoleFn: console.${consoleFnName} });
1356
+
1357
+ splitText(
1358
+ colors.text.banner.title.${variant}("${title.value}"),
1359
+ Math.max(process.stdout.columns - ${totalPadding.value}, 0)
1360
+ ).forEach((line) => {
1361
+ writeLine(colors.border.banner.outline.${variant}("${theme.borderStyles.banner.outline[variant].left}") + " ".repeat(Math.max(Math.floor((process.stdout.columns - (stripAnsi(line).length + ${bannerPadding.value})) / 2), 0)) + colors.text.banner.description.${variant}(line) + " ".repeat(Math.max(Math.ceil((process.stdout.columns - (stripAnsi(line).length + ${bannerPadding.value})) / 2), 0)) + colors.border.banner.outline.${variant}("${theme.borderStyles.banner.outline[variant].right}"), { consoleFn: console.${consoleFnName} });
1362
+ });
1363
+
1364
+ ${command?.title ? `writeLine(colors.border.banner.outline.${variant}("${theme.borderStyles.banner.outline[variant].bottomLeft}") + " ".repeat(Math.max(process.stdout.columns - ${bannerPadding.value})) + colors.border.banner.outline.${variant}("${theme.borderStyles.banner.outline[variant].bottomRight}"), { consoleFn: console.${consoleFnName} });
1365
+
1366
+ writeLine(colors.border.banner.outline.${variant}("${theme.borderStyles.banner.outline[variant].left}") + " ".repeat(Math.max(Math.floor((process.stdout.columns - (stripAnsi(line).length + ${bannerPadding.value})) / 2), 0)) + colors.text.banner.command.${variant}("${command.title}") + " ".repeat(Math.max(Math.ceil((process.stdout.columns - (stripAnsi(line).length + ${bannerPadding.value})) / 2), 0)) + colors.border.banner.outline.${variant}("${theme.borderStyles.banner.outline[variant].right}"), { consoleFn: console.${consoleFnName} }); ` : ""}
1367
+
1368
+ splitText(
1369
+ ${command?.title ? "colors.text.banner.description" : "colors.text.banner.command"}.${variant}("${description.value.replace(/"/g, "\\\"")}"),
1370
+ Math.max(process.stdout.columns - ${totalPadding.value}, 0)
1371
+ ).forEach((line) => {
1372
+ writeLine(colors.border.banner.outline.${variant}("${theme.borderStyles.banner.outline[variant].left}") + " ".repeat(Math.max(Math.floor((process.stdout.columns - (stripAnsi(line).length + ${bannerPadding.value})) / 2), 0)) + colors.text.banner.description.${variant}(line) + " ".repeat(Math.max(Math.ceil((process.stdout.columns - (stripAnsi(line).length + ${bannerPadding.value})) / 2), 0)) + colors.border.banner.outline.${variant}("${theme.borderStyles.banner.outline[variant].right}"), { consoleFn: console.${consoleFnName} });
1373
+ });
1374
+
1375
+ writeLine(colors.border.banner.outline.${variant}("${theme.borderStyles.banner.outline[variant].bottomLeft}") + ${footer.value ? `colors.border.banner.outline.${variant}("${theme.borderStyles.banner.outline[variant].bottom}".repeat(Math.max(process.stdout.columns - ${4 + (footer.value ? footer.value.length : 0) + bannerPadding.value}, 0))) + " " + ${footer.value ? `colors.text.banner.footer.${variant}("${footer.value}")` : ""} + " " + colors.border.banner.outline.${variant}("${theme.borderStyles.banner.outline[variant].bottom}".repeat(4))` : `colors.border.banner.outline.${variant}("${theme.borderStyles.banner.outline[variant].bottom}".repeat(Math.max(process.stdout.columns - ${bannerPadding.value}, 0)))`} + colors.border.banner.outline.${variant}("${theme.borderStyles.banner.outline[variant].bottomRight}"), { consoleFn: console.${consoleFnName} });
1376
+ `;
1377
+ }
1378
+ })];
1379
+ }
1380
+ /**
1178
1381
  * A component to generate the `wrapAnsi` function in the `shell-shock:console` builtin module.
1179
1382
  */
1180
1383
  function WrapAnsiFunction() {
@@ -1362,11 +1565,11 @@ function DividerFunctionDeclaration() {
1362
1565
  optional: false
1363
1566
  }],
1364
1567
  get children() {
1365
- return __alloy_js_core.code`const padding = options.padding ?? ${theme.padding.app * 4};
1568
+ return __alloy_js_core.code`const padding = options.padding ?? ${Math.max(theme.padding.app, 1) * 4};
1366
1569
  const width = options.width ?? (process.stdout.columns - (Math.max(padding, 0) * 2));
1367
1570
  const border = options.border === "tertiary" ? colors.border.app.divider.tertiary("${theme.borderStyles.app.divider.tertiary.top}") : options.border === "secondary" ? colors.border.app.divider.secondary("${theme.borderStyles.app.divider.secondary.top}") : colors.border.app.divider.primary("${theme.borderStyles.app.divider.primary.top}");
1368
1571
 
1369
- writeLine(" ".repeat(padding) + border.repeat(Math.max(width / ${theme.borderStyles.app.divider.primary.top.length ?? 1}, 0)));
1572
+ writeLine(" ".repeat(Math.max(padding - ${theme.padding.app}, 0)) + border.repeat(Math.max(width / ${theme.borderStyles.app.divider.primary.top.length ?? 1}, 0)));
1370
1573
  `;
1371
1574
  }
1372
1575
  })
@@ -1825,14 +2028,17 @@ let colWidths = [] as number[];
1825
2028
  let rowDims = [] as Dimensions[];
1826
2029
 
1827
2030
  const calculateRowDimensions = () => {
2031
+ colWidths = [];
1828
2032
  return cells.reduce((dims, row) => {
1829
- dims.push(row.reduce((dim, cell) => {
1830
- if (cell.width > dim.width) {
1831
- dim.width = cell.width;
1832
- }
2033
+ dims.push(row.reduce((dim, cell, index) => {
2034
+ dim.width += cell.width;
1833
2035
  if (cell.height > dim.height) {
1834
2036
  dim.height = cell.height;
1835
2037
  }
2038
+ if (!colWidths[index] || cell.width > colWidths[index]!) {
2039
+ colWidths[index] = cell.width;
2040
+ }
2041
+
1836
2042
  return dim;
1837
2043
  }, { width: 0, height: 0 } as Dimensions));
1838
2044
 
@@ -1840,14 +2046,13 @@ const calculateRowDimensions = () => {
1840
2046
  }, [] as Dimensions[]);
1841
2047
  }
1842
2048
 
1843
- rowDims = calculateRowDimensions();
1844
-
1845
- /*
1846
2049
  let recalculate!: boolean;
1847
2050
  do {
1848
2051
  recalculate = false;
1849
- rowDims.map((row, rowIndex) => {
1850
- if (row.width > Math.max(process.stdout.columns - ${Math.max(theme.padding.app, 0) * 2}, 0)) {
2052
+ rowDims = calculateRowDimensions();
2053
+
2054
+ rowDims.forEach((row, rowIndex) => {
2055
+ if (!recalculate && row.width > Math.max(process.stdout.columns - ${Math.max(theme.padding.app, 0) * 2}, 0)) {
1851
2056
  const cell = cells[rowIndex]!.reduce((largestCell, cell) => {
1852
2057
  if (cell.width > largestCell.width) {
1853
2058
  return cell;
@@ -1857,7 +2062,7 @@ do {
1857
2062
 
1858
2063
  const lines = splitText(
1859
2064
  cell.value,
1860
- Math.max(process.stdout.columns - ${Math.max(theme.padding.app, 0) * 2}, 0) - row.width - cell.width
2065
+ Math.max(process.stdout.columns - ${Math.max(theme.padding.app, 0) * 2} - (row.width - (cell.width - cell.padding * 2)), 0)
1861
2066
  );
1862
2067
 
1863
2068
  cell.value = lines.join("\\n");
@@ -1868,50 +2073,68 @@ do {
1868
2073
  }
1869
2074
  });
1870
2075
 
1871
- if (recalculate) {
1872
- rowDims = calculateRowDimensions();
2076
+ if (!recalculate && colWidths.reduce((a, b) => a + b, 0) > Math.max(process.stdout.columns - ${Math.max(theme.padding.app, 0) * 2}, 0)) {
2077
+ let colIndex = 0;
2078
+ const cell = cells.reduce((ret, row) => {
2079
+ return row.reduce((largest, current, i) => {
2080
+ if (largest.width < current.width) {
2081
+ colIndex = i;
2082
+ return current;
2083
+ }
2084
+ return largest;
2085
+ }, ret);
2086
+ }, cells[0]![0]!);
2087
+
2088
+ const lines = splitText(
2089
+ cell.value,
2090
+ Math.max(process.stdout.columns - ${Math.max(theme.padding.app, 0) * 2} - (colWidths.filter((_, i) => i !== colIndex).reduce((a, b) => a + b, 0)) - cell.padding * 2, 0)
2091
+ );
2092
+
2093
+ cell.value = lines.join("\\n");
2094
+ cell.height = lines.length;
2095
+ cell.width = Math.max(...lines.map(line => stripAnsi(line).length)) + cell.padding * 2;
2096
+
2097
+ recalculate = true;
1873
2098
  }
1874
2099
  } while (recalculate);
1875
- */
1876
-
1877
- rowDims.map((row, rowIndex) => {
1878
- cells[rowIndex]!.forEach(cell => {
1879
- cell.height = row.height;
1880
- });
1881
- });
1882
2100
 
1883
2101
  // Render table
1884
- cells.forEach(row => {
1885
- let line = "";
2102
+ cells.forEach((row, rowIndex) => {
2103
+ const outputs = [] as string[][];
1886
2104
  row.forEach((cell, colIndex) => {
1887
- const cellContent = cell.value;
1888
- let paddedContent = "";
1889
- const totalPadding = cell.padding * 2;
1890
- const contentLength = stripAnsi(cellContent).length;
1891
- const totalWidth = colWidths[colIndex] ?? contentLength + totalPadding;
1892
-
1893
- switch (cell.align) {
1894
- case "right":
1895
- paddedContent = " ".repeat(totalWidth - contentLength - totalPadding) + cellContent + " ".repeat(totalPadding);
1896
- break;
1897
- case "center":
1898
- const leftPadding = Math.floor((totalWidth - contentLength - totalPadding) / 2);
1899
- const rightPadding = totalWidth - contentLength - totalPadding - leftPadding;
1900
- paddedContent = " ".repeat(leftPadding) + cellContent + " ".repeat(rightPadding + totalPadding);
1901
- break;
1902
- case "left":
1903
- default:
1904
- paddedContent = " ".repeat(totalPadding) + cellContent + " ".repeat(totalWidth - contentLength - totalPadding);
1905
- break;
2105
+ const lines = cell.value.split("\\n");
2106
+ while (lines.length < rowDims[rowIndex]!.height) {
2107
+ lines.push("");
1906
2108
  }
1907
2109
 
1908
- line += cell.border.left + paddedContent;
1909
- if (colIndex === row.length - 1) {
1910
- line += paddedContent + cell.border.right;
1911
- }
2110
+ outputs.push(lines.map(line => {
2111
+ let paddedContent = "";
2112
+ switch (cell.align) {
2113
+ case "right":
2114
+ paddedContent = " ".repeat(Math.max(colWidths[colIndex] - stripAnsi(line).length - cell.padding, 0)) + line + " ".repeat(cell.padding);
2115
+ break;
2116
+ case "center":
2117
+ const leftPadding = Math.floor((colWidths[colIndex] - stripAnsi(line).length - cell.padding) / 2);
2118
+ const rightPadding = colWidths[colIndex] - stripAnsi(line).length - leftPadding;
2119
+ paddedContent = " ".repeat(leftPadding) + line + " ".repeat(rightPadding);
2120
+ break;
2121
+ case "left":
2122
+ default:
2123
+ paddedContent = " ".repeat(cell.padding) + line + " ".repeat(Math.max(colWidths[colIndex] - stripAnsi(line).length - cell.padding, 0));
2124
+ break;
2125
+ }
2126
+
2127
+ if (colIndex === row.length - 1) {
2128
+ return cell.border.left + paddedContent + cell.border.right;
2129
+ } else {
2130
+ return cell.border.left + paddedContent;
2131
+ }
2132
+ }));
1912
2133
  });
1913
2134
 
1914
- writeLine(line);
2135
+ for (let index = 0; index < rowDims[rowIndex]!.height; index++) {
2136
+ writeLine(outputs.map(output => output[index] ?? "").join(""));
2137
+ }
1915
2138
  });
1916
2139
  `)
1917
2140
  ];
@@ -1933,6 +2156,7 @@ function ConsoleBuiltin() {
1933
2156
  builtinImports: {
1934
2157
  utils: [
1935
2158
  "hasFlag",
2159
+ "isMinimal",
1936
2160
  "isColorSupported",
1937
2161
  "colorSupportLevels",
1938
2162
  "isHyperlinkSupported"
@@ -1940,7 +2164,8 @@ function ConsoleBuiltin() {
1940
2164
  env: [
1941
2165
  "env",
1942
2166
  "isDevelopment",
1943
- "isDebug"
2167
+ "isDebug",
2168
+ "isCI"
1944
2169
  ]
1945
2170
  },
1946
2171
  get children() {
@@ -1963,6 +2188,9 @@ function ConsoleBuiltin() {
1963
2188
  (0, __alloy_js_core_jsx_runtime.createComponent)(DividerFunctionDeclaration, {}),
1964
2189
  (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
1965
2190
  (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
2191
+ (0, __alloy_js_core_jsx_runtime.createComponent)(BannerFunctionDeclaration, {}),
2192
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
2193
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
1966
2194
  (0, __alloy_js_core_jsx_runtime.createComponent)(MessageFunctionDeclaration, {
1967
2195
  type: "help",
1968
2196
  variant: "help",
@@ -1992,6 +2220,7 @@ function ConsoleBuiltin() {
1992
2220
  variant: "debug",
1993
2221
  consoleFnName: "debug",
1994
2222
  description: "debug",
2223
+ timestamp: true,
1995
2224
  get prefix() {
1996
2225
  return (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.IfStatement, {
1997
2226
  condition: __alloy_js_core.code`!isDevelopment && !isDebug && env.LOG_LEVEL !== "debug"`,
@@ -2006,9 +2235,10 @@ function ConsoleBuiltin() {
2006
2235
  variant: "debug",
2007
2236
  consoleFnName: "debug",
2008
2237
  description: "verbose",
2238
+ timestamp: true,
2009
2239
  get prefix() {
2010
2240
  return (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.IfStatement, {
2011
- condition: __alloy_js_core.code`!(isDevelopment || isDebug || env.LOG_LEVEL === "debug" || hasFlag(["verbose", "verbose=true", "verbose=always", "debug", "debug=true", "debug=always"]))`,
2241
+ condition: __alloy_js_core.code`!(isDevelopment || isDebug || env.LOG_LEVEL === "debug" || hasFlag(["verbose", "verbose=true", "verbose=always"]))`,
2012
2242
  children: __alloy_js_core.code`return; `
2013
2243
  });
2014
2244
  }
@@ -2036,6 +2266,7 @@ function ConsoleBuiltin() {
2036
2266
  variant: "error",
2037
2267
  consoleFnName: "error",
2038
2268
  description: "error",
2269
+ timestamp: true,
2039
2270
  parameters: [{
2040
2271
  name: "err",
2041
2272
  type: "string | Error",
@@ -2074,6 +2305,7 @@ function ConsoleBuiltin() {
2074
2305
  }
2075
2306
 
2076
2307
  //#endregion
2308
+ exports.BannerFunctionDeclaration = BannerFunctionDeclaration;
2077
2309
  exports.ColorsDeclaration = ColorsDeclaration;
2078
2310
  exports.ConsoleBuiltin = ConsoleBuiltin;
2079
2311
  exports.DividerFunctionDeclaration = DividerFunctionDeclaration;