@visulima/colorize 1.4.15 → 1.4.17
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 +19 -0
- package/dist/gradient.cjs +62 -3
- package/dist/gradient.d.cts +2 -10
- package/dist/gradient.d.mts +2 -10
- package/dist/gradient.d.ts +2 -10
- package/dist/gradient.mjs +56 -3
- package/dist/index.browser.d.mts +4 -4
- package/dist/index.browser.d.ts +4 -4
- package/dist/index.browser.mjs +63 -1
- package/dist/index.server.cjs +266 -2
- package/dist/index.server.d.mts +4 -4
- package/dist/index.server.d.ts +4 -4
- package/dist/index.server.mjs +63 -1
- package/dist/packem_shared/Colorize-BvQhMhEm.mjs +417 -0
- package/dist/packem_shared/Colorize-C1aMUhji.mjs +258 -0
- package/dist/packem_shared/GradientBuilder-Cjbl4_Hm.cjs +505 -0
- package/dist/packem_shared/GradientBuilder-DAeJG33X.mjs +501 -0
- package/dist/packem_shared/colorize.server-CaHAyuJ2.mjs +203 -0
- package/dist/packem_shared/colorize.server-n1sJSS5f.cjs +205 -0
- package/dist/packem_shared/convertHexToRgb-DDy3Eccg.cjs +19 -0
- package/dist/packem_shared/convertHexToRgb-DOIRmKxM.mjs +15 -0
- package/dist/packem_shared/rgbToAnsi256-Cakhu-n9.cjs +50 -0
- package/dist/packem_shared/rgbToAnsi256-DcQVMIqi.mjs +44 -0
- package/dist/packem_shared/{types-CoLB2PX2.d.mjs → types-M28Oe2t1.d.mjs} +1 -1
- package/dist/packem_shared/{types-CoLB2PX2.d.mts → types-M28Oe2t1.d.mts} +1 -1
- package/dist/template.cjs +158 -2
- package/dist/template.mjs +152 -2
- package/dist/utils.cjs +13 -1
- package/dist/utils.mjs +2 -1
- package/package.json +10 -10
- package/dist/packem_shared/Colorize-BG7_2JWK.mjs +0 -2
- package/dist/packem_shared/Colorize-gGSr400y.mjs +0 -1
- package/dist/packem_shared/GradientBuilder-Bn5OODm9.cjs +0 -1
- package/dist/packem_shared/GradientBuilder-CL8ERRQu.mjs +0 -1
- package/dist/packem_shared/colorize.server-BayBPE0C.mjs +0 -2
- package/dist/packem_shared/colorize.server-BdZzymFP.cjs +0 -2
- package/dist/packem_shared/convertHexToRgb-CSiKB7t1.mjs +0 -1
- package/dist/packem_shared/convertHexToRgb-DN4AQa3T.cjs +0 -1
- package/dist/packem_shared/rgbToAnsi256-D4IPvnol.cjs +0 -1
- package/dist/packem_shared/rgbToAnsi256-YETEPW8R.mjs +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
## @visulima/colorize [1.4.17](https://github.com/visulima/visulima/compare/@visulima/colorize@1.4.16...@visulima/colorize@1.4.17) (2025-01-12)
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
* updated @visulima/packem, and all other dev dependencies ([7797a1c](https://github.com/visulima/visulima/commit/7797a1c3e6f1fc532895247bd88285a8a9883c40))
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Dependencies
|
|
9
|
+
|
|
10
|
+
* **@visulima/is-ansi-color-supported:** upgraded to 2.2.10
|
|
11
|
+
* **@visulima/path:** upgraded to 1.3.2
|
|
12
|
+
|
|
13
|
+
## @visulima/colorize [1.4.16](https://github.com/visulima/visulima/compare/@visulima/colorize@1.4.15...@visulima/colorize@1.4.16) (2025-01-08)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Dependencies
|
|
17
|
+
|
|
18
|
+
* **@visulima/path:** upgraded to 1.3.1
|
|
19
|
+
|
|
1
20
|
## @visulima/colorize [1.4.15](https://github.com/visulima/visulima/compare/@visulima/colorize@1.4.14...@visulima/colorize@1.4.15) (2025-01-08)
|
|
2
21
|
|
|
3
22
|
|
package/dist/gradient.cjs
CHANGED
|
@@ -1,3 +1,62 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
|
4
|
+
|
|
5
|
+
const colorize_server = require('./packem_shared/colorize.server-n1sJSS5f.cjs');
|
|
6
|
+
const GradientBuilder = require('./packem_shared/GradientBuilder-Cjbl4_Hm.cjs');
|
|
7
|
+
|
|
8
|
+
var __defProp = Object.defineProperty;
|
|
9
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
10
|
+
const colorize = new colorize_server.Colorize();
|
|
11
|
+
const forbiddenChars = /\s/g;
|
|
12
|
+
const gradient = /* @__PURE__ */ __name((stops, options) => {
|
|
13
|
+
const { hsvSpin = "short", interpolation = "rgb" } = options ?? {};
|
|
14
|
+
let builder = new GradientBuilder.GradientBuilder(colorize, stops);
|
|
15
|
+
if (options?.loop) {
|
|
16
|
+
builder = builder.loop();
|
|
17
|
+
} else if (options?.reverse) {
|
|
18
|
+
builder = builder.reverse();
|
|
19
|
+
}
|
|
20
|
+
return (string_) => {
|
|
21
|
+
const colorsCount = Math.max(string_.replaceAll(forbiddenChars, "").length, builder.stops.length);
|
|
22
|
+
const colors = interpolation === "rgb" ? builder.rgb(colorsCount) : builder.hsv(colorsCount, hsvSpin);
|
|
23
|
+
let result = "";
|
|
24
|
+
for (const s of string_) {
|
|
25
|
+
if (forbiddenChars.test(s)) {
|
|
26
|
+
result += s;
|
|
27
|
+
} else {
|
|
28
|
+
const color = colors.shift();
|
|
29
|
+
result += color(s);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
}, "gradient");
|
|
35
|
+
const multilineGradient = /* @__PURE__ */ __name((stops, options) => {
|
|
36
|
+
const { hsvSpin = "short", interpolation = "rgb" } = options ?? {};
|
|
37
|
+
let builder = new GradientBuilder.GradientBuilder(colorize, stops);
|
|
38
|
+
if (options?.loop) {
|
|
39
|
+
builder = builder.loop();
|
|
40
|
+
} else if (options?.reverse) {
|
|
41
|
+
builder = builder.reverse();
|
|
42
|
+
}
|
|
43
|
+
return (string_) => {
|
|
44
|
+
const lines = string_.split("\n");
|
|
45
|
+
const colorsCount = Reflect.apply(Math.max, null, [...lines.map((l) => l.length), builder.stops.length]);
|
|
46
|
+
const colors = interpolation === "rgb" ? builder.rgb(colorsCount) : builder.hsv(colorsCount, hsvSpin);
|
|
47
|
+
const results = [];
|
|
48
|
+
for (const line of lines) {
|
|
49
|
+
const lineColors = [...colors];
|
|
50
|
+
let lineResult = "";
|
|
51
|
+
for (const l of line) {
|
|
52
|
+
lineResult += forbiddenChars.test(l) ? l : lineColors.shift()(l);
|
|
53
|
+
}
|
|
54
|
+
results.push(lineResult);
|
|
55
|
+
}
|
|
56
|
+
return results.join("\n");
|
|
57
|
+
};
|
|
58
|
+
}, "multilineGradient");
|
|
59
|
+
|
|
60
|
+
exports.GradientBuilder = GradientBuilder.GradientBuilder;
|
|
61
|
+
exports.gradient = gradient;
|
|
62
|
+
exports.multilineGradient = multilineGradient;
|
package/dist/gradient.d.cts
CHANGED
|
@@ -10,21 +10,13 @@ declare class GradientBuilder {
|
|
|
10
10
|
hsv(steps: number, mode?: boolean | "long" | "short"): ColorizeType[];
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
declare const gradient: (stops: (ColorValueHex | CssColorName | RGB | StopInput | [
|
|
14
|
-
number,
|
|
15
|
-
number,
|
|
16
|
-
number
|
|
17
|
-
])[], options?: {
|
|
13
|
+
declare const gradient: (stops: (ColorValueHex | CssColorName | RGB | StopInput | [number, number, number])[], options?: {
|
|
18
14
|
hsvSpin?: "long" | "short";
|
|
19
15
|
interpolation?: "hsv" | "rgb";
|
|
20
16
|
loop?: boolean;
|
|
21
17
|
reverse?: boolean;
|
|
22
18
|
}) => ((string_: string) => string);
|
|
23
|
-
declare const multilineGradient: (stops: (ColorValueHex | CssColorName | RGB | StopInput | [
|
|
24
|
-
number,
|
|
25
|
-
number,
|
|
26
|
-
number
|
|
27
|
-
])[], options?: {
|
|
19
|
+
declare const multilineGradient: (stops: (ColorValueHex | CssColorName | RGB | StopInput | [number, number, number])[], options?: {
|
|
28
20
|
hsvSpin?: "long" | "short";
|
|
29
21
|
interpolation?: "hsv" | "rgb";
|
|
30
22
|
loop?: boolean;
|
package/dist/gradient.d.mts
CHANGED
|
@@ -10,21 +10,13 @@ declare class GradientBuilder {
|
|
|
10
10
|
hsv(steps: number, mode?: boolean | "long" | "short"): ColorizeType[];
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
declare const gradient: (stops: (ColorValueHex | CssColorName | RGB | StopInput | [
|
|
14
|
-
number,
|
|
15
|
-
number,
|
|
16
|
-
number
|
|
17
|
-
])[], options?: {
|
|
13
|
+
declare const gradient: (stops: (ColorValueHex | CssColorName | RGB | StopInput | [number, number, number])[], options?: {
|
|
18
14
|
hsvSpin?: "long" | "short";
|
|
19
15
|
interpolation?: "hsv" | "rgb";
|
|
20
16
|
loop?: boolean;
|
|
21
17
|
reverse?: boolean;
|
|
22
18
|
}) => ((string_: string) => string);
|
|
23
|
-
declare const multilineGradient: (stops: (ColorValueHex | CssColorName | RGB | StopInput | [
|
|
24
|
-
number,
|
|
25
|
-
number,
|
|
26
|
-
number
|
|
27
|
-
])[], options?: {
|
|
19
|
+
declare const multilineGradient: (stops: (ColorValueHex | CssColorName | RGB | StopInput | [number, number, number])[], options?: {
|
|
28
20
|
hsvSpin?: "long" | "short";
|
|
29
21
|
interpolation?: "hsv" | "rgb";
|
|
30
22
|
loop?: boolean;
|
package/dist/gradient.d.ts
CHANGED
|
@@ -10,21 +10,13 @@ declare class GradientBuilder {
|
|
|
10
10
|
hsv(steps: number, mode?: boolean | "long" | "short"): ColorizeType[];
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
declare const gradient: (stops: (ColorValueHex | CssColorName | RGB | StopInput | [
|
|
14
|
-
number,
|
|
15
|
-
number,
|
|
16
|
-
number
|
|
17
|
-
])[], options?: {
|
|
13
|
+
declare const gradient: (stops: (ColorValueHex | CssColorName | RGB | StopInput | [number, number, number])[], options?: {
|
|
18
14
|
hsvSpin?: "long" | "short";
|
|
19
15
|
interpolation?: "hsv" | "rgb";
|
|
20
16
|
loop?: boolean;
|
|
21
17
|
reverse?: boolean;
|
|
22
18
|
}) => ((string_: string) => string);
|
|
23
|
-
declare const multilineGradient: (stops: (ColorValueHex | CssColorName | RGB | StopInput | [
|
|
24
|
-
number,
|
|
25
|
-
number,
|
|
26
|
-
number
|
|
27
|
-
])[], options?: {
|
|
19
|
+
declare const multilineGradient: (stops: (ColorValueHex | CssColorName | RGB | StopInput | [number, number, number])[], options?: {
|
|
28
20
|
hsvSpin?: "long" | "short";
|
|
29
21
|
interpolation?: "hsv" | "rgb";
|
|
30
22
|
loop?: boolean;
|
package/dist/gradient.mjs
CHANGED
|
@@ -1,3 +1,56 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { C as Colorize } from './packem_shared/colorize.server-CaHAyuJ2.mjs';
|
|
2
|
+
import { GradientBuilder } from './packem_shared/GradientBuilder-DAeJG33X.mjs';
|
|
3
|
+
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
6
|
+
const colorize = new Colorize();
|
|
7
|
+
const forbiddenChars = /\s/g;
|
|
8
|
+
const gradient = /* @__PURE__ */ __name((stops, options) => {
|
|
9
|
+
const { hsvSpin = "short", interpolation = "rgb" } = options ?? {};
|
|
10
|
+
let builder = new GradientBuilder(colorize, stops);
|
|
11
|
+
if (options?.loop) {
|
|
12
|
+
builder = builder.loop();
|
|
13
|
+
} else if (options?.reverse) {
|
|
14
|
+
builder = builder.reverse();
|
|
15
|
+
}
|
|
16
|
+
return (string_) => {
|
|
17
|
+
const colorsCount = Math.max(string_.replaceAll(forbiddenChars, "").length, builder.stops.length);
|
|
18
|
+
const colors = interpolation === "rgb" ? builder.rgb(colorsCount) : builder.hsv(colorsCount, hsvSpin);
|
|
19
|
+
let result = "";
|
|
20
|
+
for (const s of string_) {
|
|
21
|
+
if (forbiddenChars.test(s)) {
|
|
22
|
+
result += s;
|
|
23
|
+
} else {
|
|
24
|
+
const color = colors.shift();
|
|
25
|
+
result += color(s);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return result;
|
|
29
|
+
};
|
|
30
|
+
}, "gradient");
|
|
31
|
+
const multilineGradient = /* @__PURE__ */ __name((stops, options) => {
|
|
32
|
+
const { hsvSpin = "short", interpolation = "rgb" } = options ?? {};
|
|
33
|
+
let builder = new GradientBuilder(colorize, stops);
|
|
34
|
+
if (options?.loop) {
|
|
35
|
+
builder = builder.loop();
|
|
36
|
+
} else if (options?.reverse) {
|
|
37
|
+
builder = builder.reverse();
|
|
38
|
+
}
|
|
39
|
+
return (string_) => {
|
|
40
|
+
const lines = string_.split("\n");
|
|
41
|
+
const colorsCount = Reflect.apply(Math.max, null, [...lines.map((l) => l.length), builder.stops.length]);
|
|
42
|
+
const colors = interpolation === "rgb" ? builder.rgb(colorsCount) : builder.hsv(colorsCount, hsvSpin);
|
|
43
|
+
const results = [];
|
|
44
|
+
for (const line of lines) {
|
|
45
|
+
const lineColors = [...colors];
|
|
46
|
+
let lineResult = "";
|
|
47
|
+
for (const l of line) {
|
|
48
|
+
lineResult += forbiddenChars.test(l) ? l : lineColors.shift()(l);
|
|
49
|
+
}
|
|
50
|
+
results.push(lineResult);
|
|
51
|
+
}
|
|
52
|
+
return results.join("\n");
|
|
53
|
+
};
|
|
54
|
+
}, "multilineGradient");
|
|
55
|
+
|
|
56
|
+
export { GradientBuilder, gradient, multilineGradient };
|
package/dist/index.browser.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as ColorizeType } from './packem_shared/types-
|
|
2
|
-
export { A as AnsiColors,
|
|
1
|
+
import { C as ColorizeType, a as ColorValueHex } from './packem_shared/types-M28Oe2t1.mjs';
|
|
2
|
+
export { A as AnsiColors, b as AnsiStyles } from './packem_shared/types-M28Oe2t1.mjs';
|
|
3
3
|
|
|
4
4
|
declare const WebColorize: new () => ColorizeType;
|
|
5
5
|
|
|
@@ -18,7 +18,7 @@ declare const bgGray: ColorizeType;
|
|
|
18
18
|
declare const bgGreen: ColorizeType;
|
|
19
19
|
declare const bgGreenBright: ColorizeType;
|
|
20
20
|
declare const bgGrey: ColorizeType;
|
|
21
|
-
declare const bgHex: (color:
|
|
21
|
+
declare const bgHex: (color: ColorValueHex) => ColorizeType;
|
|
22
22
|
declare const bgMagenta: ColorizeType;
|
|
23
23
|
declare const bgMagentaBright: ColorizeType;
|
|
24
24
|
declare const bgRed: ColorizeType;
|
|
@@ -41,7 +41,7 @@ declare const gray: ColorizeType;
|
|
|
41
41
|
declare const green: ColorizeType;
|
|
42
42
|
declare const greenBright: ColorizeType;
|
|
43
43
|
declare const grey: ColorizeType;
|
|
44
|
-
declare const hex: (color:
|
|
44
|
+
declare const hex: (color: ColorValueHex) => ColorizeType;
|
|
45
45
|
declare const hidden: ColorizeType;
|
|
46
46
|
declare const inverse: ColorizeType;
|
|
47
47
|
declare const italic: ColorizeType;
|
package/dist/index.browser.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as ColorizeType } from './packem_shared/types-
|
|
2
|
-
export { A as AnsiColors,
|
|
1
|
+
import { C as ColorizeType, a as ColorValueHex } from './packem_shared/types-M28Oe2t1.d.mjs';
|
|
2
|
+
export { A as AnsiColors, b as AnsiStyles } from './packem_shared/types-M28Oe2t1.d.mjs';
|
|
3
3
|
|
|
4
4
|
declare const WebColorize: new () => ColorizeType;
|
|
5
5
|
|
|
@@ -18,7 +18,7 @@ declare const bgGray: ColorizeType;
|
|
|
18
18
|
declare const bgGreen: ColorizeType;
|
|
19
19
|
declare const bgGreenBright: ColorizeType;
|
|
20
20
|
declare const bgGrey: ColorizeType;
|
|
21
|
-
declare const bgHex: (color:
|
|
21
|
+
declare const bgHex: (color: ColorValueHex) => ColorizeType;
|
|
22
22
|
declare const bgMagenta: ColorizeType;
|
|
23
23
|
declare const bgMagentaBright: ColorizeType;
|
|
24
24
|
declare const bgRed: ColorizeType;
|
|
@@ -41,7 +41,7 @@ declare const gray: ColorizeType;
|
|
|
41
41
|
declare const green: ColorizeType;
|
|
42
42
|
declare const greenBright: ColorizeType;
|
|
43
43
|
declare const grey: ColorizeType;
|
|
44
|
-
declare const hex: (color:
|
|
44
|
+
declare const hex: (color: ColorValueHex) => ColorizeType;
|
|
45
45
|
declare const hidden: ColorizeType;
|
|
46
46
|
declare const inverse: ColorizeType;
|
|
47
47
|
declare const italic: ColorizeType;
|
package/dist/index.browser.mjs
CHANGED
|
@@ -1 +1,63 @@
|
|
|
1
|
-
import
|
|
1
|
+
import WebColorize from './packem_shared/Colorize-BvQhMhEm.mjs';
|
|
2
|
+
|
|
3
|
+
const colorize = new WebColorize();
|
|
4
|
+
const {
|
|
5
|
+
ansi256,
|
|
6
|
+
bg,
|
|
7
|
+
bgAnsi256,
|
|
8
|
+
bgBlack,
|
|
9
|
+
bgBlackBright,
|
|
10
|
+
bgBlue,
|
|
11
|
+
bgBlueBright,
|
|
12
|
+
bgCyan,
|
|
13
|
+
bgCyanBright,
|
|
14
|
+
bgGray,
|
|
15
|
+
bgGreen,
|
|
16
|
+
bgGreenBright,
|
|
17
|
+
bgGrey,
|
|
18
|
+
bgHex,
|
|
19
|
+
bgMagenta,
|
|
20
|
+
bgMagentaBright,
|
|
21
|
+
bgRed,
|
|
22
|
+
bgRedBright,
|
|
23
|
+
bgRgb,
|
|
24
|
+
bgWhite,
|
|
25
|
+
bgWhiteBright,
|
|
26
|
+
bgYellow,
|
|
27
|
+
bgYellowBright,
|
|
28
|
+
black,
|
|
29
|
+
blackBright,
|
|
30
|
+
blue,
|
|
31
|
+
blueBright,
|
|
32
|
+
bold,
|
|
33
|
+
cyan,
|
|
34
|
+
cyanBright,
|
|
35
|
+
dim,
|
|
36
|
+
fg,
|
|
37
|
+
gray,
|
|
38
|
+
green,
|
|
39
|
+
greenBright,
|
|
40
|
+
grey,
|
|
41
|
+
hex,
|
|
42
|
+
hidden,
|
|
43
|
+
inverse,
|
|
44
|
+
italic,
|
|
45
|
+
magenta,
|
|
46
|
+
magentaBright,
|
|
47
|
+
overline,
|
|
48
|
+
red,
|
|
49
|
+
redBright,
|
|
50
|
+
reset,
|
|
51
|
+
rgb,
|
|
52
|
+
strike,
|
|
53
|
+
strikethrough,
|
|
54
|
+
strip,
|
|
55
|
+
underline,
|
|
56
|
+
visible,
|
|
57
|
+
white,
|
|
58
|
+
whiteBright,
|
|
59
|
+
yellow,
|
|
60
|
+
yellowBright
|
|
61
|
+
} = colorize;
|
|
62
|
+
|
|
63
|
+
export { WebColorize as Colorize, ansi256, bg, bgAnsi256, bgBlack, bgBlackBright, bgBlue, bgBlueBright, bgCyan, bgCyanBright, bgGray, bgGreen, bgGreenBright, bgGrey, bgHex, bgMagenta, bgMagentaBright, bgRed, bgRedBright, bgRgb, bgWhite, bgWhiteBright, bgYellow, bgYellowBright, black, blackBright, blue, blueBright, bold, cyan, cyanBright, colorize as default, dim, fg, gray, green, greenBright, grey, hex, hidden, inverse, italic, magenta, magentaBright, overline, red, redBright, reset, rgb, strike, strikethrough, strip, underline, visible, white, whiteBright, yellow, yellowBright };
|
package/dist/index.server.cjs
CHANGED
|
@@ -1,2 +1,266 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
|
4
|
+
|
|
5
|
+
const isAnsiColorSupported = require('@visulima/is-ansi-color-supported');
|
|
6
|
+
|
|
7
|
+
var __defProp$6 = Object.defineProperty;
|
|
8
|
+
var __name$6 = (target, value) => __defProp$6(target, "name", { value, configurable: true });
|
|
9
|
+
function ansiRegex({ onlyFirst = false } = {}) {
|
|
10
|
+
const ST = "(?:\\u0007|\\u001B\\u005C|\\u009C)";
|
|
11
|
+
const pattern = [
|
|
12
|
+
`[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?${ST})`,
|
|
13
|
+
"(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"
|
|
14
|
+
].join("|");
|
|
15
|
+
return new RegExp(pattern, onlyFirst ? undefined : "g");
|
|
16
|
+
}
|
|
17
|
+
__name$6(ansiRegex, "ansiRegex");
|
|
18
|
+
|
|
19
|
+
var __defProp$5 = Object.defineProperty;
|
|
20
|
+
var __name$5 = (target, value) => __defProp$5(target, "name", { value, configurable: true });
|
|
21
|
+
const clamp = /* @__PURE__ */ __name$5((number_, min, max) => min > number_ ? min : number_ > max ? max : number_, "clamp");
|
|
22
|
+
|
|
23
|
+
var __defProp$4 = Object.defineProperty;
|
|
24
|
+
var __name$4 = (target, value) => __defProp$4(target, "name", { value, configurable: true });
|
|
25
|
+
const convertHexToRgb = /* @__PURE__ */ __name$4((hex) => {
|
|
26
|
+
let [, color] = /([a-f\d]{3,6})/i.exec(hex) ?? [];
|
|
27
|
+
const length_ = color ? color.length : 0;
|
|
28
|
+
if (length_ === 3) {
|
|
29
|
+
color = color[0] + color[0] + color[1] + color[1] + color[2] + color[2];
|
|
30
|
+
} else if (length_ !== 6) {
|
|
31
|
+
return [0, 0, 0];
|
|
32
|
+
}
|
|
33
|
+
const number_ = Number.parseInt(color, 16);
|
|
34
|
+
return [number_ >> 16 & 255, number_ >> 8 & 255, number_ & 255];
|
|
35
|
+
}, "convertHexToRgb");
|
|
36
|
+
|
|
37
|
+
var __defProp$3 = Object.defineProperty;
|
|
38
|
+
var __name$3 = (target, value) => __defProp$3(target, "name", { value, configurable: true });
|
|
39
|
+
const rgbToAnsi256 = /* @__PURE__ */ __name$3((r, g, b) => {
|
|
40
|
+
if (r === g && g === b) {
|
|
41
|
+
if (r < 8) {
|
|
42
|
+
return 16;
|
|
43
|
+
}
|
|
44
|
+
if (r > 248) {
|
|
45
|
+
return 231;
|
|
46
|
+
}
|
|
47
|
+
return Math.round((r - 8) / 247 * 24) + 232;
|
|
48
|
+
}
|
|
49
|
+
return 16 + // r / 255 * 5 => r / 51
|
|
50
|
+
36 * Math.round(r / 51) + 6 * Math.round(g / 51) + Math.round(b / 51);
|
|
51
|
+
}, "rgbToAnsi256");
|
|
52
|
+
const ansi256To16 = /* @__PURE__ */ __name$3((code) => {
|
|
53
|
+
let r;
|
|
54
|
+
let g;
|
|
55
|
+
let b;
|
|
56
|
+
if (code < 8) {
|
|
57
|
+
return 30 + code;
|
|
58
|
+
}
|
|
59
|
+
if (code < 16) {
|
|
60
|
+
return 90 + (code - 8);
|
|
61
|
+
}
|
|
62
|
+
if (code >= 232) {
|
|
63
|
+
r = g = b = ((code - 232) * 10 + 8) / 255;
|
|
64
|
+
} else {
|
|
65
|
+
code -= 16;
|
|
66
|
+
const remainder = code % 36;
|
|
67
|
+
r = Math.floor(code / 36) / 5;
|
|
68
|
+
g = Math.floor(remainder / 6) / 5;
|
|
69
|
+
b = remainder % 6 / 5;
|
|
70
|
+
}
|
|
71
|
+
const value = Math.max(r, g, b) * 2;
|
|
72
|
+
if (value === 0) {
|
|
73
|
+
return 30;
|
|
74
|
+
}
|
|
75
|
+
const code16 = 30 + (Math.round(b) << 2 | Math.round(g) << 1 | Math.round(r));
|
|
76
|
+
return value === 2 ? code16 + 60 : code16;
|
|
77
|
+
}, "ansi256To16");
|
|
78
|
+
const rgbToAnsi16 = /* @__PURE__ */ __name$3((r, g, b) => ansi256To16(rgbToAnsi256(r, g, b)), "rgbToAnsi16");
|
|
79
|
+
|
|
80
|
+
var __defProp$2 = Object.defineProperty;
|
|
81
|
+
var __name$2 = (target, value) => __defProp$2(target, "name", { value, configurable: true });
|
|
82
|
+
const closeCode = 39;
|
|
83
|
+
const bgCloseCode = 49;
|
|
84
|
+
const bgOffset = 10;
|
|
85
|
+
const supportedColor = isAnsiColorSupported.isStdoutColorSupported();
|
|
86
|
+
const mono = { close: "", open: "" };
|
|
87
|
+
const esc = supportedColor > 0 ? (open, close) => {
|
|
88
|
+
return { close: "\x1B[" + close + "m", open: "\x1B[" + open + "m" };
|
|
89
|
+
} : () => mono;
|
|
90
|
+
const createRgbFunction = /* @__PURE__ */ __name$2((function_) => (r, g, b) => function_(rgbToAnsi256(Number(r), Number(g), Number(b))), "createRgbFunction");
|
|
91
|
+
const createHexFunction = /* @__PURE__ */ __name$2((function_) => (hex) => {
|
|
92
|
+
const [r, g, b] = convertHexToRgb(hex);
|
|
93
|
+
return function_(r, g, b);
|
|
94
|
+
}, "createHexFunction");
|
|
95
|
+
let createAnsi256 = /* @__PURE__ */ __name$2((code) => esc("38;5;" + code, closeCode), "createAnsi256");
|
|
96
|
+
let createBgAnsi256 = /* @__PURE__ */ __name$2((code) => esc("48;5;" + code, bgCloseCode), "createBgAnsi256");
|
|
97
|
+
let createRgb = /* @__PURE__ */ __name$2((r, g, b) => esc("38;2;" + r + ";" + g + ";" + b, closeCode), "createRgb");
|
|
98
|
+
let createBgRgb = /* @__PURE__ */ __name$2((r, g, b) => esc("48;2;" + r + ";" + g + ";" + b, bgCloseCode), "createBgRgb");
|
|
99
|
+
if (supportedColor === 1) {
|
|
100
|
+
createAnsi256 = /* @__PURE__ */ __name$2((code) => esc(ansi256To16(Number(code)), closeCode), "createAnsi256");
|
|
101
|
+
createBgAnsi256 = /* @__PURE__ */ __name$2((code) => esc(ansi256To16(Number(code)) + bgOffset, bgCloseCode), "createBgAnsi256");
|
|
102
|
+
createRgb = /* @__PURE__ */ __name$2((r, g, b) => esc(rgbToAnsi16(Number(r), Number(g), Number(b)), closeCode), "createRgb");
|
|
103
|
+
createBgRgb = /* @__PURE__ */ __name$2((r, g, b) => esc(rgbToAnsi16(Number(r), Number(g), Number(b)) + bgOffset, bgCloseCode), "createBgRgb");
|
|
104
|
+
} else if (supportedColor === 2) {
|
|
105
|
+
createRgb = createRgbFunction(createAnsi256);
|
|
106
|
+
createBgRgb = createRgbFunction(createBgAnsi256);
|
|
107
|
+
}
|
|
108
|
+
const baseStyles = {
|
|
109
|
+
// 21 isn't widely supported and 22 does the same thing
|
|
110
|
+
bold: esc(1, 22),
|
|
111
|
+
dim: esc(2, 22),
|
|
112
|
+
hidden: esc(8, 28),
|
|
113
|
+
inverse: esc(7, 27),
|
|
114
|
+
italic: esc(3, 23),
|
|
115
|
+
overline: esc(53, 55),
|
|
116
|
+
reset: esc(0, 0),
|
|
117
|
+
strike: esc(9, 29),
|
|
118
|
+
// alias for strikethrough
|
|
119
|
+
strikethrough: esc(9, 29),
|
|
120
|
+
underline: esc(4, 24),
|
|
121
|
+
visible: mono
|
|
122
|
+
};
|
|
123
|
+
const baseColors = {
|
|
124
|
+
bgBlack: esc(40, bgCloseCode),
|
|
125
|
+
bgBlackBright: esc(100, bgCloseCode),
|
|
126
|
+
bgBlue: esc(44, bgCloseCode),
|
|
127
|
+
bgBlueBright: esc(104, bgCloseCode),
|
|
128
|
+
bgCyan: esc(46, bgCloseCode),
|
|
129
|
+
bgCyanBright: esc(106, bgCloseCode),
|
|
130
|
+
bgGray: esc(100, bgCloseCode),
|
|
131
|
+
// US spelling alias for bgBlackBright
|
|
132
|
+
bgGreen: esc(42, bgCloseCode),
|
|
133
|
+
bgGreenBright: esc(102, bgCloseCode),
|
|
134
|
+
bgGrey: esc(100, bgCloseCode),
|
|
135
|
+
// UK spelling alias for bgBlackBright
|
|
136
|
+
bgMagenta: esc(45, bgCloseCode),
|
|
137
|
+
bgMagentaBright: esc(105, bgCloseCode),
|
|
138
|
+
bgRed: esc(41, bgCloseCode),
|
|
139
|
+
bgRedBright: esc(101, bgCloseCode),
|
|
140
|
+
bgWhite: esc(47, bgCloseCode),
|
|
141
|
+
bgWhiteBright: esc(107, bgCloseCode),
|
|
142
|
+
bgYellow: esc(43, bgCloseCode),
|
|
143
|
+
bgYellowBright: esc(103, bgCloseCode),
|
|
144
|
+
black: esc(30, closeCode),
|
|
145
|
+
blackBright: esc(90, closeCode),
|
|
146
|
+
blue: esc(34, closeCode),
|
|
147
|
+
blueBright: esc(94, closeCode),
|
|
148
|
+
cyan: esc(36, closeCode),
|
|
149
|
+
cyanBright: esc(96, closeCode),
|
|
150
|
+
gray: esc(90, closeCode),
|
|
151
|
+
// US spelling alias for blackBright
|
|
152
|
+
green: esc(32, closeCode),
|
|
153
|
+
greenBright: esc(92, closeCode),
|
|
154
|
+
grey: esc(90, closeCode),
|
|
155
|
+
// UK spelling alias for blackBright
|
|
156
|
+
magenta: esc(35, closeCode),
|
|
157
|
+
magentaBright: esc(95, closeCode),
|
|
158
|
+
red: esc(31, closeCode),
|
|
159
|
+
redBright: esc(91, closeCode),
|
|
160
|
+
white: esc(37, closeCode),
|
|
161
|
+
whiteBright: esc(97, closeCode),
|
|
162
|
+
yellow: esc(33, closeCode),
|
|
163
|
+
yellowBright: esc(93, closeCode)
|
|
164
|
+
};
|
|
165
|
+
const styleMethods = {
|
|
166
|
+
bg: /* @__PURE__ */ __name$2((code) => createBgAnsi256(clamp(code, 0, 255)), "bg"),
|
|
167
|
+
bgHex: createHexFunction(createBgRgb),
|
|
168
|
+
bgRgb: /* @__PURE__ */ __name$2((r, g, b) => createBgRgb(clamp(r, 0, 255), clamp(g, 0, 255), clamp(b, 0, 255)), "bgRgb"),
|
|
169
|
+
fg: /* @__PURE__ */ __name$2((code) => createAnsi256(clamp(code, 0, 255)), "fg"),
|
|
170
|
+
hex: createHexFunction(createRgb),
|
|
171
|
+
rgb: /* @__PURE__ */ __name$2((r, g, b) => createRgb(clamp(r, 0, 255), clamp(g, 0, 255), clamp(b, 0, 255)), "rgb")
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
var __defProp$1 = Object.defineProperty;
|
|
175
|
+
var __name$1 = (target, value) => __defProp$1(target, "name", { value, configurable: true });
|
|
176
|
+
const stringReplaceAll = /* @__PURE__ */ __name$1((string_, searchValue, replaceValue) => {
|
|
177
|
+
if (searchValue === "") {
|
|
178
|
+
return string_;
|
|
179
|
+
}
|
|
180
|
+
let pos = string_.indexOf(searchValue);
|
|
181
|
+
if (pos < 0) {
|
|
182
|
+
return string_;
|
|
183
|
+
}
|
|
184
|
+
const substringLength = searchValue.length;
|
|
185
|
+
let lastPos = 0;
|
|
186
|
+
let result = "";
|
|
187
|
+
while (~pos) {
|
|
188
|
+
result += string_.slice(lastPos, pos) + replaceValue;
|
|
189
|
+
lastPos = pos + substringLength;
|
|
190
|
+
pos = string_.indexOf(searchValue, lastPos);
|
|
191
|
+
}
|
|
192
|
+
return result + string_.slice(lastPos);
|
|
193
|
+
}, "stringReplaceAll");
|
|
194
|
+
|
|
195
|
+
var __defProp = Object.defineProperty;
|
|
196
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
197
|
+
const styles = {};
|
|
198
|
+
let stylePrototype = null;
|
|
199
|
+
const wrapText = /* @__PURE__ */ __name((strings, values, properties) => {
|
|
200
|
+
if (!strings) {
|
|
201
|
+
return "";
|
|
202
|
+
}
|
|
203
|
+
let string = strings.raw == null ? strings + "" : String.raw(strings, ...values);
|
|
204
|
+
if (string.includes("\x1B")) {
|
|
205
|
+
for (let currentProperties = properties; currentProperties; currentProperties = currentProperties.props) {
|
|
206
|
+
string = stringReplaceAll(string, currentProperties.close, currentProperties.open);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
if (string.includes("\n")) {
|
|
210
|
+
string = string.replace(/(\r*\n)/g, properties.closeStack + "$1" + properties.openStack);
|
|
211
|
+
}
|
|
212
|
+
return properties.openStack + string + properties.closeStack;
|
|
213
|
+
}, "wrapText");
|
|
214
|
+
const createStyle = /* @__PURE__ */ __name(({ props }, { close, open }) => {
|
|
215
|
+
const openStack = (props?.openStack ?? "") + open;
|
|
216
|
+
const closeStack = close + (props?.closeStack ?? "");
|
|
217
|
+
const style = /* @__PURE__ */ __name((strings, ...values) => wrapText(strings, values, style.props), "style");
|
|
218
|
+
Object.setPrototypeOf(style, stylePrototype);
|
|
219
|
+
style.props = { close, closeStack, open, openStack, props };
|
|
220
|
+
style.open = openStack;
|
|
221
|
+
style.close = closeStack;
|
|
222
|
+
return style;
|
|
223
|
+
}, "createStyle");
|
|
224
|
+
const Colorize$1 = /* @__PURE__ */ __name(function() {
|
|
225
|
+
const self = /* @__PURE__ */ __name((string_) => string_ + "", "self");
|
|
226
|
+
self.strip = (value) => value.replaceAll(ansiRegex(), "");
|
|
227
|
+
for (const name in baseColors) {
|
|
228
|
+
styles[name] = {
|
|
229
|
+
get() {
|
|
230
|
+
const style = createStyle(this, baseColors[name]);
|
|
231
|
+
Object.defineProperty(this, name, { value: style });
|
|
232
|
+
return style;
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
for (const name in baseStyles) {
|
|
237
|
+
styles[name] = {
|
|
238
|
+
get() {
|
|
239
|
+
const style = createStyle(this, baseStyles[name]);
|
|
240
|
+
Object.defineProperty(this, name, { value: style });
|
|
241
|
+
return style;
|
|
242
|
+
}
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
stylePrototype = Object.defineProperties({}, styles);
|
|
246
|
+
Object.setPrototypeOf(self, stylePrototype);
|
|
247
|
+
return self;
|
|
248
|
+
}, "Colorize");
|
|
249
|
+
for (const name in styleMethods) {
|
|
250
|
+
styles[name] = {
|
|
251
|
+
get() {
|
|
252
|
+
return (...arguments_) => (
|
|
253
|
+
// @ts-expect-error: TODO: fix typing of `arguments_`
|
|
254
|
+
createStyle(this, styleMethods[name](...arguments_))
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
styles.ansi256 = styles.fg;
|
|
260
|
+
styles.bgAnsi256 = styles.bg;
|
|
261
|
+
|
|
262
|
+
const colorize = new Colorize$1();
|
|
263
|
+
const Colorize = Colorize$1;
|
|
264
|
+
|
|
265
|
+
module.exports = colorize;
|
|
266
|
+
module.exports.Colorize = Colorize;
|
package/dist/index.server.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as ColorizeType } from './packem_shared/types-
|
|
2
|
-
export { A as AnsiColors,
|
|
1
|
+
import { C as ColorizeType, a as ColorValueHex } from './packem_shared/types-M28Oe2t1.mjs';
|
|
2
|
+
export { A as AnsiColors, b as AnsiStyles } from './packem_shared/types-M28Oe2t1.mjs';
|
|
3
3
|
|
|
4
4
|
declare const Colorize: new () => ColorizeType;
|
|
5
5
|
|
|
@@ -18,7 +18,7 @@ declare const bgGray: ColorizeType;
|
|
|
18
18
|
declare const bgGreen: ColorizeType;
|
|
19
19
|
declare const bgGreenBright: ColorizeType;
|
|
20
20
|
declare const bgGrey: ColorizeType;
|
|
21
|
-
declare const bgHex: (color:
|
|
21
|
+
declare const bgHex: (color: ColorValueHex) => ColorizeType;
|
|
22
22
|
declare const bgMagenta: ColorizeType;
|
|
23
23
|
declare const bgMagentaBright: ColorizeType;
|
|
24
24
|
declare const bgRed: ColorizeType;
|
|
@@ -41,7 +41,7 @@ declare const gray: ColorizeType;
|
|
|
41
41
|
declare const green: ColorizeType;
|
|
42
42
|
declare const greenBright: ColorizeType;
|
|
43
43
|
declare const grey: ColorizeType;
|
|
44
|
-
declare const hex: (color:
|
|
44
|
+
declare const hex: (color: ColorValueHex) => ColorizeType;
|
|
45
45
|
declare const hidden: ColorizeType;
|
|
46
46
|
declare const inverse: ColorizeType;
|
|
47
47
|
declare const italic: ColorizeType;
|