@likec4/core 1.9.0 → 1.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +311 -111
- package/dist/index.d.cts +191 -158
- package/dist/index.d.mts +191 -158
- package/dist/index.d.ts +814 -0
- package/dist/index.mjs +308 -113
- package/dist/shared/{core.9l7eW3pn.d.cts → core.Czd51Dd8.d.cts} +55 -38
- package/dist/shared/{core.9l7eW3pn.d.mts → core.Czd51Dd8.d.mts} +55 -38
- package/dist/shared/core.Czd51Dd8.d.ts +834 -0
- package/dist/shared/{core.DcPLm41i.cjs → core.Db3ntVII.cjs} +17 -3
- package/dist/shared/{core.DfUTsojZ.mjs → core.DeifT5lC.mjs} +16 -4
- package/dist/types/index.cjs +3 -1
- package/dist/types/index.d.cts +1 -1
- package/dist/types/index.d.mts +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.mjs +1 -1
- package/package.json +9 -7
- package/src/index.ts +1 -0
- package/src/types/_common.ts +2 -0
- package/src/types/element.ts +3 -0
- package/src/types/expression.ts +4 -0
- package/src/types/relation.ts +3 -0
- package/src/types/view.ts +37 -6
- package/src/utils/compare-natural.spec.ts +37 -0
- package/src/utils/compare-natural.ts +14 -0
- package/src/utils/fqn.spec.ts +99 -2
- package/src/utils/fqn.ts +38 -1
- package/src/utils/index.ts +1 -0
- package/src/utils/relations.spec.ts +1 -1
- package/src/utils/relations.ts +7 -7
package/dist/index.cjs
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const types_index = require('./shared/core.
|
|
3
|
+
const types_index = require('./shared/core.Db3ntVII.cjs');
|
|
4
|
+
|
|
5
|
+
const { min: min$4, max: max$4 } = Math;
|
|
4
6
|
|
|
5
7
|
const limit = (x, low = 0, high = 1) => {
|
|
6
|
-
return min$
|
|
8
|
+
return min$4(max$4(low, x), high);
|
|
7
9
|
};
|
|
8
10
|
|
|
9
11
|
const clip_rgb = (rgb) => {
|
|
@@ -124,7 +126,7 @@ class Color {
|
|
|
124
126
|
}
|
|
125
127
|
|
|
126
128
|
// this gets updated automatically
|
|
127
|
-
const version = '3.
|
|
129
|
+
const version = '3.1.1';
|
|
128
130
|
|
|
129
131
|
const chroma = (...args) => {
|
|
130
132
|
return new Color(...args);
|
|
@@ -2605,6 +2607,72 @@ const contrast = (a, b) => {
|
|
|
2605
2607
|
return l1 > l2 ? (l1 + 0.05) / (l2 + 0.05) : (l2 + 0.05) / (l1 + 0.05);
|
|
2606
2608
|
};
|
|
2607
2609
|
|
|
2610
|
+
/**
|
|
2611
|
+
* @license
|
|
2612
|
+
*
|
|
2613
|
+
* The APCA contrast prediction algorithm is based of the formulas published
|
|
2614
|
+
* in the APCA-1.0.98G specification by Myndex. The specification is available at:
|
|
2615
|
+
* https://raw.githubusercontent.com/Myndex/apca-w3/master/images/APCAw3_0.1.17_APCA0.0.98G.svg
|
|
2616
|
+
*
|
|
2617
|
+
* Note that the APCA implementation is still beta, so please update to
|
|
2618
|
+
* future versions of chroma.js when they become available.
|
|
2619
|
+
*
|
|
2620
|
+
* You can read more about the APCA Readability Criterion at
|
|
2621
|
+
* https://readtech.org/ARC/
|
|
2622
|
+
*/
|
|
2623
|
+
|
|
2624
|
+
// constants
|
|
2625
|
+
const W_offset = 0.027;
|
|
2626
|
+
const P_in = 0.0005;
|
|
2627
|
+
const P_out = 0.1;
|
|
2628
|
+
const R_scale = 1.14;
|
|
2629
|
+
const B_threshold = 0.022;
|
|
2630
|
+
const B_exp = 1.414;
|
|
2631
|
+
|
|
2632
|
+
const contrastAPCA = (text, bg) => {
|
|
2633
|
+
// parse input colors
|
|
2634
|
+
text = new Color(text);
|
|
2635
|
+
bg = new Color(bg);
|
|
2636
|
+
// if text color has alpha, blend against background
|
|
2637
|
+
if (text.alpha() < 1) {
|
|
2638
|
+
text = mix(bg, text, text.alpha(), 'rgb');
|
|
2639
|
+
}
|
|
2640
|
+
const l_text = lum(...text.rgb());
|
|
2641
|
+
const l_bg = lum(...bg.rgb());
|
|
2642
|
+
|
|
2643
|
+
// soft clamp black levels
|
|
2644
|
+
const Y_text =
|
|
2645
|
+
l_text >= B_threshold
|
|
2646
|
+
? l_text
|
|
2647
|
+
: l_text + Math.pow(B_threshold - l_text, B_exp);
|
|
2648
|
+
const Y_bg =
|
|
2649
|
+
l_bg >= B_threshold ? l_bg : l_bg + Math.pow(B_threshold - l_bg, B_exp);
|
|
2650
|
+
|
|
2651
|
+
// normal polarity (dark text on light background)
|
|
2652
|
+
const S_norm = Math.pow(Y_bg, 0.56) - Math.pow(Y_text, 0.57);
|
|
2653
|
+
// reverse polarity (light text on dark background)
|
|
2654
|
+
const S_rev = Math.pow(Y_bg, 0.65) - Math.pow(Y_text, 0.62);
|
|
2655
|
+
// clamp noise then scale
|
|
2656
|
+
const C =
|
|
2657
|
+
Math.abs(Y_bg - Y_text) < P_in
|
|
2658
|
+
? 0
|
|
2659
|
+
: Y_text < Y_bg
|
|
2660
|
+
? S_norm * R_scale
|
|
2661
|
+
: S_rev * R_scale;
|
|
2662
|
+
// clamp minimum contrast then offset
|
|
2663
|
+
const S_apc = Math.abs(C) < P_out ? 0 : C > 0 ? C - W_offset : C + W_offset;
|
|
2664
|
+
// scale to 100
|
|
2665
|
+
return S_apc * 100;
|
|
2666
|
+
};
|
|
2667
|
+
|
|
2668
|
+
function lum(r, g, b) {
|
|
2669
|
+
return (
|
|
2670
|
+
0.2126729 * Math.pow(r / 255, 2.4) +
|
|
2671
|
+
0.7151522 * Math.pow(g / 255, 2.4) +
|
|
2672
|
+
0.072175 * Math.pow(b / 255, 2.4)
|
|
2673
|
+
);
|
|
2674
|
+
}
|
|
2675
|
+
|
|
2608
2676
|
const { sqrt, pow, min, max: max$1, atan2, abs, cos, sin, exp, PI } = Math;
|
|
2609
2677
|
|
|
2610
2678
|
function deltaE (a, b, Kl = 1, Kc = 1, Kh = 1) {
|
|
@@ -2767,10 +2835,24 @@ const colorbrewer = {
|
|
|
2767
2835
|
Pastel1: ['#fbb4ae', '#b3cde3', '#ccebc5', '#decbe4', '#fed9a6', '#ffffcc', '#e5d8bd', '#fddaec', '#f2f2f2']
|
|
2768
2836
|
};
|
|
2769
2837
|
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
|
|
2838
|
+
const colorbrewerTypes = Object.keys(colorbrewer);
|
|
2839
|
+
const typeMap = new Map(colorbrewerTypes.map((key) => [key.toLowerCase(), key]));
|
|
2840
|
+
|
|
2841
|
+
// use Proxy to allow case-insensitive access to palettes
|
|
2842
|
+
const colorbrewerProxy =
|
|
2843
|
+
typeof Proxy === 'function'
|
|
2844
|
+
? new Proxy(colorbrewer, {
|
|
2845
|
+
get(target, prop) {
|
|
2846
|
+
const lower = prop.toLowerCase();
|
|
2847
|
+
if (typeMap.has(lower)) {
|
|
2848
|
+
return target[typeMap.get(lower)];
|
|
2849
|
+
}
|
|
2850
|
+
},
|
|
2851
|
+
getOwnPropertyNames() {
|
|
2852
|
+
return Object.getOwnPropertyNames(colorbrewerTypes);
|
|
2853
|
+
}
|
|
2854
|
+
})
|
|
2855
|
+
: colorbrewer;
|
|
2774
2856
|
|
|
2775
2857
|
const cmyk2rgb = (...args) => {
|
|
2776
2858
|
args = unpack(args, 'cmyk');
|
|
@@ -2875,7 +2957,7 @@ const lch2css = (...args) => {
|
|
|
2875
2957
|
let mode = last(args) || 'lab';
|
|
2876
2958
|
lcha[0] = rnd2(lcha[0]) + '%';
|
|
2877
2959
|
lcha[1] = rnd2(lcha[1]);
|
|
2878
|
-
lcha[2] = rnd2(lcha[2]) + 'deg'; // add deg unit to hue
|
|
2960
|
+
lcha[2] = isNaN(lcha[2]) ? 'none' : rnd2(lcha[2]) + 'deg'; // add deg unit to hue
|
|
2879
2961
|
if (mode === 'lcha' || (lcha.length > 3 && lcha[3] < 1)) {
|
|
2880
2962
|
lcha[3] = '/ ' + (lcha.length > 3 ? lcha[3] : 1);
|
|
2881
2963
|
} else {
|
|
@@ -2884,7 +2966,7 @@ const lch2css = (...args) => {
|
|
|
2884
2966
|
return `lch(${lcha.join(' ')})`;
|
|
2885
2967
|
};
|
|
2886
2968
|
|
|
2887
|
-
const oklab2css
|
|
2969
|
+
const oklab2css = (...args) => {
|
|
2888
2970
|
const laba = unpack(args, 'lab');
|
|
2889
2971
|
laba[0] = rnd2(laba[0] * 100) + '%';
|
|
2890
2972
|
laba[1] = rnd3(laba[1]);
|
|
@@ -2904,17 +2986,17 @@ const rgb2oklch = (...args) => {
|
|
|
2904
2986
|
return [L, c, h, ...(rest.length > 0 && rest[0] < 1 ? [rest[0]] : [])];
|
|
2905
2987
|
};
|
|
2906
2988
|
|
|
2907
|
-
const
|
|
2908
|
-
const
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
if (
|
|
2913
|
-
|
|
2989
|
+
const oklch2css = (...args) => {
|
|
2990
|
+
const lcha = unpack(args, 'lch');
|
|
2991
|
+
lcha[0] = rnd2(lcha[0] * 100) + '%';
|
|
2992
|
+
lcha[1] = rnd3(lcha[1]);
|
|
2993
|
+
lcha[2] = isNaN(lcha[2]) ? 'none' : rnd2(lcha[2]) + 'deg'; // add deg unit to hue
|
|
2994
|
+
if (lcha.length > 3 && lcha[3] < 1) {
|
|
2995
|
+
lcha[3] = '/ ' + (lcha.length > 3 ? lcha[3] : 1);
|
|
2914
2996
|
} else {
|
|
2915
|
-
|
|
2997
|
+
lcha.length = 3;
|
|
2916
2998
|
}
|
|
2917
|
-
return `oklch(${
|
|
2999
|
+
return `oklch(${lcha.join(' ')})`;
|
|
2918
3000
|
};
|
|
2919
3001
|
|
|
2920
3002
|
const { round: round$2 } = Math;
|
|
@@ -2950,10 +3032,10 @@ const rgb2css = (...args) => {
|
|
|
2950
3032
|
return cssColor;
|
|
2951
3033
|
}
|
|
2952
3034
|
if (mode.substr(0, 5) === 'oklab') {
|
|
2953
|
-
return oklab2css
|
|
3035
|
+
return oklab2css(rgb2oklab(rgba));
|
|
2954
3036
|
}
|
|
2955
3037
|
if (mode.substr(0, 5) === 'oklch') {
|
|
2956
|
-
return
|
|
3038
|
+
return oklch2css(rgb2oklch(rgba));
|
|
2957
3039
|
}
|
|
2958
3040
|
rgba[0] = round$2(rgba[0]);
|
|
2959
3041
|
rgba[1] = round$2(rgba[1]);
|
|
@@ -2973,42 +3055,75 @@ const oklch2rgb = (...args) => {
|
|
|
2973
3055
|
return [r, g, b, ...(rest.length > 0 && rest[0] < 1 ? [rest[0]] : [])];
|
|
2974
3056
|
};
|
|
2975
3057
|
|
|
2976
|
-
const
|
|
2977
|
-
const
|
|
2978
|
-
|
|
2979
|
-
const
|
|
2980
|
-
|
|
2981
|
-
const
|
|
2982
|
-
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
const
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
3058
|
+
const INT_OR_PCT = /((?:-?\d+)|(?:-?\d+(?:\.\d+)?)%|none)/.source;
|
|
3059
|
+
const FLOAT_OR_PCT = /((?:-?(?:\d+(?:\.\d*)?|\.\d+)%?)|none)/.source;
|
|
3060
|
+
const PCT = /((?:-?(?:\d+(?:\.\d*)?|\.\d+)%)|none)/.source;
|
|
3061
|
+
const RE_S = /\s*/.source;
|
|
3062
|
+
const SEP = /\s+/.source;
|
|
3063
|
+
const COMMA = /\s*,\s*/.source;
|
|
3064
|
+
const ANLGE = /((?:-?(?:\d+(?:\.\d*)?|\.\d+)(?:deg)?)|none)/.source;
|
|
3065
|
+
const ALPHA = /\s*(?:\/\s*((?:[01]|[01]?\.\d+)|\d+(?:\.\d+)?%))?/.source;
|
|
3066
|
+
|
|
3067
|
+
// e.g. rgb(250 20 0), rgb(100% 50% 20%), rgb(100% 50% 20% / 0.5)
|
|
3068
|
+
const RE_RGB = new RegExp(
|
|
3069
|
+
'^rgba?\\(' +
|
|
3070
|
+
RE_S +
|
|
3071
|
+
[INT_OR_PCT, INT_OR_PCT, INT_OR_PCT].join(SEP) +
|
|
3072
|
+
ALPHA +
|
|
3073
|
+
'\\)$'
|
|
3074
|
+
);
|
|
3075
|
+
const RE_RGB_LEGACY = new RegExp(
|
|
3076
|
+
'^rgb\\(' +
|
|
3077
|
+
RE_S +
|
|
3078
|
+
[INT_OR_PCT, INT_OR_PCT, INT_OR_PCT].join(COMMA) +
|
|
3079
|
+
RE_S +
|
|
3080
|
+
'\\)$'
|
|
3081
|
+
);
|
|
3082
|
+
const RE_RGBA_LEGACY = new RegExp(
|
|
3083
|
+
'^rgba\\(' +
|
|
3084
|
+
RE_S +
|
|
3085
|
+
[INT_OR_PCT, INT_OR_PCT, INT_OR_PCT, FLOAT_OR_PCT].join(COMMA) +
|
|
3086
|
+
RE_S +
|
|
3087
|
+
'\\)$'
|
|
3088
|
+
);
|
|
2998
3089
|
|
|
2999
|
-
const
|
|
3000
|
-
|
|
3090
|
+
const RE_HSL = new RegExp(
|
|
3091
|
+
'^hsla?\\(' + RE_S + [ANLGE, PCT, PCT].join(SEP) + ALPHA + '\\)$'
|
|
3092
|
+
);
|
|
3093
|
+
const RE_HSL_LEGACY = new RegExp(
|
|
3094
|
+
'^hsl?\\(' + RE_S + [ANLGE, PCT, PCT].join(COMMA) + RE_S + '\\)$'
|
|
3095
|
+
);
|
|
3001
3096
|
const RE_HSLA_LEGACY =
|
|
3002
3097
|
/^hsla\(\s*(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)$/;
|
|
3003
3098
|
|
|
3004
|
-
const RE_LAB =
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
|
|
3011
|
-
|
|
3099
|
+
const RE_LAB = new RegExp(
|
|
3100
|
+
'^lab\\(' +
|
|
3101
|
+
RE_S +
|
|
3102
|
+
[FLOAT_OR_PCT, FLOAT_OR_PCT, FLOAT_OR_PCT].join(SEP) +
|
|
3103
|
+
ALPHA +
|
|
3104
|
+
'\\)$'
|
|
3105
|
+
);
|
|
3106
|
+
const RE_LCH = new RegExp(
|
|
3107
|
+
'^lch\\(' +
|
|
3108
|
+
RE_S +
|
|
3109
|
+
[FLOAT_OR_PCT, FLOAT_OR_PCT, ANLGE].join(SEP) +
|
|
3110
|
+
ALPHA +
|
|
3111
|
+
'\\)$'
|
|
3112
|
+
);
|
|
3113
|
+
const RE_OKLAB = new RegExp(
|
|
3114
|
+
'^oklab\\(' +
|
|
3115
|
+
RE_S +
|
|
3116
|
+
[FLOAT_OR_PCT, FLOAT_OR_PCT, FLOAT_OR_PCT].join(SEP) +
|
|
3117
|
+
ALPHA +
|
|
3118
|
+
'\\)$'
|
|
3119
|
+
);
|
|
3120
|
+
const RE_OKLCH = new RegExp(
|
|
3121
|
+
'^oklch\\(' +
|
|
3122
|
+
RE_S +
|
|
3123
|
+
[FLOAT_OR_PCT, FLOAT_OR_PCT, ANLGE].join(SEP) +
|
|
3124
|
+
ALPHA +
|
|
3125
|
+
'\\)$'
|
|
3126
|
+
);
|
|
3012
3127
|
|
|
3013
3128
|
const { round: round$1 } = Math;
|
|
3014
3129
|
|
|
@@ -3035,6 +3150,11 @@ const noneToValue = (v, noneValue) => {
|
|
|
3035
3150
|
|
|
3036
3151
|
const css2rgb = (css) => {
|
|
3037
3152
|
css = css.toLowerCase().trim();
|
|
3153
|
+
|
|
3154
|
+
if (css === 'transparent') {
|
|
3155
|
+
return [0, 0, 0, 0];
|
|
3156
|
+
}
|
|
3157
|
+
|
|
3038
3158
|
let m;
|
|
3039
3159
|
|
|
3040
3160
|
if (input.format.named) {
|
|
@@ -3046,58 +3166,39 @@ const css2rgb = (css) => {
|
|
|
3046
3166
|
|
|
3047
3167
|
// rgb(250 20 0) or rgb(250,20,0)
|
|
3048
3168
|
if ((m = css.match(RE_RGB)) || (m = css.match(RE_RGB_LEGACY))) {
|
|
3049
|
-
|
|
3169
|
+
let rgb = m.slice(1, 4);
|
|
3050
3170
|
for (let i = 0; i < 3; i++) {
|
|
3051
|
-
rgb[i] = +rgb[i];
|
|
3171
|
+
rgb[i] = +percentToAbsolute(noneToValue(rgb[i], 0), 0, 255);
|
|
3052
3172
|
}
|
|
3053
|
-
rgb
|
|
3173
|
+
rgb = roundRGB(rgb);
|
|
3174
|
+
const alpha = m[4] !== undefined ? +percentToAbsolute(m[4], 0, 1) : 1;
|
|
3175
|
+
rgb[3] = alpha; // default alpha
|
|
3054
3176
|
return rgb;
|
|
3055
3177
|
}
|
|
3056
3178
|
|
|
3057
3179
|
// rgba(250,20,0,0.4)
|
|
3058
|
-
if ((m = css.match(
|
|
3180
|
+
if ((m = css.match(RE_RGBA_LEGACY))) {
|
|
3059
3181
|
const rgb = m.slice(1, 5);
|
|
3060
3182
|
for (let i = 0; i < 4; i++) {
|
|
3061
|
-
rgb[i] = +rgb[i];
|
|
3183
|
+
rgb[i] = +percentToAbsolute(rgb[i], 0, 255);
|
|
3062
3184
|
}
|
|
3063
3185
|
return rgb;
|
|
3064
3186
|
}
|
|
3065
3187
|
|
|
3066
|
-
// rgb(100%,0%,0%)
|
|
3067
|
-
if ((m = css.match(RE_RGB_PCT)) || (m = css.match(RE_RGB_PCT_LEGACY))) {
|
|
3068
|
-
const rgb = m.slice(1, 4);
|
|
3069
|
-
for (let i = 0; i < 3; i++) {
|
|
3070
|
-
rgb[i] = round$1(rgb[i] * 2.55);
|
|
3071
|
-
}
|
|
3072
|
-
rgb[3] = 1; // default alpha
|
|
3073
|
-
return rgb;
|
|
3074
|
-
}
|
|
3075
|
-
|
|
3076
|
-
// rgba(100%,0%,0%,0.4)
|
|
3077
|
-
if ((m = css.match(RE_RGBA_PCT)) || (m = css.match(RE_RGBA_PCT_LEGACY))) {
|
|
3078
|
-
const rgb = m.slice(1, 5);
|
|
3079
|
-
for (let i = 0; i < 3; i++) {
|
|
3080
|
-
rgb[i] = round$1(rgb[i] * 2.55);
|
|
3081
|
-
}
|
|
3082
|
-
rgb[3] = +rgb[3];
|
|
3083
|
-
return rgb;
|
|
3084
|
-
}
|
|
3085
|
-
|
|
3086
3188
|
// hsl(0,100%,50%)
|
|
3087
3189
|
if ((m = css.match(RE_HSL)) || (m = css.match(RE_HSL_LEGACY))) {
|
|
3088
3190
|
const hsl = m.slice(1, 4);
|
|
3089
|
-
hsl[
|
|
3090
|
-
hsl[
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
rgb[3] = 1;
|
|
3191
|
+
hsl[0] = +noneToValue(hsl[0].replace('deg', ''), 0);
|
|
3192
|
+
hsl[1] = +percentToAbsolute(noneToValue(hsl[1], 0), 0, 100) * 0.01;
|
|
3193
|
+
hsl[2] = +percentToAbsolute(noneToValue(hsl[2], 0), 0, 100) * 0.01;
|
|
3194
|
+
const rgb = roundRGB(hsl2rgb(hsl));
|
|
3195
|
+
const alpha = m[4] !== undefined ? +percentToAbsolute(m[4], 0, 1) : 1;
|
|
3196
|
+
rgb[3] = alpha;
|
|
3096
3197
|
return rgb;
|
|
3097
3198
|
}
|
|
3098
3199
|
|
|
3099
3200
|
// hsla(0,100%,50%,0.5)
|
|
3100
|
-
if ((m = css.match(
|
|
3201
|
+
if ((m = css.match(RE_HSLA_LEGACY))) {
|
|
3101
3202
|
const hsl = m.slice(1, 4);
|
|
3102
3203
|
hsl[1] *= 0.01;
|
|
3103
3204
|
hsl[2] *= 0.01;
|
|
@@ -3111,16 +3212,17 @@ const css2rgb = (css) => {
|
|
|
3111
3212
|
|
|
3112
3213
|
if ((m = css.match(RE_LAB))) {
|
|
3113
3214
|
const lab = m.slice(1, 4);
|
|
3114
|
-
lab[0] = percentToAbsolute(lab[0], 0, 100);
|
|
3115
|
-
lab[1] = percentToAbsolute(lab[1], -125, 125, true);
|
|
3116
|
-
lab[2] = percentToAbsolute(lab[2], -125, 125, true);
|
|
3215
|
+
lab[0] = percentToAbsolute(noneToValue(lab[0], 0), 0, 100);
|
|
3216
|
+
lab[1] = percentToAbsolute(noneToValue(lab[1], 0), -125, 125, true);
|
|
3217
|
+
lab[2] = percentToAbsolute(noneToValue(lab[2], 0), -125, 125, true);
|
|
3117
3218
|
// convert to D50 Lab whitepoint
|
|
3118
3219
|
const wp = getLabWhitePoint();
|
|
3119
3220
|
setLabWhitePoint('d50');
|
|
3120
3221
|
const rgb = roundRGB(lab2rgb(lab));
|
|
3121
3222
|
// convert back to original Lab whitepoint
|
|
3122
3223
|
setLabWhitePoint(wp);
|
|
3123
|
-
|
|
3224
|
+
const alpha = m[4] !== undefined ? +percentToAbsolute(m[4], 0, 1) : 1;
|
|
3225
|
+
rgb[3] = alpha;
|
|
3124
3226
|
return rgb;
|
|
3125
3227
|
}
|
|
3126
3228
|
|
|
@@ -3135,27 +3237,30 @@ const css2rgb = (css) => {
|
|
|
3135
3237
|
const rgb = roundRGB(lch2rgb(lch));
|
|
3136
3238
|
// convert back to original Lab whitepoint
|
|
3137
3239
|
setLabWhitePoint(wp);
|
|
3138
|
-
|
|
3240
|
+
const alpha = m[4] !== undefined ? +percentToAbsolute(m[4], 0, 1) : 1;
|
|
3241
|
+
rgb[3] = alpha;
|
|
3139
3242
|
return rgb;
|
|
3140
3243
|
}
|
|
3141
3244
|
|
|
3142
3245
|
if ((m = css.match(RE_OKLAB))) {
|
|
3143
3246
|
const oklab = m.slice(1, 4);
|
|
3144
|
-
oklab[0] = percentToAbsolute(oklab[0], 0, 1);
|
|
3145
|
-
oklab[1] = percentToAbsolute(oklab[1], -0.4, 0.4, true);
|
|
3146
|
-
oklab[2] = percentToAbsolute(oklab[2], -0.4, 0.4, true);
|
|
3247
|
+
oklab[0] = percentToAbsolute(noneToValue(oklab[0], 0), 0, 1);
|
|
3248
|
+
oklab[1] = percentToAbsolute(noneToValue(oklab[1], 0), -0.4, 0.4, true);
|
|
3249
|
+
oklab[2] = percentToAbsolute(noneToValue(oklab[2], 0), -0.4, 0.4, true);
|
|
3147
3250
|
const rgb = roundRGB(oklab2rgb(oklab));
|
|
3148
|
-
|
|
3251
|
+
const alpha = m[4] !== undefined ? +percentToAbsolute(m[4], 0, 1) : 1;
|
|
3252
|
+
rgb[3] = alpha;
|
|
3149
3253
|
return rgb;
|
|
3150
3254
|
}
|
|
3151
3255
|
|
|
3152
3256
|
if ((m = css.match(RE_OKLCH))) {
|
|
3153
3257
|
const oklch = m.slice(1, 4);
|
|
3154
|
-
oklch[0] = percentToAbsolute(oklch[0], 0, 1);
|
|
3258
|
+
oklch[0] = percentToAbsolute(noneToValue(oklch[0], 0), 0, 1);
|
|
3155
3259
|
oklch[1] = percentToAbsolute(noneToValue(oklch[1], 0), 0, 0.4, false);
|
|
3156
3260
|
oklch[2] = +noneToValue(oklch[2].replace('deg', ''), 0);
|
|
3157
3261
|
const rgb = roundRGB(oklch2rgb(oklch));
|
|
3158
|
-
|
|
3262
|
+
const alpha = m[4] !== undefined ? +percentToAbsolute(m[4], 0, 1) : 1;
|
|
3263
|
+
rgb[3] = alpha;
|
|
3159
3264
|
return rgb;
|
|
3160
3265
|
}
|
|
3161
3266
|
};
|
|
@@ -3164,11 +3269,7 @@ css2rgb.test = (s) => {
|
|
|
3164
3269
|
return (
|
|
3165
3270
|
// modern
|
|
3166
3271
|
RE_RGB.test(s) ||
|
|
3167
|
-
RE_RGBA.test(s) ||
|
|
3168
|
-
RE_RGB_PCT.test(s) ||
|
|
3169
|
-
RE_RGBA_PCT.test(s) ||
|
|
3170
3272
|
RE_HSL.test(s) ||
|
|
3171
|
-
RE_HSLA.test(s) ||
|
|
3172
3273
|
RE_LAB.test(s) ||
|
|
3173
3274
|
RE_LCH.test(s) ||
|
|
3174
3275
|
RE_OKLAB.test(s) ||
|
|
@@ -3176,10 +3277,9 @@ css2rgb.test = (s) => {
|
|
|
3176
3277
|
// legacy
|
|
3177
3278
|
RE_RGB_LEGACY.test(s) ||
|
|
3178
3279
|
RE_RGBA_LEGACY.test(s) ||
|
|
3179
|
-
RE_RGB_PCT_LEGACY.test(s) ||
|
|
3180
|
-
RE_RGBA_PCT_LEGACY.test(s) ||
|
|
3181
3280
|
RE_HSL_LEGACY.test(s) ||
|
|
3182
|
-
RE_HSLA_LEGACY.test(s)
|
|
3281
|
+
RE_HSLA_LEGACY.test(s) ||
|
|
3282
|
+
s === 'transparent'
|
|
3183
3283
|
);
|
|
3184
3284
|
};
|
|
3185
3285
|
|
|
@@ -3345,10 +3445,11 @@ Object.assign(chroma, {
|
|
|
3345
3445
|
average,
|
|
3346
3446
|
bezier: bezier$1,
|
|
3347
3447
|
blend,
|
|
3348
|
-
brewer:
|
|
3448
|
+
brewer: colorbrewerProxy,
|
|
3349
3449
|
Color,
|
|
3350
3450
|
colors: w3cx11,
|
|
3351
3451
|
contrast,
|
|
3452
|
+
contrastAPCA,
|
|
3352
3453
|
cubehelix,
|
|
3353
3454
|
deltaE,
|
|
3354
3455
|
distance,
|
|
@@ -3563,6 +3664,81 @@ function t(r){return typeof r=="string"}
|
|
|
3563
3664
|
|
|
3564
3665
|
function n(e){return !!e}
|
|
3565
3666
|
|
|
3667
|
+
function getDefaultExportFromCjs (x) {
|
|
3668
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
3669
|
+
}
|
|
3670
|
+
|
|
3671
|
+
var naturalCompareLite = {exports: {}};
|
|
3672
|
+
|
|
3673
|
+
/*
|
|
3674
|
+
* @version 1.4.0
|
|
3675
|
+
* @date 2015-10-26
|
|
3676
|
+
* @stability 3 - Stable
|
|
3677
|
+
* @author Lauri Rooden (https://github.com/litejs/natural-compare-lite)
|
|
3678
|
+
* @license MIT License
|
|
3679
|
+
*/
|
|
3680
|
+
|
|
3681
|
+
|
|
3682
|
+
var naturalCompare = function(a, b) {
|
|
3683
|
+
var i, codeA
|
|
3684
|
+
, codeB = 1
|
|
3685
|
+
, posA = 0
|
|
3686
|
+
, posB = 0
|
|
3687
|
+
, alphabet = String.alphabet;
|
|
3688
|
+
|
|
3689
|
+
function getCode(str, pos, code) {
|
|
3690
|
+
if (code) {
|
|
3691
|
+
for (i = pos; code = getCode(str, i), code < 76 && code > 65;) ++i;
|
|
3692
|
+
return +str.slice(pos - 1, i)
|
|
3693
|
+
}
|
|
3694
|
+
code = alphabet && alphabet.indexOf(str.charAt(pos));
|
|
3695
|
+
return code > -1 ? code + 76 : ((code = str.charCodeAt(pos) || 0), code < 45 || code > 127) ? code
|
|
3696
|
+
: code < 46 ? 65 // -
|
|
3697
|
+
: code < 48 ? code - 1
|
|
3698
|
+
: code < 58 ? code + 18 // 0-9
|
|
3699
|
+
: code < 65 ? code - 11
|
|
3700
|
+
: code < 91 ? code + 11 // A-Z
|
|
3701
|
+
: code < 97 ? code - 37
|
|
3702
|
+
: code < 123 ? code + 5 // a-z
|
|
3703
|
+
: code - 63
|
|
3704
|
+
}
|
|
3705
|
+
|
|
3706
|
+
|
|
3707
|
+
if ((a+="") != (b+="")) for (;codeB;) {
|
|
3708
|
+
codeA = getCode(a, posA++);
|
|
3709
|
+
codeB = getCode(b, posB++);
|
|
3710
|
+
|
|
3711
|
+
if (codeA < 76 && codeB < 76 && codeA > 66 && codeB > 66) {
|
|
3712
|
+
codeA = getCode(a, posA, posA);
|
|
3713
|
+
codeB = getCode(b, posB, posA = i);
|
|
3714
|
+
posB = i;
|
|
3715
|
+
}
|
|
3716
|
+
|
|
3717
|
+
if (codeA != codeB) return (codeA < codeB) ? -1 : 1
|
|
3718
|
+
}
|
|
3719
|
+
return 0
|
|
3720
|
+
};
|
|
3721
|
+
|
|
3722
|
+
try {
|
|
3723
|
+
naturalCompareLite.exports = naturalCompare;
|
|
3724
|
+
} catch (e) {
|
|
3725
|
+
String.naturalCompare = naturalCompare;
|
|
3726
|
+
}
|
|
3727
|
+
|
|
3728
|
+
var naturalCompareLiteExports = naturalCompareLite.exports;
|
|
3729
|
+
const compare = /*@__PURE__*/getDefaultExportFromCjs(naturalCompareLiteExports);
|
|
3730
|
+
|
|
3731
|
+
function compareNatural(a, b) {
|
|
3732
|
+
if (a === b) return 0;
|
|
3733
|
+
if (t(a)) {
|
|
3734
|
+
if (t(b)) {
|
|
3735
|
+
return compare(a, b);
|
|
3736
|
+
}
|
|
3737
|
+
return 1;
|
|
3738
|
+
}
|
|
3739
|
+
return t(b) ? -1 : 0;
|
|
3740
|
+
}
|
|
3741
|
+
|
|
3566
3742
|
function isString(value) {
|
|
3567
3743
|
return value != null && typeof value === "string";
|
|
3568
3744
|
}
|
|
@@ -3659,6 +3835,25 @@ function compareFqnHierarchically(a, b) {
|
|
|
3659
3835
|
function compareByFqnHierarchically(a, b) {
|
|
3660
3836
|
return compareFqnHierarchically(a.id, b.id);
|
|
3661
3837
|
}
|
|
3838
|
+
function sortByFqnHierarchically(array) {
|
|
3839
|
+
return array.map((item) => ({ item, fqn: item.id.split(".") })).sort((a, b) => {
|
|
3840
|
+
return a.fqn.length - b.fqn.length;
|
|
3841
|
+
}).map(({ item }) => item);
|
|
3842
|
+
}
|
|
3843
|
+
function sortNaturalByFqn(array) {
|
|
3844
|
+
return array.map((item) => ({ item, fqn: item.id.split(".") })).sort((a, b) => {
|
|
3845
|
+
if (a.fqn.length !== b.fqn.length) {
|
|
3846
|
+
return a.fqn.length - b.fqn.length;
|
|
3847
|
+
}
|
|
3848
|
+
for (let i = 0; i < a.fqn.length; i++) {
|
|
3849
|
+
const compare = compareNatural(a.fqn[i], b.fqn[i]);
|
|
3850
|
+
if (compare !== 0) {
|
|
3851
|
+
return compare;
|
|
3852
|
+
}
|
|
3853
|
+
}
|
|
3854
|
+
return 0;
|
|
3855
|
+
}).map(({ item }) => item);
|
|
3856
|
+
}
|
|
3662
3857
|
|
|
3663
3858
|
class LikeC4ViewModel {
|
|
3664
3859
|
constructor(view, model) {
|
|
@@ -4284,14 +4479,14 @@ const compareRelations = (a, b) => {
|
|
|
4284
4479
|
return -1;
|
|
4285
4480
|
}
|
|
4286
4481
|
const compareParents = parentA && parentB ? compareFqnHierarchically(parentA, parentB) : 0;
|
|
4287
|
-
if (compareParents
|
|
4288
|
-
|
|
4289
|
-
|
|
4290
|
-
|
|
4291
|
-
|
|
4292
|
-
return
|
|
4482
|
+
if (compareParents !== 0) {
|
|
4483
|
+
return compareParents;
|
|
4484
|
+
}
|
|
4485
|
+
const compareSource = compareFqnHierarchically(a.source, b.source);
|
|
4486
|
+
if (compareSource !== 0) {
|
|
4487
|
+
return compareSource;
|
|
4293
4488
|
}
|
|
4294
|
-
return
|
|
4489
|
+
return compareFqnHierarchically(a.target, b.target);
|
|
4295
4490
|
};
|
|
4296
4491
|
|
|
4297
4492
|
exports.AsFqn = types_index.AsFqn;
|
|
@@ -4306,6 +4501,7 @@ exports.Expr = types_index.expression;
|
|
|
4306
4501
|
exports.StepEdgeId = types_index.StepEdgeId;
|
|
4307
4502
|
exports.extractStep = types_index.extractStep;
|
|
4308
4503
|
exports.getBBoxCenter = types_index.getBBoxCenter;
|
|
4504
|
+
exports.getParallelStepsPrefix = types_index.getParallelStepsPrefix;
|
|
4309
4505
|
exports.invariant = types_index.invariant;
|
|
4310
4506
|
exports.isAndOperator = types_index.isAndOperator;
|
|
4311
4507
|
exports.isComputedDynamicView = types_index.isComputedDynamicView;
|
|
@@ -4314,6 +4510,7 @@ exports.isCustomElement = types_index.isCustomElement;
|
|
|
4314
4510
|
exports.isCustomRelationExpr = types_index.isCustomRelationExpr;
|
|
4315
4511
|
exports.isDynamicView = types_index.isDynamicView;
|
|
4316
4512
|
exports.isDynamicViewIncludeRule = types_index.isDynamicViewIncludeRule;
|
|
4513
|
+
exports.isDynamicViewParallelSteps = types_index.isDynamicViewParallelSteps;
|
|
4317
4514
|
exports.isElement = types_index.isElement;
|
|
4318
4515
|
exports.isElementKindExpr = types_index.isElementKindExpr;
|
|
4319
4516
|
exports.isElementPredicateExpr = types_index.isElementPredicateExpr;
|
|
@@ -4352,6 +4549,7 @@ exports.ancestorsFqn = ancestorsFqn;
|
|
|
4352
4549
|
exports.commonAncestor = commonAncestor;
|
|
4353
4550
|
exports.compareByFqnHierarchically = compareByFqnHierarchically;
|
|
4354
4551
|
exports.compareFqnHierarchically = compareFqnHierarchically;
|
|
4552
|
+
exports.compareNatural = compareNatural;
|
|
4355
4553
|
exports.compareRelations = compareRelations;
|
|
4356
4554
|
exports.computeColorValues = computeColorValues;
|
|
4357
4555
|
exports.defaultTheme = defaultTheme;
|
|
@@ -4366,3 +4564,5 @@ exports.nameFromFqn = nameFromFqn;
|
|
|
4366
4564
|
exports.notDescendantOf = notDescendantOf;
|
|
4367
4565
|
exports.parentFqn = parentFqn;
|
|
4368
4566
|
exports.parentFqnPredicate = parentFqnPredicate;
|
|
4567
|
+
exports.sortByFqnHierarchically = sortByFqnHierarchically;
|
|
4568
|
+
exports.sortNaturalByFqn = sortNaturalByFqn;
|