@csstools/postcss-trigonometric-functions 3.0.0 → 3.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,21 @@
1
1
  # Changes to PostCSS Trigonometric Functions
2
2
 
3
+ ### 3.0.1
4
+
5
+ _July 24, 2023_
6
+
7
+ - Use the latest utilities from `@csstools/css-tokenizer` to reduce the bundle size.
8
+ - Updated [`@csstools/css-tokenizer`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-tokenizer) to [`2.2.0`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-tokenizer/CHANGELOG.md#220) (minor)
9
+ - Updated [`@csstools/css-parser-algorithms`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-parser-algorithms) to [`2.3.1`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-parser-algorithms/CHANGELOG.md#231) (patch)
10
+ - Updated [`@csstools/css-calc`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-calc) to [`1.1.3`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-calc/CHANGELOG.md#113) (patch)
11
+
3
12
  ### 3.0.0
4
13
 
5
14
  _July 3, 2023_
6
15
 
7
16
  - Change license to `MIT-0` ([read more about this change in the blog post](https://preset-env.cssdb.org/blog/license-change/))
8
- - Updated [`@csstools/css-parser-algorithms`](/packages/css-parser-algorithms) to [`2.3.0`](/packages/css-parser-algorithms/CHANGELOG.md#230) (minor)
9
- - Updated [`@csstools/css-calc`](/packages/css-calc) to [`1.1.2`](/packages/css-calc/CHANGELOG.md#112) (patch)
17
+ - Updated [`@csstools/css-parser-algorithms`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-parser-algorithms) to [`2.3.0`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-parser-algorithms/CHANGELOG.md#230) (minor)
18
+ - Updated [`@csstools/css-calc`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-calc) to [`1.1.2`](https://github.com/csstools/postcss-plugins/tree/main/packages/css-calc/CHANGELOG.md#112) (patch)
10
19
 
11
20
  ### 2.1.1
12
21
 
package/dist/checks.d.ts CHANGED
@@ -1 +1,2 @@
1
- export declare const checks: string[];
1
+ export declare const FUNCTION_NAME_REGEXP: RegExp;
2
+ export declare const FUNCTION_CALL_REGEXP: RegExp;
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var e=require("@csstools/css-calc"),s=require("@csstools/css-parser-algorithms"),o=require("@csstools/css-tokenizer");const n=["asin(","acos(","atan(","atan2(","sin(","cos(","tan("];function calc(t){const r=o.tokenizer({css:t}),c=[];for(;!r.endOfFile();)c.push(r.nextToken());c.push(r.nextToken());const i=s.parseCommaSeparatedListOfComponentValues(c,{});let a=!1;for(let e=0;e<i.length;e++){const o=i[e];for(let e=0;e<o.length;e++){const t=o[e];if(s.isFunctionNode(t)&&n.includes(t.getName().toLowerCase()+"(")){a=!0;break}(s.isSimpleBlockNode(t)||s.isFunctionNode(t))&&t.walk(((e,o)=>{if("number"!=typeof o)return;const t=e.node;return s.isFunctionNode(t)&&n.includes(t.getName().toLowerCase()+"(")?(a=!0,!1):void 0}))}}return a?e.calcFromComponentValues(i,{precision:5,toCanonicalUnits:!0}).map((e=>e.map((e=>o.stringify(...e.tokens()))).join(""))).join(","):t}const creator=e=>{const s=Object.assign({preserve:!1},e);return{postcssPlugin:"postcss-trigonometric-functions",Declaration(e){if(!n.some((s=>e.value.toLowerCase().includes(s))))return;const o=calc(e.value);o!==e.value&&(e.cloneBefore({value:o}),s.preserve||e.remove())}}};creator.postcss=!0,module.exports=creator;
1
+ "use strict";var s=require("@csstools/css-calc"),e=require("@csstools/css-parser-algorithms"),o=require("@csstools/css-tokenizer");const t=["asin","acos","atan","atan2","sin","cos","tan"],n=new RegExp(`^(${t.join("|")})$`,"i"),c=new RegExp(`(${t.join("|")})\\(`,"i");function calc(t){const c=o.tokenize({css:t});return c.some((s=>s[0]===o.TokenType.Function&&n.test(s[4].value)))?e.stringify(s.calcFromComponentValues(e.parseCommaSeparatedListOfComponentValues(c),{precision:5,toCanonicalUnits:!0})):t}const creator=s=>{const e=Object.assign({preserve:!1},s);return{postcssPlugin:"postcss-trigonometric-functions",Declaration(s){if(!c.test(s.value))return;const o=calc(s.value);o!==s.value&&(s.cloneBefore({value:o}),e.preserve||s.remove())}}};creator.postcss=!0,module.exports=creator;
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{calcFromComponentValues as e}from"@csstools/css-calc";import{parseCommaSeparatedListOfComponentValues as s,isFunctionNode as o,isSimpleBlockNode as t}from"@csstools/css-parser-algorithms";import{tokenizer as n,stringify as r}from"@csstools/css-tokenizer";const c=["asin(","acos(","atan(","atan2(","sin(","cos(","tan("];function calc(a){const i=n({css:a}),l=[];for(;!i.endOfFile();)l.push(i.nextToken());l.push(i.nextToken());const u=s(l,{});let p=!1;for(let e=0;e<u.length;e++){const s=u[e];for(let e=0;e<s.length;e++){const n=s[e];if(o(n)&&c.includes(n.getName().toLowerCase()+"(")){p=!0;break}(t(n)||o(n))&&n.walk(((e,s)=>{if("number"!=typeof s)return;const t=e.node;return o(t)&&c.includes(t.getName().toLowerCase()+"(")?(p=!0,!1):void 0}))}}return p?e(u,{precision:5,toCanonicalUnits:!0}).map((e=>e.map((e=>r(...e.tokens()))).join(""))).join(","):a}const creator=e=>{const s=Object.assign({preserve:!1},e);return{postcssPlugin:"postcss-trigonometric-functions",Declaration(e){if(!c.some((s=>e.value.toLowerCase().includes(s))))return;const o=calc(e.value);o!==e.value&&(e.cloneBefore({value:o}),s.preserve||e.remove())}}};creator.postcss=!0;export{creator as default};
1
+ import{calcFromComponentValues as s}from"@csstools/css-calc";import{stringify as o,parseCommaSeparatedListOfComponentValues as t}from"@csstools/css-parser-algorithms";import{tokenize as e,TokenType as n}from"@csstools/css-tokenizer";const c=["asin","acos","atan","atan2","sin","cos","tan"],r=new RegExp(`^(${c.join("|")})$`,"i"),a=new RegExp(`(${c.join("|")})\\(`,"i");function calc(c){const a=e({css:c});return a.some((s=>s[0]===n.Function&&r.test(s[4].value)))?o(s(t(a),{precision:5,toCanonicalUnits:!0})):c}const creator=s=>{const o=Object.assign({preserve:!1},s);return{postcssPlugin:"postcss-trigonometric-functions",Declaration(s){if(!a.test(s.value))return;const t=calc(s.value);t!==s.value&&(s.cloneBefore({value:t}),o.preserve||s.remove())}}};creator.postcss=!0;export{creator as default};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@csstools/postcss-trigonometric-functions",
3
3
  "description": "Use sin(), cos(), tan(), acos(), atan(), and atan2() to compute trigonometric relationships",
4
- "version": "3.0.0",
4
+ "version": "3.0.1",
5
5
  "contributors": [
6
6
  {
7
7
  "name": "Antonio Laguna",
@@ -45,9 +45,9 @@
45
45
  "dist"
46
46
  ],
47
47
  "dependencies": {
48
- "@csstools/css-calc": "^1.1.2",
49
- "@csstools/css-parser-algorithms": "^2.3.0",
50
- "@csstools/css-tokenizer": "^2.1.1"
48
+ "@csstools/css-calc": "^1.1.3",
49
+ "@csstools/css-parser-algorithms": "^2.3.1",
50
+ "@csstools/css-tokenizer": "^2.2.0"
51
51
  },
52
52
  "peerDependencies": {
53
53
  "postcss": "^8.4"