@socketsecurity/lib 5.18.1 → 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 +49 -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 -70
  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,148 +0,0 @@
1
- export interface ProgressBarOptions {
2
- /**
3
- * Width of the progress bar in characters.
4
- * @default 40
5
- */
6
- width?: number | undefined;
7
- /**
8
- * Format template for progress bar display.
9
- * Available tokens: `:bar`, `:percent`, `:current`, `:total`, `:elapsed`, `:eta`.
10
- * Custom tokens can be passed via the `tokens` parameter in `update()` or `tick()`.
11
- * @default ':bar :percent :current/:total'
12
- * @example
13
- * ```ts
14
- * format: ':bar :percent :current/:total :eta'
15
- * ```
16
- */
17
- format?: string | undefined;
18
- /**
19
- * Character(s) to use for completed portion of bar.
20
- * @default '█'
21
- */
22
- complete?: string | undefined;
23
- /**
24
- * Character(s) to use for incomplete portion of bar.
25
- * @default '░'
26
- */
27
- incomplete?: string | undefined;
28
- /**
29
- * Character(s) to use for the head of the progress bar.
30
- * @default ''
31
- */
32
- head?: string | undefined;
33
- /**
34
- * Clear the progress bar when complete.
35
- * @default false
36
- */
37
- clear?: boolean | undefined;
38
- /**
39
- * Minimum time between renders in milliseconds.
40
- * ~60fps = 16ms throttle.
41
- * @default 16
42
- */
43
- renderThrottle?: number | undefined;
44
- /**
45
- * Stream to write progress bar output to.
46
- * @default process.stderr
47
- */
48
- stream?: NodeJS.WriteStream | undefined;
49
- /**
50
- * Color to apply to the completed portion of the bar.
51
- * @default 'cyan'
52
- */
53
- color?: 'cyan' | 'green' | 'yellow' | 'blue' | 'magenta' | undefined;
54
- }
55
- export declare class ProgressBar {
56
- private current;
57
- private total;
58
- private startTime;
59
- private lastRender;
60
- private stream;
61
- private options;
62
- private terminated;
63
- private lastDrawnWidth;
64
- /**
65
- * Create a new progress bar instance.
66
- *
67
- * @param total - Total number of units for the progress bar
68
- * @param options - Configuration options for the progress bar
69
- *
70
- * @example
71
- * ```ts
72
- * const bar = new ProgressBar(100, {
73
- * width: 50,
74
- * format: ':bar :percent :current/:total :eta',
75
- * color: 'green'
76
- * })
77
- * ```
78
- */
79
- constructor(total: number, options?: ProgressBarOptions);
80
- /**
81
- * Update progress to a specific value and redraw the bar.
82
- * Updates are throttled to prevent excessive rendering (default ~60fps).
83
- *
84
- * @param current - Current progress value (will be clamped to total)
85
- * @param tokens - Optional custom tokens to replace in format string
86
- *
87
- * @example
88
- * ```ts
89
- * bar.update(50)
90
- * bar.update(75, { status: 'Processing...' })
91
- * ```
92
- */
93
- update(current: number, tokens?: Record<string, unknown>): void;
94
- /**
95
- * Increment progress by a specified amount.
96
- * Convenience method for `update(current + amount)`.
97
- *
98
- * @param amount - Amount to increment by
99
- * @param tokens - Optional custom tokens to replace in format string
100
- * @default amount 1
101
- *
102
- * @example
103
- * ```ts
104
- * bar.tick() // Increment by 1
105
- * bar.tick(5) // Increment by 5
106
- * bar.tick(1, { file: 'data.json' })
107
- * ```
108
- */
109
- tick(amount?: number, tokens?: Record<string, unknown>): void;
110
- /**
111
- * Render the progress bar.
112
- */
113
- private render;
114
- /**
115
- * Clear the current line.
116
- */
117
- private clearLine;
118
- /**
119
- * Format time in seconds to human readable.
120
- */
121
- private formatTime;
122
- /**
123
- * Terminate the progress bar and optionally clear it.
124
- * Called automatically when progress reaches 100%.
125
- * If `clear` option is true, removes the bar from terminal.
126
- * Otherwise, moves to next line to preserve the final state.
127
- */
128
- terminate(): void;
129
- }
130
- /**
131
- * Create a simple progress indicator without a graphical bar.
132
- * Returns a formatted string showing progress as percentage and fraction.
133
- *
134
- * @param current - Current progress value
135
- * @param total - Total progress value
136
- * @param label - Optional label prefix
137
- * @returns Formatted progress indicator string
138
- *
139
- * @example
140
- * ```ts
141
- * createProgressIndicator(50, 100)
142
- * // Returns: '[50%] 50/100'
143
- *
144
- * createProgressIndicator(3, 10, 'Files')
145
- * // Returns: 'Files: [30%] 3/10'
146
- * ```
147
- */
148
- export declare function createProgressIndicator(current: number, total: number, label?: string | undefined): string;
@@ -1,212 +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 progress_exports = {};
31
- __export(progress_exports, {
32
- ProgressBar: () => ProgressBar,
33
- createProgressIndicator: () => createProgressIndicator
34
- });
35
- module.exports = __toCommonJS(progress_exports);
36
- var import_node_process = __toESM(require("node:process"));
37
- var import_yoctocolors_cjs = __toESM(require("../external/yoctocolors-cjs"));
38
- var import_strings = require("../strings");
39
- class ProgressBar {
40
- current = 0;
41
- total;
42
- startTime;
43
- lastRender = 0;
44
- stream;
45
- options;
46
- terminated = false;
47
- lastDrawnWidth = 0;
48
- /**
49
- * Create a new progress bar instance.
50
- *
51
- * @param total - Total number of units for the progress bar
52
- * @param options - Configuration options for the progress bar
53
- *
54
- * @example
55
- * ```ts
56
- * const bar = new ProgressBar(100, {
57
- * width: 50,
58
- * format: ':bar :percent :current/:total :eta',
59
- * color: 'green'
60
- * })
61
- * ```
62
- */
63
- constructor(total, options) {
64
- this.total = total;
65
- this.startTime = Date.now();
66
- this.stream = options?.stream || import_node_process.default.stderr;
67
- this.options = {
68
- width: 40,
69
- format: ":bar :percent :current/:total",
70
- complete: "\u2588",
71
- incomplete: "\u2591",
72
- head: "",
73
- clear: false,
74
- // ~60fps.
75
- renderThrottle: 16,
76
- stream: this.stream,
77
- color: "cyan",
78
- ...options
79
- };
80
- }
81
- /**
82
- * Update progress to a specific value and redraw the bar.
83
- * Updates are throttled to prevent excessive rendering (default ~60fps).
84
- *
85
- * @param current - Current progress value (will be clamped to total)
86
- * @param tokens - Optional custom tokens to replace in format string
87
- *
88
- * @example
89
- * ```ts
90
- * bar.update(50)
91
- * bar.update(75, { status: 'Processing...' })
92
- * ```
93
- */
94
- update(current, tokens) {
95
- if (this.terminated) {
96
- return;
97
- }
98
- this.current = Math.min(current, this.total);
99
- const now = Date.now();
100
- if (now - this.lastRender < this.options.renderThrottle && this.current < this.total) {
101
- return;
102
- }
103
- this.lastRender = now;
104
- this.render(tokens);
105
- if (this.current >= this.total) {
106
- this.terminate();
107
- }
108
- }
109
- /**
110
- * Increment progress by a specified amount.
111
- * Convenience method for `update(current + amount)`.
112
- *
113
- * @param amount - Amount to increment by
114
- * @param tokens - Optional custom tokens to replace in format string
115
- * @default amount 1
116
- *
117
- * @example
118
- * ```ts
119
- * bar.tick() // Increment by 1
120
- * bar.tick(5) // Increment by 5
121
- * bar.tick(1, { file: 'data.json' })
122
- * ```
123
- */
124
- tick(amount = 1, tokens) {
125
- this.update(this.current + amount, tokens);
126
- }
127
- /**
128
- * Render the progress bar.
129
- */
130
- render(tokens) {
131
- const colorFn = import_yoctocolors_cjs.default[this.options.color] || ((s) => s);
132
- const percent = this.total === 0 ? 0 : Math.floor(this.current / this.total * 100);
133
- const elapsed = Date.now() - this.startTime;
134
- const eta = this.current === 0 ? 0 : elapsed / this.current * (this.total - this.current);
135
- const availableWidth = this.options.width;
136
- const filledWidth = this.total === 0 ? 0 : Math.floor(this.current / this.total * availableWidth);
137
- const emptyWidth = availableWidth - filledWidth;
138
- const filled = (0, import_strings.repeatString)(this.options.complete, filledWidth);
139
- const empty = (0, import_strings.repeatString)(this.options.incomplete, emptyWidth);
140
- const bar = colorFn(filled) + empty;
141
- let output = this.options.format;
142
- output = output.replace(":bar", bar);
143
- output = output.replace(":percent", `${percent}%`);
144
- output = output.replace(":current", String(this.current));
145
- output = output.replace(":total", String(this.total));
146
- output = output.replace(":elapsed", this.formatTime(elapsed));
147
- output = output.replace(":eta", this.formatTime(eta));
148
- if (tokens) {
149
- for (const [key, value] of Object.entries(tokens)) {
150
- output = output.replace(`:${key}`, String(value));
151
- }
152
- }
153
- this.clearLine();
154
- this.stream.write(output);
155
- this.lastDrawnWidth = (0, import_strings.stripAnsi)(output).length;
156
- }
157
- /**
158
- * Clear the current line.
159
- */
160
- clearLine() {
161
- if (this.stream.isTTY) {
162
- this.stream.cursorTo(0);
163
- this.stream.clearLine(0);
164
- } else if (this.lastDrawnWidth > 0) {
165
- this.stream.write(`\r${(0, import_strings.repeatString)(" ", this.lastDrawnWidth)}\r`);
166
- }
167
- }
168
- /**
169
- * Format time in seconds to human readable.
170
- */
171
- formatTime(ms) {
172
- const seconds = Math.round(ms / 1e3);
173
- if (seconds < 60) {
174
- return `${seconds}s`;
175
- }
176
- const minutes = Math.floor(seconds / 60);
177
- const remainingSeconds = seconds % 60;
178
- return `${minutes}m${remainingSeconds}s`;
179
- }
180
- /**
181
- * Terminate the progress bar and optionally clear it.
182
- * Called automatically when progress reaches 100%.
183
- * If `clear` option is true, removes the bar from terminal.
184
- * Otherwise, moves to next line to preserve the final state.
185
- */
186
- terminate() {
187
- if (this.terminated) {
188
- return;
189
- }
190
- this.terminated = true;
191
- if (this.options.clear) {
192
- this.clearLine();
193
- } else {
194
- this.stream.write("\n");
195
- }
196
- }
197
- }
198
- function createProgressIndicator(current, total, label) {
199
- const percent = total === 0 ? 0 : Math.floor(current / total * 100);
200
- const progress = `${current}/${total}`;
201
- let output = "";
202
- if (label) {
203
- output += `${label}: `;
204
- }
205
- output += `${import_yoctocolors_cjs.default.cyan(`[${percent}%]`)} ${progress}`;
206
- return output;
207
- }
208
- // Annotate the CommonJS export names for ESM import in node:
209
- 0 && (module.exports = {
210
- ProgressBar,
211
- createProgressIndicator
212
- });
@@ -1,195 +0,0 @@
1
- import checkboxRaw from '../external/@inquirer/checkbox';
2
- import confirmRaw from '../external/@inquirer/confirm';
3
- import inputRaw from '../external/@inquirer/input';
4
- import passwordRaw from '../external/@inquirer/password';
5
- import { type ThemeName } from '../themes/themes';
6
- import type { Theme } from '../themes/types';
7
- // Modules imported at the top - extract default and Separator
8
- declare const searchRaw: any;
9
- declare const selectRaw: any;
10
- declare const ActualSeparator: any;
11
- // Type definitions
12
- /**
13
- * Choice option for select and search prompts.
14
- *
15
- * @template Value - Type of the choice value
16
- */
17
- export interface Choice<Value = unknown> {
18
- /** The value returned when this choice is selected */
19
- value: Value;
20
- /** Display name for the choice (defaults to value.toString()) */
21
- name?: string | undefined;
22
- /** Additional description text shown below the choice */
23
- description?: string | undefined;
24
- /** Short text shown after selection (defaults to name) */
25
- short?: string | undefined;
26
- /** Whether this choice is disabled, or a reason string */
27
- disabled?: boolean | string | undefined;
28
- }
29
- /**
30
- * Context for inquirer prompts.
31
- * Minimal context interface used by Inquirer prompts.
32
- * Duplicated from `@inquirer/type` - InquirerContext.
33
- */
34
- interface InquirerContext {
35
- /** Abort signal for cancelling the prompt */
36
- signal?: AbortSignal | undefined;
37
- /** Input stream (defaults to process.stdin) */
38
- input?: NodeJS.ReadableStream | undefined;
39
- /** Output stream (defaults to process.stdout) */
40
- output?: NodeJS.WritableStream | undefined;
41
- /** Clear the prompt from terminal when done */
42
- clearPromptOnDone?: boolean | undefined;
43
- }
44
- /**
45
- * Extended context with spinner support.
46
- * Allows passing a spinner instance to be managed during prompts.
47
- */
48
- export type Context = import('../objects').Remap<InquirerContext & {
49
- /** Optional spinner to stop/start during prompt display */
50
- spinner?: import('../spinner').Spinner | undefined;
51
- }>;
52
- /**
53
- * Separator for visual grouping in select/checkbox prompts.
54
- * Creates a non-selectable visual separator line.
55
- * Duplicated from `@inquirer/select` - Separator.
56
- * This type definition ensures the Separator type is available in published packages.
57
- *
58
- * @example
59
- * import { Separator } from './prompts'
60
- *
61
- * const choices = [
62
- * { name: 'Option 1', value: 1 },
63
- * new Separator(),
64
- * { name: 'Option 2', value: 2 }
65
- * ]
66
- */
67
- declare class SeparatorType {
68
- readonly separator: string;
69
- readonly type: 'separator';
70
- constructor(separator?: string);
71
- }
72
- export type Separator = SeparatorType;
73
- /**
74
- * Convert Socket theme to @inquirer theme format.
75
- * Maps our theme colors to inquirer's style functions.
76
- * Handles theme names, Theme objects, and passes through @inquirer themes.
77
- *
78
- * @param theme - Socket theme name, Theme object, or @inquirer theme
79
- * @returns @inquirer theme object
80
- *
81
- * @example
82
- * ```ts
83
- * // Socket theme name
84
- * createInquirerTheme('sunset')
85
- *
86
- * // Socket Theme object
87
- * createInquirerTheme(SUNSET_THEME)
88
- *
89
- * // @inquirer theme (passes through)
90
- * createInquirerTheme({ style: {...}, icon: {...} })
91
- * ```
92
- */
93
- export declare function createInquirerTheme(theme: Theme | ThemeName | unknown): Record<string, unknown>;
94
- /**
95
- * Wrap an inquirer prompt with spinner handling, theme injection, and signal injection.
96
- * Automatically stops/starts spinners during prompt display, injects the current theme,
97
- * and injects abort signals. Trims string results and handles cancellation gracefully.
98
- *
99
- * @template T - Type of the prompt result
100
- * @param inquirerPrompt - The inquirer prompt function to wrap
101
- * @returns Wrapped prompt function with spinner, theme, and signal handling
102
- *
103
- * @example
104
- * const myPrompt = wrapPrompt(rawInquirerPrompt)
105
- * const result = await myPrompt({ message: 'Enter name:' })
106
- */
107
- /*@__NO_SIDE_EFFECTS__*/
108
- export declare function wrapPrompt<T = unknown>(inquirerPrompt: (...args: unknown[]) => Promise<T>): (...args: unknown[]) => Promise<T | undefined>;
109
- /**
110
- * Prompt to select multiple items from a list of choices.
111
- * Wrapped with spinner handling and abort signal support.
112
- *
113
- * @example
114
- * const choices = await checkbox({
115
- * message: 'Select options:',
116
- * choices: [
117
- * { name: 'Option 1', value: 'opt1' },
118
- * { name: 'Option 2', value: 'opt2' },
119
- * { name: 'Option 3', value: 'opt3' }
120
- * ]
121
- * })
122
- */
123
- export declare const checkbox: typeof checkboxRaw;
124
- /**
125
- * Prompt for a yes/no confirmation.
126
- * Wrapped with spinner handling and abort signal support.
127
- *
128
- * @example
129
- * const answer = await confirm({ message: 'Continue?' })
130
- * if (answer) { // user confirmed }
131
- */
132
- export declare const confirm: typeof confirmRaw;
133
- /**
134
- * Prompt for text input.
135
- * Wrapped with spinner handling and abort signal support.
136
- * Result is automatically trimmed.
137
- *
138
- * @example
139
- * const name = await input({ message: 'Enter your name:' })
140
- */
141
- export declare const input: typeof inputRaw;
142
- /**
143
- * Prompt for password input (hidden characters).
144
- * Wrapped with spinner handling and abort signal support.
145
- *
146
- * @example
147
- * const token = await password({ message: 'Enter API token:' })
148
- */
149
- export declare const password: typeof passwordRaw;
150
- /**
151
- * Prompt with searchable/filterable choices.
152
- * Wrapped with spinner handling and abort signal support.
153
- *
154
- * @example
155
- * const result = await search({
156
- * message: 'Select a package:',
157
- * source: async (input) => fetchPackages(input)
158
- * })
159
- */
160
- export declare const search: typeof searchRaw;
161
- /**
162
- * Prompt to select from a list of choices.
163
- * Wrapped with spinner handling and abort signal support.
164
- *
165
- * @example
166
- * const choice = await select({
167
- * message: 'Choose an option:',
168
- * choices: [
169
- * { name: 'Option 1', value: 'opt1' },
170
- * { name: 'Option 2', value: 'opt2' }
171
- * ]
172
- * })
173
- */
174
- export declare const select: typeof selectRaw;
175
- export { ActualSeparator as Separator };
176
- /**
177
- * Create a separator for select prompts.
178
- * Creates a visual separator line in choice lists.
179
- *
180
- * @param text - Optional separator text (defaults to '───────')
181
- * @returns Separator instance
182
- *
183
- * @example
184
- * import { select, createSeparator } from '@socketsecurity/lib/stdio/prompts'
185
- *
186
- * const choice = await select({
187
- * message: 'Choose an option:',
188
- * choices: [
189
- * { name: 'Option 1', value: 1 },
190
- * createSeparator(),
191
- * { name: 'Option 2', value: 2 }
192
- * ]
193
- * })
194
- */
195
- export declare function createSeparator(text?: string): InstanceType<typeof ActualSeparator>;