@jam-comments/server-utilities 0.0.4 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +3 -3
- package/dist/index.es.js +612 -2595
- package/dist/index.umd.js +2 -36
- package/dist/log.d.ts +2 -2
- package/dist/markupFetcher.d.ts +1 -0
- package/package.json +3 -3
- package/dist/CommentFetcher.d.ts +0 -40
- package/dist/utils.d.ts +0 -9
package/dist/index.es.js
CHANGED
|
@@ -1,1424 +1,50 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
21
|
-
var ansiStyles$3 = { exports: {} };
|
|
22
|
-
var colorName$1 = {
|
|
23
|
-
"aliceblue": [240, 248, 255],
|
|
24
|
-
"antiquewhite": [250, 235, 215],
|
|
25
|
-
"aqua": [0, 255, 255],
|
|
26
|
-
"aquamarine": [127, 255, 212],
|
|
27
|
-
"azure": [240, 255, 255],
|
|
28
|
-
"beige": [245, 245, 220],
|
|
29
|
-
"bisque": [255, 228, 196],
|
|
30
|
-
"black": [0, 0, 0],
|
|
31
|
-
"blanchedalmond": [255, 235, 205],
|
|
32
|
-
"blue": [0, 0, 255],
|
|
33
|
-
"blueviolet": [138, 43, 226],
|
|
34
|
-
"brown": [165, 42, 42],
|
|
35
|
-
"burlywood": [222, 184, 135],
|
|
36
|
-
"cadetblue": [95, 158, 160],
|
|
37
|
-
"chartreuse": [127, 255, 0],
|
|
38
|
-
"chocolate": [210, 105, 30],
|
|
39
|
-
"coral": [255, 127, 80],
|
|
40
|
-
"cornflowerblue": [100, 149, 237],
|
|
41
|
-
"cornsilk": [255, 248, 220],
|
|
42
|
-
"crimson": [220, 20, 60],
|
|
43
|
-
"cyan": [0, 255, 255],
|
|
44
|
-
"darkblue": [0, 0, 139],
|
|
45
|
-
"darkcyan": [0, 139, 139],
|
|
46
|
-
"darkgoldenrod": [184, 134, 11],
|
|
47
|
-
"darkgray": [169, 169, 169],
|
|
48
|
-
"darkgreen": [0, 100, 0],
|
|
49
|
-
"darkgrey": [169, 169, 169],
|
|
50
|
-
"darkkhaki": [189, 183, 107],
|
|
51
|
-
"darkmagenta": [139, 0, 139],
|
|
52
|
-
"darkolivegreen": [85, 107, 47],
|
|
53
|
-
"darkorange": [255, 140, 0],
|
|
54
|
-
"darkorchid": [153, 50, 204],
|
|
55
|
-
"darkred": [139, 0, 0],
|
|
56
|
-
"darksalmon": [233, 150, 122],
|
|
57
|
-
"darkseagreen": [143, 188, 143],
|
|
58
|
-
"darkslateblue": [72, 61, 139],
|
|
59
|
-
"darkslategray": [47, 79, 79],
|
|
60
|
-
"darkslategrey": [47, 79, 79],
|
|
61
|
-
"darkturquoise": [0, 206, 209],
|
|
62
|
-
"darkviolet": [148, 0, 211],
|
|
63
|
-
"deeppink": [255, 20, 147],
|
|
64
|
-
"deepskyblue": [0, 191, 255],
|
|
65
|
-
"dimgray": [105, 105, 105],
|
|
66
|
-
"dimgrey": [105, 105, 105],
|
|
67
|
-
"dodgerblue": [30, 144, 255],
|
|
68
|
-
"firebrick": [178, 34, 34],
|
|
69
|
-
"floralwhite": [255, 250, 240],
|
|
70
|
-
"forestgreen": [34, 139, 34],
|
|
71
|
-
"fuchsia": [255, 0, 255],
|
|
72
|
-
"gainsboro": [220, 220, 220],
|
|
73
|
-
"ghostwhite": [248, 248, 255],
|
|
74
|
-
"gold": [255, 215, 0],
|
|
75
|
-
"goldenrod": [218, 165, 32],
|
|
76
|
-
"gray": [128, 128, 128],
|
|
77
|
-
"green": [0, 128, 0],
|
|
78
|
-
"greenyellow": [173, 255, 47],
|
|
79
|
-
"grey": [128, 128, 128],
|
|
80
|
-
"honeydew": [240, 255, 240],
|
|
81
|
-
"hotpink": [255, 105, 180],
|
|
82
|
-
"indianred": [205, 92, 92],
|
|
83
|
-
"indigo": [75, 0, 130],
|
|
84
|
-
"ivory": [255, 255, 240],
|
|
85
|
-
"khaki": [240, 230, 140],
|
|
86
|
-
"lavender": [230, 230, 250],
|
|
87
|
-
"lavenderblush": [255, 240, 245],
|
|
88
|
-
"lawngreen": [124, 252, 0],
|
|
89
|
-
"lemonchiffon": [255, 250, 205],
|
|
90
|
-
"lightblue": [173, 216, 230],
|
|
91
|
-
"lightcoral": [240, 128, 128],
|
|
92
|
-
"lightcyan": [224, 255, 255],
|
|
93
|
-
"lightgoldenrodyellow": [250, 250, 210],
|
|
94
|
-
"lightgray": [211, 211, 211],
|
|
95
|
-
"lightgreen": [144, 238, 144],
|
|
96
|
-
"lightgrey": [211, 211, 211],
|
|
97
|
-
"lightpink": [255, 182, 193],
|
|
98
|
-
"lightsalmon": [255, 160, 122],
|
|
99
|
-
"lightseagreen": [32, 178, 170],
|
|
100
|
-
"lightskyblue": [135, 206, 250],
|
|
101
|
-
"lightslategray": [119, 136, 153],
|
|
102
|
-
"lightslategrey": [119, 136, 153],
|
|
103
|
-
"lightsteelblue": [176, 196, 222],
|
|
104
|
-
"lightyellow": [255, 255, 224],
|
|
105
|
-
"lime": [0, 255, 0],
|
|
106
|
-
"limegreen": [50, 205, 50],
|
|
107
|
-
"linen": [250, 240, 230],
|
|
108
|
-
"magenta": [255, 0, 255],
|
|
109
|
-
"maroon": [128, 0, 0],
|
|
110
|
-
"mediumaquamarine": [102, 205, 170],
|
|
111
|
-
"mediumblue": [0, 0, 205],
|
|
112
|
-
"mediumorchid": [186, 85, 211],
|
|
113
|
-
"mediumpurple": [147, 112, 219],
|
|
114
|
-
"mediumseagreen": [60, 179, 113],
|
|
115
|
-
"mediumslateblue": [123, 104, 238],
|
|
116
|
-
"mediumspringgreen": [0, 250, 154],
|
|
117
|
-
"mediumturquoise": [72, 209, 204],
|
|
118
|
-
"mediumvioletred": [199, 21, 133],
|
|
119
|
-
"midnightblue": [25, 25, 112],
|
|
120
|
-
"mintcream": [245, 255, 250],
|
|
121
|
-
"mistyrose": [255, 228, 225],
|
|
122
|
-
"moccasin": [255, 228, 181],
|
|
123
|
-
"navajowhite": [255, 222, 173],
|
|
124
|
-
"navy": [0, 0, 128],
|
|
125
|
-
"oldlace": [253, 245, 230],
|
|
126
|
-
"olive": [128, 128, 0],
|
|
127
|
-
"olivedrab": [107, 142, 35],
|
|
128
|
-
"orange": [255, 165, 0],
|
|
129
|
-
"orangered": [255, 69, 0],
|
|
130
|
-
"orchid": [218, 112, 214],
|
|
131
|
-
"palegoldenrod": [238, 232, 170],
|
|
132
|
-
"palegreen": [152, 251, 152],
|
|
133
|
-
"paleturquoise": [175, 238, 238],
|
|
134
|
-
"palevioletred": [219, 112, 147],
|
|
135
|
-
"papayawhip": [255, 239, 213],
|
|
136
|
-
"peachpuff": [255, 218, 185],
|
|
137
|
-
"peru": [205, 133, 63],
|
|
138
|
-
"pink": [255, 192, 203],
|
|
139
|
-
"plum": [221, 160, 221],
|
|
140
|
-
"powderblue": [176, 224, 230],
|
|
141
|
-
"purple": [128, 0, 128],
|
|
142
|
-
"rebeccapurple": [102, 51, 153],
|
|
143
|
-
"red": [255, 0, 0],
|
|
144
|
-
"rosybrown": [188, 143, 143],
|
|
145
|
-
"royalblue": [65, 105, 225],
|
|
146
|
-
"saddlebrown": [139, 69, 19],
|
|
147
|
-
"salmon": [250, 128, 114],
|
|
148
|
-
"sandybrown": [244, 164, 96],
|
|
149
|
-
"seagreen": [46, 139, 87],
|
|
150
|
-
"seashell": [255, 245, 238],
|
|
151
|
-
"sienna": [160, 82, 45],
|
|
152
|
-
"silver": [192, 192, 192],
|
|
153
|
-
"skyblue": [135, 206, 235],
|
|
154
|
-
"slateblue": [106, 90, 205],
|
|
155
|
-
"slategray": [112, 128, 144],
|
|
156
|
-
"slategrey": [112, 128, 144],
|
|
157
|
-
"snow": [255, 250, 250],
|
|
158
|
-
"springgreen": [0, 255, 127],
|
|
159
|
-
"steelblue": [70, 130, 180],
|
|
160
|
-
"tan": [210, 180, 140],
|
|
161
|
-
"teal": [0, 128, 128],
|
|
162
|
-
"thistle": [216, 191, 216],
|
|
163
|
-
"tomato": [255, 99, 71],
|
|
164
|
-
"turquoise": [64, 224, 208],
|
|
165
|
-
"violet": [238, 130, 238],
|
|
166
|
-
"wheat": [245, 222, 179],
|
|
167
|
-
"white": [255, 255, 255],
|
|
168
|
-
"whitesmoke": [245, 245, 245],
|
|
169
|
-
"yellow": [255, 255, 0],
|
|
170
|
-
"yellowgreen": [154, 205, 50]
|
|
171
|
-
};
|
|
172
|
-
const cssKeywords$1 = colorName$1;
|
|
173
|
-
const reverseKeywords$1 = {};
|
|
174
|
-
for (const key of Object.keys(cssKeywords$1)) {
|
|
175
|
-
reverseKeywords$1[cssKeywords$1[key]] = key;
|
|
176
|
-
}
|
|
177
|
-
const convert$3 = {
|
|
178
|
-
rgb: { channels: 3, labels: "rgb" },
|
|
179
|
-
hsl: { channels: 3, labels: "hsl" },
|
|
180
|
-
hsv: { channels: 3, labels: "hsv" },
|
|
181
|
-
hwb: { channels: 3, labels: "hwb" },
|
|
182
|
-
cmyk: { channels: 4, labels: "cmyk" },
|
|
183
|
-
xyz: { channels: 3, labels: "xyz" },
|
|
184
|
-
lab: { channels: 3, labels: "lab" },
|
|
185
|
-
lch: { channels: 3, labels: "lch" },
|
|
186
|
-
hex: { channels: 1, labels: ["hex"] },
|
|
187
|
-
keyword: { channels: 1, labels: ["keyword"] },
|
|
188
|
-
ansi16: { channels: 1, labels: ["ansi16"] },
|
|
189
|
-
ansi256: { channels: 1, labels: ["ansi256"] },
|
|
190
|
-
hcg: { channels: 3, labels: ["h", "c", "g"] },
|
|
191
|
-
apple: { channels: 3, labels: ["r16", "g16", "b16"] },
|
|
192
|
-
gray: { channels: 1, labels: ["gray"] }
|
|
193
|
-
};
|
|
194
|
-
var conversions$5 = convert$3;
|
|
195
|
-
for (const model of Object.keys(convert$3)) {
|
|
196
|
-
if (!("channels" in convert$3[model])) {
|
|
197
|
-
throw new Error("missing channels property: " + model);
|
|
198
|
-
}
|
|
199
|
-
if (!("labels" in convert$3[model])) {
|
|
200
|
-
throw new Error("missing channel labels property: " + model);
|
|
201
|
-
}
|
|
202
|
-
if (convert$3[model].labels.length !== convert$3[model].channels) {
|
|
203
|
-
throw new Error("channel and label counts mismatch: " + model);
|
|
204
|
-
}
|
|
205
|
-
const { channels, labels } = convert$3[model];
|
|
206
|
-
delete convert$3[model].channels;
|
|
207
|
-
delete convert$3[model].labels;
|
|
208
|
-
Object.defineProperty(convert$3[model], "channels", { value: channels });
|
|
209
|
-
Object.defineProperty(convert$3[model], "labels", { value: labels });
|
|
210
|
-
}
|
|
211
|
-
convert$3.rgb.hsl = function(rgb) {
|
|
212
|
-
const r = rgb[0] / 255;
|
|
213
|
-
const g = rgb[1] / 255;
|
|
214
|
-
const b = rgb[2] / 255;
|
|
215
|
-
const min = Math.min(r, g, b);
|
|
216
|
-
const max = Math.max(r, g, b);
|
|
217
|
-
const delta = max - min;
|
|
218
|
-
let h;
|
|
219
|
-
let s;
|
|
220
|
-
if (max === min) {
|
|
221
|
-
h = 0;
|
|
222
|
-
} else if (r === max) {
|
|
223
|
-
h = (g - b) / delta;
|
|
224
|
-
} else if (g === max) {
|
|
225
|
-
h = 2 + (b - r) / delta;
|
|
226
|
-
} else if (b === max) {
|
|
227
|
-
h = 4 + (r - g) / delta;
|
|
228
|
-
}
|
|
229
|
-
h = Math.min(h * 60, 360);
|
|
230
|
-
if (h < 0) {
|
|
231
|
-
h += 360;
|
|
232
|
-
}
|
|
233
|
-
const l = (min + max) / 2;
|
|
234
|
-
if (max === min) {
|
|
235
|
-
s = 0;
|
|
236
|
-
} else if (l <= 0.5) {
|
|
237
|
-
s = delta / (max + min);
|
|
238
|
-
} else {
|
|
239
|
-
s = delta / (2 - max - min);
|
|
240
|
-
}
|
|
241
|
-
return [h, s * 100, l * 100];
|
|
242
|
-
};
|
|
243
|
-
convert$3.rgb.hsv = function(rgb) {
|
|
244
|
-
let rdif;
|
|
245
|
-
let gdif;
|
|
246
|
-
let bdif;
|
|
247
|
-
let h;
|
|
248
|
-
let s;
|
|
249
|
-
const r = rgb[0] / 255;
|
|
250
|
-
const g = rgb[1] / 255;
|
|
251
|
-
const b = rgb[2] / 255;
|
|
252
|
-
const v = Math.max(r, g, b);
|
|
253
|
-
const diff = v - Math.min(r, g, b);
|
|
254
|
-
const diffc = function(c) {
|
|
255
|
-
return (v - c) / 6 / diff + 1 / 2;
|
|
256
|
-
};
|
|
257
|
-
if (diff === 0) {
|
|
258
|
-
h = 0;
|
|
259
|
-
s = 0;
|
|
260
|
-
} else {
|
|
261
|
-
s = diff / v;
|
|
262
|
-
rdif = diffc(r);
|
|
263
|
-
gdif = diffc(g);
|
|
264
|
-
bdif = diffc(b);
|
|
265
|
-
if (r === v) {
|
|
266
|
-
h = bdif - gdif;
|
|
267
|
-
} else if (g === v) {
|
|
268
|
-
h = 1 / 3 + rdif - bdif;
|
|
269
|
-
} else if (b === v) {
|
|
270
|
-
h = 2 / 3 + gdif - rdif;
|
|
271
|
-
}
|
|
272
|
-
if (h < 0) {
|
|
273
|
-
h += 1;
|
|
274
|
-
} else if (h > 1) {
|
|
275
|
-
h -= 1;
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
return [
|
|
279
|
-
h * 360,
|
|
280
|
-
s * 100,
|
|
281
|
-
v * 100
|
|
282
|
-
];
|
|
283
|
-
};
|
|
284
|
-
convert$3.rgb.hwb = function(rgb) {
|
|
285
|
-
const r = rgb[0];
|
|
286
|
-
const g = rgb[1];
|
|
287
|
-
let b = rgb[2];
|
|
288
|
-
const h = convert$3.rgb.hsl(rgb)[0];
|
|
289
|
-
const w = 1 / 255 * Math.min(r, Math.min(g, b));
|
|
290
|
-
b = 1 - 1 / 255 * Math.max(r, Math.max(g, b));
|
|
291
|
-
return [h, w * 100, b * 100];
|
|
292
|
-
};
|
|
293
|
-
convert$3.rgb.cmyk = function(rgb) {
|
|
294
|
-
const r = rgb[0] / 255;
|
|
295
|
-
const g = rgb[1] / 255;
|
|
296
|
-
const b = rgb[2] / 255;
|
|
297
|
-
const k = Math.min(1 - r, 1 - g, 1 - b);
|
|
298
|
-
const c = (1 - r - k) / (1 - k) || 0;
|
|
299
|
-
const m = (1 - g - k) / (1 - k) || 0;
|
|
300
|
-
const y = (1 - b - k) / (1 - k) || 0;
|
|
301
|
-
return [c * 100, m * 100, y * 100, k * 100];
|
|
302
|
-
};
|
|
303
|
-
function comparativeDistance$1(x, y) {
|
|
304
|
-
return (x[0] - y[0]) ** 2 + (x[1] - y[1]) ** 2 + (x[2] - y[2]) ** 2;
|
|
305
|
-
}
|
|
306
|
-
convert$3.rgb.keyword = function(rgb) {
|
|
307
|
-
const reversed = reverseKeywords$1[rgb];
|
|
308
|
-
if (reversed) {
|
|
309
|
-
return reversed;
|
|
310
|
-
}
|
|
311
|
-
let currentClosestDistance = Infinity;
|
|
312
|
-
let currentClosestKeyword;
|
|
313
|
-
for (const keyword of Object.keys(cssKeywords$1)) {
|
|
314
|
-
const value = cssKeywords$1[keyword];
|
|
315
|
-
const distance = comparativeDistance$1(rgb, value);
|
|
316
|
-
if (distance < currentClosestDistance) {
|
|
317
|
-
currentClosestDistance = distance;
|
|
318
|
-
currentClosestKeyword = keyword;
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
return currentClosestKeyword;
|
|
322
|
-
};
|
|
323
|
-
convert$3.keyword.rgb = function(keyword) {
|
|
324
|
-
return cssKeywords$1[keyword];
|
|
325
|
-
};
|
|
326
|
-
convert$3.rgb.xyz = function(rgb) {
|
|
327
|
-
let r = rgb[0] / 255;
|
|
328
|
-
let g = rgb[1] / 255;
|
|
329
|
-
let b = rgb[2] / 255;
|
|
330
|
-
r = r > 0.04045 ? ((r + 0.055) / 1.055) ** 2.4 : r / 12.92;
|
|
331
|
-
g = g > 0.04045 ? ((g + 0.055) / 1.055) ** 2.4 : g / 12.92;
|
|
332
|
-
b = b > 0.04045 ? ((b + 0.055) / 1.055) ** 2.4 : b / 12.92;
|
|
333
|
-
const x = r * 0.4124 + g * 0.3576 + b * 0.1805;
|
|
334
|
-
const y = r * 0.2126 + g * 0.7152 + b * 0.0722;
|
|
335
|
-
const z = r * 0.0193 + g * 0.1192 + b * 0.9505;
|
|
336
|
-
return [x * 100, y * 100, z * 100];
|
|
337
|
-
};
|
|
338
|
-
convert$3.rgb.lab = function(rgb) {
|
|
339
|
-
const xyz = convert$3.rgb.xyz(rgb);
|
|
340
|
-
let x = xyz[0];
|
|
341
|
-
let y = xyz[1];
|
|
342
|
-
let z = xyz[2];
|
|
343
|
-
x /= 95.047;
|
|
344
|
-
y /= 100;
|
|
345
|
-
z /= 108.883;
|
|
346
|
-
x = x > 8856e-6 ? x ** (1 / 3) : 7.787 * x + 16 / 116;
|
|
347
|
-
y = y > 8856e-6 ? y ** (1 / 3) : 7.787 * y + 16 / 116;
|
|
348
|
-
z = z > 8856e-6 ? z ** (1 / 3) : 7.787 * z + 16 / 116;
|
|
349
|
-
const l = 116 * y - 16;
|
|
350
|
-
const a = 500 * (x - y);
|
|
351
|
-
const b = 200 * (y - z);
|
|
352
|
-
return [l, a, b];
|
|
353
|
-
};
|
|
354
|
-
convert$3.hsl.rgb = function(hsl) {
|
|
355
|
-
const h = hsl[0] / 360;
|
|
356
|
-
const s = hsl[1] / 100;
|
|
357
|
-
const l = hsl[2] / 100;
|
|
358
|
-
let t2;
|
|
359
|
-
let t3;
|
|
360
|
-
let val;
|
|
361
|
-
if (s === 0) {
|
|
362
|
-
val = l * 255;
|
|
363
|
-
return [val, val, val];
|
|
364
|
-
}
|
|
365
|
-
if (l < 0.5) {
|
|
366
|
-
t2 = l * (1 + s);
|
|
367
|
-
} else {
|
|
368
|
-
t2 = l + s - l * s;
|
|
369
|
-
}
|
|
370
|
-
const t1 = 2 * l - t2;
|
|
371
|
-
const rgb = [0, 0, 0];
|
|
372
|
-
for (let i = 0; i < 3; i++) {
|
|
373
|
-
t3 = h + 1 / 3 * -(i - 1);
|
|
374
|
-
if (t3 < 0) {
|
|
375
|
-
t3++;
|
|
376
|
-
}
|
|
377
|
-
if (t3 > 1) {
|
|
378
|
-
t3--;
|
|
379
|
-
}
|
|
380
|
-
if (6 * t3 < 1) {
|
|
381
|
-
val = t1 + (t2 - t1) * 6 * t3;
|
|
382
|
-
} else if (2 * t3 < 1) {
|
|
383
|
-
val = t2;
|
|
384
|
-
} else if (3 * t3 < 2) {
|
|
385
|
-
val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
|
|
386
|
-
} else {
|
|
387
|
-
val = t1;
|
|
388
|
-
}
|
|
389
|
-
rgb[i] = val * 255;
|
|
390
|
-
}
|
|
391
|
-
return rgb;
|
|
392
|
-
};
|
|
393
|
-
convert$3.hsl.hsv = function(hsl) {
|
|
394
|
-
const h = hsl[0];
|
|
395
|
-
let s = hsl[1] / 100;
|
|
396
|
-
let l = hsl[2] / 100;
|
|
397
|
-
let smin = s;
|
|
398
|
-
const lmin = Math.max(l, 0.01);
|
|
399
|
-
l *= 2;
|
|
400
|
-
s *= l <= 1 ? l : 2 - l;
|
|
401
|
-
smin *= lmin <= 1 ? lmin : 2 - lmin;
|
|
402
|
-
const v = (l + s) / 2;
|
|
403
|
-
const sv = l === 0 ? 2 * smin / (lmin + smin) : 2 * s / (l + s);
|
|
404
|
-
return [h, sv * 100, v * 100];
|
|
405
|
-
};
|
|
406
|
-
convert$3.hsv.rgb = function(hsv) {
|
|
407
|
-
const h = hsv[0] / 60;
|
|
408
|
-
const s = hsv[1] / 100;
|
|
409
|
-
let v = hsv[2] / 100;
|
|
410
|
-
const hi = Math.floor(h) % 6;
|
|
411
|
-
const f = h - Math.floor(h);
|
|
412
|
-
const p = 255 * v * (1 - s);
|
|
413
|
-
const q = 255 * v * (1 - s * f);
|
|
414
|
-
const t = 255 * v * (1 - s * (1 - f));
|
|
415
|
-
v *= 255;
|
|
416
|
-
switch (hi) {
|
|
417
|
-
case 0:
|
|
418
|
-
return [v, t, p];
|
|
419
|
-
case 1:
|
|
420
|
-
return [q, v, p];
|
|
421
|
-
case 2:
|
|
422
|
-
return [p, v, t];
|
|
423
|
-
case 3:
|
|
424
|
-
return [p, q, v];
|
|
425
|
-
case 4:
|
|
426
|
-
return [t, p, v];
|
|
427
|
-
case 5:
|
|
428
|
-
return [v, p, q];
|
|
429
|
-
}
|
|
430
|
-
};
|
|
431
|
-
convert$3.hsv.hsl = function(hsv) {
|
|
432
|
-
const h = hsv[0];
|
|
433
|
-
const s = hsv[1] / 100;
|
|
434
|
-
const v = hsv[2] / 100;
|
|
435
|
-
const vmin = Math.max(v, 0.01);
|
|
436
|
-
let sl;
|
|
437
|
-
let l;
|
|
438
|
-
l = (2 - s) * v;
|
|
439
|
-
const lmin = (2 - s) * vmin;
|
|
440
|
-
sl = s * vmin;
|
|
441
|
-
sl /= lmin <= 1 ? lmin : 2 - lmin;
|
|
442
|
-
sl = sl || 0;
|
|
443
|
-
l /= 2;
|
|
444
|
-
return [h, sl * 100, l * 100];
|
|
445
|
-
};
|
|
446
|
-
convert$3.hwb.rgb = function(hwb) {
|
|
447
|
-
const h = hwb[0] / 360;
|
|
448
|
-
let wh = hwb[1] / 100;
|
|
449
|
-
let bl = hwb[2] / 100;
|
|
450
|
-
const ratio = wh + bl;
|
|
451
|
-
let f;
|
|
452
|
-
if (ratio > 1) {
|
|
453
|
-
wh /= ratio;
|
|
454
|
-
bl /= ratio;
|
|
455
|
-
}
|
|
456
|
-
const i = Math.floor(6 * h);
|
|
457
|
-
const v = 1 - bl;
|
|
458
|
-
f = 6 * h - i;
|
|
459
|
-
if ((i & 1) !== 0) {
|
|
460
|
-
f = 1 - f;
|
|
461
|
-
}
|
|
462
|
-
const n = wh + f * (v - wh);
|
|
463
|
-
let r;
|
|
464
|
-
let g;
|
|
465
|
-
let b;
|
|
466
|
-
switch (i) {
|
|
467
|
-
default:
|
|
468
|
-
case 6:
|
|
469
|
-
case 0:
|
|
470
|
-
r = v;
|
|
471
|
-
g = n;
|
|
472
|
-
b = wh;
|
|
473
|
-
break;
|
|
474
|
-
case 1:
|
|
475
|
-
r = n;
|
|
476
|
-
g = v;
|
|
477
|
-
b = wh;
|
|
478
|
-
break;
|
|
479
|
-
case 2:
|
|
480
|
-
r = wh;
|
|
481
|
-
g = v;
|
|
482
|
-
b = n;
|
|
483
|
-
break;
|
|
484
|
-
case 3:
|
|
485
|
-
r = wh;
|
|
486
|
-
g = n;
|
|
487
|
-
b = v;
|
|
488
|
-
break;
|
|
489
|
-
case 4:
|
|
490
|
-
r = n;
|
|
491
|
-
g = wh;
|
|
492
|
-
b = v;
|
|
493
|
-
break;
|
|
494
|
-
case 5:
|
|
495
|
-
r = v;
|
|
496
|
-
g = wh;
|
|
497
|
-
b = n;
|
|
498
|
-
break;
|
|
499
|
-
}
|
|
500
|
-
return [r * 255, g * 255, b * 255];
|
|
501
|
-
};
|
|
502
|
-
convert$3.cmyk.rgb = function(cmyk) {
|
|
503
|
-
const c = cmyk[0] / 100;
|
|
504
|
-
const m = cmyk[1] / 100;
|
|
505
|
-
const y = cmyk[2] / 100;
|
|
506
|
-
const k = cmyk[3] / 100;
|
|
507
|
-
const r = 1 - Math.min(1, c * (1 - k) + k);
|
|
508
|
-
const g = 1 - Math.min(1, m * (1 - k) + k);
|
|
509
|
-
const b = 1 - Math.min(1, y * (1 - k) + k);
|
|
510
|
-
return [r * 255, g * 255, b * 255];
|
|
511
|
-
};
|
|
512
|
-
convert$3.xyz.rgb = function(xyz) {
|
|
513
|
-
const x = xyz[0] / 100;
|
|
514
|
-
const y = xyz[1] / 100;
|
|
515
|
-
const z = xyz[2] / 100;
|
|
516
|
-
let r;
|
|
517
|
-
let g;
|
|
518
|
-
let b;
|
|
519
|
-
r = x * 3.2406 + y * -1.5372 + z * -0.4986;
|
|
520
|
-
g = x * -0.9689 + y * 1.8758 + z * 0.0415;
|
|
521
|
-
b = x * 0.0557 + y * -0.204 + z * 1.057;
|
|
522
|
-
r = r > 31308e-7 ? 1.055 * r ** (1 / 2.4) - 0.055 : r * 12.92;
|
|
523
|
-
g = g > 31308e-7 ? 1.055 * g ** (1 / 2.4) - 0.055 : g * 12.92;
|
|
524
|
-
b = b > 31308e-7 ? 1.055 * b ** (1 / 2.4) - 0.055 : b * 12.92;
|
|
525
|
-
r = Math.min(Math.max(0, r), 1);
|
|
526
|
-
g = Math.min(Math.max(0, g), 1);
|
|
527
|
-
b = Math.min(Math.max(0, b), 1);
|
|
528
|
-
return [r * 255, g * 255, b * 255];
|
|
529
|
-
};
|
|
530
|
-
convert$3.xyz.lab = function(xyz) {
|
|
531
|
-
let x = xyz[0];
|
|
532
|
-
let y = xyz[1];
|
|
533
|
-
let z = xyz[2];
|
|
534
|
-
x /= 95.047;
|
|
535
|
-
y /= 100;
|
|
536
|
-
z /= 108.883;
|
|
537
|
-
x = x > 8856e-6 ? x ** (1 / 3) : 7.787 * x + 16 / 116;
|
|
538
|
-
y = y > 8856e-6 ? y ** (1 / 3) : 7.787 * y + 16 / 116;
|
|
539
|
-
z = z > 8856e-6 ? z ** (1 / 3) : 7.787 * z + 16 / 116;
|
|
540
|
-
const l = 116 * y - 16;
|
|
541
|
-
const a = 500 * (x - y);
|
|
542
|
-
const b = 200 * (y - z);
|
|
543
|
-
return [l, a, b];
|
|
544
|
-
};
|
|
545
|
-
convert$3.lab.xyz = function(lab) {
|
|
546
|
-
const l = lab[0];
|
|
547
|
-
const a = lab[1];
|
|
548
|
-
const b = lab[2];
|
|
549
|
-
let x;
|
|
550
|
-
let y;
|
|
551
|
-
let z;
|
|
552
|
-
y = (l + 16) / 116;
|
|
553
|
-
x = a / 500 + y;
|
|
554
|
-
z = y - b / 200;
|
|
555
|
-
const y2 = y ** 3;
|
|
556
|
-
const x2 = x ** 3;
|
|
557
|
-
const z2 = z ** 3;
|
|
558
|
-
y = y2 > 8856e-6 ? y2 : (y - 16 / 116) / 7.787;
|
|
559
|
-
x = x2 > 8856e-6 ? x2 : (x - 16 / 116) / 7.787;
|
|
560
|
-
z = z2 > 8856e-6 ? z2 : (z - 16 / 116) / 7.787;
|
|
561
|
-
x *= 95.047;
|
|
562
|
-
y *= 100;
|
|
563
|
-
z *= 108.883;
|
|
564
|
-
return [x, y, z];
|
|
565
|
-
};
|
|
566
|
-
convert$3.lab.lch = function(lab) {
|
|
567
|
-
const l = lab[0];
|
|
568
|
-
const a = lab[1];
|
|
569
|
-
const b = lab[2];
|
|
570
|
-
let h;
|
|
571
|
-
const hr = Math.atan2(b, a);
|
|
572
|
-
h = hr * 360 / 2 / Math.PI;
|
|
573
|
-
if (h < 0) {
|
|
574
|
-
h += 360;
|
|
575
|
-
}
|
|
576
|
-
const c = Math.sqrt(a * a + b * b);
|
|
577
|
-
return [l, c, h];
|
|
578
|
-
};
|
|
579
|
-
convert$3.lch.lab = function(lch) {
|
|
580
|
-
const l = lch[0];
|
|
581
|
-
const c = lch[1];
|
|
582
|
-
const h = lch[2];
|
|
583
|
-
const hr = h / 360 * 2 * Math.PI;
|
|
584
|
-
const a = c * Math.cos(hr);
|
|
585
|
-
const b = c * Math.sin(hr);
|
|
586
|
-
return [l, a, b];
|
|
587
|
-
};
|
|
588
|
-
convert$3.rgb.ansi16 = function(args, saturation = null) {
|
|
589
|
-
const [r, g, b] = args;
|
|
590
|
-
let value = saturation === null ? convert$3.rgb.hsv(args)[2] : saturation;
|
|
591
|
-
value = Math.round(value / 50);
|
|
592
|
-
if (value === 0) {
|
|
593
|
-
return 30;
|
|
594
|
-
}
|
|
595
|
-
let ansi = 30 + (Math.round(b / 255) << 2 | Math.round(g / 255) << 1 | Math.round(r / 255));
|
|
596
|
-
if (value === 2) {
|
|
597
|
-
ansi += 60;
|
|
598
|
-
}
|
|
599
|
-
return ansi;
|
|
600
|
-
};
|
|
601
|
-
convert$3.hsv.ansi16 = function(args) {
|
|
602
|
-
return convert$3.rgb.ansi16(convert$3.hsv.rgb(args), args[2]);
|
|
603
|
-
};
|
|
604
|
-
convert$3.rgb.ansi256 = function(args) {
|
|
605
|
-
const r = args[0];
|
|
606
|
-
const g = args[1];
|
|
607
|
-
const b = args[2];
|
|
608
|
-
if (r === g && g === b) {
|
|
609
|
-
if (r < 8) {
|
|
610
|
-
return 16;
|
|
611
|
-
}
|
|
612
|
-
if (r > 248) {
|
|
613
|
-
return 231;
|
|
614
|
-
}
|
|
615
|
-
return Math.round((r - 8) / 247 * 24) + 232;
|
|
616
|
-
}
|
|
617
|
-
const ansi = 16 + 36 * Math.round(r / 255 * 5) + 6 * Math.round(g / 255 * 5) + Math.round(b / 255 * 5);
|
|
618
|
-
return ansi;
|
|
619
|
-
};
|
|
620
|
-
convert$3.ansi16.rgb = function(args) {
|
|
621
|
-
let color = args % 10;
|
|
622
|
-
if (color === 0 || color === 7) {
|
|
623
|
-
if (args > 50) {
|
|
624
|
-
color += 3.5;
|
|
625
|
-
}
|
|
626
|
-
color = color / 10.5 * 255;
|
|
627
|
-
return [color, color, color];
|
|
628
|
-
}
|
|
629
|
-
const mult = (~~(args > 50) + 1) * 0.5;
|
|
630
|
-
const r = (color & 1) * mult * 255;
|
|
631
|
-
const g = (color >> 1 & 1) * mult * 255;
|
|
632
|
-
const b = (color >> 2 & 1) * mult * 255;
|
|
633
|
-
return [r, g, b];
|
|
634
|
-
};
|
|
635
|
-
convert$3.ansi256.rgb = function(args) {
|
|
636
|
-
if (args >= 232) {
|
|
637
|
-
const c = (args - 232) * 10 + 8;
|
|
638
|
-
return [c, c, c];
|
|
639
|
-
}
|
|
640
|
-
args -= 16;
|
|
641
|
-
let rem;
|
|
642
|
-
const r = Math.floor(args / 36) / 5 * 255;
|
|
643
|
-
const g = Math.floor((rem = args % 36) / 6) / 5 * 255;
|
|
644
|
-
const b = rem % 6 / 5 * 255;
|
|
645
|
-
return [r, g, b];
|
|
646
|
-
};
|
|
647
|
-
convert$3.rgb.hex = function(args) {
|
|
648
|
-
const integer = ((Math.round(args[0]) & 255) << 16) + ((Math.round(args[1]) & 255) << 8) + (Math.round(args[2]) & 255);
|
|
649
|
-
const string = integer.toString(16).toUpperCase();
|
|
650
|
-
return "000000".substring(string.length) + string;
|
|
651
|
-
};
|
|
652
|
-
convert$3.hex.rgb = function(args) {
|
|
653
|
-
const match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
|
|
654
|
-
if (!match) {
|
|
655
|
-
return [0, 0, 0];
|
|
656
|
-
}
|
|
657
|
-
let colorString = match[0];
|
|
658
|
-
if (match[0].length === 3) {
|
|
659
|
-
colorString = colorString.split("").map((char) => {
|
|
660
|
-
return char + char;
|
|
661
|
-
}).join("");
|
|
662
|
-
}
|
|
663
|
-
const integer = parseInt(colorString, 16);
|
|
664
|
-
const r = integer >> 16 & 255;
|
|
665
|
-
const g = integer >> 8 & 255;
|
|
666
|
-
const b = integer & 255;
|
|
667
|
-
return [r, g, b];
|
|
668
|
-
};
|
|
669
|
-
convert$3.rgb.hcg = function(rgb) {
|
|
670
|
-
const r = rgb[0] / 255;
|
|
671
|
-
const g = rgb[1] / 255;
|
|
672
|
-
const b = rgb[2] / 255;
|
|
673
|
-
const max = Math.max(Math.max(r, g), b);
|
|
674
|
-
const min = Math.min(Math.min(r, g), b);
|
|
675
|
-
const chroma = max - min;
|
|
676
|
-
let grayscale;
|
|
677
|
-
let hue;
|
|
678
|
-
if (chroma < 1) {
|
|
679
|
-
grayscale = min / (1 - chroma);
|
|
680
|
-
} else {
|
|
681
|
-
grayscale = 0;
|
|
682
|
-
}
|
|
683
|
-
if (chroma <= 0) {
|
|
684
|
-
hue = 0;
|
|
685
|
-
} else if (max === r) {
|
|
686
|
-
hue = (g - b) / chroma % 6;
|
|
687
|
-
} else if (max === g) {
|
|
688
|
-
hue = 2 + (b - r) / chroma;
|
|
689
|
-
} else {
|
|
690
|
-
hue = 4 + (r - g) / chroma;
|
|
691
|
-
}
|
|
692
|
-
hue /= 6;
|
|
693
|
-
hue %= 1;
|
|
694
|
-
return [hue * 360, chroma * 100, grayscale * 100];
|
|
695
|
-
};
|
|
696
|
-
convert$3.hsl.hcg = function(hsl) {
|
|
697
|
-
const s = hsl[1] / 100;
|
|
698
|
-
const l = hsl[2] / 100;
|
|
699
|
-
const c = l < 0.5 ? 2 * s * l : 2 * s * (1 - l);
|
|
700
|
-
let f = 0;
|
|
701
|
-
if (c < 1) {
|
|
702
|
-
f = (l - 0.5 * c) / (1 - c);
|
|
703
|
-
}
|
|
704
|
-
return [hsl[0], c * 100, f * 100];
|
|
705
|
-
};
|
|
706
|
-
convert$3.hsv.hcg = function(hsv) {
|
|
707
|
-
const s = hsv[1] / 100;
|
|
708
|
-
const v = hsv[2] / 100;
|
|
709
|
-
const c = s * v;
|
|
710
|
-
let f = 0;
|
|
711
|
-
if (c < 1) {
|
|
712
|
-
f = (v - c) / (1 - c);
|
|
713
|
-
}
|
|
714
|
-
return [hsv[0], c * 100, f * 100];
|
|
715
|
-
};
|
|
716
|
-
convert$3.hcg.rgb = function(hcg) {
|
|
717
|
-
const h = hcg[0] / 360;
|
|
718
|
-
const c = hcg[1] / 100;
|
|
719
|
-
const g = hcg[2] / 100;
|
|
720
|
-
if (c === 0) {
|
|
721
|
-
return [g * 255, g * 255, g * 255];
|
|
722
|
-
}
|
|
723
|
-
const pure = [0, 0, 0];
|
|
724
|
-
const hi = h % 1 * 6;
|
|
725
|
-
const v = hi % 1;
|
|
726
|
-
const w = 1 - v;
|
|
727
|
-
let mg = 0;
|
|
728
|
-
switch (Math.floor(hi)) {
|
|
729
|
-
case 0:
|
|
730
|
-
pure[0] = 1;
|
|
731
|
-
pure[1] = v;
|
|
732
|
-
pure[2] = 0;
|
|
733
|
-
break;
|
|
734
|
-
case 1:
|
|
735
|
-
pure[0] = w;
|
|
736
|
-
pure[1] = 1;
|
|
737
|
-
pure[2] = 0;
|
|
738
|
-
break;
|
|
739
|
-
case 2:
|
|
740
|
-
pure[0] = 0;
|
|
741
|
-
pure[1] = 1;
|
|
742
|
-
pure[2] = v;
|
|
743
|
-
break;
|
|
744
|
-
case 3:
|
|
745
|
-
pure[0] = 0;
|
|
746
|
-
pure[1] = w;
|
|
747
|
-
pure[2] = 1;
|
|
748
|
-
break;
|
|
749
|
-
case 4:
|
|
750
|
-
pure[0] = v;
|
|
751
|
-
pure[1] = 0;
|
|
752
|
-
pure[2] = 1;
|
|
753
|
-
break;
|
|
754
|
-
default:
|
|
755
|
-
pure[0] = 1;
|
|
756
|
-
pure[1] = 0;
|
|
757
|
-
pure[2] = w;
|
|
758
|
-
}
|
|
759
|
-
mg = (1 - c) * g;
|
|
760
|
-
return [
|
|
761
|
-
(c * pure[0] + mg) * 255,
|
|
762
|
-
(c * pure[1] + mg) * 255,
|
|
763
|
-
(c * pure[2] + mg) * 255
|
|
764
|
-
];
|
|
765
|
-
};
|
|
766
|
-
convert$3.hcg.hsv = function(hcg) {
|
|
767
|
-
const c = hcg[1] / 100;
|
|
768
|
-
const g = hcg[2] / 100;
|
|
769
|
-
const v = c + g * (1 - c);
|
|
770
|
-
let f = 0;
|
|
771
|
-
if (v > 0) {
|
|
772
|
-
f = c / v;
|
|
773
|
-
}
|
|
774
|
-
return [hcg[0], f * 100, v * 100];
|
|
775
|
-
};
|
|
776
|
-
convert$3.hcg.hsl = function(hcg) {
|
|
777
|
-
const c = hcg[1] / 100;
|
|
778
|
-
const g = hcg[2] / 100;
|
|
779
|
-
const l = g * (1 - c) + 0.5 * c;
|
|
780
|
-
let s = 0;
|
|
781
|
-
if (l > 0 && l < 0.5) {
|
|
782
|
-
s = c / (2 * l);
|
|
783
|
-
} else if (l >= 0.5 && l < 1) {
|
|
784
|
-
s = c / (2 * (1 - l));
|
|
785
|
-
}
|
|
786
|
-
return [hcg[0], s * 100, l * 100];
|
|
787
|
-
};
|
|
788
|
-
convert$3.hcg.hwb = function(hcg) {
|
|
789
|
-
const c = hcg[1] / 100;
|
|
790
|
-
const g = hcg[2] / 100;
|
|
791
|
-
const v = c + g * (1 - c);
|
|
792
|
-
return [hcg[0], (v - c) * 100, (1 - v) * 100];
|
|
793
|
-
};
|
|
794
|
-
convert$3.hwb.hcg = function(hwb) {
|
|
795
|
-
const w = hwb[1] / 100;
|
|
796
|
-
const b = hwb[2] / 100;
|
|
797
|
-
const v = 1 - b;
|
|
798
|
-
const c = v - w;
|
|
799
|
-
let g = 0;
|
|
800
|
-
if (c < 1) {
|
|
801
|
-
g = (v - c) / (1 - c);
|
|
802
|
-
}
|
|
803
|
-
return [hwb[0], c * 100, g * 100];
|
|
804
|
-
};
|
|
805
|
-
convert$3.apple.rgb = function(apple) {
|
|
806
|
-
return [apple[0] / 65535 * 255, apple[1] / 65535 * 255, apple[2] / 65535 * 255];
|
|
807
|
-
};
|
|
808
|
-
convert$3.rgb.apple = function(rgb) {
|
|
809
|
-
return [rgb[0] / 255 * 65535, rgb[1] / 255 * 65535, rgb[2] / 255 * 65535];
|
|
810
|
-
};
|
|
811
|
-
convert$3.gray.rgb = function(args) {
|
|
812
|
-
return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];
|
|
813
|
-
};
|
|
814
|
-
convert$3.gray.hsl = function(args) {
|
|
815
|
-
return [0, 0, args[0]];
|
|
816
|
-
};
|
|
817
|
-
convert$3.gray.hsv = convert$3.gray.hsl;
|
|
818
|
-
convert$3.gray.hwb = function(gray) {
|
|
819
|
-
return [0, 100, gray[0]];
|
|
820
|
-
};
|
|
821
|
-
convert$3.gray.cmyk = function(gray) {
|
|
822
|
-
return [0, 0, 0, gray[0]];
|
|
823
|
-
};
|
|
824
|
-
convert$3.gray.lab = function(gray) {
|
|
825
|
-
return [gray[0], 0, 0];
|
|
826
|
-
};
|
|
827
|
-
convert$3.gray.hex = function(gray) {
|
|
828
|
-
const val = Math.round(gray[0] / 100 * 255) & 255;
|
|
829
|
-
const integer = (val << 16) + (val << 8) + val;
|
|
830
|
-
const string = integer.toString(16).toUpperCase();
|
|
831
|
-
return "000000".substring(string.length) + string;
|
|
832
|
-
};
|
|
833
|
-
convert$3.rgb.gray = function(rgb) {
|
|
834
|
-
const val = (rgb[0] + rgb[1] + rgb[2]) / 3;
|
|
835
|
-
return [val / 255 * 100];
|
|
836
|
-
};
|
|
837
|
-
const conversions$4 = conversions$5;
|
|
838
|
-
function buildGraph$1() {
|
|
839
|
-
const graph = {};
|
|
840
|
-
const models2 = Object.keys(conversions$4);
|
|
841
|
-
for (let len = models2.length, i = 0; i < len; i++) {
|
|
842
|
-
graph[models2[i]] = {
|
|
843
|
-
distance: -1,
|
|
844
|
-
parent: null
|
|
845
|
-
};
|
|
846
|
-
}
|
|
847
|
-
return graph;
|
|
848
|
-
}
|
|
849
|
-
function deriveBFS$1(fromModel) {
|
|
850
|
-
const graph = buildGraph$1();
|
|
851
|
-
const queue = [fromModel];
|
|
852
|
-
graph[fromModel].distance = 0;
|
|
853
|
-
while (queue.length) {
|
|
854
|
-
const current = queue.pop();
|
|
855
|
-
const adjacents = Object.keys(conversions$4[current]);
|
|
856
|
-
for (let len = adjacents.length, i = 0; i < len; i++) {
|
|
857
|
-
const adjacent = adjacents[i];
|
|
858
|
-
const node = graph[adjacent];
|
|
859
|
-
if (node.distance === -1) {
|
|
860
|
-
node.distance = graph[current].distance + 1;
|
|
861
|
-
node.parent = current;
|
|
862
|
-
queue.unshift(adjacent);
|
|
863
|
-
}
|
|
864
|
-
}
|
|
865
|
-
}
|
|
866
|
-
return graph;
|
|
867
|
-
}
|
|
868
|
-
function link$1(from, to) {
|
|
869
|
-
return function(args) {
|
|
870
|
-
return to(from(args));
|
|
871
|
-
};
|
|
872
|
-
}
|
|
873
|
-
function wrapConversion$1(toModel, graph) {
|
|
874
|
-
const path = [graph[toModel].parent, toModel];
|
|
875
|
-
let fn = conversions$4[graph[toModel].parent][toModel];
|
|
876
|
-
let cur = graph[toModel].parent;
|
|
877
|
-
while (graph[cur].parent) {
|
|
878
|
-
path.unshift(graph[cur].parent);
|
|
879
|
-
fn = link$1(conversions$4[graph[cur].parent][cur], fn);
|
|
880
|
-
cur = graph[cur].parent;
|
|
881
|
-
}
|
|
882
|
-
fn.conversion = path;
|
|
883
|
-
return fn;
|
|
884
|
-
}
|
|
885
|
-
var route$3 = function(fromModel) {
|
|
886
|
-
const graph = deriveBFS$1(fromModel);
|
|
887
|
-
const conversion = {};
|
|
888
|
-
const models2 = Object.keys(graph);
|
|
889
|
-
for (let len = models2.length, i = 0; i < len; i++) {
|
|
890
|
-
const toModel = models2[i];
|
|
891
|
-
const node = graph[toModel];
|
|
892
|
-
if (node.parent === null) {
|
|
893
|
-
continue;
|
|
894
|
-
}
|
|
895
|
-
conversion[toModel] = wrapConversion$1(toModel, graph);
|
|
896
|
-
}
|
|
897
|
-
return conversion;
|
|
898
|
-
};
|
|
899
|
-
const conversions$3 = conversions$5;
|
|
900
|
-
const route$2 = route$3;
|
|
901
|
-
const convert$2 = {};
|
|
902
|
-
const models$1 = Object.keys(conversions$3);
|
|
903
|
-
function wrapRaw$1(fn) {
|
|
904
|
-
const wrappedFn = function(...args) {
|
|
905
|
-
const arg0 = args[0];
|
|
906
|
-
if (arg0 === void 0 || arg0 === null) {
|
|
907
|
-
return arg0;
|
|
908
|
-
}
|
|
909
|
-
if (arg0.length > 1) {
|
|
910
|
-
args = arg0;
|
|
911
|
-
}
|
|
912
|
-
return fn(args);
|
|
913
|
-
};
|
|
914
|
-
if ("conversion" in fn) {
|
|
915
|
-
wrappedFn.conversion = fn.conversion;
|
|
916
|
-
}
|
|
917
|
-
return wrappedFn;
|
|
918
|
-
}
|
|
919
|
-
function wrapRounded$1(fn) {
|
|
920
|
-
const wrappedFn = function(...args) {
|
|
921
|
-
const arg0 = args[0];
|
|
922
|
-
if (arg0 === void 0 || arg0 === null) {
|
|
923
|
-
return arg0;
|
|
924
|
-
}
|
|
925
|
-
if (arg0.length > 1) {
|
|
926
|
-
args = arg0;
|
|
927
|
-
}
|
|
928
|
-
const result = fn(args);
|
|
929
|
-
if (typeof result === "object") {
|
|
930
|
-
for (let len = result.length, i = 0; i < len; i++) {
|
|
931
|
-
result[i] = Math.round(result[i]);
|
|
932
|
-
}
|
|
933
|
-
}
|
|
934
|
-
return result;
|
|
935
|
-
};
|
|
936
|
-
if ("conversion" in fn) {
|
|
937
|
-
wrappedFn.conversion = fn.conversion;
|
|
938
|
-
}
|
|
939
|
-
return wrappedFn;
|
|
940
|
-
}
|
|
941
|
-
models$1.forEach((fromModel) => {
|
|
942
|
-
convert$2[fromModel] = {};
|
|
943
|
-
Object.defineProperty(convert$2[fromModel], "channels", { value: conversions$3[fromModel].channels });
|
|
944
|
-
Object.defineProperty(convert$2[fromModel], "labels", { value: conversions$3[fromModel].labels });
|
|
945
|
-
const routes = route$2(fromModel);
|
|
946
|
-
const routeModels = Object.keys(routes);
|
|
947
|
-
routeModels.forEach((toModel) => {
|
|
948
|
-
const fn = routes[toModel];
|
|
949
|
-
convert$2[fromModel][toModel] = wrapRounded$1(fn);
|
|
950
|
-
convert$2[fromModel][toModel].raw = wrapRaw$1(fn);
|
|
951
|
-
});
|
|
952
|
-
});
|
|
953
|
-
var colorConvert$1 = convert$2;
|
|
954
|
-
(function(module) {
|
|
955
|
-
const wrapAnsi16 = (fn, offset) => (...args) => {
|
|
956
|
-
const code = fn(...args);
|
|
957
|
-
return `\x1B[${code + offset}m`;
|
|
958
|
-
};
|
|
959
|
-
const wrapAnsi256 = (fn, offset) => (...args) => {
|
|
960
|
-
const code = fn(...args);
|
|
961
|
-
return `\x1B[${38 + offset};5;${code}m`;
|
|
962
|
-
};
|
|
963
|
-
const wrapAnsi16m = (fn, offset) => (...args) => {
|
|
964
|
-
const rgb = fn(...args);
|
|
965
|
-
return `\x1B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`;
|
|
966
|
-
};
|
|
967
|
-
const ansi2ansi = (n) => n;
|
|
968
|
-
const rgb2rgb = (r, g, b) => [r, g, b];
|
|
969
|
-
const setLazyProperty = (object, property, get) => {
|
|
970
|
-
Object.defineProperty(object, property, {
|
|
971
|
-
get: () => {
|
|
972
|
-
const value = get();
|
|
973
|
-
Object.defineProperty(object, property, {
|
|
974
|
-
value,
|
|
975
|
-
enumerable: true,
|
|
976
|
-
configurable: true
|
|
977
|
-
});
|
|
978
|
-
return value;
|
|
979
|
-
},
|
|
980
|
-
enumerable: true,
|
|
981
|
-
configurable: true
|
|
982
|
-
});
|
|
983
|
-
};
|
|
984
|
-
let colorConvert2;
|
|
985
|
-
const makeDynamicStyles = (wrap, targetSpace, identity, isBackground) => {
|
|
986
|
-
if (colorConvert2 === void 0) {
|
|
987
|
-
colorConvert2 = colorConvert$1;
|
|
988
|
-
}
|
|
989
|
-
const offset = isBackground ? 10 : 0;
|
|
990
|
-
const styles2 = {};
|
|
991
|
-
for (const [sourceSpace, suite] of Object.entries(colorConvert2)) {
|
|
992
|
-
const name = sourceSpace === "ansi16" ? "ansi" : sourceSpace;
|
|
993
|
-
if (sourceSpace === targetSpace) {
|
|
994
|
-
styles2[name] = wrap(identity, offset);
|
|
995
|
-
} else if (typeof suite === "object") {
|
|
996
|
-
styles2[name] = wrap(suite[targetSpace], offset);
|
|
997
|
-
}
|
|
998
|
-
}
|
|
999
|
-
return styles2;
|
|
1000
|
-
};
|
|
1001
|
-
function assembleStyles() {
|
|
1002
|
-
const codes = /* @__PURE__ */ new Map();
|
|
1003
|
-
const styles2 = {
|
|
1004
|
-
modifier: {
|
|
1005
|
-
reset: [0, 0],
|
|
1006
|
-
bold: [1, 22],
|
|
1007
|
-
dim: [2, 22],
|
|
1008
|
-
italic: [3, 23],
|
|
1009
|
-
underline: [4, 24],
|
|
1010
|
-
inverse: [7, 27],
|
|
1011
|
-
hidden: [8, 28],
|
|
1012
|
-
strikethrough: [9, 29]
|
|
1013
|
-
},
|
|
1014
|
-
color: {
|
|
1015
|
-
black: [30, 39],
|
|
1016
|
-
red: [31, 39],
|
|
1017
|
-
green: [32, 39],
|
|
1018
|
-
yellow: [33, 39],
|
|
1019
|
-
blue: [34, 39],
|
|
1020
|
-
magenta: [35, 39],
|
|
1021
|
-
cyan: [36, 39],
|
|
1022
|
-
white: [37, 39],
|
|
1023
|
-
blackBright: [90, 39],
|
|
1024
|
-
redBright: [91, 39],
|
|
1025
|
-
greenBright: [92, 39],
|
|
1026
|
-
yellowBright: [93, 39],
|
|
1027
|
-
blueBright: [94, 39],
|
|
1028
|
-
magentaBright: [95, 39],
|
|
1029
|
-
cyanBright: [96, 39],
|
|
1030
|
-
whiteBright: [97, 39]
|
|
1031
|
-
},
|
|
1032
|
-
bgColor: {
|
|
1033
|
-
bgBlack: [40, 49],
|
|
1034
|
-
bgRed: [41, 49],
|
|
1035
|
-
bgGreen: [42, 49],
|
|
1036
|
-
bgYellow: [43, 49],
|
|
1037
|
-
bgBlue: [44, 49],
|
|
1038
|
-
bgMagenta: [45, 49],
|
|
1039
|
-
bgCyan: [46, 49],
|
|
1040
|
-
bgWhite: [47, 49],
|
|
1041
|
-
bgBlackBright: [100, 49],
|
|
1042
|
-
bgRedBright: [101, 49],
|
|
1043
|
-
bgGreenBright: [102, 49],
|
|
1044
|
-
bgYellowBright: [103, 49],
|
|
1045
|
-
bgBlueBright: [104, 49],
|
|
1046
|
-
bgMagentaBright: [105, 49],
|
|
1047
|
-
bgCyanBright: [106, 49],
|
|
1048
|
-
bgWhiteBright: [107, 49]
|
|
1049
|
-
}
|
|
1050
|
-
};
|
|
1051
|
-
styles2.color.gray = styles2.color.blackBright;
|
|
1052
|
-
styles2.bgColor.bgGray = styles2.bgColor.bgBlackBright;
|
|
1053
|
-
styles2.color.grey = styles2.color.blackBright;
|
|
1054
|
-
styles2.bgColor.bgGrey = styles2.bgColor.bgBlackBright;
|
|
1055
|
-
for (const [groupName, group] of Object.entries(styles2)) {
|
|
1056
|
-
for (const [styleName, style] of Object.entries(group)) {
|
|
1057
|
-
styles2[styleName] = {
|
|
1058
|
-
open: `\x1B[${style[0]}m`,
|
|
1059
|
-
close: `\x1B[${style[1]}m`
|
|
1060
|
-
};
|
|
1061
|
-
group[styleName] = styles2[styleName];
|
|
1062
|
-
codes.set(style[0], style[1]);
|
|
1063
|
-
}
|
|
1064
|
-
Object.defineProperty(styles2, groupName, {
|
|
1065
|
-
value: group,
|
|
1066
|
-
enumerable: false
|
|
1067
|
-
});
|
|
1068
|
-
}
|
|
1069
|
-
Object.defineProperty(styles2, "codes", {
|
|
1070
|
-
value: codes,
|
|
1071
|
-
enumerable: false
|
|
1
|
+
const getBaseUrl = () => {
|
|
2
|
+
var _a;
|
|
3
|
+
if (typeof process !== "undefined" && ((_a = process.env) == null ? void 0 : _a.JAM_COMMENTS_BASE_URL)) {
|
|
4
|
+
return process.env["JAM_COMMENTS_BASE_URL"];
|
|
5
|
+
}
|
|
6
|
+
return "https://go.jamcomments.com";
|
|
7
|
+
};
|
|
8
|
+
const markupFetcher = (platform) => {
|
|
9
|
+
return async ({
|
|
10
|
+
path,
|
|
11
|
+
domain,
|
|
12
|
+
apiKey,
|
|
13
|
+
embedScript = false
|
|
14
|
+
}) => {
|
|
15
|
+
const params = new URLSearchParams({
|
|
16
|
+
path,
|
|
17
|
+
domain,
|
|
18
|
+
force_embed: "1",
|
|
19
|
+
embed_script: embedScript ? "1" : "0"
|
|
1072
20
|
});
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
setLazyProperty(styles2.bgColor, "ansi256", () => makeDynamicStyles(wrapAnsi256, "ansi256", ansi2ansi, true));
|
|
1080
|
-
setLazyProperty(styles2.bgColor, "ansi16m", () => makeDynamicStyles(wrapAnsi16m, "rgb", rgb2rgb, true));
|
|
1081
|
-
return styles2;
|
|
1082
|
-
}
|
|
1083
|
-
Object.defineProperty(module, "exports", {
|
|
1084
|
-
enumerable: true,
|
|
1085
|
-
get: assembleStyles
|
|
1086
|
-
});
|
|
1087
|
-
})(ansiStyles$3);
|
|
1088
|
-
var browser$1 = {
|
|
1089
|
-
stdout: false,
|
|
1090
|
-
stderr: false
|
|
1091
|
-
};
|
|
1092
|
-
const stringReplaceAll$3 = (string, substring, replacer) => {
|
|
1093
|
-
let index = string.indexOf(substring);
|
|
1094
|
-
if (index === -1) {
|
|
1095
|
-
return string;
|
|
1096
|
-
}
|
|
1097
|
-
const substringLength = substring.length;
|
|
1098
|
-
let endIndex = 0;
|
|
1099
|
-
let returnValue = "";
|
|
1100
|
-
do {
|
|
1101
|
-
returnValue += string.substr(endIndex, index - endIndex) + substring + replacer;
|
|
1102
|
-
endIndex = index + substringLength;
|
|
1103
|
-
index = string.indexOf(substring, endIndex);
|
|
1104
|
-
} while (index !== -1);
|
|
1105
|
-
returnValue += string.substr(endIndex);
|
|
1106
|
-
return returnValue;
|
|
1107
|
-
};
|
|
1108
|
-
const stringEncaseCRLFWithFirstIndex$3 = (string, prefix, postfix, index) => {
|
|
1109
|
-
let endIndex = 0;
|
|
1110
|
-
let returnValue = "";
|
|
1111
|
-
do {
|
|
1112
|
-
const gotCR = string[index - 1] === "\r";
|
|
1113
|
-
returnValue += string.substr(endIndex, (gotCR ? index - 1 : index) - endIndex) + prefix + (gotCR ? "\r\n" : "\n") + postfix;
|
|
1114
|
-
endIndex = index + 1;
|
|
1115
|
-
index = string.indexOf("\n", endIndex);
|
|
1116
|
-
} while (index !== -1);
|
|
1117
|
-
returnValue += string.substr(endIndex);
|
|
1118
|
-
return returnValue;
|
|
1119
|
-
};
|
|
1120
|
-
var util$1 = {
|
|
1121
|
-
stringReplaceAll: stringReplaceAll$3,
|
|
1122
|
-
stringEncaseCRLFWithFirstIndex: stringEncaseCRLFWithFirstIndex$3
|
|
1123
|
-
};
|
|
1124
|
-
const TEMPLATE_REGEX$1 = /(?:\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi;
|
|
1125
|
-
const STYLE_REGEX$1 = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
|
|
1126
|
-
const STRING_REGEX$1 = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
|
|
1127
|
-
const ESCAPE_REGEX$1 = /\\(u(?:[a-f\d]{4}|{[a-f\d]{1,6}})|x[a-f\d]{2}|.)|([^\\])/gi;
|
|
1128
|
-
const ESCAPES$1 = /* @__PURE__ */ new Map([
|
|
1129
|
-
["n", "\n"],
|
|
1130
|
-
["r", "\r"],
|
|
1131
|
-
["t", " "],
|
|
1132
|
-
["b", "\b"],
|
|
1133
|
-
["f", "\f"],
|
|
1134
|
-
["v", "\v"],
|
|
1135
|
-
["0", "\0"],
|
|
1136
|
-
["\\", "\\"],
|
|
1137
|
-
["e", "\x1B"],
|
|
1138
|
-
["a", "\x07"]
|
|
1139
|
-
]);
|
|
1140
|
-
function unescape$2(c) {
|
|
1141
|
-
const u = c[0] === "u";
|
|
1142
|
-
const bracket = c[1] === "{";
|
|
1143
|
-
if (u && !bracket && c.length === 5 || c[0] === "x" && c.length === 3) {
|
|
1144
|
-
return String.fromCharCode(parseInt(c.slice(1), 16));
|
|
1145
|
-
}
|
|
1146
|
-
if (u && bracket) {
|
|
1147
|
-
return String.fromCodePoint(parseInt(c.slice(2, -1), 16));
|
|
1148
|
-
}
|
|
1149
|
-
return ESCAPES$1.get(c) || c;
|
|
1150
|
-
}
|
|
1151
|
-
function parseArguments$1(name, arguments_) {
|
|
1152
|
-
const results = [];
|
|
1153
|
-
const chunks = arguments_.trim().split(/\s*,\s*/g);
|
|
1154
|
-
let matches;
|
|
1155
|
-
for (const chunk of chunks) {
|
|
1156
|
-
const number = Number(chunk);
|
|
1157
|
-
if (!Number.isNaN(number)) {
|
|
1158
|
-
results.push(number);
|
|
1159
|
-
} else if (matches = chunk.match(STRING_REGEX$1)) {
|
|
1160
|
-
results.push(matches[2].replace(ESCAPE_REGEX$1, (m, escape, character) => escape ? unescape$2(escape) : character));
|
|
1161
|
-
} else {
|
|
1162
|
-
throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`);
|
|
1163
|
-
}
|
|
1164
|
-
}
|
|
1165
|
-
return results;
|
|
1166
|
-
}
|
|
1167
|
-
function parseStyle$1(style) {
|
|
1168
|
-
STYLE_REGEX$1.lastIndex = 0;
|
|
1169
|
-
const results = [];
|
|
1170
|
-
let matches;
|
|
1171
|
-
while ((matches = STYLE_REGEX$1.exec(style)) !== null) {
|
|
1172
|
-
const name = matches[1];
|
|
1173
|
-
if (matches[2]) {
|
|
1174
|
-
const args = parseArguments$1(name, matches[2]);
|
|
1175
|
-
results.push([name].concat(args));
|
|
1176
|
-
} else {
|
|
1177
|
-
results.push([name]);
|
|
1178
|
-
}
|
|
1179
|
-
}
|
|
1180
|
-
return results;
|
|
1181
|
-
}
|
|
1182
|
-
function buildStyle$1(chalk2, styles2) {
|
|
1183
|
-
const enabled = {};
|
|
1184
|
-
for (const layer of styles2) {
|
|
1185
|
-
for (const style of layer.styles) {
|
|
1186
|
-
enabled[style[0]] = layer.inverse ? null : style.slice(1);
|
|
1187
|
-
}
|
|
1188
|
-
}
|
|
1189
|
-
let current = chalk2;
|
|
1190
|
-
for (const [styleName, styles3] of Object.entries(enabled)) {
|
|
1191
|
-
if (!Array.isArray(styles3)) {
|
|
1192
|
-
continue;
|
|
1193
|
-
}
|
|
1194
|
-
if (!(styleName in current)) {
|
|
1195
|
-
throw new Error(`Unknown Chalk style: ${styleName}`);
|
|
1196
|
-
}
|
|
1197
|
-
current = styles3.length > 0 ? current[styleName](...styles3) : current[styleName];
|
|
1198
|
-
}
|
|
1199
|
-
return current;
|
|
1200
|
-
}
|
|
1201
|
-
var templates$1 = (chalk2, temporary) => {
|
|
1202
|
-
const styles2 = [];
|
|
1203
|
-
const chunks = [];
|
|
1204
|
-
let chunk = [];
|
|
1205
|
-
temporary.replace(TEMPLATE_REGEX$1, (m, escapeCharacter, inverse, style, close, character) => {
|
|
1206
|
-
if (escapeCharacter) {
|
|
1207
|
-
chunk.push(unescape$2(escapeCharacter));
|
|
1208
|
-
} else if (style) {
|
|
1209
|
-
const string = chunk.join("");
|
|
1210
|
-
chunk = [];
|
|
1211
|
-
chunks.push(styles2.length === 0 ? string : buildStyle$1(chalk2, styles2)(string));
|
|
1212
|
-
styles2.push({ inverse, styles: parseStyle$1(style) });
|
|
1213
|
-
} else if (close) {
|
|
1214
|
-
if (styles2.length === 0) {
|
|
1215
|
-
throw new Error("Found extraneous } in Chalk template literal");
|
|
21
|
+
const response = await fetch(`${getBaseUrl()}/api/markup?${params}`, {
|
|
22
|
+
method: "GET",
|
|
23
|
+
headers: {
|
|
24
|
+
Authorization: `Bearer ${apiKey}`,
|
|
25
|
+
Accept: "application/json",
|
|
26
|
+
"X-Platform": platform
|
|
1216
27
|
}
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
} else {
|
|
1221
|
-
chunk.push(character);
|
|
1222
|
-
}
|
|
1223
|
-
});
|
|
1224
|
-
chunks.push(chunk.join(""));
|
|
1225
|
-
if (styles2.length > 0) {
|
|
1226
|
-
const errMessage = `Chalk template literal is missing ${styles2.length} closing bracket${styles2.length === 1 ? "" : "s"} (\`}\`)`;
|
|
1227
|
-
throw new Error(errMessage);
|
|
1228
|
-
}
|
|
1229
|
-
return chunks.join("");
|
|
1230
|
-
};
|
|
1231
|
-
const ansiStyles$2 = ansiStyles$3.exports;
|
|
1232
|
-
const { stdout: stdoutColor$1, stderr: stderrColor$1 } = browser$1;
|
|
1233
|
-
const {
|
|
1234
|
-
stringReplaceAll: stringReplaceAll$2,
|
|
1235
|
-
stringEncaseCRLFWithFirstIndex: stringEncaseCRLFWithFirstIndex$2
|
|
1236
|
-
} = util$1;
|
|
1237
|
-
const { isArray: isArray$1 } = Array;
|
|
1238
|
-
const levelMapping$1 = [
|
|
1239
|
-
"ansi",
|
|
1240
|
-
"ansi",
|
|
1241
|
-
"ansi256",
|
|
1242
|
-
"ansi16m"
|
|
1243
|
-
];
|
|
1244
|
-
const styles$1 = /* @__PURE__ */ Object.create(null);
|
|
1245
|
-
const applyOptions$1 = (object, options = {}) => {
|
|
1246
|
-
if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
|
|
1247
|
-
throw new Error("The `level` option should be an integer from 0 to 3");
|
|
1248
|
-
}
|
|
1249
|
-
const colorLevel = stdoutColor$1 ? stdoutColor$1.level : 0;
|
|
1250
|
-
object.level = options.level === void 0 ? colorLevel : options.level;
|
|
1251
|
-
};
|
|
1252
|
-
class ChalkClass$1 {
|
|
1253
|
-
constructor(options) {
|
|
1254
|
-
return chalkFactory$1(options);
|
|
1255
|
-
}
|
|
1256
|
-
}
|
|
1257
|
-
const chalkFactory$1 = (options) => {
|
|
1258
|
-
const chalk2 = {};
|
|
1259
|
-
applyOptions$1(chalk2, options);
|
|
1260
|
-
chalk2.template = (...arguments_) => chalkTag$1(chalk2.template, ...arguments_);
|
|
1261
|
-
Object.setPrototypeOf(chalk2, Chalk$1.prototype);
|
|
1262
|
-
Object.setPrototypeOf(chalk2.template, chalk2);
|
|
1263
|
-
chalk2.template.constructor = () => {
|
|
1264
|
-
throw new Error("`chalk.constructor()` is deprecated. Use `new chalk.Instance()` instead.");
|
|
1265
|
-
};
|
|
1266
|
-
chalk2.template.Instance = ChalkClass$1;
|
|
1267
|
-
return chalk2.template;
|
|
1268
|
-
};
|
|
1269
|
-
function Chalk$1(options) {
|
|
1270
|
-
return chalkFactory$1(options);
|
|
1271
|
-
}
|
|
1272
|
-
for (const [styleName, style] of Object.entries(ansiStyles$2)) {
|
|
1273
|
-
styles$1[styleName] = {
|
|
1274
|
-
get() {
|
|
1275
|
-
const builder = createBuilder$1(this, createStyler$1(style.open, style.close, this._styler), this._isEmpty);
|
|
1276
|
-
Object.defineProperty(this, styleName, { value: builder });
|
|
1277
|
-
return builder;
|
|
1278
|
-
}
|
|
1279
|
-
};
|
|
1280
|
-
}
|
|
1281
|
-
styles$1.visible = {
|
|
1282
|
-
get() {
|
|
1283
|
-
const builder = createBuilder$1(this, this._styler, true);
|
|
1284
|
-
Object.defineProperty(this, "visible", { value: builder });
|
|
1285
|
-
return builder;
|
|
1286
|
-
}
|
|
1287
|
-
};
|
|
1288
|
-
const usedModels$1 = ["rgb", "hex", "keyword", "hsl", "hsv", "hwb", "ansi", "ansi256"];
|
|
1289
|
-
for (const model of usedModels$1) {
|
|
1290
|
-
styles$1[model] = {
|
|
1291
|
-
get() {
|
|
1292
|
-
const { level } = this;
|
|
1293
|
-
return function(...arguments_) {
|
|
1294
|
-
const styler = createStyler$1(ansiStyles$2.color[levelMapping$1[level]][model](...arguments_), ansiStyles$2.color.close, this._styler);
|
|
1295
|
-
return createBuilder$1(this, styler, this._isEmpty);
|
|
1296
|
-
};
|
|
1297
|
-
}
|
|
1298
|
-
};
|
|
1299
|
-
}
|
|
1300
|
-
for (const model of usedModels$1) {
|
|
1301
|
-
const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
|
|
1302
|
-
styles$1[bgModel] = {
|
|
1303
|
-
get() {
|
|
1304
|
-
const { level } = this;
|
|
1305
|
-
return function(...arguments_) {
|
|
1306
|
-
const styler = createStyler$1(ansiStyles$2.bgColor[levelMapping$1[level]][model](...arguments_), ansiStyles$2.bgColor.close, this._styler);
|
|
1307
|
-
return createBuilder$1(this, styler, this._isEmpty);
|
|
1308
|
-
};
|
|
1309
|
-
}
|
|
1310
|
-
};
|
|
1311
|
-
}
|
|
1312
|
-
const proto$1 = Object.defineProperties(() => {
|
|
1313
|
-
}, __spreadProps(__spreadValues({}, styles$1), {
|
|
1314
|
-
level: {
|
|
1315
|
-
enumerable: true,
|
|
1316
|
-
get() {
|
|
1317
|
-
return this._generator.level;
|
|
1318
|
-
},
|
|
1319
|
-
set(level) {
|
|
1320
|
-
this._generator.level = level;
|
|
28
|
+
});
|
|
29
|
+
if (response.status === 401) {
|
|
30
|
+
throw `Unauthorized! Are your domain and API key set correctly?`;
|
|
1321
31
|
}
|
|
1322
|
-
|
|
1323
|
-
}
|
|
1324
|
-
const createStyler$1 = (open, close, parent) => {
|
|
1325
|
-
let openAll;
|
|
1326
|
-
let closeAll;
|
|
1327
|
-
if (parent === void 0) {
|
|
1328
|
-
openAll = open;
|
|
1329
|
-
closeAll = close;
|
|
1330
|
-
} else {
|
|
1331
|
-
openAll = parent.openAll + open;
|
|
1332
|
-
closeAll = close + parent.closeAll;
|
|
1333
|
-
}
|
|
1334
|
-
return {
|
|
1335
|
-
open,
|
|
1336
|
-
close,
|
|
1337
|
-
openAll,
|
|
1338
|
-
closeAll,
|
|
1339
|
-
parent
|
|
1340
|
-
};
|
|
1341
|
-
};
|
|
1342
|
-
const createBuilder$1 = (self2, _styler, _isEmpty) => {
|
|
1343
|
-
const builder = (...arguments_) => {
|
|
1344
|
-
if (isArray$1(arguments_[0]) && isArray$1(arguments_[0].raw)) {
|
|
1345
|
-
return applyStyle$1(builder, chalkTag$1(builder, ...arguments_));
|
|
32
|
+
if (!response.ok) {
|
|
33
|
+
throw `Request failed! Status code: ${response.status}, message: ${response.statusText}`;
|
|
1346
34
|
}
|
|
1347
|
-
return
|
|
35
|
+
return await response.text();
|
|
1348
36
|
};
|
|
1349
|
-
Object.setPrototypeOf(builder, proto$1);
|
|
1350
|
-
builder._generator = self2;
|
|
1351
|
-
builder._styler = _styler;
|
|
1352
|
-
builder._isEmpty = _isEmpty;
|
|
1353
|
-
return builder;
|
|
1354
37
|
};
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
if (styler === void 0) {
|
|
1361
|
-
return string;
|
|
1362
|
-
}
|
|
1363
|
-
const { openAll, closeAll } = styler;
|
|
1364
|
-
if (string.indexOf("\x1B") !== -1) {
|
|
1365
|
-
while (styler !== void 0) {
|
|
1366
|
-
string = stringReplaceAll$2(string, styler.close, styler.open);
|
|
1367
|
-
styler = styler.parent;
|
|
1368
|
-
}
|
|
1369
|
-
}
|
|
1370
|
-
const lfIndex = string.indexOf("\n");
|
|
1371
|
-
if (lfIndex !== -1) {
|
|
1372
|
-
string = stringEncaseCRLFWithFirstIndex$2(string, closeAll, openAll, lfIndex);
|
|
1373
|
-
}
|
|
1374
|
-
return openAll + string + closeAll;
|
|
1375
|
-
};
|
|
1376
|
-
let template$1;
|
|
1377
|
-
const chalkTag$1 = (chalk2, ...strings) => {
|
|
1378
|
-
const [firstString] = strings;
|
|
1379
|
-
if (!isArray$1(firstString) || !isArray$1(firstString.raw)) {
|
|
1380
|
-
return strings.join(" ");
|
|
1381
|
-
}
|
|
1382
|
-
const arguments_ = strings.slice(1);
|
|
1383
|
-
const parts = [firstString.raw[0]];
|
|
1384
|
-
for (let i = 1; i < firstString.length; i++) {
|
|
1385
|
-
parts.push(String(arguments_[i - 1]).replace(/[{}\\]/g, "\\$&"), String(firstString.raw[i]));
|
|
1386
|
-
}
|
|
1387
|
-
if (template$1 === void 0) {
|
|
1388
|
-
template$1 = templates$1;
|
|
38
|
+
var chalk$1 = { exports: {} };
|
|
39
|
+
var matchOperatorsRe = /[|\\{}()[\]^$+*?.]/g;
|
|
40
|
+
var escapeStringRegexp = function(str) {
|
|
41
|
+
if (typeof str !== "string") {
|
|
42
|
+
throw new TypeError("Expected a string");
|
|
1389
43
|
}
|
|
1390
|
-
return
|
|
44
|
+
return str.replace(matchOperatorsRe, "\\$&");
|
|
1391
45
|
};
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
chalk$1.supportsColor = stdoutColor$1;
|
|
1395
|
-
chalk$1.stderr = Chalk$1({ level: stderrColor$1 ? stderrColor$1.level : 0 });
|
|
1396
|
-
chalk$1.stderr.supportsColor = stderrColor$1;
|
|
1397
|
-
var source = chalk$1;
|
|
1398
|
-
const log = (message) => {
|
|
1399
|
-
console.log(`${source.magenta("JamComments:")} ${message}`);
|
|
1400
|
-
};
|
|
1401
|
-
var log$1 = log;
|
|
1402
|
-
var __defProp$1 = Object.defineProperty;
|
|
1403
|
-
var __defProps2 = Object.defineProperties;
|
|
1404
|
-
var __getOwnPropDescs2 = Object.getOwnPropertyDescriptors;
|
|
1405
|
-
var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
|
|
1406
|
-
var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
|
|
1407
|
-
var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
|
|
1408
|
-
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1409
|
-
var __spreadValues$1 = (a, b) => {
|
|
1410
|
-
for (var prop in b || (b = {}))
|
|
1411
|
-
if (__hasOwnProp$1.call(b, prop))
|
|
1412
|
-
__defNormalProp$1(a, prop, b[prop]);
|
|
1413
|
-
if (__getOwnPropSymbols$1)
|
|
1414
|
-
for (var prop of __getOwnPropSymbols$1(b)) {
|
|
1415
|
-
if (__propIsEnum$1.call(b, prop))
|
|
1416
|
-
__defNormalProp$1(a, prop, b[prop]);
|
|
1417
|
-
}
|
|
1418
|
-
return a;
|
|
1419
|
-
};
|
|
1420
|
-
var __spreadProps2 = (a, b) => __defProps2(a, __getOwnPropDescs2(b));
|
|
1421
|
-
var ansiStyles$1 = { exports: {} };
|
|
46
|
+
var ansiStyles = { exports: {} };
|
|
47
|
+
var conversions$2 = { exports: {} };
|
|
1422
48
|
var colorName = {
|
|
1423
49
|
"aliceblue": [240, 248, 255],
|
|
1424
50
|
"antiquewhite": [250, 235, 215],
|
|
@@ -1569,12 +195,14 @@ var colorName = {
|
|
|
1569
195
|
"yellow": [255, 255, 0],
|
|
1570
196
|
"yellowgreen": [154, 205, 50]
|
|
1571
197
|
};
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
for (
|
|
1575
|
-
|
|
198
|
+
var cssKeywords = colorName;
|
|
199
|
+
var reverseKeywords = {};
|
|
200
|
+
for (var key in cssKeywords) {
|
|
201
|
+
if (cssKeywords.hasOwnProperty(key)) {
|
|
202
|
+
reverseKeywords[cssKeywords[key]] = key;
|
|
203
|
+
}
|
|
1576
204
|
}
|
|
1577
|
-
|
|
205
|
+
var convert$1 = conversions$2.exports = {
|
|
1578
206
|
rgb: { channels: 3, labels: "rgb" },
|
|
1579
207
|
hsl: { channels: 3, labels: "hsl" },
|
|
1580
208
|
hsv: { channels: 3, labels: "hsv" },
|
|
@@ -1591,32 +219,35 @@ const convert$1 = {
|
|
|
1591
219
|
apple: { channels: 3, labels: ["r16", "g16", "b16"] },
|
|
1592
220
|
gray: { channels: 1, labels: ["gray"] }
|
|
1593
221
|
};
|
|
1594
|
-
var
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
222
|
+
for (var model in convert$1) {
|
|
223
|
+
if (convert$1.hasOwnProperty(model)) {
|
|
224
|
+
if (!("channels" in convert$1[model])) {
|
|
225
|
+
throw new Error("missing channels property: " + model);
|
|
226
|
+
}
|
|
227
|
+
if (!("labels" in convert$1[model])) {
|
|
228
|
+
throw new Error("missing channel labels property: " + model);
|
|
229
|
+
}
|
|
230
|
+
if (convert$1[model].labels.length !== convert$1[model].channels) {
|
|
231
|
+
throw new Error("channel and label counts mismatch: " + model);
|
|
232
|
+
}
|
|
233
|
+
var channels = convert$1[model].channels;
|
|
234
|
+
var labels = convert$1[model].labels;
|
|
235
|
+
delete convert$1[model].channels;
|
|
236
|
+
delete convert$1[model].labels;
|
|
237
|
+
Object.defineProperty(convert$1[model], "channels", { value: channels });
|
|
238
|
+
Object.defineProperty(convert$1[model], "labels", { value: labels });
|
|
1604
239
|
}
|
|
1605
|
-
const { channels, labels } = convert$1[model];
|
|
1606
|
-
delete convert$1[model].channels;
|
|
1607
|
-
delete convert$1[model].labels;
|
|
1608
|
-
Object.defineProperty(convert$1[model], "channels", { value: channels });
|
|
1609
|
-
Object.defineProperty(convert$1[model], "labels", { value: labels });
|
|
1610
240
|
}
|
|
1611
241
|
convert$1.rgb.hsl = function(rgb) {
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
242
|
+
var r = rgb[0] / 255;
|
|
243
|
+
var g = rgb[1] / 255;
|
|
244
|
+
var b = rgb[2] / 255;
|
|
245
|
+
var min = Math.min(r, g, b);
|
|
246
|
+
var max = Math.max(r, g, b);
|
|
247
|
+
var delta = max - min;
|
|
248
|
+
var h;
|
|
249
|
+
var s;
|
|
250
|
+
var l;
|
|
1620
251
|
if (max === min) {
|
|
1621
252
|
h = 0;
|
|
1622
253
|
} else if (r === max) {
|
|
@@ -1630,7 +261,7 @@ convert$1.rgb.hsl = function(rgb) {
|
|
|
1630
261
|
if (h < 0) {
|
|
1631
262
|
h += 360;
|
|
1632
263
|
}
|
|
1633
|
-
|
|
264
|
+
l = (min + max) / 2;
|
|
1634
265
|
if (max === min) {
|
|
1635
266
|
s = 0;
|
|
1636
267
|
} else if (l <= 0.5) {
|
|
@@ -1641,22 +272,21 @@ convert$1.rgb.hsl = function(rgb) {
|
|
|
1641
272
|
return [h, s * 100, l * 100];
|
|
1642
273
|
};
|
|
1643
274
|
convert$1.rgb.hsv = function(rgb) {
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
275
|
+
var rdif;
|
|
276
|
+
var gdif;
|
|
277
|
+
var bdif;
|
|
278
|
+
var h;
|
|
279
|
+
var s;
|
|
280
|
+
var r = rgb[0] / 255;
|
|
281
|
+
var g = rgb[1] / 255;
|
|
282
|
+
var b = rgb[2] / 255;
|
|
283
|
+
var v = Math.max(r, g, b);
|
|
284
|
+
var diff = v - Math.min(r, g, b);
|
|
285
|
+
var diffc = function(c) {
|
|
1655
286
|
return (v - c) / 6 / diff + 1 / 2;
|
|
1656
287
|
};
|
|
1657
288
|
if (diff === 0) {
|
|
1658
|
-
h = 0;
|
|
1659
|
-
s = 0;
|
|
289
|
+
h = s = 0;
|
|
1660
290
|
} else {
|
|
1661
291
|
s = diff / v;
|
|
1662
292
|
rdif = diffc(r);
|
|
@@ -1682,40 +312,46 @@ convert$1.rgb.hsv = function(rgb) {
|
|
|
1682
312
|
];
|
|
1683
313
|
};
|
|
1684
314
|
convert$1.rgb.hwb = function(rgb) {
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
315
|
+
var r = rgb[0];
|
|
316
|
+
var g = rgb[1];
|
|
317
|
+
var b = rgb[2];
|
|
318
|
+
var h = convert$1.rgb.hsl(rgb)[0];
|
|
319
|
+
var w = 1 / 255 * Math.min(r, Math.min(g, b));
|
|
1690
320
|
b = 1 - 1 / 255 * Math.max(r, Math.max(g, b));
|
|
1691
321
|
return [h, w * 100, b * 100];
|
|
1692
322
|
};
|
|
1693
323
|
convert$1.rgb.cmyk = function(rgb) {
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
324
|
+
var r = rgb[0] / 255;
|
|
325
|
+
var g = rgb[1] / 255;
|
|
326
|
+
var b = rgb[2] / 255;
|
|
327
|
+
var c;
|
|
328
|
+
var m;
|
|
329
|
+
var y;
|
|
330
|
+
var k;
|
|
331
|
+
k = Math.min(1 - r, 1 - g, 1 - b);
|
|
332
|
+
c = (1 - r - k) / (1 - k) || 0;
|
|
333
|
+
m = (1 - g - k) / (1 - k) || 0;
|
|
334
|
+
y = (1 - b - k) / (1 - k) || 0;
|
|
1701
335
|
return [c * 100, m * 100, y * 100, k * 100];
|
|
1702
336
|
};
|
|
1703
337
|
function comparativeDistance(x, y) {
|
|
1704
|
-
return (x[0] - y[0]
|
|
338
|
+
return Math.pow(x[0] - y[0], 2) + Math.pow(x[1] - y[1], 2) + Math.pow(x[2] - y[2], 2);
|
|
1705
339
|
}
|
|
1706
340
|
convert$1.rgb.keyword = function(rgb) {
|
|
1707
|
-
|
|
341
|
+
var reversed = reverseKeywords[rgb];
|
|
1708
342
|
if (reversed) {
|
|
1709
343
|
return reversed;
|
|
1710
344
|
}
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
for (
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
currentClosestDistance
|
|
1718
|
-
|
|
345
|
+
var currentClosestDistance = Infinity;
|
|
346
|
+
var currentClosestKeyword;
|
|
347
|
+
for (var keyword in cssKeywords) {
|
|
348
|
+
if (cssKeywords.hasOwnProperty(keyword)) {
|
|
349
|
+
var value = cssKeywords[keyword];
|
|
350
|
+
var distance = comparativeDistance(rgb, value);
|
|
351
|
+
if (distance < currentClosestDistance) {
|
|
352
|
+
currentClosestDistance = distance;
|
|
353
|
+
currentClosestKeyword = keyword;
|
|
354
|
+
}
|
|
1719
355
|
}
|
|
1720
356
|
}
|
|
1721
357
|
return currentClosestKeyword;
|
|
@@ -1724,40 +360,45 @@ convert$1.keyword.rgb = function(keyword) {
|
|
|
1724
360
|
return cssKeywords[keyword];
|
|
1725
361
|
};
|
|
1726
362
|
convert$1.rgb.xyz = function(rgb) {
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
r = r > 0.04045 ? ((r + 0.055) / 1.055
|
|
1731
|
-
g = g > 0.04045 ? ((g + 0.055) / 1.055
|
|
1732
|
-
b = b > 0.04045 ? ((b + 0.055) / 1.055
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
363
|
+
var r = rgb[0] / 255;
|
|
364
|
+
var g = rgb[1] / 255;
|
|
365
|
+
var b = rgb[2] / 255;
|
|
366
|
+
r = r > 0.04045 ? Math.pow((r + 0.055) / 1.055, 2.4) : r / 12.92;
|
|
367
|
+
g = g > 0.04045 ? Math.pow((g + 0.055) / 1.055, 2.4) : g / 12.92;
|
|
368
|
+
b = b > 0.04045 ? Math.pow((b + 0.055) / 1.055, 2.4) : b / 12.92;
|
|
369
|
+
var x = r * 0.4124 + g * 0.3576 + b * 0.1805;
|
|
370
|
+
var y = r * 0.2126 + g * 0.7152 + b * 0.0722;
|
|
371
|
+
var z = r * 0.0193 + g * 0.1192 + b * 0.9505;
|
|
1736
372
|
return [x * 100, y * 100, z * 100];
|
|
1737
373
|
};
|
|
1738
374
|
convert$1.rgb.lab = function(rgb) {
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
375
|
+
var xyz = convert$1.rgb.xyz(rgb);
|
|
376
|
+
var x = xyz[0];
|
|
377
|
+
var y = xyz[1];
|
|
378
|
+
var z = xyz[2];
|
|
379
|
+
var l;
|
|
380
|
+
var a;
|
|
381
|
+
var b;
|
|
1743
382
|
x /= 95.047;
|
|
1744
383
|
y /= 100;
|
|
1745
384
|
z /= 108.883;
|
|
1746
|
-
x = x > 8856e-6 ? x
|
|
1747
|
-
y = y > 8856e-6 ? y
|
|
1748
|
-
z = z > 8856e-6 ? z
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
385
|
+
x = x > 8856e-6 ? Math.pow(x, 1 / 3) : 7.787 * x + 16 / 116;
|
|
386
|
+
y = y > 8856e-6 ? Math.pow(y, 1 / 3) : 7.787 * y + 16 / 116;
|
|
387
|
+
z = z > 8856e-6 ? Math.pow(z, 1 / 3) : 7.787 * z + 16 / 116;
|
|
388
|
+
l = 116 * y - 16;
|
|
389
|
+
a = 500 * (x - y);
|
|
390
|
+
b = 200 * (y - z);
|
|
1752
391
|
return [l, a, b];
|
|
1753
392
|
};
|
|
1754
393
|
convert$1.hsl.rgb = function(hsl) {
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
394
|
+
var h = hsl[0] / 360;
|
|
395
|
+
var s = hsl[1] / 100;
|
|
396
|
+
var l = hsl[2] / 100;
|
|
397
|
+
var t1;
|
|
398
|
+
var t2;
|
|
399
|
+
var t3;
|
|
400
|
+
var rgb;
|
|
401
|
+
var val;
|
|
1761
402
|
if (s === 0) {
|
|
1762
403
|
val = l * 255;
|
|
1763
404
|
return [val, val, val];
|
|
@@ -1767,9 +408,9 @@ convert$1.hsl.rgb = function(hsl) {
|
|
|
1767
408
|
} else {
|
|
1768
409
|
t2 = l + s - l * s;
|
|
1769
410
|
}
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
for (
|
|
411
|
+
t1 = 2 * l - t2;
|
|
412
|
+
rgb = [0, 0, 0];
|
|
413
|
+
for (var i = 0; i < 3; i++) {
|
|
1773
414
|
t3 = h + 1 / 3 * -(i - 1);
|
|
1774
415
|
if (t3 < 0) {
|
|
1775
416
|
t3++;
|
|
@@ -1791,27 +432,29 @@ convert$1.hsl.rgb = function(hsl) {
|
|
|
1791
432
|
return rgb;
|
|
1792
433
|
};
|
|
1793
434
|
convert$1.hsl.hsv = function(hsl) {
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
435
|
+
var h = hsl[0];
|
|
436
|
+
var s = hsl[1] / 100;
|
|
437
|
+
var l = hsl[2] / 100;
|
|
438
|
+
var smin = s;
|
|
439
|
+
var lmin = Math.max(l, 0.01);
|
|
440
|
+
var sv;
|
|
441
|
+
var v;
|
|
1799
442
|
l *= 2;
|
|
1800
443
|
s *= l <= 1 ? l : 2 - l;
|
|
1801
444
|
smin *= lmin <= 1 ? lmin : 2 - lmin;
|
|
1802
|
-
|
|
1803
|
-
|
|
445
|
+
v = (l + s) / 2;
|
|
446
|
+
sv = l === 0 ? 2 * smin / (lmin + smin) : 2 * s / (l + s);
|
|
1804
447
|
return [h, sv * 100, v * 100];
|
|
1805
448
|
};
|
|
1806
449
|
convert$1.hsv.rgb = function(hsv) {
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
450
|
+
var h = hsv[0] / 60;
|
|
451
|
+
var s = hsv[1] / 100;
|
|
452
|
+
var v = hsv[2] / 100;
|
|
453
|
+
var hi = Math.floor(h) % 6;
|
|
454
|
+
var f = h - Math.floor(h);
|
|
455
|
+
var p = 255 * v * (1 - s);
|
|
456
|
+
var q = 255 * v * (1 - s * f);
|
|
457
|
+
var t = 255 * v * (1 - s * (1 - f));
|
|
1815
458
|
v *= 255;
|
|
1816
459
|
switch (hi) {
|
|
1817
460
|
case 0:
|
|
@@ -1829,14 +472,15 @@ convert$1.hsv.rgb = function(hsv) {
|
|
|
1829
472
|
}
|
|
1830
473
|
};
|
|
1831
474
|
convert$1.hsv.hsl = function(hsv) {
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
475
|
+
var h = hsv[0];
|
|
476
|
+
var s = hsv[1] / 100;
|
|
477
|
+
var v = hsv[2] / 100;
|
|
478
|
+
var vmin = Math.max(v, 0.01);
|
|
479
|
+
var lmin;
|
|
480
|
+
var sl;
|
|
481
|
+
var l;
|
|
1838
482
|
l = (2 - s) * v;
|
|
1839
|
-
|
|
483
|
+
lmin = (2 - s) * vmin;
|
|
1840
484
|
sl = s * vmin;
|
|
1841
485
|
sl /= lmin <= 1 ? lmin : 2 - lmin;
|
|
1842
486
|
sl = sl || 0;
|
|
@@ -1844,25 +488,28 @@ convert$1.hsv.hsl = function(hsv) {
|
|
|
1844
488
|
return [h, sl * 100, l * 100];
|
|
1845
489
|
};
|
|
1846
490
|
convert$1.hwb.rgb = function(hwb) {
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
491
|
+
var h = hwb[0] / 360;
|
|
492
|
+
var wh = hwb[1] / 100;
|
|
493
|
+
var bl = hwb[2] / 100;
|
|
494
|
+
var ratio = wh + bl;
|
|
495
|
+
var i;
|
|
496
|
+
var v;
|
|
497
|
+
var f;
|
|
498
|
+
var n;
|
|
1852
499
|
if (ratio > 1) {
|
|
1853
500
|
wh /= ratio;
|
|
1854
501
|
bl /= ratio;
|
|
1855
502
|
}
|
|
1856
|
-
|
|
1857
|
-
|
|
503
|
+
i = Math.floor(6 * h);
|
|
504
|
+
v = 1 - bl;
|
|
1858
505
|
f = 6 * h - i;
|
|
1859
506
|
if ((i & 1) !== 0) {
|
|
1860
507
|
f = 1 - f;
|
|
1861
508
|
}
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
509
|
+
n = wh + f * (v - wh);
|
|
510
|
+
var r;
|
|
511
|
+
var g;
|
|
512
|
+
var b;
|
|
1866
513
|
switch (i) {
|
|
1867
514
|
default:
|
|
1868
515
|
case 6:
|
|
@@ -1900,61 +547,67 @@ convert$1.hwb.rgb = function(hwb) {
|
|
|
1900
547
|
return [r * 255, g * 255, b * 255];
|
|
1901
548
|
};
|
|
1902
549
|
convert$1.cmyk.rgb = function(cmyk) {
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
550
|
+
var c = cmyk[0] / 100;
|
|
551
|
+
var m = cmyk[1] / 100;
|
|
552
|
+
var y = cmyk[2] / 100;
|
|
553
|
+
var k = cmyk[3] / 100;
|
|
554
|
+
var r;
|
|
555
|
+
var g;
|
|
556
|
+
var b;
|
|
557
|
+
r = 1 - Math.min(1, c * (1 - k) + k);
|
|
558
|
+
g = 1 - Math.min(1, m * (1 - k) + k);
|
|
559
|
+
b = 1 - Math.min(1, y * (1 - k) + k);
|
|
1910
560
|
return [r * 255, g * 255, b * 255];
|
|
1911
561
|
};
|
|
1912
562
|
convert$1.xyz.rgb = function(xyz) {
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
563
|
+
var x = xyz[0] / 100;
|
|
564
|
+
var y = xyz[1] / 100;
|
|
565
|
+
var z = xyz[2] / 100;
|
|
566
|
+
var r;
|
|
567
|
+
var g;
|
|
568
|
+
var b;
|
|
1919
569
|
r = x * 3.2406 + y * -1.5372 + z * -0.4986;
|
|
1920
570
|
g = x * -0.9689 + y * 1.8758 + z * 0.0415;
|
|
1921
571
|
b = x * 0.0557 + y * -0.204 + z * 1.057;
|
|
1922
|
-
r = r > 31308e-7 ? 1.055 * r
|
|
1923
|
-
g = g > 31308e-7 ? 1.055 * g
|
|
1924
|
-
b = b > 31308e-7 ? 1.055 * b
|
|
572
|
+
r = r > 31308e-7 ? 1.055 * Math.pow(r, 1 / 2.4) - 0.055 : r * 12.92;
|
|
573
|
+
g = g > 31308e-7 ? 1.055 * Math.pow(g, 1 / 2.4) - 0.055 : g * 12.92;
|
|
574
|
+
b = b > 31308e-7 ? 1.055 * Math.pow(b, 1 / 2.4) - 0.055 : b * 12.92;
|
|
1925
575
|
r = Math.min(Math.max(0, r), 1);
|
|
1926
576
|
g = Math.min(Math.max(0, g), 1);
|
|
1927
577
|
b = Math.min(Math.max(0, b), 1);
|
|
1928
578
|
return [r * 255, g * 255, b * 255];
|
|
1929
579
|
};
|
|
1930
580
|
convert$1.xyz.lab = function(xyz) {
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
581
|
+
var x = xyz[0];
|
|
582
|
+
var y = xyz[1];
|
|
583
|
+
var z = xyz[2];
|
|
584
|
+
var l;
|
|
585
|
+
var a;
|
|
586
|
+
var b;
|
|
1934
587
|
x /= 95.047;
|
|
1935
588
|
y /= 100;
|
|
1936
589
|
z /= 108.883;
|
|
1937
|
-
x = x > 8856e-6 ? x
|
|
1938
|
-
y = y > 8856e-6 ? y
|
|
1939
|
-
z = z > 8856e-6 ? z
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
590
|
+
x = x > 8856e-6 ? Math.pow(x, 1 / 3) : 7.787 * x + 16 / 116;
|
|
591
|
+
y = y > 8856e-6 ? Math.pow(y, 1 / 3) : 7.787 * y + 16 / 116;
|
|
592
|
+
z = z > 8856e-6 ? Math.pow(z, 1 / 3) : 7.787 * z + 16 / 116;
|
|
593
|
+
l = 116 * y - 16;
|
|
594
|
+
a = 500 * (x - y);
|
|
595
|
+
b = 200 * (y - z);
|
|
1943
596
|
return [l, a, b];
|
|
1944
597
|
};
|
|
1945
598
|
convert$1.lab.xyz = function(lab) {
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
599
|
+
var l = lab[0];
|
|
600
|
+
var a = lab[1];
|
|
601
|
+
var b = lab[2];
|
|
602
|
+
var x;
|
|
603
|
+
var y;
|
|
604
|
+
var z;
|
|
1952
605
|
y = (l + 16) / 116;
|
|
1953
606
|
x = a / 500 + y;
|
|
1954
607
|
z = y - b / 200;
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
608
|
+
var y2 = Math.pow(y, 3);
|
|
609
|
+
var x2 = Math.pow(x, 3);
|
|
610
|
+
var z2 = Math.pow(z, 3);
|
|
1958
611
|
y = y2 > 8856e-6 ? y2 : (y - 16 / 116) / 7.787;
|
|
1959
612
|
x = x2 > 8856e-6 ? x2 : (x - 16 / 116) / 7.787;
|
|
1960
613
|
z = z2 > 8856e-6 ? z2 : (z - 16 / 116) / 7.787;
|
|
@@ -1964,35 +617,42 @@ convert$1.lab.xyz = function(lab) {
|
|
|
1964
617
|
return [x, y, z];
|
|
1965
618
|
};
|
|
1966
619
|
convert$1.lab.lch = function(lab) {
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
620
|
+
var l = lab[0];
|
|
621
|
+
var a = lab[1];
|
|
622
|
+
var b = lab[2];
|
|
623
|
+
var hr;
|
|
624
|
+
var h;
|
|
625
|
+
var c;
|
|
626
|
+
hr = Math.atan2(b, a);
|
|
1972
627
|
h = hr * 360 / 2 / Math.PI;
|
|
1973
628
|
if (h < 0) {
|
|
1974
629
|
h += 360;
|
|
1975
630
|
}
|
|
1976
|
-
|
|
631
|
+
c = Math.sqrt(a * a + b * b);
|
|
1977
632
|
return [l, c, h];
|
|
1978
633
|
};
|
|
1979
634
|
convert$1.lch.lab = function(lch) {
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
635
|
+
var l = lch[0];
|
|
636
|
+
var c = lch[1];
|
|
637
|
+
var h = lch[2];
|
|
638
|
+
var a;
|
|
639
|
+
var b;
|
|
640
|
+
var hr;
|
|
641
|
+
hr = h / 360 * 2 * Math.PI;
|
|
642
|
+
a = c * Math.cos(hr);
|
|
643
|
+
b = c * Math.sin(hr);
|
|
1986
644
|
return [l, a, b];
|
|
1987
645
|
};
|
|
1988
|
-
convert$1.rgb.ansi16 = function(args
|
|
1989
|
-
|
|
1990
|
-
|
|
646
|
+
convert$1.rgb.ansi16 = function(args) {
|
|
647
|
+
var r = args[0];
|
|
648
|
+
var g = args[1];
|
|
649
|
+
var b = args[2];
|
|
650
|
+
var value = 1 in arguments ? arguments[1] : convert$1.rgb.hsv(args)[2];
|
|
1991
651
|
value = Math.round(value / 50);
|
|
1992
652
|
if (value === 0) {
|
|
1993
653
|
return 30;
|
|
1994
654
|
}
|
|
1995
|
-
|
|
655
|
+
var ansi = 30 + (Math.round(b / 255) << 2 | Math.round(g / 255) << 1 | Math.round(r / 255));
|
|
1996
656
|
if (value === 2) {
|
|
1997
657
|
ansi += 60;
|
|
1998
658
|
}
|
|
@@ -2002,9 +662,9 @@ convert$1.hsv.ansi16 = function(args) {
|
|
|
2002
662
|
return convert$1.rgb.ansi16(convert$1.hsv.rgb(args), args[2]);
|
|
2003
663
|
};
|
|
2004
664
|
convert$1.rgb.ansi256 = function(args) {
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
665
|
+
var r = args[0];
|
|
666
|
+
var g = args[1];
|
|
667
|
+
var b = args[2];
|
|
2008
668
|
if (r === g && g === b) {
|
|
2009
669
|
if (r < 8) {
|
|
2010
670
|
return 16;
|
|
@@ -2014,11 +674,11 @@ convert$1.rgb.ansi256 = function(args) {
|
|
|
2014
674
|
}
|
|
2015
675
|
return Math.round((r - 8) / 247 * 24) + 232;
|
|
2016
676
|
}
|
|
2017
|
-
|
|
677
|
+
var ansi = 16 + 36 * Math.round(r / 255 * 5) + 6 * Math.round(g / 255 * 5) + Math.round(b / 255 * 5);
|
|
2018
678
|
return ansi;
|
|
2019
679
|
};
|
|
2020
680
|
convert$1.ansi16.rgb = function(args) {
|
|
2021
|
-
|
|
681
|
+
var color = args % 10;
|
|
2022
682
|
if (color === 0 || color === 7) {
|
|
2023
683
|
if (args > 50) {
|
|
2024
684
|
color += 3.5;
|
|
@@ -2026,55 +686,55 @@ convert$1.ansi16.rgb = function(args) {
|
|
|
2026
686
|
color = color / 10.5 * 255;
|
|
2027
687
|
return [color, color, color];
|
|
2028
688
|
}
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
689
|
+
var mult = (~~(args > 50) + 1) * 0.5;
|
|
690
|
+
var r = (color & 1) * mult * 255;
|
|
691
|
+
var g = (color >> 1 & 1) * mult * 255;
|
|
692
|
+
var b = (color >> 2 & 1) * mult * 255;
|
|
2033
693
|
return [r, g, b];
|
|
2034
694
|
};
|
|
2035
695
|
convert$1.ansi256.rgb = function(args) {
|
|
2036
696
|
if (args >= 232) {
|
|
2037
|
-
|
|
697
|
+
var c = (args - 232) * 10 + 8;
|
|
2038
698
|
return [c, c, c];
|
|
2039
699
|
}
|
|
2040
700
|
args -= 16;
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
701
|
+
var rem;
|
|
702
|
+
var r = Math.floor(args / 36) / 5 * 255;
|
|
703
|
+
var g = Math.floor((rem = args % 36) / 6) / 5 * 255;
|
|
704
|
+
var b = rem % 6 / 5 * 255;
|
|
2045
705
|
return [r, g, b];
|
|
2046
706
|
};
|
|
2047
707
|
convert$1.rgb.hex = function(args) {
|
|
2048
|
-
|
|
2049
|
-
|
|
708
|
+
var integer = ((Math.round(args[0]) & 255) << 16) + ((Math.round(args[1]) & 255) << 8) + (Math.round(args[2]) & 255);
|
|
709
|
+
var string = integer.toString(16).toUpperCase();
|
|
2050
710
|
return "000000".substring(string.length) + string;
|
|
2051
711
|
};
|
|
2052
712
|
convert$1.hex.rgb = function(args) {
|
|
2053
|
-
|
|
713
|
+
var match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
|
|
2054
714
|
if (!match) {
|
|
2055
715
|
return [0, 0, 0];
|
|
2056
716
|
}
|
|
2057
|
-
|
|
717
|
+
var colorString = match[0];
|
|
2058
718
|
if (match[0].length === 3) {
|
|
2059
|
-
colorString = colorString.split("").map((char)
|
|
719
|
+
colorString = colorString.split("").map(function(char) {
|
|
2060
720
|
return char + char;
|
|
2061
721
|
}).join("");
|
|
2062
722
|
}
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
723
|
+
var integer = parseInt(colorString, 16);
|
|
724
|
+
var r = integer >> 16 & 255;
|
|
725
|
+
var g = integer >> 8 & 255;
|
|
726
|
+
var b = integer & 255;
|
|
2067
727
|
return [r, g, b];
|
|
2068
728
|
};
|
|
2069
729
|
convert$1.rgb.hcg = function(rgb) {
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
730
|
+
var r = rgb[0] / 255;
|
|
731
|
+
var g = rgb[1] / 255;
|
|
732
|
+
var b = rgb[2] / 255;
|
|
733
|
+
var max = Math.max(Math.max(r, g), b);
|
|
734
|
+
var min = Math.min(Math.min(r, g), b);
|
|
735
|
+
var chroma = max - min;
|
|
736
|
+
var grayscale;
|
|
737
|
+
var hue;
|
|
2078
738
|
if (chroma < 1) {
|
|
2079
739
|
grayscale = min / (1 - chroma);
|
|
2080
740
|
} else {
|
|
@@ -2087,44 +747,49 @@ convert$1.rgb.hcg = function(rgb) {
|
|
|
2087
747
|
} else if (max === g) {
|
|
2088
748
|
hue = 2 + (b - r) / chroma;
|
|
2089
749
|
} else {
|
|
2090
|
-
hue = 4 + (r - g) / chroma;
|
|
750
|
+
hue = 4 + (r - g) / chroma + 4;
|
|
2091
751
|
}
|
|
2092
752
|
hue /= 6;
|
|
2093
753
|
hue %= 1;
|
|
2094
754
|
return [hue * 360, chroma * 100, grayscale * 100];
|
|
2095
755
|
};
|
|
2096
756
|
convert$1.hsl.hcg = function(hsl) {
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
757
|
+
var s = hsl[1] / 100;
|
|
758
|
+
var l = hsl[2] / 100;
|
|
759
|
+
var c = 1;
|
|
760
|
+
var f = 0;
|
|
761
|
+
if (l < 0.5) {
|
|
762
|
+
c = 2 * s * l;
|
|
763
|
+
} else {
|
|
764
|
+
c = 2 * s * (1 - l);
|
|
765
|
+
}
|
|
2101
766
|
if (c < 1) {
|
|
2102
767
|
f = (l - 0.5 * c) / (1 - c);
|
|
2103
768
|
}
|
|
2104
769
|
return [hsl[0], c * 100, f * 100];
|
|
2105
770
|
};
|
|
2106
771
|
convert$1.hsv.hcg = function(hsv) {
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
772
|
+
var s = hsv[1] / 100;
|
|
773
|
+
var v = hsv[2] / 100;
|
|
774
|
+
var c = s * v;
|
|
775
|
+
var f = 0;
|
|
2111
776
|
if (c < 1) {
|
|
2112
777
|
f = (v - c) / (1 - c);
|
|
2113
778
|
}
|
|
2114
779
|
return [hsv[0], c * 100, f * 100];
|
|
2115
780
|
};
|
|
2116
781
|
convert$1.hcg.rgb = function(hcg) {
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
782
|
+
var h = hcg[0] / 360;
|
|
783
|
+
var c = hcg[1] / 100;
|
|
784
|
+
var g = hcg[2] / 100;
|
|
2120
785
|
if (c === 0) {
|
|
2121
786
|
return [g * 255, g * 255, g * 255];
|
|
2122
787
|
}
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
788
|
+
var pure = [0, 0, 0];
|
|
789
|
+
var hi = h % 1 * 6;
|
|
790
|
+
var v = hi % 1;
|
|
791
|
+
var w = 1 - v;
|
|
792
|
+
var mg = 0;
|
|
2128
793
|
switch (Math.floor(hi)) {
|
|
2129
794
|
case 0:
|
|
2130
795
|
pure[0] = 1;
|
|
@@ -2164,20 +829,20 @@ convert$1.hcg.rgb = function(hcg) {
|
|
|
2164
829
|
];
|
|
2165
830
|
};
|
|
2166
831
|
convert$1.hcg.hsv = function(hcg) {
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
832
|
+
var c = hcg[1] / 100;
|
|
833
|
+
var g = hcg[2] / 100;
|
|
834
|
+
var v = c + g * (1 - c);
|
|
835
|
+
var f = 0;
|
|
2171
836
|
if (v > 0) {
|
|
2172
837
|
f = c / v;
|
|
2173
838
|
}
|
|
2174
839
|
return [hcg[0], f * 100, v * 100];
|
|
2175
840
|
};
|
|
2176
841
|
convert$1.hcg.hsl = function(hcg) {
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
842
|
+
var c = hcg[1] / 100;
|
|
843
|
+
var g = hcg[2] / 100;
|
|
844
|
+
var l = g * (1 - c) + 0.5 * c;
|
|
845
|
+
var s = 0;
|
|
2181
846
|
if (l > 0 && l < 0.5) {
|
|
2182
847
|
s = c / (2 * l);
|
|
2183
848
|
} else if (l >= 0.5 && l < 1) {
|
|
@@ -2186,17 +851,17 @@ convert$1.hcg.hsl = function(hcg) {
|
|
|
2186
851
|
return [hcg[0], s * 100, l * 100];
|
|
2187
852
|
};
|
|
2188
853
|
convert$1.hcg.hwb = function(hcg) {
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
854
|
+
var c = hcg[1] / 100;
|
|
855
|
+
var g = hcg[2] / 100;
|
|
856
|
+
var v = c + g * (1 - c);
|
|
2192
857
|
return [hcg[0], (v - c) * 100, (1 - v) * 100];
|
|
2193
858
|
};
|
|
2194
859
|
convert$1.hwb.hcg = function(hwb) {
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
860
|
+
var w = hwb[1] / 100;
|
|
861
|
+
var b = hwb[2] / 100;
|
|
862
|
+
var v = 1 - b;
|
|
863
|
+
var c = v - w;
|
|
864
|
+
var g = 0;
|
|
2200
865
|
if (c < 1) {
|
|
2201
866
|
g = (v - c) / (1 - c);
|
|
2202
867
|
}
|
|
@@ -2211,10 +876,9 @@ convert$1.rgb.apple = function(rgb) {
|
|
|
2211
876
|
convert$1.gray.rgb = function(args) {
|
|
2212
877
|
return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];
|
|
2213
878
|
};
|
|
2214
|
-
convert$1.gray.hsl = function(args) {
|
|
879
|
+
convert$1.gray.hsl = convert$1.gray.hsv = function(args) {
|
|
2215
880
|
return [0, 0, args[0]];
|
|
2216
881
|
};
|
|
2217
|
-
convert$1.gray.hsv = convert$1.gray.hsl;
|
|
2218
882
|
convert$1.gray.hwb = function(gray) {
|
|
2219
883
|
return [0, 100, gray[0]];
|
|
2220
884
|
};
|
|
@@ -2225,20 +889,20 @@ convert$1.gray.lab = function(gray) {
|
|
|
2225
889
|
return [gray[0], 0, 0];
|
|
2226
890
|
};
|
|
2227
891
|
convert$1.gray.hex = function(gray) {
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
892
|
+
var val = Math.round(gray[0] / 100 * 255) & 255;
|
|
893
|
+
var integer = (val << 16) + (val << 8) + val;
|
|
894
|
+
var string = integer.toString(16).toUpperCase();
|
|
2231
895
|
return "000000".substring(string.length) + string;
|
|
2232
896
|
};
|
|
2233
897
|
convert$1.rgb.gray = function(rgb) {
|
|
2234
|
-
|
|
898
|
+
var val = (rgb[0] + rgb[1] + rgb[2]) / 3;
|
|
2235
899
|
return [val / 255 * 100];
|
|
2236
900
|
};
|
|
2237
|
-
|
|
901
|
+
var conversions$1 = conversions$2.exports;
|
|
2238
902
|
function buildGraph() {
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
for (
|
|
903
|
+
var graph = {};
|
|
904
|
+
var models2 = Object.keys(conversions$1);
|
|
905
|
+
for (var len = models2.length, i = 0; i < len; i++) {
|
|
2242
906
|
graph[models2[i]] = {
|
|
2243
907
|
distance: -1,
|
|
2244
908
|
parent: null
|
|
@@ -2247,15 +911,15 @@ function buildGraph() {
|
|
|
2247
911
|
return graph;
|
|
2248
912
|
}
|
|
2249
913
|
function deriveBFS(fromModel) {
|
|
2250
|
-
|
|
2251
|
-
|
|
914
|
+
var graph = buildGraph();
|
|
915
|
+
var queue = [fromModel];
|
|
2252
916
|
graph[fromModel].distance = 0;
|
|
2253
917
|
while (queue.length) {
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
for (
|
|
2257
|
-
|
|
2258
|
-
|
|
918
|
+
var current = queue.pop();
|
|
919
|
+
var adjacents = Object.keys(conversions$1[current]);
|
|
920
|
+
for (var len = adjacents.length, i = 0; i < len; i++) {
|
|
921
|
+
var adjacent = adjacents[i];
|
|
922
|
+
var node = graph[adjacent];
|
|
2259
923
|
if (node.distance === -1) {
|
|
2260
924
|
node.distance = graph[current].distance + 1;
|
|
2261
925
|
node.parent = current;
|
|
@@ -2271,9 +935,9 @@ function link(from, to) {
|
|
|
2271
935
|
};
|
|
2272
936
|
}
|
|
2273
937
|
function wrapConversion(toModel, graph) {
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
938
|
+
var path = [graph[toModel].parent, toModel];
|
|
939
|
+
var fn = conversions$1[graph[toModel].parent][toModel];
|
|
940
|
+
var cur = graph[toModel].parent;
|
|
2277
941
|
while (graph[cur].parent) {
|
|
2278
942
|
path.unshift(graph[cur].parent);
|
|
2279
943
|
fn = link(conversions$1[graph[cur].parent][cur], fn);
|
|
@@ -2283,12 +947,12 @@ function wrapConversion(toModel, graph) {
|
|
|
2283
947
|
return fn;
|
|
2284
948
|
}
|
|
2285
949
|
var route$1 = function(fromModel) {
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
for (
|
|
2290
|
-
|
|
2291
|
-
|
|
950
|
+
var graph = deriveBFS(fromModel);
|
|
951
|
+
var conversion = {};
|
|
952
|
+
var models2 = Object.keys(graph);
|
|
953
|
+
for (var len = models2.length, i = 0; i < len; i++) {
|
|
954
|
+
var toModel = models2[i];
|
|
955
|
+
var node = graph[toModel];
|
|
2292
956
|
if (node.parent === null) {
|
|
2293
957
|
continue;
|
|
2294
958
|
}
|
|
@@ -2296,18 +960,17 @@ var route$1 = function(fromModel) {
|
|
|
2296
960
|
}
|
|
2297
961
|
return conversion;
|
|
2298
962
|
};
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
963
|
+
var conversions = conversions$2.exports;
|
|
964
|
+
var route = route$1;
|
|
965
|
+
var convert = {};
|
|
966
|
+
var models = Object.keys(conversions);
|
|
2303
967
|
function wrapRaw(fn) {
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
return arg0;
|
|
968
|
+
var wrappedFn = function(args) {
|
|
969
|
+
if (args === void 0 || args === null) {
|
|
970
|
+
return args;
|
|
2308
971
|
}
|
|
2309
|
-
if (
|
|
2310
|
-
args =
|
|
972
|
+
if (arguments.length > 1) {
|
|
973
|
+
args = Array.prototype.slice.call(arguments);
|
|
2311
974
|
}
|
|
2312
975
|
return fn(args);
|
|
2313
976
|
};
|
|
@@ -2317,17 +980,16 @@ function wrapRaw(fn) {
|
|
|
2317
980
|
return wrappedFn;
|
|
2318
981
|
}
|
|
2319
982
|
function wrapRounded(fn) {
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
return arg0;
|
|
983
|
+
var wrappedFn = function(args) {
|
|
984
|
+
if (args === void 0 || args === null) {
|
|
985
|
+
return args;
|
|
2324
986
|
}
|
|
2325
|
-
if (
|
|
2326
|
-
args =
|
|
987
|
+
if (arguments.length > 1) {
|
|
988
|
+
args = Array.prototype.slice.call(arguments);
|
|
2327
989
|
}
|
|
2328
|
-
|
|
990
|
+
var result = fn(args);
|
|
2329
991
|
if (typeof result === "object") {
|
|
2330
|
-
for (
|
|
992
|
+
for (var len = result.length, i = 0; i < len; i++) {
|
|
2331
993
|
result[i] = Math.round(result[i]);
|
|
2332
994
|
}
|
|
2333
995
|
}
|
|
@@ -2338,69 +1000,36 @@ function wrapRounded(fn) {
|
|
|
2338
1000
|
}
|
|
2339
1001
|
return wrappedFn;
|
|
2340
1002
|
}
|
|
2341
|
-
models.forEach((fromModel)
|
|
1003
|
+
models.forEach(function(fromModel) {
|
|
2342
1004
|
convert[fromModel] = {};
|
|
2343
1005
|
Object.defineProperty(convert[fromModel], "channels", { value: conversions[fromModel].channels });
|
|
2344
1006
|
Object.defineProperty(convert[fromModel], "labels", { value: conversions[fromModel].labels });
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
routeModels.forEach((toModel)
|
|
2348
|
-
|
|
1007
|
+
var routes = route(fromModel);
|
|
1008
|
+
var routeModels = Object.keys(routes);
|
|
1009
|
+
routeModels.forEach(function(toModel) {
|
|
1010
|
+
var fn = routes[toModel];
|
|
2349
1011
|
convert[fromModel][toModel] = wrapRounded(fn);
|
|
2350
1012
|
convert[fromModel][toModel].raw = wrapRaw(fn);
|
|
2351
1013
|
});
|
|
2352
1014
|
});
|
|
2353
1015
|
var colorConvert = convert;
|
|
2354
1016
|
(function(module) {
|
|
2355
|
-
const
|
|
2356
|
-
|
|
1017
|
+
const colorConvert$1 = colorConvert;
|
|
1018
|
+
const wrapAnsi16 = (fn, offset) => function() {
|
|
1019
|
+
const code = fn.apply(colorConvert$1, arguments);
|
|
2357
1020
|
return `\x1B[${code + offset}m`;
|
|
2358
1021
|
};
|
|
2359
|
-
const wrapAnsi256 = (fn, offset) => (
|
|
2360
|
-
const code = fn(
|
|
1022
|
+
const wrapAnsi256 = (fn, offset) => function() {
|
|
1023
|
+
const code = fn.apply(colorConvert$1, arguments);
|
|
2361
1024
|
return `\x1B[${38 + offset};5;${code}m`;
|
|
2362
1025
|
};
|
|
2363
|
-
const wrapAnsi16m = (fn, offset) => (
|
|
2364
|
-
const rgb = fn(
|
|
1026
|
+
const wrapAnsi16m = (fn, offset) => function() {
|
|
1027
|
+
const rgb = fn.apply(colorConvert$1, arguments);
|
|
2365
1028
|
return `\x1B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`;
|
|
2366
1029
|
};
|
|
2367
|
-
const ansi2ansi = (n) => n;
|
|
2368
|
-
const rgb2rgb = (r, g, b) => [r, g, b];
|
|
2369
|
-
const setLazyProperty = (object, property, get) => {
|
|
2370
|
-
Object.defineProperty(object, property, {
|
|
2371
|
-
get: () => {
|
|
2372
|
-
const value = get();
|
|
2373
|
-
Object.defineProperty(object, property, {
|
|
2374
|
-
value,
|
|
2375
|
-
enumerable: true,
|
|
2376
|
-
configurable: true
|
|
2377
|
-
});
|
|
2378
|
-
return value;
|
|
2379
|
-
},
|
|
2380
|
-
enumerable: true,
|
|
2381
|
-
configurable: true
|
|
2382
|
-
});
|
|
2383
|
-
};
|
|
2384
|
-
let colorConvert$12;
|
|
2385
|
-
const makeDynamicStyles = (wrap, targetSpace, identity, isBackground) => {
|
|
2386
|
-
if (colorConvert$12 === void 0) {
|
|
2387
|
-
colorConvert$12 = colorConvert;
|
|
2388
|
-
}
|
|
2389
|
-
const offset = isBackground ? 10 : 0;
|
|
2390
|
-
const styles2 = {};
|
|
2391
|
-
for (const [sourceSpace, suite] of Object.entries(colorConvert$12)) {
|
|
2392
|
-
const name = sourceSpace === "ansi16" ? "ansi" : sourceSpace;
|
|
2393
|
-
if (sourceSpace === targetSpace) {
|
|
2394
|
-
styles2[name] = wrap(identity, offset);
|
|
2395
|
-
} else if (typeof suite === "object") {
|
|
2396
|
-
styles2[name] = wrap(suite[targetSpace], offset);
|
|
2397
|
-
}
|
|
2398
|
-
}
|
|
2399
|
-
return styles2;
|
|
2400
|
-
};
|
|
2401
1030
|
function assembleStyles() {
|
|
2402
1031
|
const codes = /* @__PURE__ */ new Map();
|
|
2403
|
-
const
|
|
1032
|
+
const styles = {
|
|
2404
1033
|
modifier: {
|
|
2405
1034
|
reset: [0, 0],
|
|
2406
1035
|
bold: [1, 22],
|
|
@@ -2420,7 +1049,7 @@ var colorConvert = convert;
|
|
|
2420
1049
|
magenta: [35, 39],
|
|
2421
1050
|
cyan: [36, 39],
|
|
2422
1051
|
white: [37, 39],
|
|
2423
|
-
|
|
1052
|
+
gray: [90, 39],
|
|
2424
1053
|
redBright: [91, 39],
|
|
2425
1054
|
greenBright: [92, 39],
|
|
2426
1055
|
yellowBright: [93, 39],
|
|
@@ -2448,83 +1077,85 @@ var colorConvert = convert;
|
|
|
2448
1077
|
bgWhiteBright: [107, 49]
|
|
2449
1078
|
}
|
|
2450
1079
|
};
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
styles2[styleName] = {
|
|
1080
|
+
styles.color.grey = styles.color.gray;
|
|
1081
|
+
for (const groupName of Object.keys(styles)) {
|
|
1082
|
+
const group = styles[groupName];
|
|
1083
|
+
for (const styleName of Object.keys(group)) {
|
|
1084
|
+
const style = group[styleName];
|
|
1085
|
+
styles[styleName] = {
|
|
2458
1086
|
open: `\x1B[${style[0]}m`,
|
|
2459
1087
|
close: `\x1B[${style[1]}m`
|
|
2460
1088
|
};
|
|
2461
|
-
group[styleName] =
|
|
1089
|
+
group[styleName] = styles[styleName];
|
|
2462
1090
|
codes.set(style[0], style[1]);
|
|
2463
1091
|
}
|
|
2464
|
-
Object.defineProperty(
|
|
1092
|
+
Object.defineProperty(styles, groupName, {
|
|
2465
1093
|
value: group,
|
|
2466
1094
|
enumerable: false
|
|
2467
1095
|
});
|
|
1096
|
+
Object.defineProperty(styles, "codes", {
|
|
1097
|
+
value: codes,
|
|
1098
|
+
enumerable: false
|
|
1099
|
+
});
|
|
2468
1100
|
}
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
1101
|
+
const ansi2ansi = (n) => n;
|
|
1102
|
+
const rgb2rgb = (r, g, b) => [r, g, b];
|
|
1103
|
+
styles.color.close = "\x1B[39m";
|
|
1104
|
+
styles.bgColor.close = "\x1B[49m";
|
|
1105
|
+
styles.color.ansi = {
|
|
1106
|
+
ansi: wrapAnsi16(ansi2ansi, 0)
|
|
1107
|
+
};
|
|
1108
|
+
styles.color.ansi256 = {
|
|
1109
|
+
ansi256: wrapAnsi256(ansi2ansi, 0)
|
|
1110
|
+
};
|
|
1111
|
+
styles.color.ansi16m = {
|
|
1112
|
+
rgb: wrapAnsi16m(rgb2rgb, 0)
|
|
1113
|
+
};
|
|
1114
|
+
styles.bgColor.ansi = {
|
|
1115
|
+
ansi: wrapAnsi16(ansi2ansi, 10)
|
|
1116
|
+
};
|
|
1117
|
+
styles.bgColor.ansi256 = {
|
|
1118
|
+
ansi256: wrapAnsi256(ansi2ansi, 10)
|
|
1119
|
+
};
|
|
1120
|
+
styles.bgColor.ansi16m = {
|
|
1121
|
+
rgb: wrapAnsi16m(rgb2rgb, 10)
|
|
1122
|
+
};
|
|
1123
|
+
for (let key of Object.keys(colorConvert$1)) {
|
|
1124
|
+
if (typeof colorConvert$1[key] !== "object") {
|
|
1125
|
+
continue;
|
|
1126
|
+
}
|
|
1127
|
+
const suite = colorConvert$1[key];
|
|
1128
|
+
if (key === "ansi16") {
|
|
1129
|
+
key = "ansi";
|
|
1130
|
+
}
|
|
1131
|
+
if ("ansi16" in suite) {
|
|
1132
|
+
styles.color.ansi[key] = wrapAnsi16(suite.ansi16, 0);
|
|
1133
|
+
styles.bgColor.ansi[key] = wrapAnsi16(suite.ansi16, 10);
|
|
1134
|
+
}
|
|
1135
|
+
if ("ansi256" in suite) {
|
|
1136
|
+
styles.color.ansi256[key] = wrapAnsi256(suite.ansi256, 0);
|
|
1137
|
+
styles.bgColor.ansi256[key] = wrapAnsi256(suite.ansi256, 10);
|
|
1138
|
+
}
|
|
1139
|
+
if ("rgb" in suite) {
|
|
1140
|
+
styles.color.ansi16m[key] = wrapAnsi16m(suite.rgb, 0);
|
|
1141
|
+
styles.bgColor.ansi16m[key] = wrapAnsi16m(suite.rgb, 10);
|
|
1142
|
+
}
|
|
1143
|
+
}
|
|
1144
|
+
return styles;
|
|
2482
1145
|
}
|
|
2483
1146
|
Object.defineProperty(module, "exports", {
|
|
2484
1147
|
enumerable: true,
|
|
2485
1148
|
get: assembleStyles
|
|
2486
1149
|
});
|
|
2487
|
-
})(ansiStyles
|
|
1150
|
+
})(ansiStyles);
|
|
2488
1151
|
var browser = {
|
|
2489
1152
|
stdout: false,
|
|
2490
1153
|
stderr: false
|
|
2491
1154
|
};
|
|
2492
|
-
const
|
|
2493
|
-
let index = string.indexOf(substring);
|
|
2494
|
-
if (index === -1) {
|
|
2495
|
-
return string;
|
|
2496
|
-
}
|
|
2497
|
-
const substringLength = substring.length;
|
|
2498
|
-
let endIndex = 0;
|
|
2499
|
-
let returnValue = "";
|
|
2500
|
-
do {
|
|
2501
|
-
returnValue += string.substr(endIndex, index - endIndex) + substring + replacer;
|
|
2502
|
-
endIndex = index + substringLength;
|
|
2503
|
-
index = string.indexOf(substring, endIndex);
|
|
2504
|
-
} while (index !== -1);
|
|
2505
|
-
returnValue += string.substr(endIndex);
|
|
2506
|
-
return returnValue;
|
|
2507
|
-
};
|
|
2508
|
-
const stringEncaseCRLFWithFirstIndex$1 = (string, prefix, postfix, index) => {
|
|
2509
|
-
let endIndex = 0;
|
|
2510
|
-
let returnValue = "";
|
|
2511
|
-
do {
|
|
2512
|
-
const gotCR = string[index - 1] === "\r";
|
|
2513
|
-
returnValue += string.substr(endIndex, (gotCR ? index - 1 : index) - endIndex) + prefix + (gotCR ? "\r\n" : "\n") + postfix;
|
|
2514
|
-
endIndex = index + 1;
|
|
2515
|
-
index = string.indexOf("\n", endIndex);
|
|
2516
|
-
} while (index !== -1);
|
|
2517
|
-
returnValue += string.substr(endIndex);
|
|
2518
|
-
return returnValue;
|
|
2519
|
-
};
|
|
2520
|
-
var util = {
|
|
2521
|
-
stringReplaceAll: stringReplaceAll$1,
|
|
2522
|
-
stringEncaseCRLFWithFirstIndex: stringEncaseCRLFWithFirstIndex$1
|
|
2523
|
-
};
|
|
2524
|
-
const TEMPLATE_REGEX = /(?:\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi;
|
|
1155
|
+
const TEMPLATE_REGEX = /(?:\\(u[a-f\d]{4}|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi;
|
|
2525
1156
|
const STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
|
|
2526
1157
|
const STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
|
|
2527
|
-
const ESCAPE_REGEX = /\\(u
|
|
1158
|
+
const ESCAPE_REGEX = /\\(u[a-f\d]{4}|x[a-f\d]{2}|.)|([^\\])/gi;
|
|
2528
1159
|
const ESCAPES = /* @__PURE__ */ new Map([
|
|
2529
1160
|
["n", "\n"],
|
|
2530
1161
|
["r", "\r"],
|
|
@@ -2537,27 +1168,21 @@ const ESCAPES = /* @__PURE__ */ new Map([
|
|
|
2537
1168
|
["e", "\x1B"],
|
|
2538
1169
|
["a", "\x07"]
|
|
2539
1170
|
]);
|
|
2540
|
-
function unescape
|
|
2541
|
-
|
|
2542
|
-
const bracket = c[1] === "{";
|
|
2543
|
-
if (u && !bracket && c.length === 5 || c[0] === "x" && c.length === 3) {
|
|
1171
|
+
function unescape(c) {
|
|
1172
|
+
if (c[0] === "u" && c.length === 5 || c[0] === "x" && c.length === 3) {
|
|
2544
1173
|
return String.fromCharCode(parseInt(c.slice(1), 16));
|
|
2545
1174
|
}
|
|
2546
|
-
if (u && bracket) {
|
|
2547
|
-
return String.fromCodePoint(parseInt(c.slice(2, -1), 16));
|
|
2548
|
-
}
|
|
2549
1175
|
return ESCAPES.get(c) || c;
|
|
2550
1176
|
}
|
|
2551
|
-
function parseArguments(name,
|
|
1177
|
+
function parseArguments(name, args) {
|
|
2552
1178
|
const results = [];
|
|
2553
|
-
const chunks =
|
|
1179
|
+
const chunks = args.trim().split(/\s*,\s*/g);
|
|
2554
1180
|
let matches;
|
|
2555
1181
|
for (const chunk of chunks) {
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
results.push(number);
|
|
1182
|
+
if (!isNaN(chunk)) {
|
|
1183
|
+
results.push(Number(chunk));
|
|
2559
1184
|
} else if (matches = chunk.match(STRING_REGEX)) {
|
|
2560
|
-
results.push(matches[2].replace(ESCAPE_REGEX, (m, escape,
|
|
1185
|
+
results.push(matches[2].replace(ESCAPE_REGEX, (m, escape, chr) => escape ? unescape(escape) : chr));
|
|
2561
1186
|
} else {
|
|
2562
1187
|
throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`);
|
|
2563
1188
|
}
|
|
@@ -2579,833 +1204,225 @@ function parseStyle(style) {
|
|
|
2579
1204
|
}
|
|
2580
1205
|
return results;
|
|
2581
1206
|
}
|
|
2582
|
-
function buildStyle(chalk2,
|
|
1207
|
+
function buildStyle(chalk2, styles) {
|
|
2583
1208
|
const enabled = {};
|
|
2584
|
-
for (const layer of
|
|
1209
|
+
for (const layer of styles) {
|
|
2585
1210
|
for (const style of layer.styles) {
|
|
2586
1211
|
enabled[style[0]] = layer.inverse ? null : style.slice(1);
|
|
2587
1212
|
}
|
|
2588
1213
|
}
|
|
2589
1214
|
let current = chalk2;
|
|
2590
|
-
for (const
|
|
2591
|
-
if (
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
1215
|
+
for (const styleName of Object.keys(enabled)) {
|
|
1216
|
+
if (Array.isArray(enabled[styleName])) {
|
|
1217
|
+
if (!(styleName in current)) {
|
|
1218
|
+
throw new Error(`Unknown Chalk style: ${styleName}`);
|
|
1219
|
+
}
|
|
1220
|
+
if (enabled[styleName].length > 0) {
|
|
1221
|
+
current = current[styleName].apply(current, enabled[styleName]);
|
|
1222
|
+
} else {
|
|
1223
|
+
current = current[styleName];
|
|
1224
|
+
}
|
|
2596
1225
|
}
|
|
2597
|
-
current = styles3.length > 0 ? current[styleName](...styles3) : current[styleName];
|
|
2598
1226
|
}
|
|
2599
1227
|
return current;
|
|
2600
1228
|
}
|
|
2601
|
-
var templates = (chalk2,
|
|
2602
|
-
const
|
|
1229
|
+
var templates = (chalk2, tmp) => {
|
|
1230
|
+
const styles = [];
|
|
2603
1231
|
const chunks = [];
|
|
2604
1232
|
let chunk = [];
|
|
2605
|
-
|
|
2606
|
-
if (
|
|
2607
|
-
chunk.push(unescape
|
|
1233
|
+
tmp.replace(TEMPLATE_REGEX, (m, escapeChar, inverse, style, close, chr) => {
|
|
1234
|
+
if (escapeChar) {
|
|
1235
|
+
chunk.push(unescape(escapeChar));
|
|
2608
1236
|
} else if (style) {
|
|
2609
|
-
const
|
|
1237
|
+
const str = chunk.join("");
|
|
2610
1238
|
chunk = [];
|
|
2611
|
-
chunks.push(
|
|
2612
|
-
|
|
1239
|
+
chunks.push(styles.length === 0 ? str : buildStyle(chalk2, styles)(str));
|
|
1240
|
+
styles.push({ inverse, styles: parseStyle(style) });
|
|
2613
1241
|
} else if (close) {
|
|
2614
|
-
if (
|
|
1242
|
+
if (styles.length === 0) {
|
|
2615
1243
|
throw new Error("Found extraneous } in Chalk template literal");
|
|
2616
1244
|
}
|
|
2617
|
-
chunks.push(buildStyle(chalk2,
|
|
1245
|
+
chunks.push(buildStyle(chalk2, styles)(chunk.join("")));
|
|
2618
1246
|
chunk = [];
|
|
2619
|
-
|
|
1247
|
+
styles.pop();
|
|
2620
1248
|
} else {
|
|
2621
|
-
chunk.push(
|
|
1249
|
+
chunk.push(chr);
|
|
2622
1250
|
}
|
|
2623
1251
|
});
|
|
2624
1252
|
chunks.push(chunk.join(""));
|
|
2625
|
-
if (
|
|
2626
|
-
const
|
|
2627
|
-
throw new Error(
|
|
1253
|
+
if (styles.length > 0) {
|
|
1254
|
+
const errMsg = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? "" : "s"} (\`}\`)`;
|
|
1255
|
+
throw new Error(errMsg);
|
|
2628
1256
|
}
|
|
2629
1257
|
return chunks.join("");
|
|
2630
1258
|
};
|
|
2631
|
-
|
|
2632
|
-
const
|
|
2633
|
-
const
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
const
|
|
2638
|
-
const
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
constructor(options) {
|
|
2654
|
-
return chalkFactory(options);
|
|
2655
|
-
}
|
|
2656
|
-
}
|
|
2657
|
-
const chalkFactory = (options) => {
|
|
2658
|
-
const chalk2 = {};
|
|
2659
|
-
applyOptions(chalk2, options);
|
|
2660
|
-
chalk2.template = (...arguments_) => chalkTag(chalk2.template, ...arguments_);
|
|
2661
|
-
Object.setPrototypeOf(chalk2, Chalk.prototype);
|
|
2662
|
-
Object.setPrototypeOf(chalk2.template, chalk2);
|
|
2663
|
-
chalk2.template.constructor = () => {
|
|
2664
|
-
throw new Error("`chalk.constructor()` is deprecated. Use `new chalk.Instance()` instead.");
|
|
2665
|
-
};
|
|
2666
|
-
chalk2.template.Instance = ChalkClass;
|
|
2667
|
-
return chalk2.template;
|
|
2668
|
-
};
|
|
2669
|
-
function Chalk(options) {
|
|
2670
|
-
return chalkFactory(options);
|
|
2671
|
-
}
|
|
2672
|
-
for (const [styleName, style] of Object.entries(ansiStyles)) {
|
|
2673
|
-
styles[styleName] = {
|
|
2674
|
-
get() {
|
|
2675
|
-
const builder = createBuilder(this, createStyler(style.open, style.close, this._styler), this._isEmpty);
|
|
2676
|
-
Object.defineProperty(this, styleName, { value: builder });
|
|
2677
|
-
return builder;
|
|
2678
|
-
}
|
|
2679
|
-
};
|
|
2680
|
-
}
|
|
2681
|
-
styles.visible = {
|
|
2682
|
-
get() {
|
|
2683
|
-
const builder = createBuilder(this, this._styler, true);
|
|
2684
|
-
Object.defineProperty(this, "visible", { value: builder });
|
|
2685
|
-
return builder;
|
|
2686
|
-
}
|
|
2687
|
-
};
|
|
2688
|
-
const usedModels = ["rgb", "hex", "keyword", "hsl", "hsv", "hwb", "ansi", "ansi256"];
|
|
2689
|
-
for (const model of usedModels) {
|
|
2690
|
-
styles[model] = {
|
|
2691
|
-
get() {
|
|
2692
|
-
const { level } = this;
|
|
2693
|
-
return function(...arguments_) {
|
|
2694
|
-
const styler = createStyler(ansiStyles.color[levelMapping[level]][model](...arguments_), ansiStyles.color.close, this._styler);
|
|
2695
|
-
return createBuilder(this, styler, this._isEmpty);
|
|
2696
|
-
};
|
|
2697
|
-
}
|
|
2698
|
-
};
|
|
2699
|
-
}
|
|
2700
|
-
for (const model of usedModels) {
|
|
2701
|
-
const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
|
|
2702
|
-
styles[bgModel] = {
|
|
2703
|
-
get() {
|
|
2704
|
-
const { level } = this;
|
|
2705
|
-
return function(...arguments_) {
|
|
2706
|
-
const styler = createStyler(ansiStyles.bgColor[levelMapping[level]][model](...arguments_), ansiStyles.bgColor.close, this._styler);
|
|
2707
|
-
return createBuilder(this, styler, this._isEmpty);
|
|
1259
|
+
(function(module) {
|
|
1260
|
+
const escapeStringRegexp$1 = escapeStringRegexp;
|
|
1261
|
+
const ansiStyles$1 = ansiStyles.exports;
|
|
1262
|
+
const stdoutColor = browser.stdout;
|
|
1263
|
+
const template = templates;
|
|
1264
|
+
const isSimpleWindowsTerm = process.platform === "win32" && !({}.TERM || "").toLowerCase().startsWith("xterm");
|
|
1265
|
+
const levelMapping = ["ansi", "ansi", "ansi256", "ansi16m"];
|
|
1266
|
+
const skipModels = /* @__PURE__ */ new Set(["gray"]);
|
|
1267
|
+
const styles = /* @__PURE__ */ Object.create(null);
|
|
1268
|
+
function applyOptions(obj, options) {
|
|
1269
|
+
options = options || {};
|
|
1270
|
+
const scLevel = 0;
|
|
1271
|
+
obj.level = options.level === void 0 ? scLevel : options.level;
|
|
1272
|
+
obj.enabled = "enabled" in options ? options.enabled : obj.level > 0;
|
|
1273
|
+
}
|
|
1274
|
+
function Chalk(options) {
|
|
1275
|
+
if (!this || !(this instanceof Chalk) || this.template) {
|
|
1276
|
+
const chalk2 = {};
|
|
1277
|
+
applyOptions(chalk2, options);
|
|
1278
|
+
chalk2.template = function() {
|
|
1279
|
+
const args = [].slice.call(arguments);
|
|
1280
|
+
return chalkTag.apply(null, [chalk2.template].concat(args));
|
|
2708
1281
|
};
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
}
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
if (parent === void 0) {
|
|
2728
|
-
openAll = open;
|
|
2729
|
-
closeAll = close;
|
|
2730
|
-
} else {
|
|
2731
|
-
openAll = parent.openAll + open;
|
|
2732
|
-
closeAll = close + parent.closeAll;
|
|
1282
|
+
Object.setPrototypeOf(chalk2, Chalk.prototype);
|
|
1283
|
+
Object.setPrototypeOf(chalk2.template, chalk2);
|
|
1284
|
+
chalk2.template.constructor = Chalk;
|
|
1285
|
+
return chalk2.template;
|
|
1286
|
+
}
|
|
1287
|
+
applyOptions(this, options);
|
|
1288
|
+
}
|
|
1289
|
+
if (isSimpleWindowsTerm) {
|
|
1290
|
+
ansiStyles$1.blue.open = "\x1B[94m";
|
|
1291
|
+
}
|
|
1292
|
+
for (const key of Object.keys(ansiStyles$1)) {
|
|
1293
|
+
ansiStyles$1[key].closeRe = new RegExp(escapeStringRegexp$1(ansiStyles$1[key].close), "g");
|
|
1294
|
+
styles[key] = {
|
|
1295
|
+
get() {
|
|
1296
|
+
const codes = ansiStyles$1[key];
|
|
1297
|
+
return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, key);
|
|
1298
|
+
}
|
|
1299
|
+
};
|
|
2733
1300
|
}
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
openAll,
|
|
2738
|
-
closeAll,
|
|
2739
|
-
parent
|
|
2740
|
-
};
|
|
2741
|
-
};
|
|
2742
|
-
const createBuilder = (self2, _styler, _isEmpty) => {
|
|
2743
|
-
const builder = (...arguments_) => {
|
|
2744
|
-
if (isArray(arguments_[0]) && isArray(arguments_[0].raw)) {
|
|
2745
|
-
return applyStyle(builder, chalkTag(builder, ...arguments_));
|
|
1301
|
+
styles.visible = {
|
|
1302
|
+
get() {
|
|
1303
|
+
return build.call(this, this._styles || [], true, "visible");
|
|
2746
1304
|
}
|
|
2747
|
-
return applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
|
|
2748
1305
|
};
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
return builder;
|
|
2754
|
-
};
|
|
2755
|
-
const applyStyle = (self2, string) => {
|
|
2756
|
-
if (self2.level <= 0 || !string) {
|
|
2757
|
-
return self2._isEmpty ? "" : string;
|
|
2758
|
-
}
|
|
2759
|
-
let styler = self2._styler;
|
|
2760
|
-
if (styler === void 0) {
|
|
2761
|
-
return string;
|
|
2762
|
-
}
|
|
2763
|
-
const { openAll, closeAll } = styler;
|
|
2764
|
-
if (string.indexOf("\x1B") !== -1) {
|
|
2765
|
-
while (styler !== void 0) {
|
|
2766
|
-
string = stringReplaceAll(string, styler.close, styler.open);
|
|
2767
|
-
styler = styler.parent;
|
|
2768
|
-
}
|
|
2769
|
-
}
|
|
2770
|
-
const lfIndex = string.indexOf("\n");
|
|
2771
|
-
if (lfIndex !== -1) {
|
|
2772
|
-
string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
|
|
2773
|
-
}
|
|
2774
|
-
return openAll + string + closeAll;
|
|
2775
|
-
};
|
|
2776
|
-
let template;
|
|
2777
|
-
const chalkTag = (chalk2, ...strings) => {
|
|
2778
|
-
const [firstString] = strings;
|
|
2779
|
-
if (!isArray(firstString) || !isArray(firstString.raw)) {
|
|
2780
|
-
return strings.join(" ");
|
|
2781
|
-
}
|
|
2782
|
-
const arguments_ = strings.slice(1);
|
|
2783
|
-
const parts = [firstString.raw[0]];
|
|
2784
|
-
for (let i = 1; i < firstString.length; i++) {
|
|
2785
|
-
parts.push(String(arguments_[i - 1]).replace(/[{}\\]/g, "\\$&"), String(firstString.raw[i]));
|
|
2786
|
-
}
|
|
2787
|
-
if (template === void 0) {
|
|
2788
|
-
template = templates;
|
|
2789
|
-
}
|
|
2790
|
-
return template(chalk2, parts.join(""));
|
|
2791
|
-
};
|
|
2792
|
-
Object.defineProperties(Chalk.prototype, styles);
|
|
2793
|
-
const chalk = Chalk();
|
|
2794
|
-
chalk.supportsColor = stdoutColor;
|
|
2795
|
-
chalk.stderr = Chalk({ level: stderrColor ? stderrColor.level : 0 });
|
|
2796
|
-
chalk.stderr.supportsColor = stderrColor;
|
|
2797
|
-
const isDev = () => {
|
|
2798
|
-
const processIsDefined = typeof process !== "undefined";
|
|
2799
|
-
const env = processIsDefined && process.env && process.env["NODE_ENV"] && process.env["NODE_ENV"].toLowerCase();
|
|
2800
|
-
return env !== "production";
|
|
2801
|
-
};
|
|
2802
|
-
var isDev$1 = isDev;
|
|
2803
|
-
const DEFAULT_SERVICE_ENDPOINT = "https://service.jamcomments.com";
|
|
2804
|
-
const DEVELOPMENT_SERVICE_ENDPOINT = "http://localhost:4000";
|
|
2805
|
-
const getServiceEndpoint = (explicitEndpoint = null) => {
|
|
2806
|
-
if (typeof window !== "undefined" && window["jcForceLocal"]) {
|
|
2807
|
-
return DEVELOPMENT_SERVICE_ENDPOINT;
|
|
2808
|
-
}
|
|
2809
|
-
if (explicitEndpoint) {
|
|
2810
|
-
return explicitEndpoint;
|
|
2811
|
-
}
|
|
2812
|
-
return process.env["NODE_ENV"] === "production" ? DEFAULT_SERVICE_ENDPOINT : DEVELOPMENT_SERVICE_ENDPOINT;
|
|
2813
|
-
};
|
|
2814
|
-
var getServiceEndpoint$1 = getServiceEndpoint;
|
|
2815
|
-
var __defProp2 = Object.defineProperty;
|
|
2816
|
-
var __getOwnPropSymbols2 = Object.getOwnPropertySymbols;
|
|
2817
|
-
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
2818
|
-
var __propIsEnum2 = Object.prototype.propertyIsEnumerable;
|
|
2819
|
-
var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2820
|
-
var __spreadValues2 = (a, b) => {
|
|
2821
|
-
for (var prop in b || (b = {}))
|
|
2822
|
-
if (__hasOwnProp2.call(b, prop))
|
|
2823
|
-
__defNormalProp2(a, prop, b[prop]);
|
|
2824
|
-
if (__getOwnPropSymbols2)
|
|
2825
|
-
for (var prop of __getOwnPropSymbols2(b)) {
|
|
2826
|
-
if (__propIsEnum2.call(b, prop))
|
|
2827
|
-
__defNormalProp2(a, prop, b[prop]);
|
|
1306
|
+
ansiStyles$1.color.closeRe = new RegExp(escapeStringRegexp$1(ansiStyles$1.color.close), "g");
|
|
1307
|
+
for (const model of Object.keys(ansiStyles$1.color.ansi)) {
|
|
1308
|
+
if (skipModels.has(model)) {
|
|
1309
|
+
continue;
|
|
2828
1310
|
}
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
1311
|
+
styles[model] = {
|
|
1312
|
+
get() {
|
|
1313
|
+
const level = this.level;
|
|
1314
|
+
return function() {
|
|
1315
|
+
const open = ansiStyles$1.color[levelMapping[level]][model].apply(null, arguments);
|
|
1316
|
+
const codes = {
|
|
1317
|
+
open,
|
|
1318
|
+
close: ansiStyles$1.color.close,
|
|
1319
|
+
closeRe: ansiStyles$1.color.closeRe
|
|
1320
|
+
};
|
|
1321
|
+
return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model);
|
|
1322
|
+
};
|
|
1323
|
+
}
|
|
1324
|
+
};
|
|
2835
1325
|
}
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
fetchOptions,
|
|
2841
|
-
query,
|
|
2842
|
-
variables
|
|
2843
|
-
}) {
|
|
2844
|
-
const payload = { query, variables: JSON.stringify(variables) };
|
|
2845
|
-
const { method = "POST", headers = {} } = fetchOptions;
|
|
2846
|
-
const isGet = /get/i.test(method);
|
|
2847
|
-
const preparedEndpoint = isGet ? attachParamsToUrl(endpoint, payload) : endpoint;
|
|
2848
|
-
try {
|
|
2849
|
-
const response = await fetch(preparedEndpoint, {
|
|
2850
|
-
method: method.toUpperCase(),
|
|
2851
|
-
headers: __spreadValues2({
|
|
2852
|
-
"Content-Type": `application/${isGet ? "x-www-form-urlencoded" : "json"}`
|
|
2853
|
-
}, headers),
|
|
2854
|
-
body: isGet ? null : JSON.stringify(payload)
|
|
2855
|
-
});
|
|
2856
|
-
const { data, errors } = await response.json();
|
|
2857
|
-
const returnPayload = { data };
|
|
2858
|
-
if (errors) {
|
|
2859
|
-
returnPayload.errors = errors;
|
|
1326
|
+
ansiStyles$1.bgColor.closeRe = new RegExp(escapeStringRegexp$1(ansiStyles$1.bgColor.close), "g");
|
|
1327
|
+
for (const model of Object.keys(ansiStyles$1.bgColor.ansi)) {
|
|
1328
|
+
if (skipModels.has(model)) {
|
|
1329
|
+
continue;
|
|
2860
1330
|
}
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
1331
|
+
const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
|
|
1332
|
+
styles[bgModel] = {
|
|
1333
|
+
get() {
|
|
1334
|
+
const level = this.level;
|
|
1335
|
+
return function() {
|
|
1336
|
+
const open = ansiStyles$1.bgColor[levelMapping[level]][model].apply(null, arguments);
|
|
1337
|
+
const codes = {
|
|
1338
|
+
open,
|
|
1339
|
+
close: ansiStyles$1.bgColor.close,
|
|
1340
|
+
closeRe: ansiStyles$1.bgColor.closeRe
|
|
1341
|
+
};
|
|
1342
|
+
return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model);
|
|
1343
|
+
};
|
|
1344
|
+
}
|
|
1345
|
+
};
|
|
2864
1346
|
}
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
|
|
2874
|
-
|
|
1347
|
+
const proto = Object.defineProperties(() => {
|
|
1348
|
+
}, styles);
|
|
1349
|
+
function build(_styles, _empty, key) {
|
|
1350
|
+
const builder = function() {
|
|
1351
|
+
return applyStyle.apply(builder, arguments);
|
|
1352
|
+
};
|
|
1353
|
+
builder._styles = _styles;
|
|
1354
|
+
builder._empty = _empty;
|
|
1355
|
+
const self = this;
|
|
1356
|
+
Object.defineProperty(builder, "level", {
|
|
1357
|
+
enumerable: true,
|
|
1358
|
+
get() {
|
|
1359
|
+
return self.level;
|
|
1360
|
+
},
|
|
1361
|
+
set(level) {
|
|
1362
|
+
self.level = level;
|
|
2875
1363
|
}
|
|
2876
1364
|
});
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
emailAddress: "joanne@example.com",
|
|
2885
|
-
content: "<blockquote>This is some random quote.</blockquote><p>That's good stuff! Thanks for posting.</p>",
|
|
2886
|
-
path: null,
|
|
2887
|
-
createdAt: "1620462061499",
|
|
2888
|
-
status: "approved"
|
|
2889
|
-
},
|
|
2890
|
-
{
|
|
2891
|
-
id: "2",
|
|
2892
|
-
name: "Jennyfer Abbott",
|
|
2893
|
-
emailAddress: "jennyfer@example.com",
|
|
2894
|
-
content: "Animi voluptatem quae quas eius et error id. Ipsum amet corporis. Non corrupti eum et vel harum ut mollitia rerum laborum. Sunt est id et. Beatae nobis sit id qui ut ducimus sapiente placeat. Minus atque rerum natus et. Libero velit corporis. Blanditiis enim aut enim est ex qui omnis nemo dolorem. \n\n Vel asperiores molestias qui accusamus est libero voluptas. Blanditiis doloremque sint qui facere voluptatum et possimus aliquid. Eos enim iste qui aliquid suscipit a. Et nemo rerum voluptatem quia. Accusantium non sunt velit et temporibus beatae numquam omnis magnam. Nulla facere exercitationem est fugiat incidunt architecto corporis beatae et. Modi error quod qui rem aut.",
|
|
2895
|
-
path: null,
|
|
2896
|
-
createdAt: "1586054668000",
|
|
2897
|
-
status: "approved"
|
|
2898
|
-
},
|
|
2899
|
-
{
|
|
2900
|
-
id: "3",
|
|
2901
|
-
name: "Carmella Gutkowski",
|
|
2902
|
-
emailAddress: "carmella@example.com",
|
|
2903
|
-
content: "Dolores delectus qui id rem aut. Modi voluptate laborum dolorum suscipit optio eaque. Cum est non temporibus voluptas incidunt.",
|
|
2904
|
-
path: null,
|
|
2905
|
-
createdAt: "1578537868000",
|
|
2906
|
-
status: "approved"
|
|
2907
|
-
},
|
|
2908
|
-
{
|
|
2909
|
-
id: "4",
|
|
2910
|
-
name: "Coby Sawayn",
|
|
2911
|
-
emailAddress: "coby@example.com",
|
|
2912
|
-
content: "Occaecati necessitatibus assumenda quia. Quam esse voluptas necessitatibus tenetur similique deleniti voluptas. Est voluptas nobis. Necessitatibus eum repellendus et commodi quasi corrupti. Cupiditate tempore quasi labore.",
|
|
2913
|
-
path: null,
|
|
2914
|
-
createdAt: "1602254668000",
|
|
2915
|
-
status: "approved"
|
|
2916
|
-
},
|
|
2917
|
-
{
|
|
2918
|
-
id: "5",
|
|
2919
|
-
name: "Florence Wolf",
|
|
2920
|
-
emailAddress: "florence@example.com",
|
|
2921
|
-
content: "Possimus vitae adipisci dolorum adipisci quaerat ut itaque. Dolorem delectus pariatur maxime qui voluptatem.",
|
|
2922
|
-
path: null,
|
|
2923
|
-
createdAt: "1591713868000",
|
|
2924
|
-
status: "approved"
|
|
2925
|
-
}
|
|
2926
|
-
];
|
|
2927
|
-
var requiresPort = function required(port2, protocol) {
|
|
2928
|
-
protocol = protocol.split(":")[0];
|
|
2929
|
-
port2 = +port2;
|
|
2930
|
-
if (!port2)
|
|
2931
|
-
return false;
|
|
2932
|
-
switch (protocol) {
|
|
2933
|
-
case "http":
|
|
2934
|
-
case "ws":
|
|
2935
|
-
return port2 !== 80;
|
|
2936
|
-
case "https":
|
|
2937
|
-
case "wss":
|
|
2938
|
-
return port2 !== 443;
|
|
2939
|
-
case "ftp":
|
|
2940
|
-
return port2 !== 21;
|
|
2941
|
-
case "gopher":
|
|
2942
|
-
return port2 !== 70;
|
|
2943
|
-
case "file":
|
|
2944
|
-
return false;
|
|
2945
|
-
}
|
|
2946
|
-
return port2 !== 0;
|
|
2947
|
-
};
|
|
2948
|
-
var querystringify$1 = {};
|
|
2949
|
-
var has = Object.prototype.hasOwnProperty, undef;
|
|
2950
|
-
function decode(input) {
|
|
2951
|
-
try {
|
|
2952
|
-
return decodeURIComponent(input.replace(/\+/g, " "));
|
|
2953
|
-
} catch (e) {
|
|
2954
|
-
return null;
|
|
2955
|
-
}
|
|
2956
|
-
}
|
|
2957
|
-
function encode(input) {
|
|
2958
|
-
try {
|
|
2959
|
-
return encodeURIComponent(input);
|
|
2960
|
-
} catch (e) {
|
|
2961
|
-
return null;
|
|
2962
|
-
}
|
|
2963
|
-
}
|
|
2964
|
-
function querystring(query) {
|
|
2965
|
-
var parser = /([^=?#&]+)=?([^&]*)/g, result = {}, part;
|
|
2966
|
-
while (part = parser.exec(query)) {
|
|
2967
|
-
var key = decode(part[1]), value = decode(part[2]);
|
|
2968
|
-
if (key === null || value === null || key in result)
|
|
2969
|
-
continue;
|
|
2970
|
-
result[key] = value;
|
|
2971
|
-
}
|
|
2972
|
-
return result;
|
|
2973
|
-
}
|
|
2974
|
-
function querystringify(obj, prefix) {
|
|
2975
|
-
prefix = prefix || "";
|
|
2976
|
-
var pairs = [], value, key;
|
|
2977
|
-
if (typeof prefix !== "string")
|
|
2978
|
-
prefix = "?";
|
|
2979
|
-
for (key in obj) {
|
|
2980
|
-
if (has.call(obj, key)) {
|
|
2981
|
-
value = obj[key];
|
|
2982
|
-
if (!value && (value === null || value === undef || isNaN(value))) {
|
|
2983
|
-
value = "";
|
|
1365
|
+
Object.defineProperty(builder, "enabled", {
|
|
1366
|
+
enumerable: true,
|
|
1367
|
+
get() {
|
|
1368
|
+
return self.enabled;
|
|
1369
|
+
},
|
|
1370
|
+
set(enabled) {
|
|
1371
|
+
self.enabled = enabled;
|
|
2984
1372
|
}
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
pairs.push(key + "=" + value);
|
|
2990
|
-
}
|
|
2991
|
-
}
|
|
2992
|
-
return pairs.length ? prefix + pairs.join("&") : "";
|
|
2993
|
-
}
|
|
2994
|
-
querystringify$1.stringify = querystringify;
|
|
2995
|
-
querystringify$1.parse = querystring;
|
|
2996
|
-
var required2 = requiresPort, qs = querystringify$1, controlOrWhitespace = /^[\x00-\x20\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]+/, CRHTLF = /[\n\r\t]/g, slashes = /^[A-Za-z][A-Za-z0-9+-.]*:\/\//, port = /:\d+$/, protocolre = /^([a-z][a-z0-9.+-]*:)?(\/\/)?([\\/]+)?([\S\s]*)/i, windowsDriveLetter = /^[a-zA-Z]:/;
|
|
2997
|
-
function trimLeft(str) {
|
|
2998
|
-
return (str ? str : "").toString().replace(controlOrWhitespace, "");
|
|
2999
|
-
}
|
|
3000
|
-
var rules = [
|
|
3001
|
-
["#", "hash"],
|
|
3002
|
-
["?", "query"],
|
|
3003
|
-
function sanitize(address, url) {
|
|
3004
|
-
return isSpecial(url.protocol) ? address.replace(/\\/g, "/") : address;
|
|
3005
|
-
},
|
|
3006
|
-
["/", "pathname"],
|
|
3007
|
-
["@", "auth", 1],
|
|
3008
|
-
[NaN, "host", void 0, 1, 1],
|
|
3009
|
-
[/:(\d*)$/, "port", void 0, 1],
|
|
3010
|
-
[NaN, "hostname", void 0, 1, 1]
|
|
3011
|
-
];
|
|
3012
|
-
var ignore = { hash: 1, query: 1 };
|
|
3013
|
-
function lolcation(loc) {
|
|
3014
|
-
var globalVar;
|
|
3015
|
-
if (typeof window !== "undefined")
|
|
3016
|
-
globalVar = window;
|
|
3017
|
-
else if (typeof commonjsGlobal !== "undefined")
|
|
3018
|
-
globalVar = commonjsGlobal;
|
|
3019
|
-
else if (typeof self !== "undefined")
|
|
3020
|
-
globalVar = self;
|
|
3021
|
-
else
|
|
3022
|
-
globalVar = {};
|
|
3023
|
-
var location = globalVar.location || {};
|
|
3024
|
-
loc = loc || location;
|
|
3025
|
-
var finaldestination = {}, type = typeof loc, key;
|
|
3026
|
-
if (loc.protocol === "blob:") {
|
|
3027
|
-
finaldestination = new Url(unescape(loc.pathname), {});
|
|
3028
|
-
} else if (type === "string") {
|
|
3029
|
-
finaldestination = new Url(loc, {});
|
|
3030
|
-
for (key in ignore)
|
|
3031
|
-
delete finaldestination[key];
|
|
3032
|
-
} else if (type === "object") {
|
|
3033
|
-
for (key in loc) {
|
|
3034
|
-
if (key in ignore)
|
|
3035
|
-
continue;
|
|
3036
|
-
finaldestination[key] = loc[key];
|
|
3037
|
-
}
|
|
3038
|
-
if (finaldestination.slashes === void 0) {
|
|
3039
|
-
finaldestination.slashes = slashes.test(loc.href);
|
|
3040
|
-
}
|
|
1373
|
+
});
|
|
1374
|
+
builder.hasGrey = this.hasGrey || key === "gray" || key === "grey";
|
|
1375
|
+
builder.__proto__ = proto;
|
|
1376
|
+
return builder;
|
|
3041
1377
|
}
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
address = trimLeft(address);
|
|
3049
|
-
address = address.replace(CRHTLF, "");
|
|
3050
|
-
location = location || {};
|
|
3051
|
-
var match = protocolre.exec(address);
|
|
3052
|
-
var protocol = match[1] ? match[1].toLowerCase() : "";
|
|
3053
|
-
var forwardSlashes = !!match[2];
|
|
3054
|
-
var otherSlashes = !!match[3];
|
|
3055
|
-
var slashesCount = 0;
|
|
3056
|
-
var rest;
|
|
3057
|
-
if (forwardSlashes) {
|
|
3058
|
-
if (otherSlashes) {
|
|
3059
|
-
rest = match[2] + match[3] + match[4];
|
|
3060
|
-
slashesCount = match[2].length + match[3].length;
|
|
3061
|
-
} else {
|
|
3062
|
-
rest = match[2] + match[4];
|
|
3063
|
-
slashesCount = match[2].length;
|
|
1378
|
+
function applyStyle() {
|
|
1379
|
+
const args = arguments;
|
|
1380
|
+
const argsLen = args.length;
|
|
1381
|
+
let str = String(arguments[0]);
|
|
1382
|
+
if (argsLen === 0) {
|
|
1383
|
+
return "";
|
|
3064
1384
|
}
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
} else {
|
|
3070
|
-
rest = match[4];
|
|
1385
|
+
if (argsLen > 1) {
|
|
1386
|
+
for (let a = 1; a < argsLen; a++) {
|
|
1387
|
+
str += " " + args[a];
|
|
1388
|
+
}
|
|
3071
1389
|
}
|
|
3072
|
-
|
|
3073
|
-
|
|
3074
|
-
if (slashesCount >= 2) {
|
|
3075
|
-
rest = rest.slice(2);
|
|
1390
|
+
if (!this.enabled || this.level <= 0 || !str) {
|
|
1391
|
+
return this._empty ? "" : str;
|
|
3076
1392
|
}
|
|
3077
|
-
|
|
3078
|
-
|
|
3079
|
-
|
|
3080
|
-
if (forwardSlashes) {
|
|
3081
|
-
rest = rest.slice(2);
|
|
1393
|
+
const originalDim = ansiStyles$1.dim.open;
|
|
1394
|
+
if (isSimpleWindowsTerm && this.hasGrey) {
|
|
1395
|
+
ansiStyles$1.dim.open = "";
|
|
3082
1396
|
}
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
return {
|
|
3087
|
-
protocol,
|
|
3088
|
-
slashes: forwardSlashes || isSpecial(protocol),
|
|
3089
|
-
slashesCount,
|
|
3090
|
-
rest
|
|
3091
|
-
};
|
|
3092
|
-
}
|
|
3093
|
-
function resolve(relative, base) {
|
|
3094
|
-
if (relative === "")
|
|
3095
|
-
return base;
|
|
3096
|
-
var path = (base || "/").split("/").slice(0, -1).concat(relative.split("/")), i = path.length, last = path[i - 1], unshift = false, up = 0;
|
|
3097
|
-
while (i--) {
|
|
3098
|
-
if (path[i] === ".") {
|
|
3099
|
-
path.splice(i, 1);
|
|
3100
|
-
} else if (path[i] === "..") {
|
|
3101
|
-
path.splice(i, 1);
|
|
3102
|
-
up++;
|
|
3103
|
-
} else if (up) {
|
|
3104
|
-
if (i === 0)
|
|
3105
|
-
unshift = true;
|
|
3106
|
-
path.splice(i, 1);
|
|
3107
|
-
up--;
|
|
1397
|
+
for (const code of this._styles.slice().reverse()) {
|
|
1398
|
+
str = code.open + str.replace(code.closeRe, code.open) + code.close;
|
|
1399
|
+
str = str.replace(/\r?\n/g, `${code.close}$&${code.open}`);
|
|
3108
1400
|
}
|
|
1401
|
+
ansiStyles$1.dim.open = originalDim;
|
|
1402
|
+
return str;
|
|
3109
1403
|
}
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
path.push("");
|
|
3114
|
-
return path.join("/");
|
|
3115
|
-
}
|
|
3116
|
-
function Url(address, location, parser) {
|
|
3117
|
-
address = trimLeft(address);
|
|
3118
|
-
address = address.replace(CRHTLF, "");
|
|
3119
|
-
if (!(this instanceof Url)) {
|
|
3120
|
-
return new Url(address, location, parser);
|
|
3121
|
-
}
|
|
3122
|
-
var relative, extracted, parse, instruction, index, key, instructions = rules.slice(), type = typeof location, url = this, i = 0;
|
|
3123
|
-
if (type !== "object" && type !== "string") {
|
|
3124
|
-
parser = location;
|
|
3125
|
-
location = null;
|
|
3126
|
-
}
|
|
3127
|
-
if (parser && typeof parser !== "function")
|
|
3128
|
-
parser = qs.parse;
|
|
3129
|
-
location = lolcation(location);
|
|
3130
|
-
extracted = extractProtocol(address || "", location);
|
|
3131
|
-
relative = !extracted.protocol && !extracted.slashes;
|
|
3132
|
-
url.slashes = extracted.slashes || relative && location.slashes;
|
|
3133
|
-
url.protocol = extracted.protocol || location.protocol || "";
|
|
3134
|
-
address = extracted.rest;
|
|
3135
|
-
if (extracted.protocol === "file:" && (extracted.slashesCount !== 2 || windowsDriveLetter.test(address)) || !extracted.slashes && (extracted.protocol || extracted.slashesCount < 2 || !isSpecial(url.protocol))) {
|
|
3136
|
-
instructions[3] = [/(.*)/, "pathname"];
|
|
3137
|
-
}
|
|
3138
|
-
for (; i < instructions.length; i++) {
|
|
3139
|
-
instruction = instructions[i];
|
|
3140
|
-
if (typeof instruction === "function") {
|
|
3141
|
-
address = instruction(address, url);
|
|
3142
|
-
continue;
|
|
3143
|
-
}
|
|
3144
|
-
parse = instruction[0];
|
|
3145
|
-
key = instruction[1];
|
|
3146
|
-
if (parse !== parse) {
|
|
3147
|
-
url[key] = address;
|
|
3148
|
-
} else if (typeof parse === "string") {
|
|
3149
|
-
index = parse === "@" ? address.lastIndexOf(parse) : address.indexOf(parse);
|
|
3150
|
-
if (~index) {
|
|
3151
|
-
if (typeof instruction[2] === "number") {
|
|
3152
|
-
url[key] = address.slice(0, index);
|
|
3153
|
-
address = address.slice(index + instruction[2]);
|
|
3154
|
-
} else {
|
|
3155
|
-
url[key] = address.slice(index);
|
|
3156
|
-
address = address.slice(0, index);
|
|
3157
|
-
}
|
|
3158
|
-
}
|
|
3159
|
-
} else if (index = parse.exec(address)) {
|
|
3160
|
-
url[key] = index[1];
|
|
3161
|
-
address = address.slice(0, index.index);
|
|
1404
|
+
function chalkTag(chalk2, strings) {
|
|
1405
|
+
if (!Array.isArray(strings)) {
|
|
1406
|
+
return [].slice.call(arguments, 1).join(" ");
|
|
3162
1407
|
}
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
url.query = parser(url.query);
|
|
3169
|
-
if (relative && location.slashes && url.pathname.charAt(0) !== "/" && (url.pathname !== "" || location.pathname !== "")) {
|
|
3170
|
-
url.pathname = resolve(url.pathname, location.pathname);
|
|
3171
|
-
}
|
|
3172
|
-
if (url.pathname.charAt(0) !== "/" && isSpecial(url.protocol)) {
|
|
3173
|
-
url.pathname = "/" + url.pathname;
|
|
3174
|
-
}
|
|
3175
|
-
if (!required2(url.port, url.protocol)) {
|
|
3176
|
-
url.host = url.hostname;
|
|
3177
|
-
url.port = "";
|
|
3178
|
-
}
|
|
3179
|
-
url.username = url.password = "";
|
|
3180
|
-
if (url.auth) {
|
|
3181
|
-
index = url.auth.indexOf(":");
|
|
3182
|
-
if (~index) {
|
|
3183
|
-
url.username = url.auth.slice(0, index);
|
|
3184
|
-
url.username = encodeURIComponent(decodeURIComponent(url.username));
|
|
3185
|
-
url.password = url.auth.slice(index + 1);
|
|
3186
|
-
url.password = encodeURIComponent(decodeURIComponent(url.password));
|
|
3187
|
-
} else {
|
|
3188
|
-
url.username = encodeURIComponent(decodeURIComponent(url.auth));
|
|
1408
|
+
const args = [].slice.call(arguments, 2);
|
|
1409
|
+
const parts = [strings.raw[0]];
|
|
1410
|
+
for (let i = 1; i < strings.length; i++) {
|
|
1411
|
+
parts.push(String(args[i - 1]).replace(/[{}\\]/g, "\\$&"));
|
|
1412
|
+
parts.push(String(strings.raw[i]));
|
|
3189
1413
|
}
|
|
3190
|
-
|
|
3191
|
-
}
|
|
3192
|
-
url.origin = url.protocol !== "file:" && isSpecial(url.protocol) && url.host ? url.protocol + "//" + url.host : "null";
|
|
3193
|
-
url.href = url.toString();
|
|
3194
|
-
}
|
|
3195
|
-
function set(part, value, fn) {
|
|
3196
|
-
var url = this;
|
|
3197
|
-
switch (part) {
|
|
3198
|
-
case "query":
|
|
3199
|
-
if (typeof value === "string" && value.length) {
|
|
3200
|
-
value = (fn || qs.parse)(value);
|
|
3201
|
-
}
|
|
3202
|
-
url[part] = value;
|
|
3203
|
-
break;
|
|
3204
|
-
case "port":
|
|
3205
|
-
url[part] = value;
|
|
3206
|
-
if (!required2(value, url.protocol)) {
|
|
3207
|
-
url.host = url.hostname;
|
|
3208
|
-
url[part] = "";
|
|
3209
|
-
} else if (value) {
|
|
3210
|
-
url.host = url.hostname + ":" + value;
|
|
3211
|
-
}
|
|
3212
|
-
break;
|
|
3213
|
-
case "hostname":
|
|
3214
|
-
url[part] = value;
|
|
3215
|
-
if (url.port)
|
|
3216
|
-
value += ":" + url.port;
|
|
3217
|
-
url.host = value;
|
|
3218
|
-
break;
|
|
3219
|
-
case "host":
|
|
3220
|
-
url[part] = value;
|
|
3221
|
-
if (port.test(value)) {
|
|
3222
|
-
value = value.split(":");
|
|
3223
|
-
url.port = value.pop();
|
|
3224
|
-
url.hostname = value.join(":");
|
|
3225
|
-
} else {
|
|
3226
|
-
url.hostname = value;
|
|
3227
|
-
url.port = "";
|
|
3228
|
-
}
|
|
3229
|
-
break;
|
|
3230
|
-
case "protocol":
|
|
3231
|
-
url.protocol = value.toLowerCase();
|
|
3232
|
-
url.slashes = !fn;
|
|
3233
|
-
break;
|
|
3234
|
-
case "pathname":
|
|
3235
|
-
case "hash":
|
|
3236
|
-
if (value) {
|
|
3237
|
-
var char = part === "pathname" ? "/" : "#";
|
|
3238
|
-
url[part] = value.charAt(0) !== char ? char + value : value;
|
|
3239
|
-
} else {
|
|
3240
|
-
url[part] = value;
|
|
3241
|
-
}
|
|
3242
|
-
break;
|
|
3243
|
-
case "username":
|
|
3244
|
-
case "password":
|
|
3245
|
-
url[part] = encodeURIComponent(value);
|
|
3246
|
-
break;
|
|
3247
|
-
case "auth":
|
|
3248
|
-
var index = value.indexOf(":");
|
|
3249
|
-
if (~index) {
|
|
3250
|
-
url.username = value.slice(0, index);
|
|
3251
|
-
url.username = encodeURIComponent(decodeURIComponent(url.username));
|
|
3252
|
-
url.password = value.slice(index + 1);
|
|
3253
|
-
url.password = encodeURIComponent(decodeURIComponent(url.password));
|
|
3254
|
-
} else {
|
|
3255
|
-
url.username = encodeURIComponent(decodeURIComponent(value));
|
|
3256
|
-
}
|
|
3257
|
-
}
|
|
3258
|
-
for (var i = 0; i < rules.length; i++) {
|
|
3259
|
-
var ins = rules[i];
|
|
3260
|
-
if (ins[4])
|
|
3261
|
-
url[ins[1]] = url[ins[1]].toLowerCase();
|
|
3262
|
-
}
|
|
3263
|
-
url.auth = url.password ? url.username + ":" + url.password : url.username;
|
|
3264
|
-
url.origin = url.protocol !== "file:" && isSpecial(url.protocol) && url.host ? url.protocol + "//" + url.host : "null";
|
|
3265
|
-
url.href = url.toString();
|
|
3266
|
-
return url;
|
|
3267
|
-
}
|
|
3268
|
-
function toString(stringify) {
|
|
3269
|
-
if (!stringify || typeof stringify !== "function")
|
|
3270
|
-
stringify = qs.stringify;
|
|
3271
|
-
var query, url = this, host = url.host, protocol = url.protocol;
|
|
3272
|
-
if (protocol && protocol.charAt(protocol.length - 1) !== ":")
|
|
3273
|
-
protocol += ":";
|
|
3274
|
-
var result = protocol + (url.protocol && url.slashes || isSpecial(url.protocol) ? "//" : "");
|
|
3275
|
-
if (url.username) {
|
|
3276
|
-
result += url.username;
|
|
3277
|
-
if (url.password)
|
|
3278
|
-
result += ":" + url.password;
|
|
3279
|
-
result += "@";
|
|
3280
|
-
} else if (url.password) {
|
|
3281
|
-
result += ":" + url.password;
|
|
3282
|
-
result += "@";
|
|
3283
|
-
} else if (url.protocol !== "file:" && isSpecial(url.protocol) && !host && url.pathname !== "/") {
|
|
3284
|
-
result += "@";
|
|
1414
|
+
return template(chalk2, parts.join(""));
|
|
3285
1415
|
}
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
result += url.hash;
|
|
3295
|
-
return result;
|
|
3296
|
-
}
|
|
3297
|
-
Url.prototype = { set, toString };
|
|
3298
|
-
Url.extractProtocol = extractProtocol;
|
|
3299
|
-
Url.location = lolcation;
|
|
3300
|
-
Url.trimLeft = trimLeft;
|
|
3301
|
-
Url.qs = qs;
|
|
3302
|
-
var urlParse = Url;
|
|
3303
|
-
const parsePath = (urlOrPath) => {
|
|
3304
|
-
const pathName = new urlParse(urlOrPath)["pathname"] || "";
|
|
3305
|
-
return pathName.replace(/^(\/{1,})|\/{1,}$/g, "");
|
|
3306
|
-
};
|
|
3307
|
-
const filterByUrl = (comments, urlOrPath) => {
|
|
3308
|
-
const pagePath = parsePath(urlOrPath);
|
|
3309
|
-
return comments.filter((comment) => {
|
|
3310
|
-
if (!comment.path) {
|
|
3311
|
-
return false;
|
|
3312
|
-
}
|
|
3313
|
-
const commentPath = parsePath(comment.path);
|
|
3314
|
-
return commentPath === pagePath;
|
|
3315
|
-
});
|
|
1416
|
+
Object.defineProperties(Chalk.prototype, styles);
|
|
1417
|
+
module.exports = Chalk();
|
|
1418
|
+
module.exports.supportsColor = stdoutColor;
|
|
1419
|
+
module.exports.default = module.exports;
|
|
1420
|
+
})(chalk$1);
|
|
1421
|
+
var chalk = chalk$1.exports;
|
|
1422
|
+
const log = (message) => {
|
|
1423
|
+
console.log(`${chalk.magenta("JamComments:")} ${message}`);
|
|
3316
1424
|
};
|
|
3317
|
-
const
|
|
3318
|
-
|
|
3319
|
-
return content;
|
|
3320
|
-
}
|
|
3321
|
-
return content.split(/(?:\r\n|\r|\n)/).filter((text) => !!text).map((text) => `<p>${text.trim()}</p>`).join("");
|
|
1425
|
+
const logError = (message) => {
|
|
1426
|
+
console.error(`JamComments: ${message}`);
|
|
3322
1427
|
};
|
|
3323
|
-
|
|
3324
|
-
const COMMENTS_QUERY = `
|
|
3325
|
-
fragment commentFields on Comment {
|
|
3326
|
-
createdAt
|
|
3327
|
-
name
|
|
3328
|
-
content
|
|
3329
|
-
path
|
|
3330
|
-
id
|
|
3331
|
-
}
|
|
3332
|
-
|
|
3333
|
-
query Comments($domain: String!, $status: String, $skip: Int, $perPage: Int, $path: String){
|
|
3334
|
-
comments(domain: $domain, status: $status, skip: $skip, perPage: $perPage, path: $path) {
|
|
3335
|
-
items {
|
|
3336
|
-
...commentFields
|
|
3337
|
-
children {
|
|
3338
|
-
...commentFields
|
|
3339
|
-
}
|
|
3340
|
-
}
|
|
3341
|
-
meta {
|
|
3342
|
-
hasMore
|
|
3343
|
-
}
|
|
3344
|
-
}
|
|
3345
|
-
}`;
|
|
3346
|
-
class CommentFetcher {
|
|
3347
|
-
constructor({ domain, apiKey, isDev: isDev2 = isDev$1() }) {
|
|
3348
|
-
this.isDev = isDev2;
|
|
3349
|
-
this.domain = domain;
|
|
3350
|
-
this.client = QuestClient({
|
|
3351
|
-
endpoint: `${getServiceEndpoint$1()}/graphql`,
|
|
3352
|
-
headers: {
|
|
3353
|
-
"x-api-key": apiKey
|
|
3354
|
-
}
|
|
3355
|
-
});
|
|
3356
|
-
}
|
|
3357
|
-
async _getBatchOfComments({ skip = 0, path = "" }) {
|
|
3358
|
-
const { data, errors } = await this.client.send(COMMENTS_QUERY, {
|
|
3359
|
-
domain: this.domain,
|
|
3360
|
-
status: "approved",
|
|
3361
|
-
perPage: PER_PAGE,
|
|
3362
|
-
path,
|
|
3363
|
-
skip
|
|
3364
|
-
});
|
|
3365
|
-
if (!data && errors && errors.length) {
|
|
3366
|
-
throw new Error(`Something went wrong with JamComments! Here's the error:
|
|
3367
|
-
|
|
3368
|
-
${JSON.stringify(errors)}`);
|
|
3369
|
-
}
|
|
3370
|
-
const { items, meta } = data.comments;
|
|
3371
|
-
if (errors && errors.length) {
|
|
3372
|
-
throw new Error(errors[0].message);
|
|
3373
|
-
}
|
|
3374
|
-
log$1(`Fetched a batch of ${items.length} comments.`);
|
|
3375
|
-
return {
|
|
3376
|
-
comments: items,
|
|
3377
|
-
hasMore: meta.hasMore
|
|
3378
|
-
};
|
|
3379
|
-
}
|
|
3380
|
-
_prepareDummyComments() {
|
|
3381
|
-
const descendingDates = dummyComments.map((d) => d.createdAt).sort().reverse();
|
|
3382
|
-
return dummyComments.map((comment, index) => {
|
|
3383
|
-
comment.createdAt = descendingDates[index];
|
|
3384
|
-
delete comment.emailAddress;
|
|
3385
|
-
return comment;
|
|
3386
|
-
});
|
|
3387
|
-
}
|
|
3388
|
-
_prepareContent(comments) {
|
|
3389
|
-
return comments.map((c) => {
|
|
3390
|
-
c.content = makeHtmlReady(c.content);
|
|
3391
|
-
return c;
|
|
3392
|
-
});
|
|
3393
|
-
}
|
|
3394
|
-
async getAllComments(path = "") {
|
|
3395
|
-
if (this.isDev) {
|
|
3396
|
-
return this._prepareContent(this._prepareDummyComments());
|
|
3397
|
-
}
|
|
3398
|
-
let allComments = [];
|
|
3399
|
-
let skip = 0;
|
|
3400
|
-
let hasMore = false;
|
|
3401
|
-
do {
|
|
3402
|
-
const freshFetch = await this._getBatchOfComments({ skip, path });
|
|
3403
|
-
hasMore = freshFetch.hasMore;
|
|
3404
|
-
skip = skip + freshFetch.comments.length;
|
|
3405
|
-
allComments = [...allComments, ...freshFetch.comments];
|
|
3406
|
-
} while (hasMore);
|
|
3407
|
-
return this._prepareContent(allComments);
|
|
3408
|
-
}
|
|
3409
|
-
}
|
|
3410
|
-
var CommentFetcher$1 = CommentFetcher;
|
|
3411
|
-
export { CommentFetcher$1 as CommentFetcher, filterByUrl, log$1 as log, makeHtmlReady, parsePath };
|
|
1428
|
+
export { log, logError, markupFetcher };
|