@reliverse/relico 1.1.1 β†’ 1.2.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.
package/README.md CHANGED
@@ -1,9 +1,9 @@
1
1
  # Reliverse Relico
2
2
 
3
- [πŸ“š Docs](.github/DOCS.md) β€’ [πŸ“¦ NPM](https://npmjs.com/package/@reliverse/relico) β€’ [🌌 GitHub](https://github.com/reliverse/relico)
4
-
5
3
  > @reliverse/relico is a themeable, chainable, typed, truecolor-powered terminal styling toolkit β€” built for humans, not just terminals. It makes your CLI output beautiful, accessible, and expressive β€” with developer-first ergonomics, smart config, and blazing-fast performance.
6
4
 
5
+ [sponsor](https://github.com/sponsors/blefnk) β€” [discord](https://discord.gg/Pb8uKbwpsJ) β€” [repo](https://github.com/reliverse/relico) β€” [npm](https://npmjs.com/@reliverse/relico)
6
+
7
7
  ## 🌟 Why Relico?
8
8
 
9
9
  Because terminal styling shouldn’t feel like duct tape. **Relico** brings design-system-level polish to your CLI logs, banners, errors, and output β€” without battling your runtime, shell, or platform. Terminal styling should be *fun*, not frustrating. Relico makes it feel *right*.
@@ -19,7 +19,7 @@ Because terminal styling shouldn’t feel like duct tape. **Relico** brings desi
19
19
  - 🎯 **Precision-crafted ANSI output** β€” every color, reset, and style code is finely tuned for contrast, legibility, and glitch-free rendering β€” even in flaky terminals (as far as Node.js permits)
20
20
  - 🦾 **Relico isn’t just about color** β€” it’s about communication β€” make your CLI users' output more than readable β€” make it feel *intentional*.
21
21
 
22
- <img src="example.png" width="50%" alt="Available Relico colors" />
22
+ <img src="./example/example.png" width="50%" alt="Available Relico colors" />
23
23
 
24
24
  ## Installation
25
25
 
@@ -62,11 +62,10 @@ console.log(re.info("Custom config loaded!"));
62
62
  ## API Sneak Peek
63
63
 
64
64
  ```ts
65
- import { re, colorize, rgb } from "@reliverse/relico";
65
+ import { re, rgb } from "@reliverse/relico";
66
66
 
67
67
  console.log(re.red("Red!"));
68
68
  console.log(re.bold(re.green("Bold green")));
69
- console.log(colorize("magenta", "Hello!"));
70
69
 
71
70
  console.log(rgb(250, 128, 114)("This is salmon"));
72
71
  ```
@@ -275,7 +274,7 @@ bun i
275
274
  bun dev
276
275
  ```
277
276
 
278
- Check `examples/e-mod.ts` for all the fun.
277
+ Check `example/e-mod.ts` for all the fun.
279
278
 
280
279
  ## Use Cases
281
280
 
package/bin/mod.d.ts CHANGED
@@ -137,11 +137,9 @@ export declare function configure(userInput: unknown): void;
137
137
  * Returns a color function by name (or `reset` or identity if not found).
138
138
  * Uses cached functions for better performance.
139
139
  */
140
- export declare function getColor(name: string): (text: string | number) => string;
141
140
  /**
142
141
  * Colorizes text with a color function.
143
142
  */
144
- export declare function colorize(name: string, text: string | number): string;
145
143
  /**
146
144
  * Sets the color level (0=none, 1=basic, 2=256, 3=truecolor).
147
145
  */
@@ -333,11 +331,6 @@ export declare function colorizeJson(obj: unknown, options?: {
333
331
  indent?: number;
334
332
  compact?: boolean;
335
333
  }): string;
336
- /**
337
- * Initialize user configuration with optional programmatic overrides
338
- * @param programmaticConfig Optional configuration to override default settings
339
- * @param userSettingsPrecedence If true, user file settings take precedence over programmatic
340
- */
341
334
  /**
342
335
  * Initialize user configuration with optional programmatic overrides
343
336
  * @param programmaticConfig Optional configuration to override settings
package/bin/mod.js CHANGED
@@ -99,9 +99,7 @@ export const defaultColorKeys = [
99
99
  const argv = typeof process === "undefined" ? [] : process.argv;
100
100
  const isDisabled = Boolean(env.NO_COLOR) || argv.includes("--no-color");
101
101
  const isForced = Boolean(env.FORCE_COLOR) || argv.includes("--color");
102
- const isCI = Boolean(
103
- env.CI && (env.GITHUB_ACTIONS || env.GITLAB_CI || env.CIRCLECI)
104
- );
102
+ const isCI = Boolean(env.CI && (env.GITHUB_ACTIONS || env.GITLAB_CI || env.CIRCLECI));
105
103
  const isOtherCI = Boolean(
106
104
  env.CI && (env.TRAVIS || env.APPVEYOR || env.JENKINS_URL || env.BITBUCKET_BUILD_NUMBER || env.TEAMCITY_VERSION)
107
105
  );
@@ -465,9 +463,7 @@ function hexToAnsiBasic(hex2, isBg = false) {
465
463
  const distanceKey = `${r},${g},${b}`;
466
464
  let distances;
467
465
  if (colorDistances.has(distanceKey)) {
468
- distances = colorDistances.get(distanceKey) ?? shouldNeverHappen(
469
- "Relico expected to use a color cache, but it's missing."
470
- );
466
+ distances = colorDistances.get(distanceKey) ?? shouldNeverHappen("Relico expected to use a color cache, but it's missing.");
471
467
  } else {
472
468
  distances = basicColors.map((color) => {
473
469
  const dr = r - color.rgb.r;
@@ -582,9 +578,7 @@ function initColorFunctions() {
582
578
  for (const [key, [open, close]] of Object.entries(colorMap)) {
583
579
  const cacheKey = `formatter:${open}:${close}`;
584
580
  if (formatterCache.has(cacheKey)) {
585
- colorFunctions[key] = formatterCache.get(cacheKey) ?? shouldNeverHappen(
586
- "Relico expected to use a formatter cache, but it's missing."
587
- );
581
+ colorFunctions[key] = formatterCache.get(cacheKey) ?? shouldNeverHappen("Relico expected to use a formatter cache, but it's missing.");
588
582
  } else {
589
583
  const formatter = createFormatter(open, close);
590
584
  formatterCache.set(cacheKey, formatter);
@@ -626,12 +620,6 @@ export function configure(userInput) {
626
620
  config = newConfig;
627
621
  }
628
622
  }
629
- export function getColor(name) {
630
- return colorFunctions[name] || colorFunctions.reset || identityColor;
631
- }
632
- export function colorize(name, text) {
633
- return getColor(name)(text);
634
- }
635
623
  export function setColorLevel(level) {
636
624
  if (config.colorLevel !== level) {
637
625
  configure({ colorLevel: level });
@@ -802,9 +790,7 @@ export function chain(...formatters) {
802
790
  if (formatters.length === 0) return identityColor;
803
791
  if (formatters.length === 1) return formatters[0];
804
792
  if (config.colorLevel === 0) return identityColor;
805
- const cacheKey = `chain:${formatters.map(
806
- (f) => f.name || formatterCache.entries().next().value?.[0] || "custom"
807
- ).join(",")}`;
793
+ const cacheKey = `chain:${formatters.map((f) => f.name || formatterCache.entries().next().value?.[0] || "custom").join(",")}`;
808
794
  if (formatterCache.has(cacheKey)) {
809
795
  return formatterCache.get(cacheKey);
810
796
  }
@@ -859,9 +845,7 @@ export function multiGradient(text, colors, options) {
859
845
  if (chars.length === 0) return "";
860
846
  const smoothing = options?.smoothing ?? 1;
861
847
  const distribution = options?.distribution ?? "even";
862
- const rgbColors = colors.map(
863
- (color) => hexToRGB(normalizeColor(color))
864
- );
848
+ const rgbColors = colors.map((color) => hexToRGB(normalizeColor(color)));
865
849
  let result = "";
866
850
  for (let i = 0; i < chars.length; i++) {
867
851
  let gradientPos;
@@ -876,15 +860,9 @@ export function multiGradient(text, colors, options) {
876
860
  const segmentOffset = segmentPos - segmentIndex;
877
861
  const startColor = rgbColors[segmentIndex];
878
862
  const endColor = rgbColors[segmentIndex + 1];
879
- const r = Math.round(
880
- startColor.r + segmentOffset * (endColor.r - startColor.r)
881
- );
882
- const g = Math.round(
883
- startColor.g + segmentOffset * (endColor.g - startColor.g)
884
- );
885
- const b = Math.round(
886
- startColor.b + segmentOffset * (endColor.b - startColor.b)
887
- );
863
+ const r = Math.round(startColor.r + segmentOffset * (endColor.r - startColor.r));
864
+ const g = Math.round(startColor.g + segmentOffset * (endColor.g - startColor.g));
865
+ const b = Math.round(startColor.b + segmentOffset * (endColor.b - startColor.b));
888
866
  const colorFn = rgb(r, g, b);
889
867
  result += colorFn(chars[i]);
890
868
  }
@@ -898,9 +876,7 @@ export function blend(color1, color2, ratio = 0.5) {
898
876
  ratio = Math.max(0, Math.min(1, ratio));
899
877
  if (ratio === 0) return hex(color1);
900
878
  if (ratio === 1) return hex(color2);
901
- const cacheKey = `blend:${normalizeColor(color1)}:${normalizeColor(
902
- color2
903
- )}:${ratio.toFixed(3)}`;
879
+ const cacheKey = `blend:${normalizeColor(color1)}:${normalizeColor(color2)}:${ratio.toFixed(3)}`;
904
880
  if (formatterCache.has(cacheKey)) {
905
881
  return formatterCache.get(cacheKey);
906
882
  }
@@ -1146,10 +1122,7 @@ export function colorizeJson(obj, options) {
1146
1122
  }
1147
1123
  const indent = options?.indent ?? 2;
1148
1124
  const json = JSON.stringify(obj, null, options?.compact ? 0 : indent);
1149
- return json.replace(/"(\\.|[^"\\])*"(?=\s*:)/g, (match) => re.cyan(match)).replace(
1150
- /:\s*"(\\.|[^"\\])*"/g,
1151
- (match) => `: ${re.green(match.slice(match.indexOf('"')))}`
1152
- ).replace(
1125
+ return json.replace(/"(\\.|[^"\\])*"(?=\s*:)/g, (match) => re.cyan(match)).replace(/:\s*"(\\.|[^"\\])*"/g, (match) => `: ${re.green(match.slice(match.indexOf('"')))}`).replace(
1153
1126
  /:\s*\b(true|false|null)\b/g,
1154
1127
  (match) => `: ${re.yellow(match.slice(match.indexOf(":") + 1))}`
1155
1128
  ).replace(
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "dependencies": {
3
3
  "@reliverse/runtime": "^1.0.3",
4
- "c12": "^3.0.3",
4
+ "c12": "^3.1.0",
5
5
  "pathe": "^2.0.3"
6
6
  },
7
7
  "description": "@reliverse/relico is a themeable, chainable, typed, truecolor-powered, modern terminal styling toolkit. Designed to make your CLI output colorful, accessible, and human-friendly. It gives you a flexible way to apply colors and styles β€” with reliability and a smart developer experience baked in. Built for humans, not just terminals.",
@@ -9,7 +9,7 @@
9
9
  "license": "MIT",
10
10
  "name": "@reliverse/relico",
11
11
  "type": "module",
12
- "version": "1.1.1",
12
+ "version": "1.2.0",
13
13
  "author": "reliverse",
14
14
  "bugs": {
15
15
  "email": "blefnk@gmail.com",
@@ -22,23 +22,7 @@
22
22
  "type": "git",
23
23
  "url": "git+https://github.com/reliverse/relico.git"
24
24
  },
25
- "devDependencies": {
26
- "@biomejs/biome": "1.9.4",
27
- "@eslint/js": "^9.26.0",
28
- "@reliverse/relidler-cfg": "^1.1.3",
29
- "@stylistic/eslint-plugin": "^4.2.0",
30
- "@total-typescript/ts-reset": "^0.6.1",
31
- "@types/bun": "^1.2.13",
32
- "@types/node": "^22.15.17",
33
- "eslint": "^9.26.0",
34
- "eslint-plugin-no-relative-import-paths": "^1.6.1",
35
- "eslint-plugin-perfectionist": "^4.13.0",
36
- "jiti": "^2.4.2",
37
- "knip": "^5.55.1",
38
- "typescript": "^5.8.3",
39
- "typescript-eslint": "^8.32.1",
40
- "vitest": "^3.1.3"
41
- },
25
+ "devDependencies": {},
42
26
  "exports": {
43
27
  ".": "./bin/mod.js"
44
28
  },
@@ -53,4 +37,4 @@
53
37
  "publishConfig": {
54
38
  "access": "public"
55
39
  }
56
- }
40
+ }