@amaster.ai/vite-plugins 1.0.0-beta.4 → 1.0.0-beta.41

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.js CHANGED
@@ -1,4 +1,68 @@
1
- import {createHash}from'crypto';import f,{readFileSync}from'fs';import b,{dirname,resolve}from'path';import {fileURLToPath}from'url';import E from'process';function _(r,e){let n=`${r}:${e}`;return createHash("md5").update(n).digest("hex").substring(0,12)}var T=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 y(){let r=false;return {name:"vite-plugin-component-id",enforce:"pre",configResolved(e){r=e.command==="serve";},transform(e,n){if(!r||!/\.(tsx|jsx)$/.test(n)||n.includes("node_modules")||!/<[a-z]/.test(e))return null;try{let t=e,o=/<([a-z][\da-z]*)(?=[\s/>])/g,a,i=[];for(;(a=o.exec(e))!==null;){let s=a[1];if(!s)continue;let d=a.index,c=a.index+a[0].length;if(!T.has(s))continue;let u=c,p=!1,g=!1;for(;u<e.length&&!p;)e[u]===">"&&(p=!0,e.substring(d,u).includes("data-node-component-id")&&(g=!0)),u++;g||i.push({index:d,tag:s,tagEndIndex:c});}let l=e;for(let s=i.length-1;s>=0;s--){let d=i[s];if(!d)continue;let{index:c,tagEndIndex:u}=d,p=_(n,c),g=l.substring(0,u),m=l.substring(u);t=`${g} data-node-component-id="${p}"${m}`,l=t;}return {code:t,map:null}}catch{return null}}}}var I=`<script>
1
+ import {createHash}from'crypto';import Te from'fs';import ye from'path';import et from'process';import Ne from'fs/promises';import {Buffer as Buffer$1}from'buffer';var Ct=Object.create;var Qe=Object.defineProperty;var $t=Object.getOwnPropertyDescriptor;var It=Object.getOwnPropertyNames;var Lt=Object.getPrototypeOf,Dt=Object.prototype.hasOwnProperty;var V=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var Mt=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Bt=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of It(t))!Dt.call(e,i)&&i!==r&&Qe(e,i,{get:()=>t[i],enumerable:!(n=$t(t,i))||n.enumerable});return e};var Ft=(e,t,r)=>(r=e!=null?Ct(Lt(e)):{},Bt(Qe(r,"default",{value:e,enumerable:true}),e));var Pt=Mt((Kr,Ot)=>{var Ve=Object.defineProperty,Vt=Object.getOwnPropertyDescriptor,Yt=Object.getOwnPropertyNames,Xt=Object.prototype.hasOwnProperty,Kt=(e,t)=>{for(var r in t)Ve(e,r,{get:t[r],enumerable:true});},Qt=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Yt(t))!Xt.call(e,i)&&i!==r&&Ve(e,i,{get:()=>t[i],enumerable:!(n=Vt(t,i))||n.enumerable});return e},Gt=e=>Qt(Ve({},"__esModule",{value:true}),e),Oe={};Kt(Oe,{analyzeMetafile:()=>Pr,analyzeMetafileSync:()=>jr,build:()=>Er,buildSync:()=>Tr,context:()=>_r,default:()=>Lr,formatMessages:()=>Or,formatMessagesSync:()=>Rr,initialize:()=>$r,stop:()=>Cr,transform:()=>kr,transformSync:()=>Ar,version:()=>xr});Ot.exports=Gt(Oe);function rt(e){let t=n=>{if(n===null)r.write8(0);else if(typeof n=="boolean")r.write8(1),r.write8(+n);else if(typeof n=="number")r.write8(2),r.write32(n|0);else if(typeof n=="string")r.write8(3),r.write(ne(n));else if(n instanceof Uint8Array)r.write8(4),r.write(n);else if(n instanceof Array){r.write8(5),r.write32(n.length);for(let i of n)t(i);}else {let i=Object.keys(n);r.write8(6),r.write32(i.length);for(let l of i)r.write(ne(l)),t(n[l]);}},r=new dt;return r.write32(0),r.write32(e.id<<1|+!e.isRequest),t(e.value),He(r.buf,r.len-4,0),r.buf.subarray(0,r.len)}function Zt(e){let t=()=>{switch(r.read8()){case 0:return null;case 1:return !!r.read8();case 2:return r.read32();case 3:return be(r.read());case 4:return r.read();case 5:{let s=r.read32(),d=[];for(let a=0;a<s;a++)d.push(t());return d}case 6:{let s=r.read32(),d={};for(let a=0;a<s;a++)d[be(r.read())]=t();return d}default:throw new Error("Invalid packet")}},r=new dt(e),n=r.read32(),i=(n&1)===0;n>>>=1;let l=t();if(r.ptr!==e.length)throw new Error("Invalid packet");return {id:n,isRequest:i,value:l}}var dt=class{constructor(e=new Uint8Array(1024)){this.buf=e,this.len=0,this.ptr=0;}_write(e){if(this.len+e>this.buf.length){let t=new Uint8Array((this.len+e)*2);t.set(this.buf),this.buf=t;}return this.len+=e,this.len-e}write8(e){let t=this._write(1);this.buf[t]=e;}write32(e){let t=this._write(4);He(this.buf,e,t);}write(e){let t=this._write(4+e.length);He(this.buf,e.length,t),this.buf.set(e,t+4);}_read(e){if(this.ptr+e>this.buf.length)throw new Error("Invalid packet");return this.ptr+=e,this.ptr-e}read8(){return this.buf[this._read(1)]}read32(){return pt(this.buf,this._read(4))}read(){let e=this.read32(),t=new Uint8Array(e),r=this._read(t.length);return t.set(this.buf.subarray(r,r+e)),t}},ne,be,ze;if(typeof TextEncoder<"u"&&typeof TextDecoder<"u"){let e=new TextEncoder,t=new TextDecoder;ne=r=>e.encode(r),be=r=>t.decode(r),ze='new TextEncoder().encode("")';}else if(typeof Buffer<"u")ne=e=>Buffer.from(e),be=e=>{let{buffer:t,byteOffset:r,byteLength:n}=e;return Buffer.from(t,r,n).toString()},ze='Buffer.from("")';else throw new Error("No UTF-8 codec found");if(!(ne("")instanceof Uint8Array))throw new Error(`Invariant violation: "${ze} instanceof Uint8Array" is incorrectly false
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 He(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 je=()=>null,q=e=>typeof e=="boolean"?null:"a boolean",v=e=>typeof e=="string"?null:"a string",Ce=e=>e instanceof RegExp?null:"a RegExp object",de=e=>typeof e=="number"&&e===(e|0)?null:"an integer",er=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",tr=e=>typeof e=="object"&&e!==null?null:"an array or an object",rr=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",nr=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",ir=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 or(e){let t=Object.create(null),r=o(e,t,"wasmURL",ir),n=o(e,t,"wasmModule",rr),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",Ce),u=o(t,r,"reserveProps",Ce),y=o(t,r,"mangleQuoted",q),k=o(t,r,"minify",q),E=o(t,r,"minifySyntax",q),A=o(t,r,"minifyWhitespace",q),F=o(t,r,"minifyIdentifiers",q),L=o(t,r,"lineLimit",de),U=o(t,r,"drop",G),z=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),$=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),j=o(t,r,"supported",Z),I=o(t,r,"pure",G),R=o(t,r,"keepNames",q),O=o(t,r,"platform",v),C=o(t,r,"tsconfigRaw",nr),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}`),C&&e.push(`--tsconfig-raw=${typeof C=="string"?C:JSON.stringify(C)}`),k&&e.push("--minify"),E&&e.push("--minify-syntax"),A&&e.push("--minify-whitespace"),F&&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(z&&e.push(`--drop-labels=${ve(z,"drop label")}`),N&&e.push(`--abs-paths=${ve(N,"abs paths")}`),c&&e.push(`--mangle-props=${$e(c)}`),u&&e.push(`--reserve-props=${$e(u)}`),y!==void 0&&e.push(`--mangle-quoted=${y}`),f&&e.push(`--jsx=${f}`),_&&e.push(`--jsx-factory=${_}`),P&&e.push(`--jsx-fragment=${P}`),$&&e.push(`--jsx-import-source=${$}`),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(j)for(let h in j){if(h.indexOf("=")>=0)throw new Error(`Invalid supported: ${h}`);let B=j[h];if(typeof B!="boolean")throw new Error(`Expected value for supported ${J(h)} to be a boolean, got ${typeof B} instead`);e.push(`--supported:${h}=${B}`);}if(I)for(let h of I)e.push(`--pure:${Q(h,"pure")}`);R&&e.push("--keep-names");}function sr(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),F=o(t,a,"metafile",q),L=o(t,a,"outfile",v),U=o(t,a,"outdir",v),z=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),$=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),j=o(t,a,"entryNames",v),I=o(t,a,"chunkNames",v),R=o(t,a,"assetNames",v),O=o(t,a,"inject",G),C=o(t,a,"banner",Z),N=o(t,a,"footer",Z),h=o(t,a,"entryPoints",tr),B=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),H=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"),F&&s.push("--metafile"),L&&s.push(`--outfile=${L}`),U&&s.push(`--outdir=${U}`),z&&s.push(`--outbase=${z}`),x&&s.push(`--tsconfig=${x}`),$&&s.push(`--packages=${$}`),w&&s.push(`--resolve-extensions=${ve(w,"resolve extension")}`),S&&s.push(`--public-path=${S}`),j&&s.push(`--entry-names=${j}`),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(C)for(let b in C){if(b.indexOf("=")>=0)throw new Error(`Invalid banner file type: ${b}`);s.push(`--banner:${b}=${Q(C[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:B,nodePaths:oe,mangleCache:wt(H)}}function ar(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=Zt(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 $=0,T=l++,p={},g={ref(){++$===1&&w&&w.ref();},unref(){--$===0&&(delete t[T],w&&w.unref());}};t[T]=p,g.ref(),lr(x,T,u,y,g,e,p,m,f,_,(S,j)=>{try{P(S,j);}finally{g.unref();}});},transform:({callName:x,refs:w,input:m,options:f,isTTY:_,fs:P,callback:$})=>{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:j}=ar(x,f,_,it),I={command:"transform",flags:S,inputFS:g!==null,input:g!==null?ne(g):typeof m=="string"?ne(m):m};j&&(I.mangleCache=j),u(w,I,(R,O)=>{if(R)return $(new Error(R),null);let C=Se(O.errors,T),N=Se(O.warnings,T),h=1,B=()=>{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),$(null,M);}};if(C.length>0)return $(_e("Transform failed",C,N),null);O.codeFS&&(h++,P.readFile(O.code,(M,D)=>{M!==null?$(M,null):(O.code=D,B());})),O.mapFS&&(h++,P.readFile(O.map,(M,D)=>{M!==null?$(M,null):(O.map=D,B());})),B();});}catch(S){let j=[];try{Me(j,f,{},_,it);}catch{}let I=fe(S,e,T,void 0,"");u(w,{command:"error",flags:j,error:I},()=>{I.detail=T.load(I.detail),$(_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={},$=o(f,P,"kind",v),T=o(f,P,"color",q),p=o(f,P,"terminalWidth",de);if(W(f,P,`in ${x}() call`),$===void 0)throw new Error(`Missing "kind" in ${x}() call`);if($!=="error"&&$!=="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:$==="warning"};T!==void 0&&(g.color=T),p!==void 0&&(g.terminalWidth=p),u(w,g,(S,j)=>{if(S)return _(new Error(S),null);_(null,j.messages);});},analyzeMetafile:({callName:x,refs:w,metafile:m,options:f,callback:_})=>{f===void 0&&(f={});let P={},$=o(f,P,"color",q),T=o(f,P,"verbose",q);W(f,P,`in ${x}() call`);let p={command:"analyze-metafile",metafile:m};$!==void 0&&(p.color=$),T!==void 0&&(p.verbose=T),u(w,p,(g,S)=>{if(g)return _(new Error(g),null);_(null,S.result);});}}}}function lr(e,t,r,n,i,l,s,d,a,c,u){let y=St(),k=e==="context",E=(L,U)=>{let z=[];try{Me(z,d,{},a,nt);}catch{}let x=fe(L,l,y,void 0,U);r(i,{command:"error",flags:z,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"),"");ur(t,r,n,i,l,s,d,A,y).then(L=>{if(!L.ok)return E(L.error,L.pluginName);try{F(L.requestPlugins,L.runOnEndCallbacks,L.scheduleOnDisposeCallbacks);}catch(U){E(U,"");}},L=>E(L,""));return}try{F(null,(L,U)=>U([],[]),()=>{});}catch(L){E(L,"");}function F(L,U,z){let x=l.hasFS,{entries:w,flags:m,write:f,stdinContents:_,stdinResolveDir:P,absWorkingDir:$,nodePaths:T,mangleCache:p}=sr(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,nodePaths:T,context:k};L&&(g.plugins=L),p&&(g.mangleCache=p);let S=(R,O)=>{let C={errors:Se(R.errors,y),warnings:Se(R.warnings,y),outputFiles:void 0,metafile:void 0,mangleCache:void 0},N=C.errors.slice(),h=C.warnings.slice();R.outputFiles&&(C.outputFiles=R.outputFiles.map(fr)),R.metafile&&(C.metafile=JSON.parse(R.metafile)),R.mangleCache&&(C.mangleCache=R.mangleCache),R.writeToStdout!==void 0&&console.log(be(R.writeToStdout).replace(/\n$/,"")),U(C,(B,M)=>{if(N.length>0||B.length>0){let D=_e("Build failed",N.concat(B),h.concat(M));return O(D,null,B,M)}O(null,C,B,M);});},j,I;k&&(s["on-end"]=(R,O)=>new Promise(C=>{S(O,(N,h,B,M)=>{let D={errors:B,warnings:M};I&&I(N,h),j=void 0,I=void 0,n(R,D),C();});})),r(i,g,(R,O)=>{if(R)return u(new Error(R),null);if(!k)return S(O,(h,B)=>(z(),u(h,B)));if(O.errors.length>0)return u(_e("Context failed",O.errors,O.warnings),null);let C=false,N={rebuild:()=>(j||(j=new Promise((h,B)=>{let M;I=(K,H)=>{M||(M=()=>K?B(K):h(H));};let D=()=>{r(i,{command:"rebuild",key:t},(H,oe)=>{H?B(new Error(H)):M?M():D();});};D();})),j),watch:(h={})=>new Promise((B,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 H={command:"watch",key:t};K&&(H.delay=K),r(i,H,oe=>{oe?M(new Error(oe)):B(void 0);});}),serve:(h={})=>new Promise((B,M)=>{if(!l.hasFS)throw new Error('Cannot use the "serve" API in this environment');let D={},K=o(h,D,"port",er),H=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),H!==void 0&&(te.host=H),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,jt)=>{ae(jt.args),n(Rt,{});}),B(he);});}),cancel:()=>new Promise(h=>{if(C)return h();r(i,{command:"cancel",key:t},()=>{h();});}),dispose:()=>new Promise(h=>{if(C)return h();C=true,r(i,{command:"dispose",key:t},()=>{h(),z(),i.unref();});})};i.ref(),u(null,N);});}}var ur=async(e,t,r,n,i,l,s,d,a)=>{let c=[],u=[],y={},k={},E=[],A=0,F=0,L=[],U=false;d=[...d];for(let w of d){let m={};if(typeof w!="object")throw new Error(`Plugin at index ${F} must be an object`);let f=o(w,m,"name",v);if(typeof f!="string"||f==="")throw new Error(`Plugin at index ${F} 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:[]};F++;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),j=o(g,S,"pluginName",v),I=o(g,S,"importer",v),R=o(g,S,"namespace",v),O=o(g,S,"resolveDir",v),C=o(g,S,"kind",v),N=o(g,S,"pluginData",je),h=o(g,S,"with",Z);return W(g,S,"in resolve() call"),new Promise((B,M)=>{let D={command:"resolve",path:p,key:e,pluginName:f};if(j!=null&&(D.pluginName=j),I!=null&&(D.importer=I),R!=null&&(D.namespace=R),O!=null&&(D.resolveDir=O),C!=null)D.kind=C;else throw new Error('Must specify "kind" when calling "resolve"');N!=null&&(D.pluginData=a.store(N)),h!=null&&(D.with=cr(h,"with")),t(n,D,(K,H)=>{K!==null?M(new Error(K)):B({errors:Se(H.errors,a),warnings:Se(H.warnings,a),path:H.path,external:H.external,sideEffects:H.sideEffects,namespace:H.namespace,suffix:H.suffix,pluginData:a.load(H.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:',j=Ae(new Error(S),i,"onResolve"),I={},R=o(p,I,"filter",Ce),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 C=A++;y[C]={name:f,callback:g,note:j},P.onResolve.push({id:C,filter:$e(R),namespace:O||""});},onLoad(p,g){let S='This error came from the "onLoad" callback registered here:',j=Ae(new Error(S),i,"onLoad"),I={},R=o(p,I,"filter",Ce),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 C=A++;k[C]={name:f,callback:g,note:j},P.onLoad.push({id:C,filter:$e(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:$})=>{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,$&&$(),_));}})),r(w,f);},l["on-resolve"]=async(w,m)=>{let f={},_="",P,$;for(let T of m.ids)try{({name:_,callback:P,note:$}=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),j=o(p,g,"path",v),I=o(p,g,"namespace",v),R=o(p,g,"suffix",v),O=o(p,g,"external",q),C=o(p,g,"sideEffects",q),N=o(p,g,"pluginData",je),h=o(p,g,"errors",le),B=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),j!=null&&(f.path=j),I!=null&&(f.namespace=I),R!=null&&(f.suffix=R),O!=null&&(f.external=O),C!=null&&(f.sideEffects=C),N!=null&&(f.pluginData=a.store(N)),h!=null&&(f.errors=ue(h,"errors",a,_,void 0)),B!=null&&(f.warnings=ue(B,"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,$&&$(),_)]};break}r(w,f);},l["on-load"]=async(w,m)=>{let f={},_="",P,$;for(let T of m.ids)try{({name:_,callback:P,note:$}=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),j=o(p,g,"contents",yt),I=o(p,g,"resolveDir",v),R=o(p,g,"pluginData",je),O=o(p,g,"loader",v),C=o(p,g,"errors",le),N=o(p,g,"warnings",le),h=o(p,g,"watchFiles",G),B=o(p,g,"watchDirs",G);W(p,g,`from onLoad() callback in plugin ${J(_)}`),f.id=T,S!=null&&(f.pluginName=S),j instanceof Uint8Array?f.contents=j:j!=null&&(f.contents=ne(j)),I!=null&&(f.resolveDir=I),R!=null&&(f.pluginData=a.store(R)),O!=null&&(f.loader=O),C!=null&&(f.errors=ue(C,"errors",a,_,void 0)),N!=null&&(f.warnings=ue(N,"warnings",a,_,void 0)),h!=null&&(f.watchFiles=Re(h,"watchFiles")),B!=null&&(f.watchDirs=Re(B,"watchDirs"));break}}catch(p){f={id:T,errors:[fe(p,i,a,$&&$(),_)]};break}r(w,f);};let z=(w,m)=>m([],[]);u.length>0&&(z=(w,m)=>{(async()=>{let f=[],_=[];for(let{name:P,callback:$,note:T}of u){let p,g;try{let S=await $(w);if(S!=null){if(typeof S!="object")throw new Error(`Expected onEnd() callback in plugin ${J(P)} to return an object`);let j={},I=o(S,j,"errors",le),R=o(S,j,"warnings",le);W(S,j,`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:z,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",je),F=`in element ${s} of "${t}"`;W(d,a,F);let L=[];if(E)for(let U of E){let z={},x=o(U,z,"text",v),w=o(U,z,"location",ot);W(U,z,F),L.push({text:x||"",location:st(w,F,i)});}l.push({id:c||"",pluginName:u||n,text:y||"",location:st(k,F,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 cr(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 fr({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 $e(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,dr=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 pr(){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 gr(){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 mr(e,t){let r=re.dirname(V.resolve("esbuild"));return re.join(r,`downloaded-${e.replace("/","-")}-${re.basename(t)}`)}function hr(){if(dr(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}=pr(),n;try{n=V.resolve(`${e}/${t}`);}catch(i){if(n=mr(e,t),!ce.existsSync(n)){try{V.resolve(e);}catch{let l=gr();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"),yr=V("crypto"),We=V("path"),pe=V("fs"),wr=V("os"),vr=V("tty"),Y;if(process.env.ESBUILD_WORKER_THREADS!=="0"){try{Y=V("worker_threads");}catch{}let[e,t]=process.versions.node.split(".");(+e<12||+e==12&&+t<17||+e==13&&+t<13)&&(Y=void 0);}var ft,Pe=((ft=Y?.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}=hr();return t?["node",[e]]:[e,[]]}},ke=()=>vr.isatty(2),br={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);}}},Sr={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);}}},xr="0.27.2",Er=e=>me().build(e),_r=e=>me().context(e),kr=(e,t)=>me().transform(e,t),Or=(e,t)=>me().formatMessages(e,t),Pr=(e,t)=>me().analyzeMetafile(e,t),Tr=e=>{if(Y&&!Pe)return X||(X=Fe(Y)),X.buildSync(e);let t;return Be(r=>r.buildOrContext({callName:"buildSync",refs:null,options:e,isTTY:ke(),defaultWD:ge,callback:(n,i)=>{if(n)throw n;t=i;}})),t},Ar=(e,t)=>{if(Y&&!Pe)return X||(X=Fe(Y)),X.transformSync(e,t);let r;return Be(n=>n.transform({callName:"transformSync",refs:null,input:e,options:t||{},isTTY:ke(),fs:br,callback:(i,l)=>{if(i)throw i;r=l;}})),r},Rr=(e,t)=>{if(Y&&!Pe)return X||(X=Fe(Y)),X.formatMessagesSync(e,t);let r;return Be(n=>n.formatMessages({callName:"formatMessagesSync",refs:null,messages:e,options:t,callback:(i,l)=>{if(i)throw i;r=l;}})),r},jr=(e,t)=>{if(Y&&!Pe)return X||(X=Fe(Y)),X.analyzeMetafileSync(e,t);let r;return Be(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},Cr=()=>(De&&De(),X&&X.stop(),Promise.resolve()),Je=false,$r=e=>{if(e=or(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:Sr,callback:(A,F)=>A?E(A):k(F)})),formatMessages:(u,y)=>new Promise((k,E)=>l.formatMessages({callName:"formatMessages",refs:c,messages:u,options:y,callback:(A,F)=>A?E(A):k(F)})),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,F)=>A?E(A):k(F)}))},Ee},Be=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(wr.tmpdir(),`esbuild-${yr.randomBytes(32).toString("hex")}`),X=null,Fe=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 F=Atomics.wait(E,0,0);if(F!=="ok"&&F!=="not-equal")throw new Error("Internal error: Atomics.wait() failed: "+F);let{message:{id:L,resolve:U,reject:z,properties:x}}=e.receiveMessageOnPort(t);if(y!==L)throw new Error(`Internal error: Expected id ${y} but got id ${L}`);if(z)throw d(z,x),z;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(),X=null;}}},Ir=()=>{let e=Y.workerData.workerPort,t=Y.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=Y.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&&Ir();var Lr=Oe;});function qt(e,t){let r=`${e}:${t}`;return 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 zt(){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),F=a.substring(k);n=`${A} data-node-component-id="${E}"${F}`,a=n;}return {code:n,map:null}}catch{return null}}}}var Ht=`<script>
2
66
  document.addEventListener("click", (e) => {
3
67
  const element = e.target;
4
68
  const noJumpOut = document.body.classList.contains("forbid-jump-out")
@@ -16,15 +80,55 @@ document.addEventListener("click", (e) => {
16
80
  e.preventDefault();
17
81
  }
18
82
  });
19
- </script>`;function H(){try{let r=fileURLToPath(import.meta.url),e=dirname(r),n=resolve(e,"../dist/bridge.bridge.js");return `<script>
20
- ${readFileSync(n,"utf-8")}
21
- </script>`}catch(r){return console.warn("Failed to read bridge script:",r),""}}function h(){let r=false,e="";return {name:"vite-plugin-editor-bridge",configResolved(n){r=n.command==="serve",r&&(e=H());},transformIndexHtml(n){let o=`${I}${r?e:""}</body>`;return n.replace("</body>",o)}}}function v(r){let e=false,n=r?.routesFilePath||"src/routes.tsx";return {name:"vite-plugin-routes-expose",enforce:"post",configResolved(t){e=t.command==="serve";},transform(t,o){if(!e||!o.endsWith(n))return null;try{return t.includes("window.__APP_ROUTES__")?null:{code:`${t}
83
+ </script>`,Wt=`<script>
84
+ (function() {
85
+ const SOURCE_KEY = Symbol.for("__jsxSource__");
86
+ const SESSION_KEY = import.meta.env.VITE_AMASTER_KEY;
87
+
88
+ // Expose minimal API for external bridge script
89
+ window.__AMASTER_BRIDGE__ = {
90
+ getSourceInfo: (element) => element?.[SOURCE_KEY],
91
+ getSourceMap: () => window.sourceElementMap,
92
+ postToParent: (type, data) => {
93
+ window.parent.postMessage({ type, data, key: SESSION_KEY }, "*");
94
+ },
95
+ isDev: import.meta.env.DEV,
96
+ };
97
+
98
+ // Listen for bridge script URL from platform
99
+ window.addEventListener("message", (event) => {
100
+ const { type, data, key } = event.data;
101
+
102
+ if (key !== SESSION_KEY) {
103
+ console.warn("[Bridge] Invalid session key");
104
+ return;
105
+ }
106
+
107
+ if (type === "amaster.loadBridge" && data?.scriptUrl) {
108
+ const script = document.createElement("script");
109
+ script.src = data.scriptUrl;
110
+ script.onload = () => {
111
+ console.log("[Bridge] External script loaded");
112
+ window.__AMASTER_BRIDGE__?.postToParent("amaster.bridge.ready", {});
113
+ };
114
+ script.onerror = () => {
115
+ console.error("[Bridge] Failed to load external script");
116
+ };
117
+ document.head.appendChild(script);
118
+ }
119
+ });
120
+
121
+ window.addEventListener("load", () => {
122
+ window.__AMASTER_BRIDGE__?.postToParent("amaster.bridge.initialized", {});
123
+ });
124
+ })();
125
+ </script>`;function Ge(){let e=false;return {name:"vite-plugin-editor-bridge",configResolved(t){e=t.command==="serve";},transformIndexHtml(t){if(!e)return t;let r=`${Ht}${Wt}</body>`;return t.replace("</body>",r)}}}function Ze(e){let t=false,r=e?.routesFilePath||"src/routes.tsx";return {name:"vite-plugin-routes-expose",enforce:"post",configResolved(n){t=n.command==="serve";},transform(n,i){if(!t||!i.endsWith(r))return null;try{return n.includes("window.__APP_ROUTES__")?null:{code:`${n}
22
126
 
23
127
  // Development mode: Expose routes to window.__APP_ROUTES__
24
128
  if (typeof window !== 'undefined') {
25
129
  window.__APP_ROUTES__ = typeof routes !== 'undefined' && Array.isArray(routes) ? routes : [];
26
130
  }
27
- `,map:null}}catch{return null}}}}function w(){let r="",e=`
131
+ `,map:null}}catch{return null}}}}function tt(){let e="",t=`
28
132
  <script>
29
133
  (function() {
30
134
  'use strict';
@@ -490,6 +594,170 @@ if (typeof window !== 'undefined') {
490
594
  addLog(entry);
491
595
  });
492
596
 
597
+ // ============================================
598
+ // Vite deps 504 error capture using PerformanceObserver
599
+ // Only captures 504 errors for node_modules/.vite resources (pre-bundled dependencies)
600
+ // ============================================
601
+ var reportedUrls = {}; // Track reported URLs to avoid duplicates
602
+
603
+ if (typeof PerformanceObserver !== 'undefined') {
604
+ var perfObserver = new PerformanceObserver(function(list) {
605
+ var entries = list.getEntries();
606
+ for (var i = 0; i < entries.length; i++) {
607
+ var perfEntry = entries[i];
608
+ // Only check script resources
609
+ if (perfEntry.initiatorType !== 'script') {
610
+ continue;
611
+ }
612
+
613
+ var resourceUrl = perfEntry.name || '';
614
+ // Only report errors for node_modules/.vite resources
615
+ if (resourceUrl.indexOf('node_modules/.vite') === -1 && resourceUrl.indexOf('/node_modules/.vite') === -1) {
616
+ continue;
617
+ }
618
+
619
+ // Check if response status is 504 (Gateway Timeout)
620
+ // responseStatus is available in Resource Timing Level 2
621
+ var status = perfEntry.responseStatus;
622
+ if (status === 504) {
623
+ // Avoid duplicate reports
624
+ if (reportedUrls[resourceUrl]) {
625
+ continue;
626
+ }
627
+ reportedUrls[resourceUrl] = true;
628
+
629
+ var entry = {
630
+ type: 'vite-deps-error',
631
+ timestamp: new Date().toISOString(),
632
+ level: 'error',
633
+ url: resourceUrl,
634
+ status: 504,
635
+ message: 'Vite pre-bundled dependency returned 504 Gateway Timeout: ' + resourceUrl,
636
+ duration: perfEntry.duration,
637
+ transferSize: perfEntry.transferSize
638
+ };
639
+ addLog(entry);
640
+ }
641
+ }
642
+ });
643
+
644
+ try {
645
+ perfObserver.observe({ type: 'resource', buffered: true });
646
+ } catch (e) {
647
+ // Fallback for browsers that don't support the options
648
+ try {
649
+ perfObserver.observe({ entryTypes: ['resource'] });
650
+ } catch (e2) {
651
+ originalConsole.warn('[BrowserLogs] PerformanceObserver not supported:', e2.message);
652
+ }
653
+ }
654
+ }
655
+
656
+ // ============================================
657
+ // Script load error capture (for 504 and other network errors)
658
+ // This captures errors that PerformanceObserver might miss
659
+ // ============================================
660
+
661
+ // Use MutationObserver to watch for dynamically added script tags
662
+ function attachScriptErrorHandler(script) {
663
+ if (script.__errorHandlerAttached__) return;
664
+ script.__errorHandlerAttached__ = true;
665
+
666
+ script.addEventListener('error', function(event) {
667
+ var src = script.src || '';
668
+
669
+ // Only report errors for node_modules/.vite resources
670
+ if (src.indexOf('node_modules/.vite') === -1 && src.indexOf('/node_modules/.vite') === -1) {
671
+ return;
672
+ }
673
+
674
+ // Avoid duplicate reports
675
+ if (reportedUrls[src]) {
676
+ return;
677
+ }
678
+ reportedUrls[src] = true;
679
+
680
+ var entry = {
681
+ type: 'vite-deps-error',
682
+ timestamp: new Date().toISOString(),
683
+ level: 'error',
684
+ url: src,
685
+ status: 'load-error',
686
+ message: 'Vite pre-bundled dependency failed to load (possibly 504 Gateway Timeout): ' + src,
687
+ errorType: event.type
688
+ };
689
+ addLog(entry);
690
+ });
691
+ }
692
+
693
+ // Attach error handlers to existing scripts
694
+ var existingScripts = document.querySelectorAll('script[src]');
695
+ for (var i = 0; i < existingScripts.length; i++) {
696
+ attachScriptErrorHandler(existingScripts[i]);
697
+ }
698
+
699
+ // Watch for dynamically added scripts
700
+ if (typeof MutationObserver !== 'undefined') {
701
+ var scriptObserver = new MutationObserver(function(mutations) {
702
+ for (var i = 0; i < mutations.length; i++) {
703
+ var mutation = mutations[i];
704
+ for (var j = 0; j < mutation.addedNodes.length; j++) {
705
+ var node = mutation.addedNodes[j];
706
+ if (node.nodeName === 'SCRIPT' && node.src) {
707
+ attachScriptErrorHandler(node);
708
+ }
709
+ // Also check child nodes
710
+ if (node.querySelectorAll) {
711
+ var scripts = node.querySelectorAll('script[src]');
712
+ for (var k = 0; k < scripts.length; k++) {
713
+ attachScriptErrorHandler(scripts[k]);
714
+ }
715
+ }
716
+ }
717
+ }
718
+ });
719
+
720
+ scriptObserver.observe(document.documentElement, {
721
+ childList: true,
722
+ subtree: true
723
+ });
724
+ }
725
+
726
+ // Also intercept document.createElement to catch scripts before they're added to DOM
727
+ var originalCreateElement = document.createElement.bind(document);
728
+ document.createElement = function(tagName) {
729
+ var element = originalCreateElement(tagName);
730
+ if (tagName.toLowerCase() === 'script') {
731
+ // Use a setter to catch when src is set
732
+ var originalSrc = '';
733
+ Object.defineProperty(element, '__originalSrc__', {
734
+ get: function() { return originalSrc; },
735
+ set: function(val) { originalSrc = val; }
736
+ });
737
+
738
+ // Defer attaching error handler until src is set
739
+ var srcDescriptor = Object.getOwnPropertyDescriptor(HTMLScriptElement.prototype, 'src');
740
+ if (srcDescriptor && srcDescriptor.set) {
741
+ var originalSrcSetter = srcDescriptor.set;
742
+ Object.defineProperty(element, 'src', {
743
+ get: function() {
744
+ return srcDescriptor.get ? srcDescriptor.get.call(this) : this.getAttribute('src');
745
+ },
746
+ set: function(value) {
747
+ if (originalSrcSetter) {
748
+ originalSrcSetter.call(this, value);
749
+ } else {
750
+ this.setAttribute('src', value);
751
+ }
752
+ attachScriptErrorHandler(this);
753
+ },
754
+ configurable: true
755
+ });
756
+ }
757
+ }
758
+ return element;
759
+ };
760
+
493
761
  window.addEventListener('unhandledrejection', function(event) {
494
762
  var entry = {
495
763
  type: 'error',
@@ -541,6 +809,247 @@ if (typeof window !== 'undefined') {
541
809
 
542
810
  originalConsole.log('[BrowserLogs] Log collection started');
543
811
  })();
544
- </script>`;return {name:"vite-plugin-browser-logs",configResolved(n){let t=n.root||E.cwd();r=b.join(t,"browser.log");},configureServer(n){n.middlewares.use((t,o,a)=>{if(t.url==="/__browser__"&&t.method==="POST"){let i=t.headers.origin||"*",l="";t.on("data",s=>{l+=s.toString();}),t.on("end",()=>{try{let s=b.dirname(r);f.existsSync(s)||f.mkdirSync(s,{recursive:!0}),f.appendFileSync(r,`${l}
545
- `,"utf-8"),o.writeHead(200,{"Content-Type":"application/json","Access-Control-Allow-Origin":i,"Access-Control-Allow-Methods":"POST, OPTIONS","Access-Control-Allow-Headers":"Content-Type"}),o.end(JSON.stringify({success:!0}));}catch(s){console.error("[BrowserLogs] Write error:",s),o.writeHead(500,{"Content-Type":"application/json","Access-Control-Allow-Origin":i,"Access-Control-Allow-Methods":"POST, OPTIONS","Access-Control-Allow-Headers":"Content-Type"}),o.end(JSON.stringify({success:false,error:String(s)}));}});}else if(t.url==="/__browser__"&&t.method==="OPTIONS"){let i=t.headers.origin||"*";o.writeHead(204,{"Access-Control-Allow-Origin":i,"Access-Control-Allow-Methods":"POST, OPTIONS","Access-Control-Allow-Headers":"Content-Type","Access-Control-Max-Age":"86400"}),o.end();}else if(t.url==="/__browser__"){let i=t.headers.origin||"*";o.writeHead(405,{"Content-Type":"application/json","Access-Control-Allow-Origin":i}),o.end(JSON.stringify({error:"Method not allowed"}));}else a();}),console.log("[BrowserLogs] Logs will be written to:",r);},transformIndexHtml(n){return n.replace(/<head([^>]*)>/i,`<head$1>${e}`)}}}function L(r={}){let e=[y(),h(),v()];return E.env.WORKSPACE_GIT_REPO&&e.push(w()),e}export{y as componentIdPlugin,L as default,h as editorBridgePlugin,v as routesExposePlugin};//# sourceMappingURL=index.js.map
812
+ </script>`;return {name:"vite-plugin-browser-logs",configResolved(r){let n=et.env.WORKSPACE_DIR;if(n)e=ye.join(n,"browser.log");else {let i=r.root||et.cwd();for(;i!==ye.dirname(i)&&!Te.existsSync(ye.join(i,"package.json"));)i=ye.dirname(i);e=ye.join(i,"browser.log");}},configureServer(r){r.middlewares.use((n,i,l)=>{if(n.url==="/__browser__"&&n.method==="POST"){let s=n.headers.origin||"*",d="";n.on("data",a=>{d+=a.toString();}),n.on("end",()=>{try{let a=ye.dirname(e);Te.existsSync(a)||Te.mkdirSync(a,{recursive:!0}),Te.appendFileSync(e,`${d}
813
+ `,"utf-8"),i.writeHead(200,{"Content-Type":"application/json","Access-Control-Allow-Origin":s,"Access-Control-Allow-Methods":"POST, OPTIONS","Access-Control-Allow-Headers":"Content-Type"}),i.end(JSON.stringify({success:!0}));}catch(a){console.error("[BrowserLogs] Write error:",a),i.writeHead(500,{"Content-Type":"application/json","Access-Control-Allow-Origin":s,"Access-Control-Allow-Methods":"POST, OPTIONS","Access-Control-Allow-Headers":"Content-Type"}),i.end(JSON.stringify({success:false,error:String(a)}));}});}else if(n.url==="/__browser__"&&n.method==="OPTIONS"){let s=n.headers.origin||"*";i.writeHead(204,{"Access-Control-Allow-Origin":s,"Access-Control-Allow-Methods":"POST, OPTIONS","Access-Control-Allow-Headers":"Content-Type","Access-Control-Max-Age":"86400"}),i.end();}else if(n.url==="/__browser__"){let s=n.headers.origin||"*";i.writeHead(405,{"Content-Type":"application/json","Access-Control-Allow-Origin":s}),i.end(JSON.stringify({error:"Method not allowed"}));}else l();}),console.log("[BrowserLogs] Logs will be written to:",e);},transformIndexHtml(r){return r.replace(/<head([^>]*)>/i,`<head$1>${t}`)}}}var Jt=`
814
+ import * as React from "react";
815
+ import * as ReactJSXDevRuntime from "react/jsx-dev-runtime";
816
+
817
+ const _jsxDEV = ReactJSXDevRuntime.jsxDEV;
818
+ export const Fragment = ReactJSXDevRuntime.Fragment;
819
+
820
+ const SOURCE_KEY = Symbol.for("__jsxSource__");
821
+ const PROJECT_ROOT = "";
822
+
823
+ const cleanFileName = (fileName) => {
824
+ if (!fileName) return "";
825
+ // Remove project root prefix to get relative path
826
+ if (PROJECT_ROOT && fileName.startsWith(PROJECT_ROOT)) {
827
+ const relative = fileName.slice(PROJECT_ROOT.length);
828
+ return relative.startsWith("/") ? relative.slice(1) : relative;
829
+ }
830
+ return fileName;
831
+ };
832
+
833
+ // Global map to track elements by source location
834
+ const sourceElementMap = new Map();
835
+ window.sourceElementMap = sourceElementMap;
836
+
837
+ function getSourceKey(sourceInfo) {
838
+ return \`\${cleanFileName(sourceInfo.fileName)}:\${sourceInfo.lineNumber}:\${sourceInfo.columnNumber}\`;
839
+ }
840
+
841
+ function unregisterElement(node, sourceInfo) {
842
+ const key = getSourceKey(sourceInfo);
843
+ const refs = sourceElementMap.get(key);
844
+ if (refs) {
845
+ for (const ref of refs) {
846
+ if (ref.deref() === node) {
847
+ refs.delete(ref);
848
+ break;
849
+ }
850
+ }
851
+ if (refs.size === 0) {
852
+ sourceElementMap.delete(key);
853
+ }
854
+ }
855
+ }
856
+
857
+ function registerElement(node, sourceInfo) {
858
+ const key = getSourceKey(sourceInfo);
859
+ if (!sourceElementMap.has(key)) {
860
+ sourceElementMap.set(key, new Set());
861
+ }
862
+ sourceElementMap.get(key).add(new WeakRef(node));
863
+ }
864
+
865
+ function getTypeName(type) {
866
+ if (typeof type === "string") return type;
867
+ if (typeof type === "function") return type.displayName || type.name || "Unknown";
868
+ if (typeof type === "object" && type !== null) {
869
+ return type.displayName || type.render?.displayName || type.render?.name || "Unknown";
870
+ }
871
+ return "Unknown";
872
+ }
873
+
874
+ export function jsxDEV(type, props, key, isStatic, source, self) {
875
+ // For custom components, tag their rendered output
876
+ if (source?.fileName && typeof type !== "string" && type !== Fragment) {
877
+ const typeName = getTypeName(type);
878
+ const jsxSourceInfo = {
879
+ fileName: cleanFileName(source.fileName),
880
+ lineNumber: source.lineNumber,
881
+ columnNumber: source.columnNumber,
882
+ displayName: typeName,
883
+ };
884
+
885
+ const originalRef = props?.ref;
886
+ const enhancedProps = {
887
+ ...props,
888
+ ref: (node) => {
889
+ if (node) {
890
+ if (!node[SOURCE_KEY]) {
891
+ node[SOURCE_KEY] = jsxSourceInfo;
892
+ registerElement(node, jsxSourceInfo);
893
+ }
894
+ }
895
+ if (typeof originalRef === "function") {
896
+ originalRef(node);
897
+ } else if (originalRef && typeof originalRef === "object") {
898
+ originalRef.current = node;
899
+ }
900
+ },
901
+ };
902
+
903
+ return _jsxDEV(type, enhancedProps, key, isStatic, source, self);
904
+ }
905
+
906
+ // For host elements (div, span, etc.), tag with source info
907
+ if (source?.fileName && typeof type === "string") {
908
+ const sourceInfo = {
909
+ fileName: cleanFileName(source.fileName),
910
+ lineNumber: source.lineNumber,
911
+ columnNumber: source.columnNumber,
912
+ displayName: type,
913
+ };
914
+
915
+ const originalRef = props?.ref;
916
+
917
+ const enhancedProps = {
918
+ ...props,
919
+ ref: (node) => {
920
+ if (node) {
921
+ const existingSource = node[SOURCE_KEY];
922
+ if (existingSource) {
923
+ if (getSourceKey(existingSource) !== getSourceKey(sourceInfo)) {
924
+ unregisterElement(node, existingSource);
925
+ node[SOURCE_KEY] = sourceInfo;
926
+ registerElement(node, sourceInfo);
927
+ }
928
+ } else {
929
+ node[SOURCE_KEY] = sourceInfo;
930
+ registerElement(node, sourceInfo);
931
+ }
932
+ }
933
+ if (typeof originalRef === "function") {
934
+ originalRef(node);
935
+ } else if (originalRef && typeof originalRef === "object") {
936
+ originalRef.current = node;
937
+ }
938
+ },
939
+ };
940
+ return _jsxDEV(type, enhancedProps, key, isStatic, source, self);
941
+ }
942
+
943
+ return _jsxDEV(type, props, key, isStatic, source, self);
944
+ }
945
+ `;function Ue(){let e=false,t="";return {name:"vite-plugin-jsx-source-tagger",enforce:"pre",configResolved(r){e=r.command==="serve",t=r.root;},resolveId(r,n){return e&&r==="react/jsx-dev-runtime"&&!n?.includes("\0jsx-source")?"\0jsx-source/jsx-dev-runtime":null},load(r){return e&&r==="\0jsx-source/jsx-dev-runtime"?Jt.replace('const PROJECT_ROOT = "";',`const PROJECT_ROOT = ${JSON.stringify(t)};`):null}}}var Tt=Ft(Pt());function Xe(e){let t="",r=false,n=null,i=e?.configPath||"./tailwind.config.ts",l="@amaster/tailwind-config",s="\0"+l,d=async()=>{let c=ye.resolve(t,i);try{return await Ne.access(c),c}catch{if(i.endsWith(".ts")){let u=c.replace(/\.ts$/,".js");try{return await Ne.access(u),u}catch{return null}}else if(i.endsWith(".js")){let u=c.replace(/\.js$/,".ts");try{return await Ne.access(u),u}catch{return null}}return null}},a=async()=>{try{let c=await d();if(!c)return null;let u=await Ne.readFile(c,"utf-8"),y=await Tt.transform(u,{loader:c.endsWith(".ts")?"ts":"js",format:"esm",platform:"node"}),E=await import(`data:text/javascript;base64,${Buffer$1.from(y.code).toString("base64")}`);if(!E?.default)throw new Error("Invalid Tailwind config structure");try{let A=(await import('tailwindcss/resolveConfig.js')).default;n=A(E.default);}catch{n=E.default;}return n}catch{return null}};return {name:"vite-plugin-tailwind-config-sync",configResolved(c){t=c.root,r=c.command==="serve";},async buildStart(){r&&await a();},resolveId(c){if(c===l)return s},async load(c){if(c===s)return n||await a(),`
946
+ let config = ${JSON.stringify(n)};
947
+
948
+ let _updateConfig;
949
+ if (import.meta.hot) {
950
+ // Accept self updates
951
+ import.meta.hot.accept((newModule) => {
952
+ if (newModule && _updateConfig) {
953
+ _updateConfig(newModule.default);
954
+ }
955
+ });
956
+ }
957
+
958
+ export default new Proxy(config, {
959
+ get(target, prop) {
960
+ if (prop === 'then') return undefined;
961
+ if (prop === '__setUpdater') {
962
+ return (fn) => { _updateConfig = fn; };
963
+ }
964
+ return target[prop];
965
+ }
966
+ });
967
+ `},configureServer(c){r&&(async()=>{try{let u=await d();u&&c.watcher.add(u);}catch{}})();},async handleHotUpdate({file:c,server:u}){let y=await d();if(!y||ye.normalize(c)!==ye.normalize(y))return;await a();let k=u.moduleGraph.getModuleById(s);return k?(u.moduleGraph.invalidateModule(k),[k]):[]}}}function Ke(e={}){let{designWidth:t=375,maxWidth:r=750,baseFontSize:n=12,minRootSize:i=12,maxRootSize:l=24}=e;return {name:"vite-plugin-taro-style-adapter",apply:"serve",transformIndexHtml(s){let d=`
968
+ <script data-taro-flexible="true">
969
+ (function() {
970
+ var designWidth = ${t};
971
+ var maxWidth = ${r};
972
+ var baseFontSize = ${n};
973
+ var minRootSize = ${i};
974
+ var maxRootSize = ${l};
975
+
976
+ function setRootFontSize() {
977
+ var docEl = document.documentElement;
978
+ var clientWidth = docEl.clientWidth;
979
+
980
+ // \u9650\u5236\u6700\u5927\u5BBD\u5EA6
981
+ if (clientWidth > maxWidth) {
982
+ clientWidth = maxWidth;
983
+ }
984
+
985
+ // \u8BA1\u7B97\u6839\u5B57\u53F7: (\u5C4F\u5E55\u5BBD\u5EA6 / \u8BBE\u8BA1\u7A3F\u5BBD\u5EA6) * \u57FA\u51C6\u5B57\u53F7
986
+ var fontSize = (clientWidth / designWidth) * baseFontSize;
987
+
988
+ // \u5E94\u7528\u6700\u5C0F/\u6700\u5927\u9650\u5236
989
+ if (fontSize < minRootSize) {
990
+ fontSize = minRootSize;
991
+ } else if (fontSize > maxRootSize) {
992
+ fontSize = maxRootSize;
993
+ }
994
+
995
+ docEl.style.fontSize = fontSize + 'px';
996
+ }
997
+
998
+ setRootFontSize();
999
+
1000
+ // \u76D1\u542C\u7A97\u53E3\u53D8\u5316
1001
+ window.addEventListener('resize', setRootFontSize);
1002
+ window.addEventListener('orientationchange', setRootFontSize);
1003
+
1004
+ // \u9875\u9762\u663E\u793A\u65F6\u91CD\u65B0\u8BA1\u7B97\uFF08\u89E3\u51B3\u67D0\u4E9B\u6D4F\u89C8\u5668\u7684 bug\uFF09
1005
+ document.addEventListener('DOMContentLoaded', setRootFontSize);
1006
+ })();
1007
+ </script>
1008
+ `;return s.replace("</head>",`${d}
1009
+ <style data-taro-adapter="true">
1010
+ /* \u4EC5 H5 \u751F\u6548\uFF1A\u9690\u85CF Taro \u9875\u9762\u5BB9\u5668\u6EDA\u52A8\u6761\uFF0C\u4F46\u4ECD\u53EF\u6EDA\u52A8 */
1011
+ .taro_page {
1012
+ -ms-overflow-style: none; /* IE/Edge \u8001\u7248 */
1013
+ scrollbar-width: none; /* Firefox */
1014
+ }
1015
+
1016
+ .taro_page::-webkit-scrollbar {
1017
+ width: 0;
1018
+ height: 0;
1019
+ display: none; /* Chrome/Safari */
1020
+ }
1021
+
1022
+ /* \u9690\u85CF Taro ScrollView \u7EC4\u4EF6\u7684\u6EDA\u52A8\u6761 */
1023
+ .taro-scroll-view__scroll-y,
1024
+ .taro-scroll-view__scroll-x {
1025
+ -ms-overflow-style: none; /* IE/Edge \u8001\u7248 */
1026
+ scrollbar-width: none; /* Firefox */
1027
+ }
1028
+
1029
+ .taro-scroll-view__scroll-y::-webkit-scrollbar,
1030
+ .taro-scroll-view__scroll-x::-webkit-scrollbar {
1031
+ width: 0;
1032
+ height: 0;
1033
+ display: none; /* Chrome/Safari */
1034
+ }
1035
+
1036
+ /*
1037
+ * \u4FEE\u590D Taro Image \u7EC4\u4EF6\u5728 H5 \u4E0B\u7684\u5C3A\u5BF8\u95EE\u9898
1038
+ *
1039
+ * \u95EE\u9898\uFF1ATaro Image \u7EC4\u4EF6\u4F7F\u7528 aspectFit \u6A21\u5F0F\u65F6\uFF0C\u5185\u90E8 img \u4F7F\u7528 max-width/max-height: 100%
1040
+ * \u5BFC\u81F4\u5C0F\u5C3A\u5BF8\u56FE\u7247\uFF08\u5982 SVG \u56FE\u6807\uFF09\u65E0\u6CD5\u6309\u6307\u5B9A\u5C3A\u5BF8\u663E\u793A\uFF0C\u53EA\u663E\u793A\u539F\u59CB\u5C3A\u5BF8
1041
+ *
1042
+ * \u89E3\u51B3\uFF1A\u8BA9 img \u586B\u6EE1 taro-image-core \u5BB9\u5668\uFF0C\u7531\u5BB9\u5668\u63A7\u5236\u5C3A\u5BF8
1043
+ */
1044
+ taro-image-core img.taro-img__mode-aspectfit {
1045
+ width: 100%;
1046
+ height: 100%;
1047
+ max-width: none;
1048
+ max-height: none;
1049
+ position: static;
1050
+ transform: none;
1051
+ object-fit: contain;
1052
+ }
1053
+ </style>
1054
+ </head>`)}}}function qe(e={}){let{ratio:t=2}=e;return {postcssPlugin:"postcss-rpx2px",Declaration(r){r.value.includes("rpx")&&(r.value=r.value.replace(/(-?\d*\.?\d+)rpx/gi,(n,i)=>{let l=parseFloat(i)/t;return l===0?"0":`${l}px`}));}}}qe.postcss=true;function Mr(e={}){let{additional:t=[],autoInjectTaroApp:r=true,autoInjectVite:n=true}=e,i={},l=new Set(t);return r&&Object.keys(process.env).forEach(s=>{s.startsWith("TARO_APP_")&&l.add(s);}),n&&Object.keys(process.env).forEach(s=>{s.startsWith("VITE_")&&l.add(s);}),l.forEach(s=>{let d=process.env[s]||"";i[`process.env.${s}`]=JSON.stringify(d);}),i}function Br(){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 Fr(e={}){let t=e.isTaro??et.env.TARO_ENV==="h5",r=[Ge(),Ze()];return e.jsxSourceTagger!==false&&r.push(Ue()),e.tailwindConfigSync!==false&&r.push(Xe({configPath:e.tailwindConfigPath})),t&&(r.unshift(Ke(e.styleAdapter)),r.unshift({name:"dev-postcss-rpx2px-plugin",apply:"serve",config(n){typeof n.css?.postcss=="object"&&n.css?.postcss.plugins?.unshift(qe());}})),et.env.WORKSPACE_GIT_REPO&&r.push(tt()),r}export{zt as componentIdPlugin,Fr as default,Ge as editorBridgePlugin,Br as injectAmasterEnv,Mr as injectTaroEnv,Ue as jsxSourceTaggerPlugin,Ze as routesExposePlugin,qe as rpx2pxPlugin,Xe as tailwindConfigSyncPlugin,Ke as taroStyleAdapterPlugin};//# sourceMappingURL=index.js.map
546
1055
  //# sourceMappingURL=index.js.map