@amaster.ai/vite-plugins 1.0.0-beta.39 → 1.0.0-beta.40
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/bridge.bridge.js +1 -24
- package/dist/index.cjs +285 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +177 -16
- package/dist/index.d.ts +177 -16
- package/dist/index.js +285 -8
- package/dist/index.js.map +1 -1
- package/package.json +22 -6
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,68 @@
|
|
|
1
|
-
'use strict';Object.defineProperty(exports,'__esModule',{value:true});var crypto=require('crypto'),
|
|
1
|
+
'use strict';Object.defineProperty(exports,'__esModule',{value:true});var crypto=require('crypto'),Te=require('fs'),ye=require('path'),url=require('url'),et=require('process'),Ne=require('fs/promises'),buffer=require('buffer');var _documentCurrentScript=typeof document!=='undefined'?document.currentScript:null;function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var Te__default=/*#__PURE__*/_interopDefault(Te);var ye__default=/*#__PURE__*/_interopDefault(ye);var et__default=/*#__PURE__*/_interopDefault(et);var Ne__default=/*#__PURE__*/_interopDefault(Ne);var jt=Object.create;var Qe=Object.defineProperty;var Ct=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 Ft=(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=Ct(t,i))||n.enumerable});return e};var Bt=(e,t,r)=>(r=e!=null?jt(Lt(e)):{},Ft(Qe(r,"default",{value:e,enumerable:true}),e));var Pt=Mt((nn,Ot)=>{var Ve=Object.defineProperty,Qt=Object.getOwnPropertyDescriptor,Gt=Object.getOwnPropertyNames,Zt=Object.prototype.hasOwnProperty,er=(e,t)=>{for(var r in t)Ve(e,r,{get:t[r],enumerable:true});},tr=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Gt(t))!Zt.call(e,i)&&i!==r&&Ve(e,i,{get:()=>t[i],enumerable:!(n=Qt(t,i))||n.enumerable});return e},rr=e=>tr(Ve({},"__esModule",{value:true}),e),Oe={};er(Oe,{analyzeMetafile:()=>$r,analyzeMetafileSync:()=>Lr,build:()=>Pr,buildSync:()=>jr,context:()=>Tr,default:()=>Br,formatMessages:()=>Rr,formatMessagesSync:()=>Ir,initialize:()=>Mr,stop:()=>Dr,transform:()=>Ar,transformSync:()=>Cr,version:()=>Or});Ot.exports=rr(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),ze(r.buf,r.len-4,0),r.buf.subarray(0,r.len)}function nr(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);ze(this.buf,e,t);}write(e){let t=this._write(4+e.length);ze(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,He;if(typeof TextEncoder<"u"&&typeof TextDecoder<"u"){let e=new TextEncoder,t=new TextDecoder;ne=r=>e.encode(r),be=r=>t.decode(r),He='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()},He='Buffer.from("")';else throw new Error("No UTF-8 codec found");if(!(ne("")instanceof Uint8Array))throw new Error(`Invariant violation: "${He} 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 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>
|
|
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,15 @@ document.addEventListener("click", (e) => {
|
|
|
16
80
|
e.preventDefault();
|
|
17
81
|
}
|
|
18
82
|
});
|
|
19
|
-
</script>`;function
|
|
20
|
-
${
|
|
21
|
-
</script>`}catch(
|
|
83
|
+
</script>`;function Yt(){try{let e=url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))),t=ye.dirname(e),r=ye.resolve(t,"../dist/bridge.bridge.js");return `<script>
|
|
84
|
+
${Te.readFileSync(r,"utf-8")}
|
|
85
|
+
</script>`}catch(e){return console.warn("Failed to read bridge script:",e),""}}function Ge(){let e=false,t="";return {name:"vite-plugin-editor-bridge",configResolved(r){e=r.command==="serve",e&&(t=Yt());},transformIndexHtml(r){if(!e)return r;let n=`${Xt}${t}</body>`;return r.replace("</body>",n)}}}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
86
|
|
|
23
87
|
// Development mode: Expose routes to window.__APP_ROUTES__
|
|
24
88
|
if (typeof window !== 'undefined') {
|
|
25
89
|
window.__APP_ROUTES__ = typeof routes !== 'undefined' && Array.isArray(routes) ? routes : [];
|
|
26
90
|
}
|
|
27
|
-
`,map:null}}catch{return null}}}}function
|
|
91
|
+
`,map:null}}catch{return null}}}}function tt(){let e="",t=`
|
|
28
92
|
<script>
|
|
29
93
|
(function() {
|
|
30
94
|
'use strict';
|
|
@@ -705,8 +769,203 @@ if (typeof window !== 'undefined') {
|
|
|
705
769
|
|
|
706
770
|
originalConsole.log('[BrowserLogs] Log collection started');
|
|
707
771
|
})();
|
|
708
|
-
</script>`;return {name:"vite-plugin-browser-logs",configResolved(
|
|
709
|
-
`,"utf-8"),
|
|
772
|
+
</script>`;return {name:"vite-plugin-browser-logs",configResolved(r){let n=et__default.default.env.WORKSPACE_DIR;if(n)e=ye__default.default.join(n,"browser.log");else {let i=r.root||et__default.default.cwd();for(;i!==ye__default.default.dirname(i)&&!Te__default.default.existsSync(ye__default.default.join(i,"package.json"));)i=ye__default.default.dirname(i);e=ye__default.default.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__default.default.dirname(e);Te__default.default.existsSync(a)||Te__default.default.mkdirSync(a,{recursive:!0}),Te__default.default.appendFileSync(e,`${d}
|
|
773
|
+
`,"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 Kt=`
|
|
774
|
+
import * as React from "react";
|
|
775
|
+
import * as ReactJSXDevRuntime from "react/jsx-dev-runtime";
|
|
776
|
+
|
|
777
|
+
const _jsxDEV = ReactJSXDevRuntime.jsxDEV;
|
|
778
|
+
export const Fragment = ReactJSXDevRuntime.Fragment;
|
|
779
|
+
|
|
780
|
+
const SOURCE_KEY = Symbol.for("__jsxSource__");
|
|
781
|
+
const PROJECT_ROOT = "";
|
|
782
|
+
|
|
783
|
+
const cleanFileName = (fileName) => {
|
|
784
|
+
if (!fileName) return "";
|
|
785
|
+
// Remove project root prefix to get relative path
|
|
786
|
+
if (PROJECT_ROOT && fileName.startsWith(PROJECT_ROOT)) {
|
|
787
|
+
const relative = fileName.slice(PROJECT_ROOT.length);
|
|
788
|
+
return relative.startsWith("/") ? relative.slice(1) : relative;
|
|
789
|
+
}
|
|
790
|
+
return fileName;
|
|
791
|
+
};
|
|
792
|
+
|
|
793
|
+
// Global map to track elements by source location
|
|
794
|
+
const sourceElementMap = new Map();
|
|
795
|
+
window.sourceElementMap = sourceElementMap;
|
|
796
|
+
|
|
797
|
+
function getSourceKey(sourceInfo) {
|
|
798
|
+
return \`\${cleanFileName(sourceInfo.fileName)}:\${sourceInfo.lineNumber}:\${sourceInfo.columnNumber}\`;
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
function unregisterElement(node, sourceInfo) {
|
|
802
|
+
const key = getSourceKey(sourceInfo);
|
|
803
|
+
const refs = sourceElementMap.get(key);
|
|
804
|
+
if (refs) {
|
|
805
|
+
for (const ref of refs) {
|
|
806
|
+
if (ref.deref() === node) {
|
|
807
|
+
refs.delete(ref);
|
|
808
|
+
break;
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
if (refs.size === 0) {
|
|
812
|
+
sourceElementMap.delete(key);
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
function registerElement(node, sourceInfo) {
|
|
818
|
+
const key = getSourceKey(sourceInfo);
|
|
819
|
+
if (!sourceElementMap.has(key)) {
|
|
820
|
+
sourceElementMap.set(key, new Set());
|
|
821
|
+
}
|
|
822
|
+
sourceElementMap.get(key).add(new WeakRef(node));
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
function getTypeName(type) {
|
|
826
|
+
if (typeof type === "string") return type;
|
|
827
|
+
if (typeof type === "function") return type.displayName || type.name || "Unknown";
|
|
828
|
+
if (typeof type === "object" && type !== null) {
|
|
829
|
+
return type.displayName || type.render?.displayName || type.render?.name || "Unknown";
|
|
830
|
+
}
|
|
831
|
+
return "Unknown";
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
export function jsxDEV(type, props, key, isStatic, source, self) {
|
|
835
|
+
// For custom components, tag their rendered output
|
|
836
|
+
if (source?.fileName && typeof type !== "string" && type !== Fragment) {
|
|
837
|
+
const typeName = getTypeName(type);
|
|
838
|
+
const jsxSourceInfo = {
|
|
839
|
+
fileName: cleanFileName(source.fileName),
|
|
840
|
+
lineNumber: source.lineNumber,
|
|
841
|
+
columnNumber: source.columnNumber,
|
|
842
|
+
displayName: typeName,
|
|
843
|
+
};
|
|
844
|
+
|
|
845
|
+
const originalRef = props?.ref;
|
|
846
|
+
const enhancedProps = {
|
|
847
|
+
...props,
|
|
848
|
+
ref: (node) => {
|
|
849
|
+
if (node) {
|
|
850
|
+
if (!node[SOURCE_KEY]) {
|
|
851
|
+
node[SOURCE_KEY] = jsxSourceInfo;
|
|
852
|
+
registerElement(node, jsxSourceInfo);
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
if (typeof originalRef === "function") {
|
|
856
|
+
originalRef(node);
|
|
857
|
+
} else if (originalRef && typeof originalRef === "object") {
|
|
858
|
+
originalRef.current = node;
|
|
859
|
+
}
|
|
860
|
+
},
|
|
861
|
+
};
|
|
862
|
+
|
|
863
|
+
return _jsxDEV(type, enhancedProps, key, isStatic, source, self);
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
// For host elements (div, span, etc.), tag with source info
|
|
867
|
+
if (source?.fileName && typeof type === "string") {
|
|
868
|
+
const sourceInfo = {
|
|
869
|
+
fileName: cleanFileName(source.fileName),
|
|
870
|
+
lineNumber: source.lineNumber,
|
|
871
|
+
columnNumber: source.columnNumber,
|
|
872
|
+
displayName: type,
|
|
873
|
+
};
|
|
874
|
+
|
|
875
|
+
const originalRef = props?.ref;
|
|
876
|
+
|
|
877
|
+
const enhancedProps = {
|
|
878
|
+
...props,
|
|
879
|
+
ref: (node) => {
|
|
880
|
+
if (node) {
|
|
881
|
+
const existingSource = node[SOURCE_KEY];
|
|
882
|
+
if (existingSource) {
|
|
883
|
+
if (getSourceKey(existingSource) !== getSourceKey(sourceInfo)) {
|
|
884
|
+
unregisterElement(node, existingSource);
|
|
885
|
+
node[SOURCE_KEY] = sourceInfo;
|
|
886
|
+
registerElement(node, sourceInfo);
|
|
887
|
+
}
|
|
888
|
+
} else {
|
|
889
|
+
node[SOURCE_KEY] = sourceInfo;
|
|
890
|
+
registerElement(node, sourceInfo);
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
if (typeof originalRef === "function") {
|
|
894
|
+
originalRef(node);
|
|
895
|
+
} else if (originalRef && typeof originalRef === "object") {
|
|
896
|
+
originalRef.current = node;
|
|
897
|
+
}
|
|
898
|
+
},
|
|
899
|
+
};
|
|
900
|
+
return _jsxDEV(type, enhancedProps, key, isStatic, source, self);
|
|
901
|
+
}
|
|
902
|
+
|
|
903
|
+
return _jsxDEV(type, props, key, isStatic, source, self);
|
|
904
|
+
}
|
|
905
|
+
`;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"?Kt.replace('const PROJECT_ROOT = "";',`const PROJECT_ROOT = ${JSON.stringify(t)};`):null}}}var Tt=Bt(Pt());function Ye(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__default.default.resolve(t,i);try{return await Ne__default.default.access(c),c}catch{if(i.endsWith(".ts")){let u=c.replace(/\.ts$/,".js");try{return await Ne__default.default.access(u),u}catch{return null}}else if(i.endsWith(".js")){let u=c.replace(/\.js$/,".ts");try{return await Ne__default.default.access(u),u}catch{return null}}return null}},a=async()=>{try{let c=await d();if(!c)return null;let u=await Ne__default.default.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.Buffer.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(),`
|
|
906
|
+
let config = ${JSON.stringify(n)};
|
|
907
|
+
|
|
908
|
+
let _updateConfig;
|
|
909
|
+
if (import.meta.hot) {
|
|
910
|
+
// Accept self updates
|
|
911
|
+
import.meta.hot.accept((newModule) => {
|
|
912
|
+
if (newModule && _updateConfig) {
|
|
913
|
+
_updateConfig(newModule.default);
|
|
914
|
+
}
|
|
915
|
+
});
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
export default new Proxy(config, {
|
|
919
|
+
get(target, prop) {
|
|
920
|
+
if (prop === 'then') return undefined;
|
|
921
|
+
if (prop === '__setUpdater') {
|
|
922
|
+
return (fn) => { _updateConfig = fn; };
|
|
923
|
+
}
|
|
924
|
+
return target[prop];
|
|
925
|
+
}
|
|
926
|
+
});
|
|
927
|
+
`},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__default.default.normalize(c)!==ye__default.default.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=`
|
|
928
|
+
<script data-taro-flexible="true">
|
|
929
|
+
(function() {
|
|
930
|
+
var designWidth = ${t};
|
|
931
|
+
var maxWidth = ${r};
|
|
932
|
+
var baseFontSize = ${n};
|
|
933
|
+
var minRootSize = ${i};
|
|
934
|
+
var maxRootSize = ${l};
|
|
935
|
+
|
|
936
|
+
function setRootFontSize() {
|
|
937
|
+
var docEl = document.documentElement;
|
|
938
|
+
var clientWidth = docEl.clientWidth;
|
|
939
|
+
|
|
940
|
+
// \u9650\u5236\u6700\u5927\u5BBD\u5EA6
|
|
941
|
+
if (clientWidth > maxWidth) {
|
|
942
|
+
clientWidth = maxWidth;
|
|
943
|
+
}
|
|
944
|
+
|
|
945
|
+
// \u8BA1\u7B97\u6839\u5B57\u53F7: (\u5C4F\u5E55\u5BBD\u5EA6 / \u8BBE\u8BA1\u7A3F\u5BBD\u5EA6) * \u57FA\u51C6\u5B57\u53F7
|
|
946
|
+
var fontSize = (clientWidth / designWidth) * baseFontSize;
|
|
947
|
+
|
|
948
|
+
// \u5E94\u7528\u6700\u5C0F/\u6700\u5927\u9650\u5236
|
|
949
|
+
if (fontSize < minRootSize) {
|
|
950
|
+
fontSize = minRootSize;
|
|
951
|
+
} else if (fontSize > maxRootSize) {
|
|
952
|
+
fontSize = maxRootSize;
|
|
953
|
+
}
|
|
954
|
+
|
|
955
|
+
docEl.style.fontSize = fontSize + 'px';
|
|
956
|
+
}
|
|
957
|
+
|
|
958
|
+
setRootFontSize();
|
|
959
|
+
|
|
960
|
+
// \u76D1\u542C\u7A97\u53E3\u53D8\u5316
|
|
961
|
+
window.addEventListener('resize', setRootFontSize);
|
|
962
|
+
window.addEventListener('orientationchange', setRootFontSize);
|
|
963
|
+
|
|
964
|
+
// \u9875\u9762\u663E\u793A\u65F6\u91CD\u65B0\u8BA1\u7B97\uFF08\u89E3\u51B3\u67D0\u4E9B\u6D4F\u89C8\u5668\u7684 bug\uFF09
|
|
965
|
+
document.addEventListener('DOMContentLoaded', setRootFontSize);
|
|
966
|
+
})();
|
|
967
|
+
</script>
|
|
968
|
+
`;return s.replace("</head>",`${d}
|
|
710
969
|
<style data-taro-adapter="true">
|
|
711
970
|
/* \u4EC5 H5 \u751F\u6548\uFF1A\u9690\u85CF Taro \u9875\u9762\u5BB9\u5668\u6EDA\u52A8\u6761\uFF0C\u4F46\u4ECD\u53EF\u6EDA\u52A8 */
|
|
712
971
|
.taro_page {
|
|
@@ -733,6 +992,24 @@ if (typeof window !== 'undefined') {
|
|
|
733
992
|
height: 0;
|
|
734
993
|
display: none; /* Chrome/Safari */
|
|
735
994
|
}
|
|
995
|
+
|
|
996
|
+
/*
|
|
997
|
+
* \u4FEE\u590D Taro Image \u7EC4\u4EF6\u5728 H5 \u4E0B\u7684\u5C3A\u5BF8\u95EE\u9898
|
|
998
|
+
*
|
|
999
|
+
* \u95EE\u9898\uFF1ATaro Image \u7EC4\u4EF6\u4F7F\u7528 aspectFit \u6A21\u5F0F\u65F6\uFF0C\u5185\u90E8 img \u4F7F\u7528 max-width/max-height: 100%
|
|
1000
|
+
* \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
|
|
1001
|
+
*
|
|
1002
|
+
* \u89E3\u51B3\uFF1A\u8BA9 img \u586B\u6EE1 taro-image-core \u5BB9\u5668\uFF0C\u7531\u5BB9\u5668\u63A7\u5236\u5C3A\u5BF8
|
|
1003
|
+
*/
|
|
1004
|
+
taro-image-core img.taro-img__mode-aspectfit {
|
|
1005
|
+
width: 100%;
|
|
1006
|
+
height: 100%;
|
|
1007
|
+
max-width: none;
|
|
1008
|
+
max-height: none;
|
|
1009
|
+
position: static;
|
|
1010
|
+
transform: none;
|
|
1011
|
+
object-fit: contain;
|
|
1012
|
+
}
|
|
736
1013
|
</style>
|
|
737
|
-
</head>`)}}}function
|
|
1014
|
+
</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 qr(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 Ur(){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 Hr(e={}){let t=e.isTaro??et__default.default.env.TARO_ENV==="h5",r=[Ge(),Ze()];return e.jsxSourceTagger!==false&&r.push(Ue()),e.tailwindConfigSync!==false&&r.push(Ye({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__default.default.env.WORKSPACE_GIT_REPO&&r.push(tt()),r}exports.componentIdPlugin=Ht;exports.default=Hr;exports.editorBridgePlugin=Ge;exports.injectAmasterEnv=Ur;exports.injectTaroEnv=qr;exports.jsxSourceTaggerPlugin=Ue;exports.routesExposePlugin=Ze;exports.rpx2pxPlugin=qe;exports.tailwindConfigSyncPlugin=Ye;exports.taroStyleAdapterPlugin=Ke;//# sourceMappingURL=index.cjs.map
|
|
738
1015
|
//# sourceMappingURL=index.cjs.map
|