Spaces:
Paused
Paused
Upload folder using huggingface_hub
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- .gitattributes +0 -19
- node_modules/@asamuzakjp/css-color/dist/esm/index.d.ts +0 -20
- node_modules/@asamuzakjp/css-color/dist/esm/index.js +0 -29
- node_modules/@asamuzakjp/css-color/dist/esm/index.js.map +0 -1
- node_modules/@asamuzakjp/css-color/dist/esm/js/cache.d.ts +0 -38
- node_modules/@asamuzakjp/css-color/dist/esm/js/cache.js +0 -90
- node_modules/@asamuzakjp/css-color/dist/esm/js/cache.js.map +0 -1
- node_modules/@asamuzakjp/css-color/dist/esm/js/color.d.ts +0 -537
- node_modules/@asamuzakjp/css-color/dist/esm/js/color.js +0 -3534
- node_modules/@asamuzakjp/css-color/dist/esm/js/color.js.map +0 -0
- node_modules/@asamuzakjp/css-color/dist/esm/js/common.d.ts +0 -21
- node_modules/@asamuzakjp/css-color/dist/esm/js/common.js +0 -17
- node_modules/@asamuzakjp/css-color/dist/esm/js/common.js.map +0 -1
- node_modules/@asamuzakjp/css-color/dist/esm/js/constant.d.ts +0 -43
- node_modules/@asamuzakjp/css-color/dist/esm/js/constant.js +0 -60
- node_modules/@asamuzakjp/css-color/dist/esm/js/constant.js.map +0 -1
- node_modules/@asamuzakjp/css-color/dist/esm/js/convert.d.ts +0 -99
- node_modules/@asamuzakjp/css-color/dist/esm/js/convert.js +0 -245
- node_modules/@asamuzakjp/css-color/dist/esm/js/convert.js.map +0 -1
- node_modules/@asamuzakjp/css-color/dist/esm/js/css-calc.d.ts +0 -89
- node_modules/@asamuzakjp/css-color/dist/esm/js/css-calc.js +0 -636
- node_modules/@asamuzakjp/css-color/dist/esm/js/css-calc.js.map +0 -1
- node_modules/@asamuzakjp/css-color/dist/esm/js/css-gradient.d.ts +0 -79
- node_modules/@asamuzakjp/css-color/dist/esm/js/css-gradient.js +0 -291
- node_modules/@asamuzakjp/css-color/dist/esm/js/css-gradient.js.map +0 -1
- node_modules/@asamuzakjp/css-color/dist/esm/js/css-var.d.ts +0 -31
- node_modules/@asamuzakjp/css-color/dist/esm/js/css-var.js +0 -144
- node_modules/@asamuzakjp/css-color/dist/esm/js/css-var.js.map +0 -1
- node_modules/@asamuzakjp/css-color/dist/esm/js/relative-color.d.ts +0 -65
- node_modules/@asamuzakjp/css-color/dist/esm/js/relative-color.js +0 -451
- node_modules/@asamuzakjp/css-color/dist/esm/js/relative-color.js.map +0 -1
- node_modules/@asamuzakjp/css-color/dist/esm/js/resolve.d.ts +0 -15
- node_modules/@asamuzakjp/css-color/dist/esm/js/resolve.js +0 -210
- node_modules/@asamuzakjp/css-color/dist/esm/js/resolve.js.map +0 -1
- node_modules/@asamuzakjp/css-color/dist/esm/js/typedef.d.ts +0 -80
- node_modules/@asamuzakjp/css-color/dist/esm/js/util.d.ts +0 -59
- node_modules/@asamuzakjp/css-color/dist/esm/js/util.js +0 -274
- node_modules/@asamuzakjp/css-color/dist/esm/js/util.js.map +0 -1
- node_modules/@babel/core/node_modules/.bin/semver +0 -174
- node_modules/@babel/core/node_modules/semver/LICENSE +0 -15
- node_modules/@babel/core/node_modules/semver/README.md +0 -443
- node_modules/@babel/core/node_modules/semver/bin/semver.js +0 -174
- node_modules/@babel/core/node_modules/semver/package.json +0 -38
- node_modules/@babel/core/node_modules/semver/range.bnf +0 -16
- node_modules/@babel/core/node_modules/semver/semver.js +0 -1643
- node_modules/@babel/helper-compilation-targets/node_modules/.bin/semver +0 -174
- node_modules/@babel/helper-compilation-targets/node_modules/semver/LICENSE +0 -15
- node_modules/@babel/helper-compilation-targets/node_modules/semver/README.md +0 -443
- node_modules/@babel/helper-compilation-targets/node_modules/semver/bin/semver.js +0 -174
- node_modules/@babel/helper-compilation-targets/node_modules/semver/package.json +0 -38
.gitattributes
CHANGED
|
@@ -25,22 +25,3 @@
|
|
| 25 |
*.eot binary
|
| 26 |
*.pdf binary
|
| 27 |
*.zip binary
|
| 28 |
-
node_modules/@jimp/js-bmp/src/images/windows95.bmp filter=lfs diff=lfs merge=lfs -text
|
| 29 |
-
node_modules/@jimp/js-bmp/src/images/windows95.png filter=lfs diff=lfs merge=lfs -text
|
| 30 |
-
node_modules/@jimp/plugin-blit/src/__image_snapshots__/index-node-test-ts-blit-over-image-blit-alpha-1-snap.png filter=lfs diff=lfs merge=lfs -text
|
| 31 |
-
node_modules/@jimp/plugin-blit/src/images/blit-alpha.png filter=lfs diff=lfs merge=lfs -text
|
| 32 |
-
node_modules/@jimp/plugin-blur/src/__image_snapshots__/index-node-test-ts-has-alpha-image-with-alpha-1-snap.png filter=lfs diff=lfs merge=lfs -text
|
| 33 |
-
node_modules/@jimp/plugin-color/src/__image_snapshots__/convolution-node-test-ts-convolution-new-pixel-value-is-greater-than-255-1-snap.png filter=lfs diff=lfs merge=lfs -text
|
| 34 |
-
node_modules/@jimp/plugin-color/src/images/qr.jpg filter=lfs diff=lfs merge=lfs -text
|
| 35 |
-
node_modules/@jimp/plugin-print/dist/fonts/open-sans/open-sans-128-black/open-sans-128-black.png filter=lfs diff=lfs merge=lfs -text
|
| 36 |
-
node_modules/@jimp/plugin-print/dist/fonts/open-sans/open-sans-128-white/open-sans-128-white.png filter=lfs diff=lfs merge=lfs -text
|
| 37 |
-
node_modules/@jimp/plugin-print/fonts/open-sans/open-sans-128-black/open-sans-128-black.png filter=lfs diff=lfs merge=lfs -text
|
| 38 |
-
node_modules/@jimp/plugin-print/fonts/open-sans/open-sans-128-white/open-sans-128-white.png filter=lfs diff=lfs merge=lfs -text
|
| 39 |
-
node_modules/@jimp/plugin-threshold/src/__image_snapshots__/index-test-ts-src-index-test-ts-threshold-defines-default-threshold-for-lighter-backgrounds-1-snap.png filter=lfs diff=lfs merge=lfs -text
|
| 40 |
-
node_modules/@rolldown/binding-linux-x64-gnu/rolldown-binding.linux-x64-gnu.node filter=lfs diff=lfs merge=lfs -text
|
| 41 |
-
node_modules/@rolldown/binding-linux-x64-musl/rolldown-binding.linux-x64-musl.node filter=lfs diff=lfs merge=lfs -text
|
| 42 |
-
node_modules/@rollup/rollup-linux-x64-gnu/rollup.linux-x64-gnu.node filter=lfs diff=lfs merge=lfs -text
|
| 43 |
-
node_modules/@rollup/rollup-linux-x64-musl/rollup.linux-x64-musl.node filter=lfs diff=lfs merge=lfs -text
|
| 44 |
-
node_modules/@swc/core-linux-x64-gnu/swc.linux-x64-gnu.node filter=lfs diff=lfs merge=lfs -text
|
| 45 |
-
node_modules/@swc/core-linux-x64-musl/swc.linux-x64-musl.node filter=lfs diff=lfs merge=lfs -text
|
| 46 |
-
node_modules/@trivago/prettier-plugin-sort-imports/.yarn/install-state.gz filter=lfs diff=lfs merge=lfs -text
|
|
|
|
| 25 |
*.eot binary
|
| 26 |
*.pdf binary
|
| 27 |
*.zip binary
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
node_modules/@asamuzakjp/css-color/dist/esm/index.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
| 1 |
-
/*!
|
| 2 |
-
* CSS color - Resolve, parse, convert CSS color.
|
| 3 |
-
* @license MIT
|
| 4 |
-
* @copyright asamuzaK (Kazz)
|
| 5 |
-
* @see {@link https://github.com/asamuzaK/cssColor/blob/main/LICENSE}
|
| 6 |
-
*/
|
| 7 |
-
export { convert } from './js/convert.js';
|
| 8 |
-
export { resolve } from './js/resolve.js';
|
| 9 |
-
export declare const utils: {
|
| 10 |
-
cssCalc: (value: string, opt?: import('./js/typedef.js').Options) => string;
|
| 11 |
-
cssVar: (value: string, opt?: import('./js/typedef.js').Options) => string;
|
| 12 |
-
extractDashedIdent: (value: string) => string[];
|
| 13 |
-
isAbsoluteFontSize: (css: unknown) => boolean;
|
| 14 |
-
isAbsoluteSizeOrLength: (value: number | string, unit: string | undefined) => boolean;
|
| 15 |
-
isColor: (value: unknown, opt?: import('./js/typedef.js').Options) => boolean;
|
| 16 |
-
isGradient: (value: string, opt?: import('./js/typedef.js').Options) => boolean;
|
| 17 |
-
resolveGradient: (value: string, opt?: import('./js/typedef.js').Options) => string;
|
| 18 |
-
resolveLengthInPixels: (value: number | string, unit: string | undefined, opt?: import('./js/typedef.js').Options) => number;
|
| 19 |
-
splitValue: (value: string, opt?: import('./js/typedef.js').Options) => string[];
|
| 20 |
-
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
node_modules/@asamuzakjp/css-color/dist/esm/index.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
| 1 |
-
import { resolve } from "./js/resolve.js";
|
| 2 |
-
import { extractDashedIdent, isAbsoluteFontSize, isAbsoluteSizeOrLength, isColor, resolveLengthInPixels, splitValue } from "./js/util.js";
|
| 3 |
-
import { cssVar } from "./js/css-var.js";
|
| 4 |
-
import { cssCalc } from "./js/css-calc.js";
|
| 5 |
-
import { isGradient, resolveGradient } from "./js/css-gradient.js";
|
| 6 |
-
import { convert } from "./js/convert.js";
|
| 7 |
-
//#region src/index.ts
|
| 8 |
-
/*!
|
| 9 |
-
* CSS color - Resolve, parse, convert CSS color.
|
| 10 |
-
* @license MIT
|
| 11 |
-
* @copyright asamuzaK (Kazz)
|
| 12 |
-
* @see {@link https://github.com/asamuzaK/cssColor/blob/main/LICENSE}
|
| 13 |
-
*/
|
| 14 |
-
var utils = {
|
| 15 |
-
cssCalc,
|
| 16 |
-
cssVar,
|
| 17 |
-
extractDashedIdent,
|
| 18 |
-
isAbsoluteFontSize,
|
| 19 |
-
isAbsoluteSizeOrLength,
|
| 20 |
-
isColor,
|
| 21 |
-
isGradient,
|
| 22 |
-
resolveGradient,
|
| 23 |
-
resolveLengthInPixels,
|
| 24 |
-
splitValue
|
| 25 |
-
};
|
| 26 |
-
//#endregion
|
| 27 |
-
export { convert, resolve, utils };
|
| 28 |
-
|
| 29 |
-
//# sourceMappingURL=index.js.map
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
node_modules/@asamuzakjp/css-color/dist/esm/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/index.ts"],"sourcesContent":["/*!\n * CSS color - Resolve, parse, convert CSS color.\n * @license MIT\n * @copyright asamuzaK (Kazz)\n * @see {@link https://github.com/asamuzaK/cssColor/blob/main/LICENSE}\n */\n\nimport { cssCalc } from './js/css-calc';\nimport { isGradient, resolveGradient } from './js/css-gradient';\nimport { cssVar } from './js/css-var';\nimport {\n extractDashedIdent,\n isAbsoluteFontSize,\n isAbsoluteSizeOrLength,\n isColor,\n resolveLengthInPixels,\n splitValue\n} from './js/util';\n\nexport { convert } from './js/convert';\nexport { resolve } from './js/resolve';\n/* utils */\nexport const utils = {\n cssCalc,\n cssVar,\n extractDashedIdent,\n isAbsoluteFontSize,\n isAbsoluteSizeOrLength,\n isColor,\n isGradient,\n resolveGradient,\n resolveLengthInPixels,\n splitValue\n};\n"],"mappings":";;;;;;;;;;;;;AAsBA,IAAa,QAAQ;CACnB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD"}
|
|
|
|
|
|
node_modules/@asamuzakjp/css-color/dist/esm/js/cache.d.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
| 1 |
-
import { GenerationalCache } from '@asamuzakjp/generational-cache';
|
| 2 |
-
import { Options } from './typedef.js';
|
| 3 |
-
/**
|
| 4 |
-
* CacheItem
|
| 5 |
-
*/
|
| 6 |
-
export declare class CacheItem {
|
| 7 |
-
#private;
|
| 8 |
-
constructor(item: unknown, isNull?: boolean);
|
| 9 |
-
get item(): unknown;
|
| 10 |
-
get isNull(): boolean;
|
| 11 |
-
}
|
| 12 |
-
/**
|
| 13 |
-
* NullObject
|
| 14 |
-
*/
|
| 15 |
-
export declare class NullObject extends CacheItem {
|
| 16 |
-
constructor();
|
| 17 |
-
}
|
| 18 |
-
export declare const genCache: GenerationalCache<string, CacheItem>;
|
| 19 |
-
/**
|
| 20 |
-
* set cache
|
| 21 |
-
* @param key - cache key
|
| 22 |
-
* @param value - value to cache
|
| 23 |
-
* @returns void
|
| 24 |
-
*/
|
| 25 |
-
export declare const setCache: (key: string, value: unknown) => void;
|
| 26 |
-
/**
|
| 27 |
-
* get cache
|
| 28 |
-
* @param key - cache key
|
| 29 |
-
* @returns cached item or false otherwise
|
| 30 |
-
*/
|
| 31 |
-
export declare const getCache: (key: string) => CacheItem | false;
|
| 32 |
-
/**
|
| 33 |
-
* create cache key
|
| 34 |
-
* @param keyData - key data
|
| 35 |
-
* @param [opt] - options
|
| 36 |
-
* @returns cache key
|
| 37 |
-
*/
|
| 38 |
-
export declare const createCacheKey: (keyData: Record<string, string>, opt?: Options) => string;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
node_modules/@asamuzakjp/css-color/dist/esm/js/cache.js
DELETED
|
@@ -1,90 +0,0 @@
|
|
| 1 |
-
import { GenerationalCache } from "@asamuzakjp/generational-cache";
|
| 2 |
-
//#region src/js/cache.ts
|
| 3 |
-
/**
|
| 4 |
-
* cache
|
| 5 |
-
*/
|
| 6 |
-
var CACHE_SIZE = 2048;
|
| 7 |
-
/**
|
| 8 |
-
* CacheItem
|
| 9 |
-
*/
|
| 10 |
-
var CacheItem = class {
|
| 11 |
-
#isNull;
|
| 12 |
-
#item;
|
| 13 |
-
constructor(item, isNull = false) {
|
| 14 |
-
this.#item = item;
|
| 15 |
-
this.#isNull = !!isNull;
|
| 16 |
-
}
|
| 17 |
-
get item() {
|
| 18 |
-
return this.#item;
|
| 19 |
-
}
|
| 20 |
-
get isNull() {
|
| 21 |
-
return this.#isNull;
|
| 22 |
-
}
|
| 23 |
-
};
|
| 24 |
-
/**
|
| 25 |
-
* NullObject
|
| 26 |
-
*/
|
| 27 |
-
var NullObject = class extends CacheItem {
|
| 28 |
-
constructor() {
|
| 29 |
-
super(Symbol("null"), true);
|
| 30 |
-
}
|
| 31 |
-
};
|
| 32 |
-
var genCache = new GenerationalCache(CACHE_SIZE);
|
| 33 |
-
/**
|
| 34 |
-
* shared null object
|
| 35 |
-
*/
|
| 36 |
-
var sharedNullObject = new NullObject();
|
| 37 |
-
/**
|
| 38 |
-
* set cache
|
| 39 |
-
* @param key - cache key
|
| 40 |
-
* @param value - value to cache
|
| 41 |
-
* @returns void
|
| 42 |
-
*/
|
| 43 |
-
var setCache = (key, value) => {
|
| 44 |
-
if (!key) return;
|
| 45 |
-
if (value === null) genCache.set(key, sharedNullObject);
|
| 46 |
-
else if (value instanceof CacheItem) genCache.set(key, value);
|
| 47 |
-
else genCache.set(key, new CacheItem(value));
|
| 48 |
-
};
|
| 49 |
-
/**
|
| 50 |
-
* get cache
|
| 51 |
-
* @param key - cache key
|
| 52 |
-
* @returns cached item or false otherwise
|
| 53 |
-
*/
|
| 54 |
-
var getCache = (key) => {
|
| 55 |
-
if (!key) return false;
|
| 56 |
-
const item = genCache.get(key);
|
| 57 |
-
if (item !== void 0) return item;
|
| 58 |
-
return false;
|
| 59 |
-
};
|
| 60 |
-
/**
|
| 61 |
-
* helper function to sort object keys alphabetically
|
| 62 |
-
* @param obj - Object
|
| 63 |
-
* @returns stringified JSON
|
| 64 |
-
*/
|
| 65 |
-
var stringifySorted = (obj) => {
|
| 66 |
-
const keys = Object.keys(obj);
|
| 67 |
-
if (keys.length === 0) return "";
|
| 68 |
-
keys.sort();
|
| 69 |
-
let result = "";
|
| 70 |
-
for (const key of keys) result += `${key}:${JSON.stringify(obj[key])};`;
|
| 71 |
-
return result;
|
| 72 |
-
};
|
| 73 |
-
/**
|
| 74 |
-
* create cache key
|
| 75 |
-
* @param keyData - key data
|
| 76 |
-
* @param [opt] - options
|
| 77 |
-
* @returns cache key
|
| 78 |
-
*/
|
| 79 |
-
var createCacheKey = (keyData, opt = {}) => {
|
| 80 |
-
if (!keyData || opt.customProperty && typeof opt.customProperty.callback === "function" || opt.dimension && typeof opt.dimension.callback === "function") return "";
|
| 81 |
-
const namespace = keyData.namespace || "";
|
| 82 |
-
const name = keyData.name || "";
|
| 83 |
-
const value = keyData.value || "";
|
| 84 |
-
if (!namespace && !name && !value) return "";
|
| 85 |
-
return `${`${namespace}:${name}:${value}`}::${`${opt.format || ""}|${opt.colorSpace || ""}|${opt.colorScheme || ""}|${opt.currentColor || ""}|${opt.d50 ? "1" : "0"}|${opt.nullable ? "1" : "0"}|${opt.preserveComment ? "1" : "0"}|${opt.delimiter || ""}`}::${opt.customProperty ? stringifySorted(opt.customProperty) : ""}::${opt.dimension ? stringifySorted(opt.dimension) : ""}`;
|
| 86 |
-
};
|
| 87 |
-
//#endregion
|
| 88 |
-
export { CacheItem, NullObject, createCacheKey, getCache, setCache };
|
| 89 |
-
|
| 90 |
-
//# sourceMappingURL=cache.js.map
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
node_modules/@asamuzakjp/css-color/dist/esm/js/cache.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
{"version":3,"file":"cache.js","names":["#item","#isNull"],"sources":["../../../src/js/cache.ts"],"sourcesContent":["/**\n * cache\n */\n\nimport { GenerationalCache } from '@asamuzakjp/generational-cache';\nimport { Options } from './typedef';\n\n/* constants */\nconst CACHE_SIZE = 2048;\n\n/**\n * CacheItem\n */\nexport class CacheItem {\n /* private */\n #isNull: boolean;\n #item: unknown;\n\n constructor(item: unknown, isNull: boolean = false) {\n this.#item = item;\n this.#isNull = !!isNull;\n }\n\n get item() {\n return this.#item;\n }\n\n get isNull() {\n return this.#isNull;\n }\n}\n\n/**\n * NullObject\n */\nexport class NullObject extends CacheItem {\n constructor() {\n super(Symbol('null'), true);\n }\n}\n\n/*\n * generational cache instance\n */\nexport const genCache = new GenerationalCache<string, CacheItem>(CACHE_SIZE);\n\n/**\n * shared null object\n */\nconst sharedNullObject = new NullObject();\n\n/**\n * set cache\n * @param key - cache key\n * @param value - value to cache\n * @returns void\n */\nexport const setCache = (key: string, value: unknown): void => {\n if (!key) {\n return;\n }\n if (value === null) {\n genCache.set(key, sharedNullObject);\n } else if (value instanceof CacheItem) {\n genCache.set(key, value);\n } else {\n genCache.set(key, new CacheItem(value));\n }\n};\n\n/**\n * get cache\n * @param key - cache key\n * @returns cached item or false otherwise\n */\nexport const getCache = (key: string): CacheItem | false => {\n if (!key) {\n return false;\n }\n const item = genCache.get(key);\n if (item !== undefined) {\n return item as CacheItem;\n }\n return false;\n};\n\n/**\n * helper function to sort object keys alphabetically\n * @param obj - Object\n * @returns stringified JSON\n */\nconst stringifySorted = (obj: Record<string, unknown>): string => {\n const keys = Object.keys(obj);\n if (keys.length === 0) {\n return '';\n }\n keys.sort();\n let result = '';\n for (const key of keys) {\n result += `${key}:${JSON.stringify(obj[key])};`;\n }\n return result;\n};\n\n/**\n * create cache key\n * @param keyData - key data\n * @param [opt] - options\n * @returns cache key\n */\nexport const createCacheKey = (\n keyData: Record<string, string>,\n opt: Options = {}\n): string => {\n if (\n !keyData ||\n (opt.customProperty && typeof opt.customProperty.callback === 'function') ||\n (opt.dimension && typeof opt.dimension.callback === 'function')\n ) {\n return '';\n }\n const namespace = keyData.namespace || '';\n const name = keyData.name || '';\n const value = keyData.value || '';\n if (!namespace && !name && !value) {\n return '';\n }\n const baseKey = `${namespace}:${name}:${value}`;\n const optStr = `${opt.format || ''}|${opt.colorSpace || ''}|${opt.colorScheme || ''}|${opt.currentColor || ''}|${opt.d50 ? '1' : '0'}|${opt.nullable ? '1' : '0'}|${opt.preserveComment ? '1' : '0'}|${opt.delimiter || ''}`;\n const customPropStr = opt.customProperty\n ? stringifySorted(opt.customProperty as Record<string, unknown>)\n : '';\n const dimStr = opt.dimension\n ? stringifySorted(opt.dimension as Record<string, unknown>)\n : '';\n return `${baseKey}::${optStr}::${customPropStr}::${dimStr}`;\n};\n"],"mappings":";;;;;AAQA,IAAM,aAAa;;;;AAKnB,IAAa,YAAb,MAAuB;CAErB;CACA;CAEA,YAAY,MAAe,SAAkB,OAAO;AAClD,QAAA,OAAa;AACb,QAAA,SAAe,CAAC,CAAC;;CAGnB,IAAI,OAAO;AACT,SAAO,MAAA;;CAGT,IAAI,SAAS;AACX,SAAO,MAAA;;;;;;AAOX,IAAa,aAAb,cAAgC,UAAU;CACxC,cAAc;AACZ,QA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AI,GAAG,IAAI,kBAAkB,MAAM,IAAI,GAAG,IAAI,aAAa,KAO3L,IANP,IAAI,iBACtB,gBAAgB,IAAI,eAA0C,GAC9D,GAI2C,IAHhC,IAAI,YACf,gBAAgB,IAAI,UAAqC,GACzD"}
|
|
|
|
|
|
node_modules/@asamuzakjp/css-color/dist/esm/js/color.d.ts
DELETED
|
@@ -1,537 +0,0 @@
|
|
| 1 |
-
import { NullObject } from './cache.js';
|
| 2 |
-
import { ColorChannels, Options, SpecifiedColorChannels } from './typedef.js';
|
| 3 |
-
/**
|
| 4 |
-
* @type TriColorChannels - color channels without alpha
|
| 5 |
-
*/
|
| 6 |
-
type TriColorChannels = [x: number, y: number, z: number];
|
| 7 |
-
/**
|
| 8 |
-
* @type ColorMatrix - color matrix
|
| 9 |
-
*/
|
| 10 |
-
type ColorMatrix = [
|
| 11 |
-
r1: TriColorChannels,
|
| 12 |
-
r2: TriColorChannels,
|
| 13 |
-
r3: TriColorChannels
|
| 14 |
-
];
|
| 15 |
-
/**
|
| 16 |
-
* named colors
|
| 17 |
-
*/
|
| 18 |
-
export declare const NAMED_COLORS: {
|
| 19 |
-
readonly aliceblue: [240, 248, 255];
|
| 20 |
-
readonly antiquewhite: [250, 235, 215];
|
| 21 |
-
readonly aqua: [0, 255, 255];
|
| 22 |
-
readonly aquamarine: [127, 255, 212];
|
| 23 |
-
readonly azure: [240, 255, 255];
|
| 24 |
-
readonly beige: [245, 245, 220];
|
| 25 |
-
readonly bisque: [255, 228, 196];
|
| 26 |
-
readonly black: [0, 0, 0];
|
| 27 |
-
readonly blanchedalmond: [255, 235, 205];
|
| 28 |
-
readonly blue: [0, 0, 255];
|
| 29 |
-
readonly blueviolet: [138, 43, 226];
|
| 30 |
-
readonly brown: [165, 42, 42];
|
| 31 |
-
readonly burlywood: [222, 184, 135];
|
| 32 |
-
readonly cadetblue: [95, 158, 160];
|
| 33 |
-
readonly chartreuse: [127, 255, 0];
|
| 34 |
-
readonly chocolate: [210, 105, 30];
|
| 35 |
-
readonly coral: [255, 127, 80];
|
| 36 |
-
readonly cornflowerblue: [100, 149, 237];
|
| 37 |
-
readonly cornsilk: [255, 248, 220];
|
| 38 |
-
readonly crimson: [220, 20, 60];
|
| 39 |
-
readonly cyan: [0, 255, 255];
|
| 40 |
-
readonly darkblue: [0, 0, 139];
|
| 41 |
-
readonly darkcyan: [0, 139, 139];
|
| 42 |
-
readonly darkgoldenrod: [184, 134, 11];
|
| 43 |
-
readonly darkgray: [169, 169, 169];
|
| 44 |
-
readonly darkgreen: [0, 100, 0];
|
| 45 |
-
readonly darkgrey: [169, 169, 169];
|
| 46 |
-
readonly darkkhaki: [189, 183, 107];
|
| 47 |
-
readonly darkmagenta: [139, 0, 139];
|
| 48 |
-
readonly darkolivegreen: [85, 107, 47];
|
| 49 |
-
readonly darkorange: [255, 140, 0];
|
| 50 |
-
readonly darkorchid: [153, 50, 204];
|
| 51 |
-
readonly darkred: [139, 0, 0];
|
| 52 |
-
readonly darksalmon: [233, 150, 122];
|
| 53 |
-
readonly darkseagreen: [143, 188, 143];
|
| 54 |
-
readonly darkslateblue: [72, 61, 139];
|
| 55 |
-
readonly darkslategray: [47, 79, 79];
|
| 56 |
-
readonly darkslategrey: [47, 79, 79];
|
| 57 |
-
readonly darkturquoise: [0, 206, 209];
|
| 58 |
-
readonly darkviolet: [148, 0, 211];
|
| 59 |
-
readonly deeppink: [255, 20, 147];
|
| 60 |
-
readonly deepskyblue: [0, 191, 255];
|
| 61 |
-
readonly dimgray: [105, 105, 105];
|
| 62 |
-
readonly dimgrey: [105, 105, 105];
|
| 63 |
-
readonly dodgerblue: [30, 144, 255];
|
| 64 |
-
readonly firebrick: [178, 34, 34];
|
| 65 |
-
readonly floralwhite: [255, 250, 240];
|
| 66 |
-
readonly forestgreen: [34, 139, 34];
|
| 67 |
-
readonly fuchsia: [255, 0, 255];
|
| 68 |
-
readonly gainsboro: [220, 220, 220];
|
| 69 |
-
readonly ghostwhite: [248, 248, 255];
|
| 70 |
-
readonly gold: [255, 215, 0];
|
| 71 |
-
readonly goldenrod: [218, 165, 32];
|
| 72 |
-
readonly gray: [128, 128, 128];
|
| 73 |
-
readonly green: [0, 128, 0];
|
| 74 |
-
readonly greenyellow: [173, 255, 47];
|
| 75 |
-
readonly grey: [128, 128, 128];
|
| 76 |
-
readonly honeydew: [240, 255, 240];
|
| 77 |
-
readonly hotpink: [255, 105, 180];
|
| 78 |
-
readonly indianred: [205, 92, 92];
|
| 79 |
-
readonly indigo: [75, 0, 130];
|
| 80 |
-
readonly ivory: [255, 255, 240];
|
| 81 |
-
readonly khaki: [240, 230, 140];
|
| 82 |
-
readonly lavender: [230, 230, 250];
|
| 83 |
-
readonly lavenderblush: [255, 240, 245];
|
| 84 |
-
readonly lawngreen: [124, 252, 0];
|
| 85 |
-
readonly lemonchiffon: [255, 250, 205];
|
| 86 |
-
readonly lightblue: [173, 216, 230];
|
| 87 |
-
readonly lightcoral: [240, 128, 128];
|
| 88 |
-
readonly lightcyan: [224, 255, 255];
|
| 89 |
-
readonly lightgoldenrodyellow: [250, 250, 210];
|
| 90 |
-
readonly lightgray: [211, 211, 211];
|
| 91 |
-
readonly lightgreen: [144, 238, 144];
|
| 92 |
-
readonly lightgrey: [211, 211, 211];
|
| 93 |
-
readonly lightpink: [255, 182, 193];
|
| 94 |
-
readonly lightsalmon: [255, 160, 122];
|
| 95 |
-
readonly lightseagreen: [32, 178, 170];
|
| 96 |
-
readonly lightskyblue: [135, 206, 250];
|
| 97 |
-
readonly lightslategray: [119, 136, 153];
|
| 98 |
-
readonly lightslategrey: [119, 136, 153];
|
| 99 |
-
readonly lightsteelblue: [176, 196, 222];
|
| 100 |
-
readonly lightyellow: [255, 255, 224];
|
| 101 |
-
readonly lime: [0, 255, 0];
|
| 102 |
-
readonly limegreen: [50, 205, 50];
|
| 103 |
-
readonly linen: [250, 240, 230];
|
| 104 |
-
readonly magenta: [255, 0, 255];
|
| 105 |
-
readonly maroon: [128, 0, 0];
|
| 106 |
-
readonly mediumaquamarine: [102, 205, 170];
|
| 107 |
-
readonly mediumblue: [0, 0, 205];
|
| 108 |
-
readonly mediumorchid: [186, 85, 211];
|
| 109 |
-
readonly mediumpurple: [147, 112, 219];
|
| 110 |
-
readonly mediumseagreen: [60, 179, 113];
|
| 111 |
-
readonly mediumslateblue: [123, 104, 238];
|
| 112 |
-
readonly mediumspringgreen: [0, 250, 154];
|
| 113 |
-
readonly mediumturquoise: [72, 209, 204];
|
| 114 |
-
readonly mediumvioletred: [199, 21, 133];
|
| 115 |
-
readonly midnightblue: [25, 25, 112];
|
| 116 |
-
readonly mintcream: [245, 255, 250];
|
| 117 |
-
readonly mistyrose: [255, 228, 225];
|
| 118 |
-
readonly moccasin: [255, 228, 181];
|
| 119 |
-
readonly navajowhite: [255, 222, 173];
|
| 120 |
-
readonly navy: [0, 0, 128];
|
| 121 |
-
readonly oldlace: [253, 245, 230];
|
| 122 |
-
readonly olive: [128, 128, 0];
|
| 123 |
-
readonly olivedrab: [107, 142, 35];
|
| 124 |
-
readonly orange: [255, 165, 0];
|
| 125 |
-
readonly orangered: [255, 69, 0];
|
| 126 |
-
readonly orchid: [218, 112, 214];
|
| 127 |
-
readonly palegoldenrod: [238, 232, 170];
|
| 128 |
-
readonly palegreen: [152, 251, 152];
|
| 129 |
-
readonly paleturquoise: [175, 238, 238];
|
| 130 |
-
readonly palevioletred: [219, 112, 147];
|
| 131 |
-
readonly papayawhip: [255, 239, 213];
|
| 132 |
-
readonly peachpuff: [255, 218, 185];
|
| 133 |
-
readonly peru: [205, 133, 63];
|
| 134 |
-
readonly pink: [255, 192, 203];
|
| 135 |
-
readonly plum: [221, 160, 221];
|
| 136 |
-
readonly powderblue: [176, 224, 230];
|
| 137 |
-
readonly purple: [128, 0, 128];
|
| 138 |
-
readonly rebeccapurple: [102, 51, 153];
|
| 139 |
-
readonly red: [255, 0, 0];
|
| 140 |
-
readonly rosybrown: [188, 143, 143];
|
| 141 |
-
readonly royalblue: [65, 105, 225];
|
| 142 |
-
readonly saddlebrown: [139, 69, 19];
|
| 143 |
-
readonly salmon: [250, 128, 114];
|
| 144 |
-
readonly sandybrown: [244, 164, 96];
|
| 145 |
-
readonly seagreen: [46, 139, 87];
|
| 146 |
-
readonly seashell: [255, 245, 238];
|
| 147 |
-
readonly sienna: [160, 82, 45];
|
| 148 |
-
readonly silver: [192, 192, 192];
|
| 149 |
-
readonly skyblue: [135, 206, 235];
|
| 150 |
-
readonly slateblue: [106, 90, 205];
|
| 151 |
-
readonly slategray: [112, 128, 144];
|
| 152 |
-
readonly slategrey: [112, 128, 144];
|
| 153 |
-
readonly snow: [255, 250, 250];
|
| 154 |
-
readonly springgreen: [0, 255, 127];
|
| 155 |
-
readonly steelblue: [70, 130, 180];
|
| 156 |
-
readonly tan: [210, 180, 140];
|
| 157 |
-
readonly teal: [0, 128, 128];
|
| 158 |
-
readonly thistle: [216, 191, 216];
|
| 159 |
-
readonly tomato: [255, 99, 71];
|
| 160 |
-
readonly turquoise: [64, 224, 208];
|
| 161 |
-
readonly violet: [238, 130, 238];
|
| 162 |
-
readonly wheat: [245, 222, 179];
|
| 163 |
-
readonly white: [255, 255, 255];
|
| 164 |
-
readonly whitesmoke: [245, 245, 245];
|
| 165 |
-
readonly yellow: [255, 255, 0];
|
| 166 |
-
readonly yellowgreen: [154, 205, 50];
|
| 167 |
-
};
|
| 168 |
-
/**
|
| 169 |
-
* cache invalid color value
|
| 170 |
-
* @param key - cache key
|
| 171 |
-
* @param nullable - is nullable
|
| 172 |
-
* @returns cached value
|
| 173 |
-
*/
|
| 174 |
-
export declare const cacheInvalidColorValue: (cacheKey: string, format: string, nullable?: boolean) => SpecifiedColorChannels | string | NullObject;
|
| 175 |
-
/**
|
| 176 |
-
* resolve invalid color value
|
| 177 |
-
* @param format - output format
|
| 178 |
-
* @param nullable - is nullable
|
| 179 |
-
* @returns resolved value
|
| 180 |
-
*/
|
| 181 |
-
export declare const resolveInvalidColorValue: (format: string, nullable?: boolean) => SpecifiedColorChannels | string | NullObject;
|
| 182 |
-
/**
|
| 183 |
-
* validate color components
|
| 184 |
-
* @param arr - color components
|
| 185 |
-
* @param [opt] - options
|
| 186 |
-
* @param [opt.alpha] - alpha channel
|
| 187 |
-
* @param [opt.minLength] - min length
|
| 188 |
-
* @param [opt.maxLength] - max length
|
| 189 |
-
* @param [opt.minRange] - min range
|
| 190 |
-
* @param [opt.maxRange] - max range
|
| 191 |
-
* @param [opt.validateRange] - validate range
|
| 192 |
-
* @returns result - validated color components
|
| 193 |
-
*/
|
| 194 |
-
export declare const validateColorComponents: (arr: ColorChannels | TriColorChannels, opt?: {
|
| 195 |
-
alpha?: boolean;
|
| 196 |
-
minLength?: number;
|
| 197 |
-
maxLength?: number;
|
| 198 |
-
minRange?: number;
|
| 199 |
-
maxRange?: number;
|
| 200 |
-
validateRange?: boolean;
|
| 201 |
-
}) => ColorChannels | TriColorChannels;
|
| 202 |
-
/**
|
| 203 |
-
* transform matrix
|
| 204 |
-
* @param mtx - 3 * 3 matrix
|
| 205 |
-
* @param vct - vector
|
| 206 |
-
* @param [skip] - skip validate
|
| 207 |
-
* @returns TriColorChannels - [p1, p2, p3]
|
| 208 |
-
*/
|
| 209 |
-
export declare const transformMatrix: (mtx: ColorMatrix, vct: TriColorChannels, skip?: boolean) => TriColorChannels;
|
| 210 |
-
/**
|
| 211 |
-
* normalize color components
|
| 212 |
-
* @param colorA - color components [v1, v2, v3, v4]
|
| 213 |
-
* @param colorB - color components [v1, v2, v3, v4]
|
| 214 |
-
* @param [skip] - skip validate
|
| 215 |
-
* @returns result - [colorA, colorB]
|
| 216 |
-
*/
|
| 217 |
-
export declare const normalizeColorComponents: (colorA: [number | string, number | string, number | string, number | string], colorB: [number | string, number | string, number | string, number | string], skip?: boolean) => [ColorChannels, ColorChannels];
|
| 218 |
-
/**
|
| 219 |
-
* number to hex string
|
| 220 |
-
* @param value - numeric value
|
| 221 |
-
* @returns hex string
|
| 222 |
-
*/
|
| 223 |
-
export declare const numberToHexString: (value: number) => string;
|
| 224 |
-
/**
|
| 225 |
-
* angle to deg
|
| 226 |
-
* @param angle
|
| 227 |
-
* @returns deg: 0..360
|
| 228 |
-
*/
|
| 229 |
-
export declare const angleToDeg: (angle: string) => number;
|
| 230 |
-
/**
|
| 231 |
-
* parse alpha
|
| 232 |
-
* @param [alpha] - alpha value
|
| 233 |
-
* @returns alpha: 0..1
|
| 234 |
-
*/
|
| 235 |
-
export declare const parseAlpha: (alpha?: string) => number;
|
| 236 |
-
/**
|
| 237 |
-
* parse hex alpha
|
| 238 |
-
* @param value - alpha value in hex string
|
| 239 |
-
* @returns alpha: 0..1
|
| 240 |
-
*/
|
| 241 |
-
export declare const parseHexAlpha: (value: string) => number;
|
| 242 |
-
/**
|
| 243 |
-
* transform rgb to linear rgb
|
| 244 |
-
* @param rgb - [r, g, b] r|g|b: 0..255
|
| 245 |
-
* @param [skip] - skip validate
|
| 246 |
-
* @returns TriColorChannels - [r, g, b] r|g|b: 0..1
|
| 247 |
-
*/
|
| 248 |
-
export declare const transformRgbToLinearRgb: (rgb: TriColorChannels, skip?: boolean) => TriColorChannels;
|
| 249 |
-
/**
|
| 250 |
-
* transform rgb to xyz
|
| 251 |
-
* @param rgb - [r, g, b] r|g|b: 0..255
|
| 252 |
-
* @param [skip] - skip validate
|
| 253 |
-
* @returns TriColorChannels - [x, y, z]
|
| 254 |
-
*/
|
| 255 |
-
export declare const transformRgbToXyz: (rgb: TriColorChannels, skip?: boolean) => TriColorChannels;
|
| 256 |
-
/**
|
| 257 |
-
* transform rgb to xyz-d50
|
| 258 |
-
* @param rgb - [r, g, b] r|g|b: 0..255 alpha: 0..1
|
| 259 |
-
* @returns TriColorChannels - [x, y, z]
|
| 260 |
-
*/
|
| 261 |
-
export declare const transformRgbToXyzD50: (rgb: TriColorChannels) => TriColorChannels;
|
| 262 |
-
/**
|
| 263 |
-
* transform linear rgb to rgb
|
| 264 |
-
* @param rgb - [r, g, b] r|g|b: 0..1
|
| 265 |
-
* @param [round] - round result
|
| 266 |
-
* @returns TriColorChannels - [r, g, b] r|g|b: 0..255
|
| 267 |
-
*/
|
| 268 |
-
export declare const transformLinearRgbToRgb: (rgb: TriColorChannels, round?: boolean) => TriColorChannels;
|
| 269 |
-
/**
|
| 270 |
-
* transform xyz to rgb
|
| 271 |
-
* @param xyz - [x, y, z]
|
| 272 |
-
* @param [skip] - skip validate
|
| 273 |
-
* @returns TriColorChannels - [r, g, b] r|g|b: 0..255
|
| 274 |
-
*/
|
| 275 |
-
export declare const transformXyzToRgb: (xyz: TriColorChannels, skip?: boolean) => TriColorChannels;
|
| 276 |
-
/**
|
| 277 |
-
* transform xyz to xyz-d50
|
| 278 |
-
* @param xyz - [x, y, z]
|
| 279 |
-
* @returns TriColorChannels - [x, y, z]
|
| 280 |
-
*/
|
| 281 |
-
export declare const transformXyzToXyzD50: (xyz: TriColorChannels) => TriColorChannels;
|
| 282 |
-
/**
|
| 283 |
-
* transform xyz to hsl
|
| 284 |
-
* @param xyz - [x, y, z]
|
| 285 |
-
* @param [skip] - skip validate
|
| 286 |
-
* @returns TriColorChannels - [h, s, l]
|
| 287 |
-
*/
|
| 288 |
-
export declare const transformXyzToHsl: (xyz: TriColorChannels, skip?: boolean) => TriColorChannels;
|
| 289 |
-
/**
|
| 290 |
-
* transform xyz to hwb
|
| 291 |
-
* @param xyz - [x, y, z]
|
| 292 |
-
* @param [skip] - skip validate
|
| 293 |
-
* @returns TriColorChannels - [h, w, b]
|
| 294 |
-
*/
|
| 295 |
-
export declare const transformXyzToHwb: (xyz: TriColorChannels, skip?: boolean) => TriColorChannels;
|
| 296 |
-
/**
|
| 297 |
-
* transform xyz to oklab
|
| 298 |
-
* @param xyz - [x, y, z]
|
| 299 |
-
* @param [skip] - skip validate
|
| 300 |
-
* @returns TriColorChannels - [l, a, b]
|
| 301 |
-
*/
|
| 302 |
-
export declare const transformXyzToOklab: (xyz: TriColorChannels, skip?: boolean) => TriColorChannels;
|
| 303 |
-
/**
|
| 304 |
-
* transform xyz to oklch
|
| 305 |
-
* @param xyz - [x, y, z]
|
| 306 |
-
* @param [skip] - skip validate
|
| 307 |
-
* @returns TriColorChannels - [l, c, h]
|
| 308 |
-
*/
|
| 309 |
-
export declare const transformXyzToOklch: (xyz: TriColorChannels, skip?: boolean) => TriColorChannels;
|
| 310 |
-
/**
|
| 311 |
-
* transform xyz D50 to rgb
|
| 312 |
-
* @param xyz - [x, y, z]
|
| 313 |
-
* @param [skip] - skip validate
|
| 314 |
-
* @returns TriColorChannels - [r, g, b] r|g|b: 0..255
|
| 315 |
-
*/
|
| 316 |
-
export declare const transformXyzD50ToRgb: (xyz: TriColorChannels, skip?: boolean) => TriColorChannels;
|
| 317 |
-
/**
|
| 318 |
-
* transform xyz-d50 to lab
|
| 319 |
-
* @param xyz - [x, y, z]
|
| 320 |
-
* @param [skip] - skip validate
|
| 321 |
-
* @returns TriColorChannels - [l, a, b]
|
| 322 |
-
*/
|
| 323 |
-
export declare const transformXyzD50ToLab: (xyz: TriColorChannels, skip?: boolean) => TriColorChannels;
|
| 324 |
-
/**
|
| 325 |
-
* transform xyz-d50 to lch
|
| 326 |
-
* @param xyz - [x, y, z]
|
| 327 |
-
* @param [skip] - skip validate
|
| 328 |
-
* @returns TriColorChannels - [l, c, h]
|
| 329 |
-
*/
|
| 330 |
-
export declare const transformXyzD50ToLch: (xyz: TriColorChannels, skip?: boolean) => TriColorChannels;
|
| 331 |
-
/**
|
| 332 |
-
* convert rgb to hex color
|
| 333 |
-
* @param rgb - [r, g, b, alpha] r|g|b: 0..255 alpha: 0..1
|
| 334 |
-
* @returns hex color
|
| 335 |
-
*/
|
| 336 |
-
export declare const convertRgbToHex: (rgb: ColorChannels) => string;
|
| 337 |
-
/**
|
| 338 |
-
* convert linear rgb to hex color
|
| 339 |
-
* @param rgb - [r, g, b, alpha] r|g|b|alpha: 0..1
|
| 340 |
-
* @param [skip] - skip validate
|
| 341 |
-
* @returns hex color
|
| 342 |
-
*/
|
| 343 |
-
export declare const convertLinearRgbToHex: (rgb: ColorChannels, skip?: boolean) => string;
|
| 344 |
-
/**
|
| 345 |
-
* convert xyz to hex color
|
| 346 |
-
* @param xyz - [x, y, z, alpha]
|
| 347 |
-
* @returns hex color
|
| 348 |
-
*/
|
| 349 |
-
export declare const convertXyzToHex: (xyz: ColorChannels) => string;
|
| 350 |
-
/**
|
| 351 |
-
* convert xyz D50 to hex color
|
| 352 |
-
* @param xyz - [x, y, z, alpha]
|
| 353 |
-
* @returns hex color
|
| 354 |
-
*/
|
| 355 |
-
export declare const convertXyzD50ToHex: (xyz: ColorChannels) => string;
|
| 356 |
-
/**
|
| 357 |
-
* convert hex color to rgb
|
| 358 |
-
* @param value - hex color value
|
| 359 |
-
* @returns ColorChannels - [r, g, b, alpha] r|g|b: 0..255 alpha: 0..1
|
| 360 |
-
*/
|
| 361 |
-
export declare const convertHexToRgb: (value: string) => ColorChannels;
|
| 362 |
-
/**
|
| 363 |
-
* convert hex color to linear rgb
|
| 364 |
-
* @param value - hex color value
|
| 365 |
-
* @returns ColorChannels - [r, g, b, alpha] r|g|b|alpha: 0..1
|
| 366 |
-
*/
|
| 367 |
-
export declare const convertHexToLinearRgb: (value: string) => ColorChannels;
|
| 368 |
-
/**
|
| 369 |
-
* convert hex color to xyz
|
| 370 |
-
* @param value - hex color value
|
| 371 |
-
* @returns ColorChannels - [x, y, z, alpha]
|
| 372 |
-
*/
|
| 373 |
-
export declare const convertHexToXyz: (value: string) => ColorChannels;
|
| 374 |
-
/**
|
| 375 |
-
* parse rgb()
|
| 376 |
-
* @param value - rgb color value
|
| 377 |
-
* @param [opt] - options
|
| 378 |
-
* @returns parsed color - ['rgb', r, g, b, alpha], '(empty)', NullObject
|
| 379 |
-
*/
|
| 380 |
-
export declare const parseRgb: (value: string, opt?: Options) => SpecifiedColorChannels | string | NullObject;
|
| 381 |
-
/**
|
| 382 |
-
* parse hsl()
|
| 383 |
-
* @param value - hsl color value
|
| 384 |
-
* @param [opt] - options
|
| 385 |
-
* @returns parsed color - ['rgb', r, g, b, alpha], '(empty)', NullObject
|
| 386 |
-
*/
|
| 387 |
-
export declare const parseHsl: (value: string, opt?: Options) => SpecifiedColorChannels | string | NullObject;
|
| 388 |
-
/**
|
| 389 |
-
* parse hwb()
|
| 390 |
-
* @param value - hwb color value
|
| 391 |
-
* @param [opt] - options
|
| 392 |
-
* @returns parsed color - ['rgb', r, g, b, alpha], '(empty)', NullObject
|
| 393 |
-
*/
|
| 394 |
-
export declare const parseHwb: (value: string, opt?: Options) => SpecifiedColorChannels | string | NullObject;
|
| 395 |
-
/**
|
| 396 |
-
* parse lab()
|
| 397 |
-
* @param value - lab color value
|
| 398 |
-
* @param [opt] - options
|
| 399 |
-
* @returns parsed color
|
| 400 |
-
* - [xyz-d50, x, y, z, alpha], ['lab', l, a, b, alpha], '(empty)', NullObject
|
| 401 |
-
*/
|
| 402 |
-
export declare const parseLab: (value: string, opt?: Options) => SpecifiedColorChannels | string | NullObject;
|
| 403 |
-
/**
|
| 404 |
-
* parse lch()
|
| 405 |
-
* @param value - lch color value
|
| 406 |
-
* @param [opt] - options
|
| 407 |
-
* @returns parsed color
|
| 408 |
-
* - ['xyz-d50', x, y, z, alpha], ['lch', l, c, h, alpha]
|
| 409 |
-
* - '(empty)', NullObject
|
| 410 |
-
*/
|
| 411 |
-
export declare const parseLch: (value: string, opt?: Options) => SpecifiedColorChannels | string | NullObject;
|
| 412 |
-
/**
|
| 413 |
-
* parse oklab()
|
| 414 |
-
* @param value - oklab color value
|
| 415 |
-
* @param [opt] - options
|
| 416 |
-
* @returns parsed color
|
| 417 |
-
* - ['xyz-d65', x, y, z, alpha], ['oklab', l, a, b, alpha]
|
| 418 |
-
* - '(empty)', NullObject
|
| 419 |
-
*/
|
| 420 |
-
export declare const parseOklab: (value: string, opt?: Options) => SpecifiedColorChannels | string | NullObject;
|
| 421 |
-
/**
|
| 422 |
-
* parse oklch()
|
| 423 |
-
* @param value - oklch color value
|
| 424 |
-
* @param [opt] - options
|
| 425 |
-
* @returns parsed color
|
| 426 |
-
* - ['xyz-d65', x, y, z, alpha], ['oklch', l, c, h, alpha]
|
| 427 |
-
* - '(empty)', NullObject
|
| 428 |
-
*/
|
| 429 |
-
export declare const parseOklch: (value: string, opt?: Options) => SpecifiedColorChannels | string | NullObject;
|
| 430 |
-
/**
|
| 431 |
-
* parse color()
|
| 432 |
-
* @param value - color function value
|
| 433 |
-
* @param [opt] - options
|
| 434 |
-
* @returns parsed color
|
| 435 |
-
* - ['xyz-(d50|d65)', x, y, z, alpha], [cs, r, g, b, alpha]
|
| 436 |
-
* - '(empty)', NullObject
|
| 437 |
-
*/
|
| 438 |
-
export declare const parseColorFunc: (value: string, opt?: Options) => SpecifiedColorChannels | string | NullObject;
|
| 439 |
-
/**
|
| 440 |
-
* parse color value
|
| 441 |
-
* @param value - CSS color value
|
| 442 |
-
* @param [opt] - options
|
| 443 |
-
* @returns parsed color
|
| 444 |
-
* - ['xyz-(d50|d65)', x, y, z, alpha], ['rgb', r, g, b, alpha]
|
| 445 |
-
* - value, '(empty)', NullObject
|
| 446 |
-
*/
|
| 447 |
-
export declare const parseColorValue: (value: string, opt?: Options) => SpecifiedColorChannels | string | NullObject;
|
| 448 |
-
/**
|
| 449 |
-
* resolve color value
|
| 450 |
-
* @param value - CSS color value
|
| 451 |
-
* @param [opt] - options
|
| 452 |
-
* @returns resolved color
|
| 453 |
-
* - [cs, v1, v2, v3, alpha], value, '(empty)', NullObject
|
| 454 |
-
*/
|
| 455 |
-
export declare const resolveColorValue: (value: string, opt?: Options) => SpecifiedColorChannels | string | NullObject;
|
| 456 |
-
/**
|
| 457 |
-
* resolve color()
|
| 458 |
-
* @param value - color function value
|
| 459 |
-
* @param [opt] - options
|
| 460 |
-
* @returns resolved color - [cs, v1, v2, v3, alpha], '(empty)', NullObject
|
| 461 |
-
*/
|
| 462 |
-
export declare const resolveColorFunc: (value: string, opt?: Options) => SpecifiedColorChannels | string | NullObject;
|
| 463 |
-
/**
|
| 464 |
-
* convert color value to linear rgb
|
| 465 |
-
* @param value - CSS color value
|
| 466 |
-
* @param [opt] - options
|
| 467 |
-
* @returns ColorChannels | NullObject - [r, g, b, alpha] r|g|b|alpha: 0..1
|
| 468 |
-
*/
|
| 469 |
-
export declare const convertColorToLinearRgb: (value: string, opt?: {
|
| 470 |
-
colorSpace?: string;
|
| 471 |
-
format?: string;
|
| 472 |
-
}) => ColorChannels | NullObject;
|
| 473 |
-
/**
|
| 474 |
-
* convert color value to rgb
|
| 475 |
-
* @param value - CSS color value
|
| 476 |
-
* @param [opt] - options
|
| 477 |
-
* @returns ColorChannels | NullObject
|
| 478 |
-
* - [r, g, b, alpha] r|g|b: 0..255 alpha: 0..1
|
| 479 |
-
*/
|
| 480 |
-
export declare const convertColorToRgb: (value: string, opt?: Options) => ColorChannels | NullObject;
|
| 481 |
-
/**
|
| 482 |
-
* convert color value to xyz
|
| 483 |
-
* @param value - CSS color value
|
| 484 |
-
* @param [opt] - options
|
| 485 |
-
* @returns ColorChannels | NullObject - [x, y, z, alpha]
|
| 486 |
-
*/
|
| 487 |
-
export declare const convertColorToXyz: (value: string, opt?: Options) => ColorChannels | NullObject;
|
| 488 |
-
/**
|
| 489 |
-
* convert color value to hsl
|
| 490 |
-
* @param value - CSS color value
|
| 491 |
-
* @param [opt] - options
|
| 492 |
-
* @returns ColorChannels | NullObject - [h, s, l, alpha], hue may be powerless
|
| 493 |
-
*/
|
| 494 |
-
export declare const convertColorToHsl: (value: string, opt?: Options) => ColorChannels | [number | string, number, number, number] | NullObject;
|
| 495 |
-
/**
|
| 496 |
-
* convert color value to hwb
|
| 497 |
-
* @param value - CSS color value
|
| 498 |
-
* @param [opt] - options
|
| 499 |
-
* @returns ColorChannels | NullObject - [h, w, b, alpha], hue may be powerless
|
| 500 |
-
*/
|
| 501 |
-
export declare const convertColorToHwb: (value: string, opt?: Options) => ColorChannels | [number | string, number, number, number] | NullObject;
|
| 502 |
-
/**
|
| 503 |
-
* convert color value to lab
|
| 504 |
-
* @param value - CSS color value
|
| 505 |
-
* @param [opt] - options
|
| 506 |
-
* @returns ColorChannels | NullObject - [l, a, b, alpha]
|
| 507 |
-
*/
|
| 508 |
-
export declare const convertColorToLab: (value: string, opt?: Options) => ColorChannels | NullObject;
|
| 509 |
-
/**
|
| 510 |
-
* convert color value to lch
|
| 511 |
-
* @param value - CSS color value
|
| 512 |
-
* @param [opt] - options
|
| 513 |
-
* @returns ColorChannels | NullObject - [l, c, h, alpha], hue may be powerless
|
| 514 |
-
*/
|
| 515 |
-
export declare const convertColorToLch: (value: string, opt?: Options) => ColorChannels | [number, number, number | string, number] | NullObject;
|
| 516 |
-
/**
|
| 517 |
-
* convert color value to oklab
|
| 518 |
-
* @param value - CSS color value
|
| 519 |
-
* @param [opt] - options
|
| 520 |
-
* @returns ColorChannels | NullObject - [l, a, b, alpha]
|
| 521 |
-
*/
|
| 522 |
-
export declare const convertColorToOklab: (value: string, opt?: Options) => ColorChannels | NullObject;
|
| 523 |
-
/**
|
| 524 |
-
* convert color value to oklch
|
| 525 |
-
* @param value - CSS color value
|
| 526 |
-
* @param [opt] - options
|
| 527 |
-
* @returns ColorChannels | NullObject - [l, c, h, alpha], hue may be powerless
|
| 528 |
-
*/
|
| 529 |
-
export declare const convertColorToOklch: (value: string, opt?: Options) => ColorChannels | [number, number, number | string, number] | NullObject;
|
| 530 |
-
/**
|
| 531 |
-
* resolve color-mix()
|
| 532 |
-
* @param value - color-mix color value
|
| 533 |
-
* @param [opt] - options
|
| 534 |
-
* @returns resolved color - [cs, v1, v2, v3, alpha], '(empty)'
|
| 535 |
-
*/
|
| 536 |
-
export declare const resolveColorMix: (value: string, opt?: Options) => SpecifiedColorChannels | string | NullObject;
|
| 537 |
-
export {};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
node_modules/@asamuzakjp/css-color/dist/esm/js/color.js
DELETED
|
@@ -1,3534 +0,0 @@
|
|
| 1 |
-
import { CacheItem, NullObject, createCacheKey, getCache, setCache } from "./cache.js";
|
| 2 |
-
import { isString } from "./common.js";
|
| 3 |
-
import { ANGLE, CS_HUE_CAPT, CS_MIX, CS_RGB, CS_XYZ, FN_MIX, NONE, NUM, PCT, SYN_COLOR_TYPE, SYN_FN_COLOR, SYN_HSL, SYN_HSL_LV3, SYN_LCH, SYN_MIX, SYN_MIX_CAPT, SYN_MIX_PART, SYN_MOD, SYN_RGB_LV3, VAL_COMP, VAL_MIX, VAL_SPEC } from "./constant.js";
|
| 4 |
-
import { resolveColor } from "./resolve.js";
|
| 5 |
-
import { interpolateHue, roundToPrecision, splitValue } from "./util.js";
|
| 6 |
-
//#region src/js/color.ts
|
| 7 |
-
/**
|
| 8 |
-
* color
|
| 9 |
-
*
|
| 10 |
-
* Ref: CSS Color Module Level 4
|
| 11 |
-
* Sample code for Color Conversions
|
| 12 |
-
* https://w3c.github.io/csswg-drafts/css-color-4/#color-conversion-code
|
| 13 |
-
*/
|
| 14 |
-
var NAMESPACE = "color";
|
| 15 |
-
var PPTH = .001;
|
| 16 |
-
var HALF = .5;
|
| 17 |
-
var DUO = 2;
|
| 18 |
-
var TRIA = 3;
|
| 19 |
-
var QUAD = 4;
|
| 20 |
-
var OCT = 8;
|
| 21 |
-
var DEC = 10;
|
| 22 |
-
var DOZ = 12;
|
| 23 |
-
var HEX = 16;
|
| 24 |
-
var SEXA = 60;
|
| 25 |
-
var DEG_HALF = 180;
|
| 26 |
-
var DEG = 360;
|
| 27 |
-
var MAX_PCT = 100;
|
| 28 |
-
var MAX_RGB = 255;
|
| 29 |
-
var POW_SQR = 2;
|
| 30 |
-
var POW_CUBE = 3;
|
| 31 |
-
var POW_LINEAR = 2.4;
|
| 32 |
-
var LINEAR_COEF = 12.92;
|
| 33 |
-
var LINEAR_OFFSET = .055;
|
| 34 |
-
var LAB_L = 116;
|
| 35 |
-
var LAB_A = 500;
|
| 36 |
-
var LAB_B = 200;
|
| 37 |
-
var LAB_EPSILON = 216 / 24389;
|
| 38 |
-
var LAB_KAPPA = 24389 / 27;
|
| 39 |
-
var D50 = [
|
| 40 |
-
.3457 / .3585,
|
| 41 |
-
1,
|
| 42 |
-
.2958 / .3585
|
| 43 |
-
];
|
| 44 |
-
var MATRIX_D50_TO_D65 = [
|
| 45 |
-
[
|
| 46 |
-
.955473421488075,
|
| 47 |
-
-.02309845494876471,
|
| 48 |
-
.06325924320057072
|
| 49 |
-
],
|
| 50 |
-
[
|
| 51 |
-
-.0283697093338637,
|
| 52 |
-
1.0099953980813041,
|
| 53 |
-
.021041441191917323
|
| 54 |
-
],
|
| 55 |
-
[
|
| 56 |
-
.012314014864481998,
|
| 57 |
-
-.020507649298898964,
|
| 58 |
-
1.330365926242124
|
| 59 |
-
]
|
| 60 |
-
];
|
| 61 |
-
var MATRIX_D65_TO_D50 = [
|
| 62 |
-
[
|
| 63 |
-
1.0479297925449969,
|
| 64 |
-
.022946870601609652,
|
| 65 |
-
-.05019226628920524
|
| 66 |
-
],
|
| 67 |
-
[
|
| 68 |
-
.02962780877005599,
|
| 69 |
-
.9904344267538799,
|
| 70 |
-
-.017073799063418826
|
| 71 |
-
],
|
| 72 |
-
[
|
| 73 |
-
-.009243040646204504,
|
| 74 |
-
.015055191490298152,
|
| 75 |
-
.7518742814281371
|
| 76 |
-
]
|
| 77 |
-
];
|
| 78 |
-
var MATRIX_L_RGB_TO_XYZ = [
|
| 79 |
-
[
|
| 80 |
-
506752 / 1228815,
|
| 81 |
-
87881 / 245763,
|
| 82 |
-
12673 / 70218
|
| 83 |
-
],
|
| 84 |
-
[
|
| 85 |
-
87098 / 409605,
|
| 86 |
-
175762 / 245763,
|
| 87 |
-
12673 / 175545
|
| 88 |
-
],
|
| 89 |
-
[
|
| 90 |
-
7918 / 409605,
|
| 91 |
-
87881 / 737289,
|
| 92 |
-
1001167 / 1053270
|
| 93 |
-
]
|
| 94 |
-
];
|
| 95 |
-
var MATRIX_XYZ_TO_L_RGB = [
|
| 96 |
-
[
|
| 97 |
-
12831 / 3959,
|
| 98 |
-
-329 / 214,
|
| 99 |
-
-1974 / 3959
|
| 100 |
-
],
|
| 101 |
-
[
|
| 102 |
-
-851781 / 878810,
|
| 103 |
-
1648619 / 878810,
|
| 104 |
-
36519 / 878810
|
| 105 |
-
],
|
| 106 |
-
[
|
| 107 |
-
705 / 12673,
|
| 108 |
-
-2585 / 12673,
|
| 109 |
-
705 / 667
|
| 110 |
-
]
|
| 111 |
-
];
|
| 112 |
-
var MATRIX_XYZ_TO_LMS = [
|
| 113 |
-
[
|
| 114 |
-
.819022437996703,
|
| 115 |
-
.3619062600528904,
|
| 116 |
-
-.1288737815209879
|
| 117 |
-
],
|
| 118 |
-
[
|
| 119 |
-
.0329836539323885,
|
| 120 |
-
.9292868615863434,
|
| 121 |
-
.0361446663506424
|
| 122 |
-
],
|
| 123 |
-
[
|
| 124 |
-
.0481771893596242,
|
| 125 |
-
.2642395317527308,
|
| 126 |
-
.6335478284694309
|
| 127 |
-
]
|
| 128 |
-
];
|
| 129 |
-
var MATRIX_LMS_TO_XYZ = [
|
| 130 |
-
[
|
| 131 |
-
1.2268798758459243,
|
| 132 |
-
-.5578149944602171,
|
| 133 |
-
.2813910456659647
|
| 134 |
-
],
|
| 135 |
-
[
|
| 136 |
-
-.0405757452148008,
|
| 137 |
-
1.112286803280317,
|
| 138 |
-
-.0717110580655164
|
| 139 |
-
],
|
| 140 |
-
[
|
| 141 |
-
-.0763729366746601,
|
| 142 |
-
-.4214933324022432,
|
| 143 |
-
1.5869240198367816
|
| 144 |
-
]
|
| 145 |
-
];
|
| 146 |
-
var MATRIX_OKLAB_TO_LMS = [
|
| 147 |
-
[
|
| 148 |
-
1,
|
| 149 |
-
.3963377773761749,
|
| 150 |
-
.2158037573099136
|
| 151 |
-
],
|
| 152 |
-
[
|
| 153 |
-
1,
|
| 154 |
-
-.1055613458156586,
|
| 155 |
-
-.0638541728258133
|
| 156 |
-
],
|
| 157 |
-
[
|
| 158 |
-
1,
|
| 159 |
-
-.0894841775298119,
|
| 160 |
-
-1.2914855480194092
|
| 161 |
-
]
|
| 162 |
-
];
|
| 163 |
-
var MATRIX_LMS_TO_OKLAB = [
|
| 164 |
-
[
|
| 165 |
-
.210454268309314,
|
| 166 |
-
.7936177747023054,
|
| 167 |
-
-.0040720430116193
|
| 168 |
-
],
|
| 169 |
-
[
|
| 170 |
-
1.9779985324311684,
|
| 171 |
-
-2.42859224204858,
|
| 172 |
-
.450593709617411
|
| 173 |
-
],
|
| 174 |
-
[
|
| 175 |
-
.0259040424655478,
|
| 176 |
-
.7827717124575296,
|
| 177 |
-
-.8086757549230774
|
| 178 |
-
]
|
| 179 |
-
];
|
| 180 |
-
var MATRIX_P3_TO_XYZ = [
|
| 181 |
-
[
|
| 182 |
-
608311 / 1250200,
|
| 183 |
-
189793 / 714400,
|
| 184 |
-
198249 / 1000160
|
| 185 |
-
],
|
| 186 |
-
[
|
| 187 |
-
35783 / 156275,
|
| 188 |
-
247089 / 357200,
|
| 189 |
-
198249 / 2500400
|
| 190 |
-
],
|
| 191 |
-
[
|
| 192 |
-
0 / 1,
|
| 193 |
-
32229 / 714400,
|
| 194 |
-
5220557 / 5000800
|
| 195 |
-
]
|
| 196 |
-
];
|
| 197 |
-
var MATRIX_REC2020_TO_XYZ = [
|
| 198 |
-
[
|
| 199 |
-
63426534 / 99577255,
|
| 200 |
-
20160776 / 139408157,
|
| 201 |
-
47086771 / 278816314
|
| 202 |
-
],
|
| 203 |
-
[
|
| 204 |
-
26158966 / 99577255,
|
| 205 |
-
472592308 / 697040785,
|
| 206 |
-
8267143 / 139408157
|
| 207 |
-
],
|
| 208 |
-
[
|
| 209 |
-
0 / 1,
|
| 210 |
-
19567812 / 697040785,
|
| 211 |
-
295819943 / 278816314
|
| 212 |
-
]
|
| 213 |
-
];
|
| 214 |
-
var MATRIX_A98_TO_XYZ = [
|
| 215 |
-
[
|
| 216 |
-
573536 / 994567,
|
| 217 |
-
263643 / 1420810,
|
| 218 |
-
187206 / 994567
|
| 219 |
-
],
|
| 220 |
-
[
|
| 221 |
-
591459 / 1989134,
|
| 222 |
-
6239551 / 9945670,
|
| 223 |
-
374412 / 4972835
|
| 224 |
-
],
|
| 225 |
-
[
|
| 226 |
-
53769 / 1989134,
|
| 227 |
-
351524 / 4972835,
|
| 228 |
-
4929758 / 4972835
|
| 229 |
-
]
|
| 230 |
-
];
|
| 231 |
-
var MATRIX_PROPHOTO_TO_XYZ_D50 = [
|
| 232 |
-
[
|
| 233 |
-
.7977666449006423,
|
| 234 |
-
.13518129740053308,
|
| 235 |
-
.0313477341283922
|
| 236 |
-
],
|
| 237 |
-
[
|
| 238 |
-
.2880748288194013,
|
| 239 |
-
.711835234241873,
|
| 240 |
-
8993693872564e-17
|
| 241 |
-
],
|
| 242 |
-
[
|
| 243 |
-
0,
|
| 244 |
-
0,
|
| 245 |
-
.8251046025104602
|
| 246 |
-
]
|
| 247 |
-
];
|
| 248 |
-
var REG_COLOR = new RegExp(`^(?:${SYN_COLOR_TYPE})$`);
|
| 249 |
-
var REG_CS_HUE = new RegExp(`^${CS_HUE_CAPT}$`);
|
| 250 |
-
var REG_CS_XYZ = /^xyz(?:-d(?:50|65))?$/;
|
| 251 |
-
var REG_CURRENT = /^currentColor$/i;
|
| 252 |
-
var REG_FN_COLOR = new RegExp(`^color\\(\\s*(${SYN_FN_COLOR})\\s*\\)$`);
|
| 253 |
-
var REG_HSL = new RegExp(`^hsla?\\(\\s*(${SYN_HSL}|${SYN_HSL_LV3})\\s*\\)$`);
|
| 254 |
-
var REG_HWB = new RegExp(`^hwb\\(\\s*(${SYN_HSL})\\s*\\)$`);
|
| 255 |
-
var REG_LAB = new RegExp(`^lab\\(\\s*(${SYN_MOD})\\s*\\)$`);
|
| 256 |
-
var REG_LCH = new RegExp(`^lch\\(\\s*(${SYN_LCH})\\s*\\)$`);
|
| 257 |
-
var REG_MIX = new RegExp(`^${SYN_MIX}$`);
|
| 258 |
-
var REG_MIX_CAPT = new RegExp(`^${SYN_MIX_CAPT}$`);
|
| 259 |
-
var REG_MIX_NEST = new RegExp(`${SYN_MIX}`, "g");
|
| 260 |
-
var REG_OKLAB = new RegExp(`^oklab\\(\\s*(${SYN_MOD})\\s*\\)$`);
|
| 261 |
-
var REG_OKLCH = new RegExp(`^oklch\\(\\s*(${SYN_LCH})\\s*\\)$`);
|
| 262 |
-
var REG_SPEC = /^(?:specifi|comput)edValue$/;
|
| 263 |
-
var REG_ANGLE_TO_DEG = new RegExp(`^(${NUM})(${ANGLE})?$`);
|
| 264 |
-
var REG_PARSE_RGB = new RegExp(`^rgba?\\(\\s*(${SYN_MOD}|${SYN_RGB_LV3})\\s*\\)$`);
|
| 265 |
-
var REG_MIX_CS_RGB_XYZ = new RegExp(`^(?:${CS_RGB}|${CS_XYZ})$`);
|
| 266 |
-
var REG_MIX_IN_CS = new RegExp(`in\\s+(${CS_MIX})`);
|
| 267 |
-
var REG_MIX_START = new RegExp(`^color-mix\\(\\s*in\\s+(${CS_MIX})\\s*,`);
|
| 268 |
-
var REG_MIX_COLOR_PART = new RegExp(`^(${SYN_COLOR_TYPE})(?:\\s+(${PCT}))?$`);
|
| 269 |
-
/**
|
| 270 |
-
* named colors
|
| 271 |
-
*/
|
| 272 |
-
var NAMED_COLORS = {
|
| 273 |
-
aliceblue: [
|
| 274 |
-
240,
|
| 275 |
-
248,
|
| 276 |
-
255
|
| 277 |
-
],
|
| 278 |
-
antiquewhite: [
|
| 279 |
-
250,
|
| 280 |
-
235,
|
| 281 |
-
215
|
| 282 |
-
],
|
| 283 |
-
aqua: [
|
| 284 |
-
0,
|
| 285 |
-
255,
|
| 286 |
-
255
|
| 287 |
-
],
|
| 288 |
-
aquamarine: [
|
| 289 |
-
127,
|
| 290 |
-
255,
|
| 291 |
-
212
|
| 292 |
-
],
|
| 293 |
-
azure: [
|
| 294 |
-
240,
|
| 295 |
-
255,
|
| 296 |
-
255
|
| 297 |
-
],
|
| 298 |
-
beige: [
|
| 299 |
-
245,
|
| 300 |
-
245,
|
| 301 |
-
220
|
| 302 |
-
],
|
| 303 |
-
bisque: [
|
| 304 |
-
255,
|
| 305 |
-
228,
|
| 306 |
-
196
|
| 307 |
-
],
|
| 308 |
-
black: [
|
| 309 |
-
0,
|
| 310 |
-
0,
|
| 311 |
-
0
|
| 312 |
-
],
|
| 313 |
-
blanchedalmond: [
|
| 314 |
-
255,
|
| 315 |
-
235,
|
| 316 |
-
205
|
| 317 |
-
],
|
| 318 |
-
blue: [
|
| 319 |
-
0,
|
| 320 |
-
0,
|
| 321 |
-
255
|
| 322 |
-
],
|
| 323 |
-
blueviolet: [
|
| 324 |
-
138,
|
| 325 |
-
43,
|
| 326 |
-
226
|
| 327 |
-
],
|
| 328 |
-
brown: [
|
| 329 |
-
165,
|
| 330 |
-
42,
|
| 331 |
-
42
|
| 332 |
-
],
|
| 333 |
-
burlywood: [
|
| 334 |
-
222,
|
| 335 |
-
184,
|
| 336 |
-
135
|
| 337 |
-
],
|
| 338 |
-
cadetblue: [
|
| 339 |
-
95,
|
| 340 |
-
158,
|
| 341 |
-
160
|
| 342 |
-
],
|
| 343 |
-
chartreuse: [
|
| 344 |
-
127,
|
| 345 |
-
255,
|
| 346 |
-
0
|
| 347 |
-
],
|
| 348 |
-
chocolate: [
|
| 349 |
-
210,
|
| 350 |
-
105,
|
| 351 |
-
30
|
| 352 |
-
],
|
| 353 |
-
coral: [
|
| 354 |
-
255,
|
| 355 |
-
127,
|
| 356 |
-
80
|
| 357 |
-
],
|
| 358 |
-
cornflowerblue: [
|
| 359 |
-
100,
|
| 360 |
-
149,
|
| 361 |
-
237
|
| 362 |
-
],
|
| 363 |
-
cornsilk: [
|
| 364 |
-
255,
|
| 365 |
-
248,
|
| 366 |
-
220
|
| 367 |
-
],
|
| 368 |
-
crimson: [
|
| 369 |
-
220,
|
| 370 |
-
20,
|
| 371 |
-
60
|
| 372 |
-
],
|
| 373 |
-
cyan: [
|
| 374 |
-
0,
|
| 375 |
-
255,
|
| 376 |
-
255
|
| 377 |
-
],
|
| 378 |
-
darkblue: [
|
| 379 |
-
0,
|
| 380 |
-
0,
|
| 381 |
-
139
|
| 382 |
-
],
|
| 383 |
-
darkcyan: [
|
| 384 |
-
0,
|
| 385 |
-
139,
|
| 386 |
-
139
|
| 387 |
-
],
|
| 388 |
-
darkgoldenrod: [
|
| 389 |
-
184,
|
| 390 |
-
134,
|
| 391 |
-
11
|
| 392 |
-
],
|
| 393 |
-
darkgray: [
|
| 394 |
-
169,
|
| 395 |
-
169,
|
| 396 |
-
169
|
| 397 |
-
],
|
| 398 |
-
darkgreen: [
|
| 399 |
-
0,
|
| 400 |
-
100,
|
| 401 |
-
0
|
| 402 |
-
],
|
| 403 |
-
darkgrey: [
|
| 404 |
-
169,
|
| 405 |
-
169,
|
| 406 |
-
169
|
| 407 |
-
],
|
| 408 |
-
darkkhaki: [
|
| 409 |
-
189,
|
| 410 |
-
183,
|
| 411 |
-
107
|
| 412 |
-
],
|
| 413 |
-
darkmagenta: [
|
| 414 |
-
139,
|
| 415 |
-
0,
|
| 416 |
-
139
|
| 417 |
-
],
|
| 418 |
-
darkolivegreen: [
|
| 419 |
-
85,
|
| 420 |
-
107,
|
| 421 |
-
47
|
| 422 |
-
],
|
| 423 |
-
darkorange: [
|
| 424 |
-
255,
|
| 425 |
-
140,
|
| 426 |
-
0
|
| 427 |
-
],
|
| 428 |
-
darkorchid: [
|
| 429 |
-
153,
|
| 430 |
-
50,
|
| 431 |
-
204
|
| 432 |
-
],
|
| 433 |
-
darkred: [
|
| 434 |
-
139,
|
| 435 |
-
0,
|
| 436 |
-
0
|
| 437 |
-
],
|
| 438 |
-
darksalmon: [
|
| 439 |
-
233,
|
| 440 |
-
150,
|
| 441 |
-
122
|
| 442 |
-
],
|
| 443 |
-
darkseagreen: [
|
| 444 |
-
143,
|
| 445 |
-
188,
|
| 446 |
-
143
|
| 447 |
-
],
|
| 448 |
-
darkslateblue: [
|
| 449 |
-
72,
|
| 450 |
-
61,
|
| 451 |
-
139
|
| 452 |
-
],
|
| 453 |
-
darkslategray: [
|
| 454 |
-
47,
|
| 455 |
-
79,
|
| 456 |
-
79
|
| 457 |
-
],
|
| 458 |
-
darkslategrey: [
|
| 459 |
-
47,
|
| 460 |
-
79,
|
| 461 |
-
79
|
| 462 |
-
],
|
| 463 |
-
darkturquoise: [
|
| 464 |
-
0,
|
| 465 |
-
206,
|
| 466 |
-
209
|
| 467 |
-
],
|
| 468 |
-
darkviolet: [
|
| 469 |
-
148,
|
| 470 |
-
0,
|
| 471 |
-
211
|
| 472 |
-
],
|
| 473 |
-
deeppink: [
|
| 474 |
-
255,
|
| 475 |
-
20,
|
| 476 |
-
147
|
| 477 |
-
],
|
| 478 |
-
deepskyblue: [
|
| 479 |
-
0,
|
| 480 |
-
191,
|
| 481 |
-
255
|
| 482 |
-
],
|
| 483 |
-
dimgray: [
|
| 484 |
-
105,
|
| 485 |
-
105,
|
| 486 |
-
105
|
| 487 |
-
],
|
| 488 |
-
dimgrey: [
|
| 489 |
-
105,
|
| 490 |
-
105,
|
| 491 |
-
105
|
| 492 |
-
],
|
| 493 |
-
dodgerblue: [
|
| 494 |
-
30,
|
| 495 |
-
144,
|
| 496 |
-
255
|
| 497 |
-
],
|
| 498 |
-
firebrick: [
|
| 499 |
-
178,
|
| 500 |
-
34,
|
| 501 |
-
34
|
| 502 |
-
],
|
| 503 |
-
floralwhite: [
|
| 504 |
-
255,
|
| 505 |
-
250,
|
| 506 |
-
240
|
| 507 |
-
],
|
| 508 |
-
forestgreen: [
|
| 509 |
-
34,
|
| 510 |
-
139,
|
| 511 |
-
34
|
| 512 |
-
],
|
| 513 |
-
fuchsia: [
|
| 514 |
-
255,
|
| 515 |
-
0,
|
| 516 |
-
255
|
| 517 |
-
],
|
| 518 |
-
gainsboro: [
|
| 519 |
-
220,
|
| 520 |
-
220,
|
| 521 |
-
220
|
| 522 |
-
],
|
| 523 |
-
ghostwhite: [
|
| 524 |
-
248,
|
| 525 |
-
248,
|
| 526 |
-
255
|
| 527 |
-
],
|
| 528 |
-
gold: [
|
| 529 |
-
255,
|
| 530 |
-
215,
|
| 531 |
-
0
|
| 532 |
-
],
|
| 533 |
-
goldenrod: [
|
| 534 |
-
218,
|
| 535 |
-
165,
|
| 536 |
-
32
|
| 537 |
-
],
|
| 538 |
-
gray: [
|
| 539 |
-
128,
|
| 540 |
-
128,
|
| 541 |
-
128
|
| 542 |
-
],
|
| 543 |
-
green: [
|
| 544 |
-
0,
|
| 545 |
-
128,
|
| 546 |
-
0
|
| 547 |
-
],
|
| 548 |
-
greenyellow: [
|
| 549 |
-
173,
|
| 550 |
-
255,
|
| 551 |
-
47
|
| 552 |
-
],
|
| 553 |
-
grey: [
|
| 554 |
-
128,
|
| 555 |
-
128,
|
| 556 |
-
128
|
| 557 |
-
],
|
| 558 |
-
honeydew: [
|
| 559 |
-
240,
|
| 560 |
-
255,
|
| 561 |
-
240
|
| 562 |
-
],
|
| 563 |
-
hotpink: [
|
| 564 |
-
255,
|
| 565 |
-
105,
|
| 566 |
-
180
|
| 567 |
-
],
|
| 568 |
-
indianred: [
|
| 569 |
-
205,
|
| 570 |
-
92,
|
| 571 |
-
92
|
| 572 |
-
],
|
| 573 |
-
indigo: [
|
| 574 |
-
75,
|
| 575 |
-
0,
|
| 576 |
-
130
|
| 577 |
-
],
|
| 578 |
-
ivory: [
|
| 579 |
-
255,
|
| 580 |
-
255,
|
| 581 |
-
240
|
| 582 |
-
],
|
| 583 |
-
khaki: [
|
| 584 |
-
240,
|
| 585 |
-
230,
|
| 586 |
-
140
|
| 587 |
-
],
|
| 588 |
-
lavender: [
|
| 589 |
-
230,
|
| 590 |
-
230,
|
| 591 |
-
250
|
| 592 |
-
],
|
| 593 |
-
lavenderblush: [
|
| 594 |
-
255,
|
| 595 |
-
240,
|
| 596 |
-
245
|
| 597 |
-
],
|
| 598 |
-
lawngreen: [
|
| 599 |
-
124,
|
| 600 |
-
252,
|
| 601 |
-
0
|
| 602 |
-
],
|
| 603 |
-
lemonchiffon: [
|
| 604 |
-
255,
|
| 605 |
-
250,
|
| 606 |
-
205
|
| 607 |
-
],
|
| 608 |
-
lightblue: [
|
| 609 |
-
173,
|
| 610 |
-
216,
|
| 611 |
-
230
|
| 612 |
-
],
|
| 613 |
-
lightcoral: [
|
| 614 |
-
240,
|
| 615 |
-
128,
|
| 616 |
-
128
|
| 617 |
-
],
|
| 618 |
-
lightcyan: [
|
| 619 |
-
224,
|
| 620 |
-
255,
|
| 621 |
-
255
|
| 622 |
-
],
|
| 623 |
-
lightgoldenrodyellow: [
|
| 624 |
-
250,
|
| 625 |
-
250,
|
| 626 |
-
210
|
| 627 |
-
],
|
| 628 |
-
lightgray: [
|
| 629 |
-
211,
|
| 630 |
-
211,
|
| 631 |
-
211
|
| 632 |
-
],
|
| 633 |
-
lightgreen: [
|
| 634 |
-
144,
|
| 635 |
-
238,
|
| 636 |
-
144
|
| 637 |
-
],
|
| 638 |
-
lightgrey: [
|
| 639 |
-
211,
|
| 640 |
-
211,
|
| 641 |
-
211
|
| 642 |
-
],
|
| 643 |
-
lightpink: [
|
| 644 |
-
255,
|
| 645 |
-
182,
|
| 646 |
-
193
|
| 647 |
-
],
|
| 648 |
-
lightsalmon: [
|
| 649 |
-
255,
|
| 650 |
-
160,
|
| 651 |
-
122
|
| 652 |
-
],
|
| 653 |
-
lightseagreen: [
|
| 654 |
-
32,
|
| 655 |
-
178,
|
| 656 |
-
170
|
| 657 |
-
],
|
| 658 |
-
lightskyblue: [
|
| 659 |
-
135,
|
| 660 |
-
206,
|
| 661 |
-
250
|
| 662 |
-
],
|
| 663 |
-
lightslategray: [
|
| 664 |
-
119,
|
| 665 |
-
136,
|
| 666 |
-
153
|
| 667 |
-
],
|
| 668 |
-
lightslategrey: [
|
| 669 |
-
119,
|
| 670 |
-
136,
|
| 671 |
-
153
|
| 672 |
-
],
|
| 673 |
-
lightsteelblue: [
|
| 674 |
-
176,
|
| 675 |
-
196,
|
| 676 |
-
222
|
| 677 |
-
],
|
| 678 |
-
lightyellow: [
|
| 679 |
-
255,
|
| 680 |
-
255,
|
| 681 |
-
224
|
| 682 |
-
],
|
| 683 |
-
lime: [
|
| 684 |
-
0,
|
| 685 |
-
255,
|
| 686 |
-
0
|
| 687 |
-
],
|
| 688 |
-
limegreen: [
|
| 689 |
-
50,
|
| 690 |
-
205,
|
| 691 |
-
50
|
| 692 |
-
],
|
| 693 |
-
linen: [
|
| 694 |
-
250,
|
| 695 |
-
240,
|
| 696 |
-
230
|
| 697 |
-
],
|
| 698 |
-
magenta: [
|
| 699 |
-
255,
|
| 700 |
-
0,
|
| 701 |
-
255
|
| 702 |
-
],
|
| 703 |
-
maroon: [
|
| 704 |
-
128,
|
| 705 |
-
0,
|
| 706 |
-
0
|
| 707 |
-
],
|
| 708 |
-
mediumaquamarine: [
|
| 709 |
-
102,
|
| 710 |
-
205,
|
| 711 |
-
170
|
| 712 |
-
],
|
| 713 |
-
mediumblue: [
|
| 714 |
-
0,
|
| 715 |
-
0,
|
| 716 |
-
205
|
| 717 |
-
],
|
| 718 |
-
mediumorchid: [
|
| 719 |
-
186,
|
| 720 |
-
85,
|
| 721 |
-
211
|
| 722 |
-
],
|
| 723 |
-
mediumpurple: [
|
| 724 |
-
147,
|
| 725 |
-
112,
|
| 726 |
-
219
|
| 727 |
-
],
|
| 728 |
-
mediumseagreen: [
|
| 729 |
-
60,
|
| 730 |
-
179,
|
| 731 |
-
113
|
| 732 |
-
],
|
| 733 |
-
mediumslateblue: [
|
| 734 |
-
123,
|
| 735 |
-
104,
|
| 736 |
-
238
|
| 737 |
-
],
|
| 738 |
-
mediumspringgreen: [
|
| 739 |
-
0,
|
| 740 |
-
250,
|
| 741 |
-
154
|
| 742 |
-
],
|
| 743 |
-
mediumturquoise: [
|
| 744 |
-
72,
|
| 745 |
-
209,
|
| 746 |
-
204
|
| 747 |
-
],
|
| 748 |
-
mediumvioletred: [
|
| 749 |
-
199,
|
| 750 |
-
21,
|
| 751 |
-
133
|
| 752 |
-
],
|
| 753 |
-
midnightblue: [
|
| 754 |
-
25,
|
| 755 |
-
25,
|
| 756 |
-
112
|
| 757 |
-
],
|
| 758 |
-
mintcream: [
|
| 759 |
-
245,
|
| 760 |
-
255,
|
| 761 |
-
250
|
| 762 |
-
],
|
| 763 |
-
mistyrose: [
|
| 764 |
-
255,
|
| 765 |
-
228,
|
| 766 |
-
225
|
| 767 |
-
],
|
| 768 |
-
moccasin: [
|
| 769 |
-
255,
|
| 770 |
-
228,
|
| 771 |
-
181
|
| 772 |
-
],
|
| 773 |
-
navajowhite: [
|
| 774 |
-
255,
|
| 775 |
-
222,
|
| 776 |
-
173
|
| 777 |
-
],
|
| 778 |
-
navy: [
|
| 779 |
-
0,
|
| 780 |
-
0,
|
| 781 |
-
128
|
| 782 |
-
],
|
| 783 |
-
oldlace: [
|
| 784 |
-
253,
|
| 785 |
-
245,
|
| 786 |
-
230
|
| 787 |
-
],
|
| 788 |
-
olive: [
|
| 789 |
-
128,
|
| 790 |
-
128,
|
| 791 |
-
0
|
| 792 |
-
],
|
| 793 |
-
olivedrab: [
|
| 794 |
-
107,
|
| 795 |
-
142,
|
| 796 |
-
35
|
| 797 |
-
],
|
| 798 |
-
orange: [
|
| 799 |
-
255,
|
| 800 |
-
165,
|
| 801 |
-
0
|
| 802 |
-
],
|
| 803 |
-
orangered: [
|
| 804 |
-
255,
|
| 805 |
-
69,
|
| 806 |
-
0
|
| 807 |
-
],
|
| 808 |
-
orchid: [
|
| 809 |
-
218,
|
| 810 |
-
112,
|
| 811 |
-
214
|
| 812 |
-
],
|
| 813 |
-
palegoldenrod: [
|
| 814 |
-
238,
|
| 815 |
-
232,
|
| 816 |
-
170
|
| 817 |
-
],
|
| 818 |
-
palegreen: [
|
| 819 |
-
152,
|
| 820 |
-
251,
|
| 821 |
-
152
|
| 822 |
-
],
|
| 823 |
-
paleturquoise: [
|
| 824 |
-
175,
|
| 825 |
-
238,
|
| 826 |
-
238
|
| 827 |
-
],
|
| 828 |
-
palevioletred: [
|
| 829 |
-
219,
|
| 830 |
-
112,
|
| 831 |
-
147
|
| 832 |
-
],
|
| 833 |
-
papayawhip: [
|
| 834 |
-
255,
|
| 835 |
-
239,
|
| 836 |
-
213
|
| 837 |
-
],
|
| 838 |
-
peachpuff: [
|
| 839 |
-
255,
|
| 840 |
-
218,
|
| 841 |
-
185
|
| 842 |
-
],
|
| 843 |
-
peru: [
|
| 844 |
-
205,
|
| 845 |
-
133,
|
| 846 |
-
63
|
| 847 |
-
],
|
| 848 |
-
pink: [
|
| 849 |
-
255,
|
| 850 |
-
192,
|
| 851 |
-
203
|
| 852 |
-
],
|
| 853 |
-
plum: [
|
| 854 |
-
221,
|
| 855 |
-
160,
|
| 856 |
-
221
|
| 857 |
-
],
|
| 858 |
-
powderblue: [
|
| 859 |
-
176,
|
| 860 |
-
224,
|
| 861 |
-
230
|
| 862 |
-
],
|
| 863 |
-
purple: [
|
| 864 |
-
128,
|
| 865 |
-
0,
|
| 866 |
-
128
|
| 867 |
-
],
|
| 868 |
-
rebeccapurple: [
|
| 869 |
-
102,
|
| 870 |
-
51,
|
| 871 |
-
153
|
| 872 |
-
],
|
| 873 |
-
red: [
|
| 874 |
-
255,
|
| 875 |
-
0,
|
| 876 |
-
0
|
| 877 |
-
],
|
| 878 |
-
rosybrown: [
|
| 879 |
-
188,
|
| 880 |
-
143,
|
| 881 |
-
143
|
| 882 |
-
],
|
| 883 |
-
royalblue: [
|
| 884 |
-
65,
|
| 885 |
-
105,
|
| 886 |
-
225
|
| 887 |
-
],
|
| 888 |
-
saddlebrown: [
|
| 889 |
-
139,
|
| 890 |
-
69,
|
| 891 |
-
19
|
| 892 |
-
],
|
| 893 |
-
salmon: [
|
| 894 |
-
250,
|
| 895 |
-
128,
|
| 896 |
-
114
|
| 897 |
-
],
|
| 898 |
-
sandybrown: [
|
| 899 |
-
244,
|
| 900 |
-
164,
|
| 901 |
-
96
|
| 902 |
-
],
|
| 903 |
-
seagreen: [
|
| 904 |
-
46,
|
| 905 |
-
139,
|
| 906 |
-
87
|
| 907 |
-
],
|
| 908 |
-
seashell: [
|
| 909 |
-
255,
|
| 910 |
-
245,
|
| 911 |
-
238
|
| 912 |
-
],
|
| 913 |
-
sienna: [
|
| 914 |
-
160,
|
| 915 |
-
82,
|
| 916 |
-
45
|
| 917 |
-
],
|
| 918 |
-
silver: [
|
| 919 |
-
192,
|
| 920 |
-
192,
|
| 921 |
-
192
|
| 922 |
-
],
|
| 923 |
-
skyblue: [
|
| 924 |
-
135,
|
| 925 |
-
206,
|
| 926 |
-
235
|
| 927 |
-
],
|
| 928 |
-
slateblue: [
|
| 929 |
-
106,
|
| 930 |
-
90,
|
| 931 |
-
205
|
| 932 |
-
],
|
| 933 |
-
slategray: [
|
| 934 |
-
112,
|
| 935 |
-
128,
|
| 936 |
-
144
|
| 937 |
-
],
|
| 938 |
-
slategrey: [
|
| 939 |
-
112,
|
| 940 |
-
128,
|
| 941 |
-
144
|
| 942 |
-
],
|
| 943 |
-
snow: [
|
| 944 |
-
255,
|
| 945 |
-
250,
|
| 946 |
-
250
|
| 947 |
-
],
|
| 948 |
-
springgreen: [
|
| 949 |
-
0,
|
| 950 |
-
255,
|
| 951 |
-
127
|
| 952 |
-
],
|
| 953 |
-
steelblue: [
|
| 954 |
-
70,
|
| 955 |
-
130,
|
| 956 |
-
180
|
| 957 |
-
],
|
| 958 |
-
tan: [
|
| 959 |
-
210,
|
| 960 |
-
180,
|
| 961 |
-
140
|
| 962 |
-
],
|
| 963 |
-
teal: [
|
| 964 |
-
0,
|
| 965 |
-
128,
|
| 966 |
-
128
|
| 967 |
-
],
|
| 968 |
-
thistle: [
|
| 969 |
-
216,
|
| 970 |
-
191,
|
| 971 |
-
216
|
| 972 |
-
],
|
| 973 |
-
tomato: [
|
| 974 |
-
255,
|
| 975 |
-
99,
|
| 976 |
-
71
|
| 977 |
-
],
|
| 978 |
-
turquoise: [
|
| 979 |
-
64,
|
| 980 |
-
224,
|
| 981 |
-
208
|
| 982 |
-
],
|
| 983 |
-
violet: [
|
| 984 |
-
238,
|
| 985 |
-
130,
|
| 986 |
-
238
|
| 987 |
-
],
|
| 988 |
-
wheat: [
|
| 989 |
-
245,
|
| 990 |
-
222,
|
| 991 |
-
179
|
| 992 |
-
],
|
| 993 |
-
white: [
|
| 994 |
-
255,
|
| 995 |
-
255,
|
| 996 |
-
255
|
| 997 |
-
],
|
| 998 |
-
whitesmoke: [
|
| 999 |
-
245,
|
| 1000 |
-
245,
|
| 1001 |
-
245
|
| 1002 |
-
],
|
| 1003 |
-
yellow: [
|
| 1004 |
-
255,
|
| 1005 |
-
255,
|
| 1006 |
-
0
|
| 1007 |
-
],
|
| 1008 |
-
yellowgreen: [
|
| 1009 |
-
154,
|
| 1010 |
-
205,
|
| 1011 |
-
50
|
| 1012 |
-
]
|
| 1013 |
-
};
|
| 1014 |
-
/**
|
| 1015 |
-
* cache invalid color value
|
| 1016 |
-
* @param key - cache key
|
| 1017 |
-
* @param nullable - is nullable
|
| 1018 |
-
* @returns cached value
|
| 1019 |
-
*/
|
| 1020 |
-
var cacheInvalidColorValue = (cacheKey, format, nullable = false) => {
|
| 1021 |
-
if (format === "specifiedValue") {
|
| 1022 |
-
const res = "";
|
| 1023 |
-
setCache(cacheKey, res);
|
| 1024 |
-
return res;
|
| 1025 |
-
}
|
| 1026 |
-
if (nullable) {
|
| 1027 |
-
setCache(cacheKey, null);
|
| 1028 |
-
return new NullObject();
|
| 1029 |
-
}
|
| 1030 |
-
const res = [
|
| 1031 |
-
"rgb",
|
| 1032 |
-
0,
|
| 1033 |
-
0,
|
| 1034 |
-
0,
|
| 1035 |
-
0
|
| 1036 |
-
];
|
| 1037 |
-
setCache(cacheKey, res);
|
| 1038 |
-
return res;
|
| 1039 |
-
};
|
| 1040 |
-
/**
|
| 1041 |
-
* resolve invalid color value
|
| 1042 |
-
* @param format - output format
|
| 1043 |
-
* @param nullable - is nullable
|
| 1044 |
-
* @returns resolved value
|
| 1045 |
-
*/
|
| 1046 |
-
var resolveInvalidColorValue = (format, nullable = false) => {
|
| 1047 |
-
switch (format) {
|
| 1048 |
-
case "hsl":
|
| 1049 |
-
case "hwb":
|
| 1050 |
-
case VAL_MIX: return new NullObject();
|
| 1051 |
-
case VAL_SPEC: return "";
|
| 1052 |
-
default:
|
| 1053 |
-
if (nullable) return new NullObject();
|
| 1054 |
-
return [
|
| 1055 |
-
"rgb",
|
| 1056 |
-
0,
|
| 1057 |
-
0,
|
| 1058 |
-
0,
|
| 1059 |
-
0
|
| 1060 |
-
];
|
| 1061 |
-
}
|
| 1062 |
-
};
|
| 1063 |
-
/**
|
| 1064 |
-
* validate color components
|
| 1065 |
-
* @param arr - color components
|
| 1066 |
-
* @param [opt] - options
|
| 1067 |
-
* @param [opt.alpha] - alpha channel
|
| 1068 |
-
* @param [opt.minLength] - min length
|
| 1069 |
-
* @param [opt.maxLength] - max length
|
| 1070 |
-
* @param [opt.minRange] - min range
|
| 1071 |
-
* @param [opt.maxRange] - max range
|
| 1072 |
-
* @param [opt.validateRange] - validate range
|
| 1073 |
-
* @returns result - validated color components
|
| 1074 |
-
*/
|
| 1075 |
-
var validateColorComponents = (arr, opt = {}) => {
|
| 1076 |
-
if (!Array.isArray(arr)) throw new TypeError(`${arr} is not an array.`);
|
| 1077 |
-
const { alpha = false, minLength = TRIA, maxLength = QUAD, minRange = 0, maxRange = 1, validateRange = true } = opt;
|
| 1078 |
-
if (!Number.isFinite(minLength)) throw new TypeError(`${minLength} is not a number.`);
|
| 1079 |
-
if (!Number.isFinite(maxLength)) throw new TypeError(`${maxLength} is not a number.`);
|
| 1080 |
-
if (!Number.isFinite(minRange)) throw new TypeError(`${minRange} is not a number.`);
|
| 1081 |
-
if (!Number.isFinite(maxRange)) throw new TypeError(`${maxRange} is not a number.`);
|
| 1082 |
-
const l = arr.length;
|
| 1083 |
-
if (l < minLength || l > maxLength) throw new Error(`Unexpected array length ${l}.`);
|
| 1084 |
-
let i = 0;
|
| 1085 |
-
while (i < l) {
|
| 1086 |
-
const v = arr[i];
|
| 1087 |
-
if (!Number.isFinite(v)) throw new TypeError(`${v} is not a number.`);
|
| 1088 |
-
else if (i < TRIA && validateRange && (v < minRange || v > maxRange)) throw new RangeError(`${v} is not between ${minRange} and ${maxRange}.`);
|
| 1089 |
-
else if (i === TRIA && (v < 0 || v > 1)) throw new RangeError(`${v} is not between 0 and 1.`);
|
| 1090 |
-
i++;
|
| 1091 |
-
}
|
| 1092 |
-
if (alpha && l === TRIA) arr.push(1);
|
| 1093 |
-
return arr;
|
| 1094 |
-
};
|
| 1095 |
-
/**
|
| 1096 |
-
* transform matrix
|
| 1097 |
-
* @param mtx - 3 * 3 matrix
|
| 1098 |
-
* @param vct - vector
|
| 1099 |
-
* @param [skip] - skip validate
|
| 1100 |
-
* @returns TriColorChannels - [p1, p2, p3]
|
| 1101 |
-
*/
|
| 1102 |
-
var transformMatrix = (mtx, vct, skip = false) => {
|
| 1103 |
-
if (!Array.isArray(mtx)) throw new TypeError(`${mtx} is not an array.`);
|
| 1104 |
-
else if (mtx.length !== TRIA) throw new Error(`Unexpected array length ${mtx.length}.`);
|
| 1105 |
-
else if (!skip) for (let i of mtx) i = validateColorComponents(i, {
|
| 1106 |
-
maxLength: TRIA,
|
| 1107 |
-
validateRange: false
|
| 1108 |
-
});
|
| 1109 |
-
const [[r1c1, r1c2, r1c3], [r2c1, r2c2, r2c3], [r3c1, r3c2, r3c3]] = mtx;
|
| 1110 |
-
let v1, v2, v3;
|
| 1111 |
-
if (skip) [v1, v2, v3] = vct;
|
| 1112 |
-
else [v1, v2, v3] = validateColorComponents(vct, {
|
| 1113 |
-
maxLength: TRIA,
|
| 1114 |
-
validateRange: false
|
| 1115 |
-
});
|
| 1116 |
-
return [
|
| 1117 |
-
r1c1 * v1 + r1c2 * v2 + r1c3 * v3,
|
| 1118 |
-
r2c1 * v1 + r2c2 * v2 + r2c3 * v3,
|
| 1119 |
-
r3c1 * v1 + r3c2 * v2 + r3c3 * v3
|
| 1120 |
-
];
|
| 1121 |
-
};
|
| 1122 |
-
/**
|
| 1123 |
-
* normalize color components
|
| 1124 |
-
* @param colorA - color components [v1, v2, v3, v4]
|
| 1125 |
-
* @param colorB - color components [v1, v2, v3, v4]
|
| 1126 |
-
* @param [skip] - skip validate
|
| 1127 |
-
* @returns result - [colorA, colorB]
|
| 1128 |
-
*/
|
| 1129 |
-
var normalizeColorComponents = (colorA, colorB, skip = false) => {
|
| 1130 |
-
if (!Array.isArray(colorA)) throw new TypeError(`${colorA} is not an array.`);
|
| 1131 |
-
else if (colorA.length !== QUAD) throw new Error(`Unexpected array length ${colorA.length}.`);
|
| 1132 |
-
if (!Array.isArray(colorB)) throw new TypeError(`${colorB} is not an array.`);
|
| 1133 |
-
else if (colorB.length !== QUAD) throw new Error(`Unexpected array length ${colorB.length}.`);
|
| 1134 |
-
let i = 0;
|
| 1135 |
-
while (i < QUAD) {
|
| 1136 |
-
if (colorA[i] === "none" && colorB[i] === "none") {
|
| 1137 |
-
colorA[i] = 0;
|
| 1138 |
-
colorB[i] = 0;
|
| 1139 |
-
} else if (colorA[i] === "none") colorA[i] = colorB[i];
|
| 1140 |
-
else if (colorB[i] === "none") colorB[i] = colorA[i];
|
| 1141 |
-
i++;
|
| 1142 |
-
}
|
| 1143 |
-
if (skip) return [colorA, colorB];
|
| 1144 |
-
return [validateColorComponents(colorA, {
|
| 1145 |
-
minLength: QUAD,
|
| 1146 |
-
validateRange: false
|
| 1147 |
-
}), validateColorComponents(colorB, {
|
| 1148 |
-
minLength: QUAD,
|
| 1149 |
-
validateRange: false
|
| 1150 |
-
})];
|
| 1151 |
-
};
|
| 1152 |
-
/**
|
| 1153 |
-
* number to hex string
|
| 1154 |
-
* @param value - numeric value
|
| 1155 |
-
* @returns hex string
|
| 1156 |
-
*/
|
| 1157 |
-
var numberToHexString = (value) => {
|
| 1158 |
-
if (!Number.isFinite(value)) throw new TypeError(`${value} is not a number.`);
|
| 1159 |
-
else {
|
| 1160 |
-
value = Math.round(value);
|
| 1161 |
-
if (value < 0 || value > MAX_RGB) throw new RangeError(`${value} is not between 0 and ${MAX_RGB}.`);
|
| 1162 |
-
}
|
| 1163 |
-
let hex = value.toString(HEX);
|
| 1164 |
-
if (hex.length === 1) hex = `0${hex}`;
|
| 1165 |
-
return hex;
|
| 1166 |
-
};
|
| 1167 |
-
/**
|
| 1168 |
-
* angle to deg
|
| 1169 |
-
* @param angle
|
| 1170 |
-
* @returns deg: 0..360
|
| 1171 |
-
*/
|
| 1172 |
-
var angleToDeg = (angle) => {
|
| 1173 |
-
if (isString(angle)) angle = angle.trim();
|
| 1174 |
-
else throw new TypeError(`${angle} is not a string.`);
|
| 1175 |
-
const GRAD = DEG / 400;
|
| 1176 |
-
const RAD = DEG / (Math.PI * DUO);
|
| 1177 |
-
if (!REG_ANGLE_TO_DEG.test(angle)) throw new SyntaxError(`Invalid property value: ${angle}`);
|
| 1178 |
-
const [, value, unit] = angle.match(REG_ANGLE_TO_DEG);
|
| 1179 |
-
let deg;
|
| 1180 |
-
switch (unit) {
|
| 1181 |
-
case "grad":
|
| 1182 |
-
deg = parseFloat(value) * GRAD;
|
| 1183 |
-
break;
|
| 1184 |
-
case "rad":
|
| 1185 |
-
deg = parseFloat(value) * RAD;
|
| 1186 |
-
break;
|
| 1187 |
-
case "turn":
|
| 1188 |
-
deg = parseFloat(value) * DEG;
|
| 1189 |
-
break;
|
| 1190 |
-
default: deg = parseFloat(value);
|
| 1191 |
-
}
|
| 1192 |
-
deg %= DEG;
|
| 1193 |
-
if (deg < 0) deg += DEG;
|
| 1194 |
-
else if (Object.is(deg, -0)) deg = 0;
|
| 1195 |
-
return deg;
|
| 1196 |
-
};
|
| 1197 |
-
/**
|
| 1198 |
-
* parse alpha
|
| 1199 |
-
* @param [alpha] - alpha value
|
| 1200 |
-
* @returns alpha: 0..1
|
| 1201 |
-
*/
|
| 1202 |
-
var parseAlpha = (alpha = "") => {
|
| 1203 |
-
if (isString(alpha)) {
|
| 1204 |
-
alpha = alpha.trim();
|
| 1205 |
-
if (!alpha) alpha = "1";
|
| 1206 |
-
else if (alpha === "none") alpha = "0";
|
| 1207 |
-
else {
|
| 1208 |
-
let a;
|
| 1209 |
-
if (alpha.endsWith("%")) a = parseFloat(alpha) / MAX_PCT;
|
| 1210 |
-
else a = parseFloat(alpha);
|
| 1211 |
-
if (!Number.isFinite(a)) throw new TypeError(`${a} is not a finite number.`);
|
| 1212 |
-
if (a < PPTH) alpha = "0";
|
| 1213 |
-
else if (a > 1) alpha = "1";
|
| 1214 |
-
else alpha = a.toFixed(TRIA);
|
| 1215 |
-
}
|
| 1216 |
-
} else alpha = "1";
|
| 1217 |
-
return parseFloat(alpha);
|
| 1218 |
-
};
|
| 1219 |
-
/**
|
| 1220 |
-
* parse hex alpha
|
| 1221 |
-
* @param value - alpha value in hex string
|
| 1222 |
-
* @returns alpha: 0..1
|
| 1223 |
-
*/
|
| 1224 |
-
var parseHexAlpha = (value) => {
|
| 1225 |
-
if (isString(value)) {
|
| 1226 |
-
if (value === "") throw new SyntaxError("Invalid property value: (empty string)");
|
| 1227 |
-
value = value.trim();
|
| 1228 |
-
} else throw new TypeError(`${value} is not a string.`);
|
| 1229 |
-
let alpha = parseInt(value, HEX);
|
| 1230 |
-
if (alpha <= 0) return 0;
|
| 1231 |
-
if (alpha >= MAX_RGB) return 1;
|
| 1232 |
-
const alphaMap = /* @__PURE__ */ new Map();
|
| 1233 |
-
for (let i = 1; i < MAX_PCT; i++) alphaMap.set(Math.round(i * MAX_RGB / MAX_PCT), i);
|
| 1234 |
-
if (alphaMap.has(alpha)) alpha = alphaMap.get(alpha) / MAX_PCT;
|
| 1235 |
-
else alpha = Math.round(alpha / MAX_RGB / PPTH) * PPTH;
|
| 1236 |
-
return parseFloat(alpha.toFixed(TRIA));
|
| 1237 |
-
};
|
| 1238 |
-
/**
|
| 1239 |
-
* transform rgb to linear rgb
|
| 1240 |
-
* @param rgb - [r, g, b] r|g|b: 0..255
|
| 1241 |
-
* @param [skip] - skip validate
|
| 1242 |
-
* @returns TriColorChannels - [r, g, b] r|g|b: 0..1
|
| 1243 |
-
*/
|
| 1244 |
-
var transformRgbToLinearRgb = (rgb, skip = false) => {
|
| 1245 |
-
let rr, gg, bb;
|
| 1246 |
-
if (skip) [rr, gg, bb] = rgb;
|
| 1247 |
-
else [rr, gg, bb] = validateColorComponents(rgb, {
|
| 1248 |
-
maxLength: TRIA,
|
| 1249 |
-
maxRange: MAX_RGB
|
| 1250 |
-
});
|
| 1251 |
-
let r = rr / MAX_RGB;
|
| 1252 |
-
let g = gg / MAX_RGB;
|
| 1253 |
-
let b = bb / MAX_RGB;
|
| 1254 |
-
const COND_POW = .04045;
|
| 1255 |
-
if (r > COND_POW) r = Math.pow((r + LINEAR_OFFSET) / (1 + LINEAR_OFFSET), POW_LINEAR);
|
| 1256 |
-
else r /= LINEAR_COEF;
|
| 1257 |
-
if (g > COND_POW) g = Math.pow((g + LINEAR_OFFSET) / (1 + LINEAR_OFFSET), POW_LINEAR);
|
| 1258 |
-
else g /= LINEAR_COEF;
|
| 1259 |
-
if (b > COND_POW) b = Math.pow((b + LINEAR_OFFSET) / (1 + LINEAR_OFFSET), POW_LINEAR);
|
| 1260 |
-
else b /= LINEAR_COEF;
|
| 1261 |
-
return [
|
| 1262 |
-
r,
|
| 1263 |
-
g,
|
| 1264 |
-
b
|
| 1265 |
-
];
|
| 1266 |
-
};
|
| 1267 |
-
/**
|
| 1268 |
-
* transform rgb to xyz
|
| 1269 |
-
* @param rgb - [r, g, b] r|g|b: 0..255
|
| 1270 |
-
* @param [skip] - skip validate
|
| 1271 |
-
* @returns TriColorChannels - [x, y, z]
|
| 1272 |
-
*/
|
| 1273 |
-
var transformRgbToXyz = (rgb, skip = false) => {
|
| 1274 |
-
if (!skip) rgb = validateColorComponents(rgb, {
|
| 1275 |
-
maxLength: TRIA,
|
| 1276 |
-
maxRange: MAX_RGB
|
| 1277 |
-
});
|
| 1278 |
-
rgb = transformRgbToLinearRgb(rgb, true);
|
| 1279 |
-
return transformMatrix(MATRIX_L_RGB_TO_XYZ, rgb, true);
|
| 1280 |
-
};
|
| 1281 |
-
/**
|
| 1282 |
-
* transform linear rgb to rgb
|
| 1283 |
-
* @param rgb - [r, g, b] r|g|b: 0..1
|
| 1284 |
-
* @param [round] - round result
|
| 1285 |
-
* @returns TriColorChannels - [r, g, b] r|g|b: 0..255
|
| 1286 |
-
*/
|
| 1287 |
-
var transformLinearRgbToRgb = (rgb, round = false) => {
|
| 1288 |
-
let [r, g, b] = validateColorComponents(rgb, { maxLength: TRIA });
|
| 1289 |
-
const COND_POW = 809 / 258400;
|
| 1290 |
-
if (r > COND_POW) r = Math.pow(r, 1 / POW_LINEAR) * (1 + LINEAR_OFFSET) - LINEAR_OFFSET;
|
| 1291 |
-
else r *= LINEAR_COEF;
|
| 1292 |
-
r *= MAX_RGB;
|
| 1293 |
-
if (g > COND_POW) g = Math.pow(g, 1 / POW_LINEAR) * (1 + LINEAR_OFFSET) - LINEAR_OFFSET;
|
| 1294 |
-
else g *= LINEAR_COEF;
|
| 1295 |
-
g *= MAX_RGB;
|
| 1296 |
-
if (b > COND_POW) b = Math.pow(b, 1 / POW_LINEAR) * (1 + LINEAR_OFFSET) - LINEAR_OFFSET;
|
| 1297 |
-
else b *= LINEAR_COEF;
|
| 1298 |
-
b *= MAX_RGB;
|
| 1299 |
-
return [
|
| 1300 |
-
round ? Math.round(r) : r,
|
| 1301 |
-
round ? Math.round(g) : g,
|
| 1302 |
-
round ? Math.round(b) : b
|
| 1303 |
-
];
|
| 1304 |
-
};
|
| 1305 |
-
/**
|
| 1306 |
-
* transform xyz to rgb
|
| 1307 |
-
* @param xyz - [x, y, z]
|
| 1308 |
-
* @param [skip] - skip validate
|
| 1309 |
-
* @returns TriColorChannels - [r, g, b] r|g|b: 0..255
|
| 1310 |
-
*/
|
| 1311 |
-
var transformXyzToRgb = (xyz, skip = false) => {
|
| 1312 |
-
if (!skip) xyz = validateColorComponents(xyz, {
|
| 1313 |
-
maxLength: TRIA,
|
| 1314 |
-
validateRange: false
|
| 1315 |
-
});
|
| 1316 |
-
let [r, g, b] = transformMatrix(MATRIX_XYZ_TO_L_RGB, xyz, true);
|
| 1317 |
-
[r, g, b] = transformLinearRgbToRgb([
|
| 1318 |
-
Math.min(Math.max(r, 0), 1),
|
| 1319 |
-
Math.min(Math.max(g, 0), 1),
|
| 1320 |
-
Math.min(Math.max(b, 0), 1)
|
| 1321 |
-
], true);
|
| 1322 |
-
return [
|
| 1323 |
-
r,
|
| 1324 |
-
g,
|
| 1325 |
-
b
|
| 1326 |
-
];
|
| 1327 |
-
};
|
| 1328 |
-
/**
|
| 1329 |
-
* transform xyz to hsl
|
| 1330 |
-
* @param xyz - [x, y, z]
|
| 1331 |
-
* @param [skip] - skip validate
|
| 1332 |
-
* @returns TriColorChannels - [h, s, l]
|
| 1333 |
-
*/
|
| 1334 |
-
var transformXyzToHsl = (xyz, skip = false) => {
|
| 1335 |
-
const [rr, gg, bb] = transformXyzToRgb(xyz, skip);
|
| 1336 |
-
const r = rr / MAX_RGB;
|
| 1337 |
-
const g = gg / MAX_RGB;
|
| 1338 |
-
const b = bb / MAX_RGB;
|
| 1339 |
-
const max = Math.max(r, g, b);
|
| 1340 |
-
const min = Math.min(r, g, b);
|
| 1341 |
-
const d = max - min;
|
| 1342 |
-
const l = (max + min) * HALF * MAX_PCT;
|
| 1343 |
-
let h, s;
|
| 1344 |
-
if (Math.round(l) === 0 || Math.round(l) === MAX_PCT) {
|
| 1345 |
-
h = 0;
|
| 1346 |
-
s = 0;
|
| 1347 |
-
} else {
|
| 1348 |
-
s = d / (1 - Math.abs(max + min - 1)) * MAX_PCT;
|
| 1349 |
-
if (s === 0) h = 0;
|
| 1350 |
-
else {
|
| 1351 |
-
switch (max) {
|
| 1352 |
-
case r:
|
| 1353 |
-
h = (g - b) / d;
|
| 1354 |
-
break;
|
| 1355 |
-
case g:
|
| 1356 |
-
h = (b - r) / d + DUO;
|
| 1357 |
-
break;
|
| 1358 |
-
case b:
|
| 1359 |
-
default:
|
| 1360 |
-
h = (r - g) / d + QUAD;
|
| 1361 |
-
break;
|
| 1362 |
-
}
|
| 1363 |
-
h = h * SEXA % DEG;
|
| 1364 |
-
if (h < 0) h += DEG;
|
| 1365 |
-
}
|
| 1366 |
-
}
|
| 1367 |
-
return [
|
| 1368 |
-
h,
|
| 1369 |
-
s,
|
| 1370 |
-
l
|
| 1371 |
-
];
|
| 1372 |
-
};
|
| 1373 |
-
/**
|
| 1374 |
-
* transform xyz to hwb
|
| 1375 |
-
* @param xyz - [x, y, z]
|
| 1376 |
-
* @param [skip] - skip validate
|
| 1377 |
-
* @returns TriColorChannels - [h, w, b]
|
| 1378 |
-
*/
|
| 1379 |
-
var transformXyzToHwb = (xyz, skip = false) => {
|
| 1380 |
-
const [r, g, b] = transformXyzToRgb(xyz, skip);
|
| 1381 |
-
const wh = Math.min(r, g, b) / MAX_RGB;
|
| 1382 |
-
const bk = 1 - Math.max(r, g, b) / MAX_RGB;
|
| 1383 |
-
let h;
|
| 1384 |
-
if (wh + bk === 1) h = 0;
|
| 1385 |
-
else [h] = transformXyzToHsl(xyz);
|
| 1386 |
-
return [
|
| 1387 |
-
h,
|
| 1388 |
-
wh * MAX_PCT,
|
| 1389 |
-
bk * MAX_PCT
|
| 1390 |
-
];
|
| 1391 |
-
};
|
| 1392 |
-
/**
|
| 1393 |
-
* transform xyz to oklab
|
| 1394 |
-
* @param xyz - [x, y, z]
|
| 1395 |
-
* @param [skip] - skip validate
|
| 1396 |
-
* @returns TriColorChannels - [l, a, b]
|
| 1397 |
-
*/
|
| 1398 |
-
var transformXyzToOklab = (xyz, skip = false) => {
|
| 1399 |
-
if (!skip) xyz = validateColorComponents(xyz, {
|
| 1400 |
-
maxLength: TRIA,
|
| 1401 |
-
validateRange: false
|
| 1402 |
-
});
|
| 1403 |
-
let [l, a, b] = transformMatrix(MATRIX_LMS_TO_OKLAB, transformMatrix(MATRIX_XYZ_TO_LMS, xyz, true).map((c) => Math.cbrt(c)), true);
|
| 1404 |
-
l = Math.min(Math.max(l, 0), 1);
|
| 1405 |
-
const lPct = Math.round(parseFloat(l.toFixed(QUAD)) * MAX_PCT);
|
| 1406 |
-
if (lPct === 0 || lPct === MAX_PCT) {
|
| 1407 |
-
a = 0;
|
| 1408 |
-
b = 0;
|
| 1409 |
-
}
|
| 1410 |
-
return [
|
| 1411 |
-
l,
|
| 1412 |
-
a,
|
| 1413 |
-
b
|
| 1414 |
-
];
|
| 1415 |
-
};
|
| 1416 |
-
/**
|
| 1417 |
-
* transform xyz to oklch
|
| 1418 |
-
* @param xyz - [x, y, z]
|
| 1419 |
-
* @param [skip] - skip validate
|
| 1420 |
-
* @returns TriColorChannels - [l, c, h]
|
| 1421 |
-
*/
|
| 1422 |
-
var transformXyzToOklch = (xyz, skip = false) => {
|
| 1423 |
-
const [l, a, b] = transformXyzToOklab(xyz, skip);
|
| 1424 |
-
let c, h;
|
| 1425 |
-
const lPct = Math.round(parseFloat(l.toFixed(QUAD)) * MAX_PCT);
|
| 1426 |
-
if (lPct === 0 || lPct === MAX_PCT) {
|
| 1427 |
-
c = 0;
|
| 1428 |
-
h = 0;
|
| 1429 |
-
} else {
|
| 1430 |
-
c = Math.max(Math.sqrt(Math.pow(a, POW_SQR) + Math.pow(b, POW_SQR)), 0);
|
| 1431 |
-
if (parseFloat(c.toFixed(QUAD)) === 0) h = 0;
|
| 1432 |
-
else {
|
| 1433 |
-
h = Math.atan2(b, a) * DEG_HALF / Math.PI;
|
| 1434 |
-
if (h < 0) h += DEG;
|
| 1435 |
-
}
|
| 1436 |
-
}
|
| 1437 |
-
return [
|
| 1438 |
-
l,
|
| 1439 |
-
c,
|
| 1440 |
-
h
|
| 1441 |
-
];
|
| 1442 |
-
};
|
| 1443 |
-
/**
|
| 1444 |
-
* transform xyz D50 to rgb
|
| 1445 |
-
* @param xyz - [x, y, z]
|
| 1446 |
-
* @param [skip] - skip validate
|
| 1447 |
-
* @returns TriColorChannels - [r, g, b] r|g|b: 0..255
|
| 1448 |
-
*/
|
| 1449 |
-
var transformXyzD50ToRgb = (xyz, skip = false) => {
|
| 1450 |
-
if (!skip) xyz = validateColorComponents(xyz, {
|
| 1451 |
-
maxLength: TRIA,
|
| 1452 |
-
validateRange: false
|
| 1453 |
-
});
|
| 1454 |
-
return transformXyzToRgb(transformMatrix(MATRIX_D50_TO_D65, xyz, true), true);
|
| 1455 |
-
};
|
| 1456 |
-
/**
|
| 1457 |
-
* transform xyz-d50 to lab
|
| 1458 |
-
* @param xyz - [x, y, z]
|
| 1459 |
-
* @param [skip] - skip validate
|
| 1460 |
-
* @returns TriColorChannels - [l, a, b]
|
| 1461 |
-
*/
|
| 1462 |
-
var transformXyzD50ToLab = (xyz, skip = false) => {
|
| 1463 |
-
if (!skip) xyz = validateColorComponents(xyz, {
|
| 1464 |
-
maxLength: TRIA,
|
| 1465 |
-
validateRange: false
|
| 1466 |
-
});
|
| 1467 |
-
const [f0, f1, f2] = xyz.map((val, i) => val / D50[i]).map((val) => val > LAB_EPSILON ? Math.cbrt(val) : (val * LAB_KAPPA + HEX) / LAB_L);
|
| 1468 |
-
const l = Math.min(Math.max(LAB_L * f1 - HEX, 0), MAX_PCT);
|
| 1469 |
-
let a, b;
|
| 1470 |
-
if (l === 0 || l === MAX_PCT) {
|
| 1471 |
-
a = 0;
|
| 1472 |
-
b = 0;
|
| 1473 |
-
} else {
|
| 1474 |
-
a = (f0 - f1) * LAB_A;
|
| 1475 |
-
b = (f1 - f2) * LAB_B;
|
| 1476 |
-
}
|
| 1477 |
-
return [
|
| 1478 |
-
l,
|
| 1479 |
-
a,
|
| 1480 |
-
b
|
| 1481 |
-
];
|
| 1482 |
-
};
|
| 1483 |
-
/**
|
| 1484 |
-
* transform xyz-d50 to lch
|
| 1485 |
-
* @param xyz - [x, y, z]
|
| 1486 |
-
* @param [skip] - skip validate
|
| 1487 |
-
* @returns TriColorChannels - [l, c, h]
|
| 1488 |
-
*/
|
| 1489 |
-
var transformXyzD50ToLch = (xyz, skip = false) => {
|
| 1490 |
-
const [l, a, b] = transformXyzD50ToLab(xyz, skip);
|
| 1491 |
-
let c, h;
|
| 1492 |
-
if (l === 0 || l === MAX_PCT) {
|
| 1493 |
-
c = 0;
|
| 1494 |
-
h = 0;
|
| 1495 |
-
} else {
|
| 1496 |
-
c = Math.max(Math.sqrt(Math.pow(a, POW_SQR) + Math.pow(b, POW_SQR)), 0);
|
| 1497 |
-
h = Math.atan2(b, a) * DEG_HALF / Math.PI;
|
| 1498 |
-
if (h < 0) h += DEG;
|
| 1499 |
-
}
|
| 1500 |
-
return [
|
| 1501 |
-
l,
|
| 1502 |
-
c,
|
| 1503 |
-
h
|
| 1504 |
-
];
|
| 1505 |
-
};
|
| 1506 |
-
/**
|
| 1507 |
-
* convert rgb to hex color
|
| 1508 |
-
* @param rgb - [r, g, b, alpha] r|g|b: 0..255 alpha: 0..1
|
| 1509 |
-
* @returns hex color
|
| 1510 |
-
*/
|
| 1511 |
-
var convertRgbToHex = (rgb) => {
|
| 1512 |
-
const [r, g, b, alpha] = validateColorComponents(rgb, {
|
| 1513 |
-
alpha: true,
|
| 1514 |
-
maxRange: MAX_RGB
|
| 1515 |
-
});
|
| 1516 |
-
const rr = numberToHexString(r);
|
| 1517 |
-
const gg = numberToHexString(g);
|
| 1518 |
-
const bb = numberToHexString(b);
|
| 1519 |
-
const aa = numberToHexString(alpha * MAX_RGB);
|
| 1520 |
-
let hex;
|
| 1521 |
-
if (aa === "ff") hex = `#${rr}${gg}${bb}`;
|
| 1522 |
-
else hex = `#${rr}${gg}${bb}${aa}`;
|
| 1523 |
-
return hex;
|
| 1524 |
-
};
|
| 1525 |
-
/**
|
| 1526 |
-
* convert hex color to rgb
|
| 1527 |
-
* @param value - hex color value
|
| 1528 |
-
* @returns ColorChannels - [r, g, b, alpha] r|g|b: 0..255 alpha: 0..1
|
| 1529 |
-
*/
|
| 1530 |
-
var convertHexToRgb = (value) => {
|
| 1531 |
-
if (isString(value)) value = value.toLowerCase().trim();
|
| 1532 |
-
else throw new TypeError(`${value} is not a string.`);
|
| 1533 |
-
if (!(/^#[\da-f]{6}$/.test(value) || /^#[\da-f]{3}$/.test(value) || /^#[\da-f]{8}$/.test(value) || /^#[\da-f]{4}$/.test(value))) throw new SyntaxError(`Invalid property value: ${value}`);
|
| 1534 |
-
const arr = [];
|
| 1535 |
-
if (/^#[\da-f]{3}$/.test(value)) {
|
| 1536 |
-
const [, r, g, b] = value.match(/^#([\da-f])([\da-f])([\da-f])$/);
|
| 1537 |
-
arr.push(parseInt(`${r}${r}`, HEX), parseInt(`${g}${g}`, HEX), parseInt(`${b}${b}`, HEX), 1);
|
| 1538 |
-
} else if (/^#[\da-f]{4}$/.test(value)) {
|
| 1539 |
-
const [, r, g, b, alpha] = value.match(/^#([\da-f])([\da-f])([\da-f])([\da-f])$/);
|
| 1540 |
-
arr.push(parseInt(`${r}${r}`, HEX), parseInt(`${g}${g}`, HEX), parseInt(`${b}${b}`, HEX), parseHexAlpha(`${alpha}${alpha}`));
|
| 1541 |
-
} else if (/^#[\da-f]{8}$/.test(value)) {
|
| 1542 |
-
const [, r, g, b, alpha] = value.match(/^#([\da-f]{2})([\da-f]{2})([\da-f]{2})([\da-f]{2})$/);
|
| 1543 |
-
arr.push(parseInt(r, HEX), parseInt(g, HEX), parseInt(b, HEX), parseHexAlpha(alpha));
|
| 1544 |
-
} else {
|
| 1545 |
-
const [, r, g, b] = value.match(/^#([\da-f]{2})([\da-f]{2})([\da-f]{2})$/);
|
| 1546 |
-
arr.push(parseInt(r, HEX), parseInt(g, HEX), parseInt(b, HEX), 1);
|
| 1547 |
-
}
|
| 1548 |
-
return arr;
|
| 1549 |
-
};
|
| 1550 |
-
/**
|
| 1551 |
-
* convert hex color to linear rgb
|
| 1552 |
-
* @param value - hex color value
|
| 1553 |
-
* @returns ColorChannels - [r, g, b, alpha] r|g|b|alpha: 0..1
|
| 1554 |
-
*/
|
| 1555 |
-
var convertHexToLinearRgb = (value) => {
|
| 1556 |
-
const [rr, gg, bb, alpha] = convertHexToRgb(value);
|
| 1557 |
-
const [r, g, b] = transformRgbToLinearRgb([
|
| 1558 |
-
rr,
|
| 1559 |
-
gg,
|
| 1560 |
-
bb
|
| 1561 |
-
], true);
|
| 1562 |
-
return [
|
| 1563 |
-
r,
|
| 1564 |
-
g,
|
| 1565 |
-
b,
|
| 1566 |
-
alpha
|
| 1567 |
-
];
|
| 1568 |
-
};
|
| 1569 |
-
/**
|
| 1570 |
-
* convert hex color to xyz
|
| 1571 |
-
* @param value - hex color value
|
| 1572 |
-
* @returns ColorChannels - [x, y, z, alpha]
|
| 1573 |
-
*/
|
| 1574 |
-
var convertHexToXyz = (value) => {
|
| 1575 |
-
const [r, g, b, alpha] = convertHexToLinearRgb(value);
|
| 1576 |
-
const [x, y, z] = transformMatrix(MATRIX_L_RGB_TO_XYZ, [
|
| 1577 |
-
r,
|
| 1578 |
-
g,
|
| 1579 |
-
b
|
| 1580 |
-
], true);
|
| 1581 |
-
return [
|
| 1582 |
-
x,
|
| 1583 |
-
y,
|
| 1584 |
-
z,
|
| 1585 |
-
alpha
|
| 1586 |
-
];
|
| 1587 |
-
};
|
| 1588 |
-
/**
|
| 1589 |
-
* parse rgb()
|
| 1590 |
-
* @param value - rgb color value
|
| 1591 |
-
* @param [opt] - options
|
| 1592 |
-
* @returns parsed color - ['rgb', r, g, b, alpha], '(empty)', NullObject
|
| 1593 |
-
*/
|
| 1594 |
-
var parseRgb = (value, opt = {}) => {
|
| 1595 |
-
if (isString(value)) value = value.toLowerCase().trim();
|
| 1596 |
-
else throw new TypeError(`${value} is not a string.`);
|
| 1597 |
-
const { format = "", nullable = false } = opt;
|
| 1598 |
-
if (!REG_PARSE_RGB.test(value)) {
|
| 1599 |
-
const res = resolveInvalidColorValue(format, nullable);
|
| 1600 |
-
if (res instanceof NullObject) return res;
|
| 1601 |
-
if (isString(res)) return res;
|
| 1602 |
-
return res;
|
| 1603 |
-
}
|
| 1604 |
-
const [, val] = value.match(REG_PARSE_RGB);
|
| 1605 |
-
const [v1, v2, v3, v4 = ""] = val.match(/[^\s,/]+/g);
|
| 1606 |
-
let r, g, b;
|
| 1607 |
-
if (v1 === "none") r = 0;
|
| 1608 |
-
else {
|
| 1609 |
-
if (v1.endsWith("%")) r = parseFloat(v1) * MAX_RGB / MAX_PCT;
|
| 1610 |
-
else r = parseFloat(v1);
|
| 1611 |
-
r = Math.min(Math.max(roundToPrecision(r, OCT), 0), MAX_RGB);
|
| 1612 |
-
}
|
| 1613 |
-
if (v2 === "none") g = 0;
|
| 1614 |
-
else {
|
| 1615 |
-
if (v2.endsWith("%")) g = parseFloat(v2) * MAX_RGB / MAX_PCT;
|
| 1616 |
-
else g = parseFloat(v2);
|
| 1617 |
-
g = Math.min(Math.max(roundToPrecision(g, OCT), 0), MAX_RGB);
|
| 1618 |
-
}
|
| 1619 |
-
if (v3 === "none") b = 0;
|
| 1620 |
-
else {
|
| 1621 |
-
if (v3.endsWith("%")) b = parseFloat(v3) * MAX_RGB / MAX_PCT;
|
| 1622 |
-
else b = parseFloat(v3);
|
| 1623 |
-
b = Math.min(Math.max(roundToPrecision(b, OCT), 0), MAX_RGB);
|
| 1624 |
-
}
|
| 1625 |
-
const alpha = parseAlpha(v4);
|
| 1626 |
-
return [
|
| 1627 |
-
"rgb",
|
| 1628 |
-
r,
|
| 1629 |
-
g,
|
| 1630 |
-
b,
|
| 1631 |
-
format === "mixValue" && v4 === "none" ? NONE : alpha
|
| 1632 |
-
];
|
| 1633 |
-
};
|
| 1634 |
-
/**
|
| 1635 |
-
* parse hsl()
|
| 1636 |
-
* @param value - hsl color value
|
| 1637 |
-
* @param [opt] - options
|
| 1638 |
-
* @returns parsed color - ['rgb', r, g, b, alpha], '(empty)', NullObject
|
| 1639 |
-
*/
|
| 1640 |
-
var parseHsl = (value, opt = {}) => {
|
| 1641 |
-
if (isString(value)) value = value.trim();
|
| 1642 |
-
else throw new TypeError(`${value} is not a string.`);
|
| 1643 |
-
const { format = "", nullable = false } = opt;
|
| 1644 |
-
if (!REG_HSL.test(value)) {
|
| 1645 |
-
const res = resolveInvalidColorValue(format, nullable);
|
| 1646 |
-
if (res instanceof NullObject) return res;
|
| 1647 |
-
if (isString(res)) return res;
|
| 1648 |
-
return res;
|
| 1649 |
-
}
|
| 1650 |
-
const [, val] = value.match(REG_HSL);
|
| 1651 |
-
const [v1, v2, v3, v4 = ""] = val.match(/[^\s,/]+/g);
|
| 1652 |
-
let h, s, l;
|
| 1653 |
-
if (v1 === "none") h = 0;
|
| 1654 |
-
else h = angleToDeg(v1);
|
| 1655 |
-
if (v2 === "none") s = 0;
|
| 1656 |
-
else s = Math.min(Math.max(parseFloat(v2), 0), MAX_PCT);
|
| 1657 |
-
if (v3 === "none") l = 0;
|
| 1658 |
-
else l = Math.min(Math.max(parseFloat(v3), 0), MAX_PCT);
|
| 1659 |
-
const alpha = parseAlpha(v4);
|
| 1660 |
-
if (format === "hsl") return [
|
| 1661 |
-
format,
|
| 1662 |
-
v1 === "none" ? v1 : h,
|
| 1663 |
-
v2 === "none" ? v2 : s,
|
| 1664 |
-
v3 === "none" ? v3 : l,
|
| 1665 |
-
v4 === "none" ? v4 : alpha
|
| 1666 |
-
];
|
| 1667 |
-
h = h / DEG * DOZ;
|
| 1668 |
-
l /= MAX_PCT;
|
| 1669 |
-
const sa = s / MAX_PCT * Math.min(l, 1 - l);
|
| 1670 |
-
const rk = h % DOZ;
|
| 1671 |
-
const gk = (8 + h) % DOZ;
|
| 1672 |
-
const bk = (4 + h) % DOZ;
|
| 1673 |
-
const r = l - sa * Math.max(-1, Math.min(rk - TRIA, TRIA ** POW_SQR - rk, 1));
|
| 1674 |
-
const g = l - sa * Math.max(-1, Math.min(gk - TRIA, TRIA ** POW_SQR - gk, 1));
|
| 1675 |
-
const b = l - sa * Math.max(-1, Math.min(bk - TRIA, TRIA ** POW_SQR - bk, 1));
|
| 1676 |
-
return [
|
| 1677 |
-
"rgb",
|
| 1678 |
-
Math.min(Math.max(roundToPrecision(r * MAX_RGB, OCT), 0), MAX_RGB),
|
| 1679 |
-
Math.min(Math.max(roundToPrecision(g * MAX_RGB, OCT), 0), MAX_RGB),
|
| 1680 |
-
Math.min(Math.max(roundToPrecision(b * MAX_RGB, OCT), 0), MAX_RGB),
|
| 1681 |
-
alpha
|
| 1682 |
-
];
|
| 1683 |
-
};
|
| 1684 |
-
/**
|
| 1685 |
-
* parse hwb()
|
| 1686 |
-
* @param value - hwb color value
|
| 1687 |
-
* @param [opt] - options
|
| 1688 |
-
* @returns parsed color - ['rgb', r, g, b, alpha], '(empty)', NullObject
|
| 1689 |
-
*/
|
| 1690 |
-
var parseHwb = (value, opt = {}) => {
|
| 1691 |
-
if (isString(value)) value = value.trim();
|
| 1692 |
-
else throw new TypeError(`${value} is not a string.`);
|
| 1693 |
-
const { format = "", nullable = false } = opt;
|
| 1694 |
-
if (!REG_HWB.test(value)) {
|
| 1695 |
-
const res = resolveInvalidColorValue(format, nullable);
|
| 1696 |
-
if (res instanceof NullObject) return res;
|
| 1697 |
-
if (isString(res)) return res;
|
| 1698 |
-
return res;
|
| 1699 |
-
}
|
| 1700 |
-
const [, val] = value.match(REG_HWB);
|
| 1701 |
-
const [v1, v2, v3, v4 = ""] = val.match(/[^\s,/]+/g);
|
| 1702 |
-
let h, wh, bk;
|
| 1703 |
-
if (v1 === "none") h = 0;
|
| 1704 |
-
else h = angleToDeg(v1);
|
| 1705 |
-
if (v2 === "none") wh = 0;
|
| 1706 |
-
else wh = Math.min(Math.max(parseFloat(v2), 0), MAX_PCT) / MAX_PCT;
|
| 1707 |
-
if (v3 === "none") bk = 0;
|
| 1708 |
-
else bk = Math.min(Math.max(parseFloat(v3), 0), MAX_PCT) / MAX_PCT;
|
| 1709 |
-
const alpha = parseAlpha(v4);
|
| 1710 |
-
if (format === "hwb") return [
|
| 1711 |
-
format,
|
| 1712 |
-
v1 === "none" ? v1 : h,
|
| 1713 |
-
v2 === "none" ? v2 : wh * MAX_PCT,
|
| 1714 |
-
v3 === "none" ? v3 : bk * MAX_PCT,
|
| 1715 |
-
v4 === "none" ? v4 : alpha
|
| 1716 |
-
];
|
| 1717 |
-
if (wh + bk >= 1) {
|
| 1718 |
-
const v = roundToPrecision(wh / (wh + bk) * MAX_RGB, OCT);
|
| 1719 |
-
return [
|
| 1720 |
-
"rgb",
|
| 1721 |
-
v,
|
| 1722 |
-
v,
|
| 1723 |
-
v,
|
| 1724 |
-
alpha
|
| 1725 |
-
];
|
| 1726 |
-
}
|
| 1727 |
-
const factor = (1 - wh - bk) / MAX_RGB;
|
| 1728 |
-
let [, r, g, b] = parseHsl(`hsl(${h} 100 50)`);
|
| 1729 |
-
r = roundToPrecision((r * factor + wh) * MAX_RGB, OCT);
|
| 1730 |
-
g = roundToPrecision((g * factor + wh) * MAX_RGB, OCT);
|
| 1731 |
-
b = roundToPrecision((b * factor + wh) * MAX_RGB, OCT);
|
| 1732 |
-
return [
|
| 1733 |
-
"rgb",
|
| 1734 |
-
Math.min(Math.max(r, 0), MAX_RGB),
|
| 1735 |
-
Math.min(Math.max(g, 0), MAX_RGB),
|
| 1736 |
-
Math.min(Math.max(b, 0), MAX_RGB),
|
| 1737 |
-
alpha
|
| 1738 |
-
];
|
| 1739 |
-
};
|
| 1740 |
-
/**
|
| 1741 |
-
* parse lab()
|
| 1742 |
-
* @param value - lab color value
|
| 1743 |
-
* @param [opt] - options
|
| 1744 |
-
* @returns parsed color
|
| 1745 |
-
* - [xyz-d50, x, y, z, alpha], ['lab', l, a, b, alpha], '(empty)', NullObject
|
| 1746 |
-
*/
|
| 1747 |
-
var parseLab = (value, opt = {}) => {
|
| 1748 |
-
if (isString(value)) value = value.trim();
|
| 1749 |
-
else throw new TypeError(`${value} is not a string.`);
|
| 1750 |
-
const { format = "", nullable = false } = opt;
|
| 1751 |
-
if (!REG_LAB.test(value)) {
|
| 1752 |
-
const res = resolveInvalidColorValue(format, nullable);
|
| 1753 |
-
if (res instanceof NullObject) return res;
|
| 1754 |
-
if (isString(res)) return res;
|
| 1755 |
-
return res;
|
| 1756 |
-
}
|
| 1757 |
-
const COEF_PCT = 1.25;
|
| 1758 |
-
const COND_POW = 8;
|
| 1759 |
-
const [, val] = value.match(REG_LAB);
|
| 1760 |
-
const [v1, v2, v3, v4 = ""] = val.match(/[^\s,/]+/g);
|
| 1761 |
-
let l, a, b;
|
| 1762 |
-
if (v1 === "none") l = 0;
|
| 1763 |
-
else {
|
| 1764 |
-
if (v1.endsWith("%")) {
|
| 1765 |
-
l = parseFloat(v1);
|
| 1766 |
-
if (l > MAX_PCT) l = MAX_PCT;
|
| 1767 |
-
} else l = parseFloat(v1);
|
| 1768 |
-
if (l < 0) l = 0;
|
| 1769 |
-
}
|
| 1770 |
-
if (v2 === "none") a = 0;
|
| 1771 |
-
else a = v2.endsWith("%") ? parseFloat(v2) * COEF_PCT : parseFloat(v2);
|
| 1772 |
-
if (v3 === "none") b = 0;
|
| 1773 |
-
else b = v3.endsWith("%") ? parseFloat(v3) * COEF_PCT : parseFloat(v3);
|
| 1774 |
-
const alpha = parseAlpha(v4);
|
| 1775 |
-
if (REG_SPEC.test(format)) return [
|
| 1776 |
-
"lab",
|
| 1777 |
-
v1 === "none" ? v1 : roundToPrecision(l, HEX),
|
| 1778 |
-
v2 === "none" ? v2 : roundToPrecision(a, HEX),
|
| 1779 |
-
v3 === "none" ? v3 : roundToPrecision(b, HEX),
|
| 1780 |
-
v4 === "none" ? v4 : alpha
|
| 1781 |
-
];
|
| 1782 |
-
const fl = (l + HEX) / LAB_L;
|
| 1783 |
-
const fa = a / LAB_A + fl;
|
| 1784 |
-
const fb = fl - b / LAB_B;
|
| 1785 |
-
const powFl = Math.pow(fl, POW_CUBE);
|
| 1786 |
-
const powFa = Math.pow(fa, POW_CUBE);
|
| 1787 |
-
const powFb = Math.pow(fb, POW_CUBE);
|
| 1788 |
-
const [x, y, z] = [
|
| 1789 |
-
powFa > LAB_EPSILON ? powFa : (fa * LAB_L - HEX) / LAB_KAPPA,
|
| 1790 |
-
l > COND_POW ? powFl : l / LAB_KAPPA,
|
| 1791 |
-
powFb > LAB_EPSILON ? powFb : (fb * LAB_L - HEX) / LAB_KAPPA
|
| 1792 |
-
].map((val, i) => val * D50[i]);
|
| 1793 |
-
return [
|
| 1794 |
-
"xyz-d50",
|
| 1795 |
-
roundToPrecision(x, HEX),
|
| 1796 |
-
roundToPrecision(y, HEX),
|
| 1797 |
-
roundToPrecision(z, HEX),
|
| 1798 |
-
alpha
|
| 1799 |
-
];
|
| 1800 |
-
};
|
| 1801 |
-
/**
|
| 1802 |
-
* parse lch()
|
| 1803 |
-
* @param value - lch color value
|
| 1804 |
-
* @param [opt] - options
|
| 1805 |
-
* @returns parsed color
|
| 1806 |
-
* - ['xyz-d50', x, y, z, alpha], ['lch', l, c, h, alpha]
|
| 1807 |
-
* - '(empty)', NullObject
|
| 1808 |
-
*/
|
| 1809 |
-
var parseLch = (value, opt = {}) => {
|
| 1810 |
-
if (isString(value)) value = value.trim();
|
| 1811 |
-
else throw new TypeError(`${value} is not a string.`);
|
| 1812 |
-
const { format = "", nullable = false } = opt;
|
| 1813 |
-
if (!REG_LCH.test(value)) {
|
| 1814 |
-
const res = resolveInvalidColorValue(format, nullable);
|
| 1815 |
-
if (res instanceof NullObject) return res;
|
| 1816 |
-
if (isString(res)) return res;
|
| 1817 |
-
return res;
|
| 1818 |
-
}
|
| 1819 |
-
const COEF_PCT = 1.5;
|
| 1820 |
-
const [, val] = value.match(REG_LCH);
|
| 1821 |
-
const [v1, v2, v3, v4 = ""] = val.match(/[^\s,/]+/g);
|
| 1822 |
-
let l, c, h;
|
| 1823 |
-
if (v1 === "none") l = 0;
|
| 1824 |
-
else {
|
| 1825 |
-
l = parseFloat(v1);
|
| 1826 |
-
if (l < 0) l = 0;
|
| 1827 |
-
}
|
| 1828 |
-
if (v2 === "none") c = 0;
|
| 1829 |
-
else c = v2.endsWith("%") ? parseFloat(v2) * COEF_PCT : parseFloat(v2);
|
| 1830 |
-
if (v3 === "none") h = 0;
|
| 1831 |
-
else h = angleToDeg(v3);
|
| 1832 |
-
const alpha = parseAlpha(v4);
|
| 1833 |
-
if (REG_SPEC.test(format)) return [
|
| 1834 |
-
"lch",
|
| 1835 |
-
v1 === "none" ? v1 : roundToPrecision(l, HEX),
|
| 1836 |
-
v2 === "none" ? v2 : roundToPrecision(c, HEX),
|
| 1837 |
-
v3 === "none" ? v3 : roundToPrecision(h, HEX),
|
| 1838 |
-
v4 === "none" ? v4 : alpha
|
| 1839 |
-
];
|
| 1840 |
-
const a = c * Math.cos(h * Math.PI / DEG_HALF);
|
| 1841 |
-
const b = c * Math.sin(h * Math.PI / DEG_HALF);
|
| 1842 |
-
const [, x, y, z] = parseLab(`lab(${l} ${a} ${b})`);
|
| 1843 |
-
return [
|
| 1844 |
-
"xyz-d50",
|
| 1845 |
-
roundToPrecision(x, HEX),
|
| 1846 |
-
roundToPrecision(y, HEX),
|
| 1847 |
-
roundToPrecision(z, HEX),
|
| 1848 |
-
alpha
|
| 1849 |
-
];
|
| 1850 |
-
};
|
| 1851 |
-
/**
|
| 1852 |
-
* parse oklab()
|
| 1853 |
-
* @param value - oklab color value
|
| 1854 |
-
* @param [opt] - options
|
| 1855 |
-
* @returns parsed color
|
| 1856 |
-
* - ['xyz-d65', x, y, z, alpha], ['oklab', l, a, b, alpha]
|
| 1857 |
-
* - '(empty)', NullObject
|
| 1858 |
-
*/
|
| 1859 |
-
var parseOklab = (value, opt = {}) => {
|
| 1860 |
-
if (isString(value)) value = value.trim();
|
| 1861 |
-
else throw new TypeError(`${value} is not a string.`);
|
| 1862 |
-
const { format = "", nullable = false } = opt;
|
| 1863 |
-
if (!REG_OKLAB.test(value)) {
|
| 1864 |
-
const res = resolveInvalidColorValue(format, nullable);
|
| 1865 |
-
if (res instanceof NullObject) return res;
|
| 1866 |
-
if (isString(res)) return res;
|
| 1867 |
-
return res;
|
| 1868 |
-
}
|
| 1869 |
-
const COEF_PCT = .4;
|
| 1870 |
-
const [, val] = value.match(REG_OKLAB);
|
| 1871 |
-
const [v1, v2, v3, v4 = ""] = val.match(/[^\s,/]+/g);
|
| 1872 |
-
let l, a, b;
|
| 1873 |
-
if (v1 === "none") l = 0;
|
| 1874 |
-
else {
|
| 1875 |
-
l = v1.endsWith("%") ? parseFloat(v1) / MAX_PCT : parseFloat(v1);
|
| 1876 |
-
if (l < 0) l = 0;
|
| 1877 |
-
}
|
| 1878 |
-
if (v2 === "none") a = 0;
|
| 1879 |
-
else if (v2.endsWith("%")) a = parseFloat(v2) * COEF_PCT / MAX_PCT;
|
| 1880 |
-
else a = parseFloat(v2);
|
| 1881 |
-
if (v3 === "none") b = 0;
|
| 1882 |
-
else if (v3.endsWith("%")) b = parseFloat(v3) * COEF_PCT / MAX_PCT;
|
| 1883 |
-
else b = parseFloat(v3);
|
| 1884 |
-
const alpha = parseAlpha(v4);
|
| 1885 |
-
if (REG_SPEC.test(format)) return [
|
| 1886 |
-
"oklab",
|
| 1887 |
-
v1 === "none" ? v1 : roundToPrecision(l, HEX),
|
| 1888 |
-
v2 === "none" ? v2 : roundToPrecision(a, HEX),
|
| 1889 |
-
v3 === "none" ? v3 : roundToPrecision(b, HEX),
|
| 1890 |
-
v4 === "none" ? v4 : alpha
|
| 1891 |
-
];
|
| 1892 |
-
const [x, y, z] = transformMatrix(MATRIX_LMS_TO_XYZ, transformMatrix(MATRIX_OKLAB_TO_LMS, [
|
| 1893 |
-
l,
|
| 1894 |
-
a,
|
| 1895 |
-
b
|
| 1896 |
-
]).map((c) => Math.pow(c, POW_CUBE)), true);
|
| 1897 |
-
return [
|
| 1898 |
-
"xyz-d65",
|
| 1899 |
-
roundToPrecision(x, HEX),
|
| 1900 |
-
roundToPrecision(y, HEX),
|
| 1901 |
-
roundToPrecision(z, HEX),
|
| 1902 |
-
alpha
|
| 1903 |
-
];
|
| 1904 |
-
};
|
| 1905 |
-
/**
|
| 1906 |
-
* parse oklch()
|
| 1907 |
-
* @param value - oklch color value
|
| 1908 |
-
* @param [opt] - options
|
| 1909 |
-
* @returns parsed color
|
| 1910 |
-
* - ['xyz-d65', x, y, z, alpha], ['oklch', l, c, h, alpha]
|
| 1911 |
-
* - '(empty)', NullObject
|
| 1912 |
-
*/
|
| 1913 |
-
var parseOklch = (value, opt = {}) => {
|
| 1914 |
-
if (isString(value)) value = value.trim();
|
| 1915 |
-
else throw new TypeError(`${value} is not a string.`);
|
| 1916 |
-
const { format = "", nullable = false } = opt;
|
| 1917 |
-
if (!REG_OKLCH.test(value)) {
|
| 1918 |
-
const res = resolveInvalidColorValue(format, nullable);
|
| 1919 |
-
if (res instanceof NullObject) return res;
|
| 1920 |
-
if (isString(res)) return res;
|
| 1921 |
-
return res;
|
| 1922 |
-
}
|
| 1923 |
-
const COEF_PCT = .4;
|
| 1924 |
-
const [, val] = value.match(REG_OKLCH);
|
| 1925 |
-
const [v1, v2, v3, v4 = ""] = val.match(/[^\s,/]+/g);
|
| 1926 |
-
let l, c, h;
|
| 1927 |
-
if (v1 === "none") l = 0;
|
| 1928 |
-
else {
|
| 1929 |
-
l = v1.endsWith("%") ? parseFloat(v1) / MAX_PCT : parseFloat(v1);
|
| 1930 |
-
if (l < 0) l = 0;
|
| 1931 |
-
}
|
| 1932 |
-
if (v2 === "none") c = 0;
|
| 1933 |
-
else {
|
| 1934 |
-
if (v2.endsWith("%")) c = parseFloat(v2) * COEF_PCT / MAX_PCT;
|
| 1935 |
-
else c = parseFloat(v2);
|
| 1936 |
-
if (c < 0) c = 0;
|
| 1937 |
-
}
|
| 1938 |
-
if (v3 === "none") h = 0;
|
| 1939 |
-
else h = angleToDeg(v3);
|
| 1940 |
-
const alpha = parseAlpha(v4);
|
| 1941 |
-
if (REG_SPEC.test(format)) return [
|
| 1942 |
-
"oklch",
|
| 1943 |
-
v1 === "none" ? v1 : roundToPrecision(l, HEX),
|
| 1944 |
-
v2 === "none" ? v2 : roundToPrecision(c, HEX),
|
| 1945 |
-
v3 === "none" ? v3 : roundToPrecision(h, HEX),
|
| 1946 |
-
v4 === "none" ? v4 : alpha
|
| 1947 |
-
];
|
| 1948 |
-
const a = c * Math.cos(h * Math.PI / DEG_HALF);
|
| 1949 |
-
const b = c * Math.sin(h * Math.PI / DEG_HALF);
|
| 1950 |
-
const [x, y, z] = transformMatrix(MATRIX_LMS_TO_XYZ, transformMatrix(MATRIX_OKLAB_TO_LMS, [
|
| 1951 |
-
l,
|
| 1952 |
-
a,
|
| 1953 |
-
b
|
| 1954 |
-
]).map((cc) => Math.pow(cc, POW_CUBE)), true);
|
| 1955 |
-
return [
|
| 1956 |
-
"xyz-d65",
|
| 1957 |
-
roundToPrecision(x, HEX),
|
| 1958 |
-
roundToPrecision(y, HEX),
|
| 1959 |
-
roundToPrecision(z, HEX),
|
| 1960 |
-
alpha
|
| 1961 |
-
];
|
| 1962 |
-
};
|
| 1963 |
-
/**
|
| 1964 |
-
* parse color()
|
| 1965 |
-
* @param value - color function value
|
| 1966 |
-
* @param [opt] - options
|
| 1967 |
-
* @returns parsed color
|
| 1968 |
-
* - ['xyz-(d50|d65)', x, y, z, alpha], [cs, r, g, b, alpha]
|
| 1969 |
-
* - '(empty)', NullObject
|
| 1970 |
-
*/
|
| 1971 |
-
var parseColorFunc = (value, opt = {}) => {
|
| 1972 |
-
if (isString(value)) value = value.trim();
|
| 1973 |
-
else throw new TypeError(`${value} is not a string.`);
|
| 1974 |
-
const { colorSpace = "", d50 = false, format = "", nullable = false } = opt;
|
| 1975 |
-
if (!REG_FN_COLOR.test(value)) {
|
| 1976 |
-
const res = resolveInvalidColorValue(format, nullable);
|
| 1977 |
-
if (res instanceof NullObject) return res;
|
| 1978 |
-
if (isString(res)) return res;
|
| 1979 |
-
return res;
|
| 1980 |
-
}
|
| 1981 |
-
const [, val] = value.match(REG_FN_COLOR);
|
| 1982 |
-
let [cs, v1, v2, v3, v4 = ""] = val.match(/[^\s,/]+/g);
|
| 1983 |
-
let r, g, b;
|
| 1984 |
-
if (cs === "xyz") cs = "xyz-d65";
|
| 1985 |
-
if (v1 === "none") r = 0;
|
| 1986 |
-
else r = v1.endsWith("%") ? parseFloat(v1) / MAX_PCT : parseFloat(v1);
|
| 1987 |
-
if (v2 === "none") g = 0;
|
| 1988 |
-
else g = v2.endsWith("%") ? parseFloat(v2) / MAX_PCT : parseFloat(v2);
|
| 1989 |
-
if (v3 === "none") b = 0;
|
| 1990 |
-
else b = v3.endsWith("%") ? parseFloat(v3) / MAX_PCT : parseFloat(v3);
|
| 1991 |
-
const alpha = parseAlpha(v4);
|
| 1992 |
-
if (REG_SPEC.test(format) || format === "mixValue" && cs === colorSpace) return [
|
| 1993 |
-
cs,
|
| 1994 |
-
v1 === "none" ? v1 : roundToPrecision(r, DEC),
|
| 1995 |
-
v2 === "none" ? v2 : roundToPrecision(g, DEC),
|
| 1996 |
-
v3 === "none" ? v3 : roundToPrecision(b, DEC),
|
| 1997 |
-
v4 === "none" ? v4 : alpha
|
| 1998 |
-
];
|
| 1999 |
-
let x = 0;
|
| 2000 |
-
let y = 0;
|
| 2001 |
-
let z = 0;
|
| 2002 |
-
if (cs === "srgb-linear") {
|
| 2003 |
-
[x, y, z] = transformMatrix(MATRIX_L_RGB_TO_XYZ, [
|
| 2004 |
-
r,
|
| 2005 |
-
g,
|
| 2006 |
-
b
|
| 2007 |
-
]);
|
| 2008 |
-
if (d50) [x, y, z] = transformMatrix(MATRIX_D65_TO_D50, [
|
| 2009 |
-
x,
|
| 2010 |
-
y,
|
| 2011 |
-
z
|
| 2012 |
-
], true);
|
| 2013 |
-
} else if (cs === "display-p3") {
|
| 2014 |
-
const linearRgb = transformRgbToLinearRgb([
|
| 2015 |
-
r * MAX_RGB,
|
| 2016 |
-
g * MAX_RGB,
|
| 2017 |
-
b * MAX_RGB
|
| 2018 |
-
]);
|
| 2019 |
-
[x, y, z] = transformMatrix(MATRIX_P3_TO_XYZ, linearRgb);
|
| 2020 |
-
if (d50) [x, y, z] = transformMatrix(MATRIX_D65_TO_D50, [
|
| 2021 |
-
x,
|
| 2022 |
-
y,
|
| 2023 |
-
z
|
| 2024 |
-
], true);
|
| 2025 |
-
} else if (cs === "rec2020") {
|
| 2026 |
-
const ALPHA = 1.09929682680944;
|
| 2027 |
-
const BETA = .018053968510807;
|
| 2028 |
-
const REC_COEF = .45;
|
| 2029 |
-
const rgb = [
|
| 2030 |
-
r,
|
| 2031 |
-
g,
|
| 2032 |
-
b
|
| 2033 |
-
].map((c) => {
|
| 2034 |
-
let cl;
|
| 2035 |
-
if (c < BETA * REC_COEF * DEC) cl = c / (REC_COEF * DEC);
|
| 2036 |
-
else cl = Math.pow((c + ALPHA - 1) / ALPHA, 1 / REC_COEF);
|
| 2037 |
-
return cl;
|
| 2038 |
-
});
|
| 2039 |
-
[x, y, z] = transformMatrix(MATRIX_REC2020_TO_XYZ, rgb);
|
| 2040 |
-
if (d50) [x, y, z] = transformMatrix(MATRIX_D65_TO_D50, [
|
| 2041 |
-
x,
|
| 2042 |
-
y,
|
| 2043 |
-
z
|
| 2044 |
-
], true);
|
| 2045 |
-
} else if (cs === "a98-rgb") {
|
| 2046 |
-
const POW_A98 = 563 / 256;
|
| 2047 |
-
const rgb = [
|
| 2048 |
-
r,
|
| 2049 |
-
g,
|
| 2050 |
-
b
|
| 2051 |
-
].map((c) => {
|
| 2052 |
-
return Math.pow(c, POW_A98);
|
| 2053 |
-
});
|
| 2054 |
-
[x, y, z] = transformMatrix(MATRIX_A98_TO_XYZ, rgb);
|
| 2055 |
-
if (d50) [x, y, z] = transformMatrix(MATRIX_D65_TO_D50, [
|
| 2056 |
-
x,
|
| 2057 |
-
y,
|
| 2058 |
-
z
|
| 2059 |
-
], true);
|
| 2060 |
-
} else if (cs === "prophoto-rgb") {
|
| 2061 |
-
const POW_PROPHOTO = 1.8;
|
| 2062 |
-
const rgb = [
|
| 2063 |
-
r,
|
| 2064 |
-
g,
|
| 2065 |
-
b
|
| 2066 |
-
].map((c) => {
|
| 2067 |
-
let cl;
|
| 2068 |
-
if (c > 1 / (HEX * DUO)) cl = Math.pow(c, POW_PROPHOTO);
|
| 2069 |
-
else cl = c / HEX;
|
| 2070 |
-
return cl;
|
| 2071 |
-
});
|
| 2072 |
-
[x, y, z] = transformMatrix(MATRIX_PROPHOTO_TO_XYZ_D50, rgb);
|
| 2073 |
-
if (!d50) [x, y, z] = transformMatrix(MATRIX_D50_TO_D65, [
|
| 2074 |
-
x,
|
| 2075 |
-
y,
|
| 2076 |
-
z
|
| 2077 |
-
], true);
|
| 2078 |
-
} else if (/^xyz(?:-d(?:50|65))?$/.test(cs)) {
|
| 2079 |
-
[x, y, z] = [
|
| 2080 |
-
r,
|
| 2081 |
-
g,
|
| 2082 |
-
b
|
| 2083 |
-
];
|
| 2084 |
-
if (cs === "xyz-d50") {
|
| 2085 |
-
if (!d50) [x, y, z] = transformMatrix(MATRIX_D50_TO_D65, [
|
| 2086 |
-
x,
|
| 2087 |
-
y,
|
| 2088 |
-
z
|
| 2089 |
-
]);
|
| 2090 |
-
} else if (d50) [x, y, z] = transformMatrix(MATRIX_D65_TO_D50, [
|
| 2091 |
-
x,
|
| 2092 |
-
y,
|
| 2093 |
-
z
|
| 2094 |
-
], true);
|
| 2095 |
-
} else {
|
| 2096 |
-
[x, y, z] = transformRgbToXyz([
|
| 2097 |
-
r * MAX_RGB,
|
| 2098 |
-
g * MAX_RGB,
|
| 2099 |
-
b * MAX_RGB
|
| 2100 |
-
]);
|
| 2101 |
-
if (d50) [x, y, z] = transformMatrix(MATRIX_D65_TO_D50, [
|
| 2102 |
-
x,
|
| 2103 |
-
y,
|
| 2104 |
-
z
|
| 2105 |
-
], true);
|
| 2106 |
-
}
|
| 2107 |
-
return [
|
| 2108 |
-
d50 ? "xyz-d50" : "xyz-d65",
|
| 2109 |
-
roundToPrecision(x, HEX),
|
| 2110 |
-
roundToPrecision(y, HEX),
|
| 2111 |
-
roundToPrecision(z, HEX),
|
| 2112 |
-
format === "mixValue" && v4 === "none" ? v4 : alpha
|
| 2113 |
-
];
|
| 2114 |
-
};
|
| 2115 |
-
/**
|
| 2116 |
-
* parse color value
|
| 2117 |
-
* @param value - CSS color value
|
| 2118 |
-
* @param [opt] - options
|
| 2119 |
-
* @returns parsed color
|
| 2120 |
-
* - ['xyz-(d50|d65)', x, y, z, alpha], ['rgb', r, g, b, alpha]
|
| 2121 |
-
* - value, '(empty)', NullObject
|
| 2122 |
-
*/
|
| 2123 |
-
var parseColorValue = (value, opt = {}) => {
|
| 2124 |
-
if (isString(value)) value = value.toLowerCase().trim();
|
| 2125 |
-
else throw new TypeError(`${value} is not a string.`);
|
| 2126 |
-
const { d50 = false, format = "", nullable = false } = opt;
|
| 2127 |
-
if (!REG_COLOR.test(value)) {
|
| 2128 |
-
const res = resolveInvalidColorValue(format, nullable);
|
| 2129 |
-
if (res instanceof NullObject) return res;
|
| 2130 |
-
if (isString(res)) return res;
|
| 2131 |
-
return res;
|
| 2132 |
-
}
|
| 2133 |
-
let x = 0;
|
| 2134 |
-
let y = 0;
|
| 2135 |
-
let z = 0;
|
| 2136 |
-
let alpha = 0;
|
| 2137 |
-
if (REG_CURRENT.test(value)) {
|
| 2138 |
-
if (format === "computedValue") return [
|
| 2139 |
-
"rgb",
|
| 2140 |
-
0,
|
| 2141 |
-
0,
|
| 2142 |
-
0,
|
| 2143 |
-
0
|
| 2144 |
-
];
|
| 2145 |
-
if (format === "specifiedValue") return value;
|
| 2146 |
-
} else if (/^[a-z]+$/.test(value)) if (Object.hasOwn(NAMED_COLORS, value)) {
|
| 2147 |
-
if (format === "specifiedValue") return value;
|
| 2148 |
-
const [r, g, b] = NAMED_COLORS[value];
|
| 2149 |
-
alpha = 1;
|
| 2150 |
-
if (format === "computedValue") return [
|
| 2151 |
-
"rgb",
|
| 2152 |
-
r,
|
| 2153 |
-
g,
|
| 2154 |
-
b,
|
| 2155 |
-
alpha
|
| 2156 |
-
];
|
| 2157 |
-
[x, y, z] = transformRgbToXyz([
|
| 2158 |
-
r,
|
| 2159 |
-
g,
|
| 2160 |
-
b
|
| 2161 |
-
], true);
|
| 2162 |
-
if (d50) [x, y, z] = transformMatrix(MATRIX_D65_TO_D50, [
|
| 2163 |
-
x,
|
| 2164 |
-
y,
|
| 2165 |
-
z
|
| 2166 |
-
], true);
|
| 2167 |
-
} else switch (format) {
|
| 2168 |
-
case VAL_COMP:
|
| 2169 |
-
if (nullable && value !== "transparent") return new NullObject();
|
| 2170 |
-
return [
|
| 2171 |
-
"rgb",
|
| 2172 |
-
0,
|
| 2173 |
-
0,
|
| 2174 |
-
0,
|
| 2175 |
-
0
|
| 2176 |
-
];
|
| 2177 |
-
case VAL_SPEC:
|
| 2178 |
-
if (value === "transparent") return value;
|
| 2179 |
-
return "";
|
| 2180 |
-
case VAL_MIX:
|
| 2181 |
-
if (value === "transparent") return [
|
| 2182 |
-
"rgb",
|
| 2183 |
-
0,
|
| 2184 |
-
0,
|
| 2185 |
-
0,
|
| 2186 |
-
0
|
| 2187 |
-
];
|
| 2188 |
-
return new NullObject();
|
| 2189 |
-
default:
|
| 2190 |
-
}
|
| 2191 |
-
else if (value[0] === "#") {
|
| 2192 |
-
if (REG_SPEC.test(format)) return ["rgb", ...convertHexToRgb(value)];
|
| 2193 |
-
[x, y, z, alpha] = convertHexToXyz(value);
|
| 2194 |
-
if (d50) [x, y, z] = transformMatrix(MATRIX_D65_TO_D50, [
|
| 2195 |
-
x,
|
| 2196 |
-
y,
|
| 2197 |
-
z
|
| 2198 |
-
], true);
|
| 2199 |
-
} else if (value.startsWith("lab")) {
|
| 2200 |
-
if (REG_SPEC.test(format)) return parseLab(value, opt);
|
| 2201 |
-
[, x, y, z, alpha] = parseLab(value);
|
| 2202 |
-
if (!d50) [x, y, z] = transformMatrix(MATRIX_D50_TO_D65, [
|
| 2203 |
-
x,
|
| 2204 |
-
y,
|
| 2205 |
-
z
|
| 2206 |
-
], true);
|
| 2207 |
-
} else if (value.startsWith("lch")) {
|
| 2208 |
-
if (REG_SPEC.test(format)) return parseLch(value, opt);
|
| 2209 |
-
[, x, y, z, alpha] = parseLch(value);
|
| 2210 |
-
if (!d50) [x, y, z] = transformMatrix(MATRIX_D50_TO_D65, [
|
| 2211 |
-
x,
|
| 2212 |
-
y,
|
| 2213 |
-
z
|
| 2214 |
-
], true);
|
| 2215 |
-
} else if (value.startsWith("oklab")) {
|
| 2216 |
-
if (REG_SPEC.test(format)) return parseOklab(value, opt);
|
| 2217 |
-
[, x, y, z, alpha] = parseOklab(value);
|
| 2218 |
-
if (d50) [x, y, z] = transformMatrix(MATRIX_D65_TO_D50, [
|
| 2219 |
-
x,
|
| 2220 |
-
y,
|
| 2221 |
-
z
|
| 2222 |
-
], true);
|
| 2223 |
-
} else if (value.startsWith("oklch")) {
|
| 2224 |
-
if (REG_SPEC.test(format)) return parseOklch(value, opt);
|
| 2225 |
-
[, x, y, z, alpha] = parseOklch(value);
|
| 2226 |
-
if (d50) [x, y, z] = transformMatrix(MATRIX_D65_TO_D50, [
|
| 2227 |
-
x,
|
| 2228 |
-
y,
|
| 2229 |
-
z
|
| 2230 |
-
], true);
|
| 2231 |
-
} else {
|
| 2232 |
-
let r, g, b;
|
| 2233 |
-
if (value.startsWith("hsl")) [, r, g, b, alpha] = parseHsl(value);
|
| 2234 |
-
else if (value.startsWith("hwb")) [, r, g, b, alpha] = parseHwb(value);
|
| 2235 |
-
else [, r, g, b, alpha] = parseRgb(value, opt);
|
| 2236 |
-
if (REG_SPEC.test(format)) return [
|
| 2237 |
-
"rgb",
|
| 2238 |
-
Math.round(r),
|
| 2239 |
-
Math.round(g),
|
| 2240 |
-
Math.round(b),
|
| 2241 |
-
alpha
|
| 2242 |
-
];
|
| 2243 |
-
[x, y, z] = transformRgbToXyz([
|
| 2244 |
-
r,
|
| 2245 |
-
g,
|
| 2246 |
-
b
|
| 2247 |
-
]);
|
| 2248 |
-
if (d50) [x, y, z] = transformMatrix(MATRIX_D65_TO_D50, [
|
| 2249 |
-
x,
|
| 2250 |
-
y,
|
| 2251 |
-
z
|
| 2252 |
-
], true);
|
| 2253 |
-
}
|
| 2254 |
-
return [
|
| 2255 |
-
d50 ? "xyz-d50" : "xyz-d65",
|
| 2256 |
-
roundToPrecision(x, HEX),
|
| 2257 |
-
roundToPrecision(y, HEX),
|
| 2258 |
-
roundToPrecision(z, HEX),
|
| 2259 |
-
alpha
|
| 2260 |
-
];
|
| 2261 |
-
};
|
| 2262 |
-
/**
|
| 2263 |
-
* resolve color value
|
| 2264 |
-
* @param value - CSS color value
|
| 2265 |
-
* @param [opt] - options
|
| 2266 |
-
* @returns resolved color
|
| 2267 |
-
* - [cs, v1, v2, v3, alpha], value, '(empty)', NullObject
|
| 2268 |
-
*/
|
| 2269 |
-
var resolveColorValue = (value, opt = {}) => {
|
| 2270 |
-
if (isString(value)) value = value.toLowerCase().trim();
|
| 2271 |
-
else throw new TypeError(`${value} is not a string.`);
|
| 2272 |
-
const { colorSpace = "", format = "", nullable = false } = opt;
|
| 2273 |
-
const cacheKey = createCacheKey({
|
| 2274 |
-
namespace: NAMESPACE,
|
| 2275 |
-
name: "resolveColorValue",
|
| 2276 |
-
value
|
| 2277 |
-
}, opt);
|
| 2278 |
-
const cachedResult = getCache(cacheKey);
|
| 2279 |
-
if (cachedResult instanceof CacheItem) {
|
| 2280 |
-
if (cachedResult.isNull) return cachedResult;
|
| 2281 |
-
const cachedItem = cachedResult.item;
|
| 2282 |
-
if (isString(cachedItem)) return cachedItem;
|
| 2283 |
-
return cachedItem;
|
| 2284 |
-
}
|
| 2285 |
-
if (!REG_COLOR.test(value)) {
|
| 2286 |
-
const res = resolveInvalidColorValue(format, nullable);
|
| 2287 |
-
if (res instanceof NullObject) {
|
| 2288 |
-
setCache(cacheKey, null);
|
| 2289 |
-
return res;
|
| 2290 |
-
}
|
| 2291 |
-
setCache(cacheKey, res);
|
| 2292 |
-
if (isString(res)) return res;
|
| 2293 |
-
return res;
|
| 2294 |
-
}
|
| 2295 |
-
let cs = "";
|
| 2296 |
-
let r = 0;
|
| 2297 |
-
let g = 0;
|
| 2298 |
-
let b = 0;
|
| 2299 |
-
let alpha = 0;
|
| 2300 |
-
if (REG_CURRENT.test(value)) {
|
| 2301 |
-
if (format === "specifiedValue") {
|
| 2302 |
-
setCache(cacheKey, value);
|
| 2303 |
-
return value;
|
| 2304 |
-
}
|
| 2305 |
-
} else if (/^[a-z]+$/.test(value)) if (Object.hasOwn(NAMED_COLORS, value)) {
|
| 2306 |
-
if (format === "specifiedValue") {
|
| 2307 |
-
setCache(cacheKey, value);
|
| 2308 |
-
return value;
|
| 2309 |
-
}
|
| 2310 |
-
[r, g, b] = NAMED_COLORS[value];
|
| 2311 |
-
alpha = 1;
|
| 2312 |
-
} else switch (format) {
|
| 2313 |
-
case VAL_SPEC: {
|
| 2314 |
-
if (value === "transparent") {
|
| 2315 |
-
setCache(cacheKey, value);
|
| 2316 |
-
return value;
|
| 2317 |
-
}
|
| 2318 |
-
const res = "";
|
| 2319 |
-
setCache(cacheKey, res);
|
| 2320 |
-
return res;
|
| 2321 |
-
}
|
| 2322 |
-
case VAL_MIX:
|
| 2323 |
-
if (value === "transparent") {
|
| 2324 |
-
const res = [
|
| 2325 |
-
"rgb",
|
| 2326 |
-
0,
|
| 2327 |
-
0,
|
| 2328 |
-
0,
|
| 2329 |
-
0
|
| 2330 |
-
];
|
| 2331 |
-
setCache(cacheKey, res);
|
| 2332 |
-
return res;
|
| 2333 |
-
}
|
| 2334 |
-
setCache(cacheKey, null);
|
| 2335 |
-
return new NullObject();
|
| 2336 |
-
case VAL_COMP:
|
| 2337 |
-
default: {
|
| 2338 |
-
if (nullable && value !== "transparent") {
|
| 2339 |
-
setCache(cacheKey, null);
|
| 2340 |
-
return new NullObject();
|
| 2341 |
-
}
|
| 2342 |
-
const res = [
|
| 2343 |
-
"rgb",
|
| 2344 |
-
0,
|
| 2345 |
-
0,
|
| 2346 |
-
0,
|
| 2347 |
-
0
|
| 2348 |
-
];
|
| 2349 |
-
setCache(cacheKey, res);
|
| 2350 |
-
return res;
|
| 2351 |
-
}
|
| 2352 |
-
}
|
| 2353 |
-
else if (value[0] === "#") [r, g, b, alpha] = convertHexToRgb(value);
|
| 2354 |
-
else if (value.startsWith("hsl")) [, r, g, b, alpha] = parseHsl(value, opt);
|
| 2355 |
-
else if (value.startsWith("hwb")) [, r, g, b, alpha] = parseHwb(value, opt);
|
| 2356 |
-
else if (/^l(?:ab|ch)/.test(value)) {
|
| 2357 |
-
let x, y, z;
|
| 2358 |
-
if (value.startsWith("lab")) [cs, x, y, z, alpha] = parseLab(value, opt);
|
| 2359 |
-
else [cs, x, y, z, alpha] = parseLch(value, opt);
|
| 2360 |
-
if (REG_SPEC.test(format)) {
|
| 2361 |
-
const res = [
|
| 2362 |
-
cs,
|
| 2363 |
-
x,
|
| 2364 |
-
y,
|
| 2365 |
-
z,
|
| 2366 |
-
alpha
|
| 2367 |
-
];
|
| 2368 |
-
setCache(cacheKey, res);
|
| 2369 |
-
return res;
|
| 2370 |
-
}
|
| 2371 |
-
[r, g, b] = transformXyzD50ToRgb([
|
| 2372 |
-
x,
|
| 2373 |
-
y,
|
| 2374 |
-
z
|
| 2375 |
-
]);
|
| 2376 |
-
} else if (/^okl(?:ab|ch)/.test(value)) {
|
| 2377 |
-
let x, y, z;
|
| 2378 |
-
if (value.startsWith("oklab")) [cs, x, y, z, alpha] = parseOklab(value, opt);
|
| 2379 |
-
else [cs, x, y, z, alpha] = parseOklch(value, opt);
|
| 2380 |
-
if (REG_SPEC.test(format)) {
|
| 2381 |
-
const res = [
|
| 2382 |
-
cs,
|
| 2383 |
-
x,
|
| 2384 |
-
y,
|
| 2385 |
-
z,
|
| 2386 |
-
alpha
|
| 2387 |
-
];
|
| 2388 |
-
setCache(cacheKey, res);
|
| 2389 |
-
return res;
|
| 2390 |
-
}
|
| 2391 |
-
[r, g, b] = transformXyzToRgb([
|
| 2392 |
-
x,
|
| 2393 |
-
y,
|
| 2394 |
-
z
|
| 2395 |
-
]);
|
| 2396 |
-
} else [, r, g, b, alpha] = parseRgb(value, opt);
|
| 2397 |
-
if (format === "mixValue" && colorSpace === "srgb") {
|
| 2398 |
-
const res = [
|
| 2399 |
-
"srgb",
|
| 2400 |
-
r / MAX_RGB,
|
| 2401 |
-
g / MAX_RGB,
|
| 2402 |
-
b / MAX_RGB,
|
| 2403 |
-
alpha
|
| 2404 |
-
];
|
| 2405 |
-
setCache(cacheKey, res);
|
| 2406 |
-
return res;
|
| 2407 |
-
}
|
| 2408 |
-
const res = [
|
| 2409 |
-
"rgb",
|
| 2410 |
-
Math.round(r),
|
| 2411 |
-
Math.round(g),
|
| 2412 |
-
Math.round(b),
|
| 2413 |
-
alpha
|
| 2414 |
-
];
|
| 2415 |
-
setCache(cacheKey, res);
|
| 2416 |
-
return res;
|
| 2417 |
-
};
|
| 2418 |
-
/**
|
| 2419 |
-
* resolve color()
|
| 2420 |
-
* @param value - color function value
|
| 2421 |
-
* @param [opt] - options
|
| 2422 |
-
* @returns resolved color - [cs, v1, v2, v3, alpha], '(empty)', NullObject
|
| 2423 |
-
*/
|
| 2424 |
-
var resolveColorFunc = (value, opt = {}) => {
|
| 2425 |
-
if (isString(value)) value = value.toLowerCase().trim();
|
| 2426 |
-
else throw new TypeError(`${value} is not a string.`);
|
| 2427 |
-
const { colorSpace = "", format = "", nullable = false } = opt;
|
| 2428 |
-
const cacheKey = createCacheKey({
|
| 2429 |
-
namespace: NAMESPACE,
|
| 2430 |
-
name: "resolveColorFunc",
|
| 2431 |
-
value
|
| 2432 |
-
}, opt);
|
| 2433 |
-
const cachedResult = getCache(cacheKey);
|
| 2434 |
-
if (cachedResult instanceof CacheItem) {
|
| 2435 |
-
if (cachedResult.isNull) return cachedResult;
|
| 2436 |
-
const cachedItem = cachedResult.item;
|
| 2437 |
-
if (isString(cachedItem)) return cachedItem;
|
| 2438 |
-
return cachedItem;
|
| 2439 |
-
}
|
| 2440 |
-
if (!REG_FN_COLOR.test(value)) {
|
| 2441 |
-
const res = resolveInvalidColorValue(format, nullable);
|
| 2442 |
-
if (res instanceof NullObject) {
|
| 2443 |
-
setCache(cacheKey, null);
|
| 2444 |
-
return res;
|
| 2445 |
-
}
|
| 2446 |
-
setCache(cacheKey, res);
|
| 2447 |
-
if (isString(res)) return res;
|
| 2448 |
-
return res;
|
| 2449 |
-
}
|
| 2450 |
-
const [cs, v1, v2, v3, v4] = parseColorFunc(value, opt);
|
| 2451 |
-
if (REG_SPEC.test(format) || format === "mixValue" && cs === colorSpace) {
|
| 2452 |
-
const res = [
|
| 2453 |
-
cs,
|
| 2454 |
-
v1,
|
| 2455 |
-
v2,
|
| 2456 |
-
v3,
|
| 2457 |
-
v4
|
| 2458 |
-
];
|
| 2459 |
-
setCache(cacheKey, res);
|
| 2460 |
-
return res;
|
| 2461 |
-
}
|
| 2462 |
-
const x = parseFloat(`${v1}`);
|
| 2463 |
-
const y = parseFloat(`${v2}`);
|
| 2464 |
-
const z = parseFloat(`${v3}`);
|
| 2465 |
-
const alpha = parseAlpha(`${v4}`);
|
| 2466 |
-
const [r, g, b] = transformXyzToRgb([
|
| 2467 |
-
x,
|
| 2468 |
-
y,
|
| 2469 |
-
z
|
| 2470 |
-
], true);
|
| 2471 |
-
const res = [
|
| 2472 |
-
"rgb",
|
| 2473 |
-
r,
|
| 2474 |
-
g,
|
| 2475 |
-
b,
|
| 2476 |
-
alpha
|
| 2477 |
-
];
|
| 2478 |
-
setCache(cacheKey, res);
|
| 2479 |
-
return res;
|
| 2480 |
-
};
|
| 2481 |
-
/**
|
| 2482 |
-
* convert color value to linear rgb
|
| 2483 |
-
* @param value - CSS color value
|
| 2484 |
-
* @param [opt] - options
|
| 2485 |
-
* @returns ColorChannels | NullObject - [r, g, b, alpha] r|g|b|alpha: 0..1
|
| 2486 |
-
*/
|
| 2487 |
-
var convertColorToLinearRgb = (value, opt = {}) => {
|
| 2488 |
-
if (isString(value)) value = value.trim();
|
| 2489 |
-
else throw new TypeError(`${value} is not a string.`);
|
| 2490 |
-
const { colorSpace = "", format = "" } = opt;
|
| 2491 |
-
let cs = "";
|
| 2492 |
-
let r, g, b, alpha, x, y, z;
|
| 2493 |
-
if (format === "mixValue") {
|
| 2494 |
-
let xyz;
|
| 2495 |
-
if (value.startsWith("color(")) xyz = parseColorFunc(value, opt);
|
| 2496 |
-
else xyz = parseColorValue(value, opt);
|
| 2497 |
-
if (xyz instanceof NullObject) return xyz;
|
| 2498 |
-
[cs, x, y, z, alpha] = xyz;
|
| 2499 |
-
if (cs === colorSpace) return [
|
| 2500 |
-
x,
|
| 2501 |
-
y,
|
| 2502 |
-
z,
|
| 2503 |
-
alpha
|
| 2504 |
-
];
|
| 2505 |
-
[r, g, b] = transformMatrix(MATRIX_XYZ_TO_L_RGB, [
|
| 2506 |
-
x,
|
| 2507 |
-
y,
|
| 2508 |
-
z
|
| 2509 |
-
], true);
|
| 2510 |
-
} else if (value.startsWith("color(")) {
|
| 2511 |
-
const [, val] = value.match(REG_FN_COLOR);
|
| 2512 |
-
const [cs] = val.match(/[^\s,/]+/g);
|
| 2513 |
-
if (cs === "srgb-linear") [, r, g, b, alpha] = resolveColorFunc(value, { format: VAL_COMP });
|
| 2514 |
-
else {
|
| 2515 |
-
[, x, y, z, alpha] = parseColorFunc(value);
|
| 2516 |
-
[r, g, b] = transformMatrix(MATRIX_XYZ_TO_L_RGB, [
|
| 2517 |
-
x,
|
| 2518 |
-
y,
|
| 2519 |
-
z
|
| 2520 |
-
], true);
|
| 2521 |
-
}
|
| 2522 |
-
} else {
|
| 2523 |
-
[, x, y, z, alpha] = parseColorValue(value);
|
| 2524 |
-
[r, g, b] = transformMatrix(MATRIX_XYZ_TO_L_RGB, [
|
| 2525 |
-
x,
|
| 2526 |
-
y,
|
| 2527 |
-
z
|
| 2528 |
-
], true);
|
| 2529 |
-
}
|
| 2530 |
-
return [
|
| 2531 |
-
Math.min(Math.max(r, 0), 1),
|
| 2532 |
-
Math.min(Math.max(g, 0), 1),
|
| 2533 |
-
Math.min(Math.max(b, 0), 1),
|
| 2534 |
-
alpha
|
| 2535 |
-
];
|
| 2536 |
-
};
|
| 2537 |
-
/**
|
| 2538 |
-
* convert color value to rgb
|
| 2539 |
-
* @param value - CSS color value
|
| 2540 |
-
* @param [opt] - options
|
| 2541 |
-
* @returns ColorChannels | NullObject
|
| 2542 |
-
* - [r, g, b, alpha] r|g|b: 0..255 alpha: 0..1
|
| 2543 |
-
*/
|
| 2544 |
-
var convertColorToRgb = (value, opt = {}) => {
|
| 2545 |
-
if (isString(value)) value = value.trim();
|
| 2546 |
-
else throw new TypeError(`${value} is not a string.`);
|
| 2547 |
-
const { format = "" } = opt;
|
| 2548 |
-
let r, g, b, alpha;
|
| 2549 |
-
if (format === "mixValue") {
|
| 2550 |
-
let rgb;
|
| 2551 |
-
if (value.startsWith("color(")) rgb = resolveColorFunc(value, opt);
|
| 2552 |
-
else rgb = resolveColorValue(value, opt);
|
| 2553 |
-
if (rgb instanceof NullObject) return rgb;
|
| 2554 |
-
[, r, g, b, alpha] = rgb;
|
| 2555 |
-
} else if (value.startsWith("color(")) {
|
| 2556 |
-
const [, val] = value.match(REG_FN_COLOR);
|
| 2557 |
-
const [cs] = val.match(/[^\s,/]+/g);
|
| 2558 |
-
if (cs === "srgb") {
|
| 2559 |
-
[, r, g, b, alpha] = resolveColorFunc(value, { format: VAL_COMP });
|
| 2560 |
-
r *= MAX_RGB;
|
| 2561 |
-
g *= MAX_RGB;
|
| 2562 |
-
b *= MAX_RGB;
|
| 2563 |
-
} else [, r, g, b, alpha] = resolveColorFunc(value);
|
| 2564 |
-
} else if (/^(?:ok)?l(?:ab|ch)/.test(value)) {
|
| 2565 |
-
[r, g, b, alpha] = convertColorToLinearRgb(value);
|
| 2566 |
-
[r, g, b] = transformLinearRgbToRgb([
|
| 2567 |
-
r,
|
| 2568 |
-
g,
|
| 2569 |
-
b
|
| 2570 |
-
]);
|
| 2571 |
-
} else [, r, g, b, alpha] = resolveColorValue(value, { format: VAL_COMP });
|
| 2572 |
-
return [
|
| 2573 |
-
r,
|
| 2574 |
-
g,
|
| 2575 |
-
b,
|
| 2576 |
-
alpha
|
| 2577 |
-
];
|
| 2578 |
-
};
|
| 2579 |
-
/**
|
| 2580 |
-
* convert color value to xyz
|
| 2581 |
-
* @param value - CSS color value
|
| 2582 |
-
* @param [opt] - options
|
| 2583 |
-
* @returns ColorChannels | NullObject - [x, y, z, alpha]
|
| 2584 |
-
*/
|
| 2585 |
-
var convertColorToXyz = (value, opt = {}) => {
|
| 2586 |
-
if (isString(value)) value = value.trim();
|
| 2587 |
-
else throw new TypeError(`${value} is not a string.`);
|
| 2588 |
-
const { d50 = false, format = "" } = opt;
|
| 2589 |
-
let x, y, z, alpha;
|
| 2590 |
-
if (format === "mixValue") {
|
| 2591 |
-
let xyz;
|
| 2592 |
-
if (value.startsWith("color(")) xyz = parseColorFunc(value, opt);
|
| 2593 |
-
else xyz = parseColorValue(value, opt);
|
| 2594 |
-
if (xyz instanceof NullObject) return xyz;
|
| 2595 |
-
[, x, y, z, alpha] = xyz;
|
| 2596 |
-
} else if (value.startsWith("color(")) {
|
| 2597 |
-
const [, val] = value.match(REG_FN_COLOR);
|
| 2598 |
-
const [cs] = val.match(/[^\s,/]+/g);
|
| 2599 |
-
if (d50) if (cs === "xyz-d50") [, x, y, z, alpha] = resolveColorFunc(value, { format: VAL_COMP });
|
| 2600 |
-
else [, x, y, z, alpha] = parseColorFunc(value, opt);
|
| 2601 |
-
else if (/^xyz(?:-d65)?$/.test(cs)) [, x, y, z, alpha] = resolveColorFunc(value, { format: VAL_COMP });
|
| 2602 |
-
else [, x, y, z, alpha] = parseColorFunc(value);
|
| 2603 |
-
} else [, x, y, z, alpha] = parseColorValue(value, opt);
|
| 2604 |
-
return [
|
| 2605 |
-
x,
|
| 2606 |
-
y,
|
| 2607 |
-
z,
|
| 2608 |
-
alpha
|
| 2609 |
-
];
|
| 2610 |
-
};
|
| 2611 |
-
/**
|
| 2612 |
-
* convert color value to hsl
|
| 2613 |
-
* @param value - CSS color value
|
| 2614 |
-
* @param [opt] - options
|
| 2615 |
-
* @returns ColorChannels | NullObject - [h, s, l, alpha], hue may be powerless
|
| 2616 |
-
*/
|
| 2617 |
-
var convertColorToHsl = (value, opt = {}) => {
|
| 2618 |
-
if (isString(value)) value = value.trim();
|
| 2619 |
-
else throw new TypeError(`${value} is not a string.`);
|
| 2620 |
-
const { format = "" } = opt;
|
| 2621 |
-
let h, s, l, alpha;
|
| 2622 |
-
if (REG_HSL.test(value)) {
|
| 2623 |
-
[, h, s, l, alpha] = parseHsl(value, { format: "hsl" });
|
| 2624 |
-
if (format === "hsl") return [
|
| 2625 |
-
Math.round(h),
|
| 2626 |
-
Math.round(s),
|
| 2627 |
-
Math.round(l),
|
| 2628 |
-
alpha
|
| 2629 |
-
];
|
| 2630 |
-
return [
|
| 2631 |
-
h,
|
| 2632 |
-
s,
|
| 2633 |
-
l,
|
| 2634 |
-
alpha
|
| 2635 |
-
];
|
| 2636 |
-
}
|
| 2637 |
-
let x, y, z;
|
| 2638 |
-
if (format === "mixValue") {
|
| 2639 |
-
let xyz;
|
| 2640 |
-
if (value.startsWith("color(")) xyz = parseColorFunc(value, opt);
|
| 2641 |
-
else xyz = parseColorValue(value, opt);
|
| 2642 |
-
if (xyz instanceof NullObject) return xyz;
|
| 2643 |
-
[, x, y, z, alpha] = xyz;
|
| 2644 |
-
} else if (value.startsWith("color(")) [, x, y, z, alpha] = parseColorFunc(value);
|
| 2645 |
-
else [, x, y, z, alpha] = parseColorValue(value);
|
| 2646 |
-
[h, s, l] = transformXyzToHsl([
|
| 2647 |
-
x,
|
| 2648 |
-
y,
|
| 2649 |
-
z
|
| 2650 |
-
], true);
|
| 2651 |
-
if (format === "hsl") return [
|
| 2652 |
-
Math.round(h),
|
| 2653 |
-
Math.round(s),
|
| 2654 |
-
Math.round(l),
|
| 2655 |
-
alpha
|
| 2656 |
-
];
|
| 2657 |
-
return [
|
| 2658 |
-
format === "mixValue" && s === 0 ? NONE : h,
|
| 2659 |
-
s,
|
| 2660 |
-
l,
|
| 2661 |
-
alpha
|
| 2662 |
-
];
|
| 2663 |
-
};
|
| 2664 |
-
/**
|
| 2665 |
-
* convert color value to hwb
|
| 2666 |
-
* @param value - CSS color value
|
| 2667 |
-
* @param [opt] - options
|
| 2668 |
-
* @returns ColorChannels | NullObject - [h, w, b, alpha], hue may be powerless
|
| 2669 |
-
*/
|
| 2670 |
-
var convertColorToHwb = (value, opt = {}) => {
|
| 2671 |
-
if (isString(value)) value = value.trim();
|
| 2672 |
-
else throw new TypeError(`${value} is not a string.`);
|
| 2673 |
-
const { format = "" } = opt;
|
| 2674 |
-
let h, w, b, alpha;
|
| 2675 |
-
if (REG_HWB.test(value)) {
|
| 2676 |
-
[, h, w, b, alpha] = parseHwb(value, { format: "hwb" });
|
| 2677 |
-
if (format === "hwb") return [
|
| 2678 |
-
Math.round(h),
|
| 2679 |
-
Math.round(w),
|
| 2680 |
-
Math.round(b),
|
| 2681 |
-
alpha
|
| 2682 |
-
];
|
| 2683 |
-
return [
|
| 2684 |
-
h,
|
| 2685 |
-
w,
|
| 2686 |
-
b,
|
| 2687 |
-
alpha
|
| 2688 |
-
];
|
| 2689 |
-
}
|
| 2690 |
-
let x, y, z;
|
| 2691 |
-
if (format === "mixValue") {
|
| 2692 |
-
let xyz;
|
| 2693 |
-
if (value.startsWith("color(")) xyz = parseColorFunc(value, opt);
|
| 2694 |
-
else xyz = parseColorValue(value, opt);
|
| 2695 |
-
if (xyz instanceof NullObject) return xyz;
|
| 2696 |
-
[, x, y, z, alpha] = xyz;
|
| 2697 |
-
} else if (value.startsWith("color(")) [, x, y, z, alpha] = parseColorFunc(value);
|
| 2698 |
-
else [, x, y, z, alpha] = parseColorValue(value);
|
| 2699 |
-
[h, w, b] = transformXyzToHwb([
|
| 2700 |
-
x,
|
| 2701 |
-
y,
|
| 2702 |
-
z
|
| 2703 |
-
], true);
|
| 2704 |
-
if (format === "hwb") return [
|
| 2705 |
-
Math.round(h),
|
| 2706 |
-
Math.round(w),
|
| 2707 |
-
Math.round(b),
|
| 2708 |
-
alpha
|
| 2709 |
-
];
|
| 2710 |
-
return [
|
| 2711 |
-
format === "mixValue" && w + b >= 100 ? NONE : h,
|
| 2712 |
-
w,
|
| 2713 |
-
b,
|
| 2714 |
-
alpha
|
| 2715 |
-
];
|
| 2716 |
-
};
|
| 2717 |
-
/**
|
| 2718 |
-
* convert color value to lab
|
| 2719 |
-
* @param value - CSS color value
|
| 2720 |
-
* @param [opt] - options
|
| 2721 |
-
* @returns ColorChannels | NullObject - [l, a, b, alpha]
|
| 2722 |
-
*/
|
| 2723 |
-
var convertColorToLab = (value, opt = {}) => {
|
| 2724 |
-
if (isString(value)) value = value.trim();
|
| 2725 |
-
else throw new TypeError(`${value} is not a string.`);
|
| 2726 |
-
const { format = "" } = opt;
|
| 2727 |
-
let l, a, b, alpha;
|
| 2728 |
-
if (REG_LAB.test(value)) {
|
| 2729 |
-
[, l, a, b, alpha] = parseLab(value, { format: VAL_COMP });
|
| 2730 |
-
return [
|
| 2731 |
-
l,
|
| 2732 |
-
a,
|
| 2733 |
-
b,
|
| 2734 |
-
alpha
|
| 2735 |
-
];
|
| 2736 |
-
}
|
| 2737 |
-
let x, y, z;
|
| 2738 |
-
if (format === "mixValue") {
|
| 2739 |
-
let xyz;
|
| 2740 |
-
opt.d50 = true;
|
| 2741 |
-
if (value.startsWith("color(")) xyz = parseColorFunc(value, opt);
|
| 2742 |
-
else xyz = parseColorValue(value, opt);
|
| 2743 |
-
if (xyz instanceof NullObject) return xyz;
|
| 2744 |
-
[, x, y, z, alpha] = xyz;
|
| 2745 |
-
} else if (value.startsWith("color(")) [, x, y, z, alpha] = parseColorFunc(value, { d50: true });
|
| 2746 |
-
else [, x, y, z, alpha] = parseColorValue(value, { d50: true });
|
| 2747 |
-
[l, a, b] = transformXyzD50ToLab([
|
| 2748 |
-
x,
|
| 2749 |
-
y,
|
| 2750 |
-
z
|
| 2751 |
-
], true);
|
| 2752 |
-
return [
|
| 2753 |
-
l,
|
| 2754 |
-
a,
|
| 2755 |
-
b,
|
| 2756 |
-
alpha
|
| 2757 |
-
];
|
| 2758 |
-
};
|
| 2759 |
-
/**
|
| 2760 |
-
* convert color value to lch
|
| 2761 |
-
* @param value - CSS color value
|
| 2762 |
-
* @param [opt] - options
|
| 2763 |
-
* @returns ColorChannels | NullObject - [l, c, h, alpha], hue may be powerless
|
| 2764 |
-
*/
|
| 2765 |
-
var convertColorToLch = (value, opt = {}) => {
|
| 2766 |
-
if (isString(value)) value = value.trim();
|
| 2767 |
-
else throw new TypeError(`${value} is not a string.`);
|
| 2768 |
-
const { format = "" } = opt;
|
| 2769 |
-
let l, c, h, alpha;
|
| 2770 |
-
if (REG_LCH.test(value)) {
|
| 2771 |
-
[, l, c, h, alpha] = parseLch(value, { format: VAL_COMP });
|
| 2772 |
-
return [
|
| 2773 |
-
l,
|
| 2774 |
-
c,
|
| 2775 |
-
h,
|
| 2776 |
-
alpha
|
| 2777 |
-
];
|
| 2778 |
-
}
|
| 2779 |
-
let x, y, z;
|
| 2780 |
-
if (format === "mixValue") {
|
| 2781 |
-
let xyz;
|
| 2782 |
-
opt.d50 = true;
|
| 2783 |
-
if (value.startsWith("color(")) xyz = parseColorFunc(value, opt);
|
| 2784 |
-
else xyz = parseColorValue(value, opt);
|
| 2785 |
-
if (xyz instanceof NullObject) return xyz;
|
| 2786 |
-
[, x, y, z, alpha] = xyz;
|
| 2787 |
-
} else if (value.startsWith("color(")) [, x, y, z, alpha] = parseColorFunc(value, { d50: true });
|
| 2788 |
-
else [, x, y, z, alpha] = parseColorValue(value, { d50: true });
|
| 2789 |
-
[l, c, h] = transformXyzD50ToLch([
|
| 2790 |
-
x,
|
| 2791 |
-
y,
|
| 2792 |
-
z
|
| 2793 |
-
], true);
|
| 2794 |
-
return [
|
| 2795 |
-
l,
|
| 2796 |
-
c,
|
| 2797 |
-
format === "mixValue" && c === 0 ? NONE : h,
|
| 2798 |
-
alpha
|
| 2799 |
-
];
|
| 2800 |
-
};
|
| 2801 |
-
/**
|
| 2802 |
-
* convert color value to oklab
|
| 2803 |
-
* @param value - CSS color value
|
| 2804 |
-
* @param [opt] - options
|
| 2805 |
-
* @returns ColorChannels | NullObject - [l, a, b, alpha]
|
| 2806 |
-
*/
|
| 2807 |
-
var convertColorToOklab = (value, opt = {}) => {
|
| 2808 |
-
if (isString(value)) value = value.trim();
|
| 2809 |
-
else throw new TypeError(`${value} is not a string.`);
|
| 2810 |
-
const { format = "" } = opt;
|
| 2811 |
-
let l, a, b, alpha;
|
| 2812 |
-
if (REG_OKLAB.test(value)) {
|
| 2813 |
-
[, l, a, b, alpha] = parseOklab(value, { format: VAL_COMP });
|
| 2814 |
-
return [
|
| 2815 |
-
l,
|
| 2816 |
-
a,
|
| 2817 |
-
b,
|
| 2818 |
-
alpha
|
| 2819 |
-
];
|
| 2820 |
-
}
|
| 2821 |
-
let x, y, z;
|
| 2822 |
-
if (format === "mixValue") {
|
| 2823 |
-
let xyz;
|
| 2824 |
-
if (value.startsWith("color(")) xyz = parseColorFunc(value, opt);
|
| 2825 |
-
else xyz = parseColorValue(value, opt);
|
| 2826 |
-
if (xyz instanceof NullObject) return xyz;
|
| 2827 |
-
[, x, y, z, alpha] = xyz;
|
| 2828 |
-
} else if (value.startsWith("color(")) [, x, y, z, alpha] = parseColorFunc(value);
|
| 2829 |
-
else [, x, y, z, alpha] = parseColorValue(value);
|
| 2830 |
-
[l, a, b] = transformXyzToOklab([
|
| 2831 |
-
x,
|
| 2832 |
-
y,
|
| 2833 |
-
z
|
| 2834 |
-
], true);
|
| 2835 |
-
return [
|
| 2836 |
-
l,
|
| 2837 |
-
a,
|
| 2838 |
-
b,
|
| 2839 |
-
alpha
|
| 2840 |
-
];
|
| 2841 |
-
};
|
| 2842 |
-
/**
|
| 2843 |
-
* convert color value to oklch
|
| 2844 |
-
* @param value - CSS color value
|
| 2845 |
-
* @param [opt] - options
|
| 2846 |
-
* @returns ColorChannels | NullObject - [l, c, h, alpha], hue may be powerless
|
| 2847 |
-
*/
|
| 2848 |
-
var convertColorToOklch = (value, opt = {}) => {
|
| 2849 |
-
if (isString(value)) value = value.trim();
|
| 2850 |
-
else throw new TypeError(`${value} is not a string.`);
|
| 2851 |
-
const { format = "" } = opt;
|
| 2852 |
-
let l, c, h, alpha;
|
| 2853 |
-
if (REG_OKLCH.test(value)) {
|
| 2854 |
-
[, l, c, h, alpha] = parseOklch(value, { format: VAL_COMP });
|
| 2855 |
-
return [
|
| 2856 |
-
l,
|
| 2857 |
-
c,
|
| 2858 |
-
h,
|
| 2859 |
-
alpha
|
| 2860 |
-
];
|
| 2861 |
-
}
|
| 2862 |
-
let x, y, z;
|
| 2863 |
-
if (format === "mixValue") {
|
| 2864 |
-
let xyz;
|
| 2865 |
-
if (value.startsWith("color(")) xyz = parseColorFunc(value, opt);
|
| 2866 |
-
else xyz = parseColorValue(value, opt);
|
| 2867 |
-
if (xyz instanceof NullObject) return xyz;
|
| 2868 |
-
[, x, y, z, alpha] = xyz;
|
| 2869 |
-
} else if (value.startsWith("color(")) [, x, y, z, alpha] = parseColorFunc(value);
|
| 2870 |
-
else [, x, y, z, alpha] = parseColorValue(value);
|
| 2871 |
-
[l, c, h] = transformXyzToOklch([
|
| 2872 |
-
x,
|
| 2873 |
-
y,
|
| 2874 |
-
z
|
| 2875 |
-
], true);
|
| 2876 |
-
return [
|
| 2877 |
-
l,
|
| 2878 |
-
c,
|
| 2879 |
-
format === "mixValue" && c === 0 ? NONE : h,
|
| 2880 |
-
alpha
|
| 2881 |
-
];
|
| 2882 |
-
};
|
| 2883 |
-
/**
|
| 2884 |
-
* resolve color-mix()
|
| 2885 |
-
* @param value - color-mix color value
|
| 2886 |
-
* @param [opt] - options
|
| 2887 |
-
* @returns resolved color - [cs, v1, v2, v3, alpha], '(empty)'
|
| 2888 |
-
*/
|
| 2889 |
-
var resolveColorMix = (value, opt = {}) => {
|
| 2890 |
-
if (isString(value)) value = value.toLowerCase().trim();
|
| 2891 |
-
else throw new TypeError(`${value} is not a string.`);
|
| 2892 |
-
const { format = "", nullable = false } = opt;
|
| 2893 |
-
const cacheKey = createCacheKey({
|
| 2894 |
-
namespace: NAMESPACE,
|
| 2895 |
-
name: "resolveColorMix",
|
| 2896 |
-
value
|
| 2897 |
-
}, opt);
|
| 2898 |
-
const cachedResult = getCache(cacheKey);
|
| 2899 |
-
if (cachedResult instanceof CacheItem) {
|
| 2900 |
-
if (cachedResult.isNull) return cachedResult;
|
| 2901 |
-
const cachedItem = cachedResult.item;
|
| 2902 |
-
if (isString(cachedItem)) return cachedItem;
|
| 2903 |
-
return cachedItem;
|
| 2904 |
-
}
|
| 2905 |
-
const nestedItems = [];
|
| 2906 |
-
let colorSpace = "";
|
| 2907 |
-
let hueArc = "";
|
| 2908 |
-
let colorA = "";
|
| 2909 |
-
let pctA = "";
|
| 2910 |
-
let colorB = "";
|
| 2911 |
-
let pctB = "";
|
| 2912 |
-
let parsed = false;
|
| 2913 |
-
if (!REG_MIX.test(value)) if (value.startsWith("color-mix(") && REG_MIX_NEST.test(value)) {
|
| 2914 |
-
const items = value.match(REG_MIX_NEST);
|
| 2915 |
-
for (const item of items) if (item) {
|
| 2916 |
-
let val = resolveColorMix(item, { format: format === "specifiedValue" ? format : VAL_COMP });
|
| 2917 |
-
if (Array.isArray(val)) {
|
| 2918 |
-
const [cs, v1, v2, v3, v4] = val;
|
| 2919 |
-
if (v1 === 0 && v2 === 0 && v3 === 0 && v4 === 0) {
|
| 2920 |
-
value = "";
|
| 2921 |
-
break;
|
| 2922 |
-
}
|
| 2923 |
-
if (REG_MIX_CS_RGB_XYZ.test(cs)) if (v4 === 1) val = `color(${cs} ${v1} ${v2} ${v3})`;
|
| 2924 |
-
else val = `color(${cs} ${v1} ${v2} ${v3} / ${v4})`;
|
| 2925 |
-
else if (v4 === 1) val = `${cs}(${v1} ${v2} ${v3})`;
|
| 2926 |
-
else val = `${cs}(${v1} ${v2} ${v3} / ${v4})`;
|
| 2927 |
-
} else if (!REG_MIX.test(val)) {
|
| 2928 |
-
value = "";
|
| 2929 |
-
break;
|
| 2930 |
-
}
|
| 2931 |
-
nestedItems.push(val);
|
| 2932 |
-
value = value.replace(item, val);
|
| 2933 |
-
}
|
| 2934 |
-
if (!value) return cacheInvalidColorValue(cacheKey, format, nullable);
|
| 2935 |
-
} else if (value.startsWith("color-mix(") && value.endsWith(")") && value.includes("light-dark(")) {
|
| 2936 |
-
const [csPart = "", partA = "", partB = ""] = splitValue(value.replace(FN_MIX, "").replace(/\)$/, ""), { delimiter: "," });
|
| 2937 |
-
const [colorPartA = "", pctPartA = ""] = splitValue(partA);
|
| 2938 |
-
const [colorPartB = "", pctPartB = ""] = splitValue(partB);
|
| 2939 |
-
const specifiedColorA = resolveColor(colorPartA, { format: VAL_SPEC });
|
| 2940 |
-
const specifiedColorB = resolveColor(colorPartB, { format: VAL_SPEC });
|
| 2941 |
-
if (REG_MIX_IN_CS.test(csPart) && specifiedColorA && specifiedColorB) if (format === "specifiedValue") {
|
| 2942 |
-
const [, cs] = csPart.match(REG_MIX_IN_CS);
|
| 2943 |
-
if (REG_CS_HUE.test(cs)) [, colorSpace, hueArc] = cs.match(REG_CS_HUE);
|
| 2944 |
-
else colorSpace = cs;
|
| 2945 |
-
colorA = specifiedColorA;
|
| 2946 |
-
if (pctPartA) pctA = pctPartA;
|
| 2947 |
-
colorB = specifiedColorB;
|
| 2948 |
-
if (pctPartB) pctB = pctPartB;
|
| 2949 |
-
value = value.replace(colorPartA, specifiedColorA).replace(colorPartB, specifiedColorB);
|
| 2950 |
-
parsed = true;
|
| 2951 |
-
} else {
|
| 2952 |
-
const resolvedColorA = resolveColor(colorPartA, opt);
|
| 2953 |
-
const resolvedColorB = resolveColor(colorPartB, opt);
|
| 2954 |
-
if (isString(resolvedColorA) && isString(resolvedColorB)) value = value.replace(colorPartA, resolvedColorA).replace(colorPartB, resolvedColorB);
|
| 2955 |
-
}
|
| 2956 |
-
else return cacheInvalidColorValue(cacheKey, format, nullable);
|
| 2957 |
-
} else return cacheInvalidColorValue(cacheKey, format, nullable);
|
| 2958 |
-
if (nestedItems.length && format === "specifiedValue") {
|
| 2959 |
-
const [, cs] = value.match(REG_MIX_START);
|
| 2960 |
-
if (REG_CS_HUE.test(cs)) [, colorSpace, hueArc] = cs.match(REG_CS_HUE);
|
| 2961 |
-
else colorSpace = cs;
|
| 2962 |
-
if (nestedItems.length === 2) {
|
| 2963 |
-
let [itemA, itemB] = nestedItems;
|
| 2964 |
-
itemA = itemA.replace(/(?=[()])/g, "\\");
|
| 2965 |
-
itemB = itemB.replace(/(?=[()])/g, "\\");
|
| 2966 |
-
const regA = new RegExp(`(${itemA})(?:\\s+(${PCT}))?`);
|
| 2967 |
-
const regB = new RegExp(`(${itemB})(?:\\s+(${PCT}))?`);
|
| 2968 |
-
[, colorA, pctA] = value.match(regA);
|
| 2969 |
-
[, colorB, pctB] = value.match(regB);
|
| 2970 |
-
} else {
|
| 2971 |
-
let [item] = nestedItems;
|
| 2972 |
-
item = item.replace(/(?=[()])/g, "\\");
|
| 2973 |
-
const itemPart = `${item}(?:\\s+${PCT})?`;
|
| 2974 |
-
const itemPartCapt = `(${item})(?:\\s+(${PCT}))?`;
|
| 2975 |
-
const regItemPart = new RegExp(`^${itemPartCapt}$`);
|
| 2976 |
-
if (new RegExp(`${itemPartCapt}\\s*\\)$`).test(value)) {
|
| 2977 |
-
const reg = new RegExp(`(${SYN_MIX_PART})\\s*,\\s*(${itemPart})\\s*\\)$`);
|
| 2978 |
-
const [, colorPartA, colorPartB] = value.match(reg);
|
| 2979 |
-
[, colorA, pctA] = colorPartA.match(REG_MIX_COLOR_PART);
|
| 2980 |
-
[, colorB, pctB] = colorPartB.match(regItemPart);
|
| 2981 |
-
} else {
|
| 2982 |
-
const reg = new RegExp(`(${itemPart})\\s*,\\s*(${SYN_MIX_PART})\\s*\\)$`);
|
| 2983 |
-
const [, colorPartA, colorPartB] = value.match(reg);
|
| 2984 |
-
[, colorA, pctA] = colorPartA.match(regItemPart);
|
| 2985 |
-
[, colorB, pctB] = colorPartB.match(REG_MIX_COLOR_PART);
|
| 2986 |
-
}
|
| 2987 |
-
}
|
| 2988 |
-
} else if (!parsed) {
|
| 2989 |
-
const [, cs, colorPartA, colorPartB] = value.match(REG_MIX_CAPT);
|
| 2990 |
-
[, colorA, pctA] = colorPartA.match(REG_MIX_COLOR_PART);
|
| 2991 |
-
[, colorB, pctB] = colorPartB.match(REG_MIX_COLOR_PART);
|
| 2992 |
-
if (REG_CS_HUE.test(cs)) [, colorSpace, hueArc] = cs.match(REG_CS_HUE);
|
| 2993 |
-
else colorSpace = cs;
|
| 2994 |
-
}
|
| 2995 |
-
let pA, pB, m;
|
| 2996 |
-
if (pctA && pctB) {
|
| 2997 |
-
const p1 = parseFloat(pctA) / MAX_PCT;
|
| 2998 |
-
const p2 = parseFloat(pctB) / MAX_PCT;
|
| 2999 |
-
if (p1 < 0 || p1 > 1 || p2 < 0 || p2 > 1 || p1 === 0 && p2 === 0) return cacheInvalidColorValue(cacheKey, format, nullable);
|
| 3000 |
-
const factor = p1 + p2;
|
| 3001 |
-
pA = p1 / factor;
|
| 3002 |
-
pB = p2 / factor;
|
| 3003 |
-
m = factor < 1 ? factor : 1;
|
| 3004 |
-
} else {
|
| 3005 |
-
if (pctA) {
|
| 3006 |
-
pA = parseFloat(pctA) / MAX_PCT;
|
| 3007 |
-
if (pA < 0 || pA > 1) return cacheInvalidColorValue(cacheKey, format, nullable);
|
| 3008 |
-
pB = 1 - pA;
|
| 3009 |
-
} else if (pctB) {
|
| 3010 |
-
pB = parseFloat(pctB) / MAX_PCT;
|
| 3011 |
-
if (pB < 0 || pB > 1) return cacheInvalidColorValue(cacheKey, format, nullable);
|
| 3012 |
-
pA = 1 - pB;
|
| 3013 |
-
} else {
|
| 3014 |
-
pA = HALF;
|
| 3015 |
-
pB = HALF;
|
| 3016 |
-
}
|
| 3017 |
-
m = 1;
|
| 3018 |
-
}
|
| 3019 |
-
if (colorSpace === "xyz") colorSpace = "xyz-d65";
|
| 3020 |
-
if (format === "specifiedValue") {
|
| 3021 |
-
let valueA = "";
|
| 3022 |
-
let valueB = "";
|
| 3023 |
-
if (colorA.startsWith("color-mix(") || colorA.startsWith("light-dark(")) valueA = colorA;
|
| 3024 |
-
else if (colorA.startsWith("color(")) {
|
| 3025 |
-
const [cs, v1, v2, v3, v4] = parseColorFunc(colorA, opt);
|
| 3026 |
-
if (v4 === 1) valueA = `color(${cs} ${v1} ${v2} ${v3})`;
|
| 3027 |
-
else valueA = `color(${cs} ${v1} ${v2} ${v3} / ${v4})`;
|
| 3028 |
-
} else {
|
| 3029 |
-
const val = parseColorValue(colorA, opt);
|
| 3030 |
-
if (Array.isArray(val)) {
|
| 3031 |
-
const [cs, v1, v2, v3, v4] = val;
|
| 3032 |
-
if (v4 === 1) if (cs === "rgb") valueA = `${cs}(${v1}, ${v2}, ${v3})`;
|
| 3033 |
-
else valueA = `${cs}(${v1} ${v2} ${v3})`;
|
| 3034 |
-
else if (cs === "rgb") valueA = `${cs}a(${v1}, ${v2}, ${v3}, ${v4})`;
|
| 3035 |
-
else valueA = `${cs}(${v1} ${v2} ${v3} / ${v4})`;
|
| 3036 |
-
} else {
|
| 3037 |
-
if (!isString(val) || !val) {
|
| 3038 |
-
setCache(cacheKey, "");
|
| 3039 |
-
return "";
|
| 3040 |
-
}
|
| 3041 |
-
valueA = val;
|
| 3042 |
-
}
|
| 3043 |
-
}
|
| 3044 |
-
if (colorB.startsWith("color-mix(") || colorB.startsWith("light-dark(")) valueB = colorB;
|
| 3045 |
-
else if (colorB.startsWith("color(")) {
|
| 3046 |
-
const [cs, v1, v2, v3, v4] = parseColorFunc(colorB, opt);
|
| 3047 |
-
if (v4 === 1) valueB = `color(${cs} ${v1} ${v2} ${v3})`;
|
| 3048 |
-
else valueB = `color(${cs} ${v1} ${v2} ${v3} / ${v4})`;
|
| 3049 |
-
} else {
|
| 3050 |
-
const val = parseColorValue(colorB, opt);
|
| 3051 |
-
if (Array.isArray(val)) {
|
| 3052 |
-
const [cs, v1, v2, v3, v4] = val;
|
| 3053 |
-
if (v4 === 1) if (cs === "rgb") valueB = `${cs}(${v1}, ${v2}, ${v3})`;
|
| 3054 |
-
else valueB = `${cs}(${v1} ${v2} ${v3})`;
|
| 3055 |
-
else if (cs === "rgb") valueB = `${cs}a(${v1}, ${v2}, ${v3}, ${v4})`;
|
| 3056 |
-
else valueB = `${cs}(${v1} ${v2} ${v3} / ${v4})`;
|
| 3057 |
-
} else {
|
| 3058 |
-
if (!isString(val) || !val) {
|
| 3059 |
-
setCache(cacheKey, "");
|
| 3060 |
-
return "";
|
| 3061 |
-
}
|
| 3062 |
-
valueB = val;
|
| 3063 |
-
}
|
| 3064 |
-
}
|
| 3065 |
-
if (pctA && pctB) {
|
| 3066 |
-
valueA += ` ${parseFloat(pctA)}%`;
|
| 3067 |
-
valueB += ` ${parseFloat(pctB)}%`;
|
| 3068 |
-
} else if (pctA) {
|
| 3069 |
-
const pA = parseFloat(pctA);
|
| 3070 |
-
if (pA !== MAX_PCT * HALF) valueA += ` ${pA}%`;
|
| 3071 |
-
} else if (pctB) {
|
| 3072 |
-
const pA = MAX_PCT - parseFloat(pctB);
|
| 3073 |
-
if (pA !== MAX_PCT * HALF) valueA += ` ${pA}%`;
|
| 3074 |
-
}
|
| 3075 |
-
if (hueArc) {
|
| 3076 |
-
const res = `color-mix(in ${colorSpace} ${hueArc} hue, ${valueA}, ${valueB})`;
|
| 3077 |
-
setCache(cacheKey, res);
|
| 3078 |
-
return res;
|
| 3079 |
-
} else {
|
| 3080 |
-
const res = `color-mix(in ${colorSpace}, ${valueA}, ${valueB})`;
|
| 3081 |
-
setCache(cacheKey, res);
|
| 3082 |
-
return res;
|
| 3083 |
-
}
|
| 3084 |
-
}
|
| 3085 |
-
let r = 0;
|
| 3086 |
-
let g = 0;
|
| 3087 |
-
let b = 0;
|
| 3088 |
-
let alpha = 0;
|
| 3089 |
-
if (/^srgb(?:-linear)?$/.test(colorSpace)) {
|
| 3090 |
-
let rgbA, rgbB;
|
| 3091 |
-
if (colorSpace === "srgb") {
|
| 3092 |
-
if (REG_CURRENT.test(colorA)) rgbA = [
|
| 3093 |
-
NONE,
|
| 3094 |
-
NONE,
|
| 3095 |
-
NONE,
|
| 3096 |
-
NONE
|
| 3097 |
-
];
|
| 3098 |
-
else rgbA = convertColorToRgb(colorA, {
|
| 3099 |
-
colorSpace,
|
| 3100 |
-
format: VAL_MIX
|
| 3101 |
-
});
|
| 3102 |
-
if (REG_CURRENT.test(colorB)) rgbB = [
|
| 3103 |
-
NONE,
|
| 3104 |
-
NONE,
|
| 3105 |
-
NONE,
|
| 3106 |
-
NONE
|
| 3107 |
-
];
|
| 3108 |
-
else rgbB = convertColorToRgb(colorB, {
|
| 3109 |
-
colorSpace,
|
| 3110 |
-
format: VAL_MIX
|
| 3111 |
-
});
|
| 3112 |
-
} else {
|
| 3113 |
-
if (REG_CURRENT.test(colorA)) rgbA = [
|
| 3114 |
-
NONE,
|
| 3115 |
-
NONE,
|
| 3116 |
-
NONE,
|
| 3117 |
-
NONE
|
| 3118 |
-
];
|
| 3119 |
-
else rgbA = convertColorToLinearRgb(colorA, {
|
| 3120 |
-
colorSpace,
|
| 3121 |
-
format: VAL_MIX
|
| 3122 |
-
});
|
| 3123 |
-
if (REG_CURRENT.test(colorB)) rgbB = [
|
| 3124 |
-
NONE,
|
| 3125 |
-
NONE,
|
| 3126 |
-
NONE,
|
| 3127 |
-
NONE
|
| 3128 |
-
];
|
| 3129 |
-
else rgbB = convertColorToLinearRgb(colorB, {
|
| 3130 |
-
colorSpace,
|
| 3131 |
-
format: VAL_MIX
|
| 3132 |
-
});
|
| 3133 |
-
}
|
| 3134 |
-
if (rgbA instanceof NullObject || rgbB instanceof NullObject) return cacheInvalidColorValue(cacheKey, format, nullable);
|
| 3135 |
-
const [rrA, ggA, bbA, aaA] = rgbA;
|
| 3136 |
-
const [rrB, ggB, bbB, aaB] = rgbB;
|
| 3137 |
-
const rNone = rrA === "none" && rrB === "none";
|
| 3138 |
-
const gNone = ggA === "none" && ggB === "none";
|
| 3139 |
-
const bNone = bbA === "none" && bbB === "none";
|
| 3140 |
-
const alphaNone = aaA === "none" && aaB === "none";
|
| 3141 |
-
const [[rA, gA, bA, alphaA], [rB, gB, bB, alphaB]] = normalizeColorComponents([
|
| 3142 |
-
rrA,
|
| 3143 |
-
ggA,
|
| 3144 |
-
bbA,
|
| 3145 |
-
aaA
|
| 3146 |
-
], [
|
| 3147 |
-
rrB,
|
| 3148 |
-
ggB,
|
| 3149 |
-
bbB,
|
| 3150 |
-
aaB
|
| 3151 |
-
], true);
|
| 3152 |
-
const factorA = alphaA * pA;
|
| 3153 |
-
const factorB = alphaB * pB;
|
| 3154 |
-
alpha = factorA + factorB;
|
| 3155 |
-
if (alpha === 0) {
|
| 3156 |
-
r = rA * pA + rB * pB;
|
| 3157 |
-
g = gA * pA + gB * pB;
|
| 3158 |
-
b = bA * pA + bB * pB;
|
| 3159 |
-
} else {
|
| 3160 |
-
r = (rA * factorA + rB * factorB) / alpha;
|
| 3161 |
-
g = (gA * factorA + gB * factorB) / alpha;
|
| 3162 |
-
b = (bA * factorA + bB * factorB) / alpha;
|
| 3163 |
-
alpha = parseFloat(alpha.toFixed(3));
|
| 3164 |
-
}
|
| 3165 |
-
if (format === "computedValue") {
|
| 3166 |
-
const res = [
|
| 3167 |
-
colorSpace,
|
| 3168 |
-
rNone ? NONE : roundToPrecision(r, HEX),
|
| 3169 |
-
gNone ? NONE : roundToPrecision(g, HEX),
|
| 3170 |
-
bNone ? NONE : roundToPrecision(b, HEX),
|
| 3171 |
-
alphaNone ? NONE : alpha * m
|
| 3172 |
-
];
|
| 3173 |
-
setCache(cacheKey, res);
|
| 3174 |
-
return res;
|
| 3175 |
-
}
|
| 3176 |
-
r *= MAX_RGB;
|
| 3177 |
-
g *= MAX_RGB;
|
| 3178 |
-
b *= MAX_RGB;
|
| 3179 |
-
} else if (REG_CS_XYZ.test(colorSpace)) {
|
| 3180 |
-
let xyzA, xyzB;
|
| 3181 |
-
if (REG_CURRENT.test(colorA)) xyzA = [
|
| 3182 |
-
NONE,
|
| 3183 |
-
NONE,
|
| 3184 |
-
NONE,
|
| 3185 |
-
NONE
|
| 3186 |
-
];
|
| 3187 |
-
else xyzA = convertColorToXyz(colorA, {
|
| 3188 |
-
colorSpace,
|
| 3189 |
-
d50: colorSpace === "xyz-d50",
|
| 3190 |
-
format: VAL_MIX
|
| 3191 |
-
});
|
| 3192 |
-
if (REG_CURRENT.test(colorB)) xyzB = [
|
| 3193 |
-
NONE,
|
| 3194 |
-
NONE,
|
| 3195 |
-
NONE,
|
| 3196 |
-
NONE
|
| 3197 |
-
];
|
| 3198 |
-
else xyzB = convertColorToXyz(colorB, {
|
| 3199 |
-
colorSpace,
|
| 3200 |
-
d50: colorSpace === "xyz-d50",
|
| 3201 |
-
format: VAL_MIX
|
| 3202 |
-
});
|
| 3203 |
-
if (xyzA instanceof NullObject || xyzB instanceof NullObject) return cacheInvalidColorValue(cacheKey, format, nullable);
|
| 3204 |
-
const [xxA, yyA, zzA, aaA] = xyzA;
|
| 3205 |
-
const [xxB, yyB, zzB, aaB] = xyzB;
|
| 3206 |
-
const xNone = xxA === "none" && xxB === "none";
|
| 3207 |
-
const yNone = yyA === "none" && yyB === "none";
|
| 3208 |
-
const zNone = zzA === "none" && zzB === "none";
|
| 3209 |
-
const alphaNone = aaA === "none" && aaB === "none";
|
| 3210 |
-
const [[xA, yA, zA, alphaA], [xB, yB, zB, alphaB]] = normalizeColorComponents([
|
| 3211 |
-
xxA,
|
| 3212 |
-
yyA,
|
| 3213 |
-
zzA,
|
| 3214 |
-
aaA
|
| 3215 |
-
], [
|
| 3216 |
-
xxB,
|
| 3217 |
-
yyB,
|
| 3218 |
-
zzB,
|
| 3219 |
-
aaB
|
| 3220 |
-
], true);
|
| 3221 |
-
const factorA = alphaA * pA;
|
| 3222 |
-
const factorB = alphaB * pB;
|
| 3223 |
-
alpha = factorA + factorB;
|
| 3224 |
-
let x, y, z;
|
| 3225 |
-
if (alpha === 0) {
|
| 3226 |
-
x = xA * pA + xB * pB;
|
| 3227 |
-
y = yA * pA + yB * pB;
|
| 3228 |
-
z = zA * pA + zB * pB;
|
| 3229 |
-
} else {
|
| 3230 |
-
x = (xA * factorA + xB * factorB) / alpha;
|
| 3231 |
-
y = (yA * factorA + yB * factorB) / alpha;
|
| 3232 |
-
z = (zA * factorA + zB * factorB) / alpha;
|
| 3233 |
-
alpha = parseFloat(alpha.toFixed(3));
|
| 3234 |
-
}
|
| 3235 |
-
if (format === "computedValue") {
|
| 3236 |
-
const res = [
|
| 3237 |
-
colorSpace,
|
| 3238 |
-
xNone ? NONE : roundToPrecision(x, HEX),
|
| 3239 |
-
yNone ? NONE : roundToPrecision(y, HEX),
|
| 3240 |
-
zNone ? NONE : roundToPrecision(z, HEX),
|
| 3241 |
-
alphaNone ? NONE : alpha * m
|
| 3242 |
-
];
|
| 3243 |
-
setCache(cacheKey, res);
|
| 3244 |
-
return res;
|
| 3245 |
-
}
|
| 3246 |
-
if (colorSpace === "xyz-d50") [r, g, b] = transformXyzD50ToRgb([
|
| 3247 |
-
x,
|
| 3248 |
-
y,
|
| 3249 |
-
z
|
| 3250 |
-
], true);
|
| 3251 |
-
else [r, g, b] = transformXyzToRgb([
|
| 3252 |
-
x,
|
| 3253 |
-
y,
|
| 3254 |
-
z
|
| 3255 |
-
], true);
|
| 3256 |
-
} else if (/^h(?:sl|wb)$/.test(colorSpace)) {
|
| 3257 |
-
let hslA, hslB;
|
| 3258 |
-
if (colorSpace === "hsl") {
|
| 3259 |
-
if (REG_CURRENT.test(colorA)) hslA = [
|
| 3260 |
-
NONE,
|
| 3261 |
-
NONE,
|
| 3262 |
-
NONE,
|
| 3263 |
-
NONE
|
| 3264 |
-
];
|
| 3265 |
-
else hslA = convertColorToHsl(colorA, {
|
| 3266 |
-
colorSpace,
|
| 3267 |
-
format: VAL_MIX
|
| 3268 |
-
});
|
| 3269 |
-
if (REG_CURRENT.test(colorB)) hslB = [
|
| 3270 |
-
NONE,
|
| 3271 |
-
NONE,
|
| 3272 |
-
NONE,
|
| 3273 |
-
NONE
|
| 3274 |
-
];
|
| 3275 |
-
else hslB = convertColorToHsl(colorB, {
|
| 3276 |
-
colorSpace,
|
| 3277 |
-
format: VAL_MIX
|
| 3278 |
-
});
|
| 3279 |
-
} else {
|
| 3280 |
-
if (REG_CURRENT.test(colorA)) hslA = [
|
| 3281 |
-
NONE,
|
| 3282 |
-
NONE,
|
| 3283 |
-
NONE,
|
| 3284 |
-
NONE
|
| 3285 |
-
];
|
| 3286 |
-
else hslA = convertColorToHwb(colorA, {
|
| 3287 |
-
colorSpace,
|
| 3288 |
-
format: VAL_MIX
|
| 3289 |
-
});
|
| 3290 |
-
if (REG_CURRENT.test(colorB)) hslB = [
|
| 3291 |
-
NONE,
|
| 3292 |
-
NONE,
|
| 3293 |
-
NONE,
|
| 3294 |
-
NONE
|
| 3295 |
-
];
|
| 3296 |
-
else hslB = convertColorToHwb(colorB, {
|
| 3297 |
-
colorSpace,
|
| 3298 |
-
format: VAL_MIX
|
| 3299 |
-
});
|
| 3300 |
-
}
|
| 3301 |
-
if (hslA instanceof NullObject || hslB instanceof NullObject) return cacheInvalidColorValue(cacheKey, format, nullable);
|
| 3302 |
-
const [hhA, ssA, llA, aaA] = hslA;
|
| 3303 |
-
const [hhB, ssB, llB, aaB] = hslB;
|
| 3304 |
-
const alphaNone = aaA === "none" && aaB === "none";
|
| 3305 |
-
let [[hA, sA, lA, alphaA], [hB, sB, lB, alphaB]] = normalizeColorComponents([
|
| 3306 |
-
hhA,
|
| 3307 |
-
ssA,
|
| 3308 |
-
llA,
|
| 3309 |
-
aaA
|
| 3310 |
-
], [
|
| 3311 |
-
hhB,
|
| 3312 |
-
ssB,
|
| 3313 |
-
llB,
|
| 3314 |
-
aaB
|
| 3315 |
-
], true);
|
| 3316 |
-
if (hueArc) [hA, hB] = interpolateHue(hA, hB, hueArc);
|
| 3317 |
-
const factorA = alphaA * pA;
|
| 3318 |
-
const factorB = alphaB * pB;
|
| 3319 |
-
alpha = factorA + factorB;
|
| 3320 |
-
const h = (hA * pA + hB * pB) % DEG;
|
| 3321 |
-
let s, l;
|
| 3322 |
-
if (alpha === 0) {
|
| 3323 |
-
s = sA * pA + sB * pB;
|
| 3324 |
-
l = lA * pA + lB * pB;
|
| 3325 |
-
} else {
|
| 3326 |
-
s = (sA * factorA + sB * factorB) / alpha;
|
| 3327 |
-
l = (lA * factorA + lB * factorB) / alpha;
|
| 3328 |
-
alpha = parseFloat(alpha.toFixed(3));
|
| 3329 |
-
}
|
| 3330 |
-
[r, g, b] = convertColorToRgb(`${colorSpace}(${h} ${s} ${l})`);
|
| 3331 |
-
if (format === "computedValue") {
|
| 3332 |
-
const res = [
|
| 3333 |
-
"srgb",
|
| 3334 |
-
roundToPrecision(r / MAX_RGB, HEX),
|
| 3335 |
-
roundToPrecision(g / MAX_RGB, HEX),
|
| 3336 |
-
roundToPrecision(b / MAX_RGB, HEX),
|
| 3337 |
-
alphaNone ? NONE : alpha * m
|
| 3338 |
-
];
|
| 3339 |
-
setCache(cacheKey, res);
|
| 3340 |
-
return res;
|
| 3341 |
-
}
|
| 3342 |
-
} else if (/^(?:ok)?lch$/.test(colorSpace)) {
|
| 3343 |
-
let lchA, lchB;
|
| 3344 |
-
if (colorSpace === "lch") {
|
| 3345 |
-
if (REG_CURRENT.test(colorA)) lchA = [
|
| 3346 |
-
NONE,
|
| 3347 |
-
NONE,
|
| 3348 |
-
NONE,
|
| 3349 |
-
NONE
|
| 3350 |
-
];
|
| 3351 |
-
else lchA = convertColorToLch(colorA, {
|
| 3352 |
-
colorSpace,
|
| 3353 |
-
format: VAL_MIX
|
| 3354 |
-
});
|
| 3355 |
-
if (REG_CURRENT.test(colorB)) lchB = [
|
| 3356 |
-
NONE,
|
| 3357 |
-
NONE,
|
| 3358 |
-
NONE,
|
| 3359 |
-
NONE
|
| 3360 |
-
];
|
| 3361 |
-
else lchB = convertColorToLch(colorB, {
|
| 3362 |
-
colorSpace,
|
| 3363 |
-
format: VAL_MIX
|
| 3364 |
-
});
|
| 3365 |
-
} else {
|
| 3366 |
-
if (REG_CURRENT.test(colorA)) lchA = [
|
| 3367 |
-
NONE,
|
| 3368 |
-
NONE,
|
| 3369 |
-
NONE,
|
| 3370 |
-
NONE
|
| 3371 |
-
];
|
| 3372 |
-
else lchA = convertColorToOklch(colorA, {
|
| 3373 |
-
colorSpace,
|
| 3374 |
-
format: VAL_MIX
|
| 3375 |
-
});
|
| 3376 |
-
if (REG_CURRENT.test(colorB)) lchB = [
|
| 3377 |
-
NONE,
|
| 3378 |
-
NONE,
|
| 3379 |
-
NONE,
|
| 3380 |
-
NONE
|
| 3381 |
-
];
|
| 3382 |
-
else lchB = convertColorToOklch(colorB, {
|
| 3383 |
-
colorSpace,
|
| 3384 |
-
format: VAL_MIX
|
| 3385 |
-
});
|
| 3386 |
-
}
|
| 3387 |
-
if (lchA instanceof NullObject || lchB instanceof NullObject) return cacheInvalidColorValue(cacheKey, format, nullable);
|
| 3388 |
-
const [llA, ccA, hhA, aaA] = lchA;
|
| 3389 |
-
const [llB, ccB, hhB, aaB] = lchB;
|
| 3390 |
-
const lNone = llA === "none" && llB === "none";
|
| 3391 |
-
const cNone = ccA === "none" && ccB === "none";
|
| 3392 |
-
const hNone = hhA === "none" && hhB === "none";
|
| 3393 |
-
const alphaNone = aaA === "none" && aaB === "none";
|
| 3394 |
-
let [[lA, cA, hA, alphaA], [lB, cB, hB, alphaB]] = normalizeColorComponents([
|
| 3395 |
-
llA,
|
| 3396 |
-
ccA,
|
| 3397 |
-
hhA,
|
| 3398 |
-
aaA
|
| 3399 |
-
], [
|
| 3400 |
-
llB,
|
| 3401 |
-
ccB,
|
| 3402 |
-
hhB,
|
| 3403 |
-
aaB
|
| 3404 |
-
], true);
|
| 3405 |
-
if (hueArc) [hA, hB] = interpolateHue(hA, hB, hueArc);
|
| 3406 |
-
const factorA = alphaA * pA;
|
| 3407 |
-
const factorB = alphaB * pB;
|
| 3408 |
-
alpha = factorA + factorB;
|
| 3409 |
-
const h = (hA * pA + hB * pB) % DEG;
|
| 3410 |
-
let l, c;
|
| 3411 |
-
if (alpha === 0) {
|
| 3412 |
-
l = lA * pA + lB * pB;
|
| 3413 |
-
c = cA * pA + cB * pB;
|
| 3414 |
-
} else {
|
| 3415 |
-
l = (lA * factorA + lB * factorB) / alpha;
|
| 3416 |
-
c = (cA * factorA + cB * factorB) / alpha;
|
| 3417 |
-
alpha = parseFloat(alpha.toFixed(3));
|
| 3418 |
-
}
|
| 3419 |
-
if (format === "computedValue") {
|
| 3420 |
-
const res = [
|
| 3421 |
-
colorSpace,
|
| 3422 |
-
lNone ? NONE : roundToPrecision(l, HEX),
|
| 3423 |
-
cNone ? NONE : roundToPrecision(c, HEX),
|
| 3424 |
-
hNone ? NONE : roundToPrecision(h, HEX),
|
| 3425 |
-
alphaNone ? NONE : alpha * m
|
| 3426 |
-
];
|
| 3427 |
-
setCache(cacheKey, res);
|
| 3428 |
-
return res;
|
| 3429 |
-
}
|
| 3430 |
-
[, r, g, b] = resolveColorValue(`${colorSpace}(${l} ${c} ${h})`);
|
| 3431 |
-
} else {
|
| 3432 |
-
let labA, labB;
|
| 3433 |
-
if (colorSpace === "lab") {
|
| 3434 |
-
if (REG_CURRENT.test(colorA)) labA = [
|
| 3435 |
-
NONE,
|
| 3436 |
-
NONE,
|
| 3437 |
-
NONE,
|
| 3438 |
-
NONE
|
| 3439 |
-
];
|
| 3440 |
-
else labA = convertColorToLab(colorA, {
|
| 3441 |
-
colorSpace,
|
| 3442 |
-
format: VAL_MIX
|
| 3443 |
-
});
|
| 3444 |
-
if (REG_CURRENT.test(colorB)) labB = [
|
| 3445 |
-
NONE,
|
| 3446 |
-
NONE,
|
| 3447 |
-
NONE,
|
| 3448 |
-
NONE
|
| 3449 |
-
];
|
| 3450 |
-
else labB = convertColorToLab(colorB, {
|
| 3451 |
-
colorSpace,
|
| 3452 |
-
format: VAL_MIX
|
| 3453 |
-
});
|
| 3454 |
-
} else {
|
| 3455 |
-
if (REG_CURRENT.test(colorA)) labA = [
|
| 3456 |
-
NONE,
|
| 3457 |
-
NONE,
|
| 3458 |
-
NONE,
|
| 3459 |
-
NONE
|
| 3460 |
-
];
|
| 3461 |
-
else labA = convertColorToOklab(colorA, {
|
| 3462 |
-
colorSpace,
|
| 3463 |
-
format: VAL_MIX
|
| 3464 |
-
});
|
| 3465 |
-
if (REG_CURRENT.test(colorB)) labB = [
|
| 3466 |
-
NONE,
|
| 3467 |
-
NONE,
|
| 3468 |
-
NONE,
|
| 3469 |
-
NONE
|
| 3470 |
-
];
|
| 3471 |
-
else labB = convertColorToOklab(colorB, {
|
| 3472 |
-
colorSpace,
|
| 3473 |
-
format: VAL_MIX
|
| 3474 |
-
});
|
| 3475 |
-
}
|
| 3476 |
-
if (labA instanceof NullObject || labB instanceof NullObject) return cacheInvalidColorValue(cacheKey, format, nullable);
|
| 3477 |
-
const [llA, aaA, bbA, alA] = labA;
|
| 3478 |
-
const [llB, aaB, bbB, alB] = labB;
|
| 3479 |
-
const lNone = llA === "none" && llB === "none";
|
| 3480 |
-
const aNone = aaA === "none" && aaB === "none";
|
| 3481 |
-
const bNone = bbA === "none" && bbB === "none";
|
| 3482 |
-
const alphaNone = alA === "none" && alB === "none";
|
| 3483 |
-
const [[lA, aA, bA, alphaA], [lB, aB, bB, alphaB]] = normalizeColorComponents([
|
| 3484 |
-
llA,
|
| 3485 |
-
aaA,
|
| 3486 |
-
bbA,
|
| 3487 |
-
alA
|
| 3488 |
-
], [
|
| 3489 |
-
llB,
|
| 3490 |
-
aaB,
|
| 3491 |
-
bbB,
|
| 3492 |
-
alB
|
| 3493 |
-
], true);
|
| 3494 |
-
const factorA = alphaA * pA;
|
| 3495 |
-
const factorB = alphaB * pB;
|
| 3496 |
-
alpha = factorA + factorB;
|
| 3497 |
-
let l, aO, bO;
|
| 3498 |
-
if (alpha === 0) {
|
| 3499 |
-
l = lA * pA + lB * pB;
|
| 3500 |
-
aO = aA * pA + aB * pB;
|
| 3501 |
-
bO = bA * pA + bB * pB;
|
| 3502 |
-
} else {
|
| 3503 |
-
l = (lA * factorA + lB * factorB) / alpha;
|
| 3504 |
-
aO = (aA * factorA + aB * factorB) / alpha;
|
| 3505 |
-
bO = (bA * factorA + bB * factorB) / alpha;
|
| 3506 |
-
alpha = parseFloat(alpha.toFixed(3));
|
| 3507 |
-
}
|
| 3508 |
-
if (format === "computedValue") {
|
| 3509 |
-
const res = [
|
| 3510 |
-
colorSpace,
|
| 3511 |
-
lNone ? NONE : roundToPrecision(l, HEX),
|
| 3512 |
-
aNone ? NONE : roundToPrecision(aO, HEX),
|
| 3513 |
-
bNone ? NONE : roundToPrecision(bO, HEX),
|
| 3514 |
-
alphaNone ? NONE : alpha * m
|
| 3515 |
-
];
|
| 3516 |
-
setCache(cacheKey, res);
|
| 3517 |
-
return res;
|
| 3518 |
-
}
|
| 3519 |
-
[, r, g, b] = resolveColorValue(`${colorSpace}(${l} ${aO} ${bO})`);
|
| 3520 |
-
}
|
| 3521 |
-
const res = [
|
| 3522 |
-
"rgb",
|
| 3523 |
-
Math.round(r),
|
| 3524 |
-
Math.round(g),
|
| 3525 |
-
Math.round(b),
|
| 3526 |
-
parseFloat((alpha * m).toFixed(3))
|
| 3527 |
-
];
|
| 3528 |
-
setCache(cacheKey, res);
|
| 3529 |
-
return res;
|
| 3530 |
-
};
|
| 3531 |
-
//#endregion
|
| 3532 |
-
export { NAMED_COLORS, convertColorToHsl, convertColorToHwb, convertColorToLab, convertColorToLch, convertColorToOklab, convertColorToOklch, convertColorToRgb, convertRgbToHex, numberToHexString, parseColorFunc, parseColorValue, resolveColorFunc, resolveColorMix, resolveColorValue };
|
| 3533 |
-
|
| 3534 |
-
//# sourceMappingURL=color.js.map
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
node_modules/@asamuzakjp/css-color/dist/esm/js/color.js.map
DELETED
|
The diff for this file is too large to render.
See raw diff
|
|
|
node_modules/@asamuzakjp/css-color/dist/esm/js/common.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
| 1 |
-
/**
|
| 2 |
-
* common
|
| 3 |
-
*/
|
| 4 |
-
/**
|
| 5 |
-
* get type
|
| 6 |
-
* @param o - object to check
|
| 7 |
-
* @returns type of object
|
| 8 |
-
*/
|
| 9 |
-
export declare const getType: (o: unknown) => string;
|
| 10 |
-
/**
|
| 11 |
-
* is string
|
| 12 |
-
* @param o - object to check
|
| 13 |
-
* @returns result
|
| 14 |
-
*/
|
| 15 |
-
export declare const isString: (o: unknown) => o is string;
|
| 16 |
-
/**
|
| 17 |
-
* is string or number
|
| 18 |
-
* @param o - object to check
|
| 19 |
-
* @returns result
|
| 20 |
-
*/
|
| 21 |
-
export declare const isStringOrNumber: (o: unknown) => boolean;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
node_modules/@asamuzakjp/css-color/dist/esm/js/common.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
| 1 |
-
//#region src/js/common.ts
|
| 2 |
-
/**
|
| 3 |
-
* is string
|
| 4 |
-
* @param o - object to check
|
| 5 |
-
* @returns result
|
| 6 |
-
*/
|
| 7 |
-
var isString = (o) => typeof o === "string" || o instanceof String;
|
| 8 |
-
/**
|
| 9 |
-
* is string or number
|
| 10 |
-
* @param o - object to check
|
| 11 |
-
* @returns result
|
| 12 |
-
*/
|
| 13 |
-
var isStringOrNumber = (o) => isString(o) || typeof o === "number";
|
| 14 |
-
//#endregion
|
| 15 |
-
export { isString, isStringOrNumber };
|
| 16 |
-
|
| 17 |
-
//# sourceMappingURL=common.js.map
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
node_modules/@asamuzakjp/css-color/dist/esm/js/common.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
{"version":3,"file":"common.js","names":[],"sources":["../../../src/js/common.ts"],"sourcesContent":["/**\n * common\n */\n\n/* numeric constants */\nconst TYPE_FROM = 8;\nconst TYPE_TO = -1;\n\n/**\n * get type\n * @param o - object to check\n * @returns type of object\n */\nexport const getType = (o: unknown): string =>\n Object.prototype.toString.call(o).slice(TYPE_FROM, TYPE_TO);\n\n/**\n * is string\n * @param o - object to check\n * @returns result\n */\nexport const isString = (o: unknown): o is string =>\n typeof o === 'string' || o instanceof String;\n\n/**\n * is string or number\n * @param o - object to check\n * @returns result\n */\nexport const isStringOrNumber = (o: unknown): boolean =>\n isString(o) || typeof o === 'number';\n"],"mappings":";;;;;;AAqBA,IAAa,YAAY,MACvB,OAAO,MAAM,YAAY,aAAa;;;;;;AAOxC,IAAa,oBAAoB,MAC/B,SAAS,EAAE,IAAI,OAAO,MAAM"}
|
|
|
|
|
|
node_modules/@asamuzakjp/css-color/dist/esm/js/constant.d.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
| 1 |
-
/**
|
| 2 |
-
* constant
|
| 3 |
-
*/
|
| 4 |
-
export declare const ANGLE = "deg|g?rad|turn";
|
| 5 |
-
export declare const LENGTH = "[cm]m|[dls]?v(?:[bhiw]|max|min)|in|p[ctx]|q|r?(?:[cl]h|cap|e[mx]|ic)";
|
| 6 |
-
export declare const NUM = "[+-]?(?:(?:0|[1-9]\\d*)(?:\\.\\d*)?|\\.\\d+)(?:e-?(?:0|[1-9]\\d*))?";
|
| 7 |
-
export declare const NUM_POSITIVE = "\\+?(?:(?:0|[1-9]\\d*)(?:\\.\\d*)?|\\.\\d+)(?:e-?(?:0|[1-9]\\d*))?";
|
| 8 |
-
export declare const NONE = "none";
|
| 9 |
-
export declare const PCT = "[+-]?(?:(?:0|[1-9]\\d*)(?:\\.\\d*)?|\\.\\d+)(?:e-?(?:0|[1-9]\\d*))?%";
|
| 10 |
-
export declare const SYN_FN_CALC = "^(?:calc|clamp|max|min|exp|hypot|log|pow|sqrt|abs|sign|mod|rem|round|a?(?:cos|sin|tan)|atan2)\\(|(?<=[*\\/\\s\\(])(?:calc|clamp|max|min|exp|hypot|log|pow|sqrt|abs|sign|mod|rem|round|a?(?:cos|sin|tan)|atan2)\\(";
|
| 11 |
-
export declare const SYN_FN_MATH_START = "^(?:clamp|max|min|exp|hypot|log|pow|sqrt|abs|sign|mod|rem|round|a?(?:cos|sin|tan)|atan2)\\($";
|
| 12 |
-
export declare const SYN_FN_VAR = "^var\\(|(?<=[*\\/\\s\\(])var\\(";
|
| 13 |
-
export declare const SYN_FN_VAR_START = "^(?:var|calc|clamp|max|min|exp|hypot|log|pow|sqrt|abs|sign|mod|rem|round|a?(?:cos|sin|tan)|atan2)\\(";
|
| 14 |
-
export declare const CS_HUE = "(?:(?:ok)?lch|hsl|hwb)(?:\\s(?:(?:de|in)creasing|longer|shorter)\\shue)?";
|
| 15 |
-
export declare const CS_HUE_CAPT = "((?:ok)?lch|hsl|hwb)(?:\\s((?:de|in)creasing|longer|shorter)\\shue)?";
|
| 16 |
-
export declare const CS_LAB = "(?:ok)?lab";
|
| 17 |
-
export declare const CS_LCH = "(?:ok)?lch";
|
| 18 |
-
export declare const CS_SRGB = "srgb(?:-linear)?";
|
| 19 |
-
export declare const CS_RGB = "(?:a98|prophoto)-rgb|display-p3|rec2020|srgb(?:-linear)?";
|
| 20 |
-
export declare const CS_XYZ = "xyz(?:-d(?:50|65))?";
|
| 21 |
-
export declare const CS_RECT = "(?:ok)?lab|(?:a98|prophoto)-rgb|display-p3|rec2020|srgb(?:-linear)?|xyz(?:-d(?:50|65))?";
|
| 22 |
-
export declare const CS_MIX = "(?:(?:ok)?lch|hsl|hwb)(?:\\s(?:(?:de|in)creasing|longer|shorter)\\shue)?|(?:ok)?lab|(?:a98|prophoto)-rgb|display-p3|rec2020|srgb(?:-linear)?|xyz(?:-d(?:50|65))?";
|
| 23 |
-
export declare const FN_COLOR = "color(";
|
| 24 |
-
export declare const FN_LIGHT_DARK = "light-dark(";
|
| 25 |
-
export declare const FN_MIX = "color-mix(";
|
| 26 |
-
export declare const FN_REL = "(?:(?:ok)?l(?:ab|ch)|color|hsla?|hwb|rgba?)\\(\\s*from\\s+";
|
| 27 |
-
export declare const FN_REL_CAPT = "((?:ok)?l(?:ab|ch)|color|hsla?|hwb|rgba?)\\(\\s*from\\s+";
|
| 28 |
-
export declare const FN_VAR = "var(";
|
| 29 |
-
export declare const SYN_FN_COLOR = "(?:(?:a98|prophoto)-rgb|display-p3|rec2020|srgb(?:-linear)?|xyz(?:-d(?:50|65))?)(?:\\s+(?:[+-]?(?:(?:0|[1-9]\\d*)(?:\\.\\d*)?|\\.\\d+)(?:e-?(?:0|[1-9]\\d*))?|[+-]?(?:(?:0|[1-9]\\d*)(?:\\.\\d*)?|\\.\\d+)(?:e-?(?:0|[1-9]\\d*))?%|none)){3}(?:\\s*\\/\\s*(?:[+-]?(?:(?:0|[1-9]\\d*)(?:\\.\\d*)?|\\.\\d+)(?:e-?(?:0|[1-9]\\d*))?|[+-]?(?:(?:0|[1-9]\\d*)(?:\\.\\d*)?|\\.\\d+)(?:e-?(?:0|[1-9]\\d*))?%|none))?";
|
| 30 |
-
export declare const SYN_FN_LIGHT_DARK = "^light-dark\\(";
|
| 31 |
-
export declare const SYN_FN_REL = "^(?:(?:ok)?l(?:ab|ch)|color|hsla?|hwb|rgba?)\\(\\s*from\\s+|(?<=[\\s])(?:(?:ok)?l(?:ab|ch)|color|hsla?|hwb|rgba?)\\(\\s*from\\s+";
|
| 32 |
-
export declare const SYN_HSL = "(?:[+-]?(?:(?:0|[1-9]\\d*)(?:\\.\\d*)?|\\.\\d+)(?:e-?(?:0|[1-9]\\d*))?(?:deg|g?rad|turn)?|none)(?:\\s+(?:[+-]?(?:(?:0|[1-9]\\d*)(?:\\.\\d*)?|\\.\\d+)(?:e-?(?:0|[1-9]\\d*))?|[+-]?(?:(?:0|[1-9]\\d*)(?:\\.\\d*)?|\\.\\d+)(?:e-?(?:0|[1-9]\\d*))?%|none)){2}(?:\\s*\\/\\s*(?:[+-]?(?:(?:0|[1-9]\\d*)(?:\\.\\d*)?|\\.\\d+)(?:e-?(?:0|[1-9]\\d*))?|[+-]?(?:(?:0|[1-9]\\d*)(?:\\.\\d*)?|\\.\\d+)(?:e-?(?:0|[1-9]\\d*))?%|none))?";
|
| 33 |
-
export declare const SYN_HSL_LV3 = "[+-]?(?:(?:0|[1-9]\\d*)(?:\\.\\d*)?|\\.\\d+)(?:e-?(?:0|[1-9]\\d*))?(?:deg|g?rad|turn)?(?:\\s*,\\s*[+-]?(?:(?:0|[1-9]\\d*)(?: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:e-?(?:0|[1-9]\\d*))?(?:deg|g?rad|turn)?|none)(?:\\s*\\/\\s*(?:[+-]?(?:(?:0|[1-9]\\d*)(?:\\.\\d*)?|\\.\\d+)(?:e-?(?:0|[1-9]\\d*))?|[+-]?(?:(?:0|[1-9]\\d*)(?:\\.\\d*)?|\\.\\d+)(?:e-?(?:0|[1-9]\\d*))?%|none))?\\s*\\)|color\\(\\s*(?:(?:a98|prophoto)-rgb|display-p3|rec2020|srgb(?:-linear)?|xyz(?:-d(?:50|65))?)(?:\\s+(?:[+-]?(?:(?:0|[1-9]\\d*)(?:\\.\\d*)?|\\.\\d+)(?:e-?(?:0|[1-9]\\d*))?|[+-]?(?:(?:0|[1-9]\\d*)(?:\\.\\d*)?|\\.\\d+)(?:e-?(?:0|[1-9]\\d*))?%|none)){3}(?:\\s*\\/\\s*(?:[+-]?(?:(?:0|[1-9]\\d*)(?:\\.\\d*)?|\\.\\d+)(?:e-?(?:0|[1-9]\\d*))?|[+-]?(?:(?:0|[1-9]\\d*)(?:\\.\\d*)?|\\.\\d+)(?:e-?(?:0|[1-9]\\d*))?%|none))?\\s*\\))(?:\\s+[+-]?(?:(?:0|[1-9]\\d*)(?:\\.\\d*)?|\\.\\d+)(?:e-?(?:0|[1-9]\\d*))?%)?";
|
| 39 |
-
export declare const SYN_MIX = "color-mix\\(\\s*in\\s+(?:(?:(?:ok)?lch|hsl|hwb)(?:\\s(?:(?:de|in)creasing|longer|shorter)\\shue)?|(?:ok)?lab|(?:a98|prophoto)-rgb|display-p3|rec2020|srgb(?:-linear)?|xyz(?:-d(?:50|65))?)\\s*,\\s*(?:[a-z]+|#[\\da-f]{3}|#[\\da-f]{4}|#[\\da-f]{6}|#[\\da-f]{8}|hsla?\\(\\s*[+-]?(?:(?:0|[1-9]\\d*)(?:\\.\\d*)?|\\.\\d+)(?:e-?(?:0|[1-9]\\d*))?(?:deg|g?rad|turn)?(?:\\s*,\\s*[+-]?(?:(?:0|[1-9]\\d*)(?:\\.\\d*)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?|\\.\\d+)(?:e-?(?:0|[1-9]\\d*))?%|none)){3}(?:\\s*\\/\\s*(?:[+-]?(?:(?:0|[1-9]\\d*)(?:\\.\\d*)?|\\.\\d+)(?:e-?(?:0|[1-9]\\d*))?|[+-]?(?:(?:0|[1-9]\\d*)(?:\\.\\d*)?|\\.\\d+)(?:e-?(?:0|[1-9]\\d*))?%|none))?\\s*\\))(?:\\s+[+-]?(?:(?:0|[1-9]\\d*)(?:\\.\\d*)?|\\.\\d+)(?:e-?(?:0|[1-9]\\d*))?%)?)\\s*\\)";
|
| 41 |
-
export declare const VAL_COMP = "computedValue";
|
| 42 |
-
export declare const VAL_MIX = "mixValue";
|
| 43 |
-
export declare const VAL_SPEC = "specifiedValue";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
node_modules/@asamuzakjp/css-color/dist/esm/js/constant.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
| 1 |
-
//#region src/js/constant.ts
|
| 2 |
-
/**
|
| 3 |
-
* constant
|
| 4 |
-
*/
|
| 5 |
-
var _DIGIT = "(?:0|[1-9]\\d*)";
|
| 6 |
-
var _MATH = `clamp|max|min|exp|hypot|log|pow|sqrt|abs|sign|mod|rem|round|a?(?:cos|sin|tan)|atan2`;
|
| 7 |
-
var _CALC = `calc|${_MATH}`;
|
| 8 |
-
var _VAR = `var|${_CALC}`;
|
| 9 |
-
var ANGLE = "deg|g?rad|turn";
|
| 10 |
-
var LENGTH = "[cm]m|[dls]?v(?:[bhiw]|max|min)|in|p[ctx]|q|r?(?:[cl]h|cap|e[mx]|ic)";
|
| 11 |
-
var NUM = `[+-]?(?:${_DIGIT}(?:\\.\\d*)?|\\.\\d+)(?:e-?${_DIGIT})?`;
|
| 12 |
-
var NUM_POSITIVE = `\\+?(?:${_DIGIT}(?:\\.\\d*)?|\\.\\d+)(?:e-?${_DIGIT})?`;
|
| 13 |
-
var NONE = "none";
|
| 14 |
-
var PCT = `${NUM}%`;
|
| 15 |
-
var SYN_FN_CALC = `^(?:${_CALC})\\(|(?<=[*\\/\\s\\(])(?:${_CALC})\\(`;
|
| 16 |
-
var SYN_FN_MATH_START = `^(?:${_MATH})\\($`;
|
| 17 |
-
var SYN_FN_VAR = "^var\\(|(?<=[*\\/\\s\\(])var\\(";
|
| 18 |
-
var SYN_FN_VAR_START = `^(?:${_VAR})\\(`;
|
| 19 |
-
var _ALPHA = `(?:\\s*\\/\\s*(?:${NUM}|${PCT}|${NONE}))?`;
|
| 20 |
-
var _ALPHA_LV3 = `(?:\\s*,\\s*(?:${NUM}|${PCT}))?`;
|
| 21 |
-
var _COLOR_FUNC = "(?:ok)?l(?:ab|ch)|color|hsla?|hwb|rgba?";
|
| 22 |
-
var _COLOR_KEY = "[a-z]+|#[\\da-f]{3}|#[\\da-f]{4}|#[\\da-f]{6}|#[\\da-f]{8}";
|
| 23 |
-
var _CS_HUE = "(?:ok)?lch|hsl|hwb";
|
| 24 |
-
var _CS_HUE_ARC = "(?:de|in)creasing|longer|shorter";
|
| 25 |
-
var _NUM_ANGLE = `${NUM}(?:${ANGLE})?`;
|
| 26 |
-
var _NUM_ANGLE_NONE = `(?:${NUM}(?:${ANGLE})?|${NONE})`;
|
| 27 |
-
var _NUM_PCT_NONE = `(?:${NUM}|${PCT}|${NONE})`;
|
| 28 |
-
var CS_HUE = `(?:${_CS_HUE})(?:\\s(?:${_CS_HUE_ARC})\\shue)?`;
|
| 29 |
-
var CS_HUE_CAPT = `(${_CS_HUE})(?:\\s(${_CS_HUE_ARC})\\shue)?`;
|
| 30 |
-
var CS_LAB = "(?:ok)?lab";
|
| 31 |
-
var CS_LCH = "(?:ok)?lch";
|
| 32 |
-
var CS_RGB = `(?:a98|prophoto)-rgb|display-p3|rec2020|srgb(?:-linear)?`;
|
| 33 |
-
var CS_XYZ = "xyz(?:-d(?:50|65))?";
|
| 34 |
-
var CS_RECT = `${CS_LAB}|${CS_RGB}|${CS_XYZ}`;
|
| 35 |
-
var CS_MIX = `${CS_HUE}|${CS_RECT}`;
|
| 36 |
-
var FN_COLOR = "color(";
|
| 37 |
-
var FN_LIGHT_DARK = "light-dark(";
|
| 38 |
-
var FN_MIX = "color-mix(";
|
| 39 |
-
var FN_REL = `(?:${_COLOR_FUNC})\\(\\s*from\\s+`;
|
| 40 |
-
var FN_REL_CAPT = `(${_COLOR_FUNC})\\(\\s*from\\s+`;
|
| 41 |
-
var FN_VAR = "var(";
|
| 42 |
-
var SYN_FN_COLOR = `(?:${CS_RGB}|${CS_XYZ})(?:\\s+${_NUM_PCT_NONE}){3}${_ALPHA}`;
|
| 43 |
-
var SYN_FN_LIGHT_DARK = "^light-dark\\(";
|
| 44 |
-
var SYN_FN_REL = `^${FN_REL}|(?<=[\\s])${FN_REL}`;
|
| 45 |
-
var SYN_HSL = `${_NUM_ANGLE_NONE}(?:\\s+${_NUM_PCT_NONE}){2}${_ALPHA}`;
|
| 46 |
-
var SYN_HSL_LV3 = `${_NUM_ANGLE}(?:\\s*,\\s*${PCT}){2}${_ALPHA_LV3}`;
|
| 47 |
-
var SYN_LCH = `(?:${_NUM_PCT_NONE}\\s+){2}${_NUM_ANGLE_NONE}${_ALPHA}`;
|
| 48 |
-
var SYN_MOD = `${_NUM_PCT_NONE}(?:\\s+${_NUM_PCT_NONE}){2}${_ALPHA}`;
|
| 49 |
-
var SYN_RGB_LV3 = `(?:${NUM}(?:\\s*,\\s*${NUM}){2}|${PCT}(?:\\s*,\\s*${PCT}){2})${_ALPHA_LV3}`;
|
| 50 |
-
var SYN_COLOR_TYPE = `${_COLOR_KEY}|hsla?\\(\\s*${SYN_HSL_LV3}\\s*\\)|rgba?\\(\\s*${SYN_RGB_LV3}\\s*\\)|(?:hsla?|hwb)\\(\\s*${SYN_HSL}\\s*\\)|(?:(?:ok)?lab|rgba?)\\(\\s*${SYN_MOD}\\s*\\)|(?:ok)?lch\\(\\s*${SYN_LCH}\\s*\\)|color\\(\\s*${SYN_FN_COLOR}\\s*\\)`;
|
| 51 |
-
var SYN_MIX_PART = `(?:${SYN_COLOR_TYPE})(?:\\s+${PCT})?`;
|
| 52 |
-
var SYN_MIX = `color-mix\\(\\s*in\\s+(?:${CS_MIX})\\s*,\\s*${SYN_MIX_PART}\\s*,\\s*${SYN_MIX_PART}\\s*\\)`;
|
| 53 |
-
var SYN_MIX_CAPT = `color-mix\\(\\s*in\\s+(${CS_MIX})\\s*,\\s*(${SYN_MIX_PART})\\s*,\\s*(${SYN_MIX_PART})\\s*\\)`;
|
| 54 |
-
var VAL_COMP = "computedValue";
|
| 55 |
-
var VAL_MIX = "mixValue";
|
| 56 |
-
var VAL_SPEC = "specifiedValue";
|
| 57 |
-
//#endregion
|
| 58 |
-
export { ANGLE, CS_HUE, CS_HUE_CAPT, CS_LAB, CS_LCH, CS_MIX, CS_RECT, CS_RGB, CS_XYZ, FN_COLOR, FN_LIGHT_DARK, FN_MIX, FN_REL, FN_REL_CAPT, FN_VAR, LENGTH, NONE, NUM, NUM_POSITIVE, PCT, SYN_COLOR_TYPE, SYN_FN_CALC, SYN_FN_COLOR, SYN_FN_LIGHT_DARK, SYN_FN_MATH_START, SYN_FN_REL, SYN_FN_VAR, SYN_FN_VAR_START, SYN_HSL, SYN_HSL_LV3, SYN_LCH, SYN_MIX, SYN_MIX_CAPT, SYN_MIX_PART, SYN_MOD, SYN_RGB_LV3, VAL_COMP, VAL_MIX, VAL_SPEC };
|
| 59 |
-
|
| 60 |
-
//# sourceMappingURL=constant.js.map
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
node_modules/@asamuzakjp/css-color/dist/esm/js/constant.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
{"version":3,"file":"constant.js","names":[],"sources":["../../../src/js/constant.ts"],"sourcesContent":["/**\n * constant\n */\n\n/* values and units */\nconst _DIGIT = '(?:0|[1-9]\\\\d*)';\nconst _COMPARE = 'clamp|max|min';\nconst _EXPO = 'exp|hypot|log|pow|sqrt';\nconst _SIGN = 'abs|sign';\nconst _STEP = 'mod|rem|round';\nconst _TRIG = 'a?(?:cos|sin|tan)|atan2';\nconst _MATH = `${_COMPARE}|${_EXPO}|${_SIGN}|${_STEP}|${_TRIG}`;\nconst _CALC = `calc|${_MATH}`;\nconst _VAR = `var|${_CALC}`;\nexport const ANGLE = 'deg|g?rad|turn';\nexport const LENGTH =\n '[cm]m|[dls]?v(?:[bhiw]|max|min)|in|p[ctx]|q|r?(?:[cl]h|cap|e[mx]|ic)';\nexport const NUM = `[+-]?(?:${_DIGIT}(?:\\\\.\\\\d*)?|\\\\.\\\\d+)(?:e-?${_DIGIT})?`;\nexport const NUM_POSITIVE = `\\\\+?(?:${_DIGIT}(?:\\\\.\\\\d*)?|\\\\.\\\\d+)(?:e-?${_DIGIT})?`;\nexport const NONE = 'none';\nexport const PCT = `${NUM}%`;\nexport const SYN_FN_CALC = `^(?:${_CALC})\\\\(|(?<=[*\\\\/\\\\s\\\\(])(?:${_CALC})\\\\(`;\nexport const SYN_FN_MATH_START = `^(?:${_MATH})\\\\($`;\nexport const SYN_FN_VAR = '^var\\\\(|(?<=[*\\\\/\\\\s\\\\(])var\\\\(';\nexport const SYN_FN_VAR_START = `^(?:${_VAR})\\\\(`;\n\n/* colors */\nconst _ALPHA = `(?:\\\\s*\\\\/\\\\s*(?:${NUM}|${PCT}|${NONE}))?`;\nconst _ALPHA_LV3 = `(?:\\\\s*,\\\\s*(?:${NUM}|${PCT}))?`;\nconst _COLOR_FUNC = '(?:ok)?l(?:ab|ch)|color|hsla?|hwb|rgba?';\nconst _COLOR_KEY = '[a-z]+|#[\\\\da-f]{3}|#[\\\\da-f]{4}|#[\\\\da-f]{6}|#[\\\\da-f]{8}';\nconst _CS_HUE = '(?:ok)?lch|hsl|hwb';\nconst _CS_HUE_ARC = '(?:de|in)creasing|longer|shorter';\nconst _NUM_ANGLE = `${NUM}(?:${ANGLE})?`;\nconst _NUM_ANGLE_NONE = `(?:${NUM}(?:${ANGLE})?|${NONE})`;\nconst _NUM_PCT_NONE = `(?:${NUM}|${PCT}|${NONE})`;\nexport const CS_HUE = `(?:${_CS_HUE})(?:\\\\s(?:${_CS_HUE_ARC})\\\\shue)?`;\nexport const CS_HUE_CAPT = `(${_CS_HUE})(?:\\\\s(${_CS_HUE_ARC})\\\\shue)?`;\nexport const CS_LAB = '(?:ok)?lab';\nexport const CS_LCH = '(?:ok)?lch';\nexport const CS_SRGB = 'srgb(?:-linear)?';\nexport const CS_RGB = `(?:a98|prophoto)-rgb|display-p3|rec2020|${CS_SRGB}`;\nexport const CS_XYZ = 'xyz(?:-d(?:50|65))?';\nexport const CS_RECT = `${CS_LAB}|${CS_RGB}|${CS_XYZ}`;\nexport const CS_MIX = `${CS_HUE}|${CS_RECT}`;\nexport const FN_COLOR = 'color(';\nexport const FN_LIGHT_DARK = 'light-dark(';\nexport const FN_MIX = 'color-mix(';\nexport const FN_REL = `(?:${_COLOR_FUNC})\\\\(\\\\s*from\\\\s+`;\nexport const FN_REL_CAPT = `(${_COLOR_FUNC})\\\\(\\\\s*from\\\\s+`;\nexport const FN_VAR = 'var(';\nexport const SYN_FN_COLOR = `(?:${CS_RGB}|${CS_XYZ})(?:\\\\s+${_NUM_PCT_NONE}){3}${_ALPHA}`;\nexport const SYN_FN_LIGHT_DARK = '^light-dark\\\\(';\nexport const SYN_FN_REL = `^${FN_REL}|(?<=[\\\\s])${FN_REL}`;\nexport const SYN_HSL = `${_NUM_ANGLE_NONE}(?:\\\\s+${_NUM_PCT_NONE}){2}${_ALPHA}`;\nexport const SYN_HSL_LV3 = `${_NUM_ANGLE}(?:\\\\s*,\\\\s*${PCT}){2}${_ALPHA_LV3}`;\nexport const SYN_LCH = `(?:${_NUM_PCT_NONE}\\\\s+){2}${_NUM_ANGLE_NONE}${_ALPHA}`;\nexport const SYN_MOD = `${_NUM_PCT_NONE}(?:\\\\s+${_NUM_PCT_NONE}){2}${_ALPHA}`;\nexport const SYN_RGB_LV3 = `(?:${NUM}(?:\\\\s*,\\\\s*${NUM}){2}|${PCT}(?:\\\\s*,\\\\s*${PCT}){2})${_ALPHA_LV3}`;\nexport const SYN_COLOR_TYPE = `${_COLOR_KEY}|hsla?\\\\(\\\\s*${SYN_HSL_LV3}\\\\s*\\\\)|rgba?\\\\(\\\\s*${SYN_RGB_LV3}\\\\s*\\\\)|(?:hsla?|hwb)\\\\(\\\\s*${SYN_HSL}\\\\s*\\\\)|(?:(?:ok)?lab|rgba?)\\\\(\\\\s*${SYN_MOD}\\\\s*\\\\)|(?:ok)?lch\\\\(\\\\s*${SYN_LCH}\\\\s*\\\\)|color\\\\(\\\\s*${SYN_FN_COLOR}\\\\s*\\\\)`;\nexport const SYN_MIX_PART = `(?:${SYN_COLOR_TYPE})(?:\\\\s+${PCT})?`;\nexport const SYN_MIX = `color-mix\\\\(\\\\s*in\\\\s+(?:${CS_MIX})\\\\s*,\\\\s*${SYN_MIX_PART}\\\\s*,\\\\s*${SYN_MIX_PART}\\\\s*\\\\)`;\nexport const SYN_MIX_CAPT = `color-mix\\\\(\\\\s*in\\\\s+(${CS_MIX})\\\\s*,\\\\s*(${SYN_MIX_PART})\\\\s*,\\\\s*(${SYN_MIX_PART})\\\\s*\\\\)`;\n\n/* formats */\nexport const VAL_COMP = 'computedValue';\nexport const VAL_MIX = 'mixValue';\nexport const VAL_SPEC = 'specifiedValue';\n"],"mappings":";;;;AAKA,IAAM,SAAS;AAMf,IAAM,QAAQ;AACd,IAAM,QAAQ,QAAQ;AACtB,IAAM,OAAO,OAAO;AACpB,IAAa,QAAQ;AACrB,IAAa,SACX;AACF,IAAa,MAAM,WAAW,OAAO,6BAA6B,OAAO;AACzE,IAAa,eAAe,UAAU,OAAO,6BAA6B,OAAO;AACjF,IAAa,OAAO;AACpB,IAAa,MAAM,GAAG,IAAI;AAC1B,IAAa,cAAc,OAAO,MAAM,2BAA2B,MAAM;AACzE,IAAa,oBAAoB,OAAO,MAAM;AAC9C,IAAa,aAAa;AAC1B,IAAa,mBAAmB,OAAO,KAAK;AAG5C,IAAM,SAAS,oBAAoB,IAAI,GAAG,IAAI,GAAG,KAAK;AACtD,IAAM,aAAa,kBAAkB,IAAI,GAAG,IAAI;AAChD,IAAM,cAAc;AACpB,IAAM,aAAa;AACnB,IAAM,UAAU;AAChB,IAAM,cAAc;AACpB,IAAM,aAAa,GAAG,IAAI,KAAK,MAAM;AACrC,IAAM,kBAAkB,MAAM,IAAI,KAAK,MAAM,KAAK,KAAK;AACvD,IAAM,gBAAgB,MAAM,IAAI,GAAG,IAAI,GAAG,KAAK;AAC/C,IAAa,SAAS,MAAM,QAAQ,YAAY,YAAY;AAC5D,IAAa,cAAc,IAAI,QAAQ,UAAU,YAAY;AAC7D,IAAa,SAAS;AACtB,IAAa,SAAS;AAEtB,IAAa,SAAS;AACtB,IAAa,SAAS;AACtB,IAAa,UAAU,GAAG,OAAO,GAAG,OAAO,GAAG;AAC9C,IAAa,SAAS,GAAG,OAAO,GAAG;AACnC,IAAa,WAAW;AACxB,IAAa,gBAAgB;AAC7B,IAAa,SAAS;AACtB,IAAa,SAAS,MAAM,YAAY;AACxC,IAAa,cAAc,IAAI,YAAY;AAC3C,IAAa,SAAS;AACtB,IAAa,eAAe,MAAM,OAAO,GAAG,OAAO,UAAU,cAAc,MAAM;AACjF,IAAa,oBAAoB;AACjC,IAAa,aAAa,IAAI,OAAO,aAAa;AAClD,IAAa,UAAU,GAAG,gBAAgB,SAAS,cAAc,MAAM;AACvE,IAAa,cAAc,GAAG,WAAW,cAAc,IAAI,MAAM;AACjE,IAAa,UAAU,MAAM,cAAc,UAAU,kBAAkB;AACvE,IAAa,UAAU,GAAG,cAAc,SAAS,cAAc,MAAM;AACrE,IAAa,cAAc,MAAM,IAAI,cAAc,IAAI,OAAO,IAAI,cAAc,IAAI,OAAO;AAC3F,IAAa,iBAAiB,GAAG,WAAW,eAAe,YAAY,sBAAsB,YAAY,8BAA8B,QAAQ,qCAAqC,QAAQ,2BAA2B,QAAQ,sBAAsB,aAAa;AAClQ,IAAa,eAAe,MAAM,eAAe,UAAU,IAAI;AAC/D,IAAa,UAAU,4BAA4B,OAAO,YAAY,aAAa,WAAW,aAAa;AAC3G,IAAa,eAAe,0BAA0B,OAAO,aAAa,aAAa,aAAa,aAAa;AAGjH,IAAa,WAAW;AACxB,IAAa,UAAU;AACvB,IAAa,WAAW"}
|
|
|
|
|
|
node_modules/@asamuzakjp/css-color/dist/esm/js/convert.d.ts
DELETED
|
@@ -1,99 +0,0 @@
|
|
| 1 |
-
import { NullObject } from './cache.js';
|
| 2 |
-
import { ColorChannels, Options } from './typedef.js';
|
| 3 |
-
/**
|
| 4 |
-
* pre process
|
| 5 |
-
* @param value - CSS color value
|
| 6 |
-
* @param [opt] - options
|
| 7 |
-
* @returns value
|
| 8 |
-
*/
|
| 9 |
-
export declare const preProcess: (value: string, opt?: Options) => string | NullObject;
|
| 10 |
-
/**
|
| 11 |
-
* convert number to hex string
|
| 12 |
-
* @param value - numeric value
|
| 13 |
-
* @returns hex string: 00..ff
|
| 14 |
-
*/
|
| 15 |
-
export declare const numberToHex: (value: number) => string;
|
| 16 |
-
/**
|
| 17 |
-
* convert color to hex
|
| 18 |
-
* @param value - CSS color value
|
| 19 |
-
* @param [opt] - options
|
| 20 |
-
* @param [opt.alpha] - enable alpha channel
|
| 21 |
-
* @returns #rrggbb | #rrggbbaa | null
|
| 22 |
-
*/
|
| 23 |
-
export declare const colorToHex: (value: string, opt?: Options) => string | null;
|
| 24 |
-
/**
|
| 25 |
-
* convert color to hsl
|
| 26 |
-
* @param value - CSS color value
|
| 27 |
-
* @param [opt] - options
|
| 28 |
-
* @returns ColorChannels - [h, s, l, alpha]
|
| 29 |
-
*/
|
| 30 |
-
export declare const colorToHsl: (value: string, opt?: Options) => ColorChannels;
|
| 31 |
-
/**
|
| 32 |
-
* convert color to hwb
|
| 33 |
-
* @param value - CSS color value
|
| 34 |
-
* @param [opt] - options
|
| 35 |
-
* @returns ColorChannels - [h, w, b, alpha]
|
| 36 |
-
*/
|
| 37 |
-
export declare const colorToHwb: (value: string, opt?: Options) => ColorChannels;
|
| 38 |
-
/**
|
| 39 |
-
* convert color to lab
|
| 40 |
-
* @param value - CSS color value
|
| 41 |
-
* @param [opt] - options
|
| 42 |
-
* @returns ColorChannels - [l, a, b, alpha]
|
| 43 |
-
*/
|
| 44 |
-
export declare const colorToLab: (value: string, opt?: Options) => ColorChannels;
|
| 45 |
-
/**
|
| 46 |
-
* convert color to lch
|
| 47 |
-
* @param value - CSS color value
|
| 48 |
-
* @param [opt] - options
|
| 49 |
-
* @returns ColorChannels - [l, c, h, alpha]
|
| 50 |
-
*/
|
| 51 |
-
export declare const colorToLch: (value: string, opt?: Options) => ColorChannels;
|
| 52 |
-
/**
|
| 53 |
-
* convert color to oklab
|
| 54 |
-
* @param value - CSS color value
|
| 55 |
-
* @param [opt] - options
|
| 56 |
-
* @returns ColorChannels - [l, a, b, alpha]
|
| 57 |
-
*/
|
| 58 |
-
export declare const colorToOklab: (value: string, opt?: Options) => ColorChannels;
|
| 59 |
-
/**
|
| 60 |
-
* convert color to oklch
|
| 61 |
-
* @param value - CSS color value
|
| 62 |
-
* @param [opt] - options
|
| 63 |
-
* @returns ColorChannels - [l, c, h, alpha]
|
| 64 |
-
*/
|
| 65 |
-
export declare const colorToOklch: (value: string, opt?: Options) => ColorChannels;
|
| 66 |
-
/**
|
| 67 |
-
* convert color to rgb
|
| 68 |
-
* @param value - CSS color value
|
| 69 |
-
* @param [opt] - options
|
| 70 |
-
* @returns ColorChannels - [r, g, b, alpha]
|
| 71 |
-
*/
|
| 72 |
-
export declare const colorToRgb: (value: string, opt?: Options) => ColorChannels;
|
| 73 |
-
/**
|
| 74 |
-
* convert color to xyz
|
| 75 |
-
* @param value - CSS color value
|
| 76 |
-
* @param [opt] - options
|
| 77 |
-
* @returns ColorChannels - [x, y, z, alpha]
|
| 78 |
-
*/
|
| 79 |
-
export declare const colorToXyz: (value: string, opt?: Options) => ColorChannels;
|
| 80 |
-
/**
|
| 81 |
-
* convert color to xyz-d50
|
| 82 |
-
* @param value - CSS color value
|
| 83 |
-
* @param [opt] - options
|
| 84 |
-
* @returns ColorChannels - [x, y, z, alpha]
|
| 85 |
-
*/
|
| 86 |
-
export declare const colorToXyzD50: (value: string, opt?: Options) => ColorChannels;
|
| 87 |
-
export declare const convert: {
|
| 88 |
-
colorToHex: (value: string, opt?: Options) => string | null;
|
| 89 |
-
colorToHsl: (value: string, opt?: Options) => ColorChannels;
|
| 90 |
-
colorToHwb: (value: string, opt?: Options) => ColorChannels;
|
| 91 |
-
colorToLab: (value: string, opt?: Options) => ColorChannels;
|
| 92 |
-
colorToLch: (value: string, opt?: Options) => ColorChannels;
|
| 93 |
-
colorToOklab: (value: string, opt?: Options) => ColorChannels;
|
| 94 |
-
colorToOklch: (value: string, opt?: Options) => ColorChannels;
|
| 95 |
-
colorToRgb: (value: string, opt?: Options) => ColorChannels;
|
| 96 |
-
colorToXyz: (value: string, opt?: Options) => ColorChannels;
|
| 97 |
-
colorToXyzD50: (value: string, opt?: Options) => ColorChannels;
|
| 98 |
-
numberToHex: (value: number) => string;
|
| 99 |
-
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
node_modules/@asamuzakjp/css-color/dist/esm/js/convert.js
DELETED
|
@@ -1,245 +0,0 @@
|
|
| 1 |
-
import { CacheItem, NullObject, createCacheKey, getCache, setCache } from "./cache.js";
|
| 2 |
-
import { isString } from "./common.js";
|
| 3 |
-
import { SYN_FN_CALC, SYN_FN_REL, SYN_FN_VAR, VAL_COMP } from "./constant.js";
|
| 4 |
-
import { convertColorToHsl, convertColorToHwb, convertColorToLab, convertColorToLch, convertColorToOklab, convertColorToOklch, convertColorToRgb, numberToHexString, parseColorFunc, parseColorValue } from "./color.js";
|
| 5 |
-
import { resolveRelativeColor } from "./relative-color.js";
|
| 6 |
-
import { resolveColor } from "./resolve.js";
|
| 7 |
-
import { resolveVar } from "./css-var.js";
|
| 8 |
-
import { cssCalc } from "./css-calc.js";
|
| 9 |
-
//#region src/js/convert.ts
|
| 10 |
-
/**
|
| 11 |
-
* convert
|
| 12 |
-
*/
|
| 13 |
-
var NAMESPACE = "convert";
|
| 14 |
-
var REG_FN_CALC = new RegExp(SYN_FN_CALC);
|
| 15 |
-
var REG_FN_REL = new RegExp(SYN_FN_REL);
|
| 16 |
-
var REG_FN_VAR = new RegExp(SYN_FN_VAR);
|
| 17 |
-
/**
|
| 18 |
-
* pre process
|
| 19 |
-
* @param value - CSS color value
|
| 20 |
-
* @param [opt] - options
|
| 21 |
-
* @returns value
|
| 22 |
-
*/
|
| 23 |
-
var preProcess = (value, opt = {}) => {
|
| 24 |
-
if (!isString(value)) return new NullObject();
|
| 25 |
-
value = value.trim();
|
| 26 |
-
if (!value) return new NullObject();
|
| 27 |
-
const cacheKey = createCacheKey({
|
| 28 |
-
namespace: NAMESPACE,
|
| 29 |
-
name: "preProcess",
|
| 30 |
-
value
|
| 31 |
-
}, opt);
|
| 32 |
-
const cachedResult = getCache(cacheKey);
|
| 33 |
-
if (cachedResult instanceof CacheItem) {
|
| 34 |
-
if (cachedResult.isNull) return cachedResult;
|
| 35 |
-
return cachedResult.item;
|
| 36 |
-
}
|
| 37 |
-
let res = value;
|
| 38 |
-
if (REG_FN_VAR.test(value)) {
|
| 39 |
-
const resolved = resolveVar(value, opt);
|
| 40 |
-
if (isString(resolved)) res = resolved;
|
| 41 |
-
else {
|
| 42 |
-
setCache(cacheKey, null);
|
| 43 |
-
return new NullObject();
|
| 44 |
-
}
|
| 45 |
-
}
|
| 46 |
-
if (isString(res)) {
|
| 47 |
-
if (REG_FN_REL.test(res)) {
|
| 48 |
-
const resolved = resolveRelativeColor(res, opt);
|
| 49 |
-
if (isString(resolved)) res = resolved;
|
| 50 |
-
else {
|
| 51 |
-
setCache(cacheKey, null);
|
| 52 |
-
return new NullObject();
|
| 53 |
-
}
|
| 54 |
-
} else if (REG_FN_CALC.test(res)) res = cssCalc(res, opt);
|
| 55 |
-
}
|
| 56 |
-
if (isString(res)) {
|
| 57 |
-
if (res.startsWith("color-mix")) res = resolveColor(res, {
|
| 58 |
-
...opt,
|
| 59 |
-
format: VAL_COMP,
|
| 60 |
-
nullable: true
|
| 61 |
-
});
|
| 62 |
-
}
|
| 63 |
-
setCache(cacheKey, res);
|
| 64 |
-
return res;
|
| 65 |
-
};
|
| 66 |
-
/**
|
| 67 |
-
* converter factory to reduce boilerplate
|
| 68 |
-
* @param name - function name for cache
|
| 69 |
-
* @param format - color format
|
| 70 |
-
* @param convertFn - conversion function
|
| 71 |
-
* @returns color converter function
|
| 72 |
-
*/
|
| 73 |
-
var createColorConverter = (name, format, convertFn) => {
|
| 74 |
-
const colorConverterFn = (value, opt = {}) => {
|
| 75 |
-
if (!isString(value)) throw new TypeError(`${value} is not a string.`);
|
| 76 |
-
const resolved = preProcess(value, opt);
|
| 77 |
-
if (resolved instanceof NullObject) return [
|
| 78 |
-
0,
|
| 79 |
-
0,
|
| 80 |
-
0,
|
| 81 |
-
0
|
| 82 |
-
];
|
| 83 |
-
const val = resolved.toLowerCase();
|
| 84 |
-
const cacheKey = createCacheKey({
|
| 85 |
-
namespace: NAMESPACE,
|
| 86 |
-
name,
|
| 87 |
-
value: val
|
| 88 |
-
}, opt);
|
| 89 |
-
const cached = getCache(cacheKey);
|
| 90 |
-
if (cached instanceof CacheItem) return cached.item;
|
| 91 |
-
const result = convertFn(val, {
|
| 92 |
-
...opt,
|
| 93 |
-
format
|
| 94 |
-
});
|
| 95 |
-
setCache(cacheKey, result);
|
| 96 |
-
return result;
|
| 97 |
-
};
|
| 98 |
-
return colorConverterFn;
|
| 99 |
-
};
|
| 100 |
-
/**
|
| 101 |
-
* convert number to hex string
|
| 102 |
-
* @param value - numeric value
|
| 103 |
-
* @returns hex string: 00..ff
|
| 104 |
-
*/
|
| 105 |
-
var numberToHex = (value) => numberToHexString(value);
|
| 106 |
-
/**
|
| 107 |
-
* convert color to hex
|
| 108 |
-
* @param value - CSS color value
|
| 109 |
-
* @param [opt] - options
|
| 110 |
-
* @param [opt.alpha] - enable alpha channel
|
| 111 |
-
* @returns #rrggbb | #rrggbbaa | null
|
| 112 |
-
*/
|
| 113 |
-
var colorToHex = (value, opt = {}) => {
|
| 114 |
-
if (!isString(value)) throw new TypeError(`${value} is not a string.`);
|
| 115 |
-
const resolved = preProcess(value, opt);
|
| 116 |
-
if (resolved instanceof NullObject) return null;
|
| 117 |
-
const val = resolved.toLowerCase();
|
| 118 |
-
const cacheKey = createCacheKey({
|
| 119 |
-
namespace: NAMESPACE,
|
| 120 |
-
name: "colorToHex",
|
| 121 |
-
value: val
|
| 122 |
-
}, opt);
|
| 123 |
-
const cached = getCache(cacheKey);
|
| 124 |
-
if (cached instanceof CacheItem) {
|
| 125 |
-
if (cached.isNull) return null;
|
| 126 |
-
return cached.item;
|
| 127 |
-
}
|
| 128 |
-
const hex = resolveColor(val, {
|
| 129 |
-
...opt,
|
| 130 |
-
nullable: true,
|
| 131 |
-
format: opt.alpha ? "hexAlpha" : "hex"
|
| 132 |
-
});
|
| 133 |
-
if (isString(hex)) {
|
| 134 |
-
setCache(cacheKey, hex);
|
| 135 |
-
return hex;
|
| 136 |
-
}
|
| 137 |
-
setCache(cacheKey, null);
|
| 138 |
-
return null;
|
| 139 |
-
};
|
| 140 |
-
/**
|
| 141 |
-
* convert color to hsl
|
| 142 |
-
* @param value - CSS color value
|
| 143 |
-
* @param [opt] - options
|
| 144 |
-
* @returns ColorChannels - [h, s, l, alpha]
|
| 145 |
-
*/
|
| 146 |
-
var colorToHsl = createColorConverter("colorToHsl", "hsl", convertColorToHsl);
|
| 147 |
-
/**
|
| 148 |
-
* convert color to hwb
|
| 149 |
-
* @param value - CSS color value
|
| 150 |
-
* @param [opt] - options
|
| 151 |
-
* @returns ColorChannels - [h, w, b, alpha]
|
| 152 |
-
*/
|
| 153 |
-
var colorToHwb = createColorConverter("colorToHwb", "hwb", convertColorToHwb);
|
| 154 |
-
/**
|
| 155 |
-
* convert color to lab
|
| 156 |
-
* @param value - CSS color value
|
| 157 |
-
* @param [opt] - options
|
| 158 |
-
* @returns ColorChannels - [l, a, b, alpha]
|
| 159 |
-
*/
|
| 160 |
-
var colorToLab = createColorConverter("colorToLab", "lab", convertColorToLab);
|
| 161 |
-
/**
|
| 162 |
-
* convert color to lch
|
| 163 |
-
* @param value - CSS color value
|
| 164 |
-
* @param [opt] - options
|
| 165 |
-
* @returns ColorChannels - [l, c, h, alpha]
|
| 166 |
-
*/
|
| 167 |
-
var colorToLch = createColorConverter("colorToLch", "lch", convertColorToLch);
|
| 168 |
-
/**
|
| 169 |
-
* convert color to oklab
|
| 170 |
-
* @param value - CSS color value
|
| 171 |
-
* @param [opt] - options
|
| 172 |
-
* @returns ColorChannels - [l, a, b, alpha]
|
| 173 |
-
*/
|
| 174 |
-
var colorToOklab = createColorConverter("colorToOklab", "oklab", convertColorToOklab);
|
| 175 |
-
/**
|
| 176 |
-
* convert color to oklch
|
| 177 |
-
* @param value - CSS color value
|
| 178 |
-
* @param [opt] - options
|
| 179 |
-
* @returns ColorChannels - [l, c, h, alpha]
|
| 180 |
-
*/
|
| 181 |
-
var colorToOklch = createColorConverter("colorToOklch", "oklch", convertColorToOklch);
|
| 182 |
-
/**
|
| 183 |
-
* convert color to rgb
|
| 184 |
-
* @param value - CSS color value
|
| 185 |
-
* @param [opt] - options
|
| 186 |
-
* @returns ColorChannels - [r, g, b, alpha]
|
| 187 |
-
*/
|
| 188 |
-
var colorToRgb = createColorConverter("colorToRgb", "rgb", convertColorToRgb);
|
| 189 |
-
/**
|
| 190 |
-
* convert color to xyz
|
| 191 |
-
* @param value - CSS color value
|
| 192 |
-
* @param [opt] - options
|
| 193 |
-
* @returns ColorChannels - [x, y, z, alpha]
|
| 194 |
-
*/
|
| 195 |
-
var colorToXyz = (value, opt = {}) => {
|
| 196 |
-
if (!isString(value)) throw new TypeError(`${value} is not a string.`);
|
| 197 |
-
const resolved = preProcess(value, opt);
|
| 198 |
-
if (resolved instanceof NullObject) return [
|
| 199 |
-
0,
|
| 200 |
-
0,
|
| 201 |
-
0,
|
| 202 |
-
0
|
| 203 |
-
];
|
| 204 |
-
const val = resolved.toLowerCase();
|
| 205 |
-
const cacheKey = createCacheKey({
|
| 206 |
-
namespace: NAMESPACE,
|
| 207 |
-
name: "colorToXyz",
|
| 208 |
-
value: val
|
| 209 |
-
}, opt);
|
| 210 |
-
const cached = getCache(cacheKey);
|
| 211 |
-
if (cached instanceof CacheItem) return cached.item;
|
| 212 |
-
let parsed;
|
| 213 |
-
if (val.startsWith("color(")) parsed = parseColorFunc(val, opt);
|
| 214 |
-
else parsed = parseColorValue(val, opt);
|
| 215 |
-
const [, ...xyz] = parsed;
|
| 216 |
-
setCache(cacheKey, xyz);
|
| 217 |
-
return xyz;
|
| 218 |
-
};
|
| 219 |
-
/**
|
| 220 |
-
* convert color to xyz-d50
|
| 221 |
-
* @param value - CSS color value
|
| 222 |
-
* @param [opt] - options
|
| 223 |
-
* @returns ColorChannels - [x, y, z, alpha]
|
| 224 |
-
*/
|
| 225 |
-
var colorToXyzD50 = (value, opt = {}) => {
|
| 226 |
-
opt.d50 = true;
|
| 227 |
-
return colorToXyz(value, opt);
|
| 228 |
-
};
|
| 229 |
-
var convert = {
|
| 230 |
-
colorToHex,
|
| 231 |
-
colorToHsl,
|
| 232 |
-
colorToHwb,
|
| 233 |
-
colorToLab,
|
| 234 |
-
colorToLch,
|
| 235 |
-
colorToOklab,
|
| 236 |
-
colorToOklch,
|
| 237 |
-
colorToRgb,
|
| 238 |
-
colorToXyz,
|
| 239 |
-
colorToXyzD50,
|
| 240 |
-
numberToHex
|
| 241 |
-
};
|
| 242 |
-
//#endregion
|
| 243 |
-
export { convert };
|
| 244 |
-
|
| 245 |
-
//# sourceMappingURL=convert.js.map
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
node_modules/@asamuzakjp/css-color/dist/esm/js/convert.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
{"version":3,"file":"convert.js","names":[],"sources":["../../../src/js/convert.ts"],"sourcesContent":["/**\n * convert\n */\n\nimport {\n CacheItem,\n NullObject,\n createCacheKey,\n getCache,\n setCache\n} from './cache';\nimport {\n convertColorToHsl,\n convertColorToHwb,\n convertColorToLab,\n convertColorToLch,\n convertColorToOklab,\n convertColorToOklch,\n convertColorToRgb,\n numberToHexString,\n parseColorFunc,\n parseColorValue\n} from './color';\nimport { isString } from './common';\nimport { cssCalc } from './css-calc';\nimport { resolveVar } from './css-var';\nimport { resolveRelativeColor } from './relative-color';\nimport { resolveColor } from './resolve';\nimport { ColorChannels, ComputedColorChannels, Options } from './typedef';\n\n/* constants */\nimport { SYN_FN_CALC, SYN_FN_REL, SYN_FN_VAR, VAL_COMP } from './constant';\nconst NAMESPACE = 'convert';\n\n/* regexp */\nconst REG_FN_CALC = new RegExp(SYN_FN_CALC);\nconst REG_FN_REL = new RegExp(SYN_FN_REL);\nconst REG_FN_VAR = new RegExp(SYN_FN_VAR);\n\n/**\n * pre process\n * @param value - CSS color value\n * @param [opt] - options\n * @returns value\n */\nexport const preProcess = (\n value: string,\n opt: Options = {}\n): string | NullObject => {\n if (!isString(value)) {\n return new NullObject();\n }\n value = value.trim();\n if (!value) {\n return new NullObject();\n }\n const cacheKey: string = createCacheKey(\n { namespace: NAMESPACE, name: 'preProcess', value },\n opt\n );\n const cachedResult = getCache(cacheKey);\n if (cachedResult instanceof CacheItem) {\n if (cachedResult.isNull) {\n return cachedResult as NullObject;\n }\n return cachedResult.item as string;\n }\n let res: string | NullObject = value;\n if (REG_FN_VAR.test(value)) {\n const resolved = resolveVar(value, opt);\n if (isString(resolved)) {\n res = resolved;\n } else {\n setCache(cacheKey, null);\n return new NullObject();\n }\n }\n if (isString(res)) {\n if (REG_FN_REL.test(res)) {\n const resolved = resolveRelativeColor(res, opt);\n if (isString(resolved)) {\n res = resolved;\n } else {\n setCache(cacheKey, null);\n return new NullObject();\n }\n } else if (REG_FN_CALC.test(res)) {\n res = cssCalc(res, opt);\n }\n }\n if (isString(res)) {\n if (res.startsWith('color-mix')) {\n res = resolveColor(res, { ...opt, format: VAL_COMP, nullable: true });\n }\n }\n setCache(cacheKey, res);\n return res;\n};\n\n/**\n * converter factory to reduce boilerplate\n * @param name - function name for cache\n * @param format - color format\n * @param convertFn - conversion function\n * @returns color converter function\n */\nconst createColorConverter = (\n name: string,\n format: string,\n convertFn: Function\n) => {\n const colorConverterFn = (\n value: string,\n opt: Options = {}\n ): ColorChannels => {\n if (!isString(value)) {\n throw new TypeError(`${value} is not a string.`);\n }\n const resolved = preProcess(value, opt);\n if (resolved instanceof NullObject) {\n return [0, 0, 0, 0];\n }\n const val = resolved.toLowerCase();\n const cacheKey = createCacheKey(\n { namespace: NAMESPACE, name, value: val },\n opt\n );\n const cached = getCache(cacheKey);\n if (cached instanceof CacheItem) {\n return cached.item as ColorChannels;\n }\n const result = convertFn(val, { ...opt, format }) as ColorChannels;\n setCache(cacheKey, result);\n return result;\n };\n return colorConverterFn;\n};\n\n/**\n * convert number to hex string\n * @param value - numeric value\n * @returns hex string: 00..ff\n */\nexport const numberToHex = (value: number): string => numberToHexString(value);\n\n/**\n * convert color to hex\n * @param value - CSS color value\n * @param [opt] - options\n * @param [opt.alpha] - enable alpha channel\n * @returns #rrggbb | #rrggbbaa | null\n */\nexport const colorToHex = (value: string, opt: Options = {}): string | null => {\n if (!isString(value)) {\n throw new TypeError(`${value} is not a string.`);\n }\n const resolved = preProcess(value, opt);\n if (resolved instanceof NullObject) {\n return null;\n }\n const val = resolved.toLowerCase();\n const cacheKey = createCacheKey(\n { namespace: NAMESPACE, name: 'colorToHex', value: val },\n opt\n );\n const cached = getCache(cacheKey);\n if (cached instanceof CacheItem) {\n if (cached.isNull) {\n return null;\n }\n return cached.item as string;\n }\n const hex = resolveColor(val, {\n ...opt,\n nullable: true,\n format: opt.alpha ? 'hexAlpha' : 'hex'\n });\n if (isString(hex)) {\n setCache(cacheKey, hex);\n return hex;\n }\n setCache(cacheKey, null);\n return null;\n};\n\n/**\n * convert color to hsl\n * @param value - CSS color value\n * @param [opt] - options\n * @returns ColorChannels - [h, s, l, alpha]\n */\nexport const colorToHsl = createColorConverter(\n 'colorToHsl',\n 'hsl',\n convertColorToHsl\n);\n\n/**\n * convert color to hwb\n * @param value - CSS color value\n * @param [opt] - options\n * @returns ColorChannels - [h, w, b, alpha]\n */\nexport const colorToHwb = createColorConverter(\n 'colorToHwb',\n 'hwb',\n convertColorToHwb\n);\n\n/**\n * convert color to lab\n * @param value - CSS color value\n * @param [opt] - options\n * @returns ColorChannels - [l, a, b, alpha]\n */\nexport const colorToLab = createColorConverter(\n 'colorToLab',\n 'lab',\n convertColorToLab\n);\n\n/**\n * convert color to lch\n * @param value - CSS color value\n * @param [opt] - options\n * @returns ColorChannels - [l, c, h, alpha]\n */\nexport const colorToLch = createColorConverter(\n 'colorToLch',\n 'lch',\n convertColorToLch\n);\n\n/**\n * convert color to oklab\n * @param value - CSS color value\n * @param [opt] - options\n * @returns ColorChannels - [l, a, b, alpha]\n */\nexport const colorToOklab = createColorConverter(\n 'colorToOklab',\n 'oklab',\n convertColorToOklab\n);\n\n/**\n * convert color to oklch\n * @param value - CSS color value\n * @param [opt] - options\n * @returns ColorChannels - [l, c, h, alpha]\n */\nexport const colorToOklch = createColorConverter(\n 'colorToOklch',\n 'oklch',\n convertColorToOklch\n);\n\n/**\n * convert color to rgb\n * @param value - CSS color value\n * @param [opt] - options\n * @returns ColorChannels - [r, g, b, alpha]\n */\nexport const colorToRgb = createColorConverter(\n 'colorToRgb',\n 'rgb',\n convertColorToRgb\n);\n\n/**\n * convert color to xyz\n * @param value - CSS color value\n * @param [opt] - options\n * @returns ColorChannels - [x, y, z, alpha]\n */\nexport const colorToXyz = (value: string, opt: Options = {}): ColorChannels => {\n if (!isString(value)) {\n throw new TypeError(`${value} is not a string.`);\n }\n const resolved = preProcess(value, opt);\n if (resolved instanceof NullObject) {\n return [0, 0, 0, 0];\n }\n const val = resolved.toLowerCase();\n const cacheKey = createCacheKey(\n { namespace: NAMESPACE, name: 'colorToXyz', value: val },\n opt\n );\n const cached = getCache(cacheKey);\n if (cached instanceof CacheItem) {\n return cached.item as ColorChannels;\n }\n let parsed;\n if (val.startsWith('color(')) {\n parsed = parseColorFunc(val, opt);\n } else {\n parsed = parseColorValue(val, opt);\n }\n const [, ...xyz] = parsed as ComputedColorChannels;\n setCache(cacheKey, xyz);\n return xyz as ColorChannels;\n};\n\n/**\n * convert color to xyz-d50\n * @param value - CSS color value\n * @param [opt] - options\n * @returns ColorChannels - [x, y, z, alpha]\n */\nexport const colorToXyzD50 = (\n value: string,\n opt: Options = {}\n): ColorChannels => {\n opt.d50 = true;\n return colorToXyz(value, opt);\n};\n\n/* convert */\nexport const convert = {\n colorToHex,\n colorToHsl,\n colorToHwb,\n colorToLab,\n colorToLch,\n colorToOklab,\n colorToOklch,\n colorToRgb,\n colorToXyz,\n colorToXyzD50,\n numberToHex\n};\n"],"mappings":";;;;;;;;;;;;AAgCA,IAAM,YAAY;AAGlB,IAAM,cAAc,IAAI,OAAO,YAAY;AAC3C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,gBACA,SACA,oBACD;;;;;;;AAQD,IAAa,aAAa,qBACxB,cACA,OACA,kBACD;;;;;;;AAQD,IAAa,cAAc,OAAe,MAAe,EAAE,KAAoB;AAC7E,KAAI,CAAC,SAAS,MAAM,CAClB,OAAM,IAAI,UAAU,GAAG,MAAM,mBAAmB;CAElD,MAAM,WAAW,WAAW,OAAO,IAAI;AACvC,KAAI,oBAAoB,WACtB,QAAO;EAAC;EAAG;EAAG;EAAG;EAAE;CAErB,MAAM,MAAM,SAAS,aAAa;CAClC,MAAM,WAAW,eACf;EAAE,WAAW;EAAW,MAAM;EAAc,OAAO;EAAK,EACxD,IACD;CACD,MAAM,SAAS,SAAS,SAAS;AACjC,KAAI,kBAAkB,UACpB,QAAO,OAAO;CAEhB,IAAI;AACJ,KAAI,IAAI,WAAW,SAAS,CAC1B,UAAS,eAAe,KAAK,IAAI;KAEjC,UAAS,gBAAgB,KAAK,IAAI;CAEpC,MAAM,GAAG,GAAG,OAAO;AACnB,UAAS,UAAU,IAAI;AACvB,QAAO;;;;;;;;AAST,IAAa,iBACX,OACA,MAAe,EAAE,KACC;AAClB,KAAI,MAAM;AACV,QAAO,WAAW,OAAO,IAAI;;AAI/B,IAAa,UAAU;CACrB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD"}
|
|
|
|
|
|
node_modules/@asamuzakjp/css-color/dist/esm/js/css-calc.d.ts
DELETED
|
@@ -1,89 +0,0 @@
|
|
| 1 |
-
import { CSSToken } from '@csstools/css-tokenizer';
|
| 2 |
-
import { NullObject } from './cache.js';
|
| 3 |
-
import { Options } from './typedef.js';
|
| 4 |
-
/**
|
| 5 |
-
* Calclator
|
| 6 |
-
*/
|
| 7 |
-
export declare class Calculator {
|
| 8 |
-
#private;
|
| 9 |
-
/**
|
| 10 |
-
* constructor
|
| 11 |
-
*/
|
| 12 |
-
constructor();
|
| 13 |
-
get hasNum(): boolean;
|
| 14 |
-
set hasNum(value: boolean);
|
| 15 |
-
get numSum(): number[];
|
| 16 |
-
get numMul(): number[];
|
| 17 |
-
get hasPct(): boolean;
|
| 18 |
-
set hasPct(value: boolean);
|
| 19 |
-
get pctSum(): number[];
|
| 20 |
-
get pctMul(): number[];
|
| 21 |
-
get hasDim(): boolean;
|
| 22 |
-
set hasDim(value: boolean);
|
| 23 |
-
get dimSum(): string[];
|
| 24 |
-
get dimSub(): string[];
|
| 25 |
-
get dimMul(): string[];
|
| 26 |
-
get dimDiv(): string[];
|
| 27 |
-
get hasEtc(): boolean;
|
| 28 |
-
set hasEtc(value: boolean);
|
| 29 |
-
get etcSum(): string[];
|
| 30 |
-
get etcSub(): string[];
|
| 31 |
-
get etcMul(): string[];
|
| 32 |
-
get etcDiv(): string[];
|
| 33 |
-
/**
|
| 34 |
-
* clear values
|
| 35 |
-
* @returns void
|
| 36 |
-
*/
|
| 37 |
-
clear(): void;
|
| 38 |
-
/**
|
| 39 |
-
* sort values
|
| 40 |
-
* @param values - values
|
| 41 |
-
* @returns sorted values
|
| 42 |
-
*/
|
| 43 |
-
sort(values?: string[]): string[];
|
| 44 |
-
/**
|
| 45 |
-
* multiply values
|
| 46 |
-
* @returns resolved value
|
| 47 |
-
*/
|
| 48 |
-
multiply(): string;
|
| 49 |
-
/**
|
| 50 |
-
* sum values
|
| 51 |
-
* @returns resolved value
|
| 52 |
-
*/
|
| 53 |
-
sum(): string;
|
| 54 |
-
}
|
| 55 |
-
/**
|
| 56 |
-
* sort calc values
|
| 57 |
-
* @param values - values to sort
|
| 58 |
-
* @param [finalize] - finalize values
|
| 59 |
-
* @returns sorted values
|
| 60 |
-
*/
|
| 61 |
-
export declare const sortCalcValues: (values?: (number | string)[], finalize?: boolean) => string;
|
| 62 |
-
/**
|
| 63 |
-
* serialize calc
|
| 64 |
-
* @param value - CSS value
|
| 65 |
-
* @param [opt] - options
|
| 66 |
-
* @returns serialized value
|
| 67 |
-
*/
|
| 68 |
-
export declare const serializeCalc: (value: string, opt?: Options) => string;
|
| 69 |
-
/**
|
| 70 |
-
* resolve dimension
|
| 71 |
-
* @param token - CSS token
|
| 72 |
-
* @param [opt] - options
|
| 73 |
-
* @returns resolved value
|
| 74 |
-
*/
|
| 75 |
-
export declare const resolveDimension: (token: CSSToken, opt?: Options) => string | NullObject;
|
| 76 |
-
/**
|
| 77 |
-
* parse tokens
|
| 78 |
-
* @param tokens - CSS tokens
|
| 79 |
-
* @param [opt] - options
|
| 80 |
-
* @returns parsed tokens
|
| 81 |
-
*/
|
| 82 |
-
export declare const parseTokens: (tokens: CSSToken[], opt?: Options) => string[];
|
| 83 |
-
/**
|
| 84 |
-
* CSS calc()
|
| 85 |
-
* @param value - CSS value including calc()
|
| 86 |
-
* @param [opt] - options
|
| 87 |
-
* @returns resolved value
|
| 88 |
-
*/
|
| 89 |
-
export declare const cssCalc: (value: string, opt?: Options) => string;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
node_modules/@asamuzakjp/css-color/dist/esm/js/css-calc.js
DELETED
|
@@ -1,636 +0,0 @@
|
|
| 1 |
-
import { CacheItem, NullObject, createCacheKey, getCache, setCache } from "./cache.js";
|
| 2 |
-
import { isString, isStringOrNumber } from "./common.js";
|
| 3 |
-
import { ANGLE, LENGTH, NUM, SYN_FN_CALC, SYN_FN_MATH_START, SYN_FN_VAR, SYN_FN_VAR_START } from "./constant.js";
|
| 4 |
-
import { resolveLengthInPixels, roundToPrecision } from "./util.js";
|
| 5 |
-
import { resolveVar } from "./css-var.js";
|
| 6 |
-
import { calc } from "@csstools/css-calc";
|
| 7 |
-
import { TokenType, tokenize } from "@csstools/css-tokenizer";
|
| 8 |
-
//#region src/js/css-calc.ts
|
| 9 |
-
/**
|
| 10 |
-
* css-calc
|
| 11 |
-
*/
|
| 12 |
-
var { CloseParen: PAREN_CLOSE, Comment: COMMENT, Dimension: DIM, EOF, Function: FUNC, OpenParen: PAREN_OPEN, Whitespace: W_SPACE } = TokenType;
|
| 13 |
-
var NAMESPACE = "css-calc";
|
| 14 |
-
var TRIA = 3;
|
| 15 |
-
var HEX = 16;
|
| 16 |
-
var MAX_PCT = 100;
|
| 17 |
-
var REG_FN_CALC = new RegExp(SYN_FN_CALC);
|
| 18 |
-
var REG_FN_CALC_NUM = new RegExp(`^calc\\((${NUM})\\)$`);
|
| 19 |
-
var REG_FN_MATH_START = new RegExp(SYN_FN_MATH_START);
|
| 20 |
-
var REG_FN_VAR = new RegExp(SYN_FN_VAR);
|
| 21 |
-
var REG_FN_VAR_START = new RegExp(SYN_FN_VAR_START);
|
| 22 |
-
var REG_OPERATOR = /\s[*+/-]\s/;
|
| 23 |
-
var REG_PAREN_OPEN = /\($/;
|
| 24 |
-
var REG_TYPE_DIM = new RegExp(`^(${NUM})(${ANGLE}|${LENGTH})$`);
|
| 25 |
-
var REG_TYPE_DIM_PCT = new RegExp(`^(${NUM})(${ANGLE}|${LENGTH}|%)$`);
|
| 26 |
-
var REG_TYPE_PCT = new RegExp(`^(${NUM})%$`);
|
| 27 |
-
/**
|
| 28 |
-
* Calclator
|
| 29 |
-
*/
|
| 30 |
-
var Calculator = class {
|
| 31 |
-
#hasNum;
|
| 32 |
-
#numSum;
|
| 33 |
-
#numMul;
|
| 34 |
-
#hasPct;
|
| 35 |
-
#pctSum;
|
| 36 |
-
#pctMul;
|
| 37 |
-
#hasDim;
|
| 38 |
-
#dimSum;
|
| 39 |
-
#dimSub;
|
| 40 |
-
#dimMul;
|
| 41 |
-
#dimDiv;
|
| 42 |
-
#hasEtc;
|
| 43 |
-
#etcSum;
|
| 44 |
-
#etcSub;
|
| 45 |
-
#etcMul;
|
| 46 |
-
#etcDiv;
|
| 47 |
-
#calcOpts;
|
| 48 |
-
/**
|
| 49 |
-
* constructor
|
| 50 |
-
*/
|
| 51 |
-
constructor() {
|
| 52 |
-
this.#hasNum = false;
|
| 53 |
-
this.#numSum = [];
|
| 54 |
-
this.#numMul = [];
|
| 55 |
-
this.#hasPct = false;
|
| 56 |
-
this.#pctSum = [];
|
| 57 |
-
this.#pctMul = [];
|
| 58 |
-
this.#hasDim = false;
|
| 59 |
-
this.#dimSum = [];
|
| 60 |
-
this.#dimSub = [];
|
| 61 |
-
this.#dimMul = [];
|
| 62 |
-
this.#dimDiv = [];
|
| 63 |
-
this.#hasEtc = false;
|
| 64 |
-
this.#etcSum = [];
|
| 65 |
-
this.#etcSub = [];
|
| 66 |
-
this.#etcMul = [];
|
| 67 |
-
this.#etcDiv = [];
|
| 68 |
-
this.#calcOpts = { toCanonicalUnits: true };
|
| 69 |
-
}
|
| 70 |
-
get hasNum() {
|
| 71 |
-
return this.#hasNum;
|
| 72 |
-
}
|
| 73 |
-
set hasNum(value) {
|
| 74 |
-
this.#hasNum = !!value;
|
| 75 |
-
}
|
| 76 |
-
get numSum() {
|
| 77 |
-
return this.#numSum;
|
| 78 |
-
}
|
| 79 |
-
get numMul() {
|
| 80 |
-
return this.#numMul;
|
| 81 |
-
}
|
| 82 |
-
get hasPct() {
|
| 83 |
-
return this.#hasPct;
|
| 84 |
-
}
|
| 85 |
-
set hasPct(value) {
|
| 86 |
-
this.#hasPct = !!value;
|
| 87 |
-
}
|
| 88 |
-
get pctSum() {
|
| 89 |
-
return this.#pctSum;
|
| 90 |
-
}
|
| 91 |
-
get pctMul() {
|
| 92 |
-
return this.#pctMul;
|
| 93 |
-
}
|
| 94 |
-
get hasDim() {
|
| 95 |
-
return this.#hasDim;
|
| 96 |
-
}
|
| 97 |
-
set hasDim(value) {
|
| 98 |
-
this.#hasDim = !!value;
|
| 99 |
-
}
|
| 100 |
-
get dimSum() {
|
| 101 |
-
return this.#dimSum;
|
| 102 |
-
}
|
| 103 |
-
get dimSub() {
|
| 104 |
-
return this.#dimSub;
|
| 105 |
-
}
|
| 106 |
-
get dimMul() {
|
| 107 |
-
return this.#dimMul;
|
| 108 |
-
}
|
| 109 |
-
get dimDiv() {
|
| 110 |
-
return this.#dimDiv;
|
| 111 |
-
}
|
| 112 |
-
get hasEtc() {
|
| 113 |
-
return this.#hasEtc;
|
| 114 |
-
}
|
| 115 |
-
set hasEtc(value) {
|
| 116 |
-
this.#hasEtc = !!value;
|
| 117 |
-
}
|
| 118 |
-
get etcSum() {
|
| 119 |
-
return this.#etcSum;
|
| 120 |
-
}
|
| 121 |
-
get etcSub() {
|
| 122 |
-
return this.#etcSub;
|
| 123 |
-
}
|
| 124 |
-
get etcMul() {
|
| 125 |
-
return this.#etcMul;
|
| 126 |
-
}
|
| 127 |
-
get etcDiv() {
|
| 128 |
-
return this.#etcDiv;
|
| 129 |
-
}
|
| 130 |
-
/**
|
| 131 |
-
* clear values
|
| 132 |
-
* @returns void
|
| 133 |
-
*/
|
| 134 |
-
clear() {
|
| 135 |
-
this.#hasNum = false;
|
| 136 |
-
this.#numSum.length = 0;
|
| 137 |
-
this.#numMul.length = 0;
|
| 138 |
-
this.#hasPct = false;
|
| 139 |
-
this.#pctSum.length = 0;
|
| 140 |
-
this.#pctMul.length = 0;
|
| 141 |
-
this.#hasDim = false;
|
| 142 |
-
this.#dimSum.length = 0;
|
| 143 |
-
this.#dimSub.length = 0;
|
| 144 |
-
this.#dimMul.length = 0;
|
| 145 |
-
this.#dimDiv.length = 0;
|
| 146 |
-
this.#hasEtc = false;
|
| 147 |
-
this.#etcSum.length = 0;
|
| 148 |
-
this.#etcSub.length = 0;
|
| 149 |
-
this.#etcMul.length = 0;
|
| 150 |
-
this.#etcDiv.length = 0;
|
| 151 |
-
}
|
| 152 |
-
/**
|
| 153 |
-
* sort values
|
| 154 |
-
* @param values - values
|
| 155 |
-
* @returns sorted values
|
| 156 |
-
*/
|
| 157 |
-
sort(values = []) {
|
| 158 |
-
const arr = [...values];
|
| 159 |
-
if (arr.length > 1) arr.sort((a, b) => {
|
| 160 |
-
let res;
|
| 161 |
-
if (REG_TYPE_DIM_PCT.test(a) && REG_TYPE_DIM_PCT.test(b)) {
|
| 162 |
-
const [, valA, unitA] = a.match(REG_TYPE_DIM_PCT);
|
| 163 |
-
const [, valB, unitB] = b.match(REG_TYPE_DIM_PCT);
|
| 164 |
-
if (unitA === unitB) if (Number(valA) === Number(valB)) res = 0;
|
| 165 |
-
else if (Number(valA) > Number(valB)) res = 1;
|
| 166 |
-
else res = -1;
|
| 167 |
-
else if (unitA > unitB) res = 1;
|
| 168 |
-
else res = -1;
|
| 169 |
-
} else if (a === b) res = 0;
|
| 170 |
-
else if (a > b) res = 1;
|
| 171 |
-
else res = -1;
|
| 172 |
-
return res;
|
| 173 |
-
});
|
| 174 |
-
return arr;
|
| 175 |
-
}
|
| 176 |
-
/**
|
| 177 |
-
* multiply values
|
| 178 |
-
* @returns resolved value
|
| 179 |
-
*/
|
| 180 |
-
multiply() {
|
| 181 |
-
const value = [];
|
| 182 |
-
let num;
|
| 183 |
-
if (this.#hasNum) {
|
| 184 |
-
num = 1;
|
| 185 |
-
for (const i of this.#numMul) {
|
| 186 |
-
num *= i;
|
| 187 |
-
if (num === 0 || !Number.isFinite(num) || Number.isNaN(num)) break;
|
| 188 |
-
}
|
| 189 |
-
if (!this.#hasPct && !this.#hasDim && !this.hasEtc) {
|
| 190 |
-
if (Number.isFinite(num)) num = roundToPrecision(num, HEX);
|
| 191 |
-
value.push(num);
|
| 192 |
-
}
|
| 193 |
-
}
|
| 194 |
-
if (this.#hasPct) {
|
| 195 |
-
if (typeof num !== "number") num = 1;
|
| 196 |
-
for (const i of this.#pctMul) {
|
| 197 |
-
num *= i;
|
| 198 |
-
if (num === 0 || !Number.isFinite(num) || Number.isNaN(num)) break;
|
| 199 |
-
}
|
| 200 |
-
if (Number.isFinite(num)) num = `${roundToPrecision(num, HEX)}%`;
|
| 201 |
-
if (!this.#hasDim && !this.hasEtc) value.push(num);
|
| 202 |
-
}
|
| 203 |
-
if (this.#hasDim) {
|
| 204 |
-
let dim = "";
|
| 205 |
-
let mul = "";
|
| 206 |
-
let div = "";
|
| 207 |
-
if (this.#dimMul.length) if (this.#dimMul.length === 1) [mul] = this.#dimMul;
|
| 208 |
-
else mul = `${this.sort(this.#dimMul).join(" * ")}`;
|
| 209 |
-
if (this.#dimDiv.length) if (this.#dimDiv.length === 1) [div] = this.#dimDiv;
|
| 210 |
-
else div = `${this.sort(this.#dimDiv).join(" * ")}`;
|
| 211 |
-
if (Number.isFinite(num)) {
|
| 212 |
-
if (mul) if (div) if (div.includes("*")) dim = calc(`calc(${num} * ${mul} / (${div}))`, this.#calcOpts);
|
| 213 |
-
else dim = calc(`calc(${num} * ${mul} / ${div})`, this.#calcOpts);
|
| 214 |
-
else dim = calc(`calc(${num} * ${mul})`, this.#calcOpts);
|
| 215 |
-
else if (div.includes("*")) dim = calc(`calc(${num} / (${div}))`, this.#calcOpts);
|
| 216 |
-
else dim = calc(`calc(${num} / ${div})`, this.#calcOpts);
|
| 217 |
-
value.push(dim.replace(/^calc/, ""));
|
| 218 |
-
} else {
|
| 219 |
-
if (!value.length && num !== void 0) value.push(num);
|
| 220 |
-
if (mul) {
|
| 221 |
-
if (div) if (div.includes("*")) dim = calc(`calc(${mul} / (${div}))`, this.#calcOpts);
|
| 222 |
-
else dim = calc(`calc(${mul} / ${div})`, this.#calcOpts);
|
| 223 |
-
else dim = calc(`calc(${mul})`, this.#calcOpts);
|
| 224 |
-
if (value.length) value.push("*", dim.replace(/^calc/, ""));
|
| 225 |
-
else value.push(dim.replace(/^calc/, ""));
|
| 226 |
-
} else {
|
| 227 |
-
dim = calc(`calc(${div})`, this.#calcOpts);
|
| 228 |
-
if (value.length) value.push("/", dim.replace(/^calc/, ""));
|
| 229 |
-
else value.push("1", "/", dim.replace(/^calc/, ""));
|
| 230 |
-
}
|
| 231 |
-
}
|
| 232 |
-
}
|
| 233 |
-
if (this.#hasEtc) {
|
| 234 |
-
if (this.#etcMul.length) {
|
| 235 |
-
if (!value.length && num !== void 0) value.push(num);
|
| 236 |
-
const mul = this.sort(this.#etcMul).join(" * ");
|
| 237 |
-
if (value.length) value.push(`* ${mul}`);
|
| 238 |
-
else value.push(`${mul}`);
|
| 239 |
-
}
|
| 240 |
-
if (this.#etcDiv.length) {
|
| 241 |
-
const div = this.sort(this.#etcDiv).join(" * ");
|
| 242 |
-
if (div.includes("*")) if (value.length) value.push(`/ (${div})`);
|
| 243 |
-
else value.push(`1 / (${div})`);
|
| 244 |
-
else if (value.length) value.push(`/ ${div}`);
|
| 245 |
-
else value.push(`1 / ${div}`);
|
| 246 |
-
}
|
| 247 |
-
}
|
| 248 |
-
if (value.length) return value.join(" ");
|
| 249 |
-
return "";
|
| 250 |
-
}
|
| 251 |
-
/**
|
| 252 |
-
* sum values
|
| 253 |
-
* @returns resolved value
|
| 254 |
-
*/
|
| 255 |
-
sum() {
|
| 256 |
-
const value = [];
|
| 257 |
-
if (this.#hasNum) {
|
| 258 |
-
let num = 0;
|
| 259 |
-
for (const i of this.#numSum) {
|
| 260 |
-
num += i;
|
| 261 |
-
if (!Number.isFinite(num) || Number.isNaN(num)) break;
|
| 262 |
-
}
|
| 263 |
-
value.push(num);
|
| 264 |
-
}
|
| 265 |
-
if (this.#hasPct) {
|
| 266 |
-
let num = 0;
|
| 267 |
-
for (const i of this.#pctSum) {
|
| 268 |
-
num += i;
|
| 269 |
-
if (!Number.isFinite(num)) break;
|
| 270 |
-
}
|
| 271 |
-
if (Number.isFinite(num)) num = `${num}%`;
|
| 272 |
-
if (value.length) value.push(`+ ${num}`);
|
| 273 |
-
else value.push(num);
|
| 274 |
-
}
|
| 275 |
-
if (this.#hasDim) {
|
| 276 |
-
let dim, sum, sub;
|
| 277 |
-
if (this.#dimSum.length) sum = this.sort(this.#dimSum).join(" + ");
|
| 278 |
-
if (this.#dimSub.length) sub = this.sort(this.#dimSub).join(" + ");
|
| 279 |
-
if (sum) if (sub) if (sub.includes("-")) dim = calc(`calc(${sum} - (${sub}))`, this.#calcOpts);
|
| 280 |
-
else dim = calc(`calc(${sum} - ${sub})`, this.#calcOpts);
|
| 281 |
-
else dim = calc(`calc(${sum})`, this.#calcOpts);
|
| 282 |
-
else dim = calc(`calc(-1 * (${sub}))`, this.#calcOpts);
|
| 283 |
-
if (value.length) value.push("+", dim.replace(/^calc/, ""));
|
| 284 |
-
else value.push(dim.replace(/^calc/, ""));
|
| 285 |
-
}
|
| 286 |
-
if (this.#hasEtc) {
|
| 287 |
-
if (this.#etcSum.length) {
|
| 288 |
-
const sum = this.sort(this.#etcSum).map((item) => {
|
| 289 |
-
let res;
|
| 290 |
-
if (REG_OPERATOR.test(item) && !item.startsWith("(") && !item.endsWith(")")) res = `(${item})`;
|
| 291 |
-
else res = item;
|
| 292 |
-
return res;
|
| 293 |
-
}).join(" + ");
|
| 294 |
-
if (value.length) if (this.#etcSum.length > 1) value.push(`+ (${sum})`);
|
| 295 |
-
else value.push(`+ ${sum}`);
|
| 296 |
-
else value.push(`${sum}`);
|
| 297 |
-
}
|
| 298 |
-
if (this.#etcSub.length) {
|
| 299 |
-
const sub = this.sort(this.#etcSub).map((item) => {
|
| 300 |
-
let res;
|
| 301 |
-
if (REG_OPERATOR.test(item) && !item.startsWith("(") && !item.endsWith(")")) res = `(${item})`;
|
| 302 |
-
else res = item;
|
| 303 |
-
return res;
|
| 304 |
-
}).join(" + ");
|
| 305 |
-
if (value.length) if (this.#etcSub.length > 1) value.push(`- (${sub})`);
|
| 306 |
-
else value.push(`- ${sub}`);
|
| 307 |
-
else if (this.#etcSub.length > 1) value.push(`-1 * (${sub})`);
|
| 308 |
-
else value.push(`-1 * ${sub}`);
|
| 309 |
-
}
|
| 310 |
-
}
|
| 311 |
-
if (value.length) return value.join(" ");
|
| 312 |
-
return "";
|
| 313 |
-
}
|
| 314 |
-
};
|
| 315 |
-
/**
|
| 316 |
-
* sort calc values
|
| 317 |
-
* @param values - values to sort
|
| 318 |
-
* @param [finalize] - finalize values
|
| 319 |
-
* @returns sorted values
|
| 320 |
-
*/
|
| 321 |
-
var sortCalcValues = (values = [], finalize = false) => {
|
| 322 |
-
if (values.length < TRIA) throw new Error(`Unexpected array length ${values.length}.`);
|
| 323 |
-
const start = values.shift();
|
| 324 |
-
if (!isString(start) || !start.endsWith("(")) throw new Error(`Unexpected token ${start}.`);
|
| 325 |
-
const end = values.pop();
|
| 326 |
-
if (end !== ")") throw new Error(`Unexpected token ${end}.`);
|
| 327 |
-
if (values.length === 1) {
|
| 328 |
-
const [value] = values;
|
| 329 |
-
if (!isStringOrNumber(value)) throw new Error(`Unexpected token ${value}.`);
|
| 330 |
-
return `${start}${value}${end}`;
|
| 331 |
-
}
|
| 332 |
-
const sortedValues = [];
|
| 333 |
-
const cal = new Calculator();
|
| 334 |
-
let operator = "";
|
| 335 |
-
const l = values.length;
|
| 336 |
-
let hasAddSub = false;
|
| 337 |
-
for (let i = 0; i < l; i++) {
|
| 338 |
-
const value = values[i];
|
| 339 |
-
if (!isStringOrNumber(value)) throw new Error(`Unexpected token ${value}.`);
|
| 340 |
-
if (value === "*" || value === "/") operator = value;
|
| 341 |
-
else if (value === "+" || value === "-") {
|
| 342 |
-
const sortedValue = cal.multiply();
|
| 343 |
-
if (sortedValue) sortedValues.push(sortedValue, value);
|
| 344 |
-
hasAddSub = true;
|
| 345 |
-
cal.clear();
|
| 346 |
-
operator = "";
|
| 347 |
-
} else {
|
| 348 |
-
const numValue = Number(value);
|
| 349 |
-
const strValue = `${value}`;
|
| 350 |
-
switch (operator) {
|
| 351 |
-
case "/":
|
| 352 |
-
if (Number.isFinite(numValue)) {
|
| 353 |
-
cal.hasNum = true;
|
| 354 |
-
cal.numMul.push(1 / numValue);
|
| 355 |
-
} else if (REG_TYPE_PCT.test(strValue)) {
|
| 356 |
-
const [, val] = strValue.match(REG_TYPE_PCT);
|
| 357 |
-
cal.hasPct = true;
|
| 358 |
-
cal.pctMul.push(MAX_PCT * MAX_PCT / Number(val));
|
| 359 |
-
} else if (REG_TYPE_DIM.test(strValue)) {
|
| 360 |
-
cal.hasDim = true;
|
| 361 |
-
cal.dimDiv.push(strValue);
|
| 362 |
-
} else {
|
| 363 |
-
cal.hasEtc = true;
|
| 364 |
-
cal.etcDiv.push(strValue);
|
| 365 |
-
}
|
| 366 |
-
break;
|
| 367 |
-
default: if (Number.isFinite(numValue)) {
|
| 368 |
-
cal.hasNum = true;
|
| 369 |
-
cal.numMul.push(numValue);
|
| 370 |
-
} else if (REG_TYPE_PCT.test(strValue)) {
|
| 371 |
-
const [, val] = strValue.match(REG_TYPE_PCT);
|
| 372 |
-
cal.hasPct = true;
|
| 373 |
-
cal.pctMul.push(Number(val));
|
| 374 |
-
} else if (REG_TYPE_DIM.test(strValue)) {
|
| 375 |
-
cal.hasDim = true;
|
| 376 |
-
cal.dimMul.push(strValue);
|
| 377 |
-
} else {
|
| 378 |
-
cal.hasEtc = true;
|
| 379 |
-
cal.etcMul.push(strValue);
|
| 380 |
-
}
|
| 381 |
-
}
|
| 382 |
-
}
|
| 383 |
-
if (i === l - 1) {
|
| 384 |
-
const sortedValue = cal.multiply();
|
| 385 |
-
if (sortedValue) sortedValues.push(sortedValue);
|
| 386 |
-
cal.clear();
|
| 387 |
-
operator = "";
|
| 388 |
-
}
|
| 389 |
-
}
|
| 390 |
-
let resolvedValue = "";
|
| 391 |
-
if (finalize && hasAddSub) {
|
| 392 |
-
const finalizedValues = [];
|
| 393 |
-
cal.clear();
|
| 394 |
-
operator = "";
|
| 395 |
-
const l = sortedValues.length;
|
| 396 |
-
for (let i = 0; i < l; i++) {
|
| 397 |
-
const value = sortedValues[i];
|
| 398 |
-
if (isStringOrNumber(value)) if (value === "+" || value === "-") operator = value;
|
| 399 |
-
else {
|
| 400 |
-
const numValue = Number(value);
|
| 401 |
-
const strValue = `${value}`;
|
| 402 |
-
switch (operator) {
|
| 403 |
-
case "-":
|
| 404 |
-
if (Number.isFinite(numValue)) {
|
| 405 |
-
cal.hasNum = true;
|
| 406 |
-
cal.numSum.push(-1 * numValue);
|
| 407 |
-
} else if (REG_TYPE_PCT.test(strValue)) {
|
| 408 |
-
const [, val] = strValue.match(REG_TYPE_PCT);
|
| 409 |
-
cal.hasPct = true;
|
| 410 |
-
cal.pctSum.push(-1 * Number(val));
|
| 411 |
-
} else if (REG_TYPE_DIM.test(strValue)) {
|
| 412 |
-
cal.hasDim = true;
|
| 413 |
-
cal.dimSub.push(strValue);
|
| 414 |
-
} else {
|
| 415 |
-
cal.hasEtc = true;
|
| 416 |
-
cal.etcSub.push(strValue);
|
| 417 |
-
}
|
| 418 |
-
break;
|
| 419 |
-
default: if (Number.isFinite(numValue)) {
|
| 420 |
-
cal.hasNum = true;
|
| 421 |
-
cal.numSum.push(numValue);
|
| 422 |
-
} else if (REG_TYPE_PCT.test(strValue)) {
|
| 423 |
-
const [, val] = strValue.match(REG_TYPE_PCT);
|
| 424 |
-
cal.hasPct = true;
|
| 425 |
-
cal.pctSum.push(Number(val));
|
| 426 |
-
} else if (REG_TYPE_DIM.test(strValue)) {
|
| 427 |
-
cal.hasDim = true;
|
| 428 |
-
cal.dimSum.push(strValue);
|
| 429 |
-
} else {
|
| 430 |
-
cal.hasEtc = true;
|
| 431 |
-
cal.etcSum.push(strValue);
|
| 432 |
-
}
|
| 433 |
-
}
|
| 434 |
-
}
|
| 435 |
-
if (i === l - 1) {
|
| 436 |
-
const sortedValue = cal.sum();
|
| 437 |
-
if (sortedValue) finalizedValues.push(sortedValue);
|
| 438 |
-
cal.clear();
|
| 439 |
-
operator = "";
|
| 440 |
-
}
|
| 441 |
-
}
|
| 442 |
-
resolvedValue = finalizedValues.join(" ").replace(/\+\s-/g, "- ");
|
| 443 |
-
} else resolvedValue = sortedValues.join(" ").replace(/\+\s-/g, "- ");
|
| 444 |
-
if (resolvedValue.startsWith("(") && resolvedValue.endsWith(")") && resolvedValue.lastIndexOf("(") === 0 && resolvedValue.indexOf(")") === resolvedValue.length - 1) resolvedValue = resolvedValue.substring(1, resolvedValue.length - 1);
|
| 445 |
-
return `${start}${resolvedValue}${end}`;
|
| 446 |
-
};
|
| 447 |
-
/**
|
| 448 |
-
* resolve AST node
|
| 449 |
-
* @param node - AST node
|
| 450 |
-
* @param isRoot - is root node
|
| 451 |
-
* @returns resolved value
|
| 452 |
-
*/
|
| 453 |
-
var resolveNode = (node, isRoot) => {
|
| 454 |
-
const flatItems = [];
|
| 455 |
-
for (const item of node) if (Array.isArray(item)) flatItems.push(resolveNode(item, false));
|
| 456 |
-
else flatItems.push(item);
|
| 457 |
-
if (isRoot) {
|
| 458 |
-
if (flatItems.length >= TRIA) return sortCalcValues(flatItems, true);
|
| 459 |
-
const joined = flatItems.join("");
|
| 460 |
-
return joined.startsWith("calc(") ? joined : `calc(${joined})`;
|
| 461 |
-
}
|
| 462 |
-
if (flatItems.length >= TRIA) {
|
| 463 |
-
let serialized = sortCalcValues(flatItems, false);
|
| 464 |
-
if (REG_FN_VAR_START.test(serialized)) serialized = calc(serialized, { toCanonicalUnits: true });
|
| 465 |
-
return serialized;
|
| 466 |
-
}
|
| 467 |
-
return flatItems.join("");
|
| 468 |
-
};
|
| 469 |
-
/**
|
| 470 |
-
* serialize calc
|
| 471 |
-
* @param value - CSS value
|
| 472 |
-
* @param [opt] - options
|
| 473 |
-
* @returns serialized value
|
| 474 |
-
*/
|
| 475 |
-
var serializeCalc = (value, opt = {}) => {
|
| 476 |
-
const { format = "" } = opt;
|
| 477 |
-
if (isString(value)) {
|
| 478 |
-
if (!REG_FN_VAR_START.test(value) || format !== "specifiedValue") return value;
|
| 479 |
-
value = value.toLowerCase().trim();
|
| 480 |
-
} else throw new TypeError(`${value} is not a string.`);
|
| 481 |
-
const cacheKey = createCacheKey({
|
| 482 |
-
namespace: NAMESPACE,
|
| 483 |
-
name: "serializeCalc",
|
| 484 |
-
value
|
| 485 |
-
}, opt);
|
| 486 |
-
const cachedResult = getCache(cacheKey);
|
| 487 |
-
if (cachedResult instanceof CacheItem) return cachedResult.item;
|
| 488 |
-
const items = tokenize({ css: value }).map((token) => {
|
| 489 |
-
const [type, val] = token;
|
| 490 |
-
let res = "";
|
| 491 |
-
if (type !== W_SPACE && type !== COMMENT) res = val;
|
| 492 |
-
return res;
|
| 493 |
-
}).filter((v) => v);
|
| 494 |
-
const stack = [[]];
|
| 495 |
-
for (const item of items) if (REG_PAREN_OPEN.test(item)) {
|
| 496 |
-
const newNode = [item];
|
| 497 |
-
const parent = stack[stack.length - 1];
|
| 498 |
-
if (parent) parent.push(newNode);
|
| 499 |
-
stack.push(newNode);
|
| 500 |
-
} else if (item === ")") if (stack.length > 1) {
|
| 501 |
-
const currentLevel = stack.pop();
|
| 502 |
-
if (currentLevel) currentLevel.push(item);
|
| 503 |
-
} else {
|
| 504 |
-
const root = stack[0];
|
| 505 |
-
if (root) root.push(item);
|
| 506 |
-
}
|
| 507 |
-
else {
|
| 508 |
-
const parent = stack[stack.length - 1];
|
| 509 |
-
if (parent) parent.push(item);
|
| 510 |
-
}
|
| 511 |
-
let serializedCalc = "";
|
| 512 |
-
const rootItems = stack[0];
|
| 513 |
-
if (rootItems) if (rootItems.length === 1 && Array.isArray(rootItems[0])) serializedCalc = resolveNode(rootItems[0], true);
|
| 514 |
-
else {
|
| 515 |
-
const flatItems = [];
|
| 516 |
-
for (const item of rootItems) if (Array.isArray(item)) flatItems.push(resolveNode(item, false));
|
| 517 |
-
else flatItems.push(item);
|
| 518 |
-
if (flatItems.length >= TRIA) serializedCalc = sortCalcValues(flatItems, true);
|
| 519 |
-
else {
|
| 520 |
-
const firstItem = flatItems[0] || "";
|
| 521 |
-
serializedCalc = isString(firstItem) && firstItem.startsWith("calc(") ? firstItem : `calc(${firstItem})`;
|
| 522 |
-
}
|
| 523 |
-
}
|
| 524 |
-
setCache(cacheKey, serializedCalc);
|
| 525 |
-
return serializedCalc;
|
| 526 |
-
};
|
| 527 |
-
/**
|
| 528 |
-
* resolve dimension
|
| 529 |
-
* @param token - CSS token
|
| 530 |
-
* @param [opt] - options
|
| 531 |
-
* @returns resolved value
|
| 532 |
-
*/
|
| 533 |
-
var resolveDimension = (token, opt = {}) => {
|
| 534 |
-
if (!Array.isArray(token)) throw new TypeError(`${token} is not an array.`);
|
| 535 |
-
const [, , , , detail = {}] = token;
|
| 536 |
-
const { unit, value } = detail;
|
| 537 |
-
if (unit === "px") return `${value}${unit}`;
|
| 538 |
-
const pixelValue = resolveLengthInPixels(Number(value), unit, opt);
|
| 539 |
-
if (Number.isFinite(pixelValue)) return `${roundToPrecision(pixelValue, HEX)}px`;
|
| 540 |
-
return new NullObject();
|
| 541 |
-
};
|
| 542 |
-
/**
|
| 543 |
-
* parse tokens
|
| 544 |
-
* @param tokens - CSS tokens
|
| 545 |
-
* @param [opt] - options
|
| 546 |
-
* @returns parsed tokens
|
| 547 |
-
*/
|
| 548 |
-
var parseTokens = (tokens, opt = {}) => {
|
| 549 |
-
if (!Array.isArray(tokens)) throw new TypeError(`${tokens} is not an array.`);
|
| 550 |
-
const { format = "" } = opt;
|
| 551 |
-
const mathFunc = /* @__PURE__ */ new Set();
|
| 552 |
-
let nest = 0;
|
| 553 |
-
const res = [];
|
| 554 |
-
for (const token of tokens) {
|
| 555 |
-
if (!Array.isArray(token)) throw new TypeError(`${token} is not an array.`);
|
| 556 |
-
const [type = "", value = ""] = token;
|
| 557 |
-
switch (type) {
|
| 558 |
-
case DIM:
|
| 559 |
-
if (format === "specifiedValue" && !mathFunc.has(nest)) res.push(value);
|
| 560 |
-
else {
|
| 561 |
-
const resolvedValue = resolveDimension(token, opt);
|
| 562 |
-
if (isString(resolvedValue)) res.push(resolvedValue);
|
| 563 |
-
else res.push(value);
|
| 564 |
-
}
|
| 565 |
-
break;
|
| 566 |
-
case FUNC:
|
| 567 |
-
case PAREN_OPEN:
|
| 568 |
-
res.push(value);
|
| 569 |
-
nest++;
|
| 570 |
-
if (REG_FN_MATH_START.test(value)) mathFunc.add(nest);
|
| 571 |
-
break;
|
| 572 |
-
case PAREN_CLOSE:
|
| 573 |
-
if (res.length) if (res[res.length - 1] === " ") res.splice(-1, 1, value);
|
| 574 |
-
else res.push(value);
|
| 575 |
-
else res.push(value);
|
| 576 |
-
if (mathFunc.has(nest)) mathFunc.delete(nest);
|
| 577 |
-
nest--;
|
| 578 |
-
break;
|
| 579 |
-
case W_SPACE:
|
| 580 |
-
if (res.length) {
|
| 581 |
-
const lastValue = res[res.length - 1];
|
| 582 |
-
if (isString(lastValue) && !lastValue.endsWith("(") && lastValue !== " ") res.push(value);
|
| 583 |
-
}
|
| 584 |
-
break;
|
| 585 |
-
default: if (type !== COMMENT && type !== EOF) res.push(value);
|
| 586 |
-
}
|
| 587 |
-
}
|
| 588 |
-
return res;
|
| 589 |
-
};
|
| 590 |
-
/**
|
| 591 |
-
* CSS calc()
|
| 592 |
-
* @param value - CSS value including calc()
|
| 593 |
-
* @param [opt] - options
|
| 594 |
-
* @returns resolved value
|
| 595 |
-
*/
|
| 596 |
-
var cssCalc = (value, opt = {}) => {
|
| 597 |
-
const { format = "" } = opt;
|
| 598 |
-
if (isString(value)) {
|
| 599 |
-
if (REG_FN_VAR.test(value)) if (format === "specifiedValue") return value;
|
| 600 |
-
else {
|
| 601 |
-
const resolvedValue = resolveVar(value, opt);
|
| 602 |
-
if (isString(resolvedValue)) return resolvedValue;
|
| 603 |
-
else return "";
|
| 604 |
-
}
|
| 605 |
-
else if (!REG_FN_CALC.test(value)) return value;
|
| 606 |
-
value = value.toLowerCase().trim();
|
| 607 |
-
} else throw new TypeError(`${value} is not a string.`);
|
| 608 |
-
const cacheKey = createCacheKey({
|
| 609 |
-
namespace: NAMESPACE,
|
| 610 |
-
name: "cssCalc",
|
| 611 |
-
value
|
| 612 |
-
}, opt);
|
| 613 |
-
const cachedResult = getCache(cacheKey);
|
| 614 |
-
if (cachedResult instanceof CacheItem) return cachedResult.item;
|
| 615 |
-
let resolvedValue = calc(parseTokens(tokenize({ css: value }), opt).join(""), { toCanonicalUnits: true });
|
| 616 |
-
if (REG_FN_VAR_START.test(value)) {
|
| 617 |
-
if (REG_TYPE_DIM_PCT.test(resolvedValue)) {
|
| 618 |
-
const [, val, unit] = resolvedValue.match(REG_TYPE_DIM_PCT);
|
| 619 |
-
resolvedValue = `${roundToPrecision(Number(val), HEX)}${unit}`;
|
| 620 |
-
}
|
| 621 |
-
if (resolvedValue && !REG_FN_VAR_START.test(resolvedValue) && format === "specifiedValue") resolvedValue = `calc(${resolvedValue})`;
|
| 622 |
-
}
|
| 623 |
-
if (format === "specifiedValue") {
|
| 624 |
-
if (/\s[-+*/]\s/.test(resolvedValue) && !resolvedValue.includes("NaN")) resolvedValue = serializeCalc(resolvedValue, opt);
|
| 625 |
-
else if (REG_FN_CALC_NUM.test(resolvedValue)) {
|
| 626 |
-
const [, val] = resolvedValue.match(REG_FN_CALC_NUM);
|
| 627 |
-
resolvedValue = `calc(${roundToPrecision(Number(val), HEX)})`;
|
| 628 |
-
}
|
| 629 |
-
}
|
| 630 |
-
setCache(cacheKey, resolvedValue);
|
| 631 |
-
return resolvedValue;
|
| 632 |
-
};
|
| 633 |
-
//#endregion
|
| 634 |
-
export { cssCalc, resolveDimension, serializeCalc };
|
| 635 |
-
|
| 636 |
-
//# sourceMappingURL=css-calc.js.map
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
node_modules/@asamuzakjp/css-color/dist/esm/js/css-calc.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
{"version":3,"file":"css-calc.js","names":["#hasNum","#numSum","#numMul","#hasPct","#pctSum","#pctMul","#hasDim","#dimSum","#dimSub","#dimMul","#dimDiv","#hasEtc","#etcSum","#etcSub","#etcMul","#etcDiv","#calcOpts"],"sources":["../../../src/js/css-calc.ts"],"sourcesContent":["/**\n * css-calc\n */\n\nimport { calc, conversionOptions as CalcOptions } from '@csstools/css-calc';\nimport { CSSToken, TokenType, tokenize } from '@csstools/css-tokenizer';\nimport {\n CacheItem,\n NullObject,\n createCacheKey,\n getCache,\n setCache\n} from './cache';\nimport { isString, isStringOrNumber } from './common';\nimport { resolveVar } from './css-var';\nimport { resolveLengthInPixels, roundToPrecision } from './util';\nimport { MatchedRegExp, Options } from './typedef';\n\n/* constants */\nimport {\n ANGLE,\n LENGTH,\n NUM,\n SYN_FN_CALC,\n SYN_FN_MATH_START,\n SYN_FN_VAR,\n SYN_FN_VAR_START,\n VAL_SPEC\n} from './constant';\nconst {\n CloseParen: PAREN_CLOSE,\n Comment: COMMENT,\n Dimension: DIM,\n EOF,\n Function: FUNC,\n OpenParen: PAREN_OPEN,\n Whitespace: W_SPACE\n} = TokenType;\nconst NAMESPACE = 'css-calc';\n\n/* numeric constants */\nconst TRIA = 3;\nconst HEX = 16;\nconst MAX_PCT = 100;\n\n/* regexp */\nconst REG_FN_CALC = new RegExp(SYN_FN_CALC);\nconst REG_FN_CALC_NUM = new RegExp(`^calc\\\\((${NUM})\\\\)$`);\nconst REG_FN_MATH_START = new RegExp(SYN_FN_MATH_START);\nconst REG_FN_VAR = new RegExp(SYN_FN_VAR);\nconst REG_FN_VAR_START = new RegExp(SYN_FN_VAR_START);\nconst REG_OPERATOR = /\\s[*+/-]\\s/;\nconst REG_PAREN_OPEN = /\\($/;\nconst REG_TYPE_DIM = new RegExp(`^(${NUM})(${ANGLE}|${LENGTH})$`);\nconst REG_TYPE_DIM_PCT = new RegExp(`^(${NUM})(${ANGLE}|${LENGTH}|%)$`);\nconst REG_TYPE_PCT = new RegExp(`^(${NUM})%$`);\n\n/**\n * Calclator\n */\nexport class Calculator {\n /* private */\n // number\n #hasNum: boolean;\n #numSum: number[];\n #numMul: number[];\n // percentage\n #hasPct: boolean;\n #pctSum: number[];\n #pctMul: number[];\n // dimension\n #hasDim: boolean;\n #dimSum: string[];\n #dimSub: string[];\n #dimMul: string[];\n #dimDiv: string[];\n // et cetra\n #hasEtc: boolean;\n #etcSum: string[];\n #etcSub: string[];\n #etcMul: string[];\n #etcDiv: string[];\n // calc options\n #calcOpts: CalcOptions;\n\n /**\n * constructor\n */\n constructor() {\n // number\n this.#hasNum = false;\n this.#numSum = [];\n this.#numMul = [];\n // percentage\n this.#hasPct = false;\n this.#pctSum = [];\n this.#pctMul = [];\n // dimension\n this.#hasDim = false;\n this.#dimSum = [];\n this.#dimSub = [];\n this.#dimMul = [];\n this.#dimDiv = [];\n // et cetra\n this.#hasEtc = false;\n this.#etcSum = [];\n this.#etcSub = [];\n this.#etcMul = [];\n this.#etcDiv = [];\n // calc options\n this.#calcOpts = {\n toCanonicalUnits: true\n };\n }\n\n get hasNum() {\n return this.#hasNum;\n }\n\n set hasNum(value: boolean) {\n this.#hasNum = !!value;\n }\n\n get numSum() {\n return this.#numSum;\n }\n\n get numMul() {\n return this.#numMul;\n }\n\n get hasPct() {\n return this.#hasPct;\n }\n\n set hasPct(value: boolean) {\n this.#hasPct = !!value;\n }\n\n get pctSum() {\n return this.#pctSum;\n }\n\n get pctMul() {\n return this.#pctMul;\n }\n\n get hasDim() {\n return this.#hasDim;\n }\n\n set hasDim(value: boolean) {\n this.#hasDim = !!value;\n }\n\n get dimSum() {\n return this.#dimSum;\n }\n\n get dimSub() {\n return this.#dimSub;\n }\n\n get dimMul() {\n return this.#dimMul;\n }\n\n get dimDiv() {\n return this.#dimDiv;\n }\n\n get hasEtc() {\n return this.#hasEtc;\n }\n\n set hasEtc(value: boolean) {\n this.#hasEtc = !!value;\n }\n\n get etcSum() {\n return this.#etcSum;\n }\n\n get etcSub() {\n return this.#etcSub;\n }\n\n get etcMul() {\n return this.#etcMul;\n }\n\n get etcDiv() {\n return this.#etcDiv;\n }\n\n /**\n * clear values\n * @returns void\n */\n clear() {\n // number\n this.#hasNum = false;\n this.#numSum.length = 0;\n this.#numMul.length = 0;\n // percentage\n this.#hasPct = false;\n this.#pctSum.length = 0;\n this.#pctMul.length = 0;\n // dimension\n this.#hasDim = false;\n this.#dimSum.length = 0;\n this.#dimSub.length = 0;\n this.#dimMul.length = 0;\n this.#dimDiv.length = 0;\n // et cetra\n this.#hasEtc = false;\n this.#etcSum.length = 0;\n this.#etcSub.length = 0;\n this.#etcMul.length = 0;\n this.#etcDiv.length = 0;\n }\n\n /**\n * sort values\n * @param values - values\n * @returns sorted values\n */\n sort(values: string[] = []): string[] {\n const arr = [...values];\n if (arr.length > 1) {\n arr.sort((a, b) => {\n let res;\n if (REG_TYPE_DIM_PCT.test(a) && REG_TYPE_DIM_PCT.test(b)) {\n const [, valA, unitA] = a.match(REG_TYPE_DIM_PCT) as MatchedRegExp;\n const [, valB, unitB] = b.match(REG_TYPE_DIM_PCT) as MatchedRegExp;\n if (unitA === unitB) {\n if (Number(valA) === Number(valB)) {\n res = 0;\n } else if (Number(valA) > Number(valB)) {\n res = 1;\n } else {\n res = -1;\n }\n } else if (unitA > unitB) {\n res = 1;\n } else {\n res = -1;\n }\n } else {\n if (a === b) {\n res = 0;\n } else if (a > b) {\n res = 1;\n } else {\n res = -1;\n }\n }\n return res;\n });\n }\n return arr;\n }\n\n /**\n * multiply values\n * @returns resolved value\n */\n multiply(): string {\n const value = [];\n let num;\n if (this.#hasNum) {\n num = 1;\n for (const i of this.#numMul) {\n num *= i;\n if (num === 0 || !Number.isFinite(num) || Number.isNaN(num)) {\n break;\n }\n }\n if (!this.#hasPct && !this.#hasDim && !this.hasEtc) {\n if (Number.isFinite(num)) {\n num = roundToPrecision(num, HEX);\n }\n value.push(num);\n }\n }\n if (this.#hasPct) {\n if (typeof num !== 'number') {\n num = 1;\n }\n for (const i of this.#pctMul) {\n num *= i;\n if (num === 0 || !Number.isFinite(num) || Number.isNaN(num)) {\n break;\n }\n }\n if (Number.isFinite(num)) {\n num = `${roundToPrecision(num, HEX)}%`;\n }\n if (!this.#hasDim && !this.hasEtc) {\n value.push(num);\n }\n }\n if (this.#hasDim) {\n let dim = '';\n let mul = '';\n let div = '';\n if (this.#dimMul.length) {\n if (this.#dimMul.length === 1) {\n [mul] = this.#dimMul as [string];\n } else {\n mul = `${this.sort(this.#dimMul).join(' * ')}`;\n }\n }\n if (this.#dimDiv.length) {\n if (this.#dimDiv.length === 1) {\n [div] = this.#dimDiv as [string];\n } else {\n div = `${this.sort(this.#dimDiv).join(' * ')}`;\n }\n }\n if (Number.isFinite(num)) {\n if (mul) {\n if (div) {\n if (div.includes('*')) {\n dim = calc(`calc(${num} * ${mul} / (${div}))`, this.#calcOpts);\n } else {\n dim = calc(`calc(${num} * ${mul} / ${div})`, this.#calcOpts);\n }\n } else {\n dim = calc(`calc(${num} * ${mul})`, this.#calcOpts);\n }\n } else if (div.includes('*')) {\n dim = calc(`calc(${num} / (${div}))`, this.#calcOpts);\n } else {\n dim = calc(`calc(${num} / ${div})`, this.#calcOpts);\n }\n value.push(dim.replace(/^calc/, ''));\n } else {\n if (!value.length && num !== undefined) {\n value.push(num);\n }\n if (mul) {\n if (div) {\n if (div.includes('*')) {\n dim = calc(`calc(${mul} / (${div}))`, this.#calcOpts);\n } else {\n dim = calc(`calc(${mul} / ${div})`, this.#calcOpts);\n }\n } else {\n dim = calc(`calc(${mul})`, this.#calcOpts);\n }\n if (value.length) {\n value.push('*', dim.replace(/^calc/, ''));\n } else {\n value.push(dim.replace(/^calc/, ''));\n }\n } else {\n dim = calc(`calc(${div})`, this.#calcOpts);\n if (value.length) {\n value.push('/', dim.replace(/^calc/, ''));\n } else {\n value.push('1', '/', dim.replace(/^calc/, ''));\n }\n }\n }\n }\n if (this.#hasEtc) {\n if (this.#etcMul.length) {\n if (!value.length && num !== undefined) {\n value.push(num);\n }\n const mul = this.sort(this.#etcMul).join(' * ');\n if (value.length) {\n value.push(`* ${mul}`);\n } else {\n value.push(`${mul}`);\n }\n }\n if (this.#etcDiv.length) {\n const div = this.sort(this.#etcDiv).join(' * ');\n if (div.includes('*')) {\n if (value.length) {\n value.push(`/ (${div})`);\n } else {\n value.push(`1 / (${div})`);\n }\n } else if (value.length) {\n value.push(`/ ${div}`);\n } else {\n value.push(`1 / ${div}`);\n }\n }\n }\n if (value.length) {\n return value.join(' ');\n }\n return '';\n }\n\n /**\n * sum values\n * @returns resolved value\n */\n sum(): string {\n const value = [];\n if (this.#hasNum) {\n let num = 0;\n for (const i of this.#numSum) {\n num += i;\n if (!Number.isFinite(num) || Number.isNaN(num)) {\n break;\n }\n }\n value.push(num);\n }\n if (this.#hasPct) {\n let num: number | string = 0;\n for (const i of this.#pctSum) {\n num += i;\n if (!Number.isFinite(num)) {\n break;\n }\n }\n if (Number.isFinite(num)) {\n num = `${num}%`;\n }\n if (value.length) {\n value.push(`+ ${num}`);\n } else {\n value.push(num);\n }\n }\n if (this.#hasDim) {\n let dim, sum, sub;\n if (this.#dimSum.length) {\n sum = this.sort(this.#dimSum).join(' + ');\n }\n if (this.#dimSub.length) {\n sub = this.sort(this.#dimSub).join(' + ');\n }\n if (sum) {\n if (sub) {\n if (sub.includes('-')) {\n dim = calc(`calc(${sum} - (${sub}))`, this.#calcOpts);\n } else {\n dim = calc(`calc(${sum} - ${sub})`, this.#calcOpts);\n }\n } else {\n dim = calc(`calc(${sum})`, this.#calcOpts);\n }\n } else {\n dim = calc(`calc(-1 * (${sub}))`, this.#calcOpts);\n }\n if (value.length) {\n value.push('+', dim.replace(/^calc/, ''));\n } else {\n value.push(dim.replace(/^calc/, ''));\n }\n }\n if (this.#hasEtc) {\n if (this.#etcSum.length) {\n const sum = this.sort(this.#etcSum)\n .map(item => {\n let res;\n if (\n REG_OPERATOR.test(item) &&\n !item.startsWith('(') &&\n !item.endsWith(')')\n ) {\n res = `(${item})`;\n } else {\n res = item;\n }\n return res;\n })\n .join(' + ');\n if (value.length) {\n if (this.#etcSum.length > 1) {\n value.push(`+ (${sum})`);\n } else {\n value.push(`+ ${sum}`);\n }\n } else {\n value.push(`${sum}`);\n }\n }\n if (this.#etcSub.length) {\n const sub = this.sort(this.#etcSub)\n .map(item => {\n let res;\n if (\n REG_OPERATOR.test(item) &&\n !item.startsWith('(') &&\n !item.endsWith(')')\n ) {\n res = `(${item})`;\n } else {\n res = item;\n }\n return res;\n })\n .join(' + ');\n if (value.length) {\n if (this.#etcSub.length > 1) {\n value.push(`- (${sub})`);\n } else {\n value.push(`- ${sub}`);\n }\n } else if (this.#etcSub.length > 1) {\n value.push(`-1 * (${sub})`);\n } else {\n value.push(`-1 * ${sub}`);\n }\n }\n }\n if (value.length) {\n return value.join(' ');\n }\n return '';\n }\n}\n\n/**\n * sort calc values\n * @param values - values to sort\n * @param [finalize] - finalize values\n * @returns sorted values\n */\nexport const sortCalcValues = (\n values: (number | string)[] = [],\n finalize: boolean = false\n): string => {\n if (values.length < TRIA) {\n throw new Error(`Unexpected array length ${values.length}.`);\n }\n const start = values.shift();\n if (!isString(start) || !start.endsWith('(')) {\n throw new Error(`Unexpected token ${start}.`);\n }\n const end = values.pop();\n if (end !== ')') {\n throw new Error(`Unexpected token ${end}.`);\n }\n if (values.length === 1) {\n const [value] = values;\n if (!isStringOrNumber(value)) {\n throw new Error(`Unexpected token ${value}.`);\n }\n return `${start}${value}${end}`;\n }\n const sortedValues = [];\n const cal = new Calculator();\n let operator: string = '';\n const l = values.length;\n // Array traversal optimization for operator check\n let hasAddSub = false;\n for (let i = 0; i < l; i++) {\n const value = values[i];\n if (!isStringOrNumber(value)) {\n throw new Error(`Unexpected token ${value}.`);\n }\n if (value === '*' || value === '/') {\n operator = value;\n } else if (value === '+' || value === '-') {\n const sortedValue = cal.multiply();\n if (sortedValue) {\n sortedValues.push(sortedValue, value);\n }\n // Mark presence of + or -\n hasAddSub = true;\n cal.clear();\n operator = '';\n } else {\n const numValue = Number(value);\n const strValue = `${value}`;\n switch (operator) {\n case '/': {\n if (Number.isFinite(numValue)) {\n cal.hasNum = true;\n cal.numMul.push(1 / numValue);\n } else if (REG_TYPE_PCT.test(strValue)) {\n const [, val] = strValue.match(REG_TYPE_PCT) as MatchedRegExp;\n cal.hasPct = true;\n cal.pctMul.push((MAX_PCT * MAX_PCT) / Number(val));\n } else if (REG_TYPE_DIM.test(strValue)) {\n cal.hasDim = true;\n cal.dimDiv.push(strValue);\n } else {\n cal.hasEtc = true;\n cal.etcDiv.push(strValue);\n }\n break;\n }\n case '*':\n default: {\n if (Number.isFinite(numValue)) {\n cal.hasNum = true;\n cal.numMul.push(numValue);\n } else if (REG_TYPE_PCT.test(strValue)) {\n const [, val] = strValue.match(REG_TYPE_PCT) as MatchedRegExp;\n cal.hasPct = true;\n cal.pctMul.push(Number(val));\n } else if (REG_TYPE_DIM.test(strValue)) {\n cal.hasDim = true;\n cal.dimMul.push(strValue);\n } else {\n cal.hasEtc = true;\n cal.etcMul.push(strValue);\n }\n }\n }\n }\n if (i === l - 1) {\n const sortedValue = cal.multiply();\n if (sortedValue) {\n sortedValues.push(sortedValue);\n }\n cal.clear();\n operator = '';\n }\n }\n let resolvedValue = '';\n if (finalize && hasAddSub) {\n const finalizedValues = [];\n cal.clear();\n operator = '';\n const l = sortedValues.length;\n for (let i = 0; i < l; i++) {\n const value = sortedValues[i];\n if (isStringOrNumber(value)) {\n if (value === '+' || value === '-') {\n operator = value;\n } else {\n const numValue = Number(value);\n const strValue = `${value}`;\n switch (operator) {\n case '-': {\n if (Number.isFinite(numValue)) {\n cal.hasNum = true;\n cal.numSum.push(-1 * numValue);\n } else if (REG_TYPE_PCT.test(strValue)) {\n const [, val] = strValue.match(REG_TYPE_PCT) as MatchedRegExp;\n cal.hasPct = true;\n cal.pctSum.push(-1 * Number(val));\n } else if (REG_TYPE_DIM.test(strValue)) {\n cal.hasDim = true;\n cal.dimSub.push(strValue);\n } else {\n cal.hasEtc = true;\n cal.etcSub.push(strValue);\n }\n break;\n }\n case '+':\n default: {\n if (Number.isFinite(numValue)) {\n cal.hasNum = true;\n cal.numSum.push(numValue);\n } else if (REG_TYPE_PCT.test(strValue)) {\n const [, val] = strValue.match(REG_TYPE_PCT) as MatchedRegExp;\n cal.hasPct = true;\n cal.pctSum.push(Number(val));\n } else if (REG_TYPE_DIM.test(strValue)) {\n cal.hasDim = true;\n cal.dimSum.push(strValue);\n } else {\n cal.hasEtc = true;\n cal.etcSum.push(strValue);\n }\n }\n }\n }\n }\n if (i === l - 1) {\n const sortedValue = cal.sum();\n if (sortedValue) {\n finalizedValues.push(sortedValue);\n }\n cal.clear();\n operator = '';\n }\n }\n resolvedValue = finalizedValues.join(' ').replace(/\\+\\s-/g, '- ');\n } else {\n resolvedValue = sortedValues.join(' ').replace(/\\+\\s-/g, '- ');\n }\n if (\n resolvedValue.startsWith('(') &&\n resolvedValue.endsWith(')') &&\n resolvedValue.lastIndexOf('(') === 0 &&\n resolvedValue.indexOf(')') === resolvedValue.length - 1\n ) {\n resolvedValue = resolvedValue.substring(1, resolvedValue.length - 1);\n }\n return `${start}${resolvedValue}${end}`;\n};\n\n/**\n * resolve AST node\n * @param node - AST node\n * @param isRoot - is root node\n * @returns resolved value\n */\nconst resolveNode = (node: any[], isRoot: boolean): string => {\n const flatItems: string[] = [];\n for (const item of node) {\n if (Array.isArray(item)) {\n flatItems.push(resolveNode(item, false));\n } else {\n flatItems.push(item as string);\n }\n }\n if (isRoot) {\n if (flatItems.length >= TRIA) {\n return sortCalcValues(flatItems, true);\n }\n const joined = flatItems.join('');\n return joined.startsWith('calc(') ? joined : `calc(${joined})`;\n }\n if (flatItems.length >= TRIA) {\n let serialized = sortCalcValues(flatItems, false);\n if (REG_FN_VAR_START.test(serialized)) {\n serialized = calc(serialized, { toCanonicalUnits: true });\n }\n return serialized;\n }\n return flatItems.join('');\n};\n\n/**\n * serialize calc\n * @param value - CSS value\n * @param [opt] - options\n * @returns serialized value\n */\nexport const serializeCalc = (value: string, opt: Options = {}): string => {\n const { format = '' } = opt;\n if (isString(value)) {\n if (!REG_FN_VAR_START.test(value) || format !== VAL_SPEC) {\n return value;\n }\n value = value.toLowerCase().trim();\n } else {\n throw new TypeError(`${value} is not a string.`);\n }\n const cacheKey: string = createCacheKey(\n {\n namespace: NAMESPACE,\n name: 'serializeCalc',\n value\n },\n opt\n );\n const cachedResult = getCache(cacheKey);\n if (cachedResult instanceof CacheItem) {\n return cachedResult.item as string;\n }\n const items: string[] = tokenize({ css: value })\n .map((token: CSSToken): string => {\n const [type, val] = token as [TokenType, string];\n let res = '';\n if (type !== W_SPACE && type !== COMMENT) {\n res = val;\n }\n return res;\n })\n .filter(v => v);\n const stack: any[][] = [[]];\n for (const item of items) {\n if (REG_PAREN_OPEN.test(item)) {\n const newNode = [item];\n const parent = stack[stack.length - 1];\n if (parent) {\n parent.push(newNode);\n }\n stack.push(newNode);\n } else if (item === ')') {\n if (stack.length > 1) {\n const currentLevel = stack.pop();\n if (currentLevel) {\n currentLevel.push(item);\n }\n } else {\n const root = stack[0];\n if (root) {\n root.push(item);\n }\n }\n } else {\n const parent = stack[stack.length - 1];\n if (parent) {\n parent.push(item);\n }\n }\n }\n let serializedCalc = '';\n const rootItems = stack[0];\n if (rootItems) {\n if (rootItems.length === 1 && Array.isArray(rootItems[0])) {\n serializedCalc = resolveNode(rootItems[0], true);\n } else {\n const flatItems: string[] = [];\n for (const item of rootItems) {\n if (Array.isArray(item)) {\n flatItems.push(resolveNode(item, false));\n } else {\n flatItems.push(item as string);\n }\n }\n if (flatItems.length >= TRIA) {\n serializedCalc = sortCalcValues(flatItems, true);\n } else {\n const firstItem = flatItems[0] || '';\n serializedCalc =\n isString(firstItem) && firstItem.startsWith('calc(')\n ? firstItem\n : `calc(${firstItem})`;\n }\n }\n }\n setCache(cacheKey, serializedCalc);\n return serializedCalc;\n};\n\n/**\n * resolve dimension\n * @param token - CSS token\n * @param [opt] - options\n * @returns resolved value\n */\nexport const resolveDimension = (\n token: CSSToken,\n opt: Options = {}\n): string | NullObject => {\n if (!Array.isArray(token)) {\n throw new TypeError(`${token} is not an array.`);\n }\n const [, , , , detail = {}] = token;\n const { unit, value } = detail as {\n unit: string;\n value: number;\n };\n if (unit === 'px') {\n return `${value}${unit}`;\n }\n const pixelValue = resolveLengthInPixels(Number(value), unit, opt);\n if (Number.isFinite(pixelValue)) {\n return `${roundToPrecision(pixelValue, HEX)}px`;\n }\n return new NullObject();\n};\n\n/**\n * parse tokens\n * @param tokens - CSS tokens\n * @param [opt] - options\n * @returns parsed tokens\n */\nexport const parseTokens = (\n tokens: CSSToken[],\n opt: Options = {}\n): string[] => {\n if (!Array.isArray(tokens)) {\n throw new TypeError(`${tokens} is not an array.`);\n }\n const { format = '' } = opt;\n const mathFunc = new Set();\n let nest = 0;\n const res: string[] = [];\n for (const token of tokens) {\n if (!Array.isArray(token)) {\n throw new TypeError(`${token} is not an array.`);\n }\n const [type = '', value = ''] = token as [TokenType, string];\n switch (type) {\n case DIM: {\n if (format === VAL_SPEC && !mathFunc.has(nest)) {\n res.push(value);\n } else {\n const resolvedValue = resolveDimension(token, opt);\n if (isString(resolvedValue)) {\n res.push(resolvedValue);\n } else {\n res.push(value);\n }\n }\n break;\n }\n case FUNC:\n case PAREN_OPEN: {\n res.push(value);\n nest++;\n if (REG_FN_MATH_START.test(value)) {\n mathFunc.add(nest);\n }\n break;\n }\n case PAREN_CLOSE: {\n if (res.length) {\n const lastValue = res[res.length - 1];\n if (lastValue === ' ') {\n res.splice(-1, 1, value);\n } else {\n res.push(value);\n }\n } else {\n res.push(value);\n }\n if (mathFunc.has(nest)) {\n mathFunc.delete(nest);\n }\n nest--;\n break;\n }\n case W_SPACE: {\n if (res.length) {\n const lastValue = res[res.length - 1];\n if (\n isString(lastValue) &&\n !lastValue.endsWith('(') &&\n lastValue !== ' '\n ) {\n res.push(value);\n }\n }\n break;\n }\n default: {\n if (type !== COMMENT && type !== EOF) {\n res.push(value);\n }\n }\n }\n }\n return res;\n};\n\n/**\n * CSS calc()\n * @param value - CSS value including calc()\n * @param [opt] - options\n * @returns resolved value\n */\nexport const cssCalc = (value: string, opt: Options = {}): string => {\n const { format = '' } = opt;\n if (isString(value)) {\n if (REG_FN_VAR.test(value)) {\n if (format === VAL_SPEC) {\n return value;\n } else {\n const resolvedValue = resolveVar(value, opt);\n if (isString(resolvedValue)) {\n return resolvedValue;\n } else {\n return '';\n }\n }\n } else if (!REG_FN_CALC.test(value)) {\n return value;\n }\n value = value.toLowerCase().trim();\n } else {\n throw new TypeError(`${value} is not a string.`);\n }\n const cacheKey: string = createCacheKey(\n {\n namespace: NAMESPACE,\n name: 'cssCalc',\n value\n },\n opt\n );\n const cachedResult = getCache(cacheKey);\n if (cachedResult instanceof CacheItem) {\n return cachedResult.item as string;\n }\n const tokens = tokenize({ css: value });\n const values = parseTokens(tokens, opt);\n let resolvedValue: string = calc(values.join(''), {\n toCanonicalUnits: true\n });\n if (REG_FN_VAR_START.test(value)) {\n if (REG_TYPE_DIM_PCT.test(resolvedValue)) {\n const [, val, unit] = resolvedValue.match(\n REG_TYPE_DIM_PCT\n ) as MatchedRegExp;\n resolvedValue = `${roundToPrecision(Number(val), HEX)}${unit}`;\n }\n // wrap with `calc()`\n if (\n resolvedValue &&\n !REG_FN_VAR_START.test(resolvedValue) &&\n format === VAL_SPEC\n ) {\n resolvedValue = `calc(${resolvedValue})`;\n }\n }\n if (format === VAL_SPEC) {\n if (/\\s[-+*/]\\s/.test(resolvedValue) && !resolvedValue.includes('NaN')) {\n resolvedValue = serializeCalc(resolvedValue, opt);\n } else if (REG_FN_CALC_NUM.test(resolvedValue)) {\n const [, val] = resolvedValue.match(REG_FN_CALC_NUM) as MatchedRegExp;\n resolvedValue = `calc(${roundToPrecision(Number(val), HEX)})`;\n }\n }\n setCache(cacheKey, resolvedValue);\n return resolvedValue;\n};\n"],"mappings":";;;;;;;;;;;AA6BA,IAAM,EACJ,YAAY,aACZ,SAAS,SACT,WAAW,KACX,KACA,UAAU,MACV,WAAW,YACX,YAAY,YACV;AACJ,IAAM,YAAY;AAGlB,IAAM,OAAO;AACb,IAAM,MAAM;AACZ,IAAM,UAAU;AAGhB,IAAM,cAAc,IAAI,OAAO,YAAY;AAC3C,IAAM,kBAAkB,IAAI,OAAO,YAAY,IAAI,OAAO;AAC1D,IAAM,oBAAoB,IAAI,OAAO,kBAAkB;AACvD,IAAM,aAAa,IAAI,OAAO,WAAW;AACzC,IAAM,mBAAmB,IAAI,OAAO,iBAAiB;AACrD,IAAM,eAAe;AACrB,I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AAO,IAAI;AAC5C,OAAI,SAAS,cAAc,CACzB,QAAO;OAEP,QAAO;;WAGF,CAAC,YAAY,KAAK,MAAM,CACjC,QAAO;AAET,UAAQ,MAAM,aAAa,CAAC,MAAM;OAElC,OAAM,IAAI,UAAU,GAAG,MAAM,mBAAmB;CAElD,MAAM,WAAmB,eACvB;EACE,WAAW;EACX,MAAM;EACN;EACD,EACD,IACD;CACD,MAAM,eAAe,SAAS,SAAS;AACvC,KAAI,wBAAwB,UAC1B,QAAO,aAAa;CAItB,IAAI,gBAAwB,KADb,YADA,SAAS,EAAE,KAAK,OAAO,CAAC,EACJ,IAAI,CACC,KAAK,GAAG,EAAE,EAChD,kBAAkB,MACnB,CAAC;AACF,KAAI,iBAAiB,KAAK,MAAM,EAAE;AAChC,MAAI,iBAAiB,KAAK,cAAc,EAAE;GACxC,MAAM,GAAG,KAAK,QAAQ,cAAc,MAClC,iBACD;AACD,mBAAgB,GAAG,iBAAiB,OAAO,IAAI,EAAE,IAAI,GAAG;;AAG1D,MACE,iBACA,CAAC,iBAAiB,KAAK,cAAc,IACrC,WAAA,iBAEA,iBAAgB,QAAQ,cAAc;;AAG1C,KAAI,WAAA;MACE,aAAa,KAAK,cAAc,IAAI,CAAC,cAAc,SAAS,MAAM,CACpE,iBAAgB,cAAc,eAAe,IAAI;WACxC,gBAAgB,KAAK,cAAc,EAAE;GAC9C,MAAM,GAAG,OAAO,cAAc,MAAM,gBAAgB;AACpD,mBAAgB,QAAQ,iBAAiB,OAAO,IAAI,EAAE,IAAI,CAAC;;;AAG/D,UAAS,UAAU,cAAc;AACjC,QAAO"}
|
|
|
|
|
|
node_modules/@asamuzakjp/css-color/dist/esm/js/css-gradient.d.ts
DELETED
|
@@ -1,79 +0,0 @@
|
|
| 1 |
-
import { Options } from './typedef.js';
|
| 2 |
-
/**
|
| 3 |
-
* @type ColorStopList - list of color stops
|
| 4 |
-
*/
|
| 5 |
-
type ColorStopList = [string, string, ...string[]];
|
| 6 |
-
/**
|
| 7 |
-
* @typedef ValidateGradientLine - validate gradient line
|
| 8 |
-
* @property line - gradient line
|
| 9 |
-
* @property valid - result
|
| 10 |
-
*/
|
| 11 |
-
interface ValidateGradientLine {
|
| 12 |
-
line: string;
|
| 13 |
-
valid: boolean;
|
| 14 |
-
}
|
| 15 |
-
/**
|
| 16 |
-
* @typedef ValidateColorStops - validate color stops
|
| 17 |
-
* @property colorStops - list of color stops
|
| 18 |
-
* @property valid - result
|
| 19 |
-
*/
|
| 20 |
-
interface ValidateColorStops {
|
| 21 |
-
colorStops: string[];
|
| 22 |
-
valid: boolean;
|
| 23 |
-
}
|
| 24 |
-
/**
|
| 25 |
-
* @typedef Gradient - parsed CSS gradient
|
| 26 |
-
* @property value - input value
|
| 27 |
-
* @property type - gradient type
|
| 28 |
-
* @property [gradientLine] - gradient line
|
| 29 |
-
* @property colorStopList - list of color stops
|
| 30 |
-
*/
|
| 31 |
-
interface Gradient {
|
| 32 |
-
value: string;
|
| 33 |
-
type: string;
|
| 34 |
-
gradientLine?: string;
|
| 35 |
-
colorStopList: ColorStopList;
|
| 36 |
-
}
|
| 37 |
-
/**
|
| 38 |
-
* get gradient type
|
| 39 |
-
* @param value - gradient value
|
| 40 |
-
* @returns gradient type
|
| 41 |
-
*/
|
| 42 |
-
export declare const getGradientType: (value: string) => string;
|
| 43 |
-
/**
|
| 44 |
-
* validate gradient line
|
| 45 |
-
* @param value - gradient line value
|
| 46 |
-
* @param type - gradient type
|
| 47 |
-
* @returns result
|
| 48 |
-
*/
|
| 49 |
-
export declare const validateGradientLine: (value: string, type: string) => ValidateGradientLine;
|
| 50 |
-
/**
|
| 51 |
-
* validate color stop list
|
| 52 |
-
* @param list
|
| 53 |
-
* @param type
|
| 54 |
-
* @param [opt]
|
| 55 |
-
* @returns result
|
| 56 |
-
*/
|
| 57 |
-
export declare const validateColorStopList: (list: string[], type: string, opt?: Options) => ValidateColorStops;
|
| 58 |
-
/**
|
| 59 |
-
* parse CSS gradient
|
| 60 |
-
* @param value - gradient value
|
| 61 |
-
* @param [opt] - options
|
| 62 |
-
* @returns parsed result
|
| 63 |
-
*/
|
| 64 |
-
export declare const parseGradient: (value: string, opt?: Options) => Gradient | null;
|
| 65 |
-
/**
|
| 66 |
-
* resolve CSS gradient
|
| 67 |
-
* @param value - CSS value
|
| 68 |
-
* @param [opt] - options
|
| 69 |
-
* @returns result
|
| 70 |
-
*/
|
| 71 |
-
export declare const resolveGradient: (value: string, opt?: Options) => string;
|
| 72 |
-
/**
|
| 73 |
-
* is CSS gradient
|
| 74 |
-
* @param value - CSS value
|
| 75 |
-
* @param [opt] - options
|
| 76 |
-
* @returns result
|
| 77 |
-
*/
|
| 78 |
-
export declare const isGradient: (value: string, opt?: Options) => boolean;
|
| 79 |
-
export {};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
node_modules/@asamuzakjp/css-color/dist/esm/js/css-gradient.js
DELETED
|
@@ -1,291 +0,0 @@
|
|
| 1 |
-
import { CacheItem, createCacheKey, getCache, setCache } from "./cache.js";
|
| 2 |
-
import { isString } from "./common.js";
|
| 3 |
-
import { ANGLE, CS_HUE, CS_RECT, LENGTH, NUM, NUM_POSITIVE, PCT, VAL_COMP } from "./constant.js";
|
| 4 |
-
import { resolveColor } from "./resolve.js";
|
| 5 |
-
import { isColor, splitValue } from "./util.js";
|
| 6 |
-
//#region src/js/css-gradient.ts
|
| 7 |
-
/**
|
| 8 |
-
* css-gradient
|
| 9 |
-
*/
|
| 10 |
-
var NAMESPACE = "css-gradient";
|
| 11 |
-
var DIM_ANGLE = `${NUM}(?:${ANGLE})`;
|
| 12 |
-
var DIM_ANGLE_PCT = `${DIM_ANGLE}|${PCT}`;
|
| 13 |
-
var DIM_LEN_PCT = `${`${NUM}(?:${LENGTH})|0`}|${PCT}`;
|
| 14 |
-
var DIM_LEN_PCT_POSI = `${NUM_POSITIVE}(?:${LENGTH}|%)|0`;
|
| 15 |
-
var DIM_LEN_POSI = `${NUM_POSITIVE}(?:${LENGTH})|0`;
|
| 16 |
-
var CTR = "center";
|
| 17 |
-
var L_R = "left|right";
|
| 18 |
-
var T_B = "top|bottom";
|
| 19 |
-
var S_E = "start|end";
|
| 20 |
-
var AXIS_X = `${L_R}|x-(?:${S_E})`;
|
| 21 |
-
var AXIS_Y = `${T_B}|y-(?:${S_E})`;
|
| 22 |
-
var BLOCK = `block-(?:${S_E})`;
|
| 23 |
-
var INLINE = `inline-(?:${S_E})`;
|
| 24 |
-
var POS_1 = `${CTR}|${AXIS_X}|${AXIS_Y}|${BLOCK}|${INLINE}|${DIM_LEN_PCT}`;
|
| 25 |
-
var POS_2 = [
|
| 26 |
-
`(?:${CTR}|${AXIS_X})\\s+(?:${CTR}|${AXIS_Y})`,
|
| 27 |
-
`(?:${CTR}|${AXIS_Y})\\s+(?:${CTR}|${AXIS_X})`,
|
| 28 |
-
`(?:${CTR}|${AXIS_X}|${DIM_LEN_PCT})\\s+(?:${CTR}|${AXIS_Y}|${DIM_LEN_PCT})`,
|
| 29 |
-
`(?:${CTR}|${BLOCK})\\s+(?:${CTR}|${INLINE})`,
|
| 30 |
-
`(?:${CTR}|${INLINE})\\s+(?:${CTR}|${BLOCK})`,
|
| 31 |
-
`(?:${CTR}|${S_E})\\s+(?:${CTR}|${S_E})`
|
| 32 |
-
].join("|");
|
| 33 |
-
var POS_4 = [
|
| 34 |
-
`(?:${AXIS_X})\\s+(?:${DIM_LEN_PCT})\\s+(?:${AXIS_Y})\\s+(?:${DIM_LEN_PCT})`,
|
| 35 |
-
`(?:${AXIS_Y})\\s+(?:${DIM_LEN_PCT})\\s+(?:${AXIS_X})\\s+(?:${DIM_LEN_PCT})`,
|
| 36 |
-
`(?:${BLOCK})\\s+(?:${DIM_LEN_PCT})\\s+(?:${INLINE})\\s+(?:${DIM_LEN_PCT})`,
|
| 37 |
-
`(?:${INLINE})\\s+(?:${DIM_LEN_PCT})\\s+(?:${BLOCK})\\s+(?:${DIM_LEN_PCT})`,
|
| 38 |
-
`(?:${S_E})\\s+(?:${DIM_LEN_PCT})\\s+(?:${S_E})\\s+(?:${DIM_LEN_PCT})`
|
| 39 |
-
].join("|");
|
| 40 |
-
var RAD_EXTENT = "(?:clos|farth)est-(?:corner|side)";
|
| 41 |
-
var RAD_SIZE = [
|
| 42 |
-
`${RAD_EXTENT}(?:\\s+${RAD_EXTENT})?`,
|
| 43 |
-
`${DIM_LEN_POSI}`,
|
| 44 |
-
`(?:${DIM_LEN_PCT_POSI})\\s+(?:${DIM_LEN_PCT_POSI})`
|
| 45 |
-
].join("|");
|
| 46 |
-
var RAD_SHAPE = "circle|ellipse";
|
| 47 |
-
var FROM_ANGLE = `from\\s+${DIM_ANGLE}`;
|
| 48 |
-
var AT_POSITION = `at\\s+(?:${POS_1}|${POS_2}|${POS_4})`;
|
| 49 |
-
var TO_SIDE_CORNER = `to\\s+(?:(?:${L_R})(?:\\s(?:${T_B}))?|(?:${T_B})(?:\\s(?:${L_R}))?)`;
|
| 50 |
-
var IN_COLOR_SPACE = `in\\s+(?:${CS_RECT}|${CS_HUE})`;
|
| 51 |
-
var LINE_SYNTAX_LINEAR = [`(?:${DIM_ANGLE}|${TO_SIDE_CORNER})(?:\\s+${IN_COLOR_SPACE})?`, `${IN_COLOR_SPACE}(?:\\s+(?:${DIM_ANGLE}|${TO_SIDE_CORNER}))?`].join("|");
|
| 52 |
-
var LINE_SYNTAX_RADIAL = [
|
| 53 |
-
`(?:${RAD_SHAPE})(?:\\s+(?:${RAD_SIZE}))?(?:\\s+${AT_POSITION})?(?:\\s+${IN_COLOR_SPACE})?`,
|
| 54 |
-
`(?:${RAD_SIZE})(?:\\s+(?:${RAD_SHAPE}))?(?:\\s+${AT_POSITION})?(?:\\s+${IN_COLOR_SPACE})?`,
|
| 55 |
-
`${AT_POSITION}(?:\\s+${IN_COLOR_SPACE})?`,
|
| 56 |
-
`${IN_COLOR_SPACE}(?:\\s+${RAD_SHAPE})(?:\\s+(?:${RAD_SIZE}))?(?:\\s+${AT_POSITION})?`,
|
| 57 |
-
`${IN_COLOR_SPACE}(?:\\s+${RAD_SIZE})(?:\\s+(?:${RAD_SHAPE}))?(?:\\s+${AT_POSITION})?`,
|
| 58 |
-
`${IN_COLOR_SPACE}(?:\\s+${AT_POSITION})?`
|
| 59 |
-
].join("|");
|
| 60 |
-
var LINE_SYNTAX_CONIC = [
|
| 61 |
-
`${FROM_ANGLE}(?:\\s+${AT_POSITION})?(?:\\s+${IN_COLOR_SPACE})?`,
|
| 62 |
-
`${AT_POSITION}(?:\\s+${IN_COLOR_SPACE})?`,
|
| 63 |
-
`${IN_COLOR_SPACE}(?:\\s+${FROM_ANGLE})?(?:\\s+${AT_POSITION})?`
|
| 64 |
-
].join("|");
|
| 65 |
-
var DEFAULT_LINEAR = [/to\s+bottom/];
|
| 66 |
-
var DEFAULT_RADIAL = [
|
| 67 |
-
/ellipse/,
|
| 68 |
-
/farthest-corner/,
|
| 69 |
-
/at\s+center/
|
| 70 |
-
];
|
| 71 |
-
var DEFAULT_CONIC = [/at\s+center/];
|
| 72 |
-
var IS_CONIC = /^(?:repeating-)?conic-gradient$/;
|
| 73 |
-
var IS_LINEAR = /^(?:repeating-)?linear-gradient$/;
|
| 74 |
-
var IS_RADIAL = /^(?:repeating-)?radial-gradient$/;
|
| 75 |
-
var REG_COLOR_HINT_CONIC = new RegExp(`^(?:${DIM_ANGLE_PCT})$`);
|
| 76 |
-
var REG_COLOR_HINT_NON_CONIC = new RegExp(`^(?:${DIM_LEN_PCT})$`);
|
| 77 |
-
var REG_DIM_CONIC = new RegExp(`(?:\\s+(?:${DIM_ANGLE_PCT})){1,2}$`);
|
| 78 |
-
var REG_DIM_NON_CONIC = new RegExp(`(?:\\s+(?:${DIM_LEN_PCT})){1,2}$`);
|
| 79 |
-
var REG_GRAD = /^(?:repeating-)?(?:conic|linear|radial)-gradient\(/;
|
| 80 |
-
var REG_GRAD_CAPT = /^((?:repeating-)?(?:conic|linear|radial)-gradient)\(/;
|
| 81 |
-
var REG_LINE_CONIC = new RegExp(`^(?:${LINE_SYNTAX_CONIC})$`);
|
| 82 |
-
var REG_LINE_LINEAR = new RegExp(`^(?:${LINE_SYNTAX_LINEAR})$`);
|
| 83 |
-
var REG_LINE_RADIAL = new RegExp(`^(?:${LINE_SYNTAX_RADIAL})$`);
|
| 84 |
-
/**
|
| 85 |
-
* get gradient type
|
| 86 |
-
* @param value - gradient value
|
| 87 |
-
* @returns gradient type
|
| 88 |
-
*/
|
| 89 |
-
var getGradientType = (value) => {
|
| 90 |
-
if (isString(value)) {
|
| 91 |
-
value = value.trim();
|
| 92 |
-
if (REG_GRAD.test(value)) {
|
| 93 |
-
const [, type] = value.match(REG_GRAD_CAPT);
|
| 94 |
-
return type;
|
| 95 |
-
}
|
| 96 |
-
}
|
| 97 |
-
return "";
|
| 98 |
-
};
|
| 99 |
-
/**
|
| 100 |
-
* validate gradient line
|
| 101 |
-
* @param value - gradient line value
|
| 102 |
-
* @param type - gradient type
|
| 103 |
-
* @returns result
|
| 104 |
-
*/
|
| 105 |
-
var validateGradientLine = (value, type) => {
|
| 106 |
-
if (isString(value) && isString(type)) {
|
| 107 |
-
value = value.trim();
|
| 108 |
-
type = type.trim();
|
| 109 |
-
let reg = null;
|
| 110 |
-
let defaultValues = [];
|
| 111 |
-
if (IS_LINEAR.test(type)) {
|
| 112 |
-
reg = REG_LINE_LINEAR;
|
| 113 |
-
defaultValues = DEFAULT_LINEAR;
|
| 114 |
-
} else if (IS_RADIAL.test(type)) {
|
| 115 |
-
reg = REG_LINE_RADIAL;
|
| 116 |
-
defaultValues = DEFAULT_RADIAL;
|
| 117 |
-
} else if (IS_CONIC.test(type)) {
|
| 118 |
-
reg = REG_LINE_CONIC;
|
| 119 |
-
defaultValues = DEFAULT_CONIC;
|
| 120 |
-
}
|
| 121 |
-
if (reg) {
|
| 122 |
-
const valid = reg.test(value);
|
| 123 |
-
if (valid) {
|
| 124 |
-
let line = value;
|
| 125 |
-
for (const defaultValue of defaultValues) line = line.replace(defaultValue, "");
|
| 126 |
-
line = line.replace(/\s{2,}/g, " ").trim();
|
| 127 |
-
return {
|
| 128 |
-
line,
|
| 129 |
-
valid
|
| 130 |
-
};
|
| 131 |
-
}
|
| 132 |
-
return {
|
| 133 |
-
valid,
|
| 134 |
-
line: value
|
| 135 |
-
};
|
| 136 |
-
}
|
| 137 |
-
}
|
| 138 |
-
return {
|
| 139 |
-
line: value,
|
| 140 |
-
valid: false
|
| 141 |
-
};
|
| 142 |
-
};
|
| 143 |
-
/**
|
| 144 |
-
* validate color stop list
|
| 145 |
-
* @param list
|
| 146 |
-
* @param type
|
| 147 |
-
* @param [opt]
|
| 148 |
-
* @returns result
|
| 149 |
-
*/
|
| 150 |
-
var validateColorStopList = (list, type, opt = {}) => {
|
| 151 |
-
if (Array.isArray(list) && list.length > 1) {
|
| 152 |
-
const isConic = IS_CONIC.test(type);
|
| 153 |
-
const regColorHint = isConic ? REG_COLOR_HINT_CONIC : REG_COLOR_HINT_NON_CONIC;
|
| 154 |
-
const regDimension = isConic ? REG_DIM_CONIC : REG_DIM_NON_CONIC;
|
| 155 |
-
const valueList = [];
|
| 156 |
-
let prevType = "";
|
| 157 |
-
for (let i = 0; i < list.length; i++) {
|
| 158 |
-
const item = list[i];
|
| 159 |
-
if (isString(item)) if (regColorHint.test(item)) {
|
| 160 |
-
if (i === 0 || prevType === "hint") return {
|
| 161 |
-
colorStops: list,
|
| 162 |
-
valid: false
|
| 163 |
-
};
|
| 164 |
-
prevType = "hint";
|
| 165 |
-
valueList.push(item);
|
| 166 |
-
} else {
|
| 167 |
-
const itemColor = item.replace(regDimension, "");
|
| 168 |
-
if (isColor(itemColor, { format: "specifiedValue" })) {
|
| 169 |
-
const resolvedColor = resolveColor(itemColor, opt);
|
| 170 |
-
prevType = "color";
|
| 171 |
-
valueList.push(item.replace(itemColor, resolvedColor));
|
| 172 |
-
} else return {
|
| 173 |
-
colorStops: list,
|
| 174 |
-
valid: false
|
| 175 |
-
};
|
| 176 |
-
}
|
| 177 |
-
else return {
|
| 178 |
-
colorStops: list,
|
| 179 |
-
valid: false
|
| 180 |
-
};
|
| 181 |
-
}
|
| 182 |
-
if (prevType !== "color") return {
|
| 183 |
-
colorStops: list,
|
| 184 |
-
valid: false
|
| 185 |
-
};
|
| 186 |
-
return {
|
| 187 |
-
valid: true,
|
| 188 |
-
colorStops: valueList
|
| 189 |
-
};
|
| 190 |
-
}
|
| 191 |
-
return {
|
| 192 |
-
colorStops: list,
|
| 193 |
-
valid: false
|
| 194 |
-
};
|
| 195 |
-
};
|
| 196 |
-
/**
|
| 197 |
-
* parse CSS gradient
|
| 198 |
-
* @param value - gradient value
|
| 199 |
-
* @param [opt] - options
|
| 200 |
-
* @returns parsed result
|
| 201 |
-
*/
|
| 202 |
-
var parseGradient = (value, opt = {}) => {
|
| 203 |
-
if (isString(value)) {
|
| 204 |
-
value = value.trim();
|
| 205 |
-
const cacheKey = createCacheKey({
|
| 206 |
-
namespace: NAMESPACE,
|
| 207 |
-
name: "parseGradient",
|
| 208 |
-
value
|
| 209 |
-
}, opt);
|
| 210 |
-
const cachedResult = getCache(cacheKey);
|
| 211 |
-
if (cachedResult instanceof CacheItem) {
|
| 212 |
-
if (cachedResult.isNull) return null;
|
| 213 |
-
return cachedResult.item;
|
| 214 |
-
}
|
| 215 |
-
const type = getGradientType(value);
|
| 216 |
-
const gradValue = value.replace(REG_GRAD, "").replace(/\)$/, "");
|
| 217 |
-
if (type && gradValue) {
|
| 218 |
-
const [lineOrColorStop = "", ...itemList] = splitValue(gradValue, { delimiter: "," });
|
| 219 |
-
const regDimension = IS_CONIC.test(type) ? REG_DIM_CONIC : REG_DIM_NON_CONIC;
|
| 220 |
-
let colorStop = "";
|
| 221 |
-
if (regDimension.test(lineOrColorStop)) {
|
| 222 |
-
const itemColor = lineOrColorStop.replace(regDimension, "");
|
| 223 |
-
if (isColor(itemColor, { format: "specifiedValue" })) {
|
| 224 |
-
const resolvedColor = resolveColor(itemColor, opt);
|
| 225 |
-
colorStop = lineOrColorStop.replace(itemColor, resolvedColor);
|
| 226 |
-
}
|
| 227 |
-
} else if (isColor(lineOrColorStop, { format: "specifiedValue" })) colorStop = resolveColor(lineOrColorStop, opt);
|
| 228 |
-
if (colorStop) {
|
| 229 |
-
itemList.unshift(colorStop);
|
| 230 |
-
const { colorStops, valid } = validateColorStopList(itemList, type, opt);
|
| 231 |
-
if (valid) {
|
| 232 |
-
const res = {
|
| 233 |
-
value,
|
| 234 |
-
type,
|
| 235 |
-
colorStopList: colorStops
|
| 236 |
-
};
|
| 237 |
-
setCache(cacheKey, res);
|
| 238 |
-
return res;
|
| 239 |
-
}
|
| 240 |
-
} else if (itemList.length > 1) {
|
| 241 |
-
const { line: gradientLine, valid: validLine } = validateGradientLine(lineOrColorStop, type);
|
| 242 |
-
const { colorStops, valid: validColorStops } = validateColorStopList(itemList, type, opt);
|
| 243 |
-
if (validLine && validColorStops) {
|
| 244 |
-
const res = {
|
| 245 |
-
value,
|
| 246 |
-
type,
|
| 247 |
-
gradientLine,
|
| 248 |
-
colorStopList: colorStops
|
| 249 |
-
};
|
| 250 |
-
setCache(cacheKey, res);
|
| 251 |
-
return res;
|
| 252 |
-
}
|
| 253 |
-
}
|
| 254 |
-
}
|
| 255 |
-
setCache(cacheKey, null);
|
| 256 |
-
return null;
|
| 257 |
-
}
|
| 258 |
-
return null;
|
| 259 |
-
};
|
| 260 |
-
/**
|
| 261 |
-
* resolve CSS gradient
|
| 262 |
-
* @param value - CSS value
|
| 263 |
-
* @param [opt] - options
|
| 264 |
-
* @returns result
|
| 265 |
-
*/
|
| 266 |
-
var resolveGradient = (value, opt = {}) => {
|
| 267 |
-
const { format = VAL_COMP } = opt;
|
| 268 |
-
const gradient = parseGradient(value, opt);
|
| 269 |
-
if (gradient) {
|
| 270 |
-
const { type = "", gradientLine = "", colorStopList = [] } = gradient;
|
| 271 |
-
if (type && Array.isArray(colorStopList) && colorStopList.length > 1) {
|
| 272 |
-
if (gradientLine) return `${type}(${gradientLine}, ${colorStopList.join(", ")})`;
|
| 273 |
-
return `${type}(${colorStopList.join(", ")})`;
|
| 274 |
-
}
|
| 275 |
-
}
|
| 276 |
-
if (format === "specifiedValue") return "";
|
| 277 |
-
return "none";
|
| 278 |
-
};
|
| 279 |
-
/**
|
| 280 |
-
* is CSS gradient
|
| 281 |
-
* @param value - CSS value
|
| 282 |
-
* @param [opt] - options
|
| 283 |
-
* @returns result
|
| 284 |
-
*/
|
| 285 |
-
var isGradient = (value, opt = {}) => {
|
| 286 |
-
return parseGradient(value, opt) !== null;
|
| 287 |
-
};
|
| 288 |
-
//#endregion
|
| 289 |
-
export { isGradient, resolveGradient };
|
| 290 |
-
|
| 291 |
-
//# sourceMappingURL=css-gradient.js.map
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
node_modules/@asamuzakjp/css-color/dist/esm/js/css-gradient.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
{"version":3,"file":"css-gradient.js","names":[],"sources":["../../../src/js/css-gradient.ts"],"sourcesContent":["/**\n * css-gradient\n */\n\nimport { CacheItem, createCacheKey, getCache, setCache } from './cache';\nimport { resolveColor } from './resolve';\nimport { isString } from './common';\nimport { MatchedRegExp, Options } from './typedef';\nimport { isColor, splitValue } from './util';\n\n/* constants */\nimport {\n ANGLE,\n CS_HUE,\n CS_RECT,\n LENGTH,\n NUM,\n NUM_POSITIVE,\n PCT,\n VAL_COMP,\n VAL_SPEC\n} from './constant';\nconst NAMESPACE = 'css-gradient';\nconst DIM_ANGLE = `${NUM}(?:${ANGLE})`;\nconst DIM_ANGLE_PCT = `${DIM_ANGLE}|${PCT}`;\nconst DIM_LEN = `${NUM}(?:${LENGTH})|0`;\nconst DIM_LEN_PCT = `${DIM_LEN}|${PCT}`;\nconst DIM_LEN_PCT_POSI = `${NUM_POSITIVE}(?:${LENGTH}|%)|0`;\nconst DIM_LEN_POSI = `${NUM_POSITIVE}(?:${LENGTH})|0`;\nconst CTR = 'center';\nconst L_R = 'left|right';\nconst T_B = 'top|bottom';\nconst S_E = 'start|end';\nconst AXIS_X = `${L_R}|x-(?:${S_E})`;\nconst AXIS_Y = `${T_B}|y-(?:${S_E})`;\nconst BLOCK = `block-(?:${S_E})`;\nconst INLINE = `inline-(?:${S_E})`;\nconst POS_1 = `${CTR}|${AXIS_X}|${AXIS_Y}|${BLOCK}|${INLINE}|${DIM_LEN_PCT}`;\nconst POS_2 = [\n `(?:${CTR}|${AXIS_X})\\\\s+(?:${CTR}|${AXIS_Y})`,\n `(?:${CTR}|${AXIS_Y})\\\\s+(?:${CTR}|${AXIS_X})`,\n `(?:${CTR}|${AXIS_X}|${DIM_LEN_PCT})\\\\s+(?:${CTR}|${AXIS_Y}|${DIM_LEN_PCT})`,\n `(?:${CTR}|${BLOCK})\\\\s+(?:${CTR}|${INLINE})`,\n `(?:${CTR}|${INLINE})\\\\s+(?:${CTR}|${BLOCK})`,\n `(?:${CTR}|${S_E})\\\\s+(?:${CTR}|${S_E})`\n].join('|');\nconst POS_4 = [\n `(?:${AXIS_X})\\\\s+(?:${DIM_LEN_PCT})\\\\s+(?:${AXIS_Y})\\\\s+(?:${DIM_LEN_PCT})`,\n `(?:${AXIS_Y})\\\\s+(?:${DIM_LEN_PCT})\\\\s+(?:${AXIS_X})\\\\s+(?:${DIM_LEN_PCT})`,\n `(?:${BLOCK})\\\\s+(?:${DIM_LEN_PCT})\\\\s+(?:${INLINE})\\\\s+(?:${DIM_LEN_PCT})`,\n `(?:${INLINE})\\\\s+(?:${DIM_LEN_PCT})\\\\s+(?:${BLOCK})\\\\s+(?:${DIM_LEN_PCT})`,\n `(?:${S_E})\\\\s+(?:${DIM_LEN_PCT})\\\\s+(?:${S_E})\\\\s+(?:${DIM_LEN_PCT})`\n].join('|');\nconst RAD_EXTENT = '(?:clos|farth)est-(?:corner|side)';\nconst RAD_SIZE = [\n `${RAD_EXTENT}(?:\\\\s+${RAD_EXTENT})?`,\n `${DIM_LEN_POSI}`,\n `(?:${DIM_LEN_PCT_POSI})\\\\s+(?:${DIM_LEN_PCT_POSI})`\n].join('|');\nconst RAD_SHAPE = 'circle|ellipse';\nconst FROM_ANGLE = `from\\\\s+${DIM_ANGLE}`;\nconst AT_POSITION = `at\\\\s+(?:${POS_1}|${POS_2}|${POS_4})`;\nconst TO_SIDE_CORNER = `to\\\\s+(?:(?:${L_R})(?:\\\\s(?:${T_B}))?|(?:${T_B})(?:\\\\s(?:${L_R}))?)`;\nconst IN_COLOR_SPACE = `in\\\\s+(?:${CS_RECT}|${CS_HUE})`;\nconst LINE_SYNTAX_LINEAR = [\n `(?:${DIM_ANGLE}|${TO_SIDE_CORNER})(?:\\\\s+${IN_COLOR_SPACE})?`,\n `${IN_COLOR_SPACE}(?:\\\\s+(?:${DIM_ANGLE}|${TO_SIDE_CORNER}))?`\n].join('|');\nconst LINE_SYNTAX_RADIAL = [\n `(?:${RAD_SHAPE})(?:\\\\s+(?:${RAD_SIZE}))?(?:\\\\s+${AT_POSITION})?(?:\\\\s+${IN_COLOR_SPACE})?`,\n `(?:${RAD_SIZE})(?:\\\\s+(?:${RAD_SHAPE}))?(?:\\\\s+${AT_POSITION})?(?:\\\\s+${IN_COLOR_SPACE})?`,\n `${AT_POSITION}(?:\\\\s+${IN_COLOR_SPACE})?`,\n `${IN_COLOR_SPACE}(?:\\\\s+${RAD_SHAPE})(?:\\\\s+(?:${RAD_SIZE}))?(?:\\\\s+${AT_POSITION})?`,\n `${IN_COLOR_SPACE}(?:\\\\s+${RAD_SIZE})(?:\\\\s+(?:${RAD_SHAPE}))?(?:\\\\s+${AT_POSITION})?`,\n `${IN_COLOR_SPACE}(?:\\\\s+${AT_POSITION})?`\n].join('|');\nconst LINE_SYNTAX_CONIC = [\n `${FROM_ANGLE}(?:\\\\s+${AT_POSITION})?(?:\\\\s+${IN_COLOR_SPACE})?`,\n `${AT_POSITION}(?:\\\\s+${IN_COLOR_SPACE})?`,\n `${IN_COLOR_SPACE}(?:\\\\s+${FROM_ANGLE})?(?:\\\\s+${AT_POSITION})?`\n].join('|');\nconst DEFAULT_LINEAR = [/to\\s+bottom/];\nconst DEFAULT_RADIAL = [/ellipse/, /farthest-corner/, /at\\s+center/];\nconst DEFAULT_CONIC = [/at\\s+center/];\n\n/* type definitions */\n/**\n * @type ColorStopList - list of color stops\n */\ntype ColorStopList = [string, string, ...string[]];\n\n/**\n * @typedef ValidateGradientLine - validate gradient line\n * @property line - gradient line\n * @property valid - result\n */\ninterface ValidateGradientLine {\n line: string;\n valid: boolean;\n}\n\n/**\n * @typedef ValidateColorStops - validate color stops\n * @property colorStops - list of color stops\n * @property valid - result\n */\ninterface ValidateColorStops {\n colorStops: string[];\n valid: boolean;\n}\n\n/**\n * @typedef Gradient - parsed CSS gradient\n * @property value - input value\n * @property type - gradient type\n * @property [gradientLine] - gradient line\n * @property colorStopList - list of color stops\n */\ninterface Gradient {\n value: string;\n type: string;\n gradientLine?: string;\n colorStopList: ColorStopList;\n}\n\n/* regexp */\nconst IS_CONIC = /^(?:repeating-)?conic-gradient$/;\nconst IS_LINEAR = /^(?:repeating-)?linear-gradient$/;\nconst IS_RADIAL = /^(?:repeating-)?radial-gradient$/;\nconst REG_COLOR_HINT_CONIC = new RegExp(`^(?:${DIM_ANGLE_PCT})$`);\nconst REG_COLOR_HINT_NON_CONIC = new RegExp(`^(?:${DIM_LEN_PCT})$`);\nconst REG_DIM_CONIC = new RegExp(`(?:\\\\s+(?:${DIM_ANGLE_PCT})){1,2}$`);\nconst REG_DIM_NON_CONIC = new RegExp(`(?:\\\\s+(?:${DIM_LEN_PCT})){1,2}$`);\nconst REG_GRAD = /^(?:repeating-)?(?:conic|linear|radial)-gradient\\(/;\nconst REG_GRAD_CAPT = /^((?:repeating-)?(?:conic|linear|radial)-gradient)\\(/;\nconst REG_LINE_CONIC = new RegExp(`^(?:${LINE_SYNTAX_CONIC})$`);\nconst REG_LINE_LINEAR = new RegExp(`^(?:${LINE_SYNTAX_LINEAR})$`);\nconst REG_LINE_RADIAL = new RegExp(`^(?:${LINE_SYNTAX_RADIAL})$`);\n\n/**\n * get gradient type\n * @param value - gradient value\n * @returns gradient type\n */\nexport const getGradientType = (value: string): string => {\n if (isString(value)) {\n value = value.trim();\n if (REG_GRAD.test(value)) {\n const [, type] = value.match(REG_GRAD_CAPT) as MatchedRegExp;\n return type;\n }\n }\n return '';\n};\n\n/**\n * validate gradient line\n * @param value - gradient line value\n * @param type - gradient type\n * @returns result\n */\nexport const validateGradientLine = (\n value: string,\n type: string\n): ValidateGradientLine => {\n if (isString(value) && isString(type)) {\n value = value.trim();\n type = type.trim();\n let reg: RegExp | null = null;\n let defaultValues: RegExp[] = [];\n\n if (IS_LINEAR.test(type)) {\n reg = REG_LINE_LINEAR;\n defaultValues = DEFAULT_LINEAR;\n } else if (IS_RADIAL.test(type)) {\n reg = REG_LINE_RADIAL;\n defaultValues = DEFAULT_RADIAL;\n } else if (IS_CONIC.test(type)) {\n reg = REG_LINE_CONIC;\n defaultValues = DEFAULT_CONIC;\n }\n if (reg) {\n const valid = reg.test(value);\n if (valid) {\n let line = value;\n for (const defaultValue of defaultValues) {\n line = line.replace(defaultValue, '');\n }\n line = line.replace(/\\s{2,}/g, ' ').trim();\n return { line, valid };\n }\n return { valid, line: value };\n }\n }\n return { line: value, valid: false };\n};\n\n/**\n * validate color stop list\n * @param list\n * @param type\n * @param [opt]\n * @returns result\n */\nexport const validateColorStopList = (\n list: string[],\n type: string,\n opt: Options = {}\n): ValidateColorStops => {\n if (Array.isArray(list) && list.length > 1) {\n const isConic = IS_CONIC.test(type);\n const regColorHint = isConic\n ? REG_COLOR_HINT_CONIC\n : REG_COLOR_HINT_NON_CONIC;\n const regDimension = isConic ? REG_DIM_CONIC : REG_DIM_NON_CONIC;\n const valueList: string[] = [];\n // State tracker: 'color' or 'hint'\n let prevType = '';\n for (let i = 0; i < list.length; i++) {\n const item = list[i];\n if (isString(item)) {\n if (regColorHint.test(item)) {\n // Hints cannot be the first item, and two hints cannot be adjacent\n if (i === 0 || prevType === 'hint') {\n return { colorStops: list, valid: false };\n }\n prevType = 'hint';\n valueList.push(item);\n } else {\n const itemColor = item.replace(regDimension, '');\n if (isColor(itemColor, { format: VAL_SPEC })) {\n const resolvedColor = resolveColor(itemColor, opt) as string;\n prevType = 'color';\n valueList.push(item.replace(itemColor, resolvedColor));\n } else {\n return { colorStops: list, valid: false };\n }\n }\n } else {\n return { colorStops: list, valid: false };\n }\n }\n // The last item must be a color, not a hint\n if (prevType !== 'color') {\n return { colorStops: list, valid: false };\n }\n return { valid: true, colorStops: valueList };\n }\n return { colorStops: list, valid: false };\n};\n\n/**\n * parse CSS gradient\n * @param value - gradient value\n * @param [opt] - options\n * @returns parsed result\n */\nexport const parseGradient = (\n value: string,\n opt: Options = {}\n): Gradient | null => {\n if (isString(value)) {\n value = value.trim();\n const cacheKey: string = createCacheKey(\n {\n namespace: NAMESPACE,\n name: 'parseGradient',\n value\n },\n opt\n );\n const cachedResult = getCache(cacheKey);\n if (cachedResult instanceof CacheItem) {\n if (cachedResult.isNull) {\n return null;\n }\n return cachedResult.item as Gradient;\n }\n const type = getGradientType(value);\n const gradValue = value.replace(REG_GRAD, '').replace(/\\)$/, '');\n if (type && gradValue) {\n const [lineOrColorStop = '', ...itemList] = splitValue(gradValue, {\n delimiter: ','\n });\n const isConic = IS_CONIC.test(type);\n const regDimension = isConic ? REG_DIM_CONIC : REG_DIM_NON_CONIC;\n let colorStop = '';\n if (regDimension.test(lineOrColorStop)) {\n const itemColor = lineOrColorStop.replace(regDimension, '');\n if (isColor(itemColor, { format: VAL_SPEC })) {\n const resolvedColor = resolveColor(itemColor, opt) as string;\n colorStop = lineOrColorStop.replace(itemColor, resolvedColor);\n }\n } else if (isColor(lineOrColorStop, { format: VAL_SPEC })) {\n colorStop = resolveColor(lineOrColorStop, opt) as string;\n }\n if (colorStop) {\n itemList.unshift(colorStop);\n const { colorStops, valid } = validateColorStopList(\n itemList,\n type,\n opt\n );\n if (valid) {\n const res: Gradient = {\n value,\n type,\n colorStopList: colorStops as ColorStopList\n };\n setCache(cacheKey, res);\n return res;\n }\n } else if (itemList.length > 1) {\n const { line: gradientLine, valid: validLine } = validateGradientLine(\n lineOrColorStop,\n type\n );\n const { colorStops, valid: validColorStops } = validateColorStopList(\n itemList,\n type,\n opt\n );\n if (validLine && validColorStops) {\n const res: Gradient = {\n value,\n type,\n gradientLine,\n colorStopList: colorStops as ColorStopList\n };\n setCache(cacheKey, res);\n return res;\n }\n }\n }\n setCache(cacheKey, null);\n return null;\n }\n return null;\n};\n\n/**\n * resolve CSS gradient\n * @param value - CSS value\n * @param [opt] - options\n * @returns result\n */\nexport const resolveGradient = (value: string, opt: Options = {}): string => {\n const { format = VAL_COMP } = opt;\n const gradient = parseGradient(value, opt);\n if (gradient) {\n const { type = '', gradientLine = '', colorStopList = [] } = gradient;\n if (type && Array.isArray(colorStopList) && colorStopList.length > 1) {\n if (gradientLine) {\n return `${type}(${gradientLine}, ${colorStopList.join(', ')})`;\n }\n return `${type}(${colorStopList.join(', ')})`;\n }\n }\n if (format === VAL_SPEC) {\n return '';\n }\n return 'none';\n};\n\n/**\n * is CSS gradient\n * @param value - CSS value\n * @param [opt] - options\n * @returns result\n */\nexport const isGradient = (value: string, opt: Options = {}): boolean => {\n const gradient = parseGradient(value, opt);\n return gradient !== null;\n};\n"],"mappings":";;;;;;;;;AAsBA,IAAM,YAAY;AAClB,IAAM,YAAY,GAAG,IAAI,KAAK,MAAM;AACpC,IAAM,gBAAgB,GAAG,UAAU,GAAG;AAEtC,IAAM,cAAc,GADJ,GAAG,IAAI,KAAK,OAAO,KACJ,GAAG;AAClC,IAAM,mBAAmB,GAAG,aAAa,KAAK,OAAO;AACrD,IAAM,eAAe,GAAG,aAAa,KAAK,OAAO;AACjD,IAAM,MAAM;AACZ,IAAM,MAAM;AACZ,IA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AAE,KAAc;AAEvE,QADiB,cAAc,OAAO,IAAI,KACtB"}
|
|
|
|
|
|
node_modules/@asamuzakjp/css-color/dist/esm/js/css-var.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
| 1 |
-
import { CSSToken } from '@csstools/css-tokenizer';
|
| 2 |
-
import { NullObject } from './cache.js';
|
| 3 |
-
import { Options } from './typedef.js';
|
| 4 |
-
/**
|
| 5 |
-
* resolve custom property
|
| 6 |
-
* @param tokens - CSS tokens
|
| 7 |
-
* @param [opt] - options
|
| 8 |
-
* @returns result - [tokens, resolvedValue]
|
| 9 |
-
*/
|
| 10 |
-
export declare function resolveCustomProperty(tokens: CSSToken[], opt?: Options): [CSSToken[], string];
|
| 11 |
-
/**
|
| 12 |
-
* parse tokens
|
| 13 |
-
* @param tokens - CSS tokens
|
| 14 |
-
* @param [opt] - options
|
| 15 |
-
* @returns parsed tokens
|
| 16 |
-
*/
|
| 17 |
-
export declare function parseTokens(tokens: CSSToken[], opt?: Options): string[] | NullObject;
|
| 18 |
-
/**
|
| 19 |
-
* resolve CSS var()
|
| 20 |
-
* @param value - CSS value including var()
|
| 21 |
-
* @param [opt] - options
|
| 22 |
-
* @returns resolved value
|
| 23 |
-
*/
|
| 24 |
-
export declare function resolveVar(value: string, opt?: Options): string | NullObject;
|
| 25 |
-
/**
|
| 26 |
-
* CSS var()
|
| 27 |
-
* @param value - CSS value including var()
|
| 28 |
-
* @param [opt] - options
|
| 29 |
-
* @returns resolved value
|
| 30 |
-
*/
|
| 31 |
-
export declare const cssVar: (value: string, opt?: Options) => string;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
node_modules/@asamuzakjp/css-color/dist/esm/js/css-var.js
DELETED
|
@@ -1,144 +0,0 @@
|
|
| 1 |
-
import { CacheItem, NullObject, createCacheKey, getCache, setCache } from "./cache.js";
|
| 2 |
-
import { isString } from "./common.js";
|
| 3 |
-
import { SYN_FN_CALC, SYN_FN_VAR } from "./constant.js";
|
| 4 |
-
import { isColor } from "./util.js";
|
| 5 |
-
import { cssCalc } from "./css-calc.js";
|
| 6 |
-
import { TokenType, tokenize } from "@csstools/css-tokenizer";
|
| 7 |
-
//#region src/js/css-var.ts
|
| 8 |
-
/**
|
| 9 |
-
* css-var
|
| 10 |
-
*/
|
| 11 |
-
var { CloseParen: PAREN_CLOSE, Comment: COMMENT, EOF, Ident: IDENT, Whitespace: W_SPACE } = TokenType;
|
| 12 |
-
var NAMESPACE = "css-var";
|
| 13 |
-
var REG_FN_CALC = new RegExp(SYN_FN_CALC);
|
| 14 |
-
var REG_FN_VAR = new RegExp(SYN_FN_VAR);
|
| 15 |
-
var REG_CSS_WIDE_KEYWORD = /^(?:inherit|initial|revert(?:-layer)?|unset)$/;
|
| 16 |
-
/**
|
| 17 |
-
* resolve custom property
|
| 18 |
-
* @param tokens - CSS tokens
|
| 19 |
-
* @param [opt] - options
|
| 20 |
-
* @returns result - [tokens, resolvedValue]
|
| 21 |
-
*/
|
| 22 |
-
function resolveCustomProperty(tokens, opt = {}) {
|
| 23 |
-
if (!Array.isArray(tokens)) throw new TypeError(`${tokens} is not an array.`);
|
| 24 |
-
const { customProperty = {} } = opt;
|
| 25 |
-
const items = [];
|
| 26 |
-
while (tokens.length) {
|
| 27 |
-
const token = tokens.shift();
|
| 28 |
-
if (!token) break;
|
| 29 |
-
if (!Array.isArray(token)) throw new TypeError(`${token} is not an array.`);
|
| 30 |
-
const [type, value] = token;
|
| 31 |
-
if (type === PAREN_CLOSE) break;
|
| 32 |
-
if (value === "var(") {
|
| 33 |
-
const [, item] = resolveCustomProperty(tokens, opt);
|
| 34 |
-
if (item) items.push(item);
|
| 35 |
-
} else if (type === IDENT) {
|
| 36 |
-
if (value.startsWith("--")) {
|
| 37 |
-
let item;
|
| 38 |
-
if (Object.hasOwn(customProperty, value)) item = customProperty[value];
|
| 39 |
-
else if (typeof customProperty.callback === "function") item = customProperty.callback(value);
|
| 40 |
-
if (item) items.push(item);
|
| 41 |
-
} else if (value) items.push(value);
|
| 42 |
-
}
|
| 43 |
-
}
|
| 44 |
-
let resolveAsColor = false;
|
| 45 |
-
if (items.length > 1) resolveAsColor = isColor(items[items.length - 1]);
|
| 46 |
-
let resolvedValue = "";
|
| 47 |
-
for (let item of items) {
|
| 48 |
-
item = item.trim();
|
| 49 |
-
if (REG_FN_VAR.test(item)) {
|
| 50 |
-
const resolvedItem = resolveVar(item, opt);
|
| 51 |
-
if (isString(resolvedItem)) {
|
| 52 |
-
if (!resolveAsColor || isColor(resolvedItem)) resolvedValue = resolvedItem;
|
| 53 |
-
}
|
| 54 |
-
} else if (REG_FN_CALC.test(item)) {
|
| 55 |
-
item = cssCalc(item, opt);
|
| 56 |
-
if (!resolveAsColor || isColor(item)) resolvedValue = item;
|
| 57 |
-
} else if (item && !REG_CSS_WIDE_KEYWORD.test(item)) {
|
| 58 |
-
if (!resolveAsColor || isColor(item)) resolvedValue = item;
|
| 59 |
-
}
|
| 60 |
-
if (resolvedValue) break;
|
| 61 |
-
}
|
| 62 |
-
return [tokens, resolvedValue];
|
| 63 |
-
}
|
| 64 |
-
/**
|
| 65 |
-
* parse tokens
|
| 66 |
-
* @param tokens - CSS tokens
|
| 67 |
-
* @param [opt] - options
|
| 68 |
-
* @returns parsed tokens
|
| 69 |
-
*/
|
| 70 |
-
function parseTokens(tokens, opt = {}) {
|
| 71 |
-
const res = [];
|
| 72 |
-
while (tokens.length) {
|
| 73 |
-
const token = tokens.shift();
|
| 74 |
-
if (!token) break;
|
| 75 |
-
const [type = "", value = ""] = token;
|
| 76 |
-
if (value === "var(") {
|
| 77 |
-
const [, resolvedValue] = resolveCustomProperty(tokens, opt);
|
| 78 |
-
if (!resolvedValue) return new NullObject();
|
| 79 |
-
res.push(resolvedValue);
|
| 80 |
-
} else switch (type) {
|
| 81 |
-
case PAREN_CLOSE:
|
| 82 |
-
if (res.length) if (res[res.length - 1] === " ") res[res.length - 1] = value;
|
| 83 |
-
else res.push(value);
|
| 84 |
-
else res.push(value);
|
| 85 |
-
break;
|
| 86 |
-
case W_SPACE:
|
| 87 |
-
if (res.length) {
|
| 88 |
-
const lastValue = res[res.length - 1];
|
| 89 |
-
if (isString(lastValue) && !lastValue.endsWith("(") && lastValue !== " ") res.push(value);
|
| 90 |
-
}
|
| 91 |
-
break;
|
| 92 |
-
default: if (type !== COMMENT && type !== EOF) res.push(value);
|
| 93 |
-
}
|
| 94 |
-
}
|
| 95 |
-
return res;
|
| 96 |
-
}
|
| 97 |
-
/**
|
| 98 |
-
* resolve CSS var()
|
| 99 |
-
* @param value - CSS value including var()
|
| 100 |
-
* @param [opt] - options
|
| 101 |
-
* @returns resolved value
|
| 102 |
-
*/
|
| 103 |
-
function resolveVar(value, opt = {}) {
|
| 104 |
-
const { format = "" } = opt;
|
| 105 |
-
if (isString(value)) {
|
| 106 |
-
if (!REG_FN_VAR.test(value) || format === "specifiedValue") return value;
|
| 107 |
-
value = value.trim();
|
| 108 |
-
} else throw new TypeError(`${value} is not a string.`);
|
| 109 |
-
const cacheKey = createCacheKey({
|
| 110 |
-
namespace: NAMESPACE,
|
| 111 |
-
name: "resolveVar",
|
| 112 |
-
value
|
| 113 |
-
}, opt);
|
| 114 |
-
const cachedResult = getCache(cacheKey);
|
| 115 |
-
if (cachedResult instanceof CacheItem) {
|
| 116 |
-
if (cachedResult.isNull) return cachedResult;
|
| 117 |
-
return cachedResult.item;
|
| 118 |
-
}
|
| 119 |
-
const values = parseTokens(tokenize({ css: value }), opt);
|
| 120 |
-
if (Array.isArray(values)) {
|
| 121 |
-
let color = values.join("");
|
| 122 |
-
if (REG_FN_CALC.test(color)) color = cssCalc(color, opt);
|
| 123 |
-
setCache(cacheKey, color);
|
| 124 |
-
return color;
|
| 125 |
-
} else {
|
| 126 |
-
setCache(cacheKey, null);
|
| 127 |
-
return new NullObject();
|
| 128 |
-
}
|
| 129 |
-
}
|
| 130 |
-
/**
|
| 131 |
-
* CSS var()
|
| 132 |
-
* @param value - CSS value including var()
|
| 133 |
-
* @param [opt] - options
|
| 134 |
-
* @returns resolved value
|
| 135 |
-
*/
|
| 136 |
-
var cssVar = (value, opt = {}) => {
|
| 137 |
-
const resolvedValue = resolveVar(value, opt);
|
| 138 |
-
if (isString(resolvedValue)) return resolvedValue;
|
| 139 |
-
return "";
|
| 140 |
-
};
|
| 141 |
-
//#endregion
|
| 142 |
-
export { cssVar, resolveVar };
|
| 143 |
-
|
| 144 |
-
//# sourceMappingURL=css-var.js.map
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
node_modules/@asamuzakjp/css-color/dist/esm/js/css-var.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
{"version":3,"file":"css-var.js","names":[],"sources":["../../../src/js/css-var.ts"],"sourcesContent":["/**\n * css-var\n */\n\nimport { CSSToken, TokenType, tokenize } from '@csstools/css-tokenizer';\nimport {\n CacheItem,\n NullObject,\n createCacheKey,\n getCache,\n setCache\n} from './cache';\nimport { isString } from './common';\nimport { cssCalc } from './css-calc';\nimport { isColor } from './util';\nimport { Options } from './typedef';\n\n/* constants */\nimport { FN_VAR, SYN_FN_CALC, SYN_FN_VAR, VAL_SPEC } from './constant';\nconst {\n CloseParen: PAREN_CLOSE,\n Comment: COMMENT,\n EOF,\n Ident: IDENT,\n Whitespace: W_SPACE\n} = TokenType;\nconst NAMESPACE = 'css-var';\n\n/* regexp */\nconst REG_FN_CALC = new RegExp(SYN_FN_CALC);\nconst REG_FN_VAR = new RegExp(SYN_FN_VAR);\nconst REG_CSS_WIDE_KEYWORD = /^(?:inherit|initial|revert(?:-layer)?|unset)$/;\n\n/**\n * resolve custom property\n * @param tokens - CSS tokens\n * @param [opt] - options\n * @returns result - [tokens, resolvedValue]\n */\nexport function resolveCustomProperty(\n tokens: CSSToken[],\n opt: Options = {}\n): [CSSToken[], string] {\n if (!Array.isArray(tokens)) {\n throw new TypeError(`${tokens} is not an array.`);\n }\n const { customProperty = {} } = opt;\n const items: string[] = [];\n while (tokens.length) {\n const token = tokens.shift();\n if (!token) {\n break;\n }\n if (!Array.isArray(token)) {\n throw new TypeError(`${token} is not an array.`);\n }\n const [type, value] = token as [TokenType, string];\n // end of var()\n if (type === PAREN_CLOSE) {\n break;\n }\n // nested var()\n if (value === FN_VAR) {\n const [, item] = resolveCustomProperty(tokens, opt);\n if (item) {\n items.push(item);\n }\n } else if (type === IDENT) {\n if (value.startsWith('--')) {\n let item;\n if (Object.hasOwn(customProperty, value)) {\n item = customProperty[value] as string;\n } else if (typeof customProperty.callback === 'function') {\n item = customProperty.callback(value);\n }\n if (item) {\n items.push(item);\n }\n } else if (value) {\n items.push(value);\n }\n }\n }\n let resolveAsColor = false;\n if (items.length > 1) {\n resolveAsColor = isColor(items[items.length - 1]);\n }\n let resolvedValue = '';\n for (let item of items) {\n item = item.trim();\n if (REG_FN_VAR.test(item)) {\n // recurse resolveVar()\n const resolvedItem = resolveVar(item, opt);\n if (isString(resolvedItem)) {\n if (!resolveAsColor || isColor(resolvedItem)) {\n resolvedValue = resolvedItem;\n }\n }\n } else if (REG_FN_CALC.test(item)) {\n item = cssCalc(item, opt);\n if (!resolveAsColor || isColor(item)) {\n resolvedValue = item;\n }\n } else if (item && !REG_CSS_WIDE_KEYWORD.test(item)) {\n if (!resolveAsColor || isColor(item)) {\n resolvedValue = item;\n }\n }\n if (resolvedValue) {\n break;\n }\n }\n return [tokens, resolvedValue];\n}\n\n/**\n * parse tokens\n * @param tokens - CSS tokens\n * @param [opt] - options\n * @returns parsed tokens\n */\nexport function parseTokens(\n tokens: CSSToken[],\n opt: Options = {}\n): string[] | NullObject {\n const res: string[] = [];\n while (tokens.length) {\n const token = tokens.shift();\n if (!token) break;\n const [type = '', value = ''] = token as [TokenType, string];\n if (value === FN_VAR) {\n const [, resolvedValue] = resolveCustomProperty(tokens, opt);\n if (!resolvedValue) {\n return new NullObject();\n }\n res.push(resolvedValue);\n } else {\n switch (type) {\n case PAREN_CLOSE: {\n if (res.length) {\n if (res[res.length - 1] === ' ') {\n res[res.length - 1] = value;\n } else {\n res.push(value);\n }\n } else {\n res.push(value);\n }\n break;\n }\n case W_SPACE: {\n if (res.length) {\n const lastValue = res[res.length - 1];\n if (\n isString(lastValue) &&\n !lastValue.endsWith('(') &&\n lastValue !== ' '\n ) {\n res.push(value);\n }\n }\n break;\n }\n default: {\n if (type !== COMMENT && type !== EOF) {\n res.push(value);\n }\n }\n }\n }\n }\n return res;\n}\n\n/**\n * resolve CSS var()\n * @param value - CSS value including var()\n * @param [opt] - options\n * @returns resolved value\n */\nexport function resolveVar(\n value: string,\n opt: Options = {}\n): string | NullObject {\n const { format = '' } = opt;\n if (isString(value)) {\n if (!REG_FN_VAR.test(value) || format === VAL_SPEC) {\n return value;\n }\n value = value.trim();\n } else {\n throw new TypeError(`${value} is not a string.`);\n }\n const cacheKey: string = createCacheKey(\n {\n namespace: NAMESPACE,\n name: 'resolveVar',\n value\n },\n opt\n );\n const cachedResult = getCache(cacheKey);\n if (cachedResult instanceof CacheItem) {\n if (cachedResult.isNull) {\n return cachedResult as NullObject;\n }\n return cachedResult.item as string;\n }\n const tokens = tokenize({ css: value });\n const values = parseTokens(tokens, opt);\n if (Array.isArray(values)) {\n let color = values.join('');\n if (REG_FN_CALC.test(color)) {\n color = cssCalc(color, opt);\n }\n setCache(cacheKey, color);\n return color;\n } else {\n setCache(cacheKey, null);\n return new NullObject();\n }\n}\n\n/**\n * CSS var()\n * @param value - CSS value including var()\n * @param [opt] - options\n * @returns resolved value\n */\nexport const cssVar = (value: string, opt: Options = {}): string => {\n const resolvedValue = resolveVar(value, opt);\n if (isString(resolvedValue)) {\n return resolvedValue;\n }\n return '';\n};\n"],"mappings":";;;;;;;;;;AAmBA,IAAM,EACJ,YAAY,aACZ,SAAS,SACT,KACA,OAAO,OACP,YAAY,YACV;AACJ,IAAM,YAAY;AAGlB,IAAM,cAAc,IAAI,OAAO,YAAY;AAC3C,IAAM,aAAa,IAAI,OAAO,WAAW;AACzC,IAAM,uBAAuB;;;;;;;AAQ7B,SAAgB,sBACd,QACA,MAAe,EAAE,EACK;AACtB,KAAI,CAAC,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AAO,CAAC,EACJ,IAAI;AACvC,KAAI,MAAM,QAAQ,OAAO,EAAE;EACzB,IAAI,QAAQ,OAAO,KAAK,GAAG;AAC3B,MAAI,YAAY,KAAK,MAAM,CACzB,SAAQ,QAAQ,OAAO,IAAI;AAE7B,WAAS,UAAU,MAAM;AACzB,SAAO;QACF;AACL,WAAS,UAAU,KAAK;AACxB,SAAO,IAAI,YAAY;;;;;;;;;AAU3B,IAAa,UAAU,OAAe,MAAe,EAAE,KAAa;CAClE,MAAM,gBAAgB,WAAW,OAAO,IAAI;AAC5C,KAAI,SAAS,cAAc,CACzB,QAAO;AAET,QAAO"}
|
|
|
|
|
|
node_modules/@asamuzakjp/css-color/dist/esm/js/relative-color.d.ts
DELETED
|
@@ -1,65 +0,0 @@
|
|
| 1 |
-
import { CSSToken } from '@csstools/css-tokenizer';
|
| 2 |
-
import { NullObject } from './cache.js';
|
| 3 |
-
import { ColorChannels, Options, StringColorChannels } from './typedef.js';
|
| 4 |
-
/**
|
| 5 |
-
* @type NumberOrStringColorChannels - color channel
|
| 6 |
-
*/
|
| 7 |
-
type NumberOrStringColorChannels = ColorChannels & StringColorChannels;
|
| 8 |
-
/**
|
| 9 |
-
* resolve relative color channels
|
| 10 |
-
* @param value
|
| 11 |
-
* - CSS color value
|
| 12 |
-
* - system colors are not supported
|
| 13 |
-
* @param [opt] - options
|
| 14 |
-
* @param [opt.currentColor]
|
| 15 |
-
* - color to use for `currentcolor` keyword
|
| 16 |
-
* - if omitted, it will be treated as a missing color
|
| 17 |
-
* i.e. `rgb(none none none / none)`
|
| 18 |
-
* @param [opt.customProperty]
|
| 19 |
-
* - custom properties
|
| 20 |
-
* - pair of `--` prefixed property name and value,
|
| 21 |
-
* e.g. `customProperty: { '--some-color': '#0000ff' }`
|
| 22 |
-
* - and/or `callback` function to get the value of the custom property,
|
| 23 |
-
* e.g. `customProperty: { callback: someDeclaration.getPropertyValue }`
|
| 24 |
-
* @param [opt.dimension]
|
| 25 |
-
* - dimension, convert relative length to pixels
|
| 26 |
-
* - pair of unit and it's value as a number in pixels,
|
| 27 |
-
* e.g. `dimension: { em: 12, rem: 16, vw: 10.26 }`
|
| 28 |
-
* - and/or `callback` function to get the value as a number in pixels,
|
| 29 |
-
* e.g. `dimension: { callback: convertUnitToPixel }`
|
| 30 |
-
* @param [opt.format]
|
| 31 |
-
* - output format, one of below
|
| 32 |
-
* - `computedValue` (default), [computed value][139] of the color
|
| 33 |
-
* - `specifiedValue`, [specified value][140] of the color
|
| 34 |
-
* - `hex`, hex color notation, i.e. `rrggbb`
|
| 35 |
-
* - `hexAlpha`, hex color notation with alpha channel, i.e. `#rrggbbaa`
|
| 36 |
-
* @returns
|
| 37 |
-
* - one of rgba?(), #rrggbb(aa)?, color-name, '(empty-string)',
|
| 38 |
-
* color(color-space r g b / alpha), color(color-space x y z / alpha),
|
| 39 |
-
* lab(l a b / alpha), lch(l c h / alpha), oklab(l a b / alpha),
|
| 40 |
-
* oklch(l c h / alpha), null
|
| 41 |
-
* - in `computedValue`, values are numbers, however `rgb()` values are
|
| 42 |
-
* integers
|
| 43 |
-
* - in `specifiedValue`, returns `empty string` for unknown and/or invalid
|
| 44 |
-
* color
|
| 45 |
-
* - in `hex`, returns `null` for `transparent`, and also returns `null` if
|
| 46 |
-
* any of `r`, `g`, `b`, `alpha` is not a number
|
| 47 |
-
* - in `hexAlpha`, returns `#00000000` for `transparent`,
|
| 48 |
-
* however returns `null` if any of `r`, `g`, `b`, `alpha` is not a number
|
| 49 |
-
*/
|
| 50 |
-
export declare function resolveColorChannels(tokens: CSSToken[], opt?: Options): NumberOrStringColorChannels | NullObject;
|
| 51 |
-
/**
|
| 52 |
-
* extract origin color
|
| 53 |
-
* @param value - CSS color value
|
| 54 |
-
* @param [opt] - options
|
| 55 |
-
* @returns origin color value
|
| 56 |
-
*/
|
| 57 |
-
export declare function extractOriginColor(value: string, opt?: Options): string | NullObject;
|
| 58 |
-
/**
|
| 59 |
-
* resolve relative color
|
| 60 |
-
* @param value - CSS relative color value
|
| 61 |
-
* @param [opt] - options
|
| 62 |
-
* @returns resolved value
|
| 63 |
-
*/
|
| 64 |
-
export declare function resolveRelativeColor(value: string, opt?: Options): string | NullObject;
|
| 65 |
-
export {};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
node_modules/@asamuzakjp/css-color/dist/esm/js/relative-color.js
DELETED
|
@@ -1,451 +0,0 @@
|
|
| 1 |
-
import { CacheItem, NullObject, createCacheKey, getCache, setCache } from "./cache.js";
|
| 2 |
-
import { isString, isStringOrNumber } from "./common.js";
|
| 3 |
-
import { CS_LAB, CS_LCH, FN_REL, FN_REL_CAPT, FN_VAR, NONE, SYN_COLOR_TYPE, SYN_FN_MATH_START, SYN_FN_VAR, SYN_MIX, VAL_SPEC } from "./constant.js";
|
| 4 |
-
import { NAMED_COLORS, convertColorToRgb } from "./color.js";
|
| 5 |
-
import { resolveColor } from "./resolve.js";
|
| 6 |
-
import { roundToPrecision, splitValue } from "./util.js";
|
| 7 |
-
import { resolveDimension, serializeCalc } from "./css-calc.js";
|
| 8 |
-
import { TokenType, tokenize } from "@csstools/css-tokenizer";
|
| 9 |
-
import { SyntaxFlag, color } from "@csstools/css-color-parser";
|
| 10 |
-
import { parseComponentValue } from "@csstools/css-parser-algorithms";
|
| 11 |
-
//#region src/js/relative-color.ts
|
| 12 |
-
/**
|
| 13 |
-
* relative-color
|
| 14 |
-
*/
|
| 15 |
-
var { CloseParen: PAREN_CLOSE, Comment: COMMENT, Delim: DELIM, Dimension: DIM, EOF, Function: FUNC, Ident: IDENT, Number: NUM, OpenParen: PAREN_OPEN, Percentage: PCT, Whitespace: W_SPACE } = TokenType;
|
| 16 |
-
var { HasNoneKeywords: KEY_NONE } = SyntaxFlag;
|
| 17 |
-
var NAMESPACE = "relative-color";
|
| 18 |
-
var OCT = 8;
|
| 19 |
-
var DEC = 10;
|
| 20 |
-
var HEX = 16;
|
| 21 |
-
var MAX_PCT = 100;
|
| 22 |
-
var MAX_RGB = 255;
|
| 23 |
-
var COLOR_CHANNELS = new Map([
|
| 24 |
-
["color", [
|
| 25 |
-
"r",
|
| 26 |
-
"g",
|
| 27 |
-
"b",
|
| 28 |
-
"alpha"
|
| 29 |
-
]],
|
| 30 |
-
["hsl", [
|
| 31 |
-
"h",
|
| 32 |
-
"s",
|
| 33 |
-
"l",
|
| 34 |
-
"alpha"
|
| 35 |
-
]],
|
| 36 |
-
["hsla", [
|
| 37 |
-
"h",
|
| 38 |
-
"s",
|
| 39 |
-
"l",
|
| 40 |
-
"alpha"
|
| 41 |
-
]],
|
| 42 |
-
["hwb", [
|
| 43 |
-
"h",
|
| 44 |
-
"w",
|
| 45 |
-
"b",
|
| 46 |
-
"alpha"
|
| 47 |
-
]],
|
| 48 |
-
["lab", [
|
| 49 |
-
"l",
|
| 50 |
-
"a",
|
| 51 |
-
"b",
|
| 52 |
-
"alpha"
|
| 53 |
-
]],
|
| 54 |
-
["lch", [
|
| 55 |
-
"l",
|
| 56 |
-
"c",
|
| 57 |
-
"h",
|
| 58 |
-
"alpha"
|
| 59 |
-
]],
|
| 60 |
-
["oklab", [
|
| 61 |
-
"l",
|
| 62 |
-
"a",
|
| 63 |
-
"b",
|
| 64 |
-
"alpha"
|
| 65 |
-
]],
|
| 66 |
-
["oklch", [
|
| 67 |
-
"l",
|
| 68 |
-
"c",
|
| 69 |
-
"h",
|
| 70 |
-
"alpha"
|
| 71 |
-
]],
|
| 72 |
-
["rgb", [
|
| 73 |
-
"r",
|
| 74 |
-
"g",
|
| 75 |
-
"b",
|
| 76 |
-
"alpha"
|
| 77 |
-
]],
|
| 78 |
-
["rgba", [
|
| 79 |
-
"r",
|
| 80 |
-
"g",
|
| 81 |
-
"b",
|
| 82 |
-
"alpha"
|
| 83 |
-
]]
|
| 84 |
-
]);
|
| 85 |
-
var REG_COLOR_CAPT = new RegExp(`^${FN_REL}(${SYN_COLOR_TYPE}|${SYN_MIX})\\s+`);
|
| 86 |
-
var REG_CS_HSL = /(?:hsla?|hwb)$/;
|
| 87 |
-
var REG_CS_CIE = new RegExp(`^(?:${CS_LAB}|${CS_LCH})$`);
|
| 88 |
-
var REG_FN_CALC_SUM = /^(?:abs|sig?n|cos|tan)\(/;
|
| 89 |
-
var REG_FN_MATH_START = new RegExp(SYN_FN_MATH_START);
|
| 90 |
-
var REG_FN_REL = new RegExp(FN_REL);
|
| 91 |
-
var REG_FN_REL_CAPT = new RegExp(`^${FN_REL_CAPT}`);
|
| 92 |
-
var REG_FN_REL_START = new RegExp(`^${FN_REL}`);
|
| 93 |
-
var REG_FN_VAR = new RegExp(SYN_FN_VAR);
|
| 94 |
-
/**
|
| 95 |
-
* resolve relative color channels
|
| 96 |
-
* @param value
|
| 97 |
-
* - CSS color value
|
| 98 |
-
* - system colors are not supported
|
| 99 |
-
* @param [opt] - options
|
| 100 |
-
* @param [opt.currentColor]
|
| 101 |
-
* - color to use for `currentcolor` keyword
|
| 102 |
-
* - if omitted, it will be treated as a missing color
|
| 103 |
-
* i.e. `rgb(none none none / none)`
|
| 104 |
-
* @param [opt.customProperty]
|
| 105 |
-
* - custom properties
|
| 106 |
-
* - pair of `--` prefixed property name and value,
|
| 107 |
-
* e.g. `customProperty: { '--some-color': '#0000ff' }`
|
| 108 |
-
* - and/or `callback` function to get the value of the custom property,
|
| 109 |
-
* e.g. `customProperty: { callback: someDeclaration.getPropertyValue }`
|
| 110 |
-
* @param [opt.dimension]
|
| 111 |
-
* - dimension, convert relative length to pixels
|
| 112 |
-
* - pair of unit and it's value as a number in pixels,
|
| 113 |
-
* e.g. `dimension: { em: 12, rem: 16, vw: 10.26 }`
|
| 114 |
-
* - and/or `callback` function to get the value as a number in pixels,
|
| 115 |
-
* e.g. `dimension: { callback: convertUnitToPixel }`
|
| 116 |
-
* @param [opt.format]
|
| 117 |
-
* - output format, one of below
|
| 118 |
-
* - `computedValue` (default), [computed value][139] of the color
|
| 119 |
-
* - `specifiedValue`, [specified value][140] of the color
|
| 120 |
-
* - `hex`, hex color notation, i.e. `rrggbb`
|
| 121 |
-
* - `hexAlpha`, hex color notation with alpha channel, i.e. `#rrggbbaa`
|
| 122 |
-
* @returns
|
| 123 |
-
* - one of rgba?(), #rrggbb(aa)?, color-name, '(empty-string)',
|
| 124 |
-
* color(color-space r g b / alpha), color(color-space x y z / alpha),
|
| 125 |
-
* lab(l a b / alpha), lch(l c h / alpha), oklab(l a b / alpha),
|
| 126 |
-
* oklch(l c h / alpha), null
|
| 127 |
-
* - in `computedValue`, values are numbers, however `rgb()` values are
|
| 128 |
-
* integers
|
| 129 |
-
* - in `specifiedValue`, returns `empty string` for unknown and/or invalid
|
| 130 |
-
* color
|
| 131 |
-
* - in `hex`, returns `null` for `transparent`, and also returns `null` if
|
| 132 |
-
* any of `r`, `g`, `b`, `alpha` is not a number
|
| 133 |
-
* - in `hexAlpha`, returns `#00000000` for `transparent`,
|
| 134 |
-
* however returns `null` if any of `r`, `g`, `b`, `alpha` is not a number
|
| 135 |
-
*/
|
| 136 |
-
function resolveColorChannels(tokens, opt = {}) {
|
| 137 |
-
if (!Array.isArray(tokens)) throw new TypeError(`${tokens} is not an array.`);
|
| 138 |
-
const { colorSpace = "", format = "" } = opt;
|
| 139 |
-
const colorChannel = COLOR_CHANNELS.get(colorSpace);
|
| 140 |
-
if (!colorChannel) return new NullObject();
|
| 141 |
-
const mathFunc = /* @__PURE__ */ new Set();
|
| 142 |
-
const channels = [
|
| 143 |
-
[],
|
| 144 |
-
[],
|
| 145 |
-
[],
|
| 146 |
-
[]
|
| 147 |
-
];
|
| 148 |
-
let i = 0;
|
| 149 |
-
let nest = 0;
|
| 150 |
-
let func = "";
|
| 151 |
-
let precededPct = false;
|
| 152 |
-
for (const token of tokens) {
|
| 153 |
-
if (!Array.isArray(token)) throw new TypeError(`${token} is not an array.`);
|
| 154 |
-
const [type, value, , , detail] = token;
|
| 155 |
-
const channel = channels[i];
|
| 156 |
-
if (Array.isArray(channel)) switch (type) {
|
| 157 |
-
case DELIM:
|
| 158 |
-
if (func) {
|
| 159 |
-
if ((value === "+" || value === "-") && precededPct && !REG_FN_CALC_SUM.test(func)) return new NullObject();
|
| 160 |
-
precededPct = false;
|
| 161 |
-
channel.push(value);
|
| 162 |
-
}
|
| 163 |
-
break;
|
| 164 |
-
case DIM: {
|
| 165 |
-
if (!func || !REG_FN_CALC_SUM.test(func)) return new NullObject();
|
| 166 |
-
const resolvedValue = resolveDimension(token, opt);
|
| 167 |
-
if (isString(resolvedValue)) channel.push(resolvedValue);
|
| 168 |
-
else channel.push(value);
|
| 169 |
-
break;
|
| 170 |
-
}
|
| 171 |
-
case FUNC:
|
| 172 |
-
channel.push(value);
|
| 173 |
-
func = value;
|
| 174 |
-
nest++;
|
| 175 |
-
if (REG_FN_MATH_START.test(value)) mathFunc.add(nest);
|
| 176 |
-
break;
|
| 177 |
-
case IDENT:
|
| 178 |
-
if (!colorChannel.includes(value)) return new NullObject();
|
| 179 |
-
channel.push(value);
|
| 180 |
-
if (!func) i++;
|
| 181 |
-
break;
|
| 182 |
-
case NUM:
|
| 183 |
-
channel.push(Number(detail?.value));
|
| 184 |
-
if (!func) i++;
|
| 185 |
-
break;
|
| 186 |
-
case PAREN_OPEN:
|
| 187 |
-
channel.push(value);
|
| 188 |
-
nest++;
|
| 189 |
-
break;
|
| 190 |
-
case PAREN_CLOSE:
|
| 191 |
-
if (func) {
|
| 192 |
-
if (channel[channel.length - 1] === " ") channel[channel.length - 1] = value;
|
| 193 |
-
else channel.push(value);
|
| 194 |
-
if (mathFunc.has(nest)) mathFunc.delete(nest);
|
| 195 |
-
nest--;
|
| 196 |
-
if (nest === 0) {
|
| 197 |
-
func = "";
|
| 198 |
-
i++;
|
| 199 |
-
}
|
| 200 |
-
}
|
| 201 |
-
break;
|
| 202 |
-
case PCT:
|
| 203 |
-
if (!func) return new NullObject();
|
| 204 |
-
else if (!REG_FN_CALC_SUM.test(func)) {
|
| 205 |
-
let lastValue;
|
| 206 |
-
for (let j = channel.length - 1; j >= 0; j--) if (channel[j] !== " ") {
|
| 207 |
-
lastValue = channel[j];
|
| 208 |
-
break;
|
| 209 |
-
}
|
| 210 |
-
if (lastValue === "+" || lastValue === "-") return new NullObject();
|
| 211 |
-
else if (lastValue === "*" || lastValue === "/") precededPct = false;
|
| 212 |
-
else precededPct = true;
|
| 213 |
-
}
|
| 214 |
-
channel.push(Number(detail?.value) / MAX_PCT);
|
| 215 |
-
break;
|
| 216 |
-
case W_SPACE:
|
| 217 |
-
if (channel.length && func) {
|
| 218 |
-
const lastValue = channel[channel.length - 1];
|
| 219 |
-
if (typeof lastValue === "number") channel.push(value);
|
| 220 |
-
else if (isString(lastValue) && !lastValue.endsWith("(") && lastValue !== " ") channel.push(value);
|
| 221 |
-
}
|
| 222 |
-
break;
|
| 223 |
-
default: if (type !== COMMENT && type !== EOF && func) channel.push(value);
|
| 224 |
-
}
|
| 225 |
-
}
|
| 226 |
-
const channelValues = [];
|
| 227 |
-
for (const channel of channels) if (channel.length === 1) {
|
| 228 |
-
const [resolvedValue] = channel;
|
| 229 |
-
if (isStringOrNumber(resolvedValue)) channelValues.push(resolvedValue);
|
| 230 |
-
} else if (channel.length) {
|
| 231 |
-
const resolvedValue = serializeCalc(channel.join(""), { format });
|
| 232 |
-
channelValues.push(resolvedValue);
|
| 233 |
-
}
|
| 234 |
-
return channelValues;
|
| 235 |
-
}
|
| 236 |
-
/**
|
| 237 |
-
* extract origin color
|
| 238 |
-
* @param value - CSS color value
|
| 239 |
-
* @param [opt] - options
|
| 240 |
-
* @returns origin color value
|
| 241 |
-
*/
|
| 242 |
-
function extractOriginColor(value, opt = {}) {
|
| 243 |
-
const { colorScheme = "normal", currentColor = "", format = "" } = opt;
|
| 244 |
-
if (isString(value)) {
|
| 245 |
-
value = value.toLowerCase().trim();
|
| 246 |
-
if (!value) return new NullObject();
|
| 247 |
-
if (!REG_FN_REL_START.test(value)) return value;
|
| 248 |
-
} else return new NullObject();
|
| 249 |
-
const cacheKey = createCacheKey({
|
| 250 |
-
namespace: NAMESPACE,
|
| 251 |
-
name: "extractOriginColor",
|
| 252 |
-
value
|
| 253 |
-
}, opt);
|
| 254 |
-
const cachedResult = getCache(cacheKey);
|
| 255 |
-
if (cachedResult instanceof CacheItem) {
|
| 256 |
-
if (cachedResult.isNull) return cachedResult;
|
| 257 |
-
return cachedResult.item;
|
| 258 |
-
}
|
| 259 |
-
if (/currentcolor/.test(value)) if (currentColor) value = value.replace(/currentcolor/g, currentColor);
|
| 260 |
-
else {
|
| 261 |
-
setCache(cacheKey, null);
|
| 262 |
-
return new NullObject();
|
| 263 |
-
}
|
| 264 |
-
let colorSpace = "";
|
| 265 |
-
if (REG_FN_REL_CAPT.test(value)) [, colorSpace] = value.match(REG_FN_REL_CAPT);
|
| 266 |
-
opt.colorSpace = colorSpace;
|
| 267 |
-
if (value.includes("light-dark(")) {
|
| 268 |
-
const [, originColor = ""] = splitValue(value.replace(new RegExp(`^${colorSpace}\\(`), "").replace(/\)$/, ""));
|
| 269 |
-
const specifiedOriginColor = resolveColor(originColor, {
|
| 270 |
-
colorScheme,
|
| 271 |
-
format: VAL_SPEC
|
| 272 |
-
});
|
| 273 |
-
if (specifiedOriginColor === "") {
|
| 274 |
-
setCache(cacheKey, null);
|
| 275 |
-
return new NullObject();
|
| 276 |
-
}
|
| 277 |
-
if (format === "specifiedValue") value = value.replace(originColor, specifiedOriginColor);
|
| 278 |
-
else {
|
| 279 |
-
const resolvedOriginColor = resolveColor(specifiedOriginColor, opt);
|
| 280 |
-
if (isString(resolvedOriginColor)) value = value.replace(originColor, resolvedOriginColor);
|
| 281 |
-
}
|
| 282 |
-
}
|
| 283 |
-
if (REG_COLOR_CAPT.test(value)) {
|
| 284 |
-
const [, originColor] = value.match(REG_COLOR_CAPT);
|
| 285 |
-
const [, restValue] = value.split(originColor);
|
| 286 |
-
if (/^[a-z]+$/.test(originColor)) {
|
| 287 |
-
if (!/^transparent$/.test(originColor) && !Object.hasOwn(NAMED_COLORS, originColor)) {
|
| 288 |
-
setCache(cacheKey, null);
|
| 289 |
-
return new NullObject();
|
| 290 |
-
}
|
| 291 |
-
} else if (format === "specifiedValue") {
|
| 292 |
-
const resolvedOriginColor = resolveColor(originColor, opt);
|
| 293 |
-
if (isString(resolvedOriginColor)) value = value.replace(originColor, resolvedOriginColor);
|
| 294 |
-
}
|
| 295 |
-
if (format === "specifiedValue") {
|
| 296 |
-
const channelValues = resolveColorChannels(tokenize({ css: restValue }), opt);
|
| 297 |
-
if (channelValues instanceof NullObject) {
|
| 298 |
-
setCache(cacheKey, null);
|
| 299 |
-
return channelValues;
|
| 300 |
-
}
|
| 301 |
-
const [v1, v2, v3, v4] = channelValues;
|
| 302 |
-
let channelValue = "";
|
| 303 |
-
if (isStringOrNumber(v4)) channelValue = ` ${v1} ${v2} ${v3} / ${v4})`;
|
| 304 |
-
else channelValue = ` ${channelValues.join(" ")})`;
|
| 305 |
-
if (restValue !== channelValue) value = value.replace(restValue, channelValue);
|
| 306 |
-
}
|
| 307 |
-
} else {
|
| 308 |
-
const [, restValue] = value.split(REG_FN_REL_START);
|
| 309 |
-
const tokens = tokenize({ css: restValue });
|
| 310 |
-
const originColor = [];
|
| 311 |
-
let nest = 0;
|
| 312 |
-
let tokenIndex = 0;
|
| 313 |
-
for (const [type, tokenValue] of tokens) {
|
| 314 |
-
tokenIndex++;
|
| 315 |
-
switch (type) {
|
| 316 |
-
case FUNC:
|
| 317 |
-
case PAREN_OPEN:
|
| 318 |
-
originColor.push(tokenValue);
|
| 319 |
-
nest++;
|
| 320 |
-
break;
|
| 321 |
-
case PAREN_CLOSE: {
|
| 322 |
-
const lastValue = originColor[originColor.length - 1];
|
| 323 |
-
if (lastValue === " ") originColor[originColor.length - 1] = tokenValue;
|
| 324 |
-
else if (isString(lastValue)) originColor.push(tokenValue);
|
| 325 |
-
nest--;
|
| 326 |
-
break;
|
| 327 |
-
}
|
| 328 |
-
case W_SPACE: {
|
| 329 |
-
const lastValue = originColor[originColor.length - 1];
|
| 330 |
-
if (isString(lastValue) && !lastValue.endsWith("(") && lastValue !== " ") originColor.push(tokenValue);
|
| 331 |
-
break;
|
| 332 |
-
}
|
| 333 |
-
default: if (type !== COMMENT && type !== EOF) originColor.push(tokenValue);
|
| 334 |
-
}
|
| 335 |
-
if (nest === 0) break;
|
| 336 |
-
}
|
| 337 |
-
const resolvedOriginColor = resolveRelativeColor(originColor.join("").trim(), opt);
|
| 338 |
-
if (resolvedOriginColor instanceof NullObject) {
|
| 339 |
-
setCache(cacheKey, null);
|
| 340 |
-
return resolvedOriginColor;
|
| 341 |
-
}
|
| 342 |
-
const channelValues = resolveColorChannels(tokens.slice(tokenIndex), opt);
|
| 343 |
-
if (channelValues instanceof NullObject) {
|
| 344 |
-
setCache(cacheKey, null);
|
| 345 |
-
return channelValues;
|
| 346 |
-
}
|
| 347 |
-
const [v1, v2, v3, v4] = channelValues;
|
| 348 |
-
let channelValue = "";
|
| 349 |
-
if (isStringOrNumber(v4)) channelValue = ` ${v1} ${v2} ${v3} / ${v4})`;
|
| 350 |
-
else channelValue = ` ${channelValues.join(" ")})`;
|
| 351 |
-
value = value.replace(restValue, `${resolvedOriginColor}${channelValue}`);
|
| 352 |
-
}
|
| 353 |
-
setCache(cacheKey, value);
|
| 354 |
-
return value;
|
| 355 |
-
}
|
| 356 |
-
/**
|
| 357 |
-
* resolve relative color
|
| 358 |
-
* @param value - CSS relative color value
|
| 359 |
-
* @param [opt] - options
|
| 360 |
-
* @returns resolved value
|
| 361 |
-
*/
|
| 362 |
-
function resolveRelativeColor(value, opt = {}) {
|
| 363 |
-
const { format = "" } = opt;
|
| 364 |
-
if (isString(value)) {
|
| 365 |
-
if (REG_FN_VAR.test(value)) {
|
| 366 |
-
if (format !== "specifiedValue") throw new SyntaxError(`Unexpected token ${FN_VAR} found.`);
|
| 367 |
-
return value;
|
| 368 |
-
} else if (!REG_FN_REL.test(value)) return value;
|
| 369 |
-
value = value.toLowerCase().trim();
|
| 370 |
-
} else throw new TypeError(`${value} is not a string.`);
|
| 371 |
-
const cacheKey = createCacheKey({
|
| 372 |
-
namespace: NAMESPACE,
|
| 373 |
-
name: "resolveRelativeColor",
|
| 374 |
-
value
|
| 375 |
-
}, opt);
|
| 376 |
-
const cachedResult = getCache(cacheKey);
|
| 377 |
-
if (cachedResult instanceof CacheItem) {
|
| 378 |
-
if (cachedResult.isNull) return cachedResult;
|
| 379 |
-
return cachedResult.item;
|
| 380 |
-
}
|
| 381 |
-
const originColor = extractOriginColor(value, opt);
|
| 382 |
-
if (originColor instanceof NullObject) {
|
| 383 |
-
setCache(cacheKey, null);
|
| 384 |
-
return originColor;
|
| 385 |
-
}
|
| 386 |
-
value = originColor;
|
| 387 |
-
if (format === "specifiedValue") {
|
| 388 |
-
if (value.startsWith("rgba(")) value = value.replace("rgba(", "rgb(");
|
| 389 |
-
else if (value.startsWith("hsla(")) value = value.replace("hsla(", "hsl(");
|
| 390 |
-
return value;
|
| 391 |
-
}
|
| 392 |
-
const parsedComponents = color(parseComponentValue(tokenize({ css: value })));
|
| 393 |
-
if (!parsedComponents) {
|
| 394 |
-
setCache(cacheKey, null);
|
| 395 |
-
return new NullObject();
|
| 396 |
-
}
|
| 397 |
-
const { alpha: alphaComponent, channels: channelsComponent, colorNotation, syntaxFlags } = parsedComponents;
|
| 398 |
-
let alpha;
|
| 399 |
-
if (Number.isNaN(Number(alphaComponent))) if (syntaxFlags instanceof Set && syntaxFlags.has(KEY_NONE)) alpha = NONE;
|
| 400 |
-
else alpha = 0;
|
| 401 |
-
else alpha = roundToPrecision(Number(alphaComponent), OCT);
|
| 402 |
-
let v1;
|
| 403 |
-
let v2;
|
| 404 |
-
let v3;
|
| 405 |
-
[v1, v2, v3] = channelsComponent;
|
| 406 |
-
let resolvedValue;
|
| 407 |
-
if (REG_CS_CIE.test(colorNotation)) {
|
| 408 |
-
const hasNone = syntaxFlags instanceof Set && syntaxFlags.has(KEY_NONE);
|
| 409 |
-
if (Number.isNaN(v1)) if (hasNone) v1 = NONE;
|
| 410 |
-
else v1 = 0;
|
| 411 |
-
else v1 = roundToPrecision(v1, HEX);
|
| 412 |
-
if (Number.isNaN(v2)) if (hasNone) v2 = NONE;
|
| 413 |
-
else v2 = 0;
|
| 414 |
-
else v2 = roundToPrecision(v2, HEX);
|
| 415 |
-
if (Number.isNaN(v3)) if (hasNone) v3 = NONE;
|
| 416 |
-
else v3 = 0;
|
| 417 |
-
else v3 = roundToPrecision(v3, HEX);
|
| 418 |
-
if (alpha === 1) resolvedValue = `${colorNotation}(${v1} ${v2} ${v3})`;
|
| 419 |
-
else resolvedValue = `${colorNotation}(${v1} ${v2} ${v3} / ${alpha})`;
|
| 420 |
-
} else if (REG_CS_HSL.test(colorNotation)) {
|
| 421 |
-
if (Number.isNaN(v1)) v1 = 0;
|
| 422 |
-
if (Number.isNaN(v2)) v2 = 0;
|
| 423 |
-
if (Number.isNaN(v3)) v3 = 0;
|
| 424 |
-
let [r, g, b] = convertColorToRgb(`${colorNotation}(${v1} ${v2} ${v3} / ${alpha})`);
|
| 425 |
-
r = roundToPrecision(r / MAX_RGB, DEC);
|
| 426 |
-
g = roundToPrecision(g / MAX_RGB, DEC);
|
| 427 |
-
b = roundToPrecision(b / MAX_RGB, DEC);
|
| 428 |
-
if (alpha === 1) resolvedValue = `color(srgb ${r} ${g} ${b})`;
|
| 429 |
-
else resolvedValue = `color(srgb ${r} ${g} ${b} / ${alpha})`;
|
| 430 |
-
} else {
|
| 431 |
-
const cs = colorNotation === "rgb" ? "srgb" : colorNotation;
|
| 432 |
-
const hasNone = syntaxFlags instanceof Set && syntaxFlags.has(KEY_NONE);
|
| 433 |
-
if (Number.isNaN(v1)) if (hasNone) v1 = NONE;
|
| 434 |
-
else v1 = 0;
|
| 435 |
-
else v1 = roundToPrecision(v1, DEC);
|
| 436 |
-
if (Number.isNaN(v2)) if (hasNone) v2 = NONE;
|
| 437 |
-
else v2 = 0;
|
| 438 |
-
else v2 = roundToPrecision(v2, DEC);
|
| 439 |
-
if (Number.isNaN(v3)) if (hasNone) v3 = NONE;
|
| 440 |
-
else v3 = 0;
|
| 441 |
-
else v3 = roundToPrecision(v3, DEC);
|
| 442 |
-
if (alpha === 1) resolvedValue = `color(${cs} ${v1} ${v2} ${v3})`;
|
| 443 |
-
else resolvedValue = `color(${cs} ${v1} ${v2} ${v3} / ${alpha})`;
|
| 444 |
-
}
|
| 445 |
-
setCache(cacheKey, resolvedValue);
|
| 446 |
-
return resolvedValue;
|
| 447 |
-
}
|
| 448 |
-
//#endregion
|
| 449 |
-
export { resolveRelativeColor };
|
| 450 |
-
|
| 451 |
-
//# sourceMappingURL=relative-color.js.map
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
node_modules/@asamuzakjp/css-color/dist/esm/js/relative-color.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
{"version":3,"file":"relative-color.js","names":[],"sources":["../../../src/js/relative-color.ts"],"sourcesContent":["/**\n * relative-color\n */\n\nimport { SyntaxFlag, color as colorParser } from '@csstools/css-color-parser';\nimport {\n ComponentValue,\n parseComponentValue\n} from '@csstools/css-parser-algorithms';\nimport { CSSToken, TokenType, tokenize } from '@csstools/css-tokenizer';\nimport {\n CacheItem,\n NullObject,\n createCacheKey,\n getCache,\n setCache\n} from './cache';\nimport { NAMED_COLORS, convertColorToRgb } from './color';\nimport { isString, isStringOrNumber } from './common';\nimport { resolveDimension, serializeCalc } from './css-calc';\nimport { resolveColor } from './resolve';\nimport { roundToPrecision, splitValue } from './util';\nimport {\n ColorChannels,\n MatchedRegExp,\n Options,\n StringColorChannels\n} from './typedef';\n\n/* constants */\nimport {\n CS_LAB,\n CS_LCH,\n FN_LIGHT_DARK,\n FN_REL,\n FN_REL_CAPT,\n FN_VAR,\n NONE,\n SYN_COLOR_TYPE,\n SYN_FN_MATH_START,\n SYN_FN_VAR,\n SYN_MIX,\n VAL_SPEC\n} from './constant';\nconst {\n CloseParen: PAREN_CLOSE,\n Comment: COMMENT,\n Delim: DELIM,\n Dimension: DIM,\n EOF,\n Function: FUNC,\n Ident: IDENT,\n Number: NUM,\n OpenParen: PAREN_OPEN,\n Percentage: PCT,\n Whitespace: W_SPACE\n} = TokenType;\nconst { HasNoneKeywords: KEY_NONE } = SyntaxFlag;\nconst NAMESPACE = 'relative-color';\n\n/* constants */\nconst OCT = 8;\nconst DEC = 10;\nconst HEX = 16;\nconst MAX_PCT = 100;\nconst MAX_RGB = 255;\nconst COLOR_CHANNELS = new Map([\n ['color', ['r', 'g', 'b', 'alpha']],\n ['hsl', ['h', 's', 'l', 'alpha']],\n ['hsla', ['h', 's', 'l', 'alpha']],\n ['hwb', ['h', 'w', 'b', 'alpha']],\n ['lab', ['l', 'a', 'b', 'alpha']],\n ['lch', ['l', 'c', 'h', 'alpha']],\n ['oklab', ['l', 'a', 'b', 'alpha']],\n ['oklch', ['l', 'c', 'h', 'alpha']],\n ['rgb', ['r', 'g', 'b', 'alpha']],\n ['rgba', ['r', 'g', 'b', 'alpha']]\n]);\n\n/* type definitions */\n/**\n * @type NumberOrStringColorChannels - color channel\n */\ntype NumberOrStringColorChannels = ColorChannels & StringColorChannels;\n\n/* regexp */\nconst REG_COLOR_CAPT = new RegExp(\n `^${FN_REL}(${SYN_COLOR_TYPE}|${SYN_MIX})\\\\s+`\n);\nconst REG_CS_HSL = /(?:hsla?|hwb)$/;\nconst REG_CS_CIE = new RegExp(`^(?:${CS_LAB}|${CS_LCH})$`);\nconst REG_FN_CALC_SUM = /^(?:abs|sig?n|cos|tan)\\(/;\nconst REG_FN_MATH_START = new RegExp(SYN_FN_MATH_START);\nconst REG_FN_REL = new RegExp(FN_REL);\nconst REG_FN_REL_CAPT = new RegExp(`^${FN_REL_CAPT}`);\nconst REG_FN_REL_START = new RegExp(`^${FN_REL}`);\nconst REG_FN_VAR = new RegExp(SYN_FN_VAR);\n\n/**\n * resolve relative color channels\n * @param value\n * - CSS color value\n * - system colors are not supported\n * @param [opt] - options\n * @param [opt.currentColor]\n * - color to use for `currentcolor` keyword\n * - if omitted, it will be treated as a missing color\n * i.e. `rgb(none none none / none)`\n * @param [opt.customProperty]\n * - custom properties\n * - pair of `--` prefixed property name and value,\n * e.g. `customProperty: { '--some-color': '#0000ff' }`\n * - and/or `callback` function to get the value of the custom property,\n * e.g. `customProperty: { callback: someDeclaration.getPropertyValue }`\n * @param [opt.dimension]\n * - dimension, convert relative length to pixels\n * - pair of unit and it's value as a number in pixels,\n * e.g. `dimension: { em: 12, rem: 16, vw: 10.26 }`\n * - and/or `callback` function to get the value as a number in pixels,\n * e.g. `dimension: { callback: convertUnitToPixel }`\n * @param [opt.format]\n * - output format, one of below\n * - `computedValue` (default), [computed value][139] of the color\n * - `specifiedValue`, [specified value][140] of the color\n * - `hex`, hex color notation, i.e. `rrggbb`\n * - `hexAlpha`, hex color notation with alpha channel, i.e. `#rrggbbaa`\n * @returns\n * - one of rgba?(), #rrggbb(aa)?, color-name, '(empty-string)',\n * color(color-space r g b / alpha), color(color-space x y z / alpha),\n * lab(l a b / alpha), lch(l c h / alpha), oklab(l a b / alpha),\n * oklch(l c h / alpha), null\n * - in `computedValue`, values are numbers, however `rgb()` values are\n * integers\n * - in `specifiedValue`, returns `empty string` for unknown and/or invalid\n * color\n * - in `hex`, returns `null` for `transparent`, and also returns `null` if\n * any of `r`, `g`, `b`, `alpha` is not a number\n * - in `hexAlpha`, returns `#00000000` for `transparent`,\n * however returns `null` if any of `r`, `g`, `b`, `alpha` is not a number\n */\nexport function resolveColorChannels(\n tokens: CSSToken[],\n opt: Options = {}\n): NumberOrStringColorChannels | NullObject {\n if (!Array.isArray(tokens)) {\n throw new TypeError(`${tokens} is not an array.`);\n }\n const { colorSpace = '', format = '' } = opt;\n const colorChannel = COLOR_CHANNELS.get(colorSpace);\n // invalid color channel\n if (!colorChannel) {\n return new NullObject();\n }\n const mathFunc = new Set();\n const channels: [\n (number | string)[],\n (number | string)[],\n (number | string)[],\n (number | string)[]\n ] = [[], [], [], []];\n let i = 0;\n let nest = 0;\n let func = '';\n let precededPct = false;\n for (const token of tokens) {\n if (!Array.isArray(token)) {\n throw new TypeError(`${token} is not an array.`);\n }\n const [type, value, , , detail] = token as [\n TokenType,\n string,\n number,\n number,\n { value: string | number } | undefined\n ];\n const channel = channels[i];\n if (Array.isArray(channel)) {\n switch (type) {\n case DELIM: {\n if (func) {\n if (\n (value === '+' || value === '-') &&\n precededPct &&\n !REG_FN_CALC_SUM.test(func)\n ) {\n return new NullObject();\n }\n precededPct = false;\n channel.push(value);\n }\n break;\n }\n case DIM: {\n if (!func || !REG_FN_CALC_SUM.test(func)) {\n return new NullObject();\n }\n const resolvedValue = resolveDimension(token, opt);\n if (isString(resolvedValue)) {\n channel.push(resolvedValue);\n } else {\n channel.push(value);\n }\n break;\n }\n case FUNC: {\n channel.push(value);\n func = value;\n nest++;\n if (REG_FN_MATH_START.test(value)) {\n mathFunc.add(nest);\n }\n break;\n }\n case IDENT: {\n // invalid channel key\n if (!colorChannel.includes(value)) {\n return new NullObject();\n }\n channel.push(value);\n if (!func) {\n i++;\n }\n break;\n }\n case NUM: {\n channel.push(Number(detail?.value));\n if (!func) {\n i++;\n }\n break;\n }\n case PAREN_OPEN: {\n channel.push(value);\n nest++;\n break;\n }\n case PAREN_CLOSE: {\n if (func) {\n const lastValue = channel[channel.length - 1];\n if (lastValue === ' ') {\n channel[channel.length - 1] = value;\n } else {\n channel.push(value);\n }\n if (mathFunc.has(nest)) {\n mathFunc.delete(nest);\n }\n nest--;\n if (nest === 0) {\n func = '';\n i++;\n }\n }\n break;\n }\n case PCT: {\n if (!func) {\n return new NullObject();\n } else if (!REG_FN_CALC_SUM.test(func)) {\n let lastValue: string | number | undefined;\n for (let j = channel.length - 1; j >= 0; j--) {\n if (channel[j] !== ' ') {\n lastValue = channel[j];\n break;\n }\n }\n if (lastValue === '+' || lastValue === '-') {\n return new NullObject();\n } else if (lastValue === '*' || lastValue === '/') {\n precededPct = false;\n } else {\n precededPct = true;\n }\n }\n channel.push(Number(detail?.value) / MAX_PCT);\n break;\n }\n case W_SPACE: {\n if (channel.length && func) {\n const lastValue = channel[channel.length - 1];\n if (typeof lastValue === 'number') {\n channel.push(value);\n } else if (\n isString(lastValue) &&\n !lastValue.endsWith('(') &&\n lastValue !== ' '\n ) {\n channel.push(value);\n }\n }\n break;\n }\n default: {\n if (type !== COMMENT && type !== EOF && func) {\n channel.push(value);\n }\n }\n }\n }\n }\n const channelValues = [];\n for (const channel of channels) {\n if (channel.length === 1) {\n const [resolvedValue] = channel;\n if (isStringOrNumber(resolvedValue)) {\n channelValues.push(resolvedValue);\n }\n } else if (channel.length) {\n const resolvedValue = serializeCalc(channel.join(''), {\n format\n });\n channelValues.push(resolvedValue);\n }\n }\n return channelValues as NumberOrStringColorChannels;\n}\n\n/**\n * extract origin color\n * @param value - CSS color value\n * @param [opt] - options\n * @returns origin color value\n */\nexport function extractOriginColor(\n value: string,\n opt: Options = {}\n): string | NullObject {\n const { colorScheme = 'normal', currentColor = '', format = '' } = opt;\n if (isString(value)) {\n value = value.toLowerCase().trim();\n if (!value) {\n return new NullObject();\n }\n if (!REG_FN_REL_START.test(value)) {\n return value;\n }\n } else {\n return new NullObject();\n }\n const cacheKey: string = createCacheKey(\n {\n namespace: NAMESPACE,\n name: 'extractOriginColor',\n value\n },\n opt\n );\n const cachedResult = getCache(cacheKey);\n if (cachedResult instanceof CacheItem) {\n if (cachedResult.isNull) {\n return cachedResult as NullObject;\n }\n return cachedResult.item as string;\n }\n if (/currentcolor/.test(value)) {\n if (currentColor) {\n value = value.replace(/currentcolor/g, currentColor);\n } else {\n setCache(cacheKey, null);\n return new NullObject();\n }\n }\n let colorSpace = '';\n if (REG_FN_REL_CAPT.test(value)) {\n [, colorSpace] = value.match(REG_FN_REL_CAPT) as MatchedRegExp;\n }\n opt.colorSpace = colorSpace;\n if (value.includes(FN_LIGHT_DARK)) {\n const colorParts = value\n .replace(new RegExp(`^${colorSpace}\\\\(`), '')\n .replace(/\\)$/, '');\n const [, originColor = ''] = splitValue(colorParts);\n const specifiedOriginColor = resolveColor(originColor, {\n colorScheme,\n format: VAL_SPEC\n }) as string;\n if (specifiedOriginColor === '') {\n setCache(cacheKey, null);\n return new NullObject();\n }\n if (format === VAL_SPEC) {\n value = value.replace(originColor, specifiedOriginColor);\n } else {\n const resolvedOriginColor = resolveColor(specifiedOriginColor, opt);\n if (isString(resolvedOriginColor)) {\n value = value.replace(originColor, resolvedOriginColor);\n }\n }\n }\n if (REG_COLOR_CAPT.test(value)) {\n const [, originColor] = value.match(REG_COLOR_CAPT) as MatchedRegExp;\n const [, restValue] = value.split(originColor) as MatchedRegExp;\n if (/^[a-z]+$/.test(originColor)) {\n if (\n !/^transparent$/.test(originColor) &&\n !Object.hasOwn(NAMED_COLORS, originColor)\n ) {\n setCache(cacheKey, null);\n return new NullObject();\n }\n } else if (format === VAL_SPEC) {\n const resolvedOriginColor = resolveColor(originColor, opt);\n if (isString(resolvedOriginColor)) {\n value = value.replace(originColor, resolvedOriginColor);\n }\n }\n if (format === VAL_SPEC) {\n const tokens = tokenize({ css: restValue });\n const channelValues = resolveColorChannels(tokens, opt);\n if (channelValues instanceof NullObject) {\n setCache(cacheKey, null);\n return channelValues;\n }\n const [v1, v2, v3, v4] = channelValues;\n let channelValue = '';\n if (isStringOrNumber(v4)) {\n channelValue = ` ${v1} ${v2} ${v3} / ${v4})`;\n } else {\n channelValue = ` ${channelValues.join(' ')})`;\n }\n if (restValue !== channelValue) {\n value = value.replace(restValue, channelValue);\n }\n }\n } else {\n // nested relative color\n const [, restValue] = value.split(REG_FN_REL_START) as MatchedRegExp;\n const tokens = tokenize({ css: restValue });\n const originColor: string[] = [];\n let nest = 0;\n let tokenIndex = 0;\n for (const [type, tokenValue] of tokens) {\n tokenIndex++;\n switch (type) {\n case FUNC:\n case PAREN_OPEN: {\n originColor.push(tokenValue);\n nest++;\n break;\n }\n case PAREN_CLOSE: {\n const lastValue = originColor[originColor.length - 1];\n if (lastValue === ' ') {\n originColor[originColor.length - 1] = tokenValue;\n } else if (isString(lastValue)) {\n originColor.push(tokenValue);\n }\n nest--;\n break;\n }\n case W_SPACE: {\n const lastValue = originColor[originColor.length - 1];\n if (\n isString(lastValue) &&\n !lastValue.endsWith('(') &&\n lastValue !== ' '\n ) {\n originColor.push(tokenValue);\n }\n break;\n }\n default: {\n if (type !== COMMENT && type !== EOF) {\n originColor.push(tokenValue);\n }\n }\n }\n if (nest === 0) {\n break;\n }\n }\n const resolvedOriginColor = resolveRelativeColor(\n originColor.join('').trim(),\n opt\n );\n if (resolvedOriginColor instanceof NullObject) {\n setCache(cacheKey, null);\n return resolvedOriginColor;\n }\n const channelValues = resolveColorChannels(tokens.slice(tokenIndex), opt);\n if (channelValues instanceof NullObject) {\n setCache(cacheKey, null);\n return channelValues;\n }\n const [v1, v2, v3, v4] = channelValues;\n let channelValue = '';\n if (isStringOrNumber(v4)) {\n channelValue = ` ${v1} ${v2} ${v3} / ${v4})`;\n } else {\n channelValue = ` ${channelValues.join(' ')})`;\n }\n value = value.replace(restValue, `${resolvedOriginColor}${channelValue}`);\n }\n setCache(cacheKey, value);\n return value;\n}\n\n/**\n * resolve relative color\n * @param value - CSS relative color value\n * @param [opt] - options\n * @returns resolved value\n */\nexport function resolveRelativeColor(\n value: string,\n opt: Options = {}\n): string | NullObject {\n const { format = '' } = opt;\n if (isString(value)) {\n if (REG_FN_VAR.test(value)) {\n // var() must be resolved before resolveRelativeColor()\n if (format !== VAL_SPEC) {\n throw new SyntaxError(`Unexpected token ${FN_VAR} found.`);\n }\n return value;\n } else if (!REG_FN_REL.test(value)) {\n return value;\n }\n value = value.toLowerCase().trim();\n } else {\n throw new TypeError(`${value} is not a string.`);\n }\n const cacheKey: string = createCacheKey(\n {\n namespace: NAMESPACE,\n name: 'resolveRelativeColor',\n value\n },\n opt\n );\n const cachedResult = getCache(cacheKey);\n if (cachedResult instanceof CacheItem) {\n if (cachedResult.isNull) {\n return cachedResult as NullObject;\n }\n return cachedResult.item as string;\n }\n const originColor = extractOriginColor(value, opt);\n if (originColor instanceof NullObject) {\n setCache(cacheKey, null);\n return originColor;\n }\n value = originColor;\n if (format === VAL_SPEC) {\n if (value.startsWith('rgba(')) {\n value = value.replace('rgba(', 'rgb(');\n } else if (value.startsWith('hsla(')) {\n value = value.replace('hsla(', 'hsl(');\n }\n return value;\n }\n const tokens = tokenize({ css: value });\n const components = parseComponentValue(tokens) as ComponentValue;\n const parsedComponents = colorParser(components);\n if (!parsedComponents) {\n setCache(cacheKey, null);\n return new NullObject();\n }\n const {\n alpha: alphaComponent,\n channels: channelsComponent,\n colorNotation,\n syntaxFlags\n } = parsedComponents;\n let alpha: number | string;\n if (Number.isNaN(Number(alphaComponent))) {\n if (syntaxFlags instanceof Set && syntaxFlags.has(KEY_NONE)) {\n alpha = NONE;\n } else {\n alpha = 0;\n }\n } else {\n alpha = roundToPrecision(Number(alphaComponent), OCT);\n }\n let v1: number | string;\n let v2: number | string;\n let v3: number | string;\n [v1, v2, v3] = channelsComponent;\n let resolvedValue;\n if (REG_CS_CIE.test(colorNotation)) {\n const hasNone = syntaxFlags instanceof Set && syntaxFlags.has(KEY_NONE);\n if (Number.isNaN(v1)) {\n if (hasNone) {\n v1 = NONE;\n } else {\n v1 = 0;\n }\n } else {\n v1 = roundToPrecision(v1, HEX);\n }\n if (Number.isNaN(v2)) {\n if (hasNone) {\n v2 = NONE;\n } else {\n v2 = 0;\n }\n } else {\n v2 = roundToPrecision(v2, HEX);\n }\n if (Number.isNaN(v3)) {\n if (hasNone) {\n v3 = NONE;\n } else {\n v3 = 0;\n }\n } else {\n v3 = roundToPrecision(v3, HEX);\n }\n if (alpha === 1) {\n resolvedValue = `${colorNotation}(${v1} ${v2} ${v3})`;\n } else {\n resolvedValue = `${colorNotation}(${v1} ${v2} ${v3} / ${alpha})`;\n }\n } else if (REG_CS_HSL.test(colorNotation)) {\n if (Number.isNaN(v1)) {\n v1 = 0;\n }\n if (Number.isNaN(v2)) {\n v2 = 0;\n }\n if (Number.isNaN(v3)) {\n v3 = 0;\n }\n let [r, g, b] = convertColorToRgb(\n `${colorNotation}(${v1} ${v2} ${v3} / ${alpha})`\n ) as ColorChannels;\n r = roundToPrecision(r / MAX_RGB, DEC);\n g = roundToPrecision(g / MAX_RGB, DEC);\n b = roundToPrecision(b / MAX_RGB, DEC);\n if (alpha === 1) {\n resolvedValue = `color(srgb ${r} ${g} ${b})`;\n } else {\n resolvedValue = `color(srgb ${r} ${g} ${b} / ${alpha})`;\n }\n } else {\n const cs = colorNotation === 'rgb' ? 'srgb' : colorNotation;\n const hasNone = syntaxFlags instanceof Set && syntaxFlags.has(KEY_NONE);\n if (Number.isNaN(v1)) {\n if (hasNone) {\n v1 = NONE;\n } else {\n v1 = 0;\n }\n } else {\n v1 = roundToPrecision(v1, DEC);\n }\n if (Number.isNaN(v2)) {\n if (hasNone) {\n v2 = NONE;\n } else {\n v2 = 0;\n }\n } else {\n v2 = roundToPrecision(v2, DEC);\n }\n if (Number.isNaN(v3)) {\n if (hasNone) {\n v3 = NONE;\n } else {\n v3 = 0;\n }\n } else {\n v3 = roundToPrecision(v3, DEC);\n }\n if (alpha === 1) {\n resolvedValue = `color(${cs} ${v1} ${v2} ${v3})`;\n } else {\n resolvedValue = `color(${cs} ${v1} ${v2} ${v3} / ${alpha})`;\n }\n }\n setCache(cacheKey, resolvedValue);\n return resolvedValue;\n}\n"],"mappings":";;;;;;;;;;;;;;AA4CA,IAAM,EACJ,YAAY,aACZ,SAAS,SACT,OAAO,OACP,WAAW,KACX,KACA,UAAU,MACV,OAAO,OACP,QAAQ,KACR,WAAW,YACX,YAAY,KACZ,YAAY,YACV;AACJ,IAAM,EAAE,iBAAiB,aAAa;AACtC,IAAM,YAAY;AAGlB,IAAM,MAAM;AACZ,IAAM,MAAM;AACZ,IAAM,MAAM;AACZ,IAAM,UAAU;AAChB,IAAM,UAAU;AAChB,IAAM,iBAAiB,IAAI,IAAI;CAC7B,CAAC,SAAS;EAAC;EAAK;EAAK;EAAK;EAAQ,CAAC;CACnC,CAAC,OAAO;EAAC;EAAK;EAAK;EAAK;EAAQ,CAAC;CACjC,CAAC,QAAQ;EAAC;EAAK;EAAK;EA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ClB,MAAK;EAEP,IAAI,CAAC,GAAG,GAAG,KAAK,kBACd,GAAG,cAAc,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,KAAK,MAAM,GAC/C;AACD,MAAI,iBAAiB,IAAI,SAAS,IAAI;AACtC,MAAI,iBAAiB,IAAI,SAAS,IAAI;AACtC,MAAI,iBAAiB,IAAI,SAAS,IAAI;AACtC,MAAI,UAAU,EACZ,iBAAgB,cAAc,EAAE,GAAG,EAAE,GAAG,EAAE;MAE1C,iBAAgB,cAAc,EAAE,GAAG,EAAE,GAAG,EAAE,KAAK,MAAM;QAElD;EACL,MAAM,KAAK,kBAAkB,QAAQ,SAAS;EAC9C,MAAM,UAAU,uBAAuB,OAAO,YAAY,IAAI,SAAS;AACvE,MAAI,OAAO,MAAM,GAAG,CAClB,KAAI,QACF,MAAK;MAEL,MAAK;MAGP,MAAK,iBAAiB,IAAI,IAAI;AAEhC,MAAI,OAAO,MAAM,GAAG,CAClB,KAAI,QACF,MAAK;MAEL,MAAK;MAGP,MAAK,iBAAiB,IAAI,IAAI;AAEhC,MAAI,OAAO,MAAM,GAAG,CAClB,KAAI,QACF,MAAK;MAEL,MAAK;MAGP,MAAK,iBAAiB,IAAI,IAAI;AAEhC,MAAI,UAAU,EACZ,iBAAgB,SAAS,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG;MAE9C,iBAAgB,SAAS,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,KAAK,MAAM;;AAG7D,UAAS,UAAU,cAAc;AACjC,QAAO"}
|
|
|
|
|
|
node_modules/@asamuzakjp/css-color/dist/esm/js/resolve.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
| 1 |
-
import { NullObject } from './cache.js';
|
| 2 |
-
import { Options } from './typedef.js';
|
| 3 |
-
/**
|
| 4 |
-
* resolve color
|
| 5 |
-
* @param value - CSS color value
|
| 6 |
-
* @param [opt] - options
|
| 7 |
-
* @returns resolved color
|
| 8 |
-
*/
|
| 9 |
-
export declare const resolveColor: (value: string, opt?: Options) => string | NullObject;
|
| 10 |
-
/**
|
| 11 |
-
* resolve CSS color
|
| 12 |
-
* @param value - CSS color value. system colors are not supported
|
| 13 |
-
* @param [opt] - options
|
| 14 |
-
*/
|
| 15 |
-
export declare const resolve: (value: string, opt?: Options) => string | null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
node_modules/@asamuzakjp/css-color/dist/esm/js/resolve.js
DELETED
|
@@ -1,210 +0,0 @@
|
|
| 1 |
-
import { CacheItem, NullObject, createCacheKey, getCache, setCache } from "./cache.js";
|
| 2 |
-
import { isString } from "./common.js";
|
| 3 |
-
import { SYN_FN_CALC, SYN_FN_LIGHT_DARK, SYN_FN_REL, SYN_FN_VAR, VAL_COMP, VAL_SPEC } from "./constant.js";
|
| 4 |
-
import { convertRgbToHex, resolveColorFunc, resolveColorMix, resolveColorValue } from "./color.js";
|
| 5 |
-
import { resolveRelativeColor } from "./relative-color.js";
|
| 6 |
-
import { splitValue } from "./util.js";
|
| 7 |
-
import { resolveVar } from "./css-var.js";
|
| 8 |
-
import { cssCalc } from "./css-calc.js";
|
| 9 |
-
//#region src/js/resolve.ts
|
| 10 |
-
/**
|
| 11 |
-
* resolve
|
| 12 |
-
*/
|
| 13 |
-
var NAMESPACE = "resolve";
|
| 14 |
-
var RGB_TRANSPARENT = "rgba(0, 0, 0, 0)";
|
| 15 |
-
var REG_FN_CALC = new RegExp(SYN_FN_CALC);
|
| 16 |
-
var REG_FN_LIGHT_DARK = new RegExp(SYN_FN_LIGHT_DARK);
|
| 17 |
-
var REG_FN_REL = new RegExp(SYN_FN_REL);
|
| 18 |
-
var REG_FN_VAR = new RegExp(SYN_FN_VAR);
|
| 19 |
-
/**
|
| 20 |
-
* resolve color
|
| 21 |
-
* @param value - CSS color value
|
| 22 |
-
* @param [opt] - options
|
| 23 |
-
* @returns resolved color
|
| 24 |
-
*/
|
| 25 |
-
var resolveColor = (value, opt = {}) => {
|
| 26 |
-
if (!isString(value)) throw new TypeError(`${value} is not a string.`);
|
| 27 |
-
value = value.trim();
|
| 28 |
-
const { colorScheme = "normal", currentColor = "", format = VAL_COMP, nullable = false } = opt;
|
| 29 |
-
const cacheKey = createCacheKey({
|
| 30 |
-
namespace: NAMESPACE,
|
| 31 |
-
name: "resolve",
|
| 32 |
-
value
|
| 33 |
-
}, opt);
|
| 34 |
-
const cachedResult = getCache(cacheKey);
|
| 35 |
-
if (cachedResult instanceof CacheItem) {
|
| 36 |
-
if (cachedResult.isNull) return cachedResult;
|
| 37 |
-
return cachedResult.item;
|
| 38 |
-
}
|
| 39 |
-
if (REG_FN_VAR.test(value)) {
|
| 40 |
-
if (format === "specifiedValue") {
|
| 41 |
-
setCache(cacheKey, value);
|
| 42 |
-
return value;
|
| 43 |
-
}
|
| 44 |
-
const resolvedVar = resolveVar(value, opt);
|
| 45 |
-
if (resolvedVar instanceof NullObject) {
|
| 46 |
-
const res = format === "hex" || format === "hexAlpha" || nullable ? resolvedVar : RGB_TRANSPARENT;
|
| 47 |
-
setCache(cacheKey, res);
|
| 48 |
-
return res;
|
| 49 |
-
}
|
| 50 |
-
value = resolvedVar;
|
| 51 |
-
}
|
| 52 |
-
if (opt.format !== format) opt.format = format;
|
| 53 |
-
value = value.toLowerCase();
|
| 54 |
-
if (REG_FN_LIGHT_DARK.test(value) && value.endsWith(")")) {
|
| 55 |
-
const [light = "", dark = ""] = splitValue(value.replace(REG_FN_LIGHT_DARK, "").replace(/\)$/, ""), { delimiter: "," });
|
| 56 |
-
if (light && dark) {
|
| 57 |
-
if (format === "specifiedValue") {
|
| 58 |
-
const lightColor = resolveColor(light, opt);
|
| 59 |
-
const darkColor = resolveColor(dark, opt);
|
| 60 |
-
const res = lightColor && darkColor ? `light-dark(${lightColor}, ${darkColor})` : "";
|
| 61 |
-
setCache(cacheKey, res);
|
| 62 |
-
return res;
|
| 63 |
-
}
|
| 64 |
-
const resolved = resolveColor(colorScheme === "dark" ? dark : light, opt);
|
| 65 |
-
const res = resolved instanceof NullObject && !nullable ? RGB_TRANSPARENT : resolved;
|
| 66 |
-
setCache(cacheKey, res);
|
| 67 |
-
return res;
|
| 68 |
-
}
|
| 69 |
-
const invalidRes = format === "specifiedValue" ? "" : format === "hex" || format === "hexAlpha" ? new NullObject() : RGB_TRANSPARENT;
|
| 70 |
-
setCache(cacheKey, invalidRes);
|
| 71 |
-
return invalidRes;
|
| 72 |
-
}
|
| 73 |
-
if (REG_FN_REL.test(value)) {
|
| 74 |
-
const resolvedRel = resolveRelativeColor(value, opt);
|
| 75 |
-
if (format === "computedValue") {
|
| 76 |
-
const res = resolvedRel instanceof NullObject && !nullable ? RGB_TRANSPARENT : resolvedRel;
|
| 77 |
-
setCache(cacheKey, res);
|
| 78 |
-
return res;
|
| 79 |
-
}
|
| 80 |
-
if (format === "specifiedValue") {
|
| 81 |
-
const res = resolvedRel instanceof NullObject ? "" : resolvedRel;
|
| 82 |
-
setCache(cacheKey, res);
|
| 83 |
-
return res;
|
| 84 |
-
}
|
| 85 |
-
value = resolvedRel instanceof NullObject ? "" : resolvedRel;
|
| 86 |
-
}
|
| 87 |
-
if (REG_FN_CALC.test(value)) value = cssCalc(value, opt);
|
| 88 |
-
let cs = "";
|
| 89 |
-
let r = NaN;
|
| 90 |
-
let g = NaN;
|
| 91 |
-
let b = NaN;
|
| 92 |
-
let alpha = NaN;
|
| 93 |
-
if (value === "transparent") {
|
| 94 |
-
let res;
|
| 95 |
-
switch (format) {
|
| 96 |
-
case VAL_SPEC:
|
| 97 |
-
res = value;
|
| 98 |
-
break;
|
| 99 |
-
case "hex":
|
| 100 |
-
res = new NullObject();
|
| 101 |
-
break;
|
| 102 |
-
case "hexAlpha":
|
| 103 |
-
res = "#00000000";
|
| 104 |
-
break;
|
| 105 |
-
default: res = RGB_TRANSPARENT;
|
| 106 |
-
}
|
| 107 |
-
setCache(cacheKey, res);
|
| 108 |
-
return res;
|
| 109 |
-
}
|
| 110 |
-
if (value === "currentcolor") {
|
| 111 |
-
if (format === "specifiedValue") {
|
| 112 |
-
setCache(cacheKey, value);
|
| 113 |
-
return value;
|
| 114 |
-
}
|
| 115 |
-
if (currentColor) {
|
| 116 |
-
let resolvedCurrent;
|
| 117 |
-
if (currentColor.startsWith("color-mix(")) resolvedCurrent = resolveColorMix(currentColor, opt);
|
| 118 |
-
else if (currentColor.startsWith("color(")) resolvedCurrent = resolveColorFunc(currentColor, opt);
|
| 119 |
-
else resolvedCurrent = resolveColorValue(currentColor, opt);
|
| 120 |
-
if (resolvedCurrent instanceof NullObject) {
|
| 121 |
-
setCache(cacheKey, resolvedCurrent);
|
| 122 |
-
return resolvedCurrent;
|
| 123 |
-
}
|
| 124 |
-
[cs, r, g, b, alpha] = resolvedCurrent;
|
| 125 |
-
} else {
|
| 126 |
-
const res = format === "computedValue" ? RGB_TRANSPARENT : value;
|
| 127 |
-
if (format === "computedValue") {
|
| 128 |
-
setCache(cacheKey, res);
|
| 129 |
-
return res;
|
| 130 |
-
}
|
| 131 |
-
}
|
| 132 |
-
} else if (format === "specifiedValue") {
|
| 133 |
-
let res = "";
|
| 134 |
-
if (value.startsWith("color-mix(")) res = resolveColorMix(value, opt);
|
| 135 |
-
else if (value.startsWith("color(")) {
|
| 136 |
-
const [scs, rr, gg, bb, aa] = resolveColorFunc(value, opt);
|
| 137 |
-
res = aa === 1 ? `color(${scs} ${rr} ${gg} ${bb})` : `color(${scs} ${rr} ${gg} ${bb} / ${aa})`;
|
| 138 |
-
} else {
|
| 139 |
-
const rgb = resolveColorValue(value, opt);
|
| 140 |
-
if (isString(rgb)) res = rgb;
|
| 141 |
-
else {
|
| 142 |
-
const [scs, rr, gg, bb, aa] = rgb;
|
| 143 |
-
if (scs === "rgb") res = aa === 1 ? `${scs}(${rr}, ${gg}, ${bb})` : `${scs}a(${rr}, ${gg}, ${bb}, ${aa})`;
|
| 144 |
-
else res = aa === 1 ? `${scs}(${rr} ${gg} ${bb})` : `${scs}(${rr} ${gg} ${bb} / ${aa})`;
|
| 145 |
-
}
|
| 146 |
-
}
|
| 147 |
-
setCache(cacheKey, res);
|
| 148 |
-
return res;
|
| 149 |
-
} else if (value.startsWith("color-mix(")) {
|
| 150 |
-
if (currentColor) value = value.replace(/currentcolor/g, currentColor);
|
| 151 |
-
value = value.replace(/transparent/g, RGB_TRANSPARENT);
|
| 152 |
-
const resolvedMix = resolveColorMix(value, opt);
|
| 153 |
-
if (resolvedMix instanceof NullObject) {
|
| 154 |
-
setCache(cacheKey, resolvedMix);
|
| 155 |
-
return resolvedMix;
|
| 156 |
-
}
|
| 157 |
-
[cs, r, g, b, alpha] = resolvedMix;
|
| 158 |
-
} else if (value.startsWith("color(")) {
|
| 159 |
-
const resolvedFunc = resolveColorFunc(value, opt);
|
| 160 |
-
if (resolvedFunc instanceof NullObject) {
|
| 161 |
-
setCache(cacheKey, resolvedFunc);
|
| 162 |
-
return resolvedFunc;
|
| 163 |
-
}
|
| 164 |
-
[cs, r, g, b, alpha] = resolvedFunc;
|
| 165 |
-
} else if (value) {
|
| 166 |
-
const resolvedVal = resolveColorValue(value, opt);
|
| 167 |
-
if (resolvedVal instanceof NullObject) {
|
| 168 |
-
setCache(cacheKey, resolvedVal);
|
| 169 |
-
return resolvedVal;
|
| 170 |
-
}
|
| 171 |
-
[cs, r, g, b, alpha] = resolvedVal;
|
| 172 |
-
}
|
| 173 |
-
let finalRes = "";
|
| 174 |
-
switch (format) {
|
| 175 |
-
case "hex":
|
| 176 |
-
case "hexAlpha":
|
| 177 |
-
if (Number.isNaN(r) || Number.isNaN(g) || Number.isNaN(b) || Number.isNaN(alpha) || format === "hex" && alpha === 0) finalRes = new NullObject();
|
| 178 |
-
else finalRes = convertRgbToHex([
|
| 179 |
-
r,
|
| 180 |
-
g,
|
| 181 |
-
b,
|
| 182 |
-
format === "hex" ? 1 : alpha
|
| 183 |
-
]);
|
| 184 |
-
break;
|
| 185 |
-
default: if (cs === "rgb") finalRes = alpha === 1 ? `${cs}(${r}, ${g}, ${b})` : `${cs}a(${r}, ${g}, ${b}, ${alpha})`;
|
| 186 |
-
else if ([
|
| 187 |
-
"lab",
|
| 188 |
-
"lch",
|
| 189 |
-
"oklab",
|
| 190 |
-
"oklch"
|
| 191 |
-
].includes(cs)) finalRes = alpha === 1 ? `${cs}(${r} ${g} ${b})` : `${cs}(${r} ${g} ${b} / ${alpha})`;
|
| 192 |
-
else finalRes = alpha === 1 ? `color(${cs} ${r} ${g} ${b})` : `color(${cs} ${r} ${g} ${b} / ${alpha})`;
|
| 193 |
-
}
|
| 194 |
-
setCache(cacheKey, finalRes);
|
| 195 |
-
return finalRes;
|
| 196 |
-
};
|
| 197 |
-
/**
|
| 198 |
-
* resolve CSS color
|
| 199 |
-
* @param value - CSS color value. system colors are not supported
|
| 200 |
-
* @param [opt] - options
|
| 201 |
-
*/
|
| 202 |
-
var resolve = (value, opt = {}) => {
|
| 203 |
-
opt.nullable = false;
|
| 204 |
-
const resolvedValue = resolveColor(value, opt);
|
| 205 |
-
return resolvedValue instanceof NullObject ? null : resolvedValue;
|
| 206 |
-
};
|
| 207 |
-
//#endregion
|
| 208 |
-
export { resolve, resolveColor };
|
| 209 |
-
|
| 210 |
-
//# sourceMappingURL=resolve.js.map
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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sourcesContent":["/**\n * resolve\n */\n\nimport {\n CacheItem,\n NullObject,\n createCacheKey,\n getCache,\n setCache\n} from './cache';\nimport {\n convertRgbToHex,\n resolveColorFunc,\n resolveColorMix,\n resolveColorValue\n} from './color';\nimport { isString } from './common';\nimport { cssCalc } from './css-calc';\nimport { resolveVar } from './css-var';\nimport { resolveRelativeColor } from './relative-color';\nimport { splitValue } from './util';\nimport {\n ComputedColorChannels,\n Options,\n SpecifiedColorChannels\n} from './typedef';\n\n/* constants */\nimport {\n FN_COLOR,\n FN_MIX,\n SYN_FN_CALC,\n SYN_FN_LIGHT_DARK,\n SYN_FN_REL,\n SYN_FN_VAR,\n VAL_COMP,\n VAL_SPEC\n} from './constant';\nconst NAMESPACE = 'resolve';\nconst RGB_TRANSPARENT = 'rgba(0, 0, 0, 0)';\n\n/* regexp */\nconst REG_FN_CALC = new RegExp(SYN_FN_CALC);\nconst REG_FN_LIGHT_DARK = new RegExp(SYN_FN_LIGHT_DARK);\nconst REG_FN_REL = new RegExp(SYN_FN_REL);\nconst REG_FN_VAR = new RegExp(SYN_FN_VAR);\n\n/**\n * resolve color\n * @param value - CSS color value\n * @param [opt] - options\n * @returns resolved color\n */\nexport const resolveColor = (\n value: string,\n opt: Options = {}\n): string | NullObject => {\n if (!isString(value)) {\n throw new TypeError(`${value} is not a string.`);\n }\n value = value.trim();\n const {\n colorScheme = 'normal',\n currentColor = '',\n format = VAL_COMP,\n nullable = false\n } = opt;\n const cacheKey: string = createCacheKey(\n { namespace: NAMESPACE, name: 'resolve', value },\n opt\n );\n const cachedResult = getCache(cacheKey);\n if (cachedResult instanceof CacheItem) {\n if (cachedResult.isNull) {\n return cachedResult as NullObject;\n }\n return cachedResult.item as string;\n }\n // 1. var() resolution\n if (REG_FN_VAR.test(value)) {\n if (format === VAL_SPEC) {\n setCache(cacheKey, value);\n return value;\n }\n const resolvedVar = resolveVar(value, opt);\n if (resolvedVar instanceof NullObject) {\n const res =\n format === 'hex' || format === 'hexAlpha' || nullable\n ? resolvedVar\n : RGB_TRANSPARENT;\n setCache(cacheKey, res);\n return res;\n }\n value = resolvedVar;\n }\n if (opt.format !== format) {\n opt.format = format;\n }\n value = value.toLowerCase();\n // 2. light-dark() resolution\n if (REG_FN_LIGHT_DARK.test(value) && value.endsWith(')')) {\n const colorParts = value.replace(REG_FN_LIGHT_DARK, '').replace(/\\)$/, '');\n const [light = '', dark = ''] = splitValue(colorParts, { delimiter: ',' });\n if (light && dark) {\n if (format === VAL_SPEC) {\n const lightColor = resolveColor(light, opt);\n const darkColor = resolveColor(dark, opt);\n const res =\n lightColor && darkColor\n ? `light-dark(${lightColor}, ${darkColor})`\n : '';\n setCache(cacheKey, res);\n return res;\n }\n const chosen = colorScheme === 'dark' ? dark : light;\n const resolved = resolveColor(chosen, opt);\n const res =\n resolved instanceof NullObject && !nullable\n ? RGB_TRANSPARENT\n : resolved;\n setCache(cacheKey, res);\n return res;\n }\n // fallback for invalid light-dark\n const invalidRes =\n format === VAL_SPEC\n ? ''\n : format === 'hex' || format === 'hexAlpha'\n ? new NullObject()\n : RGB_TRANSPARENT;\n setCache(cacheKey, invalidRes);\n return invalidRes;\n }\n // 3. Relative Color resolution\n if (REG_FN_REL.test(value)) {\n const resolvedRel = resolveRelativeColor(value, opt);\n if (format === VAL_COMP) {\n const res =\n resolvedRel instanceof NullObject && !nullable\n ? RGB_TRANSPARENT\n : resolvedRel;\n setCache(cacheKey, res);\n return res;\n }\n if (format === VAL_SPEC) {\n const res = resolvedRel instanceof NullObject ? '' : resolvedRel;\n setCache(cacheKey, res);\n return res;\n }\n value = resolvedRel instanceof NullObject ? '' : resolvedRel;\n }\n // 4. calc() resolution\n if (REG_FN_CALC.test(value)) {\n value = cssCalc(value, opt);\n }\n // 5. Keyword & Color-space resolution\n let cs = '';\n let r = NaN;\n let g = NaN;\n let b = NaN;\n let alpha = NaN;\n if (value === 'transparent') {\n let res: string | NullObject;\n switch (format) {\n case VAL_SPEC: {\n res = value;\n break;\n }\n case 'hex': {\n res = new NullObject();\n break;\n }\n case 'hexAlpha': {\n res = '#00000000';\n break;\n }\n default: {\n res = RGB_TRANSPARENT;\n }\n }\n setCache(cacheKey, res);\n return res;\n }\n if (value === 'currentcolor') {\n if (format === VAL_SPEC) {\n setCache(cacheKey, value);\n return value;\n }\n if (currentColor) {\n let resolvedCurrent;\n if (currentColor.startsWith(FN_MIX)) {\n resolvedCurrent = resolveColorMix(currentColor, opt);\n } else if (currentColor.startsWith(FN_COLOR)) {\n resolvedCurrent = resolveColorFunc(currentColor, opt);\n } else {\n resolvedCurrent = resolveColorValue(currentColor, opt);\n }\n if (resolvedCurrent instanceof NullObject) {\n setCache(cacheKey, resolvedCurrent);\n return resolvedCurrent;\n }\n [cs, r, g, b, alpha] = resolvedCurrent as ComputedColorChannels;\n } else {\n // value is handled below if not VAL_COMP\n const res = format === VAL_COMP ? RGB_TRANSPARENT : value;\n if (format === VAL_COMP) {\n setCache(cacheKey, res);\n return res;\n }\n }\n } else if (format === VAL_SPEC) {\n let res = '';\n if (value.startsWith(FN_MIX)) {\n res = resolveColorMix(value, opt) as string;\n } else if (value.startsWith(FN_COLOR)) {\n const [scs, rr, gg, bb, aa] = resolveColorFunc(\n value,\n opt\n ) as SpecifiedColorChannels;\n res =\n aa === 1\n ? `color(${scs} ${rr} ${gg} ${bb})`\n : `color(${scs} ${rr} ${gg} ${bb} / ${aa})`;\n } else {\n const rgb = resolveColorValue(value, opt);\n if (isString(rgb)) {\n res = rgb;\n } else {\n const [scs, rr, gg, bb, aa] = rgb as SpecifiedColorChannels;\n if (scs === 'rgb') {\n res =\n aa === 1\n ? `${scs}(${rr}, ${gg}, ${bb})`\n : `${scs}a(${rr}, ${gg}, ${bb}, ${aa})`;\n } else {\n res =\n aa === 1\n ? `${scs}(${rr} ${gg} ${bb})`\n : `${scs}(${rr} ${gg} ${bb} / ${aa})`;\n }\n }\n }\n setCache(cacheKey, res);\n return res;\n } else if (value.startsWith(FN_MIX)) {\n if (currentColor) {\n value = value.replace(/currentcolor/g, currentColor);\n }\n value = value.replace(/transparent/g, RGB_TRANSPARENT);\n const resolvedMix = resolveColorMix(value, opt);\n if (resolvedMix instanceof NullObject) {\n setCache(cacheKey, resolvedMix);\n return resolvedMix;\n }\n [cs, r, g, b, alpha] = resolvedMix as ComputedColorChannels;\n } else if (value.startsWith(FN_COLOR)) {\n const resolvedFunc = resolveColorFunc(value, opt);\n if (resolvedFunc instanceof NullObject) {\n setCache(cacheKey, resolvedFunc);\n return resolvedFunc;\n }\n [cs, r, g, b, alpha] = resolvedFunc as ComputedColorChannels;\n } else if (value) {\n const resolvedVal = resolveColorValue(value, opt);\n if (resolvedVal instanceof NullObject) {\n setCache(cacheKey, resolvedVal);\n return resolvedVal;\n }\n [cs, r, g, b, alpha] = resolvedVal as ComputedColorChannels;\n }\n // 6. Format Finalization\n let finalRes: string | NullObject = '';\n switch (format) {\n case 'hex':\n case 'hexAlpha': {\n if (\n Number.isNaN(r) ||\n Number.isNaN(g) ||\n Number.isNaN(b) ||\n Number.isNaN(alpha) ||\n (format === 'hex' && alpha === 0)\n ) {\n finalRes = new NullObject();\n } else {\n finalRes = convertRgbToHex([r, g, b, format === 'hex' ? 1 : alpha]);\n }\n break;\n }\n default: {\n if (cs === 'rgb') {\n finalRes =\n alpha === 1\n ? `${cs}(${r}, ${g}, ${b})`\n : `${cs}a(${r}, ${g}, ${b}, ${alpha})`;\n } else if (['lab', 'lch', 'oklab', 'oklch'].includes(cs)) {\n finalRes =\n alpha === 1\n ? `${cs}(${r} ${g} ${b})`\n : `${cs}(${r} ${g} ${b} / ${alpha})`;\n } else {\n finalRes =\n alpha === 1\n ? `color(${cs} ${r} ${g} ${b})`\n : `color(${cs} ${r} ${g} ${b} / ${alpha})`;\n }\n }\n }\n setCache(cacheKey, finalRes);\n return finalRes;\n};\n\n/**\n * resolve CSS color\n * @param value - CSS color value. system colors are not supported\n * @param [opt] - options\n */\nexport const resolve = (value: string, opt: Options = {}): string | null => {\n opt.nullable = false;\n const resolvedValue = resolveColor(value, opt);\n return resolvedValue instanceof NullObject ? null : (resolvedValue as string);\n};\n"],"mappings":";;;;;;;;;;;;AAuCA,IAAM,YAAY;AAClB,IAAM,kBAAkB;AAGxB,IAAM,cAAc,IAAI,OAAO,YAAY;AAC3C,IAAM,oBAAoB,IAAI,OAAO,kBAAkB;AACvD,IAAM,aAAa,IAAI,OAAO,WAAW;AACzC,IAAM,aAAa,IAAI,OAAO,WAAW;;;;;;;AAQzC,IAAa,gBACX,OACA,MAAe,EAAE,KACO;AACxB,KAAI,CAAC,SAAS,MAAM,CAClB,OAAM,IAAI,UAAU,GAAG,MAAM,mBAAmB;AAElD,SAAQ,MAAM,MAAM;CACpB,MAAM,EACJ,cAAc,UACd,eAAe,IACf,SAAS,UACT,WAAW,UACT;CACJ,MAAM,WAAmB,eACvB;EAAE,WAAW;EAAW,MAAM;EAAW;EAAO,EAChD,IACD;CACD,MAAM,eAAe,SAAS,SAAS;AACvC,KAAI,wBAAwB,WAAW;AACrC,MAAI,aAAa,OACf,QAAO;AAET,SAAO,aAAa;;AAGtB,KAAI,WAAW,KAAK,MAAM,EAAE;AAC1B,MAAI,WAAA,kBAAqB;AACvB,YAAS,UAAU,MAAM;AACzB,UAAO;;EAET,MAAM,cAAc,WAAW,OAAO,IAAI;AAC1C,MAAI,uBAAuB,YAAY;GACrC,MAAM,MACJ,WAAW,SAAS,WAAW,cAAc,WACzC,cACA;AACN,YAAS,UAAU,IAAI;AACvB,UAAO;;AAET,UAAQ;;AAEV,KAAI,IAAI,WAAW,OACjB,KAAI,SAAS;AAEf,SAAQ,MAAM,aAAa;AAE3B,KAAI,kBAAkB,KAAK,MAAM,IAAI,MAAM,SAAS,IAAI,EAAE;EAExD,MAAM,CAAC,QAAQ,IAAI,OAAO,MAAM,WADb,MAAM,QAAQ,mBAAmB,GAAG,CAAC,QAAQ,OAAO,GAAG,EACnB,EAAE,WAAW,KAAK,CAAC;AAC1E,MAAI,SAAS,MAAM;AACjB,OAAI,WA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AG,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,KAC3B,SAAS,GAAG,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,KAAK,MAAM;;AAIlD,UAAS,UAAU,SAAS;AAC5B,QAAO;;;;;;;AAQT,IAAa,WAAW,OAAe,MAAe,EAAE,KAAoB;AAC1E,KAAI,WAAW;CACf,MAAM,gBAAgB,aAAa,OAAO,IAAI;AAC9C,QAAO,yBAAyB,aAAa,OAAQ"}
|
|
|
|
|
|
node_modules/@asamuzakjp/css-color/dist/esm/js/typedef.d.ts
DELETED
|
@@ -1,80 +0,0 @@
|
|
| 1 |
-
/**
|
| 2 |
-
* typedef
|
| 3 |
-
*/
|
| 4 |
-
/**
|
| 5 |
-
* @typedef Options - options
|
| 6 |
-
* @property [alpha] - enable alpha
|
| 7 |
-
* @property [colorSpace] - color space
|
| 8 |
-
* @property [currentColor] - color for currentcolor
|
| 9 |
-
* @property [customProperty] - custom properties
|
| 10 |
-
* @property [d50] - white point in d50
|
| 11 |
-
* @property [dimension] - dimension
|
| 12 |
-
* @property [format] - output format
|
| 13 |
-
* @property [key] - key
|
| 14 |
-
*/
|
| 15 |
-
export interface Options {
|
| 16 |
-
alpha?: boolean;
|
| 17 |
-
colorScheme?: string;
|
| 18 |
-
colorSpace?: string;
|
| 19 |
-
currentColor?: string;
|
| 20 |
-
customProperty?: Record<string, string | ((K: string) => string)>;
|
| 21 |
-
d50?: boolean;
|
| 22 |
-
delimiter?: string | string[];
|
| 23 |
-
dimension?: Record<string, number | ((K: string) => number)>;
|
| 24 |
-
format?: string;
|
| 25 |
-
nullable?: boolean;
|
| 26 |
-
preserveComment?: boolean;
|
| 27 |
-
}
|
| 28 |
-
/**
|
| 29 |
-
* @type ColorChannels - color channels
|
| 30 |
-
*/
|
| 31 |
-
export type ColorChannels = [x: number, y: number, z: number, alpha: number];
|
| 32 |
-
/**
|
| 33 |
-
* @type StringColorChannels - color channels
|
| 34 |
-
*/
|
| 35 |
-
export type StringColorChannels = [
|
| 36 |
-
x: string,
|
| 37 |
-
y: string,
|
| 38 |
-
z: string,
|
| 39 |
-
alpha: string | undefined
|
| 40 |
-
];
|
| 41 |
-
/**
|
| 42 |
-
* @type StringColorSpacedChannels - specified value
|
| 43 |
-
*/
|
| 44 |
-
export type StringColorSpacedChannels = [
|
| 45 |
-
cs: string,
|
| 46 |
-
x: string,
|
| 47 |
-
y: string,
|
| 48 |
-
z: string,
|
| 49 |
-
alpha: string | undefined
|
| 50 |
-
];
|
| 51 |
-
/**
|
| 52 |
-
* @type ComputedColorChannels - computed value
|
| 53 |
-
*/
|
| 54 |
-
export type ComputedColorChannels = [
|
| 55 |
-
cs: string,
|
| 56 |
-
x: number,
|
| 57 |
-
y: number,
|
| 58 |
-
z: number,
|
| 59 |
-
alpha: number
|
| 60 |
-
];
|
| 61 |
-
/**
|
| 62 |
-
* @type SpecifiedColorChannels - specified value
|
| 63 |
-
*/
|
| 64 |
-
export type SpecifiedColorChannels = [
|
| 65 |
-
cs: string,
|
| 66 |
-
x: number | string,
|
| 67 |
-
y: number | string,
|
| 68 |
-
z: number | string,
|
| 69 |
-
alpha: number | string
|
| 70 |
-
];
|
| 71 |
-
/**
|
| 72 |
-
* @type MatchedRegExp - matched regexp array
|
| 73 |
-
*/
|
| 74 |
-
export type MatchedRegExp = [
|
| 75 |
-
match: string,
|
| 76 |
-
gr1: string,
|
| 77 |
-
gr2: string,
|
| 78 |
-
gr3: string,
|
| 79 |
-
gr4: string
|
| 80 |
-
];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
node_modules/@asamuzakjp/css-color/dist/esm/js/util.d.ts
DELETED
|
@@ -1,59 +0,0 @@
|
|
| 1 |
-
import { Options } from './typedef.js';
|
| 2 |
-
/**
|
| 3 |
-
* split value
|
| 4 |
-
* NOTE: comments are stripped, it can be preserved if, in the options param,
|
| 5 |
-
* `delimiter` is either ',' or '/' and with `preserveComment` set to `true`
|
| 6 |
-
* @param value - CSS value
|
| 7 |
-
* @param [opt] - options
|
| 8 |
-
* @returns array of values
|
| 9 |
-
*/
|
| 10 |
-
export declare const splitValue: (value: string, opt?: Options) => string[];
|
| 11 |
-
/**
|
| 12 |
-
* extract dashed-ident tokens
|
| 13 |
-
* @param value - CSS value
|
| 14 |
-
* @returns array of dashed-ident tokens
|
| 15 |
-
*/
|
| 16 |
-
export declare const extractDashedIdent: (value: string) => string[];
|
| 17 |
-
/**
|
| 18 |
-
* is color
|
| 19 |
-
* @param value - CSS value
|
| 20 |
-
* @param [opt] - options
|
| 21 |
-
* @returns result
|
| 22 |
-
*/
|
| 23 |
-
export declare const isColor: (value: unknown, opt?: Options) => boolean;
|
| 24 |
-
/**
|
| 25 |
-
* round to specified precision
|
| 26 |
-
* @param value - numeric value
|
| 27 |
-
* @param bit - minimum bits
|
| 28 |
-
* @returns rounded value
|
| 29 |
-
*/
|
| 30 |
-
export declare const roundToPrecision: (value: number, bit?: number) => number;
|
| 31 |
-
/**
|
| 32 |
-
* interpolate hue
|
| 33 |
-
* @param hueA - hue value
|
| 34 |
-
* @param hueB - hue value
|
| 35 |
-
* @param arc - shorter | longer | increasing | decreasing
|
| 36 |
-
* @returns result - [hueA, hueB]
|
| 37 |
-
*/
|
| 38 |
-
export declare const interpolateHue: (hueA: number, hueB: number, arc?: string) => [number, number];
|
| 39 |
-
/**
|
| 40 |
-
* resolve length in pixels
|
| 41 |
-
* @param value - value
|
| 42 |
-
* @param unit - unit
|
| 43 |
-
* @param [opt] - options
|
| 44 |
-
* @returns pixelated value
|
| 45 |
-
*/
|
| 46 |
-
export declare const resolveLengthInPixels: (value: number | string, unit: string | undefined, opt?: Options) => number;
|
| 47 |
-
/**
|
| 48 |
-
* is absolute size or length
|
| 49 |
-
* @param value - value
|
| 50 |
-
* @param unit - unit
|
| 51 |
-
* @returns result
|
| 52 |
-
*/
|
| 53 |
-
export declare const isAbsoluteSizeOrLength: (value: number | string, unit: string | undefined) => boolean;
|
| 54 |
-
/**
|
| 55 |
-
* is absolute font size
|
| 56 |
-
* @param css - css
|
| 57 |
-
* @returns result
|
| 58 |
-
*/
|
| 59 |
-
export declare const isAbsoluteFontSize: (css: unknown) => boolean;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
node_modules/@asamuzakjp/css-color/dist/esm/js/util.js
DELETED
|
@@ -1,274 +0,0 @@
|
|
| 1 |
-
import { CacheItem, createCacheKey, getCache, setCache } from "./cache.js";
|
| 2 |
-
import { isString } from "./common.js";
|
| 3 |
-
import { SYN_COLOR_TYPE, SYN_MIX, VAL_SPEC } from "./constant.js";
|
| 4 |
-
import { NAMED_COLORS } from "./color.js";
|
| 5 |
-
import { resolveColor } from "./resolve.js";
|
| 6 |
-
import { TokenType, tokenize } from "@csstools/css-tokenizer";
|
| 7 |
-
//#region src/js/util.ts
|
| 8 |
-
/**
|
| 9 |
-
* util
|
| 10 |
-
*/
|
| 11 |
-
var { CloseParen: PAREN_CLOSE, Comma: COMMA, Comment: COMMENT, Delim: DELIM, EOF, Function: FUNC, OpenParen: PAREN_OPEN, Whitespace: W_SPACE } = TokenType;
|
| 12 |
-
var NAMESPACE = "util";
|
| 13 |
-
var DEC = 10;
|
| 14 |
-
var HEX = 16;
|
| 15 |
-
var DEG = 360;
|
| 16 |
-
var DEG_HALF = 180;
|
| 17 |
-
var REG_COLOR = new RegExp(`^(?:${SYN_COLOR_TYPE})$`);
|
| 18 |
-
var REG_DIMENSION = /^([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)([a-z]*)$/i;
|
| 19 |
-
var REG_FN_COLOR = /^(?:(?:ok)?l(?:ab|ch)|color(?:-mix)?|hsla?|hwb|rgba?|var)\(/;
|
| 20 |
-
var REG_MIX = new RegExp(SYN_MIX);
|
| 21 |
-
var REG_DASHED_IDENT = /--[\w-]+/g;
|
| 22 |
-
var REG_COMMA = /^,$/;
|
| 23 |
-
var REG_SLASH = /^\/$/;
|
| 24 |
-
var REG_WHITESPACE = /^\s+$/;
|
| 25 |
-
/**
|
| 26 |
-
* split value
|
| 27 |
-
* NOTE: comments are stripped, it can be preserved if, in the options param,
|
| 28 |
-
* `delimiter` is either ',' or '/' and with `preserveComment` set to `true`
|
| 29 |
-
* @param value - CSS value
|
| 30 |
-
* @param [opt] - options
|
| 31 |
-
* @returns array of values
|
| 32 |
-
*/
|
| 33 |
-
var splitValue = (value, opt = {}) => {
|
| 34 |
-
if (!isString(value)) throw new TypeError(`${value} is not a string.`);
|
| 35 |
-
const strValue = value.trim();
|
| 36 |
-
const { delimiter = " ", preserveComment = false } = opt;
|
| 37 |
-
const cacheKey = createCacheKey({
|
| 38 |
-
namespace: NAMESPACE,
|
| 39 |
-
name: "splitValue",
|
| 40 |
-
value: strValue
|
| 41 |
-
}, {
|
| 42 |
-
delimiter,
|
| 43 |
-
preserveComment
|
| 44 |
-
});
|
| 45 |
-
const cachedResult = getCache(cacheKey);
|
| 46 |
-
if (cachedResult instanceof CacheItem) return cachedResult.item;
|
| 47 |
-
let regDelimiter;
|
| 48 |
-
switch (delimiter) {
|
| 49 |
-
case ",":
|
| 50 |
-
regDelimiter = REG_COMMA;
|
| 51 |
-
break;
|
| 52 |
-
case "/":
|
| 53 |
-
regDelimiter = REG_SLASH;
|
| 54 |
-
break;
|
| 55 |
-
default: regDelimiter = REG_WHITESPACE;
|
| 56 |
-
}
|
| 57 |
-
const tokens = tokenize({ css: strValue });
|
| 58 |
-
let nest = 0;
|
| 59 |
-
let currentStr = "";
|
| 60 |
-
const res = [];
|
| 61 |
-
for (const [type, val] of tokens) switch (type) {
|
| 62 |
-
case COMMA:
|
| 63 |
-
case DELIM:
|
| 64 |
-
if (nest === 0 && regDelimiter.test(val)) {
|
| 65 |
-
res.push(currentStr.trim());
|
| 66 |
-
currentStr = "";
|
| 67 |
-
} else currentStr += val;
|
| 68 |
-
break;
|
| 69 |
-
case COMMENT:
|
| 70 |
-
if (preserveComment && (delimiter === "," || delimiter === "/")) currentStr += val;
|
| 71 |
-
break;
|
| 72 |
-
case FUNC:
|
| 73 |
-
case PAREN_OPEN:
|
| 74 |
-
currentStr += val;
|
| 75 |
-
nest++;
|
| 76 |
-
break;
|
| 77 |
-
case PAREN_CLOSE:
|
| 78 |
-
currentStr += val;
|
| 79 |
-
nest--;
|
| 80 |
-
break;
|
| 81 |
-
case W_SPACE:
|
| 82 |
-
if (regDelimiter.test(val)) if (nest === 0) {
|
| 83 |
-
if (currentStr) {
|
| 84 |
-
res.push(currentStr.trim());
|
| 85 |
-
currentStr = "";
|
| 86 |
-
}
|
| 87 |
-
} else currentStr += " ";
|
| 88 |
-
else if (!currentStr.endsWith(" ")) currentStr += " ";
|
| 89 |
-
break;
|
| 90 |
-
default: if (type === EOF) {
|
| 91 |
-
res.push(currentStr.trim());
|
| 92 |
-
currentStr = "";
|
| 93 |
-
} else currentStr += val;
|
| 94 |
-
}
|
| 95 |
-
setCache(cacheKey, res);
|
| 96 |
-
return res;
|
| 97 |
-
};
|
| 98 |
-
/**
|
| 99 |
-
* extract dashed-ident tokens
|
| 100 |
-
* @param value - CSS value
|
| 101 |
-
* @returns array of dashed-ident tokens
|
| 102 |
-
*/
|
| 103 |
-
var extractDashedIdent = (value) => {
|
| 104 |
-
if (!isString(value)) throw new TypeError(`${value} is not a string.`);
|
| 105 |
-
const strValue = value.trim();
|
| 106 |
-
const cacheKey = createCacheKey({
|
| 107 |
-
namespace: NAMESPACE,
|
| 108 |
-
name: "extractDashedIdent",
|
| 109 |
-
value: strValue
|
| 110 |
-
});
|
| 111 |
-
const cachedResult = getCache(cacheKey);
|
| 112 |
-
if (cachedResult instanceof CacheItem) return cachedResult.item;
|
| 113 |
-
const matches = strValue.match(REG_DASHED_IDENT);
|
| 114 |
-
const res = matches ? [...new Set(matches)] : [];
|
| 115 |
-
setCache(cacheKey, res);
|
| 116 |
-
return res;
|
| 117 |
-
};
|
| 118 |
-
/**
|
| 119 |
-
* is color
|
| 120 |
-
* @param value - CSS value
|
| 121 |
-
* @param [opt] - options
|
| 122 |
-
* @returns result
|
| 123 |
-
*/
|
| 124 |
-
var isColor = (value, opt = {}) => {
|
| 125 |
-
if (!isString(value)) return false;
|
| 126 |
-
const str = value.toLowerCase().trim();
|
| 127 |
-
if (!str) return false;
|
| 128 |
-
if (/^[a-z]+$/.test(str)) return str === "currentcolor" || str === "transparent" || Object.hasOwn(NAMED_COLORS, str);
|
| 129 |
-
if (REG_COLOR.test(str) || REG_MIX.test(str)) return true;
|
| 130 |
-
if (REG_FN_COLOR.test(str)) {
|
| 131 |
-
const colorOpt = {
|
| 132 |
-
...opt,
|
| 133 |
-
nullable: true
|
| 134 |
-
};
|
| 135 |
-
if (!colorOpt.format) colorOpt.format = VAL_SPEC;
|
| 136 |
-
return !!resolveColor(str, colorOpt);
|
| 137 |
-
}
|
| 138 |
-
return false;
|
| 139 |
-
};
|
| 140 |
-
/**
|
| 141 |
-
* round to specified precision
|
| 142 |
-
* @param value - numeric value
|
| 143 |
-
* @param bit - minimum bits
|
| 144 |
-
* @returns rounded value
|
| 145 |
-
*/
|
| 146 |
-
var roundToPrecision = (value, bit = 0) => {
|
| 147 |
-
if (!Number.isFinite(value)) throw new TypeError(`${value} is not a finite number.`);
|
| 148 |
-
if (!Number.isFinite(bit)) throw new TypeError(`${bit} is not a finite number.`);
|
| 149 |
-
if (bit < 0 || bit > HEX) throw new RangeError(`${bit} is not between 0 and ${HEX}.`);
|
| 150 |
-
if (bit === 0) return Math.round(value);
|
| 151 |
-
const precision = bit === HEX ? 6 : bit < DEC ? 4 : 5;
|
| 152 |
-
return parseFloat(value.toPrecision(precision));
|
| 153 |
-
};
|
| 154 |
-
/**
|
| 155 |
-
* interpolate hue
|
| 156 |
-
* @param hueA - hue value
|
| 157 |
-
* @param hueB - hue value
|
| 158 |
-
* @param arc - shorter | longer | increasing | decreasing
|
| 159 |
-
* @returns result - [hueA, hueB]
|
| 160 |
-
*/
|
| 161 |
-
var interpolateHue = (hueA, hueB, arc = "shorter") => {
|
| 162 |
-
if (!Number.isFinite(hueA)) throw new TypeError(`${hueA} is not a finite number.`);
|
| 163 |
-
if (!Number.isFinite(hueB)) throw new TypeError(`${hueB} is not a finite number.`);
|
| 164 |
-
let a = hueA;
|
| 165 |
-
let b = hueB;
|
| 166 |
-
switch (arc) {
|
| 167 |
-
case "decreasing":
|
| 168 |
-
if (b > a) a += DEG;
|
| 169 |
-
break;
|
| 170 |
-
case "increasing":
|
| 171 |
-
if (b < a) b += DEG;
|
| 172 |
-
break;
|
| 173 |
-
case "longer":
|
| 174 |
-
if (b > a && b < a + DEG_HALF) a += DEG;
|
| 175 |
-
else if (b > a - DEG_HALF && b <= a) b += DEG;
|
| 176 |
-
break;
|
| 177 |
-
default: if (b > a + DEG_HALF) a += DEG;
|
| 178 |
-
else if (b < a - DEG_HALF) b += DEG;
|
| 179 |
-
}
|
| 180 |
-
return [a, b];
|
| 181 |
-
};
|
| 182 |
-
var absoluteFontSize = new Map([
|
| 183 |
-
["xx-small", 9 / 16],
|
| 184 |
-
["x-small", 5 / 8],
|
| 185 |
-
["small", 13 / 16],
|
| 186 |
-
["medium", 1],
|
| 187 |
-
["large", 9 / 8],
|
| 188 |
-
["x-large", 3 / 2],
|
| 189 |
-
["xx-large", 2],
|
| 190 |
-
["xxx-large", 3]
|
| 191 |
-
]);
|
| 192 |
-
var relativeFontSize = new Map([["smaller", 1 / 1.2], ["larger", 1.2]]);
|
| 193 |
-
var absoluteLength = new Map([
|
| 194 |
-
["cm", 96 / 2.54],
|
| 195 |
-
["mm", 96 / 25.4],
|
| 196 |
-
["q", 96 / 101.6],
|
| 197 |
-
["in", 96],
|
| 198 |
-
["pc", 16],
|
| 199 |
-
["pt", 96 / 72],
|
| 200 |
-
["px", 1]
|
| 201 |
-
]);
|
| 202 |
-
var relativeLength = new Map([
|
| 203 |
-
["rcap", 1],
|
| 204 |
-
["rch", .5],
|
| 205 |
-
["rem", 1],
|
| 206 |
-
["rex", .5],
|
| 207 |
-
["ric", 1],
|
| 208 |
-
["rlh", 1.2]
|
| 209 |
-
]);
|
| 210 |
-
/**
|
| 211 |
-
* resolve length in pixels
|
| 212 |
-
* @param value - value
|
| 213 |
-
* @param unit - unit
|
| 214 |
-
* @param [opt] - options
|
| 215 |
-
* @returns pixelated value
|
| 216 |
-
*/
|
| 217 |
-
var resolveLengthInPixels = (value, unit, opt = {}) => {
|
| 218 |
-
const { dimension = {} } = opt;
|
| 219 |
-
const { callback, em, rem, vh, vw } = dimension;
|
| 220 |
-
if (isString(value)) {
|
| 221 |
-
const str = value.toLowerCase().trim();
|
| 222 |
-
const ratio = absoluteFontSize.get(str);
|
| 223 |
-
if (ratio !== void 0) return ratio * rem;
|
| 224 |
-
const relRatio = relativeFontSize.get(str);
|
| 225 |
-
if (relRatio !== void 0) return relRatio * em;
|
| 226 |
-
return NaN;
|
| 227 |
-
}
|
| 228 |
-
if (Number.isFinite(value) && unit) {
|
| 229 |
-
const u = unit.toLowerCase();
|
| 230 |
-
if (Object.hasOwn(dimension, u)) return value * Number(dimension[u]);
|
| 231 |
-
if (typeof callback === "function") return value * (callback(u) ?? NaN);
|
| 232 |
-
const absRatio = absoluteLength.get(u);
|
| 233 |
-
if (absRatio !== void 0) return value * absRatio;
|
| 234 |
-
const relRatio = relativeLength.get(u);
|
| 235 |
-
if (relRatio !== void 0) return value * relRatio * rem;
|
| 236 |
-
const rUnitRatio = relativeLength.get(`r${u}`);
|
| 237 |
-
if (rUnitRatio !== void 0) return value * rUnitRatio * em;
|
| 238 |
-
switch (u) {
|
| 239 |
-
case "vb":
|
| 240 |
-
case "vi": return value * vw;
|
| 241 |
-
case "vmax": return value * Math.max(vh, vw);
|
| 242 |
-
case "vmin": return value * Math.min(vh, vw);
|
| 243 |
-
default:
|
| 244 |
-
}
|
| 245 |
-
}
|
| 246 |
-
return NaN;
|
| 247 |
-
};
|
| 248 |
-
/**
|
| 249 |
-
* is absolute size or length
|
| 250 |
-
* @param value - value
|
| 251 |
-
* @param unit - unit
|
| 252 |
-
* @returns result
|
| 253 |
-
*/
|
| 254 |
-
var isAbsoluteSizeOrLength = (value, unit) => {
|
| 255 |
-
if (isString(value)) return absoluteFontSize.has(value.toLowerCase().trim());
|
| 256 |
-
if (isString(unit)) return absoluteLength.has(unit.toLowerCase().trim());
|
| 257 |
-
return value === 0;
|
| 258 |
-
};
|
| 259 |
-
/**
|
| 260 |
-
* is absolute font size
|
| 261 |
-
* @param css - css
|
| 262 |
-
* @returns result
|
| 263 |
-
*/
|
| 264 |
-
var isAbsoluteFontSize = (css) => {
|
| 265 |
-
if (!isString(css)) return false;
|
| 266 |
-
const str = css.trim();
|
| 267 |
-
if (isAbsoluteSizeOrLength(str, void 0)) return true;
|
| 268 |
-
const match = str.match(REG_DIMENSION);
|
| 269 |
-
return match ? isAbsoluteSizeOrLength(Number(match[1]), match[2] || void 0) : false;
|
| 270 |
-
};
|
| 271 |
-
//#endregion
|
| 272 |
-
export { extractDashedIdent, interpolateHue, isAbsoluteFontSize, isAbsoluteSizeOrLength, isColor, resolveLengthInPixels, roundToPrecision, splitValue };
|
| 273 |
-
|
| 274 |
-
//# sourceMappingURL=util.js.map
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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ts"],"sourcesContent":["/**\n * util\n */\n\nimport { TokenType, tokenize } from '@csstools/css-tokenizer';\nimport { CacheItem, createCacheKey, getCache, setCache } from './cache';\nimport { isString } from './common';\nimport { resolveColor } from './resolve';\nimport { Options } from './typedef';\n\n/* constants */\nimport { NAMED_COLORS } from './color';\nimport { SYN_COLOR_TYPE, SYN_MIX, VAL_SPEC } from './constant';\nconst {\n CloseParen: PAREN_CLOSE,\n Comma: COMMA,\n Comment: COMMENT,\n Delim: DELIM,\n EOF,\n Function: FUNC,\n OpenParen: PAREN_OPEN,\n Whitespace: W_SPACE\n} = TokenType;\nconst NAMESPACE = 'util';\n\n/* numeric constants */\nconst DEC = 10;\nconst HEX = 16;\nconst DEG = 360;\nconst DEG_HALF = 180;\n\n/* regexp */\nconst REG_COLOR = new RegExp(`^(?:${SYN_COLOR_TYPE})$`);\nconst REG_DIMENSION = /^([+-]?(?:\\d+(?:\\.\\d+)?|\\.\\d+)(?:e[+-]?\\d+)?)([a-z]*)$/i;\nconst REG_FN_COLOR =\n /^(?:(?:ok)?l(?:ab|ch)|color(?:-mix)?|hsla?|hwb|rgba?|var)\\(/;\nconst REG_MIX = new RegExp(SYN_MIX);\nconst REG_DASHED_IDENT = /--[\\w-]+/g;\nconst REG_COMMA = /^,$/;\nconst REG_SLASH = /^\\/$/;\nconst REG_WHITESPACE = /^\\s+$/;\n\n/**\n * split value\n * NOTE: comments are stripped, it can be preserved if, in the options param,\n * `delimiter` is either ',' or '/' and with `preserveComment` set to `true`\n * @param value - CSS value\n * @param [opt] - options\n * @returns array of values\n */\nexport const splitValue = (value: string, opt: Options = {}): string[] => {\n if (!isString(value)) {\n throw new TypeError(`${value} is not a string.`);\n }\n const strValue = value.trim();\n const { delimiter = ' ', preserveComment = false } = opt;\n const cacheKey: string = createCacheKey(\n {\n namespace: NAMESPACE,\n name: 'splitValue',\n value: strValue\n },\n { delimiter, preserveComment }\n );\n const cachedResult = getCache(cacheKey);\n if (cachedResult instanceof CacheItem) {\n return cachedResult.item as string[];\n }\n let regDelimiter;\n switch (delimiter) {\n case ',': {\n regDelimiter = REG_COMMA;\n break;\n }\n case '/': {\n regDelimiter = REG_SLASH;\n break;\n }\n default: {\n regDelimiter = REG_WHITESPACE;\n }\n }\n const tokens = tokenize({ css: strValue });\n let nest = 0;\n let currentStr = '';\n const res: string[] = [];\n for (const [type, val] of tokens) {\n switch (type) {\n case COMMA:\n case DELIM: {\n if (nest === 0 && regDelimiter.test(val)) {\n res.push(currentStr.trim());\n currentStr = '';\n } else {\n currentStr += val;\n }\n break;\n }\n case COMMENT: {\n if (preserveComment && (delimiter === ',' || delimiter === '/')) {\n currentStr += val;\n }\n break;\n }\n case FUNC:\n case PAREN_OPEN: {\n currentStr += val;\n nest++;\n break;\n }\n case PAREN_CLOSE: {\n currentStr += val;\n nest--;\n break;\n }\n case W_SPACE: {\n if (regDelimiter.test(val)) {\n if (nest === 0) {\n if (currentStr) {\n res.push(currentStr.trim());\n currentStr = '';\n }\n } else {\n currentStr += ' ';\n }\n } else if (!currentStr.endsWith(' ')) {\n currentStr += ' ';\n }\n break;\n }\n default: {\n if (type === EOF) {\n res.push(currentStr.trim());\n currentStr = '';\n } else {\n currentStr += val;\n }\n }\n }\n }\n setCache(cacheKey, res);\n return res;\n};\n\n/**\n * extract dashed-ident tokens\n * @param value - CSS value\n * @returns array of dashed-ident tokens\n */\nexport const extractDashedIdent = (value: string): string[] => {\n if (!isString(value)) {\n throw new TypeError(`${value} is not a string.`);\n }\n const strValue = value.trim();\n const cacheKey: string = createCacheKey({\n namespace: NAMESPACE,\n name: 'extractDashedIdent',\n value: strValue\n });\n const cachedResult = getCache(cacheKey);\n if (cachedResult instanceof CacheItem) {\n return cachedResult.item as string[];\n }\n const matches = strValue.match(REG_DASHED_IDENT);\n const res = matches ? [...new Set(matches)] : [];\n setCache(cacheKey, res);\n return res;\n};\n\n/**\n * is color\n * @param value - CSS value\n * @param [opt] - options\n * @returns result\n */\nexport const isColor = (value: unknown, opt: Options = {}): boolean => {\n if (!isString(value)) {\n return false;\n }\n const str = value.toLowerCase().trim();\n if (!str) {\n return false;\n }\n if (/^[a-z]+$/.test(str)) {\n return (\n str === 'currentcolor' ||\n str === 'transparent' ||\n Object.hasOwn(NAMED_COLORS, str)\n );\n }\n if (REG_COLOR.test(str) || REG_MIX.test(str)) {\n return true;\n }\n if (REG_FN_COLOR.test(str)) {\n const colorOpt = { ...opt, nullable: true };\n if (!colorOpt.format) colorOpt.format = VAL_SPEC;\n return !!resolveColor(str, colorOpt);\n }\n return false;\n};\n\n/**\n * round to specified precision\n * @param value - numeric value\n * @param bit - minimum bits\n * @returns rounded value\n */\nexport const roundToPrecision = (value: number, bit: number = 0): number => {\n if (!Number.isFinite(value)) {\n throw new TypeError(`${value} is not a finite number.`);\n }\n if (!Number.isFinite(bit)) {\n throw new TypeError(`${bit} is not a finite number.`);\n }\n if (bit < 0 || bit > HEX) {\n throw new RangeError(`${bit} is not between 0 and ${HEX}.`);\n }\n if (bit === 0) {\n return Math.round(value);\n }\n const precision = bit === HEX ? 6 : bit < DEC ? 4 : 5;\n return parseFloat(value.toPrecision(precision));\n};\n\n/**\n * interpolate hue\n * @param hueA - hue value\n * @param hueB - hue value\n * @param arc - shorter | longer | increasing | decreasing\n * @returns result - [hueA, hueB]\n */\nexport const interpolateHue = (\n hueA: number,\n hueB: number,\n arc: string = 'shorter'\n): [number, number] => {\n if (!Number.isFinite(hueA)) {\n throw new TypeError(`${hueA} is not a finite number.`);\n }\n if (!Number.isFinite(hueB)) {\n throw new TypeError(`${hueB} is not a finite number.`);\n }\n let a = hueA;\n let b = hueB;\n switch (arc) {\n case 'decreasing': {\n if (b > a) {\n a += DEG;\n }\n break;\n }\n case 'increasing': {\n if (b < a) {\n b += DEG;\n }\n break;\n }\n case 'longer': {\n if (b > a && b < a + DEG_HALF) {\n a += DEG;\n } else if (b > a - DEG_HALF && b <= a) {\n b += DEG;\n }\n break;\n }\n case 'shorter':\n default: {\n if (b > a + DEG_HALF) {\n a += DEG;\n } else if (b < a - DEG_HALF) {\n b += DEG;\n }\n }\n }\n return [a, b];\n};\n\n/* absolute font size to pixel ratio */\nconst absoluteFontSize = new Map([\n ['xx-small', 9 / 16],\n ['x-small', 5 / 8],\n ['small', 13 / 16],\n ['medium', 1],\n ['large', 9 / 8],\n ['x-large', 3 / 2],\n ['xx-large', 2],\n ['xxx-large', 3]\n]);\n\n/* relative font size to pixel ratio */\nconst relativeFontSize = new Map([\n ['smaller', 1 / 1.2],\n ['larger', 1.2]\n]);\n\n/* absolute length to pixel ratio */\nconst absoluteLength = new Map([\n ['cm', 96 / 2.54],\n ['mm', 96 / 25.4],\n ['q', 96 / 101.6],\n ['in', 96],\n ['pc', 16],\n ['pt', 96 / 72],\n ['px', 1]\n]);\n\n/* relative length to pixel ratio */\nconst relativeLength = new Map([\n ['rcap', 1],\n ['rch', 0.5],\n ['rem', 1],\n ['rex', 0.5],\n ['ric', 1],\n ['rlh', 1.2]\n]);\n\n/**\n * resolve length in pixels\n * @param value - value\n * @param unit - unit\n * @param [opt] - options\n * @returns pixelated value\n */\nexport const resolveLengthInPixels = (\n value: number | string,\n unit: string | undefined,\n opt: Options = {}\n): number => {\n const { dimension = {} } = opt;\n const { callback, em, rem, vh, vw } = dimension as {\n callback: (K: string) => number;\n em: number;\n rem: number;\n vh: number;\n vw: number;\n };\n if (isString(value)) {\n const str = value.toLowerCase().trim();\n const ratio = absoluteFontSize.get(str);\n if (ratio !== undefined) {\n return ratio * rem;\n }\n const relRatio = relativeFontSize.get(str);\n if (relRatio !== undefined) {\n return relRatio * em;\n }\n return Number.NaN;\n }\n if (Number.isFinite(value) && unit) {\n const u = unit.toLowerCase();\n if (Object.hasOwn(dimension, u)) {\n return value * Number(dimension[u]);\n }\n if (typeof callback === 'function') {\n return value * (callback(u) ?? Number.NaN);\n }\n const absRatio = absoluteLength.get(u);\n if (absRatio !== undefined) {\n return value * absRatio;\n }\n const relRatio = relativeLength.get(u);\n if (relRatio !== undefined) {\n return value * relRatio * rem;\n }\n const rUnitRatio = relativeLength.get(`r${u}`);\n if (rUnitRatio !== undefined) {\n return value * rUnitRatio * em;\n }\n switch (u) {\n case 'vb':\n case 'vi': {\n return value * vw;\n }\n case 'vmax': {\n return value * Math.max(vh, vw);\n }\n case 'vmin': {\n return value * Math.min(vh, vw);\n }\n default:\n }\n }\n // unsupported or invalid value\n return Number.NaN;\n};\n\n/**\n * is absolute size or length\n * @param value - value\n * @param unit - unit\n * @returns result\n */\nexport const isAbsoluteSizeOrLength = (\n value: number | string,\n unit: string | undefined\n): boolean => {\n if (isString(value)) {\n return absoluteFontSize.has(value.toLowerCase().trim());\n }\n if (isString(unit)) {\n return absoluteLength.has(unit.toLowerCase().trim());\n }\n return value === 0;\n};\n\n/**\n * is absolute font size\n * @param css - css\n * @returns result\n */\nexport const isAbsoluteFontSize = (css: unknown): boolean => {\n if (!isString(css)) {\n return false;\n }\n const str = css.trim();\n if (isAbsoluteSizeOrLength(str, undefined)) {\n return true;\n }\n const match = str.match(REG_DIMENSION);\n return match\n ? isAbsoluteSizeOrLength(Number(match[1]), match[2] || undefined)\n : false;\n};\n"],"mappings":";;;;;;;;;;AAaA,IAAM,EACJ,YAAY,aACZ,OAAO,OACP,SAAS,SACT,OAAO,OACP,KACA,UAAU,MACV,WAAW,YACX,YAAY,YACV;AACJ,IAAM,YAAY;AAGlB,IAAM,MAAM;AACZ,IAAM,MAAM;AACZ,IAAM,MAAM;AACZ,IAAM,WAAW;AAGjB,IAAM,YAAY,IAAI,OAAO,OAAO,eAAe,IAAI;AACvD,IAAM,gBAAgB;AACtB,IAAM,eACJ;AACF,IAAM,UAAU,IAAI,OAAO,QAAQ;AACnC,IAAM,mBAAmB;AACzB,IAAM,YAAY;AAClB,IAAM,YAAY;AAClB,IAAM,iBAAiB;;;;;;;;;AAUvB,IAAa,cAAc,OAAe,MAAe,EAAE,KAAe;AACxE,KAAI,CAAC,SAAS,MAAM,CAClB,OAAM,IAAI,UAAU,GAAG,MAAM,mBA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ACZ,KAAI,SAAS,MAAM,CACjB,QAAO,iBAAiB,IAAI,MAAM,aAAa,CAAC,MAAM,CAAC;AAEzD,KAAI,SAAS,KAAK,CAChB,QAAO,eAAe,IAAI,KAAK,aAAa,CAAC,MAAM,CAAC;AAEtD,QAAO,UAAU;;;;;;;AAQnB,IAAa,sBAAsB,QAA0B;AAC3D,KAAI,CAAC,SAAS,IAAI,CAChB,QAAO;CAET,MAAM,MAAM,IAAI,MAAM;AACtB,KAAI,uBAAuB,KAAK,KAAA,EAAU,CACxC,QAAO;CAET,MAAM,QAAQ,IAAI,MAAM,cAAc;AACtC,QAAO,QACH,uBAAuB,OAAO,MAAM,GAAG,EAAE,MAAM,MAAM,KAAA,EAAU,GAC/D"}
|
|
|
|
|
|
node_modules/@babel/core/node_modules/.bin/semver
DELETED
|
@@ -1,174 +0,0 @@
|
|
| 1 |
-
#!/usr/bin/env node
|
| 2 |
-
// Standalone semver comparison program.
|
| 3 |
-
// Exits successfully and prints matching version(s) if
|
| 4 |
-
// any supplied version is valid and passes all tests.
|
| 5 |
-
|
| 6 |
-
var argv = process.argv.slice(2)
|
| 7 |
-
|
| 8 |
-
var versions = []
|
| 9 |
-
|
| 10 |
-
var range = []
|
| 11 |
-
|
| 12 |
-
var inc = null
|
| 13 |
-
|
| 14 |
-
var version = require('../package.json').version
|
| 15 |
-
|
| 16 |
-
var loose = false
|
| 17 |
-
|
| 18 |
-
var includePrerelease = false
|
| 19 |
-
|
| 20 |
-
var coerce = false
|
| 21 |
-
|
| 22 |
-
var rtl = false
|
| 23 |
-
|
| 24 |
-
var identifier
|
| 25 |
-
|
| 26 |
-
var semver = require('../semver')
|
| 27 |
-
|
| 28 |
-
var reverse = false
|
| 29 |
-
|
| 30 |
-
var options = {}
|
| 31 |
-
|
| 32 |
-
main()
|
| 33 |
-
|
| 34 |
-
function main () {
|
| 35 |
-
if (!argv.length) return help()
|
| 36 |
-
while (argv.length) {
|
| 37 |
-
var a = argv.shift()
|
| 38 |
-
var indexOfEqualSign = a.indexOf('=')
|
| 39 |
-
if (indexOfEqualSign !== -1) {
|
| 40 |
-
a = a.slice(0, indexOfEqualSign)
|
| 41 |
-
argv.unshift(a.slice(indexOfEqualSign + 1))
|
| 42 |
-
}
|
| 43 |
-
switch (a) {
|
| 44 |
-
case '-rv': case '-rev': case '--rev': case '--reverse':
|
| 45 |
-
reverse = true
|
| 46 |
-
break
|
| 47 |
-
case '-l': case '--loose':
|
| 48 |
-
loose = true
|
| 49 |
-
break
|
| 50 |
-
case '-p': case '--include-prerelease':
|
| 51 |
-
includePrerelease = true
|
| 52 |
-
break
|
| 53 |
-
case '-v': case '--version':
|
| 54 |
-
versions.push(argv.shift())
|
| 55 |
-
break
|
| 56 |
-
case '-i': case '--inc': case '--increment':
|
| 57 |
-
switch (argv[0]) {
|
| 58 |
-
case 'major': case 'minor': case 'patch': case 'prerelease':
|
| 59 |
-
case 'premajor': case 'preminor': case 'prepatch':
|
| 60 |
-
inc = argv.shift()
|
| 61 |
-
break
|
| 62 |
-
default:
|
| 63 |
-
inc = 'patch'
|
| 64 |
-
break
|
| 65 |
-
}
|
| 66 |
-
break
|
| 67 |
-
case '--preid':
|
| 68 |
-
identifier = argv.shift()
|
| 69 |
-
break
|
| 70 |
-
case '-r': case '--range':
|
| 71 |
-
range.push(argv.shift())
|
| 72 |
-
break
|
| 73 |
-
case '-c': case '--coerce':
|
| 74 |
-
coerce = true
|
| 75 |
-
break
|
| 76 |
-
case '--rtl':
|
| 77 |
-
rtl = true
|
| 78 |
-
break
|
| 79 |
-
case '--ltr':
|
| 80 |
-
rtl = false
|
| 81 |
-
break
|
| 82 |
-
case '-h': case '--help': case '-?':
|
| 83 |
-
return help()
|
| 84 |
-
default:
|
| 85 |
-
versions.push(a)
|
| 86 |
-
break
|
| 87 |
-
}
|
| 88 |
-
}
|
| 89 |
-
|
| 90 |
-
var options = { loose: loose, includePrerelease: includePrerelease, rtl: rtl }
|
| 91 |
-
|
| 92 |
-
versions = versions.map(function (v) {
|
| 93 |
-
return coerce ? (semver.coerce(v, options) || { version: v }).version : v
|
| 94 |
-
}).filter(function (v) {
|
| 95 |
-
return semver.valid(v)
|
| 96 |
-
})
|
| 97 |
-
if (!versions.length) return fail()
|
| 98 |
-
if (inc && (versions.length !== 1 || range.length)) { return failInc() }
|
| 99 |
-
|
| 100 |
-
for (var i = 0, l = range.length; i < l; i++) {
|
| 101 |
-
versions = versions.filter(function (v) {
|
| 102 |
-
return semver.satisfies(v, range[i], options)
|
| 103 |
-
})
|
| 104 |
-
if (!versions.length) return fail()
|
| 105 |
-
}
|
| 106 |
-
return success(versions)
|
| 107 |
-
}
|
| 108 |
-
|
| 109 |
-
function failInc () {
|
| 110 |
-
console.error('--inc can only be used on a single version with no range')
|
| 111 |
-
fail()
|
| 112 |
-
}
|
| 113 |
-
|
| 114 |
-
function fail () { process.exit(1) }
|
| 115 |
-
|
| 116 |
-
function success () {
|
| 117 |
-
var compare = reverse ? 'rcompare' : 'compare'
|
| 118 |
-
versions.sort(function (a, b) {
|
| 119 |
-
return semver[compare](a, b, options)
|
| 120 |
-
}).map(function (v) {
|
| 121 |
-
return semver.clean(v, options)
|
| 122 |
-
}).map(function (v) {
|
| 123 |
-
return inc ? semver.inc(v, inc, options, identifier) : v
|
| 124 |
-
}).forEach(function (v, i, _) { console.log(v) })
|
| 125 |
-
}
|
| 126 |
-
|
| 127 |
-
function help () {
|
| 128 |
-
console.log(['SemVer ' + version,
|
| 129 |
-
'',
|
| 130 |
-
'A JavaScript implementation of the https://semver.org/ specification',
|
| 131 |
-
'Copyright Isaac Z. Schlueter',
|
| 132 |
-
'',
|
| 133 |
-
'Usage: semver [options] <version> [<version> [...]]',
|
| 134 |
-
'Prints valid versions sorted by SemVer precedence',
|
| 135 |
-
'',
|
| 136 |
-
'Options:',
|
| 137 |
-
'-r --range <range>',
|
| 138 |
-
' Print versions that match the specified range.',
|
| 139 |
-
'',
|
| 140 |
-
'-i --increment [<level>]',
|
| 141 |
-
' Increment a version by the specified level. Level can',
|
| 142 |
-
' be one of: major, minor, patch, premajor, preminor,',
|
| 143 |
-
" prepatch, or prerelease. Default level is 'patch'.",
|
| 144 |
-
' Only one version may be specified.',
|
| 145 |
-
'',
|
| 146 |
-
'--preid <identifier>',
|
| 147 |
-
' Identifier to be used to prefix premajor, preminor,',
|
| 148 |
-
' prepatch or prerelease version increments.',
|
| 149 |
-
'',
|
| 150 |
-
'-l --loose',
|
| 151 |
-
' Interpret versions and ranges loosely',
|
| 152 |
-
'',
|
| 153 |
-
'-p --include-prerelease',
|
| 154 |
-
' Always include prerelease versions in range matching',
|
| 155 |
-
'',
|
| 156 |
-
'-c --coerce',
|
| 157 |
-
' Coerce a string into SemVer if possible',
|
| 158 |
-
' (does not imply --loose)',
|
| 159 |
-
'',
|
| 160 |
-
'--rtl',
|
| 161 |
-
' Coerce version strings right to left',
|
| 162 |
-
'',
|
| 163 |
-
'--ltr',
|
| 164 |
-
' Coerce version strings left to right (default)',
|
| 165 |
-
'',
|
| 166 |
-
'Program exits successfully if any valid version satisfies',
|
| 167 |
-
'all supplied ranges, and prints all satisfying versions.',
|
| 168 |
-
'',
|
| 169 |
-
'If no satisfying versions are found, then exits failure.',
|
| 170 |
-
'',
|
| 171 |
-
'Versions are printed in ascending order, so supplying',
|
| 172 |
-
'multiple versions to the utility will just sort them.'
|
| 173 |
-
].join('\n'))
|
| 174 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
node_modules/@babel/core/node_modules/semver/LICENSE
DELETED
|
@@ -1,15 +0,0 @@
|
|
| 1 |
-
The ISC License
|
| 2 |
-
|
| 3 |
-
Copyright (c) Isaac Z. Schlueter and Contributors
|
| 4 |
-
|
| 5 |
-
Permission to use, copy, modify, and/or distribute this software for any
|
| 6 |
-
purpose with or without fee is hereby granted, provided that the above
|
| 7 |
-
copyright notice and this permission notice appear in all copies.
|
| 8 |
-
|
| 9 |
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
| 10 |
-
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
| 11 |
-
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
| 12 |
-
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
| 13 |
-
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
| 14 |
-
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
| 15 |
-
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
node_modules/@babel/core/node_modules/semver/README.md
DELETED
|
@@ -1,443 +0,0 @@
|
|
| 1 |
-
semver(1) -- The semantic versioner for npm
|
| 2 |
-
===========================================
|
| 3 |
-
|
| 4 |
-
## Install
|
| 5 |
-
|
| 6 |
-
```bash
|
| 7 |
-
npm install semver
|
| 8 |
-
````
|
| 9 |
-
|
| 10 |
-
## Usage
|
| 11 |
-
|
| 12 |
-
As a node module:
|
| 13 |
-
|
| 14 |
-
```js
|
| 15 |
-
const semver = require('semver')
|
| 16 |
-
|
| 17 |
-
semver.valid('1.2.3') // '1.2.3'
|
| 18 |
-
semver.valid('a.b.c') // null
|
| 19 |
-
semver.clean(' =v1.2.3 ') // '1.2.3'
|
| 20 |
-
semver.satisfies('1.2.3', '1.x || >=2.5.0 || 5.0.0 - 7.2.3') // true
|
| 21 |
-
semver.gt('1.2.3', '9.8.7') // false
|
| 22 |
-
semver.lt('1.2.3', '9.8.7') // true
|
| 23 |
-
semver.minVersion('>=1.0.0') // '1.0.0'
|
| 24 |
-
semver.valid(semver.coerce('v2')) // '2.0.0'
|
| 25 |
-
semver.valid(semver.coerce('42.6.7.9.3-alpha')) // '42.6.7'
|
| 26 |
-
```
|
| 27 |
-
|
| 28 |
-
As a command-line utility:
|
| 29 |
-
|
| 30 |
-
```
|
| 31 |
-
$ semver -h
|
| 32 |
-
|
| 33 |
-
A JavaScript implementation of the https://semver.org/ specification
|
| 34 |
-
Copyright Isaac Z. Schlueter
|
| 35 |
-
|
| 36 |
-
Usage: semver [options] <version> [<version> [...]]
|
| 37 |
-
Prints valid versions sorted by SemVer precedence
|
| 38 |
-
|
| 39 |
-
Options:
|
| 40 |
-
-r --range <range>
|
| 41 |
-
Print versions that match the specified range.
|
| 42 |
-
|
| 43 |
-
-i --increment [<level>]
|
| 44 |
-
Increment a version by the specified level. Level can
|
| 45 |
-
be one of: major, minor, patch, premajor, preminor,
|
| 46 |
-
prepatch, or prerelease. Default level is 'patch'.
|
| 47 |
-
Only one version may be specified.
|
| 48 |
-
|
| 49 |
-
--preid <identifier>
|
| 50 |
-
Identifier to be used to prefix premajor, preminor,
|
| 51 |
-
prepatch or prerelease version increments.
|
| 52 |
-
|
| 53 |
-
-l --loose
|
| 54 |
-
Interpret versions and ranges loosely
|
| 55 |
-
|
| 56 |
-
-p --include-prerelease
|
| 57 |
-
Always include prerelease versions in range matching
|
| 58 |
-
|
| 59 |
-
-c --coerce
|
| 60 |
-
Coerce a string into SemVer if possible
|
| 61 |
-
(does not imply --loose)
|
| 62 |
-
|
| 63 |
-
--rtl
|
| 64 |
-
Coerce version strings right to left
|
| 65 |
-
|
| 66 |
-
--ltr
|
| 67 |
-
Coerce version strings left to right (default)
|
| 68 |
-
|
| 69 |
-
Program exits successfully if any valid version satisfies
|
| 70 |
-
all supplied ranges, and prints all satisfying versions.
|
| 71 |
-
|
| 72 |
-
If no satisfying versions are found, then exits failure.
|
| 73 |
-
|
| 74 |
-
Versions are printed in ascending order, so supplying
|
| 75 |
-
multiple versions to the utility will just sort them.
|
| 76 |
-
```
|
| 77 |
-
|
| 78 |
-
## Versions
|
| 79 |
-
|
| 80 |
-
A "version" is described by the `v2.0.0` specification found at
|
| 81 |
-
<https://semver.org/>.
|
| 82 |
-
|
| 83 |
-
A leading `"="` or `"v"` character is stripped off and ignored.
|
| 84 |
-
|
| 85 |
-
## Ranges
|
| 86 |
-
|
| 87 |
-
A `version range` is a set of `comparators` which specify versions
|
| 88 |
-
that satisfy the range.
|
| 89 |
-
|
| 90 |
-
A `comparator` is composed of an `operator` and a `version`. The set
|
| 91 |
-
of primitive `operators` is:
|
| 92 |
-
|
| 93 |
-
* `<` Less than
|
| 94 |
-
* `<=` Less than or equal to
|
| 95 |
-
* `>` Greater than
|
| 96 |
-
* `>=` Greater than or equal to
|
| 97 |
-
* `=` Equal. If no operator is specified, then equality is assumed,
|
| 98 |
-
so this operator is optional, but MAY be included.
|
| 99 |
-
|
| 100 |
-
For example, the comparator `>=1.2.7` would match the versions
|
| 101 |
-
`1.2.7`, `1.2.8`, `2.5.3`, and `1.3.9`, but not the versions `1.2.6`
|
| 102 |
-
or `1.1.0`.
|
| 103 |
-
|
| 104 |
-
Comparators can be joined by whitespace to form a `comparator set`,
|
| 105 |
-
which is satisfied by the **intersection** of all of the comparators
|
| 106 |
-
it includes.
|
| 107 |
-
|
| 108 |
-
A range is composed of one or more comparator sets, joined by `||`. A
|
| 109 |
-
version matches a range if and only if every comparator in at least
|
| 110 |
-
one of the `||`-separated comparator sets is satisfied by the version.
|
| 111 |
-
|
| 112 |
-
For example, the range `>=1.2.7 <1.3.0` would match the versions
|
| 113 |
-
`1.2.7`, `1.2.8`, and `1.2.99`, but not the versions `1.2.6`, `1.3.0`,
|
| 114 |
-
or `1.1.0`.
|
| 115 |
-
|
| 116 |
-
The range `1.2.7 || >=1.2.9 <2.0.0` would match the versions `1.2.7`,
|
| 117 |
-
`1.2.9`, and `1.4.6`, but not the versions `1.2.8` or `2.0.0`.
|
| 118 |
-
|
| 119 |
-
### Prerelease Tags
|
| 120 |
-
|
| 121 |
-
If a version has a prerelease tag (for example, `1.2.3-alpha.3`) then
|
| 122 |
-
it will only be allowed to satisfy comparator sets if at least one
|
| 123 |
-
comparator with the same `[major, minor, patch]` tuple also has a
|
| 124 |
-
prerelease tag.
|
| 125 |
-
|
| 126 |
-
For example, the range `>1.2.3-alpha.3` would be allowed to match the
|
| 127 |
-
version `1.2.3-alpha.7`, but it would *not* be satisfied by
|
| 128 |
-
`3.4.5-alpha.9`, even though `3.4.5-alpha.9` is technically "greater
|
| 129 |
-
than" `1.2.3-alpha.3` according to the SemVer sort rules. The version
|
| 130 |
-
range only accepts prerelease tags on the `1.2.3` version. The
|
| 131 |
-
version `3.4.5` *would* satisfy the range, because it does not have a
|
| 132 |
-
prerelease flag, and `3.4.5` is greater than `1.2.3-alpha.7`.
|
| 133 |
-
|
| 134 |
-
The purpose for this behavior is twofold. First, prerelease versions
|
| 135 |
-
frequently are updated very quickly, and contain many breaking changes
|
| 136 |
-
that are (by the author's design) not yet fit for public consumption.
|
| 137 |
-
Therefore, by default, they are excluded from range matching
|
| 138 |
-
semantics.
|
| 139 |
-
|
| 140 |
-
Second, a user who has opted into using a prerelease version has
|
| 141 |
-
clearly indicated the intent to use *that specific* set of
|
| 142 |
-
alpha/beta/rc versions. By including a prerelease tag in the range,
|
| 143 |
-
the user is indicating that they are aware of the risk. However, it
|
| 144 |
-
is still not appropriate to assume that they have opted into taking a
|
| 145 |
-
similar risk on the *next* set of prerelease versions.
|
| 146 |
-
|
| 147 |
-
Note that this behavior can be suppressed (treating all prerelease
|
| 148 |
-
versions as if they were normal versions, for the purpose of range
|
| 149 |
-
matching) by setting the `includePrerelease` flag on the options
|
| 150 |
-
object to any
|
| 151 |
-
[functions](https://github.com/npm/node-semver#functions) that do
|
| 152 |
-
range matching.
|
| 153 |
-
|
| 154 |
-
#### Prerelease Identifiers
|
| 155 |
-
|
| 156 |
-
The method `.inc` takes an additional `identifier` string argument that
|
| 157 |
-
will append the value of the string as a prerelease identifier:
|
| 158 |
-
|
| 159 |
-
```javascript
|
| 160 |
-
semver.inc('1.2.3', 'prerelease', 'beta')
|
| 161 |
-
// '1.2.4-beta.0'
|
| 162 |
-
```
|
| 163 |
-
|
| 164 |
-
command-line example:
|
| 165 |
-
|
| 166 |
-
```bash
|
| 167 |
-
$ semver 1.2.3 -i prerelease --preid beta
|
| 168 |
-
1.2.4-beta.0
|
| 169 |
-
```
|
| 170 |
-
|
| 171 |
-
Which then can be used to increment further:
|
| 172 |
-
|
| 173 |
-
```bash
|
| 174 |
-
$ semver 1.2.4-beta.0 -i prerelease
|
| 175 |
-
1.2.4-beta.1
|
| 176 |
-
```
|
| 177 |
-
|
| 178 |
-
### Advanced Range Syntax
|
| 179 |
-
|
| 180 |
-
Advanced range syntax desugars to primitive comparators in
|
| 181 |
-
deterministic ways.
|
| 182 |
-
|
| 183 |
-
Advanced ranges may be combined in the same way as primitive
|
| 184 |
-
comparators using white space or `||`.
|
| 185 |
-
|
| 186 |
-
#### Hyphen Ranges `X.Y.Z - A.B.C`
|
| 187 |
-
|
| 188 |
-
Specifies an inclusive set.
|
| 189 |
-
|
| 190 |
-
* `1.2.3 - 2.3.4` := `>=1.2.3 <=2.3.4`
|
| 191 |
-
|
| 192 |
-
If a partial version is provided as the first version in the inclusive
|
| 193 |
-
range, then the missing pieces are replaced with zeroes.
|
| 194 |
-
|
| 195 |
-
* `1.2 - 2.3.4` := `>=1.2.0 <=2.3.4`
|
| 196 |
-
|
| 197 |
-
If a partial version is provided as the second version in the
|
| 198 |
-
inclusive range, then all versions that start with the supplied parts
|
| 199 |
-
of the tuple are accepted, but nothing that would be greater than the
|
| 200 |
-
provided tuple parts.
|
| 201 |
-
|
| 202 |
-
* `1.2.3 - 2.3` := `>=1.2.3 <2.4.0`
|
| 203 |
-
* `1.2.3 - 2` := `>=1.2.3 <3.0.0`
|
| 204 |
-
|
| 205 |
-
#### X-Ranges `1.2.x` `1.X` `1.2.*` `*`
|
| 206 |
-
|
| 207 |
-
Any of `X`, `x`, or `*` may be used to "stand in" for one of the
|
| 208 |
-
numeric values in the `[major, minor, patch]` tuple.
|
| 209 |
-
|
| 210 |
-
* `*` := `>=0.0.0` (Any version satisfies)
|
| 211 |
-
* `1.x` := `>=1.0.0 <2.0.0` (Matching major version)
|
| 212 |
-
* `1.2.x` := `>=1.2.0 <1.3.0` (Matching major and minor versions)
|
| 213 |
-
|
| 214 |
-
A partial version range is treated as an X-Range, so the special
|
| 215 |
-
character is in fact optional.
|
| 216 |
-
|
| 217 |
-
* `""` (empty string) := `*` := `>=0.0.0`
|
| 218 |
-
* `1` := `1.x.x` := `>=1.0.0 <2.0.0`
|
| 219 |
-
* `1.2` := `1.2.x` := `>=1.2.0 <1.3.0`
|
| 220 |
-
|
| 221 |
-
#### Tilde Ranges `~1.2.3` `~1.2` `~1`
|
| 222 |
-
|
| 223 |
-
Allows patch-level changes if a minor version is specified on the
|
| 224 |
-
comparator. Allows minor-level changes if not.
|
| 225 |
-
|
| 226 |
-
* `~1.2.3` := `>=1.2.3 <1.(2+1).0` := `>=1.2.3 <1.3.0`
|
| 227 |
-
* `~1.2` := `>=1.2.0 <1.(2+1).0` := `>=1.2.0 <1.3.0` (Same as `1.2.x`)
|
| 228 |
-
* `~1` := `>=1.0.0 <(1+1).0.0` := `>=1.0.0 <2.0.0` (Same as `1.x`)
|
| 229 |
-
* `~0.2.3` := `>=0.2.3 <0.(2+1).0` := `>=0.2.3 <0.3.0`
|
| 230 |
-
* `~0.2` := `>=0.2.0 <0.(2+1).0` := `>=0.2.0 <0.3.0` (Same as `0.2.x`)
|
| 231 |
-
* `~0` := `>=0.0.0 <(0+1).0.0` := `>=0.0.0 <1.0.0` (Same as `0.x`)
|
| 232 |
-
* `~1.2.3-beta.2` := `>=1.2.3-beta.2 <1.3.0` Note that prereleases in
|
| 233 |
-
the `1.2.3` version will be allowed, if they are greater than or
|
| 234 |
-
equal to `beta.2`. So, `1.2.3-beta.4` would be allowed, but
|
| 235 |
-
`1.2.4-beta.2` would not, because it is a prerelease of a
|
| 236 |
-
different `[major, minor, patch]` tuple.
|
| 237 |
-
|
| 238 |
-
#### Caret Ranges `^1.2.3` `^0.2.5` `^0.0.4`
|
| 239 |
-
|
| 240 |
-
Allows changes that do not modify the left-most non-zero element in the
|
| 241 |
-
`[major, minor, patch]` tuple. In other words, this allows patch and
|
| 242 |
-
minor updates for versions `1.0.0` and above, patch updates for
|
| 243 |
-
versions `0.X >=0.1.0`, and *no* updates for versions `0.0.X`.
|
| 244 |
-
|
| 245 |
-
Many authors treat a `0.x` version as if the `x` were the major
|
| 246 |
-
"breaking-change" indicator.
|
| 247 |
-
|
| 248 |
-
Caret ranges are ideal when an author may make breaking changes
|
| 249 |
-
between `0.2.4` and `0.3.0` releases, which is a common practice.
|
| 250 |
-
However, it presumes that there will *not* be breaking changes between
|
| 251 |
-
`0.2.4` and `0.2.5`. It allows for changes that are presumed to be
|
| 252 |
-
additive (but non-breaking), according to commonly observed practices.
|
| 253 |
-
|
| 254 |
-
* `^1.2.3` := `>=1.2.3 <2.0.0`
|
| 255 |
-
* `^0.2.3` := `>=0.2.3 <0.3.0`
|
| 256 |
-
* `^0.0.3` := `>=0.0.3 <0.0.4`
|
| 257 |
-
* `^1.2.3-beta.2` := `>=1.2.3-beta.2 <2.0.0` Note that prereleases in
|
| 258 |
-
the `1.2.3` version will be allowed, if they are greater than or
|
| 259 |
-
equal to `beta.2`. So, `1.2.3-beta.4` would be allowed, but
|
| 260 |
-
`1.2.4-beta.2` would not, because it is a prerelease of a
|
| 261 |
-
different `[major, minor, patch]` tuple.
|
| 262 |
-
* `^0.0.3-beta` := `>=0.0.3-beta <0.0.4` Note that prereleases in the
|
| 263 |
-
`0.0.3` version *only* will be allowed, if they are greater than or
|
| 264 |
-
equal to `beta`. So, `0.0.3-pr.2` would be allowed.
|
| 265 |
-
|
| 266 |
-
When parsing caret ranges, a missing `patch` value desugars to the
|
| 267 |
-
number `0`, but will allow flexibility within that value, even if the
|
| 268 |
-
major and minor versions are both `0`.
|
| 269 |
-
|
| 270 |
-
* `^1.2.x` := `>=1.2.0 <2.0.0`
|
| 271 |
-
* `^0.0.x` := `>=0.0.0 <0.1.0`
|
| 272 |
-
* `^0.0` := `>=0.0.0 <0.1.0`
|
| 273 |
-
|
| 274 |
-
A missing `minor` and `patch` values will desugar to zero, but also
|
| 275 |
-
allow flexibility within those values, even if the major version is
|
| 276 |
-
zero.
|
| 277 |
-
|
| 278 |
-
* `^1.x` := `>=1.0.0 <2.0.0`
|
| 279 |
-
* `^0.x` := `>=0.0.0 <1.0.0`
|
| 280 |
-
|
| 281 |
-
### Range Grammar
|
| 282 |
-
|
| 283 |
-
Putting all this together, here is a Backus-Naur grammar for ranges,
|
| 284 |
-
for the benefit of parser authors:
|
| 285 |
-
|
| 286 |
-
```bnf
|
| 287 |
-
range-set ::= range ( logical-or range ) *
|
| 288 |
-
logical-or ::= ( ' ' ) * '||' ( ' ' ) *
|
| 289 |
-
range ::= hyphen | simple ( ' ' simple ) * | ''
|
| 290 |
-
hyphen ::= partial ' - ' partial
|
| 291 |
-
simple ::= primitive | partial | tilde | caret
|
| 292 |
-
primitive ::= ( '<' | '>' | '>=' | '<=' | '=' ) partial
|
| 293 |
-
partial ::= xr ( '.' xr ( '.' xr qualifier ? )? )?
|
| 294 |
-
xr ::= 'x' | 'X' | '*' | nr
|
| 295 |
-
nr ::= '0' | ['1'-'9'] ( ['0'-'9'] ) *
|
| 296 |
-
tilde ::= '~' partial
|
| 297 |
-
caret ::= '^' partial
|
| 298 |
-
qualifier ::= ( '-' pre )? ( '+' build )?
|
| 299 |
-
pre ::= parts
|
| 300 |
-
build ::= parts
|
| 301 |
-
parts ::= part ( '.' part ) *
|
| 302 |
-
part ::= nr | [-0-9A-Za-z]+
|
| 303 |
-
```
|
| 304 |
-
|
| 305 |
-
## Functions
|
| 306 |
-
|
| 307 |
-
All methods and classes take a final `options` object argument. All
|
| 308 |
-
options in this object are `false` by default. The options supported
|
| 309 |
-
are:
|
| 310 |
-
|
| 311 |
-
- `loose` Be more forgiving about not-quite-valid semver strings.
|
| 312 |
-
(Any resulting output will always be 100% strict compliant, of
|
| 313 |
-
course.) For backwards compatibility reasons, if the `options`
|
| 314 |
-
argument is a boolean value instead of an object, it is interpreted
|
| 315 |
-
to be the `loose` param.
|
| 316 |
-
- `includePrerelease` Set to suppress the [default
|
| 317 |
-
behavior](https://github.com/npm/node-semver#prerelease-tags) of
|
| 318 |
-
excluding prerelease tagged versions from ranges unless they are
|
| 319 |
-
explicitly opted into.
|
| 320 |
-
|
| 321 |
-
Strict-mode Comparators and Ranges will be strict about the SemVer
|
| 322 |
-
strings that they parse.
|
| 323 |
-
|
| 324 |
-
* `valid(v)`: Return the parsed version, or null if it's not valid.
|
| 325 |
-
* `inc(v, release)`: Return the version incremented by the release
|
| 326 |
-
type (`major`, `premajor`, `minor`, `preminor`, `patch`,
|
| 327 |
-
`prepatch`, or `prerelease`), or null if it's not valid
|
| 328 |
-
* `premajor` in one call will bump the version up to the next major
|
| 329 |
-
version and down to a prerelease of that major version.
|
| 330 |
-
`preminor`, and `prepatch` work the same way.
|
| 331 |
-
* If called from a non-prerelease version, the `prerelease` will work the
|
| 332 |
-
same as `prepatch`. It increments the patch version, then makes a
|
| 333 |
-
prerelease. If the input version is already a prerelease it simply
|
| 334 |
-
increments it.
|
| 335 |
-
* `prerelease(v)`: Returns an array of prerelease components, or null
|
| 336 |
-
if none exist. Example: `prerelease('1.2.3-alpha.1') -> ['alpha', 1]`
|
| 337 |
-
* `major(v)`: Return the major version number.
|
| 338 |
-
* `minor(v)`: Return the minor version number.
|
| 339 |
-
* `patch(v)`: Return the patch version number.
|
| 340 |
-
* `intersects(r1, r2, loose)`: Return true if the two supplied ranges
|
| 341 |
-
or comparators intersect.
|
| 342 |
-
* `parse(v)`: Attempt to parse a string as a semantic version, returning either
|
| 343 |
-
a `SemVer` object or `null`.
|
| 344 |
-
|
| 345 |
-
### Comparison
|
| 346 |
-
|
| 347 |
-
* `gt(v1, v2)`: `v1 > v2`
|
| 348 |
-
* `gte(v1, v2)`: `v1 >= v2`
|
| 349 |
-
* `lt(v1, v2)`: `v1 < v2`
|
| 350 |
-
* `lte(v1, v2)`: `v1 <= v2`
|
| 351 |
-
* `eq(v1, v2)`: `v1 == v2` This is true if they're logically equivalent,
|
| 352 |
-
even if they're not the exact same string. You already know how to
|
| 353 |
-
compare strings.
|
| 354 |
-
* `neq(v1, v2)`: `v1 != v2` The opposite of `eq`.
|
| 355 |
-
* `cmp(v1, comparator, v2)`: Pass in a comparison string, and it'll call
|
| 356 |
-
the corresponding function above. `"==="` and `"!=="` do simple
|
| 357 |
-
string comparison, but are included for completeness. Throws if an
|
| 358 |
-
invalid comparison string is provided.
|
| 359 |
-
* `compare(v1, v2)`: Return `0` if `v1 == v2`, or `1` if `v1` is greater, or `-1` if
|
| 360 |
-
`v2` is greater. Sorts in ascending order if passed to `Array.sort()`.
|
| 361 |
-
* `rcompare(v1, v2)`: The reverse of compare. Sorts an array of versions
|
| 362 |
-
in descending order when passed to `Array.sort()`.
|
| 363 |
-
* `compareBuild(v1, v2)`: The same as `compare` but considers `build` when two versions
|
| 364 |
-
are equal. Sorts in ascending order if passed to `Array.sort()`.
|
| 365 |
-
`v2` is greater. Sorts in ascending order if passed to `Array.sort()`.
|
| 366 |
-
* `diff(v1, v2)`: Returns difference between two versions by the release type
|
| 367 |
-
(`major`, `premajor`, `minor`, `preminor`, `patch`, `prepatch`, or `prerelease`),
|
| 368 |
-
or null if the versions are the same.
|
| 369 |
-
|
| 370 |
-
### Comparators
|
| 371 |
-
|
| 372 |
-
* `intersects(comparator)`: Return true if the comparators intersect
|
| 373 |
-
|
| 374 |
-
### Ranges
|
| 375 |
-
|
| 376 |
-
* `validRange(range)`: Return the valid range or null if it's not valid
|
| 377 |
-
* `satisfies(version, range)`: Return true if the version satisfies the
|
| 378 |
-
range.
|
| 379 |
-
* `maxSatisfying(versions, range)`: Return the highest version in the list
|
| 380 |
-
that satisfies the range, or `null` if none of them do.
|
| 381 |
-
* `minSatisfying(versions, range)`: Return the lowest version in the list
|
| 382 |
-
that satisfies the range, or `null` if none of them do.
|
| 383 |
-
* `minVersion(range)`: Return the lowest version that can possibly match
|
| 384 |
-
the given range.
|
| 385 |
-
* `gtr(version, range)`: Return `true` if version is greater than all the
|
| 386 |
-
versions possible in the range.
|
| 387 |
-
* `ltr(version, range)`: Return `true` if version is less than all the
|
| 388 |
-
versions possible in the range.
|
| 389 |
-
* `outside(version, range, hilo)`: Return true if the version is outside
|
| 390 |
-
the bounds of the range in either the high or low direction. The
|
| 391 |
-
`hilo` argument must be either the string `'>'` or `'<'`. (This is
|
| 392 |
-
the function called by `gtr` and `ltr`.)
|
| 393 |
-
* `intersects(range)`: Return true if any of the ranges comparators intersect
|
| 394 |
-
|
| 395 |
-
Note that, since ranges may be non-contiguous, a version might not be
|
| 396 |
-
greater than a range, less than a range, *or* satisfy a range! For
|
| 397 |
-
example, the range `1.2 <1.2.9 || >2.0.0` would have a hole from `1.2.9`
|
| 398 |
-
until `2.0.0`, so the version `1.2.10` would not be greater than the
|
| 399 |
-
range (because `2.0.1` satisfies, which is higher), nor less than the
|
| 400 |
-
range (since `1.2.8` satisfies, which is lower), and it also does not
|
| 401 |
-
satisfy the range.
|
| 402 |
-
|
| 403 |
-
If you want to know if a version satisfies or does not satisfy a
|
| 404 |
-
range, use the `satisfies(version, range)` function.
|
| 405 |
-
|
| 406 |
-
### Coercion
|
| 407 |
-
|
| 408 |
-
* `coerce(version, options)`: Coerces a string to semver if possible
|
| 409 |
-
|
| 410 |
-
This aims to provide a very forgiving translation of a non-semver string to
|
| 411 |
-
semver. It looks for the first digit in a string, and consumes all
|
| 412 |
-
remaining characters which satisfy at least a partial semver (e.g., `1`,
|
| 413 |
-
`1.2`, `1.2.3`) up to the max permitted length (256 characters). Longer
|
| 414 |
-
versions are simply truncated (`4.6.3.9.2-alpha2` becomes `4.6.3`). All
|
| 415 |
-
surrounding text is simply ignored (`v3.4 replaces v3.3.1` becomes
|
| 416 |
-
`3.4.0`). Only text which lacks digits will fail coercion (`version one`
|
| 417 |
-
is not valid). The maximum length for any semver component considered for
|
| 418 |
-
coercion is 16 characters; longer components will be ignored
|
| 419 |
-
(`10000000000000000.4.7.4` becomes `4.7.4`). The maximum value for any
|
| 420 |
-
semver component is `Integer.MAX_SAFE_INTEGER || (2**53 - 1)`; higher value
|
| 421 |
-
components are invalid (`9999999999999999.4.7.4` is likely invalid).
|
| 422 |
-
|
| 423 |
-
If the `options.rtl` flag is set, then `coerce` will return the right-most
|
| 424 |
-
coercible tuple that does not share an ending index with a longer coercible
|
| 425 |
-
tuple. For example, `1.2.3.4` will return `2.3.4` in rtl mode, not
|
| 426 |
-
`4.0.0`. `1.2.3/4` will return `4.0.0`, because the `4` is not a part of
|
| 427 |
-
any other overlapping SemVer tuple.
|
| 428 |
-
|
| 429 |
-
### Clean
|
| 430 |
-
|
| 431 |
-
* `clean(version)`: Clean a string to be a valid semver if possible
|
| 432 |
-
|
| 433 |
-
This will return a cleaned and trimmed semver version. If the provided version is not valid a null will be returned. This does not work for ranges.
|
| 434 |
-
|
| 435 |
-
ex.
|
| 436 |
-
* `s.clean(' = v 2.1.5foo')`: `null`
|
| 437 |
-
* `s.clean(' = v 2.1.5foo', { loose: true })`: `'2.1.5-foo'`
|
| 438 |
-
* `s.clean(' = v 2.1.5-foo')`: `null`
|
| 439 |
-
* `s.clean(' = v 2.1.5-foo', { loose: true })`: `'2.1.5-foo'`
|
| 440 |
-
* `s.clean('=v2.1.5')`: `'2.1.5'`
|
| 441 |
-
* `s.clean(' =v2.1.5')`: `2.1.5`
|
| 442 |
-
* `s.clean(' 2.1.5 ')`: `'2.1.5'`
|
| 443 |
-
* `s.clean('~1.0.0')`: `null`
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
node_modules/@babel/core/node_modules/semver/bin/semver.js
DELETED
|
@@ -1,174 +0,0 @@
|
|
| 1 |
-
#!/usr/bin/env node
|
| 2 |
-
// Standalone semver comparison program.
|
| 3 |
-
// Exits successfully and prints matching version(s) if
|
| 4 |
-
// any supplied version is valid and passes all tests.
|
| 5 |
-
|
| 6 |
-
var argv = process.argv.slice(2)
|
| 7 |
-
|
| 8 |
-
var versions = []
|
| 9 |
-
|
| 10 |
-
var range = []
|
| 11 |
-
|
| 12 |
-
var inc = null
|
| 13 |
-
|
| 14 |
-
var version = require('../package.json').version
|
| 15 |
-
|
| 16 |
-
var loose = false
|
| 17 |
-
|
| 18 |
-
var includePrerelease = false
|
| 19 |
-
|
| 20 |
-
var coerce = false
|
| 21 |
-
|
| 22 |
-
var rtl = false
|
| 23 |
-
|
| 24 |
-
var identifier
|
| 25 |
-
|
| 26 |
-
var semver = require('../semver')
|
| 27 |
-
|
| 28 |
-
var reverse = false
|
| 29 |
-
|
| 30 |
-
var options = {}
|
| 31 |
-
|
| 32 |
-
main()
|
| 33 |
-
|
| 34 |
-
function main () {
|
| 35 |
-
if (!argv.length) return help()
|
| 36 |
-
while (argv.length) {
|
| 37 |
-
var a = argv.shift()
|
| 38 |
-
var indexOfEqualSign = a.indexOf('=')
|
| 39 |
-
if (indexOfEqualSign !== -1) {
|
| 40 |
-
a = a.slice(0, indexOfEqualSign)
|
| 41 |
-
argv.unshift(a.slice(indexOfEqualSign + 1))
|
| 42 |
-
}
|
| 43 |
-
switch (a) {
|
| 44 |
-
case '-rv': case '-rev': case '--rev': case '--reverse':
|
| 45 |
-
reverse = true
|
| 46 |
-
break
|
| 47 |
-
case '-l': case '--loose':
|
| 48 |
-
loose = true
|
| 49 |
-
break
|
| 50 |
-
case '-p': case '--include-prerelease':
|
| 51 |
-
includePrerelease = true
|
| 52 |
-
break
|
| 53 |
-
case '-v': case '--version':
|
| 54 |
-
versions.push(argv.shift())
|
| 55 |
-
break
|
| 56 |
-
case '-i': case '--inc': case '--increment':
|
| 57 |
-
switch (argv[0]) {
|
| 58 |
-
case 'major': case 'minor': case 'patch': case 'prerelease':
|
| 59 |
-
case 'premajor': case 'preminor': case 'prepatch':
|
| 60 |
-
inc = argv.shift()
|
| 61 |
-
break
|
| 62 |
-
default:
|
| 63 |
-
inc = 'patch'
|
| 64 |
-
break
|
| 65 |
-
}
|
| 66 |
-
break
|
| 67 |
-
case '--preid':
|
| 68 |
-
identifier = argv.shift()
|
| 69 |
-
break
|
| 70 |
-
case '-r': case '--range':
|
| 71 |
-
range.push(argv.shift())
|
| 72 |
-
break
|
| 73 |
-
case '-c': case '--coerce':
|
| 74 |
-
coerce = true
|
| 75 |
-
break
|
| 76 |
-
case '--rtl':
|
| 77 |
-
rtl = true
|
| 78 |
-
break
|
| 79 |
-
case '--ltr':
|
| 80 |
-
rtl = false
|
| 81 |
-
break
|
| 82 |
-
case '-h': case '--help': case '-?':
|
| 83 |
-
return help()
|
| 84 |
-
default:
|
| 85 |
-
versions.push(a)
|
| 86 |
-
break
|
| 87 |
-
}
|
| 88 |
-
}
|
| 89 |
-
|
| 90 |
-
var options = { loose: loose, includePrerelease: includePrerelease, rtl: rtl }
|
| 91 |
-
|
| 92 |
-
versions = versions.map(function (v) {
|
| 93 |
-
return coerce ? (semver.coerce(v, options) || { version: v }).version : v
|
| 94 |
-
}).filter(function (v) {
|
| 95 |
-
return semver.valid(v)
|
| 96 |
-
})
|
| 97 |
-
if (!versions.length) return fail()
|
| 98 |
-
if (inc && (versions.length !== 1 || range.length)) { return failInc() }
|
| 99 |
-
|
| 100 |
-
for (var i = 0, l = range.length; i < l; i++) {
|
| 101 |
-
versions = versions.filter(function (v) {
|
| 102 |
-
return semver.satisfies(v, range[i], options)
|
| 103 |
-
})
|
| 104 |
-
if (!versions.length) return fail()
|
| 105 |
-
}
|
| 106 |
-
return success(versions)
|
| 107 |
-
}
|
| 108 |
-
|
| 109 |
-
function failInc () {
|
| 110 |
-
console.error('--inc can only be used on a single version with no range')
|
| 111 |
-
fail()
|
| 112 |
-
}
|
| 113 |
-
|
| 114 |
-
function fail () { process.exit(1) }
|
| 115 |
-
|
| 116 |
-
function success () {
|
| 117 |
-
var compare = reverse ? 'rcompare' : 'compare'
|
| 118 |
-
versions.sort(function (a, b) {
|
| 119 |
-
return semver[compare](a, b, options)
|
| 120 |
-
}).map(function (v) {
|
| 121 |
-
return semver.clean(v, options)
|
| 122 |
-
}).map(function (v) {
|
| 123 |
-
return inc ? semver.inc(v, inc, options, identifier) : v
|
| 124 |
-
}).forEach(function (v, i, _) { console.log(v) })
|
| 125 |
-
}
|
| 126 |
-
|
| 127 |
-
function help () {
|
| 128 |
-
console.log(['SemVer ' + version,
|
| 129 |
-
'',
|
| 130 |
-
'A JavaScript implementation of the https://semver.org/ specification',
|
| 131 |
-
'Copyright Isaac Z. Schlueter',
|
| 132 |
-
'',
|
| 133 |
-
'Usage: semver [options] <version> [<version> [...]]',
|
| 134 |
-
'Prints valid versions sorted by SemVer precedence',
|
| 135 |
-
'',
|
| 136 |
-
'Options:',
|
| 137 |
-
'-r --range <range>',
|
| 138 |
-
' Print versions that match the specified range.',
|
| 139 |
-
'',
|
| 140 |
-
'-i --increment [<level>]',
|
| 141 |
-
' Increment a version by the specified level. Level can',
|
| 142 |
-
' be one of: major, minor, patch, premajor, preminor,',
|
| 143 |
-
" prepatch, or prerelease. Default level is 'patch'.",
|
| 144 |
-
' Only one version may be specified.',
|
| 145 |
-
'',
|
| 146 |
-
'--preid <identifier>',
|
| 147 |
-
' Identifier to be used to prefix premajor, preminor,',
|
| 148 |
-
' prepatch or prerelease version increments.',
|
| 149 |
-
'',
|
| 150 |
-
'-l --loose',
|
| 151 |
-
' Interpret versions and ranges loosely',
|
| 152 |
-
'',
|
| 153 |
-
'-p --include-prerelease',
|
| 154 |
-
' Always include prerelease versions in range matching',
|
| 155 |
-
'',
|
| 156 |
-
'-c --coerce',
|
| 157 |
-
' Coerce a string into SemVer if possible',
|
| 158 |
-
' (does not imply --loose)',
|
| 159 |
-
'',
|
| 160 |
-
'--rtl',
|
| 161 |
-
' Coerce version strings right to left',
|
| 162 |
-
'',
|
| 163 |
-
'--ltr',
|
| 164 |
-
' Coerce version strings left to right (default)',
|
| 165 |
-
'',
|
| 166 |
-
'Program exits successfully if any valid version satisfies',
|
| 167 |
-
'all supplied ranges, and prints all satisfying versions.',
|
| 168 |
-
'',
|
| 169 |
-
'If no satisfying versions are found, then exits failure.',
|
| 170 |
-
'',
|
| 171 |
-
'Versions are printed in ascending order, so supplying',
|
| 172 |
-
'multiple versions to the utility will just sort them.'
|
| 173 |
-
].join('\n'))
|
| 174 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
node_modules/@babel/core/node_modules/semver/package.json
DELETED
|
@@ -1,38 +0,0 @@
|
|
| 1 |
-
{
|
| 2 |
-
"name": "semver",
|
| 3 |
-
"version": "6.3.1",
|
| 4 |
-
"description": "The semantic version parser used by npm.",
|
| 5 |
-
"main": "semver.js",
|
| 6 |
-
"scripts": {
|
| 7 |
-
"test": "tap test/ --100 --timeout=30",
|
| 8 |
-
"lint": "echo linting disabled",
|
| 9 |
-
"postlint": "template-oss-check",
|
| 10 |
-
"template-oss-apply": "template-oss-apply --force",
|
| 11 |
-
"lintfix": "npm run lint -- --fix",
|
| 12 |
-
"snap": "tap test/ --100 --timeout=30",
|
| 13 |
-
"posttest": "npm run lint"
|
| 14 |
-
},
|
| 15 |
-
"devDependencies": {
|
| 16 |
-
"@npmcli/template-oss": "4.17.0",
|
| 17 |
-
"tap": "^12.7.0"
|
| 18 |
-
},
|
| 19 |
-
"license": "ISC",
|
| 20 |
-
"repository": {
|
| 21 |
-
"type": "git",
|
| 22 |
-
"url": "https://github.com/npm/node-semver.git"
|
| 23 |
-
},
|
| 24 |
-
"bin": {
|
| 25 |
-
"semver": "./bin/semver.js"
|
| 26 |
-
},
|
| 27 |
-
"files": [
|
| 28 |
-
"bin",
|
| 29 |
-
"range.bnf",
|
| 30 |
-
"semver.js"
|
| 31 |
-
],
|
| 32 |
-
"author": "GitHub Inc.",
|
| 33 |
-
"templateOSS": {
|
| 34 |
-
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
|
| 35 |
-
"content": "./scripts/template-oss",
|
| 36 |
-
"version": "4.17.0"
|
| 37 |
-
}
|
| 38 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
node_modules/@babel/core/node_modules/semver/range.bnf
DELETED
|
@@ -1,16 +0,0 @@
|
|
| 1 |
-
range-set ::= range ( logical-or range ) *
|
| 2 |
-
logical-or ::= ( ' ' ) * '||' ( ' ' ) *
|
| 3 |
-
range ::= hyphen | simple ( ' ' simple ) * | ''
|
| 4 |
-
hyphen ::= partial ' - ' partial
|
| 5 |
-
simple ::= primitive | partial | tilde | caret
|
| 6 |
-
primitive ::= ( '<' | '>' | '>=' | '<=' | '=' ) partial
|
| 7 |
-
partial ::= xr ( '.' xr ( '.' xr qualifier ? )? )?
|
| 8 |
-
xr ::= 'x' | 'X' | '*' | nr
|
| 9 |
-
nr ::= '0' | [1-9] ( [0-9] ) *
|
| 10 |
-
tilde ::= '~' partial
|
| 11 |
-
caret ::= '^' partial
|
| 12 |
-
qualifier ::= ( '-' pre )? ( '+' build )?
|
| 13 |
-
pre ::= parts
|
| 14 |
-
build ::= parts
|
| 15 |
-
parts ::= part ( '.' part ) *
|
| 16 |
-
part ::= nr | [-0-9A-Za-z]+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
node_modules/@babel/core/node_modules/semver/semver.js
DELETED
|
@@ -1,1643 +0,0 @@
|
|
| 1 |
-
exports = module.exports = SemVer
|
| 2 |
-
|
| 3 |
-
var debug
|
| 4 |
-
/* istanbul ignore next */
|
| 5 |
-
if (typeof process === 'object' &&
|
| 6 |
-
process.env &&
|
| 7 |
-
process.env.NODE_DEBUG &&
|
| 8 |
-
/\bsemver\b/i.test(process.env.NODE_DEBUG)) {
|
| 9 |
-
debug = function () {
|
| 10 |
-
var args = Array.prototype.slice.call(arguments, 0)
|
| 11 |
-
args.unshift('SEMVER')
|
| 12 |
-
console.log.apply(console, args)
|
| 13 |
-
}
|
| 14 |
-
} else {
|
| 15 |
-
debug = function () {}
|
| 16 |
-
}
|
| 17 |
-
|
| 18 |
-
// Note: this is the semver.org version of the spec that it implements
|
| 19 |
-
// Not necessarily the package version of this code.
|
| 20 |
-
exports.SEMVER_SPEC_VERSION = '2.0.0'
|
| 21 |
-
|
| 22 |
-
var MAX_LENGTH = 256
|
| 23 |
-
var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER ||
|
| 24 |
-
/* istanbul ignore next */ 9007199254740991
|
| 25 |
-
|
| 26 |
-
// Max safe segment length for coercion.
|
| 27 |
-
var MAX_SAFE_COMPONENT_LENGTH = 16
|
| 28 |
-
|
| 29 |
-
var MAX_SAFE_BUILD_LENGTH = MAX_LENGTH - 6
|
| 30 |
-
|
| 31 |
-
// The actual regexps go on exports.re
|
| 32 |
-
var re = exports.re = []
|
| 33 |
-
var safeRe = exports.safeRe = []
|
| 34 |
-
var src = exports.src = []
|
| 35 |
-
var t = exports.tokens = {}
|
| 36 |
-
var R = 0
|
| 37 |
-
|
| 38 |
-
function tok (n) {
|
| 39 |
-
t[n] = R++
|
| 40 |
-
}
|
| 41 |
-
|
| 42 |
-
var LETTERDASHNUMBER = '[a-zA-Z0-9-]'
|
| 43 |
-
|
| 44 |
-
// Replace some greedy regex tokens to prevent regex dos issues. These regex are
|
| 45 |
-
// used internally via the safeRe object since all inputs in this library get
|
| 46 |
-
// normalized first to trim and collapse all extra whitespace. The original
|
| 47 |
-
// regexes are exported for userland consumption and lower level usage. A
|
| 48 |
-
// future breaking change could export the safer regex only with a note that
|
| 49 |
-
// all input should have extra whitespace removed.
|
| 50 |
-
var safeRegexReplacements = [
|
| 51 |
-
['\\s', 1],
|
| 52 |
-
['\\d', MAX_LENGTH],
|
| 53 |
-
[LETTERDASHNUMBER, MAX_SAFE_BUILD_LENGTH],
|
| 54 |
-
]
|
| 55 |
-
|
| 56 |
-
function makeSafeRe (value) {
|
| 57 |
-
for (var i = 0; i < safeRegexReplacements.length; i++) {
|
| 58 |
-
var token = safeRegexReplacements[i][0]
|
| 59 |
-
var max = safeRegexReplacements[i][1]
|
| 60 |
-
value = value
|
| 61 |
-
.split(token + '*').join(token + '{0,' + max + '}')
|
| 62 |
-
.split(token + '+').join(token + '{1,' + max + '}')
|
| 63 |
-
}
|
| 64 |
-
return value
|
| 65 |
-
}
|
| 66 |
-
|
| 67 |
-
// The following Regular Expressions can be used for tokenizing,
|
| 68 |
-
// validating, and parsing SemVer version strings.
|
| 69 |
-
|
| 70 |
-
// ## Numeric Identifier
|
| 71 |
-
// A single `0`, or a non-zero digit followed by zero or more digits.
|
| 72 |
-
|
| 73 |
-
tok('NUMERICIDENTIFIER')
|
| 74 |
-
src[t.NUMERICIDENTIFIER] = '0|[1-9]\\d*'
|
| 75 |
-
tok('NUMERICIDENTIFIERLOOSE')
|
| 76 |
-
src[t.NUMERICIDENTIFIERLOOSE] = '\\d+'
|
| 77 |
-
|
| 78 |
-
// ## Non-numeric Identifier
|
| 79 |
-
// Zero or more digits, followed by a letter or hyphen, and then zero or
|
| 80 |
-
// more letters, digits, or hyphens.
|
| 81 |
-
|
| 82 |
-
tok('NONNUMERICIDENTIFIER')
|
| 83 |
-
src[t.NONNUMERICIDENTIFIER] = '\\d*[a-zA-Z-]' + LETTERDASHNUMBER + '*'
|
| 84 |
-
|
| 85 |
-
// ## Main Version
|
| 86 |
-
// Three dot-separated numeric identifiers.
|
| 87 |
-
|
| 88 |
-
tok('MAINVERSION')
|
| 89 |
-
src[t.MAINVERSION] = '(' + src[t.NUMERICIDENTIFIER] + ')\\.' +
|
| 90 |
-
'(' + src[t.NUMERICIDENTIFIER] + ')\\.' +
|
| 91 |
-
'(' + src[t.NUMERICIDENTIFIER] + ')'
|
| 92 |
-
|
| 93 |
-
tok('MAINVERSIONLOOSE')
|
| 94 |
-
src[t.MAINVERSIONLOOSE] = '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')\\.' +
|
| 95 |
-
'(' + src[t.NUMERICIDENTIFIERLOOSE] + ')\\.' +
|
| 96 |
-
'(' + src[t.NUMERICIDENTIFIERLOOSE] + ')'
|
| 97 |
-
|
| 98 |
-
// ## Pre-release Version Identifier
|
| 99 |
-
// A numeric identifier, or a non-numeric identifier.
|
| 100 |
-
|
| 101 |
-
tok('PRERELEASEIDENTIFIER')
|
| 102 |
-
src[t.PRERELEASEIDENTIFIER] = '(?:' + src[t.NUMERICIDENTIFIER] +
|
| 103 |
-
'|' + src[t.NONNUMERICIDENTIFIER] + ')'
|
| 104 |
-
|
| 105 |
-
tok('PRERELEASEIDENTIFIERLOOSE')
|
| 106 |
-
src[t.PRERELEASEIDENTIFIERLOOSE] = '(?:' + src[t.NUMERICIDENTIFIERLOOSE] +
|
| 107 |
-
'|' + src[t.NONNUMERICIDENTIFIER] + ')'
|
| 108 |
-
|
| 109 |
-
// ## Pre-release Version
|
| 110 |
-
// Hyphen, followed by one or more dot-separated pre-release version
|
| 111 |
-
// identifiers.
|
| 112 |
-
|
| 113 |
-
tok('PRERELEASE')
|
| 114 |
-
src[t.PRERELEASE] = '(?:-(' + src[t.PRERELEASEIDENTIFIER] +
|
| 115 |
-
'(?:\\.' + src[t.PRERELEASEIDENTIFIER] + ')*))'
|
| 116 |
-
|
| 117 |
-
tok('PRERELEASELOOSE')
|
| 118 |
-
src[t.PRERELEASELOOSE] = '(?:-?(' + src[t.PRERELEASEIDENTIFIERLOOSE] +
|
| 119 |
-
'(?:\\.' + src[t.PRERELEASEIDENTIFIERLOOSE] + ')*))'
|
| 120 |
-
|
| 121 |
-
// ## Build Metadata Identifier
|
| 122 |
-
// Any combination of digits, letters, or hyphens.
|
| 123 |
-
|
| 124 |
-
tok('BUILDIDENTIFIER')
|
| 125 |
-
src[t.BUILDIDENTIFIER] = LETTERDASHNUMBER + '+'
|
| 126 |
-
|
| 127 |
-
// ## Build Metadata
|
| 128 |
-
// Plus sign, followed by one or more period-separated build metadata
|
| 129 |
-
// identifiers.
|
| 130 |
-
|
| 131 |
-
tok('BUILD')
|
| 132 |
-
src[t.BUILD] = '(?:\\+(' + src[t.BUILDIDENTIFIER] +
|
| 133 |
-
'(?:\\.' + src[t.BUILDIDENTIFIER] + ')*))'
|
| 134 |
-
|
| 135 |
-
// ## Full Version String
|
| 136 |
-
// A main version, followed optionally by a pre-release version and
|
| 137 |
-
// build metadata.
|
| 138 |
-
|
| 139 |
-
// Note that the only major, minor, patch, and pre-release sections of
|
| 140 |
-
// the version string are capturing groups. The build metadata is not a
|
| 141 |
-
// capturing group, because it should not ever be used in version
|
| 142 |
-
// comparison.
|
| 143 |
-
|
| 144 |
-
tok('FULL')
|
| 145 |
-
tok('FULLPLAIN')
|
| 146 |
-
src[t.FULLPLAIN] = 'v?' + src[t.MAINVERSION] +
|
| 147 |
-
src[t.PRERELEASE] + '?' +
|
| 148 |
-
src[t.BUILD] + '?'
|
| 149 |
-
|
| 150 |
-
src[t.FULL] = '^' + src[t.FULLPLAIN] + '$'
|
| 151 |
-
|
| 152 |
-
// like full, but allows v1.2.3 and =1.2.3, which people do sometimes.
|
| 153 |
-
// also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty
|
| 154 |
-
// common in the npm registry.
|
| 155 |
-
tok('LOOSEPLAIN')
|
| 156 |
-
src[t.LOOSEPLAIN] = '[v=\\s]*' + src[t.MAINVERSIONLOOSE] +
|
| 157 |
-
src[t.PRERELEASELOOSE] + '?' +
|
| 158 |
-
src[t.BUILD] + '?'
|
| 159 |
-
|
| 160 |
-
tok('LOOSE')
|
| 161 |
-
src[t.LOOSE] = '^' + src[t.LOOSEPLAIN] + '$'
|
| 162 |
-
|
| 163 |
-
tok('GTLT')
|
| 164 |
-
src[t.GTLT] = '((?:<|>)?=?)'
|
| 165 |
-
|
| 166 |
-
// Something like "2.*" or "1.2.x".
|
| 167 |
-
// Note that "x.x" is a valid xRange identifer, meaning "any version"
|
| 168 |
-
// Only the first item is strictly required.
|
| 169 |
-
tok('XRANGEIDENTIFIERLOOSE')
|
| 170 |
-
src[t.XRANGEIDENTIFIERLOOSE] = src[t.NUMERICIDENTIFIERLOOSE] + '|x|X|\\*'
|
| 171 |
-
tok('XRANGEIDENTIFIER')
|
| 172 |
-
src[t.XRANGEIDENTIFIER] = src[t.NUMERICIDENTIFIER] + '|x|X|\\*'
|
| 173 |
-
|
| 174 |
-
tok('XRANGEPLAIN')
|
| 175 |
-
src[t.XRANGEPLAIN] = '[v=\\s]*(' + src[t.XRANGEIDENTIFIER] + ')' +
|
| 176 |
-
'(?:\\.(' + src[t.XRANGEIDENTIFIER] + ')' +
|
| 177 |
-
'(?:\\.(' + src[t.XRANGEIDENTIFIER] + ')' +
|
| 178 |
-
'(?:' + src[t.PRERELEASE] + ')?' +
|
| 179 |
-
src[t.BUILD] + '?' +
|
| 180 |
-
')?)?'
|
| 181 |
-
|
| 182 |
-
tok('XRANGEPLAINLOOSE')
|
| 183 |
-
src[t.XRANGEPLAINLOOSE] = '[v=\\s]*(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' +
|
| 184 |
-
'(?:\\.(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' +
|
| 185 |
-
'(?:\\.(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' +
|
| 186 |
-
'(?:' + src[t.PRERELEASELOOSE] + ')?' +
|
| 187 |
-
src[t.BUILD] + '?' +
|
| 188 |
-
')?)?'
|
| 189 |
-
|
| 190 |
-
tok('XRANGE')
|
| 191 |
-
src[t.XRANGE] = '^' + src[t.GTLT] + '\\s*' + src[t.XRANGEPLAIN] + '$'
|
| 192 |
-
tok('XRANGELOOSE')
|
| 193 |
-
src[t.XRANGELOOSE] = '^' + src[t.GTLT] + '\\s*' + src[t.XRANGEPLAINLOOSE] + '$'
|
| 194 |
-
|
| 195 |
-
// Coercion.
|
| 196 |
-
// Extract anything that could conceivably be a part of a valid semver
|
| 197 |
-
tok('COERCE')
|
| 198 |
-
src[t.COERCE] = '(^|[^\\d])' +
|
| 199 |
-
'(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '})' +
|
| 200 |
-
'(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' +
|
| 201 |
-
'(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' +
|
| 202 |
-
'(?:$|[^\\d])'
|
| 203 |
-
tok('COERCERTL')
|
| 204 |
-
re[t.COERCERTL] = new RegExp(src[t.COERCE], 'g')
|
| 205 |
-
safeRe[t.COERCERTL] = new RegExp(makeSafeRe(src[t.COERCE]), 'g')
|
| 206 |
-
|
| 207 |
-
// Tilde ranges.
|
| 208 |
-
// Meaning is "reasonably at or greater than"
|
| 209 |
-
tok('LONETILDE')
|
| 210 |
-
src[t.LONETILDE] = '(?:~>?)'
|
| 211 |
-
|
| 212 |
-
tok('TILDETRIM')
|
| 213 |
-
src[t.TILDETRIM] = '(\\s*)' + src[t.LONETILDE] + '\\s+'
|
| 214 |
-
re[t.TILDETRIM] = new RegExp(src[t.TILDETRIM], 'g')
|
| 215 |
-
safeRe[t.TILDETRIM] = new RegExp(makeSafeRe(src[t.TILDETRIM]), 'g')
|
| 216 |
-
var tildeTrimReplace = '$1~'
|
| 217 |
-
|
| 218 |
-
tok('TILDE')
|
| 219 |
-
src[t.TILDE] = '^' + src[t.LONETILDE] + src[t.XRANGEPLAIN] + '$'
|
| 220 |
-
tok('TILDELOOSE')
|
| 221 |
-
src[t.TILDELOOSE] = '^' + src[t.LONETILDE] + src[t.XRANGEPLAINLOOSE] + '$'
|
| 222 |
-
|
| 223 |
-
// Caret ranges.
|
| 224 |
-
// Meaning is "at least and backwards compatible with"
|
| 225 |
-
tok('LONECARET')
|
| 226 |
-
src[t.LONECARET] = '(?:\\^)'
|
| 227 |
-
|
| 228 |
-
tok('CARETTRIM')
|
| 229 |
-
src[t.CARETTRIM] = '(\\s*)' + src[t.LONECARET] + '\\s+'
|
| 230 |
-
re[t.CARETTRIM] = new RegExp(src[t.CARETTRIM], 'g')
|
| 231 |
-
safeRe[t.CARETTRIM] = new RegExp(makeSafeRe(src[t.CARETTRIM]), 'g')
|
| 232 |
-
var caretTrimReplace = '$1^'
|
| 233 |
-
|
| 234 |
-
tok('CARET')
|
| 235 |
-
src[t.CARET] = '^' + src[t.LONECARET] + src[t.XRANGEPLAIN] + '$'
|
| 236 |
-
tok('CARETLOOSE')
|
| 237 |
-
src[t.CARETLOOSE] = '^' + src[t.LONECARET] + src[t.XRANGEPLAINLOOSE] + '$'
|
| 238 |
-
|
| 239 |
-
// A simple gt/lt/eq thing, or just "" to indicate "any version"
|
| 240 |
-
tok('COMPARATORLOOSE')
|
| 241 |
-
src[t.COMPARATORLOOSE] = '^' + src[t.GTLT] + '\\s*(' + src[t.LOOSEPLAIN] + ')$|^$'
|
| 242 |
-
tok('COMPARATOR')
|
| 243 |
-
src[t.COMPARATOR] = '^' + src[t.GTLT] + '\\s*(' + src[t.FULLPLAIN] + ')$|^$'
|
| 244 |
-
|
| 245 |
-
// An expression to strip any whitespace between the gtlt and the thing
|
| 246 |
-
// it modifies, so that `> 1.2.3` ==> `>1.2.3`
|
| 247 |
-
tok('COMPARATORTRIM')
|
| 248 |
-
src[t.COMPARATORTRIM] = '(\\s*)' + src[t.GTLT] +
|
| 249 |
-
'\\s*(' + src[t.LOOSEPLAIN] + '|' + src[t.XRANGEPLAIN] + ')'
|
| 250 |
-
|
| 251 |
-
// this one has to use the /g flag
|
| 252 |
-
re[t.COMPARATORTRIM] = new RegExp(src[t.COMPARATORTRIM], 'g')
|
| 253 |
-
safeRe[t.COMPARATORTRIM] = new RegExp(makeSafeRe(src[t.COMPARATORTRIM]), 'g')
|
| 254 |
-
var comparatorTrimReplace = '$1$2$3'
|
| 255 |
-
|
| 256 |
-
// Something like `1.2.3 - 1.2.4`
|
| 257 |
-
// Note that these all use the loose form, because they'll be
|
| 258 |
-
// checked against either the strict or loose comparator form
|
| 259 |
-
// later.
|
| 260 |
-
tok('HYPHENRANGE')
|
| 261 |
-
src[t.HYPHENRANGE] = '^\\s*(' + src[t.XRANGEPLAIN] + ')' +
|
| 262 |
-
'\\s+-\\s+' +
|
| 263 |
-
'(' + src[t.XRANGEPLAIN] + ')' +
|
| 264 |
-
'\\s*$'
|
| 265 |
-
|
| 266 |
-
tok('HYPHENRANGELOOSE')
|
| 267 |
-
src[t.HYPHENRANGELOOSE] = '^\\s*(' + src[t.XRANGEPLAINLOOSE] + ')' +
|
| 268 |
-
'\\s+-\\s+' +
|
| 269 |
-
'(' + src[t.XRANGEPLAINLOOSE] + ')' +
|
| 270 |
-
'\\s*$'
|
| 271 |
-
|
| 272 |
-
// Star ranges basically just allow anything at all.
|
| 273 |
-
tok('STAR')
|
| 274 |
-
src[t.STAR] = '(<|>)?=?\\s*\\*'
|
| 275 |
-
|
| 276 |
-
// Compile to actual regexp objects.
|
| 277 |
-
// All are flag-free, unless they were created above with a flag.
|
| 278 |
-
for (var i = 0; i < R; i++) {
|
| 279 |
-
debug(i, src[i])
|
| 280 |
-
if (!re[i]) {
|
| 281 |
-
re[i] = new RegExp(src[i])
|
| 282 |
-
|
| 283 |
-
// Replace all greedy whitespace to prevent regex dos issues. These regex are
|
| 284 |
-
// used internally via the safeRe object since all inputs in this library get
|
| 285 |
-
// normalized first to trim and collapse all extra whitespace. The original
|
| 286 |
-
// regexes are exported for userland consumption and lower level usage. A
|
| 287 |
-
// future breaking change could export the safer regex only with a note that
|
| 288 |
-
// all input should have extra whitespace removed.
|
| 289 |
-
safeRe[i] = new RegExp(makeSafeRe(src[i]))
|
| 290 |
-
}
|
| 291 |
-
}
|
| 292 |
-
|
| 293 |
-
exports.parse = parse
|
| 294 |
-
function parse (version, options) {
|
| 295 |
-
if (!options || typeof options !== 'object') {
|
| 296 |
-
options = {
|
| 297 |
-
loose: !!options,
|
| 298 |
-
includePrerelease: false
|
| 299 |
-
}
|
| 300 |
-
}
|
| 301 |
-
|
| 302 |
-
if (version instanceof SemVer) {
|
| 303 |
-
return version
|
| 304 |
-
}
|
| 305 |
-
|
| 306 |
-
if (typeof version !== 'string') {
|
| 307 |
-
return null
|
| 308 |
-
}
|
| 309 |
-
|
| 310 |
-
if (version.length > MAX_LENGTH) {
|
| 311 |
-
return null
|
| 312 |
-
}
|
| 313 |
-
|
| 314 |
-
var r = options.loose ? safeRe[t.LOOSE] : safeRe[t.FULL]
|
| 315 |
-
if (!r.test(version)) {
|
| 316 |
-
return null
|
| 317 |
-
}
|
| 318 |
-
|
| 319 |
-
try {
|
| 320 |
-
return new SemVer(version, options)
|
| 321 |
-
} catch (er) {
|
| 322 |
-
return null
|
| 323 |
-
}
|
| 324 |
-
}
|
| 325 |
-
|
| 326 |
-
exports.valid = valid
|
| 327 |
-
function valid (version, options) {
|
| 328 |
-
var v = parse(version, options)
|
| 329 |
-
return v ? v.version : null
|
| 330 |
-
}
|
| 331 |
-
|
| 332 |
-
exports.clean = clean
|
| 333 |
-
function clean (version, options) {
|
| 334 |
-
var s = parse(version.trim().replace(/^[=v]+/, ''), options)
|
| 335 |
-
return s ? s.version : null
|
| 336 |
-
}
|
| 337 |
-
|
| 338 |
-
exports.SemVer = SemVer
|
| 339 |
-
|
| 340 |
-
function SemVer (version, options) {
|
| 341 |
-
if (!options || typeof options !== 'object') {
|
| 342 |
-
options = {
|
| 343 |
-
loose: !!options,
|
| 344 |
-
includePrerelease: false
|
| 345 |
-
}
|
| 346 |
-
}
|
| 347 |
-
if (version instanceof SemVer) {
|
| 348 |
-
if (version.loose === options.loose) {
|
| 349 |
-
return version
|
| 350 |
-
} else {
|
| 351 |
-
version = version.version
|
| 352 |
-
}
|
| 353 |
-
} else if (typeof version !== 'string') {
|
| 354 |
-
throw new TypeError('Invalid Version: ' + version)
|
| 355 |
-
}
|
| 356 |
-
|
| 357 |
-
if (version.length > MAX_LENGTH) {
|
| 358 |
-
throw new TypeError('version is longer than ' + MAX_LENGTH + ' characters')
|
| 359 |
-
}
|
| 360 |
-
|
| 361 |
-
if (!(this instanceof SemVer)) {
|
| 362 |
-
return new SemVer(version, options)
|
| 363 |
-
}
|
| 364 |
-
|
| 365 |
-
debug('SemVer', version, options)
|
| 366 |
-
this.options = options
|
| 367 |
-
this.loose = !!options.loose
|
| 368 |
-
|
| 369 |
-
var m = version.trim().match(options.loose ? safeRe[t.LOOSE] : safeRe[t.FULL])
|
| 370 |
-
|
| 371 |
-
if (!m) {
|
| 372 |
-
throw new TypeError('Invalid Version: ' + version)
|
| 373 |
-
}
|
| 374 |
-
|
| 375 |
-
this.raw = version
|
| 376 |
-
|
| 377 |
-
// these are actually numbers
|
| 378 |
-
this.major = +m[1]
|
| 379 |
-
this.minor = +m[2]
|
| 380 |
-
this.patch = +m[3]
|
| 381 |
-
|
| 382 |
-
if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
|
| 383 |
-
throw new TypeError('Invalid major version')
|
| 384 |
-
}
|
| 385 |
-
|
| 386 |
-
if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
|
| 387 |
-
throw new TypeError('Invalid minor version')
|
| 388 |
-
}
|
| 389 |
-
|
| 390 |
-
if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
|
| 391 |
-
throw new TypeError('Invalid patch version')
|
| 392 |
-
}
|
| 393 |
-
|
| 394 |
-
// numberify any prerelease numeric ids
|
| 395 |
-
if (!m[4]) {
|
| 396 |
-
this.prerelease = []
|
| 397 |
-
} else {
|
| 398 |
-
this.prerelease = m[4].split('.').map(function (id) {
|
| 399 |
-
if (/^[0-9]+$/.test(id)) {
|
| 400 |
-
var num = +id
|
| 401 |
-
if (num >= 0 && num < MAX_SAFE_INTEGER) {
|
| 402 |
-
return num
|
| 403 |
-
}
|
| 404 |
-
}
|
| 405 |
-
return id
|
| 406 |
-
})
|
| 407 |
-
}
|
| 408 |
-
|
| 409 |
-
this.build = m[5] ? m[5].split('.') : []
|
| 410 |
-
this.format()
|
| 411 |
-
}
|
| 412 |
-
|
| 413 |
-
SemVer.prototype.format = function () {
|
| 414 |
-
this.version = this.major + '.' + this.minor + '.' + this.patch
|
| 415 |
-
if (this.prerelease.length) {
|
| 416 |
-
this.version += '-' + this.prerelease.join('.')
|
| 417 |
-
}
|
| 418 |
-
return this.version
|
| 419 |
-
}
|
| 420 |
-
|
| 421 |
-
SemVer.prototype.toString = function () {
|
| 422 |
-
return this.version
|
| 423 |
-
}
|
| 424 |
-
|
| 425 |
-
SemVer.prototype.compare = function (other) {
|
| 426 |
-
debug('SemVer.compare', this.version, this.options, other)
|
| 427 |
-
if (!(other instanceof SemVer)) {
|
| 428 |
-
other = new SemVer(other, this.options)
|
| 429 |
-
}
|
| 430 |
-
|
| 431 |
-
return this.compareMain(other) || this.comparePre(other)
|
| 432 |
-
}
|
| 433 |
-
|
| 434 |
-
SemVer.prototype.compareMain = function (other) {
|
| 435 |
-
if (!(other instanceof SemVer)) {
|
| 436 |
-
other = new SemVer(other, this.options)
|
| 437 |
-
}
|
| 438 |
-
|
| 439 |
-
return compareIdentifiers(this.major, other.major) ||
|
| 440 |
-
compareIdentifiers(this.minor, other.minor) ||
|
| 441 |
-
compareIdentifiers(this.patch, other.patch)
|
| 442 |
-
}
|
| 443 |
-
|
| 444 |
-
SemVer.prototype.comparePre = function (other) {
|
| 445 |
-
if (!(other instanceof SemVer)) {
|
| 446 |
-
other = new SemVer(other, this.options)
|
| 447 |
-
}
|
| 448 |
-
|
| 449 |
-
// NOT having a prerelease is > having one
|
| 450 |
-
if (this.prerelease.length && !other.prerelease.length) {
|
| 451 |
-
return -1
|
| 452 |
-
} else if (!this.prerelease.length && other.prerelease.length) {
|
| 453 |
-
return 1
|
| 454 |
-
} else if (!this.prerelease.length && !other.prerelease.length) {
|
| 455 |
-
return 0
|
| 456 |
-
}
|
| 457 |
-
|
| 458 |
-
var i = 0
|
| 459 |
-
do {
|
| 460 |
-
var a = this.prerelease[i]
|
| 461 |
-
var b = other.prerelease[i]
|
| 462 |
-
debug('prerelease compare', i, a, b)
|
| 463 |
-
if (a === undefined && b === undefined) {
|
| 464 |
-
return 0
|
| 465 |
-
} else if (b === undefined) {
|
| 466 |
-
return 1
|
| 467 |
-
} else if (a === undefined) {
|
| 468 |
-
return -1
|
| 469 |
-
} else if (a === b) {
|
| 470 |
-
continue
|
| 471 |
-
} else {
|
| 472 |
-
return compareIdentifiers(a, b)
|
| 473 |
-
}
|
| 474 |
-
} while (++i)
|
| 475 |
-
}
|
| 476 |
-
|
| 477 |
-
SemVer.prototype.compareBuild = function (other) {
|
| 478 |
-
if (!(other instanceof SemVer)) {
|
| 479 |
-
other = new SemVer(other, this.options)
|
| 480 |
-
}
|
| 481 |
-
|
| 482 |
-
var i = 0
|
| 483 |
-
do {
|
| 484 |
-
var a = this.build[i]
|
| 485 |
-
var b = other.build[i]
|
| 486 |
-
debug('prerelease compare', i, a, b)
|
| 487 |
-
if (a === undefined && b === undefined) {
|
| 488 |
-
return 0
|
| 489 |
-
} else if (b === undefined) {
|
| 490 |
-
return 1
|
| 491 |
-
} else if (a === undefined) {
|
| 492 |
-
return -1
|
| 493 |
-
} else if (a === b) {
|
| 494 |
-
continue
|
| 495 |
-
} else {
|
| 496 |
-
return compareIdentifiers(a, b)
|
| 497 |
-
}
|
| 498 |
-
} while (++i)
|
| 499 |
-
}
|
| 500 |
-
|
| 501 |
-
// preminor will bump the version up to the next minor release, and immediately
|
| 502 |
-
// down to pre-release. premajor and prepatch work the same way.
|
| 503 |
-
SemVer.prototype.inc = function (release, identifier) {
|
| 504 |
-
switch (release) {
|
| 505 |
-
case 'premajor':
|
| 506 |
-
this.prerelease.length = 0
|
| 507 |
-
this.patch = 0
|
| 508 |
-
this.minor = 0
|
| 509 |
-
this.major++
|
| 510 |
-
this.inc('pre', identifier)
|
| 511 |
-
break
|
| 512 |
-
case 'preminor':
|
| 513 |
-
this.prerelease.length = 0
|
| 514 |
-
this.patch = 0
|
| 515 |
-
this.minor++
|
| 516 |
-
this.inc('pre', identifier)
|
| 517 |
-
break
|
| 518 |
-
case 'prepatch':
|
| 519 |
-
// If this is already a prerelease, it will bump to the next version
|
| 520 |
-
// drop any prereleases that might already exist, since they are not
|
| 521 |
-
// relevant at this point.
|
| 522 |
-
this.prerelease.length = 0
|
| 523 |
-
this.inc('patch', identifier)
|
| 524 |
-
this.inc('pre', identifier)
|
| 525 |
-
break
|
| 526 |
-
// If the input is a non-prerelease version, this acts the same as
|
| 527 |
-
// prepatch.
|
| 528 |
-
case 'prerelease':
|
| 529 |
-
if (this.prerelease.length === 0) {
|
| 530 |
-
this.inc('patch', identifier)
|
| 531 |
-
}
|
| 532 |
-
this.inc('pre', identifier)
|
| 533 |
-
break
|
| 534 |
-
|
| 535 |
-
case 'major':
|
| 536 |
-
// If this is a pre-major version, bump up to the same major version.
|
| 537 |
-
// Otherwise increment major.
|
| 538 |
-
// 1.0.0-5 bumps to 1.0.0
|
| 539 |
-
// 1.1.0 bumps to 2.0.0
|
| 540 |
-
if (this.minor !== 0 ||
|
| 541 |
-
this.patch !== 0 ||
|
| 542 |
-
this.prerelease.length === 0) {
|
| 543 |
-
this.major++
|
| 544 |
-
}
|
| 545 |
-
this.minor = 0
|
| 546 |
-
this.patch = 0
|
| 547 |
-
this.prerelease = []
|
| 548 |
-
break
|
| 549 |
-
case 'minor':
|
| 550 |
-
// If this is a pre-minor version, bump up to the same minor version.
|
| 551 |
-
// Otherwise increment minor.
|
| 552 |
-
// 1.2.0-5 bumps to 1.2.0
|
| 553 |
-
// 1.2.1 bumps to 1.3.0
|
| 554 |
-
if (this.patch !== 0 || this.prerelease.length === 0) {
|
| 555 |
-
this.minor++
|
| 556 |
-
}
|
| 557 |
-
this.patch = 0
|
| 558 |
-
this.prerelease = []
|
| 559 |
-
break
|
| 560 |
-
case 'patch':
|
| 561 |
-
// If this is not a pre-release version, it will increment the patch.
|
| 562 |
-
// If it is a pre-release it will bump up to the same patch version.
|
| 563 |
-
// 1.2.0-5 patches to 1.2.0
|
| 564 |
-
// 1.2.0 patches to 1.2.1
|
| 565 |
-
if (this.prerelease.length === 0) {
|
| 566 |
-
this.patch++
|
| 567 |
-
}
|
| 568 |
-
this.prerelease = []
|
| 569 |
-
break
|
| 570 |
-
// This probably shouldn't be used publicly.
|
| 571 |
-
// 1.0.0 "pre" would become 1.0.0-0 which is the wrong direction.
|
| 572 |
-
case 'pre':
|
| 573 |
-
if (this.prerelease.length === 0) {
|
| 574 |
-
this.prerelease = [0]
|
| 575 |
-
} else {
|
| 576 |
-
var i = this.prerelease.length
|
| 577 |
-
while (--i >= 0) {
|
| 578 |
-
if (typeof this.prerelease[i] === 'number') {
|
| 579 |
-
this.prerelease[i]++
|
| 580 |
-
i = -2
|
| 581 |
-
}
|
| 582 |
-
}
|
| 583 |
-
if (i === -1) {
|
| 584 |
-
// didn't increment anything
|
| 585 |
-
this.prerelease.push(0)
|
| 586 |
-
}
|
| 587 |
-
}
|
| 588 |
-
if (identifier) {
|
| 589 |
-
// 1.2.0-beta.1 bumps to 1.2.0-beta.2,
|
| 590 |
-
// 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0
|
| 591 |
-
if (this.prerelease[0] === identifier) {
|
| 592 |
-
if (isNaN(this.prerelease[1])) {
|
| 593 |
-
this.prerelease = [identifier, 0]
|
| 594 |
-
}
|
| 595 |
-
} else {
|
| 596 |
-
this.prerelease = [identifier, 0]
|
| 597 |
-
}
|
| 598 |
-
}
|
| 599 |
-
break
|
| 600 |
-
|
| 601 |
-
default:
|
| 602 |
-
throw new Error('invalid increment argument: ' + release)
|
| 603 |
-
}
|
| 604 |
-
this.format()
|
| 605 |
-
this.raw = this.version
|
| 606 |
-
return this
|
| 607 |
-
}
|
| 608 |
-
|
| 609 |
-
exports.inc = inc
|
| 610 |
-
function inc (version, release, loose, identifier) {
|
| 611 |
-
if (typeof (loose) === 'string') {
|
| 612 |
-
identifier = loose
|
| 613 |
-
loose = undefined
|
| 614 |
-
}
|
| 615 |
-
|
| 616 |
-
try {
|
| 617 |
-
return new SemVer(version, loose).inc(release, identifier).version
|
| 618 |
-
} catch (er) {
|
| 619 |
-
return null
|
| 620 |
-
}
|
| 621 |
-
}
|
| 622 |
-
|
| 623 |
-
exports.diff = diff
|
| 624 |
-
function diff (version1, version2) {
|
| 625 |
-
if (eq(version1, version2)) {
|
| 626 |
-
return null
|
| 627 |
-
} else {
|
| 628 |
-
var v1 = parse(version1)
|
| 629 |
-
var v2 = parse(version2)
|
| 630 |
-
var prefix = ''
|
| 631 |
-
if (v1.prerelease.length || v2.prerelease.length) {
|
| 632 |
-
prefix = 'pre'
|
| 633 |
-
var defaultResult = 'prerelease'
|
| 634 |
-
}
|
| 635 |
-
for (var key in v1) {
|
| 636 |
-
if (key === 'major' || key === 'minor' || key === 'patch') {
|
| 637 |
-
if (v1[key] !== v2[key]) {
|
| 638 |
-
return prefix + key
|
| 639 |
-
}
|
| 640 |
-
}
|
| 641 |
-
}
|
| 642 |
-
return defaultResult // may be undefined
|
| 643 |
-
}
|
| 644 |
-
}
|
| 645 |
-
|
| 646 |
-
exports.compareIdentifiers = compareIdentifiers
|
| 647 |
-
|
| 648 |
-
var numeric = /^[0-9]+$/
|
| 649 |
-
function compareIdentifiers (a, b) {
|
| 650 |
-
var anum = numeric.test(a)
|
| 651 |
-
var bnum = numeric.test(b)
|
| 652 |
-
|
| 653 |
-
if (anum && bnum) {
|
| 654 |
-
a = +a
|
| 655 |
-
b = +b
|
| 656 |
-
}
|
| 657 |
-
|
| 658 |
-
return a === b ? 0
|
| 659 |
-
: (anum && !bnum) ? -1
|
| 660 |
-
: (bnum && !anum) ? 1
|
| 661 |
-
: a < b ? -1
|
| 662 |
-
: 1
|
| 663 |
-
}
|
| 664 |
-
|
| 665 |
-
exports.rcompareIdentifiers = rcompareIdentifiers
|
| 666 |
-
function rcompareIdentifiers (a, b) {
|
| 667 |
-
return compareIdentifiers(b, a)
|
| 668 |
-
}
|
| 669 |
-
|
| 670 |
-
exports.major = major
|
| 671 |
-
function major (a, loose) {
|
| 672 |
-
return new SemVer(a, loose).major
|
| 673 |
-
}
|
| 674 |
-
|
| 675 |
-
exports.minor = minor
|
| 676 |
-
function minor (a, loose) {
|
| 677 |
-
return new SemVer(a, loose).minor
|
| 678 |
-
}
|
| 679 |
-
|
| 680 |
-
exports.patch = patch
|
| 681 |
-
function patch (a, loose) {
|
| 682 |
-
return new SemVer(a, loose).patch
|
| 683 |
-
}
|
| 684 |
-
|
| 685 |
-
exports.compare = compare
|
| 686 |
-
function compare (a, b, loose) {
|
| 687 |
-
return new SemVer(a, loose).compare(new SemVer(b, loose))
|
| 688 |
-
}
|
| 689 |
-
|
| 690 |
-
exports.compareLoose = compareLoose
|
| 691 |
-
function compareLoose (a, b) {
|
| 692 |
-
return compare(a, b, true)
|
| 693 |
-
}
|
| 694 |
-
|
| 695 |
-
exports.compareBuild = compareBuild
|
| 696 |
-
function compareBuild (a, b, loose) {
|
| 697 |
-
var versionA = new SemVer(a, loose)
|
| 698 |
-
var versionB = new SemVer(b, loose)
|
| 699 |
-
return versionA.compare(versionB) || versionA.compareBuild(versionB)
|
| 700 |
-
}
|
| 701 |
-
|
| 702 |
-
exports.rcompare = rcompare
|
| 703 |
-
function rcompare (a, b, loose) {
|
| 704 |
-
return compare(b, a, loose)
|
| 705 |
-
}
|
| 706 |
-
|
| 707 |
-
exports.sort = sort
|
| 708 |
-
function sort (list, loose) {
|
| 709 |
-
return list.sort(function (a, b) {
|
| 710 |
-
return exports.compareBuild(a, b, loose)
|
| 711 |
-
})
|
| 712 |
-
}
|
| 713 |
-
|
| 714 |
-
exports.rsort = rsort
|
| 715 |
-
function rsort (list, loose) {
|
| 716 |
-
return list.sort(function (a, b) {
|
| 717 |
-
return exports.compareBuild(b, a, loose)
|
| 718 |
-
})
|
| 719 |
-
}
|
| 720 |
-
|
| 721 |
-
exports.gt = gt
|
| 722 |
-
function gt (a, b, loose) {
|
| 723 |
-
return compare(a, b, loose) > 0
|
| 724 |
-
}
|
| 725 |
-
|
| 726 |
-
exports.lt = lt
|
| 727 |
-
function lt (a, b, loose) {
|
| 728 |
-
return compare(a, b, loose) < 0
|
| 729 |
-
}
|
| 730 |
-
|
| 731 |
-
exports.eq = eq
|
| 732 |
-
function eq (a, b, loose) {
|
| 733 |
-
return compare(a, b, loose) === 0
|
| 734 |
-
}
|
| 735 |
-
|
| 736 |
-
exports.neq = neq
|
| 737 |
-
function neq (a, b, loose) {
|
| 738 |
-
return compare(a, b, loose) !== 0
|
| 739 |
-
}
|
| 740 |
-
|
| 741 |
-
exports.gte = gte
|
| 742 |
-
function gte (a, b, loose) {
|
| 743 |
-
return compare(a, b, loose) >= 0
|
| 744 |
-
}
|
| 745 |
-
|
| 746 |
-
exports.lte = lte
|
| 747 |
-
function lte (a, b, loose) {
|
| 748 |
-
return compare(a, b, loose) <= 0
|
| 749 |
-
}
|
| 750 |
-
|
| 751 |
-
exports.cmp = cmp
|
| 752 |
-
function cmp (a, op, b, loose) {
|
| 753 |
-
switch (op) {
|
| 754 |
-
case '===':
|
| 755 |
-
if (typeof a === 'object')
|
| 756 |
-
a = a.version
|
| 757 |
-
if (typeof b === 'object')
|
| 758 |
-
b = b.version
|
| 759 |
-
return a === b
|
| 760 |
-
|
| 761 |
-
case '!==':
|
| 762 |
-
if (typeof a === 'object')
|
| 763 |
-
a = a.version
|
| 764 |
-
if (typeof b === 'object')
|
| 765 |
-
b = b.version
|
| 766 |
-
return a !== b
|
| 767 |
-
|
| 768 |
-
case '':
|
| 769 |
-
case '=':
|
| 770 |
-
case '==':
|
| 771 |
-
return eq(a, b, loose)
|
| 772 |
-
|
| 773 |
-
case '!=':
|
| 774 |
-
return neq(a, b, loose)
|
| 775 |
-
|
| 776 |
-
case '>':
|
| 777 |
-
return gt(a, b, loose)
|
| 778 |
-
|
| 779 |
-
case '>=':
|
| 780 |
-
return gte(a, b, loose)
|
| 781 |
-
|
| 782 |
-
case '<':
|
| 783 |
-
return lt(a, b, loose)
|
| 784 |
-
|
| 785 |
-
case '<=':
|
| 786 |
-
return lte(a, b, loose)
|
| 787 |
-
|
| 788 |
-
default:
|
| 789 |
-
throw new TypeError('Invalid operator: ' + op)
|
| 790 |
-
}
|
| 791 |
-
}
|
| 792 |
-
|
| 793 |
-
exports.Comparator = Comparator
|
| 794 |
-
function Comparator (comp, options) {
|
| 795 |
-
if (!options || typeof options !== 'object') {
|
| 796 |
-
options = {
|
| 797 |
-
loose: !!options,
|
| 798 |
-
includePrerelease: false
|
| 799 |
-
}
|
| 800 |
-
}
|
| 801 |
-
|
| 802 |
-
if (comp instanceof Comparator) {
|
| 803 |
-
if (comp.loose === !!options.loose) {
|
| 804 |
-
return comp
|
| 805 |
-
} else {
|
| 806 |
-
comp = comp.value
|
| 807 |
-
}
|
| 808 |
-
}
|
| 809 |
-
|
| 810 |
-
if (!(this instanceof Comparator)) {
|
| 811 |
-
return new Comparator(comp, options)
|
| 812 |
-
}
|
| 813 |
-
|
| 814 |
-
comp = comp.trim().split(/\s+/).join(' ')
|
| 815 |
-
debug('comparator', comp, options)
|
| 816 |
-
this.options = options
|
| 817 |
-
this.loose = !!options.loose
|
| 818 |
-
this.parse(comp)
|
| 819 |
-
|
| 820 |
-
if (this.semver === ANY) {
|
| 821 |
-
this.value = ''
|
| 822 |
-
} else {
|
| 823 |
-
this.value = this.operator + this.semver.version
|
| 824 |
-
}
|
| 825 |
-
|
| 826 |
-
debug('comp', this)
|
| 827 |
-
}
|
| 828 |
-
|
| 829 |
-
var ANY = {}
|
| 830 |
-
Comparator.prototype.parse = function (comp) {
|
| 831 |
-
var r = this.options.loose ? safeRe[t.COMPARATORLOOSE] : safeRe[t.COMPARATOR]
|
| 832 |
-
var m = comp.match(r)
|
| 833 |
-
|
| 834 |
-
if (!m) {
|
| 835 |
-
throw new TypeError('Invalid comparator: ' + comp)
|
| 836 |
-
}
|
| 837 |
-
|
| 838 |
-
this.operator = m[1] !== undefined ? m[1] : ''
|
| 839 |
-
if (this.operator === '=') {
|
| 840 |
-
this.operator = ''
|
| 841 |
-
}
|
| 842 |
-
|
| 843 |
-
// if it literally is just '>' or '' then allow anything.
|
| 844 |
-
if (!m[2]) {
|
| 845 |
-
this.semver = ANY
|
| 846 |
-
} else {
|
| 847 |
-
this.semver = new SemVer(m[2], this.options.loose)
|
| 848 |
-
}
|
| 849 |
-
}
|
| 850 |
-
|
| 851 |
-
Comparator.prototype.toString = function () {
|
| 852 |
-
return this.value
|
| 853 |
-
}
|
| 854 |
-
|
| 855 |
-
Comparator.prototype.test = function (version) {
|
| 856 |
-
debug('Comparator.test', version, this.options.loose)
|
| 857 |
-
|
| 858 |
-
if (this.semver === ANY || version === ANY) {
|
| 859 |
-
return true
|
| 860 |
-
}
|
| 861 |
-
|
| 862 |
-
if (typeof version === 'string') {
|
| 863 |
-
try {
|
| 864 |
-
version = new SemVer(version, this.options)
|
| 865 |
-
} catch (er) {
|
| 866 |
-
return false
|
| 867 |
-
}
|
| 868 |
-
}
|
| 869 |
-
|
| 870 |
-
return cmp(version, this.operator, this.semver, this.options)
|
| 871 |
-
}
|
| 872 |
-
|
| 873 |
-
Comparator.prototype.intersects = function (comp, options) {
|
| 874 |
-
if (!(comp instanceof Comparator)) {
|
| 875 |
-
throw new TypeError('a Comparator is required')
|
| 876 |
-
}
|
| 877 |
-
|
| 878 |
-
if (!options || typeof options !== 'object') {
|
| 879 |
-
options = {
|
| 880 |
-
loose: !!options,
|
| 881 |
-
includePrerelease: false
|
| 882 |
-
}
|
| 883 |
-
}
|
| 884 |
-
|
| 885 |
-
var rangeTmp
|
| 886 |
-
|
| 887 |
-
if (this.operator === '') {
|
| 888 |
-
if (this.value === '') {
|
| 889 |
-
return true
|
| 890 |
-
}
|
| 891 |
-
rangeTmp = new Range(comp.value, options)
|
| 892 |
-
return satisfies(this.value, rangeTmp, options)
|
| 893 |
-
} else if (comp.operator === '') {
|
| 894 |
-
if (comp.value === '') {
|
| 895 |
-
return true
|
| 896 |
-
}
|
| 897 |
-
rangeTmp = new Range(this.value, options)
|
| 898 |
-
return satisfies(comp.semver, rangeTmp, options)
|
| 899 |
-
}
|
| 900 |
-
|
| 901 |
-
var sameDirectionIncreasing =
|
| 902 |
-
(this.operator === '>=' || this.operator === '>') &&
|
| 903 |
-
(comp.operator === '>=' || comp.operator === '>')
|
| 904 |
-
var sameDirectionDecreasing =
|
| 905 |
-
(this.operator === '<=' || this.operator === '<') &&
|
| 906 |
-
(comp.operator === '<=' || comp.operator === '<')
|
| 907 |
-
var sameSemVer = this.semver.version === comp.semver.version
|
| 908 |
-
var differentDirectionsInclusive =
|
| 909 |
-
(this.operator === '>=' || this.operator === '<=') &&
|
| 910 |
-
(comp.operator === '>=' || comp.operator === '<=')
|
| 911 |
-
var oppositeDirectionsLessThan =
|
| 912 |
-
cmp(this.semver, '<', comp.semver, options) &&
|
| 913 |
-
((this.operator === '>=' || this.operator === '>') &&
|
| 914 |
-
(comp.operator === '<=' || comp.operator === '<'))
|
| 915 |
-
var oppositeDirectionsGreaterThan =
|
| 916 |
-
cmp(this.semver, '>', comp.semver, options) &&
|
| 917 |
-
((this.operator === '<=' || this.operator === '<') &&
|
| 918 |
-
(comp.operator === '>=' || comp.operator === '>'))
|
| 919 |
-
|
| 920 |
-
return sameDirectionIncreasing || sameDirectionDecreasing ||
|
| 921 |
-
(sameSemVer && differentDirectionsInclusive) ||
|
| 922 |
-
oppositeDirectionsLessThan || oppositeDirectionsGreaterThan
|
| 923 |
-
}
|
| 924 |
-
|
| 925 |
-
exports.Range = Range
|
| 926 |
-
function Range (range, options) {
|
| 927 |
-
if (!options || typeof options !== 'object') {
|
| 928 |
-
options = {
|
| 929 |
-
loose: !!options,
|
| 930 |
-
includePrerelease: false
|
| 931 |
-
}
|
| 932 |
-
}
|
| 933 |
-
|
| 934 |
-
if (range instanceof Range) {
|
| 935 |
-
if (range.loose === !!options.loose &&
|
| 936 |
-
range.includePrerelease === !!options.includePrerelease) {
|
| 937 |
-
return range
|
| 938 |
-
} else {
|
| 939 |
-
return new Range(range.raw, options)
|
| 940 |
-
}
|
| 941 |
-
}
|
| 942 |
-
|
| 943 |
-
if (range instanceof Comparator) {
|
| 944 |
-
return new Range(range.value, options)
|
| 945 |
-
}
|
| 946 |
-
|
| 947 |
-
if (!(this instanceof Range)) {
|
| 948 |
-
return new Range(range, options)
|
| 949 |
-
}
|
| 950 |
-
|
| 951 |
-
this.options = options
|
| 952 |
-
this.loose = !!options.loose
|
| 953 |
-
this.includePrerelease = !!options.includePrerelease
|
| 954 |
-
|
| 955 |
-
// First reduce all whitespace as much as possible so we do not have to rely
|
| 956 |
-
// on potentially slow regexes like \s*. This is then stored and used for
|
| 957 |
-
// future error messages as well.
|
| 958 |
-
this.raw = range
|
| 959 |
-
.trim()
|
| 960 |
-
.split(/\s+/)
|
| 961 |
-
.join(' ')
|
| 962 |
-
|
| 963 |
-
// First, split based on boolean or ||
|
| 964 |
-
this.set = this.raw.split('||').map(function (range) {
|
| 965 |
-
return this.parseRange(range.trim())
|
| 966 |
-
}, this).filter(function (c) {
|
| 967 |
-
// throw out any that are not relevant for whatever reason
|
| 968 |
-
return c.length
|
| 969 |
-
})
|
| 970 |
-
|
| 971 |
-
if (!this.set.length) {
|
| 972 |
-
throw new TypeError('Invalid SemVer Range: ' + this.raw)
|
| 973 |
-
}
|
| 974 |
-
|
| 975 |
-
this.format()
|
| 976 |
-
}
|
| 977 |
-
|
| 978 |
-
Range.prototype.format = function () {
|
| 979 |
-
this.range = this.set.map(function (comps) {
|
| 980 |
-
return comps.join(' ').trim()
|
| 981 |
-
}).join('||').trim()
|
| 982 |
-
return this.range
|
| 983 |
-
}
|
| 984 |
-
|
| 985 |
-
Range.prototype.toString = function () {
|
| 986 |
-
return this.range
|
| 987 |
-
}
|
| 988 |
-
|
| 989 |
-
Range.prototype.parseRange = function (range) {
|
| 990 |
-
var loose = this.options.loose
|
| 991 |
-
// `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4`
|
| 992 |
-
var hr = loose ? safeRe[t.HYPHENRANGELOOSE] : safeRe[t.HYPHENRANGE]
|
| 993 |
-
range = range.replace(hr, hyphenReplace)
|
| 994 |
-
debug('hyphen replace', range)
|
| 995 |
-
// `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5`
|
| 996 |
-
range = range.replace(safeRe[t.COMPARATORTRIM], comparatorTrimReplace)
|
| 997 |
-
debug('comparator trim', range, safeRe[t.COMPARATORTRIM])
|
| 998 |
-
|
| 999 |
-
// `~ 1.2.3` => `~1.2.3`
|
| 1000 |
-
range = range.replace(safeRe[t.TILDETRIM], tildeTrimReplace)
|
| 1001 |
-
|
| 1002 |
-
// `^ 1.2.3` => `^1.2.3`
|
| 1003 |
-
range = range.replace(safeRe[t.CARETTRIM], caretTrimReplace)
|
| 1004 |
-
|
| 1005 |
-
// normalize spaces
|
| 1006 |
-
range = range.split(/\s+/).join(' ')
|
| 1007 |
-
|
| 1008 |
-
// At this point, the range is completely trimmed and
|
| 1009 |
-
// ready to be split into comparators.
|
| 1010 |
-
|
| 1011 |
-
var compRe = loose ? safeRe[t.COMPARATORLOOSE] : safeRe[t.COMPARATOR]
|
| 1012 |
-
var set = range.split(' ').map(function (comp) {
|
| 1013 |
-
return parseComparator(comp, this.options)
|
| 1014 |
-
}, this).join(' ').split(/\s+/)
|
| 1015 |
-
if (this.options.loose) {
|
| 1016 |
-
// in loose mode, throw out any that are not valid comparators
|
| 1017 |
-
set = set.filter(function (comp) {
|
| 1018 |
-
return !!comp.match(compRe)
|
| 1019 |
-
})
|
| 1020 |
-
}
|
| 1021 |
-
set = set.map(function (comp) {
|
| 1022 |
-
return new Comparator(comp, this.options)
|
| 1023 |
-
}, this)
|
| 1024 |
-
|
| 1025 |
-
return set
|
| 1026 |
-
}
|
| 1027 |
-
|
| 1028 |
-
Range.prototype.intersects = function (range, options) {
|
| 1029 |
-
if (!(range instanceof Range)) {
|
| 1030 |
-
throw new TypeError('a Range is required')
|
| 1031 |
-
}
|
| 1032 |
-
|
| 1033 |
-
return this.set.some(function (thisComparators) {
|
| 1034 |
-
return (
|
| 1035 |
-
isSatisfiable(thisComparators, options) &&
|
| 1036 |
-
range.set.some(function (rangeComparators) {
|
| 1037 |
-
return (
|
| 1038 |
-
isSatisfiable(rangeComparators, options) &&
|
| 1039 |
-
thisComparators.every(function (thisComparator) {
|
| 1040 |
-
return rangeComparators.every(function (rangeComparator) {
|
| 1041 |
-
return thisComparator.intersects(rangeComparator, options)
|
| 1042 |
-
})
|
| 1043 |
-
})
|
| 1044 |
-
)
|
| 1045 |
-
})
|
| 1046 |
-
)
|
| 1047 |
-
})
|
| 1048 |
-
}
|
| 1049 |
-
|
| 1050 |
-
// take a set of comparators and determine whether there
|
| 1051 |
-
// exists a version which can satisfy it
|
| 1052 |
-
function isSatisfiable (comparators, options) {
|
| 1053 |
-
var result = true
|
| 1054 |
-
var remainingComparators = comparators.slice()
|
| 1055 |
-
var testComparator = remainingComparators.pop()
|
| 1056 |
-
|
| 1057 |
-
while (result && remainingComparators.length) {
|
| 1058 |
-
result = remainingComparators.every(function (otherComparator) {
|
| 1059 |
-
return testComparator.intersects(otherComparator, options)
|
| 1060 |
-
})
|
| 1061 |
-
|
| 1062 |
-
testComparator = remainingComparators.pop()
|
| 1063 |
-
}
|
| 1064 |
-
|
| 1065 |
-
return result
|
| 1066 |
-
}
|
| 1067 |
-
|
| 1068 |
-
// Mostly just for testing and legacy API reasons
|
| 1069 |
-
exports.toComparators = toComparators
|
| 1070 |
-
function toComparators (range, options) {
|
| 1071 |
-
return new Range(range, options).set.map(function (comp) {
|
| 1072 |
-
return comp.map(function (c) {
|
| 1073 |
-
return c.value
|
| 1074 |
-
}).join(' ').trim().split(' ')
|
| 1075 |
-
})
|
| 1076 |
-
}
|
| 1077 |
-
|
| 1078 |
-
// comprised of xranges, tildes, stars, and gtlt's at this point.
|
| 1079 |
-
// already replaced the hyphen ranges
|
| 1080 |
-
// turn into a set of JUST comparators.
|
| 1081 |
-
function parseComparator (comp, options) {
|
| 1082 |
-
debug('comp', comp, options)
|
| 1083 |
-
comp = replaceCarets(comp, options)
|
| 1084 |
-
debug('caret', comp)
|
| 1085 |
-
comp = replaceTildes(comp, options)
|
| 1086 |
-
debug('tildes', comp)
|
| 1087 |
-
comp = replaceXRanges(comp, options)
|
| 1088 |
-
debug('xrange', comp)
|
| 1089 |
-
comp = replaceStars(comp, options)
|
| 1090 |
-
debug('stars', comp)
|
| 1091 |
-
return comp
|
| 1092 |
-
}
|
| 1093 |
-
|
| 1094 |
-
function isX (id) {
|
| 1095 |
-
return !id || id.toLowerCase() === 'x' || id === '*'
|
| 1096 |
-
}
|
| 1097 |
-
|
| 1098 |
-
// ~, ~> --> * (any, kinda silly)
|
| 1099 |
-
// ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0
|
| 1100 |
-
// ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0
|
| 1101 |
-
// ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0
|
| 1102 |
-
// ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0
|
| 1103 |
-
// ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0
|
| 1104 |
-
function replaceTildes (comp, options) {
|
| 1105 |
-
return comp.trim().split(/\s+/).map(function (comp) {
|
| 1106 |
-
return replaceTilde(comp, options)
|
| 1107 |
-
}).join(' ')
|
| 1108 |
-
}
|
| 1109 |
-
|
| 1110 |
-
function replaceTilde (comp, options) {
|
| 1111 |
-
var r = options.loose ? safeRe[t.TILDELOOSE] : safeRe[t.TILDE]
|
| 1112 |
-
return comp.replace(r, function (_, M, m, p, pr) {
|
| 1113 |
-
debug('tilde', comp, _, M, m, p, pr)
|
| 1114 |
-
var ret
|
| 1115 |
-
|
| 1116 |
-
if (isX(M)) {
|
| 1117 |
-
ret = ''
|
| 1118 |
-
} else if (isX(m)) {
|
| 1119 |
-
ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0'
|
| 1120 |
-
} else if (isX(p)) {
|
| 1121 |
-
// ~1.2 == >=1.2.0 <1.3.0
|
| 1122 |
-
ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0'
|
| 1123 |
-
} else if (pr) {
|
| 1124 |
-
debug('replaceTilde pr', pr)
|
| 1125 |
-
ret = '>=' + M + '.' + m + '.' + p + '-' + pr +
|
| 1126 |
-
' <' + M + '.' + (+m + 1) + '.0'
|
| 1127 |
-
} else {
|
| 1128 |
-
// ~1.2.3 == >=1.2.3 <1.3.0
|
| 1129 |
-
ret = '>=' + M + '.' + m + '.' + p +
|
| 1130 |
-
' <' + M + '.' + (+m + 1) + '.0'
|
| 1131 |
-
}
|
| 1132 |
-
|
| 1133 |
-
debug('tilde return', ret)
|
| 1134 |
-
return ret
|
| 1135 |
-
})
|
| 1136 |
-
}
|
| 1137 |
-
|
| 1138 |
-
// ^ --> * (any, kinda silly)
|
| 1139 |
-
// ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0
|
| 1140 |
-
// ^2.0, ^2.0.x --> >=2.0.0 <3.0.0
|
| 1141 |
-
// ^1.2, ^1.2.x --> >=1.2.0 <2.0.0
|
| 1142 |
-
// ^1.2.3 --> >=1.2.3 <2.0.0
|
| 1143 |
-
// ^1.2.0 --> >=1.2.0 <2.0.0
|
| 1144 |
-
function replaceCarets (comp, options) {
|
| 1145 |
-
return comp.trim().split(/\s+/).map(function (comp) {
|
| 1146 |
-
return replaceCaret(comp, options)
|
| 1147 |
-
}).join(' ')
|
| 1148 |
-
}
|
| 1149 |
-
|
| 1150 |
-
function replaceCaret (comp, options) {
|
| 1151 |
-
debug('caret', comp, options)
|
| 1152 |
-
var r = options.loose ? safeRe[t.CARETLOOSE] : safeRe[t.CARET]
|
| 1153 |
-
return comp.replace(r, function (_, M, m, p, pr) {
|
| 1154 |
-
debug('caret', comp, _, M, m, p, pr)
|
| 1155 |
-
var ret
|
| 1156 |
-
|
| 1157 |
-
if (isX(M)) {
|
| 1158 |
-
ret = ''
|
| 1159 |
-
} else if (isX(m)) {
|
| 1160 |
-
ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0'
|
| 1161 |
-
} else if (isX(p)) {
|
| 1162 |
-
if (M === '0') {
|
| 1163 |
-
ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0'
|
| 1164 |
-
} else {
|
| 1165 |
-
ret = '>=' + M + '.' + m + '.0 <' + (+M + 1) + '.0.0'
|
| 1166 |
-
}
|
| 1167 |
-
} else if (pr) {
|
| 1168 |
-
debug('replaceCaret pr', pr)
|
| 1169 |
-
if (M === '0') {
|
| 1170 |
-
if (m === '0') {
|
| 1171 |
-
ret = '>=' + M + '.' + m + '.' + p + '-' + pr +
|
| 1172 |
-
' <' + M + '.' + m + '.' + (+p + 1)
|
| 1173 |
-
} else {
|
| 1174 |
-
ret = '>=' + M + '.' + m + '.' + p + '-' + pr +
|
| 1175 |
-
' <' + M + '.' + (+m + 1) + '.0'
|
| 1176 |
-
}
|
| 1177 |
-
} else {
|
| 1178 |
-
ret = '>=' + M + '.' + m + '.' + p + '-' + pr +
|
| 1179 |
-
' <' + (+M + 1) + '.0.0'
|
| 1180 |
-
}
|
| 1181 |
-
} else {
|
| 1182 |
-
debug('no pr')
|
| 1183 |
-
if (M === '0') {
|
| 1184 |
-
if (m === '0') {
|
| 1185 |
-
ret = '>=' + M + '.' + m + '.' + p +
|
| 1186 |
-
' <' + M + '.' + m + '.' + (+p + 1)
|
| 1187 |
-
} else {
|
| 1188 |
-
ret = '>=' + M + '.' + m + '.' + p +
|
| 1189 |
-
' <' + M + '.' + (+m + 1) + '.0'
|
| 1190 |
-
}
|
| 1191 |
-
} else {
|
| 1192 |
-
ret = '>=' + M + '.' + m + '.' + p +
|
| 1193 |
-
' <' + (+M + 1) + '.0.0'
|
| 1194 |
-
}
|
| 1195 |
-
}
|
| 1196 |
-
|
| 1197 |
-
debug('caret return', ret)
|
| 1198 |
-
return ret
|
| 1199 |
-
})
|
| 1200 |
-
}
|
| 1201 |
-
|
| 1202 |
-
function replaceXRanges (comp, options) {
|
| 1203 |
-
debug('replaceXRanges', comp, options)
|
| 1204 |
-
return comp.split(/\s+/).map(function (comp) {
|
| 1205 |
-
return replaceXRange(comp, options)
|
| 1206 |
-
}).join(' ')
|
| 1207 |
-
}
|
| 1208 |
-
|
| 1209 |
-
function replaceXRange (comp, options) {
|
| 1210 |
-
comp = comp.trim()
|
| 1211 |
-
var r = options.loose ? safeRe[t.XRANGELOOSE] : safeRe[t.XRANGE]
|
| 1212 |
-
return comp.replace(r, function (ret, gtlt, M, m, p, pr) {
|
| 1213 |
-
debug('xRange', comp, ret, gtlt, M, m, p, pr)
|
| 1214 |
-
var xM = isX(M)
|
| 1215 |
-
var xm = xM || isX(m)
|
| 1216 |
-
var xp = xm || isX(p)
|
| 1217 |
-
var anyX = xp
|
| 1218 |
-
|
| 1219 |
-
if (gtlt === '=' && anyX) {
|
| 1220 |
-
gtlt = ''
|
| 1221 |
-
}
|
| 1222 |
-
|
| 1223 |
-
// if we're including prereleases in the match, then we need
|
| 1224 |
-
// to fix this to -0, the lowest possible prerelease value
|
| 1225 |
-
pr = options.includePrerelease ? '-0' : ''
|
| 1226 |
-
|
| 1227 |
-
if (xM) {
|
| 1228 |
-
if (gtlt === '>' || gtlt === '<') {
|
| 1229 |
-
// nothing is allowed
|
| 1230 |
-
ret = '<0.0.0-0'
|
| 1231 |
-
} else {
|
| 1232 |
-
// nothing is forbidden
|
| 1233 |
-
ret = '*'
|
| 1234 |
-
}
|
| 1235 |
-
} else if (gtlt && anyX) {
|
| 1236 |
-
// we know patch is an x, because we have any x at all.
|
| 1237 |
-
// replace X with 0
|
| 1238 |
-
if (xm) {
|
| 1239 |
-
m = 0
|
| 1240 |
-
}
|
| 1241 |
-
p = 0
|
| 1242 |
-
|
| 1243 |
-
if (gtlt === '>') {
|
| 1244 |
-
// >1 => >=2.0.0
|
| 1245 |
-
// >1.2 => >=1.3.0
|
| 1246 |
-
// >1.2.3 => >= 1.2.4
|
| 1247 |
-
gtlt = '>='
|
| 1248 |
-
if (xm) {
|
| 1249 |
-
M = +M + 1
|
| 1250 |
-
m = 0
|
| 1251 |
-
p = 0
|
| 1252 |
-
} else {
|
| 1253 |
-
m = +m + 1
|
| 1254 |
-
p = 0
|
| 1255 |
-
}
|
| 1256 |
-
} else if (gtlt === '<=') {
|
| 1257 |
-
// <=0.7.x is actually <0.8.0, since any 0.7.x should
|
| 1258 |
-
// pass. Similarly, <=7.x is actually <8.0.0, etc.
|
| 1259 |
-
gtlt = '<'
|
| 1260 |
-
if (xm) {
|
| 1261 |
-
M = +M + 1
|
| 1262 |
-
} else {
|
| 1263 |
-
m = +m + 1
|
| 1264 |
-
}
|
| 1265 |
-
}
|
| 1266 |
-
|
| 1267 |
-
ret = gtlt + M + '.' + m + '.' + p + pr
|
| 1268 |
-
} else if (xm) {
|
| 1269 |
-
ret = '>=' + M + '.0.0' + pr + ' <' + (+M + 1) + '.0.0' + pr
|
| 1270 |
-
} else if (xp) {
|
| 1271 |
-
ret = '>=' + M + '.' + m + '.0' + pr +
|
| 1272 |
-
' <' + M + '.' + (+m + 1) + '.0' + pr
|
| 1273 |
-
}
|
| 1274 |
-
|
| 1275 |
-
debug('xRange return', ret)
|
| 1276 |
-
|
| 1277 |
-
return ret
|
| 1278 |
-
})
|
| 1279 |
-
}
|
| 1280 |
-
|
| 1281 |
-
// Because * is AND-ed with everything else in the comparator,
|
| 1282 |
-
// and '' means "any version", just remove the *s entirely.
|
| 1283 |
-
function replaceStars (comp, options) {
|
| 1284 |
-
debug('replaceStars', comp, options)
|
| 1285 |
-
// Looseness is ignored here. star is always as loose as it gets!
|
| 1286 |
-
return comp.trim().replace(safeRe[t.STAR], '')
|
| 1287 |
-
}
|
| 1288 |
-
|
| 1289 |
-
// This function is passed to string.replace(re[t.HYPHENRANGE])
|
| 1290 |
-
// M, m, patch, prerelease, build
|
| 1291 |
-
// 1.2 - 3.4.5 => >=1.2.0 <=3.4.5
|
| 1292 |
-
// 1.2.3 - 3.4 => >=1.2.0 <3.5.0 Any 3.4.x will do
|
| 1293 |
-
// 1.2 - 3.4 => >=1.2.0 <3.5.0
|
| 1294 |
-
function hyphenReplace ($0,
|
| 1295 |
-
from, fM, fm, fp, fpr, fb,
|
| 1296 |
-
to, tM, tm, tp, tpr, tb) {
|
| 1297 |
-
if (isX(fM)) {
|
| 1298 |
-
from = ''
|
| 1299 |
-
} else if (isX(fm)) {
|
| 1300 |
-
from = '>=' + fM + '.0.0'
|
| 1301 |
-
} else if (isX(fp)) {
|
| 1302 |
-
from = '>=' + fM + '.' + fm + '.0'
|
| 1303 |
-
} else {
|
| 1304 |
-
from = '>=' + from
|
| 1305 |
-
}
|
| 1306 |
-
|
| 1307 |
-
if (isX(tM)) {
|
| 1308 |
-
to = ''
|
| 1309 |
-
} else if (isX(tm)) {
|
| 1310 |
-
to = '<' + (+tM + 1) + '.0.0'
|
| 1311 |
-
} else if (isX(tp)) {
|
| 1312 |
-
to = '<' + tM + '.' + (+tm + 1) + '.0'
|
| 1313 |
-
} else if (tpr) {
|
| 1314 |
-
to = '<=' + tM + '.' + tm + '.' + tp + '-' + tpr
|
| 1315 |
-
} else {
|
| 1316 |
-
to = '<=' + to
|
| 1317 |
-
}
|
| 1318 |
-
|
| 1319 |
-
return (from + ' ' + to).trim()
|
| 1320 |
-
}
|
| 1321 |
-
|
| 1322 |
-
// if ANY of the sets match ALL of its comparators, then pass
|
| 1323 |
-
Range.prototype.test = function (version) {
|
| 1324 |
-
if (!version) {
|
| 1325 |
-
return false
|
| 1326 |
-
}
|
| 1327 |
-
|
| 1328 |
-
if (typeof version === 'string') {
|
| 1329 |
-
try {
|
| 1330 |
-
version = new SemVer(version, this.options)
|
| 1331 |
-
} catch (er) {
|
| 1332 |
-
return false
|
| 1333 |
-
}
|
| 1334 |
-
}
|
| 1335 |
-
|
| 1336 |
-
for (var i = 0; i < this.set.length; i++) {
|
| 1337 |
-
if (testSet(this.set[i], version, this.options)) {
|
| 1338 |
-
return true
|
| 1339 |
-
}
|
| 1340 |
-
}
|
| 1341 |
-
return false
|
| 1342 |
-
}
|
| 1343 |
-
|
| 1344 |
-
function testSet (set, version, options) {
|
| 1345 |
-
for (var i = 0; i < set.length; i++) {
|
| 1346 |
-
if (!set[i].test(version)) {
|
| 1347 |
-
return false
|
| 1348 |
-
}
|
| 1349 |
-
}
|
| 1350 |
-
|
| 1351 |
-
if (version.prerelease.length && !options.includePrerelease) {
|
| 1352 |
-
// Find the set of versions that are allowed to have prereleases
|
| 1353 |
-
// For example, ^1.2.3-pr.1 desugars to >=1.2.3-pr.1 <2.0.0
|
| 1354 |
-
// That should allow `1.2.3-pr.2` to pass.
|
| 1355 |
-
// However, `1.2.4-alpha.notready` should NOT be allowed,
|
| 1356 |
-
// even though it's within the range set by the comparators.
|
| 1357 |
-
for (i = 0; i < set.length; i++) {
|
| 1358 |
-
debug(set[i].semver)
|
| 1359 |
-
if (set[i].semver === ANY) {
|
| 1360 |
-
continue
|
| 1361 |
-
}
|
| 1362 |
-
|
| 1363 |
-
if (set[i].semver.prerelease.length > 0) {
|
| 1364 |
-
var allowed = set[i].semver
|
| 1365 |
-
if (allowed.major === version.major &&
|
| 1366 |
-
allowed.minor === version.minor &&
|
| 1367 |
-
allowed.patch === version.patch) {
|
| 1368 |
-
return true
|
| 1369 |
-
}
|
| 1370 |
-
}
|
| 1371 |
-
}
|
| 1372 |
-
|
| 1373 |
-
// Version has a -pre, but it's not one of the ones we like.
|
| 1374 |
-
return false
|
| 1375 |
-
}
|
| 1376 |
-
|
| 1377 |
-
return true
|
| 1378 |
-
}
|
| 1379 |
-
|
| 1380 |
-
exports.satisfies = satisfies
|
| 1381 |
-
function satisfies (version, range, options) {
|
| 1382 |
-
try {
|
| 1383 |
-
range = new Range(range, options)
|
| 1384 |
-
} catch (er) {
|
| 1385 |
-
return false
|
| 1386 |
-
}
|
| 1387 |
-
return range.test(version)
|
| 1388 |
-
}
|
| 1389 |
-
|
| 1390 |
-
exports.maxSatisfying = maxSatisfying
|
| 1391 |
-
function maxSatisfying (versions, range, options) {
|
| 1392 |
-
var max = null
|
| 1393 |
-
var maxSV = null
|
| 1394 |
-
try {
|
| 1395 |
-
var rangeObj = new Range(range, options)
|
| 1396 |
-
} catch (er) {
|
| 1397 |
-
return null
|
| 1398 |
-
}
|
| 1399 |
-
versions.forEach(function (v) {
|
| 1400 |
-
if (rangeObj.test(v)) {
|
| 1401 |
-
// satisfies(v, range, options)
|
| 1402 |
-
if (!max || maxSV.compare(v) === -1) {
|
| 1403 |
-
// compare(max, v, true)
|
| 1404 |
-
max = v
|
| 1405 |
-
maxSV = new SemVer(max, options)
|
| 1406 |
-
}
|
| 1407 |
-
}
|
| 1408 |
-
})
|
| 1409 |
-
return max
|
| 1410 |
-
}
|
| 1411 |
-
|
| 1412 |
-
exports.minSatisfying = minSatisfying
|
| 1413 |
-
function minSatisfying (versions, range, options) {
|
| 1414 |
-
var min = null
|
| 1415 |
-
var minSV = null
|
| 1416 |
-
try {
|
| 1417 |
-
var rangeObj = new Range(range, options)
|
| 1418 |
-
} catch (er) {
|
| 1419 |
-
return null
|
| 1420 |
-
}
|
| 1421 |
-
versions.forEach(function (v) {
|
| 1422 |
-
if (rangeObj.test(v)) {
|
| 1423 |
-
// satisfies(v, range, options)
|
| 1424 |
-
if (!min || minSV.compare(v) === 1) {
|
| 1425 |
-
// compare(min, v, true)
|
| 1426 |
-
min = v
|
| 1427 |
-
minSV = new SemVer(min, options)
|
| 1428 |
-
}
|
| 1429 |
-
}
|
| 1430 |
-
})
|
| 1431 |
-
return min
|
| 1432 |
-
}
|
| 1433 |
-
|
| 1434 |
-
exports.minVersion = minVersion
|
| 1435 |
-
function minVersion (range, loose) {
|
| 1436 |
-
range = new Range(range, loose)
|
| 1437 |
-
|
| 1438 |
-
var minver = new SemVer('0.0.0')
|
| 1439 |
-
if (range.test(minver)) {
|
| 1440 |
-
return minver
|
| 1441 |
-
}
|
| 1442 |
-
|
| 1443 |
-
minver = new SemVer('0.0.0-0')
|
| 1444 |
-
if (range.test(minver)) {
|
| 1445 |
-
return minver
|
| 1446 |
-
}
|
| 1447 |
-
|
| 1448 |
-
minver = null
|
| 1449 |
-
for (var i = 0; i < range.set.length; ++i) {
|
| 1450 |
-
var comparators = range.set[i]
|
| 1451 |
-
|
| 1452 |
-
comparators.forEach(function (comparator) {
|
| 1453 |
-
// Clone to avoid manipulating the comparator's semver object.
|
| 1454 |
-
var compver = new SemVer(comparator.semver.version)
|
| 1455 |
-
switch (comparator.operator) {
|
| 1456 |
-
case '>':
|
| 1457 |
-
if (compver.prerelease.length === 0) {
|
| 1458 |
-
compver.patch++
|
| 1459 |
-
} else {
|
| 1460 |
-
compver.prerelease.push(0)
|
| 1461 |
-
}
|
| 1462 |
-
compver.raw = compver.format()
|
| 1463 |
-
/* fallthrough */
|
| 1464 |
-
case '':
|
| 1465 |
-
case '>=':
|
| 1466 |
-
if (!minver || gt(minver, compver)) {
|
| 1467 |
-
minver = compver
|
| 1468 |
-
}
|
| 1469 |
-
break
|
| 1470 |
-
case '<':
|
| 1471 |
-
case '<=':
|
| 1472 |
-
/* Ignore maximum versions */
|
| 1473 |
-
break
|
| 1474 |
-
/* istanbul ignore next */
|
| 1475 |
-
default:
|
| 1476 |
-
throw new Error('Unexpected operation: ' + comparator.operator)
|
| 1477 |
-
}
|
| 1478 |
-
})
|
| 1479 |
-
}
|
| 1480 |
-
|
| 1481 |
-
if (minver && range.test(minver)) {
|
| 1482 |
-
return minver
|
| 1483 |
-
}
|
| 1484 |
-
|
| 1485 |
-
return null
|
| 1486 |
-
}
|
| 1487 |
-
|
| 1488 |
-
exports.validRange = validRange
|
| 1489 |
-
function validRange (range, options) {
|
| 1490 |
-
try {
|
| 1491 |
-
// Return '*' instead of '' so that truthiness works.
|
| 1492 |
-
// This will throw if it's invalid anyway
|
| 1493 |
-
return new Range(range, options).range || '*'
|
| 1494 |
-
} catch (er) {
|
| 1495 |
-
return null
|
| 1496 |
-
}
|
| 1497 |
-
}
|
| 1498 |
-
|
| 1499 |
-
// Determine if version is less than all the versions possible in the range
|
| 1500 |
-
exports.ltr = ltr
|
| 1501 |
-
function ltr (version, range, options) {
|
| 1502 |
-
return outside(version, range, '<', options)
|
| 1503 |
-
}
|
| 1504 |
-
|
| 1505 |
-
// Determine if version is greater than all the versions possible in the range.
|
| 1506 |
-
exports.gtr = gtr
|
| 1507 |
-
function gtr (version, range, options) {
|
| 1508 |
-
return outside(version, range, '>', options)
|
| 1509 |
-
}
|
| 1510 |
-
|
| 1511 |
-
exports.outside = outside
|
| 1512 |
-
function outside (version, range, hilo, options) {
|
| 1513 |
-
version = new SemVer(version, options)
|
| 1514 |
-
range = new Range(range, options)
|
| 1515 |
-
|
| 1516 |
-
var gtfn, ltefn, ltfn, comp, ecomp
|
| 1517 |
-
switch (hilo) {
|
| 1518 |
-
case '>':
|
| 1519 |
-
gtfn = gt
|
| 1520 |
-
ltefn = lte
|
| 1521 |
-
ltfn = lt
|
| 1522 |
-
comp = '>'
|
| 1523 |
-
ecomp = '>='
|
| 1524 |
-
break
|
| 1525 |
-
case '<':
|
| 1526 |
-
gtfn = lt
|
| 1527 |
-
ltefn = gte
|
| 1528 |
-
ltfn = gt
|
| 1529 |
-
comp = '<'
|
| 1530 |
-
ecomp = '<='
|
| 1531 |
-
break
|
| 1532 |
-
default:
|
| 1533 |
-
throw new TypeError('Must provide a hilo val of "<" or ">"')
|
| 1534 |
-
}
|
| 1535 |
-
|
| 1536 |
-
// If it satisifes the range it is not outside
|
| 1537 |
-
if (satisfies(version, range, options)) {
|
| 1538 |
-
return false
|
| 1539 |
-
}
|
| 1540 |
-
|
| 1541 |
-
// From now on, variable terms are as if we're in "gtr" mode.
|
| 1542 |
-
// but note that everything is flipped for the "ltr" function.
|
| 1543 |
-
|
| 1544 |
-
for (var i = 0; i < range.set.length; ++i) {
|
| 1545 |
-
var comparators = range.set[i]
|
| 1546 |
-
|
| 1547 |
-
var high = null
|
| 1548 |
-
var low = null
|
| 1549 |
-
|
| 1550 |
-
comparators.forEach(function (comparator) {
|
| 1551 |
-
if (comparator.semver === ANY) {
|
| 1552 |
-
comparator = new Comparator('>=0.0.0')
|
| 1553 |
-
}
|
| 1554 |
-
high = high || comparator
|
| 1555 |
-
low = low || comparator
|
| 1556 |
-
if (gtfn(comparator.semver, high.semver, options)) {
|
| 1557 |
-
high = comparator
|
| 1558 |
-
} else if (ltfn(comparator.semver, low.semver, options)) {
|
| 1559 |
-
low = comparator
|
| 1560 |
-
}
|
| 1561 |
-
})
|
| 1562 |
-
|
| 1563 |
-
// If the edge version comparator has a operator then our version
|
| 1564 |
-
// isn't outside it
|
| 1565 |
-
if (high.operator === comp || high.operator === ecomp) {
|
| 1566 |
-
return false
|
| 1567 |
-
}
|
| 1568 |
-
|
| 1569 |
-
// If the lowest version comparator has an operator and our version
|
| 1570 |
-
// is less than it then it isn't higher than the range
|
| 1571 |
-
if ((!low.operator || low.operator === comp) &&
|
| 1572 |
-
ltefn(version, low.semver)) {
|
| 1573 |
-
return false
|
| 1574 |
-
} else if (low.operator === ecomp && ltfn(version, low.semver)) {
|
| 1575 |
-
return false
|
| 1576 |
-
}
|
| 1577 |
-
}
|
| 1578 |
-
return true
|
| 1579 |
-
}
|
| 1580 |
-
|
| 1581 |
-
exports.prerelease = prerelease
|
| 1582 |
-
function prerelease (version, options) {
|
| 1583 |
-
var parsed = parse(version, options)
|
| 1584 |
-
return (parsed && parsed.prerelease.length) ? parsed.prerelease : null
|
| 1585 |
-
}
|
| 1586 |
-
|
| 1587 |
-
exports.intersects = intersects
|
| 1588 |
-
function intersects (r1, r2, options) {
|
| 1589 |
-
r1 = new Range(r1, options)
|
| 1590 |
-
r2 = new Range(r2, options)
|
| 1591 |
-
return r1.intersects(r2)
|
| 1592 |
-
}
|
| 1593 |
-
|
| 1594 |
-
exports.coerce = coerce
|
| 1595 |
-
function coerce (version, options) {
|
| 1596 |
-
if (version instanceof SemVer) {
|
| 1597 |
-
return version
|
| 1598 |
-
}
|
| 1599 |
-
|
| 1600 |
-
if (typeof version === 'number') {
|
| 1601 |
-
version = String(version)
|
| 1602 |
-
}
|
| 1603 |
-
|
| 1604 |
-
if (typeof version !== 'string') {
|
| 1605 |
-
return null
|
| 1606 |
-
}
|
| 1607 |
-
|
| 1608 |
-
options = options || {}
|
| 1609 |
-
|
| 1610 |
-
var match = null
|
| 1611 |
-
if (!options.rtl) {
|
| 1612 |
-
match = version.match(safeRe[t.COERCE])
|
| 1613 |
-
} else {
|
| 1614 |
-
// Find the right-most coercible string that does not share
|
| 1615 |
-
// a terminus with a more left-ward coercible string.
|
| 1616 |
-
// Eg, '1.2.3.4' wants to coerce '2.3.4', not '3.4' or '4'
|
| 1617 |
-
//
|
| 1618 |
-
// Walk through the string checking with a /g regexp
|
| 1619 |
-
// Manually set the index so as to pick up overlapping matches.
|
| 1620 |
-
// Stop when we get a match that ends at the string end, since no
|
| 1621 |
-
// coercible string can be more right-ward without the same terminus.
|
| 1622 |
-
var next
|
| 1623 |
-
while ((next = safeRe[t.COERCERTL].exec(version)) &&
|
| 1624 |
-
(!match || match.index + match[0].length !== version.length)
|
| 1625 |
-
) {
|
| 1626 |
-
if (!match ||
|
| 1627 |
-
next.index + next[0].length !== match.index + match[0].length) {
|
| 1628 |
-
match = next
|
| 1629 |
-
}
|
| 1630 |
-
safeRe[t.COERCERTL].lastIndex = next.index + next[1].length + next[2].length
|
| 1631 |
-
}
|
| 1632 |
-
// leave it in a clean state
|
| 1633 |
-
safeRe[t.COERCERTL].lastIndex = -1
|
| 1634 |
-
}
|
| 1635 |
-
|
| 1636 |
-
if (match === null) {
|
| 1637 |
-
return null
|
| 1638 |
-
}
|
| 1639 |
-
|
| 1640 |
-
return parse(match[2] +
|
| 1641 |
-
'.' + (match[3] || '0') +
|
| 1642 |
-
'.' + (match[4] || '0'), options)
|
| 1643 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
node_modules/@babel/helper-compilation-targets/node_modules/.bin/semver
DELETED
|
@@ -1,174 +0,0 @@
|
|
| 1 |
-
#!/usr/bin/env node
|
| 2 |
-
// Standalone semver comparison program.
|
| 3 |
-
// Exits successfully and prints matching version(s) if
|
| 4 |
-
// any supplied version is valid and passes all tests.
|
| 5 |
-
|
| 6 |
-
var argv = process.argv.slice(2)
|
| 7 |
-
|
| 8 |
-
var versions = []
|
| 9 |
-
|
| 10 |
-
var range = []
|
| 11 |
-
|
| 12 |
-
var inc = null
|
| 13 |
-
|
| 14 |
-
var version = require('../package.json').version
|
| 15 |
-
|
| 16 |
-
var loose = false
|
| 17 |
-
|
| 18 |
-
var includePrerelease = false
|
| 19 |
-
|
| 20 |
-
var coerce = false
|
| 21 |
-
|
| 22 |
-
var rtl = false
|
| 23 |
-
|
| 24 |
-
var identifier
|
| 25 |
-
|
| 26 |
-
var semver = require('../semver')
|
| 27 |
-
|
| 28 |
-
var reverse = false
|
| 29 |
-
|
| 30 |
-
var options = {}
|
| 31 |
-
|
| 32 |
-
main()
|
| 33 |
-
|
| 34 |
-
function main () {
|
| 35 |
-
if (!argv.length) return help()
|
| 36 |
-
while (argv.length) {
|
| 37 |
-
var a = argv.shift()
|
| 38 |
-
var indexOfEqualSign = a.indexOf('=')
|
| 39 |
-
if (indexOfEqualSign !== -1) {
|
| 40 |
-
a = a.slice(0, indexOfEqualSign)
|
| 41 |
-
argv.unshift(a.slice(indexOfEqualSign + 1))
|
| 42 |
-
}
|
| 43 |
-
switch (a) {
|
| 44 |
-
case '-rv': case '-rev': case '--rev': case '--reverse':
|
| 45 |
-
reverse = true
|
| 46 |
-
break
|
| 47 |
-
case '-l': case '--loose':
|
| 48 |
-
loose = true
|
| 49 |
-
break
|
| 50 |
-
case '-p': case '--include-prerelease':
|
| 51 |
-
includePrerelease = true
|
| 52 |
-
break
|
| 53 |
-
case '-v': case '--version':
|
| 54 |
-
versions.push(argv.shift())
|
| 55 |
-
break
|
| 56 |
-
case '-i': case '--inc': case '--increment':
|
| 57 |
-
switch (argv[0]) {
|
| 58 |
-
case 'major': case 'minor': case 'patch': case 'prerelease':
|
| 59 |
-
case 'premajor': case 'preminor': case 'prepatch':
|
| 60 |
-
inc = argv.shift()
|
| 61 |
-
break
|
| 62 |
-
default:
|
| 63 |
-
inc = 'patch'
|
| 64 |
-
break
|
| 65 |
-
}
|
| 66 |
-
break
|
| 67 |
-
case '--preid':
|
| 68 |
-
identifier = argv.shift()
|
| 69 |
-
break
|
| 70 |
-
case '-r': case '--range':
|
| 71 |
-
range.push(argv.shift())
|
| 72 |
-
break
|
| 73 |
-
case '-c': case '--coerce':
|
| 74 |
-
coerce = true
|
| 75 |
-
break
|
| 76 |
-
case '--rtl':
|
| 77 |
-
rtl = true
|
| 78 |
-
break
|
| 79 |
-
case '--ltr':
|
| 80 |
-
rtl = false
|
| 81 |
-
break
|
| 82 |
-
case '-h': case '--help': case '-?':
|
| 83 |
-
return help()
|
| 84 |
-
default:
|
| 85 |
-
versions.push(a)
|
| 86 |
-
break
|
| 87 |
-
}
|
| 88 |
-
}
|
| 89 |
-
|
| 90 |
-
var options = { loose: loose, includePrerelease: includePrerelease, rtl: rtl }
|
| 91 |
-
|
| 92 |
-
versions = versions.map(function (v) {
|
| 93 |
-
return coerce ? (semver.coerce(v, options) || { version: v }).version : v
|
| 94 |
-
}).filter(function (v) {
|
| 95 |
-
return semver.valid(v)
|
| 96 |
-
})
|
| 97 |
-
if (!versions.length) return fail()
|
| 98 |
-
if (inc && (versions.length !== 1 || range.length)) { return failInc() }
|
| 99 |
-
|
| 100 |
-
for (var i = 0, l = range.length; i < l; i++) {
|
| 101 |
-
versions = versions.filter(function (v) {
|
| 102 |
-
return semver.satisfies(v, range[i], options)
|
| 103 |
-
})
|
| 104 |
-
if (!versions.length) return fail()
|
| 105 |
-
}
|
| 106 |
-
return success(versions)
|
| 107 |
-
}
|
| 108 |
-
|
| 109 |
-
function failInc () {
|
| 110 |
-
console.error('--inc can only be used on a single version with no range')
|
| 111 |
-
fail()
|
| 112 |
-
}
|
| 113 |
-
|
| 114 |
-
function fail () { process.exit(1) }
|
| 115 |
-
|
| 116 |
-
function success () {
|
| 117 |
-
var compare = reverse ? 'rcompare' : 'compare'
|
| 118 |
-
versions.sort(function (a, b) {
|
| 119 |
-
return semver[compare](a, b, options)
|
| 120 |
-
}).map(function (v) {
|
| 121 |
-
return semver.clean(v, options)
|
| 122 |
-
}).map(function (v) {
|
| 123 |
-
return inc ? semver.inc(v, inc, options, identifier) : v
|
| 124 |
-
}).forEach(function (v, i, _) { console.log(v) })
|
| 125 |
-
}
|
| 126 |
-
|
| 127 |
-
function help () {
|
| 128 |
-
console.log(['SemVer ' + version,
|
| 129 |
-
'',
|
| 130 |
-
'A JavaScript implementation of the https://semver.org/ specification',
|
| 131 |
-
'Copyright Isaac Z. Schlueter',
|
| 132 |
-
'',
|
| 133 |
-
'Usage: semver [options] <version> [<version> [...]]',
|
| 134 |
-
'Prints valid versions sorted by SemVer precedence',
|
| 135 |
-
'',
|
| 136 |
-
'Options:',
|
| 137 |
-
'-r --range <range>',
|
| 138 |
-
' Print versions that match the specified range.',
|
| 139 |
-
'',
|
| 140 |
-
'-i --increment [<level>]',
|
| 141 |
-
' Increment a version by the specified level. Level can',
|
| 142 |
-
' be one of: major, minor, patch, premajor, preminor,',
|
| 143 |
-
" prepatch, or prerelease. Default level is 'patch'.",
|
| 144 |
-
' Only one version may be specified.',
|
| 145 |
-
'',
|
| 146 |
-
'--preid <identifier>',
|
| 147 |
-
' Identifier to be used to prefix premajor, preminor,',
|
| 148 |
-
' prepatch or prerelease version increments.',
|
| 149 |
-
'',
|
| 150 |
-
'-l --loose',
|
| 151 |
-
' Interpret versions and ranges loosely',
|
| 152 |
-
'',
|
| 153 |
-
'-p --include-prerelease',
|
| 154 |
-
' Always include prerelease versions in range matching',
|
| 155 |
-
'',
|
| 156 |
-
'-c --coerce',
|
| 157 |
-
' Coerce a string into SemVer if possible',
|
| 158 |
-
' (does not imply --loose)',
|
| 159 |
-
'',
|
| 160 |
-
'--rtl',
|
| 161 |
-
' Coerce version strings right to left',
|
| 162 |
-
'',
|
| 163 |
-
'--ltr',
|
| 164 |
-
' Coerce version strings left to right (default)',
|
| 165 |
-
'',
|
| 166 |
-
'Program exits successfully if any valid version satisfies',
|
| 167 |
-
'all supplied ranges, and prints all satisfying versions.',
|
| 168 |
-
'',
|
| 169 |
-
'If no satisfying versions are found, then exits failure.',
|
| 170 |
-
'',
|
| 171 |
-
'Versions are printed in ascending order, so supplying',
|
| 172 |
-
'multiple versions to the utility will just sort them.'
|
| 173 |
-
].join('\n'))
|
| 174 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
node_modules/@babel/helper-compilation-targets/node_modules/semver/LICENSE
DELETED
|
@@ -1,15 +0,0 @@
|
|
| 1 |
-
The ISC License
|
| 2 |
-
|
| 3 |
-
Copyright (c) Isaac Z. Schlueter and Contributors
|
| 4 |
-
|
| 5 |
-
Permission to use, copy, modify, and/or distribute this software for any
|
| 6 |
-
purpose with or without fee is hereby granted, provided that the above
|
| 7 |
-
copyright notice and this permission notice appear in all copies.
|
| 8 |
-
|
| 9 |
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
| 10 |
-
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
| 11 |
-
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
| 12 |
-
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
| 13 |
-
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
| 14 |
-
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
| 15 |
-
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
node_modules/@babel/helper-compilation-targets/node_modules/semver/README.md
DELETED
|
@@ -1,443 +0,0 @@
|
|
| 1 |
-
semver(1) -- The semantic versioner for npm
|
| 2 |
-
===========================================
|
| 3 |
-
|
| 4 |
-
## Install
|
| 5 |
-
|
| 6 |
-
```bash
|
| 7 |
-
npm install semver
|
| 8 |
-
````
|
| 9 |
-
|
| 10 |
-
## Usage
|
| 11 |
-
|
| 12 |
-
As a node module:
|
| 13 |
-
|
| 14 |
-
```js
|
| 15 |
-
const semver = require('semver')
|
| 16 |
-
|
| 17 |
-
semver.valid('1.2.3') // '1.2.3'
|
| 18 |
-
semver.valid('a.b.c') // null
|
| 19 |
-
semver.clean(' =v1.2.3 ') // '1.2.3'
|
| 20 |
-
semver.satisfies('1.2.3', '1.x || >=2.5.0 || 5.0.0 - 7.2.3') // true
|
| 21 |
-
semver.gt('1.2.3', '9.8.7') // false
|
| 22 |
-
semver.lt('1.2.3', '9.8.7') // true
|
| 23 |
-
semver.minVersion('>=1.0.0') // '1.0.0'
|
| 24 |
-
semver.valid(semver.coerce('v2')) // '2.0.0'
|
| 25 |
-
semver.valid(semver.coerce('42.6.7.9.3-alpha')) // '42.6.7'
|
| 26 |
-
```
|
| 27 |
-
|
| 28 |
-
As a command-line utility:
|
| 29 |
-
|
| 30 |
-
```
|
| 31 |
-
$ semver -h
|
| 32 |
-
|
| 33 |
-
A JavaScript implementation of the https://semver.org/ specification
|
| 34 |
-
Copyright Isaac Z. Schlueter
|
| 35 |
-
|
| 36 |
-
Usage: semver [options] <version> [<version> [...]]
|
| 37 |
-
Prints valid versions sorted by SemVer precedence
|
| 38 |
-
|
| 39 |
-
Options:
|
| 40 |
-
-r --range <range>
|
| 41 |
-
Print versions that match the specified range.
|
| 42 |
-
|
| 43 |
-
-i --increment [<level>]
|
| 44 |
-
Increment a version by the specified level. Level can
|
| 45 |
-
be one of: major, minor, patch, premajor, preminor,
|
| 46 |
-
prepatch, or prerelease. Default level is 'patch'.
|
| 47 |
-
Only one version may be specified.
|
| 48 |
-
|
| 49 |
-
--preid <identifier>
|
| 50 |
-
Identifier to be used to prefix premajor, preminor,
|
| 51 |
-
prepatch or prerelease version increments.
|
| 52 |
-
|
| 53 |
-
-l --loose
|
| 54 |
-
Interpret versions and ranges loosely
|
| 55 |
-
|
| 56 |
-
-p --include-prerelease
|
| 57 |
-
Always include prerelease versions in range matching
|
| 58 |
-
|
| 59 |
-
-c --coerce
|
| 60 |
-
Coerce a string into SemVer if possible
|
| 61 |
-
(does not imply --loose)
|
| 62 |
-
|
| 63 |
-
--rtl
|
| 64 |
-
Coerce version strings right to left
|
| 65 |
-
|
| 66 |
-
--ltr
|
| 67 |
-
Coerce version strings left to right (default)
|
| 68 |
-
|
| 69 |
-
Program exits successfully if any valid version satisfies
|
| 70 |
-
all supplied ranges, and prints all satisfying versions.
|
| 71 |
-
|
| 72 |
-
If no satisfying versions are found, then exits failure.
|
| 73 |
-
|
| 74 |
-
Versions are printed in ascending order, so supplying
|
| 75 |
-
multiple versions to the utility will just sort them.
|
| 76 |
-
```
|
| 77 |
-
|
| 78 |
-
## Versions
|
| 79 |
-
|
| 80 |
-
A "version" is described by the `v2.0.0` specification found at
|
| 81 |
-
<https://semver.org/>.
|
| 82 |
-
|
| 83 |
-
A leading `"="` or `"v"` character is stripped off and ignored.
|
| 84 |
-
|
| 85 |
-
## Ranges
|
| 86 |
-
|
| 87 |
-
A `version range` is a set of `comparators` which specify versions
|
| 88 |
-
that satisfy the range.
|
| 89 |
-
|
| 90 |
-
A `comparator` is composed of an `operator` and a `version`. The set
|
| 91 |
-
of primitive `operators` is:
|
| 92 |
-
|
| 93 |
-
* `<` Less than
|
| 94 |
-
* `<=` Less than or equal to
|
| 95 |
-
* `>` Greater than
|
| 96 |
-
* `>=` Greater than or equal to
|
| 97 |
-
* `=` Equal. If no operator is specified, then equality is assumed,
|
| 98 |
-
so this operator is optional, but MAY be included.
|
| 99 |
-
|
| 100 |
-
For example, the comparator `>=1.2.7` would match the versions
|
| 101 |
-
`1.2.7`, `1.2.8`, `2.5.3`, and `1.3.9`, but not the versions `1.2.6`
|
| 102 |
-
or `1.1.0`.
|
| 103 |
-
|
| 104 |
-
Comparators can be joined by whitespace to form a `comparator set`,
|
| 105 |
-
which is satisfied by the **intersection** of all of the comparators
|
| 106 |
-
it includes.
|
| 107 |
-
|
| 108 |
-
A range is composed of one or more comparator sets, joined by `||`. A
|
| 109 |
-
version matches a range if and only if every comparator in at least
|
| 110 |
-
one of the `||`-separated comparator sets is satisfied by the version.
|
| 111 |
-
|
| 112 |
-
For example, the range `>=1.2.7 <1.3.0` would match the versions
|
| 113 |
-
`1.2.7`, `1.2.8`, and `1.2.99`, but not the versions `1.2.6`, `1.3.0`,
|
| 114 |
-
or `1.1.0`.
|
| 115 |
-
|
| 116 |
-
The range `1.2.7 || >=1.2.9 <2.0.0` would match the versions `1.2.7`,
|
| 117 |
-
`1.2.9`, and `1.4.6`, but not the versions `1.2.8` or `2.0.0`.
|
| 118 |
-
|
| 119 |
-
### Prerelease Tags
|
| 120 |
-
|
| 121 |
-
If a version has a prerelease tag (for example, `1.2.3-alpha.3`) then
|
| 122 |
-
it will only be allowed to satisfy comparator sets if at least one
|
| 123 |
-
comparator with the same `[major, minor, patch]` tuple also has a
|
| 124 |
-
prerelease tag.
|
| 125 |
-
|
| 126 |
-
For example, the range `>1.2.3-alpha.3` would be allowed to match the
|
| 127 |
-
version `1.2.3-alpha.7`, but it would *not* be satisfied by
|
| 128 |
-
`3.4.5-alpha.9`, even though `3.4.5-alpha.9` is technically "greater
|
| 129 |
-
than" `1.2.3-alpha.3` according to the SemVer sort rules. The version
|
| 130 |
-
range only accepts prerelease tags on the `1.2.3` version. The
|
| 131 |
-
version `3.4.5` *would* satisfy the range, because it does not have a
|
| 132 |
-
prerelease flag, and `3.4.5` is greater than `1.2.3-alpha.7`.
|
| 133 |
-
|
| 134 |
-
The purpose for this behavior is twofold. First, prerelease versions
|
| 135 |
-
frequently are updated very quickly, and contain many breaking changes
|
| 136 |
-
that are (by the author's design) not yet fit for public consumption.
|
| 137 |
-
Therefore, by default, they are excluded from range matching
|
| 138 |
-
semantics.
|
| 139 |
-
|
| 140 |
-
Second, a user who has opted into using a prerelease version has
|
| 141 |
-
clearly indicated the intent to use *that specific* set of
|
| 142 |
-
alpha/beta/rc versions. By including a prerelease tag in the range,
|
| 143 |
-
the user is indicating that they are aware of the risk. However, it
|
| 144 |
-
is still not appropriate to assume that they have opted into taking a
|
| 145 |
-
similar risk on the *next* set of prerelease versions.
|
| 146 |
-
|
| 147 |
-
Note that this behavior can be suppressed (treating all prerelease
|
| 148 |
-
versions as if they were normal versions, for the purpose of range
|
| 149 |
-
matching) by setting the `includePrerelease` flag on the options
|
| 150 |
-
object to any
|
| 151 |
-
[functions](https://github.com/npm/node-semver#functions) that do
|
| 152 |
-
range matching.
|
| 153 |
-
|
| 154 |
-
#### Prerelease Identifiers
|
| 155 |
-
|
| 156 |
-
The method `.inc` takes an additional `identifier` string argument that
|
| 157 |
-
will append the value of the string as a prerelease identifier:
|
| 158 |
-
|
| 159 |
-
```javascript
|
| 160 |
-
semver.inc('1.2.3', 'prerelease', 'beta')
|
| 161 |
-
// '1.2.4-beta.0'
|
| 162 |
-
```
|
| 163 |
-
|
| 164 |
-
command-line example:
|
| 165 |
-
|
| 166 |
-
```bash
|
| 167 |
-
$ semver 1.2.3 -i prerelease --preid beta
|
| 168 |
-
1.2.4-beta.0
|
| 169 |
-
```
|
| 170 |
-
|
| 171 |
-
Which then can be used to increment further:
|
| 172 |
-
|
| 173 |
-
```bash
|
| 174 |
-
$ semver 1.2.4-beta.0 -i prerelease
|
| 175 |
-
1.2.4-beta.1
|
| 176 |
-
```
|
| 177 |
-
|
| 178 |
-
### Advanced Range Syntax
|
| 179 |
-
|
| 180 |
-
Advanced range syntax desugars to primitive comparators in
|
| 181 |
-
deterministic ways.
|
| 182 |
-
|
| 183 |
-
Advanced ranges may be combined in the same way as primitive
|
| 184 |
-
comparators using white space or `||`.
|
| 185 |
-
|
| 186 |
-
#### Hyphen Ranges `X.Y.Z - A.B.C`
|
| 187 |
-
|
| 188 |
-
Specifies an inclusive set.
|
| 189 |
-
|
| 190 |
-
* `1.2.3 - 2.3.4` := `>=1.2.3 <=2.3.4`
|
| 191 |
-
|
| 192 |
-
If a partial version is provided as the first version in the inclusive
|
| 193 |
-
range, then the missing pieces are replaced with zeroes.
|
| 194 |
-
|
| 195 |
-
* `1.2 - 2.3.4` := `>=1.2.0 <=2.3.4`
|
| 196 |
-
|
| 197 |
-
If a partial version is provided as the second version in the
|
| 198 |
-
inclusive range, then all versions that start with the supplied parts
|
| 199 |
-
of the tuple are accepted, but nothing that would be greater than the
|
| 200 |
-
provided tuple parts.
|
| 201 |
-
|
| 202 |
-
* `1.2.3 - 2.3` := `>=1.2.3 <2.4.0`
|
| 203 |
-
* `1.2.3 - 2` := `>=1.2.3 <3.0.0`
|
| 204 |
-
|
| 205 |
-
#### X-Ranges `1.2.x` `1.X` `1.2.*` `*`
|
| 206 |
-
|
| 207 |
-
Any of `X`, `x`, or `*` may be used to "stand in" for one of the
|
| 208 |
-
numeric values in the `[major, minor, patch]` tuple.
|
| 209 |
-
|
| 210 |
-
* `*` := `>=0.0.0` (Any version satisfies)
|
| 211 |
-
* `1.x` := `>=1.0.0 <2.0.0` (Matching major version)
|
| 212 |
-
* `1.2.x` := `>=1.2.0 <1.3.0` (Matching major and minor versions)
|
| 213 |
-
|
| 214 |
-
A partial version range is treated as an X-Range, so the special
|
| 215 |
-
character is in fact optional.
|
| 216 |
-
|
| 217 |
-
* `""` (empty string) := `*` := `>=0.0.0`
|
| 218 |
-
* `1` := `1.x.x` := `>=1.0.0 <2.0.0`
|
| 219 |
-
* `1.2` := `1.2.x` := `>=1.2.0 <1.3.0`
|
| 220 |
-
|
| 221 |
-
#### Tilde Ranges `~1.2.3` `~1.2` `~1`
|
| 222 |
-
|
| 223 |
-
Allows patch-level changes if a minor version is specified on the
|
| 224 |
-
comparator. Allows minor-level changes if not.
|
| 225 |
-
|
| 226 |
-
* `~1.2.3` := `>=1.2.3 <1.(2+1).0` := `>=1.2.3 <1.3.0`
|
| 227 |
-
* `~1.2` := `>=1.2.0 <1.(2+1).0` := `>=1.2.0 <1.3.0` (Same as `1.2.x`)
|
| 228 |
-
* `~1` := `>=1.0.0 <(1+1).0.0` := `>=1.0.0 <2.0.0` (Same as `1.x`)
|
| 229 |
-
* `~0.2.3` := `>=0.2.3 <0.(2+1).0` := `>=0.2.3 <0.3.0`
|
| 230 |
-
* `~0.2` := `>=0.2.0 <0.(2+1).0` := `>=0.2.0 <0.3.0` (Same as `0.2.x`)
|
| 231 |
-
* `~0` := `>=0.0.0 <(0+1).0.0` := `>=0.0.0 <1.0.0` (Same as `0.x`)
|
| 232 |
-
* `~1.2.3-beta.2` := `>=1.2.3-beta.2 <1.3.0` Note that prereleases in
|
| 233 |
-
the `1.2.3` version will be allowed, if they are greater than or
|
| 234 |
-
equal to `beta.2`. So, `1.2.3-beta.4` would be allowed, but
|
| 235 |
-
`1.2.4-beta.2` would not, because it is a prerelease of a
|
| 236 |
-
different `[major, minor, patch]` tuple.
|
| 237 |
-
|
| 238 |
-
#### Caret Ranges `^1.2.3` `^0.2.5` `^0.0.4`
|
| 239 |
-
|
| 240 |
-
Allows changes that do not modify the left-most non-zero element in the
|
| 241 |
-
`[major, minor, patch]` tuple. In other words, this allows patch and
|
| 242 |
-
minor updates for versions `1.0.0` and above, patch updates for
|
| 243 |
-
versions `0.X >=0.1.0`, and *no* updates for versions `0.0.X`.
|
| 244 |
-
|
| 245 |
-
Many authors treat a `0.x` version as if the `x` were the major
|
| 246 |
-
"breaking-change" indicator.
|
| 247 |
-
|
| 248 |
-
Caret ranges are ideal when an author may make breaking changes
|
| 249 |
-
between `0.2.4` and `0.3.0` releases, which is a common practice.
|
| 250 |
-
However, it presumes that there will *not* be breaking changes between
|
| 251 |
-
`0.2.4` and `0.2.5`. It allows for changes that are presumed to be
|
| 252 |
-
additive (but non-breaking), according to commonly observed practices.
|
| 253 |
-
|
| 254 |
-
* `^1.2.3` := `>=1.2.3 <2.0.0`
|
| 255 |
-
* `^0.2.3` := `>=0.2.3 <0.3.0`
|
| 256 |
-
* `^0.0.3` := `>=0.0.3 <0.0.4`
|
| 257 |
-
* `^1.2.3-beta.2` := `>=1.2.3-beta.2 <2.0.0` Note that prereleases in
|
| 258 |
-
the `1.2.3` version will be allowed, if they are greater than or
|
| 259 |
-
equal to `beta.2`. So, `1.2.3-beta.4` would be allowed, but
|
| 260 |
-
`1.2.4-beta.2` would not, because it is a prerelease of a
|
| 261 |
-
different `[major, minor, patch]` tuple.
|
| 262 |
-
* `^0.0.3-beta` := `>=0.0.3-beta <0.0.4` Note that prereleases in the
|
| 263 |
-
`0.0.3` version *only* will be allowed, if they are greater than or
|
| 264 |
-
equal to `beta`. So, `0.0.3-pr.2` would be allowed.
|
| 265 |
-
|
| 266 |
-
When parsing caret ranges, a missing `patch` value desugars to the
|
| 267 |
-
number `0`, but will allow flexibility within that value, even if the
|
| 268 |
-
major and minor versions are both `0`.
|
| 269 |
-
|
| 270 |
-
* `^1.2.x` := `>=1.2.0 <2.0.0`
|
| 271 |
-
* `^0.0.x` := `>=0.0.0 <0.1.0`
|
| 272 |
-
* `^0.0` := `>=0.0.0 <0.1.0`
|
| 273 |
-
|
| 274 |
-
A missing `minor` and `patch` values will desugar to zero, but also
|
| 275 |
-
allow flexibility within those values, even if the major version is
|
| 276 |
-
zero.
|
| 277 |
-
|
| 278 |
-
* `^1.x` := `>=1.0.0 <2.0.0`
|
| 279 |
-
* `^0.x` := `>=0.0.0 <1.0.0`
|
| 280 |
-
|
| 281 |
-
### Range Grammar
|
| 282 |
-
|
| 283 |
-
Putting all this together, here is a Backus-Naur grammar for ranges,
|
| 284 |
-
for the benefit of parser authors:
|
| 285 |
-
|
| 286 |
-
```bnf
|
| 287 |
-
range-set ::= range ( logical-or range ) *
|
| 288 |
-
logical-or ::= ( ' ' ) * '||' ( ' ' ) *
|
| 289 |
-
range ::= hyphen | simple ( ' ' simple ) * | ''
|
| 290 |
-
hyphen ::= partial ' - ' partial
|
| 291 |
-
simple ::= primitive | partial | tilde | caret
|
| 292 |
-
primitive ::= ( '<' | '>' | '>=' | '<=' | '=' ) partial
|
| 293 |
-
partial ::= xr ( '.' xr ( '.' xr qualifier ? )? )?
|
| 294 |
-
xr ::= 'x' | 'X' | '*' | nr
|
| 295 |
-
nr ::= '0' | ['1'-'9'] ( ['0'-'9'] ) *
|
| 296 |
-
tilde ::= '~' partial
|
| 297 |
-
caret ::= '^' partial
|
| 298 |
-
qualifier ::= ( '-' pre )? ( '+' build )?
|
| 299 |
-
pre ::= parts
|
| 300 |
-
build ::= parts
|
| 301 |
-
parts ::= part ( '.' part ) *
|
| 302 |
-
part ::= nr | [-0-9A-Za-z]+
|
| 303 |
-
```
|
| 304 |
-
|
| 305 |
-
## Functions
|
| 306 |
-
|
| 307 |
-
All methods and classes take a final `options` object argument. All
|
| 308 |
-
options in this object are `false` by default. The options supported
|
| 309 |
-
are:
|
| 310 |
-
|
| 311 |
-
- `loose` Be more forgiving about not-quite-valid semver strings.
|
| 312 |
-
(Any resulting output will always be 100% strict compliant, of
|
| 313 |
-
course.) For backwards compatibility reasons, if the `options`
|
| 314 |
-
argument is a boolean value instead of an object, it is interpreted
|
| 315 |
-
to be the `loose` param.
|
| 316 |
-
- `includePrerelease` Set to suppress the [default
|
| 317 |
-
behavior](https://github.com/npm/node-semver#prerelease-tags) of
|
| 318 |
-
excluding prerelease tagged versions from ranges unless they are
|
| 319 |
-
explicitly opted into.
|
| 320 |
-
|
| 321 |
-
Strict-mode Comparators and Ranges will be strict about the SemVer
|
| 322 |
-
strings that they parse.
|
| 323 |
-
|
| 324 |
-
* `valid(v)`: Return the parsed version, or null if it's not valid.
|
| 325 |
-
* `inc(v, release)`: Return the version incremented by the release
|
| 326 |
-
type (`major`, `premajor`, `minor`, `preminor`, `patch`,
|
| 327 |
-
`prepatch`, or `prerelease`), or null if it's not valid
|
| 328 |
-
* `premajor` in one call will bump the version up to the next major
|
| 329 |
-
version and down to a prerelease of that major version.
|
| 330 |
-
`preminor`, and `prepatch` work the same way.
|
| 331 |
-
* If called from a non-prerelease version, the `prerelease` will work the
|
| 332 |
-
same as `prepatch`. It increments the patch version, then makes a
|
| 333 |
-
prerelease. If the input version is already a prerelease it simply
|
| 334 |
-
increments it.
|
| 335 |
-
* `prerelease(v)`: Returns an array of prerelease components, or null
|
| 336 |
-
if none exist. Example: `prerelease('1.2.3-alpha.1') -> ['alpha', 1]`
|
| 337 |
-
* `major(v)`: Return the major version number.
|
| 338 |
-
* `minor(v)`: Return the minor version number.
|
| 339 |
-
* `patch(v)`: Return the patch version number.
|
| 340 |
-
* `intersects(r1, r2, loose)`: Return true if the two supplied ranges
|
| 341 |
-
or comparators intersect.
|
| 342 |
-
* `parse(v)`: Attempt to parse a string as a semantic version, returning either
|
| 343 |
-
a `SemVer` object or `null`.
|
| 344 |
-
|
| 345 |
-
### Comparison
|
| 346 |
-
|
| 347 |
-
* `gt(v1, v2)`: `v1 > v2`
|
| 348 |
-
* `gte(v1, v2)`: `v1 >= v2`
|
| 349 |
-
* `lt(v1, v2)`: `v1 < v2`
|
| 350 |
-
* `lte(v1, v2)`: `v1 <= v2`
|
| 351 |
-
* `eq(v1, v2)`: `v1 == v2` This is true if they're logically equivalent,
|
| 352 |
-
even if they're not the exact same string. You already know how to
|
| 353 |
-
compare strings.
|
| 354 |
-
* `neq(v1, v2)`: `v1 != v2` The opposite of `eq`.
|
| 355 |
-
* `cmp(v1, comparator, v2)`: Pass in a comparison string, and it'll call
|
| 356 |
-
the corresponding function above. `"==="` and `"!=="` do simple
|
| 357 |
-
string comparison, but are included for completeness. Throws if an
|
| 358 |
-
invalid comparison string is provided.
|
| 359 |
-
* `compare(v1, v2)`: Return `0` if `v1 == v2`, or `1` if `v1` is greater, or `-1` if
|
| 360 |
-
`v2` is greater. Sorts in ascending order if passed to `Array.sort()`.
|
| 361 |
-
* `rcompare(v1, v2)`: The reverse of compare. Sorts an array of versions
|
| 362 |
-
in descending order when passed to `Array.sort()`.
|
| 363 |
-
* `compareBuild(v1, v2)`: The same as `compare` but considers `build` when two versions
|
| 364 |
-
are equal. Sorts in ascending order if passed to `Array.sort()`.
|
| 365 |
-
`v2` is greater. Sorts in ascending order if passed to `Array.sort()`.
|
| 366 |
-
* `diff(v1, v2)`: Returns difference between two versions by the release type
|
| 367 |
-
(`major`, `premajor`, `minor`, `preminor`, `patch`, `prepatch`, or `prerelease`),
|
| 368 |
-
or null if the versions are the same.
|
| 369 |
-
|
| 370 |
-
### Comparators
|
| 371 |
-
|
| 372 |
-
* `intersects(comparator)`: Return true if the comparators intersect
|
| 373 |
-
|
| 374 |
-
### Ranges
|
| 375 |
-
|
| 376 |
-
* `validRange(range)`: Return the valid range or null if it's not valid
|
| 377 |
-
* `satisfies(version, range)`: Return true if the version satisfies the
|
| 378 |
-
range.
|
| 379 |
-
* `maxSatisfying(versions, range)`: Return the highest version in the list
|
| 380 |
-
that satisfies the range, or `null` if none of them do.
|
| 381 |
-
* `minSatisfying(versions, range)`: Return the lowest version in the list
|
| 382 |
-
that satisfies the range, or `null` if none of them do.
|
| 383 |
-
* `minVersion(range)`: Return the lowest version that can possibly match
|
| 384 |
-
the given range.
|
| 385 |
-
* `gtr(version, range)`: Return `true` if version is greater than all the
|
| 386 |
-
versions possible in the range.
|
| 387 |
-
* `ltr(version, range)`: Return `true` if version is less than all the
|
| 388 |
-
versions possible in the range.
|
| 389 |
-
* `outside(version, range, hilo)`: Return true if the version is outside
|
| 390 |
-
the bounds of the range in either the high or low direction. The
|
| 391 |
-
`hilo` argument must be either the string `'>'` or `'<'`. (This is
|
| 392 |
-
the function called by `gtr` and `ltr`.)
|
| 393 |
-
* `intersects(range)`: Return true if any of the ranges comparators intersect
|
| 394 |
-
|
| 395 |
-
Note that, since ranges may be non-contiguous, a version might not be
|
| 396 |
-
greater than a range, less than a range, *or* satisfy a range! For
|
| 397 |
-
example, the range `1.2 <1.2.9 || >2.0.0` would have a hole from `1.2.9`
|
| 398 |
-
until `2.0.0`, so the version `1.2.10` would not be greater than the
|
| 399 |
-
range (because `2.0.1` satisfies, which is higher), nor less than the
|
| 400 |
-
range (since `1.2.8` satisfies, which is lower), and it also does not
|
| 401 |
-
satisfy the range.
|
| 402 |
-
|
| 403 |
-
If you want to know if a version satisfies or does not satisfy a
|
| 404 |
-
range, use the `satisfies(version, range)` function.
|
| 405 |
-
|
| 406 |
-
### Coercion
|
| 407 |
-
|
| 408 |
-
* `coerce(version, options)`: Coerces a string to semver if possible
|
| 409 |
-
|
| 410 |
-
This aims to provide a very forgiving translation of a non-semver string to
|
| 411 |
-
semver. It looks for the first digit in a string, and consumes all
|
| 412 |
-
remaining characters which satisfy at least a partial semver (e.g., `1`,
|
| 413 |
-
`1.2`, `1.2.3`) up to the max permitted length (256 characters). Longer
|
| 414 |
-
versions are simply truncated (`4.6.3.9.2-alpha2` becomes `4.6.3`). All
|
| 415 |
-
surrounding text is simply ignored (`v3.4 replaces v3.3.1` becomes
|
| 416 |
-
`3.4.0`). Only text which lacks digits will fail coercion (`version one`
|
| 417 |
-
is not valid). The maximum length for any semver component considered for
|
| 418 |
-
coercion is 16 characters; longer components will be ignored
|
| 419 |
-
(`10000000000000000.4.7.4` becomes `4.7.4`). The maximum value for any
|
| 420 |
-
semver component is `Integer.MAX_SAFE_INTEGER || (2**53 - 1)`; higher value
|
| 421 |
-
components are invalid (`9999999999999999.4.7.4` is likely invalid).
|
| 422 |
-
|
| 423 |
-
If the `options.rtl` flag is set, then `coerce` will return the right-most
|
| 424 |
-
coercible tuple that does not share an ending index with a longer coercible
|
| 425 |
-
tuple. For example, `1.2.3.4` will return `2.3.4` in rtl mode, not
|
| 426 |
-
`4.0.0`. `1.2.3/4` will return `4.0.0`, because the `4` is not a part of
|
| 427 |
-
any other overlapping SemVer tuple.
|
| 428 |
-
|
| 429 |
-
### Clean
|
| 430 |
-
|
| 431 |
-
* `clean(version)`: Clean a string to be a valid semver if possible
|
| 432 |
-
|
| 433 |
-
This will return a cleaned and trimmed semver version. If the provided version is not valid a null will be returned. This does not work for ranges.
|
| 434 |
-
|
| 435 |
-
ex.
|
| 436 |
-
* `s.clean(' = v 2.1.5foo')`: `null`
|
| 437 |
-
* `s.clean(' = v 2.1.5foo', { loose: true })`: `'2.1.5-foo'`
|
| 438 |
-
* `s.clean(' = v 2.1.5-foo')`: `null`
|
| 439 |
-
* `s.clean(' = v 2.1.5-foo', { loose: true })`: `'2.1.5-foo'`
|
| 440 |
-
* `s.clean('=v2.1.5')`: `'2.1.5'`
|
| 441 |
-
* `s.clean(' =v2.1.5')`: `2.1.5`
|
| 442 |
-
* `s.clean(' 2.1.5 ')`: `'2.1.5'`
|
| 443 |
-
* `s.clean('~1.0.0')`: `null`
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
node_modules/@babel/helper-compilation-targets/node_modules/semver/bin/semver.js
DELETED
|
@@ -1,174 +0,0 @@
|
|
| 1 |
-
#!/usr/bin/env node
|
| 2 |
-
// Standalone semver comparison program.
|
| 3 |
-
// Exits successfully and prints matching version(s) if
|
| 4 |
-
// any supplied version is valid and passes all tests.
|
| 5 |
-
|
| 6 |
-
var argv = process.argv.slice(2)
|
| 7 |
-
|
| 8 |
-
var versions = []
|
| 9 |
-
|
| 10 |
-
var range = []
|
| 11 |
-
|
| 12 |
-
var inc = null
|
| 13 |
-
|
| 14 |
-
var version = require('../package.json').version
|
| 15 |
-
|
| 16 |
-
var loose = false
|
| 17 |
-
|
| 18 |
-
var includePrerelease = false
|
| 19 |
-
|
| 20 |
-
var coerce = false
|
| 21 |
-
|
| 22 |
-
var rtl = false
|
| 23 |
-
|
| 24 |
-
var identifier
|
| 25 |
-
|
| 26 |
-
var semver = require('../semver')
|
| 27 |
-
|
| 28 |
-
var reverse = false
|
| 29 |
-
|
| 30 |
-
var options = {}
|
| 31 |
-
|
| 32 |
-
main()
|
| 33 |
-
|
| 34 |
-
function main () {
|
| 35 |
-
if (!argv.length) return help()
|
| 36 |
-
while (argv.length) {
|
| 37 |
-
var a = argv.shift()
|
| 38 |
-
var indexOfEqualSign = a.indexOf('=')
|
| 39 |
-
if (indexOfEqualSign !== -1) {
|
| 40 |
-
a = a.slice(0, indexOfEqualSign)
|
| 41 |
-
argv.unshift(a.slice(indexOfEqualSign + 1))
|
| 42 |
-
}
|
| 43 |
-
switch (a) {
|
| 44 |
-
case '-rv': case '-rev': case '--rev': case '--reverse':
|
| 45 |
-
reverse = true
|
| 46 |
-
break
|
| 47 |
-
case '-l': case '--loose':
|
| 48 |
-
loose = true
|
| 49 |
-
break
|
| 50 |
-
case '-p': case '--include-prerelease':
|
| 51 |
-
includePrerelease = true
|
| 52 |
-
break
|
| 53 |
-
case '-v': case '--version':
|
| 54 |
-
versions.push(argv.shift())
|
| 55 |
-
break
|
| 56 |
-
case '-i': case '--inc': case '--increment':
|
| 57 |
-
switch (argv[0]) {
|
| 58 |
-
case 'major': case 'minor': case 'patch': case 'prerelease':
|
| 59 |
-
case 'premajor': case 'preminor': case 'prepatch':
|
| 60 |
-
inc = argv.shift()
|
| 61 |
-
break
|
| 62 |
-
default:
|
| 63 |
-
inc = 'patch'
|
| 64 |
-
break
|
| 65 |
-
}
|
| 66 |
-
break
|
| 67 |
-
case '--preid':
|
| 68 |
-
identifier = argv.shift()
|
| 69 |
-
break
|
| 70 |
-
case '-r': case '--range':
|
| 71 |
-
range.push(argv.shift())
|
| 72 |
-
break
|
| 73 |
-
case '-c': case '--coerce':
|
| 74 |
-
coerce = true
|
| 75 |
-
break
|
| 76 |
-
case '--rtl':
|
| 77 |
-
rtl = true
|
| 78 |
-
break
|
| 79 |
-
case '--ltr':
|
| 80 |
-
rtl = false
|
| 81 |
-
break
|
| 82 |
-
case '-h': case '--help': case '-?':
|
| 83 |
-
return help()
|
| 84 |
-
default:
|
| 85 |
-
versions.push(a)
|
| 86 |
-
break
|
| 87 |
-
}
|
| 88 |
-
}
|
| 89 |
-
|
| 90 |
-
var options = { loose: loose, includePrerelease: includePrerelease, rtl: rtl }
|
| 91 |
-
|
| 92 |
-
versions = versions.map(function (v) {
|
| 93 |
-
return coerce ? (semver.coerce(v, options) || { version: v }).version : v
|
| 94 |
-
}).filter(function (v) {
|
| 95 |
-
return semver.valid(v)
|
| 96 |
-
})
|
| 97 |
-
if (!versions.length) return fail()
|
| 98 |
-
if (inc && (versions.length !== 1 || range.length)) { return failInc() }
|
| 99 |
-
|
| 100 |
-
for (var i = 0, l = range.length; i < l; i++) {
|
| 101 |
-
versions = versions.filter(function (v) {
|
| 102 |
-
return semver.satisfies(v, range[i], options)
|
| 103 |
-
})
|
| 104 |
-
if (!versions.length) return fail()
|
| 105 |
-
}
|
| 106 |
-
return success(versions)
|
| 107 |
-
}
|
| 108 |
-
|
| 109 |
-
function failInc () {
|
| 110 |
-
console.error('--inc can only be used on a single version with no range')
|
| 111 |
-
fail()
|
| 112 |
-
}
|
| 113 |
-
|
| 114 |
-
function fail () { process.exit(1) }
|
| 115 |
-
|
| 116 |
-
function success () {
|
| 117 |
-
var compare = reverse ? 'rcompare' : 'compare'
|
| 118 |
-
versions.sort(function (a, b) {
|
| 119 |
-
return semver[compare](a, b, options)
|
| 120 |
-
}).map(function (v) {
|
| 121 |
-
return semver.clean(v, options)
|
| 122 |
-
}).map(function (v) {
|
| 123 |
-
return inc ? semver.inc(v, inc, options, identifier) : v
|
| 124 |
-
}).forEach(function (v, i, _) { console.log(v) })
|
| 125 |
-
}
|
| 126 |
-
|
| 127 |
-
function help () {
|
| 128 |
-
console.log(['SemVer ' + version,
|
| 129 |
-
'',
|
| 130 |
-
'A JavaScript implementation of the https://semver.org/ specification',
|
| 131 |
-
'Copyright Isaac Z. Schlueter',
|
| 132 |
-
'',
|
| 133 |
-
'Usage: semver [options] <version> [<version> [...]]',
|
| 134 |
-
'Prints valid versions sorted by SemVer precedence',
|
| 135 |
-
'',
|
| 136 |
-
'Options:',
|
| 137 |
-
'-r --range <range>',
|
| 138 |
-
' Print versions that match the specified range.',
|
| 139 |
-
'',
|
| 140 |
-
'-i --increment [<level>]',
|
| 141 |
-
' Increment a version by the specified level. Level can',
|
| 142 |
-
' be one of: major, minor, patch, premajor, preminor,',
|
| 143 |
-
" prepatch, or prerelease. Default level is 'patch'.",
|
| 144 |
-
' Only one version may be specified.',
|
| 145 |
-
'',
|
| 146 |
-
'--preid <identifier>',
|
| 147 |
-
' Identifier to be used to prefix premajor, preminor,',
|
| 148 |
-
' prepatch or prerelease version increments.',
|
| 149 |
-
'',
|
| 150 |
-
'-l --loose',
|
| 151 |
-
' Interpret versions and ranges loosely',
|
| 152 |
-
'',
|
| 153 |
-
'-p --include-prerelease',
|
| 154 |
-
' Always include prerelease versions in range matching',
|
| 155 |
-
'',
|
| 156 |
-
'-c --coerce',
|
| 157 |
-
' Coerce a string into SemVer if possible',
|
| 158 |
-
' (does not imply --loose)',
|
| 159 |
-
'',
|
| 160 |
-
'--rtl',
|
| 161 |
-
' Coerce version strings right to left',
|
| 162 |
-
'',
|
| 163 |
-
'--ltr',
|
| 164 |
-
' Coerce version strings left to right (default)',
|
| 165 |
-
'',
|
| 166 |
-
'Program exits successfully if any valid version satisfies',
|
| 167 |
-
'all supplied ranges, and prints all satisfying versions.',
|
| 168 |
-
'',
|
| 169 |
-
'If no satisfying versions are found, then exits failure.',
|
| 170 |
-
'',
|
| 171 |
-
'Versions are printed in ascending order, so supplying',
|
| 172 |
-
'multiple versions to the utility will just sort them.'
|
| 173 |
-
].join('\n'))
|
| 174 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
node_modules/@babel/helper-compilation-targets/node_modules/semver/package.json
DELETED
|
@@ -1,38 +0,0 @@
|
|
| 1 |
-
{
|
| 2 |
-
"name": "semver",
|
| 3 |
-
"version": "6.3.1",
|
| 4 |
-
"description": "The semantic version parser used by npm.",
|
| 5 |
-
"main": "semver.js",
|
| 6 |
-
"scripts": {
|
| 7 |
-
"test": "tap test/ --100 --timeout=30",
|
| 8 |
-
"lint": "echo linting disabled",
|
| 9 |
-
"postlint": "template-oss-check",
|
| 10 |
-
"template-oss-apply": "template-oss-apply --force",
|
| 11 |
-
"lintfix": "npm run lint -- --fix",
|
| 12 |
-
"snap": "tap test/ --100 --timeout=30",
|
| 13 |
-
"posttest": "npm run lint"
|
| 14 |
-
},
|
| 15 |
-
"devDependencies": {
|
| 16 |
-
"@npmcli/template-oss": "4.17.0",
|
| 17 |
-
"tap": "^12.7.0"
|
| 18 |
-
},
|
| 19 |
-
"license": "ISC",
|
| 20 |
-
"repository": {
|
| 21 |
-
"type": "git",
|
| 22 |
-
"url": "https://github.com/npm/node-semver.git"
|
| 23 |
-
},
|
| 24 |
-
"bin": {
|
| 25 |
-
"semver": "./bin/semver.js"
|
| 26 |
-
},
|
| 27 |
-
"files": [
|
| 28 |
-
"bin",
|
| 29 |
-
"range.bnf",
|
| 30 |
-
"semver.js"
|
| 31 |
-
],
|
| 32 |
-
"author": "GitHub Inc.",
|
| 33 |
-
"templateOSS": {
|
| 34 |
-
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
|
| 35 |
-
"content": "./scripts/template-oss",
|
| 36 |
-
"version": "4.17.0"
|
| 37 |
-
}
|
| 38 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|