@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.
- package/dist/_virtual/_rolldown/runtime.cjs +29 -1
- package/dist/api.cjs +148 -1
- package/dist/api.d.cts +6 -6
- package/dist/api.d.cts.map +1 -1
- package/dist/api.d.mts +6 -6
- package/dist/api.d.mts.map +1 -1
- package/dist/api.mjs +145 -1
- package/dist/api.mjs.map +1 -1
- package/dist/components/command-validation-logic.cjs +292 -1
- package/dist/components/command-validation-logic.mjs +289 -1
- package/dist/components/command-validation-logic.mjs.map +1 -1
- package/dist/components/docs.cjs +265 -1
- package/dist/components/docs.mjs +256 -1
- package/dist/components/docs.mjs.map +1 -1
- package/dist/components/exec-builtin.cjs +429 -13
- package/dist/components/exec-builtin.mjs +425 -13
- package/dist/components/exec-builtin.mjs.map +1 -1
- package/dist/components/helpers.cjs +120 -1
- package/dist/components/helpers.mjs +112 -1
- package/dist/components/helpers.mjs.map +1 -1
- package/dist/components/index.cjs +58 -1
- package/dist/components/index.mjs +10 -1
- package/dist/components/options-parser-logic.cjs +960 -5
- package/dist/components/options-parser-logic.d.cts +1 -1
- package/dist/components/options-parser-logic.mjs +945 -5
- package/dist/components/options-parser-logic.mjs.map +1 -1
- package/dist/components/state-builtin.cjs +629 -8
- package/dist/components/state-builtin.mjs +622 -8
- package/dist/components/state-builtin.mjs.map +1 -1
- package/dist/components/usage.cjs +117 -1
- package/dist/components/usage.mjs +114 -1
- package/dist/components/usage.mjs.map +1 -1
- package/dist/components/utils-builtin.cjs +838 -33
- package/dist/components/utils-builtin.mjs +828 -33
- package/dist/components/utils-builtin.mjs.map +1 -1
- package/dist/config.cjs +31 -1
- package/dist/config.mjs +29 -1
- package/dist/config.mjs.map +1 -1
- package/dist/contexts/command.cjs +26 -1
- package/dist/contexts/command.mjs +23 -1
- package/dist/contexts/command.mjs.map +1 -1
- package/dist/contexts/index.cjs +9 -1
- package/dist/contexts/index.mjs +4 -1
- package/dist/contexts/options.cjs +63 -1
- package/dist/contexts/options.mjs +58 -1
- package/dist/contexts/options.mjs.map +1 -1
- package/dist/helpers/automd.cjs +71 -1
- package/dist/helpers/automd.mjs +70 -1
- package/dist/helpers/automd.mjs.map +1 -1
- package/dist/helpers/docs-helpers.cjs +23 -1
- package/dist/helpers/docs-helpers.mjs +22 -1
- package/dist/helpers/docs-helpers.mjs.map +1 -1
- package/dist/helpers/paths.cjs +137 -1
- package/dist/helpers/paths.mjs +133 -1
- package/dist/helpers/paths.mjs.map +1 -1
- package/dist/helpers/persistence.cjs +115 -1
- package/dist/helpers/persistence.mjs +112 -1
- package/dist/helpers/persistence.mjs.map +1 -1
- package/dist/helpers/update-package-json.cjs +65 -1
- package/dist/helpers/update-package-json.mjs +63 -1
- package/dist/helpers/update-package-json.mjs.map +1 -1
- package/dist/helpers/utilities.cjs +95 -1
- package/dist/helpers/utilities.mjs +93 -1
- package/dist/helpers/utilities.mjs.map +1 -1
- package/dist/helpers/validations.cjs +71 -1
- package/dist/helpers/validations.mjs +71 -1
- package/dist/helpers/validations.mjs.map +1 -1
- package/dist/index.cjs +53 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +7 -1
- package/dist/plugin-utils/compute-bin.cjs +50 -1
- package/dist/plugin-utils/compute-bin.mjs +49 -1
- package/dist/plugin-utils/compute-bin.mjs.map +1 -1
- package/dist/plugin-utils/context-helpers.cjs +231 -1
- package/dist/plugin-utils/context-helpers.mjs +221 -1
- package/dist/plugin-utils/context-helpers.mjs.map +1 -1
- package/dist/plugin-utils/deepkit.cjs +71 -1
- package/dist/plugin-utils/deepkit.mjs +69 -1
- package/dist/plugin-utils/deepkit.mjs.map +1 -1
- package/dist/plugin-utils/description-helpers.cjs +111 -2
- package/dist/plugin-utils/description-helpers.mjs +107 -2
- package/dist/plugin-utils/description-helpers.mjs.map +1 -1
- package/dist/plugin-utils/get-command-tree.cjs +117 -1
- package/dist/plugin-utils/get-command-tree.mjs +114 -1
- package/dist/plugin-utils/get-command-tree.mjs.map +1 -1
- package/dist/plugin-utils/index.cjs +39 -1
- package/dist/plugin-utils/index.mjs +10 -1
- package/dist/plugin-utils/reflect.cjs +52 -1
- package/dist/plugin-utils/reflect.mjs +52 -1
- package/dist/plugin-utils/reflect.mjs.map +1 -1
- package/dist/plugin-utils/traverse-command-tree.cjs +64 -1
- package/dist/plugin-utils/traverse-command-tree.mjs +62 -1
- package/dist/plugin-utils/traverse-command-tree.mjs.map +1 -1
- package/dist/plugin-utils/type-checks.cjs +93 -1
- package/dist/plugin-utils/type-checks.mjs +88 -1
- package/dist/plugin-utils/type-checks.mjs.map +1 -1
- package/dist/plugin.cjs +471 -4
- package/dist/plugin.d.cts.map +1 -1
- package/dist/plugin.d.mts.map +1 -1
- package/dist/plugin.mjs +465 -4
- package/dist/plugin.mjs.map +1 -1
- package/dist/resolver/deepkit.cjs +135 -1
- package/dist/resolver/deepkit.mjs +134 -1
- package/dist/resolver/deepkit.mjs.map +1 -1
- package/dist/resolver/helpers.cjs +173 -1
- package/dist/resolver/helpers.mjs +168 -1
- package/dist/resolver/helpers.mjs.map +1 -1
- package/dist/resolver/module.cjs +145 -1
- package/dist/resolver/module.mjs +144 -1
- package/dist/resolver/module.mjs.map +1 -1
- package/dist/resolver/resolve.cjs +222 -1
- package/dist/resolver/resolve.mjs +221 -1
- package/dist/resolver/resolve.mjs.map +1 -1
- package/dist/types/command.cjs +441 -1
- package/dist/types/command.d.cts +1 -1
- package/dist/types/command.d.mts +2 -2
- package/dist/types/command.mjs +405 -1
- package/dist/types/command.mjs.map +1 -1
- package/dist/types/config.cjs +134 -1
- package/dist/types/config.d.cts +10 -8
- package/dist/types/config.d.cts.map +1 -1
- package/dist/types/config.d.mts +10 -8
- package/dist/types/config.d.mts.map +1 -1
- package/dist/types/config.mjs +127 -1
- package/dist/types/config.mjs.map +1 -1
- package/dist/types/context.cjs +37 -1
- package/dist/types/context.mjs +34 -1
- package/dist/types/context.mjs.map +1 -1
- package/dist/types/env.cjs +52 -1
- package/dist/types/env.d.cts +1 -1
- package/dist/types/env.d.mts +1 -1
- package/dist/types/env.mjs +50 -1
- package/dist/types/env.mjs.map +1 -1
- package/dist/types/index.cjs +50 -1
- package/dist/types/index.d.cts +2 -2
- package/dist/types/index.d.mts +2 -2
- package/dist/types/index.mjs +6 -1
- package/dist/types/options.cjs +12 -1
- package/dist/types/options.mjs +10 -1
- package/package.json +22 -21
|
@@ -1,4 +1,50 @@
|
|
|
1
|
-
import{createComponent
|
|
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>; `
|
|
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 ?? "")${
|
|
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
|
-
`)
|
|
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
|
-
} `
|
|
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 {} `
|
|
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 {} `
|
|
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
|
-
}; `
|
|
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
|
-
}; `
|
|
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 {} `
|
|
372
|
+
} catch {} `
|
|
373
|
+
}),
|
|
374
|
+
createComponent(Spacing, {}),
|
|
375
|
+
code`return result ?? {
|
|
195
376
|
columns: DEFAULT_TERMINAL_COLUMNS,
|
|
196
377
|
rows: DEFAULT_TERMINAL_ROWS,
|
|
197
|
-
}; `
|
|
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
|
-
`
|
|
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
|
-
}; `
|
|
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"; `
|
|
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
|
-
}; `
|
|
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; `
|
|
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;`
|
|
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
|
-
};`
|
|
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;`
|
|
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;`
|
|
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;`
|
|
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;`
|
|
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;`
|
|
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 };`
|
|
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;`
|
|
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;`
|
|
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);`
|
|
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
|
-
}`
|
|
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:, ${
|
|
954
|
-
if (/^(?:node|data|https?|${
|
|
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("${
|
|
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("${
|
|
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
|
-
|
|
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
|