@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,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/spinner.ts"],
4
- "sourcesContent": ["/**\n * @fileoverview CLI spinner utilities for long-running operations.\n * Provides animated progress indicators with CI environment detection.\n */\n\nimport type { Writable } from 'node:stream'\n\n// Note: getAbortSignal is imported lazily to avoid circular dependencies.\nimport { CI } from '#env/ci'\nimport { generateSocketSpinnerFrames } from './effects/pulse-frames'\nimport type {\n ShimmerColorGradient,\n ShimmerConfig,\n ShimmerDirection,\n ShimmerState,\n} from './effects/text-shimmer'\nimport { applyShimmer, COLOR_INHERIT, DIR_LTR } from './effects/text-shimmer'\nimport yoctoSpinner from './external/@socketregistry/yocto-spinner'\nimport { hasOwn } from './objects'\nimport { isBlankString, stringWidth } from './strings'\n\nexport type ColorName =\n | 'black'\n | 'blue'\n | 'blueBright'\n | 'cyan'\n | 'cyanBright'\n | 'gray'\n | 'green'\n | 'greenBright'\n | 'magenta'\n | 'magentaBright'\n | 'red'\n | 'redBright'\n | 'white'\n | 'whiteBright'\n | 'yellow'\n | 'yellowBright'\n\nexport type ColorInherit = 'inherit'\n\nexport type ColorRgb = readonly [number, number, number]\n\nexport type ColorValue = ColorName | ColorRgb\n\nexport type SymbolType = 'fail' | 'info' | 'success' | 'warn'\n\n// Map color names to RGB values.\nconst colorToRgb: Record<ColorName, ColorRgb> = {\n __proto__: null,\n black: [0, 0, 0],\n blue: [0, 0, 255],\n blueBright: [100, 149, 237],\n cyan: [0, 255, 255],\n cyanBright: [0, 255, 255],\n gray: [128, 128, 128],\n green: [0, 128, 0],\n greenBright: [0, 255, 0],\n magenta: [255, 0, 255],\n magentaBright: [255, 105, 180],\n red: [255, 0, 0],\n redBright: [255, 69, 0],\n white: [255, 255, 255],\n whiteBright: [255, 255, 255],\n yellow: [255, 255, 0],\n yellowBright: [255, 255, 153],\n} as Record<ColorName, ColorRgb>\n\n/**\n * Check if value is RGB tuple.\n */\nfunction isRgbTuple(value: ColorValue): value is ColorRgb {\n return Array.isArray(value)\n}\n\n/**\n * Convert ColorValue to RGB tuple.\n */\nfunction toRgb(color: ColorValue): ColorRgb {\n if (isRgbTuple(color)) {\n return color\n }\n return colorToRgb[color]\n}\n\nexport type ProgressInfo = {\n current: number\n total: number\n unit?: string | undefined\n}\n\nexport type ShimmerInfo = ShimmerState & {\n color: ColorInherit | ColorValue | ShimmerColorGradient\n}\n\nexport type Spinner = {\n color: ColorRgb\n spinner: SpinnerStyle\n\n get isSpinning(): boolean\n\n clear(): Spinner\n debug(text?: string | undefined, ...extras: unknown[]): Spinner\n debugAndStop(text?: string | undefined, ...extras: unknown[]): Spinner\n error(text?: string | undefined, ...extras: unknown[]): Spinner\n errorAndStop(text?: string | undefined, ...extras: unknown[]): Spinner\n fail(text?: string | undefined, ...extras: unknown[]): Spinner\n failAndStop(text?: string | undefined, ...extras: unknown[]): Spinner\n\n // text property returns a method via _textMethod override\n text(value: string): Spinner\n text(): string\n\n indent(spaces?: number | undefined): Spinner\n dedent(spaces?: number | undefined): Spinner\n\n info(text?: string | undefined, ...extras: unknown[]): Spinner\n infoAndStop(text?: string | undefined, ...extras: unknown[]): Spinner\n log(text?: string | undefined, ...extras: unknown[]): Spinner\n logAndStop(text?: string | undefined, ...extras: unknown[]): Spinner\n\n start(text?: string | undefined): Spinner\n stop(text?: string | undefined): Spinner\n stopAndPersist(text?: string | undefined): Spinner\n\n step(text?: string | undefined, ...extras: unknown[]): Spinner\n substep(text?: string | undefined, ...extras: unknown[]): Spinner\n\n success(text?: string | undefined, ...extras: unknown[]): Spinner\n successAndStop(text?: string | undefined, ...extras: unknown[]): Spinner\n\n done(text?: string | undefined, ...extras: unknown[]): Spinner\n doneAndStop(text?: string | undefined, ...extras: unknown[]): Spinner\n\n progress(current: number, total: number, unit?: string | undefined): Spinner\n progressStep(amount?: number): Spinner\n\n shimmer(enabled: boolean): Spinner\n shimmer(config: Partial<ShimmerConfig> | ShimmerDirection): Spinner\n\n warn(text?: string | undefined, ...extras: unknown[]): Spinner\n warnAndStop(text?: string | undefined, ...extras: unknown[]): Spinner\n}\n\nexport type SpinnerOptions = {\n readonly color?: ColorValue | undefined\n readonly shimmer?: ShimmerConfig | ShimmerDirection | undefined\n readonly spinner?: SpinnerStyle | undefined\n readonly signal?: AbortSignal | undefined\n readonly stream?: Writable | undefined\n readonly text?: string | undefined\n}\n\nexport type SpinnerStyle = {\n readonly frames: string[]\n readonly interval?: number | undefined\n}\n\nexport const ciSpinner: SpinnerStyle = {\n frames: [''],\n interval: 2_147_483_647,\n}\n\nfunction desc(value: unknown) {\n return {\n __proto__: null,\n configurable: true,\n value,\n writable: true,\n }\n}\n\nfunction normalizeText(value: unknown) {\n return typeof value === 'string' ? value.trimStart() : ''\n}\n\nfunction formatProgress(progress: ProgressInfo): string {\n const { current, total, unit } = progress\n const percentage = Math.round((current / total) * 100)\n const bar = renderProgressBar(percentage)\n const count = unit ? `${current}/${total} ${unit}` : `${current}/${total}`\n return `${bar} ${percentage}% (${count})`\n}\n\nfunction renderProgressBar(percentage: number, width: number = 20): string {\n const filled = Math.round((percentage / 100) * width)\n const empty = width - filled\n const bar = '\u2588'.repeat(filled) + '\u2591'.repeat(empty)\n // Use cyan color for the progress bar\n const colors = /*@__PURE__*/ require('./external/yoctocolors-cjs')\n return colors.cyan(bar)\n}\n\nlet _cliSpinners: Record<string, SpinnerStyle> | undefined\n\n/**\n * Get available CLI spinner styles or a specific style by name.\n * Extends the standard cli-spinners collection with Socket custom spinners.\n *\n * @see https://github.com/sindresorhus/cli-spinners/blob/main/spinners.json\n *\n * Custom spinners:\n * - `socket` (default): Socket pulse animation with sparkles and lightning\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function getCliSpinners(\n styleName?: string | undefined,\n): SpinnerStyle | Record<string, SpinnerStyle> | undefined {\n if (_cliSpinners === undefined) {\n // biome-ignore lint/suspicious/noExplicitAny: Accessing internal yocto-spinner constructor.\n const YoctoCtor = yoctoSpinner as any\n // Get the YoctoSpinner class to access static properties.\n const tempInstance = YoctoCtor({})\n // biome-ignore lint/suspicious/noExplicitAny: Accessing internal yocto-spinner class.\n const YoctoSpinnerClass = tempInstance.constructor as any\n // Extend the standard cli-spinners collection with Socket custom spinners.\n _cliSpinners = {\n __proto__: null,\n ...YoctoSpinnerClass.spinners,\n socket: generateSocketSpinnerFrames(),\n }\n }\n if (typeof styleName === 'string' && _cliSpinners) {\n return hasOwn(_cliSpinners, styleName) ? _cliSpinners[styleName] : undefined\n }\n return _cliSpinners\n}\n\nlet _Spinner: {\n new (options?: SpinnerOptions | undefined): Spinner\n}\nlet _defaultSpinner: SpinnerStyle | undefined\n\n/**\n * Create a spinner instance for displaying loading indicators.\n *\n * AUTO-CLEAR BEHAVIOR:\n * - All *AndStop() methods AUTO-CLEAR the spinner line via yocto-spinner.stop()\n * Examples: doneAndStop(), successAndStop(), failAndStop(), etc.\n *\n * - Methods WITHOUT \"AndStop\" do NOT clear (spinner keeps spinning)\n * Examples: done(), success(), fail(), etc.\n *\n * STREAM USAGE:\n * - Spinner animation: stderr (yocto-spinner default)\n * - Status methods (done, success, fail, info, warn, step, substep): stderr\n * - Data methods (log): stdout\n *\n * COMPARISON WITH LOGGER:\n * - logger.done() does NOT auto-clear (requires manual logger.clearLine())\n * - spinner.doneAndStop() DOES auto-clear (built into yocto-spinner.stop())\n * - Pattern: logger.clearLine().done() vs spinner.doneAndStop()\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function Spinner(options?: SpinnerOptions | undefined): Spinner {\n if (_Spinner === undefined) {\n // biome-ignore lint/suspicious/noExplicitAny: Accessing internal yocto-spinner constructor.\n const YoctoCtor = yoctoSpinner as any\n // Get the actual YoctoSpinner class from an instance\n const tempInstance = YoctoCtor({})\n const YoctoSpinnerClass = tempInstance.constructor\n\n /*@__PURE__*/\n // biome-ignore lint/suspicious/noExplicitAny: Extending yocto-spinner class.\n _Spinner = class SpinnerClass extends (YoctoSpinnerClass as any) {\n declare isSpinning: boolean\n #baseText: string = ''\n #indentation: string = ''\n #progress?: ProgressInfo | undefined\n #shimmer?: ShimmerInfo | undefined\n #shimmerSavedConfig?: ShimmerInfo | undefined\n\n constructor(options?: SpinnerOptions | undefined) {\n const opts = { __proto__: null, ...options } as SpinnerOptions\n\n // Convert color option to RGB (default to Socket purple).\n const spinnerColor = opts.color ?? ([140, 82, 255] as const)\n\n // Validate RGB tuple if provided.\n if (\n isRgbTuple(spinnerColor) &&\n (spinnerColor.length !== 3 ||\n !spinnerColor.every(\n n => typeof n === 'number' && n >= 0 && n <= 255,\n ))\n ) {\n throw new TypeError(\n 'RGB color must be an array of 3 numbers between 0 and 255',\n )\n }\n\n const spinnerColorRgb = toRgb(spinnerColor)\n\n // Parse shimmer config - can be object or direction string.\n let shimmerInfo: ShimmerInfo | undefined\n if (opts.shimmer) {\n let shimmerDir: ShimmerDirection\n let shimmerColor:\n | ColorInherit\n | ColorValue\n | ShimmerColorGradient\n | undefined\n // Default: 0.33 steps per frame (~150ms per step).\n let shimmerSpeed: number = 1 / 3\n\n if (typeof opts.shimmer === 'string') {\n shimmerDir = opts.shimmer\n } else {\n const shimmerConfig = {\n __proto__: null,\n ...opts.shimmer,\n } as ShimmerConfig\n shimmerDir = shimmerConfig.dir ?? DIR_LTR\n shimmerColor = shimmerConfig.color ?? COLOR_INHERIT\n shimmerSpeed = shimmerConfig.speed ?? 1 / 3\n }\n\n // Create shimmer info with initial animation state:\n // - COLOR_INHERIT means use spinner color dynamically\n // - ColorValue (name or RGB tuple) is an explicit override color\n // - undefined color defaults to COLOR_INHERIT\n // - speed controls steps per frame (lower = slower, e.g., 0.33 = ~150ms per step)\n shimmerInfo = {\n __proto__: null,\n color: shimmerColor === undefined ? COLOR_INHERIT : shimmerColor,\n currentDir: DIR_LTR,\n mode: shimmerDir,\n speed: shimmerSpeed,\n step: 0,\n } as ShimmerInfo\n }\n\n // eslint-disable-next-line constructor-super\n super({\n signal: require('#constants/process').getAbortSignal(),\n ...opts,\n // Pass RGB color directly to yocto-spinner (it now supports RGB).\n color: spinnerColorRgb,\n // onRenderFrame callback provides full control over frame + text layout.\n // Calculates spacing based on frame width to prevent text jumping.\n onRenderFrame: (\n frame: string,\n text: string,\n applyColor: (text: string) => string,\n ) => {\n const width = stringWidth(frame)\n // Narrow frames (width 1) get 2 spaces, wide frames (width 2) get 1 space.\n // Total width is consistent: 3 characters (frame + spacing) before text.\n const spacing = width === 1 ? ' ' : ' '\n return frame ? `${applyColor(frame)}${spacing}${text}` : text\n },\n // onFrameUpdate callback is called by yocto-spinner whenever a frame advances.\n // This ensures shimmer updates are perfectly synchronized with animation beats.\n onFrameUpdate: shimmerInfo\n ? () => {\n // Update parent's text without triggering render.\n // Parent's #skipRender flag prevents nested render calls.\n // Only update if we have base text to avoid blank frames.\n if (this.#baseText) {\n super.text = this.#buildDisplayText()\n }\n }\n : undefined,\n })\n\n this.#shimmer = shimmerInfo\n this.#shimmerSavedConfig = shimmerInfo\n }\n\n // Override color getter to ensure it's always RGB.\n get color(): ColorRgb {\n const value = super.color\n return isRgbTuple(value) ? value : toRgb(value)\n }\n\n // Override color setter to always convert to RGB before passing to yocto-spinner.\n set color(value: ColorValue | ColorRgb) {\n super.color = isRgbTuple(value) ? value : toRgb(value)\n }\n\n /**\n * Apply a yocto-spinner method and update logger state.\n * Handles text normalization, extra arguments, and logger tracking.\n * @private\n */\n #apply(methodName: string, args: unknown[]) {\n let extras: unknown[]\n let text = args.at(0)\n if (typeof text === 'string') {\n extras = args.slice(1)\n } else {\n extras = args\n text = ''\n }\n const wasSpinning = this.isSpinning\n const normalized = normalizeText(text)\n super[methodName](normalized)\n const {\n incLogCallCountSymbol,\n lastWasBlankSymbol,\n logger,\n } = /*@__PURE__*/ require('./logger.js')\n if (methodName === 'stop') {\n if (wasSpinning && normalized) {\n logger[lastWasBlankSymbol](isBlankString(normalized))\n logger[incLogCallCountSymbol]()\n }\n } else {\n logger[lastWasBlankSymbol](false)\n logger[incLogCallCountSymbol]()\n }\n if (extras.length) {\n logger.log(...extras)\n logger[lastWasBlankSymbol](false)\n }\n return this\n }\n\n /**\n * Build the complete display text with progress, shimmer, and indentation.\n * Combines base text, progress bar, shimmer effects, and indentation.\n * @private\n */\n #buildDisplayText() {\n let displayText = this.#baseText\n\n if (this.#progress) {\n const progressText = formatProgress(this.#progress)\n displayText = displayText\n ? `${displayText} ${progressText}`\n : progressText\n }\n\n // Apply shimmer effect if enabled.\n if (displayText && this.#shimmer) {\n // If shimmer color is 'inherit', use current spinner color (getter ensures RGB).\n // Otherwise, check if it's a gradient (array of arrays) or single color.\n let shimmerColor: ColorRgb | ShimmerColorGradient\n if (this.#shimmer.color === COLOR_INHERIT) {\n shimmerColor = this.color\n } else if (Array.isArray(this.#shimmer.color[0])) {\n // It's a gradient - use as is.\n shimmerColor = this.#shimmer.color as ShimmerColorGradient\n } else {\n // It's a single color - convert to RGB.\n shimmerColor = toRgb(this.#shimmer.color as ColorValue)\n }\n\n displayText = applyShimmer(displayText, this.#shimmer, {\n color: shimmerColor,\n direction: this.#shimmer.mode,\n })\n }\n\n // Apply indentation\n if (this.#indentation && displayText) {\n displayText = this.#indentation + displayText\n }\n\n return displayText\n }\n\n /**\n * Show a status message without stopping the spinner.\n * Outputs the symbol and message to stderr, then continues spinning.\n */\n #showStatusAndKeepSpinning(symbolType: SymbolType, args: unknown[]) {\n let text = args.at(0)\n let extras: unknown[]\n if (typeof text === 'string') {\n extras = args.slice(1)\n } else {\n extras = args\n text = ''\n }\n\n const { LOG_SYMBOLS, logger } = /*@__PURE__*/ require('./logger.js')\n // Note: Status messages always go to stderr.\n logger.error(`${LOG_SYMBOLS[symbolType]} ${text}`, ...extras)\n return this\n }\n\n /**\n * Update the spinner's displayed text.\n * Rebuilds display text and triggers render.\n * @private\n */\n #updateSpinnerText() {\n // Call the parent class's text setter, which triggers render.\n super.text = this.#buildDisplayText()\n }\n\n /**\n * Show a debug message without stopping the spinner (only if debug mode enabled).\n * Outputs to stderr and continues spinning.\n */\n debug(...args: unknown[]) {\n const { isDebug } = /*@__PURE__*/ require('./debug.js')\n if (isDebug()) {\n return this.#showStatusAndKeepSpinning('info', args)\n }\n return this\n }\n\n /**\n * Show a debug message and stop the spinner (only if debug mode enabled).\n * Auto-clears the spinner line before displaying the message.\n */\n debugAndStop(...args: unknown[]) {\n const { isDebug } = /*@__PURE__*/ require('./debug.js')\n if (isDebug()) {\n return this.#apply('info', args)\n }\n return this\n }\n\n /**\n * Decrease indentation level.\n * Pass 0 to reset indentation to zero.\n * @param spaces - Number of spaces to remove (default: 2)\n */\n dedent(spaces?: number) {\n // Pass 0 to reset indentation\n if (spaces === 0) {\n this.#indentation = ''\n } else {\n const amount = spaces ?? 2\n const newLength = Math.max(0, this.#indentation.length - amount)\n this.#indentation = this.#indentation.slice(0, newLength)\n }\n this.#updateSpinnerText()\n return this\n }\n\n /**\n * Alias for success() (shorter name).\n * DESIGN DECISION: Unlike yocto-spinner, our done() does NOT stop the spinner.\n * Use doneAndStop() if you want to stop the spinner.\n */\n done(...args: unknown[]) {\n return this.#showStatusAndKeepSpinning('success', args)\n }\n\n /**\n * Show a done message and stop the spinner.\n * Auto-clears the spinner line before displaying the success message.\n */\n doneAndStop(...args: unknown[]) {\n return this.#apply('success', args)\n }\n\n /**\n * Show a failure message without stopping the spinner.\n * DESIGN DECISION: Unlike yocto-spinner, our fail() does NOT stop the spinner.\n * This allows displaying errors while continuing to spin.\n * Use failAndStop() if you want to stop the spinner.\n */\n fail(...args: unknown[]) {\n return this.#showStatusAndKeepSpinning('fail', args)\n }\n\n /**\n * Show a failure message and stop the spinner.\n * Auto-clears the spinner line before displaying the error message.\n */\n failAndStop(...args: unknown[]) {\n return this.#apply('error', args)\n }\n\n /**\n * Increase indentation level.\n * Pass 0 to reset indentation to zero.\n * @param spaces - Number of spaces to add (default: 2)\n */\n indent(spaces?: number) {\n // Pass 0 to reset indentation\n if (spaces === 0) {\n this.#indentation = ''\n } else {\n const amount = spaces ?? 2\n this.#indentation += ' '.repeat(amount)\n }\n this.#updateSpinnerText()\n return this\n }\n\n /**\n * Show an info message without stopping the spinner.\n * Outputs to stderr and continues spinning.\n */\n info(...args: unknown[]) {\n return this.#showStatusAndKeepSpinning('info', args)\n }\n\n /**\n * Show an info message and stop the spinner.\n * Auto-clears the spinner line before displaying the message.\n */\n infoAndStop(...args: unknown[]) {\n return this.#apply('info', args)\n }\n\n /**\n * Log a message to stdout without stopping the spinner.\n * Unlike other methods, this outputs to stdout for data logging.\n */\n log(...args: unknown[]) {\n const { logger } = /*@__PURE__*/ require('./logger.js')\n logger.log(...args)\n return this\n }\n\n /**\n * Log a message and stop the spinner.\n * Auto-clears the spinner line before displaying the message.\n */\n logAndStop(...args: unknown[]) {\n return this.#apply('stop', args)\n }\n\n /**\n * Update progress information displayed with the spinner.\n * Shows a progress bar with percentage and optional unit label.\n * @param current - Current progress value\n * @param total - Total progress value\n * @param unit - Optional unit label (e.g., 'files', 'items')\n */\n progress = (\n current: number,\n total: number,\n unit?: string | undefined,\n ) => {\n this.#progress = {\n __proto__: null,\n current,\n total,\n ...(unit ? { unit } : {}),\n } as ProgressInfo\n this.#updateSpinnerText()\n return this\n }\n\n /**\n * Increment progress by a specified amount.\n * Updates the progress bar displayed with the spinner.\n * @param amount - Amount to increment (default: 1)\n */\n progressStep(amount: number = 1) {\n if (this.#progress) {\n const newCurrent = this.#progress.current + amount\n this.#progress = {\n __proto__: null,\n current: Math.max(0, Math.min(newCurrent, this.#progress.total)),\n total: this.#progress.total,\n ...(this.#progress.unit ? { unit: this.#progress.unit } : {}),\n } as ProgressInfo\n this.#updateSpinnerText()\n }\n return this\n }\n\n /**\n * Start the spinner animation with optional text.\n * Begins displaying the animated spinner.\n * @param text - Optional text to display with the spinner\n */\n start(...args: unknown[]) {\n if (args.length) {\n const text = args.at(0)\n const normalized = normalizeText(text)\n // We clear this.text on start when `text` is falsy because yocto-spinner\n // will not clear it otherwise.\n if (!normalized) {\n this.#baseText = ''\n super.text = ''\n } else {\n this.#baseText = normalized\n }\n }\n\n this.#updateSpinnerText()\n return this.#apply('start', args)\n }\n\n /**\n * Log a main step message to stderr without stopping the spinner.\n * Adds a blank line before the message for visual separation.\n * Aligns with logger.step() to use stderr for status messages.\n */\n step(...args: unknown[]) {\n const text = args[0]\n const { logger } = /*@__PURE__*/ require('./logger.js')\n if (typeof text === 'string') {\n // Add blank line before step for visual separation.\n logger.error('')\n // Use error (stderr) to align with logger.step() default stream.\n logger.error(text, ...args.slice(1))\n }\n return this\n }\n\n /**\n * Log an indented substep message to stderr without stopping the spinner.\n * Adds 2-space indentation to the message.\n * Aligns with logger.substep() to use stderr for status messages.\n */\n substep(...args: unknown[]) {\n const text = args[0]\n if (typeof text === 'string') {\n // Add 2-space indent for substep.\n const { logger } = /*@__PURE__*/ require('./logger.js')\n // Use error (stderr) to align with logger.substep() default stream.\n logger.error(` ${text}`, ...args.slice(1))\n }\n return this\n }\n\n /**\n * Stop the spinner animation and clear internal state.\n * Auto-clears the spinner line via yocto-spinner.stop().\n * Resets progress, shimmer, and text state.\n * @param text - Optional final text to display after stopping\n */\n stop(...args: unknown[]) {\n // Clear internal state.\n this.#baseText = ''\n this.#progress = undefined\n // Reset shimmer animation state if shimmer is enabled.\n if (this.#shimmer) {\n this.#shimmer.currentDir = DIR_LTR\n this.#shimmer.step = 0\n }\n // Call parent stop first (clears screen, sets isSpinning = false).\n const result = this.#apply('stop', args)\n // Then clear text to avoid blank frame render.\n // This is safe now because isSpinning is false.\n super.text = ''\n return result\n }\n\n /**\n * Show a success message without stopping the spinner.\n * DESIGN DECISION: Unlike yocto-spinner, our success() does NOT stop the spinner.\n * This allows displaying success messages while continuing to spin for multi-step operations.\n * Use successAndStop() if you want to stop the spinner.\n */\n success(...args: unknown[]) {\n return this.#showStatusAndKeepSpinning('success', args)\n }\n\n /**\n * Show a success message and stop the spinner.\n * Auto-clears the spinner line before displaying the success message.\n */\n successAndStop(...args: unknown[]) {\n return this.#apply('success', args)\n }\n\n /**\n * Get or set the spinner text.\n * When called with no arguments, returns the current text.\n * When called with text, updates the display and returns the spinner.\n * @param value - Text to display (omit to get current text)\n * @returns Current text (getter) or this spinner (setter)\n */\n text(): string\n text(value: string): Spinner\n text(value?: string): string | Spinner {\n // biome-ignore lint/complexity/noArguments: Function overload for getter/setter pattern.\n if (arguments.length === 0) {\n // Getter: return current base text\n return this.#baseText\n }\n // Setter: update base text and refresh display\n this.#baseText = value ?? ''\n this.#updateSpinnerText()\n return this as unknown as Spinner\n }\n\n /**\n * Show a warning message without stopping the spinner.\n * Outputs to stderr and continues spinning.\n */\n warn(...args: unknown[]) {\n return this.#showStatusAndKeepSpinning('warn', args)\n }\n\n /**\n * Show a warning message and stop the spinner.\n * Auto-clears the spinner line before displaying the warning message.\n */\n warnAndStop(...args: unknown[]) {\n return this.#apply('warning', args)\n }\n\n /**\n * Toggle shimmer effect or update shimmer configuration.\n * Preserves shimmer config when toggling off, allowing easy re-enable.\n * Supports partial config updates to tweak specific properties.\n *\n * @param enabledOrConfig - Boolean to toggle, partial config to update, or direction string\n * @returns This spinner for chaining\n *\n * @example\n * // Toggle off (preserves config for later re-enable)\n * spinner.shimmer(false)\n *\n * // Toggle on (restores saved config or uses defaults)\n * spinner.shimmer(true)\n *\n * // Update specific properties\n * spinner.shimmer({ speed: 0.5 })\n * spinner.shimmer({ color: [255, 0, 0] })\n *\n * // Set direction\n * spinner.shimmer('rtl')\n */\n shimmer(\n enabledOrConfig:\n | boolean\n | Partial<ShimmerConfig>\n | ShimmerDirection\n | undefined,\n ): Spinner {\n if (enabledOrConfig === false) {\n // Disable shimmer but preserve config.\n this.#shimmer = undefined\n } else if (enabledOrConfig === true) {\n // Re-enable with saved config or defaults.\n if (this.#shimmerSavedConfig) {\n // Restore saved config.\n this.#shimmer = { ...this.#shimmerSavedConfig }\n } else {\n // Create default config.\n this.#shimmer = {\n color: COLOR_INHERIT,\n currentDir: DIR_LTR,\n mode: DIR_LTR,\n speed: 1 / 3,\n step: 0,\n } as ShimmerInfo\n this.#shimmerSavedConfig = this.#shimmer\n }\n } else if (typeof enabledOrConfig === 'string') {\n // Direction string - update existing or create new.\n if (this.#shimmer) {\n // Update existing shimmer direction.\n this.#shimmer = {\n ...this.#shimmer,\n mode: enabledOrConfig,\n }\n this.#shimmerSavedConfig = this.#shimmer\n } else if (this.#shimmerSavedConfig) {\n // Restore and update.\n this.#shimmer = {\n ...this.#shimmerSavedConfig,\n mode: enabledOrConfig,\n }\n this.#shimmerSavedConfig = this.#shimmer\n } else {\n // Create new with direction.\n this.#shimmer = {\n color: COLOR_INHERIT,\n currentDir: DIR_LTR,\n mode: enabledOrConfig,\n speed: 1 / 3,\n step: 0,\n } as ShimmerInfo\n this.#shimmerSavedConfig = this.#shimmer\n }\n } else if (enabledOrConfig && typeof enabledOrConfig === 'object') {\n // Partial config update - merge with existing or saved config.\n const partialConfig = {\n __proto__: null,\n ...enabledOrConfig,\n } as Partial<ShimmerConfig>\n\n if (this.#shimmer) {\n // Update existing shimmer.\n this.#shimmer = {\n ...this.#shimmer,\n ...(partialConfig.color !== undefined\n ? { color: partialConfig.color }\n : {}),\n ...(partialConfig.dir !== undefined\n ? { mode: partialConfig.dir }\n : {}),\n ...(partialConfig.speed !== undefined\n ? { speed: partialConfig.speed }\n : {}),\n } as ShimmerInfo\n this.#shimmerSavedConfig = this.#shimmer\n } else if (this.#shimmerSavedConfig) {\n // Restore and update.\n this.#shimmer = {\n ...this.#shimmerSavedConfig,\n ...(partialConfig.color !== undefined\n ? { color: partialConfig.color }\n : {}),\n ...(partialConfig.dir !== undefined\n ? { mode: partialConfig.dir }\n : {}),\n ...(partialConfig.speed !== undefined\n ? { speed: partialConfig.speed }\n : {}),\n } as ShimmerInfo\n this.#shimmerSavedConfig = this.#shimmer\n } else {\n // Create new with partial config.\n this.#shimmer = {\n color: partialConfig.color ?? COLOR_INHERIT,\n currentDir: DIR_LTR,\n mode: partialConfig.dir ?? DIR_LTR,\n speed: partialConfig.speed ?? 1 / 3,\n step: 0,\n } as ShimmerInfo\n this.#shimmerSavedConfig = this.#shimmer\n }\n }\n\n this.#updateSpinnerText()\n return this as unknown as Spinner\n }\n } as unknown as {\n new (options?: SpinnerOptions | undefined): Spinner\n }\n // Add aliases.\n Object.defineProperties(_Spinner.prototype, {\n error: desc(_Spinner.prototype.fail),\n errorAndStop: desc(_Spinner.prototype.failAndStop),\n warning: desc(_Spinner.prototype.warn),\n warningAndStop: desc(_Spinner.prototype.warnAndStop),\n })\n _defaultSpinner = CI\n ? ciSpinner\n : (getCliSpinners('socket') as SpinnerStyle)\n }\n return new _Spinner({\n spinner: _defaultSpinner,\n ...options,\n })\n}\n\nlet _spinner: ReturnType<typeof Spinner> | undefined\n/**\n * Get the default spinner instance.\n * Lazily creates the spinner to avoid circular dependencies during module initialization.\n */\nexport function getDefaultSpinner(): ReturnType<typeof Spinner> {\n if (_spinner === undefined) {\n _spinner = Spinner()\n }\n return _spinner\n}\n\n/**\n * @deprecated Use `getDefaultSpinner()` function instead for better tree-shaking and to avoid circular dependencies.\n */\nexport const spinner = /* @__PURE__ */ (() => {\n // Lazy initialization to prevent circular dependency issues during module loading.\n let _lazySpinner: ReturnType<typeof Spinner> | undefined\n return new Proxy({} as ReturnType<typeof Spinner>, {\n get(_target, prop) {\n if (_lazySpinner === undefined) {\n _lazySpinner = Spinner()\n }\n const value = _lazySpinner[prop as keyof ReturnType<typeof Spinner>]\n return typeof value === 'function' ? value.bind(_lazySpinner) : value\n },\n })\n})()\n\nexport type WithSpinnerOptions<T> = {\n message: string\n operation: () => Promise<T>\n spinner?: Spinner | undefined\n}\n\n/**\n * Execute an async operation with spinner lifecycle management.\n * Ensures spinner.stop() is always called via try/finally, even if the operation throws.\n *\n * @param options - Configuration object\n * @param options.message - Message to display while spinner is running\n * @param options.operation - Async function to execute\n * @param options.spinner - Optional spinner instance (if not provided, no spinner is used)\n * @returns Result of the operation\n * @throws Re-throws any error from operation after stopping spinner\n *\n * @example\n * import { spinner, withSpinner } from '@socketsecurity/registry/lib/spinner'\n *\n * // With spinner instance\n * await withSpinner({\n * message: 'Processing\u2026',\n * operation: async () => {\n * return await processData()\n * },\n * spinner\n * })\n *\n * // Without spinner instance (no-op)\n * await withSpinner({\n * message: 'Processing\u2026',\n * operation: async () => {\n * return await processData()\n * }\n * })\n */\nexport async function withSpinner<T>(\n options: WithSpinnerOptions<T>,\n): Promise<T> {\n const { message, operation, spinner } = {\n __proto__: null,\n ...options,\n } as WithSpinnerOptions<T>\n\n if (!spinner) {\n return await operation()\n }\n\n spinner.start(message)\n try {\n return await operation()\n } finally {\n spinner.stop()\n }\n}\n\nexport type WithSpinnerRestoreOptions<T> = {\n operation: () => Promise<T>\n spinner?: Spinner | undefined\n wasSpinning: boolean\n}\n\n/**\n * Execute an async operation with conditional spinner restart.\n * Useful when you need to temporarily stop a spinner for an operation,\n * then restore it to its previous state.\n *\n * @param options - Configuration object\n * @param options.operation - Async function to execute\n * @param options.spinner - Optional spinner instance to manage\n * @param options.wasSpinning - Whether spinner was spinning before\n * @returns Result of the operation\n * @throws Re-throws any error from operation after restoring spinner state\n *\n * @example\n * import { spinner, withSpinnerRestore } from '@socketsecurity/registry/lib/spinner'\n *\n * const wasSpinning = spinner.isSpinning\n * spinner.stop()\n *\n * const result = await withSpinnerRestore({\n * operation: async () => {\n * // Do work without spinner\n * return await someOperation()\n * },\n * spinner,\n * wasSpinning\n * })\n */\nexport async function withSpinnerRestore<T>(\n options: WithSpinnerRestoreOptions<T>,\n): Promise<T> {\n const { operation, spinner, wasSpinning } = {\n __proto__: null,\n ...options,\n } as WithSpinnerRestoreOptions<T>\n\n try {\n return await operation()\n } finally {\n if (spinner && wasSpinning) {\n spinner.start()\n }\n }\n}\n\nexport type WithSpinnerSyncOptions<T> = {\n message: string\n operation: () => T\n spinner?: Spinner | undefined\n}\n\n/**\n * Execute a synchronous operation with spinner lifecycle management.\n * Ensures spinner.stop() is always called via try/finally, even if the operation throws.\n *\n * @param options - Configuration object\n * @param options.message - Message to display while spinner is running\n * @param options.operation - Function to execute\n * @param options.spinner - Optional spinner instance (if not provided, no spinner is used)\n * @returns Result of the operation\n * @throws Re-throws any error from operation after stopping spinner\n *\n * @example\n * import { spinner, withSpinnerSync} from '@socketsecurity/registry/lib/spinner'\n *\n * const result = withSpinnerSync({\n * message: 'Processing\u2026',\n * operation: () => {\n * return processDataSync()\n * },\n * spinner\n * })\n */\nexport function withSpinnerSync<T>(options: WithSpinnerSyncOptions<T>): T {\n const { message, operation, spinner } = {\n __proto__: null,\n ...options,\n } as WithSpinnerSyncOptions<T>\n\n if (!spinner) {\n return operation()\n }\n\n spinner.start(message)\n try {\n return operation()\n } finally {\n spinner.stop()\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA,gBAAmB;AACnB,0BAA4C;AAO5C,0BAAqD;AACrD,2BAAyB;AACzB,qBAAuB;AACvB,qBAA2C;AA6B3C,MAAM,aAA0C;AAAA,EAC9C,WAAW;AAAA,EACX,OAAO,CAAC,GAAG,GAAG,CAAC;AAAA,EACf,MAAM,CAAC,GAAG,GAAG,GAAG;AAAA,EAChB,YAAY,CAAC,KAAK,KAAK,GAAG;AAAA,EAC1B,MAAM,CAAC,GAAG,KAAK,GAAG;AAAA,EAClB,YAAY,CAAC,GAAG,KAAK,GAAG;AAAA,EACxB,MAAM,CAAC,KAAK,KAAK,GAAG;AAAA,EACpB,OAAO,CAAC,GAAG,KAAK,CAAC;AAAA,EACjB,aAAa,CAAC,GAAG,KAAK,CAAC;AAAA,EACvB,SAAS,CAAC,KAAK,GAAG,GAAG;AAAA,EACrB,eAAe,CAAC,KAAK,KAAK,GAAG;AAAA,EAC7B,KAAK,CAAC,KAAK,GAAG,CAAC;AAAA,EACf,WAAW,CAAC,KAAK,IAAI,CAAC;AAAA,EACtB,OAAO,CAAC,KAAK,KAAK,GAAG;AAAA,EACrB,aAAa,CAAC,KAAK,KAAK,GAAG;AAAA,EAC3B,QAAQ,CAAC,KAAK,KAAK,CAAC;AAAA,EACpB,cAAc,CAAC,KAAK,KAAK,GAAG;AAC9B;AAKA,SAAS,WAAW,OAAsC;AACxD,SAAO,MAAM,QAAQ,KAAK;AAC5B;AAKA,SAAS,MAAM,OAA6B;AAC1C,MAAI,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AAA,IACX,GAAG;AAAA,EACL;AAEA,MAAI;AACF,WAAO,MAAM,UAAU;AAAA,EACzB,UAAE;AACA,QAAIA,YAAW,aAAa;AAC1B,MAAAA,SAAQ,MAAM;AAAA,IAChB;AAAA,EACF;AACF;AA8BO,SAAS,gBAAmB,SAAuC;AACxE,QAAM,EAAE,SAAS,WAAW,SAAAA,SAAQ,IAAI;AAAA,IACtC,WAAW;AAAA,IACX,GAAG;AAAA,EACL;AAEA,MAAI,CAACA,UAAS;AACZ,WAAO,UAAU;AAAA,EACnB;AAEA,EAAAA,SAAQ,MAAM,OAAO;AACrB,MAAI;AACF,WAAO,UAAU;AAAA,EACnB,UAAE;AACA,IAAAA,SAAQ,KAAK;AAAA,EACf;AACF;",
4
+ "sourcesContent": ["/**\n * @fileoverview CLI spinner utilities for long-running operations.\n * Provides animated progress indicators with CI environment detection.\n */\n\nimport type { Writable } from 'node:stream'\n\n// Note: getAbortSignal is imported lazily to avoid circular dependencies.\nimport { CI } from '#env/ci'\nimport { generateSocketSpinnerFrames } from './effects/pulse-frames'\nimport type {\n ShimmerColorGradient,\n ShimmerConfig,\n ShimmerDirection,\n ShimmerState,\n} from './effects/text-shimmer'\nimport { applyShimmer, COLOR_INHERIT, DIR_LTR } from './effects/text-shimmer'\nimport yoctoSpinner from './external/@socketregistry/yocto-spinner'\nimport { hasOwn } from './objects'\nimport { isBlankString, stringWidth } from './strings'\n\n/**\n * Named color values supported by the spinner.\n * Maps to standard terminal colors with bright variants.\n */\nexport type ColorName =\n | 'black'\n | 'blue'\n | 'blueBright'\n | 'cyan'\n | 'cyanBright'\n | 'gray'\n | 'green'\n | 'greenBright'\n | 'magenta'\n | 'magentaBright'\n | 'red'\n | 'redBright'\n | 'white'\n | 'whiteBright'\n | 'yellow'\n | 'yellowBright'\n\n/**\n * Special 'inherit' color value that uses the spinner's current color.\n * Used with shimmer effects to dynamically inherit the spinner color.\n */\nexport type ColorInherit = 'inherit'\n\n/**\n * RGB color tuple with values 0-255 for red, green, and blue channels.\n * @example [140, 82, 255] // Socket purple\n * @example [255, 0, 0] // Red\n */\nexport type ColorRgb = readonly [number, number, number]\n\n/**\n * Union of all supported color types: named colors or RGB tuples.\n */\nexport type ColorValue = ColorName | ColorRgb\n\n/**\n * Symbol types for status messages.\n * Maps to log symbols: success (\u2713), fail (\u2717), info (\u2139), warn (\u26A0).\n */\nexport type SymbolType = 'fail' | 'info' | 'success' | 'warn'\n\n// Map color names to RGB values.\nconst colorToRgb: Record<ColorName, ColorRgb> = {\n __proto__: null,\n black: [0, 0, 0],\n blue: [0, 0, 255],\n blueBright: [100, 149, 237],\n cyan: [0, 255, 255],\n cyanBright: [0, 255, 255],\n gray: [128, 128, 128],\n green: [0, 128, 0],\n greenBright: [0, 255, 0],\n magenta: [255, 0, 255],\n magentaBright: [255, 105, 180],\n red: [255, 0, 0],\n redBright: [255, 69, 0],\n white: [255, 255, 255],\n whiteBright: [255, 255, 255],\n yellow: [255, 255, 0],\n yellowBright: [255, 255, 153],\n} as Record<ColorName, ColorRgb>\n\n/**\n * Type guard to check if a color value is an RGB tuple.\n * @param value - Color value to check\n * @returns `true` if value is an RGB tuple, `false` if it's a color name\n */\nfunction isRgbTuple(value: ColorValue): value is ColorRgb {\n return Array.isArray(value)\n}\n\n/**\n * Convert a color value to RGB tuple format.\n * Named colors are looked up in the `colorToRgb` map, RGB tuples are returned as-is.\n * @param color - Color name or RGB tuple\n * @returns RGB tuple with values 0-255\n */\nfunction toRgb(color: ColorValue): ColorRgb {\n if (isRgbTuple(color)) {\n return color\n }\n return colorToRgb[color]\n}\n\n/**\n * Progress tracking information for display in spinner.\n * Used by `progress()` and `progressStep()` methods to show animated progress bars.\n */\nexport type ProgressInfo = {\n /** Current progress value */\n current: number\n /** Total/maximum progress value */\n total: number\n /** Optional unit label displayed after the progress count (e.g., 'files', 'items') */\n unit?: string | undefined\n}\n\n/**\n * Internal shimmer state with color configuration.\n * Extends `ShimmerState` with additional color property that can be inherited from spinner.\n */\nexport type ShimmerInfo = ShimmerState & {\n /** Color for shimmer effect - can inherit from spinner, use explicit color, or gradient */\n color: ColorInherit | ColorValue | ShimmerColorGradient\n}\n\n/**\n * Spinner instance for displaying animated loading indicators.\n * Provides methods for status updates, progress tracking, and text shimmer effects.\n *\n * KEY BEHAVIORS:\n * - Methods WITHOUT \"AndStop\" keep the spinner running (e.g., `success()`, `fail()`)\n * - Methods WITH \"AndStop\" auto-clear the spinner line (e.g., `successAndStop()`, `failAndStop()`)\n * - Status messages (done, success, fail, info, warn, step, substep) go to stderr\n * - Data messages (`log()`) go to stdout\n *\n * @example\n * ```ts\n * import { Spinner } from '@socketsecurity/registry/lib/spinner'\n *\n * const spinner = Spinner({ text: 'Loading\u2026' })\n * spinner.start()\n *\n * // Show success while continuing to spin\n * spinner.success('Step 1 complete')\n *\n * // Stop the spinner with success message\n * spinner.successAndStop('All done!')\n * ```\n */\nexport type Spinner = {\n /** Current spinner color as RGB tuple */\n color: ColorRgb\n /** Current spinner animation style */\n spinner: SpinnerStyle\n\n /** Whether spinner is currently animating */\n get isSpinning(): boolean\n\n /** Clear the current line without stopping the spinner */\n clear(): Spinner\n\n /** Show debug message without stopping (only if debug mode enabled) */\n debug(text?: string | undefined, ...extras: unknown[]): Spinner\n /** Show debug message and stop the spinner (only if debug mode enabled) */\n debugAndStop(text?: string | undefined, ...extras: unknown[]): Spinner\n\n /** Alias for `fail()` - show error without stopping */\n error(text?: string | undefined, ...extras: unknown[]): Spinner\n /** Alias for `failAndStop()` - show error and stop */\n errorAndStop(text?: string | undefined, ...extras: unknown[]): Spinner\n\n /** Show failure (\u2717) without stopping the spinner */\n fail(text?: string | undefined, ...extras: unknown[]): Spinner\n /** Show failure (\u2717) and stop the spinner, auto-clearing the line */\n failAndStop(text?: string | undefined, ...extras: unknown[]): Spinner\n\n /** Get current spinner text (getter) or set new text (setter) */\n text(value: string): Spinner\n text(): string\n\n /** Increase indentation by specified spaces (default: 2) */\n indent(spaces?: number | undefined): Spinner\n /** Decrease indentation by specified spaces (default: 2) */\n dedent(spaces?: number | undefined): Spinner\n\n /** Show info (\u2139) message without stopping the spinner */\n info(text?: string | undefined, ...extras: unknown[]): Spinner\n /** Show info (\u2139) message and stop the spinner, auto-clearing the line */\n infoAndStop(text?: string | undefined, ...extras: unknown[]): Spinner\n\n /** Log to stdout without stopping the spinner */\n log(text?: string | undefined, ...extras: unknown[]): Spinner\n /** Log and stop the spinner, auto-clearing the line */\n logAndStop(text?: string | undefined, ...extras: unknown[]): Spinner\n\n /** Start spinning with optional text */\n start(text?: string | undefined): Spinner\n /** Stop spinning and clear internal state, auto-clearing the line */\n stop(text?: string | undefined): Spinner\n /** Stop and show final text without clearing the line */\n stopAndPersist(text?: string | undefined): Spinner\n\n /** Show main step message to stderr without stopping */\n step(text?: string | undefined, ...extras: unknown[]): Spinner\n /** Show indented substep message to stderr without stopping */\n substep(text?: string | undefined, ...extras: unknown[]): Spinner\n\n /** Show success (\u2713) without stopping the spinner */\n success(text?: string | undefined, ...extras: unknown[]): Spinner\n /** Show success (\u2713) and stop the spinner, auto-clearing the line */\n successAndStop(text?: string | undefined, ...extras: unknown[]): Spinner\n\n /** Alias for `success()` - show success without stopping */\n done(text?: string | undefined, ...extras: unknown[]): Spinner\n /** Alias for `successAndStop()` - show success and stop */\n doneAndStop(text?: string | undefined, ...extras: unknown[]): Spinner\n\n /** Update progress bar with current/total values and optional unit */\n progress(current: number, total: number, unit?: string | undefined): Spinner\n /** Increment progress by specified amount (default: 1) */\n progressStep(amount?: number): Spinner\n\n /** Toggle shimmer effect on/off */\n shimmer(enabled: boolean): Spinner\n /** Update shimmer configuration or set direction */\n shimmer(config: Partial<ShimmerConfig> | ShimmerDirection): Spinner\n\n /** Show warning (\u26A0) without stopping the spinner */\n warn(text?: string | undefined, ...extras: unknown[]): Spinner\n /** Show warning (\u26A0) and stop the spinner, auto-clearing the line */\n warnAndStop(text?: string | undefined, ...extras: unknown[]): Spinner\n}\n\n/**\n * Configuration options for creating a spinner instance.\n */\nexport type SpinnerOptions = {\n /**\n * Spinner color as RGB tuple or color name.\n * @default [140, 82, 255] Socket purple\n */\n readonly color?: ColorValue | undefined\n /**\n * Shimmer effect configuration or direction string.\n * When enabled, text will have an animated shimmer effect.\n * @default undefined No shimmer effect\n */\n readonly shimmer?: ShimmerConfig | ShimmerDirection | undefined\n /**\n * Animation style with frames and timing.\n * @default 'socket' Custom Socket animation in CLI, minimal in CI\n */\n readonly spinner?: SpinnerStyle | undefined\n /**\n * Abort signal for cancelling the spinner.\n * @default getAbortSignal() from process constants\n */\n readonly signal?: AbortSignal | undefined\n /**\n * Output stream for spinner rendering.\n * @default process.stderr\n */\n readonly stream?: Writable | undefined\n /**\n * Initial text to display with the spinner.\n * @default undefined No initial text\n */\n readonly text?: string | undefined\n}\n\n/**\n * Animation style definition for spinner frames.\n * Defines the visual appearance and timing of the spinner animation.\n */\nexport type SpinnerStyle = {\n /** Array of animation frames (strings to display sequentially) */\n readonly frames: string[]\n /**\n * Milliseconds between frame changes.\n * @default 80 Standard frame rate\n */\n readonly interval?: number | undefined\n}\n\n/**\n * Minimal spinner style for CI environments.\n * Uses empty frame and max interval to effectively disable animation in CI.\n */\nexport const ciSpinner: SpinnerStyle = {\n frames: [''],\n interval: 2_147_483_647,\n}\n\n/**\n * Create a property descriptor for defining non-enumerable properties.\n * Used for adding aliased methods to the Spinner prototype.\n * @param value - Value for the property\n * @returns Property descriptor object\n * @private\n */\nfunction desc(value: unknown) {\n return {\n __proto__: null,\n configurable: true,\n value,\n writable: true,\n }\n}\n\n/**\n * Normalize text input by trimming leading whitespace.\n * Non-string values are converted to empty string.\n * @param value - Text to normalize\n * @returns Normalized string with leading whitespace removed\n * @private\n */\nfunction normalizeText(value: unknown) {\n return typeof value === 'string' ? value.trimStart() : ''\n}\n\n/**\n * Format progress information as a visual progress bar with percentage and count.\n * @param progress - Progress tracking information\n * @returns Formatted string with colored progress bar, percentage, and count\n * @private\n * @example \"\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591 35% (7/20 files)\"\n */\nfunction formatProgress(progress: ProgressInfo): string {\n const { current, total, unit } = progress\n const percentage = Math.round((current / total) * 100)\n const bar = renderProgressBar(percentage)\n const count = unit ? `${current}/${total} ${unit}` : `${current}/${total}`\n return `${bar} ${percentage}% (${count})`\n}\n\n/**\n * Render a progress bar using block characters (\u2588 for filled, \u2591 for empty).\n * @param percentage - Progress percentage (0-100)\n * @param width - Total width of progress bar in characters\n * @returns Colored progress bar string\n * @default width=20\n * @private\n */\nfunction renderProgressBar(percentage: number, width: number = 20): string {\n const filled = Math.round((percentage / 100) * width)\n const empty = width - filled\n const bar = '\u2588'.repeat(filled) + '\u2591'.repeat(empty)\n // Use cyan color for the progress bar\n const colors = /*@__PURE__*/ require('./external/yoctocolors-cjs')\n return colors.cyan(bar)\n}\n\nlet _cliSpinners: Record<string, SpinnerStyle> | undefined\n\n/**\n * Get available CLI spinner styles or a specific style by name.\n * Extends the standard cli-spinners collection with Socket custom spinners.\n *\n * Custom spinners:\n * - `socket` (default): Socket pulse animation with sparkles and lightning\n *\n * @param styleName - Optional name of specific spinner style to retrieve\n * @returns Specific spinner style if name provided, all styles if omitted, `undefined` if style not found\n * @see https://github.com/sindresorhus/cli-spinners/blob/main/spinners.json\n *\n * @example\n * ```ts\n * // Get all available spinner styles\n * const allSpinners = getCliSpinners()\n *\n * // Get specific style\n * const socketStyle = getCliSpinners('socket')\n * const dotsStyle = getCliSpinners('dots')\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function getCliSpinners(\n styleName?: string | undefined,\n): SpinnerStyle | Record<string, SpinnerStyle> | undefined {\n if (_cliSpinners === undefined) {\n const YoctoCtor = yoctoSpinner as any\n // Get the YoctoSpinner class to access static properties.\n const tempInstance = YoctoCtor({})\n const YoctoSpinnerClass = tempInstance.constructor as any\n // Extend the standard cli-spinners collection with Socket custom spinners.\n _cliSpinners = {\n __proto__: null,\n ...YoctoSpinnerClass.spinners,\n socket: generateSocketSpinnerFrames(),\n }\n }\n if (typeof styleName === 'string' && _cliSpinners) {\n return hasOwn(_cliSpinners, styleName) ? _cliSpinners[styleName] : undefined\n }\n return _cliSpinners\n}\n\nlet _Spinner: {\n new (options?: SpinnerOptions | undefined): Spinner\n}\nlet _defaultSpinner: SpinnerStyle | undefined\n\n/**\n * Create a spinner instance for displaying loading indicators.\n * Provides an animated CLI spinner with status messages, progress tracking, and shimmer effects.\n *\n * AUTO-CLEAR BEHAVIOR:\n * - All *AndStop() methods AUTO-CLEAR the spinner line via yocto-spinner.stop()\n * Examples: `doneAndStop()`, `successAndStop()`, `failAndStop()`, etc.\n *\n * - Methods WITHOUT \"AndStop\" do NOT clear (spinner keeps spinning)\n * Examples: `done()`, `success()`, `fail()`, etc.\n *\n * STREAM USAGE:\n * - Spinner animation: stderr (yocto-spinner default)\n * - Status methods (done, success, fail, info, warn, step, substep): stderr\n * - Data methods (`log()`): stdout\n *\n * COMPARISON WITH LOGGER:\n * - `logger.done()` does NOT auto-clear (requires manual `logger.clearLine()`)\n * - `spinner.doneAndStop()` DOES auto-clear (built into yocto-spinner.stop())\n * - Pattern: `logger.clearLine().done()` vs `spinner.doneAndStop()`\n *\n * @param options - Configuration options for the spinner\n * @returns New spinner instance\n *\n * @example\n * ```ts\n * import { Spinner } from '@socketsecurity/registry/lib/spinner'\n *\n * // Basic usage\n * const spinner = Spinner({ text: 'Loading data\u2026' })\n * spinner.start()\n * await fetchData()\n * spinner.successAndStop('Data loaded!')\n *\n * // With custom color\n * const spinner = Spinner({\n * text: 'Processing\u2026',\n * color: [255, 0, 0] // Red\n * })\n *\n * // With shimmer effect\n * const spinner = Spinner({\n * text: 'Building\u2026',\n * shimmer: { dir: 'ltr', speed: 0.5 }\n * })\n *\n * // Show progress\n * spinner.progress(5, 10, 'files')\n * spinner.progressStep() // Increment by 1\n * ```\n */\n/*@__NO_SIDE_EFFECTS__*/\nexport function Spinner(options?: SpinnerOptions | undefined): Spinner {\n if (_Spinner === undefined) {\n const YoctoCtor = yoctoSpinner as any\n // Get the actual YoctoSpinner class from an instance\n const tempInstance = YoctoCtor({})\n const YoctoSpinnerClass = tempInstance.constructor\n\n /*@__PURE__*/\n _Spinner = class SpinnerClass extends (YoctoSpinnerClass as any) {\n declare isSpinning: boolean\n #baseText: string = ''\n #indentation: string = ''\n #progress?: ProgressInfo | undefined\n #shimmer?: ShimmerInfo | undefined\n #shimmerSavedConfig?: ShimmerInfo | undefined\n\n constructor(options?: SpinnerOptions | undefined) {\n const opts = { __proto__: null, ...options } as SpinnerOptions\n\n // Convert color option to RGB (default to Socket purple).\n const spinnerColor = opts.color ?? ([140, 82, 255] as const)\n\n // Validate RGB tuple if provided.\n if (\n isRgbTuple(spinnerColor) &&\n (spinnerColor.length !== 3 ||\n !spinnerColor.every(\n n => typeof n === 'number' && n >= 0 && n <= 255,\n ))\n ) {\n throw new TypeError(\n 'RGB color must be an array of 3 numbers between 0 and 255',\n )\n }\n\n const spinnerColorRgb = toRgb(spinnerColor)\n\n // Parse shimmer config - can be object or direction string.\n let shimmerInfo: ShimmerInfo | undefined\n if (opts.shimmer) {\n let shimmerDir: ShimmerDirection\n let shimmerColor:\n | ColorInherit\n | ColorValue\n | ShimmerColorGradient\n | undefined\n // Default: 0.33 steps per frame (~150ms per step).\n let shimmerSpeed: number = 1 / 3\n\n if (typeof opts.shimmer === 'string') {\n shimmerDir = opts.shimmer\n } else {\n const shimmerConfig = {\n __proto__: null,\n ...opts.shimmer,\n } as ShimmerConfig\n shimmerDir = shimmerConfig.dir ?? DIR_LTR\n shimmerColor = shimmerConfig.color ?? COLOR_INHERIT\n shimmerSpeed = shimmerConfig.speed ?? 1 / 3\n }\n\n // Create shimmer info with initial animation state:\n // - COLOR_INHERIT means use spinner color dynamically\n // - ColorValue (name or RGB tuple) is an explicit override color\n // - undefined color defaults to COLOR_INHERIT\n // - speed controls steps per frame (lower = slower, e.g., 0.33 = ~150ms per step)\n shimmerInfo = {\n __proto__: null,\n color: shimmerColor === undefined ? COLOR_INHERIT : shimmerColor,\n currentDir: DIR_LTR,\n mode: shimmerDir,\n speed: shimmerSpeed,\n step: 0,\n } as ShimmerInfo\n }\n\n // eslint-disable-next-line constructor-super\n super({\n signal: require('#constants/process').getAbortSignal(),\n ...opts,\n // Pass RGB color directly to yocto-spinner (it now supports RGB).\n color: spinnerColorRgb,\n // onRenderFrame callback provides full control over frame + text layout.\n // Calculates spacing based on frame width to prevent text jumping.\n onRenderFrame: (\n frame: string,\n text: string,\n applyColor: (text: string) => string,\n ) => {\n const width = stringWidth(frame)\n // Narrow frames (width 1) get 2 spaces, wide frames (width 2) get 1 space.\n // Total width is consistent: 3 characters (frame + spacing) before text.\n const spacing = width === 1 ? ' ' : ' '\n return frame ? `${applyColor(frame)}${spacing}${text}` : text\n },\n // onFrameUpdate callback is called by yocto-spinner whenever a frame advances.\n // This ensures shimmer updates are perfectly synchronized with animation beats.\n onFrameUpdate: shimmerInfo\n ? () => {\n // Update parent's text without triggering render.\n // Parent's #skipRender flag prevents nested render calls.\n // Only update if we have base text to avoid blank frames.\n if (this.#baseText) {\n super.text = this.#buildDisplayText()\n }\n }\n : undefined,\n })\n\n this.#shimmer = shimmerInfo\n this.#shimmerSavedConfig = shimmerInfo\n }\n\n // Override color getter to ensure it's always RGB.\n get color(): ColorRgb {\n const value = super.color\n return isRgbTuple(value) ? value : toRgb(value)\n }\n\n // Override color setter to always convert to RGB before passing to yocto-spinner.\n set color(value: ColorValue | ColorRgb) {\n super.color = isRgbTuple(value) ? value : toRgb(value)\n }\n\n /**\n * Apply a yocto-spinner method and update logger state.\n * Handles text normalization, extra arguments, and logger tracking.\n * @private\n */\n #apply(methodName: string, args: unknown[]) {\n let extras: unknown[]\n let text = args.at(0)\n if (typeof text === 'string') {\n extras = args.slice(1)\n } else {\n extras = args\n text = ''\n }\n const wasSpinning = this.isSpinning\n const normalized = normalizeText(text)\n super[methodName](normalized)\n const {\n incLogCallCountSymbol,\n lastWasBlankSymbol,\n logger,\n } = /*@__PURE__*/ require('./logger.js')\n if (methodName === 'stop') {\n if (wasSpinning && normalized) {\n logger[lastWasBlankSymbol](isBlankString(normalized))\n logger[incLogCallCountSymbol]()\n }\n } else {\n logger[lastWasBlankSymbol](false)\n logger[incLogCallCountSymbol]()\n }\n if (extras.length) {\n logger.log(...extras)\n logger[lastWasBlankSymbol](false)\n }\n return this\n }\n\n /**\n * Build the complete display text with progress, shimmer, and indentation.\n * Combines base text, progress bar, shimmer effects, and indentation.\n * @private\n */\n #buildDisplayText() {\n let displayText = this.#baseText\n\n if (this.#progress) {\n const progressText = formatProgress(this.#progress)\n displayText = displayText\n ? `${displayText} ${progressText}`\n : progressText\n }\n\n // Apply shimmer effect if enabled.\n if (displayText && this.#shimmer) {\n // If shimmer color is 'inherit', use current spinner color (getter ensures RGB).\n // Otherwise, check if it's a gradient (array of arrays) or single color.\n let shimmerColor: ColorRgb | ShimmerColorGradient\n if (this.#shimmer.color === COLOR_INHERIT) {\n shimmerColor = this.color\n } else if (Array.isArray(this.#shimmer.color[0])) {\n // It's a gradient - use as is.\n shimmerColor = this.#shimmer.color as ShimmerColorGradient\n } else {\n // It's a single color - convert to RGB.\n shimmerColor = toRgb(this.#shimmer.color as ColorValue)\n }\n\n displayText = applyShimmer(displayText, this.#shimmer, {\n color: shimmerColor,\n direction: this.#shimmer.mode,\n })\n }\n\n // Apply indentation\n if (this.#indentation && displayText) {\n displayText = this.#indentation + displayText\n }\n\n return displayText\n }\n\n /**\n * Show a status message without stopping the spinner.\n * Outputs the symbol and message to stderr, then continues spinning.\n */\n #showStatusAndKeepSpinning(symbolType: SymbolType, args: unknown[]) {\n let text = args.at(0)\n let extras: unknown[]\n if (typeof text === 'string') {\n extras = args.slice(1)\n } else {\n extras = args\n text = ''\n }\n\n const { LOG_SYMBOLS, logger } = /*@__PURE__*/ require('./logger.js')\n // Note: Status messages always go to stderr.\n logger.error(`${LOG_SYMBOLS[symbolType]} ${text}`, ...extras)\n return this\n }\n\n /**\n * Update the spinner's displayed text.\n * Rebuilds display text and triggers render.\n * @private\n */\n #updateSpinnerText() {\n // Call the parent class's text setter, which triggers render.\n super.text = this.#buildDisplayText()\n }\n\n /**\n * Show a debug message (\u2139) without stopping the spinner.\n * Only displays if debug mode is enabled via environment variable.\n * Outputs to stderr and continues spinning.\n *\n * @param text - Debug message to display\n * @param extras - Additional values to log\n * @returns This spinner for chaining\n */\n debug(text?: string | undefined, ...extras: unknown[]) {\n const { isDebug } = /*@__PURE__*/ require('./debug.js')\n if (isDebug()) {\n return this.#showStatusAndKeepSpinning('info', [text, ...extras])\n }\n return this\n }\n\n /**\n * Show a debug message (\u2139) and stop the spinner.\n * Only displays if debug mode is enabled via environment variable.\n * Auto-clears the spinner line before displaying the message.\n *\n * @param text - Debug message to display\n * @param extras - Additional values to log\n * @returns This spinner for chaining\n */\n debugAndStop(text?: string | undefined, ...extras: unknown[]) {\n const { isDebug } = /*@__PURE__*/ require('./debug.js')\n if (isDebug()) {\n return this.#apply('info', [text, ...extras])\n }\n return this\n }\n\n /**\n * Decrease indentation level by removing spaces from the left.\n * Pass 0 to reset indentation to zero completely.\n *\n * @param spaces - Number of spaces to remove\n * @returns This spinner for chaining\n * @default spaces=2\n *\n * @example\n * ```ts\n * spinner.dedent() // Remove 2 spaces\n * spinner.dedent(4) // Remove 4 spaces\n * spinner.dedent(0) // Reset to zero indentation\n * ```\n */\n dedent(spaces?: number | undefined) {\n // Pass 0 to reset indentation\n if (spaces === 0) {\n this.#indentation = ''\n } else {\n const amount = spaces ?? 2\n const newLength = Math.max(0, this.#indentation.length - amount)\n this.#indentation = this.#indentation.slice(0, newLength)\n }\n this.#updateSpinnerText()\n return this\n }\n\n /**\n * Show a done/success message (\u2713) without stopping the spinner.\n * Alias for `success()` with a shorter name.\n *\n * DESIGN DECISION: Unlike yocto-spinner, our `done()` does NOT stop the spinner.\n * Use `doneAndStop()` if you want to stop the spinner.\n *\n * @param text - Message to display\n * @param extras - Additional values to log\n * @returns This spinner for chaining\n */\n done(text?: string | undefined, ...extras: unknown[]) {\n return this.#showStatusAndKeepSpinning('success', [text, ...extras])\n }\n\n /**\n * Show a done/success message (\u2713) and stop the spinner.\n * Auto-clears the spinner line before displaying the success message.\n *\n * @param text - Message to display\n * @param extras - Additional values to log\n * @returns This spinner for chaining\n */\n doneAndStop(text?: string | undefined, ...extras: unknown[]) {\n return this.#apply('success', [text, ...extras])\n }\n\n /**\n * Show a failure message (\u2717) without stopping the spinner.\n * DESIGN DECISION: Unlike yocto-spinner, our `fail()` does NOT stop the spinner.\n * This allows displaying errors while continuing to spin.\n * Use `failAndStop()` if you want to stop the spinner.\n *\n * @param text - Error message to display\n * @param extras - Additional values to log\n * @returns This spinner for chaining\n */\n fail(text?: string | undefined, ...extras: unknown[]) {\n return this.#showStatusAndKeepSpinning('fail', [text, ...extras])\n }\n\n /**\n * Show a failure message (\u2717) and stop the spinner.\n * Auto-clears the spinner line before displaying the error message.\n *\n * @param text - Error message to display\n * @param extras - Additional values to log\n * @returns This spinner for chaining\n */\n failAndStop(text?: string | undefined, ...extras: unknown[]) {\n return this.#apply('error', [text, ...extras])\n }\n\n /**\n * Increase indentation level by adding spaces to the left.\n * Pass 0 to reset indentation to zero completely.\n *\n * @param spaces - Number of spaces to add\n * @returns This spinner for chaining\n * @default spaces=2\n *\n * @example\n * ```ts\n * spinner.indent() // Add 2 spaces\n * spinner.indent(4) // Add 4 spaces\n * spinner.indent(0) // Reset to zero indentation\n * ```\n */\n indent(spaces?: number | undefined) {\n // Pass 0 to reset indentation\n if (spaces === 0) {\n this.#indentation = ''\n } else {\n const amount = spaces ?? 2\n this.#indentation += ' '.repeat(amount)\n }\n this.#updateSpinnerText()\n return this\n }\n\n /**\n * Show an info message (\u2139) without stopping the spinner.\n * Outputs to stderr and continues spinning.\n *\n * @param text - Info message to display\n * @param extras - Additional values to log\n * @returns This spinner for chaining\n */\n info(text?: string | undefined, ...extras: unknown[]) {\n return this.#showStatusAndKeepSpinning('info', [text, ...extras])\n }\n\n /**\n * Show an info message (\u2139) and stop the spinner.\n * Auto-clears the spinner line before displaying the message.\n *\n * @param text - Info message to display\n * @param extras - Additional values to log\n * @returns This spinner for chaining\n */\n infoAndStop(text?: string | undefined, ...extras: unknown[]) {\n return this.#apply('info', [text, ...extras])\n }\n\n /**\n * Log a message to stdout without stopping the spinner.\n * Unlike other status methods, this outputs to stdout for data logging.\n *\n * @param args - Values to log to stdout\n * @returns This spinner for chaining\n */\n log(...args: unknown[]) {\n const { logger } = /*@__PURE__*/ require('./logger.js')\n logger.log(...args)\n return this\n }\n\n /**\n * Log a message to stdout and stop the spinner.\n * Auto-clears the spinner line before displaying the message.\n *\n * @param text - Message to display\n * @param extras - Additional values to log\n * @returns This spinner for chaining\n */\n logAndStop(text?: string | undefined, ...extras: unknown[]) {\n return this.#apply('stop', [text, ...extras])\n }\n\n /**\n * Update progress information displayed with the spinner.\n * Shows a progress bar with percentage and optional unit label.\n *\n * @param current - Current progress value\n * @param total - Total/maximum progress value\n * @param unit - Optional unit label (e.g., 'files', 'items')\n * @returns This spinner for chaining\n *\n * @example\n * ```ts\n * spinner.progress(5, 10) // \"\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591 50% (5/10)\"\n * spinner.progress(7, 20, 'files') // \"\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591\u2591 35% (7/20 files)\"\n * ```\n */\n progress = (\n current: number,\n total: number,\n unit?: string | undefined,\n ) => {\n this.#progress = {\n __proto__: null,\n current,\n total,\n ...(unit ? { unit } : {}),\n } as ProgressInfo\n this.#updateSpinnerText()\n return this\n }\n\n /**\n * Increment progress by a specified amount.\n * Updates the progress bar displayed with the spinner.\n * Clamps the result between 0 and the total value.\n *\n * @param amount - Amount to increment by\n * @returns This spinner for chaining\n * @default amount=1\n *\n * @example\n * ```ts\n * spinner.progress(0, 10, 'files')\n * spinner.progressStep() // Progress: 1/10\n * spinner.progressStep(3) // Progress: 4/10\n * ```\n */\n progressStep(amount: number = 1) {\n if (this.#progress) {\n const newCurrent = this.#progress.current + amount\n this.#progress = {\n __proto__: null,\n current: Math.max(0, Math.min(newCurrent, this.#progress.total)),\n total: this.#progress.total,\n ...(this.#progress.unit ? { unit: this.#progress.unit } : {}),\n } as ProgressInfo\n this.#updateSpinnerText()\n }\n return this\n }\n\n /**\n * Start the spinner animation with optional text.\n * Begins displaying the animated spinner on stderr.\n *\n * @param text - Optional text to display with the spinner\n * @returns This spinner for chaining\n *\n * @example\n * ```ts\n * spinner.start('Loading\u2026')\n * // Later:\n * spinner.successAndStop('Done!')\n * ```\n */\n start(...args: unknown[]) {\n if (args.length) {\n const text = args.at(0)\n const normalized = normalizeText(text)\n // We clear this.text on start when `text` is falsy because yocto-spinner\n // will not clear it otherwise.\n if (!normalized) {\n this.#baseText = ''\n super.text = ''\n } else {\n this.#baseText = normalized\n }\n }\n\n this.#updateSpinnerText()\n return this.#apply('start', args)\n }\n\n /**\n * Log a main step message to stderr without stopping the spinner.\n * Adds a blank line before the message for visual separation.\n * Aligns with `logger.step()` to use stderr for status messages.\n *\n * @param text - Step message to display\n * @param extras - Additional values to log\n * @returns This spinner for chaining\n *\n * @example\n * ```ts\n * spinner.step('Building application')\n * spinner.substep('Compiling TypeScript')\n * spinner.substep('Bundling assets')\n * ```\n */\n step(text?: string | undefined, ...extras: unknown[]) {\n const { logger } = /*@__PURE__*/ require('./logger.js')\n if (typeof text === 'string') {\n // Add blank line before step for visual separation.\n logger.error('')\n // Use error (stderr) to align with logger.step() default stream.\n logger.error(text, ...extras)\n }\n return this\n }\n\n /**\n * Log an indented substep message to stderr without stopping the spinner.\n * Adds 2-space indentation to the message.\n * Aligns with `logger.substep()` to use stderr for status messages.\n *\n * @param text - Substep message to display\n * @param extras - Additional values to log\n * @returns This spinner for chaining\n *\n * @example\n * ```ts\n * spinner.step('Building application')\n * spinner.substep('Compiling TypeScript')\n * spinner.substep('Bundling assets')\n * ```\n */\n substep(text?: string | undefined, ...extras: unknown[]) {\n if (typeof text === 'string') {\n // Add 2-space indent for substep.\n const { logger } = /*@__PURE__*/ require('./logger.js')\n // Use error (stderr) to align with logger.substep() default stream.\n logger.error(` ${text}`, ...extras)\n }\n return this\n }\n\n /**\n * Stop the spinner animation and clear internal state.\n * Auto-clears the spinner line via yocto-spinner.stop().\n * Resets progress, shimmer, and text state.\n *\n * @param text - Optional final text to display after stopping\n * @returns This spinner for chaining\n *\n * @example\n * ```ts\n * spinner.start('Processing\u2026')\n * // Do work\n * spinner.stop() // Just stop, no message\n * // or\n * spinner.stop('Finished processing')\n * ```\n */\n stop(...args: unknown[]) {\n // Clear internal state.\n this.#baseText = ''\n this.#progress = undefined\n // Reset shimmer animation state if shimmer is enabled.\n if (this.#shimmer) {\n this.#shimmer.currentDir = DIR_LTR\n this.#shimmer.step = 0\n }\n // Call parent stop first (clears screen, sets isSpinning = false).\n const result = this.#apply('stop', args)\n // Then clear text to avoid blank frame render.\n // This is safe now because isSpinning is false.\n super.text = ''\n return result\n }\n\n /**\n * Show a success message (\u2713) without stopping the spinner.\n * DESIGN DECISION: Unlike yocto-spinner, our `success()` does NOT stop the spinner.\n * This allows displaying success messages while continuing to spin for multi-step operations.\n * Use `successAndStop()` if you want to stop the spinner.\n *\n * @param text - Success message to display\n * @param extras - Additional values to log\n * @returns This spinner for chaining\n */\n success(text?: string | undefined, ...extras: unknown[]) {\n return this.#showStatusAndKeepSpinning('success', [text, ...extras])\n }\n\n /**\n * Show a success message (\u2713) and stop the spinner.\n * Auto-clears the spinner line before displaying the success message.\n *\n * @param text - Success message to display\n * @param extras - Additional values to log\n * @returns This spinner for chaining\n */\n successAndStop(text?: string | undefined, ...extras: unknown[]) {\n return this.#apply('success', [text, ...extras])\n }\n\n /**\n * Get or set the spinner text.\n * When called with no arguments, returns the current base text.\n * When called with text, updates the display and returns the spinner for chaining.\n *\n * @param value - Text to display (omit to get current text)\n * @returns Current text (getter) or this spinner (setter)\n *\n * @example\n * ```ts\n * // Setter\n * spinner.text('Loading data\u2026')\n * spinner.text('Processing\u2026')\n *\n * // Getter\n * const current = spinner.text()\n * console.log(current) // \"Processing\u2026\"\n * ```\n */\n text(): string\n text(value: string): Spinner\n text(value?: string): string | Spinner {\n // biome-ignore lint/complexity/noArguments: Function overload for getter/setter pattern.\n if (arguments.length === 0) {\n // Getter: return current base text\n return this.#baseText\n }\n // Setter: update base text and refresh display\n this.#baseText = value ?? ''\n this.#updateSpinnerText()\n return this as unknown as Spinner\n }\n\n /**\n * Show a warning message (\u26A0) without stopping the spinner.\n * Outputs to stderr and continues spinning.\n *\n * @param text - Warning message to display\n * @param extras - Additional values to log\n * @returns This spinner for chaining\n */\n warn(text?: string | undefined, ...extras: unknown[]) {\n return this.#showStatusAndKeepSpinning('warn', [text, ...extras])\n }\n\n /**\n * Show a warning message (\u26A0) and stop the spinner.\n * Auto-clears the spinner line before displaying the warning message.\n *\n * @param text - Warning message to display\n * @param extras - Additional values to log\n * @returns This spinner for chaining\n */\n warnAndStop(text?: string | undefined, ...extras: unknown[]) {\n return this.#apply('warning', [text, ...extras])\n }\n\n /**\n * Toggle shimmer effect or update shimmer configuration.\n * Preserves shimmer config when toggling off, allowing easy re-enable.\n * Supports partial config updates to tweak specific properties.\n *\n * @param enabledOrConfig - Boolean to toggle, partial config to update, or direction string\n * @returns This spinner for chaining\n *\n * @example\n * // Toggle off (preserves config for later re-enable)\n * spinner.shimmer(false)\n *\n * // Toggle on (restores saved config or uses defaults)\n * spinner.shimmer(true)\n *\n * // Update specific properties\n * spinner.shimmer({ speed: 0.5 })\n * spinner.shimmer({ color: [255, 0, 0] })\n *\n * // Set direction\n * spinner.shimmer('rtl')\n */\n shimmer(\n enabledOrConfig:\n | boolean\n | Partial<ShimmerConfig>\n | ShimmerDirection\n | undefined,\n ): Spinner {\n if (enabledOrConfig === false) {\n // Disable shimmer but preserve config.\n this.#shimmer = undefined\n } else if (enabledOrConfig === true) {\n // Re-enable with saved config or defaults.\n if (this.#shimmerSavedConfig) {\n // Restore saved config.\n this.#shimmer = { ...this.#shimmerSavedConfig }\n } else {\n // Create default config.\n this.#shimmer = {\n color: COLOR_INHERIT,\n currentDir: DIR_LTR,\n mode: DIR_LTR,\n speed: 1 / 3,\n step: 0,\n } as ShimmerInfo\n this.#shimmerSavedConfig = this.#shimmer\n }\n } else if (typeof enabledOrConfig === 'string') {\n // Direction string - update existing or create new.\n if (this.#shimmer) {\n // Update existing shimmer direction.\n this.#shimmer = {\n ...this.#shimmer,\n mode: enabledOrConfig,\n }\n this.#shimmerSavedConfig = this.#shimmer\n } else if (this.#shimmerSavedConfig) {\n // Restore and update.\n this.#shimmer = {\n ...this.#shimmerSavedConfig,\n mode: enabledOrConfig,\n }\n this.#shimmerSavedConfig = this.#shimmer\n } else {\n // Create new with direction.\n this.#shimmer = {\n color: COLOR_INHERIT,\n currentDir: DIR_LTR,\n mode: enabledOrConfig,\n speed: 1 / 3,\n step: 0,\n } as ShimmerInfo\n this.#shimmerSavedConfig = this.#shimmer\n }\n } else if (enabledOrConfig && typeof enabledOrConfig === 'object') {\n // Partial config update - merge with existing or saved config.\n const partialConfig = {\n __proto__: null,\n ...enabledOrConfig,\n } as Partial<ShimmerConfig>\n\n if (this.#shimmer) {\n // Update existing shimmer.\n this.#shimmer = {\n ...this.#shimmer,\n ...(partialConfig.color !== undefined\n ? { color: partialConfig.color }\n : {}),\n ...(partialConfig.dir !== undefined\n ? { mode: partialConfig.dir }\n : {}),\n ...(partialConfig.speed !== undefined\n ? { speed: partialConfig.speed }\n : {}),\n } as ShimmerInfo\n this.#shimmerSavedConfig = this.#shimmer\n } else if (this.#shimmerSavedConfig) {\n // Restore and update.\n this.#shimmer = {\n ...this.#shimmerSavedConfig,\n ...(partialConfig.color !== undefined\n ? { color: partialConfig.color }\n : {}),\n ...(partialConfig.dir !== undefined\n ? { mode: partialConfig.dir }\n : {}),\n ...(partialConfig.speed !== undefined\n ? { speed: partialConfig.speed }\n : {}),\n } as ShimmerInfo\n this.#shimmerSavedConfig = this.#shimmer\n } else {\n // Create new with partial config.\n this.#shimmer = {\n color: partialConfig.color ?? COLOR_INHERIT,\n currentDir: DIR_LTR,\n mode: partialConfig.dir ?? DIR_LTR,\n speed: partialConfig.speed ?? 1 / 3,\n step: 0,\n } as ShimmerInfo\n this.#shimmerSavedConfig = this.#shimmer\n }\n }\n\n this.#updateSpinnerText()\n return this as unknown as Spinner\n }\n } as unknown as {\n new (options?: SpinnerOptions | undefined): Spinner\n }\n // Add aliases.\n Object.defineProperties(_Spinner.prototype, {\n error: desc(_Spinner.prototype.fail),\n errorAndStop: desc(_Spinner.prototype.failAndStop),\n warning: desc(_Spinner.prototype.warn),\n warningAndStop: desc(_Spinner.prototype.warnAndStop),\n })\n _defaultSpinner = CI\n ? ciSpinner\n : (getCliSpinners('socket') as SpinnerStyle)\n }\n return new _Spinner({\n spinner: _defaultSpinner,\n ...options,\n })\n}\n\nlet _spinner: ReturnType<typeof Spinner> | undefined\n\n/**\n * Get the default spinner instance.\n * Lazily creates the spinner to avoid circular dependencies during module initialization.\n * Reuses the same instance across calls.\n *\n * @returns Shared default spinner instance\n *\n * @example\n * ```ts\n * import { getDefaultSpinner } from '@socketsecurity/registry/lib/spinner'\n *\n * const spinner = getDefaultSpinner()\n * spinner.start('Loading\u2026')\n * ```\n */\nexport function getDefaultSpinner(): ReturnType<typeof Spinner> {\n if (_spinner === undefined) {\n _spinner = Spinner()\n }\n return _spinner\n}\n\n/**\n * Default shared spinner instance (lazily initialized).\n *\n * @deprecated Use `getDefaultSpinner()` function instead for better tree-shaking and to avoid circular dependencies.\n *\n * @example\n * ```ts\n * // Old (deprecated):\n * import { spinner } from '@socketsecurity/registry/lib/spinner'\n * spinner.start('Loading\u2026')\n *\n * // New (recommended):\n * import { getDefaultSpinner } from '@socketsecurity/registry/lib/spinner'\n * const spinner = getDefaultSpinner()\n * spinner.start('Loading\u2026')\n * ```\n */\nexport const spinner = /* @__PURE__ */ (() => {\n // Lazy initialization to prevent circular dependency issues during module loading.\n let _lazySpinner: ReturnType<typeof Spinner> | undefined\n return new Proxy({} as ReturnType<typeof Spinner>, {\n get(_target, prop) {\n if (_lazySpinner === undefined) {\n _lazySpinner = Spinner()\n }\n const value = _lazySpinner[prop as keyof ReturnType<typeof Spinner>]\n return typeof value === 'function' ? value.bind(_lazySpinner) : value\n },\n })\n})()\n\n/**\n * Configuration options for `withSpinner()` helper.\n * @template T - Return type of the async operation\n */\nexport type WithSpinnerOptions<T> = {\n /** Message to display while the spinner is running */\n message: string\n /** Async function to execute while spinner is active */\n operation: () => Promise<T>\n /**\n * Optional spinner instance to use.\n * If not provided, operation runs without spinner.\n */\n spinner?: Spinner | undefined\n}\n\n/**\n * Execute an async operation with spinner lifecycle management.\n * Ensures `spinner.stop()` is always called via try/finally, even if the operation throws.\n * Provides safe cleanup and consistent spinner behavior.\n *\n * @template T - Return type of the operation\n * @param options - Configuration object\n * @param options.message - Message to display while spinner is running\n * @param options.operation - Async function to execute\n * @param options.spinner - Optional spinner instance (if not provided, no spinner is used)\n * @returns Result of the operation\n * @throws Re-throws any error from operation after stopping spinner\n *\n * @example\n * ```ts\n * import { Spinner, withSpinner } from '@socketsecurity/registry/lib/spinner'\n *\n * const spinner = Spinner()\n *\n * // With spinner instance\n * const result = await withSpinner({\n * message: 'Processing\u2026',\n * operation: async () => {\n * return await processData()\n * },\n * spinner\n * })\n *\n * // Without spinner instance (no-op, just runs operation)\n * const result = await withSpinner({\n * message: 'Processing\u2026',\n * operation: async () => {\n * return await processData()\n * }\n * })\n * ```\n */\nexport async function withSpinner<T>(\n options: WithSpinnerOptions<T>,\n): Promise<T> {\n const { message, operation, spinner } = {\n __proto__: null,\n ...options,\n } as WithSpinnerOptions<T>\n\n if (!spinner) {\n return await operation()\n }\n\n spinner.start(message)\n try {\n return await operation()\n } finally {\n spinner.stop()\n }\n}\n\n/**\n * Configuration options for `withSpinnerRestore()` helper.\n * @template T - Return type of the async operation\n */\nexport type WithSpinnerRestoreOptions<T> = {\n /** Async function to execute while spinner is stopped */\n operation: () => Promise<T>\n /** Optional spinner instance to restore after operation */\n spinner?: Spinner | undefined\n /** Whether spinner was spinning before the operation (used to conditionally restart) */\n wasSpinning: boolean\n}\n\n/**\n * Execute an async operation with conditional spinner restart.\n * Useful when you need to temporarily stop a spinner for an operation,\n * then restore it to its previous state (if it was spinning).\n *\n * @template T - Return type of the operation\n * @param options - Configuration object\n * @param options.operation - Async function to execute\n * @param options.spinner - Optional spinner instance to manage\n * @param options.wasSpinning - Whether spinner was spinning before the operation\n * @returns Result of the operation\n * @throws Re-throws any error from operation after restoring spinner state\n *\n * @example\n * ```ts\n * import { getDefaultSpinner, withSpinnerRestore } from '@socketsecurity/registry/lib/spinner'\n *\n * const spinner = getDefaultSpinner()\n * const wasSpinning = spinner.isSpinning\n * spinner.stop()\n *\n * const result = await withSpinnerRestore({\n * operation: async () => {\n * // Do work without spinner\n * return await someOperation()\n * },\n * spinner,\n * wasSpinning\n * })\n * // Spinner is automatically restarted if wasSpinning was true\n * ```\n */\nexport async function withSpinnerRestore<T>(\n options: WithSpinnerRestoreOptions<T>,\n): Promise<T> {\n const { operation, spinner, wasSpinning } = {\n __proto__: null,\n ...options,\n } as WithSpinnerRestoreOptions<T>\n\n try {\n return await operation()\n } finally {\n if (spinner && wasSpinning) {\n spinner.start()\n }\n }\n}\n\n/**\n * Configuration options for `withSpinnerSync()` helper.\n * @template T - Return type of the sync operation\n */\nexport type WithSpinnerSyncOptions<T> = {\n /** Message to display while the spinner is running */\n message: string\n /** Synchronous function to execute while spinner is active */\n operation: () => T\n /**\n * Optional spinner instance to use.\n * If not provided, operation runs without spinner.\n */\n spinner?: Spinner | undefined\n}\n\n/**\n * Execute a synchronous operation with spinner lifecycle management.\n * Ensures `spinner.stop()` is always called via try/finally, even if the operation throws.\n * Provides safe cleanup and consistent spinner behavior for sync operations.\n *\n * @template T - Return type of the operation\n * @param options - Configuration object\n * @param options.message - Message to display while spinner is running\n * @param options.operation - Synchronous function to execute\n * @param options.spinner - Optional spinner instance (if not provided, no spinner is used)\n * @returns Result of the operation\n * @throws Re-throws any error from operation after stopping spinner\n *\n * @example\n * ```ts\n * import { Spinner, withSpinnerSync } from '@socketsecurity/registry/lib/spinner'\n *\n * const spinner = Spinner()\n *\n * const result = withSpinnerSync({\n * message: 'Processing\u2026',\n * operation: () => {\n * return processDataSync()\n * },\n * spinner\n * })\n * ```\n */\nexport function withSpinnerSync<T>(options: WithSpinnerSyncOptions<T>): T {\n const { message, operation, spinner } = {\n __proto__: null,\n ...options,\n } as WithSpinnerSyncOptions<T>\n\n if (!spinner) {\n return operation()\n }\n\n spinner.start(message)\n try {\n return operation()\n } finally {\n spinner.stop()\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA,gBAAmB;AACnB,0BAA4C;AAO5C,0BAAqD;AACrD,2BAAyB;AACzB,qBAAuB;AACvB,qBAA2C;AAiD3C,MAAM,aAA0C;AAAA,EAC9C,WAAW;AAAA,EACX,OAAO,CAAC,GAAG,GAAG,CAAC;AAAA,EACf,MAAM,CAAC,GAAG,GAAG,GAAG;AAAA,EAChB,YAAY,CAAC,KAAK,KAAK,GAAG;AAAA,EAC1B,MAAM,CAAC,GAAG,KAAK,GAAG;AAAA,EAClB,YAAY,CAAC,GAAG,KAAK,GAAG;AAAA,EACxB,MAAM,CAAC,KAAK,KAAK,GAAG;AAAA,EACpB,OAAO,CAAC,GAAG,KAAK,CAAC;AAAA,EACjB,aAAa,CAAC,GAAG,KAAK,CAAC;AAAA,EACvB,SAAS,CAAC,KAAK,GAAG,GAAG;AAAA,EACrB,eAAe,CAAC,KAAK,KAAK,GAAG;AAAA,EAC7B,KAAK,CAAC,KA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AI,CAACA,UAAS;AACZ,WAAO,MAAM,UAAU;AAAA,EACzB;AAEA,EAAAA,SAAQ,MAAM,OAAO;AACrB,MAAI;AACF,WAAO,MAAM,UAAU;AAAA,EACzB,UAAE;AACA,IAAAA,SAAQ,KAAK;AAAA,EACf;AACF;AA+CA,eAAsB,mBACpB,SACY;AACZ,QAAM,EAAE,WAAW,SAAAA,UAAS,YAAY,IAAI;AAAA,IAC1C,WAAW;AAAA,IACX,GAAG;AAAA,EACL;AAEA,MAAI;AACF,WAAO,MAAM,UAAU;AAAA,EACzB,UAAE;AACA,QAAIA,YAAW,aAAa;AAC1B,MAAAA,SAAQ,MAAM;AAAA,IAChB;AAAA,EACF;AACF;AA8CO,SAAS,gBAAmB,SAAuC;AACxE,QAAM,EAAE,SAAS,WAAW,SAAAA,SAAQ,IAAI;AAAA,IACtC,WAAW;AAAA,IACX,GAAG;AAAA,EACL;AAEA,MAAI,CAACA,UAAS;AACZ,WAAO,UAAU;AAAA,EACnB;AAEA,EAAAA,SAAQ,MAAM,OAAO;AACrB,MAAI;AACF,WAAO,UAAU;AAAA,EACnB,UAAE;AACA,IAAAA,SAAQ,KAAK;AAAA,EACf;AACF;",
6
6
  "names": ["yoctoSpinner", "options", "spinner"]
7
7
  }
@@ -3,38 +3,159 @@
3
3
  * Provides functions for clearing lines, screens, and managing cursor position.
4
4
  */
5
5
  /**
6
- * Clear the current line.
6
+ * Clear the current line in the terminal.
7
+ * Uses native TTY methods when available, falls back to ANSI escape codes.
8
+ *
9
+ * ANSI Sequences:
10
+ * - `\r`: Carriage return (move to line start)
11
+ * - `\x1b[K`: Clear from cursor to end of line
12
+ *
13
+ * @param stream - Output stream to clear
14
+ * @default stream process.stdout
15
+ *
16
+ * @example
17
+ * ```ts
18
+ * clearLine() // Clear current line on stdout
19
+ * clearLine(process.stderr) // Clear on stderr
20
+ * ```
7
21
  */
8
22
  export declare function clearLine(stream?: NodeJS.WriteStream): void;
9
23
  /**
10
- * Clear lines above the current position.
24
+ * Clear multiple lines above the current cursor position.
25
+ * Useful for clearing multi-line output like progress bars or status messages.
26
+ *
27
+ * ANSI Sequences:
28
+ * - `\x1b[1A`: Move cursor up one line
29
+ * - `\x1b[2K`: Erase entire line
30
+ *
31
+ * @param count - Number of lines to clear
32
+ * @param stream - Output stream to clear
33
+ * @default stream process.stdout
34
+ *
35
+ * @example
36
+ * ```ts
37
+ * console.log('Line 1')
38
+ * console.log('Line 2')
39
+ * console.log('Line 3')
40
+ * clearLines(2) // Clears lines 2 and 3
41
+ * ```
11
42
  */
12
43
  export declare function clearLines(count: number, stream?: NodeJS.WriteStream): void;
13
44
  /**
14
- * Clear the entire screen.
45
+ * Clear the entire screen and reset cursor to top-left.
46
+ * Only works in TTY environments.
47
+ *
48
+ * ANSI Sequence:
49
+ * - `\x1bc`: Full reset (clear screen and move cursor home)
50
+ *
51
+ * @param stream - Output stream to clear
52
+ * @default stream process.stdout
53
+ *
54
+ * @example
55
+ * ```ts
56
+ * clearScreen() // Clear entire terminal
57
+ * ```
15
58
  */
16
59
  export declare function clearScreen(stream?: NodeJS.WriteStream): void;
17
60
  /**
18
- * Clear the visible terminal screen (alias for clearScreen).
61
+ * Clear the visible terminal screen.
62
+ * Alias for `clearScreen()`.
63
+ *
64
+ * @param stream - Output stream to clear
65
+ * @default stream process.stdout
66
+ *
67
+ * @example
68
+ * ```ts
69
+ * clearVisible() // Same as clearScreen()
70
+ * ```
19
71
  */
20
72
  export declare function clearVisible(stream?: NodeJS.WriteStream): void;
21
73
  /**
22
- * Move cursor to beginning of line.
74
+ * Move cursor to the beginning of the current line.
75
+ * Uses native TTY methods when available, falls back to carriage return.
76
+ *
77
+ * @param stream - Output stream to manipulate
78
+ * @default stream process.stdout
79
+ *
80
+ * @example
81
+ * ```ts
82
+ * process.stdout.write('Some text...')
83
+ * cursorToStart()
84
+ * process.stdout.write('New text') // Overwrites from start
85
+ * ```
23
86
  */
24
87
  export declare function cursorToStart(stream?: NodeJS.WriteStream): void;
25
88
  /**
26
- * Hide the cursor.
89
+ * Hide the terminal cursor.
90
+ * Useful for cleaner output during animations or progress indicators.
91
+ *
92
+ * ANSI Sequence:
93
+ * - `\x1b[?25l`: DECTCEM hide cursor
94
+ *
95
+ * @param stream - Output stream to manipulate
96
+ * @default stream process.stdout
97
+ *
98
+ * @example
99
+ * ```ts
100
+ * hideCursor()
101
+ * // ... show animation
102
+ * showCursor()
103
+ * ```
27
104
  */
28
105
  export declare function hideCursor(stream?: NodeJS.WriteStream): void;
29
106
  /**
30
- * Show the cursor.
107
+ * Show the terminal cursor.
108
+ * Should be called after `hideCursor()` to restore normal cursor visibility.
109
+ *
110
+ * ANSI Sequence:
111
+ * - `\x1b[?25h`: DECTCEM show cursor
112
+ *
113
+ * @param stream - Output stream to manipulate
114
+ * @default stream process.stdout
115
+ *
116
+ * @example
117
+ * ```ts
118
+ * hideCursor()
119
+ * // ... show animation
120
+ * showCursor()
121
+ * ```
31
122
  */
32
123
  export declare function showCursor(stream?: NodeJS.WriteStream): void;
33
124
  /**
34
- * Save cursor position.
125
+ * Save the current cursor position.
126
+ * Can be restored later with `restoreCursor()`.
127
+ *
128
+ * ANSI Sequence:
129
+ * - `\x1b7`: DECSC save cursor
130
+ *
131
+ * @param stream - Output stream to manipulate
132
+ * @default stream process.stdout
133
+ *
134
+ * @example
135
+ * ```ts
136
+ * saveCursor()
137
+ * console.log('Temporary text')
138
+ * restoreCursor()
139
+ * console.log('Back at saved position')
140
+ * ```
35
141
  */
36
142
  export declare function saveCursor(stream?: NodeJS.WriteStream): void;
37
143
  /**
38
- * Restore cursor position.
144
+ * Restore cursor to previously saved position.
145
+ * Must be called after `saveCursor()`.
146
+ *
147
+ * ANSI Sequence:
148
+ * - `\x1b8`: DECRC restore cursor
149
+ *
150
+ * @param stream - Output stream to manipulate
151
+ * @default stream process.stdout
152
+ *
153
+ * @example
154
+ * ```ts
155
+ * saveCursor()
156
+ * console.log('Temporary text')
157
+ * restoreCursor()
158
+ * console.log('Back at saved position')
159
+ * ```
39
160
  */
40
161
  export declare function restoreCursor(stream?: NodeJS.WriteStream): void;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/stdio/clear.ts"],
4
- "sourcesContent": ["/**\n * @fileoverview Terminal clearing and cursor utilities.\n * Provides functions for clearing lines, screens, and managing cursor position.\n */\n\n/**\n * Clear the current line.\n */\nexport function clearLine(stream: NodeJS.WriteStream = process.stdout): void {\n if (stream.isTTY) {\n // TTY: Use cursor control\n stream.cursorTo(0)\n stream.clearLine(0)\n } else {\n // Non-TTY: Use ANSI escape codes\n stream.write('\\r\\x1b[K')\n }\n}\n\n/**\n * Clear lines above the current position.\n */\nexport function clearLines(\n count: number,\n stream: NodeJS.WriteStream = process.stdout,\n): void {\n for (let i = 0; i < count; i++) {\n // Move up and clear line\n stream.write('\\x1b[1A\\x1b[2K')\n }\n}\n\n/**\n * Clear the entire screen.\n */\nexport function clearScreen(stream: NodeJS.WriteStream = process.stdout): void {\n if (stream.isTTY) {\n // Clear screen and move cursor to top-left\n stream.write('\\x1bc')\n }\n}\n\n/**\n * Clear the visible terminal screen (alias for clearScreen).\n */\nexport function clearVisible(\n stream: NodeJS.WriteStream = process.stdout,\n): void {\n clearScreen(stream)\n}\n\n/**\n * Move cursor to beginning of line.\n */\nexport function cursorToStart(\n stream: NodeJS.WriteStream = process.stdout,\n): void {\n if (stream.isTTY) {\n stream.cursorTo(0)\n } else {\n stream.write('\\r')\n }\n}\n\n/**\n * Hide the cursor.\n */\nexport function hideCursor(stream: NodeJS.WriteStream = process.stdout): void {\n stream.write('\\x1b[?25l')\n}\n\n/**\n * Show the cursor.\n */\nexport function showCursor(stream: NodeJS.WriteStream = process.stdout): void {\n stream.write('\\x1b[?25h')\n}\n\n/**\n * Save cursor position.\n */\nexport function saveCursor(stream: NodeJS.WriteStream = process.stdout): void {\n stream.write('\\x1b7')\n}\n\n/**\n * Restore cursor position.\n */\nexport function restoreCursor(\n stream: NodeJS.WriteStream = process.stdout,\n): void {\n stream.write('\\x1b8')\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQO,SAAS,UAAU,SAA6B,QAAQ,QAAc;AAC3E,MAAI,OAAO,OAAO;AAEhB,WAAO,SAAS,CAAC;AACjB,WAAO,UAAU,CAAC;AAAA,EACpB,OAAO;AAEL,WAAO,MAAM,UAAU;AAAA,EACzB;AACF;AAKO,SAAS,WACd,OACA,SAA6B,QAAQ,QAC/B;AACN,WAAS,IAAI,GAAG,IAAI,OAAO,KAAK;AAE9B,WAAO,MAAM,gBAAgB;AAAA,EAC/B;AACF;AAKO,SAAS,YAAY,SAA6B,QAAQ,QAAc;AAC7E,MAAI,OAAO,OAAO;AAEhB,WAAO,MAAM,OAAO;AAAA,EACtB;AACF;AAKO,SAAS,aACd,SAA6B,QAAQ,QAC/B;AACN,cAAY,MAAM;AACpB;AAKO,SAAS,cACd,SAA6B,QAAQ,QAC/B;AACN,MAAI,OAAO,OAAO;AAChB,WAAO,SAAS,CAAC;AAAA,EACnB,OAAO;AACL,WAAO,MAAM,IAAI;AAAA,EACnB;AACF;AAKO,SAAS,WAAW,SAA6B,QAAQ,QAAc;AAC5E,SAAO,MAAM,WAAW;AAC1B;AAKO,SAAS,WAAW,SAA6B,QAAQ,QAAc;AAC5E,SAAO,MAAM,WAAW;AAC1B;AAKO,SAAS,WAAW,SAA6B,QAAQ,QAAc;AAC5E,SAAO,MAAM,OAAO;AACtB;AAKO,SAAS,cACd,SAA6B,QAAQ,QAC/B;AACN,SAAO,MAAM,OAAO;AACtB;",
4
+ "sourcesContent": ["/**\n * @fileoverview Terminal clearing and cursor utilities.\n * Provides functions for clearing lines, screens, and managing cursor position.\n */\n\n/**\n * Clear the current line in the terminal.\n * Uses native TTY methods when available, falls back to ANSI escape codes.\n *\n * ANSI Sequences:\n * - `\\r`: Carriage return (move to line start)\n * - `\\x1b[K`: Clear from cursor to end of line\n *\n * @param stream - Output stream to clear\n * @default stream process.stdout\n *\n * @example\n * ```ts\n * clearLine() // Clear current line on stdout\n * clearLine(process.stderr) // Clear on stderr\n * ```\n */\nexport function clearLine(stream: NodeJS.WriteStream = process.stdout): void {\n if (stream.isTTY) {\n // TTY: Use cursor control\n stream.cursorTo(0)\n stream.clearLine(0)\n } else {\n // Non-TTY: Use ANSI escape codes\n stream.write('\\r\\x1b[K')\n }\n}\n\n/**\n * Clear multiple lines above the current cursor position.\n * Useful for clearing multi-line output like progress bars or status messages.\n *\n * ANSI Sequences:\n * - `\\x1b[1A`: Move cursor up one line\n * - `\\x1b[2K`: Erase entire line\n *\n * @param count - Number of lines to clear\n * @param stream - Output stream to clear\n * @default stream process.stdout\n *\n * @example\n * ```ts\n * console.log('Line 1')\n * console.log('Line 2')\n * console.log('Line 3')\n * clearLines(2) // Clears lines 2 and 3\n * ```\n */\nexport function clearLines(\n count: number,\n stream: NodeJS.WriteStream = process.stdout,\n): void {\n for (let i = 0; i < count; i++) {\n // Move up and clear line\n stream.write('\\x1b[1A\\x1b[2K')\n }\n}\n\n/**\n * Clear the entire screen and reset cursor to top-left.\n * Only works in TTY environments.\n *\n * ANSI Sequence:\n * - `\\x1bc`: Full reset (clear screen and move cursor home)\n *\n * @param stream - Output stream to clear\n * @default stream process.stdout\n *\n * @example\n * ```ts\n * clearScreen() // Clear entire terminal\n * ```\n */\nexport function clearScreen(stream: NodeJS.WriteStream = process.stdout): void {\n if (stream.isTTY) {\n // Clear screen and move cursor to top-left\n stream.write('\\x1bc')\n }\n}\n\n/**\n * Clear the visible terminal screen.\n * Alias for `clearScreen()`.\n *\n * @param stream - Output stream to clear\n * @default stream process.stdout\n *\n * @example\n * ```ts\n * clearVisible() // Same as clearScreen()\n * ```\n */\nexport function clearVisible(\n stream: NodeJS.WriteStream = process.stdout,\n): void {\n clearScreen(stream)\n}\n\n/**\n * Move cursor to the beginning of the current line.\n * Uses native TTY methods when available, falls back to carriage return.\n *\n * @param stream - Output stream to manipulate\n * @default stream process.stdout\n *\n * @example\n * ```ts\n * process.stdout.write('Some text...')\n * cursorToStart()\n * process.stdout.write('New text') // Overwrites from start\n * ```\n */\nexport function cursorToStart(\n stream: NodeJS.WriteStream = process.stdout,\n): void {\n if (stream.isTTY) {\n stream.cursorTo(0)\n } else {\n stream.write('\\r')\n }\n}\n\n/**\n * Hide the terminal cursor.\n * Useful for cleaner output during animations or progress indicators.\n *\n * ANSI Sequence:\n * - `\\x1b[?25l`: DECTCEM hide cursor\n *\n * @param stream - Output stream to manipulate\n * @default stream process.stdout\n *\n * @example\n * ```ts\n * hideCursor()\n * // ... show animation\n * showCursor()\n * ```\n */\nexport function hideCursor(stream: NodeJS.WriteStream = process.stdout): void {\n stream.write('\\x1b[?25l')\n}\n\n/**\n * Show the terminal cursor.\n * Should be called after `hideCursor()` to restore normal cursor visibility.\n *\n * ANSI Sequence:\n * - `\\x1b[?25h`: DECTCEM show cursor\n *\n * @param stream - Output stream to manipulate\n * @default stream process.stdout\n *\n * @example\n * ```ts\n * hideCursor()\n * // ... show animation\n * showCursor()\n * ```\n */\nexport function showCursor(stream: NodeJS.WriteStream = process.stdout): void {\n stream.write('\\x1b[?25h')\n}\n\n/**\n * Save the current cursor position.\n * Can be restored later with `restoreCursor()`.\n *\n * ANSI Sequence:\n * - `\\x1b7`: DECSC save cursor\n *\n * @param stream - Output stream to manipulate\n * @default stream process.stdout\n *\n * @example\n * ```ts\n * saveCursor()\n * console.log('Temporary text')\n * restoreCursor()\n * console.log('Back at saved position')\n * ```\n */\nexport function saveCursor(stream: NodeJS.WriteStream = process.stdout): void {\n stream.write('\\x1b7')\n}\n\n/**\n * Restore cursor to previously saved position.\n * Must be called after `saveCursor()`.\n *\n * ANSI Sequence:\n * - `\\x1b8`: DECRC restore cursor\n *\n * @param stream - Output stream to manipulate\n * @default stream process.stdout\n *\n * @example\n * ```ts\n * saveCursor()\n * console.log('Temporary text')\n * restoreCursor()\n * console.log('Back at saved position')\n * ```\n */\nexport function restoreCursor(\n stream: NodeJS.WriteStream = process.stdout,\n): void {\n stream.write('\\x1b8')\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAsBO,SAAS,UAAU,SAA6B,QAAQ,QAAc;AAC3E,MAAI,OAAO,OAAO;AAEhB,WAAO,SAAS,CAAC;AACjB,WAAO,UAAU,CAAC;AAAA,EACpB,OAAO;AAEL,WAAO,MAAM,UAAU;AAAA,EACzB;AACF;AAsBO,SAAS,WACd,OACA,SAA6B,QAAQ,QAC/B;AACN,WAAS,IAAI,GAAG,IAAI,OAAO,KAAK;AAE9B,WAAO,MAAM,gBAAgB;AAAA,EAC/B;AACF;AAiBO,SAAS,YAAY,SAA6B,QAAQ,QAAc;AAC7E,MAAI,OAAO,OAAO;AAEhB,WAAO,MAAM,OAAO;AAAA,EACtB;AACF;AAcO,SAAS,aACd,SAA6B,QAAQ,QAC/B;AACN,cAAY,MAAM;AACpB;AAgBO,SAAS,cACd,SAA6B,QAAQ,QAC/B;AACN,MAAI,OAAO,OAAO;AAChB,WAAO,SAAS,CAAC;AAAA,EACnB,OAAO;AACL,WAAO,MAAM,IAAI;AAAA,EACnB;AACF;AAmBO,SAAS,WAAW,SAA6B,QAAQ,QAAc;AAC5E,SAAO,MAAM,WAAW;AAC1B;AAmBO,SAAS,WAAW,SAA6B,QAAQ,QAAc;AAC5E,SAAO,MAAM,WAAW;AAC1B;AAoBO,SAAS,WAAW,SAA6B,QAAQ,QAAc;AAC5E,SAAO,MAAM,OAAO;AACtB;AAoBO,SAAS,cACd,SAA6B,QAAQ,QAC/B;AACN,SAAO,MAAM,OAAO;AACtB;",
6
6
  "names": []
7
7
  }
@@ -1,48 +1,144 @@
1
1
  export interface DividerOptions {
2
- width?: number;
3
- char?: string;
4
- color?: (text: string) => string;
2
+ /**
3
+ * Width of the divider line in characters.
4
+ * @default 55
5
+ */
6
+ width?: number | undefined;
7
+ /**
8
+ * Character to repeat for the divider line.
9
+ * @default '═'
10
+ */
11
+ char?: string | undefined;
12
+ /**
13
+ * Optional color function to apply to the divider.
14
+ * Accepts a function from `yoctocolors` or similar.
15
+ */
16
+ color?: ((text: string) => string) | undefined;
5
17
  }
6
18
  /**
7
19
  * Create a divider line with custom character and width.
20
+ * Returns a string of repeated characters for visual separation.
21
+ *
22
+ * @param options - Divider formatting options
23
+ * @returns Divider string
24
+ *
25
+ * @example
26
+ * ```ts
27
+ * console.log(divider()) // Default: 55 '═' characters
28
+ * console.log(divider({ char: '-', width: 40 }))
29
+ * console.log(divider({ char: '·', width: 30 }))
30
+ * ```
8
31
  */
9
32
  export declare function divider(options?: DividerOptions): string;
10
33
  /**
11
- * Print a divider line to console.
34
+ * Print a divider line directly to console.
35
+ *
36
+ * @param options - Divider formatting options
37
+ *
38
+ * @example
39
+ * ```ts
40
+ * printDivider() // Prints default divider
41
+ * printDivider({ char: '─', width: 60 })
42
+ * ```
12
43
  */
13
44
  export declare function printDivider(options?: DividerOptions): void;
14
45
  /**
15
- * Common divider presets.
46
+ * Common divider style presets.
47
+ * Provides quick access to popular divider styles.
48
+ *
49
+ * @example
50
+ * ```ts
51
+ * console.log(dividers.thick()) // ═══════...
52
+ * console.log(dividers.thin()) // ───────...
53
+ * console.log(dividers.dotted()) // ·······...
54
+ * ```
16
55
  */
17
56
  export declare const dividers: {
57
+ /** Thick double-line divider using `═` */
18
58
  readonly thick: () => string;
59
+ /** Thin single-line divider using `─` */
19
60
  readonly thin: () => string;
61
+ /** Double-line divider (alias for thick) */
20
62
  readonly double: () => string;
63
+ /** Simple single dash divider using `-` */
21
64
  readonly single: () => string;
65
+ /** Dotted divider using `·` */
22
66
  readonly dotted: () => string;
67
+ /** Dashed divider using `╌` */
23
68
  readonly dashed: () => string;
69
+ /** Wave divider using `~` */
24
70
  readonly wave: () => string;
71
+ /** Star divider using `*` */
25
72
  readonly star: () => string;
73
+ /** Diamond divider using `◆` */
26
74
  readonly diamond: () => string;
75
+ /** Arrow divider using `→` */
27
76
  readonly arrow: () => string;
28
77
  };
29
78
  /**
30
- * Print a thick divider (default).
79
+ * Print a thick divider line (default style).
80
+ * Convenience function using `═` character.
81
+ *
82
+ * @example
83
+ * ```ts
84
+ * printThickDivider()
85
+ * // ═══════════════════════════════════════════════════
86
+ * ```
31
87
  */
32
88
  export declare function printThickDivider(): void;
33
89
  /**
34
- * Print a thin divider.
90
+ * Print a thin divider line.
91
+ * Convenience function using `─` character.
92
+ *
93
+ * @example
94
+ * ```ts
95
+ * printThinDivider()
96
+ * // ───────────────────────────────────────────────────
97
+ * ```
35
98
  */
36
99
  export declare function printThinDivider(): void;
37
100
  /**
38
- * Print a dotted line divider.
101
+ * Print a dotted divider line.
102
+ * Convenience function using `·` character.
103
+ *
104
+ * @example
105
+ * ```ts
106
+ * printDottedDivider()
107
+ * // ·······················································
108
+ * ```
39
109
  */
40
110
  export declare function printDottedDivider(): void;
41
111
  /**
42
- * Create a section break with spacing.
112
+ * Create a section break with blank lines before and after the divider.
113
+ * Useful for creating visual separation between major sections.
114
+ *
115
+ * @param options - Divider formatting options
116
+ * @returns Section break string with newlines
117
+ *
118
+ * @example
119
+ * ```ts
120
+ * console.log('Previous section')
121
+ * console.log(sectionBreak())
122
+ * console.log('Next section')
123
+ * // Output:
124
+ * // Previous section
125
+ * //
126
+ * // ═══════════════════════════════════════════════════
127
+ * //
128
+ * // Next section
129
+ * ```
43
130
  */
44
131
  export declare function sectionBreak(options?: DividerOptions): string;
45
132
  /**
46
- * Print a section break with spacing.
133
+ * Print a section break with spacing directly to console.
134
+ *
135
+ * @param options - Divider formatting options
136
+ *
137
+ * @example
138
+ * ```ts
139
+ * console.log('Previous section')
140
+ * printSectionBreak()
141
+ * console.log('Next section')
142
+ * ```
47
143
  */
48
144
  export declare function printSectionBreak(options?: DividerOptions): void;