@shell-shock/preset-script 0.3.0 → 0.3.2
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.
- package/README.md +1 -1
- package/dist/components/args-parser-logic.d.cts +7 -7
- package/dist/components/command-entry.d.cts +4 -4
- package/dist/components/command-entry.d.cts.map +1 -1
- package/dist/components/command-entry.d.mts +4 -4
- package/dist/components/command-entry.d.mts.map +1 -1
- package/dist/components/console-builtin.cjs +17 -17
- package/dist/components/console-builtin.cjs.map +1 -1
- package/dist/components/console-builtin.d.cts +11 -2
- package/dist/components/console-builtin.d.cts.map +1 -1
- package/dist/components/console-builtin.d.mts +11 -2
- package/dist/components/console-builtin.d.mts.map +1 -1
- package/dist/components/console-builtin.mjs +17 -17
- package/dist/components/console-builtin.mjs.map +1 -1
- package/dist/components/help.cjs +3 -3
- package/dist/components/help.cjs.map +1 -1
- package/dist/components/help.d.cts +5 -5
- package/dist/components/help.d.cts.map +1 -1
- package/dist/components/help.d.mts +5 -5
- package/dist/components/help.mjs +3 -3
- package/dist/components/help.mjs.map +1 -1
- package/dist/components/index.d.cts +2 -2
- package/dist/components/index.d.mts +2 -2
- package/dist/components/utils-builtin.cjs +1 -1
- package/dist/components/utils-builtin.cjs.map +1 -1
- package/dist/components/utils-builtin.d.cts +7 -7
- package/dist/components/utils-builtin.d.mts +7 -7
- package/dist/components/utils-builtin.mjs +1 -1
- package/dist/components/utils-builtin.mjs.map +1 -1
- package/dist/components/virtual-command-entry.d.cts +3 -3
- package/dist/contexts/theme.cjs +2 -2
- package/dist/contexts/theme.cjs.map +1 -1
- package/dist/helpers/ansi-utils.cjs +3 -0
- package/dist/helpers/ansi-utils.d.cts +8 -1
- package/dist/helpers/ansi-utils.d.cts.map +1 -1
- package/dist/helpers/ansi-utils.d.mts +8 -1
- package/dist/helpers/ansi-utils.d.mts.map +1 -1
- package/dist/helpers/ansi-utils.mjs +1 -1
- package/dist/helpers/get-default-options.d.cts +13 -0
- package/dist/helpers/get-default-options.d.cts.map +1 -0
- package/dist/helpers/get-default-options.d.mts +13 -0
- package/dist/helpers/get-default-options.d.mts.map +1 -0
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/types/plugin.d.cts.map +1 -1
- package/dist/types/plugin.d.mts.map +1 -1
- package/package.json +38 -10
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils-builtin.mjs","names":["code","Show","splitProps","FunctionDeclaration","InterfaceDeclaration","InterfaceMember","VarDeclaration","usePowerlines","BuiltinFile","TSDoc","TSDocLink","TSDocParam","TSDocReturns","getAppTitle","defu","EnvSupportUtilities","_$createComponent","name","doc","initializer","_$createIntrinsic","ColorSupportUtilities","children","type","heading","parameters","default","HyperlinkSupportUtilities","returnType","ArgsUtilities","ExitFunctionDeclaration","context","optional","async","UtilsBuiltin","props","rest","_$mergeProps","id","description","imports","builtinImports","console","env","when","Boolean"],"sources":["../../src/components/utils-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, Show, splitProps } from \"@alloy-js/core\";\nimport {\n FunctionDeclaration,\n InterfaceDeclaration,\n InterfaceMember,\n VarDeclaration\n} from \"@alloy-js/typescript\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport type { BuiltinFileProps } from \"@powerlines/plugin-alloy/typescript/components/builtin-file\";\nimport { BuiltinFile } from \"@powerlines/plugin-alloy/typescript/components/builtin-file\";\nimport {\n TSDoc,\n TSDocLink,\n TSDocParam,\n TSDocReturns\n} from \"@powerlines/plugin-alloy/typescript/components/tsdoc\";\nimport { getAppTitle } from \"@shell-shock/core/plugin-utils/context-helpers\";\nimport defu from \"defu\";\nimport type { ScriptPresetContext } from \"../types/plugin\";\n\nexport interface UtilsBuiltinProps extends Omit<\n BuiltinFileProps,\n \"id\" | \"description\"\n> {}\n\n/**\n * Generates utilities for detecting terminal color support.\n */\n\nexport function EnvSupportUtilities() {\n return (\n <>\n <VarDeclaration\n export\n const\n name=\"isTTY\"\n doc=\"Detect if stdout.TTY is available\"\n initializer={code`Boolean(process.stdout && process.stdout.isTTY);`}\n />\n <hbr />\n <hbr />\n <VarDeclaration\n export\n const\n name=\"isMinimal\"\n doc=\"Detect if the current environment is minimal (CI, non-TTY, etc.)\"\n initializer={code` env.MINIMAL || isCI || isTest || !isTTY; `}\n />\n <hbr />\n <hbr />\n <VarDeclaration\n export\n const\n name=\"isInteractive\"\n doc=\"Detect if the current environment is interactive\"\n initializer={code` !isMinimal && process.stdin?.isTTY && env.TERM !== \"dumb\"; `}\n />\n </>\n );\n}\n\n/**\n * Generates utilities for detecting terminal color support.\n */\nexport function ColorSupportUtilities() {\n return (\n <>\n <InterfaceDeclaration\n export\n name=\"GetColorSupportLevelOptions\"\n doc=\"Options for the getColorSupportLevel function\">\n <InterfaceMember\n name=\"ignoreFlags\"\n type=\"boolean\"\n doc=\"Indicates if the function should skip checking command-line flags for color support\"\n />\n </InterfaceDeclaration>\n <hbr />\n <hbr />\n <TSDoc heading=\"Checks if a specific flag is present in the command line arguments.\">\n <TSDocLink>\n {\"https://github.com/sindresorhus/has-flag/blob/main/index.js\"}\n </TSDocLink>\n <TSDocParam name=\"flag\">\n {'The flag to check for, e.g., \"color\", \"no-color\".'}\n </TSDocParam>\n <TSDocParam name=\"argv\">\n {\n \"The command line arguments to check against. Defaults to global Deno args or process args.\"\n }\n </TSDocParam>\n <TSDocReturns>\n {\"True if the flag is present, false otherwise.\"}\n </TSDocReturns>\n </TSDoc>\n <FunctionDeclaration\n export\n name=\"getColorSupportLevel\"\n parameters={[\n { name: \"stream\", type: \"NodeJS.WriteStream & { fd: 1 | 2; }\" },\n {\n name: \"options\",\n type: \"GetColorSupportLevelOptions\",\n default: \"{ ignoreFlags: false }\"\n }\n ]}>\n {code`const { ignoreFlags } = options;\n\n let forceColor: number | undefined;\n if (env.FORCE_COLOR !== undefined) {\n forceColor = !env.FORCE_COLOR\n ? 0\n : typeof env.FORCE_COLOR === \"boolean\"\n ? 1\n : typeof env.FORCE_COLOR === \"number\" &&\n [0, 1, 2, 3].includes(Math.min(env.FORCE_COLOR as number, 3))\n ? Math.min(env.FORCE_COLOR as number, 3)\n : undefined;\n }\n\n if (ignoreFlags !== true && forceColor === undefined) {\n if (\n hasFlag(\"no-color\") ||\n hasFlag(\"no-colors\") ||\n hasFlag(\"color=false\") ||\n hasFlag(\"color=never\")\n ) {\n return 0;\n }\n\n if (\n hasFlag(\"color=16m\") ||\n hasFlag(\"color=full\") ||\n hasFlag(\"color=truecolor\")\n ) {\n return 3;\n }\n\n if (hasFlag(\"color=256\")) {\n return 2;\n }\n\n if (\n hasFlag(\"color\") ||\n hasFlag(\"colors\") ||\n hasFlag(\"color=true\") ||\n hasFlag(\"color=always\")\n ) {\n forceColor = 1;\n }\n }\n\n const level = Boolean(env.TF_BUILD) || Boolean(env.AGENT_NAME)\n ? 1\n : stream &&\n !(isTTY || (stream && stream.isTTY)) &&\n forceColor === undefined\n ? 0\n : env.TERM === \"dumb\"\n ? forceColor || 0\n : isWindows\n ? Number(os.release().split(\".\")[0]) >= 10 &&\n Number(os.release().split(\".\")[2]) >= 10_586\n ? Number(os.release().split(\".\")[2]) >= 14_931\n ? 3\n : 2\n : 1\n : isCI\n ? Boolean(env.GITHUB_ACTIONS) ||\n Boolean(env.GITEA_ACTIONS) ||\n Boolean(env.CIRCLECI)\n ? 3\n : Boolean(env.TRAVIS) ||\n Boolean(env.APPVEYOR) ||\n Boolean(env.GITLAB_CI) ||\n Boolean(env.BUILDKITE) ||\n Boolean(env.DRONE) ||\n env.CI_NAME === \"codeship\"\n ? 1\n : forceColor || 0\n : Boolean(env.TEAMCITY_VERSION)\n ? /^(?:9\\.0*[1-9]\\d*\\.|\\d{2,}\\.)/.test(String(env.TEAMCITY_VERSION) || \"\")\n ? 1\n : 0\n : String(env.COLORTERM) === \"truecolor\" ||\n env.TERM === \"xterm-kitty\"\n ? 3\n : Boolean(env.TERM_PROGRAM)\n ? env.TERM_PROGRAM === \"iTerm.app\"\n ? Number.parseInt(\n (env.TERM_PROGRAM_VERSION || \"\").split(\".\")[0] as string,\n 10\n ) >= 3\n ? 3\n : 2\n : env.TERM_PROGRAM === \"Apple_Terminal\"\n ? 2\n : 0\n : /-256(?:color)?$/i.test(env.TERM || \"\")\n ? 2\n : /^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(\n env.TERM || \"\"\n )\n ? 1\n : Boolean(env.COLORTERM);\n\n return typeof level === \"boolean\" || level === 0\n ? false\n : {\n level,\n hasBasic: true,\n has256: level >= 2,\n has16m: level >= 3,\n };\n\n `}\n </FunctionDeclaration>\n <hbr />\n <hbr />\n <VarDeclaration\n export\n const\n name=\"colorSupportLevels\"\n doc=\"Detect the terminal color support level in the current environment\"\n initializer={code` {\n stdout: getColorSupportLevel(process.stdout),\n stderr: getColorSupportLevel(process.stderr),\n }; `}\n />\n <hbr />\n <hbr />\n <VarDeclaration\n export\n const\n name=\"isColorSupported\"\n doc=\"Detect if terminal color is supported in the current environment\"\n initializer={code` Boolean(colorSupportLevels.stdout); `}\n />\n <hbr />\n <hbr />\n <VarDeclaration\n export\n const\n name=\"isUnicodeSupported\"\n doc=\"Detect if Unicode characters are supported in the current environment\"\n initializer={code` !isWindows\n ? env.TERM !== \"linux\"\n : Boolean(env.WT_SESSION) ||\n Boolean(env.TERMINUS_SUBLIME) ||\n env.ConEmuTask === \"{cmd::Cmder}\" ||\n env.TERM_PROGRAM === \"Terminus-Sublime\" ||\n env.TERM_PROGRAM === \"vscode\" ||\n env.TERM === \"xterm-256color\" ||\n env.TERM === \"alacritty\" ||\n env.TERM === \"rxvt-unicode\" ||\n env.TERM === \"rxvt-unicode-256color\" ||\n env.TERMINAL_EMULATOR === \"JetBrains-JediTerm\"; `}\n />\n </>\n );\n}\n\n/**\n * Generates utilities for detecting terminal color support.\n */\n\nexport function HyperlinkSupportUtilities() {\n return (\n <>\n <FunctionDeclaration\n name=\"parseVersion\"\n parameters={[{ name: \"version\", type: \"string\", default: '\"\"' }]}>\n {code`if (/^\\d{3,4}$/.test(version)) {\n const match = /(\\d{1,2})(\\d{2})/.exec(version) ?? [];\n\n return {\n major: 0,\n minor: Number.parseInt(match[1]!, 10),\n patch: Number.parseInt(match[2]!, 10)\n };\n }\n\n const versionParts = (version ?? \"\")\n .split(\".\")\n .map(n => Number.parseInt(n, 10));\n\n return {\n major: versionParts[0],\n minor: versionParts[1],\n patch: versionParts[2]\n }; `}\n </FunctionDeclaration>\n <hbr />\n <hbr />\n <TSDoc heading=\"Check if the current environment/terminal supports hyperlinks in the terminal.\">\n <TSDocReturns>\n {\"True if the current environment/terminal supports hyperlinks.\"}\n </TSDocReturns>\n </TSDoc>\n <FunctionDeclaration\n export\n name=\"isHyperlinkSupported\"\n returnType=\"boolean\">\n {code`if (Boolean(env.FORCE_HYPERLINK)) {\n return true;\n }\n\n if (Boolean(env.NETLIFY)) {\n return true;\n } else if (isColorSupported || isTTY) {\n return false;\n } else if (Boolean(env.WT_SESSION)) {\n return true;\n } else if (isWindows || isMinimal || Boolean(env.TEAMCITY_VERSION)) {\n return false;\n } else if (Boolean(env.TERM_PROGRAM)) {\n const version = parseVersion(env.TERM_PROGRAM_VERSION);\n\n switch (String(env.TERM_PROGRAM)) {\n case \"iTerm.app\": {\n if (version.major === 3) {\n return version.minor !== undefined && version.minor >= 1;\n }\n\n return version.major !== undefined && version.major > 3;\n }\n case \"WezTerm\": {\n return version.major !== undefined && version.major >= 20_200_620;\n }\n\n case \"vscode\": {\n if (Boolean(env.CURSOR_TRACE_ID)) {\n return true;\n }\n\n return (\n version.minor !== undefined &&\n version.major !== undefined &&\n (version.major > 1 || (version.major === 1 && version.minor >= 72))\n );\n }\n\n case \"ghostty\": {\n return true;\n }\n }\n }\n\n if (Boolean(env.VTE_VERSION)) {\n if (env.VTE_VERSION === \"0.50.0\") {\n return false;\n }\n\n const version = parseVersion(env.VTE_VERSION);\n return (\n (version.major !== undefined && version.major > 0) ||\n (version.minor !== undefined && version.minor >= 50)\n );\n }\n\n if (String(env.TERM) === \"alacritty\") {\n return true;\n }\n\n return false; `}\n </FunctionDeclaration>\n </>\n );\n}\n\n/**\n * Generates utilities for detecting terminal color support.\n */\nexport function ArgsUtilities() {\n return (\n <>\n <TSDoc heading=\"Retrieves the command line arguments from Deno or Node.js environments.\">\n <TSDocReturns>\n {\n \"An array of command line arguments from Deno or Node.js environments.\"\n }\n </TSDocReturns>\n </TSDoc>\n <FunctionDeclaration export name=\"getArgs\">\n {code`return ((globalThis as { Deno?: { args: string[] } })?.Deno?.args ?? process.argv ?? []) as string[];`}\n </FunctionDeclaration>\n <hbr />\n <hbr />\n <TSDoc heading=\"Checks if a specific flag is present in the command line arguments.\">\n <TSDocLink>\n {\"https://github.com/sindresorhus/has-flag/blob/main/index.js\"}\n </TSDocLink>\n <TSDocParam name=\"flag\">\n {\n 'The flag (or an array of flags/aliases) to check for, e.g., \"color\", \"no-color\".'\n }\n </TSDocParam>\n <TSDocParam name=\"argv\">\n {\n \"The command line arguments to check against. Defaults to global Deno args or process args.\"\n }\n </TSDocParam>\n <TSDocReturns>\n {\"True if the flag is present, false otherwise.\"}\n </TSDocReturns>\n </TSDoc>\n <FunctionDeclaration\n export\n name=\"hasFlag\"\n parameters={[\n { name: \"flag\", type: \"string | string[]\" },\n {\n name: \"argv\",\n type: \"string[]\",\n default: \"getArgs()\"\n }\n ]}>\n <VarDeclaration\n const\n name=\"position\"\n type=\"number\"\n initializer={code`(Array.isArray(flag) ? flag : [flag]).reduce((ret, f) => {\n const pos = argv.findIndex(arg => (f.startsWith(\"-\") ? \"\" : (f.length === 1 ? \"-\" : \"--\") + f)?.toLowerCase() === arg?.toLowerCase() || arg?.toLowerCase().startsWith((f.length === 1 ? \"-\" : \"--\") + f + \"=\"));\n return pos !== -1 ? pos : ret;\n }, -1);`}\n />\n <hbr />\n {code`return position !== -1 && argv.indexOf(\"--\") === -1 || position < argv.indexOf(\"--\");`}\n </FunctionDeclaration>\n </>\n );\n}\n\n/**\n * The `exit` handler function declaration code for the Shell Shock project.\n */\nexport function ExitFunctionDeclaration() {\n const context = usePowerlines<ScriptPresetContext>();\n\n return (\n <>\n <InterfaceDeclaration\n export\n name=\"ExitOptions\"\n doc=\"Options for the exit handler function.\">\n <InterfaceMember\n name=\"exception\"\n optional\n type=\"string | Error\"\n doc=\"An optional exception that caused the exit. This can be a string message or an Error object.\"\n />\n <hbr />\n <InterfaceMember\n name=\"skipProcessExit\"\n optional\n type=\"boolean\"\n doc=\"Indicates whether the exit function should manually exit the process or not. If set to true, the exit function will not call process.exit() and will allow the application to continue running. If set to false or not specified, the exit function will call process.exit() to terminate the application.\"\n />\n <hbr />\n <InterfaceMember\n name=\"isSynchronous\"\n optional\n type=\"boolean\"\n doc=\"Indicates whether the exit function should perform synchronous operations only. If set to true, the exit function will avoid any asynchronous operations during exit. If set to false or not specified, the exit function may perform asynchronous operations as needed.\"\n />\n <hbr />\n <InterfaceMember\n name=\"signal\"\n optional\n type=\"number\"\n doc=\"The signal number that triggered the exit. This is typically used when the shutdown is initiated by a system signal (e.g., SIGINT, SIGTERM).\"\n />\n </InterfaceDeclaration>\n <hbr />\n <hbr />\n <VarDeclaration\n let\n name=\"isExiting\"\n type=\"boolean\"\n initializer={code`false;`}\n />\n <VarDeclaration\n const\n name=\"callbackAsyncQueue\"\n type=\"Array<[(code: number | string) => Promise<void> | void, number]>\"\n initializer={code`[];`}\n />\n <VarDeclaration\n const\n name=\"callbackSyncQueue\"\n type=\"Array<(code: number | string) => void>\"\n initializer={code`[];`}\n />\n <hbr />\n <hbr />\n <FunctionDeclaration\n export\n async\n name=\"exit\"\n parameters={[\n {\n name: \"options\",\n type: \"ExitOptions\",\n default: \"{}\"\n }\n ]}>\n {code`\n try {\n if (isExiting) {\n return;\n }\n\n isExiting = true;\n\n let exitCode: number | string = 0;\n if ((options.signal !== undefined && options.signal > 0) || options.exception) {\n exitCode = 128 + (options.signal ?? 1);\n } else if (typeof process.exitCode === \"number\" || typeof process.exitCode === \"string\") {\n exitCode = process.exitCode;\n }\n\n if (options.exception) {\n error(\\`A fatal error occured while running the application - please contact the ${getAppTitle(\n context\n )} support team: \\\\n\\${typeof options.exception === \"string\" ? options.exception : options.exception.message}\\`);\n }\n\n const terminate = (force = false) => {\n verbose(\\`The ${getAppTitle(\n context\n )} application exited \\${options.exception ? \\`early due to an exception\\` : \"successfully\"}...\\`);\n if (!options.skipProcessExit) {\n process.exit(exitCode);\n }\n };\n\n for (const callbackSync of callbackSyncQueue) {\n callbackSync(exitCode);\n }\n\n if (!options.isSynchronous) {\n const promises = [];\n let forceAfter = 0;\n for (const [callbackAsync, wait] of callbackAsyncQueue) {\n forceAfter = Math.max(forceAfter, wait);\n promises.push(Promise.resolve(callbackAsync(exitCode)));\n }\n\n const asyncTimer = setTimeout(() => {\n terminate(true);\n }, forceAfter);\n await Promise.all(promises);\n clearTimeout(asyncTimer);\n }\n\n terminate();\n } catch (err) {\n error(\\`The exit process failed to complete\\${(err as Error).message ? \\` - (err as Error).message\\` : \"\"}. Please contact the ${getAppTitle(\n context\n )} support team.\\`);\n\n if (!options.skipProcessExit) {\n process.exit(1);\n }\n }\n `}\n </FunctionDeclaration>\n </>\n );\n}\n\n/**\n * A built-in utilities module for Shell Shock.\n */\nexport function UtilsBuiltin(props: UtilsBuiltinProps) {\n const [{ children }, rest] = splitProps(props, [\"children\"]);\n\n return (\n <BuiltinFile\n id=\"utils\"\n description=\"A collection of helper utilities that ease command-line application development.\"\n {...rest}\n imports={defu(rest.imports ?? {}, {\n \"node:os\": \"os\",\n \"node:process\": \"process\"\n })}\n builtinImports={defu(rest.builtinImports ?? {}, {\n console: [\"error\", \"verbose\"],\n env: [\"env\", \"isCI\", \"isTest\", \"isWindows\"]\n })}>\n <hbr />\n <hbr />\n <ArgsUtilities />\n <hbr />\n <hbr />\n <EnvSupportUtilities />\n <hbr />\n <hbr />\n <HyperlinkSupportUtilities />\n <hbr />\n <hbr />\n <ColorSupportUtilities />\n <hbr />\n <hbr />\n <ExitFunctionDeclaration />\n <hbr />\n <hbr />\n <Show when={Boolean(children)}>{children}</Show>\n </BuiltinFile>\n );\n}\n"],"mappings":";;;;;;;;;;;;;AA+CA,SAAgBe,sBAAsB;AACpC,QAAA;EAAAC,gBAEKV,gBAAc;GAAA,UAAA;GAAA,SAAA;GAGbW,MAAI;GACJC,KAAG;GACHC,aAAanB,IAAI;GAAkD,CAAA;EAAAoB,gBAAA,OAAA,EAAA,CAAA;EAAAA,gBAAA,OAAA,EAAA,CAAA;EAAAJ,gBAIpEV,gBAAc;GAAA,UAAA;GAAA,SAAA;GAGbW,MAAI;GACJC,KAAG;GACHC,aAAanB,IAAI;GAA4C,CAAA;EAAAoB,gBAAA,OAAA,EAAA,CAAA;EAAAA,gBAAA,OAAA,EAAA,CAAA;EAAAJ,gBAI9DV,gBAAc;GAAA,UAAA;GAAA,SAAA;GAGbW,MAAI;GACJC,KAAG;GACHC,aAAanB,IAAI;GAA8D,CAAA;EAAA;;;;;AASvF,SAAgBqB,wBAAwB;AACtC,QAAA;EAAAL,gBAEKZ,sBAAoB;GAAA,UAAA;GAEnBa,MAAI;GACJC,KAAG;GAAA,IAAAI,WAAA;AAAA,WAAAN,gBACFX,iBAAe;KACdY,MAAI;KACJM,MAAI;KACJL,KAAG;KAAA,CAAA;;GAAA,CAAA;EAAAE,gBAAA,OAAA,EAAA,CAAA;EAAA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AA,EAAA,CAAA;IAAAA,gBAAA,OAAA,EAAA,CAAA;IAAAJ,gBAGzBK,uBAAqB,EAAA,CAAA;IAAAD,gBAAA,OAAA,EAAA,CAAA;IAAAA,gBAAA,OAAA,EAAA,CAAA;IAAAJ,gBAGrBc,yBAAuB,EAAA,CAAA;IAAAV,gBAAA,OAAA,EAAA,CAAA;IAAAA,gBAAA,OAAA,EAAA,CAAA;IAAAJ,gBAGvBf,MAAI;KAAA,IAAC2C,OAAI;AAAA,aAAEC,QAAQvB,SAAS;;KAAGA;KAAQ,CAAA;IAAA;;EAAA,CAAA,CAAA"}
|
|
1
|
+
{"version":3,"file":"utils-builtin.mjs","names":["code","Show","splitProps","FunctionDeclaration","InterfaceDeclaration","InterfaceMember","VarDeclaration","usePowerlines","BuiltinFile","TSDoc","TSDocLink","TSDocParam","TSDocReturns","getAppTitle","defu","EnvSupportUtilities","_$createComponent","name","doc","initializer","_$createIntrinsic","ColorSupportUtilities","children","type","heading","parameters","default","HyperlinkSupportUtilities","returnType","ArgsUtilities","ExitFunctionDeclaration","context","optional","async","UtilsBuiltin","props","rest","_$mergeProps","id","description","imports","builtinImports","console","env","when","Boolean"],"sources":["../../src/components/utils-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, Show, splitProps } from \"@alloy-js/core\";\nimport {\n FunctionDeclaration,\n InterfaceDeclaration,\n InterfaceMember,\n VarDeclaration\n} from \"@alloy-js/typescript\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport type { BuiltinFileProps } from \"@powerlines/plugin-alloy/typescript/components/builtin-file\";\nimport { BuiltinFile } from \"@powerlines/plugin-alloy/typescript/components/builtin-file\";\nimport {\n TSDoc,\n TSDocLink,\n TSDocParam,\n TSDocReturns\n} from \"@powerlines/plugin-alloy/typescript/components/tsdoc\";\nimport { getAppTitle } from \"@shell-shock/core/plugin-utils/context-helpers\";\nimport defu from \"defu\";\nimport type { ScriptPresetContext } from \"../types/plugin\";\n\nexport interface UtilsBuiltinProps extends Omit<\n BuiltinFileProps,\n \"id\" | \"description\"\n> {}\n\n/**\n * Generates utilities for detecting terminal color support.\n */\n\nexport function EnvSupportUtilities() {\n return (\n <>\n <VarDeclaration\n export\n const\n name=\"isTTY\"\n doc=\"Detect if stdout.TTY is available\"\n initializer={code`Boolean(process.stdout && process.stdout.isTTY);`}\n />\n <hbr />\n <hbr />\n <VarDeclaration\n export\n const\n name=\"isMinimal\"\n doc=\"Detect if the current environment is minimal (CI, non-TTY, etc.)\"\n initializer={code` env.MINIMAL || isCI || isTest || !isTTY; `}\n />\n <hbr />\n <hbr />\n <VarDeclaration\n export\n const\n name=\"isInteractive\"\n doc=\"Detect if the current environment is interactive\"\n initializer={code` !isMinimal && process.stdin?.isTTY && env.TERM !== \"dumb\"; `}\n />\n </>\n );\n}\n\n/**\n * Generates utilities for detecting terminal color support.\n */\nexport function ColorSupportUtilities() {\n return (\n <>\n <InterfaceDeclaration\n export\n name=\"GetColorSupportLevelOptions\"\n doc=\"Options for the getColorSupportLevel function\">\n <InterfaceMember\n name=\"ignoreFlags\"\n type=\"boolean\"\n doc=\"Indicates if the function should skip checking command-line flags for color support\"\n />\n </InterfaceDeclaration>\n <hbr />\n <hbr />\n <TSDoc heading=\"Checks if a specific flag is present in the command line arguments.\">\n <TSDocLink>\n {\"https://github.com/sindresorhus/has-flag/blob/main/index.js\"}\n </TSDocLink>\n <TSDocParam name=\"flag\">\n {'The flag to check for, e.g., \"color\", \"no-color\".'}\n </TSDocParam>\n <TSDocParam name=\"argv\">\n {\n \"The command line arguments to check against. Defaults to global Deno args or process args.\"\n }\n </TSDocParam>\n <TSDocReturns>\n {\"True if the flag is present, false otherwise.\"}\n </TSDocReturns>\n </TSDoc>\n <FunctionDeclaration\n export\n name=\"getColorSupportLevel\"\n parameters={[\n { name: \"stream\", type: \"NodeJS.WriteStream & { fd: 1 | 2; }\" },\n {\n name: \"options\",\n type: \"GetColorSupportLevelOptions\",\n default: \"{ ignoreFlags: false }\"\n }\n ]}>\n {code`const { ignoreFlags } = options;\n\n let forceColor: number | undefined;\n if (env.FORCE_COLOR !== undefined) {\n forceColor = !env.FORCE_COLOR\n ? 0\n : typeof env.FORCE_COLOR === \"boolean\"\n ? 1\n : typeof env.FORCE_COLOR === \"number\" &&\n [0, 1, 2, 3].includes(Math.min(env.FORCE_COLOR as number, 3))\n ? Math.min(env.FORCE_COLOR as number, 3)\n : undefined;\n }\n\n if (ignoreFlags !== true && forceColor === undefined) {\n if (\n hasFlag(\"no-color\") ||\n hasFlag(\"no-colors\") ||\n hasFlag(\"color=false\") ||\n hasFlag(\"color=never\")\n ) {\n return 0;\n }\n\n if (\n hasFlag(\"color=16m\") ||\n hasFlag(\"color=full\") ||\n hasFlag(\"color=truecolor\")\n ) {\n return 3;\n }\n\n if (hasFlag(\"color=256\")) {\n return 2;\n }\n\n if (\n hasFlag(\"color\") ||\n hasFlag(\"colors\") ||\n hasFlag(\"color=true\") ||\n hasFlag(\"color=always\")\n ) {\n forceColor = 1;\n }\n }\n\n const level = Boolean(env.TF_BUILD) || Boolean(env.AGENT_NAME)\n ? 1\n : stream &&\n !(isTTY || (stream && stream.isTTY)) &&\n forceColor === undefined\n ? 0\n : env.TERM === \"dumb\"\n ? forceColor || 0\n : isWindows\n ? Number(os.release().split(\".\")[0]) >= 10 &&\n Number(os.release().split(\".\")[2]) >= 10_586\n ? Number(os.release().split(\".\")[2]) >= 14_931\n ? 3\n : 2\n : 1\n : isCI\n ? Boolean(env.GITHUB_ACTIONS) ||\n Boolean(env.GITEA_ACTIONS) ||\n Boolean(env.CIRCLECI)\n ? 3\n : Boolean(env.TRAVIS) ||\n Boolean(env.APPVEYOR) ||\n Boolean(env.GITLAB_CI) ||\n Boolean(env.BUILDKITE) ||\n Boolean(env.DRONE) ||\n env.CI_NAME === \"codeship\"\n ? 1\n : forceColor || 0\n : Boolean(env.TEAMCITY_VERSION)\n ? /^(?:9\\.0*[1-9]\\d*\\.|\\d{2,}\\.)/.test(String(env.TEAMCITY_VERSION) || \"\")\n ? 1\n : 0\n : String(env.COLORTERM) === \"truecolor\" ||\n env.TERM === \"xterm-kitty\"\n ? 3\n : Boolean(env.TERM_PROGRAM)\n ? env.TERM_PROGRAM === \"iTerm.app\"\n ? Number.parseInt(\n (env.TERM_PROGRAM_VERSION || \"\").split(\".\")[0] as string,\n 10\n ) >= 3\n ? 3\n : 2\n : env.TERM_PROGRAM === \"Apple_Terminal\"\n ? 2\n : 0\n : /-256(?:color)?$/i.test(env.TERM || \"\")\n ? 2\n : /^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(\n env.TERM || \"\"\n )\n ? 1\n : Boolean(env.COLORTERM);\n\n return typeof level === \"boolean\" || level === 0\n ? false\n : {\n level,\n hasBasic: true,\n has256: level >= 2,\n has16m: level >= 3,\n };\n\n `}\n </FunctionDeclaration>\n <hbr />\n <hbr />\n <VarDeclaration\n export\n const\n name=\"colorSupportLevels\"\n doc=\"Detect the terminal color support level in the current environment\"\n initializer={code` {\n stdout: getColorSupportLevel(process.stdout),\n stderr: getColorSupportLevel(process.stderr),\n }; `}\n />\n <hbr />\n <hbr />\n <VarDeclaration\n export\n const\n name=\"isColorSupported\"\n doc=\"Detect if terminal color is supported in the current environment\"\n initializer={code` Boolean(colorSupportLevels.stdout); `}\n />\n <hbr />\n <hbr />\n <VarDeclaration\n export\n const\n name=\"isUnicodeSupported\"\n doc=\"Detect if Unicode characters are supported in the current environment\"\n initializer={code` !isWindows\n ? env.TERM !== \"linux\"\n : Boolean(env.WT_SESSION) ||\n Boolean(env.TERMINUS_SUBLIME) ||\n env.ConEmuTask === \"{cmd::Cmder}\" ||\n env.TERM_PROGRAM === \"Terminus-Sublime\" ||\n env.TERM_PROGRAM === \"vscode\" ||\n env.TERM === \"xterm-256color\" ||\n env.TERM === \"alacritty\" ||\n env.TERM === \"rxvt-unicode\" ||\n env.TERM === \"rxvt-unicode-256color\" ||\n env.TERMINAL_EMULATOR === \"JetBrains-JediTerm\"; `}\n />\n </>\n );\n}\n\n/**\n * Generates utilities for detecting terminal color support.\n */\n\nexport function HyperlinkSupportUtilities() {\n return (\n <>\n <FunctionDeclaration\n name=\"parseVersion\"\n parameters={[{ name: \"version\", type: \"string\", default: '\"\"' }]}>\n {code`if (/^\\d{3,4}$/.test(version)) {\n const match = /(\\d{1,2})(\\d{2})/.exec(version) ?? [];\n\n return {\n major: 0,\n minor: Number.parseInt(match[1]!, 10),\n patch: Number.parseInt(match[2]!, 10)\n };\n }\n\n const versionParts = (version ?? \"\")\n .split(\".\")\n .map(n => Number.parseInt(n, 10));\n\n return {\n major: versionParts[0],\n minor: versionParts[1],\n patch: versionParts[2]\n }; `}\n </FunctionDeclaration>\n <hbr />\n <hbr />\n <TSDoc heading=\"Check if the current environment/terminal supports hyperlinks in the terminal.\">\n <TSDocReturns>\n {\"True if the current environment/terminal supports hyperlinks.\"}\n </TSDocReturns>\n </TSDoc>\n <FunctionDeclaration\n export\n name=\"isHyperlinkSupported\"\n returnType=\"boolean\">\n {code`if (Boolean(env.FORCE_HYPERLINK)) {\n return true;\n }\n\n if (Boolean(env.NETLIFY)) {\n return true;\n } else if (isColorSupported || isTTY) {\n return false;\n } else if (Boolean(env.WT_SESSION)) {\n return true;\n } else if (isWindows || isMinimal || Boolean(env.TEAMCITY_VERSION)) {\n return false;\n } else if (Boolean(env.TERM_PROGRAM)) {\n const version = parseVersion(env.TERM_PROGRAM_VERSION);\n\n switch (String(env.TERM_PROGRAM)) {\n case \"iTerm.app\": {\n if (version.major === 3) {\n return version.minor !== undefined && version.minor >= 1;\n }\n\n return version.major !== undefined && version.major > 3;\n }\n case \"WezTerm\": {\n return version.major !== undefined && version.major >= 20_200_620;\n }\n\n case \"vscode\": {\n if (Boolean(env.CURSOR_TRACE_ID)) {\n return true;\n }\n\n return (\n version.minor !== undefined &&\n version.major !== undefined &&\n (version.major > 1 || (version.major === 1 && version.minor >= 72))\n );\n }\n\n case \"ghostty\": {\n return true;\n }\n }\n }\n\n if (Boolean(env.VTE_VERSION)) {\n if (env.VTE_VERSION === \"0.50.0\") {\n return false;\n }\n\n const version = parseVersion(env.VTE_VERSION);\n return (\n (version.major !== undefined && version.major > 0) ||\n (version.minor !== undefined && version.minor >= 50)\n );\n }\n\n if (String(env.TERM) === \"alacritty\") {\n return true;\n }\n\n return false; `}\n </FunctionDeclaration>\n </>\n );\n}\n\n/**\n * Generates utilities for detecting terminal color support.\n */\nexport function ArgsUtilities() {\n return (\n <>\n <TSDoc heading=\"Retrieves the command line arguments from Deno or Node.js environments.\">\n <TSDocReturns>\n {\n \"An array of command line arguments from Deno or Node.js environments.\"\n }\n </TSDocReturns>\n </TSDoc>\n <FunctionDeclaration export name=\"getArgs\">\n {code`return ((globalThis as { Deno?: { args: string[] } })?.Deno?.args ?? process.argv ?? []) as string[];`}\n </FunctionDeclaration>\n <hbr />\n <hbr />\n <TSDoc heading=\"Checks if a specific flag is present in the command line arguments.\">\n <TSDocLink>\n {\"https://github.com/sindresorhus/has-flag/blob/main/index.js\"}\n </TSDocLink>\n <TSDocParam name=\"flag\">\n {\n 'The flag (or an array of flags/aliases) to check for, e.g., \"color\", \"no-color\".'\n }\n </TSDocParam>\n <TSDocParam name=\"argv\">\n {\n \"The command line arguments to check against. Defaults to global Deno args or process args.\"\n }\n </TSDocParam>\n <TSDocReturns>\n {\"True if the flag is present, false otherwise.\"}\n </TSDocReturns>\n </TSDoc>\n <FunctionDeclaration\n export\n name=\"hasFlag\"\n parameters={[\n { name: \"flag\", type: \"string | string[]\" },\n {\n name: \"argv\",\n type: \"string[]\",\n default: \"getArgs()\"\n }\n ]}>\n <VarDeclaration\n const\n name=\"position\"\n type=\"number\"\n initializer={code`(Array.isArray(flag) ? flag : [flag]).reduce((ret, f) => {\n const pos = argv.findIndex(arg => (f.startsWith(\"-\") ? \"\" : (f.length === 1 ? \"-\" : \"--\") + f)?.toLowerCase() === arg?.toLowerCase() || arg?.toLowerCase().startsWith((f.length === 1 ? \"-\" : \"--\") + f + \"=\"));\n return pos !== -1 ? pos : ret;\n }, -1);`}\n />\n <hbr />\n {code`return position !== -1 && argv.indexOf(\"--\") === -1 || position < argv.indexOf(\"--\");`}\n </FunctionDeclaration>\n </>\n );\n}\n\n/**\n * The `exit` handler function declaration code for the Shell Shock project.\n */\nexport function ExitFunctionDeclaration() {\n const context = usePowerlines<ScriptPresetContext>();\n\n return (\n <>\n <InterfaceDeclaration\n export\n name=\"ExitOptions\"\n doc=\"Options for the exit handler function.\">\n <InterfaceMember\n name=\"exception\"\n optional\n type=\"string | Error\"\n doc=\"An optional exception that caused the exit. This can be a string message or an Error object.\"\n />\n <hbr />\n <InterfaceMember\n name=\"skipProcessExit\"\n optional\n type=\"boolean\"\n doc=\"Indicates whether the exit function should manually exit the process or not. If set to true, the exit function will not call process.exit() and will allow the application to continue running. If set to false or not specified, the exit function will call process.exit() to terminate the application.\"\n />\n <hbr />\n <InterfaceMember\n name=\"isSynchronous\"\n optional\n type=\"boolean\"\n doc=\"Indicates whether the exit function should perform synchronous operations only. If set to true, the exit function will avoid any asynchronous operations during exit. If set to false or not specified, the exit function may perform asynchronous operations as needed.\"\n />\n <hbr />\n <InterfaceMember\n name=\"signal\"\n optional\n type=\"number\"\n doc=\"The signal number that triggered the exit. This is typically used when the shutdown is initiated by a system signal (e.g., SIGINT, SIGTERM).\"\n />\n </InterfaceDeclaration>\n <hbr />\n <hbr />\n <VarDeclaration\n let\n name=\"isExiting\"\n type=\"boolean\"\n initializer={code`false;`}\n />\n <VarDeclaration\n const\n name=\"callbackAsyncQueue\"\n type=\"Array<[(code: number | string) => Promise<void> | void, number]>\"\n initializer={code`[];`}\n />\n <VarDeclaration\n const\n name=\"callbackSyncQueue\"\n type=\"Array<(code: number | string) => void>\"\n initializer={code`[];`}\n />\n <hbr />\n <hbr />\n <FunctionDeclaration\n export\n async\n name=\"exit\"\n parameters={[\n {\n name: \"options\",\n type: \"ExitOptions\",\n default: \"{}\"\n }\n ]}>\n {code`\n try {\n if (isExiting) {\n return;\n }\n\n isExiting = true;\n\n let exitCode: number | string = 0;\n if ((options.signal !== undefined && options.signal > 0) || options.exception) {\n exitCode = 128 + (options.signal ?? 1);\n } else if (typeof process.exitCode === \"number\" || typeof process.exitCode === \"string\") {\n exitCode = process.exitCode;\n }\n\n if (options.exception) {\n error(\\`A fatal error occured while running the application - please contact the ${getAppTitle(\n context\n )} support team: \\\\n\\\\n\\${typeof options.exception === \"string\" ? options.exception : options.exception.message}\\`);\n }\n\n const terminate = (force = false) => {\n verbose(\\`The ${getAppTitle(\n context\n )} application exited \\${options.exception ? \\`early due to an exception\\` : \"successfully\"}...\\`);\n if (!options.skipProcessExit) {\n process.exit(exitCode);\n }\n };\n\n for (const callbackSync of callbackSyncQueue) {\n callbackSync(exitCode);\n }\n\n if (!options.isSynchronous) {\n const promises = [];\n let forceAfter = 0;\n for (const [callbackAsync, wait] of callbackAsyncQueue) {\n forceAfter = Math.max(forceAfter, wait);\n promises.push(Promise.resolve(callbackAsync(exitCode)));\n }\n\n const asyncTimer = setTimeout(() => {\n terminate(true);\n }, forceAfter);\n await Promise.all(promises);\n clearTimeout(asyncTimer);\n }\n\n terminate();\n } catch (err) {\n error(\\`The exit process failed to complete\\${(err as Error).message ? \\` - (err as Error).message\\` : \"\"}. Please contact the ${getAppTitle(\n context\n )} support team.\\`);\n\n if (!options.skipProcessExit) {\n process.exit(1);\n }\n }\n `}\n </FunctionDeclaration>\n </>\n );\n}\n\n/**\n * A built-in utilities module for Shell Shock.\n */\nexport function UtilsBuiltin(props: UtilsBuiltinProps) {\n const [{ children }, rest] = splitProps(props, [\"children\"]);\n\n return (\n <BuiltinFile\n id=\"utils\"\n description=\"A collection of helper utilities that ease command-line application development.\"\n {...rest}\n imports={defu(rest.imports ?? {}, {\n \"node:os\": \"os\",\n \"node:process\": \"process\"\n })}\n builtinImports={defu(rest.builtinImports ?? {}, {\n console: [\"error\", \"verbose\"],\n env: [\"env\", \"isCI\", \"isTest\", \"isWindows\"]\n })}>\n <hbr />\n <hbr />\n <ArgsUtilities />\n <hbr />\n <hbr />\n <EnvSupportUtilities />\n <hbr />\n <hbr />\n <HyperlinkSupportUtilities />\n <hbr />\n <hbr />\n <ColorSupportUtilities />\n <hbr />\n <hbr />\n <ExitFunctionDeclaration />\n <hbr />\n <hbr />\n <Show when={Boolean(children)}>{children}</Show>\n </BuiltinFile>\n );\n}\n"],"mappings":";;;;;;;;;;;;;AA+CA,SAAgBe,sBAAsB;AACpC,QAAA;EAAAC,gBAEKV,gBAAc;GAAA,UAAA;GAAA,SAAA;GAGbW,MAAI;GACJC,KAAG;GACHC,aAAanB,IAAI;GAAkD,CAAA;EAAAoB,gBAAA,OAAA,EAAA,CAAA;EAAAA,gBAAA,OAAA,EAAA,CAAA;EAAAJ,gBAIpEV,gBAAc;GAAA,UAAA;GAAA,SAAA;GAGbW,MAAI;GACJC,KAAG;GACHC,aAAanB,IAAI;GAA4C,CAAA;EAAAoB,gBAAA,OAAA,EAAA,CAAA;EAAAA,gBAAA,OAAA,EAAA,CAAA;EAAAJ,gBAI9DV,gBAAc;GAAA,UAAA;GAAA,SAAA;GAGbW,MAAI;GACJC,KAAG;GACHC,aAAanB,IAAI;GAA8D,CAAA;EAAA;;;;;AASvF,SAAgBqB,wBAAwB;AACtC,QAAA;EAAAL,gBAEKZ,sBAAoB;GAAA,UAAA;GAEnBa,MAAI;GACJC,KAAG;GAAA,IAAAI,WAAA;AAAA,WAAAN,gBACFX,iBAAe;KACdY,MAAI;KACJ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A,gBAAA,OAAA,EAAA,CAAA;IAAAJ,gBAGnBW,2BAAyB,EAAA,CAAA;IAAAP,gBAAA,OAAA,EAAA,CAAA;IAAAA,gBAAA,OAAA,EAAA,CAAA;IAAAJ,gBAGzBK,uBAAqB,EAAA,CAAA;IAAAD,gBAAA,OAAA,EAAA,CAAA;IAAAA,gBAAA,OAAA,EAAA,CAAA;IAAAJ,gBAGrBc,yBAAuB,EAAA,CAAA;IAAAV,gBAAA,OAAA,EAAA,CAAA;IAAAA,gBAAA,OAAA,EAAA,CAAA;IAAAJ,gBAGvBf,MAAI;KAAA,IAAC2C,OAAI;AAAA,aAAEC,QAAQvB,SAAS;;KAAGA;KAAQ,CAAA;IAAA;;EAAA,CAAA,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _alloy_js_core5 from "@alloy-js/core";
|
|
2
2
|
import { CommandTree } from "@shell-shock/core/types/command";
|
|
3
3
|
import { EntryFileProps } from "@powerlines/plugin-alloy/typescript/components/entry-file";
|
|
4
4
|
|
|
@@ -8,14 +8,14 @@ import { EntryFileProps } from "@powerlines/plugin-alloy/typescript/components/e
|
|
|
8
8
|
*/
|
|
9
9
|
declare function VirtualCommandHandlerDeclaration(props: {
|
|
10
10
|
command: CommandTree;
|
|
11
|
-
}):
|
|
11
|
+
}): _alloy_js_core5.Children;
|
|
12
12
|
interface VirtualCommandEntryProps extends Omit<EntryFileProps, "path" | "typeDefinition"> {
|
|
13
13
|
command: CommandTree;
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
16
|
* The virtual command entry point for the Shell Shock project.
|
|
17
17
|
*/
|
|
18
|
-
declare function VirtualCommandEntry(props: VirtualCommandEntryProps):
|
|
18
|
+
declare function VirtualCommandEntry(props: VirtualCommandEntryProps): _alloy_js_core5.Children;
|
|
19
19
|
//#endregion
|
|
20
20
|
export { VirtualCommandEntry, VirtualCommandEntryProps, VirtualCommandHandlerDeclaration };
|
|
21
21
|
//# sourceMappingURL=virtual-command-entry.d.cts.map
|
package/dist/contexts/theme.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
-
const
|
|
2
|
+
const require_helpers_ansi_utils = require('../helpers/ansi-utils.cjs');
|
|
3
3
|
let __alloy_js_core = require("@alloy-js/core");
|
|
4
4
|
let __powerlines_plugin_alloy_core_contexts_context = require("@powerlines/plugin-alloy/core/contexts/context");
|
|
5
5
|
|
|
@@ -20,7 +20,7 @@ function useTheme() {
|
|
|
20
20
|
*/
|
|
21
21
|
function useColors() {
|
|
22
22
|
const theme = useTheme();
|
|
23
|
-
return (0, __alloy_js_core.computed)(() =>
|
|
23
|
+
return (0, __alloy_js_core.computed)(() => require_helpers_ansi_utils.getAnsiStyles(theme.colors)).value;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme.cjs","names":["computed","usePowerlines","getAnsiStyles","useTheme","context","theme","value","useColors","colors"],"sources":["../../src/contexts/theme.ts"],"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 { computed } from \"@alloy-js/core\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport type { ThemeResolvedConfig } from \"@shell-shock/plugin-theme/types/theme\";\nimport type { AnsiStyles } from \"../helpers/ansi-utils\";\nimport { getAnsiStyles } from \"../helpers/ansi-utils\";\nimport type { ScriptPresetContext } from \"../types/plugin\";\n\n/**\n * Hook to access the current application's theme configuration.\n *\n * @returns The resolved theme configuration.\n */\nexport function useTheme(): ThemeResolvedConfig {\n const context = usePowerlines<ScriptPresetContext>();\n const theme = computed(() => context.theme);\n\n return theme.value;\n}\n\n/**\n * Hook to access the current application's ANSI colors/styles.\n *\n * @returns The ANSI colors/styles.\n */\nexport function useColors(): AnsiStyles {\n const theme = useTheme();\n const colors = computed(() => getAnsiStyles(theme.colors));\n\n return colors.value;\n}\n"],"mappings":";;;;;;;;;;;AA8BA,SAAgBG,WAAgC;CAC9C,MAAMC,8EAA8C;AAGpD,4CAF6BA,QAAQC,MAAM,CAE9BC;;;;;;;AAQf,SAAgBC,YAAwB;CACtC,MAAMF,QAAQF,UAAU;AAGxB,4CAF8BD,
|
|
1
|
+
{"version":3,"file":"theme.cjs","names":["computed","usePowerlines","getAnsiStyles","useTheme","context","theme","value","useColors","colors"],"sources":["../../src/contexts/theme.ts"],"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 { computed } from \"@alloy-js/core\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport type { ThemeResolvedConfig } from \"@shell-shock/plugin-theme/types/theme\";\nimport type { AnsiStyles } from \"../helpers/ansi-utils\";\nimport { getAnsiStyles } from \"../helpers/ansi-utils\";\nimport type { ScriptPresetContext } from \"../types/plugin\";\n\n/**\n * Hook to access the current application's theme configuration.\n *\n * @returns The resolved theme configuration.\n */\nexport function useTheme(): ThemeResolvedConfig {\n const context = usePowerlines<ScriptPresetContext>();\n const theme = computed(() => context.theme);\n\n return theme.value;\n}\n\n/**\n * Hook to access the current application's ANSI colors/styles.\n *\n * @returns The ANSI colors/styles.\n */\nexport function useColors(): AnsiStyles {\n const theme = useTheme();\n const colors = computed(() => getAnsiStyles(theme.colors));\n\n return colors.value;\n}\n"],"mappings":";;;;;;;;;;;AA8BA,SAAgBG,WAAgC;CAC9C,MAAMC,8EAA8C;AAGpD,4CAF6BA,QAAQC,MAAM,CAE9BC;;;;;;;AAQf,SAAgBC,YAAwB;CACtC,MAAMF,QAAQF,UAAU;AAGxB,4CAF8BD,yCAAcG,MAAMG,OAAO,CAAC,CAE5CF"}
|
|
@@ -63,6 +63,13 @@ type ThemeAnsiStyles = Record<"ansi16" | "ansi256" | "ansi16m", {
|
|
|
63
63
|
theme: ThemeAnsiStylesFormat<ThemeColorsResolvedConfig>;
|
|
64
64
|
}>;
|
|
65
65
|
type AnsiStyles = BaseAnsiStyles & ThemeAnsiStyles;
|
|
66
|
+
/**
|
|
67
|
+
* Generates ANSI styles based on the provided context.
|
|
68
|
+
*
|
|
69
|
+
* @param theme - The theme colors configuration.
|
|
70
|
+
* @returns The generated ANSI styles.
|
|
71
|
+
*/
|
|
72
|
+
declare function getAnsiStyles(theme: ThemeColorsResolvedConfig): AnsiStyles;
|
|
66
73
|
//#endregion
|
|
67
|
-
export { AnsiStyles };
|
|
74
|
+
export { AnsiStyles, AnsiWrappers, BaseAnsiStyles, BaseAnsiStylesKeys, ThemeAnsiStyles, bgColors, colors, getAnsiStyles, modifiers };
|
|
68
75
|
//# sourceMappingURL=ansi-utils.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ansi-utils.d.cts","names":[],"sources":["../../src/helpers/ansi-utils.ts"],"sourcesContent":[],"mappings":";;;cAsBa;;EAAA,IAAA,EAAA,MAUZ,EAAA;EAEY,GAAA,EAAA,MAqBZ,EAAA;EAEY,MAAA,EAAA,M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,MAAA,EAAA;EAF2B,MAAA,EAAA,MAAA,EAAA;EAAM,IAAA,EAAA,MAAA,EAAA;EAK9B,OAAA,EAAA,MAAA,EAAA;EAA2B,IAAA,EAAA,MAAA,EAAA;EAEd,KAAA,EAAA,MAAA,EAAA;EAA0B,WAAA,EAAA,MAAA,EAAA;EAAE,IAAA,EAAA,MAAA,EAAA;EAAxB,IAAA,EAAA,MAAA,EAAA;EAElB,SAAA,EAAA,MAAA,EAAA;EAAY,WAAA,EAAA,MAAA,EAAA;EAEJ,YAAA,EAAA,MAAe,EAAA;EAEM,UAAA,EAAA,MAAA,EAAA;EAAtB,aAAA,EAAA,MAAA,EAAA;EAFmB,UAAA,EAAA,MAAA,EAAA;EAAM,WAAA,EAAA,MAAA,EAAA;AAKpC,CAAA;AAwfgB,cA9jBH,QA8jBgB,EAAA;;;;;;;;;;;;;;;;;;;;UAviBZ,YAAA;;;;KA0BL,kBAAA,gBACK,yBACA,sBACA;KAEL,cAAA,GAAiB,yCAE3B,OAAO,oBAAoB;KAGxB,2BAA2B,iCAEd,IAAI,sBAAsB,EAAE,QAE1C;KAEQ,eAAA,GAAkB;SAEnB,sBAAsB;;KAGrB,UAAA,GAAa,iBAAiB;;;;;;;iBAwf1B,aAAA,QAAqB,4BAA4B"}
|
|
@@ -63,6 +63,13 @@ type ThemeAnsiStyles = Record<"ansi16" | "ansi256" | "ansi16m", {
|
|
|
63
63
|
theme: ThemeAnsiStylesFormat<ThemeColorsResolvedConfig>;
|
|
64
64
|
}>;
|
|
65
65
|
type AnsiStyles = BaseAnsiStyles & ThemeAnsiStyles;
|
|
66
|
+
/**
|
|
67
|
+
* Generates ANSI styles based on the provided context.
|
|
68
|
+
*
|
|
69
|
+
* @param theme - The theme colors configuration.
|
|
70
|
+
* @returns The generated ANSI styles.
|
|
71
|
+
*/
|
|
72
|
+
declare function getAnsiStyles(theme: ThemeColorsResolvedConfig): AnsiStyles;
|
|
66
73
|
//#endregion
|
|
67
|
-
export { AnsiStyles };
|
|
74
|
+
export { AnsiStyles, AnsiWrappers, BaseAnsiStyles, BaseAnsiStylesKeys, ThemeAnsiStyles, bgColors, colors, getAnsiStyles, modifiers };
|
|
68
75
|
//# sourceMappingURL=ansi-utils.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ansi-utils.d.mts","names":[],"sources":["../../src/helpers/ansi-utils.ts"],"sourcesContent":[],"mappings":";;;cAsBa;;EAAA,IAAA,EAAA,MAUZ,EAAA;EAEY,GAAA,EAAA,MAqBZ,EAAA;EAEY,MAAA,EAAA,MAqBZ,EAAA;EAEgB,SAAA,EAAA,MAAY,EAAA;EA0BjB,QAAA,EAAA,MAAA,EAAA;EACK,OAAA,EAAA,MAAA,EAAA;EACA,MAAA,EAAA,MAAA,EAAA;EACA,aAAA,EAAA,MAAA,EAAA;CAAQ;AAEb,cA7EC,MA6Ea,EAAA;EAEjB,KAAA,EAAA,MAAA,EAAA;EAAoB,GAAA,EAAA,MAAA,EAAA;EAA3B,KAAA,EAAA,MAAA,EAAA;EAF2B,MAAA,EAAA,MAAA,EAAA;EAAM,IAAA,EAAA,MAAA,EAAA;EAK9B,OAAA,EAAA,MAAA,EAAA;EAA2B,IAAA,EAAA,MAAA,EAAA;EAEd,KAAA,EAAA,MAAA,EAAA;EAA0B,WAAA,EAAA,MAAA,EAAA;EAAE,IAAA,EAAA,MAAA,EAAA;EAAxB,IAAA,EAAA,MAAA,EAAA;EAElB,SAAA,EAAA,MAAA,EAAA;EAAY,WAAA,EAAA,MAAA,EAAA;EAEJ,YAAA,EAAA,MAAe,EAAA;EAEM,UAAA,EAAA,MAAA,EAAA;EAAtB,aAAA,EAAA,MAAA,EAAA;EAFmB,UAAA,EAAA,MAAA,EAAA;EAAM,WAAA,EAAA,MAAA,EAAA;AAKpC,CAAA;
|
|
1
|
+
{"version":3,"file":"ansi-utils.d.mts","names":[],"sources":["../../src/helpers/ansi-utils.ts"],"sourcesContent":[],"mappings":";;;cAsBa;;EAAA,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+
//#region src/helpers/get-default-options.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Get the default command options.
|
|
7
|
+
*
|
|
8
|
+
* @returns The default command options.
|
|
9
|
+
*/
|
|
10
|
+
declare function getDefaultOptions(): CommandOption[];
|
|
11
|
+
//#endregion
|
|
12
|
+
export { getDefaultOptions };
|
|
13
|
+
//# sourceMappingURL=get-default-options.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-default-options.d.cts","names":[],"sources":["../../src/helpers/get-default-options.ts"],"sourcesContent":[],"mappings":";;;;;;AA0BA;;;iBAAgB,iBAAA,CAAA,GAAqB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CommandOption } from "@shell-shock/core";
|
|
2
|
+
|
|
3
|
+
//#region src/helpers/get-default-options.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Get the default command options.
|
|
7
|
+
*
|
|
8
|
+
* @returns The default command options.
|
|
9
|
+
*/
|
|
10
|
+
declare function getDefaultOptions(): CommandOption[];
|
|
11
|
+
//#endregion
|
|
12
|
+
export { getDefaultOptions };
|
|
13
|
+
//# sourceMappingURL=get-default-options.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-default-options.d.mts","names":[],"sources":["../../src/helpers/get-default-options.ts"],"sourcesContent":[],"mappings":";;;;;;AA0BA;;;iBAAgB,iBAAA,CAAA,GAAqB"}
|
package/dist/index.cjs
CHANGED
|
@@ -7,7 +7,7 @@ const require_components_virtual_command_entry = require('./components/virtual-c
|
|
|
7
7
|
const require_components_command_entry = require('./components/command-entry.cjs');
|
|
8
8
|
const require_components_console_builtin = require('./components/console-builtin.cjs');
|
|
9
9
|
const require_components_utils_builtin = require('./components/utils-builtin.cjs');
|
|
10
|
-
const
|
|
10
|
+
const require_helpers_get_default_options = require('./helpers/get-default-options.cjs');
|
|
11
11
|
let __alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
12
12
|
let __alloy_js_core = require("@alloy-js/core");
|
|
13
13
|
let __alloy_js_typescript = require("@alloy-js/typescript");
|
|
@@ -28,7 +28,7 @@ const plugin = (options = {}) => {
|
|
|
28
28
|
config() {
|
|
29
29
|
this.debug("Providing default configuration for the Shell Shock `script` preset.");
|
|
30
30
|
return {
|
|
31
|
-
defaultOptions:
|
|
31
|
+
defaultOptions: require_helpers_get_default_options.getDefaultOptions,
|
|
32
32
|
isCaseSensitive: false,
|
|
33
33
|
...options
|
|
34
34
|
};
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["code","For","Show","VarDeclaration","render","getAppBin","theme","BinEntry","CommandEntry","CommandRouter","ConsoleBuiltin","Help","HelpOptions","UtilsBuiltin","VirtualCommandEntry","getDefaultOptions","plugin","options","name","config","debug","defaultOptions","isCaseSensitive","configResolved","dependencies","didyoumean2","prepare","_$createComponent","order","handler","_self$","builtinImports","console","utils","children","when","Object","keys","commands","length","type","initializer","_$createIntrinsic","path","each","values","doubleHardline","joiner","ender","child","_$memo","title","isVirtual","description","command","indent","fallback"],"sources":["../src/index.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, For, Show } from \"@alloy-js/core\";\nimport { VarDeclaration } from \"@alloy-js/typescript\";\nimport { render } from \"@powerlines/plugin-alloy/render\";\nimport { getAppBin } from \"@shell-shock/core/plugin-utils/context-helpers\";\nimport theme from \"@shell-shock/plugin-theme\";\nimport type { Plugin } from \"powerlines/types/plugin\";\nimport { BinEntry } from \"./components/bin-entry\";\nimport { CommandEntry } from \"./components/command-entry\";\nimport { CommandRouter } from \"./components/command-router\";\nimport { ConsoleBuiltin } from \"./components/console-builtin\";\nimport { Help, HelpOptions } from \"./components/help\";\nimport { UtilsBuiltin } from \"./components/utils-builtin\";\nimport { VirtualCommandEntry } from \"./components/virtual-command-entry\";\nimport { getDefaultOptions } from \"./helpers/get-default-options\";\nimport type { ScriptPresetContext, ScriptPresetOptions } from \"./types/plugin\";\n\n/**\n * The Shell Shock base plugin.\n */\nexport const plugin = <\n TContext extends ScriptPresetContext = ScriptPresetContext\n>(\n options: ScriptPresetOptions = {}\n) => {\n return [\n theme({\n theme: options.theme\n }),\n {\n name: \"shell-shock:script-preset\",\n config() {\n this.debug(\n \"Providing default configuration for the Shell Shock `script` preset.\"\n );\n\n return {\n defaultOptions: getDefaultOptions,\n isCaseSensitive: false,\n ...options\n };\n },\n configResolved() {\n this.dependencies.didyoumean2 = \"^7.0.4\";\n },\n async prepare() {\n this.debug(\n \"Rendering built-in modules for the Shell Shock `script` preset.\"\n );\n\n return render(\n this,\n <>\n <UtilsBuiltin />\n <ConsoleBuiltin />\n </>\n );\n }\n },\n {\n name: \"shell-shock:script-preset:generate-entrypoint\",\n prepare: {\n order: \"post\",\n async handler() {\n this.debug(\n \"Rendering entrypoint modules for the Shell Shock `script` preset.\"\n );\n\n return render(\n this,\n <>\n <BinEntry\n builtinImports={{\n console: [\"divider\", \"writeLine\", \"colors\", \"banner\", \"help\"],\n utils: [\"getArgs\"]\n }}>\n <Show when={Object.keys(this.commands).length > 0}>\n <VarDeclaration\n const\n name=\"args\"\n type=\"string[]\"\n initializer={code`getArgs();`}\n />\n <hbr />\n <CommandRouter path={[]} commands={this.commands ?? {}} />\n <hbr />\n </Show>\n <hbr />\n {code`\n writeLine(\"\");\n banner();\n writeLine(\"\"); `}\n <hbr />\n <hbr />\n {code`writeLine(colors.text.heading.secondary(\"Global Options:\"));`}\n <hbr />\n <HelpOptions options={this.options} />\n {code`writeLine(\"\"); `}\n <hbr />\n <hbr />\n <Show when={Object.keys(this.commands).length > 0}>\n {code`writeLine(colors.text.body.secondary(\"The following commands are available:\"));\n writeLine(\"\"); `}\n <hbr />\n <hbr />\n <For\n each={Object.values(this.commands)}\n doubleHardline\n joiner={code`writeLine(\"\"); `}\n ender={code`writeLine(\"\"); `}>\n {child => (\n <>\n {code`\n writeLine(colors.text.heading.primary(\"${child.title} ${child.isVirtual ? \"\" : \"Command\"}\"));\n writeLine(\"\");\n writeLine(colors.text.body.secondary(\"${child.description}\"));\n writeLine(\"\");\n `}\n <hbr />\n <Help command={child} indent={2} />\n <hbr />\n </>\n )}\n </For>\n {code`help(\"Running a specific command with the help flag (via: '${getAppBin(this)} <specific command> --help') will provide additional information that is specific to that command.\");\n writeLine(\"\");`}\n </Show>\n </BinEntry>\n <Show when={Object.values(this.commands).length > 0}>\n <For each={Object.values(this.commands)} doubleHardline>\n {child => (\n <Show\n when={child.isVirtual}\n fallback={<CommandEntry command={child} />}>\n <VirtualCommandEntry command={child} />\n </Show>\n )}\n </For>\n </Show>\n </>\n );\n }\n }\n }\n ] as Plugin<TContext>[];\n};\n\nexport default plugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAqCA,MAAagB,UAGXC,UAA+B,EAAE,KAC9B;AACH,QAAO;0CACC,EACJX,OAAOW,QAAQX,OAChB,CAAC;EACF;GACEY,MAAM;GACNC,SAAS;AACP,SAAKC,MACH,uEACD;AAED,WAAO;KACLC,gBAAgBN;KAChBO,iBAAiB;KACjB,GAAGL;KACJ;;GAEHM,iBAAiB;AACf,SAAKC,aAAaC,cAAc;;GAElC,MAAMC,UAAU;AACd,SAAKN,MACH,kEACD;AAED,wDACE,MAAI,kDAEDP,+CAAY,EAAA,CAAA,mDACZH,mDAAc,EAAA,CAAA,CAEnB,CAAC;;GAEJ;EACD;GACEQ,MAAM;GACNQ,SAAS;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,WAC3Be,UAAK;yDAEDjD,oBAAI;yDAC4BiD,MAAME,MAAK,GAAIF,MAAMG,YAAY,KAAK,UAAS;;wDAEhDH,MAAMI,YAAW;;kBAExD;8DAAA,OAAA,EAAA,CAAA;8DAEQ1C,8BAAI;cAAC2C,SAASL;cAAOM,QAAQ;cAAC,CAAA;8DAAA,OAAA,EAAA,CAAA;aAAA;YAGlC,CAAA;uDAEFvD,oBAAI,6HAAuE8B,
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["code","For","Show","VarDeclaration","render","getAppBin","theme","BinEntry","CommandEntry","CommandRouter","ConsoleBuiltin","Help","HelpOptions","UtilsBuiltin","VirtualCommandEntry","getDefaultOptions","plugin","options","name","config","debug","defaultOptions","isCaseSensitive","configResolved","dependencies","didyoumean2","prepare","_$createComponent","order","handler","_self$","builtinImports","console","utils","children","when","Object","keys","commands","length","type","initializer","_$createIntrinsic","path","each","values","doubleHardline","joiner","ender","child","_$memo","title","isVirtual","description","command","indent","fallback"],"sources":["../src/index.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, For, Show } from \"@alloy-js/core\";\nimport { VarDeclaration } from \"@alloy-js/typescript\";\nimport { render } from \"@powerlines/plugin-alloy/render\";\nimport { getAppBin } from \"@shell-shock/core/plugin-utils/context-helpers\";\nimport theme from \"@shell-shock/plugin-theme\";\nimport type { Plugin } from \"powerlines/types/plugin\";\nimport { BinEntry } from \"./components/bin-entry\";\nimport { CommandEntry } from \"./components/command-entry\";\nimport { CommandRouter } from \"./components/command-router\";\nimport { ConsoleBuiltin } from \"./components/console-builtin\";\nimport { Help, HelpOptions } from \"./components/help\";\nimport { UtilsBuiltin } from \"./components/utils-builtin\";\nimport { VirtualCommandEntry } from \"./components/virtual-command-entry\";\nimport { getDefaultOptions } from \"./helpers/get-default-options\";\nimport type { ScriptPresetContext, ScriptPresetOptions } from \"./types/plugin\";\n\n/**\n * The Shell Shock base plugin.\n */\nexport const plugin = <\n TContext extends ScriptPresetContext = ScriptPresetContext\n>(\n options: ScriptPresetOptions = {}\n) => {\n return [\n theme({\n theme: options.theme\n }),\n {\n name: \"shell-shock:script-preset\",\n config() {\n this.debug(\n \"Providing default configuration for the Shell Shock `script` preset.\"\n );\n\n return {\n defaultOptions: getDefaultOptions,\n isCaseSensitive: false,\n ...options\n };\n },\n configResolved() {\n this.dependencies.didyoumean2 = \"^7.0.4\";\n },\n async prepare() {\n this.debug(\n \"Rendering built-in modules for the Shell Shock `script` preset.\"\n );\n\n return render(\n this,\n <>\n <UtilsBuiltin />\n <ConsoleBuiltin />\n </>\n );\n }\n },\n {\n name: \"shell-shock:script-preset:generate-entrypoint\",\n prepare: {\n order: \"post\",\n async handler() {\n this.debug(\n \"Rendering entrypoint modules for the Shell Shock `script` preset.\"\n );\n\n return render(\n this,\n <>\n <BinEntry\n builtinImports={{\n console: [\"divider\", \"writeLine\", \"colors\", \"banner\", \"help\"],\n utils: [\"getArgs\"]\n }}>\n <Show when={Object.keys(this.commands).length > 0}>\n <VarDeclaration\n const\n name=\"args\"\n type=\"string[]\"\n initializer={code`getArgs();`}\n />\n <hbr />\n <CommandRouter path={[]} commands={this.commands ?? {}} />\n <hbr />\n </Show>\n <hbr />\n {code`\n writeLine(\"\");\n banner();\n writeLine(\"\"); `}\n <hbr />\n <hbr />\n {code`writeLine(colors.text.heading.secondary(\"Global Options:\"));`}\n <hbr />\n <HelpOptions options={this.options} />\n {code`writeLine(\"\"); `}\n <hbr />\n <hbr />\n <Show when={Object.keys(this.commands).length > 0}>\n {code`writeLine(colors.text.body.secondary(\"The following commands are available:\"));\n writeLine(\"\"); `}\n <hbr />\n <hbr />\n <For\n each={Object.values(this.commands)}\n doubleHardline\n joiner={code`writeLine(\"\"); `}\n ender={code`writeLine(\"\"); `}>\n {child => (\n <>\n {code`\n writeLine(colors.text.heading.primary(\"${child.title} ${child.isVirtual ? \"\" : \"Command\"}\"));\n writeLine(\"\");\n writeLine(colors.text.body.secondary(\"${child.description}\"));\n writeLine(\"\");\n `}\n <hbr />\n <Help command={child} indent={2} />\n <hbr />\n </>\n )}\n </For>\n {code`help(\"Running a specific command with the help flag (via: '${getAppBin(\n this\n )} <specific command> --help') will provide additional information that is specific to that command.\");\n writeLine(\"\");`}\n </Show>\n </BinEntry>\n <Show when={Object.values(this.commands).length > 0}>\n <For each={Object.values(this.commands)} doubleHardline>\n {child => (\n <Show\n when={child.isVirtual}\n fallback={<CommandEntry command={child} />}>\n <VirtualCommandEntry command={child} />\n </Show>\n )}\n </For>\n </Show>\n </>\n );\n }\n }\n }\n ] as Plugin<TContext>[];\n};\n\nexport default plugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAqCA,MAAagB,UAGXC,UAA+B,EAAE,KAC9B;AACH,QAAO;0CACC,EACJX,OAAOW,QAAQX,OAChB,CAAC;EACF;GACEY,MAAM;GACNC,SAAS;AACP,SAAKC,MACH,uEACD;AAED,WAAO;KACLC,gBAAgBN;KAChBO,iBAAiB;KACjB,GAAGL;KACJ;;GAEHM,iBAAiB;AACf,SAAKC,aAAaC,cAAc;;GAElC,MAAMC,UAAU;AACd,SAAKN,MACH,kEACD;AAED,wDACE,MAAI,kDAEDP,+CAAY,EAAA,CAAA,mDACZH,mDAAc,EAAA,CAAA,CAEnB,CAAC;;GAEJ;EACD;GACEQ,MAAM;GACNQ,SAAS;IACPE,OAAO;IACP,MAAMC,UAAU;KAAA,MAAAC,SAAA;AACd,UAAKV,MACH,oEACD;AAED,yDACE,MAAI,kDAEDb,uCAAQ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,YAAW;;kBAExD;8DAAA,OAAA,EAAA,CAAA;8DAEQ1C,8BAAI;cAAC2C,SAASL;cAAOM,QAAQ;cAAC,CAAA;8DAAA,OAAA,EAAA,CAAA;aAAA;YAGlC,CAAA;uDAEFvD,oBAAI,6HAAuE8B,OAE3E,CAAA;kCACc;WAAA;;SAAA,CAAA;QAAA;;MAAA,CAAA,mDAGlB5B,sBAAI;MAAA,IAACiC,OAAI;AAAA,cAAEC,OAAOS,OAAOf,OAAKQ,SAAS,CAACC,SAAS;;MAAC,IAAAL,WAAA;AAAA,+DAChDjC,qBAAG;QAAA,IAAC2C,OAAI;AAAA,gBAAER,OAAOS,OAAOf,OAAKQ,SAAS;;QAAEQ,gBAAc;QAAAZ,WACpDe,2DACE/C,sBAAI;SAAA,IACHiC,OAAI;AAAA,iBAAEc,MAAMG;;SAAS,IACrBI,WAAQ;AAAA,kEAAGhD,+CAAY,EAAC8C,SAASL,OAAK,CAAA;;SAAA,IAAAf,WAAA;AAAA,kEACrCpB,8DAAmB,EAACwC,SAASL,OAAK,CAAA;;SAAA,CAAA;QAEtC,CAAA;;MAAA,CAAA,CAIT,CAAC;;IAEL;GACD;EACF;;AAGH,kBAAejC"}
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.tsx"],"sourcesContent":[],"mappings":";;;;;;;AAqCA;AACmB,cADN,MACM,EAAA,CAAA,iBAAA,mBAAA,GAAsB,mBAAtB,CAAA,CAAA,OAAA,CAAA,EAER,mBAFQ,EAAA,
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.tsx"],"sourcesContent":[],"mappings":";;;;;;;AAqCA;AACmB,cADN,MACM,EAAA,CAAA,iBAAA,mBAAA,GAAsB,mBAAtB,CAAA,CAAA,OAAA,CAAA,EAER,mBAFQ,EAAA,GA6HZ,MA7HY,CA6HL,QA7HK,CAAA,EAAA"}
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.tsx"],"sourcesContent":[],"mappings":";;;;;;;AAqCA;AACmB,cADN,MACM,EAAA,CAAA,iBAAA,mBAAA,GAAsB,mBAAtB,CAAA,CAAA,OAAA,CAAA,EAER,mBAFQ,EAAA,
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.tsx"],"sourcesContent":[],"mappings":";;;;;;;AAqCA;AACmB,cADN,MACM,EAAA,CAAA,iBAAA,mBAAA,GAAsB,mBAAtB,CAAA,CAAA,OAAA,CAAA,EAER,mBAFQ,EAAA,GA6HZ,MA7HY,CA6HL,QA7HK,CAAA,EAAA"}
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["code","For","Show","VarDeclaration","render","getAppBin","theme","BinEntry","CommandEntry","CommandRouter","ConsoleBuiltin","Help","HelpOptions","UtilsBuiltin","VirtualCommandEntry","getDefaultOptions","plugin","options","name","config","debug","defaultOptions","isCaseSensitive","configResolved","dependencies","didyoumean2","prepare","_$createComponent","order","handler","_self$","builtinImports","console","utils","children","when","Object","keys","commands","length","type","initializer","_$createIntrinsic","path","each","values","doubleHardline","joiner","ender","child","_$memo","title","isVirtual","description","command","indent","fallback"],"sources":["../src/index.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, For, Show } from \"@alloy-js/core\";\nimport { VarDeclaration } from \"@alloy-js/typescript\";\nimport { render } from \"@powerlines/plugin-alloy/render\";\nimport { getAppBin } from \"@shell-shock/core/plugin-utils/context-helpers\";\nimport theme from \"@shell-shock/plugin-theme\";\nimport type { Plugin } from \"powerlines/types/plugin\";\nimport { BinEntry } from \"./components/bin-entry\";\nimport { CommandEntry } from \"./components/command-entry\";\nimport { CommandRouter } from \"./components/command-router\";\nimport { ConsoleBuiltin } from \"./components/console-builtin\";\nimport { Help, HelpOptions } from \"./components/help\";\nimport { UtilsBuiltin } from \"./components/utils-builtin\";\nimport { VirtualCommandEntry } from \"./components/virtual-command-entry\";\nimport { getDefaultOptions } from \"./helpers/get-default-options\";\nimport type { ScriptPresetContext, ScriptPresetOptions } from \"./types/plugin\";\n\n/**\n * The Shell Shock base plugin.\n */\nexport const plugin = <\n TContext extends ScriptPresetContext = ScriptPresetContext\n>(\n options: ScriptPresetOptions = {}\n) => {\n return [\n theme({\n theme: options.theme\n }),\n {\n name: \"shell-shock:script-preset\",\n config() {\n this.debug(\n \"Providing default configuration for the Shell Shock `script` preset.\"\n );\n\n return {\n defaultOptions: getDefaultOptions,\n isCaseSensitive: false,\n ...options\n };\n },\n configResolved() {\n this.dependencies.didyoumean2 = \"^7.0.4\";\n },\n async prepare() {\n this.debug(\n \"Rendering built-in modules for the Shell Shock `script` preset.\"\n );\n\n return render(\n this,\n <>\n <UtilsBuiltin />\n <ConsoleBuiltin />\n </>\n );\n }\n },\n {\n name: \"shell-shock:script-preset:generate-entrypoint\",\n prepare: {\n order: \"post\",\n async handler() {\n this.debug(\n \"Rendering entrypoint modules for the Shell Shock `script` preset.\"\n );\n\n return render(\n this,\n <>\n <BinEntry\n builtinImports={{\n console: [\"divider\", \"writeLine\", \"colors\", \"banner\", \"help\"],\n utils: [\"getArgs\"]\n }}>\n <Show when={Object.keys(this.commands).length > 0}>\n <VarDeclaration\n const\n name=\"args\"\n type=\"string[]\"\n initializer={code`getArgs();`}\n />\n <hbr />\n <CommandRouter path={[]} commands={this.commands ?? {}} />\n <hbr />\n </Show>\n <hbr />\n {code`\n writeLine(\"\");\n banner();\n writeLine(\"\"); `}\n <hbr />\n <hbr />\n {code`writeLine(colors.text.heading.secondary(\"Global Options:\"));`}\n <hbr />\n <HelpOptions options={this.options} />\n {code`writeLine(\"\"); `}\n <hbr />\n <hbr />\n <Show when={Object.keys(this.commands).length > 0}>\n {code`writeLine(colors.text.body.secondary(\"The following commands are available:\"));\n writeLine(\"\"); `}\n <hbr />\n <hbr />\n <For\n each={Object.values(this.commands)}\n doubleHardline\n joiner={code`writeLine(\"\"); `}\n ender={code`writeLine(\"\"); `}>\n {child => (\n <>\n {code`\n writeLine(colors.text.heading.primary(\"${child.title} ${child.isVirtual ? \"\" : \"Command\"}\"));\n writeLine(\"\");\n writeLine(colors.text.body.secondary(\"${child.description}\"));\n writeLine(\"\");\n `}\n <hbr />\n <Help command={child} indent={2} />\n <hbr />\n </>\n )}\n </For>\n {code`help(\"Running a specific command with the help flag (via: '${getAppBin(this)} <specific command> --help') will provide additional information that is specific to that command.\");\n writeLine(\"\");`}\n </Show>\n </BinEntry>\n <Show when={Object.values(this.commands).length > 0}>\n <For each={Object.values(this.commands)} doubleHardline>\n {child => (\n <Show\n when={child.isVirtual}\n fallback={<CommandEntry command={child} />}>\n <VirtualCommandEntry command={child} />\n </Show>\n )}\n </For>\n </Show>\n </>\n );\n }\n }\n }\n ] as Plugin<TContext>[];\n};\n\nexport default plugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAqCA,MAAagB,UAGXC,UAA+B,EAAE,KAC9B;AACH,QAAO;EACLX,MAAM,EACJA,OAAOW,QAAQX,OAChB,CAAC;EACF;GACEY,MAAM;GACNC,SAAS;AACP,SAAKC,MACH,uEACD;AAED,WAAO;KACLC,gBAAgBN;KAChBO,iBAAiB;KACjB,GAAGL;KACJ;;GAEHM,iBAAiB;AACf,SAAKC,aAAaC,cAAc;;GAElC,MAAMC,UAAU;AACd,SAAKN,MACH,kEACD;AAED,WAAO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AC,IAAAL,WAAA;AAAA,iBAAA;WAC9ClC,IAAI;;WACW0C,gBAAA,OAAA,EAAA,CAAA;WAAAA,gBAAA,OAAA,EAAA,CAAA;WAAAf,gBAGf1B,KAAG;YAAA,IACF2C,OAAI;AAAA,oBAAER,OAAOS,OAAOf,OAAKQ,SAAS;;YAClCQ,gBAAc;YACdC,QAAQ/C,IAAI;YACZgD,OAAOhD,IAAI;YAAiBkC,WAC3Be,UAAK;aAAAC,WAEDlD,IAAI;yDAC4BiD,MAAME,MAAK,GAAIF,MAAMG,YAAY,KAAK,UAAS;;wDAEhDH,MAAMI,YAAW;;kBAExD;aAAAX,gBAAA,OAAA,EAAA,CAAA;aAAAf,gBAEQhB,MAAI;cAAC2C,SAASL;cAAOM,QAAQ;cAAC,CAAA;aAAAb,gBAAA,OAAA,EAAA,CAAA;aAAA;YAGlC,CAAA;WAAAQ,WAEFlD,IAAI,8DAA8DK,UAASyB,
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["code","For","Show","VarDeclaration","render","getAppBin","theme","BinEntry","CommandEntry","CommandRouter","ConsoleBuiltin","Help","HelpOptions","UtilsBuiltin","VirtualCommandEntry","getDefaultOptions","plugin","options","name","config","debug","defaultOptions","isCaseSensitive","configResolved","dependencies","didyoumean2","prepare","_$createComponent","order","handler","_self$","builtinImports","console","utils","children","when","Object","keys","commands","length","type","initializer","_$createIntrinsic","path","each","values","doubleHardline","joiner","ender","child","_$memo","title","isVirtual","description","command","indent","fallback"],"sources":["../src/index.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, For, Show } from \"@alloy-js/core\";\nimport { VarDeclaration } from \"@alloy-js/typescript\";\nimport { render } from \"@powerlines/plugin-alloy/render\";\nimport { getAppBin } from \"@shell-shock/core/plugin-utils/context-helpers\";\nimport theme from \"@shell-shock/plugin-theme\";\nimport type { Plugin } from \"powerlines/types/plugin\";\nimport { BinEntry } from \"./components/bin-entry\";\nimport { CommandEntry } from \"./components/command-entry\";\nimport { CommandRouter } from \"./components/command-router\";\nimport { ConsoleBuiltin } from \"./components/console-builtin\";\nimport { Help, HelpOptions } from \"./components/help\";\nimport { UtilsBuiltin } from \"./components/utils-builtin\";\nimport { VirtualCommandEntry } from \"./components/virtual-command-entry\";\nimport { getDefaultOptions } from \"./helpers/get-default-options\";\nimport type { ScriptPresetContext, ScriptPresetOptions } from \"./types/plugin\";\n\n/**\n * The Shell Shock base plugin.\n */\nexport const plugin = <\n TContext extends ScriptPresetContext = ScriptPresetContext\n>(\n options: ScriptPresetOptions = {}\n) => {\n return [\n theme({\n theme: options.theme\n }),\n {\n name: \"shell-shock:script-preset\",\n config() {\n this.debug(\n \"Providing default configuration for the Shell Shock `script` preset.\"\n );\n\n return {\n defaultOptions: getDefaultOptions,\n isCaseSensitive: false,\n ...options\n };\n },\n configResolved() {\n this.dependencies.didyoumean2 = \"^7.0.4\";\n },\n async prepare() {\n this.debug(\n \"Rendering built-in modules for the Shell Shock `script` preset.\"\n );\n\n return render(\n this,\n <>\n <UtilsBuiltin />\n <ConsoleBuiltin />\n </>\n );\n }\n },\n {\n name: \"shell-shock:script-preset:generate-entrypoint\",\n prepare: {\n order: \"post\",\n async handler() {\n this.debug(\n \"Rendering entrypoint modules for the Shell Shock `script` preset.\"\n );\n\n return render(\n this,\n <>\n <BinEntry\n builtinImports={{\n console: [\"divider\", \"writeLine\", \"colors\", \"banner\", \"help\"],\n utils: [\"getArgs\"]\n }}>\n <Show when={Object.keys(this.commands).length > 0}>\n <VarDeclaration\n const\n name=\"args\"\n type=\"string[]\"\n initializer={code`getArgs();`}\n />\n <hbr />\n <CommandRouter path={[]} commands={this.commands ?? {}} />\n <hbr />\n </Show>\n <hbr />\n {code`\n writeLine(\"\");\n banner();\n writeLine(\"\"); `}\n <hbr />\n <hbr />\n {code`writeLine(colors.text.heading.secondary(\"Global Options:\"));`}\n <hbr />\n <HelpOptions options={this.options} />\n {code`writeLine(\"\"); `}\n <hbr />\n <hbr />\n <Show when={Object.keys(this.commands).length > 0}>\n {code`writeLine(colors.text.body.secondary(\"The following commands are available:\"));\n writeLine(\"\"); `}\n <hbr />\n <hbr />\n <For\n each={Object.values(this.commands)}\n doubleHardline\n joiner={code`writeLine(\"\"); `}\n ender={code`writeLine(\"\"); `}>\n {child => (\n <>\n {code`\n writeLine(colors.text.heading.primary(\"${child.title} ${child.isVirtual ? \"\" : \"Command\"}\"));\n writeLine(\"\");\n writeLine(colors.text.body.secondary(\"${child.description}\"));\n writeLine(\"\");\n `}\n <hbr />\n <Help command={child} indent={2} />\n <hbr />\n </>\n )}\n </For>\n {code`help(\"Running a specific command with the help flag (via: '${getAppBin(\n this\n )} <specific command> --help') will provide additional information that is specific to that command.\");\n writeLine(\"\");`}\n </Show>\n </BinEntry>\n <Show when={Object.values(this.commands).length > 0}>\n <For each={Object.values(this.commands)} doubleHardline>\n {child => (\n <Show\n when={child.isVirtual}\n fallback={<CommandEntry command={child} />}>\n <VirtualCommandEntry command={child} />\n </Show>\n )}\n </For>\n </Show>\n </>\n );\n }\n }\n }\n ] as Plugin<TContext>[];\n};\n\nexport default plugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAqCA,MAAagB,UAGXC,UAA+B,EAAE,KAC9B;AACH,QAAO;EACLX,MAAM,EACJA,OAAOW,QAAQX,OAChB,CAAC;EACF;GACEY,MAAM;GACNC,SAAS;AACP,SAAKC,MACH,uEACD;AAED,WAAO;KACLC,gBAAgBN;KAChBO,iBAAiB;KACjB,GAAGL;KACJ;;GAEHM,iB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;;IAEL;GACD;EACF;;AAGH,kBAAejC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.cts","names":[],"sources":["../../src/types/plugin.ts"],"sourcesContent":[],"mappings":";;;;;;;UAmCiB,mBAAA,SACP,KAAK,4BAA4B,QAAQ;;AADnD;;;;;;;;;;EAmBY,cAAA,CAAA,EALN,aAK4B,EAAA,GAAA,CAAG,
|
|
1
|
+
{"version":3,"file":"plugin.d.cts","names":[],"sources":["../../src/types/plugin.ts"],"sourcesContent":[],"mappings":";;;;;;;UAmCiB,mBAAA,SACP,KAAK,4BAA4B,QAAQ;;AADnD;;;;;;;;;;EAmBY,cAAA,CAAA,EALN,aAK4B,EAAA,GAAA,CAAA,CAAG,OAAA,EAJpB,OAIiC,EAAA,KAAA,EAJjB,WAIoC,EAAA,GAJpB,aAIoB,EAAA,CAAA,GAAA,KAAA;AAErE;AAAyC,KAF7B,sBAAA,GAAyB,UAEI,GAFS,mBAET;AACzB,KADJ,0BAAA,GAA6B,cACzB,GAAd,QAAc,CAAL,IAAK,CAAA,mBAAA,EAAA,OAAA,CAAA,CAAA,GACd,yBADc;AAAL,KAGC,mBAHD,CAAA,wBAIe,0BAJf,GAKP,0BALO,CAAA,GAMP,kBANO,CAMY,eANZ,CAAA,GAOT,kBAPS,CAOU,eAPV,CAAA,GAQT,OARS,CAQD,eARC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.mts","names":[],"sources":["../../src/types/plugin.ts"],"sourcesContent":[],"mappings":";;;;;;;UAmCiB,mBAAA,SACP,KAAK,4BAA4B,QAAQ;;AADnD;;;;;;;;;;EAmBY,cAAA,CAAA,EALN,aAK4B,EAAA,GAAA,CAAA,
|
|
1
|
+
{"version":3,"file":"plugin.d.mts","names":[],"sources":["../../src/types/plugin.ts"],"sourcesContent":[],"mappings":";;;;;;;UAmCiB,mBAAA,SACP,KAAK,4BAA4B,QAAQ;;AADnD;;;;;;;;;;EAmBY,cAAA,CAAA,EALN,aAK4B,EAAA,GAAA,CAAG,CAAA,OAAA,EAJpB,OAIiC,EAAA,KAAA,EAJjB,WAIoC,EAAA,GAJpB,aAIoB,EAAA,CAAA,GAAA,KAAA;AAErE;AAAyC,KAF7B,sBAAA,GAAyB,UAEI,GAFS,mBAET;AACzB,KADJ,0BAAA,GAA6B,cACzB,GAAd,QAAc,CAAL,IAAK,CAAA,mBAAA,EAAA,OAAA,CAAA,CAAA,GACd,yBADc;AAAL,KAGC,mBAHD,CAAA,wBAIe,0BAJf,GAKP,0BALO,CAAA,GAMP,kBANO,CAMY,eANZ,CAAA,GAOT,kBAPS,CAOU,eAPV,CAAA,GAQT,OARS,CAQD,eARC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shell-shock/preset-script",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A Shell Shock preset that generates a fully-featured script application.",
|
|
6
6
|
"repository": {
|
|
@@ -209,6 +209,34 @@
|
|
|
209
209
|
"default": "./dist/contexts/theme.mjs"
|
|
210
210
|
}
|
|
211
211
|
},
|
|
212
|
+
"./helpers/ansi-utils": {
|
|
213
|
+
"require": {
|
|
214
|
+
"types": "./dist/helpers/ansi-utils.d.cts",
|
|
215
|
+
"default": "./dist/helpers/ansi-utils.cjs"
|
|
216
|
+
},
|
|
217
|
+
"import": {
|
|
218
|
+
"types": "./dist/helpers/ansi-utils.d.mts",
|
|
219
|
+
"default": "./dist/helpers/ansi-utils.mjs"
|
|
220
|
+
},
|
|
221
|
+
"default": {
|
|
222
|
+
"types": "./dist/helpers/ansi-utils.d.mts",
|
|
223
|
+
"default": "./dist/helpers/ansi-utils.mjs"
|
|
224
|
+
}
|
|
225
|
+
},
|
|
226
|
+
"./helpers/get-default-options": {
|
|
227
|
+
"require": {
|
|
228
|
+
"types": "./dist/helpers/get-default-options.d.cts",
|
|
229
|
+
"default": "./dist/helpers/get-default-options.cjs"
|
|
230
|
+
},
|
|
231
|
+
"import": {
|
|
232
|
+
"types": "./dist/helpers/get-default-options.d.mts",
|
|
233
|
+
"default": "./dist/helpers/get-default-options.mjs"
|
|
234
|
+
},
|
|
235
|
+
"default": {
|
|
236
|
+
"types": "./dist/helpers/get-default-options.d.mts",
|
|
237
|
+
"default": "./dist/helpers/get-default-options.mjs"
|
|
238
|
+
}
|
|
239
|
+
},
|
|
212
240
|
"./package.json": "./package.json",
|
|
213
241
|
"./types": {
|
|
214
242
|
"require": {
|
|
@@ -251,23 +279,23 @@
|
|
|
251
279
|
"dependencies": {
|
|
252
280
|
"@alloy-js/core": "0.22.0",
|
|
253
281
|
"@alloy-js/typescript": "^0.22.0",
|
|
254
|
-
"@powerlines/deepkit": "^0.6.
|
|
255
|
-
"@powerlines/plugin-alloy": "^0.20.
|
|
256
|
-
"@powerlines/plugin-plugin": "^0.12.
|
|
257
|
-
"@shell-shock/core": "^0.4.
|
|
258
|
-
"@shell-shock/plugin-theme": "^0.0.
|
|
282
|
+
"@powerlines/deepkit": "^0.6.47",
|
|
283
|
+
"@powerlines/plugin-alloy": "^0.20.10",
|
|
284
|
+
"@powerlines/plugin-plugin": "^0.12.218",
|
|
285
|
+
"@shell-shock/core": "^0.4.4",
|
|
286
|
+
"@shell-shock/plugin-theme": "^0.0.12",
|
|
259
287
|
"@stryke/path": "^0.26.4",
|
|
260
288
|
"@stryke/string-format": "^0.13.7",
|
|
261
289
|
"@stryke/type-checks": "^0.5.23",
|
|
262
290
|
"defu": "^6.1.4",
|
|
263
|
-
"powerlines": "^0.38.
|
|
291
|
+
"powerlines": "^0.38.34",
|
|
264
292
|
"@stryke/helpers": "0.9.40"
|
|
265
293
|
},
|
|
266
294
|
"devDependencies": {
|
|
267
295
|
"@babel/core": "^7.29.0",
|
|
268
|
-
"@powerlines/plugin-alloy": "^0.20.
|
|
269
|
-
"@types/node": "^22.19.
|
|
296
|
+
"@powerlines/plugin-alloy": "^0.20.10",
|
|
297
|
+
"@types/node": "^22.19.9"
|
|
270
298
|
},
|
|
271
299
|
"publishConfig": { "access": "public" },
|
|
272
|
-
"gitHead": "
|
|
300
|
+
"gitHead": "2905cdd0c86c5c4f8b4205e82fd180ee0b97351e"
|
|
273
301
|
}
|