keycloakify 10.0.0-rc.62 → 10.0.0-rc.64
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/bin/193.index.js +552 -0
- package/bin/{991.index.js → 240.index.js} +40 -2
- package/bin/{952.index.js → 363.index.js} +702 -154
- package/bin/{214.index.js → 430.index.js} +2 -161
- package/bin/526.index.js +111 -93
- package/bin/538.index.js +37 -28
- package/bin/{98.index.js → 827.index.js} +39 -187
- package/bin/{941.index.js → 890.index.js} +159 -2
- package/bin/932.index.js +37 -66
- package/bin/97.index.js +1 -1
- package/bin/main.js +7 -7
- package/package.json +9 -9
- package/src/bin/add-story.ts +1 -1
- package/src/bin/keycloakify/buildJars/buildJar.ts +24 -27
- package/src/bin/keycloakify/buildJars/buildJars.ts +5 -5
- package/src/bin/keycloakify/generateResources/generateResourcesForMainTheme.ts +33 -32
- package/src/bin/keycloakify/generateResources/generateResourcesForThemeVariant.ts +22 -26
- package/src/bin/shared/getImplementedThemeTypes.ts +23 -0
- package/src/bin/shared/getThemeSrcDirPath.ts +44 -32
- package/src/bin/shared/metaInfKeycloakThemes.ts +16 -60
- package/src/bin/start-keycloak/appBuild.ts +1 -1
- package/src/bin/start-keycloak/keycloakifyBuild.ts +3 -2
- package/src/bin/start-keycloak/start-keycloak.ts +37 -71
- package/vite-plugin/index.js +1848 -30
- package/bin/190.index.js +0 -597
package/vite-plugin/index.js
CHANGED
@@ -5084,47 +5084,57 @@ var crawl = __nccwpck_require__(3036);
|
|
5084
5084
|
var external_path_ = __nccwpck_require__(1017);
|
5085
5085
|
// EXTERNAL MODULE: ./dist/bin/shared/constants.js
|
5086
5086
|
var constants = __nccwpck_require__(173);
|
5087
|
+
// EXTERNAL MODULE: ./node_modules/chalk/source/index.js
|
5088
|
+
var source = __nccwpck_require__(8818);
|
5089
|
+
var source_default = /*#__PURE__*/__nccwpck_require__.n(source);
|
5087
5090
|
;// CONCATENATED MODULE: ./dist/bin/shared/getThemeSrcDirPath.js
|
5088
5091
|
|
5089
5092
|
|
5090
5093
|
|
5091
5094
|
|
5092
5095
|
|
5093
|
-
|
5096
|
+
|
5097
|
+
let cache = undefined;
|
5094
5098
|
/** Can't catch error, if the directory isn't found, this function will just exit the process with an error message. */
|
5095
5099
|
function getThemeSrcDirPath(params) {
|
5096
5100
|
const { projectDirPath } = params;
|
5097
|
-
|
5098
|
-
|
5099
|
-
dirPath: srcDirPath,
|
5100
|
-
returnedPathsType: "relative to dirPath"
|
5101
|
-
})
|
5102
|
-
.map(fileRelativePath => {
|
5103
|
-
for (const themeSrcDirBasename of themeSrcDirBasenames) {
|
5104
|
-
const split = fileRelativePath.split(themeSrcDirBasename);
|
5105
|
-
if (split.length === 2) {
|
5106
|
-
return (0,external_path_.join)(srcDirPath, split[0] + themeSrcDirBasename);
|
5107
|
-
}
|
5108
|
-
}
|
5109
|
-
return undefined;
|
5110
|
-
})
|
5111
|
-
.filter((0,tsafe.exclude)(undefined))[0];
|
5112
|
-
if (themeSrcDirPath !== undefined) {
|
5101
|
+
if (cache !== undefined && cache.projectDirPath === projectDirPath) {
|
5102
|
+
const { themeSrcDirPath } = cache;
|
5113
5103
|
return { themeSrcDirPath };
|
5114
5104
|
}
|
5115
|
-
|
5116
|
-
|
5117
|
-
|
5105
|
+
cache = undefined;
|
5106
|
+
const { themeSrcDirPath } = (() => {
|
5107
|
+
const srcDirPath = (0,external_path_.join)(projectDirPath, "src");
|
5108
|
+
const themeSrcDirPath = (0,crawl/* crawl */.J)({
|
5109
|
+
dirPath: srcDirPath,
|
5110
|
+
returnedPathsType: "relative to dirPath"
|
5111
|
+
})
|
5112
|
+
.map(fileRelativePath => {
|
5113
|
+
for (const themeSrcDirBasename of themeSrcDirBasenames) {
|
5114
|
+
const split = fileRelativePath.split(themeSrcDirBasename);
|
5115
|
+
if (split.length === 2) {
|
5116
|
+
return (0,external_path_.join)(srcDirPath, split[0] + themeSrcDirBasename);
|
5117
|
+
}
|
5118
|
+
}
|
5119
|
+
return undefined;
|
5120
|
+
})
|
5121
|
+
.filter((0,tsafe.exclude)(undefined))[0];
|
5122
|
+
if (themeSrcDirPath !== undefined) {
|
5123
|
+
return { themeSrcDirPath };
|
5118
5124
|
}
|
5119
|
-
|
5120
|
-
|
5121
|
-
|
5122
|
-
|
5123
|
-
|
5124
|
-
|
5125
|
-
|
5126
|
-
|
5125
|
+
for (const themeType of [...constants.themeTypes, "email"]) {
|
5126
|
+
if (!external_fs_.existsSync((0,external_path_.join)(srcDirPath, themeType))) {
|
5127
|
+
continue;
|
5128
|
+
}
|
5129
|
+
return { themeSrcDirPath: srcDirPath };
|
5130
|
+
}
|
5131
|
+
console.log(source_default().red("Can't locate your theme source directory. It should be either: "));
|
5132
|
+
process.exit(-1);
|
5133
|
+
})();
|
5134
|
+
cache = { projectDirPath, themeSrcDirPath };
|
5135
|
+
return { themeSrcDirPath };
|
5127
5136
|
}
|
5137
|
+
const themeSrcDirBasenames = ["keycloak-theme", "keycloak_theme"];
|
5128
5138
|
//# sourceMappingURL=getThemeSrcDirPath.js.map
|
5129
5139
|
// EXTERNAL MODULE: external "fs/promises"
|
5130
5140
|
var promises_ = __nccwpck_require__(3292);
|
@@ -10141,6 +10151,178 @@ class AggregateError extends Error {
|
|
10141
10151
|
module.exports = AggregateError;
|
10142
10152
|
|
10143
10153
|
|
10154
|
+
/***/ }),
|
10155
|
+
|
10156
|
+
/***/ 2068:
|
10157
|
+
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
10158
|
+
|
10159
|
+
"use strict";
|
10160
|
+
/* module decorator */ module = __nccwpck_require__.nmd(module);
|
10161
|
+
|
10162
|
+
|
10163
|
+
const wrapAnsi16 = (fn, offset) => (...args) => {
|
10164
|
+
const code = fn(...args);
|
10165
|
+
return `\u001B[${code + offset}m`;
|
10166
|
+
};
|
10167
|
+
|
10168
|
+
const wrapAnsi256 = (fn, offset) => (...args) => {
|
10169
|
+
const code = fn(...args);
|
10170
|
+
return `\u001B[${38 + offset};5;${code}m`;
|
10171
|
+
};
|
10172
|
+
|
10173
|
+
const wrapAnsi16m = (fn, offset) => (...args) => {
|
10174
|
+
const rgb = fn(...args);
|
10175
|
+
return `\u001B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`;
|
10176
|
+
};
|
10177
|
+
|
10178
|
+
const ansi2ansi = n => n;
|
10179
|
+
const rgb2rgb = (r, g, b) => [r, g, b];
|
10180
|
+
|
10181
|
+
const setLazyProperty = (object, property, get) => {
|
10182
|
+
Object.defineProperty(object, property, {
|
10183
|
+
get: () => {
|
10184
|
+
const value = get();
|
10185
|
+
|
10186
|
+
Object.defineProperty(object, property, {
|
10187
|
+
value,
|
10188
|
+
enumerable: true,
|
10189
|
+
configurable: true
|
10190
|
+
});
|
10191
|
+
|
10192
|
+
return value;
|
10193
|
+
},
|
10194
|
+
enumerable: true,
|
10195
|
+
configurable: true
|
10196
|
+
});
|
10197
|
+
};
|
10198
|
+
|
10199
|
+
/** @type {typeof import('color-convert')} */
|
10200
|
+
let colorConvert;
|
10201
|
+
const makeDynamicStyles = (wrap, targetSpace, identity, isBackground) => {
|
10202
|
+
if (colorConvert === undefined) {
|
10203
|
+
colorConvert = __nccwpck_require__(6931);
|
10204
|
+
}
|
10205
|
+
|
10206
|
+
const offset = isBackground ? 10 : 0;
|
10207
|
+
const styles = {};
|
10208
|
+
|
10209
|
+
for (const [sourceSpace, suite] of Object.entries(colorConvert)) {
|
10210
|
+
const name = sourceSpace === 'ansi16' ? 'ansi' : sourceSpace;
|
10211
|
+
if (sourceSpace === targetSpace) {
|
10212
|
+
styles[name] = wrap(identity, offset);
|
10213
|
+
} else if (typeof suite === 'object') {
|
10214
|
+
styles[name] = wrap(suite[targetSpace], offset);
|
10215
|
+
}
|
10216
|
+
}
|
10217
|
+
|
10218
|
+
return styles;
|
10219
|
+
};
|
10220
|
+
|
10221
|
+
function assembleStyles() {
|
10222
|
+
const codes = new Map();
|
10223
|
+
const styles = {
|
10224
|
+
modifier: {
|
10225
|
+
reset: [0, 0],
|
10226
|
+
// 21 isn't widely supported and 22 does the same thing
|
10227
|
+
bold: [1, 22],
|
10228
|
+
dim: [2, 22],
|
10229
|
+
italic: [3, 23],
|
10230
|
+
underline: [4, 24],
|
10231
|
+
inverse: [7, 27],
|
10232
|
+
hidden: [8, 28],
|
10233
|
+
strikethrough: [9, 29]
|
10234
|
+
},
|
10235
|
+
color: {
|
10236
|
+
black: [30, 39],
|
10237
|
+
red: [31, 39],
|
10238
|
+
green: [32, 39],
|
10239
|
+
yellow: [33, 39],
|
10240
|
+
blue: [34, 39],
|
10241
|
+
magenta: [35, 39],
|
10242
|
+
cyan: [36, 39],
|
10243
|
+
white: [37, 39],
|
10244
|
+
|
10245
|
+
// Bright color
|
10246
|
+
blackBright: [90, 39],
|
10247
|
+
redBright: [91, 39],
|
10248
|
+
greenBright: [92, 39],
|
10249
|
+
yellowBright: [93, 39],
|
10250
|
+
blueBright: [94, 39],
|
10251
|
+
magentaBright: [95, 39],
|
10252
|
+
cyanBright: [96, 39],
|
10253
|
+
whiteBright: [97, 39]
|
10254
|
+
},
|
10255
|
+
bgColor: {
|
10256
|
+
bgBlack: [40, 49],
|
10257
|
+
bgRed: [41, 49],
|
10258
|
+
bgGreen: [42, 49],
|
10259
|
+
bgYellow: [43, 49],
|
10260
|
+
bgBlue: [44, 49],
|
10261
|
+
bgMagenta: [45, 49],
|
10262
|
+
bgCyan: [46, 49],
|
10263
|
+
bgWhite: [47, 49],
|
10264
|
+
|
10265
|
+
// Bright color
|
10266
|
+
bgBlackBright: [100, 49],
|
10267
|
+
bgRedBright: [101, 49],
|
10268
|
+
bgGreenBright: [102, 49],
|
10269
|
+
bgYellowBright: [103, 49],
|
10270
|
+
bgBlueBright: [104, 49],
|
10271
|
+
bgMagentaBright: [105, 49],
|
10272
|
+
bgCyanBright: [106, 49],
|
10273
|
+
bgWhiteBright: [107, 49]
|
10274
|
+
}
|
10275
|
+
};
|
10276
|
+
|
10277
|
+
// Alias bright black as gray (and grey)
|
10278
|
+
styles.color.gray = styles.color.blackBright;
|
10279
|
+
styles.bgColor.bgGray = styles.bgColor.bgBlackBright;
|
10280
|
+
styles.color.grey = styles.color.blackBright;
|
10281
|
+
styles.bgColor.bgGrey = styles.bgColor.bgBlackBright;
|
10282
|
+
|
10283
|
+
for (const [groupName, group] of Object.entries(styles)) {
|
10284
|
+
for (const [styleName, style] of Object.entries(group)) {
|
10285
|
+
styles[styleName] = {
|
10286
|
+
open: `\u001B[${style[0]}m`,
|
10287
|
+
close: `\u001B[${style[1]}m`
|
10288
|
+
};
|
10289
|
+
|
10290
|
+
group[styleName] = styles[styleName];
|
10291
|
+
|
10292
|
+
codes.set(style[0], style[1]);
|
10293
|
+
}
|
10294
|
+
|
10295
|
+
Object.defineProperty(styles, groupName, {
|
10296
|
+
value: group,
|
10297
|
+
enumerable: false
|
10298
|
+
});
|
10299
|
+
}
|
10300
|
+
|
10301
|
+
Object.defineProperty(styles, 'codes', {
|
10302
|
+
value: codes,
|
10303
|
+
enumerable: false
|
10304
|
+
});
|
10305
|
+
|
10306
|
+
styles.color.close = '\u001B[39m';
|
10307
|
+
styles.bgColor.close = '\u001B[49m';
|
10308
|
+
|
10309
|
+
setLazyProperty(styles.color, 'ansi', () => makeDynamicStyles(wrapAnsi16, 'ansi16', ansi2ansi, false));
|
10310
|
+
setLazyProperty(styles.color, 'ansi256', () => makeDynamicStyles(wrapAnsi256, 'ansi256', ansi2ansi, false));
|
10311
|
+
setLazyProperty(styles.color, 'ansi16m', () => makeDynamicStyles(wrapAnsi16m, 'rgb', rgb2rgb, false));
|
10312
|
+
setLazyProperty(styles.bgColor, 'ansi', () => makeDynamicStyles(wrapAnsi16, 'ansi16', ansi2ansi, true));
|
10313
|
+
setLazyProperty(styles.bgColor, 'ansi256', () => makeDynamicStyles(wrapAnsi256, 'ansi256', ansi2ansi, true));
|
10314
|
+
setLazyProperty(styles.bgColor, 'ansi16m', () => makeDynamicStyles(wrapAnsi16m, 'rgb', rgb2rgb, true));
|
10315
|
+
|
10316
|
+
return styles;
|
10317
|
+
}
|
10318
|
+
|
10319
|
+
// Make the export immutable
|
10320
|
+
Object.defineProperty(module, 'exports', {
|
10321
|
+
enumerable: true,
|
10322
|
+
get: assembleStyles
|
10323
|
+
});
|
10324
|
+
|
10325
|
+
|
10144
10326
|
/***/ }),
|
10145
10327
|
|
10146
10328
|
/***/ 9417:
|
@@ -19286,6 +19468,432 @@ module.exports = function (uniq) {
|
|
19286
19468
|
}
|
19287
19469
|
|
19288
19470
|
|
19471
|
+
/***/ }),
|
19472
|
+
|
19473
|
+
/***/ 8818:
|
19474
|
+
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
19475
|
+
|
19476
|
+
"use strict";
|
19477
|
+
|
19478
|
+
const ansiStyles = __nccwpck_require__(2068);
|
19479
|
+
const {stdout: stdoutColor, stderr: stderrColor} = __nccwpck_require__(9318);
|
19480
|
+
const {
|
19481
|
+
stringReplaceAll,
|
19482
|
+
stringEncaseCRLFWithFirstIndex
|
19483
|
+
} = __nccwpck_require__(2415);
|
19484
|
+
|
19485
|
+
const {isArray} = Array;
|
19486
|
+
|
19487
|
+
// `supportsColor.level` → `ansiStyles.color[name]` mapping
|
19488
|
+
const levelMapping = [
|
19489
|
+
'ansi',
|
19490
|
+
'ansi',
|
19491
|
+
'ansi256',
|
19492
|
+
'ansi16m'
|
19493
|
+
];
|
19494
|
+
|
19495
|
+
const styles = Object.create(null);
|
19496
|
+
|
19497
|
+
const applyOptions = (object, options = {}) => {
|
19498
|
+
if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
|
19499
|
+
throw new Error('The `level` option should be an integer from 0 to 3');
|
19500
|
+
}
|
19501
|
+
|
19502
|
+
// Detect level if not set manually
|
19503
|
+
const colorLevel = stdoutColor ? stdoutColor.level : 0;
|
19504
|
+
object.level = options.level === undefined ? colorLevel : options.level;
|
19505
|
+
};
|
19506
|
+
|
19507
|
+
class ChalkClass {
|
19508
|
+
constructor(options) {
|
19509
|
+
// eslint-disable-next-line no-constructor-return
|
19510
|
+
return chalkFactory(options);
|
19511
|
+
}
|
19512
|
+
}
|
19513
|
+
|
19514
|
+
const chalkFactory = options => {
|
19515
|
+
const chalk = {};
|
19516
|
+
applyOptions(chalk, options);
|
19517
|
+
|
19518
|
+
chalk.template = (...arguments_) => chalkTag(chalk.template, ...arguments_);
|
19519
|
+
|
19520
|
+
Object.setPrototypeOf(chalk, Chalk.prototype);
|
19521
|
+
Object.setPrototypeOf(chalk.template, chalk);
|
19522
|
+
|
19523
|
+
chalk.template.constructor = () => {
|
19524
|
+
throw new Error('`chalk.constructor()` is deprecated. Use `new chalk.Instance()` instead.');
|
19525
|
+
};
|
19526
|
+
|
19527
|
+
chalk.template.Instance = ChalkClass;
|
19528
|
+
|
19529
|
+
return chalk.template;
|
19530
|
+
};
|
19531
|
+
|
19532
|
+
function Chalk(options) {
|
19533
|
+
return chalkFactory(options);
|
19534
|
+
}
|
19535
|
+
|
19536
|
+
for (const [styleName, style] of Object.entries(ansiStyles)) {
|
19537
|
+
styles[styleName] = {
|
19538
|
+
get() {
|
19539
|
+
const builder = createBuilder(this, createStyler(style.open, style.close, this._styler), this._isEmpty);
|
19540
|
+
Object.defineProperty(this, styleName, {value: builder});
|
19541
|
+
return builder;
|
19542
|
+
}
|
19543
|
+
};
|
19544
|
+
}
|
19545
|
+
|
19546
|
+
styles.visible = {
|
19547
|
+
get() {
|
19548
|
+
const builder = createBuilder(this, this._styler, true);
|
19549
|
+
Object.defineProperty(this, 'visible', {value: builder});
|
19550
|
+
return builder;
|
19551
|
+
}
|
19552
|
+
};
|
19553
|
+
|
19554
|
+
const usedModels = ['rgb', 'hex', 'keyword', 'hsl', 'hsv', 'hwb', 'ansi', 'ansi256'];
|
19555
|
+
|
19556
|
+
for (const model of usedModels) {
|
19557
|
+
styles[model] = {
|
19558
|
+
get() {
|
19559
|
+
const {level} = this;
|
19560
|
+
return function (...arguments_) {
|
19561
|
+
const styler = createStyler(ansiStyles.color[levelMapping[level]][model](...arguments_), ansiStyles.color.close, this._styler);
|
19562
|
+
return createBuilder(this, styler, this._isEmpty);
|
19563
|
+
};
|
19564
|
+
}
|
19565
|
+
};
|
19566
|
+
}
|
19567
|
+
|
19568
|
+
for (const model of usedModels) {
|
19569
|
+
const bgModel = 'bg' + model[0].toUpperCase() + model.slice(1);
|
19570
|
+
styles[bgModel] = {
|
19571
|
+
get() {
|
19572
|
+
const {level} = this;
|
19573
|
+
return function (...arguments_) {
|
19574
|
+
const styler = createStyler(ansiStyles.bgColor[levelMapping[level]][model](...arguments_), ansiStyles.bgColor.close, this._styler);
|
19575
|
+
return createBuilder(this, styler, this._isEmpty);
|
19576
|
+
};
|
19577
|
+
}
|
19578
|
+
};
|
19579
|
+
}
|
19580
|
+
|
19581
|
+
const proto = Object.defineProperties(() => {}, {
|
19582
|
+
...styles,
|
19583
|
+
level: {
|
19584
|
+
enumerable: true,
|
19585
|
+
get() {
|
19586
|
+
return this._generator.level;
|
19587
|
+
},
|
19588
|
+
set(level) {
|
19589
|
+
this._generator.level = level;
|
19590
|
+
}
|
19591
|
+
}
|
19592
|
+
});
|
19593
|
+
|
19594
|
+
const createStyler = (open, close, parent) => {
|
19595
|
+
let openAll;
|
19596
|
+
let closeAll;
|
19597
|
+
if (parent === undefined) {
|
19598
|
+
openAll = open;
|
19599
|
+
closeAll = close;
|
19600
|
+
} else {
|
19601
|
+
openAll = parent.openAll + open;
|
19602
|
+
closeAll = close + parent.closeAll;
|
19603
|
+
}
|
19604
|
+
|
19605
|
+
return {
|
19606
|
+
open,
|
19607
|
+
close,
|
19608
|
+
openAll,
|
19609
|
+
closeAll,
|
19610
|
+
parent
|
19611
|
+
};
|
19612
|
+
};
|
19613
|
+
|
19614
|
+
const createBuilder = (self, _styler, _isEmpty) => {
|
19615
|
+
const builder = (...arguments_) => {
|
19616
|
+
if (isArray(arguments_[0]) && isArray(arguments_[0].raw)) {
|
19617
|
+
// Called as a template literal, for example: chalk.red`2 + 3 = {bold ${2+3}}`
|
19618
|
+
return applyStyle(builder, chalkTag(builder, ...arguments_));
|
19619
|
+
}
|
19620
|
+
|
19621
|
+
// Single argument is hot path, implicit coercion is faster than anything
|
19622
|
+
// eslint-disable-next-line no-implicit-coercion
|
19623
|
+
return applyStyle(builder, (arguments_.length === 1) ? ('' + arguments_[0]) : arguments_.join(' '));
|
19624
|
+
};
|
19625
|
+
|
19626
|
+
// We alter the prototype because we must return a function, but there is
|
19627
|
+
// no way to create a function with a different prototype
|
19628
|
+
Object.setPrototypeOf(builder, proto);
|
19629
|
+
|
19630
|
+
builder._generator = self;
|
19631
|
+
builder._styler = _styler;
|
19632
|
+
builder._isEmpty = _isEmpty;
|
19633
|
+
|
19634
|
+
return builder;
|
19635
|
+
};
|
19636
|
+
|
19637
|
+
const applyStyle = (self, string) => {
|
19638
|
+
if (self.level <= 0 || !string) {
|
19639
|
+
return self._isEmpty ? '' : string;
|
19640
|
+
}
|
19641
|
+
|
19642
|
+
let styler = self._styler;
|
19643
|
+
|
19644
|
+
if (styler === undefined) {
|
19645
|
+
return string;
|
19646
|
+
}
|
19647
|
+
|
19648
|
+
const {openAll, closeAll} = styler;
|
19649
|
+
if (string.indexOf('\u001B') !== -1) {
|
19650
|
+
while (styler !== undefined) {
|
19651
|
+
// Replace any instances already present with a re-opening code
|
19652
|
+
// otherwise only the part of the string until said closing code
|
19653
|
+
// will be colored, and the rest will simply be 'plain'.
|
19654
|
+
string = stringReplaceAll(string, styler.close, styler.open);
|
19655
|
+
|
19656
|
+
styler = styler.parent;
|
19657
|
+
}
|
19658
|
+
}
|
19659
|
+
|
19660
|
+
// We can move both next actions out of loop, because remaining actions in loop won't have
|
19661
|
+
// any/visible effect on parts we add here. Close the styling before a linebreak and reopen
|
19662
|
+
// after next line to fix a bleed issue on macOS: https://github.com/chalk/chalk/pull/92
|
19663
|
+
const lfIndex = string.indexOf('\n');
|
19664
|
+
if (lfIndex !== -1) {
|
19665
|
+
string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
|
19666
|
+
}
|
19667
|
+
|
19668
|
+
return openAll + string + closeAll;
|
19669
|
+
};
|
19670
|
+
|
19671
|
+
let template;
|
19672
|
+
const chalkTag = (chalk, ...strings) => {
|
19673
|
+
const [firstString] = strings;
|
19674
|
+
|
19675
|
+
if (!isArray(firstString) || !isArray(firstString.raw)) {
|
19676
|
+
// If chalk() was called by itself or with a string,
|
19677
|
+
// return the string itself as a string.
|
19678
|
+
return strings.join(' ');
|
19679
|
+
}
|
19680
|
+
|
19681
|
+
const arguments_ = strings.slice(1);
|
19682
|
+
const parts = [firstString.raw[0]];
|
19683
|
+
|
19684
|
+
for (let i = 1; i < firstString.length; i++) {
|
19685
|
+
parts.push(
|
19686
|
+
String(arguments_[i - 1]).replace(/[{}\\]/g, '\\$&'),
|
19687
|
+
String(firstString.raw[i])
|
19688
|
+
);
|
19689
|
+
}
|
19690
|
+
|
19691
|
+
if (template === undefined) {
|
19692
|
+
template = __nccwpck_require__(6987);
|
19693
|
+
}
|
19694
|
+
|
19695
|
+
return template(chalk, parts.join(''));
|
19696
|
+
};
|
19697
|
+
|
19698
|
+
Object.defineProperties(Chalk.prototype, styles);
|
19699
|
+
|
19700
|
+
const chalk = Chalk(); // eslint-disable-line new-cap
|
19701
|
+
chalk.supportsColor = stdoutColor;
|
19702
|
+
chalk.stderr = Chalk({level: stderrColor ? stderrColor.level : 0}); // eslint-disable-line new-cap
|
19703
|
+
chalk.stderr.supportsColor = stderrColor;
|
19704
|
+
|
19705
|
+
module.exports = chalk;
|
19706
|
+
|
19707
|
+
|
19708
|
+
/***/ }),
|
19709
|
+
|
19710
|
+
/***/ 6987:
|
19711
|
+
/***/ ((module) => {
|
19712
|
+
|
19713
|
+
"use strict";
|
19714
|
+
|
19715
|
+
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;
|
19716
|
+
const STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
|
19717
|
+
const STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
|
19718
|
+
const ESCAPE_REGEX = /\\(u(?:[a-f\d]{4}|{[a-f\d]{1,6}})|x[a-f\d]{2}|.)|([^\\])/gi;
|
19719
|
+
|
19720
|
+
const ESCAPES = new Map([
|
19721
|
+
['n', '\n'],
|
19722
|
+
['r', '\r'],
|
19723
|
+
['t', '\t'],
|
19724
|
+
['b', '\b'],
|
19725
|
+
['f', '\f'],
|
19726
|
+
['v', '\v'],
|
19727
|
+
['0', '\0'],
|
19728
|
+
['\\', '\\'],
|
19729
|
+
['e', '\u001B'],
|
19730
|
+
['a', '\u0007']
|
19731
|
+
]);
|
19732
|
+
|
19733
|
+
function unescape(c) {
|
19734
|
+
const u = c[0] === 'u';
|
19735
|
+
const bracket = c[1] === '{';
|
19736
|
+
|
19737
|
+
if ((u && !bracket && c.length === 5) || (c[0] === 'x' && c.length === 3)) {
|
19738
|
+
return String.fromCharCode(parseInt(c.slice(1), 16));
|
19739
|
+
}
|
19740
|
+
|
19741
|
+
if (u && bracket) {
|
19742
|
+
return String.fromCodePoint(parseInt(c.slice(2, -1), 16));
|
19743
|
+
}
|
19744
|
+
|
19745
|
+
return ESCAPES.get(c) || c;
|
19746
|
+
}
|
19747
|
+
|
19748
|
+
function parseArguments(name, arguments_) {
|
19749
|
+
const results = [];
|
19750
|
+
const chunks = arguments_.trim().split(/\s*,\s*/g);
|
19751
|
+
let matches;
|
19752
|
+
|
19753
|
+
for (const chunk of chunks) {
|
19754
|
+
const number = Number(chunk);
|
19755
|
+
if (!Number.isNaN(number)) {
|
19756
|
+
results.push(number);
|
19757
|
+
} else if ((matches = chunk.match(STRING_REGEX))) {
|
19758
|
+
results.push(matches[2].replace(ESCAPE_REGEX, (m, escape, character) => escape ? unescape(escape) : character));
|
19759
|
+
} else {
|
19760
|
+
throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`);
|
19761
|
+
}
|
19762
|
+
}
|
19763
|
+
|
19764
|
+
return results;
|
19765
|
+
}
|
19766
|
+
|
19767
|
+
function parseStyle(style) {
|
19768
|
+
STYLE_REGEX.lastIndex = 0;
|
19769
|
+
|
19770
|
+
const results = [];
|
19771
|
+
let matches;
|
19772
|
+
|
19773
|
+
while ((matches = STYLE_REGEX.exec(style)) !== null) {
|
19774
|
+
const name = matches[1];
|
19775
|
+
|
19776
|
+
if (matches[2]) {
|
19777
|
+
const args = parseArguments(name, matches[2]);
|
19778
|
+
results.push([name].concat(args));
|
19779
|
+
} else {
|
19780
|
+
results.push([name]);
|
19781
|
+
}
|
19782
|
+
}
|
19783
|
+
|
19784
|
+
return results;
|
19785
|
+
}
|
19786
|
+
|
19787
|
+
function buildStyle(chalk, styles) {
|
19788
|
+
const enabled = {};
|
19789
|
+
|
19790
|
+
for (const layer of styles) {
|
19791
|
+
for (const style of layer.styles) {
|
19792
|
+
enabled[style[0]] = layer.inverse ? null : style.slice(1);
|
19793
|
+
}
|
19794
|
+
}
|
19795
|
+
|
19796
|
+
let current = chalk;
|
19797
|
+
for (const [styleName, styles] of Object.entries(enabled)) {
|
19798
|
+
if (!Array.isArray(styles)) {
|
19799
|
+
continue;
|
19800
|
+
}
|
19801
|
+
|
19802
|
+
if (!(styleName in current)) {
|
19803
|
+
throw new Error(`Unknown Chalk style: ${styleName}`);
|
19804
|
+
}
|
19805
|
+
|
19806
|
+
current = styles.length > 0 ? current[styleName](...styles) : current[styleName];
|
19807
|
+
}
|
19808
|
+
|
19809
|
+
return current;
|
19810
|
+
}
|
19811
|
+
|
19812
|
+
module.exports = (chalk, temporary) => {
|
19813
|
+
const styles = [];
|
19814
|
+
const chunks = [];
|
19815
|
+
let chunk = [];
|
19816
|
+
|
19817
|
+
// eslint-disable-next-line max-params
|
19818
|
+
temporary.replace(TEMPLATE_REGEX, (m, escapeCharacter, inverse, style, close, character) => {
|
19819
|
+
if (escapeCharacter) {
|
19820
|
+
chunk.push(unescape(escapeCharacter));
|
19821
|
+
} else if (style) {
|
19822
|
+
const string = chunk.join('');
|
19823
|
+
chunk = [];
|
19824
|
+
chunks.push(styles.length === 0 ? string : buildStyle(chalk, styles)(string));
|
19825
|
+
styles.push({inverse, styles: parseStyle(style)});
|
19826
|
+
} else if (close) {
|
19827
|
+
if (styles.length === 0) {
|
19828
|
+
throw new Error('Found extraneous } in Chalk template literal');
|
19829
|
+
}
|
19830
|
+
|
19831
|
+
chunks.push(buildStyle(chalk, styles)(chunk.join('')));
|
19832
|
+
chunk = [];
|
19833
|
+
styles.pop();
|
19834
|
+
} else {
|
19835
|
+
chunk.push(character);
|
19836
|
+
}
|
19837
|
+
});
|
19838
|
+
|
19839
|
+
chunks.push(chunk.join(''));
|
19840
|
+
|
19841
|
+
if (styles.length > 0) {
|
19842
|
+
const errMessage = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? '' : 's'} (\`}\`)`;
|
19843
|
+
throw new Error(errMessage);
|
19844
|
+
}
|
19845
|
+
|
19846
|
+
return chunks.join('');
|
19847
|
+
};
|
19848
|
+
|
19849
|
+
|
19850
|
+
/***/ }),
|
19851
|
+
|
19852
|
+
/***/ 2415:
|
19853
|
+
/***/ ((module) => {
|
19854
|
+
|
19855
|
+
"use strict";
|
19856
|
+
|
19857
|
+
|
19858
|
+
const stringReplaceAll = (string, substring, replacer) => {
|
19859
|
+
let index = string.indexOf(substring);
|
19860
|
+
if (index === -1) {
|
19861
|
+
return string;
|
19862
|
+
}
|
19863
|
+
|
19864
|
+
const substringLength = substring.length;
|
19865
|
+
let endIndex = 0;
|
19866
|
+
let returnValue = '';
|
19867
|
+
do {
|
19868
|
+
returnValue += string.substr(endIndex, index - endIndex) + substring + replacer;
|
19869
|
+
endIndex = index + substringLength;
|
19870
|
+
index = string.indexOf(substring, endIndex);
|
19871
|
+
} while (index !== -1);
|
19872
|
+
|
19873
|
+
returnValue += string.substr(endIndex);
|
19874
|
+
return returnValue;
|
19875
|
+
};
|
19876
|
+
|
19877
|
+
const stringEncaseCRLFWithFirstIndex = (string, prefix, postfix, index) => {
|
19878
|
+
let endIndex = 0;
|
19879
|
+
let returnValue = '';
|
19880
|
+
do {
|
19881
|
+
const gotCR = string[index - 1] === '\r';
|
19882
|
+
returnValue += string.substr(endIndex, (gotCR ? index - 1 : index) - endIndex) + prefix + (gotCR ? '\r\n' : '\n') + postfix;
|
19883
|
+
endIndex = index + 1;
|
19884
|
+
index = string.indexOf('\n', endIndex);
|
19885
|
+
} while (index !== -1);
|
19886
|
+
|
19887
|
+
returnValue += string.substr(endIndex);
|
19888
|
+
return returnValue;
|
19889
|
+
};
|
19890
|
+
|
19891
|
+
module.exports = {
|
19892
|
+
stringReplaceAll,
|
19893
|
+
stringEncaseCRLFWithFirstIndex
|
19894
|
+
};
|
19895
|
+
|
19896
|
+
|
19289
19897
|
/***/ }),
|
19290
19898
|
|
19291
19899
|
/***/ 7972:
|
@@ -19334,6 +19942,1204 @@ module.exports = (stack, options) => {
|
|
19334
19942
|
};
|
19335
19943
|
|
19336
19944
|
|
19945
|
+
/***/ }),
|
19946
|
+
|
19947
|
+
/***/ 7391:
|
19948
|
+
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
19949
|
+
|
19950
|
+
/* MIT license */
|
19951
|
+
/* eslint-disable no-mixed-operators */
|
19952
|
+
const cssKeywords = __nccwpck_require__(8510);
|
19953
|
+
|
19954
|
+
// NOTE: conversions should only return primitive values (i.e. arrays, or
|
19955
|
+
// values that give correct `typeof` results).
|
19956
|
+
// do not use box values types (i.e. Number(), String(), etc.)
|
19957
|
+
|
19958
|
+
const reverseKeywords = {};
|
19959
|
+
for (const key of Object.keys(cssKeywords)) {
|
19960
|
+
reverseKeywords[cssKeywords[key]] = key;
|
19961
|
+
}
|
19962
|
+
|
19963
|
+
const convert = {
|
19964
|
+
rgb: {channels: 3, labels: 'rgb'},
|
19965
|
+
hsl: {channels: 3, labels: 'hsl'},
|
19966
|
+
hsv: {channels: 3, labels: 'hsv'},
|
19967
|
+
hwb: {channels: 3, labels: 'hwb'},
|
19968
|
+
cmyk: {channels: 4, labels: 'cmyk'},
|
19969
|
+
xyz: {channels: 3, labels: 'xyz'},
|
19970
|
+
lab: {channels: 3, labels: 'lab'},
|
19971
|
+
lch: {channels: 3, labels: 'lch'},
|
19972
|
+
hex: {channels: 1, labels: ['hex']},
|
19973
|
+
keyword: {channels: 1, labels: ['keyword']},
|
19974
|
+
ansi16: {channels: 1, labels: ['ansi16']},
|
19975
|
+
ansi256: {channels: 1, labels: ['ansi256']},
|
19976
|
+
hcg: {channels: 3, labels: ['h', 'c', 'g']},
|
19977
|
+
apple: {channels: 3, labels: ['r16', 'g16', 'b16']},
|
19978
|
+
gray: {channels: 1, labels: ['gray']}
|
19979
|
+
};
|
19980
|
+
|
19981
|
+
module.exports = convert;
|
19982
|
+
|
19983
|
+
// Hide .channels and .labels properties
|
19984
|
+
for (const model of Object.keys(convert)) {
|
19985
|
+
if (!('channels' in convert[model])) {
|
19986
|
+
throw new Error('missing channels property: ' + model);
|
19987
|
+
}
|
19988
|
+
|
19989
|
+
if (!('labels' in convert[model])) {
|
19990
|
+
throw new Error('missing channel labels property: ' + model);
|
19991
|
+
}
|
19992
|
+
|
19993
|
+
if (convert[model].labels.length !== convert[model].channels) {
|
19994
|
+
throw new Error('channel and label counts mismatch: ' + model);
|
19995
|
+
}
|
19996
|
+
|
19997
|
+
const {channels, labels} = convert[model];
|
19998
|
+
delete convert[model].channels;
|
19999
|
+
delete convert[model].labels;
|
20000
|
+
Object.defineProperty(convert[model], 'channels', {value: channels});
|
20001
|
+
Object.defineProperty(convert[model], 'labels', {value: labels});
|
20002
|
+
}
|
20003
|
+
|
20004
|
+
convert.rgb.hsl = function (rgb) {
|
20005
|
+
const r = rgb[0] / 255;
|
20006
|
+
const g = rgb[1] / 255;
|
20007
|
+
const b = rgb[2] / 255;
|
20008
|
+
const min = Math.min(r, g, b);
|
20009
|
+
const max = Math.max(r, g, b);
|
20010
|
+
const delta = max - min;
|
20011
|
+
let h;
|
20012
|
+
let s;
|
20013
|
+
|
20014
|
+
if (max === min) {
|
20015
|
+
h = 0;
|
20016
|
+
} else if (r === max) {
|
20017
|
+
h = (g - b) / delta;
|
20018
|
+
} else if (g === max) {
|
20019
|
+
h = 2 + (b - r) / delta;
|
20020
|
+
} else if (b === max) {
|
20021
|
+
h = 4 + (r - g) / delta;
|
20022
|
+
}
|
20023
|
+
|
20024
|
+
h = Math.min(h * 60, 360);
|
20025
|
+
|
20026
|
+
if (h < 0) {
|
20027
|
+
h += 360;
|
20028
|
+
}
|
20029
|
+
|
20030
|
+
const l = (min + max) / 2;
|
20031
|
+
|
20032
|
+
if (max === min) {
|
20033
|
+
s = 0;
|
20034
|
+
} else if (l <= 0.5) {
|
20035
|
+
s = delta / (max + min);
|
20036
|
+
} else {
|
20037
|
+
s = delta / (2 - max - min);
|
20038
|
+
}
|
20039
|
+
|
20040
|
+
return [h, s * 100, l * 100];
|
20041
|
+
};
|
20042
|
+
|
20043
|
+
convert.rgb.hsv = function (rgb) {
|
20044
|
+
let rdif;
|
20045
|
+
let gdif;
|
20046
|
+
let bdif;
|
20047
|
+
let h;
|
20048
|
+
let s;
|
20049
|
+
|
20050
|
+
const r = rgb[0] / 255;
|
20051
|
+
const g = rgb[1] / 255;
|
20052
|
+
const b = rgb[2] / 255;
|
20053
|
+
const v = Math.max(r, g, b);
|
20054
|
+
const diff = v - Math.min(r, g, b);
|
20055
|
+
const diffc = function (c) {
|
20056
|
+
return (v - c) / 6 / diff + 1 / 2;
|
20057
|
+
};
|
20058
|
+
|
20059
|
+
if (diff === 0) {
|
20060
|
+
h = 0;
|
20061
|
+
s = 0;
|
20062
|
+
} else {
|
20063
|
+
s = diff / v;
|
20064
|
+
rdif = diffc(r);
|
20065
|
+
gdif = diffc(g);
|
20066
|
+
bdif = diffc(b);
|
20067
|
+
|
20068
|
+
if (r === v) {
|
20069
|
+
h = bdif - gdif;
|
20070
|
+
} else if (g === v) {
|
20071
|
+
h = (1 / 3) + rdif - bdif;
|
20072
|
+
} else if (b === v) {
|
20073
|
+
h = (2 / 3) + gdif - rdif;
|
20074
|
+
}
|
20075
|
+
|
20076
|
+
if (h < 0) {
|
20077
|
+
h += 1;
|
20078
|
+
} else if (h > 1) {
|
20079
|
+
h -= 1;
|
20080
|
+
}
|
20081
|
+
}
|
20082
|
+
|
20083
|
+
return [
|
20084
|
+
h * 360,
|
20085
|
+
s * 100,
|
20086
|
+
v * 100
|
20087
|
+
];
|
20088
|
+
};
|
20089
|
+
|
20090
|
+
convert.rgb.hwb = function (rgb) {
|
20091
|
+
const r = rgb[0];
|
20092
|
+
const g = rgb[1];
|
20093
|
+
let b = rgb[2];
|
20094
|
+
const h = convert.rgb.hsl(rgb)[0];
|
20095
|
+
const w = 1 / 255 * Math.min(r, Math.min(g, b));
|
20096
|
+
|
20097
|
+
b = 1 - 1 / 255 * Math.max(r, Math.max(g, b));
|
20098
|
+
|
20099
|
+
return [h, w * 100, b * 100];
|
20100
|
+
};
|
20101
|
+
|
20102
|
+
convert.rgb.cmyk = function (rgb) {
|
20103
|
+
const r = rgb[0] / 255;
|
20104
|
+
const g = rgb[1] / 255;
|
20105
|
+
const b = rgb[2] / 255;
|
20106
|
+
|
20107
|
+
const k = Math.min(1 - r, 1 - g, 1 - b);
|
20108
|
+
const c = (1 - r - k) / (1 - k) || 0;
|
20109
|
+
const m = (1 - g - k) / (1 - k) || 0;
|
20110
|
+
const y = (1 - b - k) / (1 - k) || 0;
|
20111
|
+
|
20112
|
+
return [c * 100, m * 100, y * 100, k * 100];
|
20113
|
+
};
|
20114
|
+
|
20115
|
+
function comparativeDistance(x, y) {
|
20116
|
+
/*
|
20117
|
+
See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
|
20118
|
+
*/
|
20119
|
+
return (
|
20120
|
+
((x[0] - y[0]) ** 2) +
|
20121
|
+
((x[1] - y[1]) ** 2) +
|
20122
|
+
((x[2] - y[2]) ** 2)
|
20123
|
+
);
|
20124
|
+
}
|
20125
|
+
|
20126
|
+
convert.rgb.keyword = function (rgb) {
|
20127
|
+
const reversed = reverseKeywords[rgb];
|
20128
|
+
if (reversed) {
|
20129
|
+
return reversed;
|
20130
|
+
}
|
20131
|
+
|
20132
|
+
let currentClosestDistance = Infinity;
|
20133
|
+
let currentClosestKeyword;
|
20134
|
+
|
20135
|
+
for (const keyword of Object.keys(cssKeywords)) {
|
20136
|
+
const value = cssKeywords[keyword];
|
20137
|
+
|
20138
|
+
// Compute comparative distance
|
20139
|
+
const distance = comparativeDistance(rgb, value);
|
20140
|
+
|
20141
|
+
// Check if its less, if so set as closest
|
20142
|
+
if (distance < currentClosestDistance) {
|
20143
|
+
currentClosestDistance = distance;
|
20144
|
+
currentClosestKeyword = keyword;
|
20145
|
+
}
|
20146
|
+
}
|
20147
|
+
|
20148
|
+
return currentClosestKeyword;
|
20149
|
+
};
|
20150
|
+
|
20151
|
+
convert.keyword.rgb = function (keyword) {
|
20152
|
+
return cssKeywords[keyword];
|
20153
|
+
};
|
20154
|
+
|
20155
|
+
convert.rgb.xyz = function (rgb) {
|
20156
|
+
let r = rgb[0] / 255;
|
20157
|
+
let g = rgb[1] / 255;
|
20158
|
+
let b = rgb[2] / 255;
|
20159
|
+
|
20160
|
+
// Assume sRGB
|
20161
|
+
r = r > 0.04045 ? (((r + 0.055) / 1.055) ** 2.4) : (r / 12.92);
|
20162
|
+
g = g > 0.04045 ? (((g + 0.055) / 1.055) ** 2.4) : (g / 12.92);
|
20163
|
+
b = b > 0.04045 ? (((b + 0.055) / 1.055) ** 2.4) : (b / 12.92);
|
20164
|
+
|
20165
|
+
const x = (r * 0.4124) + (g * 0.3576) + (b * 0.1805);
|
20166
|
+
const y = (r * 0.2126) + (g * 0.7152) + (b * 0.0722);
|
20167
|
+
const z = (r * 0.0193) + (g * 0.1192) + (b * 0.9505);
|
20168
|
+
|
20169
|
+
return [x * 100, y * 100, z * 100];
|
20170
|
+
};
|
20171
|
+
|
20172
|
+
convert.rgb.lab = function (rgb) {
|
20173
|
+
const xyz = convert.rgb.xyz(rgb);
|
20174
|
+
let x = xyz[0];
|
20175
|
+
let y = xyz[1];
|
20176
|
+
let z = xyz[2];
|
20177
|
+
|
20178
|
+
x /= 95.047;
|
20179
|
+
y /= 100;
|
20180
|
+
z /= 108.883;
|
20181
|
+
|
20182
|
+
x = x > 0.008856 ? (x ** (1 / 3)) : (7.787 * x) + (16 / 116);
|
20183
|
+
y = y > 0.008856 ? (y ** (1 / 3)) : (7.787 * y) + (16 / 116);
|
20184
|
+
z = z > 0.008856 ? (z ** (1 / 3)) : (7.787 * z) + (16 / 116);
|
20185
|
+
|
20186
|
+
const l = (116 * y) - 16;
|
20187
|
+
const a = 500 * (x - y);
|
20188
|
+
const b = 200 * (y - z);
|
20189
|
+
|
20190
|
+
return [l, a, b];
|
20191
|
+
};
|
20192
|
+
|
20193
|
+
convert.hsl.rgb = function (hsl) {
|
20194
|
+
const h = hsl[0] / 360;
|
20195
|
+
const s = hsl[1] / 100;
|
20196
|
+
const l = hsl[2] / 100;
|
20197
|
+
let t2;
|
20198
|
+
let t3;
|
20199
|
+
let val;
|
20200
|
+
|
20201
|
+
if (s === 0) {
|
20202
|
+
val = l * 255;
|
20203
|
+
return [val, val, val];
|
20204
|
+
}
|
20205
|
+
|
20206
|
+
if (l < 0.5) {
|
20207
|
+
t2 = l * (1 + s);
|
20208
|
+
} else {
|
20209
|
+
t2 = l + s - l * s;
|
20210
|
+
}
|
20211
|
+
|
20212
|
+
const t1 = 2 * l - t2;
|
20213
|
+
|
20214
|
+
const rgb = [0, 0, 0];
|
20215
|
+
for (let i = 0; i < 3; i++) {
|
20216
|
+
t3 = h + 1 / 3 * -(i - 1);
|
20217
|
+
if (t3 < 0) {
|
20218
|
+
t3++;
|
20219
|
+
}
|
20220
|
+
|
20221
|
+
if (t3 > 1) {
|
20222
|
+
t3--;
|
20223
|
+
}
|
20224
|
+
|
20225
|
+
if (6 * t3 < 1) {
|
20226
|
+
val = t1 + (t2 - t1) * 6 * t3;
|
20227
|
+
} else if (2 * t3 < 1) {
|
20228
|
+
val = t2;
|
20229
|
+
} else if (3 * t3 < 2) {
|
20230
|
+
val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
|
20231
|
+
} else {
|
20232
|
+
val = t1;
|
20233
|
+
}
|
20234
|
+
|
20235
|
+
rgb[i] = val * 255;
|
20236
|
+
}
|
20237
|
+
|
20238
|
+
return rgb;
|
20239
|
+
};
|
20240
|
+
|
20241
|
+
convert.hsl.hsv = function (hsl) {
|
20242
|
+
const h = hsl[0];
|
20243
|
+
let s = hsl[1] / 100;
|
20244
|
+
let l = hsl[2] / 100;
|
20245
|
+
let smin = s;
|
20246
|
+
const lmin = Math.max(l, 0.01);
|
20247
|
+
|
20248
|
+
l *= 2;
|
20249
|
+
s *= (l <= 1) ? l : 2 - l;
|
20250
|
+
smin *= lmin <= 1 ? lmin : 2 - lmin;
|
20251
|
+
const v = (l + s) / 2;
|
20252
|
+
const sv = l === 0 ? (2 * smin) / (lmin + smin) : (2 * s) / (l + s);
|
20253
|
+
|
20254
|
+
return [h, sv * 100, v * 100];
|
20255
|
+
};
|
20256
|
+
|
20257
|
+
convert.hsv.rgb = function (hsv) {
|
20258
|
+
const h = hsv[0] / 60;
|
20259
|
+
const s = hsv[1] / 100;
|
20260
|
+
let v = hsv[2] / 100;
|
20261
|
+
const hi = Math.floor(h) % 6;
|
20262
|
+
|
20263
|
+
const f = h - Math.floor(h);
|
20264
|
+
const p = 255 * v * (1 - s);
|
20265
|
+
const q = 255 * v * (1 - (s * f));
|
20266
|
+
const t = 255 * v * (1 - (s * (1 - f)));
|
20267
|
+
v *= 255;
|
20268
|
+
|
20269
|
+
switch (hi) {
|
20270
|
+
case 0:
|
20271
|
+
return [v, t, p];
|
20272
|
+
case 1:
|
20273
|
+
return [q, v, p];
|
20274
|
+
case 2:
|
20275
|
+
return [p, v, t];
|
20276
|
+
case 3:
|
20277
|
+
return [p, q, v];
|
20278
|
+
case 4:
|
20279
|
+
return [t, p, v];
|
20280
|
+
case 5:
|
20281
|
+
return [v, p, q];
|
20282
|
+
}
|
20283
|
+
};
|
20284
|
+
|
20285
|
+
convert.hsv.hsl = function (hsv) {
|
20286
|
+
const h = hsv[0];
|
20287
|
+
const s = hsv[1] / 100;
|
20288
|
+
const v = hsv[2] / 100;
|
20289
|
+
const vmin = Math.max(v, 0.01);
|
20290
|
+
let sl;
|
20291
|
+
let l;
|
20292
|
+
|
20293
|
+
l = (2 - s) * v;
|
20294
|
+
const lmin = (2 - s) * vmin;
|
20295
|
+
sl = s * vmin;
|
20296
|
+
sl /= (lmin <= 1) ? lmin : 2 - lmin;
|
20297
|
+
sl = sl || 0;
|
20298
|
+
l /= 2;
|
20299
|
+
|
20300
|
+
return [h, sl * 100, l * 100];
|
20301
|
+
};
|
20302
|
+
|
20303
|
+
// http://dev.w3.org/csswg/css-color/#hwb-to-rgb
|
20304
|
+
convert.hwb.rgb = function (hwb) {
|
20305
|
+
const h = hwb[0] / 360;
|
20306
|
+
let wh = hwb[1] / 100;
|
20307
|
+
let bl = hwb[2] / 100;
|
20308
|
+
const ratio = wh + bl;
|
20309
|
+
let f;
|
20310
|
+
|
20311
|
+
// Wh + bl cant be > 1
|
20312
|
+
if (ratio > 1) {
|
20313
|
+
wh /= ratio;
|
20314
|
+
bl /= ratio;
|
20315
|
+
}
|
20316
|
+
|
20317
|
+
const i = Math.floor(6 * h);
|
20318
|
+
const v = 1 - bl;
|
20319
|
+
f = 6 * h - i;
|
20320
|
+
|
20321
|
+
if ((i & 0x01) !== 0) {
|
20322
|
+
f = 1 - f;
|
20323
|
+
}
|
20324
|
+
|
20325
|
+
const n = wh + f * (v - wh); // Linear interpolation
|
20326
|
+
|
20327
|
+
let r;
|
20328
|
+
let g;
|
20329
|
+
let b;
|
20330
|
+
/* eslint-disable max-statements-per-line,no-multi-spaces */
|
20331
|
+
switch (i) {
|
20332
|
+
default:
|
20333
|
+
case 6:
|
20334
|
+
case 0: r = v; g = n; b = wh; break;
|
20335
|
+
case 1: r = n; g = v; b = wh; break;
|
20336
|
+
case 2: r = wh; g = v; b = n; break;
|
20337
|
+
case 3: r = wh; g = n; b = v; break;
|
20338
|
+
case 4: r = n; g = wh; b = v; break;
|
20339
|
+
case 5: r = v; g = wh; b = n; break;
|
20340
|
+
}
|
20341
|
+
/* eslint-enable max-statements-per-line,no-multi-spaces */
|
20342
|
+
|
20343
|
+
return [r * 255, g * 255, b * 255];
|
20344
|
+
};
|
20345
|
+
|
20346
|
+
convert.cmyk.rgb = function (cmyk) {
|
20347
|
+
const c = cmyk[0] / 100;
|
20348
|
+
const m = cmyk[1] / 100;
|
20349
|
+
const y = cmyk[2] / 100;
|
20350
|
+
const k = cmyk[3] / 100;
|
20351
|
+
|
20352
|
+
const r = 1 - Math.min(1, c * (1 - k) + k);
|
20353
|
+
const g = 1 - Math.min(1, m * (1 - k) + k);
|
20354
|
+
const b = 1 - Math.min(1, y * (1 - k) + k);
|
20355
|
+
|
20356
|
+
return [r * 255, g * 255, b * 255];
|
20357
|
+
};
|
20358
|
+
|
20359
|
+
convert.xyz.rgb = function (xyz) {
|
20360
|
+
const x = xyz[0] / 100;
|
20361
|
+
const y = xyz[1] / 100;
|
20362
|
+
const z = xyz[2] / 100;
|
20363
|
+
let r;
|
20364
|
+
let g;
|
20365
|
+
let b;
|
20366
|
+
|
20367
|
+
r = (x * 3.2406) + (y * -1.5372) + (z * -0.4986);
|
20368
|
+
g = (x * -0.9689) + (y * 1.8758) + (z * 0.0415);
|
20369
|
+
b = (x * 0.0557) + (y * -0.2040) + (z * 1.0570);
|
20370
|
+
|
20371
|
+
// Assume sRGB
|
20372
|
+
r = r > 0.0031308
|
20373
|
+
? ((1.055 * (r ** (1.0 / 2.4))) - 0.055)
|
20374
|
+
: r * 12.92;
|
20375
|
+
|
20376
|
+
g = g > 0.0031308
|
20377
|
+
? ((1.055 * (g ** (1.0 / 2.4))) - 0.055)
|
20378
|
+
: g * 12.92;
|
20379
|
+
|
20380
|
+
b = b > 0.0031308
|
20381
|
+
? ((1.055 * (b ** (1.0 / 2.4))) - 0.055)
|
20382
|
+
: b * 12.92;
|
20383
|
+
|
20384
|
+
r = Math.min(Math.max(0, r), 1);
|
20385
|
+
g = Math.min(Math.max(0, g), 1);
|
20386
|
+
b = Math.min(Math.max(0, b), 1);
|
20387
|
+
|
20388
|
+
return [r * 255, g * 255, b * 255];
|
20389
|
+
};
|
20390
|
+
|
20391
|
+
convert.xyz.lab = function (xyz) {
|
20392
|
+
let x = xyz[0];
|
20393
|
+
let y = xyz[1];
|
20394
|
+
let z = xyz[2];
|
20395
|
+
|
20396
|
+
x /= 95.047;
|
20397
|
+
y /= 100;
|
20398
|
+
z /= 108.883;
|
20399
|
+
|
20400
|
+
x = x > 0.008856 ? (x ** (1 / 3)) : (7.787 * x) + (16 / 116);
|
20401
|
+
y = y > 0.008856 ? (y ** (1 / 3)) : (7.787 * y) + (16 / 116);
|
20402
|
+
z = z > 0.008856 ? (z ** (1 / 3)) : (7.787 * z) + (16 / 116);
|
20403
|
+
|
20404
|
+
const l = (116 * y) - 16;
|
20405
|
+
const a = 500 * (x - y);
|
20406
|
+
const b = 200 * (y - z);
|
20407
|
+
|
20408
|
+
return [l, a, b];
|
20409
|
+
};
|
20410
|
+
|
20411
|
+
convert.lab.xyz = function (lab) {
|
20412
|
+
const l = lab[0];
|
20413
|
+
const a = lab[1];
|
20414
|
+
const b = lab[2];
|
20415
|
+
let x;
|
20416
|
+
let y;
|
20417
|
+
let z;
|
20418
|
+
|
20419
|
+
y = (l + 16) / 116;
|
20420
|
+
x = a / 500 + y;
|
20421
|
+
z = y - b / 200;
|
20422
|
+
|
20423
|
+
const y2 = y ** 3;
|
20424
|
+
const x2 = x ** 3;
|
20425
|
+
const z2 = z ** 3;
|
20426
|
+
y = y2 > 0.008856 ? y2 : (y - 16 / 116) / 7.787;
|
20427
|
+
x = x2 > 0.008856 ? x2 : (x - 16 / 116) / 7.787;
|
20428
|
+
z = z2 > 0.008856 ? z2 : (z - 16 / 116) / 7.787;
|
20429
|
+
|
20430
|
+
x *= 95.047;
|
20431
|
+
y *= 100;
|
20432
|
+
z *= 108.883;
|
20433
|
+
|
20434
|
+
return [x, y, z];
|
20435
|
+
};
|
20436
|
+
|
20437
|
+
convert.lab.lch = function (lab) {
|
20438
|
+
const l = lab[0];
|
20439
|
+
const a = lab[1];
|
20440
|
+
const b = lab[2];
|
20441
|
+
let h;
|
20442
|
+
|
20443
|
+
const hr = Math.atan2(b, a);
|
20444
|
+
h = hr * 360 / 2 / Math.PI;
|
20445
|
+
|
20446
|
+
if (h < 0) {
|
20447
|
+
h += 360;
|
20448
|
+
}
|
20449
|
+
|
20450
|
+
const c = Math.sqrt(a * a + b * b);
|
20451
|
+
|
20452
|
+
return [l, c, h];
|
20453
|
+
};
|
20454
|
+
|
20455
|
+
convert.lch.lab = function (lch) {
|
20456
|
+
const l = lch[0];
|
20457
|
+
const c = lch[1];
|
20458
|
+
const h = lch[2];
|
20459
|
+
|
20460
|
+
const hr = h / 360 * 2 * Math.PI;
|
20461
|
+
const a = c * Math.cos(hr);
|
20462
|
+
const b = c * Math.sin(hr);
|
20463
|
+
|
20464
|
+
return [l, a, b];
|
20465
|
+
};
|
20466
|
+
|
20467
|
+
convert.rgb.ansi16 = function (args, saturation = null) {
|
20468
|
+
const [r, g, b] = args;
|
20469
|
+
let value = saturation === null ? convert.rgb.hsv(args)[2] : saturation; // Hsv -> ansi16 optimization
|
20470
|
+
|
20471
|
+
value = Math.round(value / 50);
|
20472
|
+
|
20473
|
+
if (value === 0) {
|
20474
|
+
return 30;
|
20475
|
+
}
|
20476
|
+
|
20477
|
+
let ansi = 30
|
20478
|
+
+ ((Math.round(b / 255) << 2)
|
20479
|
+
| (Math.round(g / 255) << 1)
|
20480
|
+
| Math.round(r / 255));
|
20481
|
+
|
20482
|
+
if (value === 2) {
|
20483
|
+
ansi += 60;
|
20484
|
+
}
|
20485
|
+
|
20486
|
+
return ansi;
|
20487
|
+
};
|
20488
|
+
|
20489
|
+
convert.hsv.ansi16 = function (args) {
|
20490
|
+
// Optimization here; we already know the value and don't need to get
|
20491
|
+
// it converted for us.
|
20492
|
+
return convert.rgb.ansi16(convert.hsv.rgb(args), args[2]);
|
20493
|
+
};
|
20494
|
+
|
20495
|
+
convert.rgb.ansi256 = function (args) {
|
20496
|
+
const r = args[0];
|
20497
|
+
const g = args[1];
|
20498
|
+
const b = args[2];
|
20499
|
+
|
20500
|
+
// We use the extended greyscale palette here, with the exception of
|
20501
|
+
// black and white. normal palette only has 4 greyscale shades.
|
20502
|
+
if (r === g && g === b) {
|
20503
|
+
if (r < 8) {
|
20504
|
+
return 16;
|
20505
|
+
}
|
20506
|
+
|
20507
|
+
if (r > 248) {
|
20508
|
+
return 231;
|
20509
|
+
}
|
20510
|
+
|
20511
|
+
return Math.round(((r - 8) / 247) * 24) + 232;
|
20512
|
+
}
|
20513
|
+
|
20514
|
+
const ansi = 16
|
20515
|
+
+ (36 * Math.round(r / 255 * 5))
|
20516
|
+
+ (6 * Math.round(g / 255 * 5))
|
20517
|
+
+ Math.round(b / 255 * 5);
|
20518
|
+
|
20519
|
+
return ansi;
|
20520
|
+
};
|
20521
|
+
|
20522
|
+
convert.ansi16.rgb = function (args) {
|
20523
|
+
let color = args % 10;
|
20524
|
+
|
20525
|
+
// Handle greyscale
|
20526
|
+
if (color === 0 || color === 7) {
|
20527
|
+
if (args > 50) {
|
20528
|
+
color += 3.5;
|
20529
|
+
}
|
20530
|
+
|
20531
|
+
color = color / 10.5 * 255;
|
20532
|
+
|
20533
|
+
return [color, color, color];
|
20534
|
+
}
|
20535
|
+
|
20536
|
+
const mult = (~~(args > 50) + 1) * 0.5;
|
20537
|
+
const r = ((color & 1) * mult) * 255;
|
20538
|
+
const g = (((color >> 1) & 1) * mult) * 255;
|
20539
|
+
const b = (((color >> 2) & 1) * mult) * 255;
|
20540
|
+
|
20541
|
+
return [r, g, b];
|
20542
|
+
};
|
20543
|
+
|
20544
|
+
convert.ansi256.rgb = function (args) {
|
20545
|
+
// Handle greyscale
|
20546
|
+
if (args >= 232) {
|
20547
|
+
const c = (args - 232) * 10 + 8;
|
20548
|
+
return [c, c, c];
|
20549
|
+
}
|
20550
|
+
|
20551
|
+
args -= 16;
|
20552
|
+
|
20553
|
+
let rem;
|
20554
|
+
const r = Math.floor(args / 36) / 5 * 255;
|
20555
|
+
const g = Math.floor((rem = args % 36) / 6) / 5 * 255;
|
20556
|
+
const b = (rem % 6) / 5 * 255;
|
20557
|
+
|
20558
|
+
return [r, g, b];
|
20559
|
+
};
|
20560
|
+
|
20561
|
+
convert.rgb.hex = function (args) {
|
20562
|
+
const integer = ((Math.round(args[0]) & 0xFF) << 16)
|
20563
|
+
+ ((Math.round(args[1]) & 0xFF) << 8)
|
20564
|
+
+ (Math.round(args[2]) & 0xFF);
|
20565
|
+
|
20566
|
+
const string = integer.toString(16).toUpperCase();
|
20567
|
+
return '000000'.substring(string.length) + string;
|
20568
|
+
};
|
20569
|
+
|
20570
|
+
convert.hex.rgb = function (args) {
|
20571
|
+
const match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
|
20572
|
+
if (!match) {
|
20573
|
+
return [0, 0, 0];
|
20574
|
+
}
|
20575
|
+
|
20576
|
+
let colorString = match[0];
|
20577
|
+
|
20578
|
+
if (match[0].length === 3) {
|
20579
|
+
colorString = colorString.split('').map(char => {
|
20580
|
+
return char + char;
|
20581
|
+
}).join('');
|
20582
|
+
}
|
20583
|
+
|
20584
|
+
const integer = parseInt(colorString, 16);
|
20585
|
+
const r = (integer >> 16) & 0xFF;
|
20586
|
+
const g = (integer >> 8) & 0xFF;
|
20587
|
+
const b = integer & 0xFF;
|
20588
|
+
|
20589
|
+
return [r, g, b];
|
20590
|
+
};
|
20591
|
+
|
20592
|
+
convert.rgb.hcg = function (rgb) {
|
20593
|
+
const r = rgb[0] / 255;
|
20594
|
+
const g = rgb[1] / 255;
|
20595
|
+
const b = rgb[2] / 255;
|
20596
|
+
const max = Math.max(Math.max(r, g), b);
|
20597
|
+
const min = Math.min(Math.min(r, g), b);
|
20598
|
+
const chroma = (max - min);
|
20599
|
+
let grayscale;
|
20600
|
+
let hue;
|
20601
|
+
|
20602
|
+
if (chroma < 1) {
|
20603
|
+
grayscale = min / (1 - chroma);
|
20604
|
+
} else {
|
20605
|
+
grayscale = 0;
|
20606
|
+
}
|
20607
|
+
|
20608
|
+
if (chroma <= 0) {
|
20609
|
+
hue = 0;
|
20610
|
+
} else
|
20611
|
+
if (max === r) {
|
20612
|
+
hue = ((g - b) / chroma) % 6;
|
20613
|
+
} else
|
20614
|
+
if (max === g) {
|
20615
|
+
hue = 2 + (b - r) / chroma;
|
20616
|
+
} else {
|
20617
|
+
hue = 4 + (r - g) / chroma;
|
20618
|
+
}
|
20619
|
+
|
20620
|
+
hue /= 6;
|
20621
|
+
hue %= 1;
|
20622
|
+
|
20623
|
+
return [hue * 360, chroma * 100, grayscale * 100];
|
20624
|
+
};
|
20625
|
+
|
20626
|
+
convert.hsl.hcg = function (hsl) {
|
20627
|
+
const s = hsl[1] / 100;
|
20628
|
+
const l = hsl[2] / 100;
|
20629
|
+
|
20630
|
+
const c = l < 0.5 ? (2.0 * s * l) : (2.0 * s * (1.0 - l));
|
20631
|
+
|
20632
|
+
let f = 0;
|
20633
|
+
if (c < 1.0) {
|
20634
|
+
f = (l - 0.5 * c) / (1.0 - c);
|
20635
|
+
}
|
20636
|
+
|
20637
|
+
return [hsl[0], c * 100, f * 100];
|
20638
|
+
};
|
20639
|
+
|
20640
|
+
convert.hsv.hcg = function (hsv) {
|
20641
|
+
const s = hsv[1] / 100;
|
20642
|
+
const v = hsv[2] / 100;
|
20643
|
+
|
20644
|
+
const c = s * v;
|
20645
|
+
let f = 0;
|
20646
|
+
|
20647
|
+
if (c < 1.0) {
|
20648
|
+
f = (v - c) / (1 - c);
|
20649
|
+
}
|
20650
|
+
|
20651
|
+
return [hsv[0], c * 100, f * 100];
|
20652
|
+
};
|
20653
|
+
|
20654
|
+
convert.hcg.rgb = function (hcg) {
|
20655
|
+
const h = hcg[0] / 360;
|
20656
|
+
const c = hcg[1] / 100;
|
20657
|
+
const g = hcg[2] / 100;
|
20658
|
+
|
20659
|
+
if (c === 0.0) {
|
20660
|
+
return [g * 255, g * 255, g * 255];
|
20661
|
+
}
|
20662
|
+
|
20663
|
+
const pure = [0, 0, 0];
|
20664
|
+
const hi = (h % 1) * 6;
|
20665
|
+
const v = hi % 1;
|
20666
|
+
const w = 1 - v;
|
20667
|
+
let mg = 0;
|
20668
|
+
|
20669
|
+
/* eslint-disable max-statements-per-line */
|
20670
|
+
switch (Math.floor(hi)) {
|
20671
|
+
case 0:
|
20672
|
+
pure[0] = 1; pure[1] = v; pure[2] = 0; break;
|
20673
|
+
case 1:
|
20674
|
+
pure[0] = w; pure[1] = 1; pure[2] = 0; break;
|
20675
|
+
case 2:
|
20676
|
+
pure[0] = 0; pure[1] = 1; pure[2] = v; break;
|
20677
|
+
case 3:
|
20678
|
+
pure[0] = 0; pure[1] = w; pure[2] = 1; break;
|
20679
|
+
case 4:
|
20680
|
+
pure[0] = v; pure[1] = 0; pure[2] = 1; break;
|
20681
|
+
default:
|
20682
|
+
pure[0] = 1; pure[1] = 0; pure[2] = w;
|
20683
|
+
}
|
20684
|
+
/* eslint-enable max-statements-per-line */
|
20685
|
+
|
20686
|
+
mg = (1.0 - c) * g;
|
20687
|
+
|
20688
|
+
return [
|
20689
|
+
(c * pure[0] + mg) * 255,
|
20690
|
+
(c * pure[1] + mg) * 255,
|
20691
|
+
(c * pure[2] + mg) * 255
|
20692
|
+
];
|
20693
|
+
};
|
20694
|
+
|
20695
|
+
convert.hcg.hsv = function (hcg) {
|
20696
|
+
const c = hcg[1] / 100;
|
20697
|
+
const g = hcg[2] / 100;
|
20698
|
+
|
20699
|
+
const v = c + g * (1.0 - c);
|
20700
|
+
let f = 0;
|
20701
|
+
|
20702
|
+
if (v > 0.0) {
|
20703
|
+
f = c / v;
|
20704
|
+
}
|
20705
|
+
|
20706
|
+
return [hcg[0], f * 100, v * 100];
|
20707
|
+
};
|
20708
|
+
|
20709
|
+
convert.hcg.hsl = function (hcg) {
|
20710
|
+
const c = hcg[1] / 100;
|
20711
|
+
const g = hcg[2] / 100;
|
20712
|
+
|
20713
|
+
const l = g * (1.0 - c) + 0.5 * c;
|
20714
|
+
let s = 0;
|
20715
|
+
|
20716
|
+
if (l > 0.0 && l < 0.5) {
|
20717
|
+
s = c / (2 * l);
|
20718
|
+
} else
|
20719
|
+
if (l >= 0.5 && l < 1.0) {
|
20720
|
+
s = c / (2 * (1 - l));
|
20721
|
+
}
|
20722
|
+
|
20723
|
+
return [hcg[0], s * 100, l * 100];
|
20724
|
+
};
|
20725
|
+
|
20726
|
+
convert.hcg.hwb = function (hcg) {
|
20727
|
+
const c = hcg[1] / 100;
|
20728
|
+
const g = hcg[2] / 100;
|
20729
|
+
const v = c + g * (1.0 - c);
|
20730
|
+
return [hcg[0], (v - c) * 100, (1 - v) * 100];
|
20731
|
+
};
|
20732
|
+
|
20733
|
+
convert.hwb.hcg = function (hwb) {
|
20734
|
+
const w = hwb[1] / 100;
|
20735
|
+
const b = hwb[2] / 100;
|
20736
|
+
const v = 1 - b;
|
20737
|
+
const c = v - w;
|
20738
|
+
let g = 0;
|
20739
|
+
|
20740
|
+
if (c < 1) {
|
20741
|
+
g = (v - c) / (1 - c);
|
20742
|
+
}
|
20743
|
+
|
20744
|
+
return [hwb[0], c * 100, g * 100];
|
20745
|
+
};
|
20746
|
+
|
20747
|
+
convert.apple.rgb = function (apple) {
|
20748
|
+
return [(apple[0] / 65535) * 255, (apple[1] / 65535) * 255, (apple[2] / 65535) * 255];
|
20749
|
+
};
|
20750
|
+
|
20751
|
+
convert.rgb.apple = function (rgb) {
|
20752
|
+
return [(rgb[0] / 255) * 65535, (rgb[1] / 255) * 65535, (rgb[2] / 255) * 65535];
|
20753
|
+
};
|
20754
|
+
|
20755
|
+
convert.gray.rgb = function (args) {
|
20756
|
+
return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];
|
20757
|
+
};
|
20758
|
+
|
20759
|
+
convert.gray.hsl = function (args) {
|
20760
|
+
return [0, 0, args[0]];
|
20761
|
+
};
|
20762
|
+
|
20763
|
+
convert.gray.hsv = convert.gray.hsl;
|
20764
|
+
|
20765
|
+
convert.gray.hwb = function (gray) {
|
20766
|
+
return [0, 100, gray[0]];
|
20767
|
+
};
|
20768
|
+
|
20769
|
+
convert.gray.cmyk = function (gray) {
|
20770
|
+
return [0, 0, 0, gray[0]];
|
20771
|
+
};
|
20772
|
+
|
20773
|
+
convert.gray.lab = function (gray) {
|
20774
|
+
return [gray[0], 0, 0];
|
20775
|
+
};
|
20776
|
+
|
20777
|
+
convert.gray.hex = function (gray) {
|
20778
|
+
const val = Math.round(gray[0] / 100 * 255) & 0xFF;
|
20779
|
+
const integer = (val << 16) + (val << 8) + val;
|
20780
|
+
|
20781
|
+
const string = integer.toString(16).toUpperCase();
|
20782
|
+
return '000000'.substring(string.length) + string;
|
20783
|
+
};
|
20784
|
+
|
20785
|
+
convert.rgb.gray = function (rgb) {
|
20786
|
+
const val = (rgb[0] + rgb[1] + rgb[2]) / 3;
|
20787
|
+
return [val / 255 * 100];
|
20788
|
+
};
|
20789
|
+
|
20790
|
+
|
20791
|
+
/***/ }),
|
20792
|
+
|
20793
|
+
/***/ 6931:
|
20794
|
+
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
20795
|
+
|
20796
|
+
const conversions = __nccwpck_require__(7391);
|
20797
|
+
const route = __nccwpck_require__(221);
|
20798
|
+
|
20799
|
+
const convert = {};
|
20800
|
+
|
20801
|
+
const models = Object.keys(conversions);
|
20802
|
+
|
20803
|
+
function wrapRaw(fn) {
|
20804
|
+
const wrappedFn = function (...args) {
|
20805
|
+
const arg0 = args[0];
|
20806
|
+
if (arg0 === undefined || arg0 === null) {
|
20807
|
+
return arg0;
|
20808
|
+
}
|
20809
|
+
|
20810
|
+
if (arg0.length > 1) {
|
20811
|
+
args = arg0;
|
20812
|
+
}
|
20813
|
+
|
20814
|
+
return fn(args);
|
20815
|
+
};
|
20816
|
+
|
20817
|
+
// Preserve .conversion property if there is one
|
20818
|
+
if ('conversion' in fn) {
|
20819
|
+
wrappedFn.conversion = fn.conversion;
|
20820
|
+
}
|
20821
|
+
|
20822
|
+
return wrappedFn;
|
20823
|
+
}
|
20824
|
+
|
20825
|
+
function wrapRounded(fn) {
|
20826
|
+
const wrappedFn = function (...args) {
|
20827
|
+
const arg0 = args[0];
|
20828
|
+
|
20829
|
+
if (arg0 === undefined || arg0 === null) {
|
20830
|
+
return arg0;
|
20831
|
+
}
|
20832
|
+
|
20833
|
+
if (arg0.length > 1) {
|
20834
|
+
args = arg0;
|
20835
|
+
}
|
20836
|
+
|
20837
|
+
const result = fn(args);
|
20838
|
+
|
20839
|
+
// We're assuming the result is an array here.
|
20840
|
+
// see notice in conversions.js; don't use box types
|
20841
|
+
// in conversion functions.
|
20842
|
+
if (typeof result === 'object') {
|
20843
|
+
for (let len = result.length, i = 0; i < len; i++) {
|
20844
|
+
result[i] = Math.round(result[i]);
|
20845
|
+
}
|
20846
|
+
}
|
20847
|
+
|
20848
|
+
return result;
|
20849
|
+
};
|
20850
|
+
|
20851
|
+
// Preserve .conversion property if there is one
|
20852
|
+
if ('conversion' in fn) {
|
20853
|
+
wrappedFn.conversion = fn.conversion;
|
20854
|
+
}
|
20855
|
+
|
20856
|
+
return wrappedFn;
|
20857
|
+
}
|
20858
|
+
|
20859
|
+
models.forEach(fromModel => {
|
20860
|
+
convert[fromModel] = {};
|
20861
|
+
|
20862
|
+
Object.defineProperty(convert[fromModel], 'channels', {value: conversions[fromModel].channels});
|
20863
|
+
Object.defineProperty(convert[fromModel], 'labels', {value: conversions[fromModel].labels});
|
20864
|
+
|
20865
|
+
const routes = route(fromModel);
|
20866
|
+
const routeModels = Object.keys(routes);
|
20867
|
+
|
20868
|
+
routeModels.forEach(toModel => {
|
20869
|
+
const fn = routes[toModel];
|
20870
|
+
|
20871
|
+
convert[fromModel][toModel] = wrapRounded(fn);
|
20872
|
+
convert[fromModel][toModel].raw = wrapRaw(fn);
|
20873
|
+
});
|
20874
|
+
});
|
20875
|
+
|
20876
|
+
module.exports = convert;
|
20877
|
+
|
20878
|
+
|
20879
|
+
/***/ }),
|
20880
|
+
|
20881
|
+
/***/ 221:
|
20882
|
+
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
20883
|
+
|
20884
|
+
const conversions = __nccwpck_require__(7391);
|
20885
|
+
|
20886
|
+
/*
|
20887
|
+
This function routes a model to all other models.
|
20888
|
+
|
20889
|
+
all functions that are routed have a property `.conversion` attached
|
20890
|
+
to the returned synthetic function. This property is an array
|
20891
|
+
of strings, each with the steps in between the 'from' and 'to'
|
20892
|
+
color models (inclusive).
|
20893
|
+
|
20894
|
+
conversions that are not possible simply are not included.
|
20895
|
+
*/
|
20896
|
+
|
20897
|
+
function buildGraph() {
|
20898
|
+
const graph = {};
|
20899
|
+
// https://jsperf.com/object-keys-vs-for-in-with-closure/3
|
20900
|
+
const models = Object.keys(conversions);
|
20901
|
+
|
20902
|
+
for (let len = models.length, i = 0; i < len; i++) {
|
20903
|
+
graph[models[i]] = {
|
20904
|
+
// http://jsperf.com/1-vs-infinity
|
20905
|
+
// micro-opt, but this is simple.
|
20906
|
+
distance: -1,
|
20907
|
+
parent: null
|
20908
|
+
};
|
20909
|
+
}
|
20910
|
+
|
20911
|
+
return graph;
|
20912
|
+
}
|
20913
|
+
|
20914
|
+
// https://en.wikipedia.org/wiki/Breadth-first_search
|
20915
|
+
function deriveBFS(fromModel) {
|
20916
|
+
const graph = buildGraph();
|
20917
|
+
const queue = [fromModel]; // Unshift -> queue -> pop
|
20918
|
+
|
20919
|
+
graph[fromModel].distance = 0;
|
20920
|
+
|
20921
|
+
while (queue.length) {
|
20922
|
+
const current = queue.pop();
|
20923
|
+
const adjacents = Object.keys(conversions[current]);
|
20924
|
+
|
20925
|
+
for (let len = adjacents.length, i = 0; i < len; i++) {
|
20926
|
+
const adjacent = adjacents[i];
|
20927
|
+
const node = graph[adjacent];
|
20928
|
+
|
20929
|
+
if (node.distance === -1) {
|
20930
|
+
node.distance = graph[current].distance + 1;
|
20931
|
+
node.parent = current;
|
20932
|
+
queue.unshift(adjacent);
|
20933
|
+
}
|
20934
|
+
}
|
20935
|
+
}
|
20936
|
+
|
20937
|
+
return graph;
|
20938
|
+
}
|
20939
|
+
|
20940
|
+
function link(from, to) {
|
20941
|
+
return function (args) {
|
20942
|
+
return to(from(args));
|
20943
|
+
};
|
20944
|
+
}
|
20945
|
+
|
20946
|
+
function wrapConversion(toModel, graph) {
|
20947
|
+
const path = [graph[toModel].parent, toModel];
|
20948
|
+
let fn = conversions[graph[toModel].parent][toModel];
|
20949
|
+
|
20950
|
+
let cur = graph[toModel].parent;
|
20951
|
+
while (graph[cur].parent) {
|
20952
|
+
path.unshift(graph[cur].parent);
|
20953
|
+
fn = link(conversions[graph[cur].parent][cur], fn);
|
20954
|
+
cur = graph[cur].parent;
|
20955
|
+
}
|
20956
|
+
|
20957
|
+
fn.conversion = path;
|
20958
|
+
return fn;
|
20959
|
+
}
|
20960
|
+
|
20961
|
+
module.exports = function (fromModel) {
|
20962
|
+
const graph = deriveBFS(fromModel);
|
20963
|
+
const conversion = {};
|
20964
|
+
|
20965
|
+
const models = Object.keys(graph);
|
20966
|
+
for (let len = models.length, i = 0; i < len; i++) {
|
20967
|
+
const toModel = models[i];
|
20968
|
+
const node = graph[toModel];
|
20969
|
+
|
20970
|
+
if (node.parent === null) {
|
20971
|
+
// No possible conversion, or this node is the source model.
|
20972
|
+
continue;
|
20973
|
+
}
|
20974
|
+
|
20975
|
+
conversion[toModel] = wrapConversion(toModel, graph);
|
20976
|
+
}
|
20977
|
+
|
20978
|
+
return conversion;
|
20979
|
+
};
|
20980
|
+
|
20981
|
+
|
20982
|
+
|
20983
|
+
/***/ }),
|
20984
|
+
|
20985
|
+
/***/ 8510:
|
20986
|
+
/***/ ((module) => {
|
20987
|
+
|
20988
|
+
"use strict";
|
20989
|
+
|
20990
|
+
|
20991
|
+
module.exports = {
|
20992
|
+
"aliceblue": [240, 248, 255],
|
20993
|
+
"antiquewhite": [250, 235, 215],
|
20994
|
+
"aqua": [0, 255, 255],
|
20995
|
+
"aquamarine": [127, 255, 212],
|
20996
|
+
"azure": [240, 255, 255],
|
20997
|
+
"beige": [245, 245, 220],
|
20998
|
+
"bisque": [255, 228, 196],
|
20999
|
+
"black": [0, 0, 0],
|
21000
|
+
"blanchedalmond": [255, 235, 205],
|
21001
|
+
"blue": [0, 0, 255],
|
21002
|
+
"blueviolet": [138, 43, 226],
|
21003
|
+
"brown": [165, 42, 42],
|
21004
|
+
"burlywood": [222, 184, 135],
|
21005
|
+
"cadetblue": [95, 158, 160],
|
21006
|
+
"chartreuse": [127, 255, 0],
|
21007
|
+
"chocolate": [210, 105, 30],
|
21008
|
+
"coral": [255, 127, 80],
|
21009
|
+
"cornflowerblue": [100, 149, 237],
|
21010
|
+
"cornsilk": [255, 248, 220],
|
21011
|
+
"crimson": [220, 20, 60],
|
21012
|
+
"cyan": [0, 255, 255],
|
21013
|
+
"darkblue": [0, 0, 139],
|
21014
|
+
"darkcyan": [0, 139, 139],
|
21015
|
+
"darkgoldenrod": [184, 134, 11],
|
21016
|
+
"darkgray": [169, 169, 169],
|
21017
|
+
"darkgreen": [0, 100, 0],
|
21018
|
+
"darkgrey": [169, 169, 169],
|
21019
|
+
"darkkhaki": [189, 183, 107],
|
21020
|
+
"darkmagenta": [139, 0, 139],
|
21021
|
+
"darkolivegreen": [85, 107, 47],
|
21022
|
+
"darkorange": [255, 140, 0],
|
21023
|
+
"darkorchid": [153, 50, 204],
|
21024
|
+
"darkred": [139, 0, 0],
|
21025
|
+
"darksalmon": [233, 150, 122],
|
21026
|
+
"darkseagreen": [143, 188, 143],
|
21027
|
+
"darkslateblue": [72, 61, 139],
|
21028
|
+
"darkslategray": [47, 79, 79],
|
21029
|
+
"darkslategrey": [47, 79, 79],
|
21030
|
+
"darkturquoise": [0, 206, 209],
|
21031
|
+
"darkviolet": [148, 0, 211],
|
21032
|
+
"deeppink": [255, 20, 147],
|
21033
|
+
"deepskyblue": [0, 191, 255],
|
21034
|
+
"dimgray": [105, 105, 105],
|
21035
|
+
"dimgrey": [105, 105, 105],
|
21036
|
+
"dodgerblue": [30, 144, 255],
|
21037
|
+
"firebrick": [178, 34, 34],
|
21038
|
+
"floralwhite": [255, 250, 240],
|
21039
|
+
"forestgreen": [34, 139, 34],
|
21040
|
+
"fuchsia": [255, 0, 255],
|
21041
|
+
"gainsboro": [220, 220, 220],
|
21042
|
+
"ghostwhite": [248, 248, 255],
|
21043
|
+
"gold": [255, 215, 0],
|
21044
|
+
"goldenrod": [218, 165, 32],
|
21045
|
+
"gray": [128, 128, 128],
|
21046
|
+
"green": [0, 128, 0],
|
21047
|
+
"greenyellow": [173, 255, 47],
|
21048
|
+
"grey": [128, 128, 128],
|
21049
|
+
"honeydew": [240, 255, 240],
|
21050
|
+
"hotpink": [255, 105, 180],
|
21051
|
+
"indianred": [205, 92, 92],
|
21052
|
+
"indigo": [75, 0, 130],
|
21053
|
+
"ivory": [255, 255, 240],
|
21054
|
+
"khaki": [240, 230, 140],
|
21055
|
+
"lavender": [230, 230, 250],
|
21056
|
+
"lavenderblush": [255, 240, 245],
|
21057
|
+
"lawngreen": [124, 252, 0],
|
21058
|
+
"lemonchiffon": [255, 250, 205],
|
21059
|
+
"lightblue": [173, 216, 230],
|
21060
|
+
"lightcoral": [240, 128, 128],
|
21061
|
+
"lightcyan": [224, 255, 255],
|
21062
|
+
"lightgoldenrodyellow": [250, 250, 210],
|
21063
|
+
"lightgray": [211, 211, 211],
|
21064
|
+
"lightgreen": [144, 238, 144],
|
21065
|
+
"lightgrey": [211, 211, 211],
|
21066
|
+
"lightpink": [255, 182, 193],
|
21067
|
+
"lightsalmon": [255, 160, 122],
|
21068
|
+
"lightseagreen": [32, 178, 170],
|
21069
|
+
"lightskyblue": [135, 206, 250],
|
21070
|
+
"lightslategray": [119, 136, 153],
|
21071
|
+
"lightslategrey": [119, 136, 153],
|
21072
|
+
"lightsteelblue": [176, 196, 222],
|
21073
|
+
"lightyellow": [255, 255, 224],
|
21074
|
+
"lime": [0, 255, 0],
|
21075
|
+
"limegreen": [50, 205, 50],
|
21076
|
+
"linen": [250, 240, 230],
|
21077
|
+
"magenta": [255, 0, 255],
|
21078
|
+
"maroon": [128, 0, 0],
|
21079
|
+
"mediumaquamarine": [102, 205, 170],
|
21080
|
+
"mediumblue": [0, 0, 205],
|
21081
|
+
"mediumorchid": [186, 85, 211],
|
21082
|
+
"mediumpurple": [147, 112, 219],
|
21083
|
+
"mediumseagreen": [60, 179, 113],
|
21084
|
+
"mediumslateblue": [123, 104, 238],
|
21085
|
+
"mediumspringgreen": [0, 250, 154],
|
21086
|
+
"mediumturquoise": [72, 209, 204],
|
21087
|
+
"mediumvioletred": [199, 21, 133],
|
21088
|
+
"midnightblue": [25, 25, 112],
|
21089
|
+
"mintcream": [245, 255, 250],
|
21090
|
+
"mistyrose": [255, 228, 225],
|
21091
|
+
"moccasin": [255, 228, 181],
|
21092
|
+
"navajowhite": [255, 222, 173],
|
21093
|
+
"navy": [0, 0, 128],
|
21094
|
+
"oldlace": [253, 245, 230],
|
21095
|
+
"olive": [128, 128, 0],
|
21096
|
+
"olivedrab": [107, 142, 35],
|
21097
|
+
"orange": [255, 165, 0],
|
21098
|
+
"orangered": [255, 69, 0],
|
21099
|
+
"orchid": [218, 112, 214],
|
21100
|
+
"palegoldenrod": [238, 232, 170],
|
21101
|
+
"palegreen": [152, 251, 152],
|
21102
|
+
"paleturquoise": [175, 238, 238],
|
21103
|
+
"palevioletred": [219, 112, 147],
|
21104
|
+
"papayawhip": [255, 239, 213],
|
21105
|
+
"peachpuff": [255, 218, 185],
|
21106
|
+
"peru": [205, 133, 63],
|
21107
|
+
"pink": [255, 192, 203],
|
21108
|
+
"plum": [221, 160, 221],
|
21109
|
+
"powderblue": [176, 224, 230],
|
21110
|
+
"purple": [128, 0, 128],
|
21111
|
+
"rebeccapurple": [102, 51, 153],
|
21112
|
+
"red": [255, 0, 0],
|
21113
|
+
"rosybrown": [188, 143, 143],
|
21114
|
+
"royalblue": [65, 105, 225],
|
21115
|
+
"saddlebrown": [139, 69, 19],
|
21116
|
+
"salmon": [250, 128, 114],
|
21117
|
+
"sandybrown": [244, 164, 96],
|
21118
|
+
"seagreen": [46, 139, 87],
|
21119
|
+
"seashell": [255, 245, 238],
|
21120
|
+
"sienna": [160, 82, 45],
|
21121
|
+
"silver": [192, 192, 192],
|
21122
|
+
"skyblue": [135, 206, 235],
|
21123
|
+
"slateblue": [106, 90, 205],
|
21124
|
+
"slategray": [112, 128, 144],
|
21125
|
+
"slategrey": [112, 128, 144],
|
21126
|
+
"snow": [255, 250, 250],
|
21127
|
+
"springgreen": [0, 255, 127],
|
21128
|
+
"steelblue": [70, 130, 180],
|
21129
|
+
"tan": [210, 180, 140],
|
21130
|
+
"teal": [0, 128, 128],
|
21131
|
+
"thistle": [216, 191, 216],
|
21132
|
+
"tomato": [255, 99, 71],
|
21133
|
+
"turquoise": [64, 224, 208],
|
21134
|
+
"violet": [238, 130, 238],
|
21135
|
+
"wheat": [245, 222, 179],
|
21136
|
+
"white": [255, 255, 255],
|
21137
|
+
"whitesmoke": [245, 245, 245],
|
21138
|
+
"yellow": [255, 255, 0],
|
21139
|
+
"yellowgreen": [154, 205, 50]
|
21140
|
+
};
|
21141
|
+
|
21142
|
+
|
19337
21143
|
/***/ }),
|
19338
21144
|
|
19339
21145
|
/***/ 4697:
|
@@ -51257,8 +53063,8 @@ module.exports = {"i8":"3.0.2"};
|
|
51257
53063
|
/******/ }
|
51258
53064
|
/******/ // Create a new module (and put it into the cache)
|
51259
53065
|
/******/ var module = __webpack_module_cache__[moduleId] = {
|
51260
|
-
/******/
|
51261
|
-
/******/
|
53066
|
+
/******/ id: moduleId,
|
53067
|
+
/******/ loaded: false,
|
51262
53068
|
/******/ exports: {}
|
51263
53069
|
/******/ };
|
51264
53070
|
/******/
|
@@ -51271,6 +53077,9 @@ module.exports = {"i8":"3.0.2"};
|
|
51271
53077
|
/******/ if(threw) delete __webpack_module_cache__[moduleId];
|
51272
53078
|
/******/ }
|
51273
53079
|
/******/
|
53080
|
+
/******/ // Flag the module as loaded
|
53081
|
+
/******/ module.loaded = true;
|
53082
|
+
/******/
|
51274
53083
|
/******/ // Return the exports of the module
|
51275
53084
|
/******/ return module.exports;
|
51276
53085
|
/******/ }
|
@@ -51316,6 +53125,15 @@ module.exports = {"i8":"3.0.2"};
|
|
51316
53125
|
/******/ };
|
51317
53126
|
/******/ })();
|
51318
53127
|
/******/
|
53128
|
+
/******/ /* webpack/runtime/node module decorator */
|
53129
|
+
/******/ (() => {
|
53130
|
+
/******/ __nccwpck_require__.nmd = (module) => {
|
53131
|
+
/******/ module.paths = [];
|
53132
|
+
/******/ if (!module.children) module.children = [];
|
53133
|
+
/******/ return module;
|
53134
|
+
/******/ };
|
53135
|
+
/******/ })();
|
53136
|
+
/******/
|
51319
53137
|
/******/ /* webpack/runtime/compat */
|
51320
53138
|
/******/
|
51321
53139
|
/******/ if (typeof __nccwpck_require__ !== 'undefined') __nccwpck_require__.ab = __dirname + "/";
|