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