epiphany/node_modules/@csstools/postcss-trigonometric-functions/dist/index.mjs
2023-12-09 22:48:07 -08:00

1 line
799 B
JavaScript

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};