@csstools/postcss-gradients-interpolation-method 6.0.1 → 6.0.3

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,9 +1,9 @@
1
1
  # Changes to PostCSS Gradients Interpolation Method
2
2
 
3
- ### 6.0.1
3
+ ### 6.0.3
4
4
 
5
- _January 25, 2026_
5
+ _April 12, 2026_
6
6
 
7
- - Updated [`@csstools/css-color-parser`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser) to [`4.0.1`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser/CHANGELOG.md#401) (patch)
7
+ - Updated [`@csstools/css-color-parser`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser) to [`4.1.0`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser/CHANGELOG.md#410) (minor)
8
8
 
9
9
  [Full CHANGELOG](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-gradients-interpolation-method/CHANGELOG.md)
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import o from"@csstools/postcss-progressive-custom-properties";import{hasFallback as e,hasSupportsAtRuleAncestor as t}from"@csstools/utilities";import{WhitespaceNode as r,TokenNode as i,FunctionNode as n,isCommentNode as s,isWhitespaceNode as l,isTokenNode as a,stringify as c,replaceComponentValues as u,parseCommaSeparatedListOfComponentValues as p,isFunctionNode as v}from"@csstools/css-parser-algorithms";import{TokenType as f,isTokenComma as h,isTokenIdent as m,tokenize as d}from"@csstools/css-tokenizer";import{serializeP3 as g,color as w,colorDataFitsRGB_Gamut as D,serializeRGB as C,SyntaxFlag as b}from"@csstools/css-color-parser";const x=/(?:repeating-)?(?:linear|radial|conic)-gradient\(/i,W=/\bin\b/i,P={test:o=>x.test(o)&&W.test(o)},A=/^(repeating-)?(linear|radial|conic)-gradient$/i;function interpolateColorsInColorStopsList(o,e,t,s=!1){const l=[],a=[];for(let s=0;s<o.length-1;s++){const l=o[s],c=o[s+1];if(a.push(l),t||g(l.colorData,!1).toString()!==g(c.colorData,!1).toString()&&l.position.toString()!==c.position.toString())for(let o=1;o<=9;o++){const s=10*o;let u=[];t&&(u=[new r([[f.Whitespace," ",-1,-1,void 0]]),t,new r([[f.Whitespace," ",-1,-1,void 0]]),new i([f.Ident,"hue",-1,-1,{value:"hue"}])]);const p=new n([f.Function,"color-mix(",-1,-1,{value:"color-mix"}],[f.CloseParen,")",-1,-1,void 0],[new i([f.Ident,"in",-1,-1,{value:"in"}]),new r([[f.Whitespace," ",-1,-1,void 0]]),e,...u,new i([f.Comma,",",-1,-1,void 0]),new r([[f.Whitespace," ",-1,-1,void 0]]),l.color,new r([[f.Whitespace," ",-1,-1,void 0]]),new i([f.Percentage,100-s+"%",-1,-1,{value:100-s}]),new i([f.Comma,",",-1,-1,void 0]),new r([[f.Whitespace," ",-1,-1,void 0]]),c.color,new r([[f.Whitespace," ",-1,-1,void 0]]),new i([f.Percentage,`${s}%`,-1,-1,{value:s}])]),v=w(p);if(!v)return!1;a.push({colorData:v})}s===o.length-2&&a.push(c)}for(let o=0;o<a.length;o++)s&&!D(a[o].colorData)?a[o].color=g(a[o].colorData,!1):a[o].color=C(a[o].colorData,!1);for(let o=0;o<a.length;o++){const e=a[o];e.position?l.push(e.color,new r([[f.Whitespace," ",-1,-1,void 0]]),e.position):l.push(e.color),o!==a.length-1&&l.push(new i([f.Comma,",",-1,-1,void 0]),new r([[f.Whitespace," ",-1,-1,void 0]]))}return l}function parseColorStops(o){const e=[];let t={};for(let r=0;r<o.length;r++){const i=o[r];if(s(i)||l(i))continue;if(a(i)&&h(i.value)){if(t.color&&t.colorData&&t.positionA){e.push({color:t.color,colorData:t.colorData,position:t.positionA}),t.positionB&&e.push({color:t.color,colorData:t.colorData,position:t.positionB}),t={};continue}return!1}const n=w(i);if(n){if(t.color)return!1;if(n.syntaxFlags.has(b.Experimental))return!1;t.color=i,t.colorData=n}else{if(!t.color)return!1;if(t.positionA){if(!t.positionA||t.positionB)return!1;t.positionB=i}else t.positionA=i}}return!(!t.color||!t.positionA)&&(t.color&&t.colorData&&t.positionA&&(e.push({color:t.color,colorData:t.colorData,position:t.positionA}),t.positionB&&e.push({color:t.color,colorData:t.colorData,position:t.positionB})),!(e.length<2)&&e)}const B=/^(?:srgb|srgb-linear|lab|oklab|xyz|xyz-d50|xyz-d65|hsl|hwb|lch|oklch)$/i,S=/^(?:hsl|hwb|lch|oklch)$/i,y=/^(?:shorter|longer|increasing|decreasing)$/i,$=/^in$/i,k=/^hue$/i;function modifyGradientFunctionComponentValues(o,e=!1){const t=o.getName();if(!A.test(t))return!1;let n="srgb",c=null,u=null,p=null,v=null,d=null,g=[];{let e=0,t=o.value[e];for(;t&&!(a(t)&&m(t.value)&&$.test(t.value[4].value));){if(a(t)&&h(t.value))return!1;e++,t=o.value[e]}for(c=t,e++,t=o.value[e];s(t)||l(t);)e++,t=o.value[e];if(a(t)&&m(t.value)&&B.test(t.value[4].value)){if(u)return!1;u=t,n=t.value[4].value,e++,t=o.value[e]}for(;s(t)||l(t);)e++,t=o.value[e];if(a(t)&&m(t.value)&&y.test(t.value[4].value)&&S.test(n)){if(p||!u)return!1;p=t,e++,t=o.value[e]}for(;s(t)||l(t);)e++,t=o.value[e];if(a(t)&&m(t.value)&&k.test(t.value[4].value)){if(v||!u||!p)return!1;v=t,e++,t=o.value[e]}for(;t&&(!a(t)||!h(t.value));)e++,t=o.value[e];if(d=t,!d)return!1;g=o.value.slice(e+1)}if(!u)return!1;if(p&&!v)return!1;if(v&&!p)return!1;const w=parseColorStops(g);if(!w)return!1;const D=interpolateColorsInColorStopsList(w,u,p,e);if(!D)return!1;const C=trim([...o.value.slice(0,o.value.indexOf(c)),...o.value.slice(o.value.indexOf(v||u)+1,o.value.indexOf(d))]);return C.length>0&&C.some(o=>!s(o))&&C.push(new i([f.Comma,",",-1,-1,void 0]),new r([[f.Whitespace," ",-1,-1,void 0]])),trim([...C,...trim(D)])}function trim(o){let e=0,t=o.length-1;for(let t=0;t<o.length;t++)if(!l(o[t])){e=t;break}for(let e=o.length-1;e>=0;e--)if(!l(o[e])){t=e;break}return o.slice(e,t+1)}const basePlugin=o=>({postcssPlugin:"postcss-gradients-interpolation-method",Declaration(r){if(!P.test(r.value))return;if(e(r))return;if(t(r,P))return;const i=d({css:r.value}),n=c(u(p(i),o=>{if(!v(o))return;const e=modifyGradientFunctionComponentValues(o);e&&(o.value=e)}));if(n===r.value)return;const s=c(u(p(i),o=>{if(!v(o))return;const e=modifyGradientFunctionComponentValues(o,!0);e&&(o.value=e)}));r.cloneBefore({value:n}),n!==s&&r.cloneBefore({value:s}),o?.preserve||r.remove()}});basePlugin.postcss=!0;const postcssPlugin=e=>{const t=Object.assign({enableProgressiveCustomProperties:!0,preserve:!0},e);return t.enableProgressiveCustomProperties?{postcssPlugin:"postcss-gradients-interpolation-method",plugins:[o(),basePlugin(t)]}:basePlugin(t)};postcssPlugin.postcss=!0;export{postcssPlugin as default,postcssPlugin as"module.exports"};
1
+ import o from"@csstools/postcss-progressive-custom-properties";import{hasFallback as e,hasSupportsAtRuleAncestor as t}from"@csstools/utilities";import{WhitespaceNode as r,TokenNode as i,FunctionNode as n,isCommentNode as s,isWhitespaceNode as l,isTokenNode as a,stringify as c,replaceComponentValues as u,parseCommaSeparatedListOfComponentValues as p,isFunctionNode as v}from"@csstools/css-parser-algorithms";import{TokenType as f,isTokenComma as h,isTokenIdent as m,tokenize as d}from"@csstools/css-tokenizer";import{serializeP3 as g,color as w,colorDataFitsRGB_Gamut as D,serializeRGB as C,SyntaxFlag as b}from"@csstools/css-color-parser";const x=/(?:repeating-)?(?:linear|radial|conic)-gradient\(/i,W=/\bin\b/i,P={test:o=>x.test(o)&&W.test(o)},A=/^(repeating-)?(linear|radial|conic)-gradient$/i;function interpolateColorsInColorStopsList(o,e,t,s=!1){const l=[],a=[];for(let s=0;s<o.length-1;s++){const l=o[s],c=o[s+1];if(a.push(l),t||g(l.colorData,!1).toString()!==g(c.colorData,!1).toString()&&l.position.toString()!==c.position.toString())for(let o=1;o<=9;o++){const s=10*o;let u=[];t&&(u=[new r([[f.Whitespace," ",-1,-1,void 0]]),t,new r([[f.Whitespace," ",-1,-1,void 0]]),new i([f.Ident,"hue",-1,-1,{value:"hue"}])]);const p=new n([f.Function,"color-mix(",-1,-1,{value:"color-mix"}],[f.CloseParen,")",-1,-1,void 0],[new i([f.Ident,"in",-1,-1,{value:"in"}]),new r([[f.Whitespace," ",-1,-1,void 0]]),e,...u,new i([f.Comma,",",-1,-1,void 0]),new r([[f.Whitespace," ",-1,-1,void 0]]),l.color,new r([[f.Whitespace," ",-1,-1,void 0]]),new i([f.Percentage,100-s+"%",-1,-1,{value:100-s}]),new i([f.Comma,",",-1,-1,void 0]),new r([[f.Whitespace," ",-1,-1,void 0]]),c.color,new r([[f.Whitespace," ",-1,-1,void 0]]),new i([f.Percentage,`${s}%`,-1,-1,{value:s}])]),v=w(p);if(!v)return!1;a.push({colorData:v})}s===o.length-2&&a.push(c)}for(let o=0;o<a.length;o++)s&&!D(a[o].colorData)?a[o].color=g(a[o].colorData,!1):a[o].color=C(a[o].colorData,!1);for(let o=0;o<a.length;o++){const e=a[o];e.position?l.push(e.color,new r([[f.Whitespace," ",-1,-1,void 0]]),e.position):l.push(e.color),o!==a.length-1&&l.push(new i([f.Comma,",",-1,-1,void 0]),new r([[f.Whitespace," ",-1,-1,void 0]]))}return l}function parseColorStops(o){const e=[];let t={};for(let r=0;r<o.length;r++){const i=o[r];if(s(i)||l(i))continue;if(a(i)&&h(i.value)){if(t.color&&t.colorData&&t.positionA){e.push({color:t.color,colorData:t.colorData,position:t.positionA}),t.positionB&&e.push({color:t.color,colorData:t.colorData,position:t.positionB}),t={};continue}return!1}const n=w(i);if(n){if(t.color)return!1;if(n.syntaxFlags.has(b.Experimental))return!1;t.color=i,t.colorData=n}else{if(!t.color)return!1;if(t.positionA){if(!t.positionA||t.positionB)return!1;t.positionB=i}else t.positionA=i}}return!(!t.color||!t.positionA)&&(t.color&&t.colorData&&t.positionA&&(e.push({color:t.color,colorData:t.colorData,position:t.positionA}),t.positionB&&e.push({color:t.color,colorData:t.colorData,position:t.positionB})),!(e.length<2)&&e)}const B=/^(?:srgb|srgb-linear|lab|oklab|xyz|xyz-d50|xyz-d65|hsl|hwb|lch|oklch)$/i,S=/^(?:hsl|hwb|lch|oklch)$/i,y=/^(?:shorter|longer|increasing|decreasing)$/i,$=/^in$/i,k=/^hue$/i;function modifyGradientFunctionComponentValues(o,e=!1){const t=o.getName();if(!A.test(t))return!1;let n,c,u,p="srgb",v=null,d=null,g=null;{let e=0,t=o.value[e];for(;t&&!(a(t)&&m(t.value)&&$.test(t.value[4].value));){if(a(t)&&h(t.value))return!1;e++,t=o.value[e]}for(n=t,e++,t=o.value[e];s(t)||l(t);)e++,t=o.value[e];for(a(t)&&m(t.value)&&B.test(t.value[4].value)&&(v=t,p=t.value[4].value,e++,t=o.value[e]);s(t)||l(t);)e++,t=o.value[e];if(a(t)&&m(t.value)&&y.test(t.value[4].value)&&S.test(p)){if(!v)return!1;d=t,e++,t=o.value[e]}for(;s(t)||l(t);)e++,t=o.value[e];if(a(t)&&m(t.value)&&k.test(t.value[4].value)){if(!v||!d)return!1;g=t,e++,t=o.value[e]}for(;t&&(!a(t)||!h(t.value));)e++,t=o.value[e];if(c=t,!c)return!1;u=o.value.slice(e+1)}if(!v)return!1;if(d&&!g)return!1;if(g&&!d)return!1;const w=parseColorStops(u);if(!w)return!1;const D=interpolateColorsInColorStopsList(w,v,d,e);if(!D)return!1;const C=trim([...o.value.slice(0,o.value.indexOf(n)),...o.value.slice(o.value.indexOf(g||v)+1,o.value.indexOf(c))]);return C.length>0&&C.some(o=>!s(o))&&C.push(new i([f.Comma,",",-1,-1,void 0]),new r([[f.Whitespace," ",-1,-1,void 0]])),trim([...C,...trim(D)])}function trim(o){let e=0,t=o.length-1;for(let t=0;t<o.length;t++)if(!l(o[t])){e=t;break}for(let e=o.length-1;e>=0;e--)if(!l(o[e])){t=e;break}return o.slice(e,t+1)}const basePlugin=o=>({postcssPlugin:"postcss-gradients-interpolation-method",Declaration(r){if(!P.test(r.value))return;if(e(r))return;if(t(r,P))return;const i=d({css:r.value}),n=c(u(p(i),o=>{if(!v(o))return;const e=modifyGradientFunctionComponentValues(o);e&&(o.value=e)}));if(n===r.value)return;const s=c(u(p(i),o=>{if(!v(o))return;const e=modifyGradientFunctionComponentValues(o,!0);e&&(o.value=e)}));r.cloneBefore({value:n}),n!==s&&r.cloneBefore({value:s}),o?.preserve||r.remove()}});basePlugin.postcss=!0;const postcssPlugin=e=>{const t=Object.assign({enableProgressiveCustomProperties:!0,preserve:!0},e);return t.enableProgressiveCustomProperties?{postcssPlugin:"postcss-gradients-interpolation-method",plugins:[o(),basePlugin(t)]}:basePlugin(t)};postcssPlugin.postcss=!0;export{postcssPlugin as default,postcssPlugin as"module.exports"};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@csstools/postcss-gradients-interpolation-method",
3
3
  "description": "Use interpolation methods in CSS gradient functions",
4
- "version": "6.0.1",
4
+ "version": "6.0.3",
5
5
  "author": "Jonathan Neal <jonathantneal@hotmail.com>",
6
6
  "license": "MIT-0",
7
7
  "funding": [
@@ -31,7 +31,7 @@
31
31
  "dist"
32
32
  ],
33
33
  "dependencies": {
34
- "@csstools/css-color-parser": "^4.0.1",
34
+ "@csstools/css-color-parser": "^4.1.0",
35
35
  "@csstools/css-parser-algorithms": "^4.0.0",
36
36
  "@csstools/css-tokenizer": "^4.0.0",
37
37
  "@csstools/postcss-progressive-custom-properties": "^5.0.0",