{"_id":"@0xkahi/cli-dye","_rev":"2-004bcb67ec4439afdba619f68cac8478","name":"@0xkahi/cli-dye","dist-tags":{"latest":"1.1.0"},"versions":{"1.0.0":{"name":"@0xkahi/cli-dye","version":"1.0.0","keywords":["ansi","cli","color","colors","console","terminal"],"author":{"name":"0xKahi"},"_id":"@0xkahi/cli-dye@1.0.0","maintainers":[{"name":"0xkahi","email":"waifumaximalist@gmail.com"}],"homepage":"https://github.com/0xKahi/cli-dye#readme","bugs":{"url":"https://github.com/0xKahi/cli-dye/issues"},"dist":{"shasum":"910196871ba478ad27868fddf5d0de4e3f3db401","tarball":"https://registry.npmjs.org/@0xkahi/cli-dye/-/cli-dye-1.0.0.tgz","fileCount":4,"integrity":"sha512-M/DyFBCu8MAC5/5DPH2MKEiXS2B9/paDkT4v4QRJVvBgzginc8eTyep6vX4ZXfNzjP2KGM8wpysXsifmppCkrA==","signatures":[{"sig":"MEQCIB9QbcvVPfoLXZYsxRAKipoPaVQgG3VeJjeCpcmUmQdOAiADcfW0Uhn7TzFLiXg9OLI0Loh9nU/34fn3UIHrITsiAw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":11883},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"gitHead":"161ee4a8343683a9f1873038dcd6a5ff35c3bbd1","private":false,"scripts":{"lint":"bun biome","test":"bun test","biome":"biome check ./src ./test","build":"rm -rf dist && bun build ./src/index.ts --outdir ./dist --target node && tsc --project tsconfig.build.json","check":"bun run lint && bun run type-check","release":"changeset publish","version":"changeset version","lint:fix":"bun biome --write","changeset":"changeset","type-check":"tsc --noEmit"},"_npmUser":{"name":"0xkahi","email":"waifumaximalist@gmail.com"},"repository":{"url":"git+https://github.com/0xKahi/cli-dye.git","type":"git"},"_npmVersion":"10.9.8","description":"fast nodejs cli library for formatting terminal text","directories":{},"_nodeVersion":"22.23.1","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"bun-types":"latest","@types/bun":"latest","typescript":"^5","@types/node":"^24.0.0","@biomejs/biome":"^2.4.15","@changesets/cli":"^2.31.0"},"_npmOperationalInternal":{"tmp":"tmp/cli-dye_1.0.0_1783810254340_0.7722261771887784","host":"s3://npm-registry-packages-npm-production"}},"1.1.0":{"name":"@0xkahi/cli-dye","version":"1.1.0","private":false,"description":"fast nodejs cli library for formatting terminal text","type":"module","main":"./dist/index.js","module":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"author":{"name":"0xKahi"},"keywords":["ansi","cli","color","colors","console","terminal"],"publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/0xKahi/cli-dye.git"},"scripts":{"biome":"biome check ./src ./test","lint":"bun biome","lint:fix":"bun biome --write","test":"bun test","type-check":"tsc --noEmit","check":"bun run lint && bun run type-check","build":"rm -rf dist && bun build ./src/index.ts --outdir ./dist --target node && tsc --project tsconfig.build.json","changeset":"changeset","release":"changeset publish","version":"changeset version"},"devDependencies":{"@biomejs/biome":"^2.4.15","@changesets/cli":"^2.31.0","@types/bun":"latest","@types/node":"^24.0.0","bun-types":"latest","typescript":"^5"},"_id":"@0xkahi/cli-dye@1.1.0","gitHead":"27e2f93badadcd493a53a557e40a22a487df98cc","bugs":{"url":"https://github.com/0xKahi/cli-dye/issues"},"homepage":"https://github.com/0xKahi/cli-dye#readme","_nodeVersion":"22.23.1","_npmVersion":"10.9.8","dist":{"integrity":"sha512-bX8TRF7/ZbBMe7cUt1/Tj5tqKsuJYyMJMEQrRsaRyZ5JX0K2Y2oPZ/DR3hp9hmxZJbcgQQik1DDIaz1x0LNWxQ==","shasum":"126ad686df3ab505144a532eb9c94249eac21edd","tarball":"https://registry.npmjs.org/@0xkahi/cli-dye/-/cli-dye-1.1.0.tgz","fileCount":4,"unpackedSize":14695,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIAQ3iHB03IU4tBR8qemCGbgg+Tzea9md2V4BcE8sNOZ0AiAKL+GOMYE1WFhWB+SLP+tfjvtkpwP6ntK5VT7WXhCi1A=="}]},"_npmUser":{"name":"0xkahi","email":"waifumaximalist@gmail.com"},"directories":{},"maintainers":[{"name":"0xkahi","email":"waifumaximalist@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/cli-dye_1.1.0_1783822083044_0.7627753792251624"},"_hasShrinkwrap":false}},"time":{"created":"2026-07-11T22:50:54.071Z","modified":"2026-07-12T02:08:03.282Z","1.0.0":"2026-07-11T22:50:54.484Z","1.1.0":"2026-07-12T02:08:03.175Z"},"bugs":{"url":"https://github.com/0xKahi/cli-dye/issues"},"author":{"name":"0xKahi"},"homepage":"https://github.com/0xKahi/cli-dye#readme","keywords":["ansi","cli","color","colors","console","terminal"],"repository":{"type":"git","url":"git+https://github.com/0xKahi/cli-dye.git"},"description":"fast nodejs cli library for formatting terminal text","maintainers":[{"name":"0xkahi","email":"waifumaximalist@gmail.com"}],"readme":"# @0xkahi/cli-dye\n\nA lightweight, dependency-free ANSI styling library for terminal output.\n\nDye provides reusable modifier chains, named terminal colors, truecolor hexadecimal values, automatic color detection, and ANSI stripping while always returning primitive strings.\n\n## Installation\n\n```sh\nnpm install @0xkahi/cli-dye\n```\n\n```sh\nbun add @0xkahi/cli-dye\n```\n\n## Usage\n\n```ts\nimport { dye } from '@0xkahi/cli-dye';\n\nconsole.log(dye.bold('Important'));\nconsole.log(dye.italic().underline('Styled text'));\nconsole.log(dye.colorize('Success', { fg: 'brightGreen' }));\n```\n\n## Modifiers\n\nDye supports the following modifiers:\n\n- `reset`\n- `bold`\n- `dim`\n- `italic`\n- `underline`\n- `inverse`\n- `hidden`\n- `strikethrough`\n\nUse a modifier directly:\n\n```ts\nconst message = dye.bold('Hello');\n```\n\nOr call it without text to create a reusable builder:\n\n```ts\nconst heading = dye.bold().underline();\n\nconsole.log(heading('First heading'));\nconsole.log(heading('Second heading'));\n```\n\nModifiers can be chained in any order. Repeated modifiers are automatically deduplicated.\n\n## Colors\n\nUse `colorize()` to apply an optional foreground, background, or both:\n\n```ts\nconsole.log(dye.colorize('Error', { fg: 'brightWhite', bg: 'red' }));\nconsole.log(dye.colorize('Info', { fg: 'cyan' }));\nconsole.log(dye.colorize('Highlighted', { bg: 'yellow' }));\n```\n\n### Named colors\n\nThe following foreground and background colors are available:\n\n| Regular | Bright |\n| --- | --- |\n| `black` | `brightBlack` |\n| `red` | `brightRed` |\n| `green` | `brightGreen` |\n| `yellow` | `brightYellow` |\n| `blue` | `brightBlue` |\n| `magenta` | `brightMagenta` |\n| `cyan` | `brightCyan` |\n| `white` | `brightWhite` |\n| `gray` | |\n\n> The exact appearance of named colors depends on the user's terminal palette. `gray` and `brightBlack` use the same ANSI color code.\n\n### Hexadecimal colors\n\nCreate truecolor values with `dye.hex()`:\n\n```ts\nconst pink = dye.hex('#ed7892');\nconst blue = dye.hex('#00f');\n\nconsole.log(dye.colorize('Truecolor', {\n  fg: pink,\n  bg: blue,\n}));\n```\n\nBoth `#RGB` and `#RRGGBB` forms are accepted, case-insensitively. Hashless values, invalid digits, and alpha-bearing values throw a `TypeError`.\n\nHex colors are emitted directly using terminal 24-bit color sequences. Dye does not convert them to ANSI-256 or ANSI-16 palettes.\n\n## Color builders\n\nCalling `colorize()` with only options creates a reusable builder. Color builders support all modifiers:\n\n```ts\nconst warning = dye\n  .colorize({ fg: 'brightYellow' })\n  .bold()\n  .underline();\n\nconsole.log(warning('Check your configuration'));\nconsole.log(warning('Connection is unstable'));\n```\n\nRendered values are always primitive strings—not string-like wrapper objects.\n\n## Color output control\n\nDye detects terminal color support when the module is loaded. The resolved state is exposed through the read-only `enabled` property:\n\n```ts\nconsole.log(dye.enabled);\n```\n\nOverride color output when needed:\n\n```ts\ndye.setEnabled(true);      // Always emit ANSI sequences\ndye.setEnabled(false);     // Always return plain text\ndye.setEnabled(undefined); // Restore automatic detection\n```\n\nWhen output is disabled, styling and color functions return the supplied text without adding ANSI sequences.\n\nDye respects common terminal signals, including TTY support, `NO_COLOR`, `FORCE_COLOR`, and `TERM=dumb`.\n\n## Strip ANSI sequences\n\nUse `strip()` to remove ANSI CSI sequences from a string:\n\n```ts\nconst message = dye.colorize({ fg: 'red' }).bold('Failure');\n\nconsole.log(dye.strip(message)); // \"Failure\"\n```\n\nIt works with modifier-only output too:\n\n```ts\nconsole.log(dye.strip(dye.bold('Hello'))); // \"Hello\"\n```\n\n`strip()` also removes supported CSI sequences generated by other ANSI libraries.\n\n## TypeScript\n\nDye includes TypeScript declarations and exports its public color and builder types:\n\n```ts\nimport { dye } from '@0xkahi/cli-dye';\nimport type {\n  DyeColor,\n  ColorizeOptions,\n  HexColor,\n  StandardColor,\n  DyeStyler,\n} from '@0xkahi/cli-dye';\n```\n\n## API\n\n### `dye.<modifier>(text)`\n\nApplies a modifier immediately and returns a string.\n\n### `dye.<modifier>()`\n\nReturns a reusable `DyeStyler` builder.\n\n### `dye.colorize(text, options?)`\n\nApplies foreground and/or background colors immediately.\n\n### `dye.colorize(options?)`\n\nReturns a reusable color and modifier builder.\n\n### `dye.hex(value)`\n\nValidates and converts `#RGB` or `#RRGGBB` into an opaque `HexColor`.\n\n### `dye.strip(text)`\n\nRemoves ANSI CSI escape sequences.\n\n### `dye.enabled`\n\nReports whether styling output is currently enabled.\n\n### `dye.setEnabled(value)`\n\nSets a `true` or `false` override. Pass `undefined` to restore automatic detection.\n","readmeFilename":"README.md"}