@reteps/tree-sitter-htmlmustache 0.3.0 → 0.4.0
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/cli/out/main.js +529 -1539
- package/package.json +10 -10
- package/tree-sitter.json +1 -1
package/cli/out/main.js
CHANGED
|
@@ -6,9 +6,6 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
6
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
7
|
var __getProtoOf = Object.getPrototypeOf;
|
|
8
8
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
-
var __commonJS = (cb, mod) => function __require() {
|
|
10
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
11
|
-
};
|
|
12
9
|
var __copyProps = (to, from, except, desc) => {
|
|
13
10
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
11
|
for (let key of __getOwnPropNames(from))
|
|
@@ -26,1560 +23,504 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
23
|
mod
|
|
27
24
|
));
|
|
28
25
|
|
|
29
|
-
// node_modules/
|
|
30
|
-
var
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
"hotpink": [255, 105, 180],
|
|
93
|
-
"indianred": [205, 92, 92],
|
|
94
|
-
"indigo": [75, 0, 130],
|
|
95
|
-
"ivory": [255, 255, 240],
|
|
96
|
-
"khaki": [240, 230, 140],
|
|
97
|
-
"lavender": [230, 230, 250],
|
|
98
|
-
"lavenderblush": [255, 240, 245],
|
|
99
|
-
"lawngreen": [124, 252, 0],
|
|
100
|
-
"lemonchiffon": [255, 250, 205],
|
|
101
|
-
"lightblue": [173, 216, 230],
|
|
102
|
-
"lightcoral": [240, 128, 128],
|
|
103
|
-
"lightcyan": [224, 255, 255],
|
|
104
|
-
"lightgoldenrodyellow": [250, 250, 210],
|
|
105
|
-
"lightgray": [211, 211, 211],
|
|
106
|
-
"lightgreen": [144, 238, 144],
|
|
107
|
-
"lightgrey": [211, 211, 211],
|
|
108
|
-
"lightpink": [255, 182, 193],
|
|
109
|
-
"lightsalmon": [255, 160, 122],
|
|
110
|
-
"lightseagreen": [32, 178, 170],
|
|
111
|
-
"lightskyblue": [135, 206, 250],
|
|
112
|
-
"lightslategray": [119, 136, 153],
|
|
113
|
-
"lightslategrey": [119, 136, 153],
|
|
114
|
-
"lightsteelblue": [176, 196, 222],
|
|
115
|
-
"lightyellow": [255, 255, 224],
|
|
116
|
-
"lime": [0, 255, 0],
|
|
117
|
-
"limegreen": [50, 205, 50],
|
|
118
|
-
"linen": [250, 240, 230],
|
|
119
|
-
"magenta": [255, 0, 255],
|
|
120
|
-
"maroon": [128, 0, 0],
|
|
121
|
-
"mediumaquamarine": [102, 205, 170],
|
|
122
|
-
"mediumblue": [0, 0, 205],
|
|
123
|
-
"mediumorchid": [186, 85, 211],
|
|
124
|
-
"mediumpurple": [147, 112, 219],
|
|
125
|
-
"mediumseagreen": [60, 179, 113],
|
|
126
|
-
"mediumslateblue": [123, 104, 238],
|
|
127
|
-
"mediumspringgreen": [0, 250, 154],
|
|
128
|
-
"mediumturquoise": [72, 209, 204],
|
|
129
|
-
"mediumvioletred": [199, 21, 133],
|
|
130
|
-
"midnightblue": [25, 25, 112],
|
|
131
|
-
"mintcream": [245, 255, 250],
|
|
132
|
-
"mistyrose": [255, 228, 225],
|
|
133
|
-
"moccasin": [255, 228, 181],
|
|
134
|
-
"navajowhite": [255, 222, 173],
|
|
135
|
-
"navy": [0, 0, 128],
|
|
136
|
-
"oldlace": [253, 245, 230],
|
|
137
|
-
"olive": [128, 128, 0],
|
|
138
|
-
"olivedrab": [107, 142, 35],
|
|
139
|
-
"orange": [255, 165, 0],
|
|
140
|
-
"orangered": [255, 69, 0],
|
|
141
|
-
"orchid": [218, 112, 214],
|
|
142
|
-
"palegoldenrod": [238, 232, 170],
|
|
143
|
-
"palegreen": [152, 251, 152],
|
|
144
|
-
"paleturquoise": [175, 238, 238],
|
|
145
|
-
"palevioletred": [219, 112, 147],
|
|
146
|
-
"papayawhip": [255, 239, 213],
|
|
147
|
-
"peachpuff": [255, 218, 185],
|
|
148
|
-
"peru": [205, 133, 63],
|
|
149
|
-
"pink": [255, 192, 203],
|
|
150
|
-
"plum": [221, 160, 221],
|
|
151
|
-
"powderblue": [176, 224, 230],
|
|
152
|
-
"purple": [128, 0, 128],
|
|
153
|
-
"rebeccapurple": [102, 51, 153],
|
|
154
|
-
"red": [255, 0, 0],
|
|
155
|
-
"rosybrown": [188, 143, 143],
|
|
156
|
-
"royalblue": [65, 105, 225],
|
|
157
|
-
"saddlebrown": [139, 69, 19],
|
|
158
|
-
"salmon": [250, 128, 114],
|
|
159
|
-
"sandybrown": [244, 164, 96],
|
|
160
|
-
"seagreen": [46, 139, 87],
|
|
161
|
-
"seashell": [255, 245, 238],
|
|
162
|
-
"sienna": [160, 82, 45],
|
|
163
|
-
"silver": [192, 192, 192],
|
|
164
|
-
"skyblue": [135, 206, 235],
|
|
165
|
-
"slateblue": [106, 90, 205],
|
|
166
|
-
"slategray": [112, 128, 144],
|
|
167
|
-
"slategrey": [112, 128, 144],
|
|
168
|
-
"snow": [255, 250, 250],
|
|
169
|
-
"springgreen": [0, 255, 127],
|
|
170
|
-
"steelblue": [70, 130, 180],
|
|
171
|
-
"tan": [210, 180, 140],
|
|
172
|
-
"teal": [0, 128, 128],
|
|
173
|
-
"thistle": [216, 191, 216],
|
|
174
|
-
"tomato": [255, 99, 71],
|
|
175
|
-
"turquoise": [64, 224, 208],
|
|
176
|
-
"violet": [238, 130, 238],
|
|
177
|
-
"wheat": [245, 222, 179],
|
|
178
|
-
"white": [255, 255, 255],
|
|
179
|
-
"whitesmoke": [245, 245, 245],
|
|
180
|
-
"yellow": [255, 255, 0],
|
|
181
|
-
"yellowgreen": [154, 205, 50]
|
|
182
|
-
};
|
|
26
|
+
// node_modules/chalk/source/vendor/ansi-styles/index.js
|
|
27
|
+
var ANSI_BACKGROUND_OFFSET = 10;
|
|
28
|
+
var wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
|
|
29
|
+
var wrapAnsi256 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`;
|
|
30
|
+
var wrapAnsi16m = (offset = 0) => (red, green, blue) => `\x1B[${38 + offset};2;${red};${green};${blue}m`;
|
|
31
|
+
var styles = {
|
|
32
|
+
modifier: {
|
|
33
|
+
reset: [0, 0],
|
|
34
|
+
// 21 isn't widely supported and 22 does the same thing
|
|
35
|
+
bold: [1, 22],
|
|
36
|
+
dim: [2, 22],
|
|
37
|
+
italic: [3, 23],
|
|
38
|
+
underline: [4, 24],
|
|
39
|
+
overline: [53, 55],
|
|
40
|
+
inverse: [7, 27],
|
|
41
|
+
hidden: [8, 28],
|
|
42
|
+
strikethrough: [9, 29]
|
|
43
|
+
},
|
|
44
|
+
color: {
|
|
45
|
+
black: [30, 39],
|
|
46
|
+
red: [31, 39],
|
|
47
|
+
green: [32, 39],
|
|
48
|
+
yellow: [33, 39],
|
|
49
|
+
blue: [34, 39],
|
|
50
|
+
magenta: [35, 39],
|
|
51
|
+
cyan: [36, 39],
|
|
52
|
+
white: [37, 39],
|
|
53
|
+
// Bright color
|
|
54
|
+
blackBright: [90, 39],
|
|
55
|
+
gray: [90, 39],
|
|
56
|
+
// Alias of `blackBright`
|
|
57
|
+
grey: [90, 39],
|
|
58
|
+
// Alias of `blackBright`
|
|
59
|
+
redBright: [91, 39],
|
|
60
|
+
greenBright: [92, 39],
|
|
61
|
+
yellowBright: [93, 39],
|
|
62
|
+
blueBright: [94, 39],
|
|
63
|
+
magentaBright: [95, 39],
|
|
64
|
+
cyanBright: [96, 39],
|
|
65
|
+
whiteBright: [97, 39]
|
|
66
|
+
},
|
|
67
|
+
bgColor: {
|
|
68
|
+
bgBlack: [40, 49],
|
|
69
|
+
bgRed: [41, 49],
|
|
70
|
+
bgGreen: [42, 49],
|
|
71
|
+
bgYellow: [43, 49],
|
|
72
|
+
bgBlue: [44, 49],
|
|
73
|
+
bgMagenta: [45, 49],
|
|
74
|
+
bgCyan: [46, 49],
|
|
75
|
+
bgWhite: [47, 49],
|
|
76
|
+
// Bright color
|
|
77
|
+
bgBlackBright: [100, 49],
|
|
78
|
+
bgGray: [100, 49],
|
|
79
|
+
// Alias of `bgBlackBright`
|
|
80
|
+
bgGrey: [100, 49],
|
|
81
|
+
// Alias of `bgBlackBright`
|
|
82
|
+
bgRedBright: [101, 49],
|
|
83
|
+
bgGreenBright: [102, 49],
|
|
84
|
+
bgYellowBright: [103, 49],
|
|
85
|
+
bgBlueBright: [104, 49],
|
|
86
|
+
bgMagentaBright: [105, 49],
|
|
87
|
+
bgCyanBright: [106, 49],
|
|
88
|
+
bgWhiteBright: [107, 49]
|
|
183
89
|
}
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
var
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
hsl: { channels: 3, labels: "hsl" },
|
|
197
|
-
hsv: { channels: 3, labels: "hsv" },
|
|
198
|
-
hwb: { channels: 3, labels: "hwb" },
|
|
199
|
-
cmyk: { channels: 4, labels: "cmyk" },
|
|
200
|
-
xyz: { channels: 3, labels: "xyz" },
|
|
201
|
-
lab: { channels: 3, labels: "lab" },
|
|
202
|
-
lch: { channels: 3, labels: "lch" },
|
|
203
|
-
hex: { channels: 1, labels: ["hex"] },
|
|
204
|
-
keyword: { channels: 1, labels: ["keyword"] },
|
|
205
|
-
ansi16: { channels: 1, labels: ["ansi16"] },
|
|
206
|
-
ansi256: { channels: 1, labels: ["ansi256"] },
|
|
207
|
-
hcg: { channels: 3, labels: ["h", "c", "g"] },
|
|
208
|
-
apple: { channels: 3, labels: ["r16", "g16", "b16"] },
|
|
209
|
-
gray: { channels: 1, labels: ["gray"] }
|
|
210
|
-
};
|
|
211
|
-
module2.exports = convert;
|
|
212
|
-
for (const model of Object.keys(convert)) {
|
|
213
|
-
if (!("channels" in convert[model])) {
|
|
214
|
-
throw new Error("missing channels property: " + model);
|
|
215
|
-
}
|
|
216
|
-
if (!("labels" in convert[model])) {
|
|
217
|
-
throw new Error("missing channel labels property: " + model);
|
|
218
|
-
}
|
|
219
|
-
if (convert[model].labels.length !== convert[model].channels) {
|
|
220
|
-
throw new Error("channel and label counts mismatch: " + model);
|
|
221
|
-
}
|
|
222
|
-
const { channels, labels } = convert[model];
|
|
223
|
-
delete convert[model].channels;
|
|
224
|
-
delete convert[model].labels;
|
|
225
|
-
Object.defineProperty(convert[model], "channels", { value: channels });
|
|
226
|
-
Object.defineProperty(convert[model], "labels", { value: labels });
|
|
227
|
-
}
|
|
228
|
-
convert.rgb.hsl = function(rgb) {
|
|
229
|
-
const r = rgb[0] / 255;
|
|
230
|
-
const g = rgb[1] / 255;
|
|
231
|
-
const b = rgb[2] / 255;
|
|
232
|
-
const min = Math.min(r, g, b);
|
|
233
|
-
const max = Math.max(r, g, b);
|
|
234
|
-
const delta = max - min;
|
|
235
|
-
let h;
|
|
236
|
-
let s;
|
|
237
|
-
if (max === min) {
|
|
238
|
-
h = 0;
|
|
239
|
-
} else if (r === max) {
|
|
240
|
-
h = (g - b) / delta;
|
|
241
|
-
} else if (g === max) {
|
|
242
|
-
h = 2 + (b - r) / delta;
|
|
243
|
-
} else if (b === max) {
|
|
244
|
-
h = 4 + (r - g) / delta;
|
|
245
|
-
}
|
|
246
|
-
h = Math.min(h * 60, 360);
|
|
247
|
-
if (h < 0) {
|
|
248
|
-
h += 360;
|
|
249
|
-
}
|
|
250
|
-
const l = (min + max) / 2;
|
|
251
|
-
if (max === min) {
|
|
252
|
-
s = 0;
|
|
253
|
-
} else if (l <= 0.5) {
|
|
254
|
-
s = delta / (max + min);
|
|
255
|
-
} else {
|
|
256
|
-
s = delta / (2 - max - min);
|
|
257
|
-
}
|
|
258
|
-
return [h, s * 100, l * 100];
|
|
259
|
-
};
|
|
260
|
-
convert.rgb.hsv = function(rgb) {
|
|
261
|
-
let rdif;
|
|
262
|
-
let gdif;
|
|
263
|
-
let bdif;
|
|
264
|
-
let h;
|
|
265
|
-
let s;
|
|
266
|
-
const r = rgb[0] / 255;
|
|
267
|
-
const g = rgb[1] / 255;
|
|
268
|
-
const b = rgb[2] / 255;
|
|
269
|
-
const v = Math.max(r, g, b);
|
|
270
|
-
const diff = v - Math.min(r, g, b);
|
|
271
|
-
const diffc = function(c) {
|
|
272
|
-
return (v - c) / 6 / diff + 1 / 2;
|
|
90
|
+
};
|
|
91
|
+
var modifierNames = Object.keys(styles.modifier);
|
|
92
|
+
var foregroundColorNames = Object.keys(styles.color);
|
|
93
|
+
var backgroundColorNames = Object.keys(styles.bgColor);
|
|
94
|
+
var colorNames = [...foregroundColorNames, ...backgroundColorNames];
|
|
95
|
+
function assembleStyles() {
|
|
96
|
+
const codes = /* @__PURE__ */ new Map();
|
|
97
|
+
for (const [groupName, group2] of Object.entries(styles)) {
|
|
98
|
+
for (const [styleName, style] of Object.entries(group2)) {
|
|
99
|
+
styles[styleName] = {
|
|
100
|
+
open: `\x1B[${style[0]}m`,
|
|
101
|
+
close: `\x1B[${style[1]}m`
|
|
273
102
|
};
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
s = 0;
|
|
277
|
-
} else {
|
|
278
|
-
s = diff / v;
|
|
279
|
-
rdif = diffc(r);
|
|
280
|
-
gdif = diffc(g);
|
|
281
|
-
bdif = diffc(b);
|
|
282
|
-
if (r === v) {
|
|
283
|
-
h = bdif - gdif;
|
|
284
|
-
} else if (g === v) {
|
|
285
|
-
h = 1 / 3 + rdif - bdif;
|
|
286
|
-
} else if (b === v) {
|
|
287
|
-
h = 2 / 3 + gdif - rdif;
|
|
288
|
-
}
|
|
289
|
-
if (h < 0) {
|
|
290
|
-
h += 1;
|
|
291
|
-
} else if (h > 1) {
|
|
292
|
-
h -= 1;
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
return [
|
|
296
|
-
h * 360,
|
|
297
|
-
s * 100,
|
|
298
|
-
v * 100
|
|
299
|
-
];
|
|
300
|
-
};
|
|
301
|
-
convert.rgb.hwb = function(rgb) {
|
|
302
|
-
const r = rgb[0];
|
|
303
|
-
const g = rgb[1];
|
|
304
|
-
let b = rgb[2];
|
|
305
|
-
const h = convert.rgb.hsl(rgb)[0];
|
|
306
|
-
const w = 1 / 255 * Math.min(r, Math.min(g, b));
|
|
307
|
-
b = 1 - 1 / 255 * Math.max(r, Math.max(g, b));
|
|
308
|
-
return [h, w * 100, b * 100];
|
|
309
|
-
};
|
|
310
|
-
convert.rgb.cmyk = function(rgb) {
|
|
311
|
-
const r = rgb[0] / 255;
|
|
312
|
-
const g = rgb[1] / 255;
|
|
313
|
-
const b = rgb[2] / 255;
|
|
314
|
-
const k = Math.min(1 - r, 1 - g, 1 - b);
|
|
315
|
-
const c = (1 - r - k) / (1 - k) || 0;
|
|
316
|
-
const m = (1 - g - k) / (1 - k) || 0;
|
|
317
|
-
const y = (1 - b - k) / (1 - k) || 0;
|
|
318
|
-
return [c * 100, m * 100, y * 100, k * 100];
|
|
319
|
-
};
|
|
320
|
-
function comparativeDistance(x, y) {
|
|
321
|
-
return (x[0] - y[0]) ** 2 + (x[1] - y[1]) ** 2 + (x[2] - y[2]) ** 2;
|
|
103
|
+
group2[styleName] = styles[styleName];
|
|
104
|
+
codes.set(style[0], style[1]);
|
|
322
105
|
}
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
}
|
|
397
|
-
if (6 * t3 < 1) {
|
|
398
|
-
val = t1 + (t2 - t1) * 6 * t3;
|
|
399
|
-
} else if (2 * t3 < 1) {
|
|
400
|
-
val = t2;
|
|
401
|
-
} else if (3 * t3 < 2) {
|
|
402
|
-
val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
|
|
106
|
+
Object.defineProperty(styles, groupName, {
|
|
107
|
+
value: group2,
|
|
108
|
+
enumerable: false
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
Object.defineProperty(styles, "codes", {
|
|
112
|
+
value: codes,
|
|
113
|
+
enumerable: false
|
|
114
|
+
});
|
|
115
|
+
styles.color.close = "\x1B[39m";
|
|
116
|
+
styles.bgColor.close = "\x1B[49m";
|
|
117
|
+
styles.color.ansi = wrapAnsi16();
|
|
118
|
+
styles.color.ansi256 = wrapAnsi256();
|
|
119
|
+
styles.color.ansi16m = wrapAnsi16m();
|
|
120
|
+
styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
|
|
121
|
+
styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
|
|
122
|
+
styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
|
|
123
|
+
Object.defineProperties(styles, {
|
|
124
|
+
rgbToAnsi256: {
|
|
125
|
+
value(red, green, blue) {
|
|
126
|
+
if (red === green && green === blue) {
|
|
127
|
+
if (red < 8) {
|
|
128
|
+
return 16;
|
|
129
|
+
}
|
|
130
|
+
if (red > 248) {
|
|
131
|
+
return 231;
|
|
132
|
+
}
|
|
133
|
+
return Math.round((red - 8) / 247 * 24) + 232;
|
|
134
|
+
}
|
|
135
|
+
return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5);
|
|
136
|
+
},
|
|
137
|
+
enumerable: false
|
|
138
|
+
},
|
|
139
|
+
hexToRgb: {
|
|
140
|
+
value(hex) {
|
|
141
|
+
const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));
|
|
142
|
+
if (!matches) {
|
|
143
|
+
return [0, 0, 0];
|
|
144
|
+
}
|
|
145
|
+
let [colorString] = matches;
|
|
146
|
+
if (colorString.length === 3) {
|
|
147
|
+
colorString = [...colorString].map((character) => character + character).join("");
|
|
148
|
+
}
|
|
149
|
+
const integer = Number.parseInt(colorString, 16);
|
|
150
|
+
return [
|
|
151
|
+
/* eslint-disable no-bitwise */
|
|
152
|
+
integer >> 16 & 255,
|
|
153
|
+
integer >> 8 & 255,
|
|
154
|
+
integer & 255
|
|
155
|
+
/* eslint-enable no-bitwise */
|
|
156
|
+
];
|
|
157
|
+
},
|
|
158
|
+
enumerable: false
|
|
159
|
+
},
|
|
160
|
+
hexToAnsi256: {
|
|
161
|
+
value: (hex) => styles.rgbToAnsi256(...styles.hexToRgb(hex)),
|
|
162
|
+
enumerable: false
|
|
163
|
+
},
|
|
164
|
+
ansi256ToAnsi: {
|
|
165
|
+
value(code) {
|
|
166
|
+
if (code < 8) {
|
|
167
|
+
return 30 + code;
|
|
168
|
+
}
|
|
169
|
+
if (code < 16) {
|
|
170
|
+
return 90 + (code - 8);
|
|
171
|
+
}
|
|
172
|
+
let red;
|
|
173
|
+
let green;
|
|
174
|
+
let blue;
|
|
175
|
+
if (code >= 232) {
|
|
176
|
+
red = ((code - 232) * 10 + 8) / 255;
|
|
177
|
+
green = red;
|
|
178
|
+
blue = red;
|
|
403
179
|
} else {
|
|
404
|
-
|
|
180
|
+
code -= 16;
|
|
181
|
+
const remainder = code % 36;
|
|
182
|
+
red = Math.floor(code / 36) / 5;
|
|
183
|
+
green = Math.floor(remainder / 6) / 5;
|
|
184
|
+
blue = remainder % 6 / 5;
|
|
405
185
|
}
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
};
|
|
410
|
-
convert.hsl.hsv = function(hsl) {
|
|
411
|
-
const h = hsl[0];
|
|
412
|
-
let s = hsl[1] / 100;
|
|
413
|
-
let l = hsl[2] / 100;
|
|
414
|
-
let smin = s;
|
|
415
|
-
const lmin = Math.max(l, 0.01);
|
|
416
|
-
l *= 2;
|
|
417
|
-
s *= l <= 1 ? l : 2 - l;
|
|
418
|
-
smin *= lmin <= 1 ? lmin : 2 - lmin;
|
|
419
|
-
const v = (l + s) / 2;
|
|
420
|
-
const sv = l === 0 ? 2 * smin / (lmin + smin) : 2 * s / (l + s);
|
|
421
|
-
return [h, sv * 100, v * 100];
|
|
422
|
-
};
|
|
423
|
-
convert.hsv.rgb = function(hsv) {
|
|
424
|
-
const h = hsv[0] / 60;
|
|
425
|
-
const s = hsv[1] / 100;
|
|
426
|
-
let v = hsv[2] / 100;
|
|
427
|
-
const hi = Math.floor(h) % 6;
|
|
428
|
-
const f = h - Math.floor(h);
|
|
429
|
-
const p = 255 * v * (1 - s);
|
|
430
|
-
const q = 255 * v * (1 - s * f);
|
|
431
|
-
const t = 255 * v * (1 - s * (1 - f));
|
|
432
|
-
v *= 255;
|
|
433
|
-
switch (hi) {
|
|
434
|
-
case 0:
|
|
435
|
-
return [v, t, p];
|
|
436
|
-
case 1:
|
|
437
|
-
return [q, v, p];
|
|
438
|
-
case 2:
|
|
439
|
-
return [p, v, t];
|
|
440
|
-
case 3:
|
|
441
|
-
return [p, q, v];
|
|
442
|
-
case 4:
|
|
443
|
-
return [t, p, v];
|
|
444
|
-
case 5:
|
|
445
|
-
return [v, p, q];
|
|
446
|
-
}
|
|
447
|
-
};
|
|
448
|
-
convert.hsv.hsl = function(hsv) {
|
|
449
|
-
const h = hsv[0];
|
|
450
|
-
const s = hsv[1] / 100;
|
|
451
|
-
const v = hsv[2] / 100;
|
|
452
|
-
const vmin = Math.max(v, 0.01);
|
|
453
|
-
let sl;
|
|
454
|
-
let l;
|
|
455
|
-
l = (2 - s) * v;
|
|
456
|
-
const lmin = (2 - s) * vmin;
|
|
457
|
-
sl = s * vmin;
|
|
458
|
-
sl /= lmin <= 1 ? lmin : 2 - lmin;
|
|
459
|
-
sl = sl || 0;
|
|
460
|
-
l /= 2;
|
|
461
|
-
return [h, sl * 100, l * 100];
|
|
462
|
-
};
|
|
463
|
-
convert.hwb.rgb = function(hwb) {
|
|
464
|
-
const h = hwb[0] / 360;
|
|
465
|
-
let wh = hwb[1] / 100;
|
|
466
|
-
let bl = hwb[2] / 100;
|
|
467
|
-
const ratio = wh + bl;
|
|
468
|
-
let f;
|
|
469
|
-
if (ratio > 1) {
|
|
470
|
-
wh /= ratio;
|
|
471
|
-
bl /= ratio;
|
|
472
|
-
}
|
|
473
|
-
const i = Math.floor(6 * h);
|
|
474
|
-
const v = 1 - bl;
|
|
475
|
-
f = 6 * h - i;
|
|
476
|
-
if ((i & 1) !== 0) {
|
|
477
|
-
f = 1 - f;
|
|
478
|
-
}
|
|
479
|
-
const n = wh + f * (v - wh);
|
|
480
|
-
let r;
|
|
481
|
-
let g;
|
|
482
|
-
let b;
|
|
483
|
-
switch (i) {
|
|
484
|
-
default:
|
|
485
|
-
case 6:
|
|
486
|
-
case 0:
|
|
487
|
-
r = v;
|
|
488
|
-
g = n;
|
|
489
|
-
b = wh;
|
|
490
|
-
break;
|
|
491
|
-
case 1:
|
|
492
|
-
r = n;
|
|
493
|
-
g = v;
|
|
494
|
-
b = wh;
|
|
495
|
-
break;
|
|
496
|
-
case 2:
|
|
497
|
-
r = wh;
|
|
498
|
-
g = v;
|
|
499
|
-
b = n;
|
|
500
|
-
break;
|
|
501
|
-
case 3:
|
|
502
|
-
r = wh;
|
|
503
|
-
g = n;
|
|
504
|
-
b = v;
|
|
505
|
-
break;
|
|
506
|
-
case 4:
|
|
507
|
-
r = n;
|
|
508
|
-
g = wh;
|
|
509
|
-
b = v;
|
|
510
|
-
break;
|
|
511
|
-
case 5:
|
|
512
|
-
r = v;
|
|
513
|
-
g = wh;
|
|
514
|
-
b = n;
|
|
515
|
-
break;
|
|
516
|
-
}
|
|
517
|
-
return [r * 255, g * 255, b * 255];
|
|
518
|
-
};
|
|
519
|
-
convert.cmyk.rgb = function(cmyk) {
|
|
520
|
-
const c = cmyk[0] / 100;
|
|
521
|
-
const m = cmyk[1] / 100;
|
|
522
|
-
const y = cmyk[2] / 100;
|
|
523
|
-
const k = cmyk[3] / 100;
|
|
524
|
-
const r = 1 - Math.min(1, c * (1 - k) + k);
|
|
525
|
-
const g = 1 - Math.min(1, m * (1 - k) + k);
|
|
526
|
-
const b = 1 - Math.min(1, y * (1 - k) + k);
|
|
527
|
-
return [r * 255, g * 255, b * 255];
|
|
528
|
-
};
|
|
529
|
-
convert.xyz.rgb = function(xyz) {
|
|
530
|
-
const x = xyz[0] / 100;
|
|
531
|
-
const y = xyz[1] / 100;
|
|
532
|
-
const z = xyz[2] / 100;
|
|
533
|
-
let r;
|
|
534
|
-
let g;
|
|
535
|
-
let b;
|
|
536
|
-
r = x * 3.2406 + y * -1.5372 + z * -0.4986;
|
|
537
|
-
g = x * -0.9689 + y * 1.8758 + z * 0.0415;
|
|
538
|
-
b = x * 0.0557 + y * -0.204 + z * 1.057;
|
|
539
|
-
r = r > 31308e-7 ? 1.055 * r ** (1 / 2.4) - 0.055 : r * 12.92;
|
|
540
|
-
g = g > 31308e-7 ? 1.055 * g ** (1 / 2.4) - 0.055 : g * 12.92;
|
|
541
|
-
b = b > 31308e-7 ? 1.055 * b ** (1 / 2.4) - 0.055 : b * 12.92;
|
|
542
|
-
r = Math.min(Math.max(0, r), 1);
|
|
543
|
-
g = Math.min(Math.max(0, g), 1);
|
|
544
|
-
b = Math.min(Math.max(0, b), 1);
|
|
545
|
-
return [r * 255, g * 255, b * 255];
|
|
546
|
-
};
|
|
547
|
-
convert.xyz.lab = function(xyz) {
|
|
548
|
-
let x = xyz[0];
|
|
549
|
-
let y = xyz[1];
|
|
550
|
-
let z = xyz[2];
|
|
551
|
-
x /= 95.047;
|
|
552
|
-
y /= 100;
|
|
553
|
-
z /= 108.883;
|
|
554
|
-
x = x > 8856e-6 ? x ** (1 / 3) : 7.787 * x + 16 / 116;
|
|
555
|
-
y = y > 8856e-6 ? y ** (1 / 3) : 7.787 * y + 16 / 116;
|
|
556
|
-
z = z > 8856e-6 ? z ** (1 / 3) : 7.787 * z + 16 / 116;
|
|
557
|
-
const l = 116 * y - 16;
|
|
558
|
-
const a = 500 * (x - y);
|
|
559
|
-
const b = 200 * (y - z);
|
|
560
|
-
return [l, a, b];
|
|
561
|
-
};
|
|
562
|
-
convert.lab.xyz = function(lab) {
|
|
563
|
-
const l = lab[0];
|
|
564
|
-
const a = lab[1];
|
|
565
|
-
const b = lab[2];
|
|
566
|
-
let x;
|
|
567
|
-
let y;
|
|
568
|
-
let z;
|
|
569
|
-
y = (l + 16) / 116;
|
|
570
|
-
x = a / 500 + y;
|
|
571
|
-
z = y - b / 200;
|
|
572
|
-
const y2 = y ** 3;
|
|
573
|
-
const x2 = x ** 3;
|
|
574
|
-
const z2 = z ** 3;
|
|
575
|
-
y = y2 > 8856e-6 ? y2 : (y - 16 / 116) / 7.787;
|
|
576
|
-
x = x2 > 8856e-6 ? x2 : (x - 16 / 116) / 7.787;
|
|
577
|
-
z = z2 > 8856e-6 ? z2 : (z - 16 / 116) / 7.787;
|
|
578
|
-
x *= 95.047;
|
|
579
|
-
y *= 100;
|
|
580
|
-
z *= 108.883;
|
|
581
|
-
return [x, y, z];
|
|
582
|
-
};
|
|
583
|
-
convert.lab.lch = function(lab) {
|
|
584
|
-
const l = lab[0];
|
|
585
|
-
const a = lab[1];
|
|
586
|
-
const b = lab[2];
|
|
587
|
-
let h;
|
|
588
|
-
const hr = Math.atan2(b, a);
|
|
589
|
-
h = hr * 360 / 2 / Math.PI;
|
|
590
|
-
if (h < 0) {
|
|
591
|
-
h += 360;
|
|
592
|
-
}
|
|
593
|
-
const c = Math.sqrt(a * a + b * b);
|
|
594
|
-
return [l, c, h];
|
|
595
|
-
};
|
|
596
|
-
convert.lch.lab = function(lch) {
|
|
597
|
-
const l = lch[0];
|
|
598
|
-
const c = lch[1];
|
|
599
|
-
const h = lch[2];
|
|
600
|
-
const hr = h / 360 * 2 * Math.PI;
|
|
601
|
-
const a = c * Math.cos(hr);
|
|
602
|
-
const b = c * Math.sin(hr);
|
|
603
|
-
return [l, a, b];
|
|
604
|
-
};
|
|
605
|
-
convert.rgb.ansi16 = function(args, saturation = null) {
|
|
606
|
-
const [r, g, b] = args;
|
|
607
|
-
let value = saturation === null ? convert.rgb.hsv(args)[2] : saturation;
|
|
608
|
-
value = Math.round(value / 50);
|
|
609
|
-
if (value === 0) {
|
|
610
|
-
return 30;
|
|
611
|
-
}
|
|
612
|
-
let ansi = 30 + (Math.round(b / 255) << 2 | Math.round(g / 255) << 1 | Math.round(r / 255));
|
|
613
|
-
if (value === 2) {
|
|
614
|
-
ansi += 60;
|
|
615
|
-
}
|
|
616
|
-
return ansi;
|
|
617
|
-
};
|
|
618
|
-
convert.hsv.ansi16 = function(args) {
|
|
619
|
-
return convert.rgb.ansi16(convert.hsv.rgb(args), args[2]);
|
|
620
|
-
};
|
|
621
|
-
convert.rgb.ansi256 = function(args) {
|
|
622
|
-
const r = args[0];
|
|
623
|
-
const g = args[1];
|
|
624
|
-
const b = args[2];
|
|
625
|
-
if (r === g && g === b) {
|
|
626
|
-
if (r < 8) {
|
|
627
|
-
return 16;
|
|
186
|
+
const value = Math.max(red, green, blue) * 2;
|
|
187
|
+
if (value === 0) {
|
|
188
|
+
return 30;
|
|
628
189
|
}
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
return Math.round((r - 8) / 247 * 24) + 232;
|
|
633
|
-
}
|
|
634
|
-
const ansi = 16 + 36 * Math.round(r / 255 * 5) + 6 * Math.round(g / 255 * 5) + Math.round(b / 255 * 5);
|
|
635
|
-
return ansi;
|
|
636
|
-
};
|
|
637
|
-
convert.ansi16.rgb = function(args) {
|
|
638
|
-
let color = args % 10;
|
|
639
|
-
if (color === 0 || color === 7) {
|
|
640
|
-
if (args > 50) {
|
|
641
|
-
color += 3.5;
|
|
642
|
-
}
|
|
643
|
-
color = color / 10.5 * 255;
|
|
644
|
-
return [color, color, color];
|
|
645
|
-
}
|
|
646
|
-
const mult = (~~(args > 50) + 1) * 0.5;
|
|
647
|
-
const r = (color & 1) * mult * 255;
|
|
648
|
-
const g = (color >> 1 & 1) * mult * 255;
|
|
649
|
-
const b = (color >> 2 & 1) * mult * 255;
|
|
650
|
-
return [r, g, b];
|
|
651
|
-
};
|
|
652
|
-
convert.ansi256.rgb = function(args) {
|
|
653
|
-
if (args >= 232) {
|
|
654
|
-
const c = (args - 232) * 10 + 8;
|
|
655
|
-
return [c, c, c];
|
|
656
|
-
}
|
|
657
|
-
args -= 16;
|
|
658
|
-
let rem;
|
|
659
|
-
const r = Math.floor(args / 36) / 5 * 255;
|
|
660
|
-
const g = Math.floor((rem = args % 36) / 6) / 5 * 255;
|
|
661
|
-
const b = rem % 6 / 5 * 255;
|
|
662
|
-
return [r, g, b];
|
|
663
|
-
};
|
|
664
|
-
convert.rgb.hex = function(args) {
|
|
665
|
-
const integer = ((Math.round(args[0]) & 255) << 16) + ((Math.round(args[1]) & 255) << 8) + (Math.round(args[2]) & 255);
|
|
666
|
-
const string = integer.toString(16).toUpperCase();
|
|
667
|
-
return "000000".substring(string.length) + string;
|
|
668
|
-
};
|
|
669
|
-
convert.hex.rgb = function(args) {
|
|
670
|
-
const match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
|
|
671
|
-
if (!match) {
|
|
672
|
-
return [0, 0, 0];
|
|
673
|
-
}
|
|
674
|
-
let colorString = match[0];
|
|
675
|
-
if (match[0].length === 3) {
|
|
676
|
-
colorString = colorString.split("").map((char) => {
|
|
677
|
-
return char + char;
|
|
678
|
-
}).join("");
|
|
679
|
-
}
|
|
680
|
-
const integer = parseInt(colorString, 16);
|
|
681
|
-
const r = integer >> 16 & 255;
|
|
682
|
-
const g = integer >> 8 & 255;
|
|
683
|
-
const b = integer & 255;
|
|
684
|
-
return [r, g, b];
|
|
685
|
-
};
|
|
686
|
-
convert.rgb.hcg = function(rgb) {
|
|
687
|
-
const r = rgb[0] / 255;
|
|
688
|
-
const g = rgb[1] / 255;
|
|
689
|
-
const b = rgb[2] / 255;
|
|
690
|
-
const max = Math.max(Math.max(r, g), b);
|
|
691
|
-
const min = Math.min(Math.min(r, g), b);
|
|
692
|
-
const chroma = max - min;
|
|
693
|
-
let grayscale;
|
|
694
|
-
let hue;
|
|
695
|
-
if (chroma < 1) {
|
|
696
|
-
grayscale = min / (1 - chroma);
|
|
697
|
-
} else {
|
|
698
|
-
grayscale = 0;
|
|
699
|
-
}
|
|
700
|
-
if (chroma <= 0) {
|
|
701
|
-
hue = 0;
|
|
702
|
-
} else if (max === r) {
|
|
703
|
-
hue = (g - b) / chroma % 6;
|
|
704
|
-
} else if (max === g) {
|
|
705
|
-
hue = 2 + (b - r) / chroma;
|
|
706
|
-
} else {
|
|
707
|
-
hue = 4 + (r - g) / chroma;
|
|
708
|
-
}
|
|
709
|
-
hue /= 6;
|
|
710
|
-
hue %= 1;
|
|
711
|
-
return [hue * 360, chroma * 100, grayscale * 100];
|
|
712
|
-
};
|
|
713
|
-
convert.hsl.hcg = function(hsl) {
|
|
714
|
-
const s = hsl[1] / 100;
|
|
715
|
-
const l = hsl[2] / 100;
|
|
716
|
-
const c = l < 0.5 ? 2 * s * l : 2 * s * (1 - l);
|
|
717
|
-
let f = 0;
|
|
718
|
-
if (c < 1) {
|
|
719
|
-
f = (l - 0.5 * c) / (1 - c);
|
|
720
|
-
}
|
|
721
|
-
return [hsl[0], c * 100, f * 100];
|
|
722
|
-
};
|
|
723
|
-
convert.hsv.hcg = function(hsv) {
|
|
724
|
-
const s = hsv[1] / 100;
|
|
725
|
-
const v = hsv[2] / 100;
|
|
726
|
-
const c = s * v;
|
|
727
|
-
let f = 0;
|
|
728
|
-
if (c < 1) {
|
|
729
|
-
f = (v - c) / (1 - c);
|
|
730
|
-
}
|
|
731
|
-
return [hsv[0], c * 100, f * 100];
|
|
732
|
-
};
|
|
733
|
-
convert.hcg.rgb = function(hcg) {
|
|
734
|
-
const h = hcg[0] / 360;
|
|
735
|
-
const c = hcg[1] / 100;
|
|
736
|
-
const g = hcg[2] / 100;
|
|
737
|
-
if (c === 0) {
|
|
738
|
-
return [g * 255, g * 255, g * 255];
|
|
739
|
-
}
|
|
740
|
-
const pure = [0, 0, 0];
|
|
741
|
-
const hi = h % 1 * 6;
|
|
742
|
-
const v = hi % 1;
|
|
743
|
-
const w = 1 - v;
|
|
744
|
-
let mg = 0;
|
|
745
|
-
switch (Math.floor(hi)) {
|
|
746
|
-
case 0:
|
|
747
|
-
pure[0] = 1;
|
|
748
|
-
pure[1] = v;
|
|
749
|
-
pure[2] = 0;
|
|
750
|
-
break;
|
|
751
|
-
case 1:
|
|
752
|
-
pure[0] = w;
|
|
753
|
-
pure[1] = 1;
|
|
754
|
-
pure[2] = 0;
|
|
755
|
-
break;
|
|
756
|
-
case 2:
|
|
757
|
-
pure[0] = 0;
|
|
758
|
-
pure[1] = 1;
|
|
759
|
-
pure[2] = v;
|
|
760
|
-
break;
|
|
761
|
-
case 3:
|
|
762
|
-
pure[0] = 0;
|
|
763
|
-
pure[1] = w;
|
|
764
|
-
pure[2] = 1;
|
|
765
|
-
break;
|
|
766
|
-
case 4:
|
|
767
|
-
pure[0] = v;
|
|
768
|
-
pure[1] = 0;
|
|
769
|
-
pure[2] = 1;
|
|
770
|
-
break;
|
|
771
|
-
default:
|
|
772
|
-
pure[0] = 1;
|
|
773
|
-
pure[1] = 0;
|
|
774
|
-
pure[2] = w;
|
|
775
|
-
}
|
|
776
|
-
mg = (1 - c) * g;
|
|
777
|
-
return [
|
|
778
|
-
(c * pure[0] + mg) * 255,
|
|
779
|
-
(c * pure[1] + mg) * 255,
|
|
780
|
-
(c * pure[2] + mg) * 255
|
|
781
|
-
];
|
|
782
|
-
};
|
|
783
|
-
convert.hcg.hsv = function(hcg) {
|
|
784
|
-
const c = hcg[1] / 100;
|
|
785
|
-
const g = hcg[2] / 100;
|
|
786
|
-
const v = c + g * (1 - c);
|
|
787
|
-
let f = 0;
|
|
788
|
-
if (v > 0) {
|
|
789
|
-
f = c / v;
|
|
790
|
-
}
|
|
791
|
-
return [hcg[0], f * 100, v * 100];
|
|
792
|
-
};
|
|
793
|
-
convert.hcg.hsl = function(hcg) {
|
|
794
|
-
const c = hcg[1] / 100;
|
|
795
|
-
const g = hcg[2] / 100;
|
|
796
|
-
const l = g * (1 - c) + 0.5 * c;
|
|
797
|
-
let s = 0;
|
|
798
|
-
if (l > 0 && l < 0.5) {
|
|
799
|
-
s = c / (2 * l);
|
|
800
|
-
} else if (l >= 0.5 && l < 1) {
|
|
801
|
-
s = c / (2 * (1 - l));
|
|
802
|
-
}
|
|
803
|
-
return [hcg[0], s * 100, l * 100];
|
|
804
|
-
};
|
|
805
|
-
convert.hcg.hwb = function(hcg) {
|
|
806
|
-
const c = hcg[1] / 100;
|
|
807
|
-
const g = hcg[2] / 100;
|
|
808
|
-
const v = c + g * (1 - c);
|
|
809
|
-
return [hcg[0], (v - c) * 100, (1 - v) * 100];
|
|
810
|
-
};
|
|
811
|
-
convert.hwb.hcg = function(hwb) {
|
|
812
|
-
const w = hwb[1] / 100;
|
|
813
|
-
const b = hwb[2] / 100;
|
|
814
|
-
const v = 1 - b;
|
|
815
|
-
const c = v - w;
|
|
816
|
-
let g = 0;
|
|
817
|
-
if (c < 1) {
|
|
818
|
-
g = (v - c) / (1 - c);
|
|
819
|
-
}
|
|
820
|
-
return [hwb[0], c * 100, g * 100];
|
|
821
|
-
};
|
|
822
|
-
convert.apple.rgb = function(apple) {
|
|
823
|
-
return [apple[0] / 65535 * 255, apple[1] / 65535 * 255, apple[2] / 65535 * 255];
|
|
824
|
-
};
|
|
825
|
-
convert.rgb.apple = function(rgb) {
|
|
826
|
-
return [rgb[0] / 255 * 65535, rgb[1] / 255 * 65535, rgb[2] / 255 * 65535];
|
|
827
|
-
};
|
|
828
|
-
convert.gray.rgb = function(args) {
|
|
829
|
-
return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];
|
|
830
|
-
};
|
|
831
|
-
convert.gray.hsl = function(args) {
|
|
832
|
-
return [0, 0, args[0]];
|
|
833
|
-
};
|
|
834
|
-
convert.gray.hsv = convert.gray.hsl;
|
|
835
|
-
convert.gray.hwb = function(gray) {
|
|
836
|
-
return [0, 100, gray[0]];
|
|
837
|
-
};
|
|
838
|
-
convert.gray.cmyk = function(gray) {
|
|
839
|
-
return [0, 0, 0, gray[0]];
|
|
840
|
-
};
|
|
841
|
-
convert.gray.lab = function(gray) {
|
|
842
|
-
return [gray[0], 0, 0];
|
|
843
|
-
};
|
|
844
|
-
convert.gray.hex = function(gray) {
|
|
845
|
-
const val = Math.round(gray[0] / 100 * 255) & 255;
|
|
846
|
-
const integer = (val << 16) + (val << 8) + val;
|
|
847
|
-
const string = integer.toString(16).toUpperCase();
|
|
848
|
-
return "000000".substring(string.length) + string;
|
|
849
|
-
};
|
|
850
|
-
convert.rgb.gray = function(rgb) {
|
|
851
|
-
const val = (rgb[0] + rgb[1] + rgb[2]) / 3;
|
|
852
|
-
return [val / 255 * 100];
|
|
853
|
-
};
|
|
854
|
-
}
|
|
855
|
-
});
|
|
856
|
-
|
|
857
|
-
// node_modules/color-convert/route.js
|
|
858
|
-
var require_route = __commonJS({
|
|
859
|
-
"node_modules/color-convert/route.js"(exports2, module2) {
|
|
860
|
-
var conversions = require_conversions();
|
|
861
|
-
function buildGraph() {
|
|
862
|
-
const graph = {};
|
|
863
|
-
const models = Object.keys(conversions);
|
|
864
|
-
for (let len = models.length, i = 0; i < len; i++) {
|
|
865
|
-
graph[models[i]] = {
|
|
866
|
-
// http://jsperf.com/1-vs-infinity
|
|
867
|
-
// micro-opt, but this is simple.
|
|
868
|
-
distance: -1,
|
|
869
|
-
parent: null
|
|
870
|
-
};
|
|
871
|
-
}
|
|
872
|
-
return graph;
|
|
873
|
-
}
|
|
874
|
-
function deriveBFS(fromModel) {
|
|
875
|
-
const graph = buildGraph();
|
|
876
|
-
const queue = [fromModel];
|
|
877
|
-
graph[fromModel].distance = 0;
|
|
878
|
-
while (queue.length) {
|
|
879
|
-
const current = queue.pop();
|
|
880
|
-
const adjacents = Object.keys(conversions[current]);
|
|
881
|
-
for (let len = adjacents.length, i = 0; i < len; i++) {
|
|
882
|
-
const adjacent = adjacents[i];
|
|
883
|
-
const node = graph[adjacent];
|
|
884
|
-
if (node.distance === -1) {
|
|
885
|
-
node.distance = graph[current].distance + 1;
|
|
886
|
-
node.parent = current;
|
|
887
|
-
queue.unshift(adjacent);
|
|
888
|
-
}
|
|
190
|
+
let result = 30 + (Math.round(blue) << 2 | Math.round(green) << 1 | Math.round(red));
|
|
191
|
+
if (value === 2) {
|
|
192
|
+
result += 60;
|
|
889
193
|
}
|
|
890
|
-
|
|
891
|
-
|
|
194
|
+
return result;
|
|
195
|
+
},
|
|
196
|
+
enumerable: false
|
|
197
|
+
},
|
|
198
|
+
rgbToAnsi: {
|
|
199
|
+
value: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)),
|
|
200
|
+
enumerable: false
|
|
201
|
+
},
|
|
202
|
+
hexToAnsi: {
|
|
203
|
+
value: (hex) => styles.ansi256ToAnsi(styles.hexToAnsi256(hex)),
|
|
204
|
+
enumerable: false
|
|
892
205
|
}
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
206
|
+
});
|
|
207
|
+
return styles;
|
|
208
|
+
}
|
|
209
|
+
var ansiStyles = assembleStyles();
|
|
210
|
+
var ansi_styles_default = ansiStyles;
|
|
211
|
+
|
|
212
|
+
// node_modules/chalk/source/vendor/supports-color/index.js
|
|
213
|
+
var import_node_process = __toESM(require("node:process"), 1);
|
|
214
|
+
var import_node_os = __toESM(require("node:os"), 1);
|
|
215
|
+
var import_node_tty = __toESM(require("node:tty"), 1);
|
|
216
|
+
function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : import_node_process.default.argv) {
|
|
217
|
+
const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
|
|
218
|
+
const position = argv.indexOf(prefix + flag);
|
|
219
|
+
const terminatorPosition = argv.indexOf("--");
|
|
220
|
+
return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
|
|
221
|
+
}
|
|
222
|
+
var { env } = import_node_process.default;
|
|
223
|
+
var flagForceColor;
|
|
224
|
+
if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
|
|
225
|
+
flagForceColor = 0;
|
|
226
|
+
} else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
|
|
227
|
+
flagForceColor = 1;
|
|
228
|
+
}
|
|
229
|
+
function envForceColor() {
|
|
230
|
+
if ("FORCE_COLOR" in env) {
|
|
231
|
+
if (env.FORCE_COLOR === "true") {
|
|
232
|
+
return 1;
|
|
897
233
|
}
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
let fn = conversions[graph[toModel].parent][toModel];
|
|
901
|
-
let cur = graph[toModel].parent;
|
|
902
|
-
while (graph[cur].parent) {
|
|
903
|
-
path5.unshift(graph[cur].parent);
|
|
904
|
-
fn = link(conversions[graph[cur].parent][cur], fn);
|
|
905
|
-
cur = graph[cur].parent;
|
|
906
|
-
}
|
|
907
|
-
fn.conversion = path5;
|
|
908
|
-
return fn;
|
|
234
|
+
if (env.FORCE_COLOR === "false") {
|
|
235
|
+
return 0;
|
|
909
236
|
}
|
|
910
|
-
|
|
911
|
-
const graph = deriveBFS(fromModel);
|
|
912
|
-
const conversion = {};
|
|
913
|
-
const models = Object.keys(graph);
|
|
914
|
-
for (let len = models.length, i = 0; i < len; i++) {
|
|
915
|
-
const toModel = models[i];
|
|
916
|
-
const node = graph[toModel];
|
|
917
|
-
if (node.parent === null) {
|
|
918
|
-
continue;
|
|
919
|
-
}
|
|
920
|
-
conversion[toModel] = wrapConversion(toModel, graph);
|
|
921
|
-
}
|
|
922
|
-
return conversion;
|
|
923
|
-
};
|
|
237
|
+
return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
|
|
924
238
|
}
|
|
925
|
-
}
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
return
|
|
239
|
+
}
|
|
240
|
+
function translateLevel(level) {
|
|
241
|
+
if (level === 0) {
|
|
242
|
+
return false;
|
|
243
|
+
}
|
|
244
|
+
return {
|
|
245
|
+
level,
|
|
246
|
+
hasBasic: true,
|
|
247
|
+
has256: level >= 2,
|
|
248
|
+
has16m: level >= 3
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
|
|
252
|
+
const noFlagForceColor = envForceColor();
|
|
253
|
+
if (noFlagForceColor !== void 0) {
|
|
254
|
+
flagForceColor = noFlagForceColor;
|
|
255
|
+
}
|
|
256
|
+
const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
|
|
257
|
+
if (forceColor === 0) {
|
|
258
|
+
return 0;
|
|
259
|
+
}
|
|
260
|
+
if (sniffFlags) {
|
|
261
|
+
if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
|
|
262
|
+
return 3;
|
|
949
263
|
}
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
const arg0 = args[0];
|
|
953
|
-
if (arg0 === void 0 || arg0 === null) {
|
|
954
|
-
return arg0;
|
|
955
|
-
}
|
|
956
|
-
if (arg0.length > 1) {
|
|
957
|
-
args = arg0;
|
|
958
|
-
}
|
|
959
|
-
const result = fn(args);
|
|
960
|
-
if (typeof result === "object") {
|
|
961
|
-
for (let len = result.length, i = 0; i < len; i++) {
|
|
962
|
-
result[i] = Math.round(result[i]);
|
|
963
|
-
}
|
|
964
|
-
}
|
|
965
|
-
return result;
|
|
966
|
-
};
|
|
967
|
-
if ("conversion" in fn) {
|
|
968
|
-
wrappedFn.conversion = fn.conversion;
|
|
969
|
-
}
|
|
970
|
-
return wrappedFn;
|
|
264
|
+
if (hasFlag("color=256")) {
|
|
265
|
+
return 2;
|
|
971
266
|
}
|
|
972
|
-
models.forEach((fromModel) => {
|
|
973
|
-
convert[fromModel] = {};
|
|
974
|
-
Object.defineProperty(convert[fromModel], "channels", { value: conversions[fromModel].channels });
|
|
975
|
-
Object.defineProperty(convert[fromModel], "labels", { value: conversions[fromModel].labels });
|
|
976
|
-
const routes = route(fromModel);
|
|
977
|
-
const routeModels = Object.keys(routes);
|
|
978
|
-
routeModels.forEach((toModel) => {
|
|
979
|
-
const fn = routes[toModel];
|
|
980
|
-
convert[fromModel][toModel] = wrapRounded(fn);
|
|
981
|
-
convert[fromModel][toModel].raw = wrapRaw(fn);
|
|
982
|
-
});
|
|
983
|
-
});
|
|
984
|
-
module2.exports = convert;
|
|
985
267
|
}
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
// node_modules/ansi-styles/index.js
|
|
989
|
-
var require_ansi_styles = __commonJS({
|
|
990
|
-
"node_modules/ansi-styles/index.js"(exports2, module2) {
|
|
991
|
-
"use strict";
|
|
992
|
-
var wrapAnsi16 = (fn, offset) => (...args) => {
|
|
993
|
-
const code = fn(...args);
|
|
994
|
-
return `\x1B[${code + offset}m`;
|
|
995
|
-
};
|
|
996
|
-
var wrapAnsi256 = (fn, offset) => (...args) => {
|
|
997
|
-
const code = fn(...args);
|
|
998
|
-
return `\x1B[${38 + offset};5;${code}m`;
|
|
999
|
-
};
|
|
1000
|
-
var wrapAnsi16m = (fn, offset) => (...args) => {
|
|
1001
|
-
const rgb = fn(...args);
|
|
1002
|
-
return `\x1B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`;
|
|
1003
|
-
};
|
|
1004
|
-
var ansi2ansi = (n) => n;
|
|
1005
|
-
var rgb2rgb = (r, g, b) => [r, g, b];
|
|
1006
|
-
var setLazyProperty = (object, property, get) => {
|
|
1007
|
-
Object.defineProperty(object, property, {
|
|
1008
|
-
get: () => {
|
|
1009
|
-
const value = get();
|
|
1010
|
-
Object.defineProperty(object, property, {
|
|
1011
|
-
value,
|
|
1012
|
-
enumerable: true,
|
|
1013
|
-
configurable: true
|
|
1014
|
-
});
|
|
1015
|
-
return value;
|
|
1016
|
-
},
|
|
1017
|
-
enumerable: true,
|
|
1018
|
-
configurable: true
|
|
1019
|
-
});
|
|
1020
|
-
};
|
|
1021
|
-
var colorConvert;
|
|
1022
|
-
var makeDynamicStyles = (wrap, targetSpace, identity, isBackground) => {
|
|
1023
|
-
if (colorConvert === void 0) {
|
|
1024
|
-
colorConvert = require_color_convert();
|
|
1025
|
-
}
|
|
1026
|
-
const offset = isBackground ? 10 : 0;
|
|
1027
|
-
const styles = {};
|
|
1028
|
-
for (const [sourceSpace, suite] of Object.entries(colorConvert)) {
|
|
1029
|
-
const name = sourceSpace === "ansi16" ? "ansi" : sourceSpace;
|
|
1030
|
-
if (sourceSpace === targetSpace) {
|
|
1031
|
-
styles[name] = wrap(identity, offset);
|
|
1032
|
-
} else if (typeof suite === "object") {
|
|
1033
|
-
styles[name] = wrap(suite[targetSpace], offset);
|
|
1034
|
-
}
|
|
1035
|
-
}
|
|
1036
|
-
return styles;
|
|
1037
|
-
};
|
|
1038
|
-
function assembleStyles() {
|
|
1039
|
-
const codes = /* @__PURE__ */ new Map();
|
|
1040
|
-
const styles = {
|
|
1041
|
-
modifier: {
|
|
1042
|
-
reset: [0, 0],
|
|
1043
|
-
// 21 isn't widely supported and 22 does the same thing
|
|
1044
|
-
bold: [1, 22],
|
|
1045
|
-
dim: [2, 22],
|
|
1046
|
-
italic: [3, 23],
|
|
1047
|
-
underline: [4, 24],
|
|
1048
|
-
inverse: [7, 27],
|
|
1049
|
-
hidden: [8, 28],
|
|
1050
|
-
strikethrough: [9, 29]
|
|
1051
|
-
},
|
|
1052
|
-
color: {
|
|
1053
|
-
black: [30, 39],
|
|
1054
|
-
red: [31, 39],
|
|
1055
|
-
green: [32, 39],
|
|
1056
|
-
yellow: [33, 39],
|
|
1057
|
-
blue: [34, 39],
|
|
1058
|
-
magenta: [35, 39],
|
|
1059
|
-
cyan: [36, 39],
|
|
1060
|
-
white: [37, 39],
|
|
1061
|
-
// Bright color
|
|
1062
|
-
blackBright: [90, 39],
|
|
1063
|
-
redBright: [91, 39],
|
|
1064
|
-
greenBright: [92, 39],
|
|
1065
|
-
yellowBright: [93, 39],
|
|
1066
|
-
blueBright: [94, 39],
|
|
1067
|
-
magentaBright: [95, 39],
|
|
1068
|
-
cyanBright: [96, 39],
|
|
1069
|
-
whiteBright: [97, 39]
|
|
1070
|
-
},
|
|
1071
|
-
bgColor: {
|
|
1072
|
-
bgBlack: [40, 49],
|
|
1073
|
-
bgRed: [41, 49],
|
|
1074
|
-
bgGreen: [42, 49],
|
|
1075
|
-
bgYellow: [43, 49],
|
|
1076
|
-
bgBlue: [44, 49],
|
|
1077
|
-
bgMagenta: [45, 49],
|
|
1078
|
-
bgCyan: [46, 49],
|
|
1079
|
-
bgWhite: [47, 49],
|
|
1080
|
-
// Bright color
|
|
1081
|
-
bgBlackBright: [100, 49],
|
|
1082
|
-
bgRedBright: [101, 49],
|
|
1083
|
-
bgGreenBright: [102, 49],
|
|
1084
|
-
bgYellowBright: [103, 49],
|
|
1085
|
-
bgBlueBright: [104, 49],
|
|
1086
|
-
bgMagentaBright: [105, 49],
|
|
1087
|
-
bgCyanBright: [106, 49],
|
|
1088
|
-
bgWhiteBright: [107, 49]
|
|
1089
|
-
}
|
|
1090
|
-
};
|
|
1091
|
-
styles.color.gray = styles.color.blackBright;
|
|
1092
|
-
styles.bgColor.bgGray = styles.bgColor.bgBlackBright;
|
|
1093
|
-
styles.color.grey = styles.color.blackBright;
|
|
1094
|
-
styles.bgColor.bgGrey = styles.bgColor.bgBlackBright;
|
|
1095
|
-
for (const [groupName, group2] of Object.entries(styles)) {
|
|
1096
|
-
for (const [styleName, style] of Object.entries(group2)) {
|
|
1097
|
-
styles[styleName] = {
|
|
1098
|
-
open: `\x1B[${style[0]}m`,
|
|
1099
|
-
close: `\x1B[${style[1]}m`
|
|
1100
|
-
};
|
|
1101
|
-
group2[styleName] = styles[styleName];
|
|
1102
|
-
codes.set(style[0], style[1]);
|
|
1103
|
-
}
|
|
1104
|
-
Object.defineProperty(styles, groupName, {
|
|
1105
|
-
value: group2,
|
|
1106
|
-
enumerable: false
|
|
1107
|
-
});
|
|
1108
|
-
}
|
|
1109
|
-
Object.defineProperty(styles, "codes", {
|
|
1110
|
-
value: codes,
|
|
1111
|
-
enumerable: false
|
|
1112
|
-
});
|
|
1113
|
-
styles.color.close = "\x1B[39m";
|
|
1114
|
-
styles.bgColor.close = "\x1B[49m";
|
|
1115
|
-
setLazyProperty(styles.color, "ansi", () => makeDynamicStyles(wrapAnsi16, "ansi16", ansi2ansi, false));
|
|
1116
|
-
setLazyProperty(styles.color, "ansi256", () => makeDynamicStyles(wrapAnsi256, "ansi256", ansi2ansi, false));
|
|
1117
|
-
setLazyProperty(styles.color, "ansi16m", () => makeDynamicStyles(wrapAnsi16m, "rgb", rgb2rgb, false));
|
|
1118
|
-
setLazyProperty(styles.bgColor, "ansi", () => makeDynamicStyles(wrapAnsi16, "ansi16", ansi2ansi, true));
|
|
1119
|
-
setLazyProperty(styles.bgColor, "ansi256", () => makeDynamicStyles(wrapAnsi256, "ansi256", ansi2ansi, true));
|
|
1120
|
-
setLazyProperty(styles.bgColor, "ansi16m", () => makeDynamicStyles(wrapAnsi16m, "rgb", rgb2rgb, true));
|
|
1121
|
-
return styles;
|
|
1122
|
-
}
|
|
1123
|
-
Object.defineProperty(module2, "exports", {
|
|
1124
|
-
enumerable: true,
|
|
1125
|
-
get: assembleStyles
|
|
1126
|
-
});
|
|
268
|
+
if ("TF_BUILD" in env && "AGENT_NAME" in env) {
|
|
269
|
+
return 1;
|
|
1127
270
|
}
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
// node_modules/has-flag/index.js
|
|
1131
|
-
var require_has_flag = __commonJS({
|
|
1132
|
-
"node_modules/has-flag/index.js"(exports2, module2) {
|
|
1133
|
-
"use strict";
|
|
1134
|
-
module2.exports = (flag, argv = process.argv) => {
|
|
1135
|
-
const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
|
|
1136
|
-
const position = argv.indexOf(prefix + flag);
|
|
1137
|
-
const terminatorPosition = argv.indexOf("--");
|
|
1138
|
-
return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
|
|
1139
|
-
};
|
|
271
|
+
if (haveStream && !streamIsTTY && forceColor === void 0) {
|
|
272
|
+
return 0;
|
|
1140
273
|
}
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
var hasFlag = require_has_flag();
|
|
1150
|
-
var { env } = process;
|
|
1151
|
-
var forceColor;
|
|
1152
|
-
if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
|
|
1153
|
-
forceColor = 0;
|
|
1154
|
-
} else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
|
|
1155
|
-
forceColor = 1;
|
|
274
|
+
const min = forceColor || 0;
|
|
275
|
+
if (env.TERM === "dumb") {
|
|
276
|
+
return min;
|
|
277
|
+
}
|
|
278
|
+
if (import_node_process.default.platform === "win32") {
|
|
279
|
+
const osRelease = import_node_os.default.release().split(".");
|
|
280
|
+
if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
|
|
281
|
+
return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
|
1156
282
|
}
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
} else {
|
|
1163
|
-
forceColor = env.FORCE_COLOR.length === 0 ? 1 : Math.min(parseInt(env.FORCE_COLOR, 10), 3);
|
|
1164
|
-
}
|
|
283
|
+
return 1;
|
|
284
|
+
}
|
|
285
|
+
if ("CI" in env) {
|
|
286
|
+
if (["GITHUB_ACTIONS", "GITEA_ACTIONS", "CIRCLECI"].some((key) => key in env)) {
|
|
287
|
+
return 3;
|
|
1165
288
|
}
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
return false;
|
|
1169
|
-
}
|
|
1170
|
-
return {
|
|
1171
|
-
level,
|
|
1172
|
-
hasBasic: true,
|
|
1173
|
-
has256: level >= 2,
|
|
1174
|
-
has16m: level >= 3
|
|
1175
|
-
};
|
|
289
|
+
if (["TRAVIS", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
|
|
290
|
+
return 1;
|
|
1176
291
|
}
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
return 1;
|
|
1200
|
-
}
|
|
1201
|
-
if ("CI" in env) {
|
|
1202
|
-
if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "GITHUB_ACTIONS", "BUILDKITE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
|
|
1203
|
-
return 1;
|
|
1204
|
-
}
|
|
1205
|
-
return min;
|
|
1206
|
-
}
|
|
1207
|
-
if ("TEAMCITY_VERSION" in env) {
|
|
1208
|
-
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
|
|
1209
|
-
}
|
|
1210
|
-
if (env.COLORTERM === "truecolor") {
|
|
1211
|
-
return 3;
|
|
1212
|
-
}
|
|
1213
|
-
if ("TERM_PROGRAM" in env) {
|
|
1214
|
-
const version = parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
|
|
1215
|
-
switch (env.TERM_PROGRAM) {
|
|
1216
|
-
case "iTerm.app":
|
|
1217
|
-
return version >= 3 ? 3 : 2;
|
|
1218
|
-
case "Apple_Terminal":
|
|
1219
|
-
return 2;
|
|
1220
|
-
}
|
|
292
|
+
return min;
|
|
293
|
+
}
|
|
294
|
+
if ("TEAMCITY_VERSION" in env) {
|
|
295
|
+
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
|
|
296
|
+
}
|
|
297
|
+
if (env.COLORTERM === "truecolor") {
|
|
298
|
+
return 3;
|
|
299
|
+
}
|
|
300
|
+
if (env.TERM === "xterm-kitty") {
|
|
301
|
+
return 3;
|
|
302
|
+
}
|
|
303
|
+
if (env.TERM === "xterm-ghostty") {
|
|
304
|
+
return 3;
|
|
305
|
+
}
|
|
306
|
+
if (env.TERM === "wezterm") {
|
|
307
|
+
return 3;
|
|
308
|
+
}
|
|
309
|
+
if ("TERM_PROGRAM" in env) {
|
|
310
|
+
const version = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
|
|
311
|
+
switch (env.TERM_PROGRAM) {
|
|
312
|
+
case "iTerm.app": {
|
|
313
|
+
return version >= 3 ? 3 : 2;
|
|
1221
314
|
}
|
|
1222
|
-
|
|
315
|
+
case "Apple_Terminal": {
|
|
1223
316
|
return 2;
|
|
1224
317
|
}
|
|
1225
|
-
if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
|
|
1226
|
-
return 1;
|
|
1227
|
-
}
|
|
1228
|
-
if ("COLORTERM" in env) {
|
|
1229
|
-
return 1;
|
|
1230
|
-
}
|
|
1231
|
-
return min;
|
|
1232
|
-
}
|
|
1233
|
-
function getSupportLevel(stream) {
|
|
1234
|
-
const level = supportsColor(stream, stream && stream.isTTY);
|
|
1235
|
-
return translateLevel(level);
|
|
1236
318
|
}
|
|
1237
|
-
module2.exports = {
|
|
1238
|
-
supportsColor: getSupportLevel,
|
|
1239
|
-
stdout: translateLevel(supportsColor(true, tty.isatty(1))),
|
|
1240
|
-
stderr: translateLevel(supportsColor(true, tty.isatty(2)))
|
|
1241
|
-
};
|
|
1242
319
|
}
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
// node_modules/chalk/source/util.js
|
|
1246
|
-
var require_util = __commonJS({
|
|
1247
|
-
"node_modules/chalk/source/util.js"(exports2, module2) {
|
|
1248
|
-
"use strict";
|
|
1249
|
-
var stringReplaceAll = (string, substring, replacer) => {
|
|
1250
|
-
let index = string.indexOf(substring);
|
|
1251
|
-
if (index === -1) {
|
|
1252
|
-
return string;
|
|
1253
|
-
}
|
|
1254
|
-
const substringLength = substring.length;
|
|
1255
|
-
let endIndex = 0;
|
|
1256
|
-
let returnValue = "";
|
|
1257
|
-
do {
|
|
1258
|
-
returnValue += string.substr(endIndex, index - endIndex) + substring + replacer;
|
|
1259
|
-
endIndex = index + substringLength;
|
|
1260
|
-
index = string.indexOf(substring, endIndex);
|
|
1261
|
-
} while (index !== -1);
|
|
1262
|
-
returnValue += string.substr(endIndex);
|
|
1263
|
-
return returnValue;
|
|
1264
|
-
};
|
|
1265
|
-
var stringEncaseCRLFWithFirstIndex = (string, prefix, postfix, index) => {
|
|
1266
|
-
let endIndex = 0;
|
|
1267
|
-
let returnValue = "";
|
|
1268
|
-
do {
|
|
1269
|
-
const gotCR = string[index - 1] === "\r";
|
|
1270
|
-
returnValue += string.substr(endIndex, (gotCR ? index - 1 : index) - endIndex) + prefix + (gotCR ? "\r\n" : "\n") + postfix;
|
|
1271
|
-
endIndex = index + 1;
|
|
1272
|
-
index = string.indexOf("\n", endIndex);
|
|
1273
|
-
} while (index !== -1);
|
|
1274
|
-
returnValue += string.substr(endIndex);
|
|
1275
|
-
return returnValue;
|
|
1276
|
-
};
|
|
1277
|
-
module2.exports = {
|
|
1278
|
-
stringReplaceAll,
|
|
1279
|
-
stringEncaseCRLFWithFirstIndex
|
|
1280
|
-
};
|
|
320
|
+
if (/-256(color)?$/i.test(env.TERM)) {
|
|
321
|
+
return 2;
|
|
1281
322
|
}
|
|
1282
|
-
|
|
323
|
+
if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
|
|
324
|
+
return 1;
|
|
325
|
+
}
|
|
326
|
+
if ("COLORTERM" in env) {
|
|
327
|
+
return 1;
|
|
328
|
+
}
|
|
329
|
+
return min;
|
|
330
|
+
}
|
|
331
|
+
function createSupportsColor(stream, options = {}) {
|
|
332
|
+
const level = _supportsColor(stream, {
|
|
333
|
+
streamIsTTY: stream && stream.isTTY,
|
|
334
|
+
...options
|
|
335
|
+
});
|
|
336
|
+
return translateLevel(level);
|
|
337
|
+
}
|
|
338
|
+
var supportsColor = {
|
|
339
|
+
stdout: createSupportsColor({ isTTY: import_node_tty.default.isatty(1) }),
|
|
340
|
+
stderr: createSupportsColor({ isTTY: import_node_tty.default.isatty(2) })
|
|
341
|
+
};
|
|
342
|
+
var supports_color_default = supportsColor;
|
|
1283
343
|
|
|
1284
|
-
// node_modules/chalk/source/
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
344
|
+
// node_modules/chalk/source/utilities.js
|
|
345
|
+
function stringReplaceAll(string, substring, replacer) {
|
|
346
|
+
let index = string.indexOf(substring);
|
|
347
|
+
if (index === -1) {
|
|
348
|
+
return string;
|
|
349
|
+
}
|
|
350
|
+
const substringLength = substring.length;
|
|
351
|
+
let endIndex = 0;
|
|
352
|
+
let returnValue = "";
|
|
353
|
+
do {
|
|
354
|
+
returnValue += string.slice(endIndex, index) + substring + replacer;
|
|
355
|
+
endIndex = index + substringLength;
|
|
356
|
+
index = string.indexOf(substring, endIndex);
|
|
357
|
+
} while (index !== -1);
|
|
358
|
+
returnValue += string.slice(endIndex);
|
|
359
|
+
return returnValue;
|
|
360
|
+
}
|
|
361
|
+
function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index) {
|
|
362
|
+
let endIndex = 0;
|
|
363
|
+
let returnValue = "";
|
|
364
|
+
do {
|
|
365
|
+
const gotCR = string[index - 1] === "\r";
|
|
366
|
+
returnValue += string.slice(endIndex, gotCR ? index - 1 : index) + prefix + (gotCR ? "\r\n" : "\n") + postfix;
|
|
367
|
+
endIndex = index + 1;
|
|
368
|
+
index = string.indexOf("\n", endIndex);
|
|
369
|
+
} while (index !== -1);
|
|
370
|
+
returnValue += string.slice(endIndex);
|
|
371
|
+
return returnValue;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
// node_modules/chalk/source/index.js
|
|
375
|
+
var { stdout: stdoutColor, stderr: stderrColor } = supports_color_default;
|
|
376
|
+
var GENERATOR = /* @__PURE__ */ Symbol("GENERATOR");
|
|
377
|
+
var STYLER = /* @__PURE__ */ Symbol("STYLER");
|
|
378
|
+
var IS_EMPTY = /* @__PURE__ */ Symbol("IS_EMPTY");
|
|
379
|
+
var levelMapping = [
|
|
380
|
+
"ansi",
|
|
381
|
+
"ansi",
|
|
382
|
+
"ansi256",
|
|
383
|
+
"ansi16m"
|
|
384
|
+
];
|
|
385
|
+
var styles2 = /* @__PURE__ */ Object.create(null);
|
|
386
|
+
var applyOptions = (object, options = {}) => {
|
|
387
|
+
if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
|
|
388
|
+
throw new Error("The `level` option should be an integer from 0 to 3");
|
|
389
|
+
}
|
|
390
|
+
const colorLevel = stdoutColor ? stdoutColor.level : 0;
|
|
391
|
+
object.level = options.level === void 0 ? colorLevel : options.level;
|
|
392
|
+
};
|
|
393
|
+
var chalkFactory = (options) => {
|
|
394
|
+
const chalk2 = (...strings) => strings.join(" ");
|
|
395
|
+
applyOptions(chalk2, options);
|
|
396
|
+
Object.setPrototypeOf(chalk2, createChalk.prototype);
|
|
397
|
+
return chalk2;
|
|
398
|
+
};
|
|
399
|
+
function createChalk(options) {
|
|
400
|
+
return chalkFactory(options);
|
|
401
|
+
}
|
|
402
|
+
Object.setPrototypeOf(createChalk.prototype, Function.prototype);
|
|
403
|
+
for (const [styleName, style] of Object.entries(ansi_styles_default)) {
|
|
404
|
+
styles2[styleName] = {
|
|
405
|
+
get() {
|
|
406
|
+
const builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]);
|
|
407
|
+
Object.defineProperty(this, styleName, { value: builder });
|
|
408
|
+
return builder;
|
|
1330
409
|
}
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
return results;
|
|
410
|
+
};
|
|
411
|
+
}
|
|
412
|
+
styles2.visible = {
|
|
413
|
+
get() {
|
|
414
|
+
const builder = createBuilder(this, this[STYLER], true);
|
|
415
|
+
Object.defineProperty(this, "visible", { value: builder });
|
|
416
|
+
return builder;
|
|
417
|
+
}
|
|
418
|
+
};
|
|
419
|
+
var getModelAnsi = (model, level, type, ...arguments_) => {
|
|
420
|
+
if (model === "rgb") {
|
|
421
|
+
if (level === "ansi16m") {
|
|
422
|
+
return ansi_styles_default[type].ansi16m(...arguments_);
|
|
1345
423
|
}
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
for (const layer of styles) {
|
|
1349
|
-
for (const style of layer.styles) {
|
|
1350
|
-
enabled[style[0]] = layer.inverse ? null : style.slice(1);
|
|
1351
|
-
}
|
|
1352
|
-
}
|
|
1353
|
-
let current = chalk4;
|
|
1354
|
-
for (const [styleName, styles2] of Object.entries(enabled)) {
|
|
1355
|
-
if (!Array.isArray(styles2)) {
|
|
1356
|
-
continue;
|
|
1357
|
-
}
|
|
1358
|
-
if (!(styleName in current)) {
|
|
1359
|
-
throw new Error(`Unknown Chalk style: ${styleName}`);
|
|
1360
|
-
}
|
|
1361
|
-
current = styles2.length > 0 ? current[styleName](...styles2) : current[styleName];
|
|
1362
|
-
}
|
|
1363
|
-
return current;
|
|
424
|
+
if (level === "ansi256") {
|
|
425
|
+
return ansi_styles_default[type].ansi256(ansi_styles_default.rgbToAnsi256(...arguments_));
|
|
1364
426
|
}
|
|
1365
|
-
|
|
1366
|
-
const styles = [];
|
|
1367
|
-
const chunks = [];
|
|
1368
|
-
let chunk = [];
|
|
1369
|
-
temporary.replace(TEMPLATE_REGEX, (m, escapeCharacter, inverse, style, close, character) => {
|
|
1370
|
-
if (escapeCharacter) {
|
|
1371
|
-
chunk.push(unescape(escapeCharacter));
|
|
1372
|
-
} else if (style) {
|
|
1373
|
-
const string = chunk.join("");
|
|
1374
|
-
chunk = [];
|
|
1375
|
-
chunks.push(styles.length === 0 ? string : buildStyle(chalk4, styles)(string));
|
|
1376
|
-
styles.push({ inverse, styles: parseStyle(style) });
|
|
1377
|
-
} else if (close) {
|
|
1378
|
-
if (styles.length === 0) {
|
|
1379
|
-
throw new Error("Found extraneous } in Chalk template literal");
|
|
1380
|
-
}
|
|
1381
|
-
chunks.push(buildStyle(chalk4, styles)(chunk.join("")));
|
|
1382
|
-
chunk = [];
|
|
1383
|
-
styles.pop();
|
|
1384
|
-
} else {
|
|
1385
|
-
chunk.push(character);
|
|
1386
|
-
}
|
|
1387
|
-
});
|
|
1388
|
-
chunks.push(chunk.join(""));
|
|
1389
|
-
if (styles.length > 0) {
|
|
1390
|
-
const errMessage = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? "" : "s"} (\`}\`)`;
|
|
1391
|
-
throw new Error(errMessage);
|
|
1392
|
-
}
|
|
1393
|
-
return chunks.join("");
|
|
1394
|
-
};
|
|
427
|
+
return ansi_styles_default[type].ansi(ansi_styles_default.rgbToAnsi(...arguments_));
|
|
1395
428
|
}
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
var levelMapping = [
|
|
1410
|
-
"ansi",
|
|
1411
|
-
"ansi",
|
|
1412
|
-
"ansi256",
|
|
1413
|
-
"ansi16m"
|
|
1414
|
-
];
|
|
1415
|
-
var styles = /* @__PURE__ */ Object.create(null);
|
|
1416
|
-
var applyOptions = (object, options = {}) => {
|
|
1417
|
-
if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
|
|
1418
|
-
throw new Error("The `level` option should be an integer from 0 to 3");
|
|
1419
|
-
}
|
|
1420
|
-
const colorLevel = stdoutColor ? stdoutColor.level : 0;
|
|
1421
|
-
object.level = options.level === void 0 ? colorLevel : options.level;
|
|
1422
|
-
};
|
|
1423
|
-
var ChalkClass = class {
|
|
1424
|
-
constructor(options) {
|
|
1425
|
-
return chalkFactory(options);
|
|
1426
|
-
}
|
|
1427
|
-
};
|
|
1428
|
-
var chalkFactory = (options) => {
|
|
1429
|
-
const chalk5 = {};
|
|
1430
|
-
applyOptions(chalk5, options);
|
|
1431
|
-
chalk5.template = (...arguments_) => chalkTag(chalk5.template, ...arguments_);
|
|
1432
|
-
Object.setPrototypeOf(chalk5, Chalk.prototype);
|
|
1433
|
-
Object.setPrototypeOf(chalk5.template, chalk5);
|
|
1434
|
-
chalk5.template.constructor = () => {
|
|
1435
|
-
throw new Error("`chalk.constructor()` is deprecated. Use `new chalk.Instance()` instead.");
|
|
1436
|
-
};
|
|
1437
|
-
chalk5.template.Instance = ChalkClass;
|
|
1438
|
-
return chalk5.template;
|
|
1439
|
-
};
|
|
1440
|
-
function Chalk(options) {
|
|
1441
|
-
return chalkFactory(options);
|
|
1442
|
-
}
|
|
1443
|
-
for (const [styleName, style] of Object.entries(ansiStyles)) {
|
|
1444
|
-
styles[styleName] = {
|
|
1445
|
-
get() {
|
|
1446
|
-
const builder = createBuilder(this, createStyler(style.open, style.close, this._styler), this._isEmpty);
|
|
1447
|
-
Object.defineProperty(this, styleName, { value: builder });
|
|
1448
|
-
return builder;
|
|
1449
|
-
}
|
|
429
|
+
if (model === "hex") {
|
|
430
|
+
return getModelAnsi("rgb", level, type, ...ansi_styles_default.hexToRgb(...arguments_));
|
|
431
|
+
}
|
|
432
|
+
return ansi_styles_default[type][model](...arguments_);
|
|
433
|
+
};
|
|
434
|
+
var usedModels = ["rgb", "hex", "ansi256"];
|
|
435
|
+
for (const model of usedModels) {
|
|
436
|
+
styles2[model] = {
|
|
437
|
+
get() {
|
|
438
|
+
const { level } = this;
|
|
439
|
+
return function(...arguments_) {
|
|
440
|
+
const styler = createStyler(getModelAnsi(model, levelMapping[level], "color", ...arguments_), ansi_styles_default.color.close, this[STYLER]);
|
|
441
|
+
return createBuilder(this, styler, this[IS_EMPTY]);
|
|
1450
442
|
};
|
|
1451
443
|
}
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
for (const model of usedModels) {
|
|
1461
|
-
styles[model] = {
|
|
1462
|
-
get() {
|
|
1463
|
-
const { level } = this;
|
|
1464
|
-
return function(...arguments_) {
|
|
1465
|
-
const styler = createStyler(ansiStyles.color[levelMapping[level]][model](...arguments_), ansiStyles.color.close, this._styler);
|
|
1466
|
-
return createBuilder(this, styler, this._isEmpty);
|
|
1467
|
-
};
|
|
1468
|
-
}
|
|
444
|
+
};
|
|
445
|
+
const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
|
|
446
|
+
styles2[bgModel] = {
|
|
447
|
+
get() {
|
|
448
|
+
const { level } = this;
|
|
449
|
+
return function(...arguments_) {
|
|
450
|
+
const styler = createStyler(getModelAnsi(model, levelMapping[level], "bgColor", ...arguments_), ansi_styles_default.bgColor.close, this[STYLER]);
|
|
451
|
+
return createBuilder(this, styler, this[IS_EMPTY]);
|
|
1469
452
|
};
|
|
1470
453
|
}
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
454
|
+
};
|
|
455
|
+
}
|
|
456
|
+
var proto = Object.defineProperties(() => {
|
|
457
|
+
}, {
|
|
458
|
+
...styles2,
|
|
459
|
+
level: {
|
|
460
|
+
enumerable: true,
|
|
461
|
+
get() {
|
|
462
|
+
return this[GENERATOR].level;
|
|
463
|
+
},
|
|
464
|
+
set(level) {
|
|
465
|
+
this[GENERATOR].level = level;
|
|
1482
466
|
}
|
|
1483
|
-
var proto = Object.defineProperties(() => {
|
|
1484
|
-
}, {
|
|
1485
|
-
...styles,
|
|
1486
|
-
level: {
|
|
1487
|
-
enumerable: true,
|
|
1488
|
-
get() {
|
|
1489
|
-
return this._generator.level;
|
|
1490
|
-
},
|
|
1491
|
-
set(level) {
|
|
1492
|
-
this._generator.level = level;
|
|
1493
|
-
}
|
|
1494
|
-
}
|
|
1495
|
-
});
|
|
1496
|
-
var createStyler = (open, close, parent) => {
|
|
1497
|
-
let openAll;
|
|
1498
|
-
let closeAll;
|
|
1499
|
-
if (parent === void 0) {
|
|
1500
|
-
openAll = open;
|
|
1501
|
-
closeAll = close;
|
|
1502
|
-
} else {
|
|
1503
|
-
openAll = parent.openAll + open;
|
|
1504
|
-
closeAll = close + parent.closeAll;
|
|
1505
|
-
}
|
|
1506
|
-
return {
|
|
1507
|
-
open,
|
|
1508
|
-
close,
|
|
1509
|
-
openAll,
|
|
1510
|
-
closeAll,
|
|
1511
|
-
parent
|
|
1512
|
-
};
|
|
1513
|
-
};
|
|
1514
|
-
var createBuilder = (self, _styler, _isEmpty) => {
|
|
1515
|
-
const builder = (...arguments_) => {
|
|
1516
|
-
if (isArray(arguments_[0]) && isArray(arguments_[0].raw)) {
|
|
1517
|
-
return applyStyle(builder, chalkTag(builder, ...arguments_));
|
|
1518
|
-
}
|
|
1519
|
-
return applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
|
|
1520
|
-
};
|
|
1521
|
-
Object.setPrototypeOf(builder, proto);
|
|
1522
|
-
builder._generator = self;
|
|
1523
|
-
builder._styler = _styler;
|
|
1524
|
-
builder._isEmpty = _isEmpty;
|
|
1525
|
-
return builder;
|
|
1526
|
-
};
|
|
1527
|
-
var applyStyle = (self, string) => {
|
|
1528
|
-
if (self.level <= 0 || !string) {
|
|
1529
|
-
return self._isEmpty ? "" : string;
|
|
1530
|
-
}
|
|
1531
|
-
let styler = self._styler;
|
|
1532
|
-
if (styler === void 0) {
|
|
1533
|
-
return string;
|
|
1534
|
-
}
|
|
1535
|
-
const { openAll, closeAll } = styler;
|
|
1536
|
-
if (string.indexOf("\x1B") !== -1) {
|
|
1537
|
-
while (styler !== void 0) {
|
|
1538
|
-
string = stringReplaceAll(string, styler.close, styler.open);
|
|
1539
|
-
styler = styler.parent;
|
|
1540
|
-
}
|
|
1541
|
-
}
|
|
1542
|
-
const lfIndex = string.indexOf("\n");
|
|
1543
|
-
if (lfIndex !== -1) {
|
|
1544
|
-
string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
|
|
1545
|
-
}
|
|
1546
|
-
return openAll + string + closeAll;
|
|
1547
|
-
};
|
|
1548
|
-
var template;
|
|
1549
|
-
var chalkTag = (chalk5, ...strings) => {
|
|
1550
|
-
const [firstString] = strings;
|
|
1551
|
-
if (!isArray(firstString) || !isArray(firstString.raw)) {
|
|
1552
|
-
return strings.join(" ");
|
|
1553
|
-
}
|
|
1554
|
-
const arguments_ = strings.slice(1);
|
|
1555
|
-
const parts = [firstString.raw[0]];
|
|
1556
|
-
for (let i = 1; i < firstString.length; i++) {
|
|
1557
|
-
parts.push(
|
|
1558
|
-
String(arguments_[i - 1]).replace(/[{}\\]/g, "\\$&"),
|
|
1559
|
-
String(firstString.raw[i])
|
|
1560
|
-
);
|
|
1561
|
-
}
|
|
1562
|
-
if (template === void 0) {
|
|
1563
|
-
template = require_templates();
|
|
1564
|
-
}
|
|
1565
|
-
return template(chalk5, parts.join(""));
|
|
1566
|
-
};
|
|
1567
|
-
Object.defineProperties(Chalk.prototype, styles);
|
|
1568
|
-
var chalk4 = Chalk();
|
|
1569
|
-
chalk4.supportsColor = stdoutColor;
|
|
1570
|
-
chalk4.stderr = Chalk({ level: stderrColor ? stderrColor.level : 0 });
|
|
1571
|
-
chalk4.stderr.supportsColor = stderrColor;
|
|
1572
|
-
module2.exports = chalk4;
|
|
1573
467
|
}
|
|
1574
468
|
});
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
469
|
+
var createStyler = (open, close, parent) => {
|
|
470
|
+
let openAll;
|
|
471
|
+
let closeAll;
|
|
472
|
+
if (parent === void 0) {
|
|
473
|
+
openAll = open;
|
|
474
|
+
closeAll = close;
|
|
475
|
+
} else {
|
|
476
|
+
openAll = parent.openAll + open;
|
|
477
|
+
closeAll = close + parent.closeAll;
|
|
478
|
+
}
|
|
479
|
+
return {
|
|
480
|
+
open,
|
|
481
|
+
close,
|
|
482
|
+
openAll,
|
|
483
|
+
closeAll,
|
|
484
|
+
parent
|
|
485
|
+
};
|
|
486
|
+
};
|
|
487
|
+
var createBuilder = (self, _styler, _isEmpty) => {
|
|
488
|
+
const builder = (...arguments_) => applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
|
|
489
|
+
Object.setPrototypeOf(builder, proto);
|
|
490
|
+
builder[GENERATOR] = self;
|
|
491
|
+
builder[STYLER] = _styler;
|
|
492
|
+
builder[IS_EMPTY] = _isEmpty;
|
|
493
|
+
return builder;
|
|
494
|
+
};
|
|
495
|
+
var applyStyle = (self, string) => {
|
|
496
|
+
if (self.level <= 0 || !string) {
|
|
497
|
+
return self[IS_EMPTY] ? "" : string;
|
|
498
|
+
}
|
|
499
|
+
let styler = self[STYLER];
|
|
500
|
+
if (styler === void 0) {
|
|
501
|
+
return string;
|
|
502
|
+
}
|
|
503
|
+
const { openAll, closeAll } = styler;
|
|
504
|
+
if (string.includes("\x1B")) {
|
|
505
|
+
while (styler !== void 0) {
|
|
506
|
+
string = stringReplaceAll(string, styler.close, styler.open);
|
|
507
|
+
styler = styler.parent;
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
const lfIndex = string.indexOf("\n");
|
|
511
|
+
if (lfIndex !== -1) {
|
|
512
|
+
string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
|
|
513
|
+
}
|
|
514
|
+
return openAll + string + closeAll;
|
|
515
|
+
};
|
|
516
|
+
Object.defineProperties(createChalk.prototype, styles2);
|
|
517
|
+
var chalk = createChalk();
|
|
518
|
+
var chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
|
|
519
|
+
var source_default = chalk;
|
|
1578
520
|
|
|
1579
521
|
// cli/src/check.ts
|
|
1580
522
|
var import_node_fs = __toESM(require("node:fs"));
|
|
1581
523
|
var import_node_path = __toESM(require("node:path"));
|
|
1582
|
-
var import_chalk = __toESM(require_source());
|
|
1583
524
|
|
|
1584
525
|
// cli/src/wasm.ts
|
|
1585
526
|
var path = __toESM(require("node:path"));
|
|
@@ -2243,6 +1184,55 @@ function collectAttributes(node, conditions, out) {
|
|
|
2243
1184
|
}
|
|
2244
1185
|
}
|
|
2245
1186
|
}
|
|
1187
|
+
function checkUnescapedEntities(rootNode) {
|
|
1188
|
+
const errors = [];
|
|
1189
|
+
function visit(node) {
|
|
1190
|
+
if (node.type === "text") {
|
|
1191
|
+
if (node.text === "&") {
|
|
1192
|
+
errors.push({
|
|
1193
|
+
node,
|
|
1194
|
+
message: 'Unescaped "&" in text content \u2014 use & instead',
|
|
1195
|
+
severity: "warning",
|
|
1196
|
+
fix: [{
|
|
1197
|
+
startIndex: node.startIndex,
|
|
1198
|
+
endIndex: node.endIndex,
|
|
1199
|
+
newText: "&"
|
|
1200
|
+
}],
|
|
1201
|
+
fixDescription: "Replace & with &"
|
|
1202
|
+
});
|
|
1203
|
+
return;
|
|
1204
|
+
}
|
|
1205
|
+
if (node.text.includes(">")) {
|
|
1206
|
+
const fixes = [];
|
|
1207
|
+
let searchFrom = 0;
|
|
1208
|
+
const text2 = node.text;
|
|
1209
|
+
while (true) {
|
|
1210
|
+
const idx = text2.indexOf(">", searchFrom);
|
|
1211
|
+
if (idx === -1) break;
|
|
1212
|
+
fixes.push({
|
|
1213
|
+
startIndex: node.startIndex + idx,
|
|
1214
|
+
endIndex: node.startIndex + idx + 1,
|
|
1215
|
+
newText: ">"
|
|
1216
|
+
});
|
|
1217
|
+
searchFrom = idx + 1;
|
|
1218
|
+
}
|
|
1219
|
+
errors.push({
|
|
1220
|
+
node,
|
|
1221
|
+
message: 'Unescaped ">" in text content \u2014 use > instead',
|
|
1222
|
+
severity: "warning",
|
|
1223
|
+
fix: fixes,
|
|
1224
|
+
fixDescription: "Replace > with >"
|
|
1225
|
+
});
|
|
1226
|
+
return;
|
|
1227
|
+
}
|
|
1228
|
+
}
|
|
1229
|
+
for (const child of node.children) {
|
|
1230
|
+
visit(child);
|
|
1231
|
+
}
|
|
1232
|
+
}
|
|
1233
|
+
visit(rootNode);
|
|
1234
|
+
return errors;
|
|
1235
|
+
}
|
|
2246
1236
|
function checkDuplicateAttributes(rootNode) {
|
|
2247
1237
|
const errors = [];
|
|
2248
1238
|
function visit(node) {
|
|
@@ -2339,7 +1329,8 @@ function collectErrors(tree) {
|
|
|
2339
1329
|
...checkUnquotedMustacheAttributes(tree.rootNode),
|
|
2340
1330
|
...checkConsecutiveSameNameSections(tree.rootNode, sourceText),
|
|
2341
1331
|
...checkSelfClosingNonVoidTags(tree.rootNode),
|
|
2342
|
-
...checkDuplicateAttributes(tree.rootNode)
|
|
1332
|
+
...checkDuplicateAttributes(tree.rootNode),
|
|
1333
|
+
...checkUnescapedEntities(tree.rootNode)
|
|
2343
1334
|
];
|
|
2344
1335
|
for (const error of mustacheChecks) {
|
|
2345
1336
|
errors.push({
|
|
@@ -2373,18 +1364,18 @@ function formatError(error, source) {
|
|
|
2373
1364
|
const lines = source.split("\n");
|
|
2374
1365
|
const errorLine = error.line - 1;
|
|
2375
1366
|
const isWarning = error.severity === "warning";
|
|
2376
|
-
const severityLabel = isWarning ?
|
|
2377
|
-
const colorFn = isWarning ?
|
|
2378
|
-
const header =
|
|
1367
|
+
const severityLabel = isWarning ? source_default.yellow("warning") : source_default.red("error");
|
|
1368
|
+
const colorFn = isWarning ? source_default.yellow : source_default.red;
|
|
1369
|
+
const header = source_default.bold(`${error.file}:${error.line}:${error.column}`) + " " + severityLabel + ": " + error.message;
|
|
2379
1370
|
const contextStart = Math.max(0, errorLine - 2);
|
|
2380
1371
|
const contextEnd = Math.min(lines.length - 1, error.endLine - 1);
|
|
2381
1372
|
const gutterWidth = String(contextEnd + 1).length;
|
|
2382
1373
|
const pad = (n) => String(n).padStart(gutterWidth);
|
|
2383
1374
|
const outputLines = [header];
|
|
2384
|
-
outputLines.push(
|
|
1375
|
+
outputLines.push(source_default.dim(" ".repeat(gutterWidth) + " |"));
|
|
2385
1376
|
for (let i = contextStart; i <= contextEnd; i++) {
|
|
2386
1377
|
const lineNum = i + 1;
|
|
2387
|
-
outputLines.push(
|
|
1378
|
+
outputLines.push(source_default.dim(`${pad(lineNum)} |`) + " " + lines[i]);
|
|
2388
1379
|
}
|
|
2389
1380
|
const lastErrorLineIdx = error.endLine - 1;
|
|
2390
1381
|
const lastLine = lines[lastErrorLineIdx] || "";
|
|
@@ -2399,22 +1390,22 @@ function formatError(error, source) {
|
|
|
2399
1390
|
}
|
|
2400
1391
|
const underlineLength = Math.max(1, underlineEnd - underlineStart);
|
|
2401
1392
|
const underline = " ".repeat(underlineStart) + "^".repeat(underlineLength) + " " + error.message;
|
|
2402
|
-
outputLines.push(
|
|
1393
|
+
outputLines.push(source_default.dim(" ".repeat(gutterWidth) + " |") + " " + colorFn(underline));
|
|
2403
1394
|
return outputLines.join("\n");
|
|
2404
1395
|
}
|
|
2405
1396
|
function formatSummary(totalErrors, filesWithErrors, totalFiles, totalWarnings = 0) {
|
|
2406
1397
|
if (totalErrors === 0 && totalWarnings === 0) {
|
|
2407
|
-
return
|
|
1398
|
+
return source_default.green(`No errors found (${totalFiles} ${totalFiles === 1 ? "file" : "files"} checked)`);
|
|
2408
1399
|
}
|
|
2409
1400
|
const totalStr = totalFiles === 1 ? "file" : "files";
|
|
2410
1401
|
const parts = [];
|
|
2411
1402
|
if (totalErrors > 0) {
|
|
2412
1403
|
const errStr = totalErrors === 1 ? "error" : "errors";
|
|
2413
|
-
parts.push(
|
|
1404
|
+
parts.push(source_default.red(`${totalErrors} ${errStr}`));
|
|
2414
1405
|
}
|
|
2415
1406
|
if (totalWarnings > 0) {
|
|
2416
1407
|
const warnStr = totalWarnings === 1 ? "warning" : "warnings";
|
|
2417
|
-
parts.push(
|
|
1408
|
+
parts.push(source_default.yellow(`${totalWarnings} ${warnStr}`));
|
|
2418
1409
|
}
|
|
2419
1410
|
const errFileStr = filesWithErrors === 1 ? "file" : "files";
|
|
2420
1411
|
return `${parts.join(", ")} in ${filesWithErrors} ${errFileStr} (${totalFiles} ${totalStr} checked)`;
|
|
@@ -2526,9 +1517,9 @@ async function run(args) {
|
|
|
2526
1517
|
return 1;
|
|
2527
1518
|
}
|
|
2528
1519
|
const displayPatterns = patterns.length > 0 ? patterns : config?.include ?? [];
|
|
2529
|
-
console.error(
|
|
1520
|
+
console.error(source_default.yellow("No files matched the given patterns:"));
|
|
2530
1521
|
for (const p of displayPatterns) {
|
|
2531
|
-
console.error(
|
|
1522
|
+
console.error(source_default.yellow(` ${p}`));
|
|
2532
1523
|
}
|
|
2533
1524
|
return 1;
|
|
2534
1525
|
}
|
|
@@ -2562,7 +1553,7 @@ async function run(args) {
|
|
|
2562
1553
|
errorOutput.push(formatError(error, source));
|
|
2563
1554
|
}
|
|
2564
1555
|
}
|
|
2565
|
-
console.log(errors.length > 0 ? fileErrors.length > 0 ?
|
|
1556
|
+
console.log(errors.length > 0 ? fileErrors.length > 0 ? source_default.red(displayPath) : source_default.yellow(displayPath) : source_default.dim(displayPath));
|
|
2566
1557
|
}
|
|
2567
1558
|
if (errorOutput.length > 0) {
|
|
2568
1559
|
console.log();
|
|
@@ -2579,7 +1570,6 @@ async function run(args) {
|
|
|
2579
1570
|
var import_node_fs2 = __toESM(require("node:fs"));
|
|
2580
1571
|
var import_node_path2 = __toESM(require("node:path"));
|
|
2581
1572
|
var import_node_url = require("node:url");
|
|
2582
|
-
var import_chalk2 = __toESM(require_source());
|
|
2583
1573
|
|
|
2584
1574
|
// node_modules/vscode-languageserver-textdocument/lib/esm/main.js
|
|
2585
1575
|
var FullTextDocument = class _FullTextDocument {
|
|
@@ -4285,7 +3275,7 @@ function parseFlags(args) {
|
|
|
4285
3275
|
i++;
|
|
4286
3276
|
flags.indentSize = parseInt(args[i], 10);
|
|
4287
3277
|
if (isNaN(flags.indentSize)) {
|
|
4288
|
-
console.error(
|
|
3278
|
+
console.error(source_default.red("Error: --indent-size requires a number"));
|
|
4289
3279
|
process.exit(1);
|
|
4290
3280
|
}
|
|
4291
3281
|
break;
|
|
@@ -4293,7 +3283,7 @@ function parseFlags(args) {
|
|
|
4293
3283
|
i++;
|
|
4294
3284
|
flags.printWidth = parseInt(args[i], 10);
|
|
4295
3285
|
if (isNaN(flags.printWidth)) {
|
|
4296
|
-
console.error(
|
|
3286
|
+
console.error(source_default.red("Error: --print-width requires a number"));
|
|
4297
3287
|
process.exit(1);
|
|
4298
3288
|
}
|
|
4299
3289
|
break;
|
|
@@ -4375,9 +3365,9 @@ async function run2(args) {
|
|
|
4375
3365
|
return 1;
|
|
4376
3366
|
}
|
|
4377
3367
|
const patterns = flags.patterns.length > 0 ? flags.patterns : config?.include ?? [];
|
|
4378
|
-
console.error(
|
|
3368
|
+
console.error(source_default.yellow("No files matched the given patterns:"));
|
|
4379
3369
|
for (const pattern of patterns) {
|
|
4380
|
-
console.error(
|
|
3370
|
+
console.error(source_default.yellow(` ${pattern}`));
|
|
4381
3371
|
}
|
|
4382
3372
|
return 1;
|
|
4383
3373
|
}
|
|
@@ -4392,25 +3382,25 @@ async function run2(args) {
|
|
|
4392
3382
|
const changed = formatted !== source;
|
|
4393
3383
|
if (changed) changedCount++;
|
|
4394
3384
|
if (flags.check) {
|
|
4395
|
-
console.log(changed ?
|
|
3385
|
+
console.log(changed ? source_default.red(displayPath) : source_default.dim(displayPath));
|
|
4396
3386
|
} else if (flags.write) {
|
|
4397
3387
|
if (changed) {
|
|
4398
3388
|
import_node_fs2.default.writeFileSync(file, formatted);
|
|
4399
3389
|
}
|
|
4400
|
-
console.log(changed ?
|
|
3390
|
+
console.log(changed ? source_default.green(displayPath) : source_default.dim(displayPath));
|
|
4401
3391
|
} else {
|
|
4402
3392
|
process.stdout.write(formatted);
|
|
4403
3393
|
}
|
|
4404
3394
|
}
|
|
4405
3395
|
if (flags.check && changedCount > 0) {
|
|
4406
3396
|
console.log(
|
|
4407
|
-
|
|
3397
|
+
source_default.red(`
|
|
4408
3398
|
${changedCount} ${changedCount === 1 ? "file" : "files"} would be reformatted`)
|
|
4409
3399
|
);
|
|
4410
3400
|
return 1;
|
|
4411
3401
|
}
|
|
4412
3402
|
if (flags.check) {
|
|
4413
|
-
console.log(
|
|
3403
|
+
console.log(source_default.green(`All ${files.length} ${files.length === 1 ? "file" : "files"} already formatted`));
|
|
4414
3404
|
}
|
|
4415
3405
|
return 0;
|
|
4416
3406
|
}
|
|
@@ -4440,7 +3430,7 @@ async function main() {
|
|
|
4440
3430
|
process.exit(command ? 0 : 1);
|
|
4441
3431
|
break;
|
|
4442
3432
|
default:
|
|
4443
|
-
console.error(
|
|
3433
|
+
console.error(source_default.red(`Unknown command: ${command}`));
|
|
4444
3434
|
console.error('Run "htmlmustache --help" for usage.');
|
|
4445
3435
|
process.exit(1);
|
|
4446
3436
|
}
|