jitar 0.12.0 → 0.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ConfigurationManager-DfsjmZaq.js +1 -0
- package/dist/cli.js +1 -1
- package/dist/client.js +1 -1
- package/dist/lib.js +1 -1
- package/dist/templates/backend/package.json +2 -2
- package/dist/templates/backend/services/standalone.json +1 -1
- package/dist/templates/react/package.json +12 -9
- package/dist/templates/react/services/standalone.json +2 -0
- package/dist/templates/vue/package.json +10 -7
- package/dist/templates/vue/services/standalone.json +2 -0
- package/dist/templates/vue/src/env.d.ts +1 -0
- package/package.json +13 -13
- package/dist/ConfigurationManager-CQWv0Wmk.js +0 -1
package/dist/client.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
class e extends Error{constructor(e="Invalid request"){super(e)}}class t extends Error{constructor(e="Forbidden"){super(e)}}class s extends Error{constructor(e="Not found"){super(e)}}class r extends Error{constructor(e="Not implemented"){super(e)}}class i extends Error{constructor(e="Payment required"){super(e)}}class n extends Error{constructor(e="Server error"){super(e)}}class a extends Error{constructor(e="I'm a teapot"){super(e)}}class o extends Error{constructor(e="Unauthorized"){super(e)}}const c="private",l="protected",u="public",h="normal",d="dry",p=200,m=400,f=401,g=402,w=403,y=404,E=418,S=500,v=501;class b extends e{#e;constructor(e){super(`Invalid version number '${e}'`),this.#e=e}get number(){return this.#e}}class O extends s{#t;constructor(e){super(`Procedure '${e}' not found`),this.#t=e}get fqn(){return this.#t}}class A extends t{constructor(e,t){super(`Procedure '${e}' (v${t}) is not accessible`)}}class N{#s;#r=new Map;#i=new Map;constructor(e){this.#s=e}get id(){return this.#s}addClass(e){return this.#r.set(e.fqn,e),this}hasClass(e){return void 0!==this.getClass(e)}getClass(e){return this.#r.get(e)}getClassByImplementation(e){return this.getClasses().find(t=>t.implementation===e)}getClasses(){return[...this.#r.values()]}addProcedure(e){return this.#i.set(e.fqn,e),this}hasProcedure(e){return this.#i.has(e)}getProcedure(e){return this.#i.get(e)}getExposedProcedures(){return[...this.#i.values()].filter(e=>e.public||e.protected)}}class T{#t;#n;constructor(e,t){this.#t=e,this.#n=t}get fqn(){return this.#t}get implementation(){return this.#n}}class x{static get DEFAULT(){return new x(0,0,0)}#a;#o;#c;constructor(e=0,t=0,s=0){this.#a=e,this.#o=t,this.#c=s}get major(){return this.#a}get minor(){return this.#o}get patch(){return this.#c}equals(e){return this.#a===e.major&&this.#o===e.minor&&this.#c===e.patch}greater(e){return this.#a!==e.major?this.#a>e.major:this.#o!==e.minor?this.#o>e.minor:this.#c!==e.patch&&this.#c>e.patch}less(e){return this.#a!==e.major?this.#a<e.major:this.#o!==e.minor?this.#o<e.minor:this.#c!==e.patch&&this.#c<e.patch}toString(){return`${this.#a}.${this.#o}.${this.#c}`}}class I{#t;#l=new Map;#u;constructor(e){this.#t=e}get fqn(){return this.#t}get public(){return[...this.#l.values()].some(e=>e.public)}get protected(){return[...this.#l.values()].some(e=>e.protected)}addImplementation(e){return this.#l.set(e.version,e),this.#h(e)&&(this.#u=e),this}#h(e){return void 0===this.#u||e.version.greater(this.#u.version)}getImplementation(e){const t=this.#d(e);return this.#l.get(t)}#d(e){let t=x.DEFAULT;for(const s of this.#l.keys()){if(s.equals(e))return s;s.greater(e)||t.less(s)&&(t=s)}return t}}class C{#p;#m;#f;#g;constructor(e,t,s,r){this.#p=e,this.#m=t,this.#f=s,this.#g=r}get version(){return this.#p}get public(){return this.#m===u}get protected(){return this.#m===l}get private(){return this.#m===c}get parameters(){return this.#f}get executable(){return this.#g}}class R{#w;#y;constructor(e,t=!1){this.#w=e,this.#y=t}get name(){return this.#w}get isOptional(){return this.#y}}class M extends R{}class z extends R{#E;constructor(e,t,s){super(t??"(anonymous)",s),this.#E=e}get variables(){return this.#E}}class P extends z{}class L extends z{}class k{#t;#p;#S;#v=new Map;#b;constructor(e,t,s,r,i){this.#t=e,this.#p=t,this.#S=s,this.#v=r,this.#b=i}get fqn(){return this.#t}get version(){return this.#p}get args(){return this.#S}get headers(){return this.#v}get mode(){return this.#b}clearArguments(){this.#S.clear()}setArgument(e,t){this.#S.set(e,t)}getArgument(e){return this.#S.get(e)}hasArgument(e){return this.#S.has(e)}removeArgument(e){this.#S.delete(e)}clearHeaders(){this.#v.clear()}setHeader(e,t){this.#v.set(e.toLowerCase(),t)}getHeader(e){return this.#v.get(e.toLowerCase())}hasHeader(e){return this.#v.has(e.toLowerCase())}removeHeader(e){this.#v.delete(e.toLowerCase())}}class ${#O;#A;#v;constructor(e,t=void 0,s=new Map){this.#O=e,this.#A=t,this.#v=s}get status(){return this.#O}get result(){return this.#A}set result(e){this.#A=e}get headers(){return this.#v}clearHeaders(){this.#v.clear()}setHeader(e,t){this.#v.set(e.toLowerCase(),t)}getHeader(e){return this.#v.get(e.toLowerCase())}hasHeader(e){return this.#v.has(e.toLowerCase())}removeHeader(e){this.#v.delete(e.toLowerCase())}}class V extends e{#N;constructor(e){super(`Unknown parameter ${e}`),this.#N=e}get parameterName(){return this.#N}}class D extends e{#N;constructor(e){super(`Missing value for parameter '${e}'`),this.#N=e}get parameterName(){return this.#N}}class j extends e{#N;constructor(e){super(`Invalid value for parameter '${e}'`),this.#N=e}get parameterName(){return this.#N}}class F{extract(e,t){const s=this.#T(e,t),r=[];for(const t of e){const e=this.#x(t,s);r.push(e)}if(s.size>0){const e=s.keys().next().value;throw new V(e)}return r}#T(e,t){const s=new Map;for(const[r,i]of t){if(this.#I(r)){const t=this.#C(r);!0===this.#R(e,t)&&s.set(t,i);continue}s.set(r,i)}return s}#I(e){return e.startsWith("*")}#C(e){return e.substring(1)}#R(e,t){return void 0!==e.find(e=>e.name===t)}#x(e,t,s){return e instanceof M?this.#M(e,t,s):this.#z(e,t)}#M(e,t,s){const r=t.get(e.name);if(this.#P(e,r,s))throw new D(e.name);if(this.#L(e,r,s))throw new j(e.name);return t.delete(e.name),r}#z(e,t){return e instanceof P?this.#k(e,t):this.#$(e,t)}#k(e,t){const s=this.#V(e,t);return void 0!==s?Object.values(s):void 0}#$(e,t){return this.#V(e,t)}#V(e,t){const s=e instanceof P,r={},i=[];let n=!1,a=0;for(const o of e.variables){const c=s?a++:o.name,l=this.#x(o,t,e);void 0!==l?n=!0:!1===o.isOptional&&i.push(o.name),r[c]=l}if(!0===n&&i.length>0)throw new D(i[0]);return n?r:void 0}#P(e,t,s){return void 0===t&&(!0!==e.isOptional&&!0!==s?.isOptional)}#L(e,t,s){return!1!==e.name.startsWith("...")&&(void 0===s&&t instanceof Array==!1||s instanceof P&&t instanceof Array==!1||s instanceof L&&t instanceof Object==!1)}}class B{toStatus(n){return n instanceof e?m:n instanceof t?w:n instanceof s?y:n instanceof r?v:n instanceof i?g:n instanceof a?E:n instanceof o?f:S}fromStatus(c,l){switch(c){case m:return new e(l);case w:return new t(l);case y:return new s(l);case v:return new r(l);case g:return new i(l);case E:return new a(l);case f:return new o(l);default:return new n(l)}}}const H=/^\d+(?:\.\d+){0,2}$/;class U{parse(e){if(0===e.trim().length)return x.DEFAULT;if(!1===H.test(e))throw new b(e);const t=e.split(".");switch(t.length){case 1:return new x(Number.parseInt(t[0]));case 2:return new x(Number.parseInt(t[0]),Number.parseInt(t[1]));default:return new x(Number.parseInt(t[0]),Number.parseInt(t[1]),Number.parseInt(t[2]))}}}class G extends s{#t;#p;constructor(e,t){super(`No implementation found for procedure '${e}' with version '${t}'`),this.#t=e,this.#p=t}get fqn(){return this.#t}get version(){return this.#p}}class q extends n{constructor(){super("Invalid segment")}}class W extends Error{constructor(e){super("Starting execution manager failed",{cause:e})}}class _ extends Error{constructor(e){super("Stopping execution manager failed",{cause:e})}}class K{#D=new Map;addSegment(e){this.#D.set(e.id,e)}clearSegments(){this.#D.clear()}getClassNames(){const e=new Set;for(const t of this.#D.values()){t.getClasses().forEach(t=>e.add(t.fqn))}return[...e.values()]}hasClass(e){return this.getClassNames().includes(e)}getClass(e){for(const t of this.#D.values())if(t.hasClass(e))return t.getClass(e)}getClassByImplementation(e){for(const t of this.#D.values()){const s=t.getClassByImplementation(e);if(void 0!==s)return s}}getProcedureNames(){const e=new Set;for(const t of this.#D.values()){t.getExposedProcedures().forEach(t=>e.add(t.fqn))}return[...e.values()]}hasProcedure(e){return this.getProcedureNames().includes(e)}getProcedure(e){for(const t of this.#D.values())if(t.hasProcedure(e))return t.getProcedure(e)}}class Y{#j;#F;#B=new F;#H=new B;#U=new K;constructor(e,t=[]){this.#j=e,this.#F=t}async start(){try{await this.#G()}catch(e){throw new W(e)}}async stop(){try{return this.#q()}catch(e){throw new _(e)}}async loadSegment(e){const t=await this.#j.import(e);this.addSegment(t.default)}async addSegment(e){if(e instanceof N==!1)throw new q;this.#U.addSegment(e)}getClassNames(){return this.#U.getClassNames()}hasClass(e){return this.#U.hasClass(e)}getClass(e){return this.#U.getClass(e)}getClassByImplementation(e){return this.#U.getClassByImplementation(e)}getProcedureNames(){return this.#U.getProcedureNames()}hasProcedure(e){return this.#U.hasProcedure(e)}getProcedure(e){return this.#U.getProcedure(e)}async run(e){const t=this.#W(e.fqn,e.version),s=this.#B.extract(t.parameters,e.args);return e.mode===d?new $(p,void 0):this.#_(e,t,s)}async#G(){await Promise.all(this.#F.map(e=>this.loadSegment(e)))}#q(){this.#U.clearSegments()}#W(e,t){const s=this.#U.getProcedure(e);if(void 0===s)throw new O(e);const r=s.getImplementation(t);if(void 0===r)throw new G(s.fqn,t.toString());return r}async#_(e,t,s){try{const r=await t.executable.call(e,...s);return new $(p,r)}catch(e){const t=this.#H.toStatus(e);return new $(t,e)}}}class X extends n{constructor(){super("Request cancelled")}}class J{#K;#Y;#X=[];#J=!1;#Q=0;constructor(e,t=20){this.#K=e,this.#Y=t}start(){this.#J=!0,this.#Z()}stop(){this.#J=!1,this.#ee()}run(e){return new Promise((t,s)=>{this.#X.push({request:e,resolve:t,reject:s}),this.#Z()})}#Z(){if(this.#te())return;const e=this.#X.length,t=this.#Y-this.#Q,s=Math.min(e,t);this.#se(s)}#te(){return this.#re()||this.#ie()||this.#ne()}#re(){return!1===this.#J}#ie(){return 0===this.#X.length}#ne(){return this.#Q>=this.#Y}#se(e){const t=this.#X.splice(0,e);this.#Q+=e,t.forEach(e=>this.#ae(e))}async#ae(e){try{const t=await this.#K.run(e.request);e.resolve(t)}catch(t){e.reject(t)}finally{this.#Q--,this.#Z()}}#ee(){for(;this.#X.length>0;){const e=this.#X.shift();void 0!==e&&this.#oe(e)}}#oe(e){e.reject(new X)}}const Q="starting",Z="available",ee="unavailable",te="stopping",se="stopped";class re{#ce=se;get state(){return this.#ce}set state(e){this.#ce=e}async start(e){if(!this.isStarted())try{this.setStarting(),await e()}catch(e){throw this.setStopped(),e}}async stop(e){this.isStopped()||(this.setStopping(),await e(),this.setStopped())}isStarted(){return this.#le(se)}isStopped(){return this.#ue(se)}isAvailable(){return this.#ue(Z)}setStarting(){this.#ce=Q}setAvailable(){this.#ce=Z}setUnavailable(){this.#ce=ee}setAvailability(e){return this.#ce=e?Z:ee,this.#ce}setStopping(){this.#ce=te}setStopped(){this.#ce=se}#ue(...e){return e.includes(this.#ce)}#le(...e){return!1===this.#ue(...e)}}class ie{#he;#de;#pe=new re;constructor(e){this.#he=e.url,this.#de=e.remote}get url(){return this.#he}get state(){return this.#pe.state}get trustKey(){}async start(){return this.#pe.start(async()=>{await this.#de.connect(),await this.updateState()})}async stop(){return this.#pe.stop(async()=>{await this.#de.disconnect()})}isHealthy(){return this.#de.isHealthy()}getHealth(){return this.#de.getHealth()}async updateState(){const e=await this.isHealthy();return this.#pe.setAvailability(e)}getProcedureNames(){throw new r}hasProcedure(e){throw new r}addWorker(e){return this.#de.addWorker(e.url,e.getProcedureNames(),e.trustKey)}reportWorker(e,t){return this.#de.reportWorker(e,t)}removeWorker(e){return this.#de.removeWorker(e)}run(e){return this.#de.run(e)}}class ne extends Error{constructor(e){super(`Invalid location '${e}'`)}}class ae extends Error{constructor(e){super(`File could not be found from '${e}'`)}}class oe{#me;#fe;#ge;constructor(e,t,s){this.#me=e,this.#fe=t,this.#ge=s}get location(){return this.#me}get type(){return this.#fe}get content(){return this.#ge}get size(){return this.#ge.length}}class ce{#me;#we;#ye;constructor(e,t){const s=t.resolve(e);this.#me=t.normalize(e),this.#we=t.normalize(s),this.#ye=t}getAbsoluteLocation(e){const t=this.#ye.isAbsolute(e)?e:this.#ye.join(this.#me,e),s=this.#ye.resolve(t),r=this.#ye.normalize(s);return this.#Ee(r,e),r}getRelativeLocation(e){const t=this.#ye.relative(this.#me,e);return this.#ye.normalize(t)}normalizeLocation(e){return this.#ye.normalize(e)}async getType(e){const t=this.getAbsoluteLocation(e);return await this.#ye.mimeType(t)??"application/octet-stream"}async getContent(e){const t=this.getAbsoluteLocation(e);if(!1===await this.#ye.exists(t))throw new ae(e);return this.#ye.read(t)}async exists(e){const t=this.getAbsoluteLocation(e);return this.#ye.exists(t)}isDirectory(e){const t=this.getAbsoluteLocation(e);return this.#ye.isDirectory(t)}async read(e){const t=this.getAbsoluteLocation(e),s=await this.getType(t),r=await this.getContent(t);return new oe(e,s,r)}async write(e,t){const s=this.getAbsoluteLocation(e);return this.#ye.write(s,t)}async copy(e,t){const s=this.getAbsoluteLocation(e),r=this.getAbsoluteLocation(t);return this.#ye.copy(s,r)}async delete(e){const t=this.getAbsoluteLocation(e);return this.#ye.delete(t)}async filter(e){const t=this.getAbsoluteLocation("./"),s=this.#ye.normalize(e);return(await this.#ye.filter(t,s)).map(e=>this.#ye.normalize(e))}async filterWithIgnores(e,t){const s=await this.filter(e),r=t.map(e=>this.filter(e)),i=await Promise.all(r),n=new Set(i.flat());return s.filter(e=>!1===n.has(e))}#Ee(e,t){if(!1===e.startsWith(this.#we))throw new ne(t)}}class le extends Error{constructor(){super("Remote files are not supported")}}class ue{copy(e,t){throw new le}delete(e){throw new le}exists(e){throw new le}async filter(e,t){return[]}isAbsolute(e){return e.startsWith("/")}isDirectory(e){throw new le}join(...e){throw new le}read(e){throw new le}resolve(e){return e}relative(e,t){throw new le}normalize(e){return e}mimeType(e){throw new le}write(e,t){throw new le}}class he extends ce{constructor(e){super(e,new ue)}}class de extends Error{constructor(e,t){super(`Module could not be loaded from '${e}'`,{cause:t})}}class pe{#Se;constructor(e){this.#Se=e}async import(e){const t=this.#Se.locate(e);try{return await(import(t))}catch(e){throw new de(t,e)}}}class me{constructor(e){}locate(e){throw new de(e,"Remote module loading is not allowed")}}class fe extends pe{constructor(e){super(new me(e))}}class ge{#ve;#be;constructor(e,t){this.#ve=e,this.#be=t}get fileManager(){return this.#ve}get importManager(){return this.#be}async filter(...e){return(await Promise.all(e.map(e=>this.#ve.filter(e)))).flat().map(e=>this.#ve.getRelativeLocation(e))}exists(e){return this.#ve.exists(e)}read(e){return this.#ve.read(e)}import(e){return this.#be.import(e)}}class we extends ge{constructor(e){super(new he(e),new fe(e))}fork(e){const t=this.fileManager.getAbsoluteLocation(e);return new we(t)}}class ye extends Error{constructor(e){super(`The class '${e}' could not be found`)}}class Ee extends Error{constructor(e){super(`The class '${e}' is invalid`)}}class Se extends Error{constructor(e){super(`No deserializer found for value of type '${e}'`)}}class ve extends Error{constructor(e){super(`No serializer found for value of type '${e}'`)}}class be{#Oe=[];addSerializer(e){e.parent=this,this.#Oe.unshift(e)}async serialize(e){const t=this.#Oe.find(t=>t.canSerialize(e));if(void 0===t)throw new ve(typeof e);return t.serialize(e)}async deserialize(e){const t=this.#Oe.find(t=>t.canDeserialize(e));if(void 0===t)throw new Se(typeof e);return t.deserialize(e)}}class Oe extends Error{constructor(){super("Parent serializer not set")}}class Ae{#Ae;set parent(e){this.#Ae=e}serializeOther(e){if(void 0===this.#Ae)throw new Oe;return this.#Ae.serialize(e)}deserializeOther(e){if(void 0===this.#Ae)throw new Oe;return this.#Ae.deserialize(e)}}class Ne extends Ae{canSerialize(e){return e instanceof Array}canDeserialize(e){return e instanceof Array}async serialize(e){const t=[];for(const s of e)t.push(await this.serializeOther(s));return t}async deserialize(e){return Promise.all(e.map(async e=>this.deserializeOther(e)))}}class Te extends Error{constructor(e){super(`Invalid BigInt string '${e}'`)}}class xe extends Ae{canSerialize(e){return"bigint"==typeof e}canDeserialize(e){const t=e;return t instanceof Object&&!0===t.serialized&&"BigInt"===t.name&&"string"==typeof t.value}async serialize(e){return{serialized:!0,name:"BigInt",value:e.toString()}}async deserialize(e){try{return BigInt(e.value)}catch{throw new Te(e.value)}}}class Ie extends Error{constructor(e){super(`Invalid Buffer string '${e}'`)}}class Ce extends Ae{canSerialize(e){return e instanceof Buffer}canDeserialize(e){const t=e;return t instanceof Object&&!0===t.serialized&&"Buffer"===t.name&&"string"==typeof t.base64}async serialize(e){return{serialized:!0,name:"Buffer",base64:e.toString("base64")}}async deserialize(e){try{return Buffer.from(e.base64,"base64")}catch{throw new Ie(e.base64)}}}class Re{}class Me extends Re{elements;constructor(e){super(),this.elements=e}clone(){const e=this.elements.map(e=>e.clone());return new Me(e)}toString(){return`[${this.elements.map(e=>e.toString()).join(",")}]`}}class ze{}class Pe extends ze{identifier;constructor(e){super(),this.identifier=e}is(e){return this.identifier===e}}class Le extends Pe{parameters;body;isAsync;constructor(e,t,s,r=!1){super(e),this.parameters=t,this.body=s,this.isAsync=r}clone(){const e=this.parameters.map(e=>e.clone()),t=this.body.clone();return new Le(this.identifier,e,t,this.isAsync)}toString(){const e=this.isAsync?"async ":"",t=this.identifier?` ${this.identifier}`:"",s=this.parameters.map(e=>e.toString()),r=this.body.toString();return`${e}function${t}(${s.join(",")})${r}`}}class ke extends Le{constructor(e,t,s=!1){super(void 0,e,t,s)}clone(){const e=this.parameters.map(e=>e.clone()),t=this.body.clone();return new ke(e,t,this.isAsync)}toString(){const e=this.isAsync?"async ":"",t=this.parameters.map(e=>e.toString()),s=this.body.toString();return`${e}(${t.join(", ")})=>${s}`}}class $e{binding;initializer;constructor(e,t){this.binding=e,this.initializer=t}clone(){const e=this.binding.clone(),t=this.initializer?.clone();return new $e(e,t)}toString(){return`${this.binding.toString()}${void 0!==this.initializer?`=${this.initializer.toString(!1)}`:""}`}}class Ve extends ze{code;constructor(e){super(),this.code=e}clone(){return new Ve(this.code)}toString(){return this.code}}class De{identifier;visibility;location;constructor(e,t,s){this.identifier=e,this.visibility=t,this.location=s}is(e){return this.identifier===e}}class je extends De{parameters;body;constructor(e,t){super("constructor","public","instance"),this.parameters=e,this.body=t}clone(){const e=this.parameters.map(e=>e.clone()),t=this.body.clone();return new je(e,t)}toString(){const e=this.parameters.map(e=>e.toString()),t=this.body.toString();return`${this.identifier}(${e.join(",")}) ${t}`}}class Fe extends De{body;constructor(e,t,s,r){super(e,t,s),this.body=r}clone(){const e=this.body.clone();return new Fe(this.identifier,this.visibility,this.location,e)}toString(){const e="static"===this.location?"static ":"",t="private"===this.visibility?"#":"",s=this.body.toString();return`${e}get ${t}${this.identifier}()${s}`}}class Be extends De{parameter;body;constructor(e,t,s,r,i){super(e,t,s),this.parameter=r,this.body=i}clone(){const e=this.parameter.clone(),t=this.body.clone();return new Be(this.identifier,this.visibility,this.location,e,t)}toString(){const e="static"===this.location?"static ":"",t="private"===this.visibility?"#":"",s=this.parameter.toString(),r=this.body.toString();return`${e}set ${t}${this.identifier}(${s})${r}`}}class He extends De{parameters;body;isAsync;constructor(e,t,s,r,i,n=!1){super(e,t,s),this.parameters=r,this.body=i,this.isAsync=n}clone(){const e=this.parameters.map(e=>e.clone()),t=this.body.clone();return new He(this.identifier,this.visibility,this.location,e,t,this.isAsync)}toString(){const e="static"===this.location?"static ":"",t="private"===this.visibility?"#":"",s=this.isAsync?"async ":"",r=this.parameters.map(e=>e.toString()),i=this.body.toString();return`${e}${s}${t}${this.identifier}(${r.join(",")})${i}`}}class Ue extends De{initializer;constructor(e,t,s,r){super(e,t,s),this.initializer=r}clone(){const e=this.initializer?.clone();return new Ue(this.identifier,this.visibility,this.location,e)}toString(){const e="static"===this.location?"static ":"",t="private"===this.visibility?"#":"",s=void 0!==this.initializer?`=${this.initializer.toString(!0)}`:";";return`${e}${t}${this.identifier}${s}`}}class Ge extends Pe{parent;members;constructor(e,t,s){super(e),this.parent=t,this.members=s}get construct(){return this.members.find(e=>e instanceof je)}get fields(){return this.members.filter(e=>e instanceof Ue)}get getters(){return this.members.filter(e=>e instanceof Fe)}get setters(){return this.members.filter(e=>e instanceof Be)}get methods(){return this.members.filter(e=>e instanceof He)}get publicFields(){return this.fields.filter(e=>"public"===e.visibility)}get publicGetters(){return this.getters.filter(e=>"public"===e.visibility)}get publicSetters(){return this.setters.filter(e=>"public"===e.visibility)}get publicMethods(){return this.methods.filter(e=>"public"===e.visibility)}get readable(){return[...this.publicFields,...this.publicGetters]}get writable(){return[...this.publicFields,...this.publicSetters]}getMember(e){return this.members.find(t=>t.is(e))}hasMember(e){return this.members.some(t=>t.is(e))}getField(e){return this.fields.find(t=>t.is(e))}hasField(e){return this.fields.some(t=>t.is(e))}getGetter(e){return this.getters.find(t=>t.is(e))}hasGetter(e){return this.getters.some(t=>t.is(e))}getSetter(e){return this.setters.find(t=>t.is(e))}hasSetter(e){return this.setters.some(t=>t.is(e))}getMethod(e){return this.methods.find(t=>t.is(e))}hasMethod(e){return this.methods.some(t=>t.is(e))}canRead(e){return this.readable.some(t=>t.is(e))}canWrite(e){return this.writable.some(t=>t.is(e))}clone(){const e=this.members.map(e=>e.clone());return new Ge(this.identifier,this.parent,e)}toString(){return`class ${this.identifier??""}${void 0!==this.parent?` extends ${this.parent}`:""}{${this.members.map(e=>e.toString()).join("")}}`}}class qe extends ze{members;from;constructor(e,t){super(),this.members=e,this.from=t}hasMember(e){return this.members.some(t=>t.is(e))}getMember(e){return this.members.find(t=>t.is(e))}clone(){const e=this.members.map(e=>e.clone());return new qe(e,this.from)}toString(){const e=this.members.map(e=>e.toString()),t=this.from?` from '${this.from}'`:"";return`export {${e.join(",")}}${t};`}}class We extends ze{code;constructor(e){super(),this.code=e}clone(){return new We(this.code)}toString(e=!0){const t=!1===e||this.code.endsWith("}")?"":";";return`${this.code}${t}`}}class _e extends Le{clone(){const e=this.parameters.map(e=>e.clone()),t=this.body.clone();return new _e(this.identifier,e,t,this.isAsync)}toString(){const e=this.isAsync?"async ":"",t=this.identifier??"",s=this.parameters.map(e=>e.toString()),r=this.body.toString();return`${e}function* ${t}(${s.join(",")})${r}`}}class Ke extends He{clone(){const e=this.parameters.map(e=>e.clone()),t=this.body.clone();return new Ke(this.identifier,this.visibility,this.location,e,t,this.isAsync)}toString(){const e=this.isAsync?"async ":"",t=this.identifier,s=this.parameters.map(e=>e.toString()),r=this.body.toString();return`${e}*${t}(${s.join(",")})${r}`}}class Ye extends Re{identifier;isRest;constructor(e,t=!1){super(),this.identifier=e,this.isRest=t}clone(){return new Ye(this.identifier,this.isRest)}toString(){return`${this.isRest?"...":""}${this.identifier}`}}class Xe extends ze{members;from;constructor(e,t){super(),this.members=e,this.from=t}hasMember(e){return this.members.some(t=>t.is(e))}getMember(e){return this.members.find(t=>t.is(e))}clone(){const e=this.members.map(e=>e.clone());return new Xe(e,this.from)}toString(){if(0===this.members.length)return`import '${this.from}';`;return`import {${this.members.map(e=>e.toString()).join(",")}} from '${this.from}';`}}class Je extends Pe{type;binding;initializer;constructor(e,t,s){super(t.toString()),this.type=e,this.binding=t,this.initializer=s}clone(){const e=this.binding.clone(),t=this.initializer?.clone();return new Je(this.type,e,t)}toString(){const e=void 0!==this.initializer?`=${this.initializer.toString(!0)}`:"",t=e.endsWith(";")?"":";";return`${this.type} ${this.identifier}${e}${t}`}}class Qe{statements;constructor(e){this.statements=e}get exports(){return this.statements.filter(e=>e instanceof qe)}get imports(){return this.statements.filter(e=>e instanceof Xe)}get expressions(){return this.statements.filter(e=>e instanceof We)}get declarations(){return this.statements.filter(e=>e instanceof Pe)}get variables(){return this.statements.filter(e=>e instanceof Je)}get functions(){return this.statements.filter(e=>e instanceof Le)}get classes(){return this.statements.filter(e=>e instanceof Ge)}get exported(){const e=[];for(const t of this.exports)for(const s of t.members){const t=this.getDeclaration(s.identifier);void 0!==t&&e.push(t)}return e}get exportedVariables(){return this.exported.filter(e=>e instanceof Je)}get exportedFunctions(){return this.exported.filter(e=>e instanceof Le)}get exportedClasses(){return this.exported.filter(e=>e instanceof Ge)}getExport(e){return this.exports.find(t=>t.hasMember(e))}getImport(e){return this.imports.find(t=>t.hasMember(e))}hasDeclaration(e){return this.declarations.some(t=>t.is(e))}getDeclaration(e){return this.declarations.find(t=>t.is(e))}hasVariable(e){return this.variables.some(t=>t.is(e))}getVariable(e){return this.variables.find(t=>t.is(e))}hasFunction(e){return this.functions.some(t=>t.is(e))}getFunction(e){return this.functions.find(t=>t.is(e))}hasClass(e){return this.classes.some(t=>t.is(e))}getClass(e){return this.classes.find(t=>t.is(e))}clone(){const e=this.statements.map(e=>e.clone());return new Qe(e)}toString(){return this.statements.map(e=>e.toString(!0)).join("\n")}}class Ze{identifier;alias;constructor(e,t){this.identifier=e,this.alias=t}is(e){return this.alias===e||void 0===this.alias&&this.identifier===e}clone(){return new Ze(this.identifier,this.alias)}toString(){return void 0===this.alias?this.identifier:`${this.identifier} as ${this.alias}`}}class et extends Re{elements;constructor(e){super(),this.elements=e}clone(){const e=this.elements.map(e=>e.clone());return new et(e)}toString(){return`{${this.elements.map(e=>e.toString()).join(",")}}`}}const tt={SINGLE:"//",MULTI_START:"/*",MULTI_END:"*/"},st=Object.values(tt);const rt=".",it="(",nt=")",at="[",ot="]",ct="{",lt="}",ut="_",ht={SCOPE:":",SEPARATOR:",",TERMINATOR:";"},dt=Object.values(ht);function pt(e){return dt.includes(e)}const mt={UNDEFINED:void 0,NULL:null,STRING:""},ft=["null","undefined"],gt=Object.values(mt);function wt(e){return gt.includes(e)}const yt={OPEN:it,CLOSE:nt};function Et(e){return e===yt.OPEN||e===yt.CLOSE}const St={IMPORT:"import",EXPORT:"export",AS:"as",FROM:"from",DEFAULT:"default",ASYNC:"async",AWAIT:"await",USING:"using",CONST:"const",LET:"let",VAR:"var",FUNCTION:"function",RETURN:"return",YIELD:"yield",CLASS:"class",CONSTRUCTOR:"constructor",GET:"get",SET:"set",EXTENDS:"extends",STATIC:"static",NEW:"new",THIS:"this",DO:"do",WHILE:"while",FOR:"for",OF:"of",IN:"in",BREAK:"break",CONTINUE:"continue",IF:"if",ELSE:"else",SWITCH:"switch",CASE:"case",THROW:"throw",TRY:"try",CATCH:"catch",FINALLY:"finally",TYPEOF:"typeof",INSTANCEOF:"instanceof"},vt=Object.values(St),bt=[St.IMPORT,St.EXPORT,St.VAR,St.LET,St.CONST,St.FUNCTION,St.CLASS,St.ASYNC],Ot=[St.VAR,St.LET,St.CONST,St.FUNCTION,St.CLASS,St.USING],At=[St.AS,St.ASYNC,St.GET,St.SET,St.OF,St.YIELD,St.FROM,St.STATIC];function Nt(e){return bt.includes(e)}function Tt(e){return At.includes(e)}const xt={OPEN:at,CLOSE:ot};function It(e){return e===xt.OPEN||e===xt.CLOSE}const Ct=Object.values({SINGLE:"'",DOUBLE:'"',BACKTICK:"`"});function Rt(e){return Ct.includes(e)}const Mt={ADD:"+",ARROW:"=>",ASSIGN:"=",ASSIGN_ADD:"+=",ASSIGN_BITWISE_AND:"&=",ASSIGN_BITWISE_OR:"|=",ASSIGN_BITWISE_XOR:"^=",ASSIGN_DIVIDE:"/=",ASSIGN_EXPONENTIAL:"**=",ASSIGN_LEFT_SHIFT:"<<=",ASSIGN_LOGICAL_AND:"&&=",ASSIGN_LOGICAL_OR:"||=",ASSIGN_REMAINDER:"%=",ASSIGN_MULTIPLY:"*=",ASSIGN_NULLISH:"??=",ASSIGN_RIGHT_SHIFT:">>=",ASSIGN_SUBTRACT:"-=",BITWISE_AND:"&",BITWISE_OR:"|",BITWISE_NOT:"~",BITWISE_XOR:"^",DECREMENT:"--",DIVIDE:"/",EQUAL:"==",EQUAL_STRICT:"===",EXPONENTIAL:"**",GREATER:">",GREATER_EQUAL:">=",INCREMENT:"++",LEFT_SHIFT:"<<",LESS:"<",LESS_EQUAL:"<=",LOGICAL_AND:"&&",LOGICAL_OR:"||",REMAINDER:"%",MULTIPLY:"*",NULLISH:"??",CHAINING:".",OPTIONAL_CHAINING:"?.",SPREAD:"...",NOT:"!",NOT_EQUAL:"!=",NOT_EQUAL_STRICT:"!==",RIGHT_SHIFT:">>",SUBTRACT:"-",TERNARY:"?",$BRIDGE_CHAINING_SPREAD:".."},zt=Object.values(Mt);function Pt(e){return zt.includes(e)}const Lt={OPEN:ct,CLOSE:lt};function kt(e){return e===Lt.OPEN||e===Lt.CLOSE}const $t={BOOLEAN:"boolean",COMMENT:"comment",DIVIDER:"divider",GROUP:"group",IDENTIFIER:"identifier",KEYWORD:"keyword",LIST:"list",LITERAL:"literal",NOTHING:"nothing",NUMBER:"number",OPERATOR:"operator",INDICATOR:"indicator",REGEX:"regex",SCOPE:"scope",WHITESPACE:"whitespace",NONE:"none"},Vt={SPACE:" ",TAB:"\t",NEWLINE:"\n",CARRIAGE_RETURN:"\r"},Dt=Object.values(Vt);function jt(e){return Dt.includes(e)}class Ft{#Ne;#Te;constructor(e){this.#Ne=e,this.#Te=0}get items(){return this.#Ne}get position(){return this.#Te}get size(){return this.#Ne.length}get eol(){return this.#Te>=this.#Ne.length}get current(){return this.#Ne[this.#Te]}get next(){return this.#Ne[this.#Te+1]}get previous(){return this.#Ne[this.#Te-1]}notAtEnd(){return!1===this.eol}get(e){return this.#Ne[e]}step(e=1){return this.#Te+=e,this.current}stepBack(e=1){return this.#Te-=e,this.current}hasNext(){return this.#Te+1<this.#Ne.length}insert(...e){this.#Ne.splice(this.#Te,0,...e)}}class Bt extends Ft{constructor(e){super(e.split(""))}}class Ht{#fe;#xe;#Ie;#Ce;constructor(e,t,s,r){this.#fe=e,this.#xe=t,this.#Ie=s,this.#Ce=r}get type(){return this.#fe}get value(){return this.#xe}get start(){return this.#Ie}get end(){return this.#Ce}isType(e){return this.#fe===e}hasValue(e){return this.#xe===e}toString(){return`${this.#xe}`}}class Ut extends Ft{}const Gt=["true","false"];const qt=["0","1","2","3","4","5","6","7","8","9"],Wt=[...qt,"a","b","c","d","e","f","A","B","C","D","E","F"],_t=["0","1"];function Kt(e){return qt.includes(e)}const Yt={GENERATOR:"*",PRIVATE:"#"},Xt=Object.values(Yt);class Jt{tokenize(e){const t=new Bt(e),s=[];let r;for(;t.notAtEnd();){const e=this.#Re(t,r);if(void 0===e)break;e.isType($t.WHITESPACE)||e.isType($t.COMMENT)?t.step():(s.push(e),this.#Me(e)&&(r=e),t.step())}return new Ut(s)}#Me(e){return!1===[$t.WHITESPACE,$t.COMMENT].includes(e.type)}#Re(e,t){const s=e.current,r=e.position;if(jt(s)){const t=e.position;return new Ht($t.WHITESPACE,s,r,t)}if(function(e){return st.includes(e)}(s+e.next)){const t=this.#ze(e),s=e.position;return new Ht($t.COMMENT,t,r,s)}if(this.#Pe(s,t)){const t=this.#Le(e),s=e.position;return new Ht($t.REGEX,t,r,s)}if(this.#ke(e,t)){const t=this.#$e(e),s=e.position;return new Ht($t.NUMBER,t,r,s)}if(Rt(s)){const t=this.#Ve(e),s=e.position;return new Ht($t.LITERAL,t,r,s)}if(Pt(s)){const t=this.#De(e),s=e.position;return new Ht($t.OPERATOR,t,r,s)}if(function(e){return Xt.includes(e)}(s)){const t=this.#De(e),s=e.position;return new Ht($t.INDICATOR,t,r,s)}if(pt(s)){const t=e.position;return new Ht($t.DIVIDER,s,r,t)}if(Et(s)){const t=e.position;return new Ht($t.GROUP,s,r,t)}if(kt(s)){const t=e.position;return new Ht($t.SCOPE,s,r,t)}if(It(s)){const t=e.position;return new Ht($t.LIST,s,r,t)}if(wt(s))return;const i=this.#je(e),n=e.position;return function(e){return vt.includes(e)}(i)?new Ht($t.KEYWORD,i,r,n):function(e){return Gt.includes(e)}(i)?new Ht($t.BOOLEAN,i,r,n):function(e){return ft.includes(e)}(i)?new Ht($t.NOTHING,i,r,n):new Ht($t.IDENTIFIER,i,r,n)}#ze(e){const t=e.current+e.next===tt.MULTI_START,s=t?tt.MULTI_END:Vt.NEWLINE;let r=t?tt.MULTI_START:tt.SINGLE;for(e.step(2);e.notAtEnd();){const i=e.current;if((t?i+e.next:i)===s){e.step(s.length-1);break}r+=i,e.step()}return t?r+tt.MULTI_END:r.trim()}#Pe(e,t){return e===Mt.DIVIDE&&(void 0===t||([$t.OPERATOR,$t.DIVIDER,$t.KEYWORD].includes(t.type)||[yt.OPEN,xt.OPEN].includes(t.value)))}#Fe(e){return jt(e)||e==rt||!1===this.#Be(e)}#Le(e){let t=e.current,s=!1;for(e.step();e.notAtEnd();){const r=e.current,i=e.previous;if(r===Mt.DIVIDE&&"\\"!==i)s=!0;else if(!0===s&&this.#Fe(r)){e.stepBack();break}t+=r,e.step()}return t}#ke(e,t){const s=e.current,r=e.next;return!!Kt(s)||s===Mt.SUBTRACT&&(!t?.isType($t.NUMBER)&&Kt(r))}#He(e,t,s){return t?!1===(r=e,Wt.includes(r))&&e!==ut:s?!1===function(e){return _t.includes(e)}(e)&&e!==ut:!1===Kt(e)&&e!==rt&&e!==ut&&"e"!==e;var r}#$e(e){let t=e.current;t===Mt.SUBTRACT&&(t+=e.step()),e.step();const s="x"===e.current,r="b"===e.current;for((s||r)&&(t+=e.current,e.step());e.notAtEnd();){const i=e.current;if(this.#He(i,s,r)){e.stepBack();break}t+=i,e.step()}return t}#Ve(e){const t=e.current;let s=t,r=!1;for(e.step();e.notAtEnd();){const i=e.current;if(!1===r){if(i===t){s+=i;break}"\\"===i&&(r=!0)}else r=!1;s+=i,e.step()}return s}#Be(e){return!1===(wt(e)||jt(e)||Pt(e)||Rt(e)||pt(e)||Et(e)||kt(e)||It(e))}#je(e){let t="";for(;e.notAtEnd();){const s=e.current;if(!1===this.#Be(s)){e.stepBack();break}t+=s,e.step()}return t}#De(e){let t=e.current;for(e.step();e.notAtEnd();){const s=e.current;if(!1===Pt(s)||!1===Pt(t+s)){e.stepBack();break}t+=s,e.step()}return t}}class Qt extends Error{constructor(e,t){super(`Expected keyword '${e}' at position ${t}`)}}class Zt extends Error{constructor(e,t){super(`Expected token '${e}' at position ${t}`)}}class es extends Error{constructor(e,t){super(`Unexpected keyword '${e}' at position ${t}`)}}class ts extends Error{constructor(e){super(`The given code does not contain ${e}`)}}class ss extends Error{constructor(e,t){super(`Unexpected token '${e}' at position ${t}`)}}const rs=new Ht($t.NONE,"",-1,0);class is{#Ue;constructor(e=[]){this.#Ue=e}get tokens(){return this.#Ue}append(...e){this.#Ue.push(...e)}merge(e){this.append(...e.tokens)}generate(){let e="";for(let t=0;t<this.#Ue.length;t++){const s=this.#Ue[t-1]??rs,r=this.#Ue[t],i=this.#Ue[t+1]??rs,n=this.#Ge(s,r)?" ":"",a=this.#qe(r,i)?" ":"";e+=`${n}${r.value}${a}`}return e}#Ge(e,t){return!(!t.isType($t.KEYWORD)||!this.#We(e))||!(!t.isType($t.OPERATOR)||!e.isType($t.OPERATOR))}#qe(e,t){return e.isType($t.KEYWORD)&&(t.isType($t.KEYWORD)||this.#We(t))}#We(e){return e.isType($t.IDENTIFIER)||e.isType($t.BOOLEAN)||e.isType($t.NOTHING)||e.isType($t.NUMBER)}}const ns="default",as="$_EXPORT";class os{#_e;constructor(e=new Jt){this.#_e=e}parse(e){const t=this.#_e.tokenize(e),s=this.#Ke(t);return new Qe(s)}parseStatement(e){const t=this.#_e.tokenize(e),s=this.#Ye(t);if(void 0===s)throw new ts("a statement");return s}parseImport(e){const t=this.#_e.tokenize(e),s=this.#Xe(t);if(s instanceof Xe==!1)throw new ts("an import definition");return s}parseExport(e){const t=this.#_e.tokenize(e),s=this.#Xe(t);if(s instanceof qe==!1)throw new ts("an export definition");return s}parseVariable(e){const t=this.#_e.tokenize(e),s=this.#Xe(t);if(s instanceof Je==!1)throw new ts("a variable definition");return s}parseFunction(e){const t=this.#_e.tokenize(e),s=this.#Xe(t);if(s instanceof Le==!1)throw new ts("a function definition");return s}parseClass(e){const t=this.#_e.tokenize(e),s=this.#Xe(t);if(s instanceof Ge==!1)throw new ts("a class definition");return s}#Ke(e){const t=[];for(;e.notAtEnd();){const s=this.#Ye(e);void 0!==s&&t.push(s)}return t}#Ye(e,t=!1){const s=e.current;if(this.#Je(s))return this.#Qe(e);if(s.isType($t.IDENTIFIER)){const s=e.next;return s?.hasValue(Mt.ARROW)?this.#Ze(e,t):this.#Qe(e)}if(s.isType($t.KEYWORD)){if(Tt(s.value)){const t=e.next,r=void 0!==t&&(t.hasValue(St.FUNCTION)||t.hasValue(yt.OPEN));if(s.hasValue(St.ASYNC)&&r)return e.step(),this.#Ye(e,!0);if(void 0===t||this.#et(t))return this.#Qe(e)}return s.hasValue(St.RETURN)?this.#Qe(e):!1===Nt(s.value)?this.#Qe(e):this.#Xe(e,t)}if(s.isType($t.REGEX))return this.#Qe(e);if(s.hasValue(yt.OPEN)){const s=this.#tt(e,yt.OPEN,yt.CLOSE);return s?.hasValue(Mt.ARROW)?this.#Ze(e,t):this.#Qe(e)}if(s.hasValue(Lt.OPEN))return this.#Qe(e);if(s.hasValue(xt.OPEN))return this.#Qe(e);if(s.hasValue(Mt.NOT)||s.hasValue(Mt.SUBTRACT))return this.#Qe(e);if(!pt(s.value))throw new ss(s.value,s.start);e.step()}#Je(e){return e.isType($t.LITERAL)||e.isType($t.NUMBER)||e.isType($t.BOOLEAN)||e.isType($t.NOTHING)||e.hasValue(St.NEW)}#Xe(e,t=!1){const s=e.current;switch(e.step(),s.value){case St.IMPORT:return this.#st(e);case St.EXPORT:return this.#rt(e);case St.CLASS:return this.#it(e);case St.FUNCTION:return this.#nt(e,t);case St.VAR:return this.#at(e,"var");case St.LET:return this.#at(e,"let");case St.CONST:return this.#at(e,"const");case St.ASYNC:return this.#Ye(e,!0);default:throw new es(s.value,s.start)}}#st(e){const t=[];let s=e.current;if(s.isType($t.LITERAL)){const e=this.#ot(s.value);return new Xe(t,e)}if(s.hasValue(yt.OPEN)){s=e.step();const r=this.#ot(s.value);return e.step(2),new Xe(t,r)}if(!1===s.hasValue(Lt.OPEN)){const r=s.hasValue(Mt.MULTIPLY)?Mt.MULTIPLY:ns;let i=s.value;s=e.step(),s.hasValue(St.AS)&&(s=e.step(),i=s.value,s=e.step()),t.push(new Ze(r,i))}if(s.hasValue(ht.SEPARATOR)&&(s=e.step()),s.hasValue(Lt.OPEN)){const r=this.#ct(e);t.push(...r),s=e.current}if(!1===s.hasValue(St.FROM))throw new Qt(St.FROM,s.start);s=e.step();const r=this.#ot(s.value);return e.step(),new Xe(t,r)}#rt(e){switch(e.current.value){case St.DEFAULT:return e.step(),this.#lt(e,!0);case Lt.OPEN:return this.#ut(e);default:return this.#lt(e,!1)}}#lt(e,t){let s=e.current,r=0;if(t&&this.#ht(e)){const t=`${as}_${s.start}_${s.end}`;e.insert(new Ht($t.KEYWORD,St.CONST,0,0),new Ht($t.IDENTIFIER,t,0,0),new Ht($t.OPERATOR,Mt.ASSIGN,0,0)),s=e.current}var i;if(s.hasValue(St.ASYNC)&&(s=e.step(),r++),i=s.value,Ot.includes(i)&&(s=e.step(),r++,s.hasValue(Yt.GENERATOR)&&(s=e.step(),r++)),s.hasValue(St.EXTENDS)||s.hasValue(yt.OPEN)||s.hasValue(Lt.OPEN)){const t=`${as}_${s.start}_${s.end}`;e.insert(new Ht($t.IDENTIFIER,t,0,0)),s=e.current}const n=this.#Be(s)?s.value:"",a=t?ns:void 0;let o;s=e.step(),s?.hasValue(St.FROM)&&(s=e.step(),o=this.#ot(s.value)),r>0&&(r++,e.stepBack(r));const c=new Ze(n,a);return new qe([c],o)}#ht(e){const t=e.current;if(this.#Je(t))return!0;const s=e.next;return this.#Be(t)&&s?.hasValue(yt.OPEN)}#ut(e){const t=this.#ct(e);let s,r=e.current;return r?.hasValue(St.FROM)&&(r=e.step(),s=this.#ot(r.value)),e.step(),new qe(t,s)}#ot(e){return e.slice(1,-1)}#ct(e){const t=[];let s=e.step();for(;e.notAtEnd();){if(s.hasValue(Lt.CLOSE)){e.step();break}if(s.hasValue(ht.SEPARATOR)){s=e.step();continue}const r=this.#dt(e);t.push(r),s=e.step()}return t}#dt(e){let t=e.current;const s=t.value;let r;return e.next.hasValue(St.AS)&&(t=e.step(2),r=t.value),new Ze(s,r)}#at(e,t){const s=this.#pt(e),r=this.#mt(e);return e.notAtEnd()&&e.current.hasValue(ht.SEPARATOR)&&(e.step(),e.insert(new Ht($t.KEYWORD,t,0,0))),new Je(t,s,r)}#pt(e){const t=e.current;return t.hasValue(xt.OPEN)?this.#ft(e):t.hasValue(Lt.OPEN)?this.#gt(e):this.#wt(e)}#ft(e){const t=this.#yt(e,xt.CLOSE);return new Me(t)}#gt(e){const t=this.#yt(e,Lt.CLOSE);return new et(t)}#yt(e,t){const s=[];for(e.step();e.notAtEnd();){const r=e.current;if(r.hasValue(t)){e.step();break}if(r.hasValue(ht.SEPARATOR)){e.step();continue}const i=this.#pt(e),n=this.#mt(e),a=new $e(i,n);s.push(a)}return s}#wt(e){let t=e.current,s=!1;t.hasValue(Mt.SPREAD)&&(s=!0,t=e.step());const r=t.value;return e.step(),new Ye(r,s)}#mt(e){const t=e.current;if(!1!==t.hasValue(Mt.ASSIGN))return e.step(),this.#Ye(e,!1);t.hasValue(ht.TERMINATOR)&&e.step()}#nt(e,t){let s,r=e.current,i=!1;r.hasValue(Yt.GENERATOR)&&(i=!0,r=e.step()),this.#Be(r)&&(s=r.value,e.step());const n=this.#yt(e,yt.CLOSE);if(r=e.current,!1===r.hasValue(Lt.OPEN))throw new Zt(Lt.OPEN,r.start);const a=this.#Et(e);return i?new _e(s,n,a,t):new Le(s,n,a,t)}#Ze(e,t){let s,r,i=e.current;if(i.hasValue(yt.OPEN))s=this.#yt(e,yt.CLOSE);else{const t=this.#wt(e);s=[new $e(t,void 0)]}if(i=e.current,!1===i.hasValue(Mt.ARROW))throw new Zt(Mt.ARROW,i.start);if(i=e.step(),i.hasValue(Lt.OPEN))r=this.#Et(e);else{const t=this.#Qe(e);r=new Ve(t.code)}return new ke(s,r,t)}#it(e){let t,s,r=e.current;if(this.#Be(r)&&(t=r.value,r=e.step()),r.hasValue(St.EXTENDS)&&(r=e.step(),s=r.value,r=e.step()),!1===r.hasValue(Lt.OPEN))throw new Zt(Lt.OPEN,r.start);const i=this.#St(e);return new Ge(t,s,i)}#St(e){let t=e.step();const s=[];for(;e.notAtEnd();){if(t.hasValue(Lt.CLOSE)){e.step();break}const r=this.#vt(e);s.push(r),t=e.current}return s}#vt(e){let t=e.current,s="public",r="instance",i=!1;for(;e.notAtEnd();){if(t.hasValue(Yt.PRIVATE))s="private";else if(t.hasValue(St.STATIC))r="static";else{if(!t.hasValue(St.ASYNC)){if(t.hasValue(St.CONSTRUCTOR))return this.#bt(e);if(t.hasValue(St.GET))return this.#Ot(e,r);if(t.hasValue(St.SET))return this.#At(e,r);if(t.hasValue(Yt.GENERATOR))return e.step(),this.#Nt(e,s,r,i,!0);break}i=!0}t=e.step()}return e.next.hasValue(yt.OPEN)?this.#Nt(e,s,r,i,!1):this.#Tt(e,s,r)}#bt(e){e.step();const t=this.#yt(e,yt.CLOSE),s=e.current;if(!1===s.hasValue(Lt.OPEN))throw new Zt(Lt.OPEN,s.start);const r=this.#Et(e);return new je(t,r)}#Ot(e,t){let s="public",r=e.step();r.hasValue(Yt.PRIVATE)&&(s="private",r=e.step());const i=r.value;e.step();if(0!==this.#yt(e,yt.CLOSE).length)throw new ts("an empty parameter list");if(r=e.current,!1===r.hasValue(Lt.OPEN))throw new Zt(Lt.OPEN,r.start);const n=this.#Et(e);return new Fe(i,s,t,n)}#At(e,t){let s="public",r=e.step();r.hasValue(Yt.PRIVATE)&&(s="private",r=e.step());const i=r.value;e.step();const n=this.#yt(e,yt.CLOSE);if(r=e.current,1!==n.length)throw new ts("exactly one setter parameter");if(!1===r.hasValue(Lt.OPEN))throw new Zt(Lt.OPEN,r.start);const a=this.#Et(e);return new Be(i,s,t,n[0],a)}#Nt(e,t,s,r,i){let n=e.current;const a=n.value;e.step();const o=this.#yt(e,yt.CLOSE);if(n=e.current,!1===n.hasValue(Lt.OPEN))throw new Zt(Lt.OPEN,n.start);const c=this.#Et(e);return i?new Ke(a,t,s,o,c,r):new He(a,t,s,o,c,r)}#Tt(e,t,s){const r=e.current.value;e.step();const i=this.#mt(e);return new Ue(r,t,s,i)}#Et(e){const t=this.#xt(e,Lt.OPEN,Lt.CLOSE).generate();return new Ve(t)}#Qe(e){const t=new is;let s=e.current;for(;e.notAtEnd();){if(s.hasValue(xt.OPEN)){const r=this.#xt(e,xt.OPEN,xt.CLOSE);t.merge(r),s=e.current}else if(s.hasValue(yt.OPEN)){const r=this.#xt(e,yt.OPEN,yt.CLOSE);t.merge(r),s=e.current}else if(s.hasValue(Lt.OPEN)){const r=this.#xt(e,Lt.OPEN,Lt.CLOSE);t.merge(r),s=e.current}else t.append(s),s=e.step();if(void 0===s)break;if(this.#et(s)){s.hasValue(ht.TERMINATOR)&&e.step();break}}const r=t.generate();return new We(r)}#xt(e,t,s){let r=e.current;const i=new is([r]);for(r=e.step();e.notAtEnd();){if(r.hasValue(t)){const n=this.#xt(e,t,s);i.merge(n),r=e.current;continue}if(r.hasValue(s))return e.step(),i.append(r),i;i.append(r),r=e.step()}return i}#tt(e,t,s){const r=e.position;this.#xt(e,t,s);const i=e.current,n=e.position;return e.stepBack(n-r),i}#et(e){return[ht.TERMINATOR,ht.SEPARATOR].includes(e.value)||[xt.CLOSE,yt.CLOSE,Lt.CLOSE].includes(e.value)||Nt(e.value)}#Be(e){return e.isType($t.IDENTIFIER)||e.isType($t.KEYWORD)&&Tt(e.value)}}class cs{merge(e,t){const s=void 0!==e.construct?[e.construct]:[],r=[...this.#It(e.fields,t.fields),...s,...this.#It(e.methods,t.methods),...this.#It(e.getters,t.getters),...this.#It(e.setters,t.setters)];return new Ge(e.identifier,t.identifier,r)}#It(e,t){const s=new Map;return t.forEach(e=>s.set(e.identifier,e)),e.forEach(e=>s.set(e.identifier,e)),[...s.values()]}}class ls{#Ct=new os;#Rt=new cs;fromModule(e,t=!1){const s=Object.entries(e),r=[];for(const[e,i]of s){if("function"!=typeof i.toString)continue;const s=i.toString();if(s.startsWith("class"))r.push(this.fromClass(i,t));else if(s.startsWith("function"))r.push(this.fromFunction(i));else{const t=new Ye(e,!1),i=new We(s);r.push(new Je("var",t,i))}}return new Qe(r)}fromClass(e,t=!1){const s=this.isClass(e)?this.#Mt(e):this.#zt(e);if(!1===t)return s;const r=this.getParentClass(e);if(""===r.name)return s;const i=this.fromClass(r,!0);return this.#Rt.merge(s,i)}fromObject(e,t=!0){const s=this.getClass(e);return this.fromClass(s,t)}fromFunction(e){const t=e.toString();return this.#Ct.parseFunction(t)}createInstance(e,t=[]){return new e(...t)}getClass(e){return e.constructor}getParentClass(e){return Object.getPrototypeOf(e)}isClassObject(e){return this.isClass(e.constructor)}isFunctionObject(e){return this.isFunction(e.constructor)}isClass(e){return e.toString().startsWith("class")}isFunction(e){return e.toString().startsWith("function")||e.toString().startsWith("async function")}#Mt(e){const t=e.toString();return this.#Ct.parseClass(t)}#zt(e){const t=this.createInstance(e),s=this.#Pt(e,t);return new Ge(e.name,void 0,s)}#Pt(e,t){return[...this.#Lt(t),...this.#kt(e)]}#Lt(e){const t=Object.getOwnPropertyNames(e),s=e,r=[];for(const e of t){const t=s[e],i=void 0!==t?new We(String(t)):void 0,n=new Ue(e,"public","instance",i);r.push(n)}return r}#kt(e){const t=Object.getOwnPropertyDescriptors(e.prototype),s=[];for(const e in t){const r=t[e],i=r.value;if(i instanceof Function==!1)continue;const n=this.fromFunction(i);"constructor"===n.identifier?s.push(new je(n.parameters,n.body)):void 0!==r.get?s.push(new Fe(n.identifier,"public","instance",n.body)):void 0!==r.set?s.push(new Be(n.identifier,"public","instance",n.parameters[0],n.body)):s.push(new He(n.identifier,"public","instance",n.parameters,n.body,n.isAsync))}return s}}const us=new ls;class hs extends Ae{#$t;constructor(e){super(),this.#$t=e}canSerialize(e){return e instanceof Object&&us.isClassObject(e)}canDeserialize(e){const t=e;return t instanceof Object&&!0===t.serialized&&"class"===t.name&&"string"==typeof t.key&&t.args instanceof Object&&t.args.constructor===Object&&t.fields instanceof Object&&t.fields.constructor===Object}async serialize(e){const t=us.getClass(e),s=us.fromClass(t,!0),r=this.#Vt(s),i=this.#$t.resolveKey(t);if(void 0===i)throw new ye(t.name);return{serialized:!0,key:i,name:"class",args:await this.#Dt(s,r,e),fields:await this.#jt(s,r,e)}}#Vt(e){const t=e.construct;return(t?.parameters??[]).map(e=>e.binding.identifier)}async#Dt(e,t,s){const r={};for(const[i,n]of t.entries()){const t=e.canRead(n)?await this.serializeOther(s[n]):void 0;r[i.toString()]=t}return r}async#jt(e,t,s){const r={};for(const i of e.writable){const n=i.identifier;t.includes(n)||!1===e.canRead(n)||(r[n]=await this.serializeOther(s[n]))}return r}async deserialize(e){const t=await this.#Ft(e);if(void 0===t)throw new ye(e.key);if(t instanceof Function==!1)throw new Ee(e.key);const s=await this.#Bt(t,e.args),r=us.createInstance(t,s);for(const t in e.fields){const s=e.fields[t];r[t]=await this.deserializeOther(s)}return r}async#Bt(e,t){const s=us.fromClass(e,!0).construct,r=(s?.parameters??[]).map((e,s)=>{const r=s.toString(),i=t[r];return this.deserializeOther(i)});return Promise.all(r)}async#Ft(e){return globalThis[e.key]??this.#$t.resolveClass(e.key)}}class ds extends Error{constructor(e){super(`Invalid date string '${e}'`)}}class ps extends Ae{canSerialize(e){return e instanceof Date}canDeserialize(e){const t=e;return t instanceof Object&&!0===t.serialized&&"Date"===t.name&&"string"==typeof t.value}async serialize(e){return{serialized:!0,name:"Date",value:e.toISOString()}}async deserialize(e){const t=new Date(e.value);if("Invalid Date"===t.toString())throw new ds(e.value);return t}}class ms extends Ae{canSerialize(e){if(e instanceof Object==!1)return!1;const t=e;return t.constructor===Error||t.constructor===EvalError||t.constructor===RangeError||t.constructor===ReferenceError||t.constructor===SyntaxError||t.constructor===TypeError||t.constructor===URIError||t.constructor===AggregateError}canDeserialize(e){const t=e;return t instanceof Object&&!0===t.serialized&&"Error"===t.name&&t.type in globalThis}async serialize(e){return{serialized:!0,name:"Error",type:e.constructor.name,stack:e.stack,message:e.message,cause:e.cause}}async deserialize(e){const t=new(0,globalThis[e.type])(e.message,{cause:e.cause});return t.stack=e.stack,t}}class fs extends Ae{canSerialize(e){return e instanceof Map}canDeserialize(e){const t=e;return t instanceof Object&&!0===t.serialized&&"Map"===t.name&&t.entries instanceof Object&&t.entries.keys instanceof Array&&t.entries.values instanceof Array}async serialize(e){const t=[],s=[];for(const[r,i]of e)t.push(await this.serializeOther(r)),s.push(await this.serializeOther(i));return{serialized:!0,name:"Map",entries:{keys:t,values:s}}}async deserialize(e){const t=e.entries.keys,s=e.entries.values,r=new Map;for(let e=0;e<t.length;e++){const i=await this.deserializeOther(t[e]),n=await this.deserializeOther(s[e]);r.set(i,n)}return r}}class gs extends Ae{canSerialize(e){return e instanceof Object&&e.constructor===Object}canDeserialize(e){return e instanceof Object&&e.constructor===Object}async serialize(e){const t={};for(const s in e){const r=e[s];t[s]=await this.serializeOther(r)}return t}async deserialize(e){const t={};for(const s in e){const r=e[s];t[s]=await this.deserializeOther(r)}return t}}class ws extends Ae{canSerialize(e){return e instanceof Object==!1}canDeserialize(e){return e instanceof Object==!1}async serialize(e){return e}async deserialize(e){return e}}class ys extends Error{constructor(e,t){super(`Invalid regular expression '${e}' with flags '${t}'`)}}class Es extends Ae{canSerialize(e){return e instanceof RegExp}canDeserialize(e){const t=e;return t instanceof Object&&!0===t.serialized&&"RegExp"===t.name&&"string"==typeof t.source&&"string"==typeof t.flags}async serialize(e){return{serialized:!0,name:"RegExp",source:e.source,flags:e.flags}}async deserialize(e){try{return new RegExp(e.source,e.flags)}catch{throw new ys(e.source,e.flags)}}}class Ss extends Ae{canSerialize(e){return e instanceof Set}canDeserialize(e){const t=e;return t instanceof Object&&!0===t.serialized&&"Set"===t.name&&t.values instanceof Array}async serialize(e){const t=[];for(const s of e.values())t.push(await this.serializeOther(s));return{serialized:!0,name:"Set",values:t}}async deserialize(e){const t=await Promise.all(e.values.map(async e=>this.deserializeOther(e)));return new Set([...t])}}const vs=new ls;class bs extends Ae{canSerialize(e){return e instanceof Int8Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray||e instanceof Int16Array||e instanceof Uint16Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Float32Array||e instanceof Float64Array||e instanceof BigInt64Array||e instanceof BigUint64Array}canDeserialize(e){const t=e;return t instanceof Object&&!0===t.serialized&&"TypedArray"===t.name&&t.type in globalThis&&t.bytes instanceof Array}async serialize(e){const t=e.constructor.name,s=new DataView(e.buffer),r=[];for(let e=0;e<s.byteLength;e++)r.push(s.getUint8(e));return{serialized:!0,name:"TypedArray",type:t,bytes:r}}async deserialize(e){const t=e.type,s=e.bytes,r=new ArrayBuffer(s.length),i=new DataView(r);for(let e=0;e<s.length;e++)i.setUint8(e,s[e]);const n=globalThis[t];return vs.createInstance(n,[r])}}class Os extends Error{constructor(e){super(`Invalid url string '${e}'`)}}class As extends Ae{canSerialize(e){return e instanceof URL}canDeserialize(e){const t=e;return t instanceof Object&&!0===t.serialized&&"Url"===t.name&&"string"==typeof t.value}async serialize(e){return{serialized:!0,name:"Url",value:e.toString()}}async deserialize(e){try{return new URL(e.value)}catch{throw new Os(e.value)}}}class Ns{static build(e){const t=new be;return t.addSerializer(new ws),t.addSerializer(new gs),void 0!==e&&t.addSerializer(new hs(e)),t.addSerializer(new ms),t.addSerializer(new Es),t.addSerializer(new xe),t.addSerializer(new As),t.addSerializer(new ps),t.addSerializer(new Ss),t.addSerializer(new fs),t.addSerializer(new Ne),t.addSerializer(new bs),"undefined"!=typeof Buffer&&t.addSerializer(new Ce),t}}class Ts{#Ht;constructor(e){this.#Ht=e}resolveKey(e){const t=this.#Ht.getClassByImplementation(e);return t?.fqn}resolveClass(e){const t=this.#Ht.getClass(e);return t?.implementation}}class xs extends o{constructor(){super("Request not trusted")}}const Is="X-Jitar-Trust-Key",Cs="X-Jitar-Data-Encoding",Rs="serialized";class Ms{#s;#he;#Ut;#Gt;#qt;#Ht;#Wt;#_t;#Kt;#pe=new re;constructor(e){this.#he=e.url,this.#Ut=e.trustKey,this.#Gt=e.gateway,this.#qt=!0===e.registerAtGateway,this.#Ht=e.executionManager,this.#Wt=e.healthManager;const t=e.scheduleManager;this.#_t=t.create(()=>this.#Yt(),e.reportInterval);const s=new Ts(this.#Ht);this.#Kt=Ns.build(s)}get id(){return this.#s}set id(e){this.#s=e}get state(){return this.#pe.state}get url(){return this.#he}get trustKey(){return this.#Ut}async start(){return this.#pe.start(async()=>{await Promise.all([this.#Ht.start(),this.#Wt.start()]),void 0!==this.#Gt&&(await this.#Gt.start(),this.#qt&&(this.#s=await this.#Gt.addWorker(this),this.#_t.start())),await this.updateState()})}async stop(){return this.#pe.stop(async()=>{void 0!==this.#Gt&&(void 0!==this.#s&&(this.#_t.stop(),await this.#Gt.removeWorker(this.#s)),await this.#Gt.stop()),await Promise.all([this.#Wt.stop(),this.#Ht.stop()])})}getProcedureNames(){return this.#Ht.getProcedureNames()}hasProcedure(e){return this.#Ht.hasProcedure(e)}isHealthy(){return this.#Wt.isHealthy()}getHealth(){return this.#Wt.getHealth()}isAvailable(){return this.#pe.isAvailable()}async updateState(){const e=await this.isHealthy();return this.#pe.setAvailability(e)}async reportState(e){if(void 0!==this.#Gt&&void 0!==this.#s)return this.#Gt.reportWorker(this.#s,e)}async run(e){return this.#Xt(e)?this.#Jt(e):this.#Qt(e)}#Xt(e){return void 0===this.#Gt||this.#Ht.hasProcedure(e.fqn)}async#Jt(e){const t=this.#Ht.getProcedure(e.fqn),s=t?.getImplementation(e.version);if(this.#Zt(s))throw new O(e.fqn);if(this.#es(e,s))throw new xs;const r=e.getHeader(Cs);r===Rs&&(e=await this.#ts(e)),e.removeHeader(Cs);const i=await this.#Ht.run(e);return r===Rs?this.#ss(i):i}#Zt(e){return void 0===e||e.private}#es(e,t){if(t.public)return!1;const s=e.getHeader(Is);return this.#Ut!==s}async#Qt(e){(e=await this.#rs(e)).setHeader(Cs,Rs),void 0!==this.#Ut&&e.setHeader(Is,this.#Ut);const t=await this.#Gt.run(e);return this.#is(t)}async#rs(e){const t=new Map;for(const[s,r]of e.args){const e=await this.#Kt.serialize(r);t.set(s,e)}return new k(e.fqn,e.version,t,e.headers,e.mode)}async#ts(e){const t=new Map;for(const[s,r]of e.args){const e=await this.#Kt.deserialize(r);t.set(s,e)}return new k(e.fqn,e.version,t,e.headers,e.mode)}async#ss(e){const t=await this.#Kt.serialize(e.result);return new $(e.status,t,e.headers)}async#is(e){const t=await this.#Kt.deserialize(e.result);return new $(e.status,t,e.headers)}async#Yt(){const e=await this.updateState();return this.reportState(e)}}class zs extends Error{constructor(e){super("Starting client failed",{cause:e})}}class Ps extends Error{constructor(e){super("Stopping client failed",{cause:e})}}class Ls{#K;constructor(e){this.#K=e}async handle(e,t){return this.#K.run(e)}}class ks{#ns=new U;constructor(){this.#as()}#as(){const e=globalThis;e.__run=this.#os.bind(this),e.ProcedureNotAccessible=A}async#os(e,t,s,r){const i=this.#ns.parse(t),n=new Map(Object.entries(s)),a=r instanceof k?r.headers:new Map,o=new k(e,i,n,a,h),c=this.getTrustKey();void 0!==c&&o.setHeader("X-Jitar-Trust-Key",c);const l=await this.runInternal(o);if(l.status!==p)throw l.result;return l.result}}class $s extends ks{#cs;#ls;#us=new J(this);constructor(e){super(),this.#cs=new Ms({url:e.remoteUrl,gateway:new ie({url:e.remoteUrl,remote:e.remote}),healthManager:e.healthManager,executionManager:e.executionManager,scheduleManager:e.scheduleManager}),this.#ls=e.middlewareManager}get worker(){return this.#cs}async start(){try{await this.#hs(),this.#us.start()}catch(e){throw new zs(e)}}async stop(){try{this.#us.stop(),await this.#ds()}catch(e){throw new Ps(e)}}getTrustKey(){}run(e){return this.#ls.handle(e)}async runInternal(e){return this.#us.run(e)}async#hs(){await Promise.all([this.#cs.start(),this.#ls.start()]);const e=new Ls(this.#cs);this.#ls.addMiddleware(e)}async#ds(){await Promise.all([this.#ls.stop(),this.#cs.stop()])}}const Vs="starting",Ds="started",js="stopping",Fs="stopped";class Bs extends n{constructor(){super("Invalid health check")}}class Hs extends Error{constructor(e){super("Starting health manager failed",{cause:e})}}class Us extends Error{constructor(e){super("Stopping health manager failed",{cause:e})}}class Gs{#ce=Fs;#ps=new Map;#j;#ms;constructor(e,t=[]){this.#j=e,this.#ms=t}get state(){return this.#ce}async start(){if(this.#ce===Fs)try{this.#ce=Vs,await this.#fs(),this.#ce=Ds}catch(e){throw this.#ce=Fs,new Hs(e)}}async stop(){if(this.#ce===Ds)try{this.#ce=js,this.clearHealthChecks(),this.#ce=Fs}catch(e){throw this.#ce=Ds,new Us(e)}}async loadHealthCheck(e){const t=await this.#gs(e);this.addHealthCheck(t)}addHealthCheck(e){if(void 0===e.isHealthy)throw new Bs;this.#ps.set(e.name,e)}clearHealthChecks(){this.#ps.clear()}async isHealthy(){const e=[];for(const t of this.#ps.values()){const s=this.#ws(t);e.push(s)}return Promise.all(e).then(e=>e.every(e=>e)).catch(()=>!1)}async getHealth(){const e=[];for(const[t,s]of this.#ps){const r=this.#ws(s).then(e=>({name:t,isHealthy:e})).catch(()=>({name:t,isHealthy:!1}));e.push(r)}const t=new Map;return Promise.allSettled(e).then(e=>e.forEach(e=>this.#ys(e,t))).then(()=>t)}async#fs(){(await Promise.all(this.#ms.map(e=>this.#gs(e)))).forEach(e=>this.addHealthCheck(e))}async#gs(e){return(await this.#j.import(e)).default}#ys(e,t){"fulfilled"===e.status?t.set(e.value.name,e.value.isHealthy):t.set(e.reason.name,!1)}async#ws(e){const t=e.isHealthy(),s=e.timeout;if(void 0===s)return t;const r=new Promise(e=>{setTimeout(e,s)}).then(()=>!1);return Promise.race([r,t])}}const qs=0,Ws=1,_s=2,Ks=3;class Ys{#Es;#Ss;constructor(e=Ws,t=console){this.#Es=e,this.#Ss=t}debug(...e){if(this.#Es>qs)return;const t=this.#vs("DEBUG",e);this.#Ss.debug(t)}info(...e){if(this.#Es>Ws)return;const t=this.#vs("INFO",e);this.#Ss.info(t)}warn(...e){if(this.#Es>_s)return;const t=this.#vs("WARN",e);this.#Ss.warn(t)}error(...e){if(this.#Es>Ks)return;const t=this.#vs("ERROR",e);this.#Ss.error(t)}fatal(...e){const t=this.#vs("FATAL",e);this.#Ss.error(t)}#vs(e,t){return`[${(new Date).toISOString()}][${e}] ${t.map(e=>this.#bs(e)).join(" ")}`}#bs(e,t=0){let s;switch(typeof e){case"string":s=e;break;case"object":s=this.#Os(e,t+1);break;case"undefined":s="undefined";break;case"function":s="function";break;default:s=String(e)}return`${this.#As(t)}${s}`}#Os(e,t){if(null===e)return"null";if(Array.isArray(e)){return`[\n${e.map(e=>this.#bs(e,t)).join(",\n")}\n${this.#As(t-1)}]`}if(e instanceof Error){const s=void 0!==e.cause?this.#bs(e.cause,t+1):void 0,r=void 0!==s?`\n=>${s}`:"";return`${e.message}${r}`}return JSON.stringify(e)}#As(e){return" ".repeat(e)}}const Xs="starting",Js="started",Qs="stopping",Zs="stopped";class er extends n{constructor(){super("Invalid middleware")}}class tr extends Error{constructor(e){super("Starting middleware manager failed",{cause:e})}}class sr extends Error{constructor(e){super("Stopping middleware manager failed",{cause:e})}}class rr{#ce=Zs;#Ns=[];#j;#Ts;constructor(e,t=[]){this.#j=e,this.#Ts=t}get state(){return this.#ce}async start(){if(this.#ce===Zs)try{this.#ce=Xs,await this.#xs(),this.#ce=Js}catch(e){throw this.#ce=Zs,new tr(e)}}async stop(){if(this.#ce===Js)try{this.#ce=Qs,this.clearMiddlewares(),this.#ce=Zs}catch(e){throw this.#ce=Js,new sr(e)}}async loadMiddleware(e){const t=await this.#Is(e);this.addMiddleware(t)}addMiddleware(e){if(void 0===e?.handle)throw new er;this.#Ns.push(e)}getMiddleware(e){return this.#Ns.find(t=>t instanceof e)}clearMiddlewares(){this.#Ns=[]}handle(e){return this.#Cs(e,0)()}async#xs(){(await Promise.all(this.#Ts.map(e=>this.#Is(e)))).forEach(e=>this.addMiddleware(e))}async#Is(e){return(await this.#j.import(e)).default}#Cs(e,t){const s=this.#Ns[t];if(void 0===s)return async()=>new $(p);const r=this.#Cs(e,t+1);return async()=>await s.handle(e,r)}}class ir{#Rs;#Ms;#zs;#Ps=null;constructor(e,t,s=5e3){this.#Rs=e,this.#Ms=t,this.#zs=s}start(){this.#Ls()}stop(){null!==this.#Ps&&(clearTimeout(this.#Ps),this.#Ps=null)}#Ls(){this.#Ps=setTimeout(async()=>{null!==this.#Ps&&(await this.#ks(),this.#Ls())},this.#zs),this.#Ps.unref()}async#ks(){try{await this.#Ms()}catch(e){this.#Rs.warn("Scheduled task failed",e)}}}class nr{#$s=[];#Rs;constructor(e){this.#Rs=e}create(e,t){const s=new ir(this.#Rs,e,t);return this.#$s.push(s),s}remove(e){const t=this.#$s.indexOf(e);t<0||this.#$s.splice(t,1)}startAll(){this.#$s.forEach(e=>e.start())}stopAll(){this.#$s.forEach(e=>e.stop())}}class ar{#Vs;constructor(e){this.#Vs=e}build(e){const t=e.remoteUrl,s=e.middleware,r=e.segments,i=new Ys(e.logLevel??_s),n=this.#Vs.build(t),a=new we(t),o=this.#Ds(a),c=this.#js(a,s),l=this.#Fs(a,r),u=this.#Bs(i);return new $s({remoteUrl:t,remote:n,healthManager:o,middlewareManager:c,executionManager:l,scheduleManager:u})}#Ds(e){return new Gs(e)}#js(e,t=[]){const s=new rr(e);return t.forEach(e=>s.addMiddleware(e)),s}#Fs(e,t=[]){const s=new Y(e);return t.forEach(e=>s.addSegment(e)),s}#Bs(e){return new nr(e)}}class or{#Hs;constructor(e=!0){this.#Hs=e}validate(e,t){const s=[];this.#Us("",e,t,s);return{valid:0===s.length,errors:s}}#Us(e,t,s,r){this.#Hs&&this.#Gs(e,t,s,r),this.#qs(e,t,s,r)}#Gs(e,t,s,r){const i=Object.keys(t),n=Object.keys(s);for(const t of i)if(!1===n.includes(t)){const s=this.#Ws(e,t);r.push(`Unknown field '${s}'`)}}#qs(e,t,s,r){const i=Object.keys(s);for(const n of i){const i=this.#Ws(e,n),a=s[n],o=t[n];this.#_s(i,o,a,r)}}#_s(e,t,s,r){if(void 0!==t)switch(s.type){case"string":return this.#Ks(e,t,s,r);case"integer":return this.#Ys(e,t,s,r);case"real":return this.#Xs(e,t,s,r);case"boolean":return this.#Js(e,t,s,r);case"url":return this.#Qs(e,t,s,r);case"group":return this.#Zs(e,t,s,r);case"list":return this.#er(e,t,s,r);case"enum":return this.#tr(e,t,s,r)}else!0===s.required&&r.push(`Field '${e}' is required`)}#Ks(e,t,s,r){"string"!=typeof t&&r.push(`Field '${e}' is not a string`)}#Ys(e,t,s,r){"number"==typeof t&&!1!==Number.isInteger(t)||r.push(`Field '${e}' is not an integer`)}#Xs(e,t,s,r){"number"!=typeof t&&r.push(`Field '${e}' is not a real number`)}#Js(e,t,s,r){"boolean"!=typeof t&&r.push(`Field '${e}' is not a boolean`)}#Qs(e,t,s,r){"string"==typeof t&&!1!==t.startsWith("http")||r.push(`Field '${e}' is not a valid URL`)}#Zs(e,t,s,r){"object"==typeof t?this.#Us(e,t,s.fields,r):r.push(`Field '${e}' is not an object`)}#er(e,t,s,r){if(!Array.isArray(t))return void r.push(`Field '${e}' is not a list`);const i=t;for(const t in i){const n=this.#Ws(e,t),a=i[t];this.#_s(n,a,s.items,r)}}#tr(e,t,s,r){if(!1===s.options.includes(t)){const t=s.options.map(e=>String(e));r.push(`Field '${e}' is not one of: ${t.join(", ")}`)}}#Ws(e,t){return""===e?t:`${e}.${t}`}}const cr="content-type",lr="x-jitar-content-type",ur="x-jitar-procedure-version",hr="application/json",dr="application/octet-stream";class pr extends Error{constructor(){super("Invalid worker id")}}class mr{#he;#sr;#H=new B;#rr=new or;constructor(e,t){this.#he=e,this.#sr=t}connect(){return Promise.resolve()}disconnect(){return Promise.resolve()}async provide(e){const t=`${this.#he}/${e}`,s=await this.#ir(t,{method:"GET"}),r=s.headers.get(cr)??dr,i=await s.arrayBuffer(),n=Buffer.from(i);return new oe(e,r,n)}async isHealthy(){const e=`${this.#he}/health/status`,t=await this.#ir(e,{method:"GET"});return"true"===await t.text()}async getHealth(){const e=`${this.#he}/health`,t=await this.#ir(e,{method:"GET"}),s=await t.json();return new Map(Object.entries(s))}async addWorker(e,t,s){const r=`${this.#he}/workers`,i={url:e,procedureNames:t,trustKey:s},n={method:"POST",headers:{"Content-Type":hr},body:JSON.stringify(i)},a=await this.#ir(r,n),o=a.headers.get(cr);if(null===o||!1===o.includes(hr))throw new pr;const c=await a.json();if(!1===this.#rr.validate(c,{id:{type:"string",required:!0}}).valid)throw new pr;return c.id}async reportWorker(e,t){const s=`${this.#he}/workers/${e}/report`,r={state:t},i={method:"POST",headers:{"Content-Type":hr},body:JSON.stringify(r)};await this.#ir(s,i)}async removeWorker(e){const t=`${this.#he}/workers/${e}`,s={method:"DELETE",headers:{"Content-Type":hr}};await this.#ir(t,s)}async run(e){e.setHeader(cr,hr);const t=Object.fromEntries(e.args),s=Object.fromEntries(e.headers),r=e.version.toString();s[ur]=r;const i=`${this.#he}/rpc/${e.fqn}`,n={method:"POST",redirect:"manual",headers:s,body:await this.#nr(t)},a=await this.#ir(i,n,!1),o=a.status,c=await this.#ar(a),l=this.#or(a);return new $(o,c,l)}async#ir(e,t,s=!0){const r=await this.#sr.execute(e,t);if(s&&this.#cr(r)){const e=await this.#ar(r);throw this.#H.fromStatus(r.status,String(e))}return r}#cr(e){return e.status<200||e.status>399}async#nr(e){return JSON.stringify(e)}async#ar(e){const t=e.headers.get(lr)??e.headers.get(cr);if(t?.includes("undefined"))return;if(t?.includes("null"))return null;if(t?.includes("json"))return e.json();const s=await e.text();return t?.includes("boolean")?"true"===s:t?.includes("number")?Number(s):s}#or(e){const t=new Map;for(const[s,r]of e.headers)t.set(s,r);return t}}class fr{async execute(e,t){return fetch(e,t)}}class gr{#sr;constructor(e=new fr){this.#sr=e}build(e){return new mr(e,this.#sr)}}export{P as ArrayParameter,e as BadRequest,T as Class,ar as ClientBuilder,t as Forbidden,gr as HttpRemoteBuilder,C as Implementation,M as NamedParameter,s as NotFound,r as NotImplemented,L as ObjectParameter,i as PaymentRequired,I as Procedure,k as Request,$ as Response,N as Segment,n as ServerError,a as Teapot,o as Unauthorized,x as Version};
|
|
1
|
+
class BadRequest extends Error{constructor(message="Invalid request"){super(message)}}class Forbidden extends Error{constructor(message="Forbidden"){super(message)}}class NotFound extends Error{constructor(message="Not found"){super(message)}}class NotImplemented extends Error{constructor(message="Not implemented"){super(message)}}class PaymentRequired extends Error{constructor(message="Payment required"){super(message)}}class ServerError extends Error{constructor(message="Server error"){super(message)}}class Teapot extends Error{constructor(message="I'm a teapot"){super(message)}}class Unauthorized extends Error{constructor(message="Unauthorized"){super(message)}}const AccessLevels_PRIVATE="private",AccessLevels_PROTECTED="protected",AccessLevels_PUBLIC="public",RunModes_NORMAL="normal",RunModes_DRY="dry",StatusCodes_OK=200,StatusCodes_BAD_REQUEST=400,StatusCodes_UNAUTHORIZED=401,StatusCodes_PAYMENT_REQUIRED=402,StatusCodes_FORBIDDEN=403,StatusCodes_NOT_FOUND=404,StatusCodes_TEAPOT=418,StatusCodes_SERVER_ERROR=500,StatusCodes_NOT_IMPLEMENTED=501;class ImplementationNotFound extends NotFound{#fqn;#version;constructor(fqn,version){super(`No implementation found for procedure '${fqn}' with version '${version}'`),this.name="ImplementationNotFound",this.#fqn=fqn,this.#version=version}get fqn(){return this.#fqn}get version(){return this.#version}}class InvalidParameterValue extends BadRequest{#parameterName;constructor(parameterName){super(`Invalid value for parameter '${parameterName}'`),this.name="InvalidParameterValue",this.#parameterName=parameterName}get parameterName(){return this.#parameterName}}class InvalidVersionNumber extends BadRequest{#number;constructor(number){super(`Invalid version number '${number}'`),this.name="InvalidVersionNumber",this.#number=number}get number(){return this.#number}}class MissingParameterValue extends BadRequest{#parameterName;constructor(parameterName){super(`Missing value for parameter '${parameterName}'`),this.name="MissingParameterValue",this.#parameterName=parameterName}get parameterName(){return this.#parameterName}}class ProcedureNotAccessible extends Forbidden{constructor(fqn,versionNumber){super(`Procedure '${fqn}' (v${versionNumber}) is not accessible`)}}class ProcedureNotFound extends NotFound{#fqn;constructor(fqn){super(`Procedure '${fqn}' not found`),this.name="ProcedureNotFound",this.#fqn=fqn}get fqn(){return this.#fqn}}class UnknownParameter extends BadRequest{#parameterName;constructor(parameterName){super(`Unknown parameter ${parameterName}`),this.name="UnknownParameter",this.#parameterName=parameterName}get parameterName(){return this.#parameterName}}class Segment{#id;#classes=new Map;#procedures=new Map;constructor(id){this.#id=id}get id(){return this.#id}addClass(clazz){return this.#classes.set(clazz.fqn,clazz),this}hasClass(fqn){return void 0!==this.getClass(fqn)}getClass(fqn){return this.#classes.get(fqn)}getClassByImplementation(implementation){return this.getClasses().find(clazz=>clazz.implementation===implementation)}getClasses(){return[...this.#classes.values()]}addProcedure(procedure){return this.#procedures.set(procedure.fqn,procedure),this}hasProcedure(fqn){return this.#procedures.has(fqn)}getProcedure(fqn){return this.#procedures.get(fqn)}getExposedProcedures(){return[...this.#procedures.values()].filter(procedure=>procedure.public||procedure.protected)}}class Class{#fqn;#implementation;constructor(fqn,implementation){this.#fqn=fqn,this.#implementation=implementation}get fqn(){return this.#fqn}get implementation(){return this.#implementation}}class Version{static get DEFAULT(){return new Version(0,0,0)}#major;#minor;#patch;constructor(major=0,minor=0,patch=0){this.#major=major,this.#minor=minor,this.#patch=patch}get major(){return this.#major}get minor(){return this.#minor}get patch(){return this.#patch}equals(version){return this.#major===version.major&&this.#minor===version.minor&&this.#patch===version.patch}greater(version){return this.#major!==version.major?this.#major>version.major:this.#minor!==version.minor?this.#minor>version.minor:this.#patch!==version.patch&&this.#patch>version.patch}less(version){return this.#major!==version.major?this.#major<version.major:this.#minor!==version.minor?this.#minor<version.minor:this.#patch!==version.patch&&this.#patch<version.patch}toString(){return`${this.#major}.${this.#minor}.${this.#patch}`}}class Procedure{#fqn;#implementations=new Map;#latestImplementation;constructor(fqn){this.#fqn=fqn}get fqn(){return this.#fqn}get public(){return[...this.#implementations.values()].some(implementation=>implementation.public)}get protected(){return[...this.#implementations.values()].some(implementation=>implementation.protected)}addImplementation(implementation){return this.#implementations.set(implementation.version,implementation),this.#isNewLatestImplementation(implementation)&&(this.#latestImplementation=implementation),this}#isNewLatestImplementation(implementation){return void 0===this.#latestImplementation||implementation.version.greater(this.#latestImplementation.version)}getImplementation(version){const selectedVersion=this.#selectAvailableVersion(version);return this.#implementations.get(selectedVersion)}#selectAvailableVersion(version){let selectedVersion=Version.DEFAULT;for(const implementationVersion of this.#implementations.keys()){if(implementationVersion.equals(version))return implementationVersion;implementationVersion.greater(version)||selectedVersion.less(implementationVersion)&&(selectedVersion=implementationVersion)}return selectedVersion}}class Implementation{#version;#access;#parameters;#executable;constructor(version,access,parameters,executable){this.#version=version,this.#access=access,this.#parameters=parameters,this.#executable=executable}get version(){return this.#version}get public(){return this.#access===AccessLevels_PUBLIC}get protected(){return this.#access===AccessLevels_PROTECTED}get private(){return this.#access===AccessLevels_PRIVATE}get parameters(){return this.#parameters}get executable(){return this.#executable}}class Parameter{#name;#isOptional;constructor(name,isOptional=!1){this.#name=name,this.#isOptional=isOptional}get name(){return this.#name}get isOptional(){return this.#isOptional}}class NamedParameter extends Parameter{}class DestructuredParameter extends Parameter{#variables;constructor(variables,name,isOptional){super(name??"(anonymous)",isOptional),this.#variables=variables}get variables(){return this.#variables}}class ArrayParameter extends DestructuredParameter{}class ObjectParameter extends DestructuredParameter{}class Request{#fqn;#version;#args;#headers=new Map;#mode;constructor(fqn,version,args,headers,mode){this.#fqn=fqn,this.#version=version,this.#args=args,this.#headers=headers,this.#mode=mode}get fqn(){return this.#fqn}get version(){return this.#version}get args(){return this.#args}get headers(){return this.#headers}get mode(){return this.#mode}clearArguments(){this.#args.clear()}setArgument(name,value){this.#args.set(name,value)}getArgument(name){return this.#args.get(name)}hasArgument(name){return this.#args.has(name)}removeArgument(name){this.#args.delete(name)}clearHeaders(){this.#headers.clear()}setHeader(name,value){this.#headers.set(name.toLowerCase(),value)}getHeader(name){return this.#headers.get(name.toLowerCase())}hasHeader(name){return this.#headers.has(name.toLowerCase())}removeHeader(name){this.#headers.delete(name.toLowerCase())}}class Response{#status;#result;#headers;constructor(status,result=void 0,headers=new Map){this.#status=status,this.#result=result,this.#headers=headers}get status(){return this.#status}get result(){return this.#result}set result(value){this.#result=value}get headers(){return this.#headers}clearHeaders(){this.#headers.clear()}setHeader(name,value){this.#headers.set(name.toLowerCase(),value)}getHeader(name){return this.#headers.get(name.toLowerCase())}hasHeader(name){return this.#headers.has(name.toLowerCase())}removeHeader(name){this.#headers.delete(name.toLowerCase())}}class ArgumentExtractor{extract(parameters,args){const argsCopy=this.#copyArguments(parameters,args),values=[];for(const parameter of parameters){const value=this.#extractArgumentValue(parameter,argsCopy);values.push(value)}if(argsCopy.size>0){const name=argsCopy.keys().next().value;throw new UnknownParameter(name)}return values}#copyArguments(parameters,args){const copy=new Map;for(const[key,value]of args){if(this.#isOptionalArgument(key)){const name=this.#getParameterName(key);!0===this.#containsParameter(parameters,name)&©.set(name,value);continue}copy.set(key,value)}return copy}#isOptionalArgument(argument){return argument.startsWith("*")}#getParameterName(argument){return argument.substring(1)}#containsParameter(parameters,name){return void 0!==parameters.find(parameter=>parameter.name===name)}#extractArgumentValue(parameter,args,parent){return parameter instanceof NamedParameter?this.#extractNamedArgumentValue(parameter,args,parent):this.#extractDestructedArgumentValue(parameter,args)}#extractNamedArgumentValue(parameter,args,parent){const value=args.get(parameter.name);if(this.#isMissingParameterValue(parameter,value,parent))throw new MissingParameterValue(parameter.name);if(this.#isInvalidRestParameter(parameter,value,parent))throw new InvalidParameterValue(parameter.name);return args.delete(parameter.name),value}#extractDestructedArgumentValue(parameter,args){return parameter instanceof ArrayParameter?this.#extractArrayArgumentValue(parameter,args):this.#extractObjectArgumentValue(parameter,args)}#extractArrayArgumentValue(parameter,args){const values=this.#extractVariableValues(parameter,args);return void 0!==values?Object.values(values):void 0}#extractObjectArgumentValue(parameter,args){return this.#extractVariableValues(parameter,args)}#extractVariableValues(parameter,args){const useIndex=parameter instanceof ArrayParameter,values={},missingValues=[];let containsValues=!1,index=0;for(const variable of parameter.variables){const key=useIndex?index++:variable.name,value=this.#extractArgumentValue(variable,args,parameter);void 0!==value?containsValues=!0:!1===variable.isOptional&&missingValues.push(variable.name),values[key]=value}if(!0===containsValues&&missingValues.length>0)throw new MissingParameterValue(missingValues[0]);return containsValues?values:void 0}#isMissingParameterValue(parameter,value,parent){return void 0===value&&(!0!==parameter.isOptional&&!0!==parent?.isOptional)}#isInvalidRestParameter(parameter,value,parent){return!1!==parameter.name.startsWith("...")&&(void 0===parent&&value instanceof Array==!1||parent instanceof ArrayParameter&&value instanceof Array==!1||parent instanceof ObjectParameter&&value instanceof Object==!1)}}class ErrorConverter{toStatus(error){return error instanceof BadRequest?StatusCodes_BAD_REQUEST:error instanceof Forbidden?StatusCodes_FORBIDDEN:error instanceof NotFound?StatusCodes_NOT_FOUND:error instanceof NotImplemented?StatusCodes_NOT_IMPLEMENTED:error instanceof PaymentRequired?StatusCodes_PAYMENT_REQUIRED:error instanceof Teapot?StatusCodes_TEAPOT:error instanceof Unauthorized?StatusCodes_UNAUTHORIZED:StatusCodes_SERVER_ERROR}fromStatus(status,message){switch(status){case StatusCodes_BAD_REQUEST:return new BadRequest(message);case StatusCodes_FORBIDDEN:return new Forbidden(message);case StatusCodes_NOT_FOUND:return new NotFound(message);case StatusCodes_NOT_IMPLEMENTED:return new NotImplemented(message);case StatusCodes_PAYMENT_REQUIRED:return new PaymentRequired(message);case StatusCodes_TEAPOT:return new Teapot(message);case StatusCodes_UNAUTHORIZED:return new Unauthorized(message);default:return new ServerError(message)}}}const VERSION_EXPRESSION=/^\d+(?:\.\d+){0,2}$/;class VersionParser{parse(number){if(0===number.trim().length)return Version.DEFAULT;if(!1===VERSION_EXPRESSION.test(number))throw new InvalidVersionNumber(number);const parts=number.split(".");switch(parts.length){case 1:return new Version(Number.parseInt(parts[0]));case 2:return new Version(Number.parseInt(parts[0]),Number.parseInt(parts[1]));default:return new Version(Number.parseInt(parts[0]),Number.parseInt(parts[1]),Number.parseInt(parts[2]))}}}class InvalidSegment extends ServerError{constructor(){super("Invalid segment")}}class StartingExecutionManagerFailed extends Error{constructor(cause){super("Starting execution manager failed",{cause:cause})}}class StoppingExecutionManagerFailed extends Error{constructor(cause){super("Stopping execution manager failed",{cause:cause})}}class Application{#segments=new Map;addSegment(segment){this.#segments.set(segment.id,segment)}clearSegments(){this.#segments.clear()}getClassNames(){const names=new Set;for(const segment of this.#segments.values()){segment.getClasses().forEach(clazz=>names.add(clazz.fqn))}return[...names.values()]}hasClass(fqn){return this.getClassNames().includes(fqn)}getClass(fqn){for(const segment of this.#segments.values())if(segment.hasClass(fqn))return segment.getClass(fqn)}getClassByImplementation(implementation){for(const segment of this.#segments.values()){const clazz=segment.getClassByImplementation(implementation);if(void 0!==clazz)return clazz}}getProcedureNames(){const names=new Set;for(const segment of this.#segments.values()){segment.getExposedProcedures().forEach(procedure=>names.add(procedure.fqn))}return[...names.values()]}hasProcedure(fqn){return this.getProcedureNames().includes(fqn)}getProcedure(fqn){for(const segment of this.#segments.values())if(segment.hasProcedure(fqn))return segment.getProcedure(fqn)}}class ExecutionManager{#moduleImporter;#segmentFiles;#argumentConstructor=new ArgumentExtractor;#errorConverter=new ErrorConverter;#application=new Application;constructor(moduleImporter,segmentFiles=[]){this.#moduleImporter=moduleImporter,this.#segmentFiles=segmentFiles}async start(){try{await this.#loadSegments()}catch(error){throw new StartingExecutionManagerFailed(error)}}async stop(){try{return this.#clearSegments()}catch(error){throw new StoppingExecutionManagerFailed(error)}}async loadSegment(filename){const module=await this.#moduleImporter.import(filename);this.addSegment(module.default)}async addSegment(segment){if(segment instanceof Segment==!1)throw new InvalidSegment;this.#application.addSegment(segment)}getClassNames(){return this.#application.getClassNames()}hasClass(fqn){return this.#application.hasClass(fqn)}getClass(fqn){return this.#application.getClass(fqn)}getClassByImplementation(implementation){return this.#application.getClassByImplementation(implementation)}getProcedureNames(){return this.#application.getProcedureNames()}hasProcedure(fqn){return this.#application.hasProcedure(fqn)}getProcedure(fqn){return this.#application.getProcedure(fqn)}async run(request){const implementation=this.#getImplementation(request.fqn,request.version),args=this.#argumentConstructor.extract(implementation.parameters,request.args);return request.mode===RunModes_DRY?new Response(StatusCodes_OK,void 0):this.#runImplementation(request,implementation,args)}async#loadSegments(){await Promise.all(this.#segmentFiles.map(filename=>this.loadSegment(filename)))}#clearSegments(){this.#application.clearSegments()}#getImplementation(fqn,version){const procedure=this.#application.getProcedure(fqn);if(void 0===procedure)throw new ProcedureNotFound(fqn);const implementation=procedure.getImplementation(version);if(void 0===implementation)throw new ImplementationNotFound(procedure.fqn,version.toString());return implementation}async#runImplementation(request,implementation,args){try{const result=await implementation.executable.call(request,...args);return new Response(StatusCodes_OK,result)}catch(error){const status=this.#errorConverter.toStatus(error);return new Response(status,error)}}}class RequestCancelled extends ServerError{constructor(){super("Request cancelled")}}class RequestPool{#runner;#size;#queue=[];#started=!1;#activeCount=0;constructor(runner,size=20){this.#runner=runner,this.#size=size}start(){this.#started=!0,this.#update()}stop(){this.#started=!1,this.#cancelAll()}run(request){return new Promise((resolve,reject)=>{this.#queue.push({request:request,resolve:resolve,reject:reject}),this.#update()})}#update(){if(this.#noUpdateRequired())return;const queueSize=this.#queue.length,idleCount=this.#size-this.#activeCount,activationCount=Math.min(queueSize,idleCount);this.#activate(activationCount)}#noUpdateRequired(){return this.#isStopped()||this.#queueEmpty()||this.#allActive()}#isStopped(){return!1===this.#started}#queueEmpty(){return 0===this.#queue.length}#allActive(){return this.#activeCount>=this.#size}#activate(count){const items=this.#queue.splice(0,count);this.#activeCount+=count,items.forEach(item=>this.#perform(item))}async#perform(item){try{const response=await this.#runner.run(item.request);item.resolve(response)}catch(error){item.reject(error)}finally{this.#activeCount--,this.#update()}}#cancelAll(){for(;this.#queue.length>0;){const item=this.#queue.shift();void 0!==item&&this.#cancel(item)}}#cancel(item){item.reject(new RequestCancelled)}}const States$2_STARTING="starting",States$2_AVAILABLE="available",States$2_UNAVAILABLE="unavailable",States$2_STOPPING="stopping",States$2_STOPPED="stopped";class StateManager{#state=States$2_STOPPED;get state(){return this.#state}set state(state){this.#state=state}async start(task){if(!this.isStarted())try{this.setStarting(),await task()}catch(error){throw this.setStopped(),error}}async stop(task){this.isStopped()||(this.setStopping(),await task(),this.setStopped())}isStarted(){return this.#notHasState(States$2_STOPPED)}isStopped(){return this.#hasState(States$2_STOPPED)}isAvailable(){return this.#hasState(States$2_AVAILABLE)}setStarting(){this.#state=States$2_STARTING}setAvailable(){this.#state=States$2_AVAILABLE}setUnavailable(){this.#state=States$2_UNAVAILABLE}setAvailability(available){return this.#state=available?States$2_AVAILABLE:States$2_UNAVAILABLE,this.#state}setStopping(){this.#state=States$2_STOPPING}setStopped(){this.#state=States$2_STOPPED}#hasState(...states){return states.includes(this.#state)}#notHasState(...states){return!1===this.#hasState(...states)}}class RemoteGateway{#url;#remote;#stateManager=new StateManager;constructor(configuration){this.#url=configuration.url,this.#remote=configuration.remote}get url(){return this.#url}get state(){return this.#stateManager.state}get trustKey(){}async start(){return this.#stateManager.start(async()=>{await this.#remote.connect(),await this.updateState()})}async stop(){return this.#stateManager.stop(async()=>{await this.#remote.disconnect()})}isHealthy(){return this.#remote.isHealthy()}getHealth(){return this.#remote.getHealth()}async updateState(){const healthy=await this.isHealthy();return this.#stateManager.setAvailability(healthy)}getProcedureNames(){throw new NotImplemented}hasProcedure(name){throw new NotImplemented}addWorker(worker){return this.#remote.addWorker(worker.url,worker.getProcedureNames(),worker.trustKey)}reportWorker(id,state){return this.#remote.reportWorker(id,state)}removeWorker(id){return this.#remote.removeWorker(id)}run(request){return this.#remote.run(request)}}class InvalidPath extends Error{constructor(location){super(`Invalid location '${location}'`)}}class FileNotFound extends Error{constructor(filename){super(`File could not be found from '${filename}'`)}}class File{#location;#type;#content;constructor(location,type,content){this.#location=location,this.#type=type,this.#content=content}get location(){return this.#location}get type(){return this.#type}get content(){return this.#content}get size(){return this.#content.length}}class FileManager{#rootLocation;#fileSystem;constructor(fileSystem,location,root=""){const joinedLocation=fileSystem.join(root,location),rootLocation=fileSystem.resolve(joinedLocation);this.#rootLocation=fileSystem.normalize(rootLocation),this.#fileSystem=fileSystem}normalizeLocation(location){return this.#fileSystem.normalize(location)}getAbsoluteLocation(filename){const location=this.#fileSystem.isAbsolute(filename)?filename:this.#fileSystem.join(this.#rootLocation,filename),absoluteLocation=this.#fileSystem.resolve(location),normalizedLocation=this.normalizeLocation(absoluteLocation);return this.#validateLocation(normalizedLocation,filename),normalizedLocation}getRelativeLocation(filename){const absoluteLocation=this.getAbsoluteLocation(filename),relativeLocation=this.#fileSystem.relative(this.#rootLocation,absoluteLocation);return this.normalizeLocation(relativeLocation)}async getType(filename){const location=this.getAbsoluteLocation(filename);return await this.#fileSystem.mimeType(location)??"application/octet-stream"}async getContent(filename){const location=this.getAbsoluteLocation(filename);if(!1===await this.#fileSystem.exists(location))throw new FileNotFound(filename);return this.#fileSystem.read(location)}async exists(filename){const location=this.getAbsoluteLocation(filename);return this.#fileSystem.exists(location)}isDirectory(filename){const location=this.getAbsoluteLocation(filename);return this.#fileSystem.isDirectory(location)}async read(filename){const[type,content]=await Promise.all([this.getType(filename),this.getContent(filename)]);return new File(filename,type,content)}async write(filename,content){const location=this.getAbsoluteLocation(filename);return this.#fileSystem.write(location,content)}async copy(source,destination){const sourceLocation=this.getAbsoluteLocation(source),destinationLocation=this.getAbsoluteLocation(destination);return this.#fileSystem.copy(sourceLocation,destinationLocation)}async delete(filename){const location=this.getAbsoluteLocation(filename);return this.#fileSystem.delete(location)}async filter(pattern){const normalizedPattern=this.normalizeLocation(pattern);return(await this.#fileSystem.filter(this.#rootLocation,normalizedPattern)).map(filename=>this.normalizeLocation(filename))}async filterWithIgnores(pattern,ignorePatterns){const allFilenames=await this.filter(pattern),ignoreFilters=ignorePatterns.map(pattern=>this.filter(pattern)),ignoredFilenames=await Promise.all(ignoreFilters),ignoredSet=new Set(ignoredFilenames.flat());return allFilenames.filter(filename=>!1===ignoredSet.has(filename))}#validateLocation(location,filename){const relativePath=this.#fileSystem.relative(this.#rootLocation,location),normalizedPath=this.normalizeLocation(relativePath);if(".."===normalizedPath||normalizedPath.startsWith("../"))throw new InvalidPath(filename);if(this.#fileSystem.isAbsolute(normalizedPath))throw new InvalidPath(filename)}}class RemoteFilesNotSupported extends Error{constructor(){super("Remote files are not supported")}}class RemoteFileSystem{copy(source,destination){throw new RemoteFilesNotSupported}delete(location){throw new RemoteFilesNotSupported}exists(location){throw new RemoteFilesNotSupported}async filter(location,pattern){return[]}isAbsolute(location){return location.startsWith("/")}isDirectory(location){throw new RemoteFilesNotSupported}join(...paths){return paths.filter(path=>""!==path.trim()).join("/")}read(location){throw new RemoteFilesNotSupported}resolve(location){return location}relative(from,to){throw new RemoteFilesNotSupported}normalize(location){return location}mimeType(location){throw new RemoteFilesNotSupported}write(location,content){throw new RemoteFilesNotSupported}}class RemoteFileManager extends FileManager{constructor(location,root){super(new RemoteFileSystem,location,root)}}class ModuleNotLoaded extends Error{constructor(url,cause){super(`Module could not be loaded from '${url}'`,{cause:cause})}}class ImportManager{#moduleLocator;constructor(moduleLocator){this.#moduleLocator=moduleLocator}async import(filename){const location=this.#moduleLocator.locate(filename);try{return await(import(location))}catch(error){throw new ModuleNotLoaded(location,error)}}}class RemoteModuleLocator{constructor(location){}locate(filename){throw new ModuleNotLoaded(filename,"Remote module loading is not allowed")}}class RemoteImportManager extends ImportManager{constructor(location){super(new RemoteModuleLocator(location))}}class SourcingManager{#fileManager;#importManager;constructor(fileManager,importManager){this.#fileManager=fileManager,this.#importManager=importManager}get fileManager(){return this.#fileManager}get importManager(){return this.#importManager}async filter(...patterns){return(await Promise.all(patterns.map(pattern=>this.#fileManager.filter(pattern)))).flat().map(file=>this.#fileManager.getRelativeLocation(file))}exists(filename){return this.#fileManager.exists(filename)}read(filename){return this.#fileManager.read(filename)}import(filename){return this.#importManager.import(filename)}}class RemoteSourcingManager extends SourcingManager{constructor(location){super(new RemoteFileManager(location),new RemoteImportManager(location))}fork(location){const absoluteLocation=this.fileManager.getAbsoluteLocation(location);return new RemoteSourcingManager(absoluteLocation)}}class RequestNotTrusted extends Unauthorized{constructor(){super("Request not trusted")}}class LocalWorker{#id;#url;#trustKey;#gateway;#registerAtGateway;#executionManager;#serializer;#healthManager;#reportTask;#stateManager=new StateManager;constructor(configuration){this.#url=configuration.url,this.#trustKey=configuration.trustKey,this.#gateway=configuration.gateway,this.#registerAtGateway=!0===configuration.registerAtGateway,this.#executionManager=configuration.executionManager,this.#serializer=configuration.serializer,this.#healthManager=configuration.healthManager;const scheduleManager=configuration.scheduleManager;this.#reportTask=scheduleManager.create(()=>this.#report(),configuration.reportInterval)}get id(){return this.#id}set id(id){this.#id=id}get state(){return this.#stateManager.state}get url(){return this.#url}get trustKey(){return this.#trustKey}async start(){return this.#stateManager.start(async()=>{await Promise.all([this.#executionManager.start(),this.#healthManager.start()]),void 0!==this.#gateway&&(await this.#gateway.start(),this.#registerAtGateway&&(this.#id=await this.#gateway.addWorker(this),this.#reportTask.start())),await this.updateState()})}async stop(){return this.#stateManager.stop(async()=>{void 0!==this.#gateway&&(void 0!==this.#id&&(this.#reportTask.stop(),await this.#gateway.removeWorker(this.#id)),await this.#gateway.stop()),await Promise.all([this.#healthManager.stop(),this.#executionManager.stop()])})}getProcedureNames(){return this.#executionManager.getProcedureNames()}hasProcedure(name){return this.#executionManager.hasProcedure(name)}isHealthy(){return this.#healthManager.isHealthy()}getHealth(){return this.#healthManager.getHealth()}isAvailable(){return this.#stateManager.isAvailable()}async updateState(){const healthy=await this.isHealthy();return this.#stateManager.setAvailability(healthy)}async reportState(state){if(void 0!==this.#gateway&&void 0!==this.#id)return this.#gateway.reportWorker(this.#id,state)}async run(request){return this.#mustRunLocal(request)?this.#runLocal(request):this.#runRemote(request)}#mustRunLocal(request){return void 0===this.#gateway||this.#executionManager.hasProcedure(request.fqn)}async#runLocal(request){const procedure=this.#executionManager.getProcedure(request.fqn),implementation=procedure?.getImplementation(request.version);if(this.#procedureNotFound(implementation))throw new ProcedureNotFound(request.fqn);if(this.#requestNotTrusted(request,implementation))throw new RequestNotTrusted;const dataEncoding=request.getHeader("X-Jitar-Data-Encoding");"serialized"===dataEncoding&&(request=await this.#deserializeRequest(request)),request.removeHeader("X-Jitar-Data-Encoding");const response=await this.#executionManager.run(request);return"serialized"===dataEncoding?this.#serializeResponse(response):response}#procedureNotFound(implementation){return void 0===implementation||implementation.private}#requestNotTrusted(request,implementation){if(implementation.public)return!1;const trustKey=request.getHeader("X-Jitar-Trust-Key");return this.#trustKey!==trustKey}async#runRemote(request){(request=await this.#serializeRequest(request)).setHeader("X-Jitar-Data-Encoding","serialized"),void 0!==this.#trustKey&&request.setHeader("X-Jitar-Trust-Key",this.#trustKey);const response=await this.#gateway.run(request);return this.#deserializeResponse(response)}async#serializeRequest(request){const serializedArgs=new Map;for(const[key,value]of request.args){const serializedValue=await this.#serializer.serialize(value);serializedArgs.set(key,serializedValue)}return new Request(request.fqn,request.version,serializedArgs,request.headers,request.mode)}async#deserializeRequest(request){const deserializedArgs=new Map;for(const[key,value]of request.args){const deserializedValue=await this.#serializer.deserialize(value);deserializedArgs.set(key,deserializedValue)}return new Request(request.fqn,request.version,deserializedArgs,request.headers,request.mode)}async#serializeResponse(response){const serializedResult=await this.#serializer.serialize(response.result);return new Response(response.status,serializedResult,response.headers)}async#deserializeResponse(response){const deserializedResult=await this.#serializer.deserialize(response.result);return new Response(response.status,deserializedResult,response.headers)}async#report(){const state=await this.updateState();return this.reportState(state)}}class StartingClientFailed extends Error{constructor(cause){super("Starting client failed",{cause:cause})}}class StoppingClientFailed extends Error{constructor(cause){super("Stopping client failed",{cause:cause})}}class ProcedureRunner{#runner;constructor(runner){this.#runner=runner}async handle(request,next){return this.#runner.run(request)}}class Runtime{#versionParser=new VersionParser;constructor(){this.#initGlobals()}#initGlobals(){const globals=globalThis;globals.__run=this.#run.bind(this),globals.ProcedureNotAccessible=ProcedureNotAccessible}async#run(fqn,versionNumber,args,sourceRequest){const version=this.#versionParser.parse(versionNumber),argsMap=new Map(Object.entries(args)),headersMap=sourceRequest instanceof Request?sourceRequest.headers:new Map,targetRequest=new Request(fqn,version,argsMap,headersMap,RunModes_NORMAL),trustKey=this.getTrustKey();void 0!==trustKey&&targetRequest.setHeader("X-Jitar-Trust-Key",trustKey);const targetResponse=await this.runInternal(targetRequest);if(targetResponse.status!==StatusCodes_OK)throw targetResponse.result;return targetResponse.result}}class Client extends Runtime{#worker;#middlewareManager;#requestPool=new RequestPool(this);constructor(configuration){super(),this.#worker=new LocalWorker({url:configuration.remoteUrl,gateway:new RemoteGateway({url:configuration.remoteUrl,remote:configuration.remote}),healthManager:configuration.healthManager,executionManager:configuration.executionManager,serializer:configuration.serializer,scheduleManager:configuration.scheduleManager}),this.#middlewareManager=configuration.middlewareManager}get worker(){return this.#worker}async start(){try{await this.#setUp(),this.#requestPool.start()}catch(error){throw new StartingClientFailed(error)}}async stop(){try{this.#requestPool.stop(),await this.#tearDown()}catch(error){throw new StoppingClientFailed(error)}}getTrustKey(){}run(request){return this.#middlewareManager.handle(request)}async runInternal(request){return this.#requestPool.run(request)}async#setUp(){await Promise.all([this.#worker.start(),this.#middlewareManager.start()]);const procedureRunner=new ProcedureRunner(this.#worker);this.#middlewareManager.addMiddleware(procedureRunner)}async#tearDown(){await Promise.all([this.#middlewareManager.stop(),this.#worker.stop()])}}const States$1_STARTING="starting",States$1_STARTED="started",States$1_STOPPING="stopping",States$1_STOPPED="stopped";class InvalidHealthCheck extends ServerError{constructor(){super("Invalid health check")}}class StartingHealthManagerFailed extends Error{constructor(cause){super("Starting health manager failed",{cause:cause})}}class StoppingHealthManagerFailed extends Error{constructor(cause){super("Stopping health manager failed",{cause:cause})}}class HealthManager{#state=States$1_STOPPED;#healthChecks=new Map;#moduleImporter;#healthCheckFiles;constructor(moduleImporter,healthCheckFiles=[]){this.#moduleImporter=moduleImporter,this.#healthCheckFiles=healthCheckFiles}get state(){return this.#state}async start(){if(this.#state===States$1_STOPPED)try{this.#state=States$1_STARTING,await this.#loadHealthChecks(),this.#state=States$1_STARTED}catch(error){throw this.#state=States$1_STOPPED,new StartingHealthManagerFailed(error)}}async stop(){if(this.#state===States$1_STARTED)try{this.#state=States$1_STOPPING,this.clearHealthChecks(),this.#state=States$1_STOPPED}catch(error){throw this.#state=States$1_STARTED,new StoppingHealthManagerFailed(error)}}async loadHealthCheck(filename){const healthCheck=await this.#loadHealthCheck(filename);this.addHealthCheck(healthCheck)}addHealthCheck(healthCheck){if(void 0===healthCheck.isHealthy)throw new InvalidHealthCheck;this.#healthChecks.set(healthCheck.name,healthCheck)}clearHealthChecks(){this.#healthChecks.clear()}async isHealthy(){const promises=[];for(const healthCheck of this.#healthChecks.values()){const promise=this.#executeHealthCheck(healthCheck);promises.push(promise)}return Promise.all(promises).then(results=>results.every(result=>result)).catch(()=>!1)}async getHealth(){const promises=[];for(const[name,healthCheck]of this.#healthChecks){const promise=this.#executeHealthCheck(healthCheck).then(result=>({name:name,isHealthy:result})).catch(()=>({name:name,isHealthy:!1}));promises.push(promise)}const healthChecks=new Map;return Promise.allSettled(promises).then(results=>results.forEach(result=>this.#handleHealthCheckResult(result,healthChecks))).then(()=>healthChecks)}async#loadHealthChecks(){(await Promise.all(this.#healthCheckFiles.map(filename=>this.#loadHealthCheck(filename)))).forEach(healthCheck=>this.addHealthCheck(healthCheck))}async#loadHealthCheck(filename){return(await this.#moduleImporter.import(filename)).default}#handleHealthCheckResult(result,healthChecks){"fulfilled"===result.status?healthChecks.set(result.value.name,result.value.isHealthy):healthChecks.set(result.reason.name,!1)}async#executeHealthCheck(healthCheck){const health=healthCheck.isHealthy(),milliseconds=healthCheck.timeout;if(void 0===milliseconds)return health;const timeout=new Promise(resolve=>{setTimeout(resolve,milliseconds)}).then(()=>!1);return Promise.race([timeout,health])}}const LogLevels_DEBUG=0,LogLevels_INFO=1,LogLevels_WARN=2,LogLevels_ERROR=3;class Logger{#logLevel;#writer;constructor(logLevel=LogLevels_INFO,writer=console){this.#logLevel=logLevel,this.#writer=writer}debug(...message){if(this.#logLevel>LogLevels_DEBUG)return;const messageString=this.#createMessage("DEBUG",message);this.#writer.debug(messageString)}info(...message){if(this.#logLevel>LogLevels_INFO)return;const messageString=this.#createMessage("INFO",message);this.#writer.info(messageString)}warn(...message){if(this.#logLevel>LogLevels_WARN)return;const messageString=this.#createMessage("WARN",message);this.#writer.warn(messageString)}error(...message){if(this.#logLevel>LogLevels_ERROR)return;const messageString=this.#createMessage("ERROR",message);this.#writer.error(messageString)}fatal(...message){const messageString=this.#createMessage("FATAL",message);this.#writer.error(messageString)}#createMessage(logLevel,messages){return`[${(new Date).toISOString()}][${logLevel}] ${messages.map(value=>this.#interpretValue(value)).join(" ")}`}#interpretValue(value,level=0){let result;switch(typeof value){case"string":result=value;break;case"object":result=this.#interpretObject(value,level+1);break;case"undefined":result="undefined";break;case"function":result="function";break;default:result=String(value)}return`${this.#indent(level)}${result}`}#interpretObject(object,level){if(null===object)return"null";if(Array.isArray(object)){return`[\n${object.map(value=>this.#interpretValue(value,level)).join(",\n")}\n${this.#indent(level-1)}]`}if(object instanceof Error){const causeValue=void 0!==object.cause?this.#interpretValue(object.cause,level+1):void 0,cause=void 0!==causeValue?`\n=>${causeValue}`:"";return`${object.message}${cause}`}return JSON.stringify(object)}#indent(level){return" ".repeat(level)}}const States_STARTING="starting",States_STARTED="started",States_STOPPING="stopping",States_STOPPED="stopped";class InvalidMiddleware extends ServerError{constructor(){super("Invalid middleware")}}class StartingMiddlewareManagerFailed extends Error{constructor(cause){super("Starting middleware manager failed",{cause:cause})}}class StoppingMiddlewareManagerFailed extends Error{constructor(cause){super("Stopping middleware manager failed",{cause:cause})}}class MiddlewareManager{#state=States_STOPPED;#middlewares=[];#moduleImporter;#middlewareFiles;constructor(moduleImporter,middlewareFiles=[]){this.#moduleImporter=moduleImporter,this.#middlewareFiles=middlewareFiles}get state(){return this.#state}async start(){if(this.#state===States_STOPPED)try{this.#state=States_STARTING,await this.#loadMiddlewares(),this.#state=States_STARTED}catch(error){throw this.#state=States_STOPPED,new StartingMiddlewareManagerFailed(error)}}async stop(){if(this.#state===States_STARTED)try{this.#state=States_STOPPING,this.clearMiddlewares(),this.#state=States_STOPPED}catch(error){throw this.#state=States_STARTED,new StoppingMiddlewareManagerFailed(error)}}async loadMiddleware(filename){const middleware=await this.#loadMiddleware(filename);this.addMiddleware(middleware)}addMiddleware(middleware){if(void 0===middleware?.handle)throw new InvalidMiddleware;this.#middlewares.push(middleware)}getMiddleware(type){return this.#middlewares.find(middleware=>middleware instanceof type)}clearMiddlewares(){this.#middlewares=[]}handle(request){return this.#getNextHandler(request,0)()}async#loadMiddlewares(){(await Promise.all(this.#middlewareFiles.map(filename=>this.#loadMiddleware(filename)))).forEach(middleware=>this.addMiddleware(middleware))}async#loadMiddleware(filename){return(await this.#moduleImporter.import(filename)).default}#getNextHandler(request,index){const next=this.#middlewares[index];if(void 0===next)return async()=>new Response(StatusCodes_OK);const nextHandler=this.#getNextHandler(request,index+1);return async()=>await next.handle(request,nextHandler)}}class ScheduledTask{#logger;#task;#interval;#timeout=null;constructor(logger,task,interval=5e3){this.#logger=logger,this.#task=task,this.#interval=interval}start(){this.#scheduleNextExecution()}stop(){null!==this.#timeout&&(clearTimeout(this.#timeout),this.#timeout=null)}#scheduleNextExecution(){this.#timeout=setTimeout(async()=>{null!==this.#timeout&&(await this.#executeTask(),this.#scheduleNextExecution())},this.#interval),this.#timeout.unref()}async#executeTask(){try{await this.#task()}catch(error){this.#logger.warn("Scheduled task failed",error)}}}class ScheduleManager{#scheduledTasks=[];#logger;constructor(logger){this.#logger=logger}create(task,interval){const scheduledTask=new ScheduledTask(this.#logger,task,interval);return this.#scheduledTasks.push(scheduledTask),scheduledTask}remove(scheduledTask){const index=this.#scheduledTasks.indexOf(scheduledTask);index<0||this.#scheduledTasks.splice(index,1)}startAll(){this.#scheduledTasks.forEach(scheduledTask=>scheduledTask.start())}stopAll(){this.#scheduledTasks.forEach(scheduledTask=>scheduledTask.stop())}}class ClassNotFound extends Error{constructor(name){super(`The class '${name}' could not be found`)}}class InvalidClass extends Error{constructor(name){super(`The class '${name}' is invalid`)}}class NoDeserializerFound extends Error{constructor(type){super(`No deserializer found for value of type '${type}'`)}}class NoSerializerFound extends Error{constructor(type){super(`No serializer found for value of type '${type}'`)}}class Serializer{#serializers=[];addSerializer(serializer){serializer.parent=this,this.#serializers.unshift(serializer)}async serialize(value){const serializer=this.#serializers.find(serializer=>serializer.canSerialize(value));if(void 0===serializer)throw new NoSerializerFound(typeof value);return serializer.serialize(value)}async deserialize(value){const serializer=this.#serializers.find(serializer=>serializer.canDeserialize(value));if(void 0===serializer)throw new NoDeserializerFound(typeof value);return serializer.deserialize(value)}}class ParentSerializerNotSet extends Error{constructor(){super("Parent serializer not set")}}class ValueSerializer{#parent;set parent(parent){this.#parent=parent}serializeOther(value){if(void 0===this.#parent)throw new ParentSerializerNotSet;return this.#parent.serialize(value)}deserializeOther(value){if(void 0===this.#parent)throw new ParentSerializerNotSet;return this.#parent.deserialize(value)}}class ArraySerializer extends ValueSerializer{canSerialize(value){return value instanceof Array}canDeserialize(value){return value instanceof Array}async serialize(array){const values=[];for(const value of array)values.push(await this.serializeOther(value));return values}async deserialize(array){return Promise.all(array.map(async value=>this.deserializeOther(value)))}}class InvalidBigIntString extends Error{constructor(bigIntString){super(`Invalid BigInt string '${bigIntString}'`)}}class BigIntSerializer extends ValueSerializer{canSerialize(value){return"bigint"==typeof value}canDeserialize(value){const bigInt=value;return bigInt instanceof Object&&!0===bigInt.serialized&&"BigInt"===bigInt.name&&"string"==typeof bigInt.value}async serialize(bigInt){return{serialized:!0,name:"BigInt",value:bigInt.toString()}}async deserialize(object){try{return BigInt(object.value)}catch{throw new InvalidBigIntString(object.value)}}}class InvalidBufferString extends Error{constructor(bufferString){super(`Invalid Buffer string '${bufferString}'`)}}class BufferSerializer extends ValueSerializer{canSerialize(value){return value instanceof Buffer}canDeserialize(value){const buffer=value;return buffer instanceof Object&&!0===buffer.serialized&&"Buffer"===buffer.name&&"string"==typeof buffer.base64}async serialize(buffer){return{serialized:!0,name:"Buffer",base64:buffer.toString("base64")}}async deserialize(object){try{return Buffer.from(object.base64,"base64")}catch{throw new InvalidBufferString(object.base64)}}}class ESBinding{}class ESArrayBinding extends ESBinding{elements;constructor(elements){super(),this.elements=elements}clone(){const elements=this.elements.map(element=>element.clone());return new ESArrayBinding(elements)}toString(){return`[${this.elements.map(element=>element.toString()).join(",")}]`}}class ESStatement{}class ESDeclaration extends ESStatement{identifier;constructor(identifier){super(),this.identifier=identifier}is(identifier){return this.identifier===identifier}}class ESFunction extends ESDeclaration{parameters;body;isAsync;constructor(identifier,parameters,body,isAsync=!1){super(identifier),this.parameters=parameters,this.body=body,this.isAsync=isAsync}clone(){const parameters=this.parameters.map(parameter=>parameter.clone()),body=this.body.clone();return new ESFunction(this.identifier,parameters,body,this.isAsync)}toString(){const prefix=this.isAsync?"async ":"",identifier=this.identifier?` ${this.identifier}`:"",parameters=this.parameters.map(parameter=>parameter.toString()),body=this.body.toString();return`${prefix}function${identifier}(${parameters.join(",")})${body}`}}class ESArrowFunction extends ESFunction{constructor(parameters,body,isAsync=!1){super(void 0,parameters,body,isAsync)}clone(){const parameters=this.parameters.map(parameter=>parameter.clone()),body=this.body.clone();return new ESArrowFunction(parameters,body,this.isAsync)}toString(){const prefix=this.isAsync?"async ":"",parameters=this.parameters.map(parameter=>parameter.toString()),body=this.body.toString();return`${prefix}(${parameters.join(", ")})=>${body}`}}class ESBindingElement{binding;initializer;constructor(binding,initializer){this.binding=binding,this.initializer=initializer}clone(){const binding=this.binding.clone(),initializer=this.initializer?.clone();return new ESBindingElement(binding,initializer)}toString(){return`${this.binding.toString()}${void 0!==this.initializer?`=${this.initializer.toString(!1)}`:""}`}}class ESBlock extends ESStatement{code;constructor(code){super(),this.code=code}clone(){return new ESBlock(this.code)}toString(){return this.code}}class ESClassMember{identifier;visibility;location;constructor(identifier,visibility,location){this.identifier=identifier,this.visibility=visibility,this.location=location}is(identifier){return this.identifier===identifier}}class ESConstructor extends ESClassMember{parameters;body;constructor(parameters,body){super("constructor","public","instance"),this.parameters=parameters,this.body=body}clone(){const parameters=this.parameters.map(parameter=>parameter.clone()),body=this.body.clone();return new ESConstructor(parameters,body)}toString(){const parameters=this.parameters.map(parameter=>parameter.toString()),body=this.body.toString();return`${this.identifier}(${parameters.join(",")}) ${body}`}}class ESGetter extends ESClassMember{body;constructor(identifier,visibility,location,body){super(identifier,visibility,location),this.body=body}clone(){const body=this.body.clone();return new ESGetter(this.identifier,this.visibility,this.location,body)}toString(){const location="static"===this.location?"static ":"",visibility="private"===this.visibility?"#":"",body=this.body.toString();return`${location}get ${visibility}${this.identifier}()${body}`}}class ESSetter extends ESClassMember{parameter;body;constructor(identifier,visibility,location,parameter,body){super(identifier,visibility,location),this.parameter=parameter,this.body=body}clone(){const parameter=this.parameter.clone(),body=this.body.clone();return new ESSetter(this.identifier,this.visibility,this.location,parameter,body)}toString(){const location="static"===this.location?"static ":"",visibility="private"===this.visibility?"#":"",parameter=this.parameter.toString(),body=this.body.toString();return`${location}set ${visibility}${this.identifier}(${parameter})${body}`}}class ESMethod extends ESClassMember{parameters;body;isAsync;constructor(identifier,visibility,location,parameters,body,isAsync=!1){super(identifier,visibility,location),this.parameters=parameters,this.body=body,this.isAsync=isAsync}clone(){const parameters=this.parameters.map(parameter=>parameter.clone()),body=this.body.clone();return new ESMethod(this.identifier,this.visibility,this.location,parameters,body,this.isAsync)}toString(){const location="static"===this.location?"static ":"",visibility="private"===this.visibility?"#":"",prefix=this.isAsync?"async ":"",parameters=this.parameters.map(parameter=>parameter.toString()),body=this.body.toString();return`${location}${prefix}${visibility}${this.identifier}(${parameters.join(",")})${body}`}}class ESField extends ESClassMember{initializer;constructor(identifier,visibility,location,initializer){super(identifier,visibility,location),this.initializer=initializer}clone(){const initializer=this.initializer?.clone();return new ESField(this.identifier,this.visibility,this.location,initializer)}toString(){const location="static"===this.location?"static ":"",visibility="private"===this.visibility?"#":"",initializer=void 0!==this.initializer?`=${this.initializer.toString(!0)}`:";";return`${location}${visibility}${this.identifier}${initializer}`}}class ESClass extends ESDeclaration{parent;members;constructor(identifier,parent,members){super(identifier),this.parent=parent,this.members=members}get construct(){return this.members.find(member=>member instanceof ESConstructor)}get fields(){return this.members.filter(member=>member instanceof ESField)}get getters(){return this.members.filter(member=>member instanceof ESGetter)}get setters(){return this.members.filter(member=>member instanceof ESSetter)}get methods(){return this.members.filter(member=>member instanceof ESMethod)}get publicFields(){return this.fields.filter(member=>"public"===member.visibility)}get publicGetters(){return this.getters.filter(member=>"public"===member.visibility)}get publicSetters(){return this.setters.filter(member=>"public"===member.visibility)}get publicMethods(){return this.methods.filter(member=>"public"===member.visibility)}get readable(){return[...this.publicFields,...this.publicGetters]}get writable(){return[...this.publicFields,...this.publicSetters]}getMember(identifier){return this.members.find(member=>member.is(identifier))}hasMember(identifier){return this.members.some(member=>member.is(identifier))}getField(identifier){return this.fields.find(member=>member.is(identifier))}hasField(identifier){return this.fields.some(member=>member.is(identifier))}getGetter(identifier){return this.getters.find(member=>member.is(identifier))}hasGetter(identifier){return this.getters.some(member=>member.is(identifier))}getSetter(identifier){return this.setters.find(member=>member.is(identifier))}hasSetter(identifier){return this.setters.some(member=>member.is(identifier))}getMethod(identifier){return this.methods.find(member=>member.is(identifier))}hasMethod(identifier){return this.methods.some(member=>member.is(identifier))}canRead(identifier){return this.readable.some(member=>member.is(identifier))}canWrite(identifier){return this.writable.some(member=>member.is(identifier))}clone(){const members=this.members.map(member=>member.clone());return new ESClass(this.identifier,this.parent,members)}toString(){return`class ${this.identifier??""}${void 0!==this.parent?` extends ${this.parent}`:""}{${this.members.map(member=>member.toString()).join("")}}`}}class ESExport extends ESStatement{members;from;constructor(members,from){super(),this.members=members,this.from=from}hasMember(identifier){return this.members.some(member=>member.is(identifier))}getMember(identifier){return this.members.find(member=>member.is(identifier))}clone(){const members=this.members.map(member=>member.clone());return new ESExport(members,this.from)}toString(){const members=this.members.map(member=>member.toString()),postfix=this.from?` from '${this.from}'`:"";return`export {${members.join(",")}}${postfix};`}}class ESExpression extends ESStatement{code;constructor(code){super(),this.code=code}clone(){return new ESExpression(this.code)}toString(terminate=!0){const terminator=!1===terminate||this.code.endsWith("}")?"":";";return`${this.code}${terminator}`}}class ESGeneratorFunction extends ESFunction{clone(){const parameters=this.parameters.map(parameter=>parameter.clone()),body=this.body.clone();return new ESGeneratorFunction(this.identifier,parameters,body,this.isAsync)}toString(){const prefix=this.isAsync?"async ":"",identifier=this.identifier??"",parameters=this.parameters.map(parameter=>parameter.toString()),body=this.body.toString();return`${prefix}function* ${identifier}(${parameters.join(",")})${body}`}}class ESGeneratorMethod extends ESMethod{clone(){const parameters=this.parameters.map(parameter=>parameter.clone()),body=this.body.clone();return new ESGeneratorMethod(this.identifier,this.visibility,this.location,parameters,body,this.isAsync)}toString(){const prefix=this.isAsync?"async ":"",identifier=this.identifier,parameters=this.parameters.map(parameter=>parameter.toString()),body=this.body.toString();return`${prefix}*${identifier}(${parameters.join(",")})${body}`}}class ESIdentifierBinding extends ESBinding{identifier;isRest;constructor(identifier,isRest=!1){super(),this.identifier=identifier,this.isRest=isRest}clone(){return new ESIdentifierBinding(this.identifier,this.isRest)}toString(){return`${this.isRest?"...":""}${this.identifier}`}}class ESImport extends ESStatement{members;from;constructor(members,from){super(),this.members=members,this.from=from}hasMember(identifier){return this.members.some(member=>member.is(identifier))}getMember(identifier){return this.members.find(member=>member.is(identifier))}clone(){const members=this.members.map(member=>member.clone());return new ESImport(members,this.from)}toString(){if(0===this.members.length)return`import '${this.from}';`;return`import {${this.members.map(member=>member.toString()).join(",")}} from '${this.from}';`}}class ESVariable extends ESDeclaration{type;binding;initializer;constructor(type,binding,initializer){super(binding.toString()),this.type=type,this.binding=binding,this.initializer=initializer}clone(){const binding=this.binding.clone(),initializer=this.initializer?.clone();return new ESVariable(this.type,binding,initializer)}toString(){const initializer=void 0!==this.initializer?`=${this.initializer.toString(!0)}`:"",terminator=initializer.endsWith(";")?"":";";return`${this.type} ${this.identifier}${initializer}${terminator}`}}class ESModule{statements;constructor(statements){this.statements=statements}get exports(){return this.statements.filter(statement=>statement instanceof ESExport)}get imports(){return this.statements.filter(statement=>statement instanceof ESImport)}get expressions(){return this.statements.filter(statement=>statement instanceof ESExpression)}get declarations(){return this.statements.filter(statement=>statement instanceof ESDeclaration)}get variables(){return this.statements.filter(statement=>statement instanceof ESVariable)}get functions(){return this.statements.filter(statement=>statement instanceof ESFunction)}get classes(){return this.statements.filter(statement=>statement instanceof ESClass)}get exported(){const declarations=[];for(const entry of this.exports)for(const member of entry.members){const declaration=this.getDeclaration(member.identifier);void 0!==declaration&&declarations.push(declaration)}return declarations}get exportedVariables(){return this.exported.filter(declaration=>declaration instanceof ESVariable)}get exportedFunctions(){return this.exported.filter(declaration=>declaration instanceof ESFunction)}get exportedClasses(){return this.exported.filter(declaration=>declaration instanceof ESClass)}getExport(name){return this.exports.find(entry=>entry.hasMember(name))}getImport(name){return this.imports.find(entry=>entry.hasMember(name))}hasDeclaration(identifier){return this.declarations.some(entry=>entry.is(identifier))}getDeclaration(identifier){return this.declarations.find(entry=>entry.is(identifier))}hasVariable(identifier){return this.variables.some(entry=>entry.is(identifier))}getVariable(identifier){return this.variables.find(entry=>entry.is(identifier))}hasFunction(identifier){return this.functions.some(entry=>entry.is(identifier))}getFunction(identifier){return this.functions.find(entry=>entry.is(identifier))}hasClass(identifier){return this.classes.some(entry=>entry.is(identifier))}getClass(identifier){return this.classes.find(entry=>entry.is(identifier))}clone(){const statements=this.statements.map(statement=>statement.clone());return new ESModule(statements)}toString(){return this.statements.map(statement=>statement.toString(!0)).join("\n")}}class ESModuleMember{identifier;alias;constructor(identifier,alias){this.identifier=identifier,this.alias=alias}is(identifier){return this.alias===identifier||void 0===this.alias&&this.identifier===identifier}clone(){return new ESModuleMember(this.identifier,this.alias)}toString(){return void 0===this.alias?this.identifier:`${this.identifier} as ${this.alias}`}}class ESObjectBinding extends ESBinding{elements;constructor(elements){super(),this.elements=elements}clone(){const elements=this.elements.map(element=>element.clone());return new ESObjectBinding(elements)}toString(){return`{${this.elements.map(element=>element.toString()).join(",")}}`}}const Comment={SINGLE:"//",MULTI_START:"/*",MULTI_END:"*/"},Comments=Object.values(Comment);const Punctuation_DOT=".",Punctuation_LEFT_PARENTHESIS="(",Punctuation_RIGHT_PARENTHESIS=")",Punctuation_LEFT_BRACKET="[",Punctuation_RIGHT_BRACKET="]",Punctuation_LEFT_BRACE="{",Punctuation_RIGHT_BRACE="}",Punctuation_UNDERSCORE="_",Divider={SCOPE:":",SEPARATOR:",",TERMINATOR:";"},Divisions=Object.values(Divider);function isDivider(value){return Divisions.includes(value)}const Empty={UNDEFINED:void 0,NULL:null,STRING:""},NOTHING=["null","undefined"],Empties=Object.values(Empty);function isEmpty(value){return Empties.includes(value)}const Group={OPEN:Punctuation_LEFT_PARENTHESIS,CLOSE:Punctuation_RIGHT_PARENTHESIS};function isGroup(value){return value===Group.OPEN||value===Group.CLOSE}const Keyword={IMPORT:"import",EXPORT:"export",AS:"as",FROM:"from",DEFAULT:"default",ASYNC:"async",AWAIT:"await",USING:"using",CONST:"const",LET:"let",VAR:"var",FUNCTION:"function",RETURN:"return",YIELD:"yield",CLASS:"class",CONSTRUCTOR:"constructor",GET:"get",SET:"set",EXTENDS:"extends",STATIC:"static",NEW:"new",THIS:"this",DO:"do",WHILE:"while",FOR:"for",OF:"of",IN:"in",BREAK:"break",CONTINUE:"continue",IF:"if",ELSE:"else",SWITCH:"switch",CASE:"case",THROW:"throw",TRY:"try",CATCH:"catch",FINALLY:"finally",TYPEOF:"typeof",INSTANCEOF:"instanceof"},Keywords=Object.values(Keyword),RootKeywords=[Keyword.IMPORT,Keyword.EXPORT,Keyword.VAR,Keyword.LET,Keyword.CONST,Keyword.FUNCTION,Keyword.CLASS,Keyword.ASYNC],DeclarationKeywords=[Keyword.VAR,Keyword.LET,Keyword.CONST,Keyword.FUNCTION,Keyword.CLASS,Keyword.USING],ContextualKeywords=[Keyword.AS,Keyword.ASYNC,Keyword.GET,Keyword.SET,Keyword.OF,Keyword.YIELD,Keyword.FROM,Keyword.STATIC];function isRootKeyword(value){return RootKeywords.includes(value)}function isContextualKeyword(value){return ContextualKeywords.includes(value)}const List={OPEN:Punctuation_LEFT_BRACKET,CLOSE:Punctuation_RIGHT_BRACKET};function isList(value){return value===List.OPEN||value===List.CLOSE}const Literals=Object.values({SINGLE:"'",DOUBLE:'"',BACKTICK:"`"});function isLiteral(value){return Literals.includes(value)}const Operator={ADD:"+",ARROW:"=>",ASSIGN:"=",ASSIGN_ADD:"+=",ASSIGN_BITWISE_AND:"&=",ASSIGN_BITWISE_OR:"|=",ASSIGN_BITWISE_XOR:"^=",ASSIGN_DIVIDE:"/=",ASSIGN_EXPONENTIAL:"**=",ASSIGN_LEFT_SHIFT:"<<=",ASSIGN_LOGICAL_AND:"&&=",ASSIGN_LOGICAL_OR:"||=",ASSIGN_REMAINDER:"%=",ASSIGN_MULTIPLY:"*=",ASSIGN_NULLISH:"??=",ASSIGN_RIGHT_SHIFT:">>=",ASSIGN_SUBTRACT:"-=",BITWISE_AND:"&",BITWISE_OR:"|",BITWISE_NOT:"~",BITWISE_XOR:"^",DECREMENT:"--",DIVIDE:"/",EQUAL:"==",EQUAL_STRICT:"===",EXPONENTIAL:"**",GREATER:">",GREATER_EQUAL:">=",INCREMENT:"++",LEFT_SHIFT:"<<",LESS:"<",LESS_EQUAL:"<=",LOGICAL_AND:"&&",LOGICAL_OR:"||",REMAINDER:"%",MULTIPLY:"*",NULLISH:"??",CHAINING:".",OPTIONAL_CHAINING:"?.",SPREAD:"...",NOT:"!",NOT_EQUAL:"!=",NOT_EQUAL_STRICT:"!==",RIGHT_SHIFT:">>",SUBTRACT:"-",TERNARY:"?",$BRIDGE_CHAINING_SPREAD:".."},Operators=Object.values(Operator);function isOperator(value){return Operators.includes(value)}const Scope={OPEN:Punctuation_LEFT_BRACE,CLOSE:Punctuation_RIGHT_BRACE};function isScope(value){return value===Scope.OPEN||value===Scope.CLOSE}const TokenType={BOOLEAN:"boolean",COMMENT:"comment",DIVIDER:"divider",GROUP:"group",IDENTIFIER:"identifier",KEYWORD:"keyword",LIST:"list",LITERAL:"literal",NOTHING:"nothing",NUMBER:"number",OPERATOR:"operator",INDICATOR:"indicator",REGEX:"regex",SCOPE:"scope",WHITESPACE:"whitespace",NONE:"none"},Whitespace={SPACE:" ",TAB:"\t",NEWLINE:"\n",CARRIAGE_RETURN:"\r"},Whitespaces=Object.values(Whitespace);function isWhitespace(value){return Whitespaces.includes(value)}class ItemList{#items;#position;constructor(items){this.#items=items,this.#position=0}get items(){return this.#items}get position(){return this.#position}get size(){return this.#items.length}get eol(){return this.#position>=this.#items.length}get current(){return this.#items[this.#position]}get next(){return this.#items[this.#position+1]}get previous(){return this.#items[this.#position-1]}notAtEnd(){return!1===this.eol}get(index){return this.#items[index]}step(amount=1){return this.#position+=amount,this.current}stepBack(amount=1){return this.#position-=amount,this.current}hasNext(){return this.#position+1<this.#items.length}insert(...item){this.#items.splice(this.#position,0,...item)}}class CharList extends ItemList{constructor(code){super(code.split(""))}}class Token{#type;#value;#start;#end;constructor(type,value,start,end){this.#type=type,this.#value=value,this.#start=start,this.#end=end}get type(){return this.#type}get value(){return this.#value}get start(){return this.#start}get end(){return this.#end}isType(type){return this.#type===type}hasValue(value){return this.#value===value}toString(){return`${this.#value}`}}class TokenList extends ItemList{}const BOOLEAN=["true","false"];const NUMBERS=["0","1","2","3","4","5","6","7","8","9"],HEXADECIMAL=[...NUMBERS,"a","b","c","d","e","f","A","B","C","D","E","F"],BINARY=["0","1"];function isNumber(value){return NUMBERS.includes(value)}const Indicator={GENERATOR:"*",PRIVATE:"#"},Indicators=Object.values(Indicator);class Lexer{tokenize(code){const charList=new CharList(code),tokens=[];let last;for(;charList.notAtEnd();){const token=this.#getNextToken(charList,last);if(void 0===token)break;token.isType(TokenType.WHITESPACE)||token.isType(TokenType.COMMENT)?charList.step():(tokens.push(token),this.#isCodeToken(token)&&(last=token),charList.step())}return new TokenList(tokens)}#isCodeToken(token){return!1===[TokenType.WHITESPACE,TokenType.COMMENT].includes(token.type)}#getNextToken(charList,lastToken){const char=charList.current,start=charList.position;if(isWhitespace(char)){const end=charList.position;return new Token(TokenType.WHITESPACE,char,start,end)}if(function(value){return Comments.includes(value)}(char+charList.next)){const value=this.#readComment(charList),end=charList.position;return new Token(TokenType.COMMENT,value,start,end)}if(this.#startsRegex(char,lastToken)){const value=this.#readRegex(charList),end=charList.position;return new Token(TokenType.REGEX,value,start,end)}if(this.#startsNumber(charList,lastToken)){const value=this.#readNumber(charList),end=charList.position;return new Token(TokenType.NUMBER,value,start,end)}if(isLiteral(char)){const value=this.#readLiteral(charList),end=charList.position;return new Token(TokenType.LITERAL,value,start,end)}if(isOperator(char)){const value=this.#readOperation(charList),end=charList.position;return new Token(TokenType.OPERATOR,value,start,end)}if(function(value){return Indicators.includes(value)}(char)){const value=this.#readOperation(charList),end=charList.position;return new Token(TokenType.INDICATOR,value,start,end)}if(isDivider(char)){const end=charList.position;return new Token(TokenType.DIVIDER,char,start,end)}if(isGroup(char)){const end=charList.position;return new Token(TokenType.GROUP,char,start,end)}if(isScope(char)){const end=charList.position;return new Token(TokenType.SCOPE,char,start,end)}if(isList(char)){const end=charList.position;return new Token(TokenType.LIST,char,start,end)}if(isEmpty(char))return;const value=this.#readIdentifier(charList),end=charList.position;return function(value){return Keywords.includes(value)}(value)?new Token(TokenType.KEYWORD,value,start,end):function(value){return BOOLEAN.includes(value)}(value)?new Token(TokenType.BOOLEAN,value,start,end):function(value){return NOTHING.includes(value)}(value)?new Token(TokenType.NOTHING,value,start,end):new Token(TokenType.IDENTIFIER,value,start,end)}#readComment(charList){const isMulti=charList.current+charList.next===Comment.MULTI_START,terminator=isMulti?Comment.MULTI_END:Whitespace.NEWLINE;let value=isMulti?Comment.MULTI_START:Comment.SINGLE;for(charList.step(2);charList.notAtEnd();){const char=charList.current;if((isMulti?char+charList.next:char)===terminator){charList.step(terminator.length-1);break}value+=char,charList.step()}return isMulti?value+Comment.MULTI_END:value.trim()}#startsRegex(char,lastToken){return char===Operator.DIVIDE&&(void 0===lastToken||([TokenType.OPERATOR,TokenType.DIVIDER,TokenType.KEYWORD].includes(lastToken.type)||[Group.OPEN,List.OPEN].includes(lastToken.value)))}#endsRegex(char){return isWhitespace(char)||char==Punctuation_DOT||!1===this.#isIdentifier(char)}#readRegex(charList){let value=charList.current,closed=!1;for(charList.step();charList.notAtEnd();){const current=charList.current,previous=charList.previous;if(current===Operator.DIVIDE&&"\\"!==previous)closed=!0;else if(!0===closed&&this.#endsRegex(current)){charList.stepBack();break}value+=current,charList.step()}return value}#startsNumber(charList,lastToken){const current=charList.current,next=charList.next;return!!isNumber(current)||current===Operator.SUBTRACT&&(!lastToken?.isType(TokenType.NUMBER)&&isNumber(next))}#endsNumber(char,hexadecimal,binary){return hexadecimal?!1===(value=char,HEXADECIMAL.includes(value))&&char!==Punctuation_UNDERSCORE:binary?!1===function(value){return BINARY.includes(value)}(char)&&char!==Punctuation_UNDERSCORE:!1===isNumber(char)&&char!==Punctuation_DOT&&char!==Punctuation_UNDERSCORE&&"e"!==char;var value}#readNumber(charList){let value=charList.current;value===Operator.SUBTRACT&&(value+=charList.step()),charList.step();const hexadecimal="x"===charList.current,binary="b"===charList.current;for((hexadecimal||binary)&&(value+=charList.current,charList.step());charList.notAtEnd();){const char=charList.current;if(this.#endsNumber(char,hexadecimal,binary)){charList.stepBack();break}value+=char,charList.step()}return value}#readLiteral(charList){const identifier=charList.current;let value=identifier,escaped=!1;for(charList.step();charList.notAtEnd();){const char=charList.current;if(!1===escaped){if(char===identifier){value+=char;break}"\\"===char&&(escaped=!0)}else escaped=!1;value+=char,charList.step()}return value}#isIdentifier(char){return!1===(isEmpty(char)||isWhitespace(char)||isOperator(char)||isLiteral(char)||isDivider(char)||isGroup(char)||isScope(char)||isList(char))}#readIdentifier(charList){let value="";for(;charList.notAtEnd();){const char=charList.current;if(!1===this.#isIdentifier(char)){charList.stepBack();break}value+=char,charList.step()}return value}#readOperation(charList){let value=charList.current;for(charList.step();charList.notAtEnd();){const char=charList.current;if(!1===isOperator(char)||!1===isOperator(value+char)){charList.stepBack();break}value+=char,charList.step()}return value}}class ExpectedKeyword extends Error{constructor(value,position){super(`Expected keyword '${value}' at position ${position}`)}}class ExpectedToken extends Error{constructor(value,position){super(`Expected token '${value}' at position ${position}`)}}class UnexpectedKeyword extends Error{constructor(keyword,position){super(`Unexpected keyword '${keyword}' at position ${position}`)}}class UnexpectedParseResult extends Error{constructor(expected){super(`The given code does not contain ${expected}`)}}class UnexpectedToken extends Error{constructor(value,position){super(`Unexpected token '${value}' at position ${position}`)}}const NO_TOKEN=new Token(TokenType.NONE,"",-1,0);class Coder{#tokens;constructor(tokens=[]){this.#tokens=tokens}get tokens(){return this.#tokens}append(...tokens){this.#tokens.push(...tokens)}merge(coder){this.append(...coder.tokens)}generate(){let code="";for(let index=0;index<this.#tokens.length;index++){const previous=this.#tokens[index-1]??NO_TOKEN,current=this.#tokens[index],next=this.#tokens[index+1]??NO_TOKEN,prefix=this.#needsSpacingBefore(previous,current)?" ":"",postfix=this.#needsSpacingAfter(current,next)?" ":"";code+=`${prefix}${current.value}${postfix}`}return code}#needsSpacingBefore(previous,current){return!(!current.isType(TokenType.KEYWORD)||!this.#isTextType(previous))||!(!current.isType(TokenType.OPERATOR)||!previous.isType(TokenType.OPERATOR))}#needsSpacingAfter(current,next){return current.isType(TokenType.KEYWORD)&&(next.isType(TokenType.KEYWORD)||this.#isTextType(next))}#isTextType(token){return token.isType(TokenType.IDENTIFIER)||token.isType(TokenType.BOOLEAN)||token.isType(TokenType.NOTHING)||token.isType(TokenType.NUMBER)}}class Parser{#lexer;constructor(lexer=new Lexer){this.#lexer=lexer}parse(code){const tokenList=this.#lexer.tokenize(code),statements=this.#parseAll(tokenList);return new ESModule(statements)}parseStatement(code){const tokenList=this.#lexer.tokenize(code),statement=this.#parseNext(tokenList);if(void 0===statement)throw new UnexpectedParseResult("a statement");return statement}parseImport(code){const tokenList=this.#lexer.tokenize(code),declaration=this.#parseKeyword(tokenList);if(declaration instanceof ESImport==!1)throw new UnexpectedParseResult("an import definition");return declaration}parseExport(code){const tokenList=this.#lexer.tokenize(code),declaration=this.#parseKeyword(tokenList);if(declaration instanceof ESExport==!1)throw new UnexpectedParseResult("an export definition");return declaration}parseVariable(code){const tokenList=this.#lexer.tokenize(code),declaration=this.#parseKeyword(tokenList);if(declaration instanceof ESVariable==!1)throw new UnexpectedParseResult("a variable definition");return declaration}parseFunction(code){const tokenList=this.#lexer.tokenize(code),declaration=this.#parseKeyword(tokenList);if(declaration instanceof ESFunction==!1)throw new UnexpectedParseResult("a function definition");return declaration}parseClass(code){const tokenList=this.#lexer.tokenize(code),declaration=this.#parseKeyword(tokenList);if(declaration instanceof ESClass==!1)throw new UnexpectedParseResult("a class definition");return declaration}#parseAll(tokenList){const statements=[];for(;tokenList.notAtEnd();){const statement=this.#parseNext(tokenList);void 0!==statement&&statements.push(statement)}return statements}#parseNext(tokenList,isAsync=!1){const token=tokenList.current;if(this.#isValue(token))return this.#parseExpression(tokenList);if(token.isType(TokenType.IDENTIFIER)){const next=tokenList.next;return next?.hasValue(Operator.ARROW)?this.#parseArrowFunction(tokenList,isAsync):this.#parseExpression(tokenList)}if(token.isType(TokenType.KEYWORD)){if(isContextualKeyword(token.value)){const next=tokenList.next,nextIsFunction=void 0!==next&&(next.hasValue(Keyword.FUNCTION)||next.hasValue(Group.OPEN));if(token.hasValue(Keyword.ASYNC)&&nextIsFunction)return tokenList.step(),this.#parseNext(tokenList,!0);if(void 0===next||this.#atEndOfExpression(next))return this.#parseExpression(tokenList)}return token.hasValue(Keyword.RETURN)?this.#parseExpression(tokenList):!1===isRootKeyword(token.value)?this.#parseExpression(tokenList):this.#parseKeyword(tokenList,isAsync)}if(token.isType(TokenType.REGEX))return this.#parseExpression(tokenList);if(token.hasValue(Group.OPEN)){const next=this.#peekAfterCollection(tokenList,Group.OPEN,Group.CLOSE);return next?.hasValue(Operator.ARROW)?this.#parseArrowFunction(tokenList,isAsync):this.#parseExpression(tokenList)}if(token.hasValue(Scope.OPEN))return this.#parseExpression(tokenList);if(token.hasValue(List.OPEN))return this.#parseExpression(tokenList);if(token.hasValue(Operator.NOT)||token.hasValue(Operator.SUBTRACT))return this.#parseExpression(tokenList);if(!isDivider(token.value))throw new UnexpectedToken(token.value,token.start);tokenList.step()}#isValue(token){return token.isType(TokenType.LITERAL)||token.isType(TokenType.NUMBER)||token.isType(TokenType.BOOLEAN)||token.isType(TokenType.NOTHING)||token.hasValue(Keyword.NEW)}#parseKeyword(tokenList,isAsync=!1){const token=tokenList.current;switch(tokenList.step(),token.value){case Keyword.IMPORT:return this.#parseImport(tokenList);case Keyword.EXPORT:return this.#parseExport(tokenList);case Keyword.CLASS:return this.#parseClass(tokenList);case Keyword.FUNCTION:return this.#parseFunction(tokenList,isAsync);case Keyword.VAR:return this.#parseVariable(tokenList,"var");case Keyword.LET:return this.#parseVariable(tokenList,"let");case Keyword.CONST:return this.#parseVariable(tokenList,"const");case Keyword.ASYNC:return this.#parseNext(tokenList,!0);default:throw new UnexpectedKeyword(token.value,token.start)}}#parseImport(tokenList){const members=[];let token=tokenList.current;if(token.isType(TokenType.LITERAL)){const from=this.#parseFrom(token.value);return new ESImport(members,from)}if(token.hasValue(Group.OPEN)){token=tokenList.step();const from=this.#parseFrom(token.value);return tokenList.step(2),new ESImport(members,from)}if(!1===token.hasValue(Scope.OPEN)){const identifier=token.hasValue(Operator.MULTIPLY)?Operator.MULTIPLY:"default";let alias=token.value;token=tokenList.step(),token.hasValue(Keyword.AS)&&(token=tokenList.step(),alias=token.value,token=tokenList.step()),members.push(new ESModuleMember(identifier,alias))}if(token.hasValue(Divider.SEPARATOR)&&(token=tokenList.step()),token.hasValue(Scope.OPEN)){const parsedMembers=this.#parseModuleMembers(tokenList);members.push(...parsedMembers),token=tokenList.current}if(!1===token.hasValue(Keyword.FROM))throw new ExpectedKeyword(Keyword.FROM,token.start);token=tokenList.step();const from=this.#parseFrom(token.value);return tokenList.step(),new ESImport(members,from)}#parseExport(tokenList){switch(tokenList.current.value){case Keyword.DEFAULT:return tokenList.step(),this.#parseSingleExport(tokenList,!0);case Scope.OPEN:return this.#parseMultiExport(tokenList);default:return this.#parseSingleExport(tokenList,!1)}}#parseSingleExport(tokenList,isDefault){let token=tokenList.current,stepSize=0;if(isDefault&&this.#doesExportValue(tokenList)){const identifier=`$_EXPORT_${token.start}_${token.end}`;tokenList.insert(new Token(TokenType.KEYWORD,Keyword.CONST,0,0),new Token(TokenType.IDENTIFIER,identifier,0,0),new Token(TokenType.OPERATOR,Operator.ASSIGN,0,0)),token=tokenList.current}var value;if(token.hasValue(Keyword.ASYNC)&&(token=tokenList.step(),stepSize++),value=token.value,DeclarationKeywords.includes(value)&&(token=tokenList.step(),stepSize++,token.hasValue(Indicator.GENERATOR)&&(token=tokenList.step(),stepSize++)),token.hasValue(Keyword.EXTENDS)||token.hasValue(Group.OPEN)||token.hasValue(Scope.OPEN)){const identifier=`$_EXPORT_${token.start}_${token.end}`;tokenList.insert(new Token(TokenType.IDENTIFIER,identifier,0,0)),token=tokenList.current}const identifier=this.#isIdentifier(token)?token.value:"",alias=isDefault?"default":void 0;let from;token=tokenList.step(),token?.hasValue(Keyword.FROM)&&(token=tokenList.step(),from=this.#parseFrom(token.value)),stepSize>0&&(stepSize++,tokenList.stepBack(stepSize));const member=new ESModuleMember(identifier,alias);return new ESExport([member],from)}#doesExportValue(tokenList){const current=tokenList.current;if(this.#isValue(current))return!0;const next=tokenList.next;return this.#isIdentifier(current)&&next?.hasValue(Group.OPEN)}#parseMultiExport(tokenList){const members=this.#parseModuleMembers(tokenList);let from,token=tokenList.current;return token?.hasValue(Keyword.FROM)&&(token=tokenList.step(),from=this.#parseFrom(token.value)),tokenList.step(),new ESExport(members,from)}#parseFrom(from){return from.slice(1,-1)}#parseModuleMembers(tokenList){const members=[];let token=tokenList.step();for(;tokenList.notAtEnd();){if(token.hasValue(Scope.CLOSE)){tokenList.step();break}if(token.hasValue(Divider.SEPARATOR)){token=tokenList.step();continue}const member=this.#parseModuleMember(tokenList);members.push(member),token=tokenList.step()}return members}#parseModuleMember(tokenList){let token=tokenList.current;const identifier=token.value;let alias;return tokenList.next.hasValue(Keyword.AS)&&(token=tokenList.step(2),alias=token.value),new ESModuleMember(identifier,alias)}#parseVariable(tokenList,type){const binding=this.#parseBinding(tokenList),initializer=this.#parseInitializer(tokenList);return tokenList.notAtEnd()&&tokenList.current.hasValue(Divider.SEPARATOR)&&(tokenList.step(),tokenList.insert(new Token(TokenType.KEYWORD,type,0,0))),new ESVariable(type,binding,initializer)}#parseBinding(tokenList){const token=tokenList.current;return token.hasValue(List.OPEN)?this.#parseArrayBinding(tokenList):token.hasValue(Scope.OPEN)?this.#parseObjectBinding(tokenList):this.#parseIdentifierBinding(tokenList)}#parseArrayBinding(tokenList){const elements=this.#parseBindingElements(tokenList,List.CLOSE);return new ESArrayBinding(elements)}#parseObjectBinding(tokenList){const elements=this.#parseBindingElements(tokenList,Scope.CLOSE);return new ESObjectBinding(elements)}#parseBindingElements(tokenList,closeId){const elements=[];for(tokenList.step();tokenList.notAtEnd();){const token=tokenList.current;if(token.hasValue(closeId)){tokenList.step();break}if(token.hasValue(Divider.SEPARATOR)){tokenList.step();continue}const binding=this.#parseBinding(tokenList),initializer=this.#parseInitializer(tokenList),element=new ESBindingElement(binding,initializer);elements.push(element)}return elements}#parseIdentifierBinding(tokenList){let token=tokenList.current,isRest=!1;token.hasValue(Operator.SPREAD)&&(isRest=!0,token=tokenList.step());const identifier=token.value;return tokenList.step(),new ESIdentifierBinding(identifier,isRest)}#parseInitializer(tokenList){const token=tokenList.current;if(!1!==token.hasValue(Operator.ASSIGN))return tokenList.step(),this.#parseNext(tokenList,!1);token.hasValue(Divider.TERMINATOR)&&tokenList.step()}#parseFunction(tokenList,isAsync){let identifier,token=tokenList.current,isGenerator=!1;token.hasValue(Indicator.GENERATOR)&&(isGenerator=!0,token=tokenList.step()),this.#isIdentifier(token)&&(identifier=token.value,tokenList.step());const parameters=this.#parseBindingElements(tokenList,Group.CLOSE);if(token=tokenList.current,!1===token.hasValue(Scope.OPEN))throw new ExpectedToken(Scope.OPEN,token.start);const body=this.#parseBlock(tokenList);return isGenerator?new ESGeneratorFunction(identifier,parameters,body,isAsync):new ESFunction(identifier,parameters,body,isAsync)}#parseArrowFunction(tokenList,isAsync){let parameters,body,token=tokenList.current;if(token.hasValue(Group.OPEN))parameters=this.#parseBindingElements(tokenList,Group.CLOSE);else{const binding=this.#parseIdentifierBinding(tokenList);parameters=[new ESBindingElement(binding,void 0)]}if(token=tokenList.current,!1===token.hasValue(Operator.ARROW))throw new ExpectedToken(Operator.ARROW,token.start);if(token=tokenList.step(),token.hasValue(Scope.OPEN))body=this.#parseBlock(tokenList);else{const expression=this.#parseExpression(tokenList);body=new ESBlock(expression.code)}return new ESArrowFunction(parameters,body,isAsync)}#parseClass(tokenList){let identifier,parent,token=tokenList.current;if(this.#isIdentifier(token)&&(identifier=token.value,token=tokenList.step()),token.hasValue(Keyword.EXTENDS)&&(token=tokenList.step(),parent=token.value,token=tokenList.step()),!1===token.hasValue(Scope.OPEN))throw new ExpectedToken(Scope.OPEN,token.start);const members=this.#parseClassMembers(tokenList);return new ESClass(identifier,parent,members)}#parseClassMembers(tokenList){let token=tokenList.step();const members=[];for(;tokenList.notAtEnd();){if(token.hasValue(Scope.CLOSE)){tokenList.step();break}const member=this.#parseClassMember(tokenList);members.push(member),token=tokenList.current}return members}#parseClassMember(tokenList){let token=tokenList.current,visibility="public",location="instance",isAsync=!1;for(;tokenList.notAtEnd();){if(token.hasValue(Indicator.PRIVATE))visibility="private";else if(token.hasValue(Keyword.STATIC))location="static";else{if(!token.hasValue(Keyword.ASYNC)){if(token.hasValue(Keyword.CONSTRUCTOR))return this.#parseConstructor(tokenList);if(token.hasValue(Keyword.GET))return this.#parseGetter(tokenList,location);if(token.hasValue(Keyword.SET))return this.#parseSetter(tokenList,location);if(token.hasValue(Indicator.GENERATOR))return tokenList.step(),this.#parseMethod(tokenList,visibility,location,isAsync,!0);break}isAsync=!0}token=tokenList.step()}return tokenList.next.hasValue(Group.OPEN)?this.#parseMethod(tokenList,visibility,location,isAsync,!1):this.#parseField(tokenList,visibility,location)}#parseConstructor(tokenList){tokenList.step();const parameters=this.#parseBindingElements(tokenList,Group.CLOSE),token=tokenList.current;if(!1===token.hasValue(Scope.OPEN))throw new ExpectedToken(Scope.OPEN,token.start);const body=this.#parseBlock(tokenList);return new ESConstructor(parameters,body)}#parseGetter(tokenList,location){let visibility="public",token=tokenList.step();token.hasValue(Indicator.PRIVATE)&&(visibility="private",token=tokenList.step());const identifier=token.value;tokenList.step();if(0!==this.#parseBindingElements(tokenList,Group.CLOSE).length)throw new UnexpectedParseResult("an empty parameter list");if(token=tokenList.current,!1===token.hasValue(Scope.OPEN))throw new ExpectedToken(Scope.OPEN,token.start);const body=this.#parseBlock(tokenList);return new ESGetter(identifier,visibility,location,body)}#parseSetter(tokenList,location){let visibility="public",token=tokenList.step();token.hasValue(Indicator.PRIVATE)&&(visibility="private",token=tokenList.step());const identifier=token.value;tokenList.step();const parameters=this.#parseBindingElements(tokenList,Group.CLOSE);if(token=tokenList.current,1!==parameters.length)throw new UnexpectedParseResult("exactly one setter parameter");if(!1===token.hasValue(Scope.OPEN))throw new ExpectedToken(Scope.OPEN,token.start);const body=this.#parseBlock(tokenList);return new ESSetter(identifier,visibility,location,parameters[0],body)}#parseMethod(tokenList,visibility,location,isAsync,isGenerator){let token=tokenList.current;const identifier=token.value;tokenList.step();const parameters=this.#parseBindingElements(tokenList,Group.CLOSE);if(token=tokenList.current,!1===token.hasValue(Scope.OPEN))throw new ExpectedToken(Scope.OPEN,token.start);const body=this.#parseBlock(tokenList);return isGenerator?new ESGeneratorMethod(identifier,visibility,location,parameters,body,isAsync):new ESMethod(identifier,visibility,location,parameters,body,isAsync)}#parseField(tokenList,visibility,location){const identifier=tokenList.current.value;tokenList.step();const initializer=this.#parseInitializer(tokenList);return new ESField(identifier,visibility,location,initializer)}#parseBlock(tokenList){const code=this.#parseCollectionToCode(tokenList,Scope.OPEN,Scope.CLOSE).generate();return new ESBlock(code)}#parseExpression(tokenList){const coder=new Coder;let token=tokenList.current;for(;tokenList.notAtEnd();){if(token.hasValue(List.OPEN)){const array=this.#parseCollectionToCode(tokenList,List.OPEN,List.CLOSE);coder.merge(array),token=tokenList.current}else if(token.hasValue(Group.OPEN)){const group=this.#parseCollectionToCode(tokenList,Group.OPEN,Group.CLOSE);coder.merge(group),token=tokenList.current}else if(token.hasValue(Scope.OPEN)){const scope=this.#parseCollectionToCode(tokenList,Scope.OPEN,Scope.CLOSE);coder.merge(scope),token=tokenList.current}else coder.append(token),token=tokenList.step();if(void 0===token)break;if(this.#atEndOfExpression(token)){token.hasValue(Divider.TERMINATOR)&&tokenList.step();break}}const code=coder.generate();return new ESExpression(code)}#parseCollectionToCode(tokenList,openId,closeId){let token=tokenList.current;const coder=new Coder([token]);for(token=tokenList.step();tokenList.notAtEnd();){if(token.hasValue(openId)){const collection=this.#parseCollectionToCode(tokenList,openId,closeId);coder.merge(collection),token=tokenList.current;continue}if(token.hasValue(closeId))return tokenList.step(),coder.append(token),coder;coder.append(token),token=tokenList.step()}return coder}#peekAfterCollection(tokenList,openId,closeId){const start=tokenList.position;this.#parseCollectionToCode(tokenList,openId,closeId);const token=tokenList.current,end=tokenList.position;return tokenList.stepBack(end-start),token}#atEndOfExpression(token){return[Divider.TERMINATOR,Divider.SEPARATOR].includes(token.value)||[List.CLOSE,Group.CLOSE,Scope.CLOSE].includes(token.value)||isRootKeyword(token.value)}#isIdentifier(token){return token.isType(TokenType.IDENTIFIER)||token.isType(TokenType.KEYWORD)&&isContextualKeyword(token.value)}}class ClassMerger{merge(model,parent){const constructors=void 0!==model.construct?[model.construct]:[],members=[...this.#mergeMembers(model.fields,parent.fields),...constructors,...this.#mergeMembers(model.methods,parent.methods),...this.#mergeMembers(model.getters,parent.getters),...this.#mergeMembers(model.setters,parent.setters)];return new ESClass(model.identifier,parent.identifier,members)}#mergeMembers(model,parent){const members=new Map;return parent.forEach(member=>members.set(member.identifier,member)),model.forEach(member=>members.set(member.identifier,member)),[...members.values()]}}class Reflector{#parser=new Parser;#merger=new ClassMerger;fromModule(module,inherit=!1){const entries=Object.entries(module),members=[];for(const[key,member]of entries){if("function"!=typeof member.toString)continue;const code=member.toString();if(code.startsWith("class"))members.push(this.fromClass(member,inherit));else if(code.startsWith("function"))members.push(this.fromFunction(member));else{const binding=new ESIdentifierBinding(key,!1),expression=new ESExpression(code);members.push(new ESVariable("var",binding,expression))}}return new ESModule(members)}fromClass(clazz,inherit=!1){const model=this.isClass(clazz)?this.#reflectClassStatic(clazz):this.#reflectClassDynamic(clazz);if(!1===inherit)return model;const parentClazz=this.getParentClass(clazz);if(""===parentClazz.name)return model;const parentModel=this.fromClass(parentClazz,!0);return this.#merger.merge(model,parentModel)}fromObject(object,inherit=!0){const clazz=this.getClass(object);return this.fromClass(clazz,inherit)}fromFunction(funktion){const code=funktion.toString();return this.#parser.parseFunction(code)}createInstance(clazz,args=[]){return new clazz(...args)}getClass(object){return object.constructor}getParentClass(clazz){return Object.getPrototypeOf(clazz)}isClassObject(object){return this.isClass(object.constructor)}isFunctionObject(object){return this.isFunction(object.constructor)}isClass(clazz){return clazz.toString().startsWith("class")}isFunction(clazz){return clazz.toString().startsWith("function")||clazz.toString().startsWith("async function")}#reflectClassStatic(clazz){const code=clazz.toString();return this.#parser.parseClass(code)}#reflectClassDynamic(clazz){const instance=this.createInstance(clazz),members=this.#getClassMembers(clazz,instance);return new ESClass(clazz.name,void 0,members)}#getClassMembers(clazz,instance){return[...this.#getClassFields(instance),...this.#getClassMethods(clazz)]}#getClassFields(instance){const fieldNames=Object.getOwnPropertyNames(instance),values=instance,models=[];for(const fieldName of fieldNames){const content=values[fieldName],initializer=void 0!==content?new ESExpression(String(content)):void 0,model=new ESField(fieldName,"public","instance",initializer);models.push(model)}return models}#getClassMethods(clazz){const functionDescriptions=Object.getOwnPropertyDescriptors(clazz.prototype),models=[];for(const functionName in functionDescriptions){const description=functionDescriptions[functionName],method=description.value;if(method instanceof Function==!1)continue;const model=this.fromFunction(method);"constructor"===model.identifier?models.push(new ESConstructor(model.parameters,model.body)):void 0!==description.get?models.push(new ESGetter(model.identifier,"public","instance",model.body)):void 0!==description.set?models.push(new ESSetter(model.identifier,"public","instance",model.parameters[0],model.body)):models.push(new ESMethod(model.identifier,"public","instance",model.parameters,model.body,model.isAsync))}return models}}const reflector$1=new Reflector;class ClassSerializer extends ValueSerializer{#classResolver;constructor(classResolver){super(),this.#classResolver=classResolver}canSerialize(value){return value instanceof Object&&reflector$1.isClassObject(value)}canDeserialize(value){const object=value;return object instanceof Object&&!0===object.serialized&&"class"===object.name&&"string"==typeof object.key&&object.args instanceof Object&&object.args.constructor===Object&&object.fields instanceof Object&&object.fields.constructor===Object}async serialize(object){const clazz=reflector$1.getClass(object),model=reflector$1.fromClass(clazz,!0),parameterNames=this.#extractConstructorParameters(model),key=this.#classResolver.resolveKey(clazz);if(void 0===key)throw new ClassNotFound(clazz.name);return{serialized:!0,key:key,name:"class",args:await this.#serializeConstructor(model,parameterNames,object),fields:await this.#serializeFields(model,parameterNames,object)}}#extractConstructorParameters(model){const constructor=model.construct;return(constructor?.parameters??[]).map(parameter=>parameter.binding.identifier)}async#serializeConstructor(model,includeNames,object){const args={};for(const[index,name]of includeNames.entries()){const value=model.canRead(name)?await this.serializeOther(object[name]):void 0;args[index.toString()]=value}return args}async#serializeFields(model,excludeNames,object){const fields={};for(const property of model.writable){const name=property.identifier;excludeNames.includes(name)||!1===model.canRead(name)||(fields[name]=await this.serializeOther(object[name]))}return fields}async deserialize(object){const clazz=await this.#getClass(object);if(void 0===clazz)throw new ClassNotFound(object.key);if(clazz instanceof Function==!1)throw new InvalidClass(object.key);const args=await this.#deserializeConstructor(clazz,object.args),instance=reflector$1.createInstance(clazz,args);for(const name in object.fields){const fieldValue=object.fields[name];instance[name]=await this.deserializeOther(fieldValue)}return instance}async#deserializeConstructor(clazz,args){const constructor=reflector$1.fromClass(clazz,!0).construct,values=(constructor?.parameters??[]).map((_,index)=>{const key=index.toString(),value=args[key];return this.deserializeOther(value)});return Promise.all(values)}async#getClass(resolvable){return globalThis[resolvable.key]??this.#classResolver.resolveClass(resolvable.key)}}class InvalidDateString extends Error{constructor(dateString){super(`Invalid date string '${dateString}'`)}}class DateSerializer extends ValueSerializer{canSerialize(value){return value instanceof Date}canDeserialize(value){const date=value;return date instanceof Object&&!0===date.serialized&&"Date"===date.name&&"string"==typeof date.value}async serialize(date){return{serialized:!0,name:"Date",value:date.toISOString()}}async deserialize(object){const date=new Date(object.value);if("Invalid Date"===date.toString())throw new InvalidDateString(object.value);return date}}class ErrorSerializer extends ValueSerializer{canSerialize(value){if(value instanceof Object==!1)return!1;const error=value;return error.constructor===Error||error.constructor===EvalError||error.constructor===RangeError||error.constructor===ReferenceError||error.constructor===SyntaxError||error.constructor===TypeError||error.constructor===URIError||error.constructor===AggregateError}canDeserialize(value){const error=value;return error instanceof Object&&!0===error.serialized&&"Error"===error.name&&error.type in globalThis}async serialize(error){return{serialized:!0,name:"Error",type:error.constructor.name,stack:error.stack,message:error.message,cause:error.cause}}async deserialize(object){const error=new(0,globalThis[object.type])(object.message,{cause:object.cause});return error.stack=object.stack,error}}class MapSerializer extends ValueSerializer{canSerialize(value){return value instanceof Map}canDeserialize(value){const map=value;return map instanceof Object&&!0===map.serialized&&"Map"===map.name&&map.entries instanceof Object&&map.entries.keys instanceof Array&&map.entries.values instanceof Array}async serialize(map){const keys=[],values=[];for(const[key,value]of map)keys.push(await this.serializeOther(key)),values.push(await this.serializeOther(value));return{serialized:!0,name:"Map",entries:{keys:keys,values:values}}}async deserialize(object){const keys=object.entries.keys,values=object.entries.values,result=new Map;for(let index=0;index<keys.length;index++){const key=await this.deserializeOther(keys[index]),value=await this.deserializeOther(values[index]);result.set(key,value)}return result}}class ObjectSerializer extends ValueSerializer{canSerialize(value){return value instanceof Object&&value.constructor===Object}canDeserialize(value){return value instanceof Object&&value.constructor===Object}async serialize(object){const result={};for(const key in object){const value=object[key];result[key]=await this.serializeOther(value)}return result}async deserialize(object){const result={};for(const key in object){const value=object[key];result[key]=await this.deserializeOther(value)}return result}}class PrimitiveSerializer extends ValueSerializer{canSerialize(value){return value instanceof Object==!1}canDeserialize(value){return value instanceof Object==!1}async serialize(primitive){return primitive}async deserialize(primitive){return primitive}}class InvalidRegExp extends Error{constructor(source,flags){super(`Invalid regular expression '${source}' with flags '${flags}'`)}}class RegExpSerializer extends ValueSerializer{canSerialize(value){return value instanceof RegExp}canDeserialize(value){const regExp=value;return regExp instanceof Object&&!0===regExp.serialized&&"RegExp"===regExp.name&&"string"==typeof regExp.source&&"string"==typeof regExp.flags}async serialize(regExp){return{serialized:!0,name:"RegExp",source:regExp.source,flags:regExp.flags}}async deserialize(object){try{return new RegExp(object.source,object.flags)}catch{throw new InvalidRegExp(object.source,object.flags)}}}class SetSerializer extends ValueSerializer{canSerialize(value){return value instanceof Set}canDeserialize(value){const set=value;return set instanceof Object&&!0===set.serialized&&"Set"===set.name&&set.values instanceof Array}async serialize(set){const values=[];for(const value of set.values())values.push(await this.serializeOther(value));return{serialized:!0,name:"Set",values:values}}async deserialize(object){const values=await Promise.all(object.values.map(async value=>this.deserializeOther(value)));return new Set([...values])}}const reflector=new Reflector;class ArrayBufferSerializer extends ValueSerializer{canSerialize(value){return value instanceof Int8Array||value instanceof Uint8Array||value instanceof Uint8ClampedArray||value instanceof Int16Array||value instanceof Uint16Array||value instanceof Int32Array||value instanceof Uint32Array||value instanceof Float32Array||value instanceof Float64Array||value instanceof BigInt64Array||value instanceof BigUint64Array}canDeserialize(value){const array=value;return array instanceof Object&&!0===array.serialized&&"TypedArray"===array.name&&array.type in globalThis&&array.bytes instanceof Array}async serialize(array){const type=array.constructor.name,view=new DataView(array.buffer),bytes=[];for(let index=0;index<view.byteLength;index++)bytes.push(view.getUint8(index));return{serialized:!0,name:"TypedArray",type:type,bytes:bytes}}async deserialize(object){const type=object.type,bytes=object.bytes,buffer=new ArrayBuffer(bytes.length),view=new DataView(buffer);for(let index=0;index<bytes.length;index++)view.setUint8(index,bytes[index]);const clazz=globalThis[type];return reflector.createInstance(clazz,[buffer])}}class InvalidUrlString extends Error{constructor(urlString){super(`Invalid url string '${urlString}'`)}}class UrlSerializer extends ValueSerializer{canSerialize(value){return value instanceof URL}canDeserialize(value){const url=value;return url instanceof Object&&!0===url.serialized&&"Url"===url.name&&"string"==typeof url.value}async serialize(url){return{serialized:!0,name:"Url",value:url.toString()}}async deserialize(object){try{return new URL(object.value)}catch{throw new InvalidUrlString(object.value)}}}class SerializerBuilder{static build(classResolver){const serializer=new Serializer;return serializer.addSerializer(new PrimitiveSerializer),serializer.addSerializer(new ObjectSerializer),void 0!==classResolver&&serializer.addSerializer(new ClassSerializer(classResolver)),serializer.addSerializer(new ErrorSerializer),serializer.addSerializer(new RegExpSerializer),serializer.addSerializer(new BigIntSerializer),serializer.addSerializer(new UrlSerializer),serializer.addSerializer(new DateSerializer),serializer.addSerializer(new SetSerializer),serializer.addSerializer(new MapSerializer),serializer.addSerializer(new ArraySerializer),serializer.addSerializer(new ArrayBufferSerializer),"undefined"!=typeof Buffer&&serializer.addSerializer(new BufferSerializer),serializer}}class ExecutionClassResolver{#executionManager;constructor(executionManager){this.#executionManager=executionManager}resolveKey(clazz){const model=this.#executionManager.getClassByImplementation(clazz);return model?.fqn}resolveClass(key){const model=this.#executionManager.getClass(key);return model?.implementation}}const segment=new Segment("@jitar"),implementationNotFound=new Class("@jitar/execution/ImplementationNotFound",ImplementationNotFound),invalidParameterValue=new Class("@jitar/execution/InvalidParameterValue",InvalidParameterValue),invalidVersionNumber=new Class("@jitar/execution/InvalidVersionNumber",InvalidVersionNumber),missingParameterValue=new Class("@jitar/execution/MissingParameterValue",MissingParameterValue),procedureNotFound=new Class("@jitar/execution/ProcedureNotFound",ProcedureNotFound),unknownParameter=new Class("@jitar/execution/UnknownParameter",UnknownParameter);segment.addClass(implementationNotFound),segment.addClass(invalidParameterValue),segment.addClass(invalidVersionNumber),segment.addClass(missingParameterValue),segment.addClass(procedureNotFound),segment.addClass(unknownParameter);class ClientBuilder{#remoteBuilder;constructor(remoteBuilder){this.#remoteBuilder=remoteBuilder}build(configuration){const remoteUrl=configuration.remoteUrl,middleware=configuration.middleware,segments=configuration.segments,logger=new Logger(configuration.logLevel??LogLevels_WARN),remote=this.#remoteBuilder.build(remoteUrl),sourcingManager=new RemoteSourcingManager(remoteUrl),healthManager=this.#buildHealthManager(sourcingManager),middlewareManager=this.#buildMiddlewareManager(sourcingManager,middleware),executionManager=this.#buildExecutionManager(sourcingManager,segments),serializer=this.#buildSerializer(executionManager),scheduleManager=this.#buildScheduleManager(logger);return new Client({remoteUrl:remoteUrl,remote:remote,healthManager:healthManager,middlewareManager:middlewareManager,executionManager:executionManager,serializer:serializer,scheduleManager:scheduleManager})}#buildHealthManager(sourcingManager){return new HealthManager(sourcingManager)}#buildMiddlewareManager(sourcingManager,middleware=[]){const manager=new MiddlewareManager(sourcingManager);return middleware.forEach(middleware=>manager.addMiddleware(middleware)),manager}#buildExecutionManager(sourcingManager,segments=[]){const manager=new ExecutionManager(sourcingManager);return segments.forEach(segment=>manager.addSegment(segment)),manager.addSegment(segment),manager}#buildSerializer(executionManager){const classResolver=new ExecutionClassResolver(executionManager);return SerializerBuilder.build(classResolver)}#buildScheduleManager(logger){return new ScheduleManager(logger)}}class Validator{#strict;constructor(strict=!0){this.#strict=strict}validate(data,scheme){const errors=[];this.#validateData("",data,scheme,errors);return{valid:0===errors.length,errors:errors}}#validateData(key,data,scheme,errors){this.#strict&&this.#validateKeys(key,data,scheme,errors),this.#validateValues(key,data,scheme,errors)}#validateKeys(key,data,scheme,errors){const dataKeys=Object.keys(data),schemeKeys=Object.keys(scheme);for(const dataKey of dataKeys)if(!1===schemeKeys.includes(dataKey)){const absoluteKey=this.#composeKey(key,dataKey);errors.push(`Unknown field '${absoluteKey}'`)}}#validateValues(key,data,scheme,errors){const valueKeys=Object.keys(scheme);for(const valueKey of valueKeys){const absoluteKey=this.#composeKey(key,valueKey),fieldScheme=scheme[valueKey],value=data[valueKey];this.#validateValue(absoluteKey,value,fieldScheme,errors)}}#validateValue(key,value,scheme,errors){if(void 0!==value)switch(scheme.type){case"string":return this.#validateString(key,value,scheme,errors);case"integer":return this.#validateInteger(key,value,scheme,errors);case"real":return this.#validateReal(key,value,scheme,errors);case"boolean":return this.#validateBoolean(key,value,scheme,errors);case"url":return this.#validateUrl(key,value,scheme,errors);case"group":return this.#validateGroup(key,value,scheme,errors);case"list":return this.#validateList(key,value,scheme,errors);case"enum":return this.#validateEnum(key,value,scheme,errors)}else!0===scheme.required&&errors.push(`Field '${key}' is required`)}#validateString(key,value,scheme,errors){"string"!=typeof value&&errors.push(`Field '${key}' is not a string`)}#validateInteger(key,value,scheme,errors){"number"==typeof value&&!1!==Number.isInteger(value)||errors.push(`Field '${key}' is not an integer`)}#validateReal(key,value,scheme,errors){"number"!=typeof value&&errors.push(`Field '${key}' is not a real number`)}#validateBoolean(key,value,scheme,errors){"boolean"!=typeof value&&errors.push(`Field '${key}' is not a boolean`)}#validateUrl(key,value,scheme,errors){"string"==typeof value&&!1!==value.startsWith("http")||errors.push(`Field '${key}' is not a valid URL`)}#validateGroup(key,value,scheme,errors){"object"==typeof value?this.#validateData(key,value,scheme.fields,errors):errors.push(`Field '${key}' is not an object`)}#validateList(key,value,scheme,errors){if(!Array.isArray(value))return void errors.push(`Field '${key}' is not a list`);const data=value;for(const itemIndex in data){const itemKey=this.#composeKey(key,itemIndex),itemValue=data[itemIndex];this.#validateValue(itemKey,itemValue,scheme.items,errors)}}#validateEnum(key,value,scheme,errors){if(!1===scheme.options.includes(value)){const options=scheme.options.map(option=>String(option));errors.push(`Field '${key}' is not one of: ${options.join(", ")}`)}}#composeKey(parent,key){return""===parent?key:`${parent}.${key}`}}const HeaderKeys_CONTENT_TYPE="content-type",HeaderKeys_JITAR_CONTENT_TYPE="x-jitar-content-type",HeaderKeys_JITAR_PROCEDURE_VERSION="x-jitar-procedure-version",HeaderValues_APPLICATION_JSON="application/json",HeaderValues_APPLICATION_STREAM="application/octet-stream";class InvalidWorkerId extends Error{constructor(){super("Invalid worker id")}}class HttpRemote{#url;#httpClient;#errorConverter=new ErrorConverter;#validator=new Validator;constructor(url,httpClient){this.#url=url,this.#httpClient=httpClient}connect(){return Promise.resolve()}disconnect(){return Promise.resolve()}async provide(filename){const remoteUrl=`${this.#url}/${filename}`,response=await this.#callRemote(remoteUrl,{method:"GET"}),type=response.headers.get(HeaderKeys_CONTENT_TYPE)??HeaderValues_APPLICATION_STREAM,result=await response.arrayBuffer(),content=Buffer.from(result);return new File(filename,type,content)}async isHealthy(){const remoteUrl=`${this.#url}/health/status`,response=await this.#callRemote(remoteUrl,{method:"GET"});return"true"===await response.text()}async getHealth(){const remoteUrl=`${this.#url}/health`,response=await this.#callRemote(remoteUrl,{method:"GET"}),health=await response.json();return new Map(Object.entries(health))}async addWorker(url,procedureNames,trustKey){const remoteUrl=`${this.#url}/workers`,body={url:url,procedureNames:procedureNames,trustKey:trustKey},options={method:"POST",headers:{"Content-Type":HeaderValues_APPLICATION_JSON},body:JSON.stringify(body)},response=await this.#callRemote(remoteUrl,options),contentType=response.headers.get(HeaderKeys_CONTENT_TYPE);if(null===contentType||!1===contentType.includes(HeaderValues_APPLICATION_JSON))throw new InvalidWorkerId;const result=await response.json();if(!1===this.#validator.validate(result,{id:{type:"string",required:!0}}).valid)throw new InvalidWorkerId;return result.id}async reportWorker(id,state){const remoteUrl=`${this.#url}/workers/${id}/report`,body={state:state},options={method:"POST",headers:{"Content-Type":HeaderValues_APPLICATION_JSON},body:JSON.stringify(body)};await this.#callRemote(remoteUrl,options)}async removeWorker(id){const remoteUrl=`${this.#url}/workers/${id}`,options={method:"DELETE",headers:{"Content-Type":HeaderValues_APPLICATION_JSON}};await this.#callRemote(remoteUrl,options)}async run(request){request.setHeader(HeaderKeys_CONTENT_TYPE,HeaderValues_APPLICATION_JSON);const argsObject=Object.fromEntries(request.args),headersObject=Object.fromEntries(request.headers),versionString=request.version.toString();headersObject[HeaderKeys_JITAR_PROCEDURE_VERSION]=versionString;const remoteUrl=`${this.#url}/rpc/${request.fqn}`,options={method:"POST",redirect:"manual",headers:headersObject,body:await this.#createRequestBody(argsObject)},response=await this.#callRemote(remoteUrl,options,!1),status=response.status,result=await this.#getResponseResult(response),headers=this.#createResponseHeaders(response);return new Response(status,result,headers)}async#callRemote(remoteUrl,options,throwOnError=!0){const response=await this.#httpClient.execute(remoteUrl,options);if(throwOnError&&this.#isErrorResponse(response)){const result=await this.#getResponseResult(response);throw this.#errorConverter.fromStatus(response.status,String(result))}return response}#isErrorResponse(response){return response.status<200||response.status>399}async#createRequestBody(body){return JSON.stringify(body)}async#getResponseResult(response){const contentType=response.headers.get(HeaderKeys_JITAR_CONTENT_TYPE)??response.headers.get(HeaderKeys_CONTENT_TYPE);if(contentType?.includes("undefined"))return;if(contentType?.includes("null"))return null;if(contentType?.includes("json"))return response.json();const content=await response.text();return contentType?.includes("boolean")?"true"===content:contentType?.includes("number")?Number(content):content}#createResponseHeaders(response){const headers=new Map;for(const[name,value]of response.headers)headers.set(name,value);return headers}}class FetchHttpClient{async execute(url,options){return fetch(url,options)}}class HttpRemoteBuilder{#httpClient;constructor(httpClient=new FetchHttpClient){this.#httpClient=httpClient}build(url){return new HttpRemote(url,this.#httpClient)}}export{ArrayParameter,BadRequest,Class,ClientBuilder,Forbidden,HttpRemoteBuilder,Implementation,NamedParameter,NotFound,NotImplemented,ObjectParameter,PaymentRequired,Procedure,Request,Response,Segment,ServerError,Teapot,Unauthorized,Version};
|
package/dist/lib.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{y as Version,z as AccessLevels,q as ProjectFileManager,L as LocalFileManager,r as Reader,s as Files,o as LocalGenerator,p as RemoteGenerator,G as Generator}from"./ConfigurationManager-DfsjmZaq.js";export{A as ArrayParameter,B as BadRequest,x as Class,C as ConfigurationManager,F as Forbidden,j as NamedParameter,N as NotFound,k as NotImplemented,O as ObjectParameter,l as PaymentRequired,v as Request,R as Response,m as Segment,S as ServerError,T as Teapot,U as Unauthorized}from"./ConfigurationManager-DfsjmZaq.js";import"node:fs";import"node:path";import"glob";import"mime-types";import"dotenv";class Procedure{#fqn;#implementations=new Map;#latestImplementation;constructor(fqn){this.#fqn=fqn}get fqn(){return this.#fqn}get public(){return[...this.#implementations.values()].some(implementation=>implementation.public)}get protected(){return[...this.#implementations.values()].some(implementation=>implementation.protected)}addImplementation(implementation){return this.#implementations.set(implementation.version,implementation),this.#isNewLatestImplementation(implementation)&&(this.#latestImplementation=implementation),this}#isNewLatestImplementation(implementation){return void 0===this.#latestImplementation||implementation.version.greater(this.#latestImplementation.version)}getImplementation(version){const selectedVersion=this.#selectAvailableVersion(version);return this.#implementations.get(selectedVersion)}#selectAvailableVersion(version){let selectedVersion=Version.DEFAULT;for(const implementationVersion of this.#implementations.keys()){if(implementationVersion.equals(version))return implementationVersion;implementationVersion.greater(version)||selectedVersion.less(implementationVersion)&&(selectedVersion=implementationVersion)}return selectedVersion}}class Implementation{#version;#access;#parameters;#executable;constructor(version,access,parameters,executable){this.#version=version,this.#access=access,this.#parameters=parameters,this.#executable=executable}get version(){return this.#version}get public(){return this.#access===AccessLevels.PUBLIC}get protected(){return this.#access===AccessLevels.PROTECTED}get private(){return this.#access===AccessLevels.PRIVATE}get parameters(){return this.#parameters}get executable(){return this.#executable}}class ApplicationNotRead extends Error{constructor(){super("Application not read")}}class ApplicationModuleNotFound extends Error{constructor(filename){super(`Application module not found '${filename}'`)}}class ApplicationSegmentNotFound extends Error{constructor(segmentName){super(`Application segment not found '${segmentName}'`)}}class BuildHelper{#fileManager;#applicationReader;#application;constructor(configuration){this.#fileManager=new ProjectFileManager(new LocalFileManager(configuration.source,configuration.meta.root),new LocalFileManager(configuration.target,configuration.meta.root),new LocalFileManager(configuration.resources,configuration.meta.root),new LocalFileManager(configuration.segments,configuration.meta.root),configuration.build.ignore),this.#applicationReader=new Reader(this.#fileManager)}async readApplication(){const sourceFileManager=this.#fileManager.source,resourceFileManager=this.#fileManager.resource,segmentFileManager=this.#fileManager.segment,moduleFiles=await sourceFileManager.filterWithIgnores(Files.MODULE_PATTERN,this.#fileManager.sourceIgnores),resourceFiles=await resourceFileManager.filter(Files.RESOURCE_PATTERN),segmentFiles=await segmentFileManager.filter(Files.SEGMENT_PATTERN);this.#application=await this.#applicationReader.read(moduleFiles,resourceFiles,segmentFiles)}includesModule(filename){return void 0!==this.#getApplication().repository.get(filename)}generateModuleCode(filename,segmentNames=[]){const application=this.#getApplication(),module=application.repository.get(filename);if(void 0===module)throw new ApplicationModuleNotFound(filename);const resources=application.resources,segmentation=application.segmentation,segments=segmentation.getSegments(filename);if(0===segments.length){return new LocalGenerator(module,resources,segmentation).generate()}if(void 0===segments.find(segment=>segmentNames.includes(segment.name))){return new RemoteGenerator(module,segments).generate()}return new LocalGenerator(module,resources,segmentation).generate()}generateSegmentCode(segmentName){const segment=this.#getApplication().segmentation.getSegment(segmentName);if(void 0===segment)throw new ApplicationSegmentNotFound(segmentName);return new Generator(segment).generate()}#getApplication(){if(void 0===this.#application)throw new ApplicationNotRead;return this.#application}}export{BuildHelper,Implementation,Procedure,Version};
|
|
@@ -11,18 +11,21 @@
|
|
|
11
11
|
"standalone": "jitar start --service=services/standalone.json"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"jitar": "^0.
|
|
15
|
-
"react": "^19.
|
|
16
|
-
"react-dom": "^19.
|
|
14
|
+
"jitar": "^0.12.0",
|
|
15
|
+
"react": "^19.3.1",
|
|
16
|
+
"react-dom": "^19.3.1"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
|
-
"@jitar/plugin-vite": "^0.
|
|
19
|
+
"@jitar/plugin-vite": "^0.12.0",
|
|
20
20
|
"@types/node": "^24.12.4",
|
|
21
|
-
"@types/react": "^19.
|
|
22
|
-
"@types/react-dom": "^19.
|
|
23
|
-
"@vitejs/plugin-react": "^
|
|
21
|
+
"@types/react": "^19.3.0",
|
|
22
|
+
"@types/react-dom": "^19.3.0",
|
|
23
|
+
"@vitejs/plugin-react": "^6.1.2",
|
|
24
24
|
"rimraf": "^6.1.3",
|
|
25
|
-
"typescript": "^
|
|
26
|
-
"vite": "^
|
|
25
|
+
"typescript": "^7.0.2",
|
|
26
|
+
"vite": "^8.3.5"
|
|
27
|
+
},
|
|
28
|
+
"allowScripts": {
|
|
29
|
+
"fsevents@2.3.3": true
|
|
27
30
|
}
|
|
28
31
|
}
|
|
@@ -11,17 +11,20 @@
|
|
|
11
11
|
"standalone": "jitar start --service=services/standalone.json"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"jitar": "^0.
|
|
15
|
-
"vue": "^3.5.
|
|
14
|
+
"jitar": "^0.12.0",
|
|
15
|
+
"vue": "^3.5.44"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
18
|
"@types/node": "^24.12.4",
|
|
19
|
-
"@jitar/plugin-vite": "^0.
|
|
20
|
-
"@vitejs/plugin-vue": "^6.0.
|
|
19
|
+
"@jitar/plugin-vite": "^0.12.0",
|
|
20
|
+
"@vitejs/plugin-vue": "^6.0.10",
|
|
21
21
|
"@vue/tsconfig": "^0.9.1",
|
|
22
22
|
"rimraf": "^6.1.3",
|
|
23
|
-
"typescript": "
|
|
24
|
-
"vite": "^
|
|
25
|
-
"vue-tsc": "^3.3.
|
|
23
|
+
"typescript": "6.0.3",
|
|
24
|
+
"vite": "^8.3.5",
|
|
25
|
+
"vue-tsc": "^3.3.13"
|
|
26
|
+
},
|
|
27
|
+
"allowScripts": {
|
|
28
|
+
"fsevents@2.3.3": true
|
|
26
29
|
}
|
|
27
30
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
declare module '*.css' {}
|