@socketsecurity/lib 2.10.4 → 3.0.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 (72) hide show
  1. package/CHANGELOG.md +29 -24
  2. package/README.md +231 -40
  3. package/dist/constants/platform.js +1 -1
  4. package/dist/constants/platform.js.map +3 -3
  5. package/dist/cover/code.js +1 -1
  6. package/dist/cover/code.js.map +3 -3
  7. package/dist/debug.js +2 -2
  8. package/dist/debug.js.map +3 -3
  9. package/dist/dlx-binary.d.ts +29 -6
  10. package/dist/dlx-binary.js +6 -6
  11. package/dist/dlx-binary.js.map +3 -3
  12. package/dist/dlx-package.d.ts +16 -1
  13. package/dist/dlx-package.js +6 -6
  14. package/dist/dlx-package.js.map +3 -3
  15. package/dist/dlx.js +1 -1
  16. package/dist/dlx.js.map +3 -3
  17. package/dist/env/rewire.js +1 -1
  18. package/dist/env/rewire.js.map +3 -3
  19. package/dist/external/yoctocolors-cjs.d.ts +14 -0
  20. package/dist/fs.d.ts +2 -2
  21. package/dist/fs.js.map +1 -1
  22. package/dist/git.js +1 -1
  23. package/dist/git.js.map +3 -3
  24. package/dist/http-request.js +1 -1
  25. package/dist/http-request.js.map +3 -3
  26. package/dist/ipc.js +1 -1
  27. package/dist/ipc.js.map +3 -3
  28. package/dist/links/index.d.ts +65 -0
  29. package/dist/links/index.js +3 -0
  30. package/dist/links/index.js.map +7 -0
  31. package/dist/logger.d.ts +21 -18
  32. package/dist/logger.js +1 -1
  33. package/dist/logger.js.map +3 -3
  34. package/dist/packages/isolation.js +1 -1
  35. package/dist/packages/isolation.js.map +3 -3
  36. package/dist/paths.js +1 -1
  37. package/dist/paths.js.map +2 -2
  38. package/dist/process-lock.js +2 -2
  39. package/dist/process-lock.js.map +3 -3
  40. package/dist/promises.d.ts +6 -21
  41. package/dist/promises.js +1 -1
  42. package/dist/promises.js.map +2 -2
  43. package/dist/prompts/index.d.ts +115 -0
  44. package/dist/prompts/index.js +3 -0
  45. package/dist/prompts/index.js.map +7 -0
  46. package/dist/spinner.d.ts +33 -23
  47. package/dist/spinner.js +1 -1
  48. package/dist/spinner.js.map +3 -3
  49. package/dist/stdio/mask.d.ts +2 -2
  50. package/dist/stdio/mask.js +4 -4
  51. package/dist/stdio/mask.js.map +3 -3
  52. package/dist/stdio/stdout.js +1 -1
  53. package/dist/stdio/stdout.js.map +3 -3
  54. package/dist/themes/context.d.ts +80 -0
  55. package/dist/themes/context.js +3 -0
  56. package/dist/themes/context.js.map +7 -0
  57. package/dist/themes/index.d.ts +53 -0
  58. package/dist/themes/index.js +3 -0
  59. package/dist/themes/index.js.map +7 -0
  60. package/dist/themes/themes.d.ts +49 -0
  61. package/dist/themes/themes.js +3 -0
  62. package/dist/themes/themes.js.map +7 -0
  63. package/dist/themes/types.d.ts +92 -0
  64. package/dist/themes/types.js +3 -0
  65. package/dist/themes/types.js.map +7 -0
  66. package/dist/themes/utils.d.ts +78 -0
  67. package/dist/themes/utils.js +3 -0
  68. package/dist/themes/utils.js.map +7 -0
  69. package/package.json +39 -7
  70. package/dist/download-lock.d.ts +0 -49
  71. package/dist/download-lock.js +0 -10
  72. package/dist/download-lock.js.map +0 -7
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/stdio/mask.ts"],
4
- "sourcesContent": ["/**\n * @fileoverview Interactive output masking utilities for CLI tools.\n * Provides output control with keyboard toggling (ctrl+o).\n *\n * ANSI Escape Sequences Used:\n * - '\\r': Carriage return - moves cursor to beginning of current line.\n * - '\\x1b[K' or '\\x1b[0K': CSI K (erase line) - clear from cursor to end of line.\n * - '\\x1b[2K': CSI 2K - erase entire line.\n * - '\\x1b[1A': CSI A - move cursor up 1 line.\n *\n * Terminal Control:\n * - Raw mode (setRawMode(true)): Captures keypresses immediately without buffering.\n * - TTY detection: Ensures terminal manipulation only occurs in interactive terminals.\n *\n * Key Features:\n * - Output buffering: Stores up to 1000 lines when masked to prevent memory issues.\n * - Graceful cleanup: Always restores terminal to normal mode on exit/error.\n * - Visual feedback: Uses spinner to indicate process is running when output is masked.\n */\n\nimport type { ChildProcess, SpawnOptions } from 'node:child_process'\nimport { spawn } from 'node:child_process'\nimport readline from 'node:readline'\nimport { spinner } from '../spinner.js'\nimport { clearLine } from './clear.js'\nimport { write } from './stdout.js'\n\nexport interface OutputMaskOptions {\n /**\n * Current working directory for spawned process.\n * @default process.cwd()\n */\n cwd?: string | undefined\n /**\n * Environment variables for spawned process.\n * @default process.env\n */\n env?: NodeJS.ProcessEnv | undefined\n /**\n * Filter output before displaying or buffering.\n * Return `false` to skip the line, `true` to include it.\n *\n * Useful for filtering non-fatal warnings or noise from test runners.\n * The filter runs on every chunk of output before display/buffering.\n *\n * @param text - The output text chunk (may include ANSI codes)\n * @param stream - Whether this came from 'stdout' or 'stderr'\n * @returns `true` to include this output, `false` to skip it\n *\n * @example\n * ```ts\n * filterOutput: (text, stream) => {\n * // Skip vitest worker termination errors\n * if (text.includes('Terminating worker thread')) return false\n * return true\n * }\n * ```\n */\n filterOutput?:\n | ((text: string, stream: 'stdout' | 'stderr') => boolean)\n | undefined\n /**\n * Progress message to display in spinner.\n * @default 'Running\u2026'\n */\n message?: string | undefined\n /**\n * Override the exit code based on captured output.\n *\n * Useful for handling non-fatal errors that shouldn't fail the build.\n * Called after the process exits with the original code and all captured output.\n * Return a number to override the exit code, or `undefined` to keep original.\n *\n * @param code - Original exit code from the process\n * @param stdout - All captured stdout (even filtered lines are captured)\n * @param stderr - All captured stderr (even filtered lines are captured)\n * @returns New exit code, or `undefined` to keep original\n *\n * @example\n * ```ts\n * overrideExitCode: (code, stdout, stderr) => {\n * // If only worker termination errors, treat as success\n * const output = stdout + stderr\n * const hasWorkerError = output.includes('Terminating worker thread')\n * const hasRealFailure = output.includes('FAIL')\n * if (code !== 0 && hasWorkerError && !hasRealFailure) {\n * return 0 // Override to success\n * }\n * return undefined // Keep original\n * }\n * ```\n */\n overrideExitCode?:\n | ((code: number, stdout: string, stderr: string) => number | undefined)\n | undefined\n /**\n * Start with output visible instead of masked.\n * When `true`, output shows immediately without needing ctrl+o.\n * @default false\n */\n showOutput?: boolean | undefined\n /**\n * Text to show after \"ctrl+o\" in spinner message.\n * @default 'to see full output'\n */\n toggleText?: string | undefined\n}\n\nexport interface OutputMask {\n /** Whether spinner is currently active */\n isSpinning: boolean\n /** Buffered output lines */\n outputBuffer: string[]\n /** All stderr captured (for exit code override) */\n stderrCapture: string\n /** All stdout captured (for exit code override) */\n stdoutCapture: string\n /** Whether output is currently visible */\n verbose: boolean\n}\n\n/**\n * Create an output mask for controlling command output visibility.\n * The mask tracks whether output should be shown or hidden (buffered).\n * When hidden, output is buffered and a spinner is shown instead.\n */\nexport function createOutputMask(options: OutputMaskOptions = {}): OutputMask {\n const { showOutput = false } = options\n\n return {\n isSpinning: !showOutput,\n outputBuffer: [],\n stderrCapture: '',\n stdoutCapture: '',\n verbose: showOutput,\n }\n}\n\n/**\n * Create a keyboard handler for toggling output visibility.\n * Handles two key combinations:\n * - ctrl+o: Toggle between showing and hiding output.\n * - ctrl+c: Cancel the running process.\n * The handler manipulates terminal state using ANSI escape sequences.\n */\nexport function createKeyboardHandler(\n mask: OutputMask,\n child: ChildProcess,\n options: OutputMaskOptions = {},\n): (_str: string, key: readline.Key) => void {\n const { message = 'Running\u2026', toggleText = 'to see full output' } = options\n\n return (_str, key) => {\n // ctrl+o toggles verbose mode.\n if (key?.ctrl && key.name === 'o') {\n mask.verbose = !mask.verbose\n\n if (mask.verbose) {\n // Stop spinner and show buffered output.\n if (mask.isSpinning) {\n spinner.stop()\n mask.isSpinning = false\n }\n\n // Clear the current line (removes spinner remnants).\n clearLine()\n\n // Show buffered output.\n if (mask.outputBuffer.length > 0) {\n console.log('--- Output (ctrl+o to hide) ---')\n mask.outputBuffer.forEach(line => {\n write(line)\n })\n }\n } else {\n // Hide output and show spinner.\n // Clear all the output lines that were shown.\n if (mask.outputBuffer.length > 0) {\n // Calculate number of lines to clear (output + header line).\n const lineCount = mask.outputBuffer.join('').split('\\n').length + 1\n // Move up and clear each line using ANSI escape sequences:\n // - '\\x1b[1A' (CSI A): Move cursor up 1 line.\n // - '\\x1b[2K' (CSI K with param 2): Erase entire line.\n // This combination effectively \"rewinds\" the terminal output.\n for (let i = 0; i < lineCount; i += 1) {\n process.stdout.write('\\x1b[1A\\x1b[2K')\n }\n }\n clearLine()\n\n // Clear the buffer and restart spinner.\n mask.outputBuffer = []\n if (!mask.isSpinning) {\n spinner.start(`${message} (ctrl+o ${toggleText})`)\n mask.isSpinning = true\n }\n }\n }\n // ctrl+c to cancel.\n else if (key?.ctrl && key.name === 'c') {\n // Gracefully terminate child process.\n child.kill('SIGTERM')\n // Restore terminal to normal mode before exiting.\n if (process.stdin.isTTY) {\n process.stdin.setRawMode(false)\n }\n throw new Error('Process cancelled by user')\n }\n }\n}\n\n/**\n * Attach output masking to a child process.\n * Returns a promise that resolves with the exit code.\n * This function:\n * - Sets up keyboard input handling in raw mode for immediate key capture.\n * - Buffers stdout/stderr when not in verbose mode.\n * - Shows a spinner when output is masked.\n * - Allows toggling between masked and unmasked output with ctrl+o.\n */\nexport function attachOutputMask(\n child: ChildProcess,\n options: OutputMaskOptions = {},\n): Promise<number> {\n return new Promise((resolve, reject) => {\n const { message = 'Running\u2026' } = options\n const mask = createOutputMask(options)\n\n // Start spinner if not verbose.\n if (mask.isSpinning && process.stdout.isTTY) {\n spinner.start(\n `${message} (ctrl+o ${options.toggleText || 'to see full output'})`,\n )\n }\n\n // Setup keyboard input handling.\n // Raw mode is required to capture ctrl+o without waiting for Enter.\n if (process.stdin.isTTY) {\n readline.emitKeypressEvents(process.stdin)\n process.stdin.setRawMode(true)\n\n const keypressHandler = createKeyboardHandler(mask, child, options)\n process.stdin.on('keypress', keypressHandler)\n\n // Cleanup on exit: restore terminal to normal mode.\n child.on('exit', () => {\n if (process.stdin.isTTY) {\n process.stdin.setRawMode(false)\n process.stdin.removeListener('keypress', keypressHandler)\n }\n })\n }\n\n // Handle stdout: either show immediately or buffer for later.\n if (child.stdout) {\n child.stdout.on('data', data => {\n const text = data.toString()\n\n // Always capture for exit code override.\n mask.stdoutCapture += text\n\n // Apply filter if provided.\n if (options.filterOutput && !options.filterOutput(text, 'stdout')) {\n // Skip this output.\n return undefined\n }\n\n if (mask.verbose) {\n write(text)\n } else {\n // Buffer the output for later.\n mask.outputBuffer.push(text)\n\n // Keep buffer size reasonable (last 1000 lines).\n // This prevents unbounded memory growth for long-running processes.\n const lines = mask.outputBuffer.join('').split('\\n')\n if (lines.length > 1000) {\n mask.outputBuffer = [lines.slice(-1000).join('\\n')]\n }\n }\n return undefined\n })\n }\n\n // Handle stderr: same as stdout, but write to stderr stream when verbose.\n if (child.stderr) {\n child.stderr.on('data', data => {\n const text = data.toString()\n\n // Always capture for exit code override.\n mask.stderrCapture += text\n\n // Apply filter if provided.\n if (options.filterOutput && !options.filterOutput(text, 'stderr')) {\n // Skip this output.\n return undefined\n }\n\n if (mask.verbose) {\n process.stderr.write(text)\n } else {\n mask.outputBuffer.push(text)\n }\n return undefined\n })\n }\n\n child.on('exit', code => {\n // Cleanup keyboard if needed.\n if (process.stdin.isTTY) {\n process.stdin.setRawMode(false)\n }\n\n // Allow caller to override exit code based on output.\n let finalCode = code || 0\n if (options.overrideExitCode) {\n const overridden = options.overrideExitCode(\n finalCode,\n mask.stdoutCapture,\n mask.stderrCapture,\n )\n if (overridden !== undefined) {\n finalCode = overridden\n }\n }\n\n if (mask.isSpinning) {\n if (finalCode === 0) {\n spinner.successAndStop(`${message} completed`)\n } else {\n spinner.failAndStop(`${message} failed`)\n // Show buffered output on failure so user can see what went wrong.\n if (mask.outputBuffer.length > 0 && !mask.verbose) {\n console.log('\\n--- Output ---')\n mask.outputBuffer.forEach(line => {\n write(line)\n })\n }\n }\n }\n\n resolve(finalCode)\n })\n\n child.on('error', error => {\n // Ensure terminal is restored to normal mode on error.\n if (process.stdin.isTTY) {\n process.stdin.setRawMode(false)\n }\n\n if (mask.isSpinning) {\n spinner.failAndStop(`${message} error`)\n }\n reject(error)\n })\n })\n}\n\n/**\n * Run a command with interactive output masking.\n * Convenience wrapper around spawn + attachOutputMask.\n * Spawns a child process and attaches the output masking system to it.\n * stdin is inherited, stdout and stderr are piped for masking control.\n */\nexport async function runWithMask(\n command: string,\n args: string[] = [],\n options: OutputMaskOptions & SpawnOptions = {},\n): Promise<number> {\n const {\n message = 'Running\u2026',\n showOutput = false,\n toggleText = 'to see output',\n ...spawnOptions\n } = options\n\n const child = spawn(command, args, {\n stdio: ['inherit', 'pipe', 'pipe'],\n ...spawnOptions,\n })\n\n return await attachOutputMask(child, { message, showOutput, toggleText })\n}\n"],
5
- "mappings": ";6iBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,sBAAAE,EAAA,0BAAAC,EAAA,qBAAAC,EAAA,gBAAAC,IAAA,eAAAC,EAAAN,GAqBA,IAAAO,EAAsB,8BACtBC,EAAqB,4BACrBC,EAAwB,yBACxBC,EAA0B,sBAC1BC,EAAsB,uBAqGf,SAASP,EAAiBQ,EAA6B,CAAC,EAAe,CAC5E,KAAM,CAAE,WAAAC,EAAa,EAAM,EAAID,EAE/B,MAAO,CACL,WAAY,CAACC,EACb,aAAc,CAAC,EACf,cAAe,GACf,cAAe,GACf,QAASA,CACX,CACF,CASO,SAASV,EACdW,EACAC,EACAH,EAA6B,CAAC,EACa,CAC3C,KAAM,CAAE,QAAAI,EAAU,gBAAY,WAAAC,EAAa,oBAAqB,EAAIL,EAEpE,MAAO,CAACM,EAAMC,IAAQ,CAEpB,GAAIA,GAAK,MAAQA,EAAI,OAAS,IAG5B,GAFAL,EAAK,QAAU,CAACA,EAAK,QAEjBA,EAAK,QAEHA,EAAK,aACP,UAAQ,KAAK,EACbA,EAAK,WAAa,OAIpB,aAAU,EAGNA,EAAK,aAAa,OAAS,IAC7B,QAAQ,IAAI,iCAAiC,EAC7CA,EAAK,aAAa,QAAQM,GAAQ,IAChC,SAAMA,CAAI,CACZ,CAAC,OAE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AExCQ,EAAOS,CAAK,CACd,CAAC,CACH,CAAC,CACH,CAQA,eAAsB5B,EACpB6B,EACAC,EAAiB,CAAC,EAClBvB,EAA4C,CAAC,EAC5B,CACjB,KAAM,CACJ,QAAAI,EAAU,gBACV,WAAAH,EAAa,GACb,WAAAI,EAAa,gBACb,GAAGmB,CACL,EAAIxB,EAEEG,KAAQ,SAAMmB,EAASC,EAAM,CACjC,MAAO,CAAC,UAAW,OAAQ,MAAM,EACjC,GAAGC,CACL,CAAC,EAED,OAAO,MAAMlC,EAAiBa,EAAO,CAAE,QAAAC,EAAS,WAAAH,EAAY,WAAAI,CAAW,CAAC,CAC1E",
6
- "names": ["mask_exports", "__export", "attachOutputMask", "createKeyboardHandler", "createOutputMask", "runWithMask", "__toCommonJS", "import_node_child_process", "import_node_readline", "import_spinner", "import_clear", "import_stdout", "options", "showOutput", "mask", "child", "message", "toggleText", "_str", "key", "line", "lineCount", "i", "resolve", "reject", "readline", "keypressHandler", "data", "text", "lines", "code", "finalCode", "overridden", "error", "command", "args", "spawnOptions"]
4
+ "sourcesContent": ["/**\n * @fileoverview Interactive output masking utilities for CLI tools.\n * Provides output control with keyboard toggling (ctrl+o).\n *\n * ANSI Escape Sequences Used:\n * - '\\r': Carriage return - moves cursor to beginning of current line.\n * - '\\x1b[K' or '\\x1b[0K': CSI K (erase line) - clear from cursor to end of line.\n * - '\\x1b[2K': CSI 2K - erase entire line.\n * - '\\x1b[1A': CSI A - move cursor up 1 line.\n *\n * Terminal Control:\n * - Raw mode (setRawMode(true)): Captures keypresses immediately without buffering.\n * - TTY detection: Ensures terminal manipulation only occurs in interactive terminals.\n *\n * Key Features:\n * - Output buffering: Stores up to 1000 lines when masked to prevent memory issues.\n * - Graceful cleanup: Always restores terminal to normal mode on exit/error.\n * - Visual feedback: Uses spinner to indicate process is running when output is masked.\n */\n\nimport type { ChildProcess, SpawnOptions } from 'child_process'\nimport { spawn } from 'child_process'\nimport readline from 'readline'\nimport { getDefaultSpinner } from '../spinner.js'\nimport { clearLine } from './clear.js'\nimport { write } from './stdout.js'\n\nexport interface OutputMaskOptions {\n /**\n * Current working directory for spawned process.\n * @default process.cwd()\n */\n cwd?: string | undefined\n /**\n * Environment variables for spawned process.\n * @default process.env\n */\n env?: NodeJS.ProcessEnv | undefined\n /**\n * Filter output before displaying or buffering.\n * Return `false` to skip the line, `true` to include it.\n *\n * Useful for filtering non-fatal warnings or noise from test runners.\n * The filter runs on every chunk of output before display/buffering.\n *\n * @param text - The output text chunk (may include ANSI codes)\n * @param stream - Whether this came from 'stdout' or 'stderr'\n * @returns `true` to include this output, `false` to skip it\n *\n * @example\n * ```ts\n * filterOutput: (text, stream) => {\n * // Skip vitest worker termination errors\n * if (text.includes('Terminating worker thread')) return false\n * return true\n * }\n * ```\n */\n filterOutput?:\n | ((text: string, stream: 'stdout' | 'stderr') => boolean)\n | undefined\n /**\n * Progress message to display in spinner.\n * @default 'Running\u2026'\n */\n message?: string | undefined\n /**\n * Override the exit code based on captured output.\n *\n * Useful for handling non-fatal errors that shouldn't fail the build.\n * Called after the process exits with the original code and all captured output.\n * Return a number to override the exit code, or `undefined` to keep original.\n *\n * @param code - Original exit code from the process\n * @param stdout - All captured stdout (even filtered lines are captured)\n * @param stderr - All captured stderr (even filtered lines are captured)\n * @returns New exit code, or `undefined` to keep original\n *\n * @example\n * ```ts\n * overrideExitCode: (code, stdout, stderr) => {\n * // If only worker termination errors, treat as success\n * const output = stdout + stderr\n * const hasWorkerError = output.includes('Terminating worker thread')\n * const hasRealFailure = output.includes('FAIL')\n * if (code !== 0 && hasWorkerError && !hasRealFailure) {\n * return 0 // Override to success\n * }\n * return undefined // Keep original\n * }\n * ```\n */\n overrideExitCode?:\n | ((code: number, stdout: string, stderr: string) => number | undefined)\n | undefined\n /**\n * Start with output visible instead of masked.\n * When `true`, output shows immediately without needing ctrl+o.\n * @default false\n */\n showOutput?: boolean | undefined\n /**\n * Text to show after \"ctrl+o\" in spinner message.\n * @default 'to see full output'\n */\n toggleText?: string | undefined\n}\n\nexport interface OutputMask {\n /** Whether spinner is currently active */\n isSpinning: boolean\n /** Buffered output lines */\n outputBuffer: string[]\n /** All stderr captured (for exit code override) */\n stderrCapture: string\n /** All stdout captured (for exit code override) */\n stdoutCapture: string\n /** Whether output is currently visible */\n verbose: boolean\n}\n\n/**\n * Create an output mask for controlling command output visibility.\n * The mask tracks whether output should be shown or hidden (buffered).\n * When hidden, output is buffered and a spinner is shown instead.\n */\nexport function createOutputMask(options: OutputMaskOptions = {}): OutputMask {\n const { showOutput = false } = options\n\n return {\n isSpinning: !showOutput,\n outputBuffer: [],\n stderrCapture: '',\n stdoutCapture: '',\n verbose: showOutput,\n }\n}\n\n/**\n * Create a keyboard handler for toggling output visibility.\n * Handles two key combinations:\n * - ctrl+o: Toggle between showing and hiding output.\n * - ctrl+c: Cancel the running process.\n * The handler manipulates terminal state using ANSI escape sequences.\n */\nexport function createKeyboardHandler(\n mask: OutputMask,\n child: ChildProcess,\n options: OutputMaskOptions = {},\n): (_str: string, key: readline.Key) => void {\n const { message = 'Running\u2026', toggleText = 'to see full output' } = options\n\n return (_str, key) => {\n // ctrl+o toggles verbose mode.\n if (key?.ctrl && key.name === 'o') {\n mask.verbose = !mask.verbose\n\n if (mask.verbose) {\n // Stop spinner and show buffered output.\n if (mask.isSpinning) {\n getDefaultSpinner().stop()\n mask.isSpinning = false\n }\n\n // Clear the current line (removes spinner remnants).\n clearLine()\n\n // Show buffered output.\n if (mask.outputBuffer.length > 0) {\n console.log('--- Output (ctrl+o to hide) ---')\n mask.outputBuffer.forEach(line => {\n write(line)\n })\n }\n } else {\n // Hide output and show spinner.\n // Clear all the output lines that were shown.\n if (mask.outputBuffer.length > 0) {\n // Calculate number of lines to clear (output + header line).\n const lineCount = mask.outputBuffer.join('').split('\\n').length + 1\n // Move up and clear each line using ANSI escape sequences:\n // - '\\x1b[1A' (CSI A): Move cursor up 1 line.\n // - '\\x1b[2K' (CSI K with param 2): Erase entire line.\n // This combination effectively \"rewinds\" the terminal output.\n for (let i = 0; i < lineCount; i += 1) {\n process.stdout.write('\\x1b[1A\\x1b[2K')\n }\n }\n clearLine()\n\n // Clear the buffer and restart spinner.\n mask.outputBuffer = []\n if (!mask.isSpinning) {\n getDefaultSpinner().start(`${message} (ctrl+o ${toggleText})`)\n mask.isSpinning = true\n }\n }\n }\n // ctrl+c to cancel.\n else if (key?.ctrl && key.name === 'c') {\n // Gracefully terminate child process.\n child.kill('SIGTERM')\n // Restore terminal to normal mode before exiting.\n if (process.stdin.isTTY) {\n process.stdin.setRawMode(false)\n }\n throw new Error('Process cancelled by user')\n }\n }\n}\n\n/**\n * Attach output masking to a child process.\n * Returns a promise that resolves with the exit code.\n * This function:\n * - Sets up keyboard input handling in raw mode for immediate key capture.\n * - Buffers stdout/stderr when not in verbose mode.\n * - Shows a spinner when output is masked.\n * - Allows toggling between masked and unmasked output with ctrl+o.\n */\nexport function attachOutputMask(\n child: ChildProcess,\n options: OutputMaskOptions = {},\n): Promise<number> {\n return new Promise((resolve, reject) => {\n const { message = 'Running\u2026' } = options\n const mask = createOutputMask(options)\n\n // Start spinner if not verbose.\n if (mask.isSpinning && process.stdout.isTTY) {\n getDefaultSpinner().start(\n `${message} (ctrl+o ${options.toggleText || 'to see full output'})`,\n )\n }\n\n // Setup keyboard input handling.\n // Raw mode is required to capture ctrl+o without waiting for Enter.\n if (process.stdin.isTTY) {\n readline.emitKeypressEvents(process.stdin)\n process.stdin.setRawMode(true)\n\n const keypressHandler = createKeyboardHandler(mask, child, options)\n process.stdin.on('keypress', keypressHandler)\n\n // Cleanup on exit: restore terminal to normal mode.\n child.on('exit', () => {\n if (process.stdin.isTTY) {\n process.stdin.setRawMode(false)\n process.stdin.removeListener('keypress', keypressHandler)\n }\n })\n }\n\n // Handle stdout: either show immediately or buffer for later.\n if (child.stdout) {\n child.stdout.on('data', data => {\n const text = data.toString()\n\n // Always capture for exit code override.\n mask.stdoutCapture += text\n\n // Apply filter if provided.\n if (options.filterOutput && !options.filterOutput(text, 'stdout')) {\n // Skip this output.\n return undefined\n }\n\n if (mask.verbose) {\n write(text)\n } else {\n // Buffer the output for later.\n mask.outputBuffer.push(text)\n\n // Keep buffer size reasonable (last 1000 lines).\n // This prevents unbounded memory growth for long-running processes.\n const lines = mask.outputBuffer.join('').split('\\n')\n if (lines.length > 1000) {\n mask.outputBuffer = [lines.slice(-1000).join('\\n')]\n }\n }\n return undefined\n })\n }\n\n // Handle stderr: same as stdout, but write to stderr stream when verbose.\n if (child.stderr) {\n child.stderr.on('data', data => {\n const text = data.toString()\n\n // Always capture for exit code override.\n mask.stderrCapture += text\n\n // Apply filter if provided.\n if (options.filterOutput && !options.filterOutput(text, 'stderr')) {\n // Skip this output.\n return undefined\n }\n\n if (mask.verbose) {\n process.stderr.write(text)\n } else {\n mask.outputBuffer.push(text)\n }\n return undefined\n })\n }\n\n child.on('exit', code => {\n // Cleanup keyboard if needed.\n if (process.stdin.isTTY) {\n process.stdin.setRawMode(false)\n }\n\n // Allow caller to override exit code based on output.\n let finalCode = code || 0\n if (options.overrideExitCode) {\n const overridden = options.overrideExitCode(\n finalCode,\n mask.stdoutCapture,\n mask.stderrCapture,\n )\n if (overridden !== undefined) {\n finalCode = overridden\n }\n }\n\n if (mask.isSpinning) {\n const spinner = getDefaultSpinner()\n if (finalCode === 0) {\n spinner.successAndStop(`${message} completed`)\n } else {\n spinner.failAndStop(`${message} failed`)\n // Show buffered output on failure so user can see what went wrong.\n if (mask.outputBuffer.length > 0 && !mask.verbose) {\n console.log('\\n--- Output ---')\n mask.outputBuffer.forEach(line => {\n write(line)\n })\n }\n }\n }\n\n resolve(finalCode)\n })\n\n child.on('error', error => {\n // Ensure terminal is restored to normal mode on error.\n if (process.stdin.isTTY) {\n process.stdin.setRawMode(false)\n }\n\n if (mask.isSpinning) {\n getDefaultSpinner().failAndStop(`${message} error`)\n }\n reject(error)\n })\n })\n}\n\n/**\n * Run a command with interactive output masking.\n * Convenience wrapper around spawn + attachOutputMask.\n * Spawns a child process and attaches the output masking system to it.\n * stdin is inherited, stdout and stderr are piped for masking control.\n */\nexport async function runWithMask(\n command: string,\n args: string[] = [],\n options: OutputMaskOptions & SpawnOptions = {},\n): Promise<number> {\n const {\n message = 'Running\u2026',\n showOutput = false,\n toggleText = 'to see output',\n ...spawnOptions\n } = options\n\n const child = spawn(command, args, {\n stdio: ['inherit', 'pipe', 'pipe'],\n ...spawnOptions,\n })\n\n return await attachOutputMask(child, { message, showOutput, toggleText })\n}\n"],
5
+ "mappings": ";6iBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,sBAAAE,EAAA,0BAAAC,EAAA,qBAAAC,EAAA,gBAAAC,IAAA,eAAAC,EAAAN,GAqBA,IAAAO,EAAsB,yBACtBC,EAAqB,uBACrBC,EAAkC,yBAClCC,EAA0B,sBAC1BC,EAAsB,uBAqGf,SAASP,EAAiBQ,EAA6B,CAAC,EAAe,CAC5E,KAAM,CAAE,WAAAC,EAAa,EAAM,EAAID,EAE/B,MAAO,CACL,WAAY,CAACC,EACb,aAAc,CAAC,EACf,cAAe,GACf,cAAe,GACf,QAASA,CACX,CACF,CASO,SAASV,EACdW,EACAC,EACAH,EAA6B,CAAC,EACa,CAC3C,KAAM,CAAE,QAAAI,EAAU,gBAAY,WAAAC,EAAa,oBAAqB,EAAIL,EAEpE,MAAO,CAACM,EAAMC,IAAQ,CAEpB,GAAIA,GAAK,MAAQA,EAAI,OAAS,IAG5B,GAFAL,EAAK,QAAU,CAACA,EAAK,QAEjBA,EAAK,QAEHA,EAAK,gBACP,qBAAkB,EAAE,KAAK,EACzBA,EAAK,WAAa,OAIpB,aAAU,EAGNA,EAAK,aAAa,OAAS,IAC7B,QAAQ,IAAI,iCAAiC,EAC7CA,EAAK,aAAa,QAAQM,GAAQ,IAChC,SAAMA,CAAI,CACZ,CAAC,OAEE,CAGL,GAAIN,EAAK,aAAa,OAAS,EAAG,CAEhC,MAAMO,EAAYP,EAAK,aAAa,KAAK,EAAE,EAAE,MAAM;A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K,CACd,CAAC,CACH,CAAC,CACH,CAQA,eAAsB7B,EACpB8B,EACAC,EAAiB,CAAC,EAClBxB,EAA4C,CAAC,EAC5B,CACjB,KAAM,CACJ,QAAAI,EAAU,gBACV,WAAAH,EAAa,GACb,WAAAI,EAAa,gBACb,GAAGoB,CACL,EAAIzB,EAEEG,KAAQ,SAAMoB,EAASC,EAAM,CACjC,MAAO,CAAC,UAAW,OAAQ,MAAM,EACjC,GAAGC,CACL,CAAC,EAED,OAAO,MAAMnC,EAAiBa,EAAO,CAAE,QAAAC,EAAS,WAAAH,EAAY,WAAAI,CAAW,CAAC,CAC1E",
6
+ "names": ["mask_exports", "__export", "attachOutputMask", "createKeyboardHandler", "createOutputMask", "runWithMask", "__toCommonJS", "import_child_process", "import_readline", "import_spinner", "import_clear", "import_stdout", "options", "showOutput", "mask", "child", "message", "toggleText", "_str", "key", "line", "lineCount", "i", "resolve", "reject", "readline", "keypressHandler", "data", "text", "lines", "code", "finalCode", "overridden", "spinner", "error", "command", "args", "spawnOptions"]
7
7
  }
@@ -1,4 +1,4 @@
1
1
  /* Socket Lib - Built with esbuild */
2
- var s=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var T=Object.prototype.hasOwnProperty;var x=(r,e)=>{for(var i in e)s(r,i,{get:e[i],enumerable:!0})},d=(r,e,i,c)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of p(e))!T.call(r,n)&&n!==i&&s(r,n,{get:()=>e[n],enumerable:!(c=f(e,n))||c.enumerable});return r};var w=r=>d(s({},"__esModule",{value:!0}),r);var I={};x(I,{clearLine:()=>l,clearScreenDown:()=>S,cursorTo:()=>v,ensureCursorOnExit:()=>h,getColumns:()=>b,getRows:()=>g,hideCursor:()=>C,isTTY:()=>Y,showCursor:()=>t,stdout:()=>o,write:()=>m,writeLine:()=>a});module.exports=w(I);var u=require("node:tty");const o=process.stdout;function a(r=""){o.write(`${r}
2
+ var s=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var T=Object.prototype.hasOwnProperty;var x=(r,e)=>{for(var i in e)s(r,i,{get:e[i],enumerable:!0})},d=(r,e,i,c)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of p(e))!T.call(r,n)&&n!==i&&s(r,n,{get:()=>e[n],enumerable:!(c=f(e,n))||c.enumerable});return r};var w=r=>d(s({},"__esModule",{value:!0}),r);var I={};x(I,{clearLine:()=>l,clearScreenDown:()=>S,cursorTo:()=>v,ensureCursorOnExit:()=>h,getColumns:()=>b,getRows:()=>g,hideCursor:()=>C,isTTY:()=>Y,showCursor:()=>t,stdout:()=>o,write:()=>m,writeLine:()=>a});module.exports=w(I);var u=require("tty");const o=process.stdout;function a(r=""){o.write(`${r}
3
3
  `)}function m(r){o.write(r)}function l(){o.isTTY&&(o.cursorTo(0),o.clearLine(0))}function v(r,e){o.isTTY&&o.cursorTo(r,e)}function S(){o.isTTY&&o.clearScreenDown()}function Y(){return o.isTTY||!1}function b(){return o.columns||80}function g(){return o.rows||24}function C(){o.isTTY&&o instanceof u.WriteStream&&o.write("\x1B[?25l")}function t(){o.isTTY&&o instanceof u.WriteStream&&o.write("\x1B[?25h")}function h(){process.on("exit",t),process.on("SIGINT",()=>{t(),process.exit(130)}),process.on("SIGTERM",()=>{t(),process.exit(143)})}0&&(module.exports={clearLine,clearScreenDown,cursorTo,ensureCursorOnExit,getColumns,getRows,hideCursor,isTTY,showCursor,stdout,write,writeLine});
4
4
  //# sourceMappingURL=stdout.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/stdio/stdout.ts"],
4
- "sourcesContent": ["/**\n * @fileoverview Standard output stream utilities.\n * Provides utilities for writing to stdout with formatting and control.\n */\n\nimport { WriteStream } from 'node:tty'\n\n// Get the actual stdout stream\nconst stdout: NodeJS.WriteStream = process.stdout\n\n/**\n * Write a line to stdout with trailing newline.\n *\n * @param text - Text to write\n * @default text ''\n *\n * @example\n * ```ts\n * writeLine('Hello, world!')\n * writeLine() // Write empty line\n * ```\n */\nexport function writeLine(text: string = ''): void {\n stdout.write(`${text}\\n`)\n}\n\n/**\n * Write text to stdout without adding a newline.\n *\n * @param text - Text to write\n *\n * @example\n * ```ts\n * write('Loading...')\n * // Later: clear and update\n * ```\n */\nexport function write(text: string): void {\n stdout.write(text)\n}\n\n/**\n * Clear the current line on stdout.\n * Only works in TTY environments.\n *\n * @example\n * ```ts\n * write('Processing...')\n * clearLine()\n * write('Done!')\n * ```\n */\nexport function clearLine(): void {\n if (stdout.isTTY) {\n stdout.cursorTo(0)\n stdout.clearLine(0)\n }\n}\n\n/**\n * Move cursor to specific position on stdout.\n * Only works in TTY environments.\n *\n * @param x - Column position (0-based)\n * @param y - Row position (0-based, optional)\n *\n * @example\n * ```ts\n * cursorTo(0) // Move to start of line\n * cursorTo(10, 5) // Move to column 10, row 5\n * ```\n */\nexport function cursorTo(x: number, y?: number | undefined): void {\n if (stdout.isTTY) {\n stdout.cursorTo(x, y)\n }\n}\n\n/**\n * Clear screen from cursor position down to bottom.\n * Only works in TTY environments.\n *\n * @example\n * ```ts\n * cursorTo(0, 5)\n * clearScreenDown() // Clear from row 5 to bottom\n * ```\n */\nexport function clearScreenDown(): void {\n if (stdout.isTTY) {\n stdout.clearScreenDown()\n }\n}\n\n/**\n * Check if stdout is connected to a TTY (terminal).\n *\n * @returns `true` if stdout is a TTY, `false` if piped/redirected\n *\n * @example\n * ```ts\n * if (isTTY()) {\n * // Show interactive UI\n * } else {\n * // Use simple text output\n * }\n * ```\n */\nexport function isTTY(): boolean {\n return stdout.isTTY || false\n}\n\n/**\n * Get the number of columns (width) in the terminal.\n *\n * @returns Terminal width in characters\n * @default 80\n *\n * @example\n * ```ts\n * const width = getColumns()\n * console.log(`Terminal is ${width} characters wide`)\n * ```\n */\nexport function getColumns(): number {\n return stdout.columns || 80\n}\n\n/**\n * Get the number of rows (height) in the terminal.\n *\n * @returns Terminal height in lines\n * @default 24\n *\n * @example\n * ```ts\n * const height = getRows()\n * console.log(`Terminal is ${height} lines tall`)\n * ```\n */\nexport function getRows(): number {\n return stdout.rows || 24\n}\n\n/**\n * Hide the cursor on stdout.\n * Useful for cleaner output during animations.\n *\n * @example\n * ```ts\n * hideCursor()\n * // Show animation\n * showCursor()\n * ```\n */\nexport function hideCursor(): void {\n if (stdout.isTTY && stdout instanceof WriteStream) {\n stdout.write('\\u001B[?25l')\n }\n}\n\n/**\n * Show the cursor on stdout.\n * Should be called after `hideCursor()`.\n *\n * @example\n * ```ts\n * hideCursor()\n * // Show animation\n * showCursor()\n * ```\n */\nexport function showCursor(): void {\n if (stdout.isTTY && stdout instanceof WriteStream) {\n stdout.write('\\u001B[?25h')\n }\n}\n\n/**\n * Register handlers to ensure cursor is shown on process exit.\n * Prevents hidden cursor after abnormal termination.\n * Handles SIGINT (Ctrl+C) and SIGTERM signals.\n *\n * @example\n * ```ts\n * ensureCursorOnExit()\n * hideCursor()\n * // Even if process crashes, cursor will be restored\n * ```\n */\nexport function ensureCursorOnExit(): void {\n process.on('exit', showCursor)\n process.on('SIGINT', () => {\n showCursor()\n // eslint-disable-next-line n/no-process-exit\n process.exit(130)\n })\n process.on('SIGTERM', () => {\n showCursor()\n // eslint-disable-next-line n/no-process-exit\n process.exit(143)\n })\n}\n\n// Export the raw stream for advanced usage\nexport { stdout }\n"],
5
- "mappings": ";4ZAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,eAAAE,EAAA,oBAAAC,EAAA,aAAAC,EAAA,uBAAAC,EAAA,eAAAC,EAAA,YAAAC,EAAA,eAAAC,EAAA,UAAAC,EAAA,eAAAC,EAAA,WAAAC,EAAA,UAAAC,EAAA,cAAAC,IAAA,eAAAC,EAAAd,GAKA,IAAAe,EAA4B,oBAG5B,MAAMJ,EAA6B,QAAQ,OAcpC,SAASE,EAAUG,EAAe,GAAU,CACjDL,EAAO,MAAM,GAAGK,CAAI;AAAA,CAAI,CAC1B,CAaO,SAASJ,EAAMI,EAAoB,CACxCL,EAAO,MAAMK,CAAI,CACnB,CAaO,SAASd,GAAkB,CAC5BS,EAAO,QACTA,EAAO,SAAS,CAAC,EACjBA,EAAO,UAAU,CAAC,EAEtB,CAeO,SAASP,EAASa,EAAWC,EAA8B,CAC5DP,EAAO,OACTA,EAAO,SAASM,EAAGC,CAAC,CAExB,CAYO,SAASf,GAAwB,CAClCQ,EAAO,OACTA,EAAO,gBAAgB,CAE3B,CAgBO,SAASF,GAAiB,CAC/B,OAAOE,EAAO,OAAS,EACzB,CAcO,SAASL,GAAqB,CACnC,OAAOK,EAAO,SAAW,EAC3B,CAcO,SAASJ,GAAkB,CAChC,OAAOI,EAAO,MAAQ,EACxB,CAaO,SAASH,GAAmB,CAC7BG,EAAO,OAASA,aAAkB,eACpCA,EAAO,MAAM,WAAa,CAE9B,CAaO,SAASD,GAAmB,CAC7BC,EAAO,OAASA,aAAkB,eACpCA,EAAO,MAAM,WAAa,CAE9B,CAcO,SAASN,GAA2B,CACzC,QAAQ,GAAG,OAAQK,CAAU,EAC7B,QAAQ,GAAG,SAAU,IAAM,CACzBA,EAAW,EAEX,QAAQ,KAAK,GAAG,CAClB,CAAC,EACD,QAAQ,GAAG,UAAW,IAAM,CAC1BA,EAAW,EAEX,QAAQ,KAAK,GAAG,CAClB,CAAC,CACH",
6
- "names": ["stdout_exports", "__export", "clearLine", "clearScreenDown", "cursorTo", "ensureCursorOnExit", "getColumns", "getRows", "hideCursor", "isTTY", "showCursor", "stdout", "write", "writeLine", "__toCommonJS", "import_node_tty", "text", "x", "y"]
4
+ "sourcesContent": ["/**\n * @fileoverview Standard output stream utilities.\n * Provides utilities for writing to stdout with formatting and control.\n */\n\nimport { WriteStream } from 'tty'\n\n// Get the actual stdout stream\nconst stdout: NodeJS.WriteStream = process.stdout\n\n/**\n * Write a line to stdout with trailing newline.\n *\n * @param text - Text to write\n * @default text ''\n *\n * @example\n * ```ts\n * writeLine('Hello, world!')\n * writeLine() // Write empty line\n * ```\n */\nexport function writeLine(text: string = ''): void {\n stdout.write(`${text}\\n`)\n}\n\n/**\n * Write text to stdout without adding a newline.\n *\n * @param text - Text to write\n *\n * @example\n * ```ts\n * write('Loading...')\n * // Later: clear and update\n * ```\n */\nexport function write(text: string): void {\n stdout.write(text)\n}\n\n/**\n * Clear the current line on stdout.\n * Only works in TTY environments.\n *\n * @example\n * ```ts\n * write('Processing...')\n * clearLine()\n * write('Done!')\n * ```\n */\nexport function clearLine(): void {\n if (stdout.isTTY) {\n stdout.cursorTo(0)\n stdout.clearLine(0)\n }\n}\n\n/**\n * Move cursor to specific position on stdout.\n * Only works in TTY environments.\n *\n * @param x - Column position (0-based)\n * @param y - Row position (0-based, optional)\n *\n * @example\n * ```ts\n * cursorTo(0) // Move to start of line\n * cursorTo(10, 5) // Move to column 10, row 5\n * ```\n */\nexport function cursorTo(x: number, y?: number | undefined): void {\n if (stdout.isTTY) {\n stdout.cursorTo(x, y)\n }\n}\n\n/**\n * Clear screen from cursor position down to bottom.\n * Only works in TTY environments.\n *\n * @example\n * ```ts\n * cursorTo(0, 5)\n * clearScreenDown() // Clear from row 5 to bottom\n * ```\n */\nexport function clearScreenDown(): void {\n if (stdout.isTTY) {\n stdout.clearScreenDown()\n }\n}\n\n/**\n * Check if stdout is connected to a TTY (terminal).\n *\n * @returns `true` if stdout is a TTY, `false` if piped/redirected\n *\n * @example\n * ```ts\n * if (isTTY()) {\n * // Show interactive UI\n * } else {\n * // Use simple text output\n * }\n * ```\n */\nexport function isTTY(): boolean {\n return stdout.isTTY || false\n}\n\n/**\n * Get the number of columns (width) in the terminal.\n *\n * @returns Terminal width in characters\n * @default 80\n *\n * @example\n * ```ts\n * const width = getColumns()\n * console.log(`Terminal is ${width} characters wide`)\n * ```\n */\nexport function getColumns(): number {\n return stdout.columns || 80\n}\n\n/**\n * Get the number of rows (height) in the terminal.\n *\n * @returns Terminal height in lines\n * @default 24\n *\n * @example\n * ```ts\n * const height = getRows()\n * console.log(`Terminal is ${height} lines tall`)\n * ```\n */\nexport function getRows(): number {\n return stdout.rows || 24\n}\n\n/**\n * Hide the cursor on stdout.\n * Useful for cleaner output during animations.\n *\n * @example\n * ```ts\n * hideCursor()\n * // Show animation\n * showCursor()\n * ```\n */\nexport function hideCursor(): void {\n if (stdout.isTTY && stdout instanceof WriteStream) {\n stdout.write('\\u001B[?25l')\n }\n}\n\n/**\n * Show the cursor on stdout.\n * Should be called after `hideCursor()`.\n *\n * @example\n * ```ts\n * hideCursor()\n * // Show animation\n * showCursor()\n * ```\n */\nexport function showCursor(): void {\n if (stdout.isTTY && stdout instanceof WriteStream) {\n stdout.write('\\u001B[?25h')\n }\n}\n\n/**\n * Register handlers to ensure cursor is shown on process exit.\n * Prevents hidden cursor after abnormal termination.\n * Handles SIGINT (Ctrl+C) and SIGTERM signals.\n *\n * @example\n * ```ts\n * ensureCursorOnExit()\n * hideCursor()\n * // Even if process crashes, cursor will be restored\n * ```\n */\nexport function ensureCursorOnExit(): void {\n process.on('exit', showCursor)\n process.on('SIGINT', () => {\n showCursor()\n // eslint-disable-next-line n/no-process-exit\n process.exit(130)\n })\n process.on('SIGTERM', () => {\n showCursor()\n // eslint-disable-next-line n/no-process-exit\n process.exit(143)\n })\n}\n\n// Export the raw stream for advanced usage\nexport { stdout }\n"],
5
+ "mappings": ";4ZAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,eAAAE,EAAA,oBAAAC,EAAA,aAAAC,EAAA,uBAAAC,EAAA,eAAAC,EAAA,YAAAC,EAAA,eAAAC,EAAA,UAAAC,EAAA,eAAAC,EAAA,WAAAC,EAAA,UAAAC,EAAA,cAAAC,IAAA,eAAAC,EAAAd,GAKA,IAAAe,EAA4B,eAG5B,MAAMJ,EAA6B,QAAQ,OAcpC,SAASE,EAAUG,EAAe,GAAU,CACjDL,EAAO,MAAM,GAAGK,CAAI;AAAA,CAAI,CAC1B,CAaO,SAASJ,EAAMI,EAAoB,CACxCL,EAAO,MAAMK,CAAI,CACnB,CAaO,SAASd,GAAkB,CAC5BS,EAAO,QACTA,EAAO,SAAS,CAAC,EACjBA,EAAO,UAAU,CAAC,EAEtB,CAeO,SAASP,EAASa,EAAWC,EAA8B,CAC5DP,EAAO,OACTA,EAAO,SAASM,EAAGC,CAAC,CAExB,CAYO,SAASf,GAAwB,CAClCQ,EAAO,OACTA,EAAO,gBAAgB,CAE3B,CAgBO,SAASF,GAAiB,CAC/B,OAAOE,EAAO,OAAS,EACzB,CAcO,SAASL,GAAqB,CACnC,OAAOK,EAAO,SAAW,EAC3B,CAcO,SAASJ,GAAkB,CAChC,OAAOI,EAAO,MAAQ,EACxB,CAaO,SAASH,GAAmB,CAC7BG,EAAO,OAASA,aAAkB,eACpCA,EAAO,MAAM,WAAa,CAE9B,CAaO,SAASD,GAAmB,CAC7BC,EAAO,OAASA,aAAkB,eACpCA,EAAO,MAAM,WAAa,CAE9B,CAcO,SAASN,GAA2B,CACzC,QAAQ,GAAG,OAAQK,CAAU,EAC7B,QAAQ,GAAG,SAAU,IAAM,CACzBA,EAAW,EAEX,QAAQ,KAAK,GAAG,CAClB,CAAC,EACD,QAAQ,GAAG,UAAW,IAAM,CAC1BA,EAAW,EAEX,QAAQ,KAAK,GAAG,CAClB,CAAC,CACH",
6
+ "names": ["stdout_exports", "__export", "clearLine", "clearScreenDown", "cursorTo", "ensureCursorOnExit", "getColumns", "getRows", "hideCursor", "isTTY", "showCursor", "stdout", "write", "writeLine", "__toCommonJS", "import_tty", "text", "x", "y"]
7
7
  }
@@ -0,0 +1,80 @@
1
+ import type { Theme } from './types';
2
+ import { type ThemeName } from './themes';
3
+ /**
4
+ * Theme change event listener signature.
5
+ */
6
+ export type ThemeChangeListener = (theme: Theme) => void;
7
+ /**
8
+ * Set the global fallback theme.
9
+ *
10
+ * @param theme - Theme name or object
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * setTheme('socket-firewall')
15
+ * ```
16
+ */
17
+ export declare function setTheme(theme: Theme | ThemeName): void;
18
+ /**
19
+ * Get the active theme from context.
20
+ *
21
+ * @returns Current theme
22
+ *
23
+ * @example
24
+ * ```ts
25
+ * const theme = getTheme()
26
+ * console.log(theme.displayName)
27
+ * ```
28
+ */
29
+ export declare function getTheme(): Theme;
30
+ /**
31
+ * Execute async operation with scoped theme.
32
+ * Theme automatically restored on completion.
33
+ *
34
+ * @template T - Return type
35
+ * @param theme - Scoped theme
36
+ * @param fn - Async operation
37
+ * @returns Operation result
38
+ *
39
+ * @example
40
+ * ```ts
41
+ * await withTheme('ultra', async () => {
42
+ * // Operations use Ultra theme
43
+ * })
44
+ * ```
45
+ */
46
+ export declare function withTheme<T>(theme: Theme | ThemeName, fn: () => Promise<T>): Promise<T>;
47
+ /**
48
+ * Execute sync operation with scoped theme.
49
+ * Theme automatically restored on completion.
50
+ *
51
+ * @template T - Return type
52
+ * @param theme - Scoped theme
53
+ * @param fn - Sync operation
54
+ * @returns Operation result
55
+ *
56
+ * @example
57
+ * ```ts
58
+ * const result = withThemeSync('coana', () => {
59
+ * return processData()
60
+ * })
61
+ * ```
62
+ */
63
+ export declare function withThemeSync<T>(theme: Theme | ThemeName, fn: () => T): T;
64
+ /**
65
+ * Subscribe to theme change events.
66
+ *
67
+ * @param listener - Change handler
68
+ * @returns Unsubscribe function
69
+ *
70
+ * @example
71
+ * ```ts
72
+ * const unsubscribe = onThemeChange((theme) => {
73
+ * console.log('Theme:', theme.displayName)
74
+ * })
75
+ *
76
+ * // Cleanup
77
+ * unsubscribe()
78
+ * ```
79
+ */
80
+ export declare function onThemeChange(listener: ThemeChangeListener): () => void;
@@ -0,0 +1,3 @@
1
+ /* Socket Lib - Built with esbuild */
2
+ var m=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var g=(e,t)=>{for(var n in t)m(e,n,{get:t[n],enumerable:!0})},y=(e,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of f(t))!u.call(e,r)&&r!==n&&m(e,r,{get:()=>t[r],enumerable:!(a=p(t,r))||a.enumerable});return e};var d=e=>y(m({},"__esModule",{value:!0}),e);var C={};g(C,{getTheme:()=>S,onThemeChange:()=>x,setTheme:()=>l,withTheme:()=>v,withThemeSync:()=>w});module.exports=d(C);var c=require("node:async_hooks"),o=require("./themes");const i=new c.AsyncLocalStorage;let T=o.SOCKET_THEME;const h=new Set;function l(e){T=typeof e=="string"?o.THEMES[e]:e,s(T)}function S(){return i.getStore()??T}async function v(e,t){const n=typeof e=="string"?o.THEMES[e]:e;return await i.run(n,async()=>(s(n),await t()))}function w(e,t){const n=typeof e=="string"?o.THEMES[e]:e;return i.run(n,()=>(s(n),t()))}function x(e){return h.add(e),()=>{h.delete(e)}}function s(e){for(const t of h)t(e)}0&&(module.exports={getTheme,onThemeChange,setTheme,withTheme,withThemeSync});
3
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/themes/context.ts"],
4
+ "sourcesContent": ["/**\n * @fileoverview Elegant theme context management.\n * Async-aware theming with automatic context isolation via AsyncLocalStorage.\n */\n\nimport { AsyncLocalStorage } from 'node:async_hooks'\n\nimport type { Theme } from './types'\nimport { SOCKET_THEME, THEMES, type ThemeName } from './themes'\n\n/**\n * Theme change event listener signature.\n */\nexport type ThemeChangeListener = (theme: Theme) => void\n\n/**\n * AsyncLocalStorage for theme context isolation.\n */\nconst themeStorage = new AsyncLocalStorage<Theme>()\n\n/**\n * Fallback theme for global context.\n */\nlet fallbackTheme: Theme = SOCKET_THEME\n\n/**\n * Registered theme change listeners.\n */\nconst listeners: Set<ThemeChangeListener> = new Set()\n\n/**\n * Set the global fallback theme.\n *\n * @param theme - Theme name or object\n *\n * @example\n * ```ts\n * setTheme('socket-firewall')\n * ```\n */\nexport function setTheme(theme: Theme | ThemeName): void {\n fallbackTheme = typeof theme === 'string' ? THEMES[theme] : theme\n emitThemeChange(fallbackTheme)\n}\n\n/**\n * Get the active theme from context.\n *\n * @returns Current theme\n *\n * @example\n * ```ts\n * const theme = getTheme()\n * console.log(theme.displayName)\n * ```\n */\nexport function getTheme(): Theme {\n return themeStorage.getStore() ?? fallbackTheme\n}\n\n/**\n * Execute async operation with scoped theme.\n * Theme automatically restored on completion.\n *\n * @template T - Return type\n * @param theme - Scoped theme\n * @param fn - Async operation\n * @returns Operation result\n *\n * @example\n * ```ts\n * await withTheme('ultra', async () => {\n * // Operations use Ultra theme\n * })\n * ```\n */\nexport async function withTheme<T>(\n theme: Theme | ThemeName,\n fn: () => Promise<T>,\n): Promise<T> {\n const resolvedTheme = typeof theme === 'string' ? THEMES[theme] : theme\n return await themeStorage.run(resolvedTheme, async () => {\n emitThemeChange(resolvedTheme)\n return await fn()\n })\n}\n\n/**\n * Execute sync operation with scoped theme.\n * Theme automatically restored on completion.\n *\n * @template T - Return type\n * @param theme - Scoped theme\n * @param fn - Sync operation\n * @returns Operation result\n *\n * @example\n * ```ts\n * const result = withThemeSync('coana', () => {\n * return processData()\n * })\n * ```\n */\nexport function withThemeSync<T>(theme: Theme | ThemeName, fn: () => T): T {\n const resolvedTheme = typeof theme === 'string' ? THEMES[theme] : theme\n return themeStorage.run(resolvedTheme, () => {\n emitThemeChange(resolvedTheme)\n return fn()\n })\n}\n\n/**\n * Subscribe to theme change events.\n *\n * @param listener - Change handler\n * @returns Unsubscribe function\n *\n * @example\n * ```ts\n * const unsubscribe = onThemeChange((theme) => {\n * console.log('Theme:', theme.displayName)\n * })\n *\n * // Cleanup\n * unsubscribe()\n * ```\n */\nexport function onThemeChange(listener: ThemeChangeListener): () => void {\n listeners.add(listener)\n return () => {\n listeners.delete(listener)\n }\n}\n\n/**\n * Emit theme change event to listeners.\n * @private\n */\nfunction emitThemeChange(theme: Theme): void {\n for (const listener of listeners) {\n listener(theme)\n }\n}\n"],
5
+ "mappings": ";4ZAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,cAAAE,EAAA,kBAAAC,EAAA,aAAAC,EAAA,cAAAC,EAAA,kBAAAC,IAAA,eAAAC,EAAAP,GAKA,IAAAQ,EAAkC,4BAGlCC,EAAqD,oBAUrD,MAAMC,EAAe,IAAI,oBAKzB,IAAIC,EAAuB,eAK3B,MAAMC,EAAsC,IAAI,IAYzC,SAASR,EAASS,EAAgC,CACvDF,EAAgB,OAAOE,GAAU,SAAW,SAAOA,CAAK,EAAIA,EAC5DC,EAAgBH,CAAa,CAC/B,CAaO,SAAST,GAAkB,CAChC,OAAOQ,EAAa,SAAS,GAAKC,CACpC,CAkBA,eAAsBN,EACpBQ,EACAE,EACY,CACZ,MAAMC,EAAgB,OAAOH,GAAU,SAAW,SAAOA,CAAK,EAAIA,EAClE,OAAO,MAAMH,EAAa,IAAIM,EAAe,UAC3CF,EAAgBE,CAAa,EACtB,MAAMD,EAAG,EACjB,CACH,CAkBO,SAAST,EAAiBO,EAA0BE,EAAgB,CACzE,MAAMC,EAAgB,OAAOH,GAAU,SAAW,SAAOA,CAAK,EAAIA,EAClE,OAAOH,EAAa,IAAIM,EAAe,KACrCF,EAAgBE,CAAa,EACtBD,EAAG,EACX,CACH,CAkBO,SAASZ,EAAcc,EAA2C,CACvE,OAAAL,EAAU,IAAIK,CAAQ,EACf,IAAM,CACXL,EAAU,OAAOK,CAAQ,CAC3B,CACF,CAMA,SAASH,EAAgBD,EAAoB,CAC3C,UAAWI,KAAYL,EACrBK,EAASJ,CAAK,CAElB",
6
+ "names": ["context_exports", "__export", "getTheme", "onThemeChange", "setTheme", "withTheme", "withThemeSync", "__toCommonJS", "import_node_async_hooks", "import_themes", "themeStorage", "fallbackTheme", "listeners", "theme", "emitThemeChange", "fn", "resolvedTheme", "listener"]
7
+ }
@@ -0,0 +1,53 @@
1
+ /**
2
+ * @fileoverview Elegant theming system for Socket libraries.
3
+ * Unified visual language across spinners, loggers, prompts, and links.
4
+ *
5
+ * @example
6
+ * ```ts
7
+ * import { setTheme, THEMES } from '@socketsecurity/lib/themes'
8
+ *
9
+ * // Set global theme
10
+ * setTheme('brick')
11
+ * ```
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * import { withTheme } from '@socketsecurity/lib/themes'
16
+ *
17
+ * // Scoped theme context
18
+ * await withTheme('ultra', async () => {
19
+ * // All operations inherit Ultra theme
20
+ * })
21
+ * ```
22
+ *
23
+ * @example
24
+ * ```ts
25
+ * import { createTheme } from '@socketsecurity/lib/themes'
26
+ *
27
+ * // Custom theme creation
28
+ * const myTheme = createTheme({
29
+ * name: 'custom',
30
+ * displayName: 'Custom Theme',
31
+ * colors: {
32
+ * primary: [255, 100, 200],
33
+ * success: 'greenBright',
34
+ * error: 'redBright',
35
+ * warning: 'yellowBright',
36
+ * info: 'blueBright',
37
+ * step: 'cyanBright',
38
+ * text: 'white',
39
+ * textDim: 'gray',
40
+ * link: 'cyanBright',
41
+ * prompt: 'primary'
42
+ * }
43
+ * })
44
+ * ```
45
+ */
46
+ // Type system
47
+ export type { ColorReference, Theme, ThemeColors, ThemeEffects, ThemeMeta, } from './types';
48
+ // Curated themes
49
+ export { BRICK_THEME, LUSH_THEME, SOCKET_THEME, SUNSET_THEME, THEMES, ULTRA_THEME, type ThemeName, } from './themes';
50
+ // Context management
51
+ export { getTheme, onThemeChange, setTheme, withTheme, withThemeSync, type ThemeChangeListener, } from './context';
52
+ // Composition utilities
53
+ export { createTheme, extendTheme, resolveColor, resolveShimmerColor, } from './utils';
@@ -0,0 +1,3 @@
1
+ /* Socket Lib - Built with esbuild */
2
+ var E=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var n=Object.prototype.hasOwnProperty;var s=(h,m)=>{for(var t in m)E(h,t,{get:m[t],enumerable:!0})},H=(h,m,t,p)=>{if(m&&typeof m=="object"||typeof m=="function")for(let r of f(m))!n.call(h,r)&&r!==t&&E(h,r,{get:()=>m[r],enumerable:!(p=C(m,r))||p.enumerable});return h};var M=h=>H(E({},"__esModule",{value:!0}),h);var S={};s(S,{BRICK_THEME:()=>e.BRICK_THEME,LUSH_THEME:()=>e.LUSH_THEME,SOCKET_THEME:()=>e.SOCKET_THEME,SUNSET_THEME:()=>e.SUNSET_THEME,THEMES:()=>e.THEMES,ULTRA_THEME:()=>e.ULTRA_THEME,createTheme:()=>o.createTheme,extendTheme:()=>o.extendTheme,getTheme:()=>T.getTheme,onThemeChange:()=>T.onThemeChange,resolveColor:()=>o.resolveColor,resolveShimmerColor:()=>o.resolveShimmerColor,setTheme:()=>T.setTheme,withTheme:()=>T.withTheme,withThemeSync:()=>T.withThemeSync});module.exports=M(S);var e=require("./themes"),T=require("./context"),o=require("./utils");0&&(module.exports={BRICK_THEME,LUSH_THEME,SOCKET_THEME,SUNSET_THEME,THEMES,ULTRA_THEME,createTheme,extendTheme,getTheme,onThemeChange,resolveColor,resolveShimmerColor,setTheme,withTheme,withThemeSync});
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/themes/index.ts"],
4
+ "sourcesContent": ["/**\n * @fileoverview Elegant theming system for Socket libraries.\n * Unified visual language across spinners, loggers, prompts, and links.\n *\n * @example\n * ```ts\n * import { setTheme, THEMES } from '@socketsecurity/lib/themes'\n *\n * // Set global theme\n * setTheme('brick')\n * ```\n *\n * @example\n * ```ts\n * import { withTheme } from '@socketsecurity/lib/themes'\n *\n * // Scoped theme context\n * await withTheme('ultra', async () => {\n * // All operations inherit Ultra theme\n * })\n * ```\n *\n * @example\n * ```ts\n * import { createTheme } from '@socketsecurity/lib/themes'\n *\n * // Custom theme creation\n * const myTheme = createTheme({\n * name: 'custom',\n * displayName: 'Custom Theme',\n * colors: {\n * primary: [255, 100, 200],\n * success: 'greenBright',\n * error: 'redBright',\n * warning: 'yellowBright',\n * info: 'blueBright',\n * step: 'cyanBright',\n * text: 'white',\n * textDim: 'gray',\n * link: 'cyanBright',\n * prompt: 'primary'\n * }\n * })\n * ```\n */\n\n// Type system\nexport type {\n ColorReference,\n Theme,\n ThemeColors,\n ThemeEffects,\n ThemeMeta,\n} from './types'\n\n// Curated themes\nexport {\n BRICK_THEME,\n LUSH_THEME,\n SOCKET_THEME,\n SUNSET_THEME,\n THEMES,\n ULTRA_THEME,\n type ThemeName,\n} from './themes'\n\n// Context management\nexport {\n getTheme,\n onThemeChange,\n setTheme,\n withTheme,\n withThemeSync,\n type ThemeChangeListener,\n} from './context'\n\n// Composition utilities\nexport {\n createTheme,\n extendTheme,\n resolveColor,\n resolveShimmerColor,\n} from './utils'\n"],
5
+ "mappings": ";4ZAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,sdAAAE,EAAAF,GAwDA,IAAAG,EAQO,oBAGPC,EAOO,qBAGPC,EAKO",
6
+ "names": ["themes_exports", "__export", "__toCommonJS", "import_themes", "import_context", "import_utils"]
7
+ }
@@ -0,0 +1,49 @@
1
+ /**
2
+ * @fileoverview Elegant theme definitions for Socket libraries.
3
+ * Sophisticated color palettes crafted for clarity and visual harmony.
4
+ *
5
+ * Philosophy: Every color choice serves a purpose. Bright variants ensure
6
+ * terminal legibility without compromising sophistication. Minimal emoji use,
7
+ * refined symbols with color—elegance in restraint.
8
+ */
9
+ import type { Theme } from './types';
10
+ /**
11
+ * Socket Security — The signature theme.
12
+ * Refined violet with subtle shimmer, designed for focus and elegance.
13
+ */
14
+ export declare const SOCKET_THEME: Theme;
15
+ /**
16
+ * Sunset — Crisp azure.
17
+ * Clean analytical theme with precise blue tones.
18
+ */
19
+ export declare const SUNSET_THEME: Theme;
20
+ /**
21
+ * Brick — Solid warmth.
22
+ * Rich terracotta and ember tones for grounded confidence.
23
+ */
24
+ export declare const BRICK_THEME: Theme;
25
+ /**
26
+ * Lush — Steel elegance.
27
+ * Python-inspired steel blue with golden accents.
28
+ */
29
+ export declare const LUSH_THEME: Theme;
30
+ /**
31
+ * Ultra — Premium intensity.
32
+ * Prismatic shimmer for deep analysis, where complexity meets elegance.
33
+ */
34
+ export declare const ULTRA_THEME: Theme;
35
+ /**
36
+ * Theme registry — Curated palette collection.
37
+ */
38
+ export declare const THEMES: {
39
+ readonly __proto__: any;
40
+ readonly socket: Theme;
41
+ readonly sunset: Theme;
42
+ readonly brick: Theme;
43
+ readonly lush: Theme;
44
+ readonly ultra: Theme;
45
+ };
46
+ /**
47
+ * Available theme identifiers.
48
+ */
49
+ export type ThemeName = keyof typeof THEMES;
@@ -0,0 +1,3 @@
1
+ /* Socket Lib - Built with esbuild */
2
+ var o=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var g=(r,e)=>{for(var i in e)o(r,i,{get:e[i],enumerable:!0})},d=(r,e,i,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of l(e))!y.call(r,t)&&t!==i&&o(r,t,{get:()=>e[t],enumerable:!(s=p(e,t))||s.enumerable});return r};var B=r=>d(o({},"__esModule",{value:!0}),r);var f={};g(f,{BRICK_THEME:()=>c,LUSH_THEME:()=>m,SOCKET_THEME:()=>n,SUNSET_THEME:()=>a,THEMES:()=>u,ULTRA_THEME:()=>h});module.exports=B(f);const n={name:"socket",displayName:"Socket Security",colors:{primary:[140,82,255],success:"greenBright",error:"redBright",warning:"yellowBright",info:"blueBright",step:"cyanBright",text:"white",textDim:"gray",link:"cyanBright",prompt:"primary"},effects:{spinner:{color:"primary",style:"socket"},shimmer:{enabled:!0,color:"inherit",direction:"ltr",speed:.33}},meta:{description:"Signature theme with refined violet and subtle shimmer",version:"1.0.0"}},a={name:"sunset",displayName:"Sunset",colors:{primary:[100,200,255],secondary:[50,150,200],success:"greenBright",error:"redBright",warning:"yellowBright",info:"blueBright",step:"cyanBright",text:"white",textDim:"gray",link:"cyanBright",prompt:"primary"},effects:{spinner:{color:"primary",style:"dots"}},meta:{description:"Crisp azure theme for precision and clarity",version:"1.0.0"}},c={name:"brick",displayName:"Brick",colors:{primary:[255,100,50],secondary:[255,150,100],success:"greenBright",error:"redBright",warning:"yellowBright",info:"blueBright",step:"cyanBright",text:"white",textDim:"gray",link:"secondary",prompt:"primary"},effects:{spinner:{color:"primary",style:"socket"},shimmer:{enabled:!0,color:"inherit",direction:"ltr",speed:.5}},meta:{description:"Solid theme with rich terracotta and ember warmth",version:"1.0.0"}},m={name:"lush",displayName:"Lush",colors:{primary:[70,130,180],secondary:[255,215,0],success:"greenBright",error:"redBright",warning:"yellowBright",info:"blueBright",step:"cyanBright",text:"white",textDim:"gray",link:"cyanBright",prompt:"primary"},effects:{spinner:{color:"primary",style:"dots"}},meta:{description:"Elegant theme with steel blue and golden harmony",version:"1.0.0"}},h={name:"ultra",displayName:"Ultra",colors:{primary:[140,82,255],success:"greenBright",error:"redBright",warning:"yellowBright",info:"cyanBright",step:"magentaBright",text:"whiteBright",textDim:"gray",link:"cyanBright",prompt:"primary"},effects:{spinner:{color:"inherit",style:"socket"},shimmer:{enabled:!0,color:"rainbow",direction:"bi",speed:.5}},meta:{description:"Premium theme with prismatic shimmer for deep analysis",version:"1.0.0"}},u={__proto__:null,socket:n,sunset:a,brick:c,lush:m,ultra:h};0&&(module.exports={BRICK_THEME,LUSH_THEME,SOCKET_THEME,SUNSET_THEME,THEMES,ULTRA_THEME});
3
+ //# sourceMappingURL=themes.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/themes/themes.ts"],
4
+ "sourcesContent": ["/**\n * @fileoverview Elegant theme definitions for Socket libraries.\n * Sophisticated color palettes crafted for clarity and visual harmony.\n *\n * Philosophy: Every color choice serves a purpose. Bright variants ensure\n * terminal legibility without compromising sophistication. Minimal emoji use,\n * refined symbols with color\u2014elegance in restraint.\n */\n\nimport type { Theme } from './types'\n\n/**\n * Socket Security \u2014 The signature theme.\n * Refined violet with subtle shimmer, designed for focus and elegance.\n */\nexport const SOCKET_THEME: Theme = {\n name: 'socket',\n displayName: 'Socket Security',\n colors: {\n primary: [140, 82, 255],\n success: 'greenBright',\n error: 'redBright',\n warning: 'yellowBright',\n info: 'blueBright',\n step: 'cyanBright',\n text: 'white',\n textDim: 'gray',\n link: 'cyanBright',\n prompt: 'primary',\n },\n effects: {\n spinner: {\n color: 'primary',\n style: 'socket',\n },\n shimmer: {\n enabled: true,\n color: 'inherit',\n direction: 'ltr',\n speed: 0.33,\n },\n },\n meta: {\n description: 'Signature theme with refined violet and subtle shimmer',\n version: '1.0.0',\n },\n}\n\n/**\n * Sunset \u2014 Crisp azure.\n * Clean analytical theme with precise blue tones.\n */\nexport const SUNSET_THEME: Theme = {\n name: 'sunset',\n displayName: 'Sunset',\n colors: {\n primary: [100, 200, 255],\n secondary: [50, 150, 200],\n success: 'greenBright',\n error: 'redBright',\n warning: 'yellowBright',\n info: 'blueBright',\n step: 'cyanBright',\n text: 'white',\n textDim: 'gray',\n link: 'cyanBright',\n prompt: 'primary',\n },\n effects: {\n spinner: {\n color: 'primary',\n style: 'dots',\n },\n },\n meta: {\n description: 'Crisp azure theme for precision and clarity',\n version: '1.0.0',\n },\n}\n\n/**\n * Brick \u2014 Solid warmth.\n * Rich terracotta and ember tones for grounded confidence.\n */\nexport const BRICK_THEME: Theme = {\n name: 'brick',\n displayName: 'Brick',\n colors: {\n primary: [255, 100, 50],\n secondary: [255, 150, 100],\n success: 'greenBright',\n error: 'redBright',\n warning: 'yellowBright',\n info: 'blueBright',\n step: 'cyanBright',\n text: 'white',\n textDim: 'gray',\n link: 'secondary',\n prompt: 'primary',\n },\n effects: {\n spinner: {\n color: 'primary',\n style: 'socket',\n },\n shimmer: {\n enabled: true,\n color: 'inherit',\n direction: 'ltr',\n speed: 0.5,\n },\n },\n meta: {\n description: 'Solid theme with rich terracotta and ember warmth',\n version: '1.0.0',\n },\n}\n\n/**\n * Lush \u2014 Steel elegance.\n * Python-inspired steel blue with golden accents.\n */\nexport const LUSH_THEME: Theme = {\n name: 'lush',\n displayName: 'Lush',\n colors: {\n primary: [70, 130, 180],\n secondary: [255, 215, 0],\n success: 'greenBright',\n error: 'redBright',\n warning: 'yellowBright',\n info: 'blueBright',\n step: 'cyanBright',\n text: 'white',\n textDim: 'gray',\n link: 'cyanBright',\n prompt: 'primary',\n },\n effects: {\n spinner: {\n color: 'primary',\n style: 'dots',\n },\n },\n meta: {\n description: 'Elegant theme with steel blue and golden harmony',\n version: '1.0.0',\n },\n}\n\n/**\n * Ultra \u2014 Premium intensity.\n * Prismatic shimmer for deep analysis, where complexity meets elegance.\n */\nexport const ULTRA_THEME: Theme = {\n name: 'ultra',\n displayName: 'Ultra',\n colors: {\n primary: [140, 82, 255],\n success: 'greenBright',\n error: 'redBright',\n warning: 'yellowBright',\n info: 'cyanBright',\n step: 'magentaBright',\n text: 'whiteBright',\n textDim: 'gray',\n link: 'cyanBright',\n prompt: 'primary',\n },\n effects: {\n spinner: {\n color: 'inherit',\n style: 'socket',\n },\n shimmer: {\n enabled: true,\n color: 'rainbow',\n direction: 'bi',\n speed: 0.5,\n },\n },\n meta: {\n description: 'Premium theme with prismatic shimmer for deep analysis',\n version: '1.0.0',\n },\n}\n\n/**\n * Theme registry \u2014 Curated palette collection.\n */\nexport const THEMES = {\n __proto__: null,\n socket: SOCKET_THEME,\n sunset: SUNSET_THEME,\n brick: BRICK_THEME,\n lush: LUSH_THEME,\n ultra: ULTRA_THEME,\n} as const\n\n/**\n * Available theme identifiers.\n */\nexport type ThemeName = keyof typeof THEMES\n"],
5
+ "mappings": ";4ZAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,iBAAAE,EAAA,eAAAC,EAAA,iBAAAC,EAAA,iBAAAC,EAAA,WAAAC,EAAA,gBAAAC,IAAA,eAAAC,EAAAR,GAeO,MAAMI,EAAsB,CACjC,KAAM,SACN,YAAa,kBACb,OAAQ,CACN,QAAS,CAAC,IAAK,GAAI,GAAG,EACtB,QAAS,cACT,MAAO,YACP,QAAS,eACT,KAAM,aACN,KAAM,aACN,KAAM,QACN,QAAS,OACT,KAAM,aACN,OAAQ,SACV,EACA,QAAS,CACP,QAAS,CACP,MAAO,UACP,MAAO,QACT,EACA,QAAS,CACP,QAAS,GACT,MAAO,UACP,UAAW,MACX,MAAO,GACT,CACF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AS,OACT,KAAM,aACN,OAAQ,SACV,EACA,QAAS,CACP,QAAS,CACP,MAAO,UACP,MAAO,QACT,EACA,QAAS,CACP,QAAS,GACT,MAAO,UACP,UAAW,KACX,MAAO,EACT,CACF,EACA,KAAM,CACJ,YAAa,yDACb,QAAS,OACX,CACF,EAKaD,EAAS,CACpB,UAAW,KACX,OAAQF,EACR,OAAQC,EACR,MAAOH,EACP,KAAMC,EACN,MAAOI,CACT",
6
+ "names": ["themes_exports", "__export", "BRICK_THEME", "LUSH_THEME", "SOCKET_THEME", "SUNSET_THEME", "THEMES", "ULTRA_THEME", "__toCommonJS"]
7
+ }
@@ -0,0 +1,92 @@
1
+ /**
2
+ * @fileoverview Elegant theme type system.
3
+ * Type-safe theming for spinners, loggers, prompts, and links.
4
+ */
5
+ import type { ColorValue, SpinnerStyle } from '../spinner';
6
+ import type { ShimmerDirection } from '../effects/text-shimmer';
7
+ /**
8
+ * Color reference — direct value or semantic keyword.
9
+ * Keywords: 'primary', 'secondary', 'inherit', 'rainbow'
10
+ */
11
+ export type ColorReference = ColorValue | 'primary' | 'secondary' | 'inherit' | 'rainbow';
12
+ /**
13
+ * Theme color palette — semantic colors for visual harmony.
14
+ */
15
+ export type ThemeColors = {
16
+ /** Primary brand identity */
17
+ primary: ColorValue;
18
+ /** Secondary accent (optional) */
19
+ secondary?: ColorValue | undefined;
20
+ /** Success indicator ✓ */
21
+ success: ColorValue;
22
+ /** Error indicator ✗ */
23
+ error: ColorValue;
24
+ /** Warning indicator ⚠ */
25
+ warning: ColorValue;
26
+ /** Information indicator ℹ */
27
+ info: ColorValue;
28
+ /** Progress indicator → */
29
+ step: ColorValue;
30
+ /** Primary text */
31
+ text: ColorValue;
32
+ /** Dimmed text */
33
+ textDim: ColorValue;
34
+ /** Hyperlinks */
35
+ link: ColorReference;
36
+ /** Interactive prompts */
37
+ prompt: ColorReference;
38
+ };
39
+ /**
40
+ * Theme effects — animations and visual enhancements.
41
+ */
42
+ export type ThemeEffects = {
43
+ /** Spinner configuration */
44
+ spinner?: {
45
+ /** Color (supports theme references) */
46
+ color?: ColorReference | undefined;
47
+ /** Animation style */
48
+ style?: SpinnerStyle | string | undefined;
49
+ };
50
+ /** Shimmer configuration */
51
+ shimmer?: {
52
+ /** Enable shimmer */
53
+ enabled?: boolean | undefined;
54
+ /** Color (single, gradient, or keyword) */
55
+ color?: ColorReference | ColorValue[] | undefined;
56
+ /** Direction */
57
+ direction?: ShimmerDirection | undefined;
58
+ /** Speed (steps per frame) */
59
+ speed?: number | undefined;
60
+ };
61
+ /** Pulse configuration */
62
+ pulse?: {
63
+ /** Speed (milliseconds) */
64
+ speed?: number | undefined;
65
+ };
66
+ };
67
+ /**
68
+ * Theme metadata — descriptive information.
69
+ */
70
+ export type ThemeMeta = {
71
+ /** Description */
72
+ description?: string | undefined;
73
+ /** Author */
74
+ author?: string | undefined;
75
+ /** Version */
76
+ version?: string | undefined;
77
+ };
78
+ /**
79
+ * Theme definition — complete visual identity.
80
+ */
81
+ export type Theme = {
82
+ /** Unique identifier (kebab-case) */
83
+ name: string;
84
+ /** Display name */
85
+ displayName: string;
86
+ /** Color palette */
87
+ colors: ThemeColors;
88
+ /** Visual effects (optional) */
89
+ effects?: ThemeEffects | undefined;
90
+ /** Metadata (optional) */
91
+ meta?: ThemeMeta | undefined;
92
+ };
@@ -0,0 +1,3 @@
1
+ /* Socket Lib - Built with esbuild */
2
+ var i=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var s=Object.prototype.hasOwnProperty;var u=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of d(e))!s.call(r,o)&&o!==t&&i(r,o,{get:()=>e[o],enumerable:!(n=l(e,o))||n.enumerable});return r};var f=r=>u(i({},"__esModule",{value:!0}),r);var m={};module.exports=f(m);
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/themes/types.ts"],
4
+ "sourcesContent": ["/**\n * @fileoverview Elegant theme type system.\n * Type-safe theming for spinners, loggers, prompts, and links.\n */\n\nimport type { ColorValue, SpinnerStyle } from '../spinner'\nimport type { ShimmerDirection } from '../effects/text-shimmer'\n\n/**\n * Color reference \u2014 direct value or semantic keyword.\n * Keywords: 'primary', 'secondary', 'inherit', 'rainbow'\n */\nexport type ColorReference =\n | ColorValue\n | 'primary'\n | 'secondary'\n | 'inherit'\n | 'rainbow'\n\n/**\n * Theme color palette \u2014 semantic colors for visual harmony.\n */\nexport type ThemeColors = {\n /** Primary brand identity */\n primary: ColorValue\n /** Secondary accent (optional) */\n secondary?: ColorValue | undefined\n\n /** Success indicator \u2713 */\n success: ColorValue\n /** Error indicator \u2717 */\n error: ColorValue\n /** Warning indicator \u26A0 */\n warning: ColorValue\n /** Information indicator \u2139 */\n info: ColorValue\n /** Progress indicator \u2192 */\n step: ColorValue\n\n /** Primary text */\n text: ColorValue\n /** Dimmed text */\n textDim: ColorValue\n /** Hyperlinks */\n link: ColorReference\n /** Interactive prompts */\n prompt: ColorReference\n}\n\n/**\n * Theme effects \u2014 animations and visual enhancements.\n */\nexport type ThemeEffects = {\n /** Spinner configuration */\n spinner?: {\n /** Color (supports theme references) */\n color?: ColorReference | undefined\n /** Animation style */\n style?: SpinnerStyle | string | undefined\n }\n\n /** Shimmer configuration */\n shimmer?: {\n /** Enable shimmer */\n enabled?: boolean | undefined\n /** Color (single, gradient, or keyword) */\n color?: ColorReference | ColorValue[] | undefined\n /** Direction */\n direction?: ShimmerDirection | undefined\n /** Speed (steps per frame) */\n speed?: number | undefined\n }\n\n /** Pulse configuration */\n pulse?: {\n /** Speed (milliseconds) */\n speed?: number | undefined\n }\n}\n\n/**\n * Theme metadata \u2014 descriptive information.\n */\nexport type ThemeMeta = {\n /** Description */\n description?: string | undefined\n /** Author */\n author?: string | undefined\n /** Version */\n version?: string | undefined\n}\n\n/**\n * Theme definition \u2014 complete visual identity.\n */\nexport type Theme = {\n /** Unique identifier (kebab-case) */\n name: string\n /** Display name */\n displayName: string\n\n /** Color palette */\n colors: ThemeColors\n\n /** Visual effects (optional) */\n effects?: ThemeEffects | undefined\n\n /** Metadata (optional) */\n meta?: ThemeMeta | undefined\n}\n"],
5
+ "mappings": ";kWAAA,IAAAA,EAAA,kBAAAC,EAAAD",
6
+ "names": ["types_exports", "__toCommonJS"]
7
+ }
@@ -0,0 +1,78 @@
1
+ import type { ColorValue } from '../spinner';
2
+ import type { ShimmerColorGradient } from '../effects/text-shimmer';
3
+ import type { Theme, ThemeColors, ColorReference } from './types';
4
+ /**
5
+ * Resolve color reference to concrete value.
6
+ * Handles semantic keywords: 'primary', 'secondary', 'rainbow', 'inherit'
7
+ *
8
+ * @param value - Color reference
9
+ * @param colors - Theme palette
10
+ * @returns Resolved color
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * resolveColor('primary', theme.colors)
15
+ * resolveColor([255, 0, 0], theme.colors)
16
+ * ```
17
+ */
18
+ export declare function resolveColor(value: ColorReference | ColorValue, colors: ThemeColors): ColorValue | 'inherit' | ShimmerColorGradient;
19
+ /**
20
+ * Resolve shimmer color with gradient support.
21
+ *
22
+ * @param value - Shimmer color
23
+ * @param theme - Theme context
24
+ * @returns Resolved color
25
+ *
26
+ * @example
27
+ * ```ts
28
+ * resolveShimmerColor('rainbow', theme)
29
+ * resolveShimmerColor('primary', theme)
30
+ * ```
31
+ */
32
+ export declare function resolveShimmerColor(value: ColorReference | ColorValue[] | undefined, theme: Theme): ColorValue | ShimmerColorGradient | 'inherit';
33
+ /**
34
+ * Extend existing theme with custom overrides.
35
+ * Deep merge of colors and effects.
36
+ *
37
+ * @param base - Base theme
38
+ * @param overrides - Custom overrides
39
+ * @returns Extended theme
40
+ *
41
+ * @example
42
+ * ```ts
43
+ * const custom = extendTheme(SOCKET_THEME, {
44
+ * name: 'custom',
45
+ * colors: { primary: [255, 100, 200] }
46
+ * })
47
+ * ```
48
+ */
49
+ export declare function extendTheme(base: Theme, overrides: Partial<Omit<Theme, 'colors'>> & {
50
+ colors?: Partial<ThemeColors> | undefined;
51
+ }): Theme;
52
+ /**
53
+ * Create new theme from complete specification.
54
+ *
55
+ * @param config - Theme configuration
56
+ * @returns Theme object
57
+ *
58
+ * @example
59
+ * ```ts
60
+ * const theme = createTheme({
61
+ * name: 'custom',
62
+ * displayName: 'Custom',
63
+ * colors: {
64
+ * primary: [255, 100, 200],
65
+ * success: 'greenBright',
66
+ * error: 'redBright',
67
+ * warning: 'yellowBright',
68
+ * info: 'blueBright',
69
+ * step: 'cyanBright',
70
+ * text: 'white',
71
+ * textDim: 'gray',
72
+ * link: 'cyanBright',
73
+ * prompt: 'primary'
74
+ * }
75
+ * })
76
+ * ```
77
+ */
78
+ export declare function createTheme(config: Pick<Theme, 'name' | 'displayName' | 'colors'> & Partial<Omit<Theme, 'name' | 'displayName' | 'colors'>>): Theme;
@@ -0,0 +1,3 @@
1
+ /* Socket Lib - Built with esbuild */
2
+ var n=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var _=Object.prototype.hasOwnProperty;var p=(e,r)=>{for(var o in r)n(e,o,{get:r[o],enumerable:!0})},h=(e,r,o,f)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of s(r))!_.call(e,t)&&t!==o&&n(e,t,{get:()=>r[t],enumerable:!(f=i(r,t))||f.enumerable});return e};var u=e=>h(n({},"__esModule",{value:!0}),e);var y={};p(y,{createTheme:()=>C,extendTheme:()=>c,resolveColor:()=>l,resolveShimmerColor:()=>a});module.exports=u(y);var m=require("../effects/ultra");function l(e,r){return typeof e=="string"?e==="primary"?r.primary:e==="secondary"?r.secondary??r.primary:e==="inherit"?"inherit":e==="rainbow"?m.RAINBOW_GRADIENT:e:e}function a(e,r){return e?e==="rainbow"?m.RAINBOW_GRADIENT:e==="inherit"?"inherit":Array.isArray(e)?(e.length>0&&Array.isArray(e[0]),e):l(e,r.colors):"inherit"}function c(e,r){return{__proto__:null,...e,...r,colors:{__proto__:null,...e.colors,...r.colors},effects:r.effects?{__proto__:null,...e.effects,...r.effects,spinner:r.effects.spinner!==void 0?{__proto__:null,...e.effects?.spinner,...r.effects.spinner}:e.effects?.spinner,shimmer:r.effects.shimmer!==void 0?{__proto__:null,...e.effects?.shimmer,...r.effects.shimmer}:e.effects?.shimmer,pulse:r.effects.pulse!==void 0?{__proto__:null,...e.effects?.pulse,...r.effects.pulse}:e.effects?.pulse}:e.effects,meta:r.meta?{__proto__:null,...e.meta,...r.meta}:e.meta}}function C(e){return{__proto__:null,name:e.name,displayName:e.displayName,colors:{__proto__:null,...e.colors},effects:e.effects?{__proto__:null,...e.effects}:void 0,meta:e.meta?{__proto__:null,...e.meta}:void 0}}0&&(module.exports={createTheme,extendTheme,resolveColor,resolveShimmerColor});
3
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/themes/utils.ts"],
4
+ "sourcesContent": ["/**\n * @fileoverview Theme utilities \u2014 color resolution and composition.\n */\n\nimport { RAINBOW_GRADIENT } from '../effects/ultra'\nimport type { ColorValue } from '../spinner'\nimport type { ShimmerColorGradient } from '../effects/text-shimmer'\nimport type { Theme, ThemeColors, ColorReference } from './types'\n\n/**\n * Resolve color reference to concrete value.\n * Handles semantic keywords: 'primary', 'secondary', 'rainbow', 'inherit'\n *\n * @param value - Color reference\n * @param colors - Theme palette\n * @returns Resolved color\n *\n * @example\n * ```ts\n * resolveColor('primary', theme.colors)\n * resolveColor([255, 0, 0], theme.colors)\n * ```\n */\nexport function resolveColor(\n value: ColorReference | ColorValue,\n colors: ThemeColors,\n): ColorValue | 'inherit' | ShimmerColorGradient {\n if (typeof value === 'string') {\n if (value === 'primary') {\n return colors.primary\n }\n if (value === 'secondary') {\n return colors.secondary ?? colors.primary\n }\n if (value === 'inherit') {\n return 'inherit'\n }\n if (value === 'rainbow') {\n return RAINBOW_GRADIENT\n }\n return value as ColorValue\n }\n return value as ColorValue\n}\n\n/**\n * Resolve shimmer color with gradient support.\n *\n * @param value - Shimmer color\n * @param theme - Theme context\n * @returns Resolved color\n *\n * @example\n * ```ts\n * resolveShimmerColor('rainbow', theme)\n * resolveShimmerColor('primary', theme)\n * ```\n */\nexport function resolveShimmerColor(\n value: ColorReference | ColorValue[] | undefined,\n theme: Theme,\n): ColorValue | ShimmerColorGradient | 'inherit' {\n if (!value) {\n return 'inherit'\n }\n if (value === 'rainbow') {\n return RAINBOW_GRADIENT\n }\n if (value === 'inherit') {\n return 'inherit'\n }\n if (Array.isArray(value)) {\n if (value.length > 0 && Array.isArray(value[0])) {\n // Gradient\n return value as ShimmerColorGradient\n }\n // Single RGB\n return value as unknown as ColorValue\n }\n return resolveColor(value as ColorReference, theme.colors)\n}\n\n/**\n * Extend existing theme with custom overrides.\n * Deep merge of colors and effects.\n *\n * @param base - Base theme\n * @param overrides - Custom overrides\n * @returns Extended theme\n *\n * @example\n * ```ts\n * const custom = extendTheme(SOCKET_THEME, {\n * name: 'custom',\n * colors: { primary: [255, 100, 200] }\n * })\n * ```\n */\nexport function extendTheme(\n base: Theme,\n overrides: Partial<Omit<Theme, 'colors'>> & {\n colors?: Partial<ThemeColors> | undefined\n },\n): Theme {\n return {\n __proto__: null,\n ...base,\n ...overrides,\n colors: {\n __proto__: null,\n ...base.colors,\n ...overrides.colors,\n } as ThemeColors,\n effects: overrides.effects\n ? {\n __proto__: null,\n ...base.effects,\n ...overrides.effects,\n spinner:\n overrides.effects.spinner !== undefined\n ? {\n __proto__: null,\n ...base.effects?.spinner,\n ...overrides.effects.spinner,\n }\n : base.effects?.spinner,\n shimmer:\n overrides.effects.shimmer !== undefined\n ? {\n __proto__: null,\n ...base.effects?.shimmer,\n ...overrides.effects.shimmer,\n }\n : base.effects?.shimmer,\n pulse:\n overrides.effects.pulse !== undefined\n ? {\n __proto__: null,\n ...base.effects?.pulse,\n ...overrides.effects.pulse,\n }\n : base.effects?.pulse,\n }\n : base.effects,\n meta: overrides.meta\n ? {\n __proto__: null,\n ...base.meta,\n ...overrides.meta,\n }\n : base.meta,\n } as Theme\n}\n\n/**\n * Create new theme from complete specification.\n *\n * @param config - Theme configuration\n * @returns Theme object\n *\n * @example\n * ```ts\n * const theme = createTheme({\n * name: 'custom',\n * displayName: 'Custom',\n * colors: {\n * primary: [255, 100, 200],\n * success: 'greenBright',\n * error: 'redBright',\n * warning: 'yellowBright',\n * info: 'blueBright',\n * step: 'cyanBright',\n * text: 'white',\n * textDim: 'gray',\n * link: 'cyanBright',\n * prompt: 'primary'\n * }\n * })\n * ```\n */\nexport function createTheme(\n config: Pick<Theme, 'name' | 'displayName' | 'colors'> &\n Partial<Omit<Theme, 'name' | 'displayName' | 'colors'>>,\n): Theme {\n return {\n __proto__: null,\n name: config.name,\n displayName: config.displayName,\n colors: { __proto__: null, ...config.colors } as ThemeColors,\n effects: config.effects\n ? { __proto__: null, ...config.effects }\n : undefined,\n meta: config.meta ? { __proto__: null, ...config.meta } : undefined,\n } as Theme\n}\n"],
5
+ "mappings": ";4ZAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,iBAAAE,EAAA,gBAAAC,EAAA,iBAAAC,EAAA,wBAAAC,IAAA,eAAAC,EAAAN,GAIA,IAAAO,EAAiC,4BAmB1B,SAASH,EACdI,EACAC,EAC+C,CAC/C,OAAI,OAAOD,GAAU,SACfA,IAAU,UACLC,EAAO,QAEZD,IAAU,YACLC,EAAO,WAAaA,EAAO,QAEhCD,IAAU,UACL,UAELA,IAAU,UACL,mBAEFA,EAEFA,CACT,CAeO,SAASH,EACdG,EACAE,EAC+C,CAC/C,OAAKF,EAGDA,IAAU,UACL,mBAELA,IAAU,UACL,UAEL,MAAM,QAAQA,CAAK,GACjBA,EAAM,OAAS,GAAK,MAAM,QAAQA,EAAM,CAAC,CAAC,EAErCA,GAKJJ,EAAaI,EAAyBE,EAAM,MAAM,EAhBhD,SAiBX,CAkBO,SAASP,EACdQ,EACAC,EAGO,CACP,MAAO,CACL,UAAW,KACX,GAAGD,EACH,GAAGC,EACH,OAAQ,CACN,UAAW,KACX,GAAGD,EAAK,OACR,GAAGC,EAAU,MACf,EACA,QAASA,EAAU,QACf,CACE,UAAW,KACX,GAAGD,EAAK,QACR,GAAGC,EAAU,QACb,QACEA,EAAU,QAAQ,UAAY,OAC1B,CACE,UAAW,KACX,GAAGD,EAAK,SAAS,QACjB,GAAGC,EAAU,QAAQ,OACvB,EACAD,EAAK,SAAS,QACpB,QACEC,EAAU,QAAQ,UAAY,OAC1B,CACE,UAAW,KACX,GAAGD,EAAK,SAAS,QACjB,GAAGC,EAAU,QAAQ,OACvB,EACAD,EAAK,SAAS,QACpB,MACEC,EAAU,QAAQ,QAAU,OACxB,CACE,UAAW,KACX,GAAGD,EAAK,SAAS,MACjB,GAAGC,EAAU,QAAQ,KACvB,EACAD,EAAK,SAAS,KACtB,EACAA,EAAK,QACT,KAAMC,EAAU,KACZ,CACE,UAAW,KACX,GAAGD,EAAK,KACR,GAAGC,EAAU,IACf,EACAD,EAAK,IACX,CACF,CA4BO,SAAST,EACdW,EAEO,CACP,MAAO,CACL,UAAW,KACX,KAAMA,EAAO,KACb,YAAaA,EAAO,YACpB,OAAQ,CAAE,UAAW,KAAM,GAAGA,EAAO,MAAO,EAC5C,QAASA,EAAO,QACZ,CAAE,UAAW,KAAM,GAAGA,EAAO,OAAQ,EACrC,OACJ,KAAMA,EAAO,KAAO,CAAE,UAAW,KAAM,GAAGA,EAAO,IAAK,EAAI,MAC5D,CACF",
6
+ "names": ["utils_exports", "__export", "createTheme", "extendTheme", "resolveColor", "resolveShimmerColor", "__toCommonJS", "import_ultra", "value", "colors", "theme", "base", "overrides", "config"]
7
+ }