@csstools/postcss-oklab-function 3.0.9 → 3.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 CHANGED
@@ -1,28 +1,29 @@
1
1
  # Changes to PostCSS OKLab Function
2
2
 
3
- ### 3.0.9
3
+ ### 3.0.11
4
4
 
5
- _December 31, 2023_
5
+ _March 13, 2024_
6
6
 
7
- - Updated [`@csstools/css-tokenizer`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-tokenizer) to [`2.2.3`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-tokenizer/CHANGELOG.md#223) (patch)
8
- - Updated [`@csstools/css-parser-algorithms`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-parser-algorithms) to [`2.5.0`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-parser-algorithms/CHANGELOG.md#250) (minor)
9
- - Updated [`@csstools/css-color-parser`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser) to [`1.5.1`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser/CHANGELOG.md#151) (patch)
7
+ - Updated [`@csstools/css-tokenizer`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-tokenizer) to [`2.2.4`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-tokenizer/CHANGELOG.md#224) (patch)
8
+ - Updated [`@csstools/postcss-progressive-custom-properties`](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-progressive-custom-properties) to [`3.1.1`](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-progressive-custom-properties/CHANGELOG.md#311) (patch)
9
+ - Updated [`@csstools/css-parser-algorithms`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-parser-algorithms) to [`2.6.1`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-parser-algorithms/CHANGELOG.md#261) (patch)
10
+ - Updated [`@csstools/css-color-parser`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser) to [`1.6.0`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser/CHANGELOG.md#160) (minor)
10
11
 
11
- ### 3.0.8
12
+ ### 3.0.10
12
13
 
13
- _December 15, 2023_
14
+ _February 19, 2024_
14
15
 
15
- - Skip transforms when a color value contains experimental syntax
16
- - Updated [`@csstools/css-tokenizer`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-tokenizer) to [`2.2.2`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-tokenizer/CHANGELOG.md#222) (patch)
17
- - Updated [`@csstools/css-parser-algorithms`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-parser-algorithms) to [`2.4.0`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-parser-algorithms/CHANGELOG.md#240) (minor)
18
- - Updated [`@csstools/postcss-progressive-custom-properties`](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-progressive-custom-properties) to [`3.0.3`](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-progressive-custom-properties/CHANGELOG.md#303) (patch)
19
- - Updated [`@csstools/css-color-parser`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser) to [`1.5.0`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser/CHANGELOG.md#150) (minor)
16
+ - Reuse code with `@csstools/utilities`
17
+ - Updated [`@csstools/css-parser-algorithms`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-parser-algorithms) to [`2.6.0`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-parser-algorithms/CHANGELOG.md#260) (minor)
18
+ - Updated [`@csstools/postcss-progressive-custom-properties`](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-progressive-custom-properties) to [`3.1.0`](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-progressive-custom-properties/CHANGELOG.md#310) (minor)
19
+ - Updated [`@csstools/css-color-parser`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser) to [`1.5.2`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser/CHANGELOG.md#152) (patch)
20
20
 
21
- ### 3.0.7
21
+ ### 3.0.9
22
22
 
23
- _October 9, 2023_
23
+ _December 31, 2023_
24
24
 
25
- - Updated [`@csstools/css-color-parser`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser) to [`1.4.0`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser/CHANGELOG.md#140) (minor)
26
- - Updated [`@csstools/postcss-progressive-custom-properties`](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-progressive-custom-properties) to [`3.0.2`](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-progressive-custom-properties/CHANGELOG.md#302) (patch)
25
+ - Updated [`@csstools/css-tokenizer`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-tokenizer) to [`2.2.3`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-tokenizer/CHANGELOG.md#223) (patch)
26
+ - Updated [`@csstools/css-parser-algorithms`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-parser-algorithms) to [`2.5.0`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-parser-algorithms/CHANGELOG.md#250) (minor)
27
+ - Updated [`@csstools/css-color-parser`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser) to [`1.5.1`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser/CHANGELOG.md#151) (patch)
27
28
 
28
29
  [Full CHANGELOG](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-oklab-function/CHANGELOG.md)
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var e=require("@csstools/postcss-progressive-custom-properties"),s=require("@csstools/css-tokenizer"),t=require("@csstools/css-color-parser"),r=require("@csstools/css-parser-algorithms");function hasFallback(e){const s=e.parent;if(!s)return!1;const t=e.prop.toLowerCase(),r=s.index(e);for(let e=0;e<r;e++){const r=s.nodes[e];if("decl"===r.type&&r.prop.toLowerCase()===t)return!0}return!1}function hasSupportsAtRuleAncestor(e){let s=e.parent;for(;s;)if("atrule"===s.type){if("supports"===s.name.toLowerCase()){if(-1!==s.params.toLowerCase().indexOf("oklab("))return!0;if(-1!==s.params.toLowerCase().indexOf("oklch("))return!0}s=s.parent}else s=s.parent;return!1}const a=/(oklab|oklch)\(/i,o=/^(oklab|oklch)$/i,basePlugin=e=>({postcssPlugin:"postcss-oklab-function",Declaration:n=>{const l=n.value;if(!a.test(l))return;if(hasFallback(n))return;if(hasSupportsAtRuleAncestor(n))return;const i=s.tokenize({css:l}),u=r.replaceComponentValues(r.parseCommaSeparatedListOfComponentValues(i),(e=>{if(!r.isFunctionNode(e)||!o.test(e.getName()))return;const s=t.color(e);return s&&!(s.syntaxFlags.has(t.SyntaxFlag.Experimental)||s.syntaxFlags.has(t.SyntaxFlag.HasNoneKeywords)||s.syntaxFlags.has(t.SyntaxFlag.RelativeColorSyntax))?t.serializeRGB(s):void 0})),p=r.stringify(u);if(p===l)return;let c=p;e?.subFeatures.displayP3&&(c=r.stringify(r.replaceComponentValues(r.parseCommaSeparatedListOfComponentValues(i),(e=>{if(!r.isFunctionNode(e)||!o.test(e.getName()))return;const s=t.color(e);return s&&!(s.syntaxFlags.has(t.SyntaxFlag.Experimental)||s.syntaxFlags.has(t.SyntaxFlag.HasNoneKeywords)||s.syntaxFlags.has(t.SyntaxFlag.RelativeColorSyntax))?t.colorDataFitsRGB_Gamut(s)?t.serializeRGB(s):t.serializeP3(s):void 0})))),n.cloneBefore({value:p}),e?.subFeatures.displayP3&&c!==p&&n.cloneBefore({value:c}),e?.preserve||n.remove()}});basePlugin.postcss=!0;const postcssPlugin=s=>{const t=Object.assign({enableProgressiveCustomProperties:!0,preserve:!1,subFeatures:{displayP3:!0}},s);return t.subFeatures=Object.assign({displayP3:!0},t.subFeatures),t.enableProgressiveCustomProperties&&(t.preserve||t.subFeatures.displayP3)?{postcssPlugin:"postcss-oklab-function",plugins:[e(),basePlugin(t)]}:basePlugin(t)};postcssPlugin.postcss=!0,module.exports=postcssPlugin;
1
+ "use strict";var s=require("@csstools/postcss-progressive-custom-properties"),e=require("@csstools/css-color-parser"),t=require("@csstools/utilities"),a=require("@csstools/css-parser-algorithms"),r=require("@csstools/css-tokenizer");const o=/\b(?:oklab|oklch)\(/i,l=/^(?:oklab|oklch)$/i,basePlugin=s=>({postcssPlugin:"postcss-oklab-function",Declaration(n){const i=n.value;if(!o.test(i))return;if(t.hasFallback(n))return;if(t.hasSupportsAtRuleAncestor(n,o))return;const u=r.tokenize({css:i}),c=a.replaceComponentValues(a.parseCommaSeparatedListOfComponentValues(u),(s=>{if(!a.isFunctionNode(s)||!l.test(s.getName()))return;const t=e.color(s);return t&&!(t.syntaxFlags.has(e.SyntaxFlag.Experimental)||t.syntaxFlags.has(e.SyntaxFlag.HasNoneKeywords)||t.syntaxFlags.has(e.SyntaxFlag.RelativeColorSyntax))?e.serializeRGB(t):void 0})),p=a.stringify(c);if(p===i)return;let g=p;s?.subFeatures.displayP3&&(g=a.stringify(a.replaceComponentValues(a.parseCommaSeparatedListOfComponentValues(u),(s=>{if(!a.isFunctionNode(s)||!l.test(s.getName()))return;const t=e.color(s);return t&&!(t.syntaxFlags.has(e.SyntaxFlag.Experimental)||t.syntaxFlags.has(e.SyntaxFlag.HasNoneKeywords)||t.syntaxFlags.has(e.SyntaxFlag.RelativeColorSyntax))?e.colorDataFitsRGB_Gamut(t)?e.serializeRGB(t):e.serializeP3(t):void 0})))),n.cloneBefore({value:p}),s?.subFeatures.displayP3&&g!==p&&n.cloneBefore({value:g}),s?.preserve||n.remove()}});basePlugin.postcss=!0;const postcssPlugin=e=>{const t=Object.assign({enableProgressiveCustomProperties:!0,preserve:!1,subFeatures:{displayP3:!0}},e);return t.subFeatures=Object.assign({displayP3:!0},t.subFeatures),t.enableProgressiveCustomProperties&&(t.preserve||t.subFeatures.displayP3)?{postcssPlugin:"postcss-oklab-function",plugins:[s(),basePlugin(t)]}:basePlugin(t)};postcssPlugin.postcss=!0,module.exports=postcssPlugin;
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import s from"@csstools/postcss-progressive-custom-properties";import{tokenize as e}from"@csstools/css-tokenizer";import{color as t,SyntaxFlag as r,serializeRGB as o,colorDataFitsRGB_Gamut as a,serializeP3 as n}from"@csstools/css-color-parser";import{replaceComponentValues as l,parseCommaSeparatedListOfComponentValues as i,isFunctionNode as p,stringify as u}from"@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}function hasSupportsAtRuleAncestor(s){let e=s.parent;for(;e;)if("atrule"===e.type){if("supports"===e.name.toLowerCase()){if(-1!==e.params.toLowerCase().indexOf("oklab("))return!0;if(-1!==e.params.toLowerCase().indexOf("oklch("))return!0}e=e.parent}else e=e.parent;return!1}const c=/(oklab|oklch)\(/i,f=/^(oklab|oklch)$/i,basePlugin=s=>({postcssPlugin:"postcss-oklab-function",Declaration:m=>{const b=m.value;if(!c.test(b))return;if(hasFallback(m))return;if(hasSupportsAtRuleAncestor(m))return;const g=e({css:b}),y=l(i(g),(s=>{if(!p(s)||!f.test(s.getName()))return;const e=t(s);return e&&!(e.syntaxFlags.has(r.Experimental)||e.syntaxFlags.has(r.HasNoneKeywords)||e.syntaxFlags.has(r.RelativeColorSyntax))?o(e):void 0})),d=u(y);if(d===b)return;let h=d;s?.subFeatures.displayP3&&(h=u(l(i(g),(s=>{if(!p(s)||!f.test(s.getName()))return;const e=t(s);return e&&!(e.syntaxFlags.has(r.Experimental)||e.syntaxFlags.has(r.HasNoneKeywords)||e.syntaxFlags.has(r.RelativeColorSyntax))?a(e)?o(e):n(e):void 0})))),m.cloneBefore({value:d}),s?.subFeatures.displayP3&&h!==d&&m.cloneBefore({value:h}),s?.preserve||m.remove()}});basePlugin.postcss=!0;const postcssPlugin=e=>{const t=Object.assign({enableProgressiveCustomProperties:!0,preserve:!1,subFeatures:{displayP3:!0}},e);return t.subFeatures=Object.assign({displayP3:!0},t.subFeatures),t.enableProgressiveCustomProperties&&(t.preserve||t.subFeatures.displayP3)?{postcssPlugin:"postcss-oklab-function",plugins:[s(),basePlugin(t)]}:basePlugin(t)};postcssPlugin.postcss=!0;export{postcssPlugin as default};
1
+ import s from"@csstools/postcss-progressive-custom-properties";import{color as e,SyntaxFlag as t,serializeRGB as o,colorDataFitsRGB_Gamut as r,serializeP3 as a}from"@csstools/css-color-parser";import{hasFallback as l,hasSupportsAtRuleAncestor as i}from"@csstools/utilities";import{replaceComponentValues as n,parseCommaSeparatedListOfComponentValues as c,isFunctionNode as u,stringify as p}from"@csstools/css-parser-algorithms";import{tokenize as m}from"@csstools/css-tokenizer";const g=/\b(?:oklab|oklch)\(/i,f=/^(?:oklab|oklch)$/i,basePlugin=s=>({postcssPlugin:"postcss-oklab-function",Declaration(b){const y=b.value;if(!g.test(y))return;if(l(b))return;if(i(b,g))return;const v=m({css:y}),F=n(c(v),(s=>{if(!u(s)||!f.test(s.getName()))return;const r=e(s);return r&&!(r.syntaxFlags.has(t.Experimental)||r.syntaxFlags.has(t.HasNoneKeywords)||r.syntaxFlags.has(t.RelativeColorSyntax))?o(r):void 0})),x=p(F);if(x===y)return;let P=x;s?.subFeatures.displayP3&&(P=p(n(c(v),(s=>{if(!u(s)||!f.test(s.getName()))return;const l=e(s);return l&&!(l.syntaxFlags.has(t.Experimental)||l.syntaxFlags.has(t.HasNoneKeywords)||l.syntaxFlags.has(t.RelativeColorSyntax))?r(l)?o(l):a(l):void 0})))),b.cloneBefore({value:x}),s?.subFeatures.displayP3&&P!==x&&b.cloneBefore({value:P}),s?.preserve||b.remove()}});basePlugin.postcss=!0;const postcssPlugin=e=>{const t=Object.assign({enableProgressiveCustomProperties:!0,preserve:!1,subFeatures:{displayP3:!0}},e);return t.subFeatures=Object.assign({displayP3:!0},t.subFeatures),t.enableProgressiveCustomProperties&&(t.preserve||t.subFeatures.displayP3)?{postcssPlugin:"postcss-oklab-function",plugins:[s(),basePlugin(t)]}:basePlugin(t)};postcssPlugin.postcss=!0;export{postcssPlugin as default};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@csstools/postcss-oklab-function",
3
3
  "description": "Use oklab() and oklch() color functions in CSS",
4
- "version": "3.0.9",
4
+ "version": "3.0.11",
5
5
  "author": "Jonathan Neal <jonathantneal@hotmail.com>",
6
6
  "license": "MIT-0",
7
7
  "funding": [
@@ -38,10 +38,11 @@
38
38
  "dist"
39
39
  ],
40
40
  "dependencies": {
41
- "@csstools/css-color-parser": "^1.5.1",
42
- "@csstools/css-parser-algorithms": "^2.5.0",
43
- "@csstools/css-tokenizer": "^2.2.3",
44
- "@csstools/postcss-progressive-custom-properties": "^3.0.3"
41
+ "@csstools/css-color-parser": "^1.6.0",
42
+ "@csstools/css-parser-algorithms": "^2.6.1",
43
+ "@csstools/css-tokenizer": "^2.2.4",
44
+ "@csstools/postcss-progressive-custom-properties": "^3.1.1",
45
+ "@csstools/utilities": "^1.0.0"
45
46
  },
46
47
  "peerDependencies": {
47
48
  "postcss": "^8.4"
@@ -49,7 +50,7 @@
49
50
  "homepage": "https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-oklab-function#readme",
50
51
  "repository": {
51
52
  "type": "git",
52
- "url": "https://github.com/csstools/postcss-plugins.git",
53
+ "url": "git+https://github.com/csstools/postcss-plugins.git",
53
54
  "directory": "plugins/postcss-oklab-function"
54
55
  },
55
56
  "bugs": "https://github.com/csstools/postcss-plugins/issues",