rnwind 0.0.7 → 0.0.9
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/lib/cjs/core/parser/color.cjs +33 -1
- package/lib/cjs/core/parser/color.cjs.map +1 -1
- package/lib/cjs/core/parser/color.d.ts +10 -0
- package/lib/cjs/core/parser/declaration.cjs +161 -10
- package/lib/cjs/core/parser/declaration.cjs.map +1 -1
- package/lib/cjs/core/parser/gradient.cjs +46 -12
- package/lib/cjs/core/parser/gradient.cjs.map +1 -1
- package/lib/cjs/core/parser/gradient.d.ts +2 -1
- package/lib/cjs/core/parser/keyframes.cjs +27 -12
- package/lib/cjs/core/parser/keyframes.cjs.map +1 -1
- package/lib/cjs/core/parser/keyframes.d.ts +11 -0
- package/lib/cjs/core/parser/layout-dispatcher.cjs +33 -10
- package/lib/cjs/core/parser/layout-dispatcher.cjs.map +1 -1
- package/lib/cjs/core/parser/length.cjs +17 -1
- package/lib/cjs/core/parser/length.cjs.map +1 -1
- package/lib/cjs/core/parser/safe-area.cjs +24 -3
- package/lib/cjs/core/parser/safe-area.cjs.map +1 -1
- package/lib/cjs/core/parser/theme-vars.cjs +58 -8
- package/lib/cjs/core/parser/theme-vars.cjs.map +1 -1
- package/lib/cjs/core/parser/tokens.cjs +77 -9
- package/lib/cjs/core/parser/tokens.cjs.map +1 -1
- package/lib/cjs/core/parser/tokens.d.ts +9 -0
- package/lib/cjs/core/parser/transform.cjs +18 -9
- package/lib/cjs/core/parser/transform.cjs.map +1 -1
- package/lib/cjs/core/parser/tw-parser.cjs +93 -33
- package/lib/cjs/core/parser/tw-parser.cjs.map +1 -1
- package/lib/cjs/core/parser/typography-dispatcher.cjs +19 -1
- package/lib/cjs/core/parser/typography-dispatcher.cjs.map +1 -1
- package/lib/cjs/core/parser/typography.cjs +15 -18
- package/lib/cjs/core/parser/typography.cjs.map +1 -1
- package/lib/cjs/core/parser/typography.d.ts +5 -5
- package/lib/cjs/core/style-builder/union-builder.cjs +0 -10
- package/lib/cjs/core/style-builder/union-builder.cjs.map +1 -1
- package/lib/cjs/core/style-builder/union-builder.d.ts +0 -8
- package/lib/cjs/metro/dts.cjs +6 -1
- package/lib/cjs/metro/dts.cjs.map +1 -1
- package/lib/cjs/metro/transformer.cjs +43 -60
- package/lib/cjs/metro/transformer.cjs.map +1 -1
- package/lib/cjs/metro/with-config.cjs +9 -29
- package/lib/cjs/metro/with-config.cjs.map +1 -1
- package/lib/cjs/runtime/hooks/use-scheme.cjs +9 -6
- package/lib/cjs/runtime/hooks/use-scheme.cjs.map +1 -1
- package/lib/cjs/runtime/hooks/use-scheme.d.ts +7 -4
- package/lib/cjs/runtime/index.cjs +1 -1
- package/lib/cjs/runtime/index.cjs.map +1 -1
- package/lib/cjs/runtime/index.d.ts +1 -1
- package/lib/cjs/runtime/lookup-css.cjs +14 -0
- package/lib/cjs/runtime/lookup-css.cjs.map +1 -1
- package/lib/cjs/runtime/lookup-css.d.ts +11 -0
- package/lib/cjs/runtime/resolve.cjs +8 -6
- package/lib/cjs/runtime/resolve.cjs.map +1 -1
- package/lib/cjs/runtime/wrap.cjs +50 -57
- package/lib/cjs/runtime/wrap.cjs.map +1 -1
- package/lib/cjs/runtime/wrap.d.ts +10 -4
- package/lib/esm/core/parser/color.d.ts +10 -0
- package/lib/esm/core/parser/color.mjs +33 -2
- package/lib/esm/core/parser/color.mjs.map +1 -1
- package/lib/esm/core/parser/declaration.mjs +162 -11
- package/lib/esm/core/parser/declaration.mjs.map +1 -1
- package/lib/esm/core/parser/gradient.d.ts +2 -1
- package/lib/esm/core/parser/gradient.mjs +45 -11
- package/lib/esm/core/parser/gradient.mjs.map +1 -1
- package/lib/esm/core/parser/keyframes.d.ts +11 -0
- package/lib/esm/core/parser/keyframes.mjs +27 -12
- package/lib/esm/core/parser/keyframes.mjs.map +1 -1
- package/lib/esm/core/parser/layout-dispatcher.mjs +33 -10
- package/lib/esm/core/parser/layout-dispatcher.mjs.map +1 -1
- package/lib/esm/core/parser/length.mjs +17 -1
- package/lib/esm/core/parser/length.mjs.map +1 -1
- package/lib/esm/core/parser/safe-area.mjs +24 -3
- package/lib/esm/core/parser/safe-area.mjs.map +1 -1
- package/lib/esm/core/parser/theme-vars.mjs +58 -8
- package/lib/esm/core/parser/theme-vars.mjs.map +1 -1
- package/lib/esm/core/parser/tokens.d.ts +9 -0
- package/lib/esm/core/parser/tokens.mjs +77 -10
- package/lib/esm/core/parser/tokens.mjs.map +1 -1
- package/lib/esm/core/parser/transform.mjs +18 -9
- package/lib/esm/core/parser/transform.mjs.map +1 -1
- package/lib/esm/core/parser/tw-parser.mjs +95 -35
- package/lib/esm/core/parser/tw-parser.mjs.map +1 -1
- package/lib/esm/core/parser/typography-dispatcher.mjs +19 -1
- package/lib/esm/core/parser/typography-dispatcher.mjs.map +1 -1
- package/lib/esm/core/parser/typography.d.ts +5 -5
- package/lib/esm/core/parser/typography.mjs +15 -18
- package/lib/esm/core/parser/typography.mjs.map +1 -1
- package/lib/esm/core/style-builder/union-builder.d.ts +0 -8
- package/lib/esm/core/style-builder/union-builder.mjs +0 -10
- package/lib/esm/core/style-builder/union-builder.mjs.map +1 -1
- package/lib/esm/metro/dts.mjs +6 -1
- package/lib/esm/metro/dts.mjs.map +1 -1
- package/lib/esm/metro/transformer.mjs +43 -60
- package/lib/esm/metro/transformer.mjs.map +1 -1
- package/lib/esm/metro/with-config.mjs +10 -30
- package/lib/esm/metro/with-config.mjs.map +1 -1
- package/lib/esm/runtime/hooks/use-scheme.d.ts +7 -4
- package/lib/esm/runtime/hooks/use-scheme.mjs +9 -6
- package/lib/esm/runtime/hooks/use-scheme.mjs.map +1 -1
- package/lib/esm/runtime/index.d.ts +1 -1
- package/lib/esm/runtime/index.mjs +1 -1
- package/lib/esm/runtime/index.mjs.map +1 -1
- package/lib/esm/runtime/lookup-css.d.ts +11 -0
- package/lib/esm/runtime/lookup-css.mjs +14 -1
- package/lib/esm/runtime/lookup-css.mjs.map +1 -1
- package/lib/esm/runtime/resolve.mjs +9 -7
- package/lib/esm/runtime/resolve.mjs.map +1 -1
- package/lib/esm/runtime/wrap.d.ts +10 -4
- package/lib/esm/runtime/wrap.mjs +50 -57
- package/lib/esm/runtime/wrap.mjs.map +1 -1
- package/package.json +1 -1
- package/src/core/parser/color.ts +32 -1
- package/src/core/parser/declaration.ts +160 -10
- package/src/core/parser/gradient.ts +48 -11
- package/src/core/parser/keyframes.ts +31 -3
- package/src/core/parser/layout-dispatcher.ts +32 -9
- package/src/core/parser/length.ts +18 -1
- package/src/core/parser/safe-area.ts +23 -2
- package/src/core/parser/theme-vars.ts +75 -8
- package/src/core/parser/tokens.ts +76 -9
- package/src/core/parser/transform.ts +19 -8
- package/src/core/parser/tw-parser.ts +95 -30
- package/src/core/parser/typography-dispatcher.ts +20 -1
- package/src/core/parser/typography.ts +15 -15
- package/src/core/style-builder/union-builder.ts +0 -11
- package/src/metro/dts.ts +6 -1
- package/src/metro/transformer.ts +45 -61
- package/src/metro/with-config.ts +10 -29
- package/src/runtime/hooks/use-scheme.ts +9 -6
- package/src/runtime/index.ts +1 -1
- package/src/runtime/lookup-css.ts +14 -0
- package/src/runtime/resolve.ts +9 -7
- package/src/runtime/wrap.tsx +57 -61
|
@@ -34,7 +34,9 @@ function byteToHex(byte) {
|
|
|
34
34
|
function rgbIntsToString(r, g, b, alpha) {
|
|
35
35
|
if (alpha >= 1)
|
|
36
36
|
return `#${byteToHex(r)}${byteToHex(g)}${byteToHex(b)}`;
|
|
37
|
-
|
|
37
|
+
// Round the alpha to shed f32 noise (`0.2 → 0.20000000298…`) — RN parses
|
|
38
|
+
// either, but the rounded form keeps generated StyleSheets compact.
|
|
39
|
+
return `rgba(${r}, ${g}, ${b}, ${Math.round(alpha * 10_000) / 10_000})`;
|
|
38
40
|
}
|
|
39
41
|
/**
|
|
40
42
|
* Format a float-RGB triple + alpha (CSS `color(srgb …)` forms) as
|
|
@@ -132,6 +134,35 @@ function xyzToHex(color) {
|
|
|
132
134
|
const mode = color.type === 'xyz-d50' ? 'xyz50' : 'xyz65';
|
|
133
135
|
return withAlpha(culori.formatHex({ mode, x: color.x, y: color.y, z: color.z }) ?? null, color.alpha);
|
|
134
136
|
}
|
|
137
|
+
/**
|
|
138
|
+
* Modern CSS color functions RN's native view manager can't paint —
|
|
139
|
+
* everything else (hex, `rgb()`/`rgba()`, `hsl()`/`hsla()`, named colors,
|
|
140
|
+
* `transparent`, `currentColor`) RN reads directly and must pass through
|
|
141
|
+
* untouched. Custom `@theme` tokens reach the parser as `var(--color-x)`
|
|
142
|
+
* (only the default palette is `theme(inline)`-d), so they flow through the
|
|
143
|
+
* unparsed-string path where the typed {@link cssColorToString} never runs —
|
|
144
|
+
* this is the one place that lowers their wide-gamut values to sRGB.
|
|
145
|
+
*/
|
|
146
|
+
const RN_UNREADABLE_COLOR_PREFIXES = ['oklch(', 'oklab(', 'lab(', 'lch(', 'color(', 'hwb('];
|
|
147
|
+
/**
|
|
148
|
+
* Lower a wide-gamut / modern CSS color STRING (`oklch(…)`, `lab(…)`,
|
|
149
|
+
* `color(display-p3 …)`, …) to an sRGB hex/rgba string RN can paint. Returns
|
|
150
|
+
* `null` for anything RN already understands (hex, rgb, hsl, named) so the
|
|
151
|
+
* caller keeps the original text — only the unrepresentable forms convert.
|
|
152
|
+
* Mirrors {@link cssColorToString}'s culori lowering for the string path.
|
|
153
|
+
* @param text Resolved CSS color text (post theme-var substitution).
|
|
154
|
+
* @returns sRGB color string, or `null` when no conversion is needed/possible.
|
|
155
|
+
*/
|
|
156
|
+
function normalizeColorString(text) {
|
|
157
|
+
const lower = text.trim().toLowerCase();
|
|
158
|
+
if (!RN_UNREADABLE_COLOR_PREFIXES.some((prefix) => lower.startsWith(prefix)))
|
|
159
|
+
return null;
|
|
160
|
+
const parsed = culori.rgb(text);
|
|
161
|
+
if (!parsed || ![parsed.r, parsed.g, parsed.b].every((v) => typeof v === 'number' && Number.isFinite(v)))
|
|
162
|
+
return null;
|
|
163
|
+
const alpha = typeof parsed.alpha === 'number' ? parsed.alpha : 1;
|
|
164
|
+
return rgbIntsToString(clampByte(parsed.r * 255), clampByte(parsed.g * 255), clampByte(parsed.b * 255), alpha);
|
|
165
|
+
}
|
|
135
166
|
/**
|
|
136
167
|
* Convert a lightningcss `CssColor` to an RN-safe color string. RGB
|
|
137
168
|
* passes through unchanged. LAB / LCH / OKLAB / OKLCH / `color(xyz-…)`
|
|
@@ -190,4 +221,5 @@ function cssColorToString(color) {
|
|
|
190
221
|
}
|
|
191
222
|
|
|
192
223
|
exports.cssColorToString = cssColorToString;
|
|
224
|
+
exports.normalizeColorString = normalizeColorString;
|
|
193
225
|
//# sourceMappingURL=color.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"color.cjs","sources":["../../../../../src/core/parser/color.ts"],"sourcesContent":["import type { CssColor, LABColor } from 'lightningcss'\nimport { formatHex, rgb as culoriRgb } from 'culori'\n\n/**\n * Clamp a 0-255 float to the integer byte range RN color strings accept.\n * @param value Unclamped float (may be negative or above 255).\n * @returns Integer in `[0, 255]`.\n */\nfunction clampByte(value: number): number {\n if (value < 0) return 0\n if (value > 255) return 255\n return Math.round(value)\n}\n\n/**\n * Two-digit hex encoding of a 0-255 byte.\n * @param byte Byte value (may be out-of-range — clamped).\n * @returns Zero-padded two-char hex string.\n */\nfunction byteToHex(byte: number): string {\n const hex = clampByte(byte).toString(16)\n return hex.length === 1 ? `0${hex}` : hex\n}\n\n/**\n * Format an integer-RGB triple + alpha as `#rrggbb` or `rgba(r, g, b, a)`.\n * @param r 0-255 red.\n * @param g 0-255 green.\n * @param b 0-255 blue.\n * @param alpha 0-1 alpha.\n * @returns Color string.\n */\nfunction rgbIntsToString(r: number, g: number, b: number, alpha: number): string {\n if (alpha >= 1) return `#${byteToHex(r)}${byteToHex(g)}${byteToHex(b)}`\n return `rgba(${r}, ${g}, ${b}, ${alpha})`\n}\n\n/**\n * Format a float-RGB triple + alpha (CSS `color(srgb …)` forms) as\n * hex/rgba.\n * @param r 0-1 red.\n * @param g 0-1 green.\n * @param b 0-1 blue.\n * @param alpha 0-1 alpha.\n * @returns Color string.\n */\nfunction floatRgbToString(r: number, g: number, b: number, alpha: number): string {\n return rgbIntsToString(clampByte(r * 255), clampByte(g * 255), clampByte(b * 255), alpha)\n}\n\n/**\n * Dispatch a LAB-family color through culori's hex formatter.\n * @param color Typed LAB-family color.\n * @returns `#rrggbb` string, or `null` when culori couldn't convert.\n */\nfunction culoriHexFor(color: LABColor): string | null {\n switch (color.type) {\n case 'oklch': {\n return formatHex({ mode: 'oklch', l: color.l, c: color.c, h: color.h }) ?? null\n }\n case 'oklab': {\n return formatHex({ mode: 'oklab', l: color.l, a: color.a, b: color.b }) ?? null\n }\n case 'lab': {\n return formatHex({ mode: 'lab', l: color.l, a: color.a, b: color.b }) ?? null\n }\n case 'lch': {\n return formatHex({ mode: 'lch', l: color.l, c: color.c, h: color.h }) ?? null\n }\n default: {\n return null\n }\n }\n}\n\n/**\n * Composite a culori-produced sRGB hex with the source alpha into the RN\n * color string. Shared tail for every culori-backed conversion (lab\n * family, XYZ, wide-gamut RGB): opaque → the hex as-is; translucent →\n * `rgba(...)` rebuilt from the hex channels.\n * @param hex sRGB hex from culori, or `null` when culori rejected the color.\n * @param alpha Source alpha (0–1).\n * @returns RN color string.\n */\nfunction withAlpha(hex: string | null, alpha: number): string {\n if (!hex) return alpha < 1 ? 'rgba(0, 0, 0, 0)' : 'transparent'\n if (alpha >= 1) return hex\n const back = culoriRgb(hex)\n if (!back) return hex\n return rgbIntsToString(clampByte(back.r * 255), clampByte(back.g * 255), clampByte(back.b * 255), alpha)\n}\n\n/**\n * Convert a LAB / LCH / OKLAB / OKLCH color to sRGB hex via culori. RN\n * can't evaluate these modern color spaces at paint time; compile-time\n * lowering to sRGB is the only portable path.\n * @param color Typed lab-family color.\n * @returns Hex or rgba string in sRGB.\n */\nfunction labFamilyToHex(color: LABColor): string {\n return withAlpha(culoriHexFor(color), color.alpha)\n}\n\n/**\n * Convert a wide-gamut `color(<space> r g b)` triple to sRGB hex via\n * culori. The channels are NOT sRGB — each space (display-p3, rec2020,\n * a98-rgb, prophoto-rgb, srgb-linear) carries its own primaries / transfer\n * function, so a bare `channel * 255` would mis-paint. culori does the\n * gamut + gamma conversion to sRGB.\n * @param mode culori mode key for the source space.\n * @param r Source red (0–1).\n * @param g Source green (0–1).\n * @param b Source blue (0–1).\n * @param alpha Alpha channel (0–1).\n * @returns sRGB color string RN accepts.\n */\nfunction wideGamutToHex(mode: 'lrgb' | 'p3' | 'a98' | 'prophoto' | 'rec2020', r: number, g: number, b: number, alpha: number): string {\n return withAlpha(formatHex({ mode, r, g, b }) ?? null, alpha)\n}\n\n/**\n * Convert a CSS `color(xyz-d50 …)` / `color(xyz-d65 …)` value to sRGB hex\n * via culori.\n * @param color Typed XYZ color (discriminated by `type`).\n * @param color.type Whether the color is in the D50 or D65 XYZ space.\n * @param color.x CIE X component (0–1).\n * @param color.y CIE Y component (0–1).\n * @param color.z CIE Z component (0–1).\n * @param color.alpha Alpha channel (0–1).\n * @returns `#rrggbb` string, or `'transparent'` when culori rejects it.\n */\nfunction xyzToHex(color: { type: 'xyz-d50' | 'xyz-d65'; x: number; y: number; z: number; alpha: number }): string {\n const mode = color.type === 'xyz-d50' ? 'xyz50' : 'xyz65'\n return withAlpha(formatHex({ mode, x: color.x, y: color.y, z: color.z }) ?? null, color.alpha)\n}\n\n/**\n * Convert a lightningcss `CssColor` to an RN-safe color string. RGB\n * passes through unchanged. LAB / LCH / OKLAB / OKLCH / `color(xyz-…)`\n * forms go through culori to reach sRGB — RN's native view manager only\n * understands sRGB-family strings. SystemColor keywords (`'background'`,\n * `'canvas'`, …) pass through untouched; they have no RN analog and the\n * runtime ignores unknown color strings gracefully.\n * @param color Typed color value.\n * @returns Color string RN accepts.\n */\nexport function cssColorToString(color: CssColor): string {\n if (typeof color === 'string') return color\n switch (color.type) {\n case 'rgb': {\n return rgbIntsToString(color.r, color.g, color.b, color.alpha)\n }\n case 'lab':\n case 'lch':\n case 'oklab':\n case 'oklch': {\n return labFamilyToHex(color)\n }\n case 'srgb': {\n return floatRgbToString(color.r, color.g, color.b, color.alpha)\n }\n case 'srgb-linear': {\n return wideGamutToHex('lrgb', color.r, color.g, color.b, color.alpha)\n }\n case 'display-p3': {\n return wideGamutToHex('p3', color.r, color.g, color.b, color.alpha)\n }\n case 'a98-rgb': {\n return wideGamutToHex('a98', color.r, color.g, color.b, color.alpha)\n }\n case 'prophoto-rgb': {\n return wideGamutToHex('prophoto', color.r, color.g, color.b, color.alpha)\n }\n case 'rec2020': {\n return wideGamutToHex('rec2020', color.r, color.g, color.b, color.alpha)\n }\n case 'xyz-d50':\n case 'xyz-d65': {\n return xyzToHex(color)\n }\n case 'currentcolor': {\n return 'currentColor'\n }\n case 'light-dark': {\n return cssColorToString(color.light)\n }\n default: {\n return 'transparent'\n }\n }\n}\n"],"names":["formatHex","culoriRgb"],"mappings":";;;;AAGA;;;;AAIG;AACH,SAAS,SAAS,CAAC,KAAa,EAAA;IAC9B,IAAI,KAAK,GAAG,CAAC;AAAE,QAAA,OAAO,CAAC;IACvB,IAAI,KAAK,GAAG,GAAG;AAAE,QAAA,OAAO,GAAG;AAC3B,IAAA,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC;AAC1B;AAEA;;;;AAIG;AACH,SAAS,SAAS,CAAC,IAAY,EAAA;IAC7B,MAAM,GAAG,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC;AACxC,IAAA,OAAO,GAAG,CAAC,MAAM,KAAK,CAAC,GAAG,CAAA,CAAA,EAAI,GAAG,CAAA,CAAE,GAAG,GAAG;AAC3C;AAEA;;;;;;;AAOG;AACH,SAAS,eAAe,CAAC,CAAS,EAAE,CAAS,EAAE,CAAS,EAAE,KAAa,EAAA;IACrE,IAAI,KAAK,IAAI,CAAC;AAAE,QAAA,OAAO,IAAI,SAAS,CAAC,CAAC,CAAC,GAAG,SAAS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;YACd,OAAO,cAAc,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,KAAK,CAAC;QACtE;QACA,KAAK,cAAc,EAAE;YACnB,OAAO,cAAc,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,KAAK,CAAC;QAC3E;QACA,KAAK,SAAS,EAAE;YACd,OAAO,cAAc,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,KAAK,CAAC;QAC1E;AACA,QAAA,KAAK,SAAS;QACd,KAAK,SAAS,EAAE;AACd,YAAA,OAAO,QAAQ,CAAC,KAAK,CAAC;QACxB;QACA,KAAK,cAAc,EAAE;AACnB,YAAA,OAAO,cAAc;QACvB;QACA,KAAK,YAAY,EAAE;AACjB,YAAA,OAAO,gBAAgB,CAAC,KAAK,CAAC,KAAK,CAAC;QACtC;QACA,SAAS;AACP,YAAA,OAAO,aAAa;QACtB;;AAEJ;;;;"}
|
|
1
|
+
{"version":3,"file":"color.cjs","sources":["../../../../../src/core/parser/color.ts"],"sourcesContent":["import type { CssColor, LABColor } from 'lightningcss'\nimport { formatHex, rgb as culoriRgb } from 'culori'\n\n/**\n * Clamp a 0-255 float to the integer byte range RN color strings accept.\n * @param value Unclamped float (may be negative or above 255).\n * @returns Integer in `[0, 255]`.\n */\nfunction clampByte(value: number): number {\n if (value < 0) return 0\n if (value > 255) return 255\n return Math.round(value)\n}\n\n/**\n * Two-digit hex encoding of a 0-255 byte.\n * @param byte Byte value (may be out-of-range — clamped).\n * @returns Zero-padded two-char hex string.\n */\nfunction byteToHex(byte: number): string {\n const hex = clampByte(byte).toString(16)\n return hex.length === 1 ? `0${hex}` : hex\n}\n\n/**\n * Format an integer-RGB triple + alpha as `#rrggbb` or `rgba(r, g, b, a)`.\n * @param r 0-255 red.\n * @param g 0-255 green.\n * @param b 0-255 blue.\n * @param alpha 0-1 alpha.\n * @returns Color string.\n */\nfunction rgbIntsToString(r: number, g: number, b: number, alpha: number): string {\n if (alpha >= 1) return `#${byteToHex(r)}${byteToHex(g)}${byteToHex(b)}`\n // Round the alpha to shed f32 noise (`0.2 → 0.20000000298…`) — RN parses\n // either, but the rounded form keeps generated StyleSheets compact.\n return `rgba(${r}, ${g}, ${b}, ${Math.round(alpha * 10_000) / 10_000})`\n}\n\n/**\n * Format a float-RGB triple + alpha (CSS `color(srgb …)` forms) as\n * hex/rgba.\n * @param r 0-1 red.\n * @param g 0-1 green.\n * @param b 0-1 blue.\n * @param alpha 0-1 alpha.\n * @returns Color string.\n */\nfunction floatRgbToString(r: number, g: number, b: number, alpha: number): string {\n return rgbIntsToString(clampByte(r * 255), clampByte(g * 255), clampByte(b * 255), alpha)\n}\n\n/**\n * Dispatch a LAB-family color through culori's hex formatter.\n * @param color Typed LAB-family color.\n * @returns `#rrggbb` string, or `null` when culori couldn't convert.\n */\nfunction culoriHexFor(color: LABColor): string | null {\n switch (color.type) {\n case 'oklch': {\n return formatHex({ mode: 'oklch', l: color.l, c: color.c, h: color.h }) ?? null\n }\n case 'oklab': {\n return formatHex({ mode: 'oklab', l: color.l, a: color.a, b: color.b }) ?? null\n }\n case 'lab': {\n return formatHex({ mode: 'lab', l: color.l, a: color.a, b: color.b }) ?? null\n }\n case 'lch': {\n return formatHex({ mode: 'lch', l: color.l, c: color.c, h: color.h }) ?? null\n }\n default: {\n return null\n }\n }\n}\n\n/**\n * Composite a culori-produced sRGB hex with the source alpha into the RN\n * color string. Shared tail for every culori-backed conversion (lab\n * family, XYZ, wide-gamut RGB): opaque → the hex as-is; translucent →\n * `rgba(...)` rebuilt from the hex channels.\n * @param hex sRGB hex from culori, or `null` when culori rejected the color.\n * @param alpha Source alpha (0–1).\n * @returns RN color string.\n */\nfunction withAlpha(hex: string | null, alpha: number): string {\n if (!hex) return alpha < 1 ? 'rgba(0, 0, 0, 0)' : 'transparent'\n if (alpha >= 1) return hex\n const back = culoriRgb(hex)\n if (!back) return hex\n return rgbIntsToString(clampByte(back.r * 255), clampByte(back.g * 255), clampByte(back.b * 255), alpha)\n}\n\n/**\n * Convert a LAB / LCH / OKLAB / OKLCH color to sRGB hex via culori. RN\n * can't evaluate these modern color spaces at paint time; compile-time\n * lowering to sRGB is the only portable path.\n * @param color Typed lab-family color.\n * @returns Hex or rgba string in sRGB.\n */\nfunction labFamilyToHex(color: LABColor): string {\n return withAlpha(culoriHexFor(color), color.alpha)\n}\n\n/**\n * Convert a wide-gamut `color(<space> r g b)` triple to sRGB hex via\n * culori. The channels are NOT sRGB — each space (display-p3, rec2020,\n * a98-rgb, prophoto-rgb, srgb-linear) carries its own primaries / transfer\n * function, so a bare `channel * 255` would mis-paint. culori does the\n * gamut + gamma conversion to sRGB.\n * @param mode culori mode key for the source space.\n * @param r Source red (0–1).\n * @param g Source green (0–1).\n * @param b Source blue (0–1).\n * @param alpha Alpha channel (0–1).\n * @returns sRGB color string RN accepts.\n */\nfunction wideGamutToHex(mode: 'lrgb' | 'p3' | 'a98' | 'prophoto' | 'rec2020', r: number, g: number, b: number, alpha: number): string {\n return withAlpha(formatHex({ mode, r, g, b }) ?? null, alpha)\n}\n\n/**\n * Convert a CSS `color(xyz-d50 …)` / `color(xyz-d65 …)` value to sRGB hex\n * via culori.\n * @param color Typed XYZ color (discriminated by `type`).\n * @param color.type Whether the color is in the D50 or D65 XYZ space.\n * @param color.x CIE X component (0–1).\n * @param color.y CIE Y component (0–1).\n * @param color.z CIE Z component (0–1).\n * @param color.alpha Alpha channel (0–1).\n * @returns `#rrggbb` string, or `'transparent'` when culori rejects it.\n */\nfunction xyzToHex(color: { type: 'xyz-d50' | 'xyz-d65'; x: number; y: number; z: number; alpha: number }): string {\n const mode = color.type === 'xyz-d50' ? 'xyz50' : 'xyz65'\n return withAlpha(formatHex({ mode, x: color.x, y: color.y, z: color.z }) ?? null, color.alpha)\n}\n\n/**\n * Modern CSS color functions RN's native view manager can't paint —\n * everything else (hex, `rgb()`/`rgba()`, `hsl()`/`hsla()`, named colors,\n * `transparent`, `currentColor`) RN reads directly and must pass through\n * untouched. Custom `@theme` tokens reach the parser as `var(--color-x)`\n * (only the default palette is `theme(inline)`-d), so they flow through the\n * unparsed-string path where the typed {@link cssColorToString} never runs —\n * this is the one place that lowers their wide-gamut values to sRGB.\n */\nconst RN_UNREADABLE_COLOR_PREFIXES: readonly string[] = ['oklch(', 'oklab(', 'lab(', 'lch(', 'color(', 'hwb(']\n\n/**\n * Lower a wide-gamut / modern CSS color STRING (`oklch(…)`, `lab(…)`,\n * `color(display-p3 …)`, …) to an sRGB hex/rgba string RN can paint. Returns\n * `null` for anything RN already understands (hex, rgb, hsl, named) so the\n * caller keeps the original text — only the unrepresentable forms convert.\n * Mirrors {@link cssColorToString}'s culori lowering for the string path.\n * @param text Resolved CSS color text (post theme-var substitution).\n * @returns sRGB color string, or `null` when no conversion is needed/possible.\n */\nexport function normalizeColorString(text: string): string | null {\n const lower = text.trim().toLowerCase()\n if (!RN_UNREADABLE_COLOR_PREFIXES.some((prefix) => lower.startsWith(prefix))) return null\n const parsed = culoriRgb(text)\n if (!parsed || ![parsed.r, parsed.g, parsed.b].every((v) => typeof v === 'number' && Number.isFinite(v))) return null\n const alpha = typeof parsed.alpha === 'number' ? parsed.alpha : 1\n return rgbIntsToString(clampByte(parsed.r * 255), clampByte(parsed.g * 255), clampByte(parsed.b * 255), alpha)\n}\n\n/**\n * Convert a lightningcss `CssColor` to an RN-safe color string. RGB\n * passes through unchanged. LAB / LCH / OKLAB / OKLCH / `color(xyz-…)`\n * forms go through culori to reach sRGB — RN's native view manager only\n * understands sRGB-family strings. SystemColor keywords (`'background'`,\n * `'canvas'`, …) pass through untouched; they have no RN analog and the\n * runtime ignores unknown color strings gracefully.\n * @param color Typed color value.\n * @returns Color string RN accepts.\n */\nexport function cssColorToString(color: CssColor): string {\n if (typeof color === 'string') return color\n switch (color.type) {\n case 'rgb': {\n return rgbIntsToString(color.r, color.g, color.b, color.alpha)\n }\n case 'lab':\n case 'lch':\n case 'oklab':\n case 'oklch': {\n return labFamilyToHex(color)\n }\n case 'srgb': {\n return floatRgbToString(color.r, color.g, color.b, color.alpha)\n }\n case 'srgb-linear': {\n return wideGamutToHex('lrgb', color.r, color.g, color.b, color.alpha)\n }\n case 'display-p3': {\n return wideGamutToHex('p3', color.r, color.g, color.b, color.alpha)\n }\n case 'a98-rgb': {\n return wideGamutToHex('a98', color.r, color.g, color.b, color.alpha)\n }\n case 'prophoto-rgb': {\n return wideGamutToHex('prophoto', color.r, color.g, color.b, color.alpha)\n }\n case 'rec2020': {\n return wideGamutToHex('rec2020', color.r, color.g, color.b, color.alpha)\n }\n case 'xyz-d50':\n case 'xyz-d65': {\n return xyzToHex(color)\n }\n case 'currentcolor': {\n return 'currentColor'\n }\n case 'light-dark': {\n return cssColorToString(color.light)\n }\n default: {\n return 'transparent'\n }\n }\n}\n"],"names":["formatHex","culoriRgb"],"mappings":";;;;AAGA;;;;AAIG;AACH,SAAS,SAAS,CAAC,KAAa,EAAA;IAC9B,IAAI,KAAK,GAAG,CAAC;AAAE,QAAA,OAAO,CAAC;IACvB,IAAI,KAAK,GAAG,GAAG;AAAE,QAAA,OAAO,GAAG;AAC3B,IAAA,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC;AAC1B;AAEA;;;;AAIG;AACH,SAAS,SAAS,CAAC,IAAY,EAAA;IAC7B,MAAM,GAAG,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC;AACxC,IAAA,OAAO,GAAG,CAAC,MAAM,KAAK,CAAC,GAAG,CAAA,CAAA,EAAI,GAAG,CAAA,CAAE,GAAG,GAAG;AAC3C;AAEA;;;;;;;AAOG;AACH,SAAS,eAAe,CAAC,CAAS,EAAE,CAAS,EAAE,CAAS,EAAE,K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EAAE,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,KAAK,CAAC;QACtE;QACA,KAAK,cAAc,EAAE;YACnB,OAAO,cAAc,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,KAAK,CAAC;QAC3E;QACA,KAAK,SAAS,EAAE;YACd,OAAO,cAAc,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,KAAK,CAAC;QAC1E;AACA,QAAA,KAAK,SAAS;QACd,KAAK,SAAS,EAAE;AACd,YAAA,OAAO,QAAQ,CAAC,KAAK,CAAC;QACxB;QACA,KAAK,cAAc,EAAE;AACnB,YAAA,OAAO,cAAc;QACvB;QACA,KAAK,YAAY,EAAE;AACjB,YAAA,OAAO,gBAAgB,CAAC,KAAK,CAAC,KAAK,CAAC;QACtC;QACA,SAAS;AACP,YAAA,OAAO,aAAa;QACtB;;AAEJ;;;;;"}
|
|
@@ -1,4 +1,14 @@
|
|
|
1
1
|
import type { CssColor } from 'lightningcss';
|
|
2
|
+
/**
|
|
3
|
+
* Lower a wide-gamut / modern CSS color STRING (`oklch(…)`, `lab(…)`,
|
|
4
|
+
* `color(display-p3 …)`, …) to an sRGB hex/rgba string RN can paint. Returns
|
|
5
|
+
* `null` for anything RN already understands (hex, rgb, hsl, named) so the
|
|
6
|
+
* caller keeps the original text — only the unrepresentable forms convert.
|
|
7
|
+
* Mirrors {@link cssColorToString}'s culori lowering for the string path.
|
|
8
|
+
* @param text Resolved CSS color text (post theme-var substitution).
|
|
9
|
+
* @returns sRGB color string, or `null` when no conversion is needed/possible.
|
|
10
|
+
*/
|
|
11
|
+
export declare function normalizeColorString(text: string): string | null;
|
|
2
12
|
/**
|
|
3
13
|
* Convert a lightningcss `CssColor` to an RN-safe color string. RGB
|
|
4
14
|
* passes through unchanged. LAB / LCH / OKLAB / OKLCH / `color(xyz-…)`
|
|
@@ -26,6 +26,71 @@ const UNSUPPORTED_LOGICAL_PROPS = new Set([
|
|
|
26
26
|
'border-block-start-style',
|
|
27
27
|
'border-block-end-style',
|
|
28
28
|
]);
|
|
29
|
+
/**
|
|
30
|
+
* Web-only CSS properties Tailwind v4 emits that have NO React Native style
|
|
31
|
+
* equivalent. Without this denylist they reach the generic `kebabToCamel`
|
|
32
|
+
* fallback and emit dead keys (`objectPosition`, `textWrap`, `willChange`,
|
|
33
|
+
* `float`, `columns`, `-webkit-line-clamp` → `WebkitLineClamp`, …) that bloat
|
|
34
|
+
* every StyleSheet and read as "supported" when they do nothing. Dropping the
|
|
35
|
+
* property name (kebab-case, pre-camel) is safe: it only excludes known
|
|
36
|
+
* web-only props — anything RN supports is handled by a typed branch above.
|
|
37
|
+
* (line-clamp's real RN behaviour comes from `numberOfLines` in text-truncate.)
|
|
38
|
+
*/
|
|
39
|
+
const RN_UNSUPPORTED_PROPERTIES = new Set([
|
|
40
|
+
'object-position',
|
|
41
|
+
'text-wrap',
|
|
42
|
+
'will-change',
|
|
43
|
+
'columns',
|
|
44
|
+
'float',
|
|
45
|
+
'clear',
|
|
46
|
+
'table-layout',
|
|
47
|
+
'caption-side',
|
|
48
|
+
'transform-style',
|
|
49
|
+
'background-blend-mode',
|
|
50
|
+
'scroll-behavior',
|
|
51
|
+
'overscroll-behavior',
|
|
52
|
+
'overscroll-behavior-x',
|
|
53
|
+
'overscroll-behavior-y',
|
|
54
|
+
'scroll-snap-type',
|
|
55
|
+
'scroll-snap-align',
|
|
56
|
+
'scroll-snap-stop',
|
|
57
|
+
'break-after',
|
|
58
|
+
'break-before',
|
|
59
|
+
'break-inside',
|
|
60
|
+
'content',
|
|
61
|
+
'field-sizing',
|
|
62
|
+
'forced-color-adjust',
|
|
63
|
+
'text-shadow',
|
|
64
|
+
'touch-action',
|
|
65
|
+
'backdrop-filter',
|
|
66
|
+
'-webkit-backdrop-filter',
|
|
67
|
+
'-webkit-line-clamp',
|
|
68
|
+
'-webkit-box-orient',
|
|
69
|
+
'-webkit-font-smoothing',
|
|
70
|
+
'-moz-osx-font-smoothing',
|
|
71
|
+
]);
|
|
72
|
+
/** CSS single-sided logical-inline property → RN writing-direction Yoga key. */
|
|
73
|
+
const LOGICAL_INLINE_TO_RN = {
|
|
74
|
+
'margin-inline-start': 'marginStart',
|
|
75
|
+
'margin-inline-end': 'marginEnd',
|
|
76
|
+
'padding-inline-start': 'paddingStart',
|
|
77
|
+
'padding-inline-end': 'paddingEnd',
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Logical border-COLOR property → physical RN side key(s). Custom `@theme`
|
|
81
|
+
* tokens reach the unparsed path as `border-inline-color: var(--color-x)`,
|
|
82
|
+
* which a plain `kebabToCamel` would turn into `borderInlineColor` — a key RN
|
|
83
|
+
* silently drops, so the border color never paints. Lower to the physical
|
|
84
|
+
* keys RN actually honors, matching the typed `dispatchBorderDeclaration`.
|
|
85
|
+
*/
|
|
86
|
+
const LOGICAL_BORDER_COLOR_SIDES = {
|
|
87
|
+
'border-inline-color': ['borderLeftColor', 'borderRightColor'],
|
|
88
|
+
'border-block-color': ['borderTopColor', 'borderBottomColor'],
|
|
89
|
+
'border-inline-start-color': ['borderLeftColor'],
|
|
90
|
+
'border-inline-end-color': ['borderRightColor'],
|
|
91
|
+
'border-block-start-color': ['borderTopColor'],
|
|
92
|
+
'border-block-end-color': ['borderBottomColor'],
|
|
93
|
+
};
|
|
29
94
|
/**
|
|
30
95
|
* Pick the closest predefined CSS easing keyword for a `cubic-bezier`
|
|
31
96
|
* control-point set. Mirrors {@link snapCubicBezierToKeyword} in
|
|
@@ -75,6 +140,25 @@ function coerceCubicBezierString(value) {
|
|
|
75
140
|
const [, x1, y1, x2, y2] = match;
|
|
76
141
|
return snapBezier(Number(x1), Number(y1), Number(x2), Number(y2));
|
|
77
142
|
}
|
|
143
|
+
/**
|
|
144
|
+
* Whether `text` has a whitespace char OUTSIDE any parenthesised group —
|
|
145
|
+
* the signature of a multi-token CSS value (`2px solid #000`) rather than a
|
|
146
|
+
* single color (`#000`, `rgb(1 2 3)`, `red`).
|
|
147
|
+
* @param text Resolved value text.
|
|
148
|
+
* @returns True when a top-level space is present.
|
|
149
|
+
*/
|
|
150
|
+
function hasTopLevelSpace(text) {
|
|
151
|
+
let depth = 0;
|
|
152
|
+
for (const ch of text.trim()) {
|
|
153
|
+
if (ch === '(')
|
|
154
|
+
depth += 1;
|
|
155
|
+
else if (ch === ')')
|
|
156
|
+
depth = Math.max(0, depth - 1);
|
|
157
|
+
else if (depth === 0 && (ch === ' ' || ch === '\t' || ch === '\n'))
|
|
158
|
+
return true;
|
|
159
|
+
}
|
|
160
|
+
return false;
|
|
161
|
+
}
|
|
78
162
|
/**
|
|
79
163
|
* Fast-path check for the handful of color property names Tailwind emits.
|
|
80
164
|
* @param property Kebab-case CSS property name.
|
|
@@ -83,6 +167,11 @@ function coerceCubicBezierString(value) {
|
|
|
83
167
|
function isColorProperty(property) {
|
|
84
168
|
return (property === 'color' ||
|
|
85
169
|
property === 'background-color' ||
|
|
170
|
+
// SVG paint props (`fill-<token>` / `stroke-<token>` via react-native-svg) —
|
|
171
|
+
// they don't end in `-color`, so without this they'd skip normalization and
|
|
172
|
+
// leak a raw `oklch(…)` string for custom `@theme` tokens.
|
|
173
|
+
property === 'fill' ||
|
|
174
|
+
property === 'stroke' ||
|
|
86
175
|
(property.startsWith('border-') && property.endsWith('-color')) ||
|
|
87
176
|
property.endsWith('-color'));
|
|
88
177
|
}
|
|
@@ -99,6 +188,8 @@ function isColorProperty(property) {
|
|
|
99
188
|
function unparsedToEntries(property, tokens$1, themeVars) {
|
|
100
189
|
if (property.length === 0)
|
|
101
190
|
return [];
|
|
191
|
+
if (RN_UNSUPPORTED_PROPERTIES.has(property))
|
|
192
|
+
return [];
|
|
102
193
|
// Safe-area detection runs BEFORE token serialization because
|
|
103
194
|
// `env()` serializes to an empty string, which would strip the side
|
|
104
195
|
// info we need. If the tokens encode a recognised `env(safe-area-inset-*)`
|
|
@@ -115,12 +206,15 @@ function unparsedToEntries(property, tokens$1, themeVars) {
|
|
|
115
206
|
const coerced = tokens.coerceUnparsedValue(text);
|
|
116
207
|
if (coerced === null)
|
|
117
208
|
return [];
|
|
118
|
-
// Skip values
|
|
119
|
-
// came from a `@property --tw-*`
|
|
120
|
-
//
|
|
121
|
-
//
|
|
122
|
-
// RN'
|
|
123
|
-
|
|
209
|
+
// Skip values still carrying an unresolved `var(--tw-*)` ANYWHERE in the
|
|
210
|
+
// string — they came from a `@property --tw-*` composable with no real
|
|
211
|
+
// fallback (e.g. `filter: blur(8px) var(--tw-brightness) …`,
|
|
212
|
+
// `transform: rotateX(45deg) var(--tw-rotate-y) …`, `touch-action`,
|
|
213
|
+
// `scroll-snap-type`). RN can't evaluate the cascade, so a leaked `var()`
|
|
214
|
+
// makes the whole declaration an invalid string RN rejects — drop it and
|
|
215
|
+
// rely on RN's default rather than emit garbage. `var(--color-*)` refs are
|
|
216
|
+
// already substituted above, so anything left is a genuine composable miss.
|
|
217
|
+
if (typeof coerced === 'string' && coerced.includes('var('))
|
|
124
218
|
return [];
|
|
125
219
|
// RN `fontFamily` is a single typeface, not a CSS fallback list — take
|
|
126
220
|
// the first family so `--font-x: "Name", sans-serif` works out of the box.
|
|
@@ -139,9 +233,23 @@ function unparsedToEntries(property, tokens$1, themeVars) {
|
|
|
139
233
|
return [[caseConvert.kebabToCamel(property), coerceCubicBezierString(coerced)]];
|
|
140
234
|
}
|
|
141
235
|
if (isColorProperty(property) && typeof coerced === 'string') {
|
|
142
|
-
//
|
|
143
|
-
//
|
|
144
|
-
|
|
236
|
+
// A color is a single token. Tailwind compiles an arbitrary shorthand like
|
|
237
|
+
// `border-[2px_solid_#000]` to `border-color: 2px solid #000` (invalid for
|
|
238
|
+
// a color property → unparsed), which would otherwise emit
|
|
239
|
+
// `borderColor: "2px solid #000000"` — a string RN rejects. A top-level
|
|
240
|
+
// space (outside parens — `rgb(1 2 3)` keeps its inner spaces) means it's a
|
|
241
|
+
// multi-token shorthand, not a color: drop it.
|
|
242
|
+
if (hasTopLevelSpace(coerced))
|
|
243
|
+
return [];
|
|
244
|
+
// Lower modern color spaces (`oklch(…)`, `lab(…)`, `color(p3 …)`) that
|
|
245
|
+
// RN can't paint to sRGB; hex/rgb/hsl/named pass through unchanged.
|
|
246
|
+
const color$1 = color.normalizeColorString(coerced) ?? coerced;
|
|
247
|
+
// Logical border-color utilities must lower to physical RN side keys —
|
|
248
|
+
// RN ignores `borderInlineColor` / `borderInlineStartColor`.
|
|
249
|
+
const sides = LOGICAL_BORDER_COLOR_SIDES[property];
|
|
250
|
+
if (sides)
|
|
251
|
+
return sides.map((key) => [key, color$1]);
|
|
252
|
+
return [[caseConvert.kebabToCamel(property), color$1]];
|
|
145
253
|
}
|
|
146
254
|
return [[caseConvert.kebabToCamel(property), coerced]];
|
|
147
255
|
}
|
|
@@ -338,7 +446,8 @@ function declarationToRnEntries(decl, themeVars) {
|
|
|
338
446
|
return [['flexBasis', v]];
|
|
339
447
|
}
|
|
340
448
|
default: {
|
|
341
|
-
return (
|
|
449
|
+
return (dispatchLogicalInline(decl) ??
|
|
450
|
+
layoutDispatcher.dispatchLayoutDeclaration(decl) ??
|
|
342
451
|
typographyDispatcher.dispatchTypographyDeclaration(decl) ??
|
|
343
452
|
colorPropertiesDispatcher.dispatchColorPropertyDeclaration(decl) ??
|
|
344
453
|
borderDispatcher.dispatchBorderDeclaration(decl) ??
|
|
@@ -347,6 +456,48 @@ function declarationToRnEntries(decl, themeVars) {
|
|
|
347
456
|
}
|
|
348
457
|
}
|
|
349
458
|
}
|
|
459
|
+
/**
|
|
460
|
+
* Map single-sided CSS logical-inline props to RN's writing-direction-aware
|
|
461
|
+
* Yoga keys: `ms-2` → `marginStart`, `pe-4` → `paddingEnd`, `start-2` →
|
|
462
|
+
* `start`, `end-3` → `end`. RN resolves start/end against the layout
|
|
463
|
+
* direction, so these stay RTL-correct. Returns null for any other property
|
|
464
|
+
* (so the dispatch chain continues).
|
|
465
|
+
* @param decl One declaration from a lightningcss style rule.
|
|
466
|
+
* @returns RN entries, or null when not a logical-inline property.
|
|
467
|
+
*/
|
|
468
|
+
function dispatchLogicalInline(decl) {
|
|
469
|
+
switch (decl.property) {
|
|
470
|
+
case 'margin-inline-start':
|
|
471
|
+
case 'margin-inline-end':
|
|
472
|
+
case 'padding-inline-start':
|
|
473
|
+
case 'padding-inline-end': {
|
|
474
|
+
const v = length.lengthPercentageOrAutoToValue(decl.value);
|
|
475
|
+
return v === null ? [] : [[LOGICAL_INLINE_TO_RN[decl.property], v]];
|
|
476
|
+
}
|
|
477
|
+
case 'inset-inline-start': {
|
|
478
|
+
const v = length.lengthPercentageOrAutoToValue(decl.value);
|
|
479
|
+
return v === null ? [] : [['start', v]];
|
|
480
|
+
}
|
|
481
|
+
case 'inset-inline-end': {
|
|
482
|
+
const v = length.lengthPercentageOrAutoToValue(decl.value);
|
|
483
|
+
return v === null ? [] : [['end', v]];
|
|
484
|
+
}
|
|
485
|
+
// Logical border-radius corners (`rounded-s/e/ss/se/ee/es-*`). RN has
|
|
486
|
+
// matching keys — `kebabToCamel('border-start-start-radius')` is exactly
|
|
487
|
+
// `borderStartStartRadius`. Value is a `[x, y]` tuple like physical corners.
|
|
488
|
+
case 'border-start-start-radius':
|
|
489
|
+
case 'border-start-end-radius':
|
|
490
|
+
case 'border-end-start-radius':
|
|
491
|
+
case 'border-end-end-radius': {
|
|
492
|
+
const [xAxis] = decl.value;
|
|
493
|
+
const v = length.dimensionPercentageToNumber(xAxis);
|
|
494
|
+
return v === null ? [] : [[caseConvert.kebabToCamel(decl.property), v]];
|
|
495
|
+
}
|
|
496
|
+
default: {
|
|
497
|
+
return null;
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
}
|
|
350
501
|
|
|
351
502
|
exports.declarationToRnEntries = declarationToRnEntries;
|
|
352
503
|
//# sourceMappingURL=declaration.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"declaration.cjs","sources":["../../../../../src/core/parser/declaration.ts"],"sourcesContent":["/* eslint-disable sonarjs/cognitive-complexity -- the main Declaration → RN-entries dispatcher is intentionally a flat switch so each branch keeps its narrowed value type */\nimport type { Declaration as LcDeclaration, TokenOrValue } from 'lightningcss'\nimport { kebabToCamel } from './case-convert'\nimport { cssColorToString } from './color'\nimport { dimensionPercentageToNumber, gapValueToValue, lengthPercentageOrAutoToValue, sizeLikeToValue } from './length'\nimport {\n expandBorderColor,\n expandBorderRadius,\n expandFourSided,\n expandGap,\n expandLogicalBlock,\n expandLogicalInline,\n flexToEntries,\n} from './shorthand'\nimport { coerceFontFamily, coerceUnparsedValue, serializeTokens, substituteThemeVars } from './tokens'\nimport { displayToEntries, fontSizeToPx, fontWeightToValue, zIndexToNumber } from './typography'\nimport { dispatchMotionDeclaration } from './motion-dispatcher'\nimport { dispatchTypographyDeclaration } from './typography-dispatcher'\nimport { dispatchLayoutDeclaration } from './layout-dispatcher'\nimport { dispatchColorPropertyDeclaration } from './color-properties-dispatcher'\nimport { dispatchBorderDeclaration } from './border-dispatcher'\nimport { detectSafeAreaMarker } from './safe-area'\nimport type { RNEntry } from './types'\n\n/** CSS timing-function properties that need `cubic-bezier(...)` snapping. */\nconst TIMING_FUNCTION_PROPS = new Set(['transition-timing-function', 'animation-timing-function'])\n\n/** CSS easing keywords Reanimated v4's CSS engine accepts as strings. */\nconst CSS_EASING_KEYWORDS = new Set(['linear', 'ease', 'ease-in', 'ease-out', 'ease-in-out', 'step-start', 'step-end'])\n\n/** CSS properties with no useful RN equivalent — silently dropped. */\nconst UNSUPPORTED_LOGICAL_PROPS = new Set([\n 'border-inline-style',\n 'border-block-style',\n 'border-inline-start-style',\n 'border-inline-end-style',\n 'border-block-start-style',\n 'border-block-end-style',\n])\n\n/**\n * Pick the closest predefined CSS easing keyword for a `cubic-bezier`\n * control-point set. Mirrors {@link snapCubicBezierToKeyword} in\n * `animation.ts` — kept here so the unparsed-string path doesn't need\n * to import a typed-only helper.\n * @param x1 First control-point x (0–1).\n * @param y1 First control-point y (0–1).\n * @param x2 Second control-point x (0–1).\n * @param y2 Second control-point y (0–1).\n * @returns CSS easing keyword.\n */\nfunction snapBezier(x1: number, y1: number, x2: number, y2: number): string {\n const tol = 0.01\n const eq = (a: number, b: number): boolean => Math.abs(a - b) < tol\n if (eq(x1, 0) && eq(y1, 0) && eq(x2, 1) && eq(y2, 1)) return 'linear'\n if (eq(x1, 0.25) && eq(y1, 0.1) && eq(x2, 0.25) && eq(y2, 1)) return 'ease'\n if (eq(x1, 0.4) && eq(y1, 0) && eq(x2, 1) && eq(y2, 1)) return 'ease-in'\n if (eq(x1, 0) && eq(y1, 0) && eq(x2, 0.2) && eq(y2, 1)) return 'ease-out'\n if (eq(x1, 0.4) && eq(y1, 0) && eq(x2, 0.2) && eq(y2, 1)) return 'ease-in-out'\n const startsFlat = x1 < 0.1\n const endsFlat = x2 > 0.9\n if (startsFlat && !endsFlat) return 'ease-out'\n if (!startsFlat && endsFlat) return 'ease-in'\n return 'ease-in-out'\n}\n\n/**\n * Snap a cubic-bezier expression string to the closest CSS keyword\n * Reanimated v4's CSS engine accepts. Strings that already are keywords\n * pass through unchanged.\n * @param value Resolved value text from an unparsed timing-function declaration.\n * @returns CSS easing keyword.\n */\nfunction coerceCubicBezierString(value: string): string {\n const text = value.trim()\n if (CSS_EASING_KEYWORDS.has(text)) return text\n const match = /^cubic-bezier\\(\\s*([\\d.-]+)\\s*,\\s*([\\d.-]+)\\s*,\\s*([\\d.-]+)\\s*,\\s*([\\d.-]+)\\s*\\)$/.exec(text)\n if (!match) return 'ease-in-out'\n const [, x1, y1, x2, y2] = match\n return snapBezier(Number(x1), Number(y1), Number(x2), Number(y2))\n}\n\n/**\n * Fast-path check for the handful of color property names Tailwind emits.\n * @param property Kebab-case CSS property name.\n * @returns Whether the property's value should be treated as a color.\n */\nfunction isColorProperty(property: string): boolean {\n return (\n property === 'color' ||\n property === 'background-color' ||\n (property.startsWith('border-') && property.endsWith('-color')) ||\n property.endsWith('-color')\n )\n}\n\n/**\n * Convert an unparsed declaration (typical Tailwind v4 output containing\n * `var()` / `calc()`) into RN entries. Serializes the token list, then\n * coerces the flat string into a number / keyword / length via a tight\n * set of shapes Tailwind actually emits.\n * @param property Real property name (kebab-case).\n * @param tokens Token list from lightningcss.\n * @param themeVars Optional lookup table for resolving `var(--x)` references.\n * @returns RN entries — usually one, empty when unusable.\n */\nfunction unparsedToEntries(\n property: string,\n tokens: readonly TokenOrValue[],\n themeVars: ReadonlyMap<string, string> | undefined,\n): readonly RNEntry[] {\n if (property.length === 0) return []\n // Safe-area detection runs BEFORE token serialization because\n // `env()` serializes to an empty string, which would strip the side\n // info we need. If the tokens encode a recognised `env(safe-area-inset-*)`\n // pattern (pure / `max(..., n)` / `calc(...+n)` / `h-screen-safe`),\n // emit a runtime-resolved marker instead.\n if (UNSUPPORTED_LOGICAL_PROPS.has(property)) return []\n const safe = detectSafeAreaMarker(tokens, themeVars)\n if (safe !== null) return [[kebabToCamel(property), safe]]\n let text = serializeTokens(tokens)\n if (themeVars && themeVars.size > 0) text = substituteThemeVars(text, themeVars)\n const coerced = coerceUnparsedValue(text)\n if (coerced === null) return []\n // Skip values that didn't resolve past their `var()` wrapper — they\n // came from a `@property --tw-*` token without a real fallback.\n // Tailwind v4's `border-N` emits `border-style: var(--tw-border-style)`\n // expecting the cascade to fill it in; in RN we drop them and rely on\n // RN's default (solid).\n if (typeof coerced === 'string' && coerced.startsWith('var(')) return []\n // RN `fontFamily` is a single typeface, not a CSS fallback list — take\n // the first family so `--font-x: \"Name\", sans-serif` works out of the box.\n if (property === 'font-family' && typeof coerced === 'string') {\n return [['fontFamily', coerceFontFamily(coerced)]]\n }\n // Logical-direction CSS properties RN doesn't have direct equivalents\n // for. Keep the dropped names in one place so it's easy to audit.\n if (UNSUPPORTED_LOGICAL_PROPS.has(property)) return []\n if (TIMING_FUNCTION_PROPS.has(property) && typeof coerced === 'string') {\n // `transition-colors` and similar emit `var(--tw-ease, cubic-bezier(...))`\n // which serializes to a cubic-bezier STRING after substitution.\n // Reanimated v4's CSS engine rejects those — snap to the closest\n // predefined keyword (same logic as the typed `EasingFunction` path).\n return [[kebabToCamel(property), coerceCubicBezierString(coerced)]]\n }\n if (isColorProperty(property) && typeof coerced === 'string') {\n // Resolved user-theme color strings (e.g. `#ff0099`) go straight to\n // the RN style — no further conversion needed.\n return [[kebabToCamel(property), coerced]]\n }\n return [[kebabToCamel(property), coerced]]\n}\n\n/**\n * Convert one lightningcss `Declaration` into zero-or-more RN style\n * entries. Shorthand declarations (padding/margin/border-radius/flex) can\n * emit multiple entries; skipped or unsupported properties emit none.\n *\n * The switch branches on `decl.property` so TypeScript narrows\n * `decl.value` to the exact typed shape for each branch — no casts\n * required. Unknown properties fall through to `[]`.\n * @param decl One declaration from a lightningcss style rule.\n * @param themeVars Optional lookup table for resolving `var(--x)` references inside unparsed values.\n * @returns Array of `[key, value]` entries.\n */\nexport function declarationToRnEntries(decl: LcDeclaration, themeVars?: ReadonlyMap<string, string>): readonly RNEntry[] {\n switch (decl.property) {\n case 'custom': {\n // Lightningcss routes two shapes through `custom`:\n // - Actual CSS custom properties (`--my-var`): no RN meaning, drop.\n // - Real properties it doesn't have a dedicated typed entry for\n // (e.g. `object-fit`, `pointer-events`, future CSS keyword-only\n // props): treat like an unparsed declaration so the keyword\n // surfaces in the RN style.\n const customName = decl.value.name\n if (customName.startsWith('--')) return []\n return unparsedToEntries(customName, decl.value.value ?? [], themeVars)\n }\n case 'unparsed': {\n return unparsedToEntries(decl.value.propertyId.property, decl.value.value, themeVars)\n }\n case 'color':\n case 'background-color':\n case 'border-top-color':\n case 'border-right-color':\n case 'border-bottom-color':\n case 'border-left-color': {\n // `background-color` narrows to `CssColor | 'background'` — the\n // literal keyword means UA default. Skip the keyword.\n if (typeof decl.value === 'string') return []\n return [[kebabToCamel(decl.property), cssColorToString(decl.value)]]\n }\n case 'border-color': {\n return expandBorderColor(decl.value)\n }\n case 'opacity': {\n // Lightningcss hands us an `f32` for opacity, so values like `0.8`\n // round-trip as `0.800000011920929`. Snap to 4 decimals to match the\n // rest of the parser's numeric convention.\n return [[decl.property, Math.round(decl.value * 10_000) / 10_000]]\n }\n case 'z-index': {\n return [['zIndex', zIndexToNumber(decl.value)]]\n }\n case 'top':\n case 'right':\n case 'bottom':\n case 'left': {\n const v = lengthPercentageOrAutoToValue(decl.value)\n if (v === null) return []\n return [[decl.property, v]]\n }\n case 'inset': {\n const top = lengthPercentageOrAutoToValue(decl.value.top)\n const right = lengthPercentageOrAutoToValue(decl.value.right)\n const bottom = lengthPercentageOrAutoToValue(decl.value.bottom)\n const left = lengthPercentageOrAutoToValue(decl.value.left)\n if (top === null || right === null || bottom === null || left === null) return []\n return [\n ['top', top],\n ['right', right],\n ['bottom', bottom],\n ['left', left],\n ]\n }\n case 'inset-inline': {\n const start = lengthPercentageOrAutoToValue(decl.value.inlineStart)\n const end = lengthPercentageOrAutoToValue(decl.value.inlineEnd)\n if (start === null || end === null) return []\n return [\n ['left', start],\n ['right', end],\n ]\n }\n case 'inset-block': {\n const start = lengthPercentageOrAutoToValue(decl.value.blockStart)\n const end = lengthPercentageOrAutoToValue(decl.value.blockEnd)\n if (start === null || end === null) return []\n return [\n ['top', start],\n ['bottom', end],\n ]\n }\n case 'width':\n case 'height':\n case 'min-width':\n case 'min-height':\n case 'max-width':\n case 'max-height': {\n const v = sizeLikeToValue(decl.value)\n if (v === null) return []\n return [[kebabToCamel(decl.property), v]]\n }\n case 'gap': {\n return expandGap(decl.value)\n }\n case 'row-gap':\n case 'column-gap': {\n const v = gapValueToValue(decl.value)\n if (v === null) return []\n return [[kebabToCamel(decl.property), v]]\n }\n case 'font-style': {\n return [['fontStyle', decl.value.type]]\n }\n case 'display': {\n return displayToEntries(decl.value)\n }\n case 'position': {\n return [['position', decl.value.type]]\n }\n case 'font-size': {\n const px = fontSizeToPx(decl.value)\n if (px === null) return []\n return [['fontSize', px]]\n }\n case 'font-weight': {\n return [['fontWeight', fontWeightToValue(decl.value)]]\n }\n case 'padding': {\n return expandFourSided('padding', decl.value)\n }\n case 'margin': {\n return expandFourSided('margin', decl.value)\n }\n case 'padding-inline': {\n return expandLogicalInline('padding', decl.value)\n }\n case 'padding-block': {\n return expandLogicalBlock('padding', decl.value)\n }\n case 'margin-inline': {\n return expandLogicalInline('margin', decl.value)\n }\n case 'margin-block': {\n return expandLogicalBlock('margin', decl.value)\n }\n case 'padding-top':\n case 'padding-right':\n case 'padding-bottom':\n case 'padding-left':\n case 'margin-top':\n case 'margin-right':\n case 'margin-bottom':\n case 'margin-left': {\n const v = lengthPercentageOrAutoToValue(decl.value)\n if (v === null) return []\n return [[kebabToCamel(decl.property), v]]\n }\n case 'border-radius': {\n return expandBorderRadius(decl.value)\n }\n case 'border-top-left-radius':\n case 'border-top-right-radius':\n case 'border-bottom-left-radius':\n case 'border-bottom-right-radius': {\n const [xAxis] = decl.value\n const v = dimensionPercentageToNumber(xAxis)\n if (v === null) return []\n return [[kebabToCamel(decl.property), v]]\n }\n case 'flex': {\n return flexToEntries(decl.value)\n }\n case 'flex-grow':\n case 'flex-shrink': {\n return [[kebabToCamel(decl.property), decl.value]]\n }\n case 'flex-basis': {\n const v = lengthPercentageOrAutoToValue(decl.value)\n if (v === null) return []\n return [['flexBasis', v]]\n }\n default: {\n return (\n dispatchLayoutDeclaration(decl) ??\n dispatchTypographyDeclaration(decl) ??\n dispatchColorPropertyDeclaration(decl) ??\n dispatchBorderDeclaration(decl) ??\n dispatchMotionDeclaration(decl) ??\n []\n )\n }\n }\n}\n"],"names":["tokens","detectSafeAreaMarker","kebabToCamel","serializeTokens","substituteThemeVars","coerceUnparsedValue","coerceFontFamily","cssColorToString","expandBorderColor","zIndexToNumber","lengthPercentageOrAutoToValue","sizeLikeToValue","expandGap","gapValueToValue","displayToEntries","fontSizeToPx","fontWeightToValue","expandFourSided","expandLogicalInline","expandLogicalBlock","expandBorderRadius","dimensionPercentageToNumber","flexToEntries","dispatchLayoutDeclaration","dispatchTypographyDeclaration","dispatchColorPropertyDeclaration","dispatchBorderDeclaration","dispatchMotionDeclaration"],"mappings":";;;;;;;;;;;;;;;AAwBA;AACA,MAAM,qBAAqB,GAAG,IAAI,GAAG,CAAC,CAAC,4BAA4B,EAAE,2BAA2B,CAAC,CAAC;AAElG;AACA,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,aAAa,EAAE,YAAY,EAAE,UAAU,CAAC,CAAC;AAEvH;AACA,MAAM,yBAAyB,GAAG,IAAI,GAAG,CAAC;IACxC,qBAAqB;IACrB,oBAAoB;IACpB,2BAA2B;IAC3B,yBAAyB;IACzB,0BAA0B;IAC1B,wBAAwB;AACzB,CAAA,CAAC;AAEF;;;;;;;;;;AAUG;AACH,SAAS,UAAU,CAAC,EAAU,EAAE,EAAU,EAAE,EAAU,EAAE,EAAU,EAAA;IAChE,MAAM,GAAG,GAAG,IAAI;AAChB,IAAA,MAAM,EAAE,GAAG,CAAC,CAAS,EAAE,CAAS,KAAc,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,GAAG;IACnE,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;AAAE,QAAA,OAAO,QAAQ;IACrE,IAAI,EAAE,CAAC,EAAE,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,GAAG,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;AAAE,QAAA,OAAO,MAAM;IAC3E,IAAI,EAAE,CAAC,EAAE,EAAE,GAAG,CAAC,IAAI,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I,CAAC,KAAK;AAC1B,YAAA,MAAM,CAAC,GAAGC,kCAA2B,CAAC,KAAK,CAAC;YAC5C,IAAI,CAAC,KAAK,IAAI;AAAE,gBAAA,OAAO,EAAE;AACzB,YAAA,OAAO,CAAC,CAACnB,wBAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;QAC3C;QACA,KAAK,MAAM,EAAE;AACX,YAAA,OAAOoB,uBAAa,CAAC,IAAI,CAAC,KAAK,CAAC;QAClC;AACA,QAAA,KAAK,WAAW;QAChB,KAAK,aAAa,EAAE;AAClB,YAAA,OAAO,CAAC,CAACpB,wBAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;QACpD;QACA,KAAK,YAAY,EAAE;YACjB,MAAM,CAAC,GAAGQ,oCAA6B,CAAC,IAAI,CAAC,KAAK,CAAC;YACnD,IAAI,CAAC,KAAK,IAAI;AAAE,gBAAA,OAAO,EAAE;AACzB,YAAA,OAAO,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;QAC3B;QACA,SAAS;AACP,YAAA,QACEa,0CAAyB,CAAC,IAAI,CAAC;gBAC/BC,kDAA6B,CAAC,IAAI,CAAC;gBACnCC,0DAAgC,CAAC,IAAI,CAAC;gBACtCC,0CAAyB,CAAC,IAAI,CAAC;gBAC/BC,0CAAyB,CAAC,IAAI,CAAC;AAC/B,gBAAA,EAAE;QAEN;;AAEJ;;;;"}
|
|
1
|
+
{"version":3,"file":"declaration.cjs","sources":["../../../../../src/core/parser/declaration.ts"],"sourcesContent":["/* eslint-disable sonarjs/cognitive-complexity -- the main Declaration → RN-entries dispatcher is intentionally a flat switch so each branch keeps its narrowed value type */\nimport type { Declaration as LcDeclaration, TokenOrValue } from 'lightningcss'\nimport { kebabToCamel } from './case-convert'\nimport { cssColorToString, normalizeColorString } from './color'\nimport { dimensionPercentageToNumber, gapValueToValue, lengthPercentageOrAutoToValue, sizeLikeToValue } from './length'\nimport {\n expandBorderColor,\n expandBorderRadius,\n expandFourSided,\n expandGap,\n expandLogicalBlock,\n expandLogicalInline,\n flexToEntries,\n} from './shorthand'\nimport { coerceFontFamily, coerceUnparsedValue, serializeTokens, substituteThemeVars } from './tokens'\nimport { displayToEntries, fontSizeToPx, fontWeightToValue, zIndexToNumber } from './typography'\nimport { dispatchMotionDeclaration } from './motion-dispatcher'\nimport { dispatchTypographyDeclaration } from './typography-dispatcher'\nimport { dispatchLayoutDeclaration } from './layout-dispatcher'\nimport { dispatchColorPropertyDeclaration } from './color-properties-dispatcher'\nimport { dispatchBorderDeclaration } from './border-dispatcher'\nimport { detectSafeAreaMarker } from './safe-area'\nimport type { RNEntry } from './types'\n\n/** CSS timing-function properties that need `cubic-bezier(...)` snapping. */\nconst TIMING_FUNCTION_PROPS = new Set(['transition-timing-function', 'animation-timing-function'])\n\n/** CSS easing keywords Reanimated v4's CSS engine accepts as strings. */\nconst CSS_EASING_KEYWORDS = new Set(['linear', 'ease', 'ease-in', 'ease-out', 'ease-in-out', 'step-start', 'step-end'])\n\n/** CSS properties with no useful RN equivalent — silently dropped. */\nconst UNSUPPORTED_LOGICAL_PROPS = new Set([\n 'border-inline-style',\n 'border-block-style',\n 'border-inline-start-style',\n 'border-inline-end-style',\n 'border-block-start-style',\n 'border-block-end-style',\n])\n\n/**\n * Web-only CSS properties Tailwind v4 emits that have NO React Native style\n * equivalent. Without this denylist they reach the generic `kebabToCamel`\n * fallback and emit dead keys (`objectPosition`, `textWrap`, `willChange`,\n * `float`, `columns`, `-webkit-line-clamp` → `WebkitLineClamp`, …) that bloat\n * every StyleSheet and read as \"supported\" when they do nothing. Dropping the\n * property name (kebab-case, pre-camel) is safe: it only excludes known\n * web-only props — anything RN supports is handled by a typed branch above.\n * (line-clamp's real RN behaviour comes from `numberOfLines` in text-truncate.)\n */\nconst RN_UNSUPPORTED_PROPERTIES: ReadonlySet<string> = new Set([\n 'object-position',\n 'text-wrap',\n 'will-change',\n 'columns',\n 'float',\n 'clear',\n 'table-layout',\n 'caption-side',\n 'transform-style',\n 'background-blend-mode',\n 'scroll-behavior',\n 'overscroll-behavior',\n 'overscroll-behavior-x',\n 'overscroll-behavior-y',\n 'scroll-snap-type',\n 'scroll-snap-align',\n 'scroll-snap-stop',\n 'break-after',\n 'break-before',\n 'break-inside',\n 'content',\n 'field-sizing',\n 'forced-color-adjust',\n 'text-shadow',\n 'touch-action',\n 'backdrop-filter',\n '-webkit-backdrop-filter',\n '-webkit-line-clamp',\n '-webkit-box-orient',\n '-webkit-font-smoothing',\n '-moz-osx-font-smoothing',\n])\n\n/** CSS single-sided logical-inline property → RN writing-direction Yoga key. */\nconst LOGICAL_INLINE_TO_RN: Record<string, string> = {\n 'margin-inline-start': 'marginStart',\n 'margin-inline-end': 'marginEnd',\n 'padding-inline-start': 'paddingStart',\n 'padding-inline-end': 'paddingEnd',\n}\n\n/**\n * Logical border-COLOR property → physical RN side key(s). Custom `@theme`\n * tokens reach the unparsed path as `border-inline-color: var(--color-x)`,\n * which a plain `kebabToCamel` would turn into `borderInlineColor` — a key RN\n * silently drops, so the border color never paints. Lower to the physical\n * keys RN actually honors, matching the typed `dispatchBorderDeclaration`.\n */\nconst LOGICAL_BORDER_COLOR_SIDES: Record<string, readonly string[]> = {\n 'border-inline-color': ['borderLeftColor', 'borderRightColor'],\n 'border-block-color': ['borderTopColor', 'borderBottomColor'],\n 'border-inline-start-color': ['borderLeftColor'],\n 'border-inline-end-color': ['borderRightColor'],\n 'border-block-start-color': ['borderTopColor'],\n 'border-block-end-color': ['borderBottomColor'],\n}\n\n/**\n * Pick the closest predefined CSS easing keyword for a `cubic-bezier`\n * control-point set. Mirrors {@link snapCubicBezierToKeyword} in\n * `animation.ts` — kept here so the unparsed-string path doesn't need\n * to import a typed-only helper.\n * @param x1 First control-point x (0–1).\n * @param y1 First control-point y (0–1).\n * @param x2 Second control-point x (0–1).\n * @param y2 Second control-point y (0–1).\n * @returns CSS easing keyword.\n */\nfunction snapBezier(x1: number, y1: number, x2: number, y2: number): string {\n const tol = 0.01\n const eq = (a: number, b: number): boolean => Math.abs(a - b) < tol\n if (eq(x1, 0) && eq(y1, 0) && eq(x2, 1) && eq(y2, 1)) return 'linear'\n if (eq(x1, 0.25) && eq(y1, 0.1) && eq(x2, 0.25) && eq(y2, 1)) return 'ease'\n if (eq(x1, 0.4) && eq(y1, 0) && eq(x2, 1) && eq(y2, 1)) return 'ease-in'\n if (eq(x1, 0) && eq(y1, 0) && eq(x2, 0.2) && eq(y2, 1)) return 'ease-out'\n if (eq(x1, 0.4) && eq(y1, 0) && eq(x2, 0.2) && eq(y2, 1)) return 'ease-in-out'\n const startsFlat = x1 < 0.1\n const endsFlat = x2 > 0.9\n if (startsFlat && !endsFlat) return 'ease-out'\n if (!startsFlat && endsFlat) return 'ease-in'\n return 'ease-in-out'\n}\n\n/**\n * Snap a cubic-bezier expression string to the closest CSS keyword\n * Reanimated v4's CSS engine accepts. Strings that already are keywords\n * pass through unchanged.\n * @param value Resolved value text from an unparsed timing-function declaration.\n * @returns CSS easing keyword.\n */\nfunction coerceCubicBezierString(value: string): string {\n const text = value.trim()\n if (CSS_EASING_KEYWORDS.has(text)) return text\n const match = /^cubic-bezier\\(\\s*([\\d.-]+)\\s*,\\s*([\\d.-]+)\\s*,\\s*([\\d.-]+)\\s*,\\s*([\\d.-]+)\\s*\\)$/.exec(text)\n if (!match) return 'ease-in-out'\n const [, x1, y1, x2, y2] = match\n return snapBezier(Number(x1), Number(y1), Number(x2), Number(y2))\n}\n\n/**\n * Whether `text` has a whitespace char OUTSIDE any parenthesised group —\n * the signature of a multi-token CSS value (`2px solid #000`) rather than a\n * single color (`#000`, `rgb(1 2 3)`, `red`).\n * @param text Resolved value text.\n * @returns True when a top-level space is present.\n */\nfunction hasTopLevelSpace(text: string): boolean {\n let depth = 0\n for (const ch of text.trim()) {\n if (ch === '(') depth += 1\n else if (ch === ')') depth = Math.max(0, depth - 1)\n else if (depth === 0 && (ch === ' ' || ch === '\\t' || ch === '\\n')) return true\n }\n return false\n}\n\n/**\n * Fast-path check for the handful of color property names Tailwind emits.\n * @param property Kebab-case CSS property name.\n * @returns Whether the property's value should be treated as a color.\n */\nfunction isColorProperty(property: string): boolean {\n return (\n property === 'color' ||\n property === 'background-color' ||\n // SVG paint props (`fill-<token>` / `stroke-<token>` via react-native-svg) —\n // they don't end in `-color`, so without this they'd skip normalization and\n // leak a raw `oklch(…)` string for custom `@theme` tokens.\n property === 'fill' ||\n property === 'stroke' ||\n (property.startsWith('border-') && property.endsWith('-color')) ||\n property.endsWith('-color')\n )\n}\n\n/**\n * Convert an unparsed declaration (typical Tailwind v4 output containing\n * `var()` / `calc()`) into RN entries. Serializes the token list, then\n * coerces the flat string into a number / keyword / length via a tight\n * set of shapes Tailwind actually emits.\n * @param property Real property name (kebab-case).\n * @param tokens Token list from lightningcss.\n * @param themeVars Optional lookup table for resolving `var(--x)` references.\n * @returns RN entries — usually one, empty when unusable.\n */\nfunction unparsedToEntries(\n property: string,\n tokens: readonly TokenOrValue[],\n themeVars: ReadonlyMap<string, string> | undefined,\n): readonly RNEntry[] {\n if (property.length === 0) return []\n if (RN_UNSUPPORTED_PROPERTIES.has(property)) return []\n // Safe-area detection runs BEFORE token serialization because\n // `env()` serializes to an empty string, which would strip the side\n // info we need. If the tokens encode a recognised `env(safe-area-inset-*)`\n // pattern (pure / `max(..., n)` / `calc(...+n)` / `h-screen-safe`),\n // emit a runtime-resolved marker instead.\n if (UNSUPPORTED_LOGICAL_PROPS.has(property)) return []\n const safe = detectSafeAreaMarker(tokens, themeVars)\n if (safe !== null) return [[kebabToCamel(property), safe]]\n let text = serializeTokens(tokens)\n if (themeVars && themeVars.size > 0) text = substituteThemeVars(text, themeVars)\n const coerced = coerceUnparsedValue(text)\n if (coerced === null) return []\n // Skip values still carrying an unresolved `var(--tw-*)` ANYWHERE in the\n // string — they came from a `@property --tw-*` composable with no real\n // fallback (e.g. `filter: blur(8px) var(--tw-brightness) …`,\n // `transform: rotateX(45deg) var(--tw-rotate-y) …`, `touch-action`,\n // `scroll-snap-type`). RN can't evaluate the cascade, so a leaked `var()`\n // makes the whole declaration an invalid string RN rejects — drop it and\n // rely on RN's default rather than emit garbage. `var(--color-*)` refs are\n // already substituted above, so anything left is a genuine composable miss.\n if (typeof coerced === 'string' && coerced.includes('var(')) return []\n // RN `fontFamily` is a single typeface, not a CSS fallback list — take\n // the first family so `--font-x: \"Name\", sans-serif` works out of the box.\n if (property === 'font-family' && typeof coerced === 'string') {\n return [['fontFamily', coerceFontFamily(coerced)]]\n }\n // Logical-direction CSS properties RN doesn't have direct equivalents\n // for. Keep the dropped names in one place so it's easy to audit.\n if (UNSUPPORTED_LOGICAL_PROPS.has(property)) return []\n if (TIMING_FUNCTION_PROPS.has(property) && typeof coerced === 'string') {\n // `transition-colors` and similar emit `var(--tw-ease, cubic-bezier(...))`\n // which serializes to a cubic-bezier STRING after substitution.\n // Reanimated v4's CSS engine rejects those — snap to the closest\n // predefined keyword (same logic as the typed `EasingFunction` path).\n return [[kebabToCamel(property), coerceCubicBezierString(coerced)]]\n }\n if (isColorProperty(property) && typeof coerced === 'string') {\n // A color is a single token. Tailwind compiles an arbitrary shorthand like\n // `border-[2px_solid_#000]` to `border-color: 2px solid #000` (invalid for\n // a color property → unparsed), which would otherwise emit\n // `borderColor: \"2px solid #000000\"` — a string RN rejects. A top-level\n // space (outside parens — `rgb(1 2 3)` keeps its inner spaces) means it's a\n // multi-token shorthand, not a color: drop it.\n if (hasTopLevelSpace(coerced)) return []\n // Lower modern color spaces (`oklch(…)`, `lab(…)`, `color(p3 …)`) that\n // RN can't paint to sRGB; hex/rgb/hsl/named pass through unchanged.\n const color = normalizeColorString(coerced) ?? coerced\n // Logical border-color utilities must lower to physical RN side keys —\n // RN ignores `borderInlineColor` / `borderInlineStartColor`.\n const sides = LOGICAL_BORDER_COLOR_SIDES[property]\n if (sides) return sides.map((key): RNEntry => [key, color])\n return [[kebabToCamel(property), color]]\n }\n return [[kebabToCamel(property), coerced]]\n}\n\n/**\n * Convert one lightningcss `Declaration` into zero-or-more RN style\n * entries. Shorthand declarations (padding/margin/border-radius/flex) can\n * emit multiple entries; skipped or unsupported properties emit none.\n *\n * The switch branches on `decl.property` so TypeScript narrows\n * `decl.value` to the exact typed shape for each branch — no casts\n * required. Unknown properties fall through to `[]`.\n * @param decl One declaration from a lightningcss style rule.\n * @param themeVars Optional lookup table for resolving `var(--x)` references inside unparsed values.\n * @returns Array of `[key, value]` entries.\n */\nexport function declarationToRnEntries(decl: LcDeclaration, themeVars?: ReadonlyMap<string, string>): readonly RNEntry[] {\n switch (decl.property) {\n case 'custom': {\n // Lightningcss routes two shapes through `custom`:\n // - Actual CSS custom properties (`--my-var`): no RN meaning, drop.\n // - Real properties it doesn't have a dedicated typed entry for\n // (e.g. `object-fit`, `pointer-events`, future CSS keyword-only\n // props): treat like an unparsed declaration so the keyword\n // surfaces in the RN style.\n const customName = decl.value.name\n if (customName.startsWith('--')) return []\n return unparsedToEntries(customName, decl.value.value ?? [], themeVars)\n }\n case 'unparsed': {\n return unparsedToEntries(decl.value.propertyId.property, decl.value.value, themeVars)\n }\n case 'color':\n case 'background-color':\n case 'border-top-color':\n case 'border-right-color':\n case 'border-bottom-color':\n case 'border-left-color': {\n // `background-color` narrows to `CssColor | 'background'` — the\n // literal keyword means UA default. Skip the keyword.\n if (typeof decl.value === 'string') return []\n return [[kebabToCamel(decl.property), cssColorToString(decl.value)]]\n }\n case 'border-color': {\n return expandBorderColor(decl.value)\n }\n case 'opacity': {\n // Lightningcss hands us an `f32` for opacity, so values like `0.8`\n // round-trip as `0.800000011920929`. Snap to 4 decimals to match the\n // rest of the parser's numeric convention.\n return [[decl.property, Math.round(decl.value * 10_000) / 10_000]]\n }\n case 'z-index': {\n return [['zIndex', zIndexToNumber(decl.value)]]\n }\n case 'top':\n case 'right':\n case 'bottom':\n case 'left': {\n const v = lengthPercentageOrAutoToValue(decl.value)\n if (v === null) return []\n return [[decl.property, v]]\n }\n case 'inset': {\n const top = lengthPercentageOrAutoToValue(decl.value.top)\n const right = lengthPercentageOrAutoToValue(decl.value.right)\n const bottom = lengthPercentageOrAutoToValue(decl.value.bottom)\n const left = lengthPercentageOrAutoToValue(decl.value.left)\n if (top === null || right === null || bottom === null || left === null) return []\n return [\n ['top', top],\n ['right', right],\n ['bottom', bottom],\n ['left', left],\n ]\n }\n case 'inset-inline': {\n const start = lengthPercentageOrAutoToValue(decl.value.inlineStart)\n const end = lengthPercentageOrAutoToValue(decl.value.inlineEnd)\n if (start === null || end === null) return []\n return [\n ['left', start],\n ['right', end],\n ]\n }\n case 'inset-block': {\n const start = lengthPercentageOrAutoToValue(decl.value.blockStart)\n const end = lengthPercentageOrAutoToValue(decl.value.blockEnd)\n if (start === null || end === null) return []\n return [\n ['top', start],\n ['bottom', end],\n ]\n }\n case 'width':\n case 'height':\n case 'min-width':\n case 'min-height':\n case 'max-width':\n case 'max-height': {\n const v = sizeLikeToValue(decl.value)\n if (v === null) return []\n return [[kebabToCamel(decl.property), v]]\n }\n case 'gap': {\n return expandGap(decl.value)\n }\n case 'row-gap':\n case 'column-gap': {\n const v = gapValueToValue(decl.value)\n if (v === null) return []\n return [[kebabToCamel(decl.property), v]]\n }\n case 'font-style': {\n return [['fontStyle', decl.value.type]]\n }\n case 'display': {\n return displayToEntries(decl.value)\n }\n case 'position': {\n return [['position', decl.value.type]]\n }\n case 'font-size': {\n const px = fontSizeToPx(decl.value)\n if (px === null) return []\n return [['fontSize', px]]\n }\n case 'font-weight': {\n return [['fontWeight', fontWeightToValue(decl.value)]]\n }\n case 'padding': {\n return expandFourSided('padding', decl.value)\n }\n case 'margin': {\n return expandFourSided('margin', decl.value)\n }\n case 'padding-inline': {\n return expandLogicalInline('padding', decl.value)\n }\n case 'padding-block': {\n return expandLogicalBlock('padding', decl.value)\n }\n case 'margin-inline': {\n return expandLogicalInline('margin', decl.value)\n }\n case 'margin-block': {\n return expandLogicalBlock('margin', decl.value)\n }\n case 'padding-top':\n case 'padding-right':\n case 'padding-bottom':\n case 'padding-left':\n case 'margin-top':\n case 'margin-right':\n case 'margin-bottom':\n case 'margin-left': {\n const v = lengthPercentageOrAutoToValue(decl.value)\n if (v === null) return []\n return [[kebabToCamel(decl.property), v]]\n }\n case 'border-radius': {\n return expandBorderRadius(decl.value)\n }\n case 'border-top-left-radius':\n case 'border-top-right-radius':\n case 'border-bottom-left-radius':\n case 'border-bottom-right-radius': {\n const [xAxis] = decl.value\n const v = dimensionPercentageToNumber(xAxis)\n if (v === null) return []\n return [[kebabToCamel(decl.property), v]]\n }\n case 'flex': {\n return flexToEntries(decl.value)\n }\n case 'flex-grow':\n case 'flex-shrink': {\n return [[kebabToCamel(decl.property), decl.value]]\n }\n case 'flex-basis': {\n const v = lengthPercentageOrAutoToValue(decl.value)\n if (v === null) return []\n return [['flexBasis', v]]\n }\n default: {\n return (\n dispatchLogicalInline(decl) ??\n dispatchLayoutDeclaration(decl) ??\n dispatchTypographyDeclaration(decl) ??\n dispatchColorPropertyDeclaration(decl) ??\n dispatchBorderDeclaration(decl) ??\n dispatchMotionDeclaration(decl) ??\n []\n )\n }\n }\n}\n\n/**\n * Map single-sided CSS logical-inline props to RN's writing-direction-aware\n * Yoga keys: `ms-2` → `marginStart`, `pe-4` → `paddingEnd`, `start-2` →\n * `start`, `end-3` → `end`. RN resolves start/end against the layout\n * direction, so these stay RTL-correct. Returns null for any other property\n * (so the dispatch chain continues).\n * @param decl One declaration from a lightningcss style rule.\n * @returns RN entries, or null when not a logical-inline property.\n */\nfunction dispatchLogicalInline(decl: LcDeclaration): readonly RNEntry[] | null {\n switch (decl.property) {\n case 'margin-inline-start':\n case 'margin-inline-end':\n case 'padding-inline-start':\n case 'padding-inline-end': {\n const v = lengthPercentageOrAutoToValue(decl.value)\n return v === null ? [] : [[LOGICAL_INLINE_TO_RN[decl.property], v]]\n }\n case 'inset-inline-start': {\n const v = lengthPercentageOrAutoToValue(decl.value)\n return v === null ? [] : [['start', v]]\n }\n case 'inset-inline-end': {\n const v = lengthPercentageOrAutoToValue(decl.value)\n return v === null ? [] : [['end', v]]\n }\n // Logical border-radius corners (`rounded-s/e/ss/se/ee/es-*`). RN has\n // matching keys — `kebabToCamel('border-start-start-radius')` is exactly\n // `borderStartStartRadius`. Value is a `[x, y]` tuple like physical corners.\n case 'border-start-start-radius':\n case 'border-start-end-radius':\n case 'border-end-start-radius':\n case 'border-end-end-radius': {\n const [xAxis] = decl.value\n const v = dimensionPercentageToNumber(xAxis)\n return v === null ? [] : [[kebabToCamel(decl.property), v]]\n }\n default: {\n return null\n }\n }\n}\n"],"names":["tokens","detectSafeAreaMarker","kebabToCamel","serializeTokens","substituteThemeVars","coerceUnparsedValue","coerceFontFamily","color","normalizeColorString","cssColorToString","expandBorderColor","zIndexToNumber","lengthPercentageOrAutoToValue","sizeLikeToValue","expandGap","gapValueToValue","displayToEntries","fontSizeToPx","fontWeightToValue","expandFourSided","expandLogicalInline","expandLogicalBlock","expandBorderRadius","dimensionPercentageToNumber","flexToEntries","dispatchLayoutDeclaration","dispatchTypographyDeclaration","dispatchColorPropertyDeclaration","dispatchBorderDeclaration","dispatchMotionDeclaration"],"mappings":";;;;;;;;;;;;;;;AAwBA;AACA,MAAM,qBAAqB,GAAG,IAAI,GAAG,CAAC,CAAC,4BAA4B,EAAE,2BAA2B,CAAC,CAAC;AAElG;AACA,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,aAAa,EAAE,YAAY,EAAE,UAAU,CAAC,CAAC;AAEvH;AACA,MAAM,yBAAyB,GAAG,IAAI,GAAG,CAAC;IACxC,qBAAqB;IACrB,oBAAoB;IACpB,2BAA2B;IAC3B,yBAAyB;IACzB,0BAA0B;IAC1B,wBAAwB;AACzB,CAAA,CAAC;AAEF;;;;;;;;;AASG;AACH,MAAM,yBAAyB,GAAwB,IAAI,GAAG,CAAC;IAC7D,iBAAiB;IACjB,W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K,oBAAoB,EAAE;YACzB,MAAM,CAAC,GAAGjB,oCAA6B,CAAC,IAAI,CAAC,KAAK,CAAC;YACnD,OAAO,CAAC,KAAK,IAAI,GAAG,EAAE,GAAG,CAAC,CAAC,oBAAoB,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;QACrE;QACA,KAAK,oBAAoB,EAAE;YACzB,MAAM,CAAC,GAAGA,oCAA6B,CAAC,IAAI,CAAC,KAAK,CAAC;AACnD,YAAA,OAAO,CAAC,KAAK,IAAI,GAAG,EAAE,GAAG,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;QACzC;QACA,KAAK,kBAAkB,EAAE;YACvB,MAAM,CAAC,GAAGA,oCAA6B,CAAC,IAAI,CAAC,KAAK,CAAC;AACnD,YAAA,OAAO,CAAC,KAAK,IAAI,GAAG,EAAE,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QACvC;;;;AAIA,QAAA,KAAK,2BAA2B;AAChC,QAAA,KAAK,yBAAyB;AAC9B,QAAA,KAAK,yBAAyB;QAC9B,KAAK,uBAAuB,EAAE;AAC5B,YAAA,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,KAAK;AAC1B,YAAA,MAAM,CAAC,GAAGW,kCAA2B,CAAC,KAAK,CAAC;YAC5C,OAAO,CAAC,KAAK,IAAI,GAAG,EAAE,GAAG,CAAC,CAACrB,wBAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;QAC7D;QACA,SAAS;AACP,YAAA,OAAO,IAAI;QACb;;AAEJ;;;;"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var culori = require('culori');
|
|
3
4
|
var color = require('./color.cjs');
|
|
5
|
+
var tokens = require('./tokens.cjs');
|
|
4
6
|
|
|
5
7
|
/**
|
|
6
8
|
* Gradient-atom extractor.
|
|
@@ -30,9 +32,10 @@ var color = require('./color.cjs');
|
|
|
30
32
|
* return the atom's role + data. Returns `null` for rules that don't
|
|
31
33
|
* belong to a gradient utility.
|
|
32
34
|
* @param declarations Declarations from one lightningcss style rule.
|
|
35
|
+
* @param themeVars
|
|
33
36
|
* @returns Gradient info, or null.
|
|
34
37
|
*/
|
|
35
|
-
function detectGradientAtom(declarations) {
|
|
38
|
+
function detectGradientAtom(declarations, themeVars) {
|
|
36
39
|
for (const decl of declarations) {
|
|
37
40
|
if (decl.property !== 'custom')
|
|
38
41
|
continue;
|
|
@@ -41,29 +44,53 @@ function detectGradientAtom(declarations) {
|
|
|
41
44
|
if (!name.startsWith('--tw-gradient-'))
|
|
42
45
|
continue;
|
|
43
46
|
if (name === '--tw-gradient-from')
|
|
44
|
-
return fromColor('from', custom.value);
|
|
47
|
+
return fromColor('from', custom.value, themeVars);
|
|
45
48
|
if (name === '--tw-gradient-via')
|
|
46
|
-
return fromColor('via', custom.value);
|
|
49
|
+
return fromColor('via', custom.value, themeVars);
|
|
47
50
|
if (name === '--tw-gradient-to')
|
|
48
|
-
return fromColor('to', custom.value);
|
|
51
|
+
return fromColor('to', custom.value, themeVars);
|
|
49
52
|
if (name === '--tw-gradient-position')
|
|
50
53
|
return fromDirection(custom.value);
|
|
51
54
|
}
|
|
52
55
|
return null;
|
|
53
56
|
}
|
|
54
57
|
/**
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
58
|
+
* Lower a resolved gradient-stop color string to one RN's `LinearGradient`
|
|
59
|
+
* `colors=` array accepts. Hex/rgb/hsl pass through; modern spaces
|
|
60
|
+
* (`oklch(…)`, `lab(…)`, `color(p3 …)`) and named colors go through culori.
|
|
61
|
+
* @param text Resolved color text (post theme-var substitution).
|
|
62
|
+
* @returns sRGB color string, or null when unparseable.
|
|
63
|
+
*/
|
|
64
|
+
function resolveGradientColor(text) {
|
|
65
|
+
if (text.startsWith('#') || text.startsWith('rgb') || text.startsWith('hsl'))
|
|
66
|
+
return text;
|
|
67
|
+
const normalized = color.normalizeColorString(text);
|
|
68
|
+
if (normalized)
|
|
69
|
+
return normalized;
|
|
70
|
+
try {
|
|
71
|
+
const hex = culori.formatHex(text);
|
|
72
|
+
return typeof hex === 'string' ? hex : null;
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Extract a stop color from a `--tw-gradient-*` value list. The default
|
|
80
|
+
* Tailwind palette is inlined to a typed `color` token; CUSTOM `@theme`
|
|
81
|
+
* tokens arrive as an unresolved `var(--color-x)` token list, so when no
|
|
82
|
+
* typed color is present we serialize, substitute `themeVars`, and lower
|
|
83
|
+
* the result to sRGB — without this, `from-<token>` / `via-<token>` /
|
|
84
|
+
* `to-<token>` dropped the stop entirely.
|
|
59
85
|
* @param role Target role (`from` / `via` / `to`).
|
|
60
86
|
* @param tokens Value tokens from the `--tw-gradient-*` declaration.
|
|
87
|
+
* @param themeVars Per-scheme var table for resolving `var(--color-x)`.
|
|
61
88
|
* @returns Gradient info, or null.
|
|
62
89
|
*/
|
|
63
|
-
function fromColor(role, tokens) {
|
|
64
|
-
if (!tokens)
|
|
90
|
+
function fromColor(role, tokens$1, themeVars) {
|
|
91
|
+
if (!tokens$1)
|
|
65
92
|
return null;
|
|
66
|
-
for (const token of tokens) {
|
|
93
|
+
for (const token of tokens$1) {
|
|
67
94
|
if (token.type !== 'color')
|
|
68
95
|
continue;
|
|
69
96
|
const color$1 = color.cssColorToString(token.value);
|
|
@@ -71,7 +98,14 @@ function fromColor(role, tokens) {
|
|
|
71
98
|
return null;
|
|
72
99
|
return { role, color: color$1 };
|
|
73
100
|
}
|
|
74
|
-
|
|
101
|
+
// Custom @theme token: value is `var(--color-x)` — serialize + resolve.
|
|
102
|
+
let text = tokens.serializeTokens(tokens$1).trim();
|
|
103
|
+
if (themeVars && themeVars.size > 0)
|
|
104
|
+
text = tokens.substituteThemeVars(text, themeVars);
|
|
105
|
+
if (text.length === 0 || text.startsWith('var('))
|
|
106
|
+
return null;
|
|
107
|
+
const color$1 = resolveGradientColor(text);
|
|
108
|
+
return color$1 ? { role, color: color$1 } : null;
|
|
75
109
|
}
|
|
76
110
|
/**
|
|
77
111
|
* Interpret a `--tw-gradient-position` value list as a direction tag.
|