@visulima/colorize 2.0.0-alpha.10 → 2.0.0-alpha.11
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 +20 -0
- package/dist/gradient.cjs +3 -62
- package/dist/gradient.d.cts +21 -12
- package/dist/gradient.d.mts +21 -12
- package/dist/gradient.d.ts +21 -12
- package/dist/gradient.mjs +3 -56
- package/dist/index.browser.d.mts +203 -60
- package/dist/index.browser.d.ts +204 -0
- package/dist/index.browser.mjs +1 -61
- package/dist/index.server.cjs +2 -255
- package/dist/index.server.d.cts +12 -6
- package/dist/index.server.d.mts +203 -60
- package/dist/index.server.d.ts +12 -6
- package/dist/index.server.mjs +1 -61
- package/dist/packem_shared/Colorize-BUAQi0t0.js +2 -0
- package/dist/packem_shared/Colorize-i0NybjSp.js +1 -0
- package/dist/packem_shared/GradientBuilder-CudosKb8.cjs +1 -0
- package/dist/packem_shared/GradientBuilder-Du8WSL23.mjs +1 -0
- package/dist/packem_shared/colorize.server-BkQZGeaS.mjs +2 -0
- package/dist/packem_shared/colorize.server-Dn-gV0MN.cjs +2 -0
- package/dist/packem_shared/convertHexToRgb-CJNE3k_E.mjs +1 -0
- package/dist/packem_shared/convertHexToRgb-Dvalc5FD.cjs +1 -0
- package/dist/packem_shared/rgbToAnsi256--f09kvlF.cjs +1 -0
- package/dist/packem_shared/rgbToAnsi256-YETEPW8R.mjs +1 -0
- package/dist/packem_shared/types.d-bhP-2hCu.d.cts +154 -0
- package/dist/packem_shared/types.d-bhP-2hCu.d.mts +154 -0
- package/dist/packem_shared/types.d-bhP-2hCu.d.ts +154 -0
- package/dist/template.cjs +2 -152
- package/dist/template.d.cts +10 -4
- package/dist/template.d.mts +4 -4
- package/dist/template.d.ts +10 -4
- package/dist/template.mjs +2 -146
- package/dist/utils.cjs +1 -13
- package/dist/utils.d.cts +13 -2
- package/dist/utils.d.mts +13 -2
- package/dist/utils.d.ts +13 -2
- package/dist/utils.mjs +1 -2
- package/package.json +47 -47
- package/dist/ansi-codes.d.cts +0 -18
- package/dist/ansi-codes.d.mts +0 -18
- package/dist/ansi-codes.d.ts +0 -18
- package/dist/colorize.browser.d.mts +0 -3
- package/dist/colorize.server.d.cts +0 -10
- package/dist/colorize.server.d.mts +0 -10
- package/dist/colorize.server.d.ts +0 -10
- package/dist/css-code.d.mts +0 -11
- package/dist/gradient/gradient-builder.d.cts +0 -10
- package/dist/gradient/gradient-builder.d.mts +0 -10
- package/dist/gradient/gradient-builder.d.ts +0 -10
- package/dist/gradient/util/color-names.d.cts +0 -2
- package/dist/gradient/util/color-names.d.mts +0 -2
- package/dist/gradient/util/color-names.d.ts +0 -2
- package/dist/gradient/util/compute.d.cts +0 -2
- package/dist/gradient/util/compute.d.mts +0 -2
- package/dist/gradient/util/compute.d.ts +0 -2
- package/dist/gradient/util/hsv-to-rgb.d.cts +0 -5
- package/dist/gradient/util/hsv-to-rgb.d.mts +0 -5
- package/dist/gradient/util/hsv-to-rgb.d.ts +0 -5
- package/dist/gradient/util/interpolate.d.cts +0 -3
- package/dist/gradient/util/interpolate.d.mts +0 -3
- package/dist/gradient/util/interpolate.d.ts +0 -3
- package/dist/gradient/util/rgb-to-hsv.d.cts +0 -9
- package/dist/gradient/util/rgb-to-hsv.d.mts +0 -9
- package/dist/gradient/util/rgb-to-hsv.d.ts +0 -9
- package/dist/packem_shared/Colorize-BQ-Wlgs0.js +0 -409
- package/dist/packem_shared/Colorize-rJUN0RFg.js +0 -250
- package/dist/packem_shared/GradientBuilder-CkX4Imo9.mjs +0 -483
- package/dist/packem_shared/GradientBuilder-DRrwebdU.cjs +0 -487
- package/dist/packem_shared/colorize.server-CwTmhs0e.cjs +0 -198
- package/dist/packem_shared/colorize.server-YxoHIDUp.mjs +0 -196
- package/dist/packem_shared/convertHexToRgb-51-edHxE.cjs +0 -21
- package/dist/packem_shared/convertHexToRgb-BZwJEiMZ.mjs +0 -17
- package/dist/packem_shared/rgbToAnsi256-BdS0fomP.mjs +0 -41
- package/dist/packem_shared/rgbToAnsi256-DL8eajTz.cjs +0 -47
- package/dist/template/make-colorize-template.d.cts +0 -9
- package/dist/template/make-colorize-template.d.mts +0 -9
- package/dist/template/make-colorize-template.d.ts +0 -9
- package/dist/template/make-template.d.cts +0 -10
- package/dist/template/make-template.d.mts +0 -10
- package/dist/template/make-template.d.ts +0 -10
- package/dist/types.d.cts +0 -174
- package/dist/types.d.mts +0 -174
- package/dist/types.d.ts +0 -174
- package/dist/util/ansi-code-hex-map.d.mts +0 -8
- package/dist/util/clamp.d.cts +0 -12
- package/dist/util/clamp.d.mts +0 -12
- package/dist/util/clamp.d.ts +0 -12
- package/dist/util/convert-hex-to-rgb.d.cts +0 -8
- package/dist/util/convert-hex-to-rgb.d.mts +0 -8
- package/dist/util/convert-hex-to-rgb.d.ts +0 -8
- package/dist/util/convert-rgb-to-ansi.d.cts +0 -18
- package/dist/util/convert-rgb-to-ansi.d.mts +0 -18
- package/dist/util/convert-rgb-to-ansi.d.ts +0 -18
- package/dist/util/string-replace-all.d.cts +0 -12
- package/dist/util/string-replace-all.d.mts +0 -12
- package/dist/util/string-replace-all.d.ts +0 -12
- package/dist/util/unescape.d.cts +0 -9
- package/dist/util/unescape.d.mts +0 -9
- package/dist/util/unescape.d.ts +0 -9
package/dist/template.mjs
CHANGED
|
@@ -1,146 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const makeColorizeTemplate = (template) => (firstString, ...arguments_) => {
|
|
5
|
-
if (!Array.isArray(firstString) || !Array.isArray(firstString.raw)) {
|
|
6
|
-
throw new TypeError("A tagged template literal must be provided");
|
|
7
|
-
}
|
|
8
|
-
const parts = [firstString.raw[0]];
|
|
9
|
-
for (let index = 1; index < firstString.raw.length; index += 1) {
|
|
10
|
-
parts.push(String(arguments_[index - 1]).replaceAll(/[{}\\]/g, String.raw`\$&`), String(firstString.raw[index]));
|
|
11
|
-
}
|
|
12
|
-
return template(parts.join(""));
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
const ESCAPES = /* @__PURE__ */ new Map([
|
|
16
|
-
["0", "\0"],
|
|
17
|
-
["\\", "\\"],
|
|
18
|
-
["a", "\x07"],
|
|
19
|
-
["b", "\b"],
|
|
20
|
-
["e", "\x1B"],
|
|
21
|
-
["f", "\f"],
|
|
22
|
-
["n", "\n"],
|
|
23
|
-
["r", "\r"],
|
|
24
|
-
["t", " "],
|
|
25
|
-
["v", "\v"]
|
|
26
|
-
]);
|
|
27
|
-
const unescape = (c) => {
|
|
28
|
-
const u = c.startsWith("u");
|
|
29
|
-
const bracket = c[1] === "{";
|
|
30
|
-
if (u && !bracket && c.length === 5 || c.startsWith("x") && c.length === 3) {
|
|
31
|
-
return String.fromCodePoint(Number.parseInt(c.slice(1), 16));
|
|
32
|
-
}
|
|
33
|
-
if (u && bracket) {
|
|
34
|
-
return String.fromCodePoint(Number.parseInt(c.slice(2, -1), 16));
|
|
35
|
-
}
|
|
36
|
-
return ESCAPES.get(c) ?? c;
|
|
37
|
-
};
|
|
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;
|
|
40
|
-
const STYLE_REGEX = /(?:^|\.)(?:(\w+)(?:\(([^)]*)\))?|#(?=[:a-f\d]{2,})([a-f\d]{6})?(?::([a-f\d]{6}))?)/gi;
|
|
41
|
-
const STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
|
|
42
|
-
const ESCAPE_REGEX = /\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.)|([^\\])/gi;
|
|
43
|
-
const CHUNK_SPLIT_REGEX = /\s*,\s*/;
|
|
44
|
-
const parseArguments = (name, value) => {
|
|
45
|
-
const results = [];
|
|
46
|
-
const chunks = value.trim().split(CHUNK_SPLIT_REGEX);
|
|
47
|
-
let matches;
|
|
48
|
-
for (const chunk of chunks) {
|
|
49
|
-
const number = Number(chunk);
|
|
50
|
-
if (!Number.isNaN(number)) {
|
|
51
|
-
results.push(number);
|
|
52
|
-
} else if (matches = STRING_REGEX.exec(chunk)) {
|
|
53
|
-
results.push(
|
|
54
|
-
matches[2].replaceAll(ESCAPE_REGEX, (_, escape, character) => {
|
|
55
|
-
if (escape) {
|
|
56
|
-
return unescape(escape);
|
|
57
|
-
}
|
|
58
|
-
return character;
|
|
59
|
-
})
|
|
60
|
-
);
|
|
61
|
-
} else {
|
|
62
|
-
throw new Error(`Invalid template style argument: ${chunk} (in style '${name}')`);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
return results;
|
|
66
|
-
};
|
|
67
|
-
const parseStyle = (style) => {
|
|
68
|
-
STYLE_REGEX.lastIndex = 0;
|
|
69
|
-
const results = [];
|
|
70
|
-
let matches;
|
|
71
|
-
while ((matches = STYLE_REGEX.exec(style)) !== null) {
|
|
72
|
-
const name = matches[1];
|
|
73
|
-
if (matches[2]) {
|
|
74
|
-
results.push([name, ...parseArguments(name, matches[2])]);
|
|
75
|
-
} else if (matches[3] || matches[4]) {
|
|
76
|
-
if (matches[3]) {
|
|
77
|
-
results.push(["rgb", ...convertHexToRgb(matches[3])]);
|
|
78
|
-
}
|
|
79
|
-
if (matches[4]) {
|
|
80
|
-
results.push(["bgRgb", ...convertHexToRgb(matches[4])]);
|
|
81
|
-
}
|
|
82
|
-
} else {
|
|
83
|
-
results.push([name]);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
return results;
|
|
87
|
-
};
|
|
88
|
-
const buildStyle = (colorize, styles) => {
|
|
89
|
-
const enabled = {};
|
|
90
|
-
for (const layer of styles) {
|
|
91
|
-
for (const style of layer.styles) {
|
|
92
|
-
enabled[style[0]] = layer.inverse ? void 0 : style.slice(1);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
let current = colorize;
|
|
96
|
-
for (const [styleName, enabledStyles] of Object.entries(enabled)) {
|
|
97
|
-
if (!Array.isArray(enabledStyles)) {
|
|
98
|
-
continue;
|
|
99
|
-
}
|
|
100
|
-
if (!(styleName in current)) {
|
|
101
|
-
throw new Error(`Unknown style: ${styleName}`);
|
|
102
|
-
}
|
|
103
|
-
current = enabledStyles.length > 0 ? current[styleName](...enabledStyles) : current[styleName];
|
|
104
|
-
}
|
|
105
|
-
return current;
|
|
106
|
-
};
|
|
107
|
-
const makeTemplate = (colorize) => (string) => {
|
|
108
|
-
const styles = [];
|
|
109
|
-
const chunks = [];
|
|
110
|
-
let chunk = [];
|
|
111
|
-
string.replaceAll(
|
|
112
|
-
TEMPLATE_REGEX,
|
|
113
|
-
// @ts-expect-error - TS doesn't understand that the regex args are defined
|
|
114
|
-
(_, escapeCharacter, inverse, style, close, character) => {
|
|
115
|
-
if (escapeCharacter) {
|
|
116
|
-
chunk.push(unescape(escapeCharacter));
|
|
117
|
-
} else if (style) {
|
|
118
|
-
const joinedChunk = chunk.join("");
|
|
119
|
-
chunk = [];
|
|
120
|
-
chunks.push(styles.length === 0 ? joinedChunk : buildStyle(colorize, styles)(joinedChunk));
|
|
121
|
-
styles.push({ inverse, styles: parseStyle(style) });
|
|
122
|
-
} else if (close) {
|
|
123
|
-
if (styles.length === 0) {
|
|
124
|
-
throw new Error("Found extraneous } in template literal");
|
|
125
|
-
}
|
|
126
|
-
chunks.push(buildStyle(colorize, styles)(chunk.join("")));
|
|
127
|
-
chunk = [];
|
|
128
|
-
styles.pop();
|
|
129
|
-
} else {
|
|
130
|
-
chunk.push(character);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
);
|
|
134
|
-
chunks.push(chunk.join(""));
|
|
135
|
-
if (styles.length > 0) {
|
|
136
|
-
throw new Error(`template literal is missing ${String(styles.length)} closing bracket${styles.length === 1 ? "" : "s"} (\`}\`)`);
|
|
137
|
-
}
|
|
138
|
-
return chunks.join("");
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
const colorize = new Colorize();
|
|
142
|
-
const makeTaggedTemplate = (instance) => makeColorizeTemplate(makeTemplate(instance));
|
|
143
|
-
const template = makeTemplate(colorize);
|
|
144
|
-
const templateFunction = makeColorizeTemplate(template);
|
|
145
|
-
|
|
146
|
-
export { templateFunction as default, makeTaggedTemplate, template };
|
|
1
|
+
var y=Object.defineProperty;var i=(e,t)=>y(e,"name",{value:t,configurable:!0});import{A}from"./packem_shared/colorize.server-BkQZGeaS.mjs";import{convertHexToRgb as g}from"./packem_shared/convertHexToRgb-CJNE3k_E.mjs";var x=Object.defineProperty,T=i((e,t)=>x(e,"name",{value:t,configurable:!0}),"n");const d=T(e=>(t,...r)=>{if(!Array.isArray(t)||!Array.isArray(t.raw))throw new TypeError("A tagged template literal must be provided");const a=[t.raw[0]];for(let n=1;n<t.raw.length;n+=1)a.push(String(r[n-1]).replaceAll(/[{}\\]/g,String.raw`\$&`),String(t.raw[n]));return e(a.join(""))},"makeColorizeTemplate");var j=Object.defineProperty,k=i((e,t)=>j(e,"name",{value:t,configurable:!0}),"e$1");const $=new Map([["0","\0"],["\\","\\"],["a","\x07"],["b","\b"],["e","\x1B"],["f","\f"],["n",`
|
|
2
|
+
`],["r","\r"],["t"," "],["v","\v"]]),b=k(e=>{const t=e.startsWith("u"),r=e[1]==="{";return t&&!r&&e.length===5||e.startsWith("x")&&e.length===3?String.fromCodePoint(Number.parseInt(e.slice(1),16)):t&&r?String.fromCodePoint(Number.parseInt(e.slice(2,-1),16)):$.get(e)??e},"unescape");var S=Object.defineProperty,u=i((e,t)=>S(e,"name",{value:t,configurable:!0}),"u");const E=/\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.)|\{(~)?(#?[\w:]+(?:\([^)]*\))?(?:\.#?[\w:]+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n))|(\})|((?:.|[\r\n\f])+?)/gi,m=/(?:^|\.)(?:(\w+)(?:\(([^)]*)\))?|#(?=[:a-f\d]{2,})([a-f\d]{6})?(?::([a-f\d]{6}))?)/gi,N=/^(['"])((?:\\.|(?!\1)[^\\])*)\1$/,P=/\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.)|([^\\])/gi,O=/\s*,\s*/,C=u((e,t)=>{const r=[],a=t.trim().split(O);let n;for(const s of a){const o=Number(s);if(!Number.isNaN(o))r.push(o);else if(n=N.exec(s))r.push(n[2].replaceAll(P,(f,l,p)=>l?b(l):p));else throw new Error(`Invalid template style argument: ${s} (in style '${e}')`)}return r},"parseArguments"),I=u(e=>{m.lastIndex=0;const t=[];let r;for(;(r=m.exec(e))!==null;){const a=r[1];r[2]?t.push([a,...C(a,r[2])]):r[3]||r[4]?(r[3]&&t.push(["rgb",...g(r[3])]),r[4]&&t.push(["bgRgb",...g(r[4])])):t.push([a])}return t},"parseStyle"),h=u((e,t)=>{const r={};for(const n of t)for(const s of n.styles)r[s[0]]=n.inverse?void 0:s.slice(1);let a=e;for(const[n,s]of Object.entries(r))if(Array.isArray(s)){if(!(n in a))throw new Error(`Unknown style: ${n}`);a=s.length>0?a[n](...s):a[n]}return a},"buildStyle"),w=u(e=>t=>{const r=[],a=[];let n=[];if(t.replaceAll(E,(s,o,f,l,p,v)=>{if(o)n.push(b(o));else if(l){const c=n.join("");n=[],a.push(r.length===0?c:h(e,r)(c)),r.push({inverse:f,styles:I(l)})}else if(p){if(r.length===0)throw new Error("Found extraneous } in template literal");a.push(h(e,r)(n.join(""))),n=[],r.pop()}else n.push(v)}),a.push(n.join("")),r.length>0)throw new Error(`template literal is missing ${String(r.length)} closing bracket${r.length===1?"":"s"} (\`}\`)`);return a.join("")},"makeTemplate");var R=Object.defineProperty,z=i((e,t)=>R(e,"name",{value:t,configurable:!0}),"e");const W=new A,U=z(e=>d(w(e)),"makeTaggedTemplate"),B=w(W),q=d(B);export{q as default,U as makeTaggedTemplate,B as template};
|
package/dist/utils.cjs
CHANGED
|
@@ -1,13 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
|
4
|
-
|
|
5
|
-
const convertHexToRgb = require('./packem_shared/convertHexToRgb-51-edHxE.cjs');
|
|
6
|
-
const rgbToAnsi256 = require('./packem_shared/rgbToAnsi256-DL8eajTz.cjs');
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
exports.convertHexToRgb = convertHexToRgb.convertHexToRgb;
|
|
11
|
-
exports.ansi256To16 = rgbToAnsi256.ansi256To16;
|
|
12
|
-
exports.rgbToAnsi16 = rgbToAnsi256.rgbToAnsi16;
|
|
13
|
-
exports.rgbToAnsi256 = rgbToAnsi256.rgbToAnsi256;
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("./packem_shared/convertHexToRgb-Dvalc5FD.cjs"),e=require("./packem_shared/rgbToAnsi256--f09kvlF.cjs");exports.convertHexToRgb=o.convertHexToRgb;exports.ansi256To16=e.ansi256To16;exports.rgbToAnsi16=e.rgbToAnsi16;exports.rgbToAnsi256=e.rgbToAnsi256;
|
package/dist/utils.d.cts
CHANGED
|
@@ -1,2 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
declare const convertHexToRgb: (hex: string) => [number, number, number];
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Convert RGB values to approximate code of ANSI 256 colors.
|
|
5
|
+
*
|
|
6
|
+
*/
|
|
7
|
+
declare const rgbToAnsi256: (r: number, g: number, b: number) => number;
|
|
8
|
+
/**
|
|
9
|
+
* Convert ANSI 256 color code to approximate code of ANSI 16 colors.
|
|
10
|
+
*/
|
|
11
|
+
declare const ansi256To16: (code: number) => number;
|
|
12
|
+
declare const rgbToAnsi16: (r: number, g: number, b: number) => number;
|
|
13
|
+
export { ansi256To16, convertHexToRgb, rgbToAnsi16, rgbToAnsi256 };
|
package/dist/utils.d.mts
CHANGED
|
@@ -1,2 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
declare const convertHexToRgb: (hex: string) => [number, number, number];
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Convert RGB values to approximate code of ANSI 256 colors.
|
|
5
|
+
*
|
|
6
|
+
*/
|
|
7
|
+
declare const rgbToAnsi256: (r: number, g: number, b: number) => number;
|
|
8
|
+
/**
|
|
9
|
+
* Convert ANSI 256 color code to approximate code of ANSI 16 colors.
|
|
10
|
+
*/
|
|
11
|
+
declare const ansi256To16: (code: number) => number;
|
|
12
|
+
declare const rgbToAnsi16: (r: number, g: number, b: number) => number;
|
|
13
|
+
export { ansi256To16, convertHexToRgb, rgbToAnsi16, rgbToAnsi256 };
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,2 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
declare const convertHexToRgb: (hex: string) => [number, number, number];
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Convert RGB values to approximate code of ANSI 256 colors.
|
|
5
|
+
*
|
|
6
|
+
*/
|
|
7
|
+
declare const rgbToAnsi256: (r: number, g: number, b: number) => number;
|
|
8
|
+
/**
|
|
9
|
+
* Convert ANSI 256 color code to approximate code of ANSI 16 colors.
|
|
10
|
+
*/
|
|
11
|
+
declare const ansi256To16: (code: number) => number;
|
|
12
|
+
declare const rgbToAnsi16: (r: number, g: number, b: number) => number;
|
|
13
|
+
export { ansi256To16, convertHexToRgb, rgbToAnsi16, rgbToAnsi256 };
|
package/dist/utils.mjs
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { ansi256To16, rgbToAnsi16, rgbToAnsi256 } from './packem_shared/rgbToAnsi256-BdS0fomP.mjs';
|
|
1
|
+
import{convertHexToRgb as e}from"./packem_shared/convertHexToRgb-CJNE3k_E.mjs";import{ansi256To16 as T,rgbToAnsi16 as b,rgbToAnsi256 as g}from"./packem_shared/rgbToAnsi256-YETEPW8R.mjs";export{T as ansi256To16,e as convertHexToRgb,b as rgbToAnsi16,g as rgbToAnsi256};
|
package/package.json
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visulima/colorize",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.11",
|
|
4
4
|
"description": "Terminal and Console string styling done right.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"256",
|
|
7
|
+
"FORCE_COLOR",
|
|
8
|
+
"NO_COLOR",
|
|
7
9
|
"anolilab",
|
|
8
10
|
"ansi",
|
|
9
11
|
"ansi-colors",
|
|
@@ -22,7 +24,6 @@
|
|
|
22
24
|
"console",
|
|
23
25
|
"cyan",
|
|
24
26
|
"firefox",
|
|
25
|
-
"FORCE_COLOR",
|
|
26
27
|
"formatting",
|
|
27
28
|
"gradient",
|
|
28
29
|
"gradients",
|
|
@@ -31,7 +32,6 @@
|
|
|
31
32
|
"log",
|
|
32
33
|
"logging",
|
|
33
34
|
"magenta",
|
|
34
|
-
"NO_COLOR",
|
|
35
35
|
"picocolors",
|
|
36
36
|
"red",
|
|
37
37
|
"rgb",
|
|
@@ -40,9 +40,9 @@
|
|
|
40
40
|
"strip-color",
|
|
41
41
|
"style",
|
|
42
42
|
"styles",
|
|
43
|
+
"tagged template",
|
|
43
44
|
"tagged template literal",
|
|
44
45
|
"tagged template string",
|
|
45
|
-
"tagged template",
|
|
46
46
|
"tagged-template",
|
|
47
47
|
"template",
|
|
48
48
|
"template-string",
|
|
@@ -56,6 +56,11 @@
|
|
|
56
56
|
"yellow"
|
|
57
57
|
],
|
|
58
58
|
"homepage": "https://visulima.com/packages/colorize/",
|
|
59
|
+
"license": "MIT",
|
|
60
|
+
"author": {
|
|
61
|
+
"name": "Daniel Bannert",
|
|
62
|
+
"email": "d.bannert@anolilab.de"
|
|
63
|
+
},
|
|
59
64
|
"repository": {
|
|
60
65
|
"type": "git",
|
|
61
66
|
"url": "git+https://github.com/visulima/visulima.git",
|
|
@@ -71,13 +76,42 @@
|
|
|
71
76
|
"url": "https://anolilab.com/support"
|
|
72
77
|
}
|
|
73
78
|
],
|
|
74
|
-
"
|
|
75
|
-
|
|
76
|
-
"
|
|
77
|
-
"
|
|
78
|
-
|
|
79
|
-
|
|
79
|
+
"files": [
|
|
80
|
+
"dist/**",
|
|
81
|
+
"README.md",
|
|
82
|
+
"CHANGELOG.md",
|
|
83
|
+
"LICENSE.md"
|
|
84
|
+
],
|
|
85
|
+
"os": [
|
|
86
|
+
"darwin",
|
|
87
|
+
"linux",
|
|
88
|
+
"win32"
|
|
89
|
+
],
|
|
80
90
|
"type": "module",
|
|
91
|
+
"sideEffects": false,
|
|
92
|
+
"main": "dist/index.server.cjs",
|
|
93
|
+
"module": "dist/index.server.mjs",
|
|
94
|
+
"types": "dist/index.server.d.ts",
|
|
95
|
+
"typesVersions": {
|
|
96
|
+
">=5.0": {
|
|
97
|
+
".": [
|
|
98
|
+
"./dist/index.server.d.ts",
|
|
99
|
+
"./dist/index.browser.d.ts"
|
|
100
|
+
],
|
|
101
|
+
"browser": [
|
|
102
|
+
"./dist/index.browser.d.ts"
|
|
103
|
+
],
|
|
104
|
+
"template": [
|
|
105
|
+
"./dist/template.d.ts"
|
|
106
|
+
],
|
|
107
|
+
"gradient": [
|
|
108
|
+
"./dist/gradient.d.ts"
|
|
109
|
+
],
|
|
110
|
+
"utils": [
|
|
111
|
+
"./dist/utils.d.ts"
|
|
112
|
+
]
|
|
113
|
+
}
|
|
114
|
+
},
|
|
81
115
|
"exports": {
|
|
82
116
|
".": {
|
|
83
117
|
"edge-light": {
|
|
@@ -135,48 +169,14 @@
|
|
|
135
169
|
},
|
|
136
170
|
"./package.json": "./package.json"
|
|
137
171
|
},
|
|
138
|
-
"
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
"typesVersions": {
|
|
142
|
-
">=5.0": {
|
|
143
|
-
".": [
|
|
144
|
-
"./dist/index.server.d.ts",
|
|
145
|
-
"./dist/index.browser.d.ts"
|
|
146
|
-
],
|
|
147
|
-
"browser": [
|
|
148
|
-
"./dist/index.browser.d.ts"
|
|
149
|
-
],
|
|
150
|
-
"template": [
|
|
151
|
-
"./dist/template.d.ts"
|
|
152
|
-
],
|
|
153
|
-
"gradient": [
|
|
154
|
-
"./dist/gradient.d.ts"
|
|
155
|
-
],
|
|
156
|
-
"utils": [
|
|
157
|
-
"./dist/utils.d.ts"
|
|
158
|
-
]
|
|
159
|
-
}
|
|
172
|
+
"publishConfig": {
|
|
173
|
+
"access": "public",
|
|
174
|
+
"provenance": true
|
|
160
175
|
},
|
|
161
|
-
"files": [
|
|
162
|
-
"dist/**",
|
|
163
|
-
"README.md",
|
|
164
|
-
"CHANGELOG.md",
|
|
165
|
-
"LICENSE.md"
|
|
166
|
-
],
|
|
167
176
|
"dependencies": {
|
|
168
177
|
"@visulima/is-ansi-color-supported": "3.0.0-alpha.10"
|
|
169
178
|
},
|
|
170
179
|
"engines": {
|
|
171
180
|
"node": "^22.14.0 || >=24.10.0"
|
|
172
|
-
},
|
|
173
|
-
"os": [
|
|
174
|
-
"darwin",
|
|
175
|
-
"linux",
|
|
176
|
-
"win32"
|
|
177
|
-
],
|
|
178
|
-
"publishConfig": {
|
|
179
|
-
"access": "public",
|
|
180
|
-
"provenance": true
|
|
181
181
|
}
|
|
182
182
|
}
|
package/dist/ansi-codes.d.cts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Modified copy of https://github.com/webdiscus/ansis/blob/master/src/ansi-codes.js
|
|
3
|
-
*
|
|
4
|
-
* ISC License
|
|
5
|
-
*
|
|
6
|
-
* Copyright (c) 2023, webdiscus
|
|
7
|
-
*/
|
|
8
|
-
import type { AnsiColors, AnsiStyles, ColorData, ColorValueHex } from "./types.d.cts";
|
|
9
|
-
export declare const baseStyles: Required<Record<AnsiStyles, ColorData>>;
|
|
10
|
-
export declare const baseColors: Required<Record<AnsiColors, ColorData>>;
|
|
11
|
-
export declare const styleMethods: {
|
|
12
|
-
bg: (code: number) => ColorData;
|
|
13
|
-
bgHex: (hex: ColorValueHex) => ColorData;
|
|
14
|
-
bgRgb: (r: number, g: number, b: number) => ColorData;
|
|
15
|
-
fg: (code: number) => ColorData;
|
|
16
|
-
hex: (hex: ColorValueHex) => ColorData;
|
|
17
|
-
rgb: (r: number, g: number, b: number) => ColorData;
|
|
18
|
-
};
|
package/dist/ansi-codes.d.mts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Modified copy of https://github.com/webdiscus/ansis/blob/master/src/ansi-codes.js
|
|
3
|
-
*
|
|
4
|
-
* ISC License
|
|
5
|
-
*
|
|
6
|
-
* Copyright (c) 2023, webdiscus
|
|
7
|
-
*/
|
|
8
|
-
import type { AnsiColors, AnsiStyles, ColorData, ColorValueHex } from "./types.d.ts";
|
|
9
|
-
export declare const baseStyles: Required<Record<AnsiStyles, ColorData>>;
|
|
10
|
-
export declare const baseColors: Required<Record<AnsiColors, ColorData>>;
|
|
11
|
-
export declare const styleMethods: {
|
|
12
|
-
bg: (code: number) => ColorData;
|
|
13
|
-
bgHex: (hex: ColorValueHex) => ColorData;
|
|
14
|
-
bgRgb: (r: number, g: number, b: number) => ColorData;
|
|
15
|
-
fg: (code: number) => ColorData;
|
|
16
|
-
hex: (hex: ColorValueHex) => ColorData;
|
|
17
|
-
rgb: (r: number, g: number, b: number) => ColorData;
|
|
18
|
-
};
|
package/dist/ansi-codes.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Modified copy of https://github.com/webdiscus/ansis/blob/master/src/ansi-codes.js
|
|
3
|
-
*
|
|
4
|
-
* ISC License
|
|
5
|
-
*
|
|
6
|
-
* Copyright (c) 2023, webdiscus
|
|
7
|
-
*/
|
|
8
|
-
import type { AnsiColors, AnsiStyles, ColorData, ColorValueHex } from "./types.d.ts";
|
|
9
|
-
export declare const baseStyles: Required<Record<AnsiStyles, ColorData>>;
|
|
10
|
-
export declare const baseColors: Required<Record<AnsiColors, ColorData>>;
|
|
11
|
-
export declare const styleMethods: {
|
|
12
|
-
bg: (code: number) => ColorData;
|
|
13
|
-
bgHex: (hex: ColorValueHex) => ColorData;
|
|
14
|
-
bgRgb: (r: number, g: number, b: number) => ColorData;
|
|
15
|
-
fg: (code: number) => ColorData;
|
|
16
|
-
hex: (hex: ColorValueHex) => ColorData;
|
|
17
|
-
rgb: (r: number, g: number, b: number) => ColorData;
|
|
18
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Modified copy of https://github.com/webdiscus/ansis/blob/master/src/index.js
|
|
3
|
-
*
|
|
4
|
-
* ISC License
|
|
5
|
-
*
|
|
6
|
-
* Copyright (c) 2023, webdiscus
|
|
7
|
-
*/
|
|
8
|
-
import type { ColorizeType } from "./types.d.cts";
|
|
9
|
-
declare const Colorize: new () => ColorizeType;
|
|
10
|
-
export = Colorize;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Modified copy of https://github.com/webdiscus/ansis/blob/master/src/index.js
|
|
3
|
-
*
|
|
4
|
-
* ISC License
|
|
5
|
-
*
|
|
6
|
-
* Copyright (c) 2023, webdiscus
|
|
7
|
-
*/
|
|
8
|
-
import type { ColorizeType } from "./types.d.ts";
|
|
9
|
-
declare const Colorize: new () => ColorizeType;
|
|
10
|
-
export default Colorize;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Modified copy of https://github.com/webdiscus/ansis/blob/master/src/index.js
|
|
3
|
-
*
|
|
4
|
-
* ISC License
|
|
5
|
-
*
|
|
6
|
-
* Copyright (c) 2023, webdiscus
|
|
7
|
-
*/
|
|
8
|
-
import type { ColorizeType } from "./types.d.ts";
|
|
9
|
-
declare const Colorize: new () => ColorizeType;
|
|
10
|
-
export = Colorize;
|
package/dist/css-code.d.mts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { AnsiColors, AnsiStyles } from "./types.d.ts";
|
|
2
|
-
export declare const baseStyles: Required<Record<AnsiStyles, string>>;
|
|
3
|
-
export declare const baseColors: Required<Record<AnsiColors, string>>;
|
|
4
|
-
export declare const styleMethods: {
|
|
5
|
-
bg: (code: number) => string;
|
|
6
|
-
bgHex: (hex: string) => string;
|
|
7
|
-
bgRgb: (r: number, g: number, b: number) => string;
|
|
8
|
-
fg: (code: number) => string;
|
|
9
|
-
hex: (hex: string) => string;
|
|
10
|
-
rgb: (r: number, g: number, b: number) => string;
|
|
11
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { ColorizeType, ColorValueHex, CssColorName, RGB, StopInput, StopOutput } from "../types.d.cts";
|
|
2
|
-
export declare class GradientBuilder {
|
|
3
|
-
#private;
|
|
4
|
-
readonly stops: StopOutput[];
|
|
5
|
-
constructor(colorize: ColorizeType, stops: (ColorValueHex | CssColorName | RGB | StopInput | [number, number, number])[]);
|
|
6
|
-
reverse(): GradientBuilder;
|
|
7
|
-
loop(): GradientBuilder;
|
|
8
|
-
rgb(steps: number): ColorizeType[];
|
|
9
|
-
hsv(steps: number, mode?: boolean | "long" | "short"): ColorizeType[];
|
|
10
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { ColorizeType, ColorValueHex, CssColorName, RGB, StopInput, StopOutput } from "../types.d.mts";
|
|
2
|
-
export declare class GradientBuilder {
|
|
3
|
-
#private;
|
|
4
|
-
readonly stops: StopOutput[];
|
|
5
|
-
constructor(colorize: ColorizeType, stops: (ColorValueHex | CssColorName | RGB | StopInput | [number, number, number])[]);
|
|
6
|
-
reverse(): GradientBuilder;
|
|
7
|
-
loop(): GradientBuilder;
|
|
8
|
-
rgb(steps: number): ColorizeType[];
|
|
9
|
-
hsv(steps: number, mode?: boolean | "long" | "short"): ColorizeType[];
|
|
10
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { ColorizeType, ColorValueHex, CssColorName, RGB, StopInput, StopOutput } from "../types.d.ts";
|
|
2
|
-
export declare class GradientBuilder {
|
|
3
|
-
#private;
|
|
4
|
-
readonly stops: StopOutput[];
|
|
5
|
-
constructor(colorize: ColorizeType, stops: (ColorValueHex | CssColorName | RGB | StopInput | [number, number, number])[]);
|
|
6
|
-
reverse(): GradientBuilder;
|
|
7
|
-
loop(): GradientBuilder;
|
|
8
|
-
rgb(steps: number): ColorizeType[];
|
|
9
|
-
hsv(steps: number, mode?: boolean | "long" | "short"): ColorizeType[];
|
|
10
|
-
}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import type { RGB, StopOutput } from "../../types.d.cts";
|
|
2
|
-
export declare const interpolateRgb: (stop1: StopOutput, stop2: StopOutput, steps: number) => RGB[];
|
|
3
|
-
export declare const interpolateHsv: (stop1: StopOutput, stop2: StopOutput, steps: number, mode: boolean | "long" | "short") => RGB[];
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import type { RGB, StopOutput } from "../../types.d.mts";
|
|
2
|
-
export declare const interpolateRgb: (stop1: StopOutput, stop2: StopOutput, steps: number) => RGB[];
|
|
3
|
-
export declare const interpolateHsv: (stop1: StopOutput, stop2: StopOutput, steps: number, mode: boolean | "long" | "short") => RGB[];
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import type { RGB, StopOutput } from "../../types.d.ts";
|
|
2
|
-
export declare const interpolateRgb: (stop1: StopOutput, stop2: StopOutput, steps: number) => RGB[];
|
|
3
|
-
export declare const interpolateHsv: (stop1: StopOutput, stop2: StopOutput, steps: number, mode: boolean | "long" | "short") => RGB[];
|