@csstools/postcss-gamut-mapping 2.0.9 → 2.0.11
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 +3 -3
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# Changes to PostCSS gamut-mapping
|
|
2
2
|
|
|
3
|
-
### 2.0.
|
|
3
|
+
### 2.0.11
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
_August 22, 2025_
|
|
6
6
|
|
|
7
|
-
- Updated [`@csstools/css-color-parser`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser) to [`3.0
|
|
7
|
+
- Updated [`@csstools/css-color-parser`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser) to [`3.1.0`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser/CHANGELOG.md#310) (minor)
|
|
8
8
|
|
|
9
9
|
[Full CHANGELOG](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-gamut-mapping/CHANGELOG.md)
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("@csstools/css-tokenizer"),o=require("@csstools/css-parser-algorithms"),a=require("@csstools/css-color-parser");const t=/\bcolor-gamut\b/i;function hasConditionalAncestor(e){let o=e.parent;for(;o;)if("atrule"===o.type){if("media"===o.name.toLowerCase()&&t.test(o.params))return!0;o=o.parent}else o=o.parent;return!1}function sameProperty(e){const o=e.prop.toLowerCase(),a=[],t=e.parent?.nodes??[];for(let e=0;e<t.length;e++){const s=t[e];"decl"===s.type&&s.prop.toLowerCase()===o&&a.push(s)}return a}const s=/\b(?:color|lab|lch|oklab|oklch)\(/i,n=/^(?:color|lab|lch|oklab|oklch)$/i,creator=()=>({postcssPlugin:"postcss-gamut-mapping",prepare(){const t=new WeakMap,r=new WeakSet;return{postcssPlugin:"postcss-gamut-mapping",OnceExit(i,{postcss:l}){i.walkDecls(
|
|
1
|
+
"use strict";var e=require("@csstools/css-tokenizer"),o=require("@csstools/css-parser-algorithms"),a=require("@csstools/css-color-parser");const t=/\bcolor-gamut\b/i;function hasConditionalAncestor(e){let o=e.parent;for(;o;)if("atrule"===o.type){if("media"===o.name.toLowerCase()&&t.test(o.params))return!0;o=o.parent}else o=o.parent;return!1}function sameProperty(e){const o=e.prop.toLowerCase(),a=[],t=e.parent?.nodes??[];for(let e=0;e<t.length;e++){const s=t[e];"decl"===s.type&&s.prop.toLowerCase()===o&&a.push(s)}return a}const s=/\b(?:color|lab|lch|oklab|oklch)\(/i,n=/^(?:color|lab|lch|oklab|oklch)$/i,creator=()=>({postcssPlugin:"postcss-gamut-mapping",prepare(){const t=new WeakMap,r=new WeakSet;return{postcssPlugin:"postcss-gamut-mapping",OnceExit(i,{postcss:l}){i.walkDecls(i=>{if(r.has(i))return;if(!s.test(i.value))return;if(!i.parent||hasConditionalAncestor(i))return;const c=sameProperty(i).map((t,s)=>{r.add(t);let i=!1;const l=t.value,c=o.replaceComponentValues(o.parseCommaSeparatedListOfComponentValues(e.tokenize({css:l})),e=>{if(!o.isFunctionNode(e)||!n.test(e.getName()))return;const t=a.color(e);return!t||t.syntaxFlags.has(a.SyntaxFlag.HasNoneKeywords)||a.colorDataFitsRGB_Gamut(t)?void 0:(i||a.colorDataFitsDisplayP3_Gamut(t)||(i=!0),a.serializeRGB(t,!0))}),p=o.stringify(c);return{isRec2020:i,matchesOriginal:p===l,modifiedValue:p,hasFallback:s>0,item:t}}),p=[];c.reverse();for(const e of c){if(e.matchesOriginal)break;p.push(e)}p.reverse(),p.forEach(({isRec2020:e,modifiedValue:o,hasFallback:a,item:s})=>{const n=s.parent;if(!n)return;const i=t.get(n)||{conditionalRules:[],propNames:new Set,lastConditionParams:{media:void 0},lastConditionalRule:void 0};t.set(n,i);const c=`(color-gamut: ${e?"rec2020":"p3"})`;if(i.lastConditionParams.media!==c&&(i.lastConditionalRule=void 0),!a){const e=s.cloneBefore({value:o});r.add(e)}if(i.lastConditionalRule){const e=s.clone();return i.lastConditionalRule.append(e),r.add(e),void s.remove()}const p=l.atRule({name:"media",params:c,source:n.source,raws:{before:"\n\n",after:"\n"}}),u=n.clone();u.removeAll(),u.raws.before="\n";const d=s.clone();u.append(d),s.remove(),r.add(d),i.lastConditionParams.media=p.params,i.lastConditionalRule=u,p.append(u),i.conditionalRules.push(p)})}),i.walk(e=>{const o=t.get(e);o&&0!==o.conditionalRules.length&&o.conditionalRules.reverse().forEach(o=>{e.after(o)})})}}}});creator.postcss=!0,module.exports=creator;
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{tokenize as e}from"@csstools/css-tokenizer";import{replaceComponentValues as o,parseCommaSeparatedListOfComponentValues as t,isFunctionNode as s,stringify as a}from"@csstools/css-parser-algorithms";import{color as n,SyntaxFlag as r,colorDataFitsRGB_Gamut as l,colorDataFitsDisplayP3_Gamut as i,serializeRGB as c}from"@csstools/css-color-parser";const p=/\bcolor-gamut\b/i;function hasConditionalAncestor(e){let o=e.parent;for(;o;)if("atrule"===o.type){if("media"===o.name.toLowerCase()&&p.test(o.params))return!0;o=o.parent}else o=o.parent;return!1}function sameProperty(e){const o=e.prop.toLowerCase(),t=[],s=e.parent?.nodes??[];for(let e=0;e<s.length;e++){const a=s[e];"decl"===a.type&&a.prop.toLowerCase()===o&&t.push(a)}return t}const d=/\b(?:color|lab|lch|oklab|oklch)\(/i,u=/^(?:color|lab|lch|oklab|oklch)$/i,creator=()=>({postcssPlugin:"postcss-gamut-mapping",prepare(){const p=new WeakMap,m=new WeakSet;return{postcssPlugin:"postcss-gamut-mapping",OnceExit(f,{postcss:h}){f.walkDecls(
|
|
1
|
+
import{tokenize as e}from"@csstools/css-tokenizer";import{replaceComponentValues as o,parseCommaSeparatedListOfComponentValues as t,isFunctionNode as s,stringify as a}from"@csstools/css-parser-algorithms";import{color as n,SyntaxFlag as r,colorDataFitsRGB_Gamut as l,colorDataFitsDisplayP3_Gamut as i,serializeRGB as c}from"@csstools/css-color-parser";const p=/\bcolor-gamut\b/i;function hasConditionalAncestor(e){let o=e.parent;for(;o;)if("atrule"===o.type){if("media"===o.name.toLowerCase()&&p.test(o.params))return!0;o=o.parent}else o=o.parent;return!1}function sameProperty(e){const o=e.prop.toLowerCase(),t=[],s=e.parent?.nodes??[];for(let e=0;e<s.length;e++){const a=s[e];"decl"===a.type&&a.prop.toLowerCase()===o&&t.push(a)}return t}const d=/\b(?:color|lab|lch|oklab|oklch)\(/i,u=/^(?:color|lab|lch|oklab|oklch)$/i,creator=()=>({postcssPlugin:"postcss-gamut-mapping",prepare(){const p=new WeakMap,m=new WeakSet;return{postcssPlugin:"postcss-gamut-mapping",OnceExit(f,{postcss:h}){f.walkDecls(f=>{if(m.has(f))return;if(!d.test(f.value))return;if(!f.parent||hasConditionalAncestor(f))return;const g=sameProperty(f).map((p,d)=>{m.add(p);let f=!1;const h=p.value,g=o(t(e({css:h})),e=>{if(!s(e)||!u.test(e.getName()))return;const o=n(e);return!o||o.syntaxFlags.has(r.HasNoneKeywords)||l(o)?void 0:(f||i(o)||(f=!0),c(o,!0))}),v=a(g);return{isRec2020:f,matchesOriginal:v===h,modifiedValue:v,hasFallback:d>0,item:p}}),v=[];g.reverse();for(const e of g){if(e.matchesOriginal)break;v.push(e)}v.reverse(),v.forEach(({isRec2020:e,modifiedValue:o,hasFallback:t,item:s})=>{const a=s.parent;if(!a)return;const n=p.get(a)||{conditionalRules:[],propNames:new Set,lastConditionParams:{media:void 0},lastConditionalRule:void 0};p.set(a,n);const r=`(color-gamut: ${e?"rec2020":"p3"})`;if(n.lastConditionParams.media!==r&&(n.lastConditionalRule=void 0),!t){const e=s.cloneBefore({value:o});m.add(e)}if(n.lastConditionalRule){const e=s.clone();return n.lastConditionalRule.append(e),m.add(e),void s.remove()}const l=h.atRule({name:"media",params:r,source:a.source,raws:{before:"\n\n",after:"\n"}}),i=a.clone();i.removeAll(),i.raws.before="\n";const c=s.clone();i.append(c),s.remove(),m.add(c),n.lastConditionParams.media=l.params,n.lastConditionalRule=i,l.append(i),n.conditionalRules.push(l)})}),f.walk(e=>{const o=p.get(e);o&&0!==o.conditionalRules.length&&o.conditionalRules.reverse().forEach(o=>{e.after(o)})})}}}});creator.postcss=!0;export{creator as default};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@csstools/postcss-gamut-mapping",
|
|
3
3
|
"description": "Gamut map css colors to fit display specific gamuts",
|
|
4
|
-
"version": "2.0.
|
|
4
|
+
"version": "2.0.11",
|
|
5
5
|
"contributors": [
|
|
6
6
|
{
|
|
7
7
|
"name": "Antonio Laguna",
|
|
@@ -48,9 +48,9 @@
|
|
|
48
48
|
"dist"
|
|
49
49
|
],
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@csstools/css-color-parser": "^3.0
|
|
52
|
-
"@csstools/css-parser-algorithms": "^3.0.
|
|
53
|
-
"@csstools/css-tokenizer": "^3.0.
|
|
51
|
+
"@csstools/css-color-parser": "^3.1.0",
|
|
52
|
+
"@csstools/css-parser-algorithms": "^3.0.5",
|
|
53
|
+
"@csstools/css-tokenizer": "^3.0.4"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
56
|
"postcss": "^8.4"
|