postcss-double-position-gradients 5.0.2 → 5.0.3

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,12 @@
1
1
  # Changes to PostCSS Double Position Gradients
2
2
 
3
+ ### 5.0.3
4
+
5
+ _December 15, 2023_
6
+
7
+ - Fix type definitions
8
+ - 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)
9
+
3
10
  ### 5.0.2
4
11
 
5
12
  _October 9, 2023_
@@ -13,130 +20,4 @@ _September 18, 2023_
13
20
  - Improve performance
14
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)
15
22
 
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.
58
-
59
- ### 3.1.1
60
-
61
- _March 7, 2022_
62
-
63
- - Add TypeScript support
64
- - Fix color functions.
65
- - Fix `at` keyword with `at 20px 20px` being interpreted as a double position color stop.
66
-
67
- ### 3.1.0
68
-
69
- _February 15, 2022_
70
-
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)
137
-
138
- ### 1.0.0
139
-
140
- _October 28, 2018_
141
-
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
@@ -97,7 +97,8 @@ postcssDoublePositionGradients({ preserve: false })
97
97
  The `enableProgressiveCustomProperties` option determines whether the original notation
98
98
  is wrapped with `@supports` when used in Custom Properties. By default, it is enabled.
99
99
 
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).
100
+ > [!NOTE]
101
+ > 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).
101
102
 
102
103
  ```js
103
104
  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");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(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}),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;
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";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(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}),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};
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.3",
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,12 @@
35
38
  "dist"
36
39
  ],
37
40
  "dependencies": {
38
- "@csstools/postcss-progressive-custom-properties": "^3.0.2",
41
+ "@csstools/postcss-progressive-custom-properties": "^3.0.3",
39
42
  "postcss-value-parser": "^4.2.0"
40
43
  },
41
44
  "peerDependencies": {
42
45
  "postcss": "^8.4"
43
46
  },
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
47
  "homepage": "https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-double-position-gradients#readme",
56
48
  "repository": {
57
49
  "type": "git",
@@ -73,12 +65,5 @@
73
65
  "repeating",
74
66
  "stop",
75
67
  "syntax"
76
- ],
77
- "csstools": {
78
- "exportName": "postcssDoublePositionGradients",
79
- "humanReadableName": "PostCSS Double Position Gradients"
80
- },
81
- "volta": {
82
- "extends": "../../package.json"
83
- }
68
+ ]
84
69
  }
@@ -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;