@visulima/colorize 1.4.23 → 1.4.24

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.
Files changed (38) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/dist/gradient.cjs +3 -62
  3. package/dist/gradient.d.cts +2 -2
  4. package/dist/gradient.d.mts +2 -2
  5. package/dist/gradient.d.ts +2 -2
  6. package/dist/gradient.mjs +3 -56
  7. package/dist/index.browser.mjs +1 -63
  8. package/dist/index.server.cjs +2 -266
  9. package/dist/index.server.d.cts +72 -71
  10. package/dist/index.server.mjs +1 -63
  11. package/dist/packem_shared/Colorize-Bn8gI3ME.mjs +1 -0
  12. package/dist/packem_shared/Colorize-CfIXnDUD.mjs +2 -0
  13. package/dist/packem_shared/GradientBuilder-C2IS34v_.cjs +1 -0
  14. package/dist/packem_shared/GradientBuilder-I_j6wpvU.mjs +1 -0
  15. package/dist/packem_shared/ansi256To16--f09kvlF.cjs +1 -0
  16. package/dist/packem_shared/ansi256To16-YETEPW8R.mjs +1 -0
  17. package/dist/packem_shared/colorize.server-9hV-s1hY.mjs +2 -0
  18. package/dist/packem_shared/colorize.server-B0BWdm8_.cjs +2 -0
  19. package/dist/packem_shared/convertHexToRgb-BEnfEytq.cjs +1 -0
  20. package/dist/packem_shared/convertHexToRgb-DGcGUKnj.mjs +1 -0
  21. package/dist/template.cjs +2 -158
  22. package/dist/template.d.cts +10 -8
  23. package/dist/template.d.mts +1 -1
  24. package/dist/template.d.ts +10 -8
  25. package/dist/template.mjs +2 -152
  26. package/dist/utils.cjs +1 -13
  27. package/dist/utils.mjs +1 -2
  28. package/package.json +19 -19
  29. package/dist/packem_shared/Colorize-B2nGcFjg.mjs +0 -417
  30. package/dist/packem_shared/Colorize-BihiZiAf.mjs +0 -258
  31. package/dist/packem_shared/GradientBuilder-Cn2sQ1aK.cjs +0 -505
  32. package/dist/packem_shared/GradientBuilder-Dy53F9zB.mjs +0 -501
  33. package/dist/packem_shared/colorize.server-0LnwnixR.cjs +0 -205
  34. package/dist/packem_shared/colorize.server-DSyvWqmN.mjs +0 -203
  35. package/dist/packem_shared/convertHexToRgb-DDy3Eccg.cjs +0 -19
  36. package/dist/packem_shared/convertHexToRgb-DOIRmKxM.mjs +0 -15
  37. package/dist/packem_shared/rgbToAnsi256-Cakhu-n9.cjs +0 -50
  38. package/dist/packem_shared/rgbToAnsi256-DcQVMIqi.mjs +0 -44
package/dist/template.mjs CHANGED
@@ -1,152 +1,2 @@
1
- import { C as Colorize } from './packem_shared/colorize.server-DSyvWqmN.mjs';
2
- import { convertHexToRgb } from './packem_shared/convertHexToRgb-DOIRmKxM.mjs';
3
-
4
- var __defProp$3 = Object.defineProperty;
5
- var __name$3 = (target, value) => __defProp$3(target, "name", { value, configurable: true });
6
- const makeColorizeTemplate = /* @__PURE__ */ __name$3((template) => (
7
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
8
- (firstString, ...arguments_) => {
9
- if (!Array.isArray(firstString) || !Array.isArray(firstString.raw)) {
10
- throw new TypeError("A tagged template literal must be provided");
11
- }
12
- const parts = [firstString.raw[0]];
13
- for (let index = 1; index < firstString.raw.length; index++) {
14
- parts.push(String(arguments_[index - 1]).replaceAll(/[{}\\]/g, "\\$&"), String(firstString.raw[index]));
15
- }
16
- return template(parts.join(""));
17
- }
18
- ), "makeColorizeTemplate");
19
-
20
- var __defProp$2 = Object.defineProperty;
21
- var __name$2 = (target, value) => __defProp$2(target, "name", { value, configurable: true });
22
- const ESCAPES = /* @__PURE__ */ new Map([
23
- ["\\", "\\"],
24
- ["0", "\0"],
25
- ["a", "\x07"],
26
- ["b", "\b"],
27
- ["e", "\x1B"],
28
- ["f", "\f"],
29
- ["n", "\n"],
30
- ["r", "\r"],
31
- ["t", " "],
32
- ["v", "\v"]
33
- ]);
34
- const unescape = /* @__PURE__ */ __name$2((c) => {
35
- const u = c.startsWith("u");
36
- const bracket = c[1] === "{";
37
- if (u && !bracket && c.length === 5 || c.startsWith("x") && c.length === 3) {
38
- return String.fromCodePoint(Number.parseInt(c.slice(1), 16));
39
- }
40
- if (u && bracket) {
41
- return String.fromCodePoint(Number.parseInt(c.slice(2, -1), 16));
42
- }
43
- return ESCAPES.get(c) ?? c;
44
- }, "unescape");
45
-
46
- var __defProp$1 = Object.defineProperty;
47
- var __name$1 = (target, value) => __defProp$1(target, "name", { value, configurable: true });
48
- const TEMPLATE_REGEX = (
49
- // eslint-disable-next-line security/detect-unsafe-regex,regexp/no-lazy-ends,regexp/no-dupe-disjunctions
50
- /\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.)|\{(~)?(#?[\w:]+(?:\([^)]*\))?(?:\.#?[\w:]+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n))|(\})|((?:.|[\r\n\f])+?)/gi
51
- );
52
- const STYLE_REGEX = /(?:^|\.)(?:(\w+)(?:\(([^)]*)\))?|#(?=[:a-f\d]{2,})([a-f\d]{6})?(?::([a-f\d]{6}))?)/gi;
53
- const STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
54
- const ESCAPE_REGEX = /\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.)|([^\\])/gi;
55
- const parseArguments = /* @__PURE__ */ __name$1((name, value) => {
56
- const results = [];
57
- const chunks = value.trim().split(/\s*,\s*/);
58
- let matches;
59
- for (const chunk of chunks) {
60
- const number = Number(chunk);
61
- if (!Number.isNaN(number)) {
62
- results.push(number);
63
- } else if (matches = STRING_REGEX.exec(chunk)) {
64
- results.push(matches[2].replace(ESCAPE_REGEX, (_, escape, character) => escape ? unescape(escape) : character));
65
- } else {
66
- throw new Error(`Invalid template style argument: ${chunk} (in style '${name}')`);
67
- }
68
- }
69
- return results;
70
- }, "parseArguments");
71
- const parseStyle = /* @__PURE__ */ __name$1((style) => {
72
- STYLE_REGEX.lastIndex = 0;
73
- const results = [];
74
- let matches;
75
- while ((matches = STYLE_REGEX.exec(style)) !== null) {
76
- const name = matches[1];
77
- if (matches[2]) {
78
- results.push([name, ...parseArguments(name, matches[2])]);
79
- } else if (matches[3] || matches[4]) {
80
- if (matches[3]) {
81
- results.push(["rgb", ...convertHexToRgb(matches[3])]);
82
- }
83
- if (matches[4]) {
84
- results.push(["bgRgb", ...convertHexToRgb(matches[4])]);
85
- }
86
- } else {
87
- results.push([name]);
88
- }
89
- }
90
- return results;
91
- }, "parseStyle");
92
- const buildStyle = /* @__PURE__ */ __name$1((colorize, styles) => {
93
- const enabled = {};
94
- for (const layer of styles) {
95
- for (const style of layer.styles) {
96
- enabled[style[0]] = layer.inverse ? null : style.slice(1);
97
- }
98
- }
99
- let current = colorize;
100
- for (const [styleName, enabledStyles] of Object.entries(enabled)) {
101
- if (!Array.isArray(enabledStyles)) {
102
- continue;
103
- }
104
- if (!(styleName in current)) {
105
- throw new Error(`Unknown style: ${styleName}`);
106
- }
107
- current = enabledStyles.length > 0 ? current[styleName](...enabledStyles) : current[styleName];
108
- }
109
- return current;
110
- }, "buildStyle");
111
- const makeTemplate = /* @__PURE__ */ __name$1((colorize) => (string) => {
112
- const styles = [];
113
- const chunks = [];
114
- let chunk = [];
115
- string.replaceAll(
116
- TEMPLATE_REGEX,
117
- // @ts-expect-error - TS doesn't understand that the regex args are defined
118
- (_, escapeCharacter, inverse, style, close, character) => {
119
- if (escapeCharacter) {
120
- chunk.push(unescape(escapeCharacter));
121
- } else if (style) {
122
- const joinedChunk = chunk.join("");
123
- chunk = [];
124
- chunks.push(styles.length === 0 ? joinedChunk : buildStyle(colorize, styles)(joinedChunk));
125
- styles.push({ inverse, styles: parseStyle(style) });
126
- } else if (close) {
127
- if (styles.length === 0) {
128
- throw new Error("Found extraneous } in template literal");
129
- }
130
- chunks.push(buildStyle(colorize, styles)(chunk.join("")));
131
- chunk = [];
132
- styles.pop();
133
- } else {
134
- chunk.push(character);
135
- }
136
- }
137
- );
138
- chunks.push(chunk.join(""));
139
- if (styles.length > 0) {
140
- throw new Error(`template literal is missing ${styles.length} closing bracket${styles.length === 1 ? "" : "s"} (\`}\`)`);
141
- }
142
- return chunks.join("");
143
- }, "makeTemplate");
144
-
145
- var __defProp = Object.defineProperty;
146
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
147
- const colorize = new Colorize();
148
- const makeTaggedTemplate = /* @__PURE__ */ __name((instance) => makeColorizeTemplate(makeTemplate(instance)), "makeTaggedTemplate");
149
- const template = makeTemplate(colorize);
150
- const template$1 = makeColorizeTemplate(template);
151
-
152
- export { template$1 as default, makeTaggedTemplate, template };
1
+ var y=Object.defineProperty;var i=(e,t)=>y(e,"name",{value:t,configurable:!0});import{S as x}from"./packem_shared/colorize.server-9hV-s1hY.mjs";import{convertHexToRgb as g}from"./packem_shared/convertHexToRgb-DGcGUKnj.mjs";var T=Object.defineProperty,j=i((e,t)=>T(e,"name",{value:t,configurable:!0}),"n");const d=j(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++)a.push(String(r[n-1]).replaceAll(/[{}\\]/g,String.raw`\$&`),String(t.raw[n]));return e(a.join(""))},"makeColorizeTemplate");var A=Object.defineProperty,k=i((e,t)=>A(e,"name",{value:t,configurable:!0}),"e");const S=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)):S.get(e)??e},"unescape");var $=Object.defineProperty,u=i((e,t)=>$(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=u((e,t)=>{const r=[],a=t.trim().split(/\s*,\s*/);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].replace(P,(f,l,p)=>l?b(l):p));else throw new Error(`Invalid template style argument: ${s} (in style '${e}')`)}return r},"parseArguments"),C=u(e=>{m.lastIndex=0;const t=[];let r;for(;(r=m.exec(e))!==null;){const a=r[1];r[2]?t.push([a,...O(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?null: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:C(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 ${r.length} closing bracket${r.length===1?"":"s"} (\`}\`)`);return a.join("")},"makeTemplate");var I=Object.defineProperty,z=i((e,t)=>I(e,"name",{value:t,configurable:!0}),"o");const R=new x,M=z(e=>d(w(e)),"makeTaggedTemplate"),W=w(R),U=d(W);export{U as default,M as makeTaggedTemplate,W as template};
package/dist/utils.cjs CHANGED
@@ -1,13 +1 @@
1
- 'use strict';
2
-
3
- Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
4
-
5
- const convertHexToRgb = require('./packem_shared/convertHexToRgb-DDy3Eccg.cjs');
6
- const rgbToAnsi256 = require('./packem_shared/rgbToAnsi256-Cakhu-n9.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-BEnfEytq.cjs"),e=require("./packem_shared/ansi256To16--f09kvlF.cjs");exports.convertHexToRgb=o.convertHexToRgb;exports.ansi256To16=e.ansi256To16;exports.rgbToAnsi16=e.rgbToAnsi16;exports.rgbToAnsi256=e.rgbToAnsi256;
package/dist/utils.mjs CHANGED
@@ -1,2 +1 @@
1
- export { convertHexToRgb } from './packem_shared/convertHexToRgb-DOIRmKxM.mjs';
2
- export { ansi256To16, rgbToAnsi16, rgbToAnsi256 } from './packem_shared/rgbToAnsi256-DcQVMIqi.mjs';
1
+ import{convertHexToRgb as e}from"./packem_shared/convertHexToRgb-DGcGUKnj.mjs";import{ansi256To16 as T,rgbToAnsi16 as b,rgbToAnsi256 as g}from"./packem_shared/ansi256To16-YETEPW8R.mjs";export{T as ansi256To16,e as convertHexToRgb,b as rgbToAnsi16,g as rgbToAnsi256};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visulima/colorize",
3
- "version": "1.4.23",
3
+ "version": "1.4.24",
4
4
  "description": "Terminal and Console string styling done right.",
5
5
  "keywords": [
6
6
  "256",
@@ -88,13 +88,13 @@
88
88
  "types": "./dist/index.browser.d.mts",
89
89
  "default": "./dist/index.browser.mjs"
90
90
  },
91
- "require": {
92
- "types": "./dist/index.server.d.cts",
93
- "default": "./dist/index.server.cjs"
94
- },
95
91
  "import": {
96
92
  "types": "./dist/index.server.d.mts",
97
93
  "default": "./dist/index.server.mjs"
94
+ },
95
+ "require": {
96
+ "types": "./dist/index.server.d.cts",
97
+ "default": "./dist/index.server.cjs"
98
98
  }
99
99
  },
100
100
  "./browser": {
@@ -104,33 +104,33 @@
104
104
  }
105
105
  },
106
106
  "./template": {
107
- "require": {
108
- "types": "./dist/template.d.cts",
109
- "default": "./dist/template.cjs"
110
- },
111
107
  "import": {
112
108
  "types": "./dist/template.d.mts",
113
109
  "default": "./dist/template.mjs"
110
+ },
111
+ "require": {
112
+ "types": "./dist/template.d.cts",
113
+ "default": "./dist/template.cjs"
114
114
  }
115
115
  },
116
116
  "./gradient": {
117
- "require": {
118
- "types": "./dist/gradient.d.cts",
119
- "default": "./dist/gradient.cjs"
120
- },
121
117
  "import": {
122
118
  "types": "./dist/gradient.d.mts",
123
119
  "default": "./dist/gradient.mjs"
120
+ },
121
+ "require": {
122
+ "types": "./dist/gradient.d.cts",
123
+ "default": "./dist/gradient.cjs"
124
124
  }
125
125
  },
126
126
  "./utils": {
127
- "require": {
128
- "types": "./dist/utils.d.cts",
129
- "default": "./dist/utils.cjs"
130
- },
131
127
  "import": {
132
128
  "types": "./dist/utils.d.mts",
133
129
  "default": "./dist/utils.mjs"
130
+ },
131
+ "require": {
132
+ "types": "./dist/utils.d.cts",
133
+ "default": "./dist/utils.cjs"
134
134
  }
135
135
  },
136
136
  "./package.json": "./package.json"
@@ -165,10 +165,10 @@
165
165
  "LICENSE.md"
166
166
  ],
167
167
  "dependencies": {
168
- "@visulima/is-ansi-color-supported": "2.2.14"
168
+ "@visulima/is-ansi-color-supported": "2.3.0"
169
169
  },
170
170
  "engines": {
171
- "node": ">=18.0.0 <=23.x"
171
+ "node": ">=18.0.0 <=24.x"
172
172
  },
173
173
  "os": [
174
174
  "darwin",
@@ -1,417 +0,0 @@
1
- const ansiCodeHexMap = {
2
- 0: "#000",
3
- 1: "#800",
4
- 2: "#080",
5
- 3: "#880",
6
- 4: "#008",
7
- 5: "#808",
8
- 6: "#088",
9
- 7: "#ccc",
10
- 8: "#444",
11
- 9: "#f00",
12
- 10: "#0f0",
13
- 11: "#ff0",
14
- 12: "#00f",
15
- 13: "#f0f",
16
- 14: "#0ff",
17
- 15: "#fff",
18
- 16: "#000",
19
- 17: "#00005f",
20
- 18: "#000087",
21
- 19: "#0000af",
22
- 20: "#0000d7",
23
- 21: "#0000ff",
24
- 22: "#005f00",
25
- 23: "#005f5f",
26
- 24: "#005f87",
27
- 25: "#005faf",
28
- 26: "#005fd7",
29
- 27: "#005fff",
30
- 28: "#008700",
31
- 29: "#00875f",
32
- 30: "#008787",
33
- 31: "#0087af",
34
- 32: "#0087d7",
35
- 33: "#0087ff",
36
- 34: "#00af00",
37
- 35: "#00af5f",
38
- 36: "#00af87",
39
- 37: "#00afaf",
40
- 38: "#00afd7",
41
- 39: "#00afff",
42
- 40: "#00d700",
43
- 41: "#00d75f",
44
- 42: "#00d787",
45
- 43: "#00d7af",
46
- 44: "#00d7d7",
47
- 45: "#00d7ff",
48
- 46: "#00ff00",
49
- 47: "#00ff5f",
50
- 48: "#00ff87",
51
- 49: "#00ffaf",
52
- 50: "#00ffd7",
53
- 51: "#00ffff",
54
- 52: "#5f0000",
55
- 53: "#5f005f",
56
- 54: "#5f0087",
57
- 55: "#5f00af",
58
- 56: "#5f00d7",
59
- 57: "#5f00ff",
60
- 58: "#5f5f00",
61
- 59: "#5f5f5f",
62
- 60: "#5f5f87",
63
- 61: "#5f5faf",
64
- 62: "#5f5fd7",
65
- 63: "#5f5fff",
66
- 64: "#5f8700",
67
- 65: "#5f875f",
68
- 66: "#5f8787",
69
- 67: "#5f87af",
70
- 68: "#5f87d7",
71
- 69: "#5f87ff",
72
- 70: "#5faf00",
73
- 71: "#5faf5f",
74
- 72: "#5faf87",
75
- 73: "#5fafaf",
76
- 74: "#5fafd7",
77
- 75: "#5fafff",
78
- 76: "#5fd700",
79
- 77: "#5fd75f",
80
- 78: "#5fd787",
81
- 79: "#5fd7af",
82
- 80: "#5fd7d7",
83
- 81: "#5fd7ff",
84
- 82: "#5fff00",
85
- 83: "#5fff5f",
86
- 84: "#5fff87",
87
- 85: "#5fffaf",
88
- 86: "#5fffd7",
89
- 87: "#5fffff",
90
- 88: "#870000",
91
- 89: "#87005f",
92
- 90: "#870087",
93
- 91: "#8700af",
94
- 92: "#8700d7",
95
- 93: "#8700ff",
96
- 94: "#875f00",
97
- 95: "#875f5f",
98
- 96: "#875f87",
99
- 97: "#875faf",
100
- 98: "#875fd7",
101
- 99: "#875fff",
102
- 100: "#878700",
103
- 101: "#87875f",
104
- 102: "#878787",
105
- 103: "#8787af",
106
- 104: "#8787d7",
107
- 105: "#8787ff",
108
- 106: "#87af00",
109
- 107: "#87af5f",
110
- 108: "#87af87",
111
- 109: "#87afaf",
112
- 110: "#87afd7",
113
- 111: "#87afff",
114
- 112: "#87d700",
115
- 113: "#87d75f",
116
- 114: "#87d787",
117
- 115: "#87d7af",
118
- 116: "#87d7d7",
119
- 117: "#87d7ff",
120
- 118: "#87ff00",
121
- 119: "#87ff5f",
122
- 120: "#87ff87",
123
- 121: "#87ffaf",
124
- 122: "#87ffd7",
125
- 123: "#87ffff",
126
- 124: "#af0000",
127
- 125: "#af005f",
128
- 126: "#af0087",
129
- 127: "#af00af",
130
- 128: "#af00d7",
131
- 129: "#af00ff",
132
- 130: "#af5f00",
133
- 131: "#af5f5f",
134
- 132: "#af5f87",
135
- 133: "#af5faf",
136
- 134: "#af5fd7",
137
- 135: "#af5fff",
138
- 136: "#af8700",
139
- 137: "#af875f",
140
- 138: "#af8787",
141
- 139: "#af87af",
142
- 140: "#af87d7",
143
- 141: "#af87ff",
144
- 142: "#afaf00",
145
- 143: "#afaf5f",
146
- 144: "#afaf87",
147
- 145: "#afafaf",
148
- 146: "#afafd7",
149
- 147: "#afafff",
150
- 148: "#afd700",
151
- 149: "#afd75f",
152
- 150: "#afd787",
153
- 151: "#afd7af",
154
- 152: "#afd7d7",
155
- 153: "#afd7ff",
156
- 154: "#afff00",
157
- 155: "#afff5f",
158
- 156: "#afff87",
159
- 157: "#afffaf",
160
- 158: "#afffd7",
161
- 159: "#afffff",
162
- 160: "#d70000",
163
- 161: "#d7005f",
164
- 162: "#d70087",
165
- 163: "#d700af",
166
- 164: "#d700d7",
167
- 165: "#d700ff",
168
- 166: "#d75f00",
169
- 167: "#d75f5f",
170
- 168: "#d75f87",
171
- 169: "#d75faf",
172
- 170: "#d75fd7",
173
- 171: "#d75fff",
174
- 172: "#d78700",
175
- 173: "#d7875f",
176
- 174: "#d78787",
177
- 175: "#d787af",
178
- 176: "#d787d7",
179
- 177: "#d787ff",
180
- 178: "#d7af00",
181
- 179: "#d7af5f",
182
- 180: "#d7af87",
183
- 181: "#d7afaf",
184
- 182: "#d7afd7",
185
- 183: "#d7afff",
186
- 184: "#d7d700",
187
- 185: "#d7d75f",
188
- 186: "#d7d787",
189
- 187: "#d7d7af",
190
- 188: "#d7d7d7",
191
- 189: "#d7d7ff",
192
- 190: "#d7ff00",
193
- 191: "#d7ff5f",
194
- 192: "#d7ff87",
195
- 193: "#d7ffaf",
196
- 194: "#d7ffd7",
197
- 195: "#d7ffff",
198
- 196: "#ff0000",
199
- 197: "#ff005f",
200
- 198: "#ff0087",
201
- 199: "#ff00af",
202
- 200: "#ff00d7",
203
- 201: "#ff00ff",
204
- 202: "#ff5f00",
205
- 203: "#ff5f5f",
206
- 204: "#ff5f87",
207
- 205: "#ff5faf",
208
- 206: "#ff5fd7",
209
- 207: "#ff5fff",
210
- 208: "#ff8700",
211
- 209: "#ff875f",
212
- 210: "#ff8787",
213
- 211: "#ff87af",
214
- 212: "#ff87d7",
215
- 213: "#ff87ff",
216
- 214: "#ffaf00",
217
- 215: "#ffaf5f",
218
- 216: "#ffaf87",
219
- 217: "#ffafaf",
220
- 218: "#ffafd7",
221
- 219: "#ffafff",
222
- 220: "#ffd700",
223
- 221: "#ffd75f",
224
- 222: "#ffd787",
225
- 223: "#ffd7af",
226
- 224: "#ffd7d7",
227
- 225: "#ffd7ff",
228
- 226: "#ffff00",
229
- 227: "#ffff5f",
230
- 228: "#ffff87",
231
- 229: "#ffffaf",
232
- 230: "#ffffd7",
233
- 231: "#ffffff",
234
- 232: "#080808",
235
- 233: "#121212",
236
- 234: "#1c1c1c",
237
- 235: "#262626",
238
- 236: "#303030",
239
- 237: "#3a3a3a",
240
- 238: "#444444",
241
- 239: "#4e4e4e",
242
- 240: "#585858",
243
- 241: "#626262",
244
- 242: "#6c6c6c",
245
- 243: "#767676",
246
- 244: "#808080",
247
- 245: "#8a8a8a",
248
- 246: "#949494",
249
- 247: "#9e9e9e",
250
- 248: "#a8a8a8",
251
- 249: "#b2b2b2",
252
- 250: "#bcbcbc",
253
- 251: "#c6c6c6",
254
- 252: "#d0d0d0",
255
- 253: "#dadada",
256
- 254: "#e4e4e4",
257
- 255: "#eeeeee"
258
- };
259
-
260
- var __defProp$1 = Object.defineProperty;
261
- var __name$1 = (target, value) => __defProp$1(target, "name", { value, configurable: true });
262
- const baseStyles = {
263
- bold: "font-weight: bold;",
264
- dim: "opacity: 0.5;",
265
- hidden: "visibility: hidden;",
266
- inverse: "background-color: currentColor; color: background-color;",
267
- italic: "font-style: italic;",
268
- overline: "text-decoration: overline;",
269
- reset: "color: inherit",
270
- strike: "text-decoration: line-through;",
271
- strikethrough: "text-decoration: line-through;",
272
- underline: "text-decoration: underline;",
273
- visible: "opacity: 0;"
274
- };
275
- const baseColors = {
276
- bgBlack: "background-color: black; color: white;",
277
- bgBlackBright: "background-color: #666; color: white;",
278
- bgBlue: "background-color: blue; color: white;",
279
- bgBlueBright: "background-color: #55f; color: white;",
280
- bgCyan: "background-color: cyan; color: black;",
281
- bgCyanBright: "background-color: #5ff; color: black;",
282
- bgGray: "background-color: #666; color: white;",
283
- // US spelling alias for bgBlackBright
284
- bgGreen: "background-color: green; color: white;",
285
- bgGreenBright: "background-color: #5f5; color: white;",
286
- bgGrey: "background-color: #666; color: white;",
287
- // UK spelling alias for bgBlackBright
288
- bgMagenta: "background-color: magenta; color: white;",
289
- bgMagentaBright: "background-color: #f5f; color: white;",
290
- bgRed: "background-color: red; color: white;",
291
- bgRedBright: "background-color: #f55; color: white;",
292
- bgWhite: "background-color: white; color: black;",
293
- bgWhiteBright: "background-color: #eee; color: black;",
294
- bgYellow: "background-color: yellow; color: black;",
295
- bgYellowBright: "background-color: #ff5; color: black;",
296
- black: "color: black;",
297
- blackBright: "color: #666;",
298
- blue: "color: blue;",
299
- blueBright: "color: #55f;",
300
- cyan: "color: cyan;",
301
- cyanBright: "color: #5ff;",
302
- gray: "color: #666;",
303
- // US spelling alias for blackBright
304
- green: "color: green;",
305
- greenBright: "color: #5f5;",
306
- grey: "color: #666;",
307
- // UK spelling alias for blackBright
308
- magenta: "color: magenta;",
309
- magentaBright: "color: #f5f;",
310
- red: "color: red;",
311
- redBright: "color: #f55;",
312
- white: "color: white;",
313
- whiteBright: "color: #eee;",
314
- yellow: "color: yellow;",
315
- yellowBright: "color: #ff5;"
316
- };
317
- const styleMethods = {
318
- // eslint-disable-next-line security/detect-object-injection
319
- bg: /* @__PURE__ */ __name$1((code) => "background-color: " + ansiCodeHexMap[code] + ";", "bg"),
320
- bgHex: /* @__PURE__ */ __name$1((hex) => "background-color: " + hex + ";", "bgHex"),
321
- bgRgb: /* @__PURE__ */ __name$1((r, g, b) => "background-color: rgb(" + r + "," + g + "," + b + ");", "bgRgb"),
322
- // eslint-disable-next-line security/detect-object-injection
323
- fg: /* @__PURE__ */ __name$1((code) => "color: " + ansiCodeHexMap[code] + ";", "fg"),
324
- hex: /* @__PURE__ */ __name$1((hex) => "color:" + hex + ";", "hex"),
325
- rgb: /* @__PURE__ */ __name$1((r, g, b) => "color: rgb(" + r + "," + g + "," + b + ");", "rgb")
326
- };
327
-
328
- var __defProp = Object.defineProperty;
329
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
330
- const styles = {};
331
- let stylePrototype = null;
332
- const cssStringToObject = /* @__PURE__ */ __name((css) => {
333
- const cssObject = {};
334
- css.replace(/(?<=^|;)\s*([^:]+)\s*:\s*([^;]+)\s*/g, (_, key, value) => {
335
- cssObject[key] = value;
336
- return value;
337
- });
338
- return cssObject;
339
- }, "cssStringToObject");
340
- const createStyle = /* @__PURE__ */ __name(({ props }, css) => {
341
- let cssStack = css;
342
- if (props?.cssStack) {
343
- const cssObject = cssStringToObject(css);
344
- const propertiesCssObject = cssStringToObject(props.cssStack);
345
- for (const key in propertiesCssObject) {
346
- if (cssObject[key] === void 0) {
347
- cssObject[key] = propertiesCssObject[key];
348
- }
349
- }
350
- cssStack = JSON.stringify(cssObject).replace(/["{}]/g, "").replace(/,/g, ";") + ";";
351
- }
352
- const style = /* @__PURE__ */ __name((input, ...values) => {
353
- if (!input) {
354
- return [];
355
- }
356
- if (typeof input === "string" && input.includes("%c")) {
357
- const collectedStyles = input.match(/(?<=,).*;/g);
358
- const inputWithoutStyles = input.replace(/,.*;/g, "");
359
- return ["%c" + inputWithoutStyles, style.css, ...collectedStyles ?? []];
360
- }
361
- if (typeof input === "number" || typeof input === "string") {
362
- return ["%c" + input, style.css];
363
- }
364
- if (input.raw !== null && Array.isArray(values) && values.length > 0) {
365
- const rawString = String.raw(input, ...values);
366
- const collectedStyles = rawString.match(/(?<=,).*;/g);
367
- const inputWithoutStyles = rawString.replace(/,.*;/g, "");
368
- return ["%c" + inputWithoutStyles, style.css, ...(collectedStyles ?? []).join("").split(",").filter(Boolean)];
369
- }
370
- const [first, ...rest] = input;
371
- rest.unshift(style.css);
372
- return [((first + "").includes("%c") ? "" : "%c") + (first + ""), rest.join("")];
373
- }, "style");
374
- Object.setPrototypeOf(style, stylePrototype);
375
- style.props = { css, cssStack, props };
376
- style.css = cssStack;
377
- return style;
378
- }, "createStyle");
379
- const WebColorize = /* @__PURE__ */ __name(function() {
380
- const self = /* @__PURE__ */ __name((string_) => string_ + "", "self");
381
- self.strip = (value) => value;
382
- for (const name in baseColors) {
383
- styles[name] = {
384
- get() {
385
- const style = createStyle(this, baseColors[name]);
386
- Object.defineProperty(this, name, { value: style });
387
- return style;
388
- }
389
- };
390
- }
391
- for (const name in baseStyles) {
392
- styles[name] = {
393
- get() {
394
- const style = createStyle(this, baseStyles[name]);
395
- Object.defineProperty(this, name, { value: style });
396
- return style;
397
- }
398
- };
399
- }
400
- stylePrototype = Object.defineProperties({}, styles);
401
- Object.setPrototypeOf(self, stylePrototype);
402
- return self;
403
- }, "WebColorize");
404
- for (const name in styleMethods) {
405
- styles[name] = {
406
- get() {
407
- return (...arguments_) => (
408
- // @ts-expect-error: TODO: fix typing of `arguments_`
409
- createStyle(this, styleMethods[name](...arguments_))
410
- );
411
- }
412
- };
413
- }
414
- styles.ansi256 = styles.fg;
415
- styles.bgAnsi256 = styles.bg;
416
-
417
- export { WebColorize as default };