@csstools/postcss-color-function 3.0.6 → 3.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,149 +1,26 @@
1
1
  # Changes to PostCSS Color Function
2
2
 
3
- ### 3.0.6
4
-
5
- _October 2, 2023_
6
-
7
- - 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)
8
-
9
- ### 3.0.5
10
-
11
- _September 24, 2023_
12
-
13
- - 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)
14
- - 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)
15
- - 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)
16
-
17
- ### 3.0.4
18
-
19
- _September 18, 2023_
20
-
21
- - 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)
22
-
23
- ### 3.0.3
24
-
25
- _September 2, 2023_
26
-
27
- - 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)
28
-
29
- ### 3.0.2
30
-
31
- _August 28, 2023_
32
-
33
- - 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)
34
-
35
- ### 3.0.1
36
-
37
- _July 24, 2023_
38
-
39
- - 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)
40
- - 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)
41
-
42
- ### 3.0.0
43
-
44
- _July 3, 2023_
45
-
46
- - Change license to `MIT-0` ([read more about this change in the blog post](https://preset-env.cssdb.org/blog/license-change/))
47
- - 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)
48
- - 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)
49
- - 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)
50
-
51
- ### 2.2.3
52
-
53
- _June 1, 2023_
54
-
55
- - Updated `@csstools/postcss-progressive-custom-properties` to `2.3.0` (minor)
56
-
57
- ### 2.2.2
58
-
59
- _May 19, 2023_
60
-
61
- - Ignore relative color syntax
62
- - Updated `@csstools/postcss-progressive-custom-properties` to `2.2.0` (minor)
63
- - Updated `@csstools/css-color-parser` to `1.2.0` (minor)
64
-
65
- ### 2.2.1
3
+ ### 3.0.8
66
4
 
67
- _April 10, 2023_
5
+ _December 15, 2023_
68
6
 
69
- - Updated `@csstools/css-tokenizer` to `2.1.1` (patch)
70
- - Updated `@csstools/css-parser-algorithms` to `2.1.1` (patch)
71
- - Updated `@csstools/css-color-parser` to `1.1.2` (patch)
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)
72
12
 
73
- ### 2.2.0
13
+ ### 3.0.7
74
14
 
75
- _March 25, 2023_
15
+ _October 9, 2023_
76
16
 
77
- - Add `@csstools/css-color-parser` dependency for all color value transformations.
78
- - Add support for `calc` expressions in color components.
79
- - Remove support for missing channel values (`color(display-p3 1)`). This was never documented and was removed from the specification.
17
+ - 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)
18
+ - 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)
80
19
 
81
- ### 2.1.0
82
-
83
- _February 6, 2023_
84
-
85
- - Add: `@csstools/color-helpers` dependency for all color value transformations.
86
-
87
- ### 2.0.1
88
-
89
- _January 28, 2023_
90
-
91
- - Improve `types` declaration in `package.json`
92
-
93
- ### 2.0.0
94
-
95
- _January 24, 2023_
96
-
97
- - Updated: Support for Node v14+ (major).
98
-
99
- ### 1.1.1
100
-
101
- _July 8, 2022_
102
-
103
- - Fix case insensitive matching.
104
-
105
- ### 1.1.0
106
-
107
- _April 4, 2022_
108
-
109
- - Allow percentage units in XYZ color spaces.
110
-
111
- ```css
112
- .percentages {
113
- color-1: color(xyz-d50 64.331% 19.245% 16.771%);
114
- color-2: color(xyz-d65 64.331% 19.245% 16.771%);
115
- color-3: color(xyz 64.331% 19.245% 16.771%);
116
-
117
- /* becomes */
118
-
119
- color-1: rgb(245,0,135);
120
- color-2: rgb(253,0,127);
121
- color-3: rgb(253,0,127);
122
- }
123
- ```
124
-
125
- ### 1.0.3
126
-
127
- _March 8, 2022_
128
-
129
- - Fix gamut mapping giving overly unsaturated colors.
130
- - Implement powerless color components in gamut mapping.
131
-
132
- ### 1.0.2
133
-
134
- _February 12, 2022_
135
-
136
- - Updated `@csstools/postcss-progressive-custom-properties` to `1.1.0`.
137
-
138
- ### 1.0.1
139
-
140
- _February 11, 2022_
141
-
142
- - Add tests for percentage values in non-xyz color spaces.
143
- - Ignore percentage values in xyz color space as these are not supported.
20
+ ### 3.0.6
144
21
 
145
- ### 1.0.0
22
+ _October 2, 2023_
146
23
 
147
- _February 7, 2022_
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)
148
25
 
149
- - Initial version
26
+ [Full CHANGELOG](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-color-function/CHANGELOG.md)
package/README.md CHANGED
@@ -90,7 +90,7 @@ postcssColorFunction({ preserve: true })
90
90
  --a-color: rgb(164, 49, 43);
91
91
  }
92
92
 
93
- @supports (color: color(srgb 0 0 0)) {
93
+ @supports (color: color(display-p3 0 0 0)) {
94
94
  :root {
95
95
  --a-color: color(srgb 0.64331 0.19245 0.16771);
96
96
  }
@@ -102,7 +102,8 @@ postcssColorFunction({ preserve: true })
102
102
  The `enableProgressiveCustomProperties` option determines whether the original notation
103
103
  is wrapped with `@supports` when used in Custom Properties. By default, it is enabled.
104
104
 
105
- ⚠️ We only recommend disabling this when you set `preserve` to `false` or if you bring your own fix for Custom Properties. See what the plugin does in its [README](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-progressive-custom-properties#readme).
105
+ > [!NOTE]
106
+ > We only recommend disabling this when you set `preserve` to `false` or if you bring your own fix for Custom Properties. See what the plugin does in its [README](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-progressive-custom-properties#readme).
106
107
 
107
108
  ```js
108
109
  postcssColorFunction({ enableProgressiveCustomProperties: false })
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}function hasSupportsAtRuleAncestor(e){let s=e.parent;for(;s;)if("atrule"===s.type){if("supports"===s.name&&-1!==s.params.indexOf("color("))return!0;s=s.parent}else s=s.parent;return!1}const o=/(color)\(/i,n=/^(color)$/i,basePlugin=e=>({postcssPlugin:"postcss-color-function",Declaration:a=>{const c=a.value;if(!o.test(c))return;if(hasFallback(a))return;if(hasSupportsAtRuleAncestor(a))return;const i=s.tokenize({css:c}),l=t.replaceComponentValues(t.parseCommaSeparatedListOfComponentValues(i),(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.serializeRGB(s)}})),p=t.stringify(l);p!==c&&(a.cloneBefore({value:p}),null!=e&&e.preserve||a.remove())}});basePlugin.postcss=!0;const postcssPlugin=s=>{const r=Object.assign({preserve:!1,enableProgressiveCustomProperties:!0},s);return r.enableProgressiveCustomProperties&&r.preserve?{postcssPlugin:"postcss-color-function",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}function hasSupportsAtRuleAncestor(e){let s=e.parent;for(;s;)if("atrule"===s.type){if("supports"===s.name&&-1!==s.params.indexOf("color("))return!0;s=s.parent}else s=s.parent;return!1}const o=/(color)\(/i,n=/^(color)$/i,basePlugin=e=>({postcssPlugin:"postcss-color-function",Declaration:a=>{const i=a.value;if(!o.test(i))return;if(hasFallback(a))return;if(hasSupportsAtRuleAncestor(a))return;const c=s.tokenize({css:i}),l=t.replaceComponentValues(t.parseCommaSeparatedListOfComponentValues(c),(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(l);p!==i&&(a.cloneBefore({value:p}),e?.preserve||a.remove())}});basePlugin.postcss=!0;const postcssPlugin=s=>{const r=Object.assign({preserve:!1,enableProgressiveCustomProperties:!0},s);return r.enableProgressiveCustomProperties&&r.preserve?{postcssPlugin:"postcss-color-function",plugins:[e(),basePlugin(r)]}:basePlugin(r)};postcssPlugin.postcss=!0,module.exports=postcssPlugin;
package/dist/index.d.ts CHANGED
@@ -1,10 +1,14 @@
1
1
  import type { PluginCreator } from 'postcss';
2
+
2
3
  /** postcss-color-function 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 */
7
8
  enableProgressiveCustomProperties?: boolean;
8
9
  };
10
+
9
11
  declare const postcssPlugin: PluginCreator<pluginOptions>;
10
12
  export default postcssPlugin;
13
+
14
+ export { }
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import s from"@csstools/postcss-progressive-custom-properties";import{tokenize as r}from"@csstools/css-tokenizer";import{color as e,SyntaxFlag as o,serializeRGB as t}from"@csstools/css-color-parser";import{replaceComponentValues as n,parseCommaSeparatedListOfComponentValues as c,isFunctionNode as a,stringify as p}from"@csstools/css-parser-algorithms";function hasFallback(s){const r=s.parent;if(!r)return!1;const e=s.prop.toLowerCase(),o=r.index(s);for(let s=0;s<o;s++){const o=r.nodes[s];if("decl"===o.type&&o.prop.toLowerCase()===e)return!0}return!1}function hasSupportsAtRuleAncestor(s){let r=s.parent;for(;r;)if("atrule"===r.type){if("supports"===r.name&&-1!==r.params.indexOf("color("))return!0;r=r.parent}else r=r.parent;return!1}const l=/(color)\(/i,i=/^(color)$/i,basePlugin=s=>({postcssPlugin:"postcss-color-function",Declaration:u=>{const f=u.value;if(!l.test(f))return;if(hasFallback(u))return;if(hasSupportsAtRuleAncestor(u))return;const m=r({css:f}),g=n(c(m),(s=>{if(a(s)&&i.test(s.getName())){const r=e(s);if(!r)return;if(r.syntaxFlags.has(o.HasNoneKeywords))return;if(r.syntaxFlags.has(o.RelativeColorSyntax))return;return t(r)}})),v=p(g);v!==f&&(u.cloneBefore({value:v}),null!=s&&s.preserve||u.remove())}});basePlugin.postcss=!0;const postcssPlugin=r=>{const e=Object.assign({preserve:!1,enableProgressiveCustomProperties:!0},r);return e.enableProgressiveCustomProperties&&e.preserve?{postcssPlugin:"postcss-color-function",plugins:[s(),basePlugin(e)]}:basePlugin(e)};postcssPlugin.postcss=!0;export{postcssPlugin as default};
1
+ import s from"@csstools/postcss-progressive-custom-properties";import{tokenize as r}from"@csstools/css-tokenizer";import{color as e,SyntaxFlag as t,serializeRGB as o}from"@csstools/css-color-parser";import{replaceComponentValues as n,parseCommaSeparatedListOfComponentValues as a,isFunctionNode as c,stringify as p}from"@csstools/css-parser-algorithms";function hasFallback(s){const r=s.parent;if(!r)return!1;const e=s.prop.toLowerCase(),t=r.index(s);for(let s=0;s<t;s++){const t=r.nodes[s];if("decl"===t.type&&t.prop.toLowerCase()===e)return!0}return!1}function hasSupportsAtRuleAncestor(s){let r=s.parent;for(;r;)if("atrule"===r.type){if("supports"===r.name&&-1!==r.params.indexOf("color("))return!0;r=r.parent}else r=r.parent;return!1}const i=/(color)\(/i,l=/^(color)$/i,basePlugin=s=>({postcssPlugin:"postcss-color-function",Declaration:u=>{const f=u.value;if(!i.test(f))return;if(hasFallback(u))return;if(hasSupportsAtRuleAncestor(u))return;const m=r({css:f}),g=n(a(m),(s=>{if(c(s)&&l.test(s.getName())){const r=e(s);if(!r)return;if(r.syntaxFlags.has(t.Experimental))return;if(r.syntaxFlags.has(t.HasNoneKeywords))return;if(r.syntaxFlags.has(t.RelativeColorSyntax))return;return o(r)}})),v=p(g);v!==f&&(u.cloneBefore({value:v}),s?.preserve||u.remove())}});basePlugin.postcss=!0;const postcssPlugin=r=>{const e=Object.assign({preserve:!1,enableProgressiveCustomProperties:!0},r);return e.enableProgressiveCustomProperties&&e.preserve?{postcssPlugin:"postcss-color-function",plugins:[s(),basePlugin(e)]}:basePlugin(e)};postcssPlugin.postcss=!0;export{postcssPlugin as default};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@csstools/postcss-color-function",
3
3
  "description": "Use the color() function in CSS",
4
- "version": "3.0.6",
4
+ "version": "3.0.8",
5
5
  "author": "Jonathan Neal <jonathantneal@hotmail.com>",
6
6
  "license": "MIT-0",
7
7
  "funding": [
@@ -17,15 +17,18 @@
17
17
  "engines": {
18
18
  "node": "^14 || ^16 || >=18"
19
19
  },
20
+ "type": "module",
20
21
  "main": "dist/index.cjs",
21
22
  "module": "dist/index.mjs",
22
- "types": "./dist/index.d.ts",
23
23
  "exports": {
24
24
  ".": {
25
- "types": "./dist/index.d.ts",
26
- "import": "./dist/index.mjs",
27
- "require": "./dist/index.cjs",
28
- "default": "./dist/index.mjs"
25
+ "import": {
26
+ "types": "./dist/index.d.ts",
27
+ "default": "./dist/index.mjs"
28
+ },
29
+ "require": {
30
+ "default": "./dist/index.cjs"
31
+ }
29
32
  }
30
33
  },
31
34
  "files": [
@@ -35,26 +38,14 @@
35
38
  "dist"
36
39
  ],
37
40
  "dependencies": {
38
- "@csstools/css-color-parser": "^1.3.3",
39
- "@csstools/css-parser-algorithms": "^2.3.2",
40
- "@csstools/css-tokenizer": "^2.2.1",
41
- "@csstools/postcss-progressive-custom-properties": "^3.0.1"
41
+ "@csstools/css-color-parser": "^1.5.0",
42
+ "@csstools/css-parser-algorithms": "^2.4.0",
43
+ "@csstools/css-tokenizer": "^2.2.2",
44
+ "@csstools/postcss-progressive-custom-properties": "^3.0.3"
42
45
  },
43
46
  "peerDependencies": {
44
47
  "postcss": "^8.4"
45
48
  },
46
- "devDependencies": {
47
- "@csstools/postcss-tape": "*",
48
- "postcss-lab-function": "^6.0.0"
49
- },
50
- "scripts": {
51
- "build": "rollup -c ../../rollup/default.mjs",
52
- "docs": "node ../../.github/bin/generate-docs/install.mjs && node ../../.github/bin/generate-docs/readme.mjs",
53
- "lint": "node ../../.github/bin/format-package-json.mjs",
54
- "prepublishOnly": "npm run build && npm run test",
55
- "test": "node .tape.mjs && node ./test/_import.mjs && node ./test/_require.cjs",
56
- "test:rewrite-expects": "REWRITE_EXPECTS=true node .tape.mjs"
57
- },
58
49
  "homepage": "https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-color-function#readme",
59
50
  "repository": {
60
51
  "type": "git",
@@ -76,14 +67,5 @@
76
67
  "srgb-linear",
77
68
  "syntax",
78
69
  "xyz"
79
- ],
80
- "csstools": {
81
- "cssdbId": "color-function",
82
- "exportName": "postcssColorFunction",
83
- "humanReadableName": "PostCSS Color Function",
84
- "specUrl": "https://www.w3.org/TR/css-color-4/#funcdef-color"
85
- },
86
- "volta": {
87
- "extends": "../../package.json"
88
- }
70
+ ]
89
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;