@shell-shock/core 0.17.8 → 0.17.10

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 (141) hide show
  1. package/dist/_virtual/_rolldown/runtime.cjs +29 -1
  2. package/dist/api.cjs +148 -1
  3. package/dist/api.d.cts +6 -6
  4. package/dist/api.d.cts.map +1 -1
  5. package/dist/api.d.mts +6 -6
  6. package/dist/api.d.mts.map +1 -1
  7. package/dist/api.mjs +145 -1
  8. package/dist/api.mjs.map +1 -1
  9. package/dist/components/command-validation-logic.cjs +292 -1
  10. package/dist/components/command-validation-logic.mjs +289 -1
  11. package/dist/components/command-validation-logic.mjs.map +1 -1
  12. package/dist/components/docs.cjs +265 -1
  13. package/dist/components/docs.mjs +256 -1
  14. package/dist/components/docs.mjs.map +1 -1
  15. package/dist/components/exec-builtin.cjs +429 -13
  16. package/dist/components/exec-builtin.mjs +425 -13
  17. package/dist/components/exec-builtin.mjs.map +1 -1
  18. package/dist/components/helpers.cjs +120 -1
  19. package/dist/components/helpers.mjs +112 -1
  20. package/dist/components/helpers.mjs.map +1 -1
  21. package/dist/components/index.cjs +58 -1
  22. package/dist/components/index.mjs +10 -1
  23. package/dist/components/options-parser-logic.cjs +960 -5
  24. package/dist/components/options-parser-logic.d.cts +1 -1
  25. package/dist/components/options-parser-logic.mjs +945 -5
  26. package/dist/components/options-parser-logic.mjs.map +1 -1
  27. package/dist/components/state-builtin.cjs +629 -8
  28. package/dist/components/state-builtin.mjs +622 -8
  29. package/dist/components/state-builtin.mjs.map +1 -1
  30. package/dist/components/usage.cjs +117 -1
  31. package/dist/components/usage.mjs +114 -1
  32. package/dist/components/usage.mjs.map +1 -1
  33. package/dist/components/utils-builtin.cjs +838 -33
  34. package/dist/components/utils-builtin.mjs +828 -33
  35. package/dist/components/utils-builtin.mjs.map +1 -1
  36. package/dist/config.cjs +31 -1
  37. package/dist/config.mjs +29 -1
  38. package/dist/config.mjs.map +1 -1
  39. package/dist/contexts/command.cjs +26 -1
  40. package/dist/contexts/command.mjs +23 -1
  41. package/dist/contexts/command.mjs.map +1 -1
  42. package/dist/contexts/index.cjs +9 -1
  43. package/dist/contexts/index.mjs +4 -1
  44. package/dist/contexts/options.cjs +63 -1
  45. package/dist/contexts/options.mjs +58 -1
  46. package/dist/contexts/options.mjs.map +1 -1
  47. package/dist/helpers/automd.cjs +71 -1
  48. package/dist/helpers/automd.mjs +70 -1
  49. package/dist/helpers/automd.mjs.map +1 -1
  50. package/dist/helpers/docs-helpers.cjs +23 -1
  51. package/dist/helpers/docs-helpers.mjs +22 -1
  52. package/dist/helpers/docs-helpers.mjs.map +1 -1
  53. package/dist/helpers/paths.cjs +137 -1
  54. package/dist/helpers/paths.mjs +133 -1
  55. package/dist/helpers/paths.mjs.map +1 -1
  56. package/dist/helpers/persistence.cjs +115 -1
  57. package/dist/helpers/persistence.mjs +112 -1
  58. package/dist/helpers/persistence.mjs.map +1 -1
  59. package/dist/helpers/update-package-json.cjs +65 -1
  60. package/dist/helpers/update-package-json.mjs +63 -1
  61. package/dist/helpers/update-package-json.mjs.map +1 -1
  62. package/dist/helpers/utilities.cjs +95 -1
  63. package/dist/helpers/utilities.mjs +93 -1
  64. package/dist/helpers/utilities.mjs.map +1 -1
  65. package/dist/helpers/validations.cjs +71 -1
  66. package/dist/helpers/validations.mjs +71 -1
  67. package/dist/helpers/validations.mjs.map +1 -1
  68. package/dist/index.cjs +53 -1
  69. package/dist/index.d.cts +3 -3
  70. package/dist/index.d.mts +3 -3
  71. package/dist/index.mjs +7 -1
  72. package/dist/plugin-utils/compute-bin.cjs +50 -1
  73. package/dist/plugin-utils/compute-bin.mjs +49 -1
  74. package/dist/plugin-utils/compute-bin.mjs.map +1 -1
  75. package/dist/plugin-utils/context-helpers.cjs +231 -1
  76. package/dist/plugin-utils/context-helpers.mjs +221 -1
  77. package/dist/plugin-utils/context-helpers.mjs.map +1 -1
  78. package/dist/plugin-utils/deepkit.cjs +71 -1
  79. package/dist/plugin-utils/deepkit.mjs +69 -1
  80. package/dist/plugin-utils/deepkit.mjs.map +1 -1
  81. package/dist/plugin-utils/description-helpers.cjs +111 -2
  82. package/dist/plugin-utils/description-helpers.mjs +107 -2
  83. package/dist/plugin-utils/description-helpers.mjs.map +1 -1
  84. package/dist/plugin-utils/get-command-tree.cjs +117 -1
  85. package/dist/plugin-utils/get-command-tree.mjs +114 -1
  86. package/dist/plugin-utils/get-command-tree.mjs.map +1 -1
  87. package/dist/plugin-utils/index.cjs +39 -1
  88. package/dist/plugin-utils/index.mjs +10 -1
  89. package/dist/plugin-utils/reflect.cjs +52 -1
  90. package/dist/plugin-utils/reflect.mjs +52 -1
  91. package/dist/plugin-utils/reflect.mjs.map +1 -1
  92. package/dist/plugin-utils/traverse-command-tree.cjs +64 -1
  93. package/dist/plugin-utils/traverse-command-tree.mjs +62 -1
  94. package/dist/plugin-utils/traverse-command-tree.mjs.map +1 -1
  95. package/dist/plugin-utils/type-checks.cjs +93 -1
  96. package/dist/plugin-utils/type-checks.mjs +88 -1
  97. package/dist/plugin-utils/type-checks.mjs.map +1 -1
  98. package/dist/plugin.cjs +471 -4
  99. package/dist/plugin.d.cts.map +1 -1
  100. package/dist/plugin.d.mts.map +1 -1
  101. package/dist/plugin.mjs +465 -4
  102. package/dist/plugin.mjs.map +1 -1
  103. package/dist/resolver/deepkit.cjs +135 -1
  104. package/dist/resolver/deepkit.mjs +134 -1
  105. package/dist/resolver/deepkit.mjs.map +1 -1
  106. package/dist/resolver/helpers.cjs +173 -1
  107. package/dist/resolver/helpers.mjs +168 -1
  108. package/dist/resolver/helpers.mjs.map +1 -1
  109. package/dist/resolver/module.cjs +145 -1
  110. package/dist/resolver/module.mjs +144 -1
  111. package/dist/resolver/module.mjs.map +1 -1
  112. package/dist/resolver/resolve.cjs +222 -1
  113. package/dist/resolver/resolve.mjs +221 -1
  114. package/dist/resolver/resolve.mjs.map +1 -1
  115. package/dist/types/command.cjs +441 -1
  116. package/dist/types/command.d.cts +1 -1
  117. package/dist/types/command.d.mts +2 -2
  118. package/dist/types/command.mjs +405 -1
  119. package/dist/types/command.mjs.map +1 -1
  120. package/dist/types/config.cjs +134 -1
  121. package/dist/types/config.d.cts +10 -8
  122. package/dist/types/config.d.cts.map +1 -1
  123. package/dist/types/config.d.mts +10 -8
  124. package/dist/types/config.d.mts.map +1 -1
  125. package/dist/types/config.mjs +127 -1
  126. package/dist/types/config.mjs.map +1 -1
  127. package/dist/types/context.cjs +37 -1
  128. package/dist/types/context.mjs +34 -1
  129. package/dist/types/context.mjs.map +1 -1
  130. package/dist/types/env.cjs +52 -1
  131. package/dist/types/env.d.cts +1 -1
  132. package/dist/types/env.d.mts +1 -1
  133. package/dist/types/env.mjs +50 -1
  134. package/dist/types/env.mjs.map +1 -1
  135. package/dist/types/index.cjs +50 -1
  136. package/dist/types/index.d.cts +2 -2
  137. package/dist/types/index.d.mts +2 -2
  138. package/dist/types/index.mjs +6 -1
  139. package/dist/types/options.cjs +12 -1
  140. package/dist/types/options.mjs +10 -1
  141. package/package.json +22 -21
@@ -1,4 +1,50 @@
1
- import{createComponent as e,createIntrinsic as t,memo as n,mergeProps as r}from"@alloy-js/core/jsx-runtime";import i from"defu";import{Show as a,code as o,splitProps as s}from"@alloy-js/core";import{Spacing as c}from"@powerlines/plugin-alloy/core/components/spacing";import{usePowerlines as l}from"@powerlines/plugin-alloy/core/contexts/context";import{FunctionDeclaration as u,IfStatement as d,InterfaceDeclaration as f,InterfaceMember as p,VarDeclaration as m}from"@alloy-js/typescript";import{BuiltinFile as h}from"@powerlines/plugin-alloy/typescript/components/builtin-file";import{TSDoc as g,TSDocInternal as _,TSDocLink as v,TSDocParam as y,TSDocRemarks as b,TSDocReturns as x}from"@powerlines/plugin-alloy/typescript/components/tsdoc";const S=[`T`,`K`,()=>C,()=>w,`Omit`,`b!b"e!!e!!ge!"o$#o##w%y`],C=[`T`,`K`,`Pick`,`l+e#!e"!fRb!b"Pde""N#!w#y`],w=[`T`,`U`,`Exclude`,`l6!Re$!RPe#!e$"qk#%QRb!b"Pde"!p)w#y`],T=[()=>S,`id`,`description`,`UtilsBuiltinProps`,`P!P.".#Jo!#Mw$y`];function E(){let t=(l.Ω=[[`Context`,`"w!`]],l());return[e(m,{const:!0,name:`deburred`,initializer:o` {
1
+ import { createComponent, createIntrinsic, memo, mergeProps } from "@alloy-js/core/jsx-runtime";
2
+ import defu$1 from "defu";
3
+ import { Show, code, splitProps } from "@alloy-js/core";
4
+ import { Spacing } from "@powerlines/plugin-alloy/core/components/spacing";
5
+ import { usePowerlines } from "@powerlines/plugin-alloy/core/contexts/context";
6
+ import { FunctionDeclaration, IfStatement, InterfaceDeclaration, InterfaceMember, VarDeclaration } from "@alloy-js/typescript";
7
+ import { BuiltinFile } from "@powerlines/plugin-alloy/typescript/components/builtin-file";
8
+ import { TSDoc, TSDocInternal, TSDocLink, TSDocParam, TSDocRemarks, TSDocReturns } from "@powerlines/plugin-alloy/typescript/components/tsdoc";
9
+
10
+ //#region src/components/utils-builtin.tsx
11
+ const __ΩOmit = [
12
+ "T",
13
+ "K",
14
+ () => __ΩPick,
15
+ () => __ΩExclude,
16
+ "Omit",
17
+ "b!b\"e!!e!!ge!\"o$#o##w%y"
18
+ ];
19
+ const __ΩPick = [
20
+ "T",
21
+ "K",
22
+ "Pick",
23
+ "l+e#!e\"!fRb!b\"Pde\"\"N#!w#y"
24
+ ];
25
+ const __ΩExclude = [
26
+ "T",
27
+ "U",
28
+ "Exclude",
29
+ "l6!Re$!RPe#!e$\"qk#%QRb!b\"Pde\"!p)w#y"
30
+ ];
31
+ const __ΩUtilsBuiltinProps = [
32
+ () => __ΩOmit,
33
+ "id",
34
+ "description",
35
+ "UtilsBuiltinProps",
36
+ "P!P.\".#Jo!#Mw$y"
37
+ ];
38
+ /**
39
+ * Generates the `findSuggestions` function for suggesting corrections for potentially misspelled options or commands.
40
+ */
41
+ function FindSuggestionsDeclaration() {
42
+ const context = (usePowerlines.Ω = [["Context", "\"w!"]], usePowerlines());
43
+ return [
44
+ createComponent(VarDeclaration, {
45
+ "const": true,
46
+ name: "deburred",
47
+ initializer: code` {
2
48
  "\\xc0": "A", "\\xc1": "A", "\\xc2": "A", "\\xc3": "A", "\\xc4": "A", "\\xc5": "A",
3
49
  "\\xe0": "a", "\\xe1": "a", "\\xe2": "a", "\\xe3": "a", "\\xe4": "a", "\\xe5": "a",
4
50
  "\\xc7": "C", "\\xe7": "c",
@@ -51,7 +97,51 @@ import{createComponent as e,createIntrinsic as t,memo as n,mergeProps as r}from"
51
97
  "\\u0132": "IJ", "\\u0133": "ij",
52
98
  "\\u0152": "Oe", "\\u0153": "oe",
53
99
  "\\u0149": "n", "\\u017f": "s"
54
- } as Record<string, string>; `}),e(c,{}),e(g,{heading:`A utility function that takes an input string and a list of possible matches, and returns a list of suggested matches based on the Levenshtein distance between the input and the possible matches.`,get children(){return[e(b,{children:`This function is intended to be used to suggest corrections for potentially misspelled options or commands.`}),e(c,{}),e(_,{}),e(c,{}),e(y,{name:`input`,children:`The input string to check for potential matches.`}),e(y,{name:`options`,children:`A list of possible matches to compare against the input.`}),e(x,{children:`A list of suggested matches based on the Levenshtein distance.`})]}}),e(u,{export:!0,name:`findSuggestions`,parameters:[{name:`input`,type:`string`},{name:`options`,type:`string[]`}],returnType:`string[]`,get children(){return[e(m,{const:!0,name:`normalizedInput`,get initializer(){return o`String(input ?? "")${t.config.isCaseSensitive?``:`.toLowerCase()`}.trim().replaceAll(/[\\s\\-_\\.]+/gu, " ").replace(/[\\\\xc0-\\\\xd6\\\\xd8-\\\\xf6\\\\xf8-\\\\xff\\\\u0100-\\\\u017f]/g, key => deburred[key]).replace(/[\\\\u0300-\\\\u036f\\\\ufe20-\\\\ufe2f\\\\u20d0-\\\\u20ff]/g, ""); `}}),e(c,{}),n(()=>o`
100
+ } as Record<string, string>; `
101
+ }),
102
+ createComponent(Spacing, {}),
103
+ createComponent(TSDoc, {
104
+ heading: "A utility function that takes an input string and a list of possible matches, and returns a list of suggested matches based on the Levenshtein distance between the input and the possible matches.",
105
+ get children() {
106
+ return [
107
+ createComponent(TSDocRemarks, { children: "This function is intended to be used to suggest corrections for potentially misspelled options or commands." }),
108
+ createComponent(Spacing, {}),
109
+ createComponent(TSDocInternal, {}),
110
+ createComponent(Spacing, {}),
111
+ createComponent(TSDocParam, {
112
+ name: "input",
113
+ children: "The input string to check for potential matches."
114
+ }),
115
+ createComponent(TSDocParam, {
116
+ name: "options",
117
+ children: "A list of possible matches to compare against the input."
118
+ }),
119
+ createComponent(TSDocReturns, { children: "A list of suggested matches based on the Levenshtein distance." })
120
+ ];
121
+ }
122
+ }),
123
+ createComponent(FunctionDeclaration, {
124
+ "export": true,
125
+ name: "findSuggestions",
126
+ parameters: [{
127
+ name: "input",
128
+ type: "string"
129
+ }, {
130
+ name: "options",
131
+ type: "string[]"
132
+ }],
133
+ returnType: "string[]",
134
+ get children() {
135
+ return [
136
+ createComponent(VarDeclaration, {
137
+ "const": true,
138
+ name: "normalizedInput",
139
+ get initializer() {
140
+ return code`String(input ?? "")${context.config.isCaseSensitive ? "" : ".toLowerCase()"}.trim().replaceAll(/[\\s\\-_\\.]+/gu, " ").replace(/[\\\\xc0-\\\\xd6\\\\xd8-\\\\xf6\\\\xf8-\\\\xff\\\\u0100-\\\\u017f]/g, key => deburred[key]).replace(/[\\\\u0300-\\\\u036f\\\\ufe20-\\\\ufe2f\\\\u20d0-\\\\u20ff]/g, ""); `;
141
+ }
142
+ }),
143
+ createComponent(Spacing, {}),
144
+ memo(() => code`
55
145
  if (!normalizedInput || options.length === 0) {
56
146
  return [];
57
147
  }
@@ -60,7 +150,7 @@ import{createComponent as e,createIntrinsic as t,memo as n,mergeProps as r}from"
60
150
  const results: Array<{ option: string; distance: number }> = [];
61
151
 
62
152
  for (const option of options) {
63
- const normalizedOption = String(option ?? "")${t.config.isCaseSensitive?``:`.toLowerCase()`}.trim().replaceAll(/[\\s\\-_\\.]+/gu, " ").replace(/[\\\\xc0-\\\\xd6\\\\xd8-\\\\xf6\\\\xf8-\\\\xff\\\\u0100-\\\\u017f]/g, key => deburred[key]).replace(/[\\\\u0300-\\\\u036f\\\\ufe20-\\\\ufe2f\\\\u20d0-\\\\u20ff]/g, "");
153
+ const normalizedOption = String(option ?? "")${context.config.isCaseSensitive ? "" : ".toLowerCase()"}.trim().replaceAll(/[\\s\\-_\\.]+/gu, " ").replace(/[\\\\xc0-\\\\xd6\\\\xd8-\\\\xf6\\\\xf8-\\\\xff\\\\u0100-\\\\u017f]/g, key => deburred[key]).replace(/[\\\\u0300-\\\\u036f\\\\ufe20-\\\\ufe2f\\\\u20d0-\\\\u20ff]/g, "");
64
154
 
65
155
  if (!normalizedOption) {
66
156
  continue;
@@ -137,7 +227,41 @@ import{createComponent as e,createIntrinsic as t,memo as n,mergeProps as r}from"
137
227
  }
138
228
 
139
229
  return results.sort((a, b) => a.distance - b.distance).map(r => r.option);
140
- `)]}})]}E.__type=[`FindSuggestionsDeclaration`,"Generates the `findSuggestions` function for suggesting corrections for potentially misspelled options or commands.",`P"/!?"`];function D(){return[e(m,{export:!0,const:!0,name:`DEFAULT_TERMINAL_COLUMNS`,doc:`Default number of terminal columns`,initializer:o`80`}),e(c,{}),e(m,{export:!0,const:!0,name:`DEFAULT_TERMINAL_ROWS`,doc:`Default number of terminal rows`,initializer:o`24`}),e(c,{}),e(u,{name:`isForegroundProcess`,children:o`if (isLinux) {
230
+ `)
231
+ ];
232
+ }
233
+ })
234
+ ];
235
+ }
236
+ FindSuggestionsDeclaration.__type = [
237
+ "FindSuggestionsDeclaration",
238
+ "Generates the `findSuggestions` function for suggesting corrections for potentially misspelled options or commands.",
239
+ "P\"/!?\""
240
+ ];
241
+ /**
242
+ * Generates utilities for detecting terminal size and whether the process is running in the foreground, which can be used to determine how to render output (e.g., whether to use a progress bar or spinner).
243
+ */
244
+ function TerminalSizeDeclaration() {
245
+ return [
246
+ createComponent(VarDeclaration, {
247
+ "export": true,
248
+ "const": true,
249
+ name: "DEFAULT_TERMINAL_COLUMNS",
250
+ doc: "Default number of terminal columns",
251
+ initializer: code`80`
252
+ }),
253
+ createComponent(Spacing, {}),
254
+ createComponent(VarDeclaration, {
255
+ "export": true,
256
+ "const": true,
257
+ name: "DEFAULT_TERMINAL_ROWS",
258
+ doc: "Default number of terminal rows",
259
+ initializer: code`24`
260
+ }),
261
+ createComponent(Spacing, {}),
262
+ createComponent(FunctionDeclaration, {
263
+ name: "isForegroundProcess",
264
+ children: code`if (isLinux) {
141
265
  return true;
142
266
  }
143
267
 
@@ -164,14 +288,24 @@ import{createComponent as e,createIntrinsic as t,memo as n,mergeProps as r}from"
164
288
  return processGroupId === foregroundProcessGroupId;
165
289
  } catch {
166
290
  return false;
167
- } `}),e(c,{}),e(u,{name:`tput`,children:o`try {
291
+ } `
292
+ }),
293
+ createComponent(Spacing, {}),
294
+ createComponent(FunctionDeclaration, {
295
+ name: "tput",
296
+ children: code`try {
168
297
  const columns = execSync(["tput", "cols"], { env: { TERM: 'dumb', ...process.env } });
169
298
  const rows = execSync(["tput", "lines"], { env: { TERM: 'dumb', ...process.env } });
170
299
 
171
300
  if (columns && rows) {
172
301
  return { columns: Number.parseInt(columns.toString().trim(), 10), rows: Number.parseInt(rows.toString().trim(), 10) };
173
302
  }
174
- } catch {} `}),e(c,{}),e(u,{name:`devTty`,children:o`try {
303
+ } catch {} `
304
+ }),
305
+ createComponent(Spacing, {}),
306
+ createComponent(FunctionDeclaration, {
307
+ name: "devTty",
308
+ children: code`try {
175
309
  const writeStream = new WriteStream(
176
310
  openSync(
177
311
  "/dev/tty",
@@ -180,21 +314,160 @@ import{createComponent as e,createIntrinsic as t,memo as n,mergeProps as r}from"
180
314
  ).getWindowSize();
181
315
 
182
316
  return { columns: writeStream[0], rows: writeStream[1] };
183
- } catch {} `}),e(c,{}),e(g,{heading:`A utility function that attempts to determine the size of the terminal (number of columns and rows) using various methods, and falls back to default values if it cannot be determined. This can be used to adjust output formatting based on the available terminal size.`,get children(){return[e(b,{children:`The function first checks if the process is running in a TTY environment and if the stdout or stderr streams provide column and row information. If not, it attempts to use platform-specific methods (like reading from /proc/self/stat on Linux, using tput on Unix-like systems, or checking /dev/tty) to determine the terminal size. If all else fails, it returns default values.`}),e(c,{}),e(x,{children:`An object containing the number of columns and rows of the terminal.`})]}}),e(u,{export:!0,name:`getTerminalSize`,returnType:`{ columns: number; rows: number; }`,get children(){return[e(d,{condition:o`process.stdout?.columns && process.stdout?.rows`,children:o`return { columns: process.stdout.columns, rows: process.stdout.rows }; `}),e(d,{condition:o`process.stderr?.columns && process.stderr?.rows`,children:o`return { columns: process.stderr.columns, rows: process.stderr.rows };`}),e(c,{}),e(d,{condition:o`isWindows`,children:o`return tput() ?? {
317
+ } catch {} `
318
+ }),
319
+ createComponent(Spacing, {}),
320
+ createComponent(TSDoc, {
321
+ heading: "A utility function that attempts to determine the size of the terminal (number of columns and rows) using various methods, and falls back to default values if it cannot be determined. This can be used to adjust output formatting based on the available terminal size.",
322
+ get children() {
323
+ return [
324
+ createComponent(TSDocRemarks, { children: "The function first checks if the process is running in a TTY environment and if the stdout or stderr streams provide column and row information. If not, it attempts to use platform-specific methods (like reading from /proc/self/stat on Linux, using tput on Unix-like systems, or checking /dev/tty) to determine the terminal size. If all else fails, it returns default values." }),
325
+ createComponent(Spacing, {}),
326
+ createComponent(TSDocReturns, { children: "An object containing the number of columns and rows of the terminal." })
327
+ ];
328
+ }
329
+ }),
330
+ createComponent(FunctionDeclaration, {
331
+ "export": true,
332
+ name: "getTerminalSize",
333
+ returnType: "{ columns: number; rows: number; }",
334
+ get children() {
335
+ return [
336
+ createComponent(IfStatement, {
337
+ condition: code`process.stdout?.columns && process.stdout?.rows`,
338
+ children: code`return { columns: process.stdout.columns, rows: process.stdout.rows }; `
339
+ }),
340
+ createComponent(IfStatement, {
341
+ condition: code`process.stderr?.columns && process.stderr?.rows`,
342
+ children: code`return { columns: process.stderr.columns, rows: process.stderr.rows };`
343
+ }),
344
+ createComponent(Spacing, {}),
345
+ createComponent(IfStatement, {
346
+ condition: code`isWindows`,
347
+ children: code`return tput() ?? {
184
348
  columns: DEFAULT_TERMINAL_COLUMNS,
185
349
  rows: DEFAULT_TERMINAL_ROWS,
186
- }; `}),e(d,{condition:o`isMacOS`,children:o`return devTty() ?? tput() ?? {
350
+ }; `
351
+ }),
352
+ createComponent(IfStatement, {
353
+ condition: code`isMacOS`,
354
+ children: code`return devTty() ?? tput() ?? {
187
355
  columns: DEFAULT_TERMINAL_COLUMNS,
188
356
  rows: DEFAULT_TERMINAL_ROWS,
189
- }; `}),e(c,{}),e(m,{let:!0,name:`result`,initializer:o`devTty() ?? tput(); `}),e(d,{condition:o`!result && isForegroundProcess()`,children:o`try {
357
+ }; `
358
+ }),
359
+ createComponent(Spacing, {}),
360
+ createComponent(VarDeclaration, {
361
+ "let": true,
362
+ name: "result",
363
+ initializer: code`devTty() ?? tput(); `
364
+ }),
365
+ createComponent(IfStatement, {
366
+ condition: code`!result && isForegroundProcess()`,
367
+ children: code`try {
190
368
  const size = execSync(["resize", "-u"]).match(/\\d+/g);
191
369
  if (size.length === 2) {
192
370
  result = { columns: Number.parseInt(size[0], 10), rows: Number.parseInt(size[1], 10) };
193
371
  }
194
- } catch {} `}),e(c,{}),o`return result ?? {
372
+ } catch {} `
373
+ }),
374
+ createComponent(Spacing, {}),
375
+ code`return result ?? {
195
376
  columns: DEFAULT_TERMINAL_COLUMNS,
196
377
  rows: DEFAULT_TERMINAL_ROWS,
197
- }; `]}})]}D.__type=[`TerminalSizeDeclaration`,`Generates utilities for detecting terminal size and whether the process is running in the foreground, which can be used to determine how to render output (e.g., whether to use a progress bar or spinner).`,`P"/!?"`];function O(){return[e(m,{export:!0,const:!0,name:`isTTY`,doc:`Detect if stdout.TTY is available`,initializer:o`Boolean(process.stdout && process.stdout.isTTY);`}),e(c,{}),e(m,{export:!0,const:!0,name:`isMinimal`,doc:`Detect if the current environment is minimal (CI, non-TTY, etc.)`,initializer:o` env.MINIMAL || isCI || isTest || !isTTY; `}),e(c,{}),e(m,{export:!0,const:!0,name:`isInteractive`,doc:`Detect if the current environment is interactive`,initializer:o` !isMinimal && process.stdin?.isTTY && env.TERM !== "dumb" && !hasFlag(["no-interactive", "non-interactive", "no-interact"]); `})]}O.__type=[`EnvSupportUtilities`,`Generates utilities for detecting terminal color support.`,`P"/!?"`];function k(){return[e(f,{export:!0,name:`GetColorSupportLevelOptions`,doc:`Options for the getColorSupportLevel function`,get children(){return e(p,{name:`ignoreFlags`,type:`boolean`,doc:`Indicates if the function should skip checking command-line flags for color support`})}}),e(c,{}),e(g,{heading:`Checks if a specific flag is present in the command-line arguments.`,get children(){return[e(v,{children:`https://github.com/sindresorhus/has-flag/blob/main/index.js`}),e(y,{name:`flag`,children:`The flag to check for, e.g., "color", "no-color".`}),e(y,{name:`argv`,children:`The command-line arguments to check against. Defaults to global Deno args or process args.`}),e(x,{children:`True if the flag is present, false otherwise.`})]}}),e(u,{export:!0,name:`getColorSupportLevel`,parameters:[{name:`stream`,type:`NodeJS.WriteStream & { fd: 1 | 2; }`},{name:`options`,type:`GetColorSupportLevelOptions`,default:`{ ignoreFlags: false }`}],children:o`const { ignoreFlags } = options;
378
+ }; `
379
+ ];
380
+ }
381
+ })
382
+ ];
383
+ }
384
+ TerminalSizeDeclaration.__type = [
385
+ "TerminalSizeDeclaration",
386
+ "Generates utilities for detecting terminal size and whether the process is running in the foreground, which can be used to determine how to render output (e.g., whether to use a progress bar or spinner).",
387
+ "P\"/!?\""
388
+ ];
389
+ /**
390
+ * Generates utilities for detecting terminal color support.
391
+ */
392
+ function EnvSupportUtilities() {
393
+ return [
394
+ createComponent(VarDeclaration, {
395
+ "export": true,
396
+ "const": true,
397
+ name: "isTTY",
398
+ doc: "Detect if stdout.TTY is available",
399
+ initializer: code`Boolean(process.stdout && process.stdout.isTTY);`
400
+ }),
401
+ createComponent(Spacing, {}),
402
+ createComponent(VarDeclaration, {
403
+ "export": true,
404
+ "const": true,
405
+ name: "isMinimal",
406
+ doc: "Detect if the current environment is minimal (CI, non-TTY, etc.)",
407
+ initializer: code` env.MINIMAL || isCI || isTest || !isTTY; `
408
+ }),
409
+ createComponent(Spacing, {}),
410
+ createComponent(VarDeclaration, {
411
+ "export": true,
412
+ "const": true,
413
+ name: "isInteractive",
414
+ doc: "Detect if the current environment is interactive",
415
+ initializer: code` !isMinimal && process.stdin?.isTTY && env.TERM !== "dumb" && !hasFlag(["no-interactive", "non-interactive", "no-interact"]); `
416
+ })
417
+ ];
418
+ }
419
+ EnvSupportUtilities.__type = [
420
+ "EnvSupportUtilities",
421
+ "Generates utilities for detecting terminal color support.",
422
+ "P\"/!?\""
423
+ ];
424
+ /**
425
+ * Generates utilities for detecting terminal color support.
426
+ */
427
+ function ColorSupportUtilities() {
428
+ return [
429
+ createComponent(InterfaceDeclaration, {
430
+ "export": true,
431
+ name: "GetColorSupportLevelOptions",
432
+ doc: "Options for the getColorSupportLevel function",
433
+ get children() {
434
+ return createComponent(InterfaceMember, {
435
+ name: "ignoreFlags",
436
+ type: "boolean",
437
+ doc: "Indicates if the function should skip checking command-line flags for color support"
438
+ });
439
+ }
440
+ }),
441
+ createComponent(Spacing, {}),
442
+ createComponent(TSDoc, {
443
+ heading: "Checks if a specific flag is present in the command-line arguments.",
444
+ get children() {
445
+ return [
446
+ createComponent(TSDocLink, { children: "https://github.com/sindresorhus/has-flag/blob/main/index.js" }),
447
+ createComponent(TSDocParam, {
448
+ name: "flag",
449
+ children: "The flag to check for, e.g., \"color\", \"no-color\"."
450
+ }),
451
+ createComponent(TSDocParam, {
452
+ name: "argv",
453
+ children: "The command-line arguments to check against. Defaults to global Deno args or process args."
454
+ }),
455
+ createComponent(TSDocReturns, { children: "True if the flag is present, false otherwise." })
456
+ ];
457
+ }
458
+ }),
459
+ createComponent(FunctionDeclaration, {
460
+ "export": true,
461
+ name: "getColorSupportLevel",
462
+ parameters: [{
463
+ name: "stream",
464
+ type: "NodeJS.WriteStream & { fd: 1 | 2; }"
465
+ }, {
466
+ name: "options",
467
+ type: "GetColorSupportLevelOptions",
468
+ default: "{ ignoreFlags: false }"
469
+ }],
470
+ children: code`const { ignoreFlags } = options;
198
471
 
199
472
  let forceColor: number | undefined;
200
473
  if (env.FORCE_COLOR !== undefined) {
@@ -303,10 +576,34 @@ import{createComponent as e,createIntrinsic as t,memo as n,mergeProps as r}from"
303
576
  has16m: level >= 3,
304
577
  };
305
578
 
306
- `}),e(c,{}),e(m,{export:!0,const:!0,name:`colorSupportLevels`,doc:`Detect the terminal color support level in the current environment`,initializer:o` {
579
+ `
580
+ }),
581
+ createComponent(Spacing, {}),
582
+ createComponent(VarDeclaration, {
583
+ "export": true,
584
+ "const": true,
585
+ name: "colorSupportLevels",
586
+ doc: "Detect the terminal color support level in the current environment",
587
+ initializer: code` {
307
588
  stdout: getColorSupportLevel(process.stdout),
308
589
  stderr: getColorSupportLevel(process.stderr),
309
- }; `}),e(c,{}),e(m,{export:!0,const:!0,name:`isColorSupported`,doc:`Detect if terminal color is supported in the current environment`,initializer:o` Boolean(colorSupportLevels.stdout); `}),e(c,{}),e(m,{export:!0,const:!0,name:`isUnicodeSupported`,doc:`Detect if Unicode characters are supported in the current environment`,initializer:o` !isWindows
590
+ }; `
591
+ }),
592
+ createComponent(Spacing, {}),
593
+ createComponent(VarDeclaration, {
594
+ "export": true,
595
+ "const": true,
596
+ name: "isColorSupported",
597
+ doc: "Detect if terminal color is supported in the current environment",
598
+ initializer: code` Boolean(colorSupportLevels.stdout); `
599
+ }),
600
+ createComponent(Spacing, {}),
601
+ createComponent(VarDeclaration, {
602
+ "export": true,
603
+ "const": true,
604
+ name: "isUnicodeSupported",
605
+ doc: "Detect if Unicode characters are supported in the current environment",
606
+ initializer: code` !isWindows
310
607
  ? env.TERM !== "linux"
311
608
  : Boolean(env.WT_SESSION) ||
312
609
  Boolean(env.TERMINUS_SUBLIME) ||
@@ -317,7 +614,28 @@ import{createComponent as e,createIntrinsic as t,memo as n,mergeProps as r}from"
317
614
  env.TERM === "alacritty" ||
318
615
  env.TERM === "rxvt-unicode" ||
319
616
  env.TERM === "rxvt-unicode-256color" ||
320
- env.TERMINAL_EMULATOR === "JetBrains-JediTerm"; `})]}k.__type=[`ColorSupportUtilities`,`Generates utilities for detecting terminal color support.`,`P"/!?"`];function A(){return[e(u,{name:`parseVersion`,parameters:[{name:`version`,type:`string`,default:`""`}],children:o`if (/^\d{3,4}$/.test(version)) {
617
+ env.TERMINAL_EMULATOR === "JetBrains-JediTerm"; `
618
+ })
619
+ ];
620
+ }
621
+ ColorSupportUtilities.__type = [
622
+ "ColorSupportUtilities",
623
+ "Generates utilities for detecting terminal color support.",
624
+ "P\"/!?\""
625
+ ];
626
+ /**
627
+ * Generates utilities for detecting terminal color support.
628
+ */
629
+ function HyperlinkSupportUtilities() {
630
+ return [
631
+ createComponent(FunctionDeclaration, {
632
+ name: "parseVersion",
633
+ parameters: [{
634
+ name: "version",
635
+ type: "string",
636
+ default: "\"\""
637
+ }],
638
+ children: code`if (/^\d{3,4}$/.test(version)) {
321
639
  const match = /(\d{1,2})(\d{2})/.exec(version) ?? [];
322
640
 
323
641
  return {
@@ -335,7 +653,20 @@ import{createComponent as e,createIntrinsic as t,memo as n,mergeProps as r}from"
335
653
  major: versionParts[0],
336
654
  minor: versionParts[1],
337
655
  patch: versionParts[2]
338
- }; `}),e(c,{}),e(g,{heading:`Check if the current environment/terminal supports hyperlinks in the terminal.`,get children(){return e(x,{children:`True if the current environment/terminal supports hyperlinks.`})}}),e(u,{export:!0,name:`isHyperlinkSupported`,returnType:`boolean`,children:o`if (Boolean(env.FORCE_HYPERLINK)) {
656
+ }; `
657
+ }),
658
+ createComponent(Spacing, {}),
659
+ createComponent(TSDoc, {
660
+ heading: "Check if the current environment/terminal supports hyperlinks in the terminal.",
661
+ get children() {
662
+ return createComponent(TSDocReturns, { children: "True if the current environment/terminal supports hyperlinks." });
663
+ }
664
+ }),
665
+ createComponent(FunctionDeclaration, {
666
+ "export": true,
667
+ name: "isHyperlinkSupported",
668
+ returnType: "boolean",
669
+ children: code`if (Boolean(env.FORCE_HYPERLINK)) {
339
670
  return true;
340
671
  }
341
672
 
@@ -396,7 +727,126 @@ import{createComponent as e,createIntrinsic as t,memo as n,mergeProps as r}from"
396
727
  return true;
397
728
  }
398
729
 
399
- return false; `})]}A.__type=[`HyperlinkSupportUtilities`,`Generates utilities for detecting terminal color support.`,`P"/!?"`];function j(){let n=(l.Ω=[[`Context`,`"w!`]],l());return[e(c,{}),e(f,{name:`ResolveModuleOptions`,doc:"Options for the `resolve` handler function.",get children(){return[e(p,{name:`parentURL`,optional:!0,type:`string`,doc:`The parent URL to use for resolving paths.`}),t(`hbr`,{}),e(p,{name:`conditions`,optional:!0,type:`string[]`,doc:`The conditions to use for resolving paths.`}),t(`hbr`,{})]}}),e(c,{}),e(f,{name:`PackageConfig`,doc:`Parsed package.json configuration for module resolution.`,get children(){return[e(p,{name:`pjsonPath`,type:`string`,doc:`The path to the package.json file.`}),t(`hbr`,{}),e(p,{name:`exists`,type:`boolean`,doc:`Whether the package.json file exists.`}),t(`hbr`,{}),e(p,{name:`main`,optional:!0,type:`string`,doc:`The main entry point of the package.`}),t(`hbr`,{}),e(p,{name:`name`,optional:!0,type:`string`,doc:`The name of the package.`}),t(`hbr`,{}),e(p,{name:`type`,optional:!0,type:`"commonjs" | "module" | "none"`,doc:`The module type of the package.`}),t(`hbr`,{}),e(p,{name:`exports`,optional:!0,type:`Record<string, unknown>`,doc:`The exports map of the package.`}),t(`hbr`,{}),e(p,{name:`imports`,optional:!0,type:`Record<string, unknown>`,doc:`The imports map of the package.`})]}}),e(c,{}),e(m,{const:!0,name:`DEFAULT_CONDITIONS_SET`,initializer:o`new Set(["node", "import"]);`}),e(c,{}),e(m,{const:!0,name:`DEFAULT_EXTENSIONS`,initializer:o`[".mjs", ".cjs", ".js", ".json", ".node"];`}),e(c,{}),e(m,{const:!0,name:`invalidPackageNameRegEx`,initializer:o`/^\\.|\\/|%/;`}),e(c,{}),e(u,{name:`readPackageConfig`,parameters:[{name:`jsonPath`,type:`string`}],returnType:`PackageConfig`,children:o`const result: PackageConfig = {
730
+ return false; `
731
+ })
732
+ ];
733
+ }
734
+ HyperlinkSupportUtilities.__type = [
735
+ "HyperlinkSupportUtilities",
736
+ "Generates utilities for detecting terminal color support.",
737
+ "P\"/!?\""
738
+ ];
739
+ /**
740
+ * Generates the `resolveModule` function declaration, which is a utility for resolving file paths across different platforms.
741
+ */
742
+ function ResolveModuleFunctionDeclaration() {
743
+ const context = (usePowerlines.Ω = [["Context", "\"w!"]], usePowerlines());
744
+ return [
745
+ createComponent(Spacing, {}),
746
+ createComponent(InterfaceDeclaration, {
747
+ name: "ResolveModuleOptions",
748
+ doc: "Options for the `resolve` handler function.",
749
+ get children() {
750
+ return [
751
+ createComponent(InterfaceMember, {
752
+ name: "parentURL",
753
+ optional: true,
754
+ type: "string",
755
+ doc: "The parent URL to use for resolving paths."
756
+ }),
757
+ createIntrinsic("hbr", {}),
758
+ createComponent(InterfaceMember, {
759
+ name: "conditions",
760
+ optional: true,
761
+ type: "string[]",
762
+ doc: "The conditions to use for resolving paths."
763
+ }),
764
+ createIntrinsic("hbr", {})
765
+ ];
766
+ }
767
+ }),
768
+ createComponent(Spacing, {}),
769
+ createComponent(InterfaceDeclaration, {
770
+ name: "PackageConfig",
771
+ doc: "Parsed package.json configuration for module resolution.",
772
+ get children() {
773
+ return [
774
+ createComponent(InterfaceMember, {
775
+ name: "pjsonPath",
776
+ type: "string",
777
+ doc: "The path to the package.json file."
778
+ }),
779
+ createIntrinsic("hbr", {}),
780
+ createComponent(InterfaceMember, {
781
+ name: "exists",
782
+ type: "boolean",
783
+ doc: "Whether the package.json file exists."
784
+ }),
785
+ createIntrinsic("hbr", {}),
786
+ createComponent(InterfaceMember, {
787
+ name: "main",
788
+ optional: true,
789
+ type: "string",
790
+ doc: "The main entry point of the package."
791
+ }),
792
+ createIntrinsic("hbr", {}),
793
+ createComponent(InterfaceMember, {
794
+ name: "name",
795
+ optional: true,
796
+ type: "string",
797
+ doc: "The name of the package."
798
+ }),
799
+ createIntrinsic("hbr", {}),
800
+ createComponent(InterfaceMember, {
801
+ name: "type",
802
+ optional: true,
803
+ type: `"commonjs" | "module" | "none"`,
804
+ doc: "The module type of the package."
805
+ }),
806
+ createIntrinsic("hbr", {}),
807
+ createComponent(InterfaceMember, {
808
+ name: "exports",
809
+ optional: true,
810
+ type: "Record<string, unknown>",
811
+ doc: "The exports map of the package."
812
+ }),
813
+ createIntrinsic("hbr", {}),
814
+ createComponent(InterfaceMember, {
815
+ name: "imports",
816
+ optional: true,
817
+ type: "Record<string, unknown>",
818
+ doc: "The imports map of the package."
819
+ })
820
+ ];
821
+ }
822
+ }),
823
+ createComponent(Spacing, {}),
824
+ createComponent(VarDeclaration, {
825
+ "const": true,
826
+ name: "DEFAULT_CONDITIONS_SET",
827
+ initializer: code`new Set(["node", "import"]);`
828
+ }),
829
+ createComponent(Spacing, {}),
830
+ createComponent(VarDeclaration, {
831
+ "const": true,
832
+ name: "DEFAULT_EXTENSIONS",
833
+ initializer: code`[".mjs", ".cjs", ".js", ".json", ".node"];`
834
+ }),
835
+ createComponent(Spacing, {}),
836
+ createComponent(VarDeclaration, {
837
+ "const": true,
838
+ name: "invalidPackageNameRegEx",
839
+ initializer: code`/^\\.|\\/|%/;`
840
+ }),
841
+ createComponent(Spacing, {}),
842
+ createComponent(FunctionDeclaration, {
843
+ name: "readPackageConfig",
844
+ parameters: [{
845
+ name: "jsonPath",
846
+ type: "string"
847
+ }],
848
+ returnType: "PackageConfig",
849
+ children: code`const result: PackageConfig = {
400
850
  pjsonPath: jsonPath,
401
851
  exists: false,
402
852
  main: undefined,
@@ -441,7 +891,17 @@ import{createComponent as e,createIntrinsic as t,memo as n,mergeProps as r}from"
441
891
  result.type = parsed.type;
442
892
  }
443
893
 
444
- return result;`}),e(c,{}),e(u,{name:`getPackageScopeConfig`,parameters:[{name:`resolved`,type:`URL | string`}],returnType:`PackageConfig`,children:o`let packageJSONUrl = new URL("package.json", resolved);
894
+ return result;`
895
+ }),
896
+ createComponent(Spacing, {}),
897
+ createComponent(FunctionDeclaration, {
898
+ name: "getPackageScopeConfig",
899
+ parameters: [{
900
+ name: "resolved",
901
+ type: "URL | string"
902
+ }],
903
+ returnType: "PackageConfig",
904
+ children: code`let packageJSONUrl = new URL("package.json", resolved);
445
905
 
446
906
  while (true) {
447
907
  const packageJSONPath = packageJSONUrl.pathname;
@@ -466,7 +926,17 @@ import{createComponent as e,createIntrinsic as t,memo as n,mergeProps as r}from"
466
926
  pjsonPath: fileURLToPath(packageJSONUrl),
467
927
  exists: false,
468
928
  type: "none"
469
- };`}),e(c,{}),e(u,{name:`isConditionalExportsMainSugar`,parameters:[{name:`exports`,type:`unknown`}],returnType:`boolean`,children:o`if (typeof exports === "string" || Array.isArray(exports)) {
929
+ };`
930
+ }),
931
+ createComponent(Spacing, {}),
932
+ createComponent(FunctionDeclaration, {
933
+ name: "isConditionalExportsMainSugar",
934
+ parameters: [{
935
+ name: "exports",
936
+ type: "unknown"
937
+ }],
938
+ returnType: "boolean",
939
+ children: code`if (typeof exports === "string" || Array.isArray(exports)) {
470
940
  return true;
471
941
  }
472
942
  if (typeof exports !== "object" || exports === null) {
@@ -488,7 +958,47 @@ import{createComponent as e,createIntrinsic as t,memo as n,mergeProps as r}from"
488
958
  }
489
959
  }
490
960
 
491
- return isConditionalSugar;`}),e(c,{}),e(u,{name:`resolvePackageTarget`,parameters:[{name:`packageJsonUrl`,type:`URL`},{name:`target`,type:`unknown`},{name:`subpath`,type:`string`},{name:`packageSubpath`,type:`string`},{name:`base`,type:`URL`},{name:`pattern`,type:`boolean`},{name:`internal`,type:`boolean`},{name:`conditions`,type:`Set<string>`}],returnType:`URL | null | undefined`,children:o`if (typeof target === "string") {
961
+ return isConditionalSugar;`
962
+ }),
963
+ createComponent(Spacing, {}),
964
+ createComponent(FunctionDeclaration, {
965
+ name: "resolvePackageTarget",
966
+ parameters: [
967
+ {
968
+ name: "packageJsonUrl",
969
+ type: "URL"
970
+ },
971
+ {
972
+ name: "target",
973
+ type: "unknown"
974
+ },
975
+ {
976
+ name: "subpath",
977
+ type: "string"
978
+ },
979
+ {
980
+ name: "packageSubpath",
981
+ type: "string"
982
+ },
983
+ {
984
+ name: "base",
985
+ type: "URL"
986
+ },
987
+ {
988
+ name: "pattern",
989
+ type: "boolean"
990
+ },
991
+ {
992
+ name: "internal",
993
+ type: "boolean"
994
+ },
995
+ {
996
+ name: "conditions",
997
+ type: "Set<string>"
998
+ }
999
+ ],
1000
+ returnType: "URL | null | undefined",
1001
+ children: code`if (typeof target === "string") {
492
1002
  if (!target.startsWith("./")) {
493
1003
  if (internal && !target.startsWith("../") && !target.startsWith("/")) {
494
1004
  let isURL = false;
@@ -585,7 +1095,35 @@ import{createComponent as e,createIntrinsic as t,memo as n,mergeProps as r}from"
585
1095
  return null;
586
1096
  }
587
1097
 
588
- return null;`}),e(c,{}),e(u,{name:`packageExportsResolve`,parameters:[{name:`packageJsonUrl`,type:`URL`},{name:`packageSubpath`,type:`string`},{name:`packageConfig`,type:`PackageConfig`},{name:`base`,type:`URL`},{name:`conditions`,type:`Set<string>`}],returnType:`URL | null | undefined`,children:o`let exports = packageConfig.exports;
1098
+ return null;`
1099
+ }),
1100
+ createComponent(Spacing, {}),
1101
+ createComponent(FunctionDeclaration, {
1102
+ name: "packageExportsResolve",
1103
+ parameters: [
1104
+ {
1105
+ name: "packageJsonUrl",
1106
+ type: "URL"
1107
+ },
1108
+ {
1109
+ name: "packageSubpath",
1110
+ type: "string"
1111
+ },
1112
+ {
1113
+ name: "packageConfig",
1114
+ type: "PackageConfig"
1115
+ },
1116
+ {
1117
+ name: "base",
1118
+ type: "URL"
1119
+ },
1120
+ {
1121
+ name: "conditions",
1122
+ type: "Set<string>"
1123
+ }
1124
+ ],
1125
+ returnType: "URL | null | undefined",
1126
+ children: code`let exports = packageConfig.exports;
589
1127
  if (isConditionalExportsMainSugar(exports)) {
590
1128
  exports = { ".": exports } as Record<string, unknown>;
591
1129
  }
@@ -659,7 +1197,20 @@ import{createComponent as e,createIntrinsic as t,memo as n,mergeProps as r}from"
659
1197
  \`Package subpath '\${packageSubpath}' is not defined by "exports" in \${fileURLToPath(packageJsonUrl)}\`
660
1198
  );
661
1199
  (err as any).code = "ERR_PACKAGE_PATH_NOT_EXPORTED";
662
- throw err;`}),e(c,{}),e(u,{name:`patternKeyCompare`,parameters:[{name:`a`,type:`string`},{name:`b`,type:`string`}],returnType:`number`,children:o`const aPatternIndex = a.indexOf("*");
1200
+ throw err;`
1201
+ }),
1202
+ createComponent(Spacing, {}),
1203
+ createComponent(FunctionDeclaration, {
1204
+ name: "patternKeyCompare",
1205
+ parameters: [{
1206
+ name: "a",
1207
+ type: "string"
1208
+ }, {
1209
+ name: "b",
1210
+ type: "string"
1211
+ }],
1212
+ returnType: "number",
1213
+ children: code`const aPatternIndex = a.indexOf("*");
663
1214
  const bPatternIndex = b.indexOf("*");
664
1215
  const baseLengthA = aPatternIndex === -1 ? a.length : aPatternIndex + 1;
665
1216
  const baseLengthB = bPatternIndex === -1 ? b.length : bPatternIndex + 1;
@@ -669,7 +1220,20 @@ import{createComponent as e,createIntrinsic as t,memo as n,mergeProps as r}from"
669
1220
  if (bPatternIndex === -1) return -1;
670
1221
  if (a.length > b.length) return -1;
671
1222
  if (b.length > a.length) return 1;
672
- return 0;`}),e(c,{}),e(u,{name:`legacyMainResolve`,parameters:[{name:`packageJsonUrl`,type:`URL`},{name:`packageConfig`,type:`PackageConfig`}],returnType:`URL | undefined`,children:o`let guess: URL | undefined;
1223
+ return 0;`
1224
+ }),
1225
+ createComponent(Spacing, {}),
1226
+ createComponent(FunctionDeclaration, {
1227
+ name: "legacyMainResolve",
1228
+ parameters: [{
1229
+ name: "packageJsonUrl",
1230
+ type: "URL"
1231
+ }, {
1232
+ name: "packageConfig",
1233
+ type: "PackageConfig"
1234
+ }],
1235
+ returnType: "URL | undefined",
1236
+ children: code`let guess: URL | undefined;
673
1237
  const tries: string[] = [];
674
1238
 
675
1239
  if (packageConfig.main !== undefined) {
@@ -697,7 +1261,20 @@ import{createComponent as e,createIntrinsic as t,memo as n,mergeProps as r}from"
697
1261
  guess = undefined;
698
1262
  }
699
1263
 
700
- return undefined;`}),e(c,{}),e(u,{name:`parsePackageName`,parameters:[{name:`specifier`,type:`string`},{name:`base`,type:`URL`}],returnType:`{ packageName: string; packageSubpath: string; isScoped: boolean }`,children:o`let separatorIndex = specifier.indexOf("/");
1264
+ return undefined;`
1265
+ }),
1266
+ createComponent(Spacing, {}),
1267
+ createComponent(FunctionDeclaration, {
1268
+ name: "parsePackageName",
1269
+ parameters: [{
1270
+ name: "specifier",
1271
+ type: "string"
1272
+ }, {
1273
+ name: "base",
1274
+ type: "URL"
1275
+ }],
1276
+ returnType: "{ packageName: string; packageSubpath: string; isScoped: boolean }",
1277
+ children: code`let separatorIndex = specifier.indexOf("/");
701
1278
  let validPackageName = true;
702
1279
  let isScoped = false;
703
1280
 
@@ -730,7 +1307,27 @@ import{createComponent as e,createIntrinsic as t,memo as n,mergeProps as r}from"
730
1307
  ? ""
731
1308
  : specifier.slice(separatorIndex));
732
1309
 
733
- return { packageName, packageSubpath, isScoped };`}),e(c,{}),e(u,{name:`packageResolve`,parameters:[{name:`specifier`,type:`string`},{name:`base`,type:`URL`},{name:`conditions`,type:`Set<string>`}],returnType:`URL`,children:o`if (builtinModules.includes(specifier)) {
1310
+ return { packageName, packageSubpath, isScoped };`
1311
+ }),
1312
+ createComponent(Spacing, {}),
1313
+ createComponent(FunctionDeclaration, {
1314
+ name: "packageResolve",
1315
+ parameters: [
1316
+ {
1317
+ name: "specifier",
1318
+ type: "string"
1319
+ },
1320
+ {
1321
+ name: "base",
1322
+ type: "URL"
1323
+ },
1324
+ {
1325
+ name: "conditions",
1326
+ type: "Set<string>"
1327
+ }
1328
+ ],
1329
+ returnType: "URL",
1330
+ children: code`if (builtinModules.includes(specifier)) {
734
1331
  return new URL("node:" + specifier);
735
1332
  }
736
1333
 
@@ -804,7 +1401,20 @@ import{createComponent as e,createIntrinsic as t,memo as n,mergeProps as r}from"
804
1401
  const err = new Error(\`Cannot find package \\\`\${packageName}\\\`\`);
805
1402
  (err as any).code = "ERR_MODULE_NOT_FOUND";
806
1403
 
807
- throw err;`}),e(c,{}),e(u,{name:`finalizeResolution`,parameters:[{name:`resolved`,type:`URL`},{name:`base`,type:`URL`}],returnType:`URL`,children:o`if (/%2f|%5c/i.test(resolved.pathname)) {
1404
+ throw err;`
1405
+ }),
1406
+ createComponent(Spacing, {}),
1407
+ createComponent(FunctionDeclaration, {
1408
+ name: "finalizeResolution",
1409
+ parameters: [{
1410
+ name: "resolved",
1411
+ type: "URL"
1412
+ }, {
1413
+ name: "base",
1414
+ type: "URL"
1415
+ }],
1416
+ returnType: "URL",
1417
+ children: code`if (/%2f|%5c/i.test(resolved.pathname)) {
808
1418
  const err = new Error(
809
1419
  \`Invalid module \\\`\${resolved.pathname}\\\` must not include encoded "/" or "\\\\" characters imported from \${fileURLToPath(base)}\`
810
1420
  );
@@ -842,7 +1452,27 @@ import{createComponent as e,createIntrinsic as t,memo as n,mergeProps as r}from"
842
1452
  realUrl.search = search;
843
1453
  realUrl.hash = hash;
844
1454
 
845
- return realUrl;`}),e(c,{}),e(u,{name:`moduleResolve`,parameters:[{name:`specifier`,type:`string`},{name:`base`,type:`URL`},{name:`conditions`,type:`Set<string>`}],returnType:`URL`,children:o`let resolved: URL | undefined;
1455
+ return realUrl;`
1456
+ }),
1457
+ createComponent(Spacing, {}),
1458
+ createComponent(FunctionDeclaration, {
1459
+ name: "moduleResolve",
1460
+ parameters: [
1461
+ {
1462
+ name: "specifier",
1463
+ type: "string"
1464
+ },
1465
+ {
1466
+ name: "base",
1467
+ type: "URL"
1468
+ },
1469
+ {
1470
+ name: "conditions",
1471
+ type: "Set<string>"
1472
+ }
1473
+ ],
1474
+ returnType: "URL",
1475
+ children: code`let resolved: URL | undefined;
846
1476
 
847
1477
  if (
848
1478
  specifier[0] === "/" ||
@@ -931,7 +1561,27 @@ import{createComponent as e,createIntrinsic as t,memo as n,mergeProps as r}from"
931
1561
  return resolved;
932
1562
  }
933
1563
 
934
- return finalizeResolution(resolved, base);`}),e(c,{}),e(u,{name:`tryModuleResolve`,parameters:[{name:`id`,type:`string`},{name:`url`,type:`URL`},{name:`conditions`,type:`Set<string>`}],returnType:`URL | undefined`,children:o`try {
1564
+ return finalizeResolution(resolved, base);`
1565
+ }),
1566
+ createComponent(Spacing, {}),
1567
+ createComponent(FunctionDeclaration, {
1568
+ name: "tryModuleResolve",
1569
+ parameters: [
1570
+ {
1571
+ name: "id",
1572
+ type: "string"
1573
+ },
1574
+ {
1575
+ name: "url",
1576
+ type: "URL"
1577
+ },
1578
+ {
1579
+ name: "conditions",
1580
+ type: "Set<string>"
1581
+ }
1582
+ ],
1583
+ returnType: "URL | undefined",
1584
+ children: code`try {
935
1585
  return moduleResolve(id, url, conditions);
936
1586
  } catch (error: any) {
937
1587
  if (
@@ -945,13 +1595,46 @@ import{createComponent as e,createIntrinsic as t,memo as n,mergeProps as r}from"
945
1595
  ) {
946
1596
  throw error;
947
1597
  }
948
- }`}),e(c,{}),e(g,{heading:`A function to resolve module specifiers to URLs.`,get children(){return[e(y,{name:`specifier`,children:`The module specifier to resolve.`}),e(y,{name:`options`,children:`The options for resolving the module. Defaults to an empty object.`}),e(x,{children:`The result of the resolve operation.`})]}}),e(u,{async:!0,export:!0,name:`resolveModule`,parameters:[{name:`specifier`,type:`string`},{name:`options`,type:`ResolveModuleOptions`,default:`{} as ResolveModuleOptions`}],returnType:`Promise<string>`,get children(){return o`const parentURL = options.parentURL ? new URL(options.parentURL) : undefined;
1598
+ }`
1599
+ }),
1600
+ createComponent(Spacing, {}),
1601
+ createComponent(TSDoc, {
1602
+ heading: "A function to resolve module specifiers to URLs.",
1603
+ get children() {
1604
+ return [
1605
+ createComponent(TSDocParam, {
1606
+ name: "specifier",
1607
+ children: `The module specifier to resolve.`
1608
+ }),
1609
+ createComponent(TSDocParam, {
1610
+ name: "options",
1611
+ children: `The options for resolving the module. Defaults to an empty object.`
1612
+ }),
1613
+ createComponent(TSDocReturns, { children: `The result of the resolve operation.` })
1614
+ ];
1615
+ }
1616
+ }),
1617
+ createComponent(FunctionDeclaration, {
1618
+ async: true,
1619
+ "export": true,
1620
+ name: "resolveModule",
1621
+ parameters: [{
1622
+ name: "specifier",
1623
+ type: "string"
1624
+ }, {
1625
+ name: "options",
1626
+ type: "ResolveModuleOptions",
1627
+ default: "{} as ResolveModuleOptions"
1628
+ }],
1629
+ returnType: "Promise<string>",
1630
+ get children() {
1631
+ return code`const parentURL = options.parentURL ? new URL(options.parentURL) : undefined;
949
1632
  const conditionsSet = options.conditions?.length
950
1633
  ? new Set(options.conditions)
951
1634
  : DEFAULT_CONDITIONS_SET;
952
1635
 
953
- // Handle protocol-prefixed specifiers (node:, data:, http:, https:, ${n.config.framework}:)
954
- if (/^(?:node|data|https?|${n.config.framework}):/.test(specifier)) {
1636
+ // Handle protocol-prefixed specifiers (node:, data:, http:, https:, ${context.config.framework}:)
1637
+ if (/^(?:node|data|https?|${context.config.framework}):/.test(specifier)) {
955
1638
  return specifier;
956
1639
  }
957
1640
 
@@ -979,12 +1662,12 @@ import{createComponent as e,createIntrinsic as t,memo as n,mergeProps as r}from"
979
1662
 
980
1663
  const roots = [parentURL ?? pathToFileURL(join(process.cwd(), "_"))];
981
1664
 
982
- const projectRootURL = pathToFileURL("${n.config.root}");
1665
+ const projectRootURL = pathToFileURL("${context.config.root}");
983
1666
  if (!roots.some(root => root.href === projectRootURL.href)) {
984
1667
  roots.push(projectRootURL);
985
1668
  }
986
1669
 
987
- const workspaceRootURL = pathToFileURL("${n.config.cwd}");
1670
+ const workspaceRootURL = pathToFileURL("${context.config.cwd}");
988
1671
  if (!roots.some(root => root.href === workspaceRootURL.href)) {
989
1672
  roots.push(workspaceRootURL);
990
1673
  }
@@ -1042,5 +1725,117 @@ import{createComponent as e,createIntrinsic as t,memo as n,mergeProps as r}from"
1042
1725
  }
1043
1726
 
1044
1727
  return pathToFileURL(fileURLToPath(resolved)).href;
1045
- `}})]}j.__type=[`ResolveModuleFunctionDeclaration`,"Generates the `resolveModule` function declaration, which is a utility for resolving file paths across different platforms.",`P"/!?"`];function M(t){let[{children:n},l]=s(t,[`children`]);return e(h,r({id:`utils`,description:`A collection of helper utilities that ease command-line application development.`},l,{get imports(){return i(l.imports??{},{"node:os":`os`,"node:process":`process`,"node:path":[`join`,`sep`,`isAbsolute`],"node:fs":[{name:`constants`,alias:`fsConstants`},`openSync`,`closeSync`,`read`,`readFileSync`,`statSync`,`realpathSync`],"node:tty":[`WriteStream`],"node:url":[`fileURLToPath`,`pathToFileURL`],"node:module":[`builtinModules`]})},get builtinImports(){return i(l.builtinImports??{},{env:[`env`,`isCI`,`isTest`,`isWindows`,`isLinux`,`isMacOS`],exec:[`execSync`],state:[`hasFlag`]})},get children(){return[e(g,{heading:`A utility function to pause execution for a specified duration, which can be used in prompt interactions to create delays or timeouts. The function returns a promise that resolves after the specified duration in milliseconds, allowing it to be used with async/await syntax for easier handling of asynchronous prompt logic.`,get children(){return[e(y,{name:`durationMs`,children:`The duration to sleep in milliseconds.`}),e(x,{children:`A promise that resolves after the specified duration, allowing for asynchronous delays in prompt interactions.`})]}}),e(u,{export:!0,name:`sleep`,parameters:[{name:`durationMs`,type:`number`}],returnType:`Promise<void>`,children:o`return new Promise((resolve) => setTimeout(resolve, durationMs)); `}),e(c,{}),e(D,{}),e(c,{}),e(O,{}),e(c,{}),e(A,{}),e(c,{}),e(k,{}),e(c,{}),e(j,{}),e(c,{}),e(E,{}),e(c,{}),e(a,{get when(){return!!n},children:n})]}}))}M.__type=[()=>T,`props`,`UtilsBuiltin`,`A built-in utilities module for Shell Shock.`,`Pn!2""/#?$`];export{k as ColorSupportUtilities,O as EnvSupportUtilities,E as FindSuggestionsDeclaration,A as HyperlinkSupportUtilities,j as ResolveModuleFunctionDeclaration,D as TerminalSizeDeclaration,M as UtilsBuiltin,T as __ΩUtilsBuiltinProps};
1728
+ `;
1729
+ }
1730
+ })
1731
+ ];
1732
+ }
1733
+ ResolveModuleFunctionDeclaration.__type = [
1734
+ "ResolveModuleFunctionDeclaration",
1735
+ "Generates the `resolveModule` function declaration, which is a utility for resolving file paths across different platforms.",
1736
+ "P\"/!?\""
1737
+ ];
1738
+ /**
1739
+ * A built-in utilities module for Shell Shock.
1740
+ */
1741
+ function UtilsBuiltin(props) {
1742
+ const [{ children }, rest] = splitProps(props, ["children"]);
1743
+ return createComponent(BuiltinFile, mergeProps({
1744
+ id: "utils",
1745
+ description: "A collection of helper utilities that ease command-line application development."
1746
+ }, rest, {
1747
+ get imports() {
1748
+ return defu$1(rest.imports ?? {}, {
1749
+ "node:os": "os",
1750
+ "node:process": "process",
1751
+ "node:path": [
1752
+ "join",
1753
+ "sep",
1754
+ "isAbsolute"
1755
+ ],
1756
+ "node:fs": [
1757
+ {
1758
+ name: "constants",
1759
+ alias: "fsConstants"
1760
+ },
1761
+ "openSync",
1762
+ "closeSync",
1763
+ "read",
1764
+ "readFileSync",
1765
+ "statSync",
1766
+ "realpathSync"
1767
+ ],
1768
+ "node:tty": ["WriteStream"],
1769
+ "node:url": ["fileURLToPath", "pathToFileURL"],
1770
+ "node:module": ["builtinModules"]
1771
+ });
1772
+ },
1773
+ get builtinImports() {
1774
+ return defu$1(rest.builtinImports ?? {}, {
1775
+ env: [
1776
+ "env",
1777
+ "isCI",
1778
+ "isTest",
1779
+ "isWindows",
1780
+ "isLinux",
1781
+ "isMacOS"
1782
+ ],
1783
+ exec: ["execSync"],
1784
+ state: ["hasFlag"]
1785
+ });
1786
+ },
1787
+ get children() {
1788
+ return [
1789
+ createComponent(TSDoc, {
1790
+ heading: "A utility function to pause execution for a specified duration, which can be used in prompt interactions to create delays or timeouts. The function returns a promise that resolves after the specified duration in milliseconds, allowing it to be used with async/await syntax for easier handling of asynchronous prompt logic.",
1791
+ get children() {
1792
+ return [createComponent(TSDocParam, {
1793
+ name: "durationMs",
1794
+ children: `The duration to sleep in milliseconds.`
1795
+ }), createComponent(TSDocReturns, { children: `A promise that resolves after the specified duration, allowing for asynchronous delays in prompt interactions.` })];
1796
+ }
1797
+ }),
1798
+ createComponent(FunctionDeclaration, {
1799
+ "export": true,
1800
+ name: "sleep",
1801
+ parameters: [{
1802
+ name: "durationMs",
1803
+ type: "number"
1804
+ }],
1805
+ returnType: "Promise<void>",
1806
+ children: code`return new Promise((resolve) => setTimeout(resolve, durationMs)); `
1807
+ }),
1808
+ createComponent(Spacing, {}),
1809
+ createComponent(TerminalSizeDeclaration, {}),
1810
+ createComponent(Spacing, {}),
1811
+ createComponent(EnvSupportUtilities, {}),
1812
+ createComponent(Spacing, {}),
1813
+ createComponent(HyperlinkSupportUtilities, {}),
1814
+ createComponent(Spacing, {}),
1815
+ createComponent(ColorSupportUtilities, {}),
1816
+ createComponent(Spacing, {}),
1817
+ createComponent(ResolveModuleFunctionDeclaration, {}),
1818
+ createComponent(Spacing, {}),
1819
+ createComponent(FindSuggestionsDeclaration, {}),
1820
+ createComponent(Spacing, {}),
1821
+ createComponent(Show, {
1822
+ get when() {
1823
+ return Boolean(children);
1824
+ },
1825
+ children
1826
+ })
1827
+ ];
1828
+ }
1829
+ }));
1830
+ }
1831
+ UtilsBuiltin.__type = [
1832
+ () => __ΩUtilsBuiltinProps,
1833
+ "props",
1834
+ "UtilsBuiltin",
1835
+ "A built-in utilities module for Shell Shock.",
1836
+ "Pn!2\"\"/#?$"
1837
+ ];
1838
+
1839
+ //#endregion
1840
+ export { ColorSupportUtilities, EnvSupportUtilities, FindSuggestionsDeclaration, HyperlinkSupportUtilities, ResolveModuleFunctionDeclaration, TerminalSizeDeclaration, UtilsBuiltin, __ΩUtilsBuiltinProps };
1046
1841
  //# sourceMappingURL=utils-builtin.mjs.map