@shell-shock/preset-script 0.6.0 → 0.6.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.
Files changed (63) hide show
  1. package/README.md +1 -1
  2. package/dist/components/banner-function-declaration.cjs +4 -2
  3. package/dist/components/banner-function-declaration.cjs.map +1 -1
  4. package/dist/components/banner-function-declaration.mjs +4 -2
  5. package/dist/components/banner-function-declaration.mjs.map +1 -1
  6. package/dist/components/bin-entry.cjs +9 -5
  7. package/dist/components/bin-entry.cjs.map +1 -1
  8. package/dist/components/bin-entry.d.cts.map +1 -1
  9. package/dist/components/bin-entry.d.mts.map +1 -1
  10. package/dist/components/bin-entry.mjs +9 -5
  11. package/dist/components/bin-entry.mjs.map +1 -1
  12. package/dist/components/command-entry.cjs +160 -155
  13. package/dist/components/command-entry.cjs.map +1 -1
  14. package/dist/components/command-entry.d.cts +8 -1
  15. package/dist/components/command-entry.d.cts.map +1 -1
  16. package/dist/components/command-entry.d.mts +8 -1
  17. package/dist/components/command-entry.d.mts.map +1 -1
  18. package/dist/components/command-entry.mjs +160 -156
  19. package/dist/components/command-entry.mjs.map +1 -1
  20. package/dist/components/command-router.cjs +90 -61
  21. package/dist/components/command-router.cjs.map +1 -1
  22. package/dist/components/command-router.d.cts +5 -1
  23. package/dist/components/command-router.d.cts.map +1 -1
  24. package/dist/components/command-router.d.mts +5 -1
  25. package/dist/components/command-router.d.mts.map +1 -1
  26. package/dist/components/command-router.mjs +90 -62
  27. package/dist/components/command-router.mjs.map +1 -1
  28. package/dist/components/console-builtin.cjs +27 -19
  29. package/dist/components/console-builtin.cjs.map +1 -1
  30. package/dist/components/console-builtin.d.cts +4 -2
  31. package/dist/components/console-builtin.d.cts.map +1 -1
  32. package/dist/components/console-builtin.d.mts +4 -2
  33. package/dist/components/console-builtin.d.mts.map +1 -1
  34. package/dist/components/console-builtin.mjs +27 -19
  35. package/dist/components/console-builtin.mjs.map +1 -1
  36. package/dist/components/help.d.cts +7 -7
  37. package/dist/components/help.d.cts.map +1 -1
  38. package/dist/components/helpers.d.cts +5 -5
  39. package/dist/components/index.cjs +2 -0
  40. package/dist/components/index.d.cts +4 -4
  41. package/dist/components/index.d.mts +4 -4
  42. package/dist/components/index.mjs +3 -3
  43. package/dist/components/utils-builtin.cjs +59 -92
  44. package/dist/components/utils-builtin.cjs.map +1 -1
  45. package/dist/components/utils-builtin.d.cts +8 -8
  46. package/dist/components/utils-builtin.d.cts.map +1 -1
  47. package/dist/components/utils-builtin.d.mts.map +1 -1
  48. package/dist/components/utils-builtin.mjs +60 -93
  49. package/dist/components/utils-builtin.mjs.map +1 -1
  50. package/dist/components/virtual-command-entry.cjs +16 -12
  51. package/dist/components/virtual-command-entry.cjs.map +1 -1
  52. package/dist/components/virtual-command-entry.d.cts.map +1 -1
  53. package/dist/components/virtual-command-entry.d.mts.map +1 -1
  54. package/dist/components/virtual-command-entry.mjs +16 -12
  55. package/dist/components/virtual-command-entry.mjs.map +1 -1
  56. package/dist/index.cjs +2 -3
  57. package/dist/index.cjs.map +1 -1
  58. package/dist/index.d.cts.map +1 -1
  59. package/dist/index.d.mts.map +1 -1
  60. package/dist/index.mjs +2 -3
  61. package/dist/index.mjs.map +1 -1
  62. package/dist/types/plugin.d.cts.map +1 -1
  63. package/package.json +8 -8
@@ -4,7 +4,7 @@ import { Show, code, splitProps } from "@alloy-js/core";
4
4
  import { FunctionDeclaration, IfStatement, InterfaceDeclaration, InterfaceMember, VarDeclaration } from "@alloy-js/typescript";
5
5
  import { usePowerlines } from "@powerlines/plugin-alloy/core/contexts/context";
6
6
  import { getAppTitle } from "@shell-shock/core/plugin-utils/context-helpers";
7
- import { TSDoc, TSDocLink, TSDocParam, TSDocReturns } from "@powerlines/plugin-alloy/typescript/components/tsdoc";
7
+ import { TSDoc, TSDocInternal, TSDocLink, TSDocParam, TSDocRemarks, TSDocReturns } from "@powerlines/plugin-alloy/typescript/components/tsdoc";
8
8
  import defu from "defu";
9
9
  import { BuiltinFile } from "@powerlines/plugin-alloy/typescript/components/builtin-file";
10
10
 
@@ -37,7 +37,7 @@ function EnvSupportUtilities() {
37
37
  "const": true,
38
38
  name: "isInteractive",
39
39
  doc: "Detect if the current environment is interactive",
40
- initializer: code` !isMinimal && process.stdin?.isTTY && env.TERM !== "dumb"; `
40
+ initializer: code` !isMinimal && process.stdin?.isTTY && env.TERM !== "dumb" && !hasFlag(["no-interactive", "non-interactive", "no-interact"]); `
41
41
  })
42
42
  ];
43
43
  }
@@ -359,12 +359,21 @@ function ArgsUtilities() {
359
359
  createComponent(TSDoc, {
360
360
  heading: "Retrieves the command line arguments from Deno or Node.js environments.",
361
361
  get children() {
362
- return createComponent(TSDocReturns, { children: "An array of command line arguments from Deno or Node.js environments." });
362
+ return [
363
+ createComponent(TSDocRemarks, { children: "This function is only intended for internal use. Please use `useArgs()` instead." }),
364
+ createIntrinsic("hbr", {}),
365
+ createIntrinsic("hbr", {}),
366
+ createComponent(TSDocInternal, {}),
367
+ createIntrinsic("hbr", {}),
368
+ createIntrinsic("hbr", {}),
369
+ createComponent(TSDocReturns, { children: "An array of command line arguments from Deno or Node.js environments." })
370
+ ];
363
371
  }
364
372
  }),
365
373
  createComponent(FunctionDeclaration, {
366
374
  "export": true,
367
375
  name: "getArgs",
376
+ returnType: "string[]",
368
377
  children: code`return ((globalThis as { Deno?: { args: string[] } })?.Deno?.args ?? process.argv ?? []) as string[];`
369
378
  }),
370
379
  createIntrinsic("hbr", {}),
@@ -395,7 +404,7 @@ function ArgsUtilities() {
395
404
  }, {
396
405
  name: "argv",
397
406
  type: "string[]",
398
- default: "getArgs()"
407
+ default: "useArgs()"
399
408
  }],
400
409
  get children() {
401
410
  return [
@@ -412,6 +421,14 @@ function ArgsUtilities() {
412
421
  code`return position !== -1 && argv.indexOf("--") === -1 || position < argv.indexOf("--");`
413
422
  ];
414
423
  }
424
+ }),
425
+ createIntrinsic("hbr", {}),
426
+ createIntrinsic("hbr", {}),
427
+ createComponent(VarDeclaration, {
428
+ "export": true,
429
+ name: "isHelp",
430
+ type: "boolean",
431
+ initializer: code` !isCI && hasFlag(["help", "h", "?"]); `
415
432
  })
416
433
  ];
417
434
  }
@@ -525,7 +542,7 @@ function ExitFunctionDeclaration() {
525
542
  }),
526
543
  createIntrinsic("hbr", {}),
527
544
  memo(() => code`
528
- verbose(\`The ${getAppTitle(context)} application exited \${options.exception ? \`early due to an exception\` : "successfully"}\${options.startDate ? \`. Total processing time is \${Date.now() - options.startDate.getTime() > 100_000 ? (Date.now() - options.startDate.getTime()) / 1000 : Date.now() - options.startDate.getTime()} \${Date.now() - options.startDate.getTime() > 100_000 ? "seconds" : "milliseconds"}\` : ""}...\`);
545
+ verbose(\`The ${getAppTitle(context)} application exited \${options.exception ? \`early due to an exception\` : "successfully"}\${options.startDate ? \`. Total processing time is \${Date.now() - options.startDate.getTime() > 5000 ? Math.floor((Date.now() - options.startDate.getTime()) / 1000) : Date.now() - options.startDate.getTime()} \${Date.now() - options.startDate.getTime() > 5000 ? "seconds" : "milliseconds"}\` : ""}...\`);
529
546
  if (!options.skipProcessExit) {
530
547
  process.exit(exitCode);
531
548
  }
@@ -567,86 +584,38 @@ function ExitFunctionDeclaration() {
567
584
  function ContextUtilities() {
568
585
  return code`
569
586
  /**
570
- * The context object for the current command execution, containing the command path and segments.
587
+ * The global Shell Shock - Application context instance.
588
+ *
589
+ * @internal
571
590
  */
572
- interface CommandContext {
573
- path: string;
574
- segments: string[];
575
- }
576
-
577
- interface UseCommandContext {
578
- /**
579
- * Get the current context. Throws if no context is set.
580
- */
581
- use: () => CommandContext;
591
+ export let internal_appContext = new AsyncLocalStorage<Map<string, any>>();
582
592
 
583
- /**
584
- * Call a function with a specific context instance. This is used internally to set the context for command executions, but can also be used by advanced users to manually set the context for specific operations if needed.
585
- */
586
- call: <R>(instance: CommandContext, callback: () => R | Promise<R>) => Promise<R>;
593
+ /**
594
+ * Get the Shell Shock - Application context for the current application.
595
+ *
596
+ * @param options - The options to use when getting the context.
597
+ * @returns The Shell Shock - Application context for the current application or undefined if the context is not available.
598
+ */
599
+ export function useApp(): Map<string, any> | undefined {
600
+ return internal_appContext.getStore();
587
601
  }
588
602
 
589
- const _globalThis = (
590
- typeof globalThis !== "undefined"
591
- ? globalThis
592
- : typeof self !== "undefined"
593
- ? self
594
- : typeof global !== "undefined"
595
- ? global
596
- : typeof window !== "undefined"
597
- ? window
598
- : {}
599
- ) as typeof globalThis;
600
-
601
- const asyncHandlers: Set<() => void | (() => void)> =
602
- (_globalThis as any)["__shell-shock_async_handlers__"] ||
603
- ((_globalThis as any)["__shell-shock_async_handlers__"] = new Set());
604
-
605
- function createContext(): UseCommandContext {
606
- let currentInstance: CommandContext | undefined;
607
- let als = new AsyncLocalStorage<CommandContext>();
608
- const getCurrentInstance = (): CommandContext | undefined => {
609
- if (als) {
610
- const instance = als.getStore();
611
- if (instance) {
612
- return instance;
613
- }
614
- }
615
- return currentInstance;
616
- };
617
-
618
- const result = {
619
- use() {
620
- const instance = getCurrentInstance();
621
- if (!instance) {
622
- throw new Error(
623
- \`The Shell Shock - Command context is not available. Make sure to call useCommand() within a valid context scope.\`
624
- );
625
- }
626
- return instance;
627
- },
628
- async call(instance: CommandContext, callback: () => Promise<any> | any) {
629
- currentInstance = instance;
630
- const onRestore = () => {
631
- currentInstance = instance;
632
- };
633
- const onLeave = () =>
634
- currentInstance === instance ? onRestore : undefined;
635
-
636
- asyncHandlers.add(onLeave);
637
-
638
- try {
639
- return await (als ? als.run(instance, callback) : callback());
640
- } finally {
641
- asyncHandlers.delete(onLeave);
642
- }
643
- },
644
- };
645
-
646
- ((_globalThis as any)["__shell-shock__"]) ??= {};
647
- ((_globalThis as any)["__shell-shock__"]).__command__ = result;
603
+ /**
604
+ * A utility hook function to get the command line arguments from the application context.
605
+ *
606
+ * @returns An array of command line arguments from the application context.
607
+ * @throws If the application context is not available.
608
+ */
609
+ export function useArgs(): string[] {
610
+ return useApp()?.get("args") ?? getArgs();
611
+ }
648
612
 
649
- return result;
613
+ /**
614
+ * The context object for the current command execution, containing the command path and segments.
615
+ */
616
+ export interface CommandContext {
617
+ path: string;
618
+ segments: string[];
650
619
  }
651
620
 
652
621
  /**
@@ -654,7 +623,7 @@ function ContextUtilities() {
654
623
  *
655
624
  * @internal
656
625
  */
657
- export let internal_commandContext = createContext();
626
+ export let internal_commandContext = new AsyncLocalStorage<CommandContext>();
658
627
 
659
628
  /**
660
629
  * Get the Shell Shock - Command context for the current application.
@@ -663,16 +632,14 @@ function ContextUtilities() {
663
632
  * @returns The Shell Shock - Command context for the current application.
664
633
  * @throws If the Shell Shock - Command context is not available.
665
634
  */
666
- function useCommand(): CommandContext {
667
- if (!internal_commandContext) {
668
- if ((_globalThis as any)["__shell-shock__"]?.__command__) {
669
- internal_commandContext = (_globalThis as any)["__shell-shock__"].__command__;
670
- } else {
671
- internal_commandContext = createContext();
672
- }
635
+ export function useCommand(): CommandContext {
636
+ const result = internal_commandContext.getStore();
637
+ if (!result) {
638
+ throw new Error(
639
+ \`The Shell Shock - Command context is not available. Make sure to call useCommand() within a valid context scope.\`
640
+ );
673
641
  }
674
-
675
- return internal_commandContext.use();
642
+ return result;
676
643
  }
677
644
 
678
645
  /**
@@ -731,6 +698,9 @@ function UtilsBuiltin(props) {
731
698
  },
732
699
  get children() {
733
700
  return [
701
+ createIntrinsic("hbr", {}),
702
+ createIntrinsic("hbr", {}),
703
+ createComponent(ContextUtilities, {}),
734
704
  createIntrinsic("hbr", {}),
735
705
  createIntrinsic("hbr", {}),
736
706
  createComponent(ArgsUtilities, {}),
@@ -745,9 +715,6 @@ function UtilsBuiltin(props) {
745
715
  createComponent(ColorSupportUtilities, {}),
746
716
  createIntrinsic("hbr", {}),
747
717
  createIntrinsic("hbr", {}),
748
- createComponent(ContextUtilities, {}),
749
- createIntrinsic("hbr", {}),
750
- createIntrinsic("hbr", {}),
751
718
  createComponent(ExitFunctionDeclaration, {}),
752
719
  createIntrinsic("hbr", {}),
753
720
  createIntrinsic("hbr", {}),
@@ -1 +1 @@
1
- {"version":3,"file":"utils-builtin.mjs","names":["code","Show","splitProps","FunctionDeclaration","IfStatement","InterfaceDeclaration","InterfaceMember","VarDeclaration","usePowerlines","BuiltinFile","TSDoc","TSDocLink","TSDocParam","TSDocReturns","getAppTitle","defu","IsVerbose","EnvSupportUtilities","_$createComponent","name","doc","initializer","_$createIntrinsic","ColorSupportUtilities","children","type","heading","parameters","default","HyperlinkSupportUtilities","returnType","ArgsUtilities","ExitFunctionDeclaration","context","optional","async","_$memo","condition","ContextUtilities","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 IfStatement,\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\";\nimport { IsVerbose } from \"./helpers\";\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 <hbr />\n <InterfaceMember\n name=\"startDate\"\n optional\n type=\"Date\"\n doc=\"A Date object representing the timestamp when the process started. This can be used to measure the duration of the shutdown process.\"\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 <IfStatement\n condition={<IsVerbose />}>{code`writeLine(\"\");`}</IfStatement>\n <hbr />\n {code`\n verbose(\\`The ${getAppTitle(\n context\n )} application exited \\${options.exception ? \\`early due to an exception\\` : \"successfully\"}\\${options.startDate ? \\`. Total processing time is \\${Date.now() - options.startDate.getTime() > 100_000 ? (Date.now() - options.startDate.getTime()) / 1000 : Date.now() - options.startDate.getTime()} \\${Date.now() - options.startDate.getTime() > 100_000 ? \"seconds\" : \"milliseconds\"}\\` : \"\"}...\\`);\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\nexport function ContextUtilities() {\n return code`\n /**\n * The context object for the current command execution, containing the command path and segments.\n */\n interface CommandContext {\n path: string;\n segments: string[];\n }\n\n interface UseCommandContext {\n /**\n * Get the current context. Throws if no context is set.\n */\n use: () => CommandContext;\n\n /**\n * Call a function with a specific context instance. This is used internally to set the context for command executions, but can also be used by advanced users to manually set the context for specific operations if needed.\n */\n call: <R>(instance: CommandContext, callback: () => R | Promise<R>) => Promise<R>;\n }\n\n const _globalThis = (\n typeof globalThis !== \"undefined\"\n ? globalThis\n : typeof self !== \"undefined\"\n ? self\n : typeof global !== \"undefined\"\n ? global\n : typeof window !== \"undefined\"\n ? window\n : {}\n ) as typeof globalThis;\n\n const asyncHandlers: Set<() => void | (() => void)> =\n (_globalThis as any)[\"__shell-shock_async_handlers__\"] ||\n ((_globalThis as any)[\"__shell-shock_async_handlers__\"] = new Set());\n\n function createContext(): UseCommandContext {\n let currentInstance: CommandContext | undefined;\n let als = new AsyncLocalStorage<CommandContext>();\n const getCurrentInstance = (): CommandContext | undefined => {\n if (als) {\n const instance = als.getStore();\n if (instance) {\n return instance;\n }\n }\n return currentInstance;\n };\n\n const result = {\n use() {\n const instance = getCurrentInstance();\n if (!instance) {\n throw new Error(\n \\`The Shell Shock - Command context is not available. Make sure to call useCommand() within a valid context scope.\\`\n );\n }\n return instance;\n },\n async call(instance: CommandContext, callback: () => Promise<any> | any) {\n currentInstance = instance;\n const onRestore = () => {\n currentInstance = instance;\n };\n const onLeave = () =>\n currentInstance === instance ? onRestore : undefined;\n\n asyncHandlers.add(onLeave);\n\n try {\n return await (als ? als.run(instance, callback) : callback());\n } finally {\n asyncHandlers.delete(onLeave);\n }\n },\n };\n\n ((_globalThis as any)[\"__shell-shock__\"]) ??= {};\n ((_globalThis as any)[\"__shell-shock__\"]).__command__ = result;\n\n return result;\n }\n\n /**\n * The global Shell Shock - Command context instance.\n *\n * @internal\n */\n export let internal_commandContext = createContext();\n\n /**\n * Get the Shell Shock - Command context for the current application.\n *\n * @param options - The options to use when getting the context.\n * @returns The Shell Shock - Command context for the current application.\n * @throws If the Shell Shock - Command context is not available.\n */\n function useCommand(): CommandContext {\n if (!internal_commandContext) {\n if ((_globalThis as any)[\"__shell-shock__\"]?.__command__) {\n internal_commandContext = (_globalThis as any)[\"__shell-shock__\"].__command__;\n } else {\n internal_commandContext = createContext();\n }\n }\n\n return internal_commandContext.use();\n }\n\n /**\n * A utility hook function to get the individual segments of the current command path.\n *\n * @returns An array of command path segments.\n * @throws If the command context is not available.\n */\n export function useSegments(): string[] {\n return useCommand().segments;\n }\n\n /**\n * A utility hook function to get the full command path as a string.\n *\n * @returns The full command path as a string.\n * @throws If the command context is not available.\n */\n export function usePath(): string {\n return useCommand().path;\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 \"node:async_hooks\": [\"AsyncLocalStorage\"]\n })}\n builtinImports={defu(rest.builtinImports ?? {}, {\n console: [\"error\", \"verbose\", \"writeLine\"],\n env: [\"env\", \"isCI\", \"isTest\", \"isWindows\", \"isDevelopment\", \"isDebug\"]\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 <ContextUtilities />\n <hbr />\n <hbr />\n <ExitFunctionDeclaration />\n <hbr />\n <hbr />\n <Show when={Boolean(children)}>{children}</Show>\n </BuiltinFile>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AAiDA,SAAgBiB,sBAAsB;AACpC,QAAA;EAAAC,gBAEKX,gBAAc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BAAyB,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,gBAGrBoB,kBAAgB,EAAA,CAAA;IAAAhB,gBAAA,OAAA,EAAA,CAAA;IAAAA,gBAAA,OAAA,EAAA,CAAA;IAAAJ,gBAGhBc,yBAAuB,EAAA,CAAA;IAAAV,gBAAA,OAAA,EAAA,CAAA;IAAAA,gBAAA,OAAA,EAAA,CAAA;IAAAJ,gBAGvBjB,MAAI;KAAA,IAACgD,OAAI;AAAA,aAAEC,QAAQ1B,SAAS;;KAAGA;KAAQ,CAAA;IAAA;;EAAA,CAAA,CAAA"}
1
+ {"version":3,"file":"utils-builtin.mjs","names":["code","Show","splitProps","FunctionDeclaration","IfStatement","InterfaceDeclaration","InterfaceMember","VarDeclaration","usePowerlines","BuiltinFile","TSDoc","TSDocInternal","TSDocLink","TSDocParam","TSDocRemarks","TSDocReturns","getAppTitle","defu","IsVerbose","EnvSupportUtilities","_$createComponent","name","doc","initializer","_$createIntrinsic","ColorSupportUtilities","children","type","heading","parameters","default","HyperlinkSupportUtilities","returnType","ArgsUtilities","ExitFunctionDeclaration","context","optional","async","_$memo","condition","ContextUtilities","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 IfStatement,\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 TSDocInternal,\n TSDocLink,\n TSDocParam,\n TSDocRemarks,\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\";\nimport { IsVerbose } from \"./helpers\";\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\" && !hasFlag([\"no-interactive\", \"non-interactive\", \"no-interact\"]); `}\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 <TSDocRemarks>\n {\n \"This function is only intended for internal use. Please use `useArgs()` instead.\"\n }\n </TSDocRemarks>\n <hbr />\n <hbr />\n <TSDocInternal />\n <hbr />\n <hbr />\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\" returnType=\"string[]\">\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: \"useArgs()\"\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 <hbr />\n <hbr />\n <VarDeclaration\n export\n name=\"isHelp\"\n type=\"boolean\"\n initializer={code` !isCI && hasFlag([\"help\", \"h\", \"?\"]); `}\n />\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 <hbr />\n <InterfaceMember\n name=\"startDate\"\n optional\n type=\"Date\"\n doc=\"A Date object representing the timestamp when the process started. This can be used to measure the duration of the shutdown process.\"\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 <IfStatement\n condition={<IsVerbose />}>{code`writeLine(\"\");`}</IfStatement>\n <hbr />\n {code`\n verbose(\\`The ${getAppTitle(\n context\n )} application exited \\${options.exception ? \\`early due to an exception\\` : \"successfully\"}\\${options.startDate ? \\`. Total processing time is \\${Date.now() - options.startDate.getTime() > 5000 ? Math.floor((Date.now() - options.startDate.getTime()) / 1000) : Date.now() - options.startDate.getTime()} \\${Date.now() - options.startDate.getTime() > 5000 ? \"seconds\" : \"milliseconds\"}\\` : \"\"}...\\`);\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\nexport function ContextUtilities() {\n return code`\n /**\n * The global Shell Shock - Application context instance.\n *\n * @internal\n */\n export let internal_appContext = new AsyncLocalStorage<Map<string, any>>();\n\n /**\n * Get the Shell Shock - Application context for the current application.\n *\n * @param options - The options to use when getting the context.\n * @returns The Shell Shock - Application context for the current application or undefined if the context is not available.\n */\n export function useApp(): Map<string, any> | undefined {\n return internal_appContext.getStore();\n }\n\n /**\n * A utility hook function to get the command line arguments from the application context.\n *\n * @returns An array of command line arguments from the application context.\n * @throws If the application context is not available.\n */\n export function useArgs(): string[] {\n return useApp()?.get(\"args\") ?? getArgs();\n }\n\n /**\n * The context object for the current command execution, containing the command path and segments.\n */\n export interface CommandContext {\n path: string;\n segments: string[];\n }\n\n /**\n * The global Shell Shock - Command context instance.\n *\n * @internal\n */\n export let internal_commandContext = new AsyncLocalStorage<CommandContext>();\n\n /**\n * Get the Shell Shock - Command context for the current application.\n *\n * @param options - The options to use when getting the context.\n * @returns The Shell Shock - Command context for the current application.\n * @throws If the Shell Shock - Command context is not available.\n */\n export function useCommand(): CommandContext {\n const result = internal_commandContext.getStore();\n if (!result) {\n throw new Error(\n \\`The Shell Shock - Command context is not available. Make sure to call useCommand() within a valid context scope.\\`\n );\n }\n return result;\n }\n\n /**\n * A utility hook function to get the individual segments of the current command path.\n *\n * @returns An array of command path segments.\n * @throws If the command context is not available.\n */\n export function useSegments(): string[] {\n return useCommand().segments;\n }\n\n /**\n * A utility hook function to get the full command path as a string.\n *\n * @returns The full command path as a string.\n * @throws If the command context is not available.\n */\n export function usePath(): string {\n return useCommand().path;\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 \"node:async_hooks\": [\"AsyncLocalStorage\"]\n })}\n builtinImports={defu(rest.builtinImports ?? {}, {\n console: [\"error\", \"verbose\", \"writeLine\"],\n env: [\"env\", \"isCI\", \"isTest\", \"isWindows\", \"isDevelopment\", \"isDebug\"]\n })}>\n <hbr />\n <hbr />\n <ContextUtilities />\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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C,iBAAc;AAAA,UAAE/B,KAAK0B,KAAKK,kBAAkB,EAAE,EAAE;IAC9CC,SAAS;KAAC;KAAS;KAAW;KAAY;IAC1CC,KAAK;KAAC;KAAO;KAAQ;KAAU;KAAa;KAAiB;KAAS;IACvE,CAAC;;EAAA,IAAAxB,WAAA;AAAA,UAAA;IAAAF,gBAAA,OAAA,EAAA,CAAA;IAAAA,gBAAA,OAAA,EAAA,CAAA;IAAAJ,gBAGDoB,kBAAgB,EAAA,CAAA;IAAAhB,gBAAA,OAAA,EAAA,CAAA;IAAAA,gBAAA,OAAA,EAAA,CAAA;IAAAJ,gBAGhBa,eAAa,EAAA,CAAA;IAAAT,gBAAA,OAAA,EAAA,CAAA;IAAAA,gBAAA,OAAA,EAAA,CAAA;IAAAJ,gBAGbD,qBAAmB,EAAA,CAAA;IAAAK,gBAAA,OAAA,EAAA,CAAA;IAAAA,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,gBAGvBnB,MAAI;KAAA,IAACkD,OAAI;AAAA,aAAEC,QAAQ1B,SAAS;;KAAGA;KAAQ,CAAA;IAAA;;EAAA,CAAA,CAAA"}
@@ -49,25 +49,17 @@ function VirtualCommandHandlerDeclaration(props) {
49
49
  parameters: [{
50
50
  name: "args",
51
51
  type: "string[]",
52
- default: "getArgs()"
52
+ default: "useArgs()"
53
53
  }],
54
54
  get children() {
55
55
  return [
56
56
  (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
57
57
  (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
58
58
  children,
59
- (0, __alloy_js_core_jsx_runtime.createComponent)(require_components_command_router.CommandRouter, {
60
- get segments() {
61
- return command.segments;
62
- },
63
- get commands() {
64
- return command.children;
65
- }
66
- }),
67
59
  (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
68
60
  (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
69
61
  __alloy_js_core.code`writeLine("");
70
- banner();`,
62
+ banner(); `,
71
63
  (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
72
64
  (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
73
65
  (0, __alloy_js_core_jsx_runtime.createComponent)(require_components_help.VirtualHelp, {
@@ -125,7 +117,7 @@ function VirtualCommandEntry(props) {
125
117
  "stripAnsi"
126
118
  ],
127
119
  utils: [
128
- "getArgs",
120
+ "useArgs",
129
121
  "hasFlag",
130
122
  "isMinimal",
131
123
  "isUnicodeSupported"
@@ -137,7 +129,19 @@ function VirtualCommandEntry(props) {
137
129
  (0, __alloy_js_core_jsx_runtime.createComponent)(require_components_banner_function_declaration.BannerFunctionDeclaration, { command }),
138
130
  (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
139
131
  (0, __alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {}),
140
- (0, __alloy_js_core_jsx_runtime.createComponent)(VirtualCommandHandlerDeclaration, { command })
132
+ (0, __alloy_js_core_jsx_runtime.createComponent)(VirtualCommandHandlerDeclaration, {
133
+ command,
134
+ get children() {
135
+ return (0, __alloy_js_core_jsx_runtime.createComponent)(require_components_command_router.CommandRouter, {
136
+ get segments() {
137
+ return command.segments;
138
+ },
139
+ get commands() {
140
+ return command.children;
141
+ }
142
+ });
143
+ }
144
+ })
141
145
  ];
142
146
  }
143
147
  })), (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.For, {
@@ -1 +1 @@
1
- {"version":3,"file":"virtual-command-entry.cjs","names":["code","computed","For","Show","FunctionDeclaration","usePowerlines","TSDoc","TSDocParam","TSDocRemarks","TSDocTitle","TypescriptFile","getAppBin","getDynamicPathSegmentName","isDynamicPathSegment","joinPaths","constantCase","pascalCase","defu","BannerFunctionDeclaration","CommandEntry","CommandRouter","VirtualHelp","VirtualCommandHandlerDeclaration","props","command","children","context","_$createComponent","heading","title","segments","map","segment","join","description","replace","_$createIntrinsic","name","async","parameters","type","default","commands","options","Object","values","VirtualCommandEntry","imports","builtinImports","rest","filePath","entryPath","filter","_$mergeProps","path","value","didyoumean2","entries","child","isVirtual","reduce","ret","alias","console","utils","each","when","fallback"],"sources":["../../src/components/virtual-command-entry.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { Children } from \"@alloy-js/core\";\nimport { code, computed, For, Show } from \"@alloy-js/core\";\nimport { FunctionDeclaration } from \"@alloy-js/typescript\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport type { TypescriptFileImports } from \"@powerlines/plugin-alloy/types/components\";\nimport type { EntryFileProps } from \"@powerlines/plugin-alloy/typescript/components/entry-file\";\nimport {\n TSDoc,\n TSDocParam,\n TSDocRemarks,\n TSDocTitle\n} from \"@powerlines/plugin-alloy/typescript/components/tsdoc\";\nimport { TypescriptFile } from \"@powerlines/plugin-alloy/typescript/components/typescript-file\";\nimport {\n getAppBin,\n getDynamicPathSegmentName,\n isDynamicPathSegment\n} from \"@shell-shock/core/plugin-utils/context-helpers\";\nimport type { CommandTree } from \"@shell-shock/core/types/command\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { constantCase } from \"@stryke/string-format/constant-case\";\nimport { pascalCase } from \"@stryke/string-format/pascal-case\";\nimport defu from \"defu\";\nimport type { ScriptPresetContext } from \"../types/plugin\";\nimport { BannerFunctionDeclaration } from \"./banner-function-declaration\";\nimport { CommandEntry } from \"./command-entry\";\nimport { CommandRouter } from \"./command-router\";\nimport { VirtualHelp } from \"./help\";\n\nexport interface VirtualCommandHandlerDeclarationProps {\n command: CommandTree;\n children?: Children;\n}\n\n/**\n * A component that generates the `handler` function declaration for a command.\n */\nexport function VirtualCommandHandlerDeclaration(\n props: VirtualCommandHandlerDeclarationProps\n) {\n const { command, children } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n\n return (\n <>\n <TSDoc\n heading={`The ${command.title} (${getAppBin(context)} ${command.segments\n .map(segment =>\n isDynamicPathSegment(segment)\n ? `[${constantCase(getDynamicPathSegmentName(segment))}]`\n : segment\n )\n .join(\" \")}) virtual command.`}>\n <TSDocRemarks>{`${command.description.replace(/\\.+$/, \"\")}.`}</TSDocRemarks>\n <hbr />\n <TSDocTitle>{command.title}</TSDocTitle>\n <TSDocParam name=\"args\">{`The command-line arguments passed to the command.`}</TSDocParam>\n </TSDoc>\n <FunctionDeclaration\n export\n async\n name=\"handler\"\n parameters={[{ name: \"args\", type: \"string[]\", default: \"getArgs()\" }]}>\n <hbr />\n <hbr />\n {children}\n <CommandRouter\n segments={command.segments}\n commands={command.children}\n />\n <hbr />\n <hbr />\n {code`writeLine(\"\");\n banner();`}\n <hbr />\n <hbr />\n <VirtualHelp\n segments={command.segments}\n options={Object.values(command.options)}\n commands={command.children ?? {}}\n />\n </FunctionDeclaration>\n </>\n );\n}\n\nexport interface VirtualCommandEntryProps extends Omit<\n EntryFileProps,\n \"path\" | \"typeDefinition\"\n> {\n command: CommandTree;\n}\n\n/**\n * The virtual command entry point for the Shell Shock project.\n */\nexport function VirtualCommandEntry(props: VirtualCommandEntryProps) {\n const { command, imports, builtinImports, ...rest } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n const filePath = computed(() =>\n joinPaths(\n context.entryPath,\n command.segments\n .filter(segment => !isDynamicPathSegment(segment))\n .join(\"/\"),\n \"index.ts\"\n )\n );\n\n return (\n <>\n <TypescriptFile\n {...rest}\n path={filePath.value}\n imports={defu(\n {\n didyoumean2: [\n { name: \"didYouMean\", default: true },\n { name: \"ReturnTypeEnums\" },\n { name: \"ThresholdTypeEnums\" }\n ]\n },\n imports ?? {},\n Object.entries(command.children)\n .filter(([, child]) => child.isVirtual)\n .reduce((ret, [name, child]) => {\n ret[`./${child.name}`] = [\n { name: \"handler\", alias: `handle${pascalCase(name)}` }\n ];\n\n return ret;\n }, {} as TypescriptFileImports)\n )}\n builtinImports={defu(builtinImports ?? {}, {\n console: [\n \"help\",\n \"warn\",\n \"error\",\n \"table\",\n \"colors\",\n \"writeLine\",\n \"splitText\",\n \"stripAnsi\"\n ],\n utils: [\"getArgs\", \"hasFlag\", \"isMinimal\", \"isUnicodeSupported\"]\n })}>\n <BannerFunctionDeclaration command={command} />\n <hbr />\n <hbr />\n <VirtualCommandHandlerDeclaration command={command} />\n </TypescriptFile>\n <For each={Object.values(command.children)}>\n {child => (\n <Show\n when={child.isVirtual}\n fallback={<CommandEntry command={child} />}>\n <VirtualCommandEntry command={child} />\n </Show>\n )}\n </For>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAuDA,SAAgBsB,iCACdC,OACA;CACA,MAAM,EAAEC,SAASC,aAAaF;CAE9B,MAAMG,8EAA8C;AAEpD,QAAA,kDAEKpB,6DAAK;EAAA,IACJsB,UAAO;AAAA,UAAE,OAAOJ,QAAQK,MAAK,mEAAeH,QAAQ,CAAA,GAAIF,QAAQM,SAC7DC,KAAIC,sFACkBA,QAAQ,GACzB,0IAA2CA,QAAQ,CAAC,CAAA,KACpDA,QACL,CACAC,KAAK,IAAI,CAAA;;EAAoB,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aration","usePowerlines","TSDoc","TSDocParam","TSDocRemarks","TSDocTitle","TypescriptFile","getAppBin","getDynamicPathSegmentName","isDynamicPathSegment","joinPaths","constantCase","pascalCase","defu","BannerFunctionDeclaration","CommandEntry","CommandRouter","VirtualHelp","VirtualCommandHandlerDeclaration","props","command","children","context","_$createComponent","heading","title","segments","map","segment","join","description","replace","_$createIntrinsic","name","async","parameters","type","default","options","Object","values","commands","VirtualCommandEntry","imports","builtinImports","rest","filePath","entryPath","filter","_$mergeProps","path","value","didyoumean2","entries","child","isVirtual","reduce","ret","alias","console","utils","each","when","fallback"],"sources":["../../src/components/virtual-command-entry.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Shell Shock\n\n This code was released as part of the Shell Shock project. Shell Shock\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/shell-shock.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/shell-shock\n Documentation: https://docs.stormsoftware.com/projects/shell-shock\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { Children } from \"@alloy-js/core\";\nimport { code, computed, For, Show } from \"@alloy-js/core\";\nimport { FunctionDeclaration } from \"@alloy-js/typescript\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport type { TypescriptFileImports } from \"@powerlines/plugin-alloy/types/components\";\nimport type { EntryFileProps } from \"@powerlines/plugin-alloy/typescript/components/entry-file\";\nimport {\n TSDoc,\n TSDocParam,\n TSDocRemarks,\n TSDocTitle\n} from \"@powerlines/plugin-alloy/typescript/components/tsdoc\";\nimport { TypescriptFile } from \"@powerlines/plugin-alloy/typescript/components/typescript-file\";\nimport {\n getAppBin,\n getDynamicPathSegmentName,\n isDynamicPathSegment\n} from \"@shell-shock/core/plugin-utils/context-helpers\";\nimport type { CommandTree } from \"@shell-shock/core/types/command\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { constantCase } from \"@stryke/string-format/constant-case\";\nimport { pascalCase } from \"@stryke/string-format/pascal-case\";\nimport defu from \"defu\";\nimport type { ScriptPresetContext } from \"../types/plugin\";\nimport { BannerFunctionDeclaration } from \"./banner-function-declaration\";\nimport { CommandEntry } from \"./command-entry\";\nimport { CommandRouter } from \"./command-router\";\nimport { VirtualHelp } from \"./help\";\n\nexport interface VirtualCommandHandlerDeclarationProps {\n command: CommandTree;\n children?: Children;\n}\n\n/**\n * A component that generates the `handler` function declaration for a command.\n */\nexport function VirtualCommandHandlerDeclaration(\n props: VirtualCommandHandlerDeclarationProps\n) {\n const { command, children } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n\n return (\n <>\n <TSDoc\n heading={`The ${command.title} (${getAppBin(context)} ${command.segments\n .map(segment =>\n isDynamicPathSegment(segment)\n ? `[${constantCase(getDynamicPathSegmentName(segment))}]`\n : segment\n )\n .join(\" \")}) virtual command.`}>\n <TSDocRemarks>{`${command.description.replace(/\\.+$/, \"\")}.`}</TSDocRemarks>\n <hbr />\n <TSDocTitle>{command.title}</TSDocTitle>\n <TSDocParam name=\"args\">{`The command-line arguments passed to the command.`}</TSDocParam>\n </TSDoc>\n <FunctionDeclaration\n export\n async\n name=\"handler\"\n parameters={[{ name: \"args\", type: \"string[]\", default: \"useArgs()\" }]}>\n <hbr />\n <hbr />\n {children}\n <hbr />\n <hbr />\n {code`writeLine(\"\");\n banner(); `}\n <hbr />\n <hbr />\n <VirtualHelp\n segments={command.segments}\n options={Object.values(command.options)}\n commands={command.children ?? {}}\n />\n </FunctionDeclaration>\n </>\n );\n}\n\nexport interface VirtualCommandEntryProps extends Omit<\n EntryFileProps,\n \"path\" | \"typeDefinition\"\n> {\n command: CommandTree;\n}\n\n/**\n * The virtual command entry point for the Shell Shock project.\n */\nexport function VirtualCommandEntry(props: VirtualCommandEntryProps) {\n const { command, imports, builtinImports, ...rest } = props;\n\n const context = usePowerlines<ScriptPresetContext>();\n const filePath = computed(() =>\n joinPaths(\n context.entryPath,\n command.segments\n .filter(segment => !isDynamicPathSegment(segment))\n .join(\"/\"),\n \"index.ts\"\n )\n );\n\n return (\n <>\n <TypescriptFile\n {...rest}\n path={filePath.value}\n imports={defu(\n {\n didyoumean2: [\n { name: \"didYouMean\", default: true },\n { name: \"ReturnTypeEnums\" },\n { name: \"ThresholdTypeEnums\" }\n ]\n },\n imports ?? {},\n Object.entries(command.children)\n .filter(([, child]) => child.isVirtual)\n .reduce((ret, [name, child]) => {\n ret[`./${child.name}`] = [\n { name: \"handler\", alias: `handle${pascalCase(name)}` }\n ];\n\n return ret;\n }, {} as TypescriptFileImports)\n )}\n builtinImports={defu(builtinImports ?? {}, {\n console: [\n \"help\",\n \"warn\",\n \"error\",\n \"table\",\n \"colors\",\n \"writeLine\",\n \"splitText\",\n \"stripAnsi\"\n ],\n utils: [\"useArgs\", \"hasFlag\", \"isMinimal\", \"isUnicodeSupported\"]\n })}>\n <BannerFunctionDeclaration command={command} />\n <hbr />\n <hbr />\n <VirtualCommandHandlerDeclaration command={command}>\n <CommandRouter\n segments={command.segments}\n commands={command.children}\n />\n </VirtualCommandHandlerDeclaration>\n </TypescriptFile>\n <For each={Object.values(command.children)}>\n {child => (\n <Show\n when={child.isVirtual}\n fallback={<CommandEntry command={child} />}>\n <VirtualCommandEntry command={child} />\n </Show>\n )}\n </For>\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAuDA,SAAgBsB,iCACdC,OACA;CACA,MAAM,EAAEC,SAASC,aAAaF;CAE9B,MAAMG,8EAA8C;AAEpD,QAAA,kDAEKpB,6DAAK;EAAA,IACJsB,UAAO;AAAA,UAAE,OAAOJ,QAAQK,MAAK,mEAAeH,QAAQ,CAAA,GAAIF,QAAQM,SAC7DC,KAAIC,sFACkBA,QAAQ,GACzB,0IAA2CA,QAAQ,CAAC,CAAA,KACpDA,QACL,CACAC,KAAK,IAAI,CAAA;;EAAoB,IAAAR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ual-command-entry.d.cts","names":[],"sources":["../../src/components/virtual-command-entry.tsx"],"sourcesContent":[],"mappings":";;;;;UA+CiB,qCAAA;WACN;EADM,QAAA,CAAA,EAEJ,QAFI;AAQjB;AAkDA;;;AAAkD,iBAlDlC,gCAAA,CAkDkC,KAAA,EAjDzC,qCAiDyC,CAAA,EAjDJ,QAiDI;AAAI,UAArC,wBAAA,SAAiC,IAAI,CACpD,cADoD,EAAA,MAAA,GAAA,gBAAA,CAAA,CAAA;EAUtC,OAAA,EANL,WAMK;;;;;iBAAA,mBAAA,QAA2B,2BAAwB"}
1
+ {"version":3,"file":"virtual-command-entry.d.cts","names":[],"sources":["../../src/components/virtual-command-entry.tsx"],"sourcesContent":[],"mappings":";;;;;UA+CiB,qCAAA;WACN;EADM,QAAA,CAAA,EAEJ,QAFI;AAQjB;AA8CA;;;AAAkD,iBA9ClC,gCAAA,CA8CkC,KAAA,EA7CzC,qCA6CyC,CAAA,EA7CJ,QA6CI;AAAI,UAArC,wBAAA,SAAiC,IAAI,CACpD,cADoD,EAAA,MAAA,GAAA,gBAAA,CAAA,CAAA;EAUtC,OAAA,EANL,WAMK;;;;;iBAAA,mBAAA,QAA2B,2BAAwB"}
@@ -1 +1 @@
1
- {"version":3,"file":"virtual-command-entry.d.mts","names":[],"sources":["../../src/components/virtual-command-entry.tsx"],"sourcesContent":[],"mappings":";;;;;UA+CiB,qCAAA;WACN;EADM,QAAA,CAAA,EAEJ,QAFI;AAQjB;AAkDA;;;AAAkD,iBAlDlC,gCAAA,CAkDkC,KAAA,EAjDzC,qCAiDyC,CAAA,EAjDJ,QAiDI;AAAI,UAArC,wBAAA,SAAiC,IAAI,CACpD,cADoD,EAAA,MAAA,GAAA,gBAAA,CAAA,CAAA;EAUtC,OAAA,EANL,WAMK;;;;;iBAAA,mBAAA,QAA2B,2BAAwB"}
1
+ {"version":3,"file":"virtual-command-entry.d.mts","names":[],"sources":["../../src/components/virtual-command-entry.tsx"],"sourcesContent":[],"mappings":";;;;;UA+CiB,qCAAA;WACN;EADM,QAAA,CAAA,EAEJ,QAFI;AAQjB;AA8CA;;;AAAkD,iBA9ClC,gCAAA,CA8CkC,KAAA,EA7CzC,qCA6CyC,CAAA,EA7CJ,QA6CI;AAAI,UAArC,wBAAA,SAAiC,IAAI,CACpD,cADoD,EAAA,MAAA,GAAA,gBAAA,CAAA,CAAA;EAUtC,OAAA,EANL,WAMK;;;;;iBAAA,mBAAA,QAA2B,2BAAwB"}
@@ -47,25 +47,17 @@ function VirtualCommandHandlerDeclaration(props) {
47
47
  parameters: [{
48
48
  name: "args",
49
49
  type: "string[]",
50
- default: "getArgs()"
50
+ default: "useArgs()"
51
51
  }],
52
52
  get children() {
53
53
  return [
54
54
  createIntrinsic("hbr", {}),
55
55
  createIntrinsic("hbr", {}),
56
56
  children,
57
- createComponent(CommandRouter, {
58
- get segments() {
59
- return command.segments;
60
- },
61
- get commands() {
62
- return command.children;
63
- }
64
- }),
65
57
  createIntrinsic("hbr", {}),
66
58
  createIntrinsic("hbr", {}),
67
59
  code`writeLine("");
68
- banner();`,
60
+ banner(); `,
69
61
  createIntrinsic("hbr", {}),
70
62
  createIntrinsic("hbr", {}),
71
63
  createComponent(VirtualHelp, {
@@ -123,7 +115,7 @@ function VirtualCommandEntry(props) {
123
115
  "stripAnsi"
124
116
  ],
125
117
  utils: [
126
- "getArgs",
118
+ "useArgs",
127
119
  "hasFlag",
128
120
  "isMinimal",
129
121
  "isUnicodeSupported"
@@ -135,7 +127,19 @@ function VirtualCommandEntry(props) {
135
127
  createComponent(BannerFunctionDeclaration, { command }),
136
128
  createIntrinsic("hbr", {}),
137
129
  createIntrinsic("hbr", {}),
138
- createComponent(VirtualCommandHandlerDeclaration, { command })
130
+ createComponent(VirtualCommandHandlerDeclaration, {
131
+ command,
132
+ get children() {
133
+ return createComponent(CommandRouter, {
134
+ get segments() {
135
+ return command.segments;
136
+ },
137
+ get commands() {
138
+ return command.children;
139
+ }
140
+ });
141
+ }
142
+ })
139
143
  ];
140
144
  }
141
145
  })), createComponent(For, {