isomorfeus-asset-manager 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +21 -0
  3. data/README.md +12 -0
  4. data/lib/iso_opal.rb +10 -0
  5. data/lib/isomorfeus/asset_manager/asset.rb +67 -0
  6. data/lib/isomorfeus/asset_manager/config.rb +69 -0
  7. data/lib/isomorfeus/asset_manager/js_import.rb +59 -0
  8. data/lib/isomorfeus/asset_manager/portfolio.rb +46 -0
  9. data/lib/isomorfeus/asset_manager/rack_middleware.rb +85 -0
  10. data/lib/isomorfeus/asset_manager/ruby_import.rb +33 -0
  11. data/lib/isomorfeus/asset_manager/server_socket_processor.rb +55 -0
  12. data/lib/isomorfeus/asset_manager/version.rb +5 -0
  13. data/lib/isomorfeus/asset_manager/view_helper.rb +9 -0
  14. data/lib/isomorfeus/asset_manager.rb +145 -0
  15. data/lib/isomorfeus-asset-manager.rb +27 -0
  16. data/node_modules/.bin/esbuild +12 -0
  17. data/node_modules/.bin/esbuild.cmd +17 -0
  18. data/node_modules/.bin/esbuild.ps1 +28 -0
  19. data/node_modules/.package-lock.json +18 -0
  20. data/node_modules/esbuild-wasm/README.md +3 -0
  21. data/node_modules/esbuild-wasm/bin/esbuild +84 -0
  22. data/node_modules/esbuild-wasm/esbuild.wasm +0 -0
  23. data/node_modules/esbuild-wasm/esm/browser.d.ts +397 -0
  24. data/node_modules/esbuild-wasm/esm/browser.js +2341 -0
  25. data/node_modules/esbuild-wasm/esm/browser.min.js +8 -0
  26. data/node_modules/esbuild-wasm/exit0.js +11 -0
  27. data/node_modules/esbuild-wasm/lib/browser.d.ts +397 -0
  28. data/node_modules/esbuild-wasm/lib/browser.js +2371 -0
  29. data/node_modules/esbuild-wasm/lib/browser.min.js +10 -0
  30. data/node_modules/esbuild-wasm/lib/main.d.ts +397 -0
  31. data/node_modules/esbuild-wasm/lib/main.js +1948 -0
  32. data/node_modules/esbuild-wasm/package.json +16 -0
  33. data/node_modules/esbuild-wasm/wasm_exec.js +654 -0
  34. data/package.json +9 -0
  35. metadata +162 -0
@@ -0,0 +1,10 @@
1
+ (exports=>{
2
+ var De=Object.defineProperty,et=Object.defineProperties;var tt=Object.getOwnPropertyDescriptors;var Ue=Object.getOwnPropertySymbols;var rt=Object.prototype.hasOwnProperty,nt=Object.prototype.propertyIsEnumerable;var We=(e,t,r)=>t in e?De(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Pe=(e,t)=>{for(var r in t||(t={}))rt.call(t,r)&&We(e,r,t[r]);if(Ue)for(var r of Ue(t))nt.call(t,r)&&We(e,r,t[r]);return e},Be=(e,t)=>et(e,tt(t)),lt=e=>De(e,"__esModule",{value:!0});var it=(e,t)=>{lt(e);for(var r in t)De(e,r,{get:t[r],enumerable:!0})};var se=(e,t,r)=>new Promise((s,d)=>{var l=y=>{try{i(r.next(y))}catch(O){d(O)}},u=y=>{try{i(r.throw(y))}catch(O){d(O)}},i=y=>y.done?s(y.value):Promise.resolve(y.value).then(l,u);i((r=r.apply(e,t)).next())});it(exports,{build:()=>mt,buildSync:()=>wt,formatMessages:()=>bt,formatMessagesSync:()=>Rt,initialize:()=>Ot,serve:()=>yt,transform:()=>ht,transformSync:()=>vt,version:()=>gt});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(oe(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 d of s)t(d)}else{let d=Object.keys(s);r.write8(6),r.write32(d.length);for(let l of d)r.write(oe(l)),t(s[l])}},r=new Fe;return r.write32(0),r.write32(e.id<<1|+!e.isRequest),t(e.value),Ae(r.buf,r.len-4,0),r.buf.subarray(0,r.len)}function qe(e){let t=()=>{switch(r.read8()){case 0:return null;case 1:return!!r.read8();case 2:return r.read32();case 3:return ce(r.read());case 4:return r.read();case 5:{let u=r.read32(),i=[];for(let y=0;y<u;y++)i.push(t());return i}case 6:{let u=r.read32(),i={};for(let y=0;y<u;y++)i[ce(r.read())]=t();return i}default:throw new Error("Invalid packet")}},r=new Fe(e),s=r.read32(),d=(s&1)==0;s>>>=1;let l=t();if(r.ptr!==e.length)throw new Error("Invalid packet");return{id:s,isRequest:d,value:l}}var Fe=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);Ae(this.buf,t,r)}write(t){let r=this._write(4+t.length);Ae(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 je(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}},oe,ce;if(typeof TextEncoder!="undefined"&&typeof TextDecoder!="undefined"){let e=new TextEncoder,t=new TextDecoder;oe=r=>e.encode(r),ce=r=>t.decode(r)}else if(typeof Buffer!="undefined")oe=e=>{let t=Buffer.from(e);return t instanceof Uint8Array||(t=new Uint8Array(t)),t},ce=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 je(e,t){return e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24}function Ae(e,t,r){e[r++]=t,e[r++]=t>>8,e[r++]=t>>16,e[r++]=t>>24}function Ke(e){if(e+="",e.indexOf(",")>=0)throw new Error(`Invalid target: ${e}`);return e}var Ne=()=>null,W=e=>typeof e=="boolean"?null:"a boolean",st=e=>typeof e=="boolean"||typeof e=="object"&&!Array.isArray(e)?null:"a boolean or an object",h=e=>typeof e=="string"?null:"a string",_e=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",q=e=>Array.isArray(e)?null:"an array",me=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",Ve=e=>typeof e=="object"&&!Array.isArray(e)?null:"an object or null",Ie=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",ct=e=>typeof e=="string"||e instanceof Uint8Array?null:"a string or a Uint8Array";function n(e,t,r,s){let d=e[r];if(t[r+""]=!0,d===void 0)return;let l=s(d);if(l!==null)throw new Error(`"${r}" must be ${l}`);return d}function z(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",h),s=n(e,t,"worker",W);return z(e,t,"in startService() call"),{wasmURL:r,worker:s}}function Oe(e,t,r,s,d){let l=n(t,r,"color",W),u=n(t,r,"logLevel",h),i=n(t,r,"logLimit",ge);l!==void 0?e.push(`--color=${l}`):s&&e.push("--color=true"),e.push(`--log-level=${u||d}`),e.push(`--log-limit=${i||0}`)}function ze(e,t,r){let s=n(t,r,"legalComments",h),d=n(t,r,"sourceRoot",h),l=n(t,r,"sourcesContent",W),u=n(t,r,"target",ut),i=n(t,r,"format",h),y=n(t,r,"globalName",h),O=n(t,r,"minify",W),x=n(t,r,"minifySyntax",W),A=n(t,r,"minifyWhitespace",W),K=n(t,r,"minifyIdentifiers",W),$=n(t,r,"charset",h),L=n(t,r,"treeShaking",Ie),ee=n(t,r,"jsx",h),Q=n(t,r,"jsxFactory",h),re=n(t,r,"jsxFragment",h),te=n(t,r,"define",me),ae=n(t,r,"pure",q),ue=n(t,r,"keepNames",W);if(s&&e.push(`--legal-comments=${s}`),d!==void 0&&e.push(`--source-root=${d}`),l!==void 0&&e.push(`--sources-content=${l}`),u&&(Array.isArray(u)?e.push(`--target=${Array.from(u).map(Ke).join(",")}`):e.push(`--target=${Ke(u)}`)),i&&e.push(`--format=${i}`),y&&e.push(`--global-name=${y}`),O&&e.push("--minify"),x&&e.push("--minify-syntax"),A&&e.push("--minify-whitespace"),K&&e.push("--minify-identifiers"),$&&e.push(`--charset=${$}`),L!==void 0&&L!==!0&&e.push(`--tree-shaking=${L}`),ee&&e.push(`--jsx=${ee}`),Q&&e.push(`--jsx-factory=${Q}`),re&&e.push(`--jsx-fragment=${re}`),te)for(let H in te){if(H.indexOf("=")>=0)throw new Error(`Invalid define: ${H}`);e.push(`--define:${H}=${te[H]}`)}if(ae)for(let H of ae)e.push(`--pure:${H}`);ue&&e.push("--keep-names")}function ft(e,t,r,s,d){var j;let l=[],u=[],i=Object.create(null),y=null,O=null,x=null;Oe(l,t,i,r,s),ze(l,t,i);let A=n(t,i,"sourcemap",Ie),K=n(t,i,"bundle",W),$=n(t,i,"watch",st),L=n(t,i,"splitting",W),ee=n(t,i,"preserveSymlinks",W),Q=n(t,i,"metafile",W),re=n(t,i,"outfile",h),te=n(t,i,"outdir",h),ae=n(t,i,"outbase",h),ue=n(t,i,"platform",h),H=n(t,i,"tsconfig",h),Re=n(t,i,"resolveExtensions",q),ve=n(t,i,"nodePaths",q),ke=n(t,i,"mainFields",q),Ee=n(t,i,"conditions",q),p=n(t,i,"external",q),c=n(t,i,"loader",me),a=n(t,i,"outExtension",me),g=n(t,i,"publicPath",h),U=n(t,i,"entryNames",h),F=n(t,i,"chunkNames",h),B=n(t,i,"assetNames",h),I=n(t,i,"inject",q),P=n(t,i,"banner",me),D=n(t,i,"footer",me),R=n(t,i,"entryPoints",ot),C=n(t,i,"absWorkingDir",h),k=n(t,i,"stdin",me),S=(j=n(t,i,"write",W))!=null?j:d,E=n(t,i,"allowOverwrite",W),m=n(t,i,"incremental",W)===!0;if(i.plugins=!0,z(t,i,`in ${e}() call`),A&&l.push(`--sourcemap${A===!0?"":`=${A}`}`),K&&l.push("--bundle"),E&&l.push("--allow-overwrite"),$)if(l.push("--watch"),typeof $=="boolean")x={};else{let o=Object.create(null),v=n($,o,"onRebuild",Ce);z($,o,`on "watch" in ${e}() call`),x={onRebuild:v}}if(L&&l.push("--splitting"),ee&&l.push("--preserve-symlinks"),Q&&l.push("--metafile"),re&&l.push(`--outfile=${re}`),te&&l.push(`--outdir=${te}`),ae&&l.push(`--outbase=${ae}`),ue&&l.push(`--platform=${ue}`),H&&l.push(`--tsconfig=${H}`),Re){let o=[];for(let v of Re){if(v+="",v.indexOf(",")>=0)throw new Error(`Invalid resolve extension: ${v}`);o.push(v)}l.push(`--resolve-extensions=${o.join(",")}`)}if(g&&l.push(`--public-path=${g}`),U&&l.push(`--entry-names=${U}`),F&&l.push(`--chunk-names=${F}`),B&&l.push(`--asset-names=${B}`),ke){let o=[];for(let v of ke){if(v+="",v.indexOf(",")>=0)throw new Error(`Invalid main field: ${v}`);o.push(v)}l.push(`--main-fields=${o.join(",")}`)}if(Ee){let o=[];for(let v of Ee){if(v+="",v.indexOf(",")>=0)throw new Error(`Invalid condition: ${v}`);o.push(v)}l.push(`--conditions=${o.join(",")}`)}if(p)for(let o of p)l.push(`--external:${o}`);if(P)for(let o in P){if(o.indexOf("=")>=0)throw new Error(`Invalid banner file type: ${o}`);l.push(`--banner:${o}=${P[o]}`)}if(D)for(let o in D){if(o.indexOf("=")>=0)throw new Error(`Invalid footer file type: ${o}`);l.push(`--footer:${o}=${D[o]}`)}if(I)for(let o of I)l.push(`--inject:${o}`);if(c)for(let o in c){if(o.indexOf("=")>=0)throw new Error(`Invalid loader extension: ${o}`);l.push(`--loader:${o}=${c[o]}`)}if(a)for(let o in a){if(o.indexOf("=")>=0)throw new Error(`Invalid out extension: ${o}`);l.push(`--out-extension:${o}=${a[o]}`)}if(R)if(Array.isArray(R))for(let o of R)u.push(["",o+""]);else for(let[o,v]of Object.entries(R))u.push([o+"",v+""]);if(k){let o=Object.create(null),v=n(k,o,"contents",h),f=n(k,o,"resolveDir",h),w=n(k,o,"sourcefile",h),M=n(k,o,"loader",h);z(k,o,'in "stdin" object'),w&&l.push(`--sourcefile=${w}`),M&&l.push(`--loader=${M}`),f&&(O=f+""),y=v?v+"":""}let b=[];if(ve)for(let o of ve)o+="",b.push(o);return{entries:u,flags:l,write:S,stdinContents:y,stdinResolveDir:O,absWorkingDir:C,incremental:m,nodePaths:b,watch:x}}function dt(e,t,r,s){let d=[],l=Object.create(null);Oe(d,t,l,r,s),ze(d,t,l);let u=n(t,l,"sourcemap",Ie),i=n(t,l,"tsconfigRaw",at),y=n(t,l,"sourcefile",h),O=n(t,l,"loader",h),x=n(t,l,"banner",h),A=n(t,l,"footer",h);return z(t,l,`in ${e}() call`),u&&d.push(`--sourcemap=${u===!0?"external":u}`),i&&d.push(`--tsconfig-raw=${typeof i=="string"?i:JSON.stringify(i)}`),y&&d.push(`--sourcefile=${y}`),O&&d.push(`--loader=${O}`),x&&d.push(`--banner=${x}`),A&&d.push(`--footer=${A}`),d}function Ye(e){let t=new Map,r=new Map,s=new Map,d=new Map,l=0,u=!1,i=0,y=0,O=new Uint8Array(16*1024),x=0,A=p=>{let c=x+p.length;if(c>O.length){let g=new Uint8Array(c*2);g.set(O),O=g}O.set(p,x),x+=p.length;let a=0;for(;a+4<=x;){let g=je(O,a);if(a+4+g>x)break;a+=4,re(O.subarray(a,a+g)),a+=g}a>0&&(O.copyWithin(0,a,x),x-=a)},K=()=>{u=!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 s.values())try{p(new Error("The service was stopped"),null)}catch(c){console.error(c)}s.clear()},$=(p,c,a)=>{if(u)return a("The service is no longer running",null);let g=i++;t.set(g,(U,F)=>{try{a(U,F)}finally{p&&p.unref()}}),p&&p.ref(),e.writeToStdin(Te({id:g,isRequest:!0,value:c}))},L=(p,c)=>{if(u)throw new Error("The service is no longer running");e.writeToStdin(Te({id:p,isRequest:!1,value:c}))},ee=(p,c)=>se(this,null,function*(){try{switch(c.command){case"ping":{L(p,{});break}case"start":{let a=r.get(c.key);a?L(p,yield a(c)):L(p,{});break}case"resolve":{let a=r.get(c.key);a?L(p,yield a(c)):L(p,{});break}case"load":{let a=r.get(c.key);a?L(p,yield a(c)):L(p,{});break}case"serve-request":{let a=d.get(c.serveID);a&&a.onRequest&&a.onRequest(c.args),L(p,{});break}case"serve-wait":{let a=d.get(c.serveID);a&&a.onWait(c.error),L(p,{});break}case"watch-rebuild":{let a=s.get(c.watchID);try{a&&a(null,c.args)}catch(g){console.error(g)}L(p,{});break}default:throw new Error("Invalid command: "+c.command)}}catch(a){L(p,{errors:[ye(a,e,null,void 0,"")]})}}),Q=!0,re=p=>{if(Q){Q=!1;let a=String.fromCharCode(...p);if(a!=="0.12.25")throw new Error(`Cannot start service: Host version "0.12.25" does not match binary version ${JSON.stringify(a)}`);return}let c=qe(p);if(c.isRequest)ee(c.id,c.value);else{let a=t.get(c.id);t.delete(c.id),c.value.error?a(c.value.error,{}):a(null,c.value)}},te=(p,c,a,g)=>se(this,null,function*(){let U=[],F=[],B={},I={},P=0,D=0,R=[];c=[...c];for(let E of c){let m={};if(typeof E!="object")throw new Error(`Plugin at index ${D} must be an object`);let b=n(E,m,"name",h);if(typeof b!="string"||b==="")throw new Error(`Plugin at index ${D} is missing a name`);try{let j=n(E,m,"setup",Ce);if(typeof j!="function")throw new Error("Plugin is missing a setup function");z(E,m,`on plugin ${JSON.stringify(b)}`);let o={name:b,onResolve:[],onLoad:[]};D++;let v=j({initialOptions:p,onStart(f){let w='This error came from the "onStart" callback registered here',M=Se(new Error(w),e,"onStart");U.push({name:b,callback:f,note:M})},onEnd(f){let w='This error came from the "onEnd" callback registered here',M=Se(new Error(w),e,"onEnd");F.push({name:b,callback:f,note:M})},onResolve(f,w){let M='This error came from the "onResolve" callback registered here',N=Se(new Error(M),e,"onResolve"),_={},V=n(f,_,"filter",_e),Y=n(f,_,"namespace",h);if(z(f,_,`in onResolve() call for plugin ${JSON.stringify(b)}`),V==null)throw new Error("onResolve() call is missing a filter");let J=P++;B[J]={name:b,callback:w,note:N},o.onResolve.push({id:J,filter:V.source,namespace:Y||""})},onLoad(f,w){let M='This error came from the "onLoad" callback registered here',N=Se(new Error(M),e,"onLoad"),_={},V=n(f,_,"filter",_e),Y=n(f,_,"namespace",h);if(z(f,_,`in onLoad() call for plugin ${JSON.stringify(b)}`),V==null)throw new Error("onLoad() call is missing a filter");let J=P++;I[J]={name:b,callback:w,note:N},o.onLoad.push({id:J,filter:V.source,namespace:Y||""})}});v&&(yield v),R.push(o)}catch(j){return{ok:!1,error:j,pluginName:b}}}let C=E=>se(this,null,function*(){switch(E.command){case"start":{let m={errors:[],warnings:[]};return yield Promise.all(U.map(v=>se(this,[v],function*({name:b,callback:j,note:o}){try{let f=yield j();if(f!=null){if(typeof f!="object")throw new Error(`Expected onStart() callback in plugin ${JSON.stringify(b)} to return an object`);let w={},M=n(f,w,"errors",q),N=n(f,w,"warnings",q);z(f,w,`from onStart() callback in plugin ${JSON.stringify(b)}`),M!=null&&m.errors.push(...fe(M,"errors",g,b)),N!=null&&m.warnings.push(...fe(N,"warnings",g,b))}}catch(f){m.errors.push(ye(f,e,g,o&&o(),b))}}))),m}case"resolve":{let m={},b="",j,o;for(let v of E.ids)try{({name:b,callback:j,note:o}=B[v]);let f=yield j({path:E.path,importer:E.importer,namespace:E.namespace,resolveDir:E.resolveDir,kind:E.kind,pluginData:g.load(E.pluginData)});if(f!=null){if(typeof f!="object")throw new Error(`Expected onResolve() callback in plugin ${JSON.stringify(b)} to return an object`);let w={},M=n(f,w,"pluginName",h),N=n(f,w,"path",h),_=n(f,w,"namespace",h),V=n(f,w,"external",W),Y=n(f,w,"sideEffects",W),J=n(f,w,"pluginData",Ne),le=n(f,w,"errors",q),ie=n(f,w,"warnings",q),T=n(f,w,"watchFiles",q),G=n(f,w,"watchDirs",q);z(f,w,`from onResolve() callback in plugin ${JSON.stringify(b)}`),m.id=v,M!=null&&(m.pluginName=M),N!=null&&(m.path=N),_!=null&&(m.namespace=_),V!=null&&(m.external=V),Y!=null&&(m.sideEffects=Y),J!=null&&(m.pluginData=g.store(J)),le!=null&&(m.errors=fe(le,"errors",g,b)),ie!=null&&(m.warnings=fe(ie,"warnings",g,b)),T!=null&&(m.watchFiles=xe(T,"watchFiles")),G!=null&&(m.watchDirs=xe(G,"watchDirs"));break}}catch(f){return{id:v,errors:[ye(f,e,g,o&&o(),b)]}}return m}case"load":{let m={},b="",j,o;for(let v of E.ids)try{({name:b,callback:j,note:o}=I[v]);let f=yield j({path:E.path,namespace:E.namespace,pluginData:g.load(E.pluginData)});if(f!=null){if(typeof f!="object")throw new Error(`Expected onLoad() callback in plugin ${JSON.stringify(b)} to return an object`);let w={},M=n(f,w,"pluginName",h),N=n(f,w,"contents",ct),_=n(f,w,"resolveDir",h),V=n(f,w,"pluginData",Ne),Y=n(f,w,"loader",h),J=n(f,w,"errors",q),le=n(f,w,"warnings",q),ie=n(f,w,"watchFiles",q),T=n(f,w,"watchDirs",q);z(f,w,`from onLoad() callback in plugin ${JSON.stringify(b)}`),m.id=v,M!=null&&(m.pluginName=M),N instanceof Uint8Array?m.contents=N:N!=null&&(m.contents=oe(N)),_!=null&&(m.resolveDir=_),V!=null&&(m.pluginData=g.store(V)),Y!=null&&(m.loader=Y),J!=null&&(m.errors=fe(J,"errors",g,b)),le!=null&&(m.warnings=fe(le,"warnings",g,b)),ie!=null&&(m.watchFiles=xe(ie,"watchFiles")),T!=null&&(m.watchDirs=xe(T,"watchDirs"));break}}catch(f){return{id:v,errors:[ye(f,e,g,o&&o(),b)]}}return m}default:throw new Error("Invalid command: "+E.command)}}),k=(E,m,b)=>b();F.length>0&&(k=(E,m,b)=>{(()=>se(this,null,function*(){for(let{name:j,callback:o,note:v}of F)try{yield o(E)}catch(f){E.errors.push(yield new Promise(w=>m(f,j,v&&v(),w)))}}))().then(b)});let S=0;return{ok:!0,requestPlugins:R,runOnEndCallbacks:k,pluginRefs:{ref(){++S==1&&r.set(a,C)},unref(){--S==0&&r.delete(a)}}}}),ae=(p,c,a)=>{let g={},U=n(c,g,"port",ge),F=n(c,g,"host",h),B=n(c,g,"servedir",h),I=n(c,g,"onRequest",Ce),P=l++,D,R=new Promise((C,k)=>{D=S=>{d.delete(P),S!==null?k(new Error(S)):C()}});return a.serve={serveID:P},z(c,g,"in serve() call"),U!==void 0&&(a.serve.port=U),F!==void 0&&(a.serve.host=F),B!==void 0&&(a.serve.servedir=B),d.set(P,{onRequest:I,onWait:D}),{wait:R,stop(){$(p,{command:"serve-stop",serveID:P},()=>{})}}},ue="warning",H="silent",Re=p=>{let c=y++,a=He(),g,{refs:U,options:F,isTTY:B,callback:I}=p;if(typeof F=="object"){let R=F.plugins;if(R!==void 0){if(!Array.isArray(R))throw new Error('"plugins" must be an array');g=R}}let P=(R,C,k,S)=>{let E=[];try{Oe(E,F,{},B,ue)}catch(b){}let m=ye(R,e,a,k,C);$(U,{command:"error",flags:E,error:m},()=>{m.detail=a.load(m.detail),S(m)})},D=(R,C)=>{P(R,C,void 0,k=>{I(he("Build failed",[k],[]),null)})};if(g&&g.length>0){if(e.isSync)return D(new Error("Cannot use plugins in synchronous API calls"),"");te(F,g,c,a).then(R=>{if(!R.ok)D(R.error,R.pluginName);else try{ve(Be(Pe({},p),{key:c,details:a,logPluginError:P,requestPlugins:R.requestPlugins,runOnEndCallbacks:R.runOnEndCallbacks,pluginRefs:R.pluginRefs}))}catch(C){D(C,"")}},R=>D(R,""))}else try{ve(Be(Pe({},p),{key:c,details:a,logPluginError:P,requestPlugins:null,runOnEndCallbacks:(R,C,k)=>k(),pluginRefs:null}))}catch(R){D(R,"")}},ve=({callName:p,refs:c,serveOptions:a,options:g,isTTY:U,defaultWD:F,callback:B,key:I,details:P,logPluginError:D,requestPlugins:R,runOnEndCallbacks:C,pluginRefs:k})=>{let S={ref(){k&&k.ref(),c&&c.ref()},unref(){k&&k.unref(),c&&c.unref()}},E=!e.isBrowser,{entries:m,flags:b,write:j,stdinContents:o,stdinResolveDir:v,absWorkingDir:f,incremental:w,nodePaths:M,watch:N}=ft(p,g,U,ue,E),_={command:"build",key:I,entries:m,flags:b,write:j,stdinContents:o,stdinResolveDir:v,absWorkingDir:f||F,incremental:w,nodePaths:M};R&&(_.plugins=R);let V=a&&ae(S,a,_),Y,J,le=(T,G)=>{T.outputFiles&&(G.outputFiles=T.outputFiles.map(pt)),T.metafile&&(G.metafile=JSON.parse(T.metafile)),T.writeToStdout!==void 0&&console.log(ce(T.writeToStdout).replace(/\n$/,""))},ie=(T,G)=>{let X={errors:be(T.errors,P),warnings:be(T.warnings,P)};le(T,X),C(X,D,()=>{if(X.errors.length>0)return G(he("Build failed",X.errors,X.warnings),null);if(T.rebuildID!==void 0){if(!Y){let ne=!1;Y=()=>new Promise((de,pe)=>{if(ne||u)throw new Error("Cannot rebuild");$(S,{command:"rebuild",rebuildID:T.rebuildID},(Z,Xe)=>{if(Z)return G(he("Build failed",[{pluginName:"",text:Z,location:null,notes:[],detail:void 0}],[]),null);ie(Xe,($e,Ze)=>{$e?pe($e):de(Ze)})})}),S.ref(),Y.dispose=()=>{ne||(ne=!0,$(S,{command:"rebuild-dispose",rebuildID:T.rebuildID},()=>{}),S.unref())}}X.rebuild=Y}if(T.watchID!==void 0){if(!J){let ne=!1;S.ref(),J=()=>{ne||(ne=!0,s.delete(T.watchID),$(S,{command:"watch-stop",watchID:T.watchID},()=>{}),S.unref())},N&&s.set(T.watchID,(de,pe)=>{if(de){N.onRebuild&&N.onRebuild(de,null);return}let Z={errors:be(pe.errors,P),warnings:be(pe.warnings,P)};le(pe,Z),C(Z,D,()=>{if(Z.errors.length>0){N.onRebuild&&N.onRebuild(he("Build failed",Z.errors,Z.warnings),null);return}pe.rebuildID!==void 0&&(Z.rebuild=Y),Z.stop=J,N.onRebuild&&N.onRebuild(null,Z)})})}X.stop=J}G(null,X)})};if(j&&e.isBrowser)throw new Error('Cannot enable "write" in the browser');if(w&&e.isSync)throw new Error('Cannot use "incremental" with a synchronous build');if(N&&e.isSync)throw new Error('Cannot use "watch" with a synchronous build');$(S,_,(T,G)=>{if(T)return B(new Error(T),null);if(V){let X=G,ne=!1;S.ref();let de={port:X.port,host:X.host,wait:V.wait,stop(){ne||(ne=!0,V.stop(),S.unref())}};return S.ref(),V.wait.then(S.unref,S.unref),B(null,de)}return ie(G,B)})};return{readFromStdout:A,afterClose:K,service:{buildOrServe:Re,transform:({callName:p,refs:c,input:a,options:g,isTTY:U,fs:F,callback:B})=>{let I=He(),P=D=>{try{if(typeof a!="string")throw new Error('The input to "transform" must be a string');let R=dt(p,g,U,H);$(c,{command:"transform",flags:R,inputFS:D!==null,input:D!==null?D:a},(k,S)=>{if(k)return B(new Error(k),null);let E=be(S.errors,I),m=be(S.warnings,I),b=1,j=()=>--b==0&&B(null,{warnings:m,code:S.code,map:S.map});if(E.length>0)return B(he("Transform failed",E,m),null);S.codeFS&&(b++,F.readFile(S.code,(o,v)=>{o!==null?B(o,null):(S.code=v,j())})),S.mapFS&&(b++,F.readFile(S.map,(o,v)=>{o!==null?B(o,null):(S.map=v,j())})),j()})}catch(R){let C=[];try{Oe(C,g,{},U,H)}catch(S){}let k=ye(R,e,I,void 0,"");$(c,{command:"error",flags:C,error:k},()=>{k.detail=I.load(k.detail),B(he("Transform failed",[k],[]),null)})}};if(typeof a=="string"&&a.length>1024*1024){let D=P;P=()=>F.writeFile(a,D)}P(null)},formatMessages:({callName:p,refs:c,messages:a,options:g,callback:U})=>{let F=fe(a,"messages",null,"");if(!g)throw new Error(`Missing second argument in ${p}() call`);let B={},I=n(g,B,"kind",h),P=n(g,B,"color",W),D=n(g,B,"terminalWidth",ge);if(z(g,B,`in ${p}() call`),I===void 0)throw new Error(`Missing "kind" in ${p}() call`);if(I!=="error"&&I!=="warning")throw new Error(`Expected "kind" to be "error" or "warning" in ${p}() call`);let R={command:"format-msgs",messages:F,isWarning:I==="warning"};P!==void 0&&(R.color=P),D!==void 0&&(R.terminalWidth=D),$(c,R,(C,k)=>{if(C)return U(new Error(C),null);U(null,k.messages)})}}}}function He(){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 Se(e,t,r){let s,d=!1;return()=>{if(d)return s;d=!0;try{let l=(e.stack+"").split(`
3
+ `);l.splice(1,1);let u=Ge(t,l,r);if(u)return s={text:e.message,location:u},s}catch(l){}}}function ye(e,t,r,s,d){let l="Internal error",u=null;try{l=(e&&e.message||e)+""}catch(i){}try{u=Ge(t,(e.stack+"").split(`
4
+ `),"")}catch(i){}return{pluginName:d,text:l,location:u,notes:s?[s]:[],detail:r?r.store(e):-1}}function Ge(e,t,r){let s=" at ";if(e.readFileSync&&!t[0].startsWith(s)&&t[1].startsWith(s))for(let d=1;d<t.length;d++){let l=t[d];if(!!l.startsWith(s))for(l=l.slice(s.length);;){let u=/^(?:new |async )?\S+ \((.*)\)$/.exec(l);if(u){l=u[1];continue}if(u=/^eval at \S+ \((.*)\)(?:, \S+:\d+:\d+)?$/.exec(l),u){l=u[1];continue}if(u=/^(\S+):(\d+):(\d+)$/.exec(l),u){let i;try{i=e.readFileSync(u[1],"utf8")}catch(A){break}let y=i.split(/\r\n|\r|\n|\u2028|\u2029/)[+u[2]-1]||"",O=+u[3]-1,x=y.slice(O,O+r.length)===r?r.length:0;return{file:u[1],namespace:"file",line:+u[2],column:oe(y.slice(0,O)).length,length:oe(y.slice(O,O+x)).length,lineText:y+`
5
+ `+t.slice(1).join(`
6
+ `),suggestion:""}}break}}return null}function he(e,t,r){let s=5,d=t.length<1?"":` with ${t.length} error${t.length<2?"":"s"}:`+t.slice(0,s+1).map((u,i)=>{if(i===s)return`
7
+ ...`;if(!u.location)return`
8
+ error: ${u.text}`;let{file:y,line:O,column:x}=u.location,A=u.pluginName?`[plugin: ${u.pluginName}] `:"";return`
9
+ ${y}:${O}:${x}: error: ${A}${u.text}`}).join(""),l=new Error(`${e}${d}`);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 Qe(e,t){if(e==null)return null;let r={},s=n(e,r,"file",h),d=n(e,r,"namespace",h),l=n(e,r,"line",ge),u=n(e,r,"column",ge),i=n(e,r,"length",ge),y=n(e,r,"lineText",h),O=n(e,r,"suggestion",h);return z(e,r,t),{file:s||"",namespace:d||"",line:l||0,column:u||0,length:i||0,lineText:y||"",suggestion:O||""}}function fe(e,t,r,s){let d=[],l=0;for(let u of e){let i={},y=n(u,i,"pluginName",h),O=n(u,i,"text",h),x=n(u,i,"location",Ve),A=n(u,i,"notes",q),K=n(u,i,"detail",Ne),$=`in element ${l} of "${t}"`;z(u,i,$);let L=[];if(A)for(let ee of A){let Q={},re=n(ee,Q,"text",h),te=n(ee,Q,"location",Ve);z(ee,Q,$),L.push({text:re||"",location:Qe(te,$)})}d.push({pluginName:y||s,text:O||"",location:Qe(x,$),notes:L,detail:r?r.store(K):-1}),l++}return d}function xe(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 pt({path:e,contents:t}){let r=null;return{path:e,contents:t,get text(){return r===null&&(r=ce(t)),r}}}var gt="0.12.25",mt=e=>Le().build(e),yt=()=>{throw new Error('The "serve" API only works in node')},ht=(e,t)=>Le().transform(e,t),bt=(e,t)=>Le().formatMessages(e,t),wt=()=>{throw new Error('The "buildSync" API only works in node')},vt=()=>{throw new Error('The "transformSync" API only works in node')},Rt=()=>{throw new Error('The "formatMessagesSync" API only works in node')},we,Me,Le=()=>{if(Me)return Me;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')},Ot=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=St(t,r),we.catch(()=>{we=void 0}),we},St=(e,t)=>se(void 0,null,function*(){let r=yield fetch(e);if(!r.ok)throw new Error(`Failed to download ${JSON.stringify(e)}`);let s=yield 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.\nvar y=(l,g,d)=>new Promise((r,i)=>{var s=m=>{try{o(d.next(m))}catch(u){i(u)}},n=m=>{try{o(d.throw(m))}catch(u){i(u)}},o=m=>m.done?r(m.value):Promise.resolve(m.value).then(s,n);o((d=d.apply(l,g)).next())});(()=>{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(i,s,n,o,m,u){if(n===0&&o===s.length&&m===null){if(i===process.stdout.fd){try{process.stdout.write(s,h=>h?u(h,0,null):u(null,o,s))}catch(h){u(h,0,null)}return}if(i===process.stderr.fd){try{process.stderr.write(s,h=>h?u(h,0,null):u(null,o,s))}catch(h){u(h,0,null)}return}}r.write(i,s,n,o,m,u)}}))}const l=()=>{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(i,s){r+=d.decode(s);const n=r.lastIndexOf(`\n`);return n!=-1&&(console.log(r.substr(0,n)),r=r.substr(n+1)),s.length},write(i,s,n,o,m,u){if(n!==0||o!==s.length||m!==null){u(l());return}const h=this.writeSync(i,s);u(null,h)},chmod(i,s,n){n(l())},chown(i,s,n,o){o(l())},close(i,s){s(l())},fchmod(i,s,n){n(l())},fchown(i,s,n,o){o(l())},fstat(i,s){s(l())},fsync(i,s){s(null)},ftruncate(i,s,n){n(l())},lchown(i,s,n,o){o(l())},link(i,s,n){n(l())},lstat(i,s){s(l())},mkdir(i,s,n){n(l())},open(i,s,n,o){o(l())},read(i,s,n,o,m,u){u(l())},readdir(i,s){s(l())},readlink(i,s){s(l())},rename(i,s,n){n(l())},rmdir(i,s){s(l())},stat(i,s){s(l())},symlink(i,s,n){n(l())},truncate(i,s,n){n(l())},unlink(i,s){s(l())},utimes(i,s,n,o){o(l())}}}if(global.process||(global.process={getuid(){return-1},getgid(){return-1},geteuid(){return-1},getegid(){return-1},getgroups(){throw l()},pid:-1,ppid:-1,umask(){throw l()},cwd(){throw l()},chdir(){throw l()}}),!global.crypto&&global.require){const r=require("crypto");global.crypto={getRandomValues(i){r.randomFillSync(i)}}}if(!global.crypto)throw new Error("global.crypto is not available, polyfill required (getRandomValues only)");if(global.performance||(global.performance={now(){const[r,i]=process.hrtime();return r*1e3+i/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 g=new TextEncoder("utf-8"),d=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)},i=e=>{const t=this.mem.getUint32(e+0,!0),a=this.mem.getInt32(e+4,!0);return t+a*4294967296},s=e=>{const t=this.mem.getFloat64(e,!0);if(t===0)return;if(!isNaN(t))return t;const a=this.mem.getUint32(e,!0);return this._values[a]},n=(e,t)=>{const a=2146959360;if(typeof t=="number"&&t!==0){if(isNaN(t)){this.mem.setUint32(e+4,a,!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 f=0;switch(typeof t){case"object":t!==null&&(f=1);break;case"string":f=2;break;case"symbol":f=3;break;case"function":f=4;break}this.mem.setUint32(e+4,a|f,!0),this.mem.setUint32(e,c,!0)},o=e=>{const t=i(e+0),a=i(e+8);return new Uint8Array(this._inst.exports.mem.buffer,t,a)},m=e=>{const t=i(e+0),a=i(e+8),c=new Array(a);for(let f=0;f<a;f++)c[f]=s(t+f*8);return c},u=e=>{const t=i(e+0),a=i(e+8);return d.decode(new DataView(this._inst.exports.mem.buffer,t,a))},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=i(e+8),a=i(e+16),c=this.mem.getInt32(e+24,!0);fs.writeSync(t,new Uint8Array(this._inst.exports.mem.buffer,a,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()},i(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(o(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 a=this._values[t];this._values[t]=null,this._ids.delete(a),this._idPool.push(t)}},"syscall/js.stringVal":e=>{e>>>=0,n(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,n(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,n(e+24,Reflect.get(s(e+8),i(e+16)))},"syscall/js.valueSetIndex":e=>{e>>>=0,Reflect.set(s(e+8),i(e+16),s(e+24))},"syscall/js.valueCall":e=>{e>>>=0;try{const t=s(e+8),a=Reflect.get(t,u(e+16)),c=m(e+32),f=Reflect.apply(a,t,c);e=this._inst.exports.getsp()>>>0,n(e+56,f),this.mem.setUint8(e+64,1)}catch(t){e=this._inst.exports.getsp()>>>0,n(e+56,t),this.mem.setUint8(e+64,0)}},"syscall/js.valueInvoke":e=>{e>>>=0;try{const t=s(e+8),a=m(e+16),c=Reflect.apply(t,void 0,a);e=this._inst.exports.getsp()>>>0,n(e+40,c),this.mem.setUint8(e+48,1)}catch(t){e=this._inst.exports.getsp()>>>0,n(e+40,t),this.mem.setUint8(e+48,0)}},"syscall/js.valueNew":e=>{e>>>=0;try{const t=s(e+8),a=m(e+16),c=Reflect.construct(t,a);e=this._inst.exports.getsp()>>>0,n(e+40,c),this.mem.setUint8(e+48,1)}catch(t){e=this._inst.exports.getsp()>>>0,n(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=g.encode(String(s(e+8)));n(e+16,t),r(e+24,t.length)},"syscall/js.valueLoadString":e=>{e>>>=0;const t=s(e+8);o(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=o(e+8),a=s(e+32);if(!(a instanceof Uint8Array||a instanceof Uint8ClampedArray)){this.mem.setUint8(e+48,0);return}const c=a.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),a=o(e+16);if(!(t instanceof Uint8Array||t instanceof Uint8ClampedArray)){this.mem.setUint8(e+48,0);return}const c=a.subarray(0,t.length);t.set(c),r(e+40,c.length),this.mem.setUint8(e+48,1)},debug:e=>{console.log(e)}}}}run(r){return y(this,null,function*(){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 i=4096;const s=h=>{const e=i,t=g.encode(h+"\\0");return new Uint8Array(this.mem.buffer,i,t.length).set(t),i+=t.length,i%8!=0&&(i+=8-i%8),e},n=this.argv.length,o=[];this.argv.forEach(h=>{o.push(s(h))}),o.push(0),Object.keys(this.env).sort().forEach(h=>{o.push(s(`${h}=${this.env[h]}`))}),o.push(0);const u=i;o.forEach(h=>{this.mem.setUint32(i,h,!0),this.mem.setUint32(i+4,0,!0),i+=8}),this._inst.exports.run(n,u),this.exited&&this._resolveExitPromise(),yield 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 i=this;return function(){const s={id:r,this:this,args:arguments};return i._pendingEvent=s,i._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(i=>(process.on("exit",s=>{s===0&&!r.exited&&(r._pendingEvent={id:0},r._resume())}),r.run(i.instance))).catch(i=>{console.error(i),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.12.25"],WebAssembly.instantiate(c,o.importObject).then(({instance:e})=>o.run(e))};}',l;if(t){let y=new Blob([d],{type:"text/javascript"});l=new Worker(URL.createObjectURL(y))}else{let O=new Function("postMessage",d+"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:y})=>u(y);let{readFromStdout:u,service:i}=Ye({writeToStdin(y){l.postMessage(y)},isSync:!1,isBrowser:!0});Me={build:y=>new Promise((O,x)=>i.buildOrServe({callName:"build",refs:null,serveOptions:null,options:y,isTTY:!1,defaultWD:"/",callback:(A,K)=>A?x(A):O(K)})),transform:(y,O)=>new Promise((x,A)=>i.transform({callName:"transform",refs:null,input:y,options:O||{},isTTY:!1,fs:{readFile(K,$){$(new Error("Internal error"),null)},writeFile(K,$){$(null)}},callback:(K,$)=>K?A(K):x($)})),formatMessages:(y,O)=>new Promise((x,A)=>i.formatMessages({callName:"formatMessages",refs:null,messages:y,options:O,callback:(K,$)=>K?A(K):x($)}))}});
10
+ })(typeof exports==="object"?exports:(typeof self!=="undefined"?self:this).esbuild={});
@@ -0,0 +1,397 @@
1
+ export type Platform = 'browser' | 'node' | 'neutral';
2
+ export type Format = 'iife' | 'cjs' | 'esm';
3
+ export type Loader = 'js' | 'jsx' | 'ts' | 'tsx' | 'css' | 'json' | 'text' | 'base64' | 'file' | 'dataurl' | 'binary' | 'default';
4
+ export type LogLevel = 'verbose' | 'debug' | 'info' | 'warning' | 'error' | 'silent';
5
+ export type Charset = 'ascii' | 'utf8';
6
+ export type TreeShaking = true | 'ignore-annotations';
7
+
8
+ interface CommonOptions {
9
+ sourcemap?: boolean | 'inline' | 'external' | 'both';
10
+ legalComments?: 'none' | 'inline' | 'eof' | 'linked' | 'external';
11
+ sourceRoot?: string;
12
+ sourcesContent?: boolean;
13
+
14
+ format?: Format;
15
+ globalName?: string;
16
+ target?: string | string[];
17
+
18
+ minify?: boolean;
19
+ minifyWhitespace?: boolean;
20
+ minifyIdentifiers?: boolean;
21
+ minifySyntax?: boolean;
22
+ charset?: Charset;
23
+ treeShaking?: TreeShaking;
24
+
25
+ jsx?: 'transform' | 'preserve';
26
+ jsxFactory?: string;
27
+ jsxFragment?: string;
28
+
29
+ define?: { [key: string]: string };
30
+ pure?: string[];
31
+ keepNames?: boolean;
32
+
33
+ color?: boolean;
34
+ logLevel?: LogLevel;
35
+ logLimit?: number;
36
+ }
37
+
38
+ export interface BuildOptions extends CommonOptions {
39
+ bundle?: boolean;
40
+ splitting?: boolean;
41
+ preserveSymlinks?: boolean;
42
+ outfile?: string;
43
+ metafile?: boolean;
44
+ outdir?: string;
45
+ outbase?: string;
46
+ platform?: Platform;
47
+ external?: string[];
48
+ loader?: { [ext: string]: Loader };
49
+ resolveExtensions?: string[];
50
+ mainFields?: string[];
51
+ conditions?: string[];
52
+ write?: boolean;
53
+ allowOverwrite?: boolean;
54
+ tsconfig?: string;
55
+ outExtension?: { [ext: string]: string };
56
+ publicPath?: string;
57
+ entryNames?: string;
58
+ chunkNames?: string;
59
+ assetNames?: string;
60
+ inject?: string[];
61
+ banner?: { [type: string]: string };
62
+ footer?: { [type: string]: string };
63
+ incremental?: boolean;
64
+ entryPoints?: string[] | Record<string, string>;
65
+ stdin?: StdinOptions;
66
+ plugins?: Plugin[];
67
+ absWorkingDir?: string;
68
+ nodePaths?: string[]; // The "NODE_PATH" variable from Node.js
69
+ watch?: boolean | WatchMode;
70
+ }
71
+
72
+ export interface WatchMode {
73
+ onRebuild?: (error: BuildFailure | null, result: BuildResult | null) => void;
74
+ }
75
+
76
+ export interface StdinOptions {
77
+ contents: string;
78
+ resolveDir?: string;
79
+ sourcefile?: string;
80
+ loader?: Loader;
81
+ }
82
+
83
+ export interface Message {
84
+ pluginName: string;
85
+ text: string;
86
+ location: Location | null;
87
+ notes: Note[];
88
+
89
+ // Optional user-specified data that is passed through unmodified. You can
90
+ // use this to stash the original error, for example.
91
+ detail: any;
92
+ }
93
+
94
+ export interface Note {
95
+ text: string;
96
+ location: Location | null;
97
+ }
98
+
99
+ export interface Location {
100
+ file: string;
101
+ namespace: string;
102
+ line: number; // 1-based
103
+ column: number; // 0-based, in bytes
104
+ length: number; // in bytes
105
+ lineText: string;
106
+ suggestion: string;
107
+ }
108
+
109
+ export interface OutputFile {
110
+ path: string;
111
+ contents: Uint8Array; // "text" as bytes
112
+ text: string; // "contents" as text
113
+ }
114
+
115
+ export interface BuildInvalidate {
116
+ (): Promise<BuildIncremental>;
117
+ dispose(): void;
118
+ }
119
+
120
+ export interface BuildIncremental extends BuildResult {
121
+ rebuild: BuildInvalidate;
122
+ }
123
+
124
+ export interface BuildResult {
125
+ errors: Message[];
126
+ warnings: Message[];
127
+ outputFiles?: OutputFile[]; // Only when "write: false"
128
+ rebuild?: BuildInvalidate; // Only when "incremental: true"
129
+ stop?: () => void; // Only when "watch: true"
130
+ metafile?: Metafile; // Only when "metafile: true"
131
+ }
132
+
133
+ export interface BuildFailure extends Error {
134
+ errors: Message[];
135
+ warnings: Message[];
136
+ }
137
+
138
+ export interface ServeOptions {
139
+ port?: number;
140
+ host?: string;
141
+ servedir?: string;
142
+ onRequest?: (args: ServeOnRequestArgs) => void;
143
+ }
144
+
145
+ export interface ServeOnRequestArgs {
146
+ remoteAddress: string;
147
+ method: string;
148
+ path: string;
149
+ status: number;
150
+ timeInMS: number; // The time to generate the response, not to send it
151
+ }
152
+
153
+ export interface ServeResult {
154
+ port: number;
155
+ host: string;
156
+ wait: Promise<void>;
157
+ stop: () => void;
158
+ }
159
+
160
+ export interface TransformOptions extends CommonOptions {
161
+ tsconfigRaw?: string | {
162
+ compilerOptions?: {
163
+ jsxFactory?: string,
164
+ jsxFragmentFactory?: string,
165
+ useDefineForClassFields?: boolean,
166
+ importsNotUsedAsValues?: 'remove' | 'preserve' | 'error',
167
+ },
168
+ };
169
+
170
+ sourcefile?: string;
171
+ loader?: Loader;
172
+ banner?: string;
173
+ footer?: string;
174
+ }
175
+
176
+ export interface TransformResult {
177
+ code: string;
178
+ map: string;
179
+ warnings: Message[];
180
+ }
181
+
182
+ export interface TransformFailure extends Error {
183
+ errors: Message[];
184
+ warnings: Message[];
185
+ }
186
+
187
+ export interface Plugin {
188
+ name: string;
189
+ setup: (build: PluginBuild) => (void | Promise<void>);
190
+ }
191
+
192
+ export interface PluginBuild {
193
+ initialOptions: BuildOptions;
194
+ onStart(callback: () =>
195
+ (OnStartResult | null | void | Promise<OnStartResult | null | void>)): void;
196
+ onEnd(callback: (result: BuildResult) =>
197
+ (void | Promise<void>)): void;
198
+ onResolve(options: OnResolveOptions, callback: (args: OnResolveArgs) =>
199
+ (OnResolveResult | null | undefined | Promise<OnResolveResult | null | undefined>)): void;
200
+ onLoad(options: OnLoadOptions, callback: (args: OnLoadArgs) =>
201
+ (OnLoadResult | null | undefined | Promise<OnLoadResult | null | undefined>)): void;
202
+ }
203
+
204
+ export interface OnStartResult {
205
+ errors?: PartialMessage[];
206
+ warnings?: PartialMessage[];
207
+ }
208
+
209
+ export interface OnResolveOptions {
210
+ filter: RegExp;
211
+ namespace?: string;
212
+ }
213
+
214
+ export interface OnResolveArgs {
215
+ path: string;
216
+ importer: string;
217
+ namespace: string;
218
+ resolveDir: string;
219
+ kind: ImportKind;
220
+ pluginData: any;
221
+ }
222
+
223
+ export type ImportKind =
224
+ | 'entry-point'
225
+
226
+ // JS
227
+ | 'import-statement'
228
+ | 'require-call'
229
+ | 'dynamic-import'
230
+ | 'require-resolve'
231
+
232
+ // CSS
233
+ | 'import-rule'
234
+ | 'url-token'
235
+
236
+ export interface OnResolveResult {
237
+ pluginName?: string;
238
+
239
+ errors?: PartialMessage[];
240
+ warnings?: PartialMessage[];
241
+
242
+ path?: string;
243
+ external?: boolean;
244
+ sideEffects?: boolean;
245
+ namespace?: string;
246
+ pluginData?: any;
247
+
248
+ watchFiles?: string[];
249
+ watchDirs?: string[];
250
+ }
251
+
252
+ export interface OnLoadOptions {
253
+ filter: RegExp;
254
+ namespace?: string;
255
+ }
256
+
257
+ export interface OnLoadArgs {
258
+ path: string;
259
+ namespace: string;
260
+ pluginData: any;
261
+ }
262
+
263
+ export interface OnLoadResult {
264
+ pluginName?: string;
265
+
266
+ errors?: PartialMessage[];
267
+ warnings?: PartialMessage[];
268
+
269
+ contents?: string | Uint8Array;
270
+ resolveDir?: string;
271
+ loader?: Loader;
272
+ pluginData?: any;
273
+
274
+ watchFiles?: string[];
275
+ watchDirs?: string[];
276
+ }
277
+
278
+ export interface PartialMessage {
279
+ pluginName?: string;
280
+ text?: string;
281
+ location?: Partial<Location> | null;
282
+ notes?: PartialNote[];
283
+ detail?: any;
284
+ }
285
+
286
+ export interface PartialNote {
287
+ text?: string;
288
+ location?: Partial<Location> | null;
289
+ }
290
+
291
+ export interface Metafile {
292
+ inputs: {
293
+ [path: string]: {
294
+ bytes: number
295
+ imports: {
296
+ path: string
297
+ kind: ImportKind
298
+ }[]
299
+ }
300
+ }
301
+ outputs: {
302
+ [path: string]: {
303
+ bytes: number
304
+ inputs: {
305
+ [path: string]: {
306
+ bytesInOutput: number
307
+ }
308
+ }
309
+ imports: {
310
+ path: string
311
+ kind: ImportKind
312
+ }[]
313
+ exports: string[]
314
+ entryPoint?: string
315
+ }
316
+ }
317
+ }
318
+
319
+ export interface FormatMessagesOptions {
320
+ kind: 'error' | 'warning';
321
+ color?: boolean;
322
+ terminalWidth?: number;
323
+ }
324
+
325
+ // This function invokes the "esbuild" command-line tool for you. It returns a
326
+ // promise that either resolves with a "BuildResult" object or rejects with a
327
+ // "BuildFailure" object.
328
+ //
329
+ // Works in node: yes
330
+ // Works in browser: yes
331
+ export declare function build(options: BuildOptions & { write: false }): Promise<BuildResult & { outputFiles: OutputFile[] }>;
332
+ export declare function build(options: BuildOptions & { incremental: true }): Promise<BuildIncremental>;
333
+ export declare function build(options: BuildOptions): Promise<BuildResult>;
334
+
335
+ // This function is similar to "build" but it serves the resulting files over
336
+ // HTTP on a localhost address with the specified port.
337
+ //
338
+ // Works in node: yes
339
+ // Works in browser: no
340
+ export declare function serve(serveOptions: ServeOptions, buildOptions: BuildOptions): Promise<ServeResult>;
341
+
342
+ // This function transforms a single JavaScript file. It can be used to minify
343
+ // JavaScript, convert TypeScript/JSX to JavaScript, or convert newer JavaScript
344
+ // to older JavaScript. It returns a promise that is either resolved with a
345
+ // "TransformResult" object or rejected with a "TransformFailure" object.
346
+ //
347
+ // Works in node: yes
348
+ // Works in browser: yes
349
+ export declare function transform(input: string, options?: TransformOptions): Promise<TransformResult>;
350
+
351
+ // Converts log messages to formatted message strings suitable for printing in
352
+ // the terminal. This allows you to reuse the built-in behavior of esbuild's
353
+ // log message formatter. This is a batch-oriented API for efficiency.
354
+ //
355
+ // Works in node: yes
356
+ // Works in browser: yes
357
+ export declare function formatMessages(messages: PartialMessage[], options: FormatMessagesOptions): Promise<string[]>;
358
+
359
+ // A synchronous version of "build".
360
+ //
361
+ // Works in node: yes
362
+ // Works in browser: no
363
+ export declare function buildSync(options: BuildOptions & { write: false }): BuildResult & { outputFiles: OutputFile[] };
364
+ export declare function buildSync(options: BuildOptions): BuildResult;
365
+
366
+ // A synchronous version of "transform".
367
+ //
368
+ // Works in node: yes
369
+ // Works in browser: no
370
+ export declare function transformSync(input: string, options?: TransformOptions): TransformResult;
371
+
372
+ // A synchronous version of "formatMessages".
373
+ //
374
+ // Works in node: yes
375
+ // Works in browser: no
376
+ export declare function formatMessagesSync(messages: PartialMessage[], options: FormatMessagesOptions): string[];
377
+
378
+ // This configures the browser-based version of esbuild. It is necessary to
379
+ // call this first and wait for the returned promise to be resolved before
380
+ // making other API calls when using esbuild in the browser.
381
+ //
382
+ // Works in node: yes
383
+ // Works in browser: yes ("options" is required)
384
+ export declare function initialize(options: InitializeOptions): Promise<void>;
385
+
386
+ export interface InitializeOptions {
387
+ // The URL of the "esbuild.wasm" file. This must be provided when running
388
+ // esbuild in the browser.
389
+ wasmURL?: string
390
+
391
+ // By default esbuild runs the WebAssembly-based browser API in a web worker
392
+ // to avoid blocking the UI thread. This can be disabled by setting "worker"
393
+ // to false.
394
+ worker?: boolean
395
+ }
396
+
397
+ export let version: string;
@@ -0,0 +1,1948 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
21
+ var __export = (target, all) => {
22
+ __markAsModule(target);
23
+ for (var name in all)
24
+ __defProp(target, name, { get: all[name], enumerable: true });
25
+ };
26
+
27
+ // lib/npm/node.ts
28
+ __export(exports, {
29
+ build: () => build,
30
+ buildSync: () => buildSync,
31
+ formatMessages: () => formatMessages,
32
+ formatMessagesSync: () => formatMessagesSync,
33
+ initialize: () => initialize,
34
+ serve: () => serve,
35
+ transform: () => transform,
36
+ transformSync: () => transformSync,
37
+ version: () => version
38
+ });
39
+
40
+ // lib/shared/stdio_protocol.ts
41
+ function encodePacket(packet) {
42
+ let visit = (value) => {
43
+ if (value === null) {
44
+ bb.write8(0);
45
+ } else if (typeof value === "boolean") {
46
+ bb.write8(1);
47
+ bb.write8(+value);
48
+ } else if (typeof value === "number") {
49
+ bb.write8(2);
50
+ bb.write32(value | 0);
51
+ } else if (typeof value === "string") {
52
+ bb.write8(3);
53
+ bb.write(encodeUTF8(value));
54
+ } else if (value instanceof Uint8Array) {
55
+ bb.write8(4);
56
+ bb.write(value);
57
+ } else if (value instanceof Array) {
58
+ bb.write8(5);
59
+ bb.write32(value.length);
60
+ for (let item of value) {
61
+ visit(item);
62
+ }
63
+ } else {
64
+ let keys = Object.keys(value);
65
+ bb.write8(6);
66
+ bb.write32(keys.length);
67
+ for (let key of keys) {
68
+ bb.write(encodeUTF8(key));
69
+ visit(value[key]);
70
+ }
71
+ }
72
+ };
73
+ let bb = new ByteBuffer();
74
+ bb.write32(0);
75
+ bb.write32(packet.id << 1 | +!packet.isRequest);
76
+ visit(packet.value);
77
+ writeUInt32LE(bb.buf, bb.len - 4, 0);
78
+ return bb.buf.subarray(0, bb.len);
79
+ }
80
+ function decodePacket(bytes) {
81
+ let visit = () => {
82
+ switch (bb.read8()) {
83
+ case 0:
84
+ return null;
85
+ case 1:
86
+ return !!bb.read8();
87
+ case 2:
88
+ return bb.read32();
89
+ case 3:
90
+ return decodeUTF8(bb.read());
91
+ case 4:
92
+ return bb.read();
93
+ case 5: {
94
+ let count = bb.read32();
95
+ let value2 = [];
96
+ for (let i = 0; i < count; i++) {
97
+ value2.push(visit());
98
+ }
99
+ return value2;
100
+ }
101
+ case 6: {
102
+ let count = bb.read32();
103
+ let value2 = {};
104
+ for (let i = 0; i < count; i++) {
105
+ value2[decodeUTF8(bb.read())] = visit();
106
+ }
107
+ return value2;
108
+ }
109
+ default:
110
+ throw new Error("Invalid packet");
111
+ }
112
+ };
113
+ let bb = new ByteBuffer(bytes);
114
+ let id = bb.read32();
115
+ let isRequest = (id & 1) === 0;
116
+ id >>>= 1;
117
+ let value = visit();
118
+ if (bb.ptr !== bytes.length) {
119
+ throw new Error("Invalid packet");
120
+ }
121
+ return { id, isRequest, value };
122
+ }
123
+ var ByteBuffer = class {
124
+ constructor(buf = new Uint8Array(1024)) {
125
+ this.buf = buf;
126
+ this.len = 0;
127
+ this.ptr = 0;
128
+ }
129
+ _write(delta) {
130
+ if (this.len + delta > this.buf.length) {
131
+ let clone = new Uint8Array((this.len + delta) * 2);
132
+ clone.set(this.buf);
133
+ this.buf = clone;
134
+ }
135
+ this.len += delta;
136
+ return this.len - delta;
137
+ }
138
+ write8(value) {
139
+ let offset = this._write(1);
140
+ this.buf[offset] = value;
141
+ }
142
+ write32(value) {
143
+ let offset = this._write(4);
144
+ writeUInt32LE(this.buf, value, offset);
145
+ }
146
+ write(bytes) {
147
+ let offset = this._write(4 + bytes.length);
148
+ writeUInt32LE(this.buf, bytes.length, offset);
149
+ this.buf.set(bytes, offset + 4);
150
+ }
151
+ _read(delta) {
152
+ if (this.ptr + delta > this.buf.length) {
153
+ throw new Error("Invalid packet");
154
+ }
155
+ this.ptr += delta;
156
+ return this.ptr - delta;
157
+ }
158
+ read8() {
159
+ return this.buf[this._read(1)];
160
+ }
161
+ read32() {
162
+ return readUInt32LE(this.buf, this._read(4));
163
+ }
164
+ read() {
165
+ let length = this.read32();
166
+ let bytes = new Uint8Array(length);
167
+ let ptr = this._read(bytes.length);
168
+ bytes.set(this.buf.subarray(ptr, ptr + length));
169
+ return bytes;
170
+ }
171
+ };
172
+ var encodeUTF8;
173
+ var decodeUTF8;
174
+ if (typeof TextEncoder !== "undefined" && typeof TextDecoder !== "undefined") {
175
+ let encoder = new TextEncoder();
176
+ let decoder = new TextDecoder();
177
+ encodeUTF8 = (text) => encoder.encode(text);
178
+ decodeUTF8 = (bytes) => decoder.decode(bytes);
179
+ } else if (typeof Buffer !== "undefined") {
180
+ encodeUTF8 = (text) => {
181
+ let buffer = Buffer.from(text);
182
+ if (!(buffer instanceof Uint8Array)) {
183
+ buffer = new Uint8Array(buffer);
184
+ }
185
+ return buffer;
186
+ };
187
+ decodeUTF8 = (bytes) => {
188
+ let { buffer, byteOffset, byteLength } = bytes;
189
+ return Buffer.from(buffer, byteOffset, byteLength).toString();
190
+ };
191
+ } else {
192
+ throw new Error("No UTF-8 codec found");
193
+ }
194
+ function readUInt32LE(buffer, offset) {
195
+ return buffer[offset++] | buffer[offset++] << 8 | buffer[offset++] << 16 | buffer[offset++] << 24;
196
+ }
197
+ function writeUInt32LE(buffer, value, offset) {
198
+ buffer[offset++] = value;
199
+ buffer[offset++] = value >> 8;
200
+ buffer[offset++] = value >> 16;
201
+ buffer[offset++] = value >> 24;
202
+ }
203
+
204
+ // lib/shared/common.ts
205
+ function validateTarget(target) {
206
+ target += "";
207
+ if (target.indexOf(",") >= 0)
208
+ throw new Error(`Invalid target: ${target}`);
209
+ return target;
210
+ }
211
+ var canBeAnything = () => null;
212
+ var mustBeBoolean = (value) => typeof value === "boolean" ? null : "a boolean";
213
+ var mustBeBooleanOrObject = (value) => typeof value === "boolean" || typeof value === "object" && !Array.isArray(value) ? null : "a boolean or an object";
214
+ var mustBeString = (value) => typeof value === "string" ? null : "a string";
215
+ var mustBeRegExp = (value) => value instanceof RegExp ? null : "a RegExp object";
216
+ var mustBeInteger = (value) => typeof value === "number" && value === (value | 0) ? null : "an integer";
217
+ var mustBeFunction = (value) => typeof value === "function" ? null : "a function";
218
+ var mustBeArray = (value) => Array.isArray(value) ? null : "an array";
219
+ var mustBeObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value) ? null : "an object";
220
+ var mustBeArrayOrRecord = (value) => typeof value === "object" && value !== null ? null : "an array or an object";
221
+ var mustBeObjectOrNull = (value) => typeof value === "object" && !Array.isArray(value) ? null : "an object or null";
222
+ var mustBeStringOrBoolean = (value) => typeof value === "string" || typeof value === "boolean" ? null : "a string or a boolean";
223
+ var mustBeStringOrObject = (value) => typeof value === "string" || typeof value === "object" && value !== null && !Array.isArray(value) ? null : "a string or an object";
224
+ var mustBeStringOrArray = (value) => typeof value === "string" || Array.isArray(value) ? null : "a string or an array";
225
+ var mustBeStringOrUint8Array = (value) => typeof value === "string" || value instanceof Uint8Array ? null : "a string or a Uint8Array";
226
+ function getFlag(object, keys, key, mustBeFn) {
227
+ let value = object[key];
228
+ keys[key + ""] = true;
229
+ if (value === void 0)
230
+ return void 0;
231
+ let mustBe = mustBeFn(value);
232
+ if (mustBe !== null)
233
+ throw new Error(`"${key}" must be ${mustBe}`);
234
+ return value;
235
+ }
236
+ function checkForInvalidFlags(object, keys, where) {
237
+ for (let key in object) {
238
+ if (!(key in keys)) {
239
+ throw new Error(`Invalid option ${where}: "${key}"`);
240
+ }
241
+ }
242
+ }
243
+ function validateInitializeOptions(options) {
244
+ let keys = Object.create(null);
245
+ let wasmURL = getFlag(options, keys, "wasmURL", mustBeString);
246
+ let worker = getFlag(options, keys, "worker", mustBeBoolean);
247
+ checkForInvalidFlags(options, keys, "in startService() call");
248
+ return {
249
+ wasmURL,
250
+ worker
251
+ };
252
+ }
253
+ function pushLogFlags(flags, options, keys, isTTY2, logLevelDefault) {
254
+ let color = getFlag(options, keys, "color", mustBeBoolean);
255
+ let logLevel = getFlag(options, keys, "logLevel", mustBeString);
256
+ let logLimit = getFlag(options, keys, "logLimit", mustBeInteger);
257
+ if (color !== void 0)
258
+ flags.push(`--color=${color}`);
259
+ else if (isTTY2)
260
+ flags.push(`--color=true`);
261
+ flags.push(`--log-level=${logLevel || logLevelDefault}`);
262
+ flags.push(`--log-limit=${logLimit || 0}`);
263
+ }
264
+ function pushCommonFlags(flags, options, keys) {
265
+ let legalComments = getFlag(options, keys, "legalComments", mustBeString);
266
+ let sourceRoot = getFlag(options, keys, "sourceRoot", mustBeString);
267
+ let sourcesContent = getFlag(options, keys, "sourcesContent", mustBeBoolean);
268
+ let target = getFlag(options, keys, "target", mustBeStringOrArray);
269
+ let format = getFlag(options, keys, "format", mustBeString);
270
+ let globalName = getFlag(options, keys, "globalName", mustBeString);
271
+ let minify = getFlag(options, keys, "minify", mustBeBoolean);
272
+ let minifySyntax = getFlag(options, keys, "minifySyntax", mustBeBoolean);
273
+ let minifyWhitespace = getFlag(options, keys, "minifyWhitespace", mustBeBoolean);
274
+ let minifyIdentifiers = getFlag(options, keys, "minifyIdentifiers", mustBeBoolean);
275
+ let charset = getFlag(options, keys, "charset", mustBeString);
276
+ let treeShaking = getFlag(options, keys, "treeShaking", mustBeStringOrBoolean);
277
+ let jsx = getFlag(options, keys, "jsx", mustBeString);
278
+ let jsxFactory = getFlag(options, keys, "jsxFactory", mustBeString);
279
+ let jsxFragment = getFlag(options, keys, "jsxFragment", mustBeString);
280
+ let define = getFlag(options, keys, "define", mustBeObject);
281
+ let pure = getFlag(options, keys, "pure", mustBeArray);
282
+ let keepNames = getFlag(options, keys, "keepNames", mustBeBoolean);
283
+ if (legalComments)
284
+ flags.push(`--legal-comments=${legalComments}`);
285
+ if (sourceRoot !== void 0)
286
+ flags.push(`--source-root=${sourceRoot}`);
287
+ if (sourcesContent !== void 0)
288
+ flags.push(`--sources-content=${sourcesContent}`);
289
+ if (target) {
290
+ if (Array.isArray(target))
291
+ flags.push(`--target=${Array.from(target).map(validateTarget).join(",")}`);
292
+ else
293
+ flags.push(`--target=${validateTarget(target)}`);
294
+ }
295
+ if (format)
296
+ flags.push(`--format=${format}`);
297
+ if (globalName)
298
+ flags.push(`--global-name=${globalName}`);
299
+ if (minify)
300
+ flags.push("--minify");
301
+ if (minifySyntax)
302
+ flags.push("--minify-syntax");
303
+ if (minifyWhitespace)
304
+ flags.push("--minify-whitespace");
305
+ if (minifyIdentifiers)
306
+ flags.push("--minify-identifiers");
307
+ if (charset)
308
+ flags.push(`--charset=${charset}`);
309
+ if (treeShaking !== void 0 && treeShaking !== true)
310
+ flags.push(`--tree-shaking=${treeShaking}`);
311
+ if (jsx)
312
+ flags.push(`--jsx=${jsx}`);
313
+ if (jsxFactory)
314
+ flags.push(`--jsx-factory=${jsxFactory}`);
315
+ if (jsxFragment)
316
+ flags.push(`--jsx-fragment=${jsxFragment}`);
317
+ if (define) {
318
+ for (let key in define) {
319
+ if (key.indexOf("=") >= 0)
320
+ throw new Error(`Invalid define: ${key}`);
321
+ flags.push(`--define:${key}=${define[key]}`);
322
+ }
323
+ }
324
+ if (pure)
325
+ for (let fn of pure)
326
+ flags.push(`--pure:${fn}`);
327
+ if (keepNames)
328
+ flags.push(`--keep-names`);
329
+ }
330
+ function flagsForBuildOptions(callName, options, isTTY2, logLevelDefault, writeDefault) {
331
+ var _a2;
332
+ let flags = [];
333
+ let entries = [];
334
+ let keys = Object.create(null);
335
+ let stdinContents = null;
336
+ let stdinResolveDir = null;
337
+ let watchMode = null;
338
+ pushLogFlags(flags, options, keys, isTTY2, logLevelDefault);
339
+ pushCommonFlags(flags, options, keys);
340
+ let sourcemap = getFlag(options, keys, "sourcemap", mustBeStringOrBoolean);
341
+ let bundle = getFlag(options, keys, "bundle", mustBeBoolean);
342
+ let watch = getFlag(options, keys, "watch", mustBeBooleanOrObject);
343
+ let splitting = getFlag(options, keys, "splitting", mustBeBoolean);
344
+ let preserveSymlinks = getFlag(options, keys, "preserveSymlinks", mustBeBoolean);
345
+ let metafile = getFlag(options, keys, "metafile", mustBeBoolean);
346
+ let outfile = getFlag(options, keys, "outfile", mustBeString);
347
+ let outdir = getFlag(options, keys, "outdir", mustBeString);
348
+ let outbase = getFlag(options, keys, "outbase", mustBeString);
349
+ let platform = getFlag(options, keys, "platform", mustBeString);
350
+ let tsconfig = getFlag(options, keys, "tsconfig", mustBeString);
351
+ let resolveExtensions = getFlag(options, keys, "resolveExtensions", mustBeArray);
352
+ let nodePathsInput = getFlag(options, keys, "nodePaths", mustBeArray);
353
+ let mainFields = getFlag(options, keys, "mainFields", mustBeArray);
354
+ let conditions = getFlag(options, keys, "conditions", mustBeArray);
355
+ let external = getFlag(options, keys, "external", mustBeArray);
356
+ let loader = getFlag(options, keys, "loader", mustBeObject);
357
+ let outExtension = getFlag(options, keys, "outExtension", mustBeObject);
358
+ let publicPath = getFlag(options, keys, "publicPath", mustBeString);
359
+ let entryNames = getFlag(options, keys, "entryNames", mustBeString);
360
+ let chunkNames = getFlag(options, keys, "chunkNames", mustBeString);
361
+ let assetNames = getFlag(options, keys, "assetNames", mustBeString);
362
+ let inject = getFlag(options, keys, "inject", mustBeArray);
363
+ let banner = getFlag(options, keys, "banner", mustBeObject);
364
+ let footer = getFlag(options, keys, "footer", mustBeObject);
365
+ let entryPoints = getFlag(options, keys, "entryPoints", mustBeArrayOrRecord);
366
+ let absWorkingDir = getFlag(options, keys, "absWorkingDir", mustBeString);
367
+ let stdin = getFlag(options, keys, "stdin", mustBeObject);
368
+ let write = (_a2 = getFlag(options, keys, "write", mustBeBoolean)) != null ? _a2 : writeDefault;
369
+ let allowOverwrite = getFlag(options, keys, "allowOverwrite", mustBeBoolean);
370
+ let incremental = getFlag(options, keys, "incremental", mustBeBoolean) === true;
371
+ keys.plugins = true;
372
+ checkForInvalidFlags(options, keys, `in ${callName}() call`);
373
+ if (sourcemap)
374
+ flags.push(`--sourcemap${sourcemap === true ? "" : `=${sourcemap}`}`);
375
+ if (bundle)
376
+ flags.push("--bundle");
377
+ if (allowOverwrite)
378
+ flags.push("--allow-overwrite");
379
+ if (watch) {
380
+ flags.push("--watch");
381
+ if (typeof watch === "boolean") {
382
+ watchMode = {};
383
+ } else {
384
+ let watchKeys = Object.create(null);
385
+ let onRebuild = getFlag(watch, watchKeys, "onRebuild", mustBeFunction);
386
+ checkForInvalidFlags(watch, watchKeys, `on "watch" in ${callName}() call`);
387
+ watchMode = { onRebuild };
388
+ }
389
+ }
390
+ if (splitting)
391
+ flags.push("--splitting");
392
+ if (preserveSymlinks)
393
+ flags.push("--preserve-symlinks");
394
+ if (metafile)
395
+ flags.push(`--metafile`);
396
+ if (outfile)
397
+ flags.push(`--outfile=${outfile}`);
398
+ if (outdir)
399
+ flags.push(`--outdir=${outdir}`);
400
+ if (outbase)
401
+ flags.push(`--outbase=${outbase}`);
402
+ if (platform)
403
+ flags.push(`--platform=${platform}`);
404
+ if (tsconfig)
405
+ flags.push(`--tsconfig=${tsconfig}`);
406
+ if (resolveExtensions) {
407
+ let values = [];
408
+ for (let value of resolveExtensions) {
409
+ value += "";
410
+ if (value.indexOf(",") >= 0)
411
+ throw new Error(`Invalid resolve extension: ${value}`);
412
+ values.push(value);
413
+ }
414
+ flags.push(`--resolve-extensions=${values.join(",")}`);
415
+ }
416
+ if (publicPath)
417
+ flags.push(`--public-path=${publicPath}`);
418
+ if (entryNames)
419
+ flags.push(`--entry-names=${entryNames}`);
420
+ if (chunkNames)
421
+ flags.push(`--chunk-names=${chunkNames}`);
422
+ if (assetNames)
423
+ flags.push(`--asset-names=${assetNames}`);
424
+ if (mainFields) {
425
+ let values = [];
426
+ for (let value of mainFields) {
427
+ value += "";
428
+ if (value.indexOf(",") >= 0)
429
+ throw new Error(`Invalid main field: ${value}`);
430
+ values.push(value);
431
+ }
432
+ flags.push(`--main-fields=${values.join(",")}`);
433
+ }
434
+ if (conditions) {
435
+ let values = [];
436
+ for (let value of conditions) {
437
+ value += "";
438
+ if (value.indexOf(",") >= 0)
439
+ throw new Error(`Invalid condition: ${value}`);
440
+ values.push(value);
441
+ }
442
+ flags.push(`--conditions=${values.join(",")}`);
443
+ }
444
+ if (external)
445
+ for (let name of external)
446
+ flags.push(`--external:${name}`);
447
+ if (banner) {
448
+ for (let type in banner) {
449
+ if (type.indexOf("=") >= 0)
450
+ throw new Error(`Invalid banner file type: ${type}`);
451
+ flags.push(`--banner:${type}=${banner[type]}`);
452
+ }
453
+ }
454
+ if (footer) {
455
+ for (let type in footer) {
456
+ if (type.indexOf("=") >= 0)
457
+ throw new Error(`Invalid footer file type: ${type}`);
458
+ flags.push(`--footer:${type}=${footer[type]}`);
459
+ }
460
+ }
461
+ if (inject)
462
+ for (let path2 of inject)
463
+ flags.push(`--inject:${path2}`);
464
+ if (loader) {
465
+ for (let ext in loader) {
466
+ if (ext.indexOf("=") >= 0)
467
+ throw new Error(`Invalid loader extension: ${ext}`);
468
+ flags.push(`--loader:${ext}=${loader[ext]}`);
469
+ }
470
+ }
471
+ if (outExtension) {
472
+ for (let ext in outExtension) {
473
+ if (ext.indexOf("=") >= 0)
474
+ throw new Error(`Invalid out extension: ${ext}`);
475
+ flags.push(`--out-extension:${ext}=${outExtension[ext]}`);
476
+ }
477
+ }
478
+ if (entryPoints) {
479
+ if (Array.isArray(entryPoints)) {
480
+ for (let entryPoint of entryPoints) {
481
+ entries.push(["", entryPoint + ""]);
482
+ }
483
+ } else {
484
+ for (let [key, value] of Object.entries(entryPoints)) {
485
+ entries.push([key + "", value + ""]);
486
+ }
487
+ }
488
+ }
489
+ if (stdin) {
490
+ let stdinKeys = Object.create(null);
491
+ let contents = getFlag(stdin, stdinKeys, "contents", mustBeString);
492
+ let resolveDir = getFlag(stdin, stdinKeys, "resolveDir", mustBeString);
493
+ let sourcefile = getFlag(stdin, stdinKeys, "sourcefile", mustBeString);
494
+ let loader2 = getFlag(stdin, stdinKeys, "loader", mustBeString);
495
+ checkForInvalidFlags(stdin, stdinKeys, 'in "stdin" object');
496
+ if (sourcefile)
497
+ flags.push(`--sourcefile=${sourcefile}`);
498
+ if (loader2)
499
+ flags.push(`--loader=${loader2}`);
500
+ if (resolveDir)
501
+ stdinResolveDir = resolveDir + "";
502
+ stdinContents = contents ? contents + "" : "";
503
+ }
504
+ let nodePaths = [];
505
+ if (nodePathsInput) {
506
+ for (let value of nodePathsInput) {
507
+ value += "";
508
+ nodePaths.push(value);
509
+ }
510
+ }
511
+ return {
512
+ entries,
513
+ flags,
514
+ write,
515
+ stdinContents,
516
+ stdinResolveDir,
517
+ absWorkingDir,
518
+ incremental,
519
+ nodePaths,
520
+ watch: watchMode
521
+ };
522
+ }
523
+ function flagsForTransformOptions(callName, options, isTTY2, logLevelDefault) {
524
+ let flags = [];
525
+ let keys = Object.create(null);
526
+ pushLogFlags(flags, options, keys, isTTY2, logLevelDefault);
527
+ pushCommonFlags(flags, options, keys);
528
+ let sourcemap = getFlag(options, keys, "sourcemap", mustBeStringOrBoolean);
529
+ let tsconfigRaw = getFlag(options, keys, "tsconfigRaw", mustBeStringOrObject);
530
+ let sourcefile = getFlag(options, keys, "sourcefile", mustBeString);
531
+ let loader = getFlag(options, keys, "loader", mustBeString);
532
+ let banner = getFlag(options, keys, "banner", mustBeString);
533
+ let footer = getFlag(options, keys, "footer", mustBeString);
534
+ checkForInvalidFlags(options, keys, `in ${callName}() call`);
535
+ if (sourcemap)
536
+ flags.push(`--sourcemap=${sourcemap === true ? "external" : sourcemap}`);
537
+ if (tsconfigRaw)
538
+ flags.push(`--tsconfig-raw=${typeof tsconfigRaw === "string" ? tsconfigRaw : JSON.stringify(tsconfigRaw)}`);
539
+ if (sourcefile)
540
+ flags.push(`--sourcefile=${sourcefile}`);
541
+ if (loader)
542
+ flags.push(`--loader=${loader}`);
543
+ if (banner)
544
+ flags.push(`--banner=${banner}`);
545
+ if (footer)
546
+ flags.push(`--footer=${footer}`);
547
+ return flags;
548
+ }
549
+ function createChannel(streamIn) {
550
+ let responseCallbacks = new Map();
551
+ let pluginCallbacks = new Map();
552
+ let watchCallbacks = new Map();
553
+ let serveCallbacks = new Map();
554
+ let nextServeID = 0;
555
+ let isClosed = false;
556
+ let nextRequestID = 0;
557
+ let nextBuildKey = 0;
558
+ let stdout = new Uint8Array(16 * 1024);
559
+ let stdoutUsed = 0;
560
+ let readFromStdout = (chunk) => {
561
+ let limit = stdoutUsed + chunk.length;
562
+ if (limit > stdout.length) {
563
+ let swap = new Uint8Array(limit * 2);
564
+ swap.set(stdout);
565
+ stdout = swap;
566
+ }
567
+ stdout.set(chunk, stdoutUsed);
568
+ stdoutUsed += chunk.length;
569
+ let offset = 0;
570
+ while (offset + 4 <= stdoutUsed) {
571
+ let length = readUInt32LE(stdout, offset);
572
+ if (offset + 4 + length > stdoutUsed) {
573
+ break;
574
+ }
575
+ offset += 4;
576
+ handleIncomingPacket(stdout.subarray(offset, offset + length));
577
+ offset += length;
578
+ }
579
+ if (offset > 0) {
580
+ stdout.copyWithin(0, offset, stdoutUsed);
581
+ stdoutUsed -= offset;
582
+ }
583
+ };
584
+ let afterClose = () => {
585
+ isClosed = true;
586
+ for (let callback of responseCallbacks.values()) {
587
+ callback("The service was stopped", null);
588
+ }
589
+ responseCallbacks.clear();
590
+ for (let callbacks of serveCallbacks.values()) {
591
+ callbacks.onWait("The service was stopped");
592
+ }
593
+ serveCallbacks.clear();
594
+ for (let callback of watchCallbacks.values()) {
595
+ try {
596
+ callback(new Error("The service was stopped"), null);
597
+ } catch (e) {
598
+ console.error(e);
599
+ }
600
+ }
601
+ watchCallbacks.clear();
602
+ };
603
+ let sendRequest = (refs, value, callback) => {
604
+ if (isClosed)
605
+ return callback("The service is no longer running", null);
606
+ let id = nextRequestID++;
607
+ responseCallbacks.set(id, (error, response) => {
608
+ try {
609
+ callback(error, response);
610
+ } finally {
611
+ if (refs)
612
+ refs.unref();
613
+ }
614
+ });
615
+ if (refs)
616
+ refs.ref();
617
+ streamIn.writeToStdin(encodePacket({ id, isRequest: true, value }));
618
+ };
619
+ let sendResponse = (id, value) => {
620
+ if (isClosed)
621
+ throw new Error("The service is no longer running");
622
+ streamIn.writeToStdin(encodePacket({ id, isRequest: false, value }));
623
+ };
624
+ let handleRequest = async (id, request) => {
625
+ try {
626
+ switch (request.command) {
627
+ case "ping": {
628
+ sendResponse(id, {});
629
+ break;
630
+ }
631
+ case "start": {
632
+ let callback = pluginCallbacks.get(request.key);
633
+ if (!callback)
634
+ sendResponse(id, {});
635
+ else
636
+ sendResponse(id, await callback(request));
637
+ break;
638
+ }
639
+ case "resolve": {
640
+ let callback = pluginCallbacks.get(request.key);
641
+ if (!callback)
642
+ sendResponse(id, {});
643
+ else
644
+ sendResponse(id, await callback(request));
645
+ break;
646
+ }
647
+ case "load": {
648
+ let callback = pluginCallbacks.get(request.key);
649
+ if (!callback)
650
+ sendResponse(id, {});
651
+ else
652
+ sendResponse(id, await callback(request));
653
+ break;
654
+ }
655
+ case "serve-request": {
656
+ let callbacks = serveCallbacks.get(request.serveID);
657
+ if (callbacks && callbacks.onRequest)
658
+ callbacks.onRequest(request.args);
659
+ sendResponse(id, {});
660
+ break;
661
+ }
662
+ case "serve-wait": {
663
+ let callbacks = serveCallbacks.get(request.serveID);
664
+ if (callbacks)
665
+ callbacks.onWait(request.error);
666
+ sendResponse(id, {});
667
+ break;
668
+ }
669
+ case "watch-rebuild": {
670
+ let callback = watchCallbacks.get(request.watchID);
671
+ try {
672
+ if (callback)
673
+ callback(null, request.args);
674
+ } catch (err) {
675
+ console.error(err);
676
+ }
677
+ sendResponse(id, {});
678
+ break;
679
+ }
680
+ default:
681
+ throw new Error(`Invalid command: ` + request.command);
682
+ }
683
+ } catch (e) {
684
+ sendResponse(id, { errors: [extractErrorMessageV8(e, streamIn, null, void 0, "")] });
685
+ }
686
+ };
687
+ let isFirstPacket = true;
688
+ let handleIncomingPacket = (bytes) => {
689
+ if (isFirstPacket) {
690
+ isFirstPacket = false;
691
+ let binaryVersion = String.fromCharCode(...bytes);
692
+ if (binaryVersion !== "0.12.25") {
693
+ throw new Error(`Cannot start service: Host version "${"0.12.25"}" does not match binary version ${JSON.stringify(binaryVersion)}`);
694
+ }
695
+ return;
696
+ }
697
+ let packet = decodePacket(bytes);
698
+ if (packet.isRequest) {
699
+ handleRequest(packet.id, packet.value);
700
+ } else {
701
+ let callback = responseCallbacks.get(packet.id);
702
+ responseCallbacks.delete(packet.id);
703
+ if (packet.value.error)
704
+ callback(packet.value.error, {});
705
+ else
706
+ callback(null, packet.value);
707
+ }
708
+ };
709
+ let handlePlugins = async (initialOptions, plugins, buildKey, stash) => {
710
+ let onStartCallbacks = [];
711
+ let onEndCallbacks = [];
712
+ let onResolveCallbacks = {};
713
+ let onLoadCallbacks = {};
714
+ let nextCallbackID = 0;
715
+ let i = 0;
716
+ let requestPlugins = [];
717
+ plugins = [...plugins];
718
+ for (let item of plugins) {
719
+ let keys = {};
720
+ if (typeof item !== "object")
721
+ throw new Error(`Plugin at index ${i} must be an object`);
722
+ let name = getFlag(item, keys, "name", mustBeString);
723
+ if (typeof name !== "string" || name === "")
724
+ throw new Error(`Plugin at index ${i} is missing a name`);
725
+ try {
726
+ let setup = getFlag(item, keys, "setup", mustBeFunction);
727
+ if (typeof setup !== "function")
728
+ throw new Error(`Plugin is missing a setup function`);
729
+ checkForInvalidFlags(item, keys, `on plugin ${JSON.stringify(name)}`);
730
+ let plugin = {
731
+ name,
732
+ onResolve: [],
733
+ onLoad: []
734
+ };
735
+ i++;
736
+ let promise = setup({
737
+ initialOptions,
738
+ onStart(callback2) {
739
+ let registeredText = `This error came from the "onStart" callback registered here`;
740
+ let registeredNote = extractCallerV8(new Error(registeredText), streamIn, "onStart");
741
+ onStartCallbacks.push({ name, callback: callback2, note: registeredNote });
742
+ },
743
+ onEnd(callback2) {
744
+ let registeredText = `This error came from the "onEnd" callback registered here`;
745
+ let registeredNote = extractCallerV8(new Error(registeredText), streamIn, "onEnd");
746
+ onEndCallbacks.push({ name, callback: callback2, note: registeredNote });
747
+ },
748
+ onResolve(options, callback2) {
749
+ let registeredText = `This error came from the "onResolve" callback registered here`;
750
+ let registeredNote = extractCallerV8(new Error(registeredText), streamIn, "onResolve");
751
+ let keys2 = {};
752
+ let filter = getFlag(options, keys2, "filter", mustBeRegExp);
753
+ let namespace = getFlag(options, keys2, "namespace", mustBeString);
754
+ checkForInvalidFlags(options, keys2, `in onResolve() call for plugin ${JSON.stringify(name)}`);
755
+ if (filter == null)
756
+ throw new Error(`onResolve() call is missing a filter`);
757
+ let id = nextCallbackID++;
758
+ onResolveCallbacks[id] = { name, callback: callback2, note: registeredNote };
759
+ plugin.onResolve.push({ id, filter: filter.source, namespace: namespace || "" });
760
+ },
761
+ onLoad(options, callback2) {
762
+ let registeredText = `This error came from the "onLoad" callback registered here`;
763
+ let registeredNote = extractCallerV8(new Error(registeredText), streamIn, "onLoad");
764
+ let keys2 = {};
765
+ let filter = getFlag(options, keys2, "filter", mustBeRegExp);
766
+ let namespace = getFlag(options, keys2, "namespace", mustBeString);
767
+ checkForInvalidFlags(options, keys2, `in onLoad() call for plugin ${JSON.stringify(name)}`);
768
+ if (filter == null)
769
+ throw new Error(`onLoad() call is missing a filter`);
770
+ let id = nextCallbackID++;
771
+ onLoadCallbacks[id] = { name, callback: callback2, note: registeredNote };
772
+ plugin.onLoad.push({ id, filter: filter.source, namespace: namespace || "" });
773
+ }
774
+ });
775
+ if (promise)
776
+ await promise;
777
+ requestPlugins.push(plugin);
778
+ } catch (e) {
779
+ return { ok: false, error: e, pluginName: name };
780
+ }
781
+ }
782
+ const callback = async (request) => {
783
+ switch (request.command) {
784
+ case "start": {
785
+ let response = { errors: [], warnings: [] };
786
+ await Promise.all(onStartCallbacks.map(async ({ name, callback: callback2, note }) => {
787
+ try {
788
+ let result = await callback2();
789
+ if (result != null) {
790
+ if (typeof result !== "object")
791
+ throw new Error(`Expected onStart() callback in plugin ${JSON.stringify(name)} to return an object`);
792
+ let keys = {};
793
+ let errors = getFlag(result, keys, "errors", mustBeArray);
794
+ let warnings = getFlag(result, keys, "warnings", mustBeArray);
795
+ checkForInvalidFlags(result, keys, `from onStart() callback in plugin ${JSON.stringify(name)}`);
796
+ if (errors != null)
797
+ response.errors.push(...sanitizeMessages(errors, "errors", stash, name));
798
+ if (warnings != null)
799
+ response.warnings.push(...sanitizeMessages(warnings, "warnings", stash, name));
800
+ }
801
+ } catch (e) {
802
+ response.errors.push(extractErrorMessageV8(e, streamIn, stash, note && note(), name));
803
+ }
804
+ }));
805
+ return response;
806
+ }
807
+ case "resolve": {
808
+ let response = {}, name = "", callback2, note;
809
+ for (let id of request.ids) {
810
+ try {
811
+ ({ name, callback: callback2, note } = onResolveCallbacks[id]);
812
+ let result = await callback2({
813
+ path: request.path,
814
+ importer: request.importer,
815
+ namespace: request.namespace,
816
+ resolveDir: request.resolveDir,
817
+ kind: request.kind,
818
+ pluginData: stash.load(request.pluginData)
819
+ });
820
+ if (result != null) {
821
+ if (typeof result !== "object")
822
+ throw new Error(`Expected onResolve() callback in plugin ${JSON.stringify(name)} to return an object`);
823
+ let keys = {};
824
+ let pluginName = getFlag(result, keys, "pluginName", mustBeString);
825
+ let path2 = getFlag(result, keys, "path", mustBeString);
826
+ let namespace = getFlag(result, keys, "namespace", mustBeString);
827
+ let external = getFlag(result, keys, "external", mustBeBoolean);
828
+ let sideEffects = getFlag(result, keys, "sideEffects", mustBeBoolean);
829
+ let pluginData = getFlag(result, keys, "pluginData", canBeAnything);
830
+ let errors = getFlag(result, keys, "errors", mustBeArray);
831
+ let warnings = getFlag(result, keys, "warnings", mustBeArray);
832
+ let watchFiles = getFlag(result, keys, "watchFiles", mustBeArray);
833
+ let watchDirs = getFlag(result, keys, "watchDirs", mustBeArray);
834
+ checkForInvalidFlags(result, keys, `from onResolve() callback in plugin ${JSON.stringify(name)}`);
835
+ response.id = id;
836
+ if (pluginName != null)
837
+ response.pluginName = pluginName;
838
+ if (path2 != null)
839
+ response.path = path2;
840
+ if (namespace != null)
841
+ response.namespace = namespace;
842
+ if (external != null)
843
+ response.external = external;
844
+ if (sideEffects != null)
845
+ response.sideEffects = sideEffects;
846
+ if (pluginData != null)
847
+ response.pluginData = stash.store(pluginData);
848
+ if (errors != null)
849
+ response.errors = sanitizeMessages(errors, "errors", stash, name);
850
+ if (warnings != null)
851
+ response.warnings = sanitizeMessages(warnings, "warnings", stash, name);
852
+ if (watchFiles != null)
853
+ response.watchFiles = sanitizeStringArray(watchFiles, "watchFiles");
854
+ if (watchDirs != null)
855
+ response.watchDirs = sanitizeStringArray(watchDirs, "watchDirs");
856
+ break;
857
+ }
858
+ } catch (e) {
859
+ return { id, errors: [extractErrorMessageV8(e, streamIn, stash, note && note(), name)] };
860
+ }
861
+ }
862
+ return response;
863
+ }
864
+ case "load": {
865
+ let response = {}, name = "", callback2, note;
866
+ for (let id of request.ids) {
867
+ try {
868
+ ({ name, callback: callback2, note } = onLoadCallbacks[id]);
869
+ let result = await callback2({
870
+ path: request.path,
871
+ namespace: request.namespace,
872
+ pluginData: stash.load(request.pluginData)
873
+ });
874
+ if (result != null) {
875
+ if (typeof result !== "object")
876
+ throw new Error(`Expected onLoad() callback in plugin ${JSON.stringify(name)} to return an object`);
877
+ let keys = {};
878
+ let pluginName = getFlag(result, keys, "pluginName", mustBeString);
879
+ let contents = getFlag(result, keys, "contents", mustBeStringOrUint8Array);
880
+ let resolveDir = getFlag(result, keys, "resolveDir", mustBeString);
881
+ let pluginData = getFlag(result, keys, "pluginData", canBeAnything);
882
+ let loader = getFlag(result, keys, "loader", mustBeString);
883
+ let errors = getFlag(result, keys, "errors", mustBeArray);
884
+ let warnings = getFlag(result, keys, "warnings", mustBeArray);
885
+ let watchFiles = getFlag(result, keys, "watchFiles", mustBeArray);
886
+ let watchDirs = getFlag(result, keys, "watchDirs", mustBeArray);
887
+ checkForInvalidFlags(result, keys, `from onLoad() callback in plugin ${JSON.stringify(name)}`);
888
+ response.id = id;
889
+ if (pluginName != null)
890
+ response.pluginName = pluginName;
891
+ if (contents instanceof Uint8Array)
892
+ response.contents = contents;
893
+ else if (contents != null)
894
+ response.contents = encodeUTF8(contents);
895
+ if (resolveDir != null)
896
+ response.resolveDir = resolveDir;
897
+ if (pluginData != null)
898
+ response.pluginData = stash.store(pluginData);
899
+ if (loader != null)
900
+ response.loader = loader;
901
+ if (errors != null)
902
+ response.errors = sanitizeMessages(errors, "errors", stash, name);
903
+ if (warnings != null)
904
+ response.warnings = sanitizeMessages(warnings, "warnings", stash, name);
905
+ if (watchFiles != null)
906
+ response.watchFiles = sanitizeStringArray(watchFiles, "watchFiles");
907
+ if (watchDirs != null)
908
+ response.watchDirs = sanitizeStringArray(watchDirs, "watchDirs");
909
+ break;
910
+ }
911
+ } catch (e) {
912
+ return { id, errors: [extractErrorMessageV8(e, streamIn, stash, note && note(), name)] };
913
+ }
914
+ }
915
+ return response;
916
+ }
917
+ default:
918
+ throw new Error(`Invalid command: ` + request.command);
919
+ }
920
+ };
921
+ let runOnEndCallbacks = (result, logPluginError, done) => done();
922
+ if (onEndCallbacks.length > 0) {
923
+ runOnEndCallbacks = (result, logPluginError, done) => {
924
+ (async () => {
925
+ for (const { name, callback: callback2, note } of onEndCallbacks) {
926
+ try {
927
+ await callback2(result);
928
+ } catch (e) {
929
+ result.errors.push(await new Promise((resolve) => logPluginError(e, name, note && note(), resolve)));
930
+ }
931
+ }
932
+ })().then(done);
933
+ };
934
+ }
935
+ let refCount = 0;
936
+ return {
937
+ ok: true,
938
+ requestPlugins,
939
+ runOnEndCallbacks,
940
+ pluginRefs: {
941
+ ref() {
942
+ if (++refCount === 1)
943
+ pluginCallbacks.set(buildKey, callback);
944
+ },
945
+ unref() {
946
+ if (--refCount === 0)
947
+ pluginCallbacks.delete(buildKey);
948
+ }
949
+ }
950
+ };
951
+ };
952
+ let buildServeData = (refs, options, request) => {
953
+ let keys = {};
954
+ let port = getFlag(options, keys, "port", mustBeInteger);
955
+ let host = getFlag(options, keys, "host", mustBeString);
956
+ let servedir = getFlag(options, keys, "servedir", mustBeString);
957
+ let onRequest = getFlag(options, keys, "onRequest", mustBeFunction);
958
+ let serveID = nextServeID++;
959
+ let onWait;
960
+ let wait = new Promise((resolve, reject) => {
961
+ onWait = (error) => {
962
+ serveCallbacks.delete(serveID);
963
+ if (error !== null)
964
+ reject(new Error(error));
965
+ else
966
+ resolve();
967
+ };
968
+ });
969
+ request.serve = { serveID };
970
+ checkForInvalidFlags(options, keys, `in serve() call`);
971
+ if (port !== void 0)
972
+ request.serve.port = port;
973
+ if (host !== void 0)
974
+ request.serve.host = host;
975
+ if (servedir !== void 0)
976
+ request.serve.servedir = servedir;
977
+ serveCallbacks.set(serveID, {
978
+ onRequest,
979
+ onWait
980
+ });
981
+ return {
982
+ wait,
983
+ stop() {
984
+ sendRequest(refs, { command: "serve-stop", serveID }, () => {
985
+ });
986
+ }
987
+ };
988
+ };
989
+ const buildLogLevelDefault = "warning";
990
+ const transformLogLevelDefault = "silent";
991
+ let buildOrServe = (args) => {
992
+ let key = nextBuildKey++;
993
+ const details = createObjectStash();
994
+ let plugins;
995
+ let { refs, options, isTTY: isTTY2, callback } = args;
996
+ if (typeof options === "object") {
997
+ let value = options.plugins;
998
+ if (value !== void 0) {
999
+ if (!Array.isArray(value))
1000
+ throw new Error(`"plugins" must be an array`);
1001
+ plugins = value;
1002
+ }
1003
+ }
1004
+ let logPluginError = (e, pluginName, note, done) => {
1005
+ let flags = [];
1006
+ try {
1007
+ pushLogFlags(flags, options, {}, isTTY2, buildLogLevelDefault);
1008
+ } catch (e2) {
1009
+ }
1010
+ const message = extractErrorMessageV8(e, streamIn, details, note, pluginName);
1011
+ sendRequest(refs, { command: "error", flags, error: message }, () => {
1012
+ message.detail = details.load(message.detail);
1013
+ done(message);
1014
+ });
1015
+ };
1016
+ let handleError = (e, pluginName) => {
1017
+ logPluginError(e, pluginName, void 0, (error) => {
1018
+ callback(failureErrorWithLog("Build failed", [error], []), null);
1019
+ });
1020
+ };
1021
+ if (plugins && plugins.length > 0) {
1022
+ if (streamIn.isSync)
1023
+ return handleError(new Error("Cannot use plugins in synchronous API calls"), "");
1024
+ handlePlugins(options, plugins, key, details).then((result) => {
1025
+ if (!result.ok) {
1026
+ handleError(result.error, result.pluginName);
1027
+ } else {
1028
+ try {
1029
+ buildOrServeContinue(__spreadProps(__spreadValues({}, args), {
1030
+ key,
1031
+ details,
1032
+ logPluginError,
1033
+ requestPlugins: result.requestPlugins,
1034
+ runOnEndCallbacks: result.runOnEndCallbacks,
1035
+ pluginRefs: result.pluginRefs
1036
+ }));
1037
+ } catch (e) {
1038
+ handleError(e, "");
1039
+ }
1040
+ }
1041
+ }, (e) => handleError(e, ""));
1042
+ } else {
1043
+ try {
1044
+ buildOrServeContinue(__spreadProps(__spreadValues({}, args), {
1045
+ key,
1046
+ details,
1047
+ logPluginError,
1048
+ requestPlugins: null,
1049
+ runOnEndCallbacks: (result, logPluginError2, done) => done(),
1050
+ pluginRefs: null
1051
+ }));
1052
+ } catch (e) {
1053
+ handleError(e, "");
1054
+ }
1055
+ }
1056
+ };
1057
+ let buildOrServeContinue = ({
1058
+ callName,
1059
+ refs: callerRefs,
1060
+ serveOptions,
1061
+ options,
1062
+ isTTY: isTTY2,
1063
+ defaultWD: defaultWD2,
1064
+ callback,
1065
+ key,
1066
+ details,
1067
+ logPluginError,
1068
+ requestPlugins,
1069
+ runOnEndCallbacks,
1070
+ pluginRefs
1071
+ }) => {
1072
+ const refs = {
1073
+ ref() {
1074
+ if (pluginRefs)
1075
+ pluginRefs.ref();
1076
+ if (callerRefs)
1077
+ callerRefs.ref();
1078
+ },
1079
+ unref() {
1080
+ if (pluginRefs)
1081
+ pluginRefs.unref();
1082
+ if (callerRefs)
1083
+ callerRefs.unref();
1084
+ }
1085
+ };
1086
+ let writeDefault = !streamIn.isBrowser;
1087
+ let {
1088
+ entries,
1089
+ flags,
1090
+ write,
1091
+ stdinContents,
1092
+ stdinResolveDir,
1093
+ absWorkingDir,
1094
+ incremental,
1095
+ nodePaths,
1096
+ watch
1097
+ } = flagsForBuildOptions(callName, options, isTTY2, buildLogLevelDefault, writeDefault);
1098
+ let request = {
1099
+ command: "build",
1100
+ key,
1101
+ entries,
1102
+ flags,
1103
+ write,
1104
+ stdinContents,
1105
+ stdinResolveDir,
1106
+ absWorkingDir: absWorkingDir || defaultWD2,
1107
+ incremental,
1108
+ nodePaths
1109
+ };
1110
+ if (requestPlugins)
1111
+ request.plugins = requestPlugins;
1112
+ let serve2 = serveOptions && buildServeData(refs, serveOptions, request);
1113
+ let rebuild;
1114
+ let stop;
1115
+ let copyResponseToResult = (response, result) => {
1116
+ if (response.outputFiles)
1117
+ result.outputFiles = response.outputFiles.map(convertOutputFiles);
1118
+ if (response.metafile)
1119
+ result.metafile = JSON.parse(response.metafile);
1120
+ if (response.writeToStdout !== void 0)
1121
+ console.log(decodeUTF8(response.writeToStdout).replace(/\n$/, ""));
1122
+ };
1123
+ let buildResponseToResult = (response, callback2) => {
1124
+ let result = {
1125
+ errors: replaceDetailsInMessages(response.errors, details),
1126
+ warnings: replaceDetailsInMessages(response.warnings, details)
1127
+ };
1128
+ copyResponseToResult(response, result);
1129
+ runOnEndCallbacks(result, logPluginError, () => {
1130
+ if (result.errors.length > 0) {
1131
+ return callback2(failureErrorWithLog("Build failed", result.errors, result.warnings), null);
1132
+ }
1133
+ if (response.rebuildID !== void 0) {
1134
+ if (!rebuild) {
1135
+ let isDisposed = false;
1136
+ rebuild = () => new Promise((resolve, reject) => {
1137
+ if (isDisposed || isClosed)
1138
+ throw new Error("Cannot rebuild");
1139
+ sendRequest(refs, { command: "rebuild", rebuildID: response.rebuildID }, (error2, response2) => {
1140
+ if (error2) {
1141
+ const message = { pluginName: "", text: error2, location: null, notes: [], detail: void 0 };
1142
+ return callback2(failureErrorWithLog("Build failed", [message], []), null);
1143
+ }
1144
+ buildResponseToResult(response2, (error3, result3) => {
1145
+ if (error3)
1146
+ reject(error3);
1147
+ else
1148
+ resolve(result3);
1149
+ });
1150
+ });
1151
+ });
1152
+ refs.ref();
1153
+ rebuild.dispose = () => {
1154
+ if (isDisposed)
1155
+ return;
1156
+ isDisposed = true;
1157
+ sendRequest(refs, { command: "rebuild-dispose", rebuildID: response.rebuildID }, () => {
1158
+ });
1159
+ refs.unref();
1160
+ };
1161
+ }
1162
+ result.rebuild = rebuild;
1163
+ }
1164
+ if (response.watchID !== void 0) {
1165
+ if (!stop) {
1166
+ let isStopped = false;
1167
+ refs.ref();
1168
+ stop = () => {
1169
+ if (isStopped)
1170
+ return;
1171
+ isStopped = true;
1172
+ watchCallbacks.delete(response.watchID);
1173
+ sendRequest(refs, { command: "watch-stop", watchID: response.watchID }, () => {
1174
+ });
1175
+ refs.unref();
1176
+ };
1177
+ if (watch) {
1178
+ watchCallbacks.set(response.watchID, (serviceStopError, watchResponse) => {
1179
+ if (serviceStopError) {
1180
+ if (watch.onRebuild)
1181
+ watch.onRebuild(serviceStopError, null);
1182
+ return;
1183
+ }
1184
+ let result2 = {
1185
+ errors: replaceDetailsInMessages(watchResponse.errors, details),
1186
+ warnings: replaceDetailsInMessages(watchResponse.warnings, details)
1187
+ };
1188
+ copyResponseToResult(watchResponse, result2);
1189
+ runOnEndCallbacks(result2, logPluginError, () => {
1190
+ if (result2.errors.length > 0) {
1191
+ if (watch.onRebuild)
1192
+ watch.onRebuild(failureErrorWithLog("Build failed", result2.errors, result2.warnings), null);
1193
+ return;
1194
+ }
1195
+ if (watchResponse.rebuildID !== void 0)
1196
+ result2.rebuild = rebuild;
1197
+ result2.stop = stop;
1198
+ if (watch.onRebuild)
1199
+ watch.onRebuild(null, result2);
1200
+ });
1201
+ });
1202
+ }
1203
+ }
1204
+ result.stop = stop;
1205
+ }
1206
+ callback2(null, result);
1207
+ });
1208
+ };
1209
+ if (write && streamIn.isBrowser)
1210
+ throw new Error(`Cannot enable "write" in the browser`);
1211
+ if (incremental && streamIn.isSync)
1212
+ throw new Error(`Cannot use "incremental" with a synchronous build`);
1213
+ if (watch && streamIn.isSync)
1214
+ throw new Error(`Cannot use "watch" with a synchronous build`);
1215
+ sendRequest(refs, request, (error, response) => {
1216
+ if (error)
1217
+ return callback(new Error(error), null);
1218
+ if (serve2) {
1219
+ let serveResponse = response;
1220
+ let isStopped = false;
1221
+ refs.ref();
1222
+ let result = {
1223
+ port: serveResponse.port,
1224
+ host: serveResponse.host,
1225
+ wait: serve2.wait,
1226
+ stop() {
1227
+ if (isStopped)
1228
+ return;
1229
+ isStopped = true;
1230
+ serve2.stop();
1231
+ refs.unref();
1232
+ }
1233
+ };
1234
+ refs.ref();
1235
+ serve2.wait.then(refs.unref, refs.unref);
1236
+ return callback(null, result);
1237
+ }
1238
+ return buildResponseToResult(response, callback);
1239
+ });
1240
+ };
1241
+ let transform2 = ({ callName, refs, input, options, isTTY: isTTY2, fs: fs2, callback }) => {
1242
+ const details = createObjectStash();
1243
+ let start = (inputPath) => {
1244
+ try {
1245
+ if (typeof input !== "string")
1246
+ throw new Error('The input to "transform" must be a string');
1247
+ let flags = flagsForTransformOptions(callName, options, isTTY2, transformLogLevelDefault);
1248
+ let request = {
1249
+ command: "transform",
1250
+ flags,
1251
+ inputFS: inputPath !== null,
1252
+ input: inputPath !== null ? inputPath : input
1253
+ };
1254
+ sendRequest(refs, request, (error, response) => {
1255
+ if (error)
1256
+ return callback(new Error(error), null);
1257
+ let errors = replaceDetailsInMessages(response.errors, details);
1258
+ let warnings = replaceDetailsInMessages(response.warnings, details);
1259
+ let outstanding = 1;
1260
+ let next = () => --outstanding === 0 && callback(null, { warnings, code: response.code, map: response.map });
1261
+ if (errors.length > 0)
1262
+ return callback(failureErrorWithLog("Transform failed", errors, warnings), null);
1263
+ if (response.codeFS) {
1264
+ outstanding++;
1265
+ fs2.readFile(response.code, (err, contents) => {
1266
+ if (err !== null) {
1267
+ callback(err, null);
1268
+ } else {
1269
+ response.code = contents;
1270
+ next();
1271
+ }
1272
+ });
1273
+ }
1274
+ if (response.mapFS) {
1275
+ outstanding++;
1276
+ fs2.readFile(response.map, (err, contents) => {
1277
+ if (err !== null) {
1278
+ callback(err, null);
1279
+ } else {
1280
+ response.map = contents;
1281
+ next();
1282
+ }
1283
+ });
1284
+ }
1285
+ next();
1286
+ });
1287
+ } catch (e) {
1288
+ let flags = [];
1289
+ try {
1290
+ pushLogFlags(flags, options, {}, isTTY2, transformLogLevelDefault);
1291
+ } catch (e2) {
1292
+ }
1293
+ const error = extractErrorMessageV8(e, streamIn, details, void 0, "");
1294
+ sendRequest(refs, { command: "error", flags, error }, () => {
1295
+ error.detail = details.load(error.detail);
1296
+ callback(failureErrorWithLog("Transform failed", [error], []), null);
1297
+ });
1298
+ }
1299
+ };
1300
+ if (typeof input === "string" && input.length > 1024 * 1024) {
1301
+ let next = start;
1302
+ start = () => fs2.writeFile(input, next);
1303
+ }
1304
+ start(null);
1305
+ };
1306
+ let formatMessages2 = ({ callName, refs, messages, options, callback }) => {
1307
+ let result = sanitizeMessages(messages, "messages", null, "");
1308
+ if (!options)
1309
+ throw new Error(`Missing second argument in ${callName}() call`);
1310
+ let keys = {};
1311
+ let kind = getFlag(options, keys, "kind", mustBeString);
1312
+ let color = getFlag(options, keys, "color", mustBeBoolean);
1313
+ let terminalWidth = getFlag(options, keys, "terminalWidth", mustBeInteger);
1314
+ checkForInvalidFlags(options, keys, `in ${callName}() call`);
1315
+ if (kind === void 0)
1316
+ throw new Error(`Missing "kind" in ${callName}() call`);
1317
+ if (kind !== "error" && kind !== "warning")
1318
+ throw new Error(`Expected "kind" to be "error" or "warning" in ${callName}() call`);
1319
+ let request = {
1320
+ command: "format-msgs",
1321
+ messages: result,
1322
+ isWarning: kind === "warning"
1323
+ };
1324
+ if (color !== void 0)
1325
+ request.color = color;
1326
+ if (terminalWidth !== void 0)
1327
+ request.terminalWidth = terminalWidth;
1328
+ sendRequest(refs, request, (error, response) => {
1329
+ if (error)
1330
+ return callback(new Error(error), null);
1331
+ callback(null, response.messages);
1332
+ });
1333
+ };
1334
+ return {
1335
+ readFromStdout,
1336
+ afterClose,
1337
+ service: {
1338
+ buildOrServe,
1339
+ transform: transform2,
1340
+ formatMessages: formatMessages2
1341
+ }
1342
+ };
1343
+ }
1344
+ function createObjectStash() {
1345
+ const map = new Map();
1346
+ let nextID = 0;
1347
+ return {
1348
+ load(id) {
1349
+ return map.get(id);
1350
+ },
1351
+ store(value) {
1352
+ if (value === void 0)
1353
+ return -1;
1354
+ const id = nextID++;
1355
+ map.set(id, value);
1356
+ return id;
1357
+ }
1358
+ };
1359
+ }
1360
+ function extractCallerV8(e, streamIn, ident) {
1361
+ let note;
1362
+ let tried = false;
1363
+ return () => {
1364
+ if (tried)
1365
+ return note;
1366
+ tried = true;
1367
+ try {
1368
+ let lines = (e.stack + "").split("\n");
1369
+ lines.splice(1, 1);
1370
+ let location = parseStackLinesV8(streamIn, lines, ident);
1371
+ if (location) {
1372
+ note = { text: e.message, location };
1373
+ return note;
1374
+ }
1375
+ } catch (e2) {
1376
+ }
1377
+ };
1378
+ }
1379
+ function extractErrorMessageV8(e, streamIn, stash, note, pluginName) {
1380
+ let text = "Internal error";
1381
+ let location = null;
1382
+ try {
1383
+ text = (e && e.message || e) + "";
1384
+ } catch (e2) {
1385
+ }
1386
+ try {
1387
+ location = parseStackLinesV8(streamIn, (e.stack + "").split("\n"), "");
1388
+ } catch (e2) {
1389
+ }
1390
+ return { pluginName, text, location, notes: note ? [note] : [], detail: stash ? stash.store(e) : -1 };
1391
+ }
1392
+ function parseStackLinesV8(streamIn, lines, ident) {
1393
+ let at = " at ";
1394
+ if (streamIn.readFileSync && !lines[0].startsWith(at) && lines[1].startsWith(at)) {
1395
+ for (let i = 1; i < lines.length; i++) {
1396
+ let line = lines[i];
1397
+ if (!line.startsWith(at))
1398
+ continue;
1399
+ line = line.slice(at.length);
1400
+ while (true) {
1401
+ let match = /^(?:new |async )?\S+ \((.*)\)$/.exec(line);
1402
+ if (match) {
1403
+ line = match[1];
1404
+ continue;
1405
+ }
1406
+ match = /^eval at \S+ \((.*)\)(?:, \S+:\d+:\d+)?$/.exec(line);
1407
+ if (match) {
1408
+ line = match[1];
1409
+ continue;
1410
+ }
1411
+ match = /^(\S+):(\d+):(\d+)$/.exec(line);
1412
+ if (match) {
1413
+ let contents;
1414
+ try {
1415
+ contents = streamIn.readFileSync(match[1], "utf8");
1416
+ } catch (e) {
1417
+ break;
1418
+ }
1419
+ let lineText = contents.split(/\r\n|\r|\n|\u2028|\u2029/)[+match[2] - 1] || "";
1420
+ let column = +match[3] - 1;
1421
+ let length = lineText.slice(column, column + ident.length) === ident ? ident.length : 0;
1422
+ return {
1423
+ file: match[1],
1424
+ namespace: "file",
1425
+ line: +match[2],
1426
+ column: encodeUTF8(lineText.slice(0, column)).length,
1427
+ length: encodeUTF8(lineText.slice(column, column + length)).length,
1428
+ lineText: lineText + "\n" + lines.slice(1).join("\n"),
1429
+ suggestion: ""
1430
+ };
1431
+ }
1432
+ break;
1433
+ }
1434
+ }
1435
+ }
1436
+ return null;
1437
+ }
1438
+ function failureErrorWithLog(text, errors, warnings) {
1439
+ let limit = 5;
1440
+ let summary = errors.length < 1 ? "" : ` with ${errors.length} error${errors.length < 2 ? "" : "s"}:` + errors.slice(0, limit + 1).map((e, i) => {
1441
+ if (i === limit)
1442
+ return "\n...";
1443
+ if (!e.location)
1444
+ return `
1445
+ error: ${e.text}`;
1446
+ let { file, line, column } = e.location;
1447
+ let pluginText = e.pluginName ? `[plugin: ${e.pluginName}] ` : "";
1448
+ return `
1449
+ ${file}:${line}:${column}: error: ${pluginText}${e.text}`;
1450
+ }).join("");
1451
+ let error = new Error(`${text}${summary}`);
1452
+ error.errors = errors;
1453
+ error.warnings = warnings;
1454
+ return error;
1455
+ }
1456
+ function replaceDetailsInMessages(messages, stash) {
1457
+ for (const message of messages) {
1458
+ message.detail = stash.load(message.detail);
1459
+ }
1460
+ return messages;
1461
+ }
1462
+ function sanitizeLocation(location, where) {
1463
+ if (location == null)
1464
+ return null;
1465
+ let keys = {};
1466
+ let file = getFlag(location, keys, "file", mustBeString);
1467
+ let namespace = getFlag(location, keys, "namespace", mustBeString);
1468
+ let line = getFlag(location, keys, "line", mustBeInteger);
1469
+ let column = getFlag(location, keys, "column", mustBeInteger);
1470
+ let length = getFlag(location, keys, "length", mustBeInteger);
1471
+ let lineText = getFlag(location, keys, "lineText", mustBeString);
1472
+ let suggestion = getFlag(location, keys, "suggestion", mustBeString);
1473
+ checkForInvalidFlags(location, keys, where);
1474
+ return {
1475
+ file: file || "",
1476
+ namespace: namespace || "",
1477
+ line: line || 0,
1478
+ column: column || 0,
1479
+ length: length || 0,
1480
+ lineText: lineText || "",
1481
+ suggestion: suggestion || ""
1482
+ };
1483
+ }
1484
+ function sanitizeMessages(messages, property, stash, fallbackPluginName) {
1485
+ let messagesClone = [];
1486
+ let index = 0;
1487
+ for (const message of messages) {
1488
+ let keys = {};
1489
+ let pluginName = getFlag(message, keys, "pluginName", mustBeString);
1490
+ let text = getFlag(message, keys, "text", mustBeString);
1491
+ let location = getFlag(message, keys, "location", mustBeObjectOrNull);
1492
+ let notes = getFlag(message, keys, "notes", mustBeArray);
1493
+ let detail = getFlag(message, keys, "detail", canBeAnything);
1494
+ let where = `in element ${index} of "${property}"`;
1495
+ checkForInvalidFlags(message, keys, where);
1496
+ let notesClone = [];
1497
+ if (notes) {
1498
+ for (const note of notes) {
1499
+ let noteKeys = {};
1500
+ let noteText = getFlag(note, noteKeys, "text", mustBeString);
1501
+ let noteLocation = getFlag(note, noteKeys, "location", mustBeObjectOrNull);
1502
+ checkForInvalidFlags(note, noteKeys, where);
1503
+ notesClone.push({
1504
+ text: noteText || "",
1505
+ location: sanitizeLocation(noteLocation, where)
1506
+ });
1507
+ }
1508
+ }
1509
+ messagesClone.push({
1510
+ pluginName: pluginName || fallbackPluginName,
1511
+ text: text || "",
1512
+ location: sanitizeLocation(location, where),
1513
+ notes: notesClone,
1514
+ detail: stash ? stash.store(detail) : -1
1515
+ });
1516
+ index++;
1517
+ }
1518
+ return messagesClone;
1519
+ }
1520
+ function sanitizeStringArray(values, property) {
1521
+ const result = [];
1522
+ for (const value of values) {
1523
+ if (typeof value !== "string")
1524
+ throw new Error(`${JSON.stringify(property)} must be an array of strings`);
1525
+ result.push(value);
1526
+ }
1527
+ return result;
1528
+ }
1529
+ function convertOutputFiles({ path: path2, contents }) {
1530
+ let text = null;
1531
+ return {
1532
+ path: path2,
1533
+ contents,
1534
+ get text() {
1535
+ if (text === null)
1536
+ text = decodeUTF8(contents);
1537
+ return text;
1538
+ }
1539
+ };
1540
+ }
1541
+
1542
+ // lib/npm/node.ts
1543
+ var child_process = require("child_process");
1544
+ var crypto = require("crypto");
1545
+ var path = require("path");
1546
+ var fs = require("fs");
1547
+ var os = require("os");
1548
+ var tty = require("tty");
1549
+ var worker_threads;
1550
+ if (process.env.ESBUILD_WORKER_THREADS !== "0") {
1551
+ try {
1552
+ worker_threads = require("worker_threads");
1553
+ } catch (e) {
1554
+ }
1555
+ let [major, minor] = process.versions.node.split(".");
1556
+ if (+major < 12 || +major === 12 && +minor < 17 || +major === 13 && +minor < 13) {
1557
+ worker_threads = void 0;
1558
+ }
1559
+ }
1560
+ var _a;
1561
+ var isInternalWorkerThread = ((_a = worker_threads == null ? void 0 : worker_threads.workerData) == null ? void 0 : _a.esbuildVersion) === "0.12.25";
1562
+ var esbuildCommandAndArgs = () => {
1563
+ if (process.env.ESBUILD_BINARY_PATH) {
1564
+ return [path.resolve(process.env.ESBUILD_BINARY_PATH), []];
1565
+ }
1566
+ if (path.basename(__filename) !== "main.js" || path.basename(__dirname) !== "lib") {
1567
+ throw new Error(`The esbuild JavaScript API cannot be bundled. Please mark the "esbuild" package as external so it's not included in the bundle.
1568
+
1569
+ More information: The file containing the code for esbuild's JavaScript API (${__filename}) does not appear to be inside the esbuild package on the file system, which usually means that the esbuild package was bundled into another file. This is problematic because the API needs to run a binary executable inside the esbuild package which is located using a relative path from the API code to the executable. If the esbuild package is bundled, the relative path will be incorrect and the executable won't be found.`);
1570
+ }
1571
+ if (true) {
1572
+ return ["node", [path.join(__dirname, "..", "bin", "esbuild")]];
1573
+ }
1574
+ if (process.platform === "win32") {
1575
+ return [path.join(__dirname, "..", "esbuild.exe"), []];
1576
+ }
1577
+ let pathForYarn2 = path.join(__dirname, "..", "esbuild");
1578
+ if (fs.existsSync(pathForYarn2)) {
1579
+ return [pathForYarn2, []];
1580
+ }
1581
+ return [path.join(__dirname, "..", "bin", "esbuild"), []];
1582
+ };
1583
+ var isTTY = () => tty.isatty(2);
1584
+ var fsSync = {
1585
+ readFile(tempFile, callback) {
1586
+ try {
1587
+ let contents = fs.readFileSync(tempFile, "utf8");
1588
+ try {
1589
+ fs.unlinkSync(tempFile);
1590
+ } catch (e) {
1591
+ }
1592
+ callback(null, contents);
1593
+ } catch (err) {
1594
+ callback(err, null);
1595
+ }
1596
+ },
1597
+ writeFile(contents, callback) {
1598
+ try {
1599
+ let tempFile = randomFileName();
1600
+ fs.writeFileSync(tempFile, contents);
1601
+ callback(tempFile);
1602
+ } catch (e) {
1603
+ callback(null);
1604
+ }
1605
+ }
1606
+ };
1607
+ var fsAsync = {
1608
+ readFile(tempFile, callback) {
1609
+ try {
1610
+ fs.readFile(tempFile, "utf8", (err, contents) => {
1611
+ try {
1612
+ fs.unlink(tempFile, () => callback(err, contents));
1613
+ } catch (e) {
1614
+ callback(err, contents);
1615
+ }
1616
+ });
1617
+ } catch (err) {
1618
+ callback(err, null);
1619
+ }
1620
+ },
1621
+ writeFile(contents, callback) {
1622
+ try {
1623
+ let tempFile = randomFileName();
1624
+ fs.writeFile(tempFile, contents, (err) => err !== null ? callback(null) : callback(tempFile));
1625
+ } catch (e) {
1626
+ callback(null);
1627
+ }
1628
+ }
1629
+ };
1630
+ var version = "0.12.25";
1631
+ var build = (options) => ensureServiceIsRunning().build(options);
1632
+ var serve = (serveOptions, buildOptions) => ensureServiceIsRunning().serve(serveOptions, buildOptions);
1633
+ var transform = (input, options) => ensureServiceIsRunning().transform(input, options);
1634
+ var formatMessages = (messages, options) => ensureServiceIsRunning().formatMessages(messages, options);
1635
+ var buildSync = (options) => {
1636
+ if (worker_threads && !isInternalWorkerThread) {
1637
+ if (!workerThreadService)
1638
+ workerThreadService = startWorkerThreadService(worker_threads);
1639
+ return workerThreadService.buildSync(options);
1640
+ }
1641
+ let result;
1642
+ runServiceSync((service) => service.buildOrServe({
1643
+ callName: "buildSync",
1644
+ refs: null,
1645
+ serveOptions: null,
1646
+ options,
1647
+ isTTY: isTTY(),
1648
+ defaultWD,
1649
+ callback: (err, res) => {
1650
+ if (err)
1651
+ throw err;
1652
+ result = res;
1653
+ }
1654
+ }));
1655
+ return result;
1656
+ };
1657
+ var transformSync = (input, options) => {
1658
+ if (worker_threads && !isInternalWorkerThread) {
1659
+ if (!workerThreadService)
1660
+ workerThreadService = startWorkerThreadService(worker_threads);
1661
+ return workerThreadService.transformSync(input, options);
1662
+ }
1663
+ let result;
1664
+ runServiceSync((service) => service.transform({
1665
+ callName: "transformSync",
1666
+ refs: null,
1667
+ input,
1668
+ options: options || {},
1669
+ isTTY: isTTY(),
1670
+ fs: fsSync,
1671
+ callback: (err, res) => {
1672
+ if (err)
1673
+ throw err;
1674
+ result = res;
1675
+ }
1676
+ }));
1677
+ return result;
1678
+ };
1679
+ var formatMessagesSync = (messages, options) => {
1680
+ if (worker_threads && !isInternalWorkerThread) {
1681
+ if (!workerThreadService)
1682
+ workerThreadService = startWorkerThreadService(worker_threads);
1683
+ return workerThreadService.formatMessagesSync(messages, options);
1684
+ }
1685
+ let result;
1686
+ runServiceSync((service) => service.formatMessages({
1687
+ callName: "formatMessagesSync",
1688
+ refs: null,
1689
+ messages,
1690
+ options,
1691
+ callback: (err, res) => {
1692
+ if (err)
1693
+ throw err;
1694
+ result = res;
1695
+ }
1696
+ }));
1697
+ return result;
1698
+ };
1699
+ var initializeWasCalled = false;
1700
+ var initialize = (options) => {
1701
+ options = validateInitializeOptions(options || {});
1702
+ if (options.wasmURL)
1703
+ throw new Error(`The "wasmURL" option only works in the browser`);
1704
+ if (options.worker)
1705
+ throw new Error(`The "worker" option only works in the browser`);
1706
+ if (initializeWasCalled)
1707
+ throw new Error('Cannot call "initialize" more than once');
1708
+ ensureServiceIsRunning();
1709
+ initializeWasCalled = true;
1710
+ return Promise.resolve();
1711
+ };
1712
+ var defaultWD = process.cwd();
1713
+ var longLivedService;
1714
+ var ensureServiceIsRunning = () => {
1715
+ if (longLivedService)
1716
+ return longLivedService;
1717
+ let [command, args] = esbuildCommandAndArgs();
1718
+ let child = child_process.spawn(command, args.concat(`--service=${"0.12.25"}`, "--ping"), {
1719
+ windowsHide: true,
1720
+ stdio: ["pipe", "pipe", "inherit"],
1721
+ cwd: defaultWD
1722
+ });
1723
+ let { readFromStdout, afterClose, service } = createChannel({
1724
+ writeToStdin(bytes) {
1725
+ child.stdin.write(bytes);
1726
+ },
1727
+ readFileSync: fs.readFileSync,
1728
+ isSync: false,
1729
+ isBrowser: false
1730
+ });
1731
+ const stdin = child.stdin;
1732
+ const stdout = child.stdout;
1733
+ stdout.on("data", readFromStdout);
1734
+ stdout.on("end", afterClose);
1735
+ let refCount = 0;
1736
+ child.unref();
1737
+ if (stdin.unref) {
1738
+ stdin.unref();
1739
+ }
1740
+ if (stdout.unref) {
1741
+ stdout.unref();
1742
+ }
1743
+ const refs = {
1744
+ ref() {
1745
+ if (++refCount === 1)
1746
+ child.ref();
1747
+ },
1748
+ unref() {
1749
+ if (--refCount === 0)
1750
+ child.unref();
1751
+ }
1752
+ };
1753
+ longLivedService = {
1754
+ build: (options) => {
1755
+ return new Promise((resolve, reject) => {
1756
+ service.buildOrServe({
1757
+ callName: "build",
1758
+ refs,
1759
+ serveOptions: null,
1760
+ options,
1761
+ isTTY: isTTY(),
1762
+ defaultWD,
1763
+ callback: (err, res) => err ? reject(err) : resolve(res)
1764
+ });
1765
+ });
1766
+ },
1767
+ serve: (serveOptions, buildOptions) => {
1768
+ if (serveOptions === null || typeof serveOptions !== "object")
1769
+ throw new Error("The first argument must be an object");
1770
+ return new Promise((resolve, reject) => service.buildOrServe({
1771
+ callName: "serve",
1772
+ refs,
1773
+ serveOptions,
1774
+ options: buildOptions,
1775
+ isTTY: isTTY(),
1776
+ defaultWD,
1777
+ callback: (err, res) => err ? reject(err) : resolve(res)
1778
+ }));
1779
+ },
1780
+ transform: (input, options) => {
1781
+ return new Promise((resolve, reject) => service.transform({
1782
+ callName: "transform",
1783
+ refs,
1784
+ input,
1785
+ options: options || {},
1786
+ isTTY: isTTY(),
1787
+ fs: fsAsync,
1788
+ callback: (err, res) => err ? reject(err) : resolve(res)
1789
+ }));
1790
+ },
1791
+ formatMessages: (messages, options) => {
1792
+ return new Promise((resolve, reject) => service.formatMessages({
1793
+ callName: "formatMessages",
1794
+ refs,
1795
+ messages,
1796
+ options,
1797
+ callback: (err, res) => err ? reject(err) : resolve(res)
1798
+ }));
1799
+ }
1800
+ };
1801
+ return longLivedService;
1802
+ };
1803
+ var runServiceSync = (callback) => {
1804
+ let [command, args] = esbuildCommandAndArgs();
1805
+ let stdin = new Uint8Array();
1806
+ let { readFromStdout, afterClose, service } = createChannel({
1807
+ writeToStdin(bytes) {
1808
+ if (stdin.length !== 0)
1809
+ throw new Error("Must run at most one command");
1810
+ stdin = bytes;
1811
+ },
1812
+ isSync: true,
1813
+ isBrowser: false
1814
+ });
1815
+ callback(service);
1816
+ let stdout = child_process.execFileSync(command, args.concat(`--service=${"0.12.25"}`), {
1817
+ cwd: defaultWD,
1818
+ windowsHide: true,
1819
+ input: stdin,
1820
+ maxBuffer: +process.env.ESBUILD_MAX_BUFFER || 16 * 1024 * 1024
1821
+ });
1822
+ readFromStdout(stdout);
1823
+ afterClose();
1824
+ };
1825
+ var randomFileName = () => {
1826
+ return path.join(os.tmpdir(), `esbuild-${crypto.randomBytes(32).toString("hex")}`);
1827
+ };
1828
+ var workerThreadService = null;
1829
+ var startWorkerThreadService = (worker_threads2) => {
1830
+ let { port1: mainPort, port2: workerPort } = new worker_threads2.MessageChannel();
1831
+ let worker = new worker_threads2.Worker(__filename, {
1832
+ workerData: { workerPort, defaultWD, esbuildVersion: "0.12.25" },
1833
+ transferList: [workerPort],
1834
+ execArgv: []
1835
+ });
1836
+ let nextID = 0;
1837
+ let wasStopped = false;
1838
+ let fakeBuildError = (text) => {
1839
+ let error = new Error(`Build failed with 1 error:
1840
+ error: ${text}`);
1841
+ let errors = [{ pluginName: "", text, location: null, notes: [], detail: void 0 }];
1842
+ error.errors = errors;
1843
+ error.warnings = [];
1844
+ return error;
1845
+ };
1846
+ let validateBuildSyncOptions = (options) => {
1847
+ if (!options)
1848
+ return;
1849
+ let plugins = options.plugins;
1850
+ let incremental = options.incremental;
1851
+ let watch = options.watch;
1852
+ if (plugins && plugins.length > 0)
1853
+ throw fakeBuildError(`Cannot use plugins in synchronous API calls`);
1854
+ if (incremental)
1855
+ throw fakeBuildError(`Cannot use "incremental" with a synchronous build`);
1856
+ if (watch)
1857
+ throw fakeBuildError(`Cannot use "watch" with a synchronous build`);
1858
+ };
1859
+ let applyProperties = (object, properties) => {
1860
+ for (let key in properties) {
1861
+ object[key] = properties[key];
1862
+ }
1863
+ };
1864
+ let runCallSync = (command, args) => {
1865
+ if (wasStopped)
1866
+ throw new Error("The service was stopped");
1867
+ let id = nextID++;
1868
+ let sharedBuffer = new SharedArrayBuffer(8);
1869
+ let sharedBufferView = new Int32Array(sharedBuffer);
1870
+ let msg = { sharedBuffer, id, command, args };
1871
+ worker.postMessage(msg);
1872
+ let status = Atomics.wait(sharedBufferView, 0, 0);
1873
+ if (status !== "ok" && status !== "not-equal")
1874
+ throw new Error("Internal error: Atomics.wait() failed: " + status);
1875
+ let { message: { id: id2, resolve, reject, properties } } = worker_threads2.receiveMessageOnPort(mainPort);
1876
+ if (id !== id2)
1877
+ throw new Error(`Internal error: Expected id ${id} but got id ${id2}`);
1878
+ if (reject) {
1879
+ applyProperties(reject, properties);
1880
+ throw reject;
1881
+ }
1882
+ return resolve;
1883
+ };
1884
+ worker.unref();
1885
+ return {
1886
+ buildSync(options) {
1887
+ validateBuildSyncOptions(options);
1888
+ return runCallSync("build", [options]);
1889
+ },
1890
+ transformSync(input, options) {
1891
+ return runCallSync("transform", [input, options]);
1892
+ },
1893
+ formatMessagesSync(messages, options) {
1894
+ return runCallSync("formatMessages", [messages, options]);
1895
+ }
1896
+ };
1897
+ };
1898
+ var startSyncServiceWorker = () => {
1899
+ let workerPort = worker_threads.workerData.workerPort;
1900
+ let parentPort = worker_threads.parentPort;
1901
+ let service = ensureServiceIsRunning();
1902
+ defaultWD = worker_threads.workerData.defaultWD;
1903
+ let extractProperties = (object) => {
1904
+ let properties = {};
1905
+ if (object && typeof object === "object") {
1906
+ for (let key in object) {
1907
+ properties[key] = object[key];
1908
+ }
1909
+ }
1910
+ return properties;
1911
+ };
1912
+ parentPort.on("message", (msg) => {
1913
+ (async () => {
1914
+ let { sharedBuffer, id, command, args } = msg;
1915
+ let sharedBufferView = new Int32Array(sharedBuffer);
1916
+ try {
1917
+ if (command === "build") {
1918
+ workerPort.postMessage({ id, resolve: await service.build(args[0]) });
1919
+ } else if (command === "transform") {
1920
+ workerPort.postMessage({ id, resolve: await service.transform(args[0], args[1]) });
1921
+ } else if (command === "formatMessages") {
1922
+ workerPort.postMessage({ id, resolve: await service.formatMessages(args[0], args[1]) });
1923
+ } else {
1924
+ throw new Error(`Invalid command: ${command}`);
1925
+ }
1926
+ } catch (reject) {
1927
+ workerPort.postMessage({ id, reject, properties: extractProperties(reject) });
1928
+ }
1929
+ Atomics.add(sharedBufferView, 0, 1);
1930
+ Atomics.notify(sharedBufferView, 0, Infinity);
1931
+ })();
1932
+ });
1933
+ };
1934
+ if (isInternalWorkerThread) {
1935
+ startSyncServiceWorker();
1936
+ }
1937
+ // Annotate the CommonJS export names for ESM import in node:
1938
+ 0 && (module.exports = {
1939
+ build,
1940
+ buildSync,
1941
+ formatMessages,
1942
+ formatMessagesSync,
1943
+ initialize,
1944
+ serve,
1945
+ transform,
1946
+ transformSync,
1947
+ version
1948
+ });