@virid/express 0.1.2 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,40 +1,36 @@
1
1
  /**
2
- * @virid/express v0.1.1
2
+ * @virid/express v0.1.3
3
3
  * Add express functionality to virid
4
4
  */
5
- var Qe=Object.defineProperty;var xt=(r,e,t)=>e in r?Qe(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var n=(r,e)=>Qe(r,"name",{value:e,configurable:!0});var y=(r,e,t)=>xt(r,typeof e!="symbol"?e+"":e,t);import{MessageWriter as zt}from"@virid/core";import{MessageRegistry as Ut,MessageWriter as Lt}from"@virid/core";import{BaseMessage as Et,MessageWriter as ee}from"@virid/core";import{MessageWriter as Mt}from"@virid/core";var Ee=class Ee{constructor(e,t,s,i,o){y(this,"id");y(this,"req");y(this,"res");y(this,"timestamp");y(this,"route");y(this,"rc",0);y(this,"isClosed",!1);this.id=e,this.req=t,this.res=s,this.timestamp=i,this.route=o}inc(){this.rc++}dec(){this.rc--,this.rc===0&&this.tryFinalize()}tryFinalize(){if(this.res.writableEnded||this.isClosed)return;this.isClosed=!0;let e=`[Virid Express] Request Orphaned: The connection was closed because all systems finished execution without sending a response.
5
+ var je=Object.defineProperty;var gt=(r,e,t)=>e in r?je(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var n=(r,e)=>je(r,"name",{value:e,configurable:!0});var y=(r,e,t)=>gt(r,typeof e!="symbol"?e+"":e,t);import{MessageWriter as Wt}from"@virid/core";import{MessageRegistry as jt,MessageWriter as Qt}from"@virid/core";import{BaseMessage as yt,MessageWriter as X}from"@virid/core";import{MessageWriter as mt}from"@virid/core";var Ee=class Ee{constructor(e,t,s,i,o){y(this,"id");y(this,"req");y(this,"res");y(this,"timestamp");y(this,"route");y(this,"rc",0);y(this,"isClosed",!1);this.id=e,this.req=t,this.res=s,this.timestamp=i,this.route=o}inc(){this.rc++}dec(){this.rc--,this.rc===0&&this.tryFinalize()}tryFinalize(){if(this.res.writableEnded||this.isClosed)return;this.isClosed=!0;let e=`[Virid Express] Request Orphaned: The connection was closed because all systems finished execution without sending a response.
6
6
  Route: ${this.route}
7
- Uptime: ${Date.now()-this.timestamp}ms`;Mt.error(new Error(e)),this.res.headersSent?this.res.end():this.res.status(500).json({error:"Internal Logic Error",message:"Request processed but no response was returned by any system."})}};n(Ee,"HttpContext");var Z=Ee,we=class we{constructor(e,t=null,s={}){y(this,"status");y(this,"data");y(this,"headers");this.status=e,this.data=t,this.headers=s}};n(we,"HttpResponse");var M=we,ve=class ve extends M{constructor(e,t={}){super(200,e,t)}};n(ve,"OkResponse");var de=ve,Se=class Se extends M{constructor(e,t={}){super(201,e,t)}};n(Se,"CreatedResponse");var ue=Se,be=class be extends M{constructor(){super(204,null)}};n(be,"NoContentResponse");var pe=be,Ae=class Ae extends M{constructor(e="Bad Request"){super(400,{error:e})}};n(Ae,"BadRequestResponse");var he=Ae,Ce=class Ce extends M{constructor(e="Unauthorized"){super(401,{error:e})}};n(Ce,"UnauthorizedResponse");var fe=Ce,Re=class Re extends M{constructor(e="Forbidden"){super(403,{error:e})}};n(Re,"ForbiddenResponse");var ge=Re,$e=class $e extends M{constructor(e="Not Found"){super(404,{error:e})}};n($e,"NotFoundResponse");var me=$e,ke=class ke extends M{constructor(e="Conflict"){super(409,{error:e})}};n(ke,"ConflictResponse");var Fe=ke,Te=class Te extends M{constructor(e){super(422,{errors:e})}};n(Te,"UnprocessableEntityResponse");var We=Te,He=class He extends M{constructor(e="Internal Server Error"){super(500,{error:e})}};n(He,"InternalServerErrorResponse");var ye=He,Oe=class Oe extends M{constructor(e,t,s={}){super(e,t,s)}};n(Oe,"CustomResponseResponse");var xe=Oe,Ve=class Ve extends M{constructor(t,s={dotfiles:"allow"}){super(206,s);y(this,"filePath");y(this,"options");this.filePath=t,this.options=s}};n(Ve,"StreamFileResponse");var L=Ve,Pe=class Pe extends M{constructor(t,s={}){super(s.status,{},s.headers);y(this,"stream");y(this,"options");this.stream=t,this.options=s}};n(Pe,"StreamResponse");var G=Pe,er=n((r,e={})=>new de(r,e),"Ok"),tr=n((r,e={})=>new ue(r,e),"Created"),rr=n(()=>new pe,"NoContent"),sr=n((r="Bad Request")=>new he(r),"BadRequest"),nr=n((r="Unauthorized")=>new fe(r),"Unauthorized"),ir=n((r="Forbidden")=>new ge(r),"Forbidden"),ar=n((r="Not Found")=>new me(r),"NotFound"),Me=n((r="Internal Server Error")=>new ye(r),"InternalServerError"),or=n((r,e,t={})=>new xe(r,e,t),"CustomResponse"),cr=n((r,e)=>new L(r,e),"StreamFile"),lr=n((r,e)=>new G(r,e),"Stream"),Ie=class Ie extends Error{constructor(t,s){super(s);y(this,"status");y(this,"message");this.status=t,this.message=s}};n(Ie,"HttpError");var R=Ie;var v=new Map;function T(r,e){if(!r){e.dec();return}(Array.isArray(r)?r:[r]).forEach(s=>{s instanceof M?wt(s,e):s instanceof R?(e.res.status(s.status).json(s.message),v.delete(e.id)):s instanceof Et?ee.write(s):ee.warn(`[Virid Express] Invalid Return Type: ${typeof s}. Expected HttpResponse or Message.`)}),e.dec()}n(T,"handleResult");function wt(r,e){let{res:t}=e;if(r.headers&&Object.entries(r.headers).forEach(([s,i])=>t.setHeader(s,i)),r.status&&t.status(r.status),r instanceof L){e.inc(),t.sendFile(r.filePath,r.options,s=>{t.headersSent||ee.error(s,`[Virid Express] SteamFile Error: Path: ${r.filePath}`),e.res.end(),v.delete(e.id),e.isClosed=!0,e.dec()});return}if(r instanceof G){let{stream:s}=r;e.inc(),s.pipe(t);let i=n(()=>{v.has(e.id)&&(e.res.end(),v.delete(e.id),e.isClosed=!0,e.dec())},"cleanup");s.on("end",i),s.on("error",o=>{t.headersSent||ee.error(o,"[Virid Express] Stream Error"),i()}),s.on("close",i);return}t.status(r.status).json(r.data),v.delete(e.id)}n(wt,"handleHttpResponse");var ze=Object.defineProperty,vt=n((r,e,t)=>e in r?ze(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,"he"),c=n((r,e)=>ze(r,"name",{value:e,configurable:!0}),"o"),l=n((r,e,t)=>vt(r,typeof e!="symbol"?e+"":e,t),"i"),H,Ye=(H=class{static send(...e){g.write(this,...e)}},n(H,"G"),H);c(Ye,"BaseMessage");var ne=Ye,O,Ke=(O=class extends ne{constructor(){super(),l(this,"__kind","SingleMessage")}},n(O,"j"),O);c(Ke,"SingleMessage");var qe=Ke,V,Xe=(V=class extends ne{constructor(){super(),l(this,"__kind","EventMessage")}},n(V,"L"),V);c(Xe,"EventMessage");var $=Xe,P,Je=(P=class extends ${constructor(e,t){super(),l(this,"error"),l(this,"context"),this.error=e,this.context=t}},n(P,"W"),P);c(Je,"ErrorMessage");var De=Je,I,Ze=(I=class extends ${constructor(e){super(),l(this,"context"),this.context=e}},n(I,"F"),I);c(Ze,"WarnMessage");var Be=Ze,D,et=(D=class extends ${constructor(e){super(),l(this,"context"),this.context=e}},n(D,"Q"),D);c(et,"InfoMessage");var Ne=et,B,tt=(B=class extends ${constructor(e,t,s){super(),l(this,"ComponentClass"),l(this,"recipe"),l(this,"label"),this.ComponentClass=e,this.recipe=t,this.label=s}},n(B,"z"),B);c(tt,"AtomicModifyMessage");var Ue=tt,te=null;function rt(r){te=r}n(rt,"ne");c(rt,"activateInstance");var St=new Proxy({},{get(r,e){return e==="dispatch"?t=>{if(!te){console.error(`[Virid] Message dispatched before system init: ${t.constructor.name}`);return}return te.dispatch(t)}:Reflect.get(te||{},e)}}),N,st=(N=class{static write(e,...t){let s=typeof e=="function"?new e(...t):e;St.dispatch(s)}static error(e,t=""){this.write(new De(e,t))}static warn(e){this.write(new Be(e))}static info(e){this.write(new Ne(e))}},n(N,"U"),N);c(st,"MessageWriter");var g=st,q,nt=(q=class{constructor(e){l(this,"dirtySignalTypes",new Set),l(this,"eventQueue",[]),l(this,"isRunning",!1),l(this,"globalTick",0),l(this,"internalDepth",0),l(this,"eventHub"),l(this,"tickPayload",{}),l(this,"beforeExecuteHooks",[]),l(this,"afterExecuteHooks",[]),l(this,"beforeTickHooks",[]),l(this,"afterTickHooks",[]),this.eventHub=e}addBeforeExecute(e,t,s){s?this.beforeExecuteHooks.unshift({type:e,handler:t}):this.beforeExecuteHooks.push({type:e,handler:t})}addAfterExecute(e,t,s){s?this.afterExecuteHooks.unshift({type:e,handler:t}):this.afterExecuteHooks.push({type:e,handler:t})}addBeforeTick(e,t){t?this.beforeTickHooks.unshift(e):this.beforeTickHooks.push(e)}addAfterTick(e,t){t?this.afterTickHooks.unshift(e):this.afterTickHooks.push(e)}markDirty(e){e instanceof $?this.eventQueue.push(e):e instanceof qe&&this.dirtySignalTypes.add(e.constructor)}tick(e){if(!(this.isRunning||this.dirtySignalTypes.size===0&&this.eventQueue.length===0)){if(this.internalDepth>100){this.internalDepth=0,this.dirtySignalTypes.clear(),this.eventQueue=[],this.eventHub.reset(),g.error(new Error("[Virid Dispatcher] Deadlock: Recursive loop detected \u{1F4A5}."));return}this.isRunning=!0,this.internalDepth++,queueMicrotask(()=>{let t,s;try{this.internalDepth==0&&(this.tickPayload={},this.executeTickHooks(this.beforeTickHooks));let i=this.prepareSnapshot();t=i.signalSnapshot,s=i.eventSnapshot;let o=this.collectTasks(s,t,e);this.executeTasks(o)}catch(i){g.error(i,"[Virid Dispatcher] Unhandled Error")}finally{t&&s&&this.clear(s,t),this.isRunning=!1,this.dirtySignalTypes.size>0||this.eventQueue.length>0?this.tick(e):(this.executeTickHooks(this.afterTickHooks),this.globalTick++,this.internalDepth=0)}})}}collectTasks(e,t,s){let i=[];for(let a of e)(s.get(a.constructor)||[]).forEach(d=>{i.push(new Le(d.fn,d.priority,a,{context:d.fn.systemContext,tick:this.globalTick,payload:{}}))});let o=new Set;for(let a of t)(s.get(a)||[]).forEach(d=>{o.has(d.fn)||(i.push(new Le(d.fn,d.priority,this.eventHub.peekSignal(a),{context:d.fn.systemContext,tick:this.globalTick,payload:{}})),o.add(d.fn))});return i}executeTasks(e){e.sort((t,s)=>s.priority-t.priority);for(let t of e)try{let s=t.execute(this.beforeExecuteHooks,this.afterExecuteHooks);s instanceof Promise&&s.catch(i=>g.error(i,`[Virid Dispatcher]: Async System Error.
7
+ Uptime: ${Date.now()-this.timestamp}ms`;mt.error(new Error(e)),this.res.headersSent?this.res.end():this.res.status(500).json({error:"Internal Logic Error",message:"Request processed but no response was returned by any system."})}};n(Ee,"HttpContext");var K=Ee,Me=class Me{constructor(e,t=null,s={}){y(this,"status");y(this,"data");y(this,"headers");this.status=e,this.data=t,this.headers=s}};n(Me,"HttpResponse");var E=Me,we=class we extends E{constructor(e,t={}){super(200,e,t)}};n(we,"OkResponse");var le=we,ve=class ve extends E{constructor(e,t={}){super(201,e,t)}};n(ve,"CreatedResponse");var de=ve,Se=class Se extends E{constructor(){super(204,null)}};n(Se,"NoContentResponse");var ue=Se,Ae=class Ae extends E{constructor(e="Bad Request"){super(400,{error:e})}};n(Ae,"BadRequestResponse");var pe=Ae,be=class be extends E{constructor(e="Unauthorized"){super(401,{error:e})}};n(be,"UnauthorizedResponse");var he=be,Re=class Re extends E{constructor(e="Forbidden"){super(403,{error:e})}};n(Re,"ForbiddenResponse");var fe=Re,ke=class ke extends E{constructor(e="Not Found"){super(404,{error:e})}};n(ke,"NotFoundResponse");var ge=ke,$e=class $e extends E{constructor(e="Conflict"){super(409,{error:e})}};n($e,"ConflictResponse");var Qe=$e,Te=class Te extends E{constructor(e){super(422,{errors:e})}};n(Te,"UnprocessableEntityResponse");var Ue=Te,Ce=class Ce extends E{constructor(e="Internal Server Error"){super(500,{error:e})}};n(Ce,"InternalServerErrorResponse");var me=Ce,He=class He extends E{constructor(e,t,s={}){super(e,t,s)}};n(He,"CustomResponseResponse");var ye=He,Oe=class Oe extends E{constructor(t,s={dotfiles:"allow"}){super(206,s);y(this,"filePath");y(this,"options");this.filePath=t,this.options=s}};n(Oe,"StreamFileResponse");var F=Oe,Ve=class Ve extends E{constructor(t,s={}){super(s.status,{},s.headers);y(this,"stream");y(this,"options");this.stream=t,this.options=s}};n(Ve,"StreamResponse");var L=Ve,Kt=n((r,e={})=>new le(r,e),"Ok"),Xt=n((r,e={})=>new de(r,e),"Created"),Jt=n(()=>new ue,"NoContent"),Zt=n((r="Bad Request")=>new pe(r),"BadRequest"),er=n((r="Unauthorized")=>new he(r),"Unauthorized"),tr=n((r="Forbidden")=>new fe(r),"Forbidden"),rr=n((r="Not Found")=>new ge(r),"NotFound"),xe=n((r="Internal Server Error")=>new me(r),"InternalServerError"),sr=n((r,e,t={})=>new ye(r,e,t),"CustomResponse"),nr=n((r,e)=>new F(r,e),"StreamFile"),ir=n((r,e)=>new L(r,e),"Stream"),Pe=class Pe extends Error{constructor(t,s){super(s);y(this,"status");y(this,"message");this.status=t,this.message=s}};n(Pe,"HttpError");var k=Pe;var v=new Map;function T(r,e){if(!r){e.dec();return}(Array.isArray(r)?r:[r]).forEach(s=>{s instanceof E?xt(s,e):s instanceof k?(e.res.status(s.status).json(s.message),v.delete(e.id)):s instanceof yt?X.write(s):X.warn(`[Virid Express] Invalid Return Type: ${typeof s}. Expected HttpResponse or Message.`)}),e.dec()}n(T,"handleResult");function xt(r,e){let{res:t}=e;if(r.headers&&Object.entries(r.headers).forEach(([s,i])=>t.setHeader(s,i)),r.status&&t.status(r.status),r instanceof F){e.inc(),t.sendFile(r.filePath,r.options,s=>{t.headersSent||X.error(s,`[Virid Express] SteamFile Error: Path: ${r.filePath}`),e.res.end(),v.delete(e.id),e.isClosed=!0,e.dec()});return}if(r instanceof L){let{stream:s}=r;e.inc(),s.pipe(t);let i=n(()=>{v.has(e.id)&&(e.res.end(),v.delete(e.id),e.isClosed=!0,e.dec())},"cleanup");s.on("end",i),s.on("error",o=>{t.headersSent||X.error(o,"[Virid Express] Stream Error"),i()}),s.on("close",i);return}t.status(r.status).json(r.data),v.delete(e.id)}n(xt,"handleHttpResponse");var Le=Object.defineProperty,Et=n((r,e,t)=>e in r?Le(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,"ce"),c=n((r,e)=>Le(r,"name",{value:e,configurable:!0}),"o"),l=n((r,e,t)=>Et(r,typeof e!="symbol"?e+"":e,t),"i"),C,Ge=(C=class{static send(...e){m.write(this,...e)}},n(C,"N"),C);c(Ge,"BaseMessage");var se=Ge,H,ze=(H=class extends se{constructor(){super(),l(this,"__kind","SingleMessage")}},n(H,"B"),H);c(ze,"SingleMessage");var Ne=ze,O,Ye=(O=class extends se{constructor(){super(),l(this,"__kind","EventMessage")}},n(O,"G"),O);c(Ye,"EventMessage");var W=Ye,V,Ke=(V=class extends W{constructor(e,t){super(),l(this,"error"),l(this,"context"),this.error=e,this.context=t}},n(V,"j"),V);c(Ke,"ErrorMessage");var Ie=Ke,P,Xe=(P=class extends W{constructor(e){super(),l(this,"context"),this.context=e}},n(P,"L"),P);c(Xe,"WarnMessage");var De=Xe,I,Je=(I=class extends W{constructor(e){super(),l(this,"context"),this.context=e}},n(I,"W"),I);c(Je,"InfoMessage");var Be=Je,J=null;function Ze(r){J=r}n(Ze,"re");c(Ze,"activateInstance");var Mt=new Proxy({},{get(r,e){return e==="dispatch"?t=>{if(!J){console.error(`[Virid] Message dispatched before system init: ${t.constructor.name}`);return}return J.dispatch(t)}:Reflect.get(J||{},e)}}),D,et=(D=class{static write(e,...t){let s=typeof e=="function"?new e(...t):e;Mt.dispatch(s)}static error(e,t=""){this.write(new Ie(e,t))}static warn(e){this.write(new De(e))}static info(e){this.write(new Be(e))}},n(D,"Q"),D);c(et,"MessageWriter");var m=et,B,tt=(B=class{constructor(e){l(this,"dirtySignalTypes",new Set),l(this,"eventQueue",[]),l(this,"isRunning",!1),l(this,"globalTick",0),l(this,"internalDepth",0),l(this,"eventHub"),l(this,"tickPayload",{}),l(this,"beforeExecuteHooks",[]),l(this,"afterExecuteHooks",[]),l(this,"beforeTickHooks",[]),l(this,"afterTickHooks",[]),this.eventHub=e}addBeforeExecute(e,t,s){s?this.beforeExecuteHooks.unshift({type:e,handler:t}):this.beforeExecuteHooks.push({type:e,handler:t})}addAfterExecute(e,t,s){s?this.afterExecuteHooks.unshift({type:e,handler:t}):this.afterExecuteHooks.push({type:e,handler:t})}addBeforeTick(e,t){t?this.beforeTickHooks.unshift(e):this.beforeTickHooks.push(e)}addAfterTick(e,t){t?this.afterTickHooks.unshift(e):this.afterTickHooks.push(e)}markDirty(e){e instanceof W?this.eventQueue.push(e):e instanceof Ne&&this.dirtySignalTypes.add(e.constructor)}tick(e){if(!(this.isRunning||this.dirtySignalTypes.size===0&&this.eventQueue.length===0)){if(this.internalDepth>100){this.internalDepth=0,this.dirtySignalTypes.clear(),this.eventQueue=[],this.eventHub.reset(),m.error(new Error("[Virid Dispatcher] Deadlock: Recursive loop detected \u{1F4A5}."));return}this.isRunning=!0,this.internalDepth++,queueMicrotask(()=>{let t,s;try{this.internalDepth==1&&(this.tickPayload={},this.executeTickHooks(this.beforeTickHooks));let i=this.prepareSnapshot();t=i.signalSnapshot,s=i.eventSnapshot;let o=this.collectTasks(s,t,e);this.executeTasks(o)}catch(i){m.error(i,"[Virid Dispatcher] Unhandled Error")}finally{t&&s&&this.clear(s,t),this.isRunning=!1,this.dirtySignalTypes.size>0||this.eventQueue.length>0?this.tick(e):(this.executeTickHooks(this.afterTickHooks),this.globalTick++,this.internalDepth=0)}})}}collectTasks(e,t,s){let i=[];for(let a of e)(s.get(a.constructor)||[]).forEach(d=>{i.push(new We(d.fn,d.priority,a,{context:d.fn.systemContext,tick:this.globalTick,payload:{}}))});let o=new Set;for(let a of t)(s.get(a)||[]).forEach(d=>{o.has(d.fn)||(i.push(new We(d.fn,d.priority,this.eventHub.peekSignal(a),{context:d.fn.systemContext,tick:this.globalTick,payload:{}})),o.add(d.fn))});return i}executeTasks(e){e.sort((t,s)=>s.priority-t.priority);for(let t of e)try{let s=t.execute(this.beforeExecuteHooks,this.afterExecuteHooks);s instanceof Promise&&s.catch(i=>m.error(i,`[Virid Dispatcher]: Async System Error.
8
8
  SystemLocation: ${t.hookContext.context.targetClass.name}.${t.hookContext.context.methodName}
9
9
  MessageName: ${t.message.constructor.name}
10
- MessageData: ${JSON.stringify(t.message)}`))}catch(s){g.error(s,`[Virid Dispatcher]: Sync System Error.
10
+ MessageData: ${JSON.stringify(t.message)}`))}catch(s){m.error(s,`[Virid Dispatcher]: Sync System Error.
11
11
  SystemLocation: ${t.hookContext.context.targetClass.name}.${t.hookContext.context.methodName}
12
12
  MessageName: ${t.message.constructor.name}
13
- MessageData: ${JSON.stringify(t.message)}`)}}prepareSnapshot(){this.eventHub.flip();let e=new Set(this.dirtySignalTypes),t=[...this.eventQueue];return this.dirtySignalTypes.clear(),this.eventQueue=[],{signalSnapshot:e,eventSnapshot:t}}clear(e,t){let s=new Set(t);e.forEach(i=>s.add(i.constructor)),this.eventHub.clearSignals(s),this.eventHub.clearEvents()}executeTickHooks(e){let t={tick:this.globalTick,timestamp:Date.now(),payload:this.tickPayload};e.forEach(s=>s(t))}},n(q,"J"),q);c(nt,"Dispatcher");var bt=nt,_,it=(_=class{constructor(e,t,s,i){l(this,"fn"),l(this,"priority"),l(this,"message"),l(this,"hookContext"),this.fn=e,this.priority=t,this.message=s,this.hookContext=i}triggerHooks(e){let t=Array.isArray(this.message)?this.message[0]:this.message;if(t){for(let s of e)if(t instanceof s.type)try{let i=s.handler(this.message,this.hookContext);i instanceof Promise&&i.catch(o=>{g.error(o,`[Virid Hook] Async Hook Error:
13
+ MessageData: ${JSON.stringify(t.message)}`)}}prepareSnapshot(){this.eventHub.flip();let e=new Set(this.dirtySignalTypes),t=[...this.eventQueue];return this.dirtySignalTypes.clear(),this.eventQueue=[],{signalSnapshot:e,eventSnapshot:t}}clear(e,t){let s=new Set(t);e.forEach(i=>s.add(i.constructor)),this.eventHub.clearSignals(s),this.eventHub.clearEvents()}executeTickHooks(e){let t={tick:this.globalTick,timestamp:Date.now(),payload:this.tickPayload};e.forEach(s=>s(t))}},n(B,"z"),B);c(tt,"Dispatcher");var wt=tt,N,rt=(N=class{constructor(e,t,s,i){l(this,"fn"),l(this,"priority"),l(this,"message"),l(this,"hookContext"),this.fn=e,this.priority=t,this.message=s,this.hookContext=i}triggerHooks(e){let t=Array.isArray(this.message)?this.message[0]:this.message;if(t){for(let s of e)if(t instanceof s.type)try{let i=s.handler(this.message,this.hookContext);i instanceof Promise&&i.catch(o=>{m.error(o,`[Virid Hook] Async Hook Error:
14
14
  It is prohibited to use asynchronous hooks within Hook:
15
- ${s.type.name}`)})}catch(i){g.error(i,`[Virid Hook] Hook Execute Failed:
15
+ ${s.type.name}`)})}catch(i){m.error(i,`[Virid Hook] Hook Execute Failed:
16
16
  Triggered by: ${t.constructor.name}
17
- Registered type: ${s.type.name}`)}}}execute(e,t){this.triggerHooks(e);let s=c(()=>this.triggerHooks(t),"runAfter");try{let i=this.fn(this.message);return i instanceof Promise?i.finally(()=>s()):(s(),i)}catch(i){throw s(),i}}},n(_,"Y"),_);c(it,"ExecutionTask");var Le=it,j,at=(j=class{constructor(){l(this,"signalActive",new Map),l(this,"signalStaging",new Map),l(this,"eventActive",[]),l(this,"eventStaging",[])}push(e){if(e instanceof qe){let t=e.constructor;this.signalStaging.has(t)||this.signalStaging.set(t,[]),this.signalStaging.get(t).push(e)}else e instanceof $?this.eventStaging.push(e):g.error(new Error(`[Virid Message] Invalid Message:
18
- ${e.constructor.name} must extend SingleMessage or EventMessage`))}flip(){this.signalActive=this.signalStaging,this.signalStaging=new Map,this.eventActive=this.eventStaging,this.eventStaging=[]}peekSignal(e){return this.signalActive.get(e)||[]}getEventStream(){return this.eventActive}peekEventAt(e){return this.eventActive[e]}clearSignals(e){e.forEach(t=>this.signalActive.delete(t))}clearEvents(){this.eventActive=[]}reset(){this.signalActive.clear(),this.signalStaging.clear(),this.eventActive=[],this.eventStaging=[]}},n(j,"q"),j);c(at,"EventHub");var At=at,Q,ot=(Q=class{constructor(){l(this,"systemTaskMap",new Map)}register(e,t,s=0){let i=this.systemTaskMap.get(e)||[];if(i.findIndex(o=>o.fn===t)===-1)i.push({fn:t,priority:s}),i.sort((o,a)=>a.priority-o.priority),this.systemTaskMap.set(e,i);else{let o=t.name||"Anonymous";return g.error(new Error(`[Virid Error] System Already Registered:
17
+ Registered type: ${s.type.name}`)}}}execute(e,t){this.triggerHooks(e);let s=c(()=>this.triggerHooks(t),"runAfter");try{let i=this.fn(this.message);return i instanceof Promise?i.finally(()=>s()):(s(),i)}catch(i){throw s(),i}}},n(N,"F"),N);c(rt,"ExecutionTask");var We=rt,q,st=(q=class{constructor(){l(this,"signalActive",new Map),l(this,"signalStaging",new Map),l(this,"eventActive",[]),l(this,"eventStaging",[])}push(e){if(e instanceof Ne){let t=e.constructor;this.signalStaging.has(t)||this.signalStaging.set(t,[]),this.signalStaging.get(t).push(e)}else e instanceof W?this.eventStaging.push(e):m.error(new Error(`[Virid Message] Invalid Message:
18
+ ${e.constructor.name} must extend SingleMessage or EventMessage`))}flip(){this.signalActive=this.signalStaging,this.signalStaging=new Map,this.eventActive=this.eventStaging,this.eventStaging=[]}peekSignal(e){return this.signalActive.get(e)||[]}getEventStream(){return this.eventActive}peekEventAt(e){return this.eventActive[e]}clearSignals(e){e.forEach(t=>this.signalActive.delete(t))}clearEvents(){this.eventActive=[]}reset(){this.signalActive.clear(),this.signalStaging.clear(),this.eventActive=[],this.eventStaging=[]}},n(q,"U"),q);c(st,"EventHub");var vt=st,_,nt=(_=class{constructor(){l(this,"systemTaskMap",new Map)}register(e,t,s=0){let i=this.systemTaskMap.get(e)||[];if(i.findIndex(o=>o.fn===t)===-1)i.push({fn:t,priority:s}),i.sort((o,a)=>a.priority-o.priority),this.systemTaskMap.set(e,i);else{let o=t.name||"Anonymous";return m.error(new Error(`[Virid Error] System Already Registered:
19
19
  Class ${e.name}
20
- Function ${o}`)),()=>{}}return()=>{let o=this.systemTaskMap.get(e);if(o){let a=o.findIndex(d=>d.fn===t);a!==-1&&(o.splice(a,1),o.length===0&&this.systemTaskMap.delete(e))}}}},n(Q,"K"),Q);c(ot,"MessageRegistry");var Ct=ot,F,ct=(F=class{constructor(){l(this,"eventHub",new At),l(this,"dispatcher",new bt(this.eventHub)),l(this,"registry",new Ct),l(this,"middlewares",[]),rt(this)}useMiddleware(e,t){this.middlewares.push(e)}onBeforeExecute(e,t,s){this.dispatcher.addBeforeExecute(e,t,s)}onAfterExecute(e,t,s){this.dispatcher.addAfterExecute(e,t,s)}onBeforeTick(e,t){this.dispatcher.addBeforeTick(e,t)}onAfterTick(e,t){this.dispatcher.addAfterTick(e,t)}dispatch(e){if(!(e instanceof ne)){g.error(new Error(`[Virid Dispatch] Type Error: Message must be an instance of BaseMessage,message:${e}`));return}this.pipeline(e,()=>{if(!this.registry.systemTaskMap.has(e.constructor)){g.error(new Error(`[Virid Dispatch] No handler for message: ${e.constructor.name}`));return}this.eventHub.push(e),this.dispatcher.markDirty(e),this.dispatcher.tick(this.registry.systemTaskMap)})}pipeline(e,t){let s=0,i=c(()=>{s<this.middlewares.length?this.middlewares[s++](e,i):t()},"next");i()}register(e,t,s=0){return this.registry.register(e,t,s)}},n(F,"X"),F);c(ct,"MessageInternal");var Rt=ct,W,lt=(W=class{constructor(){l(this,"bindings",new Map),l(this,"singletonInstances",new Map)}bind(e){let t={type:"transient",ctor:e};return this.bindings.set(e,t),{toSelf:c(()=>({inSingletonScope:c(()=>(t.type="singleton",{onActivation:c(s=>{},"onActivation")}),"inSingletonScope")}),"toSelf")}}get(e,t){let s=this.bindings.get(e);if(!s)throw new Error(`[Virid Container] Unbound Constructor: No binding found for ${e.name}`);let i=s.ctor;if(s.type==="singleton"){if(!this.singletonInstances.has(e)){let a=new i,d=t(a);this.singletonInstances.set(e,d)}return this.singletonInstances.get(e)}let o=new i;return t(o)}},n(W,"Z"),W);c(lt,"ViridContainer");var $t=lt,p={reset:"\x1B[0m",red:"\x1B[31m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",gray:"\x1B[90m",bold:"\x1B[1m",green:"\x1B[32m"};function z(r,e,t){let s={params:r,targetClass:Object,methodName:t,originalMethod:e};return e.ccsContext=s,e}n(z,"N");c(z,"withContext");var kt=c(r=>{let e=`${p.green}${p.bold} \u2714 [Virid Info] ${p.reset}`,t=`${p.magenta}${r.context}${p.reset}`;console.log(`${e}${p.gray}Global Info Caught:${p.reset}
21
- ${p.green}Details:${p.reset}`,r.context||"unknown Info")},"globalInfoHandler"),Tt=c(r=>{let e=`${p.red}${p.bold} \u2716 [Virid Error] ${p.reset}`,t=`${p.magenta}${r.context}${p.reset}`;console.error(`${e}${p.gray}Global Error Caught:${p.reset}
20
+ Function ${o}`)),()=>{}}return()=>{let o=this.systemTaskMap.get(e);if(o){let a=o.findIndex(d=>d.fn===t);a!==-1&&(o.splice(a,1),o.length===0&&this.systemTaskMap.delete(e))}}}},n(_,"J"),_);c(nt,"MessageRegistry");var St=nt,j,it=(j=class{constructor(){l(this,"eventHub",new vt),l(this,"dispatcher",new wt(this.eventHub)),l(this,"registry",new St),l(this,"middlewares",[]),Ze(this)}useMiddleware(e,t){this.middlewares.push(e)}onBeforeExecute(e,t,s){this.dispatcher.addBeforeExecute(e,t,s)}onAfterExecute(e,t,s){this.dispatcher.addAfterExecute(e,t,s)}onBeforeTick(e,t){this.dispatcher.addBeforeTick(e,t)}onAfterTick(e,t){this.dispatcher.addAfterTick(e,t)}dispatch(e){if(!(e instanceof se)){m.error(new Error(`[Virid Dispatch] Type Error: Message must be an instance of BaseMessage,message:${e}`));return}this.pipeline(e,()=>{if(!this.registry.systemTaskMap.has(e.constructor)){m.error(new Error(`[Virid Dispatch] No handler for message: ${e.constructor.name}`));return}this.eventHub.push(e),this.dispatcher.markDirty(e),this.dispatcher.tick(this.registry.systemTaskMap)})}pipeline(e,t){let s=0,i=c(()=>{s<this.middlewares.length?this.middlewares[s++](e,i):t()},"next");i()}register(e,t,s=0){return this.registry.register(e,t,s)}},n(j,"Y"),j);c(it,"MessageInternal");var At=it,Q,at=(Q=class{constructor(){l(this,"bindings",new Map),l(this,"singletonInstances",new Map)}bind(e){let t={type:"transient",ctor:e};return this.bindings.set(e,t),{toSelf:c(()=>({inSingletonScope:c(()=>(t.type="singleton",{onActivation:c(s=>{},"onActivation")}),"inSingletonScope")}),"toSelf")}}get(e,t){let s=this.bindings.get(e);if(!s)throw new Error(`[Virid Container] Unbound Constructor: No binding found for ${e.name}`);let i=s.ctor;if(s.type==="singleton"){if(!this.singletonInstances.has(e)){let a=new i,d=t(a);this.singletonInstances.set(e,d)}return this.singletonInstances.get(e)}let o=new i;return t(o)}},n(Q,"q"),Q);c(at,"ViridContainer");var bt=at,p={reset:"\x1B[0m",red:"\x1B[31m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",gray:"\x1B[90m",bold:"\x1B[1m",green:"\x1B[32m"};function Z(r,e,t){let s={params:r,targetClass:Object,methodName:t,originalMethod:e};return e.ccsContext=s,e}n(Z,"K");c(Z,"withContext");var Rt=c(r=>{let e=`${p.green}${p.bold} \u2714 [Virid Info] ${p.reset}`,t=`${p.magenta}${r.context}${p.reset}`;console.log(`${e}${p.gray}Global Info Caught:${p.reset}
21
+ ${p.green}Details:${p.reset}`,r.context||"unknown Info")},"globalInfoHandler"),kt=c(r=>{let e=`${p.red}${p.bold} \u2716 [Virid Error] ${p.reset}`,t=`${p.magenta}${r.context}${p.reset}`;console.error(`${e}${p.gray}Global Error Caught:${p.reset}
22
22
  ${p.red}Context:${p.reset} ${t}
23
- ${p.red}Details:${p.reset}`,r.error||r||"unknown Error")},"globalErrorHandler"),Ht=c(r=>{let e=`${p.yellow}${p.bold} \u26A0 [Virid Warn] ${p.reset}`,t=`${p.cyan}${r.context}${p.reset}`;console.warn(`${e}${p.gray}Global Warn Caught:${p.reset}
24
- ${p.yellow}Context:${p.reset} ${t}`)},"globalWarnHandler"),Ot=c(r=>{let e=Y.get(r.ComponentClass);if(!e){console.error(`[Virid Modify] Component Not Found:
25
- Component ${r.ComponentClass.name} not found in Registry.`);return}try{r.recipe(e),g.warn(`[Virid Modify] Successfully:
26
- Modify on ${r.ComponentClass.name}
27
- label: ${r.label}`)}catch(t){g.error(t,`[Virid Error] Modify Failed:
28
- ${r.label}`)}},"atomicModifyHandler");function dt(r){r.register(Ue,z(Ue,Ot,"GlobalAtomicModifier"),1e3),r.register(Be,z(Be,Ht,"GlobalWarnHandler"),-999),r.register(De,z(De,Tt,"GlobalErrorHandler"),-999),r.register(Ne,z(Ne,kt,"GlobalInfoHandler"),-999),Y=r}n(dt,"oe");c(dt,"initializeGlobalSystems");var Y=null,mr=new Proxy({},{get(r,e){return(...t)=>{if(!Y){console.warn(`[Virid Vue] App method "${String(e)}" called before initialization.`);return}let s=Y[e];if(typeof s=="function")return s.apply(Y,t)}}}),Ge=new Set,U,ut=(U=class{constructor(){l(this,"container",new $t),l(this,"messageInternal",new Rt),l(this,"activationHooks",[])}addActivationHook(e){this.activationHooks.push(e)}get(e){return e.length>0&&g.error(new Error(`[Virid Container] Violation: Component "${e.name}" should not have constructor arguments. Dependency Injection is only allowed in Systems.`)),this.container.get(e,t=>this.handleActivation(t))}handleActivation(e){return e&&this.activationHooks.reduce((t,s)=>{try{let i=s(t);return i===void 0&&g.warn(`[Virid Container] Hook Does Bot Return A Value: Hook "${s.name}" should return a instance to continue.`),i!==void 0?i:t}catch(i){return g.error(i,"[Virid Container] Activation Hook Failed"),t}},e)}bindController(e){return this.container.bind(e).toSelf(),{inSingletonScope:c(()=>({onActivation:c(()=>{},"onActivation")}),"inSingletonScope")}}bindComponent(e){return this.container.bind(e).toSelf().inSingletonScope(),{onActivation:c(()=>{},"onActivation")}}useMiddleware(e,t=!1){this.messageInternal.useMiddleware(e,t)}onBeforeExecute(e,t,s=!1){this.messageInternal.onBeforeExecute(e,t,s)}onAfterExecute(e,t,s=!1){this.messageInternal.onAfterExecute(e,t,s)}onBeforeTick(e,t=!1){this.messageInternal.onBeforeTick(e,t)}onAfterTick(e,t=!1){this.messageInternal.onAfterTick(e,t)}register(e,t,s=0){return this.messageInternal.register(e,t,s)}use(e,t){if(Ge.has(e.name))return g.warn(`[Virid Plugin] Duplicate Installation: Plugin ${e.name} has already been installed.`),this;try{e.install(this,t),Ge.add(e.name)}catch(s){g.error(s,`[Virid Plugin]: Install Failed: ${e.name}`)}return this}},n(U,"te"),U);c(ut,"ViridApp");var Vt=ut,K=new Vt;K.addActivationHook(se);dt(K);var b={SYSTEM:"virid:core:system",MESSAGE:"virid:core:message",CONTROLLER:"virid:core:controller",COMPONENT:"virid:core:component",SAFE:"virid:core:safe",OBSERVER:"virid:core:observer"},re=c(r=>{r&&(Array.isArray(r)?r:[r]).forEach(e=>{e instanceof ne?g.write(e):g.warn("[Virid HandleResult] Invalid Return Type: Must return Message or Message[].")})},"handleResult");function Pt(r={priority:0,messageClass:null}){return(e,t,s)=>{let i=s.value,o=Reflect.getMetadata("design:paramtypes",e,t),a=Reflect.getMetadata(b.MESSAGE,e,t)||null;if(!o){let f=new Error(`[Virid System] System Parameter Loss:
29
- Unable to recognize system parameters, please confirm if import "reflection-metadata" was introduced at the beginning!`);g.error(f);return}if(o.some(f=>f===void 0)){let f=new Error(`[Virid System] Parameter Metadata Loss in "${t}":
23
+ ${p.red}Details:${p.reset}`,r.error||r||"unknown Error")},"globalErrorHandler"),$t=c(r=>{let e=`${p.yellow}${p.bold} \u26A0 [Virid Warn] ${p.reset}`,t=`${p.cyan}${r.context}${p.reset}`;console.warn(`${e}${p.gray}Global Warn Caught:${p.reset}
24
+ ${p.yellow}Context:${p.reset} ${t}`)},"globalWarnHandler");function ot(r){r.register(De,Z(De,$t,"GlobalWarnHandler"),-999),r.register(Ie,Z(Ie,kt,"GlobalErrorHandler"),-999),r.register(Be,Z(Be,Rt,"GlobalInfoHandler"),-999),ee=r}n(ot,"se");c(ot,"initializeGlobalSystems");var ee=null,pr=new Proxy({},{get(r,e){return(...t)=>{if(!ee){console.warn(`[Virid Vue] App method "${String(e)}" called before initialization.`);return}let s=ee[e];if(typeof s=="function")return s.apply(ee,t)}}}),Fe=new Set,U,ct=(U=class{constructor(){l(this,"container",new bt),l(this,"messageInternal",new At),l(this,"activationHooks",[])}addActivationHook(e){this.activationHooks.push(e)}get(e){return e.length>0&&m.error(new Error(`[Virid Container] Violation: Component "${e.name}" should not have constructor arguments. Dependency Injection is only allowed in Systems.`)),this.container.get(e,t=>this.handleActivation(t))}handleActivation(e){return e&&this.activationHooks.reduce((t,s)=>{try{let i=s(t);return i===void 0&&m.warn(`[Virid Container] Hook Does Bot Return A Value: Hook "${s.name}" should return a instance to continue.`),i!==void 0?i:t}catch(i){return m.error(i,"[Virid Container] Activation Hook Failed"),t}},e)}bindController(e){return this.container.bind(e).toSelf(),{inSingletonScope:c(()=>({onActivation:c(()=>{},"onActivation")}),"inSingletonScope")}}bindComponent(e){return this.container.bind(e).toSelf().inSingletonScope(),{onActivation:c(()=>{},"onActivation")}}useMiddleware(e,t=!1){this.messageInternal.useMiddleware(e,t)}onBeforeExecute(e,t,s=!1){this.messageInternal.onBeforeExecute(e,t,s)}onAfterExecute(e,t,s=!1){this.messageInternal.onAfterExecute(e,t,s)}onBeforeTick(e,t=!1){this.messageInternal.onBeforeTick(e,t)}onAfterTick(e,t=!1){this.messageInternal.onAfterTick(e,t)}register(e,t,s=0){return this.messageInternal.register(e,t,s)}use(e,t){if(Fe.has(e.name))return m.warn(`[Virid Plugin] Duplicate Installation: Plugin ${e.name} has already been installed.`),this;try{e.install(this,t),Fe.add(e.name)}catch(s){m.error(s,`[Virid Plugin]: Install Failed: ${e.name}`)}return this}},n(U,"Z"),U);c(ct,"ViridApp");var Tt=ct,G=new Tt;G.addActivationHook(re);ot(G);var A={SYSTEM:"virid:core:system",MESSAGE:"virid:core:message",CONTROLLER:"virid:core:controller",COMPONENT:"virid:core:component",SAFE:"virid:core:safe",OBSERVER:"virid:core:observer"},te=c(r=>{r&&(Array.isArray(r)?r:[r]).forEach(e=>{e instanceof se?m.write(e):m.warn("[Virid HandleResult] Invalid Return Type: Must return Message or Message[].")})},"handleResult");function Ct(r={priority:0,messageClass:null}){return(e,t,s)=>{let i=s.value,o=Reflect.getMetadata("design:paramtypes",e,t),a=Reflect.getMetadata(A.MESSAGE,e,t)||null;if(!o){let f=new Error(`[Virid System] System Parameter Loss:
25
+ Unable to recognize system parameters, please confirm if import "reflection-metadata" was introduced at the beginning!`);m.error(f);return}if(o.some(f=>f===void 0)){let f=new Error(`[Virid System] Parameter Metadata Loss in "${t}":
30
26
  One or more parameters have 'undefined' types.
31
27
  This usually happens when you forget to add a type annotation to a decorated parameter.
32
- Check parameter at index: ${o.indexOf(void 0)}`);g.error(f);return}if(r.messageClass&&a){g.error(new Error(`[Virid System] Multiple Messages Are Not Allowed: Cannot use @ message() and SystemParams simultaneously in ${t}`));return}if(!r.messageClass&&!a){g.error(new Error(`[Virid System] System Parameter Loss:
33
- Please declare the message type using the Message decorator`));return}let d=c(f=>{let E=o.map((x,A)=>{if(a&&a.index==A){let{messageClass:k,single:le}=a,J=Array.isArray(f)?f[0]:f;if(!(J instanceof k)){let yt=J.constructor.name;throw new Error(`[Virid System] Type Mismatch: Expected ${k.name}, but received ${yt}`)}if(J instanceof qe)return le?Array.isArray(f)?f[f.length-1]:f:Array.isArray(f)?f:[f];if(J instanceof $)return f;throw new Error(`[Virid System] unknown Message Types: Message ${k.name} is not a subclass of SingleMessage or EventMessage!`)}let C=K.get(x);if(!C)throw new Error(`[Virid System] unknown Inject Data Types: ${x.name} is not registered in the container!`);return C}),w=i.apply(e,E);return w instanceof Promise?w.then(re):re(w)},"wrappedSystem"),h={params:o,targetClass:e,methodName:t,originalMethod:i};d.systemContext=h,s.value=d;let u=r.messageClass||a.messageClass;K.register(u,d,r.priority)}}n(Pt,"lt");c(Pt,"System");function It(r,e=!0){return(t,s,i)=>{if(Reflect.hasOwnMetadata(b.MESSAGE,t,s)){g.error(new Error(`[Virid Message] Multiple Messages Are Not Allowed: ${s} has multiple @Message() decorators!`));return}let o={index:i,messageClass:r,single:e};Reflect.defineMetadata(b.MESSAGE,o,t,s)}}n(It,"ht");c(It,"Message");function Dt(){return(r,e,t)=>{let s=Reflect.getMetadata(b.SAFE,r)||new Set;s.add(e),Reflect.defineMetadata(b.SAFE,s,r)}}n(Dt,"ut");c(Dt,"Safe");function Bt(r,[]){return(e,t)=>{let s=Reflect.getMetadata(b.OBSERVER,e)||[];s.push({key:t,callback:r}),Reflect.defineMetadata(b.OBSERVER,s,e)}}n(Bt,"dt");c(Bt,"Observer");function Nt(){return r=>{Reflect.defineMetadata(b.CONTROLLER,!0,r)}}n(Nt,"ft");c(Nt,"Controller");function qt(){return r=>{Reflect.defineMetadata(b.COMPONENT,!0,r)}}n(qt,"pt");c(qt,"Component");var _t=["push","pop","shift","unshift","splice","sort","reverse"];function se(r){return!r||typeof r!="object"||Object.prototype.hasOwnProperty.call(r,"__virid_observer_processed__")||(Object.defineProperty(r,"__virid_observer_processed__",{value:!0,enumerable:!1,configurable:!0}),(Reflect.getMetadata(b.OBSERVER,r.constructor)||[]).forEach(({propertyKey:e,callback:t})=>{let s={value:r[e]},i=new Proxy(s,{get(a,d){let h=a.value;return Array.isArray(h)&&_t.includes(d)?(...u)=>{let f=[...h],E=h[d].apply(h,u),w=t.call(r,f,h);return re(w),E}:h},set(a,d,h){let u=a.value;if(h===u)return!0;a.value=h;let f=t.call(r,u,h);return re(f),!0}}),o=c(()=>i.value,"getter");o.__virid_box__=s,Object.defineProperty(r,e,{get:o,set:c(a=>{i.value=a},"set"),enumerable:!0,configurable:!0}),s.value&&typeof s.value=="object"&&se(s.value)}),Reflect.ownKeys(r).forEach(e=>{if(e==="__virid_observer_processed__")return;let t=Object.getOwnPropertyDescriptor(r,e);if(t&&t.get)return;let s=r[e];s&&typeof s=="object"&&se(s)})),r}n(se,"_");c(se,"bindObservers");function jt(){return K}n(jt,"Ct");c(jt,"createVirid");function Qt(r){let e=parseInt(r,10);if(isNaN(e))throw new R(400,`Validation failed: "${r}" is not a number.`);return e}n(Qt,"ParseIntPipe");function Ft(r){return r==="true"||r==="1"?!0:r==="false"||r==="0"?!1:!!r}n(Ft,"ParseBoolPipe");var X=new Map;X.set(Number,Qt);X.set(Boolean,Ft);function wr(r,e){if(X.has(r)){g.error(new Error(`[Virid Express Pipe] Repeated Pipe: Auto pipe for ${r} has already been registered.`));return}X.set(r,e)}n(wr,"addAutoPipe");function _e(r){return X.get(r)}n(_e,"getAutoPipe");function pt(r){let e={};if(!r)return e;let t=r.split(";");for(let s of t){let i=s.indexOf("=");if(i===-1)continue;let o=s.substring(0,i).trim();if(!o)continue;let a=s.substring(i+1).trim();a[0]==='"'&&a[a.length-1]==='"'&&(a=a.slice(1,-1));try{e[o]=a.includes("%")?decodeURIComponent(a):a}catch{e[o]=a}}return e}n(pt,"parseRawCookie");import{EventMessage as Wt}from"@virid/core";var je=class je extends Wt{constructor(t){super();y(this,"__virid_express_id");this.__virid_express_id=t,v.get(this.__virid_express_id).inc()}get requestId(){return this.__virid_express_id}};n(je,"HttpRequestMessage");var ie=je;var ae=new Ut,oe=new Map,Gt=0;function ht(r){for(let[e,t]of ae.systemTaskMap.entries())for(let s of t)r.register(e,s.fn,s.priority);ae.systemTaskMap.clear()}n(ht,"registerHttpSystem");function ft(r){for(let[e,t]of oe.entries()){let{method:s,path:i,httpMessage:o}=t,a=s.toLowerCase();r[a](i,(d,h)=>{let u=Gt++>>>0;v.set(u,new Z(u,d,h,Date.now(),i));let f=new o(u);h.once("finish",()=>v.delete(u)),h.once("close",()=>v.delete(u)),Lt.write(f)})}}n(ft,"registerHttpRoute");var ce=null;function gt(r,e){ce=r,ht(r),ft(e.server)}n(gt,"activateApp");var mt=new Proxy({},{get(r,e){return(...t)=>{if(!ce)return zt.warn(`[Virid Vue] App method "${String(e)}" called before initialization.`),null;let s=ce[e];if(typeof s=="function")return s.apply(ce,t)}}});import{MessageWriter as S}from"@virid/core";import{VIRID_METADATA as Yt}from"@virid/core";var m={...Yt,HTTPROUTE:"virid:express:route",HTTPSYSTEM:"virid:express:system",BODY:"virid:express:body",QUERY:"virid:express:query",HEADERS:"virid:express:header",REQUEST:"virid:express:request",RESPONSE:"virid:express:response",CONTEXT:"virid:express:context",PARAMS:"virid:express:params",COOKIES:"virid:express:cookie"};function Kr(r){return e=>{let t=`${r.method}:${r.path}`;oe.has(t)&&S.error(new Error(`[Virid Http] Routing Conflict: The request method ${r.method} for path ${r.path} has already been registered by ${e.name}`));let s=[];r.path.split("/").forEach(a=>{a.startsWith(":")&&s.push(a.substring(1))});let o={...r,httpMessage:e,params:s};oe.set(t,o)}}n(Kr,"HttpRoute");function Xr(r={priority:0,messageClass:null}){return(e,t,s)=>{let i=s.value,o=Reflect.getMetadata("design:paramtypes",e,t),a=Reflect.getMetadata(m.MESSAGE,e,t)||null,d=Kt(e,t,o);if(!o){let E=new Error(`[Virid HttpSystem] System Parameter Loss:
34
- Unable to recognize system parameters, please confirm if import "reflection-metadata" was introduced at the beginning!`);S.error(E);return}if(o.some(E=>E===void 0)){let E=new Error(`[Virid HttpSystem] Parameter Metadata Loss in "${t}":
28
+ Check parameter at index: ${o.indexOf(void 0)}`);m.error(f);return}if(r.messageClass&&a){m.error(new Error(`[Virid System] Multiple Messages Are Not Allowed: Cannot use @ message() and SystemParams simultaneously in ${t}`));return}if(!r.messageClass&&!a){m.error(new Error(`[Virid System] System Parameter Loss:
29
+ Please declare the message type using the Message decorator`));return}let d=c(f=>{let M=o.map((x,b)=>{if(a&&a.index==b){let{messageClass:$,single:ce}=a,Y=Array.isArray(f)?f[0]:f;if(!(Y instanceof $)){let ft=Y.constructor.name;throw new Error(`[Virid System] Type Mismatch: Expected ${$.name}, but received ${ft}`)}if(Y instanceof Ne)return ce?Array.isArray(f)?f[f.length-1]:f:Array.isArray(f)?f:[f];if(Y instanceof W)return f;throw new Error(`[Virid System] unknown Message Types: Message ${$.name} is not a subclass of SingleMessage or EventMessage!`)}let R=G.get(x);if(!R)throw new Error(`[Virid System] unknown Inject Data Types: ${x.name} is not registered in the container!`);return R}),w=i.apply(e,M);return w instanceof Promise?w.then(te):te(w)},"wrappedSystem"),h={params:o,targetClass:e,methodName:t,originalMethod:i};d.systemContext=h,s.value=d;let u=r.messageClass||a.messageClass;G.register(u,d,r.priority)}}n(Ct,"it");c(Ct,"System");function Ht(r,e=!0){return(t,s,i)=>{if(Reflect.hasOwnMetadata(A.MESSAGE,t,s)){m.error(new Error(`[Virid Message] Multiple Messages Are Not Allowed: ${s} has multiple @Message() decorators!`));return}let o={index:i,messageClass:r,single:e};Reflect.defineMetadata(A.MESSAGE,o,t,s)}}n(Ht,"at");c(Ht,"Message");function Ot(){return(r,e,t)=>{let s=Reflect.getMetadata(A.SAFE,r)||new Set;s.add(e),Reflect.defineMetadata(A.SAFE,s,r)}}n(Ot,"ct");c(Ot,"Safe");function Vt(r){return(e,t)=>{let s=Reflect.getMetadata(A.OBSERVER,e)||[];s.push({propertyKey:t,callback:r}),Reflect.defineMetadata(A.OBSERVER,s,e)}}n(Vt,"lt");c(Vt,"Observer");function Pt(){return r=>{Reflect.defineMetadata(A.CONTROLLER,!0,r)}}n(Pt,"ht");c(Pt,"Controller");function It(){return r=>{Reflect.defineMetadata(A.COMPONENT,!0,r)}}n(It,"ut");c(It,"Component");var Dt=["push","pop","shift","unshift","splice","sort","reverse"];function re(r){return!r||typeof r!="object"||Object.prototype.hasOwnProperty.call(r,"__virid_observer_processed__")||(Object.defineProperty(r,"__virid_observer_processed__",{value:!0,enumerable:!1,configurable:!0}),(Reflect.getMetadata(A.OBSERVER,r)||[]).forEach(({propertyKey:e,callback:t})=>{console.log("instance :>> ",r),console.log("propertyKey :>> ",e);let s={value:r[e]},i=new Proxy(s,{get(a,d){let h=a.value;return Array.isArray(h)&&Dt.includes(d)?(...u)=>{let f=[...h],M=h[d].apply(h,u),w=t.call(r,f,h);return te(w),M}:h},set(a,d,h){let u=a.value;if(h===u)return!0;a.value=h;let f=t.call(r,u,h);return te(f),!0}}),o=c(()=>i.value,"getter");o.__virid_box__=s,Object.defineProperty(r,e,{get:o,set:c(a=>{i.value=a},"set"),enumerable:!0,configurable:!0}),s.value&&typeof s.value=="object"&&re(s.value)}),Reflect.ownKeys(r).forEach(e=>{if(e==="__virid_observer_processed__")return;let t=Object.getOwnPropertyDescriptor(r,e);if(t&&t.get)return;let s=r[e];s&&typeof s=="object"&&re(s)})),r}n(re,"P");c(re,"bindObservers");function Bt(){return G}n(Bt,"Mt");c(Bt,"createVirid");function Nt(r){let e=parseInt(r,10);if(isNaN(e))throw new k(400,`Validation failed: "${r}" is not a number.`);return e}n(Nt,"ParseIntPipe");function qt(r){return r==="true"||r==="1"?!0:r==="false"||r==="0"?!1:!!r}n(qt,"ParseBoolPipe");var z=new Map;z.set(Number,Nt);z.set(Boolean,qt);function yr(r,e){if(z.has(r)){m.error(new Error(`[Virid Express Pipe] Repeated Pipe: Auto pipe for ${r} has already been registered.`));return}z.set(r,e)}n(yr,"addAutoPipe");function qe(r){return z.get(r)}n(qe,"getAutoPipe");function lt(r){let e={};if(!r)return e;let t=r.split(";");for(let s of t){let i=s.indexOf("=");if(i===-1)continue;let o=s.substring(0,i).trim();if(!o)continue;let a=s.substring(i+1).trim();a[0]==='"'&&a[a.length-1]==='"'&&(a=a.slice(1,-1));try{e[o]=a.includes("%")?decodeURIComponent(a):a}catch{e[o]=a}}return e}n(lt,"parseRawCookie");import{EventMessage as _t}from"@virid/core";var _e=class _e extends _t{constructor(t){super();y(this,"__virid_express_id");this.__virid_express_id=t,v.get(this.__virid_express_id).inc()}get requestId(){return this.__virid_express_id}};n(_e,"HttpRequestMessage");var ne=_e;var ie=new jt,ae=new Map,Ut=0;function dt(r){for(let[e,t]of ie.systemTaskMap.entries())for(let s of t)r.register(e,s.fn,s.priority);ie.systemTaskMap.clear()}n(dt,"registerHttpSystem");function ut(r){for(let[e,t]of ae.entries()){let{method:s,path:i,httpMessage:o}=t,a=s.toLowerCase();r[a](i,(d,h)=>{let u=Ut++>>>0;v.set(u,new K(u,d,h,Date.now(),i));let f=new o(u);h.once("finish",()=>v.delete(u)),h.once("close",()=>v.delete(u)),Qt.write(f)})}}n(ut,"registerHttpRoute");var oe=null;function pt(r,e){oe=r,dt(r),ut(e.server)}n(pt,"activateApp");var ht=new Proxy({},{get(r,e){return(...t)=>{if(!oe)return Wt.warn(`[Virid Vue] App method "${String(e)}" called before initialization.`),null;let s=oe[e];if(typeof s=="function")return s.apply(oe,t)}}});import{MessageWriter as S}from"@virid/core";import{VIRID_METADATA as Ft}from"@virid/core";var g={...Ft,HTTPROUTE:"virid:express:route",HTTPSYSTEM:"virid:express:system",BODY:"virid:express:body",QUERY:"virid:express:query",HEADERS:"virid:express:header",REQUEST:"virid:express:request",RESPONSE:"virid:express:response",CONTEXT:"virid:express:context",PARAMS:"virid:express:params",COOKIES:"virid:express:cookie"};function Lr(r){return e=>{let t=`${r.method}:${r.path}`;ae.has(t)&&S.error(new Error(`[Virid Http] Routing Conflict: The request method ${r.method} for path ${r.path} has already been registered by ${e.name}`));let s=[];r.path.split("/").forEach(a=>{a.startsWith(":")&&s.push(a.substring(1))});let o={...r,httpMessage:e,params:s};ae.set(t,o)}}n(Lr,"HttpRoute");function Gr(r={priority:0,messageClass:null}){return(e,t,s)=>{let i=s.value,o=Reflect.getMetadata("design:paramtypes",e,t),a=Reflect.getMetadata(g.MESSAGE,e,t)||null,d=Lt(e,t,o);if(!o){let M=new Error(`[Virid HttpSystem] System Parameter Loss:
30
+ Unable to recognize system parameters, please confirm if import "reflection-metadata" was introduced at the beginning!`);S.error(M);return}if(o.some(M=>M===void 0)){let M=new Error(`[Virid HttpSystem] Parameter Metadata Loss in "${t}":
35
31
  One or more parameters have 'undefined' types.
36
32
  This usually happens when you forget to add a type annotation to a decorated parameter.
37
- Check parameter at index: ${o.indexOf(void 0)}`);S.error(E);return}if(r.messageClass&&a){S.error(new Error(`[Virid HttpSystem] Multiple Messages Are Not Allowed: Cannot use @ message() and SystemParams simultaneously in ${t}`));return}if(!r.messageClass&&!a){S.error(new Error(`[Virid HttpSystem] System Parameter Loss:
38
- Please declare the message type using the Message decorator`));return}let h=r.messageClass??a.messageClass;if(!ie.isPrototypeOf(h)){S.error(new Error(`[Virid HttpSystem] Wrong Message Type: ${h.name} is not a derived subclass of HttpRequestMessage!`));return}let u=n(E=>{let w=v.get(E.requestId);if(!w)throw new Error(`[Virid Express HttpSystem] Invalid Request Context: The request context for message ${E.requestId} is missing.`);try{let x=o.map((C,k)=>{if(a&&a.index==k){if(!(E instanceof h)){let le=E.constructor.name;throw new Error(`[Virid Express HttpSystem] Type Mismatch: Expected ${h.name}, but received ${le}`)}return E}else return Xt(C,k,w,d)}),A=i.apply(e,x);return A instanceof Promise?A.then(C=>{T(C,w)}).catch(C=>{throw T(Me(),w),C}):T(A,w)}catch(x){throw x instanceof R?T(x,w):T(Me(),w),x}},"wrappedSystem"),f={params:o,targetClass:e,methodName:t,originalMethod:i};u.systemContext=f,s.value=u,ae.register(h,u,r.priority)}}n(Xr,"HttpSystem");function Jr(){return(r,e,t)=>{if(Reflect.hasOwnMetadata(m.BODY,r,e)){S.error(new Error(`[Virid Express Body] Multiple Body Are Not Allowed: ${e} has multiple @Body() decorators!`));return}let s={index:t};Reflect.defineMetadata(m.BODY,s,r,e)}}n(Jr,"Body");function Zr(){return(r,e,t)=>{if(Reflect.hasOwnMetadata(m.HEADERS,r,e)){S.error(new Error(`[Virid Express Headers] Multiple Header Are Not Allowed: ${e} has multiple @Headers() decorators!`));return}let s={index:t};Reflect.defineMetadata(m.HEADERS,s,r,e)}}n(Zr,"Headers");function es(){return(r,e,t)=>{if(Reflect.hasOwnMetadata(m.COOKIES,r,e)){S.error(new Error(`[Virid Express Cookies] Multiple Header Are Not Allowed: ${e} has multiple @Cookies() decorators!`));return}let s={index:t};Reflect.defineMetadata(m.COOKIES,s,r,e)}}n(es,"Cookies");function ts(){return(r,e,t)=>{if(Reflect.hasOwnMetadata(m.REQUEST,r,e)){S.error(new Error(`[Virid Express Req] Multiple Request Objects Are Not Allowed: ${e} has multiple @Req() decorators!`));return}let s={index:t};Reflect.defineMetadata(m.REQUEST,s,r,e)}}n(ts,"Req");function rs(){return(r,e,t)=>{if(Reflect.hasOwnMetadata(m.RESPONSE,r,e)){S.error(new Error(`[Virid Express Res] Multiple Response Objects Are Not Allowed: ${e} has multiple @Res() decorators!`));return}let s={index:t};Reflect.defineMetadata(m.RESPONSE,s,r,e)}}n(rs,"Res");function ss(){return(r,e,t)=>{if(Reflect.hasOwnMetadata(m.CONTEXT,r,e)){S.error(new Error(`[Virid Express Ctx] Multiple Context Objects Are Not Allowed: ${e} has multiple @Ctx() decorators!`));return}let s={index:t};Reflect.defineMetadata(m.CONTEXT,s,r,e)}}n(ss,"Ctx");function ns(r,e){return(t,s,i)=>{let a=[...Reflect.getOwnMetadata(m.QUERY,t,s)||[],{index:i,query:r,pipe:e}];Reflect.defineMetadata(m.QUERY,a,t,s)}}n(ns,"Query");function is(r,e){return(t,s,i)=>{let a=[...Reflect.getOwnMetadata(m.PARAMS,t,s)||[],{index:i,key:r,pipe:e}];Reflect.defineMetadata(m.PARAMS,a,t,s)}}n(is,"Params");function Kt(r,e,t){let s=Reflect.getOwnMetadata(m.BODY,r,e),i=Reflect.getOwnMetadata(m.HEADERS,r,e),o=Reflect.getOwnMetadata(m.COOKIES,r,e),a=Reflect.getOwnMetadata(m.RESPONSE,r,e),d=Reflect.getOwnMetadata(m.REQUEST,r,e),h=Reflect.getOwnMetadata(m.CONTEXT,r,e),f=(Reflect.getOwnMetadata(m.QUERY,r,e)||[]).map(x=>{if(!x.pipe){let A=t[x.index];x.pipe=_e(A)}return x}),w=(Reflect.getOwnMetadata(m.PARAMS,r,e)||[]).map(x=>{if(!x.pipe){let A=t[x.index];x.pipe=_e(A)}return x});return{bodyMeta:s,headerMeta:i,queryMeta:f,cookiesMeta:o,reqMeta:d,resMeta:a,ctxMeta:h,paramMeta:w}}n(Kt,"getHttpMetadata");function Xt(r,e,t,s){let{req:i,res:o}=t;if(s.ctxMeta?.index===e)return t;let a=s.paramMeta?.find(u=>u.index===e);if(a){let u=a.key?i.params[a.key]:i.params;return a.pipe&&u!==void 0&&(u=a.pipe(u)),u}if(s.bodyMeta?.index===e)return i.body;if(s.headerMeta?.index===e)return i.headers;if(s.cookiesMeta?.index===e)return pt(i.headers.cookie);if(s.reqMeta?.index===e)return i;if(s.resMeta?.index===e)return o;let d=s.queryMeta?.find(u=>u.index===e);if(d){let u=i.query[d.query];if(u===void 0)throw new Error(`[Virid Express] Missing Query: "${d.query}"`);return d.pipe&&(u=d.pipe(u)),u}let h=mt.get(r);if(!h)throw new Error(`[Virid System] Unknown Inject Type: ${r?.name||"Anonymous Class"} at index ${e}.
39
- Ensure it is registered in the IOC container or has a proper Http Decorator!`);return h}n(Xt,"getHttpSystemArgs");var us={name:"@virid/express",install(r,e){gt(r,e)}};export{sr as BadRequest,he as BadRequestResponse,Jr as Body,Fe as ConflictResponse,es as Cookies,tr as Created,ue as CreatedResponse,ss as Ctx,or as CustomResponse,xe as CustomResponseResponse,us as ExpressPlugin,ir as Forbidden,ge as ForbiddenResponse,Zr as Headers,Z as HttpContext,R as HttpError,ie as HttpRequestMessage,M as HttpResponse,Kr as HttpRoute,Xr as HttpSystem,Me as InternalServerError,ye as InternalServerErrorResponse,rr as NoContent,pe as NoContentResponse,ar as NotFound,me as NotFoundResponse,er as Ok,de as OkResponse,is as Params,Ft as ParseBoolPipe,Qt as ParseIntPipe,ns as Query,ts as Req,rs as Res,lr as Stream,cr as StreamFile,L as StreamFileResponse,G as StreamResponse,nr as Unauthorized,fe as UnauthorizedResponse,We as UnprocessableEntityResponse,wr as addAutoPipe,_e as getAutoPipe,pt as parseRawCookie};
33
+ Check parameter at index: ${o.indexOf(void 0)}`);S.error(M);return}if(r.messageClass&&a){S.error(new Error(`[Virid HttpSystem] Multiple Messages Are Not Allowed: Cannot use @ message() and SystemParams simultaneously in ${t}`));return}if(!r.messageClass&&!a){S.error(new Error(`[Virid HttpSystem] System Parameter Loss:
34
+ Please declare the message type using the Message decorator`));return}let h=r.messageClass??a.messageClass;if(!ne.isPrototypeOf(h)){S.error(new Error(`[Virid HttpSystem] Wrong Message Type: ${h.name} is not a derived subclass of HttpRequestMessage!`));return}let u=n(M=>{let w=v.get(M.requestId);if(!w)throw new Error(`[Virid Express HttpSystem] Invalid Request Context: The request context for message ${M.requestId} is missing.`);try{let x=o.map((R,$)=>{if(a&&a.index==$){if(!(M instanceof h)){let ce=M.constructor.name;throw new Error(`[Virid Express HttpSystem] Type Mismatch: Expected ${h.name}, but received ${ce}`)}return M}else return Gt(R,$,w,d)}),b=i.apply(e,x);return b instanceof Promise?b.then(R=>{T(R,w)}).catch(R=>{throw T(xe(),w),R}):T(b,w)}catch(x){throw x instanceof k?T(x,w):T(xe(),w),x}},"wrappedSystem"),f={params:o,targetClass:e,methodName:t,originalMethod:i};u.systemContext=f,s.value=u,ie.register(h,u,r.priority)}}n(Gr,"HttpSystem");function zr(){return(r,e,t)=>{if(Reflect.hasOwnMetadata(g.BODY,r,e)){S.error(new Error(`[Virid Express Body] Multiple Body Are Not Allowed: ${e} has multiple @Body() decorators!`));return}let s={index:t};Reflect.defineMetadata(g.BODY,s,r,e)}}n(zr,"Body");function Yr(){return(r,e,t)=>{if(Reflect.hasOwnMetadata(g.HEADERS,r,e)){S.error(new Error(`[Virid Express Headers] Multiple Header Are Not Allowed: ${e} has multiple @Headers() decorators!`));return}let s={index:t};Reflect.defineMetadata(g.HEADERS,s,r,e)}}n(Yr,"Headers");function Kr(){return(r,e,t)=>{if(Reflect.hasOwnMetadata(g.COOKIES,r,e)){S.error(new Error(`[Virid Express Cookies] Multiple Header Are Not Allowed: ${e} has multiple @Cookies() decorators!`));return}let s={index:t};Reflect.defineMetadata(g.COOKIES,s,r,e)}}n(Kr,"Cookies");function Xr(){return(r,e,t)=>{if(Reflect.hasOwnMetadata(g.REQUEST,r,e)){S.error(new Error(`[Virid Express Req] Multiple Request Objects Are Not Allowed: ${e} has multiple @Req() decorators!`));return}let s={index:t};Reflect.defineMetadata(g.REQUEST,s,r,e)}}n(Xr,"Req");function Jr(){return(r,e,t)=>{if(Reflect.hasOwnMetadata(g.RESPONSE,r,e)){S.error(new Error(`[Virid Express Res] Multiple Response Objects Are Not Allowed: ${e} has multiple @Res() decorators!`));return}let s={index:t};Reflect.defineMetadata(g.RESPONSE,s,r,e)}}n(Jr,"Res");function Zr(){return(r,e,t)=>{if(Reflect.hasOwnMetadata(g.CONTEXT,r,e)){S.error(new Error(`[Virid Express Ctx] Multiple Context Objects Are Not Allowed: ${e} has multiple @Ctx() decorators!`));return}let s={index:t};Reflect.defineMetadata(g.CONTEXT,s,r,e)}}n(Zr,"Ctx");function es(r,e){return(t,s,i)=>{let a=[...Reflect.getOwnMetadata(g.QUERY,t,s)||[],{index:i,query:r,pipe:e}];Reflect.defineMetadata(g.QUERY,a,t,s)}}n(es,"Query");function ts(r,e){return(t,s,i)=>{let a=[...Reflect.getOwnMetadata(g.PARAMS,t,s)||[],{index:i,key:r,pipe:e}];Reflect.defineMetadata(g.PARAMS,a,t,s)}}n(ts,"Params");function Lt(r,e,t){let s=Reflect.getOwnMetadata(g.BODY,r,e),i=Reflect.getOwnMetadata(g.HEADERS,r,e),o=Reflect.getOwnMetadata(g.COOKIES,r,e),a=Reflect.getOwnMetadata(g.RESPONSE,r,e),d=Reflect.getOwnMetadata(g.REQUEST,r,e),h=Reflect.getOwnMetadata(g.CONTEXT,r,e),f=(Reflect.getOwnMetadata(g.QUERY,r,e)||[]).map(x=>{if(!x.pipe){let b=t[x.index];x.pipe=qe(b)}return x}),w=(Reflect.getOwnMetadata(g.PARAMS,r,e)||[]).map(x=>{if(!x.pipe){let b=t[x.index];x.pipe=qe(b)}return x});return{bodyMeta:s,headerMeta:i,queryMeta:f,cookiesMeta:o,reqMeta:d,resMeta:a,ctxMeta:h,paramMeta:w}}n(Lt,"getHttpMetadata");function Gt(r,e,t,s){let{req:i,res:o}=t;if(s.ctxMeta?.index===e)return t;let a=s.paramMeta?.find(u=>u.index===e);if(a){let u=a.key?i.params[a.key]:i.params;return a.pipe&&u!==void 0&&(u=a.pipe(u)),u}if(s.bodyMeta?.index===e)return i.body;if(s.headerMeta?.index===e)return i.headers;if(s.cookiesMeta?.index===e)return lt(i.headers.cookie);if(s.reqMeta?.index===e)return i;if(s.resMeta?.index===e)return o;let d=s.queryMeta?.find(u=>u.index===e);if(d){let u=i.query[d.query];if(u===void 0)throw new Error(`[Virid Express] Missing Query: "${d.query}"`);return d.pipe&&(u=d.pipe(u)),u}let h=ht.get(r);if(!h)throw new Error(`[Virid System] Unknown Inject Type: ${r?.name||"Anonymous Class"} at index ${e}.
35
+ Ensure it is registered in the IOC container or has a proper Http Decorator!`);return h}n(Gt,"getHttpSystemArgs");var os={name:"@virid/express",install(r,e){pt(r,e)}};export{Zt as BadRequest,pe as BadRequestResponse,zr as Body,Qe as ConflictResponse,Kr as Cookies,Xt as Created,de as CreatedResponse,Zr as Ctx,sr as CustomResponse,ye as CustomResponseResponse,os as ExpressPlugin,tr as Forbidden,fe as ForbiddenResponse,Yr as Headers,K as HttpContext,k as HttpError,ne as HttpRequestMessage,E as HttpResponse,Lr as HttpRoute,Gr as HttpSystem,xe as InternalServerError,me as InternalServerErrorResponse,Jt as NoContent,ue as NoContentResponse,rr as NotFound,ge as NotFoundResponse,Kt as Ok,le as OkResponse,ts as Params,qt as ParseBoolPipe,Nt as ParseIntPipe,es as Query,Xr as Req,Jr as Res,ir as Stream,nr as StreamFile,F as StreamFileResponse,L as StreamResponse,er as Unauthorized,he as UnauthorizedResponse,Ue as UnprocessableEntityResponse,yr as addAutoPipe,qe as getAutoPipe,lt as parseRawCookie};
40
36
  //# sourceMappingURL=index.js.map