mirror of
https://github.com/swc-project/swc.git
synced 2024-12-25 06:36:08 +03:00
bbaf619f63
swc_bundler: - [x] Fix wrapped esms. (denoland/deno#9307) - [x] Make test secure.
4 lines
2.5 KiB
TypeScript
4 lines
2.5 KiB
TypeScript
// Loaded from https://raw.githubusercontent.com/denjucks/dex/master/lib/deps/@jspm/core@1.1.0/nodelibs/punycode.js
|
|
|
|
|
|
const t=2147483647,o=/^xn--/,n=/[^\0-\x7E]/,e=/[\x2E\u3002\uFF0E\uFF61]/g,r={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},c=Math.floor,s=String.fromCharCode;function i(t){throw new RangeError(r[t])}function f(t,o){const n=t.split("@");let r="";n.length>1&&(r=n[0]+"@",t=n[1]);const c=function(t,o){const n=[];let e=t.length;for(;e--;)n[e]=o(t[e]);return n}((t=t.replace(e,".")).split("."),o).join(".");return r+c}function l(t){const o=[];let n=0;const e=t.length;for(;n<e;){const r=t.charCodeAt(n++);if(r>=55296&&r<=56319&&n<e){const e=t.charCodeAt(n++);56320==(64512&e)?o.push(((1023&r)<<10)+(1023&e)+65536):(o.push(r),n--);}else o.push(r);}return o}const u=function(t,o){return t+22+75*(t<26)-((0!=o)<<5)},a=function(t,o,n){let e=0;for(t=n?c(t/700):t>>1,t+=c(t/o);t>455;e+=36)t=c(t/35);return c(e+36*t/(t+38))},d=function(o){const n=[],e=o.length;let r=0,s=128,f=72,l=o.lastIndexOf("-");l<0&&(l=0);for(let t=0;t<l;++t)o.charCodeAt(t)>=128&&i("not-basic"),n.push(o.charCodeAt(t));for(let d=l>0?l+1:0;d<e;){let l=r;for(let n=1,s=36;;s+=36){d>=e&&i("invalid-input");const l=(u=o.charCodeAt(d++))-48<10?u-22:u-65<26?u-65:u-97<26?u-97:36;(l>=36||l>c((t-r)/n))&&i("overflow"),r+=l*n;const a=s<=f?1:s>=f+26?26:s-f;if(l<a)break;const h=36-a;n>c(t/h)&&i("overflow"),n*=h;}const h=n.length+1;f=a(r-l,h,0==l),c(r/h)>t-s&&i("overflow"),s+=c(r/h),r%=h,n.splice(r++,0,s);}var u;return String.fromCodePoint(...n)},h=function(o){const n=[];let e=(o=l(o)).length,r=128,f=0,d=72;for(const t of o)t<128&&n.push(s(t));let h=n.length,p=h;for(h&&n.push("-");p<e;){let e=t;for(const t of o)t>=r&&t<e&&(e=t);const l=p+1;e-r>c((t-f)/l)&&i("overflow"),f+=(e-r)*l,r=e;for(const e of o)if(e<r&&++f>t&&i("overflow"),e==r){let t=f;for(let o=36;;o+=36){const e=o<=d?1:o>=d+26?26:o-d;if(t<e)break;const r=t-e,i=36-e;n.push(s(u(e+r%i,0))),t=c(r/i);}n.push(s(u(t,0))),d=a(f,l,p==h),f=0,++p;}++f,++r;}return n.join("")};var p={version:"2.1.0",ucs2:{decode:l,encode:t=>String.fromCodePoint(...t)},decode:d,encode:h,toASCII:function(t){return f(t,(function(t){return n.test(t)?"xn--"+h(t):t}))},toUnicode:function(t){return f(t,(function(t){return o.test(t)?d(t.slice(4).toLowerCase()):t}))}};var decode=p.decode;var encode=p.encode;var toASCII=p.toASCII;var toUnicode=p.toUnicode;var ucs2=p.ucs2;var version=p.version;export default p;export{decode,encode,toASCII,toUnicode,ucs2,version}; |