Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/css-color-parser/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changes to CSS Color Parser

### Unreleased (minor)

- Add a `serializeHSL` function.

### 1.4.0

_October 9, 2023_
Expand Down
2 changes: 1 addition & 1 deletion packages/css-color-parser/dist/index.cjs

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions packages/css-color-parser/dist/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ export { SyntaxFlag } from './color-data';
export { colorDataTo, colorDataFitsRGB_Gamut, colorDataFitsDisplayP3_Gamut } from './color-data';
export { serializeP3 } from './serialize/p3';
export { serializeRGB } from './serialize/rgb';
export { serializeHSL } from './serialize/hsl';
export { serializeOKLCH } from './serialize/oklch';
export declare function color(colorNode: ComponentValue): ColorData | false;
2 changes: 1 addition & 1 deletion packages/css-color-parser/dist/index.mjs

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions packages/css-color-parser/dist/serialize/hsl.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { ColorData } from '../color-data';
import { FunctionNode } from '@csstools/css-parser-algorithms';
export declare function serializeHSL(color: ColorData, gamutMapping?: boolean): FunctionNode;
1 change: 1 addition & 0 deletions packages/css-color-parser/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export { SyntaxFlag } from './color-data';
export { colorDataTo, colorDataFitsRGB_Gamut, colorDataFitsDisplayP3_Gamut } from './color-data';
export { serializeP3 } from './serialize/p3';
export { serializeRGB } from './serialize/rgb';
export { serializeHSL } from './serialize/hsl';
export { serializeOKLCH } from './serialize/oklch';

export function color(colorNode: ComponentValue): ColorData | false {
Expand Down
75 changes: 75 additions & 0 deletions packages/css-color-parser/src/serialize/hsl.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import { ColorData, convertPowerlessComponentsToZeroValuesForDisplay } from '../color-data';
import type { TokenCloseParen, TokenComma, TokenWhitespace } from '@csstools/css-tokenizer';
import { FunctionNode, TokenNode, WhitespaceNode } from '@csstools/css-parser-algorithms';
import { NumberType, TokenType } from '@csstools/css-tokenizer';
import { xyz } from '@csstools/color-helpers';
import { colorData_to_XYZ_D50 } from '../color-data';
import { toPrecision } from './to-precision';
import { XYZ_D50_to_sRGB_Gamut } from '../gamut-mapping/srgb';

export function serializeHSL(color: ColorData, gamutMapping = true): FunctionNode {
color.channels = convertPowerlessComponentsToZeroValuesForDisplay(color.channels, color.colorNotation);
let hsl = color.channels.map((x) => Number.isNaN(x) ? 0 : x);

if (gamutMapping) {
hsl = xyz.XYZ_D50_to_HSL(xyz.sRGB_to_XYZ_D50(
XYZ_D50_to_sRGB_Gamut(colorData_to_XYZ_D50(color).channels),
));
} else {
hsl = xyz.XYZ_D50_to_HSL(colorData_to_XYZ_D50(color).channels);
}

// Needs to be done twice because `xyz.XYZ_D50_to_HSL` can return `NaN` values.
hsl = hsl.map((x) => Number.isNaN(x) ? 0 : x);

const h = Math.min(360, Math.max(0, Math.round(toPrecision(hsl[0]))));
const s = Math.min(100, Math.max(0, Math.round(toPrecision(hsl[1]))));
const l = Math.min(100, Math.max(0, Math.round(toPrecision(hsl[2]))));

const close: TokenCloseParen = [TokenType.CloseParen, ')', -1, -1, undefined];
const space: TokenWhitespace = [TokenType.Whitespace, ' ', -1, -1, undefined];
const comma: TokenComma = [TokenType.Comma, ',', -1, -1, undefined];

const channels = [
new TokenNode([TokenType.Number, h.toString(), -1, -1, { value: hsl[0], type: NumberType.Integer }]),
new TokenNode(comma),
new WhitespaceNode([space]),
new TokenNode([TokenType.Percentage, s.toString() + '%', -1, -1, { value: hsl[1] }]),
new TokenNode(comma),
new WhitespaceNode([space]),
new TokenNode([TokenType.Percentage, l.toString() + '%', -1, -1, { value: hsl[2] }]),
];

if (typeof color.alpha === 'number') {
const a = Math.min(1, Math.max(0, toPrecision(Number.isNaN(color.alpha) ? 0 : color.alpha)));
if (toPrecision(a, 4) === 1) {
return new FunctionNode(
[TokenType.Function, 'hsl(', -1, -1, { value: 'hsl' }],
close,
channels,
);
}

return new FunctionNode(
[TokenType.Function, 'hsla(', -1, -1, { value: 'hsla' }],
close,
[
...channels,
new TokenNode(comma),
new WhitespaceNode([space]),
new TokenNode([TokenType.Number, toPrecision(a, 4).toString(), -1, -1, { value: color.alpha, type: NumberType.Number }]),
],
);
}

return new FunctionNode(
[TokenType.Function, 'hsla(', -1, -1, { value: 'hsla' }],
close,
[
...channels,
new TokenNode(comma),
new WhitespaceNode([space]),
color.alpha,
],
);
}
17 changes: 16 additions & 1 deletion packages/css-color-parser/test/basic/basic.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { color } from '@csstools/css-color-parser';
import assert from 'assert';
import { parse } from '../util/parse.mjs';
import { serialize_sRGB_data } from '../util/serialize.mjs';
import { serialize_HSL_data, serialize_sRGB_data } from '../util/serialize.mjs';

[
'rgb( )',
Expand Down Expand Up @@ -159,3 +159,18 @@ assert.deepStrictEqual(
serialize_sRGB_data(color(parse('color-mix(in srgb, red min(10%, 20%), blue)'))),
'rgb(26, 0, 230)',
);

assert.deepStrictEqual(
serialize_HSL_data(color(parse('hsl(50deg 50 65% / 0.5)'))),
'hsla(50, 50%, 65%, 0.5)',
);

assert.deepStrictEqual(
serialize_HSL_data(color(parse('hsla(50deg, 50%, 65%, 45%)'))),
'hsla(50, 50%, 65%, 0.45)',
);

assert.deepStrictEqual(
serialize_HSL_data(color(parse('hsl(0 0% 100%)'))),
'hsl(0, 0%, 100%)',
);
10 changes: 9 additions & 1 deletion packages/css-color-parser/test/util/serialize.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { serializeRGB, serializeP3, serializeOKLCH } from '@csstools/css-color-parser';
import { serializeRGB, serializeP3, serializeOKLCH, serializeHSL } from '@csstools/css-color-parser';

export function serialize_sRGB_data(x) {
if (!x) {
Expand All @@ -8,6 +8,14 @@ export function serialize_sRGB_data(x) {
return serializeRGB(x).toString();
}

export function serialize_HSL_data(x) {
if (!x) {
return '';
}

return serializeHSL(x).toString();
}

export function serialize_P3_data(x) {
if (!x) {
return '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
}

.test-color-functional-notation {
color: rgba(178, 34, 34, 0.5);
color: rgba(179, 34, 34, 0.5);
order: 16;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
}

.test-color-functional-notation {
color: rgba(178, 34, 34, 0.5);
color: rgba(179, 34, 34, 0.5);
order: 16;
}

Expand Down
2 changes: 1 addition & 1 deletion plugin-packs/postcss-preset-env/test/basic.ch38.expect.css
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
}

.test-color-functional-notation {
color: rgba(178, 34, 34, 0.5);
color: rgba(179, 34, 34, 0.5);
order: 16;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ h1.test-custom-selectors:not(.does-not-exist), h2.test-custom-selectors:not(.doe
}

.test-color-functional-notation {
color: rgba(178, 34, 34, 0.5);
color: rgba(179, 34, 34, 0.5);
order: 16;
}

Expand Down
2 changes: 1 addition & 1 deletion plugin-packs/postcss-preset-env/test/basic.expect.css
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
}

.test-color-functional-notation {
color: rgba(178, 34, 34, 0.5);
color: rgba(179, 34, 34, 0.5);
order: 16;
}

Expand Down
2 changes: 1 addition & 1 deletion plugin-packs/postcss-preset-env/test/basic.ff49.expect.css
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
}

.test-color-functional-notation {
color: rgba(178, 34, 34, 0.5);
color: rgba(179, 34, 34, 0.5);
order: 16;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ h1.test-custom-selectors:not(.does-not-exist), h2.test-custom-selectors:not(.doe
}

.test-color-functional-notation {
color: rgba(178, 34, 34, 0.5);
color: rgba(179, 34, 34, 0.5);
order: 16;
}

Expand Down
2 changes: 1 addition & 1 deletion plugin-packs/postcss-preset-env/test/basic.ie10.expect.css
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
}

.test-color-functional-notation {
color: rgba(178, 34, 34, 0.5);
color: rgba(179, 34, 34, 0.5);
-ms-flex-order: 16;
order: 16;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ h1.test-custom-selectors:not(.does-not-exist), h2.test-custom-selectors:not(.doe
}

.test-color-functional-notation {
color: rgba(178, 34, 34, 0.5);
color: rgba(179, 34, 34, 0.5);
order: 16;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ h1.test-custom-selectors:not(.does-not-exist), h2.test-custom-selectors:not(.doe
}

.test-color-functional-notation {
color: rgba(178, 34, 34, 0.5);
color: rgba(179, 34, 34, 0.5);
order: 16;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ h1.test-custom-selectors:not(.does-not-exist), h2.test-custom-selectors:not(.doe
}

.test-color-functional-notation {
color: rgba(178, 34, 34, 0.5);
color: rgba(179, 34, 34, 0.5);
-webkit-box-ordinal-group: 17;
-webkit-order: 16;
-moz-box-ordinal-group: 17;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ h1.test-custom-selectors:not(.does-not-exist), h2.test-custom-selectors:not(.doe
}

.test-color-functional-notation {
color: rgba(178, 34, 34, 0.5);
color: rgba(179, 34, 34, 0.5);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was always wrong, the color package is much more correct than what existed in the functional notation plugin.

color: rgb(70% 13.5% 13.5% / 50%);
-webkit-box-ordinal-group: 17;
-webkit-order: 16;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ h1.test-custom-selectors:not(.does-not-exist), h2.test-custom-selectors:not(.doe
}

.test-color-functional-notation {
color: rgba(178, 34, 34, 0.5);
color: rgba(179, 34, 34, 0.5);
order: 16;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ h1.test-custom-selectors:not(.does-not-exist), h2.test-custom-selectors:not(.doe
}

.test-color-functional-notation {
color: rgba(178, 34, 34, 0.5);
color: rgba(179, 34, 34, 0.5);
order: 16;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
}

.test-color-functional-notation {
color: rgba(178, 34, 34, 0.5);
color: rgba(179, 34, 34, 0.5);
order: 16;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
}

.test-color-functional-notation {
color: rgba(178, 34, 34, 0.5);
color: rgba(179, 34, 34, 0.5);
order: 16;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
}

.test-color-functional-notation {
color: rgba(178, 34, 34, 0.5);
color: rgba(179, 34, 34, 0.5);
order: 16;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ h1.test-custom-selectors:not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):n
}

.test-color-functional-notation:not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#) {
color: rgba(178, 34, 34, 0.5);
color: rgba(179, 34, 34, 0.5);
-webkit-box-ordinal-group: 17;
-webkit-order: 16;
-moz-box-ordinal-group: 17;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ h1.test-custom-selectors:not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):n
}

.test-color-functional-notation:not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#):not(#\#) {
color: rgba(178, 34, 34, 0.5);
color: rgba(179, 34, 34, 0.5);
color: rgb(70% 13.5% 13.5% / 50%);
-webkit-box-ordinal-group: 17;
-webkit-order: 16;
Expand Down
4 changes: 4 additions & 0 deletions plugins/postcss-color-functional-notation/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changes to PostCSS Color Functional Notation

### Unreleased (patch)

- Ensure that fallback values are always valid legacy syntax.

### 6.0.2

_October 9, 2023_
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import type { Node } from 'postcss';
export declare const rgb_hsl_functionRegex: RegExp;
export declare function hasSupportsAtRuleAncestor(node: Node): boolean;
2 changes: 1 addition & 1 deletion plugins/postcss-color-functional-notation/dist/index.cjs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
"use strict";var e=require("@csstools/postcss-progressive-custom-properties"),r=require("postcss-value-parser");function onCSSFunction(e){const r=e.value.toLowerCase();if(!needsConversion("rgb"===r||"rgba"===r,e.nodes))return;const n=convertOldSyntaxToNewSyntaxBeforeTransform(e.nodes).slice().filter((e=>"comment"!==e.type&&"space"!==e.type));let t=null;if("hsl"===r||"hsla"===r?t=hslFunctionContents(n):"rgb"!==r&&"rgba"!==r||(t=rgbFunctionContents(n)),!t)return;if(n.length>3&&(!t.slash||!t.alpha))return;transformAlpha(e,t.slash,t.alpha);const[o,u]=channelNodes(t);e.nodes.splice(e.nodes.indexOf(o)+1,0,{sourceIndex:0,sourceEndIndex:1,value:",",type:"div",before:"",after:""}),e.nodes.splice(e.nodes.indexOf(u)+1,0,{sourceIndex:0,sourceEndIndex:1,value:",",type:"div",before:"",after:""})}function isNumericNode(e){if(!e||"word"!==e.type)return!1;if(!canParseAsUnit(e))return!1;const n=r.unit(e.value);return!!n&&!!n.number}function isNumericNodeHueLike(e){if(!e||"word"!==e.type)return!1;if(!canParseAsUnit(e))return!1;const n=r.unit(e.value);if(!n)return!1;const t=n.unit.toLowerCase();return!!n.number&&("deg"===t||"grad"===t||"rad"===t||"turn"===t||""===n.unit)}function isNumericNodePercentageOrNumber(e){if(!e||"word"!==e.type)return!1;if(!canParseAsUnit(e))return!1;const n=r.unit(e.value);return!!n&&("%"===n.unit||""===n.unit)}function isCalcNode(e){return e&&"function"===e.type&&"calc"===e.value.toLowerCase()}function isVarNode(e){return e&&"function"===e.type&&"var"===e.value.toLowerCase()}function isSlashNode(e){return e&&"div"===e.type&&"/"===e.value}function hslFunctionContents(e){if(!isNumericNodeHueLike(e[0]))return null;if(!isNumericNodePercentageOrNumber(e[1]))return null;if(!isNumericNodePercentageOrNumber(e[2]))return null;const n={h:r.unit(e[0].value),hNode:e[0],s:r.unit(e[1].value),sNode:e[1],l:r.unit(e[2].value),lNode:e[2]};return normalizeHueNode(n.h),""!==n.h.unit?null:(n.hNode.value=n.h.number,isSlashNode(e[3])&&(n.slash=e[3]),(isNumericNodePercentageOrNumber(e[4])||isCalcNode(e[4])||isVarNode(e[4]))&&(n.alpha=e[4]),n)}function rgbFunctionContents(e){if(!isNumericNodePercentageOrNumber(e[0]))return null;if(!isNumericNodePercentageOrNumber(e[1]))return null;if(!isNumericNodePercentageOrNumber(e[2]))return null;const n={r:r.unit(e[0].value),rNode:e[0],g:r.unit(e[1].value),gNode:e[1],b:r.unit(e[2].value),bNode:e[2]};return"%"===n.r.unit&&(n.r.number=String(Math.floor(Number(n.r.number)/100*255)),n.rNode.value=n.r.number),"%"===n.g.unit&&(n.g.number=String(Math.floor(Number(n.g.number)/100*255)),n.gNode.value=n.g.number),"%"===n.b.unit&&(n.b.number=String(Math.floor(Number(n.b.number)/100*255)),n.bNode.value=n.b.number),isSlashNode(e[3])&&(n.slash=e[3]),(isNumericNodePercentageOrNumber(e[4])||isCalcNode(e[4])||isVarNode(e[4]))&&(n.alpha=e[4]),n}function isRgb(e){return void 0!==e.r}function channelNodes(e){return isRgb(e)?[e.rNode,e.gNode,e.bNode]:[e.hNode,e.sNode,e.lNode]}function transformAlpha(e,n,t){if("hsl"===e.value.toLowerCase()||"hsla"===e.value.toLowerCase()?e.value="hsl":"rgb"!==e.value.toLowerCase()&&"rgba"!==e.value.toLowerCase()||(e.value="rgb"),!n||!t)return;if("hsl"===e.value.toLowerCase()?e.value="hsla":e.value="rgba",n.value=",",n.before="",!isNumericNode(t))return;const o=r.unit(t.value);o&&"%"===o.unit&&(o.number=String(parseFloat(o.number)/100),t.value=String(o.number))}function normalizeHueNode(e){switch(e.unit.toLowerCase()){case"deg":return void(e.unit="");case"rad":return e.unit="",void(e.number=Math.round(180*parseFloat(e.number)/Math.PI).toString());case"grad":return e.unit="",void(e.number=Math.round(.9*parseFloat(e.number)).toString());case"turn":return e.unit="",void(e.number=Math.round(360*parseFloat(e.number)).toString())}}function canParseAsUnit(e){if(!e||!e.value)return!1;try{return!1!==r.unit(e.value)}catch(e){return!1}}function convertOldSyntaxToNewSyntaxBeforeTransform(e){let r=0;for(let n=0;n<e.length;n++){const t=e[n];if("div"===t.type&&","===t.value){if(r<2&&(t.value=" ",t.type="space"),2===r&&(t.value="/"),r>2)return[];r++}}return e}function needsConversion(e,r){let n=!1,t=!1,o=!1;const u=r.slice().filter((e=>"comment"!==e.type&&"space"!==e.type));for(let s=0;s<u.length;s++){const a=u[s];if("word"===a.type&&"from"===a.value.toLowerCase())return!1;"div"!==a.type||","!==a.value?e&&"word"===a.type&&a.value.endsWith("%")?o=!0:s===r.length-1&&"word"===a.type&&a.value.endsWith("%")&&(t=!0):n=!0}return!(!n||!t&&!o)||!n}const n=/(\(color: rgb(a?)\(0 0 0 \/ 0)|(\(color: hsl(a?)\(0 0% 0% \/ 0)/i;function hasSupportsAtRuleAncestor(e){let r=e.parent;for(;r;)if("atrule"===r.type){if("supports"===r.name&&n.test(r.params))return!0;r=r.parent}else r=r.parent;return!1}function hasFallback(e){const r=e.parent;if(!r)return!1;const n=e.prop.toLowerCase(),t=r.index(e);for(let e=0;e<t;e++){const t=r.nodes[e];if("decl"===t.type&&t.prop.toLowerCase()===n)return!0}return!1}const t=/(?:rgb|hsl)a?\(/i,basePlugin=e=>({postcssPlugin:"postcss-color-function",Declaration:(n,{result:o})=>{const u=n.value;if(!t.test(u))return;if(hasFallback(n))return;if(hasSupportsAtRuleAncestor(n))return;let s;try{s=r(u)}catch(e){n.warn(o,`Failed to parse value '${u}' as a hsl or rgb function. Leaving the original value intact.`)}if(void 0===s)return;s.walk((e=>{if(!e.type||"function"!==e.type)return;const r=e.value.toLowerCase();"hsl"!==r&&"hsla"!==r&&"rgb"!==r&&"rgba"!==r||onCSSFunction(e)}));const a=String(s);a!==u&&(n.cloneBefore({value:a}),null!=e&&e.preserve||n.remove())}});basePlugin.postcss=!0;const postcssPlugin=r=>{const n=Object.assign({preserve:!1,enableProgressiveCustomProperties:!0},r);return n.enableProgressiveCustomProperties&&n.preserve?{postcssPlugin:"postcss-color-function",plugins:[e(),basePlugin(n)]}:basePlugin(n)};postcssPlugin.postcss=!0,module.exports=postcssPlugin;
"use strict";var s=require("@csstools/postcss-progressive-custom-properties"),e=require("@csstools/css-tokenizer"),t=require("@csstools/css-color-parser"),r=require("@csstools/css-parser-algorithms");function hasFallback(s){const e=s.parent;if(!e)return!1;const t=s.prop.toLowerCase(),r=e.index(s);for(let s=0;s<r;s++){const r=e.nodes[s];if("decl"===r.type&&r.prop.toLowerCase()===t)return!0}return!1}const o=/(?:rgb|hsl)a?\(/i;function hasSupportsAtRuleAncestor(s){let e=s.parent;for(;e;)if("atrule"===e.type){if("supports"===e.name.toLowerCase()&&o.test(e.params))return!0;e=e.parent}else e=e.parent;return!1}const a=/^(?:rgb|hsl)a?$/i,basePlugin=s=>({postcssPlugin:"postcss-color-functional-notation",Declaration:n=>{const l=n.value;if(!o.test(l))return;if(hasFallback(n))return;if(hasSupportsAtRuleAncestor(n))return;const i=r.replaceComponentValues(r.parseCommaSeparatedListOfComponentValues(e.tokenize({css:l})),(s=>{if(r.isFunctionNode(s)&&a.test(s.getName())){const e=t.color(s);if(!e)return;if(e.syntaxFlags.has(t.SyntaxFlag.HasNoneKeywords))return;if(e.syntaxFlags.has(t.SyntaxFlag.RelativeColorSyntax))return;if((e.syntaxFlags.has(t.SyntaxFlag.LegacyRGB)||e.syntaxFlags.has(t.SyntaxFlag.LegacyHSL))&&!e.syntaxFlags.has(t.SyntaxFlag.HasPercentageAlpha))return;return"hsl"===e.colorNotation?t.serializeHSL(e):t.serializeRGB(e)}})),c=r.stringify(i);c!==l&&(n.cloneBefore({value:c}),null!=s&&s.preserve||n.remove())}});basePlugin.postcss=!0;const postcssPlugin=e=>{const t=Object.assign({preserve:!1,enableProgressiveCustomProperties:!0},e);return t.enableProgressiveCustomProperties&&t.preserve?{postcssPlugin:"postcss-color-functional-notation",plugins:[s(),basePlugin(t)]}:basePlugin(t)};postcssPlugin.postcss=!0,module.exports=postcssPlugin;
Loading