@virid/express 0.1.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/LICENSE +190 -0
- package/README.md +1 -0
- package/README.zh.md +1 -0
- package/dist/index.cjs +40 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +213 -0
- package/dist/index.d.ts +213 -0
- package/dist/index.js +40 -0
- package/dist/index.js.map +1 -0
- package/package.json +44 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
Copyright 2026 Ailrid
|
|
179
|
+
|
|
180
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
181
|
+
you may not use this file except in compliance with the License.
|
|
182
|
+
You may obtain a copy of the License at
|
|
183
|
+
|
|
184
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
185
|
+
|
|
186
|
+
Unless required by applicable law or agreed to in writing, software
|
|
187
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
188
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
189
|
+
See the License for the specific language governing permissions and
|
|
190
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
todo
|
package/README.zh.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
todo
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @virid/express v0.0.1
|
|
3
|
+
* Add express functionality to virid
|
|
4
|
+
*/
|
|
5
|
+
var Y=Object.defineProperty;var At=Object.getOwnPropertyDescriptor;var Ct=Object.getOwnPropertyNames;var Rt=Object.prototype.hasOwnProperty;var $t=(r,e,t)=>e in r?Y(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var i=(r,e)=>Y(r,"name",{value:e,configurable:!0});var kt=(r,e)=>{for(var t in e)Y(r,t,{get:e[t],enumerable:!0})},Tt=(r,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Ct(e))!Rt.call(r,n)&&n!==t&&Y(r,n,{get:()=>e[n],enumerable:!(s=At(e,n))||s.enumerable});return r};var Ht=r=>Tt(Y({},"__esModule",{value:!0}),r);var y=(r,e,t)=>$t(r,typeof e!="symbol"?e+"":e,t);var br={};kt(br,{BadRequest:()=>It,BadRequestResponse:()=>ae,Body:()=>hr,ConflictResponse:()=>Se,Cookies:()=>gr,Created:()=>Vt,CreatedResponse:()=>ne,Ctx:()=>xr,CustomResponse:()=>qt,CustomResponseResponse:()=>ue,ExpressPlugin:()=>Sr,Forbidden:()=>Bt,ForbiddenResponse:()=>ce,Headers:()=>fr,HttpContext:()=>K,HttpError:()=>C,HttpRequestMessage:()=>te,HttpResponse:()=>M,HttpRoute:()=>ur,HttpSystem:()=>pr,InternalServerError:()=>pe,InternalServerErrorResponse:()=>de,NoContent:()=>Pt,NoContentResponse:()=>ie,NotFound:()=>Nt,NotFoundResponse:()=>le,Ok:()=>Ot,OkResponse:()=>se,Params:()=>Er,ParseBoolPipe:()=>mt,ParseIntPipe:()=>gt,Query:()=>Mr,Req:()=>mr,Res:()=>yr,Stream:()=>jt,StreamFile:()=>_t,StreamFileResponse:()=>H,StreamResponse:()=>O,Unauthorized:()=>Dt,UnauthorizedResponse:()=>oe,UnprocessableEntityResponse:()=>be,addAutoPipe:()=>lr,getAutoPipe:()=>ye,parseRawCookie:()=>Ue});module.exports=Ht(br);var Et=require("@virid/core");var Me=require("@virid/core");var $=require("@virid/core");var Ge=require("@virid/core");var Ae=class Ae{constructor(e,t,s,n,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=n,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
|
+
Route: ${this.route}
|
|
7
|
+
Uptime: ${Date.now()-this.timestamp}ms`;Ge.MessageWriter.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."})}};i(Ae,"HttpContext");var K=Ae,Ce=class Ce{constructor(e,t=null,s={}){y(this,"status");y(this,"data");y(this,"headers");this.status=e,this.data=t,this.headers=s}};i(Ce,"HttpResponse");var M=Ce,Re=class Re extends M{constructor(e,t={}){super(200,e,t)}};i(Re,"OkResponse");var se=Re,$e=class $e extends M{constructor(e,t={}){super(201,e,t)}};i($e,"CreatedResponse");var ne=$e,ke=class ke extends M{constructor(){super(204,null)}};i(ke,"NoContentResponse");var ie=ke,Te=class Te extends M{constructor(e="Bad Request"){super(400,{error:e})}};i(Te,"BadRequestResponse");var ae=Te,He=class He extends M{constructor(e="Unauthorized"){super(401,{error:e})}};i(He,"UnauthorizedResponse");var oe=He,Oe=class Oe extends M{constructor(e="Forbidden"){super(403,{error:e})}};i(Oe,"ForbiddenResponse");var ce=Oe,Ve=class Ve extends M{constructor(e="Not Found"){super(404,{error:e})}};i(Ve,"NotFoundResponse");var le=Ve,Pe=class Pe extends M{constructor(e="Conflict"){super(409,{error:e})}};i(Pe,"ConflictResponse");var Se=Pe,Ie=class Ie extends M{constructor(e){super(422,{errors:e})}};i(Ie,"UnprocessableEntityResponse");var be=Ie,De=class De extends M{constructor(e="Internal Server Error"){super(500,{error:e})}};i(De,"InternalServerErrorResponse");var de=De,Be=class Be extends M{constructor(e,t,s={}){super(e,t,s)}};i(Be,"CustomResponseResponse");var ue=Be,Ne=class Ne extends M{constructor(t,s={dotfiles:"allow"}){super(206,s);y(this,"filePath");y(this,"options");this.filePath=t,this.options=s}};i(Ne,"StreamFileResponse");var H=Ne,qe=class qe extends M{constructor(t,s={}){super(s.status,{},s.headers);y(this,"stream");y(this,"options");this.stream=t,this.options=s}};i(qe,"StreamResponse");var O=qe,Ot=i((r,e={})=>new se(r,e),"Ok"),Vt=i((r,e={})=>new ne(r,e),"Created"),Pt=i(()=>new ie,"NoContent"),It=i((r="Bad Request")=>new ae(r),"BadRequest"),Dt=i((r="Unauthorized")=>new oe(r),"Unauthorized"),Bt=i((r="Forbidden")=>new ce(r),"Forbidden"),Nt=i((r="Not Found")=>new le(r),"NotFound"),pe=i((r="Internal Server Error")=>new de(r),"InternalServerError"),qt=i((r,e,t={})=>new ue(r,e,t),"CustomResponse"),_t=i((r,e)=>new H(r,e),"StreamFile"),jt=i((r,e)=>new O(r,e),"Stream"),_e=class _e extends Error{constructor(t,s){super(s);y(this,"status");y(this,"message");this.status=t,this.message=s}};i(_e,"HttpError");var C=_e;var v=new Map;function V(r,e){if(!r){e.dec();return}(Array.isArray(r)?r:[r]).forEach(s=>{s instanceof M?Qt(s,e):s instanceof C?(e.res.status(s.status).json(s.message),v.delete(e.id)):s instanceof $.BaseMessage?$.MessageWriter.write(s):$.MessageWriter.warn(`[Virid Express] Invalid Return Type: ${typeof s}. Expected HttpResponse or Message.`)}),e.dec()}i(V,"handleResult");function Qt(r,e){let{res:t}=e;if(r.headers&&Object.entries(r.headers).forEach(([s,n])=>t.setHeader(s,n)),r.status&&t.status(r.status),r instanceof H){e.inc(),t.sendFile(r.filePath,r.options,s=>{t.headersSent||$.MessageWriter.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 O){let{stream:s}=r;e.inc(),s.pipe(t);let n=i(()=>{v.has(e.id)&&(e.res.end(),v.delete(e.id),e.isClosed=!0,e.dec())},"cleanup");s.on("end",n),s.on("error",o=>{t.headersSent||$.MessageWriter.error(o,"[Virid Express] Stream Error"),n()}),s.on("close",n);return}t.status(r.status).json(r.data),v.delete(e.id)}i(Qt,"handleHttpResponse");var Xe=Object.defineProperty,Ft=i((r,e,t)=>e in r?Xe(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,"he"),c=i((r,e)=>Xe(r,"name",{value:e,configurable:!0}),"o"),l=i((r,e,t)=>Ft(r,typeof e!="symbol"?e+"":e,t),"i"),P,Je=(P=class{static send(...e){g.write(this,...e)}},i(P,"G"),P);c(Je,"BaseMessage");var me=Je,I,Ze=(I=class extends me{constructor(){super(),l(this,"__kind","SingleMessage")}},i(I,"j"),I);c(Ze,"SingleMessage");var We=Ze,D,et=(D=class extends me{constructor(){super(),l(this,"__kind","EventMessage")}},i(D,"L"),D);c(et,"EventMessage");var k=et,B,tt=(B=class extends k{constructor(e,t){super(),l(this,"error"),l(this,"context"),this.error=e,this.context=t}},i(B,"W"),B);c(tt,"ErrorMessage");var je=tt,N,rt=(N=class extends k{constructor(e){super(),l(this,"context"),this.context=e}},i(N,"F"),N);c(rt,"WarnMessage");var Qe=rt,q,st=(q=class extends k{constructor(e){super(),l(this,"context"),this.context=e}},i(q,"Q"),q);c(st,"InfoMessage");var Fe=st,_,nt=(_=class extends k{constructor(e,t,s){super(),l(this,"ComponentClass"),l(this,"recipe"),l(this,"label"),this.ComponentClass=e,this.recipe=t,this.label=s}},i(_,"z"),_);c(nt,"AtomicModifyMessage");var ze=nt,he=null;function it(r){he=r}i(it,"ne");c(it,"activateInstance");var Wt=new Proxy({},{get(r,e){return e==="dispatch"?t=>{if(!he){console.error(`[Virid] Message dispatched before system init: ${t.constructor.name}`);return}return he.dispatch(t)}:Reflect.get(he||{},e)}}),j,at=(j=class{static write(e,...t){let s=typeof e=="function"?new e(...t):e;Wt.dispatch(s)}static error(e,t=""){this.write(new je(e,t))}static warn(e){this.write(new Qe(e))}static info(e){this.write(new Fe(e))}},i(j,"U"),j);c(at,"MessageWriter");var g=at,Q,ot=(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 k?this.eventQueue.push(e):e instanceof We&&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 n=this.prepareSnapshot();t=n.signalSnapshot,s=n.eventSnapshot;let o=this.collectTasks(s,t,e);this.executeTasks(o)}catch(n){g.error(n,"[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 n=[];for(let a of e)(s.get(a.constructor)||[]).forEach(d=>{n.push(new Ye(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)||(n.push(new Ye(d.fn,d.priority,this.eventHub.peekSignal(a),{context:d.fn.systemContext,tick:this.globalTick,payload:{}})),o.add(d.fn))});return n}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(n=>g.error(n,`[Virid Dispatcher]: Async System Error.
|
|
8
|
+
SystemLocation: ${t.hookContext.context.targetClass.name}.${t.hookContext.context.methodName}
|
|
9
|
+
MessageName: ${t.message.constructor.name}
|
|
10
|
+
MessageData: ${JSON.stringify(t.message)}`))}catch(s){g.error(s,`[Virid Dispatcher]: Sync System Error.
|
|
11
|
+
SystemLocation: ${t.hookContext.context.targetClass.name}.${t.hookContext.context.methodName}
|
|
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(n=>s.add(n.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))}},i(Q,"J"),Q);c(ot,"Dispatcher");var Ut=ot,F,ct=(F=class{constructor(e,t,s,n){l(this,"fn"),l(this,"priority"),l(this,"message"),l(this,"hookContext"),this.fn=e,this.priority=t,this.message=s,this.hookContext=n}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 n=s.handler(this.message,this.hookContext);n instanceof Promise&&n.catch(o=>{g.error(o,`[Virid Hook] Async Hook Error:
|
|
14
|
+
It is prohibited to use asynchronous hooks within Hook:
|
|
15
|
+
${s.type.name}`)})}catch(n){g.error(n,`[Virid Hook] Hook Execute Failed:
|
|
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 n=this.fn(this.message);return n instanceof Promise?n.finally(()=>s()):(s(),n)}catch(n){throw s(),n}}},i(F,"Y"),F);c(ct,"ExecutionTask");var Ye=ct,W,lt=(W=class{constructor(){l(this,"signalActive",new Map),l(this,"signalStaging",new Map),l(this,"eventActive",[]),l(this,"eventStaging",[])}push(e){if(e instanceof We){let t=e.constructor;this.signalStaging.has(t)||this.signalStaging.set(t,[]),this.signalStaging.get(t).push(e)}else e instanceof k?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=[]}},i(W,"q"),W);c(lt,"EventHub");var Lt=lt,U,dt=(U=class{constructor(){l(this,"systemTaskMap",new Map)}register(e,t,s=0){let n=this.systemTaskMap.get(e)||[];if(n.findIndex(o=>o.fn===t)===-1)n.push({fn:t,priority:s}),n.sort((o,a)=>a.priority-o.priority),this.systemTaskMap.set(e,n);else{let o=t.name||"Anonymous";return g.error(new Error(`[Virid Error] System Already Registered:
|
|
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))}}}},i(U,"K"),U);c(dt,"MessageRegistry");var Gt=dt,L,ut=(L=class{constructor(){l(this,"eventHub",new Lt),l(this,"dispatcher",new Ut(this.eventHub)),l(this,"registry",new Gt),l(this,"middlewares",[]),it(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 me)){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,n=c(()=>{s<this.middlewares.length?this.middlewares[s++](e,n):t()},"next");n()}register(e,t,s=0){return this.registry.register(e,t,s)}},i(L,"X"),L);c(ut,"MessageInternal");var zt=ut,G,pt=(G=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 n=s.ctor;if(s.type==="singleton"){if(!this.singletonInstances.has(e)){let a=new n,d=t(a);this.singletonInstances.set(e,d)}return this.singletonInstances.get(e)}let o=new n;return t(o)}},i(G,"Z"),G);c(pt,"ViridContainer");var Yt=pt,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 X(r,e,t){let s={params:r,targetClass:Object,methodName:t,originalMethod:e};return e.ccsContext=s,e}i(X,"N");c(X,"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"),Xt=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
|
+
${p.red}Context:${p.reset} ${t}
|
|
23
|
+
${p.red}Details:${p.reset}`,r.error||r||"unknown Error")},"globalErrorHandler"),Jt=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"),Zt=c(r=>{let e=J.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 ht(r){r.register(ze,X(ze,Zt,"GlobalAtomicModifier"),1e3),r.register(Qe,X(Qe,Jt,"GlobalWarnHandler"),-999),r.register(je,X(je,Xt,"GlobalErrorHandler"),-999),r.register(Fe,X(Fe,Kt,"GlobalInfoHandler"),-999),J=r}i(ht,"oe");c(ht,"initializeGlobalSystems");var J=null,Hr=new Proxy({},{get(r,e){return(...t)=>{if(!J){console.warn(`[Virid Vue] App method "${String(e)}" called before initialization.`);return}let s=J[e];if(typeof s=="function")return s.apply(J,t)}}}),Ke=new Set,z,ft=(z=class{constructor(){l(this,"container",new Yt),l(this,"messageInternal",new zt),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 n=s(t);return n===void 0&&g.warn(`[Virid Container] Hook Does Bot Return A Value: Hook "${s.name}" should return a instance to continue.`),n!==void 0?n:t}catch(n){return g.error(n,"[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(Ke.has(e.name))return g.warn(`[Virid Plugin] Duplicate Installation: Plugin ${e.name} has already been installed.`),this;try{e.install(this,t),Ke.add(e.name)}catch(s){g.error(s,`[Virid Plugin]: Install Failed: ${e.name}`)}return this}},i(z,"te"),z);c(ft,"ViridApp");var er=ft,Z=new er;Z.addActivationHook(ge);ht(Z);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"},fe=c(r=>{r&&(Array.isArray(r)?r:[r]).forEach(e=>{e instanceof me?g.write(e):g.warn("[Virid HandleResult] Invalid Return Type: Must return Message or Message[].")})},"handleResult");function tr(r={priority:0,messageClass:null}){return(e,t,s)=>{let n=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}":
|
|
30
|
+
One or more parameters have 'undefined' types.
|
|
31
|
+
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:T,single:ve}=a,re=Array.isArray(f)?f[0]:f;if(!(re instanceof T)){let bt=re.constructor.name;throw new Error(`[Virid System] Type Mismatch: Expected ${T.name}, but received ${bt}`)}if(re instanceof We)return ve?Array.isArray(f)?f[f.length-1]:f:Array.isArray(f)?f:[f];if(re instanceof k)return f;throw new Error(`[Virid System] unknown Message Types: Message ${T.name} is not a subclass of SingleMessage or EventMessage!`)}let R=Z.get(x);if(!R)throw new Error(`[Virid System] unknown Inject Data Types: ${x.name} is not registered in the container!`);return R}),w=n.apply(e,E);return w instanceof Promise?w.then(fe):fe(w)},"wrappedSystem"),h={params:o,targetClass:e,methodName:t,originalMethod:n};d.systemContext=h,s.value=d;let u=r.messageClass||a.messageClass;Z.register(u,d,r.priority)}}i(tr,"lt");c(tr,"System");function rr(r,e=!0){return(t,s,n)=>{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:n,messageClass:r,single:e};Reflect.defineMetadata(b.MESSAGE,o,t,s)}}i(rr,"ht");c(rr,"Message");function sr(){return(r,e,t)=>{let s=Reflect.getMetadata(b.SAFE,r)||new Set;s.add(e),Reflect.defineMetadata(b.SAFE,s,r)}}i(sr,"ut");c(sr,"Safe");function nr(r,[]){return(e,t)=>{let s=Reflect.getMetadata(b.OBSERVER,e)||[];s.push({key:t,callback:r}),Reflect.defineMetadata(b.OBSERVER,s,e)}}i(nr,"dt");c(nr,"Observer");function ir(){return r=>{Reflect.defineMetadata(b.CONTROLLER,!0,r)}}i(ir,"ft");c(ir,"Controller");function ar(){return r=>{Reflect.defineMetadata(b.COMPONENT,!0,r)}}i(ar,"pt");c(ar,"Component");var or=["push","pop","shift","unshift","splice","sort","reverse"];function ge(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]},n=new Proxy(s,{get(a,d){let h=a.value;return Array.isArray(h)&&or.includes(d)?(...u)=>{let f=[...h],E=h[d].apply(h,u),w=t.call(r,f,h);return fe(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 fe(f),!0}}),o=c(()=>n.value,"getter");o.__virid_box__=s,Object.defineProperty(r,e,{get:o,set:c(a=>{n.value=a},"set"),enumerable:!0,configurable:!0}),s.value&&typeof s.value=="object"&&ge(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"&&ge(s)})),r}i(ge,"_");c(ge,"bindObservers");function cr(){return Z}i(cr,"Ct");c(cr,"createVirid");function gt(r){let e=parseInt(r,10);if(isNaN(e))throw new C(400,`Validation failed: "${r}" is not a number.`);return e}i(gt,"ParseIntPipe");function mt(r){return r==="true"||r==="1"?!0:r==="false"||r==="0"?!1:!!r}i(mt,"ParseBoolPipe");var ee=new Map;ee.set(Number,gt);ee.set(Boolean,mt);function lr(r,e){if(ee.has(r)){g.error(new Error(`[Virid Express Pipe] Repeated Pipe: Auto pipe for ${r} has already been registered.`));return}ee.set(r,e)}i(lr,"addAutoPipe");function ye(r){return ee.get(r)}i(ye,"getAutoPipe");function Ue(r){let e={};if(!r)return e;let t=r.split(";");for(let s of t){let n=s.indexOf("=");if(n===-1)continue;let o=s.substring(0,n).trim();if(!o)continue;let a=s.substring(n+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}i(Ue,"parseRawCookie");var yt=require("@virid/core");var Le=class Le extends yt.EventMessage{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}};i(Le,"HttpRequestMessage");var te=Le;var xe=new Me.MessageRegistry,Ee=new Map,dr=0;function xt(r){for(let[e,t]of xe.systemTaskMap.entries())for(let s of t)r.register(e,s.fn,s.priority);xe.systemTaskMap.clear()}i(xt,"registerHttpSystem");function Mt(r){for(let[e,t]of Ee.entries()){let{method:s,path:n,httpMessage:o}=t,a=s.toLowerCase();r[a](n,(d,h)=>{let u=dr++>>>0;v.set(u,new K(u,d,h,Date.now(),n));let f=new o(u);h.once("finish",()=>v.delete(u)),h.once("close",()=>v.delete(u)),Me.MessageWriter.write(f)})}}i(Mt,"registerHttpRoute");var we=null;function wt(r,e){we=r,xt(r),Mt(e.server)}i(wt,"activateApp");var vt=new Proxy({},{get(r,e){return(...t)=>{if(!we)return Et.MessageWriter.warn(`[Virid Vue] App method "${String(e)}" called before initialization.`),null;let s=we[e];if(typeof s=="function")return s.apply(we,t)}}});var S=require("@virid/core");var St=require("@virid/core"),m={...St.VIRID_METADATA,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 ur(r){return e=>{let t=`${r.method}:${r.path}`;Ee.has(t)&&S.MessageWriter.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};Ee.set(t,o)}}i(ur,"HttpRoute");function pr(r={priority:0,messageClass:null}){return(e,t,s)=>{let n=s.value,o=Reflect.getMetadata("design:paramtypes",e,t),a=Reflect.getMetadata(m.MESSAGE,e,t)||null,d=wr(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.MessageWriter.error(E);return}if(o.some(E=>E===void 0)){let E=new Error(`[Virid HttpSystem] Parameter Metadata Loss in "${t}":
|
|
35
|
+
One or more parameters have 'undefined' types.
|
|
36
|
+
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.MessageWriter.error(E);return}if(r.messageClass&&a){S.MessageWriter.error(new Error(`[Virid HttpSystem] Multiple Messages Are Not Allowed: Cannot use @ message() and SystemParams simultaneously in ${t}`));return}if(!r.messageClass&&!a){S.MessageWriter.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(!te.isPrototypeOf(h)){S.MessageWriter.error(new Error(`[Virid HttpSystem] Wrong Message Type: ${h.name} is not a derived subclass of HttpRequestMessage!`));return}let u=i(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((R,T)=>{if(a&&a.index==T){if(!(E instanceof h)){let ve=E.constructor.name;throw new Error(`[Virid Express HttpSystem] Type Mismatch: Expected ${h.name}, but received ${ve}`)}return E}else return vr(R,T,w,d)}),A=n.apply(e,x);return A instanceof Promise?A.then(R=>{V(R,w)}).catch(R=>{throw V(pe(),w),R}):V(A,w)}catch(x){throw x instanceof C?V(x,w):V(pe(),w),x}},"wrappedSystem"),f={params:o,targetClass:e,methodName:t,originalMethod:n};u.systemContext=f,s.value=u,xe.register(h,u,r.priority)}}i(pr,"HttpSystem");function hr(){return(r,e,t)=>{if(Reflect.hasOwnMetadata(m.BODY,r,e)){S.MessageWriter.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)}}i(hr,"Body");function fr(){return(r,e,t)=>{if(Reflect.hasOwnMetadata(m.HEADERS,r,e)){S.MessageWriter.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)}}i(fr,"Headers");function gr(){return(r,e,t)=>{if(Reflect.hasOwnMetadata(m.COOKIES,r,e)){S.MessageWriter.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)}}i(gr,"Cookies");function mr(){return(r,e,t)=>{if(Reflect.hasOwnMetadata(m.REQUEST,r,e)){S.MessageWriter.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)}}i(mr,"Req");function yr(){return(r,e,t)=>{if(Reflect.hasOwnMetadata(m.RESPONSE,r,e)){S.MessageWriter.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)}}i(yr,"Res");function xr(){return(r,e,t)=>{if(Reflect.hasOwnMetadata(m.CONTEXT,r,e)){S.MessageWriter.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)}}i(xr,"Ctx");function Mr(r,e){return(t,s,n)=>{let a=[...Reflect.getOwnMetadata(m.QUERY,t,s)||[],{index:n,query:r,pipe:e}];Reflect.defineMetadata(m.QUERY,a,t,s)}}i(Mr,"Query");function Er(r,e){return(t,s,n)=>{let a=[...Reflect.getOwnMetadata(m.PARAMS,t,s)||[],{index:n,key:r,pipe:e}];Reflect.defineMetadata(m.PARAMS,a,t,s)}}i(Er,"Params");function wr(r,e,t){let s=Reflect.getOwnMetadata(m.BODY,r,e),n=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=ye(A)}return x}),w=(Reflect.getOwnMetadata(m.PARAMS,r,e)||[]).map(x=>{if(!x.pipe){let A=t[x.index];x.pipe=ye(A)}return x});return{bodyMeta:s,headerMeta:n,queryMeta:f,cookiesMeta:o,reqMeta:d,resMeta:a,ctxMeta:h,paramMeta:w}}i(wr,"getHttpMetadata");function vr(r,e,t,s){let{req:n,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?n.params[a.key]:n.params;return a.pipe&&u!==void 0&&(u=a.pipe(u)),u}if(s.bodyMeta?.index===e)return n.body;if(s.headerMeta?.index===e)return n.headers;if(s.cookiesMeta?.index===e)return Ue(n.headers.cookie);if(s.reqMeta?.index===e)return n;if(s.resMeta?.index===e)return o;let d=s.queryMeta?.find(u=>u.index===e);if(d){let u=n.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=vt.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}i(vr,"getHttpSystemArgs");var Sr={name:"@virid/express",install(r,e){wt(r,e)}};0&&(module.exports={BadRequest,BadRequestResponse,Body,ConflictResponse,Cookies,Created,CreatedResponse,Ctx,CustomResponse,CustomResponseResponse,ExpressPlugin,Forbidden,ForbiddenResponse,Headers,HttpContext,HttpError,HttpRequestMessage,HttpResponse,HttpRoute,HttpSystem,InternalServerError,InternalServerErrorResponse,NoContent,NoContentResponse,NotFound,NotFoundResponse,Ok,OkResponse,Params,ParseBoolPipe,ParseIntPipe,Query,Req,Res,Stream,StreamFile,StreamFileResponse,StreamResponse,Unauthorized,UnauthorizedResponse,UnprocessableEntityResponse,addAutoPipe,getAutoPipe,parseRawCookie});
|
|
40
|
+
//# sourceMappingURL=index.cjs.map
|