postcss-double-position-gradients 5.0.2 → 5.0.4

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,142 +1,23 @@
1
1
  # Changes to PostCSS Double Position Gradients
2
2
 
3
- ### 5.0.2
4
-
5
- _October 9, 2023_
6
-
7
- - 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)
8
-
9
- ### 5.0.1
10
-
11
- _September 18, 2023_
12
-
13
- - Improve performance
14
- - 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)
15
-
16
- ### 5.0.0
17
-
18
- _July 3, 2023_
19
-
20
- - Change license to `MIT-0` ([read more about this change in the blog post](https://preset-env.cssdb.org/blog/license-change/))
21
- - 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)
22
-
23
- ### 4.0.4
24
-
25
- _June 1, 2023_
26
-
27
- - Updated `@csstools/postcss-progressive-custom-properties` to `2.3.0` (minor)
28
-
29
- ### 4.0.3
30
-
31
- _May 19, 2023_
32
-
33
- - Updated `@csstools/postcss-progressive-custom-properties` to `2.2.0` (minor)
34
-
35
- ### 4.0.2
36
-
37
- _February 8, 2023_
38
-
39
- - Reduce the amount of duplicate fallback CSS.
40
-
41
- ### 4.0.1
42
-
43
- _January 28, 2023_
44
-
45
- - Improve `types` declaration in `package.json`
46
-
47
- ### 4.0.0
48
-
49
- _January 24, 2023_
50
-
51
- - Updated: Support for Node v14+ (major).
52
-
53
- ### 3.1.2
54
-
55
- _July 8, 2022_
56
-
57
- - Fix case insensitive matching.
3
+ ### 5.0.4
58
4
 
59
- ### 3.1.1
5
+ _February 19, 2024_
60
6
 
61
- _March 7, 2022_
7
+ - Reuse code with `@csstools/utilities`
8
+ - 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)
62
9
 
63
- - Add TypeScript support
64
- - Fix color functions.
65
- - Fix `at` keyword with `at 20px 20px` being interpreted as a double position color stop.
10
+ ### 5.0.3
66
11
 
67
- ### 3.1.0
12
+ _December 15, 2023_
68
13
 
69
- _February 15, 2022_
14
+ - Fix type definitions
15
+ - 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)
70
16
 
71
- - Ignore values in relevant `@supports` rules.
72
- - Support double position gradients in Custom Properties.
73
-
74
- ```css
75
- @supports (order: linear-gradient(90deg, black 25% 50%, blue 50% 75%)) {
76
- .support {
77
- /* is not processed */
78
- order: linear-gradient(90deg, black 25% 50%, blue 50% 75%);
79
- }
80
- }
81
- ```
82
-
83
- ### 3.0.5
84
-
85
- _February 5, 2022_
86
-
87
- - Improved `es module` and `commonjs` compatibility
88
-
89
- ### 3.0.4
90
-
91
- _January 2, 2022_
92
-
93
- - Removed Sourcemaps from package tarball.
94
- - Moved CLI to CLI Package. See [announcement](https://github.com/csstools/postcss-plugins/discussions/121).
95
-
96
- ### 3.0.3
97
-
98
- _December 14, 2021_
99
-
100
- - Fixed: infinite loop in complex gradients.
101
-
102
- ### 3.0.2
103
-
104
- _December 13, 2021_
105
-
106
- - Changed: now uses `postcss-value-parser` for parsing.
107
- - Updated: documentation
108
-
109
- ### 3.0.1
110
-
111
- _November 18, 2021_
112
-
113
- - Added: Safeguards against postcss-values-parser potentially throwing an error.
114
-
115
- - Fixed: Issue with some gradients creating an infinite loop.
116
-
117
- - Updated: `postcss-value-parser` to 6.0.1 (patch)
118
- - Updated: `eslint` to 8.2.0 (major)
119
- - Updated: `postcss` to 8.3.11 (patch)
120
-
121
- - Removed: yarn.lock is no longer version controlled
122
-
123
- ### 3.0.0
124
-
125
- _September 17, 2021_
126
-
127
- - Updated: Support for PostCS 8+ (major).
128
- - Updated: Support for Node 12+ (major).
129
-
130
- ### 2.0.0
131
-
132
- _April 25, 2020_
133
-
134
- - Updated: `postcss` to 7.0.27 (patch)
135
- - Updated: `postcss-value-parser` to 3.2.1 (major)
136
- - Updated: Support for Node 10+ (major)
17
+ ### 5.0.2
137
18
 
138
- ### 1.0.0
19
+ _October 9, 2023_
139
20
 
140
- _October 28, 2018_
21
+ - 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)
141
22
 
142
- - Initial version
23
+ [Full CHANGELOG](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-double-position-gradients/CHANGELOG.md)
package/README.md CHANGED
@@ -1,8 +1,10 @@
1
1
  # PostCSS Double Position Gradients [<img src="https://postcss.github.io/postcss/logo.svg" alt="PostCSS" width="90" height="90" align="right">][postcss]
2
2
 
3
3
  [<img alt="NPM Version" src="https://img.shields.io/npm/v/postcss-double-position-gradients.svg" height="20">][npm-url]
4
- [<img alt="CSS Standard Status" src="https://cssdb.org/images/badges/double-position-gradients.svg" height="20">][css-url]
5
4
  [<img alt="Discord" src="https://shields.io/badge/Discord-5865F2?logo=discord&logoColor=white">][discord]
5
+ <br><br>
6
+ [<img alt="Baseline Status" src="https://cssdb.org/images/badges-baseline/double-position-gradients.svg" height="20">][css-url]
7
+ [<img alt="CSS Standard Status" src="https://cssdb.org/images/badges/double-position-gradients.svg" height="20">][css-url]
6
8
 
7
9
  [PostCSS Double Position Gradients] lets you use double-position gradients in
8
10
  CSS, following the [CSS Image Values and Replaced Content] specification.
@@ -97,7 +99,9 @@ postcssDoublePositionGradients({ preserve: false })
97
99
  The `enableProgressiveCustomProperties` option determines whether the original notation
98
100
  is wrapped with `@supports` when used in Custom Properties. By default, it is enabled.
99
101
 
100
- ⚠️ 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).
102
+ > [!NOTE]
103
+ > We only recommend disabling this when you set `preserve` to `false` or if you bring your own fix for Custom Properties.
104
+ > See what the plugin does in its [README](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-progressive-custom-properties#readme).
101
105
 
102
106
  ```js
103
107
  postcssDoublePositionGradients({ enableProgressiveCustomProperties: false })
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var e=require("@csstools/postcss-progressive-custom-properties"),t=require("postcss-value-parser");function hasFallback(e){const t=e.parent;if(!t)return!1;const r=e.prop.toLowerCase(),s=t.index(e);for(let e=0;e<s;e++){const s=t.nodes[e];if("decl"===s.type&&s.prop.toLowerCase()===r)return!0}return!1}const r=/(?:repeating-)?(?:conic|linear|radial)-gradient\(/i,s=/^(?:repeating-)?(?:conic|linear|radial)-gradient$/i;function hasSupportsAtRuleAncestor(e){let t=e.parent;for(;t;)if("atrule"===t.type){if("supports"===t.name.toLowerCase()&&r.test(t.params))return!0;t=t.parent}else t=t.parent;return!1}const o=["at","bottom","center","circle","closest-corner","closest-side","ellipse","farthest-corner","farthest-side","from","in","left","right","to","top"],isPunctuationCommaNode=e=>"div"===e.type&&","===e.value;function isNumericNode(e){try{return!1!==t.unit(null==e?void 0:e.value)}catch(e){return!1}}const basePlugin=e=>({postcssPlugin:"postcss-double-position-gradients",Declaration(n,{result:i}){if(!r.test(n.value))return;if(hasFallback(n))return;if(hasSupportsAtRuleAncestor(n))return;let a;try{a=t(n.value)}catch(e){n.warn(i,`Failed to parse value '${n.value}' as a CSS gradient. Leaving the original value intact.`)}if(void 0===a)return;a.walk((e=>{if("function"!==e.type||!s.test(e.value))return;const t=e.nodes.filter((e=>"comment"!==e.type&&"space"!==e.type));let r=!1;t.forEach(((t,s,n)=>{if("word"===t.type&&o.includes(t.value.toLowerCase())&&(r=!0),"div"===t.type&&","===t.value&&(r=!1),r)return;const i=Object(n[s-1]),a=Object(n[s-2]),c=Object(n[s+1]);if(a.type&&isNumericNode(i)&&isNumericNode(t)){const r=a,s={type:"div",value:",",before:isPunctuationCommaNode(c)?c.before:"",after:isPunctuationCommaNode(c)?"":" ",sourceIndex:0,sourceEndIndex:0};e.nodes.splice(e.nodes.indexOf(t)-1,0,s,r)}}))}));const c=a.toString();c!==n.value&&(n.cloneBefore({value:c}),null!=e&&e.preserve||n.remove())}});basePlugin.postcss=!0;const postcssPlugin=t=>{const r=Object.assign({enableProgressiveCustomProperties:!0,preserve:!0},t);return r.enableProgressiveCustomProperties&&r.preserve?{postcssPlugin:"postcss-double-position-gradients",plugins:[e(),basePlugin(r)]}:basePlugin(r)};postcssPlugin.postcss=!0,module.exports=postcssPlugin;
1
+ "use strict";var e=require("@csstools/postcss-progressive-custom-properties"),t=require("postcss-value-parser"),s=require("@csstools/utilities");const r=/(?:repeating-)?(?:conic|linear|radial)-gradient\(/i,o=/^(?:repeating-)?(?:conic|linear|radial)-gradient$/i,i=["at","bottom","center","circle","closest-corner","closest-side","ellipse","farthest-corner","farthest-side","from","in","left","right","to","top"],isPunctuationCommaNode=e=>"div"===e.type&&","===e.value;function isNumericNode(e){try{return!1!==t.unit(e?.value)}catch(e){return!1}}const basePlugin=e=>({postcssPlugin:"postcss-double-position-gradients",Declaration(n,{result:a}){if(!r.test(n.value))return;if(s.hasFallback(n))return;if(s.hasSupportsAtRuleAncestor(n,r))return;let c;try{c=t(n.value)}catch(e){n.warn(a,`Failed to parse value '${n.value}' as a CSS gradient. Leaving the original value intact.`)}if(void 0===c)return;c.walk((e=>{if("function"!==e.type||!o.test(e.value))return;const t=e.nodes.filter((e=>"comment"!==e.type&&"space"!==e.type));let s=!1;t.forEach(((t,r,o)=>{if("word"===t.type&&i.includes(t.value.toLowerCase())&&(s=!0),"div"===t.type&&","===t.value&&(s=!1),s)return;const n=Object(o[r-1]),a=Object(o[r-2]),c=Object(o[r+1]);if(a.type&&isNumericNode(n)&&isNumericNode(t)){const s=a,r={type:"div",value:",",before:isPunctuationCommaNode(c)?c.before:"",after:isPunctuationCommaNode(c)?"":" ",sourceIndex:0,sourceEndIndex:0};e.nodes.splice(e.nodes.indexOf(t)-1,0,r,s)}}))}));const l=c.toString();l!==n.value&&(n.cloneBefore({value:l}),e?.preserve||n.remove())}});basePlugin.postcss=!0;const postcssPlugin=t=>{const s=Object.assign({enableProgressiveCustomProperties:!0,preserve:!0},t);return s.enableProgressiveCustomProperties&&s.preserve?{postcssPlugin:"postcss-double-position-gradients",plugins:[e(),basePlugin(s)]}:basePlugin(s)};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-double-position-gradients plugin options */
3
- export type pluginOptions = {
4
+ export declare type pluginOptions = {
4
5
  /** Preserve the original notation. default: true */
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 e from"@csstools/postcss-progressive-custom-properties";import t from"postcss-value-parser";function hasFallback(e){const t=e.parent;if(!t)return!1;const r=e.prop.toLowerCase(),s=t.index(e);for(let e=0;e<s;e++){const s=t.nodes[e];if("decl"===s.type&&s.prop.toLowerCase()===r)return!0}return!1}const r=/(?:repeating-)?(?:conic|linear|radial)-gradient\(/i,s=/^(?:repeating-)?(?:conic|linear|radial)-gradient$/i;function hasSupportsAtRuleAncestor(e){let t=e.parent;for(;t;)if("atrule"===t.type){if("supports"===t.name.toLowerCase()&&r.test(t.params))return!0;t=t.parent}else t=t.parent;return!1}const o=["at","bottom","center","circle","closest-corner","closest-side","ellipse","farthest-corner","farthest-side","from","in","left","right","to","top"],isPunctuationCommaNode=e=>"div"===e.type&&","===e.value;function isNumericNode(e){try{return!1!==t.unit(null==e?void 0:e.value)}catch(e){return!1}}const basePlugin=e=>({postcssPlugin:"postcss-double-position-gradients",Declaration(n,{result:i}){if(!r.test(n.value))return;if(hasFallback(n))return;if(hasSupportsAtRuleAncestor(n))return;let a;try{a=t(n.value)}catch(e){n.warn(i,`Failed to parse value '${n.value}' as a CSS gradient. Leaving the original value intact.`)}if(void 0===a)return;a.walk((e=>{if("function"!==e.type||!s.test(e.value))return;const t=e.nodes.filter((e=>"comment"!==e.type&&"space"!==e.type));let r=!1;t.forEach(((t,s,n)=>{if("word"===t.type&&o.includes(t.value.toLowerCase())&&(r=!0),"div"===t.type&&","===t.value&&(r=!1),r)return;const i=Object(n[s-1]),a=Object(n[s-2]),c=Object(n[s+1]);if(a.type&&isNumericNode(i)&&isNumericNode(t)){const r=a,s={type:"div",value:",",before:isPunctuationCommaNode(c)?c.before:"",after:isPunctuationCommaNode(c)?"":" ",sourceIndex:0,sourceEndIndex:0};e.nodes.splice(e.nodes.indexOf(t)-1,0,s,r)}}))}));const c=a.toString();c!==n.value&&(n.cloneBefore({value:c}),null!=e&&e.preserve||n.remove())}});basePlugin.postcss=!0;const postcssPlugin=t=>{const r=Object.assign({enableProgressiveCustomProperties:!0,preserve:!0},t);return r.enableProgressiveCustomProperties&&r.preserve?{postcssPlugin:"postcss-double-position-gradients",plugins:[e(),basePlugin(r)]}:basePlugin(r)};postcssPlugin.postcss=!0;export{postcssPlugin as default};
1
+ import e from"@csstools/postcss-progressive-custom-properties";import t from"postcss-value-parser";import{hasFallback as s,hasSupportsAtRuleAncestor as r}from"@csstools/utilities";const o=/(?:repeating-)?(?:conic|linear|radial)-gradient\(/i,i=/^(?:repeating-)?(?:conic|linear|radial)-gradient$/i,n=["at","bottom","center","circle","closest-corner","closest-side","ellipse","farthest-corner","farthest-side","from","in","left","right","to","top"],isPunctuationCommaNode=e=>"div"===e.type&&","===e.value;function isNumericNode(e){try{return!1!==t.unit(e?.value)}catch(e){return!1}}const basePlugin=e=>({postcssPlugin:"postcss-double-position-gradients",Declaration(a,{result:c}){if(!o.test(a.value))return;if(s(a))return;if(r(a,o))return;let l;try{l=t(a.value)}catch(e){a.warn(c,`Failed to parse value '${a.value}' as a CSS gradient. Leaving the original value intact.`)}if(void 0===l)return;l.walk((e=>{if("function"!==e.type||!i.test(e.value))return;const t=e.nodes.filter((e=>"comment"!==e.type&&"space"!==e.type));let s=!1;t.forEach(((t,r,o)=>{if("word"===t.type&&n.includes(t.value.toLowerCase())&&(s=!0),"div"===t.type&&","===t.value&&(s=!1),s)return;const i=Object(o[r-1]),a=Object(o[r-2]),c=Object(o[r+1]);if(a.type&&isNumericNode(i)&&isNumericNode(t)){const s=a,r={type:"div",value:",",before:isPunctuationCommaNode(c)?c.before:"",after:isPunctuationCommaNode(c)?"":" ",sourceIndex:0,sourceEndIndex:0};e.nodes.splice(e.nodes.indexOf(t)-1,0,r,s)}}))}));const u=l.toString();u!==a.value&&(a.cloneBefore({value:u}),e?.preserve||a.remove())}});basePlugin.postcss=!0;const postcssPlugin=t=>{const s=Object.assign({enableProgressiveCustomProperties:!0,preserve:!0},t);return s.enableProgressiveCustomProperties&&s.preserve?{postcssPlugin:"postcss-double-position-gradients",plugins:[e(),basePlugin(s)]}:basePlugin(s)};postcssPlugin.postcss=!0;export{postcssPlugin as default};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "postcss-double-position-gradients",
3
3
  "description": "Use double-position gradients in CSS",
4
- "version": "5.0.2",
4
+ "version": "5.0.4",
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,23 +38,13 @@
35
38
  "dist"
36
39
  ],
37
40
  "dependencies": {
38
- "@csstools/postcss-progressive-custom-properties": "^3.0.2",
41
+ "@csstools/postcss-progressive-custom-properties": "^3.1.0",
42
+ "@csstools/utilities": "^1.0.0",
39
43
  "postcss-value-parser": "^4.2.0"
40
44
  },
41
45
  "peerDependencies": {
42
46
  "postcss": "^8.4"
43
47
  },
44
- "devDependencies": {
45
- "@csstools/postcss-tape": "*"
46
- },
47
- "scripts": {
48
- "build": "rollup -c ../../rollup/default.mjs",
49
- "docs": "node ../../.github/bin/generate-docs/install.mjs",
50
- "lint": "node ../../.github/bin/format-package-json.mjs",
51
- "prepublishOnly": "npm run build && npm run test",
52
- "test": "node .tape.mjs && node ./test/_import.mjs && node ./test/_require.cjs",
53
- "test:rewrite-expects": "REWRITE_EXPECTS=true node .tape.mjs"
54
- },
55
48
  "homepage": "https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-double-position-gradients#readme",
56
49
  "repository": {
57
50
  "type": "git",
@@ -73,12 +66,5 @@
73
66
  "repeating",
74
67
  "stop",
75
68
  "syntax"
76
- ],
77
- "csstools": {
78
- "exportName": "postcssDoublePositionGradients",
79
- "humanReadableName": "PostCSS Double Position Gradients"
80
- },
81
- "volta": {
82
- "extends": "../../package.json"
83
- }
69
+ ]
84
70
  }
@@ -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;
@@ -1,2 +0,0 @@
1
- export declare const HAS_GRADIENT_FUNCTION: RegExp;
2
- export declare const IS_GRADIENT_FUNCTION: RegExp;