@socketsecurity/lib 5.18.2 → 5.19.0

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 (305) hide show
  1. package/CHANGELOG.md +43 -0
  2. package/README.md +6 -5
  3. package/dist/abort.d.ts +3 -0
  4. package/dist/abort.js +1 -0
  5. package/dist/agent.d.ts +66 -49
  6. package/dist/agent.js +51 -50
  7. package/dist/ansi.d.ts +2 -5
  8. package/dist/ansi.js +3 -2
  9. package/dist/archives.d.ts +25 -21
  10. package/dist/archives.js +35 -34
  11. package/dist/argv/flags.d.ts +100 -91
  12. package/dist/argv/flags.js +88 -87
  13. package/dist/argv/parse.d.ts +30 -40
  14. package/dist/argv/parse.js +33 -32
  15. package/dist/arrays.d.ts +4 -8
  16. package/dist/arrays.js +1 -0
  17. package/dist/bin.d.ts +7 -5
  18. package/dist/bin.js +52 -29
  19. package/dist/cacache.d.ts +13 -12
  20. package/dist/cacache.js +9 -8
  21. package/dist/cache-with-ttl.d.ts +53 -35
  22. package/dist/cache-with-ttl.js +1 -0
  23. package/dist/colors.d.ts +5 -5
  24. package/dist/colors.js +1 -0
  25. package/dist/constants/agents.d.ts +5 -9
  26. package/dist/constants/agents.js +3 -2
  27. package/dist/constants/core.d.ts +5 -10
  28. package/dist/constants/core.js +2 -1
  29. package/dist/constants/encoding.d.ts +3 -3
  30. package/dist/constants/encoding.js +1 -0
  31. package/dist/constants/github.d.ts +3 -3
  32. package/dist/constants/github.js +1 -0
  33. package/dist/constants/licenses.d.ts +9 -2
  34. package/dist/constants/licenses.js +1 -0
  35. package/dist/constants/lifecycle-script-names.js +1 -0
  36. package/dist/constants/maintained-node-versions.d.ts +3 -0
  37. package/dist/constants/maintained-node-versions.js +1 -0
  38. package/dist/constants/node.d.ts +125 -16
  39. package/dist/constants/node.js +74 -73
  40. package/dist/constants/package-default-node-range.d.ts +3 -1
  41. package/dist/constants/package-default-node-range.js +2 -1
  42. package/dist/constants/package-default-socket-categories.d.ts +0 -1
  43. package/dist/constants/package-default-socket-categories.js +1 -0
  44. package/dist/constants/packages.d.ts +12 -17
  45. package/dist/constants/packages.js +31 -16
  46. package/dist/constants/platform.d.ts +1 -2
  47. package/dist/constants/platform.js +2 -1
  48. package/dist/constants/process.d.ts +18 -0
  49. package/dist/constants/process.js +1 -0
  50. package/dist/constants/socket.d.ts +4 -10
  51. package/dist/constants/socket.js +2 -1
  52. package/dist/constants/testing.d.ts +3 -3
  53. package/dist/constants/testing.js +1 -0
  54. package/dist/constants/time.d.ts +3 -4
  55. package/dist/constants/time.js +1 -0
  56. package/dist/constants/typescript.d.ts +10 -3
  57. package/dist/constants/typescript.js +5 -4
  58. package/dist/cover/code.d.ts +3 -0
  59. package/dist/cover/code.js +12 -12
  60. package/dist/cover/formatters.d.ts +12 -9
  61. package/dist/cover/formatters.js +19 -18
  62. package/dist/cover/type.d.ts +3 -0
  63. package/dist/cover/type.js +1 -0
  64. package/dist/cover/types.js +1 -0
  65. package/dist/debug.d.ts +32 -47
  66. package/dist/debug.js +97 -96
  67. package/dist/dlx/arborist.d.ts +134 -0
  68. package/dist/dlx/arborist.js +177 -0
  69. package/dist/dlx/binary.d.ts +25 -9
  70. package/dist/dlx/binary.js +34 -12
  71. package/dist/dlx/cache.d.ts +1 -0
  72. package/dist/dlx/cache.js +2 -1
  73. package/dist/dlx/detect.d.ts +15 -0
  74. package/dist/dlx/detect.js +28 -20
  75. package/dist/dlx/dir.d.ts +1 -11
  76. package/dist/dlx/dir.js +2 -12
  77. package/dist/dlx/integrity.d.ts +86 -0
  78. package/dist/dlx/integrity.js +112 -0
  79. package/dist/dlx/lockfile.d.ts +115 -0
  80. package/dist/dlx/lockfile.js +139 -0
  81. package/dist/dlx/manifest.d.ts +26 -1
  82. package/dist/dlx/manifest.js +9 -6
  83. package/dist/dlx/package.d.ts +58 -3
  84. package/dist/dlx/package.js +101 -74
  85. package/dist/dlx/packages.d.ts +1 -11
  86. package/dist/dlx/packages.js +3 -14
  87. package/dist/dlx/paths.d.ts +1 -0
  88. package/dist/dlx/paths.js +2 -1
  89. package/dist/effects/pulse-frames.js +1 -0
  90. package/dist/effects/text-shimmer.d.ts +13 -2
  91. package/dist/effects/text-shimmer.js +50 -46
  92. package/dist/effects/types.js +1 -0
  93. package/dist/effects/ultra.js +1 -0
  94. package/dist/env/ci.d.ts +6 -1
  95. package/dist/env/ci.js +1 -0
  96. package/dist/env/debug.d.ts +5 -1
  97. package/dist/env/debug.js +1 -0
  98. package/dist/env/github.d.ts +19 -23
  99. package/dist/env/github.js +5 -4
  100. package/dist/env/helpers.d.ts +21 -9
  101. package/dist/env/helpers.js +5 -11
  102. package/dist/env/home.d.ts +17 -4
  103. package/dist/env/home.js +2 -1
  104. package/dist/env/locale.d.ts +4 -3
  105. package/dist/env/locale.js +1 -0
  106. package/dist/env/node-auth-token.d.ts +5 -1
  107. package/dist/env/node-auth-token.js +1 -0
  108. package/dist/env/node-env.d.ts +5 -1
  109. package/dist/env/node-env.js +1 -0
  110. package/dist/env/npm.d.ts +4 -5
  111. package/dist/env/npm.js +1 -0
  112. package/dist/env/package-manager.d.ts +4 -3
  113. package/dist/env/package-manager.js +2 -1
  114. package/dist/env/path.d.ts +5 -1
  115. package/dist/env/path.js +1 -0
  116. package/dist/env/pre-commit.d.ts +5 -1
  117. package/dist/env/pre-commit.js +1 -0
  118. package/dist/env/rewire.d.ts +10 -0
  119. package/dist/env/rewire.js +7 -5
  120. package/dist/env/shell.d.ts +5 -1
  121. package/dist/env/shell.js +1 -0
  122. package/dist/env/socket-cli-shadow.d.ts +4 -5
  123. package/dist/env/socket-cli-shadow.js +1 -0
  124. package/dist/env/socket-cli.d.ts +4 -14
  125. package/dist/env/socket-cli.js +1 -0
  126. package/dist/env/socket.d.ts +6 -18
  127. package/dist/env/socket.js +4 -3
  128. package/dist/env/temp-dir.d.ts +4 -3
  129. package/dist/env/temp-dir.js +1 -0
  130. package/dist/env/term.d.ts +5 -1
  131. package/dist/env/term.js +1 -0
  132. package/dist/env/test.d.ts +4 -3
  133. package/dist/env/test.js +1 -0
  134. package/dist/env/windows.d.ts +4 -4
  135. package/dist/env/windows.js +1 -0
  136. package/dist/env/xdg.d.ts +4 -3
  137. package/dist/env/xdg.js +1 -0
  138. package/dist/env.d.ts +83 -23
  139. package/dist/env.js +112 -80
  140. package/dist/errors.js +1 -0
  141. package/dist/external/@npmcli/package-json.js +9 -3968
  142. package/dist/external/@socketregistry/packageurl-js.js +2 -2
  143. package/dist/external/debug.js +162 -328
  144. package/dist/external/external-pack.js +3 -2835
  145. package/dist/external/npm-pack.js +13939 -33342
  146. package/dist/external/zod.js +160 -7558
  147. package/dist/fs.d.ts +92 -113
  148. package/dist/fs.js +35 -35
  149. package/dist/git.d.ts +170 -164
  150. package/dist/git.js +113 -87
  151. package/dist/github.d.ts +249 -227
  152. package/dist/github.js +82 -81
  153. package/dist/globs.d.ts +31 -17
  154. package/dist/globs.js +51 -58
  155. package/dist/http-request.d.ts +99 -99
  156. package/dist/http-request.js +182 -156
  157. package/dist/ipc-cli.d.ts +28 -0
  158. package/dist/{utils/get-ipc.js → ipc-cli.js} +4 -3
  159. package/dist/ipc.d.ts +9 -299
  160. package/dist/ipc.js +18 -204
  161. package/dist/json/edit.d.ts +3 -1
  162. package/dist/json/edit.js +30 -30
  163. package/dist/json/format.d.ts +36 -36
  164. package/dist/json/format.js +22 -21
  165. package/dist/json/parse.d.ts +4 -2
  166. package/dist/json/parse.js +1 -0
  167. package/dist/json/types.js +1 -0
  168. package/dist/{links/index.d.ts → links.d.ts} +6 -2
  169. package/dist/{links/index.js → links.js} +5 -4
  170. package/dist/logger.d.ts +4 -6
  171. package/dist/logger.js +61 -53
  172. package/dist/memoization.d.ts +52 -49
  173. package/dist/memoization.js +55 -33
  174. package/dist/objects.d.ts +25 -44
  175. package/dist/objects.js +2 -1
  176. package/dist/package-extensions.d.ts +6 -0
  177. package/dist/package-extensions.js +2 -1
  178. package/dist/packages/edit.d.ts +3 -5
  179. package/dist/packages/edit.js +4 -3
  180. package/dist/packages/exports.d.ts +11 -14
  181. package/dist/packages/exports.js +11 -10
  182. package/dist/packages/isolation.d.ts +4 -0
  183. package/dist/packages/isolation.js +20 -19
  184. package/dist/packages/licenses.d.ts +3 -10
  185. package/dist/packages/licenses.js +2 -1
  186. package/dist/packages/manifest.d.ts +3 -3
  187. package/dist/packages/manifest.js +1 -0
  188. package/dist/packages/normalize.d.ts +3 -4
  189. package/dist/packages/normalize.js +1 -0
  190. package/dist/packages/operations.d.ts +3 -10
  191. package/dist/packages/operations.js +1 -0
  192. package/dist/packages/provenance.d.ts +10 -8
  193. package/dist/packages/provenance.js +55 -54
  194. package/dist/packages/specs.d.ts +3 -5
  195. package/dist/packages/specs.js +1 -0
  196. package/dist/packages/validation.d.ts +3 -3
  197. package/dist/packages/validation.js +1 -0
  198. package/dist/packages.d.ts +2 -17
  199. package/dist/packages.js +2 -1
  200. package/dist/paths/dirnames.d.ts +0 -2
  201. package/dist/paths/dirnames.js +1 -0
  202. package/dist/paths/exts.d.ts +0 -1
  203. package/dist/paths/exts.js +1 -0
  204. package/dist/paths/filenames.d.ts +0 -1
  205. package/dist/paths/filenames.js +1 -0
  206. package/dist/paths/globs.d.ts +0 -1
  207. package/dist/paths/globs.js +1 -0
  208. package/dist/paths/normalize.d.ts +115 -123
  209. package/dist/paths/normalize.js +128 -127
  210. package/dist/paths/packages.d.ts +3 -2
  211. package/dist/paths/packages.js +2 -1
  212. package/dist/paths/rewire.d.ts +9 -0
  213. package/dist/paths/rewire.js +5 -3
  214. package/dist/paths/socket.d.ts +37 -23
  215. package/dist/paths/socket.js +26 -25
  216. package/dist/performance.d.ts +87 -84
  217. package/dist/performance.js +97 -96
  218. package/dist/process-lock.d.ts +41 -1
  219. package/dist/process-lock.js +24 -17
  220. package/dist/promise-queue.d.ts +6 -0
  221. package/dist/promise-queue.js +1 -0
  222. package/dist/promises.d.ts +40 -55
  223. package/dist/promises.js +12 -11
  224. package/dist/regexps.d.ts +0 -5
  225. package/dist/regexps.js +1 -0
  226. package/dist/releases/github.d.ts +59 -63
  227. package/dist/releases/github.js +95 -100
  228. package/dist/releases/socket-btm.d.ts +9 -2
  229. package/dist/releases/socket-btm.js +32 -25
  230. package/dist/sea.d.ts +5 -0
  231. package/dist/sea.js +1 -0
  232. package/dist/shadow.d.ts +4 -0
  233. package/dist/shadow.js +1 -0
  234. package/dist/signal-exit.d.ts +7 -7
  235. package/dist/signal-exit.js +46 -45
  236. package/dist/sorts.d.ts +5 -7
  237. package/dist/sorts.js +11 -10
  238. package/dist/spawn.d.ts +96 -77
  239. package/dist/spawn.js +39 -38
  240. package/dist/spinner.d.ts +21 -22
  241. package/dist/spinner.js +15 -11
  242. package/dist/ssri.d.ts +31 -36
  243. package/dist/ssri.js +15 -14
  244. package/dist/stdio/_stream.d.ts +31 -0
  245. package/dist/stdio/_stream.js +57 -0
  246. package/dist/stdio/divider.d.ts +40 -36
  247. package/dist/stdio/divider.js +10 -9
  248. package/dist/stdio/footer.d.ts +20 -0
  249. package/dist/stdio/footer.js +12 -2
  250. package/dist/stdio/header.d.ts +4 -16
  251. package/dist/stdio/header.js +1 -9
  252. package/dist/stdio/stderr.d.ts +51 -39
  253. package/dist/stdio/stderr.js +19 -22
  254. package/dist/stdio/stdout.d.ts +54 -52
  255. package/dist/stdio/stdout.js +35 -33
  256. package/dist/streams.d.ts +4 -3
  257. package/dist/streams.js +1 -0
  258. package/dist/strings.d.ts +31 -85
  259. package/dist/strings.js +5 -49
  260. package/dist/suppress-warnings.d.ts +32 -15
  261. package/dist/suppress-warnings.js +14 -13
  262. package/dist/tables.d.ts +30 -26
  263. package/dist/tables.js +24 -23
  264. package/dist/temporary-executor.d.ts +4 -0
  265. package/dist/temporary-executor.js +1 -0
  266. package/dist/themes/context.d.ts +30 -26
  267. package/dist/themes/context.js +19 -18
  268. package/dist/themes/index.d.ts +0 -4
  269. package/dist/themes/index.js +1 -0
  270. package/dist/themes/themes.d.ts +1 -1
  271. package/dist/themes/themes.js +1 -0
  272. package/dist/themes/types.js +1 -0
  273. package/dist/themes/utils.d.ts +46 -43
  274. package/dist/themes/utils.js +45 -44
  275. package/dist/types.d.ts +48 -52
  276. package/dist/types.js +35 -35
  277. package/dist/url.d.ts +48 -53
  278. package/dist/url.js +38 -37
  279. package/dist/validation/json-parser.d.ts +19 -190
  280. package/dist/validation/json-parser.js +5 -69
  281. package/dist/validation/types.d.ts +9 -33
  282. package/dist/validation/types.js +1 -0
  283. package/dist/versions.d.ts +1 -0
  284. package/dist/versions.js +2 -1
  285. package/dist/words.d.ts +3 -6
  286. package/dist/words.js +1 -0
  287. package/dist/zod.js +1 -0
  288. package/package.json +34 -66
  289. package/dist/external/@inquirer/checkbox.js +0 -5
  290. package/dist/external/@inquirer/confirm.js +0 -5
  291. package/dist/external/@inquirer/input.js +0 -5
  292. package/dist/external/@inquirer/password.js +0 -5
  293. package/dist/external/@inquirer/search.js +0 -5
  294. package/dist/external/@inquirer/select.js +0 -5
  295. package/dist/functions.d.ts +0 -57
  296. package/dist/functions.js +0 -70
  297. package/dist/stdio/clear.d.ts +0 -140
  298. package/dist/stdio/clear.js +0 -95
  299. package/dist/stdio/mask.d.ts +0 -151
  300. package/dist/stdio/mask.js +0 -224
  301. package/dist/stdio/progress.d.ts +0 -148
  302. package/dist/stdio/progress.js +0 -212
  303. package/dist/stdio/prompts.d.ts +0 -195
  304. package/dist/stdio/prompts.js +0 -176
  305. package/dist/utils/get-ipc.d.ts +0 -15
@@ -1,140 +0,0 @@
1
- export declare function clearLine(stream?: NodeJS.WriteStream): void;
2
- /**
3
- * Clear multiple lines above the current cursor position.
4
- * Useful for clearing multi-line output like progress bars or status messages.
5
- *
6
- * ANSI Sequences:
7
- * - `\x1b[1A`: Move cursor up one line
8
- * - `\x1b[2K`: Erase entire line
9
- *
10
- * @param count - Number of lines to clear
11
- * @param stream - Output stream to clear
12
- * @default stream process.stdout
13
- *
14
- * @example
15
- * ```ts
16
- * console.log('Line 1')
17
- * console.log('Line 2')
18
- * console.log('Line 3')
19
- * clearLines(2) // Clears lines 2 and 3
20
- * ```
21
- */
22
- export declare function clearLines(count: number, stream?: NodeJS.WriteStream): void;
23
- /**
24
- * Clear the entire screen and reset cursor to top-left.
25
- * Only works in TTY environments.
26
- *
27
- * ANSI Sequence:
28
- * - `\x1bc`: Full reset (clear screen and move cursor home)
29
- *
30
- * @param stream - Output stream to clear
31
- * @default stream process.stdout
32
- *
33
- * @example
34
- * ```ts
35
- * clearScreen() // Clear entire terminal
36
- * ```
37
- */
38
- export declare function clearScreen(stream?: NodeJS.WriteStream): void;
39
- /**
40
- * Clear the visible terminal screen.
41
- * Alias for `clearScreen()`.
42
- *
43
- * @param stream - Output stream to clear
44
- * @default stream process.stdout
45
- *
46
- * @example
47
- * ```ts
48
- * clearVisible() // Same as clearScreen()
49
- * ```
50
- */
51
- export declare function clearVisible(stream?: NodeJS.WriteStream): void;
52
- /**
53
- * Move cursor to the beginning of the current line.
54
- * Uses native TTY methods when available, falls back to carriage return.
55
- *
56
- * @param stream - Output stream to manipulate
57
- * @default stream process.stdout
58
- *
59
- * @example
60
- * ```ts
61
- * process.stdout.write('Some text...')
62
- * cursorToStart()
63
- * process.stdout.write('New text') // Overwrites from start
64
- * ```
65
- */
66
- export declare function cursorToStart(stream?: NodeJS.WriteStream): void;
67
- /**
68
- * Hide the terminal cursor.
69
- * Useful for cleaner output during animations or progress indicators.
70
- *
71
- * ANSI Sequence:
72
- * - `\x1b[?25l`: DECTCEM hide cursor
73
- *
74
- * @param stream - Output stream to manipulate
75
- * @default stream process.stdout
76
- *
77
- * @example
78
- * ```ts
79
- * hideCursor()
80
- * // ... show animation
81
- * showCursor()
82
- * ```
83
- */
84
- export declare function hideCursor(stream?: NodeJS.WriteStream): void;
85
- /**
86
- * Show the terminal cursor.
87
- * Should be called after `hideCursor()` to restore normal cursor visibility.
88
- *
89
- * ANSI Sequence:
90
- * - `\x1b[?25h`: DECTCEM show cursor
91
- *
92
- * @param stream - Output stream to manipulate
93
- * @default stream process.stdout
94
- *
95
- * @example
96
- * ```ts
97
- * hideCursor()
98
- * // ... show animation
99
- * showCursor()
100
- * ```
101
- */
102
- export declare function showCursor(stream?: NodeJS.WriteStream): void;
103
- /**
104
- * Save the current cursor position.
105
- * Can be restored later with `restoreCursor()`.
106
- *
107
- * ANSI Sequence:
108
- * - `\x1b7`: DECSC save cursor
109
- *
110
- * @param stream - Output stream to manipulate
111
- * @default stream process.stdout
112
- *
113
- * @example
114
- * ```ts
115
- * saveCursor()
116
- * console.log('Temporary text')
117
- * restoreCursor()
118
- * console.log('Back at saved position')
119
- * ```
120
- */
121
- export declare function saveCursor(stream?: NodeJS.WriteStream): void;
122
- /**
123
- * Restore cursor to previously saved position.
124
- * Must be called after `saveCursor()`.
125
- *
126
- * ANSI Sequence:
127
- * - `\x1b8`: DECRC restore cursor
128
- *
129
- * @param stream - Output stream to manipulate
130
- * @default stream process.stdout
131
- *
132
- * @example
133
- * ```ts
134
- * saveCursor()
135
- * console.log('Temporary text')
136
- * restoreCursor()
137
- * console.log('Back at saved position')
138
- * ```
139
- */
140
- export declare function restoreCursor(stream?: NodeJS.WriteStream): void;
@@ -1,95 +0,0 @@
1
- "use strict";
2
- /* Socket Lib - Built with esbuild */
3
- var __create = Object.create;
4
- var __defProp = Object.defineProperty;
5
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
- var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getProtoOf = Object.getPrototypeOf;
8
- var __hasOwnProp = Object.prototype.hasOwnProperty;
9
- var __export = (target, all) => {
10
- for (var name in all)
11
- __defProp(target, name, { get: all[name], enumerable: true });
12
- };
13
- var __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from === "object" || typeof from === "function") {
15
- for (let key of __getOwnPropNames(from))
16
- if (!__hasOwnProp.call(to, key) && key !== except)
17
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
- }
19
- return to;
20
- };
21
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
- // If the importer is in node compatibility mode or this is not an ESM
23
- // file that has been converted to a CommonJS file using a Babel-
24
- // compatible transform (i.e. "__esModule" has not been set), then set
25
- // "default" to the CommonJS "module.exports" for node compatibility.
26
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
- mod
28
- ));
29
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
- var clear_exports = {};
31
- __export(clear_exports, {
32
- clearLine: () => clearLine,
33
- clearLines: () => clearLines,
34
- clearScreen: () => clearScreen,
35
- clearVisible: () => clearVisible,
36
- cursorToStart: () => cursorToStart,
37
- hideCursor: () => hideCursor,
38
- restoreCursor: () => restoreCursor,
39
- saveCursor: () => saveCursor,
40
- showCursor: () => showCursor
41
- });
42
- module.exports = __toCommonJS(clear_exports);
43
- var import_node_process = __toESM(require("node:process"));
44
- function clearLine(stream = import_node_process.default.stdout) {
45
- if (stream.isTTY) {
46
- stream.cursorTo(0);
47
- stream.clearLine(0);
48
- } else {
49
- stream.write("\r\x1B[K");
50
- }
51
- }
52
- function clearLines(count, stream = import_node_process.default.stdout) {
53
- for (let i = 0; i < count; i++) {
54
- stream.write("\x1B[1A\x1B[2K");
55
- }
56
- }
57
- function clearScreen(stream = import_node_process.default.stdout) {
58
- if (stream.isTTY) {
59
- stream.write("\x1Bc");
60
- }
61
- }
62
- function clearVisible(stream = import_node_process.default.stdout) {
63
- clearScreen(stream);
64
- }
65
- function cursorToStart(stream = import_node_process.default.stdout) {
66
- if (stream.isTTY) {
67
- stream.cursorTo(0);
68
- } else {
69
- stream.write("\r");
70
- }
71
- }
72
- function hideCursor(stream = import_node_process.default.stdout) {
73
- stream.write("\x1B[?25l");
74
- }
75
- function showCursor(stream = import_node_process.default.stdout) {
76
- stream.write("\x1B[?25h");
77
- }
78
- function saveCursor(stream = import_node_process.default.stdout) {
79
- stream.write("\x1B7");
80
- }
81
- function restoreCursor(stream = import_node_process.default.stdout) {
82
- stream.write("\x1B8");
83
- }
84
- // Annotate the CommonJS export names for ESM import in node:
85
- 0 && (module.exports = {
86
- clearLine,
87
- clearLines,
88
- clearScreen,
89
- clearVisible,
90
- cursorToStart,
91
- hideCursor,
92
- restoreCursor,
93
- saveCursor,
94
- showCursor
95
- });
@@ -1,151 +0,0 @@
1
- import type { ChildProcess, SpawnOptions } from 'child_process';
2
- export interface OutputMaskOptions {
3
- /**
4
- * Current working directory for spawned process.
5
- * @default process.cwd()
6
- */
7
- cwd?: string | undefined;
8
- /**
9
- * Environment variables for spawned process.
10
- * @default process.env
11
- */
12
- env?: NodeJS.ProcessEnv | undefined;
13
- /**
14
- * Filter output before displaying or buffering.
15
- * Return `false` to skip the line, `true` to include it.
16
- *
17
- * Useful for filtering non-fatal warnings or noise from test runners.
18
- * The filter runs on every chunk of output before display/buffering.
19
- *
20
- * @param text - The output text chunk (may include ANSI codes)
21
- * @param stream - Whether this came from 'stdout' or 'stderr'
22
- * @returns `true` to include this output, `false` to skip it
23
- *
24
- * @example
25
- * ```ts
26
- * filterOutput: (text, stream) => {
27
- * // Skip vitest worker termination errors
28
- * if (text.includes('Terminating worker thread')) return false
29
- * return true
30
- * }
31
- * ```
32
- */
33
- filterOutput?: ((text: string, stream: 'stdout' | 'stderr') => boolean) | undefined;
34
- /**
35
- * Progress message to display in spinner.
36
- * @default 'Running…'
37
- */
38
- message?: string | undefined;
39
- /**
40
- * Override the exit code based on captured output.
41
- *
42
- * Useful for handling non-fatal errors that shouldn't fail the build.
43
- * Called after the process exits with the original code and all captured output.
44
- * Return a number to override the exit code, or `undefined` to keep original.
45
- *
46
- * @param code - Original exit code from the process
47
- * @param stdout - All captured stdout (even filtered lines are captured)
48
- * @param stderr - All captured stderr (even filtered lines are captured)
49
- * @returns New exit code, or `undefined` to keep original
50
- *
51
- * @example
52
- * ```ts
53
- * overrideExitCode: (code, stdout, stderr) => {
54
- * // If only worker termination errors, treat as success
55
- * const output = stdout + stderr
56
- * const hasWorkerError = output.includes('Terminating worker thread')
57
- * const hasRealFailure = output.includes('FAIL')
58
- * if (code !== 0 && hasWorkerError && !hasRealFailure) {
59
- * return 0 // Override to success
60
- * }
61
- * return undefined // Keep original
62
- * }
63
- * ```
64
- */
65
- overrideExitCode?: ((code: number, stdout: string, stderr: string) => number | undefined) | undefined;
66
- /**
67
- * Start with output visible instead of masked.
68
- * When `true`, output shows immediately without needing ctrl+o.
69
- * @default false
70
- */
71
- showOutput?: boolean | undefined;
72
- /**
73
- * Text to show after "ctrl+o" in spinner message.
74
- * @default 'to see full output'
75
- */
76
- toggleText?: string | undefined;
77
- }
78
- export interface OutputMask {
79
- /** Whether spinner is currently active */
80
- isSpinning: boolean;
81
- /** Buffered output lines */
82
- outputBuffer: string[];
83
- /** All stderr captured (for exit code override) */
84
- stderrCapture: string;
85
- /** All stdout captured (for exit code override) */
86
- stdoutCapture: string;
87
- /** Whether output is currently visible */
88
- verbose: boolean;
89
- }
90
- /**
91
- * Create an output mask for controlling command output visibility.
92
- * The mask tracks whether output should be shown or hidden (buffered).
93
- * When hidden, output is buffered and a spinner is shown instead.
94
- *
95
- * @example
96
- * ```typescript
97
- * const mask = createOutputMask({ showOutput: false })
98
- * console.log(mask.verbose) // false
99
- * ```
100
- */
101
- export declare function createOutputMask(options?: OutputMaskOptions): OutputMask;
102
- /**
103
- * Create a keyboard handler for toggling output visibility.
104
- * Handles two key combinations:
105
- * - ctrl+o: Toggle between showing and hiding output.
106
- * - ctrl+c: Cancel the running process.
107
- * The handler manipulates terminal state using ANSI escape sequences.
108
- *
109
- * @example
110
- * ```typescript
111
- * const handler = createKeyboardHandler(mask, childProcess, {
112
- * message: 'Testing...',
113
- * })
114
- * ```
115
- */
116
- type ReadlineKey = {
117
- ctrl?: boolean;
118
- name?: string;
119
- };
120
- export declare function createKeyboardHandler(mask: OutputMask, child: ChildProcess, options?: OutputMaskOptions): (_str: string, key: ReadlineKey) => void;
121
- /**
122
- * Attach output masking to a child process.
123
- * Returns a promise that resolves with the exit code.
124
- * This function:
125
- * - Sets up keyboard input handling in raw mode for immediate key capture.
126
- * - Buffers stdout/stderr when not in verbose mode.
127
- * - Shows a spinner when output is masked.
128
- * - Allows toggling between masked and unmasked output with ctrl+o.
129
- *
130
- * @example
131
- * ```typescript
132
- * const child = spawn("pnpm", ["test"], { stdio: ["inherit", "pipe", "pipe"] })
133
- * const exitCode = await attachOutputMask(child, { message: 'Running tests' })
134
- * ```
135
- */
136
- export declare function attachOutputMask(child: ChildProcess, options?: OutputMaskOptions): Promise<number>;
137
- /**
138
- * Run a command with interactive output masking.
139
- * Convenience wrapper around spawn + attachOutputMask.
140
- * Spawns a child process and attaches the output masking system to it.
141
- * stdin is inherited, stdout and stderr are piped for masking control.
142
- *
143
- * @example
144
- * ```typescript
145
- * const exitCode = await runWithMask('pnpm', ['test'], {
146
- * message: 'Running tests',
147
- * })
148
- * ```
149
- */
150
- export declare function runWithMask(command: string, args?: string[], options?: OutputMaskOptions & SpawnOptions): Promise<number>;
151
- export {};
@@ -1,224 +0,0 @@
1
- "use strict";
2
- /* Socket Lib - Built with esbuild */
3
- var __create = Object.create;
4
- var __defProp = Object.defineProperty;
5
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
- var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getProtoOf = Object.getPrototypeOf;
8
- var __hasOwnProp = Object.prototype.hasOwnProperty;
9
- var __export = (target, all) => {
10
- for (var name in all)
11
- __defProp(target, name, { get: all[name], enumerable: true });
12
- };
13
- var __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from === "object" || typeof from === "function") {
15
- for (let key of __getOwnPropNames(from))
16
- if (!__hasOwnProp.call(to, key) && key !== except)
17
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
- }
19
- return to;
20
- };
21
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
- // If the importer is in node compatibility mode or this is not an ESM
23
- // file that has been converted to a CommonJS file using a Babel-
24
- // compatible transform (i.e. "__esModule" has not been set), then set
25
- // "default" to the CommonJS "module.exports" for node compatibility.
26
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
- mod
28
- ));
29
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
- var mask_exports = {};
31
- __export(mask_exports, {
32
- attachOutputMask: () => attachOutputMask,
33
- createKeyboardHandler: () => createKeyboardHandler,
34
- createOutputMask: () => createOutputMask,
35
- runWithMask: () => runWithMask
36
- });
37
- module.exports = __toCommonJS(mask_exports);
38
- var import_node_process = __toESM(require("node:process"));
39
- var import_spinner = require("../spinner.js");
40
- var import_clear = require("./clear.js");
41
- var import_stdout = require("./stdout.js");
42
- let _child_process;
43
- // @__NO_SIDE_EFFECTS__
44
- function getChildProcess() {
45
- if (_child_process === void 0) {
46
- _child_process = require("child_process");
47
- }
48
- return _child_process;
49
- }
50
- let _readline;
51
- // @__NO_SIDE_EFFECTS__
52
- function getReadline() {
53
- if (_readline === void 0) {
54
- _readline = require("readline");
55
- }
56
- return _readline;
57
- }
58
- const spinner = (0, import_spinner.getDefaultSpinner)();
59
- function createOutputMask(options = {}) {
60
- const { showOutput = false } = options;
61
- return {
62
- isSpinning: !showOutput,
63
- outputBuffer: [],
64
- stderrCapture: "",
65
- stdoutCapture: "",
66
- verbose: showOutput
67
- };
68
- }
69
- function createKeyboardHandler(mask, child, options = {}) {
70
- const { message = "Running\u2026", toggleText = "to see full output" } = options;
71
- return (_str, key) => {
72
- if (key?.ctrl && key.name === "o") {
73
- mask.verbose = !mask.verbose;
74
- if (mask.verbose) {
75
- if (mask.isSpinning) {
76
- spinner.stop();
77
- mask.isSpinning = false;
78
- }
79
- (0, import_clear.clearLine)();
80
- if (mask.outputBuffer.length > 0) {
81
- console.log("--- Output (ctrl+o to hide) ---");
82
- mask.outputBuffer.forEach((line) => {
83
- (0, import_stdout.write)(line);
84
- });
85
- }
86
- } else {
87
- if (mask.outputBuffer.length > 0) {
88
- const lineCount = mask.outputBuffer.join("").split("\n").length + 1;
89
- for (let i = 0; i < lineCount; i += 1) {
90
- import_node_process.default.stdout.write("\x1B[1A\x1B[2K");
91
- }
92
- }
93
- (0, import_clear.clearLine)();
94
- mask.outputBuffer = [];
95
- if (!mask.isSpinning) {
96
- spinner.start(`${message} (ctrl+o ${toggleText})`);
97
- mask.isSpinning = true;
98
- }
99
- }
100
- } else if (key?.ctrl && key.name === "c") {
101
- child.kill("SIGTERM");
102
- if (import_node_process.default.stdin.isTTY) {
103
- import_node_process.default.stdin.setRawMode(false);
104
- }
105
- throw new Error("Process cancelled by user");
106
- }
107
- };
108
- }
109
- function attachOutputMask(child, options = {}) {
110
- return new Promise((resolve, reject) => {
111
- const { message = "Running\u2026" } = options;
112
- const mask = createOutputMask(options);
113
- if (mask.isSpinning && import_node_process.default.stdout.isTTY) {
114
- spinner.start(
115
- `${message} (ctrl+o ${options.toggleText || "to see full output"})`
116
- );
117
- }
118
- if (import_node_process.default.stdin.isTTY) {
119
- (/* @__PURE__ */ getReadline()).emitKeypressEvents(import_node_process.default.stdin);
120
- import_node_process.default.stdin.setRawMode(true);
121
- const keypressHandler = createKeyboardHandler(mask, child, options);
122
- import_node_process.default.stdin.on("keypress", keypressHandler);
123
- child.on("exit", () => {
124
- if (import_node_process.default.stdin.isTTY) {
125
- import_node_process.default.stdin.setRawMode(false);
126
- import_node_process.default.stdin.removeListener("keypress", keypressHandler);
127
- }
128
- });
129
- }
130
- if (child.stdout) {
131
- child.stdout.on("data", (data) => {
132
- const text = data.toString();
133
- mask.stdoutCapture += text;
134
- if (options.filterOutput && !options.filterOutput(text, "stdout")) {
135
- return void 0;
136
- }
137
- if (mask.verbose) {
138
- (0, import_stdout.write)(text);
139
- } else {
140
- mask.outputBuffer.push(text);
141
- const lines = mask.outputBuffer.join("").split("\n");
142
- if (lines.length > 1e3) {
143
- mask.outputBuffer = [lines.slice(-1e3).join("\n")];
144
- }
145
- }
146
- return void 0;
147
- });
148
- }
149
- if (child.stderr) {
150
- child.stderr.on("data", (data) => {
151
- const text = data.toString();
152
- mask.stderrCapture += text;
153
- if (options.filterOutput && !options.filterOutput(text, "stderr")) {
154
- return void 0;
155
- }
156
- if (mask.verbose) {
157
- import_node_process.default.stderr.write(text);
158
- } else {
159
- mask.outputBuffer.push(text);
160
- }
161
- return void 0;
162
- });
163
- }
164
- child.on("exit", (code) => {
165
- if (import_node_process.default.stdin.isTTY) {
166
- import_node_process.default.stdin.setRawMode(false);
167
- }
168
- let finalCode = code || 0;
169
- if (options.overrideExitCode) {
170
- const overridden = options.overrideExitCode(
171
- finalCode,
172
- mask.stdoutCapture,
173
- mask.stderrCapture
174
- );
175
- if (overridden !== void 0) {
176
- finalCode = overridden;
177
- }
178
- }
179
- if (mask.isSpinning) {
180
- if (finalCode === 0) {
181
- spinner.successAndStop(`${message} completed`);
182
- } else {
183
- spinner.failAndStop(`${message} failed`);
184
- if (mask.outputBuffer.length > 0 && !mask.verbose) {
185
- console.log("\n--- Output ---");
186
- mask.outputBuffer.forEach((line) => {
187
- (0, import_stdout.write)(line);
188
- });
189
- }
190
- }
191
- }
192
- resolve(finalCode);
193
- });
194
- child.on("error", (error) => {
195
- if (import_node_process.default.stdin.isTTY) {
196
- import_node_process.default.stdin.setRawMode(false);
197
- }
198
- if (mask.isSpinning) {
199
- spinner.failAndStop(`${message} error`);
200
- }
201
- reject(error);
202
- });
203
- });
204
- }
205
- async function runWithMask(command, args = [], options = {}) {
206
- const {
207
- message = "Running\u2026",
208
- showOutput = false,
209
- toggleText = "to see output",
210
- ...spawnOptions
211
- } = options;
212
- const child = (/* @__PURE__ */ getChildProcess()).spawn(command, args, {
213
- stdio: ["inherit", "pipe", "pipe"],
214
- ...spawnOptions
215
- });
216
- return await attachOutputMask(child, { message, showOutput, toggleText });
217
- }
218
- // Annotate the CommonJS export names for ESM import in node:
219
- 0 && (module.exports = {
220
- attachOutputMask,
221
- createKeyboardHandler,
222
- createOutputMask,
223
- runWithMask
224
- });