-
Notifications
You must be signed in to change notification settings - Fork 0
/
es.js
1 lines (1 loc) · 1.69 KB
/
es.js
1
self.uceRequire=function(e){"use strict";var t="function"==typeof Promise?Promise:function(e){let t,s=[],n=0;return e(e=>{t=e,n=1,s.splice(0).forEach(r)}),{then:r};function r(e){return n?setTimeout(e,0,t):s.push(e),this}};t.all||(t.all=e=>new t(t=>{const{length:s}=e;s||t();let n=0;for(;n<s;)e[n++].then(r);function r(){++n===s&&t()}n=0}));const{create:s,defineProperty:n,keys:r}=Object,o=[],c=e=>l[e],l=s(null),u={},p=(e,s)=>{const r=[],c=[],p=e.replace(/(^|[\r\n])\s*import\s*((['|"])[^\3]+?\3)/g,(e,t,s)=>t+"require("+s+")").replace(/(^|[\r\n])\s*import\s*([^\3]+?)(\s*from\s*)((['|"])[^\5]+?\5)/g,(e,t,s,n,r)=>t+"const "+s.replace(/\s+as\s+/g,":")+" = require("+r+")").replace(/^\s*export\s+default(\s*)/gm,"exports.default =$1").replace(/(^|[\r\n])\s*export\s*\{([^}]+?)\}[^\n]*/g,(e,t,s)=>(s.trim().split(/\s*,\s*/).forEach(e=>{r.push(`exports.${e} = ${e};`)}),t)).replace(/(^|[\r\n])\s*export\s+(const|let|var|function)(\s+)(\w+)/g,(e,t,s,n,o)=>(r.push(`exports.${o} = ${o};`),t+s+n+o)).concat("\n",r.join("\n")).replace(/require\s*\(\s*(['"])([^\1]+?)\1\s*\)/g,(e,t,s)=>(c.push(s),e));return s?(c.forEach(e=>{e in l||o.push(new t(t=>{let s=u;if(/^(?:[./]|https?:)/.test(e)){l[e]=s;const n=new XMLHttpRequest;n.open("get",e,!0),n.send(null),n.onload=()=>{t(l[e]=i(n.responseText))}}else n(l,e,{get:()=>s,set:e=>{t(s=e)}})}))}),new t(e=>{t.all(o).then(()=>e(p))})):p},a=e=>{const t=r(e||{}),s=t.map(t=>e[t]).concat(c);return t.push("require"),e=>{const n={},o={exports:n},c=t.concat("module","exports",'"use strict;"\n'+p(e));Function.apply(null,c).apply(null,s.concat(o,n));const l=o.exports,u=r(l);return 1===u.length&&"default"===u[0]?l.default:l}},i=a();return e.asCJS=p,e.cache=l,e.cjs=a,e.loader=i,e.waiting=u,e}({});