keycloakify 10.0.0-rc.64 → 10.0.0-rc.66
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/account/KcContext/KcContext.d.ts +1 -0
- package/account/KcContext/KcContext.js.map +1 -1
- package/account/KcContext/kcContextMocks.js +2 -1
- package/account/KcContext/kcContextMocks.js.map +1 -1
- package/account/pages/Totp.js +2 -7
- package/account/pages/Totp.js.map +1 -1
- package/bin/193.index.js +0 -501
- package/bin/246.index.js +371 -75118
- package/bin/363.index.js +36 -665
- package/bin/453.index.js +603 -23
- package/bin/{890.index.js → 456.index.js} +1831 -3
- package/bin/490.index.js +75195 -0
- package/bin/526.index.js +311 -166
- package/bin/538.index.js +1 -509
- package/bin/{240.index.js → 751.index.js} +306 -322
- package/bin/772.index.js +1 -1
- package/bin/837.index.js +787 -0
- package/bin/932.index.js +1 -574
- package/bin/97.index.js +594 -14
- package/bin/main.js +8 -8
- package/bin/shared/buildContext.d.ts +16 -0
- package/bin/shared/constants.d.ts +1 -1
- package/bin/shared/constants.js +1 -1
- package/bin/shared/constants.js.map +1 -1
- package/package.json +5 -9
- package/src/account/KcContext/KcContext.ts +1 -0
- package/src/account/KcContext/kcContextMocks.ts +2 -1
- package/src/account/pages/Totp.tsx +1 -7
- package/src/bin/add-story.ts +1 -6
- package/src/bin/eject-page.ts +7 -8
- package/src/bin/initialize-email-theme.ts +1 -6
- package/src/bin/keycloakify/buildJars/buildJars.ts +23 -49
- package/src/bin/keycloakify/generateFtl/kcContextDeclarationTemplate.ftl +8 -6
- package/src/bin/keycloakify/generateResources/generateResourcesForMainTheme.ts +15 -20
- package/src/bin/keycloakify/keycloakify.ts +6 -8
- package/src/bin/shared/buildContext.ts +434 -42
- package/src/bin/shared/constants.ts +2 -1
- package/src/bin/shared/downloadKeycloakDefaultTheme.ts +135 -108
- package/src/bin/shared/generateKcGenTs.ts +2 -6
- package/src/bin/start-keycloak/keycloakifyBuild.ts +4 -4
- package/src/bin/start-keycloak/start-keycloak.ts +40 -83
- package/src/vite-plugin/vite-plugin.ts +5 -4
- package/vite-plugin/index.js +410 -187
- package/bin/480.index.js +0 -466
- package/bin/818.index.js +0 -1802
- package/bin/827.index.js +0 -1094
- package/src/bin/shared/getImplementedThemeTypes.ts +0 -23
- package/src/bin/shared/getJarFileBasename.ts +0 -11
- package/src/bin/shared/getThemeSrcDirPath.ts +0 -62
@@ -1,11 +1,1807 @@
|
|
1
|
+
exports.id = 456;
|
2
|
+
exports.ids = [456];
|
3
|
+
exports.modules = {
|
4
|
+
|
5
|
+
/***/ 52068:
|
6
|
+
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
7
|
+
|
8
|
+
"use strict";
|
9
|
+
/* module decorator */ module = __webpack_require__.nmd(module);
|
10
|
+
|
11
|
+
|
12
|
+
const wrapAnsi16 = (fn, offset) => (...args) => {
|
13
|
+
const code = fn(...args);
|
14
|
+
return `\u001B[${code + offset}m`;
|
15
|
+
};
|
16
|
+
|
17
|
+
const wrapAnsi256 = (fn, offset) => (...args) => {
|
18
|
+
const code = fn(...args);
|
19
|
+
return `\u001B[${38 + offset};5;${code}m`;
|
20
|
+
};
|
21
|
+
|
22
|
+
const wrapAnsi16m = (fn, offset) => (...args) => {
|
23
|
+
const rgb = fn(...args);
|
24
|
+
return `\u001B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`;
|
25
|
+
};
|
26
|
+
|
27
|
+
const ansi2ansi = n => n;
|
28
|
+
const rgb2rgb = (r, g, b) => [r, g, b];
|
29
|
+
|
30
|
+
const setLazyProperty = (object, property, get) => {
|
31
|
+
Object.defineProperty(object, property, {
|
32
|
+
get: () => {
|
33
|
+
const value = get();
|
34
|
+
|
35
|
+
Object.defineProperty(object, property, {
|
36
|
+
value,
|
37
|
+
enumerable: true,
|
38
|
+
configurable: true
|
39
|
+
});
|
40
|
+
|
41
|
+
return value;
|
42
|
+
},
|
43
|
+
enumerable: true,
|
44
|
+
configurable: true
|
45
|
+
});
|
46
|
+
};
|
47
|
+
|
48
|
+
/** @type {typeof import('color-convert')} */
|
49
|
+
let colorConvert;
|
50
|
+
const makeDynamicStyles = (wrap, targetSpace, identity, isBackground) => {
|
51
|
+
if (colorConvert === undefined) {
|
52
|
+
colorConvert = __webpack_require__(86931);
|
53
|
+
}
|
54
|
+
|
55
|
+
const offset = isBackground ? 10 : 0;
|
56
|
+
const styles = {};
|
57
|
+
|
58
|
+
for (const [sourceSpace, suite] of Object.entries(colorConvert)) {
|
59
|
+
const name = sourceSpace === 'ansi16' ? 'ansi' : sourceSpace;
|
60
|
+
if (sourceSpace === targetSpace) {
|
61
|
+
styles[name] = wrap(identity, offset);
|
62
|
+
} else if (typeof suite === 'object') {
|
63
|
+
styles[name] = wrap(suite[targetSpace], offset);
|
64
|
+
}
|
65
|
+
}
|
66
|
+
|
67
|
+
return styles;
|
68
|
+
};
|
69
|
+
|
70
|
+
function assembleStyles() {
|
71
|
+
const codes = new Map();
|
72
|
+
const styles = {
|
73
|
+
modifier: {
|
74
|
+
reset: [0, 0],
|
75
|
+
// 21 isn't widely supported and 22 does the same thing
|
76
|
+
bold: [1, 22],
|
77
|
+
dim: [2, 22],
|
78
|
+
italic: [3, 23],
|
79
|
+
underline: [4, 24],
|
80
|
+
inverse: [7, 27],
|
81
|
+
hidden: [8, 28],
|
82
|
+
strikethrough: [9, 29]
|
83
|
+
},
|
84
|
+
color: {
|
85
|
+
black: [30, 39],
|
86
|
+
red: [31, 39],
|
87
|
+
green: [32, 39],
|
88
|
+
yellow: [33, 39],
|
89
|
+
blue: [34, 39],
|
90
|
+
magenta: [35, 39],
|
91
|
+
cyan: [36, 39],
|
92
|
+
white: [37, 39],
|
93
|
+
|
94
|
+
// Bright color
|
95
|
+
blackBright: [90, 39],
|
96
|
+
redBright: [91, 39],
|
97
|
+
greenBright: [92, 39],
|
98
|
+
yellowBright: [93, 39],
|
99
|
+
blueBright: [94, 39],
|
100
|
+
magentaBright: [95, 39],
|
101
|
+
cyanBright: [96, 39],
|
102
|
+
whiteBright: [97, 39]
|
103
|
+
},
|
104
|
+
bgColor: {
|
105
|
+
bgBlack: [40, 49],
|
106
|
+
bgRed: [41, 49],
|
107
|
+
bgGreen: [42, 49],
|
108
|
+
bgYellow: [43, 49],
|
109
|
+
bgBlue: [44, 49],
|
110
|
+
bgMagenta: [45, 49],
|
111
|
+
bgCyan: [46, 49],
|
112
|
+
bgWhite: [47, 49],
|
113
|
+
|
114
|
+
// Bright color
|
115
|
+
bgBlackBright: [100, 49],
|
116
|
+
bgRedBright: [101, 49],
|
117
|
+
bgGreenBright: [102, 49],
|
118
|
+
bgYellowBright: [103, 49],
|
119
|
+
bgBlueBright: [104, 49],
|
120
|
+
bgMagentaBright: [105, 49],
|
121
|
+
bgCyanBright: [106, 49],
|
122
|
+
bgWhiteBright: [107, 49]
|
123
|
+
}
|
124
|
+
};
|
125
|
+
|
126
|
+
// Alias bright black as gray (and grey)
|
127
|
+
styles.color.gray = styles.color.blackBright;
|
128
|
+
styles.bgColor.bgGray = styles.bgColor.bgBlackBright;
|
129
|
+
styles.color.grey = styles.color.blackBright;
|
130
|
+
styles.bgColor.bgGrey = styles.bgColor.bgBlackBright;
|
131
|
+
|
132
|
+
for (const [groupName, group] of Object.entries(styles)) {
|
133
|
+
for (const [styleName, style] of Object.entries(group)) {
|
134
|
+
styles[styleName] = {
|
135
|
+
open: `\u001B[${style[0]}m`,
|
136
|
+
close: `\u001B[${style[1]}m`
|
137
|
+
};
|
138
|
+
|
139
|
+
group[styleName] = styles[styleName];
|
140
|
+
|
141
|
+
codes.set(style[0], style[1]);
|
142
|
+
}
|
143
|
+
|
144
|
+
Object.defineProperty(styles, groupName, {
|
145
|
+
value: group,
|
146
|
+
enumerable: false
|
147
|
+
});
|
148
|
+
}
|
149
|
+
|
150
|
+
Object.defineProperty(styles, 'codes', {
|
151
|
+
value: codes,
|
152
|
+
enumerable: false
|
153
|
+
});
|
154
|
+
|
155
|
+
styles.color.close = '\u001B[39m';
|
156
|
+
styles.bgColor.close = '\u001B[49m';
|
157
|
+
|
158
|
+
setLazyProperty(styles.color, 'ansi', () => makeDynamicStyles(wrapAnsi16, 'ansi16', ansi2ansi, false));
|
159
|
+
setLazyProperty(styles.color, 'ansi256', () => makeDynamicStyles(wrapAnsi256, 'ansi256', ansi2ansi, false));
|
160
|
+
setLazyProperty(styles.color, 'ansi16m', () => makeDynamicStyles(wrapAnsi16m, 'rgb', rgb2rgb, false));
|
161
|
+
setLazyProperty(styles.bgColor, 'ansi', () => makeDynamicStyles(wrapAnsi16, 'ansi16', ansi2ansi, true));
|
162
|
+
setLazyProperty(styles.bgColor, 'ansi256', () => makeDynamicStyles(wrapAnsi256, 'ansi256', ansi2ansi, true));
|
163
|
+
setLazyProperty(styles.bgColor, 'ansi16m', () => makeDynamicStyles(wrapAnsi16m, 'rgb', rgb2rgb, true));
|
164
|
+
|
165
|
+
return styles;
|
166
|
+
}
|
167
|
+
|
168
|
+
// Make the export immutable
|
169
|
+
Object.defineProperty(module, 'exports', {
|
170
|
+
enumerable: true,
|
171
|
+
get: assembleStyles
|
172
|
+
});
|
173
|
+
|
174
|
+
|
175
|
+
/***/ }),
|
176
|
+
|
177
|
+
/***/ 78818:
|
178
|
+
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
179
|
+
|
180
|
+
"use strict";
|
181
|
+
|
182
|
+
const ansiStyles = __webpack_require__(52068);
|
183
|
+
const {stdout: stdoutColor, stderr: stderrColor} = __webpack_require__(59318);
|
184
|
+
const {
|
185
|
+
stringReplaceAll,
|
186
|
+
stringEncaseCRLFWithFirstIndex
|
187
|
+
} = __webpack_require__(82415);
|
188
|
+
|
189
|
+
const {isArray} = Array;
|
190
|
+
|
191
|
+
// `supportsColor.level` → `ansiStyles.color[name]` mapping
|
192
|
+
const levelMapping = [
|
193
|
+
'ansi',
|
194
|
+
'ansi',
|
195
|
+
'ansi256',
|
196
|
+
'ansi16m'
|
197
|
+
];
|
198
|
+
|
199
|
+
const styles = Object.create(null);
|
200
|
+
|
201
|
+
const applyOptions = (object, options = {}) => {
|
202
|
+
if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
|
203
|
+
throw new Error('The `level` option should be an integer from 0 to 3');
|
204
|
+
}
|
205
|
+
|
206
|
+
// Detect level if not set manually
|
207
|
+
const colorLevel = stdoutColor ? stdoutColor.level : 0;
|
208
|
+
object.level = options.level === undefined ? colorLevel : options.level;
|
209
|
+
};
|
210
|
+
|
211
|
+
class ChalkClass {
|
212
|
+
constructor(options) {
|
213
|
+
// eslint-disable-next-line no-constructor-return
|
214
|
+
return chalkFactory(options);
|
215
|
+
}
|
216
|
+
}
|
217
|
+
|
218
|
+
const chalkFactory = options => {
|
219
|
+
const chalk = {};
|
220
|
+
applyOptions(chalk, options);
|
221
|
+
|
222
|
+
chalk.template = (...arguments_) => chalkTag(chalk.template, ...arguments_);
|
223
|
+
|
224
|
+
Object.setPrototypeOf(chalk, Chalk.prototype);
|
225
|
+
Object.setPrototypeOf(chalk.template, chalk);
|
226
|
+
|
227
|
+
chalk.template.constructor = () => {
|
228
|
+
throw new Error('`chalk.constructor()` is deprecated. Use `new chalk.Instance()` instead.');
|
229
|
+
};
|
230
|
+
|
231
|
+
chalk.template.Instance = ChalkClass;
|
232
|
+
|
233
|
+
return chalk.template;
|
234
|
+
};
|
235
|
+
|
236
|
+
function Chalk(options) {
|
237
|
+
return chalkFactory(options);
|
238
|
+
}
|
239
|
+
|
240
|
+
for (const [styleName, style] of Object.entries(ansiStyles)) {
|
241
|
+
styles[styleName] = {
|
242
|
+
get() {
|
243
|
+
const builder = createBuilder(this, createStyler(style.open, style.close, this._styler), this._isEmpty);
|
244
|
+
Object.defineProperty(this, styleName, {value: builder});
|
245
|
+
return builder;
|
246
|
+
}
|
247
|
+
};
|
248
|
+
}
|
249
|
+
|
250
|
+
styles.visible = {
|
251
|
+
get() {
|
252
|
+
const builder = createBuilder(this, this._styler, true);
|
253
|
+
Object.defineProperty(this, 'visible', {value: builder});
|
254
|
+
return builder;
|
255
|
+
}
|
256
|
+
};
|
257
|
+
|
258
|
+
const usedModels = ['rgb', 'hex', 'keyword', 'hsl', 'hsv', 'hwb', 'ansi', 'ansi256'];
|
259
|
+
|
260
|
+
for (const model of usedModels) {
|
261
|
+
styles[model] = {
|
262
|
+
get() {
|
263
|
+
const {level} = this;
|
264
|
+
return function (...arguments_) {
|
265
|
+
const styler = createStyler(ansiStyles.color[levelMapping[level]][model](...arguments_), ansiStyles.color.close, this._styler);
|
266
|
+
return createBuilder(this, styler, this._isEmpty);
|
267
|
+
};
|
268
|
+
}
|
269
|
+
};
|
270
|
+
}
|
271
|
+
|
272
|
+
for (const model of usedModels) {
|
273
|
+
const bgModel = 'bg' + model[0].toUpperCase() + model.slice(1);
|
274
|
+
styles[bgModel] = {
|
275
|
+
get() {
|
276
|
+
const {level} = this;
|
277
|
+
return function (...arguments_) {
|
278
|
+
const styler = createStyler(ansiStyles.bgColor[levelMapping[level]][model](...arguments_), ansiStyles.bgColor.close, this._styler);
|
279
|
+
return createBuilder(this, styler, this._isEmpty);
|
280
|
+
};
|
281
|
+
}
|
282
|
+
};
|
283
|
+
}
|
284
|
+
|
285
|
+
const proto = Object.defineProperties(() => {}, {
|
286
|
+
...styles,
|
287
|
+
level: {
|
288
|
+
enumerable: true,
|
289
|
+
get() {
|
290
|
+
return this._generator.level;
|
291
|
+
},
|
292
|
+
set(level) {
|
293
|
+
this._generator.level = level;
|
294
|
+
}
|
295
|
+
}
|
296
|
+
});
|
297
|
+
|
298
|
+
const createStyler = (open, close, parent) => {
|
299
|
+
let openAll;
|
300
|
+
let closeAll;
|
301
|
+
if (parent === undefined) {
|
302
|
+
openAll = open;
|
303
|
+
closeAll = close;
|
304
|
+
} else {
|
305
|
+
openAll = parent.openAll + open;
|
306
|
+
closeAll = close + parent.closeAll;
|
307
|
+
}
|
308
|
+
|
309
|
+
return {
|
310
|
+
open,
|
311
|
+
close,
|
312
|
+
openAll,
|
313
|
+
closeAll,
|
314
|
+
parent
|
315
|
+
};
|
316
|
+
};
|
317
|
+
|
318
|
+
const createBuilder = (self, _styler, _isEmpty) => {
|
319
|
+
const builder = (...arguments_) => {
|
320
|
+
if (isArray(arguments_[0]) && isArray(arguments_[0].raw)) {
|
321
|
+
// Called as a template literal, for example: chalk.red`2 + 3 = {bold ${2+3}}`
|
322
|
+
return applyStyle(builder, chalkTag(builder, ...arguments_));
|
323
|
+
}
|
324
|
+
|
325
|
+
// Single argument is hot path, implicit coercion is faster than anything
|
326
|
+
// eslint-disable-next-line no-implicit-coercion
|
327
|
+
return applyStyle(builder, (arguments_.length === 1) ? ('' + arguments_[0]) : arguments_.join(' '));
|
328
|
+
};
|
329
|
+
|
330
|
+
// We alter the prototype because we must return a function, but there is
|
331
|
+
// no way to create a function with a different prototype
|
332
|
+
Object.setPrototypeOf(builder, proto);
|
333
|
+
|
334
|
+
builder._generator = self;
|
335
|
+
builder._styler = _styler;
|
336
|
+
builder._isEmpty = _isEmpty;
|
337
|
+
|
338
|
+
return builder;
|
339
|
+
};
|
340
|
+
|
341
|
+
const applyStyle = (self, string) => {
|
342
|
+
if (self.level <= 0 || !string) {
|
343
|
+
return self._isEmpty ? '' : string;
|
344
|
+
}
|
345
|
+
|
346
|
+
let styler = self._styler;
|
347
|
+
|
348
|
+
if (styler === undefined) {
|
349
|
+
return string;
|
350
|
+
}
|
351
|
+
|
352
|
+
const {openAll, closeAll} = styler;
|
353
|
+
if (string.indexOf('\u001B') !== -1) {
|
354
|
+
while (styler !== undefined) {
|
355
|
+
// Replace any instances already present with a re-opening code
|
356
|
+
// otherwise only the part of the string until said closing code
|
357
|
+
// will be colored, and the rest will simply be 'plain'.
|
358
|
+
string = stringReplaceAll(string, styler.close, styler.open);
|
359
|
+
|
360
|
+
styler = styler.parent;
|
361
|
+
}
|
362
|
+
}
|
363
|
+
|
364
|
+
// We can move both next actions out of loop, because remaining actions in loop won't have
|
365
|
+
// any/visible effect on parts we add here. Close the styling before a linebreak and reopen
|
366
|
+
// after next line to fix a bleed issue on macOS: https://github.com/chalk/chalk/pull/92
|
367
|
+
const lfIndex = string.indexOf('\n');
|
368
|
+
if (lfIndex !== -1) {
|
369
|
+
string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
|
370
|
+
}
|
371
|
+
|
372
|
+
return openAll + string + closeAll;
|
373
|
+
};
|
374
|
+
|
375
|
+
let template;
|
376
|
+
const chalkTag = (chalk, ...strings) => {
|
377
|
+
const [firstString] = strings;
|
378
|
+
|
379
|
+
if (!isArray(firstString) || !isArray(firstString.raw)) {
|
380
|
+
// If chalk() was called by itself or with a string,
|
381
|
+
// return the string itself as a string.
|
382
|
+
return strings.join(' ');
|
383
|
+
}
|
384
|
+
|
385
|
+
const arguments_ = strings.slice(1);
|
386
|
+
const parts = [firstString.raw[0]];
|
387
|
+
|
388
|
+
for (let i = 1; i < firstString.length; i++) {
|
389
|
+
parts.push(
|
390
|
+
String(arguments_[i - 1]).replace(/[{}\\]/g, '\\$&'),
|
391
|
+
String(firstString.raw[i])
|
392
|
+
);
|
393
|
+
}
|
394
|
+
|
395
|
+
if (template === undefined) {
|
396
|
+
template = __webpack_require__(20500);
|
397
|
+
}
|
398
|
+
|
399
|
+
return template(chalk, parts.join(''));
|
400
|
+
};
|
401
|
+
|
402
|
+
Object.defineProperties(Chalk.prototype, styles);
|
403
|
+
|
404
|
+
const chalk = Chalk(); // eslint-disable-line new-cap
|
405
|
+
chalk.supportsColor = stdoutColor;
|
406
|
+
chalk.stderr = Chalk({level: stderrColor ? stderrColor.level : 0}); // eslint-disable-line new-cap
|
407
|
+
chalk.stderr.supportsColor = stderrColor;
|
408
|
+
|
409
|
+
module.exports = chalk;
|
410
|
+
|
411
|
+
|
412
|
+
/***/ }),
|
413
|
+
|
414
|
+
/***/ 20500:
|
415
|
+
/***/ ((module) => {
|
416
|
+
|
417
|
+
"use strict";
|
418
|
+
|
419
|
+
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;
|
420
|
+
const STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
|
421
|
+
const STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
|
422
|
+
const ESCAPE_REGEX = /\\(u(?:[a-f\d]{4}|{[a-f\d]{1,6}})|x[a-f\d]{2}|.)|([^\\])/gi;
|
423
|
+
|
424
|
+
const ESCAPES = new Map([
|
425
|
+
['n', '\n'],
|
426
|
+
['r', '\r'],
|
427
|
+
['t', '\t'],
|
428
|
+
['b', '\b'],
|
429
|
+
['f', '\f'],
|
430
|
+
['v', '\v'],
|
431
|
+
['0', '\0'],
|
432
|
+
['\\', '\\'],
|
433
|
+
['e', '\u001B'],
|
434
|
+
['a', '\u0007']
|
435
|
+
]);
|
436
|
+
|
437
|
+
function unescape(c) {
|
438
|
+
const u = c[0] === 'u';
|
439
|
+
const bracket = c[1] === '{';
|
440
|
+
|
441
|
+
if ((u && !bracket && c.length === 5) || (c[0] === 'x' && c.length === 3)) {
|
442
|
+
return String.fromCharCode(parseInt(c.slice(1), 16));
|
443
|
+
}
|
444
|
+
|
445
|
+
if (u && bracket) {
|
446
|
+
return String.fromCodePoint(parseInt(c.slice(2, -1), 16));
|
447
|
+
}
|
448
|
+
|
449
|
+
return ESCAPES.get(c) || c;
|
450
|
+
}
|
451
|
+
|
452
|
+
function parseArguments(name, arguments_) {
|
453
|
+
const results = [];
|
454
|
+
const chunks = arguments_.trim().split(/\s*,\s*/g);
|
455
|
+
let matches;
|
456
|
+
|
457
|
+
for (const chunk of chunks) {
|
458
|
+
const number = Number(chunk);
|
459
|
+
if (!Number.isNaN(number)) {
|
460
|
+
results.push(number);
|
461
|
+
} else if ((matches = chunk.match(STRING_REGEX))) {
|
462
|
+
results.push(matches[2].replace(ESCAPE_REGEX, (m, escape, character) => escape ? unescape(escape) : character));
|
463
|
+
} else {
|
464
|
+
throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`);
|
465
|
+
}
|
466
|
+
}
|
467
|
+
|
468
|
+
return results;
|
469
|
+
}
|
470
|
+
|
471
|
+
function parseStyle(style) {
|
472
|
+
STYLE_REGEX.lastIndex = 0;
|
473
|
+
|
474
|
+
const results = [];
|
475
|
+
let matches;
|
476
|
+
|
477
|
+
while ((matches = STYLE_REGEX.exec(style)) !== null) {
|
478
|
+
const name = matches[1];
|
479
|
+
|
480
|
+
if (matches[2]) {
|
481
|
+
const args = parseArguments(name, matches[2]);
|
482
|
+
results.push([name].concat(args));
|
483
|
+
} else {
|
484
|
+
results.push([name]);
|
485
|
+
}
|
486
|
+
}
|
487
|
+
|
488
|
+
return results;
|
489
|
+
}
|
490
|
+
|
491
|
+
function buildStyle(chalk, styles) {
|
492
|
+
const enabled = {};
|
493
|
+
|
494
|
+
for (const layer of styles) {
|
495
|
+
for (const style of layer.styles) {
|
496
|
+
enabled[style[0]] = layer.inverse ? null : style.slice(1);
|
497
|
+
}
|
498
|
+
}
|
499
|
+
|
500
|
+
let current = chalk;
|
501
|
+
for (const [styleName, styles] of Object.entries(enabled)) {
|
502
|
+
if (!Array.isArray(styles)) {
|
503
|
+
continue;
|
504
|
+
}
|
505
|
+
|
506
|
+
if (!(styleName in current)) {
|
507
|
+
throw new Error(`Unknown Chalk style: ${styleName}`);
|
508
|
+
}
|
509
|
+
|
510
|
+
current = styles.length > 0 ? current[styleName](...styles) : current[styleName];
|
511
|
+
}
|
512
|
+
|
513
|
+
return current;
|
514
|
+
}
|
515
|
+
|
516
|
+
module.exports = (chalk, temporary) => {
|
517
|
+
const styles = [];
|
518
|
+
const chunks = [];
|
519
|
+
let chunk = [];
|
520
|
+
|
521
|
+
// eslint-disable-next-line max-params
|
522
|
+
temporary.replace(TEMPLATE_REGEX, (m, escapeCharacter, inverse, style, close, character) => {
|
523
|
+
if (escapeCharacter) {
|
524
|
+
chunk.push(unescape(escapeCharacter));
|
525
|
+
} else if (style) {
|
526
|
+
const string = chunk.join('');
|
527
|
+
chunk = [];
|
528
|
+
chunks.push(styles.length === 0 ? string : buildStyle(chalk, styles)(string));
|
529
|
+
styles.push({inverse, styles: parseStyle(style)});
|
530
|
+
} else if (close) {
|
531
|
+
if (styles.length === 0) {
|
532
|
+
throw new Error('Found extraneous } in Chalk template literal');
|
533
|
+
}
|
534
|
+
|
535
|
+
chunks.push(buildStyle(chalk, styles)(chunk.join('')));
|
536
|
+
chunk = [];
|
537
|
+
styles.pop();
|
538
|
+
} else {
|
539
|
+
chunk.push(character);
|
540
|
+
}
|
541
|
+
});
|
542
|
+
|
543
|
+
chunks.push(chunk.join(''));
|
544
|
+
|
545
|
+
if (styles.length > 0) {
|
546
|
+
const errMessage = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? '' : 's'} (\`}\`)`;
|
547
|
+
throw new Error(errMessage);
|
548
|
+
}
|
549
|
+
|
550
|
+
return chunks.join('');
|
551
|
+
};
|
552
|
+
|
553
|
+
|
554
|
+
/***/ }),
|
555
|
+
|
556
|
+
/***/ 82415:
|
557
|
+
/***/ ((module) => {
|
558
|
+
|
559
|
+
"use strict";
|
560
|
+
|
561
|
+
|
562
|
+
const stringReplaceAll = (string, substring, replacer) => {
|
563
|
+
let index = string.indexOf(substring);
|
564
|
+
if (index === -1) {
|
565
|
+
return string;
|
566
|
+
}
|
567
|
+
|
568
|
+
const substringLength = substring.length;
|
569
|
+
let endIndex = 0;
|
570
|
+
let returnValue = '';
|
571
|
+
do {
|
572
|
+
returnValue += string.substr(endIndex, index - endIndex) + substring + replacer;
|
573
|
+
endIndex = index + substringLength;
|
574
|
+
index = string.indexOf(substring, endIndex);
|
575
|
+
} while (index !== -1);
|
576
|
+
|
577
|
+
returnValue += string.substr(endIndex);
|
578
|
+
return returnValue;
|
579
|
+
};
|
580
|
+
|
581
|
+
const stringEncaseCRLFWithFirstIndex = (string, prefix, postfix, index) => {
|
582
|
+
let endIndex = 0;
|
583
|
+
let returnValue = '';
|
584
|
+
do {
|
585
|
+
const gotCR = string[index - 1] === '\r';
|
586
|
+
returnValue += string.substr(endIndex, (gotCR ? index - 1 : index) - endIndex) + prefix + (gotCR ? '\r\n' : '\n') + postfix;
|
587
|
+
endIndex = index + 1;
|
588
|
+
index = string.indexOf('\n', endIndex);
|
589
|
+
} while (index !== -1);
|
590
|
+
|
591
|
+
returnValue += string.substr(endIndex);
|
592
|
+
return returnValue;
|
593
|
+
};
|
594
|
+
|
595
|
+
module.exports = {
|
596
|
+
stringReplaceAll,
|
597
|
+
stringEncaseCRLFWithFirstIndex
|
598
|
+
};
|
599
|
+
|
600
|
+
|
601
|
+
/***/ }),
|
602
|
+
|
603
|
+
/***/ 97391:
|
604
|
+
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
605
|
+
|
606
|
+
/* MIT license */
|
607
|
+
/* eslint-disable no-mixed-operators */
|
608
|
+
const cssKeywords = __webpack_require__(78510);
|
609
|
+
|
610
|
+
// NOTE: conversions should only return primitive values (i.e. arrays, or
|
611
|
+
// values that give correct `typeof` results).
|
612
|
+
// do not use box values types (i.e. Number(), String(), etc.)
|
613
|
+
|
614
|
+
const reverseKeywords = {};
|
615
|
+
for (const key of Object.keys(cssKeywords)) {
|
616
|
+
reverseKeywords[cssKeywords[key]] = key;
|
617
|
+
}
|
618
|
+
|
619
|
+
const convert = {
|
620
|
+
rgb: {channels: 3, labels: 'rgb'},
|
621
|
+
hsl: {channels: 3, labels: 'hsl'},
|
622
|
+
hsv: {channels: 3, labels: 'hsv'},
|
623
|
+
hwb: {channels: 3, labels: 'hwb'},
|
624
|
+
cmyk: {channels: 4, labels: 'cmyk'},
|
625
|
+
xyz: {channels: 3, labels: 'xyz'},
|
626
|
+
lab: {channels: 3, labels: 'lab'},
|
627
|
+
lch: {channels: 3, labels: 'lch'},
|
628
|
+
hex: {channels: 1, labels: ['hex']},
|
629
|
+
keyword: {channels: 1, labels: ['keyword']},
|
630
|
+
ansi16: {channels: 1, labels: ['ansi16']},
|
631
|
+
ansi256: {channels: 1, labels: ['ansi256']},
|
632
|
+
hcg: {channels: 3, labels: ['h', 'c', 'g']},
|
633
|
+
apple: {channels: 3, labels: ['r16', 'g16', 'b16']},
|
634
|
+
gray: {channels: 1, labels: ['gray']}
|
635
|
+
};
|
636
|
+
|
637
|
+
module.exports = convert;
|
638
|
+
|
639
|
+
// Hide .channels and .labels properties
|
640
|
+
for (const model of Object.keys(convert)) {
|
641
|
+
if (!('channels' in convert[model])) {
|
642
|
+
throw new Error('missing channels property: ' + model);
|
643
|
+
}
|
644
|
+
|
645
|
+
if (!('labels' in convert[model])) {
|
646
|
+
throw new Error('missing channel labels property: ' + model);
|
647
|
+
}
|
648
|
+
|
649
|
+
if (convert[model].labels.length !== convert[model].channels) {
|
650
|
+
throw new Error('channel and label counts mismatch: ' + model);
|
651
|
+
}
|
652
|
+
|
653
|
+
const {channels, labels} = convert[model];
|
654
|
+
delete convert[model].channels;
|
655
|
+
delete convert[model].labels;
|
656
|
+
Object.defineProperty(convert[model], 'channels', {value: channels});
|
657
|
+
Object.defineProperty(convert[model], 'labels', {value: labels});
|
658
|
+
}
|
659
|
+
|
660
|
+
convert.rgb.hsl = function (rgb) {
|
661
|
+
const r = rgb[0] / 255;
|
662
|
+
const g = rgb[1] / 255;
|
663
|
+
const b = rgb[2] / 255;
|
664
|
+
const min = Math.min(r, g, b);
|
665
|
+
const max = Math.max(r, g, b);
|
666
|
+
const delta = max - min;
|
667
|
+
let h;
|
668
|
+
let s;
|
669
|
+
|
670
|
+
if (max === min) {
|
671
|
+
h = 0;
|
672
|
+
} else if (r === max) {
|
673
|
+
h = (g - b) / delta;
|
674
|
+
} else if (g === max) {
|
675
|
+
h = 2 + (b - r) / delta;
|
676
|
+
} else if (b === max) {
|
677
|
+
h = 4 + (r - g) / delta;
|
678
|
+
}
|
679
|
+
|
680
|
+
h = Math.min(h * 60, 360);
|
681
|
+
|
682
|
+
if (h < 0) {
|
683
|
+
h += 360;
|
684
|
+
}
|
685
|
+
|
686
|
+
const l = (min + max) / 2;
|
687
|
+
|
688
|
+
if (max === min) {
|
689
|
+
s = 0;
|
690
|
+
} else if (l <= 0.5) {
|
691
|
+
s = delta / (max + min);
|
692
|
+
} else {
|
693
|
+
s = delta / (2 - max - min);
|
694
|
+
}
|
695
|
+
|
696
|
+
return [h, s * 100, l * 100];
|
697
|
+
};
|
698
|
+
|
699
|
+
convert.rgb.hsv = function (rgb) {
|
700
|
+
let rdif;
|
701
|
+
let gdif;
|
702
|
+
let bdif;
|
703
|
+
let h;
|
704
|
+
let s;
|
705
|
+
|
706
|
+
const r = rgb[0] / 255;
|
707
|
+
const g = rgb[1] / 255;
|
708
|
+
const b = rgb[2] / 255;
|
709
|
+
const v = Math.max(r, g, b);
|
710
|
+
const diff = v - Math.min(r, g, b);
|
711
|
+
const diffc = function (c) {
|
712
|
+
return (v - c) / 6 / diff + 1 / 2;
|
713
|
+
};
|
714
|
+
|
715
|
+
if (diff === 0) {
|
716
|
+
h = 0;
|
717
|
+
s = 0;
|
718
|
+
} else {
|
719
|
+
s = diff / v;
|
720
|
+
rdif = diffc(r);
|
721
|
+
gdif = diffc(g);
|
722
|
+
bdif = diffc(b);
|
723
|
+
|
724
|
+
if (r === v) {
|
725
|
+
h = bdif - gdif;
|
726
|
+
} else if (g === v) {
|
727
|
+
h = (1 / 3) + rdif - bdif;
|
728
|
+
} else if (b === v) {
|
729
|
+
h = (2 / 3) + gdif - rdif;
|
730
|
+
}
|
731
|
+
|
732
|
+
if (h < 0) {
|
733
|
+
h += 1;
|
734
|
+
} else if (h > 1) {
|
735
|
+
h -= 1;
|
736
|
+
}
|
737
|
+
}
|
738
|
+
|
739
|
+
return [
|
740
|
+
h * 360,
|
741
|
+
s * 100,
|
742
|
+
v * 100
|
743
|
+
];
|
744
|
+
};
|
745
|
+
|
746
|
+
convert.rgb.hwb = function (rgb) {
|
747
|
+
const r = rgb[0];
|
748
|
+
const g = rgb[1];
|
749
|
+
let b = rgb[2];
|
750
|
+
const h = convert.rgb.hsl(rgb)[0];
|
751
|
+
const w = 1 / 255 * Math.min(r, Math.min(g, b));
|
752
|
+
|
753
|
+
b = 1 - 1 / 255 * Math.max(r, Math.max(g, b));
|
754
|
+
|
755
|
+
return [h, w * 100, b * 100];
|
756
|
+
};
|
757
|
+
|
758
|
+
convert.rgb.cmyk = function (rgb) {
|
759
|
+
const r = rgb[0] / 255;
|
760
|
+
const g = rgb[1] / 255;
|
761
|
+
const b = rgb[2] / 255;
|
762
|
+
|
763
|
+
const k = Math.min(1 - r, 1 - g, 1 - b);
|
764
|
+
const c = (1 - r - k) / (1 - k) || 0;
|
765
|
+
const m = (1 - g - k) / (1 - k) || 0;
|
766
|
+
const y = (1 - b - k) / (1 - k) || 0;
|
767
|
+
|
768
|
+
return [c * 100, m * 100, y * 100, k * 100];
|
769
|
+
};
|
770
|
+
|
771
|
+
function comparativeDistance(x, y) {
|
772
|
+
/*
|
773
|
+
See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
|
774
|
+
*/
|
775
|
+
return (
|
776
|
+
((x[0] - y[0]) ** 2) +
|
777
|
+
((x[1] - y[1]) ** 2) +
|
778
|
+
((x[2] - y[2]) ** 2)
|
779
|
+
);
|
780
|
+
}
|
781
|
+
|
782
|
+
convert.rgb.keyword = function (rgb) {
|
783
|
+
const reversed = reverseKeywords[rgb];
|
784
|
+
if (reversed) {
|
785
|
+
return reversed;
|
786
|
+
}
|
787
|
+
|
788
|
+
let currentClosestDistance = Infinity;
|
789
|
+
let currentClosestKeyword;
|
790
|
+
|
791
|
+
for (const keyword of Object.keys(cssKeywords)) {
|
792
|
+
const value = cssKeywords[keyword];
|
793
|
+
|
794
|
+
// Compute comparative distance
|
795
|
+
const distance = comparativeDistance(rgb, value);
|
796
|
+
|
797
|
+
// Check if its less, if so set as closest
|
798
|
+
if (distance < currentClosestDistance) {
|
799
|
+
currentClosestDistance = distance;
|
800
|
+
currentClosestKeyword = keyword;
|
801
|
+
}
|
802
|
+
}
|
803
|
+
|
804
|
+
return currentClosestKeyword;
|
805
|
+
};
|
806
|
+
|
807
|
+
convert.keyword.rgb = function (keyword) {
|
808
|
+
return cssKeywords[keyword];
|
809
|
+
};
|
810
|
+
|
811
|
+
convert.rgb.xyz = function (rgb) {
|
812
|
+
let r = rgb[0] / 255;
|
813
|
+
let g = rgb[1] / 255;
|
814
|
+
let b = rgb[2] / 255;
|
815
|
+
|
816
|
+
// Assume sRGB
|
817
|
+
r = r > 0.04045 ? (((r + 0.055) / 1.055) ** 2.4) : (r / 12.92);
|
818
|
+
g = g > 0.04045 ? (((g + 0.055) / 1.055) ** 2.4) : (g / 12.92);
|
819
|
+
b = b > 0.04045 ? (((b + 0.055) / 1.055) ** 2.4) : (b / 12.92);
|
820
|
+
|
821
|
+
const x = (r * 0.4124) + (g * 0.3576) + (b * 0.1805);
|
822
|
+
const y = (r * 0.2126) + (g * 0.7152) + (b * 0.0722);
|
823
|
+
const z = (r * 0.0193) + (g * 0.1192) + (b * 0.9505);
|
824
|
+
|
825
|
+
return [x * 100, y * 100, z * 100];
|
826
|
+
};
|
827
|
+
|
828
|
+
convert.rgb.lab = function (rgb) {
|
829
|
+
const xyz = convert.rgb.xyz(rgb);
|
830
|
+
let x = xyz[0];
|
831
|
+
let y = xyz[1];
|
832
|
+
let z = xyz[2];
|
833
|
+
|
834
|
+
x /= 95.047;
|
835
|
+
y /= 100;
|
836
|
+
z /= 108.883;
|
837
|
+
|
838
|
+
x = x > 0.008856 ? (x ** (1 / 3)) : (7.787 * x) + (16 / 116);
|
839
|
+
y = y > 0.008856 ? (y ** (1 / 3)) : (7.787 * y) + (16 / 116);
|
840
|
+
z = z > 0.008856 ? (z ** (1 / 3)) : (7.787 * z) + (16 / 116);
|
841
|
+
|
842
|
+
const l = (116 * y) - 16;
|
843
|
+
const a = 500 * (x - y);
|
844
|
+
const b = 200 * (y - z);
|
845
|
+
|
846
|
+
return [l, a, b];
|
847
|
+
};
|
848
|
+
|
849
|
+
convert.hsl.rgb = function (hsl) {
|
850
|
+
const h = hsl[0] / 360;
|
851
|
+
const s = hsl[1] / 100;
|
852
|
+
const l = hsl[2] / 100;
|
853
|
+
let t2;
|
854
|
+
let t3;
|
855
|
+
let val;
|
856
|
+
|
857
|
+
if (s === 0) {
|
858
|
+
val = l * 255;
|
859
|
+
return [val, val, val];
|
860
|
+
}
|
861
|
+
|
862
|
+
if (l < 0.5) {
|
863
|
+
t2 = l * (1 + s);
|
864
|
+
} else {
|
865
|
+
t2 = l + s - l * s;
|
866
|
+
}
|
867
|
+
|
868
|
+
const t1 = 2 * l - t2;
|
869
|
+
|
870
|
+
const rgb = [0, 0, 0];
|
871
|
+
for (let i = 0; i < 3; i++) {
|
872
|
+
t3 = h + 1 / 3 * -(i - 1);
|
873
|
+
if (t3 < 0) {
|
874
|
+
t3++;
|
875
|
+
}
|
876
|
+
|
877
|
+
if (t3 > 1) {
|
878
|
+
t3--;
|
879
|
+
}
|
880
|
+
|
881
|
+
if (6 * t3 < 1) {
|
882
|
+
val = t1 + (t2 - t1) * 6 * t3;
|
883
|
+
} else if (2 * t3 < 1) {
|
884
|
+
val = t2;
|
885
|
+
} else if (3 * t3 < 2) {
|
886
|
+
val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
|
887
|
+
} else {
|
888
|
+
val = t1;
|
889
|
+
}
|
890
|
+
|
891
|
+
rgb[i] = val * 255;
|
892
|
+
}
|
893
|
+
|
894
|
+
return rgb;
|
895
|
+
};
|
896
|
+
|
897
|
+
convert.hsl.hsv = function (hsl) {
|
898
|
+
const h = hsl[0];
|
899
|
+
let s = hsl[1] / 100;
|
900
|
+
let l = hsl[2] / 100;
|
901
|
+
let smin = s;
|
902
|
+
const lmin = Math.max(l, 0.01);
|
903
|
+
|
904
|
+
l *= 2;
|
905
|
+
s *= (l <= 1) ? l : 2 - l;
|
906
|
+
smin *= lmin <= 1 ? lmin : 2 - lmin;
|
907
|
+
const v = (l + s) / 2;
|
908
|
+
const sv = l === 0 ? (2 * smin) / (lmin + smin) : (2 * s) / (l + s);
|
909
|
+
|
910
|
+
return [h, sv * 100, v * 100];
|
911
|
+
};
|
912
|
+
|
913
|
+
convert.hsv.rgb = function (hsv) {
|
914
|
+
const h = hsv[0] / 60;
|
915
|
+
const s = hsv[1] / 100;
|
916
|
+
let v = hsv[2] / 100;
|
917
|
+
const hi = Math.floor(h) % 6;
|
918
|
+
|
919
|
+
const f = h - Math.floor(h);
|
920
|
+
const p = 255 * v * (1 - s);
|
921
|
+
const q = 255 * v * (1 - (s * f));
|
922
|
+
const t = 255 * v * (1 - (s * (1 - f)));
|
923
|
+
v *= 255;
|
924
|
+
|
925
|
+
switch (hi) {
|
926
|
+
case 0:
|
927
|
+
return [v, t, p];
|
928
|
+
case 1:
|
929
|
+
return [q, v, p];
|
930
|
+
case 2:
|
931
|
+
return [p, v, t];
|
932
|
+
case 3:
|
933
|
+
return [p, q, v];
|
934
|
+
case 4:
|
935
|
+
return [t, p, v];
|
936
|
+
case 5:
|
937
|
+
return [v, p, q];
|
938
|
+
}
|
939
|
+
};
|
940
|
+
|
941
|
+
convert.hsv.hsl = function (hsv) {
|
942
|
+
const h = hsv[0];
|
943
|
+
const s = hsv[1] / 100;
|
944
|
+
const v = hsv[2] / 100;
|
945
|
+
const vmin = Math.max(v, 0.01);
|
946
|
+
let sl;
|
947
|
+
let l;
|
948
|
+
|
949
|
+
l = (2 - s) * v;
|
950
|
+
const lmin = (2 - s) * vmin;
|
951
|
+
sl = s * vmin;
|
952
|
+
sl /= (lmin <= 1) ? lmin : 2 - lmin;
|
953
|
+
sl = sl || 0;
|
954
|
+
l /= 2;
|
955
|
+
|
956
|
+
return [h, sl * 100, l * 100];
|
957
|
+
};
|
958
|
+
|
959
|
+
// http://dev.w3.org/csswg/css-color/#hwb-to-rgb
|
960
|
+
convert.hwb.rgb = function (hwb) {
|
961
|
+
const h = hwb[0] / 360;
|
962
|
+
let wh = hwb[1] / 100;
|
963
|
+
let bl = hwb[2] / 100;
|
964
|
+
const ratio = wh + bl;
|
965
|
+
let f;
|
966
|
+
|
967
|
+
// Wh + bl cant be > 1
|
968
|
+
if (ratio > 1) {
|
969
|
+
wh /= ratio;
|
970
|
+
bl /= ratio;
|
971
|
+
}
|
972
|
+
|
973
|
+
const i = Math.floor(6 * h);
|
974
|
+
const v = 1 - bl;
|
975
|
+
f = 6 * h - i;
|
976
|
+
|
977
|
+
if ((i & 0x01) !== 0) {
|
978
|
+
f = 1 - f;
|
979
|
+
}
|
980
|
+
|
981
|
+
const n = wh + f * (v - wh); // Linear interpolation
|
982
|
+
|
983
|
+
let r;
|
984
|
+
let g;
|
985
|
+
let b;
|
986
|
+
/* eslint-disable max-statements-per-line,no-multi-spaces */
|
987
|
+
switch (i) {
|
988
|
+
default:
|
989
|
+
case 6:
|
990
|
+
case 0: r = v; g = n; b = wh; break;
|
991
|
+
case 1: r = n; g = v; b = wh; break;
|
992
|
+
case 2: r = wh; g = v; b = n; break;
|
993
|
+
case 3: r = wh; g = n; b = v; break;
|
994
|
+
case 4: r = n; g = wh; b = v; break;
|
995
|
+
case 5: r = v; g = wh; b = n; break;
|
996
|
+
}
|
997
|
+
/* eslint-enable max-statements-per-line,no-multi-spaces */
|
998
|
+
|
999
|
+
return [r * 255, g * 255, b * 255];
|
1000
|
+
};
|
1001
|
+
|
1002
|
+
convert.cmyk.rgb = function (cmyk) {
|
1003
|
+
const c = cmyk[0] / 100;
|
1004
|
+
const m = cmyk[1] / 100;
|
1005
|
+
const y = cmyk[2] / 100;
|
1006
|
+
const k = cmyk[3] / 100;
|
1007
|
+
|
1008
|
+
const r = 1 - Math.min(1, c * (1 - k) + k);
|
1009
|
+
const g = 1 - Math.min(1, m * (1 - k) + k);
|
1010
|
+
const b = 1 - Math.min(1, y * (1 - k) + k);
|
1011
|
+
|
1012
|
+
return [r * 255, g * 255, b * 255];
|
1013
|
+
};
|
1014
|
+
|
1015
|
+
convert.xyz.rgb = function (xyz) {
|
1016
|
+
const x = xyz[0] / 100;
|
1017
|
+
const y = xyz[1] / 100;
|
1018
|
+
const z = xyz[2] / 100;
|
1019
|
+
let r;
|
1020
|
+
let g;
|
1021
|
+
let b;
|
1022
|
+
|
1023
|
+
r = (x * 3.2406) + (y * -1.5372) + (z * -0.4986);
|
1024
|
+
g = (x * -0.9689) + (y * 1.8758) + (z * 0.0415);
|
1025
|
+
b = (x * 0.0557) + (y * -0.2040) + (z * 1.0570);
|
1026
|
+
|
1027
|
+
// Assume sRGB
|
1028
|
+
r = r > 0.0031308
|
1029
|
+
? ((1.055 * (r ** (1.0 / 2.4))) - 0.055)
|
1030
|
+
: r * 12.92;
|
1031
|
+
|
1032
|
+
g = g > 0.0031308
|
1033
|
+
? ((1.055 * (g ** (1.0 / 2.4))) - 0.055)
|
1034
|
+
: g * 12.92;
|
1035
|
+
|
1036
|
+
b = b > 0.0031308
|
1037
|
+
? ((1.055 * (b ** (1.0 / 2.4))) - 0.055)
|
1038
|
+
: b * 12.92;
|
1039
|
+
|
1040
|
+
r = Math.min(Math.max(0, r), 1);
|
1041
|
+
g = Math.min(Math.max(0, g), 1);
|
1042
|
+
b = Math.min(Math.max(0, b), 1);
|
1043
|
+
|
1044
|
+
return [r * 255, g * 255, b * 255];
|
1045
|
+
};
|
1046
|
+
|
1047
|
+
convert.xyz.lab = function (xyz) {
|
1048
|
+
let x = xyz[0];
|
1049
|
+
let y = xyz[1];
|
1050
|
+
let z = xyz[2];
|
1051
|
+
|
1052
|
+
x /= 95.047;
|
1053
|
+
y /= 100;
|
1054
|
+
z /= 108.883;
|
1055
|
+
|
1056
|
+
x = x > 0.008856 ? (x ** (1 / 3)) : (7.787 * x) + (16 / 116);
|
1057
|
+
y = y > 0.008856 ? (y ** (1 / 3)) : (7.787 * y) + (16 / 116);
|
1058
|
+
z = z > 0.008856 ? (z ** (1 / 3)) : (7.787 * z) + (16 / 116);
|
1059
|
+
|
1060
|
+
const l = (116 * y) - 16;
|
1061
|
+
const a = 500 * (x - y);
|
1062
|
+
const b = 200 * (y - z);
|
1063
|
+
|
1064
|
+
return [l, a, b];
|
1065
|
+
};
|
1066
|
+
|
1067
|
+
convert.lab.xyz = function (lab) {
|
1068
|
+
const l = lab[0];
|
1069
|
+
const a = lab[1];
|
1070
|
+
const b = lab[2];
|
1071
|
+
let x;
|
1072
|
+
let y;
|
1073
|
+
let z;
|
1074
|
+
|
1075
|
+
y = (l + 16) / 116;
|
1076
|
+
x = a / 500 + y;
|
1077
|
+
z = y - b / 200;
|
1078
|
+
|
1079
|
+
const y2 = y ** 3;
|
1080
|
+
const x2 = x ** 3;
|
1081
|
+
const z2 = z ** 3;
|
1082
|
+
y = y2 > 0.008856 ? y2 : (y - 16 / 116) / 7.787;
|
1083
|
+
x = x2 > 0.008856 ? x2 : (x - 16 / 116) / 7.787;
|
1084
|
+
z = z2 > 0.008856 ? z2 : (z - 16 / 116) / 7.787;
|
1085
|
+
|
1086
|
+
x *= 95.047;
|
1087
|
+
y *= 100;
|
1088
|
+
z *= 108.883;
|
1089
|
+
|
1090
|
+
return [x, y, z];
|
1091
|
+
};
|
1092
|
+
|
1093
|
+
convert.lab.lch = function (lab) {
|
1094
|
+
const l = lab[0];
|
1095
|
+
const a = lab[1];
|
1096
|
+
const b = lab[2];
|
1097
|
+
let h;
|
1098
|
+
|
1099
|
+
const hr = Math.atan2(b, a);
|
1100
|
+
h = hr * 360 / 2 / Math.PI;
|
1101
|
+
|
1102
|
+
if (h < 0) {
|
1103
|
+
h += 360;
|
1104
|
+
}
|
1105
|
+
|
1106
|
+
const c = Math.sqrt(a * a + b * b);
|
1107
|
+
|
1108
|
+
return [l, c, h];
|
1109
|
+
};
|
1110
|
+
|
1111
|
+
convert.lch.lab = function (lch) {
|
1112
|
+
const l = lch[0];
|
1113
|
+
const c = lch[1];
|
1114
|
+
const h = lch[2];
|
1115
|
+
|
1116
|
+
const hr = h / 360 * 2 * Math.PI;
|
1117
|
+
const a = c * Math.cos(hr);
|
1118
|
+
const b = c * Math.sin(hr);
|
1119
|
+
|
1120
|
+
return [l, a, b];
|
1121
|
+
};
|
1122
|
+
|
1123
|
+
convert.rgb.ansi16 = function (args, saturation = null) {
|
1124
|
+
const [r, g, b] = args;
|
1125
|
+
let value = saturation === null ? convert.rgb.hsv(args)[2] : saturation; // Hsv -> ansi16 optimization
|
1126
|
+
|
1127
|
+
value = Math.round(value / 50);
|
1128
|
+
|
1129
|
+
if (value === 0) {
|
1130
|
+
return 30;
|
1131
|
+
}
|
1132
|
+
|
1133
|
+
let ansi = 30
|
1134
|
+
+ ((Math.round(b / 255) << 2)
|
1135
|
+
| (Math.round(g / 255) << 1)
|
1136
|
+
| Math.round(r / 255));
|
1137
|
+
|
1138
|
+
if (value === 2) {
|
1139
|
+
ansi += 60;
|
1140
|
+
}
|
1141
|
+
|
1142
|
+
return ansi;
|
1143
|
+
};
|
1144
|
+
|
1145
|
+
convert.hsv.ansi16 = function (args) {
|
1146
|
+
// Optimization here; we already know the value and don't need to get
|
1147
|
+
// it converted for us.
|
1148
|
+
return convert.rgb.ansi16(convert.hsv.rgb(args), args[2]);
|
1149
|
+
};
|
1150
|
+
|
1151
|
+
convert.rgb.ansi256 = function (args) {
|
1152
|
+
const r = args[0];
|
1153
|
+
const g = args[1];
|
1154
|
+
const b = args[2];
|
1155
|
+
|
1156
|
+
// We use the extended greyscale palette here, with the exception of
|
1157
|
+
// black and white. normal palette only has 4 greyscale shades.
|
1158
|
+
if (r === g && g === b) {
|
1159
|
+
if (r < 8) {
|
1160
|
+
return 16;
|
1161
|
+
}
|
1162
|
+
|
1163
|
+
if (r > 248) {
|
1164
|
+
return 231;
|
1165
|
+
}
|
1166
|
+
|
1167
|
+
return Math.round(((r - 8) / 247) * 24) + 232;
|
1168
|
+
}
|
1169
|
+
|
1170
|
+
const ansi = 16
|
1171
|
+
+ (36 * Math.round(r / 255 * 5))
|
1172
|
+
+ (6 * Math.round(g / 255 * 5))
|
1173
|
+
+ Math.round(b / 255 * 5);
|
1174
|
+
|
1175
|
+
return ansi;
|
1176
|
+
};
|
1177
|
+
|
1178
|
+
convert.ansi16.rgb = function (args) {
|
1179
|
+
let color = args % 10;
|
1180
|
+
|
1181
|
+
// Handle greyscale
|
1182
|
+
if (color === 0 || color === 7) {
|
1183
|
+
if (args > 50) {
|
1184
|
+
color += 3.5;
|
1185
|
+
}
|
1186
|
+
|
1187
|
+
color = color / 10.5 * 255;
|
1188
|
+
|
1189
|
+
return [color, color, color];
|
1190
|
+
}
|
1191
|
+
|
1192
|
+
const mult = (~~(args > 50) + 1) * 0.5;
|
1193
|
+
const r = ((color & 1) * mult) * 255;
|
1194
|
+
const g = (((color >> 1) & 1) * mult) * 255;
|
1195
|
+
const b = (((color >> 2) & 1) * mult) * 255;
|
1196
|
+
|
1197
|
+
return [r, g, b];
|
1198
|
+
};
|
1199
|
+
|
1200
|
+
convert.ansi256.rgb = function (args) {
|
1201
|
+
// Handle greyscale
|
1202
|
+
if (args >= 232) {
|
1203
|
+
const c = (args - 232) * 10 + 8;
|
1204
|
+
return [c, c, c];
|
1205
|
+
}
|
1206
|
+
|
1207
|
+
args -= 16;
|
1208
|
+
|
1209
|
+
let rem;
|
1210
|
+
const r = Math.floor(args / 36) / 5 * 255;
|
1211
|
+
const g = Math.floor((rem = args % 36) / 6) / 5 * 255;
|
1212
|
+
const b = (rem % 6) / 5 * 255;
|
1213
|
+
|
1214
|
+
return [r, g, b];
|
1215
|
+
};
|
1216
|
+
|
1217
|
+
convert.rgb.hex = function (args) {
|
1218
|
+
const integer = ((Math.round(args[0]) & 0xFF) << 16)
|
1219
|
+
+ ((Math.round(args[1]) & 0xFF) << 8)
|
1220
|
+
+ (Math.round(args[2]) & 0xFF);
|
1221
|
+
|
1222
|
+
const string = integer.toString(16).toUpperCase();
|
1223
|
+
return '000000'.substring(string.length) + string;
|
1224
|
+
};
|
1225
|
+
|
1226
|
+
convert.hex.rgb = function (args) {
|
1227
|
+
const match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
|
1228
|
+
if (!match) {
|
1229
|
+
return [0, 0, 0];
|
1230
|
+
}
|
1231
|
+
|
1232
|
+
let colorString = match[0];
|
1233
|
+
|
1234
|
+
if (match[0].length === 3) {
|
1235
|
+
colorString = colorString.split('').map(char => {
|
1236
|
+
return char + char;
|
1237
|
+
}).join('');
|
1238
|
+
}
|
1239
|
+
|
1240
|
+
const integer = parseInt(colorString, 16);
|
1241
|
+
const r = (integer >> 16) & 0xFF;
|
1242
|
+
const g = (integer >> 8) & 0xFF;
|
1243
|
+
const b = integer & 0xFF;
|
1244
|
+
|
1245
|
+
return [r, g, b];
|
1246
|
+
};
|
1247
|
+
|
1248
|
+
convert.rgb.hcg = function (rgb) {
|
1249
|
+
const r = rgb[0] / 255;
|
1250
|
+
const g = rgb[1] / 255;
|
1251
|
+
const b = rgb[2] / 255;
|
1252
|
+
const max = Math.max(Math.max(r, g), b);
|
1253
|
+
const min = Math.min(Math.min(r, g), b);
|
1254
|
+
const chroma = (max - min);
|
1255
|
+
let grayscale;
|
1256
|
+
let hue;
|
1257
|
+
|
1258
|
+
if (chroma < 1) {
|
1259
|
+
grayscale = min / (1 - chroma);
|
1260
|
+
} else {
|
1261
|
+
grayscale = 0;
|
1262
|
+
}
|
1263
|
+
|
1264
|
+
if (chroma <= 0) {
|
1265
|
+
hue = 0;
|
1266
|
+
} else
|
1267
|
+
if (max === r) {
|
1268
|
+
hue = ((g - b) / chroma) % 6;
|
1269
|
+
} else
|
1270
|
+
if (max === g) {
|
1271
|
+
hue = 2 + (b - r) / chroma;
|
1272
|
+
} else {
|
1273
|
+
hue = 4 + (r - g) / chroma;
|
1274
|
+
}
|
1275
|
+
|
1276
|
+
hue /= 6;
|
1277
|
+
hue %= 1;
|
1278
|
+
|
1279
|
+
return [hue * 360, chroma * 100, grayscale * 100];
|
1280
|
+
};
|
1281
|
+
|
1282
|
+
convert.hsl.hcg = function (hsl) {
|
1283
|
+
const s = hsl[1] / 100;
|
1284
|
+
const l = hsl[2] / 100;
|
1285
|
+
|
1286
|
+
const c = l < 0.5 ? (2.0 * s * l) : (2.0 * s * (1.0 - l));
|
1287
|
+
|
1288
|
+
let f = 0;
|
1289
|
+
if (c < 1.0) {
|
1290
|
+
f = (l - 0.5 * c) / (1.0 - c);
|
1291
|
+
}
|
1292
|
+
|
1293
|
+
return [hsl[0], c * 100, f * 100];
|
1294
|
+
};
|
1295
|
+
|
1296
|
+
convert.hsv.hcg = function (hsv) {
|
1297
|
+
const s = hsv[1] / 100;
|
1298
|
+
const v = hsv[2] / 100;
|
1299
|
+
|
1300
|
+
const c = s * v;
|
1301
|
+
let f = 0;
|
1302
|
+
|
1303
|
+
if (c < 1.0) {
|
1304
|
+
f = (v - c) / (1 - c);
|
1305
|
+
}
|
1306
|
+
|
1307
|
+
return [hsv[0], c * 100, f * 100];
|
1308
|
+
};
|
1309
|
+
|
1310
|
+
convert.hcg.rgb = function (hcg) {
|
1311
|
+
const h = hcg[0] / 360;
|
1312
|
+
const c = hcg[1] / 100;
|
1313
|
+
const g = hcg[2] / 100;
|
1314
|
+
|
1315
|
+
if (c === 0.0) {
|
1316
|
+
return [g * 255, g * 255, g * 255];
|
1317
|
+
}
|
1318
|
+
|
1319
|
+
const pure = [0, 0, 0];
|
1320
|
+
const hi = (h % 1) * 6;
|
1321
|
+
const v = hi % 1;
|
1322
|
+
const w = 1 - v;
|
1323
|
+
let mg = 0;
|
1324
|
+
|
1325
|
+
/* eslint-disable max-statements-per-line */
|
1326
|
+
switch (Math.floor(hi)) {
|
1327
|
+
case 0:
|
1328
|
+
pure[0] = 1; pure[1] = v; pure[2] = 0; break;
|
1329
|
+
case 1:
|
1330
|
+
pure[0] = w; pure[1] = 1; pure[2] = 0; break;
|
1331
|
+
case 2:
|
1332
|
+
pure[0] = 0; pure[1] = 1; pure[2] = v; break;
|
1333
|
+
case 3:
|
1334
|
+
pure[0] = 0; pure[1] = w; pure[2] = 1; break;
|
1335
|
+
case 4:
|
1336
|
+
pure[0] = v; pure[1] = 0; pure[2] = 1; break;
|
1337
|
+
default:
|
1338
|
+
pure[0] = 1; pure[1] = 0; pure[2] = w;
|
1339
|
+
}
|
1340
|
+
/* eslint-enable max-statements-per-line */
|
1341
|
+
|
1342
|
+
mg = (1.0 - c) * g;
|
1343
|
+
|
1344
|
+
return [
|
1345
|
+
(c * pure[0] + mg) * 255,
|
1346
|
+
(c * pure[1] + mg) * 255,
|
1347
|
+
(c * pure[2] + mg) * 255
|
1348
|
+
];
|
1349
|
+
};
|
1350
|
+
|
1351
|
+
convert.hcg.hsv = function (hcg) {
|
1352
|
+
const c = hcg[1] / 100;
|
1353
|
+
const g = hcg[2] / 100;
|
1354
|
+
|
1355
|
+
const v = c + g * (1.0 - c);
|
1356
|
+
let f = 0;
|
1357
|
+
|
1358
|
+
if (v > 0.0) {
|
1359
|
+
f = c / v;
|
1360
|
+
}
|
1361
|
+
|
1362
|
+
return [hcg[0], f * 100, v * 100];
|
1363
|
+
};
|
1364
|
+
|
1365
|
+
convert.hcg.hsl = function (hcg) {
|
1366
|
+
const c = hcg[1] / 100;
|
1367
|
+
const g = hcg[2] / 100;
|
1368
|
+
|
1369
|
+
const l = g * (1.0 - c) + 0.5 * c;
|
1370
|
+
let s = 0;
|
1371
|
+
|
1372
|
+
if (l > 0.0 && l < 0.5) {
|
1373
|
+
s = c / (2 * l);
|
1374
|
+
} else
|
1375
|
+
if (l >= 0.5 && l < 1.0) {
|
1376
|
+
s = c / (2 * (1 - l));
|
1377
|
+
}
|
1378
|
+
|
1379
|
+
return [hcg[0], s * 100, l * 100];
|
1380
|
+
};
|
1381
|
+
|
1382
|
+
convert.hcg.hwb = function (hcg) {
|
1383
|
+
const c = hcg[1] / 100;
|
1384
|
+
const g = hcg[2] / 100;
|
1385
|
+
const v = c + g * (1.0 - c);
|
1386
|
+
return [hcg[0], (v - c) * 100, (1 - v) * 100];
|
1387
|
+
};
|
1388
|
+
|
1389
|
+
convert.hwb.hcg = function (hwb) {
|
1390
|
+
const w = hwb[1] / 100;
|
1391
|
+
const b = hwb[2] / 100;
|
1392
|
+
const v = 1 - b;
|
1393
|
+
const c = v - w;
|
1394
|
+
let g = 0;
|
1395
|
+
|
1396
|
+
if (c < 1) {
|
1397
|
+
g = (v - c) / (1 - c);
|
1398
|
+
}
|
1399
|
+
|
1400
|
+
return [hwb[0], c * 100, g * 100];
|
1401
|
+
};
|
1402
|
+
|
1403
|
+
convert.apple.rgb = function (apple) {
|
1404
|
+
return [(apple[0] / 65535) * 255, (apple[1] / 65535) * 255, (apple[2] / 65535) * 255];
|
1405
|
+
};
|
1406
|
+
|
1407
|
+
convert.rgb.apple = function (rgb) {
|
1408
|
+
return [(rgb[0] / 255) * 65535, (rgb[1] / 255) * 65535, (rgb[2] / 255) * 65535];
|
1409
|
+
};
|
1410
|
+
|
1411
|
+
convert.gray.rgb = function (args) {
|
1412
|
+
return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];
|
1413
|
+
};
|
1414
|
+
|
1415
|
+
convert.gray.hsl = function (args) {
|
1416
|
+
return [0, 0, args[0]];
|
1417
|
+
};
|
1418
|
+
|
1419
|
+
convert.gray.hsv = convert.gray.hsl;
|
1420
|
+
|
1421
|
+
convert.gray.hwb = function (gray) {
|
1422
|
+
return [0, 100, gray[0]];
|
1423
|
+
};
|
1424
|
+
|
1425
|
+
convert.gray.cmyk = function (gray) {
|
1426
|
+
return [0, 0, 0, gray[0]];
|
1427
|
+
};
|
1428
|
+
|
1429
|
+
convert.gray.lab = function (gray) {
|
1430
|
+
return [gray[0], 0, 0];
|
1431
|
+
};
|
1432
|
+
|
1433
|
+
convert.gray.hex = function (gray) {
|
1434
|
+
const val = Math.round(gray[0] / 100 * 255) & 0xFF;
|
1435
|
+
const integer = (val << 16) + (val << 8) + val;
|
1436
|
+
|
1437
|
+
const string = integer.toString(16).toUpperCase();
|
1438
|
+
return '000000'.substring(string.length) + string;
|
1439
|
+
};
|
1440
|
+
|
1441
|
+
convert.rgb.gray = function (rgb) {
|
1442
|
+
const val = (rgb[0] + rgb[1] + rgb[2]) / 3;
|
1443
|
+
return [val / 255 * 100];
|
1444
|
+
};
|
1445
|
+
|
1446
|
+
|
1447
|
+
/***/ }),
|
1448
|
+
|
1449
|
+
/***/ 86931:
|
1450
|
+
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
1451
|
+
|
1452
|
+
const conversions = __webpack_require__(97391);
|
1453
|
+
const route = __webpack_require__(30880);
|
1454
|
+
|
1455
|
+
const convert = {};
|
1456
|
+
|
1457
|
+
const models = Object.keys(conversions);
|
1458
|
+
|
1459
|
+
function wrapRaw(fn) {
|
1460
|
+
const wrappedFn = function (...args) {
|
1461
|
+
const arg0 = args[0];
|
1462
|
+
if (arg0 === undefined || arg0 === null) {
|
1463
|
+
return arg0;
|
1464
|
+
}
|
1465
|
+
|
1466
|
+
if (arg0.length > 1) {
|
1467
|
+
args = arg0;
|
1468
|
+
}
|
1469
|
+
|
1470
|
+
return fn(args);
|
1471
|
+
};
|
1472
|
+
|
1473
|
+
// Preserve .conversion property if there is one
|
1474
|
+
if ('conversion' in fn) {
|
1475
|
+
wrappedFn.conversion = fn.conversion;
|
1476
|
+
}
|
1477
|
+
|
1478
|
+
return wrappedFn;
|
1479
|
+
}
|
1480
|
+
|
1481
|
+
function wrapRounded(fn) {
|
1482
|
+
const wrappedFn = function (...args) {
|
1483
|
+
const arg0 = args[0];
|
1484
|
+
|
1485
|
+
if (arg0 === undefined || arg0 === null) {
|
1486
|
+
return arg0;
|
1487
|
+
}
|
1488
|
+
|
1489
|
+
if (arg0.length > 1) {
|
1490
|
+
args = arg0;
|
1491
|
+
}
|
1492
|
+
|
1493
|
+
const result = fn(args);
|
1494
|
+
|
1495
|
+
// We're assuming the result is an array here.
|
1496
|
+
// see notice in conversions.js; don't use box types
|
1497
|
+
// in conversion functions.
|
1498
|
+
if (typeof result === 'object') {
|
1499
|
+
for (let len = result.length, i = 0; i < len; i++) {
|
1500
|
+
result[i] = Math.round(result[i]);
|
1501
|
+
}
|
1502
|
+
}
|
1503
|
+
|
1504
|
+
return result;
|
1505
|
+
};
|
1506
|
+
|
1507
|
+
// Preserve .conversion property if there is one
|
1508
|
+
if ('conversion' in fn) {
|
1509
|
+
wrappedFn.conversion = fn.conversion;
|
1510
|
+
}
|
1511
|
+
|
1512
|
+
return wrappedFn;
|
1513
|
+
}
|
1514
|
+
|
1515
|
+
models.forEach(fromModel => {
|
1516
|
+
convert[fromModel] = {};
|
1517
|
+
|
1518
|
+
Object.defineProperty(convert[fromModel], 'channels', {value: conversions[fromModel].channels});
|
1519
|
+
Object.defineProperty(convert[fromModel], 'labels', {value: conversions[fromModel].labels});
|
1520
|
+
|
1521
|
+
const routes = route(fromModel);
|
1522
|
+
const routeModels = Object.keys(routes);
|
1523
|
+
|
1524
|
+
routeModels.forEach(toModel => {
|
1525
|
+
const fn = routes[toModel];
|
1526
|
+
|
1527
|
+
convert[fromModel][toModel] = wrapRounded(fn);
|
1528
|
+
convert[fromModel][toModel].raw = wrapRaw(fn);
|
1529
|
+
});
|
1530
|
+
});
|
1531
|
+
|
1532
|
+
module.exports = convert;
|
1533
|
+
|
1534
|
+
|
1535
|
+
/***/ }),
|
1536
|
+
|
1537
|
+
/***/ 30880:
|
1538
|
+
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
1539
|
+
|
1540
|
+
const conversions = __webpack_require__(97391);
|
1541
|
+
|
1542
|
+
/*
|
1543
|
+
This function routes a model to all other models.
|
1544
|
+
|
1545
|
+
all functions that are routed have a property `.conversion` attached
|
1546
|
+
to the returned synthetic function. This property is an array
|
1547
|
+
of strings, each with the steps in between the 'from' and 'to'
|
1548
|
+
color models (inclusive).
|
1549
|
+
|
1550
|
+
conversions that are not possible simply are not included.
|
1551
|
+
*/
|
1552
|
+
|
1553
|
+
function buildGraph() {
|
1554
|
+
const graph = {};
|
1555
|
+
// https://jsperf.com/object-keys-vs-for-in-with-closure/3
|
1556
|
+
const models = Object.keys(conversions);
|
1557
|
+
|
1558
|
+
for (let len = models.length, i = 0; i < len; i++) {
|
1559
|
+
graph[models[i]] = {
|
1560
|
+
// http://jsperf.com/1-vs-infinity
|
1561
|
+
// micro-opt, but this is simple.
|
1562
|
+
distance: -1,
|
1563
|
+
parent: null
|
1564
|
+
};
|
1565
|
+
}
|
1566
|
+
|
1567
|
+
return graph;
|
1568
|
+
}
|
1569
|
+
|
1570
|
+
// https://en.wikipedia.org/wiki/Breadth-first_search
|
1571
|
+
function deriveBFS(fromModel) {
|
1572
|
+
const graph = buildGraph();
|
1573
|
+
const queue = [fromModel]; // Unshift -> queue -> pop
|
1574
|
+
|
1575
|
+
graph[fromModel].distance = 0;
|
1576
|
+
|
1577
|
+
while (queue.length) {
|
1578
|
+
const current = queue.pop();
|
1579
|
+
const adjacents = Object.keys(conversions[current]);
|
1580
|
+
|
1581
|
+
for (let len = adjacents.length, i = 0; i < len; i++) {
|
1582
|
+
const adjacent = adjacents[i];
|
1583
|
+
const node = graph[adjacent];
|
1584
|
+
|
1585
|
+
if (node.distance === -1) {
|
1586
|
+
node.distance = graph[current].distance + 1;
|
1587
|
+
node.parent = current;
|
1588
|
+
queue.unshift(adjacent);
|
1589
|
+
}
|
1590
|
+
}
|
1591
|
+
}
|
1592
|
+
|
1593
|
+
return graph;
|
1594
|
+
}
|
1595
|
+
|
1596
|
+
function link(from, to) {
|
1597
|
+
return function (args) {
|
1598
|
+
return to(from(args));
|
1599
|
+
};
|
1600
|
+
}
|
1601
|
+
|
1602
|
+
function wrapConversion(toModel, graph) {
|
1603
|
+
const path = [graph[toModel].parent, toModel];
|
1604
|
+
let fn = conversions[graph[toModel].parent][toModel];
|
1605
|
+
|
1606
|
+
let cur = graph[toModel].parent;
|
1607
|
+
while (graph[cur].parent) {
|
1608
|
+
path.unshift(graph[cur].parent);
|
1609
|
+
fn = link(conversions[graph[cur].parent][cur], fn);
|
1610
|
+
cur = graph[cur].parent;
|
1611
|
+
}
|
1612
|
+
|
1613
|
+
fn.conversion = path;
|
1614
|
+
return fn;
|
1615
|
+
}
|
1616
|
+
|
1617
|
+
module.exports = function (fromModel) {
|
1618
|
+
const graph = deriveBFS(fromModel);
|
1619
|
+
const conversion = {};
|
1620
|
+
|
1621
|
+
const models = Object.keys(graph);
|
1622
|
+
for (let len = models.length, i = 0; i < len; i++) {
|
1623
|
+
const toModel = models[i];
|
1624
|
+
const node = graph[toModel];
|
1625
|
+
|
1626
|
+
if (node.parent === null) {
|
1627
|
+
// No possible conversion, or this node is the source model.
|
1628
|
+
continue;
|
1629
|
+
}
|
1630
|
+
|
1631
|
+
conversion[toModel] = wrapConversion(toModel, graph);
|
1632
|
+
}
|
1633
|
+
|
1634
|
+
return conversion;
|
1635
|
+
};
|
1636
|
+
|
1637
|
+
|
1638
|
+
|
1639
|
+
/***/ }),
|
1640
|
+
|
1641
|
+
/***/ 78510:
|
1642
|
+
/***/ ((module) => {
|
1643
|
+
|
1
1644
|
"use strict";
|
2
|
-
|
3
|
-
|
4
|
-
exports
|
1645
|
+
|
1646
|
+
|
1647
|
+
module.exports = {
|
1648
|
+
"aliceblue": [240, 248, 255],
|
1649
|
+
"antiquewhite": [250, 235, 215],
|
1650
|
+
"aqua": [0, 255, 255],
|
1651
|
+
"aquamarine": [127, 255, 212],
|
1652
|
+
"azure": [240, 255, 255],
|
1653
|
+
"beige": [245, 245, 220],
|
1654
|
+
"bisque": [255, 228, 196],
|
1655
|
+
"black": [0, 0, 0],
|
1656
|
+
"blanchedalmond": [255, 235, 205],
|
1657
|
+
"blue": [0, 0, 255],
|
1658
|
+
"blueviolet": [138, 43, 226],
|
1659
|
+
"brown": [165, 42, 42],
|
1660
|
+
"burlywood": [222, 184, 135],
|
1661
|
+
"cadetblue": [95, 158, 160],
|
1662
|
+
"chartreuse": [127, 255, 0],
|
1663
|
+
"chocolate": [210, 105, 30],
|
1664
|
+
"coral": [255, 127, 80],
|
1665
|
+
"cornflowerblue": [100, 149, 237],
|
1666
|
+
"cornsilk": [255, 248, 220],
|
1667
|
+
"crimson": [220, 20, 60],
|
1668
|
+
"cyan": [0, 255, 255],
|
1669
|
+
"darkblue": [0, 0, 139],
|
1670
|
+
"darkcyan": [0, 139, 139],
|
1671
|
+
"darkgoldenrod": [184, 134, 11],
|
1672
|
+
"darkgray": [169, 169, 169],
|
1673
|
+
"darkgreen": [0, 100, 0],
|
1674
|
+
"darkgrey": [169, 169, 169],
|
1675
|
+
"darkkhaki": [189, 183, 107],
|
1676
|
+
"darkmagenta": [139, 0, 139],
|
1677
|
+
"darkolivegreen": [85, 107, 47],
|
1678
|
+
"darkorange": [255, 140, 0],
|
1679
|
+
"darkorchid": [153, 50, 204],
|
1680
|
+
"darkred": [139, 0, 0],
|
1681
|
+
"darksalmon": [233, 150, 122],
|
1682
|
+
"darkseagreen": [143, 188, 143],
|
1683
|
+
"darkslateblue": [72, 61, 139],
|
1684
|
+
"darkslategray": [47, 79, 79],
|
1685
|
+
"darkslategrey": [47, 79, 79],
|
1686
|
+
"darkturquoise": [0, 206, 209],
|
1687
|
+
"darkviolet": [148, 0, 211],
|
1688
|
+
"deeppink": [255, 20, 147],
|
1689
|
+
"deepskyblue": [0, 191, 255],
|
1690
|
+
"dimgray": [105, 105, 105],
|
1691
|
+
"dimgrey": [105, 105, 105],
|
1692
|
+
"dodgerblue": [30, 144, 255],
|
1693
|
+
"firebrick": [178, 34, 34],
|
1694
|
+
"floralwhite": [255, 250, 240],
|
1695
|
+
"forestgreen": [34, 139, 34],
|
1696
|
+
"fuchsia": [255, 0, 255],
|
1697
|
+
"gainsboro": [220, 220, 220],
|
1698
|
+
"ghostwhite": [248, 248, 255],
|
1699
|
+
"gold": [255, 215, 0],
|
1700
|
+
"goldenrod": [218, 165, 32],
|
1701
|
+
"gray": [128, 128, 128],
|
1702
|
+
"green": [0, 128, 0],
|
1703
|
+
"greenyellow": [173, 255, 47],
|
1704
|
+
"grey": [128, 128, 128],
|
1705
|
+
"honeydew": [240, 255, 240],
|
1706
|
+
"hotpink": [255, 105, 180],
|
1707
|
+
"indianred": [205, 92, 92],
|
1708
|
+
"indigo": [75, 0, 130],
|
1709
|
+
"ivory": [255, 255, 240],
|
1710
|
+
"khaki": [240, 230, 140],
|
1711
|
+
"lavender": [230, 230, 250],
|
1712
|
+
"lavenderblush": [255, 240, 245],
|
1713
|
+
"lawngreen": [124, 252, 0],
|
1714
|
+
"lemonchiffon": [255, 250, 205],
|
1715
|
+
"lightblue": [173, 216, 230],
|
1716
|
+
"lightcoral": [240, 128, 128],
|
1717
|
+
"lightcyan": [224, 255, 255],
|
1718
|
+
"lightgoldenrodyellow": [250, 250, 210],
|
1719
|
+
"lightgray": [211, 211, 211],
|
1720
|
+
"lightgreen": [144, 238, 144],
|
1721
|
+
"lightgrey": [211, 211, 211],
|
1722
|
+
"lightpink": [255, 182, 193],
|
1723
|
+
"lightsalmon": [255, 160, 122],
|
1724
|
+
"lightseagreen": [32, 178, 170],
|
1725
|
+
"lightskyblue": [135, 206, 250],
|
1726
|
+
"lightslategray": [119, 136, 153],
|
1727
|
+
"lightslategrey": [119, 136, 153],
|
1728
|
+
"lightsteelblue": [176, 196, 222],
|
1729
|
+
"lightyellow": [255, 255, 224],
|
1730
|
+
"lime": [0, 255, 0],
|
1731
|
+
"limegreen": [50, 205, 50],
|
1732
|
+
"linen": [250, 240, 230],
|
1733
|
+
"magenta": [255, 0, 255],
|
1734
|
+
"maroon": [128, 0, 0],
|
1735
|
+
"mediumaquamarine": [102, 205, 170],
|
1736
|
+
"mediumblue": [0, 0, 205],
|
1737
|
+
"mediumorchid": [186, 85, 211],
|
1738
|
+
"mediumpurple": [147, 112, 219],
|
1739
|
+
"mediumseagreen": [60, 179, 113],
|
1740
|
+
"mediumslateblue": [123, 104, 238],
|
1741
|
+
"mediumspringgreen": [0, 250, 154],
|
1742
|
+
"mediumturquoise": [72, 209, 204],
|
1743
|
+
"mediumvioletred": [199, 21, 133],
|
1744
|
+
"midnightblue": [25, 25, 112],
|
1745
|
+
"mintcream": [245, 255, 250],
|
1746
|
+
"mistyrose": [255, 228, 225],
|
1747
|
+
"moccasin": [255, 228, 181],
|
1748
|
+
"navajowhite": [255, 222, 173],
|
1749
|
+
"navy": [0, 0, 128],
|
1750
|
+
"oldlace": [253, 245, 230],
|
1751
|
+
"olive": [128, 128, 0],
|
1752
|
+
"olivedrab": [107, 142, 35],
|
1753
|
+
"orange": [255, 165, 0],
|
1754
|
+
"orangered": [255, 69, 0],
|
1755
|
+
"orchid": [218, 112, 214],
|
1756
|
+
"palegoldenrod": [238, 232, 170],
|
1757
|
+
"palegreen": [152, 251, 152],
|
1758
|
+
"paleturquoise": [175, 238, 238],
|
1759
|
+
"palevioletred": [219, 112, 147],
|
1760
|
+
"papayawhip": [255, 239, 213],
|
1761
|
+
"peachpuff": [255, 218, 185],
|
1762
|
+
"peru": [205, 133, 63],
|
1763
|
+
"pink": [255, 192, 203],
|
1764
|
+
"plum": [221, 160, 221],
|
1765
|
+
"powderblue": [176, 224, 230],
|
1766
|
+
"purple": [128, 0, 128],
|
1767
|
+
"rebeccapurple": [102, 51, 153],
|
1768
|
+
"red": [255, 0, 0],
|
1769
|
+
"rosybrown": [188, 143, 143],
|
1770
|
+
"royalblue": [65, 105, 225],
|
1771
|
+
"saddlebrown": [139, 69, 19],
|
1772
|
+
"salmon": [250, 128, 114],
|
1773
|
+
"sandybrown": [244, 164, 96],
|
1774
|
+
"seagreen": [46, 139, 87],
|
1775
|
+
"seashell": [255, 245, 238],
|
1776
|
+
"sienna": [160, 82, 45],
|
1777
|
+
"silver": [192, 192, 192],
|
1778
|
+
"skyblue": [135, 206, 235],
|
1779
|
+
"slateblue": [106, 90, 205],
|
1780
|
+
"slategray": [112, 128, 144],
|
1781
|
+
"slategrey": [112, 128, 144],
|
1782
|
+
"snow": [255, 250, 250],
|
1783
|
+
"springgreen": [0, 255, 127],
|
1784
|
+
"steelblue": [70, 130, 180],
|
1785
|
+
"tan": [210, 180, 140],
|
1786
|
+
"teal": [0, 128, 128],
|
1787
|
+
"thistle": [216, 191, 216],
|
1788
|
+
"tomato": [255, 99, 71],
|
1789
|
+
"turquoise": [64, 224, 208],
|
1790
|
+
"violet": [238, 130, 238],
|
1791
|
+
"wheat": [245, 222, 179],
|
1792
|
+
"white": [255, 255, 255],
|
1793
|
+
"whitesmoke": [245, 245, 245],
|
1794
|
+
"yellow": [255, 255, 0],
|
1795
|
+
"yellowgreen": [154, 205, 50]
|
1796
|
+
};
|
1797
|
+
|
1798
|
+
|
1799
|
+
/***/ }),
|
5
1800
|
|
6
1801
|
/***/ 31621:
|
7
1802
|
/***/ ((module) => {
|
8
1803
|
|
1804
|
+
"use strict";
|
9
1805
|
|
10
1806
|
|
11
1807
|
module.exports = (flag, argv = process.argv) => {
|
@@ -21,6 +1817,7 @@ module.exports = (flag, argv = process.argv) => {
|
|
21
1817
|
/***/ 59318:
|
22
1818
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
23
1819
|
|
1820
|
+
"use strict";
|
24
1821
|
|
25
1822
|
const os = __webpack_require__(22037);
|
26
1823
|
const tty = __webpack_require__(76224);
|
@@ -163,6 +1960,7 @@ module.exports = {
|
|
163
1960
|
/***/ 50379:
|
164
1961
|
/***/ ((__unused_webpack_module, exports) => {
|
165
1962
|
|
1963
|
+
"use strict";
|
166
1964
|
|
167
1965
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
168
1966
|
exports.Reflect = void 0;
|
@@ -179,6 +1977,7 @@ exports.Reflect = Reflect;
|
|
179
1977
|
/***/ 61502:
|
180
1978
|
/***/ ((__unused_webpack_module, exports) => {
|
181
1979
|
|
1980
|
+
"use strict";
|
182
1981
|
|
183
1982
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
184
1983
|
exports.capitalize = void 0;
|
@@ -195,6 +1994,7 @@ exports.capitalize = capitalize;
|
|
195
1994
|
/***/ 41370:
|
196
1995
|
/***/ ((__unused_webpack_module, exports) => {
|
197
1996
|
|
1997
|
+
"use strict";
|
198
1998
|
|
199
1999
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
200
2000
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
@@ -220,6 +2020,7 @@ exports.exclude = exclude;
|
|
220
2020
|
/***/ 11800:
|
221
2021
|
/***/ ((__unused_webpack_module, exports) => {
|
222
2022
|
|
2023
|
+
"use strict";
|
223
2024
|
|
224
2025
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
225
2026
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
@@ -243,6 +2044,7 @@ exports.flip = flip;
|
|
243
2044
|
/***/ 1666:
|
244
2045
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
245
2046
|
|
2047
|
+
"use strict";
|
246
2048
|
|
247
2049
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
248
2050
|
if (k2 === undefined) k2 = k;
|
@@ -280,6 +2082,7 @@ __exportStar(__webpack_require__(99479), exports);
|
|
280
2082
|
/***/ 75268:
|
281
2083
|
/***/ ((__unused_webpack_module, exports) => {
|
282
2084
|
|
2085
|
+
"use strict";
|
283
2086
|
|
284
2087
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
285
2088
|
exports.isPromiseLike = void 0;
|
@@ -295,6 +2098,7 @@ exports.isPromiseLike = isPromiseLike;
|
|
295
2098
|
/***/ 1049:
|
296
2099
|
/***/ ((__unused_webpack_module, exports) => {
|
297
2100
|
|
2101
|
+
"use strict";
|
298
2102
|
|
299
2103
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
300
2104
|
/* eslint-disable @typescript-eslint/ban-types */
|
@@ -326,6 +2130,7 @@ exports.noUndefined = noUndefined;
|
|
326
2130
|
/***/ 39612:
|
327
2131
|
/***/ ((__unused_webpack_module, exports) => {
|
328
2132
|
|
2133
|
+
"use strict";
|
329
2134
|
|
330
2135
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
331
2136
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
@@ -342,6 +2147,7 @@ exports.objectEntries = objectEntries;
|
|
342
2147
|
/***/ 68634:
|
343
2148
|
/***/ ((__unused_webpack_module, exports) => {
|
344
2149
|
|
2150
|
+
"use strict";
|
345
2151
|
|
346
2152
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
347
2153
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
@@ -358,6 +2164,7 @@ exports.objectFromEntries = objectFromEntries;
|
|
358
2164
|
/***/ 66762:
|
359
2165
|
/***/ ((__unused_webpack_module, exports) => {
|
360
2166
|
|
2167
|
+
"use strict";
|
361
2168
|
|
362
2169
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
363
2170
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
@@ -371,9 +2178,28 @@ exports.objectKeys = objectKeys;
|
|
371
2178
|
|
372
2179
|
/***/ }),
|
373
2180
|
|
2181
|
+
/***/ 47986:
|
2182
|
+
/***/ ((__unused_webpack_module, exports) => {
|
2183
|
+
|
2184
|
+
"use strict";
|
2185
|
+
var __webpack_unused_export__;
|
2186
|
+
|
2187
|
+
__webpack_unused_export__ = ({ value: true });
|
2188
|
+
exports.r = void 0;
|
2189
|
+
/** @see <https://docs.tsafe.dev/main/symtostr> */
|
2190
|
+
function symToStr(wrap) {
|
2191
|
+
// @ts-expect-error: We know better
|
2192
|
+
return Object.keys(wrap)[0];
|
2193
|
+
}
|
2194
|
+
exports.r = symToStr;
|
2195
|
+
//# sourceMappingURL=symToStr.js.map
|
2196
|
+
|
2197
|
+
/***/ }),
|
2198
|
+
|
374
2199
|
/***/ 47393:
|
375
2200
|
/***/ ((__unused_webpack_module, exports) => {
|
376
2201
|
|
2202
|
+
"use strict";
|
377
2203
|
|
378
2204
|
/* eslint-disable @typescript-eslint/no-namespace */
|
379
2205
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
@@ -391,6 +2217,7 @@ exports.typeGuard = typeGuard;
|
|
391
2217
|
/***/ 99479:
|
392
2218
|
/***/ ((__unused_webpack_module, exports) => {
|
393
2219
|
|
2220
|
+
"use strict";
|
394
2221
|
|
395
2222
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
396
2223
|
exports.uncapitalize = void 0;
|
@@ -407,6 +2234,7 @@ exports.uncapitalize = uncapitalize;
|
|
407
2234
|
/***/ 52300:
|
408
2235
|
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
409
2236
|
|
2237
|
+
"use strict";
|
410
2238
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
411
2239
|
/* harmony export */ "z": () => (/* binding */ z)
|
412
2240
|
/* harmony export */ });
|