@nsshunt/stsauthclient 0.0.5 → 0.0.7
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/stsauthclient.mjs +116 -1551
- package/dist/stsauthclient.mjs.map +1 -1
- package/dist/stsauthclient.umd.js +116 -1551
- package/dist/stsauthclient.umd.js.map +1 -1
- package/package.json +8 -8
- package/types/authManager.d.ts +9 -0
- package/types/authManager.d.ts.map +1 -0
- package/types/commonTypes.d.ts +14 -0
- package/types/commonTypes.d.ts.map +1 -1
- package/types/resourceManager.d.ts +24 -0
- package/types/resourceManager.d.ts.map +1 -0
- package/types/sessionManager.d.ts +5 -25
- package/types/sessionManager.d.ts.map +1 -1
package/dist/stsauthclient.mjs
CHANGED
|
@@ -1,35 +1,16 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
-
return value;
|
|
6
|
-
};
|
|
7
|
-
var __accessCheck = (obj, member, msg) => {
|
|
8
|
-
if (!member.has(obj))
|
|
9
|
-
throw TypeError("Cannot " + msg);
|
|
10
|
-
};
|
|
11
|
-
var __privateGet = (obj, member, getter) => {
|
|
12
|
-
__accessCheck(obj, member, "read from private field");
|
|
13
|
-
return getter ? getter.call(obj) : member.get(obj);
|
|
14
|
-
};
|
|
15
|
-
var __privateAdd = (obj, member, value) => {
|
|
16
|
-
if (member.has(obj))
|
|
17
|
-
throw TypeError("Cannot add the same private member more than once");
|
|
18
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
2
|
+
var __typeError = (msg) => {
|
|
3
|
+
throw TypeError(msg);
|
|
19
4
|
};
|
|
20
|
-
var
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
var
|
|
26
|
-
|
|
27
|
-
return method;
|
|
28
|
-
};
|
|
29
|
-
var _options, _httpsAgent, _logger, _LogDebugMessage, LogDebugMessage_fn, _LogInfoMessage, LogInfoMessage_fn, _LogErrorMessage, LogErrorMessage_fn, _GetErrorMessage;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
7
|
+
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
8
|
+
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
9
|
+
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
10
|
+
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
11
|
+
var _options, _httpsAgent, _logger, _axiosConfig, _accessToken;
|
|
30
12
|
import https from "node:https";
|
|
31
13
|
import axios from "axios";
|
|
32
|
-
const isNode = Object.prototype.toString.call(typeof process !== "undefined" ? process : 0) === "[object process]";
|
|
33
14
|
var StatusCodes;
|
|
34
15
|
(function(StatusCodes2) {
|
|
35
16
|
StatusCodes2[StatusCodes2["CONTINUE"] = 100] = "CONTINUE";
|
|
@@ -91,1502 +72,73 @@ var StatusCodes;
|
|
|
91
72
|
StatusCodes2[StatusCodes2["INSUFFICIENT_STORAGE"] = 507] = "INSUFFICIENT_STORAGE";
|
|
92
73
|
StatusCodes2[StatusCodes2["NETWORK_AUTHENTICATION_REQUIRED"] = 511] = "NETWORK_AUTHENTICATION_REQUIRED";
|
|
93
74
|
})(StatusCodes || (StatusCodes = {}));
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
var colorName;
|
|
99
|
-
var hasRequiredColorName;
|
|
100
|
-
function requireColorName() {
|
|
101
|
-
if (hasRequiredColorName)
|
|
102
|
-
return colorName;
|
|
103
|
-
hasRequiredColorName = 1;
|
|
104
|
-
colorName = {
|
|
105
|
-
"aliceblue": [240, 248, 255],
|
|
106
|
-
"antiquewhite": [250, 235, 215],
|
|
107
|
-
"aqua": [0, 255, 255],
|
|
108
|
-
"aquamarine": [127, 255, 212],
|
|
109
|
-
"azure": [240, 255, 255],
|
|
110
|
-
"beige": [245, 245, 220],
|
|
111
|
-
"bisque": [255, 228, 196],
|
|
112
|
-
"black": [0, 0, 0],
|
|
113
|
-
"blanchedalmond": [255, 235, 205],
|
|
114
|
-
"blue": [0, 0, 255],
|
|
115
|
-
"blueviolet": [138, 43, 226],
|
|
116
|
-
"brown": [165, 42, 42],
|
|
117
|
-
"burlywood": [222, 184, 135],
|
|
118
|
-
"cadetblue": [95, 158, 160],
|
|
119
|
-
"chartreuse": [127, 255, 0],
|
|
120
|
-
"chocolate": [210, 105, 30],
|
|
121
|
-
"coral": [255, 127, 80],
|
|
122
|
-
"cornflowerblue": [100, 149, 237],
|
|
123
|
-
"cornsilk": [255, 248, 220],
|
|
124
|
-
"crimson": [220, 20, 60],
|
|
125
|
-
"cyan": [0, 255, 255],
|
|
126
|
-
"darkblue": [0, 0, 139],
|
|
127
|
-
"darkcyan": [0, 139, 139],
|
|
128
|
-
"darkgoldenrod": [184, 134, 11],
|
|
129
|
-
"darkgray": [169, 169, 169],
|
|
130
|
-
"darkgreen": [0, 100, 0],
|
|
131
|
-
"darkgrey": [169, 169, 169],
|
|
132
|
-
"darkkhaki": [189, 183, 107],
|
|
133
|
-
"darkmagenta": [139, 0, 139],
|
|
134
|
-
"darkolivegreen": [85, 107, 47],
|
|
135
|
-
"darkorange": [255, 140, 0],
|
|
136
|
-
"darkorchid": [153, 50, 204],
|
|
137
|
-
"darkred": [139, 0, 0],
|
|
138
|
-
"darksalmon": [233, 150, 122],
|
|
139
|
-
"darkseagreen": [143, 188, 143],
|
|
140
|
-
"darkslateblue": [72, 61, 139],
|
|
141
|
-
"darkslategray": [47, 79, 79],
|
|
142
|
-
"darkslategrey": [47, 79, 79],
|
|
143
|
-
"darkturquoise": [0, 206, 209],
|
|
144
|
-
"darkviolet": [148, 0, 211],
|
|
145
|
-
"deeppink": [255, 20, 147],
|
|
146
|
-
"deepskyblue": [0, 191, 255],
|
|
147
|
-
"dimgray": [105, 105, 105],
|
|
148
|
-
"dimgrey": [105, 105, 105],
|
|
149
|
-
"dodgerblue": [30, 144, 255],
|
|
150
|
-
"firebrick": [178, 34, 34],
|
|
151
|
-
"floralwhite": [255, 250, 240],
|
|
152
|
-
"forestgreen": [34, 139, 34],
|
|
153
|
-
"fuchsia": [255, 0, 255],
|
|
154
|
-
"gainsboro": [220, 220, 220],
|
|
155
|
-
"ghostwhite": [248, 248, 255],
|
|
156
|
-
"gold": [255, 215, 0],
|
|
157
|
-
"goldenrod": [218, 165, 32],
|
|
158
|
-
"gray": [128, 128, 128],
|
|
159
|
-
"green": [0, 128, 0],
|
|
160
|
-
"greenyellow": [173, 255, 47],
|
|
161
|
-
"grey": [128, 128, 128],
|
|
162
|
-
"honeydew": [240, 255, 240],
|
|
163
|
-
"hotpink": [255, 105, 180],
|
|
164
|
-
"indianred": [205, 92, 92],
|
|
165
|
-
"indigo": [75, 0, 130],
|
|
166
|
-
"ivory": [255, 255, 240],
|
|
167
|
-
"khaki": [240, 230, 140],
|
|
168
|
-
"lavender": [230, 230, 250],
|
|
169
|
-
"lavenderblush": [255, 240, 245],
|
|
170
|
-
"lawngreen": [124, 252, 0],
|
|
171
|
-
"lemonchiffon": [255, 250, 205],
|
|
172
|
-
"lightblue": [173, 216, 230],
|
|
173
|
-
"lightcoral": [240, 128, 128],
|
|
174
|
-
"lightcyan": [224, 255, 255],
|
|
175
|
-
"lightgoldenrodyellow": [250, 250, 210],
|
|
176
|
-
"lightgray": [211, 211, 211],
|
|
177
|
-
"lightgreen": [144, 238, 144],
|
|
178
|
-
"lightgrey": [211, 211, 211],
|
|
179
|
-
"lightpink": [255, 182, 193],
|
|
180
|
-
"lightsalmon": [255, 160, 122],
|
|
181
|
-
"lightseagreen": [32, 178, 170],
|
|
182
|
-
"lightskyblue": [135, 206, 250],
|
|
183
|
-
"lightslategray": [119, 136, 153],
|
|
184
|
-
"lightslategrey": [119, 136, 153],
|
|
185
|
-
"lightsteelblue": [176, 196, 222],
|
|
186
|
-
"lightyellow": [255, 255, 224],
|
|
187
|
-
"lime": [0, 255, 0],
|
|
188
|
-
"limegreen": [50, 205, 50],
|
|
189
|
-
"linen": [250, 240, 230],
|
|
190
|
-
"magenta": [255, 0, 255],
|
|
191
|
-
"maroon": [128, 0, 0],
|
|
192
|
-
"mediumaquamarine": [102, 205, 170],
|
|
193
|
-
"mediumblue": [0, 0, 205],
|
|
194
|
-
"mediumorchid": [186, 85, 211],
|
|
195
|
-
"mediumpurple": [147, 112, 219],
|
|
196
|
-
"mediumseagreen": [60, 179, 113],
|
|
197
|
-
"mediumslateblue": [123, 104, 238],
|
|
198
|
-
"mediumspringgreen": [0, 250, 154],
|
|
199
|
-
"mediumturquoise": [72, 209, 204],
|
|
200
|
-
"mediumvioletred": [199, 21, 133],
|
|
201
|
-
"midnightblue": [25, 25, 112],
|
|
202
|
-
"mintcream": [245, 255, 250],
|
|
203
|
-
"mistyrose": [255, 228, 225],
|
|
204
|
-
"moccasin": [255, 228, 181],
|
|
205
|
-
"navajowhite": [255, 222, 173],
|
|
206
|
-
"navy": [0, 0, 128],
|
|
207
|
-
"oldlace": [253, 245, 230],
|
|
208
|
-
"olive": [128, 128, 0],
|
|
209
|
-
"olivedrab": [107, 142, 35],
|
|
210
|
-
"orange": [255, 165, 0],
|
|
211
|
-
"orangered": [255, 69, 0],
|
|
212
|
-
"orchid": [218, 112, 214],
|
|
213
|
-
"palegoldenrod": [238, 232, 170],
|
|
214
|
-
"palegreen": [152, 251, 152],
|
|
215
|
-
"paleturquoise": [175, 238, 238],
|
|
216
|
-
"palevioletred": [219, 112, 147],
|
|
217
|
-
"papayawhip": [255, 239, 213],
|
|
218
|
-
"peachpuff": [255, 218, 185],
|
|
219
|
-
"peru": [205, 133, 63],
|
|
220
|
-
"pink": [255, 192, 203],
|
|
221
|
-
"plum": [221, 160, 221],
|
|
222
|
-
"powderblue": [176, 224, 230],
|
|
223
|
-
"purple": [128, 0, 128],
|
|
224
|
-
"rebeccapurple": [102, 51, 153],
|
|
225
|
-
"red": [255, 0, 0],
|
|
226
|
-
"rosybrown": [188, 143, 143],
|
|
227
|
-
"royalblue": [65, 105, 225],
|
|
228
|
-
"saddlebrown": [139, 69, 19],
|
|
229
|
-
"salmon": [250, 128, 114],
|
|
230
|
-
"sandybrown": [244, 164, 96],
|
|
231
|
-
"seagreen": [46, 139, 87],
|
|
232
|
-
"seashell": [255, 245, 238],
|
|
233
|
-
"sienna": [160, 82, 45],
|
|
234
|
-
"silver": [192, 192, 192],
|
|
235
|
-
"skyblue": [135, 206, 235],
|
|
236
|
-
"slateblue": [106, 90, 205],
|
|
237
|
-
"slategray": [112, 128, 144],
|
|
238
|
-
"slategrey": [112, 128, 144],
|
|
239
|
-
"snow": [255, 250, 250],
|
|
240
|
-
"springgreen": [0, 255, 127],
|
|
241
|
-
"steelblue": [70, 130, 180],
|
|
242
|
-
"tan": [210, 180, 140],
|
|
243
|
-
"teal": [0, 128, 128],
|
|
244
|
-
"thistle": [216, 191, 216],
|
|
245
|
-
"tomato": [255, 99, 71],
|
|
246
|
-
"turquoise": [64, 224, 208],
|
|
247
|
-
"violet": [238, 130, 238],
|
|
248
|
-
"wheat": [245, 222, 179],
|
|
249
|
-
"white": [255, 255, 255],
|
|
250
|
-
"whitesmoke": [245, 245, 245],
|
|
251
|
-
"yellow": [255, 255, 0],
|
|
252
|
-
"yellowgreen": [154, 205, 50]
|
|
253
|
-
};
|
|
254
|
-
return colorName;
|
|
255
|
-
}
|
|
256
|
-
var conversions;
|
|
257
|
-
var hasRequiredConversions;
|
|
258
|
-
function requireConversions() {
|
|
259
|
-
if (hasRequiredConversions)
|
|
260
|
-
return conversions;
|
|
261
|
-
hasRequiredConversions = 1;
|
|
262
|
-
const cssKeywords = requireColorName();
|
|
263
|
-
const reverseKeywords = {};
|
|
264
|
-
for (const key of Object.keys(cssKeywords)) {
|
|
265
|
-
reverseKeywords[cssKeywords[key]] = key;
|
|
266
|
-
}
|
|
267
|
-
const convert = {
|
|
268
|
-
rgb: { channels: 3, labels: "rgb" },
|
|
269
|
-
hsl: { channels: 3, labels: "hsl" },
|
|
270
|
-
hsv: { channels: 3, labels: "hsv" },
|
|
271
|
-
hwb: { channels: 3, labels: "hwb" },
|
|
272
|
-
cmyk: { channels: 4, labels: "cmyk" },
|
|
273
|
-
xyz: { channels: 3, labels: "xyz" },
|
|
274
|
-
lab: { channels: 3, labels: "lab" },
|
|
275
|
-
lch: { channels: 3, labels: "lch" },
|
|
276
|
-
hex: { channels: 1, labels: ["hex"] },
|
|
277
|
-
keyword: { channels: 1, labels: ["keyword"] },
|
|
278
|
-
ansi16: { channels: 1, labels: ["ansi16"] },
|
|
279
|
-
ansi256: { channels: 1, labels: ["ansi256"] },
|
|
280
|
-
hcg: { channels: 3, labels: ["h", "c", "g"] },
|
|
281
|
-
apple: { channels: 3, labels: ["r16", "g16", "b16"] },
|
|
282
|
-
gray: { channels: 1, labels: ["gray"] }
|
|
283
|
-
};
|
|
284
|
-
conversions = convert;
|
|
285
|
-
for (const model of Object.keys(convert)) {
|
|
286
|
-
if (!("channels" in convert[model])) {
|
|
287
|
-
throw new Error("missing channels property: " + model);
|
|
288
|
-
}
|
|
289
|
-
if (!("labels" in convert[model])) {
|
|
290
|
-
throw new Error("missing channel labels property: " + model);
|
|
291
|
-
}
|
|
292
|
-
if (convert[model].labels.length !== convert[model].channels) {
|
|
293
|
-
throw new Error("channel and label counts mismatch: " + model);
|
|
294
|
-
}
|
|
295
|
-
const { channels, labels } = convert[model];
|
|
296
|
-
delete convert[model].channels;
|
|
297
|
-
delete convert[model].labels;
|
|
298
|
-
Object.defineProperty(convert[model], "channels", { value: channels });
|
|
299
|
-
Object.defineProperty(convert[model], "labels", { value: labels });
|
|
300
|
-
}
|
|
301
|
-
convert.rgb.hsl = function(rgb) {
|
|
302
|
-
const r = rgb[0] / 255;
|
|
303
|
-
const g = rgb[1] / 255;
|
|
304
|
-
const b = rgb[2] / 255;
|
|
305
|
-
const min = Math.min(r, g, b);
|
|
306
|
-
const max = Math.max(r, g, b);
|
|
307
|
-
const delta = max - min;
|
|
308
|
-
let h;
|
|
309
|
-
let s;
|
|
310
|
-
if (max === min) {
|
|
311
|
-
h = 0;
|
|
312
|
-
} else if (r === max) {
|
|
313
|
-
h = (g - b) / delta;
|
|
314
|
-
} else if (g === max) {
|
|
315
|
-
h = 2 + (b - r) / delta;
|
|
316
|
-
} else if (b === max) {
|
|
317
|
-
h = 4 + (r - g) / delta;
|
|
318
|
-
}
|
|
319
|
-
h = Math.min(h * 60, 360);
|
|
320
|
-
if (h < 0) {
|
|
321
|
-
h += 360;
|
|
322
|
-
}
|
|
323
|
-
const l = (min + max) / 2;
|
|
324
|
-
if (max === min) {
|
|
325
|
-
s = 0;
|
|
326
|
-
} else if (l <= 0.5) {
|
|
327
|
-
s = delta / (max + min);
|
|
328
|
-
} else {
|
|
329
|
-
s = delta / (2 - max - min);
|
|
330
|
-
}
|
|
331
|
-
return [h, s * 100, l * 100];
|
|
332
|
-
};
|
|
333
|
-
convert.rgb.hsv = function(rgb) {
|
|
334
|
-
let rdif;
|
|
335
|
-
let gdif;
|
|
336
|
-
let bdif;
|
|
337
|
-
let h;
|
|
338
|
-
let s;
|
|
339
|
-
const r = rgb[0] / 255;
|
|
340
|
-
const g = rgb[1] / 255;
|
|
341
|
-
const b = rgb[2] / 255;
|
|
342
|
-
const v = Math.max(r, g, b);
|
|
343
|
-
const diff = v - Math.min(r, g, b);
|
|
344
|
-
const diffc = function(c) {
|
|
345
|
-
return (v - c) / 6 / diff + 1 / 2;
|
|
346
|
-
};
|
|
347
|
-
if (diff === 0) {
|
|
348
|
-
h = 0;
|
|
349
|
-
s = 0;
|
|
350
|
-
} else {
|
|
351
|
-
s = diff / v;
|
|
352
|
-
rdif = diffc(r);
|
|
353
|
-
gdif = diffc(g);
|
|
354
|
-
bdif = diffc(b);
|
|
355
|
-
if (r === v) {
|
|
356
|
-
h = bdif - gdif;
|
|
357
|
-
} else if (g === v) {
|
|
358
|
-
h = 1 / 3 + rdif - bdif;
|
|
359
|
-
} else if (b === v) {
|
|
360
|
-
h = 2 / 3 + gdif - rdif;
|
|
361
|
-
}
|
|
362
|
-
if (h < 0) {
|
|
363
|
-
h += 1;
|
|
364
|
-
} else if (h > 1) {
|
|
365
|
-
h -= 1;
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
return [
|
|
369
|
-
h * 360,
|
|
370
|
-
s * 100,
|
|
371
|
-
v * 100
|
|
372
|
-
];
|
|
373
|
-
};
|
|
374
|
-
convert.rgb.hwb = function(rgb) {
|
|
375
|
-
const r = rgb[0];
|
|
376
|
-
const g = rgb[1];
|
|
377
|
-
let b = rgb[2];
|
|
378
|
-
const h = convert.rgb.hsl(rgb)[0];
|
|
379
|
-
const w = 1 / 255 * Math.min(r, Math.min(g, b));
|
|
380
|
-
b = 1 - 1 / 255 * Math.max(r, Math.max(g, b));
|
|
381
|
-
return [h, w * 100, b * 100];
|
|
382
|
-
};
|
|
383
|
-
convert.rgb.cmyk = function(rgb) {
|
|
384
|
-
const r = rgb[0] / 255;
|
|
385
|
-
const g = rgb[1] / 255;
|
|
386
|
-
const b = rgb[2] / 255;
|
|
387
|
-
const k = Math.min(1 - r, 1 - g, 1 - b);
|
|
388
|
-
const c = (1 - r - k) / (1 - k) || 0;
|
|
389
|
-
const m = (1 - g - k) / (1 - k) || 0;
|
|
390
|
-
const y = (1 - b - k) / (1 - k) || 0;
|
|
391
|
-
return [c * 100, m * 100, y * 100, k * 100];
|
|
392
|
-
};
|
|
393
|
-
function comparativeDistance(x, y) {
|
|
394
|
-
return (x[0] - y[0]) ** 2 + (x[1] - y[1]) ** 2 + (x[2] - y[2]) ** 2;
|
|
395
|
-
}
|
|
396
|
-
convert.rgb.keyword = function(rgb) {
|
|
397
|
-
const reversed = reverseKeywords[rgb];
|
|
398
|
-
if (reversed) {
|
|
399
|
-
return reversed;
|
|
400
|
-
}
|
|
401
|
-
let currentClosestDistance = Infinity;
|
|
402
|
-
let currentClosestKeyword;
|
|
403
|
-
for (const keyword of Object.keys(cssKeywords)) {
|
|
404
|
-
const value = cssKeywords[keyword];
|
|
405
|
-
const distance = comparativeDistance(rgb, value);
|
|
406
|
-
if (distance < currentClosestDistance) {
|
|
407
|
-
currentClosestDistance = distance;
|
|
408
|
-
currentClosestKeyword = keyword;
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
|
-
return currentClosestKeyword;
|
|
412
|
-
};
|
|
413
|
-
convert.keyword.rgb = function(keyword) {
|
|
414
|
-
return cssKeywords[keyword];
|
|
415
|
-
};
|
|
416
|
-
convert.rgb.xyz = function(rgb) {
|
|
417
|
-
let r = rgb[0] / 255;
|
|
418
|
-
let g = rgb[1] / 255;
|
|
419
|
-
let b = rgb[2] / 255;
|
|
420
|
-
r = r > 0.04045 ? ((r + 0.055) / 1.055) ** 2.4 : r / 12.92;
|
|
421
|
-
g = g > 0.04045 ? ((g + 0.055) / 1.055) ** 2.4 : g / 12.92;
|
|
422
|
-
b = b > 0.04045 ? ((b + 0.055) / 1.055) ** 2.4 : b / 12.92;
|
|
423
|
-
const x = r * 0.4124 + g * 0.3576 + b * 0.1805;
|
|
424
|
-
const y = r * 0.2126 + g * 0.7152 + b * 0.0722;
|
|
425
|
-
const z = r * 0.0193 + g * 0.1192 + b * 0.9505;
|
|
426
|
-
return [x * 100, y * 100, z * 100];
|
|
427
|
-
};
|
|
428
|
-
convert.rgb.lab = function(rgb) {
|
|
429
|
-
const xyz = convert.rgb.xyz(rgb);
|
|
430
|
-
let x = xyz[0];
|
|
431
|
-
let y = xyz[1];
|
|
432
|
-
let z = xyz[2];
|
|
433
|
-
x /= 95.047;
|
|
434
|
-
y /= 100;
|
|
435
|
-
z /= 108.883;
|
|
436
|
-
x = x > 8856e-6 ? x ** (1 / 3) : 7.787 * x + 16 / 116;
|
|
437
|
-
y = y > 8856e-6 ? y ** (1 / 3) : 7.787 * y + 16 / 116;
|
|
438
|
-
z = z > 8856e-6 ? z ** (1 / 3) : 7.787 * z + 16 / 116;
|
|
439
|
-
const l = 116 * y - 16;
|
|
440
|
-
const a = 500 * (x - y);
|
|
441
|
-
const b = 200 * (y - z);
|
|
442
|
-
return [l, a, b];
|
|
443
|
-
};
|
|
444
|
-
convert.hsl.rgb = function(hsl) {
|
|
445
|
-
const h = hsl[0] / 360;
|
|
446
|
-
const s = hsl[1] / 100;
|
|
447
|
-
const l = hsl[2] / 100;
|
|
448
|
-
let t2;
|
|
449
|
-
let t3;
|
|
450
|
-
let val;
|
|
451
|
-
if (s === 0) {
|
|
452
|
-
val = l * 255;
|
|
453
|
-
return [val, val, val];
|
|
454
|
-
}
|
|
455
|
-
if (l < 0.5) {
|
|
456
|
-
t2 = l * (1 + s);
|
|
457
|
-
} else {
|
|
458
|
-
t2 = l + s - l * s;
|
|
459
|
-
}
|
|
460
|
-
const t1 = 2 * l - t2;
|
|
461
|
-
const rgb = [0, 0, 0];
|
|
462
|
-
for (let i = 0; i < 3; i++) {
|
|
463
|
-
t3 = h + 1 / 3 * -(i - 1);
|
|
464
|
-
if (t3 < 0) {
|
|
465
|
-
t3++;
|
|
466
|
-
}
|
|
467
|
-
if (t3 > 1) {
|
|
468
|
-
t3--;
|
|
469
|
-
}
|
|
470
|
-
if (6 * t3 < 1) {
|
|
471
|
-
val = t1 + (t2 - t1) * 6 * t3;
|
|
472
|
-
} else if (2 * t3 < 1) {
|
|
473
|
-
val = t2;
|
|
474
|
-
} else if (3 * t3 < 2) {
|
|
475
|
-
val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
|
|
476
|
-
} else {
|
|
477
|
-
val = t1;
|
|
478
|
-
}
|
|
479
|
-
rgb[i] = val * 255;
|
|
480
|
-
}
|
|
481
|
-
return rgb;
|
|
482
|
-
};
|
|
483
|
-
convert.hsl.hsv = function(hsl) {
|
|
484
|
-
const h = hsl[0];
|
|
485
|
-
let s = hsl[1] / 100;
|
|
486
|
-
let l = hsl[2] / 100;
|
|
487
|
-
let smin = s;
|
|
488
|
-
const lmin = Math.max(l, 0.01);
|
|
489
|
-
l *= 2;
|
|
490
|
-
s *= l <= 1 ? l : 2 - l;
|
|
491
|
-
smin *= lmin <= 1 ? lmin : 2 - lmin;
|
|
492
|
-
const v = (l + s) / 2;
|
|
493
|
-
const sv = l === 0 ? 2 * smin / (lmin + smin) : 2 * s / (l + s);
|
|
494
|
-
return [h, sv * 100, v * 100];
|
|
495
|
-
};
|
|
496
|
-
convert.hsv.rgb = function(hsv) {
|
|
497
|
-
const h = hsv[0] / 60;
|
|
498
|
-
const s = hsv[1] / 100;
|
|
499
|
-
let v = hsv[2] / 100;
|
|
500
|
-
const hi = Math.floor(h) % 6;
|
|
501
|
-
const f = h - Math.floor(h);
|
|
502
|
-
const p = 255 * v * (1 - s);
|
|
503
|
-
const q = 255 * v * (1 - s * f);
|
|
504
|
-
const t = 255 * v * (1 - s * (1 - f));
|
|
505
|
-
v *= 255;
|
|
506
|
-
switch (hi) {
|
|
507
|
-
case 0:
|
|
508
|
-
return [v, t, p];
|
|
509
|
-
case 1:
|
|
510
|
-
return [q, v, p];
|
|
511
|
-
case 2:
|
|
512
|
-
return [p, v, t];
|
|
513
|
-
case 3:
|
|
514
|
-
return [p, q, v];
|
|
515
|
-
case 4:
|
|
516
|
-
return [t, p, v];
|
|
517
|
-
case 5:
|
|
518
|
-
return [v, p, q];
|
|
519
|
-
}
|
|
520
|
-
};
|
|
521
|
-
convert.hsv.hsl = function(hsv) {
|
|
522
|
-
const h = hsv[0];
|
|
523
|
-
const s = hsv[1] / 100;
|
|
524
|
-
const v = hsv[2] / 100;
|
|
525
|
-
const vmin = Math.max(v, 0.01);
|
|
526
|
-
let sl;
|
|
527
|
-
let l;
|
|
528
|
-
l = (2 - s) * v;
|
|
529
|
-
const lmin = (2 - s) * vmin;
|
|
530
|
-
sl = s * vmin;
|
|
531
|
-
sl /= lmin <= 1 ? lmin : 2 - lmin;
|
|
532
|
-
sl = sl || 0;
|
|
533
|
-
l /= 2;
|
|
534
|
-
return [h, sl * 100, l * 100];
|
|
535
|
-
};
|
|
536
|
-
convert.hwb.rgb = function(hwb) {
|
|
537
|
-
const h = hwb[0] / 360;
|
|
538
|
-
let wh = hwb[1] / 100;
|
|
539
|
-
let bl = hwb[2] / 100;
|
|
540
|
-
const ratio = wh + bl;
|
|
541
|
-
let f;
|
|
542
|
-
if (ratio > 1) {
|
|
543
|
-
wh /= ratio;
|
|
544
|
-
bl /= ratio;
|
|
545
|
-
}
|
|
546
|
-
const i = Math.floor(6 * h);
|
|
547
|
-
const v = 1 - bl;
|
|
548
|
-
f = 6 * h - i;
|
|
549
|
-
if ((i & 1) !== 0) {
|
|
550
|
-
f = 1 - f;
|
|
551
|
-
}
|
|
552
|
-
const n = wh + f * (v - wh);
|
|
553
|
-
let r;
|
|
554
|
-
let g;
|
|
555
|
-
let b;
|
|
556
|
-
switch (i) {
|
|
557
|
-
default:
|
|
558
|
-
case 6:
|
|
559
|
-
case 0:
|
|
560
|
-
r = v;
|
|
561
|
-
g = n;
|
|
562
|
-
b = wh;
|
|
563
|
-
break;
|
|
564
|
-
case 1:
|
|
565
|
-
r = n;
|
|
566
|
-
g = v;
|
|
567
|
-
b = wh;
|
|
568
|
-
break;
|
|
569
|
-
case 2:
|
|
570
|
-
r = wh;
|
|
571
|
-
g = v;
|
|
572
|
-
b = n;
|
|
573
|
-
break;
|
|
574
|
-
case 3:
|
|
575
|
-
r = wh;
|
|
576
|
-
g = n;
|
|
577
|
-
b = v;
|
|
578
|
-
break;
|
|
579
|
-
case 4:
|
|
580
|
-
r = n;
|
|
581
|
-
g = wh;
|
|
582
|
-
b = v;
|
|
583
|
-
break;
|
|
584
|
-
case 5:
|
|
585
|
-
r = v;
|
|
586
|
-
g = wh;
|
|
587
|
-
b = n;
|
|
588
|
-
break;
|
|
589
|
-
}
|
|
590
|
-
return [r * 255, g * 255, b * 255];
|
|
591
|
-
};
|
|
592
|
-
convert.cmyk.rgb = function(cmyk) {
|
|
593
|
-
const c = cmyk[0] / 100;
|
|
594
|
-
const m = cmyk[1] / 100;
|
|
595
|
-
const y = cmyk[2] / 100;
|
|
596
|
-
const k = cmyk[3] / 100;
|
|
597
|
-
const r = 1 - Math.min(1, c * (1 - k) + k);
|
|
598
|
-
const g = 1 - Math.min(1, m * (1 - k) + k);
|
|
599
|
-
const b = 1 - Math.min(1, y * (1 - k) + k);
|
|
600
|
-
return [r * 255, g * 255, b * 255];
|
|
601
|
-
};
|
|
602
|
-
convert.xyz.rgb = function(xyz) {
|
|
603
|
-
const x = xyz[0] / 100;
|
|
604
|
-
const y = xyz[1] / 100;
|
|
605
|
-
const z = xyz[2] / 100;
|
|
606
|
-
let r;
|
|
607
|
-
let g;
|
|
608
|
-
let b;
|
|
609
|
-
r = x * 3.2406 + y * -1.5372 + z * -0.4986;
|
|
610
|
-
g = x * -0.9689 + y * 1.8758 + z * 0.0415;
|
|
611
|
-
b = x * 0.0557 + y * -0.204 + z * 1.057;
|
|
612
|
-
r = r > 31308e-7 ? 1.055 * r ** (1 / 2.4) - 0.055 : r * 12.92;
|
|
613
|
-
g = g > 31308e-7 ? 1.055 * g ** (1 / 2.4) - 0.055 : g * 12.92;
|
|
614
|
-
b = b > 31308e-7 ? 1.055 * b ** (1 / 2.4) - 0.055 : b * 12.92;
|
|
615
|
-
r = Math.min(Math.max(0, r), 1);
|
|
616
|
-
g = Math.min(Math.max(0, g), 1);
|
|
617
|
-
b = Math.min(Math.max(0, b), 1);
|
|
618
|
-
return [r * 255, g * 255, b * 255];
|
|
619
|
-
};
|
|
620
|
-
convert.xyz.lab = function(xyz) {
|
|
621
|
-
let x = xyz[0];
|
|
622
|
-
let y = xyz[1];
|
|
623
|
-
let z = xyz[2];
|
|
624
|
-
x /= 95.047;
|
|
625
|
-
y /= 100;
|
|
626
|
-
z /= 108.883;
|
|
627
|
-
x = x > 8856e-6 ? x ** (1 / 3) : 7.787 * x + 16 / 116;
|
|
628
|
-
y = y > 8856e-6 ? y ** (1 / 3) : 7.787 * y + 16 / 116;
|
|
629
|
-
z = z > 8856e-6 ? z ** (1 / 3) : 7.787 * z + 16 / 116;
|
|
630
|
-
const l = 116 * y - 16;
|
|
631
|
-
const a = 500 * (x - y);
|
|
632
|
-
const b = 200 * (y - z);
|
|
633
|
-
return [l, a, b];
|
|
634
|
-
};
|
|
635
|
-
convert.lab.xyz = function(lab) {
|
|
636
|
-
const l = lab[0];
|
|
637
|
-
const a = lab[1];
|
|
638
|
-
const b = lab[2];
|
|
639
|
-
let x;
|
|
640
|
-
let y;
|
|
641
|
-
let z;
|
|
642
|
-
y = (l + 16) / 116;
|
|
643
|
-
x = a / 500 + y;
|
|
644
|
-
z = y - b / 200;
|
|
645
|
-
const y2 = y ** 3;
|
|
646
|
-
const x2 = x ** 3;
|
|
647
|
-
const z2 = z ** 3;
|
|
648
|
-
y = y2 > 8856e-6 ? y2 : (y - 16 / 116) / 7.787;
|
|
649
|
-
x = x2 > 8856e-6 ? x2 : (x - 16 / 116) / 7.787;
|
|
650
|
-
z = z2 > 8856e-6 ? z2 : (z - 16 / 116) / 7.787;
|
|
651
|
-
x *= 95.047;
|
|
652
|
-
y *= 100;
|
|
653
|
-
z *= 108.883;
|
|
654
|
-
return [x, y, z];
|
|
655
|
-
};
|
|
656
|
-
convert.lab.lch = function(lab) {
|
|
657
|
-
const l = lab[0];
|
|
658
|
-
const a = lab[1];
|
|
659
|
-
const b = lab[2];
|
|
660
|
-
let h;
|
|
661
|
-
const hr = Math.atan2(b, a);
|
|
662
|
-
h = hr * 360 / 2 / Math.PI;
|
|
663
|
-
if (h < 0) {
|
|
664
|
-
h += 360;
|
|
665
|
-
}
|
|
666
|
-
const c = Math.sqrt(a * a + b * b);
|
|
667
|
-
return [l, c, h];
|
|
668
|
-
};
|
|
669
|
-
convert.lch.lab = function(lch) {
|
|
670
|
-
const l = lch[0];
|
|
671
|
-
const c = lch[1];
|
|
672
|
-
const h = lch[2];
|
|
673
|
-
const hr = h / 360 * 2 * Math.PI;
|
|
674
|
-
const a = c * Math.cos(hr);
|
|
675
|
-
const b = c * Math.sin(hr);
|
|
676
|
-
return [l, a, b];
|
|
677
|
-
};
|
|
678
|
-
convert.rgb.ansi16 = function(args, saturation = null) {
|
|
679
|
-
const [r, g, b] = args;
|
|
680
|
-
let value = saturation === null ? convert.rgb.hsv(args)[2] : saturation;
|
|
681
|
-
value = Math.round(value / 50);
|
|
682
|
-
if (value === 0) {
|
|
683
|
-
return 30;
|
|
684
|
-
}
|
|
685
|
-
let ansi = 30 + (Math.round(b / 255) << 2 | Math.round(g / 255) << 1 | Math.round(r / 255));
|
|
686
|
-
if (value === 2) {
|
|
687
|
-
ansi += 60;
|
|
688
|
-
}
|
|
689
|
-
return ansi;
|
|
690
|
-
};
|
|
691
|
-
convert.hsv.ansi16 = function(args) {
|
|
692
|
-
return convert.rgb.ansi16(convert.hsv.rgb(args), args[2]);
|
|
693
|
-
};
|
|
694
|
-
convert.rgb.ansi256 = function(args) {
|
|
695
|
-
const r = args[0];
|
|
696
|
-
const g = args[1];
|
|
697
|
-
const b = args[2];
|
|
698
|
-
if (r === g && g === b) {
|
|
699
|
-
if (r < 8) {
|
|
700
|
-
return 16;
|
|
701
|
-
}
|
|
702
|
-
if (r > 248) {
|
|
703
|
-
return 231;
|
|
704
|
-
}
|
|
705
|
-
return Math.round((r - 8) / 247 * 24) + 232;
|
|
706
|
-
}
|
|
707
|
-
const ansi = 16 + 36 * Math.round(r / 255 * 5) + 6 * Math.round(g / 255 * 5) + Math.round(b / 255 * 5);
|
|
708
|
-
return ansi;
|
|
709
|
-
};
|
|
710
|
-
convert.ansi16.rgb = function(args) {
|
|
711
|
-
let color = args % 10;
|
|
712
|
-
if (color === 0 || color === 7) {
|
|
713
|
-
if (args > 50) {
|
|
714
|
-
color += 3.5;
|
|
715
|
-
}
|
|
716
|
-
color = color / 10.5 * 255;
|
|
717
|
-
return [color, color, color];
|
|
718
|
-
}
|
|
719
|
-
const mult = (~~(args > 50) + 1) * 0.5;
|
|
720
|
-
const r = (color & 1) * mult * 255;
|
|
721
|
-
const g = (color >> 1 & 1) * mult * 255;
|
|
722
|
-
const b = (color >> 2 & 1) * mult * 255;
|
|
723
|
-
return [r, g, b];
|
|
724
|
-
};
|
|
725
|
-
convert.ansi256.rgb = function(args) {
|
|
726
|
-
if (args >= 232) {
|
|
727
|
-
const c = (args - 232) * 10 + 8;
|
|
728
|
-
return [c, c, c];
|
|
729
|
-
}
|
|
730
|
-
args -= 16;
|
|
731
|
-
let rem;
|
|
732
|
-
const r = Math.floor(args / 36) / 5 * 255;
|
|
733
|
-
const g = Math.floor((rem = args % 36) / 6) / 5 * 255;
|
|
734
|
-
const b = rem % 6 / 5 * 255;
|
|
735
|
-
return [r, g, b];
|
|
736
|
-
};
|
|
737
|
-
convert.rgb.hex = function(args) {
|
|
738
|
-
const integer = ((Math.round(args[0]) & 255) << 16) + ((Math.round(args[1]) & 255) << 8) + (Math.round(args[2]) & 255);
|
|
739
|
-
const string = integer.toString(16).toUpperCase();
|
|
740
|
-
return "000000".substring(string.length) + string;
|
|
741
|
-
};
|
|
742
|
-
convert.hex.rgb = function(args) {
|
|
743
|
-
const match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
|
|
744
|
-
if (!match) {
|
|
745
|
-
return [0, 0, 0];
|
|
746
|
-
}
|
|
747
|
-
let colorString = match[0];
|
|
748
|
-
if (match[0].length === 3) {
|
|
749
|
-
colorString = colorString.split("").map((char) => {
|
|
750
|
-
return char + char;
|
|
751
|
-
}).join("");
|
|
752
|
-
}
|
|
753
|
-
const integer = parseInt(colorString, 16);
|
|
754
|
-
const r = integer >> 16 & 255;
|
|
755
|
-
const g = integer >> 8 & 255;
|
|
756
|
-
const b = integer & 255;
|
|
757
|
-
return [r, g, b];
|
|
758
|
-
};
|
|
759
|
-
convert.rgb.hcg = function(rgb) {
|
|
760
|
-
const r = rgb[0] / 255;
|
|
761
|
-
const g = rgb[1] / 255;
|
|
762
|
-
const b = rgb[2] / 255;
|
|
763
|
-
const max = Math.max(Math.max(r, g), b);
|
|
764
|
-
const min = Math.min(Math.min(r, g), b);
|
|
765
|
-
const chroma = max - min;
|
|
766
|
-
let grayscale;
|
|
767
|
-
let hue;
|
|
768
|
-
if (chroma < 1) {
|
|
769
|
-
grayscale = min / (1 - chroma);
|
|
770
|
-
} else {
|
|
771
|
-
grayscale = 0;
|
|
772
|
-
}
|
|
773
|
-
if (chroma <= 0) {
|
|
774
|
-
hue = 0;
|
|
775
|
-
} else if (max === r) {
|
|
776
|
-
hue = (g - b) / chroma % 6;
|
|
777
|
-
} else if (max === g) {
|
|
778
|
-
hue = 2 + (b - r) / chroma;
|
|
779
|
-
} else {
|
|
780
|
-
hue = 4 + (r - g) / chroma;
|
|
781
|
-
}
|
|
782
|
-
hue /= 6;
|
|
783
|
-
hue %= 1;
|
|
784
|
-
return [hue * 360, chroma * 100, grayscale * 100];
|
|
785
|
-
};
|
|
786
|
-
convert.hsl.hcg = function(hsl) {
|
|
787
|
-
const s = hsl[1] / 100;
|
|
788
|
-
const l = hsl[2] / 100;
|
|
789
|
-
const c = l < 0.5 ? 2 * s * l : 2 * s * (1 - l);
|
|
790
|
-
let f = 0;
|
|
791
|
-
if (c < 1) {
|
|
792
|
-
f = (l - 0.5 * c) / (1 - c);
|
|
793
|
-
}
|
|
794
|
-
return [hsl[0], c * 100, f * 100];
|
|
795
|
-
};
|
|
796
|
-
convert.hsv.hcg = function(hsv) {
|
|
797
|
-
const s = hsv[1] / 100;
|
|
798
|
-
const v = hsv[2] / 100;
|
|
799
|
-
const c = s * v;
|
|
800
|
-
let f = 0;
|
|
801
|
-
if (c < 1) {
|
|
802
|
-
f = (v - c) / (1 - c);
|
|
803
|
-
}
|
|
804
|
-
return [hsv[0], c * 100, f * 100];
|
|
805
|
-
};
|
|
806
|
-
convert.hcg.rgb = function(hcg) {
|
|
807
|
-
const h = hcg[0] / 360;
|
|
808
|
-
const c = hcg[1] / 100;
|
|
809
|
-
const g = hcg[2] / 100;
|
|
810
|
-
if (c === 0) {
|
|
811
|
-
return [g * 255, g * 255, g * 255];
|
|
812
|
-
}
|
|
813
|
-
const pure = [0, 0, 0];
|
|
814
|
-
const hi = h % 1 * 6;
|
|
815
|
-
const v = hi % 1;
|
|
816
|
-
const w = 1 - v;
|
|
817
|
-
let mg = 0;
|
|
818
|
-
switch (Math.floor(hi)) {
|
|
819
|
-
case 0:
|
|
820
|
-
pure[0] = 1;
|
|
821
|
-
pure[1] = v;
|
|
822
|
-
pure[2] = 0;
|
|
823
|
-
break;
|
|
824
|
-
case 1:
|
|
825
|
-
pure[0] = w;
|
|
826
|
-
pure[1] = 1;
|
|
827
|
-
pure[2] = 0;
|
|
828
|
-
break;
|
|
829
|
-
case 2:
|
|
830
|
-
pure[0] = 0;
|
|
831
|
-
pure[1] = 1;
|
|
832
|
-
pure[2] = v;
|
|
833
|
-
break;
|
|
834
|
-
case 3:
|
|
835
|
-
pure[0] = 0;
|
|
836
|
-
pure[1] = w;
|
|
837
|
-
pure[2] = 1;
|
|
838
|
-
break;
|
|
839
|
-
case 4:
|
|
840
|
-
pure[0] = v;
|
|
841
|
-
pure[1] = 0;
|
|
842
|
-
pure[2] = 1;
|
|
843
|
-
break;
|
|
844
|
-
default:
|
|
845
|
-
pure[0] = 1;
|
|
846
|
-
pure[1] = 0;
|
|
847
|
-
pure[2] = w;
|
|
848
|
-
}
|
|
849
|
-
mg = (1 - c) * g;
|
|
850
|
-
return [
|
|
851
|
-
(c * pure[0] + mg) * 255,
|
|
852
|
-
(c * pure[1] + mg) * 255,
|
|
853
|
-
(c * pure[2] + mg) * 255
|
|
854
|
-
];
|
|
855
|
-
};
|
|
856
|
-
convert.hcg.hsv = function(hcg) {
|
|
857
|
-
const c = hcg[1] / 100;
|
|
858
|
-
const g = hcg[2] / 100;
|
|
859
|
-
const v = c + g * (1 - c);
|
|
860
|
-
let f = 0;
|
|
861
|
-
if (v > 0) {
|
|
862
|
-
f = c / v;
|
|
863
|
-
}
|
|
864
|
-
return [hcg[0], f * 100, v * 100];
|
|
865
|
-
};
|
|
866
|
-
convert.hcg.hsl = function(hcg) {
|
|
867
|
-
const c = hcg[1] / 100;
|
|
868
|
-
const g = hcg[2] / 100;
|
|
869
|
-
const l = g * (1 - c) + 0.5 * c;
|
|
870
|
-
let s = 0;
|
|
871
|
-
if (l > 0 && l < 0.5) {
|
|
872
|
-
s = c / (2 * l);
|
|
873
|
-
} else if (l >= 0.5 && l < 1) {
|
|
874
|
-
s = c / (2 * (1 - l));
|
|
875
|
-
}
|
|
876
|
-
return [hcg[0], s * 100, l * 100];
|
|
877
|
-
};
|
|
878
|
-
convert.hcg.hwb = function(hcg) {
|
|
879
|
-
const c = hcg[1] / 100;
|
|
880
|
-
const g = hcg[2] / 100;
|
|
881
|
-
const v = c + g * (1 - c);
|
|
882
|
-
return [hcg[0], (v - c) * 100, (1 - v) * 100];
|
|
883
|
-
};
|
|
884
|
-
convert.hwb.hcg = function(hwb) {
|
|
885
|
-
const w = hwb[1] / 100;
|
|
886
|
-
const b = hwb[2] / 100;
|
|
887
|
-
const v = 1 - b;
|
|
888
|
-
const c = v - w;
|
|
889
|
-
let g = 0;
|
|
890
|
-
if (c < 1) {
|
|
891
|
-
g = (v - c) / (1 - c);
|
|
892
|
-
}
|
|
893
|
-
return [hwb[0], c * 100, g * 100];
|
|
894
|
-
};
|
|
895
|
-
convert.apple.rgb = function(apple) {
|
|
896
|
-
return [apple[0] / 65535 * 255, apple[1] / 65535 * 255, apple[2] / 65535 * 255];
|
|
897
|
-
};
|
|
898
|
-
convert.rgb.apple = function(rgb) {
|
|
899
|
-
return [rgb[0] / 255 * 65535, rgb[1] / 255 * 65535, rgb[2] / 255 * 65535];
|
|
900
|
-
};
|
|
901
|
-
convert.gray.rgb = function(args) {
|
|
902
|
-
return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];
|
|
903
|
-
};
|
|
904
|
-
convert.gray.hsl = function(args) {
|
|
905
|
-
return [0, 0, args[0]];
|
|
906
|
-
};
|
|
907
|
-
convert.gray.hsv = convert.gray.hsl;
|
|
908
|
-
convert.gray.hwb = function(gray) {
|
|
909
|
-
return [0, 100, gray[0]];
|
|
910
|
-
};
|
|
911
|
-
convert.gray.cmyk = function(gray) {
|
|
912
|
-
return [0, 0, 0, gray[0]];
|
|
913
|
-
};
|
|
914
|
-
convert.gray.lab = function(gray) {
|
|
915
|
-
return [gray[0], 0, 0];
|
|
916
|
-
};
|
|
917
|
-
convert.gray.hex = function(gray) {
|
|
918
|
-
const val = Math.round(gray[0] / 100 * 255) & 255;
|
|
919
|
-
const integer = (val << 16) + (val << 8) + val;
|
|
920
|
-
const string = integer.toString(16).toUpperCase();
|
|
921
|
-
return "000000".substring(string.length) + string;
|
|
922
|
-
};
|
|
923
|
-
convert.rgb.gray = function(rgb) {
|
|
924
|
-
const val = (rgb[0] + rgb[1] + rgb[2]) / 3;
|
|
925
|
-
return [val / 255 * 100];
|
|
926
|
-
};
|
|
927
|
-
return conversions;
|
|
928
|
-
}
|
|
929
|
-
var route;
|
|
930
|
-
var hasRequiredRoute;
|
|
931
|
-
function requireRoute() {
|
|
932
|
-
if (hasRequiredRoute)
|
|
933
|
-
return route;
|
|
934
|
-
hasRequiredRoute = 1;
|
|
935
|
-
const conversions2 = requireConversions();
|
|
936
|
-
function buildGraph() {
|
|
937
|
-
const graph = {};
|
|
938
|
-
const models = Object.keys(conversions2);
|
|
939
|
-
for (let len = models.length, i = 0; i < len; i++) {
|
|
940
|
-
graph[models[i]] = {
|
|
941
|
-
// http://jsperf.com/1-vs-infinity
|
|
942
|
-
// micro-opt, but this is simple.
|
|
943
|
-
distance: -1,
|
|
944
|
-
parent: null
|
|
945
|
-
};
|
|
946
|
-
}
|
|
947
|
-
return graph;
|
|
948
|
-
}
|
|
949
|
-
function deriveBFS(fromModel) {
|
|
950
|
-
const graph = buildGraph();
|
|
951
|
-
const queue = [fromModel];
|
|
952
|
-
graph[fromModel].distance = 0;
|
|
953
|
-
while (queue.length) {
|
|
954
|
-
const current = queue.pop();
|
|
955
|
-
const adjacents = Object.keys(conversions2[current]);
|
|
956
|
-
for (let len = adjacents.length, i = 0; i < len; i++) {
|
|
957
|
-
const adjacent = adjacents[i];
|
|
958
|
-
const node = graph[adjacent];
|
|
959
|
-
if (node.distance === -1) {
|
|
960
|
-
node.distance = graph[current].distance + 1;
|
|
961
|
-
node.parent = current;
|
|
962
|
-
queue.unshift(adjacent);
|
|
963
|
-
}
|
|
964
|
-
}
|
|
965
|
-
}
|
|
966
|
-
return graph;
|
|
967
|
-
}
|
|
968
|
-
function link(from, to) {
|
|
969
|
-
return function(args) {
|
|
970
|
-
return to(from(args));
|
|
971
|
-
};
|
|
972
|
-
}
|
|
973
|
-
function wrapConversion(toModel, graph) {
|
|
974
|
-
const path = [graph[toModel].parent, toModel];
|
|
975
|
-
let fn = conversions2[graph[toModel].parent][toModel];
|
|
976
|
-
let cur = graph[toModel].parent;
|
|
977
|
-
while (graph[cur].parent) {
|
|
978
|
-
path.unshift(graph[cur].parent);
|
|
979
|
-
fn = link(conversions2[graph[cur].parent][cur], fn);
|
|
980
|
-
cur = graph[cur].parent;
|
|
981
|
-
}
|
|
982
|
-
fn.conversion = path;
|
|
983
|
-
return fn;
|
|
984
|
-
}
|
|
985
|
-
route = function(fromModel) {
|
|
986
|
-
const graph = deriveBFS(fromModel);
|
|
987
|
-
const conversion = {};
|
|
988
|
-
const models = Object.keys(graph);
|
|
989
|
-
for (let len = models.length, i = 0; i < len; i++) {
|
|
990
|
-
const toModel = models[i];
|
|
991
|
-
const node = graph[toModel];
|
|
992
|
-
if (node.parent === null) {
|
|
993
|
-
continue;
|
|
994
|
-
}
|
|
995
|
-
conversion[toModel] = wrapConversion(toModel, graph);
|
|
996
|
-
}
|
|
997
|
-
return conversion;
|
|
998
|
-
};
|
|
999
|
-
return route;
|
|
1000
|
-
}
|
|
1001
|
-
var colorConvert;
|
|
1002
|
-
var hasRequiredColorConvert;
|
|
1003
|
-
function requireColorConvert() {
|
|
1004
|
-
if (hasRequiredColorConvert)
|
|
1005
|
-
return colorConvert;
|
|
1006
|
-
hasRequiredColorConvert = 1;
|
|
1007
|
-
const conversions2 = requireConversions();
|
|
1008
|
-
const route2 = requireRoute();
|
|
1009
|
-
const convert = {};
|
|
1010
|
-
const models = Object.keys(conversions2);
|
|
1011
|
-
function wrapRaw(fn) {
|
|
1012
|
-
const wrappedFn = function(...args) {
|
|
1013
|
-
const arg0 = args[0];
|
|
1014
|
-
if (arg0 === void 0 || arg0 === null) {
|
|
1015
|
-
return arg0;
|
|
1016
|
-
}
|
|
1017
|
-
if (arg0.length > 1) {
|
|
1018
|
-
args = arg0;
|
|
1019
|
-
}
|
|
1020
|
-
return fn(args);
|
|
1021
|
-
};
|
|
1022
|
-
if ("conversion" in fn) {
|
|
1023
|
-
wrappedFn.conversion = fn.conversion;
|
|
1024
|
-
}
|
|
1025
|
-
return wrappedFn;
|
|
1026
|
-
}
|
|
1027
|
-
function wrapRounded(fn) {
|
|
1028
|
-
const wrappedFn = function(...args) {
|
|
1029
|
-
const arg0 = args[0];
|
|
1030
|
-
if (arg0 === void 0 || arg0 === null) {
|
|
1031
|
-
return arg0;
|
|
1032
|
-
}
|
|
1033
|
-
if (arg0.length > 1) {
|
|
1034
|
-
args = arg0;
|
|
1035
|
-
}
|
|
1036
|
-
const result = fn(args);
|
|
1037
|
-
if (typeof result === "object") {
|
|
1038
|
-
for (let len = result.length, i = 0; i < len; i++) {
|
|
1039
|
-
result[i] = Math.round(result[i]);
|
|
1040
|
-
}
|
|
1041
|
-
}
|
|
1042
|
-
return result;
|
|
1043
|
-
};
|
|
1044
|
-
if ("conversion" in fn) {
|
|
1045
|
-
wrappedFn.conversion = fn.conversion;
|
|
1046
|
-
}
|
|
1047
|
-
return wrappedFn;
|
|
1048
|
-
}
|
|
1049
|
-
models.forEach((fromModel) => {
|
|
1050
|
-
convert[fromModel] = {};
|
|
1051
|
-
Object.defineProperty(convert[fromModel], "channels", { value: conversions2[fromModel].channels });
|
|
1052
|
-
Object.defineProperty(convert[fromModel], "labels", { value: conversions2[fromModel].labels });
|
|
1053
|
-
const routes = route2(fromModel);
|
|
1054
|
-
const routeModels = Object.keys(routes);
|
|
1055
|
-
routeModels.forEach((toModel) => {
|
|
1056
|
-
const fn = routes[toModel];
|
|
1057
|
-
convert[fromModel][toModel] = wrapRounded(fn);
|
|
1058
|
-
convert[fromModel][toModel].raw = wrapRaw(fn);
|
|
1059
|
-
});
|
|
1060
|
-
});
|
|
1061
|
-
colorConvert = convert;
|
|
1062
|
-
return colorConvert;
|
|
1063
|
-
}
|
|
1064
|
-
ansiStyles$1.exports;
|
|
1065
|
-
(function(module) {
|
|
1066
|
-
const wrapAnsi16 = (fn, offset) => (...args) => {
|
|
1067
|
-
const code = fn(...args);
|
|
1068
|
-
return `\x1B[${code + offset}m`;
|
|
1069
|
-
};
|
|
1070
|
-
const wrapAnsi256 = (fn, offset) => (...args) => {
|
|
1071
|
-
const code = fn(...args);
|
|
1072
|
-
return `\x1B[${38 + offset};5;${code}m`;
|
|
1073
|
-
};
|
|
1074
|
-
const wrapAnsi16m = (fn, offset) => (...args) => {
|
|
1075
|
-
const rgb = fn(...args);
|
|
1076
|
-
return `\x1B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`;
|
|
1077
|
-
};
|
|
1078
|
-
const ansi2ansi = (n) => n;
|
|
1079
|
-
const rgb2rgb = (r, g, b) => [r, g, b];
|
|
1080
|
-
const setLazyProperty = (object, property, get) => {
|
|
1081
|
-
Object.defineProperty(object, property, {
|
|
1082
|
-
get: () => {
|
|
1083
|
-
const value = get();
|
|
1084
|
-
Object.defineProperty(object, property, {
|
|
1085
|
-
value,
|
|
1086
|
-
enumerable: true,
|
|
1087
|
-
configurable: true
|
|
1088
|
-
});
|
|
1089
|
-
return value;
|
|
1090
|
-
},
|
|
1091
|
-
enumerable: true,
|
|
1092
|
-
configurable: true
|
|
1093
|
-
});
|
|
1094
|
-
};
|
|
1095
|
-
let colorConvert2;
|
|
1096
|
-
const makeDynamicStyles = (wrap, targetSpace, identity, isBackground) => {
|
|
1097
|
-
if (colorConvert2 === void 0) {
|
|
1098
|
-
colorConvert2 = requireColorConvert();
|
|
1099
|
-
}
|
|
1100
|
-
const offset = isBackground ? 10 : 0;
|
|
1101
|
-
const styles2 = {};
|
|
1102
|
-
for (const [sourceSpace, suite] of Object.entries(colorConvert2)) {
|
|
1103
|
-
const name = sourceSpace === "ansi16" ? "ansi" : sourceSpace;
|
|
1104
|
-
if (sourceSpace === targetSpace) {
|
|
1105
|
-
styles2[name] = wrap(identity, offset);
|
|
1106
|
-
} else if (typeof suite === "object") {
|
|
1107
|
-
styles2[name] = wrap(suite[targetSpace], offset);
|
|
1108
|
-
}
|
|
1109
|
-
}
|
|
1110
|
-
return styles2;
|
|
1111
|
-
};
|
|
1112
|
-
function assembleStyles() {
|
|
1113
|
-
const codes = /* @__PURE__ */ new Map();
|
|
1114
|
-
const styles2 = {
|
|
1115
|
-
modifier: {
|
|
1116
|
-
reset: [0, 0],
|
|
1117
|
-
// 21 isn't widely supported and 22 does the same thing
|
|
1118
|
-
bold: [1, 22],
|
|
1119
|
-
dim: [2, 22],
|
|
1120
|
-
italic: [3, 23],
|
|
1121
|
-
underline: [4, 24],
|
|
1122
|
-
inverse: [7, 27],
|
|
1123
|
-
hidden: [8, 28],
|
|
1124
|
-
strikethrough: [9, 29]
|
|
1125
|
-
},
|
|
1126
|
-
color: {
|
|
1127
|
-
black: [30, 39],
|
|
1128
|
-
red: [31, 39],
|
|
1129
|
-
green: [32, 39],
|
|
1130
|
-
yellow: [33, 39],
|
|
1131
|
-
blue: [34, 39],
|
|
1132
|
-
magenta: [35, 39],
|
|
1133
|
-
cyan: [36, 39],
|
|
1134
|
-
white: [37, 39],
|
|
1135
|
-
// Bright color
|
|
1136
|
-
blackBright: [90, 39],
|
|
1137
|
-
redBright: [91, 39],
|
|
1138
|
-
greenBright: [92, 39],
|
|
1139
|
-
yellowBright: [93, 39],
|
|
1140
|
-
blueBright: [94, 39],
|
|
1141
|
-
magentaBright: [95, 39],
|
|
1142
|
-
cyanBright: [96, 39],
|
|
1143
|
-
whiteBright: [97, 39]
|
|
1144
|
-
},
|
|
1145
|
-
bgColor: {
|
|
1146
|
-
bgBlack: [40, 49],
|
|
1147
|
-
bgRed: [41, 49],
|
|
1148
|
-
bgGreen: [42, 49],
|
|
1149
|
-
bgYellow: [43, 49],
|
|
1150
|
-
bgBlue: [44, 49],
|
|
1151
|
-
bgMagenta: [45, 49],
|
|
1152
|
-
bgCyan: [46, 49],
|
|
1153
|
-
bgWhite: [47, 49],
|
|
1154
|
-
// Bright color
|
|
1155
|
-
bgBlackBright: [100, 49],
|
|
1156
|
-
bgRedBright: [101, 49],
|
|
1157
|
-
bgGreenBright: [102, 49],
|
|
1158
|
-
bgYellowBright: [103, 49],
|
|
1159
|
-
bgBlueBright: [104, 49],
|
|
1160
|
-
bgMagentaBright: [105, 49],
|
|
1161
|
-
bgCyanBright: [106, 49],
|
|
1162
|
-
bgWhiteBright: [107, 49]
|
|
1163
|
-
}
|
|
1164
|
-
};
|
|
1165
|
-
styles2.color.gray = styles2.color.blackBright;
|
|
1166
|
-
styles2.bgColor.bgGray = styles2.bgColor.bgBlackBright;
|
|
1167
|
-
styles2.color.grey = styles2.color.blackBright;
|
|
1168
|
-
styles2.bgColor.bgGrey = styles2.bgColor.bgBlackBright;
|
|
1169
|
-
for (const [groupName, group] of Object.entries(styles2)) {
|
|
1170
|
-
for (const [styleName, style] of Object.entries(group)) {
|
|
1171
|
-
styles2[styleName] = {
|
|
1172
|
-
open: `\x1B[${style[0]}m`,
|
|
1173
|
-
close: `\x1B[${style[1]}m`
|
|
1174
|
-
};
|
|
1175
|
-
group[styleName] = styles2[styleName];
|
|
1176
|
-
codes.set(style[0], style[1]);
|
|
1177
|
-
}
|
|
1178
|
-
Object.defineProperty(styles2, groupName, {
|
|
1179
|
-
value: group,
|
|
1180
|
-
enumerable: false
|
|
1181
|
-
});
|
|
1182
|
-
}
|
|
1183
|
-
Object.defineProperty(styles2, "codes", {
|
|
1184
|
-
value: codes,
|
|
1185
|
-
enumerable: false
|
|
1186
|
-
});
|
|
1187
|
-
styles2.color.close = "\x1B[39m";
|
|
1188
|
-
styles2.bgColor.close = "\x1B[49m";
|
|
1189
|
-
setLazyProperty(styles2.color, "ansi", () => makeDynamicStyles(wrapAnsi16, "ansi16", ansi2ansi, false));
|
|
1190
|
-
setLazyProperty(styles2.color, "ansi256", () => makeDynamicStyles(wrapAnsi256, "ansi256", ansi2ansi, false));
|
|
1191
|
-
setLazyProperty(styles2.color, "ansi16m", () => makeDynamicStyles(wrapAnsi16m, "rgb", rgb2rgb, false));
|
|
1192
|
-
setLazyProperty(styles2.bgColor, "ansi", () => makeDynamicStyles(wrapAnsi16, "ansi16", ansi2ansi, true));
|
|
1193
|
-
setLazyProperty(styles2.bgColor, "ansi256", () => makeDynamicStyles(wrapAnsi256, "ansi256", ansi2ansi, true));
|
|
1194
|
-
setLazyProperty(styles2.bgColor, "ansi16m", () => makeDynamicStyles(wrapAnsi16m, "rgb", rgb2rgb, true));
|
|
1195
|
-
return styles2;
|
|
1196
|
-
}
|
|
1197
|
-
Object.defineProperty(module, "exports", {
|
|
1198
|
-
enumerable: true,
|
|
1199
|
-
get: assembleStyles
|
|
1200
|
-
});
|
|
1201
|
-
})(ansiStyles$1);
|
|
1202
|
-
var ansiStylesExports = ansiStyles$1.exports;
|
|
1203
|
-
var browser = {
|
|
1204
|
-
stdout: false,
|
|
1205
|
-
stderr: false
|
|
1206
|
-
};
|
|
1207
|
-
const stringReplaceAll$1 = (string, substring, replacer) => {
|
|
1208
|
-
let index = string.indexOf(substring);
|
|
1209
|
-
if (index === -1) {
|
|
1210
|
-
return string;
|
|
1211
|
-
}
|
|
1212
|
-
const substringLength = substring.length;
|
|
1213
|
-
let endIndex = 0;
|
|
1214
|
-
let returnValue = "";
|
|
1215
|
-
do {
|
|
1216
|
-
returnValue += string.substr(endIndex, index - endIndex) + substring + replacer;
|
|
1217
|
-
endIndex = index + substringLength;
|
|
1218
|
-
index = string.indexOf(substring, endIndex);
|
|
1219
|
-
} while (index !== -1);
|
|
1220
|
-
returnValue += string.substr(endIndex);
|
|
1221
|
-
return returnValue;
|
|
1222
|
-
};
|
|
1223
|
-
const stringEncaseCRLFWithFirstIndex$1 = (string, prefix, postfix, index) => {
|
|
1224
|
-
let endIndex = 0;
|
|
1225
|
-
let returnValue = "";
|
|
1226
|
-
do {
|
|
1227
|
-
const gotCR = string[index - 1] === "\r";
|
|
1228
|
-
returnValue += string.substr(endIndex, (gotCR ? index - 1 : index) - endIndex) + prefix + (gotCR ? "\r\n" : "\n") + postfix;
|
|
1229
|
-
endIndex = index + 1;
|
|
1230
|
-
index = string.indexOf("\n", endIndex);
|
|
1231
|
-
} while (index !== -1);
|
|
1232
|
-
returnValue += string.substr(endIndex);
|
|
1233
|
-
return returnValue;
|
|
1234
|
-
};
|
|
1235
|
-
var util = {
|
|
1236
|
-
stringReplaceAll: stringReplaceAll$1,
|
|
1237
|
-
stringEncaseCRLFWithFirstIndex: stringEncaseCRLFWithFirstIndex$1
|
|
1238
|
-
};
|
|
1239
|
-
var templates;
|
|
1240
|
-
var hasRequiredTemplates;
|
|
1241
|
-
function requireTemplates() {
|
|
1242
|
-
if (hasRequiredTemplates)
|
|
1243
|
-
return templates;
|
|
1244
|
-
hasRequiredTemplates = 1;
|
|
1245
|
-
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;
|
|
1246
|
-
const STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
|
|
1247
|
-
const STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
|
|
1248
|
-
const ESCAPE_REGEX = /\\(u(?:[a-f\d]{4}|{[a-f\d]{1,6}})|x[a-f\d]{2}|.)|([^\\])/gi;
|
|
1249
|
-
const ESCAPES = /* @__PURE__ */ new Map([
|
|
1250
|
-
["n", "\n"],
|
|
1251
|
-
["r", "\r"],
|
|
1252
|
-
["t", " "],
|
|
1253
|
-
["b", "\b"],
|
|
1254
|
-
["f", "\f"],
|
|
1255
|
-
["v", "\v"],
|
|
1256
|
-
["0", "\0"],
|
|
1257
|
-
["\\", "\\"],
|
|
1258
|
-
["e", "\x1B"],
|
|
1259
|
-
["a", "\x07"]
|
|
1260
|
-
]);
|
|
1261
|
-
function unescape(c) {
|
|
1262
|
-
const u = c[0] === "u";
|
|
1263
|
-
const bracket = c[1] === "{";
|
|
1264
|
-
if (u && !bracket && c.length === 5 || c[0] === "x" && c.length === 3) {
|
|
1265
|
-
return String.fromCharCode(parseInt(c.slice(1), 16));
|
|
1266
|
-
}
|
|
1267
|
-
if (u && bracket) {
|
|
1268
|
-
return String.fromCodePoint(parseInt(c.slice(2, -1), 16));
|
|
1269
|
-
}
|
|
1270
|
-
return ESCAPES.get(c) || c;
|
|
1271
|
-
}
|
|
1272
|
-
function parseArguments(name, arguments_) {
|
|
1273
|
-
const results = [];
|
|
1274
|
-
const chunks = arguments_.trim().split(/\s*,\s*/g);
|
|
1275
|
-
let matches;
|
|
1276
|
-
for (const chunk of chunks) {
|
|
1277
|
-
const number = Number(chunk);
|
|
1278
|
-
if (!Number.isNaN(number)) {
|
|
1279
|
-
results.push(number);
|
|
1280
|
-
} else if (matches = chunk.match(STRING_REGEX)) {
|
|
1281
|
-
results.push(matches[2].replace(ESCAPE_REGEX, (m, escape, character) => escape ? unescape(escape) : character));
|
|
1282
|
-
} else {
|
|
1283
|
-
throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`);
|
|
1284
|
-
}
|
|
1285
|
-
}
|
|
1286
|
-
return results;
|
|
1287
|
-
}
|
|
1288
|
-
function parseStyle(style) {
|
|
1289
|
-
STYLE_REGEX.lastIndex = 0;
|
|
1290
|
-
const results = [];
|
|
1291
|
-
let matches;
|
|
1292
|
-
while ((matches = STYLE_REGEX.exec(style)) !== null) {
|
|
1293
|
-
const name = matches[1];
|
|
1294
|
-
if (matches[2]) {
|
|
1295
|
-
const args = parseArguments(name, matches[2]);
|
|
1296
|
-
results.push([name].concat(args));
|
|
1297
|
-
} else {
|
|
1298
|
-
results.push([name]);
|
|
1299
|
-
}
|
|
1300
|
-
}
|
|
1301
|
-
return results;
|
|
1302
|
-
}
|
|
1303
|
-
function buildStyle(chalk2, styles2) {
|
|
1304
|
-
const enabled = {};
|
|
1305
|
-
for (const layer of styles2) {
|
|
1306
|
-
for (const style of layer.styles) {
|
|
1307
|
-
enabled[style[0]] = layer.inverse ? null : style.slice(1);
|
|
1308
|
-
}
|
|
1309
|
-
}
|
|
1310
|
-
let current = chalk2;
|
|
1311
|
-
for (const [styleName, styles3] of Object.entries(enabled)) {
|
|
1312
|
-
if (!Array.isArray(styles3)) {
|
|
1313
|
-
continue;
|
|
1314
|
-
}
|
|
1315
|
-
if (!(styleName in current)) {
|
|
1316
|
-
throw new Error(`Unknown Chalk style: ${styleName}`);
|
|
1317
|
-
}
|
|
1318
|
-
current = styles3.length > 0 ? current[styleName](...styles3) : current[styleName];
|
|
1319
|
-
}
|
|
1320
|
-
return current;
|
|
1321
|
-
}
|
|
1322
|
-
templates = (chalk2, temporary) => {
|
|
1323
|
-
const styles2 = [];
|
|
1324
|
-
const chunks = [];
|
|
1325
|
-
let chunk = [];
|
|
1326
|
-
temporary.replace(TEMPLATE_REGEX, (m, escapeCharacter, inverse, style, close, character) => {
|
|
1327
|
-
if (escapeCharacter) {
|
|
1328
|
-
chunk.push(unescape(escapeCharacter));
|
|
1329
|
-
} else if (style) {
|
|
1330
|
-
const string = chunk.join("");
|
|
1331
|
-
chunk = [];
|
|
1332
|
-
chunks.push(styles2.length === 0 ? string : buildStyle(chalk2, styles2)(string));
|
|
1333
|
-
styles2.push({ inverse, styles: parseStyle(style) });
|
|
1334
|
-
} else if (close) {
|
|
1335
|
-
if (styles2.length === 0) {
|
|
1336
|
-
throw new Error("Found extraneous } in Chalk template literal");
|
|
1337
|
-
}
|
|
1338
|
-
chunks.push(buildStyle(chalk2, styles2)(chunk.join("")));
|
|
1339
|
-
chunk = [];
|
|
1340
|
-
styles2.pop();
|
|
1341
|
-
} else {
|
|
1342
|
-
chunk.push(character);
|
|
1343
|
-
}
|
|
1344
|
-
});
|
|
1345
|
-
chunks.push(chunk.join(""));
|
|
1346
|
-
if (styles2.length > 0) {
|
|
1347
|
-
const errMessage = `Chalk template literal is missing ${styles2.length} closing bracket${styles2.length === 1 ? "" : "s"} (\`}\`)`;
|
|
1348
|
-
throw new Error(errMessage);
|
|
1349
|
-
}
|
|
1350
|
-
return chunks.join("");
|
|
1351
|
-
};
|
|
1352
|
-
return templates;
|
|
1353
|
-
}
|
|
1354
|
-
const ansiStyles = ansiStylesExports;
|
|
1355
|
-
const { stdout: stdoutColor, stderr: stderrColor } = browser;
|
|
1356
|
-
const {
|
|
1357
|
-
stringReplaceAll,
|
|
1358
|
-
stringEncaseCRLFWithFirstIndex
|
|
1359
|
-
} = util;
|
|
1360
|
-
const { isArray } = Array;
|
|
1361
|
-
const levelMapping = [
|
|
1362
|
-
"ansi",
|
|
1363
|
-
"ansi",
|
|
1364
|
-
"ansi256",
|
|
1365
|
-
"ansi16m"
|
|
1366
|
-
];
|
|
1367
|
-
const styles = /* @__PURE__ */ Object.create(null);
|
|
1368
|
-
const applyOptions = (object, options = {}) => {
|
|
1369
|
-
if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
|
|
1370
|
-
throw new Error("The `level` option should be an integer from 0 to 3");
|
|
1371
|
-
}
|
|
1372
|
-
const colorLevel = stdoutColor ? stdoutColor.level : 0;
|
|
1373
|
-
object.level = options.level === void 0 ? colorLevel : options.level;
|
|
1374
|
-
};
|
|
1375
|
-
class ChalkClass {
|
|
1376
|
-
constructor(options) {
|
|
1377
|
-
return chalkFactory(options);
|
|
1378
|
-
}
|
|
1379
|
-
}
|
|
1380
|
-
const chalkFactory = (options) => {
|
|
1381
|
-
const chalk2 = {};
|
|
1382
|
-
applyOptions(chalk2, options);
|
|
1383
|
-
chalk2.template = (...arguments_) => chalkTag(chalk2.template, ...arguments_);
|
|
1384
|
-
Object.setPrototypeOf(chalk2, Chalk.prototype);
|
|
1385
|
-
Object.setPrototypeOf(chalk2.template, chalk2);
|
|
1386
|
-
chalk2.template.constructor = () => {
|
|
1387
|
-
throw new Error("`chalk.constructor()` is deprecated. Use `new chalk.Instance()` instead.");
|
|
1388
|
-
};
|
|
1389
|
-
chalk2.template.Instance = ChalkClass;
|
|
1390
|
-
return chalk2.template;
|
|
1391
|
-
};
|
|
1392
|
-
function Chalk(options) {
|
|
1393
|
-
return chalkFactory(options);
|
|
1394
|
-
}
|
|
1395
|
-
for (const [styleName, style] of Object.entries(ansiStyles)) {
|
|
1396
|
-
styles[styleName] = {
|
|
1397
|
-
get() {
|
|
1398
|
-
const builder = createBuilder(this, createStyler(style.open, style.close, this._styler), this._isEmpty);
|
|
1399
|
-
Object.defineProperty(this, styleName, { value: builder });
|
|
1400
|
-
return builder;
|
|
1401
|
-
}
|
|
1402
|
-
};
|
|
1403
|
-
}
|
|
1404
|
-
styles.visible = {
|
|
1405
|
-
get() {
|
|
1406
|
-
const builder = createBuilder(this, this._styler, true);
|
|
1407
|
-
Object.defineProperty(this, "visible", { value: builder });
|
|
1408
|
-
return builder;
|
|
1409
|
-
}
|
|
1410
|
-
};
|
|
1411
|
-
const usedModels = ["rgb", "hex", "keyword", "hsl", "hsv", "hwb", "ansi", "ansi256"];
|
|
1412
|
-
for (const model of usedModels) {
|
|
1413
|
-
styles[model] = {
|
|
1414
|
-
get() {
|
|
1415
|
-
const { level } = this;
|
|
1416
|
-
return function(...arguments_) {
|
|
1417
|
-
const styler = createStyler(ansiStyles.color[levelMapping[level]][model](...arguments_), ansiStyles.color.close, this._styler);
|
|
1418
|
-
return createBuilder(this, styler, this._isEmpty);
|
|
1419
|
-
};
|
|
1420
|
-
}
|
|
1421
|
-
};
|
|
1422
|
-
}
|
|
1423
|
-
for (const model of usedModels) {
|
|
1424
|
-
const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
|
|
1425
|
-
styles[bgModel] = {
|
|
1426
|
-
get() {
|
|
1427
|
-
const { level } = this;
|
|
1428
|
-
return function(...arguments_) {
|
|
1429
|
-
const styler = createStyler(ansiStyles.bgColor[levelMapping[level]][model](...arguments_), ansiStyles.bgColor.close, this._styler);
|
|
1430
|
-
return createBuilder(this, styler, this._isEmpty);
|
|
1431
|
-
};
|
|
1432
|
-
}
|
|
1433
|
-
};
|
|
1434
|
-
}
|
|
1435
|
-
const proto = Object.defineProperties(() => {
|
|
1436
|
-
}, {
|
|
1437
|
-
...styles,
|
|
1438
|
-
level: {
|
|
1439
|
-
enumerable: true,
|
|
1440
|
-
get() {
|
|
1441
|
-
return this._generator.level;
|
|
1442
|
-
},
|
|
1443
|
-
set(level) {
|
|
1444
|
-
this._generator.level = level;
|
|
1445
|
-
}
|
|
1446
|
-
}
|
|
1447
|
-
});
|
|
1448
|
-
const createStyler = (open, close, parent) => {
|
|
1449
|
-
let openAll;
|
|
1450
|
-
let closeAll;
|
|
1451
|
-
if (parent === void 0) {
|
|
1452
|
-
openAll = open;
|
|
1453
|
-
closeAll = close;
|
|
1454
|
-
} else {
|
|
1455
|
-
openAll = parent.openAll + open;
|
|
1456
|
-
closeAll = close + parent.closeAll;
|
|
1457
|
-
}
|
|
1458
|
-
return {
|
|
1459
|
-
open,
|
|
1460
|
-
close,
|
|
1461
|
-
openAll,
|
|
1462
|
-
closeAll,
|
|
1463
|
-
parent
|
|
1464
|
-
};
|
|
1465
|
-
};
|
|
1466
|
-
const createBuilder = (self, _styler, _isEmpty) => {
|
|
1467
|
-
const builder = (...arguments_) => {
|
|
1468
|
-
if (isArray(arguments_[0]) && isArray(arguments_[0].raw)) {
|
|
1469
|
-
return applyStyle(builder, chalkTag(builder, ...arguments_));
|
|
1470
|
-
}
|
|
1471
|
-
return applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
|
|
1472
|
-
};
|
|
1473
|
-
Object.setPrototypeOf(builder, proto);
|
|
1474
|
-
builder._generator = self;
|
|
1475
|
-
builder._styler = _styler;
|
|
1476
|
-
builder._isEmpty = _isEmpty;
|
|
1477
|
-
return builder;
|
|
1478
|
-
};
|
|
1479
|
-
const applyStyle = (self, string) => {
|
|
1480
|
-
if (self.level <= 0 || !string) {
|
|
1481
|
-
return self._isEmpty ? "" : string;
|
|
1482
|
-
}
|
|
1483
|
-
let styler = self._styler;
|
|
1484
|
-
if (styler === void 0) {
|
|
1485
|
-
return string;
|
|
1486
|
-
}
|
|
1487
|
-
const { openAll, closeAll } = styler;
|
|
1488
|
-
if (string.indexOf("\x1B") !== -1) {
|
|
1489
|
-
while (styler !== void 0) {
|
|
1490
|
-
string = stringReplaceAll(string, styler.close, styler.open);
|
|
1491
|
-
styler = styler.parent;
|
|
1492
|
-
}
|
|
1493
|
-
}
|
|
1494
|
-
const lfIndex = string.indexOf("\n");
|
|
1495
|
-
if (lfIndex !== -1) {
|
|
1496
|
-
string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
|
|
1497
|
-
}
|
|
1498
|
-
return openAll + string + closeAll;
|
|
1499
|
-
};
|
|
1500
|
-
let template;
|
|
1501
|
-
const chalkTag = (chalk2, ...strings) => {
|
|
1502
|
-
const [firstString] = strings;
|
|
1503
|
-
if (!isArray(firstString) || !isArray(firstString.raw)) {
|
|
1504
|
-
return strings.join(" ");
|
|
1505
|
-
}
|
|
1506
|
-
const arguments_ = strings.slice(1);
|
|
1507
|
-
const parts = [firstString.raw[0]];
|
|
1508
|
-
for (let i = 1; i < firstString.length; i++) {
|
|
1509
|
-
parts.push(
|
|
1510
|
-
String(arguments_[i - 1]).replace(/[{}\\]/g, "\\$&"),
|
|
1511
|
-
String(firstString.raw[i])
|
|
1512
|
-
);
|
|
1513
|
-
}
|
|
1514
|
-
if (template === void 0) {
|
|
1515
|
-
template = requireTemplates();
|
|
1516
|
-
}
|
|
1517
|
-
return template(chalk2, parts.join(""));
|
|
1518
|
-
};
|
|
1519
|
-
Object.defineProperties(Chalk.prototype, styles);
|
|
1520
|
-
const chalk = Chalk();
|
|
1521
|
-
chalk.supportsColor = stdoutColor;
|
|
1522
|
-
chalk.stderr = Chalk({ level: stderrColor ? stderrColor.level : 0 });
|
|
1523
|
-
chalk.stderr.supportsColor = stderrColor;
|
|
1524
|
-
var source = chalk;
|
|
1525
|
-
const chalk$1 = /* @__PURE__ */ getDefaultExportFromCjs(source);
|
|
1526
|
-
class SessionManager {
|
|
1527
|
-
constructor(workerPort, options, logger) {
|
|
1528
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1529
|
-
__privateAdd(this, _LogDebugMessage);
|
|
1530
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1531
|
-
__privateAdd(this, _LogInfoMessage);
|
|
1532
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1533
|
-
__privateAdd(this, _LogErrorMessage);
|
|
1534
|
-
__privateAdd(this, _options, void 0);
|
|
75
|
+
const isNode = Object.prototype.toString.call(typeof process !== "undefined" ? process : 0) === "[object process]";
|
|
76
|
+
class ResourceManager {
|
|
77
|
+
constructor(options, logger) {
|
|
78
|
+
__privateAdd(this, _options);
|
|
1535
79
|
__privateAdd(this, _httpsAgent, null);
|
|
1536
|
-
__privateAdd(this, _logger
|
|
80
|
+
__privateAdd(this, _logger);
|
|
81
|
+
__privateAdd(this, _axiosConfig, null);
|
|
82
|
+
__privateAdd(this, _accessToken, null);
|
|
1537
83
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1538
|
-
|
|
84
|
+
__publicField(this, "GetErrorMessage", (status, error, detail) => {
|
|
1539
85
|
return {
|
|
1540
86
|
status,
|
|
1541
87
|
error,
|
|
1542
88
|
detail
|
|
1543
89
|
};
|
|
1544
90
|
});
|
|
1545
|
-
__publicField(this, "
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
}
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
91
|
+
__publicField(this, "GetHeaders", (access_token) => {
|
|
92
|
+
const headers = {
|
|
93
|
+
"Content-Type": "application/json"
|
|
94
|
+
};
|
|
95
|
+
if (__privateGet(this, _accessToken)) {
|
|
96
|
+
headers["Authorization"] = `Bearer ${access_token}`;
|
|
97
|
+
}
|
|
98
|
+
return headers;
|
|
99
|
+
});
|
|
100
|
+
// Make data be a abstract base class for resources
|
|
101
|
+
__publicField(this, "AxiosConfig", (url, httpMethod, data) => {
|
|
102
|
+
__privateSet(this, _axiosConfig, {
|
|
103
|
+
url,
|
|
104
|
+
method: httpMethod,
|
|
105
|
+
headers: this.GetHeaders(__privateGet(this, _accessToken)),
|
|
106
|
+
timeout: this.options.timeout
|
|
107
|
+
});
|
|
108
|
+
if (data) {
|
|
109
|
+
__privateGet(this, _axiosConfig).data = data;
|
|
110
|
+
}
|
|
111
|
+
if (isNode) {
|
|
112
|
+
__privateGet(this, _axiosConfig).httpsAgent = this.httpsAgent;
|
|
113
|
+
}
|
|
114
|
+
return this;
|
|
115
|
+
});
|
|
116
|
+
__publicField(this, "GetResult", async (errorCb) => {
|
|
117
|
+
const axiosConfigSnapshot = __privateGet(this, _axiosConfig);
|
|
118
|
+
const data = await axios(axiosConfigSnapshot);
|
|
119
|
+
if (data.data.status === StatusCodes.OK || data.data.status === StatusCodes.CREATED) {
|
|
120
|
+
const sessionDataRaw = data.data.detail;
|
|
121
|
+
if (sessionDataRaw) {
|
|
122
|
+
try {
|
|
123
|
+
const sessionData = JSON.parse(sessionDataRaw);
|
|
124
|
+
return sessionData;
|
|
125
|
+
} catch (error) {
|
|
126
|
+
errorCb(this.GetErrorMessage(StatusCodes.INTERNAL_SERVER_ERROR, "SessionManager:GetResult(): Could not parse session data.", error));
|
|
1575
127
|
return null;
|
|
1576
128
|
}
|
|
1577
129
|
} else {
|
|
1578
|
-
|
|
1579
|
-
errorCb(__privateGet(this, _GetErrorMessage).call(this, status, `SessionManager:GetSession(): Status not OK. Error: [${error}]`, detail));
|
|
130
|
+
errorCb(this.GetErrorMessage(StatusCodes.INTERNAL_SERVER_ERROR, "SessionManager:GetResult(): No session data returned.", null));
|
|
1580
131
|
return null;
|
|
1581
132
|
}
|
|
1582
|
-
}
|
|
1583
|
-
|
|
133
|
+
} else {
|
|
134
|
+
const { status, error, detail } = data.data;
|
|
135
|
+
errorCb(this.GetErrorMessage(status, `SessionManager:GetResult(): Status not OK. Error: [${error}]`, detail));
|
|
1584
136
|
return null;
|
|
1585
137
|
}
|
|
1586
138
|
});
|
|
1587
139
|
__privateSet(this, _options, options);
|
|
1588
140
|
__privateSet(this, _logger, logger);
|
|
1589
|
-
|
|
141
|
+
this.LogDebugMessage(`STSOAuth2Worker:constructor:#options: [${JSON.stringify(__privateGet(this, _options))}]`);
|
|
1590
142
|
if (isNode && __privateGet(this, _options).agentOptions) {
|
|
1591
143
|
__privateSet(this, _httpsAgent, new https.Agent({
|
|
1592
144
|
keepAlive: __privateGet(this, _options).agentOptions.keepAlive,
|
|
@@ -1599,55 +151,68 @@ class SessionManager {
|
|
|
1599
151
|
}));
|
|
1600
152
|
}
|
|
1601
153
|
}
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
*/
|
|
154
|
+
get httpsAgent() {
|
|
155
|
+
return __privateGet(this, _httpsAgent);
|
|
156
|
+
}
|
|
157
|
+
get options() {
|
|
158
|
+
return __privateGet(this, _options);
|
|
159
|
+
}
|
|
160
|
+
get axiosConfig() {
|
|
161
|
+
return __privateGet(this, _axiosConfig);
|
|
162
|
+
}
|
|
163
|
+
get accessToken() {
|
|
164
|
+
return __privateGet(this, _accessToken);
|
|
165
|
+
}
|
|
166
|
+
set accessToken(token) {
|
|
167
|
+
__privateSet(this, _accessToken, token);
|
|
168
|
+
}
|
|
169
|
+
SetAccessToken(token) {
|
|
170
|
+
this.accessToken = token;
|
|
171
|
+
return this;
|
|
172
|
+
}
|
|
173
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
174
|
+
LogDebugMessage(message) {
|
|
175
|
+
__privateGet(this, _logger).debug(message);
|
|
176
|
+
}
|
|
177
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
178
|
+
LogInfoMessage(message) {
|
|
179
|
+
__privateGet(this, _logger).info(message);
|
|
180
|
+
}
|
|
181
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
182
|
+
LogErrorMessage(message) {
|
|
183
|
+
__privateGet(this, _logger).error(message);
|
|
184
|
+
}
|
|
1634
185
|
}
|
|
1635
186
|
_options = new WeakMap();
|
|
1636
187
|
_httpsAgent = new WeakMap();
|
|
1637
188
|
_logger = new WeakMap();
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
};
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
}
|
|
1650
|
-
|
|
189
|
+
_axiosConfig = new WeakMap();
|
|
190
|
+
_accessToken = new WeakMap();
|
|
191
|
+
class SessionManager extends ResourceManager {
|
|
192
|
+
constructor(options, logger) {
|
|
193
|
+
super(options, logger);
|
|
194
|
+
__publicField(this, "GetSession", async (access_token, sessionId, errorCb) => {
|
|
195
|
+
try {
|
|
196
|
+
return this.SetAccessToken(access_token).AxiosConfig(`${this.options.asendpoint}/session/${encodeURIComponent(sessionId)}`, "get").GetResult(errorCb);
|
|
197
|
+
} catch (error) {
|
|
198
|
+
errorCb(this.GetErrorMessage(StatusCodes.INTERNAL_SERVER_ERROR, `SessionManager:GetSession(): Could not process session. Error: [${error}]`, error));
|
|
199
|
+
return null;
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
__publicField(this, "PatchSession", async (access_token, session, errorCb) => {
|
|
203
|
+
try {
|
|
204
|
+
if (!session.sessionId) {
|
|
205
|
+
errorCb(this.GetErrorMessage(StatusCodes.INTERNAL_SERVER_ERROR, "SessionManager:GetSession(): sessionId not provided.", null));
|
|
206
|
+
return null;
|
|
207
|
+
}
|
|
208
|
+
return this.SetAccessToken(access_token).AxiosConfig(`${this.options.asendpoint}/session/${encodeURIComponent(session.sessionId)}`, "patch", session).GetResult(errorCb);
|
|
209
|
+
} catch (error) {
|
|
210
|
+
errorCb(this.GetErrorMessage(StatusCodes.INTERNAL_SERVER_ERROR, `SessionManager:GetSession(): Could not process session. Error: [${error}]`, error));
|
|
211
|
+
return null;
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
}
|
|
1651
216
|
export {
|
|
1652
217
|
SessionManager
|
|
1653
218
|
};
|