@shell-shock/preset-script 0.1.2 → 0.2.1

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 (46) hide show
  1. package/README.md +2 -2
  2. package/dist/components/bin-entry.cjs +15 -6
  3. package/dist/components/bin-entry.cjs.map +1 -1
  4. package/dist/components/bin-entry.d.cts +3 -3
  5. package/dist/components/bin-entry.d.cts.map +1 -1
  6. package/dist/components/bin-entry.d.mts +3 -3
  7. package/dist/components/bin-entry.d.mts.map +1 -1
  8. package/dist/components/bin-entry.mjs +15 -6
  9. package/dist/components/bin-entry.mjs.map +1 -1
  10. package/dist/components/command-router.cjs +61 -38
  11. package/dist/components/command-router.cjs.map +1 -1
  12. package/dist/components/command-router.d.cts.map +1 -1
  13. package/dist/components/command-router.d.mts.map +1 -1
  14. package/dist/components/command-router.mjs +61 -38
  15. package/dist/components/command-router.mjs.map +1 -1
  16. package/dist/components/console-builtin.cjs +74 -51
  17. package/dist/components/console-builtin.cjs.map +1 -1
  18. package/dist/components/console-builtin.d.cts.map +1 -1
  19. package/dist/components/console-builtin.d.mts.map +1 -1
  20. package/dist/components/console-builtin.mjs +74 -51
  21. package/dist/components/console-builtin.mjs.map +1 -1
  22. package/dist/components/help.cjs +33 -21
  23. package/dist/components/help.cjs.map +1 -1
  24. package/dist/components/help.d.cts +16 -8
  25. package/dist/components/help.d.cts.map +1 -1
  26. package/dist/components/help.d.mts +19 -11
  27. package/dist/components/help.d.mts.map +1 -1
  28. package/dist/components/help.mjs +34 -22
  29. package/dist/components/help.mjs.map +1 -1
  30. package/dist/components/index.cjs +1 -1
  31. package/dist/components/index.d.cts +3 -3
  32. package/dist/components/index.d.mts +3 -3
  33. package/dist/components/index.mjs +2 -2
  34. package/dist/components/utils-builtin.d.mts +7 -7
  35. package/dist/components/virtual-command-entry.cjs +8 -1
  36. package/dist/components/virtual-command-entry.cjs.map +1 -1
  37. package/dist/components/virtual-command-entry.mjs +8 -1
  38. package/dist/components/virtual-command-entry.mjs.map +1 -1
  39. package/dist/index.cjs +94 -71
  40. package/dist/index.cjs.map +1 -1
  41. package/dist/index.d.cts.map +1 -1
  42. package/dist/index.d.mts.map +1 -1
  43. package/dist/index.mjs +95 -72
  44. package/dist/index.mjs.map +1 -1
  45. package/dist/types/plugin.d.cts.map +1 -1
  46. package/package.json +10 -10
@@ -1 +1 @@
1
- {"version":3,"file":"command-router.mjs","names":["code","computed","For","Show","ElseIfClause","IfStatement","VarDeclaration","DynamicImportStatement","CommandContext","useCommand","isVariableCommandPath","pascalCase","CommandRouterRoute","command","_$createComponent","when","isVirtual","children","name","importPath","path","segments","filter","segment","length","exportName","_$createIntrinsic","_$memo","CommandRouter","props","commands","route","index","Object","keys","type","initializer","condition","value","each","values","subcommand","idx","Provider","Boolean","fallback","toLowerCase"],"sources":["../../src/components/command-router.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { Children } from \"@alloy-js/core\";\nimport { code, computed, For, Show } from \"@alloy-js/core\";\nimport {\n ElseIfClause,\n IfStatement,\n VarDeclaration\n} from \"@alloy-js/typescript\";\nimport { DynamicImportStatement } from \"@powerlines/plugin-alloy/typescript/components/dynamic-import-statement\";\nimport { CommandContext, useCommand } from \"@shell-shock/core/contexts/command\";\nimport { isVariableCommandPath } from \"@shell-shock/core/plugin-utils/context-helpers\";\nimport type { CommandTree } from \"@shell-shock/core/types/command\";\nimport { pascalCase } from \"@stryke/string-format/pascal-case\";\n\nexport function CommandRouterRoute() {\n const command = useCommand();\n\n return (\n <>\n <Show when={!command.isVirtual}>\n <DynamicImportStatement\n name={`handle${pascalCase(command.name)}`}\n importPath={`./${\n command.path.segments.filter(\n segment => !isVariableCommandPath(segment)\n )[\n command.path.segments.filter(\n segment => !isVariableCommandPath(segment)\n ).length - 1\n ]\n }`}\n exportName=\"handler\"\n />\n </Show>\n <hbr />\n {code`return handle${pascalCase(command.name)}(args);`}\n </>\n );\n}\n\nexport interface CommandRouterProps {\n path: string[];\n commands?: Record<string, CommandTree>;\n route?: Children;\n}\n\n/**\n * The command router component.\n */\nexport function CommandRouter(props: CommandRouterProps) {\n const { path, commands, route } = props;\n\n const command = useCommand();\n const index = computed(() => 2 + (path.length ?? 0));\n\n return (\n <Show when={commands && Object.keys(commands).length > 0}>\n <VarDeclaration\n let\n name=\"command\"\n type=\"string\"\n initializer={code`\"\";`}\n />\n <hbr />\n <IfStatement\n condition={code`args.length > ${\n index.value\n } && args[${index.value}]`}>{code`command = args[${\n index.value\n }];`}</IfStatement>\n <hbr />\n <For each={Object.values(commands ?? {})}>\n {(subcommand, idx) => (\n <CommandContext.Provider value={subcommand}>\n <Show when={subcommand.name !== command?.name}>\n <Show\n when={Boolean(idx)}\n fallback={\n <IfStatement\n condition={code`command.toLowerCase() === \"${subcommand.name.toLowerCase()}\"`}>\n <Show\n when={Boolean(route)}\n fallback={<CommandRouterRoute />}>\n {route}\n </Show>\n </IfStatement>\n }>\n <ElseIfClause\n condition={code`command.toLowerCase() === \"${subcommand.name.toLowerCase()}\"`}>\n <Show when={Boolean(route)} fallback={<CommandRouterRoute />}>\n {route}\n </Show>\n </ElseIfClause>\n </Show>\n </Show>\n </CommandContext.Provider>\n )}\n </For>\n <ElseIfClause\n condition={code`Boolean(command)`}>{code`error(\"Unknown command: \" + command);`}</ElseIfClause>\n </Show>\n );\n}\n"],"mappings":";;;;;;;;;AA+BA,SAAgBY,qBAAqB;CACnC,MAAMC,UAAUJ,YAAY;AAE5B,QAAA;EAAAK,gBA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QAAG5B,gBACdN,eAAemC,UAAQ;MAACL,OAAOG;MAAU,IAAAxB,WAAA;AAAA,cAAAH,gBACvCX,MAAI;QAAA,IAACY,OAAI;AAAA,gBAAE0B,WAAWvB,SAASL,SAASK;;QAAI,IAAAD,WAAA;AAAA,gBAAAH,gBAC1CX,MAAI;UAAA,IACHY,OAAI;AAAA,kBAAE6B,QAAQF,IAAI;;UAAA,IAClBG,WAAQ;AAAA,kBAAA/B,gBACLT,aAAW;YAAA,IACVgC,YAAS;AAAA,oBAAErC,IAAI,8BAA8ByC,WAAWvB,KAAK4B,aAAa,CAAA;;YAAG,IAAA7B,WAAA;AAAA,oBAAAH,gBAC5EX,MAAI;cAAA,IACHY,OAAI;AAAA,sBAAE6B,QAAQb,MAAM;;cAAA,IACpBc,WAAQ;AAAA,sBAAA/B,gBAAGF,oBAAkB,EAAA,CAAA;;cAAAK,UAC5Bc;cAAK,CAAA;;YAAA,CAAA;;UAAA,IAAAd,WAAA;AAAA,kBAAAH,gBAIXV,cAAY;YAAA,IACXiC,YAAS;AAAA,oBAAErC,IAAI,8BAA8ByC,WAAWvB,KAAK4B,aAAa,CAAA;;YAAG,IAAA7B,WAAA;AAAA,oBAAAH,gBAC5EX,MAAI;cAAA,IAACY,OAAI;AAAA,sBAAE6B,QAAQb,MAAM;;cAAA,IAAEc,WAAQ;AAAA,sBAAA/B,gBAAGF,oBAAkB,EAAA,CAAA;;cAAAK,UACtDc;cAAK,CAAA;;YAAA,CAAA;;UAAA,CAAA;;QAAA,CAAA;;MAAA,CAAA;KAMjB,CAAA;IAAAjB,gBAEFV,cAAY;KACXiC,WAAWrC,IAAI;KAAkBiB,UAAGjB,IAAI;KAAuC,CAAA;IAAA;;EAAA,CAAA"}
1
+ {"version":3,"file":"command-router.mjs","names":["code","computed","For","Show","ElseIfClause","IfStatement","VarDeclaration","usePowerlines","DynamicImportStatement","CommandContext","useCommand","isVariableCommandPath","pascalCase","CommandRouterRoute","command","_$createComponent","when","isVirtual","children","name","importPath","path","segments","filter","segment","length","exportName","_$createIntrinsic","_$memo","CommandRouter","props","commands","route","context","index","Object","keys","type","initializer","condition","value","each","values","subcommand","idx","Provider","Boolean","fallback","config","isCaseSensitive","toLowerCase","replaceAll","alias","doubleHardline","map","cmd","join","JSON","stringify"],"sources":["../../src/components/command-router.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { Children } from \"@alloy-js/core\";\nimport { code, computed, For, Show } from \"@alloy-js/core\";\nimport {\n ElseIfClause,\n IfStatement,\n VarDeclaration\n} from \"@alloy-js/typescript\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport { DynamicImportStatement } from \"@powerlines/plugin-alloy/typescript/components/dynamic-import-statement\";\nimport { CommandContext, useCommand } from \"@shell-shock/core/contexts/command\";\nimport { isVariableCommandPath } from \"@shell-shock/core/plugin-utils/context-helpers\";\nimport type { CommandTree } from \"@shell-shock/core/types/command\";\nimport { pascalCase } from \"@stryke/string-format/pascal-case\";\nimport type { ScriptPresetContext } from \"../types/plugin\";\n\nexport function CommandRouterRoute() {\n const command = useCommand();\n\n return (\n <>\n <Show when={!command.isVirtual}>\n <DynamicImportStatement\n name={`handle${pascalCase(command.name)}`}\n importPath={`./${\n command.path.segments.filter(\n segment => !isVariableCommandPath(segment)\n )[\n command.path.segments.filter(\n segment => !isVariableCommandPath(segment)\n ).length - 1\n ]\n }`}\n exportName=\"handler\"\n />\n </Show>\n <hbr />\n {code`return handle${pascalCase(command.name)}(args);`}\n </>\n );\n}\n\nexport interface CommandRouterProps {\n path: string[];\n commands?: Record<string, CommandTree>;\n route?: Children;\n}\n\n/**\n * The command router component.\n */\nexport function CommandRouter(props: CommandRouterProps) {\n const { path, commands, route } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n const index = computed(() => 2 + (path.length ?? 0));\n\n return (\n <Show when={commands && Object.keys(commands).length > 0}>\n <VarDeclaration\n let\n name=\"command\"\n type=\"string\"\n initializer={code`\"\";`}\n />\n <hbr />\n <IfStatement\n condition={code`args.length > ${\n index.value\n } && args[${index.value}]`}>{code`command = args[${\n index.value\n }];`}</IfStatement>\n <hbr />\n <For each={Object.values(commands ?? {})}>\n {(subcommand, idx) => (\n <CommandContext.Provider value={subcommand}>\n <Show\n when={Boolean(idx)}\n fallback={\n <IfStatement\n condition={code`${\n context.config.isCaseSensitive\n ? \"command\"\n : 'command.toLowerCase().replaceAll(/-/g, \"\")'\n } === \"${\n context.config.isCaseSensitive\n ? subcommand.name\n : subcommand.name.toLowerCase().replaceAll(/-/g, \"\")\n }\"`}>\n <Show when={Boolean(route)} fallback={<CommandRouterRoute />}>\n {route}\n </Show>\n </IfStatement>\n }>\n <ElseIfClause\n condition={code`${\n context.config.isCaseSensitive\n ? \"command\"\n : 'command.toLowerCase().replaceAll(/-/g, \"\")'\n } === \"${\n context.config.isCaseSensitive\n ? subcommand.name\n : subcommand.name.toLowerCase().replaceAll(/-/g, \"\")\n }\"`}>\n <Show when={Boolean(route)} fallback={<CommandRouterRoute />}>\n {route}\n </Show>\n </ElseIfClause>\n </Show>\n <For each={subcommand.alias} doubleHardline>\n {alias => (\n <ElseIfClause\n condition={code`${\n context.config.isCaseSensitive\n ? \"command\"\n : 'command.toLowerCase().replaceAll(/-/g, \"\")'\n } === \"${\n context.config.isCaseSensitive\n ? alias\n : alias.toLowerCase().replaceAll(/-/g, \"\")\n }\"`}>\n <Show when={Boolean(route)} fallback={<CommandRouterRoute />}>\n {route}\n </Show>\n </ElseIfClause>\n )}\n </For>\n </CommandContext.Provider>\n )}\n </For>\n <ElseIfClause\n condition={code`Boolean(command)`}>{code`const suggestions = didYouMean(command, [${Object.values(\n commands ?? {}\n )\n .map(\n cmd =>\n `\"${cmd.name}\"${cmd.alias.map(alias => `\", \"${alias}\"`).join(\"\")}`\n )\n .join(\", \")}], {\n caseSensitive: ${JSON.stringify(context.config.isCaseSensitive)},\n returnType: ReturnTypeEnums.ALL_CLOSEST_MATCHES,\n thresholdType: ThresholdTypeEnums.SIMILARITY,\n threshold: 0.75\n });\n error(\\`Unknown command: \"\\${command}\"\\${suggestions && suggestions.length > 0 ? \\`, did you mean: \\${suggestions.length === 1 ? \\`\"\\${suggestions[0]}\"\\` : suggestions.map((suggestion, i) => i < suggestions.length - 1 ? \\`\"\\${suggestion}\", \\` : \\`or \"\\${suggestion}\"\\`)}?\\` : \"\"} \\`);`}</ElseIfClause>\n </Show>\n );\n}\n"],"mappings":";;;;;;;;;;AAiCA,SAAgBa,qBAAqB;CACnC,MAAMC,UAAUJ,YAAY;AAE5B,QAAA;EAAAK,gBAEKZ,MAAI;GAAA,IAACa,OAAI;AAAA,WAAE,CAACF,QAAQG;;GAAS,IAAAC,WAAA;AAAA,WAAAH,gBAC3BP,wBAAsB;KAAA,IACrBW,OAAI;AAAA,aAAE,SAASP,WAAWE,QAAQK,KAAK;;KAAE,IACzCC,aAAU;AAAA,aAAE,KACVN,QAAQO,KAAKC,SAASC,QACpBC,YAAW,CAACb,sBAAsBa,QACpC,CAAC,CACCV,QAAQO,KAAKC,SAASC,QACpBC,YAAW,CAACb,sBAAsBa,QACpC,CAAC,CAACC,SAAS;;KAGfC,YAAU;KAAA,CAAA;;GAAA,CAAA;EAAAC,gBAAA,OAAA,EAAA,CAAA;EAAAC,WAIb5B,IAAI,gBAAgBY,WAAWE,QAAQK,KAAK,CAAA,SAAS;EAAA;;;;;AAc5D,SAAgBU,cAAcC,OAA2B;CACvD,MAAM,EAAET,MAAMU,UAAUC,UAAUF;CAElC,MAAMG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E,CACAA,KAAK,KAAK,CAAA;2BACQC,KAAKC,UAAUzB,QAAQe,OAAOC,gBAAgB,CAAA;;;;;;;KAK4N,CAAA;IAAA;;EAAA,CAAA"}
@@ -984,7 +984,7 @@ function WriteLineFunctionDeclaration() {
984
984
  } else {
985
985
  const index = [" ", "/", "\\\\", ".", ",", "-", ":", "|", "@", "+"].reduce((ret, split) => {
986
986
  let current = ret;
987
- while (stripAnsi(line).indexOf(split, current + 1) !== -1 && stripAnsi(line).indexOf(split, current + 1) <= maxLength) {
987
+ 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
988
  current = line.indexOf(split, current + 1);
989
989
  }
990
990
 
@@ -1302,6 +1302,7 @@ function DividerFunctionDeclaration() {
1302
1302
  type: "number",
1303
1303
  doc: "The width of the divider line. If not specified, the divider will span the full width of the console, minus the padding."
1304
1304
  }),
1305
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
1305
1306
  (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
1306
1307
  heading: "The border of the divider line. Can be 'primary', 'secondary', 'tertiary', or 'none'. If not specified, the default border style will be used.",
1307
1308
  get children() {
@@ -1309,7 +1310,7 @@ function DividerFunctionDeclaration() {
1309
1310
  get type() {
1310
1311
  return __powerlines_deepkit_vendor_type.ReflectionKind.string;
1311
1312
  },
1312
- defaultValue: "\"primary\""
1313
+ defaultValue: "primary"
1313
1314
  })];
1314
1315
  }
1315
1316
  }),
@@ -1319,6 +1320,7 @@ function DividerFunctionDeclaration() {
1319
1320
  type: "\"primary\" | \"secondary\" | \"tertiary\"",
1320
1321
  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."
1321
1322
  }),
1323
+ (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
1322
1324
  (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
1323
1325
  heading: "Padding to apply to the line",
1324
1326
  get children() {
@@ -1360,11 +1362,11 @@ function DividerFunctionDeclaration() {
1360
1362
  optional: false
1361
1363
  }],
1362
1364
  get children() {
1363
- return __alloy_js_core.code`const padding = options.padding ?? ${theme.padding.app * 4};
1365
+ return __alloy_js_core.code`const padding = options.padding ?? ${Math.max(theme.padding.app, 1) * 4};
1364
1366
  const width = options.width ?? (process.stdout.columns - (Math.max(padding, 0) * 2));
1365
1367
  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}");
1366
1368
 
1367
- writeLine(" ".repeat(padding) + border.repeat(Math.max(width / ${theme.borderStyles.app.divider.primary.top.length ?? 1}, 0)));
1369
+ writeLine(" ".repeat(Math.max(padding - ${theme.padding.app}, 0)) + border.repeat(Math.max(width / ${theme.borderStyles.app.divider.primary.top.length ?? 1}, 0)));
1368
1370
  `;
1369
1371
  }
1370
1372
  })
@@ -1457,7 +1459,7 @@ function TableFunctionDeclaration(props) {
1457
1459
  get type() {
1458
1460
  return __powerlines_deepkit_vendor_type.ReflectionKind.property;
1459
1461
  },
1460
- defaultValue: "\"primary\""
1462
+ defaultValue: "primary"
1461
1463
  })
1462
1464
  ];
1463
1465
  }
@@ -1501,7 +1503,7 @@ function TableFunctionDeclaration(props) {
1501
1503
  get type() {
1502
1504
  return __powerlines_deepkit_vendor_type.ReflectionKind.property;
1503
1505
  },
1504
- defaultValue: "\"left\""
1506
+ defaultValue: "left"
1505
1507
  })
1506
1508
  ];
1507
1509
  }
@@ -1823,14 +1825,17 @@ let colWidths = [] as number[];
1823
1825
  let rowDims = [] as Dimensions[];
1824
1826
 
1825
1827
  const calculateRowDimensions = () => {
1828
+ colWidths = [];
1826
1829
  return cells.reduce((dims, row) => {
1827
- dims.push(row.reduce((dim, cell) => {
1828
- if (cell.width > dim.width) {
1829
- dim.width = cell.width;
1830
- }
1830
+ dims.push(row.reduce((dim, cell, index) => {
1831
+ dim.width += cell.width;
1831
1832
  if (cell.height > dim.height) {
1832
1833
  dim.height = cell.height;
1833
1834
  }
1835
+ if (!colWidths[index] || cell.width > colWidths[index]!) {
1836
+ colWidths[index] = cell.width;
1837
+ }
1838
+
1834
1839
  return dim;
1835
1840
  }, { width: 0, height: 0 } as Dimensions));
1836
1841
 
@@ -1838,14 +1843,13 @@ const calculateRowDimensions = () => {
1838
1843
  }, [] as Dimensions[]);
1839
1844
  }
1840
1845
 
1841
- const maxWidth = Math.max(process.stdout.columns - ${Math.max(theme.padding.app, 0) * 2}, 0);
1842
- rowDims = calculateRowDimensions();
1843
-
1844
1846
  let recalculate!: boolean;
1845
1847
  do {
1846
1848
  recalculate = false;
1847
- rowDims.map((row, rowIndex) => {
1848
- if (row.width > maxWidth) {
1849
+ rowDims = calculateRowDimensions();
1850
+
1851
+ rowDims.forEach((row, rowIndex) => {
1852
+ if (!recalculate && row.width > Math.max(process.stdout.columns - ${Math.max(theme.padding.app, 0) * 2}, 0)) {
1849
1853
  const cell = cells[rowIndex]!.reduce((largestCell, cell) => {
1850
1854
  if (cell.width > largestCell.width) {
1851
1855
  return cell;
@@ -1855,7 +1859,7 @@ do {
1855
1859
 
1856
1860
  const lines = splitText(
1857
1861
  cell.value,
1858
- maxWidth - row.width - cell.width
1862
+ Math.max(process.stdout.columns - ${Math.max(theme.padding.app, 0) * 2} - (row.width - (cell.width - cell.padding * 2)), 0)
1859
1863
  );
1860
1864
 
1861
1865
  cell.value = lines.join("\\n");
@@ -1866,49 +1870,68 @@ do {
1866
1870
  }
1867
1871
  });
1868
1872
 
1869
- if (recalculate) {
1870
- rowDims = calculateRowDimensions();
1873
+ if (!recalculate && colWidths.reduce((a, b) => a + b, 0) > Math.max(process.stdout.columns - ${Math.max(theme.padding.app, 0) * 2}, 0)) {
1874
+ let colIndex = 0;
1875
+ const cell = cells.reduce((ret, row) => {
1876
+ return row.reduce((largest, current, i) => {
1877
+ if (largest.width < current.width) {
1878
+ colIndex = i;
1879
+ return current;
1880
+ }
1881
+ return largest;
1882
+ }, ret);
1883
+ }, cells[0]![0]!);
1884
+
1885
+ const lines = splitText(
1886
+ cell.value,
1887
+ 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)
1888
+ );
1889
+
1890
+ cell.value = lines.join("\\n");
1891
+ cell.height = lines.length;
1892
+ cell.width = Math.max(...lines.map(line => stripAnsi(line).length)) + cell.padding * 2;
1893
+
1894
+ recalculate = true;
1871
1895
  }
1872
1896
  } while (recalculate);
1873
1897
 
1874
- rowDims.map((row, rowIndex) => {
1875
- cells[rowIndex]!.forEach(cell => {
1876
- cell.height = row.height;
1877
- });
1878
- });
1879
-
1880
1898
  // Render table
1881
- cells.forEach(row => {
1882
- let line = "";
1899
+ cells.forEach((row, rowIndex) => {
1900
+ const outputs = [] as string[][];
1883
1901
  row.forEach((cell, colIndex) => {
1884
- const cellContent = cell.value;
1885
- let paddedContent = "";
1886
- const totalPadding = cell.padding * 2;
1887
- const contentLength = stripAnsi(cellContent).length;
1888
- const totalWidth = colWidths[colIndex] ?? contentLength + totalPadding;
1889
-
1890
- switch (cell.align) {
1891
- case "right":
1892
- paddedContent = " ".repeat(totalWidth - contentLength - totalPadding) + cellContent + " ".repeat(totalPadding);
1893
- break;
1894
- case "center":
1895
- const leftPadding = Math.floor((totalWidth - contentLength - totalPadding) / 2);
1896
- const rightPadding = totalWidth - contentLength - totalPadding - leftPadding;
1897
- paddedContent = " ".repeat(leftPadding) + cellContent + " ".repeat(rightPadding + totalPadding);
1898
- break;
1899
- case "left":
1900
- default:
1901
- paddedContent = " ".repeat(totalPadding) + cellContent + " ".repeat(totalWidth - contentLength - totalPadding);
1902
- break;
1902
+ const lines = cell.value.split("\\n");
1903
+ while (lines.length < rowDims[rowIndex]!.height) {
1904
+ lines.push("");
1903
1905
  }
1904
1906
 
1905
- line += cell.border.left + paddedContent;
1906
- if (colIndex === row.length - 1) {
1907
- line += paddedContent + cell.border.right;
1908
- }
1907
+ outputs.push(lines.map(line => {
1908
+ let paddedContent = "";
1909
+ switch (cell.align) {
1910
+ case "right":
1911
+ paddedContent = " ".repeat(Math.max(colWidths[colIndex] - stripAnsi(line).length - cell.padding, 0)) + line + " ".repeat(cell.padding);
1912
+ break;
1913
+ case "center":
1914
+ const leftPadding = Math.floor((colWidths[colIndex] - stripAnsi(line).length - cell.padding) / 2);
1915
+ const rightPadding = colWidths[colIndex] - stripAnsi(line).length - leftPadding;
1916
+ paddedContent = " ".repeat(leftPadding) + line + " ".repeat(rightPadding);
1917
+ break;
1918
+ case "left":
1919
+ default:
1920
+ paddedContent = " ".repeat(cell.padding) + line + " ".repeat(Math.max(colWidths[colIndex] - stripAnsi(line).length - cell.padding, 0));
1921
+ break;
1922
+ }
1923
+
1924
+ if (colIndex === row.length - 1) {
1925
+ return cell.border.left + paddedContent + cell.border.right;
1926
+ } else {
1927
+ return cell.border.left + paddedContent;
1928
+ }
1929
+ }));
1909
1930
  });
1910
1931
 
1911
- writeLine(line);
1932
+ for (let index = 0; index < rowDims[rowIndex]!.height; index++) {
1933
+ writeLine(outputs.map(output => output[index] ?? "").join(""));
1934
+ }
1912
1935
  });
1913
1936
  `)
1914
1937
  ];
@@ -2005,7 +2028,7 @@ function ConsoleBuiltin() {
2005
2028
  description: "verbose",
2006
2029
  get prefix() {
2007
2030
  return (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.IfStatement, {
2008
- condition: __alloy_js_core.code`!(isDevelopment || isDebug || env.LOG_LEVEL === "debug" || hasFlag(["verbose", "verbose=true", "verbose=always", "debug", "debug=true", "debug=always"]))`,
2031
+ condition: __alloy_js_core.code`!(isDevelopment || isDebug || env.LOG_LEVEL === "debug" || hasFlag(["verbose", "verbose=true", "verbose=always"]))`,
2009
2032
  children: __alloy_js_core.code`return; `
2010
2033
  });
2011
2034
  }