@remotex-labs/xjet 1.0.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 ADDED
@@ -0,0 +1,373 @@
1
+ Mozilla Public License Version 2.0
2
+ ==================================
3
+
4
+ 1. Definitions
5
+ --------------
6
+
7
+ 1.1. "Contributor"
8
+ means each individual or legal entity that creates, contributes to
9
+ the creation of, or owns Covered Software.
10
+
11
+ 1.2. "Contributor Version"
12
+ means the combination of the Contributions of others (if any) used
13
+ by a Contributor and that particular Contributor's Contribution.
14
+
15
+ 1.3. "Contribution"
16
+ means Covered Software of a particular Contributor.
17
+
18
+ 1.4. "Covered Software"
19
+ means Source Code Form to which the initial Contributor has attached
20
+ the notice in Exhibit A, the Executable Form of such Source Code
21
+ Form, and Modifications of such Source Code Form, in each case
22
+ including portions thereof.
23
+
24
+ 1.5. "Incompatible With Secondary Licenses"
25
+ means
26
+
27
+ (a) that the initial Contributor has attached the notice described
28
+ in Exhibit B to the Covered Software; or
29
+
30
+ (b) that the Covered Software was made available under the terms of
31
+ version 1.1 or earlier of the License, but not also under the
32
+ terms of a Secondary License.
33
+
34
+ 1.6. "Executable Form"
35
+ means any form of the work other than Source Code Form.
36
+
37
+ 1.7. "Larger Work"
38
+ means a work that combines Covered Software with other material, in
39
+ a separate file or files, that is not Covered Software.
40
+
41
+ 1.8. "License"
42
+ means this document.
43
+
44
+ 1.9. "Licensable"
45
+ means having the right to grant, to the maximum extent possible,
46
+ whether at the time of the initial grant or subsequently, any and
47
+ all of the rights conveyed by this License.
48
+
49
+ 1.10. "Modifications"
50
+ means any of the following:
51
+
52
+ (a) any file in Source Code Form that results from an addition to,
53
+ deletion from, or modification of the contents of Covered
54
+ Software; or
55
+
56
+ (b) any new file in Source Code Form that contains any Covered
57
+ Software.
58
+
59
+ 1.11. "Patent Claims" of a Contributor
60
+ means any patent claim(s), including without limitation, method,
61
+ process, and apparatus claims, in any patent Licensable by such
62
+ Contributor that would be infringed, but for the grant of the
63
+ License, by the making, using, selling, offering for sale, having
64
+ made, import, or transfer of either its Contributions or its
65
+ Contributor Version.
66
+
67
+ 1.12. "Secondary License"
68
+ means either the GNU General Public License, Version 2.0, the GNU
69
+ Lesser General Public License, Version 2.1, the GNU Affero General
70
+ Public License, Version 3.0, or any later versions of those
71
+ licenses.
72
+
73
+ 1.13. "Source Code Form"
74
+ means the form of the work preferred for making modifications.
75
+
76
+ 1.14. "You" (or "Your")
77
+ means an individual or a legal entity exercising rights under this
78
+ License. For legal entities, "You" includes any entity that
79
+ controls, is controlled by, or is under common control with You. For
80
+ purposes of this definition, "control" means (a) the power, direct
81
+ or indirect, to cause the direction or management of such entity,
82
+ whether by contract or otherwise, or (b) ownership of more than
83
+ fifty percent (50%) of the outstanding shares or beneficial
84
+ ownership of such entity.
85
+
86
+ 2. License Grants and Conditions
87
+ --------------------------------
88
+
89
+ 2.1. Grants
90
+
91
+ Each Contributor hereby grants You a world-wide, royalty-free,
92
+ non-exclusive license:
93
+
94
+ (a) under intellectual property rights (other than patent or trademark)
95
+ Licensable by such Contributor to use, reproduce, make available,
96
+ modify, display, perform, distribute, and otherwise exploit its
97
+ Contributions, either on an unmodified basis, with Modifications, or
98
+ as part of a Larger Work; and
99
+
100
+ (b) under Patent Claims of such Contributor to make, use, sell, offer
101
+ for sale, have made, import, and otherwise transfer either its
102
+ Contributions or its Contributor Version.
103
+
104
+ 2.2. Effective Date
105
+
106
+ The licenses granted in Section 2.1 with respect to any Contribution
107
+ become effective for each Contribution on the date the Contributor first
108
+ distributes such Contribution.
109
+
110
+ 2.3. Limitations on Grant Scope
111
+
112
+ The licenses granted in this Section 2 are the only rights granted under
113
+ this License. No additional rights or licenses will be implied from the
114
+ distribution or licensing of Covered Software under this License.
115
+ Notwithstanding Section 2.1(b) above, no patent license is granted by a
116
+ Contributor:
117
+
118
+ (a) for any code that a Contributor has removed from Covered Software;
119
+ or
120
+
121
+ (b) for infringements caused by: (i) Your and any other third party's
122
+ modifications of Covered Software, or (ii) the combination of its
123
+ Contributions with other software (except as part of its Contributor
124
+ Version); or
125
+
126
+ (c) under Patent Claims infringed by Covered Software in the absence of
127
+ its Contributions.
128
+
129
+ This License does not grant any rights in the trademarks, service marks,
130
+ or logos of any Contributor (except as may be necessary to comply with
131
+ the notice requirements in Section 3.4).
132
+
133
+ 2.4. Subsequent Licenses
134
+
135
+ No Contributor makes additional grants as a result of Your choice to
136
+ distribute the Covered Software under a subsequent version of this
137
+ License (see Section 10.2) or under the terms of a Secondary License (if
138
+ permitted under the terms of Section 3.3).
139
+
140
+ 2.5. Representation
141
+
142
+ Each Contributor represents that the Contributor believes its
143
+ Contributions are its original creation(s) or it has sufficient rights
144
+ to grant the rights to its Contributions conveyed by this License.
145
+
146
+ 2.6. Fair Use
147
+
148
+ This License is not intended to limit any rights You have under
149
+ applicable copyright doctrines of fair use, fair dealing, or other
150
+ equivalents.
151
+
152
+ 2.7. Conditions
153
+
154
+ Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
155
+ in Section 2.1.
156
+
157
+ 3. Responsibilities
158
+ -------------------
159
+
160
+ 3.1. Distribution of Source Form
161
+
162
+ All distribution of Covered Software in Source Code Form, including any
163
+ Modifications that You create or to which You contribute, must be under
164
+ the terms of this License. You must inform recipients that the Source
165
+ Code Form of the Covered Software is governed by the terms of this
166
+ License, and how they can obtain a copy of this License. You may not
167
+ attempt to alter or restrict the recipients' rights in the Source Code
168
+ Form.
169
+
170
+ 3.2. Distribution of Executable Form
171
+
172
+ If You distribute Covered Software in Executable Form then:
173
+
174
+ (a) such Covered Software must also be made available in Source Code
175
+ Form, as described in Section 3.1, and You must inform recipients of
176
+ the Executable Form how they can obtain a copy of such Source Code
177
+ Form by reasonable means in a timely manner, at a charge no more
178
+ than the cost of distribution to the recipient; and
179
+
180
+ (b) You may distribute such Executable Form under the terms of this
181
+ License, or sublicense it under different terms, provided that the
182
+ license for the Executable Form does not attempt to limit or alter
183
+ the recipients' rights in the Source Code Form under this License.
184
+
185
+ 3.3. Distribution of a Larger Work
186
+
187
+ You may create and distribute a Larger Work under terms of Your choice,
188
+ provided that You also comply with the requirements of this License for
189
+ the Covered Software. If the Larger Work is a combination of Covered
190
+ Software with a work governed by one or more Secondary Licenses, and the
191
+ Covered Software is not Incompatible With Secondary Licenses, this
192
+ License permits You to additionally distribute such Covered Software
193
+ under the terms of such Secondary License(s), so that the recipient of
194
+ the Larger Work may, at their option, further distribute the Covered
195
+ Software under the terms of either this License or such Secondary
196
+ License(s).
197
+
198
+ 3.4. Notices
199
+
200
+ You may not remove or alter the substance of any license notices
201
+ (including copyright notices, patent notices, disclaimers of warranty,
202
+ or limitations of liability) contained within the Source Code Form of
203
+ the Covered Software, except that You may alter any license notices to
204
+ the extent required to remedy known factual inaccuracies.
205
+
206
+ 3.5. Application of Additional Terms
207
+
208
+ You may choose to offer, and to charge a fee for, warranty, support,
209
+ indemnity or liability obligations to one or more recipients of Covered
210
+ Software. However, You may do so only on Your own behalf, and not on
211
+ behalf of any Contributor. You must make it absolutely clear that any
212
+ such warranty, support, indemnity, or liability obligation is offered by
213
+ You alone, and You hereby agree to indemnify every Contributor for any
214
+ liability incurred by such Contributor as a result of warranty, support,
215
+ indemnity or liability terms You offer. You may include additional
216
+ disclaimers of warranty and limitations of liability specific to any
217
+ jurisdiction.
218
+
219
+ 4. Inability to Comply Due to Statute or Regulation
220
+ ---------------------------------------------------
221
+
222
+ If it is impossible for You to comply with any of the terms of this
223
+ License with respect to some or all of the Covered Software due to
224
+ statute, judicial order, or regulation then You must: (a) comply with
225
+ the terms of this License to the maximum extent possible; and (b)
226
+ describe the limitations and the code they affect. Such description must
227
+ be placed in a text file included with all distributions of the Covered
228
+ Software under this License. Except to the extent prohibited by statute
229
+ or regulation, such description must be sufficiently detailed for a
230
+ recipient of ordinary skill to be able to understand it.
231
+
232
+ 5. Termination
233
+ --------------
234
+
235
+ 5.1. The rights granted under this License will terminate automatically
236
+ if You fail to comply with any of its terms. However, if You become
237
+ compliant, then the rights granted under this License from a particular
238
+ Contributor are reinstated (a) provisionally, unless and until such
239
+ Contributor explicitly and finally terminates Your grants, and (b) on an
240
+ ongoing basis, if such Contributor fails to notify You of the
241
+ non-compliance by some reasonable means prior to 60 days after You have
242
+ come back into compliance. Moreover, Your grants from a particular
243
+ Contributor are reinstated on an ongoing basis if such Contributor
244
+ notifies You of the non-compliance by some reasonable means, this is the
245
+ first time You have received notice of non-compliance with this License
246
+ from such Contributor, and You become compliant prior to 30 days after
247
+ Your receipt of the notice.
248
+
249
+ 5.2. If You initiate litigation against any entity by asserting a patent
250
+ infringement claim (excluding declaratory judgment actions,
251
+ counter-claims, and cross-claims) alleging that a Contributor Version
252
+ directly or indirectly infringes any patent, then the rights granted to
253
+ You by any and all Contributors for the Covered Software under Section
254
+ 2.1 of this License shall terminate.
255
+
256
+ 5.3. In the event of termination under Sections 5.1 or 5.2 above, all
257
+ end user license agreements (excluding distributors and resellers) which
258
+ have been validly granted by You or Your distributors under this License
259
+ prior to termination shall survive termination.
260
+
261
+ ************************************************************************
262
+ * *
263
+ * 6. Disclaimer of Warranty *
264
+ * ------------------------- *
265
+ * *
266
+ * Covered Software is provided under this License on an "as is" *
267
+ * basis, without warranty of any kind, either expressed, implied, or *
268
+ * statutory, including, without limitation, warranties that the *
269
+ * Covered Software is free of defects, merchantable, fit for a *
270
+ * particular purpose or non-infringing. The entire risk as to the *
271
+ * quality and performance of the Covered Software is with You. *
272
+ * Should any Covered Software prove defective in any respect, You *
273
+ * (not any Contributor) assume the cost of any necessary servicing, *
274
+ * repair, or correction. This disclaimer of warranty constitutes an *
275
+ * essential part of this License. No use of any Covered Software is *
276
+ * authorized under this License except under this disclaimer. *
277
+ * *
278
+ ************************************************************************
279
+
280
+ ************************************************************************
281
+ * *
282
+ * 7. Limitation of Liability *
283
+ * -------------------------- *
284
+ * *
285
+ * Under no circumstances and under no legal theory, whether tort *
286
+ * (including negligence), contract, or otherwise, shall any *
287
+ * Contributor, or anyone who distributes Covered Software as *
288
+ * permitted above, be liable to You for any direct, indirect, *
289
+ * special, incidental, or consequential damages of any character *
290
+ * including, without limitation, damages for lost profits, loss of *
291
+ * goodwill, work stoppage, computer failure or malfunction, or any *
292
+ * and all other commercial damages or losses, even if such party *
293
+ * shall have been informed of the possibility of such damages. This *
294
+ * limitation of liability shall not apply to liability for death or *
295
+ * personal injury resulting from such party's negligence to the *
296
+ * extent applicable law prohibits such limitation. Some *
297
+ * jurisdictions do not allow the exclusion or limitation of *
298
+ * incidental or consequential damages, so this exclusion and *
299
+ * limitation may not apply to You. *
300
+ * *
301
+ ************************************************************************
302
+
303
+ 8. Litigation
304
+ -------------
305
+
306
+ Any litigation relating to this License may be brought only in the
307
+ courts of a jurisdiction where the defendant maintains its principal
308
+ place of business and such litigation shall be governed by laws of that
309
+ jurisdiction, without reference to its conflict-of-law provisions.
310
+ Nothing in this Section shall prevent a party's ability to bring
311
+ cross-claims or counter-claims.
312
+
313
+ 9. Miscellaneous
314
+ ----------------
315
+
316
+ This License represents the complete agreement concerning the subject
317
+ matter hereof. If any provision of this License is held to be
318
+ unenforceable, such provision shall be reformed only to the extent
319
+ necessary to make it enforceable. Any law or regulation which provides
320
+ that the language of a contract shall be construed against the drafter
321
+ shall not be used to construe this License against a Contributor.
322
+
323
+ 10. Versions of the License
324
+ ---------------------------
325
+
326
+ 10.1. New Versions
327
+
328
+ Mozilla Foundation is the license steward. Except as provided in Section
329
+ 10.3, no one other than the license steward has the right to modify or
330
+ publish new versions of this License. Each version will be given a
331
+ distinguishing version number.
332
+
333
+ 10.2. Effect of New Versions
334
+
335
+ You may distribute the Covered Software under the terms of the version
336
+ of the License under which You originally received the Covered Software,
337
+ or under the terms of any subsequent version published by the license
338
+ steward.
339
+
340
+ 10.3. Modified Versions
341
+
342
+ If you create software not governed by this License, and you want to
343
+ create a new license for such software, you may create and use a
344
+ modified version of this License if you rename the license and remove
345
+ any references to the name of the license steward (except to note that
346
+ such modified license differs from this License).
347
+
348
+ 10.4. Distributing Source Code Form that is Incompatible With Secondary
349
+ Licenses
350
+
351
+ If You choose to distribute Source Code Form that is Incompatible With
352
+ Secondary Licenses under the terms of this version of the License, the
353
+ notice described in Exhibit B of this License must be attached.
354
+
355
+ Exhibit A - Source Code Form License Notice
356
+ -------------------------------------------
357
+
358
+ This Source Code Form is subject to the terms of the Mozilla Public
359
+ License, v. 2.0. If a copy of the MPL was not distributed with this
360
+ file, You can obtain one at http://mozilla.org/MPL/2.0/.
361
+
362
+ If it is not possible or desirable to put the notice in a particular
363
+ file, then You may include the notice in a location (such as a LICENSE
364
+ file in a relevant directory) where a recipient would be likely to look
365
+ for such a notice.
366
+
367
+ You may add additional accurate notices of copyright ownership.
368
+
369
+ Exhibit B - "Incompatible With Secondary Licenses" Notice
370
+ ---------------------------------------------------------
371
+
372
+ This Source Code Form is "Incompatible With Secondary Licenses", as
373
+ defined by the Mozilla Public License, v. 2.0.
package/README.md ADDED
@@ -0,0 +1,73 @@
1
+ # xJet
2
+
3
+ [![npm version](https://img.shields.io/badge/Documentation-orange?logo=typescript&logoColor=f5f5f5)](https://remotex-labs.github.io/xJet/)
4
+ [![npm version](https://img.shields.io/npm/v/@remotex-labs/xjet.svg)](https://www.npmjs.com/package/@remotex-labs/xjet)
5
+ [![License: MPL 2.0](https://img.shields.io/badge/License-MPL_2.0-brightgreen.svg)](https://opensource.org/licenses/MPL-2.0)
6
+ [![Node.js CI](https://github.com/remotex-labs/xJet/actions/workflows/node.js.yml/badge.svg)](https://github.com/remotex-labs/xJet/actions/workflows/node.js.yml)
7
+
8
+ ## Overview
9
+
10
+ xJet is a powerful, flexible testing framework for JavaScript and TypeScript applications.
11
+ Its mission is to help you "Run Automated Tests Anywhere, Effortlessly".
12
+
13
+ ## Features
14
+
15
+ - **Familiar API**: Uses a Jest-like interface with `describe`, `it`, `test`, and `expect` functions
16
+ - **Powerful Mocking**: Complete suite of mocking utilities including `fn`, `mock`, and `spyOn`
17
+ - **CLI Options**: Configurable through command-line arguments
18
+ - **Multiple Reporters**: Support for different output formats including human-readable, JSON, and JUnit XML
19
+ - **TypeScript Support**: First-class TypeScript support with type definitions included
20
+
21
+ ## Installation
22
+
23
+ ```bash
24
+ npm install @remotex-labs/xjet
25
+ ```
26
+
27
+ ## Usage
28
+
29
+ ### Basic Test Example
30
+
31
+ ```ts
32
+ // example.test.ts
33
+ describe('Calculator', () => { test('should add two numbers correctly', () => {
34
+ const result = 1 + 2; expect(result).toBe(3);
35
+ });
36
+
37
+ it('should subtract two numbers correctly', () => {
38
+ const result = 5 - 2; expect(result).toBe(3); });
39
+ });
40
+ ```
41
+
42
+ ### Running Tests
43
+
44
+ ```bash
45
+ xJet
46
+ ```
47
+
48
+ Run:
49
+
50
+ ![Run](./docs/src/public/images/run.png)
51
+
52
+ ![Run](./docs/src/public/images/run1.png)
53
+
54
+ ![Run](./docs/src/public/images/run2.png)
55
+
56
+
57
+ ## Documentation
58
+ For complete API documentation, examples, and guides, visit: [xAnsi Documentation](https://remotex-labs.github.io/xAnsi/)
59
+
60
+ ## Compatibility
61
+ - Node.js 20+
62
+ - All modern browsers (via bundlers)
63
+ - TypeScript 4.5+
64
+
65
+ ## Contributing
66
+ Contributions are welcome!\
67
+ Please see our [Contributing Guide](CONTRIBUTING.md) for details.
68
+
69
+ ## License
70
+ This project is licensed under the Mozilla Public License 2.0 see the [LICENSE](LICENSE) file for details.
71
+
72
+ ## Acknowledgments
73
+ - Built with TypeScript
package/dist/bash.js ADDED
@@ -0,0 +1,45 @@
1
+ #!/usr/bin/env node
2
+ var at=Object.create;var ne=Object.defineProperty;var ct=Object.getOwnPropertyDescriptor;var Ce=(i,e)=>(e=Symbol[i])?e:Symbol.for("Symbol."+i),B=i=>{throw TypeError(i)};var pt=(i,e,t)=>e in i?ne(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var o=(i,e)=>ne(i,"name",{value:e,configurable:!0});var k=i=>[,,,at(i?.[Ce("metadata")]??null)],Fe=["class","method","getter","setter","accessor","field","value","get","set"],_=i=>i!==void 0&&typeof i!="function"?B("Function expected"):i,ut=(i,e,t,r,s)=>({kind:Fe[i],name:e,metadata:r,addInitializer:n=>t._?B("Already initialized"):s.push(_(n||null))}),ft=(i,e)=>pt(e,Ce("metadata"),i[3]),x=(i,e,t,r)=>{for(var s=0,n=i[e>>1],a=n&&n.length;s<a;s++)e&1?n[s].call(t):r=n[s].call(t,r);return r},v=(i,e,t,r,s,n)=>{var a,c,y,I,F,p=e&7,te=!!(e&8),S=!!(e&16),re=p>3?i.length+1:p?te?1:2:0,be=Fe[p+5],Pe=p>3&&(i[re-1]=[]),ot=i[re]||(i[re]=[]),g=p&&(!S&&!te&&(s=s.prototype),p<5&&(p>3||!S)&&ct(p<4?s:{get[t](){return Re(this,n)},set[t](l){return Ae(this,n,l)}},t));p?S&&p<4&&o(n,(p>2?"set ":p>1?"get ":"")+t):o(s,t);for(var se=r.length-1;se>=0;se--)I=ut(p,t,y={},i[3],ot),p&&(I.static=te,I.private=S,F=I.access={has:S?l=>mt(s,l):l=>t in l},p^3&&(F.get=S?l=>(p^1?Re:dt)(l,s,p^4?n:g.get):l=>l[t]),p>2&&(F.set=S?(l,ie)=>Ae(l,s,ie,p^4?n:g.set):(l,ie)=>l[t]=ie)),c=(0,r[se])(p?p<4?S?n:g[be]:p>4?void 0:{get:g.get,set:g.set}:s,I),y._=1,p^4||c===void 0?_(c)&&(p>4?Pe.unshift(c):p?S?n=c:g[be]=c:s=c):typeof c!="object"||c===null?B("Object expected"):(_(a=c.get)&&(g.get=a),_(a=c.set)&&(g.set=a),_(a=c.init)&&Pe.unshift(a));return p||ft(i,s),g&&ne(s,t,g),S?p^4?n:g:s};var oe=(i,e,t)=>e.has(i)||B("Cannot "+t),mt=(i,e)=>Object(e)!==e?B('Cannot use the "in" operator on this value'):i.has(e),Re=(i,e,t)=>(oe(i,e,"read from private field"),t?t.call(i):e.get(i));var Ae=(i,e,t,r)=>(oe(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),dt=(i,e,t)=>(oe(i,e,"access private method"),t);import{dirname as St,join as It,relative as Oe}from"path";var ae=new Map,$e=new Map;function E(i){return function(e){$e.set(e,i||{})}}o(E,"Injectable");function f(i,...e){if(ae.has(i))return ae.get(i);let t=$e.get(i);if(!t)throw new Error(`Cannot inject ${i.name} \u2013 not marked @Injectable`);let r=t.factory?t.factory(...e):new i(...e);return t?.scope==="singleton"&&ae.set(i,r),r}o(f,"inject");import{xterm as ue}from"@remotex-labs/xansi/xterm.component";import lt from"url";import{dirname as ht}from"path";import{normalize as ce}from"path";import{readFileSync as gt}from"fs";import{SourceService as yt}from"@remotex-labs/xmap";var Me,pe;Me=[E({scope:"singleton"})];var u=class{static{o(this,"FrameworkService")}filePath;distPath;rootPath;frameworkSourceMap;sourceMaps=new Map;constructor(){this.filePath=lt.fileURLToPath(import.meta.url),this.setSourceFile(this.filePath),this.frameworkSourceMap=this.getSourceMap(this.filePath),this.rootPath=this.getRootDir(),this.distPath=this.getDistDir()}isFrameworkFile(e){let{source:t,sourceRoot:r}=e,s=t?.toLowerCase();return!!(t&&s.includes("xjet")&&!s.includes("xjet.config")||r&&r.includes("xJet"))}getSourceMap(e){if(e=ce(e),this.sourceMaps.has(e))return this.sourceMaps.get(e)}setSource(e,t){let r=ce(t);try{return this.initializeSourceMap(e,r)}catch(s){throw new Error(`Failed to initialize SourceService: ${r}
3
+ ${s instanceof Error?s.message:String(s)}`)}}setSourceFile(e){let t=ce(e),r=`${e}.map`;if(!this.sourceMaps.has(t))try{let s=gt(r,"utf-8");return this.initializeSourceMap(s,t)}catch(s){throw new Error(`Failed to initialize SourceService: ${t}
4
+ ${s instanceof Error?s.message:String(s)}`)}}getRootDir(){return process.cwd()}getDistDir(){return ht(this.filePath)}initializeSourceMap(e,t){if(e?.includes('"mappings": ""'))return;let r=new yt(e,this.filePath);this.sourceMaps.set(t,r)}};pe=k(null),u=v(pe,0,"FrameworkService",Me,u),x(pe,1,u);import{Bias as kt}from"@remotex-labs/xmap";import{highlightCode as xt}from"@remotex-labs/xmap/highlighter.component";import{parseErrorStack as vt}from"@remotex-labs/xmap/parser.component";import{formatErrorCode as Et}from"@remotex-labs/xmap/formatter.component";var Tt=/\s{2,}/g,wt=/^https?:\/\//,bt=/^file:\/\//;function fe(i){if(i.fileName?.includes(this.framework.rootPath)&&(i.fileName=Oe(this.framework.rootPath,i.fileName)),!i.fileName)return i.source??"";let e=i.line&&i.column?ue.gray(`[${i.line}:${i.column}]`):"";return`at ${i.functionName??""} ${ue.darkGray(i.fileName)} ${e}`.replace(Tt," ").trim()}o(fe,"formatStackFrame");function Pt(i,e){let{source:t,sourceRoot:r,line:s}=e;if(t){let n=t.lastIndexOf("http://"),a=t.lastIndexOf("https://");if(Math.max(n,a)!==-1)return`${t.substring(Math.max(n,a))}#L${s}`;if(wt.test(t))return`${t}#L${s}`;if(r){let c=Oe(St(this.framework.distPath),It(this.framework.distPath,t)).replace(/\\/g,"/");return`${r}${c}#L${s}`}return`${t}#L${s}`}return i.fileName?i.fileName.replace(bt,""):""}o(Pt,"getSourceLocation");function Rt(i){return Et({...i,code:xt(i.code)},{color:ue.brightPink})}o(Rt,"highlightPositionCode");function At(i,e){return this.code||(this.code=e.code,this.source=e.source,this.formatCode=Rt(e)),fe.call(this,{...i,line:e.line,column:e.column,functionName:e.name??i.functionName,fileName:Pt.call(this,i,e)})}o(At,"formatFrameWithPosition");function Ct(i,e){if(!this.withNativeFrames&&i.native||!i.line&&!i.column&&!i.fileName&&!i.functionName)return"";let t=this.framework.getSourceMap(i.fileName??"");if(!t)return fe.call(this,i);let r=t.getPositionWithCode(i.line??0,i.column??0,kt.LOWER_BOUND,e);return r&&!this.withFrameworkFrames&&this.framework.isFrameworkFile(r)?"":r?(this.line=r.line,this.column=r.column,At.call(this,i,r)):fe.call(this,i)}o(Ct,"stackEntry");function me(i,e={}){let t={code:"",source:"",framework:f(u),formatCode:"",withNativeFrames:!1,withFrameworkFrames:!1,...e,...globalThis.VERBOSE&&{withNativeFrames:!0,withFrameworkFrames:!0}};return{stacks:vt(i).stack.map(n=>Ct.call(t,n,e)).filter(Boolean),code:t.code,line:t.line??0,column:t.column??0,source:t.source,formatCode:t.formatCode}}o(me,"parseStackTrace");function J(i,e={}){let t=me(i,e),r=[`
5
+ ${i.name}: ${i.message}
6
+
7
+ `];return t.formatCode&&r.push(`${t.formatCode}
8
+
9
+ `),t.stacks.length>0&&r.push(`Enhanced Stack Trace:
10
+ ${t.stacks.join(`
11
+ `)}
12
+ `),r.join("")}o(J,"formatStack");function U(i,e={}){let t=me(i,e);return t.stacks.length<1&&(t=me(i,{withFrameworkFrames:!0})),{code:t.code,line:t.line,column:t.column,source:t.source,stacks:" "+t.stacks.join(`
13
+ `),formatCode:t.formatCode}}o(U,"stackMetadata");var h=class extends Error{static{o(this,"xJetBaseError")}formattedStack;constructor(e,t="xJetError"){super(e),Object.setPrototypeOf(this,new.target.prototype),this.name=t,Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}get formatStack(){return this.formattedStack}toJSON(){let e={};for(let t of Object.keys(this)){let r=this[t];r&&(e[t]=r)}return e.name=this.name,e.stack=this.stack,e.message=this.message,e}[Symbol.for("nodejs.util.inspect.custom")](){return this.formattedStack??this.stack}reformatStack(e,t){this.formattedStack=J(e,t)}};function De(i){if(i instanceof AggregateError){console.error("AggregateError:",i.message);for(let e of i.errors)e instanceof Error&&!(e instanceof h)?console.error(J(e,{withFrameworkFrames:!0,withNativeFrames:!0})):console.error(e);return}i instanceof Error&&!(i instanceof h)?console.error(J(i,{withFrameworkFrames:!0,withNativeFrames:!0})):console.error(i)}o(De,"formatErrors");process.on("uncaughtException",i=>{De(i),process.exit(2)});process.on("unhandledRejection",i=>{De(i),process.exit(2)});import Be from"yargs";import{resolve as Ut}from"path";import{hideBin as Gt}from"yargs/helpers";import{xterm as je}from"@remotex-labs/xansi/xterm.component";var Ft=`
14
+ ___ _
15
+ |_ | | |
16
+ __ __ | | ___| |_
17
+ \\ \\/ / | |/ _ \\ __|
18
+ > </\\__/ / __/ |_
19
+ /_/\\_\\____/ \\___|\\__|
20
+ `;function G(){return`${je.burntOrange(Ft)}
21
+ Version: ${je.brightPink("1.0.0")}
22
+ `}o(G,"bannerComponent");import{existsSync as qt}from"fs";import{version as $t}from"process";var Le={bail:!1,files:["**/*.test.ts","**/*.spec.ts"],watch:!1,suites:[],filter:[],verbose:!1,timeout:5e3,parallel:1,exclude:[/node_modules/],reporter:"default",randomize:!1,build:{target:[`node${$t.slice(1)}`],packages:"bundle",platform:"browser",external:[]}};import{dirname as Bt}from"path";import{createRequire as Jt}from"module";import{Script as Mt,createContext as Ot}from"vm";async function $(i,e={},t={}){let r=new Mt(i,t),s=Ot(e);return await r.runInContext(s,{breakOnSigint:!0,displayErrors:!1})}o($,"sandboxExecute");var b=class i extends h{constructor(t,r){if(t instanceof h)return t;super(t.message,"VMRuntimeError");this.originalError=t;t instanceof AggregateError&&Array.isArray(t.errors)&&(this.errors=t.errors.map(s=>new i(s,r))),this.stack=t.stack,this.message=t.message,this.reformatStack(t,r)}static{o(this,"VMRuntimeError")}errors=[];[Symbol.for("nodejs.util.inspect.custom")](){if(this.errors&&this.errors.length>0){let t=this.errors.map(r=>`${r.formattedStack??r.stack}`).join("");return`VMRuntimeError Contains ${this.errors.length} nested errors:
23
+ ${t}
24
+ `}return this.formattedStack??this.stack}};import{cwd as Ne}from"process";import{build as Lt}from"esbuild";var d=class extends h{static{o(this,"xJetError")}constructor(e,t={withFrameworkFrames:!0}){super(e),this.reformatStack(this,t)}};import{xterm as de}from"@remotex-labs/xansi/xterm.component";import{formatCode as Dt}from"@remotex-labs/xmap/formatter.component";import{highlightCode as jt}from"@remotex-labs/xmap/highlighter.component";var z=class extends h{static{o(this,"esBuildError")}constructor(e){super("esBuildError build failed","esBuildError"),e.aggregateErrors?this.formatAggregateErrors(e.aggregateErrors):this.reformatStack(e,{withFrameworkFrames:!0})}formatAggregateErrors(e){this.formattedStack="";for(let t of e)this.formattedStack+=`
25
+ ${this.name}:
26
+ ${de.lightCoral(`${t.text}: ${t.notes.pop()?.text}`)}
27
+
28
+ `,this.formattedStack+=Dt(jt(t.location.lineText.trim()),{startLine:t.location.line}),this.formattedStack+=`
29
+
30
+ `,this.formattedStack+=`at ${de.dim(t.location.file)} ${de.gray(`[${t.location.line}:${t.location.column}]`)}
31
+
32
+ `}};var Nt={write:!1,bundle:!0,minify:!0,outdir:`${Ne()}`,format:"esm",target:"esnext",platform:"browser",sourcemap:"external",mangleQuoted:!0,sourcesContent:!0,preserveSymlinks:!0};async function _t(i,e={}){try{return await Lt({absWorkingDir:Ne(),...Nt,...e,metafile:!0,entryPoints:i})}catch(t){throw new z(t)}}o(_t,"buildFiles");async function le(i,e={}){let t=await _t(i,e),r=[],s=t.outputFiles??[],n=f(u);for(let a of s){let c=a.path.replace(/\.(map)$/,""),y=a.path.endsWith(".js.map"),I=a.path.endsWith(".js");y?n.setSource(a.text,c):I&&r.push({path:c,code:a.text+`//# sourceURL=${c}`})}return r}o(le,"transpileFiles");async function W(i,e={}){let r=(await le([i],e)).shift();if(!r)throw new d("Failed to transpile file: No output generated");return r}o(W,"transpileFile");async function _e(i){let e={minify:!1,format:"cjs",outdir:Bt(i),platform:"node",logLevel:"silent",packages:"external",minifySyntax:!0,preserveSymlinks:!0,minifyWhitespace:!0,minifyIdentifiers:!1},t={exports:{}},{code:r,path:s}=await W(i,e),n=Jt(s);try{await $(r,{Error,module:t,Buffer,RegExp,require:n,console,setTimeout,setInterval},{filename:s})}catch(a){throw a instanceof Error?new b(a):a}return t.exports.default??{}}o(_e,"parseConfigurationFile");async function X(i="",e){let t={...Le};if(i&&qt(i)){let r=await _e(i);r&&(t={...t,...r,exclude:[...t.exclude??[],...r.exclude??[]]})}return{...t,...e}}o(X,"configuration");var zt="xJet/config.xjet.ts",he={files:{describe:"Glob patterns or file paths used to discover test files",type:"string",array:!0},suites:{alias:"s",describe:"Filter pattern for test suite files. Only matching files from `files` will run.",type:"string",array:!0},filter:{alias:"f",describe:"Run only tests or suites matching these names",type:"string",array:!0},config:{alias:"c",describe:"Path to xJet configuration file (.ts or .js)",type:"string",default:zt,normalize:!0,coerce:o(i=>Ut(i),"coerce")},reporter:{alias:"r",describe:'Reporter for test results. Built-in: "spec", "json", "junit". Can also be a custom module path.',type:"string"},outputFile:{describe:'Optional file path to write reporter output (e.g., "reports/junit.xml")',type:"string"},verbose:{alias:"v",describe:"Include full stack traces, including internal frames",type:"boolean"},logLevel:{alias:"l",describe:"Set the logging verbosity level (Silent, Error, Warn, Info, Debug)",type:"string",choices:["Silent","Error","Warn","Info","Debug"]},timeout:{alias:"t",describe:"Maximum time (ms) a single test can run before failing",type:"number"},bail:{alias:"b",describe:"Stop running tests after the first failure",type:"boolean"},watch:{alias:"w",describe:"Watch files for changes and re-run tests automatically",type:"boolean"},randomize:{describe:"Randomize the order of test execution",type:"boolean"}},Wt=[["xJet --config ./xjet.config.ts","Run tests with custom configuration"],['xJet --filter "auth.*" --verbose',"Run auth-related tests with verbose logging"],['xJet --suites "src/**/*.test.ts"',"Run specific test suites"],['xJet --files "src/**/*.test.ts"',"Run pattern to collect test files"],["xJet --watch --coverage","Run tests in watch mode with coverage"]];async function Xt(){let i=Be(process.argv).options({config:he.config}).parseSync();return(await X(i.config,i)).userArgv??{}}o(Xt,"getUserArgv");async function Je(i){let e=await Xt(),t=Be(Gt(i)),r=t.showHelp;t.showHelp=function(n){return console.log(G()),this.group(Object.keys(he),"xJet Options:"),this.group(Object.keys(e),"user Options:"),r.call(this,n)};let s=t.usage("Usage: xJet [files..] [options]").command("* [files..]","Specific test files to run (supports glob patterns)",n=>n.positional("files",{describe:"Specific test files to run (supports glob patterns)",type:"string",array:!0})).options(e).options(he).epilogue("For more information, check the documentation").help().alias("help","h").strict().version();return Wt.forEach(([n,a])=>{s.example(n,a)}),s.parseSync()}o(Je,"parseArguments");import{join as jr}from"path";import{exit as we}from"process";import{accessSync as pr}from"fs";import{readFile as ur,watch as fr}from"fs/promises";import{dirname as mr,join as dr,normalize as lr}from"path";import{join as Kt,relative as Ht}from"path";import{existsSync as Vt,readdirSync as Qt}from"fs";function ge(i){return Ht(f(u).rootPath,i)}o(ge,"getRelativePath");function qe(i,e,t,r,s={}){if(!Vt(i))return{};let n=Qt(i,{withFileTypes:!0});for(let a of n){let c=Kt(i,a.name),y=ge(c);if(T(y,t))continue;if(a.isDirectory()){qe(c,e,t,r,s);continue}if((r.length===0||T(y,r))&&T(c,e)){let F=y,p=F.replace(/\.[^/.]+$/,"");s[p]=F}}return s}o(qe,"collectFilesFromDir");function Ue(i,e){let t=P(e?.suites??[]),r=P(e?.files??[]),s=P(e?.exclude??[]);return qe(i,r,s,t)}o(Ue,"getSpecFiles");var Yt=/\?/g,Zt=/\{([^}]+)\}/g,er=/(?:\/|^)\*{2}(?:\/|$)/g,tr=/(?<!\.)\*/g,rr=/\\\[([^\]]+)\\\]/g,sr=/[.+$|[\]\\]/g;function ir(i){let e=o(r=>r.replace(sr,"\\$&"),"escapeRegexChars"),t=o(r=>r.replace(Yt,".").replace(er,".*/?").replace(tr,"[^/]+").replace(rr,(s,n)=>`[${n}]`).replace(Zt,(s,n)=>`(${n.split(",").join("|")})`),"convertGlobToRegex");return new RegExp(`^${t(e(i))}$`)}o(ir,"compileGlobPattern");function nr(i){let e=/[*?[\]{}!@+()|\]]/.test(i),t=/{[^}]+}/.test(i),r=/@\([^)]+\)/.test(i);return e||t||r}o(nr,"isGlob");function T(i,e){return e.some(t=>t.test(i))}o(T,"matchesAny");function P(i){return i.map(e=>{if(e instanceof RegExp)return e;if(nr(e))return ir(e);let t=ge(e).replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return new RegExp(`^${t}$`)})}o(P,"compilePatterns");import{relative as Ge}from"path";import{readFileSync as or}from"fs";import{pathToFileURL as ar}from"url";import{createRequire as cr}from"module";var ze=new Map;function We(i="tsconfig.json"){let e=or(i,"utf8"),r=JSON.parse(e).compilerOptions?.paths;if(r)for(let[s,n]of Object.entries(r))Array.isArray(n)&&n.length>0&&ze.set(s.replace("*",""),n[0].replace("*",""))}o(We,"updateAliases");function Xe(i){let e=f(u);for(let[t,r]of ze.entries())if(i.includes(t)){let s=i.replace(t,r);return Ge(e.rootPath,s)}try{let r=cr(ar(e.rootPath+"/__placeholder__.js").href).resolve(i);if(r)return Ge(e.rootPath,r)}catch{return}}o(Xe,"resolveImport");var K=class i{constructor(e,t,r){this.testsFile=t;this.exec=r;We(),this.patterns=P(e?.files??[]),this.excludes=P(e?.exclude??[])}static{o(this,"WatchService")}static IMPORT_REGEX=/(?:from|import)\s+['"](?<path>[^'"]+)['"]/g;static FILE_EXTENSION_REGEX=/\.[^/.]+$/;framework=f(u);dependencyGraph=new Map;dependenciesCache=new Map;debounceTimer=null;patterns;excludes;async init(){await Promise.all(Object.values(this.testsFile).map(r=>this.updateGraph(r)));let e=new Set,t=fr(this.framework.rootPath,{recursive:!0});for await(let{filename:r}of t){if(!r)continue;let s=lr(r);T(s,this.excludes)||(e.add(s),this.debounce(()=>this.handleChangedFiles([...e],e)))}}debounce(e,t=400){this.debounceTimer&&clearTimeout(this.debounceTimer),this.debounceTimer=setTimeout(e,t)}fileExists(e){try{return pr(e),!0}catch{return!1}}removeFileFromGraph(e){this.dependencyGraph.delete(e),this.dependenciesCache.delete(e);for(let t of this.dependencyGraph.values())t.delete(e)}async handleChangedFiles(e,t){t.clear();let r={};for(let s of e){if(!this.fileExists(s)){this.removeFileFromGraph(s);continue}if(T(s,this.patterns)){await this.updateGraph(s);let n=s.replace(i.FILE_EXTENSION_REGEX,"");r[n]=s}this.dependencyGraph.has(s)&&(await this.updateGraph(s),this.dependencyGraph.get(s)?.forEach(n=>{let a=n.replace(i.FILE_EXTENSION_REGEX,"");r[a]=n}))}Object.keys(r).length>0&&await this.exec(r)}async getTestDependencies(e,t=!1){if(!t&&this.dependenciesCache.has(e))return this.dependenciesCache.get(e);try{let r=await ur(e,"utf-8"),s=[];for(let n of r.matchAll(i.IMPORT_REGEX)){let a=n.groups?.path;if(!a)continue;let c=Xe(a)??dr(mr(e),a);s.push(c.endsWith(".ts")?c:`${c}.ts`)}return this.dependenciesCache.set(e,s),s}catch{return this.dependenciesCache.set(e,[]),[]}}async linkDependency(e,t){for(let r of t){let s=this.dependencyGraph.get(r)??new Set,n=s.size;if(e.forEach(a=>s.add(a)),this.dependencyGraph.has(r)||this.dependencyGraph.set(r,s),s.size>n){let a=await this.getTestDependencies(r);a.length>0&&await this.linkDependency(e,a)}}}async updateGraph(e){if(T(e,this.patterns)){let r=await this.getTestDependencies(e,!0);await this.linkDependency([e],r)}else if(this.dependencyGraph.has(e)){let r=[...this.dependencyGraph.get(e)],s=await this.getTestDependencies(e,!0);await this.linkDependency(r,s)}}};import{xterm as Z}from"@remotex-labs/xansi/xterm.component";import{existsSync as xr}from"fs";import{createRequire as vr}from"module";var M=(n=>(n[n.Silent=0]="Silent",n[n.Error=1]="Error",n[n.Warn=2]="Warn",n[n.Info=3]="Info",n[n.Debug=4]="Debug",n))(M||{});import{dirname as hr}from"path";import{mkdirSync as gr,writeFileSync as yr}from"fs";var O=class{constructor(e,t){this.logLevel=e;this.outFilePath=t}static{o(this,"AbstractReporter")}};var D=class extends O{static{o(this,"JsonReporter")}testResults={};init(e,t){for(let r of e)for(let s of t)this.testResults[s.name]=this.testResults[s.name]??{},this.testResults[s.name][r]={runner:s.name,suiteName:r,timestamp:new Date,rootDescribe:{tests:[],ancestry:[],describes:[],description:"",timestamp:new Date}}}suiteStart(e){let t=e.suite,r=e.runner;this.testResults[r][t]={runner:e.runner,suiteName:t,timestamp:e.timestamp,rootDescribe:{tests:[],ancestry:[],describes:[],description:"",timestamp:e.timestamp}}}suiteEnd(e){let t=this.getSuite(e.runner,e.suite);t.duration=e.duration,t.rootDescribe.duration=e.duration,e.error&&(t.errors=t.errors??[],t.errors.push(e.error))}describeStart(e){if(e.description==="")return;let t={tests:[],describes:[],skipped:e.skipped??!1,ancestry:e.ancestry,timestamp:e.timestamp,description:e.description},r=this.getSuite(e.runner,e.suite),s=this.findParentDescribe(r,e.ancestry);s?s.describes.push(t):r.rootDescribe.describes.push(t)}describeEnd(e){let t=this.getSuite(e.runner,e.suite),r=this.findParentDescribe(t,e.ancestry);r&&(e.errors&&e.errors.length>0&&(r.errors=r.errors??[],r.errors.push(...e.errors)),r.duration=e.duration)}testStart(e){if(!e.skipped&&!e.todo)return;let t=this.getSuite(e.runner,e.suite),r=this.findParentDescribe(t,e.ancestry);if(!r)return;let s={todo:e.todo,skipped:e.skipped,ancestry:e.ancestry,timestamp:e.timestamp,description:e.description};r.tests.push(s)}testEnd(e){let t=this.getSuite(e.runner,e.suite),r=this.findParentDescribe(t,e.ancestry);if(!r)return;let s={passed:e.passed,errors:e.errors??[],ancestry:e.ancestry,duration:e.duration,timestamp:e.timestamp,description:e.description};r.tests.push(s)}finish(){let e=JSON.stringify(this.testResults,null,4);if(this.outFilePath){let t=hr(this.outFilePath);gr(t,{recursive:!0}),yr(this.outFilePath,e)}console.log(e)}getSuite(e,t){if(!this.testResults[e]||!this.testResults[e][t])throw new Error(`Suite not found: ${e} -> ${t}`);return this.testResults[e][t]}findParentDescribe(e,t){if(t.length===0)return e.rootDescribe;let r=e.rootDescribe.describes??[],s;for(let n of t){if(s=r.find(a=>a.description===n),!s)return e.rootDescribe;r=s.describes}return s}};import{dirname as Sr}from"path";import{mkdirSync as Ir,writeFileSync as kr}from"fs";var H=class extends D{static{o(this,"JunitReporter")}xmlParts=['<?xml version="1.0" encoding="UTF-8"?>'];finish(){this.xmlParts.push("<testsuites>"),Object.entries(this.testResults).forEach(([t,r])=>{this.xmlParts.push(`<testsuites name="${t}">`),Object.values(r).forEach(s=>{this.convertSuiteToXml(s)}),this.xmlParts.push("</testsuites>")}),this.xmlParts.push("</testsuites>");let e=this.xmlParts.join(`
33
+ `);if(this.outFilePath){let t=Sr(this.outFilePath);Ir(t,{recursive:!0}),kr(this.outFilePath,e)}console.log(e)}convertSuiteToXml(e){let t=e.rootDescribe,r=this.countTests(t),s=this.countFailures(t),n=this.countSkipped(t),a=this.formatDuration(e.duration),c=[`name="${e.suiteName}"`,`tests="${r}"`,`failures="${s}"`,`skipped="${n}"`,`time="${a}"`].join(" ");this.xmlParts.push(`<testsuite ${c}>`),this.convertDescribeToXml(t),this.xmlParts.push("</testsuite>")}convertDescribeToXml(e){e.tests.forEach(t=>this.convertTestToXml(t)),e.describes.forEach(t=>this.convertDescribeToXml(t))}convertTestToXml(e){let t=this.formatDuration(e.duration),r=e.description,n=`classname="${e.ancestry.join(".")||"root"}" name="${r}" time="${t}"`;if(e.skipped||e.todo){let c=e.todo?"TODO":"Skipped";this.xmlParts.push(`<testcase ${n}><skipped message="${c}" /></testcase>`);return}if(e.passed){this.xmlParts.push(`<testcase ${n} />`);return}let a=this.formatErrors(e.errors);this.xmlParts.push(`<testcase ${n}>${a}</testcase>`)}formatErrors(e){return e?.length?e.map(t=>`<failure message="${t.name}">${this.escapeXml(t.message)}
34
+ ${t.formatCode}
35
+
36
+ ${this.escapeXml(t.stack)}</failure>`).join(""):""}formatDuration(e){return((e??0)/1e3).toFixed(3)}countTests(e){return e.tests.length+e.describes.reduce((t,r)=>t+this.countTests(r),0)}countSkipped(e){return e.tests.filter(r=>r.skipped||r.todo).length+e.describes.reduce((r,s)=>r+this.countSkipped(s),0)}countFailures(e){return e.tests.filter(r=>!r.passed&&!r.skipped&&!r.todo).length+e.describes.reduce((r,s)=>r+this.countFailures(s),0)}escapeXml(e){return e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&apos;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}};import{ANSI as ye,writeRaw as He}from"@remotex-labs/xansi";import{xterm as w}from"@remotex-labs/xansi/xterm.component";import{ShadowRenderer as Ve}from"@remotex-labs/xansi/shadow.service";import{xterm as j}from"@remotex-labs/xansi/xterm.component";var V=4,m={todo:j.hex("#da5aec"),failed:j.hex("#F08080"),passed:j.hex("#90EE90"),skipped:j.hex("#fcaa63"),running:j.hex("#FFD966"),pending:j.hex("#808080")},Ke={5:m.pending("[ Pending ]"),0:m.running("[ RUNNING ]"),4:m.skipped("[ SKIPPED ]"),3:m.passed("[ PASSED ]"),2:m.failed("[ FAILED ]")};var q=class extends O{static{o(this,"ConsoleReporter")}startTime=Date.now();isSingleRunner=!1;updateInterval;maxRunnerNameLength=0;info;status;tests=this.createTests();suites=this.createSuites();suiteMap=new Map;constructor(e,t){super(e,t);let r=process.stdout.rows??24,s=process.stdout.columns??80;this.info=new Ve(r-V-1,s,1,0),this.status=new Ve(V,s,r-V,0)}init(e,t){He(ye.HIDE_CURSOR),He(ye.CLEAR_SCREEN_UP),this.suiteMap.clear(),this.startTime=Date.now(),this.tests=this.createTests(),this.suites=this.createSuites(),this.isSingleRunner=t.length<2,this.updateInterval=setInterval(this.updateState.bind(this),230),this.maxRunnerNameLength=Math.max(...t.map(r=>r.name.length));for(let r of e)for(let s of t){let n=this.getSuiteKey(s.name,r),a=this.getPrefix(5,s.name,r);this.suiteMap.set(n,{todo:0,total:0,passed:0,failed:0,skipped:0,title:a,details:[]})}this.renderSuites()}log(e){if(e.levelId>this.logLevel||this.logLevel===0)return;let t=this.ensureSuite(e.runner,e.suite),r=[""];r.push(this.getLogPrefix(e)+w.gray(` [${e.ancestry.join(" > ")}]`)),r.push(...e.message.split(`
37
+ `).map(s=>" ".repeat(2)+s)),e.invocation&&r.push(w.gray(`at (${e.invocation.source}:${e.invocation.line}:${e.invocation.column})`));for(let s of r)t.details.push(s);t.details.push(""),this.renderSuites()}suiteStart(e){let t=this.ensureSuite(e.runner,e.suite);t.title=this.getPrefix(0,e.runner,e.suite),this.renderSuites()}suiteEnd(e){this.suites.total+=1;let t=this.ensureSuite(e.runner,e.suite),r=3;e.error?(this.suites.failed+=1,r=2):t.total===t.skipped+t.todo?(this.suites.skipped+=1,r=4):t.failed>0?(this.suites.failed+=1,r=2):this.suites.passed+=1;let s=this.getPrefix(r,e.runner,e.suite);s+=` ${(e.duration/1e3).toFixed(3)} s`,t.title=s,e.error&&t.details.push(...this.parseError(e.error)),this.renderSuites()}describeEnd(e){let t=this.ensureSuite(e.runner,e.suite);if(e.errors?.length){t.failed+=1;for(let r of e.errors)t.details.push(...this.parseError(r))}}testStart(e){let t=this.ensureSuite(e.runner,e.suite);(e.todo||e.skipped)&&this.incrementTestCounters(e.todo?"todo":"skipped",t)}testEnd(e){let t=this.ensureSuite(e.runner,e.suite);if(e.errors&&e.errors.length>0){this.incrementTestCounters("failed",t);let r=m.failed(`\u25CF ${e.ancestry.join(" > ")} > ${e.description}`);r+=w.gray(` (${(e.duration/1e3).toFixed(3)} s)`),t.details.push(r);for(let s of e.errors)t.details.push(...this.parseError(s))}else this.incrementTestCounters("passed",t)}finish(){this.updateInterval?.close(),this.updateState(),this.info.clearScreen(),this.status.clearScreen(),this.info.flushToTerminal(),this.status.flushToTerminal()}getSuiteKey(e,t){return`${e}::${t}`}ensureSuite(e,t){return this.suiteMap.get(this.getSuiteKey(e,t))}createTests(){return{total:0,passed:0,failed:0,skipped:0,todo:0}}createSuites(){return{total:0,passed:0,failed:0,skipped:0}}parseError(e){let t=["",...e.message.split(`
38
+ `),""];return t.push(...e.formatCode.split(`
39
+ `).map(r=>w.dim(r)),""),t.push(...e.stack.split(`
40
+ `),""),t}incrementTestCounters(e,t){t.total+=1,this.tests.total+=1,t[e]+=1,this.tests[e]+=1}updateState(){let e=[],t=[];this.suites.failed>0&&e.push(m.failed(`${this.suites.failed} failed`)),this.suites.passed>0&&e.push(m.passed(`${this.suites.passed} passed`)),this.suites.skipped>0&&e.push(m.skipped(`${this.suites.skipped} skipped`)),this.suites.total>0&&e.push(`${this.suites.total} total`),this.tests.failed>0&&t.push(m.failed(`${this.tests.failed} failed`)),this.tests.passed>0&&t.push(m.passed(`${this.tests.passed} passed`)),this.tests.skipped>0&&t.push(m.skipped(`${this.tests.skipped} skipped`)),this.tests.todo>0&&t.push(m.todo(`${this.tests.todo} todo`)),this.tests.total>0&&t.push(`${this.tests.total} total`);let r=((Date.now()-this.startTime)/1e3).toFixed(3);this.status.writeBlock(0,0,`Suites: ${e.length?e.join(", "):"No suites yet"}
41
+ Tests: ${t.length?t.join(", "):"No tests yet"}
42
+ Time: ${w.lightOrange(`${r} s`)}`,!0),this.status.render()}renderSuites(){let e=0;for(let[,t]of this.suiteMap){this.info.writeText(e++,0,t.title,!0);for(let r of t.details)this.info.writeText(e++,2,ye.CLEAR_LINE+r,!0)}e>this.info.height?this.info.scroll=e-this.info.height:this.info.render(),this.updateState()}getPrefix(e,t,r){let s=this.isSingleRunner?"":w.burntOrange(` [ ${t.padEnd(this.maxRunnerNameLength)} ]`);return`${Ke[e]}${s} ${w.dim(r)}`}getLogPrefix(e){let t=m.pending;switch(e.levelId){case 1:t=m.failed;break;case 2:t=m.skipped;break;case 3:t=w.cyanBright;break;case 4:t=m.running;break}return t(`[ ${e.level.toLowerCase()} ]`)}};async function Er(i){return W(i,{minify:!1,format:"cjs",platform:"node",logLevel:"silent",packages:"external"})}o(Er,"transpile");async function Tr(i){let{code:e,path:t}=await Er(i);try{let r={exports:{default:void 0}},s=vr(t),n={Error,Buffer,RegExp,module:r,process,console,require:s,setTimeout,setInterval};return await $(e,n,{filename:t}),r.exports.default}catch(r){throw new b(r)}}o(Tr,"parseExternalReporter");async function Qe(i){let{reporter:e,outputFile:t}=i,r={json:D,junit:H,default:q};if(r[e]||!xr(e)){let n=r[e]||q;return new n(M[i.logLevel]??0,t)}let s=await Tr(e);if(!s)throw new d(`Reporter at "${e}" does not have a valid default export`);if(typeof s!="function")throw new d(`Reporter at "${e}" is not a valid constructor`);try{return new s(4,t)}catch(n){throw new b(n)}}o(Qe,"getReporter");var Q=class{constructor(e,t){this.target=e;this.reporter=t;this.target.on("log",this.handleLog.bind(this)),this.target.on("error",this.handleSuiteError.bind(this)),this.target.on("status",this.handleSuiteStatus.bind(this)),this.target.on("events",this.handleSuiteEvent.bind(this))}static{o(this,"MessageService")}framework=f(u);error=!1;suiteError=!1;get hasSuiteError(){return this.suiteError}get hasError(){return this.error}handleLog(e,t){let s=this.framework.getSourceMap(e.invocation.source)?.getPositionWithCode(e.invocation.line,e.invocation.column),n={level:M[e.level]??"UNKNOWN",suite:t,runner:this.target.getRunnerName(e.runnerId),levelId:e.level,message:e.message,ancestry:e.ancestry.split(","),timestamp:new Date(e.timestamp)};s&&(n.invocation={code:s.code,line:s.line,column:s.column,source:s.source}),this.reporter.log?.(n)}handleSuiteError(e,t){this.target.completeSuite(e.runnerId+e.suiteId,!0);let r={suite:t,error:this.decodeError(e.error,{linesBefore:2,linesAfter:3}),runner:this.target.getRunnerName(e.runnerId),duration:0,timestamp:new Date(e.timestamp)};this.suiteError=!0,this.reporter.suiteEnd?.(r)}handleSuiteStatus(e,t){let r={suite:t,runner:this.target.getRunnerName(e.runnerId),timestamp:new Date(e.timestamp)};switch(e.type){case 4:this.reporter.suiteStart?.(r);break;case 3:this.target.completeSuite(e.runnerId+e.suiteId,!1),r.duration=e.duration,this.reporter.suiteEnd?.(r);break;case 1:case 2:{let s=r;s.ancestry=e.ancestry.split(","),s.description=e.description,e.todo&&(s.todo=!0),e.skipped&&(s.skipped=!0),e.type===1?this.reporter.testStart?.(s):this.reporter.describeStart?.(s);break}}}handleSuiteEvent(e,t){let r={suite:t,passed:!0,runner:this.target.getRunnerName(e.runnerId),duration:e.duration,ancestry:e.ancestry.split(","),timestamp:new Date(e.timestamp),description:e.description};e.errors&&(r.errors=this.decodeError(e.errors,{linesBefore:2,linesAfter:3}),r.passed=!1,this.error=!0),e.type===1?this.reporter.testEnd?.(r):this.reporter.describeEnd?.(r)}decodeError(e,t={}){try{let r=JSON.parse(e);return Array.isArray(r)?r.map(s=>this.structuredError(s,U(s,t))):this.structuredError(r,U(r,t))}catch(r){return this.structuredError(r,U(r,t))}}structuredError(e,t){return{name:e.name,line:t.line,code:t.code,formatCode:t.formatCode,stack:t.stacks,column:t.column,message:e.message,matcherResult:e.matcherResult}}};import{relative as Pr}from"path";import*as Rr from"process";import{createRequire as Ar}from"module";import{serializeError as Cr}from"@remotex-labs/xjet-expect";import br from"events";import{serializeError as Fn}from"@remotex-labs/xjet-expect";import{Struct as L}from"@remotex-labs/xstruct";var wr=new L({line:"UInt32LE",column:"UInt32LE",source:"string"}),Se=new L({kind:"UInt8:4",suiteId:{type:"string",size:14},runnerId:{type:"string",size:14},timestamp:"string"}),Ye=new L({level:"UInt8",message:{type:"string",lengthType:"UInt32LE"},ancestry:{type:"string",lengthType:"UInt32LE"},invocation:wr}),Ie=new L({error:{type:"string",lengthType:"UInt32LE"}}),Ze=new L({type:"UInt8:5",todo:"UInt8:1",skipped:"UInt8:1",duration:"UInt32LE",ancestry:{type:"string",lengthType:"UInt32LE"},description:{type:"string",lengthType:"UInt32LE"}}),et=new L({type:"UInt8:5",passed:"UInt8:1",duration:"UInt32LE",ancestry:{type:"string",lengthType:"UInt32LE"},description:{type:"string",lengthType:"UInt32LE"},errors:{type:"string",lengthType:"UInt32LE"}});var tt={1:Ye,2:Ie,3:Ze,4:et};function rt(i){let e=Se.size,t=Se.toObject(i,c=>{e+=c}),r=t.kind,s=tt[r];if(!s)throw new Error(`Unknown packet kind: ${r}`);let n=i.subarray(e),a=s.toObject(n);return{...t,...a}}o(rt,"decodePacket");var st,xe;st=[E({scope:"singleton"})];var R=class{static{o(this,"QueueService")}paused=!0;activeCount=0;concurrencyLimit;queue=[];constructor(e){this.concurrencyLimit=e&&e>0?e:1}get size(){return this.queue.length}get running(){return this.activeCount}get isPaused(){return this.paused}stop(){this.paused=!0}start(){this.paused&&(this.paused=!1,this.processQueue())}clear(){let e=this.queue.length;return this.queue.forEach(t=>{"reject"in t&&t.reject()}),this.queue=[],e}enqueue(e,t){return new Promise((r,s)=>{let n=o(async()=>{try{let a=await e();r(a)}catch(a){s(a)}finally{this.activeCount--,this.processQueue()}},"wrappedTask");this.queue.push({task:n,runnerId:t,reject:s,resolve:r}),this.paused||this.processQueue()})}removeTasksByRunner(e){let t=this.queue.length;return this.queue=this.queue.filter(r=>r.runnerId!==e),t-this.queue.length}processQueue(){if(!this.paused)for(;this.activeCount<this.concurrencyLimit&&this.queue.length>0;){let e=this.queue.shift();e&&(this.activeCount++,e.task())}}};xe=k(null),R=v(xe,0,"QueueService",st,R),x(xe,1,R);var N=class{constructor(e){this.config=e;this.queue=new R(this.config.parallel)}static{o(this,"AbstractTarget")}queue;runningSuites=new Map;suites=new Map;eventEmitter=new br;framework=f(u);get numberActiveTask(){return this.queue.size}on(e,t){return this.eventEmitter.on(e,t),this}completeSuite(e,t=!1){let r=this.runningSuites.get(e);r&&(this.runningSuites.delete(e),t&&this.config.bail?(this.queue.stop(),this.queue.clear(),r.reject()):r.resolve())}dispatch(e){let t=rt(e),r=this.suites.get(t.suiteId);if(!r)throw new d(`Runner '${t.runnerId}' in test suite '${t.suiteId}' is not registered`);switch(t.kind){case 1:this.eventEmitter.emit("log",t,r);break;case 2:this.completeSuite(t.runnerId+t.suiteId,!0),this.eventEmitter.emit("error",t,r);break;case 3:this.eventEmitter.emit("status",t,r);break;case 4:this.eventEmitter.emit("events",t,r);break;default:let s=`Invalid schema type '${t.kind}' detected for runner '${t.runnerId}' in test suite '${t.suiteId}'`;throw new d(s)}}generateId(){return Math.random().toString(36).substring(2,9)+Math.random().toString(36).substring(2,9)}setSuites(e){if(this.suites.clear(),!e)throw new d("Suites must be provided to register them in the target");for(let[t,r]of Object.entries(e)){let s=this.generateId();this.suites.set(s,r),this.suites.set(t,s)}}};var it,ve,Fr;it=[E({scope:"singleton"})];var A=class extends(Fr=N){static{o(this,"LocalService")}runnerId=this.generateId();getRunnerName(){return"local"}getRunners(){return[{id:this.runnerId,name:this.getRunnerName()}]}async executeSuites(e,t){this.setSuites(t);let r=[];for(let s of e){let n=Pr(this.framework.rootPath,s.path).replace(/\.[^/.]+$/,"");r.push(this.queue.enqueue(async()=>this.executeTestWithErrorHandling(s.code,s.path,n)))}this.queue.start(),await Promise.allSettled(r)}async executeInSandbox(e,t,r){let s={exports:{}},n=Ar(t),a=Object.freeze({...Rr,stdout:{write:o(()=>{},"write")},stderr:{write:o(()=>{},"write")}}),c={Buffer,module:s,require:n,setTimeout,setInterval,clearTimeout,clearInterval,process:a,__XJET:{runtime:{bail:this.config.bail,path:this.suites.get(r),filter:this.config.filter,timeout:this.config.timeout,suiteId:r,runnerId:this.runnerId,randomize:this.config.randomize}},dispatch:this.dispatch.bind(this)};await $(e,c)}executeTestWithErrorHandling(e,t,r){let s=this.suites.get(r);return new Promise(async(n,a)=>{try{this.runningSuites.set(this.runnerId+s,{resolve:n,reject:a}),await this.executeInSandbox(e,t,s)}catch(c){this.completeSuite(this.runnerId+s,!0),this.eventEmitter.emit("error",{kind:2,error:JSON.stringify(Cr(c)),suiteId:s,runnerId:this.runnerId,timestamp:new Date},this.suites.get(s))}})}};ve=k(Fr),A=v(ve,0,"LocalService",it,A),x(ve,1,A);import $r from"yargs";import{relative as Mr}from"path";import{serializeError as Or}from"@remotex-labs/xjet-expect";var Y=class extends Error{static{o(this,"TimeoutError")}constructor(e,t,r=""){super(`Exceeded timeout of ${e} ms at ${t}`),Object.setPrototypeOf(this,new.target.prototype),this.name="xJetTimeoutError",Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name="xJetFailingError",r&&(this.stack=`${this.name}: ${this.message}
43
+ ${r}`)}};async function Ee(i,e,t,r){let s=typeof i=="function"?Promise.resolve(i()):Promise.resolve(i);if(e===-1||!globalThis?.setTimeout)return s;let n,a=new Promise((c,y)=>{n=globalThis?.setTimeout?.(()=>y(new Y(e,t,r)),e)});try{return await Promise.race([s,a])}finally{globalThis?.clearTimeout?.(n)}}o(Ee,"withTimeout");var nt,Te,Dr;nt=[E({scope:"singleton"})];var C=class extends(Dr=N){static{o(this,"ExternalService")}runners=new Map;async initTarget(){if(!this.config.testRunners||this.config.testRunners.length===0)throw new d("No test runners configured");let e={};this.config.userArgv&&(e=$r(process.argv.slice(2)).options(this.config.userArgv).parseSync()),await Promise.all(this.config.testRunners.map(t=>this.connectRunner(t,e)))}async freeTarget(){let e=[],t=Array.from(this.runners.values());for(let r=0;r<t.length;r++){let s=t[r];s?.disconnect&&e.push(s?.disconnect?.())}await Promise.allSettled(e)}getRunnerName(e){let t=this.runners.get(e)?.name;if(!t)throw new d(`Runner with ID "${e}" not found`);return t}getRunners(){return Array.from(this.runners.values()).map(e=>({id:e.id,name:e.name}))}async executeSuites(e,t){this.setSuites(t);let r=[];for(let s of e){let n=Mr(this.framework.rootPath,s.path).replace(/\.[^/.]+$/,"");this.runners.forEach((a,c)=>{r.push(this.queue.enqueue(async()=>this.executeTestWithErrorHandling(s.code,n,a),c))})}this.queue.start(),await Promise.allSettled(r)}async connectRunner(e,t){e.id=this.generateId(),await Ee(e.connect(this.dispatch.bind(this),e.id,t),e?.connectionTimeout??5e3,`connection of runner "${e.name}"`),this.runners.set(e.id,e)}executeTestWithErrorHandling(e,t,r){let s=this.suites.get(t);return new Promise(async(n,a)=>{try{this.runningSuites.set(r.id+s,{resolve:n,reject:a}),await this.executeInRunner(e,s,r)}catch(c){this.completeSuite(r.id+s,!0),this.eventEmitter.emit("error",{kind:2,error:JSON.stringify(Or(c)),suiteId:s,runnerId:r.id,timestamp:new Date},this.suites.get(s))}})}async executeInRunner(e,t,r){let s={runtime:{bail:this.config.bail,path:this.suites.get(t),filter:this.config.filter,timeout:this.config.timeout,suiteId:t,runnerId:r.id,randomize:this.config.randomize}},n=this.prepareTestCodeWithContext(e,s);await Ee(r?.dispatch?.(Buffer.from(n),t),r?.dispatchTimeout??5e3,`dispatch of runner "${r.name}"`)}prepareTestCodeWithContext(e,t){return`globalThis.__XJET = ${JSON.stringify(t)}; ${e}`}};Te=k(Dr),C=v(Te,0,"ExternalService",nt,C),x(Te,1,C);var Lr={js:`
44
+ `},Nr={js:"state.run({})"},ee=class{constructor(e){this.config=e;this.target=this.createTarget()}static{o(this,"SuitesService")}target;framework=f(u);async executeSuites(){let e=Ue(this.framework.rootPath,this.config);if(Object.keys(e).length===0)throw this.config.suites.length>0?Z.redBright("No test files found for ")+Z.greenBright(this.config.suites.join(", ")):Z.redBright("No test files found for ")+Z.greenBright(this.config.files.join(", "));await this.target.initTarget?.();let t=new Q(this.target,await Qe(this.config));await this.exec(t,e),this.config.watch&&await this.watchForChanges(t,e),await this.target.freeTarget?.(),t.hasError&&we(1),t.hasSuiteError&&we(2),we(0)}async exec(e,t){e.reporter.init?.(Object.values(t),e.target.getRunners());let r=await this.transpileSuites(t);await this.target.executeSuites(r,t),e.reporter.finish?.()}createTarget(){return this.config.testRunners&&this.config.testRunners.length>0?f(C,this.config):f(A,this.config)}async watchForChanges(e,t){await new K(this.config,t,this.exec.bind(this,e)).init()}async transpileSuites(e){return await le(e,{...this.config.build,banner:Lr,footer:Nr,format:"cjs",minify:!1,inject:[jr(this.framework.distPath,"shared.js")],logLevel:"silent",sourcemap:!0,keepNames:!0,minifySyntax:!0,preserveSymlinks:!0,minifyWhitespace:!0,minifyIdentifiers:!1})}};async function _r(i){let e=await Je(i);e.verbose&&(globalThis.VERBOSE=!0);let t=await X(e.config,e);t.verbose&&(globalThis.VERBOSE=!0),["json","junit"].includes(t.reporter)?globalThis.NO_COLOR=!0:console.log(G()),await new ee(t).executeSuites()}o(_r,"main");_r(process.argv);
45
+ //# sourceMappingURL=bash.js.map