@socketsecurity/lib 1.0.4 → 1.1.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 (80) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/dist/abort.js.map +2 -2
  3. package/dist/argv/parse.js.map +2 -2
  4. package/dist/arrays.d.ts +143 -0
  5. package/dist/arrays.js.map +2 -2
  6. package/dist/bin.js +1 -4
  7. package/dist/bin.js.map +2 -2
  8. package/dist/cacache.d.ts +0 -2
  9. package/dist/cacache.js +0 -1
  10. package/dist/cacache.js.map +2 -2
  11. package/dist/cache-with-ttl.js.map +2 -2
  12. package/dist/dlx.js.map +2 -2
  13. package/dist/external/@yarnpkg/extensions.d.ts +0 -1
  14. package/dist/external/cacache.d.ts +0 -7
  15. package/dist/external/debug.d.ts +0 -3
  16. package/dist/external/fast-sort.d.ts +0 -1
  17. package/dist/external/libnpmpack.d.ts +0 -1
  18. package/dist/external/make-fetch-happen.d.ts +0 -1
  19. package/dist/external/pacote.d.ts +0 -5
  20. package/dist/external/semver.d.ts +0 -1
  21. package/dist/external/validate-npm-package-name.js +1 -1
  22. package/dist/external/yargs-parser.d.ts +0 -1
  23. package/dist/external/yoctocolors-cjs.js +1 -1
  24. package/dist/external/zod.js +9 -9
  25. package/dist/fs.d.ts +595 -23
  26. package/dist/fs.js.map +2 -2
  27. package/dist/git.d.ts +488 -41
  28. package/dist/git.js.map +2 -2
  29. package/dist/github.d.ts +361 -12
  30. package/dist/github.js.map +2 -2
  31. package/dist/http-request.d.ts +463 -4
  32. package/dist/http-request.js.map +2 -2
  33. package/dist/json.d.ts +177 -4
  34. package/dist/json.js.map +2 -2
  35. package/dist/logger.d.ts +823 -70
  36. package/dist/logger.js +654 -51
  37. package/dist/logger.js.map +2 -2
  38. package/dist/objects.d.ts +386 -10
  39. package/dist/objects.js.map +2 -2
  40. package/dist/path.d.ts +270 -6
  41. package/dist/path.js.map +2 -2
  42. package/dist/promises.d.ts +432 -27
  43. package/dist/promises.js +3 -0
  44. package/dist/promises.js.map +2 -2
  45. package/dist/signal-exit.js.map +2 -2
  46. package/dist/sorts.js.map +2 -2
  47. package/dist/spawn.d.ts +242 -33
  48. package/dist/spawn.js.map +2 -2
  49. package/dist/spinner.d.ts +260 -20
  50. package/dist/spinner.js +201 -63
  51. package/dist/spinner.js.map +2 -2
  52. package/dist/stdio/clear.d.ts +130 -9
  53. package/dist/stdio/clear.js.map +2 -2
  54. package/dist/stdio/divider.d.ts +106 -10
  55. package/dist/stdio/divider.js +10 -0
  56. package/dist/stdio/divider.js.map +2 -2
  57. package/dist/stdio/footer.d.ts +70 -3
  58. package/dist/stdio/footer.js.map +2 -2
  59. package/dist/stdio/header.d.ts +93 -12
  60. package/dist/stdio/header.js.map +2 -2
  61. package/dist/stdio/mask.d.ts +82 -14
  62. package/dist/stdio/mask.js +25 -4
  63. package/dist/stdio/mask.js.map +2 -2
  64. package/dist/stdio/progress.d.ts +112 -15
  65. package/dist/stdio/progress.js +43 -3
  66. package/dist/stdio/progress.js.map +2 -2
  67. package/dist/stdio/prompts.d.ts +95 -5
  68. package/dist/stdio/prompts.js.map +2 -2
  69. package/dist/stdio/stderr.d.ts +114 -11
  70. package/dist/stdio/stderr.js.map +2 -2
  71. package/dist/stdio/stdout.d.ts +107 -11
  72. package/dist/stdio/stdout.js.map +2 -2
  73. package/dist/strings.d.ts +357 -28
  74. package/dist/strings.js.map +2 -2
  75. package/dist/suppress-warnings.js.map +2 -2
  76. package/dist/validation/json-parser.d.ts +226 -7
  77. package/dist/validation/json-parser.js.map +2 -2
  78. package/dist/validation/types.d.ts +114 -12
  79. package/dist/validation/types.js.map +1 -1
  80. package/package.json +5 -3
@@ -1,14 +1,56 @@
1
1
  export interface ProgressBarOptions {
2
- width?: number;
3
- // Template: ':bar :percent :current/:total :eta'.
4
- format?: string;
5
- complete?: string;
6
- incomplete?: string;
7
- head?: string;
8
- clear?: boolean;
9
- renderThrottle?: number;
10
- stream?: NodeJS.WriteStream;
11
- color?: 'cyan' | 'green' | 'yellow' | 'blue' | 'magenta';
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;
12
54
  }
13
55
  export declare class ProgressBar {
14
56
  private current;
@@ -19,13 +61,50 @@ export declare class ProgressBar {
19
61
  private options;
20
62
  private terminated;
21
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
+ */
22
79
  constructor(total: number, options?: ProgressBarOptions);
23
80
  /**
24
- * Update progress and redraw bar.
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
+ * ```
25
92
  */
26
93
  update(current: number, tokens?: Record<string, unknown>): void;
27
94
  /**
28
- * Increment progress by amount.
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
+ * ```
29
108
  */
30
109
  tick(amount?: number, tokens?: Record<string, unknown>): void;
31
110
  /**
@@ -41,11 +120,29 @@ export declare class ProgressBar {
41
120
  */
42
121
  private formatTime;
43
122
  /**
44
- * Terminate the progress bar.
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.
45
127
  */
46
128
  terminate(): void;
47
129
  }
48
130
  /**
49
- * Create a simple progress indicator without a bar.
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
+ * ```
50
147
  */
51
- export declare function createProgressIndicator(current: number, total: number, label?: string): string;
148
+ export declare function createProgressIndicator(current: number, total: number, label?: string | undefined): string;
@@ -43,6 +43,21 @@ class ProgressBar {
43
43
  options;
44
44
  terminated = false;
45
45
  lastDrawnWidth = 0;
46
+ /**
47
+ * Create a new progress bar instance.
48
+ *
49
+ * @param total - Total number of units for the progress bar
50
+ * @param options - Configuration options for the progress bar
51
+ *
52
+ * @example
53
+ * ```ts
54
+ * const bar = new ProgressBar(100, {
55
+ * width: 50,
56
+ * format: ':bar :percent :current/:total :eta',
57
+ * color: 'green'
58
+ * })
59
+ * ```
60
+ */
46
61
  constructor(total, options) {
47
62
  this.total = total;
48
63
  this.startTime = Date.now();
@@ -62,7 +77,17 @@ class ProgressBar {
62
77
  };
63
78
  }
64
79
  /**
65
- * Update progress and redraw bar.
80
+ * Update progress to a specific value and redraw the bar.
81
+ * Updates are throttled to prevent excessive rendering (default ~60fps).
82
+ *
83
+ * @param current - Current progress value (will be clamped to total)
84
+ * @param tokens - Optional custom tokens to replace in format string
85
+ *
86
+ * @example
87
+ * ```ts
88
+ * bar.update(50)
89
+ * bar.update(75, { status: 'Processing...' })
90
+ * ```
66
91
  */
67
92
  update(current, tokens) {
68
93
  if (this.terminated) {
@@ -80,7 +105,19 @@ class ProgressBar {
80
105
  }
81
106
  }
82
107
  /**
83
- * Increment progress by amount.
108
+ * Increment progress by a specified amount.
109
+ * Convenience method for `update(current + amount)`.
110
+ *
111
+ * @param amount - Amount to increment by
112
+ * @param tokens - Optional custom tokens to replace in format string
113
+ * @default amount 1
114
+ *
115
+ * @example
116
+ * ```ts
117
+ * bar.tick() // Increment by 1
118
+ * bar.tick(5) // Increment by 5
119
+ * bar.tick(1, { file: 'data.json' })
120
+ * ```
84
121
  */
85
122
  tick(amount = 1, tokens) {
86
123
  this.update(this.current + amount, tokens);
@@ -139,7 +176,10 @@ class ProgressBar {
139
176
  return `${minutes}m${remainingSeconds}s`;
140
177
  }
141
178
  /**
142
- * Terminate the progress bar.
179
+ * Terminate the progress bar and optionally clear it.
180
+ * Called automatically when progress reaches 100%.
181
+ * If `clear` option is true, removes the bar from terminal.
182
+ * Otherwise, moves to next line to preserve the final state.
143
183
  */
144
184
  terminate() {
145
185
  if (this.terminated) {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/stdio/progress.ts"],
4
- "sourcesContent": ["/**\n * Progress bar utilities for CLI applications.\n * Provides various progress indicators including bars, percentages, and spinners.\n */\n\nimport colors from '../external/yoctocolors-cjs'\nimport { repeatString, stripAnsi } from '../strings'\n\nexport interface ProgressBarOptions {\n width?: number\n // Template: ':bar :percent :current/:total :eta'.\n format?: string\n complete?: string\n incomplete?: string\n head?: string\n clear?: boolean\n renderThrottle?: number\n stream?: NodeJS.WriteStream\n color?: 'cyan' | 'green' | 'yellow' | 'blue' | 'magenta'\n}\n\nexport class ProgressBar {\n private current: number = 0\n private total: number\n private startTime: number\n private lastRender: number = 0\n private stream: NodeJS.WriteStream\n private options: Required<ProgressBarOptions>\n private terminated: boolean = false\n private lastDrawnWidth: number = 0\n\n constructor(total: number, options?: ProgressBarOptions) {\n this.total = total\n this.startTime = Date.now()\n this.stream = options?.stream || process.stderr\n this.options = {\n width: 40,\n format: ':bar :percent :current/:total',\n complete: '\u2588',\n incomplete: '\u2591',\n head: '',\n clear: false,\n // ~60fps.\n renderThrottle: 16,\n stream: this.stream,\n color: 'cyan',\n ...options,\n }\n }\n\n /**\n * Update progress and redraw bar.\n */\n update(current: number, tokens?: Record<string, unknown>): void {\n if (this.terminated) {\n return\n }\n\n this.current = Math.min(current, this.total)\n\n // Throttle rendering\n const now = Date.now()\n if (\n now - this.lastRender < this.options.renderThrottle &&\n this.current < this.total\n ) {\n return\n }\n this.lastRender = now\n\n this.render(tokens)\n\n if (this.current >= this.total) {\n this.terminate()\n }\n }\n\n /**\n * Increment progress by amount.\n */\n tick(amount: number = 1, tokens?: Record<string, unknown>): void {\n this.update(this.current + amount, tokens)\n }\n\n /**\n * Render the progress bar.\n */\n private render(tokens?: Record<string, unknown>): void {\n const colorFn = colors[this.options.color] || ((s: string) => s)\n\n // Calculate values\n const percent = Math.floor((this.current / this.total) * 100)\n const elapsed = Date.now() - this.startTime\n const eta =\n this.current === 0\n ? 0\n : (elapsed / this.current) * (this.total - this.current)\n\n // Build bar\n const availableWidth = this.options.width\n const filledWidth = Math.floor((this.current / this.total) * availableWidth)\n const emptyWidth = availableWidth - filledWidth\n\n const filled = repeatString(this.options.complete, filledWidth)\n const empty = repeatString(this.options.incomplete, emptyWidth)\n const bar = colorFn(filled) + empty\n\n // Format output\n let output = this.options.format\n output = output.replace(':bar', bar)\n output = output.replace(':percent', `${percent}%`)\n output = output.replace(':current', String(this.current))\n output = output.replace(':total', String(this.total))\n output = output.replace(':elapsed', this.formatTime(elapsed))\n output = output.replace(':eta', this.formatTime(eta))\n\n // Replace custom tokens\n if (tokens) {\n for (const [key, value] of Object.entries(tokens)) {\n output = output.replace(`:${key}`, String(value))\n }\n }\n\n // Clear line and write\n this.clearLine()\n this.stream.write(output)\n this.lastDrawnWidth = stripAnsi(output).length\n }\n\n /**\n * Clear the current line.\n */\n private clearLine(): void {\n if (this.stream.isTTY) {\n this.stream.cursorTo(0)\n this.stream.clearLine(0)\n } else if (this.lastDrawnWidth > 0) {\n this.stream.write(`\\r${repeatString(' ', this.lastDrawnWidth)}\\r`)\n }\n }\n\n /**\n * Format time in seconds to human readable.\n */\n private formatTime(ms: number): string {\n const seconds = Math.round(ms / 1000)\n if (seconds < 60) {\n return `${seconds}s`\n }\n const minutes = Math.floor(seconds / 60)\n const remainingSeconds = seconds % 60\n return `${minutes}m${remainingSeconds}s`\n }\n\n /**\n * Terminate the progress bar.\n */\n terminate(): void {\n if (this.terminated) {\n return\n }\n this.terminated = true\n\n if (this.options.clear) {\n this.clearLine()\n } else {\n this.stream.write('\\n')\n }\n }\n}\n\n/**\n * Create a simple progress indicator without a bar.\n */\nexport function createProgressIndicator(\n current: number,\n total: number,\n label?: string,\n): string {\n const percent = Math.floor((current / total) * 100)\n const progress = `${current}/${total}`\n\n let output = ''\n if (label) {\n output += `${label}: `\n }\n\n output += `${colors.cyan(`[${percent}%]`)} ${progress}`\n\n return output\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,6BAAmB;AACnB,qBAAwC;AAejC,MAAM,YAAY;AAAA,EACf,UAAkB;AAAA,EAClB;AAAA,EACA;AAAA,EACA,aAAqB;AAAA,EACrB;AAAA,EACA;AAAA,EACA,aAAsB;AAAA,EACtB,iBAAyB;AAAA,EAEjC,YAAY,OAAe,SAA8B;AACvD,SAAK,QAAQ;AACb,SAAK,YAAY,KAAK,IAAI;AAC1B,SAAK,SAAS,SAAS,UAAU,QAAQ;AACzC,SAAK,UAAU;AAAA,MACb,OAAO;AAAA,MACP,QAAQ;AAAA,MACR,UAAU;AAAA,MACV,YAAY;AAAA,MACZ,MAAM;AAAA,MACN,OAAO;AAAA;AAAA,MAEP,gBAAgB;AAAA,MAChB,QAAQ,KAAK;AAAA,MACb,OAAO;AAAA,MACP,GAAG;AAAA,IACL;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,SAAiB,QAAwC;AAC9D,QAAI,KAAK,YAAY;AACnB;AAAA,IACF;AAEA,SAAK,UAAU,KAAK,IAAI,SAAS,KAAK,KAAK;AAG3C,UAAM,MAAM,KAAK,IAAI;AACrB,QACE,MAAM,KAAK,aAAa,KAAK,QAAQ,kBACrC,KAAK,UAAU,KAAK,OACpB;AACA;AAAA,IACF;AACA,SAAK,aAAa;AAElB,SAAK,OAAO,MAAM;AAElB,QAAI,KAAK,WAAW,KAAK,OAAO;AAC9B,WAAK,UAAU;AAAA,IACjB;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,KAAK,SAAiB,GAAG,QAAwC;AAC/D,SAAK,OAAO,KAAK,UAAU,QAAQ,MAAM;AAAA,EAC3C;AAAA;AAAA;AAAA;AAAA,EAKQ,OAAO,QAAwC;AACrD,UAAM,UAAU,uBAAAA,QAAO,KAAK,QAAQ,KAAK,MAAM,CAAC,MAAc;AAG9D,UAAM,UAAU,KAAK,MAAO,KAAK,UAAU,KAAK,QAAS,GAAG;AAC5D,UAAM,UAAU,KAAK,IAAI,IAAI,KAAK;AAClC,UAAM,MACJ,KAAK,YAAY,IACb,IACC,UAAU,KAAK,WAAY,KAAK,QAAQ,KAAK;AAGpD,UAAM,iBAAiB,KAAK,QAAQ;AACpC,UAAM,cAAc,KAAK,MAAO,KAAK,UAAU,KAAK,QAAS,cAAc;AAC3E,UAAM,aAAa,iBAAiB;AAEpC,UAAM,aAAS,6BAAa,KAAK,QAAQ,UAAU,WAAW;AAC9D,UAAM,YAAQ,6BAAa,KAAK,QAAQ,YAAY,UAAU;AAC9D,UAAM,MAAM,QAAQ,MAAM,IAAI;AAG9B,QAAI,SAAS,KAAK,QAAQ;AAC1B,aAAS,OAAO,QAAQ,QAAQ,GAAG;AACnC,aAAS,OAAO,QAAQ,YAAY,GAAG,OAAO,GAAG;AACjD,aAAS,OAAO,QAAQ,YAAY,OAAO,KAAK,OAAO,CAAC;AACxD,aAAS,OAAO,QAAQ,UAAU,OAAO,KAAK,KAAK,CAAC;AACpD,aAAS,OAAO,QAAQ,YAAY,KAAK,WAAW,OAAO,CAAC;AAC5D,aAAS,OAAO,QAAQ,QAAQ,KAAK,WAAW,GAAG,CAAC;AAGpD,QAAI,QAAQ;AACV,iBAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,MAAM,GAAG;AACjD,iBAAS,OAAO,QAAQ,IAAI,GAAG,IAAI,OAAO,KAAK,CAAC;AAAA,MAClD;AAAA,IACF;AAGA,SAAK,UAAU;AACf,SAAK,OAAO,MAAM,MAAM;AACxB,SAAK,qBAAiB,0BAAU,MAAM,EAAE;AAAA,EAC1C;AAAA;AAAA;AAAA;AAAA,EAKQ,YAAkB;AACxB,QAAI,KAAK,OAAO,OAAO;AACrB,WAAK,OAAO,SAAS,CAAC;AACtB,WAAK,OAAO,UAAU,CAAC;AAAA,IACzB,WAAW,KAAK,iBAAiB,GAAG;AAClC,WAAK,OAAO,MAAM,SAAK,6BAAa,KAAK,KAAK,cAAc,CAAC,IAAI;AAAA,IACnE;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKQ,WAAW,IAAoB;AACrC,UAAM,UAAU,KAAK,MAAM,KAAK,GAAI;AACpC,QAAI,UAAU,IAAI;AAChB,aAAO,GAAG,OAAO;AAAA,IACnB;AACA,UAAM,UAAU,KAAK,MAAM,UAAU,EAAE;AACvC,UAAM,mBAAmB,UAAU;AACnC,WAAO,GAAG,OAAO,IAAI,gBAAgB;AAAA,EACvC;AAAA;AAAA;AAAA;AAAA,EAKA,YAAkB;AAChB,QAAI,KAAK,YAAY;AACnB;AAAA,IACF;AACA,SAAK,aAAa;AAElB,QAAI,KAAK,QAAQ,OAAO;AACtB,WAAK,UAAU;AAAA,IACjB,OAAO;AACL,WAAK,OAAO,MAAM,IAAI;AAAA,IACxB;AAAA,EACF;AACF;AAKO,SAAS,wBACd,SACA,OACA,OACQ;AACR,QAAM,UAAU,KAAK,MAAO,UAAU,QAAS,GAAG;AAClD,QAAM,WAAW,GAAG,OAAO,IAAI,KAAK;AAEpC,MAAI,SAAS;AACb,MAAI,OAAO;AACT,cAAU,GAAG,KAAK;AAAA,EACpB;AAEA,YAAU,GAAG,uBAAAA,QAAO,KAAK,IAAI,OAAO,IAAI,CAAC,IAAI,QAAQ;AAErD,SAAO;AACT;",
4
+ "sourcesContent": ["/**\n * @fileoverview Progress bar utilities for CLI applications.\n * Provides various progress indicators including bars, percentages, and spinners.\n */\n\nimport colors from '../external/yoctocolors-cjs'\nimport { repeatString, stripAnsi } from '../strings'\n\nexport interface ProgressBarOptions {\n /**\n * Width of the progress bar in characters.\n * @default 40\n */\n width?: number | undefined\n /**\n * Format template for progress bar display.\n * Available tokens: `:bar`, `:percent`, `:current`, `:total`, `:elapsed`, `:eta`.\n * Custom tokens can be passed via the `tokens` parameter in `update()` or `tick()`.\n * @default ':bar :percent :current/:total'\n * @example\n * ```ts\n * format: ':bar :percent :current/:total :eta'\n * ```\n */\n format?: string | undefined\n /**\n * Character(s) to use for completed portion of bar.\n * @default '\u2588'\n */\n complete?: string | undefined\n /**\n * Character(s) to use for incomplete portion of bar.\n * @default '\u2591'\n */\n incomplete?: string | undefined\n /**\n * Character(s) to use for the head of the progress bar.\n * @default ''\n */\n head?: string | undefined\n /**\n * Clear the progress bar when complete.\n * @default false\n */\n clear?: boolean | undefined\n /**\n * Minimum time between renders in milliseconds.\n * ~60fps = 16ms throttle.\n * @default 16\n */\n renderThrottle?: number | undefined\n /**\n * Stream to write progress bar output to.\n * @default process.stderr\n */\n stream?: NodeJS.WriteStream | undefined\n /**\n * Color to apply to the completed portion of the bar.\n * @default 'cyan'\n */\n color?: 'cyan' | 'green' | 'yellow' | 'blue' | 'magenta' | undefined\n}\n\nexport class ProgressBar {\n private current: number = 0\n private total: number\n private startTime: number\n private lastRender: number = 0\n private stream: NodeJS.WriteStream\n private options: Required<ProgressBarOptions>\n private terminated: boolean = false\n private lastDrawnWidth: number = 0\n\n /**\n * Create a new progress bar instance.\n *\n * @param total - Total number of units for the progress bar\n * @param options - Configuration options for the progress bar\n *\n * @example\n * ```ts\n * const bar = new ProgressBar(100, {\n * width: 50,\n * format: ':bar :percent :current/:total :eta',\n * color: 'green'\n * })\n * ```\n */\n constructor(total: number, options?: ProgressBarOptions) {\n this.total = total\n this.startTime = Date.now()\n this.stream = options?.stream || process.stderr\n this.options = {\n width: 40,\n format: ':bar :percent :current/:total',\n complete: '\u2588',\n incomplete: '\u2591',\n head: '',\n clear: false,\n // ~60fps.\n renderThrottle: 16,\n stream: this.stream,\n color: 'cyan',\n ...options,\n }\n }\n\n /**\n * Update progress to a specific value and redraw the bar.\n * Updates are throttled to prevent excessive rendering (default ~60fps).\n *\n * @param current - Current progress value (will be clamped to total)\n * @param tokens - Optional custom tokens to replace in format string\n *\n * @example\n * ```ts\n * bar.update(50)\n * bar.update(75, { status: 'Processing...' })\n * ```\n */\n update(current: number, tokens?: Record<string, unknown>): void {\n if (this.terminated) {\n return\n }\n\n this.current = Math.min(current, this.total)\n\n // Throttle rendering\n const now = Date.now()\n if (\n now - this.lastRender < this.options.renderThrottle &&\n this.current < this.total\n ) {\n return\n }\n this.lastRender = now\n\n this.render(tokens)\n\n if (this.current >= this.total) {\n this.terminate()\n }\n }\n\n /**\n * Increment progress by a specified amount.\n * Convenience method for `update(current + amount)`.\n *\n * @param amount - Amount to increment by\n * @param tokens - Optional custom tokens to replace in format string\n * @default amount 1\n *\n * @example\n * ```ts\n * bar.tick() // Increment by 1\n * bar.tick(5) // Increment by 5\n * bar.tick(1, { file: 'data.json' })\n * ```\n */\n tick(amount: number = 1, tokens?: Record<string, unknown>): void {\n this.update(this.current + amount, tokens)\n }\n\n /**\n * Render the progress bar.\n */\n private render(tokens?: Record<string, unknown>): void {\n const colorFn = colors[this.options.color] || ((s: string) => s)\n\n // Calculate values\n const percent = Math.floor((this.current / this.total) * 100)\n const elapsed = Date.now() - this.startTime\n const eta =\n this.current === 0\n ? 0\n : (elapsed / this.current) * (this.total - this.current)\n\n // Build bar\n const availableWidth = this.options.width\n const filledWidth = Math.floor((this.current / this.total) * availableWidth)\n const emptyWidth = availableWidth - filledWidth\n\n const filled = repeatString(this.options.complete, filledWidth)\n const empty = repeatString(this.options.incomplete, emptyWidth)\n const bar = colorFn(filled) + empty\n\n // Format output\n let output = this.options.format\n output = output.replace(':bar', bar)\n output = output.replace(':percent', `${percent}%`)\n output = output.replace(':current', String(this.current))\n output = output.replace(':total', String(this.total))\n output = output.replace(':elapsed', this.formatTime(elapsed))\n output = output.replace(':eta', this.formatTime(eta))\n\n // Replace custom tokens\n if (tokens) {\n for (const [key, value] of Object.entries(tokens)) {\n output = output.replace(`:${key}`, String(value))\n }\n }\n\n // Clear line and write\n this.clearLine()\n this.stream.write(output)\n this.lastDrawnWidth = stripAnsi(output).length\n }\n\n /**\n * Clear the current line.\n */\n private clearLine(): void {\n if (this.stream.isTTY) {\n this.stream.cursorTo(0)\n this.stream.clearLine(0)\n } else if (this.lastDrawnWidth > 0) {\n this.stream.write(`\\r${repeatString(' ', this.lastDrawnWidth)}\\r`)\n }\n }\n\n /**\n * Format time in seconds to human readable.\n */\n private formatTime(ms: number): string {\n const seconds = Math.round(ms / 1000)\n if (seconds < 60) {\n return `${seconds}s`\n }\n const minutes = Math.floor(seconds / 60)\n const remainingSeconds = seconds % 60\n return `${minutes}m${remainingSeconds}s`\n }\n\n /**\n * Terminate the progress bar and optionally clear it.\n * Called automatically when progress reaches 100%.\n * If `clear` option is true, removes the bar from terminal.\n * Otherwise, moves to next line to preserve the final state.\n */\n terminate(): void {\n if (this.terminated) {\n return\n }\n this.terminated = true\n\n if (this.options.clear) {\n this.clearLine()\n } else {\n this.stream.write('\\n')\n }\n }\n}\n\n/**\n * Create a simple progress indicator without a graphical bar.\n * Returns a formatted string showing progress as percentage and fraction.\n *\n * @param current - Current progress value\n * @param total - Total progress value\n * @param label - Optional label prefix\n * @returns Formatted progress indicator string\n *\n * @example\n * ```ts\n * createProgressIndicator(50, 100)\n * // Returns: '[50%] 50/100'\n *\n * createProgressIndicator(3, 10, 'Files')\n * // Returns: 'Files: [30%] 3/10'\n * ```\n */\nexport function createProgressIndicator(\n current: number,\n total: number,\n label?: string | undefined,\n): string {\n const percent = Math.floor((current / total) * 100)\n const progress = `${current}/${total}`\n\n let output = ''\n if (label) {\n output += `${label}: `\n }\n\n output += `${colors.cyan(`[${percent}%]`)} ${progress}`\n\n return output\n}\n"],
5
+ "mappings": "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",
6
6
  "names": ["colors"]
7
7
  }
@@ -1,25 +1,59 @@
1
1
  // Type definitions
2
+ /**
3
+ * Choice option for select and search prompts.
4
+ *
5
+ * @template Value - Type of the choice value
6
+ */
2
7
  export interface Choice<Value = unknown> {
8
+ /** The value returned when this choice is selected */
3
9
  value: Value;
10
+ /** Whether this choice is disabled, or a reason string */
4
11
  disabled?: boolean | string | undefined;
12
+ /** Additional description text shown below the choice */
5
13
  description?: string | undefined;
14
+ /** Display name for the choice (defaults to value.toString()) */
6
15
  name?: string | undefined;
16
+ /** Short text shown after selection (defaults to name) */
7
17
  short?: string | undefined;
8
18
  }
9
- // Duplicated from @inquirer/type - InquirerContext
10
- // This is the minimal context interface used by Inquirer prompts
19
+ /**
20
+ * Context for inquirer prompts.
21
+ * Minimal context interface used by Inquirer prompts.
22
+ * Duplicated from `@inquirer/type` - InquirerContext.
23
+ */
11
24
  interface InquirerContext {
25
+ /** Abort signal for cancelling the prompt */
12
26
  signal?: AbortSignal | undefined;
27
+ /** Input stream (defaults to process.stdin) */
13
28
  input?: NodeJS.ReadableStream | undefined;
29
+ /** Output stream (defaults to process.stdout) */
14
30
  output?: NodeJS.WritableStream | undefined;
31
+ /** Clear the prompt from terminal when done */
15
32
  clearPromptOnDone?: boolean | undefined;
16
33
  }
34
+ /**
35
+ * Extended context with spinner support.
36
+ * Allows passing a spinner instance to be managed during prompts.
37
+ */
17
38
  export type Context = import('../objects').Remap<InquirerContext & {
39
+ /** Optional spinner to stop/start during prompt display */
18
40
  spinner?: import('../spinner').Spinner | undefined;
19
41
  }>;
20
- // Duplicated from @inquirer/select - Separator
21
- // A separator object used in select/checkbox prompts to create visual separators
22
- // This type definition ensures the Separator type is available in published packages
42
+ /**
43
+ * Separator for visual grouping in select/checkbox prompts.
44
+ * Creates a non-selectable visual separator line.
45
+ * Duplicated from `@inquirer/select` - Separator.
46
+ * This type definition ensures the Separator type is available in published packages.
47
+ *
48
+ * @example
49
+ * import { Separator } from './prompts'
50
+ *
51
+ * const choices = [
52
+ * { name: 'Option 1', value: 1 },
53
+ * new Separator(),
54
+ * { name: 'Option 2', value: 2 }
55
+ * ]
56
+ */
23
57
  declare class SeparatorType {
24
58
  readonly separator: string;
25
59
  readonly type: 'separator';
@@ -28,6 +62,16 @@ declare class SeparatorType {
28
62
  export type Separator = SeparatorType;
29
63
  /**
30
64
  * Wrap an inquirer prompt with spinner handling and signal injection.
65
+ * Automatically stops/starts spinners during prompt display and injects abort signals.
66
+ * Trims string results and handles cancellation gracefully.
67
+ *
68
+ * @template T - Type of the prompt result
69
+ * @param inquirerPrompt - The inquirer prompt function to wrap
70
+ * @returns Wrapped prompt function with spinner and signal handling
71
+ *
72
+ * @example
73
+ * const myPrompt = wrapPrompt(rawInquirerPrompt)
74
+ * const result = await myPrompt({ message: 'Enter name:' })
31
75
  */
32
76
  /*@__NO_SIDE_EFFECTS__*/
33
77
  export declare function wrapPrompt<T = unknown>(inquirerPrompt: (...args: unknown[]) => Promise<T>): (...args: unknown[]) => Promise<T | undefined>;
@@ -38,9 +82,55 @@ declare const searchRaw: any;
38
82
  declare const selectRaw: any;
39
83
  declare const ActualSeparator: any;
40
84
  // c8 ignore stop
85
+ /**
86
+ * Prompt for a yes/no confirmation.
87
+ * Wrapped with spinner handling and abort signal support.
88
+ *
89
+ * @example
90
+ * const answer = await confirm({ message: 'Continue?' })
91
+ * if (answer) { // user confirmed }
92
+ */
41
93
  export declare const confirm: typeof confirmRaw;
94
+ /**
95
+ * Prompt for text input.
96
+ * Wrapped with spinner handling and abort signal support.
97
+ * Result is automatically trimmed.
98
+ *
99
+ * @example
100
+ * const name = await input({ message: 'Enter your name:' })
101
+ */
42
102
  export declare const input: typeof inputRaw;
103
+ /**
104
+ * Prompt for password input (hidden characters).
105
+ * Wrapped with spinner handling and abort signal support.
106
+ *
107
+ * @example
108
+ * const token = await password({ message: 'Enter API token:' })
109
+ */
43
110
  export declare const password: typeof passwordRaw;
111
+ /**
112
+ * Prompt with searchable/filterable choices.
113
+ * Wrapped with spinner handling and abort signal support.
114
+ *
115
+ * @example
116
+ * const result = await search({
117
+ * message: 'Select a package:',
118
+ * source: async (input) => fetchPackages(input)
119
+ * })
120
+ */
44
121
  export declare const search: typeof searchRaw;
122
+ /**
123
+ * Prompt to select from a list of choices.
124
+ * Wrapped with spinner handling and abort signal support.
125
+ *
126
+ * @example
127
+ * const choice = await select({
128
+ * message: 'Choose an option:',
129
+ * choices: [
130
+ * { name: 'Option 1', value: 'opt1' },
131
+ * { name: 'Option 2', value: 'opt2' }
132
+ * ]
133
+ * })
134
+ */
45
135
  export declare const select: typeof selectRaw;
46
136
  export { ActualSeparator as Separator };
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/stdio/prompts.ts"],
4
- "sourcesContent": ["/**\n * @fileoverview User prompt utilities for interactive scripts.\n * Provides inquirer.js integration with spinner support and context handling.\n */\n\nimport { getAbortSignal, getSpinner } from '#constants/process'\n\nconst abortSignal = getAbortSignal()\nconst spinner = getSpinner()\n\n// Type definitions\n\nexport interface Choice<Value = unknown> {\n value: Value\n disabled?: boolean | string | undefined\n description?: string | undefined\n name?: string | undefined\n short?: string | undefined\n}\n\n// Duplicated from @inquirer/type - InquirerContext\n// This is the minimal context interface used by Inquirer prompts\ninterface InquirerContext {\n signal?: AbortSignal | undefined\n input?: NodeJS.ReadableStream | undefined\n output?: NodeJS.WritableStream | undefined\n clearPromptOnDone?: boolean | undefined\n}\n\nexport type Context = import('../objects').Remap<\n InquirerContext & {\n spinner?: import('../spinner').Spinner | undefined\n }\n>\n\n// Duplicated from @inquirer/select - Separator\n// A separator object used in select/checkbox prompts to create visual separators\n// This type definition ensures the Separator type is available in published packages\ndeclare class SeparatorType {\n readonly separator: string\n readonly type: 'separator'\n constructor(separator?: string)\n}\n\nexport type Separator = SeparatorType\n\n/**\n * Wrap an inquirer prompt with spinner handling and signal injection.\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function wrapPrompt<T = unknown>(\n inquirerPrompt: (...args: unknown[]) => Promise<T>,\n): (...args: unknown[]) => Promise<T | undefined> {\n return async (...args) => {\n const origContext = (args.length > 1 ? args[1] : undefined) as\n | Context\n | undefined\n const { spinner: contextSpinner, ...contextWithoutSpinner } =\n origContext ?? ({} as Context)\n const spinnerInstance =\n contextSpinner !== undefined ? contextSpinner : spinner\n const signal = abortSignal\n if (origContext) {\n args[1] = {\n signal,\n ...contextWithoutSpinner,\n }\n } else {\n args[1] = { signal }\n }\n const wasSpinning = !!spinnerInstance?.isSpinning\n spinnerInstance?.stop()\n let result: unknown\n try {\n result = await inquirerPrompt(...args)\n } catch (e) {\n if (e instanceof TypeError) {\n throw e\n }\n }\n if (wasSpinning) {\n spinnerInstance.start()\n }\n return (typeof result === 'string' ? result.trim() : result) as\n | T\n | undefined\n }\n}\n\n// c8 ignore start - Third-party inquirer library requires and exports not testable in isolation.\nconst confirmExport = /*@__PURE__*/ require('../external/@inquirer/confirm')\nconst inputExport = /*@__PURE__*/ require('../external/@inquirer/input')\nconst passwordExport = /*@__PURE__*/ require('../external/@inquirer/password')\nconst searchExport = /*@__PURE__*/ require('../external/@inquirer/search')\nconst selectExport = /*@__PURE__*/ require('../external/@inquirer/select')\nconst confirmRaw = confirmExport.default ?? confirmExport\nconst inputRaw = inputExport.default ?? inputExport\nconst passwordRaw = passwordExport.default ?? passwordExport\nconst searchRaw = searchExport.default ?? searchExport\nconst selectRaw = selectExport.default ?? selectExport\nconst ActualSeparator = selectExport.Separator\n// c8 ignore stop\n\nexport const confirm: typeof confirmRaw = wrapPrompt(confirmRaw)\nexport const input: typeof inputRaw = wrapPrompt(inputRaw)\nexport const password: typeof passwordRaw = wrapPrompt(passwordRaw)\nexport const search: typeof searchRaw = wrapPrompt(searchRaw)\nexport const select: typeof selectRaw = wrapPrompt(selectRaw)\nexport { ActualSeparator as Separator }\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,qBAA2C;AAE3C,MAAM,kBAAc,+BAAe;AACnC,MAAM,cAAU,2BAAW;AAAA;AA0CpB,SAAS,WACd,gBACgD;AAChD,SAAO,UAAU,SAAS;AACxB,UAAM,cAAe,KAAK,SAAS,IAAI,KAAK,CAAC,IAAI;AAGjD,UAAM,EAAE,SAAS,gBAAgB,GAAG,sBAAsB,IACxD,eAAgB,CAAC;AACnB,UAAM,kBACJ,mBAAmB,SAAY,iBAAiB;AAClD,UAAM,SAAS;AACf,QAAI,aAAa;AACf,WAAK,CAAC,IAAI;AAAA,QACR;AAAA,QACA,GAAG;AAAA,MACL;AAAA,IACF,OAAO;AACL,WAAK,CAAC,IAAI,EAAE,OAAO;AAAA,IACrB;AACA,UAAM,cAAc,CAAC,CAAC,iBAAiB;AACvC,qBAAiB,KAAK;AACtB,QAAI;AACJ,QAAI;AACF,eAAS,MAAM,eAAe,GAAG,IAAI;AAAA,IACvC,SAAS,GAAG;AACV,UAAI,aAAa,WAAW;AAC1B,cAAM;AAAA,MACR;AAAA,IACF;AACA,QAAI,aAAa;AACf,sBAAgB,MAAM;AAAA,IACxB;AACA,WAAQ,OAAO,WAAW,WAAW,OAAO,KAAK,IAAI;AAAA,EAGvD;AACF;AAGA,MAAM,gBAA8B,QAAQ,+BAA+B;AAC3E,MAAM,cAA4B,QAAQ,6BAA6B;AACvE,MAAM,iBAA+B,QAAQ,gCAAgC;AAC7E,MAAM,eAA6B,QAAQ,8BAA8B;AACzE,MAAM,eAA6B,QAAQ,8BAA8B;AACzE,MAAM,aAAa,cAAc,WAAW;AAC5C,MAAM,WAAW,YAAY,WAAW;AACxC,MAAM,cAAc,eAAe,WAAW;AAC9C,MAAM,YAAY,aAAa,WAAW;AAC1C,MAAM,YAAY,aAAa,WAAW;AAC1C,MAAM,kBAAkB,aAAa;AAG9B,MAAM,UAA6B,2BAAW,UAAU;AACxD,MAAM,QAAyB,2BAAW,QAAQ;AAClD,MAAM,WAA+B,2BAAW,WAAW;AAC3D,MAAM,SAA2B,2BAAW,SAAS;AACrD,MAAM,SAA2B,2BAAW,SAAS;",
4
+ "sourcesContent": ["/**\n * @fileoverview User prompt utilities for interactive scripts.\n * Provides inquirer.js integration with spinner support and context handling.\n */\n\nimport { getAbortSignal, getSpinner } from '#constants/process'\n\nconst abortSignal = getAbortSignal()\nconst spinner = getSpinner()\n\n// Type definitions\n\n/**\n * Choice option for select and search prompts.\n *\n * @template Value - Type of the choice value\n */\nexport interface Choice<Value = unknown> {\n /** The value returned when this choice is selected */\n value: Value\n /** Whether this choice is disabled, or a reason string */\n disabled?: boolean | string | undefined\n /** Additional description text shown below the choice */\n description?: string | undefined\n /** Display name for the choice (defaults to value.toString()) */\n name?: string | undefined\n /** Short text shown after selection (defaults to name) */\n short?: string | undefined\n}\n\n/**\n * Context for inquirer prompts.\n * Minimal context interface used by Inquirer prompts.\n * Duplicated from `@inquirer/type` - InquirerContext.\n */\ninterface InquirerContext {\n /** Abort signal for cancelling the prompt */\n signal?: AbortSignal | undefined\n /** Input stream (defaults to process.stdin) */\n input?: NodeJS.ReadableStream | undefined\n /** Output stream (defaults to process.stdout) */\n output?: NodeJS.WritableStream | undefined\n /** Clear the prompt from terminal when done */\n clearPromptOnDone?: boolean | undefined\n}\n\n/**\n * Extended context with spinner support.\n * Allows passing a spinner instance to be managed during prompts.\n */\nexport type Context = import('../objects').Remap<\n InquirerContext & {\n /** Optional spinner to stop/start during prompt display */\n spinner?: import('../spinner').Spinner | undefined\n }\n>\n\n/**\n * Separator for visual grouping in select/checkbox prompts.\n * Creates a non-selectable visual separator line.\n * Duplicated from `@inquirer/select` - Separator.\n * This type definition ensures the Separator type is available in published packages.\n *\n * @example\n * import { Separator } from './prompts'\n *\n * const choices = [\n * { name: 'Option 1', value: 1 },\n * new Separator(),\n * { name: 'Option 2', value: 2 }\n * ]\n */\ndeclare class SeparatorType {\n readonly separator: string\n readonly type: 'separator'\n constructor(separator?: string)\n}\n\nexport type Separator = SeparatorType\n\n/**\n * Wrap an inquirer prompt with spinner handling and signal injection.\n * Automatically stops/starts spinners during prompt display and injects abort signals.\n * Trims string results and handles cancellation gracefully.\n *\n * @template T - Type of the prompt result\n * @param inquirerPrompt - The inquirer prompt function to wrap\n * @returns Wrapped prompt function with spinner and signal handling\n *\n * @example\n * const myPrompt = wrapPrompt(rawInquirerPrompt)\n * const result = await myPrompt({ message: 'Enter name:' })\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function wrapPrompt<T = unknown>(\n inquirerPrompt: (...args: unknown[]) => Promise<T>,\n): (...args: unknown[]) => Promise<T | undefined> {\n return async (...args) => {\n const origContext = (args.length > 1 ? args[1] : undefined) as\n | Context\n | undefined\n const { spinner: contextSpinner, ...contextWithoutSpinner } =\n origContext ?? ({} as Context)\n const spinnerInstance =\n contextSpinner !== undefined ? contextSpinner : spinner\n const signal = abortSignal\n if (origContext) {\n args[1] = {\n signal,\n ...contextWithoutSpinner,\n }\n } else {\n args[1] = { signal }\n }\n const wasSpinning = !!spinnerInstance?.isSpinning\n spinnerInstance?.stop()\n let result: unknown\n try {\n result = await inquirerPrompt(...args)\n } catch (e) {\n if (e instanceof TypeError) {\n throw e\n }\n }\n if (wasSpinning) {\n spinnerInstance.start()\n }\n return (typeof result === 'string' ? result.trim() : result) as\n | T\n | undefined\n }\n}\n\n// c8 ignore start - Third-party inquirer library requires and exports not testable in isolation.\nconst confirmExport = /*@__PURE__*/ require('../external/@inquirer/confirm')\nconst inputExport = /*@__PURE__*/ require('../external/@inquirer/input')\nconst passwordExport = /*@__PURE__*/ require('../external/@inquirer/password')\nconst searchExport = /*@__PURE__*/ require('../external/@inquirer/search')\nconst selectExport = /*@__PURE__*/ require('../external/@inquirer/select')\nconst confirmRaw = confirmExport.default ?? confirmExport\nconst inputRaw = inputExport.default ?? inputExport\nconst passwordRaw = passwordExport.default ?? passwordExport\nconst searchRaw = searchExport.default ?? searchExport\nconst selectRaw = selectExport.default ?? selectExport\nconst ActualSeparator = selectExport.Separator\n// c8 ignore stop\n\n/**\n * Prompt for a yes/no confirmation.\n * Wrapped with spinner handling and abort signal support.\n *\n * @example\n * const answer = await confirm({ message: 'Continue?' })\n * if (answer) { // user confirmed }\n */\nexport const confirm: typeof confirmRaw = wrapPrompt(confirmRaw)\n\n/**\n * Prompt for text input.\n * Wrapped with spinner handling and abort signal support.\n * Result is automatically trimmed.\n *\n * @example\n * const name = await input({ message: 'Enter your name:' })\n */\nexport const input: typeof inputRaw = wrapPrompt(inputRaw)\n\n/**\n * Prompt for password input (hidden characters).\n * Wrapped with spinner handling and abort signal support.\n *\n * @example\n * const token = await password({ message: 'Enter API token:' })\n */\nexport const password: typeof passwordRaw = wrapPrompt(passwordRaw)\n\n/**\n * Prompt with searchable/filterable choices.\n * Wrapped with spinner handling and abort signal support.\n *\n * @example\n * const result = await search({\n * message: 'Select a package:',\n * source: async (input) => fetchPackages(input)\n * })\n */\nexport const search: typeof searchRaw = wrapPrompt(searchRaw)\n\n/**\n * Prompt to select from a list of choices.\n * Wrapped with spinner handling and abort signal support.\n *\n * @example\n * const choice = await select({\n * message: 'Choose an option:',\n * choices: [\n * { name: 'Option 1', value: 'opt1' },\n * { name: 'Option 2', value: 'opt2' }\n * ]\n * })\n */\nexport const select: typeof selectRaw = wrapPrompt(selectRaw)\n\nexport { ActualSeparator as Separator }\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,qBAA2C;AAE3C,MAAM,kBAAc,+BAAe;AACnC,MAAM,cAAU,2BAAW;AAAA;AAsFpB,SAAS,WACd,gBACgD;AAChD,SAAO,UAAU,SAAS;AACxB,UAAM,cAAe,KAAK,SAAS,IAAI,KAAK,CAAC,IAAI;AAGjD,UAAM,EAAE,SAAS,gBAAgB,GAAG,sBAAsB,IACxD,eAAgB,CAAC;AACnB,UAAM,kBACJ,mBAAmB,SAAY,iBAAiB;AAClD,UAAM,SAAS;AACf,QAAI,aAAa;AACf,WAAK,CAAC,IAAI;AAAA,QACR;AAAA,QACA,GAAG;AAAA,MACL;AAAA,IACF,OAAO;AACL,WAAK,CAAC,IAAI,EAAE,OAAO;AAAA,IACrB;AACA,UAAM,cAAc,CAAC,CAAC,iBAAiB;AACvC,qBAAiB,KAAK;AACtB,QAAI;AACJ,QAAI;AACF,eAAS,MAAM,eAAe,GAAG,IAAI;AAAA,IACvC,SAAS,GAAG;AACV,UAAI,aAAa,WAAW;AAC1B,cAAM;AAAA,MACR;AAAA,IACF;AACA,QAAI,aAAa;AACf,sBAAgB,MAAM;AAAA,IACxB;AACA,WAAQ,OAAO,WAAW,WAAW,OAAO,KAAK,IAAI;AAAA,EAGvD;AACF;AAGA,MAAM,gBAA8B,QAAQ,+BAA+B;AAC3E,MAAM,cAA4B,QAAQ,6BAA6B;AACvE,MAAM,iBAA+B,QAAQ,gCAAgC;AAC7E,MAAM,eAA6B,QAAQ,8BAA8B;AACzE,MAAM,eAA6B,QAAQ,8BAA8B;AACzE,MAAM,aAAa,cAAc,WAAW;AAC5C,MAAM,WAAW,YAAY,WAAW;AACxC,MAAM,cAAc,eAAe,WAAW;AAC9C,MAAM,YAAY,aAAa,WAAW;AAC1C,MAAM,YAAY,aAAa,WAAW;AAC1C,MAAM,kBAAkB,aAAa;AAW9B,MAAM,UAA6B,2BAAW,UAAU;AAUxD,MAAM,QAAyB,2BAAW,QAAQ;AASlD,MAAM,WAA+B,2BAAW,WAAW;AAY3D,MAAM,SAA2B,2BAAW,SAAS;AAerD,MAAM,SAA2B,2BAAW,SAAS;",
6
6
  "names": []
7
7
  }
@@ -1,47 +1,150 @@
1
1
  /**
2
- * Standard error stream utilities.
2
+ * @fileoverview Standard error stream utilities.
3
3
  * Provides utilities for writing to stderr with formatting and control.
4
4
  */
5
5
  // Get the actual stderr stream
6
6
  declare const stderr: NodeJS.WriteStream;
7
7
  /**
8
- * Write an error line to stderr.
8
+ * Write a line to stderr with trailing newline.
9
+ * Used for error messages, warnings, and diagnostic output.
10
+ *
11
+ * @param text - Text to write
12
+ * @default text ''
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * writeErrorLine('Error: File not found')
17
+ * writeErrorLine() // Write empty line
18
+ * ```
9
19
  */
10
20
  export declare function writeErrorLine(text?: string): void;
11
21
  /**
12
- * Write error text to stderr without newline.
22
+ * Write text to stderr without adding a newline.
23
+ *
24
+ * @param text - Text to write
25
+ *
26
+ * @example
27
+ * ```ts
28
+ * writeError('Downloading...')
29
+ * // Later update progress
30
+ * ```
13
31
  */
14
32
  export declare function writeError(text: string): void;
15
33
  /**
16
34
  * Clear the current line on stderr.
35
+ * Only works in TTY environments.
36
+ *
37
+ * @example
38
+ * ```ts
39
+ * writeError('Processing...')
40
+ * clearLine()
41
+ * writeError('Done!')
42
+ * ```
17
43
  */
18
44
  export declare function clearLine(): void;
19
45
  /**
20
- * Move cursor to position on stderr.
46
+ * Move cursor to specific position on stderr.
47
+ * Only works in TTY environments.
48
+ *
49
+ * @param x - Column position (0-based)
50
+ * @param y - Row position (0-based, optional)
51
+ *
52
+ * @example
53
+ * ```ts
54
+ * cursorTo(0) // Move to start of line
55
+ * cursorTo(10, 5) // Move to column 10, row 5
56
+ * ```
21
57
  */
22
- export declare function cursorTo(x: number, y?: number): void;
58
+ export declare function cursorTo(x: number, y?: number | undefined): void;
23
59
  /**
24
- * Check if stderr is a TTY.
60
+ * Check if stderr is connected to a TTY (terminal).
61
+ *
62
+ * @returns `true` if stderr is a TTY, `false` if piped/redirected
63
+ *
64
+ * @example
65
+ * ```ts
66
+ * if (isTTY()) {
67
+ * // Show colored error messages
68
+ * } else {
69
+ * // Use plain text
70
+ * }
71
+ * ```
25
72
  */
26
73
  export declare function isTTY(): boolean;
27
74
  /**
28
- * Get terminal columns for stderr.
75
+ * Get the number of columns (width) in the terminal.
76
+ *
77
+ * @returns Terminal width in characters
78
+ * @default 80
79
+ *
80
+ * @example
81
+ * ```ts
82
+ * const width = getColumns()
83
+ * console.error(`Terminal is ${width} characters wide`)
84
+ * ```
29
85
  */
30
86
  export declare function getColumns(): number;
31
87
  /**
32
- * Get terminal rows for stderr.
88
+ * Get the number of rows (height) in the terminal.
89
+ *
90
+ * @returns Terminal height in lines
91
+ * @default 24
92
+ *
93
+ * @example
94
+ * ```ts
95
+ * const height = getRows()
96
+ * console.error(`Terminal is ${height} lines tall`)
97
+ * ```
33
98
  */
34
99
  export declare function getRows(): number;
35
100
  /**
36
- * Write a warning to stderr with formatting.
101
+ * Write a formatted warning message to stderr.
102
+ *
103
+ * @param message - Warning message text
104
+ * @param prefix - Prefix label for the warning
105
+ * @default prefix 'Warning'
106
+ *
107
+ * @example
108
+ * ```ts
109
+ * writeWarning('Deprecated API usage')
110
+ * // Output: 'Warning: Deprecated API usage'
111
+ *
112
+ * writeWarning('Invalid config', 'Config')
113
+ * // Output: 'Config: Invalid config'
114
+ * ```
37
115
  */
38
116
  export declare function writeWarning(message: string, prefix?: string): void;
39
117
  /**
40
- * Write an error to stderr with formatting.
118
+ * Write a formatted error message to stderr.
119
+ *
120
+ * @param message - Error message text
121
+ * @param prefix - Prefix label for the error
122
+ * @default prefix 'Error'
123
+ *
124
+ * @example
125
+ * ```ts
126
+ * writeErrorFormatted('File not found')
127
+ * // Output: 'Error: File not found'
128
+ *
129
+ * writeErrorFormatted('Connection failed', 'Network')
130
+ * // Output: 'Network: Connection failed'
131
+ * ```
41
132
  */
42
133
  export declare function writeErrorFormatted(message: string, prefix?: string): void;
43
134
  /**
44
- * Write stack trace to stderr.
135
+ * Write an error's stack trace to stderr.
136
+ * Falls back to formatted error message if no stack is available.
137
+ *
138
+ * @param error - Error object to write
139
+ *
140
+ * @example
141
+ * ```ts
142
+ * try {
143
+ * throw new Error('Something went wrong')
144
+ * } catch (err) {
145
+ * writeStackTrace(err as Error)
146
+ * }
147
+ * ```
45
148
  */
46
149
  export declare function writeStackTrace(error: Error): void;
47
150
  // Export the raw stream for advanced usage
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/stdio/stderr.ts"],
4
- "sourcesContent": ["/**\n * Standard error stream utilities.\n * Provides utilities for writing to stderr with formatting and control.\n */\n\n// Get the actual stderr stream\nconst stderr: NodeJS.WriteStream = process.stderr\n\n/**\n * Write an error line to stderr.\n */\nexport function writeErrorLine(text: string = ''): void {\n stderr.write(`${text}\\n`)\n}\n\n/**\n * Write error text to stderr without newline.\n */\nexport function writeError(text: string): void {\n stderr.write(text)\n}\n\n/**\n * Clear the current line on stderr.\n */\nexport function clearLine(): void {\n if (stderr.isTTY) {\n stderr.cursorTo(0)\n stderr.clearLine(0)\n }\n}\n\n/**\n * Move cursor to position on stderr.\n */\nexport function cursorTo(x: number, y?: number): void {\n if (stderr.isTTY) {\n stderr.cursorTo(x, y)\n }\n}\n\n/**\n * Check if stderr is a TTY.\n */\nexport function isTTY(): boolean {\n return stderr.isTTY || false\n}\n\n/**\n * Get terminal columns for stderr.\n */\nexport function getColumns(): number {\n return stderr.columns || 80\n}\n\n/**\n * Get terminal rows for stderr.\n */\nexport function getRows(): number {\n return stderr.rows || 24\n}\n\n/**\n * Write a warning to stderr with formatting.\n */\nexport function writeWarning(\n message: string,\n prefix: string = 'Warning',\n): void {\n const formatted = `${prefix}: ${message}`\n writeErrorLine(formatted)\n}\n\n/**\n * Write an error to stderr with formatting.\n */\nexport function writeErrorFormatted(\n message: string,\n prefix: string = 'Error',\n): void {\n const formatted = `${prefix}: ${message}`\n writeErrorLine(formatted)\n}\n\n/**\n * Write stack trace to stderr.\n */\nexport function writeStackTrace(error: Error): void {\n if (error.stack) {\n writeErrorLine(error.stack)\n } else {\n writeErrorFormatted(error.message)\n }\n}\n\n// Export the raw stream for advanced usage\nexport { stderr }\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,MAAM,SAA6B,QAAQ;AAKpC,SAAS,eAAe,OAAe,IAAU;AACtD,SAAO,MAAM,GAAG,IAAI;AAAA,CAAI;AAC1B;AAKO,SAAS,WAAW,MAAoB;AAC7C,SAAO,MAAM,IAAI;AACnB;AAKO,SAAS,YAAkB;AAChC,MAAI,OAAO,OAAO;AAChB,WAAO,SAAS,CAAC;AACjB,WAAO,UAAU,CAAC;AAAA,EACpB;AACF;AAKO,SAAS,SAAS,GAAW,GAAkB;AACpD,MAAI,OAAO,OAAO;AAChB,WAAO,SAAS,GAAG,CAAC;AAAA,EACtB;AACF;AAKO,SAAS,QAAiB;AAC/B,SAAO,OAAO,SAAS;AACzB;AAKO,SAAS,aAAqB;AACnC,SAAO,OAAO,WAAW;AAC3B;AAKO,SAAS,UAAkB;AAChC,SAAO,OAAO,QAAQ;AACxB;AAKO,SAAS,aACd,SACA,SAAiB,WACX;AACN,QAAM,YAAY,GAAG,MAAM,KAAK,OAAO;AACvC,iBAAe,SAAS;AAC1B;AAKO,SAAS,oBACd,SACA,SAAiB,SACX;AACN,QAAM,YAAY,GAAG,MAAM,KAAK,OAAO;AACvC,iBAAe,SAAS;AAC1B;AAKO,SAAS,gBAAgB,OAAoB;AAClD,MAAI,MAAM,OAAO;AACf,mBAAe,MAAM,KAAK;AAAA,EAC5B,OAAO;AACL,wBAAoB,MAAM,OAAO;AAAA,EACnC;AACF;",
4
+ "sourcesContent": ["/**\n * @fileoverview Standard error stream utilities.\n * Provides utilities for writing to stderr with formatting and control.\n */\n\n// Get the actual stderr stream\nconst stderr: NodeJS.WriteStream = process.stderr\n\n/**\n * Write a line to stderr with trailing newline.\n * Used for error messages, warnings, and diagnostic output.\n *\n * @param text - Text to write\n * @default text ''\n *\n * @example\n * ```ts\n * writeErrorLine('Error: File not found')\n * writeErrorLine() // Write empty line\n * ```\n */\nexport function writeErrorLine(text: string = ''): void {\n stderr.write(`${text}\\n`)\n}\n\n/**\n * Write text to stderr without adding a newline.\n *\n * @param text - Text to write\n *\n * @example\n * ```ts\n * writeError('Downloading...')\n * // Later update progress\n * ```\n */\nexport function writeError(text: string): void {\n stderr.write(text)\n}\n\n/**\n * Clear the current line on stderr.\n * Only works in TTY environments.\n *\n * @example\n * ```ts\n * writeError('Processing...')\n * clearLine()\n * writeError('Done!')\n * ```\n */\nexport function clearLine(): void {\n if (stderr.isTTY) {\n stderr.cursorTo(0)\n stderr.clearLine(0)\n }\n}\n\n/**\n * Move cursor to specific position on stderr.\n * Only works in TTY environments.\n *\n * @param x - Column position (0-based)\n * @param y - Row position (0-based, optional)\n *\n * @example\n * ```ts\n * cursorTo(0) // Move to start of line\n * cursorTo(10, 5) // Move to column 10, row 5\n * ```\n */\nexport function cursorTo(x: number, y?: number | undefined): void {\n if (stderr.isTTY) {\n stderr.cursorTo(x, y)\n }\n}\n\n/**\n * Check if stderr is connected to a TTY (terminal).\n *\n * @returns `true` if stderr is a TTY, `false` if piped/redirected\n *\n * @example\n * ```ts\n * if (isTTY()) {\n * // Show colored error messages\n * } else {\n * // Use plain text\n * }\n * ```\n */\nexport function isTTY(): boolean {\n return stderr.isTTY || false\n}\n\n/**\n * Get the number of columns (width) in the terminal.\n *\n * @returns Terminal width in characters\n * @default 80\n *\n * @example\n * ```ts\n * const width = getColumns()\n * console.error(`Terminal is ${width} characters wide`)\n * ```\n */\nexport function getColumns(): number {\n return stderr.columns || 80\n}\n\n/**\n * Get the number of rows (height) in the terminal.\n *\n * @returns Terminal height in lines\n * @default 24\n *\n * @example\n * ```ts\n * const height = getRows()\n * console.error(`Terminal is ${height} lines tall`)\n * ```\n */\nexport function getRows(): number {\n return stderr.rows || 24\n}\n\n/**\n * Write a formatted warning message to stderr.\n *\n * @param message - Warning message text\n * @param prefix - Prefix label for the warning\n * @default prefix 'Warning'\n *\n * @example\n * ```ts\n * writeWarning('Deprecated API usage')\n * // Output: 'Warning: Deprecated API usage'\n *\n * writeWarning('Invalid config', 'Config')\n * // Output: 'Config: Invalid config'\n * ```\n */\nexport function writeWarning(\n message: string,\n prefix: string = 'Warning',\n): void {\n const formatted = `${prefix}: ${message}`\n writeErrorLine(formatted)\n}\n\n/**\n * Write a formatted error message to stderr.\n *\n * @param message - Error message text\n * @param prefix - Prefix label for the error\n * @default prefix 'Error'\n *\n * @example\n * ```ts\n * writeErrorFormatted('File not found')\n * // Output: 'Error: File not found'\n *\n * writeErrorFormatted('Connection failed', 'Network')\n * // Output: 'Network: Connection failed'\n * ```\n */\nexport function writeErrorFormatted(\n message: string,\n prefix: string = 'Error',\n): void {\n const formatted = `${prefix}: ${message}`\n writeErrorLine(formatted)\n}\n\n/**\n * Write an error's stack trace to stderr.\n * Falls back to formatted error message if no stack is available.\n *\n * @param error - Error object to write\n *\n * @example\n * ```ts\n * try {\n * throw new Error('Something went wrong')\n * } catch (err) {\n * writeStackTrace(err as Error)\n * }\n * ```\n */\nexport function writeStackTrace(error: Error): void {\n if (error.stack) {\n writeErrorLine(error.stack)\n } else {\n writeErrorFormatted(error.message)\n }\n}\n\n// Export the raw stream for advanced usage\nexport { stderr }\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,MAAM,SAA6B,QAAQ;AAepC,SAAS,eAAe,OAAe,IAAU;AACtD,SAAO,MAAM,GAAG,IAAI;AAAA,CAAI;AAC1B;AAaO,SAAS,WAAW,MAAoB;AAC7C,SAAO,MAAM,IAAI;AACnB;AAaO,SAAS,YAAkB;AAChC,MAAI,OAAO,OAAO;AAChB,WAAO,SAAS,CAAC;AACjB,WAAO,UAAU,CAAC;AAAA,EACpB;AACF;AAeO,SAAS,SAAS,GAAW,GAA8B;AAChE,MAAI,OAAO,OAAO;AAChB,WAAO,SAAS,GAAG,CAAC;AAAA,EACtB;AACF;AAgBO,SAAS,QAAiB;AAC/B,SAAO,OAAO,SAAS;AACzB;AAcO,SAAS,aAAqB;AACnC,SAAO,OAAO,WAAW;AAC3B;AAcO,SAAS,UAAkB;AAChC,SAAO,OAAO,QAAQ;AACxB;AAkBO,SAAS,aACd,SACA,SAAiB,WACX;AACN,QAAM,YAAY,GAAG,MAAM,KAAK,OAAO;AACvC,iBAAe,SAAS;AAC1B;AAkBO,SAAS,oBACd,SACA,SAAiB,SACX;AACN,QAAM,YAAY,GAAG,MAAM,KAAK,OAAO;AACvC,iBAAe,SAAS;AAC1B;AAiBO,SAAS,gBAAgB,OAAoB;AAClD,MAAI,MAAM,OAAO;AACf,mBAAe,MAAM,KAAK;AAAA,EAC5B,OAAO;AACL,wBAAoB,MAAM,OAAO;AAAA,EACnC;AACF;",
6
6
  "names": []
7
7
  }