@shell-shock/plugin-console 0.2.3 → 0.2.5
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.
|
@@ -141,7 +141,7 @@ function AnsiHelpersDeclarations() {
|
|
|
141
141
|
* A component to generate a console message function in a Shell Shock project.
|
|
142
142
|
*/
|
|
143
143
|
function ColorFunction({ ansi16, ansi256, ansi16m, skipBackground = false }) {
|
|
144
|
-
return _alloy_js_core.code` (text: string${skipBackground ? "" : `, background = false`}): string => {
|
|
144
|
+
return _alloy_js_core.code` (text: string | number | boolean | null | undefined${skipBackground ? "" : `, background = false`}): string => {
|
|
145
145
|
try {
|
|
146
146
|
if (text === undefined || text === null || text === "") {
|
|
147
147
|
return "";
|
|
@@ -152,12 +152,12 @@ function ColorFunction({ ansi16, ansi256, ansi16m, skipBackground = false }) {
|
|
|
152
152
|
}
|
|
153
153
|
|
|
154
154
|
if (colorSupportLevels.stdout === 1) {
|
|
155
|
-
return wrapAnsi(text, ${skipBackground ? `"${ansi16.open}", "${ansi16.close}"` : `background ? "${ansi16.background.open}" : "${ansi16.open}", background ? "${ansi16.background.close}" : "${ansi16.close}"`});
|
|
155
|
+
return wrapAnsi(String(text), ${skipBackground ? `"${ansi16.open}", "${ansi16.close}"` : `background ? "${ansi16.background.open}" : "${ansi16.open}", background ? "${ansi16.background.close}" : "${ansi16.close}"`});
|
|
156
156
|
} else if (colorSupportLevels.stdout === 2) {
|
|
157
|
-
return wrapAnsi(text, ${skipBackground ? `"${ansi256.open}", "${ansi256.close}"` : `background ? "${ansi256.background.open}" : "${ansi256.open}", background ? "${ansi256.background.close}" : "${ansi256.close}"`});
|
|
157
|
+
return wrapAnsi(String(text), ${skipBackground ? `"${ansi256.open}", "${ansi256.close}"` : `background ? "${ansi256.background.open}" : "${ansi256.open}", background ? "${ansi256.background.close}" : "${ansi256.close}"`});
|
|
158
158
|
}
|
|
159
159
|
|
|
160
|
-
return wrapAnsi(text, ${skipBackground ? `"${ansi16m.open}", "${ansi16m.close}"` : `background ? "${ansi16m.background.open}" : "${ansi16m.open}", background ? "${ansi16m.background.close}" : "${ansi16m.close}"`});
|
|
160
|
+
return wrapAnsi(String(text), ${skipBackground ? `"${ansi16m.open}", "${ansi16m.close}"` : `background ? "${ansi16m.background.open}" : "${ansi16m.open}", background ? "${ansi16m.background.close}" : "${ansi16m.close}"`});
|
|
161
161
|
} catch {
|
|
162
162
|
return String(text);
|
|
163
163
|
}
|
|
@@ -813,14 +813,14 @@ function MessageFunctionDeclaration(props) {
|
|
|
813
813
|
|
|
814
814
|
${!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())}\`; ` : ""}
|
|
815
815
|
|
|
816
|
-
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(
|
|
816
|
+
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} });
|
|
817
817
|
splitText(
|
|
818
818
|
message,
|
|
819
|
-
Math.max(
|
|
819
|
+
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}, 0)
|
|
820
820
|
).forEach((line) => {
|
|
821
|
-
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(
|
|
821
|
+
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} });
|
|
822
822
|
});
|
|
823
|
-
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(
|
|
823
|
+
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} });
|
|
824
824
|
`)];
|
|
825
825
|
}
|
|
826
826
|
})];
|
|
@@ -1013,7 +1013,7 @@ function DividerFunctionDeclaration() {
|
|
|
1013
1013
|
}],
|
|
1014
1014
|
get children() {
|
|
1015
1015
|
return _alloy_js_core.code`const padding = options.padding ?? ${Math.max(theme.padding.app, 1) * 4};
|
|
1016
|
-
const width = options.width ?? (
|
|
1016
|
+
const width = options.width ?? (getTerminalSize().columns - (Math.max(padding, 0) * 2));
|
|
1017
1017
|
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}");
|
|
1018
1018
|
|
|
1019
1019
|
writeLine(" ".repeat(Math.max(padding - ${theme.padding.app}, 0)) + border.repeat(Math.max(width / ${theme.borderStyles.app.divider.primary.top.length ?? 1}, 0)));
|
|
@@ -1026,6 +1026,7 @@ function DividerFunctionDeclaration() {
|
|
|
1026
1026
|
* A component to generate the `link` function in the `shell-shock:console` builtin module.
|
|
1027
1027
|
*/
|
|
1028
1028
|
function LinkFunctionDeclaration() {
|
|
1029
|
+
const theme = (0, _shell_shock_plugin_theme_contexts_theme.useTheme)();
|
|
1029
1030
|
return [(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
1030
1031
|
heading: "Render a hyperlink in the console.",
|
|
1031
1032
|
get children() {
|
|
@@ -1035,8 +1036,12 @@ function LinkFunctionDeclaration() {
|
|
|
1035
1036
|
children: `The URL to render as a hyperlink.`
|
|
1036
1037
|
}),
|
|
1037
1038
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
1038
|
-
name: "
|
|
1039
|
-
children: `The text to display for the link. If
|
|
1039
|
+
name: "textOrExternal",
|
|
1040
|
+
children: `The text to display for the link or a boolean indicating whether the link is external. If no text is provided, the URL will be used as the text. If a boolean is provided and is true, the URL will be used as the text and the link will be rendered as an external link.`
|
|
1041
|
+
}),
|
|
1042
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
1043
|
+
name: "external",
|
|
1044
|
+
children: `A boolean indicating whether the link is external. If true, the link will be rendered as an external link.`
|
|
1040
1045
|
}),
|
|
1041
1046
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns, { children: `The formatted hyperlink string.` })
|
|
1042
1047
|
];
|
|
@@ -1044,28 +1049,40 @@ function LinkFunctionDeclaration() {
|
|
|
1044
1049
|
}), (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
1045
1050
|
"export": true,
|
|
1046
1051
|
name: "link",
|
|
1047
|
-
parameters: [
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1052
|
+
parameters: [
|
|
1053
|
+
{
|
|
1054
|
+
name: "url",
|
|
1055
|
+
type: "string",
|
|
1056
|
+
optional: false
|
|
1057
|
+
},
|
|
1058
|
+
{
|
|
1059
|
+
name: "textOrExternal",
|
|
1060
|
+
type: "string | boolean",
|
|
1061
|
+
optional: true
|
|
1062
|
+
},
|
|
1063
|
+
{
|
|
1064
|
+
name: "external",
|
|
1065
|
+
type: "boolean",
|
|
1066
|
+
optional: true
|
|
1067
|
+
}
|
|
1068
|
+
],
|
|
1056
1069
|
get children() {
|
|
1057
1070
|
return [
|
|
1058
1071
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
|
|
1059
1072
|
condition: _alloy_js_core.code`isHyperlinkSupported()`,
|
|
1060
|
-
children
|
|
1073
|
+
get children() {
|
|
1074
|
+
return _alloy_js_core.code`return \`\\x1b]8;;\${url}\\u0007\${typeof textOrExternal === "string" && textOrExternal ? textOrExternal : url}\\x1b]8;;\\u0007\${external === true || textOrExternal === true ? "${theme.icons.link.external}" : ""}\`;`;
|
|
1075
|
+
}
|
|
1061
1076
|
}),
|
|
1062
1077
|
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1063
1078
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
|
|
1064
1079
|
condition: _alloy_js_core.code`isColorSupported`,
|
|
1065
|
-
children
|
|
1080
|
+
get children() {
|
|
1081
|
+
return _alloy_js_core.code`return \`\${underline(textColors.body.link(\`\${url}\`))}\${external === true || textOrExternal === true ? "${theme.icons.link.external}" : ""}\`;`;
|
|
1082
|
+
}
|
|
1066
1083
|
}),
|
|
1067
1084
|
(0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
|
|
1068
|
-
_alloy_js_core.code`return \`\${url}\`;`
|
|
1085
|
+
(0, _alloy_js_core_jsx_runtime.memo)(() => _alloy_js_core.code`return \`\${url}\${external === true || textOrExternal === true ? "${theme.icons.link.external}" : ""}\`;`)
|
|
1069
1086
|
];
|
|
1070
1087
|
}
|
|
1071
1088
|
})];
|
|
@@ -1074,6 +1091,7 @@ function LinkFunctionDeclaration() {
|
|
|
1074
1091
|
* A component to generate the `blockquote` function declaration
|
|
1075
1092
|
*/
|
|
1076
1093
|
function BlockquoteFunctionDeclaration() {
|
|
1094
|
+
const theme = (0, _shell_shock_plugin_theme_contexts_theme.useTheme)();
|
|
1077
1095
|
return [
|
|
1078
1096
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
|
|
1079
1097
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
@@ -1094,16 +1112,18 @@ function BlockquoteFunctionDeclaration() {
|
|
|
1094
1112
|
optional: true
|
|
1095
1113
|
}],
|
|
1096
1114
|
returnType: "string",
|
|
1097
|
-
children
|
|
1115
|
+
get children() {
|
|
1116
|
+
return _alloy_js_core.code`if (text === undefined || text === null || text === "") {
|
|
1098
1117
|
return "";
|
|
1099
1118
|
}
|
|
1100
1119
|
|
|
1101
1120
|
const lines = splitText(
|
|
1102
1121
|
String(text),
|
|
1103
|
-
Math.max(
|
|
1122
|
+
Math.max(getTerminalSize().columns, 20) - 6
|
|
1104
1123
|
);
|
|
1105
1124
|
|
|
1106
|
-
return lines.map(
|
|
1125
|
+
return lines.map(line => \`\${borderColors.app.blockquote.primary(isUnicodeSupported() ? "${theme.borderStyles.app.blockquote.primary.left}" : "|")} \${italic(line)} \`).join("\\n"); `;
|
|
1126
|
+
}
|
|
1107
1127
|
})
|
|
1108
1128
|
];
|
|
1109
1129
|
}
|
|
@@ -1141,10 +1161,12 @@ function CodeFunctionDeclaration() {
|
|
|
1141
1161
|
return "";
|
|
1142
1162
|
}
|
|
1143
1163
|
|
|
1144
|
-
|
|
1164
|
+
const lines = splitText(
|
|
1145
1165
|
String(text),
|
|
1146
|
-
Math.max(
|
|
1147
|
-
)
|
|
1166
|
+
Math.max(getTerminalSize().columns, 20)
|
|
1167
|
+
);
|
|
1168
|
+
|
|
1169
|
+
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")}\`; `;
|
|
1148
1170
|
}
|
|
1149
1171
|
})
|
|
1150
1172
|
];
|
|
@@ -1786,7 +1808,7 @@ function TableFunctionDeclaration(props) {
|
|
|
1786
1808
|
heading: "Calculate the width in characters based on the provided width size.",
|
|
1787
1809
|
get children() {
|
|
1788
1810
|
return [
|
|
1789
|
-
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocRemarks, { children: `This function calculates the width in characters based on the provided width size, which can be a predefined string (e.g., "full", "1/2", "1/3", etc.) or a percentage string (e.g., "50%"). The calculation is based on the current width of the console (
|
|
1811
|
+
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocRemarks, { children: `This function calculates the width in characters based on the provided width size, which can be a predefined string (e.g., "full", "1/2", "1/3", etc.) or a percentage string (e.g., "50%"). The calculation is based on the current width of the console (getTerminalSize().columns).` }),
|
|
1790
1812
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
|
|
1791
1813
|
name: "size",
|
|
1792
1814
|
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%").`
|
|
@@ -1808,40 +1830,40 @@ function TableFunctionDeclaration(props) {
|
|
|
1808
1830
|
return [
|
|
1809
1831
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.IfStatement, {
|
|
1810
1832
|
condition: _alloy_js_core.code`["full", "100%", "1/1"]. includes(size)`,
|
|
1811
|
-
children: _alloy_js_core.code`return
|
|
1833
|
+
children: _alloy_js_core.code`return getTerminalSize().columns;`
|
|
1812
1834
|
}),
|
|
1813
1835
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.ElseIfClause, {
|
|
1814
1836
|
condition: _alloy_js_core.code`["1/2", "50%"].includes(size)`,
|
|
1815
|
-
children: _alloy_js_core.code`return Math.round(
|
|
1837
|
+
children: _alloy_js_core.code`return Math.round(getTerminalSize().columns / 2);`
|
|
1816
1838
|
}),
|
|
1817
1839
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.ElseIfClause, {
|
|
1818
1840
|
condition: _alloy_js_core.code`["1/3", "33.33%"].includes(size)`,
|
|
1819
|
-
children: _alloy_js_core.code`return Math.round(
|
|
1841
|
+
children: _alloy_js_core.code`return Math.round(getTerminalSize().columns / 3);`
|
|
1820
1842
|
}),
|
|
1821
1843
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.ElseIfClause, {
|
|
1822
1844
|
condition: _alloy_js_core.code`["1/4", "25%"].includes(size)`,
|
|
1823
|
-
children: _alloy_js_core.code`return Math.round(
|
|
1845
|
+
children: _alloy_js_core.code`return Math.round(getTerminalSize().columns / 4);`
|
|
1824
1846
|
}),
|
|
1825
1847
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.ElseIfClause, {
|
|
1826
1848
|
condition: _alloy_js_core.code`["1/5", "20%"].includes(size)`,
|
|
1827
|
-
children: _alloy_js_core.code`return Math.round(
|
|
1849
|
+
children: _alloy_js_core.code`return Math.round(getTerminalSize().columns / 5);`
|
|
1828
1850
|
}),
|
|
1829
1851
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.ElseIfClause, {
|
|
1830
1852
|
condition: _alloy_js_core.code`["1/6", "10%"].includes(size)`,
|
|
1831
|
-
children: _alloy_js_core.code`return Math.round(
|
|
1853
|
+
children: _alloy_js_core.code`return Math.round(getTerminalSize().columns / 6);`
|
|
1832
1854
|
}),
|
|
1833
1855
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.ElseIfClause, {
|
|
1834
1856
|
condition: _alloy_js_core.code`["1/12", "5%"].includes(size)`,
|
|
1835
|
-
children: _alloy_js_core.code`return Math.round(
|
|
1857
|
+
children: _alloy_js_core.code`return Math.round(getTerminalSize().columns / 12);`
|
|
1836
1858
|
}),
|
|
1837
1859
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.ElseIfClause, {
|
|
1838
1860
|
condition: _alloy_js_core.code`["1/24", "2.5%"].includes(size)`,
|
|
1839
|
-
children: _alloy_js_core.code`return Math.round(
|
|
1861
|
+
children: _alloy_js_core.code`return Math.round(getTerminalSize().columns / 24);`
|
|
1840
1862
|
}),
|
|
1841
1863
|
(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.ElseClause, { children: _alloy_js_core.code`
|
|
1842
1864
|
const match = size.match(/(\\d+(\\.\\d+)?)%/);
|
|
1843
1865
|
if (match) {
|
|
1844
|
-
return Math.round((
|
|
1866
|
+
return Math.round((getTerminalSize().columns * parseFloat(match[1])) / 100);
|
|
1845
1867
|
}
|
|
1846
1868
|
|
|
1847
1869
|
throw new Error(\`Invalid width size: \${size}\`);
|
|
@@ -2328,7 +2350,7 @@ do {
|
|
|
2328
2350
|
}
|
|
2329
2351
|
|
|
2330
2352
|
rowDims.forEach((row, rowIndex) => {
|
|
2331
|
-
if (!recalculate && row.width > Math.max(
|
|
2353
|
+
if (!recalculate && row.width > Math.max(getTerminalSize().columns - ${Math.max(theme.padding.app, 0) * 2}, 0)) {
|
|
2332
2354
|
const cell = cells[rowIndex]!.reduce((largestCell, cell) => {
|
|
2333
2355
|
if (cell.width > largestCell.width) {
|
|
2334
2356
|
return cell;
|
|
@@ -2338,7 +2360,7 @@ do {
|
|
|
2338
2360
|
|
|
2339
2361
|
const lines = splitText(
|
|
2340
2362
|
cell.value,
|
|
2341
|
-
Math.min(Math.max(
|
|
2363
|
+
Math.min(Math.max(getTerminalSize().columns - ${Math.max(theme.padding.app, 0) * 2} - (row.width - (cell.width - cell.padding * 2)), 0),
|
|
2342
2364
|
cell.maxWidth ?? Number.POSITIVE_INFINITY)
|
|
2343
2365
|
);
|
|
2344
2366
|
|
|
@@ -2350,7 +2372,7 @@ do {
|
|
|
2350
2372
|
}
|
|
2351
2373
|
});
|
|
2352
2374
|
|
|
2353
|
-
if (!recalculate && colWidths.reduce((a, b) => a + b, 0) > Math.max(
|
|
2375
|
+
if (!recalculate && colWidths.reduce((a, b) => a + b, 0) > Math.max(getTerminalSize().columns - ${Math.max(theme.padding.app, 0) * 2}, 0)) {
|
|
2354
2376
|
let colIndex = 0;
|
|
2355
2377
|
const cell = cells.reduce((ret, row) => {
|
|
2356
2378
|
return row.reduce((largest, current, index) => {
|
|
@@ -2364,7 +2386,7 @@ do {
|
|
|
2364
2386
|
|
|
2365
2387
|
const lines = splitText(
|
|
2366
2388
|
cell.value,
|
|
2367
|
-
Math.min(Math.max(
|
|
2389
|
+
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),
|
|
2368
2390
|
cell.maxWidth ?? Number.POSITIVE_INFINITY)
|
|
2369
2391
|
);
|
|
2370
2392
|
|
|
@@ -2453,7 +2475,8 @@ function ConsoleBuiltin(props) {
|
|
|
2453
2475
|
"isColorSupported",
|
|
2454
2476
|
"colorSupportLevels",
|
|
2455
2477
|
"isUnicodeSupported",
|
|
2456
|
-
"isHyperlinkSupported"
|
|
2478
|
+
"isHyperlinkSupported",
|
|
2479
|
+
"getTerminalSize"
|
|
2457
2480
|
],
|
|
2458
2481
|
env: [
|
|
2459
2482
|
"env",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"console-builtin.d.cts","names":[],"sources":["../../src/components/console-builtin.tsx"],"mappings":";;;;;;;iBAkEgB,uBAAA,CAAA,GAAuB,QAAA;AAAA,UA8L7B,cAAA;EAAA,CACP,GAAA,WAAc,iBAAA,GAAoB,cAAA;AAAA;AAAA,UAG3B,yBAAA;EACR,IAAA;EACA,OAAA;EACA,MAAA,EAAQ,cAAA;EACR,OAAA,EAAS,cAAA;EACT,OAAA,EAAS,cAAA;AAAA;AAAA,iBAGK,wBAAA,CAAyB,KAAA,EAAO,yBAAA,GAAyB,QAAA;AAAA,iBA0EzD,0BAAA,CAA2B,KAAA,EAAO,yBAAA,GAAyB,QAAA;;;;iBA8E3D,6BAAA,CAAA,GAA6B,QAAA;;;;iBA0J7B,4BAAA,CAAA,GAA4B,QAAA;;;;iBAiL5B,wBAAA,CAAA,GAAwB,QAAA;;;;iBAgExB,4BAAA,CAAA,GAA4B,QAAA;AAAA,KAqEhC,+BAAA,GAAkC,OAAA,CAC5C,IAAA,CAAK,wBAAA;EAEL,IAAA;EASA,OAAA,EAAS,mBAAA;EACT,KAAA,GAAQ,mBAAA;EACR,aAAA;EACA,WAAA;EACA,MAAA,GAAS,QAAA;EACT,SAAA;AAAA;;;;iBAMc,0BAAA,CACd,KAAA,EAAO,+BAAA,GAA+B,QAAA;;AAtjBxC;;iBAwuBgB,gBAAA,CAAA,GAAgB,QAAA;;;;iBA4EhB,4BAAA,CAAA,GAA4B,QAAA;;;AAtuB5C;iBAywBgB,0BAAA,CAAA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hB9B,6BAAA,GAAgC,IAAA,CAC1C,wBAAA;;;;iBAOc,wBAAA,CAAyB,KAAA,EAAO,6BAAA,GAA6B,QAAA;AAAA,KA0nBjE,mBAAA,GAAsB,IAAA,CAChC,gBAAA;;;;iBAOc,cAAA,CAAe,KAAA,EAAO,mBAAA,GAAmB,QAAA"}
|
|
@@ -139,7 +139,7 @@ function AnsiHelpersDeclarations() {
|
|
|
139
139
|
* A component to generate a console message function in a Shell Shock project.
|
|
140
140
|
*/
|
|
141
141
|
function ColorFunction({ ansi16, ansi256, ansi16m, skipBackground = false }) {
|
|
142
|
-
return code` (text: string${skipBackground ? "" : `, background = false`}): string => {
|
|
142
|
+
return code` (text: string | number | boolean | null | undefined${skipBackground ? "" : `, background = false`}): string => {
|
|
143
143
|
try {
|
|
144
144
|
if (text === undefined || text === null || text === "") {
|
|
145
145
|
return "";
|
|
@@ -150,12 +150,12 @@ function ColorFunction({ ansi16, ansi256, ansi16m, skipBackground = false }) {
|
|
|
150
150
|
}
|
|
151
151
|
|
|
152
152
|
if (colorSupportLevels.stdout === 1) {
|
|
153
|
-
return wrapAnsi(text, ${skipBackground ? `"${ansi16.open}", "${ansi16.close}"` : `background ? "${ansi16.background.open}" : "${ansi16.open}", background ? "${ansi16.background.close}" : "${ansi16.close}"`});
|
|
153
|
+
return wrapAnsi(String(text), ${skipBackground ? `"${ansi16.open}", "${ansi16.close}"` : `background ? "${ansi16.background.open}" : "${ansi16.open}", background ? "${ansi16.background.close}" : "${ansi16.close}"`});
|
|
154
154
|
} else if (colorSupportLevels.stdout === 2) {
|
|
155
|
-
return wrapAnsi(text, ${skipBackground ? `"${ansi256.open}", "${ansi256.close}"` : `background ? "${ansi256.background.open}" : "${ansi256.open}", background ? "${ansi256.background.close}" : "${ansi256.close}"`});
|
|
155
|
+
return wrapAnsi(String(text), ${skipBackground ? `"${ansi256.open}", "${ansi256.close}"` : `background ? "${ansi256.background.open}" : "${ansi256.open}", background ? "${ansi256.background.close}" : "${ansi256.close}"`});
|
|
156
156
|
}
|
|
157
157
|
|
|
158
|
-
return wrapAnsi(text, ${skipBackground ? `"${ansi16m.open}", "${ansi16m.close}"` : `background ? "${ansi16m.background.open}" : "${ansi16m.open}", background ? "${ansi16m.background.close}" : "${ansi16m.close}"`});
|
|
158
|
+
return wrapAnsi(String(text), ${skipBackground ? `"${ansi16m.open}", "${ansi16m.close}"` : `background ? "${ansi16m.background.open}" : "${ansi16m.open}", background ? "${ansi16m.background.close}" : "${ansi16m.close}"`});
|
|
159
159
|
} catch {
|
|
160
160
|
return String(text);
|
|
161
161
|
}
|
|
@@ -811,14 +811,14 @@ function MessageFunctionDeclaration(props) {
|
|
|
811
811
|
|
|
812
812
|
${!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())}\`; ` : ""}
|
|
813
813
|
|
|
814
|
-
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(
|
|
814
|
+
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} });
|
|
815
815
|
splitText(
|
|
816
816
|
message,
|
|
817
|
-
Math.max(
|
|
817
|
+
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}, 0)
|
|
818
818
|
).forEach((line) => {
|
|
819
|
-
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(
|
|
819
|
+
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} });
|
|
820
820
|
});
|
|
821
|
-
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(
|
|
821
|
+
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} });
|
|
822
822
|
`)];
|
|
823
823
|
}
|
|
824
824
|
})];
|
|
@@ -1011,7 +1011,7 @@ function DividerFunctionDeclaration() {
|
|
|
1011
1011
|
}],
|
|
1012
1012
|
get children() {
|
|
1013
1013
|
return code`const padding = options.padding ?? ${Math.max(theme.padding.app, 1) * 4};
|
|
1014
|
-
const width = options.width ?? (
|
|
1014
|
+
const width = options.width ?? (getTerminalSize().columns - (Math.max(padding, 0) * 2));
|
|
1015
1015
|
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}");
|
|
1016
1016
|
|
|
1017
1017
|
writeLine(" ".repeat(Math.max(padding - ${theme.padding.app}, 0)) + border.repeat(Math.max(width / ${theme.borderStyles.app.divider.primary.top.length ?? 1}, 0)));
|
|
@@ -1024,6 +1024,7 @@ function DividerFunctionDeclaration() {
|
|
|
1024
1024
|
* A component to generate the `link` function in the `shell-shock:console` builtin module.
|
|
1025
1025
|
*/
|
|
1026
1026
|
function LinkFunctionDeclaration() {
|
|
1027
|
+
const theme = useTheme();
|
|
1027
1028
|
return [createComponent(TSDoc, {
|
|
1028
1029
|
heading: "Render a hyperlink in the console.",
|
|
1029
1030
|
get children() {
|
|
@@ -1033,8 +1034,12 @@ function LinkFunctionDeclaration() {
|
|
|
1033
1034
|
children: `The URL to render as a hyperlink.`
|
|
1034
1035
|
}),
|
|
1035
1036
|
createComponent(TSDocParam, {
|
|
1036
|
-
name: "
|
|
1037
|
-
children: `The text to display for the link. If
|
|
1037
|
+
name: "textOrExternal",
|
|
1038
|
+
children: `The text to display for the link or a boolean indicating whether the link is external. If no text is provided, the URL will be used as the text. If a boolean is provided and is true, the URL will be used as the text and the link will be rendered as an external link.`
|
|
1039
|
+
}),
|
|
1040
|
+
createComponent(TSDocParam, {
|
|
1041
|
+
name: "external",
|
|
1042
|
+
children: `A boolean indicating whether the link is external. If true, the link will be rendered as an external link.`
|
|
1038
1043
|
}),
|
|
1039
1044
|
createComponent(TSDocReturns, { children: `The formatted hyperlink string.` })
|
|
1040
1045
|
];
|
|
@@ -1042,28 +1047,40 @@ function LinkFunctionDeclaration() {
|
|
|
1042
1047
|
}), createComponent(FunctionDeclaration, {
|
|
1043
1048
|
"export": true,
|
|
1044
1049
|
name: "link",
|
|
1045
|
-
parameters: [
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1050
|
+
parameters: [
|
|
1051
|
+
{
|
|
1052
|
+
name: "url",
|
|
1053
|
+
type: "string",
|
|
1054
|
+
optional: false
|
|
1055
|
+
},
|
|
1056
|
+
{
|
|
1057
|
+
name: "textOrExternal",
|
|
1058
|
+
type: "string | boolean",
|
|
1059
|
+
optional: true
|
|
1060
|
+
},
|
|
1061
|
+
{
|
|
1062
|
+
name: "external",
|
|
1063
|
+
type: "boolean",
|
|
1064
|
+
optional: true
|
|
1065
|
+
}
|
|
1066
|
+
],
|
|
1054
1067
|
get children() {
|
|
1055
1068
|
return [
|
|
1056
1069
|
createComponent(IfStatement, {
|
|
1057
1070
|
condition: code`isHyperlinkSupported()`,
|
|
1058
|
-
children
|
|
1071
|
+
get children() {
|
|
1072
|
+
return code`return \`\\x1b]8;;\${url}\\u0007\${typeof textOrExternal === "string" && textOrExternal ? textOrExternal : url}\\x1b]8;;\\u0007\${external === true || textOrExternal === true ? "${theme.icons.link.external}" : ""}\`;`;
|
|
1073
|
+
}
|
|
1059
1074
|
}),
|
|
1060
1075
|
createIntrinsic("hbr", {}),
|
|
1061
1076
|
createComponent(IfStatement, {
|
|
1062
1077
|
condition: code`isColorSupported`,
|
|
1063
|
-
children
|
|
1078
|
+
get children() {
|
|
1079
|
+
return code`return \`\${underline(textColors.body.link(\`\${url}\`))}\${external === true || textOrExternal === true ? "${theme.icons.link.external}" : ""}\`;`;
|
|
1080
|
+
}
|
|
1064
1081
|
}),
|
|
1065
1082
|
createIntrinsic("hbr", {}),
|
|
1066
|
-
code`return \`\${url}\`;`
|
|
1083
|
+
memo(() => code`return \`\${url}\${external === true || textOrExternal === true ? "${theme.icons.link.external}" : ""}\`;`)
|
|
1067
1084
|
];
|
|
1068
1085
|
}
|
|
1069
1086
|
})];
|
|
@@ -1072,6 +1089,7 @@ function LinkFunctionDeclaration() {
|
|
|
1072
1089
|
* A component to generate the `blockquote` function declaration
|
|
1073
1090
|
*/
|
|
1074
1091
|
function BlockquoteFunctionDeclaration() {
|
|
1092
|
+
const theme = useTheme();
|
|
1075
1093
|
return [
|
|
1076
1094
|
createComponent(Spacing, {}),
|
|
1077
1095
|
createComponent(TSDoc, {
|
|
@@ -1092,16 +1110,18 @@ function BlockquoteFunctionDeclaration() {
|
|
|
1092
1110
|
optional: true
|
|
1093
1111
|
}],
|
|
1094
1112
|
returnType: "string",
|
|
1095
|
-
children
|
|
1113
|
+
get children() {
|
|
1114
|
+
return code`if (text === undefined || text === null || text === "") {
|
|
1096
1115
|
return "";
|
|
1097
1116
|
}
|
|
1098
1117
|
|
|
1099
1118
|
const lines = splitText(
|
|
1100
1119
|
String(text),
|
|
1101
|
-
Math.max(
|
|
1120
|
+
Math.max(getTerminalSize().columns, 20) - 6
|
|
1102
1121
|
);
|
|
1103
1122
|
|
|
1104
|
-
return lines.map(
|
|
1123
|
+
return lines.map(line => \`\${borderColors.app.blockquote.primary(isUnicodeSupported() ? "${theme.borderStyles.app.blockquote.primary.left}" : "|")} \${italic(line)} \`).join("\\n"); `;
|
|
1124
|
+
}
|
|
1105
1125
|
})
|
|
1106
1126
|
];
|
|
1107
1127
|
}
|
|
@@ -1139,10 +1159,12 @@ function CodeFunctionDeclaration() {
|
|
|
1139
1159
|
return "";
|
|
1140
1160
|
}
|
|
1141
1161
|
|
|
1142
|
-
|
|
1162
|
+
const lines = splitText(
|
|
1143
1163
|
String(text),
|
|
1144
|
-
Math.max(
|
|
1145
|
-
)
|
|
1164
|
+
Math.max(getTerminalSize().columns, 20)
|
|
1165
|
+
);
|
|
1166
|
+
|
|
1167
|
+
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")}\`; `;
|
|
1146
1168
|
}
|
|
1147
1169
|
})
|
|
1148
1170
|
];
|
|
@@ -1784,7 +1806,7 @@ function TableFunctionDeclaration(props) {
|
|
|
1784
1806
|
heading: "Calculate the width in characters based on the provided width size.",
|
|
1785
1807
|
get children() {
|
|
1786
1808
|
return [
|
|
1787
|
-
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 (
|
|
1809
|
+
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).` }),
|
|
1788
1810
|
createComponent(TSDocParam, {
|
|
1789
1811
|
name: "size",
|
|
1790
1812
|
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%").`
|
|
@@ -1806,40 +1828,40 @@ function TableFunctionDeclaration(props) {
|
|
|
1806
1828
|
return [
|
|
1807
1829
|
createComponent(IfStatement, {
|
|
1808
1830
|
condition: code`["full", "100%", "1/1"]. includes(size)`,
|
|
1809
|
-
children: code`return
|
|
1831
|
+
children: code`return getTerminalSize().columns;`
|
|
1810
1832
|
}),
|
|
1811
1833
|
createComponent(ElseIfClause, {
|
|
1812
1834
|
condition: code`["1/2", "50%"].includes(size)`,
|
|
1813
|
-
children: code`return Math.round(
|
|
1835
|
+
children: code`return Math.round(getTerminalSize().columns / 2);`
|
|
1814
1836
|
}),
|
|
1815
1837
|
createComponent(ElseIfClause, {
|
|
1816
1838
|
condition: code`["1/3", "33.33%"].includes(size)`,
|
|
1817
|
-
children: code`return Math.round(
|
|
1839
|
+
children: code`return Math.round(getTerminalSize().columns / 3);`
|
|
1818
1840
|
}),
|
|
1819
1841
|
createComponent(ElseIfClause, {
|
|
1820
1842
|
condition: code`["1/4", "25%"].includes(size)`,
|
|
1821
|
-
children: code`return Math.round(
|
|
1843
|
+
children: code`return Math.round(getTerminalSize().columns / 4);`
|
|
1822
1844
|
}),
|
|
1823
1845
|
createComponent(ElseIfClause, {
|
|
1824
1846
|
condition: code`["1/5", "20%"].includes(size)`,
|
|
1825
|
-
children: code`return Math.round(
|
|
1847
|
+
children: code`return Math.round(getTerminalSize().columns / 5);`
|
|
1826
1848
|
}),
|
|
1827
1849
|
createComponent(ElseIfClause, {
|
|
1828
1850
|
condition: code`["1/6", "10%"].includes(size)`,
|
|
1829
|
-
children: code`return Math.round(
|
|
1851
|
+
children: code`return Math.round(getTerminalSize().columns / 6);`
|
|
1830
1852
|
}),
|
|
1831
1853
|
createComponent(ElseIfClause, {
|
|
1832
1854
|
condition: code`["1/12", "5%"].includes(size)`,
|
|
1833
|
-
children: code`return Math.round(
|
|
1855
|
+
children: code`return Math.round(getTerminalSize().columns / 12);`
|
|
1834
1856
|
}),
|
|
1835
1857
|
createComponent(ElseIfClause, {
|
|
1836
1858
|
condition: code`["1/24", "2.5%"].includes(size)`,
|
|
1837
|
-
children: code`return Math.round(
|
|
1859
|
+
children: code`return Math.round(getTerminalSize().columns / 24);`
|
|
1838
1860
|
}),
|
|
1839
1861
|
createComponent(ElseClause, { children: code`
|
|
1840
1862
|
const match = size.match(/(\\d+(\\.\\d+)?)%/);
|
|
1841
1863
|
if (match) {
|
|
1842
|
-
return Math.round((
|
|
1864
|
+
return Math.round((getTerminalSize().columns * parseFloat(match[1])) / 100);
|
|
1843
1865
|
}
|
|
1844
1866
|
|
|
1845
1867
|
throw new Error(\`Invalid width size: \${size}\`);
|
|
@@ -2326,7 +2348,7 @@ do {
|
|
|
2326
2348
|
}
|
|
2327
2349
|
|
|
2328
2350
|
rowDims.forEach((row, rowIndex) => {
|
|
2329
|
-
if (!recalculate && row.width > Math.max(
|
|
2351
|
+
if (!recalculate && row.width > Math.max(getTerminalSize().columns - ${Math.max(theme.padding.app, 0) * 2}, 0)) {
|
|
2330
2352
|
const cell = cells[rowIndex]!.reduce((largestCell, cell) => {
|
|
2331
2353
|
if (cell.width > largestCell.width) {
|
|
2332
2354
|
return cell;
|
|
@@ -2336,7 +2358,7 @@ do {
|
|
|
2336
2358
|
|
|
2337
2359
|
const lines = splitText(
|
|
2338
2360
|
cell.value,
|
|
2339
|
-
Math.min(Math.max(
|
|
2361
|
+
Math.min(Math.max(getTerminalSize().columns - ${Math.max(theme.padding.app, 0) * 2} - (row.width - (cell.width - cell.padding * 2)), 0),
|
|
2340
2362
|
cell.maxWidth ?? Number.POSITIVE_INFINITY)
|
|
2341
2363
|
);
|
|
2342
2364
|
|
|
@@ -2348,7 +2370,7 @@ do {
|
|
|
2348
2370
|
}
|
|
2349
2371
|
});
|
|
2350
2372
|
|
|
2351
|
-
if (!recalculate && colWidths.reduce((a, b) => a + b, 0) > Math.max(
|
|
2373
|
+
if (!recalculate && colWidths.reduce((a, b) => a + b, 0) > Math.max(getTerminalSize().columns - ${Math.max(theme.padding.app, 0) * 2}, 0)) {
|
|
2352
2374
|
let colIndex = 0;
|
|
2353
2375
|
const cell = cells.reduce((ret, row) => {
|
|
2354
2376
|
return row.reduce((largest, current, index) => {
|
|
@@ -2362,7 +2384,7 @@ do {
|
|
|
2362
2384
|
|
|
2363
2385
|
const lines = splitText(
|
|
2364
2386
|
cell.value,
|
|
2365
|
-
Math.min(Math.max(
|
|
2387
|
+
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),
|
|
2366
2388
|
cell.maxWidth ?? Number.POSITIVE_INFINITY)
|
|
2367
2389
|
);
|
|
2368
2390
|
|
|
@@ -2451,7 +2473,8 @@ function ConsoleBuiltin(props) {
|
|
|
2451
2473
|
"isColorSupported",
|
|
2452
2474
|
"colorSupportLevels",
|
|
2453
2475
|
"isUnicodeSupported",
|
|
2454
|
-
"isHyperlinkSupported"
|
|
2476
|
+
"isHyperlinkSupported",
|
|
2477
|
+
"getTerminalSize"
|
|
2455
2478
|
],
|
|
2456
2479
|
env: [
|
|
2457
2480
|
"env",
|