postcss-double-position-gradients 4.0.2 → 4.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 +10 -0
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +18 -14
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changes to PostCSS Double Position Gradients
|
|
2
2
|
|
|
3
|
+
### 4.0.4 (June 1, 2023)
|
|
4
|
+
|
|
5
|
+
- Updated `@csstools/postcss-progressive-custom-properties` to `2.3.0` (minor)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### 4.0.3 (May 19, 2023)
|
|
9
|
+
|
|
10
|
+
- Updated `@csstools/postcss-progressive-custom-properties` to `2.2.0` (minor)
|
|
11
|
+
|
|
12
|
+
|
|
3
13
|
### 4.0.2 (February 8, 2023)
|
|
4
14
|
|
|
5
15
|
- Reduce the amount of duplicate fallback CSS.
|
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(),n=t.index(e);for(let e=0;e<n;e++){const n=t.nodes[e];if("decl"===n.type&&n.prop.toLowerCase()===r)return!0}return!1}function includesGradientsFunction(e){return e.includes("conic-gradient(")||e.includes("linear-gradient(")||e.includes("radial-gradient(")||e.includes("repeating-conic-gradient(")||e.includes("repeating-linear-gradient(")||e.includes("repeating-radial-gradient(")}function hasSupportsAtRuleAncestor(e){let t=e.parent;for(;t;)if("atrule"===t.type){if("supports"===t.name.toLowerCase()&&includesGradientsFunction(t.params.toLowerCase()))return!0;t=t.parent}else t=t.parent;return!1}const r=["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:s}){if(!includesGradientsFunction(n.value.toLowerCase()))return;if(hasFallback(n))return;if(hasSupportsAtRuleAncestor(n))return;let i;try{i=t(n.value)}catch(e){n.warn(s,`Failed to parse value '${n.value}' as a CSS gradient. Leaving the original value intact.`)}if(void 0===i)return;i.walk((e=>{if("function"!==e.type||"conic-gradient"!==(t=e.value.toLowerCase())&&"linear-gradient"!==t&&"radial-gradient"!==t&&"repeating-conic-gradient"!==t&&"repeating-linear-gradient"!==t&&"repeating-radial-gradient"!==t)return;var t;const n=e.nodes.filter((e=>"comment"!==e.type&&"space"!==e.type));let s=!1;n.forEach(((t,n,i)=>{if("word"===t.type&&r.includes(t.value.toLowerCase())&&(s=!0),"div"===t.type&&","===t.value&&(s=!1),s)return;const o=Object(i[n-1]),a=Object(i[n-2]),c=Object(i[n+1]);if(a.type&&isNumericNode(o)&&isNumericNode(t)){const r=a,n={type:"div",value:",",before:isPunctuationCommaNode(c)?c.before:"",after:isPunctuationCommaNode(c)?"":" "};e.nodes.splice(e.nodes.indexOf(t)-1,0,n,r)}}))}));const o=i.toString();o!==n.value&&(n.cloneBefore({value:o}),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(),n=t.index(e);for(let e=0;e<n;e++){const n=t.nodes[e];if("decl"===n.type&&n.prop.toLowerCase()===r)return!0}return!1}function includesGradientsFunction(e){return e.includes("conic-gradient(")||e.includes("linear-gradient(")||e.includes("radial-gradient(")||e.includes("repeating-conic-gradient(")||e.includes("repeating-linear-gradient(")||e.includes("repeating-radial-gradient(")}function hasSupportsAtRuleAncestor(e){let t=e.parent;for(;t;)if("atrule"===t.type){if("supports"===t.name.toLowerCase()&&includesGradientsFunction(t.params.toLowerCase()))return!0;t=t.parent}else t=t.parent;return!1}const r=["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:s}){if(!includesGradientsFunction(n.value.toLowerCase()))return;if(hasFallback(n))return;if(hasSupportsAtRuleAncestor(n))return;let i;try{i=t(n.value)}catch(e){n.warn(s,`Failed to parse value '${n.value}' as a CSS gradient. Leaving the original value intact.`)}if(void 0===i)return;i.walk((e=>{if("function"!==e.type||"conic-gradient"!==(t=e.value.toLowerCase())&&"linear-gradient"!==t&&"radial-gradient"!==t&&"repeating-conic-gradient"!==t&&"repeating-linear-gradient"!==t&&"repeating-radial-gradient"!==t)return;var t;const n=e.nodes.filter((e=>"comment"!==e.type&&"space"!==e.type));let s=!1;n.forEach(((t,n,i)=>{if("word"===t.type&&r.includes(t.value.toLowerCase())&&(s=!0),"div"===t.type&&","===t.value&&(s=!1),s)return;const o=Object(i[n-1]),a=Object(i[n-2]),c=Object(i[n+1]);if(a.type&&isNumericNode(o)&&isNumericNode(t)){const r=a,n={type:"div",value:",",before:isPunctuationCommaNode(c)?c.before:"",after:isPunctuationCommaNode(c)?"":" ",sourceIndex:0,sourceEndIndex:0};e.nodes.splice(e.nodes.indexOf(t)-1,0,n,r)}}))}));const o=i.toString();o!==n.value&&(n.cloneBefore({value:o}),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;
|
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(),n=t.index(e);for(let e=0;e<n;e++){const n=t.nodes[e];if("decl"===n.type&&n.prop.toLowerCase()===r)return!0}return!1}function includesGradientsFunction(e){return e.includes("conic-gradient(")||e.includes("linear-gradient(")||e.includes("radial-gradient(")||e.includes("repeating-conic-gradient(")||e.includes("repeating-linear-gradient(")||e.includes("repeating-radial-gradient(")}function hasSupportsAtRuleAncestor(e){let t=e.parent;for(;t;)if("atrule"===t.type){if("supports"===t.name.toLowerCase()&&includesGradientsFunction(t.params.toLowerCase()))return!0;t=t.parent}else t=t.parent;return!1}const r=["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:s}){if(!includesGradientsFunction(n.value.toLowerCase()))return;if(hasFallback(n))return;if(hasSupportsAtRuleAncestor(n))return;let i;try{i=t(n.value)}catch(e){n.warn(s,`Failed to parse value '${n.value}' as a CSS gradient. Leaving the original value intact.`)}if(void 0===i)return;i.walk((e=>{if("function"!==e.type||"conic-gradient"!==(t=e.value.toLowerCase())&&"linear-gradient"!==t&&"radial-gradient"!==t&&"repeating-conic-gradient"!==t&&"repeating-linear-gradient"!==t&&"repeating-radial-gradient"!==t)return;var t;const n=e.nodes.filter((e=>"comment"!==e.type&&"space"!==e.type));let s=!1;n.forEach(((t,n,i)=>{if("word"===t.type&&r.includes(t.value.toLowerCase())&&(s=!0),"div"===t.type&&","===t.value&&(s=!1),s)return;const o=Object(i[n-1]),a=Object(i[n-2]),c=Object(i[n+1]);if(a.type&&isNumericNode(o)&&isNumericNode(t)){const r=a,n={type:"div",value:",",before:isPunctuationCommaNode(c)?c.before:"",after:isPunctuationCommaNode(c)?"":" "};e.nodes.splice(e.nodes.indexOf(t)-1,0,n,r)}}))}));const o=i.toString();o!==n.value&&(n.cloneBefore({value:o}),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(),n=t.index(e);for(let e=0;e<n;e++){const n=t.nodes[e];if("decl"===n.type&&n.prop.toLowerCase()===r)return!0}return!1}function includesGradientsFunction(e){return e.includes("conic-gradient(")||e.includes("linear-gradient(")||e.includes("radial-gradient(")||e.includes("repeating-conic-gradient(")||e.includes("repeating-linear-gradient(")||e.includes("repeating-radial-gradient(")}function hasSupportsAtRuleAncestor(e){let t=e.parent;for(;t;)if("atrule"===t.type){if("supports"===t.name.toLowerCase()&&includesGradientsFunction(t.params.toLowerCase()))return!0;t=t.parent}else t=t.parent;return!1}const r=["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:s}){if(!includesGradientsFunction(n.value.toLowerCase()))return;if(hasFallback(n))return;if(hasSupportsAtRuleAncestor(n))return;let i;try{i=t(n.value)}catch(e){n.warn(s,`Failed to parse value '${n.value}' as a CSS gradient. Leaving the original value intact.`)}if(void 0===i)return;i.walk((e=>{if("function"!==e.type||"conic-gradient"!==(t=e.value.toLowerCase())&&"linear-gradient"!==t&&"radial-gradient"!==t&&"repeating-conic-gradient"!==t&&"repeating-linear-gradient"!==t&&"repeating-radial-gradient"!==t)return;var t;const n=e.nodes.filter((e=>"comment"!==e.type&&"space"!==e.type));let s=!1;n.forEach(((t,n,i)=>{if("word"===t.type&&r.includes(t.value.toLowerCase())&&(s=!0),"div"===t.type&&","===t.value&&(s=!1),s)return;const o=Object(i[n-1]),a=Object(i[n-2]),c=Object(i[n+1]);if(a.type&&isNumericNode(o)&&isNumericNode(t)){const r=a,n={type:"div",value:",",before:isPunctuationCommaNode(c)?c.before:"",after:isPunctuationCommaNode(c)?"":" ",sourceIndex:0,sourceEndIndex:0};e.nodes.splice(e.nodes.indexOf(t)-1,0,n,r)}}))}));const o=i.toString();o!==n.value&&(n.cloneBefore({value:o}),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};
|
package/package.json
CHANGED
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "postcss-double-position-gradients",
|
|
3
3
|
"description": "Use double-position gradients in CSS",
|
|
4
|
-
"version": "4.0.
|
|
4
|
+
"version": "4.0.4",
|
|
5
5
|
"author": "Jonathan Neal <jonathantneal@hotmail.com>",
|
|
6
6
|
"license": "CC0-1.0",
|
|
7
|
-
"funding":
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
"funding": [
|
|
8
|
+
{
|
|
9
|
+
"type": "github",
|
|
10
|
+
"url": "https://github.com/sponsors/csstools"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"type": "opencollective",
|
|
14
|
+
"url": "https://opencollective.com/csstools"
|
|
15
|
+
}
|
|
16
|
+
],
|
|
11
17
|
"engines": {
|
|
12
18
|
"node": "^14 || ^16 || >=18"
|
|
13
19
|
},
|
|
@@ -29,23 +35,21 @@
|
|
|
29
35
|
"dist"
|
|
30
36
|
],
|
|
31
37
|
"dependencies": {
|
|
32
|
-
"@csstools/postcss-progressive-custom-properties": "^2.
|
|
38
|
+
"@csstools/postcss-progressive-custom-properties": "^2.3.0",
|
|
33
39
|
"postcss-value-parser": "^4.2.0"
|
|
34
40
|
},
|
|
35
41
|
"peerDependencies": {
|
|
36
42
|
"postcss": "^8.4"
|
|
37
43
|
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@csstools/postcss-tape": "*"
|
|
46
|
+
},
|
|
38
47
|
"scripts": {
|
|
39
|
-
"prebuild": "npm run clean",
|
|
40
48
|
"build": "rollup -c ../../rollup/default.mjs",
|
|
41
|
-
"clean": "node -e \"fs.rmSync('./dist', { recursive: true, force: true }); fs.mkdirSync('./dist');\"",
|
|
42
49
|
"docs": "node ../../.github/bin/generate-docs/install.mjs",
|
|
43
|
-
"lint": "
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"prepublishOnly": "npm run clean && npm run build && npm run test",
|
|
47
|
-
"test": "node .tape.mjs && npm run test:exports",
|
|
48
|
-
"test:exports": "node ./test/_import.mjs && node ./test/_require.cjs",
|
|
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",
|
|
49
53
|
"test:rewrite-expects": "REWRITE_EXPECTS=true node .tape.mjs"
|
|
50
54
|
},
|
|
51
55
|
"homepage": "https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-double-position-gradients#readme",
|