@jam-comments/server-utilities 0.0.4 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +3 -2
- package/dist/index.es.js +43 -1619
- package/dist/index.umd.js +5 -35
- package/dist/log.d.ts +2 -2
- package/dist/markupFetcher.d.ts +1 -0
- package/package.json +2 -3
- package/dist/CommentFetcher.d.ts +0 -40
package/dist/index.es.js
CHANGED
|
@@ -17,1407 +17,42 @@ var __spreadValues = (a, b) => {
|
|
|
17
17
|
return a;
|
|
18
18
|
};
|
|
19
19
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
-
|
|
21
|
-
var
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
"
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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
|
|
1072
|
-
});
|
|
1073
|
-
styles2.color.close = "\x1B[39m";
|
|
1074
|
-
styles2.bgColor.close = "\x1B[49m";
|
|
1075
|
-
setLazyProperty(styles2.color, "ansi", () => makeDynamicStyles(wrapAnsi16, "ansi16", ansi2ansi, false));
|
|
1076
|
-
setLazyProperty(styles2.color, "ansi256", () => makeDynamicStyles(wrapAnsi256, "ansi256", ansi2ansi, false));
|
|
1077
|
-
setLazyProperty(styles2.color, "ansi16m", () => makeDynamicStyles(wrapAnsi16m, "rgb", rgb2rgb, false));
|
|
1078
|
-
setLazyProperty(styles2.bgColor, "ansi", () => makeDynamicStyles(wrapAnsi16, "ansi16", ansi2ansi, true));
|
|
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");
|
|
20
|
+
const getBaseUrl = () => {
|
|
21
|
+
var _a;
|
|
22
|
+
if (typeof process !== "undefined" && ((_a = process.env) == null ? void 0 : _a.JAM_COMMENTS_BASE_URL)) {
|
|
23
|
+
return process.env["JAM_COMMENTS_BASE_URL"];
|
|
24
|
+
}
|
|
25
|
+
return "https://go.jamcomments.com";
|
|
26
|
+
};
|
|
27
|
+
const markupFetcher = (platform) => {
|
|
28
|
+
return async ({
|
|
29
|
+
path,
|
|
30
|
+
domain,
|
|
31
|
+
apiKey
|
|
32
|
+
}) => {
|
|
33
|
+
const params = new URLSearchParams({
|
|
34
|
+
path,
|
|
35
|
+
domain,
|
|
36
|
+
force_embed: "1"
|
|
37
|
+
});
|
|
38
|
+
const response = await fetch(`${getBaseUrl()}/api/markup?${params}`, {
|
|
39
|
+
method: "GET",
|
|
40
|
+
headers: {
|
|
41
|
+
Authorization: `Bearer ${apiKey}`,
|
|
42
|
+
Accept: "application/json",
|
|
43
|
+
"X-Platform": platform
|
|
1216
44
|
}
|
|
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;
|
|
45
|
+
});
|
|
46
|
+
if (response.status === 401) {
|
|
47
|
+
throw `Unauthorized! Are your domain and API key set correctly?`;
|
|
1321
48
|
}
|
|
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_));
|
|
49
|
+
if (!response.ok) {
|
|
50
|
+
throw `Request failed! Status code: ${response.status}, message: ${response.statusText}`;
|
|
1346
51
|
}
|
|
1347
|
-
return
|
|
52
|
+
return await response.text();
|
|
1348
53
|
};
|
|
1349
|
-
Object.setPrototypeOf(builder, proto$1);
|
|
1350
|
-
builder._generator = self2;
|
|
1351
|
-
builder._styler = _styler;
|
|
1352
|
-
builder._isEmpty = _isEmpty;
|
|
1353
|
-
return builder;
|
|
1354
|
-
};
|
|
1355
|
-
const applyStyle$1 = (self2, string) => {
|
|
1356
|
-
if (self2.level <= 0 || !string) {
|
|
1357
|
-
return self2._isEmpty ? "" : string;
|
|
1358
|
-
}
|
|
1359
|
-
let styler = self2._styler;
|
|
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;
|
|
1389
|
-
}
|
|
1390
|
-
return template$1(chalk2, parts.join(""));
|
|
1391
|
-
};
|
|
1392
|
-
Object.defineProperties(Chalk$1.prototype, styles$1);
|
|
1393
|
-
const chalk$1 = Chalk$1();
|
|
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
54
|
};
|
|
1420
|
-
var
|
|
55
|
+
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
1421
56
|
var ansiStyles$1 = { exports: {} };
|
|
1422
57
|
var colorName = {
|
|
1423
58
|
"aliceblue": [240, 248, 255],
|
|
@@ -2381,14 +1016,14 @@ var colorConvert = convert;
|
|
|
2381
1016
|
configurable: true
|
|
2382
1017
|
});
|
|
2383
1018
|
};
|
|
2384
|
-
let colorConvert$
|
|
1019
|
+
let colorConvert$1;
|
|
2385
1020
|
const makeDynamicStyles = (wrap, targetSpace, identity, isBackground) => {
|
|
2386
|
-
if (colorConvert$
|
|
2387
|
-
colorConvert$
|
|
1021
|
+
if (colorConvert$1 === void 0) {
|
|
1022
|
+
colorConvert$1 = colorConvert;
|
|
2388
1023
|
}
|
|
2389
1024
|
const offset = isBackground ? 10 : 0;
|
|
2390
1025
|
const styles2 = {};
|
|
2391
|
-
for (const [sourceSpace, suite] of Object.entries(colorConvert$
|
|
1026
|
+
for (const [sourceSpace, suite] of Object.entries(colorConvert$1)) {
|
|
2392
1027
|
const name = sourceSpace === "ansi16" ? "ansi" : sourceSpace;
|
|
2393
1028
|
if (sourceSpace === targetSpace) {
|
|
2394
1029
|
styles2[name] = wrap(identity, offset);
|
|
@@ -2710,7 +1345,7 @@ for (const model of usedModels) {
|
|
|
2710
1345
|
};
|
|
2711
1346
|
}
|
|
2712
1347
|
const proto = Object.defineProperties(() => {
|
|
2713
|
-
},
|
|
1348
|
+
}, __spreadProps(__spreadValues({}, styles), {
|
|
2714
1349
|
level: {
|
|
2715
1350
|
enumerable: true,
|
|
2716
1351
|
get() {
|
|
@@ -2794,136 +1429,13 @@ const chalk = Chalk();
|
|
|
2794
1429
|
chalk.supportsColor = stdoutColor;
|
|
2795
1430
|
chalk.stderr = Chalk({ level: stderrColor ? stderrColor.level : 0 });
|
|
2796
1431
|
chalk.stderr.supportsColor = stderrColor;
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
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]);
|
|
2828
|
-
}
|
|
2829
|
-
return a;
|
|
1432
|
+
var source = chalk;
|
|
1433
|
+
const log = (message) => {
|
|
1434
|
+
console.log(`${source.magenta("JamComments:")} ${message}`);
|
|
1435
|
+
};
|
|
1436
|
+
const logError = (message) => {
|
|
1437
|
+
console.error(`JamComments: ${message}`);
|
|
2830
1438
|
};
|
|
2831
|
-
function attachParamsToUrl(url, params) {
|
|
2832
|
-
const urlObj = new URL(url);
|
|
2833
|
-
for (const key in params) {
|
|
2834
|
-
urlObj.searchParams.append(key, params[key]);
|
|
2835
|
-
}
|
|
2836
|
-
return urlObj.toString();
|
|
2837
|
-
}
|
|
2838
|
-
async function makeRequest({
|
|
2839
|
-
endpoint,
|
|
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;
|
|
2860
|
-
}
|
|
2861
|
-
return returnPayload;
|
|
2862
|
-
} catch (e) {
|
|
2863
|
-
return { errors: [e] };
|
|
2864
|
-
}
|
|
2865
|
-
}
|
|
2866
|
-
function QuestClient({ endpoint, method, headers }) {
|
|
2867
|
-
const send = async (query, variables = {}) => {
|
|
2868
|
-
return makeRequest({
|
|
2869
|
-
endpoint,
|
|
2870
|
-
query,
|
|
2871
|
-
variables,
|
|
2872
|
-
fetchOptions: {
|
|
2873
|
-
method,
|
|
2874
|
-
headers
|
|
2875
|
-
}
|
|
2876
|
-
});
|
|
2877
|
-
};
|
|
2878
|
-
return { send };
|
|
2879
|
-
}
|
|
2880
|
-
var dummyComments = [
|
|
2881
|
-
{
|
|
2882
|
-
id: "1",
|
|
2883
|
-
name: "Joanne King",
|
|
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
1439
|
var requiresPort = function required(port2, protocol) {
|
|
2928
1440
|
protocol = protocol.split(":")[0];
|
|
2929
1441
|
port2 = +port2;
|
|
@@ -3320,92 +1832,4 @@ const makeHtmlReady = (content) => {
|
|
|
3320
1832
|
}
|
|
3321
1833
|
return content.split(/(?:\r\n|\r|\n)/).filter((text) => !!text).map((text) => `<p>${text.trim()}</p>`).join("");
|
|
3322
1834
|
};
|
|
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 };
|
|
1835
|
+
export { filterByUrl, log, logError, makeHtmlReady, markupFetcher, parsePath };
|