@reteps/tree-sitter-htmlmustache 0.3.1 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli/out/main.js +776 -1702
- 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
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
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
|
-
const x = r * 0.4124 + g * 0.3576 + b * 0.1805;
|
|
351
|
-
const y = r * 0.2126 + g * 0.7152 + b * 0.0722;
|
|
352
|
-
const z = r * 0.0193 + g * 0.1192 + b * 0.9505;
|
|
353
|
-
return [x * 100, y * 100, z * 100];
|
|
354
|
-
};
|
|
355
|
-
convert.rgb.lab = function(rgb) {
|
|
356
|
-
const xyz = convert.rgb.xyz(rgb);
|
|
357
|
-
let x = xyz[0];
|
|
358
|
-
let y = xyz[1];
|
|
359
|
-
let z = xyz[2];
|
|
360
|
-
x /= 95.047;
|
|
361
|
-
y /= 100;
|
|
362
|
-
z /= 108.883;
|
|
363
|
-
x = x > 8856e-6 ? x ** (1 / 3) : 7.787 * x + 16 / 116;
|
|
364
|
-
y = y > 8856e-6 ? y ** (1 / 3) : 7.787 * y + 16 / 116;
|
|
365
|
-
z = z > 8856e-6 ? z ** (1 / 3) : 7.787 * z + 16 / 116;
|
|
366
|
-
const l = 116 * y - 16;
|
|
367
|
-
const a = 500 * (x - y);
|
|
368
|
-
const b = 200 * (y - z);
|
|
369
|
-
return [l, a, b];
|
|
370
|
-
};
|
|
371
|
-
convert.hsl.rgb = function(hsl) {
|
|
372
|
-
const h = hsl[0] / 360;
|
|
373
|
-
const s = hsl[1] / 100;
|
|
374
|
-
const l = hsl[2] / 100;
|
|
375
|
-
let t2;
|
|
376
|
-
let t3;
|
|
377
|
-
let val;
|
|
378
|
-
if (s === 0) {
|
|
379
|
-
val = l * 255;
|
|
380
|
-
return [val, val, val];
|
|
381
|
-
}
|
|
382
|
-
if (l < 0.5) {
|
|
383
|
-
t2 = l * (1 + s);
|
|
384
|
-
} else {
|
|
385
|
-
t2 = l + s - l * s;
|
|
386
|
-
}
|
|
387
|
-
const t1 = 2 * l - t2;
|
|
388
|
-
const rgb = [0, 0, 0];
|
|
389
|
-
for (let i = 0; i < 3; i++) {
|
|
390
|
-
t3 = h + 1 / 3 * -(i - 1);
|
|
391
|
-
if (t3 < 0) {
|
|
392
|
-
t3++;
|
|
393
|
-
}
|
|
394
|
-
if (t3 > 1) {
|
|
395
|
-
t3--;
|
|
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;
|
|
103
|
+
group2[styleName] = styles[styleName];
|
|
104
|
+
codes.set(style[0], style[1]);
|
|
105
|
+
}
|
|
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
|
-
|
|
405
|
-
|
|
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;
|
|
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;
|
|
628
185
|
}
|
|
629
|
-
|
|
630
|
-
|
|
186
|
+
const value = Math.max(red, green, blue) * 2;
|
|
187
|
+
if (value === 0) {
|
|
188
|
+
return 30;
|
|
631
189
|
}
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
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;
|
|
190
|
+
let result = 30 + (Math.round(blue) << 2 | Math.round(green) << 1 | Math.round(red));
|
|
191
|
+
if (value === 2) {
|
|
192
|
+
result += 60;
|
|
642
193
|
}
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
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
|
-
});
|
|
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
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
return styles;
|
|
208
|
+
}
|
|
209
|
+
var ansiStyles = assembleStyles();
|
|
210
|
+
var ansi_styles_default = ansiStyles;
|
|
856
211
|
|
|
857
|
-
// node_modules/color
|
|
858
|
-
var
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
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
|
-
}
|
|
889
|
-
}
|
|
890
|
-
}
|
|
891
|
-
return graph;
|
|
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;
|
|
892
233
|
}
|
|
893
|
-
|
|
894
|
-
return
|
|
895
|
-
return to(from(args));
|
|
896
|
-
};
|
|
234
|
+
if (env.FORCE_COLOR === "false") {
|
|
235
|
+
return 0;
|
|
897
236
|
}
|
|
898
|
-
|
|
899
|
-
const path5 = [graph[toModel].parent, toModel];
|
|
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;
|
|
909
|
-
}
|
|
910
|
-
module2.exports = function(fromModel) {
|
|
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
|
-
"node_modules/color-convert/index.js"(exports2, module2) {
|
|
930
|
-
var conversions = require_conversions();
|
|
931
|
-
var route = require_route();
|
|
932
|
-
var convert = {};
|
|
933
|
-
var models = Object.keys(conversions);
|
|
934
|
-
function wrapRaw(fn) {
|
|
935
|
-
const wrappedFn = function(...args) {
|
|
936
|
-
const arg0 = args[0];
|
|
937
|
-
if (arg0 === void 0 || arg0 === null) {
|
|
938
|
-
return arg0;
|
|
939
|
-
}
|
|
940
|
-
if (arg0.length > 1) {
|
|
941
|
-
args = arg0;
|
|
942
|
-
}
|
|
943
|
-
return fn(args);
|
|
944
|
-
};
|
|
945
|
-
if ("conversion" in fn) {
|
|
946
|
-
wrappedFn.conversion = fn.conversion;
|
|
947
|
-
}
|
|
948
|
-
return wrappedFn;
|
|
949
|
-
}
|
|
950
|
-
function wrapRounded(fn) {
|
|
951
|
-
const wrappedFn = function(...args) {
|
|
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;
|
|
971
|
-
}
|
|
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;
|
|
239
|
+
}
|
|
240
|
+
function translateLevel(level) {
|
|
241
|
+
if (level === 0) {
|
|
242
|
+
return false;
|
|
985
243
|
}
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
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
|
-
});
|
|
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;
|
|
1127
255
|
}
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
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
|
-
};
|
|
256
|
+
const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
|
|
257
|
+
if (forceColor === 0) {
|
|
258
|
+
return 0;
|
|
1140
259
|
}
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
var require_supports_color = __commonJS({
|
|
1145
|
-
"node_modules/supports-color/index.js"(exports2, module2) {
|
|
1146
|
-
"use strict";
|
|
1147
|
-
var os = require("os");
|
|
1148
|
-
var tty = require("tty");
|
|
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;
|
|
1156
|
-
}
|
|
1157
|
-
if ("FORCE_COLOR" in env) {
|
|
1158
|
-
if (env.FORCE_COLOR === "true") {
|
|
1159
|
-
forceColor = 1;
|
|
1160
|
-
} else if (env.FORCE_COLOR === "false") {
|
|
1161
|
-
forceColor = 0;
|
|
1162
|
-
} else {
|
|
1163
|
-
forceColor = env.FORCE_COLOR.length === 0 ? 1 : Math.min(parseInt(env.FORCE_COLOR, 10), 3);
|
|
1164
|
-
}
|
|
260
|
+
if (sniffFlags) {
|
|
261
|
+
if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
|
|
262
|
+
return 3;
|
|
1165
263
|
}
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
return false;
|
|
1169
|
-
}
|
|
1170
|
-
return {
|
|
1171
|
-
level,
|
|
1172
|
-
hasBasic: true,
|
|
1173
|
-
has256: level >= 2,
|
|
1174
|
-
has16m: level >= 3
|
|
1175
|
-
};
|
|
264
|
+
if (hasFlag("color=256")) {
|
|
265
|
+
return 2;
|
|
1176
266
|
}
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
return min;
|
|
1193
|
-
}
|
|
1194
|
-
if (process.platform === "win32") {
|
|
1195
|
-
const osRelease = os.release().split(".");
|
|
1196
|
-
if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
|
|
1197
|
-
return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
|
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
|
-
}
|
|
1221
|
-
}
|
|
1222
|
-
if (/-256(color)?$/i.test(env.TERM)) {
|
|
1223
|
-
return 2;
|
|
1224
|
-
}
|
|
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;
|
|
267
|
+
}
|
|
268
|
+
if ("TF_BUILD" in env && "AGENT_NAME" in env) {
|
|
269
|
+
return 1;
|
|
270
|
+
}
|
|
271
|
+
if (haveStream && !streamIsTTY && forceColor === void 0) {
|
|
272
|
+
return 0;
|
|
273
|
+
}
|
|
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;
|
|
1232
282
|
}
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
283
|
+
return 1;
|
|
284
|
+
}
|
|
285
|
+
if ("CI" in env) {
|
|
286
|
+
if (["GITHUB_ACTIONS", "GITEA_ACTIONS", "CIRCLECI"].some((key) => key in env)) {
|
|
287
|
+
return 3;
|
|
288
|
+
}
|
|
289
|
+
if (["TRAVIS", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
|
|
290
|
+
return 1;
|
|
1236
291
|
}
|
|
1237
|
-
|
|
1238
|
-
supportsColor: getSupportLevel,
|
|
1239
|
-
stdout: translateLevel(supportsColor(true, tty.isatty(1))),
|
|
1240
|
-
stderr: translateLevel(supportsColor(true, tty.isatty(2)))
|
|
1241
|
-
};
|
|
292
|
+
return min;
|
|
1242
293
|
}
|
|
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
|
-
};
|
|
294
|
+
if ("TEAMCITY_VERSION" in env) {
|
|
295
|
+
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
|
|
1281
296
|
}
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
["0", "\0"],
|
|
1300
|
-
["\\", "\\"],
|
|
1301
|
-
["e", "\x1B"],
|
|
1302
|
-
["a", "\x07"]
|
|
1303
|
-
]);
|
|
1304
|
-
function unescape(c) {
|
|
1305
|
-
const u = c[0] === "u";
|
|
1306
|
-
const bracket = c[1] === "{";
|
|
1307
|
-
if (u && !bracket && c.length === 5 || c[0] === "x" && c.length === 3) {
|
|
1308
|
-
return String.fromCharCode(parseInt(c.slice(1), 16));
|
|
1309
|
-
}
|
|
1310
|
-
if (u && bracket) {
|
|
1311
|
-
return String.fromCodePoint(parseInt(c.slice(2, -1), 16));
|
|
1312
|
-
}
|
|
1313
|
-
return ESCAPES.get(c) || c;
|
|
1314
|
-
}
|
|
1315
|
-
function parseArguments(name, arguments_) {
|
|
1316
|
-
const results = [];
|
|
1317
|
-
const chunks = arguments_.trim().split(/\s*,\s*/g);
|
|
1318
|
-
let matches;
|
|
1319
|
-
for (const chunk of chunks) {
|
|
1320
|
-
const number = Number(chunk);
|
|
1321
|
-
if (!Number.isNaN(number)) {
|
|
1322
|
-
results.push(number);
|
|
1323
|
-
} else if (matches = chunk.match(STRING_REGEX)) {
|
|
1324
|
-
results.push(matches[2].replace(ESCAPE_REGEX, (m, escape, character) => escape ? unescape(escape) : character));
|
|
1325
|
-
} else {
|
|
1326
|
-
throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`);
|
|
1327
|
-
}
|
|
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;
|
|
1328
314
|
}
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
function parseStyle(style) {
|
|
1332
|
-
STYLE_REGEX.lastIndex = 0;
|
|
1333
|
-
const results = [];
|
|
1334
|
-
let matches;
|
|
1335
|
-
while ((matches = STYLE_REGEX.exec(style)) !== null) {
|
|
1336
|
-
const name = matches[1];
|
|
1337
|
-
if (matches[2]) {
|
|
1338
|
-
const args = parseArguments(name, matches[2]);
|
|
1339
|
-
results.push([name].concat(args));
|
|
1340
|
-
} else {
|
|
1341
|
-
results.push([name]);
|
|
1342
|
-
}
|
|
315
|
+
case "Apple_Terminal": {
|
|
316
|
+
return 2;
|
|
1343
317
|
}
|
|
1344
|
-
return results;
|
|
1345
318
|
}
|
|
1346
|
-
function buildStyle(chalk4, styles) {
|
|
1347
|
-
const enabled = {};
|
|
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;
|
|
1364
|
-
}
|
|
1365
|
-
module2.exports = (chalk4, temporary) => {
|
|
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
|
-
};
|
|
1395
319
|
}
|
|
1396
|
-
|
|
320
|
+
if (/-256(color)?$/i.test(env.TERM)) {
|
|
321
|
+
return 2;
|
|
322
|
+
}
|
|
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;
|
|
343
|
+
|
|
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
|
+
}
|
|
1397
373
|
|
|
1398
374
|
// node_modules/chalk/source/index.js
|
|
1399
|
-
var
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
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);
|
|
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;
|
|
1442
409
|
}
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
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_);
|
|
1451
423
|
}
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
const builder = createBuilder(this, this._styler, true);
|
|
1455
|
-
Object.defineProperty(this, "visible", { value: builder });
|
|
1456
|
-
return builder;
|
|
1457
|
-
}
|
|
1458
|
-
};
|
|
1459
|
-
var usedModels = ["rgb", "hex", "keyword", "hsl", "hsv", "hwb", "ansi", "ansi256"];
|
|
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
|
-
}
|
|
1469
|
-
};
|
|
424
|
+
if (level === "ansi256") {
|
|
425
|
+
return ansi_styles_default[type].ansi256(ansi_styles_default.rgbToAnsi256(...arguments_));
|
|
1470
426
|
}
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
427
|
+
return ansi_styles_default[type].ansi(ansi_styles_default.rgbToAnsi(...arguments_));
|
|
428
|
+
}
|
|
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]);
|
|
1481
442
|
};
|
|
1482
443
|
}
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
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(" "));
|
|
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]);
|
|
1520
452
|
};
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
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;
|
|
453
|
+
}
|
|
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;
|
|
466
|
+
}
|
|
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"));
|
|
@@ -1603,6 +544,25 @@ function parseDocument(source) {
|
|
|
1603
544
|
// lsp/server/src/configFile.ts
|
|
1604
545
|
var fs = __toESM(require("fs"));
|
|
1605
546
|
var path2 = __toESM(require("path"));
|
|
547
|
+
var VALID_CSS_DISPLAY_VALUES = /* @__PURE__ */ new Set([
|
|
548
|
+
"block",
|
|
549
|
+
"inline",
|
|
550
|
+
"inline-block",
|
|
551
|
+
"table-row",
|
|
552
|
+
"table-cell",
|
|
553
|
+
"table",
|
|
554
|
+
"table-row-group",
|
|
555
|
+
"table-header-group",
|
|
556
|
+
"table-footer-group",
|
|
557
|
+
"table-column",
|
|
558
|
+
"table-column-group",
|
|
559
|
+
"table-caption",
|
|
560
|
+
"list-item",
|
|
561
|
+
"ruby",
|
|
562
|
+
"ruby-base",
|
|
563
|
+
"ruby-text",
|
|
564
|
+
"none"
|
|
565
|
+
]);
|
|
1606
566
|
var CONFIG_FILENAME = ".htmlmustache.jsonc";
|
|
1607
567
|
function parseJsonc(text2) {
|
|
1608
568
|
let result = "";
|
|
@@ -1658,6 +618,31 @@ function findConfigFile(startDir) {
|
|
|
1658
618
|
}
|
|
1659
619
|
}
|
|
1660
620
|
var VALID_INDENT_MODES = /* @__PURE__ */ new Set(["never", "always", "attribute"]);
|
|
621
|
+
function parseCustomTagArray(arr) {
|
|
622
|
+
if (!Array.isArray(arr)) return [];
|
|
623
|
+
const tags = [];
|
|
624
|
+
for (const entry of arr) {
|
|
625
|
+
if (entry && typeof entry === "object" && "name" in entry) {
|
|
626
|
+
const e = entry;
|
|
627
|
+
if (typeof e.name !== "string" || e.name.length === 0) continue;
|
|
628
|
+
const tag = { name: e.name };
|
|
629
|
+
if (typeof e.display === "string" && VALID_CSS_DISPLAY_VALUES.has(e.display)) {
|
|
630
|
+
tag.display = e.display;
|
|
631
|
+
}
|
|
632
|
+
if (typeof e.languageAttribute === "string") tag.languageAttribute = e.languageAttribute;
|
|
633
|
+
if (e.languageMap && typeof e.languageMap === "object" && !Array.isArray(e.languageMap)) {
|
|
634
|
+
tag.languageMap = e.languageMap;
|
|
635
|
+
}
|
|
636
|
+
if (typeof e.languageDefault === "string") tag.languageDefault = e.languageDefault;
|
|
637
|
+
if (typeof e.indent === "string" && VALID_INDENT_MODES.has(e.indent)) {
|
|
638
|
+
tag.indent = e.indent;
|
|
639
|
+
}
|
|
640
|
+
if (typeof e.indentAttribute === "string") tag.indentAttribute = e.indentAttribute;
|
|
641
|
+
tags.push(tag);
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
return tags;
|
|
645
|
+
}
|
|
1661
646
|
function validateConfig(raw) {
|
|
1662
647
|
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return {};
|
|
1663
648
|
const obj = raw;
|
|
@@ -1671,6 +656,12 @@ function validateConfig(raw) {
|
|
|
1671
656
|
if (typeof obj.mustacheSpaces === "boolean") {
|
|
1672
657
|
config.mustacheSpaces = obj.mustacheSpaces;
|
|
1673
658
|
}
|
|
659
|
+
if (Array.isArray(obj.noBreakDelimiters)) {
|
|
660
|
+
const items = obj.noBreakDelimiters.filter(
|
|
661
|
+
(s) => typeof s === "string" && s.length > 0
|
|
662
|
+
);
|
|
663
|
+
if (items.length > 0) config.noBreakDelimiters = items;
|
|
664
|
+
}
|
|
1674
665
|
if (Array.isArray(obj.include)) {
|
|
1675
666
|
const items = obj.include.filter((s) => typeof s === "string" && s.length > 0);
|
|
1676
667
|
if (items.length > 0) config.include = items;
|
|
@@ -1679,26 +670,17 @@ function validateConfig(raw) {
|
|
|
1679
670
|
const items = obj.exclude.filter((s) => typeof s === "string" && s.length > 0);
|
|
1680
671
|
if (items.length > 0) config.exclude = items;
|
|
1681
672
|
}
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
tag.languageMap = e.languageMap;
|
|
1692
|
-
}
|
|
1693
|
-
if (typeof e.languageDefault === "string") tag.languageDefault = e.languageDefault;
|
|
1694
|
-
if (typeof e.indent === "string" && VALID_INDENT_MODES.has(e.indent)) {
|
|
1695
|
-
tag.indent = e.indent;
|
|
1696
|
-
}
|
|
1697
|
-
if (typeof e.indentAttribute === "string") tag.indentAttribute = e.indentAttribute;
|
|
1698
|
-
tags.push(tag);
|
|
1699
|
-
}
|
|
673
|
+
const parsedCodeTags = parseCustomTagArray(obj.customCodeTags);
|
|
674
|
+
const parsedCustomTags = parseCustomTagArray(obj.customTags);
|
|
675
|
+
if (parsedCodeTags.length > 0 || parsedCustomTags.length > 0) {
|
|
676
|
+
const mergedMap = /* @__PURE__ */ new Map();
|
|
677
|
+
for (const tag of parsedCodeTags) {
|
|
678
|
+
mergedMap.set(tag.name.toLowerCase(), tag);
|
|
679
|
+
}
|
|
680
|
+
for (const tag of parsedCustomTags) {
|
|
681
|
+
mergedMap.set(tag.name.toLowerCase(), tag);
|
|
1700
682
|
}
|
|
1701
|
-
|
|
683
|
+
config.customTags = Array.from(mergedMap.values());
|
|
1702
684
|
}
|
|
1703
685
|
return config;
|
|
1704
686
|
}
|
|
@@ -2423,18 +1405,18 @@ function formatError(error, source) {
|
|
|
2423
1405
|
const lines = source.split("\n");
|
|
2424
1406
|
const errorLine = error.line - 1;
|
|
2425
1407
|
const isWarning = error.severity === "warning";
|
|
2426
|
-
const severityLabel = isWarning ?
|
|
2427
|
-
const colorFn = isWarning ?
|
|
2428
|
-
const header =
|
|
1408
|
+
const severityLabel = isWarning ? source_default.yellow("warning") : source_default.red("error");
|
|
1409
|
+
const colorFn = isWarning ? source_default.yellow : source_default.red;
|
|
1410
|
+
const header = source_default.bold(`${error.file}:${error.line}:${error.column}`) + " " + severityLabel + ": " + error.message;
|
|
2429
1411
|
const contextStart = Math.max(0, errorLine - 2);
|
|
2430
1412
|
const contextEnd = Math.min(lines.length - 1, error.endLine - 1);
|
|
2431
1413
|
const gutterWidth = String(contextEnd + 1).length;
|
|
2432
1414
|
const pad = (n) => String(n).padStart(gutterWidth);
|
|
2433
1415
|
const outputLines = [header];
|
|
2434
|
-
outputLines.push(
|
|
1416
|
+
outputLines.push(source_default.dim(" ".repeat(gutterWidth) + " |"));
|
|
2435
1417
|
for (let i = contextStart; i <= contextEnd; i++) {
|
|
2436
1418
|
const lineNum = i + 1;
|
|
2437
|
-
outputLines.push(
|
|
1419
|
+
outputLines.push(source_default.dim(`${pad(lineNum)} |`) + " " + lines[i]);
|
|
2438
1420
|
}
|
|
2439
1421
|
const lastErrorLineIdx = error.endLine - 1;
|
|
2440
1422
|
const lastLine = lines[lastErrorLineIdx] || "";
|
|
@@ -2449,22 +1431,22 @@ function formatError(error, source) {
|
|
|
2449
1431
|
}
|
|
2450
1432
|
const underlineLength = Math.max(1, underlineEnd - underlineStart);
|
|
2451
1433
|
const underline = " ".repeat(underlineStart) + "^".repeat(underlineLength) + " " + error.message;
|
|
2452
|
-
outputLines.push(
|
|
1434
|
+
outputLines.push(source_default.dim(" ".repeat(gutterWidth) + " |") + " " + colorFn(underline));
|
|
2453
1435
|
return outputLines.join("\n");
|
|
2454
1436
|
}
|
|
2455
1437
|
function formatSummary(totalErrors, filesWithErrors, totalFiles, totalWarnings = 0) {
|
|
2456
1438
|
if (totalErrors === 0 && totalWarnings === 0) {
|
|
2457
|
-
return
|
|
1439
|
+
return source_default.green(`No errors found (${totalFiles} ${totalFiles === 1 ? "file" : "files"} checked)`);
|
|
2458
1440
|
}
|
|
2459
1441
|
const totalStr = totalFiles === 1 ? "file" : "files";
|
|
2460
1442
|
const parts = [];
|
|
2461
1443
|
if (totalErrors > 0) {
|
|
2462
1444
|
const errStr = totalErrors === 1 ? "error" : "errors";
|
|
2463
|
-
parts.push(
|
|
1445
|
+
parts.push(source_default.red(`${totalErrors} ${errStr}`));
|
|
2464
1446
|
}
|
|
2465
1447
|
if (totalWarnings > 0) {
|
|
2466
1448
|
const warnStr = totalWarnings === 1 ? "warning" : "warnings";
|
|
2467
|
-
parts.push(
|
|
1449
|
+
parts.push(source_default.yellow(`${totalWarnings} ${warnStr}`));
|
|
2468
1450
|
}
|
|
2469
1451
|
const errFileStr = filesWithErrors === 1 ? "file" : "files";
|
|
2470
1452
|
return `${parts.join(", ")} in ${filesWithErrors} ${errFileStr} (${totalFiles} ${totalStr} checked)`;
|
|
@@ -2576,9 +1558,9 @@ async function run(args) {
|
|
|
2576
1558
|
return 1;
|
|
2577
1559
|
}
|
|
2578
1560
|
const displayPatterns = patterns.length > 0 ? patterns : config?.include ?? [];
|
|
2579
|
-
console.error(
|
|
1561
|
+
console.error(source_default.yellow("No files matched the given patterns:"));
|
|
2580
1562
|
for (const p of displayPatterns) {
|
|
2581
|
-
console.error(
|
|
1563
|
+
console.error(source_default.yellow(` ${p}`));
|
|
2582
1564
|
}
|
|
2583
1565
|
return 1;
|
|
2584
1566
|
}
|
|
@@ -2612,7 +1594,7 @@ async function run(args) {
|
|
|
2612
1594
|
errorOutput.push(formatError(error, source));
|
|
2613
1595
|
}
|
|
2614
1596
|
}
|
|
2615
|
-
console.log(errors.length > 0 ? fileErrors.length > 0 ?
|
|
1597
|
+
console.log(errors.length > 0 ? fileErrors.length > 0 ? source_default.red(displayPath) : source_default.yellow(displayPath) : source_default.dim(displayPath));
|
|
2616
1598
|
}
|
|
2617
1599
|
if (errorOutput.length > 0) {
|
|
2618
1600
|
console.log();
|
|
@@ -2629,7 +1611,6 @@ async function run(args) {
|
|
|
2629
1611
|
var import_node_fs2 = __toESM(require("node:fs"));
|
|
2630
1612
|
var import_node_path2 = __toESM(require("node:path"));
|
|
2631
1613
|
var import_node_url = require("node:url");
|
|
2632
|
-
var import_chalk2 = __toESM(require_source());
|
|
2633
1614
|
|
|
2634
1615
|
// node_modules/vscode-languageserver-textdocument/lib/esm/main.js
|
|
2635
1616
|
var FullTextDocument = class _FullTextDocument {
|
|
@@ -2858,7 +1839,7 @@ function getWellformedEdit(textEdit) {
|
|
|
2858
1839
|
// lsp/server/src/formatting/printer.ts
|
|
2859
1840
|
function print(doc, options) {
|
|
2860
1841
|
const output = [];
|
|
2861
|
-
const state = { indentLevel: 0, mode: "break" };
|
|
1842
|
+
const state = { indentLevel: 0, mode: "break", groupModes: /* @__PURE__ */ new Map() };
|
|
2862
1843
|
printDoc(doc, state, output, options);
|
|
2863
1844
|
return output.join("");
|
|
2864
1845
|
}
|
|
@@ -2932,20 +1913,23 @@ function printDoc(doc, state, output, options) {
|
|
|
2932
1913
|
if (doc.break || containsBreakParent(doc.contents)) {
|
|
2933
1914
|
const prevMode = state.mode;
|
|
2934
1915
|
state.mode = "break";
|
|
1916
|
+
if (doc.id) state.groupModes.set(doc.id, "break");
|
|
2935
1917
|
printDoc(doc.contents, state, output, options);
|
|
2936
1918
|
state.mode = prevMode;
|
|
2937
1919
|
} else {
|
|
2938
1920
|
const flatOutput = [];
|
|
2939
|
-
const flatState = { ...state, mode: "flat" };
|
|
1921
|
+
const flatState = { ...state, mode: "flat", groupModes: new Map(state.groupModes) };
|
|
2940
1922
|
printDoc(doc.contents, flatState, flatOutput, options);
|
|
2941
1923
|
const flatContent = flatOutput.join("");
|
|
2942
1924
|
const printWidth = options.printWidth ?? 80;
|
|
2943
1925
|
const col = currentColumn(output);
|
|
2944
1926
|
if (!flatContent.includes("\n") && col + flatContent.length <= printWidth) {
|
|
1927
|
+
if (doc.id) state.groupModes.set(doc.id, "flat");
|
|
2945
1928
|
output.push(flatContent);
|
|
2946
1929
|
} else {
|
|
2947
1930
|
const prevMode = state.mode;
|
|
2948
1931
|
state.mode = "break";
|
|
1932
|
+
if (doc.id) state.groupModes.set(doc.id, "break");
|
|
2949
1933
|
printDoc(doc.contents, state, output, options);
|
|
2950
1934
|
state.mode = prevMode;
|
|
2951
1935
|
}
|
|
@@ -2955,13 +1939,15 @@ function printDoc(doc, state, output, options) {
|
|
|
2955
1939
|
case "fill":
|
|
2956
1940
|
printFill(doc.parts, state, output, options);
|
|
2957
1941
|
break;
|
|
2958
|
-
case "ifBreak":
|
|
2959
|
-
|
|
1942
|
+
case "ifBreak": {
|
|
1943
|
+
const effectiveMode = doc.groupId ? state.groupModes.get(doc.groupId) ?? state.mode : state.mode;
|
|
1944
|
+
if (effectiveMode === "break") {
|
|
2960
1945
|
printDoc(doc.breakContents, state, output, options);
|
|
2961
1946
|
} else {
|
|
2962
1947
|
printDoc(doc.flatContents, state, output, options);
|
|
2963
1948
|
}
|
|
2964
1949
|
break;
|
|
1950
|
+
}
|
|
2965
1951
|
case "breakParent":
|
|
2966
1952
|
state.mode = "break";
|
|
2967
1953
|
break;
|
|
@@ -3026,12 +2012,21 @@ function indent(contents) {
|
|
|
3026
2012
|
if (contents === "") return "";
|
|
3027
2013
|
return { type: "indent", contents };
|
|
3028
2014
|
}
|
|
3029
|
-
function
|
|
2015
|
+
function indentN(contents, n) {
|
|
2016
|
+
if (n <= 0 || contents === "") return contents;
|
|
2017
|
+
let result = contents;
|
|
2018
|
+
for (let i = 0; i < n; i++) {
|
|
2019
|
+
result = indent(result);
|
|
2020
|
+
}
|
|
2021
|
+
return result;
|
|
2022
|
+
}
|
|
2023
|
+
function group(contents, options) {
|
|
3030
2024
|
if (contents === "") return "";
|
|
3031
|
-
|
|
2025
|
+
const shouldBreak = options?.shouldBreak;
|
|
2026
|
+
return { type: "group", contents, break: shouldBreak || void 0, id: options?.id };
|
|
3032
2027
|
}
|
|
3033
|
-
function ifBreak(breakContents, flatContents) {
|
|
3034
|
-
return { type: "ifBreak", breakContents, flatContents };
|
|
2028
|
+
function ifBreak(breakContents, flatContents, options) {
|
|
2029
|
+
return { type: "ifBreak", breakContents, flatContents, groupId: options?.groupId };
|
|
3035
2030
|
}
|
|
3036
2031
|
function fill(parts) {
|
|
3037
2032
|
const filtered = parts.filter((p) => p !== "");
|
|
@@ -3119,8 +2114,37 @@ function getIgnoreDirective(node) {
|
|
|
3119
2114
|
return null;
|
|
3120
2115
|
}
|
|
3121
2116
|
|
|
2117
|
+
// lsp/server/src/customCodeTags.ts
|
|
2118
|
+
function isCodeTag(config) {
|
|
2119
|
+
return !!(config.languageAttribute || config.languageDefault);
|
|
2120
|
+
}
|
|
2121
|
+
function getAttributeValue(node, attrName) {
|
|
2122
|
+
for (let i = 0; i < node.childCount; i++) {
|
|
2123
|
+
const child = node.child(i);
|
|
2124
|
+
if (child?.type === "html_start_tag") {
|
|
2125
|
+
for (let j = 0; j < child.childCount; j++) {
|
|
2126
|
+
const attr = child.child(j);
|
|
2127
|
+
if (attr?.type === "html_attribute") {
|
|
2128
|
+
let name = "";
|
|
2129
|
+
let value = "";
|
|
2130
|
+
for (let k = 0; k < attr.childCount; k++) {
|
|
2131
|
+
const part = attr.child(k);
|
|
2132
|
+
if (part?.type === "html_attribute_name") name = part.text.toLowerCase();
|
|
2133
|
+
if (part?.type === "html_quoted_attribute_value") value = part.text.replace(/^["']|["']$/g, "");
|
|
2134
|
+
if (part?.type === "html_attribute_value") value = part.text;
|
|
2135
|
+
}
|
|
2136
|
+
if (name === attrName.toLowerCase()) {
|
|
2137
|
+
return value;
|
|
2138
|
+
}
|
|
2139
|
+
}
|
|
2140
|
+
}
|
|
2141
|
+
}
|
|
2142
|
+
}
|
|
2143
|
+
return null;
|
|
2144
|
+
}
|
|
2145
|
+
|
|
3122
2146
|
// lsp/server/src/formatting/classifier.ts
|
|
3123
|
-
var
|
|
2147
|
+
var EMPTY_MAP = /* @__PURE__ */ new Map();
|
|
3124
2148
|
var CSS_DISPLAY_MAP = {
|
|
3125
2149
|
// Block elements
|
|
3126
2150
|
address: "block",
|
|
@@ -3211,15 +2235,18 @@ var PRESERVE_CONTENT_ELEMENTS = /* @__PURE__ */ new Set([
|
|
|
3211
2235
|
"script",
|
|
3212
2236
|
"style"
|
|
3213
2237
|
]);
|
|
3214
|
-
function getCSSDisplay(node,
|
|
2238
|
+
function getCSSDisplay(node, customTags = EMPTY_MAP) {
|
|
3215
2239
|
const type = node.type;
|
|
3216
2240
|
if (type === "html_element") {
|
|
3217
2241
|
const tagName = getTagName(node);
|
|
3218
2242
|
if (tagName) {
|
|
3219
|
-
|
|
3220
|
-
|
|
2243
|
+
const lower = tagName.toLowerCase();
|
|
2244
|
+
const config = customTags.get(lower);
|
|
2245
|
+
if (config) {
|
|
2246
|
+
if (config.display) return config.display;
|
|
2247
|
+
if (isCodeTag(config)) return "block";
|
|
3221
2248
|
}
|
|
3222
|
-
return CSS_DISPLAY_MAP[
|
|
2249
|
+
return CSS_DISPLAY_MAP[lower] ?? "inline";
|
|
3223
2250
|
}
|
|
3224
2251
|
return "block";
|
|
3225
2252
|
}
|
|
@@ -3227,7 +2254,7 @@ function getCSSDisplay(node, customCodeTags = EMPTY_SET) {
|
|
|
3227
2254
|
return "block";
|
|
3228
2255
|
}
|
|
3229
2256
|
if (isMustacheSection(node)) {
|
|
3230
|
-
return hasBlockContent(node,
|
|
2257
|
+
return hasBlockContent(node, customTags) ? "block" : "inline";
|
|
3231
2258
|
}
|
|
3232
2259
|
return "inline";
|
|
3233
2260
|
}
|
|
@@ -3250,13 +2277,13 @@ function isWhitespaceInsensitive(display) {
|
|
|
3250
2277
|
return false;
|
|
3251
2278
|
}
|
|
3252
2279
|
}
|
|
3253
|
-
function isBlockLevel(node,
|
|
2280
|
+
function isBlockLevel(node, customTags = EMPTY_MAP) {
|
|
3254
2281
|
const type = node.type;
|
|
3255
2282
|
if (isMustacheSection(node)) {
|
|
3256
|
-
return hasBlockContent(node,
|
|
2283
|
+
return hasBlockContent(node, customTags);
|
|
3257
2284
|
}
|
|
3258
2285
|
if (type === "html_element") {
|
|
3259
|
-
const display = getCSSDisplay(node,
|
|
2286
|
+
const display = getCSSDisplay(node, customTags);
|
|
3260
2287
|
return isWhitespaceInsensitive(display);
|
|
3261
2288
|
}
|
|
3262
2289
|
if (isRawContentElement(node)) {
|
|
@@ -3264,7 +2291,7 @@ function isBlockLevel(node, customCodeTags = EMPTY_SET) {
|
|
|
3264
2291
|
}
|
|
3265
2292
|
return false;
|
|
3266
2293
|
}
|
|
3267
|
-
function shouldPreserveContent(node,
|
|
2294
|
+
function shouldPreserveContent(node, customTags = EMPTY_MAP) {
|
|
3268
2295
|
const type = node.type;
|
|
3269
2296
|
if (isRawContentElement(node)) {
|
|
3270
2297
|
return true;
|
|
@@ -3273,23 +2300,25 @@ function shouldPreserveContent(node, customCodeTags = EMPTY_SET) {
|
|
|
3273
2300
|
const tagName = getTagName(node);
|
|
3274
2301
|
if (!tagName) return false;
|
|
3275
2302
|
const lower = tagName.toLowerCase();
|
|
3276
|
-
|
|
2303
|
+
if (PRESERVE_CONTENT_ELEMENTS.has(lower)) return true;
|
|
2304
|
+
const config = customTags.get(lower);
|
|
2305
|
+
if (config && isCodeTag(config)) return true;
|
|
3277
2306
|
}
|
|
3278
2307
|
return false;
|
|
3279
2308
|
}
|
|
3280
|
-
function hasBlockContent(sectionNode,
|
|
2309
|
+
function hasBlockContent(sectionNode, customTags = EMPTY_MAP) {
|
|
3281
2310
|
const contentNodes = getContentNodes(sectionNode);
|
|
3282
2311
|
if (hasImplicitEndTags(contentNodes)) {
|
|
3283
2312
|
return true;
|
|
3284
2313
|
}
|
|
3285
2314
|
for (const node of contentNodes) {
|
|
3286
|
-
if (isBlockLevelContent(node,
|
|
2315
|
+
if (isBlockLevelContent(node, customTags)) {
|
|
3287
2316
|
return true;
|
|
3288
2317
|
}
|
|
3289
2318
|
}
|
|
3290
2319
|
return false;
|
|
3291
2320
|
}
|
|
3292
|
-
function isBlockLevelContent(node,
|
|
2321
|
+
function isBlockLevelContent(node, customTags = EMPTY_MAP) {
|
|
3293
2322
|
const type = node.type;
|
|
3294
2323
|
if (type === "html_element") {
|
|
3295
2324
|
return true;
|
|
@@ -3298,7 +2327,7 @@ function isBlockLevelContent(node, customCodeTags = EMPTY_SET) {
|
|
|
3298
2327
|
return true;
|
|
3299
2328
|
}
|
|
3300
2329
|
if (isMustacheSection(node)) {
|
|
3301
|
-
return hasBlockContent(node,
|
|
2330
|
+
return hasBlockContent(node, customTags);
|
|
3302
2331
|
}
|
|
3303
2332
|
return false;
|
|
3304
2333
|
}
|
|
@@ -3381,10 +2410,13 @@ function hasAdjacentInlineContent(index, nodes) {
|
|
|
3381
2410
|
}
|
|
3382
2411
|
return false;
|
|
3383
2412
|
}
|
|
3384
|
-
function shouldHtmlElementStayInline(node, index, nodes) {
|
|
2413
|
+
function shouldHtmlElementStayInline(node, index, nodes, customTags = EMPTY_MAP) {
|
|
3385
2414
|
if (node.type !== "html_element") {
|
|
3386
2415
|
return false;
|
|
3387
2416
|
}
|
|
2417
|
+
if (isWhitespaceInsensitive(getCSSDisplay(node, customTags))) {
|
|
2418
|
+
return false;
|
|
2419
|
+
}
|
|
3388
2420
|
if (isInTextFlow(node, index, nodes)) {
|
|
3389
2421
|
return true;
|
|
3390
2422
|
}
|
|
@@ -3405,57 +2437,11 @@ function shouldHtmlElementStayInline(node, index, nodes) {
|
|
|
3405
2437
|
}
|
|
3406
2438
|
return false;
|
|
3407
2439
|
}
|
|
3408
|
-
function shouldTreatAsBlock(node, index, nodes,
|
|
2440
|
+
function shouldTreatAsBlock(node, index, nodes, customTags = EMPTY_MAP) {
|
|
3409
2441
|
const isHtmlEl = isHtmlElementType(node);
|
|
3410
2442
|
const isMustacheSec = isMustacheSection(node);
|
|
3411
|
-
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
// lsp/server/src/customCodeTags.ts
|
|
3415
|
-
var VALID_INDENT_MODES2 = /* @__PURE__ */ new Set(["never", "always", "attribute"]);
|
|
3416
|
-
function parseCustomCodeTagSettings(tags) {
|
|
3417
|
-
const tagNames = [];
|
|
3418
|
-
const configs = [];
|
|
3419
|
-
for (const tag of tags) {
|
|
3420
|
-
if (tag && typeof tag === "object" && "name" in tag && typeof tag.name === "string") {
|
|
3421
|
-
const t = tag;
|
|
3422
|
-
const config = { name: t.name };
|
|
3423
|
-
if (typeof t.languageAttribute === "string") config.languageAttribute = t.languageAttribute;
|
|
3424
|
-
if (t.languageMap && typeof t.languageMap === "object") config.languageMap = t.languageMap;
|
|
3425
|
-
if (typeof t.languageDefault === "string") config.languageDefault = t.languageDefault;
|
|
3426
|
-
if (typeof t.indent === "string" && VALID_INDENT_MODES2.has(t.indent)) {
|
|
3427
|
-
config.indent = t.indent;
|
|
3428
|
-
}
|
|
3429
|
-
if (typeof t.indentAttribute === "string") config.indentAttribute = t.indentAttribute;
|
|
3430
|
-
tagNames.push(config.name);
|
|
3431
|
-
configs.push(config);
|
|
3432
|
-
}
|
|
3433
|
-
}
|
|
3434
|
-
return { tagNames, configs };
|
|
3435
|
-
}
|
|
3436
|
-
function getAttributeValue(node, attrName) {
|
|
3437
|
-
for (let i = 0; i < node.childCount; i++) {
|
|
3438
|
-
const child = node.child(i);
|
|
3439
|
-
if (child?.type === "html_start_tag") {
|
|
3440
|
-
for (let j = 0; j < child.childCount; j++) {
|
|
3441
|
-
const attr = child.child(j);
|
|
3442
|
-
if (attr?.type === "html_attribute") {
|
|
3443
|
-
let name = "";
|
|
3444
|
-
let value = "";
|
|
3445
|
-
for (let k = 0; k < attr.childCount; k++) {
|
|
3446
|
-
const part = attr.child(k);
|
|
3447
|
-
if (part?.type === "html_attribute_name") name = part.text.toLowerCase();
|
|
3448
|
-
if (part?.type === "html_quoted_attribute_value") value = part.text.replace(/^["']|["']$/g, "");
|
|
3449
|
-
if (part?.type === "html_attribute_value") value = part.text;
|
|
3450
|
-
}
|
|
3451
|
-
if (name === attrName.toLowerCase()) {
|
|
3452
|
-
return value;
|
|
3453
|
-
}
|
|
3454
|
-
}
|
|
3455
|
-
}
|
|
3456
|
-
}
|
|
3457
|
-
}
|
|
3458
|
-
return null;
|
|
2443
|
+
if (node.type === "html_erroneous_end_tag") return true;
|
|
2444
|
+
return isHtmlEl && !shouldHtmlElementStayInline(node, index, nodes, customTags) || isMustacheSec && !isInTextFlow(node, index, nodes) || isBlockLevel(node, customTags) && !isInTextFlow(node, index, nodes);
|
|
3459
2445
|
}
|
|
3460
2446
|
|
|
3461
2447
|
// lsp/server/src/formatting/formatters.ts
|
|
@@ -3517,7 +2503,7 @@ function formatNode(node, context, forceInline = false) {
|
|
|
3517
2503
|
case "document":
|
|
3518
2504
|
return formatDocument(node, context);
|
|
3519
2505
|
case "html_element":
|
|
3520
|
-
return formatHtmlElement(node, context);
|
|
2506
|
+
return formatHtmlElement(node, context, forceInline);
|
|
3521
2507
|
case "html_script_element":
|
|
3522
2508
|
case "html_style_element":
|
|
3523
2509
|
case "html_raw_element":
|
|
@@ -3550,8 +2536,8 @@ function formatNode(node, context, forceInline = false) {
|
|
|
3550
2536
|
function formatText(node) {
|
|
3551
2537
|
return text(normalizeText(node.text));
|
|
3552
2538
|
}
|
|
3553
|
-
function formatHtmlElement(node, context) {
|
|
3554
|
-
const tags = context.
|
|
2539
|
+
function formatHtmlElement(node, context, forceInline = false) {
|
|
2540
|
+
const tags = context.customTags;
|
|
3555
2541
|
const display = getCSSDisplay(node, tags);
|
|
3556
2542
|
const isBlock = isWhitespaceInsensitive(display);
|
|
3557
2543
|
const preserveContent = shouldPreserveContent(node, tags);
|
|
@@ -3587,7 +2573,7 @@ function formatHtmlElement(node, context) {
|
|
|
3587
2573
|
);
|
|
3588
2574
|
if (preserveContent) {
|
|
3589
2575
|
const tagNameLower = startTag ? getTagNameFromStartTag(startTag) : null;
|
|
3590
|
-
const tagConfig = tagNameLower ? context.
|
|
2576
|
+
const tagConfig = tagNameLower ? context.customTags?.get(tagNameLower) : void 0;
|
|
3591
2577
|
const shouldIndent = tagConfig ? resolveIndentMode(node, tagConfig) : false;
|
|
3592
2578
|
if (shouldIndent && startTag && endTag) {
|
|
3593
2579
|
const rawContent = context.document.getText().slice(
|
|
@@ -3630,7 +2616,26 @@ function formatHtmlElement(node, context) {
|
|
|
3630
2616
|
parts.push(text(child.text));
|
|
3631
2617
|
}
|
|
3632
2618
|
}
|
|
3633
|
-
} else if (!isBlock && !hasHtmlElementChildren
|
|
2619
|
+
} else if (!isBlock && (!hasHtmlElementChildren || forceInline && !contentNodes.some(
|
|
2620
|
+
(child) => isRawContentElement(child) || isBlockLevel(child, tags)
|
|
2621
|
+
))) {
|
|
2622
|
+
if (!forceInline && startTag && startTagHasAttributes(startTag)) {
|
|
2623
|
+
const formattedContent = formatBlockChildren(contentNodes, context);
|
|
2624
|
+
if (hasDocContent(formattedContent)) {
|
|
2625
|
+
const bareStartTag = formatStartTag(startTag, context, true);
|
|
2626
|
+
const outerParts = [
|
|
2627
|
+
group(bareStartTag),
|
|
2628
|
+
indent(concat([softline, formattedContent]))
|
|
2629
|
+
];
|
|
2630
|
+
if (hasRealEndTag) {
|
|
2631
|
+
outerParts.push(softline);
|
|
2632
|
+
}
|
|
2633
|
+
if (endTag) {
|
|
2634
|
+
outerParts.push(formatEndTag(endTag));
|
|
2635
|
+
}
|
|
2636
|
+
return group(concat(outerParts));
|
|
2637
|
+
}
|
|
2638
|
+
}
|
|
3634
2639
|
let prevEnd = startTag ? startTag.endIndex : -1;
|
|
3635
2640
|
for (const child of contentNodes) {
|
|
3636
2641
|
if (prevEnd >= 0 && child.startIndex > prevEnd) {
|
|
@@ -3639,7 +2644,7 @@ function formatHtmlElement(node, context) {
|
|
|
3639
2644
|
parts.push(text(" "));
|
|
3640
2645
|
}
|
|
3641
2646
|
}
|
|
3642
|
-
parts.push(formatNode(child, context));
|
|
2647
|
+
parts.push(formatNode(child, context, forceInline));
|
|
3643
2648
|
prevEnd = child.endIndex;
|
|
3644
2649
|
}
|
|
3645
2650
|
} else {
|
|
@@ -3654,6 +2659,21 @@ function formatHtmlElement(node, context) {
|
|
|
3654
2659
|
return isWhitespaceInsensitive(childDisplay) || isRawContentElement(child);
|
|
3655
2660
|
});
|
|
3656
2661
|
if (isBlock && !hasBlockChildren) {
|
|
2662
|
+
const hasAttrs = startTag && startTagHasAttributes(startTag);
|
|
2663
|
+
if (hasAttrs && startTag) {
|
|
2664
|
+
const bareStartTag = formatStartTag(startTag, context, true);
|
|
2665
|
+
const outerParts = [
|
|
2666
|
+
group(bareStartTag),
|
|
2667
|
+
indent(concat([softline, formattedContent]))
|
|
2668
|
+
];
|
|
2669
|
+
if (hasRealEndTag) {
|
|
2670
|
+
outerParts.push(softline);
|
|
2671
|
+
}
|
|
2672
|
+
if (endTag) {
|
|
2673
|
+
outerParts.push(formatEndTag(endTag));
|
|
2674
|
+
}
|
|
2675
|
+
return group(concat(outerParts));
|
|
2676
|
+
}
|
|
3657
2677
|
const doc = group(
|
|
3658
2678
|
concat([
|
|
3659
2679
|
indent(concat([softline, formattedContent])),
|
|
@@ -3716,7 +2736,7 @@ function formatScriptStyleElement(node, context) {
|
|
|
3716
2736
|
if (node.type === "html_raw_element") {
|
|
3717
2737
|
const startTagNode = node.child(0);
|
|
3718
2738
|
const tagNameLower = startTagNode?.type === "html_start_tag" ? getTagNameFromStartTag(startTagNode) : null;
|
|
3719
|
-
const tagConfig = tagNameLower ? context.
|
|
2739
|
+
const tagConfig = tagNameLower ? context.customTags?.get(tagNameLower) : void 0;
|
|
3720
2740
|
if (tagConfig && resolveIndentMode(node, tagConfig)) {
|
|
3721
2741
|
const dedented = dedentContent(child.text);
|
|
3722
2742
|
if (dedented.length > 0) {
|
|
@@ -3793,27 +2813,37 @@ function formatMustacheSection(node, context) {
|
|
|
3793
2813
|
parts.push(text(mustacheText(beginNode.text, context)));
|
|
3794
2814
|
}
|
|
3795
2815
|
const hasImplicit = hasImplicitEndTags(contentNodes);
|
|
3796
|
-
const
|
|
3797
|
-
|
|
3798
|
-
|
|
3799
|
-
|
|
3800
|
-
|
|
3801
|
-
parts.push(
|
|
3802
|
-
|
|
3803
|
-
|
|
3804
|
-
|
|
3805
|
-
|
|
3806
|
-
|
|
3807
|
-
|
|
3808
|
-
|
|
3809
|
-
return isWhitespaceInsensitive(childDisplay) || isRawContentElement(child);
|
|
3810
|
-
});
|
|
3811
|
-
if (!hasBlockChildren) {
|
|
3812
|
-
parts.push(indent(concat([softline, formattedContent])));
|
|
3813
|
-
parts.push(softline);
|
|
3814
|
-
} else {
|
|
3815
|
-
parts.push(indent(concat([hardline, formattedContent])));
|
|
2816
|
+
const isStaircase = !hasImplicit && contentNodes.length > 0 && contentNodes.every((n) => n.type === "html_erroneous_end_tag");
|
|
2817
|
+
if (isStaircase) {
|
|
2818
|
+
const E = contentNodes.length;
|
|
2819
|
+
for (let i = 0; i < E; i++) {
|
|
2820
|
+
const formatted = formatNode(contentNodes[i], context);
|
|
2821
|
+
parts.push(indentN(concat([hardline, formatted]), E - i));
|
|
2822
|
+
}
|
|
2823
|
+
parts.push(hardline);
|
|
2824
|
+
} else {
|
|
2825
|
+
const formattedContent = formatBlockChildren(contentNodes, context);
|
|
2826
|
+
const hasContent = hasDocContent(formattedContent);
|
|
2827
|
+
if (hasContent) {
|
|
2828
|
+
if (hasImplicit) {
|
|
3816
2829
|
parts.push(hardline);
|
|
2830
|
+
parts.push(formattedContent);
|
|
2831
|
+
parts.push(hardline);
|
|
2832
|
+
} else {
|
|
2833
|
+
const hasBlockChildren = contentNodes.some((child, i) => {
|
|
2834
|
+
if (!shouldTreatAsBlock(child, i, contentNodes, context.customTags)) {
|
|
2835
|
+
return false;
|
|
2836
|
+
}
|
|
2837
|
+
const childDisplay = getCSSDisplay(child, context.customTags);
|
|
2838
|
+
return isWhitespaceInsensitive(childDisplay) || isRawContentElement(child);
|
|
2839
|
+
});
|
|
2840
|
+
if (!hasBlockChildren) {
|
|
2841
|
+
parts.push(indent(concat([softline, formattedContent])));
|
|
2842
|
+
parts.push(softline);
|
|
2843
|
+
} else {
|
|
2844
|
+
parts.push(indent(concat([hardline, formattedContent])));
|
|
2845
|
+
parts.push(hardline);
|
|
2846
|
+
}
|
|
3817
2847
|
}
|
|
3818
2848
|
}
|
|
3819
2849
|
}
|
|
@@ -3822,7 +2852,17 @@ function formatMustacheSection(node, context) {
|
|
|
3822
2852
|
}
|
|
3823
2853
|
return group(concat(parts));
|
|
3824
2854
|
}
|
|
3825
|
-
function
|
|
2855
|
+
function startTagHasAttributes(startTag) {
|
|
2856
|
+
for (let i = 0; i < startTag.childCount; i++) {
|
|
2857
|
+
const child = startTag.child(i);
|
|
2858
|
+
if (!child) continue;
|
|
2859
|
+
if (child.type === "html_attribute" || child.type === "mustache_attribute" || child.type === "mustache_interpolation" || child.type === "mustache_triple") {
|
|
2860
|
+
return true;
|
|
2861
|
+
}
|
|
2862
|
+
}
|
|
2863
|
+
return false;
|
|
2864
|
+
}
|
|
2865
|
+
function formatStartTag(node, context, bare = false) {
|
|
3826
2866
|
let tagNameText = "";
|
|
3827
2867
|
const attrs = [];
|
|
3828
2868
|
for (let i = 0; i < node.childCount; i++) {
|
|
@@ -3855,14 +2895,13 @@ function formatStartTag(node, context) {
|
|
|
3855
2895
|
attrParts.push(attrs[i]);
|
|
3856
2896
|
}
|
|
3857
2897
|
const breakClosingBracket = isSelfClosing ? "/>" : ">";
|
|
3858
|
-
|
|
3859
|
-
|
|
3860
|
-
|
|
3861
|
-
|
|
3862
|
-
|
|
3863
|
-
|
|
3864
|
-
|
|
3865
|
-
);
|
|
2898
|
+
const inner = concat([
|
|
2899
|
+
text("<"),
|
|
2900
|
+
text(tagNameText),
|
|
2901
|
+
indent(concat([line, concat(attrParts)])),
|
|
2902
|
+
ifBreak(concat([hardline, text(breakClosingBracket)]), text(closingBracket))
|
|
2903
|
+
]);
|
|
2904
|
+
return bare ? inner : group(inner);
|
|
3866
2905
|
}
|
|
3867
2906
|
function formatEndTag(node) {
|
|
3868
2907
|
for (let i = 0; i < node.childCount; i++) {
|
|
@@ -3907,6 +2946,38 @@ function textWords(str) {
|
|
|
3907
2946
|
}
|
|
3908
2947
|
return parts;
|
|
3909
2948
|
}
|
|
2949
|
+
function collapseDelimitedRegions(parts, delimiters) {
|
|
2950
|
+
if (delimiters.length === 0) return parts;
|
|
2951
|
+
const sorted = [...delimiters].sort((a, b) => b.length - a.length);
|
|
2952
|
+
const result = [...parts];
|
|
2953
|
+
let activeDelimiter = null;
|
|
2954
|
+
for (let i = 0; i < result.length; i++) {
|
|
2955
|
+
const part = result[i];
|
|
2956
|
+
if (typeof part === "string") {
|
|
2957
|
+
if (activeDelimiter === null) {
|
|
2958
|
+
for (const delim of sorted) {
|
|
2959
|
+
const delimIdx = part.indexOf(delim);
|
|
2960
|
+
if (delimIdx >= 0) {
|
|
2961
|
+
const afterOpen = delimIdx + delim.length;
|
|
2962
|
+
const closeIdx = part.indexOf(delim, afterOpen);
|
|
2963
|
+
if (closeIdx >= 0) {
|
|
2964
|
+
continue;
|
|
2965
|
+
}
|
|
2966
|
+
activeDelimiter = delim;
|
|
2967
|
+
break;
|
|
2968
|
+
}
|
|
2969
|
+
}
|
|
2970
|
+
} else {
|
|
2971
|
+
if (part.includes(activeDelimiter)) {
|
|
2972
|
+
activeDelimiter = null;
|
|
2973
|
+
}
|
|
2974
|
+
}
|
|
2975
|
+
} else if (activeDelimiter !== null && isLine(part)) {
|
|
2976
|
+
result[i] = " ";
|
|
2977
|
+
}
|
|
2978
|
+
}
|
|
2979
|
+
return result;
|
|
2980
|
+
}
|
|
3910
2981
|
function inlineContentToFill(parts) {
|
|
3911
2982
|
if (parts.length === 0) return empty;
|
|
3912
2983
|
if (parts.length === 1) return parts[0];
|
|
@@ -3949,6 +3020,11 @@ function formatBlockChildren(nodes, context) {
|
|
|
3949
3020
|
let ignoreNext = false;
|
|
3950
3021
|
let inIgnoreRegion = false;
|
|
3951
3022
|
let ignoreRegionStartIndex = -1;
|
|
3023
|
+
const noBreakDelims = context.noBreakDelimiters;
|
|
3024
|
+
function flushCurrentLine() {
|
|
3025
|
+
const parts2 = noBreakDelims ? collapseDelimitedRegions(currentLine, noBreakDelims) : currentLine;
|
|
3026
|
+
return inlineContentToFill(parts2);
|
|
3027
|
+
}
|
|
3952
3028
|
for (let i = 0; i < nodes.length; i++) {
|
|
3953
3029
|
const node = nodes[i];
|
|
3954
3030
|
if (lastNodeEnd >= 0 && node.startIndex > lastNodeEnd && !inIgnoreRegion) {
|
|
@@ -3961,7 +3037,7 @@ function formatBlockChildren(nodes, context) {
|
|
|
3961
3037
|
const directive = getIgnoreDirective(node);
|
|
3962
3038
|
if (directive === "ignore-end" && inIgnoreRegion) {
|
|
3963
3039
|
if (currentLine.length > 0) {
|
|
3964
|
-
const lineContent = trimDoc(
|
|
3040
|
+
const lineContent = trimDoc(flushCurrentLine());
|
|
3965
3041
|
if (hasDocContent(lineContent)) {
|
|
3966
3042
|
lines.push({ doc: lineContent, blankLineBefore: blankLineBeforeCurrentLine });
|
|
3967
3043
|
}
|
|
@@ -3985,7 +3061,7 @@ function formatBlockChildren(nodes, context) {
|
|
|
3985
3061
|
}
|
|
3986
3062
|
if (directive === "ignore-start") {
|
|
3987
3063
|
if (currentLine.length > 0) {
|
|
3988
|
-
const lineContent = trimDoc(
|
|
3064
|
+
const lineContent = trimDoc(flushCurrentLine());
|
|
3989
3065
|
if (hasDocContent(lineContent)) {
|
|
3990
3066
|
lines.push({ doc: lineContent, blankLineBefore: blankLineBeforeCurrentLine });
|
|
3991
3067
|
}
|
|
@@ -4002,7 +3078,7 @@ function formatBlockChildren(nodes, context) {
|
|
|
4002
3078
|
}
|
|
4003
3079
|
if (directive === "ignore") {
|
|
4004
3080
|
if (currentLine.length > 0) {
|
|
4005
|
-
const lineContent = trimDoc(
|
|
3081
|
+
const lineContent = trimDoc(flushCurrentLine());
|
|
4006
3082
|
if (hasDocContent(lineContent)) {
|
|
4007
3083
|
lines.push({ doc: lineContent, blankLineBefore: blankLineBeforeCurrentLine });
|
|
4008
3084
|
}
|
|
@@ -4023,10 +3099,10 @@ function formatBlockChildren(nodes, context) {
|
|
|
4023
3099
|
lastNodeEnd = node.endIndex;
|
|
4024
3100
|
continue;
|
|
4025
3101
|
}
|
|
4026
|
-
const treatAsBlock = shouldTreatAsBlock(node, i, nodes, context.
|
|
3102
|
+
const treatAsBlock = shouldTreatAsBlock(node, i, nodes, context.customTags);
|
|
4027
3103
|
if (lastNodeEnd >= 0 && node.startIndex > lastNodeEnd) {
|
|
4028
3104
|
const prevNode = nodes[i - 1];
|
|
4029
|
-
const prevTreatAsBlock = shouldTreatAsBlock(prevNode, i - 1, nodes, context.
|
|
3105
|
+
const prevTreatAsBlock = shouldTreatAsBlock(prevNode, i - 1, nodes, context.customTags);
|
|
4030
3106
|
if (!prevTreatAsBlock && !treatAsBlock) {
|
|
4031
3107
|
const gap = context.document.getText().slice(lastNodeEnd, node.startIndex);
|
|
4032
3108
|
if (/\s/.test(gap)) {
|
|
@@ -4036,7 +3112,7 @@ function formatBlockChildren(nodes, context) {
|
|
|
4036
3112
|
}
|
|
4037
3113
|
if (treatAsBlock) {
|
|
4038
3114
|
if (currentLine.length > 0) {
|
|
4039
|
-
const lineContent = trimDoc(
|
|
3115
|
+
const lineContent = trimDoc(flushCurrentLine());
|
|
4040
3116
|
if (hasDocContent(lineContent)) {
|
|
4041
3117
|
lines.push({ doc: lineContent, blankLineBefore: blankLineBeforeCurrentLine });
|
|
4042
3118
|
}
|
|
@@ -4049,7 +3125,7 @@ function formatBlockChildren(nodes, context) {
|
|
|
4049
3125
|
const isMultiline = node.startPosition.row !== node.endPosition.row;
|
|
4050
3126
|
if (isMultiline) {
|
|
4051
3127
|
if (currentLine.length > 0) {
|
|
4052
|
-
const lineContent = trimDoc(
|
|
3128
|
+
const lineContent = trimDoc(flushCurrentLine());
|
|
4053
3129
|
if (hasDocContent(lineContent)) {
|
|
4054
3130
|
lines.push({ doc: lineContent, blankLineBefore: blankLineBeforeCurrentLine });
|
|
4055
3131
|
}
|
|
@@ -4082,7 +3158,7 @@ function formatBlockChildren(nodes, context) {
|
|
|
4082
3158
|
const trimmed = contentLines[j].trim();
|
|
4083
3159
|
if (!trimmed) {
|
|
4084
3160
|
if (currentLine.length > 0) {
|
|
4085
|
-
const lineContent = trimDoc(
|
|
3161
|
+
const lineContent = trimDoc(flushCurrentLine());
|
|
4086
3162
|
if (hasDocContent(lineContent)) {
|
|
4087
3163
|
lines.push({ doc: lineContent, blankLineBefore: blankLineBeforeCurrentLine });
|
|
4088
3164
|
blankLineBeforeCurrentLine = false;
|
|
@@ -4107,7 +3183,7 @@ function formatBlockChildren(nodes, context) {
|
|
|
4107
3183
|
currentLine.push(firstTrimmed);
|
|
4108
3184
|
}
|
|
4109
3185
|
if (currentLine.length > 0) {
|
|
4110
|
-
const lineContent = trimDoc(
|
|
3186
|
+
const lineContent = trimDoc(flushCurrentLine());
|
|
4111
3187
|
if (hasDocContent(lineContent)) {
|
|
4112
3188
|
lines.push({ doc: lineContent, blankLineBefore: blankLineBeforeCurrentLine });
|
|
4113
3189
|
blankLineBeforeCurrentLine = pendingBlankLine;
|
|
@@ -4161,7 +3237,7 @@ function formatBlockChildren(nodes, context) {
|
|
|
4161
3237
|
}
|
|
4162
3238
|
}
|
|
4163
3239
|
if (currentLine.length > 0) {
|
|
4164
|
-
const lineContent = trimDoc(
|
|
3240
|
+
const lineContent = trimDoc(flushCurrentLine());
|
|
4165
3241
|
if (hasDocContent(lineContent)) {
|
|
4166
3242
|
lines.push({ doc: lineContent, blankLineBefore: blankLineBeforeCurrentLine });
|
|
4167
3243
|
}
|
|
@@ -4253,21 +3329,28 @@ function createIndentUnit(options) {
|
|
|
4253
3329
|
}
|
|
4254
3330
|
|
|
4255
3331
|
// lsp/server/src/formatting/index.ts
|
|
3332
|
+
function buildCustomTagMap(customTags) {
|
|
3333
|
+
if (!customTags || customTags.length === 0) return void 0;
|
|
3334
|
+
const map = /* @__PURE__ */ new Map();
|
|
3335
|
+
for (const config of customTags) {
|
|
3336
|
+
map.set(config.name.toLowerCase(), config);
|
|
3337
|
+
}
|
|
3338
|
+
return map;
|
|
3339
|
+
}
|
|
4256
3340
|
function formatDocument2(tree, document, options, params = {}) {
|
|
4257
|
-
const {
|
|
3341
|
+
const { printWidth = 80, embeddedFormatted, mustacheSpaces, noBreakDelimiters, configFile } = params;
|
|
4258
3342
|
const mergedOptions = mergeOptions(options, document.uri, configFile);
|
|
4259
3343
|
const indentUnit = createIndentUnit(mergedOptions);
|
|
4260
3344
|
if (tree.rootNode.hasError) {
|
|
4261
3345
|
return [];
|
|
4262
3346
|
}
|
|
4263
|
-
const
|
|
4264
|
-
const customCodeTagSet = customCodeTags ? new Set(customCodeTags.map((t) => t.toLowerCase())) : void 0;
|
|
3347
|
+
const customTagMap = buildCustomTagMap(params.customTags);
|
|
4265
3348
|
const context = {
|
|
4266
3349
|
document,
|
|
4267
|
-
|
|
4268
|
-
customCodeTagConfigs: configMap,
|
|
3350
|
+
customTags: customTagMap,
|
|
4269
3351
|
embeddedFormatted,
|
|
4270
|
-
mustacheSpaces
|
|
3352
|
+
mustacheSpaces,
|
|
3353
|
+
noBreakDelimiters
|
|
4271
3354
|
};
|
|
4272
3355
|
const doc = formatDocument(tree.rootNode, context);
|
|
4273
3356
|
const formatted = print(doc, { indentUnit, printWidth });
|
|
@@ -4277,14 +3360,6 @@ function formatDocument2(tree, document, options, params = {}) {
|
|
|
4277
3360
|
};
|
|
4278
3361
|
return [{ range: fullRange, newText: formatted }];
|
|
4279
3362
|
}
|
|
4280
|
-
function buildConfigMap(configs) {
|
|
4281
|
-
if (!configs || configs.length === 0) return void 0;
|
|
4282
|
-
const map = /* @__PURE__ */ new Map();
|
|
4283
|
-
for (const config of configs) {
|
|
4284
|
-
map.set(config.name.toLowerCase(), config);
|
|
4285
|
-
}
|
|
4286
|
-
return map;
|
|
4287
|
-
}
|
|
4288
3363
|
|
|
4289
3364
|
// cli/src/format.ts
|
|
4290
3365
|
var USAGE2 = `Usage: htmlmustache format [options] [patterns...]
|
|
@@ -4335,7 +3410,7 @@ function parseFlags(args) {
|
|
|
4335
3410
|
i++;
|
|
4336
3411
|
flags.indentSize = parseInt(args[i], 10);
|
|
4337
3412
|
if (isNaN(flags.indentSize)) {
|
|
4338
|
-
console.error(
|
|
3413
|
+
console.error(source_default.red("Error: --indent-size requires a number"));
|
|
4339
3414
|
process.exit(1);
|
|
4340
3415
|
}
|
|
4341
3416
|
break;
|
|
@@ -4343,7 +3418,7 @@ function parseFlags(args) {
|
|
|
4343
3418
|
i++;
|
|
4344
3419
|
flags.printWidth = parseInt(args[i], 10);
|
|
4345
3420
|
if (isNaN(flags.printWidth)) {
|
|
4346
|
-
console.error(
|
|
3421
|
+
console.error(source_default.red("Error: --print-width requires a number"));
|
|
4347
3422
|
process.exit(1);
|
|
4348
3423
|
}
|
|
4349
3424
|
break;
|
|
@@ -4363,17 +3438,16 @@ function resolveSettings(flags, filePath) {
|
|
|
4363
3438
|
let insertSpaces = true;
|
|
4364
3439
|
let printWidth = 80;
|
|
4365
3440
|
let mustacheSpaces = false;
|
|
4366
|
-
let
|
|
4367
|
-
let customCodeTagConfigs;
|
|
3441
|
+
let customTags;
|
|
4368
3442
|
const configFile = filePath ? loadConfigFileForPath(filePath) : null;
|
|
3443
|
+
let noBreakDelimiters;
|
|
4369
3444
|
if (configFile) {
|
|
4370
3445
|
if (configFile.indentSize !== void 0) tabSize = configFile.indentSize;
|
|
4371
3446
|
if (configFile.printWidth !== void 0) printWidth = configFile.printWidth;
|
|
4372
3447
|
if (configFile.mustacheSpaces !== void 0) mustacheSpaces = configFile.mustacheSpaces;
|
|
4373
|
-
if (configFile.
|
|
4374
|
-
|
|
4375
|
-
|
|
4376
|
-
customCodeTagConfigs = parsed.configs;
|
|
3448
|
+
if (configFile.noBreakDelimiters) noBreakDelimiters = configFile.noBreakDelimiters;
|
|
3449
|
+
if (configFile.customTags && configFile.customTags.length > 0) {
|
|
3450
|
+
customTags = configFile.customTags;
|
|
4377
3451
|
}
|
|
4378
3452
|
}
|
|
4379
3453
|
if (filePath) {
|
|
@@ -4389,8 +3463,8 @@ function resolveSettings(flags, filePath) {
|
|
|
4389
3463
|
options: { tabSize, insertSpaces },
|
|
4390
3464
|
printWidth,
|
|
4391
3465
|
mustacheSpaces,
|
|
4392
|
-
|
|
4393
|
-
|
|
3466
|
+
noBreakDelimiters,
|
|
3467
|
+
customTags,
|
|
4394
3468
|
configFile
|
|
4395
3469
|
};
|
|
4396
3470
|
}
|
|
@@ -4425,9 +3499,9 @@ async function run2(args) {
|
|
|
4425
3499
|
return 1;
|
|
4426
3500
|
}
|
|
4427
3501
|
const patterns = flags.patterns.length > 0 ? flags.patterns : config?.include ?? [];
|
|
4428
|
-
console.error(
|
|
3502
|
+
console.error(source_default.yellow("No files matched the given patterns:"));
|
|
4429
3503
|
for (const pattern of patterns) {
|
|
4430
|
-
console.error(
|
|
3504
|
+
console.error(source_default.yellow(` ${pattern}`));
|
|
4431
3505
|
}
|
|
4432
3506
|
return 1;
|
|
4433
3507
|
}
|
|
@@ -4442,25 +3516,25 @@ async function run2(args) {
|
|
|
4442
3516
|
const changed = formatted !== source;
|
|
4443
3517
|
if (changed) changedCount++;
|
|
4444
3518
|
if (flags.check) {
|
|
4445
|
-
console.log(changed ?
|
|
3519
|
+
console.log(changed ? source_default.red(displayPath) : source_default.dim(displayPath));
|
|
4446
3520
|
} else if (flags.write) {
|
|
4447
3521
|
if (changed) {
|
|
4448
3522
|
import_node_fs2.default.writeFileSync(file, formatted);
|
|
4449
3523
|
}
|
|
4450
|
-
console.log(changed ?
|
|
3524
|
+
console.log(changed ? source_default.green(displayPath) : source_default.dim(displayPath));
|
|
4451
3525
|
} else {
|
|
4452
3526
|
process.stdout.write(formatted);
|
|
4453
3527
|
}
|
|
4454
3528
|
}
|
|
4455
3529
|
if (flags.check && changedCount > 0) {
|
|
4456
3530
|
console.log(
|
|
4457
|
-
|
|
3531
|
+
source_default.red(`
|
|
4458
3532
|
${changedCount} ${changedCount === 1 ? "file" : "files"} would be reformatted`)
|
|
4459
3533
|
);
|
|
4460
3534
|
return 1;
|
|
4461
3535
|
}
|
|
4462
3536
|
if (flags.check) {
|
|
4463
|
-
console.log(
|
|
3537
|
+
console.log(source_default.green(`All ${files.length} ${files.length === 1 ? "file" : "files"} already formatted`));
|
|
4464
3538
|
}
|
|
4465
3539
|
return 0;
|
|
4466
3540
|
}
|
|
@@ -4490,7 +3564,7 @@ async function main() {
|
|
|
4490
3564
|
process.exit(command ? 0 : 1);
|
|
4491
3565
|
break;
|
|
4492
3566
|
default:
|
|
4493
|
-
console.error(
|
|
3567
|
+
console.error(source_default.red(`Unknown command: ${command}`));
|
|
4494
3568
|
console.error('Run "htmlmustache --help" for usage.');
|
|
4495
3569
|
process.exit(1);
|
|
4496
3570
|
}
|