@zuplo/core 6.64.38 → 6.64.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/customer.cli.minified.js +1 -1
- package/index.minified.js +1 -1
- package/package.json +4 -4
package/customer.cli.minified.js
CHANGED
|
@@ -642,7 +642,7 @@ export default {
|
|
|
642
642
|
`:10,f=typeof o=="string"?"\r":13;return o[o.length-1]===s&&(o=o.slice(0,-1)),o[o.length-1]===f&&(o=o.slice(0,-1)),o}t(q8e,"stripFinalNewline");import Mfe from"node:process";import wG from"node:path";import{fileURLToPath as Ygt}from"node:url";function Rfe(o={}){let{env:s=process.env,platform:f=process.platform}=o;return f!=="win32"?"PATH":Object.keys(s).reverse().find(d=>d.toUpperCase()==="PATH")||"Path"}t(Rfe,"pathKey");var U1r=t(({cwd:o=Mfe.cwd(),path:s=Mfe.env[Rfe()],preferLocal:f=!0,execPath:d=Mfe.execPath,addExecPath:y=!0}={})=>{let x=o instanceof URL?Ygt(o):o,P=wG.resolve(x),F=[];return f&&z1r(F,P),y&&$1r(F,d,P),[...F,s].join(wG.delimiter)},"npmRunPath"),z1r=t((o,s)=>{let f;for(;f!==s;)o.push(wG.join(s,"node_modules/.bin")),f=s,s=wG.resolve(s,"..")},"applyPreferLocal"),$1r=t((o,s,f)=>{let d=s instanceof URL?Ygt(s):s;o.push(wG.resolve(f,d,".."))},"applyExecPath"),Kgt=t(({env:o=Mfe.env,...s}={})=>{o={...o};let f=Rfe({env:o});return s.path=o[f],o[f]=U1r(s),o},"npmRunPathEnv");var J1r=t((o,s,f,d)=>{if(f==="length"||f==="prototype"||f==="arguments"||f==="caller")return;let y=Object.getOwnPropertyDescriptor(o,f),x=Object.getOwnPropertyDescriptor(s,f);!W1r(y,x)&&d||Object.defineProperty(o,f,x)},"copyProperty"),W1r=t(function(o,s){return o===void 0||o.configurable||o.writable===s.writable&&o.enumerable===s.enumerable&&o.configurable===s.configurable&&(o.writable||o.value===s.value)},"canCopyProperty"),q1r=t((o,s)=>{let f=Object.getPrototypeOf(s);f!==Object.getPrototypeOf(o)&&Object.setPrototypeOf(o,f)},"changePrototype"),V1r=t((o,s)=>`/* Wrapped ${o}*/
|
|
643
643
|
${s}`,"wrappedToString"),H1r=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),G1r=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),Y1r=t((o,s,f)=>{let d=f===""?"":`with ${f.trim()}() `,y=V1r.bind(null,d,s.toString());Object.defineProperty(y,"name",G1r),Object.defineProperty(o,"toString",{...H1r,value:y})},"changeToString");function V8e(o,s,{ignoreNonConfigurable:f=!1}={}){let{name:d}=o;for(let y of Reflect.ownKeys(s))J1r(o,s,y,f);return q1r(o,s),Y1r(o,s,d),o}t(V8e,"mimicFunction");var jfe=new WeakMap,Xgt=t((o,s={})=>{if(typeof o!="function")throw new TypeError("Expected a function");let f,d=0,y=o.displayName||o.name||"<anonymous>",x=t(function(...P){if(jfe.set(x,++d),d===1)f=o.apply(this,P),o=null;else if(s.throw===!0)throw new Error(`Function \`${y}\` can only be called once`);return f},"onetime");return V8e(x,o),jfe.set(x,d),x},"onetime");Xgt.callCount=o=>{if(!jfe.has(o))throw new Error(`The given function \`${o.name}\` is not wrapped by the \`onetime\` package`);return jfe.get(o)};var Zgt=Xgt;import{constants as Q1r}from"os";var Qgt=t(function(){let o=H8e-e0t+1;return Array.from({length:o},K1r)},"getRealtimeSignals"),K1r=t(function(o,s){return{name:`SIGRT${s+1}`,number:e0t+s,action:"terminate",description:"Application-specific signal (realtime)",standard:"posix"}},"getRealtimeSignal"),e0t=34,H8e=64;import{constants as X1r}from"os";var t0t=[{name:"SIGHUP",number:1,action:"terminate",description:"Terminal closed",standard:"posix"},{name:"SIGINT",number:2,action:"terminate",description:"User interruption with CTRL-C",standard:"ansi"},{name:"SIGQUIT",number:3,action:"core",description:"User interruption with CTRL-\\",standard:"posix"},{name:"SIGILL",number:4,action:"core",description:"Invalid machine instruction",standard:"ansi"},{name:"SIGTRAP",number:5,action:"core",description:"Debugger breakpoint",standard:"posix"},{name:"SIGABRT",number:6,action:"core",description:"Aborted",standard:"ansi"},{name:"SIGIOT",number:6,action:"core",description:"Aborted",standard:"bsd"},{name:"SIGBUS",number:7,action:"core",description:"Bus error due to misaligned, non-existing address or paging error",standard:"bsd"},{name:"SIGEMT",number:7,action:"terminate",description:"Command should be emulated but is not implemented",standard:"other"},{name:"SIGFPE",number:8,action:"core",description:"Floating point arithmetic error",standard:"ansi"},{name:"SIGKILL",number:9,action:"terminate",description:"Forced termination",standard:"posix",forced:!0},{name:"SIGUSR1",number:10,action:"terminate",description:"Application-specific signal",standard:"posix"},{name:"SIGSEGV",number:11,action:"core",description:"Segmentation fault",standard:"ansi"},{name:"SIGUSR2",number:12,action:"terminate",description:"Application-specific signal",standard:"posix"},{name:"SIGPIPE",number:13,action:"terminate",description:"Broken pipe or socket",standard:"posix"},{name:"SIGALRM",number:14,action:"terminate",description:"Timeout or timer",standard:"posix"},{name:"SIGTERM",number:15,action:"terminate",description:"Termination",standard:"ansi"},{name:"SIGSTKFLT",number:16,action:"terminate",description:"Stack is empty or overflowed",standard:"other"},{name:"SIGCHLD",number:17,action:"ignore",description:"Child process terminated, paused or unpaused",standard:"posix"},{name:"SIGCLD",number:17,action:"ignore",description:"Child process terminated, paused or unpaused",standard:"other"},{name:"SIGCONT",number:18,action:"unpause",description:"Unpaused",standard:"posix",forced:!0},{name:"SIGSTOP",number:19,action:"pause",description:"Paused",standard:"posix",forced:!0},{name:"SIGTSTP",number:20,action:"pause",description:'Paused using CTRL-Z or "suspend"',standard:"posix"},{name:"SIGTTIN",number:21,action:"pause",description:"Background process cannot read terminal input",standard:"posix"},{name:"SIGBREAK",number:21,action:"terminate",description:"User interruption with CTRL-BREAK",standard:"other"},{name:"SIGTTOU",number:22,action:"pause",description:"Background process cannot write to terminal output",standard:"posix"},{name:"SIGURG",number:23,action:"ignore",description:"Socket received out-of-band data",standard:"bsd"},{name:"SIGXCPU",number:24,action:"core",description:"Process timed out",standard:"bsd"},{name:"SIGXFSZ",number:25,action:"core",description:"File too big",standard:"bsd"},{name:"SIGVTALRM",number:26,action:"terminate",description:"Timeout or timer",standard:"bsd"},{name:"SIGPROF",number:27,action:"terminate",description:"Timeout or timer",standard:"bsd"},{name:"SIGWINCH",number:28,action:"ignore",description:"Terminal window size changed",standard:"bsd"},{name:"SIGIO",number:29,action:"terminate",description:"I/O is available",standard:"other"},{name:"SIGPOLL",number:29,action:"terminate",description:"Watched event",standard:"other"},{name:"SIGINFO",number:29,action:"ignore",description:"Request for process information",standard:"other"},{name:"SIGPWR",number:30,action:"terminate",description:"Device running out of power",standard:"systemv"},{name:"SIGSYS",number:31,action:"core",description:"Invalid system call",standard:"other"},{name:"SIGUNUSED",number:31,action:"terminate",description:"Invalid system call",standard:"other"}];var G8e=t(function(){let o=Qgt();return[...t0t,...o].map(Z1r)},"getSignals"),Z1r=t(function({name:o,number:s,description:f,action:d,forced:y=!1,standard:x}){let{signals:{[o]:P}}=X1r,F=P!==void 0;return{name:o,number:F?P:s,description:f,supported:F,action:d,forced:y,standard:x}},"normalizeSignal");var evr=t(function(){return G8e().reduce(tvr,{})},"getSignalsByName"),tvr=t(function(o,{name:s,number:f,description:d,supported:y,action:x,forced:P,standard:F}){return{...o,[s]:{name:s,number:f,description:d,supported:y,action:x,forced:P,standard:F}}},"getSignalByName"),r0t=evr(),rvr=t(function(){let o=G8e(),s=H8e+1,f=Array.from({length:s},(d,y)=>nvr(y,o));return Object.assign({},...f)},"getSignalsByNumber"),nvr=t(function(o,s){let f=ivr(o,s);if(f===void 0)return{};let{name:d,description:y,supported:x,action:P,forced:F,standard:J}=f;return{[o]:{name:d,number:o,description:y,supported:x,action:P,forced:F,standard:J}}},"getSignalByNumber"),ivr=t(function(o,s){let f=s.find(({name:d})=>Q1r.signals[d]===o);return f!==void 0?f:s.find(d=>d.number===o)},"findSignalByNumber"),IRr=rvr();var svr=t(({timedOut:o,timeout:s,errorCode:f,signal:d,signalDescription:y,exitCode:x,isCanceled:P})=>o?`timed out after ${s} milliseconds`:P?"was canceled":f!==void 0?`failed with ${f}`:d!==void 0?`was killed with ${d} (${y})`:x!==void 0?`failed with exit code ${x}`:"failed","getErrorPrefix"),Y8e=t(({stdout:o,stderr:s,all:f,error:d,signal:y,exitCode:x,command:P,escapedCommand:F,timedOut:J,isCanceled:G,killed:Se,parsed:{options:{timeout:de}}})=>{x=x===null?void 0:x,y=y===null?void 0:y;let ae=y===void 0?void 0:r0t[y].description,Ke=d&&d.code,Fe=`Command ${svr({timedOut:J,timeout:de,errorCode:Ke,signal:y,signalDescription:ae,exitCode:x,isCanceled:G})}: ${P}`,Gt=Object.prototype.toString.call(d)==="[object Error]",jt=Gt?`${Fe}
|
|
644
644
|
${d.message}`:Fe,Pr=[jt,s,o].filter(Boolean).join(`
|
|
645
|
-
`);return Gt?(d.originalMessage=d.message,d.message=Pr):d=new Error(Pr),d.shortMessage=jt,d.command=P,d.escapedCommand=F,d.exitCode=x,d.signal=y,d.signalDescription=ae,d.stdout=o,d.stderr=s,f!==void 0&&(d.all=f),"bufferedData"in d&&delete d.bufferedData,d.failed=!0,d.timedOut=!!J,d.isCanceled=G,d.killed=Se&&!J,d},"makeError");var Bfe=["stdin","stdout","stderr"],avr=t(o=>Bfe.some(s=>o[s]!==void 0),"hasAlias"),n0t=t(o=>{if(!o)return;let{stdio:s}=o;if(s===void 0)return Bfe.map(d=>o[d]);if(avr(o))throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${Bfe.map(d=>`\`${d}\``).join(", ")}`);if(typeof s=="string")return s;if(!Array.isArray(s))throw new TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof s}\``);let f=Math.max(s.length,Bfe.length);return Array.from({length:f},(d,y)=>s[y])},"normalizeStdio");var u0t=Sd(l0t(),1);import ovr from"node:os";var cvr=1e3*5,f0t=t((o,s="SIGTERM",f={})=>{let d=o(s);return lvr(o,s,f,d),d},"spawnedKill"),lvr=t((o,s,f,d)=>{if(!uvr(s,f,d))return;let y=_vr(f),x=setTimeout(()=>{o("SIGKILL")},y);x.unref&&x.unref()},"setKillTimeout"),uvr=t((o,{forceKillAfterTimeout:s},f)=>fvr(o)&&s!==!1&&f,"shouldForceKill"),fvr=t(o=>o===ovr.constants.signals.SIGTERM||typeof o=="string"&&o.toUpperCase()==="SIGTERM","isSigterm"),_vr=t(({forceKillAfterTimeout:o=!0})=>{if(o===!0)return cvr;if(!Number.isFinite(o)||o<0)throw new TypeError(`Expected the \`forceKillAfterTimeout\` option to be a non-negative integer, got \`${o}\` (${typeof o})`);return o},"getForceKillAfterTimeout"),_0t=t((o,s)=>{o.kill()&&(s.isCanceled=!0)},"spawnedCancel"),pvr=t((o,s,f)=>{o.kill(s),f(Object.assign(new Error("Timed out"),{timedOut:!0,signal:s}))},"timeoutKill"),p0t=t((o,{timeout:s,killSignal:f="SIGTERM"},d)=>{if(s===0||s===void 0)return d;let y,x=new Promise((F,J)=>{y=setTimeout(()=>{pvr(o,f,J)},s)}),P=d.finally(()=>{clearTimeout(y)});return Promise.race([x,P])},"setupTimeout"),d0t=t(({timeout:o})=>{if(o!==void 0&&(!Number.isFinite(o)||o<0))throw new TypeError(`Expected the \`timeout\` option to be a non-negative integer, got \`${o}\` (${typeof o})`)},"validateTimeout"),m0t=t(async(o,{cleanup:s,detached:f},d)=>{if(!s||f)return d;let y=(0,u0t.default)(()=>{o.kill()});return d.finally(()=>{y()})},"setExitHandler");function h0t(o){return o!==null&&typeof o=="object"&&typeof o.pipe=="function"}t(h0t,"isStream");var tOe=Sd(v0t(),1),T0t=Sd(S0t(),1);var x0t=t((o,s)=>{s===void 0||o.stdin===void 0||(h0t(s)?s.pipe(o.stdin):o.stdin.end(s))},"handleInput"),E0t=t((o,{all:s})=>{if(!s||!o.stdout&&!o.stderr)return;let f=(0,T0t.default)();return o.stdout&&f.add(o.stdout),o.stderr&&f.add(o.stderr),f},"makeAllStream"),Q8e=t(async(o,s)=>{if(o){o.destroy();try{return await s}catch(f){return f.bufferedData}}},"getBufferedData"),eOe=t((o,{encoding:s,buffer:f,maxBuffer:d})=>{if(!(!o||!f))return s?(0,tOe.default)(o,{encoding:s,maxBuffer:d}):tOe.default.buffer(o,{maxBuffer:d})},"getStreamPromise"),C0t=t(async({stdout:o,stderr:s,all:f},{encoding:d,buffer:y,maxBuffer:x},P)=>{let F=eOe(o,{encoding:d,buffer:y,maxBuffer:x}),J=eOe(s,{encoding:d,buffer:y,maxBuffer:x}),G=eOe(f,{encoding:d,buffer:y,maxBuffer:x*2});try{return await Promise.all([P,F,J,G])}catch(Se){return Promise.all([{error:Se,signal:Se.signal,timedOut:Se.timedOut},Q8e(o,F),Q8e(s,J),Q8e(f,G)])}},"getSpawnedResult");var Svr=(async()=>{})().constructor.prototype,Tvr=["then","catch","finally"].map(o=>[o,Reflect.getOwnPropertyDescriptor(Svr,o)]),rOe=t((o,s)=>{for(let[f,d]of Tvr){let y=typeof s=="function"?(...x)=>Reflect.apply(d.value,s(),x):d.value.bind(s);Reflect.defineProperty(o,f,{...d,value:y})}return o},"mergePromise"),k0t=t(o=>new Promise((s,f)=>{o.on("exit",(d,y)=>{s({exitCode:d,signal:y})}),o.on("error",d=>{f(d)}),o.stdin&&o.stdin.on("error",d=>{f(d)})}),"getSpawnedPromise");var w0t=t((o,s=[])=>Array.isArray(s)?[o,...s]:[o],"normalizeArgs"),xvr=/^[\w.-]+$/,Evr=/"/g,Cvr=t(o=>typeof o!="string"||xvr.test(o)?o:`"${o.replace(Evr,'\\"')}"`,"escapeArg"),D0t=t((o,s)=>w0t(o,s).join(" "),"joinCommand"),P0t=t((o,s)=>w0t(o,s).map(f=>Cvr(f)).join(" "),"getEscapedCommand");var Dvr=1e3*1e3*100,Pvr=t(({env:o,extendEnv:s,preferLocal:f,localDir:d,execPath:y})=>{let x=s?{...qfe.env,...o}:o;return f?Kgt({env:x,cwd:d,execPath:y}):x},"getEnv"),Avr=t((o,s,f={})=>{let d=N0t.default._parse(o,s,f);return o=d.command,s=d.args,f=d.options,f={maxBuffer:Dvr,buffer:!0,stripFinalNewline:!0,extendEnv:!0,preferLocal:!1,localDir:f.cwd||qfe.cwd(),execPath:qfe.execPath,encoding:"utf8",reject:!0,cleanup:!0,all:!1,windowsHide:!0,...f},f.env=Pvr(f),f.stdio=n0t(f),qfe.platform==="win32"&&wvr.basename(o,".exe")==="cmd"&&s.unshift("/q"),{file:o,args:s,options:f,parsed:d}},"handleArguments"),nOe=t((o,s,f)=>typeof s!="string"&&!kvr.isBuffer(s)?f===void 0?void 0:"":o.stripFinalNewline?q8e(s):s,"handleOutput");function I0t(o,s,f){let d=Avr(o,s,f),y=D0t(o,s),x=P0t(o,s);d0t(d.options);let P;try{P=A0t.spawn(d.file,d.args,d.options)}catch(Ke){let $e=new A0t.ChildProcess,Fe=Promise.reject(Y8e({error:Ke,stdout:"",stderr:"",all:"",command:y,escapedCommand:x,parsed:d,timedOut:!1,isCanceled:!1,killed:!1}));return rOe($e,Fe)}let F=k0t(P),J=p0t(P,d.options,F),G=m0t(P,d.options,J),Se={isCanceled:!1};P.kill=f0t.bind(null,P.kill.bind(P)),P.cancel=_0t.bind(null,P,Se);let ae=Zgt(t(async()=>{let[{error:Ke,exitCode:$e,signal:Fe,timedOut:Gt},jt,Pr,Fn]=await C0t(P,d.options,G),sn=nOe(d.options,jt),Un=nOe(d.options,Pr),Er=nOe(d.options,Fn);if(Ke||$e!==0||Fe!==null){let vr=Y8e({error:Ke,exitCode:$e,signal:Fe,stdout:sn,stderr:Un,all:Er,command:y,escapedCommand:x,parsed:d,timedOut:Gt,isCanceled:Se.isCanceled||(d.options.signal?d.options.signal.aborted:!1),killed:P.killed});if(!d.options.reject)return vr;throw vr}return{command:y,escapedCommand:x,exitCode:0,stdout:sn,stderr:Un,all:Er,failed:!1,timedOut:!1,isCanceled:!1,killed:!1}},"handlePromise"));return x0t(P,d.options.input),P.all=E0t(P,d.options),rOe(P,ae)}t(I0t,"execa");async function Hfe(o,s){if(o.__ZUPLO_LOG_LEVEL=process.env.__ZUPLO_LOG_LEVEL??process.env.LOG_LEVEL,o.__ZUPLO_LOG_FORMAT=process.env.__ZUPLO_LOG_FORMAT??process.env.LOG_FORMAT,o.LOG_LEVEL=process.env.LOG_LEVEL??process.env.LOG_LEVEL,o.LOG_FORMAT=process.env.LOG_FORMAT??process.env.LOG_FORMAT,o.GIT_SHA=process.env.GIT_SHA??await Nvr(s),process.env.__ZUPLO_CONFIG&&(o.__ZUPLO_CONFIG=process.env.__ZUPLO_CONFIG),O0t(Vfe.join(s,".env.zuplo"))){let f=F0t(Vfe.join(s,".env.zuplo"),"utf8"),d=iOe.default.parse(f);for(let y of Object.keys(d))if(o[y]=d[y],y==="ZUPLO_SYSTEM_CONFIGURATIONS"){let x=Buffer.from(qoe.decode(d[y])).toString(),P=JSON.parse(x);for(let F of Object.keys(P))o[F]=P[F]}}if(O0t(Vfe.join(s,".env"))){let f=F0t(Vfe.join(s,".env"),"utf8"),d=iOe.default.parse(f);for(let y of Object.keys(d))o[y]=d[y]}for(let f of Object.keys(o))o[f]===void 0&&delete o[f];return o}t(Hfe,"setEnvironment");async function Nvr(o){let s="unknown";try{let{stdout:f}=await I0t("git",["rev-parse","HEAD"],{cwd:o});f.trim().length===40&&(s=f.trim())}catch{}return s}t(Nvr,"getGitSha");async function Lvr({buildId:o,output:s,sourceDirectory:f,bundledDir:d,port:y,binaryName:x,publicZuploEnvironmentVariables:P,logger:F,handleRuntimeStdio:J}){if(d){let Se=AG.join(f,d,"modules.json");if(!Ivr(Se))throw new Error("The bundled-dir does not contain a modules.json file.");let de=await Fvr(Se,"utf-8").then(JSON.parse),ae=await GM(f);return ae.status===LP?new Promise((Ke,$e)=>{G(ae.config.compatibilityDate,AG.join(f,d),de,Ke,J)().catch(Fe=>{F.error(Fe),$e(Fe)})}):(F.warn("Failed to get Zuplo config. Using default compatibility date."),new Promise((Ke,$e)=>{G(void 0,f,de,Ke,J)().catch(Fe=>{F.error(Fe),$e(Fe)})}))}else{let Se=new MI({buildId:o,output:s,sourceDirectory:f,command:"dev",logger:F,publicZuploEnvironmentVariables:P??{ZUPLO_ENVIRONMENT_TYPE:"LOCAL_DEVELOPMENT"},urls:void 0});try{await Se.start()}catch{F.info("Ran into irrecoverable error while building. Fix the error and rerun the command."),process.exit(1)}return new Promise((de,ae)=>{Se.onReload((Ke,$e)=>{($e||Ke?.errors&&Ke.errors.length>0)&&ae($e??Ke?.errors),G(Ke?.config?.compatibilityDate,AG.join(f,"dist"),HM(f,Ke?.metafile),de,J)().catch(Fe=>{F.error(Fe),ae(Fe)})})})}function G(Se,de,ae,Ke,$e){return async()=>{let Fe={};await Hfe(Fe,f);let Gt=new L0t.ZuploWorkerd({compatibilityDate:Se,scriptDirectory:de,modules:ae,port:y??Gm.DEV_SERVER_PORT,bindings:Fe,handleRuntimeStdio:$e}),jt=x??"compiled-zup",Pr=AG.join(f,"dist");await Ovr(Pr,{recursive:!0}),await Gt.compileBinary({binaryPath:AG.join(f,"dist",jt)}),await Gt.dispose(),Ke(void 0)}}t(G,"compile")}t(Lvr,"compileWorkerdServer");import R0t from"node:assert";import Mvr from"node:child_process";import jvr from"node:fs";import Gfe from"node:os";import Bvr from"node:path";import{Readable as M0t}from"node:stream";import{fileURLToPath as U0t}from"node:url";import Rvr from"node:net";function NG(o,s){return new Promise(f=>{let d=new Rvr.Socket;d.connect(s,o),d.on("connect",()=>{d.destroy(),f(!1)}),d.on("error",()=>{d.destroy(),f(!0)})})}t(NG,"isPortAvailable");function j0t(o,s){let f=import.meta.resolve(o),d=new URL(".",f),y=new URL(s,d);if(jvr.existsSync(y))return U0t(y)}t(j0t,"getValidExecutablePath");function Uvr(){let o=Gfe.platform()==="win32"?"deno.exe":"deno",s=j0t("deno/package.json",o);if(s)return s;let f=zvr(),d=j0t(`@deno/${f}/package.json`,o);if(d)return d;throw new Error("Failed to locate the managed-dedicated server executable.")}t(Uvr,"locateDenoExecutable");function zvr(){let o=Gfe.platform();return o==="linux"?`${o}-${B0t()}-glibc`:`${o}-${B0t()}`}t(zvr,"getTarget");function B0t(){let o=Gfe.arch();if(o!=="arm64"&&o!=="x64")throw new Error("Unsupported architecture "+Gfe.arch()+". Only x64 and aarch64 binaries are available.");return o}t(B0t,"getArch");var Yfe=class{static{t(this,"ZenoServer")}serverProcess;sourceDirectory;port;debugPort;processExitPromise;logger;output;buildWatcher;onReload;handleRuntimeStdio;denoExecutablePath;unsafelyIgnoreCertificateErrors;constructor(s){if(this.port=s.port??9e3,this.debugPort=s.debugPort,this.logger=s.logger,this.output=s.output,this.onReload=s.onReload,this.handleRuntimeStdio=s.handleRuntimeStdio,this.sourceDirectory=s.sourceDirectory,this.unsafelyIgnoreCertificateErrors=!!s.unsafelyIgnoreCertificateErrors,!s.zupTestMode){let f="http://localhost:3000",d=`http://localhost:${this.port}`;this.buildWatcher=new MI({sourceDirectory:s.sourceDirectory,command:"dev",logger:s.logger,publicZuploEnvironmentVariables:{...s.publicZuploEnvironmentVariables,ZUPLO_ENVIRONMENT_TYPE:"LOCAL_DEVELOPMENT"},buildId:"dev",output:s.output,urls:{devPortal:{defaultUrl:f,urls:[f]},api:{defaultUrl:d,urls:[d]}}}),this.buildWatcher.watchEnvFiles()}this.denoExecutablePath=Uvr()}getServeArgs(){let s=`${Bvr.dirname(U0t(import.meta.url))}/zeno.js`,f=["run","--allow-read","--allow-net","--allow-env","--allow-write",...this.unsafelyIgnoreCertificateErrors?["--unsafely-ignore-certificate-errors"]:[]];return this.debugPort&&f.push(`--inspect=127.0.0.1:${this.debugPort}`),f.push(s),f.push("--dir",this.sourceDirectory),f.push("--port",this.port.toString()),f}async getUnavailablePorts(){let s=[];return this.debugPort&&!await NG("127.0.0.1",this.debugPort)&&s.push(this.debugPort),await NG("127.0.0.1",this.port)||s.push(this.port),s}async start(){let s=await this.getUnavailablePorts();if(s.length>0)throw new Error(`The following ports are not available: ${s.join(", ")}`);if(this.buildWatcher)try{await this.buildWatcher.start()}catch(f){this.output.child("api").error(f.toString());let d="Ran into irrecoverable error while starting watcher. Fix the error and restart the server.";this.output.child("api").error(d),this.logger?.info(d),process.exit(1)}await this.startOrReload(),this.buildWatcher?.onReload((f,d)=>{d||f?.errors&&f.errors.length>0||(this.onReload(f,d),this.startOrReload().catch(y=>{this.output.child("api").error(y.toString()),this.logger?.error(y)}))})}async startOrReload(){try{await this.dispose(),this.logger?.info("Starting managed-dedicated local server");let s=this.getServeArgs();this.serverProcess=Mvr.spawn(this.denoExecutablePath,s,{stdio:["pipe","pipe","pipe"],env:{...process.env,FORCE_COLOR:"1"}}),R0t(this.serverProcess.stdout instanceof M0t),R0t(this.serverProcess.stderr instanceof M0t),this.processExitPromise=this.waitForExit(),this.handleRuntimeStdio(this.serverProcess.stdout,this.serverProcess.stderr)}catch(s){this.logger?.debug(s)}}waitForExit(){return new Promise(s=>{this.serverProcess?.once("exit",s)})}dispose(){return this.serverProcess?.kill("SIGKILL"),this.processExitPromise}async stop(){await this.dispose(),await this.buildWatcher?.close()}};var z0t=Sd(I8e(),1);import $vr from"node:path";var Kfe=class{static{t(this,"WorkerdServer")}sourceDirectory;port;debugPort;buildWatcher;workerd;logger;output;handleRuntimeStdio;onReload;constructor(s){if(this.sourceDirectory=s.sourceDirectory,this.port=s.port??Gm.DEV_SERVER_PORT,this.debugPort=s.debugPort,this.logger=s.logger,this.output=s.output,this.handleRuntimeStdio=s.handleRuntimeStdio,this.onReload=s.onReload,!s.zupTestMode){let f="http://localhost:3000",d=`http://localhost:${this.port}`;this.buildWatcher=new MI({...s,logger:this.logger,publicZuploEnvironmentVariables:{...s.publicZuploEnvironmentVariables,ZUPLO_ENVIRONMENT_TYPE:"LOCAL_DEVELOPMENT"},urls:{devPortal:{defaultUrl:f,urls:[f]},api:{defaultUrl:d,urls:[d]}}}),this.buildWatcher.watchEnvFiles()}}async start(){if(!await NG("localhost",this.port))throw new Error(`Port ${this.port} is currently in use. Please use a different port.`);if(this.buildWatcher)try{await this.buildWatcher.start()}catch(f){this.output.child("api").error(f.toString());let d="Ran into irrecoverable error while starting watcher. Fix the error and restart the server.";this.output.child("api").error(d),this.logger?.info(d),process.exit(1)}this.buildWatcher?.onReload((f,d)=>{d||f?.errors&&f.errors.length>0||(this.onReload(f,d),this.startOrReload(f).catch(y=>{this.output.child("api").error(y.toString()),this.logger?.error(y)}))})}async startOrReload(s){try{let f={};await Hfe(f,this.sourceDirectory),await this.workerd?.dispose(),this.workerd=new z0t.ZuploWorkerd({compatibilityDate:s?.config?.compatibilityDate,scriptDirectory:$vr.join(this.sourceDirectory,"dist"),modules:HM(this.sourceDirectory,s?.metafile),port:this.port,inspectorPort:this.debugPort??void 0,bindings:f,handleRuntimeStdio:this.handleRuntimeStdio}),await this.workerd.serve()}catch(f){this.logger?.debug(f)}}async stop(){await this.buildWatcher?.close(),await this.workerd?.dispose()}};async function Jvr(o){let s=await GM(o),f=!1;return s.status===LP&&(f=s.config.projectType!=="managed-edge"||(s.config.flags?.managedDedicatedFlags?.useZeno??!1)),f||process.env.ZUPLO_DEV_RUNTIME==="zeno"}t(Jvr,"useZeno");async function Wvr({sourceDirectory:o,port:s,debugPort:f,publicZuploEnvironmentVariables:d,unsafelyIgnoreCertificateErrors:y,logger:x,output:P,buildId:F,onReload:J,handleRuntimeStdio:G}){process.env.ZUPLO_IS_LOCAL_DEVELOPMENT="true";let Se;await Jvr(o)?(x.debug("Starting managed-dedicated local dev server."),Se=new Yfe({sourceDirectory:o,port:s,debugPort:f,logger:x,output:P,publicZuploEnvironmentVariables:d,onReload:J,handleRuntimeStdio:G,unsafelyIgnoreCertificateErrors:y})):(x.debug("Starting edge local dev server."),Se=new Kfe({sourceDirectory:o,command:"dev",port:s,debugPort:f,publicZuploEnvironmentVariables:d,logger:x,output:P,buildId:F,onReload:J,handleRuntimeStdio:G})),await Se.start();async function de(){await Se.stop()}t(de,"handle"),process.on("SIGTERM",de),process.on("SIGINT",de)}t(Wvr,"startDevServer");var Iy=new URL("./public/",import.meta.url);import{readFile as Xfe}from"fs/promises";var J1=class{static{t(this,"BaseComponent")}#e;#n;#t;scriptFile;cssFile;constructor(o){this.#t=o}async getStyles(){return this.cssFile?this.#t?await Xfe(this.cssFile,"utf-8"):(this.#e=this.#e??await Xfe(this.cssFile,"utf-8"),this.#e):null}async getScript(){return this.scriptFile?this.#t?await Xfe(this.scriptFile,"utf-8"):(this.#n=this.#n??await Xfe(this.scriptFile,"utf-8"),this.#n):null}};var $0t=class extends J1{static{t(this,"Layout")}cssFile=new URL("./layout/style.css",Iy);scriptFile=new URL("./layout/script.js",Iy);async toHTML(o){return`<!DOCTYPE html>
|
|
645
|
+
`);return Gt?(d.originalMessage=d.message,d.message=Pr):d=new Error(Pr),d.shortMessage=jt,d.command=P,d.escapedCommand=F,d.exitCode=x,d.signal=y,d.signalDescription=ae,d.stdout=o,d.stderr=s,f!==void 0&&(d.all=f),"bufferedData"in d&&delete d.bufferedData,d.failed=!0,d.timedOut=!!J,d.isCanceled=G,d.killed=Se&&!J,d},"makeError");var Bfe=["stdin","stdout","stderr"],avr=t(o=>Bfe.some(s=>o[s]!==void 0),"hasAlias"),n0t=t(o=>{if(!o)return;let{stdio:s}=o;if(s===void 0)return Bfe.map(d=>o[d]);if(avr(o))throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${Bfe.map(d=>`\`${d}\``).join(", ")}`);if(typeof s=="string")return s;if(!Array.isArray(s))throw new TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof s}\``);let f=Math.max(s.length,Bfe.length);return Array.from({length:f},(d,y)=>s[y])},"normalizeStdio");var u0t=Sd(l0t(),1);import ovr from"node:os";var cvr=1e3*5,f0t=t((o,s="SIGTERM",f={})=>{let d=o(s);return lvr(o,s,f,d),d},"spawnedKill"),lvr=t((o,s,f,d)=>{if(!uvr(s,f,d))return;let y=_vr(f),x=setTimeout(()=>{o("SIGKILL")},y);x.unref&&x.unref()},"setKillTimeout"),uvr=t((o,{forceKillAfterTimeout:s},f)=>fvr(o)&&s!==!1&&f,"shouldForceKill"),fvr=t(o=>o===ovr.constants.signals.SIGTERM||typeof o=="string"&&o.toUpperCase()==="SIGTERM","isSigterm"),_vr=t(({forceKillAfterTimeout:o=!0})=>{if(o===!0)return cvr;if(!Number.isFinite(o)||o<0)throw new TypeError(`Expected the \`forceKillAfterTimeout\` option to be a non-negative integer, got \`${o}\` (${typeof o})`);return o},"getForceKillAfterTimeout"),_0t=t((o,s)=>{o.kill()&&(s.isCanceled=!0)},"spawnedCancel"),pvr=t((o,s,f)=>{o.kill(s),f(Object.assign(new Error("Timed out"),{timedOut:!0,signal:s}))},"timeoutKill"),p0t=t((o,{timeout:s,killSignal:f="SIGTERM"},d)=>{if(s===0||s===void 0)return d;let y,x=new Promise((F,J)=>{y=setTimeout(()=>{pvr(o,f,J)},s)}),P=d.finally(()=>{clearTimeout(y)});return Promise.race([x,P])},"setupTimeout"),d0t=t(({timeout:o})=>{if(o!==void 0&&(!Number.isFinite(o)||o<0))throw new TypeError(`Expected the \`timeout\` option to be a non-negative integer, got \`${o}\` (${typeof o})`)},"validateTimeout"),m0t=t(async(o,{cleanup:s,detached:f},d)=>{if(!s||f)return d;let y=(0,u0t.default)(()=>{o.kill()});return d.finally(()=>{y()})},"setExitHandler");function h0t(o){return o!==null&&typeof o=="object"&&typeof o.pipe=="function"}t(h0t,"isStream");var tOe=Sd(v0t(),1),T0t=Sd(S0t(),1);var x0t=t((o,s)=>{s===void 0||o.stdin===void 0||(h0t(s)?s.pipe(o.stdin):o.stdin.end(s))},"handleInput"),E0t=t((o,{all:s})=>{if(!s||!o.stdout&&!o.stderr)return;let f=(0,T0t.default)();return o.stdout&&f.add(o.stdout),o.stderr&&f.add(o.stderr),f},"makeAllStream"),Q8e=t(async(o,s)=>{if(o){o.destroy();try{return await s}catch(f){return f.bufferedData}}},"getBufferedData"),eOe=t((o,{encoding:s,buffer:f,maxBuffer:d})=>{if(!(!o||!f))return s?(0,tOe.default)(o,{encoding:s,maxBuffer:d}):tOe.default.buffer(o,{maxBuffer:d})},"getStreamPromise"),C0t=t(async({stdout:o,stderr:s,all:f},{encoding:d,buffer:y,maxBuffer:x},P)=>{let F=eOe(o,{encoding:d,buffer:y,maxBuffer:x}),J=eOe(s,{encoding:d,buffer:y,maxBuffer:x}),G=eOe(f,{encoding:d,buffer:y,maxBuffer:x*2});try{return await Promise.all([P,F,J,G])}catch(Se){return Promise.all([{error:Se,signal:Se.signal,timedOut:Se.timedOut},Q8e(o,F),Q8e(s,J),Q8e(f,G)])}},"getSpawnedResult");var Svr=(async()=>{})().constructor.prototype,Tvr=["then","catch","finally"].map(o=>[o,Reflect.getOwnPropertyDescriptor(Svr,o)]),rOe=t((o,s)=>{for(let[f,d]of Tvr){let y=typeof s=="function"?(...x)=>Reflect.apply(d.value,s(),x):d.value.bind(s);Reflect.defineProperty(o,f,{...d,value:y})}return o},"mergePromise"),k0t=t(o=>new Promise((s,f)=>{o.on("exit",(d,y)=>{s({exitCode:d,signal:y})}),o.on("error",d=>{f(d)}),o.stdin&&o.stdin.on("error",d=>{f(d)})}),"getSpawnedPromise");var w0t=t((o,s=[])=>Array.isArray(s)?[o,...s]:[o],"normalizeArgs"),xvr=/^[\w.-]+$/,Evr=/"/g,Cvr=t(o=>typeof o!="string"||xvr.test(o)?o:`"${o.replace(Evr,'\\"')}"`,"escapeArg"),D0t=t((o,s)=>w0t(o,s).join(" "),"joinCommand"),P0t=t((o,s)=>w0t(o,s).map(f=>Cvr(f)).join(" "),"getEscapedCommand");var Dvr=1e3*1e3*100,Pvr=t(({env:o,extendEnv:s,preferLocal:f,localDir:d,execPath:y})=>{let x=s?{...qfe.env,...o}:o;return f?Kgt({env:x,cwd:d,execPath:y}):x},"getEnv"),Avr=t((o,s,f={})=>{let d=N0t.default._parse(o,s,f);return o=d.command,s=d.args,f=d.options,f={maxBuffer:Dvr,buffer:!0,stripFinalNewline:!0,extendEnv:!0,preferLocal:!1,localDir:f.cwd||qfe.cwd(),execPath:qfe.execPath,encoding:"utf8",reject:!0,cleanup:!0,all:!1,windowsHide:!0,...f},f.env=Pvr(f),f.stdio=n0t(f),qfe.platform==="win32"&&wvr.basename(o,".exe")==="cmd"&&s.unshift("/q"),{file:o,args:s,options:f,parsed:d}},"handleArguments"),nOe=t((o,s,f)=>typeof s!="string"&&!kvr.isBuffer(s)?f===void 0?void 0:"":o.stripFinalNewline?q8e(s):s,"handleOutput");function I0t(o,s,f){let d=Avr(o,s,f),y=D0t(o,s),x=P0t(o,s);d0t(d.options);let P;try{P=A0t.spawn(d.file,d.args,d.options)}catch(Ke){let $e=new A0t.ChildProcess,Fe=Promise.reject(Y8e({error:Ke,stdout:"",stderr:"",all:"",command:y,escapedCommand:x,parsed:d,timedOut:!1,isCanceled:!1,killed:!1}));return rOe($e,Fe)}let F=k0t(P),J=p0t(P,d.options,F),G=m0t(P,d.options,J),Se={isCanceled:!1};P.kill=f0t.bind(null,P.kill.bind(P)),P.cancel=_0t.bind(null,P,Se);let ae=Zgt(t(async()=>{let[{error:Ke,exitCode:$e,signal:Fe,timedOut:Gt},jt,Pr,Fn]=await C0t(P,d.options,G),sn=nOe(d.options,jt),Un=nOe(d.options,Pr),Er=nOe(d.options,Fn);if(Ke||$e!==0||Fe!==null){let vr=Y8e({error:Ke,exitCode:$e,signal:Fe,stdout:sn,stderr:Un,all:Er,command:y,escapedCommand:x,parsed:d,timedOut:Gt,isCanceled:Se.isCanceled||(d.options.signal?d.options.signal.aborted:!1),killed:P.killed});if(!d.options.reject)return vr;throw vr}return{command:y,escapedCommand:x,exitCode:0,stdout:sn,stderr:Un,all:Er,failed:!1,timedOut:!1,isCanceled:!1,killed:!1}},"handlePromise"));return x0t(P,d.options.input),P.all=E0t(P,d.options),rOe(P,ae)}t(I0t,"execa");async function Hfe(o,s){if(o.__ZUPLO_LOG_LEVEL=process.env.__ZUPLO_LOG_LEVEL??process.env.LOG_LEVEL,o.__ZUPLO_LOG_FORMAT=process.env.__ZUPLO_LOG_FORMAT??process.env.LOG_FORMAT,o.LOG_LEVEL=process.env.LOG_LEVEL??process.env.LOG_LEVEL,o.LOG_FORMAT=process.env.LOG_FORMAT??process.env.LOG_FORMAT,o.GIT_SHA=process.env.GIT_SHA??await Nvr(s),process.env.__ZUPLO_CONFIG&&(o.__ZUPLO_CONFIG=process.env.__ZUPLO_CONFIG),O0t(Vfe.join(s,".env.zuplo"))){let f=F0t(Vfe.join(s,".env.zuplo"),"utf8"),d=iOe.default.parse(f);for(let y of Object.keys(d))if(o[y]=d[y],y==="ZUPLO_SYSTEM_CONFIGURATIONS"){let x=Buffer.from(qoe.decode(d[y])).toString(),P=JSON.parse(x);for(let F of Object.keys(P))o[F]=P[F]}}if(O0t(Vfe.join(s,".env"))){let f=F0t(Vfe.join(s,".env"),"utf8"),d=iOe.default.parse(f);for(let y of Object.keys(d))o[y]=d[y]}for(let f of Object.keys(o))o[f]===void 0&&delete o[f];return o}t(Hfe,"setEnvironment");async function Nvr(o){let s="unknown";try{let{stdout:f}=await I0t("git",["rev-parse","HEAD"],{cwd:o});f.trim().length===40&&(s=f.trim())}catch{}return s}t(Nvr,"getGitSha");async function Lvr({buildId:o,output:s,sourceDirectory:f,bundledDir:d,port:y,binaryName:x,publicZuploEnvironmentVariables:P,logger:F,handleRuntimeStdio:J}){if(d){let Se=AG.join(f,d,"modules.json");if(!Ivr(Se))throw new Error("The bundled-dir does not contain a modules.json file.");let de=await Fvr(Se,"utf-8").then(JSON.parse),ae=await GM(f);return ae.status===LP?new Promise((Ke,$e)=>{G(ae.config.compatibilityDate,AG.join(f,d),de,Ke,J)().catch(Fe=>{F.error(Fe),$e(Fe)})}):(F.warn("Failed to get Zuplo config. Using default compatibility date."),new Promise((Ke,$e)=>{G(void 0,f,de,Ke,J)().catch(Fe=>{F.error(Fe),$e(Fe)})}))}else{let Se=new MI({buildId:o,output:s,sourceDirectory:f,command:"dev",logger:F,publicZuploEnvironmentVariables:P??{ZUPLO_ENVIRONMENT_TYPE:"LOCAL_DEVELOPMENT"},urls:void 0});try{await Se.start()}catch{F.info("Ran into irrecoverable error while building. Fix the error and rerun the command."),process.exit(1)}return new Promise((de,ae)=>{Se.onReload((Ke,$e)=>{($e||Ke?.errors&&Ke.errors.length>0)&&ae($e??Ke?.errors),G(Ke?.config?.compatibilityDate,AG.join(f,"dist"),HM(f,Ke?.metafile),de,J)().catch(Fe=>{F.error(Fe),ae(Fe)})})})}function G(Se,de,ae,Ke,$e){return async()=>{let Fe={};await Hfe(Fe,f);let Gt=new L0t.ZuploWorkerd({compatibilityDate:Se,scriptDirectory:de,modules:ae,port:y??Gm.DEV_SERVER_PORT,bindings:Fe,handleRuntimeStdio:$e}),jt=x??"compiled-zup",Pr=AG.join(f,"dist");await Ovr(Pr,{recursive:!0}),await Gt.compileBinary({binaryPath:AG.join(f,"dist",jt)}),await Gt.dispose(),Ke(void 0)}}t(G,"compile")}t(Lvr,"compileWorkerdServer");import R0t from"node:assert";import Mvr from"node:child_process";import jvr from"node:fs";import Gfe from"node:os";import Bvr from"node:path";import{Readable as M0t}from"node:stream";import{fileURLToPath as U0t}from"node:url";import Rvr from"node:net";function NG(o,s){return new Promise(f=>{let d=new Rvr.Socket;d.connect(s,o),d.on("connect",()=>{d.destroy(),f(!1)}),d.on("error",()=>{d.destroy(),f(!0)})})}t(NG,"isPortAvailable");function j0t(o,s){let f=import.meta.resolve(o),d=new URL(".",f),y=new URL(s,d);if(jvr.existsSync(y))return U0t(y)}t(j0t,"getValidExecutablePath");function Uvr(){let o=Gfe.platform()==="win32"?"deno.exe":"deno",s=j0t("deno/package.json",o);if(s)return s;let f=zvr(),d=j0t(`@deno/${f}/package.json`,o);if(d)return d;throw new Error("Failed to locate the managed-dedicated server executable.")}t(Uvr,"locateDenoExecutable");function zvr(){let o=Gfe.platform();return o==="linux"?`${o}-${B0t()}-glibc`:`${o}-${B0t()}`}t(zvr,"getTarget");function B0t(){let o=Gfe.arch();if(o!=="arm64"&&o!=="x64")throw new Error("Unsupported architecture "+Gfe.arch()+". Only x64 and aarch64 binaries are available.");return o}t(B0t,"getArch");var Yfe=class{static{t(this,"ZenoServer")}serverProcess;sourceDirectory;port;debugPort;processExitPromise;logger;output;buildWatcher;onReload;handleRuntimeStdio;denoExecutablePath;unsafelyIgnoreCertificateErrors;constructor(s){if(this.port=s.port??9e3,this.debugPort=s.debugPort,this.logger=s.logger,this.output=s.output,this.onReload=s.onReload,this.handleRuntimeStdio=s.handleRuntimeStdio,this.sourceDirectory=s.sourceDirectory,this.unsafelyIgnoreCertificateErrors=!!s.unsafelyIgnoreCertificateErrors,!s.zupTestMode){let d=`http://localhost:${s.devPortalPort??3e3}`,y=`http://localhost:${this.port}`;this.buildWatcher=new MI({sourceDirectory:s.sourceDirectory,command:"dev",logger:s.logger,publicZuploEnvironmentVariables:{...s.publicZuploEnvironmentVariables,ZUPLO_ENVIRONMENT_TYPE:"LOCAL_DEVELOPMENT"},buildId:"dev",output:s.output,urls:{devPortal:{defaultUrl:d,urls:[d]},api:{defaultUrl:y,urls:[y]}}}),this.buildWatcher.watchEnvFiles()}this.denoExecutablePath=Uvr()}getServeArgs(){let s=`${Bvr.dirname(U0t(import.meta.url))}/zeno.js`,f=["run","--allow-read","--allow-net","--allow-env","--allow-write",...this.unsafelyIgnoreCertificateErrors?["--unsafely-ignore-certificate-errors"]:[]];return this.debugPort&&f.push(`--inspect=127.0.0.1:${this.debugPort}`),f.push(s),f.push("--dir",this.sourceDirectory),f.push("--port",this.port.toString()),f}async getUnavailablePorts(){let s=[];return this.debugPort&&!await NG("127.0.0.1",this.debugPort)&&s.push(this.debugPort),await NG("127.0.0.1",this.port)||s.push(this.port),s}async start(){let s=await this.getUnavailablePorts();if(s.length>0)throw new Error(`The following ports are not available: ${s.join(", ")}`);if(this.buildWatcher)try{await this.buildWatcher.start()}catch(f){this.output.child("api").error(f.toString());let d="Ran into irrecoverable error while starting watcher. Fix the error and restart the server.";this.output.child("api").error(d),this.logger?.info(d),process.exit(1)}await this.startOrReload(),this.buildWatcher?.onReload((f,d)=>{d||f?.errors&&f.errors.length>0||(this.onReload(f,d),this.startOrReload().catch(y=>{this.output.child("api").error(y.toString()),this.logger?.error(y)}))})}async startOrReload(){try{await this.dispose(),this.logger?.info("Starting managed-dedicated local server");let s=this.getServeArgs();this.serverProcess=Mvr.spawn(this.denoExecutablePath,s,{stdio:["pipe","pipe","pipe"],env:{...process.env,FORCE_COLOR:"1"}}),R0t(this.serverProcess.stdout instanceof M0t),R0t(this.serverProcess.stderr instanceof M0t),this.processExitPromise=this.waitForExit(),this.handleRuntimeStdio(this.serverProcess.stdout,this.serverProcess.stderr)}catch(s){this.logger?.debug(s)}}waitForExit(){return new Promise(s=>{this.serverProcess?.once("exit",s)})}dispose(){return this.serverProcess?.kill("SIGKILL"),this.processExitPromise}async stop(){await this.dispose(),await this.buildWatcher?.close()}};var z0t=Sd(I8e(),1);import $vr from"node:path";var Kfe=class{static{t(this,"WorkerdServer")}sourceDirectory;port;debugPort;buildWatcher;workerd;logger;output;handleRuntimeStdio;onReload;constructor(s){if(this.sourceDirectory=s.sourceDirectory,this.port=s.port??Gm.DEV_SERVER_PORT,this.debugPort=s.debugPort,this.logger=s.logger,this.output=s.output,this.handleRuntimeStdio=s.handleRuntimeStdio,this.onReload=s.onReload,!s.zupTestMode){let d=`http://localhost:${s.devPortalPort??3e3}`,y=`http://localhost:${this.port}`;this.buildWatcher=new MI({...s,logger:this.logger,publicZuploEnvironmentVariables:{...s.publicZuploEnvironmentVariables,ZUPLO_ENVIRONMENT_TYPE:"LOCAL_DEVELOPMENT"},urls:{devPortal:{defaultUrl:d,urls:[d]},api:{defaultUrl:y,urls:[y]}}}),this.buildWatcher.watchEnvFiles()}}async start(){if(!await NG("localhost",this.port))throw new Error(`Port ${this.port} is currently in use. Please use a different port.`);if(this.buildWatcher)try{await this.buildWatcher.start()}catch(f){this.output.child("api").error(f.toString());let d="Ran into irrecoverable error while starting watcher. Fix the error and restart the server.";this.output.child("api").error(d),this.logger?.info(d),process.exit(1)}this.buildWatcher?.onReload((f,d)=>{d||f?.errors&&f.errors.length>0||(this.onReload(f,d),this.startOrReload(f).catch(y=>{this.output.child("api").error(y.toString()),this.logger?.error(y)}))})}async startOrReload(s){try{let f={};await Hfe(f,this.sourceDirectory),await this.workerd?.dispose(),this.workerd=new z0t.ZuploWorkerd({compatibilityDate:s?.config?.compatibilityDate,scriptDirectory:$vr.join(this.sourceDirectory,"dist"),modules:HM(this.sourceDirectory,s?.metafile),port:this.port,inspectorPort:this.debugPort??void 0,bindings:f,handleRuntimeStdio:this.handleRuntimeStdio}),await this.workerd.serve()}catch(f){this.logger?.debug(f)}}async stop(){await this.buildWatcher?.close(),await this.workerd?.dispose()}};async function Jvr(o){let s=await GM(o),f=!1;return s.status===LP&&(f=s.config.projectType!=="managed-edge"||(s.config.flags?.managedDedicatedFlags?.useZeno??!1)),f||process.env.ZUPLO_DEV_RUNTIME==="zeno"}t(Jvr,"useZeno");async function Wvr({sourceDirectory:o,port:s,debugPort:f,devPortalPort:d,publicZuploEnvironmentVariables:y,unsafelyIgnoreCertificateErrors:x,logger:P,output:F,buildId:J,onReload:G,handleRuntimeStdio:Se}){process.env.ZUPLO_IS_LOCAL_DEVELOPMENT="true";let de;await Jvr(o)?(P.debug("Starting managed-dedicated local dev server."),de=new Yfe({sourceDirectory:o,port:s,debugPort:f,devPortalPort:d,logger:P,output:F,publicZuploEnvironmentVariables:y,onReload:G,handleRuntimeStdio:Se,unsafelyIgnoreCertificateErrors:x})):(P.debug("Starting edge local dev server."),de=new Kfe({sourceDirectory:o,command:"dev",port:s,debugPort:f,devPortalPort:d,publicZuploEnvironmentVariables:y,logger:P,output:F,buildId:J,onReload:G,handleRuntimeStdio:Se})),await de.start();async function ae(){await de.stop()}t(ae,"handle"),process.on("SIGTERM",ae),process.on("SIGINT",ae)}t(Wvr,"startDevServer");var Iy=new URL("./public/",import.meta.url);import{readFile as Xfe}from"fs/promises";var J1=class{static{t(this,"BaseComponent")}#e;#n;#t;scriptFile;cssFile;constructor(o){this.#t=o}async getStyles(){return this.cssFile?this.#t?await Xfe(this.cssFile,"utf-8"):(this.#e=this.#e??await Xfe(this.cssFile,"utf-8"),this.#e):null}async getScript(){return this.scriptFile?this.#t?await Xfe(this.scriptFile,"utf-8"):(this.#n=this.#n??await Xfe(this.scriptFile,"utf-8"),this.#n):null}};var $0t=class extends J1{static{t(this,"Layout")}cssFile=new URL("./layout/style.css",Iy);scriptFile=new URL("./layout/script.js",Iy);async toHTML(o){return`<!DOCTYPE html>
|
|
646
646
|
<html lang="en">
|
|
647
647
|
<head>
|
|
648
648
|
<meta charset="UTF-8" />
|
package/index.minified.js
CHANGED
|
@@ -647,7 +647,7 @@ export default {
|
|
|
647
647
|
`:10,f=typeof o=="string"?"\r":13;return o[o.length-1]===s&&(o=o.slice(0,-1)),o[o.length-1]===f&&(o=o.slice(0,-1)),o}t(Y8e,"stripFinalNewline");import Mfe from"node:process";import wG from"node:path";import{fileURLToPath as Kgt}from"node:url";function Rfe(o={}){let{env:s=process.env,platform:f=process.platform}=o;return f!=="win32"?"PATH":Object.keys(s).reverse().find(d=>d.toUpperCase()==="PATH")||"Path"}t(Rfe,"pathKey");var K1r=t(({cwd:o=Mfe.cwd(),path:s=Mfe.env[Rfe()],preferLocal:f=!0,execPath:d=Mfe.execPath,addExecPath:y=!0}={})=>{let x=o instanceof URL?Kgt(o):o,P=wG.resolve(x),F=[];return f&&X1r(F,P),y&&Z1r(F,d,P),[...F,s].join(wG.delimiter)},"npmRunPath"),X1r=t((o,s)=>{let f;for(;f!==s;)o.push(wG.join(s,"node_modules/.bin")),f=s,s=wG.resolve(s,"..")},"applyPreferLocal"),Z1r=t((o,s,f)=>{let d=s instanceof URL?Kgt(s):s;o.push(wG.resolve(f,d,".."))},"applyExecPath"),Xgt=t(({env:o=Mfe.env,...s}={})=>{o={...o};let f=Rfe({env:o});return s.path=o[f],o[f]=K1r(s),o},"npmRunPathEnv");var Q1r=t((o,s,f,d)=>{if(f==="length"||f==="prototype"||f==="arguments"||f==="caller")return;let y=Object.getOwnPropertyDescriptor(o,f),x=Object.getOwnPropertyDescriptor(s,f);!evr(y,x)&&d||Object.defineProperty(o,f,x)},"copyProperty"),evr=t(function(o,s){return o===void 0||o.configurable||o.writable===s.writable&&o.enumerable===s.enumerable&&o.configurable===s.configurable&&(o.writable||o.value===s.value)},"canCopyProperty"),tvr=t((o,s)=>{let f=Object.getPrototypeOf(s);f!==Object.getPrototypeOf(o)&&Object.setPrototypeOf(o,f)},"changePrototype"),rvr=t((o,s)=>`/* Wrapped ${o}*/
|
|
648
648
|
${s}`,"wrappedToString"),nvr=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),ivr=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),svr=t((o,s,f)=>{let d=f===""?"":`with ${f.trim()}() `,y=rvr.bind(null,d,s.toString());Object.defineProperty(y,"name",ivr),Object.defineProperty(o,"toString",{...nvr,value:y})},"changeToString");function K8e(o,s,{ignoreNonConfigurable:f=!1}={}){let{name:d}=o;for(let y of Reflect.ownKeys(s))Q1r(o,s,y,f);return tvr(o,s),svr(o,s,d),o}t(K8e,"mimicFunction");var jfe=new WeakMap,Zgt=t((o,s={})=>{if(typeof o!="function")throw new TypeError("Expected a function");let f,d=0,y=o.displayName||o.name||"<anonymous>",x=t(function(...P){if(jfe.set(x,++d),d===1)f=o.apply(this,P),o=null;else if(s.throw===!0)throw new Error(`Function \`${y}\` can only be called once`);return f},"onetime");return K8e(x,o),jfe.set(x,d),x},"onetime");Zgt.callCount=o=>{if(!jfe.has(o))throw new Error(`The given function \`${o.name}\` is not wrapped by the \`onetime\` package`);return jfe.get(o)};var Qgt=Zgt;import{constants as lvr}from"os";var e0t=t(function(){let o=X8e-t0t+1;return Array.from({length:o},avr)},"getRealtimeSignals"),avr=t(function(o,s){return{name:`SIGRT${s+1}`,number:t0t+s,action:"terminate",description:"Application-specific signal (realtime)",standard:"posix"}},"getRealtimeSignal"),t0t=34,X8e=64;import{constants as ovr}from"os";var r0t=[{name:"SIGHUP",number:1,action:"terminate",description:"Terminal closed",standard:"posix"},{name:"SIGINT",number:2,action:"terminate",description:"User interruption with CTRL-C",standard:"ansi"},{name:"SIGQUIT",number:3,action:"core",description:"User interruption with CTRL-\\",standard:"posix"},{name:"SIGILL",number:4,action:"core",description:"Invalid machine instruction",standard:"ansi"},{name:"SIGTRAP",number:5,action:"core",description:"Debugger breakpoint",standard:"posix"},{name:"SIGABRT",number:6,action:"core",description:"Aborted",standard:"ansi"},{name:"SIGIOT",number:6,action:"core",description:"Aborted",standard:"bsd"},{name:"SIGBUS",number:7,action:"core",description:"Bus error due to misaligned, non-existing address or paging error",standard:"bsd"},{name:"SIGEMT",number:7,action:"terminate",description:"Command should be emulated but is not implemented",standard:"other"},{name:"SIGFPE",number:8,action:"core",description:"Floating point arithmetic error",standard:"ansi"},{name:"SIGKILL",number:9,action:"terminate",description:"Forced termination",standard:"posix",forced:!0},{name:"SIGUSR1",number:10,action:"terminate",description:"Application-specific signal",standard:"posix"},{name:"SIGSEGV",number:11,action:"core",description:"Segmentation fault",standard:"ansi"},{name:"SIGUSR2",number:12,action:"terminate",description:"Application-specific signal",standard:"posix"},{name:"SIGPIPE",number:13,action:"terminate",description:"Broken pipe or socket",standard:"posix"},{name:"SIGALRM",number:14,action:"terminate",description:"Timeout or timer",standard:"posix"},{name:"SIGTERM",number:15,action:"terminate",description:"Termination",standard:"ansi"},{name:"SIGSTKFLT",number:16,action:"terminate",description:"Stack is empty or overflowed",standard:"other"},{name:"SIGCHLD",number:17,action:"ignore",description:"Child process terminated, paused or unpaused",standard:"posix"},{name:"SIGCLD",number:17,action:"ignore",description:"Child process terminated, paused or unpaused",standard:"other"},{name:"SIGCONT",number:18,action:"unpause",description:"Unpaused",standard:"posix",forced:!0},{name:"SIGSTOP",number:19,action:"pause",description:"Paused",standard:"posix",forced:!0},{name:"SIGTSTP",number:20,action:"pause",description:'Paused using CTRL-Z or "suspend"',standard:"posix"},{name:"SIGTTIN",number:21,action:"pause",description:"Background process cannot read terminal input",standard:"posix"},{name:"SIGBREAK",number:21,action:"terminate",description:"User interruption with CTRL-BREAK",standard:"other"},{name:"SIGTTOU",number:22,action:"pause",description:"Background process cannot write to terminal output",standard:"posix"},{name:"SIGURG",number:23,action:"ignore",description:"Socket received out-of-band data",standard:"bsd"},{name:"SIGXCPU",number:24,action:"core",description:"Process timed out",standard:"bsd"},{name:"SIGXFSZ",number:25,action:"core",description:"File too big",standard:"bsd"},{name:"SIGVTALRM",number:26,action:"terminate",description:"Timeout or timer",standard:"bsd"},{name:"SIGPROF",number:27,action:"terminate",description:"Timeout or timer",standard:"bsd"},{name:"SIGWINCH",number:28,action:"ignore",description:"Terminal window size changed",standard:"bsd"},{name:"SIGIO",number:29,action:"terminate",description:"I/O is available",standard:"other"},{name:"SIGPOLL",number:29,action:"terminate",description:"Watched event",standard:"other"},{name:"SIGINFO",number:29,action:"ignore",description:"Request for process information",standard:"other"},{name:"SIGPWR",number:30,action:"terminate",description:"Device running out of power",standard:"systemv"},{name:"SIGSYS",number:31,action:"core",description:"Invalid system call",standard:"other"},{name:"SIGUNUSED",number:31,action:"terminate",description:"Invalid system call",standard:"other"}];var Z8e=t(function(){let o=e0t();return[...r0t,...o].map(cvr)},"getSignals"),cvr=t(function({name:o,number:s,description:f,action:d,forced:y=!1,standard:x}){let{signals:{[o]:P}}=ovr,F=P!==void 0;return{name:o,number:F?P:s,description:f,supported:F,action:d,forced:y,standard:x}},"normalizeSignal");var uvr=t(function(){return Z8e().reduce(fvr,{})},"getSignalsByName"),fvr=t(function(o,{name:s,number:f,description:d,supported:y,action:x,forced:P,standard:F}){return{...o,[s]:{name:s,number:f,description:d,supported:y,action:x,forced:P,standard:F}}},"getSignalByName"),n0t=uvr(),_vr=t(function(){let o=Z8e(),s=X8e+1,f=Array.from({length:s},(d,y)=>pvr(y,o));return Object.assign({},...f)},"getSignalsByNumber"),pvr=t(function(o,s){let f=dvr(o,s);if(f===void 0)return{};let{name:d,description:y,supported:x,action:P,forced:F,standard:J}=f;return{[o]:{name:d,number:o,description:y,supported:x,action:P,forced:F,standard:J}}},"getSignalByNumber"),dvr=t(function(o,s){let f=s.find(({name:d})=>lvr.signals[d]===o);return f!==void 0?f:s.find(d=>d.number===o)},"findSignalByNumber"),i9r=_vr();var mvr=t(({timedOut:o,timeout:s,errorCode:f,signal:d,signalDescription:y,exitCode:x,isCanceled:P})=>o?`timed out after ${s} milliseconds`:P?"was canceled":f!==void 0?`failed with ${f}`:d!==void 0?`was killed with ${d} (${y})`:x!==void 0?`failed with exit code ${x}`:"failed","getErrorPrefix"),Q8e=t(({stdout:o,stderr:s,all:f,error:d,signal:y,exitCode:x,command:P,escapedCommand:F,timedOut:J,isCanceled:G,killed:Se,parsed:{options:{timeout:de}}})=>{x=x===null?void 0:x,y=y===null?void 0:y;let ae=y===void 0?void 0:n0t[y].description,Ke=d&&d.code,Fe=`Command ${mvr({timedOut:J,timeout:de,errorCode:Ke,signal:y,signalDescription:ae,exitCode:x,isCanceled:G})}: ${P}`,Gt=Object.prototype.toString.call(d)==="[object Error]",jt=Gt?`${Fe}
|
|
649
649
|
${d.message}`:Fe,Pr=[jt,s,o].filter(Boolean).join(`
|
|
650
|
-
`);return Gt?(d.originalMessage=d.message,d.message=Pr):d=new Error(Pr),d.shortMessage=jt,d.command=P,d.escapedCommand=F,d.exitCode=x,d.signal=y,d.signalDescription=ae,d.stdout=o,d.stderr=s,f!==void 0&&(d.all=f),"bufferedData"in d&&delete d.bufferedData,d.failed=!0,d.timedOut=!!J,d.isCanceled=G,d.killed=Se&&!J,d},"makeError");var Bfe=["stdin","stdout","stderr"],hvr=t(o=>Bfe.some(s=>o[s]!==void 0),"hasAlias"),i0t=t(o=>{if(!o)return;let{stdio:s}=o;if(s===void 0)return Bfe.map(d=>o[d]);if(hvr(o))throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${Bfe.map(d=>`\`${d}\``).join(", ")}`);if(typeof s=="string")return s;if(!Array.isArray(s))throw new TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof s}\``);let f=Math.max(s.length,Bfe.length);return Array.from({length:f},(d,y)=>s[y])},"normalizeStdio");var f0t=Dp(u0t(),1);import gvr from"node:os";var yvr=1e3*5,_0t=t((o,s="SIGTERM",f={})=>{let d=o(s);return vvr(o,s,f,d),d},"spawnedKill"),vvr=t((o,s,f,d)=>{if(!bvr(s,f,d))return;let y=Tvr(f),x=setTimeout(()=>{o("SIGKILL")},y);x.unref&&x.unref()},"setKillTimeout"),bvr=t((o,{forceKillAfterTimeout:s},f)=>Svr(o)&&s!==!1&&f,"shouldForceKill"),Svr=t(o=>o===gvr.constants.signals.SIGTERM||typeof o=="string"&&o.toUpperCase()==="SIGTERM","isSigterm"),Tvr=t(({forceKillAfterTimeout:o=!0})=>{if(o===!0)return yvr;if(!Number.isFinite(o)||o<0)throw new TypeError(`Expected the \`forceKillAfterTimeout\` option to be a non-negative integer, got \`${o}\` (${typeof o})`);return o},"getForceKillAfterTimeout"),p0t=t((o,s)=>{o.kill()&&(s.isCanceled=!0)},"spawnedCancel"),xvr=t((o,s,f)=>{o.kill(s),f(Object.assign(new Error("Timed out"),{timedOut:!0,signal:s}))},"timeoutKill"),d0t=t((o,{timeout:s,killSignal:f="SIGTERM"},d)=>{if(s===0||s===void 0)return d;let y,x=new Promise((F,J)=>{y=setTimeout(()=>{xvr(o,f,J)},s)}),P=d.finally(()=>{clearTimeout(y)});return Promise.race([x,P])},"setupTimeout"),m0t=t(({timeout:o})=>{if(o!==void 0&&(!Number.isFinite(o)||o<0))throw new TypeError(`Expected the \`timeout\` option to be a non-negative integer, got \`${o}\` (${typeof o})`)},"validateTimeout"),h0t=t(async(o,{cleanup:s,detached:f},d)=>{if(!s||f)return d;let y=(0,f0t.default)(()=>{o.kill()});return d.finally(()=>{y()})},"setExitHandler");function g0t(o){return o!==null&&typeof o=="object"&&typeof o.pipe=="function"}t(g0t,"isStream");var sOe=Dp(b0t(),1),x0t=Dp(T0t(),1);var E0t=t((o,s)=>{s===void 0||o.stdin===void 0||(g0t(s)?s.pipe(o.stdin):o.stdin.end(s))},"handleInput"),C0t=t((o,{all:s})=>{if(!s||!o.stdout&&!o.stderr)return;let f=(0,x0t.default)();return o.stdout&&f.add(o.stdout),o.stderr&&f.add(o.stderr),f},"makeAllStream"),nOe=t(async(o,s)=>{if(o){o.destroy();try{return await s}catch(f){return f.bufferedData}}},"getBufferedData"),iOe=t((o,{encoding:s,buffer:f,maxBuffer:d})=>{if(!(!o||!f))return s?(0,sOe.default)(o,{encoding:s,maxBuffer:d}):sOe.default.buffer(o,{maxBuffer:d})},"getStreamPromise"),k0t=t(async({stdout:o,stderr:s,all:f},{encoding:d,buffer:y,maxBuffer:x},P)=>{let F=iOe(o,{encoding:d,buffer:y,maxBuffer:x}),J=iOe(s,{encoding:d,buffer:y,maxBuffer:x}),G=iOe(f,{encoding:d,buffer:y,maxBuffer:x*2});try{return await Promise.all([P,F,J,G])}catch(Se){return Promise.all([{error:Se,signal:Se.signal,timedOut:Se.timedOut},nOe(o,F),nOe(s,J),nOe(f,G)])}},"getSpawnedResult");var Nvr=(async()=>{})().constructor.prototype,Ivr=["then","catch","finally"].map(o=>[o,Reflect.getOwnPropertyDescriptor(Nvr,o)]),aOe=t((o,s)=>{for(let[f,d]of Ivr){let y=typeof s=="function"?(...x)=>Reflect.apply(d.value,s(),x):d.value.bind(s);Reflect.defineProperty(o,f,{...d,value:y})}return o},"mergePromise"),w0t=t(o=>new Promise((s,f)=>{o.on("exit",(d,y)=>{s({exitCode:d,signal:y})}),o.on("error",d=>{f(d)}),o.stdin&&o.stdin.on("error",d=>{f(d)})}),"getSpawnedPromise");var D0t=t((o,s=[])=>Array.isArray(s)?[o,...s]:[o],"normalizeArgs"),Ovr=/^[\w.-]+$/,Fvr=/"/g,Lvr=t(o=>typeof o!="string"||Ovr.test(o)?o:`"${o.replace(Fvr,'\\"')}"`,"escapeArg"),P0t=t((o,s)=>D0t(o,s).join(" "),"joinCommand"),A0t=t((o,s)=>D0t(o,s).map(f=>Lvr(f)).join(" "),"getEscapedCommand");var jvr=1e3*1e3*100,Bvr=t(({env:o,extendEnv:s,preferLocal:f,localDir:d,execPath:y})=>{let x=s?{...qfe.env,...o}:o;return f?Xgt({env:x,cwd:d,execPath:y}):x},"getEnv"),Uvr=t((o,s,f={})=>{let d=I0t.default._parse(o,s,f);return o=d.command,s=d.args,f=d.options,f={maxBuffer:jvr,buffer:!0,stripFinalNewline:!0,extendEnv:!0,preferLocal:!1,localDir:f.cwd||qfe.cwd(),execPath:qfe.execPath,encoding:"utf8",reject:!0,cleanup:!0,all:!1,windowsHide:!0,...f},f.env=Bvr(f),f.stdio=i0t(f),qfe.platform==="win32"&&Mvr.basename(o,".exe")==="cmd"&&s.unshift("/q"),{file:o,args:s,options:f,parsed:d}},"handleArguments"),oOe=t((o,s,f)=>typeof s!="string"&&!Rvr.isBuffer(s)?f===void 0?void 0:"":o.stripFinalNewline?Y8e(s):s,"handleOutput");function O0t(o,s,f){let d=Uvr(o,s,f),y=P0t(o,s),x=A0t(o,s);m0t(d.options);let P;try{P=N0t.spawn(d.file,d.args,d.options)}catch(Ke){let $e=new N0t.ChildProcess,Fe=Promise.reject(Q8e({error:Ke,stdout:"",stderr:"",all:"",command:y,escapedCommand:x,parsed:d,timedOut:!1,isCanceled:!1,killed:!1}));return aOe($e,Fe)}let F=w0t(P),J=d0t(P,d.options,F),G=h0t(P,d.options,J),Se={isCanceled:!1};P.kill=_0t.bind(null,P.kill.bind(P)),P.cancel=p0t.bind(null,P,Se);let ae=Qgt(t(async()=>{let[{error:Ke,exitCode:$e,signal:Fe,timedOut:Gt},jt,Pr,Fn]=await k0t(P,d.options,G),sn=oOe(d.options,jt),Un=oOe(d.options,Pr),Er=oOe(d.options,Fn);if(Ke||$e!==0||Fe!==null){let vr=Q8e({error:Ke,exitCode:$e,signal:Fe,stdout:sn,stderr:Un,all:Er,command:y,escapedCommand:x,parsed:d,timedOut:Gt,isCanceled:Se.isCanceled||(d.options.signal?d.options.signal.aborted:!1),killed:P.killed});if(!d.options.reject)return vr;throw vr}return{command:y,escapedCommand:x,exitCode:0,stdout:sn,stderr:Un,all:Er,failed:!1,timedOut:!1,isCanceled:!1,killed:!1}},"handlePromise"));return E0t(P,d.options.input),P.all=C0t(P,d.options),aOe(P,ae)}t(O0t,"execa");async function Hfe(o,s){if(o.__ZUPLO_LOG_LEVEL=process.env.__ZUPLO_LOG_LEVEL??process.env.LOG_LEVEL,o.__ZUPLO_LOG_FORMAT=process.env.__ZUPLO_LOG_FORMAT??process.env.LOG_FORMAT,o.LOG_LEVEL=process.env.LOG_LEVEL??process.env.LOG_LEVEL,o.LOG_FORMAT=process.env.LOG_FORMAT??process.env.LOG_FORMAT,o.GIT_SHA=process.env.GIT_SHA??await zvr(s),process.env.__ZUPLO_CONFIG&&(o.__ZUPLO_CONFIG=process.env.__ZUPLO_CONFIG),F0t(Vfe.join(s,".env.zuplo"))){let f=L0t(Vfe.join(s,".env.zuplo"),"utf8"),d=cOe.default.parse(f);for(let y of Object.keys(d))if(o[y]=d[y],y==="ZUPLO_SYSTEM_CONFIGURATIONS"){let x=Buffer.from(qoe.decode(d[y])).toString(),P=JSON.parse(x);for(let F of Object.keys(P))o[F]=P[F]}}if(F0t(Vfe.join(s,".env"))){let f=L0t(Vfe.join(s,".env"),"utf8"),d=cOe.default.parse(f);for(let y of Object.keys(d))o[y]=d[y]}for(let f of Object.keys(o))o[f]===void 0&&delete o[f];return o}t(Hfe,"setEnvironment");async function zvr(o){let s="unknown";try{let{stdout:f}=await O0t("git",["rev-parse","HEAD"],{cwd:o});f.trim().length===40&&(s=f.trim())}catch{}return s}t(zvr,"getGitSha");async function qvr({buildId:o,output:s,sourceDirectory:f,bundledDir:d,port:y,binaryName:x,publicZuploEnvironmentVariables:P,logger:F,handleRuntimeStdio:J}){if(d){let Se=AG.join(f,d,"modules.json");if(!$vr(Se))throw new Error("The bundled-dir does not contain a modules.json file.");let de=await Wvr(Se,"utf-8").then(JSON.parse),ae=await GM(f);return ae.status===jP?new Promise((Ke,$e)=>{G(ae.config.compatibilityDate,AG.join(f,d),de,Ke,J)().catch(Fe=>{F.error(Fe),$e(Fe)})}):(F.warn("Failed to get Zuplo config. Using default compatibility date."),new Promise((Ke,$e)=>{G(void 0,f,de,Ke,J)().catch(Fe=>{F.error(Fe),$e(Fe)})}))}else{let Se=new aA({buildId:o,output:s,sourceDirectory:f,command:"dev",logger:F,publicZuploEnvironmentVariables:P??{ZUPLO_ENVIRONMENT_TYPE:"LOCAL_DEVELOPMENT"},urls:void 0});try{await Se.start()}catch{F.info("Ran into irrecoverable error while building. Fix the error and rerun the command."),process.exit(1)}return new Promise((de,ae)=>{Se.onReload((Ke,$e)=>{($e||Ke?.errors&&Ke.errors.length>0)&&ae($e??Ke?.errors),G(Ke?.config?.compatibilityDate,AG.join(f,"dist"),HM(f,Ke?.metafile),de,J)().catch(Fe=>{F.error(Fe),ae(Fe)})})})}function G(Se,de,ae,Ke,$e){return async()=>{let Fe={};await Hfe(Fe,f);let Gt=new R0t.ZuploWorkerd({compatibilityDate:Se,scriptDirectory:de,modules:ae,port:y??km.DEV_SERVER_PORT,bindings:Fe,handleRuntimeStdio:$e}),jt=x??"compiled-zup",Pr=AG.join(f,"dist");await Jvr(Pr,{recursive:!0}),await Gt.compileBinary({binaryPath:AG.join(f,"dist",jt)}),await Gt.dispose(),Ke(void 0)}}t(G,"compile")}t(qvr,"compileWorkerdServer");import M0t from"node:assert";import Hvr from"node:child_process";import Gvr from"node:fs";import Gfe from"node:os";import Yvr from"node:path";import{Readable as j0t}from"node:stream";import{fileURLToPath as z0t}from"node:url";import Vvr from"node:net";function NG(o,s){return new Promise(f=>{let d=new Vvr.Socket;d.connect(s,o),d.on("connect",()=>{d.destroy(),f(!1)}),d.on("error",()=>{d.destroy(),f(!0)})})}t(NG,"isPortAvailable");function B0t(o,s){let f=import.meta.resolve(o),d=new URL(".",f),y=new URL(s,d);if(Gvr.existsSync(y))return z0t(y)}t(B0t,"getValidExecutablePath");function Kvr(){let o=Gfe.platform()==="win32"?"deno.exe":"deno",s=B0t("deno/package.json",o);if(s)return s;let f=Xvr(),d=B0t(`@deno/${f}/package.json`,o);if(d)return d;throw new Error("Failed to locate the managed-dedicated server executable.")}t(Kvr,"locateDenoExecutable");function Xvr(){let o=Gfe.platform();return o==="linux"?`${o}-${U0t()}-glibc`:`${o}-${U0t()}`}t(Xvr,"getTarget");function U0t(){let o=Gfe.arch();if(o!=="arm64"&&o!=="x64")throw new Error("Unsupported architecture "+Gfe.arch()+". Only x64 and aarch64 binaries are available.");return o}t(U0t,"getArch");var Yfe=class{static{t(this,"ZenoServer")}serverProcess;sourceDirectory;port;debugPort;processExitPromise;logger;output;buildWatcher;onReload;handleRuntimeStdio;denoExecutablePath;unsafelyIgnoreCertificateErrors;constructor(s){if(this.port=s.port??9e3,this.debugPort=s.debugPort,this.logger=s.logger,this.output=s.output,this.onReload=s.onReload,this.handleRuntimeStdio=s.handleRuntimeStdio,this.sourceDirectory=s.sourceDirectory,this.unsafelyIgnoreCertificateErrors=!!s.unsafelyIgnoreCertificateErrors,!s.zupTestMode){let f="http://localhost:3000",d=`http://localhost:${this.port}`;this.buildWatcher=new aA({sourceDirectory:s.sourceDirectory,command:"dev",logger:s.logger,publicZuploEnvironmentVariables:{...s.publicZuploEnvironmentVariables,ZUPLO_ENVIRONMENT_TYPE:"LOCAL_DEVELOPMENT"},buildId:"dev",output:s.output,urls:{devPortal:{defaultUrl:f,urls:[f]},api:{defaultUrl:d,urls:[d]}}}),this.buildWatcher.watchEnvFiles()}this.denoExecutablePath=Kvr()}getServeArgs(){let s=`${Yvr.dirname(z0t(import.meta.url))}/zeno.js`,f=["run","--allow-read","--allow-net","--allow-env","--allow-write",...this.unsafelyIgnoreCertificateErrors?["--unsafely-ignore-certificate-errors"]:[]];return this.debugPort&&f.push(`--inspect=127.0.0.1:${this.debugPort}`),f.push(s),f.push("--dir",this.sourceDirectory),f.push("--port",this.port.toString()),f}async getUnavailablePorts(){let s=[];return this.debugPort&&!await NG("127.0.0.1",this.debugPort)&&s.push(this.debugPort),await NG("127.0.0.1",this.port)||s.push(this.port),s}async start(){let s=await this.getUnavailablePorts();if(s.length>0)throw new Error(`The following ports are not available: ${s.join(", ")}`);if(this.buildWatcher)try{await this.buildWatcher.start()}catch(f){this.output.child("api").error(f.toString());let d="Ran into irrecoverable error while starting watcher. Fix the error and restart the server.";this.output.child("api").error(d),this.logger?.info(d),process.exit(1)}await this.startOrReload(),this.buildWatcher?.onReload((f,d)=>{d||f?.errors&&f.errors.length>0||(this.onReload(f,d),this.startOrReload().catch(y=>{this.output.child("api").error(y.toString()),this.logger?.error(y)}))})}async startOrReload(){try{await this.dispose(),this.logger?.info("Starting managed-dedicated local server");let s=this.getServeArgs();this.serverProcess=Hvr.spawn(this.denoExecutablePath,s,{stdio:["pipe","pipe","pipe"],env:{...process.env,FORCE_COLOR:"1"}}),M0t(this.serverProcess.stdout instanceof j0t),M0t(this.serverProcess.stderr instanceof j0t),this.processExitPromise=this.waitForExit(),this.handleRuntimeStdio(this.serverProcess.stdout,this.serverProcess.stderr)}catch(s){this.logger?.debug(s)}}waitForExit(){return new Promise(s=>{this.serverProcess?.once("exit",s)})}dispose(){return this.serverProcess?.kill("SIGKILL"),this.processExitPromise}async stop(){await this.dispose(),await this.buildWatcher?.close()}};var $0t=Dp(B8e(),1);import Zvr from"node:path";var Kfe=class{static{t(this,"WorkerdServer")}sourceDirectory;port;debugPort;buildWatcher;workerd;logger;output;handleRuntimeStdio;onReload;constructor(s){if(this.sourceDirectory=s.sourceDirectory,this.port=s.port??km.DEV_SERVER_PORT,this.debugPort=s.debugPort,this.logger=s.logger,this.output=s.output,this.handleRuntimeStdio=s.handleRuntimeStdio,this.onReload=s.onReload,!s.zupTestMode){let f="http://localhost:3000",d=`http://localhost:${this.port}`;this.buildWatcher=new aA({...s,logger:this.logger,publicZuploEnvironmentVariables:{...s.publicZuploEnvironmentVariables,ZUPLO_ENVIRONMENT_TYPE:"LOCAL_DEVELOPMENT"},urls:{devPortal:{defaultUrl:f,urls:[f]},api:{defaultUrl:d,urls:[d]}}}),this.buildWatcher.watchEnvFiles()}}async start(){if(!await NG("localhost",this.port))throw new Error(`Port ${this.port} is currently in use. Please use a different port.`);if(this.buildWatcher)try{await this.buildWatcher.start()}catch(f){this.output.child("api").error(f.toString());let d="Ran into irrecoverable error while starting watcher. Fix the error and restart the server.";this.output.child("api").error(d),this.logger?.info(d),process.exit(1)}this.buildWatcher?.onReload((f,d)=>{d||f?.errors&&f.errors.length>0||(this.onReload(f,d),this.startOrReload(f).catch(y=>{this.output.child("api").error(y.toString()),this.logger?.error(y)}))})}async startOrReload(s){try{let f={};await Hfe(f,this.sourceDirectory),await this.workerd?.dispose(),this.workerd=new $0t.ZuploWorkerd({compatibilityDate:s?.config?.compatibilityDate,scriptDirectory:Zvr.join(this.sourceDirectory,"dist"),modules:HM(this.sourceDirectory,s?.metafile),port:this.port,inspectorPort:this.debugPort??void 0,bindings:f,handleRuntimeStdio:this.handleRuntimeStdio}),await this.workerd.serve()}catch(f){this.logger?.debug(f)}}async stop(){await this.buildWatcher?.close(),await this.workerd?.dispose()}};async function Qvr(o){let s=await GM(o),f=!1;return s.status===jP&&(f=s.config.projectType!=="managed-edge"||(s.config.flags?.managedDedicatedFlags?.useZeno??!1)),f||process.env.ZUPLO_DEV_RUNTIME==="zeno"}t(Qvr,"useZeno");async function ebr({sourceDirectory:o,port:s,debugPort:f,publicZuploEnvironmentVariables:d,unsafelyIgnoreCertificateErrors:y,logger:x,output:P,buildId:F,onReload:J,handleRuntimeStdio:G}){process.env.ZUPLO_IS_LOCAL_DEVELOPMENT="true";let Se;await Qvr(o)?(x.debug("Starting managed-dedicated local dev server."),Se=new Yfe({sourceDirectory:o,port:s,debugPort:f,logger:x,output:P,publicZuploEnvironmentVariables:d,onReload:J,handleRuntimeStdio:G,unsafelyIgnoreCertificateErrors:y})):(x.debug("Starting edge local dev server."),Se=new Kfe({sourceDirectory:o,command:"dev",port:s,debugPort:f,publicZuploEnvironmentVariables:d,logger:x,output:P,buildId:F,onReload:J,handleRuntimeStdio:G})),await Se.start();async function de(){await Se.stop()}t(de,"handle"),process.on("SIGTERM",de),process.on("SIGINT",de)}t(ebr,"startDevServer");import*as Qfe from"node:path";var Lj=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,W0t=new Set,lOe=typeof process=="object"&&process?process:{},q0t=t((o,s,f,d)=>{typeof lOe.emitWarning=="function"?lOe.emitWarning(o,s,f,d):console.error(`[${f}] ${s}: ${o}`)},"emitWarning"),Xfe=globalThis.AbortController,J0t=globalThis.AbortSignal;if(typeof Xfe>"u"){J0t=class{static{t(this,"AbortSignal")}onabort;_onabort=[];reason;aborted=!1;addEventListener(d,y){this._onabort.push(y)}},Xfe=class{static{t(this,"AbortController")}constructor(){s()}signal=new J0t;abort(d){if(!this.signal.aborted){this.signal.reason=d,this.signal.aborted=!0;for(let y of this.signal._onabort)y(d);this.signal.onabort?.(d)}}};let o=lOe.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",s=t(()=>{o&&(o=!1,q0t("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",s))},"warnACPolyfill")}var tbr=t(o=>!W0t.has(o),"shouldWarn"),JMr=Symbol("type"),BI=t(o=>o&&o===Math.floor(o)&&o>0&&isFinite(o),"isPosInt"),V0t=t(o=>BI(o)?o<=Math.pow(2,8)?Uint8Array:o<=Math.pow(2,16)?Uint16Array:o<=Math.pow(2,32)?Uint32Array:o<=Number.MAX_SAFE_INTEGER?Rj:null:null,"getUintArray"),Rj=class extends Array{static{t(this,"ZeroArray")}constructor(s){super(s),this.fill(0)}},uOe=class o{static{t(this,"Stack")}heap;length;static#e=!1;static create(s){let f=V0t(s);if(!f)return[];o.#e=!0;let d=new o(s,f);return o.#e=!1,d}constructor(s,f){if(!o.#e)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new f(s),this.length=0}push(s){this.heap[this.length++]=s}pop(){return this.heap[--this.length]}},Zfe=class o{static{t(this,"LRUCache")}#e;#n;#t;#r;#s;#p;#o;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#_;#u;#c;#i;#a;#h;#m;#f;#d;#g;#y;#E;#T;#C;#k;#v;#x;#A;static unsafeExposeInternals(s){return{starts:s.#T,ttls:s.#C,sizes:s.#E,keyMap:s.#c,keyList:s.#i,valList:s.#a,next:s.#h,prev:s.#m,get head(){return s.#f},get tail(){return s.#d},free:s.#g,isBackgroundFetch:t(f=>s.#S(f),"isBackgroundFetch"),backgroundFetch:t((f,d,y,x)=>s.#j(f,d,y,x),"backgroundFetch"),moveToTail:t(f=>s.#$(f),"moveToTail"),indexes:t(f=>s.#N(f),"indexes"),rindexes:t(f=>s.#I(f),"rindexes"),isStale:t(f=>s.#P(f),"isStale")}}get max(){return this.#e}get maxSize(){return this.#n}get calculatedSize(){return this.#u}get size(){return this.#_}get fetchMethod(){return this.#p}get memoMethod(){return this.#o}get dispose(){return this.#t}get onInsert(){return this.#r}get disposeAfter(){return this.#s}constructor(s){let{max:f=0,ttl:d,ttlResolution:y=1,ttlAutopurge:x,updateAgeOnGet:P,updateAgeOnHas:F,allowStale:J,dispose:G,onInsert:Se,disposeAfter:de,noDisposeOnSet:ae,noUpdateTTL:Ke,maxSize:$e=0,maxEntrySize:Fe=0,sizeCalculation:Gt,fetchMethod:jt,memoMethod:Pr,noDeleteOnFetchRejection:Fn,noDeleteOnStaleGet:sn,allowStaleOnFetchRejection:Un,allowStaleOnFetchAbort:Er,ignoreFetchAbort:vr}=s;if(f!==0&&!BI(f))throw new TypeError("max option must be a nonnegative integer");let ls=f?V0t(f):Array;if(!ls)throw new Error("invalid max value: "+f);if(this.#e=f,this.#n=$e,this.maxEntrySize=Fe||this.#n,this.sizeCalculation=Gt,this.sizeCalculation){if(!this.#n&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(Pr!==void 0&&typeof Pr!="function")throw new TypeError("memoMethod must be a function if defined");if(this.#o=Pr,jt!==void 0&&typeof jt!="function")throw new TypeError("fetchMethod must be a function if specified");if(this.#p=jt,this.#v=!!jt,this.#c=new Map,this.#i=new Array(f).fill(void 0),this.#a=new Array(f).fill(void 0),this.#h=new ls(f),this.#m=new ls(f),this.#f=0,this.#d=0,this.#g=uOe.create(f),this.#_=0,this.#u=0,typeof G=="function"&&(this.#t=G),typeof Se=="function"&&(this.#r=Se),typeof de=="function"?(this.#s=de,this.#y=[]):(this.#s=void 0,this.#y=void 0),this.#k=!!this.#t,this.#A=!!this.#r,this.#x=!!this.#s,this.noDisposeOnSet=!!ae,this.noUpdateTTL=!!Ke,this.noDeleteOnFetchRejection=!!Fn,this.allowStaleOnFetchRejection=!!Un,this.allowStaleOnFetchAbort=!!Er,this.ignoreFetchAbort=!!vr,this.maxEntrySize!==0){if(this.#n!==0&&!BI(this.#n))throw new TypeError("maxSize must be a positive integer if specified");if(!BI(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#U()}if(this.allowStale=!!J,this.noDeleteOnStaleGet=!!sn,this.updateAgeOnGet=!!P,this.updateAgeOnHas=!!F,this.ttlResolution=BI(y)||y===0?y:1,this.ttlAutopurge=!!x,this.ttl=d||0,this.ttl){if(!BI(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#l()}if(this.#e===0&&this.ttl===0&&this.#n===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#e&&!this.#n){let Ni="LRU_CACHE_UNBOUNDED";tbr(Ni)&&(W0t.add(Ni),q0t("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",Ni,o))}}getRemainingTTL(s){return this.#c.has(s)?1/0:0}#l(){let s=new Rj(this.#e),f=new Rj(this.#e);this.#C=s,this.#T=f,this.#D=(x,P,F=Lj.now())=>{if(f[x]=P!==0?F:0,s[x]=P,P!==0&&this.ttlAutopurge){let J=setTimeout(()=>{this.#P(x)&&this.#B(this.#i[x],"expire")},P+1);J.unref&&J.unref()}},this.#O=x=>{f[x]=s[x]!==0?Lj.now():0},this.#w=(x,P)=>{if(s[P]){let F=s[P],J=f[P];if(!F||!J)return;x.ttl=F,x.start=J,x.now=d||y();let G=x.now-J;x.remainingTTL=F-G}};let d=0,y=t(()=>{let x=Lj.now();if(this.ttlResolution>0){d=x;let P=setTimeout(()=>d=0,this.ttlResolution);P.unref&&P.unref()}return x},"getNow");this.getRemainingTTL=x=>{let P=this.#c.get(x);if(P===void 0)return 0;let F=s[P],J=f[P];if(!F||!J)return 1/0;let G=(d||y())-J;return F-G},this.#P=x=>{let P=f[x],F=s[x];return!!F&&!!P&&(d||y())-P>F}}#O=t(()=>{},"#updateItemAge");#w=t(()=>{},"#statusTTL");#D=t(()=>{},"#setItemTTL");#P=t(()=>!1,"#isStale");#U(){let s=new Rj(this.#e);this.#u=0,this.#E=s,this.#R=f=>{this.#u-=s[f],s[f]=0},this.#L=(f,d,y,x)=>{if(this.#S(d))return 0;if(!BI(y))if(x){if(typeof x!="function")throw new TypeError("sizeCalculation must be a function");if(y=x(d,f),!BI(y))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return y},this.#F=(f,d,y)=>{if(s[f]=d,this.#n){let x=this.#n-s[f];for(;this.#u>x;)this.#b(!0)}this.#u+=s[f],y&&(y.entrySize=d,y.totalCalculatedSize=this.#u)}}#R=t(s=>{},"#removeItemSize");#F=t((s,f,d)=>{},"#addItemSize");#L=t((s,f,d,y)=>{if(d||y)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0},"#requireSize");*#N({allowStale:s=this.allowStale}={}){if(this.#_)for(let f=this.#d;!(!this.#z(f)||((s||!this.#P(f))&&(yield f),f===this.#f));)f=this.#m[f]}*#I({allowStale:s=this.allowStale}={}){if(this.#_)for(let f=this.#f;!(!this.#z(f)||((s||!this.#P(f))&&(yield f),f===this.#d));)f=this.#h[f]}#z(s){return s!==void 0&&this.#c.get(this.#i[s])===s}*entries(){for(let s of this.#N())this.#a[s]!==void 0&&this.#i[s]!==void 0&&!this.#S(this.#a[s])&&(yield[this.#i[s],this.#a[s]])}*rentries(){for(let s of this.#I())this.#a[s]!==void 0&&this.#i[s]!==void 0&&!this.#S(this.#a[s])&&(yield[this.#i[s],this.#a[s]])}*keys(){for(let s of this.#N()){let f=this.#i[s];f!==void 0&&!this.#S(this.#a[s])&&(yield f)}}*rkeys(){for(let s of this.#I()){let f=this.#i[s];f!==void 0&&!this.#S(this.#a[s])&&(yield f)}}*values(){for(let s of this.#N())this.#a[s]!==void 0&&!this.#S(this.#a[s])&&(yield this.#a[s])}*rvalues(){for(let s of this.#I())this.#a[s]!==void 0&&!this.#S(this.#a[s])&&(yield this.#a[s])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(s,f={}){for(let d of this.#N()){let y=this.#a[d],x=this.#S(y)?y.__staleWhileFetching:y;if(x!==void 0&&s(x,this.#i[d],this))return this.get(this.#i[d],f)}}forEach(s,f=this){for(let d of this.#N()){let y=this.#a[d],x=this.#S(y)?y.__staleWhileFetching:y;x!==void 0&&s.call(f,x,this.#i[d],this)}}rforEach(s,f=this){for(let d of this.#I()){let y=this.#a[d],x=this.#S(y)?y.__staleWhileFetching:y;x!==void 0&&s.call(f,x,this.#i[d],this)}}purgeStale(){let s=!1;for(let f of this.#I({allowStale:!0}))this.#P(f)&&(this.#B(this.#i[f],"expire"),s=!0);return s}info(s){let f=this.#c.get(s);if(f===void 0)return;let d=this.#a[f],y=this.#S(d)?d.__staleWhileFetching:d;if(y===void 0)return;let x={value:y};if(this.#C&&this.#T){let P=this.#C[f],F=this.#T[f];if(P&&F){let J=P-(Lj.now()-F);x.ttl=J,x.start=Date.now()}}return this.#E&&(x.size=this.#E[f]),x}dump(){let s=[];for(let f of this.#N({allowStale:!0})){let d=this.#i[f],y=this.#a[f],x=this.#S(y)?y.__staleWhileFetching:y;if(x===void 0||d===void 0)continue;let P={value:x};if(this.#C&&this.#T){P.ttl=this.#C[f];let F=Lj.now()-this.#T[f];P.start=Math.floor(Date.now()-F)}this.#E&&(P.size=this.#E[f]),s.unshift([d,P])}return s}load(s){this.clear();for(let[f,d]of s){if(d.start){let y=Date.now()-d.start;d.start=Lj.now()-y}this.set(f,d.value,d)}}set(s,f,d={}){if(f===void 0)return this.delete(s),this;let{ttl:y=this.ttl,start:x,noDisposeOnSet:P=this.noDisposeOnSet,sizeCalculation:F=this.sizeCalculation,status:J}=d,{noUpdateTTL:G=this.noUpdateTTL}=d,Se=this.#L(s,f,d.size||0,F);if(this.maxEntrySize&&Se>this.maxEntrySize)return J&&(J.set="miss",J.maxEntrySizeExceeded=!0),this.#B(s,"set"),this;let de=this.#_===0?void 0:this.#c.get(s);if(de===void 0)de=this.#_===0?this.#d:this.#g.length!==0?this.#g.pop():this.#_===this.#e?this.#b(!1):this.#_,this.#i[de]=s,this.#a[de]=f,this.#c.set(s,de),this.#h[this.#d]=de,this.#m[de]=this.#d,this.#d=de,this.#_++,this.#F(de,Se,J),J&&(J.set="add"),G=!1,this.#A&&this.#r?.(f,s,"add");else{this.#$(de);let ae=this.#a[de];if(f!==ae){if(this.#v&&this.#S(ae)){ae.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:Ke}=ae;Ke!==void 0&&!P&&(this.#k&&this.#t?.(Ke,s,"set"),this.#x&&this.#y?.push([Ke,s,"set"]))}else P||(this.#k&&this.#t?.(ae,s,"set"),this.#x&&this.#y?.push([ae,s,"set"]));if(this.#R(de),this.#F(de,Se,J),this.#a[de]=f,J){J.set="replace";let Ke=ae&&this.#S(ae)?ae.__staleWhileFetching:ae;Ke!==void 0&&(J.oldValue=Ke)}}else J&&(J.set="update");this.#A&&this.onInsert?.(f,s,f===ae?"update":"replace")}if(y!==0&&!this.#C&&this.#l(),this.#C&&(G||this.#D(de,y,x),J&&this.#w(J,de)),!P&&this.#x&&this.#y){let ae=this.#y,Ke;for(;Ke=ae?.shift();)this.#s?.(...Ke)}return this}pop(){try{for(;this.#_;){let s=this.#a[this.#f];if(this.#b(!0),this.#S(s)){if(s.__staleWhileFetching)return s.__staleWhileFetching}else if(s!==void 0)return s}}finally{if(this.#x&&this.#y){let s=this.#y,f;for(;f=s?.shift();)this.#s?.(...f)}}}#b(s){let f=this.#f,d=this.#i[f],y=this.#a[f];return this.#v&&this.#S(y)?y.__abortController.abort(new Error("evicted")):(this.#k||this.#x)&&(this.#k&&this.#t?.(y,d,"evict"),this.#x&&this.#y?.push([y,d,"evict"])),this.#R(f),s&&(this.#i[f]=void 0,this.#a[f]=void 0,this.#g.push(f)),this.#_===1?(this.#f=this.#d=0,this.#g.length=0):this.#f=this.#h[f],this.#c.delete(d),this.#_--,f}has(s,f={}){let{updateAgeOnHas:d=this.updateAgeOnHas,status:y}=f,x=this.#c.get(s);if(x!==void 0){let P=this.#a[x];if(this.#S(P)&&P.__staleWhileFetching===void 0)return!1;if(this.#P(x))y&&(y.has="stale",this.#w(y,x));else return d&&this.#O(x),y&&(y.has="hit",this.#w(y,x)),!0}else y&&(y.has="miss");return!1}peek(s,f={}){let{allowStale:d=this.allowStale}=f,y=this.#c.get(s);if(y===void 0||!d&&this.#P(y))return;let x=this.#a[y];return this.#S(x)?x.__staleWhileFetching:x}#j(s,f,d,y){let x=f===void 0?void 0:this.#a[f];if(this.#S(x))return x;let P=new Xfe,{signal:F}=d;F?.addEventListener("abort",()=>P.abort(F.reason),{signal:P.signal});let J={signal:P.signal,options:d,context:y},G=t((Fe,Gt=!1)=>{let{aborted:jt}=P.signal,Pr=d.ignoreFetchAbort&&Fe!==void 0;if(d.status&&(jt&&!Gt?(d.status.fetchAborted=!0,d.status.fetchError=P.signal.reason,Pr&&(d.status.fetchAbortIgnored=!0)):d.status.fetchResolved=!0),jt&&!Pr&&!Gt)return de(P.signal.reason);let Fn=Ke;return this.#a[f]===Ke&&(Fe===void 0?Fn.__staleWhileFetching?this.#a[f]=Fn.__staleWhileFetching:this.#B(s,"fetch"):(d.status&&(d.status.fetchUpdated=!0),this.set(s,Fe,J.options))),Fe},"cb"),Se=t(Fe=>(d.status&&(d.status.fetchRejected=!0,d.status.fetchError=Fe),de(Fe)),"eb"),de=t(Fe=>{let{aborted:Gt}=P.signal,jt=Gt&&d.allowStaleOnFetchAbort,Pr=jt||d.allowStaleOnFetchRejection,Fn=Pr||d.noDeleteOnFetchRejection,sn=Ke;if(this.#a[f]===Ke&&(!Fn||sn.__staleWhileFetching===void 0?this.#B(s,"fetch"):jt||(this.#a[f]=sn.__staleWhileFetching)),Pr)return d.status&&sn.__staleWhileFetching!==void 0&&(d.status.returnedStale=!0),sn.__staleWhileFetching;if(sn.__returned===sn)throw Fe},"fetchFail"),ae=t((Fe,Gt)=>{let jt=this.#p?.(s,x,J);jt&&jt instanceof Promise&&jt.then(Pr=>Fe(Pr===void 0?void 0:Pr),Gt),P.signal.addEventListener("abort",()=>{(!d.ignoreFetchAbort||d.allowStaleOnFetchAbort)&&(Fe(void 0),d.allowStaleOnFetchAbort&&(Fe=t(Pr=>G(Pr,!0),"res")))})},"pcall");d.status&&(d.status.fetchDispatched=!0);let Ke=new Promise(ae).then(G,Se),$e=Object.assign(Ke,{__abortController:P,__staleWhileFetching:x,__returned:void 0});return f===void 0?(this.set(s,$e,{...J.options,status:void 0}),f=this.#c.get(s)):this.#a[f]=$e,$e}#S(s){if(!this.#v)return!1;let f=s;return!!f&&f instanceof Promise&&f.hasOwnProperty("__staleWhileFetching")&&f.__abortController instanceof Xfe}async fetch(s,f={}){let{allowStale:d=this.allowStale,updateAgeOnGet:y=this.updateAgeOnGet,noDeleteOnStaleGet:x=this.noDeleteOnStaleGet,ttl:P=this.ttl,noDisposeOnSet:F=this.noDisposeOnSet,size:J=0,sizeCalculation:G=this.sizeCalculation,noUpdateTTL:Se=this.noUpdateTTL,noDeleteOnFetchRejection:de=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:ae=this.allowStaleOnFetchRejection,ignoreFetchAbort:Ke=this.ignoreFetchAbort,allowStaleOnFetchAbort:$e=this.allowStaleOnFetchAbort,context:Fe,forceRefresh:Gt=!1,status:jt,signal:Pr}=f;if(!this.#v)return jt&&(jt.fetch="get"),this.get(s,{allowStale:d,updateAgeOnGet:y,noDeleteOnStaleGet:x,status:jt});let Fn={allowStale:d,updateAgeOnGet:y,noDeleteOnStaleGet:x,ttl:P,noDisposeOnSet:F,size:J,sizeCalculation:G,noUpdateTTL:Se,noDeleteOnFetchRejection:de,allowStaleOnFetchRejection:ae,allowStaleOnFetchAbort:$e,ignoreFetchAbort:Ke,status:jt,signal:Pr},sn=this.#c.get(s);if(sn===void 0){jt&&(jt.fetch="miss");let Un=this.#j(s,sn,Fn,Fe);return Un.__returned=Un}else{let Un=this.#a[sn];if(this.#S(Un)){let nc=d&&Un.__staleWhileFetching!==void 0;return jt&&(jt.fetch="inflight",nc&&(jt.returnedStale=!0)),nc?Un.__staleWhileFetching:Un.__returned=Un}let Er=this.#P(sn);if(!Gt&&!Er)return jt&&(jt.fetch="hit"),this.#$(sn),y&&this.#O(sn),jt&&this.#w(jt,sn),Un;let vr=this.#j(s,sn,Fn,Fe),Ni=vr.__staleWhileFetching!==void 0&&d;return jt&&(jt.fetch=Er?"stale":"refresh",Ni&&Er&&(jt.returnedStale=!0)),Ni?vr.__staleWhileFetching:vr.__returned=vr}}async forceFetch(s,f={}){let d=await this.fetch(s,f);if(d===void 0)throw new Error("fetch() returned undefined");return d}memo(s,f={}){let d=this.#o;if(!d)throw new Error("no memoMethod provided to constructor");let{context:y,forceRefresh:x,...P}=f,F=this.get(s,P);if(!x&&F!==void 0)return F;let J=d(s,F,{options:P,context:y});return this.set(s,J,P),J}get(s,f={}){let{allowStale:d=this.allowStale,updateAgeOnGet:y=this.updateAgeOnGet,noDeleteOnStaleGet:x=this.noDeleteOnStaleGet,status:P}=f,F=this.#c.get(s);if(F!==void 0){let J=this.#a[F],G=this.#S(J);return P&&this.#w(P,F),this.#P(F)?(P&&(P.get="stale"),G?(P&&d&&J.__staleWhileFetching!==void 0&&(P.returnedStale=!0),d?J.__staleWhileFetching:void 0):(x||this.#B(s,"expire"),P&&d&&(P.returnedStale=!0),d?J:void 0)):(P&&(P.get="hit"),G?J.__staleWhileFetching:(this.#$(F),y&&this.#O(F),J))}else P&&(P.get="miss")}#M(s,f){this.#m[f]=s,this.#h[s]=f}#$(s){s!==this.#d&&(s===this.#f?this.#f=this.#h[s]:this.#M(this.#m[s],this.#h[s]),this.#M(this.#d,s),this.#d=s)}delete(s){return this.#B(s,"delete")}#B(s,f){let d=!1;if(this.#_!==0){let y=this.#c.get(s);if(y!==void 0)if(d=!0,this.#_===1)this.#J(f);else{this.#R(y);let x=this.#a[y];if(this.#S(x)?x.__abortController.abort(new Error("deleted")):(this.#k||this.#x)&&(this.#k&&this.#t?.(x,s,f),this.#x&&this.#y?.push([x,s,f])),this.#c.delete(s),this.#i[y]=void 0,this.#a[y]=void 0,y===this.#d)this.#d=this.#m[y];else if(y===this.#f)this.#f=this.#h[y];else{let P=this.#m[y];this.#h[P]=this.#h[y];let F=this.#h[y];this.#m[F]=this.#m[y]}this.#_--,this.#g.push(y)}}if(this.#x&&this.#y?.length){let y=this.#y,x;for(;x=y?.shift();)this.#s?.(...x)}return d}clear(){return this.#J("delete")}#J(s){for(let f of this.#I({allowStale:!0})){let d=this.#a[f];if(this.#S(d))d.__abortController.abort(new Error("deleted"));else{let y=this.#i[f];this.#k&&this.#t?.(d,y,s),this.#x&&this.#y?.push([d,y,s])}}if(this.#c.clear(),this.#a.fill(void 0),this.#i.fill(void 0),this.#C&&this.#T&&(this.#C.fill(0),this.#T.fill(0)),this.#E&&this.#E.fill(0),this.#f=0,this.#d=0,this.#g.length=0,this.#u=0,this.#_=0,this.#x&&this.#y){let f=this.#y,d;for(;d=f?.shift();)this.#s?.(...d)}}};import{SourceMapConsumer as rbr}from"source-map";var fOe=new Zfe({max:100,ttl:1e3*60*5,dispose:t(o=>{o&&o.destroy()},"dispose")});function nbr(o){let s=o.split(`
|
|
650
|
+
`);return Gt?(d.originalMessage=d.message,d.message=Pr):d=new Error(Pr),d.shortMessage=jt,d.command=P,d.escapedCommand=F,d.exitCode=x,d.signal=y,d.signalDescription=ae,d.stdout=o,d.stderr=s,f!==void 0&&(d.all=f),"bufferedData"in d&&delete d.bufferedData,d.failed=!0,d.timedOut=!!J,d.isCanceled=G,d.killed=Se&&!J,d},"makeError");var Bfe=["stdin","stdout","stderr"],hvr=t(o=>Bfe.some(s=>o[s]!==void 0),"hasAlias"),i0t=t(o=>{if(!o)return;let{stdio:s}=o;if(s===void 0)return Bfe.map(d=>o[d]);if(hvr(o))throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${Bfe.map(d=>`\`${d}\``).join(", ")}`);if(typeof s=="string")return s;if(!Array.isArray(s))throw new TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof s}\``);let f=Math.max(s.length,Bfe.length);return Array.from({length:f},(d,y)=>s[y])},"normalizeStdio");var f0t=Dp(u0t(),1);import gvr from"node:os";var yvr=1e3*5,_0t=t((o,s="SIGTERM",f={})=>{let d=o(s);return vvr(o,s,f,d),d},"spawnedKill"),vvr=t((o,s,f,d)=>{if(!bvr(s,f,d))return;let y=Tvr(f),x=setTimeout(()=>{o("SIGKILL")},y);x.unref&&x.unref()},"setKillTimeout"),bvr=t((o,{forceKillAfterTimeout:s},f)=>Svr(o)&&s!==!1&&f,"shouldForceKill"),Svr=t(o=>o===gvr.constants.signals.SIGTERM||typeof o=="string"&&o.toUpperCase()==="SIGTERM","isSigterm"),Tvr=t(({forceKillAfterTimeout:o=!0})=>{if(o===!0)return yvr;if(!Number.isFinite(o)||o<0)throw new TypeError(`Expected the \`forceKillAfterTimeout\` option to be a non-negative integer, got \`${o}\` (${typeof o})`);return o},"getForceKillAfterTimeout"),p0t=t((o,s)=>{o.kill()&&(s.isCanceled=!0)},"spawnedCancel"),xvr=t((o,s,f)=>{o.kill(s),f(Object.assign(new Error("Timed out"),{timedOut:!0,signal:s}))},"timeoutKill"),d0t=t((o,{timeout:s,killSignal:f="SIGTERM"},d)=>{if(s===0||s===void 0)return d;let y,x=new Promise((F,J)=>{y=setTimeout(()=>{xvr(o,f,J)},s)}),P=d.finally(()=>{clearTimeout(y)});return Promise.race([x,P])},"setupTimeout"),m0t=t(({timeout:o})=>{if(o!==void 0&&(!Number.isFinite(o)||o<0))throw new TypeError(`Expected the \`timeout\` option to be a non-negative integer, got \`${o}\` (${typeof o})`)},"validateTimeout"),h0t=t(async(o,{cleanup:s,detached:f},d)=>{if(!s||f)return d;let y=(0,f0t.default)(()=>{o.kill()});return d.finally(()=>{y()})},"setExitHandler");function g0t(o){return o!==null&&typeof o=="object"&&typeof o.pipe=="function"}t(g0t,"isStream");var sOe=Dp(b0t(),1),x0t=Dp(T0t(),1);var E0t=t((o,s)=>{s===void 0||o.stdin===void 0||(g0t(s)?s.pipe(o.stdin):o.stdin.end(s))},"handleInput"),C0t=t((o,{all:s})=>{if(!s||!o.stdout&&!o.stderr)return;let f=(0,x0t.default)();return o.stdout&&f.add(o.stdout),o.stderr&&f.add(o.stderr),f},"makeAllStream"),nOe=t(async(o,s)=>{if(o){o.destroy();try{return await s}catch(f){return f.bufferedData}}},"getBufferedData"),iOe=t((o,{encoding:s,buffer:f,maxBuffer:d})=>{if(!(!o||!f))return s?(0,sOe.default)(o,{encoding:s,maxBuffer:d}):sOe.default.buffer(o,{maxBuffer:d})},"getStreamPromise"),k0t=t(async({stdout:o,stderr:s,all:f},{encoding:d,buffer:y,maxBuffer:x},P)=>{let F=iOe(o,{encoding:d,buffer:y,maxBuffer:x}),J=iOe(s,{encoding:d,buffer:y,maxBuffer:x}),G=iOe(f,{encoding:d,buffer:y,maxBuffer:x*2});try{return await Promise.all([P,F,J,G])}catch(Se){return Promise.all([{error:Se,signal:Se.signal,timedOut:Se.timedOut},nOe(o,F),nOe(s,J),nOe(f,G)])}},"getSpawnedResult");var Nvr=(async()=>{})().constructor.prototype,Ivr=["then","catch","finally"].map(o=>[o,Reflect.getOwnPropertyDescriptor(Nvr,o)]),aOe=t((o,s)=>{for(let[f,d]of Ivr){let y=typeof s=="function"?(...x)=>Reflect.apply(d.value,s(),x):d.value.bind(s);Reflect.defineProperty(o,f,{...d,value:y})}return o},"mergePromise"),w0t=t(o=>new Promise((s,f)=>{o.on("exit",(d,y)=>{s({exitCode:d,signal:y})}),o.on("error",d=>{f(d)}),o.stdin&&o.stdin.on("error",d=>{f(d)})}),"getSpawnedPromise");var D0t=t((o,s=[])=>Array.isArray(s)?[o,...s]:[o],"normalizeArgs"),Ovr=/^[\w.-]+$/,Fvr=/"/g,Lvr=t(o=>typeof o!="string"||Ovr.test(o)?o:`"${o.replace(Fvr,'\\"')}"`,"escapeArg"),P0t=t((o,s)=>D0t(o,s).join(" "),"joinCommand"),A0t=t((o,s)=>D0t(o,s).map(f=>Lvr(f)).join(" "),"getEscapedCommand");var jvr=1e3*1e3*100,Bvr=t(({env:o,extendEnv:s,preferLocal:f,localDir:d,execPath:y})=>{let x=s?{...qfe.env,...o}:o;return f?Xgt({env:x,cwd:d,execPath:y}):x},"getEnv"),Uvr=t((o,s,f={})=>{let d=I0t.default._parse(o,s,f);return o=d.command,s=d.args,f=d.options,f={maxBuffer:jvr,buffer:!0,stripFinalNewline:!0,extendEnv:!0,preferLocal:!1,localDir:f.cwd||qfe.cwd(),execPath:qfe.execPath,encoding:"utf8",reject:!0,cleanup:!0,all:!1,windowsHide:!0,...f},f.env=Bvr(f),f.stdio=i0t(f),qfe.platform==="win32"&&Mvr.basename(o,".exe")==="cmd"&&s.unshift("/q"),{file:o,args:s,options:f,parsed:d}},"handleArguments"),oOe=t((o,s,f)=>typeof s!="string"&&!Rvr.isBuffer(s)?f===void 0?void 0:"":o.stripFinalNewline?Y8e(s):s,"handleOutput");function O0t(o,s,f){let d=Uvr(o,s,f),y=P0t(o,s),x=A0t(o,s);m0t(d.options);let P;try{P=N0t.spawn(d.file,d.args,d.options)}catch(Ke){let $e=new N0t.ChildProcess,Fe=Promise.reject(Q8e({error:Ke,stdout:"",stderr:"",all:"",command:y,escapedCommand:x,parsed:d,timedOut:!1,isCanceled:!1,killed:!1}));return aOe($e,Fe)}let F=w0t(P),J=d0t(P,d.options,F),G=h0t(P,d.options,J),Se={isCanceled:!1};P.kill=_0t.bind(null,P.kill.bind(P)),P.cancel=p0t.bind(null,P,Se);let ae=Qgt(t(async()=>{let[{error:Ke,exitCode:$e,signal:Fe,timedOut:Gt},jt,Pr,Fn]=await k0t(P,d.options,G),sn=oOe(d.options,jt),Un=oOe(d.options,Pr),Er=oOe(d.options,Fn);if(Ke||$e!==0||Fe!==null){let vr=Q8e({error:Ke,exitCode:$e,signal:Fe,stdout:sn,stderr:Un,all:Er,command:y,escapedCommand:x,parsed:d,timedOut:Gt,isCanceled:Se.isCanceled||(d.options.signal?d.options.signal.aborted:!1),killed:P.killed});if(!d.options.reject)return vr;throw vr}return{command:y,escapedCommand:x,exitCode:0,stdout:sn,stderr:Un,all:Er,failed:!1,timedOut:!1,isCanceled:!1,killed:!1}},"handlePromise"));return E0t(P,d.options.input),P.all=C0t(P,d.options),aOe(P,ae)}t(O0t,"execa");async function Hfe(o,s){if(o.__ZUPLO_LOG_LEVEL=process.env.__ZUPLO_LOG_LEVEL??process.env.LOG_LEVEL,o.__ZUPLO_LOG_FORMAT=process.env.__ZUPLO_LOG_FORMAT??process.env.LOG_FORMAT,o.LOG_LEVEL=process.env.LOG_LEVEL??process.env.LOG_LEVEL,o.LOG_FORMAT=process.env.LOG_FORMAT??process.env.LOG_FORMAT,o.GIT_SHA=process.env.GIT_SHA??await zvr(s),process.env.__ZUPLO_CONFIG&&(o.__ZUPLO_CONFIG=process.env.__ZUPLO_CONFIG),F0t(Vfe.join(s,".env.zuplo"))){let f=L0t(Vfe.join(s,".env.zuplo"),"utf8"),d=cOe.default.parse(f);for(let y of Object.keys(d))if(o[y]=d[y],y==="ZUPLO_SYSTEM_CONFIGURATIONS"){let x=Buffer.from(qoe.decode(d[y])).toString(),P=JSON.parse(x);for(let F of Object.keys(P))o[F]=P[F]}}if(F0t(Vfe.join(s,".env"))){let f=L0t(Vfe.join(s,".env"),"utf8"),d=cOe.default.parse(f);for(let y of Object.keys(d))o[y]=d[y]}for(let f of Object.keys(o))o[f]===void 0&&delete o[f];return o}t(Hfe,"setEnvironment");async function zvr(o){let s="unknown";try{let{stdout:f}=await O0t("git",["rev-parse","HEAD"],{cwd:o});f.trim().length===40&&(s=f.trim())}catch{}return s}t(zvr,"getGitSha");async function qvr({buildId:o,output:s,sourceDirectory:f,bundledDir:d,port:y,binaryName:x,publicZuploEnvironmentVariables:P,logger:F,handleRuntimeStdio:J}){if(d){let Se=AG.join(f,d,"modules.json");if(!$vr(Se))throw new Error("The bundled-dir does not contain a modules.json file.");let de=await Wvr(Se,"utf-8").then(JSON.parse),ae=await GM(f);return ae.status===jP?new Promise((Ke,$e)=>{G(ae.config.compatibilityDate,AG.join(f,d),de,Ke,J)().catch(Fe=>{F.error(Fe),$e(Fe)})}):(F.warn("Failed to get Zuplo config. Using default compatibility date."),new Promise((Ke,$e)=>{G(void 0,f,de,Ke,J)().catch(Fe=>{F.error(Fe),$e(Fe)})}))}else{let Se=new aA({buildId:o,output:s,sourceDirectory:f,command:"dev",logger:F,publicZuploEnvironmentVariables:P??{ZUPLO_ENVIRONMENT_TYPE:"LOCAL_DEVELOPMENT"},urls:void 0});try{await Se.start()}catch{F.info("Ran into irrecoverable error while building. Fix the error and rerun the command."),process.exit(1)}return new Promise((de,ae)=>{Se.onReload((Ke,$e)=>{($e||Ke?.errors&&Ke.errors.length>0)&&ae($e??Ke?.errors),G(Ke?.config?.compatibilityDate,AG.join(f,"dist"),HM(f,Ke?.metafile),de,J)().catch(Fe=>{F.error(Fe),ae(Fe)})})})}function G(Se,de,ae,Ke,$e){return async()=>{let Fe={};await Hfe(Fe,f);let Gt=new R0t.ZuploWorkerd({compatibilityDate:Se,scriptDirectory:de,modules:ae,port:y??km.DEV_SERVER_PORT,bindings:Fe,handleRuntimeStdio:$e}),jt=x??"compiled-zup",Pr=AG.join(f,"dist");await Jvr(Pr,{recursive:!0}),await Gt.compileBinary({binaryPath:AG.join(f,"dist",jt)}),await Gt.dispose(),Ke(void 0)}}t(G,"compile")}t(qvr,"compileWorkerdServer");import M0t from"node:assert";import Hvr from"node:child_process";import Gvr from"node:fs";import Gfe from"node:os";import Yvr from"node:path";import{Readable as j0t}from"node:stream";import{fileURLToPath as z0t}from"node:url";import Vvr from"node:net";function NG(o,s){return new Promise(f=>{let d=new Vvr.Socket;d.connect(s,o),d.on("connect",()=>{d.destroy(),f(!1)}),d.on("error",()=>{d.destroy(),f(!0)})})}t(NG,"isPortAvailable");function B0t(o,s){let f=import.meta.resolve(o),d=new URL(".",f),y=new URL(s,d);if(Gvr.existsSync(y))return z0t(y)}t(B0t,"getValidExecutablePath");function Kvr(){let o=Gfe.platform()==="win32"?"deno.exe":"deno",s=B0t("deno/package.json",o);if(s)return s;let f=Xvr(),d=B0t(`@deno/${f}/package.json`,o);if(d)return d;throw new Error("Failed to locate the managed-dedicated server executable.")}t(Kvr,"locateDenoExecutable");function Xvr(){let o=Gfe.platform();return o==="linux"?`${o}-${U0t()}-glibc`:`${o}-${U0t()}`}t(Xvr,"getTarget");function U0t(){let o=Gfe.arch();if(o!=="arm64"&&o!=="x64")throw new Error("Unsupported architecture "+Gfe.arch()+". Only x64 and aarch64 binaries are available.");return o}t(U0t,"getArch");var Yfe=class{static{t(this,"ZenoServer")}serverProcess;sourceDirectory;port;debugPort;processExitPromise;logger;output;buildWatcher;onReload;handleRuntimeStdio;denoExecutablePath;unsafelyIgnoreCertificateErrors;constructor(s){if(this.port=s.port??9e3,this.debugPort=s.debugPort,this.logger=s.logger,this.output=s.output,this.onReload=s.onReload,this.handleRuntimeStdio=s.handleRuntimeStdio,this.sourceDirectory=s.sourceDirectory,this.unsafelyIgnoreCertificateErrors=!!s.unsafelyIgnoreCertificateErrors,!s.zupTestMode){let d=`http://localhost:${s.devPortalPort??3e3}`,y=`http://localhost:${this.port}`;this.buildWatcher=new aA({sourceDirectory:s.sourceDirectory,command:"dev",logger:s.logger,publicZuploEnvironmentVariables:{...s.publicZuploEnvironmentVariables,ZUPLO_ENVIRONMENT_TYPE:"LOCAL_DEVELOPMENT"},buildId:"dev",output:s.output,urls:{devPortal:{defaultUrl:d,urls:[d]},api:{defaultUrl:y,urls:[y]}}}),this.buildWatcher.watchEnvFiles()}this.denoExecutablePath=Kvr()}getServeArgs(){let s=`${Yvr.dirname(z0t(import.meta.url))}/zeno.js`,f=["run","--allow-read","--allow-net","--allow-env","--allow-write",...this.unsafelyIgnoreCertificateErrors?["--unsafely-ignore-certificate-errors"]:[]];return this.debugPort&&f.push(`--inspect=127.0.0.1:${this.debugPort}`),f.push(s),f.push("--dir",this.sourceDirectory),f.push("--port",this.port.toString()),f}async getUnavailablePorts(){let s=[];return this.debugPort&&!await NG("127.0.0.1",this.debugPort)&&s.push(this.debugPort),await NG("127.0.0.1",this.port)||s.push(this.port),s}async start(){let s=await this.getUnavailablePorts();if(s.length>0)throw new Error(`The following ports are not available: ${s.join(", ")}`);if(this.buildWatcher)try{await this.buildWatcher.start()}catch(f){this.output.child("api").error(f.toString());let d="Ran into irrecoverable error while starting watcher. Fix the error and restart the server.";this.output.child("api").error(d),this.logger?.info(d),process.exit(1)}await this.startOrReload(),this.buildWatcher?.onReload((f,d)=>{d||f?.errors&&f.errors.length>0||(this.onReload(f,d),this.startOrReload().catch(y=>{this.output.child("api").error(y.toString()),this.logger?.error(y)}))})}async startOrReload(){try{await this.dispose(),this.logger?.info("Starting managed-dedicated local server");let s=this.getServeArgs();this.serverProcess=Hvr.spawn(this.denoExecutablePath,s,{stdio:["pipe","pipe","pipe"],env:{...process.env,FORCE_COLOR:"1"}}),M0t(this.serverProcess.stdout instanceof j0t),M0t(this.serverProcess.stderr instanceof j0t),this.processExitPromise=this.waitForExit(),this.handleRuntimeStdio(this.serverProcess.stdout,this.serverProcess.stderr)}catch(s){this.logger?.debug(s)}}waitForExit(){return new Promise(s=>{this.serverProcess?.once("exit",s)})}dispose(){return this.serverProcess?.kill("SIGKILL"),this.processExitPromise}async stop(){await this.dispose(),await this.buildWatcher?.close()}};var $0t=Dp(B8e(),1);import Zvr from"node:path";var Kfe=class{static{t(this,"WorkerdServer")}sourceDirectory;port;debugPort;buildWatcher;workerd;logger;output;handleRuntimeStdio;onReload;constructor(s){if(this.sourceDirectory=s.sourceDirectory,this.port=s.port??km.DEV_SERVER_PORT,this.debugPort=s.debugPort,this.logger=s.logger,this.output=s.output,this.handleRuntimeStdio=s.handleRuntimeStdio,this.onReload=s.onReload,!s.zupTestMode){let d=`http://localhost:${s.devPortalPort??3e3}`,y=`http://localhost:${this.port}`;this.buildWatcher=new aA({...s,logger:this.logger,publicZuploEnvironmentVariables:{...s.publicZuploEnvironmentVariables,ZUPLO_ENVIRONMENT_TYPE:"LOCAL_DEVELOPMENT"},urls:{devPortal:{defaultUrl:d,urls:[d]},api:{defaultUrl:y,urls:[y]}}}),this.buildWatcher.watchEnvFiles()}}async start(){if(!await NG("localhost",this.port))throw new Error(`Port ${this.port} is currently in use. Please use a different port.`);if(this.buildWatcher)try{await this.buildWatcher.start()}catch(f){this.output.child("api").error(f.toString());let d="Ran into irrecoverable error while starting watcher. Fix the error and restart the server.";this.output.child("api").error(d),this.logger?.info(d),process.exit(1)}this.buildWatcher?.onReload((f,d)=>{d||f?.errors&&f.errors.length>0||(this.onReload(f,d),this.startOrReload(f).catch(y=>{this.output.child("api").error(y.toString()),this.logger?.error(y)}))})}async startOrReload(s){try{let f={};await Hfe(f,this.sourceDirectory),await this.workerd?.dispose(),this.workerd=new $0t.ZuploWorkerd({compatibilityDate:s?.config?.compatibilityDate,scriptDirectory:Zvr.join(this.sourceDirectory,"dist"),modules:HM(this.sourceDirectory,s?.metafile),port:this.port,inspectorPort:this.debugPort??void 0,bindings:f,handleRuntimeStdio:this.handleRuntimeStdio}),await this.workerd.serve()}catch(f){this.logger?.debug(f)}}async stop(){await this.buildWatcher?.close(),await this.workerd?.dispose()}};async function Qvr(o){let s=await GM(o),f=!1;return s.status===jP&&(f=s.config.projectType!=="managed-edge"||(s.config.flags?.managedDedicatedFlags?.useZeno??!1)),f||process.env.ZUPLO_DEV_RUNTIME==="zeno"}t(Qvr,"useZeno");async function ebr({sourceDirectory:o,port:s,debugPort:f,devPortalPort:d,publicZuploEnvironmentVariables:y,unsafelyIgnoreCertificateErrors:x,logger:P,output:F,buildId:J,onReload:G,handleRuntimeStdio:Se}){process.env.ZUPLO_IS_LOCAL_DEVELOPMENT="true";let de;await Qvr(o)?(P.debug("Starting managed-dedicated local dev server."),de=new Yfe({sourceDirectory:o,port:s,debugPort:f,devPortalPort:d,logger:P,output:F,publicZuploEnvironmentVariables:y,onReload:G,handleRuntimeStdio:Se,unsafelyIgnoreCertificateErrors:x})):(P.debug("Starting edge local dev server."),de=new Kfe({sourceDirectory:o,command:"dev",port:s,debugPort:f,devPortalPort:d,publicZuploEnvironmentVariables:y,logger:P,output:F,buildId:J,onReload:G,handleRuntimeStdio:Se})),await de.start();async function ae(){await de.stop()}t(ae,"handle"),process.on("SIGTERM",ae),process.on("SIGINT",ae)}t(ebr,"startDevServer");import*as Qfe from"node:path";var Lj=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,W0t=new Set,lOe=typeof process=="object"&&process?process:{},q0t=t((o,s,f,d)=>{typeof lOe.emitWarning=="function"?lOe.emitWarning(o,s,f,d):console.error(`[${f}] ${s}: ${o}`)},"emitWarning"),Xfe=globalThis.AbortController,J0t=globalThis.AbortSignal;if(typeof Xfe>"u"){J0t=class{static{t(this,"AbortSignal")}onabort;_onabort=[];reason;aborted=!1;addEventListener(d,y){this._onabort.push(y)}},Xfe=class{static{t(this,"AbortController")}constructor(){s()}signal=new J0t;abort(d){if(!this.signal.aborted){this.signal.reason=d,this.signal.aborted=!0;for(let y of this.signal._onabort)y(d);this.signal.onabort?.(d)}}};let o=lOe.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",s=t(()=>{o&&(o=!1,q0t("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",s))},"warnACPolyfill")}var tbr=t(o=>!W0t.has(o),"shouldWarn"),JMr=Symbol("type"),BI=t(o=>o&&o===Math.floor(o)&&o>0&&isFinite(o),"isPosInt"),V0t=t(o=>BI(o)?o<=Math.pow(2,8)?Uint8Array:o<=Math.pow(2,16)?Uint16Array:o<=Math.pow(2,32)?Uint32Array:o<=Number.MAX_SAFE_INTEGER?Rj:null:null,"getUintArray"),Rj=class extends Array{static{t(this,"ZeroArray")}constructor(s){super(s),this.fill(0)}},uOe=class o{static{t(this,"Stack")}heap;length;static#e=!1;static create(s){let f=V0t(s);if(!f)return[];o.#e=!0;let d=new o(s,f);return o.#e=!1,d}constructor(s,f){if(!o.#e)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new f(s),this.length=0}push(s){this.heap[this.length++]=s}pop(){return this.heap[--this.length]}},Zfe=class o{static{t(this,"LRUCache")}#e;#n;#t;#r;#s;#p;#o;ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#_;#u;#c;#i;#a;#h;#m;#f;#d;#g;#y;#E;#T;#C;#k;#v;#x;#A;static unsafeExposeInternals(s){return{starts:s.#T,ttls:s.#C,sizes:s.#E,keyMap:s.#c,keyList:s.#i,valList:s.#a,next:s.#h,prev:s.#m,get head(){return s.#f},get tail(){return s.#d},free:s.#g,isBackgroundFetch:t(f=>s.#S(f),"isBackgroundFetch"),backgroundFetch:t((f,d,y,x)=>s.#j(f,d,y,x),"backgroundFetch"),moveToTail:t(f=>s.#$(f),"moveToTail"),indexes:t(f=>s.#N(f),"indexes"),rindexes:t(f=>s.#I(f),"rindexes"),isStale:t(f=>s.#P(f),"isStale")}}get max(){return this.#e}get maxSize(){return this.#n}get calculatedSize(){return this.#u}get size(){return this.#_}get fetchMethod(){return this.#p}get memoMethod(){return this.#o}get dispose(){return this.#t}get onInsert(){return this.#r}get disposeAfter(){return this.#s}constructor(s){let{max:f=0,ttl:d,ttlResolution:y=1,ttlAutopurge:x,updateAgeOnGet:P,updateAgeOnHas:F,allowStale:J,dispose:G,onInsert:Se,disposeAfter:de,noDisposeOnSet:ae,noUpdateTTL:Ke,maxSize:$e=0,maxEntrySize:Fe=0,sizeCalculation:Gt,fetchMethod:jt,memoMethod:Pr,noDeleteOnFetchRejection:Fn,noDeleteOnStaleGet:sn,allowStaleOnFetchRejection:Un,allowStaleOnFetchAbort:Er,ignoreFetchAbort:vr}=s;if(f!==0&&!BI(f))throw new TypeError("max option must be a nonnegative integer");let ls=f?V0t(f):Array;if(!ls)throw new Error("invalid max value: "+f);if(this.#e=f,this.#n=$e,this.maxEntrySize=Fe||this.#n,this.sizeCalculation=Gt,this.sizeCalculation){if(!this.#n&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(Pr!==void 0&&typeof Pr!="function")throw new TypeError("memoMethod must be a function if defined");if(this.#o=Pr,jt!==void 0&&typeof jt!="function")throw new TypeError("fetchMethod must be a function if specified");if(this.#p=jt,this.#v=!!jt,this.#c=new Map,this.#i=new Array(f).fill(void 0),this.#a=new Array(f).fill(void 0),this.#h=new ls(f),this.#m=new ls(f),this.#f=0,this.#d=0,this.#g=uOe.create(f),this.#_=0,this.#u=0,typeof G=="function"&&(this.#t=G),typeof Se=="function"&&(this.#r=Se),typeof de=="function"?(this.#s=de,this.#y=[]):(this.#s=void 0,this.#y=void 0),this.#k=!!this.#t,this.#A=!!this.#r,this.#x=!!this.#s,this.noDisposeOnSet=!!ae,this.noUpdateTTL=!!Ke,this.noDeleteOnFetchRejection=!!Fn,this.allowStaleOnFetchRejection=!!Un,this.allowStaleOnFetchAbort=!!Er,this.ignoreFetchAbort=!!vr,this.maxEntrySize!==0){if(this.#n!==0&&!BI(this.#n))throw new TypeError("maxSize must be a positive integer if specified");if(!BI(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#U()}if(this.allowStale=!!J,this.noDeleteOnStaleGet=!!sn,this.updateAgeOnGet=!!P,this.updateAgeOnHas=!!F,this.ttlResolution=BI(y)||y===0?y:1,this.ttlAutopurge=!!x,this.ttl=d||0,this.ttl){if(!BI(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#l()}if(this.#e===0&&this.ttl===0&&this.#n===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#e&&!this.#n){let Ni="LRU_CACHE_UNBOUNDED";tbr(Ni)&&(W0t.add(Ni),q0t("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",Ni,o))}}getRemainingTTL(s){return this.#c.has(s)?1/0:0}#l(){let s=new Rj(this.#e),f=new Rj(this.#e);this.#C=s,this.#T=f,this.#D=(x,P,F=Lj.now())=>{if(f[x]=P!==0?F:0,s[x]=P,P!==0&&this.ttlAutopurge){let J=setTimeout(()=>{this.#P(x)&&this.#B(this.#i[x],"expire")},P+1);J.unref&&J.unref()}},this.#O=x=>{f[x]=s[x]!==0?Lj.now():0},this.#w=(x,P)=>{if(s[P]){let F=s[P],J=f[P];if(!F||!J)return;x.ttl=F,x.start=J,x.now=d||y();let G=x.now-J;x.remainingTTL=F-G}};let d=0,y=t(()=>{let x=Lj.now();if(this.ttlResolution>0){d=x;let P=setTimeout(()=>d=0,this.ttlResolution);P.unref&&P.unref()}return x},"getNow");this.getRemainingTTL=x=>{let P=this.#c.get(x);if(P===void 0)return 0;let F=s[P],J=f[P];if(!F||!J)return 1/0;let G=(d||y())-J;return F-G},this.#P=x=>{let P=f[x],F=s[x];return!!F&&!!P&&(d||y())-P>F}}#O=t(()=>{},"#updateItemAge");#w=t(()=>{},"#statusTTL");#D=t(()=>{},"#setItemTTL");#P=t(()=>!1,"#isStale");#U(){let s=new Rj(this.#e);this.#u=0,this.#E=s,this.#R=f=>{this.#u-=s[f],s[f]=0},this.#L=(f,d,y,x)=>{if(this.#S(d))return 0;if(!BI(y))if(x){if(typeof x!="function")throw new TypeError("sizeCalculation must be a function");if(y=x(d,f),!BI(y))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return y},this.#F=(f,d,y)=>{if(s[f]=d,this.#n){let x=this.#n-s[f];for(;this.#u>x;)this.#b(!0)}this.#u+=s[f],y&&(y.entrySize=d,y.totalCalculatedSize=this.#u)}}#R=t(s=>{},"#removeItemSize");#F=t((s,f,d)=>{},"#addItemSize");#L=t((s,f,d,y)=>{if(d||y)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0},"#requireSize");*#N({allowStale:s=this.allowStale}={}){if(this.#_)for(let f=this.#d;!(!this.#z(f)||((s||!this.#P(f))&&(yield f),f===this.#f));)f=this.#m[f]}*#I({allowStale:s=this.allowStale}={}){if(this.#_)for(let f=this.#f;!(!this.#z(f)||((s||!this.#P(f))&&(yield f),f===this.#d));)f=this.#h[f]}#z(s){return s!==void 0&&this.#c.get(this.#i[s])===s}*entries(){for(let s of this.#N())this.#a[s]!==void 0&&this.#i[s]!==void 0&&!this.#S(this.#a[s])&&(yield[this.#i[s],this.#a[s]])}*rentries(){for(let s of this.#I())this.#a[s]!==void 0&&this.#i[s]!==void 0&&!this.#S(this.#a[s])&&(yield[this.#i[s],this.#a[s]])}*keys(){for(let s of this.#N()){let f=this.#i[s];f!==void 0&&!this.#S(this.#a[s])&&(yield f)}}*rkeys(){for(let s of this.#I()){let f=this.#i[s];f!==void 0&&!this.#S(this.#a[s])&&(yield f)}}*values(){for(let s of this.#N())this.#a[s]!==void 0&&!this.#S(this.#a[s])&&(yield this.#a[s])}*rvalues(){for(let s of this.#I())this.#a[s]!==void 0&&!this.#S(this.#a[s])&&(yield this.#a[s])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(s,f={}){for(let d of this.#N()){let y=this.#a[d],x=this.#S(y)?y.__staleWhileFetching:y;if(x!==void 0&&s(x,this.#i[d],this))return this.get(this.#i[d],f)}}forEach(s,f=this){for(let d of this.#N()){let y=this.#a[d],x=this.#S(y)?y.__staleWhileFetching:y;x!==void 0&&s.call(f,x,this.#i[d],this)}}rforEach(s,f=this){for(let d of this.#I()){let y=this.#a[d],x=this.#S(y)?y.__staleWhileFetching:y;x!==void 0&&s.call(f,x,this.#i[d],this)}}purgeStale(){let s=!1;for(let f of this.#I({allowStale:!0}))this.#P(f)&&(this.#B(this.#i[f],"expire"),s=!0);return s}info(s){let f=this.#c.get(s);if(f===void 0)return;let d=this.#a[f],y=this.#S(d)?d.__staleWhileFetching:d;if(y===void 0)return;let x={value:y};if(this.#C&&this.#T){let P=this.#C[f],F=this.#T[f];if(P&&F){let J=P-(Lj.now()-F);x.ttl=J,x.start=Date.now()}}return this.#E&&(x.size=this.#E[f]),x}dump(){let s=[];for(let f of this.#N({allowStale:!0})){let d=this.#i[f],y=this.#a[f],x=this.#S(y)?y.__staleWhileFetching:y;if(x===void 0||d===void 0)continue;let P={value:x};if(this.#C&&this.#T){P.ttl=this.#C[f];let F=Lj.now()-this.#T[f];P.start=Math.floor(Date.now()-F)}this.#E&&(P.size=this.#E[f]),s.unshift([d,P])}return s}load(s){this.clear();for(let[f,d]of s){if(d.start){let y=Date.now()-d.start;d.start=Lj.now()-y}this.set(f,d.value,d)}}set(s,f,d={}){if(f===void 0)return this.delete(s),this;let{ttl:y=this.ttl,start:x,noDisposeOnSet:P=this.noDisposeOnSet,sizeCalculation:F=this.sizeCalculation,status:J}=d,{noUpdateTTL:G=this.noUpdateTTL}=d,Se=this.#L(s,f,d.size||0,F);if(this.maxEntrySize&&Se>this.maxEntrySize)return J&&(J.set="miss",J.maxEntrySizeExceeded=!0),this.#B(s,"set"),this;let de=this.#_===0?void 0:this.#c.get(s);if(de===void 0)de=this.#_===0?this.#d:this.#g.length!==0?this.#g.pop():this.#_===this.#e?this.#b(!1):this.#_,this.#i[de]=s,this.#a[de]=f,this.#c.set(s,de),this.#h[this.#d]=de,this.#m[de]=this.#d,this.#d=de,this.#_++,this.#F(de,Se,J),J&&(J.set="add"),G=!1,this.#A&&this.#r?.(f,s,"add");else{this.#$(de);let ae=this.#a[de];if(f!==ae){if(this.#v&&this.#S(ae)){ae.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:Ke}=ae;Ke!==void 0&&!P&&(this.#k&&this.#t?.(Ke,s,"set"),this.#x&&this.#y?.push([Ke,s,"set"]))}else P||(this.#k&&this.#t?.(ae,s,"set"),this.#x&&this.#y?.push([ae,s,"set"]));if(this.#R(de),this.#F(de,Se,J),this.#a[de]=f,J){J.set="replace";let Ke=ae&&this.#S(ae)?ae.__staleWhileFetching:ae;Ke!==void 0&&(J.oldValue=Ke)}}else J&&(J.set="update");this.#A&&this.onInsert?.(f,s,f===ae?"update":"replace")}if(y!==0&&!this.#C&&this.#l(),this.#C&&(G||this.#D(de,y,x),J&&this.#w(J,de)),!P&&this.#x&&this.#y){let ae=this.#y,Ke;for(;Ke=ae?.shift();)this.#s?.(...Ke)}return this}pop(){try{for(;this.#_;){let s=this.#a[this.#f];if(this.#b(!0),this.#S(s)){if(s.__staleWhileFetching)return s.__staleWhileFetching}else if(s!==void 0)return s}}finally{if(this.#x&&this.#y){let s=this.#y,f;for(;f=s?.shift();)this.#s?.(...f)}}}#b(s){let f=this.#f,d=this.#i[f],y=this.#a[f];return this.#v&&this.#S(y)?y.__abortController.abort(new Error("evicted")):(this.#k||this.#x)&&(this.#k&&this.#t?.(y,d,"evict"),this.#x&&this.#y?.push([y,d,"evict"])),this.#R(f),s&&(this.#i[f]=void 0,this.#a[f]=void 0,this.#g.push(f)),this.#_===1?(this.#f=this.#d=0,this.#g.length=0):this.#f=this.#h[f],this.#c.delete(d),this.#_--,f}has(s,f={}){let{updateAgeOnHas:d=this.updateAgeOnHas,status:y}=f,x=this.#c.get(s);if(x!==void 0){let P=this.#a[x];if(this.#S(P)&&P.__staleWhileFetching===void 0)return!1;if(this.#P(x))y&&(y.has="stale",this.#w(y,x));else return d&&this.#O(x),y&&(y.has="hit",this.#w(y,x)),!0}else y&&(y.has="miss");return!1}peek(s,f={}){let{allowStale:d=this.allowStale}=f,y=this.#c.get(s);if(y===void 0||!d&&this.#P(y))return;let x=this.#a[y];return this.#S(x)?x.__staleWhileFetching:x}#j(s,f,d,y){let x=f===void 0?void 0:this.#a[f];if(this.#S(x))return x;let P=new Xfe,{signal:F}=d;F?.addEventListener("abort",()=>P.abort(F.reason),{signal:P.signal});let J={signal:P.signal,options:d,context:y},G=t((Fe,Gt=!1)=>{let{aborted:jt}=P.signal,Pr=d.ignoreFetchAbort&&Fe!==void 0;if(d.status&&(jt&&!Gt?(d.status.fetchAborted=!0,d.status.fetchError=P.signal.reason,Pr&&(d.status.fetchAbortIgnored=!0)):d.status.fetchResolved=!0),jt&&!Pr&&!Gt)return de(P.signal.reason);let Fn=Ke;return this.#a[f]===Ke&&(Fe===void 0?Fn.__staleWhileFetching?this.#a[f]=Fn.__staleWhileFetching:this.#B(s,"fetch"):(d.status&&(d.status.fetchUpdated=!0),this.set(s,Fe,J.options))),Fe},"cb"),Se=t(Fe=>(d.status&&(d.status.fetchRejected=!0,d.status.fetchError=Fe),de(Fe)),"eb"),de=t(Fe=>{let{aborted:Gt}=P.signal,jt=Gt&&d.allowStaleOnFetchAbort,Pr=jt||d.allowStaleOnFetchRejection,Fn=Pr||d.noDeleteOnFetchRejection,sn=Ke;if(this.#a[f]===Ke&&(!Fn||sn.__staleWhileFetching===void 0?this.#B(s,"fetch"):jt||(this.#a[f]=sn.__staleWhileFetching)),Pr)return d.status&&sn.__staleWhileFetching!==void 0&&(d.status.returnedStale=!0),sn.__staleWhileFetching;if(sn.__returned===sn)throw Fe},"fetchFail"),ae=t((Fe,Gt)=>{let jt=this.#p?.(s,x,J);jt&&jt instanceof Promise&&jt.then(Pr=>Fe(Pr===void 0?void 0:Pr),Gt),P.signal.addEventListener("abort",()=>{(!d.ignoreFetchAbort||d.allowStaleOnFetchAbort)&&(Fe(void 0),d.allowStaleOnFetchAbort&&(Fe=t(Pr=>G(Pr,!0),"res")))})},"pcall");d.status&&(d.status.fetchDispatched=!0);let Ke=new Promise(ae).then(G,Se),$e=Object.assign(Ke,{__abortController:P,__staleWhileFetching:x,__returned:void 0});return f===void 0?(this.set(s,$e,{...J.options,status:void 0}),f=this.#c.get(s)):this.#a[f]=$e,$e}#S(s){if(!this.#v)return!1;let f=s;return!!f&&f instanceof Promise&&f.hasOwnProperty("__staleWhileFetching")&&f.__abortController instanceof Xfe}async fetch(s,f={}){let{allowStale:d=this.allowStale,updateAgeOnGet:y=this.updateAgeOnGet,noDeleteOnStaleGet:x=this.noDeleteOnStaleGet,ttl:P=this.ttl,noDisposeOnSet:F=this.noDisposeOnSet,size:J=0,sizeCalculation:G=this.sizeCalculation,noUpdateTTL:Se=this.noUpdateTTL,noDeleteOnFetchRejection:de=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:ae=this.allowStaleOnFetchRejection,ignoreFetchAbort:Ke=this.ignoreFetchAbort,allowStaleOnFetchAbort:$e=this.allowStaleOnFetchAbort,context:Fe,forceRefresh:Gt=!1,status:jt,signal:Pr}=f;if(!this.#v)return jt&&(jt.fetch="get"),this.get(s,{allowStale:d,updateAgeOnGet:y,noDeleteOnStaleGet:x,status:jt});let Fn={allowStale:d,updateAgeOnGet:y,noDeleteOnStaleGet:x,ttl:P,noDisposeOnSet:F,size:J,sizeCalculation:G,noUpdateTTL:Se,noDeleteOnFetchRejection:de,allowStaleOnFetchRejection:ae,allowStaleOnFetchAbort:$e,ignoreFetchAbort:Ke,status:jt,signal:Pr},sn=this.#c.get(s);if(sn===void 0){jt&&(jt.fetch="miss");let Un=this.#j(s,sn,Fn,Fe);return Un.__returned=Un}else{let Un=this.#a[sn];if(this.#S(Un)){let nc=d&&Un.__staleWhileFetching!==void 0;return jt&&(jt.fetch="inflight",nc&&(jt.returnedStale=!0)),nc?Un.__staleWhileFetching:Un.__returned=Un}let Er=this.#P(sn);if(!Gt&&!Er)return jt&&(jt.fetch="hit"),this.#$(sn),y&&this.#O(sn),jt&&this.#w(jt,sn),Un;let vr=this.#j(s,sn,Fn,Fe),Ni=vr.__staleWhileFetching!==void 0&&d;return jt&&(jt.fetch=Er?"stale":"refresh",Ni&&Er&&(jt.returnedStale=!0)),Ni?vr.__staleWhileFetching:vr.__returned=vr}}async forceFetch(s,f={}){let d=await this.fetch(s,f);if(d===void 0)throw new Error("fetch() returned undefined");return d}memo(s,f={}){let d=this.#o;if(!d)throw new Error("no memoMethod provided to constructor");let{context:y,forceRefresh:x,...P}=f,F=this.get(s,P);if(!x&&F!==void 0)return F;let J=d(s,F,{options:P,context:y});return this.set(s,J,P),J}get(s,f={}){let{allowStale:d=this.allowStale,updateAgeOnGet:y=this.updateAgeOnGet,noDeleteOnStaleGet:x=this.noDeleteOnStaleGet,status:P}=f,F=this.#c.get(s);if(F!==void 0){let J=this.#a[F],G=this.#S(J);return P&&this.#w(P,F),this.#P(F)?(P&&(P.get="stale"),G?(P&&d&&J.__staleWhileFetching!==void 0&&(P.returnedStale=!0),d?J.__staleWhileFetching:void 0):(x||this.#B(s,"expire"),P&&d&&(P.returnedStale=!0),d?J:void 0)):(P&&(P.get="hit"),G?J.__staleWhileFetching:(this.#$(F),y&&this.#O(F),J))}else P&&(P.get="miss")}#M(s,f){this.#m[f]=s,this.#h[s]=f}#$(s){s!==this.#d&&(s===this.#f?this.#f=this.#h[s]:this.#M(this.#m[s],this.#h[s]),this.#M(this.#d,s),this.#d=s)}delete(s){return this.#B(s,"delete")}#B(s,f){let d=!1;if(this.#_!==0){let y=this.#c.get(s);if(y!==void 0)if(d=!0,this.#_===1)this.#J(f);else{this.#R(y);let x=this.#a[y];if(this.#S(x)?x.__abortController.abort(new Error("deleted")):(this.#k||this.#x)&&(this.#k&&this.#t?.(x,s,f),this.#x&&this.#y?.push([x,s,f])),this.#c.delete(s),this.#i[y]=void 0,this.#a[y]=void 0,y===this.#d)this.#d=this.#m[y];else if(y===this.#f)this.#f=this.#h[y];else{let P=this.#m[y];this.#h[P]=this.#h[y];let F=this.#h[y];this.#m[F]=this.#m[y]}this.#_--,this.#g.push(y)}}if(this.#x&&this.#y?.length){let y=this.#y,x;for(;x=y?.shift();)this.#s?.(...x)}return d}clear(){return this.#J("delete")}#J(s){for(let f of this.#I({allowStale:!0})){let d=this.#a[f];if(this.#S(d))d.__abortController.abort(new Error("deleted"));else{let y=this.#i[f];this.#k&&this.#t?.(d,y,s),this.#x&&this.#y?.push([d,y,s])}}if(this.#c.clear(),this.#a.fill(void 0),this.#i.fill(void 0),this.#C&&this.#T&&(this.#C.fill(0),this.#T.fill(0)),this.#E&&this.#E.fill(0),this.#f=0,this.#d=0,this.#g.length=0,this.#u=0,this.#_=0,this.#x&&this.#y){let f=this.#y,d;for(;d=f?.shift();)this.#s?.(...d)}}};import{SourceMapConsumer as rbr}from"source-map";var fOe=new Zfe({max:100,ttl:1e3*60*5,dispose:t(o=>{o&&o.destroy()},"dispose")});function nbr(o){let s=o.split(`
|
|
651
651
|
`),f=[],d="",y=/^\s*at\s+(?:(.+?)\s+\()?(.+?):(\d+):(\d+)\)?$/;for(let x=0;x<s.length&&!(x>10);x++){let P=s[x],F=y.exec(P);F?f.push({functionName:F[1]||"<anonymous>",fileName:F[2],lineNumber:parseInt(F[3],10),columnNumber:parseInt(F[4],10),source:P}):x===0&&(d=P)}return{errorMessage:d,frames:f}}t(nbr,"parseStackTrace");async function H0t(o,s){try{return await s(o)}catch{return null}}t(H0t,"loadSourceMap");async function ibr(o,s){let f=`${o}.map`,d=await H0t(f,s);if(d)return d;try{let y=await s(o),P=/\/\/[#@]\s*sourceMappingURL=(.+?)$/m.exec(y);if(P){let F=P[1].trim();if(F.startsWith("data:")){let Se=/^data:application\/json;(?:charset=utf-8;)?base64,(.+)$/.exec(F);if(Se)return Buffer.from(Se[1],"base64").toString("utf-8")}let J=Qfe.resolve(Qfe.dirname(o),F);if(d=await H0t(J,s),d)return d}}catch{}return null}t(ibr,"findSourceMap");async function _Oe(o,s){let{errorMessage:f,frames:d}=nbr(o),y=[];for(let x of d){if(!x.fileName||!x.lineNumber||!x.columnNumber){y.push(x);continue}if(x.fileName.startsWith("http://")||x.fileName.startsWith("https://")){y.push(x);continue}let P=x.fileName.replace(/^file:\/\//,"");if(!fOe.has(P)){let J=await ibr(P,s);if(J)try{let G=await new rbr(JSON.parse(J));fOe.set(P,G)}catch{}}let F=fOe.get(P);if(F)try{let J=F.originalPositionFor({line:x.lineNumber,column:x.columnNumber-1});if(J.source){let G=J.source.startsWith("../")?J.source.replace(/^\.\.\/+/,""):J.source;G.includes("@zuplo/")&&(G=G.replace(/@zuplo\/([^/]+)\/out\/(?:esm|cjs)\/@zuplo\/\1\//,"@zuplo/$1/"),G=G.replace(/@zuplo\/([^/]+)\/dist\/@zuplo\/\1\//,"@zuplo/$1/")),G.includes("/app/packages/")&&G.includes("/src/")&&(G=G.replace(/.*\/app\/packages\/([^/]+)\/src\//,"@zuplo/$1/")),G.includes("node_modules/")&&(G=G.replace(/.*node_modules\//,""));let Se=J.name??void 0;if(!Se&&x.functionName&&x.functionName.length<=2){let ae=[];for(let $e=1;$e<=30;$e++){let Fe=F.originalPositionFor({line:x.lineNumber,column:Math.max(0,x.columnNumber-1-$e)});Fe.name&&ae.push({name:Fe.name,distance:$e})}let Ke=ae.find($e=>$e.name.includes("default")||$e.name.includes("Default"))||ae.find($e=>$e.name.includes("_"))||ae.find($e=>/^[a-z][A-Za-z0-9]*$/.test($e.name)&&$e.name.length>5)||ae[0];Ke&&(Se=Ke.name)}Se=Se??x.functionName;let de={...x,originalFileName:G,originalLineNumber:J.line??void 0,originalColumnNumber:J.column!=null?J.column+1:void 0,originalFunctionName:Se};if(J.line){let ae=F.sourceContentFor(J.source,!0);if(ae){let Ke=ae.split(`
|
|
652
652
|
`);Ke[J.line-1]&&(de.originalSource=Ke[J.line-1].trim())}}if(de.originalFileName?.includes("@opentelemetry/api/")&&(de.originalFileName.includes("/context/")||de.originalFileName.includes("/trace/")||de.originalFunctionName?.includes(".with")||de.originalFunctionName?.includes("startActiveSpan")))continue;y.push(de);continue}}catch{}y.push(x)}return sbr(f,y)}t(_Oe,"mapStacktrace");function sbr(o,s){let f=[];o&&f.push(o);for(let d of s)if(d.originalFileName&&d.originalLineNumber){let y=d.originalFunctionName||d.functionName||"<anonymous>",x=d.originalFileName,P=d.originalLineNumber,F=d.originalColumnNumber||1;f.push(` at ${y} (${x}:${P}:${F})`),d.originalSource&&f.push(` ${d.originalSource}`)}else f.push(d.source);return f.join(`
|
|
653
653
|
`)}t(sbr,"formatMappedStackTrace");var Oy=new URL("./public/",import.meta.url);import{readFile as e_e}from"fs/promises";var J1=class{static{t(this,"BaseComponent")}#e;#n;#t;scriptFile;cssFile;constructor(o){this.#t=o}async getStyles(){return this.cssFile?this.#t?await e_e(this.cssFile,"utf-8"):(this.#e=this.#e??await e_e(this.cssFile,"utf-8"),this.#e):null}async getScript(){return this.scriptFile?this.#t?await e_e(this.scriptFile,"utf-8"):(this.#n=this.#n??await e_e(this.scriptFile,"utf-8"),this.#n):null}};var G0t=class extends J1{static{t(this,"Layout")}cssFile=new URL("./layout/style.css",Oy);scriptFile=new URL("./layout/script.js",Oy);async toHTML(o){return`<!DOCTYPE html>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zuplo/core",
|
|
3
|
-
"version": "6.64.
|
|
3
|
+
"version": "6.64.40",
|
|
4
4
|
"repository": "https://github.com/zuplo/zuplo",
|
|
5
5
|
"author": "Zuplo, Inc.",
|
|
6
6
|
"type": "module",
|
|
@@ -40,9 +40,9 @@
|
|
|
40
40
|
"source-map": "^0.7.4"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
|
-
"@zuplo/graphql": "6.64.
|
|
44
|
-
"@zuplo/otel": "6.64.
|
|
45
|
-
"@zuplo/runtime": "6.64.
|
|
43
|
+
"@zuplo/graphql": "6.64.40",
|
|
44
|
+
"@zuplo/otel": "6.64.40",
|
|
45
|
+
"@zuplo/runtime": "6.64.40",
|
|
46
46
|
"deno": "2.3.1"
|
|
47
47
|
}
|
|
48
48
|
}
|