postcss-double-position-gradients 3.1.2 → 4.0.1

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,12 +1,20 @@
1
1
  # Changes to PostCSS Double Position Gradients
2
2
 
3
+ ### 4.0.1 (January 28, 2023)
4
+
5
+ - Improve `types` declaration in `package.json`
6
+
7
+ ### 4.0.0 (January 24, 2023)
8
+
9
+ - Updated: Support for Node v14+ (major).
10
+
3
11
  ### 3.1.2 (July 8, 2022)
4
12
 
5
13
  - Fix case insensitive matching.
6
14
 
7
15
  ### 3.1.1 (March 7, 2022)
8
16
 
9
- - Add typescript support
17
+ - Add TypeScript support
10
18
  - Fix color functions.
11
19
  - Fix `at` keyword with `at 20px 20px` being interpreted as a double position color stop.
12
20
 
package/README.md CHANGED
@@ -58,8 +58,8 @@ postcss([
58
58
 
59
59
  [PostCSS Double Position Gradients] runs in all Node environments, with special instructions for:
60
60
 
61
- | [Node](INSTALL.md#node) | [PostCSS CLI](INSTALL.md#postcss-cli) | [Webpack](INSTALL.md#webpack) | [Create React App](INSTALL.md#create-react-app) | [Gulp](INSTALL.md#gulp) | [Grunt](INSTALL.md#grunt) |
62
- | --- | --- | --- | --- | --- | --- |
61
+ | [Node](INSTALL.md#node) | [PostCSS CLI](INSTALL.md#postcss-cli) | [Webpack](INSTALL.md#webpack) | [Gulp](INSTALL.md#gulp) | [Grunt](INSTALL.md#grunt) |
62
+ | --- | --- | --- | --- | --- |
63
63
 
64
64
  ## Options
65
65
 
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var e=require("@csstools/postcss-progressive-custom-properties"),t=require("postcss-value-parser");function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=r(e),s=r(t);function i(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(")}const a=["at","bottom","center","circle","closest-corner","closest-side","ellipse","farthest-corner","farthest-side","from","in","left","right","to","top"],o=e=>"div"===e.type&&","===e.value;function l(e){try{return!1!==s.default.unit(null==e?void 0:e.value)}catch(e){return!1}}const c=e=>({postcssPlugin:"postcss-double-position-gradients",Declaration(t,{result:r}){if(!i(t.value.toLowerCase()))return;if(function(e){let t=e.parent;for(;t;)if("atrule"===t.type){if("supports"===t.name.toLowerCase()&&i(t.params.toLowerCase()))return!0;t=t.parent}else t=t.parent;return!1}(t))return;let n;try{n=s.default(t.value)}catch(e){t.warn(r,`Failed to parse value '${t.value}' as a CSS gradient. Leaving the original value intact.`)}if(void 0===n)return;n.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 r=e.nodes.filter((e=>"comment"!==e.type&&"space"!==e.type));let n=!1;r.forEach(((t,r,s)=>{if("word"===t.type&&a.includes(t.value.toLowerCase())&&(n=!0),"div"===t.type&&","===t.value&&(n=!1),n)return;const i=Object(s[r-1]),c=Object(s[r-2]),u=Object(s[r+1]);if(c.type&&l(i)&&l(t)){const r=c,n={type:"div",value:",",before:o(u)?u.before:"",after:o(u)?"":" "};e.nodes.splice(e.nodes.indexOf(t)-1,0,n,r)}}))}));const c=n.toString();c!==t.value&&(t.cloneBefore({value:c}),e.preserve||t.remove())}});c.postcss=!0;const u=e=>{const t=Object.assign({enableProgressiveCustomProperties:!0,preserve:!0},e);return t.enableProgressiveCustomProperties&&t.preserve?{postcssPlugin:"postcss-double-position-gradients",plugins:[n.default(),c(t)]}:c(t)};u.postcss=!0,module.exports=u;
1
+ "use strict";var e=require("@csstools/postcss-progressive-custom-properties"),t=require("postcss-value-parser");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(s,{result:n}){if(!includesGradientsFunction(s.value.toLowerCase()))return;if(hasSupportsAtRuleAncestor(s))return;let i;try{i=t(s.value)}catch(e){s.warn(n,`Failed to parse value '${s.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 s=e.nodes.filter((e=>"comment"!==e.type&&"space"!==e.type));let n=!1;s.forEach(((t,s,i)=>{if("word"===t.type&&r.includes(t.value.toLowerCase())&&(n=!0),"div"===t.type&&","===t.value&&(n=!1),n)return;const o=Object(i[s-1]),a=Object(i[s-2]),c=Object(i[s+1]);if(a.type&&isNumericNode(o)&&isNumericNode(t)){const r=a,s={type:"div",value:",",before:isPunctuationCommaNode(c)?c.before:"",after:isPunctuationCommaNode(c)?"":" "};e.nodes.splice(e.nodes.indexOf(t)-1,0,s,r)}}))}));const o=i.toString();o!==s.value&&(s.cloneBefore({value:o}),e.preserve||s.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,6 +1,9 @@
1
1
  import type { PluginCreator } from 'postcss';
2
- declare type pluginOptions = {
2
+ /** postcss-double-position-gradients plugin options */
3
+ export type pluginOptions = {
4
+ /** Preserve the original notation. default: true */
3
5
  preserve?: boolean;
6
+ /** Enable "@csstools/postcss-progressive-custom-properties". default: true */
4
7
  enableProgressiveCustomProperties?: boolean;
5
8
  };
6
9
  declare const postcssPlugin: PluginCreator<pluginOptions>;
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import e from"@csstools/postcss-progressive-custom-properties";import t from"postcss-value-parser";function r(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(")}const n=["at","bottom","center","circle","closest-corner","closest-side","ellipse","farthest-corner","farthest-side","from","in","left","right","to","top"],s=e=>"div"===e.type&&","===e.value;function i(e){try{return!1!==t.unit(null==e?void 0:e.value)}catch(e){return!1}}const a=e=>({postcssPlugin:"postcss-double-position-gradients",Declaration(a,{result:o}){if(!r(a.value.toLowerCase()))return;if(function(e){let t=e.parent;for(;t;)if("atrule"===t.type){if("supports"===t.name.toLowerCase()&&r(t.params.toLowerCase()))return!0;t=t.parent}else t=t.parent;return!1}(a))return;let c;try{c=t(a.value)}catch(e){a.warn(o,`Failed to parse value '${a.value}' as a CSS gradient. Leaving the original value intact.`)}if(void 0===c)return;c.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 r=e.nodes.filter((e=>"comment"!==e.type&&"space"!==e.type));let a=!1;r.forEach(((t,r,o)=>{if("word"===t.type&&n.includes(t.value.toLowerCase())&&(a=!0),"div"===t.type&&","===t.value&&(a=!1),a)return;const c=Object(o[r-1]),l=Object(o[r-2]),u=Object(o[r+1]);if(l.type&&i(c)&&i(t)){const r=l,n={type:"div",value:",",before:s(u)?u.before:"",after:s(u)?"":" "};e.nodes.splice(e.nodes.indexOf(t)-1,0,n,r)}}))}));const l=c.toString();l!==a.value&&(a.cloneBefore({value:l}),e.preserve||a.remove())}});a.postcss=!0;const o=t=>{const r=Object.assign({enableProgressiveCustomProperties:!0,preserve:!0},t);return r.enableProgressiveCustomProperties&&r.preserve?{postcssPlugin:"postcss-double-position-gradients",plugins:[e(),a(r)]}:a(r)};o.postcss=!0;export{o as default};
1
+ import e from"@csstools/postcss-progressive-custom-properties";import t from"postcss-value-parser";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(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};
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": "3.1.2",
4
+ "version": "4.0.1",
5
5
  "author": "Jonathan Neal <jonathantneal@hotmail.com>",
6
6
  "license": "CC0-1.0",
7
7
  "funding": {
@@ -9,13 +9,14 @@
9
9
  "url": "https://opencollective.com/csstools"
10
10
  },
11
11
  "engines": {
12
- "node": "^12 || ^14 || >=16"
12
+ "node": "^14 || ^16 || >=18"
13
13
  },
14
14
  "main": "dist/index.cjs",
15
15
  "module": "dist/index.mjs",
16
16
  "types": "dist/index.d.ts",
17
17
  "exports": {
18
18
  ".": {
19
+ "types": "./dist/index.d.ts",
19
20
  "import": "./dist/index.mjs",
20
21
  "require": "./dist/index.cjs",
21
22
  "default": "./dist/index.mjs"
@@ -28,15 +29,16 @@
28
29
  "dist"
29
30
  ],
30
31
  "dependencies": {
31
- "@csstools/postcss-progressive-custom-properties": "^1.1.0",
32
+ "@csstools/postcss-progressive-custom-properties": "^2.0.0",
32
33
  "postcss-value-parser": "^4.2.0"
33
34
  },
34
35
  "peerDependencies": {
35
- "postcss": "^8.2"
36
+ "postcss": "^8.4"
36
37
  },
37
38
  "scripts": {
38
- "build": "rollup -c ../../rollup/default.js",
39
- "clean": "node -e \"fs.rmSync('./dist', { recursive: true, force: true });\"",
39
+ "prebuild": "npm run clean",
40
+ "build": "rollup -c ../../rollup/default.mjs",
41
+ "clean": "node -e \"fs.rmSync('./dist', { recursive: true, force: true }); fs.mkdirSync('./dist');\"",
40
42
  "docs": "node ../../.github/bin/generate-docs/install.mjs",
41
43
  "lint": "npm run lint:eslint && npm run lint:package-json",
42
44
  "lint:eslint": "eslint ./src --ext .js --ext .ts --ext .mjs --no-error-on-unmatched-pattern",