@shell-shock/preset-cli 0.9.20 → 0.9.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1,29 @@
1
- var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));exports.__toESM=s;
1
+ //#region \0rolldown/runtime.js
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") {
10
+ for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
+ key = keys[i];
12
+ if (!__hasOwnProp.call(to, key) && key !== except) {
13
+ __defProp(to, key, {
14
+ get: ((k) => from[k]).bind(null, key),
15
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
+ });
17
+ }
18
+ }
19
+ }
20
+ return to;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
23
+ value: mod,
24
+ enumerable: true
25
+ }) : target, mod));
26
+
27
+ //#endregion
28
+
29
+ exports.__toESM = __toESM;
@@ -1,8 +1,96 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../_virtual/_rolldown/runtime.cjs`);let e=require(`@alloy-js/core/jsx-runtime`),t=require(`@alloy-js/core`),n=require(`@shell-shock/core/plugin-utils`),r=require(`@powerlines/plugin-alloy/core/components/spacing`),i=require(`@powerlines/plugin-alloy/core/contexts/context`),a=require(`@shell-shock/plugin-banner/components/banner-builtin`),o=require(`@shell-shock/plugin-banner/components/banner-function-declaration`),s=require(`@shell-shock/plugin-theme/contexts/theme`),c=require(`cfonts`);function l(r){let{consoleFnName:a=`log`,variant:l=`primary`,command:u}=r,d=(0,s.useTheme)(),f=(0,i.usePowerlines)(),p=(0,t.computed)(()=>`${d.labels.banner.header[l]||(0,n.getAppTitle)(f)} v${f.packageJson.version||`1.0.0`}`),m=(0,t.computed)(()=>d.labels.banner.footer[l]),h=(0,t.computed)(()=>(0,n.getAppTitle)(f,!0).replace(`v${f.packageJson.version||`1.0.0`}`,``)),g=(0,t.computed)(()=>u?.description||(0,n.getAppDescription)(f)),_=(0,t.computed)(()=>{let e=(0,c.render)((0,n.getAppTitle)(f,!0),{font:`tiny`,align:`left`,background:`transparent`,letterSpacing:1,lineHeight:1,gradient:!1,transitionGradient:!1,env:`node`});return e?e.array:[`${(0,n.getAppTitle)(f,!0)} Command-Line Interface`]}),v=(0,t.computed)(()=>Math.max(d.padding.app,0)*2+(d.borderStyles.banner.outline[l]?.left.length??0)+(d.borderStyles.banner.outline[l]?.right.length??0)),y=(0,t.computed)(()=>Math.max(d.padding.banner,0)*2+v.value);return(0,e.createComponent)(o.BannerFunctionBodyDeclaration,{get header(){return p.value},get description(){return g.value},get footer(){return m.value},variant:l,consoleFnName:a,command:u,insertNewlineAfterDescription:!0,get children(){return t.code`const titleLines = [${_.value.map(e=>JSON.stringify(e.trim())).join(`, `)}];
2
- const title = Math.max(...titleLines.map(line => stripAnsi(line).length)) > Math.max(getTerminalSize().columns + ${y.value}, 20) ? "${h.value}" : \`\\n\${titleLines.join("\\n")}\\n\`;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
+ let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
4
+ let _alloy_js_core = require("@alloy-js/core");
5
+ let _shell_shock_core_plugin_utils = require("@shell-shock/core/plugin-utils");
6
+ let _powerlines_plugin_alloy_core_components_spacing = require("@powerlines/plugin-alloy/core/components/spacing");
7
+ let _powerlines_plugin_alloy_core_contexts_context = require("@powerlines/plugin-alloy/core/contexts/context");
8
+ let _shell_shock_plugin_banner_components_banner_builtin = require("@shell-shock/plugin-banner/components/banner-builtin");
9
+ let _shell_shock_plugin_banner_components_banner_function_declaration = require("@shell-shock/plugin-banner/components/banner-function-declaration");
10
+ let _shell_shock_plugin_theme_contexts_theme = require("@shell-shock/plugin-theme/contexts/theme");
11
+ let cfonts = require("cfonts");
12
+
13
+ //#region src/components/banner-builtin.tsx
14
+ /**
15
+ * A component to generate the `banner` function in the `shell-shock:console` builtin module.
16
+ */
17
+ function BannerFunctionBodyDeclaration(props) {
18
+ const { consoleFnName = "log", variant = "primary", command } = props;
19
+ const theme = (0, _shell_shock_plugin_theme_contexts_theme.useTheme)();
20
+ const context = (0, _powerlines_plugin_alloy_core_contexts_context.usePowerlines)();
21
+ const header = (0, _alloy_js_core.computed)(() => `${theme.labels.banner.header[variant] || (0, _shell_shock_core_plugin_utils.getAppTitle)(context)} v${context.packageJson.version || "1.0.0"}`);
22
+ const footer = (0, _alloy_js_core.computed)(() => theme.labels.banner.footer[variant]);
23
+ const title = (0, _alloy_js_core.computed)(() => (0, _shell_shock_core_plugin_utils.getAppTitle)(context, true).replace(`v${context.packageJson.version || "1.0.0"}`, ""));
24
+ const description = (0, _alloy_js_core.computed)(() => command?.description || (0, _shell_shock_core_plugin_utils.getAppDescription)(context));
25
+ const titleLines = (0, _alloy_js_core.computed)(() => {
26
+ const result = (0, cfonts.render)((0, _shell_shock_core_plugin_utils.getAppTitle)(context, true), {
27
+ font: "tiny",
28
+ align: "left",
29
+ background: "transparent",
30
+ letterSpacing: 1,
31
+ lineHeight: 1,
32
+ gradient: false,
33
+ transitionGradient: false,
34
+ env: "node"
35
+ });
36
+ if (!result) return [`${(0, _shell_shock_core_plugin_utils.getAppTitle)(context, true)} Command-Line Interface`];
37
+ return result.array;
38
+ });
39
+ const bannerPadding = (0, _alloy_js_core.computed)(() => Math.max(theme.padding.app, 0) * 2 + (theme.borderStyles.banner.outline[variant]?.left.length ?? 0) + (theme.borderStyles.banner.outline[variant]?.right.length ?? 0));
40
+ const totalPadding = (0, _alloy_js_core.computed)(() => Math.max(theme.padding.banner, 0) * 2 + bannerPadding.value);
41
+ return (0, _alloy_js_core_jsx_runtime.createComponent)(_shell_shock_plugin_banner_components_banner_function_declaration.BannerFunctionBodyDeclaration, {
42
+ get header() {
43
+ return header.value;
44
+ },
45
+ get description() {
46
+ return description.value;
47
+ },
48
+ get footer() {
49
+ return footer.value;
50
+ },
51
+ variant,
52
+ consoleFnName,
53
+ command,
54
+ insertNewlineAfterDescription: true,
55
+ get children() {
56
+ return _alloy_js_core.code`const titleLines = [${titleLines.value.map((line) => JSON.stringify(line.trim())).join(", ")}];
57
+ const title = Math.max(...titleLines.map(line => stripAnsi(line).length)) > Math.max(getTerminalSize().columns + ${totalPadding.value}, 20) ? "${title.value}" : \`\\n\${titleLines.join("\\n")}\\n\`;
3
58
 
4
59
  splitText(title,
5
- Math.max(getTerminalSize().columns - ${y.value}, 20)
60
+ Math.max(getTerminalSize().columns - ${totalPadding.value}, 20)
6
61
  ).forEach((line) => {
7
- writeLine(borderColors.banner.outline.${l}("${d.borderStyles.banner.outline[l].left}") + " ".repeat(Math.max(Math.floor((getTerminalSize().columns - (stripAnsi(line).length + ${v.value})) / 2), 0)) + bold(textColors.banner.title.${l}(line)) + " ".repeat(Math.max(Math.ceil((getTerminalSize().columns - (stripAnsi(line).length + ${v.value})) / 2), 0)) + borderColors.banner.outline.${l}("${d.borderStyles.banner.outline[l].right}"), { consoleFn: console.${a} });
8
- }); `}})}function u(n){let[{command:i,children:s},c]=(0,t.splitProps)(n,[`command`,`children`]);return(0,e.createComponent)(a.BannerBuiltin,(0,e.mergeProps)(c,{command:i,get children(){return(0,e.createComponent)(o.BannerFunctionDeclarationWrapper,{command:i,get children(){return[(0,e.createComponent)(l,{command:i}),(0,e.createComponent)(r.Spacing,{}),(0,e.createComponent)(t.Show,{get when(){return!!s},children:s})]}})}}))}exports.BannerBuiltin=u,exports.BannerFunctionBodyDeclaration=l;
62
+ writeLine(borderColors.banner.outline.${variant}("${theme.borderStyles.banner.outline[variant].left}") + " ".repeat(Math.max(Math.floor((getTerminalSize().columns - (stripAnsi(line).length + ${bannerPadding.value})) / 2), 0)) + bold(textColors.banner.title.${variant}(line)) + " ".repeat(Math.max(Math.ceil((getTerminalSize().columns - (stripAnsi(line).length + ${bannerPadding.value})) / 2), 0)) + borderColors.banner.outline.${variant}("${theme.borderStyles.banner.outline[variant].right}"), { consoleFn: console.${consoleFnName} });
63
+ }); `;
64
+ }
65
+ });
66
+ }
67
+ /**
68
+ * A built-in banner module for Shell Shock.
69
+ */
70
+ function BannerBuiltin(props) {
71
+ const [{ command, children }, rest] = (0, _alloy_js_core.splitProps)(props, ["command", "children"]);
72
+ return (0, _alloy_js_core_jsx_runtime.createComponent)(_shell_shock_plugin_banner_components_banner_builtin.BannerBuiltin, (0, _alloy_js_core_jsx_runtime.mergeProps)(rest, {
73
+ command,
74
+ get children() {
75
+ return (0, _alloy_js_core_jsx_runtime.createComponent)(_shell_shock_plugin_banner_components_banner_function_declaration.BannerFunctionDeclarationWrapper, {
76
+ command,
77
+ get children() {
78
+ return [
79
+ (0, _alloy_js_core_jsx_runtime.createComponent)(BannerFunctionBodyDeclaration, { command }),
80
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
81
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
82
+ get when() {
83
+ return Boolean(children);
84
+ },
85
+ children
86
+ })
87
+ ];
88
+ }
89
+ });
90
+ }
91
+ }));
92
+ }
93
+
94
+ //#endregion
95
+ exports.BannerBuiltin = BannerBuiltin;
96
+ exports.BannerFunctionBodyDeclaration = BannerFunctionBodyDeclaration;
@@ -1,9 +1,94 @@
1
- import{createComponent as e,mergeProps as t}from"@alloy-js/core/jsx-runtime";import{Show as n,code as r,computed as i,splitProps as a}from"@alloy-js/core";import{getAppDescription as o,getAppTitle as s}from"@shell-shock/core/plugin-utils";import{Spacing as c}from"@powerlines/plugin-alloy/core/components/spacing";import{usePowerlines as l}from"@powerlines/plugin-alloy/core/contexts/context";import{BannerBuiltin as u}from"@shell-shock/plugin-banner/components/banner-builtin";import{BannerFunctionBodyDeclaration as d,BannerFunctionDeclarationWrapper as f}from"@shell-shock/plugin-banner/components/banner-function-declaration";import{useTheme as p}from"@shell-shock/plugin-theme/contexts/theme";import{render as m}from"cfonts";function h(t){let{consoleFnName:n=`log`,variant:a=`primary`,command:c}=t,u=p(),f=l(),h=i(()=>`${u.labels.banner.header[a]||s(f)} v${f.packageJson.version||`1.0.0`}`),g=i(()=>u.labels.banner.footer[a]),_=i(()=>s(f,!0).replace(`v${f.packageJson.version||`1.0.0`}`,``)),v=i(()=>c?.description||o(f)),y=i(()=>{let e=m(s(f,!0),{font:`tiny`,align:`left`,background:`transparent`,letterSpacing:1,lineHeight:1,gradient:!1,transitionGradient:!1,env:`node`});return e?e.array:[`${s(f,!0)} Command-Line Interface`]}),b=i(()=>Math.max(u.padding.app,0)*2+(u.borderStyles.banner.outline[a]?.left.length??0)+(u.borderStyles.banner.outline[a]?.right.length??0)),x=i(()=>Math.max(u.padding.banner,0)*2+b.value);return e(d,{get header(){return h.value},get description(){return v.value},get footer(){return g.value},variant:a,consoleFnName:n,command:c,insertNewlineAfterDescription:!0,get children(){return r`const titleLines = [${y.value.map(e=>JSON.stringify(e.trim())).join(`, `)}];
2
- const title = Math.max(...titleLines.map(line => stripAnsi(line).length)) > Math.max(getTerminalSize().columns + ${x.value}, 20) ? "${_.value}" : \`\\n\${titleLines.join("\\n")}\\n\`;
1
+ import { createComponent, memo, mergeProps } from "@alloy-js/core/jsx-runtime";
2
+ import { Show, code, computed, splitProps } from "@alloy-js/core";
3
+ import { getAppDescription, getAppTitle } from "@shell-shock/core/plugin-utils";
4
+ import { Spacing } from "@powerlines/plugin-alloy/core/components/spacing";
5
+ import { usePowerlines } from "@powerlines/plugin-alloy/core/contexts/context";
6
+ import { BannerBuiltin as BannerBuiltin$1 } from "@shell-shock/plugin-banner/components/banner-builtin";
7
+ import { BannerFunctionBodyDeclaration as BannerFunctionBodyDeclaration$1, BannerFunctionDeclarationWrapper } from "@shell-shock/plugin-banner/components/banner-function-declaration";
8
+ import { useTheme } from "@shell-shock/plugin-theme/contexts/theme";
9
+ import { render } from "cfonts";
10
+
11
+ //#region src/components/banner-builtin.tsx
12
+ /**
13
+ * A component to generate the `banner` function in the `shell-shock:console` builtin module.
14
+ */
15
+ function BannerFunctionBodyDeclaration(props) {
16
+ const { consoleFnName = "log", variant = "primary", command } = props;
17
+ const theme = useTheme();
18
+ const context = usePowerlines();
19
+ const header = computed(() => `${theme.labels.banner.header[variant] || getAppTitle(context)} v${context.packageJson.version || "1.0.0"}`);
20
+ const footer = computed(() => theme.labels.banner.footer[variant]);
21
+ const title = computed(() => getAppTitle(context, true).replace(`v${context.packageJson.version || "1.0.0"}`, ""));
22
+ const description = computed(() => command?.description || getAppDescription(context));
23
+ const titleLines = computed(() => {
24
+ const result = render(getAppTitle(context, true), {
25
+ font: "tiny",
26
+ align: "left",
27
+ background: "transparent",
28
+ letterSpacing: 1,
29
+ lineHeight: 1,
30
+ gradient: false,
31
+ transitionGradient: false,
32
+ env: "node"
33
+ });
34
+ if (!result) return [`${getAppTitle(context, true)} Command-Line Interface`];
35
+ return result.array;
36
+ });
37
+ const bannerPadding = computed(() => Math.max(theme.padding.app, 0) * 2 + (theme.borderStyles.banner.outline[variant]?.left.length ?? 0) + (theme.borderStyles.banner.outline[variant]?.right.length ?? 0));
38
+ const totalPadding = computed(() => Math.max(theme.padding.banner, 0) * 2 + bannerPadding.value);
39
+ return createComponent(BannerFunctionBodyDeclaration$1, {
40
+ get header() {
41
+ return header.value;
42
+ },
43
+ get description() {
44
+ return description.value;
45
+ },
46
+ get footer() {
47
+ return footer.value;
48
+ },
49
+ variant,
50
+ consoleFnName,
51
+ command,
52
+ insertNewlineAfterDescription: true,
53
+ get children() {
54
+ return code`const titleLines = [${titleLines.value.map((line) => JSON.stringify(line.trim())).join(", ")}];
55
+ const title = Math.max(...titleLines.map(line => stripAnsi(line).length)) > Math.max(getTerminalSize().columns + ${totalPadding.value}, 20) ? "${title.value}" : \`\\n\${titleLines.join("\\n")}\\n\`;
3
56
 
4
57
  splitText(title,
5
- Math.max(getTerminalSize().columns - ${x.value}, 20)
58
+ Math.max(getTerminalSize().columns - ${totalPadding.value}, 20)
6
59
  ).forEach((line) => {
7
- writeLine(borderColors.banner.outline.${a}("${u.borderStyles.banner.outline[a].left}") + " ".repeat(Math.max(Math.floor((getTerminalSize().columns - (stripAnsi(line).length + ${b.value})) / 2), 0)) + bold(textColors.banner.title.${a}(line)) + " ".repeat(Math.max(Math.ceil((getTerminalSize().columns - (stripAnsi(line).length + ${b.value})) / 2), 0)) + borderColors.banner.outline.${a}("${u.borderStyles.banner.outline[a].right}"), { consoleFn: console.${n} });
8
- }); `}})}function g(r){let[{command:i,children:o},s]=a(r,[`command`,`children`]);return e(u,t(s,{command:i,get children(){return e(f,{command:i,get children(){return[e(h,{command:i}),e(c,{}),e(n,{get when(){return!!o},children:o})]}})}}))}export{g as BannerBuiltin,h as BannerFunctionBodyDeclaration};
60
+ writeLine(borderColors.banner.outline.${variant}("${theme.borderStyles.banner.outline[variant].left}") + " ".repeat(Math.max(Math.floor((getTerminalSize().columns - (stripAnsi(line).length + ${bannerPadding.value})) / 2), 0)) + bold(textColors.banner.title.${variant}(line)) + " ".repeat(Math.max(Math.ceil((getTerminalSize().columns - (stripAnsi(line).length + ${bannerPadding.value})) / 2), 0)) + borderColors.banner.outline.${variant}("${theme.borderStyles.banner.outline[variant].right}"), { consoleFn: console.${consoleFnName} });
61
+ }); `;
62
+ }
63
+ });
64
+ }
65
+ /**
66
+ * A built-in banner module for Shell Shock.
67
+ */
68
+ function BannerBuiltin(props) {
69
+ const [{ command, children }, rest] = splitProps(props, ["command", "children"]);
70
+ return createComponent(BannerBuiltin$1, mergeProps(rest, {
71
+ command,
72
+ get children() {
73
+ return createComponent(BannerFunctionDeclarationWrapper, {
74
+ command,
75
+ get children() {
76
+ return [
77
+ createComponent(BannerFunctionBodyDeclaration, { command }),
78
+ createComponent(Spacing, {}),
79
+ createComponent(Show, {
80
+ get when() {
81
+ return Boolean(children);
82
+ },
83
+ children
84
+ })
85
+ ];
86
+ }
87
+ });
88
+ }
89
+ }));
90
+ }
91
+
92
+ //#endregion
93
+ export { BannerBuiltin, BannerFunctionBodyDeclaration };
9
94
  //# sourceMappingURL=banner-builtin.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"banner-builtin.mjs","names":[],"sources":["../../src/components/banner-builtin.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 { code, computed, Show, splitProps } from \"@alloy-js/core\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport type { BuiltinFileProps } from \"@powerlines/plugin-alloy/typescript/components/builtin-file\";\nimport type { CommandTree } from \"@shell-shock/core\";\nimport { getAppDescription, getAppTitle } from \"@shell-shock/core/plugin-utils\";\nimport { BannerBuiltin as BaseBannerBuiltin } from \"@shell-shock/plugin-banner/components/banner-builtin\";\nimport type { BannerFunctionBodyDeclarationProps } from \"@shell-shock/plugin-banner/components/banner-function-declaration\";\nimport {\n BannerFunctionDeclarationWrapper,\n BannerFunctionBodyDeclaration as BaseBannerFunctionBodyDeclaration\n} from \"@shell-shock/plugin-banner/components/banner-function-declaration\";\nimport { useTheme } from \"@shell-shock/plugin-theme/contexts/theme\";\nimport { render } from \"cfonts\";\nimport type { CLIPresetContext } from \"../types/plugin\";\n\n/**\n * A component to generate the `banner` function in the `shell-shock:console` builtin module.\n */\nexport function BannerFunctionBodyDeclaration(\n props: Omit<\n BannerFunctionBodyDeclarationProps,\n \"header\" | \"description\" | \"footer\"\n >\n) {\n const { consoleFnName = \"log\", variant = \"primary\", command } = props;\n\n const theme = useTheme();\n const context = usePowerlines<CLIPresetContext>();\n\n const header = computed(\n () =>\n `${theme.labels.banner.header[variant] || getAppTitle(context)} v${\n context.packageJson.version || \"1.0.0\"\n }`\n );\n const footer = computed(() => theme.labels.banner.footer[variant]);\n const title = computed(() =>\n getAppTitle(context, true).replace(\n `v${context.packageJson.version || \"1.0.0\"}`,\n \"\"\n )\n );\n const description = computed(\n () => command?.description || getAppDescription(context)\n );\n\n const titleLines = computed(() => {\n const result = render(getAppTitle(context, true), {\n font: \"tiny\",\n align: \"left\",\n background: \"transparent\",\n letterSpacing: 1,\n lineHeight: 1,\n gradient: false,\n transitionGradient: false,\n env: \"node\"\n });\n if (!result) {\n return [`${getAppTitle(context, true)} Command-Line Interface`];\n }\n\n return result.array;\n });\n\n const bannerPadding = computed(\n () =>\n Math.max(theme.padding.app, 0) * 2 +\n (theme.borderStyles.banner.outline[variant]?.left.length ?? 0) +\n (theme.borderStyles.banner.outline[variant]?.right.length ?? 0)\n );\n const totalPadding = computed(\n () => Math.max(theme.padding.banner, 0) * 2 + bannerPadding.value\n );\n\n return (\n <BaseBannerFunctionBodyDeclaration\n header={header.value}\n description={description.value}\n footer={footer.value}\n variant={variant}\n consoleFnName={consoleFnName}\n command={command}\n insertNewlineAfterDescription>\n {code`const titleLines = [${titleLines.value\n .map(line => JSON.stringify(line.trim()))\n .join(\", \")}];\n const title = Math.max(...titleLines.map(line => stripAnsi(line).length)) > Math.max(getTerminalSize().columns + ${\n totalPadding.value\n }, 20) ? \"${title.value}\" : \\`\\\\n\\${titleLines.join(\"\\\\n\")}\\\\n\\`;\n\n splitText(title,\n Math.max(getTerminalSize().columns - ${totalPadding.value}, 20)\n ).forEach((line) => {\n writeLine(borderColors.banner.outline.${variant}(\"${\n theme.borderStyles.banner.outline[variant].left\n }\") + \" \".repeat(Math.max(Math.floor((getTerminalSize().columns - (stripAnsi(line).length + ${\n bannerPadding.value\n })) / 2), 0)) + bold(textColors.banner.title.${variant}(line)) + \" \".repeat(Math.max(Math.ceil((getTerminalSize().columns - (stripAnsi(line).length + ${\n bannerPadding.value\n })) / 2), 0)) + borderColors.banner.outline.${variant}(\"${\n theme.borderStyles.banner.outline[variant].right\n }\"), { consoleFn: console.${consoleFnName} });\n }); `}\n </BaseBannerFunctionBodyDeclaration>\n );\n}\n\nexport type BannerBuiltinProps = Omit<\n BuiltinFileProps,\n \"id\" | \"description\"\n> & {\n /**\n * The command to generate the `banner` function declaration for.\n */\n command: CommandTree;\n};\n\n/**\n * A built-in banner module for Shell Shock.\n */\nexport function BannerBuiltin(props: BannerBuiltinProps) {\n const [{ command, children }, rest] = splitProps(props, [\n \"command\",\n \"children\"\n ]);\n\n return (\n <BaseBannerBuiltin {...rest} command={command}>\n <BannerFunctionDeclarationWrapper command={command}>\n <BannerFunctionBodyDeclaration command={command} />\n <Spacing />\n <Show when={Boolean(children)}>{children}</Show>\n </BannerFunctionDeclarationWrapper>\n </BaseBannerBuiltin>\n );\n}\n"],"mappings":"0tBA8BA,SAA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A,EAAA,MAAA,8CAAA,EAAA,iGAAA,EAAA,MAAA,6CAAA,EAAA,IAAA,EAAA,aAAA,OAAA,QAAA,GAAA,MAAA,2BAAA,EAAA;aAGD,CAAC,CAKJ,SAAQ,EAAe,EAAQ,CAC7B,GAAM,CAAC,CACN,UAAA,YAED,GAAO,EAAA,EAAA,CAAA,UAAA,WAAA,CAAA,CACP,OAAG,EAAA,EAAA,EAAA,EAAA,CACQ,UACT,IAAE,UAAa,CACb,OAAO,EAAa,EAAA,CACX,UACT,IAAA,UAAe,CACf,MAAS,CAAA,EAAO,EAAA,CAChB,UACK,CAAC,CAAA,EAAoB,EAAE,EAAA,CAAU,CAAC,EAAA,EAAA,CACjC,IAAC,MAAQ,CACP,MAAO,EAAA,GAEA,WACV,CAAC,CAAC,EAEP,CAAA,EAEH,CAAC,CAAC"}
1
+ {"version":3,"file":"banner-builtin.mjs","names":[],"sources":["../../src/components/banner-builtin.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 { code, computed, Show, splitProps } from \"@alloy-js/core\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport type { BuiltinFileProps } from \"@powerlines/plugin-alloy/typescript/components/builtin-file\";\nimport type { CommandTree } from \"@shell-shock/core\";\nimport { getAppDescription, getAppTitle } from \"@shell-shock/core/plugin-utils\";\nimport { BannerBuiltin as BaseBannerBuiltin } from \"@shell-shock/plugin-banner/components/banner-builtin\";\nimport type { BannerFunctionBodyDeclarationProps } from \"@shell-shock/plugin-banner/components/banner-function-declaration\";\nimport {\n BannerFunctionDeclarationWrapper,\n BannerFunctionBodyDeclaration as BaseBannerFunctionBodyDeclaration\n} from \"@shell-shock/plugin-banner/components/banner-function-declaration\";\nimport { useTheme } from \"@shell-shock/plugin-theme/contexts/theme\";\nimport { render } from \"cfonts\";\nimport type { CLIPresetContext } from \"../types/plugin\";\n\n/**\n * A component to generate the `banner` function in the `shell-shock:console` builtin module.\n */\nexport function BannerFunctionBodyDeclaration(\n props: Omit<\n BannerFunctionBodyDeclarationProps,\n \"header\" | \"description\" | \"footer\"\n >\n) {\n const { consoleFnName = \"log\", variant = \"primary\", command } = props;\n\n const theme = useTheme();\n const context = usePowerlines<CLIPresetContext>();\n\n const header = computed(\n () =>\n `${theme.labels.banner.header[variant] || getAppTitle(context)} v${\n context.packageJson.version || \"1.0.0\"\n }`\n );\n const footer = computed(() => theme.labels.banner.footer[variant]);\n const title = computed(() =>\n getAppTitle(context, true).replace(\n `v${context.packageJson.version || \"1.0.0\"}`,\n \"\"\n )\n );\n const description = computed(\n () => command?.description || getAppDescription(context)\n );\n\n const titleLines = computed(() => {\n const result = render(getAppTitle(context, true), {\n font: \"tiny\",\n align: \"left\",\n background: \"transparent\",\n letterSpacing: 1,\n lineHeight: 1,\n gradient: false,\n transitionGradient: false,\n env: \"node\"\n });\n if (!result) {\n return [`${getAppTitle(context, true)} Command-Line Interface`];\n }\n\n return result.array;\n });\n\n const bannerPadding = computed(\n () =>\n Math.max(theme.padding.app, 0) * 2 +\n (theme.borderStyles.banner.outline[variant]?.left.length ?? 0) +\n (theme.borderStyles.banner.outline[variant]?.right.length ?? 0)\n );\n const totalPadding = computed(\n () => Math.max(theme.padding.banner, 0) * 2 + bannerPadding.value\n );\n\n return (\n <BaseBannerFunctionBodyDeclaration\n header={header.value}\n description={description.value}\n footer={footer.value}\n variant={variant}\n consoleFnName={consoleFnName}\n command={command}\n insertNewlineAfterDescription>\n {code`const titleLines = [${titleLines.value\n .map(line => JSON.stringify(line.trim()))\n .join(\", \")}];\n const title = Math.max(...titleLines.map(line => stripAnsi(line).length)) > Math.max(getTerminalSize().columns + ${\n totalPadding.value\n }, 20) ? \"${title.value}\" : \\`\\\\n\\${titleLines.join(\"\\\\n\")}\\\\n\\`;\n\n splitText(title,\n Math.max(getTerminalSize().columns - ${totalPadding.value}, 20)\n ).forEach((line) => {\n writeLine(borderColors.banner.outline.${variant}(\"${\n theme.borderStyles.banner.outline[variant].left\n }\") + \" \".repeat(Math.max(Math.floor((getTerminalSize().columns - (stripAnsi(line).length + ${\n bannerPadding.value\n })) / 2), 0)) + bold(textColors.banner.title.${variant}(line)) + \" \".repeat(Math.max(Math.ceil((getTerminalSize().columns - (stripAnsi(line).length + ${\n bannerPadding.value\n })) / 2), 0)) + borderColors.banner.outline.${variant}(\"${\n theme.borderStyles.banner.outline[variant].right\n }\"), { consoleFn: console.${consoleFnName} });\n }); `}\n </BaseBannerFunctionBodyDeclaration>\n );\n}\n\nexport type BannerBuiltinProps = Omit<\n BuiltinFileProps,\n \"id\" | \"description\"\n> & {\n /**\n * The command to generate the `banner` function declaration for.\n */\n command: CommandTree;\n};\n\n/**\n * A built-in banner module for Shell Shock.\n */\nexport function BannerBuiltin(props: BannerBuiltinProps) {\n const [{ command, children }, rest] = splitProps(props, [\n \"command\",\n \"children\"\n ]);\n\n return (\n <BaseBannerBuiltin {...rest} command={command}>\n <BannerFunctionDeclarationWrapper command={command}>\n <BannerFunctionBodyDeclaration command={command} />\n <Spacing />\n <Show when={Boolean(children)}>{children}</Show>\n </BannerFunctionDeclarationWrapper>\n </BaseBannerBuiltin>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AA8BA,SAAS,8BAAqC,OAAM;CACpD,MAAQ,EACR,gBAAc,4BAEZ,YACG;CACH,MAAA,QAAA,UAAA;CACF,MAAO,UAAS,eAAA;CACd,MAAM,SAAK,eAAA,GAAA,MAAA,OAAA,OAA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