@amaster.ai/vite-plugins 1.0.0-beta.40 → 1.0.0-beta.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +57 -81
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -7
- package/dist/index.d.ts +1 -7
- package/dist/index.js +57 -81
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/bridge.bridge.js +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,68 +1,4 @@
|
|
|
1
|
-
'use strict';Object.defineProperty(exports,'__esModule',{value:true});var
|
|
2
|
-
|
|
3
|
-
This indicates that your JavaScript environment is broken. You cannot use
|
|
4
|
-
esbuild in this environment because esbuild relies on this invariant. This
|
|
5
|
-
is not a problem with esbuild. You need to fix your environment instead.
|
|
6
|
-
`);function pt(e,t){return e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24}function ze(e,t,r){e[r++]=t,e[r++]=t>>8,e[r++]=t>>16,e[r++]=t>>24;}var J=JSON.stringify,nt="warning",it="silent";function ve(e,t){let r=[];for(let n of e){if(Q(n,t),n.indexOf(",")>=0)throw new Error(`Invalid ${t}: ${n}`);r.push(n);}return r.join(",")}var $e=()=>null,q=e=>typeof e=="boolean"?null:"a boolean",v=e=>typeof e=="string"?null:"a string",je=e=>e instanceof RegExp?null:"a RegExp object",de=e=>typeof e=="number"&&e===(e|0)?null:"an integer",ir=e=>typeof e=="number"&&e===(e|0)&&e>=0&&e<=65535?null:"a valid port number",gt=e=>typeof e=="function"?null:"a function",le=e=>Array.isArray(e)?null:"an array",G=e=>Array.isArray(e)&&e.every(t=>typeof t=="string")?null:"an array of strings",Z=e=>typeof e=="object"&&e!==null&&!Array.isArray(e)?null:"an object",or=e=>typeof e=="object"&&e!==null?null:"an array or an object",sr=e=>e instanceof WebAssembly.Module?null:"a WebAssembly.Module",ot=e=>typeof e=="object"&&!Array.isArray(e)?null:"an object or null",mt=e=>typeof e=="string"||typeof e=="boolean"?null:"a string or a boolean",ar=e=>typeof e=="string"||typeof e=="object"&&e!==null&&!Array.isArray(e)?null:"a string or an object",ht=e=>typeof e=="string"||Array.isArray(e)&&e.every(t=>typeof t=="string")?null:"a string or an array of strings",yt=e=>typeof e=="string"||e instanceof Uint8Array?null:"a string or a Uint8Array",lr=e=>typeof e=="string"||e instanceof URL?null:"a string or a URL";function o(e,t,r,n){let i=e[r];if(t[r+""]=true,i===void 0)return;let l=n(i);if(l!==null)throw new Error(`${J(r)} must be ${l}`);return i}function W(e,t,r){for(let n in e)if(!(n in t))throw new Error(`Invalid option ${r}: ${J(n)}`)}function ur(e){let t=Object.create(null),r=o(e,t,"wasmURL",lr),n=o(e,t,"wasmModule",sr),i=o(e,t,"worker",q);return W(e,t,"in initialize() call"),{wasmURL:r,wasmModule:n,worker:i}}function wt(e){let t;if(e!==void 0){t=Object.create(null);for(let r in e){let n=e[r];if(typeof n=="string"||n===false)t[r]=n;else throw new Error(`Expected ${J(r)} in mangle cache to map to either a string or false`)}}return t}function Me(e,t,r,n,i){let l=o(t,r,"color",q),s=o(t,r,"logLevel",v),d=o(t,r,"logLimit",de);l!==void 0?e.push(`--color=${l}`):n&&e.push("--color=true"),e.push(`--log-level=${s||i}`),e.push(`--log-limit=${d||0}`);}function Q(e,t,r){if(typeof e!="string")throw new Error(`Expected value for ${t}${r!==void 0?" "+J(r):""} to be a string, got ${typeof e} instead`);return e}function vt(e,t,r){let n=o(t,r,"legalComments",v),i=o(t,r,"sourceRoot",v),l=o(t,r,"sourcesContent",q),s=o(t,r,"target",ht),d=o(t,r,"format",v),a=o(t,r,"globalName",v),c=o(t,r,"mangleProps",je),u=o(t,r,"reserveProps",je),y=o(t,r,"mangleQuoted",q),k=o(t,r,"minify",q),E=o(t,r,"minifySyntax",q),A=o(t,r,"minifyWhitespace",q),B=o(t,r,"minifyIdentifiers",q),L=o(t,r,"lineLimit",de),U=o(t,r,"drop",G),H=o(t,r,"dropLabels",G),x=o(t,r,"charset",v),w=o(t,r,"treeShaking",q),m=o(t,r,"ignoreAnnotations",q),f=o(t,r,"jsx",v),_=o(t,r,"jsxFactory",v),P=o(t,r,"jsxFragment",v),C=o(t,r,"jsxImportSource",v),T=o(t,r,"jsxDev",q),p=o(t,r,"jsxSideEffects",q),g=o(t,r,"define",Z),S=o(t,r,"logOverride",Z),$=o(t,r,"supported",Z),I=o(t,r,"pure",G),R=o(t,r,"keepNames",q),O=o(t,r,"platform",v),j=o(t,r,"tsconfigRaw",ar),N=o(t,r,"absPaths",G);if(n&&e.push(`--legal-comments=${n}`),i!==void 0&&e.push(`--source-root=${i}`),l!==void 0&&e.push(`--sources-content=${l}`),s&&e.push(`--target=${ve(Array.isArray(s)?s:[s],"target")}`),d&&e.push(`--format=${d}`),a&&e.push(`--global-name=${a}`),O&&e.push(`--platform=${O}`),j&&e.push(`--tsconfig-raw=${typeof j=="string"?j:JSON.stringify(j)}`),k&&e.push("--minify"),E&&e.push("--minify-syntax"),A&&e.push("--minify-whitespace"),B&&e.push("--minify-identifiers"),L&&e.push(`--line-limit=${L}`),x&&e.push(`--charset=${x}`),w!==void 0&&e.push(`--tree-shaking=${w}`),m&&e.push("--ignore-annotations"),U)for(let h of U)e.push(`--drop:${Q(h,"drop")}`);if(H&&e.push(`--drop-labels=${ve(H,"drop label")}`),N&&e.push(`--abs-paths=${ve(N,"abs paths")}`),c&&e.push(`--mangle-props=${Ce(c)}`),u&&e.push(`--reserve-props=${Ce(u)}`),y!==void 0&&e.push(`--mangle-quoted=${y}`),f&&e.push(`--jsx=${f}`),_&&e.push(`--jsx-factory=${_}`),P&&e.push(`--jsx-fragment=${P}`),C&&e.push(`--jsx-import-source=${C}`),T&&e.push("--jsx-dev"),p&&e.push("--jsx-side-effects"),g)for(let h in g){if(h.indexOf("=")>=0)throw new Error(`Invalid define: ${h}`);e.push(`--define:${h}=${Q(g[h],"define",h)}`);}if(S)for(let h in S){if(h.indexOf("=")>=0)throw new Error(`Invalid log override: ${h}`);e.push(`--log-override:${h}=${Q(S[h],"log override",h)}`);}if($)for(let h in $){if(h.indexOf("=")>=0)throw new Error(`Invalid supported: ${h}`);let F=$[h];if(typeof F!="boolean")throw new Error(`Expected value for supported ${J(h)} to be a boolean, got ${typeof F} instead`);e.push(`--supported:${h}=${F}`);}if(I)for(let h of I)e.push(`--pure:${Q(h,"pure")}`);R&&e.push("--keep-names");}function cr(e,t,r,n,i){var l;let s=[],d=[],a=Object.create(null),c=null,u=null;Me(s,t,a,r,n),vt(s,t,a);let y=o(t,a,"sourcemap",mt),k=o(t,a,"bundle",q),E=o(t,a,"splitting",q),A=o(t,a,"preserveSymlinks",q),B=o(t,a,"metafile",q),L=o(t,a,"outfile",v),U=o(t,a,"outdir",v),H=o(t,a,"outbase",v),x=o(t,a,"tsconfig",v),w=o(t,a,"resolveExtensions",G),m=o(t,a,"nodePaths",G),f=o(t,a,"mainFields",G),_=o(t,a,"conditions",G),P=o(t,a,"external",G),C=o(t,a,"packages",v),T=o(t,a,"alias",Z),p=o(t,a,"loader",Z),g=o(t,a,"outExtension",Z),S=o(t,a,"publicPath",v),$=o(t,a,"entryNames",v),I=o(t,a,"chunkNames",v),R=o(t,a,"assetNames",v),O=o(t,a,"inject",G),j=o(t,a,"banner",Z),N=o(t,a,"footer",Z),h=o(t,a,"entryPoints",or),F=o(t,a,"absWorkingDir",v),M=o(t,a,"stdin",Z),D=(l=o(t,a,"write",q))!=null?l:i,K=o(t,a,"allowOverwrite",q),z=o(t,a,"mangleCache",Z);if(a.plugins=true,W(t,a,`in ${e}() call`),y&&s.push(`--sourcemap${y===true?"":`=${y}`}`),k&&s.push("--bundle"),K&&s.push("--allow-overwrite"),E&&s.push("--splitting"),A&&s.push("--preserve-symlinks"),B&&s.push("--metafile"),L&&s.push(`--outfile=${L}`),U&&s.push(`--outdir=${U}`),H&&s.push(`--outbase=${H}`),x&&s.push(`--tsconfig=${x}`),C&&s.push(`--packages=${C}`),w&&s.push(`--resolve-extensions=${ve(w,"resolve extension")}`),S&&s.push(`--public-path=${S}`),$&&s.push(`--entry-names=${$}`),I&&s.push(`--chunk-names=${I}`),R&&s.push(`--asset-names=${R}`),f&&s.push(`--main-fields=${ve(f,"main field")}`),_&&s.push(`--conditions=${ve(_,"condition")}`),P)for(let b of P)s.push(`--external:${Q(b,"external")}`);if(T)for(let b in T){if(b.indexOf("=")>=0)throw new Error(`Invalid package name in alias: ${b}`);s.push(`--alias:${b}=${Q(T[b],"alias",b)}`);}if(j)for(let b in j){if(b.indexOf("=")>=0)throw new Error(`Invalid banner file type: ${b}`);s.push(`--banner:${b}=${Q(j[b],"banner",b)}`);}if(N)for(let b in N){if(b.indexOf("=")>=0)throw new Error(`Invalid footer file type: ${b}`);s.push(`--footer:${b}=${Q(N[b],"footer",b)}`);}if(O)for(let b of O)s.push(`--inject:${Q(b,"inject")}`);if(p)for(let b in p){if(b.indexOf("=")>=0)throw new Error(`Invalid loader extension: ${b}`);s.push(`--loader:${b}=${Q(p[b],"loader",b)}`);}if(g)for(let b in g){if(b.indexOf("=")>=0)throw new Error(`Invalid out extension: ${b}`);s.push(`--out-extension:${b}=${Q(g[b],"out extension",b)}`);}if(h)if(Array.isArray(h))for(let b=0,se=h.length;b<se;b++){let ee=h[b];if(typeof ee=="object"&&ee!==null){let ie=Object.create(null),ae=o(ee,ie,"in",v),te=o(ee,ie,"out",v);if(W(ee,ie,"in entry point at index "+b),ae===void 0)throw new Error('Missing property "in" for entry point at index '+b);if(te===void 0)throw new Error('Missing property "out" for entry point at index '+b);d.push([te,ae]);}else d.push(["",Q(ee,"entry point at index "+b)]);}else for(let b in h)d.push([b,Q(h[b],"entry point",b)]);if(M){let b=Object.create(null),se=o(M,b,"contents",yt),ee=o(M,b,"resolveDir",v),ie=o(M,b,"sourcefile",v),ae=o(M,b,"loader",v);W(M,b,'in "stdin" object'),ie&&s.push(`--sourcefile=${ie}`),ae&&s.push(`--loader=${ae}`),ee&&(u=ee),typeof se=="string"?c=ne(se):se instanceof Uint8Array&&(c=se);}let oe=[];if(m)for(let b of m)b+="",oe.push(b);return {entries:d,flags:s,write:D,stdinContents:c,stdinResolveDir:u,absWorkingDir:F,nodePaths:oe,mangleCache:wt(z)}}function fr(e,t,r,n){let i=[],l=Object.create(null);Me(i,t,l,r,n),vt(i,t,l);let s=o(t,l,"sourcemap",mt),d=o(t,l,"sourcefile",v),a=o(t,l,"loader",v),c=o(t,l,"banner",v),u=o(t,l,"footer",v),y=o(t,l,"mangleCache",Z);return W(t,l,`in ${e}() call`),s&&i.push(`--sourcemap=${s===true?"external":s}`),d&&i.push(`--sourcefile=${d}`),a&&i.push(`--loader=${a}`),c&&i.push(`--banner=${c}`),u&&i.push(`--footer=${u}`),{flags:i,mangleCache:wt(y)}}function bt(e){let t={},r={didClose:false,reason:""},n={},i=0,l=0,s=new Uint8Array(16*1024),d=0,a=x=>{let w=d+x.length;if(w>s.length){let f=new Uint8Array(w*2);f.set(s),s=f;}s.set(x,d),d+=x.length;let m=0;for(;m+4<=d;){let f=pt(s,m);if(m+4+f>d)break;m+=4,A(s.subarray(m,m+f)),m+=f;}m>0&&(s.copyWithin(0,m,d),d-=m);},c=x=>{r.didClose=true,x&&(r.reason=": "+(x.message||x));let w="The service was stopped"+r.reason;for(let m in n)n[m](w,null);n={};},u=(x,w,m)=>{if(r.didClose)return m("The service is no longer running"+r.reason,null);let f=i++;n[f]=(_,P)=>{try{m(_,P);}finally{x&&x.unref();}},x&&x.ref(),e.writeToStdin(rt({id:f,isRequest:true,value:w}));},y=(x,w)=>{if(r.didClose)throw new Error("The service is no longer running"+r.reason);e.writeToStdin(rt({id:x,isRequest:false,value:w}));},k=async(x,w)=>{try{if(w.command==="ping"){y(x,{});return}if(typeof w.key=="number"){let m=t[w.key];if(!m)return;let f=m[w.command];if(f){await f(x,w);return}}throw new Error("Invalid command: "+w.command)}catch(m){let f=[fe(m,e,null,void 0,"")];try{y(x,{errors:f});}catch{}}},E=true,A=x=>{if(E){E=false;let m=String.fromCharCode(...x);if(m!=="0.27.2")throw new Error(`Cannot start service: Host version "0.27.2" does not match binary version ${J(m)}`);return}let w=nr(x);if(w.isRequest)k(w.id,w.value);else {let m=n[w.id];delete n[w.id],w.value.error?m(w.value.error,{}):m(null,w.value);}};return {readFromStdout:a,afterClose:c,service:{buildOrContext:({callName:x,refs:w,options:m,isTTY:f,defaultWD:_,callback:P})=>{let C=0,T=l++,p={},g={ref(){++C===1&&w&&w.ref();},unref(){--C===0&&(delete t[T],w&&w.unref());}};t[T]=p,g.ref(),dr(x,T,u,y,g,e,p,m,f,_,(S,$)=>{try{P(S,$);}finally{g.unref();}});},transform:({callName:x,refs:w,input:m,options:f,isTTY:_,fs:P,callback:C})=>{let T=St(),p=g=>{try{if(typeof m!="string"&&!(m instanceof Uint8Array))throw new Error('The input to "transform" must be a string or a Uint8Array');let{flags:S,mangleCache:$}=fr(x,f,_,it),I={command:"transform",flags:S,inputFS:g!==null,input:g!==null?ne(g):typeof m=="string"?ne(m):m};$&&(I.mangleCache=$),u(w,I,(R,O)=>{if(R)return C(new Error(R),null);let j=Se(O.errors,T),N=Se(O.warnings,T),h=1,F=()=>{if(--h===0){let M={warnings:N,code:O.code,map:O.map,mangleCache:void 0,legalComments:void 0};"legalComments"in O&&(M.legalComments=O?.legalComments),O.mangleCache&&(M.mangleCache=O?.mangleCache),C(null,M);}};if(j.length>0)return C(_e("Transform failed",j,N),null);O.codeFS&&(h++,P.readFile(O.code,(M,D)=>{M!==null?C(M,null):(O.code=D,F());})),O.mapFS&&(h++,P.readFile(O.map,(M,D)=>{M!==null?C(M,null):(O.map=D,F());})),F();});}catch(S){let $=[];try{Me($,f,{},_,it);}catch{}let I=fe(S,e,T,void 0,"");u(w,{command:"error",flags:$,error:I},()=>{I.detail=T.load(I.detail),C(_e("Transform failed",[I],[]),null);});}};if((typeof m=="string"||m instanceof Uint8Array)&&m.length>1024*1024){let g=p;p=()=>P.writeFile(m,g);}p(null);},formatMessages:({callName:x,refs:w,messages:m,options:f,callback:_})=>{if(!f)throw new Error(`Missing second argument in ${x}() call`);let P={},C=o(f,P,"kind",v),T=o(f,P,"color",q),p=o(f,P,"terminalWidth",de);if(W(f,P,`in ${x}() call`),C===void 0)throw new Error(`Missing "kind" in ${x}() call`);if(C!=="error"&&C!=="warning")throw new Error(`Expected "kind" to be "error" or "warning" in ${x}() call`);let g={command:"format-msgs",messages:ue(m,"messages",null,"",p),isWarning:C==="warning"};T!==void 0&&(g.color=T),p!==void 0&&(g.terminalWidth=p),u(w,g,(S,$)=>{if(S)return _(new Error(S),null);_(null,$.messages);});},analyzeMetafile:({callName:x,refs:w,metafile:m,options:f,callback:_})=>{f===void 0&&(f={});let P={},C=o(f,P,"color",q),T=o(f,P,"verbose",q);W(f,P,`in ${x}() call`);let p={command:"analyze-metafile",metafile:m};C!==void 0&&(p.color=C),T!==void 0&&(p.verbose=T),u(w,p,(g,S)=>{if(g)return _(new Error(g),null);_(null,S.result);});}}}}function dr(e,t,r,n,i,l,s,d,a,c,u){let y=St(),k=e==="context",E=(L,U)=>{let H=[];try{Me(H,d,{},a,nt);}catch{}let x=fe(L,l,y,void 0,U);r(i,{command:"error",flags:H,error:x},()=>{x.detail=y.load(x.detail),u(_e(k?"Context failed":"Build failed",[x],[]),null);});},A;if(typeof d=="object"){let L=d.plugins;if(L!==void 0){if(!Array.isArray(L))return E(new Error('"plugins" must be an array'),"");A=L;}}if(A&&A.length>0){if(l.isSync)return E(new Error("Cannot use plugins in synchronous API calls"),"");pr(t,r,n,i,l,s,d,A,y).then(L=>{if(!L.ok)return E(L.error,L.pluginName);try{B(L.requestPlugins,L.runOnEndCallbacks,L.scheduleOnDisposeCallbacks);}catch(U){E(U,"");}},L=>E(L,""));return}try{B(null,(L,U)=>U([],[]),()=>{});}catch(L){E(L,"");}function B(L,U,H){let x=l.hasFS,{entries:w,flags:m,write:f,stdinContents:_,stdinResolveDir:P,absWorkingDir:C,nodePaths:T,mangleCache:p}=cr(e,d,a,nt,x);if(f&&!l.hasFS)throw new Error('The "write" option is unavailable in this environment');let g={command:"build",key:t,entries:w,flags:m,write:f,stdinContents:_,stdinResolveDir:P,absWorkingDir:C||c,nodePaths:T,context:k};L&&(g.plugins=L),p&&(g.mangleCache=p);let S=(R,O)=>{let j={errors:Se(R.errors,y),warnings:Se(R.warnings,y),outputFiles:void 0,metafile:void 0,mangleCache:void 0},N=j.errors.slice(),h=j.warnings.slice();R.outputFiles&&(j.outputFiles=R.outputFiles.map(mr)),R.metafile&&(j.metafile=JSON.parse(R.metafile)),R.mangleCache&&(j.mangleCache=R.mangleCache),R.writeToStdout!==void 0&&console.log(be(R.writeToStdout).replace(/\n$/,"")),U(j,(F,M)=>{if(N.length>0||F.length>0){let D=_e("Build failed",N.concat(F),h.concat(M));return O(D,null,F,M)}O(null,j,F,M);});},$,I;k&&(s["on-end"]=(R,O)=>new Promise(j=>{S(O,(N,h,F,M)=>{let D={errors:F,warnings:M};I&&I(N,h),$=void 0,I=void 0,n(R,D),j();});})),r(i,g,(R,O)=>{if(R)return u(new Error(R),null);if(!k)return S(O,(h,F)=>(H(),u(h,F)));if(O.errors.length>0)return u(_e("Context failed",O.errors,O.warnings),null);let j=false,N={rebuild:()=>($||($=new Promise((h,F)=>{let M;I=(K,z)=>{M||(M=()=>K?F(K):h(z));};let D=()=>{r(i,{command:"rebuild",key:t},(z,oe)=>{z?F(new Error(z)):M?M():D();});};D();})),$),watch:(h={})=>new Promise((F,M)=>{if(!l.hasFS)throw new Error('Cannot use the "watch" API in this environment');let D={},K=o(h,D,"delay",de);W(h,D,"in watch() call");let z={command:"watch",key:t};K&&(z.delay=K),r(i,z,oe=>{oe?M(new Error(oe)):F(void 0);});}),serve:(h={})=>new Promise((F,M)=>{if(!l.hasFS)throw new Error('Cannot use the "serve" API in this environment');let D={},K=o(h,D,"port",ir),z=o(h,D,"host",v),oe=o(h,D,"servedir",v),b=o(h,D,"keyfile",v),se=o(h,D,"certfile",v),ee=o(h,D,"fallback",v),ie=o(h,D,"cors",Z),ae=o(h,D,"onRequest",gt);W(h,D,"in serve() call");let te={command:"serve",key:t,onRequest:!!ae};if(K!==void 0&&(te.port=K),z!==void 0&&(te.host=z),oe!==void 0&&(te.servedir=oe),b!==void 0&&(te.keyfile=b),se!==void 0&&(te.certfile=se),ee!==void 0&&(te.fallback=ee),ie){let xe={},he=o(ie,xe,"origin",ht);W(ie,xe,'on "cors" object'),Array.isArray(he)?te.corsOrigin=he:he!==void 0&&(te.corsOrigin=[he]);}r(i,te,(xe,he)=>{if(xe)return M(new Error(xe));ae&&(s["serve-request"]=(Rt,$t)=>{ae($t.args),n(Rt,{});}),F(he);});}),cancel:()=>new Promise(h=>{if(j)return h();r(i,{command:"cancel",key:t},()=>{h();});}),dispose:()=>new Promise(h=>{if(j)return h();j=true,r(i,{command:"dispose",key:t},()=>{h(),H(),i.unref();});})};i.ref(),u(null,N);});}}var pr=async(e,t,r,n,i,l,s,d,a)=>{let c=[],u=[],y={},k={},E=[],A=0,B=0,L=[],U=false;d=[...d];for(let w of d){let m={};if(typeof w!="object")throw new Error(`Plugin at index ${B} must be an object`);let f=o(w,m,"name",v);if(typeof f!="string"||f==="")throw new Error(`Plugin at index ${B} is missing a name`);try{let _=o(w,m,"setup",gt);if(typeof _!="function")throw new Error("Plugin is missing a setup function");W(w,m,`on plugin ${J(f)}`);let P={name:f,onStart:!1,onEnd:!1,onResolve:[],onLoad:[]};B++;let T=_({initialOptions:s,resolve:(p,g={})=>{if(!U)throw new Error('Cannot call "resolve" before plugin setup has completed');if(typeof p!="string")throw new Error("The path to resolve must be a string");let S=Object.create(null),$=o(g,S,"pluginName",v),I=o(g,S,"importer",v),R=o(g,S,"namespace",v),O=o(g,S,"resolveDir",v),j=o(g,S,"kind",v),N=o(g,S,"pluginData",$e),h=o(g,S,"with",Z);return W(g,S,"in resolve() call"),new Promise((F,M)=>{let D={command:"resolve",path:p,key:e,pluginName:f};if($!=null&&(D.pluginName=$),I!=null&&(D.importer=I),R!=null&&(D.namespace=R),O!=null&&(D.resolveDir=O),j!=null)D.kind=j;else throw new Error('Must specify "kind" when calling "resolve"');N!=null&&(D.pluginData=a.store(N)),h!=null&&(D.with=gr(h,"with")),t(n,D,(K,z)=>{K!==null?M(new Error(K)):F({errors:Se(z.errors,a),warnings:Se(z.warnings,a),path:z.path,external:z.external,sideEffects:z.sideEffects,namespace:z.namespace,suffix:z.suffix,pluginData:a.load(z.pluginData)});});})},onStart(p){let g='This error came from the "onStart" callback registered here:',S=Ae(new Error(g),i,"onStart");c.push({name:f,callback:p,note:S}),P.onStart=!0;},onEnd(p){let g='This error came from the "onEnd" callback registered here:',S=Ae(new Error(g),i,"onEnd");u.push({name:f,callback:p,note:S}),P.onEnd=!0;},onResolve(p,g){let S='This error came from the "onResolve" callback registered here:',$=Ae(new Error(S),i,"onResolve"),I={},R=o(p,I,"filter",je),O=o(p,I,"namespace",v);if(W(p,I,`in onResolve() call for plugin ${J(f)}`),R==null)throw new Error("onResolve() call is missing a filter");let j=A++;y[j]={name:f,callback:g,note:$},P.onResolve.push({id:j,filter:Ce(R),namespace:O||""});},onLoad(p,g){let S='This error came from the "onLoad" callback registered here:',$=Ae(new Error(S),i,"onLoad"),I={},R=o(p,I,"filter",je),O=o(p,I,"namespace",v);if(W(p,I,`in onLoad() call for plugin ${J(f)}`),R==null)throw new Error("onLoad() call is missing a filter");let j=A++;k[j]={name:f,callback:g,note:$},P.onLoad.push({id:j,filter:Ce(R),namespace:O||""});},onDispose(p){E.push(p);},esbuild:i.esbuild});T&&await T,L.push(P);}catch(_){return {ok:false,error:_,pluginName:f}}}l["on-start"]=async(w,m)=>{a.clear();let f={errors:[],warnings:[]};await Promise.all(c.map(async({name:_,callback:P,note:C})=>{try{let T=await P();if(T!=null){if(typeof T!="object")throw new Error(`Expected onStart() callback in plugin ${J(_)} to return an object`);let p={},g=o(T,p,"errors",le),S=o(T,p,"warnings",le);W(T,p,`from onStart() callback in plugin ${J(_)}`),g!=null&&f.errors.push(...ue(g,"errors",a,_,void 0)),S!=null&&f.warnings.push(...ue(S,"warnings",a,_,void 0));}}catch(T){f.errors.push(fe(T,i,a,C&&C(),_));}})),r(w,f);},l["on-resolve"]=async(w,m)=>{let f={},_="",P,C;for(let T of m.ids)try{({name:_,callback:P,note:C}=y[T]);let p=await P({path:m.path,importer:m.importer,namespace:m.namespace,resolveDir:m.resolveDir,kind:m.kind,pluginData:a.load(m.pluginData),with:m.with});if(p!=null){if(typeof p!="object")throw new Error(`Expected onResolve() callback in plugin ${J(_)} to return an object`);let g={},S=o(p,g,"pluginName",v),$=o(p,g,"path",v),I=o(p,g,"namespace",v),R=o(p,g,"suffix",v),O=o(p,g,"external",q),j=o(p,g,"sideEffects",q),N=o(p,g,"pluginData",$e),h=o(p,g,"errors",le),F=o(p,g,"warnings",le),M=o(p,g,"watchFiles",G),D=o(p,g,"watchDirs",G);W(p,g,`from onResolve() callback in plugin ${J(_)}`),f.id=T,S!=null&&(f.pluginName=S),$!=null&&(f.path=$),I!=null&&(f.namespace=I),R!=null&&(f.suffix=R),O!=null&&(f.external=O),j!=null&&(f.sideEffects=j),N!=null&&(f.pluginData=a.store(N)),h!=null&&(f.errors=ue(h,"errors",a,_,void 0)),F!=null&&(f.warnings=ue(F,"warnings",a,_,void 0)),M!=null&&(f.watchFiles=Re(M,"watchFiles")),D!=null&&(f.watchDirs=Re(D,"watchDirs"));break}}catch(p){f={id:T,errors:[fe(p,i,a,C&&C(),_)]};break}r(w,f);},l["on-load"]=async(w,m)=>{let f={},_="",P,C;for(let T of m.ids)try{({name:_,callback:P,note:C}=k[T]);let p=await P({path:m.path,namespace:m.namespace,suffix:m.suffix,pluginData:a.load(m.pluginData),with:m.with});if(p!=null){if(typeof p!="object")throw new Error(`Expected onLoad() callback in plugin ${J(_)} to return an object`);let g={},S=o(p,g,"pluginName",v),$=o(p,g,"contents",yt),I=o(p,g,"resolveDir",v),R=o(p,g,"pluginData",$e),O=o(p,g,"loader",v),j=o(p,g,"errors",le),N=o(p,g,"warnings",le),h=o(p,g,"watchFiles",G),F=o(p,g,"watchDirs",G);W(p,g,`from onLoad() callback in plugin ${J(_)}`),f.id=T,S!=null&&(f.pluginName=S),$ instanceof Uint8Array?f.contents=$:$!=null&&(f.contents=ne($)),I!=null&&(f.resolveDir=I),R!=null&&(f.pluginData=a.store(R)),O!=null&&(f.loader=O),j!=null&&(f.errors=ue(j,"errors",a,_,void 0)),N!=null&&(f.warnings=ue(N,"warnings",a,_,void 0)),h!=null&&(f.watchFiles=Re(h,"watchFiles")),F!=null&&(f.watchDirs=Re(F,"watchDirs"));break}}catch(p){f={id:T,errors:[fe(p,i,a,C&&C(),_)]};break}r(w,f);};let H=(w,m)=>m([],[]);u.length>0&&(H=(w,m)=>{(async()=>{let f=[],_=[];for(let{name:P,callback:C,note:T}of u){let p,g;try{let S=await C(w);if(S!=null){if(typeof S!="object")throw new Error(`Expected onEnd() callback in plugin ${J(P)} to return an object`);let $={},I=o(S,$,"errors",le),R=o(S,$,"warnings",le);W(S,$,`from onEnd() callback in plugin ${J(P)}`),I!=null&&(p=ue(I,"errors",a,P,void 0)),R!=null&&(g=ue(R,"warnings",a,P,void 0));}}catch(S){p=[fe(S,i,a,T&&T(),P)];}if(p){f.push(...p);try{w.errors.push(...p);}catch{}}if(g){_.push(...g);try{w.warnings.push(...g);}catch{}}}m(f,_);})();});let x=()=>{for(let w of E)setTimeout(()=>w(),0);};return U=true,{ok:true,requestPlugins:L,runOnEndCallbacks:H,scheduleOnDisposeCallbacks:x}};function St(){let e=new Map,t=0;return {clear(){e.clear();},load(r){return e.get(r)},store(r){if(r===void 0)return -1;let n=t++;return e.set(n,r),n}}}function Ae(e,t,r){let n,i=false;return ()=>{if(i)return n;i=true;try{let l=(e.stack+"").split(`
|
|
7
|
-
`);l.splice(1,1);let s=xt(t,l,r);if(s)return n={text:e.message,location:s},n}catch{}}}function fe(e,t,r,n,i){let l="Internal error",s=null;try{l=(e&&e.message||e)+"";}catch{}try{s=xt(t,(e.stack+"").split(`
|
|
8
|
-
`),"");}catch{}return {id:"",pluginName:i,text:l,location:s,notes:n?[n]:[],detail:r?r.store(e):-1}}function xt(e,t,r){let n=" at ";if(e.readFileSync&&!t[0].startsWith(n)&&t[1].startsWith(n))for(let i=1;i<t.length;i++){let l=t[i];if(l.startsWith(n))for(l=l.slice(n.length);;){let s=/^(?:new |async )?\S+ \((.*)\)$/.exec(l);if(s){l=s[1];continue}if(s=/^eval at \S+ \((.*)\)(?:, \S+:\d+:\d+)?$/.exec(l),s){l=s[1];continue}if(s=/^(\S+):(\d+):(\d+)$/.exec(l),s){let d;try{d=e.readFileSync(s[1],"utf8");}catch{break}let a=d.split(/\r\n|\r|\n|\u2028|\u2029/)[+s[2]-1]||"",c=+s[3]-1,u=a.slice(c,c+r.length)===r?r.length:0;return {file:s[1],namespace:"file",line:+s[2],column:ne(a.slice(0,c)).length,length:ne(a.slice(c,c+u)).length,lineText:a+`
|
|
9
|
-
`+t.slice(1).join(`
|
|
10
|
-
`),suggestion:""}}break}}return null}function _e(e,t,r){let n=5;e+=t.length<1?"":` with ${t.length} error${t.length<2?"":"s"}:`+t.slice(0,n+1).map((l,s)=>{if(s===n)return `
|
|
11
|
-
...`;if(!l.location)return `
|
|
12
|
-
error: ${l.text}`;let{file:d,line:a,column:c}=l.location,u=l.pluginName?`[plugin: ${l.pluginName}] `:"";return `
|
|
13
|
-
${d}:${a}:${c}: ERROR: ${u}${l.text}`}).join("");let i=new Error(e);for(let[l,s]of [["errors",t],["warnings",r]])Object.defineProperty(i,l,{configurable:true,enumerable:true,get:()=>s,set:d=>Object.defineProperty(i,l,{configurable:true,enumerable:true,value:d})});return i}function Se(e,t){for(let r of e)r.detail=t.load(r.detail);return e}function st(e,t,r){if(e==null)return null;let n={},i=o(e,n,"file",v),l=o(e,n,"namespace",v),s=o(e,n,"line",de),d=o(e,n,"column",de),a=o(e,n,"length",de),c=o(e,n,"lineText",v),u=o(e,n,"suggestion",v);if(W(e,n,t),c){let y=c.slice(0,(d&&d>0?d:0)+(a&&a>0?a:0)+(r&&r>0?r:80));!/[\x7F-\uFFFF]/.test(y)&&!/\n/.test(c)&&(c=y);}return {file:i||"",namespace:l||"",line:s||0,column:d||0,length:a||0,lineText:c||"",suggestion:u||""}}function ue(e,t,r,n,i){let l=[],s=0;for(let d of e){let a={},c=o(d,a,"id",v),u=o(d,a,"pluginName",v),y=o(d,a,"text",v),k=o(d,a,"location",ot),E=o(d,a,"notes",le),A=o(d,a,"detail",$e),B=`in element ${s} of "${t}"`;W(d,a,B);let L=[];if(E)for(let U of E){let H={},x=o(U,H,"text",v),w=o(U,H,"location",ot);W(U,H,B),L.push({text:x||"",location:st(w,B,i)});}l.push({id:c||"",pluginName:u||n,text:y||"",location:st(k,B,i),notes:L,detail:r?r.store(A):-1}),s++;}return l}function Re(e,t){let r=[];for(let n of e){if(typeof n!="string")throw new Error(`${J(t)} must be an array of strings`);r.push(n);}return r}function gr(e,t){let r=Object.create(null);for(let n in e){let i=e[n];if(typeof i!="string")throw new Error(`key ${J(n)} in object ${J(t)} must be a string`);r[n]=i;}return r}function mr({path:e,contents:t,hash:r}){let n=null;return {path:e,contents:t,hash:r,get text(){let i=this.contents;return (n===null||i!==t)&&(t=i,n=be(i)),n}}}function Ce(e){let t=e.source;return e.flags&&(t=`(?${e.flags})${t}`),t}var ce=V("fs"),at=V("os"),re=V("path"),we=process.env.ESBUILD_BINARY_PATH||we,hr=e=>!!e&&e!=="/usr/bin/esbuild",lt="@esbuild/darwin-arm64",ut="@esbuild/darwin-x64",Ie={"win32 arm64 LE":"@esbuild/win32-arm64","win32 ia32 LE":"@esbuild/win32-ia32","win32 x64 LE":"@esbuild/win32-x64"},Le={"aix ppc64 BE":"@esbuild/aix-ppc64","android arm64 LE":"@esbuild/android-arm64","darwin arm64 LE":"@esbuild/darwin-arm64","darwin x64 LE":"@esbuild/darwin-x64","freebsd arm64 LE":"@esbuild/freebsd-arm64","freebsd x64 LE":"@esbuild/freebsd-x64","linux arm LE":"@esbuild/linux-arm","linux arm64 LE":"@esbuild/linux-arm64","linux ia32 LE":"@esbuild/linux-ia32","linux mips64el LE":"@esbuild/linux-mips64el","linux ppc64 LE":"@esbuild/linux-ppc64","linux riscv64 LE":"@esbuild/linux-riscv64","linux s390x BE":"@esbuild/linux-s390x","linux x64 LE":"@esbuild/linux-x64","linux loong64 LE":"@esbuild/linux-loong64","netbsd arm64 LE":"@esbuild/netbsd-arm64","netbsd x64 LE":"@esbuild/netbsd-x64","openbsd arm64 LE":"@esbuild/openbsd-arm64","openbsd x64 LE":"@esbuild/openbsd-x64","sunos x64 LE":"@esbuild/sunos-x64"},ct={"android arm LE":"@esbuild/android-arm","android x64 LE":"@esbuild/android-x64","openharmony arm64 LE":"@esbuild/openharmony-arm64"};function yr(){let e,t,r=false,n=`${process.platform} ${at.arch()} ${at.endianness()}`;if(n in Ie)e=Ie[n],t="esbuild.exe";else if(n in Le)e=Le[n],t="bin/esbuild";else if(n in ct)e=ct[n],t="bin/esbuild",r=true;else throw new Error(`Unsupported platform: ${n}`);return {pkg:e,subpath:t,isWASM:r}}function wr(){let e=V.resolve("esbuild"),t=re.dirname(re.dirname(re.dirname(e)));if(re.basename(t)==="node_modules"){for(let r in Le)try{let n=Le[r];if(ce.existsSync(re.join(t,n)))return n}catch{}for(let r in Ie)try{let n=Ie[r];if(ce.existsSync(re.join(t,n)))return n}catch{}}return null}function vr(e,t){let r=re.dirname(V.resolve("esbuild"));return re.join(r,`downloaded-${e.replace("/","-")}-${re.basename(t)}`)}function br(){if(hr(we))if(!ce.existsSync(we))console.warn(`[esbuild] Ignoring bad configuration: ESBUILD_BINARY_PATH=${we}`);else return {binPath:we,isWASM:false};let{pkg:e,subpath:t,isWASM:r}=yr(),n;try{n=V.resolve(`${e}/${t}`);}catch(i){if(n=vr(e,t),!ce.existsSync(n)){try{V.resolve(e);}catch{let l=wr();if(l){let s=`
|
|
14
|
-
Specifically the "${l}" package is present but this platform
|
|
15
|
-
needs the "${e}" package instead. People often get into this
|
|
16
|
-
situation by installing esbuild on Windows or macOS and copying "node_modules"
|
|
17
|
-
into a Docker image that runs Linux, or by copying "node_modules" between
|
|
18
|
-
Windows and WSL environments.
|
|
19
|
-
|
|
20
|
-
If you are installing with npm, you can try not copying the "node_modules"
|
|
21
|
-
directory when you copy the files over, and running "npm ci" or "npm install"
|
|
22
|
-
on the destination platform after the copy. Or you could consider using yarn
|
|
23
|
-
instead of npm which has built-in support for installing a package on multiple
|
|
24
|
-
platforms simultaneously.
|
|
25
|
-
|
|
26
|
-
If you are installing with yarn, you can try listing both this platform and the
|
|
27
|
-
other platform in your ".yarnrc.yml" file using the "supportedArchitectures"
|
|
28
|
-
feature: https://yarnpkg.com/configuration/yarnrc/#supportedArchitectures
|
|
29
|
-
Keep in mind that this means multiple copies of esbuild will be present.
|
|
30
|
-
`;throw (e===ut&&l===lt||e===lt&&l===ut)&&(s=`
|
|
31
|
-
Specifically the "${l}" package is present but this platform
|
|
32
|
-
needs the "${e}" package instead. People often get into this
|
|
33
|
-
situation by installing esbuild with npm running inside of Rosetta 2 and then
|
|
34
|
-
trying to use it with node running outside of Rosetta 2, or vice versa (Rosetta
|
|
35
|
-
2 is Apple's on-the-fly x86_64-to-arm64 translation service).
|
|
36
|
-
|
|
37
|
-
If you are installing with npm, you can try ensuring that both npm and node are
|
|
38
|
-
not running under Rosetta 2 and then reinstalling esbuild. This likely involves
|
|
39
|
-
changing how you installed npm and/or node. For example, installing node with
|
|
40
|
-
the universal installer here should work: https://nodejs.org/en/download/. Or
|
|
41
|
-
you could consider using yarn instead of npm which has built-in support for
|
|
42
|
-
installing a package on multiple platforms simultaneously.
|
|
43
|
-
|
|
44
|
-
If you are installing with yarn, you can try listing both "arm64" and "x64"
|
|
45
|
-
in your ".yarnrc.yml" file using the "supportedArchitectures" feature:
|
|
46
|
-
https://yarnpkg.com/configuration/yarnrc/#supportedArchitectures
|
|
47
|
-
Keep in mind that this means multiple copies of esbuild will be present.
|
|
48
|
-
`),new Error(`
|
|
49
|
-
You installed esbuild for another platform than the one you're currently using.
|
|
50
|
-
This won't work because esbuild is written with native code and needs to
|
|
51
|
-
install a platform-specific binary executable.
|
|
52
|
-
${s}
|
|
53
|
-
Another alternative is to use the "esbuild-wasm" package instead, which works
|
|
54
|
-
the same way on all platforms. But it comes with a heavy performance cost and
|
|
55
|
-
can sometimes be 10x slower than the "esbuild" package, so you may also not
|
|
56
|
-
want to do that.
|
|
57
|
-
`)}throw new Error(`The package "${e}" could not be found, and is needed by esbuild.
|
|
58
|
-
|
|
59
|
-
If you are installing esbuild with npm, make sure that you don't specify the
|
|
60
|
-
"--no-optional" or "--omit=optional" flags. The "optionalDependencies" feature
|
|
61
|
-
of "package.json" is used by esbuild to install the correct binary executable
|
|
62
|
-
for your current platform.`)}throw i}}if(/\.zip\//.test(n)){let i;try{i=V("pnpapi");}catch{}if(i){let l=i.getPackageInformation(i.topLevel).packageLocation,s=re.join(l,"node_modules",".cache","esbuild",`pnpapi-${e.replace("/","-")}-0.27.2-${re.basename(t)}`);return ce.existsSync(s)||(ce.mkdirSync(re.dirname(s),{recursive:true}),ce.copyFileSync(n,s),ce.chmodSync(s,493)),{binPath:s,isWASM:r}}}return {binPath:n,isWASM:r}}var Et=V("child_process"),Sr=V("crypto"),We=V("path"),pe=V("fs"),xr=V("os"),Er=V("tty"),X;if(process.env.ESBUILD_WORKER_THREADS!=="0"){try{X=V("worker_threads");}catch{}let[e,t]=process.versions.node.split(".");(+e<12||+e==12&&+t<17||+e==13&&+t<13)&&(X=void 0);}var ft,Pe=((ft=X?.workerData)==null?void 0:ft.esbuildVersion)==="0.27.2",_t=()=>{if(!we&&(We.basename(__filename)!=="main.js"||We.basename(__dirname)!=="lib"))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.
|
|
63
|
-
|
|
64
|
-
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.`);{let{binPath:e,isWASM:t}=br();return t?["node",[e]]:[e,[]]}},ke=()=>Er.isatty(2),_r={readFile(e,t){try{let r=pe.readFileSync(e,"utf8");try{pe.unlinkSync(e);}catch{}t(null,r);}catch(r){t(r,null);}},writeFile(e,t){try{let r=kt();pe.writeFileSync(r,e),t(r);}catch{t(null);}}},kr={readFile(e,t){try{pe.readFile(e,"utf8",(r,n)=>{try{pe.unlink(e,()=>t(r,n));}catch{t(r,n);}});}catch(r){t(r,null);}},writeFile(e,t){try{let r=kt();pe.writeFile(r,e,n=>t(n!==null?null:r));}catch{t(null);}}},Or="0.27.2",Pr=e=>me().build(e),Tr=e=>me().context(e),Ar=(e,t)=>me().transform(e,t),Rr=(e,t)=>me().formatMessages(e,t),$r=(e,t)=>me().analyzeMetafile(e,t),jr=e=>{if(X&&!Pe)return Y||(Y=Be(X)),Y.buildSync(e);let t;return Fe(r=>r.buildOrContext({callName:"buildSync",refs:null,options:e,isTTY:ke(),defaultWD:ge,callback:(n,i)=>{if(n)throw n;t=i;}})),t},Cr=(e,t)=>{if(X&&!Pe)return Y||(Y=Be(X)),Y.transformSync(e,t);let r;return Fe(n=>n.transform({callName:"transformSync",refs:null,input:e,options:t||{},isTTY:ke(),fs:_r,callback:(i,l)=>{if(i)throw i;r=l;}})),r},Ir=(e,t)=>{if(X&&!Pe)return Y||(Y=Be(X)),Y.formatMessagesSync(e,t);let r;return Fe(n=>n.formatMessages({callName:"formatMessagesSync",refs:null,messages:e,options:t,callback:(i,l)=>{if(i)throw i;r=l;}})),r},Lr=(e,t)=>{if(X&&!Pe)return Y||(Y=Be(X)),Y.analyzeMetafileSync(e,t);let r;return Fe(n=>n.analyzeMetafile({callName:"analyzeMetafileSync",refs:null,metafile:typeof e=="string"?e:JSON.stringify(e),options:t,callback:(i,l)=>{if(i)throw i;r=l;}})),r},Dr=()=>(De&&De(),Y&&Y.stop(),Promise.resolve()),Je=false,Mr=e=>{if(e=ur(e||{}),e.wasmURL)throw new Error('The "wasmURL" option only works in the browser');if(e.wasmModule)throw new Error('The "wasmModule" option only works in the browser');if(e.worker)throw new Error('The "worker" option only works in the browser');if(Je)throw new Error('Cannot call "initialize" more than once');return me(),Je=true,Promise.resolve()},ge=process.cwd(),Ee,De,me=()=>{if(Ee)return Ee;let[e,t]=_t(),r=Et.spawn(e,t.concat("--service=0.27.2","--ping"),{windowsHide:true,stdio:["pipe","pipe","inherit"],cwd:ge}),{readFromStdout:n,afterClose:i,service:l}=bt({writeToStdin(u){r.stdin.write(u,y=>{y&&i(y);});},readFileSync:pe.readFileSync,isSync:false,hasFS:true,esbuild:Oe});r.stdin.on("error",i),r.on("error",i);let s=r.stdin,d=r.stdout;d.on("data",n),d.on("end",i),De=()=>{s.destroy(),d.destroy(),r.kill(),Je=false,Ee=void 0,De=void 0;};let a=0;r.unref(),s.unref&&s.unref(),d.unref&&d.unref();let c={ref(){++a===1&&r.ref();},unref(){--a===0&&r.unref();}};return Ee={build:u=>new Promise((y,k)=>{l.buildOrContext({callName:"build",refs:c,options:u,isTTY:ke(),defaultWD:ge,callback:(E,A)=>E?k(E):y(A)});}),context:u=>new Promise((y,k)=>l.buildOrContext({callName:"context",refs:c,options:u,isTTY:ke(),defaultWD:ge,callback:(E,A)=>E?k(E):y(A)})),transform:(u,y)=>new Promise((k,E)=>l.transform({callName:"transform",refs:c,input:u,options:y||{},isTTY:ke(),fs:kr,callback:(A,B)=>A?E(A):k(B)})),formatMessages:(u,y)=>new Promise((k,E)=>l.formatMessages({callName:"formatMessages",refs:c,messages:u,options:y,callback:(A,B)=>A?E(A):k(B)})),analyzeMetafile:(u,y)=>new Promise((k,E)=>l.analyzeMetafile({callName:"analyzeMetafile",refs:c,metafile:typeof u=="string"?u:JSON.stringify(u),options:y,callback:(A,B)=>A?E(A):k(B)}))},Ee},Fe=e=>{let[t,r]=_t(),n=new Uint8Array,{readFromStdout:i,afterClose:l,service:s}=bt({writeToStdin(a){if(n.length!==0)throw new Error("Must run at most one command");n=a;},isSync:true,hasFS:true,esbuild:Oe});e(s);let d=Et.execFileSync(t,r.concat("--service=0.27.2"),{cwd:ge,windowsHide:true,input:n,maxBuffer:+process.env.ESBUILD_MAX_BUFFER||16*1024*1024});i(d),l(null);},kt=()=>We.join(xr.tmpdir(),`esbuild-${Sr.randomBytes(32).toString("hex")}`),Y=null,Be=e=>{let{port1:t,port2:r}=new e.MessageChannel,n=new e.Worker(__filename,{workerData:{workerPort:r,defaultWD:ge,esbuildVersion:"0.27.2"},transferList:[r],execArgv:[]}),i=0,l=c=>{let u=new Error(`Build failed with 1 error:
|
|
65
|
-
error: ${c}`),y=[{id:"",pluginName:"",text:c,location:null,notes:[],detail:void 0}];return u.errors=y,u.warnings=[],u},s=c=>{if(!c)return;let u=c.plugins;if(u&&u.length>0)throw l("Cannot use plugins in synchronous API calls")},d=(c,u)=>{for(let y in u)c[y]=u[y];},a=(c,u)=>{let y=i++,k=new SharedArrayBuffer(8),E=new Int32Array(k),A={sharedBuffer:k,id:y,command:c,args:u};n.postMessage(A);let B=Atomics.wait(E,0,0);if(B!=="ok"&&B!=="not-equal")throw new Error("Internal error: Atomics.wait() failed: "+B);let{message:{id:L,resolve:U,reject:H,properties:x}}=e.receiveMessageOnPort(t);if(y!==L)throw new Error(`Internal error: Expected id ${y} but got id ${L}`);if(H)throw d(H,x),H;return U};return n.unref(),{buildSync(c){return s(c),a("build",[c])},transformSync(c,u){return a("transform",[c,u])},formatMessagesSync(c,u){return a("formatMessages",[c,u])},analyzeMetafileSync(c,u){return a("analyzeMetafile",[c,u])},stop(){n.terminate(),Y=null;}}},Fr=()=>{let e=X.workerData.workerPort,t=X.parentPort,r=n=>{let i={};if(n&&typeof n=="object")for(let l in n)i[l]=n[l];return i};try{let n=me();ge=X.workerData.defaultWD,t.on("message",i=>{(async()=>{let{sharedBuffer:l,id:s,command:d,args:a}=i,c=new Int32Array(l);try{switch(d){case "build":e.postMessage({id:s,resolve:await n.build(a[0])});break;case "transform":e.postMessage({id:s,resolve:await n.transform(a[0],a[1])});break;case "formatMessages":e.postMessage({id:s,resolve:await n.formatMessages(a[0],a[1])});break;case "analyzeMetafile":e.postMessage({id:s,resolve:await n.analyzeMetafile(a[0],a[1])});break;default:throw new Error(`Invalid command: ${d}`)}}catch(u){e.postMessage({id:s,reject:u,properties:r(u)});}Atomics.add(c,0,1),Atomics.notify(c,0,1/0);})();});}catch(n){t.on("message",i=>{let{sharedBuffer:l,id:s}=i,d=new Int32Array(l);e.postMessage({id:s,reject:n,properties:r(n)}),Atomics.add(d,0,1),Atomics.notify(d,0,1/0);});}};Pe&&Fr();var Br=Oe;});function qt(e,t){let r=`${e}:${t}`;return crypto.createHash("md5").update(r).digest("hex").substring(0,12)}var Ut=new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","link","main","map","mark","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strong","style","sub","summary","sup","svg","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr"]);function Ht(){let e=false;return {name:"vite-plugin-component-id",enforce:"pre",configResolved(t){e=t.command==="serve";},transform(t,r){if(!e||!/\.(tsx|jsx)$/.test(r)||r.includes("node_modules")||!/<[a-z]/.test(t))return null;try{let n=t,i=/<([a-z][\da-z]*)(?=[\s/>])/g,l,s=[],d=c=>{let u=!1,y=!1,k=!1,E=0;for(;E<c;){let A=t[E];if((E>0?t[E-1]:"")==="\\"){E++;continue}A==="'"&&!y&&!k?u=!u:A==='"'&&!u&&!k?y=!y:A==="`"&&!u&&!y&&(k=!k),E++;}return u||y||k};for(;(l=i.exec(t))!==null;){let c=l[1];if(!c)continue;let u=l.index,y=l.index+l[0].length;if(!Ut.has(c)||d(u))continue;let k=y,E=!1,A=!1;for(;k<t.length&&!E;)t[k]===">"&&(E=!0,t.substring(u,k).includes("data-node-component-id")&&(A=!0)),k++;A||s.push({index:u,tag:c,tagEndIndex:y});}let a=t;for(let c=s.length-1;c>=0;c--){let u=s[c];if(!u)continue;let{index:y,tagEndIndex:k}=u,E=qt(r,y),A=a.substring(0,k),B=a.substring(k);n=`${A} data-node-component-id="${E}"${B}`,a=n;}return {code:n,map:null}}catch{return null}}}}var Xt=`<script>
|
|
1
|
+
'use strict';Object.defineProperty(exports,'__esModule',{value:true});var g=require('fs'),d=require('path'),x=require('process'),m=require('fs/promises'),T=require('esbuild'),buffer=require('buffer');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var g__default=/*#__PURE__*/_interopDefault(g);var d__default=/*#__PURE__*/_interopDefault(d);var x__default=/*#__PURE__*/_interopDefault(x);var m__default=/*#__PURE__*/_interopDefault(m);var T__namespace=/*#__PURE__*/_interopNamespace(T);var A=`<script>
|
|
66
2
|
document.addEventListener("click", (e) => {
|
|
67
3
|
const element = e.target;
|
|
68
4
|
const noJumpOut = document.body.classList.contains("forbid-jump-out")
|
|
@@ -80,15 +16,55 @@ document.addEventListener("click", (e) => {
|
|
|
80
16
|
e.preventDefault();
|
|
81
17
|
}
|
|
82
18
|
});
|
|
83
|
-
</script
|
|
84
|
-
|
|
85
|
-
|
|
19
|
+
</script>`,I=`<script>
|
|
20
|
+
(function() {
|
|
21
|
+
const SOURCE_KEY = Symbol.for("__jsxSource__");
|
|
22
|
+
const SESSION_KEY = import.meta.env.VITE_AMASTER_KEY;
|
|
23
|
+
|
|
24
|
+
// Expose minimal API for external bridge script
|
|
25
|
+
window.__AMASTER_BRIDGE__ = {
|
|
26
|
+
getSourceInfo: (element) => element?.[SOURCE_KEY],
|
|
27
|
+
getSourceMap: () => window.sourceElementMap,
|
|
28
|
+
postToParent: (type, data) => {
|
|
29
|
+
window.parent.postMessage({ type, data, key: SESSION_KEY }, "*");
|
|
30
|
+
},
|
|
31
|
+
isDev: import.meta.env.DEV,
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
// Listen for bridge script URL from platform
|
|
35
|
+
window.addEventListener("message", (event) => {
|
|
36
|
+
const { type, data, key } = event.data;
|
|
37
|
+
|
|
38
|
+
if (key !== SESSION_KEY) {
|
|
39
|
+
console.warn("[Bridge] Invalid session key");
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (type === "amaster.loadBridge" && data?.scriptUrl) {
|
|
44
|
+
const script = document.createElement("script");
|
|
45
|
+
script.src = data.scriptUrl;
|
|
46
|
+
script.onload = () => {
|
|
47
|
+
console.log("[Bridge] External script loaded");
|
|
48
|
+
window.__AMASTER_BRIDGE__?.postToParent("amaster.bridge.ready", {});
|
|
49
|
+
};
|
|
50
|
+
script.onerror = () => {
|
|
51
|
+
console.error("[Bridge] Failed to load external script");
|
|
52
|
+
};
|
|
53
|
+
document.head.appendChild(script);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
window.addEventListener("load", () => {
|
|
58
|
+
window.__AMASTER_BRIDGE__?.postToParent("amaster.bridge.initialized", {});
|
|
59
|
+
});
|
|
60
|
+
})();
|
|
61
|
+
</script>`;function b(){let r=false;return {name:"vite-plugin-editor-bridge",configResolved(o){r=o.command==="serve";},transformIndexHtml(o){if(!r)return o;let e=`${A}${I}</body>`;return o.replace("</body>",e)}}}function E(r){let o=false,e=r?.routesFilePath||"src/routes.tsx";return {name:"vite-plugin-routes-expose",enforce:"post",configResolved(t){o=t.command==="serve";},transform(t,n){if(!o||!n.endsWith(e))return null;try{return t.includes("window.__APP_ROUTES__")?null:{code:`${t}
|
|
86
62
|
|
|
87
63
|
// Development mode: Expose routes to window.__APP_ROUTES__
|
|
88
64
|
if (typeof window !== 'undefined') {
|
|
89
65
|
window.__APP_ROUTES__ = typeof routes !== 'undefined' && Array.isArray(routes) ? routes : [];
|
|
90
66
|
}
|
|
91
|
-
`,map:null}}catch{return null}}}}function
|
|
67
|
+
`,map:null}}catch{return null}}}}function O(){let r="",o=`
|
|
92
68
|
<script>
|
|
93
69
|
(function() {
|
|
94
70
|
'use strict';
|
|
@@ -769,8 +745,8 @@ if (typeof window !== 'undefined') {
|
|
|
769
745
|
|
|
770
746
|
originalConsole.log('[BrowserLogs] Log collection started');
|
|
771
747
|
})();
|
|
772
|
-
</script>`;return {name:"vite-plugin-browser-logs",configResolved(
|
|
773
|
-
`,"utf-8"),
|
|
748
|
+
</script>`;return {name:"vite-plugin-browser-logs",configResolved(e){let t=x__default.default.env.WORKSPACE_DIR;if(t)r=d__default.default.join(t,"browser.log");else {let n=e.root||x__default.default.cwd();for(;n!==d__default.default.dirname(n)&&!g__default.default.existsSync(d__default.default.join(n,"package.json"));)n=d__default.default.dirname(n);r=d__default.default.join(n,"browser.log");}},configureServer(e){e.middlewares.use((t,n,a)=>{if(t.url==="/__browser__"&&t.method==="POST"){let s=t.headers.origin||"*",l="";t.on("data",c=>{l+=c.toString();}),t.on("end",()=>{try{let c=d__default.default.dirname(r);g__default.default.existsSync(c)||g__default.default.mkdirSync(c,{recursive:!0}),g__default.default.appendFileSync(r,`${l}
|
|
749
|
+
`,"utf-8"),n.writeHead(200,{"Content-Type":"application/json","Access-Control-Allow-Origin":s,"Access-Control-Allow-Methods":"POST, OPTIONS","Access-Control-Allow-Headers":"Content-Type"}),n.end(JSON.stringify({success:!0}));}catch(c){console.error("[BrowserLogs] Write error:",c),n.writeHead(500,{"Content-Type":"application/json","Access-Control-Allow-Origin":s,"Access-Control-Allow-Methods":"POST, OPTIONS","Access-Control-Allow-Headers":"Content-Type"}),n.end(JSON.stringify({success:false,error:String(c)}));}});}else if(t.url==="/__browser__"&&t.method==="OPTIONS"){let s=t.headers.origin||"*";n.writeHead(204,{"Access-Control-Allow-Origin":s,"Access-Control-Allow-Methods":"POST, OPTIONS","Access-Control-Allow-Headers":"Content-Type","Access-Control-Max-Age":"86400"}),n.end();}else if(t.url==="/__browser__"){let s=t.headers.origin||"*";n.writeHead(405,{"Content-Type":"application/json","Access-Control-Allow-Origin":s}),n.end(JSON.stringify({error:"Method not allowed"}));}else a();}),console.log("[BrowserLogs] Logs will be written to:",r);},transformIndexHtml(e){return e.replace(/<head([^>]*)>/i,`<head$1>${o}`)}}}var j=`
|
|
774
750
|
import * as React from "react";
|
|
775
751
|
import * as ReactJSXDevRuntime from "react/jsx-dev-runtime";
|
|
776
752
|
|
|
@@ -902,8 +878,8 @@ export function jsxDEV(type, props, key, isStatic, source, self) {
|
|
|
902
878
|
|
|
903
879
|
return _jsxDEV(type, props, key, isStatic, source, self);
|
|
904
880
|
}
|
|
905
|
-
`;function
|
|
906
|
-
let config = ${JSON.stringify(
|
|
881
|
+
`;function v(){let r=false,o="";return {name:"vite-plugin-jsx-source-tagger",enforce:"pre",configResolved(e){r=e.command==="serve",o=e.root;},resolveId(e,t){return r&&e==="react/jsx-dev-runtime"&&!t?.includes("\0jsx-source")?"\0jsx-source/jsx-dev-runtime":null},load(e){return r&&e==="\0jsx-source/jsx-dev-runtime"?j.replace('const PROJECT_ROOT = "";',`const PROJECT_ROOT = ${JSON.stringify(o)};`):null}}}function _(r){let o="",e=false,t=null,n=r?.configPath||"./tailwind.config.ts",a="@amaster/tailwind-config",s="\0"+a,l=async()=>{let i=d__default.default.resolve(o,n);try{return await m__default.default.access(i),i}catch{if(n.endsWith(".ts")){let u=i.replace(/\.ts$/,".js");try{return await m__default.default.access(u),u}catch{return null}}else if(n.endsWith(".js")){let u=i.replace(/\.js$/,".ts");try{return await m__default.default.access(u),u}catch{return null}}return null}},c=async()=>{try{let i=await l();if(!i)return null;let u=await m__default.default.readFile(i,"utf-8"),p=await T__namespace.transform(u,{loader:i.endsWith(".ts")?"ts":"js",format:"esm",platform:"node"}),h=await import(`data:text/javascript;base64,${buffer.Buffer.from(p.code).toString("base64")}`);if(!h?.default)throw new Error("Invalid Tailwind config structure");try{let P=(await import('tailwindcss/resolveConfig.js')).default;t=P(h.default);}catch{t=h.default;}return t}catch{return null}};return {name:"vite-plugin-tailwind-config-sync",configResolved(i){o=i.root,e=i.command==="serve";},async buildStart(){e&&await c();},resolveId(i){if(i===a)return s},async load(i){if(i===s)return t||await c(),`
|
|
882
|
+
let config = ${JSON.stringify(t)};
|
|
907
883
|
|
|
908
884
|
let _updateConfig;
|
|
909
885
|
if (import.meta.hot) {
|
|
@@ -924,14 +900,14 @@ export default new Proxy(config, {
|
|
|
924
900
|
return target[prop];
|
|
925
901
|
}
|
|
926
902
|
});
|
|
927
|
-
`},configureServer(
|
|
903
|
+
`},configureServer(i){e&&(async()=>{try{let u=await l();u&&i.watcher.add(u);}catch{}})();},async handleHotUpdate({file:i,server:u}){let p=await l();if(!p||d__default.default.normalize(i)!==d__default.default.normalize(p))return;await c();let f=u.moduleGraph.getModuleById(s);return f?(u.moduleGraph.invalidateModule(f),[f]):[]}}}function w(r={}){let{designWidth:o=375,maxWidth:e=750,baseFontSize:t=12,minRootSize:n=12,maxRootSize:a=24}=r;return {name:"vite-plugin-taro-style-adapter",apply:"serve",transformIndexHtml(s){let l=`
|
|
928
904
|
<script data-taro-flexible="true">
|
|
929
905
|
(function() {
|
|
930
|
-
var designWidth = ${
|
|
931
|
-
var maxWidth = ${
|
|
932
|
-
var baseFontSize = ${
|
|
933
|
-
var minRootSize = ${
|
|
934
|
-
var maxRootSize = ${
|
|
906
|
+
var designWidth = ${o};
|
|
907
|
+
var maxWidth = ${e};
|
|
908
|
+
var baseFontSize = ${t};
|
|
909
|
+
var minRootSize = ${n};
|
|
910
|
+
var maxRootSize = ${a};
|
|
935
911
|
|
|
936
912
|
function setRootFontSize() {
|
|
937
913
|
var docEl = document.documentElement;
|
|
@@ -965,7 +941,7 @@ export default new Proxy(config, {
|
|
|
965
941
|
document.addEventListener('DOMContentLoaded', setRootFontSize);
|
|
966
942
|
})();
|
|
967
943
|
</script>
|
|
968
|
-
`;return s.replace("</head>",`${
|
|
944
|
+
`;return s.replace("</head>",`${l}
|
|
969
945
|
<style data-taro-adapter="true">
|
|
970
946
|
/* \u4EC5 H5 \u751F\u6548\uFF1A\u9690\u85CF Taro \u9875\u9762\u5BB9\u5668\u6EDA\u52A8\u6761\uFF0C\u4F46\u4ECD\u53EF\u6EDA\u52A8 */
|
|
971
947
|
.taro_page {
|
|
@@ -1011,5 +987,5 @@ export default new Proxy(config, {
|
|
|
1011
987
|
object-fit: contain;
|
|
1012
988
|
}
|
|
1013
989
|
</style>
|
|
1014
|
-
</head>`)}}}function
|
|
990
|
+
</head>`)}}}function y(r={}){let{ratio:o=2}=r;return {postcssPlugin:"postcss-rpx2px",Declaration(e){e.value.includes("rpx")&&(e.value=e.value.replace(/(-?\d*\.?\d+)rpx/gi,(t,n)=>{let a=parseFloat(n)/o;return a===0?"0":`${a}px`}));}}}y.postcss=true;function k(r={}){let{additional:o=[],autoInjectTaroApp:e=true,autoInjectVite:t=true}=r,n={},a=new Set(o);return e&&Object.keys(process.env).forEach(s=>{s.startsWith("TARO_APP_")&&a.add(s);}),t&&Object.keys(process.env).forEach(s=>{s.startsWith("VITE_")&&a.add(s);}),a.forEach(s=>{let l=process.env[s]||"";n[`process.env.${s}`]=JSON.stringify(l);}),n}function L(){return {"process.env.TARO_APP_API_BASE_URL":JSON.stringify(process.env.TARO_APP_API_BASE_URL||""),"process.env.VITE_API_BASE_URL":JSON.stringify(process.env.VITE_API_BASE_URL||"")}}function q(r={}){let o=r.isTaro??x__default.default.env.TARO_ENV==="h5",e=[b(),E()];return r.jsxSourceTagger!==false&&e.push(v()),r.tailwindConfigSync!==false&&e.push(_({configPath:r.tailwindConfigPath})),o&&(e.unshift(w(r.styleAdapter)),e.unshift({name:"dev-postcss-rpx2px-plugin",apply:"serve",config(t){typeof t.css?.postcss=="object"&&t.css?.postcss.plugins?.unshift(y());}})),x__default.default.env.WORKSPACE_GIT_REPO&&e.push(O()),e}exports.default=q;exports.editorBridgePlugin=b;exports.injectAmasterEnv=L;exports.injectTaroEnv=k;exports.jsxSourceTaggerPlugin=v;exports.routesExposePlugin=E;exports.rpx2pxPlugin=y;exports.tailwindConfigSyncPlugin=_;exports.taroStyleAdapterPlugin=w;//# sourceMappingURL=index.cjs.map
|
|
1015
991
|
//# sourceMappingURL=index.cjs.map
|