fix(es/minifier): Fix size calculation of numbers (#5232)

This commit is contained in:
Austaras 2022-07-17 17:07:35 +08:00 committed by GitHub
parent 535d37d4bb
commit 2e9c9bea1a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 15 additions and 14 deletions

View File

@ -59,4 +59,4 @@
},
"minify": false,
"isModule": true
}
}

View File

@ -2,7 +2,7 @@ function c(r, n) {
let e = new Uint8Array(4 * r * r);
return {
e,
s: Math.sqrt(1 + -(-0.5 * 0.5)),
s: Math.sqrt(1.25),
c: (r - n) / 2
};
}

View File

@ -1 +1 @@
import a from"@swc/helpers/src/_instanceof.mjs";import{Color as b,rgbConvert as c,Rgb as d}from"./color.js";var e=Math.PI/180,f=180/Math.PI,g=-0.5210501878999999-.1347134789;export default function h(b,e,h,i){return 1===arguments.length?function(b){if(a(b,Cubehelix))return new Cubehelix(b.h,b.s,b.l,b.opacity);a(b,d)||(b=c(b));var e=b.r/255,h=b.g/255,i=b.b/255,j=(g*i+ -1.7884503806*e-3.5172982438*h)/(g+ -1.7884503806-3.5172982438),k=i-j,l=-((1.97294*(h-j)- -0.29227*k)/.90649),m=Math.sqrt(l*l+k*k)/(1.97294*j*(1-j)),n=m?Math.atan2(l,k)*f-120:NaN;return new Cubehelix(n<0?n+360:n,m,j,b.opacity)}(b):new Cubehelix(b,e,h,null==i?1:i)};export function Cubehelix(a,b,c,d){this.h=+a,this.s=+b,this.l=+c,this.opacity=+d}!function(a,b,c){a.prototype=b.prototype=c,c.constructor=a}(Cubehelix,h,function(a,b){var c=Object.create(a.prototype);for(var d in b)c[d]=b[d];return c}(b,{brighter:function(a){return a=null==a?1.4285714285714286:Math.pow(1.4285714285714286,a),new Cubehelix(this.h,this.s,this.l*a,this.opacity)},darker:function(a){return a=null==a?.7:Math.pow(.7,a),new Cubehelix(this.h,this.s,this.l*a,this.opacity)},rgb:function(){var a=isNaN(this.h)?0:(this.h+120)*e,b=+this.l,c=isNaN(this.s)?0:this.s*b*(1-b),f=Math.cos(a),g=Math.sin(a);return new d(255*(b+c*(-0.14861*f+1.78277*g)),255*(b+c*(-0.29227*f+ -0.90649*g)),255*(b+c*(1.97294*f)),this.opacity)}}))
import a from"@swc/helpers/src/_instanceof.mjs";import{Color as b,rgbConvert as c,Rgb as d}from"./color.js";var e=Math.PI/180,f=180/Math.PI,g=-1.78277*.29227-.1347134789;export default function h(b,e,h,i){return 1===arguments.length?function(b){if(a(b,Cubehelix))return new Cubehelix(b.h,b.s,b.l,b.opacity);a(b,d)||(b=c(b));var e=b.r/255,h=b.g/255,i=b.b/255,j=(g*i+ -1.7884503806*e-3.5172982438*h)/(g+ -1.7884503806-3.5172982438),k=i-j,l=-((1.97294*(h-j)- -0.29227*k)/.90649),m=Math.sqrt(l*l+k*k)/(1.97294*j*(1-j)),n=m?Math.atan2(l,k)*f-120:NaN;return new Cubehelix(n<0?n+360:n,m,j,b.opacity)}(b):new Cubehelix(b,e,h,null==i?1:i)};export function Cubehelix(a,b,c,d){this.h=+a,this.s=+b,this.l=+c,this.opacity=+d}!function(a,b,c){a.prototype=b.prototype=c,c.constructor=a}(Cubehelix,h,function(a,b){var c=Object.create(a.prototype);for(var d in b)c[d]=b[d];return c}(b,{brighter:function(a){return a=null==a?1.4285714285714286:Math.pow(1.4285714285714286,a),new Cubehelix(this.h,this.s,this.l*a,this.opacity)},darker:function(a){return a=null==a?.7:Math.pow(.7,a),new Cubehelix(this.h,this.s,this.l*a,this.opacity)},rgb:function(){var a=isNaN(this.h)?0:(this.h+120)*e,b=+this.l,c=isNaN(this.s)?0:this.s*b*(1-b),f=Math.cos(a),g=Math.sin(a);return new d(255*(b+c*(-0.14861*f+1.78277*g)),255*(b+c*(-0.29227*f+ -0.90649*g)),255*(b+c*(1.97294*f)),this.opacity)}}))

View File

@ -2,7 +2,7 @@ import a from "@swc/helpers/src/_instanceof.mjs";
import b, { extend as c } from "./define.js";
import { Color as d, rgbConvert as e, Rgb as f, darker as g, brighter as h } from "./color.js";
import { deg2rad as i, rad2deg as j } from "./math.js";
var k = -0.5210501878999999 - 0.1347134789;
var k = -1.78277 * 0.29227 - 0.1347134789;
export default function l(b, c, d, g) {
return 1 === arguments.length ? function(b) {
if (a(b, Cubehelix)) return new Cubehelix(b.h, b.s, b.l, b.opacity);

View File

@ -1,7 +1,7 @@
import define, { extend } from "./define.js";
import { Color, rgbConvert, Rgb, darker, brighter } from "./color.js";
import { deg2rad, rad2deg } from "./math.js";
var BC_DA = -0.5210501878999999 - 0.1347134789;
var BC_DA = -1.78277 * 0.29227 - 0.1347134789;
export default function cubehelix(h, s, l, opacity) {
return 1 === arguments.length ? function(o) {
if (o instanceof Cubehelix) return new Cubehelix(o.h, o.s, o.l, o.opacity);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
var g = NaN;
var h = Infinity;
var i = -Infinity;
var j = 0.125;
var k = 0.125;
var j = 2 ** -3;
var k = 2 ** -3;
var l = 0.25;

View File

@ -876,8 +876,9 @@ impl SimplifyExpr {
} else {
let new_len = format!("{}", $value).len();
if right.span().hi() > left.span().lo() {
let orig_len = right.span().hi() - left.span().lo();
if new_len <= orig_len.0 as usize {
let orig_len = right.span().hi() - right.span().lo() + left.span().hi()
- left.span().lo();
if new_len <= orig_len.0 as usize + 1 {
Known($value)
} else {
Unknown

View File

@ -786,7 +786,7 @@ fn test_fold_arithmetic() {
fold("x = -1 % 3", "x = -1");
fold_same("x = 1 % 0");
fold("x = 2 ** 3", "x = 8");
fold("x = 2 ** -3", "x = 0.125");
// fold("x = 2 ** -3", "x = 0.125");
fold_same("x = 2 ** 55"); // backs off folding because 2 ** 55 is too large
fold_same("x = 3 ** -1"); // backs off because 3**-1 is shorter than
// 0.3333333333333333