@csstools/postcss-relative-color-syntax 2.0.7 → 2.0.8

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,15 @@
1
1
  # Changes to PostCSS Relative Color Syntax
2
2
 
3
+ ### 2.0.8
4
+
5
+ _December 15, 2023_
6
+
7
+ - Skip transforms when a color value contains experimental syntax
8
+ - 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)
9
+ - 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)
10
+ - 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)
11
+ - 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)
12
+
3
13
  ### 2.0.7
4
14
 
5
15
  _October 9, 2023_
@@ -13,67 +23,4 @@ _October 2, 2023_
13
23
 
14
24
  - Updated [`@csstools/css-color-parser`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser) to [`1.3.3`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser/CHANGELOG.md#133) (patch)
15
25
 
16
- ### 2.0.5
17
-
18
- _September 24, 2023_
19
-
20
- - Small performance improvements
21
- - Updated [`@csstools/css-tokenizer`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-tokenizer) to [`2.2.1`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-tokenizer/CHANGELOG.md#221) (patch)
22
- - Updated [`@csstools/css-parser-algorithms`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-parser-algorithms) to [`2.3.2`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-parser-algorithms/CHANGELOG.md#232) (patch)
23
- - Updated [`@csstools/css-color-parser`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser) to [`1.3.2`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser/CHANGELOG.md#132) (patch)
24
-
25
- ### 2.0.4
26
-
27
- _September 18, 2023_
28
-
29
- - Updated [`@csstools/postcss-progressive-custom-properties`](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-progressive-custom-properties) to [`3.0.1`](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-progressive-custom-properties/CHANGELOG.md#301) (patch)
30
-
31
- ### 2.0.3
32
-
33
- _September 2, 2023_
34
-
35
- - Updated [`@csstools/css-color-parser`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser) to [`1.3.1`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser/CHANGELOG.md#131) (patch)
36
-
37
- ### 2.0.2
38
-
39
- _August 28, 2023_
40
-
41
- - Updated [`@csstools/css-color-parser`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser) to [`1.3.0`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser/CHANGELOG.md#130) (minor)
42
-
43
- ### 2.0.1
44
-
45
- _July 24, 2023_
46
-
47
- - Updated [`@csstools/css-tokenizer`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-tokenizer) to [`2.2.0`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-tokenizer/CHANGELOG.md#220) (minor)
48
- - Updated [`@csstools/css-parser-algorithms`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-parser-algorithms) to [`2.3.1`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-parser-algorithms/CHANGELOG.md#231) (patch)
49
-
50
- ### 2.0.0
51
-
52
- _July 3, 2023_
53
-
54
- - Change license to `MIT-0` ([read more about this change in the blog post](https://preset-env.cssdb.org/blog/license-change/))
55
- - Updated [`@csstools/css-parser-algorithms`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-parser-algorithms) to [`2.3.0`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-parser-algorithms/CHANGELOG.md#230) (minor)
56
- - Updated [`@csstools/postcss-progressive-custom-properties`](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-progressive-custom-properties) to [`3.0.0`](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-progressive-custom-properties/CHANGELOG.md#300) (major)
57
- - Updated [`@csstools/css-color-parser`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser) to [`1.2.2`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-color-parser/CHANGELOG.md#122) (patch)
58
-
59
- ### 1.0.2
60
-
61
- _June 14, 2023_
62
-
63
- - Fix value calculation for `hue` components in relative color syntax.
64
-
65
- ### 1.0.1
66
-
67
- _June 1, 2023_
68
-
69
- - Updated `@csstools/postcss-progressive-custom-properties` to `2.3.0` (minor)
70
-
71
- ### 1.0.0
72
-
73
- _May 19, 2023_
74
-
75
- - Initial version
76
- - Updated `@csstools/postcss-progressive-custom-properties` to `2.2.0` (minor)
77
- - Updated `@csstools/css-color-parser` to `1.2.0` (minor)
78
-
79
-
26
+ [Full CHANGELOG](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-relative-color-syntax/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"),r=require("@csstools/css-color-parser"),t=require("@csstools/css-parser-algorithms");function hasFallback(e){const s=e.parent;if(!s)return!1;const r=e.prop.toLowerCase(),t=s.index(e);for(let e=0;e<t;e++){const t=s.nodes[e];if("decl"===t.type&&t.prop.toLowerCase()===r)return!0}return!1}const o=/(rgb|hsl|hwb|lab|lch|oklch|oklab|color)\(\s*?from/i;function hasSupportsAtRuleAncestor(e){let s=e.parent;for(;s;)if("atrule"===s.type){if("supports"===s.name.toLowerCase()&&o.test(s.params))return!0;s=s.parent}else s=s.parent;return!1}const a=/(rgb|hsl|hwb|lab|lch|oklch|oklab|color)\(/i,l=/^(rgb|hsl|hwb|lab|lch|oklch|oklab|color)$/i,n=/from/i,basePlugin=e=>({postcssPlugin:"postcss-relative-color-syntax",Declaration:o=>{const i=o.value;if(!a.test(i))return;if(!n.test(i))return;if(hasFallback(o))return;if(hasSupportsAtRuleAncestor(o))return;const u=s.tokenize({css:i}),c=t.replaceComponentValues(t.parseCommaSeparatedListOfComponentValues(u),(e=>{if(t.isFunctionNode(e)&&l.test(e.getName())){const s=r.color(e);if(!s)return;if(s.syntaxFlags.has(r.SyntaxFlag.HasNoneKeywords))return;if(!s.syntaxFlags.has(r.SyntaxFlag.RelativeColorSyntax))return;return r.serializeRGB(s)}})),p=t.stringify(c);if(p===i)return;let f=p;null!=e&&e.subFeatures.displayP3&&(f=t.stringify(t.replaceComponentValues(t.parseCommaSeparatedListOfComponentValues(u),(e=>{if(t.isFunctionNode(e)&&l.test(e.getName())){const s=r.color(e);if(!s)return;if(s.syntaxFlags.has(r.SyntaxFlag.HasNoneKeywords))return;if(!s.syntaxFlags.has(r.SyntaxFlag.RelativeColorSyntax))return;return r.colorDataFitsRGB_Gamut(s)?r.serializeRGB(s):r.serializeP3(s)}})))),o.cloneBefore({value:p}),null!=e&&e.subFeatures.displayP3&&f!==p&&o.cloneBefore({value:f}),null!=e&&e.preserve||o.remove()}});basePlugin.postcss=!0;const postcssPlugin=s=>{const r=Object.assign({enableProgressiveCustomProperties:!0,preserve:!1,subFeatures:{displayP3:!0}},s);return r.subFeatures=Object.assign({displayP3:!0},r.subFeatures),r.enableProgressiveCustomProperties&&(r.preserve||r.subFeatures.displayP3)?{postcssPlugin:"postcss-relative-color-syntax",plugins:[e(),basePlugin(r)]}:basePlugin(r)};postcssPlugin.postcss=!0,module.exports=postcssPlugin;
1
+ "use strict";var e=require("@csstools/postcss-progressive-custom-properties"),s=require("@csstools/css-tokenizer"),r=require("@csstools/css-color-parser"),t=require("@csstools/css-parser-algorithms");function hasFallback(e){const s=e.parent;if(!s)return!1;const r=e.prop.toLowerCase(),t=s.index(e);for(let e=0;e<t;e++){const t=s.nodes[e];if("decl"===t.type&&t.prop.toLowerCase()===r)return!0}return!1}const o=/(rgb|hsl|hwb|lab|lch|oklch|oklab|color)\(\s*?from/i;function hasSupportsAtRuleAncestor(e){let s=e.parent;for(;s;)if("atrule"===s.type){if("supports"===s.name.toLowerCase()&&o.test(s.params))return!0;s=s.parent}else s=s.parent;return!1}const a=/(rgb|hsl|hwb|lab|lch|oklch|oklab|color)\(/i,n=/^(rgb|hsl|hwb|lab|lch|oklch|oklab|color)$/i,l=/from/i,basePlugin=e=>({postcssPlugin:"postcss-relative-color-syntax",Declaration:o=>{const i=o.value;if(!a.test(i))return;if(!l.test(i))return;if(hasFallback(o))return;if(hasSupportsAtRuleAncestor(o))return;const u=s.tokenize({css:i}),c=t.replaceComponentValues(t.parseCommaSeparatedListOfComponentValues(u),(e=>{if(t.isFunctionNode(e)&&n.test(e.getName())){const s=r.color(e);if(!s)return;if(s.syntaxFlags.has(r.SyntaxFlag.Experimental))return;if(s.syntaxFlags.has(r.SyntaxFlag.HasNoneKeywords))return;if(!s.syntaxFlags.has(r.SyntaxFlag.RelativeColorSyntax))return;return r.serializeRGB(s)}})),p=t.stringify(c);if(p===i)return;let f=p;e?.subFeatures.displayP3&&(f=t.stringify(t.replaceComponentValues(t.parseCommaSeparatedListOfComponentValues(u),(e=>{if(t.isFunctionNode(e)&&n.test(e.getName())){const s=r.color(e);if(!s)return;if(s.syntaxFlags.has(r.SyntaxFlag.HasNoneKeywords))return;if(!s.syntaxFlags.has(r.SyntaxFlag.RelativeColorSyntax))return;return r.colorDataFitsRGB_Gamut(s)?r.serializeRGB(s):r.serializeP3(s)}})))),o.cloneBefore({value:p}),e?.subFeatures.displayP3&&f!==p&&o.cloneBefore({value:f}),e?.preserve||o.remove()}});basePlugin.postcss=!0;const postcssPlugin=s=>{const r=Object.assign({enableProgressiveCustomProperties:!0,preserve:!1,subFeatures:{displayP3:!0}},s);return r.subFeatures=Object.assign({displayP3:!0},r.subFeatures),r.enableProgressiveCustomProperties&&(r.preserve||r.subFeatures.displayP3)?{postcssPlugin:"postcss-relative-color-syntax",plugins:[e(),basePlugin(r)]}:basePlugin(r)};postcssPlugin.postcss=!0,module.exports=postcssPlugin;
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import type { PluginCreator } from 'postcss';
2
+
2
3
  /** postcss-relative-color-syntax plugin options */
3
- export type pluginOptions = {
4
+ export declare type pluginOptions = {
4
5
  /** Preserve the original notation. default: false */
5
6
  preserve?: boolean;
6
7
  /** Enable "@csstools/postcss-progressive-custom-properties". default: true */
@@ -11,5 +12,8 @@ export type pluginOptions = {
11
12
  displayP3?: boolean;
12
13
  };
13
14
  };
15
+
14
16
  declare const postcssPlugin: PluginCreator<pluginOptions>;
15
17
  export default postcssPlugin;
18
+
19
+ export { }
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 r,SyntaxFlag as t,serializeRGB as o,colorDataFitsRGB_Gamut as a,serializeP3 as l}from"@csstools/css-color-parser";import{replaceComponentValues as n,parseCommaSeparatedListOfComponentValues as u,isFunctionNode as c,stringify as i}from"@csstools/css-parser-algorithms";function hasFallback(s){const e=s.parent;if(!e)return!1;const r=s.prop.toLowerCase(),t=e.index(s);for(let s=0;s<t;s++){const t=e.nodes[s];if("decl"===t.type&&t.prop.toLowerCase()===r)return!0}return!1}const p=/(rgb|hsl|hwb|lab|lch|oklch|oklab|color)\(\s*?from/i;function hasSupportsAtRuleAncestor(s){let e=s.parent;for(;e;)if("atrule"===e.type){if("supports"===e.name.toLowerCase()&&p.test(e.params))return!0;e=e.parent}else e=e.parent;return!1}const f=/(rgb|hsl|hwb|lab|lch|oklch|oklab|color)\(/i,b=/^(rgb|hsl|hwb|lab|lch|oklch|oklab|color)$/i,h=/from/i,basePlugin=s=>({postcssPlugin:"postcss-relative-color-syntax",Declaration:p=>{const m=p.value;if(!f.test(m))return;if(!h.test(m))return;if(hasFallback(p))return;if(hasSupportsAtRuleAncestor(p))return;const g=e({css:m}),y=n(u(g),(s=>{if(c(s)&&b.test(s.getName())){const e=r(s);if(!e)return;if(e.syntaxFlags.has(t.HasNoneKeywords))return;if(!e.syntaxFlags.has(t.RelativeColorSyntax))return;return o(e)}})),v=i(y);if(v===m)return;let F=v;null!=s&&s.subFeatures.displayP3&&(F=i(n(u(g),(s=>{if(c(s)&&b.test(s.getName())){const e=r(s);if(!e)return;if(e.syntaxFlags.has(t.HasNoneKeywords))return;if(!e.syntaxFlags.has(t.RelativeColorSyntax))return;return a(e)?o(e):l(e)}})))),p.cloneBefore({value:v}),null!=s&&s.subFeatures.displayP3&&F!==v&&p.cloneBefore({value:F}),null!=s&&s.preserve||p.remove()}});basePlugin.postcss=!0;const postcssPlugin=e=>{const r=Object.assign({enableProgressiveCustomProperties:!0,preserve:!1,subFeatures:{displayP3:!0}},e);return r.subFeatures=Object.assign({displayP3:!0},r.subFeatures),r.enableProgressiveCustomProperties&&(r.preserve||r.subFeatures.displayP3)?{postcssPlugin:"postcss-relative-color-syntax",plugins:[s(),basePlugin(r)]}:basePlugin(r)};postcssPlugin.postcss=!0;export{postcssPlugin as default};
1
+ import s from"@csstools/postcss-progressive-custom-properties";import{tokenize as e}from"@csstools/css-tokenizer";import{color as r,SyntaxFlag as t,serializeRGB as o,colorDataFitsRGB_Gamut as a,serializeP3 as l}from"@csstools/css-color-parser";import{replaceComponentValues as n,parseCommaSeparatedListOfComponentValues as i,isFunctionNode as c,stringify as u}from"@csstools/css-parser-algorithms";function hasFallback(s){const e=s.parent;if(!e)return!1;const r=s.prop.toLowerCase(),t=e.index(s);for(let s=0;s<t;s++){const t=e.nodes[s];if("decl"===t.type&&t.prop.toLowerCase()===r)return!0}return!1}const p=/(rgb|hsl|hwb|lab|lch|oklch|oklab|color)\(\s*?from/i;function hasSupportsAtRuleAncestor(s){let e=s.parent;for(;e;)if("atrule"===e.type){if("supports"===e.name.toLowerCase()&&p.test(e.params))return!0;e=e.parent}else e=e.parent;return!1}const f=/(rgb|hsl|hwb|lab|lch|oklch|oklab|color)\(/i,b=/^(rgb|hsl|hwb|lab|lch|oklch|oklab|color)$/i,h=/from/i,basePlugin=s=>({postcssPlugin:"postcss-relative-color-syntax",Declaration:p=>{const m=p.value;if(!f.test(m))return;if(!h.test(m))return;if(hasFallback(p))return;if(hasSupportsAtRuleAncestor(p))return;const g=e({css:m}),y=n(i(g),(s=>{if(c(s)&&b.test(s.getName())){const e=r(s);if(!e)return;if(e.syntaxFlags.has(t.Experimental))return;if(e.syntaxFlags.has(t.HasNoneKeywords))return;if(!e.syntaxFlags.has(t.RelativeColorSyntax))return;return o(e)}})),v=u(y);if(v===m)return;let F=v;s?.subFeatures.displayP3&&(F=u(n(i(g),(s=>{if(c(s)&&b.test(s.getName())){const e=r(s);if(!e)return;if(e.syntaxFlags.has(t.HasNoneKeywords))return;if(!e.syntaxFlags.has(t.RelativeColorSyntax))return;return a(e)?o(e):l(e)}})))),p.cloneBefore({value:v}),s?.subFeatures.displayP3&&F!==v&&p.cloneBefore({value:F}),s?.preserve||p.remove()}});basePlugin.postcss=!0;const postcssPlugin=e=>{const r=Object.assign({enableProgressiveCustomProperties:!0,preserve:!1,subFeatures:{displayP3:!0}},e);return r.subFeatures=Object.assign({displayP3:!0},r.subFeatures),r.enableProgressiveCustomProperties&&(r.preserve||r.subFeatures.displayP3)?{postcssPlugin:"postcss-relative-color-syntax",plugins:[s(),basePlugin(r)]}:basePlugin(r)};postcssPlugin.postcss=!0;export{postcssPlugin as default};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@csstools/postcss-relative-color-syntax",
3
3
  "description": "Use the relative color syntax in CSS",
4
- "version": "2.0.7",
4
+ "version": "2.0.8",
5
5
  "contributors": [
6
6
  {
7
7
  "name": "Antonio Laguna",
@@ -27,15 +27,18 @@
27
27
  "engines": {
28
28
  "node": "^14 || ^16 || >=18"
29
29
  },
30
+ "type": "module",
30
31
  "main": "dist/index.cjs",
31
32
  "module": "dist/index.mjs",
32
- "types": "dist/index.d.ts",
33
33
  "exports": {
34
34
  ".": {
35
- "types": "./dist/index.d.ts",
36
- "import": "./dist/index.mjs",
37
- "require": "./dist/index.cjs",
38
- "default": "./dist/index.mjs"
35
+ "import": {
36
+ "types": "./dist/index.d.ts",
37
+ "default": "./dist/index.mjs"
38
+ },
39
+ "require": {
40
+ "default": "./dist/index.cjs"
41
+ }
39
42
  }
40
43
  },
41
44
  "files": [
@@ -45,25 +48,14 @@
45
48
  "dist"
46
49
  ],
47
50
  "dependencies": {
48
- "@csstools/css-color-parser": "^1.4.0",
49
- "@csstools/css-parser-algorithms": "^2.3.2",
50
- "@csstools/css-tokenizer": "^2.2.1",
51
- "@csstools/postcss-progressive-custom-properties": "^3.0.2"
51
+ "@csstools/css-color-parser": "^1.5.0",
52
+ "@csstools/css-parser-algorithms": "^2.4.0",
53
+ "@csstools/css-tokenizer": "^2.2.2",
54
+ "@csstools/postcss-progressive-custom-properties": "^3.0.3"
52
55
  },
53
56
  "peerDependencies": {
54
57
  "postcss": "^8.4"
55
58
  },
56
- "devDependencies": {
57
- "@csstools/postcss-tape": "*"
58
- },
59
- "scripts": {
60
- "build": "rollup -c ../../rollup/default.mjs",
61
- "docs": "node ../../.github/bin/generate-docs/install.mjs && node ../../.github/bin/generate-docs/readme.mjs",
62
- "lint": "node ../../.github/bin/format-package-json.mjs",
63
- "prepublishOnly": "npm run build && npm run test",
64
- "test": "node .tape.mjs && node ./test/_import.mjs && node ./test/_require.cjs",
65
- "test:rewrite-expects": "REWRITE_EXPECTS=true node .tape.mjs"
66
- },
67
59
  "homepage": "https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-relative-color-syntax#readme",
68
60
  "repository": {
69
61
  "type": "git",
@@ -75,14 +67,5 @@
75
67
  "color",
76
68
  "postcss-plugin",
77
69
  "relative color syntax"
78
- ],
79
- "csstools": {
80
- "cssdbId": "relative-color-syntax",
81
- "exportName": "postcssRelativeColorSyntax",
82
- "humanReadableName": "PostCSS Relative Color Syntax",
83
- "specUrl": "https://www.w3.org/TR/css-color-5/#relative-colors"
84
- },
85
- "volta": {
86
- "extends": "../../package.json"
87
- }
70
+ ]
88
71
  }
@@ -1,2 +0,0 @@
1
- import type { Declaration } from 'postcss';
2
- export declare function hasFallback(node: Declaration): boolean;
@@ -1,2 +0,0 @@
1
- import type { Node } from 'postcss';
2
- export declare function hasSupportsAtRuleAncestor(node: Node): boolean;