@breadc/color 0.8.9 → 0.9.1
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/dist/index.cjs +9 -0
- package/dist/index.d.ts +61 -59
- package/dist/index.mjs +9 -1
- package/package.json +7 -6
package/dist/index.cjs
CHANGED
|
@@ -56,6 +56,14 @@ function kolorist(start, end, level = 1 /* ansi */) {
|
|
|
56
56
|
return options.enabled && options.supportLevel >= level ? open + ("" + str).replace(regex, open) + close : "" + str;
|
|
57
57
|
};
|
|
58
58
|
}
|
|
59
|
+
function combine(...fns) {
|
|
60
|
+
return (str) => {
|
|
61
|
+
for (const fn of fns) {
|
|
62
|
+
str = fn(str);
|
|
63
|
+
}
|
|
64
|
+
return str;
|
|
65
|
+
};
|
|
66
|
+
}
|
|
59
67
|
function stripColors(str) {
|
|
60
68
|
return ("" + str).replace(/\x1b\[[0-9;]+m/g, "").replace(/\x1b\]8;;.*?\x07(.*?)\x1b\]8;;\x07/g, (_, group) => group);
|
|
61
69
|
}
|
|
@@ -130,6 +138,7 @@ exports.bgYellow = bgYellow;
|
|
|
130
138
|
exports.black = black;
|
|
131
139
|
exports.blue = blue;
|
|
132
140
|
exports.bold = bold;
|
|
141
|
+
exports.combine = combine;
|
|
133
142
|
exports.cyan = cyan;
|
|
134
143
|
exports.dim = dim;
|
|
135
144
|
exports.gray = gray;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,61 +1,63 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Detect how much colors the current terminal supports
|
|
3
|
-
*/
|
|
4
|
-
declare const enum SupportLevel {
|
|
5
|
-
none = 0,
|
|
6
|
-
ansi = 1,
|
|
7
|
-
ansi256 = 2
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Config whether enable color output
|
|
11
|
-
*/
|
|
12
|
-
declare const options: {
|
|
13
|
-
enabled: boolean;
|
|
14
|
-
supportLevel: SupportLevel;
|
|
15
|
-
};
|
|
16
|
-
declare function
|
|
17
|
-
declare
|
|
18
|
-
declare
|
|
19
|
-
declare const
|
|
20
|
-
declare const
|
|
21
|
-
declare const
|
|
22
|
-
declare const
|
|
23
|
-
declare const
|
|
24
|
-
declare const
|
|
25
|
-
declare const
|
|
26
|
-
declare const
|
|
27
|
-
declare const
|
|
28
|
-
declare const
|
|
29
|
-
declare const
|
|
30
|
-
declare const
|
|
31
|
-
declare const
|
|
32
|
-
declare const
|
|
33
|
-
declare const
|
|
34
|
-
declare const
|
|
35
|
-
declare const
|
|
36
|
-
declare const
|
|
37
|
-
declare const
|
|
38
|
-
declare const
|
|
39
|
-
declare const
|
|
40
|
-
declare const
|
|
41
|
-
declare const
|
|
42
|
-
declare const
|
|
43
|
-
declare const
|
|
44
|
-
declare const
|
|
45
|
-
declare const
|
|
46
|
-
declare const
|
|
47
|
-
declare const
|
|
48
|
-
declare const
|
|
49
|
-
declare const
|
|
50
|
-
declare const
|
|
51
|
-
declare const
|
|
52
|
-
declare const
|
|
53
|
-
declare const
|
|
54
|
-
declare const
|
|
55
|
-
declare const
|
|
56
|
-
declare const
|
|
57
|
-
declare const
|
|
58
|
-
declare const
|
|
1
|
+
/**
|
|
2
|
+
* Detect how much colors the current terminal supports
|
|
3
|
+
*/
|
|
4
|
+
declare const enum SupportLevel {
|
|
5
|
+
none = 0,
|
|
6
|
+
ansi = 1,
|
|
7
|
+
ansi256 = 2
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Config whether enable color output
|
|
11
|
+
*/
|
|
12
|
+
declare const options: {
|
|
13
|
+
enabled: boolean;
|
|
14
|
+
supportLevel: SupportLevel;
|
|
15
|
+
};
|
|
16
|
+
declare function kolorist(start: number | string, end: number | string, level?: SupportLevel): (str: string | number) => string;
|
|
17
|
+
declare function combine(...fns: ReturnType<typeof kolorist>[]): (str: string | number) => string | number;
|
|
18
|
+
declare function stripColors(str: string | number): string;
|
|
19
|
+
declare const reset: (str: string | number) => string;
|
|
20
|
+
declare const bold: (str: string | number) => string;
|
|
21
|
+
declare const dim: (str: string | number) => string;
|
|
22
|
+
declare const italic: (str: string | number) => string;
|
|
23
|
+
declare const underline: (str: string | number) => string;
|
|
24
|
+
declare const inverse: (str: string | number) => string;
|
|
25
|
+
declare const hidden: (str: string | number) => string;
|
|
26
|
+
declare const strikethrough: (str: string | number) => string;
|
|
27
|
+
declare const black: (str: string | number) => string;
|
|
28
|
+
declare const red: (str: string | number) => string;
|
|
29
|
+
declare const green: (str: string | number) => string;
|
|
30
|
+
declare const yellow: (str: string | number) => string;
|
|
31
|
+
declare const blue: (str: string | number) => string;
|
|
32
|
+
declare const magenta: (str: string | number) => string;
|
|
33
|
+
declare const cyan: (str: string | number) => string;
|
|
34
|
+
declare const white: (str: string | number) => string;
|
|
35
|
+
declare const gray: (str: string | number) => string;
|
|
36
|
+
declare const lightRed: (str: string | number) => string;
|
|
37
|
+
declare const lightGreen: (str: string | number) => string;
|
|
38
|
+
declare const lightYellow: (str: string | number) => string;
|
|
39
|
+
declare const lightBlue: (str: string | number) => string;
|
|
40
|
+
declare const lightMagenta: (str: string | number) => string;
|
|
41
|
+
declare const lightCyan: (str: string | number) => string;
|
|
42
|
+
declare const lightGray: (str: string | number) => string;
|
|
43
|
+
declare const bgBlack: (str: string | number) => string;
|
|
44
|
+
declare const bgRed: (str: string | number) => string;
|
|
45
|
+
declare const bgGreen: (str: string | number) => string;
|
|
46
|
+
declare const bgYellow: (str: string | number) => string;
|
|
47
|
+
declare const bgBlue: (str: string | number) => string;
|
|
48
|
+
declare const bgMagenta: (str: string | number) => string;
|
|
49
|
+
declare const bgCyan: (str: string | number) => string;
|
|
50
|
+
declare const bgWhite: (str: string | number) => string;
|
|
51
|
+
declare const bgGray: (str: string | number) => string;
|
|
52
|
+
declare const bgLightRed: (str: string | number) => string;
|
|
53
|
+
declare const bgLightGreen: (str: string | number) => string;
|
|
54
|
+
declare const bgLightYellow: (str: string | number) => string;
|
|
55
|
+
declare const bgLightBlue: (str: string | number) => string;
|
|
56
|
+
declare const bgLightMagenta: (str: string | number) => string;
|
|
57
|
+
declare const bgLightCyan: (str: string | number) => string;
|
|
58
|
+
declare const bgLightGray: (str: string | number) => string;
|
|
59
|
+
declare const ansi256: (n: number) => (str: string | number) => string;
|
|
60
|
+
declare const ansi256Bg: (n: number) => (str: string | number) => string;
|
|
59
61
|
declare function link(text: string, url: string): string;
|
|
60
62
|
|
|
61
|
-
export { SupportLevel, ansi256, ansi256Bg, bgBlack, bgBlue, bgCyan, bgGray, bgGreen, bgLightBlue, bgLightCyan, bgLightGray, bgLightGreen, bgLightMagenta, bgLightRed, bgLightYellow, bgMagenta, bgRed, bgWhite, bgYellow, black, blue, bold, cyan, dim, gray, green, hidden, inverse, italic, lightBlue, lightCyan, lightGray, lightGreen, lightMagenta, lightRed, lightYellow, link, magenta, options, red, reset, strikethrough, stripColors, underline, white, yellow };
|
|
63
|
+
export { SupportLevel, ansi256, ansi256Bg, bgBlack, bgBlue, bgCyan, bgGray, bgGreen, bgLightBlue, bgLightCyan, bgLightGray, bgLightGreen, bgLightMagenta, bgLightRed, bgLightYellow, bgMagenta, bgRed, bgWhite, bgYellow, black, blue, bold, combine, cyan, dim, gray, green, hidden, inverse, italic, lightBlue, lightCyan, lightGray, lightGreen, lightMagenta, lightRed, lightYellow, link, magenta, options, red, reset, strikethrough, stripColors, underline, white, yellow };
|
package/dist/index.mjs
CHANGED
|
@@ -54,6 +54,14 @@ function kolorist(start, end, level = 1 /* ansi */) {
|
|
|
54
54
|
return options.enabled && options.supportLevel >= level ? open + ("" + str).replace(regex, open) + close : "" + str;
|
|
55
55
|
};
|
|
56
56
|
}
|
|
57
|
+
function combine(...fns) {
|
|
58
|
+
return (str) => {
|
|
59
|
+
for (const fn of fns) {
|
|
60
|
+
str = fn(str);
|
|
61
|
+
}
|
|
62
|
+
return str;
|
|
63
|
+
};
|
|
64
|
+
}
|
|
57
65
|
function stripColors(str) {
|
|
58
66
|
return ("" + str).replace(/\x1b\[[0-9;]+m/g, "").replace(/\x1b\]8;;.*?\x07(.*?)\x1b\]8;;\x07/g, (_, group) => group);
|
|
59
67
|
}
|
|
@@ -106,4 +114,4 @@ function link(text, url) {
|
|
|
106
114
|
return options.enabled ? OSC + "8" + SEP + SEP + url + BEL + text + OSC + "8" + SEP + SEP + BEL : `${text} (\u200B${url}\u200B)`;
|
|
107
115
|
}
|
|
108
116
|
|
|
109
|
-
export { SupportLevel, ansi256, ansi256Bg, bgBlack, bgBlue, bgCyan, bgGray, bgGreen, bgLightBlue, bgLightCyan, bgLightGray, bgLightGreen, bgLightMagenta, bgLightRed, bgLightYellow, bgMagenta, bgRed, bgWhite, bgYellow, black, blue, bold, cyan, dim, gray, green, hidden, inverse, italic, lightBlue, lightCyan, lightGray, lightGreen, lightMagenta, lightRed, lightYellow, link, magenta, options, red, reset, strikethrough, stripColors, underline, white, yellow };
|
|
117
|
+
export { SupportLevel, ansi256, ansi256Bg, bgBlack, bgBlue, bgCyan, bgGray, bgGreen, bgLightBlue, bgLightCyan, bgLightGray, bgLightGreen, bgLightMagenta, bgLightRed, bgLightYellow, bgMagenta, bgRed, bgWhite, bgYellow, black, blue, bold, combine, cyan, dim, gray, green, hidden, inverse, italic, lightBlue, lightCyan, lightGray, lightGreen, lightMagenta, lightRed, lightYellow, link, magenta, options, red, reset, strikethrough, stripColors, underline, white, yellow };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@breadc/color",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.1",
|
|
4
4
|
"description": "Terminal color for Breadc",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"breadc",
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"author": "XLor",
|
|
21
21
|
"sideEffects": false,
|
|
22
|
+
"type": "module",
|
|
22
23
|
"exports": {
|
|
23
24
|
".": {
|
|
24
25
|
"require": "./dist/index.cjs",
|
|
@@ -26,15 +27,15 @@
|
|
|
26
27
|
"types": "./dist/index.d.ts"
|
|
27
28
|
}
|
|
28
29
|
},
|
|
29
|
-
"main": "
|
|
30
|
-
"module": "
|
|
31
|
-
"types": "
|
|
30
|
+
"main": "dist/index.cjs",
|
|
31
|
+
"module": "dist/index.mjs",
|
|
32
|
+
"types": "dist/index.d.ts",
|
|
32
33
|
"files": [
|
|
33
34
|
"dist"
|
|
34
35
|
],
|
|
35
36
|
"devDependencies": {
|
|
36
|
-
"@types/node": "^18.
|
|
37
|
-
"vitest": "^0.
|
|
37
|
+
"@types/node": "^18.15.11",
|
|
38
|
+
"vitest": "^0.30.1"
|
|
38
39
|
},
|
|
39
40
|
"scripts": {
|
|
40
41
|
"build": "unbuild",
|