@csstools/postcss-progressive-custom-properties 1.1.0 → 1.2.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changes to PostCSS Progressive Custom Properties
2
2
 
3
+ ## 1.2.0 (February 15, 2022)
4
+
5
+ - More matching rules for [double position gradients](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-double-position-gradients#readme).
6
+
3
7
  ## 1.1.0 (February 12, 2022)
4
8
 
5
9
  - No longer uses custom properties in `@supports` rules.
package/README.md CHANGED
@@ -94,6 +94,14 @@ postcss([
94
94
  ]).process(YOUR_CSS /*, processOptions */);
95
95
  ```
96
96
 
97
+ ## @supports
98
+
99
+ This plugin wraps Custom Property override declarations in an `@supports` rule.
100
+ With PostCSS 8 this trigger declaration visitors to run again.
101
+
102
+ Make sure your plugin detects and ignores values inside relevant `@supports` rules.
103
+
104
+
97
105
  [PostCSS Progressive Custom Properties] runs in all Node environments, with special instructions for:
98
106
 
99
107
  | [Node](INSTALL.md#node) | [PostCSS CLI](INSTALL.md#postcss-cli) | [Webpack](INSTALL.md#webpack) | [Create React App](INSTALL.md#create-react-app) | [Gulp](INSTALL.md#gulp) | [Grunt](INSTALL.md#grunt) |
@@ -0,0 +1,2 @@
1
+ import type { Node } from 'postcss-value-parser';
2
+ export declare function doublePositionGradients(node: Node): Array<string>;
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=e(require("postcss-value-parser"));const r=[{supports:"color(srgb 0 0 0)",property:"color",sniff:"color",matchers:[{type:"function",value:"color",nodes:[{type:"word",value:"srgb"},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0}]},{type:"function",value:"color",nodes:[{type:"word",value:"srgb"},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"color(srgb-linear 0 0 0)",property:"color",sniff:"color",matchers:[{type:"function",value:"color",nodes:[{type:"word",value:"srgb-linear"},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0}]},{type:"function",value:"color",nodes:[{type:"word",value:"srgb-linear"},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"color(a98-rgb 0 0 0)",property:"color",sniff:"color",matchers:[{type:"function",value:"color",nodes:[{type:"word",value:"a98-rgb"},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0}]},{type:"function",value:"color",nodes:[{type:"word",value:"a98-rgb"},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"color(prophoto-rgb 0 0 0)",property:"color",sniff:"color",matchers:[{type:"function",value:"color",nodes:[{type:"word",value:"prophoto-rgb"},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0}]},{type:"function",value:"color",nodes:[{type:"word",value:"prophoto-rgb"},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"color(display-p3 0 0 0)",property:"color",sniff:"color",matchers:[{type:"function",value:"color",nodes:[{type:"word",value:"display-p3"},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0}]},{type:"function",value:"color",nodes:[{type:"word",value:"display-p3"},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"color(rec2020 0 0 0)",property:"color",sniff:"color",matchers:[{type:"function",value:"color",nodes:[{type:"word",value:"rec2020"},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0}]},{type:"function",value:"color",nodes:[{type:"word",value:"rec2020"},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"color(xyz-d50 0 0 0)",property:"color",sniff:"color",matchers:[{type:"function",value:"color",nodes:[{type:"word",value:"xyz-d50"},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0}]},{type:"function",value:"color",nodes:[{type:"word",value:"xyz-d50"},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"color(xyz-d65 0 0 0)",property:"color",sniff:"color",matchers:[{type:"function",value:"color",nodes:[{type:"word",value:"xyz-d65"},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0}]},{type:"function",value:"color",nodes:[{type:"word",value:"xyz-d65"},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"color(xyz 0 0 0)",property:"color",sniff:"color",matchers:[{type:"function",value:"color",nodes:[{type:"word",value:"xyz"},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0}]},{type:"function",value:"color",nodes:[{type:"word",value:"xyz"},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"hsl(0, 0%, 0%)",property:"color",sniff:"hsl",matchers:[{type:"function",value:"hsl",nodes:[{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0}]},{type:"function",value:"hsl",nodes:[{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0}]}]},{supports:"hsl(0 0% 0% / 0)",property:"color",sniff:"hsl",matchers:[{type:"function",value:"hsl",nodes:[{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0}]},{type:"function",value:"hsl",nodes:[{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"hsla(0 0% 0% / 0)",property:"color",sniff:"hsla",matchers:[{type:"function",value:"hsla",nodes:[{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"hwb(0 0% 0%)",property:"color",sniff:"hwb",matchers:[{type:"function",value:"hwb",nodes:[{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0}]},{type:"function",value:"hwb",nodes:[{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"lab(0% 0 0)",property:"color",sniff:"lab",matchers:[{type:"function",value:"lab",nodes:[{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0}]},{type:"function",value:"lab",nodes:[{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"lch(0% 0 0)",property:"color",sniff:"lch",matchers:[{type:"function",value:"lch",nodes:[{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0}]},{type:"function",value:"lch",nodes:[{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"oklab(0% 0 0)",property:"color",sniff:"oklab",matchers:[{type:"function",value:"oklab",nodes:[{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0}]},{type:"function",value:"oklab",nodes:[{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"oklch(0% 0 0)",property:"color",sniff:"oklch",matchers:[{type:"function",value:"oklch",nodes:[{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0}]},{type:"function",value:"oklch",nodes:[{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"rgb(0, 0, 0, 0)",property:"color",sniff:"rgb",matchers:[{type:"function",value:"rgb",nodes:[{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0}]},{type:"function",value:"rgb",nodes:[{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0}]}]},{supports:"rgb(0 0 0 / 0)",property:"color",sniff:"rgb",matchers:[{type:"function",value:"rgb",nodes:[{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0}]},{type:"function",value:"rgb",nodes:[{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"rgba(0 0 0 / 0)",property:"color",sniff:"rgba",matchers:[{type:"function",value:"rgba",nodes:[{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"1ic",property:"font-size",sniff:"ic",matchers:[{type:"word",value:"1ic",dimension:{number:"1",unit:"ic"}}]}];function p(e,a){if(e.isVariable&&a)return!0;if(e.type!==a.type)return!1;if(function(e,a){if("space"===e.type&&"space"===a.type&&e.value.trim()===a.value.trim())return!1;if(e.dimension&&a.dimension)return e.dimension.unit!==a.dimension.unit;if(e.value!==a.value)return!0;return!1}(e,a))return!1;if(e.nodes&&a.nodes){if(e.nodes.length!==a.nodes.length)return!1;for(let r=0;r<e.nodes.length;r++)if(!p(e.nodes[r],a.nodes[r]))return!1;return!0}return!0}const t=()=>({postcssPlugin:"postcss-progressive-custom-properties",RuleExit:(e,{postcss:t})=>{const o=[],i=new Set;e.each((l=>{if("decl"!==l.type)return;if(!l.variable)return;if("initial"===l.value.trim())return;if(""===l.value.trim())return;if(!i.has(l.prop.toString()))return void i.add(l.prop.toString());const s=function(e){const t=[],o=[];r.forEach((a=>{e.indexOf(a.sniff)>-1&&o.push(a)}));try{a.default(e).walk((e=>{try{e.dimension=a.default.unit(e.value)}finally{!1===e.dimension&&delete e.dimension}for(let a=0;a<o.length;a++){const r=o[a];for(let a=0;a<r.matchers.length;a++)if(p(r.matchers[a],e))return void t.push(`(${r.property}: ${r.supports})`)}if("function"===e.type&&("conic-gradient"===e.value||"linear-gradient"===e.value)){let a=0,r=!1;for(let p=0;p<e.nodes.length;p++){const o=e.nodes[p];if("div"!==o.type||","!==o.value.trim()){if("word"!==o.type&&"function"!==o.type||a++,r&&3===a)return"conic-gradient"===e.value?void t.push("(background: conic-gradient(red 0%, red 0deg 1%, red 2deg))"):void t.push("(background: linear-gradient(0deg, red 0% 1%, red 2%))")}else a=0,r=!0}}}))}catch(e){}return t}(l.value);if(!s.length)return;const y=t.atRule({name:"supports",params:s.join(" and "),source:e.source,raws:{before:"\n\n",after:"\n"}}),u=e.clone();u.removeAll(),u.raws.before="\n",u.append(l.clone()),l.remove(),y.append(u),o.push(y)})),0!==o.length&&o.reverse().forEach((a=>{e.after(a)}))}});t.postcss=!0,module.exports=t;
1
+ "use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=e(require("postcss-value-parser"));const r=[{supports:"color(srgb 0 0 0)",property:"color",sniff:"color",matchers:[{type:"function",value:"color",nodes:[{type:"word",value:"srgb"},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0}]},{type:"function",value:"color",nodes:[{type:"word",value:"srgb"},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"color(srgb-linear 0 0 0)",property:"color",sniff:"color",matchers:[{type:"function",value:"color",nodes:[{type:"word",value:"srgb-linear"},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0}]},{type:"function",value:"color",nodes:[{type:"word",value:"srgb-linear"},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"color(a98-rgb 0 0 0)",property:"color",sniff:"color",matchers:[{type:"function",value:"color",nodes:[{type:"word",value:"a98-rgb"},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0}]},{type:"function",value:"color",nodes:[{type:"word",value:"a98-rgb"},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"color(prophoto-rgb 0 0 0)",property:"color",sniff:"color",matchers:[{type:"function",value:"color",nodes:[{type:"word",value:"prophoto-rgb"},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0}]},{type:"function",value:"color",nodes:[{type:"word",value:"prophoto-rgb"},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"color(display-p3 0 0 0)",property:"color",sniff:"color",matchers:[{type:"function",value:"color",nodes:[{type:"word",value:"display-p3"},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0}]},{type:"function",value:"color",nodes:[{type:"word",value:"display-p3"},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"color(rec2020 0 0 0)",property:"color",sniff:"color",matchers:[{type:"function",value:"color",nodes:[{type:"word",value:"rec2020"},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0}]},{type:"function",value:"color",nodes:[{type:"word",value:"rec2020"},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"color(xyz-d50 0 0 0)",property:"color",sniff:"color",matchers:[{type:"function",value:"color",nodes:[{type:"word",value:"xyz-d50"},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0}]},{type:"function",value:"color",nodes:[{type:"word",value:"xyz-d50"},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"color(xyz-d65 0 0 0)",property:"color",sniff:"color",matchers:[{type:"function",value:"color",nodes:[{type:"word",value:"xyz-d65"},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0}]},{type:"function",value:"color",nodes:[{type:"word",value:"xyz-d65"},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"color(xyz 0 0 0)",property:"color",sniff:"color",matchers:[{type:"function",value:"color",nodes:[{type:"word",value:"xyz"},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0}]},{type:"function",value:"color",nodes:[{type:"word",value:"xyz"},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"hsl(0, 0%, 0%)",property:"color",sniff:"hsl",matchers:[{type:"function",value:"hsl",nodes:[{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0}]},{type:"function",value:"hsl",nodes:[{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0}]}]},{supports:"hsl(0 0% 0% / 0)",property:"color",sniff:"hsl",matchers:[{type:"function",value:"hsl",nodes:[{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0}]},{type:"function",value:"hsl",nodes:[{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"hsla(0 0% 0% / 0)",property:"color",sniff:"hsla",matchers:[{type:"function",value:"hsla",nodes:[{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"hwb(0 0% 0%)",property:"color",sniff:"hwb",matchers:[{type:"function",value:"hwb",nodes:[{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0}]},{type:"function",value:"hwb",nodes:[{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"lab(0% 0 0)",property:"color",sniff:"lab",matchers:[{type:"function",value:"lab",nodes:[{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0}]},{type:"function",value:"lab",nodes:[{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"lch(0% 0 0)",property:"color",sniff:"lch",matchers:[{type:"function",value:"lch",nodes:[{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0}]},{type:"function",value:"lch",nodes:[{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"oklab(0% 0 0)",property:"color",sniff:"oklab",matchers:[{type:"function",value:"oklab",nodes:[{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0}]},{type:"function",value:"oklab",nodes:[{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"oklch(0% 0 0)",property:"color",sniff:"oklch",matchers:[{type:"function",value:"oklch",nodes:[{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0}]},{type:"function",value:"oklch",nodes:[{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"rgb(0, 0, 0, 0)",property:"color",sniff:"rgb",matchers:[{type:"function",value:"rgb",nodes:[{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0}]},{type:"function",value:"rgb",nodes:[{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0}]}]},{supports:"rgb(0 0 0 / 0)",property:"color",sniff:"rgb",matchers:[{type:"function",value:"rgb",nodes:[{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0}]},{type:"function",value:"rgb",nodes:[{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"rgba(0 0 0 / 0)",property:"color",sniff:"rgba",matchers:[{type:"function",value:"rgba",nodes:[{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"1ic",property:"font-size",sniff:"ic",matchers:[{type:"word",value:"1ic",dimension:{number:"1",unit:"ic"}}]}];function p(e,a){if(e.isVariable&&a)return!0;if(e.type!==a.type)return!1;if(function(e,a){if("space"===e.type&&"space"===a.type&&e.value.trim()===a.value.trim())return!1;if(e.dimension&&a.dimension)return e.dimension.unit!==a.dimension.unit;if(e.value!==a.value)return!0;return!1}(e,a))return!1;if(e.nodes&&a.nodes){if(e.nodes.length!==a.nodes.length)return!1;for(let r=0;r<e.nodes.length;r++)if(!p(e.nodes[r],a.nodes[r]))return!1;return!0}return!0}const t=()=>({postcssPlugin:"postcss-progressive-custom-properties",RuleExit:(e,{postcss:t})=>{const i=[],o=new Set;e.each((l=>{if("decl"!==l.type)return;if(!l.variable)return;if("initial"===l.value.trim())return;if(""===l.value.trim())return;if(!o.has(l.prop.toString()))return void o.add(l.prop.toString());const s=function(e){const t=[],i=[];r.forEach((a=>{e.indexOf(a.sniff)>-1&&i.push(a)}));try{a.default(e).walk((e=>{try{e.dimension=a.default.unit(e.value)}finally{!1===e.dimension&&delete e.dimension}for(let a=0;a<i.length;a++){const r=i[a];for(let a=0;a<r.matchers.length;a++)if(p(r.matchers[a],e))return void t.push(`(${r.property}: ${r.supports})`)}t.push(...function(e){const a=[];if("function"===e.type&&("conic-gradient"===e.value||"linear-gradient"===e.value||"radial-gradient"===e.value||"repeating-conic-gradient"===e.value||"repeating-linear-gradient"===e.value||"repeating-radial-gradient"===e.value)){let r=0,p=!1;e:for(let t=0;t<e.nodes.length;t++){const i=e.nodes[t];if("div"!==i.type||","!==i.value.trim()){if("word"!==i.type&&"function"!==i.type||r++,p&&3===r)switch(e.value){case"conic-gradient":a.push("(background: conic-gradient(red 0%, red 0deg 1%, red 2deg))");break e;case"linear-gradient":a.push("(background: linear-gradient(0deg, red 0% 1%, red 2%))");break e;case"radial-gradient":a.push("(background: radial-gradient(red, red 1px 2px, red 3px))");break e;case"repeating-conic-gradient":a.push("(background: repeating-conic-gradient(from 0deg, red 0deg, red 0deg 1deg, red 2deg))");break e;case"repeating-linear-gradient":a.push("(background: repeating-linear-gradient(0deg, red 0% 1%, red 2%))");break e;case"repeating-radial-gradient":a.push("(background: repeating-radial-gradient(red, red 1px 2px, red 3px))");break e}}else r=0,p=!0}}return a}(e))}))}catch(e){}return Array.from(new Set(t))}(l.value);if(!s.length)return;const y=t.atRule({name:"supports",params:s.join(" and "),source:e.source,raws:{before:"\n\n",after:"\n"}}),d=e.clone();d.removeAll(),d.raws.before="\n",d.append(l.clone()),l.remove(),y.append(d),i.push(y)})),0!==i.length&&i.reverse().forEach((a=>{e.after(a)}))}});t.postcss=!0,module.exports=t;
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import e from"postcss-value-parser";const a=[{supports:"color(srgb 0 0 0)",property:"color",sniff:"color",matchers:[{type:"function",value:"color",nodes:[{type:"word",value:"srgb"},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0}]},{type:"function",value:"color",nodes:[{type:"word",value:"srgb"},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"color(srgb-linear 0 0 0)",property:"color",sniff:"color",matchers:[{type:"function",value:"color",nodes:[{type:"word",value:"srgb-linear"},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0}]},{type:"function",value:"color",nodes:[{type:"word",value:"srgb-linear"},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"color(a98-rgb 0 0 0)",property:"color",sniff:"color",matchers:[{type:"function",value:"color",nodes:[{type:"word",value:"a98-rgb"},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0}]},{type:"function",value:"color",nodes:[{type:"word",value:"a98-rgb"},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"color(prophoto-rgb 0 0 0)",property:"color",sniff:"color",matchers:[{type:"function",value:"color",nodes:[{type:"word",value:"prophoto-rgb"},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0}]},{type:"function",value:"color",nodes:[{type:"word",value:"prophoto-rgb"},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"color(display-p3 0 0 0)",property:"color",sniff:"color",matchers:[{type:"function",value:"color",nodes:[{type:"word",value:"display-p3"},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0}]},{type:"function",value:"color",nodes:[{type:"word",value:"display-p3"},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"color(rec2020 0 0 0)",property:"color",sniff:"color",matchers:[{type:"function",value:"color",nodes:[{type:"word",value:"rec2020"},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0}]},{type:"function",value:"color",nodes:[{type:"word",value:"rec2020"},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"color(xyz-d50 0 0 0)",property:"color",sniff:"color",matchers:[{type:"function",value:"color",nodes:[{type:"word",value:"xyz-d50"},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0}]},{type:"function",value:"color",nodes:[{type:"word",value:"xyz-d50"},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"color(xyz-d65 0 0 0)",property:"color",sniff:"color",matchers:[{type:"function",value:"color",nodes:[{type:"word",value:"xyz-d65"},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0}]},{type:"function",value:"color",nodes:[{type:"word",value:"xyz-d65"},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"color(xyz 0 0 0)",property:"color",sniff:"color",matchers:[{type:"function",value:"color",nodes:[{type:"word",value:"xyz"},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0}]},{type:"function",value:"color",nodes:[{type:"word",value:"xyz"},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"hsl(0, 0%, 0%)",property:"color",sniff:"hsl",matchers:[{type:"function",value:"hsl",nodes:[{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0}]},{type:"function",value:"hsl",nodes:[{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0}]}]},{supports:"hsl(0 0% 0% / 0)",property:"color",sniff:"hsl",matchers:[{type:"function",value:"hsl",nodes:[{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0}]},{type:"function",value:"hsl",nodes:[{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"hsla(0 0% 0% / 0)",property:"color",sniff:"hsla",matchers:[{type:"function",value:"hsla",nodes:[{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"hwb(0 0% 0%)",property:"color",sniff:"hwb",matchers:[{type:"function",value:"hwb",nodes:[{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0}]},{type:"function",value:"hwb",nodes:[{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"lab(0% 0 0)",property:"color",sniff:"lab",matchers:[{type:"function",value:"lab",nodes:[{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0}]},{type:"function",value:"lab",nodes:[{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"lch(0% 0 0)",property:"color",sniff:"lch",matchers:[{type:"function",value:"lch",nodes:[{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0}]},{type:"function",value:"lch",nodes:[{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"oklab(0% 0 0)",property:"color",sniff:"oklab",matchers:[{type:"function",value:"oklab",nodes:[{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0}]},{type:"function",value:"oklab",nodes:[{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"oklch(0% 0 0)",property:"color",sniff:"oklch",matchers:[{type:"function",value:"oklch",nodes:[{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0}]},{type:"function",value:"oklch",nodes:[{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"rgb(0, 0, 0, 0)",property:"color",sniff:"rgb",matchers:[{type:"function",value:"rgb",nodes:[{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0}]},{type:"function",value:"rgb",nodes:[{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0}]}]},{supports:"rgb(0 0 0 / 0)",property:"color",sniff:"rgb",matchers:[{type:"function",value:"rgb",nodes:[{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0}]},{type:"function",value:"rgb",nodes:[{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"rgba(0 0 0 / 0)",property:"color",sniff:"rgba",matchers:[{type:"function",value:"rgba",nodes:[{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"1ic",property:"font-size",sniff:"ic",matchers:[{type:"word",value:"1ic",dimension:{number:"1",unit:"ic"}}]}];function r(e,a){if(e.isVariable&&a)return!0;if(e.type!==a.type)return!1;if(function(e,a){if("space"===e.type&&"space"===a.type&&e.value.trim()===a.value.trim())return!1;if(e.dimension&&a.dimension)return e.dimension.unit!==a.dimension.unit;if(e.value!==a.value)return!0;return!1}(e,a))return!1;if(e.nodes&&a.nodes){if(e.nodes.length!==a.nodes.length)return!1;for(let p=0;p<e.nodes.length;p++)if(!r(e.nodes[p],a.nodes[p]))return!1;return!0}return!0}const p=()=>({postcssPlugin:"postcss-progressive-custom-properties",RuleExit:(p,{postcss:t})=>{const o=[],i=new Set;p.each((l=>{if("decl"!==l.type)return;if(!l.variable)return;if("initial"===l.value.trim())return;if(""===l.value.trim())return;if(!i.has(l.prop.toString()))return void i.add(l.prop.toString());const s=function(p){const t=[],o=[];a.forEach((e=>{p.indexOf(e.sniff)>-1&&o.push(e)}));try{e(p).walk((a=>{try{a.dimension=e.unit(a.value)}finally{!1===a.dimension&&delete a.dimension}for(let e=0;e<o.length;e++){const p=o[e];for(let e=0;e<p.matchers.length;e++)if(r(p.matchers[e],a))return void t.push(`(${p.property}: ${p.supports})`)}if("function"===a.type&&("conic-gradient"===a.value||"linear-gradient"===a.value)){let e=0,r=!1;for(let p=0;p<a.nodes.length;p++){const o=a.nodes[p];if("div"!==o.type||","!==o.value.trim()){if("word"!==o.type&&"function"!==o.type||e++,r&&3===e)return"conic-gradient"===a.value?void t.push("(background: conic-gradient(red 0%, red 0deg 1%, red 2deg))"):void t.push("(background: linear-gradient(0deg, red 0% 1%, red 2%))")}else e=0,r=!0}}}))}catch(e){}return t}(l.value);if(!s.length)return;const y=t.atRule({name:"supports",params:s.join(" and "),source:p.source,raws:{before:"\n\n",after:"\n"}}),u=p.clone();u.removeAll(),u.raws.before="\n",u.append(l.clone()),l.remove(),y.append(u),o.push(y)})),0!==o.length&&o.reverse().forEach((e=>{p.after(e)}))}});p.postcss=!0;export{p as default};
1
+ import e from"postcss-value-parser";const a=[{supports:"color(srgb 0 0 0)",property:"color",sniff:"color",matchers:[{type:"function",value:"color",nodes:[{type:"word",value:"srgb"},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0}]},{type:"function",value:"color",nodes:[{type:"word",value:"srgb"},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"color(srgb-linear 0 0 0)",property:"color",sniff:"color",matchers:[{type:"function",value:"color",nodes:[{type:"word",value:"srgb-linear"},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0}]},{type:"function",value:"color",nodes:[{type:"word",value:"srgb-linear"},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"color(a98-rgb 0 0 0)",property:"color",sniff:"color",matchers:[{type:"function",value:"color",nodes:[{type:"word",value:"a98-rgb"},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0}]},{type:"function",value:"color",nodes:[{type:"word",value:"a98-rgb"},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"color(prophoto-rgb 0 0 0)",property:"color",sniff:"color",matchers:[{type:"function",value:"color",nodes:[{type:"word",value:"prophoto-rgb"},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0}]},{type:"function",value:"color",nodes:[{type:"word",value:"prophoto-rgb"},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"color(display-p3 0 0 0)",property:"color",sniff:"color",matchers:[{type:"function",value:"color",nodes:[{type:"word",value:"display-p3"},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0}]},{type:"function",value:"color",nodes:[{type:"word",value:"display-p3"},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"color(rec2020 0 0 0)",property:"color",sniff:"color",matchers:[{type:"function",value:"color",nodes:[{type:"word",value:"rec2020"},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0}]},{type:"function",value:"color",nodes:[{type:"word",value:"rec2020"},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"color(xyz-d50 0 0 0)",property:"color",sniff:"color",matchers:[{type:"function",value:"color",nodes:[{type:"word",value:"xyz-d50"},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0}]},{type:"function",value:"color",nodes:[{type:"word",value:"xyz-d50"},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"color(xyz-d65 0 0 0)",property:"color",sniff:"color",matchers:[{type:"function",value:"color",nodes:[{type:"word",value:"xyz-d65"},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0}]},{type:"function",value:"color",nodes:[{type:"word",value:"xyz-d65"},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"color(xyz 0 0 0)",property:"color",sniff:"color",matchers:[{type:"function",value:"color",nodes:[{type:"word",value:"xyz"},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0}]},{type:"function",value:"color",nodes:[{type:"word",value:"xyz"},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"hsl(0, 0%, 0%)",property:"color",sniff:"hsl",matchers:[{type:"function",value:"hsl",nodes:[{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0}]},{type:"function",value:"hsl",nodes:[{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0}]}]},{supports:"hsl(0 0% 0% / 0)",property:"color",sniff:"hsl",matchers:[{type:"function",value:"hsl",nodes:[{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0}]},{type:"function",value:"hsl",nodes:[{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"hsla(0 0% 0% / 0)",property:"color",sniff:"hsla",matchers:[{type:"function",value:"hsla",nodes:[{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"hwb(0 0% 0%)",property:"color",sniff:"hwb",matchers:[{type:"function",value:"hwb",nodes:[{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0}]},{type:"function",value:"hwb",nodes:[{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"lab(0% 0 0)",property:"color",sniff:"lab",matchers:[{type:"function",value:"lab",nodes:[{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0}]},{type:"function",value:"lab",nodes:[{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"lch(0% 0 0)",property:"color",sniff:"lch",matchers:[{type:"function",value:"lch",nodes:[{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0}]},{type:"function",value:"lch",nodes:[{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"oklab(0% 0 0)",property:"color",sniff:"oklab",matchers:[{type:"function",value:"oklab",nodes:[{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0}]},{type:"function",value:"oklab",nodes:[{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"oklch(0% 0 0)",property:"color",sniff:"oklch",matchers:[{type:"function",value:"oklch",nodes:[{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0}]},{type:"function",value:"oklch",nodes:[{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"rgb(0, 0, 0, 0)",property:"color",sniff:"rgb",matchers:[{type:"function",value:"rgb",nodes:[{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0}]},{type:"function",value:"rgb",nodes:[{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0},{type:"div",value:","},{type:"word",isVariable:!0}]}]},{supports:"rgb(0 0 0 / 0)",property:"color",sniff:"rgb",matchers:[{type:"function",value:"rgb",nodes:[{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0}]},{type:"function",value:"rgb",nodes:[{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"rgba(0 0 0 / 0)",property:"color",sniff:"rgba",matchers:[{type:"function",value:"rgba",nodes:[{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"space",value:" "},{type:"word",isVariable:!0},{type:"div",value:"/"},{type:"word",isVariable:!0}]}]},{supports:"1ic",property:"font-size",sniff:"ic",matchers:[{type:"word",value:"1ic",dimension:{number:"1",unit:"ic"}}]}];function r(e,a){if(e.isVariable&&a)return!0;if(e.type!==a.type)return!1;if(function(e,a){if("space"===e.type&&"space"===a.type&&e.value.trim()===a.value.trim())return!1;if(e.dimension&&a.dimension)return e.dimension.unit!==a.dimension.unit;if(e.value!==a.value)return!0;return!1}(e,a))return!1;if(e.nodes&&a.nodes){if(e.nodes.length!==a.nodes.length)return!1;for(let p=0;p<e.nodes.length;p++)if(!r(e.nodes[p],a.nodes[p]))return!1;return!0}return!0}const p=()=>({postcssPlugin:"postcss-progressive-custom-properties",RuleExit:(p,{postcss:t})=>{const i=[],o=new Set;p.each((l=>{if("decl"!==l.type)return;if(!l.variable)return;if("initial"===l.value.trim())return;if(""===l.value.trim())return;if(!o.has(l.prop.toString()))return void o.add(l.prop.toString());const s=function(p){const t=[],i=[];a.forEach((e=>{p.indexOf(e.sniff)>-1&&i.push(e)}));try{e(p).walk((a=>{try{a.dimension=e.unit(a.value)}finally{!1===a.dimension&&delete a.dimension}for(let e=0;e<i.length;e++){const p=i[e];for(let e=0;e<p.matchers.length;e++)if(r(p.matchers[e],a))return void t.push(`(${p.property}: ${p.supports})`)}t.push(...function(e){const a=[];if("function"===e.type&&("conic-gradient"===e.value||"linear-gradient"===e.value||"radial-gradient"===e.value||"repeating-conic-gradient"===e.value||"repeating-linear-gradient"===e.value||"repeating-radial-gradient"===e.value)){let r=0,p=!1;e:for(let t=0;t<e.nodes.length;t++){const i=e.nodes[t];if("div"!==i.type||","!==i.value.trim()){if("word"!==i.type&&"function"!==i.type||r++,p&&3===r)switch(e.value){case"conic-gradient":a.push("(background: conic-gradient(red 0%, red 0deg 1%, red 2deg))");break e;case"linear-gradient":a.push("(background: linear-gradient(0deg, red 0% 1%, red 2%))");break e;case"radial-gradient":a.push("(background: radial-gradient(red, red 1px 2px, red 3px))");break e;case"repeating-conic-gradient":a.push("(background: repeating-conic-gradient(from 0deg, red 0deg, red 0deg 1deg, red 2deg))");break e;case"repeating-linear-gradient":a.push("(background: repeating-linear-gradient(0deg, red 0% 1%, red 2%))");break e;case"repeating-radial-gradient":a.push("(background: repeating-radial-gradient(red, red 1px 2px, red 3px))");break e}}else r=0,p=!0}}return a}(a))}))}catch(e){}return Array.from(new Set(t))}(l.value);if(!s.length)return;const y=t.atRule({name:"supports",params:s.join(" and "),source:p.source,raws:{before:"\n\n",after:"\n"}}),d=p.clone();d.removeAll(),d.raws.before="\n",d.append(l.clone()),l.remove(),y.append(d),i.push(y)})),0!==i.length&&i.reverse().forEach((e=>{p.after(e)}))}});p.postcss=!0;export{p as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@csstools/postcss-progressive-custom-properties",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "Correctly declare progressive enhancements for CSS Custom Properties.",
5
5
  "author": "Jonathan Neal <jonathantneal@hotmail.com>",
6
6
  "license": "CC0-1.0",
@@ -30,9 +30,9 @@
30
30
  "prepublishOnly": "npm run clean && npm run build && npm run test",
31
31
  "stryker": "stryker run --logLevel error",
32
32
  "test": "node .tape.mjs && npm run test:exports",
33
- "test:rewrite-expects": "REWRITE_EXPECTS=true node .tape.mjs",
34
33
  "test:cli": "bash ./test/cli/test.sh",
35
- "test:exports": "node ./test/_import.mjs && node ./test/_require.cjs"
34
+ "test:exports": "node ./test/_import.mjs && node ./test/_require.cjs",
35
+ "test:rewrite-expects": "REWRITE_EXPECTS=true node .tape.mjs"
36
36
  },
37
37
  "dependencies": {
38
38
  "postcss-value-parser": "^4.2.0"