@zuplo/core 6.54.14 → 6.54.16
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/zeno.js +4 -4
package/customer.cli.minified.js
CHANGED
|
@@ -650,7 +650,7 @@ export default {
|
|
|
650
650
|
`:10,l=typeof a=="string"?"\r":13;return a[a.length-1]===s&&(a=a.slice(0,-1)),a[a.length-1]===l&&(a=a.slice(0,-1)),a}t(L9e,"stripFinalNewline");import _de from"node:process";import kY from"node:path";import{fileURLToPath as YTt}from"node:url";function fde(a={}){let{env:s=process.env,platform:l=process.platform}=a;return l!=="win32"?"PATH":Object.keys(s).reverse().find(_=>_.toUpperCase()==="PATH")||"Path"}t(fde,"pathKey");var hPr=t(({cwd:a=_de.cwd(),path:s=_de.env[fde()],preferLocal:l=!0,execPath:_=_de.execPath,addExecPath:h=!0}={})=>{let b=a instanceof URL?YTt(a):a,D=kY.resolve(b),N=[];return l&&gPr(N,D),h&&yPr(N,_,D),[...N,s].join(kY.delimiter)},"npmRunPath"),gPr=t((a,s)=>{let l;for(;l!==s;)a.push(kY.join(s,"node_modules/.bin")),l=s,s=kY.resolve(s,"..")},"applyPreferLocal"),yPr=t((a,s,l)=>{let _=s instanceof URL?YTt(s):s;a.push(kY.resolve(l,_,".."))},"applyExecPath"),XTt=t(({env:a=_de.env,...s}={})=>{a={...a};let l=fde({env:a});return s.path=a[l],a[l]=hPr(s),a},"npmRunPathEnv");var vPr=t((a,s,l,_)=>{if(l==="length"||l==="prototype"||l==="arguments"||l==="caller")return;let h=Object.getOwnPropertyDescriptor(a,l),b=Object.getOwnPropertyDescriptor(s,l);!bPr(h,b)&&_||Object.defineProperty(a,l,b)},"copyProperty"),bPr=t(function(a,s){return a===void 0||a.configurable||a.writable===s.writable&&a.enumerable===s.enumerable&&a.configurable===s.configurable&&(a.writable||a.value===s.value)},"canCopyProperty"),SPr=t((a,s)=>{let l=Object.getPrototypeOf(s);l!==Object.getPrototypeOf(a)&&Object.setPrototypeOf(a,l)},"changePrototype"),TPr=t((a,s)=>`/* Wrapped ${a}*/
|
|
651
651
|
${s}`,"wrappedToString"),xPr=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),EPr=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),CPr=t((a,s,l)=>{let _=l===""?"":`with ${l.trim()}() `,h=TPr.bind(null,_,s.toString());Object.defineProperty(h,"name",EPr),Object.defineProperty(a,"toString",{...xPr,value:h})},"changeToString");function R9e(a,s,{ignoreNonConfigurable:l=!1}={}){let{name:_}=a;for(let h of Reflect.ownKeys(s))vPr(a,s,h,l);return SPr(a,s),CPr(a,s,_),a}t(R9e,"mimicFunction");var pde=new WeakMap,QTt=t((a,s={})=>{if(typeof a!="function")throw new TypeError("Expected a function");let l,_=0,h=a.displayName||a.name||"<anonymous>",b=t(function(...D){if(pde.set(b,++_),_===1)l=a.apply(this,D),a=null;else if(s.throw===!0)throw new Error(`Function \`${h}\` can only be called once`);return l},"onetime");return R9e(b,a),pde.set(b,_),b},"onetime");QTt.callCount=a=>{if(!pde.has(a))throw new Error(`The given function \`${a.name}\` is not wrapped by the \`onetime\` package`);return pde.get(a)};var ZTt=QTt;import{constants as PPr}from"os";var ext=t(function(){let a=M9e-txt+1;return Array.from({length:a},DPr)},"getRealtimeSignals"),DPr=t(function(a,s){return{name:`SIGRT${s+1}`,number:txt+s,action:"terminate",description:"Application-specific signal (realtime)",standard:"posix"}},"getRealtimeSignal"),txt=34,M9e=64;import{constants as kPr}from"os";var rxt=[{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 j9e=t(function(){let a=ext();return[...rxt,...a].map(wPr)},"getSignals"),wPr=t(function({name:a,number:s,description:l,action:_,forced:h=!1,standard:b}){let{signals:{[a]:D}}=kPr,N=D!==void 0;return{name:a,number:N?D:s,description:l,supported:N,action:_,forced:h,standard:b}},"normalizeSignal");var APr=t(function(){return j9e().reduce(NPr,{})},"getSignalsByName"),NPr=t(function(a,{name:s,number:l,description:_,supported:h,action:b,forced:D,standard:N}){return{...a,[s]:{name:s,number:l,description:_,supported:h,action:b,forced:D,standard:N}}},"getSignalByName"),nxt=APr(),IPr=t(function(){let a=j9e(),s=M9e+1,l=Array.from({length:s},(_,h)=>OPr(h,a));return Object.assign({},...l)},"getSignalsByNumber"),OPr=t(function(a,s){let l=FPr(a,s);if(l===void 0)return{};let{name:_,description:h,supported:b,action:D,forced:N,standard:M}=l;return{[a]:{name:_,number:a,description:h,supported:b,action:D,forced:N,standard:M}}},"getSignalByNumber"),FPr=t(function(a,s){let l=s.find(({name:_})=>PPr.signals[_]===a);return l!==void 0?l:s.find(_=>_.number===a)},"findSignalByNumber"),OHr=IPr();var LPr=t(({timedOut:a,timeout:s,errorCode:l,signal:_,signalDescription:h,exitCode:b,isCanceled:D})=>a?`timed out after ${s} milliseconds`:D?"was canceled":l!==void 0?`failed with ${l}`:_!==void 0?`was killed with ${_} (${h})`:b!==void 0?`failed with exit code ${b}`:"failed","getErrorPrefix"),B9e=t(({stdout:a,stderr:s,all:l,error:_,signal:h,exitCode:b,command:D,escapedCommand:N,timedOut:M,isCanceled:z,killed:re,parsed:{options:{timeout:ie}}})=>{b=b===null?void 0:b,h=h===null?void 0:h;let Q=h===void 0?void 0:nxt[h].description,Re=_&&_.code,we=`Command ${LPr({timedOut:M,timeout:ie,errorCode:Re,signal:h,signalDescription:Q,exitCode:b,isCanceled:z})}: ${D}`,wt=Object.prototype.toString.call(_)==="[object Error]",xt=wt?`${we}
|
|
652
652
|
${_.message}`:we,Tr=[xt,s,a].filter(Boolean).join(`
|
|
653
|
-
`);return wt?(_.originalMessage=_.message,_.message=Tr):_=new Error(Tr),_.shortMessage=xt,_.command=D,_.escapedCommand=N,_.exitCode=b,_.signal=h,_.signalDescription=Q,_.stdout=a,_.stderr=s,l!==void 0&&(_.all=l),"bufferedData"in _&&delete _.bufferedData,_.failed=!0,_.timedOut=!!M,_.isCanceled=z,_.killed=re&&!M,_},"makeError");var dde=["stdin","stdout","stderr"],RPr=t(a=>dde.some(s=>a[s]!==void 0),"hasAlias"),ixt=t(a=>{if(!a)return;let{stdio:s}=a;if(s===void 0)return dde.map(_=>a[_]);if(RPr(a))throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${dde.map(_=>`\`${_}\``).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 l=Math.max(s.length,dde.length);return Array.from({length:l},(_,h)=>s[h])},"normalizeStdio");var fxt=ap(uxt(),1);import MPr from"node:os";var jPr=1e3*5,_xt=t((a,s="SIGTERM",l={})=>{let _=a(s);return BPr(a,s,l,_),_},"spawnedKill"),BPr=t((a,s,l,_)=>{if(!UPr(s,l,_))return;let h=zPr(l),b=setTimeout(()=>{a("SIGKILL")},h);b.unref&&b.unref()},"setKillTimeout"),UPr=t((a,{forceKillAfterTimeout:s},l)=>$Pr(a)&&s!==!1&&l,"shouldForceKill"),$Pr=t(a=>a===MPr.constants.signals.SIGTERM||typeof a=="string"&&a.toUpperCase()==="SIGTERM","isSigterm"),zPr=t(({forceKillAfterTimeout:a=!0})=>{if(a===!0)return jPr;if(!Number.isFinite(a)||a<0)throw new TypeError(`Expected the \`forceKillAfterTimeout\` option to be a non-negative integer, got \`${a}\` (${typeof a})`);return a},"getForceKillAfterTimeout"),pxt=t((a,s)=>{a.kill()&&(s.isCanceled=!0)},"spawnedCancel"),JPr=t((a,s,l)=>{a.kill(s),l(Object.assign(new Error("Timed out"),{timedOut:!0,signal:s}))},"timeoutKill"),dxt=t((a,{timeout:s,killSignal:l="SIGTERM"},_)=>{if(s===0||s===void 0)return _;let h,b=new Promise((N,M)=>{h=setTimeout(()=>{JPr(a,l,M)},s)}),D=_.finally(()=>{clearTimeout(h)});return Promise.race([b,D])},"setupTimeout"),mxt=t(({timeout:a})=>{if(a!==void 0&&(!Number.isFinite(a)||a<0))throw new TypeError(`Expected the \`timeout\` option to be a non-negative integer, got \`${a}\` (${typeof a})`)},"validateTimeout"),hxt=t(async(a,{cleanup:s,detached:l},_)=>{if(!s||l)return _;let h=(0,fxt.default)(()=>{a.kill()});return _.finally(()=>{h()})},"setExitHandler");function gxt(a){return a!==null&&typeof a=="object"&&typeof a.pipe=="function"}t(gxt,"isStream");var V9e=ap(bxt(),1),xxt=ap(Txt(),1);var Ext=t((a,s)=>{s===void 0||a.stdin===void 0||(gxt(s)?s.pipe(a.stdin):a.stdin.end(s))},"handleInput"),Cxt=t((a,{all:s})=>{if(!s||!a.stdout&&!a.stderr)return;let l=(0,xxt.default)();return a.stdout&&l.add(a.stdout),a.stderr&&l.add(a.stderr),l},"makeAllStream"),J9e=t(async(a,s)=>{if(a){a.destroy();try{return await s}catch(l){return l.bufferedData}}},"getBufferedData"),q9e=t((a,{encoding:s,buffer:l,maxBuffer:_})=>{if(!(!a||!l))return s?(0,V9e.default)(a,{encoding:s,maxBuffer:_}):V9e.default.buffer(a,{maxBuffer:_})},"getStreamPromise"),Dxt=t(async({stdout:a,stderr:s,all:l},{encoding:_,buffer:h,maxBuffer:b},D)=>{let N=q9e(a,{encoding:_,buffer:h,maxBuffer:b}),M=q9e(s,{encoding:_,buffer:h,maxBuffer:b}),z=q9e(l,{encoding:_,buffer:h,maxBuffer:b*2});try{return await Promise.all([D,N,M,z])}catch(re){return Promise.all([{error:re,signal:re.signal,timedOut:re.timedOut},J9e(a,N),J9e(s,M),J9e(l,z)])}},"getSpawnedResult");var XPr=(async()=>{})().constructor.prototype,QPr=["then","catch","finally"].map(a=>[a,Reflect.getOwnPropertyDescriptor(XPr,a)]),W9e=t((a,s)=>{for(let[l,_]of QPr){let h=typeof s=="function"?(...b)=>Reflect.apply(_.value,s(),b):_.value.bind(s);Reflect.defineProperty(a,l,{..._,value:h})}return a},"mergePromise"),kxt=t(a=>new Promise((s,l)=>{a.on("exit",(_,h)=>{s({exitCode:_,signal:h})}),a.on("error",_=>{l(_)}),a.stdin&&a.stdin.on("error",_=>{l(_)})}),"getSpawnedPromise");var wxt=t((a,s=[])=>Array.isArray(s)?[a,...s]:[a],"normalizeArgs"),ZPr=/^[\w.-]+$/,eAr=/"/g,tAr=t(a=>typeof a!="string"||ZPr.test(a)?a:`"${a.replace(eAr,'\\"')}"`,"escapeArg"),Pxt=t((a,s)=>wxt(a,s).join(" "),"joinCommand"),Axt=t((a,s)=>wxt(a,s).map(l=>tAr(l)).join(" "),"getEscapedCommand");var iAr=1e3*1e3*100,sAr=t(({env:a,extendEnv:s,preferLocal:l,localDir:_,execPath:h})=>{let b=s?{...bde.env,...a}:a;return l?XTt({env:b,cwd:_,execPath:h}):b},"getEnv"),aAr=t((a,s,l={})=>{let _=Ixt.default._parse(a,s,l);return a=_.command,s=_.args,l=_.options,l={maxBuffer:iAr,buffer:!0,stripFinalNewline:!0,extendEnv:!0,preferLocal:!1,localDir:l.cwd||bde.cwd(),execPath:bde.execPath,encoding:"utf8",reject:!0,cleanup:!0,all:!1,windowsHide:!0,...l},l.env=sAr(l),l.stdio=ixt(l),bde.platform==="win32"&&nAr.basename(a,".exe")==="cmd"&&s.unshift("/q"),{file:a,args:s,options:l,parsed:_}},"handleArguments"),H9e=t((a,s,l)=>typeof s!="string"&&!rAr.isBuffer(s)?l===void 0?void 0:"":a.stripFinalNewline?L9e(s):s,"handleOutput");function Oxt(a,s,l){let _=aAr(a,s,l),h=Pxt(a,s),b=Axt(a,s);mxt(_.options);let D;try{D=Nxt.spawn(_.file,_.args,_.options)}catch(Re){let Ie=new Nxt.ChildProcess,we=Promise.reject(B9e({error:Re,stdout:"",stderr:"",all:"",command:h,escapedCommand:b,parsed:_,timedOut:!1,isCanceled:!1,killed:!1}));return W9e(Ie,we)}let N=kxt(D),M=dxt(D,_.options,N),z=hxt(D,_.options,M),re={isCanceled:!1};D.kill=_xt.bind(null,D.kill.bind(D)),D.cancel=pxt.bind(null,D,re);let Q=ZTt(t(async()=>{let[{error:Re,exitCode:Ie,signal:we,timedOut:wt},xt,Tr,fn]=await Dxt(D,_.options,z),tn=H9e(_.options,xt),cn=H9e(_.options,Tr),Er=H9e(_.options,fn);if(Re||Ie!==0||we!==null){let vr=B9e({error:Re,exitCode:Ie,signal:we,stdout:tn,stderr:cn,all:Er,command:h,escapedCommand:b,parsed:_,timedOut:wt,isCanceled:re.isCanceled||(_.options.signal?_.options.signal.aborted:!1),killed:D.killed});if(!_.options.reject)return vr;throw vr}return{command:h,escapedCommand:b,exitCode:0,stdout:tn,stderr:cn,all:Er,failed:!1,timedOut:!1,isCanceled:!1,killed:!1}},"handlePromise"));return Ext(D,_.options.input),D.all=Cxt(D,_.options),W9e(D,Q)}t(Oxt,"execa");async function Tde(a,s){if(a.__ZUPLO_LOG_LEVEL=process.env.__ZUPLO_LOG_LEVEL??process.env.LOG_LEVEL,a.__ZUPLO_LOG_FORMAT=process.env.__ZUPLO_LOG_FORMAT??process.env.LOG_FORMAT,a.LOG_LEVEL=process.env.LOG_LEVEL??process.env.LOG_LEVEL,a.LOG_FORMAT=process.env.LOG_FORMAT??process.env.LOG_FORMAT,a.GIT_SHA=process.env.GIT_SHA??await oAr(s),process.env.__ZUPLO_CONFIG&&(a.__ZUPLO_CONFIG=process.env.__ZUPLO_CONFIG),Fxt(Sde.join(s,".env.zuplo"))){let l=Lxt(Sde.join(s,".env.zuplo"),"utf8"),_=G9e.default.parse(l);for(let h of Object.keys(_))if(a[h]=_[h],h==="ZUPLO_SYSTEM_CONFIGURATIONS"){let b=Buffer.from(mue.decode(_[h])).toString(),D=JSON.parse(b);for(let N of Object.keys(D))a[N]=D[N]}}if(Fxt(Sde.join(s,".env"))){let l=Lxt(Sde.join(s,".env"),"utf8"),_=G9e.default.parse(l);for(let h of Object.keys(_))a[h]=_[h]}for(let l of Object.keys(a))a[l]===void 0&&delete a[l];return a}t(Tde,"setEnvironment");async function oAr(a){let s="unknown";try{let{stdout:l}=await Oxt("git",["rev-parse","HEAD"],{cwd:a});l.trim().length===40&&(s=l.trim())}catch{}return s}t(oAr,"getGitSha");async function fAr({buildId:a,output:s,sourceDirectory:l,bundledDir:_,port:h,binaryName:b,publicZuploEnvironmentVariables:D,logger:N,handleRuntimeStdio:M}){if(_){let re=AY.join(l,_,"modules.json");if(!cAr(re))throw new Error("The bundled-dir does not contain a modules.json file.");let ie=await uAr(re,"utf-8").then(JSON.parse),Q=await uB(l);return Q.status===gA?new Promise((Re,Ie)=>{z(Q.config.compatibilityDate,AY.join(l,_),ie,Re,M)().catch(we=>{N.error(we),Ie(we)})}):(N.warn("Failed to get Zuplo config. Using default compatibility date."),new Promise((Re,Ie)=>{z(void 0,l,ie,Re,M)().catch(we=>{N.error(we),Ie(we)})}))}else{let re=new kN({buildId:a,output:s,sourceDirectory:l,command:"dev",logger:N,publicZuploEnvironmentVariables:D??{ZUPLO_ENVIRONMENT_TYPE:"LOCAL_DEVELOPMENT"},urls:void 0});try{await re.start()}catch{N.info("Ran into irrecoverable error while building. Fix the error and rerun the command."),process.exit(1)}return new Promise((ie,Q)=>{re.onReload((Re,Ie)=>{(Ie||Re&&Re.errors&&Re.errors.length>0)&&Q(Ie??Re?.errors),z(Re?.compatibilityDate,AY.join(l,"dist"),lB(l,Re?.metafile),ie,M)().catch(we=>{N.error(we),Q(we)})})})}function z(re,ie,Q,Re,Ie){return async()=>{let we={};await Tde(we,l);let wt=new Rxt.ZuploWorkerd({compatibilityDate:re,scriptDirectory:ie,modules:Q,port:h??ih.DEV_SERVER_PORT,bindings:we,handleRuntimeStdio:Ie}),xt=b??"compiled-zup",Tr=AY.join(l,"dist");await lAr(Tr,{recursive:!0}),await wt.compileBinary({binaryPath:AY.join(l,"dist",xt)}),await wt.dispose(),Re(void 0)}}t(z,"compile")}t(fAr,"compileWorkerdServer");var Mxt=ap(T9e(),1);import pAr from"node:path";import _Ar from"node:net";function NY(a,s){return new Promise(l=>{let _=new _Ar.Socket;_.connect(s,a),_.on("connect",()=>{_.destroy(),l(!1)}),_.on("error",()=>{_.destroy(),l(!0)})})}t(NY,"isPortAvailable");var xde=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??ih.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 l="http://localhost:3000",_=`http://localhost:${this.port}`;this.buildWatcher=new kN({...s,logger:this.logger,publicZuploEnvironmentVariables:{...s.publicZuploEnvironmentVariables,ZUPLO_ENVIRONMENT_TYPE:"LOCAL_DEVELOPMENT"},urls:{devPortal:{defaultUrl:l,urls:[l]},api:{defaultUrl:_,urls:[_]}}}),this.buildWatcher.watchEnvFiles()}}async start(){if(!await NY("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(l){this.output.child("api").error(l.toString());let _="Ran into irrecoverable error while starting watcher. Fix the error and restart the server.";this.output.child("api").error(_),this.logger?.info(_),process.exit(1)}await this.startOrReload(),this.buildWatcher?.onReload((l,_)=>{_||l&&l.errors&&l.errors.length>0||(this.onReload(l,_),this.startOrReload(l).catch(h=>{this.output.child("api").error(h.toString()),this.logger?.error(h)}))})}async startOrReload(s){try{let l={};await Tde(l,this.sourceDirectory),await this.workerd?.dispose(),this.workerd=new Mxt.ZuploWorkerd({compatibilityDate:s?.compatibilityDate,scriptDirectory:pAr.join(this.sourceDirectory,"dist"),modules:lB(this.sourceDirectory,s?.metafile),port:this.port,inspectorPort:this.debugPort??void 0,bindings:l,handleRuntimeStdio:this.handleRuntimeStdio}),await this.workerd.serve()}catch(l){this.logger?.debug(l)}}async stop(){await this.buildWatcher?.close(),await this.workerd?.dispose()}};import{fileURLToPath as zxt}from"node:url";import{Readable as jxt}from"node:stream";import Bxt from"node:assert";import dAr from"node:child_process";import mAr from"node:fs";import Ede from"node:os";import hAr from"node:path";function Uxt(a,s){let l=import.meta.resolve(a),_=new URL(".",l),h=new URL(s,_);if(mAr.existsSync(h))return zxt(h)}t(Uxt,"getValidExecutablePath");function gAr(){let a=Ede.platform()==="win32"?"deno.exe":"deno",s=Uxt("deno/package.json",a);if(s)return s;let l=yAr(),_=Uxt(`@deno/${l}/package.json`,a);if(_)return _;throw new Error("Failed to locate the managed-dedicated server executable.")}t(gAr,"locateDenoExecutable");function yAr(){let a=Ede.platform();return a==="linux"?a+"-"+$xt()+"-glibc":a+"-"+$xt()}t(yAr,"getTarget");function $xt(){let a=Ede.arch();if(a!=="arm64"&&a!=="x64")throw new Error("Unsupported architecture "+Ede.arch()+". Only x64 and aarch64 binaries are available.");return a}t($xt,"getArch");var Cde=class{static{t(this,"ZenoServer")}serverProcess;debugPort;processExitPromise;logger;output;buildWatcher;onReload;handleRuntimeStdio;denoExecutablePath;port=9e3;constructor(s){if(this.debugPort=s.debugPort,this.logger=s.logger,this.output=s.output,this.onReload=s.onReload,this.handleRuntimeStdio=s.handleRuntimeStdio,!s.zupTestMode){let l="http://localhost:3000",_=`http://localhost:${this.port}`;this.buildWatcher=new kN({sourceDirectory:s.sourceDirectory,command:"dev",logger:s.logger,publicZuploEnvironmentVariables:{...s.publicZuploEnvironmentVariables,ZUPLO_ENVIRONMENT_TYPE:"LOCAL_DEVELOPMENT"},buildId:"dev",output:s.output,urls:{devPortal:{defaultUrl:l,urls:[l]},api:{defaultUrl:_,urls:[_]}}}),this.buildWatcher.watchEnvFiles()}this.denoExecutablePath=gAr()}getServeArgs(){let s=`${hAr.dirname(zxt(import.meta.url))}/zeno.js`,l=["run","--allow-read","--allow-net","--allow-env","--allow-write"];return this.debugPort&&l.push(`--inspect=127.0.0.1:${this.debugPort}`),l.push(s),l}async getUnavailablePorts(){let s=[];return this.debugPort&&!await NY("127.0.0.1",this.debugPort)&&s.push(this.debugPort),await NY("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(l){this.output.child("api").error(l.toString());let _="Ran into irrecoverable error while starting watcher. Fix the error and restart the server.";this.output.child("api").error(_),this.logger?.info(_),process.exit(1)}await this.startOrReload(),this.buildWatcher?.onReload((l,_)=>{_||l&&l.errors&&l.errors.length>0||(this.onReload(l,_),this.startOrReload().catch(h=>{this.output.child("api").error(h.toString()),this.logger?.error(h)}))})}async startOrReload(){try{await this.dispose(),this.logger?.info("Starting managed-dedicated local server");let s=this.getServeArgs();this.serverProcess=dAr.spawn(this.denoExecutablePath,s,{stdio:["pipe","pipe","pipe"],env:{...process.env,FORCE_COLOR:"1"}}),Bxt(this.serverProcess.stdout instanceof jxt),Bxt(this.serverProcess.stderr instanceof jxt),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()}};async function vAr(a){let s=await uB(a),l=!1;return s.status===gA&&(l=s.config.flags?.managedDedicatedFlags?.useZeno??!1),l||process.env.ZUPLO_DEV_RUNTIME==="zeno"}t(vAr,"useZeno");async function bAr({sourceDirectory:a,port:s,debugPort:l,publicZuploEnvironmentVariables:_,logger:h,output:b,buildId:D,onReload:N,handleRuntimeStdio:M}){process.env.ZUPLO_IS_LOCAL_DEVELOPMENT="true";let z;await vAr(a)?(h.debug("Starting managed-dedicated local dev server."),z=new Cde({sourceDirectory:a,debugPort:l,logger:h,output:b,publicZuploEnvironmentVariables:_,onReload:N,handleRuntimeStdio:M})):(h.debug("Starting edge local dev server."),z=new xde({sourceDirectory:a,command:"dev",port:s,debugPort:l,publicZuploEnvironmentVariables:_,logger:h,output:b,buildId:D,onReload:N,handleRuntimeStdio:M})),await z.start();async function re(){await z.stop()}t(re,"handle"),process.on("SIGTERM",re),process.on("SIGINT",re)}t(bAr,"startDevServer");var hEt=ap(Vxt(),1),gEt=ap(dEt(),1);import{readFile as t6r}from"node:fs/promises";import MY from"node:path";var ZAr=new RegExp("^((https|http)://)?[a-zA-Z0-9]{3}\\.[a-zA-Z0-9][a-zA-Z0-9]{0,61}?[a-zA-Z0-9]\\.(com|net|cn|cc)(:[0-9]{1,4})?/$"),e6r={concat(a,s){return MY.join(a,s)},resolve(a){return this.isAbsolute(a)?this.normalize(a):this.normalize(this.concat(process.cwd(),a))},normalize(a){let s=MY.normalize(a),l=MY.sep,_=[],h=0;return s.split(l).reverse().filter(D=>D!==".").forEach(D=>{D===".."?h++:h===0?_.push(D):h--}),_.reverse().join(l)},isData(a){return a.startsWith("data:")},isURL(a){return ZAr.test(a)},isAbsolute(a){return MY.isAbsolute(a)},relativeToFile(a,s){if(this.isData(a)||this.isAbsolute(s))return this.normalize(s);{let l=MY.dirname(a);return this.normalize(this.concat(l,s))}}},Lde=e6r;var mEt=t(a=>{let s=t(l=>l in s.cache?s.cache[l]:s.cache[l]=a(l),"m");return s.forgetEverything=()=>{s.cache=Object.create(null)},s.cache=Object.create(null),s},"memoize");function aLe(a){let s=mEt(async D=>await l(D,await a(D)));async function l(D,N){if(N===void 0)return s(Lde.resolve(D));let M,z,re=t(async Q=>(z=z||await _(ie))(Q),"_resolve"),ie={path:D,text:N,get lines(){return M=M||N.split(`
|
|
653
|
+
`);return wt?(_.originalMessage=_.message,_.message=Tr):_=new Error(Tr),_.shortMessage=xt,_.command=D,_.escapedCommand=N,_.exitCode=b,_.signal=h,_.signalDescription=Q,_.stdout=a,_.stderr=s,l!==void 0&&(_.all=l),"bufferedData"in _&&delete _.bufferedData,_.failed=!0,_.timedOut=!!M,_.isCanceled=z,_.killed=re&&!M,_},"makeError");var dde=["stdin","stdout","stderr"],RPr=t(a=>dde.some(s=>a[s]!==void 0),"hasAlias"),ixt=t(a=>{if(!a)return;let{stdio:s}=a;if(s===void 0)return dde.map(_=>a[_]);if(RPr(a))throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${dde.map(_=>`\`${_}\``).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 l=Math.max(s.length,dde.length);return Array.from({length:l},(_,h)=>s[h])},"normalizeStdio");var fxt=ap(uxt(),1);import MPr from"node:os";var jPr=1e3*5,_xt=t((a,s="SIGTERM",l={})=>{let _=a(s);return BPr(a,s,l,_),_},"spawnedKill"),BPr=t((a,s,l,_)=>{if(!UPr(s,l,_))return;let h=zPr(l),b=setTimeout(()=>{a("SIGKILL")},h);b.unref&&b.unref()},"setKillTimeout"),UPr=t((a,{forceKillAfterTimeout:s},l)=>$Pr(a)&&s!==!1&&l,"shouldForceKill"),$Pr=t(a=>a===MPr.constants.signals.SIGTERM||typeof a=="string"&&a.toUpperCase()==="SIGTERM","isSigterm"),zPr=t(({forceKillAfterTimeout:a=!0})=>{if(a===!0)return jPr;if(!Number.isFinite(a)||a<0)throw new TypeError(`Expected the \`forceKillAfterTimeout\` option to be a non-negative integer, got \`${a}\` (${typeof a})`);return a},"getForceKillAfterTimeout"),pxt=t((a,s)=>{a.kill()&&(s.isCanceled=!0)},"spawnedCancel"),JPr=t((a,s,l)=>{a.kill(s),l(Object.assign(new Error("Timed out"),{timedOut:!0,signal:s}))},"timeoutKill"),dxt=t((a,{timeout:s,killSignal:l="SIGTERM"},_)=>{if(s===0||s===void 0)return _;let h,b=new Promise((N,M)=>{h=setTimeout(()=>{JPr(a,l,M)},s)}),D=_.finally(()=>{clearTimeout(h)});return Promise.race([b,D])},"setupTimeout"),mxt=t(({timeout:a})=>{if(a!==void 0&&(!Number.isFinite(a)||a<0))throw new TypeError(`Expected the \`timeout\` option to be a non-negative integer, got \`${a}\` (${typeof a})`)},"validateTimeout"),hxt=t(async(a,{cleanup:s,detached:l},_)=>{if(!s||l)return _;let h=(0,fxt.default)(()=>{a.kill()});return _.finally(()=>{h()})},"setExitHandler");function gxt(a){return a!==null&&typeof a=="object"&&typeof a.pipe=="function"}t(gxt,"isStream");var V9e=ap(bxt(),1),xxt=ap(Txt(),1);var Ext=t((a,s)=>{s===void 0||a.stdin===void 0||(gxt(s)?s.pipe(a.stdin):a.stdin.end(s))},"handleInput"),Cxt=t((a,{all:s})=>{if(!s||!a.stdout&&!a.stderr)return;let l=(0,xxt.default)();return a.stdout&&l.add(a.stdout),a.stderr&&l.add(a.stderr),l},"makeAllStream"),J9e=t(async(a,s)=>{if(a){a.destroy();try{return await s}catch(l){return l.bufferedData}}},"getBufferedData"),q9e=t((a,{encoding:s,buffer:l,maxBuffer:_})=>{if(!(!a||!l))return s?(0,V9e.default)(a,{encoding:s,maxBuffer:_}):V9e.default.buffer(a,{maxBuffer:_})},"getStreamPromise"),Dxt=t(async({stdout:a,stderr:s,all:l},{encoding:_,buffer:h,maxBuffer:b},D)=>{let N=q9e(a,{encoding:_,buffer:h,maxBuffer:b}),M=q9e(s,{encoding:_,buffer:h,maxBuffer:b}),z=q9e(l,{encoding:_,buffer:h,maxBuffer:b*2});try{return await Promise.all([D,N,M,z])}catch(re){return Promise.all([{error:re,signal:re.signal,timedOut:re.timedOut},J9e(a,N),J9e(s,M),J9e(l,z)])}},"getSpawnedResult");var XPr=(async()=>{})().constructor.prototype,QPr=["then","catch","finally"].map(a=>[a,Reflect.getOwnPropertyDescriptor(XPr,a)]),W9e=t((a,s)=>{for(let[l,_]of QPr){let h=typeof s=="function"?(...b)=>Reflect.apply(_.value,s(),b):_.value.bind(s);Reflect.defineProperty(a,l,{..._,value:h})}return a},"mergePromise"),kxt=t(a=>new Promise((s,l)=>{a.on("exit",(_,h)=>{s({exitCode:_,signal:h})}),a.on("error",_=>{l(_)}),a.stdin&&a.stdin.on("error",_=>{l(_)})}),"getSpawnedPromise");var wxt=t((a,s=[])=>Array.isArray(s)?[a,...s]:[a],"normalizeArgs"),ZPr=/^[\w.-]+$/,eAr=/"/g,tAr=t(a=>typeof a!="string"||ZPr.test(a)?a:`"${a.replace(eAr,'\\"')}"`,"escapeArg"),Pxt=t((a,s)=>wxt(a,s).join(" "),"joinCommand"),Axt=t((a,s)=>wxt(a,s).map(l=>tAr(l)).join(" "),"getEscapedCommand");var iAr=1e3*1e3*100,sAr=t(({env:a,extendEnv:s,preferLocal:l,localDir:_,execPath:h})=>{let b=s?{...bde.env,...a}:a;return l?XTt({env:b,cwd:_,execPath:h}):b},"getEnv"),aAr=t((a,s,l={})=>{let _=Ixt.default._parse(a,s,l);return a=_.command,s=_.args,l=_.options,l={maxBuffer:iAr,buffer:!0,stripFinalNewline:!0,extendEnv:!0,preferLocal:!1,localDir:l.cwd||bde.cwd(),execPath:bde.execPath,encoding:"utf8",reject:!0,cleanup:!0,all:!1,windowsHide:!0,...l},l.env=sAr(l),l.stdio=ixt(l),bde.platform==="win32"&&nAr.basename(a,".exe")==="cmd"&&s.unshift("/q"),{file:a,args:s,options:l,parsed:_}},"handleArguments"),H9e=t((a,s,l)=>typeof s!="string"&&!rAr.isBuffer(s)?l===void 0?void 0:"":a.stripFinalNewline?L9e(s):s,"handleOutput");function Oxt(a,s,l){let _=aAr(a,s,l),h=Pxt(a,s),b=Axt(a,s);mxt(_.options);let D;try{D=Nxt.spawn(_.file,_.args,_.options)}catch(Re){let Ie=new Nxt.ChildProcess,we=Promise.reject(B9e({error:Re,stdout:"",stderr:"",all:"",command:h,escapedCommand:b,parsed:_,timedOut:!1,isCanceled:!1,killed:!1}));return W9e(Ie,we)}let N=kxt(D),M=dxt(D,_.options,N),z=hxt(D,_.options,M),re={isCanceled:!1};D.kill=_xt.bind(null,D.kill.bind(D)),D.cancel=pxt.bind(null,D,re);let Q=ZTt(t(async()=>{let[{error:Re,exitCode:Ie,signal:we,timedOut:wt},xt,Tr,fn]=await Dxt(D,_.options,z),tn=H9e(_.options,xt),cn=H9e(_.options,Tr),Er=H9e(_.options,fn);if(Re||Ie!==0||we!==null){let vr=B9e({error:Re,exitCode:Ie,signal:we,stdout:tn,stderr:cn,all:Er,command:h,escapedCommand:b,parsed:_,timedOut:wt,isCanceled:re.isCanceled||(_.options.signal?_.options.signal.aborted:!1),killed:D.killed});if(!_.options.reject)return vr;throw vr}return{command:h,escapedCommand:b,exitCode:0,stdout:tn,stderr:cn,all:Er,failed:!1,timedOut:!1,isCanceled:!1,killed:!1}},"handlePromise"));return Ext(D,_.options.input),D.all=Cxt(D,_.options),W9e(D,Q)}t(Oxt,"execa");async function Tde(a,s){if(a.__ZUPLO_LOG_LEVEL=process.env.__ZUPLO_LOG_LEVEL??process.env.LOG_LEVEL,a.__ZUPLO_LOG_FORMAT=process.env.__ZUPLO_LOG_FORMAT??process.env.LOG_FORMAT,a.LOG_LEVEL=process.env.LOG_LEVEL??process.env.LOG_LEVEL,a.LOG_FORMAT=process.env.LOG_FORMAT??process.env.LOG_FORMAT,a.GIT_SHA=process.env.GIT_SHA??await oAr(s),process.env.__ZUPLO_CONFIG&&(a.__ZUPLO_CONFIG=process.env.__ZUPLO_CONFIG),Fxt(Sde.join(s,".env.zuplo"))){let l=Lxt(Sde.join(s,".env.zuplo"),"utf8"),_=G9e.default.parse(l);for(let h of Object.keys(_))if(a[h]=_[h],h==="ZUPLO_SYSTEM_CONFIGURATIONS"){let b=Buffer.from(mue.decode(_[h])).toString(),D=JSON.parse(b);for(let N of Object.keys(D))a[N]=D[N]}}if(Fxt(Sde.join(s,".env"))){let l=Lxt(Sde.join(s,".env"),"utf8"),_=G9e.default.parse(l);for(let h of Object.keys(_))a[h]=_[h]}for(let l of Object.keys(a))a[l]===void 0&&delete a[l];return a}t(Tde,"setEnvironment");async function oAr(a){let s="unknown";try{let{stdout:l}=await Oxt("git",["rev-parse","HEAD"],{cwd:a});l.trim().length===40&&(s=l.trim())}catch{}return s}t(oAr,"getGitSha");async function fAr({buildId:a,output:s,sourceDirectory:l,bundledDir:_,port:h,binaryName:b,publicZuploEnvironmentVariables:D,logger:N,handleRuntimeStdio:M}){if(_){let re=AY.join(l,_,"modules.json");if(!cAr(re))throw new Error("The bundled-dir does not contain a modules.json file.");let ie=await uAr(re,"utf-8").then(JSON.parse),Q=await uB(l);return Q.status===gA?new Promise((Re,Ie)=>{z(Q.config.compatibilityDate,AY.join(l,_),ie,Re,M)().catch(we=>{N.error(we),Ie(we)})}):(N.warn("Failed to get Zuplo config. Using default compatibility date."),new Promise((Re,Ie)=>{z(void 0,l,ie,Re,M)().catch(we=>{N.error(we),Ie(we)})}))}else{let re=new kN({buildId:a,output:s,sourceDirectory:l,command:"dev",logger:N,publicZuploEnvironmentVariables:D??{ZUPLO_ENVIRONMENT_TYPE:"LOCAL_DEVELOPMENT"},urls:void 0});try{await re.start()}catch{N.info("Ran into irrecoverable error while building. Fix the error and rerun the command."),process.exit(1)}return new Promise((ie,Q)=>{re.onReload((Re,Ie)=>{(Ie||Re&&Re.errors&&Re.errors.length>0)&&Q(Ie??Re?.errors),z(Re?.compatibilityDate,AY.join(l,"dist"),lB(l,Re?.metafile),ie,M)().catch(we=>{N.error(we),Q(we)})})})}function z(re,ie,Q,Re,Ie){return async()=>{let we={};await Tde(we,l);let wt=new Rxt.ZuploWorkerd({compatibilityDate:re,scriptDirectory:ie,modules:Q,port:h??ih.DEV_SERVER_PORT,bindings:we,handleRuntimeStdio:Ie}),xt=b??"compiled-zup",Tr=AY.join(l,"dist");await lAr(Tr,{recursive:!0}),await wt.compileBinary({binaryPath:AY.join(l,"dist",xt)}),await wt.dispose(),Re(void 0)}}t(z,"compile")}t(fAr,"compileWorkerdServer");var Mxt=ap(T9e(),1);import pAr from"node:path";import _Ar from"node:net";function NY(a,s){return new Promise(l=>{let _=new _Ar.Socket;_.connect(s,a),_.on("connect",()=>{_.destroy(),l(!1)}),_.on("error",()=>{_.destroy(),l(!0)})})}t(NY,"isPortAvailable");var xde=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??ih.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 l="http://localhost:3000",_=`http://localhost:${this.port}`;this.buildWatcher=new kN({...s,logger:this.logger,publicZuploEnvironmentVariables:{...s.publicZuploEnvironmentVariables,ZUPLO_ENVIRONMENT_TYPE:"LOCAL_DEVELOPMENT"},urls:{devPortal:{defaultUrl:l,urls:[l]},api:{defaultUrl:_,urls:[_]}}}),this.buildWatcher.watchEnvFiles()}}async start(){if(!await NY("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(l){this.output.child("api").error(l.toString());let _="Ran into irrecoverable error while starting watcher. Fix the error and restart the server.";this.output.child("api").error(_),this.logger?.info(_),process.exit(1)}await this.startOrReload(),this.buildWatcher?.onReload((l,_)=>{_||l&&l.errors&&l.errors.length>0||(this.onReload(l,_),this.startOrReload(l).catch(h=>{this.output.child("api").error(h.toString()),this.logger?.error(h)}))})}async startOrReload(s){try{let l={};await Tde(l,this.sourceDirectory),await this.workerd?.dispose(),this.workerd=new Mxt.ZuploWorkerd({compatibilityDate:s?.compatibilityDate,scriptDirectory:pAr.join(this.sourceDirectory,"dist"),modules:lB(this.sourceDirectory,s?.metafile),port:this.port,inspectorPort:this.debugPort??void 0,bindings:l,handleRuntimeStdio:this.handleRuntimeStdio}),await this.workerd.serve()}catch(l){this.logger?.debug(l)}}async stop(){await this.buildWatcher?.close(),await this.workerd?.dispose()}};import{fileURLToPath as zxt}from"node:url";import{Readable as jxt}from"node:stream";import Bxt from"node:assert";import dAr from"node:child_process";import mAr from"node:fs";import Ede from"node:os";import hAr from"node:path";function Uxt(a,s){let l=import.meta.resolve(a),_=new URL(".",l),h=new URL(s,_);if(mAr.existsSync(h))return zxt(h)}t(Uxt,"getValidExecutablePath");function gAr(){let a=Ede.platform()==="win32"?"deno.exe":"deno",s=Uxt("deno/package.json",a);if(s)return s;let l=yAr(),_=Uxt(`@deno/${l}/package.json`,a);if(_)return _;throw new Error("Failed to locate the managed-dedicated server executable.")}t(gAr,"locateDenoExecutable");function yAr(){let a=Ede.platform();return a==="linux"?a+"-"+$xt()+"-glibc":a+"-"+$xt()}t(yAr,"getTarget");function $xt(){let a=Ede.arch();if(a!=="arm64"&&a!=="x64")throw new Error("Unsupported architecture "+Ede.arch()+". Only x64 and aarch64 binaries are available.");return a}t($xt,"getArch");var Cde=class{static{t(this,"ZenoServer")}serverProcess;sourceDirectory;debugPort;processExitPromise;logger;output;buildWatcher;onReload;handleRuntimeStdio;denoExecutablePath;port=9e3;constructor(s){if(this.debugPort=s.debugPort,this.logger=s.logger,this.output=s.output,this.onReload=s.onReload,this.handleRuntimeStdio=s.handleRuntimeStdio,this.sourceDirectory=s.sourceDirectory,!s.zupTestMode){let l="http://localhost:3000",_=`http://localhost:${this.port}`;this.buildWatcher=new kN({sourceDirectory:s.sourceDirectory,command:"dev",logger:s.logger,publicZuploEnvironmentVariables:{...s.publicZuploEnvironmentVariables,ZUPLO_ENVIRONMENT_TYPE:"LOCAL_DEVELOPMENT"},buildId:"dev",output:s.output,urls:{devPortal:{defaultUrl:l,urls:[l]},api:{defaultUrl:_,urls:[_]}}}),this.buildWatcher.watchEnvFiles()}this.denoExecutablePath=gAr()}getServeArgs(){let s=`${hAr.dirname(zxt(import.meta.url))}/zeno.js`,l=["run","--allow-read","--allow-net","--allow-env","--allow-write"];return this.debugPort&&l.push(`--inspect=127.0.0.1:${this.debugPort}`),l.push(s),l.push("--dir",this.sourceDirectory),l}async getUnavailablePorts(){let s=[];return this.debugPort&&!await NY("127.0.0.1",this.debugPort)&&s.push(this.debugPort),await NY("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(l){this.output.child("api").error(l.toString());let _="Ran into irrecoverable error while starting watcher. Fix the error and restart the server.";this.output.child("api").error(_),this.logger?.info(_),process.exit(1)}await this.startOrReload(),this.buildWatcher?.onReload((l,_)=>{_||l&&l.errors&&l.errors.length>0||(this.onReload(l,_),this.startOrReload().catch(h=>{this.output.child("api").error(h.toString()),this.logger?.error(h)}))})}async startOrReload(){try{await this.dispose(),this.logger?.info("Starting managed-dedicated local server");let s=this.getServeArgs();this.serverProcess=dAr.spawn(this.denoExecutablePath,s,{stdio:["pipe","pipe","pipe"],env:{...process.env,FORCE_COLOR:"1"}}),Bxt(this.serverProcess.stdout instanceof jxt),Bxt(this.serverProcess.stderr instanceof jxt),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()}};async function vAr(a){let s=await uB(a),l=!1;return s.status===gA&&(l=s.config.flags?.managedDedicatedFlags?.useZeno??!1),l||process.env.ZUPLO_DEV_RUNTIME==="zeno"}t(vAr,"useZeno");async function bAr({sourceDirectory:a,port:s,debugPort:l,publicZuploEnvironmentVariables:_,logger:h,output:b,buildId:D,onReload:N,handleRuntimeStdio:M}){process.env.ZUPLO_IS_LOCAL_DEVELOPMENT="true";let z;await vAr(a)?(h.debug("Starting managed-dedicated local dev server."),z=new Cde({sourceDirectory:a,debugPort:l,logger:h,output:b,publicZuploEnvironmentVariables:_,onReload:N,handleRuntimeStdio:M})):(h.debug("Starting edge local dev server."),z=new xde({sourceDirectory:a,command:"dev",port:s,debugPort:l,publicZuploEnvironmentVariables:_,logger:h,output:b,buildId:D,onReload:N,handleRuntimeStdio:M})),await z.start();async function re(){await z.stop()}t(re,"handle"),process.on("SIGTERM",re),process.on("SIGINT",re)}t(bAr,"startDevServer");var hEt=ap(Vxt(),1),gEt=ap(dEt(),1);import{readFile as t6r}from"node:fs/promises";import MY from"node:path";var ZAr=new RegExp("^((https|http)://)?[a-zA-Z0-9]{3}\\.[a-zA-Z0-9][a-zA-Z0-9]{0,61}?[a-zA-Z0-9]\\.(com|net|cn|cc)(:[0-9]{1,4})?/$"),e6r={concat(a,s){return MY.join(a,s)},resolve(a){return this.isAbsolute(a)?this.normalize(a):this.normalize(this.concat(process.cwd(),a))},normalize(a){let s=MY.normalize(a),l=MY.sep,_=[],h=0;return s.split(l).reverse().filter(D=>D!==".").forEach(D=>{D===".."?h++:h===0?_.push(D):h--}),_.reverse().join(l)},isData(a){return a.startsWith("data:")},isURL(a){return ZAr.test(a)},isAbsolute(a){return MY.isAbsolute(a)},relativeToFile(a,s){if(this.isData(a)||this.isAbsolute(s))return this.normalize(s);{let l=MY.dirname(a);return this.normalize(this.concat(l,s))}}},Lde=e6r;var mEt=t(a=>{let s=t(l=>l in s.cache?s.cache[l]:s.cache[l]=a(l),"m");return s.forgetEverything=()=>{s.cache=Object.create(null)},s.cache=Object.create(null),s},"memoize");function aLe(a){let s=mEt(async D=>await l(D,await a(D)));async function l(D,N){if(N===void 0)return s(Lde.resolve(D));let M,z,re=t(async Q=>(z=z||await _(ie))(Q),"_resolve"),ie={path:D,text:N,get lines(){return M=M||N.split(`
|
|
654
654
|
`)},async resolve(Q){try{return await re(Q)}catch(Re){return Object.assign({},Q,{error:Re})}},_resolve:re};return ie}t(l,"SourceFile");async function _(D){let N=/\u0023 sourceMappingURL=(.+)\n?/g,M;for(;;){let ie=N.exec(D.text);if(ie)M=ie;else break}let z=M&&M[1],re=t(async ie=>Object.assign({},ie,{sourceFile:D,sourceLine:D.lines[ie.line-1]||""}),"defaultResolver");return z?await h(D.path,z,re):re}t(_,"SourceMapResolverFromFetchedFile");async function h(D,N,M){let z=N.startsWith("data:")?await l(D,(0,hEt.dataUriToBuffer)(N).toString()):await l(Lde.relativeToFile(D,N)),re=await new gEt.SourceMapConsumer(JSON.parse(z.text)),ie=mEt(async Q=>{let Re=Lde.relativeToFile(z.path,Q),Ie=re.sourceContentFor(Q,!0)||void 0;return await l(Re,Ie)});return async Q=>{try{let Re=re.originalPositionFor(Q);return Re.source?await(await ie(Re.source))._resolve(Object.assign({},Q,{line:Re.line,column:(Re.column??0)+1,name:Re.name})):M(Q)}catch(Re){return Object.assign(M(Q),{sourceMapError:Re})}}}t(h,"SourceMapResolver");let b=t(async function(N){try{return await l(N)}catch(M){let z={path:N,text:"",lines:[],error:M,async resolve(re){return Object.assign({},re,{error:M,sourceLine:"",sourceFile:z})},_resolve(re){return this.resolve(re)}};return z}},"getSource");return b.resetCache=()=>s.forgetEverything(),b.getCache=()=>s.cache,b}t(aLe,"buildGetSourceFunction");var r6r=t(async a=>t6r(a,{encoding:"utf8"}),"fetchFile"),yEt=aLe(r6r);import n6r from"node:path";import i6r from"node:util";var vEt=t(a=>a[a.length-1],"lastOf"),jY=t(a=>a.replace(/\\/g,"/"),"nixSlashes"),s6r=t((a,s)=>{let l=a||[],_=[],h={label:void 0,items:[l[0]]};return l.forEach(b=>{let D=s(b);h.label!==D&&h.items.length?_.push(h={label:D,items:[b]}):h.items.push(b)}),_},"partition"),BY=class a{static{t(this,"StackTracey")}items;getSource;pathRoot;constructor(s,{offset:l,getSource:_}){this.getSource=_,this.pathRoot=`${jY(process.cwd())}/`;let h=s,b=s instanceof SyntaxError;if(l=l||0,s instanceof Error&&(s=s.stack||""),typeof s=="string"&&(s=this.rawParse(s).slice(l).map(D=>this.extractEntryMetadata(D))),Array.isArray(s)){if(b){let D=i6r.inspect(h).split(`
|
|
655
655
|
`),N=D[0].split(":"),M=N.pop(),z=N.join(":");z&&s.unshift({file:jY(z),line:parseInt(M||"0",10),column:(D[2]||"").indexOf("^")+1,sourceLine:D[1],callee:"(syntax error)",syntaxError:!0,beforeParse:"",index:!1,native:!1,calleeShort:"",fileRelative:"",fileShort:"",fileName:"",thirdParty:!1})}this.items=s}else this.items=[]}extractEntryMetadata(s){let l=this.decomposePath(s.file||""),_=l[0],h=l[1];return Object.assign(s,{calleeShort:s.calleeShort||vEt((s.callee||"").split(".")),fileRelative:_,fileShort:this.shortenPath(_),fileName:vEt((s.file||"").split("/")),thirdParty:this.isThirdParty(_,h)&&!s.index,externalDomain:h})}shortenPath(s){return s.replace(/^node_modules\//,"").replace(/^webpack\/bootstrap\//,"").replace(/^__parcel_source_root\//,"")}decomposePath(s){let l=s,_=l.match(/^(http|https):\/\/([^\/]+)\/(.*)/),h=_?_[2]:void 0;return l=_?_[3]:l,l=n6r.relative(this.pathRoot,l),[jY(l).replace(/^.*:\/\/?\/?/,""),h]}isThirdParty(s,l){return!!l||s[0]==="~"||s[0]==="/"||s.indexOf("node_modules")===0||s.indexOf("webpack/bootstrap")===0}rawParse(s){return(s||"").split(`
|
|
656
656
|
`).map(h=>{h=h.trim();let b,D=[],N,M,z;if((M=h.match(/at (.+) \(eval at .+ \((.+)\), .+\)/))||(M=h.match(/at (.+) \((.+)\)/))||h.slice(0,3)!=="at "&&(M=h.match(/(.*)@(.*)/)))b=M[1],N=M[2]==="native",D=(M[2].match(/(.*):(\d+):(\d+)/)||M[2].match(/(.*):(\d+)/)||[]).slice(1);else if(z=h.match(/^(at\s+)*(.+):(\d+):(\d+)/))D=z.slice(2);else return;return b&&!D[0]&&b.split(".")[0]==="Array"&&(N=!0),{beforeParse:h,callee:b||"",index:D[0]==="/",native:N||!1,file:jY(D[0]||""),line:parseInt(D[1]||"",10)||void 0,column:parseInt(D[2]||"",10)||void 0,calleeShort:"",fileRelative:"",fileShort:"",fileName:"",thirdParty:!1}}).filter(h=>h!==void 0)}async withSourceAsyncAt(s){return this.items[s]&&this.withSourceAsync(this.items[s])}async withSourceAsync(s){if(this.shouldSkipResolving(s))return s;{let l=(s.file||"").replace("file://","");try{let h=await(await this.getSource(l)).resolve(s);return this.withSourceResolved(s,h)}catch(_){return this.withSourceResolved(s,{error:_,sourceLine:""})}}}shouldSkipResolving(s){return!!s.sourceFile||!!s.error||!!s.file&&s.file.indexOf("<")>=0}withSourceResolved(s,l){return l.sourceFile&&!l.sourceFile.error&&(l.file=jY(l.sourceFile.path),l=this.extractEntryMetadata(l)),l.sourceLine?.includes("// @hide")&&(l.sourceLine=l.sourceLine.replace("// @hide",""),l.hide=!0),(l.sourceLine?.includes("__webpack_require__")||l.sourceLine?.includes("/******/ ({"))&&(l.thirdParty=!0),Object.assign({sourceLine:""},s,l)}async withSourcesAsync(){let s=await Promise.all(this.items.map(l=>this.withSourceAsync(l)));return new a(s,{getSource:this.getSource})}mergeRepeatedLines(){return new a(s6r(this.items,s=>s.file+s.line).map(s=>s.items.slice(1).reduce((l,_)=>(l.callee=(l.callee||"<anonymous>")+" \u2192 "+(_.callee||"<anonymous>"),l.calleeShort=(l.calleeShort||"<anonymous>")+" \u2192 "+(_.calleeShort||"<anonymous>"),l),Object.assign({},s.items[0]))),{getSource:this.getSource})}async cleanAsync(){let s=await this.withSourcesAsync();return s.mergeRepeatedLines().filter((l,_)=>s.isClean(l,_))}isClean(s,l){return l===0||!(s.thirdParty||s.hide||s.native)}at(s){return Object.assign({beforeParse:"",callee:"<???>",index:!1,native:!1,file:"<???>",line:0,column:0},this.items[s])}map(s,l){return new a(this.items.map(s,l),{getSource:this.getSource})}filter(s,l){return new a(this.items.filter(s,l),{getSource:this.getSource})}slice(s,l){return new a(this.items.slice(s,l),{getSource:this.getSource})}concat(...s){return new a(this.items.concat(...s),{getSource:this.getSource})}maxColumnWidths(){return{callee:30,file:60,sourceLine:80}}static locationsEqual(s,l){return s.file===l.file&&s.line===l.line&&s.column===l.column}};import{relative as f6r}from"node:path";import{fileURLToPath as _6r}from"node:url";import{inspect as p6r}from"node:util";function oLe({onlyFirst:a=!1}={}){let l=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");return new RegExp(l,a?void 0:"g")}t(oLe,"ansiRegex");var a6r=oLe();function cLe(a){if(typeof a!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof a}\``);return a.replace(a6r,"")}t(cLe,"stripAnsi");function bEt(a){return a===161||a===164||a===167||a===168||a===170||a===173||a===174||a>=176&&a<=180||a>=182&&a<=186||a>=188&&a<=191||a===198||a===208||a===215||a===216||a>=222&&a<=225||a===230||a>=232&&a<=234||a===236||a===237||a===240||a===242||a===243||a>=247&&a<=250||a===252||a===254||a===257||a===273||a===275||a===283||a===294||a===295||a===299||a>=305&&a<=307||a===312||a>=319&&a<=322||a===324||a>=328&&a<=331||a===333||a===338||a===339||a===358||a===359||a===363||a===462||a===464||a===466||a===468||a===470||a===472||a===474||a===476||a===593||a===609||a===708||a===711||a>=713&&a<=715||a===717||a===720||a>=728&&a<=731||a===733||a===735||a>=768&&a<=879||a>=913&&a<=929||a>=931&&a<=937||a>=945&&a<=961||a>=963&&a<=969||a===1025||a>=1040&&a<=1103||a===1105||a===8208||a>=8211&&a<=8214||a===8216||a===8217||a===8220||a===8221||a>=8224&&a<=8226||a>=8228&&a<=8231||a===8240||a===8242||a===8243||a===8245||a===8251||a===8254||a===8308||a===8319||a>=8321&&a<=8324||a===8364||a===8451||a===8453||a===8457||a===8467||a===8470||a===8481||a===8482||a===8486||a===8491||a===8531||a===8532||a>=8539&&a<=8542||a>=8544&&a<=8555||a>=8560&&a<=8569||a===8585||a>=8592&&a<=8601||a===8632||a===8633||a===8658||a===8660||a===8679||a===8704||a===8706||a===8707||a===8711||a===8712||a===8715||a===8719||a===8721||a===8725||a===8730||a>=8733&&a<=8736||a===8739||a===8741||a>=8743&&a<=8748||a===8750||a>=8756&&a<=8759||a===8764||a===8765||a===8776||a===8780||a===8786||a===8800||a===8801||a>=8804&&a<=8807||a===8810||a===8811||a===8814||a===8815||a===8834||a===8835||a===8838||a===8839||a===8853||a===8857||a===8869||a===8895||a===8978||a>=9312&&a<=9449||a>=9451&&a<=9547||a>=9552&&a<=9587||a>=9600&&a<=9615||a>=9618&&a<=9621||a===9632||a===9633||a>=9635&&a<=9641||a===9650||a===9651||a===9654||a===9655||a===9660||a===9661||a===9664||a===9665||a>=9670&&a<=9672||a===9675||a>=9678&&a<=9681||a>=9698&&a<=9701||a===9711||a===9733||a===9734||a===9737||a===9742||a===9743||a===9756||a===9758||a===9792||a===9794||a===9824||a===9825||a>=9827&&a<=9829||a>=9831&&a<=9834||a===9836||a===9837||a===9839||a===9886||a===9887||a===9919||a>=9926&&a<=9933||a>=9935&&a<=9939||a>=9941&&a<=9953||a===9955||a===9960||a===9961||a>=9963&&a<=9969||a===9972||a>=9974&&a<=9977||a===9979||a===9980||a===9982||a===9983||a===10045||a>=10102&&a<=10111||a>=11094&&a<=11097||a>=12872&&a<=12879||a>=57344&&a<=63743||a>=65024&&a<=65039||a===65533||a>=127232&&a<=127242||a>=127248&&a<=127277||a>=127280&&a<=127337||a>=127344&&a<=127373||a===127375||a===127376||a>=127387&&a<=127404||a>=917760&&a<=917999||a>=983040&&a<=1048573||a>=1048576&&a<=1114109}t(bEt,"isAmbiguous");function SEt(a){return a===12288||a>=65281&&a<=65376||a>=65504&&a<=65510}t(SEt,"isFullWidth");function TEt(a){return a>=4352&&a<=4447||a===8986||a===8987||a===9001||a===9002||a>=9193&&a<=9196||a===9200||a===9203||a===9725||a===9726||a===9748||a===9749||a>=9800&&a<=9811||a===9855||a===9875||a===9889||a===9898||a===9899||a===9917||a===9918||a===9924||a===9925||a===9934||a===9940||a===9962||a===9970||a===9971||a===9973||a===9978||a===9981||a===9989||a===9994||a===9995||a===10024||a===10060||a===10062||a>=10067&&a<=10069||a===10071||a>=10133&&a<=10135||a===10160||a===10175||a===11035||a===11036||a===11088||a===11093||a>=11904&&a<=11929||a>=11931&&a<=12019||a>=12032&&a<=12245||a>=12272&&a<=12287||a>=12289&&a<=12350||a>=12353&&a<=12438||a>=12441&&a<=12543||a>=12549&&a<=12591||a>=12593&&a<=12686||a>=12688&&a<=12771||a>=12783&&a<=12830||a>=12832&&a<=12871||a>=12880&&a<=19903||a>=19968&&a<=42124||a>=42128&&a<=42182||a>=43360&&a<=43388||a>=44032&&a<=55203||a>=63744&&a<=64255||a>=65040&&a<=65049||a>=65072&&a<=65106||a>=65108&&a<=65126||a>=65128&&a<=65131||a>=94176&&a<=94180||a===94192||a===94193||a>=94208&&a<=100343||a>=100352&&a<=101589||a>=101632&&a<=101640||a>=110576&&a<=110579||a>=110581&&a<=110587||a===110589||a===110590||a>=110592&&a<=110882||a===110898||a>=110928&&a<=110930||a===110933||a>=110948&&a<=110951||a>=110960&&a<=111355||a===126980||a===127183||a===127374||a>=127377&&a<=127386||a>=127488&&a<=127490||a>=127504&&a<=127547||a>=127552&&a<=127560||a===127568||a===127569||a>=127584&&a<=127589||a>=127744&&a<=127776||a>=127789&&a<=127797||a>=127799&&a<=127868||a>=127870&&a<=127891||a>=127904&&a<=127946||a>=127951&&a<=127955||a>=127968&&a<=127984||a===127988||a>=127992&&a<=128062||a===128064||a>=128066&&a<=128252||a>=128255&&a<=128317||a>=128331&&a<=128334||a>=128336&&a<=128359||a===128378||a===128405||a===128406||a===128420||a>=128507&&a<=128591||a>=128640&&a<=128709||a===128716||a>=128720&&a<=128722||a>=128725&&a<=128727||a>=128732&&a<=128735||a===128747||a===128748||a>=128756&&a<=128764||a>=128992&&a<=129003||a===129008||a>=129292&&a<=129338||a>=129340&&a<=129349||a>=129351&&a<=129535||a>=129648&&a<=129660||a>=129664&&a<=129672||a>=129680&&a<=129725||a>=129727&&a<=129733||a>=129742&&a<=129755||a>=129760&&a<=129768||a>=129776&&a<=129784||a>=131072&&a<=196605||a>=196608&&a<=262141}t(TEt,"isWide");function o6r(a){if(!Number.isSafeInteger(a))throw new TypeError(`Expected a code point, got \`${typeof a}\`.`)}t(o6r,"validate");function xEt(a,{ambiguousAsWide:s=!1}={}){return o6r(a),SEt(a)||TEt(a)||s&&bEt(a)?2:1}t(xEt,"eastAsianWidth");var DEt=ap(CEt(),1);var c6r=new Intl.Segmenter,l6r=/^\p{Default_Ignorable_Code_Point}$/u;function Rde(a,s={}){if(typeof a!="string"||a.length===0)return 0;let{ambiguousIsNarrow:l=!0,countAnsiEscapeCodes:_=!1}=s;if(_||(a=cLe(a)),a.length===0)return 0;let h=0,b={ambiguousAsWide:!l};for(let{segment:D}of c6r.segment(a)){let N=D.codePointAt(0);if(!(N<=31||N>=127&&N<=159)&&!(N>=8203&&N<=8207||N===65279)&&!(N>=768&&N<=879||N>=6832&&N<=6911||N>=7616&&N<=7679||N>=8400&&N<=8447||N>=65056&&N<=65071)&&!(N>=55296&&N<=57343)&&!(N>=65024&&N<=65039)&&!l6r.test(D)){if((0,DEt.default)().test(D)){h+=2;continue}h+=xEt(N,b)}}return h}t(Rde,"stringWidth");var fLe=ap(wEt(),1);var{platform:PEt,cwd:u6r}=process,{red:nU,yellow:AEt,green:jde,cyan:UY,dim:lLe}=Jf,NEt=process.stdout.columns,d6r=PEt==="win32"&&!process.env.WT_SESSION?">":"\u276F",m6r=(PEt==="win32"&&!process.env.WT_SESSION,"\u2043"),h6r=u6r();function IEt(a){return a=a.replace("async file:","file:"),f6r(h6r,a.startsWith("file:")?_6r(a):a)}t(IEt,"getRelativePath");function g6r(a){return a.find(s=>s.isApp)||null}t(g6r,"mainFrame");function y6r(a,s){return a.filter(l=>(l.isApp||l.isModule)&&(!s||l.file!==s.file||l.line!==s.line))}t(y6r,"filterNativeFrames");function OEt(a){return a.callee||"anonymous"}t(OEt,"frameMethod");function FEt(a,s){let l="",_=a.length-s.length;for(let h=0;h<=_;h++)l+=" ";return l}t(FEt,"whiteSpace");function uLe(a,s,l,_,h){let b=FEt(String(l),String(s));return _?`${h}${nU(d6r)}${b}${nU(s)}${nU("|")}${b} ${nU(a)}`:`${h} ${b}${lLe(s)}${lLe("|")}${b} ${lLe(a)}`}t(uLe,"codeLine");function v6r(a,s,l){let _,h=(0,fLe.default)(Rde(s)+2,NEt);return l?_=`${s} ${nU(h(`${a.message}`).trim())}`:_=`${s} ${nU(h(`${a.name}: ${a.message}`).trim())}`,[_,s]}t(v6r,"getMessage");function b6r(a,s){let l=a.help;if(!l)return[];let _=(0,fLe.default)(Rde(s)+4,NEt);return Array.isArray(l)?l.map(h=>`${s} ${UY(_(`- ${h}`).trim())}`).concat([s]):[`${s} ${UY(l)}`,s]}t(b6r,"getHelpText");function S6r(a,s,l){if(!a)return[];let _=l?IEt(a.filePath):a.filePath;return[`${s} at ${AEt(`${OEt(a)}`)} ${jde(_)}:${jde(a.line)}`]}t(S6r,"getMainFrameLocation");function T6r(a,s){if(!a||!a.context||!a.context.line)return[];let l=a.context.start-1,_=a.context.pre.split(`
|
package/index.minified.js
CHANGED
|
@@ -655,7 +655,7 @@ export default {
|
|
|
655
655
|
`:10,l=typeof a=="string"?"\r":13;return a[a.length-1]===s&&(a=a.slice(0,-1)),a[a.length-1]===l&&(a=a.slice(0,-1)),a}t(B9e,"stripFinalNewline");import _de from"node:process";import kY from"node:path";import{fileURLToPath as YTt}from"node:url";function fde(a={}){let{env:s=process.env,platform:l=process.platform}=a;return l!=="win32"?"PATH":Object.keys(s).reverse().find(_=>_.toUpperCase()==="PATH")||"Path"}t(fde,"pathKey");var DPr=t(({cwd:a=_de.cwd(),path:s=_de.env[fde()],preferLocal:l=!0,execPath:_=_de.execPath,addExecPath:h=!0}={})=>{let b=a instanceof URL?YTt(a):a,D=kY.resolve(b),A=[];return l&&kPr(A,D),h&&wPr(A,_,D),[...A,s].join(kY.delimiter)},"npmRunPath"),kPr=t((a,s)=>{let l;for(;l!==s;)a.push(kY.join(s,"node_modules/.bin")),l=s,s=kY.resolve(s,"..")},"applyPreferLocal"),wPr=t((a,s,l)=>{let _=s instanceof URL?YTt(s):s;a.push(kY.resolve(l,_,".."))},"applyExecPath"),XTt=t(({env:a=_de.env,...s}={})=>{a={...a};let l=fde({env:a});return s.path=a[l],a[l]=DPr(s),a},"npmRunPathEnv");var PPr=t((a,s,l,_)=>{if(l==="length"||l==="prototype"||l==="arguments"||l==="caller")return;let h=Object.getOwnPropertyDescriptor(a,l),b=Object.getOwnPropertyDescriptor(s,l);!APr(h,b)&&_||Object.defineProperty(a,l,b)},"copyProperty"),APr=t(function(a,s){return a===void 0||a.configurable||a.writable===s.writable&&a.enumerable===s.enumerable&&a.configurable===s.configurable&&(a.writable||a.value===s.value)},"canCopyProperty"),NPr=t((a,s)=>{let l=Object.getPrototypeOf(s);l!==Object.getPrototypeOf(a)&&Object.setPrototypeOf(a,l)},"changePrototype"),IPr=t((a,s)=>`/* Wrapped ${a}*/
|
|
656
656
|
${s}`,"wrappedToString"),OPr=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),FPr=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),LPr=t((a,s,l)=>{let _=l===""?"":`with ${l.trim()}() `,h=IPr.bind(null,_,s.toString());Object.defineProperty(h,"name",FPr),Object.defineProperty(a,"toString",{...OPr,value:h})},"changeToString");function U9e(a,s,{ignoreNonConfigurable:l=!1}={}){let{name:_}=a;for(let h of Reflect.ownKeys(s))PPr(a,s,h,l);return NPr(a,s),LPr(a,s,_),a}t(U9e,"mimicFunction");var pde=new WeakMap,QTt=t((a,s={})=>{if(typeof a!="function")throw new TypeError("Expected a function");let l,_=0,h=a.displayName||a.name||"<anonymous>",b=t(function(...D){if(pde.set(b,++_),_===1)l=a.apply(this,D),a=null;else if(s.throw===!0)throw new Error(`Function \`${h}\` can only be called once`);return l},"onetime");return U9e(b,a),pde.set(b,_),b},"onetime");QTt.callCount=a=>{if(!pde.has(a))throw new Error(`The given function \`${a.name}\` is not wrapped by the \`onetime\` package`);return pde.get(a)};var ZTt=QTt;import{constants as BPr}from"os";var ext=t(function(){let a=$9e-txt+1;return Array.from({length:a},RPr)},"getRealtimeSignals"),RPr=t(function(a,s){return{name:`SIGRT${s+1}`,number:txt+s,action:"terminate",description:"Application-specific signal (realtime)",standard:"posix"}},"getRealtimeSignal"),txt=34,$9e=64;import{constants as MPr}from"os";var rxt=[{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 z9e=t(function(){let a=ext();return[...rxt,...a].map(jPr)},"getSignals"),jPr=t(function({name:a,number:s,description:l,action:_,forced:h=!1,standard:b}){let{signals:{[a]:D}}=MPr,A=D!==void 0;return{name:a,number:A?D:s,description:l,supported:A,action:_,forced:h,standard:b}},"normalizeSignal");var UPr=t(function(){return z9e().reduce($Pr,{})},"getSignalsByName"),$Pr=t(function(a,{name:s,number:l,description:_,supported:h,action:b,forced:D,standard:A}){return{...a,[s]:{name:s,number:l,description:_,supported:h,action:b,forced:D,standard:A}}},"getSignalByName"),nxt=UPr(),zPr=t(function(){let a=z9e(),s=$9e+1,l=Array.from({length:s},(_,h)=>JPr(h,a));return Object.assign({},...l)},"getSignalsByNumber"),JPr=t(function(a,s){let l=qPr(a,s);if(l===void 0)return{};let{name:_,description:h,supported:b,action:D,forced:A,standard:M}=l;return{[a]:{name:_,number:a,description:h,supported:b,action:D,forced:A,standard:M}}},"getSignalByNumber"),qPr=t(function(a,s){let l=s.find(({name:_})=>BPr.signals[_]===a);return l!==void 0?l:s.find(_=>_.number===a)},"findSignalByNumber"),sGr=zPr();var VPr=t(({timedOut:a,timeout:s,errorCode:l,signal:_,signalDescription:h,exitCode:b,isCanceled:D})=>a?`timed out after ${s} milliseconds`:D?"was canceled":l!==void 0?`failed with ${l}`:_!==void 0?`was killed with ${_} (${h})`:b!==void 0?`failed with exit code ${b}`:"failed","getErrorPrefix"),J9e=t(({stdout:a,stderr:s,all:l,error:_,signal:h,exitCode:b,command:D,escapedCommand:A,timedOut:M,isCanceled:z,killed:re,parsed:{options:{timeout:ie}}})=>{b=b===null?void 0:b,h=h===null?void 0:h;let Q=h===void 0?void 0:nxt[h].description,Re=_&&_.code,we=`Command ${VPr({timedOut:M,timeout:ie,errorCode:Re,signal:h,signalDescription:Q,exitCode:b,isCanceled:z})}: ${D}`,wt=Object.prototype.toString.call(_)==="[object Error]",xt=wt?`${we}
|
|
657
657
|
${_.message}`:we,Tr=[xt,s,a].filter(Boolean).join(`
|
|
658
|
-
`);return wt?(_.originalMessage=_.message,_.message=Tr):_=new Error(Tr),_.shortMessage=xt,_.command=D,_.escapedCommand=A,_.exitCode=b,_.signal=h,_.signalDescription=Q,_.stdout=a,_.stderr=s,l!==void 0&&(_.all=l),"bufferedData"in _&&delete _.bufferedData,_.failed=!0,_.timedOut=!!M,_.isCanceled=z,_.killed=re&&!M,_},"makeError");var dde=["stdin","stdout","stderr"],WPr=t(a=>dde.some(s=>a[s]!==void 0),"hasAlias"),ixt=t(a=>{if(!a)return;let{stdio:s}=a;if(s===void 0)return dde.map(_=>a[_]);if(WPr(a))throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${dde.map(_=>`\`${_}\``).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 l=Math.max(s.length,dde.length);return Array.from({length:l},(_,h)=>s[h])},"normalizeStdio");var fxt=x_(uxt(),1);import HPr from"node:os";var GPr=1e3*5,_xt=t((a,s="SIGTERM",l={})=>{let _=a(s);return KPr(a,s,l,_),_},"spawnedKill"),KPr=t((a,s,l,_)=>{if(!YPr(s,l,_))return;let h=QPr(l),b=setTimeout(()=>{a("SIGKILL")},h);b.unref&&b.unref()},"setKillTimeout"),YPr=t((a,{forceKillAfterTimeout:s},l)=>XPr(a)&&s!==!1&&l,"shouldForceKill"),XPr=t(a=>a===HPr.constants.signals.SIGTERM||typeof a=="string"&&a.toUpperCase()==="SIGTERM","isSigterm"),QPr=t(({forceKillAfterTimeout:a=!0})=>{if(a===!0)return GPr;if(!Number.isFinite(a)||a<0)throw new TypeError(`Expected the \`forceKillAfterTimeout\` option to be a non-negative integer, got \`${a}\` (${typeof a})`);return a},"getForceKillAfterTimeout"),pxt=t((a,s)=>{a.kill()&&(s.isCanceled=!0)},"spawnedCancel"),ZPr=t((a,s,l)=>{a.kill(s),l(Object.assign(new Error("Timed out"),{timedOut:!0,signal:s}))},"timeoutKill"),dxt=t((a,{timeout:s,killSignal:l="SIGTERM"},_)=>{if(s===0||s===void 0)return _;let h,b=new Promise((A,M)=>{h=setTimeout(()=>{ZPr(a,l,M)},s)}),D=_.finally(()=>{clearTimeout(h)});return Promise.race([b,D])},"setupTimeout"),mxt=t(({timeout:a})=>{if(a!==void 0&&(!Number.isFinite(a)||a<0))throw new TypeError(`Expected the \`timeout\` option to be a non-negative integer, got \`${a}\` (${typeof a})`)},"validateTimeout"),hxt=t(async(a,{cleanup:s,detached:l},_)=>{if(!s||l)return _;let h=(0,fxt.default)(()=>{a.kill()});return _.finally(()=>{h()})},"setExitHandler");function gxt(a){return a!==null&&typeof a=="object"&&typeof a.pipe=="function"}t(gxt,"isStream");var K9e=x_(bxt(),1),xxt=x_(Txt(),1);var Ext=t((a,s)=>{s===void 0||a.stdin===void 0||(gxt(s)?s.pipe(a.stdin):a.stdin.end(s))},"handleInput"),Cxt=t((a,{all:s})=>{if(!s||!a.stdout&&!a.stderr)return;let l=(0,xxt.default)();return a.stdout&&l.add(a.stdout),a.stderr&&l.add(a.stderr),l},"makeAllStream"),H9e=t(async(a,s)=>{if(a){a.destroy();try{return await s}catch(l){return l.bufferedData}}},"getBufferedData"),G9e=t((a,{encoding:s,buffer:l,maxBuffer:_})=>{if(!(!a||!l))return s?(0,K9e.default)(a,{encoding:s,maxBuffer:_}):K9e.default.buffer(a,{maxBuffer:_})},"getStreamPromise"),Dxt=t(async({stdout:a,stderr:s,all:l},{encoding:_,buffer:h,maxBuffer:b},D)=>{let A=G9e(a,{encoding:_,buffer:h,maxBuffer:b}),M=G9e(s,{encoding:_,buffer:h,maxBuffer:b}),z=G9e(l,{encoding:_,buffer:h,maxBuffer:b*2});try{return await Promise.all([D,A,M,z])}catch(re){return Promise.all([{error:re,signal:re.signal,timedOut:re.timedOut},H9e(a,A),H9e(s,M),H9e(l,z)])}},"getSpawnedResult");var oAr=(async()=>{})().constructor.prototype,cAr=["then","catch","finally"].map(a=>[a,Reflect.getOwnPropertyDescriptor(oAr,a)]),Y9e=t((a,s)=>{for(let[l,_]of cAr){let h=typeof s=="function"?(...b)=>Reflect.apply(_.value,s(),b):_.value.bind(s);Reflect.defineProperty(a,l,{..._,value:h})}return a},"mergePromise"),kxt=t(a=>new Promise((s,l)=>{a.on("exit",(_,h)=>{s({exitCode:_,signal:h})}),a.on("error",_=>{l(_)}),a.stdin&&a.stdin.on("error",_=>{l(_)})}),"getSpawnedPromise");var wxt=t((a,s=[])=>Array.isArray(s)?[a,...s]:[a],"normalizeArgs"),lAr=/^[\w.-]+$/,uAr=/"/g,fAr=t(a=>typeof a!="string"||lAr.test(a)?a:`"${a.replace(uAr,'\\"')}"`,"escapeArg"),Pxt=t((a,s)=>wxt(a,s).join(" "),"joinCommand"),Axt=t((a,s)=>wxt(a,s).map(l=>fAr(l)).join(" "),"getEscapedCommand");var dAr=1e3*1e3*100,mAr=t(({env:a,extendEnv:s,preferLocal:l,localDir:_,execPath:h})=>{let b=s?{...bde.env,...a}:a;return l?XTt({env:b,cwd:_,execPath:h}):b},"getEnv"),hAr=t((a,s,l={})=>{let _=Ixt.default._parse(a,s,l);return a=_.command,s=_.args,l=_.options,l={maxBuffer:dAr,buffer:!0,stripFinalNewline:!0,extendEnv:!0,preferLocal:!1,localDir:l.cwd||bde.cwd(),execPath:bde.execPath,encoding:"utf8",reject:!0,cleanup:!0,all:!1,windowsHide:!0,...l},l.env=mAr(l),l.stdio=ixt(l),bde.platform==="win32"&&pAr.basename(a,".exe")==="cmd"&&s.unshift("/q"),{file:a,args:s,options:l,parsed:_}},"handleArguments"),X9e=t((a,s,l)=>typeof s!="string"&&!_Ar.isBuffer(s)?l===void 0?void 0:"":a.stripFinalNewline?B9e(s):s,"handleOutput");function Oxt(a,s,l){let _=hAr(a,s,l),h=Pxt(a,s),b=Axt(a,s);mxt(_.options);let D;try{D=Nxt.spawn(_.file,_.args,_.options)}catch(Re){let Ie=new Nxt.ChildProcess,we=Promise.reject(J9e({error:Re,stdout:"",stderr:"",all:"",command:h,escapedCommand:b,parsed:_,timedOut:!1,isCanceled:!1,killed:!1}));return Y9e(Ie,we)}let A=kxt(D),M=dxt(D,_.options,A),z=hxt(D,_.options,M),re={isCanceled:!1};D.kill=_xt.bind(null,D.kill.bind(D)),D.cancel=pxt.bind(null,D,re);let Q=ZTt(t(async()=>{let[{error:Re,exitCode:Ie,signal:we,timedOut:wt},xt,Tr,fn]=await Dxt(D,_.options,z),tn=X9e(_.options,xt),cn=X9e(_.options,Tr),Er=X9e(_.options,fn);if(Re||Ie!==0||we!==null){let vr=J9e({error:Re,exitCode:Ie,signal:we,stdout:tn,stderr:cn,all:Er,command:h,escapedCommand:b,parsed:_,timedOut:wt,isCanceled:re.isCanceled||(_.options.signal?_.options.signal.aborted:!1),killed:D.killed});if(!_.options.reject)return vr;throw vr}return{command:h,escapedCommand:b,exitCode:0,stdout:tn,stderr:cn,all:Er,failed:!1,timedOut:!1,isCanceled:!1,killed:!1}},"handlePromise"));return Ext(D,_.options.input),D.all=Cxt(D,_.options),Y9e(D,Q)}t(Oxt,"execa");async function Tde(a,s){if(a.__ZUPLO_LOG_LEVEL=process.env.__ZUPLO_LOG_LEVEL??process.env.LOG_LEVEL,a.__ZUPLO_LOG_FORMAT=process.env.__ZUPLO_LOG_FORMAT??process.env.LOG_FORMAT,a.LOG_LEVEL=process.env.LOG_LEVEL??process.env.LOG_LEVEL,a.LOG_FORMAT=process.env.LOG_FORMAT??process.env.LOG_FORMAT,a.GIT_SHA=process.env.GIT_SHA??await gAr(s),process.env.__ZUPLO_CONFIG&&(a.__ZUPLO_CONFIG=process.env.__ZUPLO_CONFIG),Fxt(Sde.join(s,".env.zuplo"))){let l=Lxt(Sde.join(s,".env.zuplo"),"utf8"),_=Q9e.default.parse(l);for(let h of Object.keys(_))if(a[h]=_[h],h==="ZUPLO_SYSTEM_CONFIGURATIONS"){let b=Buffer.from(mue.decode(_[h])).toString(),D=JSON.parse(b);for(let A of Object.keys(D))a[A]=D[A]}}if(Fxt(Sde.join(s,".env"))){let l=Lxt(Sde.join(s,".env"),"utf8"),_=Q9e.default.parse(l);for(let h of Object.keys(_))a[h]=_[h]}for(let l of Object.keys(a))a[l]===void 0&&delete a[l];return a}t(Tde,"setEnvironment");async function gAr(a){let s="unknown";try{let{stdout:l}=await Oxt("git",["rev-parse","HEAD"],{cwd:a});l.trim().length===40&&(s=l.trim())}catch{}return s}t(gAr,"getGitSha");async function SAr({buildId:a,output:s,sourceDirectory:l,bundledDir:_,port:h,binaryName:b,publicZuploEnvironmentVariables:D,logger:A,handleRuntimeStdio:M}){if(_){let re=AY.join(l,_,"modules.json");if(!yAr(re))throw new Error("The bundled-dir does not contain a modules.json file.");let ie=await bAr(re,"utf-8").then(JSON.parse),Q=await uB(l);return Q.status===bA?new Promise((Re,Ie)=>{z(Q.config.compatibilityDate,AY.join(l,_),ie,Re,M)().catch(we=>{A.error(we),Ie(we)})}):(A.warn("Failed to get Zuplo config. Using default compatibility date."),new Promise((Re,Ie)=>{z(void 0,l,ie,Re,M)().catch(we=>{A.error(we),Ie(we)})}))}else{let re=new WA({buildId:a,output:s,sourceDirectory:l,command:"dev",logger:A,publicZuploEnvironmentVariables:D??{ZUPLO_ENVIRONMENT_TYPE:"LOCAL_DEVELOPMENT"},urls:void 0});try{await re.start()}catch{A.info("Ran into irrecoverable error while building. Fix the error and rerun the command."),process.exit(1)}return new Promise((ie,Q)=>{re.onReload((Re,Ie)=>{(Ie||Re&&Re.errors&&Re.errors.length>0)&&Q(Ie??Re?.errors),z(Re?.compatibilityDate,AY.join(l,"dist"),lB(l,Re?.metafile),ie,M)().catch(we=>{A.error(we),Q(we)})})})}function z(re,ie,Q,Re,Ie){return async()=>{let we={};await Tde(we,l);let wt=new Rxt.ZuploWorkerd({compatibilityDate:re,scriptDirectory:ie,modules:Q,port:h??Fm.DEV_SERVER_PORT,bindings:we,handleRuntimeStdio:Ie}),xt=b??"compiled-zup",Tr=AY.join(l,"dist");await vAr(Tr,{recursive:!0}),await wt.compileBinary({binaryPath:AY.join(l,"dist",xt)}),await wt.dispose(),Re(void 0)}}t(z,"compile")}t(SAr,"compileWorkerdServer");var Mxt=x_(P9e(),1);import xAr from"node:path";import TAr from"node:net";function NY(a,s){return new Promise(l=>{let _=new TAr.Socket;_.connect(s,a),_.on("connect",()=>{_.destroy(),l(!1)}),_.on("error",()=>{_.destroy(),l(!0)})})}t(NY,"isPortAvailable");var xde=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??Fm.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 l="http://localhost:3000",_=`http://localhost:${this.port}`;this.buildWatcher=new WA({...s,logger:this.logger,publicZuploEnvironmentVariables:{...s.publicZuploEnvironmentVariables,ZUPLO_ENVIRONMENT_TYPE:"LOCAL_DEVELOPMENT"},urls:{devPortal:{defaultUrl:l,urls:[l]},api:{defaultUrl:_,urls:[_]}}}),this.buildWatcher.watchEnvFiles()}}async start(){if(!await NY("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(l){this.output.child("api").error(l.toString());let _="Ran into irrecoverable error while starting watcher. Fix the error and restart the server.";this.output.child("api").error(_),this.logger?.info(_),process.exit(1)}await this.startOrReload(),this.buildWatcher?.onReload((l,_)=>{_||l&&l.errors&&l.errors.length>0||(this.onReload(l,_),this.startOrReload(l).catch(h=>{this.output.child("api").error(h.toString()),this.logger?.error(h)}))})}async startOrReload(s){try{let l={};await Tde(l,this.sourceDirectory),await this.workerd?.dispose(),this.workerd=new Mxt.ZuploWorkerd({compatibilityDate:s?.compatibilityDate,scriptDirectory:xAr.join(this.sourceDirectory,"dist"),modules:lB(this.sourceDirectory,s?.metafile),port:this.port,inspectorPort:this.debugPort??void 0,bindings:l,handleRuntimeStdio:this.handleRuntimeStdio}),await this.workerd.serve()}catch(l){this.logger?.debug(l)}}async stop(){await this.buildWatcher?.close(),await this.workerd?.dispose()}};import{fileURLToPath as zxt}from"node:url";import{Readable as jxt}from"node:stream";import Bxt from"node:assert";import EAr from"node:child_process";import CAr from"node:fs";import Ede from"node:os";import DAr from"node:path";function Uxt(a,s){let l=import.meta.resolve(a),_=new URL(".",l),h=new URL(s,_);if(CAr.existsSync(h))return zxt(h)}t(Uxt,"getValidExecutablePath");function kAr(){let a=Ede.platform()==="win32"?"deno.exe":"deno",s=Uxt("deno/package.json",a);if(s)return s;let l=wAr(),_=Uxt(`@deno/${l}/package.json`,a);if(_)return _;throw new Error("Failed to locate the managed-dedicated server executable.")}t(kAr,"locateDenoExecutable");function wAr(){let a=Ede.platform();return a==="linux"?a+"-"+$xt()+"-glibc":a+"-"+$xt()}t(wAr,"getTarget");function $xt(){let a=Ede.arch();if(a!=="arm64"&&a!=="x64")throw new Error("Unsupported architecture "+Ede.arch()+". Only x64 and aarch64 binaries are available.");return a}t($xt,"getArch");var Cde=class{static{t(this,"ZenoServer")}serverProcess;debugPort;processExitPromise;logger;output;buildWatcher;onReload;handleRuntimeStdio;denoExecutablePath;port=9e3;constructor(s){if(this.debugPort=s.debugPort,this.logger=s.logger,this.output=s.output,this.onReload=s.onReload,this.handleRuntimeStdio=s.handleRuntimeStdio,!s.zupTestMode){let l="http://localhost:3000",_=`http://localhost:${this.port}`;this.buildWatcher=new WA({sourceDirectory:s.sourceDirectory,command:"dev",logger:s.logger,publicZuploEnvironmentVariables:{...s.publicZuploEnvironmentVariables,ZUPLO_ENVIRONMENT_TYPE:"LOCAL_DEVELOPMENT"},buildId:"dev",output:s.output,urls:{devPortal:{defaultUrl:l,urls:[l]},api:{defaultUrl:_,urls:[_]}}}),this.buildWatcher.watchEnvFiles()}this.denoExecutablePath=kAr()}getServeArgs(){let s=`${DAr.dirname(zxt(import.meta.url))}/zeno.js`,l=["run","--allow-read","--allow-net","--allow-env","--allow-write"];return this.debugPort&&l.push(`--inspect=127.0.0.1:${this.debugPort}`),l.push(s),l}async getUnavailablePorts(){let s=[];return this.debugPort&&!await NY("127.0.0.1",this.debugPort)&&s.push(this.debugPort),await NY("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(l){this.output.child("api").error(l.toString());let _="Ran into irrecoverable error while starting watcher. Fix the error and restart the server.";this.output.child("api").error(_),this.logger?.info(_),process.exit(1)}await this.startOrReload(),this.buildWatcher?.onReload((l,_)=>{_||l&&l.errors&&l.errors.length>0||(this.onReload(l,_),this.startOrReload().catch(h=>{this.output.child("api").error(h.toString()),this.logger?.error(h)}))})}async startOrReload(){try{await this.dispose(),this.logger?.info("Starting managed-dedicated local server");let s=this.getServeArgs();this.serverProcess=EAr.spawn(this.denoExecutablePath,s,{stdio:["pipe","pipe","pipe"],env:{...process.env,FORCE_COLOR:"1"}}),Bxt(this.serverProcess.stdout instanceof jxt),Bxt(this.serverProcess.stderr instanceof jxt),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()}};async function PAr(a){let s=await uB(a),l=!1;return s.status===bA&&(l=s.config.flags?.managedDedicatedFlags?.useZeno??!1),l||process.env.ZUPLO_DEV_RUNTIME==="zeno"}t(PAr,"useZeno");async function AAr({sourceDirectory:a,port:s,debugPort:l,publicZuploEnvironmentVariables:_,logger:h,output:b,buildId:D,onReload:A,handleRuntimeStdio:M}){process.env.ZUPLO_IS_LOCAL_DEVELOPMENT="true";let z;await PAr(a)?(h.debug("Starting managed-dedicated local dev server."),z=new Cde({sourceDirectory:a,debugPort:l,logger:h,output:b,publicZuploEnvironmentVariables:_,onReload:A,handleRuntimeStdio:M})):(h.debug("Starting edge local dev server."),z=new xde({sourceDirectory:a,command:"dev",port:s,debugPort:l,publicZuploEnvironmentVariables:_,logger:h,output:b,buildId:D,onReload:A,handleRuntimeStdio:M})),await z.start();async function re(){await z.stop()}t(re,"handle"),process.on("SIGTERM",re),process.on("SIGINT",re)}t(AAr,"startDevServer");var hEt=x_(Vxt(),1),gEt=x_(dEt(),1);import{readFile as f6r}from"node:fs/promises";import MY from"node:path";var l6r=new RegExp("^((https|http)://)?[a-zA-Z0-9]{3}\\.[a-zA-Z0-9][a-zA-Z0-9]{0,61}?[a-zA-Z0-9]\\.(com|net|cn|cc)(:[0-9]{1,4})?/$"),u6r={concat(a,s){return MY.join(a,s)},resolve(a){return this.isAbsolute(a)?this.normalize(a):this.normalize(this.concat(process.cwd(),a))},normalize(a){let s=MY.normalize(a),l=MY.sep,_=[],h=0;return s.split(l).reverse().filter(D=>D!==".").forEach(D=>{D===".."?h++:h===0?_.push(D):h--}),_.reverse().join(l)},isData(a){return a.startsWith("data:")},isURL(a){return l6r.test(a)},isAbsolute(a){return MY.isAbsolute(a)},relativeToFile(a,s){if(this.isData(a)||this.isAbsolute(s))return this.normalize(s);{let l=MY.dirname(a);return this.normalize(this.concat(l,s))}}},Lde=u6r;var mEt=t(a=>{let s=t(l=>l in s.cache?s.cache[l]:s.cache[l]=a(l),"m");return s.forgetEverything=()=>{s.cache=Object.create(null)},s.cache=Object.create(null),s},"memoize");function uLe(a){let s=mEt(async D=>await l(D,await a(D)));async function l(D,A){if(A===void 0)return s(Lde.resolve(D));let M,z,re=t(async Q=>(z=z||await _(ie))(Q),"_resolve"),ie={path:D,text:A,get lines(){return M=M||A.split(`
|
|
658
|
+
`);return wt?(_.originalMessage=_.message,_.message=Tr):_=new Error(Tr),_.shortMessage=xt,_.command=D,_.escapedCommand=A,_.exitCode=b,_.signal=h,_.signalDescription=Q,_.stdout=a,_.stderr=s,l!==void 0&&(_.all=l),"bufferedData"in _&&delete _.bufferedData,_.failed=!0,_.timedOut=!!M,_.isCanceled=z,_.killed=re&&!M,_},"makeError");var dde=["stdin","stdout","stderr"],WPr=t(a=>dde.some(s=>a[s]!==void 0),"hasAlias"),ixt=t(a=>{if(!a)return;let{stdio:s}=a;if(s===void 0)return dde.map(_=>a[_]);if(WPr(a))throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${dde.map(_=>`\`${_}\``).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 l=Math.max(s.length,dde.length);return Array.from({length:l},(_,h)=>s[h])},"normalizeStdio");var fxt=x_(uxt(),1);import HPr from"node:os";var GPr=1e3*5,_xt=t((a,s="SIGTERM",l={})=>{let _=a(s);return KPr(a,s,l,_),_},"spawnedKill"),KPr=t((a,s,l,_)=>{if(!YPr(s,l,_))return;let h=QPr(l),b=setTimeout(()=>{a("SIGKILL")},h);b.unref&&b.unref()},"setKillTimeout"),YPr=t((a,{forceKillAfterTimeout:s},l)=>XPr(a)&&s!==!1&&l,"shouldForceKill"),XPr=t(a=>a===HPr.constants.signals.SIGTERM||typeof a=="string"&&a.toUpperCase()==="SIGTERM","isSigterm"),QPr=t(({forceKillAfterTimeout:a=!0})=>{if(a===!0)return GPr;if(!Number.isFinite(a)||a<0)throw new TypeError(`Expected the \`forceKillAfterTimeout\` option to be a non-negative integer, got \`${a}\` (${typeof a})`);return a},"getForceKillAfterTimeout"),pxt=t((a,s)=>{a.kill()&&(s.isCanceled=!0)},"spawnedCancel"),ZPr=t((a,s,l)=>{a.kill(s),l(Object.assign(new Error("Timed out"),{timedOut:!0,signal:s}))},"timeoutKill"),dxt=t((a,{timeout:s,killSignal:l="SIGTERM"},_)=>{if(s===0||s===void 0)return _;let h,b=new Promise((A,M)=>{h=setTimeout(()=>{ZPr(a,l,M)},s)}),D=_.finally(()=>{clearTimeout(h)});return Promise.race([b,D])},"setupTimeout"),mxt=t(({timeout:a})=>{if(a!==void 0&&(!Number.isFinite(a)||a<0))throw new TypeError(`Expected the \`timeout\` option to be a non-negative integer, got \`${a}\` (${typeof a})`)},"validateTimeout"),hxt=t(async(a,{cleanup:s,detached:l},_)=>{if(!s||l)return _;let h=(0,fxt.default)(()=>{a.kill()});return _.finally(()=>{h()})},"setExitHandler");function gxt(a){return a!==null&&typeof a=="object"&&typeof a.pipe=="function"}t(gxt,"isStream");var K9e=x_(bxt(),1),xxt=x_(Txt(),1);var Ext=t((a,s)=>{s===void 0||a.stdin===void 0||(gxt(s)?s.pipe(a.stdin):a.stdin.end(s))},"handleInput"),Cxt=t((a,{all:s})=>{if(!s||!a.stdout&&!a.stderr)return;let l=(0,xxt.default)();return a.stdout&&l.add(a.stdout),a.stderr&&l.add(a.stderr),l},"makeAllStream"),H9e=t(async(a,s)=>{if(a){a.destroy();try{return await s}catch(l){return l.bufferedData}}},"getBufferedData"),G9e=t((a,{encoding:s,buffer:l,maxBuffer:_})=>{if(!(!a||!l))return s?(0,K9e.default)(a,{encoding:s,maxBuffer:_}):K9e.default.buffer(a,{maxBuffer:_})},"getStreamPromise"),Dxt=t(async({stdout:a,stderr:s,all:l},{encoding:_,buffer:h,maxBuffer:b},D)=>{let A=G9e(a,{encoding:_,buffer:h,maxBuffer:b}),M=G9e(s,{encoding:_,buffer:h,maxBuffer:b}),z=G9e(l,{encoding:_,buffer:h,maxBuffer:b*2});try{return await Promise.all([D,A,M,z])}catch(re){return Promise.all([{error:re,signal:re.signal,timedOut:re.timedOut},H9e(a,A),H9e(s,M),H9e(l,z)])}},"getSpawnedResult");var oAr=(async()=>{})().constructor.prototype,cAr=["then","catch","finally"].map(a=>[a,Reflect.getOwnPropertyDescriptor(oAr,a)]),Y9e=t((a,s)=>{for(let[l,_]of cAr){let h=typeof s=="function"?(...b)=>Reflect.apply(_.value,s(),b):_.value.bind(s);Reflect.defineProperty(a,l,{..._,value:h})}return a},"mergePromise"),kxt=t(a=>new Promise((s,l)=>{a.on("exit",(_,h)=>{s({exitCode:_,signal:h})}),a.on("error",_=>{l(_)}),a.stdin&&a.stdin.on("error",_=>{l(_)})}),"getSpawnedPromise");var wxt=t((a,s=[])=>Array.isArray(s)?[a,...s]:[a],"normalizeArgs"),lAr=/^[\w.-]+$/,uAr=/"/g,fAr=t(a=>typeof a!="string"||lAr.test(a)?a:`"${a.replace(uAr,'\\"')}"`,"escapeArg"),Pxt=t((a,s)=>wxt(a,s).join(" "),"joinCommand"),Axt=t((a,s)=>wxt(a,s).map(l=>fAr(l)).join(" "),"getEscapedCommand");var dAr=1e3*1e3*100,mAr=t(({env:a,extendEnv:s,preferLocal:l,localDir:_,execPath:h})=>{let b=s?{...bde.env,...a}:a;return l?XTt({env:b,cwd:_,execPath:h}):b},"getEnv"),hAr=t((a,s,l={})=>{let _=Ixt.default._parse(a,s,l);return a=_.command,s=_.args,l=_.options,l={maxBuffer:dAr,buffer:!0,stripFinalNewline:!0,extendEnv:!0,preferLocal:!1,localDir:l.cwd||bde.cwd(),execPath:bde.execPath,encoding:"utf8",reject:!0,cleanup:!0,all:!1,windowsHide:!0,...l},l.env=mAr(l),l.stdio=ixt(l),bde.platform==="win32"&&pAr.basename(a,".exe")==="cmd"&&s.unshift("/q"),{file:a,args:s,options:l,parsed:_}},"handleArguments"),X9e=t((a,s,l)=>typeof s!="string"&&!_Ar.isBuffer(s)?l===void 0?void 0:"":a.stripFinalNewline?B9e(s):s,"handleOutput");function Oxt(a,s,l){let _=hAr(a,s,l),h=Pxt(a,s),b=Axt(a,s);mxt(_.options);let D;try{D=Nxt.spawn(_.file,_.args,_.options)}catch(Re){let Ie=new Nxt.ChildProcess,we=Promise.reject(J9e({error:Re,stdout:"",stderr:"",all:"",command:h,escapedCommand:b,parsed:_,timedOut:!1,isCanceled:!1,killed:!1}));return Y9e(Ie,we)}let A=kxt(D),M=dxt(D,_.options,A),z=hxt(D,_.options,M),re={isCanceled:!1};D.kill=_xt.bind(null,D.kill.bind(D)),D.cancel=pxt.bind(null,D,re);let Q=ZTt(t(async()=>{let[{error:Re,exitCode:Ie,signal:we,timedOut:wt},xt,Tr,fn]=await Dxt(D,_.options,z),tn=X9e(_.options,xt),cn=X9e(_.options,Tr),Er=X9e(_.options,fn);if(Re||Ie!==0||we!==null){let vr=J9e({error:Re,exitCode:Ie,signal:we,stdout:tn,stderr:cn,all:Er,command:h,escapedCommand:b,parsed:_,timedOut:wt,isCanceled:re.isCanceled||(_.options.signal?_.options.signal.aborted:!1),killed:D.killed});if(!_.options.reject)return vr;throw vr}return{command:h,escapedCommand:b,exitCode:0,stdout:tn,stderr:cn,all:Er,failed:!1,timedOut:!1,isCanceled:!1,killed:!1}},"handlePromise"));return Ext(D,_.options.input),D.all=Cxt(D,_.options),Y9e(D,Q)}t(Oxt,"execa");async function Tde(a,s){if(a.__ZUPLO_LOG_LEVEL=process.env.__ZUPLO_LOG_LEVEL??process.env.LOG_LEVEL,a.__ZUPLO_LOG_FORMAT=process.env.__ZUPLO_LOG_FORMAT??process.env.LOG_FORMAT,a.LOG_LEVEL=process.env.LOG_LEVEL??process.env.LOG_LEVEL,a.LOG_FORMAT=process.env.LOG_FORMAT??process.env.LOG_FORMAT,a.GIT_SHA=process.env.GIT_SHA??await gAr(s),process.env.__ZUPLO_CONFIG&&(a.__ZUPLO_CONFIG=process.env.__ZUPLO_CONFIG),Fxt(Sde.join(s,".env.zuplo"))){let l=Lxt(Sde.join(s,".env.zuplo"),"utf8"),_=Q9e.default.parse(l);for(let h of Object.keys(_))if(a[h]=_[h],h==="ZUPLO_SYSTEM_CONFIGURATIONS"){let b=Buffer.from(mue.decode(_[h])).toString(),D=JSON.parse(b);for(let A of Object.keys(D))a[A]=D[A]}}if(Fxt(Sde.join(s,".env"))){let l=Lxt(Sde.join(s,".env"),"utf8"),_=Q9e.default.parse(l);for(let h of Object.keys(_))a[h]=_[h]}for(let l of Object.keys(a))a[l]===void 0&&delete a[l];return a}t(Tde,"setEnvironment");async function gAr(a){let s="unknown";try{let{stdout:l}=await Oxt("git",["rev-parse","HEAD"],{cwd:a});l.trim().length===40&&(s=l.trim())}catch{}return s}t(gAr,"getGitSha");async function SAr({buildId:a,output:s,sourceDirectory:l,bundledDir:_,port:h,binaryName:b,publicZuploEnvironmentVariables:D,logger:A,handleRuntimeStdio:M}){if(_){let re=AY.join(l,_,"modules.json");if(!yAr(re))throw new Error("The bundled-dir does not contain a modules.json file.");let ie=await bAr(re,"utf-8").then(JSON.parse),Q=await uB(l);return Q.status===bA?new Promise((Re,Ie)=>{z(Q.config.compatibilityDate,AY.join(l,_),ie,Re,M)().catch(we=>{A.error(we),Ie(we)})}):(A.warn("Failed to get Zuplo config. Using default compatibility date."),new Promise((Re,Ie)=>{z(void 0,l,ie,Re,M)().catch(we=>{A.error(we),Ie(we)})}))}else{let re=new WA({buildId:a,output:s,sourceDirectory:l,command:"dev",logger:A,publicZuploEnvironmentVariables:D??{ZUPLO_ENVIRONMENT_TYPE:"LOCAL_DEVELOPMENT"},urls:void 0});try{await re.start()}catch{A.info("Ran into irrecoverable error while building. Fix the error and rerun the command."),process.exit(1)}return new Promise((ie,Q)=>{re.onReload((Re,Ie)=>{(Ie||Re&&Re.errors&&Re.errors.length>0)&&Q(Ie??Re?.errors),z(Re?.compatibilityDate,AY.join(l,"dist"),lB(l,Re?.metafile),ie,M)().catch(we=>{A.error(we),Q(we)})})})}function z(re,ie,Q,Re,Ie){return async()=>{let we={};await Tde(we,l);let wt=new Rxt.ZuploWorkerd({compatibilityDate:re,scriptDirectory:ie,modules:Q,port:h??Fm.DEV_SERVER_PORT,bindings:we,handleRuntimeStdio:Ie}),xt=b??"compiled-zup",Tr=AY.join(l,"dist");await vAr(Tr,{recursive:!0}),await wt.compileBinary({binaryPath:AY.join(l,"dist",xt)}),await wt.dispose(),Re(void 0)}}t(z,"compile")}t(SAr,"compileWorkerdServer");var Mxt=x_(P9e(),1);import xAr from"node:path";import TAr from"node:net";function NY(a,s){return new Promise(l=>{let _=new TAr.Socket;_.connect(s,a),_.on("connect",()=>{_.destroy(),l(!1)}),_.on("error",()=>{_.destroy(),l(!0)})})}t(NY,"isPortAvailable");var xde=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??Fm.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 l="http://localhost:3000",_=`http://localhost:${this.port}`;this.buildWatcher=new WA({...s,logger:this.logger,publicZuploEnvironmentVariables:{...s.publicZuploEnvironmentVariables,ZUPLO_ENVIRONMENT_TYPE:"LOCAL_DEVELOPMENT"},urls:{devPortal:{defaultUrl:l,urls:[l]},api:{defaultUrl:_,urls:[_]}}}),this.buildWatcher.watchEnvFiles()}}async start(){if(!await NY("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(l){this.output.child("api").error(l.toString());let _="Ran into irrecoverable error while starting watcher. Fix the error and restart the server.";this.output.child("api").error(_),this.logger?.info(_),process.exit(1)}await this.startOrReload(),this.buildWatcher?.onReload((l,_)=>{_||l&&l.errors&&l.errors.length>0||(this.onReload(l,_),this.startOrReload(l).catch(h=>{this.output.child("api").error(h.toString()),this.logger?.error(h)}))})}async startOrReload(s){try{let l={};await Tde(l,this.sourceDirectory),await this.workerd?.dispose(),this.workerd=new Mxt.ZuploWorkerd({compatibilityDate:s?.compatibilityDate,scriptDirectory:xAr.join(this.sourceDirectory,"dist"),modules:lB(this.sourceDirectory,s?.metafile),port:this.port,inspectorPort:this.debugPort??void 0,bindings:l,handleRuntimeStdio:this.handleRuntimeStdio}),await this.workerd.serve()}catch(l){this.logger?.debug(l)}}async stop(){await this.buildWatcher?.close(),await this.workerd?.dispose()}};import{fileURLToPath as zxt}from"node:url";import{Readable as jxt}from"node:stream";import Bxt from"node:assert";import EAr from"node:child_process";import CAr from"node:fs";import Ede from"node:os";import DAr from"node:path";function Uxt(a,s){let l=import.meta.resolve(a),_=new URL(".",l),h=new URL(s,_);if(CAr.existsSync(h))return zxt(h)}t(Uxt,"getValidExecutablePath");function kAr(){let a=Ede.platform()==="win32"?"deno.exe":"deno",s=Uxt("deno/package.json",a);if(s)return s;let l=wAr(),_=Uxt(`@deno/${l}/package.json`,a);if(_)return _;throw new Error("Failed to locate the managed-dedicated server executable.")}t(kAr,"locateDenoExecutable");function wAr(){let a=Ede.platform();return a==="linux"?a+"-"+$xt()+"-glibc":a+"-"+$xt()}t(wAr,"getTarget");function $xt(){let a=Ede.arch();if(a!=="arm64"&&a!=="x64")throw new Error("Unsupported architecture "+Ede.arch()+". Only x64 and aarch64 binaries are available.");return a}t($xt,"getArch");var Cde=class{static{t(this,"ZenoServer")}serverProcess;sourceDirectory;debugPort;processExitPromise;logger;output;buildWatcher;onReload;handleRuntimeStdio;denoExecutablePath;port=9e3;constructor(s){if(this.debugPort=s.debugPort,this.logger=s.logger,this.output=s.output,this.onReload=s.onReload,this.handleRuntimeStdio=s.handleRuntimeStdio,this.sourceDirectory=s.sourceDirectory,!s.zupTestMode){let l="http://localhost:3000",_=`http://localhost:${this.port}`;this.buildWatcher=new WA({sourceDirectory:s.sourceDirectory,command:"dev",logger:s.logger,publicZuploEnvironmentVariables:{...s.publicZuploEnvironmentVariables,ZUPLO_ENVIRONMENT_TYPE:"LOCAL_DEVELOPMENT"},buildId:"dev",output:s.output,urls:{devPortal:{defaultUrl:l,urls:[l]},api:{defaultUrl:_,urls:[_]}}}),this.buildWatcher.watchEnvFiles()}this.denoExecutablePath=kAr()}getServeArgs(){let s=`${DAr.dirname(zxt(import.meta.url))}/zeno.js`,l=["run","--allow-read","--allow-net","--allow-env","--allow-write"];return this.debugPort&&l.push(`--inspect=127.0.0.1:${this.debugPort}`),l.push(s),l.push("--dir",this.sourceDirectory),l}async getUnavailablePorts(){let s=[];return this.debugPort&&!await NY("127.0.0.1",this.debugPort)&&s.push(this.debugPort),await NY("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(l){this.output.child("api").error(l.toString());let _="Ran into irrecoverable error while starting watcher. Fix the error and restart the server.";this.output.child("api").error(_),this.logger?.info(_),process.exit(1)}await this.startOrReload(),this.buildWatcher?.onReload((l,_)=>{_||l&&l.errors&&l.errors.length>0||(this.onReload(l,_),this.startOrReload().catch(h=>{this.output.child("api").error(h.toString()),this.logger?.error(h)}))})}async startOrReload(){try{await this.dispose(),this.logger?.info("Starting managed-dedicated local server");let s=this.getServeArgs();this.serverProcess=EAr.spawn(this.denoExecutablePath,s,{stdio:["pipe","pipe","pipe"],env:{...process.env,FORCE_COLOR:"1"}}),Bxt(this.serverProcess.stdout instanceof jxt),Bxt(this.serverProcess.stderr instanceof jxt),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()}};async function PAr(a){let s=await uB(a),l=!1;return s.status===bA&&(l=s.config.flags?.managedDedicatedFlags?.useZeno??!1),l||process.env.ZUPLO_DEV_RUNTIME==="zeno"}t(PAr,"useZeno");async function AAr({sourceDirectory:a,port:s,debugPort:l,publicZuploEnvironmentVariables:_,logger:h,output:b,buildId:D,onReload:A,handleRuntimeStdio:M}){process.env.ZUPLO_IS_LOCAL_DEVELOPMENT="true";let z;await PAr(a)?(h.debug("Starting managed-dedicated local dev server."),z=new Cde({sourceDirectory:a,debugPort:l,logger:h,output:b,publicZuploEnvironmentVariables:_,onReload:A,handleRuntimeStdio:M})):(h.debug("Starting edge local dev server."),z=new xde({sourceDirectory:a,command:"dev",port:s,debugPort:l,publicZuploEnvironmentVariables:_,logger:h,output:b,buildId:D,onReload:A,handleRuntimeStdio:M})),await z.start();async function re(){await z.stop()}t(re,"handle"),process.on("SIGTERM",re),process.on("SIGINT",re)}t(AAr,"startDevServer");var hEt=x_(Vxt(),1),gEt=x_(dEt(),1);import{readFile as f6r}from"node:fs/promises";import MY from"node:path";var l6r=new RegExp("^((https|http)://)?[a-zA-Z0-9]{3}\\.[a-zA-Z0-9][a-zA-Z0-9]{0,61}?[a-zA-Z0-9]\\.(com|net|cn|cc)(:[0-9]{1,4})?/$"),u6r={concat(a,s){return MY.join(a,s)},resolve(a){return this.isAbsolute(a)?this.normalize(a):this.normalize(this.concat(process.cwd(),a))},normalize(a){let s=MY.normalize(a),l=MY.sep,_=[],h=0;return s.split(l).reverse().filter(D=>D!==".").forEach(D=>{D===".."?h++:h===0?_.push(D):h--}),_.reverse().join(l)},isData(a){return a.startsWith("data:")},isURL(a){return l6r.test(a)},isAbsolute(a){return MY.isAbsolute(a)},relativeToFile(a,s){if(this.isData(a)||this.isAbsolute(s))return this.normalize(s);{let l=MY.dirname(a);return this.normalize(this.concat(l,s))}}},Lde=u6r;var mEt=t(a=>{let s=t(l=>l in s.cache?s.cache[l]:s.cache[l]=a(l),"m");return s.forgetEverything=()=>{s.cache=Object.create(null)},s.cache=Object.create(null),s},"memoize");function uLe(a){let s=mEt(async D=>await l(D,await a(D)));async function l(D,A){if(A===void 0)return s(Lde.resolve(D));let M,z,re=t(async Q=>(z=z||await _(ie))(Q),"_resolve"),ie={path:D,text:A,get lines(){return M=M||A.split(`
|
|
659
659
|
`)},async resolve(Q){try{return await re(Q)}catch(Re){return Object.assign({},Q,{error:Re})}},_resolve:re};return ie}t(l,"SourceFile");async function _(D){let A=/\u0023 sourceMappingURL=(.+)\n?/g,M;for(;;){let ie=A.exec(D.text);if(ie)M=ie;else break}let z=M&&M[1],re=t(async ie=>Object.assign({},ie,{sourceFile:D,sourceLine:D.lines[ie.line-1]||""}),"defaultResolver");return z?await h(D.path,z,re):re}t(_,"SourceMapResolverFromFetchedFile");async function h(D,A,M){let z=A.startsWith("data:")?await l(D,(0,hEt.dataUriToBuffer)(A).toString()):await l(Lde.relativeToFile(D,A)),re=await new gEt.SourceMapConsumer(JSON.parse(z.text)),ie=mEt(async Q=>{let Re=Lde.relativeToFile(z.path,Q),Ie=re.sourceContentFor(Q,!0)||void 0;return await l(Re,Ie)});return async Q=>{try{let Re=re.originalPositionFor(Q);return Re.source?await(await ie(Re.source))._resolve(Object.assign({},Q,{line:Re.line,column:(Re.column??0)+1,name:Re.name})):M(Q)}catch(Re){return Object.assign(M(Q),{sourceMapError:Re})}}}t(h,"SourceMapResolver");let b=t(async function(A){try{return await l(A)}catch(M){let z={path:A,text:"",lines:[],error:M,async resolve(re){return Object.assign({},re,{error:M,sourceLine:"",sourceFile:z})},_resolve(re){return this.resolve(re)}};return z}},"getSource");return b.resetCache=()=>s.forgetEverything(),b.getCache=()=>s.cache,b}t(uLe,"buildGetSourceFunction");var _6r=t(async a=>f6r(a,{encoding:"utf8"}),"fetchFile"),yEt=uLe(_6r);import p6r from"node:path";import d6r from"node:util";var vEt=t(a=>a[a.length-1],"lastOf"),jY=t(a=>a.replace(/\\/g,"/"),"nixSlashes"),m6r=t((a,s)=>{let l=a||[],_=[],h={label:void 0,items:[l[0]]};return l.forEach(b=>{let D=s(b);h.label!==D&&h.items.length?_.push(h={label:D,items:[b]}):h.items.push(b)}),_},"partition"),BY=class a{static{t(this,"StackTracey")}items;getSource;pathRoot;constructor(s,{offset:l,getSource:_}){this.getSource=_,this.pathRoot=`${jY(process.cwd())}/`;let h=s,b=s instanceof SyntaxError;if(l=l||0,s instanceof Error&&(s=s.stack||""),typeof s=="string"&&(s=this.rawParse(s).slice(l).map(D=>this.extractEntryMetadata(D))),Array.isArray(s)){if(b){let D=d6r.inspect(h).split(`
|
|
660
660
|
`),A=D[0].split(":"),M=A.pop(),z=A.join(":");z&&s.unshift({file:jY(z),line:parseInt(M||"0",10),column:(D[2]||"").indexOf("^")+1,sourceLine:D[1],callee:"(syntax error)",syntaxError:!0,beforeParse:"",index:!1,native:!1,calleeShort:"",fileRelative:"",fileShort:"",fileName:"",thirdParty:!1})}this.items=s}else this.items=[]}extractEntryMetadata(s){let l=this.decomposePath(s.file||""),_=l[0],h=l[1];return Object.assign(s,{calleeShort:s.calleeShort||vEt((s.callee||"").split(".")),fileRelative:_,fileShort:this.shortenPath(_),fileName:vEt((s.file||"").split("/")),thirdParty:this.isThirdParty(_,h)&&!s.index,externalDomain:h})}shortenPath(s){return s.replace(/^node_modules\//,"").replace(/^webpack\/bootstrap\//,"").replace(/^__parcel_source_root\//,"")}decomposePath(s){let l=s,_=l.match(/^(http|https):\/\/([^\/]+)\/(.*)/),h=_?_[2]:void 0;return l=_?_[3]:l,l=p6r.relative(this.pathRoot,l),[jY(l).replace(/^.*:\/\/?\/?/,""),h]}isThirdParty(s,l){return!!l||s[0]==="~"||s[0]==="/"||s.indexOf("node_modules")===0||s.indexOf("webpack/bootstrap")===0}rawParse(s){return(s||"").split(`
|
|
661
661
|
`).map(h=>{h=h.trim();let b,D=[],A,M,z;if((M=h.match(/at (.+) \(eval at .+ \((.+)\), .+\)/))||(M=h.match(/at (.+) \((.+)\)/))||h.slice(0,3)!=="at "&&(M=h.match(/(.*)@(.*)/)))b=M[1],A=M[2]==="native",D=(M[2].match(/(.*):(\d+):(\d+)/)||M[2].match(/(.*):(\d+)/)||[]).slice(1);else if(z=h.match(/^(at\s+)*(.+):(\d+):(\d+)/))D=z.slice(2);else return;return b&&!D[0]&&b.split(".")[0]==="Array"&&(A=!0),{beforeParse:h,callee:b||"",index:D[0]==="/",native:A||!1,file:jY(D[0]||""),line:parseInt(D[1]||"",10)||void 0,column:parseInt(D[2]||"",10)||void 0,calleeShort:"",fileRelative:"",fileShort:"",fileName:"",thirdParty:!1}}).filter(h=>h!==void 0)}async withSourceAsyncAt(s){return this.items[s]&&this.withSourceAsync(this.items[s])}async withSourceAsync(s){if(this.shouldSkipResolving(s))return s;{let l=(s.file||"").replace("file://","");try{let h=await(await this.getSource(l)).resolve(s);return this.withSourceResolved(s,h)}catch(_){return this.withSourceResolved(s,{error:_,sourceLine:""})}}}shouldSkipResolving(s){return!!s.sourceFile||!!s.error||!!s.file&&s.file.indexOf("<")>=0}withSourceResolved(s,l){return l.sourceFile&&!l.sourceFile.error&&(l.file=jY(l.sourceFile.path),l=this.extractEntryMetadata(l)),l.sourceLine?.includes("// @hide")&&(l.sourceLine=l.sourceLine.replace("// @hide",""),l.hide=!0),(l.sourceLine?.includes("__webpack_require__")||l.sourceLine?.includes("/******/ ({"))&&(l.thirdParty=!0),Object.assign({sourceLine:""},s,l)}async withSourcesAsync(){let s=await Promise.all(this.items.map(l=>this.withSourceAsync(l)));return new a(s,{getSource:this.getSource})}mergeRepeatedLines(){return new a(m6r(this.items,s=>s.file+s.line).map(s=>s.items.slice(1).reduce((l,_)=>(l.callee=(l.callee||"<anonymous>")+" \u2192 "+(_.callee||"<anonymous>"),l.calleeShort=(l.calleeShort||"<anonymous>")+" \u2192 "+(_.calleeShort||"<anonymous>"),l),Object.assign({},s.items[0]))),{getSource:this.getSource})}async cleanAsync(){let s=await this.withSourcesAsync();return s.mergeRepeatedLines().filter((l,_)=>s.isClean(l,_))}isClean(s,l){return l===0||!(s.thirdParty||s.hide||s.native)}at(s){return Object.assign({beforeParse:"",callee:"<???>",index:!1,native:!1,file:"<???>",line:0,column:0},this.items[s])}map(s,l){return new a(this.items.map(s,l),{getSource:this.getSource})}filter(s,l){return new a(this.items.filter(s,l),{getSource:this.getSource})}slice(s,l){return new a(this.items.slice(s,l),{getSource:this.getSource})}concat(...s){return new a(this.items.concat(...s),{getSource:this.getSource})}maxColumnWidths(){return{callee:30,file:60,sourceLine:80}}static locationsEqual(s,l){return s.file===l.file&&s.line===l.line&&s.column===l.column}};import{relative as S6r}from"node:path";import{fileURLToPath as T6r}from"node:url";import{inspect as x6r}from"node:util";function fLe({onlyFirst:a=!1}={}){let l=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");return new RegExp(l,a?void 0:"g")}t(fLe,"ansiRegex");var h6r=fLe();function _Le(a){if(typeof a!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof a}\``);return a.replace(h6r,"")}t(_Le,"stripAnsi");function bEt(a){return a===161||a===164||a===167||a===168||a===170||a===173||a===174||a>=176&&a<=180||a>=182&&a<=186||a>=188&&a<=191||a===198||a===208||a===215||a===216||a>=222&&a<=225||a===230||a>=232&&a<=234||a===236||a===237||a===240||a===242||a===243||a>=247&&a<=250||a===252||a===254||a===257||a===273||a===275||a===283||a===294||a===295||a===299||a>=305&&a<=307||a===312||a>=319&&a<=322||a===324||a>=328&&a<=331||a===333||a===338||a===339||a===358||a===359||a===363||a===462||a===464||a===466||a===468||a===470||a===472||a===474||a===476||a===593||a===609||a===708||a===711||a>=713&&a<=715||a===717||a===720||a>=728&&a<=731||a===733||a===735||a>=768&&a<=879||a>=913&&a<=929||a>=931&&a<=937||a>=945&&a<=961||a>=963&&a<=969||a===1025||a>=1040&&a<=1103||a===1105||a===8208||a>=8211&&a<=8214||a===8216||a===8217||a===8220||a===8221||a>=8224&&a<=8226||a>=8228&&a<=8231||a===8240||a===8242||a===8243||a===8245||a===8251||a===8254||a===8308||a===8319||a>=8321&&a<=8324||a===8364||a===8451||a===8453||a===8457||a===8467||a===8470||a===8481||a===8482||a===8486||a===8491||a===8531||a===8532||a>=8539&&a<=8542||a>=8544&&a<=8555||a>=8560&&a<=8569||a===8585||a>=8592&&a<=8601||a===8632||a===8633||a===8658||a===8660||a===8679||a===8704||a===8706||a===8707||a===8711||a===8712||a===8715||a===8719||a===8721||a===8725||a===8730||a>=8733&&a<=8736||a===8739||a===8741||a>=8743&&a<=8748||a===8750||a>=8756&&a<=8759||a===8764||a===8765||a===8776||a===8780||a===8786||a===8800||a===8801||a>=8804&&a<=8807||a===8810||a===8811||a===8814||a===8815||a===8834||a===8835||a===8838||a===8839||a===8853||a===8857||a===8869||a===8895||a===8978||a>=9312&&a<=9449||a>=9451&&a<=9547||a>=9552&&a<=9587||a>=9600&&a<=9615||a>=9618&&a<=9621||a===9632||a===9633||a>=9635&&a<=9641||a===9650||a===9651||a===9654||a===9655||a===9660||a===9661||a===9664||a===9665||a>=9670&&a<=9672||a===9675||a>=9678&&a<=9681||a>=9698&&a<=9701||a===9711||a===9733||a===9734||a===9737||a===9742||a===9743||a===9756||a===9758||a===9792||a===9794||a===9824||a===9825||a>=9827&&a<=9829||a>=9831&&a<=9834||a===9836||a===9837||a===9839||a===9886||a===9887||a===9919||a>=9926&&a<=9933||a>=9935&&a<=9939||a>=9941&&a<=9953||a===9955||a===9960||a===9961||a>=9963&&a<=9969||a===9972||a>=9974&&a<=9977||a===9979||a===9980||a===9982||a===9983||a===10045||a>=10102&&a<=10111||a>=11094&&a<=11097||a>=12872&&a<=12879||a>=57344&&a<=63743||a>=65024&&a<=65039||a===65533||a>=127232&&a<=127242||a>=127248&&a<=127277||a>=127280&&a<=127337||a>=127344&&a<=127373||a===127375||a===127376||a>=127387&&a<=127404||a>=917760&&a<=917999||a>=983040&&a<=1048573||a>=1048576&&a<=1114109}t(bEt,"isAmbiguous");function SEt(a){return a===12288||a>=65281&&a<=65376||a>=65504&&a<=65510}t(SEt,"isFullWidth");function TEt(a){return a>=4352&&a<=4447||a===8986||a===8987||a===9001||a===9002||a>=9193&&a<=9196||a===9200||a===9203||a===9725||a===9726||a===9748||a===9749||a>=9800&&a<=9811||a===9855||a===9875||a===9889||a===9898||a===9899||a===9917||a===9918||a===9924||a===9925||a===9934||a===9940||a===9962||a===9970||a===9971||a===9973||a===9978||a===9981||a===9989||a===9994||a===9995||a===10024||a===10060||a===10062||a>=10067&&a<=10069||a===10071||a>=10133&&a<=10135||a===10160||a===10175||a===11035||a===11036||a===11088||a===11093||a>=11904&&a<=11929||a>=11931&&a<=12019||a>=12032&&a<=12245||a>=12272&&a<=12287||a>=12289&&a<=12350||a>=12353&&a<=12438||a>=12441&&a<=12543||a>=12549&&a<=12591||a>=12593&&a<=12686||a>=12688&&a<=12771||a>=12783&&a<=12830||a>=12832&&a<=12871||a>=12880&&a<=19903||a>=19968&&a<=42124||a>=42128&&a<=42182||a>=43360&&a<=43388||a>=44032&&a<=55203||a>=63744&&a<=64255||a>=65040&&a<=65049||a>=65072&&a<=65106||a>=65108&&a<=65126||a>=65128&&a<=65131||a>=94176&&a<=94180||a===94192||a===94193||a>=94208&&a<=100343||a>=100352&&a<=101589||a>=101632&&a<=101640||a>=110576&&a<=110579||a>=110581&&a<=110587||a===110589||a===110590||a>=110592&&a<=110882||a===110898||a>=110928&&a<=110930||a===110933||a>=110948&&a<=110951||a>=110960&&a<=111355||a===126980||a===127183||a===127374||a>=127377&&a<=127386||a>=127488&&a<=127490||a>=127504&&a<=127547||a>=127552&&a<=127560||a===127568||a===127569||a>=127584&&a<=127589||a>=127744&&a<=127776||a>=127789&&a<=127797||a>=127799&&a<=127868||a>=127870&&a<=127891||a>=127904&&a<=127946||a>=127951&&a<=127955||a>=127968&&a<=127984||a===127988||a>=127992&&a<=128062||a===128064||a>=128066&&a<=128252||a>=128255&&a<=128317||a>=128331&&a<=128334||a>=128336&&a<=128359||a===128378||a===128405||a===128406||a===128420||a>=128507&&a<=128591||a>=128640&&a<=128709||a===128716||a>=128720&&a<=128722||a>=128725&&a<=128727||a>=128732&&a<=128735||a===128747||a===128748||a>=128756&&a<=128764||a>=128992&&a<=129003||a===129008||a>=129292&&a<=129338||a>=129340&&a<=129349||a>=129351&&a<=129535||a>=129648&&a<=129660||a>=129664&&a<=129672||a>=129680&&a<=129725||a>=129727&&a<=129733||a>=129742&&a<=129755||a>=129760&&a<=129768||a>=129776&&a<=129784||a>=131072&&a<=196605||a>=196608&&a<=262141}t(TEt,"isWide");function g6r(a){if(!Number.isSafeInteger(a))throw new TypeError(`Expected a code point, got \`${typeof a}\`.`)}t(g6r,"validate");function xEt(a,{ambiguousAsWide:s=!1}={}){return g6r(a),SEt(a)||TEt(a)||s&&bEt(a)?2:1}t(xEt,"eastAsianWidth");var DEt=x_(CEt(),1);var y6r=new Intl.Segmenter,v6r=/^\p{Default_Ignorable_Code_Point}$/u;function Rde(a,s={}){if(typeof a!="string"||a.length===0)return 0;let{ambiguousIsNarrow:l=!0,countAnsiEscapeCodes:_=!1}=s;if(_||(a=_Le(a)),a.length===0)return 0;let h=0,b={ambiguousAsWide:!l};for(let{segment:D}of y6r.segment(a)){let A=D.codePointAt(0);if(!(A<=31||A>=127&&A<=159)&&!(A>=8203&&A<=8207||A===65279)&&!(A>=768&&A<=879||A>=6832&&A<=6911||A>=7616&&A<=7679||A>=8400&&A<=8447||A>=65056&&A<=65071)&&!(A>=55296&&A<=57343)&&!(A>=65024&&A<=65039)&&!v6r.test(D)){if((0,DEt.default)().test(D)){h+=2;continue}h+=xEt(A,b)}}return h}t(Rde,"stringWidth");var mLe=x_(wEt(),1);var{platform:PEt,cwd:b6r}=process,{red:nU,yellow:AEt,green:jde,cyan:UY,dim:pLe}=Jf,NEt=process.stdout.columns,E6r=PEt==="win32"&&!process.env.WT_SESSION?">":"\u276F",C6r=(PEt==="win32"&&!process.env.WT_SESSION,"\u2043"),D6r=b6r();function IEt(a){return a=a.replace("async file:","file:"),S6r(D6r,a.startsWith("file:")?T6r(a):a)}t(IEt,"getRelativePath");function k6r(a){return a.find(s=>s.isApp)||null}t(k6r,"mainFrame");function w6r(a,s){return a.filter(l=>(l.isApp||l.isModule)&&(!s||l.file!==s.file||l.line!==s.line))}t(w6r,"filterNativeFrames");function OEt(a){return a.callee||"anonymous"}t(OEt,"frameMethod");function FEt(a,s){let l="",_=a.length-s.length;for(let h=0;h<=_;h++)l+=" ";return l}t(FEt,"whiteSpace");function dLe(a,s,l,_,h){let b=FEt(String(l),String(s));return _?`${h}${nU(E6r)}${b}${nU(s)}${nU("|")}${b} ${nU(a)}`:`${h} ${b}${pLe(s)}${pLe("|")}${b} ${pLe(a)}`}t(dLe,"codeLine");function P6r(a,s,l){let _,h=(0,mLe.default)(Rde(s)+2,NEt);return l?_=`${s} ${nU(h(`${a.message}`).trim())}`:_=`${s} ${nU(h(`${a.name}: ${a.message}`).trim())}`,[_,s]}t(P6r,"getMessage");function A6r(a,s){let l=a.help;if(!l)return[];let _=(0,mLe.default)(Rde(s)+4,NEt);return Array.isArray(l)?l.map(h=>`${s} ${UY(_(`- ${h}`).trim())}`).concat([s]):[`${s} ${UY(l)}`,s]}t(A6r,"getHelpText");function N6r(a,s,l){if(!a)return[];let _=l?IEt(a.filePath):a.filePath;return[`${s} at ${AEt(`${OEt(a)}`)} ${jde(_)}:${jde(a.line)}`]}t(N6r,"getMainFrameLocation");function I6r(a,s){if(!a||!a.context||!a.context.line)return[];let l=a.context.start-1,_=a.context.pre.split(`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zuplo/core",
|
|
3
|
-
"version": "6.54.
|
|
3
|
+
"version": "6.54.16",
|
|
4
4
|
"repository": "https://github.com/zuplo/zuplo",
|
|
5
5
|
"author": "Zuplo, Inc.",
|
|
6
6
|
"type": "module",
|
|
@@ -41,9 +41,9 @@
|
|
|
41
41
|
"prettier": "^3.5.3"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
|
-
"@zuplo/graphql": "6.54.
|
|
45
|
-
"@zuplo/otel": "6.54.
|
|
46
|
-
"@zuplo/runtime": "6.54.
|
|
44
|
+
"@zuplo/graphql": "6.54.16",
|
|
45
|
+
"@zuplo/otel": "6.54.16",
|
|
46
|
+
"@zuplo/runtime": "6.54.16",
|
|
47
47
|
"deno": "2.3.1"
|
|
48
48
|
}
|
|
49
49
|
}
|
package/zeno.js
CHANGED
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
* DEALINGS IN THE SOFTWARE.
|
|
23
23
|
*--------------------------------------------------------------------------------------------*/
|
|
24
24
|
|
|
25
|
-
var
|
|
26
|
-
`),Le=k.encode("*"),ke=k.encode("$");function V(r){let e=[Le,k.encode(r.length.toString()),U];for(let t of r){let n=t instanceof Uint8Array?t:k.encode(t.toString());e.push(ke,k.encode(n.byteLength.toString()),U,n,U)}return W(e)}o(V,"createRequest");async function*Ne(r){let e=new Uint8Array;for await(let t of r){e=W([e,t]);let n;for(;(n=e.indexOf(U[0]))!==-1&&e[n+1]===U[1];)yield e.subarray(0,n),e=e.subarray(n+2)}}o(Ne,"readLines");function H(r,e,t=!1){return Array.fromAsync({length:e},()=>D(r,t))}o(H,"readNReplies");function R(r){return Z.decode(r.slice(1))}o(R,"parseLine");function He(r){let e=[];for(let t=0;t<r.length;t+=2)e.push(r.slice(t,t+2));return e}o(He,"chunk");async function D(r,e=!1){let{value:t}=await r.next();switch(t[0]){case he:case _e:{let n=Number(R(t));return n===-1?null:await H(r,n)}case Ae:{let n=Number(R(t))*2;return await H(r,n),D(r,e)}case Ce:return BigInt(R(t));case xe:{let{value:n}=await r.next();return Promise.reject(Z.decode(n))}case Re:return R(t)==="t";case ye:case ve:return R(t)==="-1"?null:D(r,e);case Ee:case we:switch(R(t)){case"inf":return 1/0;case"-inf":return-1/0;default:return Number(R(t))}case be:return Promise.reject(R(t));case Pe:{let n=Number(R(t))*2,i=await H(r,n);return Object.fromEntries(He(i))}case Se:return null;case Oe:return new Set(await H(r,Number(R(t)),e));case Te:return R(t);default:return e?t:Z.decode(t)}}o(D,"readReply");var $=class{static{o(this,"RedisClient")}#t;#r;#e=Promise.resolve();constructor(e){this.#t=e.writable.getWriter(),this.#r=Ne(e.readable)}#o(e){return this.#e=this.#e.then(e),this.#e}sendCommand(e,t=!1){return this.#o(()=>(this.#t.write(V(e)),D(this.#r,t)))}writeCommand(e){return this.#o(()=>this.#t.write(V(e)))}async*readReplies(e=!1){for(;;)yield D(this.#r,e)}pipelineCommands(e,t=!1){return this.#o(()=>{let n=W(e.map(V));return this.#t.write(n),H(this.#r,e.length,t)})}};var d=globalThis.Deno?.build.os==="windows"||globalThis.navigator?.platform?.startsWith("Win")||globalThis.process?.platform?.startsWith("win")||!1;function m(r){if(typeof r!="string")throw new TypeError(`Path must be a string, received "${JSON.stringify(r)}"`)}o(m,"assertPath");function y(r){return r===47}o(y,"isPosixPathSeparator");function u(r){return r===47||r===92}o(u,"isPathSeparator");function S(r){return r>=97&&r<=122||r>=65&&r<=90}o(S,"isWindowsDeviceRoot");function j(r){if(m(r),r.length===0)return"."}o(j,"assertArg");function N(r,e,t,n){let i="",c=0,l=-1,a=0,f;for(let s=0;s<=r.length;++s){if(s<r.length)f=r.charCodeAt(s);else{if(n(f))break;f=47}if(n(f)){if(!(l===s-1||a===1))if(l!==s-1&&a===2){if(i.length<2||c!==2||i.charCodeAt(i.length-1)!==46||i.charCodeAt(i.length-2)!==46){if(i.length>2){let p=i.lastIndexOf(t);p===-1?(i="",c=0):(i=i.slice(0,p),c=i.length-1-i.lastIndexOf(t)),l=s,a=0;continue}else if(i.length===2||i.length===1){i="",c=0,l=s,a=0;continue}}e&&(i.length>0?i+=`${t}..`:i="..",c=2)}else i.length>0?i+=t+r.slice(l+1,s):i=r.slice(l+1,s),c=s-l-1;l=s,a=0}else f===46&&a!==-1?++a:a=-1}return i}o(N,"normalizeString");function M(r){j(r);let e=y(r.charCodeAt(0)),t=y(r.charCodeAt(r.length-1));return r=N(r,!e,"/",y),r.length===0&&!e&&(r="."),r.length>0&&t&&(r+="/"),e?`/${r}`:r}o(M,"normalize");function K(...r){if(r.length===0)return".";r.forEach(t=>m(t));let e=r.filter(t=>t.length>0).join("/");return e===""?".":M(e)}o(K,"join");function z(r){j(r);let e=r.length,t=0,n,i=!1,c=r.charCodeAt(0);if(e>1)if(u(c))if(i=!0,u(r.charCodeAt(1))){let a=2,f=a;for(;a<e&&!u(r.charCodeAt(a));++a);if(a<e&&a!==f){let s=r.slice(f,a);for(f=a;a<e&&u(r.charCodeAt(a));++a);if(a<e&&a!==f){for(f=a;a<e&&!u(r.charCodeAt(a));++a);if(a===e)return`\\\\${s}\\${r.slice(f)}\\`;a!==f&&(n=`\\\\${s}\\${r.slice(f,a)}`,t=a)}}}else t=1;else S(c)&&r.charCodeAt(1)===58&&(n=r.slice(0,2),t=2,e>2&&u(r.charCodeAt(2))&&(i=!0,t=3));else if(u(c))return"\\";let l;return t<e?l=N(r.slice(t),!i,"\\",u):l="",l.length===0&&!i&&(l="."),l.length>0&&u(r.charCodeAt(e-1))&&(l+="\\"),n===void 0?i?l.length>0?`\\${l}`:"\\":l:i?l.length>0?`${n}\\${l}`:`${n}\\`:n+l}o(z,"normalize");function q(...r){if(r.forEach(c=>m(c)),r=r.filter(c=>c.length>0),r.length===0)return".";let e=!0,t=0,n=r[0];if(u(n.charCodeAt(0))){++t;let c=n.length;c>1&&u(n.charCodeAt(1))&&(++t,c>2&&(u(n.charCodeAt(2))?++t:e=!1))}let i=r.join("\\");if(e){for(;t<i.length&&u(i.charCodeAt(t));++t);t>=2&&(i=`\\${i.slice(t)}`)}return z(i)}o(q,"join");function _(...r){return d?q(...r):K(...r)}o(_,"join");function et(r){if(r.length>=255)throw new TypeError("Alphabet too long");let e=new Uint8Array(256);for(let s=0;s<e.length;s++)e[s]=255;for(let s=0;s<r.length;s++){let p=r.charAt(s),g=p.charCodeAt(0);if(e[g]!==255)throw new TypeError(p+" is ambiguous");e[g]=s}let t=r.length,n=r.charAt(0),i=Math.log(t)/Math.log(256),c=Math.log(256)/Math.log(t);function l(s){if(s instanceof Uint8Array||(ArrayBuffer.isView(s)?s=new Uint8Array(s.buffer,s.byteOffset,s.byteLength):Array.isArray(s)&&(s=Uint8Array.from(s))),!(s instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(s.length===0)return"";let p=0,g=0,h=0,E=s.length;for(;h!==E&&s[h]===0;)h++,p++;let b=(E-h)*c+1>>>0,C=new Uint8Array(b);for(;h!==E;){let P=s[h],x=0;for(let O=b-1;(P!==0||x<g)&&O!==-1;O--,x++)P+=256*C[O]>>>0,C[O]=P%t>>>0,P=P/t>>>0;if(P!==0)throw new Error("Non-zero carry");g=x,h++}let w=b-g;for(;w!==b&&C[w]===0;)w++;let F=n.repeat(p);for(;w<b;++w)F+=r.charAt(C[w]);return F}o(l,"encode");function a(s){if(typeof s!="string")throw new TypeError("Expected String");if(s.length===0)return new Uint8Array;let p=0,g=0,h=0;for(;s[p]===n;)g++,p++;let E=(s.length-p)*i+1>>>0,b=new Uint8Array(E);for(;p<s.length;){let P=s.charCodeAt(p);if(P>255)return;let x=e[P];if(x===255)return;let O=0;for(let G=E-1;(x!==0||O<h)&&G!==-1;G--,O++)x+=t*b[G]>>>0,b[G]=x%256>>>0,x=x/256>>>0;if(x!==0)throw new Error("Non-zero carry");h=O,p++}let C=E-h;for(;C!==E&&b[C]===0;)C++;let w=new Uint8Array(g+(E-C)),F=g;for(;C!==E;)w[F++]=b[C++];return w}o(a,"decodeUnsafe");function f(s){let p=a(s);if(p)return p;throw new Error("Non-base"+t+" character")}return o(f,"decode"),{encode:l,decodeUnsafe:a,decode:f}}o(et,"base");var oe=et;var tt="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",ne=oe(tt);import{pathToFileURL as ie}from"node:url";import se from"dotenv";var Y=class{static{o(this,"ZenoLogger")}prefix="[ZENO]:";logLevel;constructor(e="info"){this.logLevel=e}debug(...e){(this.shouldLog("debug")||Deno.env.get("ZENO_DEBUG"))&&console.debug(this.prefix,"[DEBUG]",...e)}info(...e){this.shouldLog("info")&&console.info(this.prefix,"[INFO]",...e)}warn(...e){this.shouldLog("warn")&&console.warn(this.prefix,"[WARN]",...e)}error(...e){this.shouldLog("error")&&console.error(this.prefix,"[ERROR]",...e)}shouldLog(e){let t=["debug","info","warn","error"],n=t.indexOf(this.logLevel);return t.indexOf(e)>=n}setLogLevel(e){this.logLevel=e}},A=new Y;async function ae(r){let e={};for(let[t,n]of Object.entries(Deno.env.toObject()))n!==void 0&&(e[t]=n);try{let t=_(r,".env.zuplo"),n=new TextDecoder("utf-8"),i=await Deno.readFile(ie(t)),c=n.decode(i),l=se.parse(c);for(let[a,f]of Object.entries(l))if(e[a]=f,a==="ZUPLO_SYSTEM_CONFIGURATIONS")try{let s=new TextDecoder().decode(ne.decode(f)),p=JSON.parse(s);for(let[g,h]of Object.entries(p))e[g]=String(h)}catch(s){A.error("Failed to parse ZUPLO_SYSTEM_CONFIGURATIONS from .env.zuplo:",s)}}catch(t){A.error("Error loading .env.zuplo:",t)}try{let t=_(r,".env.zuplo"),n=new TextDecoder("utf-8"),i=await Deno.readFile(ie(t)),c=n.decode(i),l=se.parse(c);for(let[a,f]of Object.entries(l))e[a]=f}catch(t){console.error("Error loading .env:",t)}for(let[t,n]of Object.entries(e))n===void 0&&delete e[t];return e}o(ae,"loadEnvironment");function le(r){return r?["true","1","yes","y"].includes(r.toLowerCase()):!1}o(le,"parseEnvBool");var Q=class{static{o(this,"CacheStorage")}#t;constructor(){this.#t=new Map}async open(e){let t=this.#t.get(e);return t||(t=new ee,this.#t.set(e,t)),t}async has(e){return this.#t.has(e)}async delete(e){throw new Error("caches.delete is not supported")}};async function rt(){let r=Deno.env.get("ZUPLO_CACHE_REDIS_HOSTNAME");if(r===void 0)throw new Error("ZUPLO_CACHE_REDIS_HOSTNAME is not set");let e=parseInt(Deno.env.get("ZUPLO_CACHE_REDIS_PORT")||"6379"),t=await Deno.connect({hostname:r,port:e});return new $(t)}o(rt,"getRedisClient");function ot(r){let e={};return r&&r.split(",").forEach(n=>{let[i,c]=n.trim().split("=");e[i.toLowerCase()]=c?c.trim():!0}),e}o(ot,"parseHeaderValue");function nt(r){let e={};for(let[t,n]of r.entries())e[t]=n;return e}o(nt,"objectifyHeaders");async function it(r){let e=await r.arrayBuffer(),t=new Uint8Array(e),n="";for(let i=0;i<t.length;i++)n+=String.fromCharCode(t[i]);return btoa(n)}o(it,"serializeResponseBody");function st(r){let e=atob(r),t=e.length,n=new Uint8Array(t);for(let i=0;i<t;i++)n[i]=e.charCodeAt(i);return n}o(st,"deserializeResponseBody");var ee=class{static{o(this,"Cache")}#t;#r;#e;constructor(e="default",t={}){this.#t=e;let n=Deno.env.get("ZUPLO_CACHE_REDIS_HOSTNAME")&&Deno.env.get("ZUPLO_CACHE_REDIS_PORT");this.#r=!n||!le(Deno.env.get("USE_ZENO_ZONE_CACHE")),this.#e=t.getRedisClient||rt}#o(e){return`${this.#t}:${e.url}`}async match(e,t){if(this.#r)return;let n=this.#o(e),i=await this.#e();await i.sendCommand(["HELLO",3]);let c=await i.sendCommand(["TTL",n]);if(c!==-2){if(c<2)return;{let l=await i.sendCommand(["HGETALL",n]),a=l.status,f=l.status,s=new Headers(JSON.parse(l.headers));return new Response(st(l.body),{status:a,statusText:f,headers:s})}}}async put(e,t){if(this.#r)return;let n=1*60*60,i=ot(t.headers.get("cache-control")),c=parseInt(i["s-maxage"]),l=parseInt(i["max-age"]),a=i["no-store"],f=i["no-cache"],s=c||l||0;if(s===0&&!a&&!f&&(s=n,t.headers.append("cache-control",`s-maxage=${n}`)),s>0){let p=this.#o(e),g=await this.#e();await g.sendCommand(["HELLO",3]),await g.sendCommand(["HSET",p,"maxage",s,"status",t.status,"statusText",t.statusText,"headers",JSON.stringify(nt(t.headers)),"body",await it(t)]),await g.sendCommand(["EXPIRE",p,s])}}async delete(e){if(this.#r)return;let t=this.#o(e);if(await(await this.#e()).sendCommand(["DEL",t])!==1)throw new Error("Failed to delete cache entry")}},at=new Q;Object.defineProperty(globalThis,"caches",{value:at,writable:!1,enumerable:!0,configurable:!1});var J=class{static{o(this,"WorkerServer")}#t;#r;#e=o(()=>({waitUntil:o(e=>{e.catch(t=>{console.error("Error in waitUntil:",t)})},"waitUntil")}),"#createContext");constructor(e){this.#r=e}async start(){let{port:e,workerModule:t,env:n}=this.#r;this.#t=Deno.serve({port:e,onListen:o(()=>{A.debug(`Server running at http://localhost:${e}`)},"onListen")},async i=>{try{return await t.default.fetch(i,n,this.#e())}catch(c){return A.error("Error handling request:",c),new Response("Internal Server Error",{status:500})}}),await this.#t.finished}async stop(){await this.#t?.shutdown()}};import{pathToFileURL as lt}from"node:url";var ce=_("dist","worker.js");function ct(){if(Deno.build.standalone)return _("..",ce);let r=Deno.cwd();return _(r,ce)}o(ct,"getDefaultWorkerPath");var ft=ct();function pt(r){return typeof r=="object"&&r!==null&&"default"in r&&typeof r.default=="object"&&"fetch"in r.default&&typeof r.default.fetch=="function"}o(pt,"isWorkerModule");async function fe(r=ft){let e;if(Deno.build.standalone?(A.debug("Loading worker module from: ",r),e=await import(r)):(A.debug("Loading dev worker module from: ",r),e=await import(lt(r).href)),!pt(e))throw new Error("Invalid worker module");return e}o(fe,"importWorkerModule");function pe(){console.log("Enabling fetch host override.");let r=globalThis.fetch,e=Deno.createHttpClient({allowHost:!0,http2:!1});return globalThis.fetch=async(t,n={})=>await r(t,{...n,client:e}),e}o(pe,"setFetchHostOverride");function ue(r){if(new.target)throw new TypeError("Cannot create an instance: parse is not a constructor");return new te(r).parse()}o(ue,"parse");var te=class{static{o(this,"JsoncParser")}#t=new Set(` \r
|
|
27
|
-
`);#r=new Set([..."[]{}:,/",...this.#t]);#e;#
|
|
28
|
-
`||this.#e[e]==="\r");e++);continue}switch(this.#e[e]){case"{":yield{type:"BeginObject",position:e};break;case"}":yield{type:"EndObject",position:e};break;case"[":yield{type:"BeginArray",position:e};break;case"]":yield{type:"EndArray",position:e};break;case":":yield{type:"NameSeparator",position:e};break;case",":yield{type:"ValueSeparator",position:e};break;case'"':{let
|
|
25
|
+
var Ue=Object.defineProperty;var n=(t,e)=>Ue(t,"name",{value:e,configurable:!0});import{scheduler as He}from"node:timers/promises";Object.defineProperty(globalThis,"scheduler",{value:He,writable:!1,enumerable:!0,configurable:!1});function q(t){let e=0;for(let s of t)e+=s.length;let r=new Uint8Array(e),o=0;for(let s of t)r.set(s,o),o+=s.length;return r}n(q,"concat");var M=new TextEncoder,se=new TextDecoder,Ie=42,Fe=124,Be=40,Ge=33,$e=35,Me=36,We=44,je=45,ze=58,Ve=37,Ke=95,Je=62,Xe=126,Ze=43,qe=61,J=M.encode(`\r
|
|
26
|
+
`),Ye=M.encode("*"),Qe=M.encode("$");function oe(t){let e=[Ye,M.encode(t.length.toString()),J];for(let r of t){let o=r instanceof Uint8Array?r:M.encode(r.toString());e.push(Qe,M.encode(o.byteLength.toString()),J,o,J)}return q(e)}n(oe,"createRequest");async function*et(t){let e=new Uint8Array;for await(let r of t){e=q([e,r]);let o;for(;(o=e.indexOf(J[0]))!==-1&&e[o+1]===J[1];)yield e.subarray(0,o),e=e.subarray(o+2)}}n(et,"readLines");function K(t,e,r=!1){return Array.fromAsync({length:e},()=>X(t,r))}n(K,"readNReplies");function k(t){return se.decode(t.slice(1))}n(k,"parseLine");function tt(t){let e=[];for(let r=0;r<t.length;r+=2)e.push(t.slice(r,r+2));return e}n(tt,"chunk");async function X(t,e=!1){let{value:r}=await t.next();switch(r[0]){case Ie:case Je:{let o=Number(k(r));return o===-1?null:await K(t,o)}case Fe:{let o=Number(k(r))*2;return await K(t,o),X(t,e)}case Be:return BigInt(k(r));case Ge:{let{value:o}=await t.next();return Promise.reject(se.decode(o))}case $e:return k(r)==="t";case Me:case qe:return k(r)==="-1"?null:X(t,e);case We:case ze:switch(k(r)){case"inf":return 1/0;case"-inf":return-1/0;default:return Number(k(r))}case je:return Promise.reject(k(r));case Ve:{let o=Number(k(r))*2,s=await K(t,o);return Object.fromEntries(tt(s))}case Ke:return null;case Xe:return new Set(await K(t,Number(k(r)),e));case Ze:return k(r);default:return e?r:se.decode(r)}}n(X,"readReply");var Y=class{static{n(this,"RedisClient")}#t;#r;#e=Promise.resolve();constructor(e){this.#t=e.writable.getWriter(),this.#r=et(e.readable)}#n(e){return this.#e=this.#e.then(e),this.#e}sendCommand(e,r=!1){return this.#n(()=>(this.#t.write(oe(e)),X(this.#r,r)))}writeCommand(e){return this.#n(()=>this.#t.write(oe(e)))}async*readReplies(e=!1){for(;;)yield X(this.#r,e)}pipelineCommands(e,r=!1){return this.#n(()=>{let o=q(e.map(oe));return this.#t.write(o),K(this.#r,e.length,r)})}};var R=globalThis.Deno?.build.os==="windows"||globalThis.navigator?.platform?.startsWith("Win")||globalThis.process?.platform?.startsWith("win")||!1;function C(t){if(typeof t!="string")throw new TypeError(`Path must be a string, received "${JSON.stringify(t)}"`)}n(C,"assertPath");function D(t){return t===47}n(D,"isPosixPathSeparator");function y(t){return t===47||t===92}n(y,"isPathSeparator");function U(t){return t>=97&&t<=122||t>=65&&t<=90}n(U,"isWindowsDeviceRoot");function ee(t){if(C(t),t.length===0)return"."}n(ee,"assertArg");function W(t,e,r,o){let s="",c=0,d=-1,l=0,u;for(let i=0;i<=t.length;++i){if(i<t.length)u=t.charCodeAt(i);else{if(o(u))break;u=47}if(o(u)){if(!(d===i-1||l===1))if(d!==i-1&&l===2){if(s.length<2||c!==2||s.charCodeAt(s.length-1)!==46||s.charCodeAt(s.length-2)!==46){if(s.length>2){let g=s.lastIndexOf(r);g===-1?(s="",c=0):(s=s.slice(0,g),c=s.length-1-s.lastIndexOf(r)),d=i,l=0;continue}else if(s.length===2||s.length===1){s="",c=0,d=i,l=0;continue}}e&&(s.length>0?s+=`${r}..`:s="..",c=2)}else s.length>0?s+=r+t.slice(d+1,i):s=t.slice(d+1,i),c=i-d-1;d=i,l=0}else u===46&&l!==-1?++l:l=-1}return s}n(W,"normalizeString");function te(t){ee(t);let e=D(t.charCodeAt(0)),r=D(t.charCodeAt(t.length-1));return t=W(t,!e,"/",D),t.length===0&&!e&&(t="."),t.length>0&&r&&(t+="/"),e?`/${t}`:t}n(te,"normalize");function ae(...t){if(t.length===0)return".";t.forEach(r=>C(r));let e=t.filter(r=>r.length>0).join("/");return e===""?".":te(e)}n(ae,"join");function re(t){ee(t);let e=t.length,r=0,o,s=!1,c=t.charCodeAt(0);if(e>1)if(y(c))if(s=!0,y(t.charCodeAt(1))){let l=2,u=l;for(;l<e&&!y(t.charCodeAt(l));++l);if(l<e&&l!==u){let i=t.slice(u,l);for(u=l;l<e&&y(t.charCodeAt(l));++l);if(l<e&&l!==u){for(u=l;l<e&&!y(t.charCodeAt(l));++l);if(l===e)return`\\\\${i}\\${t.slice(u)}\\`;l!==u&&(o=`\\\\${i}\\${t.slice(u,l)}`,r=l)}}}else r=1;else U(c)&&t.charCodeAt(1)===58&&(o=t.slice(0,2),r=2,e>2&&y(t.charCodeAt(2))&&(s=!0,r=3));else if(y(c))return"\\";let d;return r<e?d=W(t.slice(r),!s,"\\",y):d="",d.length===0&&!s&&(d="."),d.length>0&&y(t.charCodeAt(e-1))&&(d+="\\"),o===void 0?s?d.length>0?`\\${d}`:"\\":d:s?d.length>0?`${o}\\${d}`:`${o}\\`:o+d}n(re,"normalize");function le(...t){if(t.forEach(c=>C(c)),t=t.filter(c=>c.length>0),t.length===0)return".";let e=!0,r=0,o=t[0];if(y(o.charCodeAt(0))){++r;let c=o.length;c>1&&y(o.charCodeAt(1))&&(++r,c>2&&(y(o.charCodeAt(2))?++r:e=!1))}let s=t.join("\\");if(e){for(;r<s.length&&y(s.charCodeAt(r));++r);r>=2&&(s=`\\${s.slice(r)}`)}return re(s)}n(le,"join");function v(...t){return R?le(...t):ae(...t)}n(v,"join");function bt(t){if(t.length>=255)throw new TypeError("Alphabet too long");let e=new Uint8Array(256);for(let i=0;i<e.length;i++)e[i]=255;for(let i=0;i<t.length;i++){let g=t.charAt(i),p=g.charCodeAt(0);if(e[p]!==255)throw new TypeError(g+" is ambiguous");e[p]=i}let r=t.length,o=t.charAt(0),s=Math.log(r)/Math.log(256),c=Math.log(256)/Math.log(r);function d(i){if(i instanceof Uint8Array||(ArrayBuffer.isView(i)?i=new Uint8Array(i.buffer,i.byteOffset,i.byteLength):Array.isArray(i)&&(i=Uint8Array.from(i))),!(i instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(i.length===0)return"";let g=0,p=0,A=0,x=i.length;for(;A!==x&&i[A]===0;)A++,g++;let E=(x-A)*c+1>>>0,S=new Uint8Array(E);for(;A!==x;){let T=i[A],P=0;for(let N=E-1;(T!==0||P<p)&&N!==-1;N--,P++)T+=256*S[N]>>>0,S[N]=T%r>>>0,T=T/r>>>0;if(T!==0)throw new Error("Non-zero carry");p=P,A++}let _=E-p;for(;_!==E&&S[_]===0;)_++;let b=o.repeat(g);for(;_<E;++_)b+=t.charAt(S[_]);return b}n(d,"encode");function l(i){if(typeof i!="string")throw new TypeError("Expected String");if(i.length===0)return new Uint8Array;let g=0,p=0,A=0;for(;i[g]===o;)p++,g++;let x=(i.length-g)*s+1>>>0,E=new Uint8Array(x);for(;g<i.length;){let T=i.charCodeAt(g);if(T>255)return;let P=e[T];if(P===255)return;let N=0;for(let f=x-1;(P!==0||N<A)&&f!==-1;f--,N++)P+=r*E[f]>>>0,E[f]=P%256>>>0,P=P/256>>>0;if(P!==0)throw new Error("Non-zero carry");A=N,g++}let S=x-A;for(;S!==x&&E[S]===0;)S++;let _=new Uint8Array(p+(x-S)),b=p;for(;S!==x;)_[b++]=E[S++];return _}n(l,"decodeUnsafe");function u(i){let g=l(i);if(g)return g;throw new Error("Non-base"+r+" character")}return n(u,"decode"),{encode:d,decodeUnsafe:l,decode:u}}n(bt,"base");var ye=bt;var Rt="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",xe=ye(Rt);import{pathToFileURL as be}from"node:url";import Re from"dotenv";var ce=class{static{n(this,"ZenoLogger")}prefix="[ZENO]:";logLevel;constructor(e="info"){this.logLevel=e}debug(...e){(this.shouldLog("debug")||Deno.env.get("ZENO_DEBUG"))&&console.debug(this.prefix,"[DEBUG]",...e)}info(...e){this.shouldLog("info")&&console.info(this.prefix,"[INFO]",...e)}warn(...e){this.shouldLog("warn")&&console.warn(this.prefix,"[WARN]",...e)}error(...e){this.shouldLog("error")&&console.error(this.prefix,"[ERROR]",...e)}shouldLog(e){let r=["debug","info","warn","error"],o=r.indexOf(this.logLevel);return r.indexOf(e)>=o}setLogLevel(e){this.logLevel=e}},w=new ce;async function Ce(t){let e={};for(let[r,o]of Object.entries(Deno.env.toObject()))o!==void 0&&(e[r]=o);try{let r=v(t,".env.zuplo"),o=new TextDecoder("utf-8"),s=await Deno.readFile(be(r)),c=o.decode(s),d=Re.parse(c);for(let[l,u]of Object.entries(d))if(e[l]=u,l==="ZUPLO_SYSTEM_CONFIGURATIONS")try{let i=new TextDecoder().decode(xe.decode(u)),g=JSON.parse(i);for(let[p,A]of Object.entries(g))e[p]=String(A)}catch(i){Deno.build.standalone||w.error("Failed to parse ZUPLO_SYSTEM_CONFIGURATIONS from .env.zuplo:",i)}}catch(r){Deno.build.standalone||w.error("Error loading .env.zuplo:",r)}try{let r=v(t,".env"),o=new TextDecoder("utf-8"),s=await Deno.readFile(be(r)),c=o.decode(s),d=Re.parse(c);for(let[l,u]of Object.entries(d))e[l]=u}catch(r){Deno.build.standalone||w.error("Error loading .env:",r)}for(let[r,o]of Object.entries(e))o===void 0&&delete e[r];return e}n(Ce,"loadEnvironment");function Ee(t){return t?["true","1","yes","y"].includes(t.toLowerCase()):!1}n(Ee,"parseEnvBool");var fe=class{static{n(this,"CacheStorage")}#t;constructor(){this.#t=new Map}async open(e){let r=this.#t.get(e);return r||(r=new de,this.#t.set(e,r)),r}async has(e){return this.#t.has(e)}async delete(e){throw new Error("caches.delete is not supported")}};async function Ct(){let t=Deno.env.get("ZUPLO_CACHE_REDIS_HOSTNAME");if(t===void 0)throw new Error("ZUPLO_CACHE_REDIS_HOSTNAME is not set");let e=parseInt(Deno.env.get("ZUPLO_CACHE_REDIS_PORT")||"6379"),r=await Deno.connect({hostname:t,port:e});return new Y(r)}n(Ct,"getRedisClient");function Et(t){let e={};return t&&t.split(",").forEach(o=>{let[s,c]=o.trim().split("=");e[s.toLowerCase()]=c?c.trim():!0}),e}n(Et,"parseHeaderValue");function wt(t){let e={};for(let[r,o]of t.entries())e[r]=o;return e}n(wt,"objectifyHeaders");async function St(t){let e=await t.arrayBuffer(),r=new Uint8Array(e),o="";for(let s=0;s<r.length;s++)o+=String.fromCharCode(r[s]);return btoa(o)}n(St,"serializeResponseBody");function Pt(t){let e=atob(t),r=e.length,o=new Uint8Array(r);for(let s=0;s<r;s++)o[s]=e.charCodeAt(s);return o}n(Pt,"deserializeResponseBody");var de=class{static{n(this,"Cache")}#t;#r;#e;constructor(e="default",r={}){this.#t=e;let o=Deno.env.get("ZUPLO_CACHE_REDIS_HOSTNAME")&&Deno.env.get("ZUPLO_CACHE_REDIS_PORT");this.#r=!o||!Ee(Deno.env.get("USE_ZENO_ZONE_CACHE")),this.#e=r.getRedisClient||Ct}#n(e){return`${this.#t}:${e.url}`}async match(e,r){if(this.#r)return;let o=this.#n(e),s=await this.#e();await s.sendCommand(["HELLO",3]);let c=await s.sendCommand(["TTL",o]);if(c!==-2){if(c<2)return;{let d=await s.sendCommand(["HGETALL",o]),l=d.status,u=d.status,i=new Headers(JSON.parse(d.headers));return new Response(Pt(d.body),{status:l,statusText:u,headers:i})}}}async put(e,r){if(this.#r)return;let o=1*60*60,s=Et(r.headers.get("cache-control")),c=parseInt(s["s-maxage"]),d=parseInt(s["max-age"]),l=s["no-store"],u=s["no-cache"],i=c||d||0;if(i===0&&!l&&!u&&(i=o,r.headers.append("cache-control",`s-maxage=${o}`)),i>0){let g=this.#n(e),p=await this.#e();await p.sendCommand(["HELLO",3]),await p.sendCommand(["HSET",g,"maxage",i,"status",r.status,"statusText",r.statusText,"headers",JSON.stringify(wt(r.headers)),"body",await St(r)]),await p.sendCommand(["EXPIRE",g,i])}}async delete(e){if(this.#r)return;let r=this.#n(e);if(await(await this.#e()).sendCommand(["DEL",r])!==1)throw new Error("Failed to delete cache entry")}},_t=new fe;Object.defineProperty(globalThis,"caches",{value:_t,writable:!1,enumerable:!0,configurable:!1});var ne=class{static{n(this,"WorkerServer")}#t;#r;#e=n(()=>({waitUntil:n(e=>{e.catch(r=>{console.error("Error in waitUntil:",r)})},"waitUntil")}),"#createContext");constructor(e){this.#r=e}async start(){let{port:e,workerModule:r,env:o}=this.#r;this.#t=Deno.serve({port:e,onListen:n(()=>{w.debug(`Server running at http://localhost:${e}`)},"onListen")},async s=>{try{return await r.default.fetch(s,o,this.#e())}catch(c){return w.error("Error handling request:",c),new Response("Internal Server Error",{status:500})}}),await this.#t.finished}async stop(){await this.#t?.shutdown()}};import{pathToFileURL as Nt}from"node:url";var we=v("dist","worker.js");function Se(){if(Deno.build.standalone)return v("..",we);let t=Deno.cwd();return v(t,we)}n(Se,"getDefaultWorkerPath");function Ot(t){return typeof t=="object"&&t!==null&&"default"in t&&typeof t.default=="object"&&"fetch"in t.default&&typeof t.default.fetch=="function"}n(Ot,"isWorkerModule");async function ue(t){let e;if(Deno.build.standalone?(w.debug("Loading worker module from: ",t),e=await import(t)):(w.debug("Loading dev worker module from: ",t),e=await import(Nt(t).href)),!Ot(e))throw new Error("Invalid worker module");return e}n(ue,"importWorkerModule");function Pe(){console.log("Enabling fetch host override.");let t=globalThis.fetch,e=Deno.createHttpClient({allowHost:!0,http2:!1});return globalThis.fetch=async(r,o={})=>await t(r,{...o,client:e}),e}n(Pe,"setFetchHostOverride");function _e(t){if(new.target)throw new TypeError("Cannot create an instance: parse is not a constructor");return new pe(t).parse()}n(_e,"parse");var pe=class{static{n(this,"JsoncParser")}#t=new Set(` \r
|
|
27
|
+
`);#r=new Set([..."[]{}:,/",...this.#t]);#e;#n;#s;constructor(e){this.#e=`${e}`,this.#n=this.#e.length,this.#s=this.#l()}parse(){let e=this.#o(),r=this.#i(e),{done:o,value:s}=this.#s.next();if(!o)throw new SyntaxError(B(s));return r}#o(){let{done:e,value:r}=this.#s.next();if(e)throw new SyntaxError("Cannot parse JSONC: unexpected end of JSONC input");return r}*#l(){for(let e=0;e<this.#n;e++)if(!this.#t.has(this.#e[e])){if(this.#e[e]==="/"&&this.#e[e+1]==="*"){e+=2;let r=!1;for(;e<this.#n;e++)if(this.#e[e]==="*"&&this.#e[e+1]==="/"){r=!0;break}if(!r)throw new SyntaxError("Cannot parse JSONC: unexpected end of JSONC input");e++;continue}if(this.#e[e]==="/"&&this.#e[e+1]==="/"){for(e+=2;e<this.#n&&!(this.#e[e]===`
|
|
28
|
+
`||this.#e[e]==="\r");e++);continue}switch(this.#e[e]){case"{":yield{type:"BeginObject",position:e};break;case"}":yield{type:"EndObject",position:e};break;case"[":yield{type:"BeginArray",position:e};break;case"]":yield{type:"EndArray",position:e};break;case":":yield{type:"NameSeparator",position:e};break;case",":yield{type:"ValueSeparator",position:e};break;case'"':{let r=e,o=!1;for(e++;e<this.#n&&!(this.#e[e]==='"'&&!o);e++)o=this.#e[e]==="\\"&&!o;yield{type:"String",sourceText:this.#e.substring(r,e+1),position:r};break}default:{let r=e;for(;e<this.#n&&!this.#r.has(this.#e[e]);e++);e--,yield{type:"NullOrTrueOrFalseOrNumber",sourceText:this.#e.substring(r,e+1),position:r}}}}}#i(e){switch(e.type){case"BeginObject":return this.#c();case"BeginArray":return this.#f();case"NullOrTrueOrFalseOrNumber":return this.#d(e);case"String":return this.#a(e);default:throw new SyntaxError(B(e))}}#c(){let e={};for(;;){let r=this.#o();if(r.type==="EndObject")return e;if(r.type!=="String")throw new SyntaxError(B(r));let o=this.#a(r),s=this.#o();if(s.type!=="NameSeparator")throw new SyntaxError(B(s));let c=this.#o();Object.defineProperty(e,o,{value:this.#i(c),writable:!0,enumerable:!0,configurable:!0});let d=this.#o();if(d.type==="EndObject")return e;if(d.type!=="ValueSeparator")throw new SyntaxError(B(d))}}#f(){let e=[];for(;;){let r=this.#o();if(r.type==="EndArray")return e;e.push(this.#i(r));let o=this.#o();if(o.type==="EndArray")return e;if(o.type!=="ValueSeparator")throw new SyntaxError(B(o))}}#a(e){let r;try{r=JSON.parse(e.sourceText)}catch{throw new SyntaxError(B(e))}if(typeof r!="string")throw new TypeError(`Parsed value is not a string: ${r}`);return r}#d(e){if(e.sourceText==="null")return null;if(e.sourceText==="true")return!0;if(e.sourceText==="false")return!1;let r;try{r=JSON.parse(e.sourceText)}catch{throw new SyntaxError(B(e))}if(typeof r!="number")throw new TypeError(`Parsed value is not a number: ${r}`);return r}};function B({type:t,sourceText:e,position:r}){let o="";switch(t){case"BeginObject":o="{";break;case"EndObject":o="}";break;case"BeginArray":o="[";break;case"EndArray":o="]";break;case"NameSeparator":o=":";break;case"ValueSeparator":o=",";break;case"NullOrTrueOrFalseOrNumber":case"String":o=30<e.length?`${e.slice(0,30)}...`:e;break}return`Cannot parse JSONC: unexpected token "${o}" in JSONC at position ${r}`}n(B,"buildErrorMessage");var Ne="zuplo.jsonc";function Oe(t){let e=v(t,Ne),r;try{r=Deno.readTextFileSync(e)}catch(s){w.warn(s,`Failed to read ${Ne}`);return}let o=_e(r);if(o!==null){if(typeof o=="object"&&"managedDedicatedFlags"in o)return o.managedDedicatedFlags;if(typeof o=="object"&&"flags"in o&&typeof o.flags=="object"&&o.flags!==null&&"managedDedicatedFlags"in o.flags)return o.flags.managedDedicatedFlags}}n(Oe,"getManagedDedicatedSettings");var kt=/^(?:-(?:(?<doubleDash>-)(?<negated>no-)?)?)(?<key>.+?)(?:=(?<value>.+?))?$/s,Dt=/[A-Za-z]/,vt=/-?\d+(\.\d*)?(e-?\d+)?$/,Lt=/^(-|--)[^-]/,Ut=/=(?<value>.+)/,Ht=/^--[^=]+$/,It=/\W/,Ft=/\S/;function ke(t){return Ft.test(t)&&Number.isFinite(Number(t))}n(ke,"isNumber");function j(t,e,r,o=!1){e=[...e];let s=e.pop();if(e.forEach(c=>t=t[c]??={}),o){let c=t[s];if(Array.isArray(c)){c.push(r);return}r=c?[c,r]:[r]}t[s]=r}n(j,"setNested");function ge(t,e){for(let r of e){let o=t[r];if(!Object.hasOwn(t,r))return!1;t=o}return!0}n(ge,"hasNested");function De(t,e,r){let o=t.get(r);if(o===void 0)return!1;for(let s of o)if(e.has(s))return!0;return!1}n(De,"aliasIsBoolean");function ve(t){return t==="true"||t==="false"}n(ve,"isBooleanString");function me(t){return t!=="false"}n(me,"parseBooleanString");function Le(t,e){let{"--":r=!1,alias:o={},boolean:s=!1,default:c={},stopEarly:d=!1,string:l=[],collect:u=[],negatable:i=[],unknown:g=n(f=>f,"unknownFn")}=e??{},p=new Map,A=new Set,x=new Set,E=new Set,S=new Set,_=!1;if(o)for(let[f,a]of Object.entries(o)){if(a===void 0)throw new TypeError("Alias value must be defined");let m=Array.isArray(a)?a:[a];p.set(f,new Set(m)),m.forEach(H=>p.set(H,new Set([f,...m.filter($=>$!==H)])))}if(s)if(typeof s=="boolean")_=s;else{let f=Array.isArray(s)?s:[s];for(let a of f.filter(Boolean))A.add(a),p.get(a)?.forEach(m=>{A.add(m)})}if(l){let f=Array.isArray(l)?l:[l];for(let a of f.filter(Boolean))x.add(a),p.get(a)?.forEach(m=>x.add(m))}if(u){let f=Array.isArray(u)?u:[u];for(let a of f.filter(Boolean))E.add(a),p.get(a)?.forEach(m=>E.add(m))}if(i){let f=Array.isArray(i)?i:[i];for(let a of f.filter(Boolean))S.add(a),p.get(a)?.forEach(m=>S.add(m))}let b={_:[]};function T(f,a,m,H){if(!A.has(f)&&!x.has(f)&&!p.has(f)&&!(_&&Ht.test(m))&&g?.(m,f,a)===!1)return;typeof a=="string"&&!x.has(f)&&(a=ke(a)?Number(a):a);let $=H&&E.has(f);j(b,f.split("."),a,$),p.get(f)?.forEach(h=>{j(b,h.split("."),a,$)})}n(T,"setArgument");let P=[],N=t.indexOf("--");N!==-1&&(P=t.slice(N+1),t=t.slice(0,N));e:for(let f=0;f<t.length;f++){let a=t[f],m=a.match(kt)?.groups;if(m){let{doubleDash:H,negated:$}=m,h=m.key,L=m.value;if(H){if(L){A.has(h)&&(L=me(L)),T(h,L,a,!0);continue}if($){if(S.has(h)){T(h,!1,a,!1);continue}h=`no-${h}`}let O=t[f+1];if(O){if(!A.has(h)&&!_&&!O.startsWith("-")&&(!p.has(h)||!De(p,A,h))){L=O,f++,T(h,L,a,!0);continue}if(ve(O)){L=me(O),f++,T(h,L,a,!0);continue}}L=x.has(h)?"":!0,T(h,L,a,!0);continue}let he=a.slice(1,-1).split("");for(let[O,G]of he.entries()){let V=a.slice(O+2);if(V==="-"){T(G,V,a,!0);continue}if(Dt.test(G)){let Ae=Ut.exec(V)?.groups;if(Ae){T(G,Ae.value,a,!0);continue e}if(vt.test(V)){T(G,V,a,!0);continue e}}if(he[O+1]?.match(It)){T(G,a.slice(O+2),a,!0);continue e}T(G,x.has(G)?"":!0,a,!0)}if(h=a.slice(-1),h==="-")continue;let z=t[f+1];if(z){if(!Lt.test(z)&&!A.has(h)&&(!p.has(h)||!De(p,A,h))){T(h,z,a,!0),f++;continue}if(ve(z)){let O=me(z);T(h,O,a,!0),f++;continue}}T(h,x.has(h)?"":!0,a,!0);continue}if(g?.(a)!==!1&&b._.push(x.has("_")||!ke(a)?a:Number(a)),d){b._.push(...t.slice(f+1));break}}for(let[f,a]of Object.entries(c)){let m=f.split(".");ge(b,m)||(j(b,m,a),p.get(f)?.forEach(H=>j(b,H.split("."),a)))}for(let f of A.keys()){let a=f.split(".");if(!ge(b,a)){let m=E.has(f)?[]:!1;j(b,a,m)}}for(let f of x.keys()){let a=f.split(".");!ge(b,a)&&E.has(f)&&j(b,a,[])}return r?b["--"]=P:b._.push(...P),b}n(Le,"parseArgs");async function Bt(){let t;w.debug("Starting Zeno server...");let e=Le(Deno.args,{boolean:["help"],string:["port","dir"],default:{port:9e3}}),r=Number(e.port);(isNaN(r)||r<1||r>65535)&&(w.error(`Invalid port: ${e.port}. Port must be a number between 1 and 65535.`),Deno.exit(1));let o=r;try{let s=e.dir?e.dir:Deno.cwd(),c=v(s,"dist","worker.js"),d;Deno.build.standalone?d=await ue(Se()):d=await ue(c);let l=await Ce(s);Oe(s)?.allowFetchHostHeaderOverride&&(t=Pe()),await new ne({port:o,workerModule:d,env:l}).start()}catch(s){w.error("Failed to start server:",s)}finally{t&&t.close()}}n(Bt,"main");import.meta.main&&await Bt();export{Bt as main};
|