diff --git a/crates/swc/tests/fixture/codegen/escape/case-1/output/index.js b/crates/swc/tests/fixture/codegen/escape/case-1/output/index.js index fef6ecaf365..fe6fb0c7d1e 100644 --- a/crates/swc/tests/fixture/codegen/escape/case-1/output/index.js +++ b/crates/swc/tests/fixture/codegen/escape/case-1/output/index.js @@ -3,5 +3,5 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; -var _default = "\nvoid main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}\n"; +var _default = "\nvoid main() {\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}\n"; exports.default = _default; diff --git a/crates/swc/tests/fixture/codegen/escape/case-2/output/index.js b/crates/swc/tests/fixture/codegen/escape/case-2/output/index.js index ce68ef343e0..e78bab01ed5 100644 --- a/crates/swc/tests/fixture/codegen/escape/case-2/output/index.js +++ b/crates/swc/tests/fixture/codegen/escape/case-2/output/index.js @@ -3,5 +3,5 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; -var _default = '\n// Analytical approximation of the DFG LUT, one half of the\n// split-sum approximation used in indirect specular lighting.\n// via \'environmentBRDF\' from "Physically Based Shading on Mobile"\n// https://www.unrealengine.com/blog/physically-based-shading-on-mobile - environmentBRDF for GGX on mobile\nvec2 integrateSpecularBRDF( const in float dotNV, const in float roughness ) {\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\treturn vec2( -1.04, 1.04 ) * a004 + r.zw;\n}\nfloat punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\t// based upon Frostbite 3 Moving to Physically-based Rendering\n\t// page 32, equation 26: E[window1]\n\t// https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf\n\t// this is intended to be used on spot and point lights who are represented as luminous intensity\n\t// but who must be converted to luminous irradiance for surface lighting calculation\n\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\tif( cutoffDistance > 0.0 ) {\n\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t}\n\treturn distanceFalloff;\n#else\n\tif( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\t\treturn pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\t}\n\treturn 1.0;\n#endif\n}\nvec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n} // validated\nvec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\n\t// Original approximation by Christophe Schlick \'94\n\t// float fresnel = pow( 1.0 - dotLH, 5.0 );\n\t// Optimized variant (presented by Epic at SIGGRAPH \'13)\n\t// https://cdn2.unrealengine.com/Resources/files/2013SiggraphPresentationsNotes-26915738.pdf\n\tfloat fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\n\treturn ( 1.0 - specularColor ) * fresnel + specularColor;\n} // validated\nvec3 F_Schlick_RoughnessDependent( const in vec3 F0, const in float dotNV, const in float roughness ) {\n\t// See F_Schlick\n\tfloat fresnel = exp2( ( -5.55473 * dotNV - 6.98316 ) * dotNV );\n\tvec3 Fr = max( vec3( 1.0 - roughness ), F0 ) - F0;\n\treturn Fr * fresnel + F0;\n}\n// Microfacet Models for Refraction through Rough Surfaces - equation (34)\n// http://graphicrants.blogspot.com/2013/08/specular-brdf-reference.html\n// alpha is "roughness squared" in Disney\u2019s reparameterization\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\n\t// geometry term (normalized) = G(l)\u22C5G(v) / 4(n\u22C5l)(n\u22C5v)\n\t// also see #12151\n\tfloat a2 = pow2( alpha );\n\tfloat gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\tfloat gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\treturn 1.0 / ( gl * gv );\n} // validated\n// Moving Frostbite to Physically Based Rendering 3.0 - page 12, listing 2\n// https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf\nfloat G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\t// dotNL and dotNV are explicitly swapped. This is not a mistake.\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\n// Microfacet Models for Refraction through Rough Surfaces - equation (33)\n// http://graphicrants.blogspot.com/2013/08/specular-brdf-reference.html\n// alpha is "roughness squared" in Disney\u2019s reparameterization\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0; // avoid alpha = 0 with dotNH = 1\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\n// GGX Distribution, Schlick Fresnel, GGX-Smith Visibility\nvec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n\tfloat alpha = pow2( roughness ); // UE4\'s roughness\n\tvec3 halfDir = normalize( incidentLight.direction + viewDir );\n\tfloat dotNL = saturate( dot( normal, incidentLight.direction ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( G * D );\n} // validated\n// Rect Area Light\n// Real-Time Polygonal-Light Shading with Linearly Transformed Cosines\n// by Eric Heitz, Jonathan Dupuy, Stephen Hill and David Neubelt\n// code: https://github.com/selfshadow/ltc_code/\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\t// texture parameterized by sqrt( GGX alpha ) and sqrt( 1 - cos( theta ) )\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\t// Real-Time Area Lighting: a Journey from Research to Production (p.102)\n\t// An approximation of the form factor of a horizon-clipped rectangle.\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\t// rational polynomial approximation to theta / sin( theta ) / 2PI\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\t// bail if point is on back side of plane of light\n\t// assumes ccw winding order of light vertices\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\t// construct orthonormal basis around N\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 ); // negated from paper; possibly due to a different handedness of world coordinate system\n\t// compute transform\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\t// transform rect\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\t// project rect onto sphere\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\t// calculate vector form factor\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\t// adjust for horizon clipping\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n/*\n\t// alternate method of adjusting for horizon clipping (see referece)\n\t// refactoring required\n\tfloat len = length( vectorFormFactor );\n\tfloat z = vectorFormFactor.z / len;\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\t// tabulated horizon-clipped sphere, apparently...\n\tvec2 uv = vec2( z * 0.5 + 0.5, len );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\tfloat scale = texture2D( ltc_2, uv ).w;\n\tfloat result = len * scale;\n*/\n\treturn vec3( result );\n}\n// End Rect Area Light\n// ref: https://www.unrealengine.com/blog/physically-based-shading-on-mobile - environmentBRDF for GGX on mobile\nvec3 BRDF_Specular_GGX_Environment( const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tvec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n\treturn specularColor * brdf.x + brdf.y;\n} // validated\n// Fdez-Ag\xfcera\'s "Multiple-Scattering Microfacet Model for Real-Time Image Based Lighting"\n// Approximates multiscattering in order to preserve energy.\n// http://www.jcgt.org/published/0008/01/03/\nvoid BRDF_Specular_Multiscattering_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tvec3 F = F_Schlick_RoughnessDependent( specularColor, dotNV, roughness );\n\tvec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n\tvec3 FssEss = F * brdf.x + brdf.y;\n\tfloat Ess = brdf.x + brdf.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619; // 1/21\n\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\nfloat G_BlinnPhong_Implicit( /* const in float dotNL, const in float dotNV */ ) {\n\t// geometry term is (n dot l)(n dot v) / 4(n dot l)(n dot v)\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\t//float dotNL = saturate( dot( geometry.normal, incidentLight.direction ) );\n\t//float dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_BlinnPhong_Implicit( /* dotNL, dotNV */ );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n} // validated\n// source: http://simonstechblog.blogspot.ca/2011/12/microfacet-brdf.html\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\n\treturn ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );\n}\nfloat BlinnExponentToGGXRoughness( const in float blinnExponent ) {\n\treturn sqrt( 2.0 / ( blinnExponent + 2.0 ) );\n}\n#if defined( USE_SHEEN )\n// https://github.com/google/filament/blob/master/shaders/src/brdf.fs#L94\nfloat D_Charlie(float roughness, float NoH) {\n\t// Estevez and Kulla 2017, "Production Friendly Microfacet Sheen BRDF"\n\tfloat invAlpha = 1.0 / roughness;\n\tfloat cos2h = NoH * NoH;\n\tfloat sin2h = max(1.0 - cos2h, 0.0078125); // 2^(-14/2), so sin2h^2 > 0 in fp16\n\treturn (2.0 + invAlpha) * pow(sin2h, invAlpha * 0.5) / (2.0 * PI);\n}\n// https://github.com/google/filament/blob/master/shaders/src/brdf.fs#L136\nfloat V_Neubelt(float NoV, float NoL) {\n\t// Neubelt and Pettineo 2013, "Crafting a Next-gen Material Pipeline for The Order: 1886"\n\treturn saturate(1.0 / (4.0 * (NoL + NoV - NoL * NoV)));\n}\nvec3 BRDF_Specular_Sheen( const in float roughness, const in vec3 L, const in GeometricContext geometry, vec3 specularColor ) {\n\tvec3 N = geometry.normal;\n\tvec3 V = geometry.viewDir;\n\tvec3 H = normalize( V + L );\n\tfloat dotNH = saturate( dot( N, H ) );\n\treturn specularColor * D_Charlie( roughness, dotNH ) * V_Neubelt( dot(N, V), dot(N, L) );\n}\n#endif\n'; +var _default = '\n// Analytical approximation of the DFG LUT, one half of the\n// split-sum approximation used in indirect specular lighting.\n// via \'environmentBRDF\' from "Physically Based Shading on Mobile"\n// https://www.unrealengine.com/blog/physically-based-shading-on-mobile - environmentBRDF for GGX on mobile\nvec2 integrateSpecularBRDF( const in float dotNV, const in float roughness ) {\n const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n vec4 r = roughness * c0 + c1;\n float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n return vec2( -1.04, 1.04 ) * a004 + r.zw;\n}\nfloat punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n // based upon Frostbite 3 Moving to Physically-based Rendering\n // page 32, equation 26: E[window1]\n // https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf\n // this is intended to be used on spot and point lights who are represented as luminous intensity\n // but who must be converted to luminous irradiance for surface lighting calculation\n float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n if( cutoffDistance > 0.0 ) {\n distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n }\n return distanceFalloff;\n#else\n if( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n return pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n }\n return 1.0;\n#endif\n}\nvec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\n return RECIPROCAL_PI * diffuseColor;\n} // validated\nvec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\n // Original approximation by Christophe Schlick \'94\n // float fresnel = pow( 1.0 - dotLH, 5.0 );\n // Optimized variant (presented by Epic at SIGGRAPH \'13)\n // https://cdn2.unrealengine.com/Resources/files/2013SiggraphPresentationsNotes-26915738.pdf\n float fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\n return ( 1.0 - specularColor ) * fresnel + specularColor;\n} // validated\nvec3 F_Schlick_RoughnessDependent( const in vec3 F0, const in float dotNV, const in float roughness ) {\n // See F_Schlick\n float fresnel = exp2( ( -5.55473 * dotNV - 6.98316 ) * dotNV );\n vec3 Fr = max( vec3( 1.0 - roughness ), F0 ) - F0;\n return Fr * fresnel + F0;\n}\n// Microfacet Models for Refraction through Rough Surfaces - equation (34)\n// http://graphicrants.blogspot.com/2013/08/specular-brdf-reference.html\n// alpha is "roughness squared" in Disney\u2019s reparameterization\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\n // geometry term (normalized) = G(l)\u22C5G(v) / 4(n\u22C5l)(n\u22C5v)\n // also see #12151\n float a2 = pow2( alpha );\n float gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n float gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n return 1.0 / ( gl * gv );\n} // validated\n// Moving Frostbite to Physically Based Rendering 3.0 - page 12, listing 2\n// https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf\nfloat G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n float a2 = pow2( alpha );\n // dotNL and dotNV are explicitly swapped. This is not a mistake.\n float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n return 0.5 / max( gv + gl, EPSILON );\n}\n// Microfacet Models for Refraction through Rough Surfaces - equation (33)\n// http://graphicrants.blogspot.com/2013/08/specular-brdf-reference.html\n// alpha is "roughness squared" in Disney\u2019s reparameterization\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n float a2 = pow2( alpha );\n float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0; // avoid alpha = 0 with dotNH = 1\n return RECIPROCAL_PI * a2 / pow2( denom );\n}\n// GGX Distribution, Schlick Fresnel, GGX-Smith Visibility\nvec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n float alpha = pow2( roughness ); // UE4\'s roughness\n vec3 halfDir = normalize( incidentLight.direction + viewDir );\n float dotNL = saturate( dot( normal, incidentLight.direction ) );\n float dotNV = saturate( dot( normal, viewDir ) );\n float dotNH = saturate( dot( normal, halfDir ) );\n float dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n vec3 F = F_Schlick( specularColor, dotLH );\n float G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n float D = D_GGX( alpha, dotNH );\n return F * ( G * D );\n} // validated\n// Rect Area Light\n// Real-Time Polygonal-Light Shading with Linearly Transformed Cosines\n// by Eric Heitz, Jonathan Dupuy, Stephen Hill and David Neubelt\n// code: https://github.com/selfshadow/ltc_code/\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n const float LUT_SIZE = 64.0;\n const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n const float LUT_BIAS = 0.5 / LUT_SIZE;\n float dotNV = saturate( dot( N, V ) );\n // texture parameterized by sqrt( GGX alpha ) and sqrt( 1 - cos( theta ) )\n vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n uv = uv * LUT_SCALE + LUT_BIAS;\n return uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n // Real-Time Area Lighting: a Journey from Research to Production (p.102)\n // An approximation of the form factor of a horizon-clipped rectangle.\n float l = length( f );\n return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n float x = dot( v1, v2 );\n float y = abs( x );\n // rational polynomial approximation to theta / sin( theta ) / 2PI\n float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n float b = 3.4175940 + ( 4.1616724 + y ) * y;\n float v = a / b;\n float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n return cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n // bail if point is on back side of plane of light\n // assumes ccw winding order of light vertices\n vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n vec3 lightNormal = cross( v1, v2 );\n if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n // construct orthonormal basis around N\n vec3 T1, T2;\n T1 = normalize( V - N * dot( V, N ) );\n T2 = - cross( N, T1 ); // negated from paper; possibly due to a different handedness of world coordinate system\n // compute transform\n mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n // transform rect\n vec3 coords[ 4 ];\n coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n // project rect onto sphere\n coords[ 0 ] = normalize( coords[ 0 ] );\n coords[ 1 ] = normalize( coords[ 1 ] );\n coords[ 2 ] = normalize( coords[ 2 ] );\n coords[ 3 ] = normalize( coords[ 3 ] );\n // calculate vector form factor\n vec3 vectorFormFactor = vec3( 0.0 );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n // adjust for horizon clipping\n float result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n/*\n // alternate method of adjusting for horizon clipping (see referece)\n // refactoring required\n float len = length( vectorFormFactor );\n float z = vectorFormFactor.z / len;\n const float LUT_SIZE = 64.0;\n const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n const float LUT_BIAS = 0.5 / LUT_SIZE;\n // tabulated horizon-clipped sphere, apparently...\n vec2 uv = vec2( z * 0.5 + 0.5, len );\n uv = uv * LUT_SCALE + LUT_BIAS;\n float scale = texture2D( ltc_2, uv ).w;\n float result = len * scale;\n*/\n return vec3( result );\n}\n// End Rect Area Light\n// ref: https://www.unrealengine.com/blog/physically-based-shading-on-mobile - environmentBRDF for GGX on mobile\nvec3 BRDF_Specular_GGX_Environment( const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n float dotNV = saturate( dot( normal, viewDir ) );\n vec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n return specularColor * brdf.x + brdf.y;\n} // validated\n// Fdez-Ag\xfcera\'s "Multiple-Scattering Microfacet Model for Real-Time Image Based Lighting"\n// Approximates multiscattering in order to preserve energy.\n// http://www.jcgt.org/published/0008/01/03/\nvoid BRDF_Specular_Multiscattering_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n float dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n vec3 F = F_Schlick_RoughnessDependent( specularColor, dotNV, roughness );\n vec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n vec3 FssEss = F * brdf.x + brdf.y;\n float Ess = brdf.x + brdf.y;\n float Ems = 1.0 - Ess;\n vec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619; // 1/21\n vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n singleScatter += FssEss;\n multiScatter += Fms * Ems;\n}\nfloat G_BlinnPhong_Implicit( /* const in float dotNL, const in float dotNV */ ) {\n // geometry term is (n dot l)(n dot v) / 4(n dot l)(n dot v)\n return 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\n vec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n //float dotNL = saturate( dot( geometry.normal, incidentLight.direction ) );\n //float dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n float dotNH = saturate( dot( geometry.normal, halfDir ) );\n float dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n vec3 F = F_Schlick( specularColor, dotLH );\n float G = G_BlinnPhong_Implicit( /* dotNL, dotNV */ );\n float D = D_BlinnPhong( shininess, dotNH );\n return F * ( G * D );\n} // validated\n// source: http://simonstechblog.blogspot.ca/2011/12/microfacet-brdf.html\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\n return ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );\n}\nfloat BlinnExponentToGGXRoughness( const in float blinnExponent ) {\n return sqrt( 2.0 / ( blinnExponent + 2.0 ) );\n}\n#if defined( USE_SHEEN )\n// https://github.com/google/filament/blob/master/shaders/src/brdf.fs#L94\nfloat D_Charlie(float roughness, float NoH) {\n // Estevez and Kulla 2017, "Production Friendly Microfacet Sheen BRDF"\n float invAlpha = 1.0 / roughness;\n float cos2h = NoH * NoH;\n float sin2h = max(1.0 - cos2h, 0.0078125); // 2^(-14/2), so sin2h^2 > 0 in fp16\n return (2.0 + invAlpha) * pow(sin2h, invAlpha * 0.5) / (2.0 * PI);\n}\n// https://github.com/google/filament/blob/master/shaders/src/brdf.fs#L136\nfloat V_Neubelt(float NoV, float NoL) {\n // Neubelt and Pettineo 2013, "Crafting a Next-gen Material Pipeline for The Order: 1886"\n return saturate(1.0 / (4.0 * (NoL + NoV - NoL * NoV)));\n}\nvec3 BRDF_Specular_Sheen( const in float roughness, const in vec3 L, const in GeometricContext geometry, vec3 specularColor ) {\n vec3 N = geometry.normal;\n vec3 V = geometry.viewDir;\n vec3 H = normalize( V + L );\n float dotNH = saturate( dot( N, H ) );\n return specularColor * D_Charlie( roughness, dotNH ) * V_Neubelt( dot(N, V), dot(N, L) );\n}\n#endif\n'; exports.default = _default; diff --git a/crates/swc/tests/tsc-references/objectLiteralGettersAndSetters_es5.1.normal.js b/crates/swc/tests/tsc-references/objectLiteralGettersAndSetters_es5.1.normal.js index f6d63d483ae..c17d82fda81 100644 --- a/crates/swc/tests/tsc-references/objectLiteralGettersAndSetters_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/objectLiteralGettersAndSetters_es5.1.normal.js @@ -36,10 +36,10 @@ var sameName4a = { } }; var sameName5a = { - get "\t" () { + get " " () { return ""; }, - set "\t" (n){ + set " " (n){ var p4 = n; var p4; } diff --git a/crates/swc/tests/tsc-references/parserindenter_es5.1.normal.js b/crates/swc/tests/tsc-references/parserindenter_es5.1.normal.js index 80906bb5c74..81292959dbe 100644 --- a/crates/swc/tests/tsc-references/parserindenter_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/parserindenter_es5.1.normal.js @@ -319,7 +319,7 @@ var Formatting; if (StringUtils.IsNullOrEmpty(existingIndentation)) return ""; var totalIndent = 0; StringUtils.foreach(existingIndentation, function(c) { - if (c == "\t") totalIndent += tabSize; + if (c == " ") totalIndent += tabSize; else totalIndent++; }); totalIndent += level * indentSize; @@ -330,7 +330,7 @@ var Formatting; return this.GetIndentString(existingIndentation, totalIndentSize, tabSize, convertTabsToSpaces); }; _proto.GetIndentString = function GetIndentString(prefix, totalIndentSize, tabSize, convertTabsToSpaces) { - var tabString = convertTabsToSpaces ? StringUtils.create(" ", tabSize) : "\t"; + var tabString = convertTabsToSpaces ? StringUtils.create(" ", tabSize) : " "; var text = ""; if (!StringUtils.IsNullOrEmpty(prefix)) text += prefix; var pos = 0; @@ -501,7 +501,7 @@ var Formatting; var line = this.snapshot.GetLineFromPosition(offset); var lineText = line.getText(); var index = 0; - while(index < lineText.length && (lineText.charAt(index) == " " || lineText.charAt(index) == "\t")){ + while(index < lineText.length && (lineText.charAt(index) == " " || lineText.charAt(index) == " ")){ ++index; } return lineText.substr(0, index); @@ -550,7 +550,7 @@ var Formatting; var indentSize = 0; for(var i = 0; i < text.length; i++){ var c = text.charAt(i); - if (c == "\t") indentSize = indentSize + editorOptions.TabSize - indentSize % editorOptions.TabSize; + if (c == " ") indentSize = indentSize + editorOptions.TabSize - indentSize % editorOptions.TabSize; else if (c == " ") indentSize += 1; else { if (includeNonIndentChars) indentSize += 1; diff --git a/crates/swc/tests/tsc-references/parserindenter_es5.2.minified.js b/crates/swc/tests/tsc-references/parserindenter_es5.2.minified.js index 3f36176fa38..d04cb36a37b 100644 --- a/crates/swc/tests/tsc-references/parserindenter_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/parserindenter_es5.2.minified.js @@ -128,12 +128,12 @@ import * as swcHelpers from "@swc/helpers"; if (StringUtils.IsNullOrEmpty(existingIndentation)) return ""; var totalIndent = 0; return (StringUtils.foreach(existingIndentation, function(c) { - "\t" == c ? totalIndent += tabSize : totalIndent++; + " " == c ? totalIndent += tabSize : totalIndent++; }), (totalIndent += level * indentSize) < 0) ? "" : this.GetIndentString(null, totalIndent, tabSize, convertTabsToSpaces); } return this.GetIndentString(existingIndentation, level * indentSize, tabSize, convertTabsToSpaces); }, _proto.GetIndentString = function(prefix, totalIndentSize, tabSize, convertTabsToSpaces) { - var tabString = convertTabsToSpaces ? StringUtils.create(" ", tabSize) : "\t", text = ""; + var tabString = convertTabsToSpaces ? StringUtils.create(" ", tabSize) : " ", text = ""; StringUtils.IsNullOrEmpty(prefix) || (text += prefix); for(var pos = 0; pos <= totalIndentSize - tabSize;)text += tabString, pos += tabSize; for(; pos < totalIndentSize;)text += " ", pos++; @@ -196,7 +196,7 @@ import * as swcHelpers from "@swc/helpers"; }, _proto.GetLineIndentationForOffset = function(offset) { var indentationEdit; if (null != (indentationEdit = this.indentationBag.FindIndent(offset))) return indentationEdit.Indentation(); - for(var lineText = this.snapshot.GetLineFromPosition(offset).getText(), index = 0; index < lineText.length && (" " == lineText.charAt(index) || "\t" == lineText.charAt(index));)++index; + for(var lineText = this.snapshot.GetLineFromPosition(offset).getText(), index = 0; index < lineText.length && (" " == lineText.charAt(index) || " " == lineText.charAt(index));)++index; return lineText.substr(0, index); }, _proto.RegisterIndentation = function(indent, sameLineIndent) { var indentationInfo = null; @@ -230,7 +230,7 @@ import * as swcHelpers from "@swc/helpers"; }, Indenter.GetIndentSizeFromText = function(text, editorOptions, includeNonIndentChars) { for(var indentSize = 0, i = 0; i < text.length; i++){ var c = text.charAt(i); - if ("\t" == c) indentSize = indentSize + editorOptions.TabSize - indentSize % editorOptions.TabSize; + if (" " == c) indentSize = indentSize + editorOptions.TabSize - indentSize % editorOptions.TabSize; else if (" " == c) indentSize += 1; else if (includeNonIndentChars) indentSize += 1; else break; diff --git a/crates/swc/tests/tsc-references/templateStringWhitespaceEscapes1_ES6_es5.1.normal.js b/crates/swc/tests/tsc-references/templateStringWhitespaceEscapes1_ES6_es5.1.normal.js index 07a32b0935c..8ce39e6ac7c 100644 --- a/crates/swc/tests/tsc-references/templateStringWhitespaceEscapes1_ES6_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/templateStringWhitespaceEscapes1_ES6_es5.1.normal.js @@ -1,2 +1,2 @@ //@target: es6 -"\t\n\v\f\r"; +" \n\v\f\r"; diff --git a/crates/swc/tests/tsc-references/templateStringWhitespaceEscapes1_ES6_es5.2.minified.js b/crates/swc/tests/tsc-references/templateStringWhitespaceEscapes1_ES6_es5.2.minified.js index ce436955593..fc569b6007c 100644 --- a/crates/swc/tests/tsc-references/templateStringWhitespaceEscapes1_ES6_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/templateStringWhitespaceEscapes1_ES6_es5.2.minified.js @@ -1 +1 @@ -"\t\n\v\f\r"; +" \n\v\f\r"; diff --git a/crates/swc/tests/tsc-references/templateStringWhitespaceEscapes1_es5.1.normal.js b/crates/swc/tests/tsc-references/templateStringWhitespaceEscapes1_es5.1.normal.js index ce436955593..fc569b6007c 100644 --- a/crates/swc/tests/tsc-references/templateStringWhitespaceEscapes1_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/templateStringWhitespaceEscapes1_es5.1.normal.js @@ -1 +1 @@ -"\t\n\v\f\r"; +" \n\v\f\r"; diff --git a/crates/swc/tests/tsc-references/templateStringWhitespaceEscapes1_es5.2.minified.js b/crates/swc/tests/tsc-references/templateStringWhitespaceEscapes1_es5.2.minified.js index ce436955593..fc569b6007c 100644 --- a/crates/swc/tests/tsc-references/templateStringWhitespaceEscapes1_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/templateStringWhitespaceEscapes1_es5.2.minified.js @@ -1 +1 @@ -"\t\n\v\f\r"; +" \n\v\f\r"; diff --git a/crates/swc/tests/tsc-references/templateStringWhitespaceEscapes2_ES6_es5.1.normal.js b/crates/swc/tests/tsc-references/templateStringWhitespaceEscapes2_ES6_es5.1.normal.js index ef7e035356b..9e1388743a1 100644 --- a/crates/swc/tests/tsc-references/templateStringWhitespaceEscapes2_ES6_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/templateStringWhitespaceEscapes2_ES6_es5.1.normal.js @@ -1,3 +1,3 @@ //@target: es6 // , , , , , -"\t\v\f \xa0\uFEFF"; +" \v\f \xa0\uFEFF"; diff --git a/crates/swc/tests/tsc-references/templateStringWhitespaceEscapes2_ES6_es5.2.minified.js b/crates/swc/tests/tsc-references/templateStringWhitespaceEscapes2_ES6_es5.2.minified.js index a0917a7c562..51a2fc78df0 100644 --- a/crates/swc/tests/tsc-references/templateStringWhitespaceEscapes2_ES6_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/templateStringWhitespaceEscapes2_ES6_es5.2.minified.js @@ -1 +1 @@ -"\t\v\f \xa0\uFEFF"; +" \v\f \xa0\uFEFF"; diff --git a/crates/swc/tests/tsc-references/templateStringWhitespaceEscapes2_es5.1.normal.js b/crates/swc/tests/tsc-references/templateStringWhitespaceEscapes2_es5.1.normal.js index 4e72eb4a801..70ed969a802 100644 --- a/crates/swc/tests/tsc-references/templateStringWhitespaceEscapes2_es5.1.normal.js +++ b/crates/swc/tests/tsc-references/templateStringWhitespaceEscapes2_es5.1.normal.js @@ -1,2 +1,2 @@ // , , , , , -"\t\v\f \xa0\uFEFF"; +" \v\f \xa0\uFEFF"; diff --git a/crates/swc/tests/tsc-references/templateStringWhitespaceEscapes2_es5.2.minified.js b/crates/swc/tests/tsc-references/templateStringWhitespaceEscapes2_es5.2.minified.js index a0917a7c562..51a2fc78df0 100644 --- a/crates/swc/tests/tsc-references/templateStringWhitespaceEscapes2_es5.2.minified.js +++ b/crates/swc/tests/tsc-references/templateStringWhitespaceEscapes2_es5.2.minified.js @@ -1 +1 @@ -"\t\v\f \xa0\uFEFF"; +" \v\f \xa0\uFEFF"; diff --git a/crates/swc_ecma_codegen/src/lib.rs b/crates/swc_ecma_codegen/src/lib.rs index 2afa1ac59ce..0435753b793 100644 --- a/crates/swc_ecma_codegen/src/lib.rs +++ b/crates/swc_ecma_codegen/src/lib.rs @@ -3308,7 +3308,7 @@ fn get_quoted_utf16(v: &str, target: EsVersion) -> String { '\n' => buf.push_str("\\n"), '\r' => buf.push_str("\\r"), '\u{000b}' => buf.push_str("\\v"), - '\t' => buf.push_str("\\t"), + '\t' => buf.push('\t'), '\\' => { let next = iter.peek(); diff --git a/crates/swc_ecma_codegen/src/tests.rs b/crates/swc_ecma_codegen/src/tests.rs index 5c6119fa4e0..6cdee7884ed 100644 --- a/crates/swc_ecma_codegen/src/tests.rs +++ b/crates/swc_ecma_codegen/src/tests.rs @@ -571,7 +571,7 @@ fn test_get_quoted_utf16() { ); es2020("\n", "\"\\n\""); - es2020("\t", "\"\\t\""); + es2020("\t", "\"\t\""); es2020("'string'", "\"'string'\""); @@ -678,7 +678,7 @@ fn issue3617() { module.exports = '\u0009\u000A\u000B\u000C\u000D\u0020\u00A0\u1680\u2000\u2001\u2002' + '\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF' + '\u{a0}';"; let expected = r#"// a string of all valid unicode whitespaces -module.exports = "\t\n\v\f\r \xa0\u1680\u2000\u2001\u2002" + "\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF" + "\xa0";"#; +module.exports = " \n\v\f\r \xa0\u1680\u2000\u2001\u2002" + "\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF" + "\xa0";"#; let out = parse_then_emit(from, Default::default(), Syntax::default(), EsVersion::Es5); diff --git a/crates/swc_ecma_codegen/tests/fixture/string/output.min.js b/crates/swc_ecma_codegen/tests/fixture/string/output.min.js index 0226f375982..062757e71ea 100644 --- a/crates/swc_ecma_codegen/tests/fixture/string/output.min.js +++ b/crates/swc_ecma_codegen/tests/fixture/string/output.min.js @@ -1,3 +1,3 @@ const string1="test";const string2="test";const string3='te"st';const string4="te'st";const string5="test\ntest\ntest";const string6=`Yet another string primitive`;const string7="This is a very long string which needs to wrap across multiple lines because otherwise my code is unreadable.";const string8="\u4E2D\u6587 espa\xf1ol English \u0939\u093F\u0928\u094D\u0926\u0940 \u0627\u0644\u0639\u0631\u0628\u064A\u0629 portugu\xeas \u09AC\u09BE\u0982\u09B2\u09BE \u0440\u0443\u0441\u0441\u043A\u0438\u0439 \u65E5\u672C\u8A9E \u0A2A\u0A70\u0A1C\u0A3E\u0A2C\u0A40 \uD55C\uAD6D\uC5B4 \u0BA4\u0BAE\u0BBF\u0BB4\u0BCD";const string9=``;const string10=`xx\`x`;const string11=`${foo+2}`;const string12=` foo ${bar+`baz ${qux}`}`;const string13=String.raw`foo`;const string14=foo`bar`;const string15=`foo bar -ↂωↂ`;const string16=`\``;const string17=`${4+4} equals 4 + 4`;const string18=`This is ${undefined}`;const string19=`This is ${NaN}`;const string20=`This is ${null}`;const string21=`This is ${Infinity}`;const string22="This is ${1/0}";const string23="This is ${1/0}";const string24="This is ${NaN}";const string25="This is ${null}";const string26=`This is ${1/0}`;const string27=`This is ${0/0}`;const string28="This is ${0/0}";const string29="This is ${0/0}";const string30=`${4**11}`;const string31=`${4**12}`;const string32=`${4**14}`;const string33="";const string34="\b";const string35="\f";const string36="\t";const string37="\v";const string38="\n";const string39="\\n";const string40="\\";const string41='\\"';const string42="'\"";const string43="\\\\";const string44="\0";const string45="\0!";const string46="\x001";const string47="\\0";const string48="\\0!";const string49="\x07";const string50="\x07!";const string51="\x071";const string52="\x07";const string53="\\7";const string54="\\7!";const string55="\\01";const string56="\x10";const string57="\\x10";const string58="\x1b";const string59="\\x1B";const string60="\uABCD";const string61="\uABCD";const string62="U000123AB";const string63="\u{123AB}";const string64="\ud808\udfab";const string65="\ud808";const string66="\ud808X";const string67="\udfab";const string68="\udfabX";const string69="\x80";const string70="\xff";const string71="\xf0\x9f\x8d\x95";const string72="\ud801\udc02\udc03\ud804";const string73="\u03C0";const 貓="\u{1F408}";const 貓abc="\u{1F408}";const abc貓="\u{1F408}";const string74="\u2028";const string75="\u2029";const string76="\uFEFF";const string77="\x10";const string78=" ";const string79=" ";const string80="2";const string81="\x16";const string82="\x06";const string83="\0a";const string84='"test"test"test';const string85="\"test'test'test";const string86='"test"test"test';const string87="'test'test'test";const string88="\u{1F604}";const string89=new RegExp("\r").test("\r");const string90=new RegExp(" ").test(" ");const string91=new RegExp("\x1b").test("["+"\x1b"+"]");const string92=new RegExp("\\x1b").test("\x1b");const string93=new RegExp("\x1b").test("\x1b");const string94="\uD7FF";const string95="\uD7FB";const string96=sql`'#ERROR'`;const string97="\xa0";const string98="\ud83d\ude00";const string99="\ud83d@\ude00";const string100="a";const string101="\u2028" +ↂωↂ`;const string16=`\``;const string17=`${4+4} equals 4 + 4`;const string18=`This is ${undefined}`;const string19=`This is ${NaN}`;const string20=`This is ${null}`;const string21=`This is ${Infinity}`;const string22="This is ${1/0}";const string23="This is ${1/0}";const string24="This is ${NaN}";const string25="This is ${null}";const string26=`This is ${1/0}`;const string27=`This is ${0/0}`;const string28="This is ${0/0}";const string29="This is ${0/0}";const string30=`${4**11}`;const string31=`${4**12}`;const string32=`${4**14}`;const string33="";const string34="\b";const string35="\f";const string36=" ";const string37="\v";const string38="\n";const string39="\\n";const string40="\\";const string41='\\"';const string42="'\"";const string43="\\\\";const string44="\0";const string45="\0!";const string46="\x001";const string47="\\0";const string48="\\0!";const string49="\x07";const string50="\x07!";const string51="\x071";const string52="\x07";const string53="\\7";const string54="\\7!";const string55="\\01";const string56="\x10";const string57="\\x10";const string58="\x1b";const string59="\\x1B";const string60="\uABCD";const string61="\uABCD";const string62="U000123AB";const string63="\u{123AB}";const string64="\ud808\udfab";const string65="\ud808";const string66="\ud808X";const string67="\udfab";const string68="\udfabX";const string69="\x80";const string70="\xff";const string71="\xf0\x9f\x8d\x95";const string72="\ud801\udc02\udc03\ud804";const string73="\u03C0";const 貓="\u{1F408}";const 貓abc="\u{1F408}";const abc貓="\u{1F408}";const string74="\u2028";const string75="\u2029";const string76="\uFEFF";const string77="\x10";const string78=" ";const string79=" ";const string80="2";const string81="\x16";const string82="\x06";const string83="\0a";const string84='"test"test"test';const string85="\"test'test'test";const string86='"test"test"test';const string87="'test'test'test";const string88="\u{1F604}";const string89=new RegExp("\r").test("\r");const string90=new RegExp(" ").test(" ");const string91=new RegExp("\x1b").test("["+"\x1b"+"]");const string92=new RegExp("\\x1b").test("\x1b");const string93=new RegExp("\x1b").test("\x1b");const string94="\uD7FF";const string95="\uD7FB";const string96=sql`'#ERROR'`;const string97="\xa0";const string98="\ud83d\ude00";const string99="\ud83d@\ude00";const string100="a";const string101="\u2028" diff --git a/crates/swc_ecma_codegen/tests/test262-min/0b1fc7208759253b.js b/crates/swc_ecma_codegen/tests/test262-min/0b1fc7208759253b.js index 46454776253..52692ddb098 100644 --- a/crates/swc_ecma_codegen/tests/test262-min/0b1fc7208759253b.js +++ b/crates/swc_ecma_codegen/tests/test262-min/0b1fc7208759253b.js @@ -1 +1 @@ -"\0\x01\x02\x03\x04\x05\x06\x07\b\t\n\v\f\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\x7f\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe"+a +"\0\x01\x02\x03\x04\x05\x06\x07\b \n\v\f\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\x7f\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe"+a diff --git a/crates/swc_ecma_codegen/tests/test262-min/4672c2ef688237c9.js b/crates/swc_ecma_codegen/tests/test262-min/4672c2ef688237c9.js index 037ae39b916..e9064b10033 100644 --- a/crates/swc_ecma_codegen/tests/test262-min/4672c2ef688237c9.js +++ b/crates/swc_ecma_codegen/tests/test262-min/4672c2ef688237c9.js @@ -1 +1 @@ -"\n\r\t\v\b\f\\'\"\0" +"\n\r \v\b\f\\'\"\0" diff --git a/crates/swc_ecma_codegen/tests/test262-min/71e066a0fa01825b.js b/crates/swc_ecma_codegen/tests/test262-min/71e066a0fa01825b.js index 032667a3ff9..59212031199 100644 --- a/crates/swc_ecma_codegen/tests/test262-min/71e066a0fa01825b.js +++ b/crates/swc_ecma_codegen/tests/test262-min/71e066a0fa01825b.js @@ -1 +1 @@ -("\t") +(" ") diff --git a/crates/swc_ecma_codegen/tests/test262/0b1fc7208759253b.js b/crates/swc_ecma_codegen/tests/test262/0b1fc7208759253b.js index 0fc6c3df0aa..ae060d276c9 100644 --- a/crates/swc_ecma_codegen/tests/test262/0b1fc7208759253b.js +++ b/crates/swc_ecma_codegen/tests/test262/0b1fc7208759253b.js @@ -1 +1 @@ -"\0\x01\x02\x03\x04\x05\x06\x07\b\t\n\v\f\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\x7f\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe" + a; +"\0\x01\x02\x03\x04\x05\x06\x07\b \n\v\f\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\x7f\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe" + a; diff --git a/crates/swc_ecma_codegen/tests/test262/4672c2ef688237c9.js b/crates/swc_ecma_codegen/tests/test262/4672c2ef688237c9.js index ac4cd0bd08e..6e7bb0b7e5a 100644 --- a/crates/swc_ecma_codegen/tests/test262/4672c2ef688237c9.js +++ b/crates/swc_ecma_codegen/tests/test262/4672c2ef688237c9.js @@ -1 +1 @@ -"\n\r\t\v\b\f\\'\"\0"; +"\n\r \v\b\f\\'\"\0"; diff --git a/crates/swc_ecma_codegen/tests/test262/71e066a0fa01825b.js b/crates/swc_ecma_codegen/tests/test262/71e066a0fa01825b.js index 1d236106ae7..4c21c321469 100644 --- a/crates/swc_ecma_codegen/tests/test262/71e066a0fa01825b.js +++ b/crates/swc_ecma_codegen/tests/test262/71e066a0fa01825b.js @@ -1 +1 @@ -("\t"); +(" "); diff --git a/crates/swc_ecma_minifier/tests/compress/fixture/issues/2257/full/output.js b/crates/swc_ecma_minifier/tests/compress/fixture/issues/2257/full/output.js index eb85dd23095..d39d728ef61 100644 --- a/crates/swc_ecma_minifier/tests/compress/fixture/issues/2257/full/output.js +++ b/crates/swc_ecma_minifier/tests/compress/fixture/issues/2257/full/output.js @@ -5023,7 +5023,7 @@ }; }, 88443: function(module) { - module.exports = "\t\n\v\f\r \xa0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF"; + module.exports = " \n\v\f\r \xa0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF"; }, 23895: function(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) { "use strict"; diff --git a/crates/swc_ecma_minifier/tests/compress/fixture/next/33265/static/chunks/pages/index-cb36c1bf7f830e3c/output.js b/crates/swc_ecma_minifier/tests/compress/fixture/next/33265/static/chunks/pages/index-cb36c1bf7f830e3c/output.js index 80e121e4ecd..aae1d30dc31 100644 --- a/crates/swc_ecma_minifier/tests/compress/fixture/next/33265/static/chunks/pages/index-cb36c1bf7f830e3c/output.js +++ b/crates/swc_ecma_minifier/tests/compress/fixture/next/33265/static/chunks/pages/index-cb36c1bf7f830e3c/output.js @@ -2589,7 +2589,7 @@ (event = { type: 'tag', tagType: 'skip' - }).attributes = parseAttributes(match[1]), event.attributes.hasOwnProperty('SKIPPED-SEGMENTS') && (event.attributes['SKIPPED-SEGMENTS'] = parseInt(event.attributes['SKIPPED-SEGMENTS'], 10)), event.attributes.hasOwnProperty('RECENTLY-REMOVED-DATERANGES') && (event.attributes['RECENTLY-REMOVED-DATERANGES'] = event.attributes['RECENTLY-REMOVED-DATERANGES'].split("\t")), _this2.trigger('data', event); + }).attributes = parseAttributes(match[1]), event.attributes.hasOwnProperty('SKIPPED-SEGMENTS') && (event.attributes['SKIPPED-SEGMENTS'] = parseInt(event.attributes['SKIPPED-SEGMENTS'], 10)), event.attributes.hasOwnProperty('RECENTLY-REMOVED-DATERANGES') && (event.attributes['RECENTLY-REMOVED-DATERANGES'] = event.attributes['RECENTLY-REMOVED-DATERANGES'].split(" ")), _this2.trigger('data', event); return; } if ((match = /^#EXT-X-PART:(.*)$/.exec(newLine)) && match[1]) { diff --git a/crates/swc_node_bundler/tests/pass/resolve-name-fix/output/entry.js b/crates/swc_node_bundler/tests/pass/resolve-name-fix/output/entry.js index 4a42f5df51c..bf2ec912ca4 100644 --- a/crates/swc_node_bundler/tests/pass/resolve-name-fix/output/entry.js +++ b/crates/swc_node_bundler/tests/pass/resolve-name-fix/output/entry.js @@ -1229,7 +1229,7 @@ var load77 = __swcpack_require__.bind(void 0, function(module, exports) { }); }); var load78 = __swcpack_require__.bind(void 0, function(module, exports) { - module.exports = "\t\n\v\f\r \xa0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF"; + module.exports = " \n\v\f\r \xa0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF"; }); var load79 = __swcpack_require__.bind(void 0, function(module, exports) { var $export = load20();