@visulima/colorize 2.0.0-alpha.8 → 2.0.0-alpha.9

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/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ ## @visulima/colorize [2.0.0-alpha.9](https://github.com/visulima/visulima/compare/@visulima/colorize@2.0.0-alpha.8...@visulima/colorize@2.0.0-alpha.9) (2026-04-15)
2
+
3
+ ### Bug Fixes
4
+
5
+ * **colorize:** resolve eslint and formatting issues ([edc292a](https://github.com/visulima/visulima/commit/edc292a567fb3a97e6428e6fee86b47137e00952))
6
+ * **terminal:** resolve eslint and formatting issues ([8f30389](https://github.com/visulima/visulima/commit/8f30389deb9ff81e7afce0aa064ef11fcb179f23))
7
+
8
+
9
+ ### Dependencies
10
+
11
+ * **@visulima/is-ansi-color-supported:** upgraded to 3.0.0-alpha.9
12
+
1
13
  ## @visulima/colorize [2.0.0-alpha.8](https://github.com/visulima/visulima/compare/@visulima/colorize@2.0.0-alpha.7...@visulima/colorize@2.0.0-alpha.8) (2026-04-08)
2
14
 
3
15
  ### Bug Fixes
package/dist/gradient.cjs CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
4
4
 
5
- const colorize_server = require('./packem_shared/colorize.server-BFVt4Z2R.cjs');
5
+ const colorize_server = require('./packem_shared/colorize.server-XetY_pdz.cjs');
6
6
  const GradientBuilder = require('./packem_shared/GradientBuilder-DRrwebdU.cjs');
7
7
 
8
8
  const colorize = new colorize_server.Colorize();
@@ -4,11 +4,11 @@ export declare const gradient: (stops: (ColorValueHex | CssColorName | RGB | Sto
4
4
  interpolation?: "hsv" | "rgb";
5
5
  loop?: boolean;
6
6
  reverse?: boolean;
7
- }) => (string_: string) => string;
7
+ }) => ((string_: string) => string);
8
8
  export declare const multilineGradient: (stops: (ColorValueHex | CssColorName | RGB | StopInput | [number, number, number])[], options?: {
9
9
  hsvSpin?: "long" | "short";
10
10
  interpolation?: "hsv" | "rgb";
11
11
  loop?: boolean;
12
12
  reverse?: boolean;
13
- }) => (string_: string) => string;
13
+ }) => ((string_: string) => string);
14
14
  export { GradientBuilder } from "./gradient/gradient-builder.d.cts";
@@ -4,11 +4,11 @@ export declare const gradient: (stops: (ColorValueHex | CssColorName | RGB | Sto
4
4
  interpolation?: "hsv" | "rgb";
5
5
  loop?: boolean;
6
6
  reverse?: boolean;
7
- }) => (string_: string) => string;
7
+ }) => ((string_: string) => string);
8
8
  export declare const multilineGradient: (stops: (ColorValueHex | CssColorName | RGB | StopInput | [number, number, number])[], options?: {
9
9
  hsvSpin?: "long" | "short";
10
10
  interpolation?: "hsv" | "rgb";
11
11
  loop?: boolean;
12
12
  reverse?: boolean;
13
- }) => (string_: string) => string;
13
+ }) => ((string_: string) => string);
14
14
  export { GradientBuilder } from "./gradient/gradient-builder.d.mts";
@@ -4,11 +4,11 @@ export declare const gradient: (stops: (ColorValueHex | CssColorName | RGB | Sto
4
4
  interpolation?: "hsv" | "rgb";
5
5
  loop?: boolean;
6
6
  reverse?: boolean;
7
- }) => (string_: string) => string;
7
+ }) => ((string_: string) => string);
8
8
  export declare const multilineGradient: (stops: (ColorValueHex | CssColorName | RGB | StopInput | [number, number, number])[], options?: {
9
9
  hsvSpin?: "long" | "short";
10
10
  interpolation?: "hsv" | "rgb";
11
11
  loop?: boolean;
12
12
  reverse?: boolean;
13
- }) => (string_: string) => string;
13
+ }) => ((string_: string) => string);
14
14
  export { GradientBuilder } from "./gradient/gradient-builder.d.ts";
package/dist/gradient.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { C as Colorize } from './packem_shared/colorize.server-BVtbrTcf.mjs';
1
+ import { C as Colorize } from './packem_shared/colorize.server-DeZHO6IN.mjs';
2
2
  import { GradientBuilder } from './packem_shared/GradientBuilder-CkX4Imo9.mjs';
3
3
 
4
4
  const colorize = new Colorize();
@@ -10,7 +10,12 @@ function ansiRegex({ onlyFirst = false } = {}) {
10
10
  return new RegExp(pattern, onlyFirst ? void 0 : "g");
11
11
  }
12
12
 
13
- const clamp = (number_, min, max) => min > number_ ? min : Math.min(number_, max);
13
+ const clamp = (number_, min, max) => {
14
+ if (min > number_) {
15
+ return min;
16
+ }
17
+ return Math.min(number_, max);
18
+ };
14
19
 
15
20
  const HEX_COLOR_REGEX = /([a-f\d]{3,6})/i;
16
21
  const convertHexToRgb = (hex) => {
@@ -38,7 +43,8 @@ const rgbToAnsi256 = (r, g, b) => {
38
43
  }
39
44
  return Math.round((r - 8) / 247 * 24) + 232;
40
45
  }
41
- return 16 + 36 * Math.round(r / 51) + 6 * Math.round(g / 51) + Math.round(b / 51);
46
+ return 16 + // r / 255 * 5 => r / 51
47
+ 36 * Math.round(r / 51) + 6 * Math.round(g / 51) + Math.round(b / 51);
42
48
  };
43
49
  const ansi256To16 = (code) => {
44
50
  let r;
@@ -1,4 +1,4 @@
1
- import Colorize from './packem_shared/Colorize-ByTph984.js';
1
+ import Colorize from './packem_shared/Colorize-q7kOM0WA.js';
2
2
 
3
3
  const colorize = new Colorize();
4
4
  const ansi256 = colorize.ansi256;
@@ -8,7 +8,12 @@ function ansiRegex({ onlyFirst = false } = {}) {
8
8
  return new RegExp(pattern, onlyFirst ? void 0 : "g");
9
9
  }
10
10
 
11
- const clamp = (number_, min, max) => min > number_ ? min : Math.min(number_, max);
11
+ const clamp = (number_, min, max) => {
12
+ if (min > number_) {
13
+ return min;
14
+ }
15
+ return Math.min(number_, max);
16
+ };
12
17
 
13
18
  const HEX_COLOR_REGEX = /([a-f\d]{3,6})/i;
14
19
  const convertHexToRgb = (hex) => {
@@ -36,7 +41,8 @@ const rgbToAnsi256 = (r, g, b) => {
36
41
  }
37
42
  return Math.round((r - 8) / 247 * 24) + 232;
38
43
  }
39
- return 16 + 36 * Math.round(r / 51) + 6 * Math.round(g / 51) + Math.round(b / 51);
44
+ return 16 + // r / 255 * 5 => r / 51
45
+ 36 * Math.round(r / 51) + 6 * Math.round(g / 51) + Math.round(b / 51);
40
46
  };
41
47
  const ansi256To16 = (code) => {
42
48
  let r;
@@ -1,6 +1,6 @@
1
1
  import { isStdoutColorSupported } from '@visulima/is-ansi-color-supported';
2
2
  import { convertHexToRgb } from './convertHexToRgb-BZwJEiMZ.mjs';
3
- import { ansi256To16, rgbToAnsi16, rgbToAnsi256 } from './rgbToAnsi256-BdS0fomP.mjs';
3
+ import { ansi256To16, rgbToAnsi16, rgbToAnsi256 } from './rgbToAnsi256-Bca58HoN.mjs';
4
4
 
5
5
  function ansiRegex({ onlyFirst = false } = {}) {
6
6
  const ST = "(?:\\u0007|\\u001B\\u005C|\\u009C)";
@@ -10,7 +10,12 @@ function ansiRegex({ onlyFirst = false } = {}) {
10
10
  return new RegExp(pattern, onlyFirst ? void 0 : "g");
11
11
  }
12
12
 
13
- const clamp = (number_, min, max) => min > number_ ? min : Math.min(number_, max);
13
+ const clamp = (number_, min, max) => {
14
+ if (min > number_) {
15
+ return min;
16
+ }
17
+ return Math.min(number_, max);
18
+ };
14
19
 
15
20
  const closeCode = 39;
16
21
  const bgCloseCode = 49;
@@ -2,7 +2,7 @@
2
2
 
3
3
  const isAnsiColorSupported = require('@visulima/is-ansi-color-supported');
4
4
  const convertHexToRgb = require('./convertHexToRgb-51-edHxE.cjs');
5
- const rgbToAnsi256 = require('./rgbToAnsi256-DL8eajTz.cjs');
5
+ const rgbToAnsi256 = require('./rgbToAnsi256-C3-josZP.cjs');
6
6
 
7
7
  function ansiRegex({ onlyFirst = false } = {}) {
8
8
  const ST = "(?:\\u0007|\\u001B\\u005C|\\u009C)";
@@ -12,7 +12,12 @@ function ansiRegex({ onlyFirst = false } = {}) {
12
12
  return new RegExp(pattern, onlyFirst ? void 0 : "g");
13
13
  }
14
14
 
15
- const clamp = (number_, min, max) => min > number_ ? min : Math.min(number_, max);
15
+ const clamp = (number_, min, max) => {
16
+ if (min > number_) {
17
+ return min;
18
+ }
19
+ return Math.min(number_, max);
20
+ };
16
21
 
17
22
  const closeCode = 39;
18
23
  const bgCloseCode = 49;
@@ -8,7 +8,8 @@ const rgbToAnsi256 = (r, g, b) => {
8
8
  }
9
9
  return Math.round((r - 8) / 247 * 24) + 232;
10
10
  }
11
- return 16 + 36 * Math.round(r / 51) + 6 * Math.round(g / 51) + Math.round(b / 51);
11
+ return 16 + // r / 255 * 5 => r / 51
12
+ 36 * Math.round(r / 51) + 6 * Math.round(g / 51) + Math.round(b / 51);
12
13
  };
13
14
  const ansi256To16 = (code) => {
14
15
  let r;
@@ -12,7 +12,8 @@ const rgbToAnsi256 = (r, g, b) => {
12
12
  }
13
13
  return Math.round((r - 8) / 247 * 24) + 232;
14
14
  }
15
- return 16 + 36 * Math.round(r / 51) + 6 * Math.round(g / 51) + Math.round(b / 51);
15
+ return 16 + // r / 255 * 5 => r / 51
16
+ 36 * Math.round(r / 51) + 6 * Math.round(g / 51) + Math.round(b / 51);
16
17
  };
17
18
  const ansi256To16 = (code) => {
18
19
  let r;
@@ -7,4 +7,4 @@
7
7
  * Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
8
8
  */
9
9
  import type { ColorizeType } from "../types.d.cts";
10
- export declare const makeTemplate: (colorize: ColorizeType) => (string: string) => string;
10
+ export declare const makeTemplate: (colorize: ColorizeType) => ((string: string) => string);
@@ -7,4 +7,4 @@
7
7
  * Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
8
8
  */
9
9
  import type { ColorizeType } from "../types.d.mts";
10
- export declare const makeTemplate: (colorize: ColorizeType) => (string: string) => string;
10
+ export declare const makeTemplate: (colorize: ColorizeType) => ((string: string) => string);
@@ -7,4 +7,4 @@
7
7
  * Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
8
8
  */
9
9
  import type { ColorizeType } from "../types.d.ts";
10
- export declare const makeTemplate: (colorize: ColorizeType) => (string: string) => string;
10
+ export declare const makeTemplate: (colorize: ColorizeType) => ((string: string) => string);
package/dist/template.cjs CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
4
4
 
5
- const colorize_server = require('./packem_shared/colorize.server-BFVt4Z2R.cjs');
5
+ const colorize_server = require('./packem_shared/colorize.server-XetY_pdz.cjs');
6
6
  const convertHexToRgb = require('./packem_shared/convertHexToRgb-51-edHxE.cjs');
7
7
 
8
8
  const makeColorizeTemplate = (template) => (firstString, ...arguments_) => {
@@ -40,7 +40,10 @@ const unescape = (c) => {
40
40
  return ESCAPES.get(c) ?? c;
41
41
  };
42
42
 
43
- const TEMPLATE_REGEX = /\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.)|\{(~)?(#?[\w:]+(?:\([^)]*\))?(?:\.#?[\w:]+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n))|(\})|((?:.|[\r\n\f])+?)/gi;
43
+ const TEMPLATE_REGEX = (
44
+ // eslint-disable-next-line regexp/no-lazy-ends,regexp/no-dupe-disjunctions,sonarjs/regex-complexity
45
+ /\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.)|\{(~)?(#?[\w:]+(?:\([^)]*\))?(?:\.#?[\w:]+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n))|(\})|((?:.|[\r\n\f])+?)/gi
46
+ );
44
47
  const STYLE_REGEX = /(?:^|\.)(?:(\w+)(?:\(([^)]*)\))?|#(?=[:a-f\d]{2,})([a-f\d]{6})?(?::([a-f\d]{6}))?)/gi;
45
48
  const STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
46
49
  const ESCAPE_REGEX = /\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.)|([^\\])/gi;
@@ -54,7 +57,14 @@ const parseArguments = (name, value) => {
54
57
  if (!Number.isNaN(number)) {
55
58
  results.push(number);
56
59
  } else if (matches = STRING_REGEX.exec(chunk)) {
57
- results.push(matches[2].replace(ESCAPE_REGEX, (_, escape, character) => escape ? unescape(escape) : character));
60
+ results.push(
61
+ matches[2].replaceAll(ESCAPE_REGEX, (_, escape, character) => {
62
+ if (escape) {
63
+ return unescape(escape);
64
+ }
65
+ return character;
66
+ })
67
+ );
58
68
  } else {
59
69
  throw new Error(`Invalid template style argument: ${chunk} (in style '${name}')`);
60
70
  }
@@ -1,5 +1,5 @@
1
1
  import type { ColorizeType } from "./types.d.cts";
2
- export declare const makeTaggedTemplate: (instance: ColorizeType) => (firstString: TemplateStringsArray, ...arguments_: any[]) => string;
2
+ export declare const makeTaggedTemplate: (instance: ColorizeType) => ((firstString: TemplateStringsArray, ...arguments_: any[]) => string);
3
3
  export declare const template: (string: string) => string;
4
4
  declare const templateFunction: (firstString: TemplateStringsArray, ...arguments_: any[]) => string;
5
5
  export = templateFunction;
@@ -1,5 +1,5 @@
1
1
  import type { ColorizeType } from "./types.d.mts";
2
- export declare const makeTaggedTemplate: (instance: ColorizeType) => (firstString: TemplateStringsArray, ...arguments_: any[]) => string;
2
+ export declare const makeTaggedTemplate: (instance: ColorizeType) => ((firstString: TemplateStringsArray, ...arguments_: any[]) => string);
3
3
  export declare const template: (string: string) => string;
4
4
  declare const templateFunction: (firstString: TemplateStringsArray, ...arguments_: any[]) => string;
5
5
  export default templateFunction;
@@ -1,5 +1,5 @@
1
1
  import type { ColorizeType } from "./types.d.ts";
2
- export declare const makeTaggedTemplate: (instance: ColorizeType) => (firstString: TemplateStringsArray, ...arguments_: any[]) => string;
2
+ export declare const makeTaggedTemplate: (instance: ColorizeType) => ((firstString: TemplateStringsArray, ...arguments_: any[]) => string);
3
3
  export declare const template: (string: string) => string;
4
4
  declare const templateFunction: (firstString: TemplateStringsArray, ...arguments_: any[]) => string;
5
5
  export = templateFunction;
package/dist/template.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { C as Colorize } from './packem_shared/colorize.server-BVtbrTcf.mjs';
1
+ import { C as Colorize } from './packem_shared/colorize.server-DeZHO6IN.mjs';
2
2
  import { convertHexToRgb } from './packem_shared/convertHexToRgb-BZwJEiMZ.mjs';
3
3
 
4
4
  const makeColorizeTemplate = (template) => (firstString, ...arguments_) => {
@@ -36,7 +36,10 @@ const unescape = (c) => {
36
36
  return ESCAPES.get(c) ?? c;
37
37
  };
38
38
 
39
- const TEMPLATE_REGEX = /\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.)|\{(~)?(#?[\w:]+(?:\([^)]*\))?(?:\.#?[\w:]+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n))|(\})|((?:.|[\r\n\f])+?)/gi;
39
+ const TEMPLATE_REGEX = (
40
+ // eslint-disable-next-line regexp/no-lazy-ends,regexp/no-dupe-disjunctions,sonarjs/regex-complexity
41
+ /\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.)|\{(~)?(#?[\w:]+(?:\([^)]*\))?(?:\.#?[\w:]+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n))|(\})|((?:.|[\r\n\f])+?)/gi
42
+ );
40
43
  const STYLE_REGEX = /(?:^|\.)(?:(\w+)(?:\(([^)]*)\))?|#(?=[:a-f\d]{2,})([a-f\d]{6})?(?::([a-f\d]{6}))?)/gi;
41
44
  const STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
42
45
  const ESCAPE_REGEX = /\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.)|([^\\])/gi;
@@ -50,7 +53,14 @@ const parseArguments = (name, value) => {
50
53
  if (!Number.isNaN(number)) {
51
54
  results.push(number);
52
55
  } else if (matches = STRING_REGEX.exec(chunk)) {
53
- results.push(matches[2].replace(ESCAPE_REGEX, (_, escape, character) => escape ? unescape(escape) : character));
56
+ results.push(
57
+ matches[2].replaceAll(ESCAPE_REGEX, (_, escape, character) => {
58
+ if (escape) {
59
+ return unescape(escape);
60
+ }
61
+ return character;
62
+ })
63
+ );
54
64
  } else {
55
65
  throw new Error(`Invalid template style argument: ${chunk} (in style '${name}')`);
56
66
  }
package/dist/utils.cjs CHANGED
@@ -3,7 +3,7 @@
3
3
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
4
4
 
5
5
  const convertHexToRgb = require('./packem_shared/convertHexToRgb-51-edHxE.cjs');
6
- const rgbToAnsi256 = require('./packem_shared/rgbToAnsi256-DL8eajTz.cjs');
6
+ const rgbToAnsi256 = require('./packem_shared/rgbToAnsi256-C3-josZP.cjs');
7
7
 
8
8
 
9
9
 
package/dist/utils.mjs CHANGED
@@ -1,2 +1,2 @@
1
1
  export { convertHexToRgb } from './packem_shared/convertHexToRgb-BZwJEiMZ.mjs';
2
- export { ansi256To16, rgbToAnsi16, rgbToAnsi256 } from './packem_shared/rgbToAnsi256-BdS0fomP.mjs';
2
+ export { ansi256To16, rgbToAnsi16, rgbToAnsi256 } from './packem_shared/rgbToAnsi256-Bca58HoN.mjs';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visulima/colorize",
3
- "version": "2.0.0-alpha.8",
3
+ "version": "2.0.0-alpha.9",
4
4
  "description": "Terminal and Console string styling done right.",
5
5
  "keywords": [
6
6
  "256",
@@ -165,7 +165,7 @@
165
165
  "LICENSE.md"
166
166
  ],
167
167
  "dependencies": {
168
- "@visulima/is-ansi-color-supported": "3.0.0-alpha.8"
168
+ "@visulima/is-ansi-color-supported": "3.0.0-alpha.9"
169
169
  },
170
170
  "engines": {
171
171
  "node": ">=22.13 <=25.x"