@tenphi/tasty 0.0.0-snapshot.26b4630 → 0.0.0-snapshot.2705ab9
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/README.md +315 -159
- package/dist/chunks/cacheKey.js +16 -8
- package/dist/chunks/cacheKey.js.map +1 -1
- package/dist/chunks/definitions.d.ts +1 -1
- package/dist/chunks/definitions.js +2 -3
- package/dist/chunks/definitions.js.map +1 -1
- package/dist/chunks/renderChunk.js +31 -32
- package/dist/chunks/renderChunk.js.map +1 -1
- package/dist/config.d.ts +98 -12
- package/dist/config.js +134 -33
- package/dist/config.js.map +1 -1
- package/dist/core/index.d.ts +11 -10
- package/dist/core/index.js +8 -7
- package/dist/counter-style/index.js +51 -0
- package/dist/counter-style/index.js.map +1 -0
- package/dist/debug.d.ts +26 -141
- package/dist/debug.js +356 -635
- package/dist/debug.js.map +1 -1
- package/dist/font-face/index.js +63 -0
- package/dist/font-face/index.js.map +1 -0
- package/dist/hooks/resolve-ssr-collector.js +15 -0
- package/dist/hooks/resolve-ssr-collector.js.map +1 -0
- package/dist/hooks/useCounterStyle.d.ts +50 -0
- package/dist/hooks/useCounterStyle.js +47 -0
- package/dist/hooks/useCounterStyle.js.map +1 -0
- package/dist/hooks/useFontFace.d.ts +43 -0
- package/dist/hooks/useFontFace.js +71 -0
- package/dist/hooks/useFontFace.js.map +1 -0
- package/dist/hooks/useGlobalStyles.d.ts +3 -0
- package/dist/hooks/useGlobalStyles.js +24 -1
- package/dist/hooks/useGlobalStyles.js.map +1 -1
- package/dist/hooks/useKeyframes.js +14 -3
- package/dist/hooks/useKeyframes.js.map +1 -1
- package/dist/hooks/useProperty.js +32 -13
- package/dist/hooks/useProperty.js.map +1 -1
- package/dist/hooks/useRawCSS.js +9 -1
- package/dist/hooks/useRawCSS.js.map +1 -1
- package/dist/hooks/useStyles.d.ts +5 -0
- package/dist/hooks/useStyles.js +115 -46
- package/dist/hooks/useStyles.js.map +1 -1
- package/dist/index.d.ts +22 -11
- package/dist/index.js +10 -7
- package/dist/injector/index.d.ts +28 -2
- package/dist/injector/index.js +27 -1
- package/dist/injector/index.js.map +1 -1
- package/dist/injector/injector.d.ts +28 -1
- package/dist/injector/injector.js +93 -32
- package/dist/injector/injector.js.map +1 -1
- package/dist/injector/sheet-manager.d.ts +16 -7
- package/dist/injector/sheet-manager.js +31 -11
- package/dist/injector/sheet-manager.js.map +1 -1
- package/dist/injector/types.d.ts +70 -1
- package/dist/parser/classify.js +5 -4
- package/dist/parser/classify.js.map +1 -1
- package/dist/parser/const.js +17 -1
- package/dist/parser/const.js.map +1 -1
- package/dist/parser/parser.js +1 -1
- package/dist/pipeline/conditions.js +14 -8
- package/dist/pipeline/conditions.js.map +1 -1
- package/dist/pipeline/index.d.ts +3 -1
- package/dist/pipeline/index.js +137 -69
- package/dist/pipeline/index.js.map +1 -1
- package/dist/pipeline/materialize.js +404 -208
- package/dist/pipeline/materialize.js.map +1 -1
- package/dist/pipeline/parseStateKey.d.ts +1 -1
- package/dist/pipeline/parseStateKey.js +37 -20
- package/dist/pipeline/parseStateKey.js.map +1 -1
- package/dist/pipeline/simplify.js +111 -152
- package/dist/pipeline/simplify.js.map +1 -1
- package/dist/pipeline/warnings.js +18 -0
- package/dist/pipeline/warnings.js.map +1 -0
- package/dist/plugins/okhsl-plugin.js +2 -275
- package/dist/plugins/okhsl-plugin.js.map +1 -1
- package/dist/plugins/types.d.ts +9 -2
- package/dist/properties/index.js +82 -17
- package/dist/properties/index.js.map +1 -1
- package/dist/properties/property-type-resolver.d.ts +24 -0
- package/dist/properties/property-type-resolver.js +91 -0
- package/dist/properties/property-type-resolver.js.map +1 -0
- package/dist/ssr/astro.d.ts +29 -0
- package/dist/ssr/astro.js +65 -0
- package/dist/ssr/astro.js.map +1 -0
- package/dist/ssr/async-storage.d.ts +17 -0
- package/dist/ssr/async-storage.js +35 -0
- package/dist/ssr/async-storage.js.map +1 -0
- package/dist/ssr/collect-auto-properties.js +40 -0
- package/dist/ssr/collect-auto-properties.js.map +1 -0
- package/dist/ssr/collector.d.ts +102 -0
- package/dist/ssr/collector.js +227 -0
- package/dist/ssr/collector.js.map +1 -0
- package/dist/ssr/context.d.ts +8 -0
- package/dist/ssr/context.js +14 -0
- package/dist/ssr/context.js.map +1 -0
- package/dist/ssr/format-global-rules.js +22 -0
- package/dist/ssr/format-global-rules.js.map +1 -0
- package/dist/ssr/format-keyframes.js +70 -0
- package/dist/ssr/format-keyframes.js.map +1 -0
- package/dist/ssr/format-property.js +50 -0
- package/dist/ssr/format-property.js.map +1 -0
- package/dist/ssr/format-rules.js +73 -0
- package/dist/ssr/format-rules.js.map +1 -0
- package/dist/ssr/hydrate.d.ts +22 -0
- package/dist/ssr/hydrate.js +50 -0
- package/dist/ssr/hydrate.js.map +1 -0
- package/dist/ssr/index.d.ts +5 -0
- package/dist/ssr/index.js +12 -0
- package/dist/ssr/index.js.map +1 -0
- package/dist/ssr/next.d.ts +45 -0
- package/dist/ssr/next.js +71 -0
- package/dist/ssr/next.js.map +1 -0
- package/dist/ssr/ssr-collector-ref.js +12 -0
- package/dist/ssr/ssr-collector-ref.js.map +1 -0
- package/dist/states/index.js +12 -257
- package/dist/states/index.js.map +1 -1
- package/dist/styles/align.d.ts +1 -1
- package/dist/styles/align.js.map +1 -1
- package/dist/styles/border.d.ts +1 -1
- package/dist/styles/border.js +2 -2
- package/dist/styles/border.js.map +1 -1
- package/dist/styles/color.d.ts +2 -2
- package/dist/styles/color.js +9 -5
- package/dist/styles/color.js.map +1 -1
- package/dist/styles/createStyle.js +25 -22
- package/dist/styles/createStyle.js.map +1 -1
- package/dist/styles/fade.d.ts +1 -1
- package/dist/styles/fade.js.map +1 -1
- package/dist/styles/fill.d.ts +14 -16
- package/dist/styles/fill.js +6 -5
- package/dist/styles/fill.js.map +1 -1
- package/dist/styles/flow.d.ts +3 -3
- package/dist/styles/flow.js.map +1 -1
- package/dist/styles/index.js +1 -1
- package/dist/styles/justify.d.ts +1 -1
- package/dist/styles/justify.js.map +1 -1
- package/dist/styles/predefined.d.ts +0 -2
- package/dist/styles/predefined.js +1 -4
- package/dist/styles/predefined.js.map +1 -1
- package/dist/styles/preset.d.ts +5 -0
- package/dist/styles/preset.js +48 -47
- package/dist/styles/preset.js.map +1 -1
- package/dist/styles/radius.d.ts +1 -1
- package/dist/styles/radius.js.map +1 -1
- package/dist/styles/scrollbar.d.ts +9 -5
- package/dist/styles/scrollbar.js +25 -82
- package/dist/styles/scrollbar.js.map +1 -1
- package/dist/styles/shadow.d.ts +2 -2
- package/dist/styles/shadow.js.map +1 -1
- package/dist/styles/transition.d.ts +1 -1
- package/dist/styles/transition.js +1 -1
- package/dist/styles/transition.js.map +1 -1
- package/dist/styles/types.d.ts +70 -21
- package/dist/tasty.d.ts +30 -893
- package/dist/tasty.js +60 -19
- package/dist/tasty.js.map +1 -1
- package/dist/types.d.ts +3 -3
- package/dist/utils/cache-wrapper.js +4 -8
- package/dist/utils/cache-wrapper.js.map +1 -1
- package/dist/utils/color-math.d.ts +46 -0
- package/dist/utils/color-math.js +749 -0
- package/dist/utils/color-math.js.map +1 -0
- package/dist/utils/color-space.d.ts +5 -0
- package/dist/utils/color-space.js +229 -0
- package/dist/utils/color-space.js.map +1 -0
- package/dist/utils/colors.d.ts +1 -1
- package/dist/utils/colors.js +3 -1
- package/dist/utils/colors.js.map +1 -1
- package/dist/utils/css-types.d.ts +1 -1
- package/dist/utils/dotize.d.ts +1 -1
- package/dist/utils/has-keys.js +13 -0
- package/dist/utils/has-keys.js.map +1 -0
- package/dist/utils/mod-attrs.js +2 -2
- package/dist/utils/mod-attrs.js.map +1 -1
- package/dist/utils/process-tokens.d.ts +3 -13
- package/dist/utils/process-tokens.js +18 -98
- package/dist/utils/process-tokens.js.map +1 -1
- package/dist/utils/selector-transform.js +32 -0
- package/dist/utils/selector-transform.js.map +1 -0
- package/dist/utils/string.js.map +1 -1
- package/dist/utils/styles.d.ts +4 -88
- package/dist/utils/styles.js +34 -398
- package/dist/utils/styles.js.map +1 -1
- package/dist/utils/typography.d.ts +24 -13
- package/dist/utils/typography.js +14 -16
- package/dist/utils/typography.js.map +1 -1
- package/dist/zero/babel.d.ts +67 -8
- package/dist/zero/babel.js +109 -17
- package/dist/zero/babel.js.map +1 -1
- package/dist/zero/extractor.js +118 -1
- package/dist/zero/extractor.js.map +1 -1
- package/dist/zero/next.d.ts +44 -30
- package/dist/zero/next.js +102 -38
- package/dist/zero/next.js.map +1 -1
- package/docs/PIPELINE.md +519 -0
- package/docs/README.md +31 -0
- package/docs/adoption.md +296 -0
- package/docs/comparison.md +420 -0
- package/docs/configuration.md +326 -0
- package/docs/debug.md +318 -0
- package/docs/design-system.md +424 -0
- package/docs/dsl.md +673 -0
- package/docs/getting-started.md +217 -0
- package/docs/injector.md +528 -0
- package/docs/methodology.md +567 -0
- package/docs/runtime.md +485 -0
- package/docs/ssr.md +384 -0
- package/docs/styles.md +579 -0
- package/docs/tasty-static.md +433 -0
- package/package.json +98 -28
- package/dist/styles/styledScrollbar.d.ts +0 -47
- package/dist/styles/styledScrollbar.js +0 -38
- package/dist/styles/styledScrollbar.js.map +0 -1
- package/dist/tokens/typography.d.ts +0 -19
- package/dist/tokens/typography.js +0 -237
- package/dist/tokens/typography.js.map +0 -1
- package/dist/utils/hsl-to-rgb.js +0 -38
- package/dist/utils/hsl-to-rgb.js.map +0 -1
- package/dist/utils/okhsl-to-rgb.js +0 -296
- package/dist/utils/okhsl-to-rgb.js.map +0 -1
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
//#region src/styles/styledScrollbar.ts
|
|
2
|
-
/**
|
|
3
|
-
* @deprecated `styledScrollbar` is deprecated. Use `scrollbar` instead.
|
|
4
|
-
*/
|
|
5
|
-
function styledScrollbarStyle({ styledScrollbar: val }) {
|
|
6
|
-
if (val == null) return null;
|
|
7
|
-
if (!val) return [{
|
|
8
|
-
$: "::-webkit-scrollbar",
|
|
9
|
-
display: "none"
|
|
10
|
-
}, { "scrollbar-width": "none" }];
|
|
11
|
-
return [
|
|
12
|
-
{
|
|
13
|
-
$: "::-webkit-scrollbar",
|
|
14
|
-
width: "var(--scrollbar-width)",
|
|
15
|
-
height: "var(--scrollbar-width)"
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
$: "::-webkit-scrollbar-track",
|
|
19
|
-
"background-color": "var(--scrollbar-bg-color)"
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
$: "::-webkit-scrollbar-thumb",
|
|
23
|
-
"background-color": "var(--scrollbar-thumb-color)",
|
|
24
|
-
"border-radius": "var(--scrollbar-radius)",
|
|
25
|
-
border: "var(--scrollbar-outline-width) solid var(--scrollbar-outline-color)",
|
|
26
|
-
"background-clip": "padding-box"
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
$: "::-webkit-scrollbar-corner",
|
|
30
|
-
"background-color": "var(--scrollbar-corner-color)"
|
|
31
|
-
}
|
|
32
|
-
];
|
|
33
|
-
}
|
|
34
|
-
styledScrollbarStyle.__lookupStyles = ["styledScrollbar"];
|
|
35
|
-
|
|
36
|
-
//#endregion
|
|
37
|
-
export { styledScrollbarStyle };
|
|
38
|
-
//# sourceMappingURL=styledScrollbar.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"styledScrollbar.js","names":[],"sources":["../../src/styles/styledScrollbar.ts"],"sourcesContent":["/**\n * @deprecated `styledScrollbar` is deprecated. Use `scrollbar` instead.\n */\nexport function styledScrollbarStyle({ styledScrollbar: val }) {\n if (val == null) return null;\n\n if (!val) {\n return [\n {\n $: '::-webkit-scrollbar',\n display: 'none',\n },\n {\n 'scrollbar-width': 'none',\n },\n ];\n }\n\n return [\n {\n $: '::-webkit-scrollbar',\n width: 'var(--scrollbar-width)',\n height: 'var(--scrollbar-width)',\n },\n {\n $: '::-webkit-scrollbar-track',\n 'background-color': 'var(--scrollbar-bg-color)',\n },\n {\n $: '::-webkit-scrollbar-thumb',\n 'background-color': 'var(--scrollbar-thumb-color)',\n 'border-radius': 'var(--scrollbar-radius)',\n border:\n 'var(--scrollbar-outline-width) solid var(--scrollbar-outline-color)',\n 'background-clip': 'padding-box',\n },\n {\n $: '::-webkit-scrollbar-corner',\n 'background-color': 'var(--scrollbar-corner-color)',\n },\n // Breaks the scrollbar in the latest Chromium browsers\n // {\n // 'scrollbar-width': 'thin',\n // 'scrollbar-color':\n // 'var(--scrollbar-bg-color) var(--scrollbar-thumb-color)',\n // },\n ];\n}\n\nstyledScrollbarStyle.__lookupStyles = ['styledScrollbar'];\n"],"mappings":";;;;AAGA,SAAgB,qBAAqB,EAAE,iBAAiB,OAAO;AAC7D,KAAI,OAAO,KAAM,QAAO;AAExB,KAAI,CAAC,IACH,QAAO,CACL;EACE,GAAG;EACH,SAAS;EACV,EACD,EACE,mBAAmB,QACpB,CACF;AAGH,QAAO;EACL;GACE,GAAG;GACH,OAAO;GACP,QAAQ;GACT;EACD;GACE,GAAG;GACH,oBAAoB;GACrB;EACD;GACE,GAAG;GACH,oBAAoB;GACpB,iBAAiB;GACjB,QACE;GACF,mBAAmB;GACpB;EACD;GACE,GAAG;GACH,oBAAoB;GACrB;EAOF;;AAGH,qBAAqB,iBAAiB,CAAC,kBAAkB"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
//#region src/tokens/typography.d.ts
|
|
2
|
-
/**
|
|
3
|
-
* Typography preset configuration.
|
|
4
|
-
* Each preset defines font properties that get expanded into CSS custom properties.
|
|
5
|
-
*/
|
|
6
|
-
interface TypographyPreset {
|
|
7
|
-
fontSize: string;
|
|
8
|
-
lineHeight: string;
|
|
9
|
-
letterSpacing?: string;
|
|
10
|
-
fontWeight: string | number;
|
|
11
|
-
boldFontWeight?: string | number;
|
|
12
|
-
iconSize?: string;
|
|
13
|
-
textTransform?: string;
|
|
14
|
-
fontFamily?: string;
|
|
15
|
-
fontStyle?: string;
|
|
16
|
-
}
|
|
17
|
-
//#endregion
|
|
18
|
-
export { TypographyPreset };
|
|
19
|
-
//# sourceMappingURL=typography.d.ts.map
|
|
@@ -1,237 +0,0 @@
|
|
|
1
|
-
//#region src/tokens/typography.ts
|
|
2
|
-
/**
|
|
3
|
-
* Typography presets for headings, text, and special styles.
|
|
4
|
-
*
|
|
5
|
-
* Naming conventions:
|
|
6
|
-
* - `h1`-`h6`: Headings (bold by default)
|
|
7
|
-
* - `t1`-`t4`: Text styles (regular weight)
|
|
8
|
-
* - `t1m`-`t4m`: Text styles medium weight
|
|
9
|
-
* - `m1`-`m3`: Markdown/prose styles (larger line-height)
|
|
10
|
-
* - `p1`-`p4`: Paragraph styles
|
|
11
|
-
* - `c1`-`c2`: Caption/uppercase styles
|
|
12
|
-
* - `tag`: Tag/badge typography
|
|
13
|
-
* - `strong`, `em`: Inline semantic styles
|
|
14
|
-
* - `default`: Base text style
|
|
15
|
-
*/
|
|
16
|
-
const TYPOGRAPHY_PRESETS = {
|
|
17
|
-
text: {
|
|
18
|
-
fontSize: "14px",
|
|
19
|
-
lineHeight: "20px",
|
|
20
|
-
letterSpacing: "0",
|
|
21
|
-
fontWeight: "400"
|
|
22
|
-
},
|
|
23
|
-
h1: {
|
|
24
|
-
fontSize: "36px",
|
|
25
|
-
lineHeight: "44px",
|
|
26
|
-
letterSpacing: "-0.01em",
|
|
27
|
-
fontWeight: "600",
|
|
28
|
-
boldFontWeight: "700",
|
|
29
|
-
iconSize: "40px"
|
|
30
|
-
},
|
|
31
|
-
h2: {
|
|
32
|
-
fontSize: "24px",
|
|
33
|
-
lineHeight: "32px",
|
|
34
|
-
letterSpacing: "0em",
|
|
35
|
-
fontWeight: "600",
|
|
36
|
-
boldFontWeight: "700",
|
|
37
|
-
iconSize: "28px"
|
|
38
|
-
},
|
|
39
|
-
h3: {
|
|
40
|
-
fontSize: "20px",
|
|
41
|
-
lineHeight: "28px",
|
|
42
|
-
letterSpacing: "0em",
|
|
43
|
-
fontWeight: "600",
|
|
44
|
-
boldFontWeight: "700",
|
|
45
|
-
iconSize: "24px"
|
|
46
|
-
},
|
|
47
|
-
h4: {
|
|
48
|
-
fontSize: "18px",
|
|
49
|
-
lineHeight: "24px",
|
|
50
|
-
letterSpacing: "0",
|
|
51
|
-
fontWeight: "600",
|
|
52
|
-
boldFontWeight: "700",
|
|
53
|
-
iconSize: "22px"
|
|
54
|
-
},
|
|
55
|
-
h5: {
|
|
56
|
-
fontSize: "16px",
|
|
57
|
-
lineHeight: "22px",
|
|
58
|
-
letterSpacing: "0",
|
|
59
|
-
fontWeight: "600",
|
|
60
|
-
boldFontWeight: "700",
|
|
61
|
-
iconSize: "20px"
|
|
62
|
-
},
|
|
63
|
-
h6: {
|
|
64
|
-
fontSize: "14px",
|
|
65
|
-
lineHeight: "20px",
|
|
66
|
-
letterSpacing: "0.01em",
|
|
67
|
-
fontWeight: "600",
|
|
68
|
-
boldFontWeight: "700",
|
|
69
|
-
iconSize: "20px"
|
|
70
|
-
},
|
|
71
|
-
t1: {
|
|
72
|
-
fontSize: "18px",
|
|
73
|
-
lineHeight: "24px",
|
|
74
|
-
letterSpacing: "0",
|
|
75
|
-
fontWeight: "400",
|
|
76
|
-
boldFontWeight: "600",
|
|
77
|
-
iconSize: "20px"
|
|
78
|
-
},
|
|
79
|
-
t2: {
|
|
80
|
-
fontSize: "16px",
|
|
81
|
-
lineHeight: "22px",
|
|
82
|
-
letterSpacing: "0",
|
|
83
|
-
fontWeight: "400",
|
|
84
|
-
boldFontWeight: "600",
|
|
85
|
-
iconSize: "20px"
|
|
86
|
-
},
|
|
87
|
-
t2m: {
|
|
88
|
-
fontSize: "16px",
|
|
89
|
-
lineHeight: "22px",
|
|
90
|
-
letterSpacing: "0",
|
|
91
|
-
fontWeight: "500",
|
|
92
|
-
boldFontWeight: "600",
|
|
93
|
-
iconSize: "20px"
|
|
94
|
-
},
|
|
95
|
-
t3: {
|
|
96
|
-
fontSize: "14px",
|
|
97
|
-
lineHeight: "20px",
|
|
98
|
-
letterSpacing: "0",
|
|
99
|
-
fontWeight: "400",
|
|
100
|
-
boldFontWeight: "600",
|
|
101
|
-
iconSize: "18px"
|
|
102
|
-
},
|
|
103
|
-
t3m: {
|
|
104
|
-
fontSize: "14px",
|
|
105
|
-
lineHeight: "20px",
|
|
106
|
-
letterSpacing: "0",
|
|
107
|
-
fontWeight: "500",
|
|
108
|
-
boldFontWeight: "600",
|
|
109
|
-
iconSize: "18px"
|
|
110
|
-
},
|
|
111
|
-
t4: {
|
|
112
|
-
fontSize: "12px",
|
|
113
|
-
lineHeight: "18px",
|
|
114
|
-
letterSpacing: "0",
|
|
115
|
-
fontWeight: "500",
|
|
116
|
-
boldFontWeight: "600",
|
|
117
|
-
iconSize: "16px"
|
|
118
|
-
},
|
|
119
|
-
t4m: {
|
|
120
|
-
fontSize: "12px",
|
|
121
|
-
lineHeight: "18px",
|
|
122
|
-
letterSpacing: "0",
|
|
123
|
-
fontWeight: "600",
|
|
124
|
-
boldFontWeight: "700",
|
|
125
|
-
iconSize: "16px"
|
|
126
|
-
},
|
|
127
|
-
m1: {
|
|
128
|
-
fontSize: "18px",
|
|
129
|
-
lineHeight: "32px",
|
|
130
|
-
letterSpacing: "0",
|
|
131
|
-
fontWeight: "400",
|
|
132
|
-
boldFontWeight: "600",
|
|
133
|
-
iconSize: "22px"
|
|
134
|
-
},
|
|
135
|
-
m2: {
|
|
136
|
-
fontSize: "16px",
|
|
137
|
-
lineHeight: "28px",
|
|
138
|
-
letterSpacing: "0",
|
|
139
|
-
fontWeight: "400",
|
|
140
|
-
boldFontWeight: "600",
|
|
141
|
-
iconSize: "20px"
|
|
142
|
-
},
|
|
143
|
-
m3: {
|
|
144
|
-
fontSize: "14px",
|
|
145
|
-
lineHeight: "24px",
|
|
146
|
-
letterSpacing: "0",
|
|
147
|
-
fontWeight: "400",
|
|
148
|
-
boldFontWeight: "600",
|
|
149
|
-
iconSize: "20px"
|
|
150
|
-
},
|
|
151
|
-
p1: {
|
|
152
|
-
fontSize: "18px",
|
|
153
|
-
lineHeight: "28px",
|
|
154
|
-
letterSpacing: "0",
|
|
155
|
-
fontWeight: "400",
|
|
156
|
-
boldFontWeight: "600",
|
|
157
|
-
iconSize: "22px"
|
|
158
|
-
},
|
|
159
|
-
p2: {
|
|
160
|
-
fontSize: "16px",
|
|
161
|
-
lineHeight: "24px",
|
|
162
|
-
letterSpacing: "0",
|
|
163
|
-
fontWeight: "400",
|
|
164
|
-
boldFontWeight: "600",
|
|
165
|
-
iconSize: "20px"
|
|
166
|
-
},
|
|
167
|
-
p3: {
|
|
168
|
-
fontSize: "14px",
|
|
169
|
-
lineHeight: "22px",
|
|
170
|
-
letterSpacing: "0",
|
|
171
|
-
fontWeight: "400",
|
|
172
|
-
boldFontWeight: "600",
|
|
173
|
-
iconSize: "18px"
|
|
174
|
-
},
|
|
175
|
-
p4: {
|
|
176
|
-
fontSize: "12px",
|
|
177
|
-
lineHeight: "20px",
|
|
178
|
-
letterSpacing: "0",
|
|
179
|
-
fontWeight: "500",
|
|
180
|
-
boldFontWeight: "600",
|
|
181
|
-
iconSize: "16px"
|
|
182
|
-
},
|
|
183
|
-
c1: {
|
|
184
|
-
fontSize: "14px",
|
|
185
|
-
lineHeight: "20px",
|
|
186
|
-
letterSpacing: "0",
|
|
187
|
-
fontWeight: "600",
|
|
188
|
-
boldFontWeight: "700",
|
|
189
|
-
textTransform: "uppercase",
|
|
190
|
-
iconSize: "18px"
|
|
191
|
-
},
|
|
192
|
-
c2: {
|
|
193
|
-
fontSize: "12px",
|
|
194
|
-
lineHeight: "18px",
|
|
195
|
-
letterSpacing: "0.01em",
|
|
196
|
-
fontWeight: "600",
|
|
197
|
-
boldFontWeight: "700",
|
|
198
|
-
textTransform: "uppercase",
|
|
199
|
-
iconSize: "16px"
|
|
200
|
-
},
|
|
201
|
-
tag: {
|
|
202
|
-
fontSize: "12px",
|
|
203
|
-
lineHeight: "18px",
|
|
204
|
-
letterSpacing: "0.01em",
|
|
205
|
-
fontWeight: "600",
|
|
206
|
-
boldFontWeight: "700",
|
|
207
|
-
iconSize: "16px"
|
|
208
|
-
},
|
|
209
|
-
strong: {
|
|
210
|
-
fontSize: "inherit",
|
|
211
|
-
lineHeight: "inherit",
|
|
212
|
-
letterSpacing: "inherit",
|
|
213
|
-
fontFamily: "inherit",
|
|
214
|
-
fontStyle: "inherit",
|
|
215
|
-
fontWeight: "var(--bold-font-weight, var(--default-bold-font-weight, 600))"
|
|
216
|
-
},
|
|
217
|
-
em: {
|
|
218
|
-
fontSize: "inherit",
|
|
219
|
-
lineHeight: "inherit",
|
|
220
|
-
letterSpacing: "inherit",
|
|
221
|
-
fontFamily: "inherit",
|
|
222
|
-
fontStyle: "italic",
|
|
223
|
-
fontWeight: "inherit"
|
|
224
|
-
},
|
|
225
|
-
default: {
|
|
226
|
-
fontSize: "var(--t3-font-size)",
|
|
227
|
-
lineHeight: "var(--t3-line-height)",
|
|
228
|
-
letterSpacing: "var(--t3-letter-spacing)",
|
|
229
|
-
fontWeight: "var(--t3-font-weight)",
|
|
230
|
-
boldFontWeight: "600",
|
|
231
|
-
iconSize: "inherit"
|
|
232
|
-
}
|
|
233
|
-
};
|
|
234
|
-
|
|
235
|
-
//#endregion
|
|
236
|
-
export { TYPOGRAPHY_PRESETS };
|
|
237
|
-
//# sourceMappingURL=typography.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"typography.js","names":[],"sources":["../../src/tokens/typography.ts"],"sourcesContent":["/**\n * Typography preset configuration.\n * Each preset defines font properties that get expanded into CSS custom properties.\n */\nexport interface TypographyPreset {\n fontSize: string;\n lineHeight: string;\n letterSpacing?: string;\n fontWeight: string | number;\n boldFontWeight?: string | number;\n iconSize?: string;\n textTransform?: string;\n fontFamily?: string;\n fontStyle?: string;\n}\n\n/**\n * Typography presets for headings, text, and special styles.\n *\n * Naming conventions:\n * - `h1`-`h6`: Headings (bold by default)\n * - `t1`-`t4`: Text styles (regular weight)\n * - `t1m`-`t4m`: Text styles medium weight\n * - `m1`-`m3`: Markdown/prose styles (larger line-height)\n * - `p1`-`p4`: Paragraph styles\n * - `c1`-`c2`: Caption/uppercase styles\n * - `tag`: Tag/badge typography\n * - `strong`, `em`: Inline semantic styles\n * - `default`: Base text style\n */\nexport const TYPOGRAPHY_PRESETS: Record<string, TypographyPreset> = {\n // Text (basic)\n text: {\n fontSize: '14px',\n lineHeight: '20px',\n letterSpacing: '0',\n fontWeight: '400',\n },\n\n // Headings (h1-h6)\n h1: {\n fontSize: '36px',\n lineHeight: '44px',\n letterSpacing: '-0.01em',\n fontWeight: '600',\n boldFontWeight: '700',\n iconSize: '40px',\n },\n h2: {\n fontSize: '24px',\n lineHeight: '32px',\n letterSpacing: '0em',\n fontWeight: '600',\n boldFontWeight: '700',\n iconSize: '28px',\n },\n h3: {\n fontSize: '20px',\n lineHeight: '28px',\n letterSpacing: '0em',\n fontWeight: '600',\n boldFontWeight: '700',\n iconSize: '24px',\n },\n h4: {\n fontSize: '18px',\n lineHeight: '24px',\n letterSpacing: '0',\n fontWeight: '600',\n boldFontWeight: '700',\n iconSize: '22px',\n },\n h5: {\n fontSize: '16px',\n lineHeight: '22px',\n letterSpacing: '0',\n fontWeight: '600',\n boldFontWeight: '700',\n iconSize: '20px',\n },\n h6: {\n fontSize: '14px',\n lineHeight: '20px',\n letterSpacing: '0.01em',\n fontWeight: '600',\n boldFontWeight: '700',\n iconSize: '20px',\n },\n\n // Text styles (t1-t4)\n t1: {\n fontSize: '18px',\n lineHeight: '24px',\n letterSpacing: '0',\n fontWeight: '400',\n boldFontWeight: '600',\n iconSize: '20px',\n },\n t2: {\n fontSize: '16px',\n lineHeight: '22px',\n letterSpacing: '0',\n fontWeight: '400',\n boldFontWeight: '600',\n iconSize: '20px',\n },\n t2m: {\n fontSize: '16px',\n lineHeight: '22px',\n letterSpacing: '0',\n fontWeight: '500',\n boldFontWeight: '600',\n iconSize: '20px',\n },\n t3: {\n fontSize: '14px',\n lineHeight: '20px',\n letterSpacing: '0',\n fontWeight: '400',\n boldFontWeight: '600',\n iconSize: '18px',\n },\n t3m: {\n fontSize: '14px',\n lineHeight: '20px',\n letterSpacing: '0',\n fontWeight: '500',\n boldFontWeight: '600',\n iconSize: '18px',\n },\n t4: {\n fontSize: '12px',\n lineHeight: '18px',\n letterSpacing: '0',\n fontWeight: '500',\n boldFontWeight: '600',\n iconSize: '16px',\n },\n t4m: {\n fontSize: '12px',\n lineHeight: '18px',\n letterSpacing: '0',\n fontWeight: '600',\n boldFontWeight: '700',\n iconSize: '16px',\n },\n\n // Markdown/prose styles (m1-m3)\n m1: {\n fontSize: '18px',\n lineHeight: '32px',\n letterSpacing: '0',\n fontWeight: '400',\n boldFontWeight: '600',\n iconSize: '22px',\n },\n m2: {\n fontSize: '16px',\n lineHeight: '28px',\n letterSpacing: '0',\n fontWeight: '400',\n boldFontWeight: '600',\n iconSize: '20px',\n },\n m3: {\n fontSize: '14px',\n lineHeight: '24px',\n letterSpacing: '0',\n fontWeight: '400',\n boldFontWeight: '600',\n iconSize: '20px',\n },\n\n // Paragraph styles (p1-p4)\n p1: {\n fontSize: '18px',\n lineHeight: '28px',\n letterSpacing: '0',\n fontWeight: '400',\n boldFontWeight: '600',\n iconSize: '22px',\n },\n p2: {\n fontSize: '16px',\n lineHeight: '24px',\n letterSpacing: '0',\n fontWeight: '400',\n boldFontWeight: '600',\n iconSize: '20px',\n },\n p3: {\n fontSize: '14px',\n lineHeight: '22px',\n letterSpacing: '0',\n fontWeight: '400',\n boldFontWeight: '600',\n iconSize: '18px',\n },\n p4: {\n fontSize: '12px',\n lineHeight: '20px',\n letterSpacing: '0',\n fontWeight: '500',\n boldFontWeight: '600',\n iconSize: '16px',\n },\n\n // Caption/uppercase styles (c1-c2)\n c1: {\n fontSize: '14px',\n lineHeight: '20px',\n letterSpacing: '0',\n fontWeight: '600',\n boldFontWeight: '700',\n textTransform: 'uppercase',\n iconSize: '18px',\n },\n c2: {\n fontSize: '12px',\n lineHeight: '18px',\n letterSpacing: '0.01em',\n fontWeight: '600',\n boldFontWeight: '700',\n textTransform: 'uppercase',\n iconSize: '16px',\n },\n\n // Tag typography\n tag: {\n fontSize: '12px',\n lineHeight: '18px',\n letterSpacing: '0.01em',\n fontWeight: '600',\n boldFontWeight: '700',\n iconSize: '16px',\n },\n\n // Inline semantic styles\n strong: {\n fontSize: 'inherit',\n lineHeight: 'inherit',\n letterSpacing: 'inherit',\n fontFamily: 'inherit',\n fontStyle: 'inherit',\n fontWeight: 'var(--bold-font-weight, var(--default-bold-font-weight, 600))',\n },\n em: {\n fontSize: 'inherit',\n lineHeight: 'inherit',\n letterSpacing: 'inherit',\n fontFamily: 'inherit',\n fontStyle: 'italic',\n fontWeight: 'inherit',\n },\n\n // Default text style (references t3)\n default: {\n fontSize: 'var(--t3-font-size)',\n lineHeight: 'var(--t3-line-height)',\n letterSpacing: 'var(--t3-letter-spacing)',\n fontWeight: 'var(--t3-font-weight)',\n boldFontWeight: '600',\n iconSize: 'inherit',\n },\n};\n"],"mappings":"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"}
|
package/dist/utils/hsl-to-rgb.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { hslToRgbValues } from "./process-tokens.js";
|
|
2
|
-
|
|
3
|
-
//#region src/utils/hsl-to-rgb.ts
|
|
4
|
-
/**
|
|
5
|
-
* Convert HSL color string to RGB.
|
|
6
|
-
* Supports:
|
|
7
|
-
* - Modern: hsl(h s% l%), hsl(h s% l% / a)
|
|
8
|
-
* - Legacy: hsl(h, s%, l%), hsla(h, s%, l%, a)
|
|
9
|
-
*/
|
|
10
|
-
function hslToRgb(hslStr) {
|
|
11
|
-
const match = hslStr.match(/hsla?\(([^)]+)\)/i);
|
|
12
|
-
if (!match) return null;
|
|
13
|
-
const [colorPart, slashAlpha] = match[1].trim().split("/");
|
|
14
|
-
const parts = colorPart.trim().split(/[,\s]+/).filter(Boolean);
|
|
15
|
-
if (parts.length < 3) return null;
|
|
16
|
-
const alphaPart = slashAlpha?.trim() || (parts.length >= 4 ? parts[3] : null);
|
|
17
|
-
let h = parseFloat(parts[0]);
|
|
18
|
-
const hueStr = parts[0].toLowerCase();
|
|
19
|
-
if (hueStr.endsWith("turn")) h = parseFloat(hueStr) * 360;
|
|
20
|
-
else if (hueStr.endsWith("rad")) h = parseFloat(hueStr) * 180 / Math.PI;
|
|
21
|
-
h = (h % 360 + 360) % 360;
|
|
22
|
-
const parsePercent = (val) => {
|
|
23
|
-
const num = parseFloat(val);
|
|
24
|
-
return val.includes("%") ? num / 100 : num;
|
|
25
|
-
};
|
|
26
|
-
const s = Math.max(0, Math.min(1, parsePercent(parts[1])));
|
|
27
|
-
const l = Math.max(0, Math.min(1, parsePercent(parts[2])));
|
|
28
|
-
const [r, g, b] = hslToRgbValues(h, s, l);
|
|
29
|
-
if (alphaPart) {
|
|
30
|
-
const alpha = parseFloat(alphaPart.trim());
|
|
31
|
-
return `rgba(${Math.round(r)}, ${Math.round(g)}, ${Math.round(b)}, ${alpha})`;
|
|
32
|
-
}
|
|
33
|
-
return `rgb(${Math.round(r)} ${Math.round(g)} ${Math.round(b)})`;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
//#endregion
|
|
37
|
-
export { hslToRgb };
|
|
38
|
-
//# sourceMappingURL=hsl-to-rgb.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hsl-to-rgb.js","names":[],"sources":["../../src/utils/hsl-to-rgb.ts"],"sourcesContent":["import { hslToRgbValues } from './process-tokens';\n\n/**\n * Convert HSL color string to RGB.\n * Supports:\n * - Modern: hsl(h s% l%), hsl(h s% l% / a)\n * - Legacy: hsl(h, s%, l%), hsla(h, s%, l%, a)\n */\nexport function hslToRgb(hslStr: string): string | null {\n const match = hslStr.match(/hsla?\\(([^)]+)\\)/i);\n if (!match) return null;\n\n const inner = match[1].trim();\n const [colorPart, slashAlpha] = inner.split('/');\n const parts = colorPart\n .trim()\n .split(/[,\\s]+/)\n .filter(Boolean);\n\n if (parts.length < 3) return null;\n\n // Alpha can come from slash notation (modern) or 4th part (legacy comma syntax)\n const alphaPart = slashAlpha?.trim() || (parts.length >= 4 ? parts[3] : null);\n\n // Parse hue\n let h = parseFloat(parts[0]);\n const hueStr = parts[0].toLowerCase();\n if (hueStr.endsWith('turn')) h = parseFloat(hueStr) * 360;\n else if (hueStr.endsWith('rad')) h = (parseFloat(hueStr) * 180) / Math.PI;\n h = ((h % 360) + 360) % 360;\n\n // Parse saturation and lightness\n const parsePercent = (val: string): number => {\n const num = parseFloat(val);\n return val.includes('%') ? num / 100 : num;\n };\n const s = Math.max(0, Math.min(1, parsePercent(parts[1])));\n const l = Math.max(0, Math.min(1, parsePercent(parts[2])));\n\n // Use shared HSL to RGB conversion\n const [r, g, b] = hslToRgbValues(h, s, l);\n\n if (alphaPart) {\n const alpha = parseFloat(alphaPart.trim());\n return `rgba(${Math.round(r)}, ${Math.round(g)}, ${Math.round(b)}, ${alpha})`;\n }\n\n return `rgb(${Math.round(r)} ${Math.round(g)} ${Math.round(b)})`;\n}\n"],"mappings":";;;;;;;;;AAQA,SAAgB,SAAS,QAA+B;CACtD,MAAM,QAAQ,OAAO,MAAM,oBAAoB;AAC/C,KAAI,CAAC,MAAO,QAAO;CAGnB,MAAM,CAAC,WAAW,cADJ,MAAM,GAAG,MAAM,CACS,MAAM,IAAI;CAChD,MAAM,QAAQ,UACX,MAAM,CACN,MAAM,SAAS,CACf,OAAO,QAAQ;AAElB,KAAI,MAAM,SAAS,EAAG,QAAO;CAG7B,MAAM,YAAY,YAAY,MAAM,KAAK,MAAM,UAAU,IAAI,MAAM,KAAK;CAGxE,IAAI,IAAI,WAAW,MAAM,GAAG;CAC5B,MAAM,SAAS,MAAM,GAAG,aAAa;AACrC,KAAI,OAAO,SAAS,OAAO,CAAE,KAAI,WAAW,OAAO,GAAG;UAC7C,OAAO,SAAS,MAAM,CAAE,KAAK,WAAW,OAAO,GAAG,MAAO,KAAK;AACvE,MAAM,IAAI,MAAO,OAAO;CAGxB,MAAM,gBAAgB,QAAwB;EAC5C,MAAM,MAAM,WAAW,IAAI;AAC3B,SAAO,IAAI,SAAS,IAAI,GAAG,MAAM,MAAM;;CAEzC,MAAM,IAAI,KAAK,IAAI,GAAG,KAAK,IAAI,GAAG,aAAa,MAAM,GAAG,CAAC,CAAC;CAC1D,MAAM,IAAI,KAAK,IAAI,GAAG,KAAK,IAAI,GAAG,aAAa,MAAM,GAAG,CAAC,CAAC;CAG1D,MAAM,CAAC,GAAG,GAAG,KAAK,eAAe,GAAG,GAAG,EAAE;AAEzC,KAAI,WAAW;EACb,MAAM,QAAQ,WAAW,UAAU,MAAM,CAAC;AAC1C,SAAO,QAAQ,KAAK,MAAM,EAAE,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC,IAAI,MAAM;;AAG7E,QAAO,OAAO,KAAK,MAAM,EAAE,CAAC,GAAG,KAAK,MAAM,EAAE,CAAC,GAAG,KAAK,MAAM,EAAE,CAAC"}
|
|
@@ -1,296 +0,0 @@
|
|
|
1
|
-
//#region src/utils/okhsl-to-rgb.ts
|
|
2
|
-
const OKLab_to_LMS_M = [
|
|
3
|
-
[
|
|
4
|
-
1,
|
|
5
|
-
.3963377773761749,
|
|
6
|
-
.2158037573099136
|
|
7
|
-
],
|
|
8
|
-
[
|
|
9
|
-
1,
|
|
10
|
-
-.1055613458156586,
|
|
11
|
-
-.0638541728258133
|
|
12
|
-
],
|
|
13
|
-
[
|
|
14
|
-
1,
|
|
15
|
-
-.0894841775298119,
|
|
16
|
-
-1.2914855480194092
|
|
17
|
-
]
|
|
18
|
-
];
|
|
19
|
-
const LMS_to_linear_sRGB_M = [
|
|
20
|
-
[
|
|
21
|
-
4.076741636075959,
|
|
22
|
-
-3.307711539258062,
|
|
23
|
-
.2309699031821041
|
|
24
|
-
],
|
|
25
|
-
[
|
|
26
|
-
-1.2684379732850313,
|
|
27
|
-
2.6097573492876878,
|
|
28
|
-
-.3413193760026569
|
|
29
|
-
],
|
|
30
|
-
[
|
|
31
|
-
-.004196076138675526,
|
|
32
|
-
-.703418617935936,
|
|
33
|
-
1.7076146940746113
|
|
34
|
-
]
|
|
35
|
-
];
|
|
36
|
-
const OKLab_to_linear_sRGB_coefficients = [
|
|
37
|
-
[[-1.8817030993265873, -.8093650129914302], [
|
|
38
|
-
1.19086277,
|
|
39
|
-
1.76576728,
|
|
40
|
-
.59662641,
|
|
41
|
-
.75515197,
|
|
42
|
-
.56771245
|
|
43
|
-
]],
|
|
44
|
-
[[1.8144407988010998, -1.194452667805235], [
|
|
45
|
-
.73956515,
|
|
46
|
-
-.45954404,
|
|
47
|
-
.08285427,
|
|
48
|
-
.12541073,
|
|
49
|
-
-.14503204
|
|
50
|
-
]],
|
|
51
|
-
[[.13110757611180954, 1.813339709266608], [
|
|
52
|
-
1.35733652,
|
|
53
|
-
-.00915799,
|
|
54
|
-
-1.1513021,
|
|
55
|
-
-.50559606,
|
|
56
|
-
.00692167
|
|
57
|
-
]]
|
|
58
|
-
];
|
|
59
|
-
const TAU = 2 * Math.PI;
|
|
60
|
-
const K1 = .206;
|
|
61
|
-
const K2 = .03;
|
|
62
|
-
const K3 = (1 + K1) / (1 + K2);
|
|
63
|
-
const constrainAngle = (angle) => (angle % 360 + 360) % 360;
|
|
64
|
-
const toeInv = (x) => (x ** 2 + K1 * x) / (K3 * (x + K2));
|
|
65
|
-
const dot3 = (a, b) => a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
|
|
66
|
-
const dotXY = (a, b) => a[0] * b[0] + a[1] * b[1];
|
|
67
|
-
const transform = (input, matrix) => [
|
|
68
|
-
dot3(input, matrix[0]),
|
|
69
|
-
dot3(input, matrix[1]),
|
|
70
|
-
dot3(input, matrix[2])
|
|
71
|
-
];
|
|
72
|
-
const cubed3 = (lms) => [
|
|
73
|
-
lms[0] ** 3,
|
|
74
|
-
lms[1] ** 3,
|
|
75
|
-
lms[2] ** 3
|
|
76
|
-
];
|
|
77
|
-
const OKLabToLinearSRGB = (lab) => {
|
|
78
|
-
return transform(cubed3(transform(lab, OKLab_to_LMS_M)), LMS_to_linear_sRGB_M);
|
|
79
|
-
};
|
|
80
|
-
const sRGBLinearToGamma = (val) => {
|
|
81
|
-
const sign = val < 0 ? -1 : 1;
|
|
82
|
-
const abs = Math.abs(val);
|
|
83
|
-
return abs > .0031308 ? sign * (1.055 * Math.pow(abs, 1 / 2.4) - .055) : 12.92 * val;
|
|
84
|
-
};
|
|
85
|
-
const computeMaxSaturationOKLC = (a, b) => {
|
|
86
|
-
const okCoeff = OKLab_to_linear_sRGB_coefficients;
|
|
87
|
-
const lmsToRgb = LMS_to_linear_sRGB_M;
|
|
88
|
-
const tmp2 = [a, b];
|
|
89
|
-
const tmp3 = [
|
|
90
|
-
0,
|
|
91
|
-
a,
|
|
92
|
-
b
|
|
93
|
-
];
|
|
94
|
-
let chnlCoeff;
|
|
95
|
-
let chnlLMS;
|
|
96
|
-
if (dotXY(okCoeff[0][0], tmp2) > 1) {
|
|
97
|
-
chnlCoeff = okCoeff[0][1];
|
|
98
|
-
chnlLMS = lmsToRgb[0];
|
|
99
|
-
} else if (dotXY(okCoeff[1][0], tmp2) > 1) {
|
|
100
|
-
chnlCoeff = okCoeff[1][1];
|
|
101
|
-
chnlLMS = lmsToRgb[1];
|
|
102
|
-
} else {
|
|
103
|
-
chnlCoeff = okCoeff[2][1];
|
|
104
|
-
chnlLMS = lmsToRgb[2];
|
|
105
|
-
}
|
|
106
|
-
const [k0, k1, k2, k3, k4] = chnlCoeff;
|
|
107
|
-
const [wl, wm, ws] = chnlLMS;
|
|
108
|
-
let sat = k0 + k1 * a + k2 * b + k3 * (a * a) + k4 * a * b;
|
|
109
|
-
const dotYZ = (mat, vec) => mat[1] * vec[1] + mat[2] * vec[2];
|
|
110
|
-
const kl = dotYZ(OKLab_to_LMS_M[0], tmp3);
|
|
111
|
-
const km = dotYZ(OKLab_to_LMS_M[1], tmp3);
|
|
112
|
-
const ks = dotYZ(OKLab_to_LMS_M[2], tmp3);
|
|
113
|
-
const l_ = 1 + sat * kl;
|
|
114
|
-
const m_ = 1 + sat * km;
|
|
115
|
-
const s_ = 1 + sat * ks;
|
|
116
|
-
const l = l_ ** 3;
|
|
117
|
-
const m = m_ ** 3;
|
|
118
|
-
const s = s_ ** 3;
|
|
119
|
-
const lds = 3 * kl * l_ * l_;
|
|
120
|
-
const mds = 3 * km * m_ * m_;
|
|
121
|
-
const sds = 3 * ks * s_ * s_;
|
|
122
|
-
const lds2 = 6 * kl * kl * l_;
|
|
123
|
-
const mds2 = 6 * km * km * m_;
|
|
124
|
-
const sds2 = 6 * ks * ks * s_;
|
|
125
|
-
const f = wl * l + wm * m + ws * s;
|
|
126
|
-
const f1 = wl * lds + wm * mds + ws * sds;
|
|
127
|
-
const f2 = wl * lds2 + wm * mds2 + ws * sds2;
|
|
128
|
-
sat = sat - f * f1 / (f1 * f1 - .5 * f * f2);
|
|
129
|
-
return sat;
|
|
130
|
-
};
|
|
131
|
-
const findCuspOKLCH = (a, b) => {
|
|
132
|
-
const S_cusp = computeMaxSaturationOKLC(a, b);
|
|
133
|
-
const rgb_at_max = OKLabToLinearSRGB([
|
|
134
|
-
1,
|
|
135
|
-
S_cusp * a,
|
|
136
|
-
S_cusp * b
|
|
137
|
-
]);
|
|
138
|
-
const L_cusp = Math.cbrt(1 / Math.max(Math.max(rgb_at_max[0], rgb_at_max[1]), Math.max(rgb_at_max[2], 0)));
|
|
139
|
-
return [L_cusp, L_cusp * S_cusp];
|
|
140
|
-
};
|
|
141
|
-
const findGamutIntersectionOKLCH = (a, b, l1, c1, l0, cusp) => {
|
|
142
|
-
const lmsToRgb = LMS_to_linear_sRGB_M;
|
|
143
|
-
const tmp3 = [
|
|
144
|
-
0,
|
|
145
|
-
a,
|
|
146
|
-
b
|
|
147
|
-
];
|
|
148
|
-
const floatMax = Number.MAX_VALUE;
|
|
149
|
-
let t;
|
|
150
|
-
const dotYZ = (mat, vec) => mat[1] * vec[1] + mat[2] * vec[2];
|
|
151
|
-
const dotXYZ = (vec, x, y, z) => vec[0] * x + vec[1] * y + vec[2] * z;
|
|
152
|
-
if ((l1 - l0) * cusp[1] - (cusp[0] - l0) * c1 <= 0) {
|
|
153
|
-
const denom = c1 * cusp[0] + cusp[1] * (l0 - l1);
|
|
154
|
-
t = denom === 0 ? 0 : cusp[1] * l0 / denom;
|
|
155
|
-
} else {
|
|
156
|
-
const denom = c1 * (cusp[0] - 1) + cusp[1] * (l0 - l1);
|
|
157
|
-
t = denom === 0 ? 0 : cusp[1] * (l0 - 1) / denom;
|
|
158
|
-
const dl = l1 - l0;
|
|
159
|
-
const dc = c1;
|
|
160
|
-
const kl = dotYZ(OKLab_to_LMS_M[0], tmp3);
|
|
161
|
-
const km = dotYZ(OKLab_to_LMS_M[1], tmp3);
|
|
162
|
-
const ks = dotYZ(OKLab_to_LMS_M[2], tmp3);
|
|
163
|
-
const L = l0 * (1 - t) + t * l1;
|
|
164
|
-
const C = t * c1;
|
|
165
|
-
const l_ = L + C * kl;
|
|
166
|
-
const m_ = L + C * km;
|
|
167
|
-
const s_ = L + C * ks;
|
|
168
|
-
const l = l_ ** 3;
|
|
169
|
-
const m = m_ ** 3;
|
|
170
|
-
const s = s_ ** 3;
|
|
171
|
-
const ldt = 3 * (dl + dc * kl) * l_ * l_;
|
|
172
|
-
const mdt = 3 * (dl + dc * km) * m_ * m_;
|
|
173
|
-
const sdt = 3 * (dl + dc * ks) * s_ * s_;
|
|
174
|
-
const ldt2 = 6 * (dl + dc * kl) ** 2 * l_;
|
|
175
|
-
const mdt2 = 6 * (dl + dc * km) ** 2 * m_;
|
|
176
|
-
const sdt2 = 6 * (dl + dc * ks) ** 2 * s_;
|
|
177
|
-
const r_ = dotXYZ(lmsToRgb[0], l, m, s) - 1;
|
|
178
|
-
const r1 = dotXYZ(lmsToRgb[0], ldt, mdt, sdt);
|
|
179
|
-
const r2 = dotXYZ(lmsToRgb[0], ldt2, mdt2, sdt2);
|
|
180
|
-
const ur = r1 / (r1 * r1 - .5 * r_ * r2);
|
|
181
|
-
let tr = -r_ * ur;
|
|
182
|
-
const g_ = dotXYZ(lmsToRgb[1], l, m, s) - 1;
|
|
183
|
-
const g1 = dotXYZ(lmsToRgb[1], ldt, mdt, sdt);
|
|
184
|
-
const g2 = dotXYZ(lmsToRgb[1], ldt2, mdt2, sdt2);
|
|
185
|
-
const ug = g1 / (g1 * g1 - .5 * g_ * g2);
|
|
186
|
-
let tg = -g_ * ug;
|
|
187
|
-
const b_ = dotXYZ(lmsToRgb[2], l, m, s) - 1;
|
|
188
|
-
const b1 = dotXYZ(lmsToRgb[2], ldt, mdt, sdt);
|
|
189
|
-
const b2 = dotXYZ(lmsToRgb[2], ldt2, mdt2, sdt2);
|
|
190
|
-
const ub = b1 / (b1 * b1 - .5 * b_ * b2);
|
|
191
|
-
let tb = -b_ * ub;
|
|
192
|
-
tr = ur >= 0 ? tr : floatMax;
|
|
193
|
-
tg = ug >= 0 ? tg : floatMax;
|
|
194
|
-
tb = ub >= 0 ? tb : floatMax;
|
|
195
|
-
t += Math.min(tr, Math.min(tg, tb));
|
|
196
|
-
}
|
|
197
|
-
return t;
|
|
198
|
-
};
|
|
199
|
-
const computeSt = (cusp) => [cusp[1] / cusp[0], cusp[1] / (1 - cusp[0])];
|
|
200
|
-
const computeStMid = (a, b) => [.11516993 + 1 / (7.4477897 + 4.1590124 * b + a * (-2.19557347 + 1.75198401 * b + a * (-2.13704948 - 10.02301043 * b + a * (-4.24894561 + 5.38770819 * b + 4.69891013 * a)))), .11239642 + 1 / (1.6132032 - .68124379 * b + a * (.40370612 + .90148123 * b + a * (-.27087943 + .6122399 * b + a * (.00299215 - .45399568 * b - .14661872 * a))))];
|
|
201
|
-
const getCs = (L, a, b, cusp) => {
|
|
202
|
-
const cMax = findGamutIntersectionOKLCH(a, b, L, 1, L, cusp);
|
|
203
|
-
const stMax = computeSt(cusp);
|
|
204
|
-
const k = cMax / Math.min(L * stMax[0], (1 - L) * stMax[1]);
|
|
205
|
-
const stMid = computeStMid(a, b);
|
|
206
|
-
let ca = L * stMid[0];
|
|
207
|
-
let cb = (1 - L) * stMid[1];
|
|
208
|
-
const cMid = .9 * k * Math.sqrt(Math.sqrt(1 / (1 / ca ** 4 + 1 / cb ** 4)));
|
|
209
|
-
ca = L * .4;
|
|
210
|
-
cb = (1 - L) * .8;
|
|
211
|
-
return [
|
|
212
|
-
Math.sqrt(1 / (1 / ca ** 2 + 1 / cb ** 2)),
|
|
213
|
-
cMid,
|
|
214
|
-
cMax
|
|
215
|
-
];
|
|
216
|
-
};
|
|
217
|
-
const OKHSLToOKLab = (hsl) => {
|
|
218
|
-
let h = hsl[0];
|
|
219
|
-
const s = hsl[1];
|
|
220
|
-
const l = hsl[2];
|
|
221
|
-
const L = toeInv(l);
|
|
222
|
-
let a = 0;
|
|
223
|
-
let b = 0;
|
|
224
|
-
h = constrainAngle(h) / 360;
|
|
225
|
-
if (L !== 0 && L !== 1 && s !== 0) {
|
|
226
|
-
const a_ = Math.cos(TAU * h);
|
|
227
|
-
const b_ = Math.sin(TAU * h);
|
|
228
|
-
const [c0, cMid, cMax] = getCs(L, a_, b_, findCuspOKLCH(a_, b_));
|
|
229
|
-
const mid = .8;
|
|
230
|
-
const midInv = 1.25;
|
|
231
|
-
let t, k0, k1, k2;
|
|
232
|
-
if (s < mid) {
|
|
233
|
-
t = midInv * s;
|
|
234
|
-
k0 = 0;
|
|
235
|
-
k1 = mid * c0;
|
|
236
|
-
k2 = 1 - k1 / cMid;
|
|
237
|
-
} else {
|
|
238
|
-
t = 5 * (s - .8);
|
|
239
|
-
k0 = cMid;
|
|
240
|
-
k1 = .2 * cMid ** 2 * 1.25 ** 2 / c0;
|
|
241
|
-
k2 = 1 - k1 / (cMax - cMid);
|
|
242
|
-
}
|
|
243
|
-
const c = k0 + t * k1 / (1 - k2 * t);
|
|
244
|
-
a = c * a_;
|
|
245
|
-
b = c * b_;
|
|
246
|
-
}
|
|
247
|
-
return [
|
|
248
|
-
L,
|
|
249
|
-
a,
|
|
250
|
-
b
|
|
251
|
-
];
|
|
252
|
-
};
|
|
253
|
-
function okhslToSrgbInternal(h, s, l) {
|
|
254
|
-
const linearRGB = OKLabToLinearSRGB(OKHSLToOKLab([
|
|
255
|
-
h,
|
|
256
|
-
s,
|
|
257
|
-
l
|
|
258
|
-
]));
|
|
259
|
-
return [
|
|
260
|
-
sRGBLinearToGamma(linearRGB[0]),
|
|
261
|
-
sRGBLinearToGamma(linearRGB[1]),
|
|
262
|
-
sRGBLinearToGamma(linearRGB[2])
|
|
263
|
-
];
|
|
264
|
-
}
|
|
265
|
-
/**
|
|
266
|
-
* Convert OKHSL color string to RGB.
|
|
267
|
-
* Uses the same algorithm as the okhsl-plugin.
|
|
268
|
-
*/
|
|
269
|
-
function okhslToRgb(okhslStr) {
|
|
270
|
-
const match = okhslStr.match(/okhsl\(([^)]+)\)/i);
|
|
271
|
-
if (!match) return null;
|
|
272
|
-
const [colorPart, alphaPart] = match[1].trim().split("/");
|
|
273
|
-
const parts = colorPart.trim().split(/[,\s]+/).filter(Boolean);
|
|
274
|
-
if (parts.length < 3) return null;
|
|
275
|
-
let h = parseFloat(parts[0]);
|
|
276
|
-
const hueStr = parts[0].toLowerCase();
|
|
277
|
-
if (hueStr.endsWith("turn")) h = parseFloat(hueStr) * 360;
|
|
278
|
-
else if (hueStr.endsWith("rad")) h = parseFloat(hueStr) * 180 / Math.PI;
|
|
279
|
-
else if (hueStr.endsWith("deg")) h = parseFloat(hueStr);
|
|
280
|
-
const parsePercent = (val) => {
|
|
281
|
-
const num = parseFloat(val);
|
|
282
|
-
return val.includes("%") ? num / 100 : num;
|
|
283
|
-
};
|
|
284
|
-
const s = Math.max(0, Math.min(1, parsePercent(parts[1])));
|
|
285
|
-
const l = Math.max(0, Math.min(1, parsePercent(parts[2])));
|
|
286
|
-
const [r, g, b] = okhslToSrgbInternal(h, s, l);
|
|
287
|
-
const r255 = Math.round(Math.max(0, Math.min(1, r)) * 255);
|
|
288
|
-
const g255 = Math.round(Math.max(0, Math.min(1, g)) * 255);
|
|
289
|
-
const b255 = Math.round(Math.max(0, Math.min(1, b)) * 255);
|
|
290
|
-
if (alphaPart) return `rgba(${r255}, ${g255}, ${b255}, ${parseFloat(alphaPart.trim())})`;
|
|
291
|
-
return `rgb(${r255} ${g255} ${b255})`;
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
//#endregion
|
|
295
|
-
export { okhslToRgb };
|
|
296
|
-
//# sourceMappingURL=okhsl-to-rgb.js.map
|