@csstools/postcss-gradient-stop-increments-experimental 1.0.0 → 1.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,5 +1,11 @@
1
1
  # Changes to PostCSS Gradient Stop Increments
2
2
 
3
+ ### 1.0.1 (April 10, 2023)
4
+
5
+ - Updated `@csstools/css-tokenizer` to `2.1.1` (patch)
6
+ - Updated `@csstools/css-parser-algorithms` to `2.1.1` (patch)
7
+ - Updated `@csstools/css-calc` to `1.1.1` (patch)
8
+
3
9
  ### 1.0.0 (March 21, 2023)
4
10
 
5
11
  - Initial version
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var e=require("@csstools/css-parser-algorithms"),n=require("@csstools/css-calc"),o=require("@csstools/css-tokenizer");const t=/(repeating-)?(linear|radial|conic)-gradient\(/i,a=/^(repeating-)?(linear|radial|conic)-gradient$/i,i=/^(abs|acos|asin|atan|atan2|calc|clamp|cos|exp|hypot|log|max|min|mod|pow|rem|round|sign|sin|sqrt|tan)$/i,creator=n=>{const s=Object.assign({preserve:!1},n);return{postcssPlugin:"postcss-gradient-stop-increments",Declaration(n){if(!t.test(n.value))return;if(!o.tokenize({css:n.value}).find((e=>e[0]===o.TokenType.Delim&&"+"===e[4].value)))return;const r=replaceComponentValues(e.parseCommaSeparatedListOfComponentValues(o.tokenize({css:n.value})),(n=>{if(!e.isFunctionNode(n))return;const t=n.getName();if(!a.test(t))return;let s=null;for(let t=0;t<n.value.length;t++){const a=n.value[t];if(e.isTokenNode(a)&&a.value[0]===o.TokenType.Delim&&"+"===a.value[4].value){const i=a,r=t;for(;e.isCommentNode(n.value[t+1]);)t++;if(t++,isZeroOrNegative(n.value[t])){const a=new e.TokenNode([o.TokenType.Number,"0",-1,-1,{value:0,type:o.NumberType.Integer}]);n.value.splice(r,t-r+1,a),t=n.value.indexOf(a);continue}const c=incrementLengthNode(s,i,n.value[t]);n.value.splice(r,t-r+1,c),s=c,t=n.value.indexOf(c)}else(isNumericLargerThanZero(a)||e.isFunctionNode(a)&&i.test(a.getName()))&&(s=maxOfLastAndCurrentLengthNode(s,a))}})).map((e=>e.map((e=>o.stringify(...e.tokens()))).join(""))).join(",");r!==n.value&&(n.cloneBefore({value:r}),null!=s&&s.preserve||n.remove())}}};function isNumericLargerThanZero(n){return!(!e.isTokenNode(n)||n.value[0]!==o.TokenType.Percentage&&n.value[0]!==o.TokenType.Dimension&&n.value[0]!==o.TokenType.Number||!(n.value[4].value>0))}function isZeroOrNegative(n){return!(!e.isTokenNode(n)||n.value[0]!==o.TokenType.Percentage&&n.value[0]!==o.TokenType.Dimension&&n.value[0]!==o.TokenType.Number||!(n.value[4].value<=0))}function incrementLengthNode(t,a,i){if(!t)return i;const s=new e.FunctionNode([o.TokenType.Function,"calc(",-1,-1,{value:"calc"}],[o.TokenType.CloseParen,")",-1,-1,void 0],[t,new e.WhitespaceNode([[o.TokenType.Whitespace," ",-1,-1,void 0]]),a,new e.WhitespaceNode([[o.TokenType.Whitespace," ",-1,-1,void 0]]),i]),[[r]]=n.calcFromComponentValues([[s]]);return r}function maxOfLastAndCurrentLengthNode(t,a){if(!t)return a;const i=new e.FunctionNode([o.TokenType.Function,"max(",-1,-1,{value:"max"}],[o.TokenType.CloseParen,")",-1,-1,void 0],[t,new e.TokenNode([o.TokenType.Comma,",",-1,-1,void 0]),new e.WhitespaceNode([[o.TokenType.Whitespace," ",-1,-1,void 0]]),a]),[[s]]=n.calcFromComponentValues([[i]]);return s}function replaceComponentValues(n,o){for(let t=0;t<n.length;t++){const a=n[t];for(let n=0;n<a.length;n++){const t=a[n];{const e=o(t);if(e){a.splice(n,1,e);continue}}(e.isSimpleBlockNode(t)||e.isFunctionNode(t))&&t.walk(((e,n)=>{if("number"!=typeof n)return;const t=e.node,a=o(t);a&&e.parent.value.splice(n,1,a)}))}}return n}creator.postcss=!0,module.exports=creator;
1
+ "use strict";var e=require("@csstools/css-parser-algorithms"),n=require("@csstools/css-calc"),o=require("@csstools/css-tokenizer");const t=/(repeating-)?(linear|radial|conic)-gradient\(/i,a=/^(repeating-)?(linear|radial|conic)-gradient$/i,i=/^(abs|acos|asin|atan|atan2|calc|clamp|cos|exp|hypot|log|max|min|mod|pow|rem|round|sign|sin|sqrt|tan)$/i,creator=n=>{const r=Object.assign({preserve:!1},n);return{postcssPlugin:"postcss-gradient-stop-increments",Declaration(n){if(!t.test(n.value))return;const s=o.tokenize({css:n.value});if(!s.find((e=>e[0]===o.TokenType.Delim&&"+"===e[4].value)))return;const u=e.stringify(e.replaceComponentValues(e.parseCommaSeparatedListOfComponentValues(s),(n=>{if(!e.isFunctionNode(n))return;const t=n.getName();if(!a.test(t))return;let r=null;for(let t=0;t<n.value.length;t++){const a=n.value[t];if(e.isTokenNode(a)&&a.value[0]===o.TokenType.Delim&&"+"===a.value[4].value){const i=a,s=t;for(;e.isCommentNode(n.value[t+1]);)t++;if(t++,isZeroOrNegative(n.value[t])){const a=new e.TokenNode([o.TokenType.Number,"0",-1,-1,{value:0,type:o.NumberType.Integer}]);n.value.splice(s,t-s+1,a),t=n.value.indexOf(a);continue}const u=incrementLengthNode(r,i,n.value[t]);n.value.splice(s,t-s+1,u),r=u,t=n.value.indexOf(u)}else(isNumericLargerThanZero(a)||e.isFunctionNode(a)&&i.test(a.getName()))&&(r=maxOfLastAndCurrentLengthNode(r,a))}})));u!==n.value&&(n.cloneBefore({value:u}),null!=r&&r.preserve||n.remove())}}};function isNumericLargerThanZero(n){return!(!e.isTokenNode(n)||n.value[0]!==o.TokenType.Percentage&&n.value[0]!==o.TokenType.Dimension&&n.value[0]!==o.TokenType.Number||!(n.value[4].value>0))}function isZeroOrNegative(n){return!(!e.isTokenNode(n)||n.value[0]!==o.TokenType.Percentage&&n.value[0]!==o.TokenType.Dimension&&n.value[0]!==o.TokenType.Number||!(n.value[4].value<=0))}function incrementLengthNode(t,a,i){if(!t)return i;const r=new e.FunctionNode([o.TokenType.Function,"calc(",-1,-1,{value:"calc"}],[o.TokenType.CloseParen,")",-1,-1,void 0],[t,new e.WhitespaceNode([[o.TokenType.Whitespace," ",-1,-1,void 0]]),a,new e.WhitespaceNode([[o.TokenType.Whitespace," ",-1,-1,void 0]]),i]),[[s]]=n.calcFromComponentValues([[r]]);return s}function maxOfLastAndCurrentLengthNode(t,a){if(!t)return a;const i=new e.FunctionNode([o.TokenType.Function,"max(",-1,-1,{value:"max"}],[o.TokenType.CloseParen,")",-1,-1,void 0],[t,new e.TokenNode([o.TokenType.Comma,",",-1,-1,void 0]),new e.WhitespaceNode([[o.TokenType.Whitespace," ",-1,-1,void 0]]),a]),[[r]]=n.calcFromComponentValues([[i]]);return r}creator.postcss=!0,module.exports=creator;
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{parseCommaSeparatedListOfComponentValues as e,isSimpleBlockNode as n,isFunctionNode as t,isTokenNode as a,isCommentNode as r,TokenNode as o,FunctionNode as s,WhitespaceNode as i}from"@csstools/css-parser-algorithms";import{calcFromComponentValues as l}from"@csstools/css-calc";import{tokenize as u,TokenType as c,stringify as v,NumberType as m}from"@csstools/css-tokenizer";const p=/(repeating-)?(linear|radial|conic)-gradient\(/i,f=/^(repeating-)?(linear|radial|conic)-gradient$/i,g=/^(abs|acos|asin|atan|atan2|calc|clamp|cos|exp|hypot|log|max|min|mod|pow|rem|round|sign|sin|sqrt|tan)$/i,creator=n=>{const s=Object.assign({preserve:!1},n);return{postcssPlugin:"postcss-gradient-stop-increments",Declaration(n){if(!p.test(n.value))return;if(!u({css:n.value}).find((e=>e[0]===c.Delim&&"+"===e[4].value)))return;const i=replaceComponentValues(e(u({css:n.value})),(e=>{if(!t(e))return;const n=e.getName();if(!f.test(n))return;let s=null;for(let n=0;n<e.value.length;n++){const i=e.value[n];if(a(i)&&i.value[0]===c.Delim&&"+"===i.value[4].value){const t=i,a=n;for(;r(e.value[n+1]);)n++;if(n++,isZeroOrNegative(e.value[n])){const t=new o([c.Number,"0",-1,-1,{value:0,type:m.Integer}]);e.value.splice(a,n-a+1,t),n=e.value.indexOf(t);continue}const l=incrementLengthNode(s,t,e.value[n]);e.value.splice(a,n-a+1,l),s=l,n=e.value.indexOf(l)}else(isNumericLargerThanZero(i)||t(i)&&g.test(i.getName()))&&(s=maxOfLastAndCurrentLengthNode(s,i))}})).map((e=>e.map((e=>v(...e.tokens()))).join(""))).join(",");i!==n.value&&(n.cloneBefore({value:i}),null!=s&&s.preserve||n.remove())}}};function isNumericLargerThanZero(e){return!(!a(e)||e.value[0]!==c.Percentage&&e.value[0]!==c.Dimension&&e.value[0]!==c.Number||!(e.value[4].value>0))}function isZeroOrNegative(e){return!(!a(e)||e.value[0]!==c.Percentage&&e.value[0]!==c.Dimension&&e.value[0]!==c.Number||!(e.value[4].value<=0))}function incrementLengthNode(e,n,t){if(!e)return t;const a=new s([c.Function,"calc(",-1,-1,{value:"calc"}],[c.CloseParen,")",-1,-1,void 0],[e,new i([[c.Whitespace," ",-1,-1,void 0]]),n,new i([[c.Whitespace," ",-1,-1,void 0]]),t]),[[r]]=l([[a]]);return r}function maxOfLastAndCurrentLengthNode(e,n){if(!e)return n;const t=new s([c.Function,"max(",-1,-1,{value:"max"}],[c.CloseParen,")",-1,-1,void 0],[e,new o([c.Comma,",",-1,-1,void 0]),new i([[c.Whitespace," ",-1,-1,void 0]]),n]),[[a]]=l([[t]]);return a}function replaceComponentValues(e,a){for(let r=0;r<e.length;r++){const o=e[r];for(let e=0;e<o.length;e++){const r=o[e];{const n=a(r);if(n){o.splice(e,1,n);continue}}(n(r)||t(r))&&r.walk(((e,n)=>{if("number"!=typeof n)return;const t=e.node,r=a(t);r&&e.parent.value.splice(n,1,r)}))}}return e}creator.postcss=!0;export{creator as default};
1
+ import{stringify as e,replaceComponentValues as n,parseCommaSeparatedListOfComponentValues as t,isFunctionNode as a,isTokenNode as r,isCommentNode as i,TokenNode as s,FunctionNode as o,WhitespaceNode as l}from"@csstools/css-parser-algorithms";import{calcFromComponentValues as u}from"@csstools/css-calc";import{tokenize as c,TokenType as v,NumberType as m}from"@csstools/css-tokenizer";const f=/(repeating-)?(linear|radial|conic)-gradient\(/i,g=/^(repeating-)?(linear|radial|conic)-gradient$/i,d=/^(abs|acos|asin|atan|atan2|calc|clamp|cos|exp|hypot|log|max|min|mod|pow|rem|round|sign|sin|sqrt|tan)$/i,creator=o=>{const l=Object.assign({preserve:!1},o);return{postcssPlugin:"postcss-gradient-stop-increments",Declaration(o){if(!f.test(o.value))return;const u=c({css:o.value});if(!u.find((e=>e[0]===v.Delim&&"+"===e[4].value)))return;const p=e(n(t(u),(e=>{if(!a(e))return;const n=e.getName();if(!g.test(n))return;let t=null;for(let n=0;n<e.value.length;n++){const o=e.value[n];if(r(o)&&o.value[0]===v.Delim&&"+"===o.value[4].value){const a=o,r=n;for(;i(e.value[n+1]);)n++;if(n++,isZeroOrNegative(e.value[n])){const t=new s([v.Number,"0",-1,-1,{value:0,type:m.Integer}]);e.value.splice(r,n-r+1,t),n=e.value.indexOf(t);continue}const l=incrementLengthNode(t,a,e.value[n]);e.value.splice(r,n-r+1,l),t=l,n=e.value.indexOf(l)}else(isNumericLargerThanZero(o)||a(o)&&d.test(o.getName()))&&(t=maxOfLastAndCurrentLengthNode(t,o))}})));p!==o.value&&(o.cloneBefore({value:p}),null!=l&&l.preserve||o.remove())}}};function isNumericLargerThanZero(e){return!(!r(e)||e.value[0]!==v.Percentage&&e.value[0]!==v.Dimension&&e.value[0]!==v.Number||!(e.value[4].value>0))}function isZeroOrNegative(e){return!(!r(e)||e.value[0]!==v.Percentage&&e.value[0]!==v.Dimension&&e.value[0]!==v.Number||!(e.value[4].value<=0))}function incrementLengthNode(e,n,t){if(!e)return t;const a=new o([v.Function,"calc(",-1,-1,{value:"calc"}],[v.CloseParen,")",-1,-1,void 0],[e,new l([[v.Whitespace," ",-1,-1,void 0]]),n,new l([[v.Whitespace," ",-1,-1,void 0]]),t]),[[r]]=u([[a]]);return r}function maxOfLastAndCurrentLengthNode(e,n){if(!e)return n;const t=new o([v.Function,"max(",-1,-1,{value:"max"}],[v.CloseParen,")",-1,-1,void 0],[e,new s([v.Comma,",",-1,-1,void 0]),new l([[v.Whitespace," ",-1,-1,void 0]]),n]),[[a]]=u([[t]]);return a}creator.postcss=!0;export{creator as default};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@csstools/postcss-gradient-stop-increments-experimental",
3
3
  "description": "Increment CSS gradient stops",
4
- "version": "1.0.0",
4
+ "version": "1.0.1",
5
5
  "contributors": [
6
6
  {
7
7
  "name": "Antonio Laguna",
@@ -39,9 +39,9 @@
39
39
  "dist"
40
40
  ],
41
41
  "dependencies": {
42
- "@csstools/css-calc": "1.0.0",
43
- "@csstools/css-parser-algorithms": "2.0.1",
44
- "@csstools/css-tokenizer": "^2.1.0"
42
+ "@csstools/css-calc": "^1.1.1",
43
+ "@csstools/css-parser-algorithms": "^2.1.1",
44
+ "@csstools/css-tokenizer": "^2.1.1"
45
45
  },
46
46
  "peerDependencies": {
47
47
  "postcss": "^8.4"
@@ -61,7 +61,7 @@
61
61
  "repository": {
62
62
  "type": "git",
63
63
  "url": "https://github.com/csstools/postcss-plugins.git",
64
- "directory": "plugins/postcss-gradient-stop-increments"
64
+ "directory": "experimental/postcss-gradient-stop-increments"
65
65
  },
66
66
  "bugs": "https://github.com/csstools/postcss-plugins/issues",
67
67
  "keywords": [