isomorfeus-asset-manager 0.14.1 → 0.14.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,8 +1,8 @@
1
- var Pe=Object.defineProperty,tt=Object.defineProperties;var rt=Object.getOwnPropertyDescriptors;var Ue=Object.getOwnPropertySymbols;var nt=Object.prototype.hasOwnProperty,lt=Object.prototype.propertyIsEnumerable;var qe=(e,t,r)=>t in e?Pe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Me=(e,t)=>{for(var r in t||(t={}))nt.call(t,r)&&qe(e,r,t[r]);if(Ue)for(var r of Ue(t))lt.call(t,r)&&qe(e,r,t[r]);return e},Be=(e,t)=>tt(e,rt(t)),it=e=>Pe(e,"__esModule",{value:!0});var st=(e,t)=>{it(e);for(var r in t)Pe(e,r,{get:t[r],enumerable:!0})};var Le={};st(Le,{analyzeMetafile:()=>Ot,analyzeMetafileSync:()=>Et,build:()=>bt,buildSync:()=>St,formatMessages:()=>Rt,formatMessagesSync:()=>kt,initialize:()=>$t,serve:()=>wt,transform:()=>vt,transformSync:()=>xt,version:()=>ht});function Te(e){let t=s=>{if(s===null)r.write8(0);else if(typeof s=="boolean")r.write8(1),r.write8(+s);else if(typeof s=="number")r.write8(2),r.write32(s|0);else if(typeof s=="string")r.write8(3),r.write(ae(s));else if(s instanceof Uint8Array)r.write8(4),r.write(s);else if(s instanceof Array){r.write8(5),r.write32(s.length);for(let g of s)t(g)}else{let g=Object.keys(s);r.write8(6),r.write32(g.length);for(let l of g)r.write(ae(l)),t(s[l])}},r=new Ae;return r.write32(0),r.write32(e.id<<1|+!e.isRequest),t(e.value),Ne(r.buf,r.len-4,0),r.buf.subarray(0,r.len)}function We(e){let t=()=>{switch(r.read8()){case 0:return null;case 1:return!!r.read8();case 2:return r.read32();case 3:return fe(r.read());case 4:return r.read();case 5:{let f=r.read32(),i=[];for(let w=0;w<f;w++)i.push(t());return i}case 6:{let f=r.read32(),i={};for(let w=0;w<f;w++)i[fe(r.read())]=t();return i}default:throw new Error("Invalid packet")}},r=new Ae(e),s=r.read32(),g=(s&1)==0;s>>>=1;let l=t();if(r.ptr!==e.length)throw new Error("Invalid packet");return{id:s,isRequest:g,value:l}}var Ae=class{constructor(t=new Uint8Array(1024)){this.buf=t;this.len=0;this.ptr=0}_write(t){if(this.len+t>this.buf.length){let r=new Uint8Array((this.len+t)*2);r.set(this.buf),this.buf=r}return this.len+=t,this.len-t}write8(t){let r=this._write(1);this.buf[r]=t}write32(t){let r=this._write(4);Ne(this.buf,t,r)}write(t){let r=this._write(4+t.length);Ne(this.buf,t.length,r),this.buf.set(t,r+4)}_read(t){if(this.ptr+t>this.buf.length)throw new Error("Invalid packet");return this.ptr+=t,this.ptr-t}read8(){return this.buf[this._read(1)]}read32(){return Fe(this.buf,this._read(4))}read(){let t=this.read32(),r=new Uint8Array(t),s=this._read(r.length);return r.set(this.buf.subarray(s,s+t)),r}},ae,fe;if(typeof TextEncoder!="undefined"&&typeof TextDecoder!="undefined"){let e=new TextEncoder,t=new TextDecoder;ae=r=>e.encode(r),fe=r=>t.decode(r)}else if(typeof Buffer!="undefined")ae=e=>{let t=Buffer.from(e);return t instanceof Uint8Array||(t=new Uint8Array(t)),t},fe=e=>{let{buffer:t,byteOffset:r,byteLength:s}=e;return Buffer.from(t,r,s).toString()};else throw new Error("No UTF-8 codec found");function Fe(e,t){return e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24}function Ne(e,t,r){e[r++]=t,e[r++]=t>>8,e[r++]=t>>16,e[r++]=t>>24}function ze(e){if(e+="",e.indexOf(",")>=0)throw new Error(`Invalid target: ${e}`);return e}var je=()=>null,I=e=>typeof e=="boolean"?null:"a boolean",at=e=>typeof e=="boolean"||typeof e=="object"&&!Array.isArray(e)?null:"a boolean or an object",y=e=>typeof e=="string"?null:"a string",Ke=e=>e instanceof RegExp?null:"a RegExp object",ge=e=>typeof e=="number"&&e===(e|0)?null:"an integer",Ce=e=>typeof e=="function"?null:"a function",z=e=>Array.isArray(e)?null:"an array",me=e=>typeof e=="object"&&e!==null&&!Array.isArray(e)?null:"an object",ut=e=>typeof e=="object"&&e!==null?null:"an array or an object",_e=e=>typeof e=="object"&&!Array.isArray(e)?null:"an object or null",Ve=e=>typeof e=="string"||typeof e=="boolean"?null:"a string or a boolean",ft=e=>typeof e=="string"||typeof e=="object"&&e!==null&&!Array.isArray(e)?null:"a string or an object",ct=e=>typeof e=="string"||Array.isArray(e)?null:"a string or an array",dt=e=>typeof e=="string"||e instanceof Uint8Array?null:"a string or a Uint8Array";function n(e,t,r,s){let g=e[r];if(t[r+""]=!0,g===void 0)return;let l=s(g);if(l!==null)throw new Error(`"${r}" must be ${l}`);return g}function _(e,t,r){for(let s in e)if(!(s in t))throw new Error(`Invalid option ${r}: "${s}"`)}function Je(e){let t=Object.create(null),r=n(e,t,"wasmURL",y),s=n(e,t,"worker",I);return _(e,t,"in startService() call"),{wasmURL:r,worker:s}}function Re(e,t,r,s,g){let l=n(t,r,"color",I),f=n(t,r,"logLevel",y),i=n(t,r,"logLimit",ge);l!==void 0?e.push(`--color=${l}`):s&&e.push("--color=true"),e.push(`--log-level=${f||g}`),e.push(`--log-limit=${i||0}`)}function Ye(e,t,r){let s=n(t,r,"legalComments",y),g=n(t,r,"sourceRoot",y),l=n(t,r,"sourcesContent",I),f=n(t,r,"target",ct),i=n(t,r,"format",y),w=n(t,r,"globalName",y),O=n(t,r,"minify",I),x=n(t,r,"minifySyntax",I),N=n(t,r,"minifyWhitespace",I),L=n(t,r,"minifyIdentifiers",I),k=n(t,r,"charset",y),q=n(t,r,"treeShaking",I),ee=n(t,r,"ignoreAnnotations",I),Q=n(t,r,"jsx",y),te=n(t,r,"jsxFactory",y),re=n(t,r,"jsxFragment",y),le=n(t,r,"define",me),ie=n(t,r,"pure",z),ue=n(t,r,"keepNames",I);if(s&&e.push(`--legal-comments=${s}`),g!==void 0&&e.push(`--source-root=${g}`),l!==void 0&&e.push(`--sources-content=${l}`),f&&(Array.isArray(f)?e.push(`--target=${Array.from(f).map(ze).join(",")}`):e.push(`--target=${ze(f)}`)),i&&e.push(`--format=${i}`),w&&e.push(`--global-name=${w}`),O&&e.push("--minify"),x&&e.push("--minify-syntax"),N&&e.push("--minify-whitespace"),L&&e.push("--minify-identifiers"),k&&e.push(`--charset=${k}`),q!==void 0&&e.push(`--tree-shaking=${q}`),ee&&e.push("--ignore-annotations"),Q&&e.push(`--jsx=${Q}`),te&&e.push(`--jsx-factory=${te}`),re&&e.push(`--jsx-fragment=${re}`),le)for(let X in le){if(X.indexOf("=")>=0)throw new Error(`Invalid define: ${X}`);e.push(`--define:${X}=${le[X]}`)}if(ie)for(let X of ie)e.push(`--pure:${X}`);ue&&e.push("--keep-names")}function pt(e,t,r,s,g){var b;let l=[],f=[],i=Object.create(null),w=null,O=null,x=null;Re(l,t,i,r,s),Ye(l,t,i);let N=n(t,i,"sourcemap",Ve),L=n(t,i,"bundle",I),k=n(t,i,"watch",at),q=n(t,i,"splitting",I),ee=n(t,i,"preserveSymlinks",I),Q=n(t,i,"metafile",I),te=n(t,i,"outfile",y),re=n(t,i,"outdir",y),le=n(t,i,"outbase",y),ie=n(t,i,"platform",y),ue=n(t,i,"tsconfig",y),X=n(t,i,"resolveExtensions",z),ve=n(t,i,"nodePaths",z),ke=n(t,i,"mainFields",z),Ee=n(t,i,"conditions",z),$e=n(t,i,"external",z),d=n(t,i,"loader",me),u=n(t,i,"outExtension",me),o=n(t,i,"publicPath",y),c=n(t,i,"entryNames",y),C=n(t,i,"chunkNames",y),B=n(t,i,"assetNames",y),M=n(t,i,"inject",z),j=n(t,i,"banner",me),D=n(t,i,"footer",me),$=n(t,i,"entryPoints",ut),R=n(t,i,"absWorkingDir",y),T=n(t,i,"stdin",me),A=(b=n(t,i,"write",I))!=null?b:g,S=n(t,i,"allowOverwrite",I),E=n(t,i,"incremental",I)===!0;if(i.plugins=!0,_(t,i,`in ${e}() call`),N&&l.push(`--sourcemap${N===!0?"":`=${N}`}`),L&&l.push("--bundle"),S&&l.push("--allow-overwrite"),k)if(l.push("--watch"),typeof k=="boolean")x={};else{let a=Object.create(null),h=n(k,a,"onRebuild",Ce);_(k,a,`on "watch" in ${e}() call`),x={onRebuild:h}}if(q&&l.push("--splitting"),ee&&l.push("--preserve-symlinks"),Q&&l.push("--metafile"),te&&l.push(`--outfile=${te}`),re&&l.push(`--outdir=${re}`),le&&l.push(`--outbase=${le}`),ie&&l.push(`--platform=${ie}`),ue&&l.push(`--tsconfig=${ue}`),X){let a=[];for(let h of X){if(h+="",h.indexOf(",")>=0)throw new Error(`Invalid resolve extension: ${h}`);a.push(h)}l.push(`--resolve-extensions=${a.join(",")}`)}if(o&&l.push(`--public-path=${o}`),c&&l.push(`--entry-names=${c}`),C&&l.push(`--chunk-names=${C}`),B&&l.push(`--asset-names=${B}`),ke){let a=[];for(let h of ke){if(h+="",h.indexOf(",")>=0)throw new Error(`Invalid main field: ${h}`);a.push(h)}l.push(`--main-fields=${a.join(",")}`)}if(Ee){let a=[];for(let h of Ee){if(h+="",h.indexOf(",")>=0)throw new Error(`Invalid condition: ${h}`);a.push(h)}l.push(`--conditions=${a.join(",")}`)}if($e)for(let a of $e)l.push(`--external:${a}`);if(j)for(let a in j){if(a.indexOf("=")>=0)throw new Error(`Invalid banner file type: ${a}`);l.push(`--banner:${a}=${j[a]}`)}if(D)for(let a in D){if(a.indexOf("=")>=0)throw new Error(`Invalid footer file type: ${a}`);l.push(`--footer:${a}=${D[a]}`)}if(M)for(let a of M)l.push(`--inject:${a}`);if(d)for(let a in d){if(a.indexOf("=")>=0)throw new Error(`Invalid loader extension: ${a}`);l.push(`--loader:${a}=${d[a]}`)}if(u)for(let a in u){if(a.indexOf("=")>=0)throw new Error(`Invalid out extension: ${a}`);l.push(`--out-extension:${a}=${u[a]}`)}if($)if(Array.isArray($))for(let a of $)f.push(["",a+""]);else for(let[a,h]of Object.entries($))f.push([a+"",h+""]);if(T){let a=Object.create(null),h=n(T,a,"contents",y),P=n(T,a,"resolveDir",y),p=n(T,a,"sourcefile",y),v=n(T,a,"loader",y);_(T,a,'in "stdin" object'),p&&l.push(`--sourcefile=${p}`),v&&l.push(`--loader=${v}`),P&&(O=P+""),w=h?h+"":""}let m=[];if(ve)for(let a of ve)a+="",m.push(a);return{entries:f,flags:l,write:A,stdinContents:w,stdinResolveDir:O,absWorkingDir:R,incremental:E,nodePaths:m,watch:x}}function gt(e,t,r,s){let g=[],l=Object.create(null);Re(g,t,l,r,s),Ye(g,t,l);let f=n(t,l,"sourcemap",Ve),i=n(t,l,"tsconfigRaw",ft),w=n(t,l,"sourcefile",y),O=n(t,l,"loader",y),x=n(t,l,"banner",y),N=n(t,l,"footer",y);return _(t,l,`in ${e}() call`),f&&g.push(`--sourcemap=${f===!0?"external":f}`),i&&g.push(`--tsconfig-raw=${typeof i=="string"?i:JSON.stringify(i)}`),w&&g.push(`--sourcefile=${w}`),O&&g.push(`--loader=${O}`),x&&g.push(`--banner=${x}`),N&&g.push(`--footer=${N}`),g}function He(e){let t=new Map,r=new Map,s=new Map,g=new Map,l=0,f=!1,i=0,w=0,O=new Uint8Array(16*1024),x=0,N=d=>{let u=x+d.length;if(u>O.length){let c=new Uint8Array(u*2);c.set(O),O=c}O.set(d,x),x+=d.length;let o=0;for(;o+4<=x;){let c=Fe(O,o);if(o+4+c>x)break;o+=4,te(O.subarray(o,o+c)),o+=c}o>0&&(O.copyWithin(0,o,x),x-=o)},L=()=>{f=!0;for(let d of t.values())d("The service was stopped",null);t.clear();for(let d of g.values())d.onWait("The service was stopped");g.clear();for(let d of s.values())try{d(new Error("The service was stopped"),null)}catch(u){console.error(u)}s.clear()},k=(d,u,o)=>{if(f)return o("The service is no longer running",null);let c=i++;t.set(c,(C,B)=>{try{o(C,B)}finally{d&&d.unref()}}),d&&d.ref(),e.writeToStdin(Te({id:c,isRequest:!0,value:u}))},q=(d,u)=>{if(f)throw new Error("The service is no longer running");e.writeToStdin(Te({id:d,isRequest:!1,value:u}))},ee=async(d,u)=>{try{switch(u.command){case"ping":{q(d,{});break}case"start":{let o=r.get(u.key);o?q(d,await o(u)):q(d,{});break}case"resolve":{let o=r.get(u.key);o?q(d,await o(u)):q(d,{});break}case"load":{let o=r.get(u.key);o?q(d,await o(u)):q(d,{});break}case"serve-request":{let o=g.get(u.serveID);o&&o.onRequest&&o.onRequest(u.args),q(d,{});break}case"serve-wait":{let o=g.get(u.serveID);o&&o.onWait(u.error),q(d,{});break}case"watch-rebuild":{let o=s.get(u.watchID);try{o&&o(null,u.args)}catch(c){console.error(c)}q(d,{});break}default:throw new Error("Invalid command: "+u.command)}}catch(o){q(d,{errors:[ye(o,e,null,void 0,"")]})}},Q=!0,te=d=>{if(Q){Q=!1;let o=String.fromCharCode(...d);if(o!=="0.14.3")throw new Error(`Cannot start service: Host version "0.14.3" does not match binary version ${JSON.stringify(o)}`);return}let u=We(d);if(u.isRequest)ee(u.id,u.value);else{let o=t.get(u.id);t.delete(u.id),u.value.error?o(u.value.error,{}):o(null,u.value)}},re=async(d,u,o,c)=>{let C=[],B=[],M={},j={},D=0,$=0,R=[];u=[...u];for(let E of u){let m={};if(typeof E!="object")throw new Error(`Plugin at index ${$} must be an object`);let b=n(E,m,"name",y);if(typeof b!="string"||b==="")throw new Error(`Plugin at index ${$} is missing a name`);try{let a=n(E,m,"setup",Ce);if(typeof a!="function")throw new Error("Plugin is missing a setup function");_(E,m,`on plugin ${JSON.stringify(b)}`);let h={name:b,onResolve:[],onLoad:[]};$++;let P=a({initialOptions:d,onStart(p){let v='This error came from the "onStart" callback registered here:',W=Oe(new Error(v),e,"onStart");C.push({name:b,callback:p,note:W})},onEnd(p){let v='This error came from the "onEnd" callback registered here:',W=Oe(new Error(v),e,"onEnd");B.push({name:b,callback:p,note:W})},onResolve(p,v){let W='This error came from the "onResolve" callback registered here:',U=Oe(new Error(W),e,"onResolve"),K={},V=n(p,K,"filter",Ke),Y=n(p,K,"namespace",y);if(_(p,K,`in onResolve() call for plugin ${JSON.stringify(b)}`),V==null)throw new Error("onResolve() call is missing a filter");let J=D++;M[J]={name:b,callback:v,note:U},h.onResolve.push({id:J,filter:V.source,namespace:Y||""})},onLoad(p,v){let W='This error came from the "onLoad" callback registered here:',U=Oe(new Error(W),e,"onLoad"),K={},V=n(p,K,"filter",Ke),Y=n(p,K,"namespace",y);if(_(p,K,`in onLoad() call for plugin ${JSON.stringify(b)}`),V==null)throw new Error("onLoad() call is missing a filter");let J=D++;j[J]={name:b,callback:v,note:U},h.onLoad.push({id:J,filter:V.source,namespace:Y||""})},esbuild:e.esbuild});P&&await P,R.push(h)}catch(a){return{ok:!1,error:a,pluginName:b}}}let T=async E=>{switch(E.command){case"start":{let m={errors:[],warnings:[]};return await Promise.all(C.map(async({name:b,callback:a,note:h})=>{try{let P=await a();if(P!=null){if(typeof P!="object")throw new Error(`Expected onStart() callback in plugin ${JSON.stringify(b)} to return an object`);let p={},v=n(P,p,"errors",z),W=n(P,p,"warnings",z);_(P,p,`from onStart() callback in plugin ${JSON.stringify(b)}`),v!=null&&m.errors.push(...ce(v,"errors",c,b)),W!=null&&m.warnings.push(...ce(W,"warnings",c,b))}}catch(P){m.errors.push(ye(P,e,c,h&&h(),b))}})),m}case"resolve":{let m={},b="",a,h;for(let P of E.ids)try{({name:b,callback:a,note:h}=M[P]);let p=await a({path:E.path,importer:E.importer,namespace:E.namespace,resolveDir:E.resolveDir,kind:E.kind,pluginData:c.load(E.pluginData)});if(p!=null){if(typeof p!="object")throw new Error(`Expected onResolve() callback in plugin ${JSON.stringify(b)} to return an object`);let v={},W=n(p,v,"pluginName",y),U=n(p,v,"path",y),K=n(p,v,"namespace",y),V=n(p,v,"suffix",y),Y=n(p,v,"external",I),J=n(p,v,"sideEffects",I),se=n(p,v,"pluginData",je),oe=n(p,v,"errors",z),F=n(p,v,"warnings",z),G=n(p,v,"watchFiles",z),H=n(p,v,"watchDirs",z);_(p,v,`from onResolve() callback in plugin ${JSON.stringify(b)}`),m.id=P,W!=null&&(m.pluginName=W),U!=null&&(m.path=U),K!=null&&(m.namespace=K),V!=null&&(m.suffix=V),Y!=null&&(m.external=Y),J!=null&&(m.sideEffects=J),se!=null&&(m.pluginData=c.store(se)),oe!=null&&(m.errors=ce(oe,"errors",c,b)),F!=null&&(m.warnings=ce(F,"warnings",c,b)),G!=null&&(m.watchFiles=Se(G,"watchFiles")),H!=null&&(m.watchDirs=Se(H,"watchDirs"));break}}catch(p){return{id:P,errors:[ye(p,e,c,h&&h(),b)]}}return m}case"load":{let m={},b="",a,h;for(let P of E.ids)try{({name:b,callback:a,note:h}=j[P]);let p=await a({path:E.path,namespace:E.namespace,suffix:E.suffix,pluginData:c.load(E.pluginData)});if(p!=null){if(typeof p!="object")throw new Error(`Expected onLoad() callback in plugin ${JSON.stringify(b)} to return an object`);let v={},W=n(p,v,"pluginName",y),U=n(p,v,"contents",dt),K=n(p,v,"resolveDir",y),V=n(p,v,"pluginData",je),Y=n(p,v,"loader",y),J=n(p,v,"errors",z),se=n(p,v,"warnings",z),oe=n(p,v,"watchFiles",z),F=n(p,v,"watchDirs",z);_(p,v,`from onLoad() callback in plugin ${JSON.stringify(b)}`),m.id=P,W!=null&&(m.pluginName=W),U instanceof Uint8Array?m.contents=U:U!=null&&(m.contents=ae(U)),K!=null&&(m.resolveDir=K),V!=null&&(m.pluginData=c.store(V)),Y!=null&&(m.loader=Y),J!=null&&(m.errors=ce(J,"errors",c,b)),se!=null&&(m.warnings=ce(se,"warnings",c,b)),oe!=null&&(m.watchFiles=Se(oe,"watchFiles")),F!=null&&(m.watchDirs=Se(F,"watchDirs"));break}}catch(p){return{id:P,errors:[ye(p,e,c,h&&h(),b)]}}return m}default:throw new Error("Invalid command: "+E.command)}},A=(E,m,b)=>b();B.length>0&&(A=(E,m,b)=>{(async()=>{for(let{name:a,callback:h,note:P}of B)try{await h(E)}catch(p){E.errors.push(await new Promise(v=>m(p,a,P&&P(),v)))}})().then(b)});let S=0;return{ok:!0,requestPlugins:R,runOnEndCallbacks:A,pluginRefs:{ref(){++S==1&&r.set(o,T)},unref(){--S==0&&r.delete(o)}}}},le=(d,u,o)=>{let c={},C=n(u,c,"port",ge),B=n(u,c,"host",y),M=n(u,c,"servedir",y),j=n(u,c,"onRequest",Ce),D=l++,$,R=new Promise((T,A)=>{$=S=>{g.delete(D),S!==null?A(new Error(S)):T()}});return o.serve={serveID:D},_(u,c,"in serve() call"),C!==void 0&&(o.serve.port=C),B!==void 0&&(o.serve.host=B),M!==void 0&&(o.serve.servedir=M),g.set(D,{onRequest:j,onWait:$}),{wait:R,stop(){k(d,{command:"serve-stop",serveID:D},()=>{})}}},ie="warning",ue="silent",X=d=>{let u=w++,o=Ge(),c,{refs:C,options:B,isTTY:M,callback:j}=d;if(typeof B=="object"){let R=B.plugins;if(R!==void 0){if(!Array.isArray(R))throw new Error('"plugins" must be an array');c=R}}let D=(R,T,A,S)=>{let E=[];try{Re(E,B,{},M,ie)}catch(b){}let m=ye(R,e,o,A,T);k(C,{command:"error",flags:E,error:m},()=>{m.detail=o.load(m.detail),S(m)})},$=(R,T)=>{D(R,T,void 0,A=>{j(he("Build failed",[A],[]),null)})};if(c&&c.length>0){if(e.isSync)return $(new Error("Cannot use plugins in synchronous API calls"),"");re(B,c,u,o).then(R=>{if(!R.ok)$(R.error,R.pluginName);else try{ve(Be(Me({},d),{key:u,details:o,logPluginError:D,requestPlugins:R.requestPlugins,runOnEndCallbacks:R.runOnEndCallbacks,pluginRefs:R.pluginRefs}))}catch(T){$(T,"")}},R=>$(R,""))}else try{ve(Be(Me({},d),{key:u,details:o,logPluginError:D,requestPlugins:null,runOnEndCallbacks:(R,T,A)=>A(),pluginRefs:null}))}catch(R){$(R,"")}},ve=({callName:d,refs:u,serveOptions:o,options:c,isTTY:C,defaultWD:B,callback:M,key:j,details:D,logPluginError:$,requestPlugins:R,runOnEndCallbacks:T,pluginRefs:A})=>{let S={ref(){A&&A.ref(),u&&u.ref()},unref(){A&&A.unref(),u&&u.unref()}},E=!e.isBrowser,{entries:m,flags:b,write:a,stdinContents:h,stdinResolveDir:P,absWorkingDir:p,incremental:v,nodePaths:W,watch:U}=pt(d,c,C,ie,E),K={command:"build",key:j,entries:m,flags:b,write:a,stdinContents:h,stdinResolveDir:P,absWorkingDir:p||B,incremental:v,nodePaths:W};R&&(K.plugins=R);let V=o&&le(S,o,K),Y,J,se=(F,G)=>{F.outputFiles&&(G.outputFiles=F.outputFiles.map(mt)),F.metafile&&(G.metafile=JSON.parse(F.metafile)),F.writeToStdout!==void 0&&console.log(fe(F.writeToStdout).replace(/\n$/,""))},oe=(F,G)=>{let H={errors:be(F.errors,D),warnings:be(F.warnings,D)};se(F,H),T(H,$,()=>{if(H.errors.length>0)return G(he("Build failed",H.errors,H.warnings),null);if(F.rebuildID!==void 0){if(!Y){let ne=!1;Y=()=>new Promise((de,pe)=>{if(ne||f)throw new Error("Cannot rebuild");k(S,{command:"rebuild",rebuildID:F.rebuildID},(Z,Ze)=>{if(Z)return G(he("Build failed",[{pluginName:"",text:Z,location:null,notes:[],detail:void 0}],[]),null);oe(Ze,(De,et)=>{De?pe(De):de(et)})})}),S.ref(),Y.dispose=()=>{ne||(ne=!0,k(S,{command:"rebuild-dispose",rebuildID:F.rebuildID},()=>{}),S.unref())}}H.rebuild=Y}if(F.watchID!==void 0){if(!J){let ne=!1;S.ref(),J=()=>{ne||(ne=!0,s.delete(F.watchID),k(S,{command:"watch-stop",watchID:F.watchID},()=>{}),S.unref())},U&&s.set(F.watchID,(de,pe)=>{if(de){U.onRebuild&&U.onRebuild(de,null);return}let Z={errors:be(pe.errors,D),warnings:be(pe.warnings,D)};se(pe,Z),T(Z,$,()=>{if(Z.errors.length>0){U.onRebuild&&U.onRebuild(he("Build failed",Z.errors,Z.warnings),null);return}pe.rebuildID!==void 0&&(Z.rebuild=Y),Z.stop=J,U.onRebuild&&U.onRebuild(null,Z)})})}H.stop=J}G(null,H)})};if(a&&e.isBrowser)throw new Error('Cannot enable "write" in the browser');if(v&&e.isSync)throw new Error('Cannot use "incremental" with a synchronous build');if(U&&e.isSync)throw new Error('Cannot use "watch" with a synchronous build');k(S,K,(F,G)=>{if(F)return M(new Error(F),null);if(V){let H=G,ne=!1;S.ref();let de={port:H.port,host:H.host,wait:V.wait,stop(){ne||(ne=!0,V.stop(),S.unref())}};return S.ref(),V.wait.then(S.unref,S.unref),M(null,de)}return oe(G,M)})};return{readFromStdout:N,afterClose:L,service:{buildOrServe:X,transform:({callName:d,refs:u,input:o,options:c,isTTY:C,fs:B,callback:M})=>{let j=Ge(),D=$=>{try{if(typeof o!="string")throw new Error('The input to "transform" must be a string');let R=gt(d,c,C,ue);k(u,{command:"transform",flags:R,inputFS:$!==null,input:$!==null?$:o},(A,S)=>{if(A)return M(new Error(A),null);let E=be(S.errors,j),m=be(S.warnings,j),b=1,a=()=>--b==0&&M(null,{warnings:m,code:S.code,map:S.map});if(E.length>0)return M(he("Transform failed",E,m),null);S.codeFS&&(b++,B.readFile(S.code,(h,P)=>{h!==null?M(h,null):(S.code=P,a())})),S.mapFS&&(b++,B.readFile(S.map,(h,P)=>{h!==null?M(h,null):(S.map=P,a())})),a()})}catch(R){let T=[];try{Re(T,c,{},C,ue)}catch(S){}let A=ye(R,e,j,void 0,"");k(u,{command:"error",flags:T,error:A},()=>{A.detail=j.load(A.detail),M(he("Transform failed",[A],[]),null)})}};if(typeof o=="string"&&o.length>1024*1024){let $=D;D=()=>B.writeFile(o,$)}D(null)},formatMessages:({callName:d,refs:u,messages:o,options:c,callback:C})=>{let B=ce(o,"messages",null,"");if(!c)throw new Error(`Missing second argument in ${d}() call`);let M={},j=n(c,M,"kind",y),D=n(c,M,"color",I),$=n(c,M,"terminalWidth",ge);if(_(c,M,`in ${d}() call`),j===void 0)throw new Error(`Missing "kind" in ${d}() call`);if(j!=="error"&&j!=="warning")throw new Error(`Expected "kind" to be "error" or "warning" in ${d}() call`);let R={command:"format-msgs",messages:B,isWarning:j==="warning"};D!==void 0&&(R.color=D),$!==void 0&&(R.terminalWidth=$),k(u,R,(T,A)=>{if(T)return C(new Error(T),null);C(null,A.messages)})},analyzeMetafile:({callName:d,refs:u,metafile:o,options:c,callback:C})=>{c===void 0&&(c={});let B={},M=n(c,B,"color",I),j=n(c,B,"verbose",I);_(c,B,`in ${d}() call`);let D={command:"analyze-metafile",metafile:o};M!==void 0&&(D.color=M),j!==void 0&&(D.verbose=j),k(u,D,($,R)=>{if($)return C(new Error($),null);C(null,R.result)})}}}}function Ge(){let e=new Map,t=0;return{load(r){return e.get(r)},store(r){if(r===void 0)return-1;let s=t++;return e.set(s,r),s}}}function Oe(e,t,r){let s,g=!1;return()=>{if(g)return s;g=!0;try{let l=(e.stack+"").split(`
2
- `);l.splice(1,1);let f=Qe(t,l,r);if(f)return s={text:e.message,location:f},s}catch(l){}}}function ye(e,t,r,s,g){let l="Internal error",f=null;try{l=(e&&e.message||e)+""}catch(i){}try{f=Qe(t,(e.stack+"").split(`
3
- `),"")}catch(i){}return{pluginName:g,text:l,location:f,notes:s?[s]:[],detail:r?r.store(e):-1}}function Qe(e,t,r){let s=" at ";if(e.readFileSync&&!t[0].startsWith(s)&&t[1].startsWith(s))for(let g=1;g<t.length;g++){let l=t[g];if(!!l.startsWith(s))for(l=l.slice(s.length);;){let f=/^(?:new |async )?\S+ \((.*)\)$/.exec(l);if(f){l=f[1];continue}if(f=/^eval at \S+ \((.*)\)(?:, \S+:\d+:\d+)?$/.exec(l),f){l=f[1];continue}if(f=/^(\S+):(\d+):(\d+)$/.exec(l),f){let i;try{i=e.readFileSync(f[1],"utf8")}catch(N){break}let w=i.split(/\r\n|\r|\n|\u2028|\u2029/)[+f[2]-1]||"",O=+f[3]-1,x=w.slice(O,O+r.length)===r?r.length:0;return{file:f[1],namespace:"file",line:+f[2],column:ae(w.slice(0,O)).length,length:ae(w.slice(O,O+x)).length,lineText:w+`
1
+ var Le=Object.defineProperty,et=Object.defineProperties;var tt=Object.getOwnPropertyDescriptors;var Ue=Object.getOwnPropertySymbols;var rt=Object.prototype.hasOwnProperty,nt=Object.prototype.propertyIsEnumerable;var qe=(e,t,r)=>t in e?Le(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Me=(e,t)=>{for(var r in t||(t={}))rt.call(t,r)&&qe(e,r,t[r]);if(Ue)for(var r of Ue(t))nt.call(t,r)&&qe(e,r,t[r]);return e},Be=(e,t)=>et(e,tt(t));var lt=(e,t)=>{for(var r in t)Le(e,r,{get:t[r],enumerable:!0})};var Ce={};lt(Ce,{analyzeMetafile:()=>vt,analyzeMetafileSync:()=>xt,build:()=>yt,buildSync:()=>Rt,formatMessages:()=>wt,formatMessagesSync:()=>St,initialize:()=>kt,serve:()=>ht,transform:()=>bt,transformSync:()=>Ot,version:()=>mt});function Te(e){let t=o=>{if(o===null)r.write8(0);else if(typeof o=="boolean")r.write8(1),r.write8(+o);else if(typeof o=="number")r.write8(2),r.write32(o|0);else if(typeof o=="string")r.write8(3),r.write(fe(o));else if(o instanceof Uint8Array)r.write8(4),r.write(o);else if(o instanceof Array){r.write8(5),r.write32(o.length);for(let d of o)t(d)}else{let d=Object.keys(o);r.write8(6),r.write32(d.length);for(let i of d)r.write(fe(i)),t(o[i])}},r=new De;return r.write32(0),r.write32(e.id<<1|+!e.isRequest),t(e.value),Fe(r.buf,r.len-4,0),r.buf.subarray(0,r.len)}function We(e){let t=()=>{switch(r.read8()){case 0:return null;case 1:return!!r.read8();case 2:return r.read32();case 3:return ge(r.read());case 4:return r.read();case 5:{let c=r.read32(),s=[];for(let y=0;y<c;y++)s.push(t());return s}case 6:{let c=r.read32(),s={};for(let y=0;y<c;y++)s[ge(r.read())]=t();return s}default:throw new Error("Invalid packet")}},r=new De(e),o=r.read32(),d=(o&1)===0;o>>>=1;let i=t();if(r.ptr!==e.length)throw new Error("Invalid packet");return{id:o,isRequest:d,value:i}}var De=class{constructor(t=new Uint8Array(1024)){this.buf=t;this.len=0;this.ptr=0}_write(t){if(this.len+t>this.buf.length){let r=new Uint8Array((this.len+t)*2);r.set(this.buf),this.buf=r}return this.len+=t,this.len-t}write8(t){let r=this._write(1);this.buf[r]=t}write32(t){let r=this._write(4);Fe(this.buf,t,r)}write(t){let r=this._write(4+t.length);Fe(this.buf,t.length,r),this.buf.set(t,r+4)}_read(t){if(this.ptr+t>this.buf.length)throw new Error("Invalid packet");return this.ptr+=t,this.ptr-t}read8(){return this.buf[this._read(1)]}read32(){return Ae(this.buf,this._read(4))}read(){let t=this.read32(),r=new Uint8Array(t),o=this._read(r.length);return r.set(this.buf.subarray(o,o+t)),r}},fe,ge;if(typeof TextEncoder!="undefined"&&typeof TextDecoder!="undefined"){let e=new TextEncoder,t=new TextDecoder;fe=r=>e.encode(r),ge=r=>t.decode(r)}else if(typeof Buffer!="undefined")fe=e=>{let t=Buffer.from(e);return t instanceof Uint8Array||(t=new Uint8Array(t)),t},ge=e=>{let{buffer:t,byteOffset:r,byteLength:o}=e;return Buffer.from(t,r,o).toString()};else throw new Error("No UTF-8 codec found");function Ae(e,t){return e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24}function Fe(e,t,r){e[r++]=t,e[r++]=t>>8,e[r++]=t>>16,e[r++]=t>>24}function Ie(e){if(e+="",e.indexOf(",")>=0)throw new Error(`Invalid target: ${e}`);return e}var Re=()=>null,q=e=>typeof e=="boolean"?null:"a boolean",st=e=>typeof e=="boolean"||typeof e=="object"&&!Array.isArray(e)?null:"a boolean or an object",g=e=>typeof e=="string"?null:"a string",ze=e=>e instanceof RegExp?null:"a RegExp object",ye=e=>typeof e=="number"&&e===(e|0)?null:"an integer",Ne=e=>typeof e=="function"?null:"a function",_=e=>Array.isArray(e)?null:"an array",he=e=>typeof e=="object"&&e!==null&&!Array.isArray(e)?null:"an object",ot=e=>typeof e=="object"&&e!==null?null:"an array or an object",Ke=e=>typeof e=="object"&&!Array.isArray(e)?null:"an object or null",_e=e=>typeof e=="string"||typeof e=="boolean"?null:"a string or a boolean",at=e=>typeof e=="string"||typeof e=="object"&&e!==null&&!Array.isArray(e)?null:"a string or an object",ut=e=>typeof e=="string"||Array.isArray(e)?null:"a string or an array",ft=e=>typeof e=="string"||e instanceof Uint8Array?null:"a string or a Uint8Array";function n(e,t,r,o){let d=e[r];if(t[r+""]=!0,d===void 0)return;let i=o(d);if(i!==null)throw new Error(`"${r}" must be ${i}`);return d}function Y(e,t,r){for(let o in e)if(!(o in t))throw new Error(`Invalid option ${r}: "${o}"`)}function Ve(e){let t=Object.create(null),r=n(e,t,"wasmURL",g),o=n(e,t,"worker",q);return Y(e,t,"in startService() call"),{wasmURL:r,worker:o}}function Oe(e,t,r,o,d){let i=n(t,r,"color",q),c=n(t,r,"logLevel",g),s=n(t,r,"logLimit",ye);i!==void 0?e.push(`--color=${i}`):o&&e.push("--color=true"),e.push(`--log-level=${c||d}`),e.push(`--log-limit=${s||0}`)}function Je(e,t,r){let o=n(t,r,"legalComments",g),d=n(t,r,"sourceRoot",g),i=n(t,r,"sourcesContent",q),c=n(t,r,"target",ut),s=n(t,r,"format",g),y=n(t,r,"globalName",g),R=n(t,r,"minify",q),T=n(t,r,"minifySyntax",q),C=n(t,r,"minifyWhitespace",q),$=n(t,r,"minifyIdentifiers",q),S=n(t,r,"drop",_),ne=n(t,r,"charset",g),re=n(t,r,"treeShaking",q),le=n(t,r,"ignoreAnnotations",q),ie=n(t,r,"jsx",g),se=n(t,r,"jsxFactory",g),ue=n(t,r,"jsxFragment",g),oe=n(t,r,"define",he),de=n(t,r,"pure",_),pe=n(t,r,"keepNames",q);if(o&&e.push(`--legal-comments=${o}`),d!==void 0&&e.push(`--source-root=${d}`),i!==void 0&&e.push(`--sources-content=${i}`),c&&(Array.isArray(c)?e.push(`--target=${Array.from(c).map(Ie).join(",")}`):e.push(`--target=${Ie(c)}`)),s&&e.push(`--format=${s}`),y&&e.push(`--global-name=${y}`),R&&e.push("--minify"),T&&e.push("--minify-syntax"),C&&e.push("--minify-whitespace"),$&&e.push("--minify-identifiers"),ne&&e.push(`--charset=${ne}`),re!==void 0&&e.push(`--tree-shaking=${re}`),le&&e.push("--ignore-annotations"),S)for(let ee of S)e.push(`--drop:${ee}`);if(ie&&e.push(`--jsx=${ie}`),se&&e.push(`--jsx-factory=${se}`),ue&&e.push(`--jsx-fragment=${ue}`),oe)for(let ee in oe){if(ee.indexOf("=")>=0)throw new Error(`Invalid define: ${ee}`);e.push(`--define:${ee}=${oe[ee]}`)}if(de)for(let ee of de)e.push(`--pure:${ee}`);pe&&e.push("--keep-names")}function ct(e,t,r,o,d){var h;let i=[],c=[],s=Object.create(null),y=null,R=null,T=null;Oe(i,t,s,r,o),Je(i,t,s);let C=n(t,s,"sourcemap",_e),$=n(t,s,"bundle",q),S=n(t,s,"watch",st),ne=n(t,s,"splitting",q),re=n(t,s,"preserveSymlinks",q),le=n(t,s,"metafile",q),ie=n(t,s,"outfile",g),se=n(t,s,"outdir",g),ue=n(t,s,"outbase",g),oe=n(t,s,"platform",g),de=n(t,s,"tsconfig",g),pe=n(t,s,"resolveExtensions",_),ee=n(t,s,"nodePaths",_),Ee=n(t,s,"mainFields",_),$e=n(t,s,"conditions",_),p=n(t,s,"external",_),u=n(t,s,"loader",he),a=n(t,s,"outExtension",he),f=n(t,s,"publicPath",g),j=n(t,s,"entryNames",g),N=n(t,s,"chunkNames",g),P=n(t,s,"assetNames",g),E=n(t,s,"inject",_),D=n(t,s,"banner",he),M=n(t,s,"footer",he),w=n(t,s,"entryPoints",ot),U=n(t,s,"absWorkingDir",g),k=n(t,s,"stdin",he),O=(h=n(t,s,"write",q))!=null?h:d,te=n(t,s,"allowOverwrite",q),X=n(t,s,"incremental",q)===!0;if(s.plugins=!0,Y(t,s,`in ${e}() call`),C&&i.push(`--sourcemap${C===!0?"":`=${C}`}`),$&&i.push("--bundle"),te&&i.push("--allow-overwrite"),S)if(i.push("--watch"),typeof S=="boolean")T={};else{let l=Object.create(null),v=n(S,l,"onRebuild",Ne);Y(S,l,`on "watch" in ${e}() call`),T={onRebuild:v}}if(ne&&i.push("--splitting"),re&&i.push("--preserve-symlinks"),le&&i.push("--metafile"),ie&&i.push(`--outfile=${ie}`),se&&i.push(`--outdir=${se}`),ue&&i.push(`--outbase=${ue}`),oe&&i.push(`--platform=${oe}`),de&&i.push(`--tsconfig=${de}`),pe){let l=[];for(let v of pe){if(v+="",v.indexOf(",")>=0)throw new Error(`Invalid resolve extension: ${v}`);l.push(v)}i.push(`--resolve-extensions=${l.join(",")}`)}if(f&&i.push(`--public-path=${f}`),j&&i.push(`--entry-names=${j}`),N&&i.push(`--chunk-names=${N}`),P&&i.push(`--asset-names=${P}`),Ee){let l=[];for(let v of Ee){if(v+="",v.indexOf(",")>=0)throw new Error(`Invalid main field: ${v}`);l.push(v)}i.push(`--main-fields=${l.join(",")}`)}if($e){let l=[];for(let v of $e){if(v+="",v.indexOf(",")>=0)throw new Error(`Invalid condition: ${v}`);l.push(v)}i.push(`--conditions=${l.join(",")}`)}if(p)for(let l of p)i.push(`--external:${l}`);if(D)for(let l in D){if(l.indexOf("=")>=0)throw new Error(`Invalid banner file type: ${l}`);i.push(`--banner:${l}=${D[l]}`)}if(M)for(let l in M){if(l.indexOf("=")>=0)throw new Error(`Invalid footer file type: ${l}`);i.push(`--footer:${l}=${M[l]}`)}if(E)for(let l of E)i.push(`--inject:${l}`);if(u)for(let l in u){if(l.indexOf("=")>=0)throw new Error(`Invalid loader extension: ${l}`);i.push(`--loader:${l}=${u[l]}`)}if(a)for(let l in a){if(l.indexOf("=")>=0)throw new Error(`Invalid out extension: ${l}`);i.push(`--out-extension:${l}=${a[l]}`)}if(w)if(Array.isArray(w))for(let l of w)c.push(["",l+""]);else for(let[l,v]of Object.entries(w))c.push([l+"",v+""]);if(k){let l=Object.create(null),v=n(k,l,"contents",g),W=n(k,l,"resolveDir",g),L=n(k,l,"sourcefile",g),b=n(k,l,"loader",g);Y(k,l,'in "stdin" object'),L&&i.push(`--sourcefile=${L}`),b&&i.push(`--loader=${b}`),W&&(R=W+""),y=v?v+"":""}let x=[];if(ee)for(let l of ee)l+="",x.push(l);return{entries:c,flags:i,write:O,stdinContents:y,stdinResolveDir:R,absWorkingDir:U,incremental:X,nodePaths:x,watch:T}}function dt(e,t,r,o){let d=[],i=Object.create(null);Oe(d,t,i,r,o),Je(d,t,i);let c=n(t,i,"sourcemap",_e),s=n(t,i,"tsconfigRaw",at),y=n(t,i,"sourcefile",g),R=n(t,i,"loader",g),T=n(t,i,"banner",g),C=n(t,i,"footer",g);return Y(t,i,`in ${e}() call`),c&&d.push(`--sourcemap=${c===!0?"external":c}`),s&&d.push(`--tsconfig-raw=${typeof s=="string"?s:JSON.stringify(s)}`),y&&d.push(`--sourcefile=${y}`),R&&d.push(`--loader=${R}`),T&&d.push(`--banner=${T}`),C&&d.push(`--footer=${C}`),d}function Ye(e){let t=new Map,r=new Map,o=new Map,d=new Map,i=!1,c=0,s=0,y=new Uint8Array(16*1024),R=0,T=p=>{let u=R+p.length;if(u>y.length){let f=new Uint8Array(u*2);f.set(y),y=f}y.set(p,R),R+=p.length;let a=0;for(;a+4<=R;){let f=Ae(y,a);if(a+4+f>R)break;a+=4,le(y.subarray(a,a+f)),a+=f}a>0&&(y.copyWithin(0,a,R),R-=a)},C=()=>{i=!0;for(let p of t.values())p("The service was stopped",null);t.clear();for(let p of d.values())p.onWait("The service was stopped");d.clear();for(let p of o.values())try{p(new Error("The service was stopped"),null)}catch(u){console.error(u)}o.clear()},$=(p,u,a)=>{if(i)return a("The service is no longer running",null);let f=c++;t.set(f,(j,N)=>{try{a(j,N)}finally{p&&p.unref()}}),p&&p.ref(),e.writeToStdin(Te({id:f,isRequest:!0,value:u}))},S=(p,u)=>{if(i)throw new Error("The service is no longer running");e.writeToStdin(Te({id:p,isRequest:!1,value:u}))},ne=async(p,u)=>{try{switch(u.command){case"ping":{S(p,{});break}case"on-start":{let a=r.get(u.key);a?S(p,await a(u)):S(p,{});break}case"on-resolve":{let a=r.get(u.key);a?S(p,await a(u)):S(p,{});break}case"on-load":{let a=r.get(u.key);a?S(p,await a(u)):S(p,{});break}case"serve-request":{let a=d.get(u.key);a&&a.onRequest&&a.onRequest(u.args),S(p,{});break}case"serve-wait":{let a=d.get(u.key);a&&a.onWait(u.error),S(p,{});break}case"watch-rebuild":{let a=o.get(u.key);try{a&&a(null,u.args)}catch(f){console.error(f)}S(p,{});break}default:throw new Error("Invalid command: "+u.command)}}catch(a){S(p,{errors:[be(a,e,null,void 0,"")]})}},re=!0,le=p=>{if(re){re=!1;let a=String.fromCharCode(...p);if(a!=="0.14.11")throw new Error(`Cannot start service: Host version "0.14.11" does not match binary version ${JSON.stringify(a)}`);return}let u=We(p);if(u.isRequest)ne(u.id,u.value);else{let a=t.get(u.id);t.delete(u.id),u.value.error?a(u.value.error,{}):a(null,u.value)}},ie=async(p,u,a,f,j)=>{let N=[],P=[],E={},D={},M=0,w=0,U=[],k=!1;u=[...u];for(let x of u){let h={};if(typeof x!="object")throw new Error(`Plugin at index ${w} must be an object`);let l=n(x,h,"name",g);if(typeof l!="string"||l==="")throw new Error(`Plugin at index ${w} is missing a name`);try{let v=n(x,h,"setup",Ne);if(typeof v!="function")throw new Error("Plugin is missing a setup function");Y(x,h,`on plugin ${JSON.stringify(l)}`);let W={name:l,onResolve:[],onLoad:[]};w++;let b=v({initialOptions:p,resolve:(m,A={})=>{if(!k)throw new Error('Cannot call "resolve" before plugin setup has completed');if(typeof m!="string")throw new Error("The path to resolve must be a string");let F=Object.create(null),V=n(A,F,"pluginName",g),I=n(A,F,"importer",g),H=n(A,F,"namespace",g),Q=n(A,F,"resolveDir",g),B=n(A,F,"kind",g),J=n(A,F,"pluginData",Re);return Y(A,F,"in resolve() call"),new Promise((K,Z)=>{let G={command:"resolve",path:m,key:a,pluginName:l};V!=null&&(G.pluginName=V),I!=null&&(G.importer=I),H!=null&&(G.namespace=H),Q!=null&&(G.resolveDir=Q),B!=null&&(G.kind=B),J!=null&&(G.pluginData=f.store(J)),$(j,G,(ae,z)=>{ae!==null?Z(new Error(ae)):K({errors:ce(z.errors,f),warnings:ce(z.warnings,f),path:z.path,external:z.external,sideEffects:z.sideEffects,namespace:z.namespace,suffix:z.suffix,pluginData:f.load(z.pluginData)})})})},onStart(m){let A='This error came from the "onStart" callback registered here:',F=Se(new Error(A),e,"onStart");N.push({name:l,callback:m,note:F})},onEnd(m){let A='This error came from the "onEnd" callback registered here:',F=Se(new Error(A),e,"onEnd");P.push({name:l,callback:m,note:F})},onResolve(m,A){let F='This error came from the "onResolve" callback registered here:',V=Se(new Error(F),e,"onResolve"),I={},H=n(m,I,"filter",ze),Q=n(m,I,"namespace",g);if(Y(m,I,`in onResolve() call for plugin ${JSON.stringify(l)}`),H==null)throw new Error("onResolve() call is missing a filter");let B=M++;E[B]={name:l,callback:A,note:V},W.onResolve.push({id:B,filter:H.source,namespace:Q||""})},onLoad(m,A){let F='This error came from the "onLoad" callback registered here:',V=Se(new Error(F),e,"onLoad"),I={},H=n(m,I,"filter",ze),Q=n(m,I,"namespace",g);if(Y(m,I,`in onLoad() call for plugin ${JSON.stringify(l)}`),H==null)throw new Error("onLoad() call is missing a filter");let B=M++;D[B]={name:l,callback:A,note:V},W.onLoad.push({id:B,filter:H.source,namespace:Q||""})},esbuild:e.esbuild});b&&await b,U.push(W)}catch(v){return{ok:!1,error:v,pluginName:l}}}let O=async x=>{switch(x.command){case"on-start":{let h={errors:[],warnings:[]};return await Promise.all(N.map(async({name:l,callback:v,note:W})=>{try{let L=await v();if(L!=null){if(typeof L!="object")throw new Error(`Expected onStart() callback in plugin ${JSON.stringify(l)} to return an object`);let b={},m=n(L,b,"errors",_),A=n(L,b,"warnings",_);Y(L,b,`from onStart() callback in plugin ${JSON.stringify(l)}`),m!=null&&h.errors.push(...me(m,"errors",f,l)),A!=null&&h.warnings.push(...me(A,"warnings",f,l))}}catch(L){h.errors.push(be(L,e,f,W&&W(),l))}})),h}case"on-resolve":{let h={},l="",v,W;for(let L of x.ids)try{({name:l,callback:v,note:W}=E[L]);let b=await v({path:x.path,importer:x.importer,namespace:x.namespace,resolveDir:x.resolveDir,kind:x.kind,pluginData:f.load(x.pluginData)});if(b!=null){if(typeof b!="object")throw new Error(`Expected onResolve() callback in plugin ${JSON.stringify(l)} to return an object`);let m={},A=n(b,m,"pluginName",g),F=n(b,m,"path",g),V=n(b,m,"namespace",g),I=n(b,m,"suffix",g),H=n(b,m,"external",q),Q=n(b,m,"sideEffects",q),B=n(b,m,"pluginData",Re),J=n(b,m,"errors",_),K=n(b,m,"warnings",_),Z=n(b,m,"watchFiles",_),G=n(b,m,"watchDirs",_);Y(b,m,`from onResolve() callback in plugin ${JSON.stringify(l)}`),h.id=L,A!=null&&(h.pluginName=A),F!=null&&(h.path=F),V!=null&&(h.namespace=V),I!=null&&(h.suffix=I),H!=null&&(h.external=H),Q!=null&&(h.sideEffects=Q),B!=null&&(h.pluginData=f.store(B)),J!=null&&(h.errors=me(J,"errors",f,l)),K!=null&&(h.warnings=me(K,"warnings",f,l)),Z!=null&&(h.watchFiles=xe(Z,"watchFiles")),G!=null&&(h.watchDirs=xe(G,"watchDirs"));break}}catch(b){return{id:L,errors:[be(b,e,f,W&&W(),l)]}}return h}case"on-load":{let h={},l="",v,W;for(let L of x.ids)try{({name:l,callback:v,note:W}=D[L]);let b=await v({path:x.path,namespace:x.namespace,suffix:x.suffix,pluginData:f.load(x.pluginData)});if(b!=null){if(typeof b!="object")throw new Error(`Expected onLoad() callback in plugin ${JSON.stringify(l)} to return an object`);let m={},A=n(b,m,"pluginName",g),F=n(b,m,"contents",ft),V=n(b,m,"resolveDir",g),I=n(b,m,"pluginData",Re),H=n(b,m,"loader",g),Q=n(b,m,"errors",_),B=n(b,m,"warnings",_),J=n(b,m,"watchFiles",_),K=n(b,m,"watchDirs",_);Y(b,m,`from onLoad() callback in plugin ${JSON.stringify(l)}`),h.id=L,A!=null&&(h.pluginName=A),F instanceof Uint8Array?h.contents=F:F!=null&&(h.contents=fe(F)),V!=null&&(h.resolveDir=V),I!=null&&(h.pluginData=f.store(I)),H!=null&&(h.loader=H),Q!=null&&(h.errors=me(Q,"errors",f,l)),B!=null&&(h.warnings=me(B,"warnings",f,l)),J!=null&&(h.watchFiles=xe(J,"watchFiles")),K!=null&&(h.watchDirs=xe(K,"watchDirs"));break}}catch(b){return{id:L,errors:[be(b,e,f,W&&W(),l)]}}return h}default:throw new Error("Invalid command: "+x.command)}},te=(x,h,l)=>l();P.length>0&&(te=(x,h,l)=>{(async()=>{for(let{name:v,callback:W,note:L}of P)try{await W(x)}catch(b){x.errors.push(await new Promise(m=>h(b,v,L&&L(),m)))}})().then(l)}),k=!0;let X=0;return{ok:!0,requestPlugins:U,runOnEndCallbacks:te,pluginRefs:{ref(){++X===1&&r.set(a,O)},unref(){--X===0&&r.delete(a)}}}},se=(p,u,a,f)=>{let j={},N=n(u,j,"port",ye),P=n(u,j,"host",g),E=n(u,j,"servedir",g),D=n(u,j,"onRequest",Ne),M,w=new Promise((U,k)=>{M=O=>{d.delete(f),O!==null?k(new Error(O)):U()}});return a.serve={},Y(u,j,"in serve() call"),N!==void 0&&(a.serve.port=N),P!==void 0&&(a.serve.host=P),E!==void 0&&(a.serve.servedir=E),d.set(f,{onRequest:D,onWait:M}),{wait:w,stop(){$(p,{command:"serve-stop",key:f},()=>{})}}},ue="warning",oe="silent",de=p=>{let u=s++,a=He(),f,{refs:j,options:N,isTTY:P,callback:E}=p;if(typeof N=="object"){let w=N.plugins;if(w!==void 0){if(!Array.isArray(w))throw new Error('"plugins" must be an array');f=w}}let D=(w,U,k,O)=>{let te=[];try{Oe(te,N,{},P,ue)}catch(x){}let X=be(w,e,a,k,U);$(j,{command:"error",flags:te,error:X},()=>{X.detail=a.load(X.detail),O(X)})},M=(w,U)=>{D(w,U,void 0,k=>{E(we("Build failed",[k],[]),null)})};if(f&&f.length>0){if(e.isSync)return M(new Error("Cannot use plugins in synchronous API calls"),"");ie(N,f,u,a,j).then(w=>{if(!w.ok)M(w.error,w.pluginName);else try{pe(Be(Me({},p),{key:u,details:a,logPluginError:D,requestPlugins:w.requestPlugins,runOnEndCallbacks:w.runOnEndCallbacks,pluginRefs:w.pluginRefs}))}catch(U){M(U,"")}},w=>M(w,""))}else try{pe(Be(Me({},p),{key:u,details:a,logPluginError:D,requestPlugins:null,runOnEndCallbacks:(w,U,k)=>k(),pluginRefs:null}))}catch(w){M(w,"")}},pe=({callName:p,refs:u,serveOptions:a,options:f,isTTY:j,defaultWD:N,callback:P,key:E,details:D,logPluginError:M,requestPlugins:w,runOnEndCallbacks:U,pluginRefs:k})=>{let O={ref(){k&&k.ref(),u&&u.ref()},unref(){k&&k.unref(),u&&u.unref()}},te=!e.isBrowser,{entries:X,flags:x,write:h,stdinContents:l,stdinResolveDir:v,absWorkingDir:W,incremental:L,nodePaths:b,watch:m}=ct(p,f,j,ue,te),A={command:"build",key:E,entries:X,flags:x,write:h,stdinContents:l,stdinResolveDir:v,absWorkingDir:W||N,incremental:L,nodePaths:b};w&&(A.plugins=w);let F=a&&se(O,a,A,E),V,I,H=(B,J)=>{B.outputFiles&&(J.outputFiles=B.outputFiles.map(pt)),B.metafile&&(J.metafile=JSON.parse(B.metafile)),B.writeToStdout!==void 0&&console.log(ge(B.writeToStdout).replace(/\n$/,""))},Q=(B,J)=>{let K={errors:ce(B.errors,D),warnings:ce(B.warnings,D)};H(B,K),U(K,M,()=>{if(K.errors.length>0)return J(we("Build failed",K.errors,K.warnings),null);if(B.rebuild){if(!V){let Z=!1;V=()=>new Promise((G,ae)=>{if(Z||i)throw new Error("Cannot rebuild");$(O,{command:"rebuild",key:E},(z,Xe)=>{if(z)return J(we("Build failed",[{pluginName:"",text:z,location:null,notes:[],detail:void 0}],[]),null);Q(Xe,(Pe,Ze)=>{Pe?ae(Pe):G(Ze)})})}),O.ref(),V.dispose=()=>{Z||(Z=!0,$(O,{command:"rebuild-dispose",key:E},()=>{}),O.unref())}}K.rebuild=V}if(B.watch){if(!I){let Z=!1;O.ref(),I=()=>{Z||(Z=!0,o.delete(E),$(O,{command:"watch-stop",key:E},()=>{}),O.unref())},m&&o.set(E,(G,ae)=>{if(G){m.onRebuild&&m.onRebuild(G,null);return}let z={errors:ce(ae.errors,D),warnings:ce(ae.warnings,D)};H(ae,z),U(z,M,()=>{if(z.errors.length>0){m.onRebuild&&m.onRebuild(we("Build failed",z.errors,z.warnings),null);return}ae.rebuildID!==void 0&&(z.rebuild=V),z.stop=I,m.onRebuild&&m.onRebuild(null,z)})})}K.stop=I}J(null,K)})};if(h&&e.isBrowser)throw new Error('Cannot enable "write" in the browser');if(L&&e.isSync)throw new Error('Cannot use "incremental" with a synchronous build');if(m&&e.isSync)throw new Error('Cannot use "watch" with a synchronous build');$(O,A,(B,J)=>{if(B)return P(new Error(B),null);if(F){let K=J,Z=!1;O.ref();let G={port:K.port,host:K.host,wait:F.wait,stop(){Z||(Z=!0,F.stop(),O.unref())}};return O.ref(),F.wait.then(O.unref,O.unref),P(null,G)}return Q(J,P)})};return{readFromStdout:T,afterClose:C,service:{buildOrServe:de,transform:({callName:p,refs:u,input:a,options:f,isTTY:j,fs:N,callback:P})=>{let E=He(),D=M=>{try{if(typeof a!="string")throw new Error('The input to "transform" must be a string');let w=dt(p,f,j,oe);$(u,{command:"transform",flags:w,inputFS:M!==null,input:M!==null?M:a},(k,O)=>{if(k)return P(new Error(k),null);let te=ce(O.errors,E),X=ce(O.warnings,E),x=1,h=()=>--x===0&&P(null,{warnings:X,code:O.code,map:O.map});if(te.length>0)return P(we("Transform failed",te,X),null);O.codeFS&&(x++,N.readFile(O.code,(l,v)=>{l!==null?P(l,null):(O.code=v,h())})),O.mapFS&&(x++,N.readFile(O.map,(l,v)=>{l!==null?P(l,null):(O.map=v,h())})),h()})}catch(w){let U=[];try{Oe(U,f,{},j,oe)}catch(O){}let k=be(w,e,E,void 0,"");$(u,{command:"error",flags:U,error:k},()=>{k.detail=E.load(k.detail),P(we("Transform failed",[k],[]),null)})}};if(typeof a=="string"&&a.length>1024*1024){let M=D;D=()=>N.writeFile(a,M)}D(null)},formatMessages:({callName:p,refs:u,messages:a,options:f,callback:j})=>{let N=me(a,"messages",null,"");if(!f)throw new Error(`Missing second argument in ${p}() call`);let P={},E=n(f,P,"kind",g),D=n(f,P,"color",q),M=n(f,P,"terminalWidth",ye);if(Y(f,P,`in ${p}() call`),E===void 0)throw new Error(`Missing "kind" in ${p}() call`);if(E!=="error"&&E!=="warning")throw new Error(`Expected "kind" to be "error" or "warning" in ${p}() call`);let w={command:"format-msgs",messages:N,isWarning:E==="warning"};D!==void 0&&(w.color=D),M!==void 0&&(w.terminalWidth=M),$(u,w,(U,k)=>{if(U)return j(new Error(U),null);j(null,k.messages)})},analyzeMetafile:({callName:p,refs:u,metafile:a,options:f,callback:j})=>{f===void 0&&(f={});let N={},P=n(f,N,"color",q),E=n(f,N,"verbose",q);Y(f,N,`in ${p}() call`);let D={command:"analyze-metafile",metafile:a};P!==void 0&&(D.color=P),E!==void 0&&(D.verbose=E),$(u,D,(M,w)=>{if(M)return j(new Error(M),null);j(null,w.result)})}}}}function He(){let e=new Map,t=0;return{load(r){return e.get(r)},store(r){if(r===void 0)return-1;let o=t++;return e.set(o,r),o}}}function Se(e,t,r){let o,d=!1;return()=>{if(d)return o;d=!0;try{let i=(e.stack+"").split(`
2
+ `);i.splice(1,1);let c=Ge(t,i,r);if(c)return o={text:e.message,location:c},o}catch(i){}}}function be(e,t,r,o,d){let i="Internal error",c=null;try{i=(e&&e.message||e)+""}catch(s){}try{c=Ge(t,(e.stack+"").split(`
3
+ `),"")}catch(s){}return{pluginName:d,text:i,location:c,notes:o?[o]:[],detail:r?r.store(e):-1}}function Ge(e,t,r){let o=" at ";if(e.readFileSync&&!t[0].startsWith(o)&&t[1].startsWith(o))for(let d=1;d<t.length;d++){let i=t[d];if(!!i.startsWith(o))for(i=i.slice(o.length);;){let c=/^(?:new |async )?\S+ \((.*)\)$/.exec(i);if(c){i=c[1];continue}if(c=/^eval at \S+ \((.*)\)(?:, \S+:\d+:\d+)?$/.exec(i),c){i=c[1];continue}if(c=/^(\S+):(\d+):(\d+)$/.exec(i),c){let s;try{s=e.readFileSync(c[1],"utf8")}catch(C){break}let y=s.split(/\r\n|\r|\n|\u2028|\u2029/)[+c[2]-1]||"",R=+c[3]-1,T=y.slice(R,R+r.length)===r?r.length:0;return{file:c[1],namespace:"file",line:+c[2],column:fe(y.slice(0,R)).length,length:fe(y.slice(R,R+T)).length,lineText:y+`
4
4
  `+t.slice(1).join(`
5
- `),suggestion:""}}break}}return null}function he(e,t,r){let s=5,g=t.length<1?"":` with ${t.length} error${t.length<2?"":"s"}:`+t.slice(0,s+1).map((f,i)=>{if(i===s)return`
6
- ...`;if(!f.location)return`
7
- error: ${f.text}`;let{file:w,line:O,column:x}=f.location,N=f.pluginName?`[plugin: ${f.pluginName}] `:"";return`
8
- ${w}:${O}:${x}: ERROR: ${N}${f.text}`}).join(""),l=new Error(`${e}${g}`);return l.errors=t,l.warnings=r,l}function be(e,t){for(let r of e)r.detail=t.load(r.detail);return e}function Xe(e,t){if(e==null)return null;let r={},s=n(e,r,"file",y),g=n(e,r,"namespace",y),l=n(e,r,"line",ge),f=n(e,r,"column",ge),i=n(e,r,"length",ge),w=n(e,r,"lineText",y),O=n(e,r,"suggestion",y);return _(e,r,t),{file:s||"",namespace:g||"",line:l||0,column:f||0,length:i||0,lineText:w||"",suggestion:O||""}}function ce(e,t,r,s){let g=[],l=0;for(let f of e){let i={},w=n(f,i,"pluginName",y),O=n(f,i,"text",y),x=n(f,i,"location",_e),N=n(f,i,"notes",z),L=n(f,i,"detail",je),k=`in element ${l} of "${t}"`;_(f,i,k);let q=[];if(N)for(let ee of N){let Q={},te=n(ee,Q,"text",y),re=n(ee,Q,"location",_e);_(ee,Q,k),q.push({text:te||"",location:Xe(re,k)})}g.push({pluginName:w||s,text:O||"",location:Xe(x,k),notes:q,detail:r?r.store(L):-1}),l++}return g}function Se(e,t){let r=[];for(let s of e){if(typeof s!="string")throw new Error(`${JSON.stringify(t)} must be an array of strings`);r.push(s)}return r}function mt({path:e,contents:t}){let r=null;return{path:e,contents:t,get text(){return r===null&&(r=fe(t)),r}}}var ht="0.14.3",bt=e=>xe().build(e),wt=()=>{throw new Error('The "serve" API only works in node')},vt=(e,t)=>xe().transform(e,t),Rt=(e,t)=>xe().formatMessages(e,t),Ot=(e,t)=>xe().analyzeMetafile(e,t),St=()=>{throw new Error('The "buildSync" API only works in node')},xt=()=>{throw new Error('The "transformSync" API only works in node')},kt=()=>{throw new Error('The "formatMessagesSync" API only works in node')},Et=()=>{throw new Error('The "analyzeMetafileSync" API only works in node')},we,Ie,xe=()=>{if(Ie)return Ie;throw we?new Error('You need to wait for the promise returned from "initialize" to be resolved before calling this'):new Error('You need to call "initialize" before calling this')},$t=e=>{e=Je(e||{});let t=e.wasmURL,r=e.worker!==!1;if(!t)throw new Error('Must provide the "wasmURL" option');if(t+="",we)throw new Error('Cannot call "initialize" more than once');return we=Dt(t,r),we.catch(()=>{we=void 0}),we},Dt=async(e,t)=>{let r=await fetch(e);if(!r.ok)throw new Error(`Failed to download ${JSON.stringify(e)}`);let s=await r.arrayBuffer(),g='{let global={};for(let o=self;o;o=Object.getPrototypeOf(o))for(let k of Object.getOwnPropertyNames(o))if(!(k in global))Object.defineProperty(global,k,{get:()=>self[k]});\n// Copyright 2018 The Go Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n(()=>{if(typeof global=="undefined")if(typeof window!="undefined")window.global=window;else if(typeof self!="undefined")self.global=self;else throw new Error("cannot export Go (neither global, window nor self is defined)");if(!global.require&&typeof require!="undefined"&&(global.require=require),!global.fs&&global.require){const r=require("fs");typeof r=="object"&&r!==null&&Object.keys(r).length!==0&&(global.fs=Object.assign({},r,{write(n,s,i,l,d,u){if(i===0&&l===s.length&&d===null){if(n===process.stdout.fd){try{process.stdout.write(s,h=>h?u(h,0,null):u(null,l,s))}catch(h){u(h,0,null)}return}if(n===process.stderr.fd){try{process.stderr.write(s,h=>h?u(h,0,null):u(null,l,s))}catch(h){u(h,0,null)}return}}r.write(n,s,i,l,d,u)}}))}const a=()=>{const r=new Error("not implemented");return r.code="ENOSYS",r};if(!global.fs){let r="";global.fs={constants:{O_WRONLY:-1,O_RDWR:-1,O_CREAT:-1,O_TRUNC:-1,O_APPEND:-1,O_EXCL:-1},writeSync(n,s){r+=g.decode(s);const i=r.lastIndexOf(`\n`);return i!=-1&&(console.log(r.substr(0,i)),r=r.substr(i+1)),s.length},write(n,s,i,l,d,u){if(i!==0||l!==s.length||d!==null){u(a());return}const h=this.writeSync(n,s);u(null,h)},chmod(n,s,i){i(a())},chown(n,s,i,l){l(a())},close(n,s){s(a())},fchmod(n,s,i){i(a())},fchown(n,s,i,l){l(a())},fstat(n,s){s(a())},fsync(n,s){s(null)},ftruncate(n,s,i){i(a())},lchown(n,s,i,l){l(a())},link(n,s,i){i(a())},lstat(n,s){s(a())},mkdir(n,s,i){i(a())},open(n,s,i,l){l(a())},read(n,s,i,l,d,u){u(a())},readdir(n,s){s(a())},readlink(n,s){s(a())},rename(n,s,i){i(a())},rmdir(n,s){s(a())},stat(n,s){s(a())},symlink(n,s,i){i(a())},truncate(n,s,i){i(a())},unlink(n,s){s(a())},utimes(n,s,i,l){l(a())}}}if(global.process||(global.process={getuid(){return-1},getgid(){return-1},geteuid(){return-1},getegid(){return-1},getgroups(){throw a()},pid:-1,ppid:-1,umask(){throw a()},cwd(){throw a()},chdir(){throw a()}}),!global.crypto&&global.require){const r=require("crypto");global.crypto={getRandomValues(n){r.randomFillSync(n)}}}if(!global.crypto)throw new Error("global.crypto is not available, polyfill required (getRandomValues only)");if(global.performance||(global.performance={now(){const[r,n]=process.hrtime();return r*1e3+n/1e6}}),!global.TextEncoder&&global.require&&(global.TextEncoder=require("util").TextEncoder),!global.TextEncoder)throw new Error("global.TextEncoder is not available, polyfill required");if(!global.TextDecoder&&global.require&&(global.TextDecoder=require("util").TextDecoder),!global.TextDecoder)throw new Error("global.TextDecoder is not available, polyfill required");const f=new TextEncoder("utf-8"),g=new TextDecoder("utf-8");if(global.Go=class{constructor(){this.argv=["js"],this.env={},this.exit=e=>{e!==0&&console.warn("exit code:",e)},this._exitPromise=new Promise(e=>{this._resolveExitPromise=e}),this._pendingEvent=null,this._scheduledTimeouts=new Map,this._nextCallbackTimeoutID=1;const r=(e,t)=>{this.mem.setUint32(e+0,t,!0),this.mem.setUint32(e+4,Math.floor(t/4294967296),!0)},n=e=>{const t=this.mem.getUint32(e+0,!0),o=this.mem.getInt32(e+4,!0);return t+o*4294967296},s=e=>{const t=this.mem.getFloat64(e,!0);if(t===0)return;if(!isNaN(t))return t;const o=this.mem.getUint32(e,!0);return this._values[o]},i=(e,t)=>{const o=2146959360;if(typeof t=="number"&&t!==0){if(isNaN(t)){this.mem.setUint32(e+4,o,!0),this.mem.setUint32(e,0,!0);return}this.mem.setFloat64(e,t,!0);return}if(t===void 0){this.mem.setFloat64(e,0,!0);return}let c=this._ids.get(t);c===void 0&&(c=this._idPool.pop(),c===void 0&&(c=this._values.length),this._values[c]=t,this._goRefCounts[c]=0,this._ids.set(t,c)),this._goRefCounts[c]++;let m=0;switch(typeof t){case"object":t!==null&&(m=1);break;case"string":m=2;break;case"symbol":m=3;break;case"function":m=4;break}this.mem.setUint32(e+4,o|m,!0),this.mem.setUint32(e,c,!0)},l=e=>{const t=n(e+0),o=n(e+8);return new Uint8Array(this._inst.exports.mem.buffer,t,o)},d=e=>{const t=n(e+0),o=n(e+8),c=new Array(o);for(let m=0;m<o;m++)c[m]=s(t+m*8);return c},u=e=>{const t=n(e+0),o=n(e+8);return g.decode(new DataView(this._inst.exports.mem.buffer,t,o))},h=Date.now()-performance.now();this.importObject={go:{"runtime.wasmExit":e=>{e>>>=0;const t=this.mem.getInt32(e+8,!0);this.exited=!0,delete this._inst,delete this._values,delete this._goRefCounts,delete this._ids,delete this._idPool,this.exit(t)},"runtime.wasmWrite":e=>{e>>>=0;const t=n(e+8),o=n(e+16),c=this.mem.getInt32(e+24,!0);fs.writeSync(t,new Uint8Array(this._inst.exports.mem.buffer,o,c))},"runtime.resetMemoryDataView":e=>{e>>>=0,this.mem=new DataView(this._inst.exports.mem.buffer)},"runtime.nanotime1":e=>{e>>>=0,r(e+8,(h+performance.now())*1e6)},"runtime.walltime":e=>{e>>>=0;const t=new Date().getTime();r(e+8,t/1e3),this.mem.setInt32(e+16,t%1e3*1e6,!0)},"runtime.scheduleTimeoutEvent":e=>{e>>>=0;const t=this._nextCallbackTimeoutID;this._nextCallbackTimeoutID++,this._scheduledTimeouts.set(t,setTimeout(()=>{for(this._resume();this._scheduledTimeouts.has(t);)console.warn("scheduleTimeoutEvent: missed timeout event"),this._resume()},n(e+8)+1)),this.mem.setInt32(e+16,t,!0)},"runtime.clearTimeoutEvent":e=>{e>>>=0;const t=this.mem.getInt32(e+8,!0);clearTimeout(this._scheduledTimeouts.get(t)),this._scheduledTimeouts.delete(t)},"runtime.getRandomData":e=>{e>>>=0,crypto.getRandomValues(l(e+8))},"syscall/js.finalizeRef":e=>{e>>>=0;const t=this.mem.getUint32(e+8,!0);if(this._goRefCounts[t]--,this._goRefCounts[t]===0){const o=this._values[t];this._values[t]=null,this._ids.delete(o),this._idPool.push(t)}},"syscall/js.stringVal":e=>{e>>>=0,i(e+24,u(e+8))},"syscall/js.valueGet":e=>{e>>>=0;const t=Reflect.get(s(e+8),u(e+16));e=this._inst.exports.getsp()>>>0,i(e+32,t)},"syscall/js.valueSet":e=>{e>>>=0,Reflect.set(s(e+8),u(e+16),s(e+32))},"syscall/js.valueDelete":e=>{e>>>=0,Reflect.deleteProperty(s(e+8),u(e+16))},"syscall/js.valueIndex":e=>{e>>>=0,i(e+24,Reflect.get(s(e+8),n(e+16)))},"syscall/js.valueSetIndex":e=>{e>>>=0,Reflect.set(s(e+8),n(e+16),s(e+24))},"syscall/js.valueCall":e=>{e>>>=0;try{const t=s(e+8),o=Reflect.get(t,u(e+16)),c=d(e+32),m=Reflect.apply(o,t,c);e=this._inst.exports.getsp()>>>0,i(e+56,m),this.mem.setUint8(e+64,1)}catch(t){e=this._inst.exports.getsp()>>>0,i(e+56,t),this.mem.setUint8(e+64,0)}},"syscall/js.valueInvoke":e=>{e>>>=0;try{const t=s(e+8),o=d(e+16),c=Reflect.apply(t,void 0,o);e=this._inst.exports.getsp()>>>0,i(e+40,c),this.mem.setUint8(e+48,1)}catch(t){e=this._inst.exports.getsp()>>>0,i(e+40,t),this.mem.setUint8(e+48,0)}},"syscall/js.valueNew":e=>{e>>>=0;try{const t=s(e+8),o=d(e+16),c=Reflect.construct(t,o);e=this._inst.exports.getsp()>>>0,i(e+40,c),this.mem.setUint8(e+48,1)}catch(t){e=this._inst.exports.getsp()>>>0,i(e+40,t),this.mem.setUint8(e+48,0)}},"syscall/js.valueLength":e=>{e>>>=0,r(e+16,parseInt(s(e+8).length))},"syscall/js.valuePrepareString":e=>{e>>>=0;const t=f.encode(String(s(e+8)));i(e+16,t),r(e+24,t.length)},"syscall/js.valueLoadString":e=>{e>>>=0;const t=s(e+8);l(e+16).set(t)},"syscall/js.valueInstanceOf":e=>{e>>>=0,this.mem.setUint8(e+24,s(e+8)instanceof s(e+16)?1:0)},"syscall/js.copyBytesToGo":e=>{e>>>=0;const t=l(e+8),o=s(e+32);if(!(o instanceof Uint8Array||o instanceof Uint8ClampedArray)){this.mem.setUint8(e+48,0);return}const c=o.subarray(0,t.length);t.set(c),r(e+40,c.length),this.mem.setUint8(e+48,1)},"syscall/js.copyBytesToJS":e=>{e>>>=0;const t=s(e+8),o=l(e+16);if(!(t instanceof Uint8Array||t instanceof Uint8ClampedArray)){this.mem.setUint8(e+48,0);return}const c=o.subarray(0,t.length);t.set(c),r(e+40,c.length),this.mem.setUint8(e+48,1)},debug:e=>{console.log(e)}}}}async run(r){if(!(r instanceof WebAssembly.Instance))throw new Error("Go.run: WebAssembly.Instance expected");this._inst=r,this.mem=new DataView(this._inst.exports.mem.buffer),this._values=[NaN,0,null,!0,!1,global,this],this._goRefCounts=new Array(this._values.length).fill(1/0),this._ids=new Map([[0,1],[null,2],[!0,3],[!1,4],[global,5],[this,6]]),this._idPool=[],this.exited=!1;let n=4096;const s=e=>{const t=n,o=f.encode(e+"\\0");return new Uint8Array(this.mem.buffer,n,o.length).set(o),n+=o.length,n%8!=0&&(n+=8-n%8),t},i=this.argv.length,l=[];this.argv.forEach(e=>{l.push(s(e))}),l.push(0),Object.keys(this.env).sort().forEach(e=>{l.push(s(`${e}=${this.env[e]}`))}),l.push(0);const u=n;l.forEach(e=>{this.mem.setUint32(n,e,!0),this.mem.setUint32(n+4,0,!0),n+=8});const h=4096+8192;if(n>=h)throw new Error("total length of command line and environment variables exceeds limit");this._inst.exports.run(i,u),this.exited&&this._resolveExitPromise(),await this._exitPromise}_resume(){if(this.exited)throw new Error("Go program has already exited");this._inst.exports.resume(),this.exited&&this._resolveExitPromise()}_makeFuncWrapper(r){const n=this;return function(){const s={id:r,this:this,args:arguments};return n._pendingEvent=s,n._resume(),s.result}}},typeof module!="undefined"&&global.require&&global.require.main===module&&global.process&&global.process.versions&&!global.process.versions.electron){process.argv.length<3&&(console.error("usage: go_js_wasm_exec [wasm binary] [arguments]"),process.exit(1));const r=new Go;r.argv=process.argv.slice(2),r.env=Object.assign({TMPDIR:require("os").tmpdir()},process.env),r.exit=process.exit,WebAssembly.instantiate(fs.readFileSync(process.argv[2]),r.importObject).then(n=>(process.on("exit",s=>{s===0&&!r.exited&&(r._pendingEvent={id:0},r._resume())}),r.run(n.instance))).catch(n=>{console.error(n),process.exit(1)})}})();\nonmessage=({data:c})=>{let y=new TextDecoder,s=global.fs,a="";s.writeSync=(e,t)=>{if(e===1)postMessage(t);else if(e===2){a+=y.decode(t);let n=a.split(`\n`);n.length>1&&console.log(n.slice(0,-1).join(`\n`)),a=n[n.length-1]}else throw new Error("Bad write");return t.length};let l=[],i,r=0;onmessage=({data:e})=>{e.length>0&&(l.push(e),i&&i())},s.read=(e,t,n,d,h,m)=>{if(e!==0||n!==0||d!==t.length||h!==null)throw new Error("Bad read");if(l.length===0){i=()=>s.read(e,t,n,d,h,m);return}let g=l[0],u=Math.max(0,Math.min(d,g.length-r));t.set(g.subarray(r,r+u),n),r+=u,r===g.length&&(l.shift(),r=0),m(null,u)};let o=new global.Go;o.argv=["","--service=0.14.3"],WebAssembly.instantiate(c,o.importObject).then(({instance:e})=>o.run(e))};}',l;if(t){let w=new Blob([g],{type:"text/javascript"});l=new Worker(URL.createObjectURL(w))}else{let O=new Function("postMessage",g+"var onmessage; return m => onmessage(m)")(x=>l.onmessage({data:x}));l={onmessage:null,postMessage:x=>O({data:x}),terminate(){}}}l.postMessage(s),l.onmessage=({data:w})=>f(w);let{readFromStdout:f,service:i}=He({writeToStdin(w){l.postMessage(w)},isSync:!1,isBrowser:!0,esbuild:Le});Ie={build:w=>new Promise((O,x)=>i.buildOrServe({callName:"build",refs:null,serveOptions:null,options:w,isTTY:!1,defaultWD:"/",callback:(N,L)=>N?x(N):O(L)})),transform:(w,O)=>new Promise((x,N)=>i.transform({callName:"transform",refs:null,input:w,options:O||{},isTTY:!1,fs:{readFile(L,k){k(new Error("Internal error"),null)},writeFile(L,k){k(null)}},callback:(L,k)=>L?N(L):x(k)})),formatMessages:(w,O)=>new Promise((x,N)=>i.formatMessages({callName:"formatMessages",refs:null,messages:w,options:O,callback:(L,k)=>L?N(L):x(k)})),analyzeMetafile:(w,O)=>new Promise((x,N)=>i.analyzeMetafile({callName:"analyzeMetafile",refs:null,metafile:typeof w=="string"?w:JSON.stringify(w),options:O,callback:(L,k)=>L?N(L):x(k)}))}};export{Ot as analyzeMetafile,Et as analyzeMetafileSync,bt as build,St as buildSync,Rt as formatMessages,kt as formatMessagesSync,$t as initialize,wt as serve,vt as transform,xt as transformSync,ht as version};
5
+ `),suggestion:""}}break}}return null}function we(e,t,r){let o=5,d=t.length<1?"":` with ${t.length} error${t.length<2?"":"s"}:`+t.slice(0,o+1).map((c,s)=>{if(s===o)return`
6
+ ...`;if(!c.location)return`
7
+ error: ${c.text}`;let{file:y,line:R,column:T}=c.location,C=c.pluginName?`[plugin: ${c.pluginName}] `:"";return`
8
+ ${y}:${R}:${T}: ERROR: ${C}${c.text}`}).join(""),i=new Error(`${e}${d}`);return i.errors=t,i.warnings=r,i}function ce(e,t){for(let r of e)r.detail=t.load(r.detail);return e}function Qe(e,t){if(e==null)return null;let r={},o=n(e,r,"file",g),d=n(e,r,"namespace",g),i=n(e,r,"line",ye),c=n(e,r,"column",ye),s=n(e,r,"length",ye),y=n(e,r,"lineText",g),R=n(e,r,"suggestion",g);return Y(e,r,t),{file:o||"",namespace:d||"",line:i||0,column:c||0,length:s||0,lineText:y||"",suggestion:R||""}}function me(e,t,r,o){let d=[],i=0;for(let c of e){let s={},y=n(c,s,"pluginName",g),R=n(c,s,"text",g),T=n(c,s,"location",Ke),C=n(c,s,"notes",_),$=n(c,s,"detail",Re),S=`in element ${i} of "${t}"`;Y(c,s,S);let ne=[];if(C)for(let re of C){let le={},ie=n(re,le,"text",g),se=n(re,le,"location",Ke);Y(re,le,S),ne.push({text:ie||"",location:Qe(se,S)})}d.push({pluginName:y||o,text:R||"",location:Qe(T,S),notes:ne,detail:r?r.store($):-1}),i++}return d}function xe(e,t){let r=[];for(let o of e){if(typeof o!="string")throw new Error(`${JSON.stringify(t)} must be an array of strings`);r.push(o)}return r}function pt({path:e,contents:t}){let r=null;return{path:e,contents:t,get text(){return r===null&&(r=ge(t)),r}}}var mt="0.14.11",yt=e=>ke().build(e),ht=()=>{throw new Error('The "serve" API only works in node')},bt=(e,t)=>ke().transform(e,t),wt=(e,t)=>ke().formatMessages(e,t),vt=(e,t)=>ke().analyzeMetafile(e,t),Rt=()=>{throw new Error('The "buildSync" API only works in node')},Ot=()=>{throw new Error('The "transformSync" API only works in node')},St=()=>{throw new Error('The "formatMessagesSync" API only works in node')},xt=()=>{throw new Error('The "analyzeMetafileSync" API only works in node')},ve,je,ke=()=>{if(je)return je;throw ve?new Error('You need to wait for the promise returned from "initialize" to be resolved before calling this'):new Error('You need to call "initialize" before calling this')},kt=e=>{e=Ve(e||{});let t=e.wasmURL,r=e.worker!==!1;if(!t)throw new Error('Must provide the "wasmURL" option');if(t+="",ve)throw new Error('Cannot call "initialize" more than once');return ve=Et(t,r),ve.catch(()=>{ve=void 0}),ve},Et=async(e,t)=>{let r=await fetch(e);if(!r.ok)throw new Error(`Failed to download ${JSON.stringify(e)}`);let o=await r.arrayBuffer(),d='{let global={};for(let o=self;o;o=Object.getPrototypeOf(o))for(let k of Object.getOwnPropertyNames(o))if(!(k in global))Object.defineProperty(global,k,{get:()=>self[k]});\n// Copyright 2018 The Go Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style\n// license that can be found in the LICENSE file.\n(()=>{if(typeof global=="undefined")if(typeof window!="undefined")window.global=window;else if(typeof self!="undefined")self.global=self;else throw new Error("cannot export Go (neither global, window nor self is defined)");if(!global.require&&typeof require!="undefined"&&(global.require=require),!global.fs&&global.require){const r=require("fs");typeof r=="object"&&r!==null&&Object.keys(r).length!==0&&(global.fs=Object.assign({},r,{write(n,s,i,l,d,u){if(i===0&&l===s.length&&d===null){if(n===process.stdout.fd){try{process.stdout.write(s,h=>h?u(h,0,null):u(null,l,s))}catch(h){u(h,0,null)}return}if(n===process.stderr.fd){try{process.stderr.write(s,h=>h?u(h,0,null):u(null,l,s))}catch(h){u(h,0,null)}return}}r.write(n,s,i,l,d,u)}}))}const a=()=>{const r=new Error("not implemented");return r.code="ENOSYS",r};if(!global.fs){let r="";global.fs={constants:{O_WRONLY:-1,O_RDWR:-1,O_CREAT:-1,O_TRUNC:-1,O_APPEND:-1,O_EXCL:-1},writeSync(n,s){r+=g.decode(s);const i=r.lastIndexOf(`\n`);return i!=-1&&(console.log(r.substr(0,i)),r=r.substr(i+1)),s.length},write(n,s,i,l,d,u){if(i!==0||l!==s.length||d!==null){u(a());return}const h=this.writeSync(n,s);u(null,h)},chmod(n,s,i){i(a())},chown(n,s,i,l){l(a())},close(n,s){s(a())},fchmod(n,s,i){i(a())},fchown(n,s,i,l){l(a())},fstat(n,s){s(a())},fsync(n,s){s(null)},ftruncate(n,s,i){i(a())},lchown(n,s,i,l){l(a())},link(n,s,i){i(a())},lstat(n,s){s(a())},mkdir(n,s,i){i(a())},open(n,s,i,l){l(a())},read(n,s,i,l,d,u){u(a())},readdir(n,s){s(a())},readlink(n,s){s(a())},rename(n,s,i){i(a())},rmdir(n,s){s(a())},stat(n,s){s(a())},symlink(n,s,i){i(a())},truncate(n,s,i){i(a())},unlink(n,s){s(a())},utimes(n,s,i,l){l(a())}}}if(global.process||(global.process={getuid(){return-1},getgid(){return-1},geteuid(){return-1},getegid(){return-1},getgroups(){throw a()},pid:-1,ppid:-1,umask(){throw a()},cwd(){throw a()},chdir(){throw a()}}),!global.crypto&&global.require){const r=require("crypto");global.crypto={getRandomValues(n){r.randomFillSync(n)}}}if(!global.crypto)throw new Error("global.crypto is not available, polyfill required (getRandomValues only)");if(global.performance||(global.performance={now(){const[r,n]=process.hrtime();return r*1e3+n/1e6}}),!global.TextEncoder&&global.require&&(global.TextEncoder=require("util").TextEncoder),!global.TextEncoder)throw new Error("global.TextEncoder is not available, polyfill required");if(!global.TextDecoder&&global.require&&(global.TextDecoder=require("util").TextDecoder),!global.TextDecoder)throw new Error("global.TextDecoder is not available, polyfill required");const f=new TextEncoder("utf-8"),g=new TextDecoder("utf-8");if(global.Go=class{constructor(){this.argv=["js"],this.env={},this.exit=e=>{e!==0&&console.warn("exit code:",e)},this._exitPromise=new Promise(e=>{this._resolveExitPromise=e}),this._pendingEvent=null,this._scheduledTimeouts=new Map,this._nextCallbackTimeoutID=1;const r=(e,t)=>{this.mem.setUint32(e+0,t,!0),this.mem.setUint32(e+4,Math.floor(t/4294967296),!0)},n=e=>{const t=this.mem.getUint32(e+0,!0),o=this.mem.getInt32(e+4,!0);return t+o*4294967296},s=e=>{const t=this.mem.getFloat64(e,!0);if(t===0)return;if(!isNaN(t))return t;const o=this.mem.getUint32(e,!0);return this._values[o]},i=(e,t)=>{const o=2146959360;if(typeof t=="number"&&t!==0){if(isNaN(t)){this.mem.setUint32(e+4,o,!0),this.mem.setUint32(e,0,!0);return}this.mem.setFloat64(e,t,!0);return}if(t===void 0){this.mem.setFloat64(e,0,!0);return}let c=this._ids.get(t);c===void 0&&(c=this._idPool.pop(),c===void 0&&(c=this._values.length),this._values[c]=t,this._goRefCounts[c]=0,this._ids.set(t,c)),this._goRefCounts[c]++;let m=0;switch(typeof t){case"object":t!==null&&(m=1);break;case"string":m=2;break;case"symbol":m=3;break;case"function":m=4;break}this.mem.setUint32(e+4,o|m,!0),this.mem.setUint32(e,c,!0)},l=e=>{const t=n(e+0),o=n(e+8);return new Uint8Array(this._inst.exports.mem.buffer,t,o)},d=e=>{const t=n(e+0),o=n(e+8),c=new Array(o);for(let m=0;m<o;m++)c[m]=s(t+m*8);return c},u=e=>{const t=n(e+0),o=n(e+8);return g.decode(new DataView(this._inst.exports.mem.buffer,t,o))},h=Date.now()-performance.now();this.importObject={go:{"runtime.wasmExit":e=>{e>>>=0;const t=this.mem.getInt32(e+8,!0);this.exited=!0,delete this._inst,delete this._values,delete this._goRefCounts,delete this._ids,delete this._idPool,this.exit(t)},"runtime.wasmWrite":e=>{e>>>=0;const t=n(e+8),o=n(e+16),c=this.mem.getInt32(e+24,!0);fs.writeSync(t,new Uint8Array(this._inst.exports.mem.buffer,o,c))},"runtime.resetMemoryDataView":e=>{e>>>=0,this.mem=new DataView(this._inst.exports.mem.buffer)},"runtime.nanotime1":e=>{e>>>=0,r(e+8,(h+performance.now())*1e6)},"runtime.walltime":e=>{e>>>=0;const t=new Date().getTime();r(e+8,t/1e3),this.mem.setInt32(e+16,t%1e3*1e6,!0)},"runtime.scheduleTimeoutEvent":e=>{e>>>=0;const t=this._nextCallbackTimeoutID;this._nextCallbackTimeoutID++,this._scheduledTimeouts.set(t,setTimeout(()=>{for(this._resume();this._scheduledTimeouts.has(t);)console.warn("scheduleTimeoutEvent: missed timeout event"),this._resume()},n(e+8)+1)),this.mem.setInt32(e+16,t,!0)},"runtime.clearTimeoutEvent":e=>{e>>>=0;const t=this.mem.getInt32(e+8,!0);clearTimeout(this._scheduledTimeouts.get(t)),this._scheduledTimeouts.delete(t)},"runtime.getRandomData":e=>{e>>>=0,crypto.getRandomValues(l(e+8))},"syscall/js.finalizeRef":e=>{e>>>=0;const t=this.mem.getUint32(e+8,!0);if(this._goRefCounts[t]--,this._goRefCounts[t]===0){const o=this._values[t];this._values[t]=null,this._ids.delete(o),this._idPool.push(t)}},"syscall/js.stringVal":e=>{e>>>=0,i(e+24,u(e+8))},"syscall/js.valueGet":e=>{e>>>=0;const t=Reflect.get(s(e+8),u(e+16));e=this._inst.exports.getsp()>>>0,i(e+32,t)},"syscall/js.valueSet":e=>{e>>>=0,Reflect.set(s(e+8),u(e+16),s(e+32))},"syscall/js.valueDelete":e=>{e>>>=0,Reflect.deleteProperty(s(e+8),u(e+16))},"syscall/js.valueIndex":e=>{e>>>=0,i(e+24,Reflect.get(s(e+8),n(e+16)))},"syscall/js.valueSetIndex":e=>{e>>>=0,Reflect.set(s(e+8),n(e+16),s(e+24))},"syscall/js.valueCall":e=>{e>>>=0;try{const t=s(e+8),o=Reflect.get(t,u(e+16)),c=d(e+32),m=Reflect.apply(o,t,c);e=this._inst.exports.getsp()>>>0,i(e+56,m),this.mem.setUint8(e+64,1)}catch(t){e=this._inst.exports.getsp()>>>0,i(e+56,t),this.mem.setUint8(e+64,0)}},"syscall/js.valueInvoke":e=>{e>>>=0;try{const t=s(e+8),o=d(e+16),c=Reflect.apply(t,void 0,o);e=this._inst.exports.getsp()>>>0,i(e+40,c),this.mem.setUint8(e+48,1)}catch(t){e=this._inst.exports.getsp()>>>0,i(e+40,t),this.mem.setUint8(e+48,0)}},"syscall/js.valueNew":e=>{e>>>=0;try{const t=s(e+8),o=d(e+16),c=Reflect.construct(t,o);e=this._inst.exports.getsp()>>>0,i(e+40,c),this.mem.setUint8(e+48,1)}catch(t){e=this._inst.exports.getsp()>>>0,i(e+40,t),this.mem.setUint8(e+48,0)}},"syscall/js.valueLength":e=>{e>>>=0,r(e+16,parseInt(s(e+8).length))},"syscall/js.valuePrepareString":e=>{e>>>=0;const t=f.encode(String(s(e+8)));i(e+16,t),r(e+24,t.length)},"syscall/js.valueLoadString":e=>{e>>>=0;const t=s(e+8);l(e+16).set(t)},"syscall/js.valueInstanceOf":e=>{e>>>=0,this.mem.setUint8(e+24,s(e+8)instanceof s(e+16)?1:0)},"syscall/js.copyBytesToGo":e=>{e>>>=0;const t=l(e+8),o=s(e+32);if(!(o instanceof Uint8Array||o instanceof Uint8ClampedArray)){this.mem.setUint8(e+48,0);return}const c=o.subarray(0,t.length);t.set(c),r(e+40,c.length),this.mem.setUint8(e+48,1)},"syscall/js.copyBytesToJS":e=>{e>>>=0;const t=s(e+8),o=l(e+16);if(!(t instanceof Uint8Array||t instanceof Uint8ClampedArray)){this.mem.setUint8(e+48,0);return}const c=o.subarray(0,t.length);t.set(c),r(e+40,c.length),this.mem.setUint8(e+48,1)},debug:e=>{console.log(e)}}}}async run(r){if(!(r instanceof WebAssembly.Instance))throw new Error("Go.run: WebAssembly.Instance expected");this._inst=r,this.mem=new DataView(this._inst.exports.mem.buffer),this._values=[NaN,0,null,!0,!1,global,this],this._goRefCounts=new Array(this._values.length).fill(1/0),this._ids=new Map([[0,1],[null,2],[!0,3],[!1,4],[global,5],[this,6]]),this._idPool=[],this.exited=!1;let n=4096;const s=e=>{const t=n,o=f.encode(e+"\\0");return new Uint8Array(this.mem.buffer,n,o.length).set(o),n+=o.length,n%8!==0&&(n+=8-n%8),t},i=this.argv.length,l=[];this.argv.forEach(e=>{l.push(s(e))}),l.push(0),Object.keys(this.env).sort().forEach(e=>{l.push(s(`${e}=${this.env[e]}`))}),l.push(0);const u=n;l.forEach(e=>{this.mem.setUint32(n,e,!0),this.mem.setUint32(n+4,0,!0),n+=8});const h=4096+8192;if(n>=h)throw new Error("total length of command line and environment variables exceeds limit");this._inst.exports.run(i,u),this.exited&&this._resolveExitPromise(),await this._exitPromise}_resume(){if(this.exited)throw new Error("Go program has already exited");this._inst.exports.resume(),this.exited&&this._resolveExitPromise()}_makeFuncWrapper(r){const n=this;return function(){const s={id:r,this:this,args:arguments};return n._pendingEvent=s,n._resume(),s.result}}},typeof module!="undefined"&&global.require&&global.require.main===module&&global.process&&global.process.versions&&!global.process.versions.electron){process.argv.length<3&&(console.error("usage: go_js_wasm_exec [wasm binary] [arguments]"),process.exit(1));const r=new Go;r.argv=process.argv.slice(2),r.env=Object.assign({TMPDIR:require("os").tmpdir()},process.env),r.exit=process.exit,WebAssembly.instantiate(fs.readFileSync(process.argv[2]),r.importObject).then(n=>(process.on("exit",s=>{s===0&&!r.exited&&(r._pendingEvent={id:0},r._resume())}),r.run(n.instance))).catch(n=>{console.error(n),process.exit(1)})}})();\nonmessage=({data:c})=>{let y=new TextDecoder,s=global.fs,a="";s.writeSync=(e,t)=>{if(e===1)postMessage(t);else if(e===2){a+=y.decode(t);let n=a.split(`\n`);n.length>1&&console.log(n.slice(0,-1).join(`\n`)),a=n[n.length-1]}else throw new Error("Bad write");return t.length};let l=[],i,r=0;onmessage=({data:e})=>{e.length>0&&(l.push(e),i&&i())},s.read=(e,t,n,d,h,m)=>{if(e!==0||n!==0||d!==t.length||h!==null)throw new Error("Bad read");if(l.length===0){i=()=>s.read(e,t,n,d,h,m);return}let g=l[0],u=Math.max(0,Math.min(d,g.length-r));t.set(g.subarray(r,r+u),n),r+=u,r===g.length&&(l.shift(),r=0),m(null,u)};let o=new global.Go;o.argv=["","--service=0.14.11"],WebAssembly.instantiate(c,o.importObject).then(({instance:e})=>o.run(e))};}',i;if(t){let y=new Blob([d],{type:"text/javascript"});i=new Worker(URL.createObjectURL(y))}else{let R=new Function("postMessage",d+"var onmessage; return m => onmessage(m)")(T=>i.onmessage({data:T}));i={onmessage:null,postMessage:T=>R({data:T}),terminate(){}}}i.postMessage(o),i.onmessage=({data:y})=>c(y);let{readFromStdout:c,service:s}=Ye({writeToStdin(y){i.postMessage(y)},isSync:!1,isBrowser:!0,esbuild:Ce});je={build:y=>new Promise((R,T)=>s.buildOrServe({callName:"build",refs:null,serveOptions:null,options:y,isTTY:!1,defaultWD:"/",callback:(C,$)=>C?T(C):R($)})),transform:(y,R)=>new Promise((T,C)=>s.transform({callName:"transform",refs:null,input:y,options:R||{},isTTY:!1,fs:{readFile($,S){S(new Error("Internal error"),null)},writeFile($,S){S(null)}},callback:($,S)=>$?C($):T(S)})),formatMessages:(y,R)=>new Promise((T,C)=>s.formatMessages({callName:"formatMessages",refs:null,messages:y,options:R,callback:($,S)=>$?C($):T(S)})),analyzeMetafile:(y,R)=>new Promise((T,C)=>s.analyzeMetafile({callName:"analyzeMetafile",refs:null,metafile:typeof y=="string"?y:JSON.stringify(y),options:R,callback:($,S)=>$?C($):T(S)}))}};export{vt as analyzeMetafile,xt as analyzeMetafileSync,yt as build,Rt as buildSync,wt as formatMessages,St as formatMessagesSync,kt as initialize,ht as serve,bt as transform,Ot as transformSync,mt as version};
@@ -3,6 +3,7 @@ export type Format = 'iife' | 'cjs' | 'esm';
3
3
  export type Loader = 'js' | 'jsx' | 'ts' | 'tsx' | 'css' | 'json' | 'text' | 'base64' | 'file' | 'dataurl' | 'binary' | 'default';
4
4
  export type LogLevel = 'verbose' | 'debug' | 'info' | 'warning' | 'error' | 'silent';
5
5
  export type Charset = 'ascii' | 'utf8';
6
+ export type Drop = 'console' | 'debugger';
6
7
 
7
8
  interface CommonOptions {
8
9
  /** Documentation: https://esbuild.github.io/api/#sourcemap */
@@ -21,6 +22,7 @@ interface CommonOptions {
21
22
  /** Documentation: https://esbuild.github.io/api/#target */
22
23
  target?: string | string[];
23
24
 
25
+ drop?: Drop[];
24
26
  /** Documentation: https://esbuild.github.io/api/#minify */
25
27
  minify?: boolean;
26
28
  /** Documentation: https://esbuild.github.io/api/#minify */
@@ -260,6 +262,8 @@ export interface Plugin {
260
262
 
261
263
  export interface PluginBuild {
262
264
  initialOptions: BuildOptions;
265
+ resolve(path: string, options?: ResolveOptions): Promise<ResolveResult>;
266
+
263
267
  onStart(callback: () =>
264
268
  (OnStartResult | null | void | Promise<OnStartResult | null | void>)): void;
265
269
  onEnd(callback: (result: BuildResult) =>
@@ -285,6 +289,27 @@ export interface PluginBuild {
285
289
  };
286
290
  }
287
291
 
292
+ export interface ResolveOptions {
293
+ pluginName?: string;
294
+ importer?: string;
295
+ namespace?: string;
296
+ resolveDir?: string;
297
+ kind?: ImportKind;
298
+ pluginData?: any;
299
+ }
300
+
301
+ export interface ResolveResult {
302
+ errors: Message[];
303
+ warnings: Message[];
304
+
305
+ path: string;
306
+ external: boolean;
307
+ sideEffects: boolean;
308
+ namespace: string;
309
+ suffix: string;
310
+ pluginData: any;
311
+ }
312
+
288
313
  export interface OnStartResult {
289
314
  errors?: PartialMessage[];
290
315
  warnings?: PartialMessage[];
@@ -424,7 +449,9 @@ export interface AnalyzeMetafileOptions {
424
449
  * Documentation: https://esbuild.github.io/api/#build-api
425
450
  */
426
451
  export declare function build(options: BuildOptions & { write: false }): Promise<BuildResult & { outputFiles: OutputFile[] }>;
452
+ export declare function build(options: BuildOptions & { incremental: true, metafile: true }): Promise<BuildIncremental & { metafile: Metafile }>;
427
453
  export declare function build(options: BuildOptions & { incremental: true }): Promise<BuildIncremental>;
454
+ export declare function build(options: BuildOptions & { metafile: true }): Promise<BuildResult & { metafile: Metafile }>;
428
455
  export declare function build(options: BuildOptions): Promise<BuildResult>;
429
456
 
430
457
  /**